@rio-cloud/rio-uikit 1.7.1 → 1.8.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 (170) hide show
  1. package/README.md +4 -0
  2. package/SvgImage.d.ts +2 -0
  3. package/SvgImage.js +2 -0
  4. package/TableCol.d.ts +2 -0
  5. package/TableCol.js +2 -0
  6. package/TableHead.d.ts +2 -0
  7. package/TableHead.js +2 -0
  8. package/components/actionBarItem/ActionBarItemIcon.js +1 -1
  9. package/components/actionBarItem/ActionBarOverlay.js +1 -1
  10. package/components/applicationHeader/CollapsedNavItem.js +1 -0
  11. package/components/assetTree/Tree.d.ts +8 -0
  12. package/components/assetTree/Tree.js +4 -2
  13. package/components/assetTree/TreeLeaf.js +1 -1
  14. package/components/assetTree/TreeSearch.js +1 -1
  15. package/components/assetTree/TreeSummary.js +1 -1
  16. package/components/assetTree/TypeCounter.d.ts +2 -0
  17. package/components/assetTree/TypeCounter.js +1 -1
  18. package/components/autosuggest/AutoSuggest.js +2 -1
  19. package/components/button/ButtonToolbar.d.ts +1 -1
  20. package/components/button/ButtonToolbar.js +1 -1
  21. package/components/button/ToggleButton.js +0 -1
  22. package/components/clearableInput/ClearableInput.d.ts +20 -7
  23. package/components/clearableInput/ClearableInput.js +68 -8
  24. package/components/dialog/Dialog.js +1 -1
  25. package/components/dialog/FrameDialog.js +1 -1
  26. package/components/dropdown/ButtonDropdown.d.ts +11 -3
  27. package/components/dropdown/ButtonDropdown.js +79 -64
  28. package/components/dropdown/DropdownToggleButton.d.ts +7 -4
  29. package/components/dropdown/DropdownToggleButton.js +11 -3
  30. package/components/formLabel/FormLabel.js +1 -1
  31. package/components/listMenu/ListMenu.js +1 -0
  32. package/components/map/components/Map.js +1 -1
  33. package/components/map/components/features/basics/InfoBubble.js +1 -1
  34. package/components/map/components/features/layers/overlayLayers/IncidentsLayer.js +1 -1
  35. package/components/menuItems/MenuItem.js +1 -1
  36. package/components/notification/Notification.js +1 -1
  37. package/components/overlay/OverlayTrigger.js +1 -1
  38. package/components/selects/BaseSelectDropdown.js +1 -1
  39. package/components/selects/Multiselect.d.ts +8 -0
  40. package/components/selects/Multiselect.js +4 -4
  41. package/components/smoothScrollbars/SmoothScrollbars.js +1 -1
  42. package/components/svgImage/SvgElement.d.ts +8 -0
  43. package/components/svgImage/SvgElement.js +11 -0
  44. package/components/svgImage/SvgImage.d.ts +30 -0
  45. package/components/svgImage/SvgImage.js +20 -0
  46. package/components/svgImage/svgConverter.d.ts +17 -0
  47. package/components/svgImage/svgConverter.js +78 -0
  48. package/components/svgImage/useSvgLoader.d.ts +9 -0
  49. package/components/svgImage/useSvgLoader.js +43 -0
  50. package/components/switch/Switch.d.ts +4 -0
  51. package/components/switch/Switch.js +5 -6
  52. package/components/table/TableCardsSorting.d.ts +0 -1
  53. package/components/table/TableCol.d.ts +18 -0
  54. package/components/table/TableCol.js +11 -0
  55. package/components/table/TableHead.d.ts +33 -0
  56. package/components/table/TableHead.js +11 -0
  57. package/components/table/TableSettingsDialog.js +1 -1
  58. package/components/tag/Tag.js +1 -1
  59. package/components/timepicker/TimePicker.d.ts +1 -2
  60. package/components/timepicker/TimePicker.js +35 -8
  61. package/components/virtualList/VirtualList.js +1 -1
  62. package/hooks/useLocationSuggestions.d.ts +27 -0
  63. package/hooks/useLocationSuggestions.js +94 -0
  64. package/hooks/useOnboarding.d.ts +17 -5
  65. package/hooks/useOnboarding.js +7 -1
  66. package/hooks/usePostMessage.js +0 -1
  67. package/hooks/useSearch.d.ts +63 -0
  68. package/hooks/useSearch.js +73 -0
  69. package/hooks/useSorting.d.ts +6 -0
  70. package/hooks/useSorting.js +7 -4
  71. package/hooks/useTableSelection.d.ts +151 -0
  72. package/hooks/useTableSelection.js +196 -0
  73. package/lib/es/SvgImage.d.ts +2 -0
  74. package/lib/es/SvgImage.js +7 -0
  75. package/lib/es/TableCol.d.ts +2 -0
  76. package/lib/es/TableCol.js +7 -0
  77. package/lib/es/TableHead.d.ts +2 -0
  78. package/lib/es/TableHead.js +7 -0
  79. package/lib/es/components/actionBarItem/ActionBarItemIcon.js +1 -1
  80. package/lib/es/components/actionBarItem/ActionBarOverlay.js +1 -1
  81. package/lib/es/components/applicationHeader/CollapsedNavItem.js +1 -0
  82. package/lib/es/components/assetTree/Tree.d.ts +8 -0
  83. package/lib/es/components/assetTree/Tree.js +4 -2
  84. package/lib/es/components/assetTree/TreeLeaf.js +1 -1
  85. package/lib/es/components/assetTree/TreeSearch.js +1 -1
  86. package/lib/es/components/assetTree/TreeSummary.js +1 -1
  87. package/lib/es/components/assetTree/TypeCounter.d.ts +2 -0
  88. package/lib/es/components/assetTree/TypeCounter.js +1 -1
  89. package/lib/es/components/autosuggest/AutoSuggest.js +2 -1
  90. package/lib/es/components/button/ButtonToolbar.d.ts +1 -1
  91. package/lib/es/components/button/ButtonToolbar.js +1 -1
  92. package/lib/es/components/button/ToggleButton.js +0 -1
  93. package/lib/es/components/clearableInput/ClearableInput.d.ts +20 -7
  94. package/lib/es/components/clearableInput/ClearableInput.js +67 -7
  95. package/lib/es/components/dialog/Dialog.js +1 -1
  96. package/lib/es/components/dialog/FrameDialog.js +1 -1
  97. package/lib/es/components/dropdown/ButtonDropdown.d.ts +11 -3
  98. package/lib/es/components/dropdown/ButtonDropdown.js +79 -64
  99. package/lib/es/components/dropdown/DropdownToggleButton.d.ts +7 -4
  100. package/lib/es/components/dropdown/DropdownToggleButton.js +11 -3
  101. package/lib/es/components/formLabel/FormLabel.js +1 -1
  102. package/lib/es/components/listMenu/ListMenu.js +1 -0
  103. package/lib/es/components/map/components/Map.js +1 -1
  104. package/lib/es/components/map/components/features/basics/InfoBubble.js +1 -1
  105. package/lib/es/components/map/components/features/layers/overlayLayers/IncidentsLayer.js +1 -1
  106. package/lib/es/components/menuItems/MenuItem.js +1 -1
  107. package/lib/es/components/notification/Notification.js +1 -1
  108. package/lib/es/components/overlay/OverlayTrigger.js +1 -1
  109. package/lib/es/components/selects/BaseSelectDropdown.js +1 -1
  110. package/lib/es/components/selects/Multiselect.d.ts +8 -0
  111. package/lib/es/components/selects/Multiselect.js +4 -4
  112. package/lib/es/components/smoothScrollbars/SmoothScrollbars.js +1 -1
  113. package/lib/es/components/svgImage/SvgElement.d.ts +8 -0
  114. package/lib/es/components/svgImage/SvgElement.js +14 -0
  115. package/lib/es/components/svgImage/SvgImage.d.ts +30 -0
  116. package/lib/es/components/svgImage/SvgImage.js +25 -0
  117. package/lib/es/components/svgImage/svgConverter.d.ts +17 -0
  118. package/lib/es/components/svgImage/svgConverter.js +84 -0
  119. package/lib/es/components/svgImage/useSvgLoader.d.ts +9 -0
  120. package/lib/es/components/svgImage/useSvgLoader.js +48 -0
  121. package/lib/es/components/switch/Switch.d.ts +4 -0
  122. package/lib/es/components/switch/Switch.js +5 -6
  123. package/lib/es/components/table/TableCardsSorting.d.ts +0 -1
  124. package/lib/es/components/table/TableCol.d.ts +18 -0
  125. package/lib/es/components/table/TableCol.js +13 -0
  126. package/lib/es/components/table/TableHead.d.ts +33 -0
  127. package/lib/es/components/table/TableHead.js +14 -0
  128. package/lib/es/components/table/TableSettingsDialog.js +1 -1
  129. package/lib/es/components/tag/Tag.js +1 -1
  130. package/lib/es/components/timepicker/TimePicker.d.ts +1 -2
  131. package/lib/es/components/timepicker/TimePicker.js +35 -8
  132. package/lib/es/components/virtualList/VirtualList.js +1 -1
  133. package/lib/es/hooks/useLocationSuggestions.d.ts +27 -0
  134. package/lib/es/hooks/useLocationSuggestions.js +97 -0
  135. package/lib/es/hooks/useOnboarding.d.ts +17 -5
  136. package/lib/es/hooks/useOnboarding.js +7 -1
  137. package/lib/es/hooks/usePostMessage.js +0 -1
  138. package/lib/es/hooks/useSearch.d.ts +63 -0
  139. package/lib/es/hooks/useSearch.js +75 -0
  140. package/lib/es/hooks/useSorting.d.ts +6 -0
  141. package/lib/es/hooks/useSorting.js +7 -4
  142. package/lib/es/hooks/useTableSelection.d.ts +151 -0
  143. package/lib/es/hooks/useTableSelection.js +205 -0
  144. package/lib/es/themes/Volkswagen/components/applicationHeader/VolkswagenApplicationHeader.js +1 -1
  145. package/lib/es/useLocationSuggestions.d.ts +2 -0
  146. package/lib/es/useLocationSuggestions.js +7 -0
  147. package/lib/es/useSearch.d.ts +2 -0
  148. package/lib/es/useSearch.js +7 -0
  149. package/lib/es/useTableSelection.d.ts +2 -0
  150. package/lib/es/useTableSelection.js +7 -0
  151. package/lib/es/utils/storageUtils.d.ts +2 -2
  152. package/lib/es/utils/storageUtils.js +2 -0
  153. package/lib/es/utils/urlFeatureToggles.d.ts +12 -6
  154. package/lib/es/utils/urlFeatureToggles.js +14 -8
  155. package/lib/es/utils/useDropDirection.js +1 -0
  156. package/lib/es/version.json +1 -1
  157. package/package.json +36 -39
  158. package/themes/Volkswagen/components/applicationHeader/VolkswagenApplicationHeader.js +1 -1
  159. package/useLocationSuggestions.d.ts +2 -0
  160. package/useLocationSuggestions.js +2 -0
  161. package/useSearch.d.ts +2 -0
  162. package/useSearch.js +2 -0
  163. package/useTableSelection.d.ts +2 -0
  164. package/useTableSelection.js +2 -0
  165. package/utils/storageUtils.d.ts +2 -2
  166. package/utils/storageUtils.js +2 -0
  167. package/utils/urlFeatureToggles.d.ts +12 -6
  168. package/utils/urlFeatureToggles.js +10 -7
  169. package/utils/useDropDirection.js +1 -0
  170. package/version.json +1 -1
