@rio-cloud/rio-uikit 1.7.1 → 1.9.0

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 (248) hide show
  1. package/BarList.d.ts +2 -0
  2. package/BarList.js +2 -0
  3. package/README.md +4 -0
  4. package/SaveableDateInput.d.ts +2 -0
  5. package/SaveableDateInput.js +2 -0
  6. package/SvgImage.d.ts +2 -0
  7. package/SvgImage.js +2 -0
  8. package/TableCol.d.ts +2 -0
  9. package/TableCol.js +2 -0
  10. package/TableHead.d.ts +2 -0
  11. package/TableHead.js +2 -0
  12. package/components/actionBarItem/ActionBarItemIcon.js +1 -1
  13. package/components/actionBarItem/ActionBarOverlay.js +1 -1
  14. package/components/activity/Activity.d.ts +2 -2
  15. package/components/applicationHeader/CollapsedNavItem.js +1 -0
  16. package/components/assetTree/Tree.d.ts +20 -0
  17. package/components/assetTree/Tree.js +75 -38
  18. package/components/assetTree/TreeLeaf.js +1 -1
  19. package/components/assetTree/TreeNodeContainer.d.ts +1 -1
  20. package/components/assetTree/TreeSearch.js +1 -1
  21. package/components/assetTree/TreeSummary.js +1 -1
  22. package/components/assetTree/TypeCounter.d.ts +2 -0
  23. package/components/assetTree/TypeCounter.js +1 -1
  24. package/components/assetTree/useTreeExpansion.d.ts +4 -0
  25. package/components/assetTree/useTreeExpansion.js +25 -0
  26. package/components/assetTree/useTreeHeight.d.ts +1 -0
  27. package/components/assetTree/useTreeHeight.js +60 -0
  28. package/components/assetTree/useTreeScrollPosition.d.ts +3 -0
  29. package/components/assetTree/useTreeScrollPosition.js +19 -0
  30. package/components/assetTree/useTreeVirtualization.d.ts +17 -0
  31. package/components/assetTree/useTreeVirtualization.js +71 -0
  32. package/components/autosuggest/AutoSuggest.js +2 -1
  33. package/components/barList/BarList.d.ts +97 -0
  34. package/components/barList/BarList.js +42 -0
  35. package/components/barList/useSortedBars.d.ts +2 -0
  36. package/components/barList/useSortedBars.js +14 -0
  37. package/components/button/ButtonToolbar.d.ts +1 -1
  38. package/components/button/ButtonToolbar.js +1 -1
  39. package/components/button/ToggleButton.js +0 -1
  40. package/components/charts/PieChart.js +1 -1
  41. package/components/clearableInput/ClearableInput.d.ts +20 -7
  42. package/components/clearableInput/ClearableInput.js +68 -8
  43. package/components/dialog/Dialog.js +1 -1
  44. package/components/dialog/FrameDialog.js +1 -1
  45. package/components/dropdown/ButtonDropdown.d.ts +11 -3
  46. package/components/dropdown/ButtonDropdown.js +79 -64
  47. package/components/dropdown/DropdownToggleButton.d.ts +7 -4
  48. package/components/dropdown/DropdownToggleButton.js +11 -3
  49. package/components/formLabel/FormLabel.d.ts +2 -2
  50. package/components/formLabel/FormLabel.js +1 -1
  51. package/components/listMenu/ListMenu.js +4 -1
  52. package/components/map/components/Map.js +21 -6
  53. package/components/map/components/constants.d.ts +2 -0
  54. package/components/map/components/constants.js +3 -0
  55. package/components/map/components/features/basics/InfoBubble.js +1 -1
  56. package/components/map/components/features/layers/overlayLayers/IncidentsLayer.js +1 -1
  57. package/components/map/utils/mapTypes.d.ts +5 -0
  58. package/components/map/utils/rendering.d.ts +5 -2
  59. package/components/map/utils/rendering.js +46 -39
  60. package/components/menuItems/MenuItem.js +1 -1
  61. package/components/notification/Notification.js +1 -1
  62. package/components/overlay/OverlayTrigger.js +3 -3
  63. package/components/saveableInput/SaveableDateInput.d.ts +83 -0
  64. package/components/saveableInput/SaveableDateInput.js +122 -0
  65. package/components/selects/BaseSelectDropdown.js +1 -1
  66. package/components/selects/Multiselect.d.ts +8 -0
  67. package/components/selects/Multiselect.js +4 -4
  68. package/components/smoothScrollbars/SmoothScrollbars.d.ts +1 -0
  69. package/components/smoothScrollbars/SmoothScrollbars.js +3 -3
  70. package/components/statsWidget/StatsWidget.d.ts +2 -2
  71. package/components/statsWidget/StatsWidgets.d.ts +2 -2
  72. package/components/svgImage/SvgElement.d.ts +8 -0
  73. package/components/svgImage/SvgElement.js +11 -0
  74. package/components/svgImage/SvgImage.d.ts +30 -0
  75. package/components/svgImage/SvgImage.js +20 -0
  76. package/components/svgImage/svgConverter.d.ts +17 -0
  77. package/components/svgImage/svgConverter.js +78 -0
  78. package/components/svgImage/useSvgLoader.d.ts +9 -0
  79. package/components/svgImage/useSvgLoader.js +43 -0
  80. package/components/switch/Switch.d.ts +4 -0
  81. package/components/switch/Switch.js +5 -6
  82. package/components/table/TableCardsSorting.d.ts +0 -1
  83. package/components/table/TableCol.d.ts +18 -0
  84. package/components/table/TableCol.js +11 -0
  85. package/components/table/TableHead.d.ts +33 -0
  86. package/components/table/TableHead.js +11 -0
  87. package/components/table/TableSettingsDialog.js +1 -1
  88. package/components/tag/Tag.js +1 -1
  89. package/components/timepicker/TimePicker.d.ts +1 -2
  90. package/components/timepicker/TimePicker.js +35 -8
  91. package/components/tooltip/SimpleTooltip.d.ts +1 -1
  92. package/components/virtualList/VirtualList.js +1 -1
  93. package/hooks/useIsFocusWithin.d.ts +33 -0
  94. package/hooks/useIsFocusWithin.js +55 -0
  95. package/hooks/useLocationSuggestions.d.ts +27 -0
  96. package/hooks/useLocationSuggestions.js +94 -0
  97. package/hooks/useOnboarding.d.ts +17 -5
  98. package/hooks/useOnboarding.js +7 -1
  99. package/hooks/usePostMessage.js +0 -1
  100. package/hooks/useSearch.d.ts +63 -0
  101. package/hooks/useSearch.js +73 -0
  102. package/hooks/useSorting.d.ts +6 -0
  103. package/hooks/useSorting.js +7 -4
  104. package/hooks/useTableExport.d.ts +49 -0
  105. package/hooks/useTableExport.js +57 -0
  106. package/hooks/useTableSelection.d.ts +166 -0
  107. package/hooks/useTableSelection.js +201 -0
  108. package/lib/es/BarList.d.ts +2 -0
  109. package/lib/es/BarList.js +7 -0
  110. package/lib/es/SaveableDateInput.d.ts +2 -0
  111. package/lib/es/SaveableDateInput.js +7 -0
  112. package/lib/es/SvgImage.d.ts +2 -0
  113. package/lib/es/SvgImage.js +7 -0
  114. package/lib/es/TableCol.d.ts +2 -0
  115. package/lib/es/TableCol.js +7 -0
  116. package/lib/es/TableHead.d.ts +2 -0
  117. package/lib/es/TableHead.js +7 -0
  118. package/lib/es/components/actionBarItem/ActionBarItemIcon.js +1 -1
  119. package/lib/es/components/actionBarItem/ActionBarOverlay.js +1 -1
  120. package/lib/es/components/activity/Activity.d.ts +2 -2
  121. package/lib/es/components/applicationHeader/CollapsedNavItem.js +1 -0
  122. package/lib/es/components/assetTree/Tree.d.ts +20 -0
  123. package/lib/es/components/assetTree/Tree.js +74 -37
  124. package/lib/es/components/assetTree/TreeLeaf.js +1 -1
  125. package/lib/es/components/assetTree/TreeNodeContainer.d.ts +1 -1
  126. package/lib/es/components/assetTree/TreeSearch.js +1 -1
  127. package/lib/es/components/assetTree/TreeSummary.js +1 -1
  128. package/lib/es/components/assetTree/TypeCounter.d.ts +2 -0
  129. package/lib/es/components/assetTree/TypeCounter.js +1 -1
  130. package/lib/es/components/assetTree/useTreeExpansion.d.ts +4 -0
  131. package/lib/es/components/assetTree/useTreeExpansion.js +29 -0
  132. package/lib/es/components/assetTree/useTreeHeight.d.ts +1 -0
  133. package/lib/es/components/assetTree/useTreeHeight.js +64 -0
  134. package/lib/es/components/assetTree/useTreeScrollPosition.d.ts +3 -0
  135. package/lib/es/components/assetTree/useTreeScrollPosition.js +23 -0
  136. package/lib/es/components/assetTree/useTreeVirtualization.d.ts +17 -0
  137. package/lib/es/components/assetTree/useTreeVirtualization.js +76 -0
  138. package/lib/es/components/autosuggest/AutoSuggest.js +2 -1
  139. package/lib/es/components/barList/BarList.d.ts +97 -0
  140. package/lib/es/components/barList/BarList.js +45 -0
  141. package/lib/es/components/barList/useSortedBars.d.ts +2 -0
  142. package/lib/es/components/barList/useSortedBars.js +17 -0
  143. package/lib/es/components/button/ButtonToolbar.d.ts +1 -1
  144. package/lib/es/components/button/ButtonToolbar.js +1 -1
  145. package/lib/es/components/button/ToggleButton.js +0 -1
  146. package/lib/es/components/charts/PieChart.js +1 -1
  147. package/lib/es/components/clearableInput/ClearableInput.d.ts +20 -7
  148. package/lib/es/components/clearableInput/ClearableInput.js +67 -7
  149. package/lib/es/components/dialog/Dialog.js +1 -1
  150. package/lib/es/components/dialog/FrameDialog.js +1 -1
  151. package/lib/es/components/dropdown/ButtonDropdown.d.ts +11 -3
  152. package/lib/es/components/dropdown/ButtonDropdown.js +79 -64
  153. package/lib/es/components/dropdown/DropdownToggleButton.d.ts +7 -4
  154. package/lib/es/components/dropdown/DropdownToggleButton.js +11 -3
  155. package/lib/es/components/formLabel/FormLabel.d.ts +2 -2
  156. package/lib/es/components/formLabel/FormLabel.js +1 -1
  157. package/lib/es/components/listMenu/ListMenu.js +4 -1
  158. package/lib/es/components/map/components/Map.js +20 -5
  159. package/lib/es/components/map/components/constants.d.ts +2 -0
  160. package/lib/es/components/map/components/constants.js +4 -1
  161. package/lib/es/components/map/components/features/basics/InfoBubble.js +1 -1
  162. package/lib/es/components/map/components/features/layers/overlayLayers/IncidentsLayer.js +1 -1
  163. package/lib/es/components/map/utils/mapTypes.d.ts +5 -0
  164. package/lib/es/components/map/utils/rendering.d.ts +5 -2
  165. package/lib/es/components/map/utils/rendering.js +46 -39
  166. package/lib/es/components/menuItems/MenuItem.js +1 -1
  167. package/lib/es/components/notification/Notification.js +1 -1
  168. package/lib/es/components/overlay/OverlayTrigger.js +3 -3
  169. package/lib/es/components/saveableInput/SaveableDateInput.d.ts +83 -0
  170. package/lib/es/components/saveableInput/SaveableDateInput.js +125 -0
  171. package/lib/es/components/selects/BaseSelectDropdown.js +1 -1
  172. package/lib/es/components/selects/Multiselect.d.ts +8 -0
  173. package/lib/es/components/selects/Multiselect.js +4 -4
  174. package/lib/es/components/smoothScrollbars/SmoothScrollbars.d.ts +1 -0
  175. package/lib/es/components/smoothScrollbars/SmoothScrollbars.js +3 -3
  176. package/lib/es/components/statsWidget/StatsWidget.d.ts +2 -2
  177. package/lib/es/components/statsWidget/StatsWidgets.d.ts +2 -2
  178. package/lib/es/components/svgImage/SvgElement.d.ts +8 -0
  179. package/lib/es/components/svgImage/SvgElement.js +14 -0
  180. package/lib/es/components/svgImage/SvgImage.d.ts +30 -0
  181. package/lib/es/components/svgImage/SvgImage.js +23 -0
  182. package/lib/es/components/svgImage/svgConverter.d.ts +17 -0
  183. package/lib/es/components/svgImage/svgConverter.js +84 -0
  184. package/lib/es/components/svgImage/useSvgLoader.d.ts +9 -0
  185. package/lib/es/components/svgImage/useSvgLoader.js +48 -0
  186. package/lib/es/components/switch/Switch.d.ts +4 -0
  187. package/lib/es/components/switch/Switch.js +5 -6
  188. package/lib/es/components/table/TableCardsSorting.d.ts +0 -1
  189. package/lib/es/components/table/TableCol.d.ts +18 -0
  190. package/lib/es/components/table/TableCol.js +13 -0
  191. package/lib/es/components/table/TableHead.d.ts +33 -0
  192. package/lib/es/components/table/TableHead.js +14 -0
  193. package/lib/es/components/table/TableSettingsDialog.js +1 -1
  194. package/lib/es/components/tag/Tag.js +1 -1
  195. package/lib/es/components/timepicker/TimePicker.d.ts +1 -2
  196. package/lib/es/components/timepicker/TimePicker.js +35 -8
  197. package/lib/es/components/tooltip/SimpleTooltip.d.ts +1 -1
  198. package/lib/es/components/virtualList/VirtualList.js +1 -1
  199. package/lib/es/hooks/useIsFocusWithin.d.ts +33 -0
  200. package/lib/es/hooks/useIsFocusWithin.js +57 -0
  201. package/lib/es/hooks/useLocationSuggestions.d.ts +27 -0
  202. package/lib/es/hooks/useLocationSuggestions.js +97 -0
  203. package/lib/es/hooks/useOnboarding.d.ts +17 -5
  204. package/lib/es/hooks/useOnboarding.js +7 -1
  205. package/lib/es/hooks/usePostMessage.js +0 -1
  206. package/lib/es/hooks/useSearch.d.ts +63 -0
  207. package/lib/es/hooks/useSearch.js +75 -0
  208. package/lib/es/hooks/useSorting.d.ts +6 -0
  209. package/lib/es/hooks/useSorting.js +7 -4
  210. package/lib/es/hooks/useTableExport.d.ts +49 -0
  211. package/lib/es/hooks/useTableExport.js +59 -0
  212. package/lib/es/hooks/useTableSelection.d.ts +166 -0
  213. package/lib/es/hooks/useTableSelection.js +210 -0
  214. package/lib/es/themes/Volkswagen/components/applicationHeader/VolkswagenApplicationHeader.js +1 -1
  215. package/lib/es/useIsFocusWithin.d.ts +2 -0
  216. package/lib/es/useIsFocusWithin.js +7 -0
  217. package/lib/es/useLocationSuggestions.d.ts +2 -0
  218. package/lib/es/useLocationSuggestions.js +7 -0
  219. package/lib/es/useSearch.d.ts +2 -0
  220. package/lib/es/useSearch.js +7 -0
  221. package/lib/es/useTableExport.d.ts +2 -0
  222. package/lib/es/useTableExport.js +7 -0
  223. package/lib/es/useTableSelection.d.ts +2 -0
  224. package/lib/es/useTableSelection.js +7 -0
  225. package/lib/es/utils/storageUtils.d.ts +2 -2
  226. package/lib/es/utils/storageUtils.js +2 -0
  227. package/lib/es/utils/urlFeatureToggles.d.ts +12 -6
  228. package/lib/es/utils/urlFeatureToggles.js +14 -8
  229. package/lib/es/utils/useDropDirection.js +1 -0
  230. package/lib/es/version.json +1 -1
  231. package/package.json +48 -40
  232. package/themes/Volkswagen/components/applicationHeader/VolkswagenApplicationHeader.js +1 -1
  233. package/useIsFocusWithin.d.ts +2 -0
  234. package/useIsFocusWithin.js +2 -0
  235. package/useLocationSuggestions.d.ts +2 -0
  236. package/useLocationSuggestions.js +2 -0
  237. package/useSearch.d.ts +2 -0
  238. package/useSearch.js +2 -0
  239. package/useTableExport.d.ts +2 -0
  240. package/useTableExport.js +2 -0
  241. package/useTableSelection.d.ts +2 -0
  242. package/useTableSelection.js +2 -0
  243. package/utils/storageUtils.d.ts +2 -2
  244. package/utils/storageUtils.js +2 -0
  245. package/utils/urlFeatureToggles.d.ts +12 -6
  246. package/utils/urlFeatureToggles.js +10 -7
  247. package/utils/useDropDirection.js +1 -0
  248. package/version.json +1 -1
