@arc-ui/components 12.0.0-beta.21 → 12.0.0-beta.23

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 (208) hide show
  1. package/lib/Alert/Alert.cjs +41 -14
  2. package/lib/Alert/Alert.mjs +42 -15
  3. package/lib/Alert/styles.css +1 -1
  4. package/lib/Align/styles.css +1 -1
  5. package/lib/AppButton/styles.css +1 -1
  6. package/lib/Avatar/styles.css +1 -1
  7. package/lib/AvatarGroup/styles.css +1 -1
  8. package/lib/Badge/styles.css +1 -1
  9. package/lib/Banner/Banner.cjs +1 -1
  10. package/lib/Banner/Banner.mjs +1 -1
  11. package/lib/Box/styles.css +1 -1
  12. package/lib/BrandLogo/styles.css +1 -1
  13. package/lib/Breadcrumbs/Breadcrumbs.cjs +12 -3
  14. package/lib/Breadcrumbs/Breadcrumbs.mjs +12 -3
  15. package/lib/Breadcrumbs/styles.css +1 -1
  16. package/lib/Button/styles.css +1 -1
  17. package/lib/ButtonGroup/styles.css +1 -1
  18. package/lib/ButtonV2/styles.css +1 -1
  19. package/lib/Calendar/Calendar.cjs +2 -2
  20. package/lib/Calendar/Calendar.mjs +2 -2
  21. package/lib/Calendar/styles.css +1 -1
  22. package/lib/CardFooter/styles.css +1 -1
  23. package/lib/CardHeading/styles.css +1 -1
  24. package/lib/Carousel/Carousel.cjs +11 -5
  25. package/lib/Carousel/Carousel.mjs +8 -2
  26. package/lib/Carousel/styles.css +1 -1
  27. package/lib/Checkbox/Checkbox.cjs +85 -11
  28. package/lib/Checkbox/Checkbox.mjs +87 -9
  29. package/lib/Checkbox/styles.css +1 -1
  30. package/lib/Columns/styles.css +1 -1
  31. package/lib/ComboBox/ComboBox.cjs +276 -11
  32. package/lib/ComboBox/ComboBox.mjs +279 -10
  33. package/lib/ComboBox/styles.css +1 -1
  34. package/lib/ContentSwitcher/ContentSwitcher.cjs +5 -6
  35. package/lib/ContentSwitcher/ContentSwitcher.mjs +5 -6
  36. package/lib/ContentSwitcher/styles.css +1 -1
  37. package/lib/ContentSwitcherDropdown/styles.css +1 -1
  38. package/lib/DatePicker/DatePicker.cjs +351 -38
  39. package/lib/DatePicker/DatePicker.mjs +329 -17
  40. package/lib/DatePicker/styles.css +1 -1
  41. package/lib/Disclosure/styles.css +1 -1
  42. package/lib/DisclosureMini/styles.css +1 -1
  43. package/lib/Download/styles.css +1 -1
  44. package/lib/Drawer/Drawer.cjs +58 -10
  45. package/lib/Drawer/Drawer.mjs +55 -7
  46. package/lib/Drawer/styles.css +1 -1
  47. package/lib/Elevation/styles.css +1 -1
  48. package/lib/Filter/styles.css +1 -1
  49. package/lib/FormControl/styles.css +1 -1
  50. package/lib/GhostedHeroBanner/styles.css +1 -1
  51. package/lib/GradientPageBackground/GradientPageBackground.cjs +55 -43
  52. package/lib/GradientPageBackground/GradientPageBackground.mjs +55 -43
  53. package/lib/GradientPageBackground/styles.css +1 -1
  54. package/lib/Grid/styles.css +1 -1
  55. package/lib/Group/styles.css +1 -1
  56. package/lib/Heading/styles.css +1 -1
  57. package/lib/HeroBanner/HeroBanner.cjs +1 -1
  58. package/lib/HeroBanner/HeroBanner.mjs +1 -1
  59. package/lib/HeroBanner/styles.css +1 -1
  60. package/lib/HeroButton/HeroButton.cjs +77 -9
  61. package/lib/HeroButton/HeroButton.mjs +80 -8
  62. package/lib/HeroButton/styles.css +1 -1
  63. package/lib/Hidden/styles.css +1 -1
  64. package/lib/HorizontalCard/styles.css +1 -1
  65. package/lib/Icon/styles.css +1 -1
  66. package/lib/Image/styles.css +1 -1
  67. package/lib/ImpactCard/ImpactCard.cjs +3 -3
  68. package/lib/ImpactCard/ImpactCard.mjs +3 -3
  69. package/lib/ImpactCard/styles.css +1 -1
  70. package/lib/InformationCard/InformationCard.cjs +6 -6
  71. package/lib/InformationCard/InformationCard.mjs +6 -6
  72. package/lib/InformationCard/styles.css +1 -1
  73. package/lib/Link/Link.cjs +8 -51
  74. package/lib/Link/Link.mjs +7 -54
  75. package/lib/Link/styles.css +1 -1
  76. package/lib/Markup/styles.css +1 -1
  77. package/lib/MediaCard/MediaCard.cjs +53 -14
  78. package/lib/MediaCard/MediaCard.mjs +55 -12
  79. package/lib/MediaCard/styles.css +1 -1
  80. package/lib/Menu/Menu.cjs +1327 -25
  81. package/lib/Menu/Menu.mjs +1293 -10
  82. package/lib/Menu/styles.css +1 -1
  83. package/lib/Modal/styles.css +1 -1
  84. package/lib/NavigationHeader/NavigationHeader.cjs +854 -62
  85. package/lib/NavigationHeader/NavigationHeader.mjs +842 -50
  86. package/lib/NavigationHeader/styles.css +1 -1
  87. package/lib/Pagination/styles.css +1 -1
  88. package/lib/PaginationSimple/styles.css +1 -1
  89. package/lib/Popover/styles.css +1 -1
  90. package/lib/Poster/styles.css +1 -1
  91. package/lib/ProgressBar/styles.css +1 -1
  92. package/lib/ProgressStepper/styles.css +1 -1
  93. package/lib/ProgressStepperOverflow/ProgressStepperOverflow.cjs +138 -7
  94. package/lib/ProgressStepperOverflow/ProgressStepperOverflow.mjs +140 -5
  95. package/lib/ProgressStepperOverflow/styles.css +1 -1
  96. package/lib/RadioCardGroup/RadioCardGroup.cjs +48 -7
  97. package/lib/RadioCardGroup/RadioCardGroup.mjs +48 -8
  98. package/lib/RadioCardGroup/styles.css +1 -1
  99. package/lib/RadioGroup/RadioGroup.cjs +50 -8
  100. package/lib/RadioGroup/RadioGroup.mjs +49 -8
  101. package/lib/RadioGroup/styles.css +1 -1
  102. package/lib/Rule/styles.css +1 -1
  103. package/lib/ScrollToTop/styles.css +1 -1
  104. package/lib/Section/Section.cjs +1 -1
  105. package/lib/Section/Section.mjs +1 -1
  106. package/lib/Section/styles.css +1 -1
  107. package/lib/Select/styles.css +1 -1
  108. package/lib/SiteFooter/SiteFooter.cjs +2 -2
  109. package/lib/SiteFooter/SiteFooter.mjs +2 -2
  110. package/lib/SiteFooter/styles.css +1 -1
  111. package/lib/SiteFooterV2/SiteFooterV2.cjs +7 -6
  112. package/lib/SiteFooterV2/SiteFooterV2.mjs +7 -6
  113. package/lib/SiteFooterV2/styles.css +1 -1
  114. package/lib/SiteHeaderV2/SiteHeaderV2.cjs +440 -15
  115. package/lib/SiteHeaderV2/SiteHeaderV2.mjs +435 -11
  116. package/lib/SiteHeaderV2/styles.css +1 -1
  117. package/lib/Skeleton/styles.css +1 -1
  118. package/lib/SkipLink/styles.css +1 -1
  119. package/lib/Spinner/styles.css +1 -1
  120. package/lib/Surface/styles.css +1 -1
  121. package/lib/Switch/styles.css +1 -1
  122. package/lib/TabbedBanner/TabbedBanner.cjs +22 -35
  123. package/lib/TabbedBanner/TabbedBanner.mjs +25 -38
  124. package/lib/TabbedBanner/styles.css +1 -1
  125. package/lib/Tabs/Tabs.cjs +2 -2
  126. package/lib/Tabs/Tabs.mjs +3 -3
  127. package/lib/Tabs/styles.css +1 -1
  128. package/lib/Tag/Tag.cjs +9 -9
  129. package/lib/Tag/Tag.mjs +9 -9
  130. package/lib/Tag/styles.css +1 -1
  131. package/lib/TemplateBanner/TemplateBanner.cjs +1 -1
  132. package/lib/TemplateBanner/TemplateBanner.mjs +1 -1
  133. package/lib/TemplateBanner/styles.css +1 -1
  134. package/lib/Text/styles.css +1 -1
  135. package/lib/TextArea/TextArea.cjs +2 -53
  136. package/lib/TextArea/TextArea.mjs +2 -53
  137. package/lib/TextArea/styles.css +1 -1
  138. package/lib/TextInput/styles.css +1 -1
  139. package/lib/Theme/Theme.cjs +1 -1
  140. package/lib/Theme/Theme.mjs +1 -1
  141. package/lib/Theme/styles.css +1 -1
  142. package/lib/ThemeIcon/styles.css +1 -1
  143. package/lib/ThumbnailSignpost/styles.css +1 -1
  144. package/lib/Toast/styles.css +1 -1
  145. package/lib/Tooltip/styles.css +1 -1
  146. package/lib/Truncate/styles.css +1 -1
  147. package/lib/TypographyCard/TypographyCard.cjs +3 -3
  148. package/lib/TypographyCard/TypographyCard.mjs +3 -3
  149. package/lib/TypographyCard/styles.css +1 -1
  150. package/lib/UniversalHeader/styles.css +1 -1
  151. package/lib/VerticalSpace/styles.css +1 -1
  152. package/lib/VideoPlayer/styles.css +1 -1
  153. package/lib/Visible/styles.css +1 -1
  154. package/lib/VisuallyHidden/styles.css +1 -1
  155. package/lib/_shared/cjs/{Calendar-BcNtpbeY.cjs → Calendar-Bfdgf5q1.cjs} +1 -1
  156. package/lib/_shared/cjs/{ContentSwitcherList-NJN4H2Z-.cjs → ContentSwitcherList-pcYtuT6L.cjs} +10 -2
  157. package/lib/_shared/cjs/Link-C3OSQIIk.cjs +50 -0
  158. package/lib/_shared/cjs/{Section-wUVdzmGA.cjs → Section-Bz2fwj8Z.cjs} +2 -2
  159. package/lib/_shared/cjs/{TemplateBanner-D2y2XmR2.cjs → TemplateBanner-COymAI91.cjs} +14 -3
  160. package/lib/_shared/cjs/{arc-breakpoints--lzoExiR.cjs → arc-breakpoints-CS8JVk5T.cjs} +1 -1
  161. package/lib/_shared/cjs/{index.es-Th2hutNO.cjs → index.es-fkulh7qu.cjs} +1 -1
  162. package/lib/_shared/esm/{Calendar-ugZV8KxD.mjs → Calendar-Drh_NJ9I.mjs} +1 -1
  163. package/lib/_shared/esm/{ContentSwitcherList-BN2jzXel.mjs → ContentSwitcherList-DwHfU3no.mjs} +12 -5
  164. package/lib/_shared/esm/Link-DxjGH_7f.mjs +48 -0
  165. package/lib/_shared/esm/{Section-DDygQ5Az.mjs → Section-7InCvzfh.mjs} +2 -2
  166. package/lib/_shared/esm/{TemplateBanner-C_mDNU5j.mjs → TemplateBanner-Dkgzu3A5.mjs} +14 -3
  167. package/lib/_shared/esm/{arc-breakpoints-DnWZ2-TX.mjs → arc-breakpoints-D7Ie4kBt.mjs} +1 -1
  168. package/lib/_shared/esm/{index-BDWwJ5x2.mjs → index-BWkI4Dwz.mjs} +1 -1
  169. package/lib/_shared/esm/{index.es-Bo660IGW.mjs → index.es-CtRkzfKP.mjs} +1 -1
  170. package/lib/index.cjs +374 -272
  171. package/lib/index.cjs.map +1 -1
  172. package/lib/index.d.cts +223 -128
  173. package/lib/index.d.mts +223 -128
  174. package/lib/index.js.map +1 -1
  175. package/lib/index.mjs +375 -273
  176. package/lib/index.mjs.map +1 -1
  177. package/lib/styles.css +12 -8
  178. package/package.json +8 -8
  179. package/lib/_shared/cjs/BreadcrumbsLink-CDmk3Y3m.cjs +0 -18
  180. package/lib/_shared/cjs/Checkbox-DfZMjO1Y.cjs +0 -88
  181. package/lib/_shared/cjs/ComboBox-BGUhlqx1.cjs +0 -281
  182. package/lib/_shared/cjs/ContentSwitcherTab-B387Qs3I.cjs +0 -14
  183. package/lib/_shared/cjs/DatePicker-Bdw9VFZ4.cjs +0 -334
  184. package/lib/_shared/cjs/DrawerContent-DifTc6g9.cjs +0 -62
  185. package/lib/_shared/cjs/HeroButton-CrzkTUwP.cjs +0 -82
  186. package/lib/_shared/cjs/MediaCard-BEZFbiYO.cjs +0 -57
  187. package/lib/_shared/cjs/MenuItemMultiLevelContent-vLr6hSBm.cjs +0 -1328
  188. package/lib/_shared/cjs/ProgressStepperOverflow-BAGZNC26.cjs +0 -142
  189. package/lib/_shared/cjs/RadioCardGroupInput-CeUM3yPS.cjs +0 -53
  190. package/lib/_shared/cjs/RadioGroupInput-w2qkfsnG.cjs +0 -54
  191. package/lib/_shared/cjs/SiteHeaderV2NavItemWithSubNav-Cd0f-Yof.cjs +0 -445
  192. package/lib/_shared/cjs/kebabCase-CThj4IzG.cjs +0 -735
  193. package/lib/_shared/cjs/keynames-Cx13-hWr.cjs +0 -8
  194. package/lib/_shared/esm/BreadcrumbsLink-BxTurGNa.mjs +0 -16
  195. package/lib/_shared/esm/Checkbox-CwOHzlQF.mjs +0 -86
  196. package/lib/_shared/esm/ComboBox-CRlJjeev.mjs +0 -279
  197. package/lib/_shared/esm/ContentSwitcherTab-CfC3PGeZ.mjs +0 -12
  198. package/lib/_shared/esm/DatePicker-CCctia-s.mjs +0 -324
  199. package/lib/_shared/esm/DrawerContent-D6bAU8EQ.mjs +0 -58
  200. package/lib/_shared/esm/HeroButton-jdjjV_Gf.mjs +0 -80
  201. package/lib/_shared/esm/MediaCard-DqMaNWsE.mjs +0 -55
  202. package/lib/_shared/esm/MenuItemMultiLevelContent-JTOHqpzg.mjs +0 -1296
  203. package/lib/_shared/esm/ProgressStepperOverflow-fPkLltVO.mjs +0 -140
  204. package/lib/_shared/esm/RadioCardGroupInput-D7W28geB.mjs +0 -50
  205. package/lib/_shared/esm/RadioGroupInput-zAWSV29m.mjs +0 -50
  206. package/lib/_shared/esm/SiteHeaderV2NavItemWithSubNav-XbvJNiSo.mjs +0 -439
  207. package/lib/_shared/esm/kebabCase-CHRdSZ4y.mjs +0 -730
  208. package/lib/_shared/esm/keynames-B5whqsjh.mjs +0 -8
