@vritti/quantum-ui 0.2.7 → 0.2.8

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 (174) hide show
  1. package/dist/Avatar.js +219 -0
  2. package/dist/Avatar.js.map +1 -0
  3. package/dist/Badge.js +32 -0
  4. package/dist/Badge.js.map +1 -0
  5. package/dist/Button2.js +2 -2
  6. package/dist/Chart.js +19003 -0
  7. package/dist/Chart.js.map +1 -0
  8. package/dist/Checkbox.js +6 -26
  9. package/dist/Checkbox.js.map +1 -1
  10. package/dist/Combination.js +3868 -0
  11. package/dist/Combination.js.map +1 -0
  12. package/dist/DatePicker.js +15 -3877
  13. package/dist/DatePicker.js.map +1 -1
  14. package/dist/DropdownMenu.js +1591 -0
  15. package/dist/DropdownMenu.js.map +1 -0
  16. package/dist/Form.js +7 -4
  17. package/dist/Form.js.map +1 -1
  18. package/dist/Label.js +1 -1
  19. package/dist/OTPField.js +16 -5
  20. package/dist/OTPField.js.map +1 -1
  21. package/dist/PhoneField.js +14 -6
  22. package/dist/PhoneField.js.map +1 -1
  23. package/dist/Progress.js +116 -0
  24. package/dist/Progress.js.map +1 -0
  25. package/dist/Separator.js +6 -0
  26. package/dist/Separator.js.map +1 -0
  27. package/dist/Spinner.js +1 -9
  28. package/dist/Spinner.js.map +1 -1
  29. package/dist/Switch.js +210 -0
  30. package/dist/Switch.js.map +1 -0
  31. package/dist/ThemeContext.js +57 -0
  32. package/dist/ThemeContext.js.map +1 -0
  33. package/dist/ThemeToggle.js +4 -15
  34. package/dist/ThemeToggle.js.map +1 -1
  35. package/dist/Toggle.js +69 -0
  36. package/dist/Toggle.js.map +1 -0
  37. package/dist/_commonjsHelpers.js +6 -0
  38. package/dist/_commonjsHelpers.js.map +1 -0
  39. package/dist/assets/quantum-ui.css +18 -0
  40. package/dist/axios.js.map +1 -1
  41. package/dist/check.js +15 -0
  42. package/dist/check.js.map +1 -0
  43. package/dist/components/Avatar.js +2 -0
  44. package/dist/components/Avatar.js.map +1 -0
  45. package/dist/components/Badge.js +2 -0
  46. package/dist/components/Badge.js.map +1 -0
  47. package/dist/components/Chart.js +2 -0
  48. package/dist/components/Chart.js.map +1 -0
  49. package/dist/components/DropdownMenu.js +2 -0
  50. package/dist/components/DropdownMenu.js.map +1 -0
  51. package/dist/components/Progress.js +1 -174
  52. package/dist/components/Progress.js.map +1 -1
  53. package/dist/components/Separator.js +2 -0
  54. package/dist/components/Separator.js.map +1 -0
  55. package/dist/components/Switch.js +2 -0
  56. package/dist/components/Switch.js.map +1 -0
  57. package/dist/components/Toggle.js +2 -0
  58. package/dist/components/Toggle.js.map +1 -0
  59. package/dist/context/index.js +2 -0
  60. package/dist/context/index.js.map +1 -0
  61. package/dist/field.js +2 -49
  62. package/dist/field.js.map +1 -1
  63. package/dist/hooks/index.js +2 -0
  64. package/dist/hooks/index.js.map +1 -0
  65. package/dist/index.js +10 -0
  66. package/dist/index.js.map +1 -1
  67. package/dist/index10.js +105 -0
  68. package/dist/index10.js.map +1 -0
  69. package/dist/index11.js +101 -0
  70. package/dist/index11.js.map +1 -0
  71. package/dist/index12.js +205 -0
  72. package/dist/index12.js.map +1 -0
  73. package/dist/index13.js +199 -0
  74. package/dist/index13.js.map +1 -0
  75. package/dist/index2.js +55 -130
  76. package/dist/index2.js.map +1 -1
  77. package/dist/index3.js +10 -42
  78. package/dist/index3.js.map +1 -1
  79. package/dist/index4.js +125 -35
  80. package/dist/index4.js.map +1 -1
  81. package/dist/index5.js +26 -414
  82. package/dist/index5.js.map +1 -1
  83. package/dist/index6.js +8 -0
  84. package/dist/index6.js.map +1 -0
  85. package/dist/index7.js +16 -0
  86. package/dist/index7.js.map +1 -0
  87. package/dist/index8.js +45 -0
  88. package/dist/index8.js.map +1 -0
  89. package/dist/index9.js +41 -0
  90. package/dist/index9.js.map +1 -0
  91. package/dist/lib/components/Avatar/Avatar.d.ts +8 -0
  92. package/dist/lib/components/Avatar/Avatar.d.ts.map +1 -0
  93. package/dist/lib/components/Avatar/index.d.ts +2 -0
  94. package/dist/lib/components/Avatar/index.d.ts.map +1 -0
  95. package/dist/lib/components/Badge/Badge.d.ts +5 -0
  96. package/dist/lib/components/Badge/Badge.d.ts.map +1 -0
  97. package/dist/lib/components/Badge/index.d.ts +3 -0
  98. package/dist/lib/components/Badge/index.d.ts.map +1 -0
  99. package/dist/lib/components/Button/index.d.ts +1 -1
  100. package/dist/lib/components/Button/index.d.ts.map +1 -1
  101. package/dist/lib/components/Chart/Chart.d.ts +13 -0
  102. package/dist/lib/components/Chart/Chart.d.ts.map +1 -0
  103. package/dist/lib/components/Chart/index.d.ts +3 -0
  104. package/dist/lib/components/Chart/index.d.ts.map +1 -0
  105. package/dist/lib/components/DropdownMenu/DropdownMenu.d.ts +28 -0
  106. package/dist/lib/components/DropdownMenu/DropdownMenu.d.ts.map +1 -0
  107. package/dist/lib/components/DropdownMenu/index.d.ts +3 -0
  108. package/dist/lib/components/DropdownMenu/index.d.ts.map +1 -0
  109. package/dist/lib/components/DropdownMenu/types.d.ts +72 -0
  110. package/dist/lib/components/DropdownMenu/types.d.ts.map +1 -0
  111. package/dist/lib/components/Form/Form.d.ts.map +1 -1
  112. package/dist/lib/components/OTPField/OTPField.d.ts.map +1 -1
  113. package/dist/lib/components/PhoneField/PhoneField.d.ts.map +1 -1
  114. package/dist/lib/components/Separator/Separator.d.ts +3 -0
  115. package/dist/lib/components/Separator/Separator.d.ts.map +1 -0
  116. package/dist/lib/components/Separator/index.d.ts +2 -0
  117. package/dist/lib/components/Separator/index.d.ts.map +1 -0
  118. package/dist/lib/components/Switch/Switch.d.ts +9 -0
  119. package/dist/lib/components/Switch/Switch.d.ts.map +1 -0
  120. package/dist/lib/components/Switch/index.d.ts +3 -0
  121. package/dist/lib/components/Switch/index.d.ts.map +1 -0
  122. package/dist/lib/components/ThemeToggle/ThemeToggle.d.ts.map +1 -1
  123. package/dist/lib/components/Toggle/Toggle.d.ts +7 -0
  124. package/dist/lib/components/Toggle/Toggle.d.ts.map +1 -0
  125. package/dist/lib/components/Toggle/index.d.ts +2 -0
  126. package/dist/lib/components/Toggle/index.d.ts.map +1 -0
  127. package/dist/lib/components/index.d.ts +8 -0
  128. package/dist/lib/components/index.d.ts.map +1 -1
  129. package/dist/lib/context/ThemeContext.d.ts +18 -0
  130. package/dist/lib/context/ThemeContext.d.ts.map +1 -0
  131. package/dist/lib/context/index.d.ts +2 -0
  132. package/dist/lib/context/index.d.ts.map +1 -0
  133. package/dist/lib/hooks/index.d.ts +2 -0
  134. package/dist/lib/hooks/index.d.ts.map +1 -0
  135. package/dist/lib/hooks/useTheme.d.ts +8 -0
  136. package/dist/lib/hooks/useTheme.d.ts.map +1 -0
  137. package/dist/lib/index.d.ts +2 -0
  138. package/dist/lib/index.d.ts.map +1 -1
  139. package/dist/lib/theme/index.d.ts +13 -0
  140. package/dist/lib/theme/index.d.ts.map +1 -0
  141. package/dist/lib/utils/axios.d.ts +1 -0
  142. package/dist/lib/utils/axios.d.ts.map +1 -1
  143. package/dist/lib/utils/formHelpers.d.ts.map +1 -1
  144. package/dist/separator2.js +53 -0
  145. package/dist/separator2.js.map +1 -0
  146. package/dist/shadcn/index.d.ts +1 -1
  147. package/dist/shadcn/index.d.ts.map +1 -1
  148. package/dist/shadcn/shadcnAvatar/Avatar.d.ts +12 -0
  149. package/dist/shadcn/shadcnAvatar/Avatar.d.ts.map +1 -0
  150. package/dist/shadcn/shadcnAvatar/index.d.ts +2 -0
  151. package/dist/shadcn/shadcnAvatar/index.d.ts.map +1 -0
  152. package/dist/shadcn/shadcnBadge/Badge.d.ts +11 -0
  153. package/dist/shadcn/shadcnBadge/Badge.d.ts.map +1 -0
  154. package/dist/shadcn/shadcnBadge/index.d.ts +3 -0
  155. package/dist/shadcn/shadcnBadge/index.d.ts.map +1 -0
  156. package/dist/shadcn/shadcnButton/Button.d.ts +1 -1
  157. package/dist/shadcn/shadcnChart/Chart.d.ts +58 -0
  158. package/dist/shadcn/shadcnChart/Chart.d.ts.map +1 -0
  159. package/dist/shadcn/shadcnChart/index.d.ts +3 -0
  160. package/dist/shadcn/shadcnChart/index.d.ts.map +1 -0
  161. package/dist/shadcn/shadcnSpinner/Spinner.d.ts.map +1 -1
  162. package/dist/shadcn/shadcnSwitch/Switch.d.ts +7 -0
  163. package/dist/shadcn/shadcnSwitch/Switch.d.ts.map +1 -0
  164. package/dist/shadcn/shadcnSwitch/index.d.ts +2 -0
  165. package/dist/shadcn/shadcnSwitch/index.d.ts.map +1 -0
  166. package/dist/shadcn/shadcnToggle/Toggle.d.ts +10 -0
  167. package/dist/shadcn/shadcnToggle/Toggle.d.ts.map +1 -0
  168. package/dist/shadcn/shadcnToggle/index.d.ts +2 -0
  169. package/dist/shadcn/shadcnToggle/index.d.ts.map +1 -0
  170. package/dist/theme/index.js +11 -0
  171. package/dist/theme/index.js.map +1 -0
  172. package/dist/useTheme.js +15 -0
  173. package/dist/useTheme.js.map +1 -0
  174. package/package.json +45 -1
