@sentry/scraps 0.4.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/link/link.js +4 -3
- package/dist/link/linkBehaviorContext.d.ts +2 -0
- package/dist/link/linkBehaviorContext.js +17 -10
- package/dist/menu/index.d.ts +1 -1
- package/dist/menu/index.js +1 -1
- package/dist/menu/menu.d.ts +14 -6
- package/dist/menu/menu.js +160 -56
- 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/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/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/tooltip/tooltip.js +2 -5
- 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/package.json +115 -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 @@
|
|
|
1
|
+
export { DropdownMenu } from "./dropdownMenu.js";
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { TreeState } from '@react-stately/tree';
|
|
3
|
+
import type { Node } from '@react-types/shared';
|
|
4
|
+
import { type LinkProps } from '../link/index.js';
|
|
5
|
+
import { type ListItemProps, type MenuItemTrailingAction } from '../menu/index.js';
|
|
6
|
+
import type { UseOverlayProps } from '../useOverlay.js';
|
|
7
|
+
import { type VirtualRowProps } from '../useVirtualCollection.js';
|
|
8
|
+
export type DropdownMenuSearchOptions = {
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
};
|
|
11
|
+
export type DropdownMenuContentSizeOptions = {
|
|
12
|
+
maxHeight?: string | number;
|
|
13
|
+
maxWidth?: string | number;
|
|
14
|
+
};
|
|
15
|
+
export interface MenuItemProps extends ListItemProps {
|
|
16
|
+
/**
|
|
17
|
+
* Item key. Must be unique across the entire menu, including sub-menus.
|
|
18
|
+
*/
|
|
19
|
+
key: string;
|
|
20
|
+
/**
|
|
21
|
+
* Sub-items that are nested inside this item. By default, sub-items are
|
|
22
|
+
* rendered collectively as menu sections inside the current menu. If
|
|
23
|
+
* `submenu` is set, then they will be rendered together in a sub-menu.
|
|
24
|
+
*/
|
|
25
|
+
children?: MenuItemProps[];
|
|
26
|
+
/**
|
|
27
|
+
* Pass a class name to the menu item.
|
|
28
|
+
*/
|
|
29
|
+
className?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to close the menu when this item is clicked. Overrides the list-level
|
|
32
|
+
* `closeOnSelect` prop when set.
|
|
33
|
+
*/
|
|
34
|
+
closeOnSelect?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Destination if this menu item is an external link.
|
|
37
|
+
*/
|
|
38
|
+
externalHref?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Hide item from the dropdown menu. Note: this will also remove the item
|
|
41
|
+
* from the selection manager.
|
|
42
|
+
*/
|
|
43
|
+
hidden?: boolean;
|
|
44
|
+
/** Shows a selection checkmark and reserves its space when false. */
|
|
45
|
+
isSelected?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Menu item label. Should preferably be a string. If not, provide a `textValue` prop
|
|
48
|
+
* to enable search & keyboard select.
|
|
49
|
+
*/
|
|
50
|
+
label?: ListItemProps['label'];
|
|
51
|
+
/**
|
|
52
|
+
* Function to call when user selects/clicks/taps on the menu item. The
|
|
53
|
+
* item's key is passed as an argument.
|
|
54
|
+
*/
|
|
55
|
+
onAction?: () => void;
|
|
56
|
+
/**
|
|
57
|
+
* Ref to the item's root element. For a section, this is the element that
|
|
58
|
+
* wraps its label and items.
|
|
59
|
+
*/
|
|
60
|
+
ref?: React.Ref<HTMLLIElement>;
|
|
61
|
+
/**
|
|
62
|
+
* Renders this item as a trigger for a nested sub-menu (only works when
|
|
63
|
+
* `children` is also defined). Pass `true` for the defaults, or an object to
|
|
64
|
+
* customize the sub-menu: `title` is shown as its header, and `position`
|
|
65
|
+
* overrides where it opens relative to this item (defaults to `right-start`).
|
|
66
|
+
* `maxHeight` and `maxWidth` cap its size without forcing smaller
|
|
67
|
+
* menus to fill those dimensions.
|
|
68
|
+
*/
|
|
69
|
+
submenu?: boolean | (DropdownMenuContentSizeOptions & {
|
|
70
|
+
emptyMessage?: React.ReactNode;
|
|
71
|
+
position?: UseOverlayProps['position'];
|
|
72
|
+
search?: DropdownMenuSearchOptions;
|
|
73
|
+
title?: string;
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* A plain text version of the `label` prop if the label is not a string. Used for
|
|
77
|
+
* filtering and keyboard select (quick-focusing on options by typing the first letter).
|
|
78
|
+
*/
|
|
79
|
+
textValue?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Destination if this menu item is a link.
|
|
82
|
+
*/
|
|
83
|
+
to?: LinkProps['to'];
|
|
84
|
+
/**
|
|
85
|
+
* An icon-only button rendered beside, rather than inside, the focusable menu item.
|
|
86
|
+
*/
|
|
87
|
+
trailingAction?: MenuItemTrailingAction;
|
|
88
|
+
}
|
|
89
|
+
interface DropdownMenuItemProps<T extends React.ElementType = 'li'> {
|
|
90
|
+
/**
|
|
91
|
+
* Whether to close the menu when an item has been clicked/selected
|
|
92
|
+
*/
|
|
93
|
+
closeOnSelect: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Node representation (from @react-aria) of the item
|
|
96
|
+
*/
|
|
97
|
+
node: Node<MenuItemProps>;
|
|
98
|
+
/**
|
|
99
|
+
* Tree state (from @react-stately) inherited from parent menu
|
|
100
|
+
*/
|
|
101
|
+
state: TreeState<MenuItemProps>;
|
|
102
|
+
id?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Whether the item is in a virtualized menu. React Aria then sets
|
|
105
|
+
* `aria-posinset` and `aria-setsize`, so assistive technology knows the
|
|
106
|
+
* item's position in the full menu rather than among the mounted rows.
|
|
107
|
+
*/
|
|
108
|
+
isVirtualized?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Ref to the inner focusable menu item.
|
|
111
|
+
*/
|
|
112
|
+
menuItemRef?: React.Ref<HTMLElement>;
|
|
113
|
+
/**
|
|
114
|
+
* Handler that is called when the menu should close after selecting an item
|
|
115
|
+
*/
|
|
116
|
+
onClose?: () => void;
|
|
117
|
+
ref?: React.ComponentPropsWithRef<NoInfer<T>>['ref'];
|
|
118
|
+
/**
|
|
119
|
+
* Tag name for item wrapper
|
|
120
|
+
*/
|
|
121
|
+
renderAs?: T;
|
|
122
|
+
/**
|
|
123
|
+
* Measurement props from a virtualized list, applied to the item's root
|
|
124
|
+
* element. The root is measured rather than a wrapper, since submenu
|
|
125
|
+
* wrappers use `display: contents` and have no height of their own.
|
|
126
|
+
*/
|
|
127
|
+
rowProps?: VirtualRowProps;
|
|
128
|
+
submenuRef?: React.RefObject<HTMLElement | null>;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* A menu item with a label, optional details, leading and trailing elements.
|
|
132
|
+
* Can also be used as a trigger button for a submenu. See:
|
|
133
|
+
* https://react-spectrum.adobe.com/react-aria/useMenu.html
|
|
134
|
+
*/
|
|
135
|
+
export declare function DropdownMenuItem<T extends React.ElementType = 'li'>({ node, state, closeOnSelect, onClose, renderAs, ref, menuItemRef, submenuRef, isVirtualized, rowProps, ...props }: DropdownMenuItemProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
136
|
+
export {};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Fragment, useContext, useEffect, useRef } from "react";
|
|
3
|
+
import { useHover, useKeyboard } from "@react-aria/interactions";
|
|
4
|
+
import { useMenuItem } from "@react-aria/menu";
|
|
5
|
+
import { mergeProps, mergeRefs } from "@react-aria/utils";
|
|
6
|
+
import { IconCheckmark } from "@sentry/icons/checkmark";
|
|
7
|
+
import { IconChevron } from "@sentry/icons/chevron";
|
|
8
|
+
import { ExternalLink, Link } from "../link/index.js";
|
|
9
|
+
import { ListItem } from "../menu/index.js";
|
|
10
|
+
import { isAfterFirstInSection } from "../useVirtualCollection.js";
|
|
11
|
+
import { DropdownMenuContext } from "./context.js";
|
|
12
|
+
function getSectionItemAttributes(node, state) {
|
|
13
|
+
const section = null === node.parentKey || void 0 === node.parentKey ? null : state.collection.getItem(node.parentKey);
|
|
14
|
+
if (section?.type !== 'section') return {};
|
|
15
|
+
return {
|
|
16
|
+
'data-section-item': true,
|
|
17
|
+
'data-first-in-section': isAfterFirstInSection(node, section) ? void 0 : true
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function DropdownMenuItem({ node, state, closeOnSelect, onClose, renderAs, ref, menuItemRef, submenuRef, isVirtualized, rowProps, ...props }) {
|
|
21
|
+
const innerWrapRef = useRef(null);
|
|
22
|
+
const trailingActionRef = useRef(null);
|
|
23
|
+
const lastPointerPosition = useRef(null);
|
|
24
|
+
const isDisabled = state.disabledKeys.has(node.key);
|
|
25
|
+
const isFocused = state.selectionManager.focusedKey === node.key;
|
|
26
|
+
const { key, onAction, to, label, isSelected, leadingItems, submenu, trailingItems, trailingAction, externalHref, closeOnSelect: itemCloseOnSelect, ref: itemRef, ...itemProps } = node.value ?? {};
|
|
27
|
+
const isSubmenu = !!submenu;
|
|
28
|
+
const { size } = node.props;
|
|
29
|
+
const { rootOverlayState, safetyTriangle } = useContext(DropdownMenuContext);
|
|
30
|
+
const isLink = to || externalHref;
|
|
31
|
+
const resolvedCloseOnSelect = itemCloseOnSelect ?? closeOnSelect;
|
|
32
|
+
const actionHandler = ()=>{
|
|
33
|
+
if (isLink) {
|
|
34
|
+
if (resolvedCloseOnSelect) requestAnimationFrame(()=>rootOverlayState?.close());
|
|
35
|
+
onAction?.();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (isSubmenu) return void state.selectionManager.toggleSelection(node.key);
|
|
39
|
+
onAction?.();
|
|
40
|
+
};
|
|
41
|
+
const { hoverProps, isHovered } = useHover({});
|
|
42
|
+
const previousInteraction = useRef({
|
|
43
|
+
isHovered,
|
|
44
|
+
isFocused
|
|
45
|
+
});
|
|
46
|
+
useEffect(()=>{
|
|
47
|
+
const previous = previousInteraction.current;
|
|
48
|
+
previousInteraction.current = {
|
|
49
|
+
isHovered,
|
|
50
|
+
isFocused
|
|
51
|
+
};
|
|
52
|
+
if (isHovered === previous.isHovered && isFocused === previous.isFocused) return;
|
|
53
|
+
if (isHovered && isFocused) {
|
|
54
|
+
if (isSubmenu) return void state.selectionManager.replaceSelection(node.key);
|
|
55
|
+
state.selectionManager.clearSelection();
|
|
56
|
+
}
|
|
57
|
+
}, [
|
|
58
|
+
isHovered,
|
|
59
|
+
isFocused,
|
|
60
|
+
isSubmenu,
|
|
61
|
+
node.key,
|
|
62
|
+
state.selectionManager
|
|
63
|
+
]);
|
|
64
|
+
const { keyboardProps } = useKeyboard({
|
|
65
|
+
onKeyDown: (e)=>{
|
|
66
|
+
if ('ArrowRight' === e.key && isSubmenu) return void state.selectionManager.replaceSelection(node.key);
|
|
67
|
+
if ('ArrowRight' === e.key && document.activeElement === innerWrapRef.current && trailingActionRef.current) {
|
|
68
|
+
trailingActionRef.current.focus();
|
|
69
|
+
if (document.activeElement === trailingActionRef.current) return void e.preventDefault();
|
|
70
|
+
}
|
|
71
|
+
e.continuePropagation();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const { menuItemProps, labelProps, descriptionProps } = useMenuItem({
|
|
75
|
+
key: node.key,
|
|
76
|
+
onAction: actionHandler,
|
|
77
|
+
onClose: ()=>{
|
|
78
|
+
onClose?.();
|
|
79
|
+
rootOverlayState?.close();
|
|
80
|
+
},
|
|
81
|
+
closeOnSelect: isLink ? false : resolvedCloseOnSelect,
|
|
82
|
+
isDisabled,
|
|
83
|
+
isVirtualized
|
|
84
|
+
}, state, innerWrapRef);
|
|
85
|
+
const makeInnerWrapProps = ()=>{
|
|
86
|
+
if (to) return {
|
|
87
|
+
as: Link,
|
|
88
|
+
to
|
|
89
|
+
};
|
|
90
|
+
if (externalHref) return {
|
|
91
|
+
as: ExternalLink,
|
|
92
|
+
href: externalHref
|
|
93
|
+
};
|
|
94
|
+
return {
|
|
95
|
+
as: 'div',
|
|
96
|
+
onClick: (e)=>{
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
e.stopPropagation();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
const mergedMenuItemContentProps = mergeProps(props, menuItemProps, hoverProps, keyboardProps, makeInnerWrapProps(), {
|
|
103
|
+
ref: mergeRefs(menuItemRef, innerWrapRef),
|
|
104
|
+
'data-test-id': key
|
|
105
|
+
});
|
|
106
|
+
const { onPointerEnter, onPointerMove, onPointerLeave } = mergedMenuItemContentProps;
|
|
107
|
+
const itemLabel = node.rendered ?? label;
|
|
108
|
+
return /*#__PURE__*/ jsx(ListItem, {
|
|
109
|
+
ref: mergeRefs(ref, itemRef, rowProps?.ref),
|
|
110
|
+
"data-index": rowProps?.['data-index'],
|
|
111
|
+
...getSectionItemAttributes(node, state),
|
|
112
|
+
as: renderAs,
|
|
113
|
+
label: itemLabel,
|
|
114
|
+
leadingItems: void 0 === isSelected ? leadingItems : (itemState)=>/*#__PURE__*/ jsxs(Fragment, {
|
|
115
|
+
children: [
|
|
116
|
+
/*#__PURE__*/ jsx(IconCheckmark, {
|
|
117
|
+
size: "md",
|
|
118
|
+
variant: "accent",
|
|
119
|
+
"aria-hidden": true,
|
|
120
|
+
visibility: isSelected ? 'visible' : 'hidden'
|
|
121
|
+
}),
|
|
122
|
+
'function' == typeof leadingItems ? leadingItems(itemState) : leadingItems
|
|
123
|
+
]
|
|
124
|
+
}),
|
|
125
|
+
disabled: isDisabled,
|
|
126
|
+
isFocused: isFocused,
|
|
127
|
+
innerWrapProps: {
|
|
128
|
+
...mergedMenuItemContentProps,
|
|
129
|
+
onPointerEnter: (event)=>{
|
|
130
|
+
lastPointerPosition.current = {
|
|
131
|
+
x: event.clientX,
|
|
132
|
+
y: event.clientY
|
|
133
|
+
};
|
|
134
|
+
const savedEvent = {
|
|
135
|
+
...event,
|
|
136
|
+
currentTarget: event.currentTarget
|
|
137
|
+
};
|
|
138
|
+
const enter = ()=>onPointerEnter?.(savedEvent);
|
|
139
|
+
if (safetyTriangle) safetyTriangle.defer(event, enter);
|
|
140
|
+
else enter();
|
|
141
|
+
},
|
|
142
|
+
onPointerMove: (event)=>{
|
|
143
|
+
lastPointerPosition.current = {
|
|
144
|
+
x: event.clientX,
|
|
145
|
+
y: event.clientY
|
|
146
|
+
};
|
|
147
|
+
onPointerMove?.(event);
|
|
148
|
+
},
|
|
149
|
+
onPointerLeave: (event)=>{
|
|
150
|
+
safetyTriangle?.leave(event.currentTarget);
|
|
151
|
+
if ('mouse' === event.pointerType && submenuRef?.current && lastPointerPosition.current) safetyTriangle?.start(lastPointerPosition.current, submenuRef.current);
|
|
152
|
+
onPointerLeave?.(event);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
labelProps: labelProps,
|
|
156
|
+
detailsProps: descriptionProps,
|
|
157
|
+
trailingAction: trailingAction,
|
|
158
|
+
trailingActionRef: trailingActionRef,
|
|
159
|
+
trailingActionWrapperProps: {
|
|
160
|
+
onKeyDown: (event)=>{
|
|
161
|
+
if ('ArrowLeft' === event.key) {
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
event.stopPropagation();
|
|
164
|
+
innerWrapRef.current?.focus();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
trailingItems: isSubmenu ? /*#__PURE__*/ jsxs(Fragment, {
|
|
169
|
+
children: [
|
|
170
|
+
trailingItems,
|
|
171
|
+
/*#__PURE__*/ jsx(IconChevron, {
|
|
172
|
+
size: "md",
|
|
173
|
+
direction: "right",
|
|
174
|
+
"aria-hidden": "true"
|
|
175
|
+
})
|
|
176
|
+
]
|
|
177
|
+
}) : trailingItems,
|
|
178
|
+
size: size,
|
|
179
|
+
...itemProps
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
export { DropdownMenuItem };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { AriaMenuOptions } from '@react-aria/menu';
|
|
3
|
+
import type { TreeProps } from '@react-stately/tree';
|
|
4
|
+
import type { OverlayState } from './context.js';
|
|
5
|
+
import type { DropdownMenuContentSizeOptions, DropdownMenuSearchOptions, MenuItemProps } from './item.js';
|
|
6
|
+
export interface DropdownMenuListProps extends Omit<AriaMenuOptions<MenuItemProps>, 'selectionMode' | 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'disallowEmptySelection'>, TreeProps<MenuItemProps>, DropdownMenuContentSizeOptions {
|
|
7
|
+
overlayPositionProps: React.HTMLAttributes<HTMLDivElement>;
|
|
8
|
+
/**
|
|
9
|
+
* The open state of the current overlay that contains this menu
|
|
10
|
+
*/
|
|
11
|
+
overlayState: OverlayState;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the menu should close when an item has been clicked/selected
|
|
14
|
+
*/
|
|
15
|
+
closeOnSelect?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Prevent users from highlighting text inside the menu.
|
|
18
|
+
*/
|
|
19
|
+
disableTextSelection?: boolean;
|
|
20
|
+
emptyMessage?: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Whether only the items near the viewport are rendered. Computed by
|
|
23
|
+
* `DropdownMenuContent` from `virtualizeThreshold`, so it is not part of the
|
|
24
|
+
* public API: consumers set the threshold instead.
|
|
25
|
+
*/
|
|
26
|
+
isVirtualized?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* To be displayed below the menu items
|
|
29
|
+
*/
|
|
30
|
+
menuFooter?: React.ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* Title to display on top of the menu
|
|
33
|
+
*/
|
|
34
|
+
menuTitle?: React.ReactNode;
|
|
35
|
+
/** Controlled input state supplied by DropdownMenuContent. */
|
|
36
|
+
searchState?: DropdownMenuSearchOptions & {
|
|
37
|
+
onChange: (value: string) => void;
|
|
38
|
+
value: string;
|
|
39
|
+
};
|
|
40
|
+
size?: MenuItemProps['size'];
|
|
41
|
+
/**
|
|
42
|
+
* Number of items, counting the items inside sections, above which only the
|
|
43
|
+
* items near the viewport are rendered. Submenus inherit the threshold of
|
|
44
|
+
* their parent menu. Pass `Infinity` to never virtualize.
|
|
45
|
+
* @default 150
|
|
46
|
+
*/
|
|
47
|
+
virtualizeThreshold?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Style overrides applied to the position wrapper. Useful for overriding
|
|
50
|
+
* the default z-index (e.g. when the menu is inside a high z-index container
|
|
51
|
+
* like a sidebar).
|
|
52
|
+
*/
|
|
53
|
+
zIndex?: number;
|
|
54
|
+
}
|
|
55
|
+
export type DropdownMenuContentProps = Omit<DropdownMenuListProps, 'searchState' | 'isVirtualized'> & {
|
|
56
|
+
items: MenuItemProps[];
|
|
57
|
+
search?: DropdownMenuSearchOptions;
|
|
58
|
+
};
|
|
59
|
+
export declare function DropdownMenuContent({ items, disabledKeys, size, search, virtualizeThreshold, ...props }: DropdownMenuContentProps): import("@emotion/react/jsx-runtime").JSX.Element;
|