@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
|
@@ -37,19 +37,23 @@ const MenuItem = _react.forwardRef((props, forwardedRef) => {
|
|
|
37
37
|
...rest
|
|
38
38
|
} = props;
|
|
39
39
|
let logWarning = (0, _index.useWarningLogger)();
|
|
40
|
+
let hasSubMenu = _react.useMemo(
|
|
41
|
+
() => subMenuItems.length > 0,
|
|
42
|
+
[subMenuItems.length],
|
|
43
|
+
);
|
|
40
44
|
if (
|
|
41
45
|
'development' === process.env.NODE_ENV &&
|
|
42
46
|
null != onClickProp &&
|
|
43
|
-
|
|
47
|
+
hasSubMenu
|
|
44
48
|
)
|
|
45
49
|
logWarning(
|
|
46
50
|
'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.',
|
|
47
51
|
);
|
|
48
52
|
let parentMenu = _react.useContext(_Menu.MenuContext);
|
|
49
53
|
let dropdownMenu = _react.useContext(_DropdownMenu.DropdownMenuContext);
|
|
50
|
-
let shouldCloseMenuOnClick =
|
|
51
|
-
_DropdownMenu.DropdownMenuCloseOnClickContext
|
|
52
|
-
|
|
54
|
+
let shouldCloseMenuOnClick =
|
|
55
|
+
_react.useContext(_DropdownMenu.DropdownMenuCloseOnClickContext) &&
|
|
56
|
+
!hasSubMenu;
|
|
53
57
|
let menuItemRef = _react.useRef(null);
|
|
54
58
|
let submenuId = (0, _index.useId)();
|
|
55
59
|
let popoverProps = _react.useMemo(
|
|
@@ -59,12 +63,12 @@ const MenuItem = _react.forwardRef((props, forwardedRef) => {
|
|
|
59
63
|
click: true,
|
|
60
64
|
hover: true,
|
|
61
65
|
listNavigation: {
|
|
62
|
-
nested:
|
|
66
|
+
nested: hasSubMenu,
|
|
63
67
|
openOnArrowKeyDown: true,
|
|
64
68
|
},
|
|
65
69
|
},
|
|
66
70
|
}),
|
|
67
|
-
[
|
|
71
|
+
[hasSubMenu],
|
|
68
72
|
);
|
|
69
73
|
let onClick = () => {
|
|
70
74
|
if (disabled) return;
|
|
@@ -91,8 +95,8 @@ const MenuItem = _react.forwardRef((props, forwardedRef) => {
|
|
|
91
95
|
role: role,
|
|
92
96
|
tabIndex: isSelected ? 0 : -1,
|
|
93
97
|
'aria-selected': isSelected,
|
|
94
|
-
'aria-haspopup':
|
|
95
|
-
'aria-controls':
|
|
98
|
+
'aria-haspopup': hasSubMenu ? 'true' : void 0,
|
|
99
|
+
'aria-controls': hasSubMenu ? submenuId : void 0,
|
|
96
100
|
'aria-disabled': disabled,
|
|
97
101
|
...(parentMenu?.popoverGetItemProps != null
|
|
98
102
|
? parentMenu.popoverGetItemProps({
|
|
@@ -119,7 +123,7 @@ const MenuItem = _react.forwardRef((props, forwardedRef) => {
|
|
|
119
123
|
_react.createElement(_ListItem.ListItem.Description, null, sublabel),
|
|
120
124
|
),
|
|
121
125
|
!endIcon &&
|
|
122
|
-
|
|
126
|
+
hasSubMenu &&
|
|
123
127
|
_react.createElement(
|
|
124
128
|
_ListItem.ListItem.Icon,
|
|
125
129
|
{
|
|
@@ -141,7 +145,7 @@ const MenuItem = _react.forwardRef((props, forwardedRef) => {
|
|
|
141
145
|
return _react.createElement(
|
|
142
146
|
_react.Fragment,
|
|
143
147
|
null,
|
|
144
|
-
|
|
148
|
+
hasSubMenu && !disabled
|
|
145
149
|
? _react.createElement(
|
|
146
150
|
_Menu.Menu,
|
|
147
151
|
{
|
|
@@ -82,7 +82,6 @@ const usePopover = (options) => {
|
|
|
82
82
|
open,
|
|
83
83
|
onOpenChange,
|
|
84
84
|
strategy: 'fixed',
|
|
85
|
-
transform: false,
|
|
86
85
|
whileElementsMounted: _react.useMemo(
|
|
87
86
|
() =>
|
|
88
87
|
open
|
|
@@ -237,6 +236,7 @@ const Popover = _react.forwardRef((props, forwardedRef) => {
|
|
|
237
236
|
closeOnOutsideClick,
|
|
238
237
|
role: 'dialog',
|
|
239
238
|
middleware,
|
|
239
|
+
transform: false,
|
|
240
240
|
});
|
|
241
241
|
let [popoverElement, setPopoverElement] = _react.useState(null);
|
|
242
242
|
let popoverRef = (0, _index.useMergedRefs)(
|
|
@@ -303,6 +303,7 @@ const Popover = _react.forwardRef((props, forwardedRef) => {
|
|
|
303
303
|
_index.Box,
|
|
304
304
|
{
|
|
305
305
|
className: (0, _classnames.default)(
|
|
306
|
+
'iui-popover',
|
|
306
307
|
{
|
|
307
308
|
'iui-popover-surface': applyBackground,
|
|
308
309
|
},
|
package/cjs/core/Table/Table.js
CHANGED
|
@@ -99,6 +99,7 @@ const Table = (props) => {
|
|
|
99
99
|
getRowId,
|
|
100
100
|
caption = 'Table',
|
|
101
101
|
role,
|
|
102
|
+
scrollToRow,
|
|
102
103
|
..._rest
|
|
103
104
|
} = props;
|
|
104
105
|
let { ariaRestAttributes, nonAriaRestAttributes } = _react.useMemo(
|
|
@@ -451,6 +452,7 @@ const Table = (props) => {
|
|
|
451
452
|
let tableRef = _react.useRef(null);
|
|
452
453
|
let { scrollToIndex, tableRowRef } = (0, _index1.useScrollToRow)({
|
|
453
454
|
...props,
|
|
455
|
+
scrollToRow,
|
|
454
456
|
page,
|
|
455
457
|
});
|
|
456
458
|
let columnRefs = _react.useRef({});
|
|
@@ -593,7 +595,7 @@ const Table = (props) => {
|
|
|
593
595
|
_react.useEffect(() => {
|
|
594
596
|
updateStickyState();
|
|
595
597
|
}, []);
|
|
596
|
-
let captionId =
|
|
598
|
+
let captionId = (0, _index.useId)();
|
|
597
599
|
return _react.createElement(
|
|
598
600
|
_utils.TableInstanceContext.Provider,
|
|
599
601
|
{
|
|
@@ -618,7 +620,6 @@ const Table = (props) => {
|
|
|
618
620
|
},
|
|
619
621
|
}),
|
|
620
622
|
role: role,
|
|
621
|
-
'aria-labelledby': captionId,
|
|
622
623
|
onScroll: () => updateStickyState(),
|
|
623
624
|
'data-iui-size': 'default' === density ? void 0 : density,
|
|
624
625
|
...outerAriaRestAttributes,
|
|
@@ -633,10 +634,15 @@ const Table = (props) => {
|
|
|
633
634
|
role: 'table',
|
|
634
635
|
...innerAriaRestAttributes,
|
|
635
636
|
...tableProps,
|
|
637
|
+
'aria-labelledby': captionId,
|
|
636
638
|
},
|
|
637
|
-
_react.createElement(
|
|
638
|
-
|
|
639
|
-
|
|
639
|
+
_react.createElement(
|
|
640
|
+
_VisuallyHidden.VisuallyHidden,
|
|
641
|
+
{
|
|
642
|
+
id: captionId,
|
|
643
|
+
},
|
|
644
|
+
caption,
|
|
645
|
+
),
|
|
640
646
|
_react.createElement('slot', {
|
|
641
647
|
name: 'iui-table-header-wrapper',
|
|
642
648
|
}),
|
|
@@ -649,14 +655,6 @@ const Table = (props) => {
|
|
|
649
655
|
}),
|
|
650
656
|
_react.createElement('slot', null),
|
|
651
657
|
),
|
|
652
|
-
_react.createElement(
|
|
653
|
-
_VisuallyHidden.VisuallyHidden,
|
|
654
|
-
{
|
|
655
|
-
slot: 'caption',
|
|
656
|
-
id: captionId,
|
|
657
|
-
},
|
|
658
|
-
caption,
|
|
659
|
-
),
|
|
660
658
|
headerGroups.map((headerGroup) => {
|
|
661
659
|
headerGroup.headers = headerGroup.headers.filter(
|
|
662
660
|
(header) =>
|
|
@@ -19,6 +19,7 @@ const _SubRowExpander = require('./SubRowExpander.js');
|
|
|
19
19
|
const _index = require('./columns/index.js');
|
|
20
20
|
const _index1 = require('./cells/index.js');
|
|
21
21
|
const _index2 = require('../../utils/index.js');
|
|
22
|
+
const _DefaultCell = require('./cells/DefaultCell.js');
|
|
22
23
|
const TableCell = (props) => {
|
|
23
24
|
let {
|
|
24
25
|
cell,
|
|
@@ -54,63 +55,97 @@ const TableCell = (props) => {
|
|
|
54
55
|
...(0, _utils.getStickyStyle)(cell.column, tableInstance.visibleColumns),
|
|
55
56
|
},
|
|
56
57
|
});
|
|
57
|
-
let cellProps =
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
let cellProps = _react.useMemo(
|
|
59
|
+
() => ({
|
|
60
|
+
...tableInstance,
|
|
61
|
+
...{
|
|
62
|
+
cell,
|
|
63
|
+
row: cell.row,
|
|
64
|
+
value: cell.value,
|
|
65
|
+
column: cell.column,
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
[cell, tableInstance],
|
|
69
|
+
);
|
|
70
|
+
let cellContent = _react.useMemo(
|
|
71
|
+
() =>
|
|
72
|
+
_react.createElement(
|
|
73
|
+
_react.Fragment,
|
|
74
|
+
null,
|
|
75
|
+
tableHasSubRows &&
|
|
76
|
+
hasSubRowExpander &&
|
|
77
|
+
cell.row.canExpand &&
|
|
78
|
+
_react.createElement(_SubRowExpander.SubRowExpander, {
|
|
79
|
+
cell: cell,
|
|
80
|
+
isDisabled: isDisabled,
|
|
81
|
+
cellProps: cellProps,
|
|
82
|
+
expanderCell: expanderCell,
|
|
83
|
+
density: density,
|
|
84
|
+
slot: 'start',
|
|
85
|
+
}),
|
|
86
|
+
cell.render('Cell'),
|
|
87
|
+
),
|
|
88
|
+
[
|
|
60
89
|
cell,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
null,
|
|
69
|
-
tableHasSubRows &&
|
|
70
|
-
hasSubRowExpander &&
|
|
71
|
-
cell.row.canExpand &&
|
|
72
|
-
_react.createElement(_SubRowExpander.SubRowExpander, {
|
|
73
|
-
cell: cell,
|
|
74
|
-
isDisabled: isDisabled,
|
|
75
|
-
cellProps: cellProps,
|
|
76
|
-
expanderCell: expanderCell,
|
|
77
|
-
density: density,
|
|
78
|
-
slot: 'start',
|
|
79
|
-
}),
|
|
80
|
-
cell.render('Cell'),
|
|
90
|
+
cellProps,
|
|
91
|
+
density,
|
|
92
|
+
expanderCell,
|
|
93
|
+
hasSubRowExpander,
|
|
94
|
+
isDisabled,
|
|
95
|
+
tableHasSubRows,
|
|
96
|
+
],
|
|
81
97
|
);
|
|
82
|
-
let
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
let defaultCellRendererChildren = _react.useMemo(
|
|
99
|
+
() =>
|
|
100
|
+
_react.createElement(
|
|
101
|
+
_react.Fragment,
|
|
102
|
+
null,
|
|
103
|
+
cellContent,
|
|
104
|
+
'left' === cell.column.sticky &&
|
|
105
|
+
tableInstance.state.sticky.isScrolledToRight &&
|
|
106
|
+
_react.createElement(_index2.Box, {
|
|
107
|
+
className: 'iui-table-cell-shadow-right',
|
|
108
|
+
slot: 'shadows',
|
|
109
|
+
}),
|
|
110
|
+
'right' === cell.column.sticky &&
|
|
111
|
+
tableInstance.state.sticky.isScrolledToLeft &&
|
|
112
|
+
_react.createElement(_index2.Box, {
|
|
113
|
+
className: 'iui-table-cell-shadow-left',
|
|
114
|
+
slot: 'shadows',
|
|
115
|
+
}),
|
|
116
|
+
),
|
|
117
|
+
[
|
|
118
|
+
cell.column.sticky,
|
|
88
119
|
cellContent,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
),
|
|
102
|
-
};
|
|
120
|
+
tableInstance.state.sticky.isScrolledToLeft,
|
|
121
|
+
tableInstance.state.sticky.isScrolledToRight,
|
|
122
|
+
],
|
|
123
|
+
);
|
|
124
|
+
let cellRendererProps = _react.useMemo(
|
|
125
|
+
() => ({
|
|
126
|
+
cellElementProps,
|
|
127
|
+
cellProps,
|
|
128
|
+
children: defaultCellRendererChildren,
|
|
129
|
+
}),
|
|
130
|
+
[cellElementProps, cellProps, defaultCellRendererChildren],
|
|
131
|
+
);
|
|
103
132
|
return _react.createElement(
|
|
104
133
|
_react.Fragment,
|
|
105
134
|
null,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
135
|
+
_react.createElement(
|
|
136
|
+
_DefaultCell.DefaultCellRendererPropsChildren.Provider,
|
|
137
|
+
{
|
|
138
|
+
value: defaultCellRendererChildren,
|
|
139
|
+
},
|
|
140
|
+
cell.column.cellRenderer
|
|
141
|
+
? cell.column.cellRenderer({
|
|
142
|
+
...cellRendererProps,
|
|
143
|
+
isDisabled: () => isDisabled,
|
|
144
|
+
})
|
|
145
|
+
: _react.createElement(_index1.DefaultCell, {
|
|
146
|
+
...cellRendererProps,
|
|
147
|
+
isDisabled: () => isDisabled,
|
|
148
|
+
}),
|
|
149
|
+
),
|
|
115
150
|
);
|
|
116
151
|
};
|
|
@@ -21,6 +21,7 @@ export type DefaultCellProps<T extends Record<string, unknown>> = {
|
|
|
21
21
|
*/
|
|
22
22
|
clamp?: boolean;
|
|
23
23
|
} & CellRendererProps<T> & React.ComponentPropsWithoutRef<'div'>;
|
|
24
|
+
export declare const DefaultCellRendererPropsChildren: React.Context<React.ReactNode>;
|
|
24
25
|
/**
|
|
25
26
|
* Default cell.
|
|
26
27
|
* It should be passed to `cellRenderer`.
|
|
@@ -2,11 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, '__esModule', {
|
|
3
3
|
value: true,
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name],
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
DefaultCell: function () {
|
|
8
14
|
return DefaultCell;
|
|
9
15
|
},
|
|
16
|
+
DefaultCellRendererPropsChildren: function () {
|
|
17
|
+
return DefaultCellRendererPropsChildren;
|
|
18
|
+
},
|
|
10
19
|
});
|
|
11
20
|
const _interop_require_default = require('@swc/helpers/_/_interop_require_default');
|
|
12
21
|
const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
|
|
@@ -17,6 +26,7 @@ const _classnames = /*#__PURE__*/ _interop_require_default._(
|
|
|
17
26
|
);
|
|
18
27
|
const _index = require('../../../utils/index.js');
|
|
19
28
|
const _utils = require('../utils.js');
|
|
29
|
+
const DefaultCellRendererPropsChildren = _react.createContext(void 0);
|
|
20
30
|
const DefaultCell = (props) => {
|
|
21
31
|
let instance = _react.useContext(_utils.TableInstanceContext);
|
|
22
32
|
let isCustomCell = _react.useMemo(
|
|
@@ -25,6 +35,8 @@ const DefaultCell = (props) => {
|
|
|
25
35
|
?.Cell !== _reacttable.defaultColumn.Cell,
|
|
26
36
|
[instance, props.cellProps.column.id],
|
|
27
37
|
);
|
|
38
|
+
let isCellRendererChildrenCustom =
|
|
39
|
+
_react.useContext(DefaultCellRendererPropsChildren) !== props.children;
|
|
28
40
|
let {
|
|
29
41
|
cellElementProps: {
|
|
30
42
|
className: cellElementClassName,
|
|
@@ -39,7 +51,9 @@ const DefaultCell = (props) => {
|
|
|
39
51
|
className,
|
|
40
52
|
style,
|
|
41
53
|
status,
|
|
42
|
-
clamp = 'string' == typeof cellProps.value &&
|
|
54
|
+
clamp = 'string' == typeof cellProps.value &&
|
|
55
|
+
!isCustomCell &&
|
|
56
|
+
!isCellRendererChildrenCustom,
|
|
43
57
|
...rest
|
|
44
58
|
} = props;
|
|
45
59
|
let { key: cellElementKey, ...cellElementPropsRest } = cellElementProps;
|
|
@@ -68,10 +82,9 @@ const DefaultCell = (props) => {
|
|
|
68
82
|
name: 'start',
|
|
69
83
|
}),
|
|
70
84
|
_react.createElement(
|
|
71
|
-
|
|
85
|
+
TableCellContent,
|
|
72
86
|
{
|
|
73
|
-
|
|
74
|
-
onClick: (e) => e.stopPropagation(),
|
|
87
|
+
shouldRenderWrapper: isCellRendererChildrenCustom,
|
|
75
88
|
},
|
|
76
89
|
clamp
|
|
77
90
|
? _react.createElement(
|
|
@@ -113,12 +126,25 @@ const DefaultCell = (props) => {
|
|
|
113
126
|
};
|
|
114
127
|
if ('development' === process.env.NODE_ENV)
|
|
115
128
|
DefaultCell.displayName = 'DefaultCell';
|
|
129
|
+
const TableCellContent = (props) => {
|
|
130
|
+
let { children, shouldRenderWrapper } = props;
|
|
131
|
+
return shouldRenderWrapper
|
|
132
|
+
? children
|
|
133
|
+
: _react.createElement(
|
|
134
|
+
'div',
|
|
135
|
+
{
|
|
136
|
+
className: '_iui-table-cell-default-content',
|
|
137
|
+
onClick: (e) => e.stopPropagation(),
|
|
138
|
+
},
|
|
139
|
+
children,
|
|
140
|
+
);
|
|
141
|
+
};
|
|
116
142
|
const css = `
|
|
117
|
-
._iui-table-cell-
|
|
143
|
+
._iui-table-cell-default-content {
|
|
118
144
|
position: relative;
|
|
119
145
|
isolation: isolate;
|
|
120
146
|
}
|
|
121
|
-
._iui-table-cell-
|
|
147
|
+
._iui-table-cell-default-content::before {
|
|
122
148
|
content: '';
|
|
123
149
|
display: block;
|
|
124
150
|
position: absolute;
|
|
@@ -26,7 +26,7 @@ const _classnames = /*#__PURE__*/ _interop_require_default._(
|
|
|
26
26
|
const _react1 = require('@floating-ui/react');
|
|
27
27
|
const _index = require('../../utils/index.js');
|
|
28
28
|
const defaultTooltipDelay = {
|
|
29
|
-
open:
|
|
29
|
+
open: 200,
|
|
30
30
|
close: 200,
|
|
31
31
|
};
|
|
32
32
|
const useTooltip = (options = {}) => {
|
package/cjs/styles.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
Portal,
|
|
13
13
|
PortalContainerContext,
|
|
14
14
|
} from '../../utils/index.js';
|
|
15
|
-
let DialogComponent = React.forwardRef((props,
|
|
15
|
+
let DialogComponent = React.forwardRef((props, forwardedRef) => {
|
|
16
16
|
let {
|
|
17
17
|
trapFocus = false,
|
|
18
18
|
setFocus = trapFocus,
|
|
@@ -32,7 +32,7 @@ let DialogComponent = React.forwardRef((props, ref) => {
|
|
|
32
32
|
} = props;
|
|
33
33
|
let dialogRootRef = React.useRef(null);
|
|
34
34
|
let [dialogElement, setDialogElement] = React.useState(null);
|
|
35
|
-
let mergedRefs = useMergedRefs(
|
|
35
|
+
let mergedRefs = useMergedRefs(forwardedRef, dialogRootRef);
|
|
36
36
|
return isOpen
|
|
37
37
|
? React.createElement(
|
|
38
38
|
DialogContext.Provider,
|
|
@@ -50,6 +50,8 @@ let DialogComponent = React.forwardRef((props, ref) => {
|
|
|
50
50
|
isResizable,
|
|
51
51
|
relativeTo,
|
|
52
52
|
placement,
|
|
53
|
+
dialogRootRef,
|
|
54
|
+
setDialogElement,
|
|
53
55
|
},
|
|
54
56
|
},
|
|
55
57
|
React.createElement(
|
|
@@ -8,11 +8,11 @@ export const DialogBackdrop = React.forwardRef((props, ref) => {
|
|
|
8
8
|
let dialogContext = useDialogContext();
|
|
9
9
|
let dialogMainContext = useDialogMainContext();
|
|
10
10
|
let {
|
|
11
|
-
isVisible = dialogContext
|
|
12
|
-
isDismissible = dialogContext
|
|
13
|
-
onClose = dialogContext
|
|
14
|
-
closeOnExternalClick = dialogContext
|
|
15
|
-
relativeTo = dialogContext
|
|
11
|
+
isVisible = dialogContext?.isOpen,
|
|
12
|
+
isDismissible = dialogContext?.isDismissible,
|
|
13
|
+
onClose = dialogContext?.onClose,
|
|
14
|
+
closeOnExternalClick = dialogContext?.closeOnExternalClick,
|
|
15
|
+
relativeTo = dialogContext?.relativeTo,
|
|
16
16
|
onMouseDown,
|
|
17
17
|
className,
|
|
18
18
|
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 {};
|
|
@@ -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
|
|
@@ -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
|
{
|