@@ -0,0 +1,1591 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import React__default from 'react';
4
+ import { B as Button } from './Button.js';
5
+ import { a as createSlot, P as Primitive, c as composeEventHandlers, u as useControllableState, d as dispatchDiscreteCustomEvent } from './index12.js';
6
+ import { u as useComposedRefs, c as composeRefs } from './index5.js';
7
+ import { c as createContextScope } from './index11.js';
8
+ import { u as useId, c as createPopperScope, R as Root2$1, P as Portal$1, A as Anchor, h as hideOthers, a as useFocusGuards, b as ReactRemoveScroll, F as FocusScope, D as DismissableLayer, C as Content, d as Arrow, e as ChevronRight } from './Combination.js';
9
+ import { P as Presence } from './index4.js';
10
+ import { u as useCallbackRef } from './index3.js';
11
+ import { c as cn } from './utils.js';
12
+ import { C as Check } from './check.js';
13
+ import { c as createLucideIcon } from './createLucideIcon.js';
14
+
15
+ /**
16
+ * @license lucide-react v0.562.0 - ISC
17
+ *
18
+ * This source code is licensed under the ISC license.
19
+ * See the LICENSE file in the root directory of this source tree.
20
+ */
21
+
22
+
23
+ const __iconNode = [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]];
24
+ const Circle = createLucideIcon("circle", __iconNode);
25
+
26
+ function createCollection(name) {
27
+ const PROVIDER_NAME = name + "CollectionProvider";
28
+ const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);
29
+ const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(
30
+ PROVIDER_NAME,
31
+ { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
32
+ );
33
+ const CollectionProvider = (props) => {
34
+ const { scope, children } = props;
35
+ const ref = React__default.useRef(null);
36
+ const itemMap = React__default.useRef(/* @__PURE__ */ new Map()).current;
37
+ return /* @__PURE__ */ jsx(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
38
+ };
39
+ CollectionProvider.displayName = PROVIDER_NAME;
40
+ const COLLECTION_SLOT_NAME = name + "CollectionSlot";
41
+ const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);
42
+ const CollectionSlot = React__default.forwardRef(
43
+ (props, forwardedRef) => {
44
+ const { scope, children } = props;
45
+ const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
46
+ const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
47
+ return /* @__PURE__ */ jsx(CollectionSlotImpl, { ref: composedRefs, children });
48
+ }
49
+ );
50
+ CollectionSlot.displayName = COLLECTION_SLOT_NAME;
51
+ const ITEM_SLOT_NAME = name + "CollectionItemSlot";
52
+ const ITEM_DATA_ATTR = "data-radix-collection-item";
53
+ const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);
54
+ const CollectionItemSlot = React__default.forwardRef(
55
+ (props, forwardedRef) => {
56
+ const { scope, children, ...itemData } = props;
57
+ const ref = React__default.useRef(null);
58
+ const composedRefs = useComposedRefs(forwardedRef, ref);
59
+ const context = useCollectionContext(ITEM_SLOT_NAME, scope);
60
+ React__default.useEffect(() => {
61
+ context.itemMap.set(ref, { ref, ...itemData });
62
+ return () => void context.itemMap.delete(ref);
63
+ });
64
+ return /* @__PURE__ */ jsx(CollectionItemSlotImpl, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
65
+ }
66
+ );
67
+ CollectionItemSlot.displayName = ITEM_SLOT_NAME;
68
+ function useCollection(scope) {
69
+ const context = useCollectionContext(name + "CollectionConsumer", scope);
70
+ const getItems = React__default.useCallback(() => {
71
+ const collectionNode = context.collectionRef.current;
72
+ if (!collectionNode) return [];
73
+ const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
74
+ const items = Array.from(context.itemMap.values());
75
+ const orderedItems = items.sort(
76
+ (a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
77
+ );
78
+ return orderedItems;
79
+ }, [context.collectionRef, context.itemMap]);
80
+ return getItems;
81
+ }
82
+ return [
83
+ { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
84
+ useCollection,
85
+ createCollectionScope
86
+ ];
87
+ }
88
+
89
+ // packages/react/direction/src/direction.tsx
90
+ var DirectionContext = React.createContext(void 0);
91
+ function useDirection(localDir) {
92
+ const globalDir = React.useContext(DirectionContext);
93
+ return localDir || globalDir || "ltr";
94
+ }
95
+
96
+ var ENTRY_FOCUS = "rovingFocusGroup.onEntryFocus";
97
+ var EVENT_OPTIONS = { bubbles: false, cancelable: true };
98
+ var GROUP_NAME$2 = "RovingFocusGroup";
99
+ var [Collection$1, useCollection$1, createCollectionScope$1] = createCollection(GROUP_NAME$2);
100
+ var [createRovingFocusGroupContext, createRovingFocusGroupScope] = createContextScope(
101
+ GROUP_NAME$2,
102
+ [createCollectionScope$1]
103
+ );
104
+ var [RovingFocusProvider, useRovingFocusContext] = createRovingFocusGroupContext(GROUP_NAME$2);
105
+ var RovingFocusGroup = React.forwardRef(
106
+ (props, forwardedRef) => {
107
+ 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 }) }) });
108
+ }
109
+ );
110
+ RovingFocusGroup.displayName = GROUP_NAME$2;
111
+ var RovingFocusGroupImpl = React.forwardRef((props, forwardedRef) => {
112
+ const {
113
+ __scopeRovingFocusGroup,
114
+ orientation,
115
+ loop = false,
116
+ dir,
117
+ currentTabStopId: currentTabStopIdProp,
118
+ defaultCurrentTabStopId,
119
+ onCurrentTabStopIdChange,
120
+ onEntryFocus,
121
+ preventScrollOnEntryFocus = false,
122
+ ...groupProps
123
+ } = props;
124
+ const ref = React.useRef(null);
125
+ const composedRefs = useComposedRefs(forwardedRef, ref);
126
+ const direction = useDirection(dir);
127
+ const [currentTabStopId, setCurrentTabStopId] = useControllableState({
128
+ prop: currentTabStopIdProp,
129
+ defaultProp: defaultCurrentTabStopId ?? null,
130
+ onChange: onCurrentTabStopIdChange,
131
+ caller: GROUP_NAME$2
132
+ });
133
+ const [isTabbingBackOut, setIsTabbingBackOut] = React.useState(false);
134
+ const handleEntryFocus = useCallbackRef(onEntryFocus);
135
+ const getItems = useCollection$1(__scopeRovingFocusGroup);
136
+ const isClickFocusRef = React.useRef(false);
137
+ const [focusableItemsCount, setFocusableItemsCount] = React.useState(0);
138
+ React.useEffect(() => {
139
+ const node = ref.current;
140
+ if (node) {
141
+ node.addEventListener(ENTRY_FOCUS, handleEntryFocus);
142
+ return () => node.removeEventListener(ENTRY_FOCUS, handleEntryFocus);
143
+ }
144
+ }, [handleEntryFocus]);
145
+ return /* @__PURE__ */ jsx(
146
+ RovingFocusProvider,
147
+ {
148
+ scope: __scopeRovingFocusGroup,
149
+ orientation,
150
+ dir: direction,
151
+ loop,
152
+ currentTabStopId,
153
+ onItemFocus: React.useCallback(
154
+ (tabStopId) => setCurrentTabStopId(tabStopId),
155
+ [setCurrentTabStopId]
156
+ ),
157
+ onItemShiftTab: React.useCallback(() => setIsTabbingBackOut(true), []),
158
+ onFocusableItemAdd: React.useCallback(
159
+ () => setFocusableItemsCount((prevCount) => prevCount + 1),
160
+ []
161
+ ),
162
+ onFocusableItemRemove: React.useCallback(
163
+ () => setFocusableItemsCount((prevCount) => prevCount - 1),
164
+ []
165
+ ),
166
+ children: /* @__PURE__ */ jsx(
167
+ Primitive.div,
168
+ {
169
+ tabIndex: isTabbingBackOut || focusableItemsCount === 0 ? -1 : 0,
170
+ "data-orientation": orientation,
171
+ ...groupProps,
172
+ ref: composedRefs,
173
+ style: { outline: "none", ...props.style },
174
+ onMouseDown: composeEventHandlers(props.onMouseDown, () => {
175
+ isClickFocusRef.current = true;
176
+ }),
177
+ onFocus: composeEventHandlers(props.onFocus, (event) => {
178
+ const isKeyboardFocus = !isClickFocusRef.current;
179
+ if (event.target === event.currentTarget && isKeyboardFocus && !isTabbingBackOut) {
180
+ const entryFocusEvent = new CustomEvent(ENTRY_FOCUS, EVENT_OPTIONS);
181
+ event.currentTarget.dispatchEvent(entryFocusEvent);
182
+ if (!entryFocusEvent.defaultPrevented) {
183
+ const items = getItems().filter((item) => item.focusable);
184
+ const activeItem = items.find((item) => item.active);
185
+ const currentItem = items.find((item) => item.id === currentTabStopId);
186
+ const candidateItems = [activeItem, currentItem, ...items].filter(
187
+ Boolean
188
+ );
189
+ const candidateNodes = candidateItems.map((item) => item.ref.current);
190
+ focusFirst$1(candidateNodes, preventScrollOnEntryFocus);
191
+ }
192
+ }
193
+ isClickFocusRef.current = false;
194
+ }),
195
+ onBlur: composeEventHandlers(props.onBlur, () => setIsTabbingBackOut(false))
196
+ }
197
+ )
198
+ }
199
+ );
200
+ });
201
+ var ITEM_NAME$2 = "RovingFocusGroupItem";
202
+ var RovingFocusGroupItem = React.forwardRef(
203
+ (props, forwardedRef) => {
204
+ const {
205
+ __scopeRovingFocusGroup,
206
+ focusable = true,
207
+ active = false,
208
+ tabStopId,
209
+ children,
210
+ ...itemProps
211
+ } = props;
212
+ const autoId = useId();
213
+ const id = tabStopId || autoId;
214
+ const context = useRovingFocusContext(ITEM_NAME$2, __scopeRovingFocusGroup);
215
+ const isCurrentTabStop = context.currentTabStopId === id;
216
+ const getItems = useCollection$1(__scopeRovingFocusGroup);
217
+ const { onFocusableItemAdd, onFocusableItemRemove, currentTabStopId } = context;
218
+ React.useEffect(() => {
219
+ if (focusable) {
220
+ onFocusableItemAdd();
221
+ return () => onFocusableItemRemove();
222
+ }
223
+ }, [focusable, onFocusableItemAdd, onFocusableItemRemove]);
224
+ return /* @__PURE__ */ jsx(
225
+ Collection$1.ItemSlot,
226
+ {
227
+ scope: __scopeRovingFocusGroup,
228
+ id,
229
+ focusable,
230
+ active,
231
+ children: /* @__PURE__ */ jsx(
232
+ Primitive.span,
233
+ {
234
+ tabIndex: isCurrentTabStop ? 0 : -1,
235
+ "data-orientation": context.orientation,
236
+ ...itemProps,
237
+ ref: forwardedRef,
238
+ onMouseDown: composeEventHandlers(props.onMouseDown, (event) => {
239
+ if (!focusable) event.preventDefault();
240
+ else context.onItemFocus(id);
241
+ }),
242
+ onFocus: composeEventHandlers(props.onFocus, () => context.onItemFocus(id)),
243
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
244
+ if (event.key === "Tab" && event.shiftKey) {
245
+ context.onItemShiftTab();
246
+ return;
247
+ }
248
+ if (event.target !== event.currentTarget) return;
249
+ const focusIntent = getFocusIntent(event, context.orientation, context.dir);
250
+ if (focusIntent !== void 0) {
251
+ if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return;
252
+ event.preventDefault();
253
+ const items = getItems().filter((item) => item.focusable);
254
+ let candidateNodes = items.map((item) => item.ref.current);
255
+ if (focusIntent === "last") candidateNodes.reverse();
256
+ else if (focusIntent === "prev" || focusIntent === "next") {
257
+ if (focusIntent === "prev") candidateNodes.reverse();
258
+ const currentIndex = candidateNodes.indexOf(event.currentTarget);
259
+ candidateNodes = context.loop ? wrapArray$1(candidateNodes, currentIndex + 1) : candidateNodes.slice(currentIndex + 1);
260
+ }
261
+ setTimeout(() => focusFirst$1(candidateNodes));
262
+ }
263
+ }),
264
+ children: typeof children === "function" ? children({ isCurrentTabStop, hasTabStop: currentTabStopId != null }) : children
265
+ }
266
+ )
267
+ }
268
+ );
269
+ }
270
+ );
271
+ RovingFocusGroupItem.displayName = ITEM_NAME$2;
272
+ var MAP_KEY_TO_FOCUS_INTENT = {
273
+ ArrowLeft: "prev",
274
+ ArrowUp: "prev",
275
+ ArrowRight: "next",
276
+ ArrowDown: "next",
277
+ PageUp: "first",
278
+ Home: "first",
279
+ PageDown: "last",
280
+ End: "last"
281
+ };
282
+ function getDirectionAwareKey(key, dir) {
283
+ if (dir !== "rtl") return key;
284
+ return key === "ArrowLeft" ? "ArrowRight" : key === "ArrowRight" ? "ArrowLeft" : key;
285
+ }
286
+ function getFocusIntent(event, orientation, dir) {
287
+ const key = getDirectionAwareKey(event.key, dir);
288
+ if (orientation === "vertical" && ["ArrowLeft", "ArrowRight"].includes(key)) return void 0;
289
+ if (orientation === "horizontal" && ["ArrowUp", "ArrowDown"].includes(key)) return void 0;
290
+ return MAP_KEY_TO_FOCUS_INTENT[key];
291
+ }
292
+ function focusFirst$1(candidates, preventScroll = false) {
293
+ const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
294
+ for (const candidate of candidates) {
295
+ if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
296
+ candidate.focus({ preventScroll });
297
+ if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
298
+ }
299
+ }
300
+ function wrapArray$1(array, startIndex) {
301
+ return array.map((_, index) => array[(startIndex + index) % array.length]);
302
+ }
303
+ var Root = RovingFocusGroup;
304
+ var Item = RovingFocusGroupItem;
305
+
306
+ var SELECTION_KEYS = ["Enter", " "];
307
+ var FIRST_KEYS = ["ArrowDown", "PageUp", "Home"];
308
+ var LAST_KEYS = ["ArrowUp", "PageDown", "End"];
309
+ var FIRST_LAST_KEYS = [...FIRST_KEYS, ...LAST_KEYS];
310
+ var SUB_OPEN_KEYS = {
311
+ ltr: [...SELECTION_KEYS, "ArrowRight"],
312
+ rtl: [...SELECTION_KEYS, "ArrowLeft"]
313
+ };
314
+ var SUB_CLOSE_KEYS = {
315
+ ltr: ["ArrowLeft"],
316
+ rtl: ["ArrowRight"]
317
+ };
318
+ var MENU_NAME = "Menu";
319
+ var [Collection, useCollection, createCollectionScope] = createCollection(MENU_NAME);
320
+ var [createMenuContext, createMenuScope] = createContextScope(MENU_NAME, [
321
+ createCollectionScope,
322
+ createPopperScope,
323
+ createRovingFocusGroupScope
324
+ ]);
325
+ var usePopperScope = createPopperScope();
326
+ var useRovingFocusGroupScope = createRovingFocusGroupScope();
327
+ var [MenuProvider, useMenuContext] = createMenuContext(MENU_NAME);
328
+ var [MenuRootProvider, useMenuRootContext] = createMenuContext(MENU_NAME);
329
+ var Menu = (props) => {
330
+ const { __scopeMenu, open = false, children, dir, onOpenChange, modal = true } = props;
331
+ const popperScope = usePopperScope(__scopeMenu);
332
+ const [content, setContent] = React.useState(null);
333
+ const isUsingKeyboardRef = React.useRef(false);
334
+ const handleOpenChange = useCallbackRef(onOpenChange);
335
+ const direction = useDirection(dir);
336
+ React.useEffect(() => {
337
+ const handleKeyDown = () => {
338
+ isUsingKeyboardRef.current = true;
339
+ document.addEventListener("pointerdown", handlePointer, { capture: true, once: true });
340
+ document.addEventListener("pointermove", handlePointer, { capture: true, once: true });
341
+ };
342
+ const handlePointer = () => isUsingKeyboardRef.current = false;
343
+ document.addEventListener("keydown", handleKeyDown, { capture: true });
344
+ return () => {
345
+ document.removeEventListener("keydown", handleKeyDown, { capture: true });
346
+ document.removeEventListener("pointerdown", handlePointer, { capture: true });
347
+ document.removeEventListener("pointermove", handlePointer, { capture: true });
348
+ };
349
+ }, []);
350
+ return /* @__PURE__ */ jsx(Root2$1, { ...popperScope, children: /* @__PURE__ */ jsx(
351
+ MenuProvider,
352
+ {
353
+ scope: __scopeMenu,
354
+ open,
355
+ onOpenChange: handleOpenChange,
356
+ content,
357
+ onContentChange: setContent,
358
+ children: /* @__PURE__ */ jsx(
359
+ MenuRootProvider,
360
+ {
361
+ scope: __scopeMenu,
362
+ onClose: React.useCallback(() => handleOpenChange(false), [handleOpenChange]),
363
+ isUsingKeyboardRef,
364
+ dir: direction,
365
+ modal,
366
+ children
367
+ }
368
+ )
369
+ }
370
+ ) });
371
+ };
372
+ Menu.displayName = MENU_NAME;
373
+ var ANCHOR_NAME = "MenuAnchor";
374
+ var MenuAnchor = React.forwardRef(
375
+ (props, forwardedRef) => {
376
+ const { __scopeMenu, ...anchorProps } = props;
377
+ const popperScope = usePopperScope(__scopeMenu);
378
+ return /* @__PURE__ */ jsx(Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
379
+ }
380
+ );
381
+ MenuAnchor.displayName = ANCHOR_NAME;
382
+ var PORTAL_NAME$1 = "MenuPortal";
383
+ var [PortalProvider, usePortalContext] = createMenuContext(PORTAL_NAME$1, {
384
+ forceMount: void 0
385
+ });
386
+ var MenuPortal = (props) => {
387
+ const { __scopeMenu, forceMount, children, container } = props;
388
+ const context = useMenuContext(PORTAL_NAME$1, __scopeMenu);
389
+ return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopeMenu, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Portal$1, { asChild: true, container, children }) }) });
390
+ };
391
+ MenuPortal.displayName = PORTAL_NAME$1;
392
+ var CONTENT_NAME$1 = "MenuContent";
393
+ var [MenuContentProvider, useMenuContentContext] = createMenuContext(CONTENT_NAME$1);
394
+ var MenuContent = React.forwardRef(
395
+ (props, forwardedRef) => {
396
+ const portalContext = usePortalContext(CONTENT_NAME$1, props.__scopeMenu);
397
+ const { forceMount = portalContext.forceMount, ...contentProps } = props;
398
+ const context = useMenuContext(CONTENT_NAME$1, props.__scopeMenu);
399
+ const rootContext = useMenuRootContext(CONTENT_NAME$1, props.__scopeMenu);
400
+ 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 }) }) }) });
401
+ }
402
+ );
403
+ var MenuRootContentModal = React.forwardRef(
404
+ (props, forwardedRef) => {
405
+ const context = useMenuContext(CONTENT_NAME$1, props.__scopeMenu);
406
+ const ref = React.useRef(null);
407
+ const composedRefs = useComposedRefs(forwardedRef, ref);
408
+ React.useEffect(() => {
409
+ const content = ref.current;
410
+ if (content) return hideOthers(content);
411
+ }, []);
412
+ return /* @__PURE__ */ jsx(
413
+ MenuContentImpl,
414
+ {
415
+ ...props,
416
+ ref: composedRefs,
417
+ trapFocus: context.open,
418
+ disableOutsidePointerEvents: context.open,
419
+ disableOutsideScroll: true,
420
+ onFocusOutside: composeEventHandlers(
421
+ props.onFocusOutside,
422
+ (event) => event.preventDefault(),
423
+ { checkForDefaultPrevented: false }
424
+ ),
425
+ onDismiss: () => context.onOpenChange(false)
426
+ }
427
+ );
428
+ }
429
+ );
430
+ var MenuRootContentNonModal = React.forwardRef((props, forwardedRef) => {
431
+ const context = useMenuContext(CONTENT_NAME$1, props.__scopeMenu);
432
+ return /* @__PURE__ */ jsx(
433
+ MenuContentImpl,
434
+ {
435
+ ...props,
436
+ ref: forwardedRef,
437
+ trapFocus: false,
438
+ disableOutsidePointerEvents: false,
439
+ disableOutsideScroll: false,
440
+ onDismiss: () => context.onOpenChange(false)
441
+ }
442
+ );
443
+ });
444
+ var Slot = createSlot("MenuContent.ScrollLock");
445
+ var MenuContentImpl = React.forwardRef(
446
+ (props, forwardedRef) => {
447
+ const {
448
+ __scopeMenu,
449
+ loop = false,
450
+ trapFocus,
451
+ onOpenAutoFocus,
452
+ onCloseAutoFocus,
453
+ disableOutsidePointerEvents,
454
+ onEntryFocus,
455
+ onEscapeKeyDown,
456
+ onPointerDownOutside,
457
+ onFocusOutside,
458
+ onInteractOutside,
459
+ onDismiss,
460
+ disableOutsideScroll,
461
+ ...contentProps
462
+ } = props;
463
+ const context = useMenuContext(CONTENT_NAME$1, __scopeMenu);
464
+ const rootContext = useMenuRootContext(CONTENT_NAME$1, __scopeMenu);
465
+ const popperScope = usePopperScope(__scopeMenu);
466
+ const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
467
+ const getItems = useCollection(__scopeMenu);
468
+ const [currentItemId, setCurrentItemId] = React.useState(null);
469
+ const contentRef = React.useRef(null);
470
+ const composedRefs = useComposedRefs(forwardedRef, contentRef, context.onContentChange);
471
+ const timerRef = React.useRef(0);
472
+ const searchRef = React.useRef("");
473
+ const pointerGraceTimerRef = React.useRef(0);
474
+ const pointerGraceIntentRef = React.useRef(null);
475
+ const pointerDirRef = React.useRef("right");
476
+ const lastPointerXRef = React.useRef(0);
477
+ const ScrollLockWrapper = disableOutsideScroll ? ReactRemoveScroll : React.Fragment;
478
+ const scrollLockWrapperProps = disableOutsideScroll ? { as: Slot, allowPinchZoom: true } : void 0;
479
+ const handleTypeaheadSearch = (key) => {
480
+ const search = searchRef.current + key;
481
+ const items = getItems().filter((item) => !item.disabled);
482
+ const currentItem = document.activeElement;
483
+ const currentMatch = items.find((item) => item.ref.current === currentItem)?.textValue;
484
+ const values = items.map((item) => item.textValue);
485
+ const nextMatch = getNextMatch(values, search, currentMatch);
486
+ const newItem = items.find((item) => item.textValue === nextMatch)?.ref.current;
487
+ (function updateSearch(value) {
488
+ searchRef.current = value;
489
+ window.clearTimeout(timerRef.current);
490
+ if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
491
+ })(search);
492
+ if (newItem) {
493
+ setTimeout(() => newItem.focus());
494
+ }
495
+ };
496
+ React.useEffect(() => {
497
+ return () => window.clearTimeout(timerRef.current);
498
+ }, []);
499
+ useFocusGuards();
500
+ const isPointerMovingToSubmenu = React.useCallback((event) => {
501
+ const isMovingTowards = pointerDirRef.current === pointerGraceIntentRef.current?.side;
502
+ return isMovingTowards && isPointerInGraceArea(event, pointerGraceIntentRef.current?.area);
503
+ }, []);
504
+ return /* @__PURE__ */ jsx(
505
+ MenuContentProvider,
506
+ {
507
+ scope: __scopeMenu,
508
+ searchRef,
509
+ onItemEnter: React.useCallback(
510
+ (event) => {
511
+ if (isPointerMovingToSubmenu(event)) event.preventDefault();
512
+ },
513
+ [isPointerMovingToSubmenu]
514
+ ),
515
+ onItemLeave: React.useCallback(
516
+ (event) => {
517
+ if (isPointerMovingToSubmenu(event)) return;
518
+ contentRef.current?.focus();
519
+ setCurrentItemId(null);
520
+ },
521
+ [isPointerMovingToSubmenu]
522
+ ),
523
+ onTriggerLeave: React.useCallback(
524
+ (event) => {
525
+ if (isPointerMovingToSubmenu(event)) event.preventDefault();
526
+ },
527
+ [isPointerMovingToSubmenu]
528
+ ),
529
+ pointerGraceTimerRef,
530
+ onPointerGraceIntentChange: React.useCallback((intent) => {
531
+ pointerGraceIntentRef.current = intent;
532
+ }, []),
533
+ children: /* @__PURE__ */ jsx(ScrollLockWrapper, { ...scrollLockWrapperProps, children: /* @__PURE__ */ jsx(
534
+ FocusScope,
535
+ {
536
+ asChild: true,
537
+ trapped: trapFocus,
538
+ onMountAutoFocus: composeEventHandlers(onOpenAutoFocus, (event) => {
539
+ event.preventDefault();
540
+ contentRef.current?.focus({ preventScroll: true });
541
+ }),
542
+ onUnmountAutoFocus: onCloseAutoFocus,
543
+ children: /* @__PURE__ */ jsx(
544
+ DismissableLayer,
545
+ {
546
+ asChild: true,
547
+ disableOutsidePointerEvents,
548
+ onEscapeKeyDown,
549
+ onPointerDownOutside,
550
+ onFocusOutside,
551
+ onInteractOutside,
552
+ onDismiss,
553
+ children: /* @__PURE__ */ jsx(
554
+ Root,
555
+ {
556
+ asChild: true,
557
+ ...rovingFocusGroupScope,
558
+ dir: rootContext.dir,
559
+ orientation: "vertical",
560
+ loop,
561
+ currentTabStopId: currentItemId,
562
+ onCurrentTabStopIdChange: setCurrentItemId,
563
+ onEntryFocus: composeEventHandlers(onEntryFocus, (event) => {
564
+ if (!rootContext.isUsingKeyboardRef.current) event.preventDefault();
565
+ }),
566
+ preventScrollOnEntryFocus: true,
567
+ children: /* @__PURE__ */ jsx(
568
+ Content,
569
+ {
570
+ role: "menu",
571
+ "aria-orientation": "vertical",
572
+ "data-state": getOpenState(context.open),
573
+ "data-radix-menu-content": "",
574
+ dir: rootContext.dir,
575
+ ...popperScope,
576
+ ...contentProps,
577
+ ref: composedRefs,
578
+ style: { outline: "none", ...contentProps.style },
579
+ onKeyDown: composeEventHandlers(contentProps.onKeyDown, (event) => {
580
+ const target = event.target;
581
+ const isKeyDownInside = target.closest("[data-radix-menu-content]") === event.currentTarget;
582
+ const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
583
+ const isCharacterKey = event.key.length === 1;
584
+ if (isKeyDownInside) {
585
+ if (event.key === "Tab") event.preventDefault();
586
+ if (!isModifierKey && isCharacterKey) handleTypeaheadSearch(event.key);
587
+ }
588
+ const content = contentRef.current;
589
+ if (event.target !== content) return;
590
+ if (!FIRST_LAST_KEYS.includes(event.key)) return;
591
+ event.preventDefault();
592
+ const items = getItems().filter((item) => !item.disabled);
593
+ const candidateNodes = items.map((item) => item.ref.current);
594
+ if (LAST_KEYS.includes(event.key)) candidateNodes.reverse();
595
+ focusFirst(candidateNodes);
596
+ }),
597
+ onBlur: composeEventHandlers(props.onBlur, (event) => {
598
+ if (!event.currentTarget.contains(event.target)) {
599
+ window.clearTimeout(timerRef.current);
600
+ searchRef.current = "";
601
+ }
602
+ }),
603
+ onPointerMove: composeEventHandlers(
604
+ props.onPointerMove,
605
+ whenMouse((event) => {
606
+ const target = event.target;
607
+ const pointerXHasChanged = lastPointerXRef.current !== event.clientX;
608
+ if (event.currentTarget.contains(target) && pointerXHasChanged) {
609
+ const newDir = event.clientX > lastPointerXRef.current ? "right" : "left";
610
+ pointerDirRef.current = newDir;
611
+ lastPointerXRef.current = event.clientX;
612
+ }
613
+ })
614
+ )
615
+ }
616
+ )
617
+ }
618
+ )
619
+ }
620
+ )
621
+ }
622
+ ) })
623
+ }
624
+ );
625
+ }
626
+ );
627
+ MenuContent.displayName = CONTENT_NAME$1;
628
+ var GROUP_NAME$1 = "MenuGroup";
629
+ var MenuGroup = React.forwardRef(
630
+ (props, forwardedRef) => {
631
+ const { __scopeMenu, ...groupProps } = props;
632
+ return /* @__PURE__ */ jsx(Primitive.div, { role: "group", ...groupProps, ref: forwardedRef });
633
+ }
634
+ );
635
+ MenuGroup.displayName = GROUP_NAME$1;
636
+ var LABEL_NAME$1 = "MenuLabel";
637
+ var MenuLabel = React.forwardRef(
638
+ (props, forwardedRef) => {
639
+ const { __scopeMenu, ...labelProps } = props;
640
+ return /* @__PURE__ */ jsx(Primitive.div, { ...labelProps, ref: forwardedRef });
641
+ }
642
+ );
643
+ MenuLabel.displayName = LABEL_NAME$1;
644
+ var ITEM_NAME$1 = "MenuItem";
645
+ var ITEM_SELECT = "menu.itemSelect";
646
+ var MenuItem = React.forwardRef(
647
+ (props, forwardedRef) => {
648
+ const { disabled = false, onSelect, ...itemProps } = props;
649
+ const ref = React.useRef(null);
650
+ const rootContext = useMenuRootContext(ITEM_NAME$1, props.__scopeMenu);
651
+ const contentContext = useMenuContentContext(ITEM_NAME$1, props.__scopeMenu);
652
+ const composedRefs = useComposedRefs(forwardedRef, ref);
653
+ const isPointerDownRef = React.useRef(false);
654
+ const handleSelect = () => {
655
+ const menuItem = ref.current;
656
+ if (!disabled && menuItem) {
657
+ const itemSelectEvent = new CustomEvent(ITEM_SELECT, { bubbles: true, cancelable: true });
658
+ menuItem.addEventListener(ITEM_SELECT, (event) => onSelect?.(event), { once: true });
659
+ dispatchDiscreteCustomEvent(menuItem, itemSelectEvent);
660
+ if (itemSelectEvent.defaultPrevented) {
661
+ isPointerDownRef.current = false;
662
+ } else {
663
+ rootContext.onClose();
664
+ }
665
+ }
666
+ };
667
+ return /* @__PURE__ */ jsx(
668
+ MenuItemImpl,
669
+ {
670
+ ...itemProps,
671
+ ref: composedRefs,
672
+ disabled,
673
+ onClick: composeEventHandlers(props.onClick, handleSelect),
674
+ onPointerDown: (event) => {
675
+ props.onPointerDown?.(event);
676
+ isPointerDownRef.current = true;
677
+ },
678
+ onPointerUp: composeEventHandlers(props.onPointerUp, (event) => {
679
+ if (!isPointerDownRef.current) event.currentTarget?.click();
680
+ }),
681
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
682
+ const isTypingAhead = contentContext.searchRef.current !== "";
683
+ if (disabled || isTypingAhead && event.key === " ") return;
684
+ if (SELECTION_KEYS.includes(event.key)) {
685
+ event.currentTarget.click();
686
+ event.preventDefault();
687
+ }
688
+ })
689
+ }
690
+ );
691
+ }
692
+ );
693
+ MenuItem.displayName = ITEM_NAME$1;
694
+ var MenuItemImpl = React.forwardRef(
695
+ (props, forwardedRef) => {
696
+ const { __scopeMenu, disabled = false, textValue, ...itemProps } = props;
697
+ const contentContext = useMenuContentContext(ITEM_NAME$1, __scopeMenu);
698
+ const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
699
+ const ref = React.useRef(null);
700
+ const composedRefs = useComposedRefs(forwardedRef, ref);
701
+ const [isFocused, setIsFocused] = React.useState(false);
702
+ const [textContent, setTextContent] = React.useState("");
703
+ React.useEffect(() => {
704
+ const menuItem = ref.current;
705
+ if (menuItem) {
706
+ setTextContent((menuItem.textContent ?? "").trim());
707
+ }
708
+ }, [itemProps.children]);
709
+ return /* @__PURE__ */ jsx(
710
+ Collection.ItemSlot,
711
+ {
712
+ scope: __scopeMenu,
713
+ disabled,
714
+ textValue: textValue ?? textContent,
715
+ children: /* @__PURE__ */ jsx(Item, { asChild: true, ...rovingFocusGroupScope, focusable: !disabled, children: /* @__PURE__ */ jsx(
716
+ Primitive.div,
717
+ {
718
+ role: "menuitem",
719
+ "data-highlighted": isFocused ? "" : void 0,
720
+ "aria-disabled": disabled || void 0,
721
+ "data-disabled": disabled ? "" : void 0,
722
+ ...itemProps,
723
+ ref: composedRefs,
724
+ onPointerMove: composeEventHandlers(
725
+ props.onPointerMove,
726
+ whenMouse((event) => {
727
+ if (disabled) {
728
+ contentContext.onItemLeave(event);
729
+ } else {
730
+ contentContext.onItemEnter(event);
731
+ if (!event.defaultPrevented) {
732
+ const item = event.currentTarget;
733
+ item.focus({ preventScroll: true });
734
+ }
735
+ }
736
+ })
737
+ ),
738
+ onPointerLeave: composeEventHandlers(
739
+ props.onPointerLeave,
740
+ whenMouse((event) => contentContext.onItemLeave(event))
741
+ ),
742
+ onFocus: composeEventHandlers(props.onFocus, () => setIsFocused(true)),
743
+ onBlur: composeEventHandlers(props.onBlur, () => setIsFocused(false))
744
+ }
745
+ ) })
746
+ }
747
+ );
748
+ }
749
+ );
750
+ var CHECKBOX_ITEM_NAME$1 = "MenuCheckboxItem";
751
+ var MenuCheckboxItem = React.forwardRef(
752
+ (props, forwardedRef) => {
753
+ const { checked = false, onCheckedChange, ...checkboxItemProps } = props;
754
+ return /* @__PURE__ */ jsx(ItemIndicatorProvider, { scope: props.__scopeMenu, checked, children: /* @__PURE__ */ jsx(
755
+ MenuItem,
756
+ {
757
+ role: "menuitemcheckbox",
758
+ "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
759
+ ...checkboxItemProps,
760
+ ref: forwardedRef,
761
+ "data-state": getCheckedState(checked),
762
+ onSelect: composeEventHandlers(
763
+ checkboxItemProps.onSelect,
764
+ () => onCheckedChange?.(isIndeterminate(checked) ? true : !checked),
765
+ { checkForDefaultPrevented: false }
766
+ )
767
+ }
768
+ ) });
769
+ }
770
+ );
771
+ MenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME$1;
772
+ var RADIO_GROUP_NAME$1 = "MenuRadioGroup";
773
+ var [RadioGroupProvider, useRadioGroupContext] = createMenuContext(
774
+ RADIO_GROUP_NAME$1,
775
+ { value: void 0, onValueChange: () => {
776
+ } }
777
+ );
778
+ var MenuRadioGroup = React.forwardRef(
779
+ (props, forwardedRef) => {
780
+ const { value, onValueChange, ...groupProps } = props;
781
+ const handleValueChange = useCallbackRef(onValueChange);
782
+ return /* @__PURE__ */ jsx(RadioGroupProvider, { scope: props.__scopeMenu, value, onValueChange: handleValueChange, children: /* @__PURE__ */ jsx(MenuGroup, { ...groupProps, ref: forwardedRef }) });
783
+ }
784
+ );
785
+ MenuRadioGroup.displayName = RADIO_GROUP_NAME$1;
786
+ var RADIO_ITEM_NAME$1 = "MenuRadioItem";
787
+ var MenuRadioItem = React.forwardRef(
788
+ (props, forwardedRef) => {
789
+ const { value, ...radioItemProps } = props;
790
+ const context = useRadioGroupContext(RADIO_ITEM_NAME$1, props.__scopeMenu);
791
+ const checked = value === context.value;
792
+ return /* @__PURE__ */ jsx(ItemIndicatorProvider, { scope: props.__scopeMenu, checked, children: /* @__PURE__ */ jsx(
793
+ MenuItem,
794
+ {
795
+ role: "menuitemradio",
796
+ "aria-checked": checked,
797
+ ...radioItemProps,
798
+ ref: forwardedRef,
799
+ "data-state": getCheckedState(checked),
800
+ onSelect: composeEventHandlers(
801
+ radioItemProps.onSelect,
802
+ () => context.onValueChange?.(value),
803
+ { checkForDefaultPrevented: false }
804
+ )
805
+ }
806
+ ) });
807
+ }
808
+ );
809
+ MenuRadioItem.displayName = RADIO_ITEM_NAME$1;
810
+ var ITEM_INDICATOR_NAME = "MenuItemIndicator";
811
+ var [ItemIndicatorProvider, useItemIndicatorContext] = createMenuContext(
812
+ ITEM_INDICATOR_NAME,
813
+ { checked: false }
814
+ );
815
+ var MenuItemIndicator = React.forwardRef(
816
+ (props, forwardedRef) => {
817
+ const { __scopeMenu, forceMount, ...itemIndicatorProps } = props;
818
+ const indicatorContext = useItemIndicatorContext(ITEM_INDICATOR_NAME, __scopeMenu);
819
+ return /* @__PURE__ */ jsx(
820
+ Presence,
821
+ {
822
+ present: forceMount || isIndeterminate(indicatorContext.checked) || indicatorContext.checked === true,
823
+ children: /* @__PURE__ */ jsx(
824
+ Primitive.span,
825
+ {
826
+ ...itemIndicatorProps,
827
+ ref: forwardedRef,
828
+ "data-state": getCheckedState(indicatorContext.checked)
829
+ }
830
+ )
831
+ }
832
+ );
833
+ }
834
+ );
835
+ MenuItemIndicator.displayName = ITEM_INDICATOR_NAME;
836
+ var SEPARATOR_NAME$1 = "MenuSeparator";
837
+ var MenuSeparator = React.forwardRef(
838
+ (props, forwardedRef) => {
839
+ const { __scopeMenu, ...separatorProps } = props;
840
+ return /* @__PURE__ */ jsx(
841
+ Primitive.div,
842
+ {
843
+ role: "separator",
844
+ "aria-orientation": "horizontal",
845
+ ...separatorProps,
846
+ ref: forwardedRef
847
+ }
848
+ );
849
+ }
850
+ );
851
+ MenuSeparator.displayName = SEPARATOR_NAME$1;
852
+ var ARROW_NAME$1 = "MenuArrow";
853
+ var MenuArrow = React.forwardRef(
854
+ (props, forwardedRef) => {
855
+ const { __scopeMenu, ...arrowProps } = props;
856
+ const popperScope = usePopperScope(__scopeMenu);
857
+ return /* @__PURE__ */ jsx(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
858
+ }
859
+ );
860
+ MenuArrow.displayName = ARROW_NAME$1;
861
+ var SUB_NAME = "MenuSub";
862
+ var [MenuSubProvider, useMenuSubContext] = createMenuContext(SUB_NAME);
863
+ var MenuSub = (props) => {
864
+ const { __scopeMenu, children, open = false, onOpenChange } = props;
865
+ const parentMenuContext = useMenuContext(SUB_NAME, __scopeMenu);
866
+ const popperScope = usePopperScope(__scopeMenu);
867
+ const [trigger, setTrigger] = React.useState(null);
868
+ const [content, setContent] = React.useState(null);
869
+ const handleOpenChange = useCallbackRef(onOpenChange);
870
+ React.useEffect(() => {
871
+ if (parentMenuContext.open === false) handleOpenChange(false);
872
+ return () => handleOpenChange(false);
873
+ }, [parentMenuContext.open, handleOpenChange]);
874
+ return /* @__PURE__ */ jsx(Root2$1, { ...popperScope, children: /* @__PURE__ */ jsx(
875
+ MenuProvider,
876
+ {
877
+ scope: __scopeMenu,
878
+ open,
879
+ onOpenChange: handleOpenChange,
880
+ content,
881
+ onContentChange: setContent,
882
+ children: /* @__PURE__ */ jsx(
883
+ MenuSubProvider,
884
+ {
885
+ scope: __scopeMenu,
886
+ contentId: useId(),
887
+ triggerId: useId(),
888
+ trigger,
889
+ onTriggerChange: setTrigger,
890
+ children
891
+ }
892
+ )
893
+ }
894
+ ) });
895
+ };
896
+ MenuSub.displayName = SUB_NAME;
897
+ var SUB_TRIGGER_NAME$1 = "MenuSubTrigger";
898
+ var MenuSubTrigger = React.forwardRef(
899
+ (props, forwardedRef) => {
900
+ const context = useMenuContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
901
+ const rootContext = useMenuRootContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
902
+ const subContext = useMenuSubContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
903
+ const contentContext = useMenuContentContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
904
+ const openTimerRef = React.useRef(null);
905
+ const { pointerGraceTimerRef, onPointerGraceIntentChange } = contentContext;
906
+ const scope = { __scopeMenu: props.__scopeMenu };
907
+ const clearOpenTimer = React.useCallback(() => {
908
+ if (openTimerRef.current) window.clearTimeout(openTimerRef.current);
909
+ openTimerRef.current = null;
910
+ }, []);
911
+ React.useEffect(() => clearOpenTimer, [clearOpenTimer]);
912
+ React.useEffect(() => {
913
+ const pointerGraceTimer = pointerGraceTimerRef.current;
914
+ return () => {
915
+ window.clearTimeout(pointerGraceTimer);
916
+ onPointerGraceIntentChange(null);
917
+ };
918
+ }, [pointerGraceTimerRef, onPointerGraceIntentChange]);
919
+ return /* @__PURE__ */ jsx(MenuAnchor, { asChild: true, ...scope, children: /* @__PURE__ */ jsx(
920
+ MenuItemImpl,
921
+ {
922
+ id: subContext.triggerId,
923
+ "aria-haspopup": "menu",
924
+ "aria-expanded": context.open,
925
+ "aria-controls": subContext.contentId,
926
+ "data-state": getOpenState(context.open),
927
+ ...props,
928
+ ref: composeRefs(forwardedRef, subContext.onTriggerChange),
929
+ onClick: (event) => {
930
+ props.onClick?.(event);
931
+ if (props.disabled || event.defaultPrevented) return;
932
+ event.currentTarget.focus();
933
+ if (!context.open) context.onOpenChange(true);
934
+ },
935
+ onPointerMove: composeEventHandlers(
936
+ props.onPointerMove,
937
+ whenMouse((event) => {
938
+ contentContext.onItemEnter(event);
939
+ if (event.defaultPrevented) return;
940
+ if (!props.disabled && !context.open && !openTimerRef.current) {
941
+ contentContext.onPointerGraceIntentChange(null);
942
+ openTimerRef.current = window.setTimeout(() => {
943
+ context.onOpenChange(true);
944
+ clearOpenTimer();
945
+ }, 100);
946
+ }
947
+ })
948
+ ),
949
+ onPointerLeave: composeEventHandlers(
950
+ props.onPointerLeave,
951
+ whenMouse((event) => {
952
+ clearOpenTimer();
953
+ const contentRect = context.content?.getBoundingClientRect();
954
+ if (contentRect) {
955
+ const side = context.content?.dataset.side;
956
+ const rightSide = side === "right";
957
+ const bleed = rightSide ? -5 : 5;
958
+ const contentNearEdge = contentRect[rightSide ? "left" : "right"];
959
+ const contentFarEdge = contentRect[rightSide ? "right" : "left"];
960
+ contentContext.onPointerGraceIntentChange({
961
+ area: [
962
+ // Apply a bleed on clientX to ensure that our exit point is
963
+ // consistently within polygon bounds
964
+ { x: event.clientX + bleed, y: event.clientY },
965
+ { x: contentNearEdge, y: contentRect.top },
966
+ { x: contentFarEdge, y: contentRect.top },
967
+ { x: contentFarEdge, y: contentRect.bottom },
968
+ { x: contentNearEdge, y: contentRect.bottom }
969
+ ],
970
+ side
971
+ });
972
+ window.clearTimeout(pointerGraceTimerRef.current);
973
+ pointerGraceTimerRef.current = window.setTimeout(
974
+ () => contentContext.onPointerGraceIntentChange(null),
975
+ 300
976
+ );
977
+ } else {
978
+ contentContext.onTriggerLeave(event);
979
+ if (event.defaultPrevented) return;
980
+ contentContext.onPointerGraceIntentChange(null);
981
+ }
982
+ })
983
+ ),
984
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
985
+ const isTypingAhead = contentContext.searchRef.current !== "";
986
+ if (props.disabled || isTypingAhead && event.key === " ") return;
987
+ if (SUB_OPEN_KEYS[rootContext.dir].includes(event.key)) {
988
+ context.onOpenChange(true);
989
+ context.content?.focus();
990
+ event.preventDefault();
991
+ }
992
+ })
993
+ }
994
+ ) });
995
+ }
996
+ );
997
+ MenuSubTrigger.displayName = SUB_TRIGGER_NAME$1;
998
+ var SUB_CONTENT_NAME$1 = "MenuSubContent";
999
+ var MenuSubContent = React.forwardRef(
1000
+ (props, forwardedRef) => {
1001
+ const portalContext = usePortalContext(CONTENT_NAME$1, props.__scopeMenu);
1002
+ const { forceMount = portalContext.forceMount, ...subContentProps } = props;
1003
+ const context = useMenuContext(CONTENT_NAME$1, props.__scopeMenu);
1004
+ const rootContext = useMenuRootContext(CONTENT_NAME$1, props.__scopeMenu);
1005
+ const subContext = useMenuSubContext(SUB_CONTENT_NAME$1, props.__scopeMenu);
1006
+ const ref = React.useRef(null);
1007
+ const composedRefs = useComposedRefs(forwardedRef, ref);
1008
+ 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(
1009
+ MenuContentImpl,
1010
+ {
1011
+ id: subContext.contentId,
1012
+ "aria-labelledby": subContext.triggerId,
1013
+ ...subContentProps,
1014
+ ref: composedRefs,
1015
+ align: "start",
1016
+ side: rootContext.dir === "rtl" ? "left" : "right",
1017
+ disableOutsidePointerEvents: false,
1018
+ disableOutsideScroll: false,
1019
+ trapFocus: false,
1020
+ onOpenAutoFocus: (event) => {
1021
+ if (rootContext.isUsingKeyboardRef.current) ref.current?.focus();
1022
+ event.preventDefault();
1023
+ },
1024
+ onCloseAutoFocus: (event) => event.preventDefault(),
1025
+ onFocusOutside: composeEventHandlers(props.onFocusOutside, (event) => {
1026
+ if (event.target !== subContext.trigger) context.onOpenChange(false);
1027
+ }),
1028
+ onEscapeKeyDown: composeEventHandlers(props.onEscapeKeyDown, (event) => {
1029
+ rootContext.onClose();
1030
+ event.preventDefault();
1031
+ }),
1032
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
1033
+ const isKeyDownInside = event.currentTarget.contains(event.target);
1034
+ const isCloseKey = SUB_CLOSE_KEYS[rootContext.dir].includes(event.key);
1035
+ if (isKeyDownInside && isCloseKey) {
1036
+ context.onOpenChange(false);
1037
+ subContext.trigger?.focus();
1038
+ event.preventDefault();
1039
+ }
1040
+ })
1041
+ }
1042
+ ) }) }) });
1043
+ }
1044
+ );
1045
+ MenuSubContent.displayName = SUB_CONTENT_NAME$1;
1046
+ function getOpenState(open) {
1047
+ return open ? "open" : "closed";
1048
+ }
1049
+ function isIndeterminate(checked) {
1050
+ return checked === "indeterminate";
1051
+ }
1052
+ function getCheckedState(checked) {
1053
+ return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
1054
+ }
1055
+ function focusFirst(candidates) {
1056
+ const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
1057
+ for (const candidate of candidates) {
1058
+ if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
1059
+ candidate.focus();
1060
+ if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
1061
+ }
1062
+ }
1063
+ function wrapArray(array, startIndex) {
1064
+ return array.map((_, index) => array[(startIndex + index) % array.length]);
1065
+ }
1066
+ function getNextMatch(values, search, currentMatch) {
1067
+ const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
1068
+ const normalizedSearch = isRepeated ? search[0] : search;
1069
+ const currentMatchIndex = currentMatch ? values.indexOf(currentMatch) : -1;
1070
+ let wrappedValues = wrapArray(values, Math.max(currentMatchIndex, 0));
1071
+ const excludeCurrentMatch = normalizedSearch.length === 1;
1072
+ if (excludeCurrentMatch) wrappedValues = wrappedValues.filter((v) => v !== currentMatch);
1073
+ const nextMatch = wrappedValues.find(
1074
+ (value) => value.toLowerCase().startsWith(normalizedSearch.toLowerCase())
1075
+ );
1076
+ return nextMatch !== currentMatch ? nextMatch : void 0;
1077
+ }
1078
+ function isPointInPolygon(point, polygon) {
1079
+ const { x, y } = point;
1080
+ let inside = false;
1081
+ for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
1082
+ const ii = polygon[i];
1083
+ const jj = polygon[j];
1084
+ const xi = ii.x;
1085
+ const yi = ii.y;
1086
+ const xj = jj.x;
1087
+ const yj = jj.y;
1088
+ const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
1089
+ if (intersect) inside = !inside;
1090
+ }
1091
+ return inside;
1092
+ }
1093
+ function isPointerInGraceArea(event, area) {
1094
+ if (!area) return false;
1095
+ const cursorPos = { x: event.clientX, y: event.clientY };
1096
+ return isPointInPolygon(cursorPos, area);
1097
+ }
1098
+ function whenMouse(handler) {
1099
+ return (event) => event.pointerType === "mouse" ? handler(event) : void 0;
1100
+ }
1101
+ var Root3 = Menu;
1102
+ var Anchor2 = MenuAnchor;
1103
+ var Portal = MenuPortal;
1104
+ var Content2$1 = MenuContent;
1105
+ var Group = MenuGroup;
1106
+ var Label = MenuLabel;
1107
+ var Item2$1 = MenuItem;
1108
+ var CheckboxItem = MenuCheckboxItem;
1109
+ var RadioGroup = MenuRadioGroup;
1110
+ var RadioItem = MenuRadioItem;
1111
+ var ItemIndicator = MenuItemIndicator;
1112
+ var Separator = MenuSeparator;
1113
+ var Arrow2 = MenuArrow;
1114
+ var Sub = MenuSub;
1115
+ var SubTrigger = MenuSubTrigger;
1116
+ var SubContent = MenuSubContent;
1117
+
1118
+ var DROPDOWN_MENU_NAME = "DropdownMenu";
1119
+ var [createDropdownMenuContext] = createContextScope(
1120
+ DROPDOWN_MENU_NAME,
1121
+ [createMenuScope]
1122
+ );
1123
+ var useMenuScope = createMenuScope();
1124
+ var [DropdownMenuProvider, useDropdownMenuContext] = createDropdownMenuContext(DROPDOWN_MENU_NAME);
1125
+ var DropdownMenu$2 = (props) => {
1126
+ const {
1127
+ __scopeDropdownMenu,
1128
+ children,
1129
+ dir,
1130
+ open: openProp,
1131
+ defaultOpen,
1132
+ onOpenChange,
1133
+ modal = true
1134
+ } = props;
1135
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1136
+ const triggerRef = React.useRef(null);
1137
+ const [open, setOpen] = useControllableState({
1138
+ prop: openProp,
1139
+ defaultProp: defaultOpen ?? false,
1140
+ onChange: onOpenChange,
1141
+ caller: DROPDOWN_MENU_NAME
1142
+ });
1143
+ return /* @__PURE__ */ jsx(
1144
+ DropdownMenuProvider,
1145
+ {
1146
+ scope: __scopeDropdownMenu,
1147
+ triggerId: useId(),
1148
+ triggerRef,
1149
+ contentId: useId(),
1150
+ open,
1151
+ onOpenChange: setOpen,
1152
+ onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
1153
+ modal,
1154
+ children: /* @__PURE__ */ jsx(Root3, { ...menuScope, open, onOpenChange: setOpen, dir, modal, children })
1155
+ }
1156
+ );
1157
+ };
1158
+ DropdownMenu$2.displayName = DROPDOWN_MENU_NAME;
1159
+ var TRIGGER_NAME = "DropdownMenuTrigger";
1160
+ var DropdownMenuTrigger$2 = React.forwardRef(
1161
+ (props, forwardedRef) => {
1162
+ const { __scopeDropdownMenu, disabled = false, ...triggerProps } = props;
1163
+ const context = useDropdownMenuContext(TRIGGER_NAME, __scopeDropdownMenu);
1164
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1165
+ return /* @__PURE__ */ jsx(Anchor2, { asChild: true, ...menuScope, children: /* @__PURE__ */ jsx(
1166
+ Primitive.button,
1167
+ {
1168
+ type: "button",
1169
+ id: context.triggerId,
1170
+ "aria-haspopup": "menu",
1171
+ "aria-expanded": context.open,
1172
+ "aria-controls": context.open ? context.contentId : void 0,
1173
+ "data-state": context.open ? "open" : "closed",
1174
+ "data-disabled": disabled ? "" : void 0,
1175
+ disabled,
1176
+ ...triggerProps,
1177
+ ref: composeRefs(forwardedRef, context.triggerRef),
1178
+ onPointerDown: composeEventHandlers(props.onPointerDown, (event) => {
1179
+ if (!disabled && event.button === 0 && event.ctrlKey === false) {
1180
+ context.onOpenToggle();
1181
+ if (!context.open) event.preventDefault();
1182
+ }
1183
+ }),
1184
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
1185
+ if (disabled) return;
1186
+ if (["Enter", " "].includes(event.key)) context.onOpenToggle();
1187
+ if (event.key === "ArrowDown") context.onOpenChange(true);
1188
+ if (["Enter", " ", "ArrowDown"].includes(event.key)) event.preventDefault();
1189
+ })
1190
+ }
1191
+ ) });
1192
+ }
1193
+ );
1194
+ DropdownMenuTrigger$2.displayName = TRIGGER_NAME;
1195
+ var PORTAL_NAME = "DropdownMenuPortal";
1196
+ var DropdownMenuPortal$2 = (props) => {
1197
+ const { __scopeDropdownMenu, ...portalProps } = props;
1198
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1199
+ return /* @__PURE__ */ jsx(Portal, { ...menuScope, ...portalProps });
1200
+ };
1201
+ DropdownMenuPortal$2.displayName = PORTAL_NAME;
1202
+ var CONTENT_NAME = "DropdownMenuContent";
1203
+ var DropdownMenuContent$2 = React.forwardRef(
1204
+ (props, forwardedRef) => {
1205
+ const { __scopeDropdownMenu, ...contentProps } = props;
1206
+ const context = useDropdownMenuContext(CONTENT_NAME, __scopeDropdownMenu);
1207
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1208
+ const hasInteractedOutsideRef = React.useRef(false);
1209
+ return /* @__PURE__ */ jsx(
1210
+ Content2$1,
1211
+ {
1212
+ id: context.contentId,
1213
+ "aria-labelledby": context.triggerId,
1214
+ ...menuScope,
1215
+ ...contentProps,
1216
+ ref: forwardedRef,
1217
+ onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
1218
+ if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
1219
+ hasInteractedOutsideRef.current = false;
1220
+ event.preventDefault();
1221
+ }),
1222
+ onInteractOutside: composeEventHandlers(props.onInteractOutside, (event) => {
1223
+ const originalEvent = event.detail.originalEvent;
1224
+ const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
1225
+ const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
1226
+ if (!context.modal || isRightClick) hasInteractedOutsideRef.current = true;
1227
+ }),
1228
+ style: {
1229
+ ...props.style,
1230
+ // re-namespace exposed content custom properties
1231
+ ...{
1232
+ "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
1233
+ "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
1234
+ "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
1235
+ "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
1236
+ "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
1237
+ }
1238
+ }
1239
+ }
1240
+ );
1241
+ }
1242
+ );
1243
+ DropdownMenuContent$2.displayName = CONTENT_NAME;
1244
+ var GROUP_NAME = "DropdownMenuGroup";
1245
+ var DropdownMenuGroup$2 = React.forwardRef(
1246
+ (props, forwardedRef) => {
1247
+ const { __scopeDropdownMenu, ...groupProps } = props;
1248
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1249
+ return /* @__PURE__ */ jsx(Group, { ...menuScope, ...groupProps, ref: forwardedRef });
1250
+ }
1251
+ );
1252
+ DropdownMenuGroup$2.displayName = GROUP_NAME;
1253
+ var LABEL_NAME = "DropdownMenuLabel";
1254
+ var DropdownMenuLabel$2 = React.forwardRef(
1255
+ (props, forwardedRef) => {
1256
+ const { __scopeDropdownMenu, ...labelProps } = props;
1257
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1258
+ return /* @__PURE__ */ jsx(Label, { ...menuScope, ...labelProps, ref: forwardedRef });
1259
+ }
1260
+ );
1261
+ DropdownMenuLabel$2.displayName = LABEL_NAME;
1262
+ var ITEM_NAME = "DropdownMenuItem";
1263
+ var DropdownMenuItem$2 = React.forwardRef(
1264
+ (props, forwardedRef) => {
1265
+ const { __scopeDropdownMenu, ...itemProps } = props;
1266
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1267
+ return /* @__PURE__ */ jsx(Item2$1, { ...menuScope, ...itemProps, ref: forwardedRef });
1268
+ }
1269
+ );
1270
+ DropdownMenuItem$2.displayName = ITEM_NAME;
1271
+ var CHECKBOX_ITEM_NAME = "DropdownMenuCheckboxItem";
1272
+ var DropdownMenuCheckboxItem$2 = React.forwardRef((props, forwardedRef) => {
1273
+ const { __scopeDropdownMenu, ...checkboxItemProps } = props;
1274
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1275
+ return /* @__PURE__ */ jsx(CheckboxItem, { ...menuScope, ...checkboxItemProps, ref: forwardedRef });
1276
+ });
1277
+ DropdownMenuCheckboxItem$2.displayName = CHECKBOX_ITEM_NAME;
1278
+ var RADIO_GROUP_NAME = "DropdownMenuRadioGroup";
1279
+ var DropdownMenuRadioGroup$2 = React.forwardRef((props, forwardedRef) => {
1280
+ const { __scopeDropdownMenu, ...radioGroupProps } = props;
1281
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1282
+ return /* @__PURE__ */ jsx(RadioGroup, { ...menuScope, ...radioGroupProps, ref: forwardedRef });
1283
+ });
1284
+ DropdownMenuRadioGroup$2.displayName = RADIO_GROUP_NAME;
1285
+ var RADIO_ITEM_NAME = "DropdownMenuRadioItem";
1286
+ var DropdownMenuRadioItem$2 = React.forwardRef((props, forwardedRef) => {
1287
+ const { __scopeDropdownMenu, ...radioItemProps } = props;
1288
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1289
+ return /* @__PURE__ */ jsx(RadioItem, { ...menuScope, ...radioItemProps, ref: forwardedRef });
1290
+ });
1291
+ DropdownMenuRadioItem$2.displayName = RADIO_ITEM_NAME;
1292
+ var INDICATOR_NAME = "DropdownMenuItemIndicator";
1293
+ var DropdownMenuItemIndicator = React.forwardRef((props, forwardedRef) => {
1294
+ const { __scopeDropdownMenu, ...itemIndicatorProps } = props;
1295
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1296
+ return /* @__PURE__ */ jsx(ItemIndicator, { ...menuScope, ...itemIndicatorProps, ref: forwardedRef });
1297
+ });
1298
+ DropdownMenuItemIndicator.displayName = INDICATOR_NAME;
1299
+ var SEPARATOR_NAME = "DropdownMenuSeparator";
1300
+ var DropdownMenuSeparator$2 = React.forwardRef((props, forwardedRef) => {
1301
+ const { __scopeDropdownMenu, ...separatorProps } = props;
1302
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1303
+ return /* @__PURE__ */ jsx(Separator, { ...menuScope, ...separatorProps, ref: forwardedRef });
1304
+ });
1305
+ DropdownMenuSeparator$2.displayName = SEPARATOR_NAME;
1306
+ var ARROW_NAME = "DropdownMenuArrow";
1307
+ var DropdownMenuArrow = React.forwardRef(
1308
+ (props, forwardedRef) => {
1309
+ const { __scopeDropdownMenu, ...arrowProps } = props;
1310
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1311
+ return /* @__PURE__ */ jsx(Arrow2, { ...menuScope, ...arrowProps, ref: forwardedRef });
1312
+ }
1313
+ );
1314
+ DropdownMenuArrow.displayName = ARROW_NAME;
1315
+ var DropdownMenuSub$2 = (props) => {
1316
+ const { __scopeDropdownMenu, children, open: openProp, onOpenChange, defaultOpen } = props;
1317
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1318
+ const [open, setOpen] = useControllableState({
1319
+ prop: openProp,
1320
+ defaultProp: defaultOpen ?? false,
1321
+ onChange: onOpenChange,
1322
+ caller: "DropdownMenuSub"
1323
+ });
1324
+ return /* @__PURE__ */ jsx(Sub, { ...menuScope, open, onOpenChange: setOpen, children });
1325
+ };
1326
+ var SUB_TRIGGER_NAME = "DropdownMenuSubTrigger";
1327
+ var DropdownMenuSubTrigger$2 = React.forwardRef((props, forwardedRef) => {
1328
+ const { __scopeDropdownMenu, ...subTriggerProps } = props;
1329
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1330
+ return /* @__PURE__ */ jsx(SubTrigger, { ...menuScope, ...subTriggerProps, ref: forwardedRef });
1331
+ });
1332
+ DropdownMenuSubTrigger$2.displayName = SUB_TRIGGER_NAME;
1333
+ var SUB_CONTENT_NAME = "DropdownMenuSubContent";
1334
+ var DropdownMenuSubContent$2 = React.forwardRef((props, forwardedRef) => {
1335
+ const { __scopeDropdownMenu, ...subContentProps } = props;
1336
+ const menuScope = useMenuScope(__scopeDropdownMenu);
1337
+ return /* @__PURE__ */ jsx(
1338
+ SubContent,
1339
+ {
1340
+ ...menuScope,
1341
+ ...subContentProps,
1342
+ ref: forwardedRef,
1343
+ style: {
1344
+ ...props.style,
1345
+ // re-namespace exposed content custom properties
1346
+ ...{
1347
+ "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
1348
+ "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
1349
+ "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
1350
+ "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
1351
+ "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
1352
+ }
1353
+ }
1354
+ }
1355
+ );
1356
+ });
1357
+ DropdownMenuSubContent$2.displayName = SUB_CONTENT_NAME;
1358
+ var Root2 = DropdownMenu$2;
1359
+ var Trigger = DropdownMenuTrigger$2;
1360
+ var Portal2 = DropdownMenuPortal$2;
1361
+ var Content2 = DropdownMenuContent$2;
1362
+ var Group2 = DropdownMenuGroup$2;
1363
+ var Label2 = DropdownMenuLabel$2;
1364
+ var Item2 = DropdownMenuItem$2;
1365
+ var CheckboxItem2 = DropdownMenuCheckboxItem$2;
1366
+ var RadioGroup2 = DropdownMenuRadioGroup$2;
1367
+ var RadioItem2 = DropdownMenuRadioItem$2;
1368
+ var ItemIndicator2 = DropdownMenuItemIndicator;
1369
+ var Separator2 = DropdownMenuSeparator$2;
1370
+ var Sub2 = DropdownMenuSub$2;
1371
+ var SubTrigger2 = DropdownMenuSubTrigger$2;
1372
+ var SubContent2 = DropdownMenuSubContent$2;
1373
+
1374
+ const DropdownMenu$1 = Root2;
1375
+ const DropdownMenuTrigger$1 = Trigger;
1376
+ const DropdownMenuGroup$1 = Group2;
1377
+ const DropdownMenuPortal$1 = Portal2;
1378
+ const DropdownMenuSub$1 = Sub2;
1379
+ const DropdownMenuRadioGroup$1 = RadioGroup2;
1380
+ const DropdownMenuSubTrigger$1 = React.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1381
+ SubTrigger2,
1382
+ {
1383
+ ref,
1384
+ className: cn(
1385
+ "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
1386
+ inset && "pl-8",
1387
+ className
1388
+ ),
1389
+ ...props,
1390
+ children: [
1391
+ children,
1392
+ /* @__PURE__ */ jsx(ChevronRight, { className: "ml-auto h-4 w-4" })
1393
+ ]
1394
+ }
1395
+ ));
1396
+ DropdownMenuSubTrigger$1.displayName = SubTrigger2.displayName;
1397
+ const DropdownMenuSubContent$1 = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1398
+ SubContent2,
1399
+ {
1400
+ ref,
1401
+ className: cn(
1402
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
1403
+ className
1404
+ ),
1405
+ ...props
1406
+ }
1407
+ ));
1408
+ DropdownMenuSubContent$1.displayName = SubContent2.displayName;
1409
+ const DropdownMenuContent$1 = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(Portal2, { children: /* @__PURE__ */ jsx(
1410
+ Content2,
1411
+ {
1412
+ ref,
1413
+ sideOffset,
1414
+ className: cn(
1415
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
1416
+ className
1417
+ ),
1418
+ ...props
1419
+ }
1420
+ ) }));
1421
+ DropdownMenuContent$1.displayName = Content2.displayName;
1422
+ const DropdownMenuItem$1 = React.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
1423
+ Item2,
1424
+ {
1425
+ ref,
1426
+ className: cn(
1427
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
1428
+ inset && "pl-8",
1429
+ className
1430
+ ),
1431
+ ...props
1432
+ }
1433
+ ));
1434
+ DropdownMenuItem$1.displayName = Item2.displayName;
1435
+ const DropdownMenuCheckboxItem$1 = React.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(
1436
+ CheckboxItem2,
1437
+ {
1438
+ ref,
1439
+ className: cn(
1440
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
1441
+ className
1442
+ ),
1443
+ checked,
1444
+ ...props,
1445
+ children: [
1446
+ /* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(ItemIndicator2, { children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) }) }),
1447
+ children
1448
+ ]
1449
+ }
1450
+ ));
1451
+ DropdownMenuCheckboxItem$1.displayName = CheckboxItem2.displayName;
1452
+ const DropdownMenuRadioItem$1 = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1453
+ RadioItem2,
1454
+ {
1455
+ ref,
1456
+ className: cn(
1457
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
1458
+ className
1459
+ ),
1460
+ ...props,
1461
+ children: [
1462
+ /* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(ItemIndicator2, { children: /* @__PURE__ */ jsx(Circle, { className: "h-2 w-2 fill-current" }) }) }),
1463
+ children
1464
+ ]
1465
+ }
1466
+ ));
1467
+ DropdownMenuRadioItem$1.displayName = RadioItem2.displayName;
1468
+ const DropdownMenuLabel$1 = React.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
1469
+ Label2,
1470
+ {
1471
+ ref,
1472
+ className: cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className),
1473
+ ...props
1474
+ }
1475
+ ));
1476
+ DropdownMenuLabel$1.displayName = Label2.displayName;
1477
+ const DropdownMenuSeparator$1 = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(Separator2, { ref, className: cn("-mx-1 my-2 h-px bg-border", className), ...props }));
1478
+ DropdownMenuSeparator$1.displayName = Separator2.displayName;
1479
+ const DropdownMenuShortcut$1 = ({ className, ...props }) => {
1480
+ return /* @__PURE__ */ jsx("span", { className: cn("ml-auto text-xs tracking-widest opacity-60", className), ...props });
1481
+ };
1482
+ DropdownMenuShortcut$1.displayName = "DropdownMenuShortcut";
1483
+
1484
+ const DropdownMenuRoot = DropdownMenu$1;
1485
+ const DropdownMenuCheckboxItem = DropdownMenuCheckboxItem$1;
1486
+ const DropdownMenuContent = DropdownMenuContent$1;
1487
+ const DropdownMenuGroup = DropdownMenuGroup$1;
1488
+ const DropdownMenuItem = DropdownMenuItem$1;
1489
+ const DropdownMenuLabel = DropdownMenuLabel$1;
1490
+ const DropdownMenuPortal = DropdownMenuPortal$1;
1491
+ const DropdownMenuRadioGroup = DropdownMenuRadioGroup$1;
1492
+ const DropdownMenuRadioItem = DropdownMenuRadioItem$1;
1493
+ const DropdownMenuSeparator = DropdownMenuSeparator$1;
1494
+ const DropdownMenuShortcut = DropdownMenuShortcut$1;
1495
+ const DropdownMenuSub = DropdownMenuSub$1;
1496
+ const DropdownMenuSubContent = DropdownMenuSubContent$1;
1497
+ const DropdownMenuSubTrigger = DropdownMenuSubTrigger$1;
1498
+ const DropdownMenuTrigger = DropdownMenuTrigger$1;
1499
+ const renderMenuItem = (item, index) => {
1500
+ switch (item.type) {
1501
+ case "separator":
1502
+ return /* @__PURE__ */ jsx(DropdownMenuSeparator, {}, item.id ?? `separator-${index}`);
1503
+ case "label":
1504
+ return /* @__PURE__ */ jsx(DropdownMenuLabel, { children: item.label }, item.id);
1505
+ case "item": {
1506
+ const Icon = item.icon;
1507
+ return /* @__PURE__ */ jsxs(
1508
+ DropdownMenuItem,
1509
+ {
1510
+ onClick: item.onClick,
1511
+ disabled: item.disabled,
1512
+ className: item.variant === "destructive" ? "text-destructive focus:text-destructive" : void 0,
1513
+ children: [
1514
+ Icon && /* @__PURE__ */ jsx(Icon, { className: "mr-2 h-4 w-4" }),
1515
+ /* @__PURE__ */ jsx("span", { children: item.label }),
1516
+ item.shortcut && /* @__PURE__ */ jsx(DropdownMenuShortcut, { children: item.shortcut })
1517
+ ]
1518
+ },
1519
+ item.id
1520
+ );
1521
+ }
1522
+ case "checkbox": {
1523
+ const Icon = item.icon;
1524
+ return /* @__PURE__ */ jsxs(
1525
+ DropdownMenuCheckboxItem,
1526
+ {
1527
+ checked: item.checked,
1528
+ onCheckedChange: item.onCheckedChange,
1529
+ disabled: item.disabled,
1530
+ children: [
1531
+ Icon && /* @__PURE__ */ jsx(Icon, { className: "mr-2 h-4 w-4" }),
1532
+ item.label
1533
+ ]
1534
+ },
1535
+ item.id
1536
+ );
1537
+ }
1538
+ case "radio-group":
1539
+ return /* @__PURE__ */ jsx(DropdownMenuRadioGroup, { value: item.value, onValueChange: item.onValueChange, children: item.items.map((radioItem) => {
1540
+ const Icon = radioItem.icon;
1541
+ return /* @__PURE__ */ jsxs(DropdownMenuRadioItem, { value: radioItem.value, disabled: radioItem.disabled, children: [
1542
+ Icon && /* @__PURE__ */ jsx(Icon, { className: "mr-2 h-4 w-4" }),
1543
+ radioItem.label
1544
+ ] }, radioItem.value);
1545
+ }) }, item.id);
1546
+ case "sub": {
1547
+ const Icon = item.icon;
1548
+ return /* @__PURE__ */ jsxs(DropdownMenuSub, { children: [
1549
+ /* @__PURE__ */ jsxs(DropdownMenuSubTrigger, { disabled: item.disabled, children: [
1550
+ Icon && /* @__PURE__ */ jsx(Icon, { className: "mr-2 h-4 w-4" }),
1551
+ /* @__PURE__ */ jsx("span", { children: item.label })
1552
+ ] }),
1553
+ /* @__PURE__ */ jsx(DropdownMenuPortal, { children: /* @__PURE__ */ jsx(DropdownMenuSubContent, { children: item.items.map((subItem, subIndex) => renderMenuItem(subItem, subIndex)) }) })
1554
+ ] }, item.id);
1555
+ }
1556
+ case "group":
1557
+ return /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
1558
+ item.label && /* @__PURE__ */ jsx(DropdownMenuLabel, { children: item.label }),
1559
+ item.items.map((groupItem, groupIndex) => renderMenuItem(groupItem, groupIndex))
1560
+ ] }, item.id);
1561
+ case "custom": {
1562
+ const content = typeof item.render === "function" ? item.render() : item.render;
1563
+ if (item.asMenuItem) {
1564
+ return /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: item.onClick, disabled: item.disabled, children: content }, item.id);
1565
+ }
1566
+ return /* @__PURE__ */ jsx(React.Fragment, { children: content }, item.id);
1567
+ }
1568
+ default:
1569
+ return null;
1570
+ }
1571
+ };
1572
+ const DropdownMenu = ({
1573
+ trigger,
1574
+ items,
1575
+ contentClassName,
1576
+ align = "end",
1577
+ side
1578
+ }) => {
1579
+ const TriggerIcon = trigger.icon;
1580
+ return /* @__PURE__ */ jsxs(DropdownMenuRoot, { children: [
1581
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: trigger.children ?? /* @__PURE__ */ jsxs(Button, { variant: trigger.variant, className: trigger.className, children: [
1582
+ TriggerIcon && /* @__PURE__ */ jsx(TriggerIcon, { className: "mr-2 h-4 w-4" }),
1583
+ trigger.label
1584
+ ] }) }),
1585
+ /* @__PURE__ */ jsx(DropdownMenuContent, { className: contentClassName, align, side, children: items.map((item, index) => renderMenuItem(item, index)) })
1586
+ ] });
1587
+ };
1588
+ DropdownMenu.displayName = "DropdownMenu";
1589
+
1590
+ export { DropdownMenuRoot as D, DropdownMenuCheckboxItem as a, DropdownMenuContent as b, DropdownMenuGroup as c, DropdownMenuItem as d, DropdownMenuLabel as e, DropdownMenuPortal as f, DropdownMenuRadioGroup as g, DropdownMenuRadioItem as h, DropdownMenuSeparator as i, DropdownMenuShortcut as j, DropdownMenuSub as k, DropdownMenuSubContent as l, DropdownMenuSubTrigger as m, DropdownMenuTrigger as n, DropdownMenu as o };
1591
+ //# sourceMappingURL=DropdownMenu.js.map