@limetech/lime-elements 35.0.0-next.3 → 35.0.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/cjs/lime-elements.cjs.js +1 -1
  2. package/dist/cjs/limel-table.cjs.entry.js +308 -6
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/collection/components/table/columns.js +1 -1
  5. package/dist/collection/components/table/selection.js +111 -0
  6. package/dist/collection/components/table/table-selection.js +125 -0
  7. package/dist/collection/components/table/table.css +115 -32
  8. package/dist/collection/components/table/table.js +136 -3
  9. package/dist/collection/style/internal/z-index.scss +2 -1
  10. package/dist/esm/{component-2eb4e07b.js → component-834d85a1.js} +1 -1
  11. package/dist/esm/lime-elements.js +1 -1
  12. package/dist/esm/limel-checkbox.entry.js +1 -1
  13. package/dist/esm/limel-linear-progress.entry.js +1 -1
  14. package/dist/esm/limel-list_3.entry.js +2 -2
  15. package/dist/esm/limel-menu-list.entry.js +2 -2
  16. package/dist/esm/limel-slider.entry.js +1 -1
  17. package/dist/esm/limel-table.entry.js +308 -6
  18. package/dist/esm/loader.js +1 -1
  19. package/dist/esm/{util-71a23335.js → util-f1bde91c.js} +1 -1
  20. package/dist/lime-elements/lime-elements.esm.js +1 -1
  21. package/dist/lime-elements/{p-bc0dcf01.entry.js → p-8707d77b.entry.js} +1 -1
  22. package/dist/lime-elements/{p-31299106.js → p-90c6fa15.js} +1 -1
  23. package/dist/lime-elements/{p-6cfb45a1.entry.js → p-98d50f52.entry.js} +1 -1
  24. package/dist/lime-elements/{p-152a6d5f.js → p-9faad6eb.js} +1 -1
  25. package/dist/lime-elements/{p-96e44a1e.entry.js → p-a93f4190.entry.js} +1 -1
  26. package/dist/lime-elements/{p-13f0e4f4.entry.js → p-ce7a1004.entry.js} +1 -1
  27. package/dist/lime-elements/{p-b2a8cb31.entry.js → p-df8faeb4.entry.js} +1 -1
  28. package/dist/lime-elements/{p-64549ba6.entry.js → p-e275f502.entry.js} +2 -2
  29. package/dist/lime-elements/style/internal/z-index.scss +2 -1
  30. package/dist/types/components/table/columns.d.ts +7 -0
  31. package/dist/types/components/table/selection.d.ts +79 -0
  32. package/dist/types/components/table/table-selection.d.ts +57 -0
  33. package/dist/types/components/table/table.d.ts +31 -6
  34. package/dist/types/components.d.ts +24 -0
  35. package/package.json +1 -1
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["limel-color-picker.cjs",[[1,"limel-color-picker",{"value":[513],"label":[513],"helperText":[513,"helper-text"],"tooltipLabel":[513,"tooltip-label"],"required":[516],"readonly":[516],"isOpen":[32]}]]],["limel-picker.cjs",[[1,"limel-picker",{"disabled":[4],"readonly":[516],"label":[1],"searchLabel":[1,"search-label"],"helperText":[513,"helper-text"],"leadingIcon":[1,"leading-icon"],"emptyResultMessage":[1,"empty-result-message"],"required":[4],"value":[16],"searcher":[16],"multiple":[4],"delimiter":[513],"actions":[16],"actionPosition":[1,"action-position"],"actionScrollBehavior":[1,"action-scroll-behavior"],"badgeIcons":[516,"badge-icons"],"items":[32],"textValue":[32],"loading":[32],"chips":[32]}]]],["limel-date-picker.cjs",[[1,"limel-date-picker",{"disabled":[516],"readonly":[516],"invalid":[516],"label":[513],"helperText":[513,"helper-text"],"required":[516],"value":[16],"type":[513],"format":[513],"language":[513],"formattedValue":[32],"internalFormat":[32],"showPortal":[32]}]]],["limel-button-group.cjs",[[1,"limel-button-group",{"value":[16],"disabled":[516],"selectedButtonId":[32]}]]],["limel-select.cjs",[[1,"limel-select",{"disabled":[516],"readonly":[516],"invalid":[516],"required":[516],"label":[513],"helperText":[513,"helper-text"],"value":[16],"options":[16],"multiple":[4],"menuOpen":[32]}]]],["limel-tab-panel.cjs",[[1,"limel-tab-panel",{"tabs":[1040]}]]],["limel-file.cjs",[[1,"limel-file",{"value":[16],"label":[513],"required":[516],"disabled":[516],"readonly":[516],"accept":[513],"language":[1],"isDraggingOverDropZone":[32]}]]],["limel-menu.cjs",[[1,"limel-menu",{"items":[16],"disabled":[516],"openDirection":[513,"open-direction"],"open":[1540],"badgeIcons":[516,"badge-icons"],"gridLayout":[516,"grid-layout"]}]]],["limel-button.cjs",[[1,"limel-button",{"label":[513],"primary":[516],"outlined":[516],"icon":[513],"disabled":[516],"loading":[516]}]]],["limel-collapsible-section.cjs",[[1,"limel-collapsible-section",{"isOpen":[1540,"is-open"],"header":[513],"actions":[16]}]]],["limel-dialog.cjs",[[1,"limel-dialog",{"heading":[1],"fullscreen":[516],"open":[1540],"closingActions":[16]}]]],["limel-progress-flow.cjs",[[1,"limel-progress-flow",{"flowItems":[16],"disabled":[4],"readonly":[4]}]]],["limel-banner.cjs",[[1,"limel-banner",{"message":[513],"icon":[513],"isOpen":[32],"open":[64],"close":[64]}]]],["limel-table.cjs",[[1,"limel-table",{"data":[16],"columns":[16],"mode":[1],"pageSize":[2,"page-size"],"totalRows":[2,"total-rows"],"sorting":[16],"activeRow":[1040],"movableColumns":[4,"movable-columns"],"loading":[4],"page":[2],"emptyMessage":[1,"empty-message"]}]]],["limel-checkbox.cjs",[[1,"limel-checkbox",{"disabled":[516],"readonly":[516],"label":[513],"helperText":[513,"helper-text"],"checked":[516],"indeterminate":[516],"required":[516],"modified":[32]}]]],["limel-circular-progress.cjs",[[1,"limel-circular-progress",{"value":[2],"maxValue":[2,"max-value"],"suffix":[1],"displayPercentageColors":[4,"display-percentage-colors"],"size":[513]}]]],["limel-code-editor.cjs",[[1,"limel-code-editor",{"value":[1],"language":[1],"readonly":[4],"lineNumbers":[4,"line-numbers"],"colorScheme":[1,"color-scheme"],"random":[32]}]]],["limel-config.cjs",[[1,"limel-config",{"config":[16]}]]],["limel-flex-container.cjs",[[1,"limel-flex-container",{"direction":[513],"justify":[513],"align":[513],"reverse":[516]}]]],["limel-form.cjs",[[1,"limel-form",{"schema":[16],"value":[16],"disabled":[4],"propsFactory":[16],"transformErrors":[16]}]]],["limel-grid.cjs",[[1,"limel-grid"]]],["limel-linear-progress.cjs",[[1,"limel-linear-progress",{"value":[2],"indeterminate":[4]}]]],["limel-slider.cjs",[[1,"limel-slider",{"disabled":[516],"readonly":[516],"factor":[514],"label":[513],"helperText":[513,"helper-text"],"unit":[513],"value":[514],"valuemax":[514],"valuemin":[514],"step":[514],"percentageClass":[32]}]]],["limel-snackbar.cjs",[[1,"limel-snackbar",{"message":[1],"timeout":[2],"actionText":[1,"action-text"],"dismissible":[4],"multiline":[4],"language":[1],"show":[64]}]]],["limel-switch.cjs",[[1,"limel-switch",{"label":[513],"disabled":[516],"readonly":[516],"value":[516],"fieldId":[32]}]]],["limel-tab-bar.cjs",[[1,"limel-tab-bar",{"tabs":[1040],"canScrollLeft":[32],"canScrollRight":[32]},[[9,"resize","handleWindowResize"]]]]],["limel-header.cjs",[[1,"limel-header",{"icon":[1],"heading":[1],"subheading":[1],"supportingText":[1,"supporting-text"]}]]],["limel-progress-flow-item.cjs",[[0,"limel-progress-flow-item",{"item":[16],"disabled":[4],"readonly":[4]}]]],["limel-flatpickr-adapter.cjs",[[1,"limel-flatpickr-adapter",{"value":[16],"type":[1],"format":[1],"isOpen":[4,"is-open"],"inputElement":[16],"language":[1]}]]],["limel-menu-list.cjs",[[1,"limel-menu-list",{"items":[16],"badgeIcons":[4,"badge-icons"],"iconSize":[1,"icon-size"],"type":[1],"maxLinesSecondaryText":[2,"max-lines-secondary-text"]}]]],["limel-popover-surface.cjs",[[1,"limel-popover-surface",{"contentCollection":[16]}]]],["limel-icon.cjs",[[1,"limel-icon",{"size":[513],"name":[513],"badge":[516]}]]],["limel-input-field.cjs",[[1,"limel-input-field",{"disabled":[516],"readonly":[516],"invalid":[516],"label":[513],"helperText":[513,"helper-text"],"required":[516],"value":[513],"trailingIcon":[513,"trailing-icon"],"leadingIcon":[513,"leading-icon"],"pattern":[513],"type":[513],"formatNumber":[516,"format-number"],"step":[520],"max":[514],"min":[514],"maxlength":[514],"minlength":[514],"completions":[16],"showLink":[516,"show-link"],"isFocused":[32],"isModified":[32],"showCompletions":[32]}]]],["limel-color-picker-palette_2.cjs",[[1,"limel-color-picker-palette",{"value":[513],"label":[513],"helperText":[513,"helper-text"],"required":[516]}],[1,"limel-popover",{"open":[4]}]]],["limel-badge.cjs",[[1,"limel-badge",{"label":[514]}]]],["limel-chip-set.cjs",[[1,"limel-chip-set",{"value":[16],"type":[513],"label":[513],"helperText":[513,"helper-text"],"disabled":[516],"readonly":[516],"maxItems":[514,"max-items"],"required":[516],"searchLabel":[513,"search-label"],"emptyInputOnBlur":[516,"empty-input-on-blur"],"clearAllButton":[4,"clear-all-button"],"leadingIcon":[513,"leading-icon"],"delimiter":[513],"language":[1],"editMode":[32],"textValue":[32],"blurred":[32],"inputChipIndexSelected":[32],"getEditMode":[64],"setFocus":[64],"emptyInput":[64]}]]],["limel-icon-button.cjs",[[1,"limel-icon-button",{"icon":[513],"elevated":[516],"label":[513],"disabled":[516],"relayout":[64]}]]],["limel-spinner.cjs",[[1,"limel-spinner",{"size":[513],"limeBranded":[4,"lime-branded"]}]]],["limel-list_3.cjs",[[1,"limel-list",{"items":[16],"badgeIcons":[4,"badge-icons"],"iconSize":[1,"icon-size"],"type":[1],"maxLinesSecondaryText":[2,"max-lines-secondary-text"]}],[1,"limel-menu-surface",{"open":[4],"allowClicksElement":[16]}],[1,"limel-portal",{"openDirection":[1,"open-direction"],"position":[1],"containerId":[1,"container-id"],"containerStyle":[16],"parent":[16],"inheritParentWidth":[4,"inherit-parent-width"],"visible":[4]}]]],["limel-tooltip_2.cjs",[[1,"limel-tooltip",{"elementId":[513,"element-id"],"label":[513],"helperLabel":[513,"helper-label"],"maxlength":[514],"open":[32]}],[1,"limel-tooltip-content",{"label":[513],"helperLabel":[513,"helper-label"],"maxlength":[514]}]]]], options);
17
+ return index.bootstrapLazy([["limel-color-picker.cjs",[[1,"limel-color-picker",{"value":[513],"label":[513],"helperText":[513,"helper-text"],"tooltipLabel":[513,"tooltip-label"],"required":[516],"readonly":[516],"isOpen":[32]}]]],["limel-picker.cjs",[[1,"limel-picker",{"disabled":[4],"readonly":[516],"label":[1],"searchLabel":[1,"search-label"],"helperText":[513,"helper-text"],"leadingIcon":[1,"leading-icon"],"emptyResultMessage":[1,"empty-result-message"],"required":[4],"value":[16],"searcher":[16],"multiple":[4],"delimiter":[513],"actions":[16],"actionPosition":[1,"action-position"],"actionScrollBehavior":[1,"action-scroll-behavior"],"badgeIcons":[516,"badge-icons"],"items":[32],"textValue":[32],"loading":[32],"chips":[32]}]]],["limel-date-picker.cjs",[[1,"limel-date-picker",{"disabled":[516],"readonly":[516],"invalid":[516],"label":[513],"helperText":[513,"helper-text"],"required":[516],"value":[16],"type":[513],"format":[513],"language":[513],"formattedValue":[32],"internalFormat":[32],"showPortal":[32]}]]],["limel-button-group.cjs",[[1,"limel-button-group",{"value":[16],"disabled":[516],"selectedButtonId":[32]}]]],["limel-select.cjs",[[1,"limel-select",{"disabled":[516],"readonly":[516],"invalid":[516],"required":[516],"label":[513],"helperText":[513,"helper-text"],"value":[16],"options":[16],"multiple":[4],"menuOpen":[32]}]]],["limel-tab-panel.cjs",[[1,"limel-tab-panel",{"tabs":[1040]}]]],["limel-file.cjs",[[1,"limel-file",{"value":[16],"label":[513],"required":[516],"disabled":[516],"readonly":[516],"accept":[513],"language":[1],"isDraggingOverDropZone":[32]}]]],["limel-menu.cjs",[[1,"limel-menu",{"items":[16],"disabled":[516],"openDirection":[513,"open-direction"],"open":[1540],"badgeIcons":[516,"badge-icons"],"gridLayout":[516,"grid-layout"]}]]],["limel-button.cjs",[[1,"limel-button",{"label":[513],"primary":[516],"outlined":[516],"icon":[513],"disabled":[516],"loading":[516]}]]],["limel-collapsible-section.cjs",[[1,"limel-collapsible-section",{"isOpen":[1540,"is-open"],"header":[513],"actions":[16]}]]],["limel-dialog.cjs",[[1,"limel-dialog",{"heading":[1],"fullscreen":[516],"open":[1540],"closingActions":[16]}]]],["limel-progress-flow.cjs",[[1,"limel-progress-flow",{"flowItems":[16],"disabled":[4],"readonly":[4]}]]],["limel-checkbox.cjs",[[1,"limel-checkbox",{"disabled":[516],"readonly":[516],"label":[513],"helperText":[513,"helper-text"],"checked":[516],"indeterminate":[516],"required":[516],"modified":[32]}]]],["limel-table.cjs",[[1,"limel-table",{"data":[16],"columns":[16],"mode":[1],"pageSize":[2,"page-size"],"totalRows":[2,"total-rows"],"sorting":[16],"activeRow":[1040],"movableColumns":[4,"movable-columns"],"loading":[4],"page":[2],"emptyMessage":[1,"empty-message"],"selectable":[4],"selection":[16]}]]],["limel-banner.cjs",[[1,"limel-banner",{"message":[513],"icon":[513],"isOpen":[32],"open":[64],"close":[64]}]]],["limel-circular-progress.cjs",[[1,"limel-circular-progress",{"value":[2],"maxValue":[2,"max-value"],"suffix":[1],"displayPercentageColors":[4,"display-percentage-colors"],"size":[513]}]]],["limel-code-editor.cjs",[[1,"limel-code-editor",{"value":[1],"language":[1],"readonly":[4],"lineNumbers":[4,"line-numbers"],"colorScheme":[1,"color-scheme"],"random":[32]}]]],["limel-config.cjs",[[1,"limel-config",{"config":[16]}]]],["limel-flex-container.cjs",[[1,"limel-flex-container",{"direction":[513],"justify":[513],"align":[513],"reverse":[516]}]]],["limel-form.cjs",[[1,"limel-form",{"schema":[16],"value":[16],"disabled":[4],"propsFactory":[16],"transformErrors":[16]}]]],["limel-grid.cjs",[[1,"limel-grid"]]],["limel-linear-progress.cjs",[[1,"limel-linear-progress",{"value":[2],"indeterminate":[4]}]]],["limel-slider.cjs",[[1,"limel-slider",{"disabled":[516],"readonly":[516],"factor":[514],"label":[513],"helperText":[513,"helper-text"],"unit":[513],"value":[514],"valuemax":[514],"valuemin":[514],"step":[514],"percentageClass":[32]}]]],["limel-snackbar.cjs",[[1,"limel-snackbar",{"message":[1],"timeout":[2],"actionText":[1,"action-text"],"dismissible":[4],"multiline":[4],"language":[1],"show":[64]}]]],["limel-switch.cjs",[[1,"limel-switch",{"label":[513],"disabled":[516],"readonly":[516],"value":[516],"fieldId":[32]}]]],["limel-tab-bar.cjs",[[1,"limel-tab-bar",{"tabs":[1040],"canScrollLeft":[32],"canScrollRight":[32]},[[9,"resize","handleWindowResize"]]]]],["limel-header.cjs",[[1,"limel-header",{"icon":[1],"heading":[1],"subheading":[1],"supportingText":[1,"supporting-text"]}]]],["limel-progress-flow-item.cjs",[[0,"limel-progress-flow-item",{"item":[16],"disabled":[4],"readonly":[4]}]]],["limel-flatpickr-adapter.cjs",[[1,"limel-flatpickr-adapter",{"value":[16],"type":[1],"format":[1],"isOpen":[4,"is-open"],"inputElement":[16],"language":[1]}]]],["limel-menu-list.cjs",[[1,"limel-menu-list",{"items":[16],"badgeIcons":[4,"badge-icons"],"iconSize":[1,"icon-size"],"type":[1],"maxLinesSecondaryText":[2,"max-lines-secondary-text"]}]]],["limel-popover-surface.cjs",[[1,"limel-popover-surface",{"contentCollection":[16]}]]],["limel-icon.cjs",[[1,"limel-icon",{"size":[513],"name":[513],"badge":[516]}]]],["limel-input-field.cjs",[[1,"limel-input-field",{"disabled":[516],"readonly":[516],"invalid":[516],"label":[513],"helperText":[513,"helper-text"],"required":[516],"value":[513],"trailingIcon":[513,"trailing-icon"],"leadingIcon":[513,"leading-icon"],"pattern":[513],"type":[513],"formatNumber":[516,"format-number"],"step":[520],"max":[514],"min":[514],"maxlength":[514],"minlength":[514],"completions":[16],"showLink":[516,"show-link"],"isFocused":[32],"isModified":[32],"showCompletions":[32]}]]],["limel-color-picker-palette_2.cjs",[[1,"limel-color-picker-palette",{"value":[513],"label":[513],"helperText":[513,"helper-text"],"required":[516]}],[1,"limel-popover",{"open":[4]}]]],["limel-badge.cjs",[[1,"limel-badge",{"label":[514]}]]],["limel-chip-set.cjs",[[1,"limel-chip-set",{"value":[16],"type":[513],"label":[513],"helperText":[513,"helper-text"],"disabled":[516],"readonly":[516],"maxItems":[514,"max-items"],"required":[516],"searchLabel":[513,"search-label"],"emptyInputOnBlur":[516,"empty-input-on-blur"],"clearAllButton":[4,"clear-all-button"],"leadingIcon":[513,"leading-icon"],"delimiter":[513],"language":[1],"editMode":[32],"textValue":[32],"blurred":[32],"inputChipIndexSelected":[32],"getEditMode":[64],"setFocus":[64],"emptyInput":[64]}]]],["limel-icon-button.cjs",[[1,"limel-icon-button",{"icon":[513],"elevated":[516],"label":[513],"disabled":[516],"relayout":[64]}]]],["limel-spinner.cjs",[[1,"limel-spinner",{"size":[513],"limeBranded":[4,"lime-branded"]}]]],["limel-list_3.cjs",[[1,"limel-list",{"items":[16],"badgeIcons":[4,"badge-icons"],"iconSize":[1,"icon-size"],"type":[1],"maxLinesSecondaryText":[2,"max-lines-secondary-text"]}],[1,"limel-menu-surface",{"open":[4],"allowClicksElement":[16]}],[1,"limel-portal",{"openDirection":[1,"open-direction"],"position":[1],"containerId":[1,"container-id"],"containerStyle":[16],"parent":[16],"inheritParentWidth":[4,"inherit-parent-width"],"visible":[4]}]]],["limel-tooltip_2.cjs",[[1,"limel-tooltip",{"elementId":[513,"element-id"],"label":[513],"helperLabel":[513,"helper-label"],"maxlength":[514],"open":[32]}],[1,"limel-tooltip-content",{"label":[513],"helperLabel":[513,"helper-label"],"maxlength":[514]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -134,7 +134,7 @@ export function createCustomComponent(cell, column, value, pool) {
134
134
  * @param {HTMLElement} element the custom element
135
135
  * @param {object} props object of properties and event listeners
136
136
  */
137
- function setElementProperties(element, props) {
137
+ export function setElementProperties(element, props) {
138
138
  const properties = pickBy(props, negate(isEventListener));
139
139
  Object.assign(element, properties);
140
140
  const listeners = pickBy(props, isEventListener);
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Contains a set of selected data objects with methods for adding and removing
3
+ * items to the selection by referring to them by their index/position.
4
+ * Maintains a memory of the last toggled item which can be used to select or
5
+ * deselect a range of items between the last toggled item and a given item.
6
+ */
7
+ export class Selection {
8
+ /**
9
+ * Creates an instance of the Selection class.
10
+ * The provided function `getDataByIndex` is used to provide data for the
11
+ * selected items when selection is toggled by using the item index,
12
+ * which can be the row position in a table.
13
+ *
14
+ * @param {Function} getDataByIndex A function that returns the data at the given index
15
+ */
16
+ constructor(getDataByIndex) {
17
+ this.getDataByIndex = getDataByIndex;
18
+ this.toggleRange = (fromIndex, toIndex) => {
19
+ const select = !this.selectedItems.has(this.getDataByIndex(toIndex));
20
+ const lowerBound = Math.min(fromIndex, toIndex);
21
+ const upperBound = Math.max(fromIndex, toIndex);
22
+ const updatedIndexes = [];
23
+ const updatedItems = [];
24
+ for (let index = lowerBound; index <= upperBound; index++) {
25
+ const data = this.getDataByIndex(index);
26
+ if (!data) {
27
+ continue;
28
+ }
29
+ const isSelected = this.selectedItems.has(data);
30
+ if (isSelected === select) {
31
+ continue;
32
+ }
33
+ if (select) {
34
+ this.selectedItems.add(data);
35
+ }
36
+ else {
37
+ this.selectedItems.delete(data);
38
+ }
39
+ updatedIndexes.push(index);
40
+ updatedItems.push(data);
41
+ }
42
+ this.lastToggledIndex = toIndex;
43
+ return {
44
+ selected: select,
45
+ items: updatedItems,
46
+ indexes: updatedIndexes,
47
+ };
48
+ };
49
+ this.clear();
50
+ }
51
+ /**
52
+ * @returns {number} The size of the selection
53
+ */
54
+ get size() {
55
+ return this.selectedItems.size;
56
+ }
57
+ /**
58
+ * @returns {any[]} The selected items
59
+ */
60
+ get items() {
61
+ return Array.from(this.selectedItems);
62
+ }
63
+ /**
64
+ * @param {any[]} items The selected items
65
+ */
66
+ set items(items) {
67
+ this.selectedItems = new Set(items);
68
+ this.lastToggledIndex = -1;
69
+ }
70
+ /**
71
+ * Checks whether the given item exist in the selection
72
+ *
73
+ * @param {any} data The data to look up
74
+ * @returns {boolean} `true` if the given data exist in the selection, otherwise `false`
75
+ */
76
+ has(data) {
77
+ return this.selectedItems.has(data);
78
+ }
79
+ /**
80
+ * Toggles the item at the given index in the selection
81
+ *
82
+ * @param {number} index The index of the item to toggle
83
+ * @returns {SelectionChangeSet} The changes made to the selection
84
+ */
85
+ toggleSelection(index) {
86
+ return this.toggleRange(index, index);
87
+ }
88
+ /**
89
+ * Toggles the items from the last toggled index to the given index in the selection.
90
+ * The toggled items will be toggled as the item at the given index no matter
91
+ * their current state in the selection.
92
+ * Initially, when no last toggled index exist, this function behaves like
93
+ * `toggleSelection`.
94
+ *
95
+ * @param {number} index The index of the item to toggle
96
+ * @returns {SelectionChangeSet} The changes made to the selection
97
+ */
98
+ toggleSelectionFromLastIndex(index) {
99
+ if (this.lastToggledIndex < 0) {
100
+ return this.toggleSelection(index);
101
+ }
102
+ return this.toggleRange(this.lastToggledIndex, index);
103
+ }
104
+ /**
105
+ * Clears the current selection and resets last toggled index
106
+ */
107
+ clear() {
108
+ this.selectedItems = new Set();
109
+ this.lastToggledIndex = -1;
110
+ }
111
+ }
@@ -0,0 +1,125 @@
1
+ import { setElementProperties } from './columns';
2
+ import { Selection } from './selection';
3
+ import { isEqual } from 'lodash-es';
4
+ const LIMEL_CHECKBOX = 'limel-checkbox';
5
+ /**
6
+ * Provides row selection to Tabulator with shift-click support for range selections
7
+ */
8
+ export class TableSelection {
9
+ /**
10
+ * Creates an instance of the TableSelection class
11
+ *
12
+ * @param {Function} getTable Function that returns the Tabulator instance
13
+ * @param {ElementPool} pool The element pool used to cache the checkbox components
14
+ * @param {EventEmitter<object[]>} selectEvent The event emitter to use when checkboxes are toggled
15
+ */
16
+ constructor(getTable, pool, selectEvent) {
17
+ this.getTable = getTable;
18
+ this.pool = pool;
19
+ this.selectEvent = selectEvent;
20
+ /**
21
+ * Tabulator cell click handler that updates the selection for the clicked
22
+ * row and toggles the selection from the last clicked row if the shift key
23
+ * is pressed down.
24
+ *
25
+ * @param {PointerEvent} ev The pointer event
26
+ * @param {Tabulator.CellComponent} cell The clicked cell component
27
+ */
28
+ this.rowSelectorCellClick = (ev, cell) => {
29
+ ev.stopPropagation();
30
+ ev.preventDefault();
31
+ const clickedRow = cell.getRow();
32
+ const rowPosition = clickedRow.getPosition(true);
33
+ if (ev.shiftKey) {
34
+ this.updateRowSelectors(this.selection.toggleSelectionFromLastIndex(rowPosition));
35
+ }
36
+ else {
37
+ this.updateRowSelectors(this.selection.toggleSelection(rowPosition));
38
+ }
39
+ this.selectEvent.emit(this.selection.items);
40
+ };
41
+ this.updateRowSelectors = (changeSet) => {
42
+ changeSet.indexes
43
+ .map(this.getRowByIndex)
44
+ .forEach((row) => this.updateRowSelector(row, changeSet.selected));
45
+ };
46
+ this.updateRowSelector = (row, checked) => {
47
+ const cell = row.getCells()[0];
48
+ if (cell) {
49
+ const checkBox = cell.getElement().querySelector(LIMEL_CHECKBOX);
50
+ checkBox.checked = checked;
51
+ }
52
+ };
53
+ this.getActiveRows = () => {
54
+ const table = this.getTable();
55
+ if (!table) {
56
+ return [];
57
+ }
58
+ return table.getRows('active');
59
+ };
60
+ this.getRowByIndex = (index) => {
61
+ return this.getTable().getRowFromPosition(index, true);
62
+ };
63
+ this.selection = new Selection((index) => this.getRowByIndex(index).getData());
64
+ }
65
+ /**
66
+ * @returns {boolean} Returns `true` when the selection is non-empty, otherwise `false`
67
+ */
68
+ get hasSelection() {
69
+ return this.selection.size > 0;
70
+ }
71
+ /**
72
+ * Clears the selection
73
+ */
74
+ clear() {
75
+ this.selection.clear();
76
+ }
77
+ /**
78
+ * Sets the selected items
79
+ *
80
+ * @param {any[]} data The selected items
81
+ */
82
+ setSelection(data) {
83
+ if (isEqual(this.selection.items, data)) {
84
+ return;
85
+ }
86
+ this.selection.items = data;
87
+ const rows = this.getActiveRows();
88
+ rows.forEach((row) => this.updateRowSelector(row, this.selection.has(row.getData())));
89
+ }
90
+ /**
91
+ * Prepends a checkbox column used for row selection to the given column definitions
92
+ *
93
+ * @param {Tabulator.ColumnDefinition[]} columnDefinitions The column definition for the table
94
+ * @returns {Tabulator.ColumnDefinition[]} The column definitions with the checkbox column prepended to it
95
+ */
96
+ getColumnDefinitions(columnDefinitions) {
97
+ return [this.getRowSelectorColumnDefinition(), ...columnDefinitions];
98
+ }
99
+ getRowSelectorColumnDefinition() {
100
+ return {
101
+ title: '',
102
+ formatter: this.getRowSelectorFormatter(),
103
+ cellClick: this.rowSelectorCellClick,
104
+ headerClick: this.headerClick,
105
+ headerSort: false,
106
+ cssClass: 'limel-table--row-selector',
107
+ resizable: false,
108
+ htmlOutput: false,
109
+ clipboard: false,
110
+ };
111
+ }
112
+ headerClick(ev) {
113
+ ev.stopPropagation();
114
+ }
115
+ getRowSelectorFormatter() {
116
+ return (cell) => {
117
+ const element = this.pool.get(LIMEL_CHECKBOX);
118
+ setElementProperties(element, {
119
+ checked: this.selection.has(cell.getData()),
120
+ });
121
+ element.style.display = 'inline-block';
122
+ return element;
123
+ };
124
+ }
125
+ }
@@ -952,13 +952,13 @@ body.tabulator-print-fullscreen-hide > *:not(.tabulator-print-fullscreen) {
952
952
  cursor: pointer;
953
953
  }
954
954
  [aria-sort=none] .tabulator-arrow {
955
- border-bottom-color: rgb(var(--contrast-800)) !important;
955
+ border-bottom-color: rgb(var(--table-arrow-color)) !important;
956
956
  }
957
957
  [aria-sort=desc] .tabulator-arrow {
958
- border-top-color: rgb(var(--color-teal-light)) !important;
958
+ border-top-color: rgb(var(--table-arrow-color--active)) !important;
959
959
  }
960
960
  [aria-sort=asc] .tabulator-arrow {
961
- border-bottom-color: rgb(var(--color-teal-light)) !important;
961
+ border-bottom-color: rgb(var(--table-arrow-color--active)) !important;
962
962
  }
963
963
  .tabulator-arrow:before, .tabulator-arrow:after {
964
964
  display: block;
@@ -967,7 +967,7 @@ body.tabulator-print-fullscreen-hide > *:not(.tabulator-print-fullscreen) {
967
967
  bottom: 0;
968
968
  }
969
969
  .tabulator-arrow:before {
970
- background-color: rgb(var(--contrast-500));
970
+ background-color: rgb(var(--table-header-background-color));
971
971
  width: 0.5rem;
972
972
  height: 0.5rem;
973
973
  transform: rotate(45deg);
@@ -976,7 +976,7 @@ body.tabulator-print-fullscreen-hide > *:not(.tabulator-print-fullscreen) {
976
976
  }
977
977
  .tabulator-arrow:after {
978
978
  width: 0.125rem;
979
- background-color: rgb(var(--contrast-800));
979
+ background-color: rgb(var(--table-arrow-color));
980
980
  height: 0.5625rem;
981
981
  top: 0.125rem;
982
982
  left: -0.0625rem;
@@ -991,7 +991,7 @@ body.tabulator-print-fullscreen-hide > *:not(.tabulator-print-fullscreen) {
991
991
  top: -0.6875rem;
992
992
  }
993
993
  [aria-sort=desc] .tabulator-arrow:after, [aria-sort=asc] .tabulator-arrow:after {
994
- background-color: rgb(var(--color-teal-light));
994
+ background-color: rgb(var(--table-arrow-color--active));
995
995
  }
996
996
 
997
997
  @keyframes indicate-sortable-column {
@@ -1156,21 +1156,21 @@ body.tabulator-print-fullscreen-hide > *:not(.tabulator-print-fullscreen) {
1156
1156
  * Nothing in this file may output any CSS
1157
1157
  * without being explicitly called by outside code.
1158
1158
  */
1159
- :host(.has-interactive-rows) .tabulator-row.tabulator-selectable {
1159
+ :host(.has-interactive-rows) .tabulator-row:not(.tabulator-calcs).tabulator-selectable {
1160
1160
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease-out;
1161
1161
  }
1162
- :host(.has-interactive-rows) .tabulator-row.tabulator-selectable:hover {
1162
+ :host(.has-interactive-rows) .tabulator-row:not(.tabulator-calcs).tabulator-selectable:hover {
1163
1163
  box-shadow: var(--button-shadow-hovered);
1164
1164
  }
1165
- :host(.has-interactive-rows) .tabulator-row.tabulator-selectable:active {
1165
+ :host(.has-interactive-rows) .tabulator-row:not(.tabulator-calcs).tabulator-selectable:active {
1166
1166
  box-shadow: var(--button-shadow-pressed);
1167
1167
  transform: translate3d(0, 0.08rem, 0);
1168
1168
  }
1169
- :host(.has-interactive-rows) .tabulator-row.tabulator-selectable:hover {
1170
- z-index: 1;
1169
+ :host(.has-interactive-rows) .tabulator-row:not(.tabulator-calcs).tabulator-selectable:hover {
1170
+ z-index: 2;
1171
1171
  }
1172
- :host(.has-interactive-rows) .tabulator-row.tabulator-selectable:not(.active):hover {
1173
- background-color: rgb(var(--contrast-100));
1172
+ :host(.has-interactive-rows) .tabulator-row:not(.tabulator-calcs).tabulator-selectable:not(.active):hover {
1173
+ background-color: rgb(var(--table-row-background-color--hover));
1174
1174
  }
1175
1175
 
1176
1176
  :host(.has-low-density) #tabulator-table {
@@ -1263,26 +1263,109 @@ body.tabulator-print-fullscreen-hide > *:not(.tabulator-print-fullscreen) {
1263
1263
  .tabulator.has-movable-columns .tabulator-header {
1264
1264
  overflow-y: visible;
1265
1265
  }
1266
- .tabulator.has-movable-columns .tabulator-header .tabulator-col {
1266
+ .tabulator.has-movable-columns .tabulator-header .tabulator-col:not(.tabulator-frozen) {
1267
1267
  cursor: move !important;
1268
1268
  }
1269
- .tabulator.has-movable-columns .tabulator-header .tabulator-col.tabulator-sortable.tabulator-moving {
1269
+ .tabulator.has-movable-columns .tabulator-header .tabulator-col:not(.tabulator-frozen).tabulator-sortable.tabulator-moving {
1270
1270
  animation: detach-a-column-header 0.2s ease forwards;
1271
1271
  opacity: 0.9;
1272
1272
  border: none;
1273
1273
  border-radius: 0.25rem;
1274
- background-color: rgb(var(--contrast-100));
1274
+ background-color: rgb(var(---table-header-background-color-when-being-dragged));
1275
1275
  box-shadow: var(--shadow-depth-16);
1276
1276
  }
1277
- .tabulator.has-movable-columns .tabulator-header .tabulator-col.tabulator-sortable.tabulator-moving:hover {
1278
- background-color: rgb(var(--contrast-100));
1277
+ .tabulator.has-movable-columns .tabulator-header .tabulator-col:not(.tabulator-frozen).tabulator-sortable.tabulator-moving:hover {
1278
+ background-color: rgb(var(---table-header-background-color-when-being-dragged));
1279
+ }
1280
+ .tabulator.has-movable-columns .tabulator-header .tabulator-col:not(.tabulator-frozen).tabulator-sortable.tabulator-moving .tabulator-arrow:before {
1281
+ background-color: rgb(var(---table-header-background-color-when-being-dragged));
1282
+ }
1283
+
1284
+ /*
1285
+ * This file is imported into every component!
1286
+ *
1287
+ * Nothing in this file may output any CSS
1288
+ * without being explicitly called by outside code.
1289
+ */
1290
+ .select-all,
1291
+ .limel-table--row-selector {
1292
+ --mdc-checkbox-ripple-size: 1rem;
1293
+ }
1294
+
1295
+ .select-all {
1296
+ position: absolute;
1297
+ z-index: 1;
1298
+ left: 0;
1299
+ top: 0.4375rem;
1300
+ width: 2.5625rem;
1301
+ display: flex !important;
1302
+ align-items: center;
1303
+ justify-content: center;
1304
+ }
1305
+ .select-all limel-checkbox {
1306
+ transform: translate(-0.25rem, 0);
1307
+ }
1308
+
1309
+ .limel-table--row-selector {
1310
+ position: sticky !important;
1311
+ left: 0;
1312
+ border-width: 0;
1313
+ justify-content: center;
1314
+ z-index: 1;
1315
+ }
1316
+ .tabulator-row-odd .limel-table--row-selector {
1317
+ background-image: linear-gradient(to right, rgb(var(--table-row-background-color--odd)) 70%, rgb(var(--table-row-background-color--odd), 0));
1318
+ }
1319
+ .tabulator-row-even .limel-table--row-selector {
1320
+ background-image: linear-gradient(to right, rgb(var(--table-row-background-color--even)) 70%, rgb(var(--table-row-background-color--even), 0));
1321
+ }
1322
+ .tabulator-row.active .limel-table--row-selector, .tabulator-row.active:hover .limel-table--row-selector {
1323
+ background-image: linear-gradient(to right, rgb(var(--table-row-background-color--active)) 70%, rgb(var(--table-row-background-color--active), 0));
1324
+ }
1325
+ .tabulator-row:not(.tabulator-calcs):hover .limel-table--row-selector {
1326
+ will-change: background-image;
1327
+ background-image: linear-gradient(to right, rgb(var(--table-row-background-color--hover)) 70%, rgb(var(--table-row-background-color--hover), 0));
1279
1328
  }
1280
- .tabulator.has-movable-columns .tabulator-header .tabulator-col.tabulator-sortable.tabulator-moving .tabulator-arrow:before {
1281
- background-color: rgb(var(--contrast-100));
1329
+ .limel-table--row-selector limel-checkbox {
1330
+ transition: opacity 0.2s ease;
1331
+ align-self: center;
1332
+ opacity: 0.3;
1333
+ transform: translate(-0.25rem, 0);
1334
+ }
1335
+ .tabulator-row:hover .limel-table--row-selector limel-checkbox {
1336
+ opacity: 1;
1337
+ }
1338
+ .has-selection .limel-table--row-selector limel-checkbox {
1339
+ opacity: 1;
1340
+ }
1341
+ .limel-table--row-selector .tabulator-col-resize-handle {
1342
+ display: none;
1343
+ }
1344
+ .limel-table--row-selector + .tabulator-col .tabulator-col-resize-handle.prev, .limel-table--row-selector + .tabulator-cell .tabulator-col-resize-handle.prev {
1345
+ display: none;
1346
+ }
1347
+
1348
+ .tabulator.has-movable-columns .tabulator-header .tabulator-col.limel-table--row-selector {
1349
+ border: none;
1350
+ cursor: default;
1351
+ pointer-events: unset;
1352
+ background-color: transparent;
1353
+ background-image: linear-gradient(to right, rgb(var(--table-header-background-color--hover)) 70%, rgb(var(--table-header-background-color--hover), 0));
1354
+ position: sticky;
1355
+ left: 0;
1282
1356
  }
1283
1357
 
1284
1358
  :host {
1285
1359
  display: block;
1360
+ --table-header-background-color: var(--contrast-500);
1361
+ --table-header-background-color--hover: var(--contrast-400);
1362
+ --table-header-background-color-when-being-dragged: var(--contrast-100);
1363
+ --table-row-background-color--odd: var(--contrast-200);
1364
+ --table-row-background-color--even: var(--contrast-100);
1365
+ --table-row-background-color--hover: var(--contrast-100);
1366
+ --table-row-background-color--active: var(--color-teal-lighter);
1367
+ --table-arrow-color: var(--contrast-800);
1368
+ --table-arrow-color--active: var(--color-teal-default);
1286
1369
  }
1287
1370
 
1288
1371
  #tabulator-container {
@@ -1304,46 +1387,46 @@ body.tabulator-print-fullscreen-hide > *:not(.tabulator-print-fullscreen) {
1304
1387
 
1305
1388
  .tabulator .tabulator-header {
1306
1389
  border-bottom: 0;
1307
- background-color: rgb(var(--contrast-500));
1390
+ background-color: rgb(var(--table-header-background-color--hover));
1308
1391
  }
1309
1392
  .tabulator .tabulator-header .tabulator-col {
1310
1393
  transition: background-color 0.2s ease;
1311
- background-color: rgb(var(--contrast-500));
1394
+ background-color: rgb(var(--table-header-background-color--hover));
1312
1395
  border-right-color: rgb(var(--contrast-200));
1313
1396
  }
1314
- .tabulator .tabulator-header .tabulator-col .tabulator-col-content {
1315
- padding-top: 0.5rem;
1316
- padding-bottom: 0.5rem;
1317
- }
1318
1397
  .tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover {
1319
- background-color: rgb(var(--contrast-400));
1398
+ background-color: var(--table-header-background-color--hover);
1320
1399
  }
1321
1400
  .tabulator .tabulator-header .tabulator-col-title {
1322
1401
  font-weight: 500;
1323
1402
  padding-left: 0.125rem;
1324
1403
  }
1325
1404
  .tabulator .tabulator-footer {
1326
- background-color: rgb(var(--contrast-500));
1405
+ background-color: rgb(var(--table-header-background-color--hover));
1327
1406
  border: none;
1407
+ user-select: auto;
1328
1408
  }
1329
1409
  .tabulator .tabulator-footer .tabulator-calcs-holder {
1330
1410
  border-color: rgb(var(--contrast-600));
1331
1411
  }
1332
1412
 
1413
+ .tabulator-row.tabulator-calcs {
1414
+ cursor: default !important;
1415
+ }
1333
1416
  .tabulator-row.tabulator-selectable {
1334
1417
  transition: background-color 0.2s ease;
1335
1418
  }
1336
1419
  .tabulator-row.tabulator-selectable:not(.active):hover {
1337
- background-color: rgb(var(--contrast-500));
1420
+ background-color: rgb(var(--table-header-background-color));
1338
1421
  }
1339
1422
  .tabulator-row.tabulator-row-odd {
1340
- background-color: rgb(var(--contrast-200));
1423
+ background-color: rgb(var(--table-row-background-color--odd));
1341
1424
  }
1342
1425
  .tabulator-row.tabulator-row-even {
1343
- background-color: rgb(var(--contrast-100));
1426
+ background-color: rgb(var(--table-row-background-color--even));
1344
1427
  }
1345
1428
  .tabulator-row.active, .tabulator-row.active:hover {
1346
- background-color: rgba(var(--color-teal-light), 0.16);
1429
+ background-color: rgb(var(--table-row-background-color--active));
1347
1430
  }
1348
1431
  .tabulator-row .tabulator-cell {
1349
1432
  border-right: transparent;