@itwin/itwinui-react 3.14.2 → 3.15.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 +68 -2
- package/DEV-cjs/core/Carousel/CarouselDotsList.js +11 -4
- package/DEV-cjs/core/Carousel/CarouselSlider.js +3 -3
- package/DEV-cjs/core/ColorPicker/ColorBuilder.js +72 -24
- package/DEV-cjs/core/ColorPicker/ColorInputPanel.js +35 -7
- package/DEV-cjs/core/ColorPicker/ColorPalette.js +21 -3
- package/DEV-cjs/core/ComboBox/ComboBox.js +2 -1
- package/DEV-cjs/core/ComboBox/ComboBoxMenu.js +2 -2
- package/DEV-cjs/core/DropdownMenu/DropdownMenu.js +20 -19
- package/DEV-cjs/core/Overlay/Overlay.js +0 -18
- package/DEV-cjs/core/Popover/Popover.js +17 -10
- package/DEV-cjs/core/Select/Select.js +4 -2
- package/DEV-cjs/core/Table/Table.js +50 -25
- package/DEV-cjs/core/Table/TableExpandableContentMemoized.js +47 -0
- package/DEV-cjs/core/Table/TableRowMemoized.js +0 -18
- package/DEV-cjs/core/Table/hooks/useColumnDragAndDrop.js +12 -14
- package/DEV-cjs/core/ThemeProvider/ThemeProvider.js +18 -0
- package/DEV-cjs/core/Toast/Toast.js +6 -7
- package/DEV-cjs/styles.js +1 -1
- package/DEV-cjs/utils/components/ShadowRoot.js +22 -8
- package/DEV-cjs/utils/hooks/useWarningLogger.js +5 -3
- package/DEV-esm/core/Carousel/CarouselDotsList.js +10 -5
- package/DEV-esm/core/Carousel/CarouselSlider.js +2 -3
- package/DEV-esm/core/ColorPicker/ColorBuilder.js +56 -22
- package/DEV-esm/core/ColorPicker/ColorInputPanel.js +37 -8
- package/DEV-esm/core/ColorPicker/ColorPalette.js +18 -3
- package/DEV-esm/core/ComboBox/ComboBox.js +2 -1
- package/DEV-esm/core/ComboBox/ComboBoxMenu.js +2 -2
- package/DEV-esm/core/DropdownMenu/DropdownMenu.js +20 -19
- package/DEV-esm/core/Overlay/Overlay.js +1 -19
- package/DEV-esm/core/Popover/Popover.js +18 -10
- package/DEV-esm/core/Select/Select.js +4 -2
- package/DEV-esm/core/Table/Table.js +50 -25
- package/DEV-esm/core/Table/TableExpandableContentMemoized.js +33 -0
- package/DEV-esm/core/Table/TableRowMemoized.js +1 -21
- package/DEV-esm/core/Table/hooks/useColumnDragAndDrop.js +12 -6
- package/DEV-esm/core/ThemeProvider/ThemeProvider.js +18 -0
- package/DEV-esm/core/Toast/Toast.js +5 -5
- package/DEV-esm/styles.js +1 -1
- package/DEV-esm/utils/components/ShadowRoot.js +22 -8
- package/DEV-esm/utils/hooks/useWarningLogger.js +4 -3
- package/cjs/core/Buttons/SplitButton.d.ts +5 -0
- package/cjs/core/Carousel/CarouselDotsList.js +11 -4
- package/cjs/core/Carousel/CarouselSlider.js +3 -3
- package/cjs/core/ColorPicker/ColorBuilder.d.ts +22 -1
- package/cjs/core/ColorPicker/ColorBuilder.js +72 -24
- package/cjs/core/ColorPicker/ColorInputPanel.d.ts +18 -0
- package/cjs/core/ColorPicker/ColorInputPanel.js +35 -7
- package/cjs/core/ColorPicker/ColorPalette.d.ts +8 -0
- package/cjs/core/ColorPicker/ColorPalette.js +21 -3
- package/cjs/core/ComboBox/ComboBox.d.ts +3 -2
- package/cjs/core/ComboBox/ComboBox.js +2 -1
- package/cjs/core/ComboBox/ComboBoxMenu.js +2 -2
- package/cjs/core/DropdownMenu/DropdownMenu.d.ts +11 -0
- package/cjs/core/DropdownMenu/DropdownMenu.js +20 -19
- package/cjs/core/Overlay/Overlay.js +0 -18
- package/cjs/core/Popover/Popover.d.ts +4 -1
- package/cjs/core/Popover/Popover.js +17 -10
- package/cjs/core/Select/Select.d.ts +14 -2
- package/cjs/core/Select/Select.js +4 -2
- package/cjs/core/Table/Table.js +50 -25
- package/cjs/core/Table/TableExpandableContentMemoized.d.ts +10 -0
- package/cjs/core/Table/TableExpandableContentMemoized.js +47 -0
- package/cjs/core/Table/TableRowMemoized.js +0 -18
- package/cjs/core/Table/hooks/useColumnDragAndDrop.js +12 -14
- package/cjs/core/ThemeProvider/ThemeProvider.js +18 -0
- package/cjs/core/Toast/Toast.js +6 -7
- package/cjs/styles.js +1 -1
- package/cjs/utils/components/ShadowRoot.js +22 -8
- package/cjs/utils/hooks/useWarningLogger.js +1 -0
- package/esm/core/Buttons/SplitButton.d.ts +5 -0
- package/esm/core/Carousel/CarouselDotsList.js +10 -5
- package/esm/core/Carousel/CarouselSlider.js +2 -3
- package/esm/core/ColorPicker/ColorBuilder.d.ts +22 -1
- package/esm/core/ColorPicker/ColorBuilder.js +56 -22
- package/esm/core/ColorPicker/ColorInputPanel.d.ts +18 -0
- package/esm/core/ColorPicker/ColorInputPanel.js +37 -8
- package/esm/core/ColorPicker/ColorPalette.d.ts +8 -0
- package/esm/core/ColorPicker/ColorPalette.js +18 -3
- package/esm/core/ComboBox/ComboBox.d.ts +3 -2
- package/esm/core/ComboBox/ComboBox.js +2 -1
- package/esm/core/ComboBox/ComboBoxMenu.js +2 -2
- package/esm/core/DropdownMenu/DropdownMenu.d.ts +11 -0
- package/esm/core/DropdownMenu/DropdownMenu.js +20 -19
- package/esm/core/Overlay/Overlay.js +1 -19
- package/esm/core/Popover/Popover.d.ts +4 -1
- package/esm/core/Popover/Popover.js +18 -10
- package/esm/core/Select/Select.d.ts +14 -2
- package/esm/core/Select/Select.js +4 -2
- package/esm/core/Table/Table.js +50 -25
- package/esm/core/Table/TableExpandableContentMemoized.d.ts +10 -0
- package/esm/core/Table/TableExpandableContentMemoized.js +33 -0
- package/esm/core/Table/TableRowMemoized.js +1 -21
- package/esm/core/Table/hooks/useColumnDragAndDrop.js +12 -6
- package/esm/core/ThemeProvider/ThemeProvider.js +18 -0
- package/esm/core/Toast/Toast.js +5 -5
- package/esm/styles.js +1 -1
- package/esm/utils/components/ShadowRoot.js +22 -8
- package/esm/utils/hooks/useWarningLogger.js +1 -0
- package/package.json +8 -6
- package/styles.css +8 -8
|
@@ -2,13 +2,24 @@ import * as React from 'react';
|
|
|
2
2
|
import cx from 'classnames';
|
|
3
3
|
import { IconButton } from '../Buttons/IconButton.js';
|
|
4
4
|
import { Input } from '../Input/Input.js';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ColorValue,
|
|
7
|
+
SvgSwap,
|
|
8
|
+
Box,
|
|
9
|
+
useId,
|
|
10
|
+
useMergedRefs,
|
|
11
|
+
mergeEventHandlers,
|
|
12
|
+
} from '../../utils/index.js';
|
|
6
13
|
import { useColorPickerContext } from './ColorPickerContext.js';
|
|
7
14
|
export const ColorInputPanel = React.forwardRef((props, ref) => {
|
|
8
15
|
let {
|
|
9
16
|
defaultColorFormat,
|
|
10
17
|
allowedColorFormats = ['hsl', 'rgb', 'hex'],
|
|
11
18
|
className,
|
|
19
|
+
colorInputContainerProps,
|
|
20
|
+
panelLabelProps,
|
|
21
|
+
inputFieldsGroupProps,
|
|
22
|
+
swapColorFormatButtonProps,
|
|
12
23
|
...rest
|
|
13
24
|
} = props;
|
|
14
25
|
let inputsContainerRef = React.useRef(null);
|
|
@@ -352,10 +363,12 @@ export const ColorInputPanel = React.forwardRef((props, ref) => {
|
|
|
352
363
|
Number(input[3]) < 0 || Number(input[3]) > 1 ? 'negative' : void 0,
|
|
353
364
|
}),
|
|
354
365
|
);
|
|
355
|
-
let
|
|
366
|
+
let fallbackLabelId = useId();
|
|
367
|
+
let labelId = panelLabelProps?.id ?? fallbackLabelId;
|
|
356
368
|
return React.createElement(
|
|
357
369
|
Box,
|
|
358
370
|
{
|
|
371
|
+
as: 'div',
|
|
359
372
|
className: cx('iui-color-input-wrapper', className),
|
|
360
373
|
ref: ref,
|
|
361
374
|
...rest,
|
|
@@ -363,7 +376,12 @@ export const ColorInputPanel = React.forwardRef((props, ref) => {
|
|
|
363
376
|
React.createElement(
|
|
364
377
|
Box,
|
|
365
378
|
{
|
|
366
|
-
|
|
379
|
+
as: 'div',
|
|
380
|
+
...panelLabelProps,
|
|
381
|
+
className: cx(
|
|
382
|
+
'iui-color-picker-section-label',
|
|
383
|
+
panelLabelProps?.className,
|
|
384
|
+
),
|
|
367
385
|
id: labelId,
|
|
368
386
|
},
|
|
369
387
|
showAlpha && 'hex' !== currentFormat
|
|
@@ -373,26 +391,37 @@ export const ColorInputPanel = React.forwardRef((props, ref) => {
|
|
|
373
391
|
React.createElement(
|
|
374
392
|
Box,
|
|
375
393
|
{
|
|
376
|
-
|
|
394
|
+
as: 'div',
|
|
395
|
+
...colorInputContainerProps,
|
|
396
|
+
className: cx('iui-color-input', colorInputContainerProps?.className),
|
|
377
397
|
},
|
|
378
398
|
allowedColorFormats.length > 1 &&
|
|
379
399
|
React.createElement(
|
|
380
400
|
IconButton,
|
|
381
401
|
{
|
|
382
|
-
styleType: 'borderless',
|
|
383
|
-
onClick: swapColorFormat,
|
|
384
402
|
size: 'small',
|
|
403
|
+
styleType: 'borderless',
|
|
385
404
|
label: 'Switch format',
|
|
405
|
+
...swapColorFormatButtonProps,
|
|
406
|
+
onClick: mergeEventHandlers(
|
|
407
|
+
swapColorFormatButtonProps?.onClick,
|
|
408
|
+
swapColorFormat,
|
|
409
|
+
),
|
|
386
410
|
},
|
|
387
411
|
React.createElement(SvgSwap, null),
|
|
388
412
|
),
|
|
389
413
|
React.createElement(
|
|
390
414
|
Box,
|
|
391
415
|
{
|
|
392
|
-
|
|
393
|
-
className: 'iui-color-input-fields',
|
|
416
|
+
as: 'div',
|
|
394
417
|
role: 'hex' !== currentFormat ? 'group' : void 0,
|
|
395
418
|
'aria-labelledby': 'hex' !== currentFormat ? labelId : void 0,
|
|
419
|
+
...inputFieldsGroupProps,
|
|
420
|
+
ref: useMergedRefs(inputsContainerRef, inputFieldsGroupProps?.ref),
|
|
421
|
+
className: cx(
|
|
422
|
+
'iui-color-input-fields',
|
|
423
|
+
inputFieldsGroupProps?.className,
|
|
424
|
+
),
|
|
396
425
|
},
|
|
397
426
|
'hex' === currentFormat && hexInputField,
|
|
398
427
|
'rgb' === currentFormat && rgbInputs,
|
|
@@ -5,7 +5,15 @@ import { getColorValue } from './ColorPicker.js';
|
|
|
5
5
|
import { ColorSwatch } from './ColorSwatch.js';
|
|
6
6
|
import { useColorPickerContext } from './ColorPickerContext.js';
|
|
7
7
|
export const ColorPalette = React.forwardRef((props, ref) => {
|
|
8
|
-
let {
|
|
8
|
+
let {
|
|
9
|
+
colors,
|
|
10
|
+
label,
|
|
11
|
+
labelProps,
|
|
12
|
+
className,
|
|
13
|
+
children,
|
|
14
|
+
paletteContainerProps,
|
|
15
|
+
...rest
|
|
16
|
+
} = props;
|
|
9
17
|
let { activeColor, setActiveColor, onChangeComplete } =
|
|
10
18
|
useColorPickerContext();
|
|
11
19
|
return React.createElement(
|
|
@@ -19,14 +27,21 @@ export const ColorPalette = React.forwardRef((props, ref) => {
|
|
|
19
27
|
React.createElement(
|
|
20
28
|
Box,
|
|
21
29
|
{
|
|
22
|
-
|
|
30
|
+
as: 'div',
|
|
31
|
+
...labelProps,
|
|
32
|
+
className: cx(
|
|
33
|
+
'iui-color-picker-section-label',
|
|
34
|
+
labelProps?.className,
|
|
35
|
+
),
|
|
23
36
|
},
|
|
24
37
|
label,
|
|
25
38
|
),
|
|
26
39
|
React.createElement(
|
|
27
40
|
Box,
|
|
28
41
|
{
|
|
29
|
-
|
|
42
|
+
as: 'div',
|
|
43
|
+
...paletteContainerProps,
|
|
44
|
+
className: cx('iui-color-palette', paletteContainerProps?.className),
|
|
30
45
|
},
|
|
31
46
|
children,
|
|
32
47
|
colors &&
|
|
@@ -38,7 +38,7 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
|
|
|
38
38
|
filterFunction = defaultFilterFunction,
|
|
39
39
|
inputProps,
|
|
40
40
|
endIconProps,
|
|
41
|
-
dropdownMenuProps,
|
|
41
|
+
dropdownMenuProps: { middleware, ...dropdownMenuProps } = {},
|
|
42
42
|
emptyStateMessage = 'No options found',
|
|
43
43
|
itemRenderer,
|
|
44
44
|
enableVirtualization = false,
|
|
@@ -318,6 +318,7 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
|
|
|
318
318
|
size: {
|
|
319
319
|
maxHeight: 'var(--iui-menu-max-height)',
|
|
320
320
|
},
|
|
321
|
+
...middleware,
|
|
321
322
|
},
|
|
322
323
|
closeOnOutsideClick: true,
|
|
323
324
|
interactions: {
|
|
@@ -90,7 +90,7 @@ let VirtualizedComboBoxMenu = (props) => {
|
|
|
90
90
|
);
|
|
91
91
|
};
|
|
92
92
|
export const ComboBoxMenu = React.forwardRef((props, forwardedRef) => {
|
|
93
|
-
let { className, children, style, ...rest } = props;
|
|
93
|
+
let { className, children, style, portal = true, ...rest } = props;
|
|
94
94
|
let { id, enableVirtualization, popover } =
|
|
95
95
|
useSafeContext(ComboBoxStateContext);
|
|
96
96
|
let { menuRef } = useSafeContext(ComboBoxRefsContext);
|
|
@@ -100,7 +100,7 @@ export const ComboBoxMenu = React.forwardRef((props, forwardedRef) => {
|
|
|
100
100
|
React.createElement(
|
|
101
101
|
Portal,
|
|
102
102
|
{
|
|
103
|
-
portal:
|
|
103
|
+
portal: portal,
|
|
104
104
|
},
|
|
105
105
|
React.createElement(
|
|
106
106
|
List,
|
|
@@ -23,6 +23,7 @@ let DropdownMenuContent = React.forwardRef((props, forwardedRef) => {
|
|
|
23
23
|
matchWidth = false,
|
|
24
24
|
onVisibleChange,
|
|
25
25
|
portal = true,
|
|
26
|
+
middleware,
|
|
26
27
|
...rest
|
|
27
28
|
} = props;
|
|
28
29
|
let [visible, setVisible] = useControlledState(
|
|
@@ -36,28 +37,28 @@ let DropdownMenuContent = React.forwardRef((props, forwardedRef) => {
|
|
|
36
37
|
return menuItems;
|
|
37
38
|
}, [menuItems, setVisible]);
|
|
38
39
|
return React.createElement(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
portal: portal,
|
|
52
|
-
popoverProps: {
|
|
40
|
+
Menu,
|
|
41
|
+
{
|
|
42
|
+
trigger: children,
|
|
43
|
+
onKeyDown: mergeEventHandlers(props.onKeyDown, (e) => {
|
|
44
|
+
if (e.defaultPrevented) return;
|
|
45
|
+
if ('Tab' === e.key) setVisible(false);
|
|
46
|
+
}),
|
|
47
|
+
role: role,
|
|
48
|
+
ref: forwardedRef,
|
|
49
|
+
portal: portal,
|
|
50
|
+
popoverProps: React.useMemo(
|
|
51
|
+
() => ({
|
|
53
52
|
placement,
|
|
54
53
|
matchWidth,
|
|
55
54
|
visible,
|
|
56
55
|
onVisibleChange: setVisible,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
middleware,
|
|
57
|
+
}),
|
|
58
|
+
[matchWidth, middleware, placement, setVisible, visible],
|
|
59
|
+
),
|
|
60
|
+
...rest,
|
|
61
|
+
},
|
|
62
|
+
menuContent,
|
|
62
63
|
);
|
|
63
64
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Box,
|
|
2
|
+
import { Box, polymorphic } from '../../utils/index.js';
|
|
3
3
|
let OverlayComponent = React.forwardRef((props, forwardedRef) => {
|
|
4
4
|
let { content, children, ...rest } = props;
|
|
5
5
|
return React.createElement(
|
|
@@ -15,7 +15,6 @@ let OverlayComponent = React.forwardRef((props, forwardedRef) => {
|
|
|
15
15
|
OverlayComponent.displayName = 'Overlay';
|
|
16
16
|
let OverlayHiddenContent = React.forwardRef((props, ref) => {
|
|
17
17
|
let { children, ...rest } = props;
|
|
18
|
-
useInertPolyfill();
|
|
19
18
|
return React.createElement(
|
|
20
19
|
Box,
|
|
21
20
|
{
|
|
@@ -36,20 +35,3 @@ export const Overlay = Object.assign(OverlayComponent, {
|
|
|
36
35
|
HiddenContent: OverlayHiddenContent,
|
|
37
36
|
Overlay: OverlayOverlay,
|
|
38
37
|
});
|
|
39
|
-
let useInertPolyfill = () => {
|
|
40
|
-
let loaded = React.useRef(false);
|
|
41
|
-
let modulePath =
|
|
42
|
-
'https://cdn.jsdelivr.net/npm/wicg-inert@3.1.2/dist/inert.min.js';
|
|
43
|
-
React.useEffect(() => {
|
|
44
|
-
(async () => {
|
|
45
|
-
if (
|
|
46
|
-
!HTMLElement.prototype.hasOwnProperty('inert') &&
|
|
47
|
-
!loaded.current &&
|
|
48
|
-
!isUnitTest
|
|
49
|
-
) {
|
|
50
|
-
await new Function('url', 'return import(url)')(modulePath);
|
|
51
|
-
loaded.current = true;
|
|
52
|
-
}
|
|
53
|
-
})();
|
|
54
|
-
}, []);
|
|
55
|
-
};
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
Box,
|
|
26
26
|
ShadowRoot,
|
|
27
27
|
cloneElementWithRef,
|
|
28
|
+
isUnitTest,
|
|
28
29
|
mergeEventHandlers,
|
|
29
30
|
useControlledState,
|
|
30
31
|
useId,
|
|
@@ -47,21 +48,22 @@ export const usePopover = (options) => {
|
|
|
47
48
|
} = options;
|
|
48
49
|
let mergedInteractions = React.useMemo(
|
|
49
50
|
() => ({
|
|
50
|
-
click: true,
|
|
51
|
-
dismiss: true,
|
|
52
|
-
hover: false,
|
|
53
|
-
focus: false,
|
|
54
51
|
...interactionsProp,
|
|
52
|
+
click: interactionsProp?.click ?? true,
|
|
53
|
+
dismiss: interactionsProp?.dismiss ?? true,
|
|
54
|
+
hover: interactionsProp?.hover ?? false,
|
|
55
|
+
focus: interactionsProp?.focus ?? false,
|
|
55
56
|
}),
|
|
56
57
|
[interactionsProp],
|
|
57
58
|
);
|
|
58
59
|
let tree = useFloatingTree();
|
|
59
60
|
let middleware = React.useMemo(
|
|
60
61
|
() => ({
|
|
61
|
-
flip: true,
|
|
62
|
-
shift: true,
|
|
63
|
-
size: true,
|
|
64
62
|
...options.middleware,
|
|
63
|
+
flip: options.middleware?.flip ?? true,
|
|
64
|
+
shift: options.middleware?.shift ?? true,
|
|
65
|
+
size: options.middleware?.size ?? true,
|
|
66
|
+
hide: options.middleware?.hide || !isUnitTest,
|
|
65
67
|
}),
|
|
66
68
|
[options.middleware],
|
|
67
69
|
);
|
|
@@ -166,17 +168,23 @@ export const usePopover = (options) => {
|
|
|
166
168
|
maxInlineSize: `min(${2 * referenceWidth}px, 90vw)`,
|
|
167
169
|
}
|
|
168
170
|
: {}),
|
|
171
|
+
...(middleware.hide &&
|
|
172
|
+
floating.middlewareData.hide?.referenceHidden && {
|
|
173
|
+
visibility: 'hidden',
|
|
174
|
+
}),
|
|
169
175
|
...userProps?.style,
|
|
170
176
|
},
|
|
171
177
|
}),
|
|
172
178
|
[
|
|
173
|
-
floating.floatingStyles,
|
|
174
179
|
interactions,
|
|
175
|
-
|
|
176
|
-
|
|
180
|
+
floating.floatingStyles,
|
|
181
|
+
floating.middlewareData.hide?.referenceHidden,
|
|
177
182
|
middleware.size,
|
|
183
|
+
middleware.hide,
|
|
178
184
|
availableHeight,
|
|
179
185
|
maxHeight,
|
|
186
|
+
matchWidth,
|
|
187
|
+
referenceWidth,
|
|
180
188
|
],
|
|
181
189
|
);
|
|
182
190
|
let getReferenceProps = React.useCallback(
|
|
@@ -110,7 +110,7 @@ let CustomSelect = React.forwardRef((props, forwardedRef) => {
|
|
|
110
110
|
multiple = false,
|
|
111
111
|
triggerProps,
|
|
112
112
|
status,
|
|
113
|
-
popoverProps,
|
|
113
|
+
popoverProps: { portal = true, ...popoverProps } = {},
|
|
114
114
|
styleType,
|
|
115
115
|
...rest
|
|
116
116
|
} = props;
|
|
@@ -304,7 +304,9 @@ let CustomSelect = React.forwardRef((props, forwardedRef) => {
|
|
|
304
304
|
popover.open &&
|
|
305
305
|
React.createElement(
|
|
306
306
|
Portal,
|
|
307
|
-
|
|
307
|
+
{
|
|
308
|
+
portal: portal,
|
|
309
|
+
},
|
|
308
310
|
React.createElement(
|
|
309
311
|
SelectListbox,
|
|
310
312
|
{
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
} from './actionHandlers/index.js';
|
|
49
49
|
import { SELECTION_CELL_ID } from './columns/index.js';
|
|
50
50
|
import { ColumnHeader } from './ColumnHeader.js';
|
|
51
|
+
import { TableExpandableContentMemoized } from './TableExpandableContentMemoized.js';
|
|
51
52
|
let singleRowSelectedAction = 'singleRowSelected';
|
|
52
53
|
let shiftRowSelectedAction = 'shiftRowSelected';
|
|
53
54
|
export const tableResizeStartAction = 'tableResizeStart';
|
|
@@ -239,6 +240,17 @@ export const Table = (props) => {
|
|
|
239
240
|
),
|
|
240
241
|
[data, getSubRows],
|
|
241
242
|
);
|
|
243
|
+
let [rowHasParent] = React.useState(() => new WeakSet());
|
|
244
|
+
let getSubRowsWithSubComponents = React.useCallback(
|
|
245
|
+
(originalRow) => {
|
|
246
|
+
if (!rowHasParent.has(originalRow)) {
|
|
247
|
+
rowHasParent.add(originalRow);
|
|
248
|
+
return [originalRow];
|
|
249
|
+
}
|
|
250
|
+
return originalRow.subRows || [];
|
|
251
|
+
},
|
|
252
|
+
[rowHasParent],
|
|
253
|
+
);
|
|
242
254
|
let instance = useTable(
|
|
243
255
|
{
|
|
244
256
|
manualPagination: !paginatorRenderer,
|
|
@@ -251,7 +263,7 @@ export const Table = (props) => {
|
|
|
251
263
|
filterTypes,
|
|
252
264
|
selectSubRows,
|
|
253
265
|
data,
|
|
254
|
-
getSubRows,
|
|
266
|
+
getSubRows: subComponent ? getSubRowsWithSubComponents : getSubRows,
|
|
255
267
|
initialState: {
|
|
256
268
|
pageSize,
|
|
257
269
|
...props.initialState,
|
|
@@ -447,39 +459,54 @@ export const Table = (props) => {
|
|
|
447
459
|
useLayoutEffect(() => {
|
|
448
460
|
if (scrollToIndex)
|
|
449
461
|
virtualizer.scrollToIndex(scrollToIndex, {
|
|
450
|
-
align: '
|
|
462
|
+
align: 'start',
|
|
451
463
|
});
|
|
452
464
|
}, [virtualizer, scrollToIndex]);
|
|
453
465
|
let getPreparedRow = React.useCallback(
|
|
454
466
|
(index, virtualItem, virtualizer) => {
|
|
455
467
|
let row = page[index];
|
|
456
468
|
prepareRow(row);
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
469
|
+
if (row.subRows.length > 0 || !subComponent)
|
|
470
|
+
return React.createElement(TableRowMemoized, {
|
|
471
|
+
row: row,
|
|
472
|
+
rowProps: rowProps,
|
|
473
|
+
isLast: index === page.length - 1,
|
|
474
|
+
onRowInViewport: onRowInViewportRef,
|
|
475
|
+
onBottomReached: onBottomReachedRef,
|
|
476
|
+
intersectionMargin: intersectionMargin,
|
|
477
|
+
state: state,
|
|
478
|
+
key: row.getRowProps().key,
|
|
479
|
+
onClick: onRowClickHandler,
|
|
480
|
+
subComponent: subComponent,
|
|
481
|
+
isDisabled: !!isRowDisabled?.(row.original),
|
|
482
|
+
tableHasSubRows: hasAnySubRows,
|
|
483
|
+
tableInstance: instance,
|
|
484
|
+
expanderCell: expanderCell,
|
|
485
|
+
scrollContainerRef: tableRef.current,
|
|
486
|
+
tableRowRef: enableVirtualization ? void 0 : tableRowRef(row),
|
|
487
|
+
density: density,
|
|
488
|
+
virtualItem: virtualItem,
|
|
489
|
+
virtualizer: virtualizer,
|
|
490
|
+
});
|
|
491
|
+
return React.createElement(
|
|
492
|
+
TableExpandableContentMemoized,
|
|
493
|
+
{
|
|
494
|
+
key: row.getRowProps().key,
|
|
495
|
+
virtualItem: virtualItem,
|
|
496
|
+
ref: enableVirtualization
|
|
497
|
+
? virtualizer?.measureElement
|
|
498
|
+
: tableRowRef(row),
|
|
499
|
+
isDisabled: !!isRowDisabled?.(row.original),
|
|
500
|
+
},
|
|
501
|
+
subComponent(row),
|
|
502
|
+
);
|
|
478
503
|
},
|
|
479
504
|
[
|
|
480
505
|
page,
|
|
481
506
|
prepareRow,
|
|
482
507
|
rowProps,
|
|
508
|
+
onRowInViewportRef,
|
|
509
|
+
onBottomReachedRef,
|
|
483
510
|
intersectionMargin,
|
|
484
511
|
state,
|
|
485
512
|
onRowClickHandler,
|
|
@@ -491,8 +518,6 @@ export const Table = (props) => {
|
|
|
491
518
|
enableVirtualization,
|
|
492
519
|
tableRowRef,
|
|
493
520
|
density,
|
|
494
|
-
onBottomReachedRef,
|
|
495
|
-
onRowInViewportRef,
|
|
496
521
|
],
|
|
497
522
|
);
|
|
498
523
|
let updateStickyState = () => {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Box } from '../../utils/index.js';
|
|
4
|
+
let TableExpandableContent = React.forwardRef((props, ref) => {
|
|
5
|
+
let { children, className, style, isDisabled, virtualItem, ...rest } = props;
|
|
6
|
+
return React.createElement(
|
|
7
|
+
Box,
|
|
8
|
+
{
|
|
9
|
+
className: cx('iui-table-row', 'iui-table-expanded-content', className),
|
|
10
|
+
style: {
|
|
11
|
+
flex: '0 0 auto',
|
|
12
|
+
minWidth: '100%',
|
|
13
|
+
...(null != virtualItem
|
|
14
|
+
? {
|
|
15
|
+
transform: `translateY(${virtualItem.start}px)`,
|
|
16
|
+
}
|
|
17
|
+
: {}),
|
|
18
|
+
...style,
|
|
19
|
+
},
|
|
20
|
+
'aria-disabled': isDisabled,
|
|
21
|
+
'data-iui-index': virtualItem?.index,
|
|
22
|
+
...(null != virtualItem && {
|
|
23
|
+
'data-iui-virtualizer': 'item',
|
|
24
|
+
}),
|
|
25
|
+
ref: ref,
|
|
26
|
+
...rest,
|
|
27
|
+
},
|
|
28
|
+
children,
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
export const TableExpandableContentMemoized = React.memo(
|
|
32
|
+
TableExpandableContent,
|
|
33
|
+
);
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import cx from 'classnames';
|
|
3
|
-
import {
|
|
4
|
-
Box,
|
|
5
|
-
useIntersection,
|
|
6
|
-
useMergedRefs,
|
|
7
|
-
WithCSSTransition,
|
|
8
|
-
} from '../../utils/index.js';
|
|
3
|
+
import { Box, useIntersection, useMergedRefs } from '../../utils/index.js';
|
|
9
4
|
import { TableCell } from './TableCell.js';
|
|
10
5
|
export const TableRow = (props) => {
|
|
11
6
|
let {
|
|
@@ -106,21 +101,6 @@ export const TableRow = (props) => {
|
|
|
106
101
|
}),
|
|
107
102
|
),
|
|
108
103
|
),
|
|
109
|
-
subComponent &&
|
|
110
|
-
React.createElement(
|
|
111
|
-
WithCSSTransition,
|
|
112
|
-
{
|
|
113
|
-
in: row.isExpanded,
|
|
114
|
-
},
|
|
115
|
-
React.createElement(
|
|
116
|
-
Box,
|
|
117
|
-
{
|
|
118
|
-
className: cx('iui-table-row', 'iui-table-expanded-content'),
|
|
119
|
-
'aria-disabled': isDisabled,
|
|
120
|
-
},
|
|
121
|
-
subComponent(row),
|
|
122
|
-
),
|
|
123
|
-
),
|
|
124
104
|
);
|
|
125
105
|
};
|
|
126
106
|
let hasAnySelectedSubRow = (row, selectedRowIds) => {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { actions, makePropGetter, useGetLatest } from 'react-table';
|
|
2
2
|
import { styles } from '../../../styles.js';
|
|
3
|
+
let leftClassName = styles['iui-table-reorder-column-left'];
|
|
4
|
+
let rightClassName = styles['iui-table-reorder-column-right'];
|
|
3
5
|
let REORDER_ACTIONS = {
|
|
4
6
|
columnDragStart: 'columnDragStart',
|
|
5
7
|
columnDragEnd: 'columnDragEnd',
|
|
@@ -21,12 +23,16 @@ let defaultGetDragAndDropProps =
|
|
|
21
23
|
};
|
|
22
24
|
let setOnDragColumnStyle = (event, position) => {
|
|
23
25
|
let columnElement = event.currentTarget;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
columnElement.classList.add(
|
|
26
|
+
if ('left' === position) {
|
|
27
|
+
columnElement.classList.remove(rightClassName);
|
|
28
|
+
columnElement.classList.add(leftClassName);
|
|
29
|
+
} else if ('right' === position) {
|
|
30
|
+
columnElement.classList.remove(leftClassName);
|
|
31
|
+
columnElement.classList.add(rightClassName);
|
|
32
|
+
} else {
|
|
33
|
+
columnElement.classList.remove(leftClassName);
|
|
34
|
+
columnElement.classList.remove(rightClassName);
|
|
35
|
+
}
|
|
30
36
|
};
|
|
31
37
|
let reorderColumns = (tableColumns, srcIndex, dstIndex) => {
|
|
32
38
|
let newTableColumns = [...tableColumns];
|
|
@@ -32,6 +32,7 @@ export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
|
|
|
32
32
|
includeCss = 'inherit' === themeProp,
|
|
33
33
|
...rest
|
|
34
34
|
} = props;
|
|
35
|
+
useInertPolyfill();
|
|
35
36
|
let [rootElement, setRootElement] = React.useState(null);
|
|
36
37
|
let parent = useParentThemeAndContext(rootElement);
|
|
37
38
|
let theme = 'inherit' === themeProp ? parent.theme || 'light' : themeProp;
|
|
@@ -278,3 +279,20 @@ let useIuiDebugRef = () => {
|
|
|
278
279
|
};
|
|
279
280
|
_globalThis1.__iui.versions.add(JSON.stringify(meta));
|
|
280
281
|
};
|
|
282
|
+
let useInertPolyfill = () => {
|
|
283
|
+
let loaded = React.useRef(false);
|
|
284
|
+
let modulePath =
|
|
285
|
+
'https://cdn.jsdelivr.net/npm/wicg-inert@3.1.2/dist/inert.min.js';
|
|
286
|
+
React.useEffect(() => {
|
|
287
|
+
(async () => {
|
|
288
|
+
if (
|
|
289
|
+
!HTMLElement.prototype.hasOwnProperty('inert') &&
|
|
290
|
+
!loaded.current &&
|
|
291
|
+
!isUnitTest
|
|
292
|
+
) {
|
|
293
|
+
await new Function('url', 'return import(url)')(modulePath);
|
|
294
|
+
loaded.current = true;
|
|
295
|
+
}
|
|
296
|
+
})();
|
|
297
|
+
}, []);
|
|
298
|
+
};
|
|
@@ -8,11 +8,10 @@ import {
|
|
|
8
8
|
Box,
|
|
9
9
|
useSafeContext,
|
|
10
10
|
ButtonBase,
|
|
11
|
+
useMediaQuery,
|
|
11
12
|
} from '../../utils/index.js';
|
|
12
13
|
import { IconButton } from '../Buttons/IconButton.js';
|
|
13
14
|
import { ToasterStateContext } from './Toaster.js';
|
|
14
|
-
let isMotionOk = () =>
|
|
15
|
-
getWindow()?.matchMedia?.('(prefers-reduced-motion: no-preference)')?.matches;
|
|
16
15
|
export const Toast = (props) => {
|
|
17
16
|
let {
|
|
18
17
|
content,
|
|
@@ -34,6 +33,7 @@ export const Toast = (props) => {
|
|
|
34
33
|
let [height, setHeight] = React.useState(0);
|
|
35
34
|
let thisElement = React.useRef(null);
|
|
36
35
|
let [margin, setMargin] = React.useState(0);
|
|
36
|
+
let motionOk = useMediaQuery('(prefers-reduced-motion: no-preference)');
|
|
37
37
|
let marginStyle = () => {
|
|
38
38
|
if ('top' === placementPosition)
|
|
39
39
|
return {
|
|
@@ -98,16 +98,16 @@ export const Toast = (props) => {
|
|
|
98
98
|
appear: true,
|
|
99
99
|
unmountOnExit: true,
|
|
100
100
|
onEnter: (node) => {
|
|
101
|
-
if (
|
|
101
|
+
if (motionOk) {
|
|
102
102
|
node.style.transform = 'translateY(15%)';
|
|
103
103
|
node.style.transitionTimingFunction = 'ease';
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
onEntered: (node) => {
|
|
107
|
-
if (
|
|
107
|
+
if (motionOk) node.style.transform = 'translateY(0)';
|
|
108
108
|
},
|
|
109
109
|
onExiting: (node) => {
|
|
110
|
-
if (
|
|
110
|
+
if (motionOk) {
|
|
111
111
|
let { translateX, translateY } = calculateOutAnimation(node);
|
|
112
112
|
node.style.transform = animateOutTo
|
|
113
113
|
? `scale(0.9) translate(${translateX}px,${translateY}px)`
|
package/DEV-esm/styles.js
CHANGED