@sentry/scraps 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/README.md +95 -3
  2. package/dist/alert/alert.js +10 -7
  3. package/dist/badge/tag.js +4 -2
  4. package/dist/button/button.js +1 -0
  5. package/dist/button/linkButton.js +1 -0
  6. package/dist/button/styles.js +157 -152
  7. package/dist/codeBlock/codeBlock.js +1 -0
  8. package/dist/compactSelect/compactSelect.d.ts +2 -2
  9. package/dist/compactSelect/compactSelect.js +37 -23
  10. package/dist/compactSelect/control.js +14 -10
  11. package/dist/compactSelect/gridList/index.js +35 -36
  12. package/dist/compactSelect/gridList/option.d.ts +4 -1
  13. package/dist/compactSelect/gridList/option.js +4 -3
  14. package/dist/compactSelect/gridList/section.d.ts +10 -3
  15. package/dist/compactSelect/gridList/section.js +16 -33
  16. package/dist/compactSelect/listBox/index.d.ts +1 -1
  17. package/dist/compactSelect/listBox/index.js +46 -58
  18. package/dist/compactSelect/listBox/section.d.ts +10 -8
  19. package/dist/compactSelect/listBox/section.js +11 -30
  20. package/dist/compactSelect/styles.d.ts +6 -7
  21. package/dist/compactSelect/styles.js +1 -23
  22. package/dist/compactSelect/utils.js +2 -6
  23. package/dist/dateTime/config.d.ts +23 -0
  24. package/dist/dateTime/config.js +50 -0
  25. package/dist/dateTime/context.d.ts +18 -0
  26. package/dist/dateTime/context.js +46 -0
  27. package/dist/dateTime/dateTime.d.ts +6 -0
  28. package/dist/dateTime/dateTime.js +30 -0
  29. package/dist/dateTime/format.d.ts +24 -0
  30. package/dist/dateTime/format.js +45 -0
  31. package/dist/dateTime/index.d.ts +6 -0
  32. package/dist/dateTime/index.js +6 -0
  33. package/dist/dateTime/intlFormatter.d.ts +9 -0
  34. package/dist/dateTime/intlFormatter.js +16 -0
  35. package/dist/dateTime/parseDate.d.ts +3 -0
  36. package/dist/dateTime/parseDate.js +12 -0
  37. package/dist/diagnostics/context.d.ts +12 -0
  38. package/dist/diagnostics/context.js +11 -0
  39. package/dist/diagnostics/index.d.ts +2 -0
  40. package/dist/diagnostics/index.js +1 -0
  41. package/dist/disclosure/disclosure.js +1 -1
  42. package/dist/dragHandle/dragHandle.js +3 -5
  43. package/dist/dropdownMenu/context.d.ts +36 -11
  44. package/dist/dropdownMenu/context.js +2 -1
  45. package/dist/dropdownMenu/dropdownMenu.d.ts +2 -2
  46. package/dist/dropdownMenu/dropdownMenu.js +9 -3
  47. package/dist/dropdownMenu/item.d.ts +7 -8
  48. package/dist/dropdownMenu/item.js +43 -77
  49. package/dist/dropdownMenu/list.d.ts +31 -5
  50. package/dist/dropdownMenu/list.js +154 -133
  51. package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +5 -241
  52. package/dist/dropdownMenu/useDropdownMenuKeyboard.js +5 -29
  53. package/dist/dropdownMenu/useDropdownMenuRowLayout.js +6 -14
  54. package/dist/dropdownMenu/useDropdownRootMenuState.d.ts +13 -0
  55. package/dist/dropdownMenu/useDropdownRootMenuState.js +30 -0
  56. package/dist/dropdownMenu/useDropdownSubmenuState.d.ts +19 -0
  57. package/dist/dropdownMenu/useDropdownSubmenuState.js +25 -0
  58. package/dist/dropdownMenu/utils.js +5 -7
  59. package/dist/duration/formatElapsedDuration.d.ts +4 -0
  60. package/dist/duration/formatElapsedDuration.js +10 -0
  61. package/dist/duration/getDuration.d.ts +68 -0
  62. package/dist/duration/getDuration.js +80 -0
  63. package/dist/duration/index.d.ts +2 -0
  64. package/dist/duration/index.js +2 -0
  65. package/dist/form/field/radioGroupField.d.ts +7 -0
  66. package/dist/form/field/radioGroupField.js +14 -0
  67. package/dist/form/field/selectField.d.ts +3 -4
  68. package/dist/form/field/selectField.js +16 -24
  69. package/dist/{compactSelect/fzf.d.ts → fzf.d.ts} +1 -0
  70. package/dist/{compactSelect/fzf.js → fzf.js} +5 -1
  71. package/dist/layout/container.d.ts +24 -7
  72. package/dist/layout/container.js +9 -12
  73. package/dist/layout/flex.js +1 -1
  74. package/dist/layout/grid.js +2 -2
  75. package/dist/layout/index.d.ts +1 -1
  76. package/dist/layout/index.js +1 -1
  77. package/dist/layout/stack.js +1 -1
  78. package/dist/layout/styles.d.ts +28 -7
  79. package/dist/layout/styles.js +76 -16
  80. package/dist/layout/surface.d.ts +2 -2
  81. package/dist/layout/surface.js +6 -3
  82. package/dist/legacyDatetime.d.ts +21 -0
  83. package/dist/legacyDatetime.js +13 -0
  84. package/dist/link/index.d.ts +1 -1
  85. package/dist/link/index.js +1 -1
  86. package/dist/link/linkBehaviorContext.d.ts +9 -0
  87. package/dist/link/linkBehaviorContext.js +37 -7
  88. package/dist/menu/menu.d.ts +1 -3
  89. package/dist/menu/menu.js +5 -6
  90. package/dist/menu/selectValue.d.ts +2 -6
  91. package/dist/modal/components.js +2 -2
  92. package/dist/overlayArrow.js +2 -2
  93. package/dist/relativeTime/getRelativeDate.d.ts +14 -0
  94. package/dist/relativeTime/getRelativeDate.js +107 -0
  95. package/dist/relativeTime/index.d.ts +3 -0
  96. package/dist/relativeTime/index.js +3 -0
  97. package/dist/relativeTime/relativeTime.d.ts +55 -0
  98. package/dist/relativeTime/relativeTime.js +102 -0
  99. package/dist/relativeTime/useRelativeTimeFormatter.d.ts +2 -0
  100. package/dist/relativeTime/useRelativeTimeFormatter.js +10 -0
  101. package/dist/select/chips.d.ts +14 -0
  102. package/dist/select/chips.js +45 -0
  103. package/dist/select/filter.js +7 -11
  104. package/dist/select/index.d.ts +1 -1
  105. package/dist/select/indicators.d.ts +11 -0
  106. package/dist/select/indicators.js +61 -0
  107. package/dist/select/menu.d.ts +44 -0
  108. package/dist/select/menu.js +103 -0
  109. package/dist/select/option.d.ts +23 -15
  110. package/dist/select/option.js +66 -58
  111. package/dist/select/options.d.ts +31 -0
  112. package/dist/select/options.js +74 -0
  113. package/dist/select/select.d.ts +24 -11
  114. package/dist/select/select.js +527 -429
  115. package/dist/select/styles.d.ts +148 -2
  116. package/dist/select/styles.js +156 -1
  117. package/dist/select/types.d.ts +6 -7
  118. package/dist/select/types.js +4 -0
  119. package/dist/select/utils.d.ts +2 -0
  120. package/dist/select/utils.js +4 -0
  121. package/dist/separator/separator.d.ts +2 -2
  122. package/dist/separator/separator.js +4 -3
  123. package/dist/slot/slot.js +16 -12
  124. package/dist/tabs/context.d.ts +9 -0
  125. package/dist/tabs/context.js +9 -0
  126. package/dist/tabs/index.d.ts +2 -4
  127. package/dist/tabs/index.js +1 -3
  128. package/dist/tabs/item.d.ts +16 -5
  129. package/dist/tabs/tab.js +9 -4
  130. package/dist/tabs/tabList.d.ts +5 -5
  131. package/dist/tabs/tabList.js +8 -6
  132. package/dist/tabs/tabPanels.d.ts +2 -3
  133. package/dist/tabs/tabPanels.js +1 -1
  134. package/dist/tabs/tabs.d.ts +46 -31
  135. package/dist/tabs/tabs.js +38 -35
  136. package/dist/text/prose.d.ts +2 -2
  137. package/dist/theme/index.d.ts +2 -0
  138. package/dist/theme/index.js +2 -0
  139. package/dist/theme/theme.d.ts +34 -34
  140. package/dist/theme/theme.js +9 -0
  141. package/dist/theme/types.d.ts +21 -2
  142. package/dist/theme/useResolvedTheme.d.ts +12 -0
  143. package/dist/theme/useResolvedTheme.js +20 -0
  144. package/dist/theme/variables.css +1116 -0
  145. package/dist/theme/variables.d.ts +985 -0
  146. package/dist/theme/variables.js +455 -0
  147. package/dist/translation/index.d.ts +1 -0
  148. package/dist/translation/index.js +1 -0
  149. package/dist/translation/translate.d.ts +9 -0
  150. package/dist/translation/translate.js +5 -0
  151. package/dist/translation/translationContext.d.ts +2 -1
  152. package/dist/translation/translationContext.js +2 -1
  153. package/dist/useVirtualCollection.d.ts +14 -1
  154. package/dist/useVirtualCollection.js +59 -3
  155. package/fonts/OFL.txt +94 -0
  156. package/fonts/roboto-mono-variable-cyrillic-ext.woff2 +0 -0
  157. package/fonts/roboto-mono-variable-cyrillic.woff2 +0 -0
  158. package/fonts/roboto-mono-variable-greek.woff2 +0 -0
  159. package/fonts/roboto-mono-variable-latin-ext.woff2 +0 -0
  160. package/fonts/roboto-mono-variable-vietnamese.woff2 +0 -0
  161. package/fonts/roboto-mono-variable.woff2 +0 -0
  162. package/fonts/rubik-variable-cyrillic-ext.woff2 +0 -0
  163. package/fonts/rubik-variable-cyrillic.woff2 +0 -0
  164. package/fonts/rubik-variable-latin-ext.woff2 +0 -0
  165. package/fonts/rubik-variable.woff2 +0 -0
  166. package/fonts.css +211 -0
  167. package/package.json +39 -15
  168. package/dist/compactSelect/useVirtualizedItems.d.ts +0 -52
  169. package/dist/compactSelect/useVirtualizedItems.js +0 -74
  170. package/dist/datetime.d.ts +0 -39
  171. package/dist/datetime.js +0 -20
  172. package/dist/dropdownMenu/useSafetyTriangle.d.ts +0 -12
  173. package/dist/dropdownMenu/useSafetyTriangle.js +0 -119
  174. package/dist/select/reactSelectWrapper.d.ts +0 -8
  175. package/dist/select/reactSelectWrapper.js +0 -25
  176. package/dist/select/virtualizedMenuList.d.ts +0 -24
  177. package/dist/select/virtualizedMenuList.js +0 -123
