@itwin/itwinui-react 3.18.0 → 3.18.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 +19 -0
- package/DEV-cjs/core/Dialog/Dialog.js +4 -6
- package/DEV-cjs/core/Dialog/DialogBackdrop.js +5 -5
- package/DEV-cjs/core/Dialog/DialogContext.js +1 -1
- package/DEV-cjs/core/Dialog/DialogMain.js +18 -13
- package/DEV-cjs/core/Dialog/DialogTitleBar.js +3 -3
- package/DEV-cjs/core/Menu/MenuItem.js +14 -10
- package/DEV-cjs/core/Popover/Popover.js +2 -1
- package/DEV-cjs/core/Table/Table.js +11 -13
- package/DEV-cjs/core/Table/TableCell.js +87 -52
- package/DEV-cjs/core/Table/cells/DefaultCell.js +35 -9
- package/DEV-cjs/core/Tooltip/Tooltip.js +1 -1
- package/DEV-cjs/styles.js +1 -1
- package/DEV-esm/core/Dialog/Dialog.js +4 -2
- package/DEV-esm/core/Dialog/DialogBackdrop.js +5 -5
- package/DEV-esm/core/Dialog/DialogContext.js +1 -1
- package/DEV-esm/core/Dialog/DialogMain.js +13 -13
- package/DEV-esm/core/Dialog/DialogTitleBar.js +3 -3
- package/DEV-esm/core/Menu/MenuItem.js +13 -10
- package/DEV-esm/core/Popover/Popover.js +2 -1
- package/DEV-esm/core/Table/Table.js +12 -13
- package/DEV-esm/core/Table/TableCell.js +87 -52
- package/DEV-esm/core/Table/cells/DefaultCell.js +23 -6
- package/DEV-esm/core/Tooltip/Tooltip.js +1 -1
- package/DEV-esm/styles.js +1 -1
- package/cjs/core/Dialog/Dialog.js +4 -6
- package/cjs/core/Dialog/DialogBackdrop.js +5 -5
- package/cjs/core/Dialog/DialogContext.d.ts +7 -6
- package/cjs/core/Dialog/DialogContext.js +1 -1
- package/cjs/core/Dialog/DialogMain.d.ts +1 -1
- package/cjs/core/Dialog/DialogMain.js +18 -13
- package/cjs/core/Dialog/DialogTitleBar.js +3 -3
- package/cjs/core/Menu/MenuItem.js +14 -10
- package/cjs/core/Popover/Popover.js +2 -1
- package/cjs/core/Table/Table.js +11 -13
- package/cjs/core/Table/TableCell.js +87 -52
- package/cjs/core/Table/cells/DefaultCell.d.ts +1 -0
- package/cjs/core/Table/cells/DefaultCell.js +35 -9
- package/cjs/core/Tooltip/Tooltip.js +1 -1
- package/cjs/styles.js +1 -1
- package/esm/core/Dialog/Dialog.js +4 -2
- package/esm/core/Dialog/DialogBackdrop.js +5 -5
- package/esm/core/Dialog/DialogContext.d.ts +7 -6
- package/esm/core/Dialog/DialogContext.js +1 -1
- package/esm/core/Dialog/DialogMain.d.ts +1 -1
- package/esm/core/Dialog/DialogMain.js +13 -13
- package/esm/core/Dialog/DialogTitleBar.js +3 -3
- package/esm/core/Menu/MenuItem.js +13 -10
- package/esm/core/Popover/Popover.js +2 -1
- package/esm/core/Table/Table.js +12 -13
- package/esm/core/Table/TableCell.js +87 -52
- package/esm/core/Table/cells/DefaultCell.d.ts +1 -0
- package/esm/core/Table/cells/DefaultCell.js +23 -6
- package/esm/core/Tooltip/Tooltip.js +1 -1
- package/esm/styles.js +1 -1
- package/package.json +2 -2
- package/styles.css +10 -10
|
@@ -13,27 +13,27 @@ import { useDialogContext } from './DialogContext.js';
|
|
|
13
13
|
import { DialogDragContext } from './DialogDragContext.js';
|
|
14
14
|
import { useDragAndDrop } from '../../utils/hooks/useDragAndDrop.js';
|
|
15
15
|
import { DialogMainContext } from './DialogMainContext.js';
|
|
16
|
-
export const DialogMain = React.forwardRef((props,
|
|
16
|
+
export const DialogMain = React.forwardRef((props, forwardedRef) => {
|
|
17
17
|
let dialogContext = useDialogContext();
|
|
18
18
|
let {
|
|
19
19
|
className,
|
|
20
20
|
children,
|
|
21
21
|
styleType = 'default',
|
|
22
|
-
isOpen = dialogContext
|
|
23
|
-
isDismissible = dialogContext
|
|
24
|
-
onClose = dialogContext
|
|
25
|
-
closeOnEsc = dialogContext
|
|
26
|
-
trapFocus = dialogContext
|
|
27
|
-
setFocus = dialogContext
|
|
28
|
-
preventDocumentScroll = dialogContext
|
|
22
|
+
isOpen = dialogContext?.isOpen,
|
|
23
|
+
isDismissible = dialogContext?.isDismissible,
|
|
24
|
+
onClose = dialogContext?.onClose,
|
|
25
|
+
closeOnEsc = dialogContext?.closeOnEsc,
|
|
26
|
+
trapFocus = dialogContext?.trapFocus,
|
|
27
|
+
setFocus = dialogContext?.setFocus,
|
|
28
|
+
preventDocumentScroll = dialogContext?.preventDocumentScroll,
|
|
29
29
|
onKeyDown,
|
|
30
|
-
isDraggable = dialogContext
|
|
31
|
-
isResizable = dialogContext
|
|
30
|
+
isDraggable = dialogContext?.isDraggable,
|
|
31
|
+
isResizable = dialogContext?.isResizable,
|
|
32
32
|
style: propStyle,
|
|
33
|
-
placement = dialogContext
|
|
33
|
+
placement = dialogContext?.placement,
|
|
34
34
|
...rest
|
|
35
35
|
} = props;
|
|
36
|
-
let { dialogRootRef } = dialogContext;
|
|
36
|
+
let { dialogRootRef, setDialogElement } = dialogContext || {};
|
|
37
37
|
let dialogRef = React.useRef(null);
|
|
38
38
|
let previousFocusedElement = React.useRef(null);
|
|
39
39
|
let [style, setStyle] = React.useState();
|
|
@@ -130,7 +130,7 @@ export const DialogMain = React.forwardRef((props, ref) => {
|
|
|
130
130
|
className,
|
|
131
131
|
),
|
|
132
132
|
role: 'dialog',
|
|
133
|
-
ref: useMergedRefs(dialogRef, mountRef,
|
|
133
|
+
ref: useMergedRefs(dialogRef, mountRef, setDialogElement, forwardedRef),
|
|
134
134
|
onKeyDown: handleKeyDown,
|
|
135
135
|
tabIndex: -1,
|
|
136
136
|
'data-iui-placement': placement,
|
|
@@ -13,9 +13,9 @@ export const DialogTitleBar = Object.assign(
|
|
|
13
13
|
let {
|
|
14
14
|
children,
|
|
15
15
|
titleText,
|
|
16
|
-
isDismissible = dialogContext
|
|
17
|
-
onClose = dialogContext
|
|
18
|
-
isDraggable = dialogContext
|
|
16
|
+
isDismissible = dialogContext?.isDismissible,
|
|
17
|
+
onClose = dialogContext?.onClose,
|
|
18
|
+
isDraggable = dialogContext?.isDraggable,
|
|
19
19
|
className,
|
|
20
20
|
onPointerDown: onPointerDownProp,
|
|
21
21
|
...rest
|
|
@@ -31,19 +31,22 @@ export const MenuItem = React.forwardRef((props, forwardedRef) => {
|
|
|
31
31
|
...rest
|
|
32
32
|
} = props;
|
|
33
33
|
let logWarning = useWarningLogger();
|
|
34
|
+
let hasSubMenu = React.useMemo(
|
|
35
|
+
() => subMenuItems.length > 0,
|
|
36
|
+
[subMenuItems.length],
|
|
37
|
+
);
|
|
34
38
|
if (
|
|
35
39
|
'development' === process.env.NODE_ENV &&
|
|
36
40
|
null != onClickProp &&
|
|
37
|
-
|
|
41
|
+
hasSubMenu
|
|
38
42
|
)
|
|
39
43
|
logWarning(
|
|
40
44
|
'Passing a non-empty submenuItems array and onClick to MenuItem at the same time is not supported. This is because when a non empty submenuItems array is passed, clicking the MenuItem toggles the submenu visibility.',
|
|
41
45
|
);
|
|
42
46
|
let parentMenu = React.useContext(MenuContext);
|
|
43
47
|
let dropdownMenu = React.useContext(DropdownMenuContext);
|
|
44
|
-
let shouldCloseMenuOnClick =
|
|
45
|
-
DropdownMenuCloseOnClickContext
|
|
46
|
-
);
|
|
48
|
+
let shouldCloseMenuOnClick =
|
|
49
|
+
React.useContext(DropdownMenuCloseOnClickContext) && !hasSubMenu;
|
|
47
50
|
let menuItemRef = React.useRef(null);
|
|
48
51
|
let submenuId = useId();
|
|
49
52
|
let popoverProps = React.useMemo(
|
|
@@ -53,12 +56,12 @@ export const MenuItem = React.forwardRef((props, forwardedRef) => {
|
|
|
53
56
|
click: true,
|
|
54
57
|
hover: true,
|
|
55
58
|
listNavigation: {
|
|
56
|
-
nested:
|
|
59
|
+
nested: hasSubMenu,
|
|
57
60
|
openOnArrowKeyDown: true,
|
|
58
61
|
},
|
|
59
62
|
},
|
|
60
63
|
}),
|
|
61
|
-
[
|
|
64
|
+
[hasSubMenu],
|
|
62
65
|
);
|
|
63
66
|
let onClick = () => {
|
|
64
67
|
if (disabled) return;
|
|
@@ -85,8 +88,8 @@ export const MenuItem = React.forwardRef((props, forwardedRef) => {
|
|
|
85
88
|
role: role,
|
|
86
89
|
tabIndex: isSelected ? 0 : -1,
|
|
87
90
|
'aria-selected': isSelected,
|
|
88
|
-
'aria-haspopup':
|
|
89
|
-
'aria-controls':
|
|
91
|
+
'aria-haspopup': hasSubMenu ? 'true' : void 0,
|
|
92
|
+
'aria-controls': hasSubMenu ? submenuId : void 0,
|
|
90
93
|
'aria-disabled': disabled,
|
|
91
94
|
...(parentMenu?.popoverGetItemProps != null
|
|
92
95
|
? parentMenu.popoverGetItemProps({
|
|
@@ -112,7 +115,7 @@ export const MenuItem = React.forwardRef((props, forwardedRef) => {
|
|
|
112
115
|
sublabel && React.createElement(ListItem.Description, null, sublabel),
|
|
113
116
|
),
|
|
114
117
|
!endIcon &&
|
|
115
|
-
|
|
118
|
+
hasSubMenu &&
|
|
116
119
|
React.createElement(
|
|
117
120
|
ListItem.Icon,
|
|
118
121
|
{
|
|
@@ -134,7 +137,7 @@ export const MenuItem = React.forwardRef((props, forwardedRef) => {
|
|
|
134
137
|
return React.createElement(
|
|
135
138
|
React.Fragment,
|
|
136
139
|
null,
|
|
137
|
-
|
|
140
|
+
hasSubMenu && !disabled
|
|
138
141
|
? React.createElement(
|
|
139
142
|
Menu,
|
|
140
143
|
{
|
|
@@ -86,7 +86,6 @@ export const usePopover = (options) => {
|
|
|
86
86
|
open,
|
|
87
87
|
onOpenChange,
|
|
88
88
|
strategy: 'fixed',
|
|
89
|
-
transform: false,
|
|
90
89
|
whileElementsMounted: React.useMemo(
|
|
91
90
|
() =>
|
|
92
91
|
open ? (...args) => autoUpdate(...args, autoUpdateOptions) : void 0,
|
|
@@ -238,6 +237,7 @@ export const Popover = React.forwardRef((props, forwardedRef) => {
|
|
|
238
237
|
closeOnOutsideClick,
|
|
239
238
|
role: 'dialog',
|
|
240
239
|
middleware,
|
|
240
|
+
transform: false,
|
|
241
241
|
});
|
|
242
242
|
let [popoverElement, setPopoverElement] = React.useState(null);
|
|
243
243
|
let popoverRef = useMergedRefs(
|
|
@@ -304,6 +304,7 @@ export const Popover = React.forwardRef((props, forwardedRef) => {
|
|
|
304
304
|
Box,
|
|
305
305
|
{
|
|
306
306
|
className: cx(
|
|
307
|
+
'iui-popover',
|
|
307
308
|
{
|
|
308
309
|
'iui-popover-surface': applyBackground,
|
|
309
310
|
},
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
useMergedRefs,
|
|
24
24
|
useLatestRef,
|
|
25
25
|
useVirtualScroll,
|
|
26
|
+
useId,
|
|
26
27
|
} from '../../utils/index.js';
|
|
27
28
|
import { TableInstanceContext } from './utils.js';
|
|
28
29
|
import { TableRowMemoized } from './TableRowMemoized.js';
|
|
@@ -111,6 +112,7 @@ export const Table = (props) => {
|
|
|
111
112
|
getRowId,
|
|
112
113
|
caption = 'Table',
|
|
113
114
|
role,
|
|
115
|
+
scrollToRow,
|
|
114
116
|
..._rest
|
|
115
117
|
} = props;
|
|
116
118
|
let { ariaRestAttributes, nonAriaRestAttributes } = React.useMemo(
|
|
@@ -456,6 +458,7 @@ export const Table = (props) => {
|
|
|
456
458
|
let tableRef = React.useRef(null);
|
|
457
459
|
let { scrollToIndex, tableRowRef } = useScrollToRow({
|
|
458
460
|
...props,
|
|
461
|
+
scrollToRow,
|
|
459
462
|
page,
|
|
460
463
|
});
|
|
461
464
|
let columnRefs = React.useRef({});
|
|
@@ -598,7 +601,7 @@ export const Table = (props) => {
|
|
|
598
601
|
React.useEffect(() => {
|
|
599
602
|
updateStickyState();
|
|
600
603
|
}, []);
|
|
601
|
-
let captionId =
|
|
604
|
+
let captionId = useId();
|
|
602
605
|
return React.createElement(
|
|
603
606
|
TableInstanceContext.Provider,
|
|
604
607
|
{
|
|
@@ -623,7 +626,6 @@ export const Table = (props) => {
|
|
|
623
626
|
},
|
|
624
627
|
}),
|
|
625
628
|
role: role,
|
|
626
|
-
'aria-labelledby': captionId,
|
|
627
629
|
onScroll: () => updateStickyState(),
|
|
628
630
|
'data-iui-size': 'default' === density ? void 0 : density,
|
|
629
631
|
...outerAriaRestAttributes,
|
|
@@ -638,10 +640,15 @@ export const Table = (props) => {
|
|
|
638
640
|
role: 'table',
|
|
639
641
|
...innerAriaRestAttributes,
|
|
640
642
|
...tableProps,
|
|
643
|
+
'aria-labelledby': captionId,
|
|
641
644
|
},
|
|
642
|
-
React.createElement(
|
|
643
|
-
|
|
644
|
-
|
|
645
|
+
React.createElement(
|
|
646
|
+
VisuallyHidden,
|
|
647
|
+
{
|
|
648
|
+
id: captionId,
|
|
649
|
+
},
|
|
650
|
+
caption,
|
|
651
|
+
),
|
|
645
652
|
React.createElement('slot', {
|
|
646
653
|
name: 'iui-table-header-wrapper',
|
|
647
654
|
}),
|
|
@@ -654,14 +661,6 @@ export const Table = (props) => {
|
|
|
654
661
|
}),
|
|
655
662
|
React.createElement('slot', null),
|
|
656
663
|
),
|
|
657
|
-
React.createElement(
|
|
658
|
-
VisuallyHidden,
|
|
659
|
-
{
|
|
660
|
-
slot: 'caption',
|
|
661
|
-
id: captionId,
|
|
662
|
-
},
|
|
663
|
-
caption,
|
|
664
|
-
),
|
|
665
664
|
headerGroups.map((headerGroup) => {
|
|
666
665
|
headerGroup.headers = headerGroup.headers.filter(
|
|
667
666
|
(header) =>
|
|
@@ -5,6 +5,7 @@ import { SubRowExpander } from './SubRowExpander.js';
|
|
|
5
5
|
import { SELECTION_CELL_ID } from './columns/index.js';
|
|
6
6
|
import { DefaultCell } from './cells/index.js';
|
|
7
7
|
import { Box } from '../../utils/index.js';
|
|
8
|
+
import { DefaultCellRendererPropsChildren } from './cells/DefaultCell.js';
|
|
8
9
|
export const TableCell = (props) => {
|
|
9
10
|
let {
|
|
10
11
|
cell,
|
|
@@ -33,63 +34,97 @@ export const TableCell = (props) => {
|
|
|
33
34
|
...getStickyStyle(cell.column, tableInstance.visibleColumns),
|
|
34
35
|
},
|
|
35
36
|
});
|
|
36
|
-
let cellProps =
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
let cellProps = React.useMemo(
|
|
38
|
+
() => ({
|
|
39
|
+
...tableInstance,
|
|
40
|
+
...{
|
|
41
|
+
cell,
|
|
42
|
+
row: cell.row,
|
|
43
|
+
value: cell.value,
|
|
44
|
+
column: cell.column,
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
[cell, tableInstance],
|
|
48
|
+
);
|
|
49
|
+
let cellContent = React.useMemo(
|
|
50
|
+
() =>
|
|
51
|
+
React.createElement(
|
|
52
|
+
React.Fragment,
|
|
53
|
+
null,
|
|
54
|
+
tableHasSubRows &&
|
|
55
|
+
hasSubRowExpander &&
|
|
56
|
+
cell.row.canExpand &&
|
|
57
|
+
React.createElement(SubRowExpander, {
|
|
58
|
+
cell: cell,
|
|
59
|
+
isDisabled: isDisabled,
|
|
60
|
+
cellProps: cellProps,
|
|
61
|
+
expanderCell: expanderCell,
|
|
62
|
+
density: density,
|
|
63
|
+
slot: 'start',
|
|
64
|
+
}),
|
|
65
|
+
cell.render('Cell'),
|
|
66
|
+
),
|
|
67
|
+
[
|
|
39
68
|
cell,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
null,
|
|
48
|
-
tableHasSubRows &&
|
|
49
|
-
hasSubRowExpander &&
|
|
50
|
-
cell.row.canExpand &&
|
|
51
|
-
React.createElement(SubRowExpander, {
|
|
52
|
-
cell: cell,
|
|
53
|
-
isDisabled: isDisabled,
|
|
54
|
-
cellProps: cellProps,
|
|
55
|
-
expanderCell: expanderCell,
|
|
56
|
-
density: density,
|
|
57
|
-
slot: 'start',
|
|
58
|
-
}),
|
|
59
|
-
cell.render('Cell'),
|
|
69
|
+
cellProps,
|
|
70
|
+
density,
|
|
71
|
+
expanderCell,
|
|
72
|
+
hasSubRowExpander,
|
|
73
|
+
isDisabled,
|
|
74
|
+
tableHasSubRows,
|
|
75
|
+
],
|
|
60
76
|
);
|
|
61
|
-
let
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
let defaultCellRendererChildren = React.useMemo(
|
|
78
|
+
() =>
|
|
79
|
+
React.createElement(
|
|
80
|
+
React.Fragment,
|
|
81
|
+
null,
|
|
82
|
+
cellContent,
|
|
83
|
+
'left' === cell.column.sticky &&
|
|
84
|
+
tableInstance.state.sticky.isScrolledToRight &&
|
|
85
|
+
React.createElement(Box, {
|
|
86
|
+
className: 'iui-table-cell-shadow-right',
|
|
87
|
+
slot: 'shadows',
|
|
88
|
+
}),
|
|
89
|
+
'right' === cell.column.sticky &&
|
|
90
|
+
tableInstance.state.sticky.isScrolledToLeft &&
|
|
91
|
+
React.createElement(Box, {
|
|
92
|
+
className: 'iui-table-cell-shadow-left',
|
|
93
|
+
slot: 'shadows',
|
|
94
|
+
}),
|
|
95
|
+
),
|
|
96
|
+
[
|
|
97
|
+
cell.column.sticky,
|
|
67
98
|
cellContent,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
),
|
|
81
|
-
};
|
|
99
|
+
tableInstance.state.sticky.isScrolledToLeft,
|
|
100
|
+
tableInstance.state.sticky.isScrolledToRight,
|
|
101
|
+
],
|
|
102
|
+
);
|
|
103
|
+
let cellRendererProps = React.useMemo(
|
|
104
|
+
() => ({
|
|
105
|
+
cellElementProps,
|
|
106
|
+
cellProps,
|
|
107
|
+
children: defaultCellRendererChildren,
|
|
108
|
+
}),
|
|
109
|
+
[cellElementProps, cellProps, defaultCellRendererChildren],
|
|
110
|
+
);
|
|
82
111
|
return React.createElement(
|
|
83
112
|
React.Fragment,
|
|
84
113
|
null,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
114
|
+
React.createElement(
|
|
115
|
+
DefaultCellRendererPropsChildren.Provider,
|
|
116
|
+
{
|
|
117
|
+
value: defaultCellRendererChildren,
|
|
118
|
+
},
|
|
119
|
+
cell.column.cellRenderer
|
|
120
|
+
? cell.column.cellRenderer({
|
|
121
|
+
...cellRendererProps,
|
|
122
|
+
isDisabled: () => isDisabled,
|
|
123
|
+
})
|
|
124
|
+
: React.createElement(DefaultCell, {
|
|
125
|
+
...cellRendererProps,
|
|
126
|
+
isDisabled: () => isDisabled,
|
|
127
|
+
}),
|
|
128
|
+
),
|
|
94
129
|
);
|
|
95
130
|
};
|
|
@@ -3,6 +3,7 @@ import { defaultColumn } from 'react-table';
|
|
|
3
3
|
import cx from 'classnames';
|
|
4
4
|
import { Box, LineClamp, ShadowRoot } from '../../../utils/index.js';
|
|
5
5
|
import { TableInstanceContext } from '../utils.js';
|
|
6
|
+
export const DefaultCellRendererPropsChildren = React.createContext(void 0);
|
|
6
7
|
export const DefaultCell = (props) => {
|
|
7
8
|
let instance = React.useContext(TableInstanceContext);
|
|
8
9
|
let isCustomCell = React.useMemo(
|
|
@@ -11,6 +12,8 @@ export const DefaultCell = (props) => {
|
|
|
11
12
|
?.Cell !== defaultColumn.Cell,
|
|
12
13
|
[instance, props.cellProps.column.id],
|
|
13
14
|
);
|
|
15
|
+
let isCellRendererChildrenCustom =
|
|
16
|
+
React.useContext(DefaultCellRendererPropsChildren) !== props.children;
|
|
14
17
|
let {
|
|
15
18
|
cellElementProps: {
|
|
16
19
|
className: cellElementClassName,
|
|
@@ -25,7 +28,9 @@ export const DefaultCell = (props) => {
|
|
|
25
28
|
className,
|
|
26
29
|
style,
|
|
27
30
|
status,
|
|
28
|
-
clamp = 'string' == typeof cellProps.value &&
|
|
31
|
+
clamp = 'string' == typeof cellProps.value &&
|
|
32
|
+
!isCustomCell &&
|
|
33
|
+
!isCellRendererChildrenCustom,
|
|
29
34
|
...rest
|
|
30
35
|
} = props;
|
|
31
36
|
let { key: cellElementKey, ...cellElementPropsRest } = cellElementProps;
|
|
@@ -54,10 +59,9 @@ export const DefaultCell = (props) => {
|
|
|
54
59
|
name: 'start',
|
|
55
60
|
}),
|
|
56
61
|
React.createElement(
|
|
57
|
-
|
|
62
|
+
TableCellContent,
|
|
58
63
|
{
|
|
59
|
-
|
|
60
|
-
onClick: (e) => e.stopPropagation(),
|
|
64
|
+
shouldRenderWrapper: isCellRendererChildrenCustom,
|
|
61
65
|
},
|
|
62
66
|
clamp
|
|
63
67
|
? React.createElement(
|
|
@@ -99,12 +103,25 @@ export const DefaultCell = (props) => {
|
|
|
99
103
|
};
|
|
100
104
|
if ('development' === process.env.NODE_ENV)
|
|
101
105
|
DefaultCell.displayName = 'DefaultCell';
|
|
106
|
+
let TableCellContent = (props) => {
|
|
107
|
+
let { children, shouldRenderWrapper } = props;
|
|
108
|
+
return shouldRenderWrapper
|
|
109
|
+
? children
|
|
110
|
+
: React.createElement(
|
|
111
|
+
'div',
|
|
112
|
+
{
|
|
113
|
+
className: '_iui-table-cell-default-content',
|
|
114
|
+
onClick: (e) => e.stopPropagation(),
|
|
115
|
+
},
|
|
116
|
+
children,
|
|
117
|
+
);
|
|
118
|
+
};
|
|
102
119
|
let css = `
|
|
103
|
-
._iui-table-cell-
|
|
120
|
+
._iui-table-cell-default-content {
|
|
104
121
|
position: relative;
|
|
105
122
|
isolation: isolate;
|
|
106
123
|
}
|
|
107
|
-
._iui-table-cell-
|
|
124
|
+
._iui-table-cell-default-content::before {
|
|
108
125
|
content: '';
|
|
109
126
|
display: block;
|
|
110
127
|
position: absolute;
|
package/DEV-esm/styles.js
CHANGED
|
@@ -21,7 +21,7 @@ const _DialogContext = require('./DialogContext.js');
|
|
|
21
21
|
const _DialogButtonBar = require('./DialogButtonBar.js');
|
|
22
22
|
const _DialogMain = require('./DialogMain.js');
|
|
23
23
|
const _index = require('../../utils/index.js');
|
|
24
|
-
const DialogComponent = _react.forwardRef((props,
|
|
24
|
+
const DialogComponent = _react.forwardRef((props, forwardedRef) => {
|
|
25
25
|
let {
|
|
26
26
|
trapFocus = false,
|
|
27
27
|
setFocus = trapFocus,
|
|
@@ -41,11 +41,7 @@ const DialogComponent = _react.forwardRef((props, ref) => {
|
|
|
41
41
|
} = props;
|
|
42
42
|
let dialogRootRef = _react.useRef(null);
|
|
43
43
|
let [dialogElement, setDialogElement] = _react.useState(null);
|
|
44
|
-
let mergedRefs = (0, _index.useMergedRefs)(
|
|
45
|
-
ref,
|
|
46
|
-
dialogRootRef,
|
|
47
|
-
setDialogElement,
|
|
48
|
-
);
|
|
44
|
+
let mergedRefs = (0, _index.useMergedRefs)(forwardedRef, dialogRootRef);
|
|
49
45
|
return isOpen
|
|
50
46
|
? _react.createElement(
|
|
51
47
|
_DialogContext.DialogContext.Provider,
|
|
@@ -63,6 +59,8 @@ const DialogComponent = _react.forwardRef((props, ref) => {
|
|
|
63
59
|
isResizable,
|
|
64
60
|
relativeTo,
|
|
65
61
|
placement,
|
|
62
|
+
dialogRootRef,
|
|
63
|
+
setDialogElement,
|
|
66
64
|
},
|
|
67
65
|
},
|
|
68
66
|
_react.createElement(
|
|
@@ -22,11 +22,11 @@ const DialogBackdrop = _react.forwardRef((props, ref) => {
|
|
|
22
22
|
let dialogContext = (0, _DialogContext.useDialogContext)();
|
|
23
23
|
let dialogMainContext = (0, _DialogMainContext.useDialogMainContext)();
|
|
24
24
|
let {
|
|
25
|
-
isVisible = dialogContext
|
|
26
|
-
isDismissible = dialogContext
|
|
27
|
-
onClose = dialogContext
|
|
28
|
-
closeOnExternalClick = dialogContext
|
|
29
|
-
relativeTo = dialogContext
|
|
25
|
+
isVisible = dialogContext?.isOpen,
|
|
26
|
+
isDismissible = dialogContext?.isDismissible,
|
|
27
|
+
onClose = dialogContext?.onClose,
|
|
28
|
+
closeOnExternalClick = dialogContext?.closeOnExternalClick,
|
|
29
|
+
relativeTo = dialogContext?.relativeTo,
|
|
30
30
|
onMouseDown,
|
|
31
31
|
className,
|
|
32
32
|
style,
|
|
@@ -80,14 +80,15 @@ export type DialogContextProps = {
|
|
|
80
80
|
* Defaults to false if using `Dialog` and true if using `Modal`.
|
|
81
81
|
*/
|
|
82
82
|
portal?: PortalProps['portal'];
|
|
83
|
-
/**
|
|
84
|
-
* Dialog root ref. For internal use.
|
|
85
|
-
*/
|
|
86
|
-
dialogRootRef?: React.RefObject<HTMLDivElement | null>;
|
|
87
83
|
/**
|
|
88
84
|
* Determines the positioning of Dialog on page.
|
|
89
85
|
*/
|
|
90
86
|
placement?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
91
87
|
};
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
type DialogContextInternalProps = {
|
|
89
|
+
dialogRootRef: React.RefObject<HTMLDivElement | null>;
|
|
90
|
+
setDialogElement: (dialogElement: HTMLElement | null) => void;
|
|
91
|
+
};
|
|
92
|
+
export declare const DialogContext: React.Context<(DialogContextProps & DialogContextInternalProps) | undefined>;
|
|
93
|
+
export declare const useDialogContext: () => (DialogContextProps & DialogContextInternalProps) | undefined;
|
|
94
|
+
export {};
|
|
@@ -20,4 +20,4 @@ _export(exports, {
|
|
|
20
20
|
const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
|
|
21
21
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require('react'));
|
|
22
22
|
const DialogContext = _react.createContext(void 0);
|
|
23
|
-
const useDialogContext = () => _react.useContext(DialogContext)
|
|
23
|
+
const useDialogContext = () => _react.useContext(DialogContext);
|
|
@@ -11,7 +11,7 @@ export type DialogMainProps = {
|
|
|
11
11
|
* Content of the dialog.
|
|
12
12
|
*/
|
|
13
13
|
children: React.ReactNode;
|
|
14
|
-
} & Omit<DialogContextProps, 'closeOnExternalClick'
|
|
14
|
+
} & Omit<DialogContextProps, 'closeOnExternalClick'>;
|
|
15
15
|
/**
|
|
16
16
|
* Dialog component which can wrap any content.
|
|
17
17
|
* @example
|
|
@@ -19,27 +19,27 @@ const _DialogContext = require('./DialogContext.js');
|
|
|
19
19
|
const _DialogDragContext = require('./DialogDragContext.js');
|
|
20
20
|
const _useDragAndDrop = require('../../utils/hooks/useDragAndDrop.js');
|
|
21
21
|
const _DialogMainContext = require('./DialogMainContext.js');
|
|
22
|
-
const DialogMain = _react.forwardRef((props,
|
|
22
|
+
const DialogMain = _react.forwardRef((props, forwardedRef) => {
|
|
23
23
|
let dialogContext = (0, _DialogContext.useDialogContext)();
|
|
24
24
|
let {
|
|
25
25
|
className,
|
|
26
26
|
children,
|
|
27
27
|
styleType = 'default',
|
|
28
|
-
isOpen = dialogContext
|
|
29
|
-
isDismissible = dialogContext
|
|
30
|
-
onClose = dialogContext
|
|
31
|
-
closeOnEsc = dialogContext
|
|
32
|
-
trapFocus = dialogContext
|
|
33
|
-
setFocus = dialogContext
|
|
34
|
-
preventDocumentScroll = dialogContext
|
|
28
|
+
isOpen = dialogContext?.isOpen,
|
|
29
|
+
isDismissible = dialogContext?.isDismissible,
|
|
30
|
+
onClose = dialogContext?.onClose,
|
|
31
|
+
closeOnEsc = dialogContext?.closeOnEsc,
|
|
32
|
+
trapFocus = dialogContext?.trapFocus,
|
|
33
|
+
setFocus = dialogContext?.setFocus,
|
|
34
|
+
preventDocumentScroll = dialogContext?.preventDocumentScroll,
|
|
35
35
|
onKeyDown,
|
|
36
|
-
isDraggable = dialogContext
|
|
37
|
-
isResizable = dialogContext
|
|
36
|
+
isDraggable = dialogContext?.isDraggable,
|
|
37
|
+
isResizable = dialogContext?.isResizable,
|
|
38
38
|
style: propStyle,
|
|
39
|
-
placement = dialogContext
|
|
39
|
+
placement = dialogContext?.placement,
|
|
40
40
|
...rest
|
|
41
41
|
} = props;
|
|
42
|
-
let { dialogRootRef } = dialogContext;
|
|
42
|
+
let { dialogRootRef, setDialogElement } = dialogContext || {};
|
|
43
43
|
let dialogRef = _react.useRef(null);
|
|
44
44
|
let previousFocusedElement = _react.useRef(null);
|
|
45
45
|
let [style, setStyle] = _react.useState();
|
|
@@ -136,7 +136,12 @@ const DialogMain = _react.forwardRef((props, ref) => {
|
|
|
136
136
|
className,
|
|
137
137
|
),
|
|
138
138
|
role: 'dialog',
|
|
139
|
-
ref: (0, _index.useMergedRefs)(
|
|
139
|
+
ref: (0, _index.useMergedRefs)(
|
|
140
|
+
dialogRef,
|
|
141
|
+
mountRef,
|
|
142
|
+
setDialogElement,
|
|
143
|
+
forwardedRef,
|
|
144
|
+
),
|
|
140
145
|
onKeyDown: handleKeyDown,
|
|
141
146
|
tabIndex: -1,
|
|
142
147
|
'data-iui-placement': placement,
|
|
@@ -27,9 +27,9 @@ const DialogTitleBar = Object.assign(
|
|
|
27
27
|
let {
|
|
28
28
|
children,
|
|
29
29
|
titleText,
|
|
30
|
-
isDismissible = dialogContext
|
|
31
|
-
onClose = dialogContext
|
|
32
|
-
isDraggable = dialogContext
|
|
30
|
+
isDismissible = dialogContext?.isDismissible,
|
|
31
|
+
onClose = dialogContext?.onClose,
|
|
32
|
+
isDraggable = dialogContext?.isDraggable,
|
|
33
33
|
className,
|
|
34
34
|
onPointerDown: onPointerDownProp,
|
|
35
35
|
...rest
|