@sentry/scraps 0.4.0 → 0.6.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 +74 -8
- package/dist/alert/alert.js +0 -3
- package/dist/badge/badge.js +1 -2
- package/dist/badge/tag.js +4 -4
- package/dist/button/button.js +1 -0
- package/dist/button/index.d.ts +0 -1
- package/dist/button/index.js +0 -1
- package/dist/button/linkButton.js +1 -0
- package/dist/button/styles.js +157 -152
- package/dist/clipboard/copyToClipboardButton.d.ts +15 -0
- package/dist/clipboard/copyToClipboardButton.js +32 -0
- package/dist/clipboard/index.d.ts +1 -0
- package/dist/clipboard/index.js +1 -0
- package/dist/code/index.d.ts +1 -0
- package/dist/code/index.js +1 -0
- package/dist/codeBlock/codeBlock.d.ts +68 -0
- package/dist/codeBlock/codeBlock.js +243 -0
- package/dist/codeBlock/index.d.ts +2 -0
- package/dist/codeBlock/index.js +2 -0
- package/dist/codeBlock/prism.d.ts +11 -0
- package/dist/codeBlock/prism.js +101 -0
- package/dist/codeBlock/styles.d.ts +2 -0
- package/dist/codeBlock/styles.js +133 -0
- package/dist/compactSelect/compactSelect.d.ts +21 -0
- package/dist/compactSelect/compactSelect.js +150 -0
- package/dist/compactSelect/composite.d.ts +54 -0
- package/dist/compactSelect/composite.js +101 -0
- package/dist/compactSelect/control.d.ts +112 -0
- package/dist/compactSelect/control.js +355 -0
- package/dist/compactSelect/gridList/index.d.ts +46 -0
- package/dist/compactSelect/gridList/index.js +102 -0
- package/dist/compactSelect/gridList/option.d.ts +15 -0
- package/dist/compactSelect/gridList/option.js +111 -0
- package/dist/compactSelect/gridList/section.d.ts +15 -0
- package/dist/compactSelect/gridList/section.js +58 -0
- package/dist/compactSelect/highlightText.d.ts +6 -0
- package/dist/compactSelect/highlightText.js +33 -0
- package/dist/compactSelect/index.d.ts +9 -0
- package/dist/compactSelect/index.js +8 -0
- package/dist/compactSelect/list.d.ts +94 -0
- package/dist/compactSelect/list.js +167 -0
- package/dist/compactSelect/listBox/index.d.ts +84 -0
- package/dist/compactSelect/listBox/index.js +175 -0
- package/dist/compactSelect/listBox/option.d.ts +19 -0
- package/dist/compactSelect/listBox/option.js +101 -0
- package/dist/compactSelect/listBox/section.d.ts +21 -0
- package/dist/compactSelect/listBox/section.js +58 -0
- package/dist/compactSelect/menuComponents.d.ts +89 -0
- package/dist/compactSelect/menuComponents.js +117 -0
- package/dist/compactSelect/selectFilterContext.d.ts +2 -0
- package/dist/compactSelect/selectFilterContext.js +3 -0
- package/dist/compactSelect/styles.d.ts +39 -0
- package/dist/compactSelect/styles.js +155 -0
- package/dist/compactSelect/types.d.ts +1 -0
- package/dist/compactSelect/types.js +0 -0
- package/dist/compactSelect/useVirtualizedItems.d.ts +52 -0
- package/dist/compactSelect/useVirtualizedItems.js +74 -0
- package/dist/compactSelect/utils.d.ts +80 -0
- package/dist/compactSelect/utils.js +264 -0
- package/dist/confirm/index.d.ts +153 -0
- package/dist/confirm/index.js +132 -0
- 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/descriptionList/descriptionList.js +4 -3
- package/dist/disclosure/disclosure.js +2 -2
- package/dist/dragHandle/dragHandle.d.ts +3 -1
- package/dist/dragHandle/dragHandle.js +8 -5
- package/dist/drawer/components.d.ts +46 -0
- package/dist/drawer/components.js +265 -0
- package/dist/drawer/globalDrawer.d.ts +106 -0
- package/dist/drawer/globalDrawer.js +173 -0
- package/dist/drawer/index.d.ts +3 -0
- package/dist/drawer/index.js +2 -0
- package/dist/drawer/useDrawerResizing.d.ts +19 -0
- package/dist/drawer/useDrawerResizing.js +111 -0
- package/dist/drawer/useDrawerWidth.d.ts +1 -0
- package/dist/drawer/useDrawerWidth.js +42 -0
- package/dist/dropdownMenu/content.d.ts +1 -0
- package/dist/dropdownMenu/content.js +1 -0
- package/dist/dropdownMenu/context.d.ts +39 -0
- package/dist/dropdownMenu/context.js +3 -0
- package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
- package/dist/dropdownMenu/dropdownMenu.js +109 -0
- package/dist/dropdownMenu/index.d.ts +2 -0
- package/dist/dropdownMenu/index.js +1 -0
- package/dist/dropdownMenu/item.d.ts +140 -0
- package/dist/dropdownMenu/item.js +142 -0
- package/dist/dropdownMenu/list.d.ts +85 -0
- package/dist/dropdownMenu/list.js +429 -0
- package/dist/dropdownMenu/search.d.ts +16 -0
- package/dist/dropdownMenu/search.js +16 -0
- package/dist/dropdownMenu/section.d.ts +21 -0
- package/dist/dropdownMenu/section.js +40 -0
- package/dist/dropdownMenu/separator.d.ts +7 -0
- package/dist/dropdownMenu/separator.js +15 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +24 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.js +31 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
- 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.d.ts +21 -0
- package/dist/dropdownMenu/utils.js +55 -0
- 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/FormSearch.d.ts +19 -0
- package/dist/form/FormSearch.js +4 -0
- package/dist/form/autoSaveForm.d.ts +110 -0
- package/dist/form/autoSaveForm.js +100 -0
- package/dist/{formPresentation → form}/displayField.js +2 -2
- package/dist/form/field/baseField.d.ts +23 -0
- package/dist/form/field/baseField.js +116 -0
- package/dist/form/field/checkboxField.d.ts +11 -0
- package/dist/form/field/checkboxField.js +42 -0
- package/dist/form/field/checkboxGroupField.d.ts +16 -0
- package/dist/form/field/checkboxGroupField.js +80 -0
- package/dist/form/field/compactSelectField.d.ts +19 -0
- package/dist/form/field/compactSelectField.js +77 -0
- package/dist/{formPresentation → form/field}/fieldIds.js +1 -1
- package/dist/form/field/inputField.d.ts +19 -0
- package/dist/form/field/inputField.js +31 -0
- package/dist/{formPresentation → form/field}/meta.js +6 -6
- package/dist/form/field/numberField.d.ts +5 -0
- package/dist/form/field/numberField.js +11 -0
- package/dist/form/field/passwordField.d.ts +3 -0
- package/dist/form/field/passwordField.js +27 -0
- package/dist/form/field/radioGroupField.d.ts +16 -0
- package/dist/form/field/radioGroupField.js +92 -0
- package/dist/form/field/rangeField.d.ts +8 -0
- package/dist/form/field/rangeField.js +34 -0
- package/dist/form/field/selectAsyncField.d.ts +31 -0
- package/dist/form/field/selectAsyncField.js +22 -0
- package/dist/form/field/selectField.d.ts +9 -0
- package/dist/form/field/selectField.js +72 -0
- package/dist/form/field/switchField.d.ts +7 -0
- package/dist/form/field/switchField.js +37 -0
- package/dist/form/field/textAreaField.d.ts +7 -0
- package/dist/form/field/textAreaField.js +25 -0
- package/dist/{formPresentation → form}/formContext.js +1 -1
- package/dist/form/formErrorContext/index.d.ts +9 -0
- package/dist/form/formErrorContext/index.js +7 -0
- package/dist/form/index.d.ts +9 -0
- package/dist/form/index.js +8 -0
- package/dist/{formPresentation → form/layout}/base.d.ts +1 -1
- package/dist/{formPresentation → form/layout}/base.js +1 -1
- package/dist/form/layout/fieldGroup.d.ts +6 -0
- package/dist/form/layout/fieldGroup.js +60 -0
- package/dist/{formPresentation/fieldLayout.d.ts → form/layout/index.d.ts} +1 -1
- package/dist/{formPresentation/fieldLayout.js → form/layout/index.js} +3 -3
- package/dist/{formPresentation → form/layout}/useStackedLayout.js +1 -1
- package/dist/form/scrapsForm.d.ts +220 -0
- package/dist/form/scrapsForm.js +126 -0
- package/dist/fzf.d.ts +9 -0
- package/dist/fzf.js +155 -0
- package/dist/hotkey/hotkey.d.ts +9 -8
- package/dist/hotkey/hotkey.js +13 -6
- package/dist/hotkey/index.d.ts +2 -1
- package/dist/hotkey/index.js +2 -1
- package/dist/hotkey/keyMappings.d.ts +1 -15
- package/dist/hotkey/keyMappings.js +29 -174
- package/dist/hotkey/useHotkeys.d.ts +3 -47
- package/dist/hotkey/useHotkeys.js +8 -42
- package/dist/image/image.js +2 -1
- package/dist/info/infoTip.d.ts +1 -1
- package/dist/info/infoTip.js +4 -3
- package/dist/input/index.d.ts +0 -3
- package/dist/input/index.js +0 -2
- package/dist/input/input.d.ts +2 -0
- package/dist/input/input.js +2 -0
- package/dist/input/passwordManagerIgnoreProps.d.ts +11 -0
- package/dist/input/passwordManagerIgnoreProps.js +8 -0
- package/dist/layout/container.d.ts +8 -2
- package/dist/layout/container.js +2 -2
- package/dist/layout/index.d.ts +2 -2
- package/dist/layout/index.js +1 -1
- package/dist/layout/styles.d.ts +2 -1
- package/dist/layout/styles.js +11 -5
- 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/link.js +4 -3
- package/dist/link/linkBehaviorContext.d.ts +11 -0
- package/dist/link/linkBehaviorContext.js +48 -11
- package/dist/menu/index.d.ts +1 -1
- package/dist/menu/index.js +1 -1
- package/dist/menu/menu.d.ts +14 -8
- package/dist/menu/menu.js +163 -60
- package/dist/modal/components.d.ts +19 -0
- package/dist/modal/components.js +99 -0
- package/dist/modal/errorBoundary.d.ts +2 -0
- package/dist/modal/errorBoundary.js +35 -0
- package/dist/modal/index.d.ts +33 -0
- package/dist/modal/index.js +260 -0
- package/dist/modal/portal.d.ts +1 -0
- package/dist/modal/portal.js +10 -0
- package/dist/modal/state.d.ts +17 -0
- package/dist/modal/state.js +41 -0
- package/dist/modal/types.d.ts +75 -0
- package/dist/modal/types.js +0 -0
- package/dist/numberInput/index.d.ts +3 -0
- package/dist/numberInput/index.js +2 -0
- package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberDragInput.js +1 -1
- package/dist/{input → numberInput}/numberInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberInput.js +1 -1
- package/dist/overlayContext.d.ts +29 -0
- package/dist/overlayContext.js +7 -0
- package/dist/pagination/index.d.ts +1 -0
- package/dist/pagination/index.js +1 -0
- package/dist/pagination/pagination.d.ts +24 -0
- package/dist/pagination/pagination.js +63 -0
- package/dist/pictureInPicture/index.d.ts +2 -0
- package/dist/pictureInPicture/index.js +2 -0
- package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
- package/dist/pictureInPicture/pictureInPicture.js +100 -0
- package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
- package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
- package/dist/pictureInPicture/portalContext.d.ts +2 -0
- package/dist/pictureInPicture/portalContext.js +3 -0
- 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/revealOnHover/revealOnHover.js +1 -1
- package/dist/segmentedControl/segmentedControl.js +1 -1
- package/dist/select/filter.d.ts +4 -0
- package/dist/select/filter.js +12 -0
- package/dist/select/index.d.ts +3 -0
- package/dist/select/index.js +2 -0
- package/dist/select/option.d.ts +16 -0
- package/dist/select/option.js +81 -0
- package/dist/select/reactSelectWrapper.d.ts +8 -0
- package/dist/select/reactSelectWrapper.js +25 -0
- package/dist/select/select.d.ts +79 -0
- package/dist/select/select.js +454 -0
- package/dist/select/styles.d.ts +9 -0
- package/dist/select/styles.js +27 -0
- package/dist/select/types.d.ts +60 -0
- package/dist/select/types.js +0 -0
- package/dist/select/virtualizedMenuList.d.ts +24 -0
- package/dist/select/virtualizedMenuList.js +123 -0
- package/dist/slideOverPanel.d.ts +20 -0
- package/dist/slideOverPanel.js +141 -0
- package/dist/splitPanel/splitPanel.d.ts +3 -1
- package/dist/splitPanel/splitPanel.js +2 -1
- package/dist/table/table.d.ts +1 -1
- package/dist/table/table.js +39 -20
- package/dist/table/useColumnResize.d.ts +6 -5
- package/dist/table/useColumnResize.js +5 -4
- package/dist/tabs/context.d.ts +9 -0
- package/dist/tabs/context.js +9 -0
- package/dist/tabs/index.d.ts +2 -0
- package/dist/tabs/index.js +1 -0
- package/dist/tabs/item.d.ts +24 -0
- package/dist/tabs/item.js +4 -0
- package/dist/tabs/tab.d.ts +22 -0
- package/dist/tabs/tab.js +208 -0
- package/dist/tabs/tabList.d.ts +18 -0
- package/dist/tabs/tabList.js +258 -0
- package/dist/tabs/tabPanels.d.ts +13 -0
- package/dist/tabs/tabPanels.js +62 -0
- package/dist/tabs/tabs.d.ts +53 -0
- package/dist/tabs/tabs.js +59 -0
- package/dist/tabs/utils.d.ts +3 -0
- package/dist/tabs/utils.js +6 -0
- package/dist/text/heading.d.ts +1 -1
- package/dist/text/heading.js +1 -1
- package/dist/text/prose.d.ts +2 -2
- package/dist/text/styles.js +1 -1
- package/dist/text/text.d.ts +1 -1
- package/dist/text/text.js +1 -1
- package/dist/theme/dark.js +9 -9
- package/dist/theme/light.js +9 -9
- package/dist/theme/theme.d.ts +34 -34
- package/dist/theme/theme.js +9 -0
- package/dist/theme/types.d.ts +20 -2
- package/dist/tooltip/tooltip.js +2 -5
- 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/useMedia.d.ts +15 -0
- package/dist/useMedia.js +24 -0
- package/dist/useOnClickOutside.d.ts +2 -0
- package/dist/useOnClickOutside.js +22 -0
- package/dist/useOverlay.d.ts +1 -0
- package/dist/useOverlay.js +1 -0
- package/dist/useVirtualCollection.d.ts +154 -0
- package/dist/useVirtualCollection.js +143 -0
- package/dist/useVirtualRows.d.ts +26 -0
- package/dist/useVirtualRows.js +26 -0
- package/dist/virtualCollectionLayout.d.ts +51 -0
- package/dist/virtualCollectionLayout.js +49 -0
- 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 +140 -23
- package/dist/datetime.d.ts +0 -39
- package/dist/datetime.js +0 -20
- package/dist/formPresentation/index.d.ts +0 -8
- package/dist/formPresentation/index.js +0 -8
- package/dist/interactionStateLayer/index.d.ts +0 -1
- package/dist/interactionStateLayer/index.js +0 -1
- package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
- package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
- package/dist/unreachable.d.ts +0 -1
- package/dist/unreachable.js +0 -4
- /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
- /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
- /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
- /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.js +0 -0
- /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
3
|
-
import * as __rspack_external_query_string_78b5d812 from "query-string";
|
|
2
|
+
import { createContext, useCallback, useContext } from "react";
|
|
4
3
|
const LinkBehaviorContext = /*#__PURE__*/ createContext(null);
|
|
5
4
|
function AnchorLink({ to, replace: _replace, preventScrollReset: _preventScrollReset, reloadDocument: _reloadDocument, state: _state, ...props }) {
|
|
6
|
-
|
|
7
|
-
...props,
|
|
8
|
-
href: to
|
|
9
|
-
});
|
|
10
|
-
const { pathname = '', hash = '', search = '', query } = to;
|
|
11
|
-
const querySearch = query ? __rspack_external_query_string_78b5d812.stringify(query) : search;
|
|
12
|
-
const href = `${pathname}${querySearch && !querySearch.startsWith('?') ? '?' : ''}${querySearch}${hash && !hash.startsWith('#') ? '#' : ''}${hash}`;
|
|
5
|
+
const { stringify } = useLinkQueryString();
|
|
13
6
|
return /*#__PURE__*/ jsx("a", {
|
|
14
7
|
...props,
|
|
15
|
-
href:
|
|
8
|
+
href: destinationToHref(to, stringify)
|
|
16
9
|
});
|
|
17
10
|
}
|
|
18
11
|
const defaultLinkBehavior = ()=>({
|
|
@@ -28,4 +21,48 @@ const useLinkBehavior = (props)=>{
|
|
|
28
21
|
behavior: ()=>behavior(props)
|
|
29
22
|
};
|
|
30
23
|
};
|
|
31
|
-
|
|
24
|
+
function parseQuery(search) {
|
|
25
|
+
const query = Object.create(null);
|
|
26
|
+
for (const [key, value] of new URLSearchParams(search)){
|
|
27
|
+
const existing = query[key];
|
|
28
|
+
if (void 0 === existing) query[key] = value;
|
|
29
|
+
else query[key] = [
|
|
30
|
+
...Array.isArray(existing) ? existing : [
|
|
31
|
+
existing
|
|
32
|
+
],
|
|
33
|
+
value
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
return query;
|
|
37
|
+
}
|
|
38
|
+
function stringifyQuery(query) {
|
|
39
|
+
const params = new URLSearchParams();
|
|
40
|
+
for (const [key, value] of Object.entries(query))for (const item of Array.isArray(value) ? value : [
|
|
41
|
+
value
|
|
42
|
+
])if (void 0 !== item) params.append(key, String(item));
|
|
43
|
+
return params.toString();
|
|
44
|
+
}
|
|
45
|
+
function useLinkQueryString() {
|
|
46
|
+
const linkBehavior = useContext(LinkBehaviorContext);
|
|
47
|
+
return {
|
|
48
|
+
parse: linkBehavior?.parse ?? parseQuery,
|
|
49
|
+
stringify: linkBehavior?.stringify ?? stringifyQuery
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function destinationToHref(to, stringify) {
|
|
53
|
+
if ('string' == typeof to) return to;
|
|
54
|
+
const { pathname = '', hash = '', search = '', query } = to;
|
|
55
|
+
const querySearch = query ? stringify(query) : search;
|
|
56
|
+
return `${pathname}${querySearch && !querySearch.startsWith('?') ? '?' : ''}${querySearch}${hash && !hash.startsWith('#') ? '#' : ''}${hash}`;
|
|
57
|
+
}
|
|
58
|
+
function useResolveLinkHref() {
|
|
59
|
+
const linkBehavior = useContext(LinkBehaviorContext);
|
|
60
|
+
const { stringify } = useLinkQueryString();
|
|
61
|
+
return useCallback((to)=>destinationToHref(linkBehavior ? linkBehavior.behavior({
|
|
62
|
+
to
|
|
63
|
+
}).to : to, stringify), [
|
|
64
|
+
linkBehavior,
|
|
65
|
+
stringify
|
|
66
|
+
]);
|
|
67
|
+
}
|
|
68
|
+
export { LinkBehaviorContextProvider, useLinkBehavior, useLinkQueryString, useResolveLinkHref };
|
package/dist/menu/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Shared presentation; consumers own state, keyboard behavior, and ARIA roles. */
|
|
2
|
-
export { calculateMenuMinHeight, MenuFooterLayout as Footer, MenuHeaderLayout as Header, MenuHeading as Title, MenuSectionLabel as SectionLabel, MenuSectionHeader as SectionHeader, MenuSectionGroup as SectionGroup, MenuSectionList as SectionList, MenuListItem as ListItem, ReserveLeadingSlot, MenuSectionSeparator as SectionSeparator, SearchInput as Search, useReserveLeadingSlot, } from './menu.js';
|
|
2
|
+
export { calculateMenuMinHeight, MenuFooterLayout as Footer, MenuHeaderLayout as Header, MenuHeading as Title, MenuSectionLabel as SectionLabel, MenuSectionHeader as SectionHeader, MenuSectionGroup as SectionGroup, MenuSectionList as SectionList, MenuListItem as ListItem, ReserveLeadingSlot, MenuSectionSeparator as SectionSeparator, SECTION_ITEM_SPACE, SearchInput as Search, useReserveLeadingSlot, focusMenuItemDetails, } from './menu.js';
|
|
3
3
|
export type { ListItemProps, MenuItemTrailingAction } from './menu.js';
|
|
4
4
|
export { ControlContext } from './controlContext.js';
|
|
5
5
|
export { DropdownButton, type DropdownButtonProps } from './dropdownButton.js';
|
package/dist/menu/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { MenuFooterLayout as Footer, MenuHeaderLayout as Header, MenuHeading as Title, MenuListItem as ListItem, MenuSectionGroup as SectionGroup, MenuSectionHeader as SectionHeader, MenuSectionLabel as SectionLabel, MenuSectionList as SectionList, MenuSectionSeparator as SectionSeparator, ReserveLeadingSlot, SearchInput as Search, calculateMenuMinHeight, useReserveLeadingSlot } from "./menu.js";
|
|
1
|
+
export { MenuFooterLayout as Footer, MenuHeaderLayout as Header, MenuHeading as Title, MenuListItem as ListItem, MenuSectionGroup as SectionGroup, MenuSectionHeader as SectionHeader, MenuSectionLabel as SectionLabel, MenuSectionList as SectionList, MenuSectionSeparator as SectionSeparator, ReserveLeadingSlot, SECTION_ITEM_SPACE, SearchInput as Search, calculateMenuMinHeight, focusMenuItemDetails, useReserveLeadingSlot } from "./menu.js";
|
|
2
2
|
export { ControlContext } from "./controlContext.js";
|
|
3
3
|
export { DropdownButton } from "./dropdownButton.js";
|
package/dist/menu/menu.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type * as React from 'react';
|
|
|
2
2
|
import { InputGroup } from '../input/index.js';
|
|
3
3
|
import { type FlexProps } from '../layout/index.js';
|
|
4
4
|
import type { ContainerProps } from '../layout/container.js';
|
|
5
|
+
import { Text } from '../text/index.js';
|
|
5
6
|
import type { FormSize } from '../theme/index.js';
|
|
6
7
|
import type { TooltipProps } from '../tooltip/index.js';
|
|
7
8
|
/** Caps a requested menu height by the space available to its overlay. */
|
|
@@ -14,9 +15,10 @@ export declare function MenuHeading({ children, padding, }: {
|
|
|
14
15
|
padding?: ContainerProps['padding'];
|
|
15
16
|
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
16
17
|
/** Text style for a heading within a menu section. */
|
|
17
|
-
export declare function MenuSectionLabel({ children, padding, ...props }: Omit<React.HTMLAttributes<HTMLSpanElement>, 'color' | 'style'> & {
|
|
18
|
+
export declare function MenuSectionLabel({ children, padding, size, ...props }: Omit<React.HTMLAttributes<HTMLSpanElement>, 'color' | 'style'> & {
|
|
18
19
|
children: React.ReactNode;
|
|
19
20
|
padding?: ContainerProps['padding'];
|
|
21
|
+
size?: React.ComponentProps<typeof Text>['size'];
|
|
20
22
|
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
21
23
|
/** Layout for a menu section heading and an optional action beside it. */
|
|
22
24
|
export declare function MenuSectionHeader({ children, trailingAction, ...props }: FlexProps & {
|
|
@@ -27,7 +29,7 @@ export declare function MenuSectionSeparator(): import("@emotion/react/jsx-runti
|
|
|
27
29
|
/** List item wrapper for a menu section. */
|
|
28
30
|
export declare function MenuSectionGroup(props: ContainerProps<'li'>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
29
31
|
/** List wrapper for the items within a menu section. */
|
|
30
|
-
export declare function MenuSectionList(props:
|
|
32
|
+
export declare function MenuSectionList(props: FlexProps<'ul'>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
31
33
|
/** Container for menu footer actions, with a divider above it. */
|
|
32
34
|
export declare function MenuFooterLayout(props: FlexProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
33
35
|
type SearchInputProps = React.ComponentPropsWithRef<typeof InputGroup.Input> & {
|
|
@@ -47,15 +49,16 @@ export declare function ReserveLeadingSlot({ reserve, children, }: {
|
|
|
47
49
|
/** Whether the surrounding menu reserves a leading slot for every item. */
|
|
48
50
|
export declare function useReserveLeadingSlot(): boolean;
|
|
49
51
|
/**
|
|
50
|
-
* Menu item priority. Determines the text
|
|
52
|
+
* Menu item priority. Determines the text color.
|
|
51
53
|
*/
|
|
52
54
|
type Priority = 'primary' | 'danger' | 'default';
|
|
55
|
+
/** Space token between the items of a dropdown menu section. */
|
|
56
|
+
export declare const SECTION_ITEM_SPACE = "2xs";
|
|
53
57
|
declare const StyledInnerWrap: import("@emotion/styled").StyledComponent<((FlexProps<import("../layout/container.js").ContainerElement> | import("../layout/flex.js").FlexPropsWithRenderFunction<import("../layout/container.js").ContainerElement>) & {
|
|
54
58
|
theme?: import("@emotion/react").Theme;
|
|
55
59
|
}) & {
|
|
56
60
|
disabled: boolean;
|
|
57
61
|
hasTrailingAction: boolean;
|
|
58
|
-
isFocused: boolean;
|
|
59
62
|
priority: Priority;
|
|
60
63
|
size?: FormSize;
|
|
61
64
|
}, {}, {}>;
|
|
@@ -86,6 +89,8 @@ export interface MenuItemTrailingAction {
|
|
|
86
89
|
/** Accessible name for the button, also shown as its tooltip. */
|
|
87
90
|
label: string;
|
|
88
91
|
onAction: () => void;
|
|
92
|
+
/** Shows a loading indicator in place of the icon while the action runs. */
|
|
93
|
+
busy?: boolean;
|
|
89
94
|
}
|
|
90
95
|
export type ListItemProps = {
|
|
91
96
|
/**
|
|
@@ -108,7 +113,7 @@ export type ListItemProps = {
|
|
|
108
113
|
*/
|
|
109
114
|
leadingItems?: ExtraContent;
|
|
110
115
|
/**
|
|
111
|
-
* Accented text
|
|
116
|
+
* Accented text color.
|
|
112
117
|
*/
|
|
113
118
|
priority?: Priority;
|
|
114
119
|
/**
|
|
@@ -145,15 +150,16 @@ interface OtherProps<T extends React.ElementType> {
|
|
|
145
150
|
as?: 'div' | 'p';
|
|
146
151
|
id?: string;
|
|
147
152
|
};
|
|
153
|
+
onDetailsHoverChange?: (isHovered: boolean, event: React.PointerEvent) => void;
|
|
148
154
|
trailingAction?: MenuItemTrailingAction;
|
|
149
155
|
/** Ref to the trailing action's button. */
|
|
150
156
|
trailingActionRef?: React.Ref<HTMLButtonElement>;
|
|
151
|
-
/** Props for the wrapper around the trailing action. */
|
|
152
|
-
trailingActionWrapperProps?: React.ComponentPropsWithRef<'div'>;
|
|
153
157
|
}
|
|
154
158
|
interface MenuListItemProps<T extends React.ElementType = 'li'> extends ListItemProps, OtherProps<T> {
|
|
155
159
|
ref?: React.ComponentPropsWithRef<NoInfer<T>>['ref'];
|
|
156
160
|
}
|
|
157
161
|
/** Renders the shared visual shell for menu and select items. */
|
|
158
|
-
export declare function MenuListItem<T extends React.ElementType = 'li'>({ label, details, as, priority, size, disabled, leadingItems, trailingItems, trailingAction, isFocused, isSelected, isPressed, innerWrapProps, labelProps, detailsProps, showDetailsInOverlay, tooltip, tooltipOptions, ref, trailingActionRef,
|
|
162
|
+
export declare function MenuListItem<T extends React.ElementType = 'li'>({ label, details, as, priority, size, disabled, leadingItems, trailingItems, trailingAction, isFocused, isSelected, isPressed, innerWrapProps, labelProps, detailsProps, showDetailsInOverlay, onDetailsHoverChange, tooltip, tooltipOptions, ref, trailingActionRef, ...props }: MenuListItemProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
163
|
+
/** Moves focus into a menu item's overlay details, returning whether it could. */
|
|
164
|
+
export declare function focusMenuItemDetails(item: Element | null): boolean;
|
|
159
165
|
export {};
|
package/dist/menu/menu.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext,
|
|
2
|
+
import { createContext, useContext, useId, useState } from "react";
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
4
|
import is_prop_valid from "@emotion/is-prop-valid";
|
|
5
5
|
import { css, useTheme } from "@emotion/react";
|
|
6
6
|
import styled from "@emotion/styled";
|
|
7
7
|
import { autoUpdate, hide, offset, useFloating } from "@floating-ui/react-dom";
|
|
8
|
-
import {
|
|
8
|
+
import { FocusScope, getFocusableTreeWalker } from "@react-aria/focus";
|
|
9
|
+
import { mergeProps, mergeRefs } from "@react-aria/utils";
|
|
10
|
+
import { VisuallyHidden } from "@react-aria/visually-hidden";
|
|
9
11
|
import { IconSearch } from "@sentry/icons/search";
|
|
10
12
|
import { Button } from "../button/index.js";
|
|
11
13
|
import { InputGroup } from "../input/index.js";
|
|
12
|
-
import interactionStateLayer from "../interactionStateLayer/index.js";
|
|
13
14
|
import { Container, Flex, Stack } from "../layout/index.js";
|
|
14
15
|
import { Overlay, PositionWrapper } from "../overlay.js";
|
|
15
16
|
import { flipOverlay, shiftOverlay } from "../overlayPositioning.js";
|
|
16
17
|
import { Separator } from "../separator/index.js";
|
|
17
18
|
import { Text } from "../text/index.js";
|
|
18
19
|
import { Tooltip } from "../tooltip/index.js";
|
|
20
|
+
import { useTranslation } from "../translation/useTranslation.js";
|
|
19
21
|
function calculateMenuMinHeight(first, second) {
|
|
20
22
|
if (void 0 === first) return 'number' == typeof second ? `${second}px` : second;
|
|
21
23
|
if (void 0 === second) return 'number' == typeof first ? `${first}px` : first;
|
|
@@ -25,7 +27,7 @@ function calculateMenuMinHeight(first, second) {
|
|
|
25
27
|
}
|
|
26
28
|
function MenuHeaderLayout(props) {
|
|
27
29
|
return /*#__PURE__*/ jsx(Stack, {
|
|
28
|
-
borderBottom: "
|
|
30
|
+
borderBottom: "secondary",
|
|
29
31
|
gap: "0",
|
|
30
32
|
...props
|
|
31
33
|
});
|
|
@@ -43,12 +45,12 @@ function MenuHeading({ children, padding }) {
|
|
|
43
45
|
children: heading
|
|
44
46
|
}) : heading;
|
|
45
47
|
}
|
|
46
|
-
function MenuSectionLabel({ children, padding, ...props }) {
|
|
48
|
+
function MenuSectionLabel({ children, padding, size = 'sm', ...props }) {
|
|
47
49
|
return /*#__PURE__*/ jsx(Container, {
|
|
48
50
|
padding: padding,
|
|
49
51
|
children: /*#__PURE__*/ jsx(Text, {
|
|
50
52
|
as: "span",
|
|
51
|
-
size:
|
|
53
|
+
size: size,
|
|
52
54
|
density: "fixed",
|
|
53
55
|
bold: true,
|
|
54
56
|
tabular: true,
|
|
@@ -74,7 +76,7 @@ function MenuSectionHeader({ children, trailingAction, ...props }) {
|
|
|
74
76
|
function MenuSectionSeparator() {
|
|
75
77
|
return /*#__PURE__*/ jsx(Separator, {
|
|
76
78
|
orientation: "horizontal",
|
|
77
|
-
border: "
|
|
79
|
+
border: "secondary"
|
|
78
80
|
});
|
|
79
81
|
}
|
|
80
82
|
function MenuSectionGroup(props) {
|
|
@@ -85,7 +87,7 @@ function MenuSectionGroup(props) {
|
|
|
85
87
|
});
|
|
86
88
|
}
|
|
87
89
|
function MenuSectionList(props) {
|
|
88
|
-
return /*#__PURE__*/ jsx(
|
|
90
|
+
return /*#__PURE__*/ jsx(Stack, {
|
|
89
91
|
as: "ul",
|
|
90
92
|
role: "presentation",
|
|
91
93
|
margin: "0",
|
|
@@ -95,7 +97,7 @@ function MenuSectionList(props) {
|
|
|
95
97
|
}
|
|
96
98
|
function MenuFooterLayout(props) {
|
|
97
99
|
return /*#__PURE__*/ jsx(Flex, {
|
|
98
|
-
borderTop: "
|
|
100
|
+
borderTop: "secondary",
|
|
99
101
|
align: "center",
|
|
100
102
|
padding: "md lg",
|
|
101
103
|
...props
|
|
@@ -120,6 +122,7 @@ function SearchInput({ padding = 'xs', ...props }) {
|
|
|
120
122
|
}),
|
|
121
123
|
/*#__PURE__*/ jsx(InputGroup.Input, {
|
|
122
124
|
size: "xs",
|
|
125
|
+
type: "search",
|
|
123
126
|
...props
|
|
124
127
|
})
|
|
125
128
|
]
|
|
@@ -138,6 +141,7 @@ function useReserveLeadingSlot() {
|
|
|
138
141
|
}
|
|
139
142
|
const TRAILING_ACTION_INSET = 'lg';
|
|
140
143
|
const TRAILING_ACTION_SPACE = '3xl';
|
|
144
|
+
const SECTION_ITEM_SPACE = '2xs';
|
|
141
145
|
const ITEM_PADDING_BY_SIZE = {
|
|
142
146
|
xs: 'xs md xs lg',
|
|
143
147
|
sm: 'sm md sm lg',
|
|
@@ -169,7 +173,6 @@ const StyledInnerWrap = styled(Flex, {
|
|
|
169
173
|
'alignSelf'
|
|
170
174
|
].includes(prop)) && ![
|
|
171
175
|
'disabled',
|
|
172
|
-
'isFocused',
|
|
173
176
|
'hasTrailingAction',
|
|
174
177
|
'priority'
|
|
175
178
|
].includes(prop)
|
|
@@ -178,6 +181,7 @@ const StyledInnerWrap = styled(Flex, {
|
|
|
178
181
|
position: relative;
|
|
179
182
|
border-radius: ${(p)=>p.theme.radius.md};
|
|
180
183
|
box-sizing: border-box;
|
|
184
|
+
background: ${(p)=>p.theme.tokens.interactive.transparent.neutral.background.rest};
|
|
181
185
|
|
|
182
186
|
font-size: ${(p)=>p.theme.form[p.size ?? 'md'].fontSize};
|
|
183
187
|
|
|
@@ -191,21 +195,28 @@ const StyledInnerWrap = styled(Flex, {
|
|
|
191
195
|
}
|
|
192
196
|
${(p)=>p.disabled && 'cursor: default;'}
|
|
193
197
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
198
|
+
${(p)=>!p.disabled && css`
|
|
199
|
+
&[data-focused='true'] {
|
|
200
|
+
${!p.hasTrailingAction && 'z-index: 1;'}
|
|
201
|
+
background:
|
|
202
|
+
linear-gradient(
|
|
203
|
+
${p.theme.tokens.interactive.transparent.neutral.background.hover},
|
|
204
|
+
${p.theme.tokens.interactive.transparent.neutral.background.hover}
|
|
205
|
+
),
|
|
206
|
+
${p.theme.tokens.background.overlay};
|
|
207
|
+
}
|
|
203
208
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
+
&[data-pressed='true'],
|
|
210
|
+
&:active:not([data-pressed='false']),
|
|
211
|
+
&[aria-expanded='true']:not([data-pressed='false']),
|
|
212
|
+
&[aria-selected='true']:not([data-pressed='false']) {
|
|
213
|
+
${!p.hasTrailingAction && 'z-index: 1;'}
|
|
214
|
+
background:
|
|
215
|
+
linear-gradient(
|
|
216
|
+
${p.theme.tokens.interactive.transparent.neutral.background.active},
|
|
217
|
+
${p.theme.tokens.interactive.transparent.neutral.background.active}
|
|
218
|
+
),
|
|
219
|
+
${p.theme.tokens.background.overlay};
|
|
209
220
|
}
|
|
210
221
|
`}
|
|
211
222
|
`;
|
|
@@ -243,23 +254,56 @@ const StyledDetails = styled('div')`
|
|
|
243
254
|
color: ${getTextColor(p)};
|
|
244
255
|
`}
|
|
245
256
|
`;
|
|
246
|
-
function MenuListItem({ label, details, as, priority = 'default', size, disabled = false, leadingItems = false, trailingItems = false, trailingAction, isFocused = false, isSelected = false, isPressed, innerWrapProps = {}, labelProps = {}, detailsProps = {}, showDetailsInOverlay = false, tooltip, tooltipOptions, ref, trailingActionRef,
|
|
247
|
-
const
|
|
257
|
+
function MenuListItem({ label, details, as, priority = 'default', size, disabled = false, leadingItems = false, trailingItems = false, trailingAction, isFocused = false, isSelected = false, isPressed, innerWrapProps = {}, labelProps = {}, detailsProps = {}, showDetailsInOverlay = false, onDetailsHoverChange, tooltip, tooltipOptions, ref, trailingActionRef, ...props }) {
|
|
258
|
+
const [itemElement, setItemElement] = useState(null);
|
|
259
|
+
const [returnFocusTarget, setReturnFocusTarget] = useState(null);
|
|
248
260
|
const theme = useTheme();
|
|
249
261
|
const labelId = useId();
|
|
250
262
|
const detailId = useId();
|
|
251
263
|
const hasInlineDetails = Boolean(details && !showDetailsInOverlay);
|
|
252
264
|
const reserveLeadingSlot = useReserveLeadingSlot();
|
|
253
265
|
const hasLeadingSlot = Boolean(leadingItems) || reserveLeadingSlot;
|
|
266
|
+
const [detailsElement, setDetailsElement] = useState(null);
|
|
267
|
+
const [isDetailsHovered, setIsDetailsHovered] = useState(false);
|
|
268
|
+
const [hasFocusInDetails, setHasFocusInDetails] = useState(false);
|
|
269
|
+
const isDetailsActive = isDetailsHovered || hasFocusInDetails;
|
|
270
|
+
const showOverlayDetails = showDetailsInOverlay && Boolean(details) && (isFocused || isDetailsActive);
|
|
271
|
+
const detailsContain = (target)=>target instanceof Node && Boolean(detailsElement?.contains(target));
|
|
272
|
+
const itemProps = mergeProps({
|
|
273
|
+
'aria-describedby': details ? detailId : void 0
|
|
274
|
+
}, props, {
|
|
275
|
+
onKeyDown: (e)=>{
|
|
276
|
+
if ('ArrowRight' === e.key && e.target === e.currentTarget && focusMenuItemDetails(e.currentTarget)) {
|
|
277
|
+
e.preventDefault();
|
|
278
|
+
e.stopPropagation();
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
onFocus: (e)=>{
|
|
282
|
+
if (detailsContain(e.target)) {
|
|
283
|
+
e.stopPropagation();
|
|
284
|
+
if (!detailsContain(e.relatedTarget) && e.relatedTarget instanceof HTMLElement) setReturnFocusTarget(e.relatedTarget);
|
|
285
|
+
setHasFocusInDetails(true);
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
onBlur: (e)=>{
|
|
289
|
+
if (detailsContain(e.target)) e.stopPropagation();
|
|
290
|
+
setHasFocusInDetails(detailsContain(e.relatedTarget));
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
const returnFocus = ()=>{
|
|
294
|
+
const target = returnFocusTarget?.isConnected ? returnFocusTarget : itemElement;
|
|
295
|
+
setReturnFocusTarget(null);
|
|
296
|
+
target?.focus();
|
|
297
|
+
};
|
|
254
298
|
return /*#__PURE__*/ jsxs(MenuItemWrap, {
|
|
255
299
|
hasTrailingAction: Boolean(trailingAction),
|
|
256
|
-
isFocused: isFocused,
|
|
300
|
+
isFocused: isFocused || isDetailsActive,
|
|
257
301
|
"aria-disabled": disabled,
|
|
258
302
|
"aria-labelledby": labelId,
|
|
259
|
-
"aria-describedby": detailId,
|
|
260
303
|
as: as ?? 'li',
|
|
261
|
-
ref: mergeRefs(ref,
|
|
262
|
-
|
|
304
|
+
ref: mergeRefs(ref, (element)=>setItemElement(element)),
|
|
305
|
+
"data-menu-item-details-id": showDetailsInOverlay ? detailId : void 0,
|
|
306
|
+
...itemProps,
|
|
263
307
|
children: [
|
|
264
308
|
/*#__PURE__*/ jsx(Tooltip, {
|
|
265
309
|
skipWrapper: true,
|
|
@@ -275,18 +319,14 @@ function MenuListItem({ label, details, as, priority = 'default', size, disabled
|
|
|
275
319
|
padding: ITEM_PADDING_BY_SIZE[size ?? 'md'],
|
|
276
320
|
paddingLeft: hasLeadingSlot ? 'md' : void 0,
|
|
277
321
|
paddingRight: trailingAction ? TRAILING_ACTION_SPACE : void 0,
|
|
278
|
-
|
|
322
|
+
"data-focused": isFocused || isDetailsActive,
|
|
323
|
+
"data-pressed": isPressed,
|
|
279
324
|
hasTrailingAction: Boolean(trailingAction),
|
|
280
325
|
disabled: disabled,
|
|
281
326
|
priority: priority,
|
|
282
327
|
size: size,
|
|
283
328
|
...innerWrapProps,
|
|
284
329
|
children: [
|
|
285
|
-
/*#__PURE__*/ jsx(StyledInteractionStateLayer, {
|
|
286
|
-
isHovered: isFocused,
|
|
287
|
-
isPressed: isPressed,
|
|
288
|
-
higherOpacity: 'default' !== priority
|
|
289
|
-
}),
|
|
290
330
|
hasLeadingSlot && /*#__PURE__*/ jsx(StyledLeadingItems, {
|
|
291
331
|
disabled: disabled,
|
|
292
332
|
hasDetails: hasInlineDetails,
|
|
@@ -298,8 +338,6 @@ function MenuListItem({ label, details, as, priority = 'default', size, disabled
|
|
|
298
338
|
}) : leadingItems
|
|
299
339
|
}),
|
|
300
340
|
/*#__PURE__*/ jsxs(StyledContentWrap, {
|
|
301
|
-
isFocused: isFocused,
|
|
302
|
-
size: size,
|
|
303
341
|
children: [
|
|
304
342
|
/*#__PURE__*/ jsxs(Stack, {
|
|
305
343
|
padding: hasInlineDetails ? 'xs 0' : void 0,
|
|
@@ -356,7 +394,6 @@ function MenuListItem({ label, details, as, priority = 'default', size, disabled
|
|
|
356
394
|
top: "0",
|
|
357
395
|
height: "100%",
|
|
358
396
|
align: "center",
|
|
359
|
-
...trailingActionWrapperProps,
|
|
360
397
|
children: /*#__PURE__*/ jsx(Button, {
|
|
361
398
|
ref: trailingActionRef,
|
|
362
399
|
size: "zero",
|
|
@@ -366,13 +403,26 @@ function MenuListItem({ label, details, as, priority = 'default', size, disabled
|
|
|
366
403
|
tooltipProps: {
|
|
367
404
|
title: trailingAction.label
|
|
368
405
|
},
|
|
406
|
+
busy: trailingAction.busy,
|
|
369
407
|
onClick: trailingAction.onAction
|
|
370
408
|
})
|
|
371
409
|
}),
|
|
372
|
-
|
|
410
|
+
showOverlayDetails && /*#__PURE__*/ jsx(DetailsOverlay, {
|
|
373
411
|
size: size,
|
|
374
412
|
id: detailId,
|
|
375
|
-
|
|
413
|
+
itemElement: itemElement,
|
|
414
|
+
labelId: labelId,
|
|
415
|
+
ref: setDetailsElement,
|
|
416
|
+
hasFocusWithin: hasFocusInDetails,
|
|
417
|
+
onReturnFocus: returnFocus,
|
|
418
|
+
onPointerEnter: (e)=>{
|
|
419
|
+
setIsDetailsHovered(true);
|
|
420
|
+
onDetailsHoverChange?.(true, e);
|
|
421
|
+
},
|
|
422
|
+
onPointerLeave: (e)=>{
|
|
423
|
+
setIsDetailsHovered(false);
|
|
424
|
+
onDetailsHoverChange?.(false, e);
|
|
425
|
+
},
|
|
376
426
|
children: 'function' == typeof details ? details({
|
|
377
427
|
disabled,
|
|
378
428
|
isFocused,
|
|
@@ -391,33 +441,89 @@ const DETAILS_MIDDLEWARE = [
|
|
|
391
441
|
shiftOverlay(),
|
|
392
442
|
hide()
|
|
393
443
|
];
|
|
394
|
-
function
|
|
444
|
+
function focusMenuItemDetails(item) {
|
|
445
|
+
const detailsId = item?.getAttribute('data-menu-item-details-id');
|
|
446
|
+
const detailsElement = detailsId ? document.getElementById(detailsId) : null;
|
|
447
|
+
const firstFocusable = detailsElement ? getFocusableTreeWalker(detailsElement, {
|
|
448
|
+
tabbable: true
|
|
449
|
+
}).nextNode() : null;
|
|
450
|
+
if (!(firstFocusable instanceof HTMLElement)) return false;
|
|
451
|
+
firstFocusable.focus();
|
|
452
|
+
return true;
|
|
453
|
+
}
|
|
454
|
+
function getTabbableElements(root) {
|
|
455
|
+
const walker = getFocusableTreeWalker(root, {
|
|
456
|
+
tabbable: true
|
|
457
|
+
});
|
|
458
|
+
const elements = [];
|
|
459
|
+
let node = walker.nextNode();
|
|
460
|
+
while(node){
|
|
461
|
+
if (node instanceof HTMLElement) elements.push(node);
|
|
462
|
+
node = walker.nextNode();
|
|
463
|
+
}
|
|
464
|
+
return elements;
|
|
465
|
+
}
|
|
466
|
+
function DetailsOverlay({ children, hasFocusWithin, id, itemElement, labelId, onPointerEnter, onPointerLeave, onReturnFocus, ref, size }) {
|
|
395
467
|
const theme = useTheme();
|
|
396
|
-
const {
|
|
468
|
+
const { t } = useTranslation();
|
|
469
|
+
const [contentElement, setContentElement] = useState(null);
|
|
470
|
+
const [isInteractive, setIsInteractive] = useState(false);
|
|
471
|
+
const { refs: { setFloating }, floatingStyles, middlewareData } = useFloating({
|
|
472
|
+
elements: {
|
|
473
|
+
reference: itemElement
|
|
474
|
+
},
|
|
397
475
|
placement: 'right-start',
|
|
398
476
|
strategy: 'fixed',
|
|
399
477
|
middleware: DETAILS_MIDDLEWARE,
|
|
400
478
|
whileElementsMounted: autoUpdate
|
|
401
479
|
});
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
480
|
+
const onContentElement = (element)=>{
|
|
481
|
+
setContentElement(element);
|
|
482
|
+
if (element) setIsInteractive(getTabbableElements(element).length > 0);
|
|
483
|
+
};
|
|
484
|
+
const onKeyDown = (e)=>{
|
|
485
|
+
if ('Escape' === e.key || 'ArrowLeft' === e.key) {
|
|
486
|
+
e.preventDefault();
|
|
487
|
+
e.stopPropagation();
|
|
488
|
+
onReturnFocus();
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if ('Tab' === e.key && contentElement) {
|
|
492
|
+
e.preventDefault();
|
|
493
|
+
e.stopPropagation();
|
|
494
|
+
const tabbables = getTabbableElements(contentElement);
|
|
495
|
+
const index = tabbables.indexOf(e.target);
|
|
496
|
+
const next = e.shiftKey ? tabbables[index <= 0 ? tabbables.length - 1 : index - 1] : tabbables[(index + 1) % tabbables.length];
|
|
497
|
+
next?.focus();
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
if (!itemElement) return null;
|
|
408
501
|
return /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(StyledPositionWrapper, {
|
|
409
502
|
"data-reference-hidden": middlewareData.hide?.referenceHidden,
|
|
410
503
|
ref: setFloating,
|
|
411
504
|
zIndex: theme.zIndex.tooltip,
|
|
412
505
|
style: floatingStyles,
|
|
413
|
-
children: /*#__PURE__*/ jsx(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
506
|
+
children: /*#__PURE__*/ jsx(FocusScope, {
|
|
507
|
+
children: /*#__PURE__*/ jsxs(StyledOverlay, {
|
|
508
|
+
id: id,
|
|
509
|
+
ref: mergeRefs(ref, onContentElement),
|
|
510
|
+
role: isInteractive ? 'dialog' : 'tooltip',
|
|
511
|
+
"aria-labelledby": isInteractive ? itemElement.getAttribute('aria-labelledby') ?? labelId : void 0,
|
|
512
|
+
placement: "right-start",
|
|
513
|
+
size: size,
|
|
514
|
+
"data-menu-item-details": true,
|
|
515
|
+
onKeyDown: onKeyDown,
|
|
516
|
+
onPointerEnter: onPointerEnter,
|
|
517
|
+
onPointerLeave: onPointerLeave,
|
|
518
|
+
children: [
|
|
519
|
+
children,
|
|
520
|
+
isInteractive && !hasFocusWithin ? /*#__PURE__*/ jsx(VisuallyHidden, {
|
|
521
|
+
children: t('Press Right Arrow to interact with details.')
|
|
522
|
+
}) : null
|
|
523
|
+
]
|
|
524
|
+
})
|
|
419
525
|
})
|
|
420
|
-
}), document.body);
|
|
526
|
+
}), itemElement.closest('[data-overlay-root]') ?? document.body);
|
|
421
527
|
}
|
|
422
528
|
const StyledPositionWrapper = styled(PositionWrapper)`
|
|
423
529
|
&[data-reference-hidden='true'] {
|
|
@@ -449,9 +555,6 @@ const MenuItemWrap = styled('li')`
|
|
|
449
555
|
outline: none;
|
|
450
556
|
}
|
|
451
557
|
`;
|
|
452
|
-
const StyledInteractionStateLayer = styled(interactionStateLayer)`
|
|
453
|
-
z-index: -1;
|
|
454
|
-
`;
|
|
455
558
|
const TrailingItems = styled('div')`
|
|
456
559
|
display: flex;
|
|
457
560
|
align-items: center;
|
|
@@ -461,4 +564,4 @@ const TrailingItems = styled('div')`
|
|
|
461
564
|
|
|
462
565
|
${(p)=>p.disabled && 'opacity: 0.5;'}
|
|
463
566
|
`;
|
|
464
|
-
export { MenuFooterLayout, MenuHeaderLayout, MenuHeading, MenuListItem, MenuSectionGroup, MenuSectionHeader, MenuSectionLabel, MenuSectionList, MenuSectionSeparator, ReserveLeadingSlot, SearchInput, calculateMenuMinHeight, useReserveLeadingSlot };
|
|
567
|
+
export { MenuFooterLayout, MenuHeaderLayout, MenuHeading, MenuListItem, MenuSectionGroup, MenuSectionHeader, MenuSectionLabel, MenuSectionList, MenuSectionSeparator, ReserveLeadingSlot, SECTION_ITEM_SPACE, SearchInput, calculateMenuMinHeight, focusMenuItemDetails, useReserveLeadingSlot };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { type Theme } from '@emotion/react';
|
|
3
|
+
import type { ButtonProps } from '../button/index.js';
|
|
4
|
+
declare const ModalBody: import("@emotion/styled").StyledComponent<{
|
|
5
|
+
theme?: Theme;
|
|
6
|
+
as?: React.ElementType;
|
|
7
|
+
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, {}>;
|
|
8
|
+
declare const ModalFooter: import("@emotion/styled").StyledComponent<React.HTMLAttributes<HTMLElement> & {
|
|
9
|
+
theme?: Theme;
|
|
10
|
+
}, {}, {}>;
|
|
11
|
+
interface ClosableHeaderProps extends React.HTMLAttributes<HTMLHeadingElement> {
|
|
12
|
+
/**
|
|
13
|
+
* Show a close button in the header
|
|
14
|
+
*/
|
|
15
|
+
closeButton?: boolean;
|
|
16
|
+
}
|
|
17
|
+
declare const makeClosableHeader: (closeModal: () => void) => ({ closeButton, children, ...props }: ClosableHeaderProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
18
|
+
declare const makeCloseButton: (closeModal: () => void) => (props: Omit<ButtonProps, "aria-label">) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
19
|
+
export { makeClosableHeader, makeCloseButton, ModalBody, ModalFooter };
|