@@ -0,0 +1,196 @@
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
+ setActiveRowId(currentActiveRow => {
68
+ const newActiveRowId = currentActiveRow === rowId ? '' : rowId;
69
+ setLastActiveRowId(currentActiveRow); // Update lastActive for the effect
70
+ return newActiveRowId;
71
+ });
72
+ }, []);
73
+ const handleSelection = useCallback((event) => {
74
+ event.preventDefault();
75
+ event.stopPropagation();
76
+ // Find the correct row element containing the data attribute
77
+ const rowElement = event.target.closest(`tr[${dataAttributeName}]`);
78
+ const selectedRowId = rowElement?.getAttribute(dataAttributeName);
79
+ if (!selectedRowId) {
80
+ console.warn('Could not find row ID for selection event.');
81
+ return;
82
+ }
83
+ setSelectedRowIds(prevSelectedRowIds => {
84
+ if (prevSelectedRowIds.includes(selectedRowId)) {
85
+ deselectRows([selectedRowId]);
86
+ return prevSelectedRowIds.filter(id => id !== selectedRowId);
87
+ }
88
+ return [...prevSelectedRowIds, selectedRowId];
89
+ });
90
+ }, []);
91
+ const handleToggleAll = useCallback((shouldSelect) => {
92
+ const allRowIds = tableData.map(row => `${row[idKey]}`);
93
+ setSelectedRowIds(shouldSelect ? allRowIds : []);
94
+ // Deselect all rows when there is at least one row selected, else select all rows
95
+ if (shouldSelect) {
96
+ setSelectedRowIds(allRowIds);
97
+ }
98
+ else {
99
+ setSelectedRowIds([]);
100
+ deselectRows(allRowIds);
101
+ for (const id in allRowIds) {
102
+ const rows = tableRef.current ? [...tableRef.current.rows] : [];
103
+ deselectRow([...rows], id, dataAttributeName, checkboxQuerySelector);
104
+ }
105
+ }
106
+ // DOM updates are handled by useEffect -> updateRowsDOM
107
+ }, [tableData]);
108
+ const deselectRows = (rowIds) => {
109
+ const rows = tableRef.current ? [...tableRef.current.rows] : [];
110
+ rowIds.forEach(rowId => deselectRow(rows, rowId, dataAttributeName, checkboxQuerySelector));
111
+ };
112
+ const hasSelection = selectedRowIds.length > 0;
113
+ const isAllSelected = hasSelection && selectedRowIds.length === tableData.length && tableData.length > 0;
114
+ // --- Return hook state and handlers ---
115
+ return {
116
+ tableRef,
117
+ selectedRowIds,
118
+ activeRowId,
119
+ onSelection: handleSelection,
120
+ onActiveRowChange: handleActiveRowChange,
121
+ onToggleAll: handleToggleAll,
122
+ updateRowSelection,
123
+ hasSelection,
124
+ isAllSelected,
125
+ };
126
+ };
127
+ /**
128
+ * Finds a table row element by its data attribute value.
129
+ *
130
+ * @param rows Array of HTMLTableRowElements to search within.
131
+ * @param value The value of the data attribute to find.
132
+ * @param attribute The name of the data attribute (e.g., 'data-id').
133
+ * @returns The found HTMLTableRowElement or undefined.
134
+ */
135
+ export const getRowByDataAttribute = (rows, value, attribute) => {
136
+ if (!value) {
137
+ return undefined;
138
+ }
139
+ return rows.find(row => row.getAttribute(attribute) === value);
140
+ };
141
+ /**
142
+ * Adds an "active" class to a specified table row.
143
+ *
144
+ * @param rows Array of HTMLTableRowElements to search within.
145
+ * @param rowId The ID of the row to highlight.
146
+ * @param dataAttributeName The data attribute used to identify the row.
147
+ */
148
+ export const highlightRow = (rows, rowId, dataAttributeName) => {
149
+ const row = getRowByDataAttribute(rows, rowId, dataAttributeName);
150
+ row?.classList.add(ACTIVE_CLASS);
151
+ };
152
+ /**
153
+ * Removes the "active" class from a specified table row.
154
+ *
155
+ * @param rows Array of HTMLTableRowElements to search within.
156
+ * @param rowId The ID of the row to unhighlight.
157
+ * @param dataAttributeName The data attribute used to identify the row.
158
+ */
159
+ export const removeHighlightFromRow = (rows, rowId, dataAttributeName) => {
160
+ const row = getRowByDataAttribute(rows, rowId, dataAttributeName);
161
+ row?.classList.remove(ACTIVE_CLASS);
162
+ };
163
+ // Helper to get the checkbox input for a single row
164
+ const getCheckboxFromRow = (row, checkboxQuerySelector) => {
165
+ return row.querySelector(checkboxQuerySelector);
166
+ };
167
+ /**
168
+ * Sets the checked state of a checkbox within a specific table row.
169
+ * @param rows Array of HTMLTableRowElements to search within.
170
+ * @param rowId The ID of the row to target (value of dataAttribute).
171
+ * @param dataAttribute The data attribute used to identify the row.
172
+ * @param checkboxQuerySelector A CSS selector to find the checkbox input within the row.
173
+ * @param isChecked The desired checked state (true for checked, false for unchecked).
174
+ */
175
+ export const setRowCheckboxState = (rows, rowId, dataAttribute, checkboxQuerySelector, isChecked) => {
176
+ const row = getRowByDataAttribute(rows, rowId, dataAttribute);
177
+ if (row) {
178
+ const checkbox = getCheckboxFromRow(row, checkboxQuerySelector);
179
+ if (checkbox) {
180
+ checkbox.checked = isChecked;
181
+ }
182
+ }
183
+ };
184
+ /**
185
+ * Marks a specific row as selected by checking its checkbox.
186
+ */
187
+ export const selectRow = (rows, rowId, dataAttribute, checkboxQuerySelector) => {
188
+ setRowCheckboxState(rows, rowId, dataAttribute, checkboxQuerySelector, true);
189
+ };
190
+ /**
191
+ * Marks a specific row as deselected by unchecking its checkbox.
192
+ */
193
+ export const deselectRow = (rows, rowId, dataAttribute, checkboxQuerySelector) => {
194
+ setRowCheckboxState(rows, rowId, dataAttribute, checkboxQuerySelector, false);
195
+ };
196
+ export default useTableSelection;
@@ -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"));
@@ -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.
@@ -43,7 +43,7 @@ const filterProps = (0, omit_1.default)([
43
43
  ]);
