@itwin/itwinui-react 3.15.5 → 3.16.1
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 +32 -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/Header/HeaderDropdownButton.js +1 -7
- package/DEV-cjs/core/Panels/Panels.js +322 -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 +3 -4
- 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/Header/HeaderDropdownButton.js +1 -3
- package/DEV-esm/core/Panels/Panels.js +304 -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 +1 -5
- 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/Header/HeaderDropdownButton.js +1 -7
- package/cjs/core/Panels/Panels.d.ts +174 -0
- package/cjs/core/Panels/Panels.js +315 -0
- package/cjs/core/Panels/helpers.d.ts +23 -0
- package/cjs/core/Panels/helpers.js +61 -0
- package/cjs/core/ProgressIndicators/ProgressLinear.d.ts +1 -1
- 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 +3 -4
- 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.d.ts +2 -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/Header/HeaderDropdownButton.js +1 -3
- package/esm/core/Panels/Panels.d.ts +174 -0
- package/esm/core/Panels/Panels.js +297 -0
- package/esm/core/Panels/helpers.d.ts +23 -0
- package/esm/core/Panels/helpers.js +41 -0
- package/esm/core/ProgressIndicators/ProgressLinear.d.ts +1 -1
- 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 +1 -5
- 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.d.ts +2 -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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import cx from 'classnames';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import { DropdownMenu } from '../DropdownMenu/DropdownMenu.js';
|
|
4
3
|
import {
|
|
@@ -8,7 +7,7 @@ import {
|
|
|
8
7
|
} from '../../utils/index.js';
|
|
9
8
|
import { HeaderBasicButton } from './HeaderBasicButton.js';
|
|
10
9
|
export const HeaderDropdownButton = React.forwardRef((props, ref) => {
|
|
11
|
-
let { menuItems,
|
|
10
|
+
let { menuItems, children, ...rest } = props;
|
|
12
11
|
let [isMenuOpen, setIsMenuOpen] = React.useState(false);
|
|
13
12
|
let [menuWidth, setMenuWidth] = React.useState(0);
|
|
14
13
|
let buttonRef = React.useRef(null);
|
|
@@ -28,7 +27,6 @@ export const HeaderDropdownButton = React.forwardRef((props, ref) => {
|
|
|
28
27
|
React.createElement(
|
|
29
28
|
HeaderBasicButton,
|
|
30
29
|
{
|
|
31
|
-
className: cx('iui-header-breadcrumb-button', className),
|
|
32
30
|
ref: refs,
|
|
33
31
|
'aria-label': 'Dropdown',
|
|
34
32
|
endIcon: isMenuOpen
|
|
@@ -0,0 +1,304 @@
|
|
|
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
|
|
43
|
+
?.getRootNode()
|
|
44
|
+
.getElementById(newActiveId)
|
|
45
|
+
?.scrollIntoView({
|
|
46
|
+
block: 'nearest',
|
|
47
|
+
inline: 'center',
|
|
48
|
+
behavior: motionOk ? 'smooth' : 'instant',
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
[activePanelId, motionOk, onActiveIdChange],
|
|
52
|
+
);
|
|
53
|
+
return React.createElement(
|
|
54
|
+
PanelsWrapperContext.Provider,
|
|
55
|
+
{
|
|
56
|
+
value: React.useMemo(
|
|
57
|
+
() => ({
|
|
58
|
+
activePanelId,
|
|
59
|
+
setActivePanelId,
|
|
60
|
+
changeActivePanel,
|
|
61
|
+
triggers,
|
|
62
|
+
setTriggers,
|
|
63
|
+
shouldFocus,
|
|
64
|
+
setShouldFocus,
|
|
65
|
+
panels,
|
|
66
|
+
}),
|
|
67
|
+
[
|
|
68
|
+
activePanelId,
|
|
69
|
+
changeActivePanel,
|
|
70
|
+
setActivePanelId,
|
|
71
|
+
setTriggers,
|
|
72
|
+
shouldFocus,
|
|
73
|
+
triggers,
|
|
74
|
+
],
|
|
75
|
+
),
|
|
76
|
+
},
|
|
77
|
+
React.createElement(
|
|
78
|
+
PanelsInstanceProvider,
|
|
79
|
+
{
|
|
80
|
+
instance: instance,
|
|
81
|
+
},
|
|
82
|
+
React.createElement(
|
|
83
|
+
Box,
|
|
84
|
+
{
|
|
85
|
+
ref: useMergedRefs(ref, forwardedRef),
|
|
86
|
+
...rest,
|
|
87
|
+
className: cx('iui-panel-wrapper', className),
|
|
88
|
+
},
|
|
89
|
+
children,
|
|
90
|
+
),
|
|
91
|
+
),
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
PanelsWrapper.displayName = 'Panels.Wrapper';
|
|
95
|
+
export const PanelsWrapperContext = React.createContext(void 0);
|
|
96
|
+
PanelsWrapperContext.displayName = 'PanelsWrapperContext';
|
|
97
|
+
let Panel = React.forwardRef((props, forwardedRef) => {
|
|
98
|
+
let { id, children, className, ...rest } = props;
|
|
99
|
+
let { activePanelId, triggers, panels, setActivePanelId } =
|
|
100
|
+
useSafeContext(PanelsWrapperContext);
|
|
101
|
+
let associatedTrigger = React.useMemo(() => triggers[id], [id, triggers]);
|
|
102
|
+
let previousActivePanelId = useDelayed(activePanelId) || activePanelId;
|
|
103
|
+
let isMounted = [activePanelId, previousActivePanelId].includes(id);
|
|
104
|
+
let isTransitioning =
|
|
105
|
+
activePanelId === id && activePanelId !== previousActivePanelId;
|
|
106
|
+
let isInert = previousActivePanelId === id && activePanelId !== id;
|
|
107
|
+
useLayoutEffect(() => {
|
|
108
|
+
let isFirstPanel = null == activePanelId && 0 === panels.current.size;
|
|
109
|
+
if (isFirstPanel) setActivePanelId(id);
|
|
110
|
+
let panelsCurrent = panels.current;
|
|
111
|
+
if (!panelsCurrent.has(id)) panelsCurrent.add(id);
|
|
112
|
+
return () => {
|
|
113
|
+
panelsCurrent.delete(id);
|
|
114
|
+
};
|
|
115
|
+
}, [activePanelId, id, panels, setActivePanelId]);
|
|
116
|
+
return React.createElement(
|
|
117
|
+
PanelContext.Provider,
|
|
118
|
+
{
|
|
119
|
+
value: React.useMemo(
|
|
120
|
+
() => ({
|
|
121
|
+
id,
|
|
122
|
+
associatedTrigger,
|
|
123
|
+
}),
|
|
124
|
+
[associatedTrigger, id],
|
|
125
|
+
),
|
|
126
|
+
},
|
|
127
|
+
isMounted &&
|
|
128
|
+
React.createElement(
|
|
129
|
+
Box,
|
|
130
|
+
{
|
|
131
|
+
ref: forwardedRef,
|
|
132
|
+
id: id,
|
|
133
|
+
className: cx('iui-panel', className),
|
|
134
|
+
'aria-labelledby': `${id}-header-title`,
|
|
135
|
+
role: 'group',
|
|
136
|
+
inert: isInert ? '' : void 0,
|
|
137
|
+
'data-iui-transitioning': isTransitioning ? 'true' : void 0,
|
|
138
|
+
...rest,
|
|
139
|
+
},
|
|
140
|
+
children,
|
|
141
|
+
),
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
Panel.displayName = 'Panels.Panel';
|
|
145
|
+
let PanelContext = React.createContext(void 0);
|
|
146
|
+
PanelContext.displayName = 'PanelContext';
|
|
147
|
+
let PanelTrigger = (props) => {
|
|
148
|
+
let { children, for: forProp } = props;
|
|
149
|
+
let {
|
|
150
|
+
changeActivePanel,
|
|
151
|
+
triggers,
|
|
152
|
+
setTriggers,
|
|
153
|
+
activePanelId: activePanel,
|
|
154
|
+
shouldFocus,
|
|
155
|
+
setShouldFocus,
|
|
156
|
+
panels,
|
|
157
|
+
} = useSafeContext(PanelsWrapperContext);
|
|
158
|
+
let { id: panelId } = useSafeContext(PanelContext);
|
|
159
|
+
let fallbackId = React.useId();
|
|
160
|
+
let triggerId = children.props.id || fallbackId;
|
|
161
|
+
let onClick = React.useCallback(() => {
|
|
162
|
+
if (null == activePanel) return;
|
|
163
|
+
setShouldFocus({
|
|
164
|
+
fromPanelId: activePanel,
|
|
165
|
+
toPanelId: forProp,
|
|
166
|
+
direction: 'forward',
|
|
167
|
+
});
|
|
168
|
+
changeActivePanel?.(forProp);
|
|
169
|
+
}, [activePanel, changeActivePanel, forProp, setShouldFocus]);
|
|
170
|
+
let focusRef = React.useCallback(
|
|
171
|
+
(el) => {
|
|
172
|
+
if (
|
|
173
|
+
shouldFocus?.direction === 'backward' &&
|
|
174
|
+
shouldFocus?.toPanelId === panelId &&
|
|
175
|
+
shouldFocus?.fromPanelId === forProp
|
|
176
|
+
) {
|
|
177
|
+
el?.focus({
|
|
178
|
+
preventScroll: true,
|
|
179
|
+
});
|
|
180
|
+
setShouldFocus(void 0);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
[forProp, panelId, setShouldFocus, shouldFocus],
|
|
184
|
+
);
|
|
185
|
+
let logWarning = useWarningLogger();
|
|
186
|
+
React.useEffect(() => {
|
|
187
|
+
if (!panels.current.has(forProp))
|
|
188
|
+
logWarning(
|
|
189
|
+
`Panels.Trigger's \`for\` prop ("${forProp}") corresponds to no Panel.`,
|
|
190
|
+
);
|
|
191
|
+
}, [forProp, logWarning, panels, triggers]);
|
|
192
|
+
React.useEffect(() => {
|
|
193
|
+
setTriggers((oldTriggers) => {
|
|
194
|
+
let triggersMatch = oldTriggers[forProp];
|
|
195
|
+
if (
|
|
196
|
+
null == triggersMatch ||
|
|
197
|
+
panelId !== triggersMatch.panelId ||
|
|
198
|
+
triggerId !== triggersMatch.triggerId
|
|
199
|
+
)
|
|
200
|
+
return {
|
|
201
|
+
...oldTriggers,
|
|
202
|
+
[forProp]: {
|
|
203
|
+
panelId,
|
|
204
|
+
triggerId,
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
return oldTriggers;
|
|
208
|
+
});
|
|
209
|
+
}, [forProp, panelId, setTriggers, triggerId]);
|
|
210
|
+
return cloneElementWithRef(children, (children) => ({
|
|
211
|
+
...children.props,
|
|
212
|
+
id: triggerId,
|
|
213
|
+
ref: focusRef,
|
|
214
|
+
onClick: mergeEventHandlers(children.props.onClick, onClick),
|
|
215
|
+
'aria-expanded': activePanel === forProp,
|
|
216
|
+
'aria-controls': forProp,
|
|
217
|
+
}));
|
|
218
|
+
};
|
|
219
|
+
PanelTrigger.displayName = 'Panels.Trigger';
|
|
220
|
+
let PanelHeader = React.forwardRef((props, forwardedRef) => {
|
|
221
|
+
let { titleProps, children, ...rest } = props;
|
|
222
|
+
let { shouldFocus, setShouldFocus } = useSafeContext(PanelsWrapperContext);
|
|
223
|
+
let { id: panelId, associatedTrigger: panelAssociatedTrigger } =
|
|
224
|
+
useSafeContext(PanelContext);
|
|
225
|
+
let focusRef = React.useCallback(
|
|
226
|
+
(el) => {
|
|
227
|
+
if (
|
|
228
|
+
shouldFocus?.direction === 'forward' &&
|
|
229
|
+
shouldFocus.toPanelId === panelId
|
|
230
|
+
) {
|
|
231
|
+
el?.focus({
|
|
232
|
+
preventScroll: true,
|
|
233
|
+
});
|
|
234
|
+
setShouldFocus(void 0);
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
[panelId, setShouldFocus, shouldFocus?.direction, shouldFocus?.toPanelId],
|
|
238
|
+
);
|
|
239
|
+
return React.createElement(
|
|
240
|
+
Flex,
|
|
241
|
+
{
|
|
242
|
+
ref: forwardedRef,
|
|
243
|
+
...rest,
|
|
244
|
+
},
|
|
245
|
+
panelAssociatedTrigger && React.createElement(PanelBackButton, null),
|
|
246
|
+
React.createElement(
|
|
247
|
+
Text,
|
|
248
|
+
{
|
|
249
|
+
id: `${panelId}-header-title`,
|
|
250
|
+
as: 'h2',
|
|
251
|
+
tabIndex: -1,
|
|
252
|
+
ref: focusRef,
|
|
253
|
+
...titleProps,
|
|
254
|
+
},
|
|
255
|
+
children,
|
|
256
|
+
),
|
|
257
|
+
);
|
|
258
|
+
});
|
|
259
|
+
PanelHeader.displayName = 'Panels.Header';
|
|
260
|
+
let PanelBackButton = React.forwardRef((props, forwardedRef) => {
|
|
261
|
+
let { children, onClick, ...rest } = props;
|
|
262
|
+
let { instance: panelInstance } = useSafeContext(PanelsInstanceContext);
|
|
263
|
+
return React.createElement(
|
|
264
|
+
IconButton,
|
|
265
|
+
{
|
|
266
|
+
ref: forwardedRef,
|
|
267
|
+
'aria-label': 'Previous panel',
|
|
268
|
+
styleType: 'borderless',
|
|
269
|
+
size: 'small',
|
|
270
|
+
'data-iui-shift': 'left',
|
|
271
|
+
...rest,
|
|
272
|
+
onClick: mergeEventHandlers(
|
|
273
|
+
React.useCallback(() => panelInstance?.goBack(), [panelInstance]),
|
|
274
|
+
onClick,
|
|
275
|
+
),
|
|
276
|
+
},
|
|
277
|
+
children || React.createElement(SvgChevronLeft, null),
|
|
278
|
+
);
|
|
279
|
+
});
|
|
280
|
+
PanelBackButton.displayName = 'Panels.BackButton';
|
|
281
|
+
export const Panels = {
|
|
282
|
+
Wrapper: PanelsWrapper,
|
|
283
|
+
Panel,
|
|
284
|
+
Trigger: PanelTrigger,
|
|
285
|
+
Header: PanelHeader,
|
|
286
|
+
useInstance: useInstance,
|
|
287
|
+
};
|
|
288
|
+
function useDelayed(
|
|
289
|
+
value,
|
|
290
|
+
{ delay } = {
|
|
291
|
+
delay: 500,
|
|
292
|
+
},
|
|
293
|
+
) {
|
|
294
|
+
let [delayed, setDelayed] = React.useState(void 0);
|
|
295
|
+
let timeout = React.useRef(void 0);
|
|
296
|
+
React.useEffect(() => {
|
|
297
|
+
if (0 === delay) setDelayed(value);
|
|
298
|
+
else timeout.current = setTimeout(() => setDelayed(value), delay);
|
|
299
|
+
return () => {
|
|
300
|
+
clearTimeout(timeout.current);
|
|
301
|
+
};
|
|
302
|
+
}, [value, delay]);
|
|
303
|
+
return delayed;
|
|
304
|
+
}
|
|
@@ -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 &&
|
|
@@ -53,7 +53,7 @@ let singleRowSelectedAction = 'singleRowSelected';
|
|
|
53
53
|
let shiftRowSelectedAction = 'shiftRowSelected';
|
|
54
54
|
export const tableResizeStartAction = 'tableResizeStart';
|
|
55
55
|
let tableResizeEndAction = 'tableResizeEnd';
|
|
56
|
-
|
|
56
|
+
export const iuiId = Symbol('iui-id');
|
|
57
57
|
let flattenColumns = (columns) => {
|
|
58
58
|
let flatColumns = [];
|
|
59
59
|
columns.forEach((column) => {
|
|
@@ -665,11 +665,7 @@ export const Table = (props) => {
|
|
|
665
665
|
},
|
|
666
666
|
bodyProps?.className,
|
|
667
667
|
),
|
|
668
|
-
style: {
|
|
669
|
-
outline: 0,
|
|
670
|
-
},
|
|
671
668
|
}),
|
|
672
|
-
tabIndex: -1,
|
|
673
669
|
'aria-multiselectable':
|
|
674
670
|
(isSelectable && 'multi' === selectionMode) || void 0,
|
|
675
671
|
},
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
SvgChevronRight,
|
|
14
14
|
Box,
|
|
15
15
|
OverflowContainer,
|
|
16
|
+
useLayoutEffect,
|
|
16
17
|
} from '../../utils/index.js';
|
|
17
18
|
import { styles } from '../../styles.js';
|
|
18
19
|
let defaultLocalization = {
|
|
@@ -56,7 +57,7 @@ export const TablePaginator = (props) => {
|
|
|
56
57
|
);
|
|
57
58
|
let pageListRef = React.useRef(null);
|
|
58
59
|
let [focusedIndex, setFocusedIndex] = React.useState(currentPage);
|
|
59
|
-
|
|
60
|
+
useLayoutEffect(() => {
|
|
60
61
|
setFocusedIndex(currentPage);
|
|
61
62
|
}, [currentPage]);
|
|
62
63
|
let needFocus = React.useRef(false);
|
|
@@ -178,6 +179,7 @@ export const TablePaginator = (props) => {
|
|
|
178
179
|
: React.createElement(TablePaginatorPageButtons, {
|
|
179
180
|
size: size,
|
|
180
181
|
focusedIndex: focusedIndex,
|
|
182
|
+
setFocusedIndex: setFocusedIndex,
|
|
181
183
|
totalPagesCount: totalPagesCount,
|
|
182
184
|
onPageChange: onPageChange,
|
|
183
185
|
currentPage: currentPage,
|
|
@@ -251,6 +253,7 @@ export const TablePaginator = (props) => {
|
|
|
251
253
|
let TablePaginatorPageButtons = (props) => {
|
|
252
254
|
let {
|
|
253
255
|
focusedIndex,
|
|
256
|
+
setFocusedIndex,
|
|
254
257
|
totalPagesCount,
|
|
255
258
|
onPageChange,
|
|
256
259
|
currentPage,
|
|
@@ -270,14 +273,24 @@ let TablePaginatorPageButtons = (props) => {
|
|
|
270
273
|
styleType: 'borderless',
|
|
271
274
|
size: buttonSize,
|
|
272
275
|
'data-iui-active': index === currentPage,
|
|
273
|
-
onClick: () =>
|
|
276
|
+
onClick: () => {
|
|
277
|
+
setFocusedIndex(index);
|
|
278
|
+
onPageChange(index);
|
|
279
|
+
},
|
|
274
280
|
'aria-current': index === currentPage,
|
|
275
281
|
'aria-label': localization.goToPageLabel?.(index + 1),
|
|
276
282
|
tabIndex: tabIndex,
|
|
277
283
|
},
|
|
278
284
|
index + 1,
|
|
279
285
|
),
|
|
280
|
-
[
|
|
286
|
+
[
|
|
287
|
+
focusedIndex,
|
|
288
|
+
buttonSize,
|
|
289
|
+
currentPage,
|
|
290
|
+
localization,
|
|
291
|
+
setFocusedIndex,
|
|
292
|
+
onPageChange,
|
|
293
|
+
],
|
|
281
294
|
);
|
|
282
295
|
let pageList = React.useMemo(
|
|
283
296
|
() =>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { iuiId } from '../Table.js';
|
|
1
2
|
let onSelectHandler = (newState, instance, onSelect, isRowDisabled) => {
|
|
2
3
|
if (!instance?.rows.length) {
|
|
3
4
|
onSelect?.([], newState);
|
|
@@ -7,14 +8,16 @@ let onSelectHandler = (newState, instance, onSelect, isRowDisabled) => {
|
|
|
7
8
|
let handleRow = (row) => {
|
|
8
9
|
if (isRowDisabled?.(row.original)) return false;
|
|
9
10
|
let isAllSubSelected = true;
|
|
10
|
-
row.initialSubRows
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
if (row.initialSubRows[0]?.original[iuiId] === void 0)
|
|
12
|
+
row.initialSubRows.forEach((subRow) => {
|
|
13
|
+
let result = handleRow(subRow);
|
|
14
|
+
if (!result) isAllSubSelected = false;
|
|
15
|
+
});
|
|
14
16
|
if (
|
|
15
|
-
|
|
16
|
-
(!
|
|
17
|
-
|
|
17
|
+
newState.selectedRowIds[row.id] &&
|
|
18
|
+
(!instance.selectSubRows ||
|
|
19
|
+
!row.initialSubRows.length ||
|
|
20
|
+
isAllSubSelected)
|
|
18
21
|
)
|
|
19
22
|
newSelectedRowIds[row.id] = true;
|
|
20
23
|
return !!newSelectedRowIds[row.id];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Checkbox } from '../../Checkbox/Checkbox.js';
|
|
3
3
|
import { DefaultCell } from '../cells/index.js';
|
|
4
|
+
import { iuiId } from '../Table.js';
|
|
4
5
|
export const SELECTION_CELL_ID = 'iui-table-checkbox-selector';
|
|
5
6
|
export const SelectionColumn = (props = {}) => {
|
|
6
7
|
let { isDisabled, density } = props;
|
|
@@ -50,7 +51,11 @@ export const SelectionColumn = (props = {}) => {
|
|
|
50
51
|
disabled: isDisabled?.(row.original),
|
|
51
52
|
onClick: (e) => e.stopPropagation(),
|
|
52
53
|
onChange: () => {
|
|
53
|
-
if (
|
|
54
|
+
if (
|
|
55
|
+
row.subRows.length > 0 &&
|
|
56
|
+
selectSubRows &&
|
|
57
|
+
void 0 === row.initialSubRows[0].original[iuiId]
|
|
58
|
+
)
|
|
54
59
|
row.toggleRowSelected(
|
|
55
60
|
!row.subRows.every(
|
|
56
61
|
(subRow) => subRow.isSelected || isDisabled?.(subRow.original),
|
package/DEV-esm/index.js
CHANGED
|
@@ -64,6 +64,7 @@ export { ModalContent } from './core/Modal/ModalContent.js';
|
|
|
64
64
|
export { ModalButtonBar } from './core/Modal/ModalButtonBar.js';
|
|
65
65
|
export { NotificationMarker } from './core/NotificationMarker/NotificationMarker.js';
|
|
66
66
|
export { Overlay } from './core/Overlay/Overlay.js';
|
|
67
|
+
export { Panels as unstable_Panels } from './core/Panels/Panels.js';
|
|
67
68
|
export { ProgressLinear } from './core/ProgressIndicators/ProgressLinear.js';
|
|
68
69
|
export { ProgressRadial } from './core/ProgressIndicators/ProgressRadial.js';
|
|
69
70
|
export { Radio } from './core/Radio/Radio.js';
|
package/DEV-esm/styles.js
CHANGED