@sentry/scraps 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -3
- package/dist/alert/alert.js +10 -7
- package/dist/badge/tag.js +4 -2
- package/dist/button/button.js +1 -0
- package/dist/button/linkButton.js +1 -0
- package/dist/button/styles.js +157 -152
- package/dist/codeBlock/codeBlock.js +1 -0
- package/dist/compactSelect/compactSelect.d.ts +2 -2
- package/dist/compactSelect/compactSelect.js +37 -23
- package/dist/compactSelect/control.js +14 -10
- package/dist/compactSelect/gridList/index.js +35 -36
- package/dist/compactSelect/gridList/option.d.ts +4 -1
- package/dist/compactSelect/gridList/option.js +4 -3
- package/dist/compactSelect/gridList/section.d.ts +10 -3
- package/dist/compactSelect/gridList/section.js +16 -33
- package/dist/compactSelect/listBox/index.d.ts +1 -1
- package/dist/compactSelect/listBox/index.js +46 -58
- package/dist/compactSelect/listBox/section.d.ts +10 -8
- package/dist/compactSelect/listBox/section.js +11 -30
- package/dist/compactSelect/styles.d.ts +6 -7
- package/dist/compactSelect/styles.js +1 -23
- package/dist/compactSelect/utils.js +2 -6
- package/dist/dateTime/config.d.ts +23 -0
- package/dist/dateTime/config.js +50 -0
- package/dist/dateTime/context.d.ts +18 -0
- package/dist/dateTime/context.js +46 -0
- package/dist/dateTime/dateTime.d.ts +6 -0
- package/dist/dateTime/dateTime.js +30 -0
- package/dist/dateTime/format.d.ts +24 -0
- package/dist/dateTime/format.js +45 -0
- package/dist/dateTime/index.d.ts +6 -0
- package/dist/dateTime/index.js +6 -0
- package/dist/dateTime/intlFormatter.d.ts +9 -0
- package/dist/dateTime/intlFormatter.js +16 -0
- package/dist/dateTime/parseDate.d.ts +3 -0
- package/dist/dateTime/parseDate.js +12 -0
- package/dist/diagnostics/context.d.ts +12 -0
- package/dist/diagnostics/context.js +11 -0
- package/dist/diagnostics/index.d.ts +2 -0
- package/dist/diagnostics/index.js +1 -0
- package/dist/disclosure/disclosure.js +1 -1
- package/dist/dragHandle/dragHandle.js +3 -5
- package/dist/dropdownMenu/context.d.ts +36 -11
- package/dist/dropdownMenu/context.js +2 -1
- package/dist/dropdownMenu/dropdownMenu.d.ts +2 -2
- package/dist/dropdownMenu/dropdownMenu.js +9 -3
- package/dist/dropdownMenu/item.d.ts +7 -8
- package/dist/dropdownMenu/item.js +43 -77
- package/dist/dropdownMenu/list.d.ts +31 -5
- package/dist/dropdownMenu/list.js +154 -133
- package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +5 -241
- package/dist/dropdownMenu/useDropdownMenuKeyboard.js +5 -29
- package/dist/dropdownMenu/useDropdownMenuRowLayout.js +6 -14
- package/dist/dropdownMenu/useDropdownRootMenuState.d.ts +13 -0
- package/dist/dropdownMenu/useDropdownRootMenuState.js +30 -0
- package/dist/dropdownMenu/useDropdownSubmenuState.d.ts +19 -0
- package/dist/dropdownMenu/useDropdownSubmenuState.js +25 -0
- package/dist/dropdownMenu/utils.js +5 -7
- package/dist/duration/formatElapsedDuration.d.ts +4 -0
- package/dist/duration/formatElapsedDuration.js +10 -0
- package/dist/duration/getDuration.d.ts +68 -0
- package/dist/duration/getDuration.js +80 -0
- package/dist/duration/index.d.ts +2 -0
- package/dist/duration/index.js +2 -0
- package/dist/form/field/radioGroupField.d.ts +7 -0
- package/dist/form/field/radioGroupField.js +14 -0
- package/dist/form/field/selectField.d.ts +3 -4
- package/dist/form/field/selectField.js +16 -24
- package/dist/{compactSelect/fzf.d.ts → fzf.d.ts} +1 -0
- package/dist/{compactSelect/fzf.js → fzf.js} +5 -1
- package/dist/layout/container.d.ts +24 -7
- package/dist/layout/container.js +9 -12
- package/dist/layout/flex.js +1 -1
- package/dist/layout/grid.js +2 -2
- package/dist/layout/index.d.ts +1 -1
- package/dist/layout/index.js +1 -1
- package/dist/layout/stack.js +1 -1
- package/dist/layout/styles.d.ts +28 -7
- package/dist/layout/styles.js +76 -16
- package/dist/layout/surface.d.ts +2 -2
- package/dist/layout/surface.js +6 -3
- package/dist/legacyDatetime.d.ts +21 -0
- package/dist/legacyDatetime.js +13 -0
- package/dist/link/index.d.ts +1 -1
- package/dist/link/index.js +1 -1
- package/dist/link/linkBehaviorContext.d.ts +9 -0
- package/dist/link/linkBehaviorContext.js +37 -7
- package/dist/menu/menu.d.ts +1 -3
- package/dist/menu/menu.js +5 -6
- package/dist/menu/selectValue.d.ts +2 -6
- package/dist/modal/components.js +2 -2
- package/dist/overlayArrow.js +2 -2
- package/dist/relativeTime/getRelativeDate.d.ts +14 -0
- package/dist/relativeTime/getRelativeDate.js +107 -0
- package/dist/relativeTime/index.d.ts +3 -0
- package/dist/relativeTime/index.js +3 -0
- package/dist/relativeTime/relativeTime.d.ts +55 -0
- package/dist/relativeTime/relativeTime.js +102 -0
- package/dist/relativeTime/useRelativeTimeFormatter.d.ts +2 -0
- package/dist/relativeTime/useRelativeTimeFormatter.js +10 -0
- package/dist/select/chips.d.ts +14 -0
- package/dist/select/chips.js +45 -0
- package/dist/select/filter.js +7 -11
- package/dist/select/index.d.ts +1 -1
- package/dist/select/indicators.d.ts +11 -0
- package/dist/select/indicators.js +61 -0
- package/dist/select/menu.d.ts +44 -0
- package/dist/select/menu.js +103 -0
- package/dist/select/option.d.ts +23 -15
- package/dist/select/option.js +66 -58
- package/dist/select/options.d.ts +31 -0
- package/dist/select/options.js +74 -0
- package/dist/select/select.d.ts +24 -11
- package/dist/select/select.js +527 -429
- package/dist/select/styles.d.ts +148 -2
- package/dist/select/styles.js +156 -1
- package/dist/select/types.d.ts +6 -7
- package/dist/select/types.js +4 -0
- package/dist/select/utils.d.ts +2 -0
- package/dist/select/utils.js +4 -0
- package/dist/separator/separator.d.ts +2 -2
- package/dist/separator/separator.js +4 -3
- package/dist/slot/slot.js +16 -12
- package/dist/tabs/context.d.ts +9 -0
- package/dist/tabs/context.js +9 -0
- package/dist/tabs/index.d.ts +2 -4
- package/dist/tabs/index.js +1 -3
- package/dist/tabs/item.d.ts +16 -5
- package/dist/tabs/tab.js +9 -4
- package/dist/tabs/tabList.d.ts +5 -5
- package/dist/tabs/tabList.js +8 -6
- package/dist/tabs/tabPanels.d.ts +2 -3
- package/dist/tabs/tabPanels.js +1 -1
- package/dist/tabs/tabs.d.ts +46 -31
- package/dist/tabs/tabs.js +38 -35
- package/dist/text/prose.d.ts +2 -2
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/index.js +2 -0
- package/dist/theme/theme.d.ts +34 -34
- package/dist/theme/theme.js +9 -0
- package/dist/theme/types.d.ts +21 -2
- package/dist/theme/useResolvedTheme.d.ts +12 -0
- package/dist/theme/useResolvedTheme.js +20 -0
- package/dist/theme/variables.css +1116 -0
- package/dist/theme/variables.d.ts +985 -0
- package/dist/theme/variables.js +455 -0
- package/dist/translation/index.d.ts +1 -0
- package/dist/translation/index.js +1 -0
- package/dist/translation/translate.d.ts +9 -0
- package/dist/translation/translate.js +5 -0
- package/dist/translation/translationContext.d.ts +2 -1
- package/dist/translation/translationContext.js +2 -1
- package/dist/useVirtualCollection.d.ts +14 -1
- package/dist/useVirtualCollection.js +59 -3
- package/fonts/OFL.txt +94 -0
- package/fonts/roboto-mono-variable-cyrillic-ext.woff2 +0 -0
- package/fonts/roboto-mono-variable-cyrillic.woff2 +0 -0
- package/fonts/roboto-mono-variable-greek.woff2 +0 -0
- package/fonts/roboto-mono-variable-latin-ext.woff2 +0 -0
- package/fonts/roboto-mono-variable-vietnamese.woff2 +0 -0
- package/fonts/roboto-mono-variable.woff2 +0 -0
- package/fonts/rubik-variable-cyrillic-ext.woff2 +0 -0
- package/fonts/rubik-variable-cyrillic.woff2 +0 -0
- package/fonts/rubik-variable-latin-ext.woff2 +0 -0
- package/fonts/rubik-variable.woff2 +0 -0
- package/fonts.css +211 -0
- package/package.json +39 -15
- package/dist/compactSelect/useVirtualizedItems.d.ts +0 -52
- package/dist/compactSelect/useVirtualizedItems.js +0 -74
- package/dist/datetime.d.ts +0 -39
- package/dist/datetime.js +0 -20
- package/dist/dropdownMenu/useSafetyTriangle.d.ts +0 -12
- package/dist/dropdownMenu/useSafetyTriangle.js +0 -119
- package/dist/select/reactSelectWrapper.d.ts +0 -8
- package/dist/select/reactSelectWrapper.js +0 -25
- package/dist/select/virtualizedMenuList.d.ts +0 -24
- package/dist/select/virtualizedMenuList.js +0 -123
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { createElement, css, useTheme } from "@emotion/react";
|
|
3
|
-
import { memo,
|
|
3
|
+
import { memo, useContext, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
4
5
|
import styled from "@emotion/styled";
|
|
5
6
|
import { FocusScope } from "@react-aria/focus";
|
|
6
|
-
import { useMenu,
|
|
7
|
+
import { useMenu, useSubmenuTrigger } from "@react-aria/menu";
|
|
7
8
|
import { useSeparator } from "@react-aria/separator";
|
|
8
9
|
import { Item, Section } from "@react-stately/collections";
|
|
9
10
|
import { useTreeState } from "@react-stately/tree";
|
|
@@ -14,17 +15,17 @@ import { Overlay, PositionWrapper } from "../overlay.js";
|
|
|
14
15
|
import { Text } from "../text/index.js";
|
|
15
16
|
import { useTranslation } from "../translation/useTranslation.js";
|
|
16
17
|
import { useOverlay } from "../useOverlay.js";
|
|
17
|
-
import { DEFAULT_VIRTUALIZE_THRESHOLD, VirtualRows, flattenSections } from "../useVirtualCollection.js";
|
|
18
|
-
import { DropdownMenuContext } from "./context.js";
|
|
18
|
+
import { DEFAULT_VIRTUALIZE_THRESHOLD, VirtualRows, flattenSections, getWidestMenuItemKey } from "../useVirtualCollection.js";
|
|
19
|
+
import { DropdownMenuContext, DropdownMenuTreeStateContext } from "./context.js";
|
|
19
20
|
import { DropdownMenuItem } from "./item.js";
|
|
20
21
|
import { DropdownMenuSearch } from "./search.js";
|
|
21
22
|
import { DropdownMenuSection } from "./section.js";
|
|
22
23
|
import { DropdownMenuSeparator } from "./separator.js";
|
|
23
24
|
import { useDropdownMenuKeyboard } from "./useDropdownMenuKeyboard.js";
|
|
24
25
|
import { useDropdownMenuRowLayout } from "./useDropdownMenuRowLayout.js";
|
|
25
|
-
import {
|
|
26
|
+
import { useDropdownSubmenuState } from "./useDropdownSubmenuState.js";
|
|
26
27
|
import { countMenuItems, filterMenuItems, getDisabledKeys, isMenuSection, removeHiddenItemsAndSetHref } from "./utils.js";
|
|
27
|
-
const list_DropdownMenuCollectionItem = /*#__PURE__*/ memo(function({ node, isVirtualized, rowIndex, rowRef, closeOnSelect, disableTextSelection, onClose, size
|
|
28
|
+
const list_DropdownMenuCollectionItem = /*#__PURE__*/ memo(function({ node, isDisabled, isVirtualized, rowIndex, rowRef, closeOnSelect, disableTextSelection, onClose, size }) {
|
|
28
29
|
const rowProps = void 0 === rowIndex || void 0 === rowRef ? void 0 : {
|
|
29
30
|
'data-index': rowIndex,
|
|
30
31
|
ref: rowRef
|
|
@@ -34,9 +35,9 @@ const list_DropdownMenuCollectionItem = /*#__PURE__*/ memo(function({ node, isVi
|
|
|
34
35
|
return /*#__PURE__*/ jsx(DropdownSubmenu, {
|
|
35
36
|
items: node.value.children,
|
|
36
37
|
node: node,
|
|
38
|
+
isDisabled: isDisabled,
|
|
37
39
|
isVirtualized: isVirtualized,
|
|
38
40
|
rowProps: rowProps,
|
|
39
|
-
state: state,
|
|
40
41
|
onClose: onClose,
|
|
41
42
|
closeOnSelect: closeOnSelect,
|
|
42
43
|
disableTextSelection: disableTextSelection,
|
|
@@ -47,15 +48,15 @@ const list_DropdownMenuCollectionItem = /*#__PURE__*/ memo(function({ node, isVi
|
|
|
47
48
|
node: node,
|
|
48
49
|
isVirtualized: isVirtualized,
|
|
49
50
|
rowProps: rowProps,
|
|
50
|
-
state: state,
|
|
51
51
|
onClose: onClose,
|
|
52
52
|
closeOnSelect: closeOnSelect
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
function DropdownMenuRows({ collection, separatorProps, isWidthLocked, menuRef, onLockWidth, virtualized, widestKey, ...itemProps }) {
|
|
56
|
+
const state = useContext(DropdownMenuTreeStateContext);
|
|
56
57
|
const { itemsAfterSections, virtual } = useDropdownMenuRowLayout({
|
|
57
58
|
collection,
|
|
58
|
-
focusedKey:
|
|
59
|
+
focusedKey: state.selectionManager.focusedKey,
|
|
59
60
|
isWidthLocked,
|
|
60
61
|
menuRef,
|
|
61
62
|
onLockWidth,
|
|
@@ -75,6 +76,7 @@ function DropdownMenuRows({ collection, separatorProps, isWidthLocked, menuRef,
|
|
|
75
76
|
/*#__PURE__*/ jsx(SectionList, {
|
|
76
77
|
children: /*#__PURE__*/ jsx(list_DropdownMenuCollectionItem, {
|
|
77
78
|
node: node,
|
|
79
|
+
isDisabled: state.disabledKeys.has(node.key),
|
|
78
80
|
isVirtualized: virtualized,
|
|
79
81
|
...itemProps
|
|
80
82
|
})
|
|
@@ -82,6 +84,7 @@ function DropdownMenuRows({ collection, separatorProps, isWidthLocked, menuRef,
|
|
|
82
84
|
]
|
|
83
85
|
}) : /*#__PURE__*/ jsx(list_DropdownMenuCollectionItem, {
|
|
84
86
|
node: node,
|
|
87
|
+
isDisabled: state.disabledKeys.has(node.key),
|
|
85
88
|
isVirtualized: virtualized,
|
|
86
89
|
rowIndex: props?.['data-index'],
|
|
87
90
|
rowRef: props?.ref,
|
|
@@ -97,11 +100,13 @@ function DropdownMenuRows({ collection, separatorProps, isWidthLocked, menuRef,
|
|
|
97
100
|
})
|
|
98
101
|
});
|
|
99
102
|
}
|
|
100
|
-
function DropdownMenuList({ closeOnSelect = true, onClose, size, menuTitle, emptyMessage, maxHeight, maxWidth, menuFooter, searchState, disableTextSelection,
|
|
103
|
+
function DropdownMenuList({ closeOnSelect = true, onClose, size, menuTitle, emptyMessage, maxHeight, maxWidth, menuFooter, searchState, disableTextSelection, overlayPositionProps, zIndex, isVirtualized: virtualized = false, isDismissable, virtualizeThreshold, menuLevel, autoFocus, ...props }) {
|
|
101
104
|
const { t } = useTranslation();
|
|
102
105
|
const theme = useTheme();
|
|
103
|
-
const
|
|
104
|
-
const
|
|
106
|
+
const context = useContext(DropdownMenuContext);
|
|
107
|
+
const isRootMenu = 'root' === menuLevel.type;
|
|
108
|
+
const rootMenuState = isRootMenu ? menuLevel.state : context.rootMenuState;
|
|
109
|
+
const submenuLevel = isRootMenu ? 0 : menuLevel.level + 1;
|
|
105
110
|
const state = useTreeState({
|
|
106
111
|
...props,
|
|
107
112
|
selectionMode: 'single'
|
|
@@ -122,39 +127,44 @@ function DropdownMenuList({ closeOnSelect = true, onClose, size, menuTitle, empt
|
|
|
122
127
|
state.disabledKeys
|
|
123
128
|
]);
|
|
124
129
|
const hasLeadingItems = items.some((node)=>node.value?.leadingItems || node.value?.isSelected !== void 0);
|
|
125
|
-
const
|
|
130
|
+
const ownMenuRef = useRef(null);
|
|
131
|
+
const menuRef = isRootMenu ? ownMenuRef : menuLevel.ref;
|
|
126
132
|
const searchRef = useRef(null);
|
|
127
133
|
const { menuProps } = useMenu({
|
|
128
134
|
...props,
|
|
135
|
+
autoFocus: searchState ? false : autoFocus,
|
|
129
136
|
selectionMode: 'single'
|
|
130
137
|
}, state, menuRef);
|
|
131
138
|
const { separatorProps } = useSeparator({
|
|
132
139
|
elementType: 'li'
|
|
133
140
|
});
|
|
134
|
-
const widestKey = useMemo(()=>virtualized ? items
|
|
141
|
+
const widestKey = useMemo(()=>virtualized ? getWidestMenuItemKey(items) : void 0, [
|
|
135
142
|
items,
|
|
136
143
|
virtualized
|
|
137
144
|
]);
|
|
138
145
|
const [lockedWidth, setLockedWidth] = useState();
|
|
139
|
-
const { focusItem,
|
|
146
|
+
const { focusItem, menuProps: keyboardMenuProps } = useDropdownMenuKeyboard({
|
|
140
147
|
focusableKeys,
|
|
141
148
|
menuProps,
|
|
142
149
|
menuRef,
|
|
143
|
-
parentMenuState,
|
|
144
150
|
searchRef,
|
|
145
|
-
state
|
|
146
|
-
stateCollection
|
|
151
|
+
state
|
|
147
152
|
});
|
|
153
|
+
const [ownPortalContainer, setOwnPortalContainer] = useState(null);
|
|
154
|
+
const portalContainer = isRootMenu ? ownPortalContainer : context.portalContainer;
|
|
148
155
|
const contextValue = useMemo(()=>({
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
156
|
+
rootMenuState,
|
|
157
|
+
parentMenuRef: menuRef,
|
|
158
|
+
portalContainer,
|
|
159
|
+
submenuLevel,
|
|
160
|
+
isDismissable,
|
|
152
161
|
virtualizeThreshold
|
|
153
162
|
}), [
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
163
|
+
rootMenuState,
|
|
164
|
+
menuRef,
|
|
165
|
+
portalContainer,
|
|
166
|
+
submenuLevel,
|
|
167
|
+
isDismissable,
|
|
158
168
|
virtualizeThreshold
|
|
159
169
|
]);
|
|
160
170
|
const searchInput = searchState && /*#__PURE__*/ jsx(DropdownMenuSearch, {
|
|
@@ -176,7 +186,7 @@ function DropdownMenuList({ closeOnSelect = true, onClose, size, menuTitle, empt
|
|
|
176
186
|
const positionedMaxWidth = void 0 === maxWidth ? overlayPositionProps.style?.maxWidth : `min(${'number' == typeof maxWidth ? `${maxWidth}px` : maxWidth}, ${availableMaxWidth})`;
|
|
177
187
|
return /*#__PURE__*/ jsx(FocusScope, {
|
|
178
188
|
restoreFocus: true,
|
|
179
|
-
autoFocus:
|
|
189
|
+
autoFocus: isRootMenu || Boolean(autoFocus) || Boolean(searchState),
|
|
180
190
|
children: /*#__PURE__*/ jsx(PositionWrapper, {
|
|
181
191
|
zIndex: void 0 === zIndex ? theme.zIndex.dropdown : Number(zIndex),
|
|
182
192
|
...overlayPositionProps,
|
|
@@ -184,86 +194,94 @@ function DropdownMenuList({ closeOnSelect = true, onClose, size, menuTitle, empt
|
|
|
184
194
|
...overlayPositionProps.style,
|
|
185
195
|
maxWidth: positionedMaxWidth
|
|
186
196
|
},
|
|
187
|
-
children: /*#__PURE__*/
|
|
197
|
+
children: /*#__PURE__*/ jsxs(DropdownMenuContext, {
|
|
188
198
|
value: contextValue,
|
|
189
|
-
children:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
event.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
199
|
+
children: [
|
|
200
|
+
/*#__PURE__*/ jsx(Stack, {
|
|
201
|
+
children: (stackProps)=>/*#__PURE__*/ jsxs(Overlay, {
|
|
202
|
+
...stackProps,
|
|
203
|
+
onKeyDownCapture: (event)=>{
|
|
204
|
+
if ('Escape' === event.key && 'submenu' === menuLevel.type && event.currentTarget.contains(event.target)) {
|
|
205
|
+
event.stopPropagation();
|
|
206
|
+
if (event.nativeEvent.isComposing) return;
|
|
207
|
+
event.preventDefault();
|
|
208
|
+
menuLevel.close();
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
style: {
|
|
212
|
+
maxHeight: calculateMenuMinHeight(maxHeight, overlayPositionProps.style?.maxHeight),
|
|
213
|
+
maxWidth: void 0 === maxWidth ? '100%' : `min(${'number' == typeof maxWidth ? `${maxWidth}px` : maxWidth}, 100%)`
|
|
214
|
+
},
|
|
215
|
+
children: [
|
|
216
|
+
menuTitle && /*#__PURE__*/ jsxs(Header, {
|
|
217
|
+
padding: searchState ? 'xs' : 'sm lg',
|
|
218
|
+
children: [
|
|
219
|
+
/*#__PURE__*/ jsx(Title, {
|
|
220
|
+
padding: searchState ? 'sm lg' : void 0,
|
|
221
|
+
children: menuTitle
|
|
222
|
+
}),
|
|
223
|
+
searchInput
|
|
224
|
+
]
|
|
225
|
+
}),
|
|
226
|
+
!menuTitle && searchInput,
|
|
227
|
+
/*#__PURE__*/ jsxs(DropdownMenuListWrap, {
|
|
228
|
+
as: "ul",
|
|
229
|
+
ref: menuRef,
|
|
230
|
+
disableTextSelection: disableTextSelection,
|
|
231
|
+
flexGrow: showEmptyMessage ? 1 : void 0,
|
|
232
|
+
width: void 0 === lockedWidth ? void 0 : `${lockedWidth}px`,
|
|
233
|
+
maxWidth: void 0 === lockedWidth ? void 0 : '100%',
|
|
234
|
+
...keyboardMenuProps,
|
|
235
|
+
children: [
|
|
236
|
+
/*#__PURE__*/ jsx(ReserveLeadingSlot, {
|
|
237
|
+
reserve: hasLeadingItems,
|
|
238
|
+
children: /*#__PURE__*/ jsx(DropdownMenuTreeStateContext, {
|
|
239
|
+
value: state,
|
|
240
|
+
children: /*#__PURE__*/ jsx(DropdownMenuRows, {
|
|
241
|
+
collection: stateCollection,
|
|
242
|
+
isWidthLocked: void 0 !== lockedWidth,
|
|
243
|
+
menuRef: menuRef,
|
|
244
|
+
onLockWidth: setLockedWidth,
|
|
245
|
+
virtualized: virtualized,
|
|
246
|
+
widestKey: widestKey,
|
|
247
|
+
closeOnSelect: closeOnSelect,
|
|
248
|
+
disableTextSelection: disableTextSelection,
|
|
249
|
+
onClose: onClose,
|
|
250
|
+
separatorProps: separatorProps,
|
|
251
|
+
size: size
|
|
252
|
+
})
|
|
253
|
+
})
|
|
254
|
+
}),
|
|
255
|
+
showEmptyMessage && /*#__PURE__*/ jsx(Stack, {
|
|
256
|
+
as: "li",
|
|
257
|
+
role: "presentation",
|
|
258
|
+
align: "center",
|
|
259
|
+
justify: "center",
|
|
260
|
+
flexGrow: 1,
|
|
261
|
+
padding: "md lg",
|
|
262
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
263
|
+
variant: "muted",
|
|
264
|
+
children: emptyMessage ?? t('No results found')
|
|
265
|
+
})
|
|
252
266
|
})
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
267
|
+
]
|
|
268
|
+
}),
|
|
269
|
+
menuFooter
|
|
270
|
+
]
|
|
271
|
+
})
|
|
272
|
+
}),
|
|
273
|
+
isRootMenu && /*#__PURE__*/ jsx(Container, {
|
|
274
|
+
display: "contents",
|
|
275
|
+
ref: setOwnPortalContainer
|
|
276
|
+
})
|
|
277
|
+
]
|
|
260
278
|
})
|
|
261
279
|
})
|
|
262
280
|
});
|
|
263
281
|
}
|
|
264
|
-
function DropdownMenuContent({ items, disabledKeys, size, search, virtualizeThreshold, ...props }) {
|
|
282
|
+
function DropdownMenuContent({ items, disabledKeys, size, search, isDismissable, virtualizeThreshold, ...props }) {
|
|
265
283
|
const [searchValue, setSearchValue] = useState('');
|
|
266
|
-
const { virtualizeThreshold: inheritedVirtualizeThreshold } = useContext(DropdownMenuContext);
|
|
284
|
+
const { isDismissable: inheritedIsDismissable, virtualizeThreshold: inheritedVirtualizeThreshold } = useContext(DropdownMenuContext);
|
|
267
285
|
const resolveHref = useResolveLinkHref();
|
|
268
286
|
const activeItems = useMemo(()=>removeHiddenItemsAndSetHref(items, resolveHref), [
|
|
269
287
|
items,
|
|
@@ -288,6 +306,7 @@ function DropdownMenuContent({ items, disabledKeys, size, search, virtualizeThre
|
|
|
288
306
|
disabledKeys: disabledKeys ?? defaultDisabledKeys,
|
|
289
307
|
items: visibleItems,
|
|
290
308
|
isVirtualized: isVirtualized,
|
|
309
|
+
isDismissable: isDismissable ?? inheritedIsDismissable,
|
|
291
310
|
virtualizeThreshold: resolvedVirtualizeThreshold,
|
|
292
311
|
searchState: search ? {
|
|
293
312
|
...search,
|
|
@@ -316,15 +335,24 @@ function DropdownMenuContent({ items, disabledKeys, size, search, virtualizeThre
|
|
|
316
335
|
}
|
|
317
336
|
});
|
|
318
337
|
}
|
|
319
|
-
function DropdownSubmenu({ items, node, isVirtualized, rowProps,
|
|
320
|
-
const {
|
|
338
|
+
function DropdownSubmenu({ isDisabled, items, node, isVirtualized, rowProps, closeOnSelect, disableTextSelection, onClose, size }) {
|
|
339
|
+
const { rootMenuState, parentMenuRef, portalContainer, submenuLevel, isDismissable } = useContext(DropdownMenuContext);
|
|
340
|
+
if (!rootMenuState || !parentMenuRef || void 0 === submenuLevel) throw new Error('DropdownSubmenu must be rendered inside a DropdownMenu');
|
|
321
341
|
const submenu = node.value?.submenu;
|
|
322
342
|
const options = 'object' == typeof submenu ? submenu : {};
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
343
|
+
const submenuState = useDropdownSubmenuState({
|
|
344
|
+
level: submenuLevel,
|
|
345
|
+
rootMenuState,
|
|
346
|
+
triggerKey: node.key
|
|
347
|
+
});
|
|
348
|
+
const submenuRef = useRef(null);
|
|
349
|
+
const { isOpen, triggerRef, triggerProps: { ref: setTriggerElement }, overlayProps } = useOverlay({
|
|
350
|
+
isOpen: submenuState.isOpen,
|
|
351
|
+
onClose: rootMenuState.close,
|
|
352
|
+
isDismissable,
|
|
327
353
|
disableTrigger: isDisabled,
|
|
354
|
+
isKeyboardDismissDisabled: true,
|
|
355
|
+
shouldCloseOnInteractOutside: (target)=>!portalContainer?.parentElement?.contains(target),
|
|
328
356
|
position: options.position ?? 'right-start',
|
|
329
357
|
offset: -4,
|
|
330
358
|
preventOverflowOptions: {
|
|
@@ -332,42 +360,28 @@ function DropdownSubmenu({ items, node, isVirtualized, rowProps, state, closeOnS
|
|
|
332
360
|
crossAxis: true
|
|
333
361
|
}
|
|
334
362
|
});
|
|
335
|
-
const {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
const isFocused = state.selectionManager.focusedKey === node.key;
|
|
363
|
+
const { submenuTriggerProps, submenuProps } = useSubmenuTrigger({
|
|
364
|
+
parentMenuRef,
|
|
365
|
+
submenuRef,
|
|
366
|
+
isDisabled,
|
|
367
|
+
type: 'menu'
|
|
368
|
+
}, submenuState, triggerRef);
|
|
369
|
+
const { submenuLevel: _submenuLevel, onClose: _closeAll, ...submenuMenuProps } = submenuProps;
|
|
343
370
|
return /*#__PURE__*/ jsxs(Container, {
|
|
344
371
|
as: "li",
|
|
345
372
|
display: "contents",
|
|
346
373
|
role: "presentation",
|
|
347
374
|
children: [
|
|
348
375
|
/*#__PURE__*/ jsx(DropdownMenuItem, {
|
|
349
|
-
menuItemRef:
|
|
350
|
-
|
|
351
|
-
if (element && !isOpen && isFocused && rootOverlayState?.isOpen) element.focus();
|
|
352
|
-
}, [
|
|
353
|
-
isOpen,
|
|
354
|
-
isFocused,
|
|
355
|
-
rootOverlayState,
|
|
356
|
-
setTriggerElement
|
|
357
|
-
]),
|
|
358
|
-
id: menuTriggerProps.id,
|
|
359
|
-
"aria-haspopup": menuTriggerProps['aria-haspopup'],
|
|
360
|
-
"aria-expanded": isOpen,
|
|
361
|
-
"aria-controls": menuTriggerProps['aria-controls'],
|
|
362
|
-
submenuRef: isOpen ? overlayRef : void 0,
|
|
376
|
+
menuItemRef: setTriggerElement,
|
|
377
|
+
submenuTriggerProps: submenuTriggerProps,
|
|
363
378
|
renderAs: "div",
|
|
364
379
|
node: node,
|
|
365
380
|
isVirtualized: isVirtualized,
|
|
366
381
|
rowProps: rowProps,
|
|
367
|
-
state: state,
|
|
368
382
|
closeOnSelect: false
|
|
369
383
|
}),
|
|
370
|
-
isOpen && /*#__PURE__*/ jsx(DropdownMenuContent, {
|
|
384
|
+
isOpen && portalContainer && /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(DropdownMenuContent, {
|
|
371
385
|
onClose: onClose,
|
|
372
386
|
closeOnSelect: closeOnSelect,
|
|
373
387
|
disableTextSelection: disableTextSelection,
|
|
@@ -377,12 +391,19 @@ function DropdownSubmenu({ items, node, isVirtualized, rowProps, state, closeOnS
|
|
|
377
391
|
maxWidth: options.maxWidth,
|
|
378
392
|
search: options.search,
|
|
379
393
|
size: size,
|
|
380
|
-
...
|
|
394
|
+
...submenuMenuProps,
|
|
395
|
+
menuLevel: {
|
|
396
|
+
type: 'submenu',
|
|
397
|
+
level: submenuLevel,
|
|
398
|
+
ref: submenuRef,
|
|
399
|
+
close: ()=>{
|
|
400
|
+
submenuState.close();
|
|
401
|
+
triggerRef.current?.focus();
|
|
402
|
+
}
|
|
403
|
+
},
|
|
381
404
|
items: items,
|
|
382
|
-
autoFocus: false,
|
|
383
|
-
overlayState: overlayState,
|
|
384
405
|
overlayPositionProps: overlayProps
|
|
385
|
-
})
|
|
406
|
+
}), portalContainer)
|
|
386
407
|
]
|
|
387
408
|
});
|
|
388
409
|
}
|