@sentry/scraps 0.3.0 → 0.5.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 +6 -5
- package/dist/alert/alert.js +0 -3
- package/dist/badge/badge.js +1 -2
- package/dist/badge/tag.js +0 -2
- package/dist/button/index.d.ts +0 -1
- package/dist/button/index.js +0 -1
- 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 +242 -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 +354 -0
- package/dist/compactSelect/fzf.d.ts +8 -0
- package/dist/compactSelect/fzf.js +151 -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 +268 -0
- package/dist/confirm/index.d.ts +153 -0
- package/dist/confirm/index.js +132 -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 +24 -0
- package/dist/dropdownMenu/context.js +3 -0
- package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
- package/dist/dropdownMenu/dropdownMenu.js +103 -0
- package/dist/dropdownMenu/index.d.ts +2 -0
- package/dist/dropdownMenu/index.js +1 -0
- package/dist/dropdownMenu/item.d.ts +136 -0
- package/dist/dropdownMenu/item.js +182 -0
- package/dist/dropdownMenu/list.d.ts +59 -0
- package/dist/dropdownMenu/list.js +410 -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 +260 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.js +55 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
- package/dist/dropdownMenu/useSafetyTriangle.d.ts +12 -0
- package/dist/dropdownMenu/useSafetyTriangle.js +119 -0
- package/dist/dropdownMenu/utils.d.ts +21 -0
- package/dist/dropdownMenu/utils.js +57 -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/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/index.d.ts +2 -2
- package/dist/layout/index.js +1 -1
- package/dist/layout/styles.d.ts +1 -1
- package/dist/link/link.js +4 -3
- package/dist/link/linkBehaviorContext.d.ts +2 -0
- package/dist/link/linkBehaviorContext.js +17 -10
- package/dist/menu/controlContext.d.ts +32 -0
- package/dist/menu/controlContext.js +7 -0
- package/dist/menu/dropdownButton.d.ts +18 -0
- package/dist/menu/dropdownButton.js +66 -0
- package/dist/menu/index.d.ts +7 -0
- package/dist/menu/index.js +3 -0
- package/dist/menu/menu.d.ts +167 -0
- package/dist/menu/menu.js +568 -0
- package/dist/menu/selectTypes.d.ts +96 -0
- package/dist/menu/selectTypes.js +0 -0
- package/dist/menu/selectValue.d.ts +13 -0
- package/dist/menu/selectValue.js +0 -0
- 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/overlayTrigger.d.ts +22 -0
- package/dist/overlayTrigger.js +30 -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/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/slot/knownContexts.d.ts +1 -1
- package/dist/spinner/index.d.ts +1 -0
- package/dist/spinner/index.js +1 -0
- package/dist/spinner/spinner.d.ts +14 -0
- package/dist/spinner/spinner.js +126 -0
- package/dist/splitPanel/index.d.ts +1 -0
- package/dist/splitPanel/index.js +1 -0
- package/dist/splitPanel/splitPanel.d.ts +38 -0
- package/dist/splitPanel/splitPanel.js +145 -0
- 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/index.d.ts +4 -0
- package/dist/tabs/index.js +3 -0
- package/dist/tabs/item.d.ts +13 -0
- package/dist/tabs/item.js +4 -0
- package/dist/tabs/tab.d.ts +22 -0
- package/dist/tabs/tab.js +205 -0
- package/dist/tabs/tabList.d.ts +18 -0
- package/dist/tabs/tabList.js +256 -0
- package/dist/tabs/tabPanels.d.ts +14 -0
- package/dist/tabs/tabPanels.js +62 -0
- package/dist/tabs/tabs.d.ts +38 -0
- package/dist/tabs/tabs.js +56 -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/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/toast/index.d.ts +5 -0
- package/dist/toast/index.js +4 -0
- package/dist/toast/toast.d.ts +10 -0
- package/dist/toast/toast.js +182 -0
- package/dist/toast/toastApi.d.ts +10 -0
- package/dist/toast/toastApi.js +53 -0
- package/dist/toast/toaster.d.ts +4 -0
- package/dist/toast/toaster.js +42 -0
- package/dist/toast/types.d.ts +17 -0
- package/dist/toast/types.js +2 -0
- package/dist/toggleCard/index.d.ts +1 -0
- package/dist/toggleCard/index.js +1 -0
- package/dist/toggleCard/toggleCard.d.ts +32 -0
- package/dist/toggleCard/toggleCard.js +301 -0
- package/dist/tooltip/tooltip.js +2 -5
- package/dist/useDimensions.d.ts +12 -0
- package/dist/useDimensions.js +31 -0
- 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/useResizableDrawer.d.ts +72 -0
- package/dist/useResizableDrawer.js +136 -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/package.json +148 -16
- 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
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { createElement } from "@emotion/react";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { getInteractionModality } from "@react-aria/interactions";
|
|
5
|
+
import { useListBox } from "@react-aria/listbox";
|
|
6
|
+
import { mergeProps, mergeRefs } from "@react-aria/utils";
|
|
7
|
+
import { ListLabel, ListSeparator, ListWrap, SizeLimitMessage } from "../styles.js";
|
|
8
|
+
import { useVirtualizedItems } from "../useVirtualizedItems.js";
|
|
9
|
+
import { hasVisibleLeadingItems } from "../utils.js";
|
|
10
|
+
import { Container } from "../../layout/index.js";
|
|
11
|
+
import { ReserveLeadingSlot } from "../../menu/index.js";
|
|
12
|
+
import { useTranslation } from "../../translation/index.js";
|
|
13
|
+
import { ListBoxDetailsHoverContext, ListBoxOption } from "./option.js";
|
|
14
|
+
import { ListBoxSection } from "./section.js";
|
|
15
|
+
const EMPTY_SET = new Set();
|
|
16
|
+
const DETAILS_CLOSE_DELAY = 150;
|
|
17
|
+
const DEFAULT_KEY_DOWN_HANDLER = ()=>true;
|
|
18
|
+
function ListBox({ ref, listState, autoFocus, size = 'md', shouldFocusWrap = true, shouldFocusOnHover = true, sizeLimitMessage, keyDownHandler = DEFAULT_KEY_DOWN_HANDLER, label, hiddenOptions = EMPTY_SET, hasSearch, searchable, overlayIsOpen, showSectionHeaders = true, showDetails = true, onAction, virtualized, virtualizedListPadding, scrollContainerRef, className, ...props }) {
|
|
19
|
+
const { t } = useTranslation();
|
|
20
|
+
const listElementRef = useRef(null);
|
|
21
|
+
const scrollElementRef = useRef(null);
|
|
22
|
+
const [hasEverOverflowed, setHasEverOverflowed] = useState(false);
|
|
23
|
+
const { listBoxProps, labelProps } = useListBox({
|
|
24
|
+
...props,
|
|
25
|
+
scrollRef: scrollElementRef,
|
|
26
|
+
autoFocus,
|
|
27
|
+
label,
|
|
28
|
+
shouldFocusWrap,
|
|
29
|
+
shouldFocusOnHover,
|
|
30
|
+
shouldSelectOnPressUp: true,
|
|
31
|
+
onAction
|
|
32
|
+
}, listState, listElementRef);
|
|
33
|
+
const onKeyDown = (e)=>{
|
|
34
|
+
const continueCallback = keyDownHandler?.(e);
|
|
35
|
+
if (continueCallback && 'Escape' !== e.key) listBoxProps.onKeyDown?.(e);
|
|
36
|
+
};
|
|
37
|
+
const listItems = useMemo(()=>[
|
|
38
|
+
...listState.collection
|
|
39
|
+
].filter((node)=>{
|
|
40
|
+
if ('section' === node.type) return ![
|
|
41
|
+
...node.childNodes
|
|
42
|
+
].every((child)=>hiddenOptions.has(child.key));
|
|
43
|
+
return !hiddenOptions.has(node.key);
|
|
44
|
+
}), [
|
|
45
|
+
listState.collection,
|
|
46
|
+
hiddenOptions
|
|
47
|
+
]);
|
|
48
|
+
const reserveLeadingSlot = useMemo(()=>hasVisibleLeadingItems(listItems, hiddenOptions), [
|
|
49
|
+
listItems,
|
|
50
|
+
hiddenOptions
|
|
51
|
+
]);
|
|
52
|
+
const mergedProps = mergeProps(listBoxProps, props);
|
|
53
|
+
const clearFocusTimeoutRef = useRef(void 0);
|
|
54
|
+
useEffect(()=>()=>window.clearTimeout(clearFocusTimeoutRef.current), []);
|
|
55
|
+
const cancelFocusClear = useCallback(()=>{
|
|
56
|
+
window.clearTimeout(clearFocusTimeoutRef.current);
|
|
57
|
+
}, []);
|
|
58
|
+
const scheduleFocusClear = useCallback(()=>{
|
|
59
|
+
window.clearTimeout(clearFocusTimeoutRef.current);
|
|
60
|
+
clearFocusTimeoutRef.current = window.setTimeout(()=>listState.selectionManager.setFocusedKey(null), DETAILS_CLOSE_DELAY);
|
|
61
|
+
}, [
|
|
62
|
+
listState.selectionManager
|
|
63
|
+
]);
|
|
64
|
+
const onDetailsHoverChange = useCallback((isHovered, e)=>{
|
|
65
|
+
if (isHovered) cancelFocusClear();
|
|
66
|
+
else if (!(e.relatedTarget instanceof Node) || !listElementRef.current?.contains(e.relatedTarget)) scheduleFocusClear();
|
|
67
|
+
}, [
|
|
68
|
+
cancelFocusClear,
|
|
69
|
+
scheduleFocusClear
|
|
70
|
+
]);
|
|
71
|
+
const onMouseLeave = (e)=>{
|
|
72
|
+
mergedProps.onMouseLeave?.(e);
|
|
73
|
+
const { focusedKey } = listState.selectionManager;
|
|
74
|
+
const focusedItemProps = null === focusedKey ? void 0 : listState.collection.getItem(focusedKey)?.props;
|
|
75
|
+
if (showDetails && focusedItemProps?.showDetailsInOverlay && focusedItemProps.details) return void scheduleFocusClear();
|
|
76
|
+
listState.selectionManager.setFocusedKey(null);
|
|
77
|
+
};
|
|
78
|
+
const onMouseEnter = (e)=>{
|
|
79
|
+
mergedProps.onMouseEnter?.(e);
|
|
80
|
+
cancelFocusClear();
|
|
81
|
+
};
|
|
82
|
+
const virtualizer = useVirtualizedItems({
|
|
83
|
+
listItems,
|
|
84
|
+
virtualized,
|
|
85
|
+
size,
|
|
86
|
+
listPadding: virtualizedListPadding
|
|
87
|
+
});
|
|
88
|
+
useEffect(()=>{
|
|
89
|
+
if (!virtualized || null === listState.selectionManager.focusedKey || 'pointer' === getInteractionModality()) return;
|
|
90
|
+
const focusedIndex = listItems.findIndex((item)=>item.key === listState.selectionManager.focusedKey);
|
|
91
|
+
if (-1 !== focusedIndex) virtualizer.scrollToIndex(focusedIndex);
|
|
92
|
+
}, [
|
|
93
|
+
virtualized,
|
|
94
|
+
listItems,
|
|
95
|
+
listState.selectionManager.focusedKey,
|
|
96
|
+
virtualizer
|
|
97
|
+
]);
|
|
98
|
+
const refs = useMemo(()=>{
|
|
99
|
+
const overflowTracker = (scrollContainer)=>{
|
|
100
|
+
if (hasEverOverflowed || 0 === listItems.length || !scrollContainer) return;
|
|
101
|
+
setHasEverOverflowed(scrollContainer.scrollHeight > scrollContainer.clientHeight);
|
|
102
|
+
};
|
|
103
|
+
return mergeRefs(scrollElementRef, overflowTracker, virtualizer.scrollElementRef, scrollContainerRef);
|
|
104
|
+
}, [
|
|
105
|
+
hasEverOverflowed,
|
|
106
|
+
virtualizer.scrollElementRef,
|
|
107
|
+
listItems,
|
|
108
|
+
scrollContainerRef
|
|
109
|
+
]);
|
|
110
|
+
return /*#__PURE__*/ jsx(ListBoxDetailsHoverContext, {
|
|
111
|
+
value: onDetailsHoverChange,
|
|
112
|
+
children: /*#__PURE__*/ jsxs(ReserveLeadingSlot, {
|
|
113
|
+
reserve: reserveLeadingSlot,
|
|
114
|
+
children: [
|
|
115
|
+
0 !== listItems.length && /*#__PURE__*/ jsx(ListSeparator, {
|
|
116
|
+
role: "separator"
|
|
117
|
+
}),
|
|
118
|
+
0 !== listItems.length && label && /*#__PURE__*/ jsx(ListLabel, {
|
|
119
|
+
...labelProps,
|
|
120
|
+
children: label
|
|
121
|
+
}),
|
|
122
|
+
/*#__PURE__*/ jsx(Container, {
|
|
123
|
+
ref: refs,
|
|
124
|
+
height: "100%",
|
|
125
|
+
overflowY: "auto",
|
|
126
|
+
className: className,
|
|
127
|
+
style: hasEverOverflowed ? {
|
|
128
|
+
scrollbarGutter: 'stable'
|
|
129
|
+
} : void 0,
|
|
130
|
+
children: /*#__PURE__*/ jsx(Container, {
|
|
131
|
+
...virtualizer.wrapperProps,
|
|
132
|
+
children: /*#__PURE__*/ jsxs(ListWrap, {
|
|
133
|
+
...mergedProps,
|
|
134
|
+
style: {
|
|
135
|
+
...mergedProps.style,
|
|
136
|
+
...virtualizer.listWrapStyle
|
|
137
|
+
},
|
|
138
|
+
onKeyDown: onKeyDown,
|
|
139
|
+
onMouseEnter: onMouseEnter,
|
|
140
|
+
onMouseLeave: onMouseLeave,
|
|
141
|
+
ref: mergeRefs(listElementRef, ref),
|
|
142
|
+
children: [
|
|
143
|
+
overlayIsOpen && virtualizer.items.map((row)=>{
|
|
144
|
+
const item = listItems[row.index];
|
|
145
|
+
if (!item) return null;
|
|
146
|
+
if ('section' === item.type) return /*#__PURE__*/ createElement(ListBoxSection, {
|
|
147
|
+
...virtualizer.itemProps(row.index),
|
|
148
|
+
key: item.key,
|
|
149
|
+
item: item,
|
|
150
|
+
listState: listState,
|
|
151
|
+
hiddenOptions: hiddenOptions,
|
|
152
|
+
size: size,
|
|
153
|
+
showSectionHeaders: showSectionHeaders,
|
|
154
|
+
showDetails: showDetails
|
|
155
|
+
});
|
|
156
|
+
return /*#__PURE__*/ jsx(ListBoxOption, {
|
|
157
|
+
...virtualizer.itemProps(row.index),
|
|
158
|
+
item: item,
|
|
159
|
+
listState: listState,
|
|
160
|
+
size: size,
|
|
161
|
+
showDetails: showDetails
|
|
162
|
+
}, item.key);
|
|
163
|
+
}),
|
|
164
|
+
!searchable && !hasSearch && hiddenOptions.size > 0 && /*#__PURE__*/ jsx(SizeLimitMessage, {
|
|
165
|
+
children: sizeLimitMessage ?? t('Use search to find more options…')
|
|
166
|
+
})
|
|
167
|
+
]
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
]
|
|
172
|
+
})
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
export { ListBox };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { AriaOptionProps } from '@react-aria/listbox';
|
|
3
|
+
import type { ListState } from '@react-stately/list';
|
|
4
|
+
import type { Node } from '@react-types/shared';
|
|
5
|
+
import { type ListItemProps } from '../../menu/index.js';
|
|
6
|
+
export declare const ListBoxDetailsHoverContext: React.Context<((isHovered: boolean, event: React.PointerEvent) => void) | undefined>;
|
|
7
|
+
export interface ListBoxOptionProps extends AriaOptionProps {
|
|
8
|
+
item: Node<any>;
|
|
9
|
+
listState: ListState<any>;
|
|
10
|
+
size: ListItemProps['size'];
|
|
11
|
+
'data-index'?: number;
|
|
12
|
+
ref?: React.Ref<HTMLLIElement>;
|
|
13
|
+
showDetails?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A <li /> element with accessible behaviors & attributes.
|
|
17
|
+
* https://react-spectrum.adobe.com/react-aria/useListBox.html
|
|
18
|
+
*/
|
|
19
|
+
export declare function ListBoxOption({ item, listState, size, showDetails, ref: refProp, 'data-index': dataIndex, }: ListBoxOptionProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Fragment, createContext, useContext, useMemo, useRef } from "react";
|
|
3
|
+
import { useOption } from "@react-aria/listbox";
|
|
4
|
+
import { mergeRefs } from "@react-aria/utils";
|
|
5
|
+
import { IconCheckmark } from "@sentry/icons/checkmark";
|
|
6
|
+
import { Checkbox } from "../../checkbox/index.js";
|
|
7
|
+
import { HighlightText } from "../highlightText.js";
|
|
8
|
+
import { LeadWrap, getOptionPaddingLeft } from "../styles.js";
|
|
9
|
+
import { ControlContext, ListItem, useReserveLeadingSlot } from "../../menu/index.js";
|
|
10
|
+
const ListBoxDetailsHoverContext = /*#__PURE__*/ createContext(void 0);
|
|
11
|
+
function ListBoxOption({ item, listState, size, showDetails = true, ref: refProp, 'data-index': dataIndex }) {
|
|
12
|
+
const ref = useRef(null);
|
|
13
|
+
const { label, details, trailingItems, priority, hideCheck, tooltip, tooltipOptions, selectionMode, showDetailsInOverlay } = item.props;
|
|
14
|
+
const multiple = selectionMode ? 'multiple' === selectionMode : 'multiple' === listState.selectionManager.selectionMode;
|
|
15
|
+
const { optionProps, labelProps, isSelected, isFocused, isDisabled, isPressed } = useOption({
|
|
16
|
+
key: item.key,
|
|
17
|
+
'aria-label': item['aria-label']
|
|
18
|
+
}, listState, ref);
|
|
19
|
+
const { search, highlightSearch } = useContext(ControlContext);
|
|
20
|
+
const onDetailsHoverChange = useContext(ListBoxDetailsHoverContext);
|
|
21
|
+
const renderedLabel = highlightSearch && search && 'string' == typeof label ? /*#__PURE__*/ jsx(HighlightText, {
|
|
22
|
+
text: label,
|
|
23
|
+
query: search
|
|
24
|
+
}) : label;
|
|
25
|
+
const labelPropsMemo = useMemo(()=>({
|
|
26
|
+
...labelProps,
|
|
27
|
+
as: 'string' == typeof label ? 'p' : 'div'
|
|
28
|
+
}), [
|
|
29
|
+
labelProps.id,
|
|
30
|
+
label
|
|
31
|
+
]);
|
|
32
|
+
const reserveLeadingSlot = useReserveLeadingSlot();
|
|
33
|
+
const { leadingItems } = item.props;
|
|
34
|
+
const leadingItemsMemo = useMemo(()=>{
|
|
35
|
+
const checkboxSize = 'xs' === size ? 'xs' : 'sm';
|
|
36
|
+
const leading = 'function' == typeof leadingItems ? leadingItems({
|
|
37
|
+
disabled: isDisabled,
|
|
38
|
+
isFocused,
|
|
39
|
+
isSelected
|
|
40
|
+
}) : leadingItems;
|
|
41
|
+
if (hideCheck) return leading;
|
|
42
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
43
|
+
children: [
|
|
44
|
+
/*#__PURE__*/ jsx(LeadWrap, {
|
|
45
|
+
"aria-hidden": "true",
|
|
46
|
+
children: multiple ? /*#__PURE__*/ jsx(Checkbox, {
|
|
47
|
+
size: checkboxSize,
|
|
48
|
+
checked: isSelected,
|
|
49
|
+
disabled: isDisabled,
|
|
50
|
+
readOnly: true
|
|
51
|
+
}) : isSelected && /*#__PURE__*/ jsx(IconCheckmark, {
|
|
52
|
+
size: checkboxSize,
|
|
53
|
+
variant: "accent"
|
|
54
|
+
})
|
|
55
|
+
}),
|
|
56
|
+
leading || reserveLeadingSlot ? /*#__PURE__*/ jsx(LeadWrap, {
|
|
57
|
+
"aria-hidden": "true",
|
|
58
|
+
minWidth: reserveLeadingSlot ? '16px' : void 0,
|
|
59
|
+
children: leading
|
|
60
|
+
}) : null
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
}, [
|
|
64
|
+
size,
|
|
65
|
+
leadingItems,
|
|
66
|
+
isDisabled,
|
|
67
|
+
isFocused,
|
|
68
|
+
isSelected,
|
|
69
|
+
hideCheck,
|
|
70
|
+
multiple,
|
|
71
|
+
reserveLeadingSlot
|
|
72
|
+
]);
|
|
73
|
+
return /*#__PURE__*/ jsx(ListItem, {
|
|
74
|
+
...optionProps,
|
|
75
|
+
"data-index": dataIndex,
|
|
76
|
+
ref: mergeRefs(ref, refProp),
|
|
77
|
+
size: size,
|
|
78
|
+
label: renderedLabel,
|
|
79
|
+
details: showDetails ? details : null,
|
|
80
|
+
disabled: isDisabled,
|
|
81
|
+
isPressed: isPressed,
|
|
82
|
+
isSelected: isSelected,
|
|
83
|
+
isFocused: listState.selectionManager.isFocused && isFocused,
|
|
84
|
+
priority: priority ? 'primary' : 'default',
|
|
85
|
+
labelProps: labelPropsMemo,
|
|
86
|
+
leadingItems: leadingItemsMemo,
|
|
87
|
+
innerWrapProps: {
|
|
88
|
+
paddingLeft: getOptionPaddingLeft({
|
|
89
|
+
hasCheck: !hideCheck,
|
|
90
|
+
hasLeadingItems: Boolean(leadingItems) || reserveLeadingSlot
|
|
91
|
+
})
|
|
92
|
+
},
|
|
93
|
+
trailingItems: trailingItems,
|
|
94
|
+
showDetailsInOverlay: showDetailsInOverlay,
|
|
95
|
+
onDetailsHoverChange: onDetailsHoverChange,
|
|
96
|
+
tooltip: tooltip,
|
|
97
|
+
tooltipOptions: tooltipOptions,
|
|
98
|
+
"data-test-id": item.key
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export { ListBoxDetailsHoverContext, ListBoxOption };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { ListState } from '@react-stately/list';
|
|
3
|
+
import type { Node } from '@react-types/shared';
|
|
4
|
+
import type { SelectKey, ListItemBase } from '../types.js';
|
|
5
|
+
import { type ListBoxOptionProps } from './option.js';
|
|
6
|
+
interface ListBoxSectionProps<T extends ListItemBase> {
|
|
7
|
+
hiddenOptions: Set<SelectKey>;
|
|
8
|
+
item: Node<T>;
|
|
9
|
+
listState: ListState<T>;
|
|
10
|
+
showSectionHeaders: boolean;
|
|
11
|
+
size: ListBoxOptionProps['size'];
|
|
12
|
+
'data-index'?: number;
|
|
13
|
+
ref?: React.Ref<HTMLLIElement>;
|
|
14
|
+
showDetails?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A <li /> element that functions as a list box section (renders a nested <ul />
|
|
18
|
+
* inside). https://react-spectrum.adobe.com/react-aria/useListBox.html
|
|
19
|
+
*/
|
|
20
|
+
export declare function ListBoxSection<T extends ListItemBase>({ item, listState, size, hiddenOptions, showSectionHeaders, showDetails, ref, 'data-index': dataIndex, }: ListBoxSectionProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Fragment, useMemo } from "react";
|
|
3
|
+
import { useListBoxSection } from "@react-aria/listbox";
|
|
4
|
+
import { useSeparator } from "@react-aria/separator";
|
|
5
|
+
import { SectionSeparator } from "../styles.js";
|
|
6
|
+
import { SectionToggle } from "../utils.js";
|
|
7
|
+
import { SectionGroup, SectionHeader, SectionLabel, SectionList } from "../../menu/index.js";
|
|
8
|
+
import { ListBoxOption } from "./option.js";
|
|
9
|
+
function ListBoxSection({ item, listState, size, hiddenOptions, showSectionHeaders, showDetails = true, ref, 'data-index': dataIndex }) {
|
|
10
|
+
const { itemProps, headingProps, groupProps } = useListBoxSection({
|
|
11
|
+
heading: item.rendered,
|
|
12
|
+
'aria-label': item['aria-label']
|
|
13
|
+
});
|
|
14
|
+
const { separatorProps } = useSeparator({
|
|
15
|
+
elementType: 'li'
|
|
16
|
+
});
|
|
17
|
+
const showToggleAllButton = 'multiple' === listState.selectionManager.selectionMode && item.value?.showToggleAllButton;
|
|
18
|
+
const childItems = useMemo(()=>[
|
|
19
|
+
...item.childNodes
|
|
20
|
+
].filter((child)=>!hiddenOptions.has(child.key)), [
|
|
21
|
+
item.childNodes,
|
|
22
|
+
hiddenOptions
|
|
23
|
+
]);
|
|
24
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
25
|
+
children: [
|
|
26
|
+
showSectionHeaders && /*#__PURE__*/ jsx(SectionSeparator, {
|
|
27
|
+
...separatorProps
|
|
28
|
+
}),
|
|
29
|
+
/*#__PURE__*/ jsxs(SectionGroup, {
|
|
30
|
+
...itemProps,
|
|
31
|
+
"data-index": dataIndex,
|
|
32
|
+
ref: ref,
|
|
33
|
+
children: [
|
|
34
|
+
(item.rendered || showToggleAllButton) && showSectionHeaders && /*#__PURE__*/ jsx(SectionHeader, {
|
|
35
|
+
trailingAction: showToggleAllButton ? /*#__PURE__*/ jsx(SectionToggle, {
|
|
36
|
+
item: item,
|
|
37
|
+
listState: listState
|
|
38
|
+
}) : null,
|
|
39
|
+
children: item.rendered && /*#__PURE__*/ jsx(SectionLabel, {
|
|
40
|
+
...headingProps,
|
|
41
|
+
children: item.rendered
|
|
42
|
+
})
|
|
43
|
+
}),
|
|
44
|
+
/*#__PURE__*/ jsx(SectionList, {
|
|
45
|
+
...groupProps,
|
|
46
|
+
children: childItems.map((child)=>/*#__PURE__*/ jsx(ListBoxOption, {
|
|
47
|
+
item: child,
|
|
48
|
+
listState: listState,
|
|
49
|
+
size: size,
|
|
50
|
+
showDetails: showDetails
|
|
51
|
+
}, child.key))
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export { ListBoxSection };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { DistributedOmit } from 'type-fest';
|
|
2
|
+
import { type AlertProps } from '../alert/index.js';
|
|
3
|
+
import { type ButtonProps, type LinkButtonProps } from '../button/index.js';
|
|
4
|
+
import { type CheckboxProps } from '../checkbox/index.js';
|
|
5
|
+
export declare const MenuComponents: {
|
|
6
|
+
/**
|
|
7
|
+
* A button sized and styled to sit in `menuHeaderTrailingItems`. Inherits the
|
|
8
|
+
* header's font size and renders in secondary text color so it blends with the
|
|
9
|
+
* title rather than competing with it.
|
|
10
|
+
*
|
|
11
|
+
* Use this for lightweight, immediate actions in the header — e.g. "Reset",
|
|
12
|
+
* "Clear", "Invite Member", or "Sync". These actions typically take effect
|
|
13
|
+
* immediately and close the menu. For navigation actions use `LinkButton`
|
|
14
|
+
* instead. For prominent footer actions use `CTAButton`.
|
|
15
|
+
*/
|
|
16
|
+
HeaderButton(props: DistributedOmit<ButtonProps, "variant" | "size">): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* A button sized and styled to sit in `menuHeaderTrailingItems`. Inherits the
|
|
19
|
+
* header's font size and renders in secondary text color so it blends with the
|
|
20
|
+
* title rather than competing with it.
|
|
21
|
+
*
|
|
22
|
+
* Use this for lightweight, immediate actions in the header — e.g. "Reset",
|
|
23
|
+
* "Clear", "Invite Member", or "Sync". These actions typically take effect
|
|
24
|
+
* immediately and close the menu. For navigation actions use `LinkButton`
|
|
25
|
+
* instead. For prominent footer actions use `CTAButton`.
|
|
26
|
+
*
|
|
27
|
+
* `priority` and `size` are locked to keep the header visually consistent.
|
|
28
|
+
*/
|
|
29
|
+
ResetButton(props: DistributedOmit<ButtonProps, "variant" | "size" | "children">): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
30
|
+
ClearButton(props: DistributedOmit<ButtonProps, "variant" | "size" | "children">): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
31
|
+
/**
|
|
32
|
+
* A button sized for `menuFooter` call-to-action slots. Larger and more
|
|
33
|
+
* visually prominent than `HeaderButton`, making it suitable for primary footer
|
|
34
|
+
* actions that don't navigate — e.g. "Invite Member" or "Create".
|
|
35
|
+
*
|
|
36
|
+
* Use this in `menuFooter` for standalone actions that aren't part of a staged
|
|
37
|
+
* selection workflow. For staged selection (deferred apply/cancel) use
|
|
38
|
+
* `ApplyButton` and `CancelButton` instead. For navigation actions use
|
|
39
|
+
* `CTALinkButton`.
|
|
40
|
+
*
|
|
41
|
+
* `priority` and `size` are locked to keep footer actions visually consistent.
|
|
42
|
+
*/
|
|
43
|
+
CTAButton(props: DistributedOmit<ButtonProps, "variant" | "size">): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
44
|
+
CTALinkButton(props: DistributedOmit<LinkButtonProps, "variant" | "size">): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
45
|
+
/**
|
|
46
|
+
* A primary "Apply" button for use in `menuFooter` in staged selection
|
|
47
|
+
* workflows, where changes are held locally and only committed when the user
|
|
48
|
+
* explicitly confirms. Automatically closes the menu after the `onClick`
|
|
49
|
+
* handler runs.
|
|
50
|
+
*
|
|
51
|
+
* Always pair with `CancelButton`. The typical pattern is:
|
|
52
|
+
*
|
|
53
|
+
* ```tsx
|
|
54
|
+
* menuFooter={
|
|
55
|
+
* stagedSelect.hasStagedChanges ? (
|
|
56
|
+
* <Flex gap="md" justify="end">
|
|
57
|
+
* <MenuComponents.CancelButton onClick={() => stagedSelect.removeStagedChanges()} />
|
|
58
|
+
* <MenuComponents.ApplyButton onClick={() => stagedSelect.commit(stagedSelect.stagedValue)} />
|
|
59
|
+
* </Flex>
|
|
60
|
+
* ) : null
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* `priority` (`primary`) and `size` are locked to keep staged selection UIs consistent.
|
|
65
|
+
*/
|
|
66
|
+
ApplyButton(props: DistributedOmit<ButtonProps, "variant" | "size" | "children">): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
67
|
+
/**
|
|
68
|
+
* A "Cancel" button for use in `menuFooter` in staged selection workflows,
|
|
69
|
+
* where changes are held locally and discarded when the user cancels.
|
|
70
|
+
* Automatically closes the menu after the `onClick` handler runs.
|
|
71
|
+
*
|
|
72
|
+
* Always pair with `ApplyButton`. See `ApplyButton` for the full usage pattern.
|
|
73
|
+
*
|
|
74
|
+
* `priority` and `size` are locked to keep staged selection UIs consistent.
|
|
75
|
+
*/
|
|
76
|
+
CancelButton(props: DistributedOmit<ButtonProps, "variant" | "size" | "children">): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
77
|
+
/**
|
|
78
|
+
* A condensed alert for use in `menuFooter` to surface contextual warnings or
|
|
79
|
+
* information without leaving the menu — e.g. "You've reached the selection
|
|
80
|
+
* limit" or "Some items are unavailable".
|
|
81
|
+
*
|
|
82
|
+
* Accepts all Alert `variant` values (`warning`, `info`, `error`, `success`).
|
|
83
|
+
* `system` is locked to `false` to prevent the full-bleed layout from
|
|
84
|
+
* breaking the menu's padding, and `showIcon` is locked to `false` to keep
|
|
85
|
+
* the alert compact.
|
|
86
|
+
*/
|
|
87
|
+
Alert({ children, ...props }: DistributedOmit<AlertProps, "system" | "showIcon">): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
88
|
+
Checkbox(props: DistributedOmit<CheckboxProps, "size">): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
89
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import { Alert } from "../alert/index.js";
|
|
5
|
+
import { Button, LinkButton } from "../button/index.js";
|
|
6
|
+
import { Checkbox } from "../checkbox/index.js";
|
|
7
|
+
import { ControlContext } from "../menu/index.js";
|
|
8
|
+
import { Text } from "../text/index.js";
|
|
9
|
+
import { useTranslation } from "../translation/index.js";
|
|
10
|
+
const MenuComponents = {
|
|
11
|
+
HeaderButton (props) {
|
|
12
|
+
return /*#__PURE__*/ jsx(StyledHeaderButton, {
|
|
13
|
+
size: "zero",
|
|
14
|
+
variant: "transparent",
|
|
15
|
+
...props
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
ResetButton (props) {
|
|
19
|
+
const controlContext = useContext(ControlContext);
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
return /*#__PURE__*/ jsx(StyledHeaderButton, {
|
|
22
|
+
size: "zero",
|
|
23
|
+
variant: "transparent",
|
|
24
|
+
...props,
|
|
25
|
+
onClick: (e)=>{
|
|
26
|
+
props.onClick?.(e);
|
|
27
|
+
controlContext.overlayState?.close();
|
|
28
|
+
},
|
|
29
|
+
children: t('Reset')
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
ClearButton (props) {
|
|
33
|
+
const controlContext = useContext(ControlContext);
|
|
34
|
+
const { t } = useTranslation();
|
|
35
|
+
return /*#__PURE__*/ jsx(StyledHeaderButton, {
|
|
36
|
+
size: "zero",
|
|
37
|
+
variant: "transparent",
|
|
38
|
+
...props,
|
|
39
|
+
onClick: (e)=>{
|
|
40
|
+
props.onClick?.(e);
|
|
41
|
+
controlContext.overlayState?.close();
|
|
42
|
+
},
|
|
43
|
+
children: t('Clear')
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
CTAButton (props) {
|
|
47
|
+
return /*#__PURE__*/ jsx(Button, {
|
|
48
|
+
size: "xs",
|
|
49
|
+
variant: "secondary",
|
|
50
|
+
...props
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
CTALinkButton (props) {
|
|
54
|
+
return /*#__PURE__*/ jsx(LinkButton, {
|
|
55
|
+
size: "xs",
|
|
56
|
+
variant: "secondary",
|
|
57
|
+
...props
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
ApplyButton (props) {
|
|
61
|
+
const controlContext = useContext(ControlContext);
|
|
62
|
+
const { t } = useTranslation();
|
|
63
|
+
return /*#__PURE__*/ jsx(Button, {
|
|
64
|
+
size: "xs",
|
|
65
|
+
variant: "primary",
|
|
66
|
+
...props,
|
|
67
|
+
onClick: (e)=>{
|
|
68
|
+
props.onClick?.(e);
|
|
69
|
+
controlContext.overlayState?.close();
|
|
70
|
+
},
|
|
71
|
+
children: t('Apply')
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
CancelButton (props) {
|
|
75
|
+
const controlContext = useContext(ControlContext);
|
|
76
|
+
const { t } = useTranslation();
|
|
77
|
+
return /*#__PURE__*/ jsx(Button, {
|
|
78
|
+
size: "xs",
|
|
79
|
+
variant: "transparent",
|
|
80
|
+
...props,
|
|
81
|
+
onClick: (e)=>{
|
|
82
|
+
props.onClick?.(e);
|
|
83
|
+
controlContext.overlayState?.close();
|
|
84
|
+
},
|
|
85
|
+
children: t('Cancel')
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
Alert ({ children, ...props }) {
|
|
89
|
+
return /*#__PURE__*/ jsx(StyledAlert, {
|
|
90
|
+
...props,
|
|
91
|
+
system: false,
|
|
92
|
+
showIcon: false,
|
|
93
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
94
|
+
size: "sm",
|
|
95
|
+
children: children
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
Checkbox (props) {
|
|
100
|
+
return /*#__PURE__*/ jsx(Checkbox, {
|
|
101
|
+
size: "sm",
|
|
102
|
+
...props
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const StyledAlert = styled(Alert)`
|
|
107
|
+
padding: ${(p)=>p.theme.space.xs} ${(p)=>p.theme.space.lg};
|
|
108
|
+
text-wrap: balance;
|
|
109
|
+
`;
|
|
110
|
+
const StyledHeaderButton = styled(Button)`
|
|
111
|
+
font-size: inherit; /* Inherit font size from MenuHeader */
|
|
112
|
+
font-weight: ${(p)=>p.theme.font.weight.sans.regular};
|
|
113
|
+
color: ${(p)=>p.theme.tokens.content.secondary};
|
|
114
|
+
padding: 0 ${(p)=>p.theme.space.xs};
|
|
115
|
+
margin: -${(p)=>p.theme.space.sm} -${(p)=>p.theme.space.xs};
|
|
116
|
+
`;
|
|
117
|
+
export { MenuComponents };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { type FlexProps } from '../layout/index.js';
|
|
3
|
+
export declare const ListWrap: import("@emotion/styled").StyledComponent<{
|
|
4
|
+
theme?: import("@emotion/react").Theme;
|
|
5
|
+
as?: React.ElementType;
|
|
6
|
+
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, {}>;
|
|
7
|
+
export declare const ListLabel: import("@emotion/styled").StyledComponent<{
|
|
8
|
+
theme?: import("@emotion/react").Theme;
|
|
9
|
+
as?: React.ElementType;
|
|
10
|
+
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
11
|
+
export declare const ListSeparator: import("@emotion/styled").StyledComponent<{
|
|
12
|
+
theme?: import("@emotion/react").Theme;
|
|
13
|
+
as?: React.ElementType;
|
|
14
|
+
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
15
|
+
export declare const SectionToggleButton: import("@emotion/styled").StyledComponent<(import("../button/index.js").ButtonProps & {
|
|
16
|
+
theme?: import("@emotion/react").Theme;
|
|
17
|
+
}) & {
|
|
18
|
+
visible: boolean;
|
|
19
|
+
}, {}, {}>;
|
|
20
|
+
export declare function SectionSeparator(props: React.HTMLAttributes<HTMLLIElement>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
21
|
+
/**
|
|
22
|
+
* Left inset for CompactSelect options. CompactSelect puts its check column 4px
|
|
23
|
+
* closer to the menu edge than dropdown menus, in line with the title. The shared
|
|
24
|
+
* menu item centers leading content in a 24px slot, which already adds 4px
|
|
25
|
+
* before a 16px checkbox, so a single check-sized item needs a smaller inset.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getOptionPaddingLeft({ hasCheck, hasLeadingItems, }: {
|
|
28
|
+
hasCheck: boolean;
|
|
29
|
+
hasLeadingItems: boolean;
|
|
30
|
+
}): "xs" | "md";
|
|
31
|
+
export declare function LeadWrap(props: FlexProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
32
|
+
export declare const EmptyMessage: import("@emotion/styled").StyledComponent<{
|
|
33
|
+
theme?: import("@emotion/react").Theme;
|
|
34
|
+
as?: React.ElementType;
|
|
35
|
+
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, {}>;
|
|
36
|
+
export declare const SizeLimitMessage: import("@emotion/styled").StyledComponent<{
|
|
37
|
+
theme?: import("@emotion/react").Theme;
|
|
38
|
+
as?: React.ElementType;
|
|
39
|
+
}, React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, {}>;
|