@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.
- 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/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 +1 -1
- package/components/listMenu/ListMenu.js +1 -0
- 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/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/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 +1 -1
- package/lib/es/components/listMenu/ListMenu.js +1 -0
- 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/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
package/README.md
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
The documentation and how to integrate the UIKIT in your project can be found here: https://uikit.developers.rio.cloud/
|
|
6
6
|
|
|
7
|
+
## Changelog
|
|
8
|
+
|
|
9
|
+
All changes, updates, and improvements for each version are documented in the changelog (https://uikit.developers.rio.cloud/#start/changelog). Refer to it for a detailed overview of new features, bug fixes, and other modifications.
|
|
10
|
+
|
|
7
11
|
## Release
|
|
8
12
|
|
|
9
13
|
Starting with version `0.12.8`, all versions of the uikit will be available under https://uikit.developers.rio.cloud/${VERSION}/.
|
package/SvgImage.d.ts
ADDED
package/SvgImage.js
ADDED
package/TableCol.d.ts
ADDED
package/TableCol.js
ADDED
package/TableHead.d.ts
ADDED
package/TableHead.js
ADDED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
//
|
|
2
|
+
// biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
const ActionBarItemIcon = forwardRef((props, ref) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
//
|
|
2
|
+
// biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import noop from 'lodash/fp/noop';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
|
|
2
3
|
import { forwardRef } from 'react';
|
|
3
4
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
4
5
|
const CollapsedNavItem = 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.
|
|
@@ -37,7 +37,7 @@ const filterProps = omit([
|
|
|
37
37
|
]);
|
|
38
38
|
const customCompare = (prevProps, nextProps) => isEqual(filterProps(prevProps), filterProps(nextProps));
|
|
39
39
|
const Tree = React.memo((props) => {
|
|
40
|
-
const { groups = [], items = [], selectedGroups = [], selectedItems = [], onSelectionChange = noop, hasMultiselect = true, showRadioButtons = false, hideSearch = false, hideTreeHead, treeHeaderContent, summary, hideSummary = false, search, searchPlaceholder = 'Type here to filter by name', onSearchChange = noop, className, scrollHeight, expandedGroups, onExpandGroupsChange = noop, showEmptyGroups = true, treeOptions = [], treeOptionsTooltip, disableAnimation = false, ...remainingProps } = props;
|
|
40
|
+
const { groups = [], items = [], selectedGroups = [], selectedItems = [], onSelectionChange = noop, hasMultiselect = true, showRadioButtons = false, hideSearch = false, hideTreeHead, treeHeaderContent, summary, hideSummary = false, search, searchPlaceholder = 'Type here to filter by name', onSearchChange = noop, className, scrollHeight, expandedGroups, onExpandGroupsChange = noop, showEmptyGroups = true, treeOptions = [], treeOptionsTooltip, disableAnimation = false, onTypeFilterChange = noop, ...remainingProps } = props;
|
|
41
41
|
const [state, dispatch] = useReducer(treeReducer, {
|
|
42
42
|
groupedItems: [],
|
|
43
43
|
flatItems: [],
|
|
@@ -261,7 +261,9 @@ const Tree = React.memo((props) => {
|
|
|
261
261
|
[otherwise, () => renderFlatList()],
|
|
262
262
|
])();
|
|
263
263
|
const handleFilterByType = (type) => {
|
|
264
|
-
|
|
264
|
+
const updatedTypeFilter = addOrRemoveFromList(state.typeFilter, type);
|
|
265
|
+
dispatch(typeFilterChanged(updatedTypeFilter));
|
|
266
|
+
onTypeFilterChange(updatedTypeFilter);
|
|
265
267
|
};
|
|
266
268
|
const enableActivity = size(state.visibleTypeCounters) !== 1;
|
|
267
269
|
const isFilterActive = notEmpty(state.typeFilter);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
//
|
|
2
|
+
// biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import isObject from 'lodash/fp/isObject';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
//
|
|
2
|
+
// biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import noop from 'lodash/fp/noop';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
//
|
|
2
|
+
// biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import TypeCounter from './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
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
//
|
|
2
|
+
// biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
|
|
3
3
|
import { forwardRef, useRef } from 'react';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import noop from 'lodash/fp/noop';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// biome-ignore lint/style/useImportType: <explanation>
|
|
2
3
|
import { useEffect, useRef, useState } from 'react';
|
|
3
4
|
import classNames from 'classnames';
|
|
4
5
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
@@ -21,7 +22,7 @@ export const AutoSuggest = (props) => {
|
|
|
21
22
|
onClear: noop,
|
|
22
23
|
onBlur: noop,
|
|
23
24
|
onFocus: noop,
|
|
24
|
-
placeholder: 'Start typing
|
|
25
|
+
placeholder: 'Start typing',
|
|
25
26
|
hasError: false,
|
|
26
27
|
tabIndex: 0,
|
|
27
28
|
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
|
*/
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
const ButtonToolbar = (props) => {
|
|
4
4
|
const { className = '', alignment, children, ...remainingProps } = props;
|
|
5
|
-
const classes = classNames(className, 'btn-toolbar', alignment === 'left' && 'justify-content-start', alignment === 'right' && 'justify-content-end', alignment === 'space-between' && 'justify-content-between');
|
|
5
|
+
const classes = classNames(className, 'btn-toolbar', alignment === 'left' && 'justify-content-start', alignment === 'right' && 'justify-content-end', alignment === 'center' && 'justify-content-center', alignment === 'space-between' && 'justify-content-between');
|
|
6
6
|
return (_jsx("div", { ...remainingProps, className: classes, children: children }));
|
|
7
7
|
};
|
|
8
8
|
export default ButtonToolbar;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import Button from './Button';
|
|
3
|
-
// @ts-ignore - the Button throws TS error due to refs that may be checked at a later point in time
|
|
4
3
|
const ToggleButton = (props) => _jsx(Button, { ...props, asToggle: true });
|
|
5
4
|
export 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.
|
|
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://
|
|
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: "
|
|
103
|
+
* Character: "0" = allowed input: "0-9" (digit)
|
|
103
104
|
*
|
|
104
|
-
* Character: "a"
|
|
105
|
+
* Character: "a" = allowed input: "a-z, A-Z" (letter)
|
|
105
106
|
*
|
|
106
|
-
* Character: "*"
|
|
107
|
+
* Character: "*" = allowed input: any character
|
|
107
108
|
*
|
|
108
|
-
*
|
|
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
|
-
* '--
|
|
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
|
/**
|
|
@@ -1,23 +1,45 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
|
|
2
|
+
// biome-ignore lint/style/useImportType: <explanation>
|
|
3
|
+
import { useState, forwardRef, useRef } from 'react';
|
|
3
4
|
import omit from 'lodash/fp/omit';
|
|
4
5
|
import isNil from 'lodash/fp/isNil';
|
|
5
6
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
6
7
|
import classNames from 'classnames';
|
|
7
8
|
import isFunction from 'lodash/fp/isFunction';
|
|
8
9
|
import noop from 'lodash/fp/noop';
|
|
9
|
-
import
|
|
10
|
+
import { IMaskInput } from 'react-imask';
|
|
10
11
|
import usePrevious from '../../hooks/usePrevious';
|
|
12
|
+
import useMergeRefs from '../../hooks/useMergeRefs';
|
|
11
13
|
export const DEFAULT_TYPE = 'text';
|
|
12
14
|
export const SUPPORTED_TYPES = ['text', 'password', 'email'];
|
|
13
15
|
const hasValue = (value) => !isEmpty(`${value}`);
|
|
14
16
|
const ClearableInput = forwardRef((props, ref) => {
|
|
15
|
-
const { type = DEFAULT_TYPE, defaultValue, value, maxLength, tabIndex = 0, hasError = false, inputRef, autoComplete, onChange = noop, onBlur = noop, onFocus = noop, onClear = noop, onKeyPress = noop, onClick = noop, mask, maskPlaceholder = '_', alwaysShowMask = false, inputClassName = '', disabled = false, className = '', children, ...remainingProps } = props;
|
|
17
|
+
const { type = DEFAULT_TYPE, defaultValue, value, maxLength, tabIndex = 0, hasError = false, inputRef, autoComplete, onChange = noop, onBlur = noop, onFocus = noop, onClear = noop, onKeyPress = noop, onClick = noop, mask, maskPlaceholder = '_', maskVisibility = 'always', alwaysShowMask = false, inputClassName = '', disabled = false, className = '', children, ...remainingProps } = props;
|
|
16
18
|
const initialValue = value || defaultValue || '';
|
|
17
19
|
const [inputValue, setInputValue] = useState(initialValue);
|
|
18
20
|
const [showClear, setShowClear] = useState(hasValue(initialValue));
|
|
21
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
19
22
|
const isControlled = !isNil(value);
|
|
23
|
+
const internalMaskRef = useRef(null);
|
|
24
|
+
const mergedInternalMaskRef = useMergeRefs(internalMaskRef, inputRef, ref);
|
|
20
25
|
const hasMask = !!mask;
|
|
26
|
+
// Calculate if mask should be visible (lazy=false means visible, lazy=true means hidden)
|
|
27
|
+
const shouldShowMask = () => {
|
|
28
|
+
// For backward compatibility
|
|
29
|
+
if (alwaysShowMask) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
switch (maskVisibility) {
|
|
33
|
+
case 'always':
|
|
34
|
+
return true;
|
|
35
|
+
case 'onFocus':
|
|
36
|
+
return isFocused;
|
|
37
|
+
case 'never':
|
|
38
|
+
return false;
|
|
39
|
+
default:
|
|
40
|
+
return isFocused;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
21
43
|
// Handles new input value and saves it in the local state.
|
|
22
44
|
// The value stored in the state is used for rendering.
|
|
23
45
|
const changeInternalValue = (newValue = '') => {
|
|
@@ -44,6 +66,45 @@ const ClearableInput = forwardRef((props, ref) => {
|
|
|
44
66
|
onChange(newValue, event);
|
|
45
67
|
}
|
|
46
68
|
};
|
|
69
|
+
const handleAccept = (newValue, maskRef, event) => {
|
|
70
|
+
if (!internalMaskRef.current) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// Simulate a ChangeEvent for backwards compatibility since react-imask does not return a change event itself
|
|
74
|
+
const syntheticEvent = {
|
|
75
|
+
target: internalMaskRef.current,
|
|
76
|
+
currentTarget: internalMaskRef.current,
|
|
77
|
+
// Standard synthetic event props
|
|
78
|
+
bubbles: true,
|
|
79
|
+
cancelable: true,
|
|
80
|
+
defaultPrevented: false,
|
|
81
|
+
isTrusted: true,
|
|
82
|
+
preventDefault: () => { },
|
|
83
|
+
stopPropagation: () => { },
|
|
84
|
+
persist: () => { },
|
|
85
|
+
nativeEvent: {},
|
|
86
|
+
type: 'change',
|
|
87
|
+
timeStamp: Date.now(),
|
|
88
|
+
};
|
|
89
|
+
// Set unmasked value manually if needed
|
|
90
|
+
// (you can use data-attributes or attach it directly)
|
|
91
|
+
syntheticEvent.target.unmaskedValue = maskRef.unmaskedValue;
|
|
92
|
+
if (isControlled) {
|
|
93
|
+
onChange(newValue, syntheticEvent);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
changeInternalValue(newValue);
|
|
97
|
+
onChange(newValue, syntheticEvent);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const handleInputFocus = (event) => {
|
|
101
|
+
setIsFocused(true);
|
|
102
|
+
onFocus(event);
|
|
103
|
+
};
|
|
104
|
+
const handleInputBlur = (event) => {
|
|
105
|
+
setIsFocused(false);
|
|
106
|
+
onBlur(event);
|
|
107
|
+
};
|
|
47
108
|
// Will be triggered on every key press but also when pressing 'Enter' for example
|
|
48
109
|
const handleKeyPress = (event) => {
|
|
49
110
|
onKeyPress(event);
|
|
@@ -66,17 +127,16 @@ const ClearableInput = forwardRef((props, ref) => {
|
|
|
66
127
|
autoComplete,
|
|
67
128
|
type: inputType,
|
|
68
129
|
value: inputValue,
|
|
69
|
-
onChange: handleChange,
|
|
70
130
|
onKeyPress: handleKeyPress,
|
|
71
|
-
onBlur,
|
|
72
|
-
onFocus,
|
|
131
|
+
onBlur: handleInputBlur,
|
|
132
|
+
onFocus: handleInputFocus,
|
|
133
|
+
onChange: hasMask ? undefined : handleChange, // In case of masked input, the onAccept callback is used
|
|
73
134
|
onClick,
|
|
74
135
|
disabled,
|
|
75
136
|
maxLength: hasMask ? undefined : maxLength,
|
|
76
137
|
tabIndex,
|
|
77
|
-
ref: inputRef || ref,
|
|
78
138
|
};
|
|
79
|
-
const input = hasMask ? (_jsx(
|
|
139
|
+
const input = hasMask ? (_jsx(IMaskInput, { ...inputProps, ref: mergedInternalMaskRef, mask: mask, placeholderChar: maskPlaceholder, onAccept: handleAccept, lazy: !shouldShowMask(), overwrite: true })) : (_jsx("input", { ...inputProps, ref: inputRef || ref }));
|
|
80
140
|
return (_jsxs("div", { className: classes, children: [children && isFunction(children) ? children(inputProps) : input, _jsx("span", { className: clearButtonClassNames, onClick: clearInputValue, children: _jsx("span", { className: 'clearButtonIcon rioglyph rioglyph-remove-sign' }) })] }));
|
|
81
141
|
});
|
|
82
142
|
export default ClearableInput;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
//
|
|
2
|
+
// biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
|
|
3
3
|
import { useState, useRef } from 'react';
|
|
4
4
|
import ReactDOM from 'react-dom';
|
|
5
5
|
import classNames from 'classnames';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
//
|
|
2
|
+
// biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import IframeResizer from 'iframe-resizer-react';
|
|
5
5
|
import Dialog from './Dialog';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type DropdownToggleEvent, type DropdownToggleButtonType } from './DropdownToggleButton';
|
|
2
3
|
import type { MenuItemProps as MenuItem } from '../menuItems/MenuItem';
|
|
3
4
|
import type { BUTTON_SIZE, BUTTON_STYLE, BUTTON_VARIANT } from '../button/Button';
|
|
4
|
-
export type ButtonDropdownProps = {
|
|
5
|
+
export type ButtonDropdownProps<T extends DropdownToggleButtonType = 'button'> = {
|
|
5
6
|
/**
|
|
6
7
|
* Unique button id. If not present a random id is generated.
|
|
7
8
|
*/
|
|
@@ -46,6 +47,13 @@ export type ButtonDropdownProps = {
|
|
|
46
47
|
* Possible values are: `link`, `link-inline`, `outline`, `action`
|
|
47
48
|
*/
|
|
48
49
|
variant?: BUTTON_VARIANT;
|
|
50
|
+
/**
|
|
51
|
+
* Specify the toggle element type.
|
|
52
|
+
* It supports the following types: "button" | "tag" | "label"
|
|
53
|
+
*
|
|
54
|
+
* @default 'button'
|
|
55
|
+
*/
|
|
56
|
+
toggleButtonType?: DropdownToggleButtonType;
|
|
49
57
|
/**
|
|
50
58
|
* Optional prop to defines whether the dropdown title is icon only which
|
|
51
59
|
* applies different padding so the button is a square.
|
|
@@ -90,7 +98,7 @@ export type ButtonDropdownProps = {
|
|
|
90
98
|
* @param event
|
|
91
99
|
* @returns
|
|
92
100
|
*/
|
|
93
|
-
onOpen?: (event
|
|
101
|
+
onOpen?: (event: DropdownToggleEvent<T>) => void;
|
|
94
102
|
/**
|
|
95
103
|
* Callback for when the toggle button was clicked to close it.
|
|
96
104
|
* @returns
|
|
@@ -117,7 +125,7 @@ export type ButtonDropdownProps = {
|
|
|
117
125
|
*/
|
|
118
126
|
className?: string;
|
|
119
127
|
};
|
|
120
|
-
declare const ButtonDropdown: React.ForwardRefExoticComponent<ButtonDropdownProps & {
|
|
128
|
+
declare const ButtonDropdown: React.ForwardRefExoticComponent<ButtonDropdownProps<"button"> & {
|
|
121
129
|
children?: React.ReactNode | undefined;
|
|
122
130
|
} & React.RefAttributes<HTMLButtonElement>>;
|
|
123
131
|
export default ButtonDropdown;
|
|
@@ -25,71 +25,86 @@ const getPlacement = (pullRight, dropup) => {
|
|
|
25
25
|
}
|
|
26
26
|
return 'bottom-start';
|
|
27
27
|
};
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
28
|
+
const createButtonDropdown = () => {
|
|
29
|
+
return forwardRef((props, ref) => {
|
|
30
|
+
const { id = Math.random().toString(36).slice(2, 16), items = [], bsSize = 'md', bsStyle = 'default', variant, disabled = false, iconOnly = false, title, splitButton = false, customDropdown, open, dropup = false, pullRight = false, noCaret = false, onOpen = noop, onClose = noop, onLabelButtonClick = noop, usePortal = false, popperConfig, toggleButtonType = 'button', toggleClassName = '', dropdownClassName, className = '', ...remainingProps } = props;
|
|
31
|
+
const [internalOpen, setInternalOpen] = useState(open);
|
|
32
|
+
const [refDropdownToggle, setRefDropdownToggle] = useState(null);
|
|
33
|
+
const [refDropdownMenu, setRefDropdownMenu] = useState(null);
|
|
34
|
+
const [refSplitButtonToggle, setRefSplitButtonToggle] = useState(null);
|
|
35
|
+
const defaultPopperConfig = {
|
|
36
|
+
placement: getPlacement(pullRight, dropup),
|
|
37
|
+
modifiers: [],
|
|
38
|
+
};
|
|
39
|
+
const popperParentRef = splitButton && pullRight ? refSplitButtonToggle : refDropdownToggle;
|
|
40
|
+
const { styles, attributes } = usePopper(popperParentRef, refDropdownMenu, popperConfig || defaultPopperConfig);
|
|
41
|
+
const isUncontrolled = isNil(open);
|
|
42
|
+
const isOpen = isUncontrolled ? internalOpen : open;
|
|
43
|
+
const wrapperRef = useClickOutside(event => {
|
|
44
|
+
if (usePortal) {
|
|
45
|
+
// In case the dropdown is rendered via portal the clickOutside the toggle button element is
|
|
46
|
+
// triggered since the dropdown is not a child of the wrapper element.
|
|
47
|
+
// In this case we need to check if the event target is inside the dropdown-menu and prevent closing
|
|
48
|
+
// the dropdown
|
|
49
|
+
if (!refDropdownMenu?.contains(event.target)) {
|
|
50
|
+
closeMenu();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
49
54
|
closeMenu();
|
|
50
55
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
}, DEFAULT_EVENT_TYPES, Boolean(isOpen) // only listen to clicks outside when the dropdown is open
|
|
57
|
+
);
|
|
58
|
+
const dropdownRoot = getOrCreatePortalRoot();
|
|
59
|
+
const shouldShowCaret = !noCaret && !splitButton && !iconOnly;
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (!isUncontrolled) {
|
|
62
|
+
setInternalOpen(open);
|
|
63
|
+
}
|
|
64
|
+
}, [isUncontrolled, open]);
|
|
65
|
+
const toggleOpen = (event) => {
|
|
66
|
+
const isDropdownOpen = isUncontrolled ? internalOpen : open;
|
|
67
|
+
if (isDropdownOpen) {
|
|
68
|
+
closeMenu();
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
openMenu(event);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const openMenu = (event) => {
|
|
75
|
+
if (isUncontrolled) {
|
|
76
|
+
setInternalOpen(true);
|
|
77
|
+
}
|
|
78
|
+
if (event) {
|
|
79
|
+
onOpen(event);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const closeMenu = () => {
|
|
83
|
+
if (isUncontrolled) {
|
|
84
|
+
setInternalOpen(false);
|
|
85
|
+
}
|
|
86
|
+
onClose();
|
|
87
|
+
};
|
|
88
|
+
const handleSplitLabelButtonClick = () => {
|
|
67
89
|
closeMenu();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
89
|
-
const handleDropdownButtonClick = splitButton ? handleSplitLabelButtonClick : toggleOpen;
|
|
90
|
-
const wrapperClasses = classNames('dropdown', 'btn-group', isOpen && 'open', className);
|
|
91
|
-
const dropdownClasses = classNames(usePortal && 'dropdown-portal', splitButton && pullRight && 'pull-right', dropdownClassName);
|
|
92
|
-
const dropdownMenu = (_jsx(MenuItemList, { className: dropdownClasses, ref: setRefDropdownMenu, style: styles.popper, ...attributes.popper, children: customDropdown ? customDropdown : _jsx(MenuItems, { items: items, closeMenu: toggleOpen }) }));
|
|
93
|
-
return (_jsxs("div", { ...remainingProps, className: wrapperClasses, ref: wrapperRef, children: [_jsx(DropdownToggleButton, { id: id, splitButton: splitButton, bsStyle: bsStyle, bsSize: bsSize, variant: variant, iconOnly: iconOnly, disabled: disabled, ref: setRefDropdownToggle, onClick: handleDropdownButtonClick, outerRef: ref, className: toggleClassName, children: _jsxs(_Fragment, { children: [title, shouldShowCaret && _jsx(Caret, {})] }) }), splitButton && (_jsx(SplitCaretButton, { id: id, bsStyle: bsStyle, bsSize: bsSize, disabled: disabled, className: toggleClassName, onClick: toggleOpen, ref: setRefSplitButtonToggle })), isOpen && usePortal && ReactDOM.createPortal(dropdownMenu, dropdownRoot), isOpen && !usePortal && dropdownMenu] }));
|
|
94
|
-
});
|
|
90
|
+
onLabelButtonClick();
|
|
91
|
+
};
|
|
92
|
+
const handleSplitCaretButtonClick = (event) => {
|
|
93
|
+
toggleOpen(event);
|
|
94
|
+
};
|
|
95
|
+
const handleDropdownButtonClick = (event) => {
|
|
96
|
+
if (splitButton) {
|
|
97
|
+
handleSplitLabelButtonClick();
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
toggleOpen(event);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const wrapperClasses = classNames('dropdown', 'btn-group', isOpen && 'open', className);
|
|
104
|
+
const dropdownClasses = classNames(usePortal && 'dropdown-portal', splitButton && pullRight && 'pull-right', dropdownClassName);
|
|
105
|
+
const dropdownMenu = (_jsx(MenuItemList, { className: dropdownClasses, ref: setRefDropdownMenu, style: styles.popper, ...attributes.popper, children: customDropdown ? customDropdown : _jsx(MenuItems, { items: items, closeMenu: toggleOpen }) }));
|
|
106
|
+
return (_jsxs("div", { ...remainingProps, className: wrapperClasses, ref: wrapperRef, children: [_jsx(DropdownToggleButton, { id: id, splitButton: splitButton, bsStyle: bsStyle, bsSize: bsSize, variant: variant, iconOnly: iconOnly, disabled: disabled, ref: setRefDropdownToggle, onClick: handleDropdownButtonClick, outerRef: ref, toggleButtonType: toggleButtonType, className: toggleClassName, children: _jsxs(_Fragment, { children: [title, shouldShowCaret && _jsx(Caret, {})] }) }), splitButton && (_jsx(SplitCaretButton, { id: id, bsStyle: bsStyle, bsSize: bsSize, disabled: disabled, className: toggleClassName, onClick: handleSplitCaretButtonClick, ref: setRefSplitButtonToggle })), isOpen && usePortal && ReactDOM.createPortal(dropdownMenu, dropdownRoot), isOpen && !usePortal && dropdownMenu] }));
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
const ButtonDropdown = createButtonDropdown();
|
|
95
110
|
export default ButtonDropdown;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type HTMLProps, type PropsWithChildren } from 'react';
|
|
2
2
|
import { type BUTTON_VARIANT, type BUTTON_SIZE, type BUTTON_STYLE } from '../button/Button';
|
|
3
|
+
export type DropdownToggleButtonType = 'button' | 'tag' | 'label';
|
|
4
|
+
export type DropdownToggleEvent<T extends DropdownToggleButtonType = 'button'> = T extends 'button' ? React.MouseEvent<HTMLButtonElement> : React.MouseEvent<HTMLDivElement>;
|
|
3
5
|
export type DropdownToggleButtonProps = HTMLProps<HTMLButtonElement> & {
|
|
4
6
|
id?: string;
|
|
5
7
|
disabled?: boolean;
|
|
6
8
|
splitButton?: boolean;
|
|
7
9
|
iconOnly?: boolean;
|
|
8
|
-
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
10
|
+
onClick: (event: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => void;
|
|
9
11
|
bsSize: BUTTON_SIZE;
|
|
10
12
|
bsStyle: BUTTON_STYLE;
|
|
11
13
|
variant?: BUTTON_VARIANT;
|
|
12
|
-
|
|
14
|
+
toggleButtonType?: DropdownToggleButtonType;
|
|
15
|
+
outerRef?: React.Ref<HTMLButtonElement | HTMLDivElement>;
|
|
13
16
|
className?: string;
|
|
14
17
|
};
|
|
15
|
-
declare const DropdownToggleButton:
|
|
18
|
+
declare const DropdownToggleButton: import("react").ForwardRefExoticComponent<Omit<PropsWithChildren<DropdownToggleButtonProps>, "ref"> & import("react").RefAttributes<HTMLDivElement | HTMLButtonElement>>;
|
|
16
19
|
export default DropdownToggleButton;
|