@rio-cloud/rio-uikit 1.3.0 → 1.4.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.
- package/ChartLabel.d.ts +2 -0
- package/ChartLabel.js +2 -0
- package/ComposedChart.d.ts +2 -0
- package/ComposedChart.js +2 -0
- package/GroupedItemList.d.ts +2 -0
- package/GroupedItemList.js +2 -0
- package/LicensePlate.d.ts +2 -0
- package/LicensePlate.js +2 -0
- package/ReferenceLine.d.ts +2 -0
- package/ReferenceLine.js +2 -0
- package/components/assetTree/TreeOptions.js +7 -3
- package/components/charts/Area.d.ts +5 -0
- package/components/charts/Area.js +1 -9
- package/components/charts/AreaChart.d.ts +2 -0
- package/components/charts/AreaChart.js +9 -6
- package/components/charts/BarChart.js +4 -4
- package/components/charts/ChartLabel.d.ts +5 -0
- package/components/charts/ChartLabel.js +2 -0
- package/components/charts/ComposedChart.d.ts +34 -0
- package/components/charts/ComposedChart.js +30 -0
- package/components/charts/Legend.d.ts +8 -10
- package/components/charts/Legend.js +3 -12
- package/components/charts/Line.d.ts +5 -0
- package/components/charts/Line.js +1 -9
- package/components/charts/LineChart.d.ts +2 -0
- package/components/charts/LineChart.js +8 -5
- package/components/charts/PieChart.js +5 -5
- package/components/charts/RadialBarChart.js +5 -5
- package/components/charts/ReferenceLine.d.ts +7 -0
- package/components/charts/ReferenceLine.js +2 -0
- package/components/dialog/Dialog.d.ts +12 -4
- package/components/dialog/SplitDialog.d.ts +3 -3
- package/components/groupedItemList/GroupedItemList.d.ts +79 -0
- package/components/groupedItemList/GroupedItemList.js +77 -0
- package/components/licensePlate/LicensePlate.d.ts +19 -0
- package/components/licensePlate/LicensePlate.js +14 -0
- package/components/selects/BaseSelectDropdown.d.ts +1 -0
- package/components/selects/BaseSelectDropdown.js +16 -14
- package/components/selects/Multiselect.d.ts +5 -0
- package/components/selects/Multiselect.js +2 -2
- package/components/selects/Select.d.ts +5 -0
- package/components/selects/Select.js +2 -2
- package/hooks/useKey.d.ts +7 -4
- package/hooks/useKey.js +36 -8
- package/lib/es/ChartLabel.d.ts +2 -0
- package/lib/es/ChartLabel.js +7 -0
- package/lib/es/ComposedChart.d.ts +2 -0
- package/lib/es/ComposedChart.js +7 -0
- package/lib/es/GroupedItemList.d.ts +2 -0
- package/lib/es/GroupedItemList.js +7 -0
- package/lib/es/LicensePlate.d.ts +2 -0
- package/lib/es/LicensePlate.js +7 -0
- package/lib/es/ReferenceLine.d.ts +2 -0
- package/lib/es/ReferenceLine.js +7 -0
- package/lib/es/components/assetTree/TreeOptions.js +7 -3
- package/lib/es/components/charts/Area.d.ts +5 -0
- package/lib/es/components/charts/Area.js +1 -9
- package/lib/es/components/charts/AreaChart.d.ts +2 -0
- package/lib/es/components/charts/AreaChart.js +7 -4
- package/lib/es/components/charts/BarChart.js +3 -3
- package/lib/es/components/charts/ChartLabel.d.ts +5 -0
- package/lib/es/components/charts/ChartLabel.js +4 -0
- package/lib/es/components/charts/ComposedChart.d.ts +34 -0
- package/lib/es/components/charts/ComposedChart.js +32 -0
- package/lib/es/components/charts/Legend.d.ts +8 -10
- package/lib/es/components/charts/Legend.js +5 -12
- package/lib/es/components/charts/Line.d.ts +5 -0
- package/lib/es/components/charts/Line.js +1 -9
- package/lib/es/components/charts/LineChart.d.ts +2 -0
- package/lib/es/components/charts/LineChart.js +7 -4
- package/lib/es/components/charts/PieChart.js +4 -4
- package/lib/es/components/charts/RadialBarChart.js +4 -4
- package/lib/es/components/charts/ReferenceLine.d.ts +7 -0
- package/lib/es/components/charts/ReferenceLine.js +4 -0
- package/lib/es/components/dialog/Dialog.d.ts +12 -4
- package/lib/es/components/dialog/SplitDialog.d.ts +3 -3
- package/lib/es/components/groupedItemList/GroupedItemList.d.ts +79 -0
- package/lib/es/components/groupedItemList/GroupedItemList.js +80 -0
- package/lib/es/components/licensePlate/LicensePlate.d.ts +19 -0
- package/lib/es/components/licensePlate/LicensePlate.js +16 -0
- package/lib/es/components/selects/BaseSelectDropdown.d.ts +1 -0
- package/lib/es/components/selects/BaseSelectDropdown.js +16 -14
- package/lib/es/components/selects/Multiselect.d.ts +5 -0
- package/lib/es/components/selects/Multiselect.js +2 -2
- package/lib/es/components/selects/Select.d.ts +5 -0
- package/lib/es/components/selects/Select.js +2 -2
- package/lib/es/hooks/useKey.d.ts +7 -4
- package/lib/es/hooks/useKey.js +35 -7
- package/lib/es/utils/colorScheme.js +10 -8
- package/lib/es/version.json +1 -1
- package/package.json +11 -11
- package/utils/colorScheme.js +10 -8
- package/version.json +1 -1
|
@@ -14,11 +14,12 @@ const useEffectOnce_1 = tslib_1.__importDefault(require("../../hooks/useEffectOn
|
|
|
14
14
|
const useKey_1 = tslib_1.__importDefault(require("../../useKey"));
|
|
15
15
|
const DropdownHeader_1 = tslib_1.__importDefault(require("./DropdownHeader"));
|
|
16
16
|
const NoItemMessage_1 = tslib_1.__importDefault(require("./NoItemMessage"));
|
|
17
|
+
const Spinner_1 = tslib_1.__importDefault(require("../spinner/Spinner"));
|
|
17
18
|
const DATA_ATTRIBUTE_ID = 'data-item-id';
|
|
18
19
|
const DEFAULT_FOCUSED_ITEM_INDEX = 0;
|
|
19
20
|
const HIGHLIGHT_CLASS = 'focus';
|
|
20
21
|
const BaseSelectDropdown = (props) => {
|
|
21
|
-
const { isOpen = false, updateDOMValues = noop_1.default, onOpen = noop_1.default, onSelect = noop_1.default, onClose = noop_1.default, options = [], autoDropDirection = true, dropup = false, pullRight = false, useActiveClass = false, focusedItemIndex: externalFocusedItemIndex, keyboardUsed: externalKeyboardUsed, noItemMessage, dropdownClassName, } = props;
|
|
22
|
+
const { isOpen = false, isLoading = false, updateDOMValues = noop_1.default, onOpen = noop_1.default, onSelect = noop_1.default, onClose = noop_1.default, options = [], autoDropDirection = true, dropup = false, pullRight = false, useActiveClass = false, focusedItemIndex: externalFocusedItemIndex, keyboardUsed: externalKeyboardUsed, noItemMessage, dropdownClassName, } = props;
|
|
22
23
|
const [focusedItemIndex, setFocusedItemIndex] = (0, react_1.useState)(externalFocusedItemIndex || DEFAULT_FOCUSED_ITEM_INDEX);
|
|
23
24
|
const [keyboardUsed, setKeyboardUsed] = (0, react_1.useState)(externalKeyboardUsed);
|
|
24
25
|
const dropdownMenuRef = (0, react_1.useRef)(null);
|
|
@@ -154,19 +155,20 @@ const BaseSelectDropdown = (props) => {
|
|
|
154
155
|
if ((0, isEmpty_1.default)(options)) {
|
|
155
156
|
return (0, jsx_runtime_1.jsx)(NoItemMessage_1.default, { noItemMessage: noItemMessage, className: dropdownMenuClasses });
|
|
156
157
|
}
|
|
157
|
-
return ((0, jsx_runtime_1.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
158
|
+
return ((0, jsx_runtime_1.jsxs)("ul", Object.assign({ className: dropdownMenuClasses, ref: dropdownMenuRef, role: 'menu' }, { children: [isLoading && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'display-flex justify-content-center padding-10' }, { children: (0, jsx_runtime_1.jsx)(Spinner_1.default, {}) }))), !isLoading &&
|
|
159
|
+
options.map((option, index) => {
|
|
160
|
+
if (option.header) {
|
|
161
|
+
return (0, jsx_runtime_1.jsx)(DropdownHeader_1.default, { icon: option.icon, label: option.label }, option.id);
|
|
162
|
+
}
|
|
163
|
+
// Show focused style only when keyboard is in use
|
|
164
|
+
const anchorClassNames = (0, classnames_1.default)('display-flex align-items-center', keyboardUsed && focusedItemIndex === index ? HIGHLIGHT_CLASS : '', option.disabled && 'pointer-events-none');
|
|
165
|
+
const wrapperClassNames = (0, classnames_1.default)(option.disabled && 'disabled', useActiveClass && option.selected && 'active');
|
|
166
|
+
return ((0, jsx_runtime_1.jsx)("li", Object.assign({ className: wrapperClassNames, role: 'listitem' }, { children: (0, jsx_runtime_1.jsxs)("a", Object.assign({ role: 'menuitem', className: anchorClassNames, "data-item-id": option.id, "data-item-index": index,
|
|
167
|
+
// Note, we need to assign the click callback only when it's not disabled
|
|
168
|
+
// otherwise the functions is still triggered
|
|
169
|
+
// biome-ignore lint/a11y/useValidAnchor: due to old structure + backwards compatibility
|
|
170
|
+
onClick: option.disabled ? undefined : handleOptionChange }, { children: [(0, jsx_runtime_1.jsxs)("span", { children: [option.icon && (0, jsx_runtime_1.jsx)("span", Object.assign({ className: 'margin-right-5' }, { children: option.icon })), option.label] }), (0, jsx_runtime_1.jsx)("input", { type: 'hidden', value: option.id })] })) }), option.id));
|
|
171
|
+
})] })));
|
|
170
172
|
};
|
|
171
173
|
const filterOptions = (itemDOMValues, filterValue, options) => {
|
|
172
174
|
const filteredDOMValues = itemDOMValues.filter(item => item.text.toLowerCase().includes(filterValue.toLowerCase()));
|
|
@@ -69,6 +69,11 @@ export type MultiselectProps<T extends MultiselectOption> = Omit<WithFeedbackAnd
|
|
|
69
69
|
* @default true
|
|
70
70
|
*/
|
|
71
71
|
autoDropDirection?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Shows a loading spinner instead of the menu items if set to true.
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
isLoading?: boolean;
|
|
72
77
|
/**
|
|
73
78
|
* Defines the size of the select to be rendered.
|
|
74
79
|
*
|
|
@@ -18,7 +18,7 @@ const useMergeRefs_1 = tslib_1.__importDefault(require("../../hooks/useMergeRefs
|
|
|
18
18
|
const WithFeedbackAndAddon_1 = tslib_1.__importDefault(require("./WithFeedbackAndAddon"));
|
|
19
19
|
const DEFAULT_FOCUSED_ITEM_INDEX = -1;
|
|
20
20
|
const Multiselect = (props) => {
|
|
21
|
-
const { name, id = name, options = [], value, onChange = noop_1.default, placeholder, dropup = false, pullRight = false, autoDropDirection = true, bsSize = 'md', disabled = false, tabIndex = 0, hasError = false, useFilter = false, multiline = false, noItemMessage, counterMessage, renderCounterMessage, showSelectedItemIcon = false, showUnselectedItemIcons = false, className, inputAddon, errorMessage, warningMessage, messageWhiteSpace = 'normal' } = props, remainingProps = tslib_1.__rest(props, ["name", "id", "options", "value", "onChange", "placeholder", "dropup", "pullRight", "autoDropDirection", "bsSize", "disabled", "tabIndex", "hasError", "useFilter", "multiline", "noItemMessage", "counterMessage", "renderCounterMessage", "showSelectedItemIcon", "showUnselectedItemIcons", "className", "inputAddon", "errorMessage", "warningMessage", "messageWhiteSpace"]);
|
|
21
|
+
const { name, id = name, options = [], value, onChange = noop_1.default, placeholder, isLoading = false, dropup = false, pullRight = false, autoDropDirection = true, bsSize = 'md', disabled = false, tabIndex = 0, hasError = false, useFilter = false, multiline = false, noItemMessage, counterMessage, renderCounterMessage, showSelectedItemIcon = false, showUnselectedItemIcons = false, className, inputAddon, errorMessage, warningMessage, messageWhiteSpace = 'normal' } = props, remainingProps = tslib_1.__rest(props, ["name", "id", "options", "value", "onChange", "placeholder", "isLoading", "dropup", "pullRight", "autoDropDirection", "bsSize", "disabled", "tabIndex", "hasError", "useFilter", "multiline", "noItemMessage", "counterMessage", "renderCounterMessage", "showSelectedItemIcon", "showUnselectedItemIcons", "className", "inputAddon", "errorMessage", "warningMessage", "messageWhiteSpace"]);
|
|
22
22
|
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
23
23
|
const [selectedItemIds, setSelectedItemIds] = (0, react_1.useState)(value || []);
|
|
24
24
|
const [isFilterActive, setIsFilterActive] = (0, react_1.useState)(false);
|
|
@@ -88,7 +88,7 @@ const Multiselect = (props) => {
|
|
|
88
88
|
option.selected = selectedItemIds.indexOf(option.id) !== -1;
|
|
89
89
|
return option;
|
|
90
90
|
});
|
|
91
|
-
return ((0, jsx_runtime_1.jsx)(BaseSelectDropdown_1.default, { isOpen: isOpen, options: nonSelectedOptions, focusedItemIndex: focusedItemIndex, keyboardUsed: keyboardUsed, updateDOMValues: updateDOMValues, onSelect: onOptionChange, onClose: closeMenu, noItemMessage: noItemMessage, pullRight: pullRight, useActiveClass: true, dropup: dropup, autoDropDirection: autoDropDirection, requestItemDOMValues: requestItemDOMValues }));
|
|
91
|
+
return ((0, jsx_runtime_1.jsx)(BaseSelectDropdown_1.default, { isOpen: isOpen, isLoading: isLoading, options: nonSelectedOptions, focusedItemIndex: focusedItemIndex, keyboardUsed: keyboardUsed, updateDOMValues: updateDOMValues, onSelect: onOptionChange, onClose: closeMenu, noItemMessage: noItemMessage, pullRight: pullRight, useActiveClass: true, dropup: dropup, autoDropDirection: autoDropDirection, requestItemDOMValues: requestItemDOMValues }));
|
|
92
92
|
};
|
|
93
93
|
const handleFilterChange = (event) => {
|
|
94
94
|
event.preventDefault();
|
|
@@ -103,6 +103,11 @@ export type SelectProps<T extends SelectOption> = Omit<WithFeedbackAndAddonProps
|
|
|
103
103
|
* @default false
|
|
104
104
|
*/
|
|
105
105
|
useClear?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Shows a loading spinner instead of the menu items if set to true.
|
|
108
|
+
* @default false
|
|
109
|
+
*/
|
|
110
|
+
isLoading?: boolean;
|
|
106
111
|
/**
|
|
107
112
|
* Text that shall be shown when not match was found when filtering.
|
|
108
113
|
*/
|
|
@@ -17,7 +17,7 @@ const SelectedOption_1 = tslib_1.__importDefault(require("./SelectedOption"));
|
|
|
17
17
|
const WithFeedbackAndAddon_1 = tslib_1.__importDefault(require("./WithFeedbackAndAddon"));
|
|
18
18
|
const DEFAULT_FOCUSED_ITEM_INDEX = -1;
|
|
19
19
|
const Select = (props) => {
|
|
20
|
-
const { name, id = name, label, options = [], value, onChange = noop_1.default, placeholder, dropup = false, pullRight = false, autoDropDirection = true, bsSize = 'md', disabled = false, tabIndex = 0, hasError = false, useFilter = false, useClear = false, noItemMessage, selectedOptionText, showSelectedItemIcon = false, showUnselectedItemIcons = false, dropdownClassName, btnClassName, className, inputAddon, errorMessage, warningMessage, messageWhiteSpace = 'normal' } = props, remainingProps = tslib_1.__rest(props, ["name", "id", "label", "options", "value", "onChange", "placeholder", "dropup", "pullRight", "autoDropDirection", "bsSize", "disabled", "tabIndex", "hasError", "useFilter", "useClear", "noItemMessage", "selectedOptionText", "showSelectedItemIcon", "showUnselectedItemIcons", "dropdownClassName", "btnClassName", "className", "inputAddon", "errorMessage", "warningMessage", "messageWhiteSpace"]);
|
|
20
|
+
const { name, id = name, label, options = [], value, onChange = noop_1.default, placeholder, isLoading = false, dropup = false, pullRight = false, autoDropDirection = true, bsSize = 'md', disabled = false, tabIndex = 0, hasError = false, useFilter = false, useClear = false, noItemMessage, selectedOptionText, showSelectedItemIcon = false, showUnselectedItemIcons = false, dropdownClassName, btnClassName, className, inputAddon, errorMessage, warningMessage, messageWhiteSpace = 'normal' } = props, remainingProps = tslib_1.__rest(props, ["name", "id", "label", "options", "value", "onChange", "placeholder", "isLoading", "dropup", "pullRight", "autoDropDirection", "bsSize", "disabled", "tabIndex", "hasError", "useFilter", "useClear", "noItemMessage", "selectedOptionText", "showSelectedItemIcon", "showUnselectedItemIcons", "dropdownClassName", "btnClassName", "className", "inputAddon", "errorMessage", "warningMessage", "messageWhiteSpace"]);
|
|
21
21
|
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
22
22
|
const [selectedItem, setSelectedItem] = (0, react_1.useState)(null);
|
|
23
23
|
const [isFilterActive, setIsFilterActive] = (0, react_1.useState)(false);
|
|
@@ -84,7 +84,7 @@ const Select = (props) => {
|
|
|
84
84
|
else if (keyboardUsed) {
|
|
85
85
|
currentFocusedItemIndex = 0;
|
|
86
86
|
}
|
|
87
|
-
return ((0, jsx_runtime_1.jsx)(BaseSelectDropdown_1.default, { isOpen: isOpen, options: filteredOptions, focusedItemIndex: currentFocusedItemIndex, keyboardUsed: keyboardUsed, updateDOMValues: updateDOMValues, onSelect: onOptionChange, onClose: closeMenu, noItemMessage: noItemMessage, pullRight: pullRight, dropup: dropup, autoDropDirection: autoDropDirection, dropdownClassName: dropdownClassName, requestItemDOMValues: requestItemDOMValues }));
|
|
87
|
+
return ((0, jsx_runtime_1.jsx)(BaseSelectDropdown_1.default, { isOpen: isOpen, isLoading: isLoading, options: filteredOptions, focusedItemIndex: currentFocusedItemIndex, keyboardUsed: keyboardUsed, updateDOMValues: updateDOMValues, onSelect: onOptionChange, onClose: closeMenu, noItemMessage: noItemMessage, pullRight: pullRight, dropup: dropup, autoDropDirection: autoDropDirection, dropdownClassName: dropdownClassName, requestItemDOMValues: requestItemDOMValues }));
|
|
88
88
|
};
|
|
89
89
|
const handleFilterChange = (event) => {
|
|
90
90
|
event.preventDefault();
|
package/lib/es/hooks/useKey.d.ts
CHANGED
|
@@ -2,9 +2,12 @@ type KeyboardEventType = 'keyup' | 'keydown' | 'keypress';
|
|
|
2
2
|
/**
|
|
3
3
|
* Custom hook to handle keyboard events.
|
|
4
4
|
*
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
*
|
|
5
|
+
* @param keyOrCallback - Either a key string (e.g., 'Enter') or a callback function.
|
|
6
|
+
* @param callbackOrEventTypes - If the first argument is a key, this should be the callback function.
|
|
7
|
+
* If the first argument is a callback, this is an optional array of event types.
|
|
8
|
+
* @param [eventTypesOrNode=['keydown']] - If the first argument is a key, this should be an array of event types.
|
|
9
|
+
* If the first argument is a callback, this is the node (defaults to document).
|
|
10
|
+
* @param [node=document] - Optional DOM node to attach the event listener to (defaults to document).
|
|
8
11
|
*/
|
|
9
|
-
declare const useKey: (
|
|
12
|
+
declare const useKey: (keyOrCallback: string | ((event: KeyboardEvent) => void), callbackOrEventTypes?: ((event: KeyboardEvent) => void | KeyboardEventType[]) | undefined, eventTypesOrNode?: KeyboardEventType[] | Document, node?: Document | HTMLElement) => void;
|
|
10
13
|
export default useKey;
|
package/lib/es/hooks/useKey.js
CHANGED
|
@@ -4,20 +4,48 @@ const react_1 = require("react");
|
|
|
4
4
|
/**
|
|
5
5
|
* Custom hook to handle keyboard events.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
*
|
|
7
|
+
* @param keyOrCallback - Either a key string (e.g., 'Enter') or a callback function.
|
|
8
|
+
* @param callbackOrEventTypes - If the first argument is a key, this should be the callback function.
|
|
9
|
+
* If the first argument is a callback, this is an optional array of event types.
|
|
10
|
+
* @param [eventTypesOrNode=['keydown']] - If the first argument is a key, this should be an array of event types.
|
|
11
|
+
* If the first argument is a callback, this is the node (defaults to document).
|
|
12
|
+
* @param [node=document] - Optional DOM node to attach the event listener to (defaults to document).
|
|
10
13
|
*/
|
|
11
|
-
const useKey = (
|
|
14
|
+
const useKey = (keyOrCallback, callbackOrEventTypes, eventTypesOrNode = ['keydown'], node = document) => {
|
|
15
|
+
const callbacksRef = (0, react_1.useRef)([]);
|
|
12
16
|
(0, react_1.useEffect)(() => {
|
|
17
|
+
const isKeyMode = typeof keyOrCallback === 'string';
|
|
18
|
+
const callback = isKeyMode
|
|
19
|
+
? callbackOrEventTypes
|
|
20
|
+
: keyOrCallback;
|
|
21
|
+
const keyHandler = (event) => {
|
|
22
|
+
if (isKeyMode) {
|
|
23
|
+
if (event.key === keyOrCallback) {
|
|
24
|
+
callback(event);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
callback(event);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
// Register the keyHandler
|
|
32
|
+
callbacksRef.current.push(keyHandler);
|
|
33
|
+
const genericHandler = (event) => {
|
|
34
|
+
for (const callBecky of callbacksRef.current) {
|
|
35
|
+
callBecky(event);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const eventTypes = Array.isArray(eventTypesOrNode) ? eventTypesOrNode : ['keydown'];
|
|
13
39
|
for (const eventType of eventTypes) {
|
|
14
|
-
node.addEventListener(eventType,
|
|
40
|
+
node.addEventListener(eventType, genericHandler);
|
|
15
41
|
}
|
|
16
42
|
return () => {
|
|
17
43
|
for (const eventType of eventTypes) {
|
|
18
|
-
node.removeEventListener(eventType,
|
|
44
|
+
node.removeEventListener(eventType, genericHandler);
|
|
19
45
|
}
|
|
46
|
+
// Clean up callback reference
|
|
47
|
+
callbacksRef.current = callbacksRef.current.filter(singleCallback => singleCallback !== keyHandler);
|
|
20
48
|
};
|
|
21
|
-
}, [
|
|
49
|
+
}, [keyOrCallback, callbackOrEventTypes, eventTypesOrNode, node]);
|
|
22
50
|
};
|
|
23
51
|
exports.default = useKey;
|
|
@@ -12,12 +12,11 @@ exports.THEME_SYSTEM = 'system';
|
|
|
12
12
|
exports.THEME_LIGHT = 'light';
|
|
13
13
|
exports.THEME_DARK = 'dark';
|
|
14
14
|
const updateHtmlScheme = (scheme) => {
|
|
15
|
-
const html = document.documentElement;
|
|
16
15
|
if (scheme) {
|
|
17
|
-
|
|
16
|
+
document.documentElement.setAttribute(exports.THEME_DATA_ATTRIBUTE, scheme);
|
|
18
17
|
}
|
|
19
18
|
else {
|
|
20
|
-
|
|
19
|
+
document.documentElement.removeAttribute(exports.THEME_DATA_ATTRIBUTE);
|
|
21
20
|
}
|
|
22
21
|
};
|
|
23
22
|
const getSchemeFromCookie = () => {
|
|
@@ -61,7 +60,7 @@ exports.getColorScheme = getColorScheme;
|
|
|
61
60
|
* @param scheme The color scheme to save.
|
|
62
61
|
*/
|
|
63
62
|
const setColorScheme = (scheme) => {
|
|
64
|
-
const isDevEnv =
|
|
63
|
+
const isDevEnv = window.location.host.startsWith('localhost') || window.location.host.startsWith('127.0.0.1');
|
|
65
64
|
const newCookieValues = encodeURIComponent(scheme);
|
|
66
65
|
const domain = isDevEnv ? 'localhost' : DOMAIN;
|
|
67
66
|
document.cookie = `${COOKIE_NAME}=${newCookieValues};domain=${domain};expires=${EXPIRATION_DATE};path=${PATH}`;
|
|
@@ -71,11 +70,14 @@ exports.setColorScheme = setColorScheme;
|
|
|
71
70
|
* Initiates listening for theme change events.
|
|
72
71
|
*/
|
|
73
72
|
const listenForSchemeChange = () => {
|
|
74
|
-
window
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
window.addEventListener('message', ({ data }) => {
|
|
74
|
+
var _a;
|
|
75
|
+
if (data === exports.THEME_CHANGE_EVENT) {
|
|
76
|
+
(0, exports.getColorScheme)();
|
|
77
77
|
// Re-send the event to all iframes that might not be notified yet
|
|
78
|
-
|
|
78
|
+
for (const iframe of document.getElementsByTagName('iframe')) {
|
|
79
|
+
(_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(exports.THEME_CHANGE_EVENT, '*');
|
|
80
|
+
}
|
|
79
81
|
}
|
|
80
82
|
}, false);
|
|
81
83
|
};
|
package/lib/es/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rio-cloud/rio-uikit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "The RIO UIKIT component library",
|
|
5
5
|
"repository": "https://bitbucket.collaboration-man.com/projects/RIOFRONT/repos/uikit-web/browse",
|
|
6
6
|
"scripts": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@testing-library/user-event": "14.5.2",
|
|
54
54
|
"@types/heremaps": "3.1.14",
|
|
55
55
|
"@types/lodash": "4.17.7",
|
|
56
|
-
"@types/react": "18.3.
|
|
56
|
+
"@types/react": "18.3.5",
|
|
57
57
|
"@types/react-dom": "18.3.0",
|
|
58
58
|
"@types/react-input-mask": "3.0.5",
|
|
59
59
|
"@types/react-redux": "7.1.33",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@typescript-eslint/parser": "6.13.2",
|
|
63
63
|
"@vitejs/plugin-react": "4.3.1",
|
|
64
64
|
"@vitest/coverage-c8": "0.33.0",
|
|
65
|
-
"autoprefixer": "10.4.
|
|
65
|
+
"autoprefixer": "10.4.20",
|
|
66
66
|
"backstopjs": "6.3.23",
|
|
67
67
|
"copyfiles": "2.4.1",
|
|
68
68
|
"dotenv": "16.4.5",
|
|
@@ -70,16 +70,16 @@
|
|
|
70
70
|
"eslint-config-prettier": "9.1.0",
|
|
71
71
|
"eslint-plugin-compat": "4.2.0",
|
|
72
72
|
"eslint-plugin-getsentry": "2.0.0",
|
|
73
|
-
"eslint-plugin-import": "2.
|
|
73
|
+
"eslint-plugin-import": "2.30.0",
|
|
74
74
|
"eslint-plugin-prefer-arrow": "1.2.3",
|
|
75
75
|
"eslint-plugin-prettier": "5.2.1",
|
|
76
|
-
"eslint-plugin-react": "7.35.
|
|
76
|
+
"eslint-plugin-react": "7.35.2",
|
|
77
77
|
"eslint-plugin-react-hooks": "4.6.2",
|
|
78
|
-
"jsdom": "
|
|
78
|
+
"jsdom": "25.0.0",
|
|
79
79
|
"jsdom-global": "3.0.2",
|
|
80
80
|
"less": "4.2.0",
|
|
81
81
|
"license-checker": "25.0.1",
|
|
82
|
-
"postcss": "8.4.
|
|
82
|
+
"postcss": "8.4.45",
|
|
83
83
|
"postcss-preset-env": "8.5.1",
|
|
84
84
|
"postcss-short": "5.0.0",
|
|
85
85
|
"pre-commit": "1.2.2",
|
|
@@ -93,8 +93,8 @@
|
|
|
93
93
|
"tiny-invariant": "1.3.3",
|
|
94
94
|
"typescript": "4.9.5",
|
|
95
95
|
"vite": "4.5.0",
|
|
96
|
-
"vite-plugin-zip-pack": "1.2.
|
|
97
|
-
"vitest": "
|
|
96
|
+
"vite-plugin-zip-pack": "1.2.4",
|
|
97
|
+
"vitest": "2.0.5",
|
|
98
98
|
"webfonts-generator": "github:rio-cloud/webfonts-generator#f666e60803da9155175a7f1775e09671d47a383b"
|
|
99
99
|
},
|
|
100
100
|
"peerDependencies": {
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"iframe-resizer-react": "1.1.0",
|
|
114
114
|
"lodash": "4.17.21",
|
|
115
115
|
"moment": "2.30.1",
|
|
116
|
-
"natural-orderby": "
|
|
116
|
+
"natural-orderby": "3.0.2",
|
|
117
117
|
"process": "0.11.10",
|
|
118
118
|
"prop-types": "15.8.1",
|
|
119
119
|
"react-bootstrap": "1.6.4",
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
"react-popper": "2.3.0",
|
|
128
128
|
"react-shadow-root": "6.2.0",
|
|
129
129
|
"recharts": "2.12.7",
|
|
130
|
-
"tslib": "2.
|
|
130
|
+
"tslib": "2.7.0"
|
|
131
131
|
},
|
|
132
132
|
"overrides": {
|
|
133
133
|
"iframe-resizer": "4.3.11"
|
package/utils/colorScheme.js
CHANGED
|
@@ -9,12 +9,11 @@ export const THEME_SYSTEM = 'system';
|
|
|
9
9
|
export const THEME_LIGHT = 'light';
|
|
10
10
|
export const THEME_DARK = 'dark';
|
|
11
11
|
const updateHtmlScheme = (scheme) => {
|
|
12
|
-
const html = document.documentElement;
|
|
13
12
|
if (scheme) {
|
|
14
|
-
|
|
13
|
+
document.documentElement.setAttribute(THEME_DATA_ATTRIBUTE, scheme);
|
|
15
14
|
}
|
|
16
15
|
else {
|
|
17
|
-
|
|
16
|
+
document.documentElement.removeAttribute(THEME_DATA_ATTRIBUTE);
|
|
18
17
|
}
|
|
19
18
|
};
|
|
20
19
|
const getSchemeFromCookie = () => {
|
|
@@ -57,7 +56,7 @@ export const getColorScheme = () => {
|
|
|
57
56
|
* @param scheme The color scheme to save.
|
|
58
57
|
*/
|
|
59
58
|
export const setColorScheme = (scheme) => {
|
|
60
|
-
const isDevEnv =
|
|
59
|
+
const isDevEnv = window.location.host.startsWith('localhost') || window.location.host.startsWith('127.0.0.1');
|
|
61
60
|
const newCookieValues = encodeURIComponent(scheme);
|
|
62
61
|
const domain = isDevEnv ? 'localhost' : DOMAIN;
|
|
63
62
|
document.cookie = `${COOKIE_NAME}=${newCookieValues};domain=${domain};expires=${EXPIRATION_DATE};path=${PATH}`;
|
|
@@ -66,11 +65,14 @@ export const setColorScheme = (scheme) => {
|
|
|
66
65
|
* Initiates listening for theme change events.
|
|
67
66
|
*/
|
|
68
67
|
export const listenForSchemeChange = () => {
|
|
69
|
-
window
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
window.addEventListener('message', ({ data }) => {
|
|
69
|
+
var _a;
|
|
70
|
+
if (data === THEME_CHANGE_EVENT) {
|
|
71
|
+
getColorScheme();
|
|
72
72
|
// Re-send the event to all iframes that might not be notified yet
|
|
73
|
-
|
|
73
|
+
for (const iframe of document.getElementsByTagName('iframe')) {
|
|
74
|
+
(_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(THEME_CHANGE_EVENT, '*');
|
|
75
|
+
}
|
|
74
76
|
}
|
|
75
77
|
}, false);
|
|
76
78
|
};
|
package/version.json
CHANGED