@@ -4,7 +4,7 @@ import type { UseOverlayProps } from '../useOverlay.js';
4
4
  import type { MenuItemProps } from './item.js';
5
5
  import type { DropdownMenuContentProps, DropdownMenuListProps } from './list.js';
6
6
  export type { MenuItemProps };
7
- interface BaseDropdownMenuProps extends Omit<DropdownMenuContentProps, 'overlayState' | 'overlayPositionProps' | 'items' | 'children' | 'menuTitle'>, Pick<UseOverlayProps, 'isOpen' | 'offset' | 'position' | 'isDismissable' | 'shouldCloseOnBlur' | 'shouldCloseOnInteractOutside' | 'onInteractOutside' | 'onOpenChange' | 'preventOverflowOptions' | 'flipOptions' | 'shouldApplyMinWidth' | 'strategy'> {
7
+ interface BaseDropdownMenuProps extends Omit<DropdownMenuContentProps, 'menuLevel' | 'overlayPositionProps' | 'items' | 'children' | 'menuTitle'>, Pick<UseOverlayProps, 'isOpen' | 'offset' | 'position' | 'isDismissable' | 'shouldCloseOnBlur' | 'shouldCloseOnInteractOutside' | 'onInteractOutside' | 'onOpenChange' | 'preventOverflowOptions' | 'flipOptions' | 'shouldApplyMinWidth' | 'strategy'> {
8
8
  /**
9
9
  * Items to display inside the dropdown menu. If the item has a `children`
10
10
  * prop, it will be rendered as a menu section. If it has a `children` prop
@@ -30,7 +30,7 @@ interface BaseDropdownMenuProps extends Omit<DropdownMenuContentProps, 'overlayS
30
30
  /**
31
31
  * Reference to the container element that the portal should be rendered into.
32
32
  */
33
- portalContainerRef?: React.RefObject<HTMLElement | null>;
33
+ portalContainerRef?: React.RefObject<Element | DocumentFragment | null>;
34
34
  /**
35
35
  * Tag name for the outer wrap, defaults to `div`
36
36
  */
@@ -8,14 +8,15 @@ import { ControlContext, DropdownButton } from "../menu/index.js";
8
8
  import { useOverlay } from "../useOverlay.js";
9
9
  import { DropdownMenuContent } from "./content.js";
10
10
  import { DropdownMenuContext } from "./context.js";
11
+ import { useDropdownRootMenuState } from "./useDropdownRootMenuState.js";
11
12
  function DropdownMenu({ items, disabledKeys, trigger, triggerLabel, isDisabled: disabledProp, isOpen: isOpenProp, renderWrapAs = 'div', size: explicitSize, className, usePortal = false, offset = 8, position = 'bottom-start', isDismissable = true, shouldCloseOnBlur = true, shouldCloseOnInteractOutside, onInteractOutside, onOpenChange, preventOverflowOptions, flipOptions, portalContainerRef, shouldApplyMinWidth, minMenuWidth, strategy, ...props }) {
12
13
  const size = explicitSize ?? 'md';
13
14
  const isDisabled = disabledProp ?? (!items || 0 === items.length);
14
- const { rootOverlayState } = useContext(DropdownMenuContext);
15
+ const { rootMenuState: parentRootMenuState } = useContext(DropdownMenuContext);
15
16
  const { isOpen, state: overlayState, triggerRef, triggerProps: overlayTriggerProps, overlayProps } = useOverlay({
16
17
  type: 'menu',
17
18
  isOpen: isOpenProp,
18
- onClose: rootOverlayState?.close,
19
+ onClose: parentRootMenuState?.close,
19
20
  offset,
20
21
  position,
21
22
  isDismissable,
@@ -29,6 +30,7 @@ function DropdownMenu({ items, disabledKeys, trigger, triggerLabel, isDisabled:
29
30
  shouldApplyMinWidth,
30
31
  strategy
31
32
  });
33
+ const rootMenuState = useDropdownRootMenuState(overlayState, parentRootMenuState);
32
34
  const { menuTriggerProps, menuProps } = useMenuTrigger({
33
35
  type: 'menu',
34
36
  isDisabled
@@ -58,7 +60,11 @@ function DropdownMenu({ items, disabledKeys, trigger, triggerLabel, isDisabled:
58
60
  minWidth: minMenuWidth ?? overlayProps.style?.minWidth
59
61
  }
60
62
  },
61
- overlayState: overlayState,
63
+ menuLevel: {
64
+ type: 'root',
65
+ state: rootMenuState
66
+ },
67
+ isDismissable: isDismissable,
62
68
  items: items
63
69
  });
64
70
  return usePortal ? /*#__PURE__*/ createPortal(menu, portalContainerRef?.current ?? document.body) : menu;
@@ -1,7 +1,7 @@
1
1
  import type * as React from 'react';
2
- import type { TreeState } from '@react-stately/tree';
2
+ import type { SubmenuTriggerAria } from '@react-aria/menu';
3
3
  import type { Node } from '@react-types/shared';
4
- import { type LinkProps } from '../link/index.js';
4
+ import type { LinkProps } from '../link/index.js';
5
5
  import { type ListItemProps, type MenuItemTrailingAction } from '../menu/index.js';
6
6
  import type { UseOverlayProps } from '../useOverlay.js';
7
7
  import { type VirtualRowProps } from '../useVirtualCollection.js';
@@ -95,10 +95,6 @@ interface DropdownMenuItemProps<T extends React.ElementType = 'li'> {
95
95
  * Node representation (from @react-aria) of the item
96
96
  */
97
97
  node: Node<MenuItemProps>;
98
- /**
99
- * Tree state (from @react-stately) inherited from parent menu
100
- */
101
- state: TreeState<MenuItemProps>;
102
98
  id?: string;
103
99
  /**
104
100
  * Whether the item is in a virtualized menu. React Aria then sets
@@ -125,12 +121,15 @@ interface DropdownMenuItemProps<T extends React.ElementType = 'li'> {
125
121
  * wrappers use `display: contents` and have no height of their own.
126
122
  */
127
123
  rowProps?: VirtualRowProps;
128
- submenuRef?: React.RefObject<HTMLElement | null>;
124
+ /**
125
+ * Props from `useSubmenuTrigger`, set when this item opens a submenu.
126
+ */
127
+ submenuTriggerProps?: SubmenuTriggerAria<MenuItemProps>['submenuTriggerProps'];
129
128
  }
130
129
  /**
131
130
  * A menu item with a label, optional details, leading and trailing elements.
132
131
  * Can also be used as a trigger button for a submenu. See:
133
132
  * https://react-spectrum.adobe.com/react-aria/useMenu.html
134
133
  */
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;
134
+ export declare function DropdownMenuItem<T extends React.ElementType = 'li'>({ node, closeOnSelect, onClose, renderAs, ref, menuItemRef, submenuTriggerProps, isVirtualized, rowProps, ...props }: DropdownMenuItemProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
136
135
  export {};
@@ -1,14 +1,14 @@
1
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";
2
+ import { Fragment, useContext, useRef } from "react";
3
+ import { useKeyboard } from "@react-aria/interactions";
4
4
  import { useMenuItem } from "@react-aria/menu";
5
5
  import { mergeProps, mergeRefs } from "@react-aria/utils";
6
6
  import { IconCheckmark } from "@sentry/icons/checkmark";
7
7
  import { IconChevron } from "@sentry/icons/chevron";
8
- import { ExternalLink, Link } from "../link/index.js";
8
+ import { useLinkBehavior } from "../link/linkBehaviorContext.js";
9
9
  import { ListItem } from "../menu/index.js";
10
10
  import { isAfterFirstInSection } from "../useVirtualCollection.js";
11
- import { DropdownMenuContext } from "./context.js";
11
+ import { DropdownMenuContext, DropdownMenuTreeStateContext } from "./context.js";
12
12
  function getSectionItemAttributes(node, state) {
13
13
  const section = null === node.parentKey || void 0 === node.parentKey ? null : state.collection.getItem(node.parentKey);
14
14
  if (section?.type !== 'section') return {};
@@ -17,53 +17,31 @@ function getSectionItemAttributes(node, state) {
17
17
  'data-first-in-section': isAfterFirstInSection(node, section) ? void 0 : true
18
18
  };
19
19
  }
20
- function DropdownMenuItem({ node, state, closeOnSelect, onClose, renderAs, ref, menuItemRef, submenuRef, isVirtualized, rowProps, ...props }) {
20
+ function DropdownMenuItem({ node, closeOnSelect, onClose, renderAs, ref, menuItemRef, submenuTriggerProps, isVirtualized, rowProps, ...props }) {
21
21
  const innerWrapRef = useRef(null);
22
22
  const trailingActionRef = useRef(null);
23
- const lastPointerPosition = useRef(null);
23
+ const state = useContext(DropdownMenuTreeStateContext);
24
24
  const isDisabled = state.disabledKeys.has(node.key);
25
25
  const isFocused = state.selectionManager.focusedKey === node.key;
26
26
  const { key, onAction, to, label, isSelected, leadingItems, submenu, trailingItems, trailingAction, externalHref, closeOnSelect: itemCloseOnSelect, ref: itemRef, ...itemProps } = node.value ?? {};
27
27
  const isSubmenu = !!submenu;
28
28
  const { size } = node.props;
29
- const { rootOverlayState, safetyTriangle } = useContext(DropdownMenuContext);
29
+ const { rootMenuState } = useContext(DropdownMenuContext);
30
30
  const isLink = to || externalHref;
31
+ const { Component: RouterLink, behavior: linkBehavior } = useLinkBehavior({
32
+ to: to ?? ''
33
+ });
31
34
  const resolvedCloseOnSelect = itemCloseOnSelect ?? closeOnSelect;
32
35
  const actionHandler = ()=>{
33
36
  if (isLink) {
34
- if (resolvedCloseOnSelect) requestAnimationFrame(()=>rootOverlayState?.close());
37
+ if (resolvedCloseOnSelect) requestAnimationFrame(()=>rootMenuState?.close());
35
38
  onAction?.();
36
39
  return;
37
40
  }
38
- if (isSubmenu) return void state.selectionManager.toggleSelection(node.key);
39
41
  onAction?.();
40
42
  };
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
43
  const { keyboardProps } = useKeyboard({
65
44
  onKeyDown: (e)=>{
66
- if ('ArrowRight' === e.key && isSubmenu) return void state.selectionManager.replaceSelection(node.key);
67
45
  if ('ArrowRight' === e.key && document.activeElement === innerWrapRef.current && trailingActionRef.current) {
68
46
  trailingActionRef.current.focus();
69
47
  if (document.activeElement === trailingActionRef.current) return void e.preventDefault();
@@ -71,12 +49,14 @@ function DropdownMenuItem({ node, state, closeOnSelect, onClose, renderAs, ref,
71
49
  e.continuePropagation();
72
50
  }
73
51
  });
52
+ const { isOpen: _isSubmenuOpen, ...submenuTriggerAriaProps } = submenuTriggerProps ?? {};
74
53
  const { menuItemProps, labelProps, descriptionProps } = useMenuItem({
54
+ ...submenuTriggerAriaProps,
75
55
  key: node.key,
76
56
  onAction: actionHandler,
77
57
  onClose: ()=>{
78
58
  onClose?.();
79
- rootOverlayState?.close();
59
+ rootMenuState?.close();
80
60
  },
81
61
  closeOnSelect: isLink ? false : resolvedCloseOnSelect,
82
62
  isDisabled,
@@ -84,12 +64,14 @@ function DropdownMenuItem({ node, state, closeOnSelect, onClose, renderAs, ref,
84
64
  }, state, innerWrapRef);
85
65
  const makeInnerWrapProps = ()=>{
86
66
  if (to) return {
87
- as: Link,
88
- to
67
+ as: RouterLink,
68
+ ...linkBehavior()
89
69
  };
90
70
  if (externalHref) return {
91
- as: ExternalLink,
92
- href: externalHref
71
+ as: 'a',
72
+ href: externalHref,
73
+ target: '_blank',
74
+ rel: 'noreferrer noopener'
93
75
  };
94
76
  return {
95
77
  as: 'div',
@@ -99,12 +81,31 @@ function DropdownMenuItem({ node, state, closeOnSelect, onClose, renderAs, ref,
99
81
  }
100
82
  };
101
83
  };
102
- const mergedMenuItemContentProps = mergeProps(props, menuItemProps, hoverProps, keyboardProps, makeInnerWrapProps(), {
84
+ const mergedMenuItemContentProps = mergeProps(props, menuItemProps, keyboardProps, makeInnerWrapProps(), {
103
85
  ref: mergeRefs(menuItemRef, innerWrapRef),
104
86
  'data-test-id': key
105
87
  });
106
- const { onPointerEnter, onPointerMove, onPointerLeave } = mergedMenuItemContentProps;
88
+ const { onPointerEnter, onPointerMove, onPointerLeave, ...menuItemContentProps } = mergedMenuItemContentProps;
107
89
  const itemLabel = node.rendered ?? label;
90
+ const isFromRow = (event)=>event.target instanceof Node && event.currentTarget.contains(event.target);
91
+ const rowEventProps = {
92
+ onPointerEnter: (event)=>{
93
+ if (isFromRow(event)) onPointerEnter?.(event);
94
+ },
95
+ onPointerMove: (event)=>{
96
+ if (isFromRow(event)) onPointerMove?.(event);
97
+ },
98
+ onPointerLeave: (event)=>{
99
+ if (isFromRow(event)) onPointerLeave?.(event);
100
+ },
101
+ onKeyDown: (event)=>{
102
+ if ('ArrowLeft' === event.key && event.target === trailingActionRef.current) {
103
+ event.preventDefault();
104
+ event.stopPropagation();
105
+ innerWrapRef.current?.focus();
106
+ }
107
+ }
108
+ };
108
109
  return /*#__PURE__*/ jsx(ListItem, {
109
110
  ref: mergeRefs(ref, itemRef, rowProps?.ref),
110
111
  "data-index": rowProps?.['data-index'],
@@ -124,47 +125,11 @@ function DropdownMenuItem({ node, state, closeOnSelect, onClose, renderAs, ref,
124
125
  }),
125
126
  disabled: isDisabled,
126
127
  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
- },
128
+ innerWrapProps: menuItemContentProps,
155
129
  labelProps: labelProps,
156
130
  detailsProps: descriptionProps,
157
131
  trailingAction: trailingAction,
158
132
  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
133
  trailingItems: isSubmenu ? /*#__PURE__*/ jsxs(Fragment, {
169
134
  children: [
170
135
  trailingItems,
@@ -176,6 +141,7 @@ function DropdownMenuItem({ node, state, closeOnSelect, onClose, renderAs, ref,
176
141
  ]
177
142
  }) : trailingItems,
178
143
  size: size,
144
+ ...rowEventProps,
179
145
  ...itemProps
180
146
  });
181
147
  }
@@ -1,14 +1,14 @@
1
1
  import type * as React from 'react';
2
2
  import type { AriaMenuOptions } from '@react-aria/menu';
3
+ import type { RootMenuTriggerState } from '@react-stately/menu';
3
4
  import type { TreeProps } from '@react-stately/tree';
4
- import type { OverlayState } from './context.js';
5
5
  import type { DropdownMenuContentSizeOptions, DropdownMenuSearchOptions, MenuItemProps } from './item.js';
6
6
  export interface DropdownMenuListProps extends Omit<AriaMenuOptions<MenuItemProps>, 'selectionMode' | 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'disallowEmptySelection'>, TreeProps<MenuItemProps>, DropdownMenuContentSizeOptions {
7
- overlayPositionProps: React.HTMLAttributes<HTMLDivElement>;
8
7
  /**
9
- * The open state of the current overlay that contains this menu
8
+ * Where this menu sits in the menu tree.
10
9
  */
11
- overlayState: OverlayState;
10
+ menuLevel: DropdownMenuLevel;
11
+ overlayPositionProps: React.HTMLAttributes<HTMLDivElement>;
12
12
  /**
13
13
  * Whether the menu should close when an item has been clicked/selected
14
14
  */
@@ -18,6 +18,11 @@ export interface DropdownMenuListProps extends Omit<AriaMenuOptions<MenuItemProp
18
18
  */
19
19
  disableTextSelection?: boolean;
20
20
  emptyMessage?: React.ReactNode;
21
+ /**
22
+ * Whether interacting outside the menu closes it. Submenus inherit the
23
+ * setting of their parent menu.
24
+ */
25
+ isDismissable?: boolean;
21
26
  /**
22
27
  * Whether only the items near the viewport are rendered. Computed by
23
28
  * `DropdownMenuContent` from `virtualizeThreshold`, so it is not part of the
@@ -52,8 +57,29 @@ export interface DropdownMenuListProps extends Omit<AriaMenuOptions<MenuItemProp
52
57
  */
53
58
  zIndex?: number;
54
59
  }
60
+ /**
61
+ * A root menu starts a menu tree, even when it renders inside another menu.
62
+ * A submenu belongs to the tree of the menu that contains its trigger, and
63
+ * reads the root menu state from context.
64
+ */
65
+ type DropdownMenuLevel = {
66
+ state: RootMenuTriggerState;
67
+ type: 'root';
68
+ } | {
69
+ /** Closes this submenu and returns focus to its trigger. */
70
+ close: () => void;
71
+ /**
72
+ * Index of this submenu in the root menu's `expandedKeysStack`: 0 for a
73
+ * submenu of the root menu, 1 for a submenu of that submenu, and so on.
74
+ */
75
+ level: number;
76
+ /** Ref for the menu element, so the trigger can move focus into it. */
77
+ ref: React.RefObject<HTMLUListElement | null>;
78
+ type: 'submenu';
79
+ };
55
80
  export type DropdownMenuContentProps = Omit<DropdownMenuListProps, 'searchState' | 'isVirtualized'> & {
56
81
  items: MenuItemProps[];
57
82
  search?: DropdownMenuSearchOptions;
58
83
  };
59
- export declare function DropdownMenuContent({ items, disabledKeys, size, search, virtualizeThreshold, ...props }: DropdownMenuContentProps): import("@emotion/react/jsx-runtime").JSX.Element;
84
+ export declare function DropdownMenuContent({ items, disabledKeys, size, search, isDismissable, virtualizeThreshold, ...props }: DropdownMenuContentProps): import("@emotion/react/jsx-runtime").JSX.Element;
85
+ export {};