@itwin/itwinui-react 3.18.0 → 3.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -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/Table/Table.js +3 -1
- 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/Table/Table.js +4 -1
- 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/Table/Table.js +3 -1
- 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/Table/Table.js +4 -1
- package/esm/core/Tooltip/Tooltip.js +1 -1
- package/esm/styles.js +1 -1
- package/package.json +1 -1
- package/styles.css +10 -10
|
@@ -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
|
|
@@ -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
|
{
|
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
|
{
|
|
@@ -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
|
{
|
package/esm/core/Table/Table.js
CHANGED
|
@@ -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
|
{
|
package/esm/styles.js
CHANGED