@rio-cloud/rio-uikit 1.7.0 → 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.
- package/README.md +4 -0
- package/SvgImage.d.ts +2 -0
- package/SvgImage.js +2 -0
- package/TableCol.d.ts +2 -0
- package/TableCol.js +2 -0
- package/TableHead.d.ts +2 -0
- package/TableHead.js +2 -0
- package/components/actionBarItem/ActionBarItemIcon.js +1 -1
- package/components/actionBarItem/ActionBarOverlay.js +1 -1
- package/components/applicationHeader/CollapsedNavItem.js +1 -0
- package/components/assetTree/Tree.d.ts +8 -0
- package/components/assetTree/Tree.js +4 -2
- package/components/assetTree/TreeLeaf.js +1 -1
- package/components/assetTree/TreeSearch.js +1 -1
- package/components/assetTree/TreeSummary.js +1 -1
- package/components/assetTree/TypeCounter.d.ts +2 -0
- package/components/assetTree/TypeCounter.js +1 -1
- package/components/autosuggest/AutoSuggest.js +2 -1
- package/components/banner/Banner.d.ts +6 -0
- package/components/banner/Banner.js +33 -8
- package/components/button/ButtonToolbar.d.ts +1 -1
- package/components/button/ButtonToolbar.js +1 -1
- package/components/button/ToggleButton.js +0 -1
- package/components/clearableInput/ClearableInput.d.ts +20 -7
- package/components/clearableInput/ClearableInput.js +68 -8
- package/components/dialog/Dialog.js +1 -1
- package/components/dialog/FrameDialog.js +1 -1
- package/components/dropdown/ButtonDropdown.d.ts +11 -3
- package/components/dropdown/ButtonDropdown.js +79 -64
- package/components/dropdown/DropdownToggleButton.d.ts +7 -4
- package/components/dropdown/DropdownToggleButton.js +11 -3
- package/components/formLabel/FormLabel.js +24 -4
- package/components/listMenu/ListMenu.js +8 -4
- package/components/map/components/Map.js +1 -1
- package/components/map/components/features/basics/InfoBubble.js +1 -1
- package/components/map/components/features/layers/overlayLayers/IncidentsLayer.js +1 -1
- package/components/mapMarker/SingleMapMarker.js +1 -1
- package/components/menuItems/MenuItem.js +1 -1
- package/components/notification/Notification.js +1 -1
- package/components/overlay/OverlayTrigger.js +1 -1
- package/components/selects/BaseSelectDropdown.js +1 -1
- package/components/selects/Multiselect.d.ts +8 -0
- package/components/selects/Multiselect.js +4 -4
- package/components/smoothScrollbars/SmoothScrollbars.js +1 -1
- package/components/svgImage/SvgElement.d.ts +8 -0
- package/components/svgImage/SvgElement.js +11 -0
- package/components/svgImage/SvgImage.d.ts +30 -0
- package/components/svgImage/SvgImage.js +20 -0
- package/components/svgImage/svgConverter.d.ts +17 -0
- package/components/svgImage/svgConverter.js +78 -0
- package/components/svgImage/useSvgLoader.d.ts +9 -0
- package/components/svgImage/useSvgLoader.js +43 -0
- package/components/switch/Switch.d.ts +4 -0
- package/components/switch/Switch.js +5 -6
- package/components/table/TableCardsSorting.d.ts +0 -1
- package/components/table/TableCol.d.ts +18 -0
- package/components/table/TableCol.js +11 -0
- package/components/table/TableHead.d.ts +33 -0
- package/components/table/TableHead.js +11 -0
- package/components/table/TableSettingsDialog.js +1 -1
- package/components/tag/Tag.js +1 -1
- package/components/timepicker/TimePicker.d.ts +1 -2
- package/components/timepicker/TimePicker.js +35 -8
- package/components/virtualList/VirtualList.js +1 -1
- package/hooks/useLocationSuggestions.d.ts +27 -0
- package/hooks/useLocationSuggestions.js +94 -0
- package/hooks/useOnboarding.d.ts +17 -5
- package/hooks/useOnboarding.js +7 -1
- package/hooks/usePostMessage.js +0 -1
- package/hooks/useSearch.d.ts +63 -0
- package/hooks/useSearch.js +73 -0
- package/hooks/useSorting.d.ts +6 -0
- package/hooks/useSorting.js +7 -4
- package/hooks/useTableSelection.d.ts +151 -0
- package/hooks/useTableSelection.js +196 -0
- package/lib/es/SvgImage.d.ts +2 -0
- package/lib/es/SvgImage.js +7 -0
- package/lib/es/TableCol.d.ts +2 -0
- package/lib/es/TableCol.js +7 -0
- package/lib/es/TableHead.d.ts +2 -0
- package/lib/es/TableHead.js +7 -0
- package/lib/es/components/actionBarItem/ActionBarItemIcon.js +1 -1
- package/lib/es/components/actionBarItem/ActionBarOverlay.js +1 -1
- package/lib/es/components/applicationHeader/CollapsedNavItem.js +1 -0
- package/lib/es/components/assetTree/Tree.d.ts +8 -0
- package/lib/es/components/assetTree/Tree.js +4 -2
- package/lib/es/components/assetTree/TreeLeaf.js +1 -1
- package/lib/es/components/assetTree/TreeSearch.js +1 -1
- package/lib/es/components/assetTree/TreeSummary.js +1 -1
- package/lib/es/components/assetTree/TypeCounter.d.ts +2 -0
- package/lib/es/components/assetTree/TypeCounter.js +1 -1
- package/lib/es/components/autosuggest/AutoSuggest.js +2 -1
- package/lib/es/components/banner/Banner.d.ts +6 -0
- package/lib/es/components/banner/Banner.js +31 -6
- package/lib/es/components/button/ButtonToolbar.d.ts +1 -1
- package/lib/es/components/button/ButtonToolbar.js +1 -1
- package/lib/es/components/button/ToggleButton.js +0 -1
- package/lib/es/components/clearableInput/ClearableInput.d.ts +20 -7
- package/lib/es/components/clearableInput/ClearableInput.js +67 -7
- package/lib/es/components/dialog/Dialog.js +1 -1
- package/lib/es/components/dialog/FrameDialog.js +1 -1
- package/lib/es/components/dropdown/ButtonDropdown.d.ts +11 -3
- package/lib/es/components/dropdown/ButtonDropdown.js +79 -64
- package/lib/es/components/dropdown/DropdownToggleButton.d.ts +7 -4
- package/lib/es/components/dropdown/DropdownToggleButton.js +11 -3
- package/lib/es/components/formLabel/FormLabel.js +24 -4
- package/lib/es/components/listMenu/ListMenu.js +7 -3
- package/lib/es/components/map/components/Map.js +1 -1
- package/lib/es/components/map/components/features/basics/InfoBubble.js +1 -1
- package/lib/es/components/map/components/features/layers/overlayLayers/IncidentsLayer.js +1 -1
- package/lib/es/components/mapMarker/SingleMapMarker.js +1 -1
- package/lib/es/components/menuItems/MenuItem.js +1 -1
- package/lib/es/components/notification/Notification.js +1 -1
- package/lib/es/components/overlay/OverlayTrigger.js +1 -1
- package/lib/es/components/selects/BaseSelectDropdown.js +1 -1
- package/lib/es/components/selects/Multiselect.d.ts +8 -0
- package/lib/es/components/selects/Multiselect.js +4 -4
- package/lib/es/components/smoothScrollbars/SmoothScrollbars.js +1 -1
- package/lib/es/components/svgImage/SvgElement.d.ts +8 -0
- package/lib/es/components/svgImage/SvgElement.js +14 -0
- package/lib/es/components/svgImage/SvgImage.d.ts +30 -0
- package/lib/es/components/svgImage/SvgImage.js +25 -0
- package/lib/es/components/svgImage/svgConverter.d.ts +17 -0
- package/lib/es/components/svgImage/svgConverter.js +84 -0
- package/lib/es/components/svgImage/useSvgLoader.d.ts +9 -0
- package/lib/es/components/svgImage/useSvgLoader.js +48 -0
- package/lib/es/components/switch/Switch.d.ts +4 -0
- package/lib/es/components/switch/Switch.js +5 -6
- package/lib/es/components/table/TableCardsSorting.d.ts +0 -1
- package/lib/es/components/table/TableCol.d.ts +18 -0
- package/lib/es/components/table/TableCol.js +13 -0
- package/lib/es/components/table/TableHead.d.ts +33 -0
- package/lib/es/components/table/TableHead.js +14 -0
- package/lib/es/components/table/TableSettingsDialog.js +1 -1
- package/lib/es/components/tag/Tag.js +1 -1
- package/lib/es/components/timepicker/TimePicker.d.ts +1 -2
- package/lib/es/components/timepicker/TimePicker.js +35 -8
- package/lib/es/components/virtualList/VirtualList.js +1 -1
- package/lib/es/hooks/useLocationSuggestions.d.ts +27 -0
- package/lib/es/hooks/useLocationSuggestions.js +97 -0
- package/lib/es/hooks/useOnboarding.d.ts +17 -5
- package/lib/es/hooks/useOnboarding.js +7 -1
- package/lib/es/hooks/usePostMessage.js +0 -1
- package/lib/es/hooks/useSearch.d.ts +63 -0
- package/lib/es/hooks/useSearch.js +75 -0
- package/lib/es/hooks/useSorting.d.ts +6 -0
- package/lib/es/hooks/useSorting.js +7 -4
- package/lib/es/hooks/useTableSelection.d.ts +151 -0
- package/lib/es/hooks/useTableSelection.js +205 -0
- package/lib/es/themes/Volkswagen/components/applicationHeader/VolkswagenApplicationHeader.js +1 -1
- package/lib/es/useLocationSuggestions.d.ts +2 -0
- package/lib/es/useLocationSuggestions.js +7 -0
- package/lib/es/useSearch.d.ts +2 -0
- package/lib/es/useSearch.js +7 -0
- package/lib/es/useTableSelection.d.ts +2 -0
- package/lib/es/useTableSelection.js +7 -0
- package/lib/es/utils/storageUtils.d.ts +2 -2
- package/lib/es/utils/storageUtils.js +2 -0
- package/lib/es/utils/urlFeatureToggles.d.ts +12 -6
- package/lib/es/utils/urlFeatureToggles.js +14 -8
- package/lib/es/utils/useDropDirection.js +1 -0
- package/lib/es/version.json +1 -1
- package/package.json +36 -39
- package/themes/Volkswagen/components/applicationHeader/VolkswagenApplicationHeader.js +1 -1
- package/useLocationSuggestions.d.ts +2 -0
- package/useLocationSuggestions.js +2 -0
- package/useSearch.d.ts +2 -0
- package/useSearch.js +2 -0
- package/useTableSelection.d.ts +2 -0
- package/useTableSelection.js +2 -0
- package/utils/storageUtils.d.ts +2 -2
- package/utils/storageUtils.js +2 -0
- package/utils/urlFeatureToggles.d.ts +12 -6
- package/utils/urlFeatureToggles.js +10 -7
- package/utils/useDropDirection.js +1 -0
- package/version.json +1 -1
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NOTIFICATION_TIMEOUT_INFINITE = exports.DEFAULT_NOTIFICATION_TIMEOUT_IN_MS = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
//
|
|
6
|
+
// biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
|
|
7
7
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
8
8
|
const react_toastify_1 = require("react-toastify");
|
|
9
9
|
exports.DEFAULT_NOTIFICATION_TIMEOUT_IN_MS = 5_000;
|
|
@@ -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
|
-
//
|
|
5
|
+
// biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
|
|
6
6
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
7
7
|
const react_dom_1 = tslib_1.__importDefault(require("react-dom"));
|
|
8
8
|
const react_popper_1 = require("react-popper");
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.filterOptions = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
//
|
|
6
|
+
// biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
9
9
|
const isEmpty_1 = tslib_1.__importDefault(require("lodash/fp/isEmpty"));
|
|
@@ -146,6 +146,14 @@ export type MultiselectProps<T extends MultiselectOption> = Omit<WithFeedbackAnd
|
|
|
146
146
|
* @default false
|
|
147
147
|
*/
|
|
148
148
|
showUnselectedItemIcons?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Additional classes to be set to the dropdown.
|
|
151
|
+
*/
|
|
152
|
+
dropdownClassName?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Additional classes to be set to the select/input.
|
|
155
|
+
*/
|
|
156
|
+
btnClassName?: string;
|
|
149
157
|
/**
|
|
150
158
|
* Additional classes to be set to the select wrapper
|
|
151
159
|
*/
|
|
@@ -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
|
-
//
|
|
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 isEqual_1 = tslib_1.__importDefault(require("lodash/fp/isEqual"));
|
|
@@ -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, 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', ...remainingProps } = props;
|
|
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', btnClassName, dropdownClassName, ...remainingProps } = props;
|
|
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);
|
|
@@ -76,7 +76,7 @@ const Multiselect = (props) => {
|
|
|
76
76
|
return ((0, jsx_runtime_1.jsx)(MultiselectToggleSelection_1.default, { options: options, selectedItemIds: selectedItemIds, showSelectedItemIcon: showSelectedItemIcon, showUnselectedItemIcons: showUnselectedItemIcons, onRemoveItem: handleRemoveSelectedItem, multiline: multiline, hasInputAddon: !!inputAddon, hasFilter: useFilter, children: multiline && renderFilter() }));
|
|
77
77
|
};
|
|
78
78
|
const renderToggle = () => {
|
|
79
|
-
const wrapperClassNames = (0, classnames_1.default)('dropdown-toggle', 'form-control', 'text-left', bsSize === 'sm' && 'input-sm', bsSize === 'lg' && 'input-lg', multiline && 'height-auto', disabled && 'disabled');
|
|
79
|
+
const wrapperClassNames = (0, classnames_1.default)('dropdown-toggle', 'form-control', 'text-left', btnClassName && btnClassName, bsSize === 'sm' && 'input-sm', bsSize === 'lg' && 'input-lg', multiline && 'height-auto', disabled && 'disabled');
|
|
80
80
|
const showPlaceholder = (0, isEmpty_1.default)(selectedItemIds) && !showUnselectedItemIcons;
|
|
81
81
|
const showFilter = useFilter && isOpen && !counterMessage && !renderCounterMessage;
|
|
82
82
|
const toggleButton = ((0, jsx_runtime_1.jsxs)("button", { type: 'button', id: id, name: name, className: wrapperClassNames, "data-toggle": 'dropdown', tabIndex: tabIndex, "aria-haspopup": 'true', "aria-expanded": isOpen, onClick: onToggle, onKeyDown: handleToggleKeyDown, ref: refToggle, children: [showPlaceholder ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(MultiselectTogglePlaceholder_1.default, { placeholder: placeholder }), showFilter && renderFilter()] })) : (renderSelection()), showFilter && !multiline && renderFilter(), (0, jsx_runtime_1.jsx)("span", { className: 'caret' })] }));
|
|
@@ -90,7 +90,7 @@ const Multiselect = (props) => {
|
|
|
90
90
|
option.selected = selectedItemIds.indexOf(option.id) !== -1;
|
|
91
91
|
return option;
|
|
92
92
|
});
|
|
93
|
-
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 }));
|
|
93
|
+
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, dropdownClassName: dropdownClassName }));
|
|
94
94
|
};
|
|
95
95
|
const handleFilterChange = (event) => {
|
|
96
96
|
event.preventDefault();
|
|
@@ -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
|
-
//
|
|
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_custom_scrollbars_2_1 = require("react-custom-scrollbars-2");
|
|
8
8
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ColorOverridesMap } from './svgConverter';
|
|
3
|
+
type SvgElementProps = {
|
|
4
|
+
node: Element;
|
|
5
|
+
colorMap: ColorOverridesMap;
|
|
6
|
+
};
|
|
7
|
+
declare const SvgElement: ({ node, colorMap }: SvgElementProps) => React.DOMElement<React.DOMAttributes<Element>, Element>;
|
|
8
|
+
export default SvgElement;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const svgConverter_1 = require("./svgConverter");
|
|
7
|
+
const SvgElement = ({ node, colorMap }) => {
|
|
8
|
+
const attributes = (0, svgConverter_1.convertAttributes)(node, colorMap);
|
|
9
|
+
return react_1.default.createElement(node.tagName.toLowerCase(), {
|
|
10
|
+
...attributes,
|
|
11
|
+
key: attributes.id || Math.random(),
|
|
12
|
+
}, Array.from(node.childNodes).map((child, idx) => child.nodeType === 1 ? (0, jsx_runtime_1.jsx)(SvgElement, { node: child, colorMap: colorMap }, idx) : null));
|
|
13
|
+
};
|
|
14
|
+
exports.default = SvgElement;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ColorOverridesMap } from './svgConverter';
|
|
3
|
+
type SvgImageProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The name of the image file without extension.
|
|
6
|
+
*/
|
|
7
|
+
name: string;
|
|
8
|
+
/**
|
|
9
|
+
* The height and width of the SVG image in pixels.
|
|
10
|
+
*
|
|
11
|
+
* @default 150
|
|
12
|
+
*/
|
|
13
|
+
size?: number;
|
|
14
|
+
/**
|
|
15
|
+
* The CDN base URL where the images are located.
|
|
16
|
+
*
|
|
17
|
+
* @default 'https://cdn.rio.cloud/riosvg'
|
|
18
|
+
*/
|
|
19
|
+
baseUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Customize color using the color map and define the CSS variable name that shall be used.
|
|
22
|
+
*/
|
|
23
|
+
colorMap?: ColorOverridesMap;
|
|
24
|
+
/**
|
|
25
|
+
* Additional class names added to the SVG element.
|
|
26
|
+
*/
|
|
27
|
+
className?: string;
|
|
28
|
+
};
|
|
29
|
+
export declare const SvgImage: (props: SvgImageProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
30
|
+
export default SvgImage;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SvgImage = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const useSvgLoader_1 = require("./useSvgLoader");
|
|
7
|
+
const BASE_CDN_URL = 'https://cdn.rio.cloud/riosvg';
|
|
8
|
+
const SvgImage = (props) => {
|
|
9
|
+
const { name, className = '', size = 150, baseUrl = BASE_CDN_URL, colorMap } = props;
|
|
10
|
+
const { svgElement, error } = (0, useSvgLoader_1.useSvgLoader)(name, baseUrl, colorMap);
|
|
11
|
+
if (error) {
|
|
12
|
+
console.error(`Icon "${name}" not found`);
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
if (!svgElement) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return react_1.default.cloneElement(svgElement, {
|
|
19
|
+
width: size,
|
|
20
|
+
height: size,
|
|
21
|
+
className,
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
exports.SvgImage = SvgImage;
|
|
25
|
+
exports.default = exports.SvgImage;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type CSSColorVar = 'color-white' | 'color-black' | 'always-color-white' | 'always-color-black' | 'gray-darkest' | 'gray-darker' | 'gray-dark' | 'gray' | 'gray-light' | 'gray-lighter' | 'gray-lightest' | 'gray-decent' | 'brand-primary' | 'brand-secondary' | 'brand-primary-decent' | 'brand-secondary-decent' | 'brand-info' | 'brand-success' | 'brand-warning' | 'brand-danger' | 'brand-info-decent' | 'brand-success-decent' | 'brand-warning-decent' | 'brand-danger-decent' | 'color-code' | 'color-status-available' | 'color-status-driving' | 'color-status-resting' | 'color-status-working' | 'color-map-marker-asset' | 'color-map-marker-poi' | 'color-map-marker-geofence' | 'color-map-marker-route' | 'color-map-marker-info' | 'color-map-marker-success' | 'color-map-marker-warning' | 'color-map-marker-danger' | 'color-map-marker-restrictions' | 'color-map-marker-text' | 'color-map-marker-active' | 'color-highlight-darkest' | 'color-highlight-darker' | 'color-highlight-dark' | 'color-highlight' | 'color-highlight-light' | 'color-highlight-lighter' | 'color-highlight-lightest' | 'color-highlight-decent' | 'color-rating-1' | 'color-rating-2' | 'color-rating-3' | 'color-rating-4' | 'color-rating-5' | 'color-coldplay-wine' | 'color-coldplay-aubergine' | 'color-coldplay-kashmir' | 'color-coldplay-fountain' | 'color-coldplay-turquoise' | 'color-coldplay-bermuda' | 'color-coldplay-moos' | 'color-coldplay-primrose' | 'color-coldplay-khaki' | 'color-warmup-crimson' | 'color-warmup-victoria' | 'color-warmup-cadillac' | 'color-warmup-raspberry' | 'color-warmup-cerise' | 'color-warmup-charm' | 'color-warmup-salmon' | 'color-warmup-cherokee' | 'color-warmup-corn' | 'color-spectrum-indigo' | 'color-spectrum-violet' | 'color-spectrum-purple' | 'color-spectrum-fuchsia' | 'color-spectrum-pink' | 'color-spectrum-rose';
|
|
2
|
+
export type ColorOverridesMap = {
|
|
3
|
+
mainStrokeColor?: CSSColorVar;
|
|
4
|
+
mainFillColor?: CSSColorVar;
|
|
5
|
+
secondaryStrokeColor?: CSSColorVar;
|
|
6
|
+
backgroundFillColor?: CSSColorVar;
|
|
7
|
+
};
|
|
8
|
+
export declare const defaultColorMap: ColorOverridesMap;
|
|
9
|
+
type StyleObject = Record<string, string>;
|
|
10
|
+
export declare const parseStyleString: (style: string) => StyleObject;
|
|
11
|
+
export declare const camelCase: (str: string) => string;
|
|
12
|
+
type ConvertedAttributes = {
|
|
13
|
+
style?: React.CSSProperties;
|
|
14
|
+
[key: string]: string | React.CSSProperties | undefined;
|
|
15
|
+
};
|
|
16
|
+
export declare const convertAttributes: (node: Element, colorOverrides: ColorOverridesMap) => ConvertedAttributes;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Define the color replacements - handle hex colors and fallbacks
|
|
3
|
+
// const svgColorReplacement: Record<string, string> = {
|
|
4
|
+
// 'rgb(255, 255, 255)': 'var(--color-white)',
|
|
5
|
+
// '#fff': 'var(--color-white)',
|
|
6
|
+
// '#ffffff': 'var(--color-white)',
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.convertAttributes = exports.camelCase = exports.parseStyleString = exports.defaultColorMap = void 0;
|
|
9
|
+
exports.defaultColorMap = {
|
|
10
|
+
mainStrokeColor: 'brand-info',
|
|
11
|
+
mainFillColor: 'color-highlight-lighter',
|
|
12
|
+
secondaryStrokeColor: 'gray',
|
|
13
|
+
backgroundFillColor: 'gray-lighter',
|
|
14
|
+
};
|
|
15
|
+
// Utility function to normalize RGB values (removes spaces, converts case)
|
|
16
|
+
const normalizeColor = (color) => color.replace(/\s+/g, '').toLowerCase();
|
|
17
|
+
const parseStyleString = (style) => {
|
|
18
|
+
return style.split(';').reduce((acc, rule) => {
|
|
19
|
+
const [key, value] = rule.split(':').map(s => s.trim());
|
|
20
|
+
if (key && value) {
|
|
21
|
+
acc[(0, exports.camelCase)(key)] = value;
|
|
22
|
+
}
|
|
23
|
+
return acc;
|
|
24
|
+
}, {});
|
|
25
|
+
};
|
|
26
|
+
exports.parseStyleString = parseStyleString;
|
|
27
|
+
const camelCase = (str) => str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
28
|
+
exports.camelCase = camelCase;
|
|
29
|
+
const REACT_ATTRIBUTE_MAP = {
|
|
30
|
+
'xml:space': 'xmlSpace',
|
|
31
|
+
'xmlns:xlink': 'xmlnsXlink',
|
|
32
|
+
'stroke-width': 'strokeWidth',
|
|
33
|
+
'fill-opacity': 'fillOpacity',
|
|
34
|
+
'stroke-opacity': 'strokeOpacity',
|
|
35
|
+
'clip-path': 'clipPath',
|
|
36
|
+
};
|
|
37
|
+
const convertAttributes = (node, colorOverrides) => {
|
|
38
|
+
const attributes = {};
|
|
39
|
+
const attrs = node.attributes;
|
|
40
|
+
// Create a dynamic color map based on the overrides
|
|
41
|
+
const colorMap = {
|
|
42
|
+
// Main fill color
|
|
43
|
+
'rgb(207, 240, 243)': `var(--${colorOverrides.mainFillColor || exports.defaultColorMap.mainFillColor})`,
|
|
44
|
+
'#cff0f3': `var(--${colorOverrides.mainFillColor || exports.defaultColorMap.mainFillColor})`,
|
|
45
|
+
// Main stroke color
|
|
46
|
+
'rgb(75, 128, 166)': `var(--${colorOverrides.mainStrokeColor || exports.defaultColorMap.mainStrokeColor})`,
|
|
47
|
+
'#4b80a6': `var(--${colorOverrides.mainStrokeColor || exports.defaultColorMap.mainStrokeColor})`,
|
|
48
|
+
// Secondary stroke color (gray elements)
|
|
49
|
+
'rgb(188, 192, 196)': `var(--${colorOverrides.secondaryStrokeColor || exports.defaultColorMap.secondaryStrokeColor})`,
|
|
50
|
+
'#bcc0c4': `var(--${colorOverrides.secondaryStrokeColor || exports.defaultColorMap.secondaryStrokeColor})`,
|
|
51
|
+
// Background fill color
|
|
52
|
+
'rgb(233, 235, 236)': `var(--${colorOverrides.backgroundFillColor || exports.defaultColorMap.backgroundFillColor})`,
|
|
53
|
+
'#e9ebec': `var(--${colorOverrides.backgroundFillColor || exports.defaultColorMap.backgroundFillColor})`,
|
|
54
|
+
// Static colors that don't change
|
|
55
|
+
'rgb(255, 255, 255)': 'var(--color-white)',
|
|
56
|
+
'#fff': 'var(--color-white)',
|
|
57
|
+
'#ffffff': 'var(--color-white)',
|
|
58
|
+
};
|
|
59
|
+
for (const attr of attrs) {
|
|
60
|
+
const attrName = REACT_ATTRIBUTE_MAP[attr.name] || attr.name;
|
|
61
|
+
let value = attr.value;
|
|
62
|
+
if (attrName === 'style') {
|
|
63
|
+
const parsedStyle = (0, exports.parseStyleString)(value);
|
|
64
|
+
if (parsedStyle.fill) {
|
|
65
|
+
const normalizedFill = normalizeColor(parsedStyle.fill);
|
|
66
|
+
parsedStyle.fill = colorMap[normalizedFill] || parsedStyle.fill;
|
|
67
|
+
}
|
|
68
|
+
if (parsedStyle.stroke) {
|
|
69
|
+
const normalizedStroke = normalizeColor(parsedStyle.stroke);
|
|
70
|
+
parsedStyle.stroke = colorMap[normalizedStroke] || parsedStyle.stroke;
|
|
71
|
+
}
|
|
72
|
+
attributes.style = parsedStyle;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
if (attrName === 'fill' || attrName === 'stroke') {
|
|
76
|
+
const normalizedColor = normalizeColor(value);
|
|
77
|
+
value = colorMap[normalizedColor] || value;
|
|
78
|
+
}
|
|
79
|
+
attributes[attrName] = value;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return attributes;
|
|
83
|
+
};
|
|
84
|
+
exports.convertAttributes = convertAttributes;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type ColorOverridesMap } from './svgConverter';
|
|
3
|
+
type UseSvgLoaderResult = {
|
|
4
|
+
svgElement: ReactNode | null;
|
|
5
|
+
error: boolean;
|
|
6
|
+
colorMap?: ColorOverridesMap;
|
|
7
|
+
};
|
|
8
|
+
export declare const useSvgLoader: (name: string, baseUrl: string, colorMap?: ColorOverridesMap) => UseSvgLoaderResult;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSvgLoader = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const svgConverter_1 = require("./svgConverter");
|
|
8
|
+
const SvgElement_1 = tslib_1.__importDefault(require("./SvgElement"));
|
|
9
|
+
const useSvgLoader = (name, baseUrl, colorMap = svgConverter_1.defaultColorMap) => {
|
|
10
|
+
const [svgElement, setSvgElement] = (0, react_1.useState)(null);
|
|
11
|
+
const [error, setError] = (0, react_1.useState)(false);
|
|
12
|
+
(0, react_1.useEffect)(() => {
|
|
13
|
+
const fetchSvg = async () => {
|
|
14
|
+
try {
|
|
15
|
+
const url = `${baseUrl}/${name}.svg`;
|
|
16
|
+
const response = await fetch(url);
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
throw new Error('Failed to load SVG');
|
|
19
|
+
}
|
|
20
|
+
const svgText = await response.text();
|
|
21
|
+
if (svgText.startsWith('<html>')) {
|
|
22
|
+
// When fetching from RIO CDN, a default index page is returned when something cannot be found.
|
|
23
|
+
// Hence, we need to check for this to throw a proper error message.
|
|
24
|
+
throw new Error(`Could not load SVG with URL: ${url}`);
|
|
25
|
+
}
|
|
26
|
+
const parser = new DOMParser();
|
|
27
|
+
const doc = parser.parseFromString(svgText, 'image/svg+xml');
|
|
28
|
+
const svgNode = doc.querySelector('svg');
|
|
29
|
+
if (!svgNode) {
|
|
30
|
+
throw new Error('Invalid SVG format');
|
|
31
|
+
}
|
|
32
|
+
const attributes = (0, svgConverter_1.convertAttributes)(svgNode, colorMap);
|
|
33
|
+
const svgJsx = ((0, jsx_runtime_1.jsx)("svg", { ...attributes, children: Array.from(svgNode.childNodes).map((node, idx) => node.nodeType === 1 ? (
|
|
34
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
|
|
35
|
+
(0, jsx_runtime_1.jsx)(SvgElement_1.default, { node: node, colorMap: colorMap }, idx)) : null) }));
|
|
36
|
+
setSvgElement(svgJsx);
|
|
37
|
+
setError(false);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
console.error(`Error loading SVG "${name}":`, err);
|
|
41
|
+
setError(true);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
fetchSvg();
|
|
45
|
+
}, [name, baseUrl, colorMap]);
|
|
46
|
+
return { svgElement, error };
|
|
47
|
+
};
|
|
48
|
+
exports.useSvgLoader = useSvgLoader;
|
|
@@ -45,6 +45,10 @@ export type SwitchProps = {
|
|
|
45
45
|
* Possible values are `left` and `right`.
|
|
46
46
|
*/
|
|
47
47
|
labelPosition?: 'left' | 'right';
|
|
48
|
+
/**
|
|
49
|
+
* Additional class names added to the SVG element.
|
|
50
|
+
*/
|
|
51
|
+
className?: string;
|
|
48
52
|
};
|
|
49
53
|
declare const Switch: React.ForwardRefExoticComponent<PropsWithChildren<SwitchProps> & React.RefAttributes<HTMLDivElement>> & {
|
|
50
54
|
LABEL_POSITION_LEFT: "left";
|
|
@@ -2,24 +2,23 @@
|
|
|
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
|
-
//
|
|
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"));
|
|
9
9
|
const currentColors_1 = require("../../utils/currentColors");
|
|
10
10
|
const Switch = (0, react_1.forwardRef)((props, ref) => {
|
|
11
|
-
const { keyName, checked = false, enabledText, minWidth = 40, disabled = false, color = 'primary', disabledText, children, labelPosition = children ? 'right' : undefined, onChange = noop_1.default, ...remainingProps } = props;
|
|
11
|
+
const { keyName, checked = false, enabledText, minWidth = 40, disabled = false, color = 'primary', disabledText, children, className = '', labelPosition = children ? 'right' : undefined, onChange = noop_1.default, ...remainingProps } = props;
|
|
12
12
|
const handleChange = (event) => {
|
|
13
13
|
onChange(event.target.checked);
|
|
14
14
|
};
|
|
15
15
|
const hasMultipleText = enabledText && disabledText;
|
|
16
16
|
const hasSingleText = enabledText && !disabledText;
|
|
17
|
+
const switchClasses = (0, classnames_1.default)('uikit-switch', className);
|
|
17
18
|
const switchLabelClasses = (0, classnames_1.default)('switch-label', disabled && 'cursor-not-allowed', labelPosition && `label-position-${labelPosition}`);
|
|
18
|
-
const switchContentClasses = (0, classnames_1.default)('switch-content'
|
|
19
|
-
// !hasMultipleText && !hasSingleText && 'width-40'
|
|
20
|
-
);
|
|
19
|
+
const switchContentClasses = (0, classnames_1.default)('switch-content');
|
|
21
20
|
const switchBackgroundColor = (0, currentColors_1.getCurrentBackgroundColor)(color);
|
|
22
|
-
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, ...remainingProps, className:
|
|
21
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, ...remainingProps, className: switchClasses, children: (0, jsx_runtime_1.jsxs)("label", { className: switchLabelClasses, children: [(0, jsx_runtime_1.jsx)("input", { onChange: handleChange, checked: checked, type: 'checkbox', id: keyName, className: 'switch-input', disabled: disabled }, keyName), (0, jsx_runtime_1.jsxs)("div", { className: switchContentClasses, style: { color: switchBackgroundColor, minWidth }, children: [hasMultipleText ? ((0, jsx_runtime_1.jsx)("div", { className: 'switch-text', "data-on": enabledText, "data-off": disabledText })) : (hasSingleText && (0, jsx_runtime_1.jsx)("div", { className: 'switch-text', "data-on": enabledText, "data-off": enabledText })), (0, jsx_runtime_1.jsx)("div", { className: 'switch-handle' })] }), children && children] }) }));
|
|
23
22
|
});
|
|
24
23
|
Switch.LABEL_POSITION_LEFT = 'left';
|
|
25
24
|
Switch.LABEL_POSITION_RIGHT = 'right';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ColumnDetails = {
|
|
2
|
+
[key: string]: number;
|
|
3
|
+
};
|
|
4
|
+
export type ColumnDetailsMap = {
|
|
5
|
+
[key: string]: ColumnDetails;
|
|
6
|
+
};
|
|
7
|
+
type TableColProps = {
|
|
8
|
+
/**
|
|
9
|
+
* The width of the column as part of the column details object used for the TableSettingsDialog.
|
|
10
|
+
*/
|
|
11
|
+
columnDetails?: ColumnDetails;
|
|
12
|
+
/**
|
|
13
|
+
* Additional classes added to the col tag element.
|
|
14
|
+
*/
|
|
15
|
+
className?: string;
|
|
16
|
+
};
|
|
17
|
+
declare const TableCol: ({ columnDetails }: TableColProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export default TableCol;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const TableCol = ({ columnDetails }) => {
|
|
5
|
+
const style = columnDetails?.width
|
|
6
|
+
? {
|
|
7
|
+
minWidth: columnDetails.width,
|
|
8
|
+
width: columnDetails.width,
|
|
9
|
+
}
|
|
10
|
+
: {};
|
|
11
|
+
return (0, jsx_runtime_1.jsx)("col", { style: style });
|
|
12
|
+
};
|
|
13
|
+
exports.default = TableCol;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
|
+
type TableHeadProps = {
|
|
3
|
+
/**
|
|
4
|
+
* The unique name of the column used as identifier
|
|
5
|
+
*/
|
|
6
|
+
column?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The label that shall be rendered in the table head next to the sorting icons.
|
|
9
|
+
*/
|
|
10
|
+
label?: string | React.ReactElement;
|
|
11
|
+
/**
|
|
12
|
+
* The string title of a column used as native title attribute on the th tag.
|
|
13
|
+
*/
|
|
14
|
+
title?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The sorting key stored as data attribute for later usage for click events.
|
|
17
|
+
*/
|
|
18
|
+
sortBy?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The column sorting direction.
|
|
21
|
+
*/
|
|
22
|
+
sortDir?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The click handler for the th tag.
|
|
25
|
+
*/
|
|
26
|
+
onClick?: (event: React.MouseEvent<HTMLTableCellElement>) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Additional class names assigned to the wrapper element.
|
|
29
|
+
*/
|
|
30
|
+
className?: string;
|
|
31
|
+
};
|
|
32
|
+
declare const TableHead: (props: PropsWithChildren<TableHeadProps>) => import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export default TableHead;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
6
|
+
const SortArrows_1 = tslib_1.__importDefault(require("./SortArrows"));
|
|
7
|
+
const TableHead = (props) => {
|
|
8
|
+
const { column, title, label, sortBy, sortDir, onClick = () => { }, className = '', children } = props;
|
|
9
|
+
const tableHeadClassNames = (0, classnames_1.default)('user-select-none', 'sort-column', className);
|
|
10
|
+
const labelString = typeof label === 'string' ? label : '';
|
|
11
|
+
const thTitle = title ?? labelString;
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)("th", { className: tableHeadClassNames, onClick: onClick, "data-field": column, "data-sortby": column, title: thTitle, children: [label && ((0, jsx_runtime_1.jsxs)("span", { children: [column !== undefined && sortBy === column ? (0, jsx_runtime_1.jsx)(SortArrows_1.default, { direction: sortDir }) : (0, jsx_runtime_1.jsx)(SortArrows_1.default, {}), (0, jsx_runtime_1.jsx)("span", { children: label })] })), children] }));
|
|
13
|
+
};
|
|
14
|
+
exports.default = TableHead;
|
|
@@ -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
|
-
//
|
|
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 isEqual_1 = tslib_1.__importDefault(require("lodash/fp/isEqual"));
|
|
@@ -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
|
-
//
|
|
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 Tag = (0, react_1.forwardRef)((props, ref) => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type Props as InputMaskProps } from 'react-input-mask';
|
|
3
2
|
export type TimePickerProps = {
|
|
4
3
|
/**
|
|
5
4
|
* Value of the time as string. Note, when value is given the component is treated as controlled.
|
|
@@ -40,7 +39,7 @@ export type TimePickerProps = {
|
|
|
40
39
|
/**
|
|
41
40
|
* Additional properties to be set on the input element.
|
|
42
41
|
*/
|
|
43
|
-
inputProps?: Omit<
|
|
42
|
+
inputProps?: Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange'>;
|
|
44
43
|
/**
|
|
45
44
|
* Additional classes to be set on the wrapper element.
|
|
46
45
|
*/
|
|
@@ -3,7 +3,7 @@ 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 react_1 = require("react");
|
|
6
|
-
const
|
|
6
|
+
const react_imask_1 = require("react-imask");
|
|
7
7
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
8
8
|
const isNil_1 = tslib_1.__importDefault(require("lodash/fp/isNil"));
|
|
9
9
|
const isEmpty_1 = tslib_1.__importDefault(require("lodash/fp/isEmpty"));
|
|
@@ -11,7 +11,7 @@ const moment_1 = tslib_1.__importDefault(require("moment"));
|
|
|
11
11
|
const noop_1 = tslib_1.__importDefault(require("lodash/fp/noop"));
|
|
12
12
|
const tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
|
|
13
13
|
const MINUTES_OFFSET = 15;
|
|
14
|
-
const mask =
|
|
14
|
+
const mask = '00:00';
|
|
15
15
|
const fullRegexp = /^(?:\d|[01]\d|2[0-3]):[0-5]\d$/;
|
|
16
16
|
const getPadded = (value) => (value >= 10 ? `${value}` : `0${value}`);
|
|
17
17
|
const formatTimeString = (hours, minutes) => `${getPadded(hours)}:${getPadded(minutes)}`;
|
|
@@ -42,11 +42,23 @@ const TimePicker = (props) => {
|
|
|
42
42
|
onChange(value);
|
|
43
43
|
}
|
|
44
44
|
}, [value]);
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
|
|
45
|
+
const handleFocus = (event) => {
|
|
46
|
+
const input = event.target;
|
|
47
|
+
// Check if value is empty or partially filled
|
|
48
|
+
if (!input.value || input.value.startsWith('-')) {
|
|
49
|
+
// Move cursor to the first empty position (usually 0)
|
|
50
|
+
// Timeout needed to wait for IMask internal focus handling
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
input.setSelectionRange(0, 0);
|
|
53
|
+
}, 0);
|
|
54
|
+
}
|
|
55
|
+
// If you want to preserve custom onFocus from props
|
|
56
|
+
inputProps.onFocus?.(event);
|
|
57
|
+
};
|
|
58
|
+
const handleAcceptTime = (val, maskRef) => {
|
|
59
|
+
setTimeValue(val);
|
|
60
|
+
if (maskRef.masked.isComplete) {
|
|
61
|
+
onChange(val);
|
|
50
62
|
}
|
|
51
63
|
};
|
|
52
64
|
const isValid = isTimeValid(timeValue);
|
|
@@ -70,6 +82,21 @@ const TimePicker = (props) => {
|
|
|
70
82
|
};
|
|
71
83
|
const { className: inputClassName, ...otherInputProps } = inputProps;
|
|
72
84
|
const hasFeedback = errorMessage || warningMessage;
|
|
73
|
-
return ((0, jsx_runtime_1.jsxs)("div", { ...remainingProps, className: (0, classnames_1.default)('TimePicker', 'input-group', className), children: [showIcon && ((0, jsx_runtime_1.jsx)("span", { className: 'input-group-addon', children: (0, jsx_runtime_1.jsx)("span", { className: 'rioglyph rioglyph-time-alt' }) })), (0, jsx_runtime_1.jsxs)("div", { className: 'form-control-feedback-wrapper', children: [(0, jsx_runtime_1.jsx)(
|
|
85
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ...remainingProps, className: (0, classnames_1.default)('TimePicker', 'input-group', className), children: [showIcon && ((0, jsx_runtime_1.jsx)("span", { className: 'input-group-addon', children: (0, jsx_runtime_1.jsx)("span", { className: 'rioglyph rioglyph-time-alt' }) })), (0, jsx_runtime_1.jsxs)("div", { className: 'form-control-feedback-wrapper', children: [(0, jsx_runtime_1.jsx)(react_imask_1.IMaskInput, { ...otherInputProps, className: (0, classnames_1.default)('TimePickerInput', 'form-control', inputClassName),
|
|
86
|
+
// mask={mask}
|
|
87
|
+
mask: 'HH:MM', blocks: {
|
|
88
|
+
HH: {
|
|
89
|
+
mask: react_imask_1.IMask.MaskedRange,
|
|
90
|
+
from: 0,
|
|
91
|
+
to: 23,
|
|
92
|
+
maxLength: 2,
|
|
93
|
+
},
|
|
94
|
+
MM: {
|
|
95
|
+
mask: react_imask_1.IMask.MaskedRange,
|
|
96
|
+
from: 0,
|
|
97
|
+
to: 59,
|
|
98
|
+
maxLength: 2,
|
|
99
|
+
},
|
|
100
|
+
}, value: timeValue, onAccept: handleAcceptTime, onFocus: handleFocus, lazy: !alwaysShowMask, placeholderChar: '-', overwrite: true }), hasFeedback && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [errorMessage && (0, jsx_runtime_1.jsx)("span", { className: 'form-control-feedback rioglyph rioglyph-error-sign' }), warningMessage && (0, jsx_runtime_1.jsx)("span", { className: 'form-control-feedback rioglyph rioglyph-warning-sign' }), (0, jsx_runtime_1.jsx)("span", { className: `help-block white-space-${messageWhiteSpace}`, children: (0, jsx_runtime_1.jsx)("span", { children: errorMessage || warningMessage }) })] }))] }), isValid && ((0, jsx_runtime_1.jsxs)("div", { className: 'TimePickerIncreaseButton input-group-addon', children: [(0, jsx_runtime_1.jsx)("div", { className: 'text-color-gray hover-text-color-dark display-grid place-items-center cursor-pointer', onClick: handleDecrease, children: (0, jsx_runtime_1.jsx)("div", { className: 'rioglyph rioglyph-chevron-left scale-90' }) }), (0, jsx_runtime_1.jsx)("div", { className: 'text-color-gray hover-text-color-dark margin-left-5 display-grid place-items-center cursor-pointer', onClick: handleIncrease, children: (0, jsx_runtime_1.jsx)("div", { className: 'rioglyph rioglyph-chevron-right scale-90' }) })] }))] }));
|
|
74
101
|
};
|
|
75
102
|
exports.default = TimePicker;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VirtualList = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
//
|
|
6
|
+
// biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const VirtualListItemWrapper_1 = tslib_1.__importDefault(require("./VirtualListItemWrapper"));
|
|
9
9
|
const useWindowResize_1 = tslib_1.__importDefault(require("../../hooks/useWindowResize"));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type LocationSuggestion = {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
};
|
|
5
|
+
export type LocationFetchOptions = Record<string, unknown> & {
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
fetchUrl?: string;
|
|
8
|
+
limit?: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Custom React hook for fetching location suggestions using HERE Maps Autocomplete API.
|
|
12
|
+
*
|
|
13
|
+
* @param query - The user input string to search for location suggestions.
|
|
14
|
+
* @param options - Optional configuration:
|
|
15
|
+
* - apiKey: Your HERE Maps API key (default is 'YOUR_API_KEY').
|
|
16
|
+
* - fetchUrl: Optional override for the autocomplete endpoint URL.
|
|
17
|
+
* @returns An object containing:
|
|
18
|
+
* - suggestions: Array of location suggestions with `id` and `label`.
|
|
19
|
+
* - loading: Boolean indicating whether the fetch is in progress.
|
|
20
|
+
* - error: Any error that occurred during fetching.
|
|
21
|
+
*/
|
|
22
|
+
declare const useLocationSuggestions: (query: string, options?: LocationFetchOptions) => {
|
|
23
|
+
suggestions: LocationSuggestion[];
|
|
24
|
+
loading: boolean;
|
|
25
|
+
error: Error | null;
|
|
26
|
+
};
|
|
27
|
+
export default useLocationSuggestions;
|