@@ -1,1296 +0,0 @@
1
- 'use client';
2
- import { _ as __rest, a as __assign, f as filterAttrs } from './filter-attrs-B6CM-NUr.mjs';
3
- import * as React from 'react';
4
- import React__default from 'react';
5
- import { u as useComposedRefs, P as Primitive, c as composeEventHandlers, h as hideOthers, a as useFocusGuards, F as FocusScope, D as DismissableLayer, d as composeRefs, R as ReactRemoveScroll, S as Slot, e as dispatchDiscreteCustomEvent, b as Portal$1 } from './Combination-BpO6XTeS.mjs';
6
- import { c as createContextScope, u as useControllableState, f as useCallbackRef, a as useId } from './index-Bz2JQq34.mjs';
7
- import { c as createCollection, u as useDirection } from './index-BbAu4d3T.mjs';
8
- import { c as createPopperScope, A as Anchor, C as Content, a as Arrow, R as Root2$1 } from './index-DLovItWo.mjs';
9
- import { P as Presence } from './index-DXTwueLZ.mjs';
10
- import { jsx } from 'react/jsx-runtime';
11
-
12
- var ENTRY_FOCUS = "rovingFocusGroup.onEntryFocus";
13
- var EVENT_OPTIONS = { bubbles: false, cancelable: true };
14
- var GROUP_NAME$2 = "RovingFocusGroup";
15
- var [Collection$1, useCollection$1, createCollectionScope$1] = createCollection(GROUP_NAME$2);
16
- var [createRovingFocusGroupContext, createRovingFocusGroupScope] = createContextScope(
17
- GROUP_NAME$2,
18
- [createCollectionScope$1]
19
- );
20
- var [RovingFocusProvider, useRovingFocusContext] = createRovingFocusGroupContext(GROUP_NAME$2);
21
- var RovingFocusGroup = React.forwardRef(
22
- (props, forwardedRef) => {
23
- return /* @__PURE__ */ jsx(Collection$1.Provider, { scope: props.__scopeRovingFocusGroup, children: /* @__PURE__ */ jsx(Collection$1.Slot, { scope: props.__scopeRovingFocusGroup, children: /* @__PURE__ */ jsx(RovingFocusGroupImpl, { ...props, ref: forwardedRef }) }) });
24
- }
25
- );
26
- RovingFocusGroup.displayName = GROUP_NAME$2;
27
- var RovingFocusGroupImpl = React.forwardRef((props, forwardedRef) => {
28
- const {
29
- __scopeRovingFocusGroup,
30
- orientation,
31
- loop = false,
32
- dir,
33
- currentTabStopId: currentTabStopIdProp,
34
- defaultCurrentTabStopId,
35
- onCurrentTabStopIdChange,
36
- onEntryFocus,
37
- preventScrollOnEntryFocus = false,
38
- ...groupProps
39
- } = props;
40
- const ref = React.useRef(null);
41
- const composedRefs = useComposedRefs(forwardedRef, ref);
42
- const direction = useDirection(dir);
43
- const [currentTabStopId = null, setCurrentTabStopId] = useControllableState({
44
- prop: currentTabStopIdProp,
45
- defaultProp: defaultCurrentTabStopId,
46
- onChange: onCurrentTabStopIdChange
47
- });
48
- const [isTabbingBackOut, setIsTabbingBackOut] = React.useState(false);
49
- const handleEntryFocus = useCallbackRef(onEntryFocus);
50
- const getItems = useCollection$1(__scopeRovingFocusGroup);
51
- const isClickFocusRef = React.useRef(false);
52
- const [focusableItemsCount, setFocusableItemsCount] = React.useState(0);
53
- React.useEffect(() => {
54
- const node = ref.current;
55
- if (node) {
56
- node.addEventListener(ENTRY_FOCUS, handleEntryFocus);
57
- return () => node.removeEventListener(ENTRY_FOCUS, handleEntryFocus);
58
- }
59
- }, [handleEntryFocus]);
60
- return /* @__PURE__ */ jsx(
61
- RovingFocusProvider,
62
- {
63
- scope: __scopeRovingFocusGroup,
64
- orientation,
65
- dir: direction,
66
- loop,
67
- currentTabStopId,
68
- onItemFocus: React.useCallback(
69
- (tabStopId) => setCurrentTabStopId(tabStopId),
70
- [setCurrentTabStopId]
71
- ),
72
- onItemShiftTab: React.useCallback(() => setIsTabbingBackOut(true), []),
73
- onFocusableItemAdd: React.useCallback(
74
- () => setFocusableItemsCount((prevCount) => prevCount + 1),
75
- []
76
- ),
77
- onFocusableItemRemove: React.useCallback(
78
- () => setFocusableItemsCount((prevCount) => prevCount - 1),
79
- []
80
- ),
81
- children: /* @__PURE__ */ jsx(
82
- Primitive.div,
83
- {
84
- tabIndex: isTabbingBackOut || focusableItemsCount === 0 ? -1 : 0,
85
- "data-orientation": orientation,
86
- ...groupProps,
87
- ref: composedRefs,
88
- style: { outline: "none", ...props.style },
89
- onMouseDown: composeEventHandlers(props.onMouseDown, () => {
90
- isClickFocusRef.current = true;
91
- }),
92
- onFocus: composeEventHandlers(props.onFocus, (event) => {
93
- const isKeyboardFocus = !isClickFocusRef.current;
94
- if (event.target === event.currentTarget && isKeyboardFocus && !isTabbingBackOut) {
95
- const entryFocusEvent = new CustomEvent(ENTRY_FOCUS, EVENT_OPTIONS);
96
- event.currentTarget.dispatchEvent(entryFocusEvent);
97
- if (!entryFocusEvent.defaultPrevented) {
98
- const items = getItems().filter((item) => item.focusable);
99
- const activeItem = items.find((item) => item.active);
100
- const currentItem = items.find((item) => item.id === currentTabStopId);
101
- const candidateItems = [activeItem, currentItem, ...items].filter(
102
- Boolean
103
- );
104
- const candidateNodes = candidateItems.map((item) => item.ref.current);
105
- focusFirst$1(candidateNodes, preventScrollOnEntryFocus);
106
- }
107
- }
108
- isClickFocusRef.current = false;
109
- }),
110
- onBlur: composeEventHandlers(props.onBlur, () => setIsTabbingBackOut(false))
111
- }
112
- )
113
- }
114
- );
115
- });
116
- var ITEM_NAME$2 = "RovingFocusGroupItem";
117
- var RovingFocusGroupItem = React.forwardRef(
118
- (props, forwardedRef) => {
119
- const {
120
- __scopeRovingFocusGroup,
121
- focusable = true,
122
- active = false,
123
- tabStopId,
124
- ...itemProps
125
- } = props;
126
- const autoId = useId();
127
- const id = tabStopId || autoId;
128
- const context = useRovingFocusContext(ITEM_NAME$2, __scopeRovingFocusGroup);
129
- const isCurrentTabStop = context.currentTabStopId === id;
130
- const getItems = useCollection$1(__scopeRovingFocusGroup);
131
- const { onFocusableItemAdd, onFocusableItemRemove } = context;
132
- React.useEffect(() => {
133
- if (focusable) {
134
- onFocusableItemAdd();
135
- return () => onFocusableItemRemove();
136
- }
137
- }, [focusable, onFocusableItemAdd, onFocusableItemRemove]);
138
- return /* @__PURE__ */ jsx(
139
- Collection$1.ItemSlot,
140
- {
141
- scope: __scopeRovingFocusGroup,
142
- id,
143
- focusable,
144
- active,
145
- children: /* @__PURE__ */ jsx(
146
- Primitive.span,
147
- {
148
- tabIndex: isCurrentTabStop ? 0 : -1,
149
- "data-orientation": context.orientation,
150
- ...itemProps,
151
- ref: forwardedRef,
152
- onMouseDown: composeEventHandlers(props.onMouseDown, (event) => {
153
- if (!focusable) event.preventDefault();
154
- else context.onItemFocus(id);
155
- }),
156
- onFocus: composeEventHandlers(props.onFocus, () => context.onItemFocus(id)),
157
- onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
158
- if (event.key === "Tab" && event.shiftKey) {
159
- context.onItemShiftTab();
160
- return;
161
- }
162
- if (event.target !== event.currentTarget) return;
163
- const focusIntent = getFocusIntent(event, context.orientation, context.dir);
164
- if (focusIntent !== void 0) {
165
- if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return;
166
- event.preventDefault();
167
- const items = getItems().filter((item) => item.focusable);
168
- let candidateNodes = items.map((item) => item.ref.current);
169
- if (focusIntent === "last") candidateNodes.reverse();
170
- else if (focusIntent === "prev" || focusIntent === "next") {
171
- if (focusIntent === "prev") candidateNodes.reverse();
172
- const currentIndex = candidateNodes.indexOf(event.currentTarget);
173
- candidateNodes = context.loop ? wrapArray$1(candidateNodes, currentIndex + 1) : candidateNodes.slice(currentIndex + 1);
174
- }
175
- setTimeout(() => focusFirst$1(candidateNodes));
176
- }
177
- })
178
- }
179
- )
180
- }
181
- );
182
- }
183
- );
184
- RovingFocusGroupItem.displayName = ITEM_NAME$2;
185
- var MAP_KEY_TO_FOCUS_INTENT = {
186
- ArrowLeft: "prev",
187
- ArrowUp: "prev",
188
- ArrowRight: "next",
189
- ArrowDown: "next",
190
- PageUp: "first",
191
- Home: "first",
192
- PageDown: "last",
193
- End: "last"
194
- };
195
- function getDirectionAwareKey(key, dir) {
196
- if (dir !== "rtl") return key;
197
- return key === "ArrowLeft" ? "ArrowRight" : key === "ArrowRight" ? "ArrowLeft" : key;
198
- }
199
- function getFocusIntent(event, orientation, dir) {
200
- const key = getDirectionAwareKey(event.key, dir);
201
- if (orientation === "vertical" && ["ArrowLeft", "ArrowRight"].includes(key)) return void 0;
202
- if (orientation === "horizontal" && ["ArrowUp", "ArrowDown"].includes(key)) return void 0;
203
- return MAP_KEY_TO_FOCUS_INTENT[key];
204
- }
205
- function focusFirst$1(candidates, preventScroll = false) {
206
- const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
207
- for (const candidate of candidates) {
208
- if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
209
- candidate.focus({ preventScroll });
210
- if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
211
- }
212
- }
213
- function wrapArray$1(array, startIndex) {
214
- return array.map((_, index) => array[(startIndex + index) % array.length]);
215
- }
216
- var Root = RovingFocusGroup;
217
- var Item = RovingFocusGroupItem;
218
-
219
- var SELECTION_KEYS = ["Enter", " "];
220
- var FIRST_KEYS = ["ArrowDown", "PageUp", "Home"];
221
- var LAST_KEYS = ["ArrowUp", "PageDown", "End"];
222
- var FIRST_LAST_KEYS = [...FIRST_KEYS, ...LAST_KEYS];
223
- var SUB_OPEN_KEYS = {
224
- ltr: [...SELECTION_KEYS, "ArrowRight"],
225
- rtl: [...SELECTION_KEYS, "ArrowLeft"]
226
- };
227
- var SUB_CLOSE_KEYS = {
228
- ltr: ["ArrowLeft"],
229
- rtl: ["ArrowRight"]
230
- };
231
- var MENU_NAME = "Menu";
232
- var [Collection, useCollection, createCollectionScope] = createCollection(MENU_NAME);
233
- var [createMenuContext, createMenuScope] = createContextScope(MENU_NAME, [
234
- createCollectionScope,
235
- createPopperScope,
236
- createRovingFocusGroupScope
237
- ]);
238
- var usePopperScope = createPopperScope();
239
- var useRovingFocusGroupScope = createRovingFocusGroupScope();
240
- var [MenuProvider, useMenuContext] = createMenuContext(MENU_NAME);
241
- var [MenuRootProvider, useMenuRootContext] = createMenuContext(MENU_NAME);
242
- var Menu = (props) => {
243
- const { __scopeMenu, open = false, children, dir, onOpenChange, modal = true } = props;
244
- const popperScope = usePopperScope(__scopeMenu);
245
- const [content, setContent] = React.useState(null);
246
- const isUsingKeyboardRef = React.useRef(false);
247
- const handleOpenChange = useCallbackRef(onOpenChange);
248
- const direction = useDirection(dir);
249
- React.useEffect(() => {
250
- const handleKeyDown = () => {
251
- isUsingKeyboardRef.current = true;
252
- document.addEventListener("pointerdown", handlePointer, { capture: true, once: true });
253
- document.addEventListener("pointermove", handlePointer, { capture: true, once: true });
254
- };
255
- const handlePointer = () => isUsingKeyboardRef.current = false;
256
- document.addEventListener("keydown", handleKeyDown, { capture: true });
257
- return () => {
258
- document.removeEventListener("keydown", handleKeyDown, { capture: true });
259
- document.removeEventListener("pointerdown", handlePointer, { capture: true });
260
- document.removeEventListener("pointermove", handlePointer, { capture: true });
261
- };
262
- }, []);
263
- return /* @__PURE__ */ jsx(Root2$1, { ...popperScope, children: /* @__PURE__ */ jsx(
264
- MenuProvider,
265
- {
266
- scope: __scopeMenu,
267
- open,
268
- onOpenChange: handleOpenChange,
269
- content,
270
- onContentChange: setContent,
271
- children: /* @__PURE__ */ jsx(
272
- MenuRootProvider,
273
- {
274
- scope: __scopeMenu,
275
- onClose: React.useCallback(() => handleOpenChange(false), [handleOpenChange]),
276
- isUsingKeyboardRef,
277
- dir: direction,
278
- modal,
279
- children
280
- }
281
- )
282
- }
283
- ) });
284
- };
285
- Menu.displayName = MENU_NAME;
286
- var ANCHOR_NAME = "MenuAnchor";
287
- var MenuAnchor = React.forwardRef(
288
- (props, forwardedRef) => {
289
- const { __scopeMenu, ...anchorProps } = props;
290
- const popperScope = usePopperScope(__scopeMenu);
291
- return /* @__PURE__ */ jsx(Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
292
- }
293
- );
294
- MenuAnchor.displayName = ANCHOR_NAME;
295
- var PORTAL_NAME$1 = "MenuPortal";
296
- var [PortalProvider, usePortalContext] = createMenuContext(PORTAL_NAME$1, {
297
- forceMount: void 0
298
- });
299
- var MenuPortal = (props) => {
300
- const { __scopeMenu, forceMount, children, container } = props;
301
- const context = useMenuContext(PORTAL_NAME$1, __scopeMenu);
302
- return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopeMenu, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Portal$1, { asChild: true, container, children }) }) });
303
- };
304
- MenuPortal.displayName = PORTAL_NAME$1;
305
- var CONTENT_NAME$1 = "MenuContent";
306
- var [MenuContentProvider, useMenuContentContext] = createMenuContext(CONTENT_NAME$1);
307
- var MenuContent$1 = React.forwardRef(
308
- (props, forwardedRef) => {
309
- const portalContext = usePortalContext(CONTENT_NAME$1, props.__scopeMenu);
310
- const { forceMount = portalContext.forceMount, ...contentProps } = props;
311
- const context = useMenuContext(CONTENT_NAME$1, props.__scopeMenu);
312
- const rootContext = useMenuRootContext(CONTENT_NAME$1, props.__scopeMenu);
313
- return /* @__PURE__ */ jsx(Collection.Provider, { scope: props.__scopeMenu, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Collection.Slot, { scope: props.__scopeMenu, children: rootContext.modal ? /* @__PURE__ */ jsx(MenuRootContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(MenuRootContentNonModal, { ...contentProps, ref: forwardedRef }) }) }) });
314
- }
315
- );
316
- var MenuRootContentModal = React.forwardRef(
317
- (props, forwardedRef) => {
318
- const context = useMenuContext(CONTENT_NAME$1, props.__scopeMenu);
319
- const ref = React.useRef(null);
320
- const composedRefs = useComposedRefs(forwardedRef, ref);
321
- React.useEffect(() => {
322
- const content = ref.current;
323
- if (content) return hideOthers(content);
324
- }, []);
325
- return /* @__PURE__ */ jsx(
326
- MenuContentImpl,
327
- {
328
- ...props,
329
- ref: composedRefs,
330
- trapFocus: context.open,
331
- disableOutsidePointerEvents: context.open,
332
- disableOutsideScroll: true,
333
- onFocusOutside: composeEventHandlers(
334
- props.onFocusOutside,
335
- (event) => event.preventDefault(),
336
- { checkForDefaultPrevented: false }
337
- ),
338
- onDismiss: () => context.onOpenChange(false)
339
- }
340
- );
341
- }
342
- );
343
- var MenuRootContentNonModal = React.forwardRef((props, forwardedRef) => {
344
- const context = useMenuContext(CONTENT_NAME$1, props.__scopeMenu);
345
- return /* @__PURE__ */ jsx(
346
- MenuContentImpl,
347
- {
348
- ...props,
349
- ref: forwardedRef,
350
- trapFocus: false,
351
- disableOutsidePointerEvents: false,
352
- disableOutsideScroll: false,
353
- onDismiss: () => context.onOpenChange(false)
354
- }
355
- );
356
- });
357
- var MenuContentImpl = React.forwardRef(
358
- (props, forwardedRef) => {
359
- const {
360
- __scopeMenu,
361
- loop = false,
362
- trapFocus,
363
- onOpenAutoFocus,
364
- onCloseAutoFocus,
365
- disableOutsidePointerEvents,
366
- onEntryFocus,
367
- onEscapeKeyDown,
368
- onPointerDownOutside,
369
- onFocusOutside,
370
- onInteractOutside,
371
- onDismiss,
372
- disableOutsideScroll,
373
- ...contentProps
374
- } = props;
375
- const context = useMenuContext(CONTENT_NAME$1, __scopeMenu);
376
- const rootContext = useMenuRootContext(CONTENT_NAME$1, __scopeMenu);
377
- const popperScope = usePopperScope(__scopeMenu);
378
- const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
379
- const getItems = useCollection(__scopeMenu);
380
- const [currentItemId, setCurrentItemId] = React.useState(null);
381
- const contentRef = React.useRef(null);
382
- const composedRefs = useComposedRefs(forwardedRef, contentRef, context.onContentChange);
383
- const timerRef = React.useRef(0);
384
- const searchRef = React.useRef("");
385
- const pointerGraceTimerRef = React.useRef(0);
386
- const pointerGraceIntentRef = React.useRef(null);
387
- const pointerDirRef = React.useRef("right");
388
- const lastPointerXRef = React.useRef(0);
389
- const ScrollLockWrapper = disableOutsideScroll ? ReactRemoveScroll : React.Fragment;
390
- const scrollLockWrapperProps = disableOutsideScroll ? { as: Slot, allowPinchZoom: true } : void 0;
391
- const handleTypeaheadSearch = (key) => {
392
- const search = searchRef.current + key;
393
- const items = getItems().filter((item) => !item.disabled);
394
- const currentItem = document.activeElement;
395
- const currentMatch = items.find((item) => item.ref.current === currentItem)?.textValue;
396
- const values = items.map((item) => item.textValue);
397
- const nextMatch = getNextMatch(values, search, currentMatch);
398
- const newItem = items.find((item) => item.textValue === nextMatch)?.ref.current;
399
- (function updateSearch(value) {
400
- searchRef.current = value;
401
- window.clearTimeout(timerRef.current);
402
- if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
403
- })(search);
404
- if (newItem) {
405
- setTimeout(() => newItem.focus());
406
- }
407
- };
408
- React.useEffect(() => {
409
- return () => window.clearTimeout(timerRef.current);
410
- }, []);
411
- useFocusGuards();
412
- const isPointerMovingToSubmenu = React.useCallback((event) => {
413
- const isMovingTowards = pointerDirRef.current === pointerGraceIntentRef.current?.side;
414
- return isMovingTowards && isPointerInGraceArea(event, pointerGraceIntentRef.current?.area);
415
- }, []);
416
- return /* @__PURE__ */ jsx(
417
- MenuContentProvider,
418
- {
419
- scope: __scopeMenu,
420
- searchRef,
421
- onItemEnter: React.useCallback(
422
- (event) => {
423
- if (isPointerMovingToSubmenu(event)) event.preventDefault();
424
- },
425
- [isPointerMovingToSubmenu]
426
- ),
427
- onItemLeave: React.useCallback(
428
- (event) => {
429
- if (isPointerMovingToSubmenu(event)) return;
430
- contentRef.current?.focus();
431
- setCurrentItemId(null);
432
- },
433
- [isPointerMovingToSubmenu]
434
- ),
435
- onTriggerLeave: React.useCallback(
436
- (event) => {
437
- if (isPointerMovingToSubmenu(event)) event.preventDefault();
438
- },
439
- [isPointerMovingToSubmenu]
440
- ),
441
- pointerGraceTimerRef,
442
- onPointerGraceIntentChange: React.useCallback((intent) => {
443
- pointerGraceIntentRef.current = intent;
444
- }, []),
445
- children: /* @__PURE__ */ jsx(ScrollLockWrapper, { ...scrollLockWrapperProps, children: /* @__PURE__ */ jsx(
446
- FocusScope,
447
- {
448
- asChild: true,
449
- trapped: trapFocus,
450
- onMountAutoFocus: composeEventHandlers(onOpenAutoFocus, (event) => {
451
- event.preventDefault();
452
- contentRef.current?.focus({ preventScroll: true });
453
- }),
454
- onUnmountAutoFocus: onCloseAutoFocus,
455
- children: /* @__PURE__ */ jsx(
456
- DismissableLayer,
457
- {
458
- asChild: true,
459
- disableOutsidePointerEvents,
460
- onEscapeKeyDown,
461
- onPointerDownOutside,
462
- onFocusOutside,
463
- onInteractOutside,
464
- onDismiss,
465
- children: /* @__PURE__ */ jsx(
466
- Root,
467
- {
468
- asChild: true,
469
- ...rovingFocusGroupScope,
470
- dir: rootContext.dir,
471
- orientation: "vertical",
472
- loop,
473
- currentTabStopId: currentItemId,
474
- onCurrentTabStopIdChange: setCurrentItemId,
475
- onEntryFocus: composeEventHandlers(onEntryFocus, (event) => {
476
- if (!rootContext.isUsingKeyboardRef.current) event.preventDefault();
477
- }),
478
- preventScrollOnEntryFocus: true,
479
- children: /* @__PURE__ */ jsx(
480
- Content,
481
- {
482
- role: "menu",
483
- "aria-orientation": "vertical",
484
- "data-state": getOpenState(context.open),
485
- "data-radix-menu-content": "",
486
- dir: rootContext.dir,
487
- ...popperScope,
488
- ...contentProps,
489
- ref: composedRefs,
490
- style: { outline: "none", ...contentProps.style },
491
- onKeyDown: composeEventHandlers(contentProps.onKeyDown, (event) => {
492
- const target = event.target;
493
- const isKeyDownInside = target.closest("[data-radix-menu-content]") === event.currentTarget;
494
- const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
495
- const isCharacterKey = event.key.length === 1;
496
- if (isKeyDownInside) {
497
- if (event.key === "Tab") event.preventDefault();
498
- if (!isModifierKey && isCharacterKey) handleTypeaheadSearch(event.key);
499
- }
500
- const content = contentRef.current;
501
- if (event.target !== content) return;
502
- if (!FIRST_LAST_KEYS.includes(event.key)) return;
503
- event.preventDefault();
504
- const items = getItems().filter((item) => !item.disabled);
505
- const candidateNodes = items.map((item) => item.ref.current);
506
- if (LAST_KEYS.includes(event.key)) candidateNodes.reverse();
507
- focusFirst(candidateNodes);
508
- }),
509
- onBlur: composeEventHandlers(props.onBlur, (event) => {
510
- if (!event.currentTarget.contains(event.target)) {
511
- window.clearTimeout(timerRef.current);
512
- searchRef.current = "";
513
- }
514
- }),
515
- onPointerMove: composeEventHandlers(
516
- props.onPointerMove,
517
- whenMouse((event) => {
518
- const target = event.target;
519
- const pointerXHasChanged = lastPointerXRef.current !== event.clientX;
520
- if (event.currentTarget.contains(target) && pointerXHasChanged) {
521
- const newDir = event.clientX > lastPointerXRef.current ? "right" : "left";
522
- pointerDirRef.current = newDir;
523
- lastPointerXRef.current = event.clientX;
524
- }
525
- })
526
- )
527
- }
528
- )
529
- }
530
- )
531
- }
532
- )
533
- }
534
- ) })
535
- }
536
- );
537
- }
538
- );
539
- MenuContent$1.displayName = CONTENT_NAME$1;
540
- var GROUP_NAME$1 = "MenuGroup";
541
- var MenuGroup = React.forwardRef(
542
- (props, forwardedRef) => {
543
- const { __scopeMenu, ...groupProps } = props;
544
- return /* @__PURE__ */ jsx(Primitive.div, { role: "group", ...groupProps, ref: forwardedRef });
545
- }
546
- );
547
- MenuGroup.displayName = GROUP_NAME$1;
548
- var LABEL_NAME$1 = "MenuLabel";
549
- var MenuLabel = React.forwardRef(
550
- (props, forwardedRef) => {
551
- const { __scopeMenu, ...labelProps } = props;
552
- return /* @__PURE__ */ jsx(Primitive.div, { ...labelProps, ref: forwardedRef });
553
- }
554
- );
555
- MenuLabel.displayName = LABEL_NAME$1;
556
- var ITEM_NAME$1 = "MenuItem";
557
- var ITEM_SELECT = "menu.itemSelect";
558
- var MenuItem = React.forwardRef(
559
- (props, forwardedRef) => {
560
- const { disabled = false, onSelect, ...itemProps } = props;
561
- const ref = React.useRef(null);
562
- const rootContext = useMenuRootContext(ITEM_NAME$1, props.__scopeMenu);
563
- const contentContext = useMenuContentContext(ITEM_NAME$1, props.__scopeMenu);
564
- const composedRefs = useComposedRefs(forwardedRef, ref);
565
- const isPointerDownRef = React.useRef(false);
566
- const handleSelect = () => {
567
- const menuItem = ref.current;
568
- if (!disabled && menuItem) {
569
- const itemSelectEvent = new CustomEvent(ITEM_SELECT, { bubbles: true, cancelable: true });
570
- menuItem.addEventListener(ITEM_SELECT, (event) => onSelect?.(event), { once: true });
571
- dispatchDiscreteCustomEvent(menuItem, itemSelectEvent);
572
- if (itemSelectEvent.defaultPrevented) {
573
- isPointerDownRef.current = false;
574
- } else {
575
- rootContext.onClose();
576
- }
577
- }
578
- };
579
- return /* @__PURE__ */ jsx(
580
- MenuItemImpl,
581
- {
582
- ...itemProps,
583
- ref: composedRefs,
584
- disabled,
585
- onClick: composeEventHandlers(props.onClick, handleSelect),
586
- onPointerDown: (event) => {
587
- props.onPointerDown?.(event);
588
- isPointerDownRef.current = true;
589
- },
590
- onPointerUp: composeEventHandlers(props.onPointerUp, (event) => {
591
- if (!isPointerDownRef.current) event.currentTarget?.click();
592
- }),
593
- onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
594
- const isTypingAhead = contentContext.searchRef.current !== "";
595
- if (disabled || isTypingAhead && event.key === " ") return;
596
- if (SELECTION_KEYS.includes(event.key)) {
597
- event.currentTarget.click();
598
- event.preventDefault();
599
- }
600
- })
601
- }
602
- );
603
- }
604
- );
605
- MenuItem.displayName = ITEM_NAME$1;
606
- var MenuItemImpl = React.forwardRef(
607
- (props, forwardedRef) => {
608
- const { __scopeMenu, disabled = false, textValue, ...itemProps } = props;
609
- const contentContext = useMenuContentContext(ITEM_NAME$1, __scopeMenu);
610
- const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
611
- const ref = React.useRef(null);
612
- const composedRefs = useComposedRefs(forwardedRef, ref);
613
- const [isFocused, setIsFocused] = React.useState(false);
614
- const [textContent, setTextContent] = React.useState("");
615
- React.useEffect(() => {
616
- const menuItem = ref.current;
617
- if (menuItem) {
618
- setTextContent((menuItem.textContent ?? "").trim());
619
- }
620
- }, [itemProps.children]);
621
- return /* @__PURE__ */ jsx(
622
- Collection.ItemSlot,
623
- {
624
- scope: __scopeMenu,
625
- disabled,
626
- textValue: textValue ?? textContent,
627
- children: /* @__PURE__ */ jsx(Item, { asChild: true, ...rovingFocusGroupScope, focusable: !disabled, children: /* @__PURE__ */ jsx(
628
- Primitive.div,
629
- {
630
- role: "menuitem",
631
- "data-highlighted": isFocused ? "" : void 0,
632
- "aria-disabled": disabled || void 0,
633
- "data-disabled": disabled ? "" : void 0,
634
- ...itemProps,
635
- ref: composedRefs,
636
- onPointerMove: composeEventHandlers(
637
- props.onPointerMove,
638
- whenMouse((event) => {
639
- if (disabled) {
640
- contentContext.onItemLeave(event);
641
- } else {
642
- contentContext.onItemEnter(event);
643
- if (!event.defaultPrevented) {
644
- const item = event.currentTarget;
645
- item.focus({ preventScroll: true });
646
- }
647
- }
648
- })
649
- ),
650
- onPointerLeave: composeEventHandlers(
651
- props.onPointerLeave,
652
- whenMouse((event) => contentContext.onItemLeave(event))
653
- ),
654
- onFocus: composeEventHandlers(props.onFocus, () => setIsFocused(true)),
655
- onBlur: composeEventHandlers(props.onBlur, () => setIsFocused(false))
656
- }
657
- ) })
658
- }
659
- );
660
- }
661
- );
662
- var CHECKBOX_ITEM_NAME$1 = "MenuCheckboxItem";
663
- var MenuCheckboxItem = React.forwardRef(
664
- (props, forwardedRef) => {
665
- const { checked = false, onCheckedChange, ...checkboxItemProps } = props;
666
- return /* @__PURE__ */ jsx(ItemIndicatorProvider, { scope: props.__scopeMenu, checked, children: /* @__PURE__ */ jsx(
667
- MenuItem,
668
- {
669
- role: "menuitemcheckbox",
670
- "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
671
- ...checkboxItemProps,
672
- ref: forwardedRef,
673
- "data-state": getCheckedState(checked),
674
- onSelect: composeEventHandlers(
675
- checkboxItemProps.onSelect,
676
- () => onCheckedChange?.(isIndeterminate(checked) ? true : !checked),
677
- { checkForDefaultPrevented: false }
678
- )
679
- }
680
- ) });
681
- }
682
- );
683
- MenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME$1;
684
- var RADIO_GROUP_NAME$1 = "MenuRadioGroup";
685
- var [RadioGroupProvider, useRadioGroupContext] = createMenuContext(
686
- RADIO_GROUP_NAME$1,
687
- { value: void 0, onValueChange: () => {
688
- } }
689
- );
690
- var MenuRadioGroup = React.forwardRef(
691
- (props, forwardedRef) => {
692
- const { value, onValueChange, ...groupProps } = props;
693
- const handleValueChange = useCallbackRef(onValueChange);
694
- return /* @__PURE__ */ jsx(RadioGroupProvider, { scope: props.__scopeMenu, value, onValueChange: handleValueChange, children: /* @__PURE__ */ jsx(MenuGroup, { ...groupProps, ref: forwardedRef }) });
695
- }
696
- );
697
- MenuRadioGroup.displayName = RADIO_GROUP_NAME$1;
698
- var RADIO_ITEM_NAME$1 = "MenuRadioItem";
699
- var MenuRadioItem = React.forwardRef(
700
- (props, forwardedRef) => {
701
- const { value, ...radioItemProps } = props;
702
- const context = useRadioGroupContext(RADIO_ITEM_NAME$1, props.__scopeMenu);
703
- const checked = value === context.value;
704
- return /* @__PURE__ */ jsx(ItemIndicatorProvider, { scope: props.__scopeMenu, checked, children: /* @__PURE__ */ jsx(
705
- MenuItem,
706
- {
707
- role: "menuitemradio",
708
- "aria-checked": checked,
709
- ...radioItemProps,
710
- ref: forwardedRef,
711
- "data-state": getCheckedState(checked),
712
- onSelect: composeEventHandlers(
713
- radioItemProps.onSelect,
714
- () => context.onValueChange?.(value),
715
- { checkForDefaultPrevented: false }
716
- )
717
- }
718
- ) });
719
- }
720
- );
721
- MenuRadioItem.displayName = RADIO_ITEM_NAME$1;
722
- var ITEM_INDICATOR_NAME = "MenuItemIndicator";
723
- var [ItemIndicatorProvider, useItemIndicatorContext] = createMenuContext(
724
- ITEM_INDICATOR_NAME,
725
- { checked: false }
726
- );
727
- var MenuItemIndicator = React.forwardRef(
728
- (props, forwardedRef) => {
729
- const { __scopeMenu, forceMount, ...itemIndicatorProps } = props;
730
- const indicatorContext = useItemIndicatorContext(ITEM_INDICATOR_NAME, __scopeMenu);
731
- return /* @__PURE__ */ jsx(
732
- Presence,
733
- {
734
- present: forceMount || isIndeterminate(indicatorContext.checked) || indicatorContext.checked === true,
735
- children: /* @__PURE__ */ jsx(
736
- Primitive.span,
737
- {
738
- ...itemIndicatorProps,
739
- ref: forwardedRef,
740
- "data-state": getCheckedState(indicatorContext.checked)
741
- }
742
- )
743
- }
744
- );
745
- }
746
- );
747
- MenuItemIndicator.displayName = ITEM_INDICATOR_NAME;
748
- var SEPARATOR_NAME$1 = "MenuSeparator";
749
- var MenuSeparator = React.forwardRef(
750
- (props, forwardedRef) => {
751
- const { __scopeMenu, ...separatorProps } = props;
752
- return /* @__PURE__ */ jsx(
753
- Primitive.div,
754
- {
755
- role: "separator",
756
- "aria-orientation": "horizontal",
757
- ...separatorProps,
758
- ref: forwardedRef
759
- }
760
- );
761
- }
762
- );
763
- MenuSeparator.displayName = SEPARATOR_NAME$1;
764
- var ARROW_NAME$1 = "MenuArrow";
765
- var MenuArrow = React.forwardRef(
766
- (props, forwardedRef) => {
767
- const { __scopeMenu, ...arrowProps } = props;
768
- const popperScope = usePopperScope(__scopeMenu);
769
- return /* @__PURE__ */ jsx(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
770
- }
771
- );
772
- MenuArrow.displayName = ARROW_NAME$1;
773
- var SUB_NAME = "MenuSub";
774
- var [MenuSubProvider, useMenuSubContext] = createMenuContext(SUB_NAME);
775
- var MenuSub = (props) => {
776
- const { __scopeMenu, children, open = false, onOpenChange } = props;
777
- const parentMenuContext = useMenuContext(SUB_NAME, __scopeMenu);
778
- const popperScope = usePopperScope(__scopeMenu);
779
- const [trigger, setTrigger] = React.useState(null);
780
- const [content, setContent] = React.useState(null);
781
- const handleOpenChange = useCallbackRef(onOpenChange);
782
- React.useEffect(() => {
783
- if (parentMenuContext.open === false) handleOpenChange(false);
784
- return () => handleOpenChange(false);
785
- }, [parentMenuContext.open, handleOpenChange]);
786
- return /* @__PURE__ */ jsx(Root2$1, { ...popperScope, children: /* @__PURE__ */ jsx(
787
- MenuProvider,
788
- {
789
- scope: __scopeMenu,
790
- open,
791
- onOpenChange: handleOpenChange,
792
- content,
793
- onContentChange: setContent,
794
- children: /* @__PURE__ */ jsx(
795
- MenuSubProvider,
796
- {
797
- scope: __scopeMenu,
798
- contentId: useId(),
799
- triggerId: useId(),
800
- trigger,
801
- onTriggerChange: setTrigger,
802
- children
803
- }
804
- )
805
- }
806
- ) });
807
- };
808
- MenuSub.displayName = SUB_NAME;
809
- var SUB_TRIGGER_NAME$1 = "MenuSubTrigger";
810
- var MenuSubTrigger = React.forwardRef(
811
- (props, forwardedRef) => {
812
- const context = useMenuContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
813
- const rootContext = useMenuRootContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
814
- const subContext = useMenuSubContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
815
- const contentContext = useMenuContentContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
816
- const openTimerRef = React.useRef(null);
817
- const { pointerGraceTimerRef, onPointerGraceIntentChange } = contentContext;
818
- const scope = { __scopeMenu: props.__scopeMenu };
819
- const clearOpenTimer = React.useCallback(() => {
820
- if (openTimerRef.current) window.clearTimeout(openTimerRef.current);
821
- openTimerRef.current = null;
822
- }, []);
823
- React.useEffect(() => clearOpenTimer, [clearOpenTimer]);
824
- React.useEffect(() => {
825
- const pointerGraceTimer = pointerGraceTimerRef.current;
826
- return () => {
827
- window.clearTimeout(pointerGraceTimer);
828
- onPointerGraceIntentChange(null);
829
- };
830
- }, [pointerGraceTimerRef, onPointerGraceIntentChange]);
831
- return /* @__PURE__ */ jsx(MenuAnchor, { asChild: true, ...scope, children: /* @__PURE__ */ jsx(
832
- MenuItemImpl,
833
- {
834
- id: subContext.triggerId,
835
- "aria-haspopup": "menu",
836
- "aria-expanded": context.open,
837
- "aria-controls": subContext.contentId,
838
- "data-state": getOpenState(context.open),
839
- ...props,
840
- ref: composeRefs(forwardedRef, subContext.onTriggerChange),
841
- onClick: (event) => {
842
- props.onClick?.(event);
843
- if (props.disabled || event.defaultPrevented) return;
844
- event.currentTarget.focus();
845
- if (!context.open) context.onOpenChange(true);
846
- },
847
- onPointerMove: composeEventHandlers(
848
- props.onPointerMove,
849
- whenMouse((event) => {
850
- contentContext.onItemEnter(event);
851
- if (event.defaultPrevented) return;
852
- if (!props.disabled && !context.open && !openTimerRef.current) {
853
- contentContext.onPointerGraceIntentChange(null);
854
- openTimerRef.current = window.setTimeout(() => {
855
- context.onOpenChange(true);
856
- clearOpenTimer();
857
- }, 100);
858
- }
859
- })
860
- ),
861
- onPointerLeave: composeEventHandlers(
862
- props.onPointerLeave,
863
- whenMouse((event) => {
864
- clearOpenTimer();
865
- const contentRect = context.content?.getBoundingClientRect();
866
- if (contentRect) {
867
- const side = context.content?.dataset.side;
868
- const rightSide = side === "right";
869
- const bleed = rightSide ? -5 : 5;
870
- const contentNearEdge = contentRect[rightSide ? "left" : "right"];
871
- const contentFarEdge = contentRect[rightSide ? "right" : "left"];
872
- contentContext.onPointerGraceIntentChange({
873
- area: [
874
- // Apply a bleed on clientX to ensure that our exit point is
875
- // consistently within polygon bounds
876
- { x: event.clientX + bleed, y: event.clientY },
877
- { x: contentNearEdge, y: contentRect.top },
878
- { x: contentFarEdge, y: contentRect.top },
879
- { x: contentFarEdge, y: contentRect.bottom },
880
- { x: contentNearEdge, y: contentRect.bottom }
881
- ],
882
- side
883
- });
884
- window.clearTimeout(pointerGraceTimerRef.current);
885
- pointerGraceTimerRef.current = window.setTimeout(
886
- () => contentContext.onPointerGraceIntentChange(null),
887
- 300
888
- );
889
- } else {
890
- contentContext.onTriggerLeave(event);
891
- if (event.defaultPrevented) return;
892
- contentContext.onPointerGraceIntentChange(null);
893
- }
894
- })
895
- ),
896
- onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
897
- const isTypingAhead = contentContext.searchRef.current !== "";
898
- if (props.disabled || isTypingAhead && event.key === " ") return;
899
- if (SUB_OPEN_KEYS[rootContext.dir].includes(event.key)) {
900
- context.onOpenChange(true);
901
- context.content?.focus();
902
- event.preventDefault();
903
- }
904
- })
905
- }
906
- ) });
907
- }
908
- );
909
- MenuSubTrigger.displayName = SUB_TRIGGER_NAME$1;
910
- var SUB_CONTENT_NAME$1 = "MenuSubContent";
911
- var MenuSubContent = React.forwardRef(
912
- (props, forwardedRef) => {
913
- const portalContext = usePortalContext(CONTENT_NAME$1, props.__scopeMenu);
914
- const { forceMount = portalContext.forceMount, ...subContentProps } = props;
915
- const context = useMenuContext(CONTENT_NAME$1, props.__scopeMenu);
916
- const rootContext = useMenuRootContext(CONTENT_NAME$1, props.__scopeMenu);
917
- const subContext = useMenuSubContext(SUB_CONTENT_NAME$1, props.__scopeMenu);
918
- const ref = React.useRef(null);
919
- const composedRefs = useComposedRefs(forwardedRef, ref);
920
- return /* @__PURE__ */ jsx(Collection.Provider, { scope: props.__scopeMenu, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Collection.Slot, { scope: props.__scopeMenu, children: /* @__PURE__ */ jsx(
921
- MenuContentImpl,
922
- {
923
- id: subContext.contentId,
924
- "aria-labelledby": subContext.triggerId,
925
- ...subContentProps,
926
- ref: composedRefs,
927
- align: "start",
928
- side: rootContext.dir === "rtl" ? "left" : "right",
929
- disableOutsidePointerEvents: false,
930
- disableOutsideScroll: false,
931
- trapFocus: false,
932
- onOpenAutoFocus: (event) => {
933
- if (rootContext.isUsingKeyboardRef.current) ref.current?.focus();
934
- event.preventDefault();
935
- },
936
- onCloseAutoFocus: (event) => event.preventDefault(),
937
- onFocusOutside: composeEventHandlers(props.onFocusOutside, (event) => {
938
- if (event.target !== subContext.trigger) context.onOpenChange(false);
939
- }),
940
- onEscapeKeyDown: composeEventHandlers(props.onEscapeKeyDown, (event) => {
941
- rootContext.onClose();
942
- event.preventDefault();
943
- }),
944
- onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
945
- const isKeyDownInside = event.currentTarget.contains(event.target);
946
- const isCloseKey = SUB_CLOSE_KEYS[rootContext.dir].includes(event.key);
947
- if (isKeyDownInside && isCloseKey) {
948
- context.onOpenChange(false);
949
- subContext.trigger?.focus();
950
- event.preventDefault();
951
- }
952
- })
953
- }
954
- ) }) }) });
955
- }
956
- );
957
- MenuSubContent.displayName = SUB_CONTENT_NAME$1;
958
- function getOpenState(open) {
959
- return open ? "open" : "closed";
960
- }
961
- function isIndeterminate(checked) {
962
- return checked === "indeterminate";
963
- }
964
- function getCheckedState(checked) {
965
- return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
966
- }
967
- function focusFirst(candidates) {
968
- const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
969
- for (const candidate of candidates) {
970
- if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
971
- candidate.focus();
972
- if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
973
- }
974
- }
975
- function wrapArray(array, startIndex) {
976
- return array.map((_, index) => array[(startIndex + index) % array.length]);
977
- }
978
- function getNextMatch(values, search, currentMatch) {
979
- const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
980
- const normalizedSearch = isRepeated ? search[0] : search;
981
- const currentMatchIndex = currentMatch ? values.indexOf(currentMatch) : -1;
982
- let wrappedValues = wrapArray(values, Math.max(currentMatchIndex, 0));
983
- const excludeCurrentMatch = normalizedSearch.length === 1;
984
- if (excludeCurrentMatch) wrappedValues = wrappedValues.filter((v) => v !== currentMatch);
985
- const nextMatch = wrappedValues.find(
986
- (value) => value.toLowerCase().startsWith(normalizedSearch.toLowerCase())
987
- );
988
- return nextMatch !== currentMatch ? nextMatch : void 0;
989
- }
990
- function isPointInPolygon(point, polygon) {
991
- const { x, y } = point;
992
- let inside = false;
993
- for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
994
- const xi = polygon[i].x;
995
- const yi = polygon[i].y;
996
- const xj = polygon[j].x;
997
- const yj = polygon[j].y;
998
- const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
999
- if (intersect) inside = !inside;
1000
- }
1001
- return inside;
1002
- }
1003
- function isPointerInGraceArea(event, area) {
1004
- if (!area) return false;
1005
- const cursorPos = { x: event.clientX, y: event.clientY };
1006
- return isPointInPolygon(cursorPos, area);
1007
- }
1008
- function whenMouse(handler) {
1009
- return (event) => event.pointerType === "mouse" ? handler(event) : void 0;
1010
- }
1011
- var Root3 = Menu;
1012
- var Anchor2 = MenuAnchor;
1013
- var Portal = MenuPortal;
1014
- var Content2$1 = MenuContent$1;
1015
- var Group = MenuGroup;
1016
- var Label = MenuLabel;
1017
- var Item2$1 = MenuItem;
1018
- var CheckboxItem = MenuCheckboxItem;
1019
- var RadioGroup = MenuRadioGroup;
1020
- var RadioItem = MenuRadioItem;
1021
- var ItemIndicator = MenuItemIndicator;
1022
- var Separator = MenuSeparator;
1023
- var Arrow2 = MenuArrow;
1024
- var Sub = MenuSub;
1025
- var SubTrigger = MenuSubTrigger;
1026
- var SubContent = MenuSubContent;
1027
-
1028
- var DROPDOWN_MENU_NAME = "DropdownMenu";
1029
- var [createDropdownMenuContext, createDropdownMenuScope] = createContextScope(
1030
- DROPDOWN_MENU_NAME,
1031
- [createMenuScope]
1032
- );
1033
- var useMenuScope = createMenuScope();
1034
- var [DropdownMenuProvider, useDropdownMenuContext] = createDropdownMenuContext(DROPDOWN_MENU_NAME);
1035
- var DropdownMenu = (props) => {
1036
- const {
1037
- __scopeDropdownMenu,
1038
- children,
1039
- dir,
1040
- open: openProp,
1041
- defaultOpen,
1042
- onOpenChange,
1043
- modal = true
1044
- } = props;
1045
- const menuScope = useMenuScope(__scopeDropdownMenu);
1046
- const triggerRef = React.useRef(null);
1047
- const [open = false, setOpen] = useControllableState({
1048
- prop: openProp,
1049
- defaultProp: defaultOpen,
1050
- onChange: onOpenChange
1051
- });
1052
- return /* @__PURE__ */ jsx(
1053
- DropdownMenuProvider,
1054
- {
1055
- scope: __scopeDropdownMenu,
1056
- triggerId: useId(),
1057
- triggerRef,
1058
- contentId: useId(),
1059
- open,
1060
- onOpenChange: setOpen,
1061
- onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
1062
- modal,
1063
- children: /* @__PURE__ */ jsx(Root3, { ...menuScope, open, onOpenChange: setOpen, dir, modal, children })
1064
- }
1065
- );
1066
- };
1067
- DropdownMenu.displayName = DROPDOWN_MENU_NAME;
1068
- var TRIGGER_NAME = "DropdownMenuTrigger";
1069
- var DropdownMenuTrigger = React.forwardRef(
1070
- (props, forwardedRef) => {
1071
- const { __scopeDropdownMenu, disabled = false, ...triggerProps } = props;
1072
- const context = useDropdownMenuContext(TRIGGER_NAME, __scopeDropdownMenu);
1073
- const menuScope = useMenuScope(__scopeDropdownMenu);
1074
- return /* @__PURE__ */ jsx(Anchor2, { asChild: true, ...menuScope, children: /* @__PURE__ */ jsx(
1075
- Primitive.button,
1076
- {
1077
- type: "button",
1078
- id: context.triggerId,
1079
- "aria-haspopup": "menu",
1080
- "aria-expanded": context.open,
1081
- "aria-controls": context.open ? context.contentId : void 0,
1082
- "data-state": context.open ? "open" : "closed",
1083
- "data-disabled": disabled ? "" : void 0,
1084
- disabled,
1085
- ...triggerProps,
1086
- ref: composeRefs(forwardedRef, context.triggerRef),
1087
- onPointerDown: composeEventHandlers(props.onPointerDown, (event) => {
1088
- if (!disabled && event.button === 0 && event.ctrlKey === false) {
1089
- context.onOpenToggle();
1090
- if (!context.open) event.preventDefault();
1091
- }
1092
- }),
1093
- onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
1094
- if (disabled) return;
1095
- if (["Enter", " "].includes(event.key)) context.onOpenToggle();
1096
- if (event.key === "ArrowDown") context.onOpenChange(true);
1097
- if (["Enter", " ", "ArrowDown"].includes(event.key)) event.preventDefault();
1098
- })
1099
- }
1100
- ) });
1101
- }
1102
- );
1103
- DropdownMenuTrigger.displayName = TRIGGER_NAME;
1104
- var PORTAL_NAME = "DropdownMenuPortal";
1105
- var DropdownMenuPortal = (props) => {
1106
- const { __scopeDropdownMenu, ...portalProps } = props;
1107
- const menuScope = useMenuScope(__scopeDropdownMenu);
1108
- return /* @__PURE__ */ jsx(Portal, { ...menuScope, ...portalProps });
1109
- };
1110
- DropdownMenuPortal.displayName = PORTAL_NAME;
1111
- var CONTENT_NAME = "DropdownMenuContent";
1112
- var DropdownMenuContent = React.forwardRef(
1113
- (props, forwardedRef) => {
1114
- const { __scopeDropdownMenu, ...contentProps } = props;
1115
- const context = useDropdownMenuContext(CONTENT_NAME, __scopeDropdownMenu);
1116
- const menuScope = useMenuScope(__scopeDropdownMenu);
1117
- const hasInteractedOutsideRef = React.useRef(false);
1118
- return /* @__PURE__ */ jsx(
1119
- Content2$1,
1120
- {
1121
- id: context.contentId,
1122
- "aria-labelledby": context.triggerId,
1123
- ...menuScope,
1124
- ...contentProps,
1125
- ref: forwardedRef,
1126
- onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
1127
- if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
1128
- hasInteractedOutsideRef.current = false;
1129
- event.preventDefault();
1130
- }),
1131
- onInteractOutside: composeEventHandlers(props.onInteractOutside, (event) => {
1132
- const originalEvent = event.detail.originalEvent;
1133
- const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
1134
- const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
1135
- if (!context.modal || isRightClick) hasInteractedOutsideRef.current = true;
1136
- }),
1137
- style: {
1138
- ...props.style,
1139
- // re-namespace exposed content custom properties
1140
- ...{
1141
- "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
1142
- "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
1143
- "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
1144
- "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
1145
- "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
1146
- }
1147
- }
1148
- }
1149
- );
1150
- }
1151
- );
1152
- DropdownMenuContent.displayName = CONTENT_NAME;
1153
- var GROUP_NAME = "DropdownMenuGroup";
1154
- var DropdownMenuGroup = React.forwardRef(
1155
- (props, forwardedRef) => {
1156
- const { __scopeDropdownMenu, ...groupProps } = props;
1157
- const menuScope = useMenuScope(__scopeDropdownMenu);
1158
- return /* @__PURE__ */ jsx(Group, { ...menuScope, ...groupProps, ref: forwardedRef });
1159
- }
1160
- );
1161
- DropdownMenuGroup.displayName = GROUP_NAME;
1162
- var LABEL_NAME = "DropdownMenuLabel";
1163
- var DropdownMenuLabel = React.forwardRef(
1164
- (props, forwardedRef) => {
1165
- const { __scopeDropdownMenu, ...labelProps } = props;
1166
- const menuScope = useMenuScope(__scopeDropdownMenu);
1167
- return /* @__PURE__ */ jsx(Label, { ...menuScope, ...labelProps, ref: forwardedRef });
1168
- }
1169
- );
1170
- DropdownMenuLabel.displayName = LABEL_NAME;
1171
- var ITEM_NAME = "DropdownMenuItem";
1172
- var DropdownMenuItem = React.forwardRef(
1173
- (props, forwardedRef) => {
1174
- const { __scopeDropdownMenu, ...itemProps } = props;
1175
- const menuScope = useMenuScope(__scopeDropdownMenu);
1176
- return /* @__PURE__ */ jsx(Item2$1, { ...menuScope, ...itemProps, ref: forwardedRef });
1177
- }
1178
- );
1179
- DropdownMenuItem.displayName = ITEM_NAME;
1180
- var CHECKBOX_ITEM_NAME = "DropdownMenuCheckboxItem";
1181
- var DropdownMenuCheckboxItem = React.forwardRef((props, forwardedRef) => {
1182
- const { __scopeDropdownMenu, ...checkboxItemProps } = props;
1183
- const menuScope = useMenuScope(__scopeDropdownMenu);
1184
- return /* @__PURE__ */ jsx(CheckboxItem, { ...menuScope, ...checkboxItemProps, ref: forwardedRef });
1185
- });
1186
- DropdownMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
1187
- var RADIO_GROUP_NAME = "DropdownMenuRadioGroup";
1188
- var DropdownMenuRadioGroup = React.forwardRef((props, forwardedRef) => {
1189
- const { __scopeDropdownMenu, ...radioGroupProps } = props;
1190
- const menuScope = useMenuScope(__scopeDropdownMenu);
1191
- return /* @__PURE__ */ jsx(RadioGroup, { ...menuScope, ...radioGroupProps, ref: forwardedRef });
1192
- });
1193
- DropdownMenuRadioGroup.displayName = RADIO_GROUP_NAME;
1194
- var RADIO_ITEM_NAME = "DropdownMenuRadioItem";
1195
- var DropdownMenuRadioItem = React.forwardRef((props, forwardedRef) => {
1196
- const { __scopeDropdownMenu, ...radioItemProps } = props;
1197
- const menuScope = useMenuScope(__scopeDropdownMenu);
1198
- return /* @__PURE__ */ jsx(RadioItem, { ...menuScope, ...radioItemProps, ref: forwardedRef });
1199
- });
1200
- DropdownMenuRadioItem.displayName = RADIO_ITEM_NAME;
1201
- var INDICATOR_NAME = "DropdownMenuItemIndicator";
1202
- var DropdownMenuItemIndicator = React.forwardRef((props, forwardedRef) => {
1203
- const { __scopeDropdownMenu, ...itemIndicatorProps } = props;
1204
- const menuScope = useMenuScope(__scopeDropdownMenu);
1205
- return /* @__PURE__ */ jsx(ItemIndicator, { ...menuScope, ...itemIndicatorProps, ref: forwardedRef });
1206
- });
1207
- DropdownMenuItemIndicator.displayName = INDICATOR_NAME;
1208
- var SEPARATOR_NAME = "DropdownMenuSeparator";
1209
- var DropdownMenuSeparator = React.forwardRef((props, forwardedRef) => {
1210
- const { __scopeDropdownMenu, ...separatorProps } = props;
1211
- const menuScope = useMenuScope(__scopeDropdownMenu);
1212
- return /* @__PURE__ */ jsx(Separator, { ...menuScope, ...separatorProps, ref: forwardedRef });
1213
- });
1214
- DropdownMenuSeparator.displayName = SEPARATOR_NAME;
1215
- var ARROW_NAME = "DropdownMenuArrow";
1216
- var DropdownMenuArrow = React.forwardRef(
1217
- (props, forwardedRef) => {
1218
- const { __scopeDropdownMenu, ...arrowProps } = props;
1219
- const menuScope = useMenuScope(__scopeDropdownMenu);
1220
- return /* @__PURE__ */ jsx(Arrow2, { ...menuScope, ...arrowProps, ref: forwardedRef });
1221
- }
1222
- );
1223
- DropdownMenuArrow.displayName = ARROW_NAME;
1224
- var DropdownMenuSub = (props) => {
1225
- const { __scopeDropdownMenu, children, open: openProp, onOpenChange, defaultOpen } = props;
1226
- const menuScope = useMenuScope(__scopeDropdownMenu);
1227
- const [open = false, setOpen] = useControllableState({
1228
- prop: openProp,
1229
- defaultProp: defaultOpen,
1230
- onChange: onOpenChange
1231
- });
1232
- return /* @__PURE__ */ jsx(Sub, { ...menuScope, open, onOpenChange: setOpen, children });
1233
- };
1234
- var SUB_TRIGGER_NAME = "DropdownMenuSubTrigger";
1235
- var DropdownMenuSubTrigger = React.forwardRef((props, forwardedRef) => {
1236
- const { __scopeDropdownMenu, ...subTriggerProps } = props;
1237
- const menuScope = useMenuScope(__scopeDropdownMenu);
1238
- return /* @__PURE__ */ jsx(SubTrigger, { ...menuScope, ...subTriggerProps, ref: forwardedRef });
1239
- });
1240
- DropdownMenuSubTrigger.displayName = SUB_TRIGGER_NAME;
1241
- var SUB_CONTENT_NAME = "DropdownMenuSubContent";
1242
- var DropdownMenuSubContent = React.forwardRef((props, forwardedRef) => {
1243
- const { __scopeDropdownMenu, ...subContentProps } = props;
1244
- const menuScope = useMenuScope(__scopeDropdownMenu);
1245
- return /* @__PURE__ */ jsx(
1246
- SubContent,
1247
- {
1248
- ...menuScope,
1249
- ...subContentProps,
1250
- ref: forwardedRef,
1251
- style: {
1252
- ...props.style,
1253
- // re-namespace exposed content custom properties
1254
- ...{
1255
- "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
1256
- "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
1257
- "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
1258
- "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
1259
- "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
1260
- }
1261
- }
1262
- }
1263
- );
1264
- });
1265
- DropdownMenuSubContent.displayName = SUB_CONTENT_NAME;
1266
- var Root2 = DropdownMenu;
1267
- var Trigger = DropdownMenuTrigger;
1268
- var Portal2 = DropdownMenuPortal;
1269
- var Content2 = DropdownMenuContent;
1270
- var Group2 = DropdownMenuGroup;
1271
- var Item2 = DropdownMenuItem;
1272
- var CheckboxItem2 = DropdownMenuCheckboxItem;
1273
- var RadioGroup2 = DropdownMenuRadioGroup;
1274
- var RadioItem2 = DropdownMenuRadioItem;
1275
- var Separator2 = DropdownMenuSeparator;
1276
- var Sub2 = DropdownMenuSub;
1277
- var SubTrigger2 = DropdownMenuSubTrigger;
1278
- var SubContent2 = DropdownMenuSubContent;
1279
-
1280
- /**
1281
- * The component that pops out when the dropdown menu is open.
1282
- */
1283
- var MenuContent = React__default.forwardRef(function (_a, ref) {
1284
- var children = _a.children, width = _a.width, minWidth = _a.minWidth, maxWidth = _a.maxWidth, _b = _a.align, align = _b === void 0 ? "start" : _b, alignOffset = _a.alignOffset, side = _a.side, props = __rest(_a, ["children", "width", "minWidth", "maxWidth", "align", "alignOffset", "side"]);
1285
- return (React__default.createElement(Content2, __assign({ ref: ref, style: { width: width, minWidth: minWidth, maxWidth: maxWidth }, className: "arc-MenuContent", sideOffset: 12, loop: true, collisionPadding: 12, forceMount: true, align: align, alignOffset: alignOffset, side: side }, filterAttrs(props)), children));
1286
- });
1287
-
1288
- /**
1289
- * The multi-level menu content that pops out when a menu item with children is hovered or clicked.
1290
- */
1291
- var MenuItemMultiLevelContent = React__default.forwardRef(function (_a, ref) {
1292
- var children = _a.children, width = _a.width, minWidth = _a.minWidth, maxWidth = _a.maxWidth, alignOffset = _a.alignOffset, props = __rest(_a, ["children", "width", "minWidth", "maxWidth", "alignOffset"]);
1293
- return (React__default.createElement(SubContent2, __assign({ ref: ref, style: { width: width, minWidth: minWidth, maxWidth: maxWidth }, className: "arc-MenuContent", sideOffset: 24, collisionPadding: 12, avoidCollisions: true, alignOffset: alignOffset }, filterAttrs(props)), children));
1294
- });
1295
-
1296
- export { CheckboxItem2 as C, Group2 as G, Item2 as I, MenuContent as M, Portal2 as P, Root2 as R, Separator2 as S, Trigger as T, RadioGroup2 as a, RadioItem2 as b, Sub2 as c, SubTrigger2 as d, MenuItemMultiLevelContent as e };