@@ -0,0 +1,166 @@
1
+ /**
2
+ * CSS class applied to the currently active row.
3
+ */
4
+ export declare const ACTIVE_CLASS = "active";
5
+ /**
6
+ * Default HTML data attribute name used to store the unique ID on table row elements.
7
+ */
8
+ export declare const DEFAULT_DATA_ATTRIBUTE = "data-id";
9
+ export declare const DEFAULT_TABLE_CHECKBOX_CELL_CLASS = ".table-checkbox";
10
+ export declare const DEFAULT_TABLE_ACTION_CELL_CLASS = ".table-action";
11
+ /**
12
+ * Options for the `useTableSelection` hook.
13
+ */
14
+ export type UseTableSelectionOptions<TData extends Record<string, any>> = {
15
+ /**
16
+ * The array of data items to be displayed in the table.
17
+ * The hook uses this to determine all possible row IDs for "select all" functionality.
18
+ */
19
+ tableData: TData[];
20
+ /**
21
+ * The key in `TData` objects that serves as the unique identifier for each row.
22
+ */
23
+ idKey: keyof TData;
24
+ /**
25
+ * Optional array of row IDs that should be initially selected.
26
+ */
27
+ initialSelectedRowIds?: string[];
28
+ /**
29
+ * Optional ID of the row that should be initially marked as active.
30
+ */
31
+ initialActiveRowId?: string;
32
+ /**
33
+ * Optional CSS query selector to find the checkbox input element within each table row.
34
+ * @default '.table-checkbox input[type="checkbox"]'
35
+ */
36
+ checkboxQuerySelector?: string;
37
+ /**
38
+ * Optional name of the HTML data attribute on `<tr>` elements that holds the unique row ID.
39
+ * @default 'data-id' (matches DEFAULT_DATA_ATTRIBUTE)
40
+ */
41
+ dataAttributeName?: string;
42
+ /**
43
+ * Optional external ref for the table element. If not provided, the hook creates its own.
44
+ * Useful if the parent component needs direct access to the table DOM element for other purposes.
45
+ */
46
+ ref?: React.RefObject<HTMLTableElement>;
47
+ };
48
+ /**
49
+ * Return value of the `useTableSelection` hook.
50
+ */
51
+ export type UseTableSelectionReturn = {
52
+ /**
53
+ * React ref attached to the `<table>` HTML element.
54
+ * Ensure this ref is assigned to your table element to enable DOM manipulations.
55
+ */
56
+ tableRef: React.RefObject<HTMLTableElement>;
57
+ /**
58
+ * An array of strings, where each string is the ID of a currently selected row.
59
+ */
60
+ selectedRowIds: string[];
61
+ /**
62
+ * The ID of the currently active row. An empty string signifies no row is active.
63
+ */
64
+ activeRowId: string;
65
+ /**
66
+ * Callback handler to be attached to the click/change event of individual row selection UI elements (e.g., checkboxes).
67
+ * It expects the clicked element to be within a `<tr>` that has the specified `dataAttributeName`.
68
+ * Manages the selection state of a single row.
69
+ *
70
+ * @param event The React mouse event from the selection UI element.
71
+ */
72
+ onSelection: (event: React.MouseEvent<HTMLElement>) => void;
73
+ /**
74
+ * Callback handler to be attached to the click event of table row (`<tr>`) elements.
75
+ * Manages the active row state.
76
+ * @param event The React mouse event from the `<tr>` element.
77
+ */
78
+ onActiveRowChange: (event: React.MouseEvent<HTMLTableRowElement>) => void;
79
+ /**
80
+ * Callback handler to select or deselect all rows.
81
+ * @param shouldSelect If true, all rows in `tableData` will be selected; otherwise, all selections will be cleared.
82
+ */
83
+ onToggleAll: (shouldSelect: boolean) => void;
84
+ /**
85
+ * Function to update row selection and active highlighting. This is useful when the row data changes due to a search value
86
+ * or any other filter.
87
+ *
88
+ * @returns
89
+ */
90
+ updateRowSelection: () => void;
91
+ /**
92
+ * Setter function to change selected rows from the outside in a controlled manner.
93
+ *
94
+ * @param rowIds
95
+ * @returns
96
+ */
97
+ setSelectedRowIds: (rowIds: string[]) => void;
98
+ /**
99
+ * Setter function to change the active row from the outside in a controlled manner.
100
+ * Use this to deselect an active row.
101
+ *
102
+ * @param activeRowId
103
+ * @returns
104
+ */
105
+ setActiveRowId: (activeRowId: string | undefined) => void;
106
+ /**
107
+ * A boolean indicating whether at least one row is currently selected.
108
+ */
109
+ hasSelection: boolean;
110
+ /**
111
+ * A boolean indicating whether all rows in the current `tableData` are selected.
112
+ */
113
+ isAllSelected: boolean;
114
+ };
115
+ /**
116
+ * A React hook to manage row selection and active row state for an HTML table,
117
+ * including DOM manipulations for visual feedback to optimize performance by
118
+ * preventing individual row re-renders.
119
+ *
120
+ * @param {UseTableSelectionOptions<TData>} options The configuration properties for the hook.
121
+ * @returns {UseTableSelectionReturn} The state and handlers for managing table selection and active row.
122
+ */
123
+ declare const useTableSelection: <TData extends Record<string, any>>(props: UseTableSelectionOptions<TData>) => UseTableSelectionReturn;
124
+ /**
125
+ * Finds a table row element by its data attribute value.
126
+ *
127
+ * @param rows Array of HTMLTableRowElements to search within.
128
+ * @param value The value of the data attribute to find.
129
+ * @param attribute The name of the data attribute (e.g., 'data-id').
130
+ * @returns The found HTMLTableRowElement or undefined.
131
+ */
132
+ export declare const getRowByDataAttribute: (rows: HTMLTableRowElement[], value: string | null | undefined, attribute: string) => HTMLTableRowElement | undefined;
133
+ /**
134
+ * Adds an "active" class to a specified table row.
135
+ *
136
+ * @param rows Array of HTMLTableRowElements to search within.
137
+ * @param rowId The ID of the row to highlight.
138
+ * @param dataAttributeName The data attribute used to identify the row.
139
+ */
140
+ export declare const highlightRow: (rows: HTMLTableRowElement[], rowId: string | null, dataAttributeName: string) => void;
141
+ /**
142
+ * Removes the "active" class from a specified table row.
143
+ *
144
+ * @param rows Array of HTMLTableRowElements to search within.
145
+ * @param rowId The ID of the row to unhighlight.
146
+ * @param dataAttributeName The data attribute used to identify the row.
147
+ */
148
+ export declare const removeHighlightFromRow: (rows: HTMLTableRowElement[], rowId: string | null, dataAttributeName: string) => void;
149
+ /**
150
+ * Sets the checked state of a checkbox within a specific table row.
151
+ * @param rows Array of HTMLTableRowElements to search within.
152
+ * @param rowId The ID of the row to target (value of dataAttribute).
153
+ * @param dataAttribute The data attribute used to identify the row.
154
+ * @param checkboxQuerySelector A CSS selector to find the checkbox input within the row.
155
+ * @param isChecked The desired checked state (true for checked, false for unchecked).
156
+ */
157
+ export declare const setRowCheckboxState: (rows: HTMLTableRowElement[], rowId: string, dataAttribute: string, checkboxQuerySelector: string, isChecked: boolean) => void;
158
+ /**
159
+ * Marks a specific row as selected by checking its checkbox.
160
+ */
161
+ export declare const selectRow: (rows: HTMLTableRowElement[], rowId: string, dataAttribute: string, checkboxQuerySelector: string) => void;
162
+ /**
163
+ * Marks a specific row as deselected by unchecking its checkbox.
164
+ */
165
+ export declare const deselectRow: (rows: HTMLTableRowElement[], rowId: string, dataAttribute: string, checkboxQuerySelector: string) => void;
166
+ export default useTableSelection;
@@ -0,0 +1,201 @@
1
+ import { useState, useRef, useCallback, useEffect } from 'react';
2
+ /**
3
+ * CSS class applied to the currently active row.
4
+ */
5
+ export const ACTIVE_CLASS = 'active';
6
+ /**
7
+ * Default HTML data attribute name used to store the unique ID on table row elements.
8
+ */
9
+ export const DEFAULT_DATA_ATTRIBUTE = 'data-id';
10
+ // Default classes for the checkbox and action cells
11
+ export const DEFAULT_TABLE_CHECKBOX_CELL_CLASS = '.table-checkbox';
12
+ export const DEFAULT_TABLE_ACTION_CELL_CLASS = '.table-action';
13
+ /**
14
+ * A React hook to manage row selection and active row state for an HTML table,
15
+ * including DOM manipulations for visual feedback to optimize performance by
16
+ * preventing individual row re-renders.
17
+ *
18
+ * @param {UseTableSelectionOptions<TData>} options The configuration properties for the hook.
19
+ * @returns {UseTableSelectionReturn} The state and handlers for managing table selection and active row.
20
+ */
21
+ const useTableSelection = (props) => {
22
+ const { tableData, idKey, initialSelectedRowIds = [], initialActiveRowId = '', checkboxQuerySelector = '.table-checkbox input[type="checkbox"]', dataAttributeName = DEFAULT_DATA_ATTRIBUTE, ref, } = props;
23
+ const [selectedRowIds, setSelectedRowIds] = useState(initialSelectedRowIds);
24
+ const [activeRowId, setActiveRowId] = useState(initialActiveRowId);
25
+ const [lastActiveRowId, setLastActiveRowId] = useState(initialActiveRowId);
26
+ const tableRef = ref ?? useRef(null);
27
+ // --- DOM Manipulation Effect (The performance workaround) ---
28
+ /**
29
+ * Effect to handle DOM manipulations for active row highlighting and ensuring
30
+ * checkboxes for selected rows are visually checked.
31
+ * This effect runs when active row state or selection state changes.
32
+ * Note: This effect currently only *selects* rows based on `selectedRowIds`.
33
+ * Deselection in the DOM is handled directly by `onSelection` and `onToggleAll` handlers.
34
+ * For a more centralized DOM update, this effect could be expanded to handle deselection as well.
35
+ */
36
+ useEffect(() => {
37
+ updateRowSelection();
38
+ }, [activeRowId, lastActiveRowId, selectedRowIds]); // Rerun when these change
39
+ const updateRowSelection = () => {
40
+ if (!tableRef.current) {
41
+ return;
42
+ }
43
+ const rows = [...tableRef.current.rows];
44
+ if (lastActiveRowId !== activeRowId) {
45
+ // Due to performance reasons the individual rows should not re-render when the
46
+ // selected driver changes, hence we need to avoid passing that information as props
47
+ // to the row component otherwise it would re-render as the props have changed.
48
+ // Instead, we check here which row to highlight.
49
+ removeHighlightFromRow(rows, lastActiveRowId, dataAttributeName);
50
+ highlightRow(rows, activeRowId, dataAttributeName);
51
+ }
52
+ // handle multi-selection
53
+ selectedRowIds.forEach(rowId => selectRow(rows, rowId, dataAttributeName, checkboxQuerySelector));
54
+ };
55
+ const handleActiveRowChange = useCallback((event) => {
56
+ event.preventDefault();
57
+ event.stopPropagation();
58
+ const targetRow = event.currentTarget;
59
+ const rowId = targetRow.getAttribute(dataAttributeName) ?? '';
60
+ // Avoid activation if click is on checkbox/action area (more robust check needed if complex row structure)
61
+ const clickedElement = event.target;
62
+ const isCheckboxCell = clickedElement.closest(DEFAULT_TABLE_CHECKBOX_CELL_CLASS);
63
+ const isActionCell = clickedElement.closest(DEFAULT_TABLE_ACTION_CELL_CLASS);
64
+ if (isCheckboxCell || isActionCell) {
65
+ return;
66
+ }
67
+ changeActiveRow(rowId);
68
+ }, []);
69
+ const changeActiveRow = (rowId = '') => {
70
+ setActiveRowId(currentActiveRow => {
71
+ const newActiveRowId = currentActiveRow === rowId ? '' : rowId;
72
+ setLastActiveRowId(currentActiveRow); // Update lastActive for the effect
73
+ return newActiveRowId;
74
+ });
75
+ };
76
+ const handleSelection = useCallback((event) => {
77
+ event.preventDefault();
78
+ event.stopPropagation();
79
+ // Find the correct row element containing the data attribute
80
+ const rowElement = event.target.closest(`tr[${dataAttributeName}]`);
81
+ const selectedRowId = rowElement?.getAttribute(dataAttributeName);
82
+ if (!selectedRowId) {
83
+ console.warn('Could not find row ID for selection event.');
84
+ return;
85
+ }
86
+ setSelectedRowIds(prevSelectedRowIds => {
87
+ if (prevSelectedRowIds.includes(selectedRowId)) {
88
+ deselectRows([selectedRowId]);
89
+ return prevSelectedRowIds.filter(id => id !== selectedRowId);
90
+ }
91
+ return [...prevSelectedRowIds, selectedRowId];
92
+ });
93
+ }, []);
94
+ const handleToggleAll = useCallback((shouldSelect) => {
95
+ const allRowIds = tableData.map(row => `${row[idKey]}`);
96
+ setSelectedRowIds(shouldSelect ? allRowIds : []);
97
+ // Deselect all rows when there is at least one row selected, else select all rows
98
+ if (shouldSelect) {
99
+ setSelectedRowIds(allRowIds);
100
+ }
101
+ else {
102
+ setSelectedRowIds([]);
103
+ deselectRows(allRowIds);
104
+ for (const id in allRowIds) {
105
+ const rows = tableRef.current ? [...tableRef.current.rows] : [];
106
+ deselectRow([...rows], id, dataAttributeName, checkboxQuerySelector);
107
+ }
108
+ }
109
+ // DOM updates are handled by useEffect -> updateRowsDOM
110
+ }, [tableData]);
111
+ const deselectRows = (rowIds) => {
112
+ const rows = tableRef.current ? [...tableRef.current.rows] : [];
113
+ rowIds.forEach(rowId => deselectRow(rows, rowId, dataAttributeName, checkboxQuerySelector));
114
+ };
115
+ const hasSelection = selectedRowIds.length > 0;
116
+ const isAllSelected = hasSelection && selectedRowIds.length === tableData.length && tableData.length > 0;
117
+ // --- Return hook state and handlers ---
118
+ return {
119
+ tableRef,
120
+ selectedRowIds,
121
+ activeRowId,
122
+ onSelection: handleSelection,
123
+ onActiveRowChange: handleActiveRowChange,
124
+ onToggleAll: handleToggleAll,
125
+ updateRowSelection,
126
+ setSelectedRowIds: (rowIds) => setSelectedRowIds(rowIds),
127
+ setActiveRowId: (activeRowId) => changeActiveRow(activeRowId),
128
+ hasSelection,
129
+ isAllSelected,
130
+ };
131
+ };
132
+ /**
133
+ * Finds a table row element by its data attribute value.
134
+ *
135
+ * @param rows Array of HTMLTableRowElements to search within.
136
+ * @param value The value of the data attribute to find.
137
+ * @param attribute The name of the data attribute (e.g., 'data-id').
138
+ * @returns The found HTMLTableRowElement or undefined.
139
+ */
140
+ export const getRowByDataAttribute = (rows, value, attribute) => {
141
+ if (!value) {
142
+ return undefined;
143
+ }
144
+ return rows.find(row => row.getAttribute(attribute) === value);
145
+ };
146
+ /**
147
+ * Adds an "active" class to a specified table row.
148
+ *
149
+ * @param rows Array of HTMLTableRowElements to search within.
150
+ * @param rowId The ID of the row to highlight.
151
+ * @param dataAttributeName The data attribute used to identify the row.
152
+ */
153
+ export const highlightRow = (rows, rowId, dataAttributeName) => {
154
+ const row = getRowByDataAttribute(rows, rowId, dataAttributeName);
155
+ row?.classList.add(ACTIVE_CLASS);
156
+ };
157
+ /**
158
+ * Removes the "active" class from a specified table row.
159
+ *
160
+ * @param rows Array of HTMLTableRowElements to search within.
161
+ * @param rowId The ID of the row to unhighlight.
162
+ * @param dataAttributeName The data attribute used to identify the row.
163
+ */
164
+ export const removeHighlightFromRow = (rows, rowId, dataAttributeName) => {
165
+ const row = getRowByDataAttribute(rows, rowId, dataAttributeName);
166
+ row?.classList.remove(ACTIVE_CLASS);
167
+ };
168
+ // Helper to get the checkbox input for a single row
169
+ const getCheckboxFromRow = (row, checkboxQuerySelector) => {
170
+ return row.querySelector(checkboxQuerySelector);
171
+ };
172
+ /**
173
+ * Sets the checked state of a checkbox within a specific table row.
174
+ * @param rows Array of HTMLTableRowElements to search within.
175
+ * @param rowId The ID of the row to target (value of dataAttribute).
176
+ * @param dataAttribute The data attribute used to identify the row.
177
+ * @param checkboxQuerySelector A CSS selector to find the checkbox input within the row.
178
+ * @param isChecked The desired checked state (true for checked, false for unchecked).
179
+ */
180
+ export const setRowCheckboxState = (rows, rowId, dataAttribute, checkboxQuerySelector, isChecked) => {
181
+ const row = getRowByDataAttribute(rows, rowId, dataAttribute);
182
+ if (row) {
183
+ const checkbox = getCheckboxFromRow(row, checkboxQuerySelector);
184
+ if (checkbox) {
185
+ checkbox.checked = isChecked;
186
+ }
187
+ }
188
+ };
189
+ /**
190
+ * Marks a specific row as selected by checking its checkbox.
191
+ */
192
+ export const selectRow = (rows, rowId, dataAttribute, checkboxQuerySelector) => {
193
+ setRowCheckboxState(rows, rowId, dataAttribute, checkboxQuerySelector, true);
194
+ };
195
+ /**
196
+ * Marks a specific row as deselected by unchecking its checkbox.
197
+ */
198
+ export const deselectRow = (rows, rowId, dataAttribute, checkboxQuerySelector) => {
199
+ setRowCheckboxState(rows, rowId, dataAttribute, checkboxQuerySelector, false);
200
+ };
201
+ export default useTableSelection;
@@ -0,0 +1,2 @@
1
+ export { default } from './components/barList/BarList';
2
+ export * from './components/barList/BarList';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var BarList_1 = require("./components/barList/BarList");
6
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(BarList_1).default; } });
7
+ tslib_1.__exportStar(require("./components/barList/BarList"), exports);
@@ -0,0 +1,2 @@
1
+ export { default } from './components/saveableInput/SaveableDateInput';
2
+ export * from './components/saveableInput/SaveableDateInput';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var SaveableDateInput_1 = require("./components/saveableInput/SaveableDateInput");
6
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(SaveableDateInput_1).default; } });
7
+ tslib_1.__exportStar(require("./components/saveableInput/SaveableDateInput"), exports);
@@ -0,0 +1,2 @@
1
+ export { default } from './components/svgImage/SvgImage';
2
+ export * from './components/svgImage/SvgImage';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var SvgImage_1 = require("./components/svgImage/SvgImage");
6
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(SvgImage_1).default; } });
7
+ tslib_1.__exportStar(require("./components/svgImage/SvgImage"), exports);
@@ -0,0 +1,2 @@
1
+ export { default } from './components/table/TableCol';
2
+ export * from './components/table/TableCol';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var TableCol_1 = require("./components/table/TableCol");
6
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(TableCol_1).default; } });
7
+ tslib_1.__exportStar(require("./components/table/TableCol"), exports);
@@ -0,0 +1,2 @@
1
+ export { default } from './components/table/TableHead';
2
+ export * from './components/table/TableHead';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var TableHead_1 = require("./components/table/TableHead");
6
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(TableHead_1).default; } });
7
+ tslib_1.__exportStar(require("./components/table/TableHead"), exports);
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- // @ts-ignore-next-line importsNotUsedAsValues
5
+ // biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
6
6
  const react_1 = require("react");
