@itwin/itwinui-react 3.17.2 → 3.17.4
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 +16 -0
- package/DEV-cjs/core/ComboBox/ComboBox.js +17 -21
- package/DEV-cjs/core/ComboBox/ComboBoxMenu.js +6 -2
- package/DEV-cjs/core/DropdownMenu/DropdownMenu.js +55 -27
- package/DEV-cjs/core/Menu/Menu.js +64 -45
- package/DEV-cjs/core/Menu/MenuItem.js +6 -0
- package/DEV-cjs/core/Tabs/Tabs.js +7 -2
- package/DEV-cjs/core/Tile/Tile.js +25 -27
- package/DEV-cjs/core/Tree/Tree.js +25 -17
- package/DEV-cjs/styles.js +1 -1
- package/DEV-esm/core/ComboBox/ComboBox.js +17 -21
- package/DEV-esm/core/ComboBox/ComboBoxMenu.js +6 -2
- package/DEV-esm/core/DropdownMenu/DropdownMenu.js +40 -24
- package/DEV-esm/core/Menu/Menu.js +57 -42
- package/DEV-esm/core/Menu/MenuItem.js +9 -0
- package/DEV-esm/core/Tabs/Tabs.js +5 -2
- package/DEV-esm/core/Tile/Tile.js +29 -28
- package/DEV-esm/core/Tree/Tree.js +25 -17
- package/DEV-esm/styles.js +1 -1
- package/cjs/core/ComboBox/ComboBox.js +17 -21
- package/cjs/core/ComboBox/ComboBoxMenu.js +6 -2
- package/cjs/core/DropdownMenu/DropdownMenu.d.ts +10 -0
- package/cjs/core/DropdownMenu/DropdownMenu.js +55 -27
- package/cjs/core/Menu/Menu.d.ts +9 -1
- package/cjs/core/Menu/Menu.js +64 -45
- package/cjs/core/Menu/MenuItem.js +6 -0
- package/cjs/core/Tabs/Tabs.js +7 -2
- package/cjs/core/Tile/Tile.js +25 -27
- package/cjs/core/Tree/Tree.js +25 -17
- package/cjs/styles.js +1 -1
- package/esm/core/ComboBox/ComboBox.js +17 -21
- package/esm/core/ComboBox/ComboBoxMenu.js +6 -2
- package/esm/core/DropdownMenu/DropdownMenu.d.ts +10 -0
- package/esm/core/DropdownMenu/DropdownMenu.js +40 -24
- package/esm/core/Menu/Menu.d.ts +9 -1
- package/esm/core/Menu/Menu.js +57 -42
- package/esm/core/Menu/MenuItem.js +9 -0
- package/esm/core/Tabs/Tabs.js +5 -2
- package/esm/core/Tile/Tile.js +29 -28
- package/esm/core/Tree/Tree.js +25 -17
- package/esm/styles.js +1 -1
- package/package.json +2 -2
- package/styles.css +10 -10
|
@@ -17,6 +17,7 @@ const _ListItem = require('../List/ListItem.js');
|
|
|
17
17
|
const _classnames = /*#__PURE__*/ _interop_require_default._(
|
|
18
18
|
require('classnames'),
|
|
19
19
|
);
|
|
20
|
+
const _DropdownMenu = require('../DropdownMenu/DropdownMenu.js');
|
|
20
21
|
const MenuItem = _react.forwardRef((props, forwardedRef) => {
|
|
21
22
|
let {
|
|
22
23
|
className,
|
|
@@ -37,6 +38,10 @@ const MenuItem = _react.forwardRef((props, forwardedRef) => {
|
|
|
37
38
|
} = props;
|
|
38
39
|
let logWarning = (0, _index.useWarningLogger)();
|
|
39
40
|
let parentMenu = _react.useContext(_Menu.MenuContext);
|
|
41
|
+
let dropdownMenu = _react.useContext(_DropdownMenu.DropdownMenuContext);
|
|
42
|
+
let shouldCloseMenuOnClick = _react.useContext(
|
|
43
|
+
_DropdownMenu.DropdownMenuCloseOnClickContext,
|
|
44
|
+
);
|
|
40
45
|
let menuItemRef = _react.useRef(null);
|
|
41
46
|
let submenuId = (0, _index.useId)();
|
|
42
47
|
let popoverProps = _react.useMemo(
|
|
@@ -55,6 +60,7 @@ const MenuItem = _react.forwardRef((props, forwardedRef) => {
|
|
|
55
60
|
);
|
|
56
61
|
let onClick = () => {
|
|
57
62
|
if (disabled) return;
|
|
63
|
+
if (shouldCloseMenuOnClick) dropdownMenu?.close();
|
|
58
64
|
onClickProp?.(value);
|
|
59
65
|
};
|
|
60
66
|
let handlers = {
|
package/cjs/core/Tabs/Tabs.js
CHANGED
|
@@ -83,7 +83,9 @@ const TabsWrapper = _react.forwardRef((props, ref) => {
|
|
|
83
83
|
});
|
|
84
84
|
const TabList = _react.forwardRef((props, ref) => {
|
|
85
85
|
let { className, children, ...rest } = props;
|
|
86
|
-
let { type, hasSublabel, color } = (0, _index.useSafeContext)(
|
|
86
|
+
let { type, hasSublabel, color, orientation } = (0, _index.useSafeContext)(
|
|
87
|
+
TabsContext,
|
|
88
|
+
);
|
|
87
89
|
let isClient = (0, _index.useIsClient)();
|
|
88
90
|
let tablistRef = _react.useRef(null);
|
|
89
91
|
let [tablistSizeRef, tabsWidth] = (0, _index.useContainerWidth)(
|
|
@@ -109,6 +111,7 @@ const TabList = _react.forwardRef((props, ref) => {
|
|
|
109
111
|
},
|
|
110
112
|
className,
|
|
111
113
|
),
|
|
114
|
+
'data-iui-orientation': orientation,
|
|
112
115
|
role: 'tablist',
|
|
113
116
|
ref: refs,
|
|
114
117
|
...rest,
|
|
@@ -154,10 +157,12 @@ const Tab = _react.forwardRef((props, forwardedRef) => {
|
|
|
154
157
|
let updateStripe = () => {
|
|
155
158
|
let currentTabRect = tabRef.current?.getBoundingClientRect();
|
|
156
159
|
let tabslistRect = tablistRef.current?.getBoundingClientRect();
|
|
160
|
+
let currentTabLeftIncludingScroll =
|
|
161
|
+
(currentTabRect?.x ?? 0) + (tablistRef.current?.scrollLeft ?? 0);
|
|
157
162
|
let tabsStripePosition =
|
|
158
163
|
null != currentTabRect && null != tabslistRect
|
|
159
164
|
? {
|
|
160
|
-
horizontal:
|
|
165
|
+
horizontal: currentTabLeftIncludingScroll - tabslistRect.x,
|
|
161
166
|
vertical: currentTabRect.y - tabslistRect.y,
|
|
162
167
|
}
|
|
163
168
|
: {
|
package/cjs/core/Tile/Tile.js
CHANGED
|
@@ -196,41 +196,39 @@ const TileMoreOptions = _react.forwardRef((props, forwardedRef) => {
|
|
|
196
196
|
let { className, children = [], buttonProps, ...rest } = props;
|
|
197
197
|
let [isMenuVisible, setIsMenuVisible] = _react.useState(false);
|
|
198
198
|
return _react.createElement(
|
|
199
|
-
|
|
199
|
+
_DropdownMenu.DropdownMenuCloseOnClickContext.Provider,
|
|
200
200
|
{
|
|
201
|
-
|
|
202
|
-
'iui-tile-more-options',
|
|
203
|
-
{
|
|
204
|
-
'iui-visible': isMenuVisible,
|
|
205
|
-
},
|
|
206
|
-
className,
|
|
207
|
-
),
|
|
208
|
-
ref: forwardedRef,
|
|
209
|
-
...rest,
|
|
201
|
+
value: true,
|
|
210
202
|
},
|
|
211
203
|
_react.createElement(
|
|
212
|
-
|
|
204
|
+
_index.Box,
|
|
213
205
|
{
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
),
|
|
206
|
+
className: (0, _classnames.default)(
|
|
207
|
+
'iui-tile-more-options',
|
|
208
|
+
{
|
|
209
|
+
'iui-visible': isMenuVisible,
|
|
210
|
+
},
|
|
211
|
+
className,
|
|
212
|
+
),
|
|
213
|
+
ref: forwardedRef,
|
|
214
|
+
...rest,
|
|
224
215
|
},
|
|
225
216
|
_react.createElement(
|
|
226
|
-
|
|
217
|
+
_DropdownMenu.DropdownMenu,
|
|
227
218
|
{
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
'aria-label': 'More options',
|
|
231
|
-
...buttonProps,
|
|
219
|
+
onVisibleChange: setIsMenuVisible,
|
|
220
|
+
menuItems: children,
|
|
232
221
|
},
|
|
233
|
-
_react.createElement(
|
|
222
|
+
_react.createElement(
|
|
223
|
+
_IconButton.IconButton,
|
|
224
|
+
{
|
|
225
|
+
styleType: 'borderless',
|
|
226
|
+
size: 'small',
|
|
227
|
+
'aria-label': 'More options',
|
|
228
|
+
...buttonProps,
|
|
229
|
+
},
|
|
230
|
+
_react.createElement(_index.SvgMore, null),
|
|
231
|
+
),
|
|
234
232
|
),
|
|
235
233
|
),
|
|
236
234
|
);
|
package/cjs/core/Tree/Tree.js
CHANGED
|
@@ -216,29 +216,37 @@ const VirtualizedTree = _react.forwardRef(
|
|
|
216
216
|
ref: (0, _index.useMergedRefs)(ref, parentRef),
|
|
217
217
|
},
|
|
218
218
|
_react.createElement(
|
|
219
|
-
|
|
219
|
+
'div',
|
|
220
220
|
{
|
|
221
|
-
|
|
221
|
+
style: {
|
|
222
|
+
display: 'contents',
|
|
223
|
+
},
|
|
222
224
|
},
|
|
223
225
|
_react.createElement(
|
|
224
|
-
|
|
226
|
+
_index.ShadowRoot,
|
|
225
227
|
{
|
|
226
|
-
|
|
227
|
-
style: {
|
|
228
|
-
minBlockSize: virtualizer.getTotalSize(),
|
|
229
|
-
},
|
|
228
|
+
css: virtualizerCss,
|
|
230
229
|
},
|
|
231
|
-
_react.createElement(
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
itemRenderer(virtualItem.index, virtualItem, virtualizer),
|
|
230
|
+
_react.createElement(
|
|
231
|
+
'div',
|
|
232
|
+
{
|
|
233
|
+
'data-iui-virtualizer': 'root',
|
|
234
|
+
style: {
|
|
235
|
+
minBlockSize: virtualizer.getTotalSize(),
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
_react.createElement('slot', null),
|
|
241
239
|
),
|
|
240
|
+
),
|
|
241
|
+
_react.createElement(
|
|
242
|
+
_react.Fragment,
|
|
243
|
+
null,
|
|
244
|
+
virtualizer
|
|
245
|
+
.getVirtualItems()
|
|
246
|
+
.map((virtualItem) =>
|
|
247
|
+
itemRenderer(virtualItem.index, virtualItem, virtualizer),
|
|
248
|
+
),
|
|
249
|
+
),
|
|
242
250
|
),
|
|
243
251
|
);
|
|
244
252
|
},
|
package/cjs/styles.js
CHANGED
|
@@ -367,27 +367,23 @@ export const ComboBox = React.forwardRef((props, forwardedRef) => {
|
|
|
367
367
|
disabled: inputProps?.disabled,
|
|
368
368
|
...rest,
|
|
369
369
|
},
|
|
370
|
-
React.createElement(
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
.filter(Boolean)
|
|
388
|
-
: void 0,
|
|
389
|
-
}),
|
|
390
|
-
),
|
|
370
|
+
React.createElement(ComboBoxInput, {
|
|
371
|
+
value: inputValue,
|
|
372
|
+
disabled: inputProps?.disabled,
|
|
373
|
+
...inputProps,
|
|
374
|
+
onChange: handleOnInput,
|
|
375
|
+
selectTags: isMultipleEnabled(selectedIndexes, multiple)
|
|
376
|
+
? selectedIndexes
|
|
377
|
+
?.map((index) => {
|
|
378
|
+
let item = options[index];
|
|
379
|
+
return React.createElement(SelectTag, {
|
|
380
|
+
key: item.label,
|
|
381
|
+
label: item.label,
|
|
382
|
+
});
|
|
383
|
+
})
|
|
384
|
+
.filter(Boolean)
|
|
385
|
+
: void 0,
|
|
386
|
+
}),
|
|
391
387
|
React.createElement(ComboBoxEndIcon, {
|
|
392
388
|
...endIconProps,
|
|
393
389
|
disabled: inputProps?.disabled,
|
|
@@ -59,8 +59,12 @@ let VirtualizedComboBoxMenu = (props) => {
|
|
|
59
59
|
[filteredOptions, getMenuItem, children, virtualizer.measureElement],
|
|
60
60
|
);
|
|
61
61
|
return React.createElement(
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
'div',
|
|
63
|
+
{
|
|
64
|
+
style: {
|
|
65
|
+
display: 'contents',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
64
68
|
React.createElement(
|
|
65
69
|
ShadowRoot,
|
|
66
70
|
{
|
|
@@ -48,3 +48,13 @@ export type DropdownMenuProps = {
|
|
|
48
48
|
* </DropdownMenu>
|
|
49
49
|
*/
|
|
50
50
|
export declare const DropdownMenu: PolymorphicForwardRefComponent<"div", DropdownMenuProps>;
|
|
51
|
+
export declare const DropdownMenuContext: React.Context<{
|
|
52
|
+
close: () => void;
|
|
53
|
+
} | undefined>;
|
|
54
|
+
/**
|
|
55
|
+
* @private
|
|
56
|
+
* Wraps around a `DropdownMenu`.
|
|
57
|
+
*
|
|
58
|
+
* If `true`, closes the `DropdownMenu` when any descendant `MenuItem` is clicked.
|
|
59
|
+
*/
|
|
60
|
+
export declare const DropdownMenuCloseOnClickContext: React.Context<boolean | undefined>;
|
|
@@ -30,34 +30,50 @@ let DropdownMenuContent = React.forwardRef((props, forwardedRef) => {
|
|
|
30
30
|
visibleProp,
|
|
31
31
|
onVisibleChange,
|
|
32
32
|
);
|
|
33
|
+
let close = React.useCallback(() => {
|
|
34
|
+
setVisible(false);
|
|
35
|
+
}, [setVisible]);
|
|
33
36
|
let menuContent = React.useMemo(() => {
|
|
34
|
-
if ('function' == typeof menuItems)
|
|
35
|
-
return menuItems(() => setVisible(false));
|
|
37
|
+
if ('function' == typeof menuItems) return menuItems(close);
|
|
36
38
|
return menuItems;
|
|
37
|
-
}, [
|
|
39
|
+
}, [close, menuItems]);
|
|
40
|
+
let dropdownMenuContextValue = React.useMemo(
|
|
41
|
+
() => ({
|
|
42
|
+
close,
|
|
43
|
+
}),
|
|
44
|
+
[close],
|
|
45
|
+
);
|
|
38
46
|
return React.createElement(
|
|
39
|
-
|
|
47
|
+
DropdownMenuContext.Provider,
|
|
40
48
|
{
|
|
41
|
-
|
|
42
|
-
onKeyDown: mergeEventHandlers(props.onKeyDown, (e) => {
|
|
43
|
-
if (e.defaultPrevented) return;
|
|
44
|
-
if ('Tab' === e.key) setVisible(false);
|
|
45
|
-
}),
|
|
46
|
-
role: role,
|
|
47
|
-
ref: forwardedRef,
|
|
48
|
-
portal: portal,
|
|
49
|
-
popoverProps: React.useMemo(
|
|
50
|
-
() => ({
|
|
51
|
-
placement,
|
|
52
|
-
matchWidth,
|
|
53
|
-
visible,
|
|
54
|
-
onVisibleChange: setVisible,
|
|
55
|
-
middleware,
|
|
56
|
-
}),
|
|
57
|
-
[matchWidth, middleware, placement, setVisible, visible],
|
|
58
|
-
),
|
|
59
|
-
...rest,
|
|
49
|
+
value: dropdownMenuContextValue,
|
|
60
50
|
},
|
|
61
|
-
|
|
51
|
+
React.createElement(
|
|
52
|
+
Menu,
|
|
53
|
+
{
|
|
54
|
+
trigger: children,
|
|
55
|
+
onKeyDown: mergeEventHandlers(props.onKeyDown, (e) => {
|
|
56
|
+
if (e.defaultPrevented) return;
|
|
57
|
+
if ('Tab' === e.key) setVisible(false);
|
|
58
|
+
}),
|
|
59
|
+
role: role,
|
|
60
|
+
ref: forwardedRef,
|
|
61
|
+
portal: portal,
|
|
62
|
+
popoverProps: React.useMemo(
|
|
63
|
+
() => ({
|
|
64
|
+
placement,
|
|
65
|
+
matchWidth,
|
|
66
|
+
visible,
|
|
67
|
+
onVisibleChange: setVisible,
|
|
68
|
+
middleware,
|
|
69
|
+
}),
|
|
70
|
+
[matchWidth, middleware, placement, setVisible, visible],
|
|
71
|
+
),
|
|
72
|
+
...rest,
|
|
73
|
+
},
|
|
74
|
+
menuContent,
|
|
75
|
+
),
|
|
62
76
|
);
|
|
63
77
|
});
|
|
78
|
+
export const DropdownMenuContext = React.createContext(void 0);
|
|
79
|
+
export const DropdownMenuCloseOnClickContext = React.createContext(void 0);
|
package/esm/core/Menu/Menu.d.ts
CHANGED
|
@@ -28,7 +28,12 @@ type MenuProps = {
|
|
|
28
28
|
listNavigation?: Partial<UseListNavigationProps>;
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* If not passed, uses the `portal` from its parent `Menu`.
|
|
33
|
+
* @see {@link PortalProps.portal} for docs on the prop.
|
|
34
|
+
*/
|
|
35
|
+
portal?: PortalProps['portal'];
|
|
36
|
+
};
|
|
32
37
|
/**
|
|
33
38
|
* @private
|
|
34
39
|
*
|
|
@@ -92,4 +97,7 @@ export declare const MenuContext: React.Context<{
|
|
|
92
97
|
popoverGetItemProps: PopoverGetItemProps;
|
|
93
98
|
focusableElements: HTMLElement[];
|
|
94
99
|
} | undefined>;
|
|
100
|
+
export declare const MenuPortalContext: React.Context<boolean | {
|
|
101
|
+
to: HTMLElement | null | undefined | (() => HTMLElement | null | undefined);
|
|
102
|
+
} | undefined>;
|
|
95
103
|
export {};
|
package/esm/core/Menu/Menu.js
CHANGED
|
@@ -25,11 +25,13 @@ export const Menu = React.forwardRef((props, ref) => {
|
|
|
25
25
|
className,
|
|
26
26
|
trigger,
|
|
27
27
|
positionReference,
|
|
28
|
-
portal
|
|
28
|
+
portal: portalProp,
|
|
29
29
|
popoverProps: popoverPropsProp,
|
|
30
30
|
children,
|
|
31
31
|
...rest
|
|
32
32
|
} = props;
|
|
33
|
+
let menuPortalContext = React.useContext(MenuPortalContext);
|
|
34
|
+
let portal = portalProp ?? menuPortalContext;
|
|
33
35
|
let tree = useFloatingTree();
|
|
34
36
|
let nodeId = useFloatingNodeId();
|
|
35
37
|
let parentId = useFloatingParentNodeId();
|
|
@@ -125,32 +127,35 @@ export const Menu = React.forwardRef((props, ref) => {
|
|
|
125
127
|
() => void 0,
|
|
126
128
|
() => void 0,
|
|
127
129
|
);
|
|
128
|
-
let popoverGetItemProps = (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
130
|
+
let popoverGetItemProps = React.useCallback(
|
|
131
|
+
({ focusableItemIndex, userProps }) =>
|
|
132
|
+
getItemProps({
|
|
133
|
+
...userProps,
|
|
134
|
+
tabIndex:
|
|
135
|
+
null != activeIndex &&
|
|
136
|
+
activeIndex >= 0 &&
|
|
137
|
+
null != focusableItemIndex &&
|
|
138
|
+
focusableItemIndex >= 0 &&
|
|
139
|
+
activeIndex === focusableItemIndex
|
|
140
|
+
? 0
|
|
141
|
+
: -1,
|
|
142
|
+
onFocus: mergeEventHandlers(userProps?.onFocus, () => {
|
|
143
|
+
queueMicrotask(() => {
|
|
144
|
+
setHasFocusedNodeInSubmenu(true);
|
|
145
|
+
});
|
|
146
|
+
tree?.events.emit('onNodeFocused', {
|
|
147
|
+
nodeId: nodeId,
|
|
148
|
+
parentId: parentId,
|
|
149
|
+
});
|
|
150
|
+
}),
|
|
151
|
+
onMouseEnter: mergeEventHandlers(userProps?.onMouseEnter, (event) => {
|
|
152
|
+
if (null != focusableItemIndex && focusableItemIndex >= 0)
|
|
153
|
+
setActiveIndex(focusableItemIndex);
|
|
154
|
+
if (event.target === event.currentTarget) event.currentTarget.focus();
|
|
155
|
+
}),
|
|
147
156
|
}),
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
setActiveIndex(focusableItemIndex);
|
|
151
|
-
if (event.target === event.currentTarget) event.currentTarget.focus();
|
|
152
|
-
}),
|
|
153
|
-
});
|
|
157
|
+
[activeIndex, getItemProps, nodeId, parentId, tree?.events],
|
|
158
|
+
);
|
|
154
159
|
let reference = cloneElementWithRef(trigger, (triggerChild) =>
|
|
155
160
|
getReferenceProps(
|
|
156
161
|
popover.getReferenceProps({
|
|
@@ -189,28 +194,38 @@ export const Menu = React.forwardRef((props, ref) => {
|
|
|
189
194
|
React.createElement(
|
|
190
195
|
MenuContext.Provider,
|
|
191
196
|
{
|
|
192
|
-
value:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
197
|
+
value: React.useMemo(
|
|
198
|
+
() => ({
|
|
199
|
+
popoverGetItemProps,
|
|
200
|
+
focusableElements,
|
|
201
|
+
}),
|
|
202
|
+
[focusableElements, popoverGetItemProps],
|
|
203
|
+
),
|
|
196
204
|
},
|
|
197
205
|
React.createElement(
|
|
198
|
-
|
|
206
|
+
MenuPortalContext.Provider,
|
|
199
207
|
{
|
|
200
|
-
value:
|
|
208
|
+
value: portal,
|
|
201
209
|
},
|
|
202
|
-
|
|
210
|
+
React.createElement(
|
|
211
|
+
PopoverOpenContext.Provider,
|
|
212
|
+
{
|
|
213
|
+
value: popover.open,
|
|
214
|
+
},
|
|
215
|
+
reference,
|
|
216
|
+
),
|
|
217
|
+
null != tree
|
|
218
|
+
? React.createElement(
|
|
219
|
+
FloatingNode,
|
|
220
|
+
{
|
|
221
|
+
id: nodeId,
|
|
222
|
+
},
|
|
223
|
+
floating,
|
|
224
|
+
)
|
|
225
|
+
: floating,
|
|
203
226
|
),
|
|
204
|
-
null != tree
|
|
205
|
-
? React.createElement(
|
|
206
|
-
FloatingNode,
|
|
207
|
-
{
|
|
208
|
-
id: nodeId,
|
|
209
|
-
},
|
|
210
|
-
floating,
|
|
211
|
-
)
|
|
212
|
-
: floating,
|
|
213
227
|
),
|
|
214
228
|
);
|
|
215
229
|
});
|
|
216
230
|
export const MenuContext = React.createContext(void 0);
|
|
231
|
+
export const MenuPortalContext = React.createContext(void 0);
|
|
@@ -8,6 +8,10 @@ import {
|
|
|
8
8
|
import { Menu, MenuContext } from './Menu.js';
|
|
9
9
|
import { ListItem } from '../List/ListItem.js';
|
|
10
10
|
import cx from 'classnames';
|
|
11
|
+
import {
|
|
12
|
+
DropdownMenuCloseOnClickContext,
|
|
13
|
+
DropdownMenuContext,
|
|
14
|
+
} from '../DropdownMenu/DropdownMenu.js';
|
|
11
15
|
export const MenuItem = React.forwardRef((props, forwardedRef) => {
|
|
12
16
|
let {
|
|
13
17
|
className,
|
|
@@ -28,6 +32,10 @@ export const MenuItem = React.forwardRef((props, forwardedRef) => {
|
|
|
28
32
|
} = props;
|
|
29
33
|
let logWarning = useWarningLogger();
|
|
30
34
|
let parentMenu = React.useContext(MenuContext);
|
|
35
|
+
let dropdownMenu = React.useContext(DropdownMenuContext);
|
|
36
|
+
let shouldCloseMenuOnClick = React.useContext(
|
|
37
|
+
DropdownMenuCloseOnClickContext,
|
|
38
|
+
);
|
|
31
39
|
let menuItemRef = React.useRef(null);
|
|
32
40
|
let submenuId = useId();
|
|
33
41
|
let popoverProps = React.useMemo(
|
|
@@ -46,6 +54,7 @@ export const MenuItem = React.forwardRef((props, forwardedRef) => {
|
|
|
46
54
|
);
|
|
47
55
|
let onClick = () => {
|
|
48
56
|
if (disabled) return;
|
|
57
|
+
if (shouldCloseMenuOnClick) dropdownMenu?.close();
|
|
49
58
|
onClickProp?.(value);
|
|
50
59
|
};
|
|
51
60
|
let handlers = {
|
package/esm/core/Tabs/Tabs.js
CHANGED
|
@@ -69,7 +69,7 @@ let TabsWrapper = React.forwardRef((props, ref) => {
|
|
|
69
69
|
});
|
|
70
70
|
let TabList = React.forwardRef((props, ref) => {
|
|
71
71
|
let { className, children, ...rest } = props;
|
|
72
|
-
let { type, hasSublabel, color } = useSafeContext(TabsContext);
|
|
72
|
+
let { type, hasSublabel, color, orientation } = useSafeContext(TabsContext);
|
|
73
73
|
let isClient = useIsClient();
|
|
74
74
|
let tablistRef = React.useRef(null);
|
|
75
75
|
let [tablistSizeRef, tabsWidth] = useContainerWidth('default' !== type);
|
|
@@ -93,6 +93,7 @@ let TabList = React.forwardRef((props, ref) => {
|
|
|
93
93
|
},
|
|
94
94
|
className,
|
|
95
95
|
),
|
|
96
|
+
'data-iui-orientation': orientation,
|
|
96
97
|
role: 'tablist',
|
|
97
98
|
ref: refs,
|
|
98
99
|
...rest,
|
|
@@ -138,10 +139,12 @@ let Tab = React.forwardRef((props, forwardedRef) => {
|
|
|
138
139
|
let updateStripe = () => {
|
|
139
140
|
let currentTabRect = tabRef.current?.getBoundingClientRect();
|
|
140
141
|
let tabslistRect = tablistRef.current?.getBoundingClientRect();
|
|
142
|
+
let currentTabLeftIncludingScroll =
|
|
143
|
+
(currentTabRect?.x ?? 0) + (tablistRef.current?.scrollLeft ?? 0);
|
|
141
144
|
let tabsStripePosition =
|
|
142
145
|
null != currentTabRect && null != tabslistRect
|
|
143
146
|
? {
|
|
144
|
-
horizontal:
|
|
147
|
+
horizontal: currentTabLeftIncludingScroll - tabslistRect.x,
|
|
145
148
|
vertical: currentTabRect.y - tabslistRect.y,
|
|
146
149
|
}
|
|
147
150
|
: {
|
package/esm/core/Tile/Tile.js
CHANGED
|
@@ -10,7 +10,10 @@ import {
|
|
|
10
10
|
polymorphic,
|
|
11
11
|
Box,
|
|
12
12
|
} from '../../utils/index.js';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
DropdownMenu,
|
|
15
|
+
DropdownMenuCloseOnClickContext,
|
|
16
|
+
} from '../DropdownMenu/DropdownMenu.js';
|
|
14
17
|
import { IconButton } from '../Buttons/IconButton.js';
|
|
15
18
|
import { ProgressRadial } from '../ProgressIndicators/ProgressRadial.js';
|
|
16
19
|
import { LinkAction } from '../LinkAction/LinkAction.js';
|
|
@@ -174,41 +177,39 @@ let TileMoreOptions = React.forwardRef((props, forwardedRef) => {
|
|
|
174
177
|
let { className, children = [], buttonProps, ...rest } = props;
|
|
175
178
|
let [isMenuVisible, setIsMenuVisible] = React.useState(false);
|
|
176
179
|
return React.createElement(
|
|
177
|
-
|
|
180
|
+
DropdownMenuCloseOnClickContext.Provider,
|
|
178
181
|
{
|
|
179
|
-
|
|
180
|
-
'iui-tile-more-options',
|
|
181
|
-
{
|
|
182
|
-
'iui-visible': isMenuVisible,
|
|
183
|
-
},
|
|
184
|
-
className,
|
|
185
|
-
),
|
|
186
|
-
ref: forwardedRef,
|
|
187
|
-
...rest,
|
|
182
|
+
value: true,
|
|
188
183
|
},
|
|
189
184
|
React.createElement(
|
|
190
|
-
|
|
185
|
+
Box,
|
|
191
186
|
{
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
),
|
|
187
|
+
className: cx(
|
|
188
|
+
'iui-tile-more-options',
|
|
189
|
+
{
|
|
190
|
+
'iui-visible': isMenuVisible,
|
|
191
|
+
},
|
|
192
|
+
className,
|
|
193
|
+
),
|
|
194
|
+
ref: forwardedRef,
|
|
195
|
+
...rest,
|
|
202
196
|
},
|
|
203
197
|
React.createElement(
|
|
204
|
-
|
|
198
|
+
DropdownMenu,
|
|
205
199
|
{
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
'aria-label': 'More options',
|
|
209
|
-
...buttonProps,
|
|
200
|
+
onVisibleChange: setIsMenuVisible,
|
|
201
|
+
menuItems: children,
|
|
210
202
|
},
|
|
211
|
-
React.createElement(
|
|
203
|
+
React.createElement(
|
|
204
|
+
IconButton,
|
|
205
|
+
{
|
|
206
|
+
styleType: 'borderless',
|
|
207
|
+
size: 'small',
|
|
208
|
+
'aria-label': 'More options',
|
|
209
|
+
...buttonProps,
|
|
210
|
+
},
|
|
211
|
+
React.createElement(SvgMore, null),
|
|
212
|
+
),
|
|
212
213
|
),
|
|
213
214
|
),
|
|
214
215
|
);
|