@itwin/itwinui-react 3.15.4 → 3.16.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/CHANGELOG.md +30 -0
- package/DEV-cjs/core/Breadcrumbs/Breadcrumbs.js +2 -2
- package/DEV-cjs/core/Checkbox/Checkbox.js +4 -6
- package/DEV-cjs/core/ComboBox/ComboBox.js +10 -6
- package/DEV-cjs/core/DatePicker/DatePicker.js +9 -1
- package/DEV-cjs/core/Dialog/Dialog.js +1 -1
- package/DEV-cjs/core/Panels/Panels.js +319 -0
- package/DEV-cjs/core/Panels/helpers.js +62 -0
- package/DEV-cjs/core/Radio/Radio.js +4 -6
- package/DEV-cjs/core/RadioTiles/RadioTileGroup.js +9 -2
- package/DEV-cjs/core/Select/SelectTag.js +9 -11
- package/DEV-cjs/core/Select/SelectTagContainer.js +2 -2
- package/DEV-cjs/core/Stepper/Stepper.js +1 -0
- package/DEV-cjs/core/Stepper/StepperStep.js +2 -1
- package/DEV-cjs/core/Table/Table.js +64 -47
- package/DEV-cjs/core/Table/TablePaginator.js +15 -3
- package/DEV-cjs/core/Table/actionHandlers/selectHandler.js +10 -7
- package/DEV-cjs/core/Table/columns/selectionColumn.js +6 -1
- package/DEV-cjs/core/Tree/Tree.js +1 -0
- package/DEV-cjs/index.js +4 -0
- package/DEV-cjs/styles.js +1 -1
- package/DEV-cjs/utils/components/MiddleTextTruncation.js +22 -4
- package/DEV-cjs/utils/components/OverflowContainer.js +170 -27
- package/DEV-cjs/utils/hooks/index.js +1 -1
- package/DEV-cjs/utils/hooks/useInstance.js +38 -0
- package/DEV-esm/core/Breadcrumbs/Breadcrumbs.js +2 -2
- package/DEV-esm/core/Checkbox/Checkbox.js +5 -10
- package/DEV-esm/core/ComboBox/ComboBox.js +10 -6
- package/DEV-esm/core/DatePicker/DatePicker.js +11 -1
- package/DEV-esm/core/Dialog/Dialog.js +1 -1
- package/DEV-esm/core/Panels/Panels.js +301 -0
- package/DEV-esm/core/Panels/helpers.js +42 -0
- package/DEV-esm/core/Radio/Radio.js +4 -9
- package/DEV-esm/core/RadioTiles/RadioTileGroup.js +8 -2
- package/DEV-esm/core/Select/SelectTag.js +9 -11
- package/DEV-esm/core/Select/SelectTagContainer.js +2 -2
- package/DEV-esm/core/Stepper/Stepper.js +1 -0
- package/DEV-esm/core/Stepper/StepperStep.js +2 -1
- package/DEV-esm/core/Table/Table.js +61 -47
- package/DEV-esm/core/Table/TablePaginator.js +16 -3
- package/DEV-esm/core/Table/actionHandlers/selectHandler.js +10 -7
- package/DEV-esm/core/Table/columns/selectionColumn.js +6 -1
- package/DEV-esm/core/Tree/Tree.js +1 -0
- package/DEV-esm/index.js +1 -0
- package/DEV-esm/styles.js +1 -1
- package/DEV-esm/utils/components/MiddleTextTruncation.js +22 -4
- package/DEV-esm/utils/components/OverflowContainer.js +143 -4
- package/DEV-esm/utils/hooks/index.js +1 -1
- package/DEV-esm/utils/hooks/useInstance.js +18 -0
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -2
- package/cjs/core/Checkbox/Checkbox.js +4 -6
- package/cjs/core/ComboBox/ComboBox.d.ts +13 -0
- package/cjs/core/ComboBox/ComboBox.js +10 -6
- package/cjs/core/DatePicker/DatePicker.d.ts +2 -2
- package/cjs/core/DatePicker/DatePicker.js +2 -1
- package/cjs/core/Dialog/Dialog.js +1 -1
- package/cjs/core/Dialog/DialogContext.d.ts +6 -2
- package/cjs/core/NonIdealState/NonIdealState.d.ts +15 -11
- package/cjs/core/Panels/Panels.d.ts +174 -0
- package/cjs/core/Panels/Panels.js +312 -0
- package/cjs/core/Panels/helpers.d.ts +23 -0
- package/cjs/core/Panels/helpers.js +61 -0
- package/cjs/core/Radio/Radio.js +4 -6
- package/cjs/core/RadioTiles/RadioTileGroup.d.ts +3 -1
- package/cjs/core/RadioTiles/RadioTileGroup.js +9 -2
- package/cjs/core/Select/SelectTag.d.ts +3 -1
- package/cjs/core/Select/SelectTag.js +9 -11
- package/cjs/core/Select/SelectTagContainer.js +2 -2
- package/cjs/core/Stepper/Stepper.d.ts +4 -0
- package/cjs/core/Stepper/Stepper.js +1 -0
- package/cjs/core/Stepper/StepperStep.d.ts +4 -0
- package/cjs/core/Stepper/StepperStep.js +2 -1
- package/cjs/core/Table/Table.d.ts +1 -0
- package/cjs/core/Table/Table.js +64 -47
- package/cjs/core/Table/TablePaginator.js +15 -3
- package/cjs/core/Table/actionHandlers/selectHandler.js +10 -7
- package/cjs/core/Table/columns/selectionColumn.js +6 -1
- package/cjs/core/Tree/Tree.js +1 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +4 -0
- package/cjs/styles.js +1 -1
- package/cjs/utils/components/MiddleTextTruncation.d.ts +5 -7
- package/cjs/utils/components/MiddleTextTruncation.js +22 -4
- package/cjs/utils/components/OverflowContainer.d.ts +1 -0
- package/cjs/utils/components/OverflowContainer.js +170 -27
- package/cjs/utils/hooks/index.d.ts +1 -1
- package/cjs/utils/hooks/index.js +1 -1
- package/cjs/utils/hooks/useInstance.d.ts +22 -0
- package/cjs/utils/hooks/useInstance.js +38 -0
- package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -2
- package/esm/core/Checkbox/Checkbox.js +5 -10
- package/esm/core/ComboBox/ComboBox.d.ts +13 -0
- package/esm/core/ComboBox/ComboBox.js +10 -6
- package/esm/core/DatePicker/DatePicker.d.ts +2 -2
- package/esm/core/DatePicker/DatePicker.js +4 -1
- package/esm/core/Dialog/Dialog.js +1 -1
- package/esm/core/Dialog/DialogContext.d.ts +6 -2
- package/esm/core/NonIdealState/NonIdealState.d.ts +15 -11
- package/esm/core/Panels/Panels.d.ts +174 -0
- package/esm/core/Panels/Panels.js +294 -0
- package/esm/core/Panels/helpers.d.ts +23 -0
- package/esm/core/Panels/helpers.js +41 -0
- package/esm/core/Radio/Radio.js +4 -9
- package/esm/core/RadioTiles/RadioTileGroup.d.ts +3 -1
- package/esm/core/RadioTiles/RadioTileGroup.js +8 -2
- package/esm/core/Select/SelectTag.d.ts +3 -1
- package/esm/core/Select/SelectTag.js +9 -11
- package/esm/core/Select/SelectTagContainer.js +2 -2
- package/esm/core/Stepper/Stepper.d.ts +4 -0
- package/esm/core/Stepper/Stepper.js +1 -0
- package/esm/core/Stepper/StepperStep.d.ts +4 -0
- package/esm/core/Stepper/StepperStep.js +2 -1
- package/esm/core/Table/Table.d.ts +1 -0
- package/esm/core/Table/Table.js +61 -47
- package/esm/core/Table/TablePaginator.js +16 -3
- package/esm/core/Table/actionHandlers/selectHandler.js +10 -7
- package/esm/core/Table/columns/selectionColumn.js +6 -1
- package/esm/core/Tree/Tree.js +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/styles.js +1 -1
- package/esm/utils/components/MiddleTextTruncation.d.ts +5 -7
- package/esm/utils/components/MiddleTextTruncation.js +22 -4
- package/esm/utils/components/OverflowContainer.d.ts +1 -0
- package/esm/utils/components/OverflowContainer.js +143 -4
- package/esm/utils/hooks/index.d.ts +1 -1
- package/esm/utils/hooks/index.js +1 -1
- package/esm/utils/hooks/useInstance.d.ts +22 -0
- package/esm/utils/hooks/useInstance.js +18 -0
- package/package.json +2 -2
- package/styles.css +8 -8
- package/DEV-cjs/utils/hooks/useOverflow.js +0 -76
- package/DEV-esm/utils/hooks/useOverflow.js +0 -63
- package/cjs/utils/hooks/useOverflow.d.ts +0 -23
- package/cjs/utils/hooks/useOverflow.js +0 -76
- package/esm/utils/hooks/useOverflow.d.ts +0 -23
- package/esm/utils/hooks/useOverflow.js +0 -63
|
@@ -34,11 +34,11 @@ export const Checkbox = React.forwardRef((props, ref) => {
|
|
|
34
34
|
'iui-checkbox',
|
|
35
35
|
{
|
|
36
36
|
'iui-checkbox-visibility': 'eyeball' === variant,
|
|
37
|
-
'iui-loading': isLoading,
|
|
38
37
|
},
|
|
39
38
|
className,
|
|
40
39
|
),
|
|
41
40
|
style: style,
|
|
41
|
+
'data-iui-loading': isLoading ? 'true' : void 0,
|
|
42
42
|
disabled: disabled || isLoading,
|
|
43
43
|
type: 'checkbox',
|
|
44
44
|
ref: refs,
|
|
@@ -57,15 +57,10 @@ export const Checkbox = React.forwardRef((props, ref) => {
|
|
|
57
57
|
Box,
|
|
58
58
|
{
|
|
59
59
|
as: 'label',
|
|
60
|
-
className: cx(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
[`iui-${status}`]: !!status,
|
|
65
|
-
'iui-loading': isLoading,
|
|
66
|
-
},
|
|
67
|
-
wrapperClassName,
|
|
68
|
-
),
|
|
60
|
+
className: cx('iui-checkbox-wrapper', wrapperClassName),
|
|
61
|
+
'data-iui-disabled': disabled ? 'true' : void 0,
|
|
62
|
+
'data-iui-status': status,
|
|
63
|
+
'data-iui-loading': isLoading ? 'true' : void 0,
|
|
69
64
|
...restWrapperProps,
|
|
70
65
|
},
|
|
71
66
|
checkbox,
|
|
@@ -47,6 +47,7 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
|
|
|
47
47
|
onHide: onHideProp,
|
|
48
48
|
id = inputProps?.id ? `iui-${inputProps.id}-cb` : idPrefix,
|
|
49
49
|
defaultValue,
|
|
50
|
+
clearFilterOnOptionToggle = true,
|
|
50
51
|
...rest
|
|
51
52
|
} = props;
|
|
52
53
|
let inputRef = React.useRef(null);
|
|
@@ -200,7 +201,6 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
|
|
|
200
201
|
preventScroll: true,
|
|
201
202
|
});
|
|
202
203
|
if (optionsRef.current[__originalIndex]?.disabled) return;
|
|
203
|
-
setIsInputDirty(false);
|
|
204
204
|
if (multiple) {
|
|
205
205
|
let actionType = isMenuItemSelected(__originalIndex)
|
|
206
206
|
? 'removed'
|
|
@@ -218,7 +218,10 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
|
|
|
218
218
|
.filter(Boolean)
|
|
219
219
|
.join(', '),
|
|
220
220
|
);
|
|
221
|
-
|
|
221
|
+
if (clearFilterOnOptionToggle) {
|
|
222
|
+
setInputValue('');
|
|
223
|
+
setIsInputDirty(false);
|
|
224
|
+
}
|
|
222
225
|
} else {
|
|
223
226
|
setSelectedIndexes(__originalIndex);
|
|
224
227
|
hide();
|
|
@@ -226,13 +229,14 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
|
|
|
226
229
|
}
|
|
227
230
|
},
|
|
228
231
|
[
|
|
229
|
-
|
|
230
|
-
isMenuItemSelected,
|
|
232
|
+
optionsRef,
|
|
231
233
|
multiple,
|
|
234
|
+
isMenuItemSelected,
|
|
235
|
+
selectedChangeHandler,
|
|
236
|
+
setSelectedIndexes,
|
|
232
237
|
onChangeHandler,
|
|
233
|
-
|
|
238
|
+
clearFilterOnOptionToggle,
|
|
234
239
|
hide,
|
|
235
|
-
setSelectedIndexes,
|
|
236
240
|
],
|
|
237
241
|
);
|
|
238
242
|
let getMenuItem = React.useCallback(
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
isBefore,
|
|
9
9
|
Box,
|
|
10
10
|
useId,
|
|
11
|
+
useLayoutEffect,
|
|
12
|
+
useWarningLogger,
|
|
11
13
|
} from '../../utils/index.js';
|
|
12
14
|
import { IconButton } from '../Buttons/IconButton.js';
|
|
13
15
|
import { TimePicker } from '../TimePicker/TimePicker.js';
|
|
@@ -135,6 +137,14 @@ export const DatePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
135
137
|
showDatesOutsideMonth = true,
|
|
136
138
|
...rest
|
|
137
139
|
} = props;
|
|
140
|
+
let logWarning = useWarningLogger();
|
|
141
|
+
{
|
|
142
|
+
let onlyOneRangePropPassed = (startDate ? 1 : 0) + (endDate ? 1 : 0) === 1;
|
|
143
|
+
if (enableRangeSelect && onlyOneRangePropPassed)
|
|
144
|
+
logWarning(
|
|
145
|
+
'`DatePicker` with `enableRangeSelect` needs *both* `startDate` and `endDate` to either be `Date` or `undefined`. Passing `Date` to just one of them is not allowed.',
|
|
146
|
+
);
|
|
147
|
+
}
|
|
138
148
|
let monthNames = localizedNames?.months ?? defaultMonths;
|
|
139
149
|
let shortDays = localizedNames?.shortDays ?? defaultShortDays;
|
|
140
150
|
let longDays = localizedNames?.days ?? defaultLongDays;
|
|
@@ -177,7 +187,7 @@ export const DatePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
177
187
|
);
|
|
178
188
|
}, [date, setMonthAndYear, startDate, endDate, enableRangeSelect]);
|
|
179
189
|
let popoverInitialFocusContext = React.useContext(PopoverInitialFocusContext);
|
|
180
|
-
|
|
190
|
+
useLayoutEffect(() => {
|
|
181
191
|
if (setFocus && popoverInitialFocusContext)
|
|
182
192
|
popoverInitialFocusContext.setInitialFocus(-1);
|
|
183
193
|
}, [popoverInitialFocusContext, setFocus]);
|
|
@@ -11,7 +11,7 @@ import { Transition } from 'react-transition-group';
|
|
|
11
11
|
let DialogComponent = React.forwardRef((props, ref) => {
|
|
12
12
|
let {
|
|
13
13
|
trapFocus = false,
|
|
14
|
-
setFocus =
|
|
14
|
+
setFocus = trapFocus,
|
|
15
15
|
preventDocumentScroll = false,
|
|
16
16
|
isOpen = false,
|
|
17
17
|
isDismissible = true,
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as ReactDOM from 'react-dom';
|
|
3
|
+
import {
|
|
4
|
+
Box,
|
|
5
|
+
cloneElementWithRef,
|
|
6
|
+
mergeEventHandlers,
|
|
7
|
+
SvgChevronLeft,
|
|
8
|
+
useInstance,
|
|
9
|
+
useMergedRefs,
|
|
10
|
+
useSafeContext,
|
|
11
|
+
useMediaQuery,
|
|
12
|
+
useWarningLogger,
|
|
13
|
+
useLayoutEffect,
|
|
14
|
+
useLatestRef,
|
|
15
|
+
} from '../../utils/index.js';
|
|
16
|
+
import { IconButton } from '../Buttons/IconButton.js';
|
|
17
|
+
import { Flex } from '../Flex/Flex.js';
|
|
18
|
+
import { Text } from '../Typography/Text.js';
|
|
19
|
+
import cx from 'classnames';
|
|
20
|
+
import { PanelsInstanceContext, PanelsInstanceProvider } from './helpers.js';
|
|
21
|
+
export const PanelsWrapper = React.forwardRef((props, forwardedRef) => {
|
|
22
|
+
let {
|
|
23
|
+
children,
|
|
24
|
+
className,
|
|
25
|
+
onActiveIdChange: onActiveIdChangeProp,
|
|
26
|
+
instance,
|
|
27
|
+
...rest
|
|
28
|
+
} = props;
|
|
29
|
+
let onActiveIdChange = useLatestRef(onActiveIdChangeProp);
|
|
30
|
+
let ref = React.useRef(null);
|
|
31
|
+
let [activePanelId, setActivePanelId] = React.useState(void 0);
|
|
32
|
+
let [triggers, setTriggers] = React.useState({});
|
|
33
|
+
let panels = React.useRef(new Set());
|
|
34
|
+
let [shouldFocus, setShouldFocus] = React.useState(void 0);
|
|
35
|
+
let motionOk = useMediaQuery('(prefers-reduced-motion: no-preference)');
|
|
36
|
+
let changeActivePanel = React.useCallback(
|
|
37
|
+
(newActiveId) => {
|
|
38
|
+
if (!panels.current.has(newActiveId) || newActiveId === activePanelId)
|
|
39
|
+
return;
|
|
40
|
+
ReactDOM.flushSync(() => setActivePanelId(newActiveId));
|
|
41
|
+
onActiveIdChange.current?.(newActiveId);
|
|
42
|
+
ref.current?.ownerDocument.getElementById(newActiveId)?.scrollIntoView({
|
|
43
|
+
block: 'nearest',
|
|
44
|
+
inline: 'center',
|
|
45
|
+
behavior: motionOk ? 'smooth' : 'instant',
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
[activePanelId, motionOk, onActiveIdChange],
|
|
49
|
+
);
|
|
50
|
+
return React.createElement(
|
|
51
|
+
PanelsWrapperContext.Provider,
|
|
52
|
+
{
|
|
53
|
+
value: React.useMemo(
|
|
54
|
+
() => ({
|
|
55
|
+
activePanelId,
|
|
56
|
+
setActivePanelId,
|
|
57
|
+
changeActivePanel,
|
|
58
|
+
triggers,
|
|
59
|
+
setTriggers,
|
|
60
|
+
shouldFocus,
|
|
61
|
+
setShouldFocus,
|
|
62
|
+
panels,
|
|
63
|
+
}),
|
|
64
|
+
[
|
|
65
|
+
activePanelId,
|
|
66
|
+
changeActivePanel,
|
|
67
|
+
setActivePanelId,
|
|
68
|
+
setTriggers,
|
|
69
|
+
shouldFocus,
|
|
70
|
+
triggers,
|
|
71
|
+
],
|
|
72
|
+
),
|
|
73
|
+
},
|
|
74
|
+
React.createElement(
|
|
75
|
+
PanelsInstanceProvider,
|
|
76
|
+
{
|
|
77
|
+
instance: instance,
|
|
78
|
+
},
|
|
79
|
+
React.createElement(
|
|
80
|
+
Box,
|
|
81
|
+
{
|
|
82
|
+
ref: useMergedRefs(ref, forwardedRef),
|
|
83
|
+
...rest,
|
|
84
|
+
className: cx('iui-panel-wrapper', className),
|
|
85
|
+
},
|
|
86
|
+
children,
|
|
87
|
+
),
|
|
88
|
+
),
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
PanelsWrapper.displayName = 'Panels.Wrapper';
|
|
92
|
+
export const PanelsWrapperContext = React.createContext(void 0);
|
|
93
|
+
PanelsWrapperContext.displayName = 'PanelsWrapperContext';
|
|
94
|
+
let Panel = React.forwardRef((props, forwardedRef) => {
|
|
95
|
+
let { id, children, className, ...rest } = props;
|
|
96
|
+
let { activePanelId, triggers, panels, setActivePanelId } =
|
|
97
|
+
useSafeContext(PanelsWrapperContext);
|
|
98
|
+
let associatedTrigger = React.useMemo(() => triggers[id], [id, triggers]);
|
|
99
|
+
let previousActivePanelId = useDelayed(activePanelId) || activePanelId;
|
|
100
|
+
let isMounted = [activePanelId, previousActivePanelId].includes(id);
|
|
101
|
+
let isTransitioning =
|
|
102
|
+
activePanelId === id && activePanelId !== previousActivePanelId;
|
|
103
|
+
let isInert = previousActivePanelId === id && activePanelId !== id;
|
|
104
|
+
useLayoutEffect(() => {
|
|
105
|
+
let isFirstPanel = null == activePanelId && 0 === panels.current.size;
|
|
106
|
+
if (isFirstPanel) setActivePanelId(id);
|
|
107
|
+
let panelsCurrent = panels.current;
|
|
108
|
+
if (!panelsCurrent.has(id)) panelsCurrent.add(id);
|
|
109
|
+
return () => {
|
|
110
|
+
panelsCurrent.delete(id);
|
|
111
|
+
};
|
|
112
|
+
}, [activePanelId, id, panels, setActivePanelId]);
|
|
113
|
+
return React.createElement(
|
|
114
|
+
PanelContext.Provider,
|
|
115
|
+
{
|
|
116
|
+
value: React.useMemo(
|
|
117
|
+
() => ({
|
|
118
|
+
id,
|
|
119
|
+
associatedTrigger,
|
|
120
|
+
}),
|
|
121
|
+
[associatedTrigger, id],
|
|
122
|
+
),
|
|
123
|
+
},
|
|
124
|
+
isMounted &&
|
|
125
|
+
React.createElement(
|
|
126
|
+
Box,
|
|
127
|
+
{
|
|
128
|
+
ref: forwardedRef,
|
|
129
|
+
id: id,
|
|
130
|
+
className: cx('iui-panel', className),
|
|
131
|
+
'aria-labelledby': `${id}-header-title`,
|
|
132
|
+
role: 'group',
|
|
133
|
+
inert: isInert ? '' : void 0,
|
|
134
|
+
'data-iui-transitioning': isTransitioning ? 'true' : void 0,
|
|
135
|
+
...rest,
|
|
136
|
+
},
|
|
137
|
+
children,
|
|
138
|
+
),
|
|
139
|
+
);
|
|
140
|
+
});
|
|
141
|
+
Panel.displayName = 'Panels.Panel';
|
|
142
|
+
let PanelContext = React.createContext(void 0);
|
|
143
|
+
PanelContext.displayName = 'PanelContext';
|
|
144
|
+
let PanelTrigger = (props) => {
|
|
145
|
+
let { children, for: forProp } = props;
|
|
146
|
+
let {
|
|
147
|
+
changeActivePanel,
|
|
148
|
+
triggers,
|
|
149
|
+
setTriggers,
|
|
150
|
+
activePanelId: activePanel,
|
|
151
|
+
shouldFocus,
|
|
152
|
+
setShouldFocus,
|
|
153
|
+
panels,
|
|
154
|
+
} = useSafeContext(PanelsWrapperContext);
|
|
155
|
+
let { id: panelId } = useSafeContext(PanelContext);
|
|
156
|
+
let fallbackId = React.useId();
|
|
157
|
+
let triggerId = children.props.id || fallbackId;
|
|
158
|
+
let onClick = React.useCallback(() => {
|
|
159
|
+
if (null == activePanel) return;
|
|
160
|
+
setShouldFocus({
|
|
161
|
+
fromPanelId: activePanel,
|
|
162
|
+
toPanelId: forProp,
|
|
163
|
+
direction: 'forward',
|
|
164
|
+
});
|
|
165
|
+
changeActivePanel?.(forProp);
|
|
166
|
+
}, [activePanel, changeActivePanel, forProp, setShouldFocus]);
|
|
167
|
+
let focusRef = React.useCallback(
|
|
168
|
+
(el) => {
|
|
169
|
+
if (
|
|
170
|
+
shouldFocus?.direction === 'backward' &&
|
|
171
|
+
shouldFocus?.toPanelId === panelId &&
|
|
172
|
+
shouldFocus?.fromPanelId === forProp
|
|
173
|
+
) {
|
|
174
|
+
el?.focus({
|
|
175
|
+
preventScroll: true,
|
|
176
|
+
});
|
|
177
|
+
setShouldFocus(void 0);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
[forProp, panelId, setShouldFocus, shouldFocus],
|
|
181
|
+
);
|
|
182
|
+
let logWarning = useWarningLogger();
|
|
183
|
+
React.useEffect(() => {
|
|
184
|
+
if (!panels.current.has(forProp))
|
|
185
|
+
logWarning(
|
|
186
|
+
`Panels.Trigger's \`for\` prop ("${forProp}") corresponds to no Panel.`,
|
|
187
|
+
);
|
|
188
|
+
}, [forProp, logWarning, panels, triggers]);
|
|
189
|
+
React.useEffect(() => {
|
|
190
|
+
setTriggers((oldTriggers) => {
|
|
191
|
+
let triggersMatch = oldTriggers[forProp];
|
|
192
|
+
if (
|
|
193
|
+
null == triggersMatch ||
|
|
194
|
+
panelId !== triggersMatch.panelId ||
|
|
195
|
+
triggerId !== triggersMatch.triggerId
|
|
196
|
+
)
|
|
197
|
+
return {
|
|
198
|
+
...oldTriggers,
|
|
199
|
+
[forProp]: {
|
|
200
|
+
panelId,
|
|
201
|
+
triggerId,
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
return oldTriggers;
|
|
205
|
+
});
|
|
206
|
+
}, [forProp, panelId, setTriggers, triggerId]);
|
|
207
|
+
return cloneElementWithRef(children, (children) => ({
|
|
208
|
+
...children.props,
|
|
209
|
+
id: triggerId,
|
|
210
|
+
ref: focusRef,
|
|
211
|
+
onClick: mergeEventHandlers(children.props.onClick, onClick),
|
|
212
|
+
'aria-expanded': activePanel === forProp,
|
|
213
|
+
'aria-controls': forProp,
|
|
214
|
+
}));
|
|
215
|
+
};
|
|
216
|
+
PanelTrigger.displayName = 'Panels.Trigger';
|
|
217
|
+
let PanelHeader = React.forwardRef((props, forwardedRef) => {
|
|
218
|
+
let { titleProps, children, ...rest } = props;
|
|
219
|
+
let { shouldFocus, setShouldFocus } = useSafeContext(PanelsWrapperContext);
|
|
220
|
+
let { id: panelId, associatedTrigger: panelAssociatedTrigger } =
|
|
221
|
+
useSafeContext(PanelContext);
|
|
222
|
+
let focusRef = React.useCallback(
|
|
223
|
+
(el) => {
|
|
224
|
+
if (
|
|
225
|
+
shouldFocus?.direction === 'forward' &&
|
|
226
|
+
shouldFocus.toPanelId === panelId
|
|
227
|
+
) {
|
|
228
|
+
el?.focus({
|
|
229
|
+
preventScroll: true,
|
|
230
|
+
});
|
|
231
|
+
setShouldFocus(void 0);
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
[panelId, setShouldFocus, shouldFocus?.direction, shouldFocus?.toPanelId],
|
|
235
|
+
);
|
|
236
|
+
return React.createElement(
|
|
237
|
+
Flex,
|
|
238
|
+
{
|
|
239
|
+
ref: forwardedRef,
|
|
240
|
+
...rest,
|
|
241
|
+
},
|
|
242
|
+
panelAssociatedTrigger && React.createElement(PanelBackButton, null),
|
|
243
|
+
React.createElement(
|
|
244
|
+
Text,
|
|
245
|
+
{
|
|
246
|
+
id: `${panelId}-header-title`,
|
|
247
|
+
as: 'h2',
|
|
248
|
+
tabIndex: -1,
|
|
249
|
+
ref: focusRef,
|
|
250
|
+
...titleProps,
|
|
251
|
+
},
|
|
252
|
+
children,
|
|
253
|
+
),
|
|
254
|
+
);
|
|
255
|
+
});
|
|
256
|
+
PanelHeader.displayName = 'Panels.Header';
|
|
257
|
+
let PanelBackButton = React.forwardRef((props, forwardedRef) => {
|
|
258
|
+
let { children, onClick, ...rest } = props;
|
|
259
|
+
let { instance: panelInstance } = useSafeContext(PanelsInstanceContext);
|
|
260
|
+
return React.createElement(
|
|
261
|
+
IconButton,
|
|
262
|
+
{
|
|
263
|
+
ref: forwardedRef,
|
|
264
|
+
'aria-label': 'Previous panel',
|
|
265
|
+
styleType: 'borderless',
|
|
266
|
+
size: 'small',
|
|
267
|
+
'data-iui-shift': 'left',
|
|
268
|
+
...rest,
|
|
269
|
+
onClick: mergeEventHandlers(
|
|
270
|
+
React.useCallback(() => panelInstance?.goBack(), [panelInstance]),
|
|
271
|
+
onClick,
|
|
272
|
+
),
|
|
273
|
+
},
|
|
274
|
+
children || React.createElement(SvgChevronLeft, null),
|
|
275
|
+
);
|
|
276
|
+
});
|
|
277
|
+
PanelBackButton.displayName = 'Panels.BackButton';
|
|
278
|
+
export const Panels = {
|
|
279
|
+
Wrapper: PanelsWrapper,
|
|
280
|
+
Panel,
|
|
281
|
+
Trigger: PanelTrigger,
|
|
282
|
+
Header: PanelHeader,
|
|
283
|
+
useInstance: useInstance,
|
|
284
|
+
};
|
|
285
|
+
function useDelayed(
|
|
286
|
+
value,
|
|
287
|
+
{ delay } = {
|
|
288
|
+
delay: 500,
|
|
289
|
+
},
|
|
290
|
+
) {
|
|
291
|
+
let [delayed, setDelayed] = React.useState(void 0);
|
|
292
|
+
let timeout = React.useRef(void 0);
|
|
293
|
+
React.useEffect(() => {
|
|
294
|
+
if (0 === delay) setDelayed(value);
|
|
295
|
+
else timeout.current = setTimeout(() => setDelayed(value), delay);
|
|
296
|
+
return () => {
|
|
297
|
+
clearTimeout(timeout.current);
|
|
298
|
+
};
|
|
299
|
+
}, [value, delay]);
|
|
300
|
+
return delayed;
|
|
301
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useSafeContext, useSynchronizeInstance } from '../../utils/index.js';
|
|
3
|
+
import { Panels, PanelsWrapperContext } from './Panels.js';
|
|
4
|
+
export const PanelsInstanceContext = React.createContext(void 0);
|
|
5
|
+
PanelsInstanceContext.displayName = 'PanelsInstanceContext';
|
|
6
|
+
export const PanelsInstanceProvider = (props) => {
|
|
7
|
+
let { children, instance: instanceProp } = props;
|
|
8
|
+
let instanceBackup = Panels.useInstance();
|
|
9
|
+
let instance = instanceProp || instanceBackup;
|
|
10
|
+
let { activePanelId, changeActivePanel, triggers, setShouldFocus } =
|
|
11
|
+
useSafeContext(PanelsWrapperContext);
|
|
12
|
+
let goBack = React.useCallback(async () => {
|
|
13
|
+
if (null == activePanelId) return;
|
|
14
|
+
let trigger = triggers[activePanelId];
|
|
15
|
+
if (null != trigger.triggerId) {
|
|
16
|
+
setShouldFocus({
|
|
17
|
+
fromPanelId: activePanelId,
|
|
18
|
+
toPanelId: trigger.panelId,
|
|
19
|
+
direction: 'backward',
|
|
20
|
+
});
|
|
21
|
+
changeActivePanel(trigger.panelId);
|
|
22
|
+
}
|
|
23
|
+
}, [activePanelId, changeActivePanel, setShouldFocus, triggers]);
|
|
24
|
+
useSynchronizeInstance(
|
|
25
|
+
instance,
|
|
26
|
+
React.useMemo(
|
|
27
|
+
() => ({
|
|
28
|
+
goBack,
|
|
29
|
+
}),
|
|
30
|
+
[goBack],
|
|
31
|
+
),
|
|
32
|
+
);
|
|
33
|
+
return React.createElement(
|
|
34
|
+
PanelsInstanceContext.Provider,
|
|
35
|
+
{
|
|
36
|
+
value: {
|
|
37
|
+
instance,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
children,
|
|
41
|
+
);
|
|
42
|
+
};
|
|
@@ -16,7 +16,7 @@ export const Radio = React.forwardRef((props, ref) => {
|
|
|
16
16
|
let refs = useMergedRefs(inputElementRef, ref);
|
|
17
17
|
let radio = React.createElement(Box, {
|
|
18
18
|
as: 'input',
|
|
19
|
-
className: cx('iui-radio', className),
|
|
19
|
+
className: cx('iui-checkbox', 'iui-radio', className),
|
|
20
20
|
style: style,
|
|
21
21
|
disabled: disabled,
|
|
22
22
|
type: 'radio',
|
|
@@ -29,14 +29,9 @@ export const Radio = React.forwardRef((props, ref) => {
|
|
|
29
29
|
{
|
|
30
30
|
as: 'label',
|
|
31
31
|
...wrapperProps,
|
|
32
|
-
className: cx(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
'iui-disabled': disabled,
|
|
36
|
-
[`iui-${status}`]: !!status,
|
|
37
|
-
},
|
|
38
|
-
wrapperProps?.className,
|
|
39
|
-
),
|
|
32
|
+
className: cx('iui-checkbox-wrapper', wrapperProps?.className),
|
|
33
|
+
'data-iui-status': status,
|
|
34
|
+
'data-iui-disabled': disabled ? 'true' : void 0,
|
|
40
35
|
},
|
|
41
36
|
radio,
|
|
42
37
|
label &&
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { InputGroup } from '../InputGroup/InputGroup.js';
|
|
3
3
|
import { Box } from '../../utils/index.js';
|
|
4
|
+
import cx from 'classnames';
|
|
4
5
|
export const RadioTileGroup = React.forwardRef((props, forwardedRef) => {
|
|
5
|
-
let { children, label, ...rest } = props;
|
|
6
|
+
let { children, label, tileContainerProps, ...rest } = props;
|
|
6
7
|
return React.createElement(
|
|
7
8
|
InputGroup,
|
|
8
9
|
{
|
|
@@ -13,7 +14,12 @@ export const RadioTileGroup = React.forwardRef((props, forwardedRef) => {
|
|
|
13
14
|
React.createElement(
|
|
14
15
|
Box,
|
|
15
16
|
{
|
|
16
|
-
|
|
17
|
+
as: 'div',
|
|
18
|
+
...tileContainerProps,
|
|
19
|
+
className: cx(
|
|
20
|
+
'iui-radio-tile-container',
|
|
21
|
+
tileContainerProps?.className,
|
|
22
|
+
),
|
|
17
23
|
},
|
|
18
24
|
children,
|
|
19
25
|
),
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import cx from 'classnames';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { Tag } from '../Tag/Tag.js';
|
|
4
4
|
export const SelectTag = React.forwardRef((props, forwardedRef) => {
|
|
5
5
|
let { className, label, ...rest } = props;
|
|
6
6
|
return React.createElement(
|
|
7
|
-
|
|
7
|
+
Tag,
|
|
8
8
|
{
|
|
9
|
-
as: 'span',
|
|
10
9
|
className: cx('iui-select-tag', className),
|
|
10
|
+
labelProps: {
|
|
11
|
+
className: 'iui-select-tag-label',
|
|
12
|
+
},
|
|
13
|
+
removeButtonProps: {
|
|
14
|
+
className: 'iui-select-tag-button',
|
|
15
|
+
},
|
|
11
16
|
ref: forwardedRef,
|
|
12
17
|
...rest,
|
|
13
18
|
},
|
|
14
|
-
|
|
15
|
-
Box,
|
|
16
|
-
{
|
|
17
|
-
as: 'span',
|
|
18
|
-
className: 'iui-select-tag-label',
|
|
19
|
-
},
|
|
20
|
-
label,
|
|
21
|
-
),
|
|
19
|
+
label,
|
|
22
20
|
);
|
|
23
21
|
});
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import cx from 'classnames';
|
|
3
3
|
import { SelectTag } from './SelectTag.js';
|
|
4
4
|
import { OverflowContainer } from '../../utils/index.js';
|
|
5
|
-
export const SelectTagContainer = React.forwardRef((props,
|
|
5
|
+
export const SelectTagContainer = React.forwardRef((props, forwardedRef) => {
|
|
6
6
|
let { tags: tagsProp, className, ...rest } = props;
|
|
7
7
|
let tags = React.useMemo(() => React.Children.toArray(tagsProp), [tagsProp]);
|
|
8
8
|
return React.createElement(
|
|
@@ -10,7 +10,7 @@ export const SelectTagContainer = React.forwardRef((props, ref) => {
|
|
|
10
10
|
{
|
|
11
11
|
itemsCount: tags.length,
|
|
12
12
|
className: cx('iui-select-tag-container', className),
|
|
13
|
-
ref:
|
|
13
|
+
ref: forwardedRef,
|
|
14
14
|
...rest,
|
|
15
15
|
},
|
|
16
16
|
React.createElement(SelectTagContainerContent, {
|
|
@@ -17,6 +17,7 @@ export const StepperStep = React.forwardRef((props, forwardedRef) => {
|
|
|
17
17
|
trackContentProps,
|
|
18
18
|
circleProps,
|
|
19
19
|
nameProps,
|
|
20
|
+
stepContent,
|
|
20
21
|
...rest
|
|
21
22
|
} = props;
|
|
22
23
|
let isPast = currentStepNumber > index;
|
|
@@ -74,7 +75,7 @@ export const StepperStep = React.forwardRef((props, forwardedRef) => {
|
|
|
74
75
|
...circleProps,
|
|
75
76
|
className: cx('iui-stepper-circle', circleProps?.className),
|
|
76
77
|
},
|
|
77
|
-
index + 1,
|
|
78
|
+
stepContent ? stepContent() : index + 1,
|
|
78
79
|
),
|
|
79
80
|
),
|
|
80
81
|
'default' === type &&
|