@itwin/itwinui-react 3.0.0-dev.1 → 3.0.0-dev.2
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 +18 -0
- package/cjs/core/Alert/Alert.d.ts +47 -28
- package/cjs/core/Alert/Alert.js +73 -21
- package/cjs/core/Avatar/Avatar.js +1 -1
- package/cjs/core/AvatarGroup/AvatarGroup.js +1 -1
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -3
- package/cjs/core/ButtonGroup/ButtonGroup.js +1 -4
- package/cjs/core/Buttons/DropdownButton/DropdownButton.js +3 -5
- package/cjs/core/Carousel/Carousel.d.ts +2 -2
- package/cjs/core/Carousel/Carousel.js +3 -5
- package/cjs/core/Carousel/CarouselDotsList.js +8 -10
- package/cjs/core/Carousel/CarouselNavigation.d.ts +2 -2
- package/cjs/core/Carousel/CarouselNavigation.js +3 -5
- package/cjs/core/Carousel/CarouselSlider.js +10 -15
- package/cjs/core/ColorPicker/ColorBuilder.js +7 -10
- package/cjs/core/ColorPicker/ColorInputPanel.js +12 -15
- package/cjs/core/ColorPicker/ColorPalette.js +4 -6
- package/cjs/core/ColorPicker/ColorPicker.js +3 -3
- package/cjs/core/ComboBox/ComboBox.js +25 -32
- package/cjs/core/ComboBox/ComboBoxDropdown.js +1 -2
- package/cjs/core/ComboBox/ComboBoxEndIcon.js +1 -1
- package/cjs/core/ComboBox/ComboBoxInput.js +21 -20
- package/cjs/core/ComboBox/ComboBoxMenu.js +3 -4
- package/cjs/core/ComboBox/ComboBoxMenuItem.js +2 -2
- package/cjs/core/ComboBox/helpers.js +4 -5
- package/cjs/core/DatePicker/DatePicker.js +32 -32
- package/cjs/core/Dialog/Dialog.js +11 -4
- package/cjs/core/Dialog/DialogBackdrop.js +1 -1
- package/cjs/core/Dialog/DialogContext.d.ts +11 -0
- package/cjs/core/Dialog/DialogMain.js +16 -22
- package/cjs/core/DropdownMenu/DropdownMenu.js +6 -8
- package/cjs/core/ExpandableBlock/ExpandableBlock.js +2 -2
- package/cjs/core/FileUpload/FileEmptyCard.js +1 -1
- package/cjs/core/FileUpload/FileUpload.js +3 -6
- package/cjs/core/FileUpload/FileUploadCard.js +9 -10
- package/cjs/core/InformationPanel/InformationPanel.js +1 -4
- package/cjs/core/LabeledInput/LabeledInput.js +1 -1
- package/cjs/core/LabeledTextarea/LabeledTextarea.js +1 -1
- package/cjs/core/Menu/Menu.js +3 -4
- package/cjs/core/Menu/MenuItem.js +8 -11
- package/cjs/core/Modal/Modal.d.ts +8 -9
- package/cjs/core/Modal/Modal.js +7 -17
- package/cjs/core/SearchBox/SearchBox.js +12 -12
- package/cjs/core/Select/Select.js +12 -17
- package/cjs/core/SideNavigation/SideNavigation.js +2 -2
- package/cjs/core/Slider/Slider.js +16 -19
- package/cjs/core/Slider/Thumb.js +1 -1
- package/cjs/core/StatusMessage/StatusMessage.js +1 -1
- package/cjs/core/Stepper/Stepper.js +1 -1
- package/cjs/core/Stepper/StepperStep.js +1 -1
- package/cjs/core/Table/Table.js +15 -15
- package/cjs/core/Table/TablePaginator.js +2 -3
- package/cjs/core/Table/TableRowMemoized.js +38 -45
- package/cjs/core/Table/actionHandlers/expandHandler.js +3 -3
- package/cjs/core/Table/actionHandlers/filterHandler.js +4 -5
- package/cjs/core/Table/actionHandlers/selectHandler.js +6 -6
- package/cjs/core/Table/cells/DefaultCell.js +1 -1
- package/cjs/core/Table/cells/EditableCell.js +6 -12
- package/cjs/core/Table/columns/actionColumn.js +3 -6
- package/cjs/core/Table/columns/expanderColumn.js +3 -3
- package/cjs/core/Table/columns/selectionColumn.js +4 -4
- package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +2 -4
- package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -3
- package/cjs/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +2 -3
- package/cjs/core/Table/filters/TextFilter/TextFilter.js +1 -2
- package/cjs/core/Table/hooks/useResizeColumns.js +16 -22
- package/cjs/core/Table/hooks/useScrollToRow.js +1 -2
- package/cjs/core/Table/hooks/useStickyColumns.js +3 -5
- package/cjs/core/Table/hooks/useSubRowFiltering.js +2 -4
- package/cjs/core/Tabs/Tabs.js +13 -16
- package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -1
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +2 -3
- package/cjs/core/ThemeProvider/ThemeProvider.js +11 -13
- package/cjs/core/Tile/Tile.js +2 -3
- package/cjs/core/TimePicker/TimePicker.js +13 -13
- package/cjs/core/Toast/Toast.js +2 -3
- package/cjs/core/Toast/Toaster.js +6 -11
- package/cjs/core/TransferList/TransferList.js +3 -4
- package/cjs/core/Tree/Tree.js +9 -13
- package/cjs/core/Tree/TreeNode.js +9 -10
- package/cjs/core/utils/color/ColorValue.js +9 -15
- package/cjs/core/utils/components/AutoclearingHiddenLiveRegion.js +2 -3
- package/cjs/core/utils/components/FocusTrap.js +4 -4
- package/cjs/core/utils/components/MiddleTextTruncation.js +1 -2
- package/cjs/core/utils/components/Popover.js +5 -8
- package/cjs/core/utils/components/Resizer.js +7 -6
- package/cjs/core/utils/components/VirtualScroll.js +14 -21
- package/cjs/core/utils/functions/dom.js +5 -5
- package/cjs/core/utils/functions/polymorphic.js +1 -1
- package/cjs/core/utils/functions/supports.js +1 -1
- package/cjs/core/utils/hooks/index.d.ts +0 -1
- package/cjs/core/utils/hooks/index.js +0 -1
- package/cjs/core/utils/hooks/useContainerWidth.js +1 -1
- package/cjs/core/utils/hooks/useDragAndDrop.js +8 -10
- package/cjs/core/utils/hooks/useEventListener.js +1 -1
- package/cjs/core/utils/hooks/useGlobals.d.ts +9 -2
- package/cjs/core/utils/hooks/useGlobals.js +6 -4
- package/cjs/core/utils/hooks/useId.js +1 -2
- package/cjs/core/utils/hooks/useIntersection.js +2 -3
- package/cjs/core/utils/hooks/useMediaQuery.js +6 -8
- package/cjs/core/utils/hooks/useOverflow.js +1 -2
- package/cjs/core/utils/hooks/useResizeObserver.js +3 -4
- package/cjs/styles.js +1 -4
- package/esm/core/Alert/Alert.d.ts +47 -28
- package/esm/core/Alert/Alert.js +74 -22
- package/esm/core/Avatar/Avatar.js +1 -1
- package/esm/core/AvatarGroup/AvatarGroup.js +1 -1
- package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -3
- package/esm/core/ButtonGroup/ButtonGroup.js +1 -4
- package/esm/core/Buttons/DropdownButton/DropdownButton.js +3 -5
- package/esm/core/Carousel/Carousel.d.ts +2 -2
- package/esm/core/Carousel/Carousel.js +3 -5
- package/esm/core/Carousel/CarouselDotsList.js +8 -10
- package/esm/core/Carousel/CarouselNavigation.d.ts +2 -2
- package/esm/core/Carousel/CarouselNavigation.js +3 -5
- package/esm/core/Carousel/CarouselSlider.js +10 -15
- package/esm/core/ColorPicker/ColorBuilder.js +7 -10
- package/esm/core/ColorPicker/ColorInputPanel.js +12 -15
- package/esm/core/ColorPicker/ColorPalette.js +4 -6
- package/esm/core/ColorPicker/ColorPicker.js +3 -3
- package/esm/core/ComboBox/ComboBox.js +25 -32
- package/esm/core/ComboBox/ComboBoxDropdown.js +1 -2
- package/esm/core/ComboBox/ComboBoxEndIcon.js +1 -1
- package/esm/core/ComboBox/ComboBoxInput.js +21 -20
- package/esm/core/ComboBox/ComboBoxMenu.js +3 -4
- package/esm/core/ComboBox/ComboBoxMenuItem.js +2 -2
- package/esm/core/ComboBox/helpers.js +4 -5
- package/esm/core/DatePicker/DatePicker.js +32 -32
- package/esm/core/Dialog/Dialog.js +12 -5
- package/esm/core/Dialog/DialogBackdrop.js +1 -1
- package/esm/core/Dialog/DialogContext.d.ts +11 -0
- package/esm/core/Dialog/DialogMain.js +16 -22
- package/esm/core/DropdownMenu/DropdownMenu.js +6 -8
- package/esm/core/ExpandableBlock/ExpandableBlock.js +2 -2
- package/esm/core/FileUpload/FileEmptyCard.js +1 -1
- package/esm/core/FileUpload/FileUpload.js +3 -6
- package/esm/core/FileUpload/FileUploadCard.js +9 -10
- package/esm/core/InformationPanel/InformationPanel.js +1 -4
- package/esm/core/LabeledInput/LabeledInput.js +1 -1
- package/esm/core/LabeledTextarea/LabeledTextarea.js +1 -1
- package/esm/core/Menu/Menu.js +3 -4
- package/esm/core/Menu/MenuItem.js +8 -11
- package/esm/core/Modal/Modal.d.ts +8 -9
- package/esm/core/Modal/Modal.js +3 -10
- package/esm/core/SearchBox/SearchBox.js +12 -12
- package/esm/core/Select/Select.js +12 -17
- package/esm/core/SideNavigation/SideNavigation.js +2 -2
- package/esm/core/Slider/Slider.js +16 -19
- package/esm/core/Slider/Thumb.js +1 -1
- package/esm/core/StatusMessage/StatusMessage.js +1 -1
- package/esm/core/Stepper/Stepper.js +1 -1
- package/esm/core/Stepper/StepperStep.js +1 -1
- package/esm/core/Table/Table.js +15 -15
- package/esm/core/Table/TablePaginator.js +2 -3
- package/esm/core/Table/TableRowMemoized.js +38 -45
- package/esm/core/Table/actionHandlers/expandHandler.js +3 -3
- package/esm/core/Table/actionHandlers/filterHandler.js +4 -5
- package/esm/core/Table/actionHandlers/selectHandler.js +6 -6
- package/esm/core/Table/cells/DefaultCell.js +1 -1
- package/esm/core/Table/cells/EditableCell.js +6 -12
- package/esm/core/Table/columns/actionColumn.js +3 -6
- package/esm/core/Table/columns/expanderColumn.js +3 -3
- package/esm/core/Table/columns/selectionColumn.js +4 -4
- package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +2 -4
- package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -3
- package/esm/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +2 -3
- package/esm/core/Table/filters/TextFilter/TextFilter.js +1 -2
- package/esm/core/Table/hooks/useResizeColumns.js +16 -22
- package/esm/core/Table/hooks/useScrollToRow.js +1 -2
- package/esm/core/Table/hooks/useStickyColumns.js +3 -5
- package/esm/core/Table/hooks/useSubRowFiltering.js +2 -4
- package/esm/core/Tabs/Tabs.js +13 -16
- package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -1
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +2 -3
- package/esm/core/ThemeProvider/ThemeProvider.js +12 -14
- package/esm/core/Tile/Tile.js +2 -3
- package/esm/core/TimePicker/TimePicker.js +13 -13
- package/esm/core/Toast/Toast.js +2 -3
- package/esm/core/Toast/Toaster.js +6 -11
- package/esm/core/TransferList/TransferList.js +3 -4
- package/esm/core/Tree/Tree.js +9 -13
- package/esm/core/Tree/TreeNode.js +9 -10
- package/esm/core/utils/color/ColorValue.js +9 -15
- package/esm/core/utils/components/AutoclearingHiddenLiveRegion.js +2 -3
- package/esm/core/utils/components/FocusTrap.js +4 -4
- package/esm/core/utils/components/MiddleTextTruncation.js +1 -2
- package/esm/core/utils/components/Popover.js +5 -8
- package/esm/core/utils/components/Resizer.js +7 -6
- package/esm/core/utils/components/VirtualScroll.js +14 -21
- package/esm/core/utils/functions/dom.js +5 -5
- package/esm/core/utils/functions/polymorphic.js +1 -1
- package/esm/core/utils/functions/supports.js +1 -1
- package/esm/core/utils/hooks/index.d.ts +0 -1
- package/esm/core/utils/hooks/index.js +0 -1
- package/esm/core/utils/hooks/useContainerWidth.js +1 -1
- package/esm/core/utils/hooks/useDragAndDrop.js +8 -10
- package/esm/core/utils/hooks/useEventListener.js +1 -1
- package/esm/core/utils/hooks/useGlobals.d.ts +9 -2
- package/esm/core/utils/hooks/useGlobals.js +6 -4
- package/esm/core/utils/hooks/useId.js +1 -2
- package/esm/core/utils/hooks/useIntersection.js +2 -3
- package/esm/core/utils/hooks/useMediaQuery.js +6 -8
- package/esm/core/utils/hooks/useOverflow.js +1 -2
- package/esm/core/utils/hooks/useResizeObserver.js +3 -4
- package/esm/styles.js +1 -4
- package/package.json +2 -2
- package/styles.css +18 -20
- package/cjs/core/utils/hooks/useIsThemeAlreadySet.d.ts +0 -7
- package/cjs/core/utils/hooks/useIsThemeAlreadySet.js +0 -54
- package/esm/core/utils/hooks/useIsThemeAlreadySet.d.ts +0 -7
- package/esm/core/utils/hooks/useIsThemeAlreadySet.js +0 -27
package/cjs/core/Tabs/Tabs.js
CHANGED
|
@@ -115,22 +115,20 @@ const Tabs = (props) => {
|
|
|
115
115
|
React.useEffect(() => {
|
|
116
116
|
if (tablistRef.current && focusedIndex !== undefined) {
|
|
117
117
|
const tab = tablistRef.current.querySelectorAll(`.${styles_js_1.default['iui-tab']}`)[focusedIndex];
|
|
118
|
-
tab
|
|
118
|
+
tab?.focus();
|
|
119
119
|
}
|
|
120
120
|
}, [focusedIndex]);
|
|
121
121
|
const [hasSublabel, setHasSublabel] = React.useState(false); // used for setting size
|
|
122
122
|
(0, index_js_1.useIsomorphicLayoutEffect)(() => {
|
|
123
|
-
var _a;
|
|
124
123
|
setHasSublabel(type !== 'pill' && // pill tabs should never have sublabels
|
|
125
|
-
!!
|
|
124
|
+
!!tablistRef.current?.querySelector(`.${styles_js_1.default['iui-tab-description']}`));
|
|
126
125
|
}, [type]);
|
|
127
126
|
const enableHorizontalScroll = React.useCallback((e) => {
|
|
128
|
-
var _a;
|
|
129
127
|
const ownerDoc = tablistRef.current;
|
|
130
128
|
if (ownerDoc === null) {
|
|
131
129
|
return;
|
|
132
130
|
}
|
|
133
|
-
let scrollLeft =
|
|
131
|
+
let scrollLeft = ownerDoc?.scrollLeft ?? 0;
|
|
134
132
|
if (e.deltaY > 0 || e.deltaX > 0) {
|
|
135
133
|
scrollLeft += 25;
|
|
136
134
|
}
|
|
@@ -145,12 +143,12 @@ const Tabs = (props) => {
|
|
|
145
143
|
if (ownerDoc === null) {
|
|
146
144
|
return;
|
|
147
145
|
}
|
|
148
|
-
if (!
|
|
146
|
+
if (!overflowOptions?.useOverflow || orientation === 'vertical') {
|
|
149
147
|
ownerDoc.removeEventListener('wheel', enableHorizontalScroll);
|
|
150
148
|
return;
|
|
151
149
|
}
|
|
152
150
|
ownerDoc.addEventListener('wheel', enableHorizontalScroll);
|
|
153
|
-
}, [overflowOptions
|
|
151
|
+
}, [overflowOptions?.useOverflow, orientation, enableHorizontalScroll]);
|
|
154
152
|
const isTabHidden = (activeTab, isVertical) => {
|
|
155
153
|
const ownerDoc = tablistRef.current;
|
|
156
154
|
if (ownerDoc === null) {
|
|
@@ -230,7 +228,7 @@ const Tabs = (props) => {
|
|
|
230
228
|
setTimeout(() => {
|
|
231
229
|
const ownerDoc = tablistRef.current;
|
|
232
230
|
if (ownerDoc !== null &&
|
|
233
|
-
|
|
231
|
+
overflowOptions?.useOverflow &&
|
|
234
232
|
currentActiveIndex !== undefined) {
|
|
235
233
|
const activeTab = ownerDoc.querySelectorAll(`.${styles_js_1.default['iui-tab']}`)[currentActiveIndex];
|
|
236
234
|
const isVertical = orientation === 'vertical';
|
|
@@ -241,7 +239,7 @@ const Tabs = (props) => {
|
|
|
241
239
|
}
|
|
242
240
|
}, 50);
|
|
243
241
|
}, [
|
|
244
|
-
overflowOptions
|
|
242
|
+
overflowOptions?.useOverflow,
|
|
245
243
|
currentActiveIndex,
|
|
246
244
|
focusedIndex,
|
|
247
245
|
orientation,
|
|
@@ -277,19 +275,19 @@ const Tabs = (props) => {
|
|
|
277
275
|
}, [orientation, setScrollingPlacement]);
|
|
278
276
|
// apply correct mask when tabs list is resized
|
|
279
277
|
const [resizeRef] = (0, index_js_1.useResizeObserver)(determineScrollingPlacement);
|
|
280
|
-
resizeRef(tablistRef
|
|
278
|
+
resizeRef(tablistRef?.current);
|
|
281
279
|
// check if overflow tabs are scrolled to far edges
|
|
282
280
|
React.useEffect(() => {
|
|
283
281
|
const ownerDoc = tablistRef.current;
|
|
284
282
|
if (ownerDoc === null) {
|
|
285
283
|
return;
|
|
286
284
|
}
|
|
287
|
-
if (!
|
|
285
|
+
if (!overflowOptions?.useOverflow) {
|
|
288
286
|
ownerDoc.removeEventListener('scroll', determineScrollingPlacement);
|
|
289
287
|
return;
|
|
290
288
|
}
|
|
291
289
|
ownerDoc.addEventListener('scroll', determineScrollingPlacement);
|
|
292
|
-
}, [overflowOptions
|
|
290
|
+
}, [overflowOptions?.useOverflow, determineScrollingPlacement]);
|
|
293
291
|
const onTabClick = React.useCallback((index) => {
|
|
294
292
|
if (onTabSelected) {
|
|
295
293
|
onTabSelected(index);
|
|
@@ -305,7 +303,7 @@ const Tabs = (props) => {
|
|
|
305
303
|
const tab = labels[index];
|
|
306
304
|
return React.isValidElement(tab) && tab.props.disabled;
|
|
307
305
|
};
|
|
308
|
-
let newIndex = focusedIndex
|
|
306
|
+
let newIndex = focusedIndex ?? currentActiveIndex;
|
|
309
307
|
/** focus next tab if delta is +1, previous tab if -1 */
|
|
310
308
|
const focusTab = (delta = +1) => {
|
|
311
309
|
do {
|
|
@@ -368,9 +366,8 @@ const Tabs = (props) => {
|
|
|
368
366
|
'aria-selected': index === currentActiveIndex,
|
|
369
367
|
tabIndex: index === currentActiveIndex ? 0 : -1,
|
|
370
368
|
onClick: (args) => {
|
|
371
|
-
var _a, _b;
|
|
372
369
|
onClick();
|
|
373
|
-
|
|
370
|
+
label.props.onClick?.(args);
|
|
374
371
|
},
|
|
375
372
|
}))));
|
|
376
373
|
}, [currentActiveIndex, onTabClick]);
|
|
@@ -380,7 +377,7 @@ const Tabs = (props) => {
|
|
|
380
377
|
'iui-animated': type !== 'default' && isClient,
|
|
381
378
|
'iui-not-animated': type !== 'default' && !isClient,
|
|
382
379
|
'iui-large': hasSublabel,
|
|
383
|
-
}, tabsClassName), "data-iui-overflow": overflowOptions
|
|
380
|
+
}, tabsClassName), "data-iui-overflow": overflowOptions?.useOverflow, "data-iui-scroll-placement": scrollingPlacement, role: 'tablist', ref: refs, onKeyDown: onKeyDown, ...rest }, labels.map((label, index) => createTab(label, index))),
|
|
384
381
|
actions && (React.createElement(index_js_1.Box, { className: 'iui-tabs-actions-wrapper' },
|
|
385
382
|
React.createElement(index_js_1.Box, { className: 'iui-tabs-actions' }, actions))),
|
|
386
383
|
children && (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-tabs-content', contentClassName), role: 'tabpanel' }, children))));
|
|
@@ -3,5 +3,5 @@ import type { ThemeOptions, ThemeType } from './ThemeProvider.js';
|
|
|
3
3
|
export declare const ThemeContext: React.Context<{
|
|
4
4
|
theme?: ThemeType | undefined;
|
|
5
5
|
themeOptions?: ThemeOptions | undefined;
|
|
6
|
-
|
|
6
|
+
portalContainerRef?: React.RefObject<HTMLElement> | undefined;
|
|
7
7
|
} | undefined>;
|
|
@@ -37,10 +37,9 @@ declare type RootProps = {
|
|
|
37
37
|
applyBackground?: boolean;
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
41
|
-
* This will be used to determine if applyBackground will default to false.
|
|
40
|
+
* This will be used to determine if background will be applied.
|
|
42
41
|
*/
|
|
43
|
-
|
|
42
|
+
shouldApplyBackground?: boolean;
|
|
44
43
|
};
|
|
45
44
|
declare type ThemeProviderOwnProps = Pick<RootProps, 'theme'> & {
|
|
46
45
|
themeOptions?: RootProps['themeOptions'];
|
|
@@ -62,28 +62,26 @@ const ThemeContext_js_1 = require("./ThemeContext.js");
|
|
|
62
62
|
* </ThemeProvider>
|
|
63
63
|
*/
|
|
64
64
|
exports.ThemeProvider = React.forwardRef((props, ref) => {
|
|
65
|
-
var _a;
|
|
66
65
|
const { theme: themeProp, children, themeOptions, ...rest } = props;
|
|
67
|
-
const
|
|
68
|
-
const mergedRefs = (0, index_js_1.useMergedRefs)(rootRef, ref);
|
|
66
|
+
const portalContainerRef = React.useRef(null);
|
|
69
67
|
const parentContext = React.useContext(ThemeContext_js_1.ThemeContext);
|
|
70
|
-
const theme = themeProp === 'inherit' ?
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
const theme = themeProp === 'inherit' ? parentContext?.theme ?? 'light' : themeProp;
|
|
69
|
+
const shouldApplyBackground = themeOptions?.applyBackground ??
|
|
70
|
+
(themeProp === 'inherit' ? false : !parentContext);
|
|
71
|
+
const contextValue = React.useMemo(() => ({ theme, themeOptions, portalContainerRef }), [theme, themeOptions]);
|
|
72
|
+
return (React.createElement(ThemeContext_js_1.ThemeContext.Provider, { value: contextValue },
|
|
73
|
+
React.createElement(Root, { theme: theme, shouldApplyBackground: shouldApplyBackground, themeOptions: themeOptions, ref: ref, ...rest },
|
|
74
|
+
children,
|
|
75
|
+
React.createElement("div", { ref: portalContainerRef }))));
|
|
75
76
|
});
|
|
76
77
|
exports.default = exports.ThemeProvider;
|
|
77
78
|
const Root = React.forwardRef((props, forwardedRef) => {
|
|
78
|
-
|
|
79
|
-
const { theme, children, themeOptions, className, isInheritingTheme, ...rest } = props;
|
|
79
|
+
const { theme, children, themeOptions, shouldApplyBackground, className, ...rest } = props;
|
|
80
80
|
const ref = React.useRef(null);
|
|
81
81
|
const mergedRefs = (0, index_js_1.useMergedRefs)(ref, forwardedRef);
|
|
82
82
|
const prefersDark = (0, index_js_1.useMediaQuery)('(prefers-color-scheme: dark)');
|
|
83
83
|
const prefersHighContrast = (0, index_js_1.useMediaQuery)('(prefers-contrast: more)');
|
|
84
84
|
const shouldApplyDark = theme === 'dark' || (theme === 'os' && prefersDark);
|
|
85
|
-
const shouldApplyHC =
|
|
86
|
-
const isThemeAlreadySet = (0, index_js_1.useIsThemeAlreadySet)((_b = ref.current) === null || _b === void 0 ? void 0 : _b.ownerDocument);
|
|
87
|
-
const shouldApplyBackground = (_c = themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.applyBackground) !== null && _c !== void 0 ? _c : (isInheritingTheme ? false : !isThemeAlreadySet.current);
|
|
85
|
+
const shouldApplyHC = themeOptions?.highContrast ?? prefersHighContrast;
|
|
88
86
|
return (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-root', { 'iui-root-background': shouldApplyBackground }, className), "data-iui-theme": shouldApplyDark ? 'dark' : 'light', "data-iui-contrast": shouldApplyHC ? 'high' : 'default', ref: mergedRefs, ...rest }, children));
|
|
89
87
|
});
|
package/cjs/core/Tile/Tile.js
CHANGED
|
@@ -78,7 +78,7 @@ exports.Tile = Object.assign(React.forwardRef((props, forwardedRef) => {
|
|
|
78
78
|
const showMenu = React.useCallback(() => setIsMenuVisible(true), []);
|
|
79
79
|
const hideMenu = React.useCallback(() => setIsMenuVisible(false), []);
|
|
80
80
|
const [localActionable, setLocalActionable] = React.useState(isActionableProp);
|
|
81
|
-
const isActionable = isActionableProp
|
|
81
|
+
const isActionable = isActionableProp ?? localActionable;
|
|
82
82
|
const tileName = (React.createElement(index_js_1.Box, { className: 'iui-tile-name' },
|
|
83
83
|
React.createElement(TitleIcon, { isLoading: isLoading, isSelected: isSelected, isNew: isNew, status: status }),
|
|
84
84
|
React.createElement(index_js_1.Box, { as: 'span', className: 'iui-tile-name-label' }, isActionable && onClick ? (React.createElement(index_js_1.LinkAction, { as: 'button', onClick: !isDisabled ? onClick : undefined, "aria-disabled": isDisabled }, name)) : (name))));
|
|
@@ -113,9 +113,8 @@ exports.Tile = Object.assign(React.forwardRef((props, forwardedRef) => {
|
|
|
113
113
|
metadata != undefined && (React.createElement(index_js_1.Box, { className: 'iui-tile-metadata' }, metadata)),
|
|
114
114
|
moreOptions && (React.createElement(index_js_2.DropdownMenu, { onShow: showMenu, onHide: hideMenu, menuItems: (close) => moreOptions.map((option) => React.cloneElement(option, {
|
|
115
115
|
onClick: (value) => {
|
|
116
|
-
var _a, _b;
|
|
117
116
|
close();
|
|
118
|
-
|
|
117
|
+
option.props.onClick?.(value);
|
|
119
118
|
},
|
|
120
119
|
})) },
|
|
121
120
|
React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-tile-more-options', {
|
|
@@ -108,17 +108,17 @@ const defaultCombinedRenderer = (date, precision) => {
|
|
|
108
108
|
exports.TimePicker = React.forwardRef((props, forwardedRef) => {
|
|
109
109
|
const { date, onChange, use12Hours = false, precision = 'minutes', hourStep = 1, minuteStep = 1, secondStep = 1, setFocusHour = false, hourRenderer = (date) => date.getHours().toLocaleString(undefined, { minimumIntegerDigits: 2 }), minuteRenderer = (date) => date.getMinutes().toLocaleString(undefined, { minimumIntegerDigits: 2 }), secondRenderer = (date) => date.getSeconds().toLocaleString(undefined, { minimumIntegerDigits: 2 }), meridiemRenderer = (meridiem) => meridiem, useCombinedRenderer = false, combinedRenderer = defaultCombinedRenderer, className, ...rest } = props;
|
|
110
110
|
const [selectedTime, setSelectedTime] = React.useState(date);
|
|
111
|
-
const [focusedTime, setFocusedTime] = React.useState(selectedTime
|
|
112
|
-
const [meridiem, setMeridiem] = React.useState(use12Hours ? (
|
|
111
|
+
const [focusedTime, setFocusedTime] = React.useState(selectedTime ?? new Date());
|
|
112
|
+
const [meridiem, setMeridiem] = React.useState(use12Hours ? (focusedTime?.getHours() > 11 ? 'PM' : 'AM') : undefined);
|
|
113
113
|
React.useEffect(() => {
|
|
114
|
-
setFocusedTime(date
|
|
114
|
+
setFocusedTime(date ?? new Date());
|
|
115
115
|
setSelectedTime(date);
|
|
116
116
|
}, [date]);
|
|
117
117
|
const onHourClick = (date) => {
|
|
118
118
|
const adjustedHour = use12Hours
|
|
119
119
|
? formatHourFrom12(date.getHours(), meridiem)
|
|
120
120
|
: date.getHours();
|
|
121
|
-
const adjustedSelectedTime = setHours(adjustedHour, selectedTime
|
|
121
|
+
const adjustedSelectedTime = setHours(adjustedHour, selectedTime ?? new Date());
|
|
122
122
|
updateCurrentTime(adjustedSelectedTime);
|
|
123
123
|
};
|
|
124
124
|
const onTimeClick = (date) => {
|
|
@@ -129,7 +129,7 @@ exports.TimePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
129
129
|
updateCurrentTime(adjustedSelectedTime);
|
|
130
130
|
};
|
|
131
131
|
const onMeridiemClick = (value) => {
|
|
132
|
-
let adjustedSelectedTime = selectedTime
|
|
132
|
+
let adjustedSelectedTime = selectedTime ?? new Date();
|
|
133
133
|
const currentHours = adjustedSelectedTime.getHours();
|
|
134
134
|
setMeridiem(value);
|
|
135
135
|
if (value === 'AM' && currentHours > 11) {
|
|
@@ -151,7 +151,7 @@ exports.TimePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
151
151
|
}
|
|
152
152
|
setFocusedTime(adjustedTime);
|
|
153
153
|
setSelectedTime(adjustedTime);
|
|
154
|
-
onChange
|
|
154
|
+
onChange?.(adjustedTime);
|
|
155
155
|
};
|
|
156
156
|
const onHourFocus = (date) => {
|
|
157
157
|
const adjustedHour = use12Hours
|
|
@@ -166,7 +166,7 @@ exports.TimePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
166
166
|
setFocusedTime(setHours(adjustedHour, date));
|
|
167
167
|
};
|
|
168
168
|
const onMeridiemFocus = (value) => {
|
|
169
|
-
let adjustedSelectedTime = selectedTime
|
|
169
|
+
let adjustedSelectedTime = selectedTime ?? new Date();
|
|
170
170
|
const currentHours = adjustedSelectedTime.getHours();
|
|
171
171
|
if (value === 'AM' && currentHours > 11) {
|
|
172
172
|
setMeridiem(value);
|
|
@@ -188,7 +188,7 @@ exports.TimePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
188
188
|
return data;
|
|
189
189
|
};
|
|
190
190
|
const time = React.useMemo(() => {
|
|
191
|
-
const time = selectedTime
|
|
191
|
+
const time = selectedTime ?? new Date();
|
|
192
192
|
const data = [];
|
|
193
193
|
const hoursArray = Array.from(Array(use12Hours ? 12 : 24).keys())
|
|
194
194
|
.filter((i) => i % hourStep === 0)
|
|
@@ -215,15 +215,15 @@ exports.TimePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
215
215
|
return data;
|
|
216
216
|
}, [hourStep, minuteStep, secondStep, selectedTime, use12Hours, precision]);
|
|
217
217
|
const hours = React.useMemo(() => {
|
|
218
|
-
const time = selectedTime
|
|
218
|
+
const time = selectedTime ?? new Date();
|
|
219
219
|
return generateDataList(use12Hours ? 12 : 24, (i) => new Date(time.getFullYear(), time.getMonth(), time.getDate(), use12Hours && i === 0 ? 12 : i, time.getMinutes(), time.getSeconds()), hourStep);
|
|
220
220
|
}, [hourStep, selectedTime, use12Hours]);
|
|
221
221
|
const minutes = React.useMemo(() => {
|
|
222
|
-
const time = selectedTime
|
|
222
|
+
const time = selectedTime ?? new Date();
|
|
223
223
|
return generateDataList(60, (i) => new Date(time.getFullYear(), time.getMonth(), time.getDate(), time.getHours(), i, time.getSeconds()), minuteStep);
|
|
224
224
|
}, [minuteStep, selectedTime]);
|
|
225
225
|
const seconds = React.useMemo(() => {
|
|
226
|
-
const time = selectedTime
|
|
226
|
+
const time = selectedTime ?? new Date();
|
|
227
227
|
return generateDataList(60, (i) => new Date(time.getFullYear(), time.getMonth(), time.getDate(), time.getHours(), time.getMinutes(), i), secondStep);
|
|
228
228
|
}, [secondStep, selectedTime]);
|
|
229
229
|
return (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-time-picker', className), ref: forwardedRef, ...rest },
|
|
@@ -244,7 +244,7 @@ const TimePickerColumn = (props) => {
|
|
|
244
244
|
}
|
|
245
245
|
});
|
|
246
246
|
const scrollIntoView = (ref, isSame) => {
|
|
247
|
-
isSame &&
|
|
247
|
+
isSame && ref?.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
248
248
|
};
|
|
249
249
|
const handleTimeKeyDown = (event, maxValue, onFocus, onSelect, currentValue) => {
|
|
250
250
|
if (event.altKey) {
|
|
@@ -284,7 +284,7 @@ const TimePickerColumn = (props) => {
|
|
|
284
284
|
'iui-selected': isSameSelected(value),
|
|
285
285
|
}), key: index, tabIndex: isSameFocus ? 0 : undefined, ref: (ref) => {
|
|
286
286
|
scrollIntoView(ref, isSameFocus);
|
|
287
|
-
needFocus.current && isSameFocus &&
|
|
287
|
+
needFocus.current && isSameFocus && ref?.focus();
|
|
288
288
|
}, onClick: () => {
|
|
289
289
|
onSelectChange(value);
|
|
290
290
|
} }, valueRenderer(value, precision)));
|
package/cjs/core/Toast/Toast.js
CHANGED
|
@@ -36,7 +36,7 @@ const react_transition_group_1 = require("react-transition-group");
|
|
|
36
36
|
const classnames_1 = __importDefault(require("classnames"));
|
|
37
37
|
const index_js_1 = require("../utils/index.js");
|
|
38
38
|
const index_js_2 = require("../Buttons/index.js");
|
|
39
|
-
const isMotionOk = () =>
|
|
39
|
+
const isMotionOk = () => (0, index_js_1.getWindow)()?.matchMedia?.('(prefers-reduced-motion: no-preference)')?.matches;
|
|
40
40
|
/**
|
|
41
41
|
* Generic Toast Component
|
|
42
42
|
* @example
|
|
@@ -93,8 +93,7 @@ const Toast = (props) => {
|
|
|
93
93
|
}, timeout);
|
|
94
94
|
};
|
|
95
95
|
const clearCloseTimeout = () => {
|
|
96
|
-
|
|
97
|
-
(_a = (0, index_js_1.getWindow)()) === null || _a === void 0 ? void 0 : _a.clearTimeout(closeTimeout.current);
|
|
96
|
+
(0, index_js_1.getWindow)()?.clearTimeout(closeTimeout.current);
|
|
98
97
|
};
|
|
99
98
|
const onRef = (ref) => {
|
|
100
99
|
if (ref) {
|
|
@@ -45,11 +45,10 @@ class Toaster {
|
|
|
45
45
|
// Create container on demand.
|
|
46
46
|
// Cannot do it in constructor, because SSG/SSR apps would fail.
|
|
47
47
|
this.asyncInit = async () => {
|
|
48
|
-
var _a, _b;
|
|
49
48
|
if (this.isInitialized) {
|
|
50
49
|
return;
|
|
51
50
|
}
|
|
52
|
-
const container = (
|
|
51
|
+
const container = (0, index_js_1.getContainer)(TOASTS_CONTAINER_ID) ?? (0, index_js_1.getDocument)()?.body;
|
|
53
52
|
if (!container) {
|
|
54
53
|
return;
|
|
55
54
|
}
|
|
@@ -81,15 +80,13 @@ class Toaster {
|
|
|
81
80
|
* Settings will be applied to new toasts on the page.
|
|
82
81
|
*/
|
|
83
82
|
setSettings(newSettings) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
(_b = newSettings.order) !== null && _b !== void 0 ? _b : (newSettings.order = ((_c = newSettings.placement) === null || _c === void 0 ? void 0 : _c.startsWith('bottom'))
|
|
83
|
+
newSettings.placement ?? (newSettings.placement = this.settings.placement);
|
|
84
|
+
newSettings.order ?? (newSettings.order = newSettings.placement?.startsWith('bottom')
|
|
87
85
|
? 'ascending'
|
|
88
86
|
: 'descending');
|
|
89
87
|
this.settings = newSettings;
|
|
90
88
|
this.asyncInit().then(() => {
|
|
91
|
-
|
|
92
|
-
(_a = this.toastsRef.current) === null || _a === void 0 ? void 0 : _a.setPlacement((_b = this.settings.placement) !== null && _b !== void 0 ? _b : 'top');
|
|
89
|
+
this.toastsRef.current?.setPlacement(this.settings.placement ?? 'top');
|
|
93
90
|
});
|
|
94
91
|
}
|
|
95
92
|
positive(content, options) {
|
|
@@ -114,9 +111,8 @@ class Toaster {
|
|
|
114
111
|
content,
|
|
115
112
|
category,
|
|
116
113
|
onRemove: () => {
|
|
117
|
-
var _a;
|
|
118
114
|
this.removeToast(currentId);
|
|
119
|
-
|
|
115
|
+
options?.onRemove?.();
|
|
120
116
|
},
|
|
121
117
|
id: currentId,
|
|
122
118
|
isVisible: true,
|
|
@@ -132,8 +128,7 @@ class Toaster {
|
|
|
132
128
|
}
|
|
133
129
|
updateView() {
|
|
134
130
|
this.asyncInit().then(() => {
|
|
135
|
-
|
|
136
|
-
(_a = this.toastsRef.current) === null || _a === void 0 ? void 0 : _a.setToasts(this.toasts);
|
|
131
|
+
this.toastsRef.current?.setToasts(this.toasts);
|
|
137
132
|
});
|
|
138
133
|
}
|
|
139
134
|
closeToast(toastId) {
|
|
@@ -36,10 +36,9 @@ const TransferListListbox = react_1.default.forwardRef((props, ref) => {
|
|
|
36
36
|
return focusableItems.filter((i) => !focusableItems.some((p) => p.contains(i.parentElement)));
|
|
37
37
|
}, []);
|
|
38
38
|
react_1.default.useEffect(() => {
|
|
39
|
-
var _a;
|
|
40
39
|
const items = getFocusableNodes();
|
|
41
40
|
if (focusedIndex != null) {
|
|
42
|
-
|
|
41
|
+
items?.[focusedIndex]?.focus();
|
|
43
42
|
return;
|
|
44
43
|
}
|
|
45
44
|
}, [focusedIndex, getFocusableNodes]);
|
|
@@ -48,10 +47,10 @@ const TransferListListbox = react_1.default.forwardRef((props, ref) => {
|
|
|
48
47
|
return;
|
|
49
48
|
}
|
|
50
49
|
const items = getFocusableNodes();
|
|
51
|
-
if (!
|
|
50
|
+
if (!items?.length) {
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
54
|
-
const currentIndex = focusedIndex
|
|
53
|
+
const currentIndex = focusedIndex ?? 0;
|
|
55
54
|
switch (event.key) {
|
|
56
55
|
case 'ArrowDown': {
|
|
57
56
|
setFocusedIndex(Math.min(currentIndex + 1, items.length - 1));
|
package/cjs/core/Tree/Tree.js
CHANGED
|
@@ -102,10 +102,10 @@ const Tree = (props) => {
|
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
const items = getFocusableNodes();
|
|
105
|
-
if (!
|
|
105
|
+
if (!items?.length) {
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
|
-
const activeIndex = items.findIndex((el) =>
|
|
108
|
+
const activeIndex = items.findIndex((el) => el.contains(treeRef.current?.ownerDocument.activeElement));
|
|
109
109
|
const currentIndex = activeIndex > -1 ? activeIndex : 0;
|
|
110
110
|
switch (event.key) {
|
|
111
111
|
case 'ArrowUp': {
|
|
@@ -155,20 +155,18 @@ const Tree = (props) => {
|
|
|
155
155
|
return [flatList, firstLevelNodes];
|
|
156
156
|
}, [data, getNode]);
|
|
157
157
|
const itemRenderer = React.useCallback((index) => {
|
|
158
|
-
var _a, _b, _c, _d;
|
|
159
158
|
const node = flatNodesList[index];
|
|
160
159
|
return (React.createElement(TreeContext_js_1.TreeContext.Provider, { key: node.nodeProps.nodeId, value: {
|
|
161
160
|
nodeDepth: node.depth,
|
|
162
161
|
subNodeIds: node.subNodeIds,
|
|
163
162
|
groupSize: node.depth === 0
|
|
164
163
|
? firstLevelNodesList.length
|
|
165
|
-
:
|
|
164
|
+
: node.parentNode?.subNodeIds?.length ?? 0,
|
|
166
165
|
indexInGroup: node.indexInGroup,
|
|
167
|
-
parentNodeId:
|
|
166
|
+
parentNodeId: node.parentNode?.nodeProps.nodeId,
|
|
168
167
|
scrollToParent: node.parentNode
|
|
169
168
|
? () => {
|
|
170
|
-
|
|
171
|
-
const parentNodeId = (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.nodeProps.nodeId;
|
|
169
|
+
const parentNodeId = node.parentNode?.nodeProps.nodeId;
|
|
172
170
|
const parentNodeIndex = flatNodesList.findIndex((n) => n.nodeProps.nodeId === parentNodeId);
|
|
173
171
|
setScrollToIndex(parentNodeIndex);
|
|
174
172
|
}
|
|
@@ -182,11 +180,10 @@ const Tree = (props) => {
|
|
|
182
180
|
}, [flatNodesList]);
|
|
183
181
|
React.useEffect(() => {
|
|
184
182
|
setTimeout(() => {
|
|
185
|
-
var _a;
|
|
186
183
|
if (scrollToIndex !== undefined) {
|
|
187
184
|
const nodeId = flatNodesListRef.current[scrollToIndex].nodeProps.nodeId;
|
|
188
|
-
const nodeElement =
|
|
189
|
-
nodeElement
|
|
185
|
+
const nodeElement = treeRef.current?.ownerDocument.querySelector(`#${nodeId}`);
|
|
186
|
+
nodeElement?.focus();
|
|
190
187
|
// Need to reset that if navigating with mouse and keyboard,
|
|
191
188
|
// e.g. pressing arrow left to go to parent node and then with mouse
|
|
192
189
|
// clicking some other child node and then pressing arrow left
|
|
@@ -195,13 +192,12 @@ const Tree = (props) => {
|
|
|
195
192
|
});
|
|
196
193
|
}, [scrollToIndex]);
|
|
197
194
|
const handleFocus = (event) => {
|
|
198
|
-
|
|
199
|
-
if ((_a = treeRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.relatedTarget)) {
|
|
195
|
+
if (treeRef.current?.contains(event.relatedTarget)) {
|
|
200
196
|
return;
|
|
201
197
|
}
|
|
202
198
|
const items = getFocusableNodes();
|
|
203
199
|
if (items.length > 0) {
|
|
204
|
-
|
|
200
|
+
items[focusedIndex.current]?.focus();
|
|
205
201
|
}
|
|
206
202
|
};
|
|
207
203
|
return (React.createElement(React.Fragment, null, enableVirtualization ? (React.createElement(VirtualizedTree, { flatNodesList: flatNodesList, itemRenderer: itemRenderer, scrollToIndex: scrollToIndex, onFocus: handleFocus, onKeyDown: handleKeyDown, ref: treeRef, className: className, style: style, ...rest })) : (React.createElement(TreeElement, { onKeyDown: handleKeyDown, onFocus: handleFocus, className: className, style: style, ref: treeRef, ...rest }, flatNodesList.map((_, i) => itemRenderer(i))))));
|
|
@@ -61,11 +61,10 @@ const TreeNode = (props) => {
|
|
|
61
61
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
62
62
|
const nodeRef = React.useRef(null);
|
|
63
63
|
const onKeyDown = (event) => {
|
|
64
|
-
var _a, _b, _c, _d, _e, _f;
|
|
65
64
|
if (event.altKey) {
|
|
66
65
|
return;
|
|
67
66
|
}
|
|
68
|
-
const isNodeFocused = nodeRef.current ===
|
|
67
|
+
const isNodeFocused = nodeRef.current === nodeRef.current?.ownerDocument.activeElement;
|
|
69
68
|
switch (event.key) {
|
|
70
69
|
case 'ArrowLeft': {
|
|
71
70
|
event.preventDefault();
|
|
@@ -75,19 +74,19 @@ const TreeNode = (props) => {
|
|
|
75
74
|
break;
|
|
76
75
|
}
|
|
77
76
|
if (parentNodeId) {
|
|
78
|
-
scrollToParent
|
|
77
|
+
scrollToParent?.();
|
|
79
78
|
break;
|
|
80
79
|
}
|
|
81
80
|
// If it is top level node (doesn't have parent node), then do nothing.
|
|
82
81
|
break;
|
|
83
82
|
}
|
|
84
83
|
const focusableElements = (0, index_js_1.getFocusableElements)(nodeRef.current);
|
|
85
|
-
const currentIndex = focusableElements.indexOf(
|
|
84
|
+
const currentIndex = focusableElements.indexOf(nodeRef.current?.ownerDocument.activeElement);
|
|
86
85
|
if (currentIndex === 0) {
|
|
87
|
-
|
|
86
|
+
nodeRef.current?.focus();
|
|
88
87
|
}
|
|
89
88
|
else {
|
|
90
|
-
|
|
89
|
+
focusableElements[currentIndex - 1]?.focus();
|
|
91
90
|
}
|
|
92
91
|
break;
|
|
93
92
|
}
|
|
@@ -99,10 +98,10 @@ const TreeNode = (props) => {
|
|
|
99
98
|
onExpanded(nodeId, true);
|
|
100
99
|
break;
|
|
101
100
|
}
|
|
102
|
-
|
|
101
|
+
focusableElements[0]?.focus();
|
|
103
102
|
break;
|
|
104
103
|
}
|
|
105
|
-
const currentIndex = focusableElements.indexOf(
|
|
104
|
+
const currentIndex = focusableElements.indexOf(nodeRef.current?.ownerDocument.activeElement);
|
|
106
105
|
if (currentIndex < focusableElements.length - 1) {
|
|
107
106
|
focusableElements[currentIndex + 1].focus();
|
|
108
107
|
break;
|
|
@@ -118,7 +117,7 @@ const TreeNode = (props) => {
|
|
|
118
117
|
}
|
|
119
118
|
event.preventDefault();
|
|
120
119
|
if (!isDisabled) {
|
|
121
|
-
onSelected
|
|
120
|
+
onSelected?.(nodeId, !isSelected);
|
|
122
121
|
}
|
|
123
122
|
break;
|
|
124
123
|
}
|
|
@@ -140,7 +139,7 @@ const TreeNode = (props) => {
|
|
|
140
139
|
React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-tree-node', {
|
|
141
140
|
'iui-active': isSelected,
|
|
142
141
|
'iui-disabled': isDisabled,
|
|
143
|
-
}), style: { '--level': nodeDepth }, onClick: () => !isDisabled &&
|
|
142
|
+
}), style: { '--level': nodeDepth }, onClick: () => !isDisabled && onSelected?.(nodeId, !isSelected) },
|
|
144
143
|
checkbox && (React.createElement(index_js_1.Box, { className: 'iui-tree-node-checkbox' }, React.isValidElement(checkbox)
|
|
145
144
|
? React.cloneElement(checkbox, {
|
|
146
145
|
tabIndex: isFocused ? 0 : -1,
|
|
@@ -116,27 +116,24 @@ class ColorValue {
|
|
|
116
116
|
* This allows component builders to know if they received bad input from user.
|
|
117
117
|
*/
|
|
118
118
|
static fromString(val, defaultColorIfNotParsed) {
|
|
119
|
-
const [tbgr, hue] = this.computeTbgrFromString(val, defaultColorIfNotParsed
|
|
119
|
+
const [tbgr, hue] = this.computeTbgrFromString(val, defaultColorIfNotParsed?.toTbgr());
|
|
120
120
|
return new ColorValue(tbgr, hue);
|
|
121
121
|
}
|
|
122
122
|
/** Create a ColorValue from hue, saturation, lightness values. */
|
|
123
123
|
static fromHSL(hsl) {
|
|
124
|
-
|
|
125
|
-
const alpha = (_a = hsl.a) !== null && _a !== void 0 ? _a : 1;
|
|
124
|
+
const alpha = hsl.a ?? 1;
|
|
126
125
|
return new ColorValue(this.computeTbgrFromHSL(hsl.h / 360, hsl.s / 100, hsl.l / 100, Math.round((1 - alpha) * 255)), hsl.h);
|
|
127
126
|
}
|
|
128
127
|
/** Create a ColorValue from an RgbColor */
|
|
129
128
|
static fromRGB(rgb) {
|
|
130
|
-
|
|
131
|
-
const alpha = (_a = rgb.a) !== null && _a !== void 0 ? _a : 1;
|
|
129
|
+
const alpha = rgb.a ?? 1;
|
|
132
130
|
return ColorValue.fromRgbt(rgb.r, rgb.g, rgb.b, Math.round((1 - alpha) * 255));
|
|
133
131
|
}
|
|
134
132
|
/**
|
|
135
133
|
* Create a ColorValue from an HsvColor
|
|
136
134
|
*/
|
|
137
135
|
static fromHSV(hsv) {
|
|
138
|
-
|
|
139
|
-
const alpha = (_a = hsv.a) !== null && _a !== void 0 ? _a : 1;
|
|
136
|
+
const alpha = hsv.a ?? 1;
|
|
140
137
|
const transparency = Math.round((1 - alpha) * 255);
|
|
141
138
|
// Check for simple case first.
|
|
142
139
|
if (!hsv.s || hsv.h === -1) {
|
|
@@ -487,33 +484,30 @@ class ColorValue {
|
|
|
487
484
|
}
|
|
488
485
|
/** Convert the 0xTTBBGGRR color to a string of the form "rgba(r,g,b,a)" where the color components are specified in decimal and the alpha component is a fraction. */
|
|
489
486
|
toRgbString(includeAlpha) {
|
|
490
|
-
var _a;
|
|
491
487
|
const rgb = this.toRgbColor();
|
|
492
488
|
const rgbString = `${rgb.r}, ${rgb.g}, ${rgb.b}`;
|
|
493
489
|
if (includeAlpha) {
|
|
494
|
-
const alpha =
|
|
490
|
+
const alpha = rgb.a ?? 1;
|
|
495
491
|
return `rgba(${rgbString}, ${ColorValue.getFormattedColorNumber(alpha, 2)})`;
|
|
496
492
|
}
|
|
497
493
|
return `rgb(${rgbString})`;
|
|
498
494
|
}
|
|
499
495
|
/** Convert this ColorValue to a string in the form "hsl(h,s,l) or hsla(h,s,l,a)" - i.e hsl(120,50%,50%). */
|
|
500
496
|
toHslString(includeAlpha) {
|
|
501
|
-
var _a, _b;
|
|
502
497
|
const hsl = this.toHslColor();
|
|
503
|
-
const hslString = `${ColorValue.getFormattedColorNumber(
|
|
498
|
+
const hslString = `${ColorValue.getFormattedColorNumber(this._hue ?? hsl.h)}, ${ColorValue.getFormattedColorNumber(hsl.s)}%, ${ColorValue.getFormattedColorNumber(hsl.l)}%`;
|
|
504
499
|
if (includeAlpha) {
|
|
505
|
-
const alpha =
|
|
500
|
+
const alpha = hsl.a ?? 1;
|
|
506
501
|
return `hsla(${hslString}, ${ColorValue.getFormattedColorNumber(alpha, 2)})`;
|
|
507
502
|
}
|
|
508
503
|
return `hsl(${hslString})`;
|
|
509
504
|
}
|
|
510
505
|
/** Convert this ColorValue to a string in the form "hsv(h,s,v) or hsva(h,s,v,a)" - i.e hsv(120,50%,50%). */
|
|
511
506
|
toHsvString(includeAlpha) {
|
|
512
|
-
var _a, _b;
|
|
513
507
|
const hsv = this.toHsvColor();
|
|
514
|
-
const hsvString = `${
|
|
508
|
+
const hsvString = `${this._hue ?? hsv.h}, ${hsv.s}%, ${hsv.v}%`;
|
|
515
509
|
if (includeAlpha) {
|
|
516
|
-
const alpha =
|
|
510
|
+
const alpha = hsv.a ?? 1;
|
|
517
511
|
return `hsva(${hsvString}, ${ColorValue.getFormattedColorNumber(alpha, 2)})`;
|
|
518
512
|
}
|
|
519
513
|
return `hsv(${hsvString})`;
|
|
@@ -42,10 +42,9 @@ const index_js_1 = require("../functions/index.js");
|
|
|
42
42
|
const AutoclearingHiddenLiveRegion = ({ text = '' }) => {
|
|
43
43
|
const [maybeText, setMaybeText] = React.useState(text);
|
|
44
44
|
React.useEffect(() => {
|
|
45
|
-
var _a;
|
|
46
45
|
setMaybeText(text);
|
|
47
|
-
const timeout = (
|
|
48
|
-
return () =>
|
|
46
|
+
const timeout = (0, index_js_1.getWindow)()?.setTimeout(() => setMaybeText(''), 5000);
|
|
47
|
+
return () => void (0, index_js_1.getWindow)()?.clearTimeout(timeout);
|
|
49
48
|
}, [text]);
|
|
50
49
|
return (React.createElement(VisuallyHidden_js_1.VisuallyHidden, { as: 'div', "aria-live": 'polite', "aria-atomic": 'true' }, maybeText));
|
|
51
50
|
};
|
|
@@ -47,19 +47,19 @@ const FocusTrap = (props) => {
|
|
|
47
47
|
const onFirstFocus = (event) => {
|
|
48
48
|
const [firstElement, lastElement] = getFirstLastFocusables();
|
|
49
49
|
if (event.relatedTarget === firstElement) {
|
|
50
|
-
lastElement
|
|
50
|
+
lastElement?.focus();
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
|
-
firstElement
|
|
53
|
+
firstElement?.focus();
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
const onLastFocus = (event) => {
|
|
57
57
|
const [firstElement, lastElement] = getFirstLastFocusables();
|
|
58
58
|
if (event.relatedTarget === lastElement) {
|
|
59
|
-
firstElement
|
|
59
|
+
firstElement?.focus();
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
|
-
lastElement
|
|
62
|
+
lastElement?.focus();
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
return (React.createElement(React.Fragment, null,
|