7
7
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
8
8
  const ActionBarItemIcon = (0, react_1.forwardRef)((props, ref) => {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- // @ts-ignore-next-line importsNotUsedAsValues
5
+ // biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
6
6
  const react_1 = require("react");
7
7
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
8
8
  const noop_1 = tslib_1.__importDefault(require("lodash/fp/noop"));
@@ -7,13 +7,13 @@ declare const STATUS_MAP: {
7
7
  readonly RESTING: "resting";
8
8
  readonly WORKING: "working";
9
9
  };
10
- type ActivityStatus = ObjectValues<typeof STATUS_MAP>;
10
+ export type ActivityStatus = ObjectValues<typeof STATUS_MAP>;
11
11
  declare const SIZE_MAP: {
12
12
  readonly SIZE_SM: "sm";
13
13
  readonly SIZE_LG: "lg";
14
14
  readonly SIZE_XL: "xl";
15
15
  };
16
- type ActivitySize = ObjectValues<typeof SIZE_MAP>;
16
+ export type ActivitySize = ObjectValues<typeof SIZE_MAP>;
17
17
  export type ActivityProps = {
18
18
  /**
19
19
  * Defines the type of activity.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ // biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
5
6
  const react_1 = require("react");
6
7
  const isEmpty_1 = tslib_1.__importDefault(require("lodash/fp/isEmpty"));
7
8
  const CollapsedNavItem = (0, react_1.forwardRef)((props, ref) => {
@@ -150,6 +150,14 @@ export type TreeProps = {
150
150
  * @default false
151
151
  */
152
152
  hideSummary?: boolean;
153
+ /**
154
+ * Callback triggered when the built-in asset type filter changes.
155
+ * This is only available when the default summary is used.
156
+ *
157
+ * @param type
158
+ * @returns
159
+ */
160
+ onTypeFilterChange?: (currentTypes: string[]) => void;
153
161
  /**
154
162
  * Defines whether the entire area below the search field is shown or not. Note: Disabling the
155
163
  * tree head will hide the select all checkbox and the tree options as well as the tree summary.
@@ -192,6 +200,18 @@ export type TreeProps = {
192
200
  * @default false
193
201
  */
194
202
  disableAnimation?: boolean;
203
+ /**
204
+ * The number of items (including groups and children) used for virtualizing the tree.
205
+ *
206
+ * @default 50
207
+ */
208
+ virtualizeThreshold?: number;
209
+ /**
210
+ * The number of items rendered beyond the visible area of a virtualized tree.
211
+ *
212
+ * @default 5
213
+ */
214
+ overscan?: number;
195
215
  /**
196
216
  * Additional classes added to the wrapping element.
197
217
  */