package.dist.TableSelection.js.map Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webcomponents Show documentation
Show all versions of webcomponents Show documentation
UI5 Web Components: webcomponents.main
The newest version!
{"version":3,"file":"TableSelection.js","sourceRoot":"","sources":["../src/TableSelection.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACN,SAAS,EACT,OAAO,GACP,MAAM,sCAAsC,CAAC;AAC9C,OAAO,gBAAgB,MAAM,uDAAuD,CAAC;AACrF,OAAO,UAAU,MAAM,4CAA4C,CAAC;AACpE,OAAO,aAAa,MAAM,0DAA0D,CAAC;AACrF,OAAO,QAAQ,MAAM,qDAAqD,CAAC;AAC3E,OAAO,KAAK,MAAM,kDAAkD,CAAC;AACrE,OAAO,kBAAkB,MAAM,+BAA+B,CAAC;AAK/D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAUH,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QACC;;;;;WAKG;QAEH,SAAI,GAA4B,UAAU,CAAC;QAE3C;;;;;WAKG;QAEH,aAAQ,GAAG,EAAE,CAAC;QAEL,eAAU,GAAG,gBAAgB,CAAC;IA2SxC,CAAC;IAvSA,eAAe,CAAC,KAAY;QAC3B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IAChC,CAAC;IAED,SAAS;QACR,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC,IAAI,CAAC;QACpC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IACzB,CAAC;IAED,iBAAiB;QAChB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IAChC,CAAC;IAED,YAAY;QACX,OAAO,IAAI,CAAC,IAAI,KAAK,kBAAkB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C;SAC9B;QAED,gBAAgB,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED,mBAAmB;QAClB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED,sBAAsB;QACrB,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7C,IAAI,GAAG,EAAE;YACR,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;SAC5B;QAED,IAAI,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5C,IAAI,CAAC,eAAe,CAAC,IAAI,GAAG,IAAI,CAAC;SACjC;IACF,CAAC;CACD,CAAA;AAtTA;IADC,QAAQ,EAAE;4CACgC;AAS3C;IADC,QAAQ,EAAE;gDACG;AAjBT,cAAc;IATnB,aAAa,CAAC,EAAE,GAAG,EAAE,qBAAqB,EAAE,CAAC;IAE9C;;;;OAIG;;IACF,KAAK,CAAC,QAAQ,CAAC;GAEV,cAAc,CA8TnB;AAED,cAAc,CAAC,MAAM,EAAE,CAAC;AAExB,eAAe,cAAc,CAAC","sourcesContent":["import {\n\tisUpShift,\n\tisShift,\n} from \"@ui5/webcomponents-base/dist/Keys.js\";\nimport getActiveElement from \"@ui5/webcomponents-base/dist/util/getActiveElement.js\";\nimport UI5Element from \"@ui5/webcomponents-base/dist/UI5Element.js\";\nimport customElement from \"@ui5/webcomponents-base/dist/decorators/customElement.js\";\nimport property from \"@ui5/webcomponents-base/dist/decorators/property.js\";\nimport event from \"@ui5/webcomponents-base/dist/decorators/event.js\";\nimport TableSelectionMode from \"./types/TableSelectionMode.js\";\nimport type Table from \"./Table.js\";\nimport type { ITableFeature } from \"./Table.js\";\nimport type TableRow from \"./TableRow.js\";\nimport type TableRowBase from \"./TableRowBase.js\";\nimport { isSelectionCheckbox, isHeaderSelector, findRowInPath } from \"./TableUtils.js\";\n\n/**\n * @class\n *\n * ### Overview\n *\n * The `ui5-table-selection` component is used inside the `ui5-table` ti add key-based selection capabilities to the `ui5-table`.\n *\n * The component offers three selection modes:\n * * Single - select a single row.\n * * Multiple - select multiple rows.\n * * None - no selection active.\n *\n * As the selection is key-based, `ui5-table-row` components need to define a unique `row-key` property.\n *\n * ### Usage\n *\n * The `ui5-table-selection` component is only used inside the `ui5-table` component as a feature.\n * It has to be slotted inside the `ui5-table` in the `features` slot.\n * The component is not intended to be used as a standalone component.\n *\n * ```html\n * \n * \t \n * \n * ```\n *\n * ### ES6 Module Import\n *\n * `import \"@ui5/webcomponents/dist/TableSelection.js\";`\n *\n * @constructor\n * @extends UI5Element\n * @since 2.0.0\n * @public\n * @experimental This web component is available since 2.0 with an experimental flag and its API and behavior are subject to change.\n */\n@customElement({ tag: \"ui5-table-selection\" })\n\n/**\n * Fired when selection is changed by user interaction.\n *\n * @public\n */\n@event(\"change\")\n\nclass TableSelection extends UI5Element implements ITableFeature {\n\t/**\n\t * Defines the selection mode.\n\t *\n\t * @default \"Multiple\"\n\t * @public\n\t */\n\t@property()\n\tmode: `${TableSelectionMode}` = \"Multiple\";\n\n\t/**\n\t * Defines the selected rows separated by a space.\n\t *\n\t * @default \"\"\n\t * @public\n\t */\n\t@property()\n\tselected = \"\";\n\n\treadonly identifier = \"TableSelection\";\n\t_table?: Table;\n\t_rangeSelection?: {selected: boolean, isUp: boolean | null, rows: TableRow[], isMouse: boolean, shiftPressed: boolean} | null;\n\n\tonTableActivate(table: Table) {\n\t\tthis._table = table;\n\t\tthis._invalidateTableAndRows();\n\t}\n\n\tonExitDOM() {\n\t\tthis.mode = TableSelectionMode.None;\n\t\tthis._invalidateTableAndRows();\n\t\tthis._table = undefined;\n\t}\n\n\tonBeforeRendering() {\n\t\tthis._invalidateTableAndRows();\n\t}\n\n\tisSelectable(): boolean {\n\t\treturn this.mode !== TableSelectionMode.None;\n\t}\n\n\tisMultiSelect(): boolean {\n\t\treturn this.mode === TableSelectionMode.Multiple;\n\t}\n\n\thasRowSelector(): boolean {\n\t\treturn this.mode !== TableSelectionMode.None;\n\t}\n\n\tgetRowIdentifier(row: TableRow): string {\n\t\treturn row.rowKey;\n\t}\n\n\tisSelected(row: TableRowBase): boolean {\n\t\tif (!this._table || !this.isSelectable()) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (row.isHeaderRow()) {\n\t\t\treturn this.areAllRowsSelected();\n\t\t}\n\n\t\tconst rowIdentifier = this.getRowIdentifier(row as TableRow);\n\t\treturn this.selectedAsArray.includes(rowIdentifier);\n\t}\n\n\thasSelectedRow(): boolean {\n\t\tif (!this._table || !this.isSelectable()) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst selectedArray = this.selectedAsArray;\n\t\treturn this._table.rows.some(row => {\n\t\t\tconst rowIdentifier = this.getRowIdentifier(row);\n\t\t\treturn selectedArray.includes(rowIdentifier);\n\t\t});\n\t}\n\n\tareAllRowsSelected(): boolean {\n\t\tif (!this._table || !this._table.rows.length || this.mode !== TableSelectionMode.Multiple) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst selectedArray = this.selectedAsArray;\n\t\treturn this._table.rows.every(row => {\n\t\t\tconst rowIdentifier = this.getRowIdentifier(row);\n\t\t\treturn selectedArray.includes(rowIdentifier);\n\t\t});\n\t}\n\n\tinformSelectionChange(row: TableRowBase) {\n\t\tif (this._rangeSelection?.isMouse && this._rangeSelection.shiftPressed) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (row.isHeaderRow()) {\n\t\t\tthis._informHeaderRowSelectionChange();\n\t\t} else {\n\t\t\tthis._informRowSelectionChange(row as TableRow);\n\t\t}\n\t}\n\n\tget selectedAsArray(): string[] {\n\t\treturn this.selected.split(\" \").filter(String);\n\t}\n\n\tset selectedAsArray(selectedArray: string[]) {\n\t\tthis.selected = selectedArray.filter(String).join(\" \");\n\t}\n\n\tget selectedAsSet(): Set {\n\t\treturn new Set(this.selectedAsArray);\n\t}\n\n\tset selectedAsSet(selectedSet: Set) {\n\t\tthis.selectedAsArray = [...selectedSet];\n\t}\n\n\t_selectRow(row: TableRow, selected: boolean) {\n\t\tconst rowIdentifier = this.getRowIdentifier(row);\n\t\tif (this.mode === TableSelectionMode.Multiple) {\n\t\t\tconst selectedSet = this.selectedAsSet;\n\t\t\tselectedSet[selected ? \"add\" : \"delete\"](rowIdentifier);\n\t\t\tthis.selectedAsSet = selectedSet;\n\t\t} else {\n\t\t\tthis.selected = selected ? rowIdentifier : \"\";\n\t\t}\n\t}\n\n\t_informRowSelectionChange(row: TableRow) {\n\t\tconst isRowSelected = this.isMultiSelect() ? !this.isSelected(row) : true;\n\t\tthis._selectRow(row, isRowSelected);\n\t\tthis.fireEvent(\"change\");\n\t}\n\n\t_informHeaderRowSelectionChange() {\n\t\tconst isRowSelected = this.areAllRowsSelected();\n\t\tconst selectedSet = this.selectedAsSet;\n\t\tthis._table!.rows.forEach(row => {\n\t\t\tconst rowIdentifier = this.getRowIdentifier(row);\n\t\t\tselectedSet[isRowSelected ? \"delete\" : \"add\"](rowIdentifier);\n\t\t});\n\t\tthis.selectedAsSet = selectedSet;\n\t\tthis.fireEvent(\"change\");\n\t}\n\n\t_invalidateTableAndRows() {\n\t\tif (!this._table) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.isSelectable()) {\n\t\t\tthis.selected = \"\";\n\t\t} else if (!this.isMultiSelect()) {\n\t\t\tthis.selected = this.selectedAsArray.shift() || \"\";\n\t\t}\n\n\t\tthis._table._invalidate++;\n\t\tthis._table.headerRow[0]._invalidate++;\n\t\tthis._table.rows.forEach(row => row._invalidate++);\n\t}\n\n\t_onkeydown(e: KeyboardEvent) {\n\t\tif (!this.isMultiSelect() || !this._table || !e.shiftKey) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst focusedElement = getActiveElement(); // Assumption: The focused element is always the \"next\" row after navigation.\n\n\t\tif (!(focusedElement?.hasAttribute(\"ui5-table-row\") || this._rangeSelection?.isMouse || focusedElement?.hasAttribute(\"ui5-growing-row\"))) {\n\t\t\tthis._stopRangeSelection();\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this._rangeSelection) {\n\t\t\t// If no range selection is active, start one\n\t\t\tthis._startRangeSelection(focusedElement as TableRow);\n\t\t} else if (e.key === \"ArrowUp\" || e.key === \"ArrowDown\") {\n\t\t\tconst change = isUpShift(e) ? -1 : 1;\n\t\t\tthis._handleRangeSelection(focusedElement as TableRow, change);\n\t\t}\n\n\t\tif (this._rangeSelection) {\n\t\t\tthis._rangeSelection.shiftPressed = e.shiftKey;\n\t\t}\n\t}\n\n\t_onkeyup(e: KeyboardEvent, eventOrigin: HTMLElement) {\n\t\tif (!this._table) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!eventOrigin.hasAttribute(\"ui5-table-row\") || !this._rangeSelection || !isShift(e)) {\n\t\t\t// Stop range selection if a) Shift is relased or b) the event target is not a row or c) the event is not from the selection checkbox\n\t\t\tif (isSelectionCheckbox(e)) {\n\t\t\t\tthis._stopRangeSelection();\n\t\t\t}\n\t\t}\n\n\t\tif (this._rangeSelection) {\n\t\t\tthis._rangeSelection.shiftPressed = e.shiftKey;\n\t\t}\n\t}\n\n\t_onclick(e: MouseEvent) {\n\t\tif (!this._table) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (isHeaderSelector(e)) {\n\t\t\tthis._stopRangeSelection();\n\t\t\treturn;\n\t\t}\n\n\t\tif (!isSelectionCheckbox(e)) {\n\t\t\tthis._stopRangeSelection();\n\t\t\treturn;\n\t\t}\n\n\t\tconst row = findRowInPath(e.composedPath());\n\n\t\tif (e.shiftKey && this._rangeSelection?.isMouse) {\n\t\t\tconst startRow = this._rangeSelection.rows[0];\n\t\t\tconst startIndex = this._table.rows.indexOf(startRow);\n\t\t\tconst endIndex = this._table.rows.indexOf(row);\n\n\t\t\t// When doing a range selection and clicking on an already selected row, the checked status should not change\n\t\t\t// Therefore, we need to manually set the checked attribute again, as clicking it would deselect it and leads to\n\t\t\t// a visual inconsistency.\n\t\t\trow.shadowRoot?.querySelector(\"#selection-component\")?.toggleAttribute(\"checked\", true);\n\n\t\t\tif (startIndex === -1 || endIndex === -1 || row.rowKey === startRow.rowKey || row.rowKey === this._rangeSelection.rows[this._rangeSelection.rows.length - 1].rowKey) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst change = endIndex - startIndex;\n\t\t\tthis._handleRangeSelection(row, change);\n\t\t} else if (row) {\n\t\t\tthis._startRangeSelection(row, true);\n\t\t}\n\t}\n\n\t/**\n\t * Start the range selection and initialises the range selection state\n\t * @param row starting row\n\t * @private\n\t */\n\t_startRangeSelection(row: TableRow, isMouse = false) {\n\t\tconst selected = this.isSelected(row);\n\t\tif (isMouse && !selected) {\n\t\t\t// Do not initiate range selection if the row is not selected\n\t\t\treturn;\n\t\t}\n\n\t\tthis._rangeSelection = {\n\t\t\tselected,\n\t\t\tisUp: null,\n\t\t\trows: [row],\n\t\t\tisMouse,\n\t\t\tshiftPressed: false,\n\t\t};\n\t}\n\n\t/**\n\t * Handles the range selection\n\t * @param targetRow row that is currently focused\n\t * @param change indicates direction\n\t * @private\n\t */\n\t_handleRangeSelection(targetRow: TableRow, change: number) {\n\t\tif (!this._rangeSelection) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isUp = change > 0;\n\t\tthis._rangeSelection.isUp ??= isUp;\n\n\t\tconst shouldReverseSelection = isUp !== this._rangeSelection.isUp && !this._rangeSelection.isMouse;\n\t\tlet selectionChanged = shouldReverseSelection && this.isSelected(targetRow);\n\n\t\tif (shouldReverseSelection) {\n\t\t\tthis._reverseRangeSelection();\n\t\t} else {\n\t\t\tconst rowIndex = this._table!.rows.indexOf(targetRow);\n\t\t\tconst [startIndex, endIndex] = [rowIndex, rowIndex - change].sort((a, b) => a - b);\n\n\t\t\tselectionChanged = this._table?.rows.slice(startIndex, endIndex + 1).reduce((changed, row) => {\n\t\t\t\tconst isRowNotInSelection = !this._rangeSelection?.rows.includes(row);\n\t\t\t\tconst isRowSelectionDifferent = this.isSelected(row) !== this._rangeSelection!.selected;\n\n\t\t\t\tif (isRowNotInSelection) {\n\t\t\t\t\tthis._rangeSelection?.rows.push(row);\n\t\t\t\t}\n\n\t\t\t\tthis._selectRow(row, this._rangeSelection!.selected);\n\n\t\t\t\treturn changed || isRowSelectionDifferent;\n\t\t\t}, selectionChanged) || false;\n\t\t}\n\n\t\tselectionChanged && this._fireEvent(\"change\");\n\t}\n\n\t_stopRangeSelection() {\n\t\tthis._rangeSelection = null;\n\t}\n\n\t_reverseRangeSelection() {\n\t\tconst row = this._rangeSelection?.rows.pop();\n\t\tif (row) {\n\t\t\tthis._selectRow(row, false);\n\t\t}\n\n\t\tif (this._rangeSelection?.rows.length === 1) {\n\t\t\tthis._rangeSelection.isUp = null;\n\t\t}\n\t}\n}\n\nTableSelection.define();\n\nexport default TableSelection;\n"]}