44
44
  const customCompare = (prevProps, nextProps) => (0, isEqual_1.default)(filterProps(prevProps), filterProps(nextProps));
45
45
  const Tree = react_1.default.memo((props) => {
46
- const { groups = [], items = [], selectedGroups = [], selectedItems = [], onSelectionChange = noop_1.default, hasMultiselect = true, showRadioButtons = false, hideSearch = false, hideTreeHead, treeHeaderContent, summary, hideSummary = false, search, searchPlaceholder = 'Type here to filter by name', onSearchChange = noop_1.default, className, scrollHeight, expandedGroups, onExpandGroupsChange = noop_1.default, showEmptyGroups = true, treeOptions = [], treeOptionsTooltip, disableAnimation = false, ...remainingProps } = props;
46
+ const { groups = [], items = [], selectedGroups = [], selectedItems = [], onSelectionChange = noop_1.default, hasMultiselect = true, showRadioButtons = false, hideSearch = false, hideTreeHead, treeHeaderContent, summary, hideSummary = false, search, searchPlaceholder = 'Type here to filter by name', onSearchChange = noop_1.default, className, scrollHeight, expandedGroups, onExpandGroupsChange = noop_1.default, showEmptyGroups = true, treeOptions = [], treeOptionsTooltip, disableAnimation = false, onTypeFilterChange = noop_1.default, ...remainingProps } = props;
47
47
  const [state, dispatch] = (0, react_1.useReducer)(treeReducer_1.treeReducer, {
48
48
  groupedItems: [],
49
49
  flatItems: [],
@@ -267,7 +267,9 @@ const Tree = react_1.default.memo((props) => {
267
267
  [stubTrue_1.default, () => renderFlatList()],
268
268
  ])();
269
269
  const handleFilterByType = (type) => {
270
- dispatch((0, treeReducer_1.typeFilterChanged)((0, treeUtils_1.addOrRemoveFromList)(state.typeFilter, type)));
270
+ const updatedTypeFilter = (0, treeUtils_1.addOrRemoveFromList)(state.typeFilter, type);
271
+ dispatch((0, treeReducer_1.typeFilterChanged)(updatedTypeFilter));
272
+ onTypeFilterChange(updatedTypeFilter);
271
273
  };
272
274
  const enableActivity = (0, size_1.default)(state.visibleTypeCounters) !== 1;
273
275
  const isFilterActive = (0, treeUtils_1.notEmpty)(state.typeFilter);
@@ -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 = tslib_1.__importDefault(require("react"));
7
7
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
8
8
  const isObject_1 = tslib_1.__importDefault(require("lodash/fp/isObject"));
@@ -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 = tslib_1.__importDefault(require("react"));
7
7
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
8
8
  const noop_1 = tslib_1.__importDefault(require("lodash/fp/noop"));
@@ -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 = tslib_1.__importDefault(require("react"));
7
7
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
8
8
  const TypeCounter_1 = tslib_1.__importDefault(require("./TypeCounter"));
@@ -33,6 +33,8 @@ export type TypeCounterProps = {
33
33
  hideOnZero?: boolean;
34
34
  /**
35
35
  * Callback function when the counter is clicked. It returns the type value.
36
+ * Make sure the "type" prop is defined to receive the value in the callback.
37
+ *
36
38
  * @param type
37
39
  * @returns
38
40
  */
@@ -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"));
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AutoSuggest = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
+ // biome-ignore lint/style/useImportType: <explanation>
6
7
  const react_1 = require("react");
7
8
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
8
9
  const isEmpty_1 = tslib_1.__importDefault(require("lodash/fp/isEmpty"));
@@ -25,7 +26,7 @@ const AutoSuggest = (props) => {
25
26
  onClear: noop_1.default,
26
27
  onBlur: noop_1.default,
27
28
  onFocus: noop_1.default,
28
- placeholder: 'Start typing ...',
29
+ placeholder: 'Start typing',
29
30
  hasError: false,
30
31
  tabIndex: 0,
31
32
  value: undefined,
@@ -3,7 +3,7 @@ export type ButtonToolbarProps = ComponentProps<'div'> & {
3
3
  /**
4
4
  * Align buttons to a defined side or set them apart.
5
5
  */
6
- alignment?: 'left' | 'right' | 'space-between';
6
+ alignment?: 'left' | 'right' | 'center' | 'space-between';
7
7
  /**
8
8
  * Additional classes set to the outer element.
9
9
  */
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
6
6
  const ButtonToolbar = (props) => {
7
7
  const { className = '', alignment, children, ...remainingProps } = props;
8
- const classes = (0, classnames_1.default)(className, 'btn-toolbar', alignment === 'left' && 'justify-content-start', alignment === 'right' && 'justify-content-end', alignment === 'space-between' && 'justify-content-between');
8
+ const classes = (0, classnames_1.default)(className, 'btn-toolbar', alignment === 'left' && 'justify-content-start', alignment === 'right' && 'justify-content-end', alignment === 'center' && 'justify-content-center', alignment === 'space-between' && 'justify-content-between');
9
9
  return ((0, jsx_runtime_1.jsx)("div", { ...remainingProps, className: classes, children: children }));
10
10
  };
11
11
  exports.default = ButtonToolbar;
@@ -3,6 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const Button_1 = tslib_1.__importDefault(require("./Button"));
6
- // @ts-ignore - the Button throws TS error due to refs that may be checked at a later point in time
7
6
  const ToggleButton = (props) => (0, jsx_runtime_1.jsx)(Button_1.default, { ...props, asToggle: true });
8
7
  exports.default = ToggleButton;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  export declare const DEFAULT_TYPE = "text";
3
3
  export declare const SUPPORTED_TYPES: string[];
4
+ export type MaskVisibility = 'always' | 'onFocus' | 'never';
4
5
  export type ClearableInputProps = {
5
6
  /**
6
7
  * Gives the input element the id.
@@ -69,7 +70,7 @@ export type ClearableInputProps = {
69
70
  * @param event
70
71
  * @returns
71
72
  */
72
- onFocus?: (event: React.MouseEvent<HTMLSpanElement>) => void;
73
+ onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
73
74
  /**
74
75
  * Callback function for when the value is cleared via the clear button.
75
76
  * @param event
@@ -93,22 +94,24 @@ export type ClearableInputProps = {
93
94
  * It defines the pattern that should be followed.
94
95
  *
95
96
  * For more details on masking, checkout the third party documentation for the
96
- * input mask here: {@link https://github.com/sanniassin/react-input-mask}
97
+ * input mask here: {@link https://imask.js.org/guide.html}
97
98
  *
98
99
  * Simple masks can be defined as strings.
99
100
  *
100
101
  * The following characters will define mask format:
101
102
  *
102
- * Character: "9" = allowed input: "0-9"
103
+ * Character: "0" = allowed input: "0-9" (digit)
103
104
  *
104
- * Character: "a" = allowed input: "a-z, A-Z"
105
+ * Character: "a" = allowed input: "a-z, A-Z" (letter)
105
106
  *
106
- * Character: "*" = allowed input: 0-9, a-z, A-Z
107
+ * Character: "*" = allowed input: any character
107
108
  *
108
- * Any format character can be escaped with a backslash.
109
+ * Character: "#" = allowed input: "0-9, a-z, A-Z" (digit or letter)
110
+ *
111
+ * Any other character in the mask is considered a fixed value.
109
112
  *
110
113
  * @example
111
- * '-- *** *** ***' or '+4\\9 99 999 99'
114
+ * '-- ### ### ###' or '+49 00 000 00'
112
115
  *
113
116
  * @example
114
117
  * ['0', '0', /[0-9]/, ' ', /[a-zA-Z]/]
@@ -127,11 +130,21 @@ export type ClearableInputProps = {
127
130
  * @default false
128
131
  */
129
132
  disabled?: boolean;
133
+ /**
134
+ * Controls when the mask pattern is visible.
135
+ * - 'always': Mask is always visible
136
+ * - 'onFocus': Mask is hidden but shown when input is focused (default)
137
+ * - 'never': Mask is never shown
138
+ *
139
+ * @default 'always'
140
+ */
141
+ maskVisibility?: MaskVisibility;
130
142
  /**
131
143
  * Whether mask prefix and placeholder should be displayed when input is empty and
132
144
  * has no focus.
133
145
  *
134
146
  * @default false
147
+ * @deprecated please use maskVisibility='always' instead
135
148
  */
136
149
  alwaysShowMask?: boolean;
137
150
  /**
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SUPPORTED_TYPES = exports.DEFAULT_TYPE = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
+ // biome-ignore lint/style/useImportType: <explanation>
6
7
  const react_1 = require("react");
7
8
  const omit_1 = tslib_1.__importDefault(require("lodash/fp/omit"));
8
9
  const isNil_1 = tslib_1.__importDefault(require("lodash/fp/isNil"));
@@ -10,18 +11,39 @@ const isEmpty_1 = tslib_1.__importDefault(require("lodash/fp/isEmpty"));
10
11
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
11
12
  const isFunction_1 = tslib_1.__importDefault(require("lodash/fp/isFunction"));
12
13
  const noop_1 = tslib_1.__importDefault(require("lodash/fp/noop"));
13
- const react_input_mask_1 = tslib_1.__importDefault(require("react-input-mask"));
14
+ const react_imask_1 = require("react-imask");
14
15
  const usePrevious_1 = tslib_1.__importDefault(require("../../hooks/usePrevious"));
16
+ const useMergeRefs_1 = tslib_1.__importDefault(require("../../hooks/useMergeRefs"));
15
17
  exports.DEFAULT_TYPE = 'text';
16
18
  exports.SUPPORTED_TYPES = ['text', 'password', 'email'];
17
19
  const hasValue = (value) => !(0, isEmpty_1.default)(`${value}`);
18
20
  const ClearableInput = (0, react_1.forwardRef)((props, ref) => {
19
- const { type = exports.DEFAULT_TYPE, defaultValue, value, maxLength, tabIndex = 0, hasError = false, inputRef, autoComplete, onChange = noop_1.default, onBlur = noop_1.default, onFocus = noop_1.default, onClear = noop_1.default, onKeyPress = noop_1.default, onClick = noop_1.default, mask, maskPlaceholder = '_', alwaysShowMask = false, inputClassName = '', disabled = false, className = '', children, ...remainingProps } = props;
21
+ const { type = exports.DEFAULT_TYPE, defaultValue, value, maxLength, tabIndex = 0, hasError = false, inputRef, autoComplete, onChange = noop_1.default, onBlur = noop_1.default, onFocus = noop_1.default, onClear = noop_1.default, onKeyPress = noop_1.default, onClick = noop_1.default, mask, maskPlaceholder = '_', maskVisibility = 'always', alwaysShowMask = false, inputClassName = '', disabled = false, className = '', children, ...remainingProps } = props;
20
22
  const initialValue = value || defaultValue || '';
21
23
  const [inputValue, setInputValue] = (0, react_1.useState)(initialValue);
22
24
  const [showClear, setShowClear] = (0, react_1.useState)(hasValue(initialValue));
25
+ const [isFocused, setIsFocused] = (0, react_1.useState)(false);
23
26
  const isControlled = !(0, isNil_1.default)(value);
27
+ const internalMaskRef = (0, react_1.useRef)(null);
28
+ const mergedInternalMaskRef = (0, useMergeRefs_1.default)(internalMaskRef, inputRef, ref);
24
29
  const hasMask = !!mask;
30
+ // Calculate if mask should be visible (lazy=false means visible, lazy=true means hidden)
31
+ const shouldShowMask = () => {
32
+ // For backward compatibility
33
+ if (alwaysShowMask) {
34
+ return true;
35
+ }
36
+ switch (maskVisibility) {
37
+ case 'always':
38
+ return true;
39
+ case 'onFocus':
40
+ return isFocused;
41
+ case 'never':
42
+ return false;
43
+ default:
44
+ return isFocused;
45
+ }
46
+ };
25
47
  // Handles new input value and saves it in the local state.
26
48
  // The value stored in the state is used for rendering.
27
49
  const changeInternalValue = (newValue = '') => {
@@ -48,6 +70,45 @@ const ClearableInput = (0, react_1.forwardRef)((props, ref) => {
48
70
  onChange(newValue, event);
49
71
  }
50
72
  };
73
+ const handleAccept = (newValue, maskRef, event) => {
74
+ if (!internalMaskRef.current) {
75
+ return;
76
+ }
77
+ // Simulate a ChangeEvent for backwards compatibility since react-imask does not return a change event itself
78
+ const syntheticEvent = {
79
+ target: internalMaskRef.current,
80
+ currentTarget: internalMaskRef.current,
81
+ // Standard synthetic event props
82
+ bubbles: true,
83
+ cancelable: true,
84
+ defaultPrevented: false,
85
+ isTrusted: true,
86
+ preventDefault: () => { },
87
+ stopPropagation: () => { },
88
+ persist: () => { },
89
+ nativeEvent: {},
90
+ type: 'change',
91
+ timeStamp: Date.now(),
92
+ };
93
+ // Set unmasked value manually if needed
94
+ // (you can use data-attributes or attach it directly)
95
+ syntheticEvent.target.unmaskedValue = maskRef.unmaskedValue;
96
+ if (isControlled) {
97
+ onChange(newValue, syntheticEvent);
98
+ }
99
+ else {
100
+ changeInternalValue(newValue);
101
+ onChange(newValue, syntheticEvent);
102
+ }
103
+ };
104
+ const handleInputFocus = (event) => {
105
+ setIsFocused(true);
106
+ onFocus(event);
107
+ };
108
+ const handleInputBlur = (event) => {
109
+ setIsFocused(false);
110
+ onBlur(event);
111
+ };
51
112
  // Will be triggered on every key press but also when pressing 'Enter' for example
52
113
  const handleKeyPress = (event) => {
53
114
  onKeyPress(event);
@@ -70,17 +131,16 @@ const ClearableInput = (0, react_1.forwardRef)((props, ref) => {
70
131
  autoComplete,
71
132
  type: inputType,
72
133
  value: inputValue,
73
- onChange: handleChange,
74
134
  onKeyPress: handleKeyPress,
75
- onBlur,
76
- onFocus,
135
+ onBlur: handleInputBlur,
136
+ onFocus: handleInputFocus,
137
+ onChange: hasMask ? undefined : handleChange, // In case of masked input, the onAccept callback is used
77
138
  onClick,
78
139
  disabled,
79
140
  maxLength: hasMask ? undefined : maxLength,
80
141
  tabIndex,
81
- ref: inputRef || ref,
82
142
  };
83
- const input = hasMask ? ((0, jsx_runtime_1.jsx)(react_input_mask_1.default, { ...inputProps, disabled: disabled, mask: mask, maskPlaceholder: maskPlaceholder, alwaysShowMask: alwaysShowMask })) : ((0, jsx_runtime_1.jsx)("input", { ...inputProps }));
143
+ const input = hasMask ? ((0, jsx_runtime_1.jsx)(react_imask_1.IMaskInput, { ...inputProps, ref: mergedInternalMaskRef, mask: mask, placeholderChar: maskPlaceholder, onAccept: handleAccept, lazy: !shouldShowMask(), overwrite: true })) : ((0, jsx_runtime_1.jsx)("input", { ...inputProps, ref: inputRef || ref }));
84
144
  return ((0, jsx_runtime_1.jsxs)("div", { className: classes, children: [children && (0, isFunction_1.default)(children) ? children(inputProps) : input, (0, jsx_runtime_1.jsx)("span", { className: clearButtonClassNames, onClick: clearInputValue, children: (0, jsx_runtime_1.jsx)("span", { className: 'clearButtonIcon rioglyph rioglyph-remove-sign' }) })] }));
85
145
  });
86
146
  exports.default = ClearableInput;
@@ -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 react_dom_1 = tslib_1.__importDefault(require("react-dom"));
8
8
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CLOSE_DIALOG_EVENT = exports.OPEN_DIALOG_EVENT = exports.DEFAULT_PREFIX = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
- // @ts-ignore-next-line importsNotUsedAsValues
6
+ // biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
7
7
  const react_1 = require("react");
8
8
  const iframe_resizer_react_1 = tslib_1.__importDefault(require("iframe-resizer-react"));
9
9
  const Dialog_1 = tslib_1.__importDefault(require("./Dialog"));