@yoopta/themes-shadcn 6.0.0-beta.12 → 6.0.0-beta.14

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 (108) hide show
  1. package/dist/accordion.js.map +1 -0
  2. package/dist/blockquote.js.map +1 -0
  3. package/dist/callout.js.map +1 -0
  4. package/dist/carousel.js.map +1 -0
  5. package/dist/chunks/Combination-2202c874.js +1080 -0
  6. package/dist/chunks/Combination-2202c874.js.map +1 -0
  7. package/dist/chunks/_tslib-514d60fe.js +67 -0
  8. package/dist/chunks/_tslib-514d60fe.js.map +1 -0
  9. package/dist/chunks/arrow-right-cc37c75c.js +30 -0
  10. package/dist/chunks/arrow-right-cc37c75c.js.map +1 -0
  11. package/dist/chunks/button-f9af7cb3.js +76 -0
  12. package/dist/chunks/button-f9af7cb3.js.map +1 -0
  13. package/dist/chunks/card-29720641.js +38 -0
  14. package/dist/chunks/card-29720641.js.map +1 -0
  15. package/dist/chunks/check-530fff0e.js +14 -0
  16. package/dist/chunks/check-530fff0e.js.map +1 -0
  17. package/dist/chunks/chevron-down-544d1acd.js +16 -0
  18. package/dist/chunks/chevron-down-544d1acd.js.map +1 -0
  19. package/dist/chunks/chevron-up-053cba03.js +14 -0
  20. package/dist/chunks/chevron-up-053cba03.js.map +1 -0
  21. package/dist/chunks/code-2ff9cc0c.js +17 -0
  22. package/dist/chunks/code-2ff9cc0c.js.map +1 -0
  23. package/dist/chunks/createLucideIcon-02eb7854.js +95 -0
  24. package/dist/chunks/createLucideIcon-02eb7854.js.map +1 -0
  25. package/dist/chunks/dropdown-menu-ac777fdc.js +1165 -0
  26. package/dist/chunks/dropdown-menu-ac777fdc.js.map +1 -0
  27. package/dist/chunks/external-link-43895ded.js +18 -0
  28. package/dist/chunks/external-link-43895ded.js.map +1 -0
  29. package/dist/chunks/file-text-99674d8d.js +20 -0
  30. package/dist/chunks/file-text-99674d8d.js.map +1 -0
  31. package/dist/chunks/hover-card-134f053d.js +257 -0
  32. package/dist/chunks/hover-card-134f053d.js.map +1 -0
  33. package/dist/chunks/index-056b596e.js +16 -0
  34. package/dist/chunks/index-056b596e.js.map +1 -0
  35. package/dist/chunks/index-35823769.js +222 -0
  36. package/dist/chunks/index-35823769.js.map +1 -0
  37. package/dist/chunks/index-41c4abc4.js +3805 -0
  38. package/dist/chunks/index-41c4abc4.js.map +1 -0
  39. package/dist/chunks/index-454935af.js +71 -0
  40. package/dist/chunks/index-454935af.js.map +1 -0
  41. package/dist/chunks/index-ae9b48d5.js +12 -0
  42. package/dist/chunks/index-ae9b48d5.js.map +1 -0
  43. package/dist/chunks/index-b8a83ba5.js +335 -0
  44. package/dist/chunks/index-b8a83ba5.js.map +1 -0
  45. package/dist/chunks/index-b8f2908d.js +40 -0
  46. package/dist/chunks/index-b8f2908d.js.map +1 -0
  47. package/dist/chunks/index-c655a86f.js +7 -0
  48. package/dist/chunks/index-c655a86f.js.map +1 -0
  49. package/dist/chunks/index-c90e54a4.js +190 -0
  50. package/dist/chunks/index-c90e54a4.js.map +1 -0
  51. package/dist/chunks/index-cf5f0d71.js +2907 -0
  52. package/dist/chunks/index-cf5f0d71.js.map +1 -0
  53. package/dist/chunks/index-d9171717.js +13 -0
  54. package/dist/chunks/index-d9171717.js.map +1 -0
  55. package/dist/chunks/index-dd0fd848.js +70 -0
  56. package/dist/chunks/index-dd0fd848.js.map +1 -0
  57. package/dist/chunks/input-5608c2c9.js +13 -0
  58. package/dist/chunks/input-5608c2c9.js.map +1 -0
  59. package/dist/chunks/label-c9152e49.js +168 -0
  60. package/dist/chunks/label-c9152e49.js.map +1 -0
  61. package/dist/chunks/language-select-bdc50f20.js +44 -0
  62. package/dist/chunks/language-select-bdc50f20.js.map +1 -0
  63. package/dist/chunks/play-1a34ad05.js +16 -0
  64. package/dist/chunks/play-1a34ad05.js.map +1 -0
  65. package/dist/chunks/plus-fcea2532.js +17 -0
  66. package/dist/chunks/plus-fcea2532.js.map +1 -0
  67. package/dist/chunks/popover-ef29b0ac.js +300 -0
  68. package/dist/chunks/popover-ef29b0ac.js.map +1 -0
  69. package/dist/chunks/scroll-area-17d8c584.js +726 -0
  70. package/dist/chunks/scroll-area-17d8c584.js.map +1 -0
  71. package/dist/chunks/select-98610101.js +1213 -0
  72. package/dist/chunks/select-98610101.js.map +1 -0
  73. package/dist/chunks/separator-9e6aa45b.js +172 -0
  74. package/dist/chunks/separator-9e6aa45b.js.map +1 -0
  75. package/dist/chunks/sparkles-8922a4af.js +26 -0
  76. package/dist/chunks/sparkles-8922a4af.js.map +1 -0
  77. package/dist/chunks/style-inject.es-746bb8ed.js +29 -0
  78. package/dist/chunks/style-inject.es-746bb8ed.js.map +1 -0
  79. package/dist/chunks/tabs-9cfbd3cc.js +204 -0
  80. package/dist/chunks/tabs-9cfbd3cc.js.map +1 -0
  81. package/dist/chunks/tooltip-f1e02ae0.js +800 -0
  82. package/dist/chunks/tooltip-f1e02ae0.js.map +1 -0
  83. package/dist/chunks/trash-2-be728dd2.js +20 -0
  84. package/dist/chunks/trash-2-be728dd2.js.map +1 -0
  85. package/dist/chunks/upload-0f56ec3e.js +44 -0
  86. package/dist/chunks/upload-0f56ec3e.js.map +1 -0
  87. package/dist/chunks/utils-131071a4.js +2500 -0
  88. package/dist/chunks/utils-131071a4.js.map +1 -0
  89. package/dist/chunks/x-2f6cf742.js +17 -0
  90. package/dist/chunks/x-2f6cf742.js.map +1 -0
  91. package/dist/code-group.js.map +1 -0
  92. package/dist/code.js.map +1 -0
  93. package/dist/divider.js.map +1 -0
  94. package/dist/embed.js.map +1 -0
  95. package/dist/file.js.map +1 -0
  96. package/dist/headings.js.map +1 -0
  97. package/dist/image.js.map +1 -0
  98. package/dist/index.js.map +1 -0
  99. package/dist/link.js.map +1 -0
  100. package/dist/lists.js.map +1 -0
  101. package/dist/mention.js.map +1 -0
  102. package/dist/paragraph.js.map +1 -0
  103. package/dist/steps.js.map +1 -0
  104. package/dist/table-of-contents.js.map +1 -0
  105. package/dist/table.js.map +1 -0
  106. package/dist/tabs.js.map +1 -0
  107. package/dist/video.js.map +1 -0
  108. package/package.json +2 -2
@@ -0,0 +1,1213 @@
1
+ import { c as createLucideIcon } from './createLucideIcon-02eb7854.js';
2
+ import { _ as __rest } from './_tslib-514d60fe.js';
3
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
4
+ import * as React from 'react';
5
+ import * as ReactDOM from 'react-dom';
6
+ import { c as clamp } from './index-c655a86f.js';
7
+ import { c as createContextScope, P as Primitive, a as composeEventHandlers, u as useLayoutEffect2, e as createSlot } from './index-b8a83ba5.js';
8
+ import { c as createCollection } from './index-dd0fd848.js';
9
+ import { u as useComposedRefs } from './index-b8f2908d.js';
10
+ import { u as useDirection } from './index-ae9b48d5.js';
11
+ import { c as createPopperScope, A as Anchor, D as DismissableLayer, C as Content, b as Arrow, R as Root2$1, P as Portal$1 } from './index-cf5f0d71.js';
12
+ import { h as hideOthers, u as useFocusGuards, R as RemoveScroll, F as FocusScope } from './Combination-2202c874.js';
13
+ import { u as useId } from './index-056b596e.js';
14
+ import { u as useCallbackRef } from './index-d9171717.js';
15
+ import { u as useControllableState } from './index-454935af.js';
16
+ import { V as VISUALLY_HIDDEN_STYLES } from './tooltip-f1e02ae0.js';
17
+ import { c as cn } from './utils-131071a4.js';
18
+ import { C as ChevronDown } from './chevron-down-544d1acd.js';
19
+ import { C as Check } from './check-530fff0e.js';
20
+ import { C as ChevronUp } from './chevron-up-053cba03.js';
21
+
22
+ /**
23
+ * @license lucide-react v0.378.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */
28
+
29
+
30
+ const Settings2 = createLucideIcon("Settings2", [
31
+ ["path", { d: "M20 7h-9", key: "3s1dr2" }],
32
+ ["path", { d: "M14 17H5", key: "gfn3mx" }],
33
+ ["circle", { cx: "17", cy: "17", r: "3", key: "18b49y" }],
34
+ ["circle", { cx: "7", cy: "7", r: "3", key: "dfmy0x" }]
35
+ ]);
36
+
37
+ // packages/react/use-previous/src/use-previous.tsx
38
+ function usePrevious(value) {
39
+ const ref = React.useRef({ value, previous: value });
40
+ return React.useMemo(() => {
41
+ if (ref.current.value !== value) {
42
+ ref.current.previous = ref.current.value;
43
+ ref.current.value = value;
44
+ }
45
+ return ref.current.previous;
46
+ }, [value]);
47
+ }
48
+
49
+ var OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
50
+ var SELECTION_KEYS = [" ", "Enter"];
51
+ var SELECT_NAME = "Select";
52
+ var [Collection, useCollection, createCollectionScope] = createCollection(SELECT_NAME);
53
+ var [createSelectContext, createSelectScope] = createContextScope(SELECT_NAME, [
54
+ createCollectionScope,
55
+ createPopperScope
56
+ ]);
57
+ var usePopperScope = createPopperScope();
58
+ var [SelectProvider, useSelectContext] = createSelectContext(SELECT_NAME);
59
+ var [SelectNativeOptionsProvider, useSelectNativeOptionsContext] = createSelectContext(SELECT_NAME);
60
+ var Select$1 = (props) => {
61
+ const {
62
+ __scopeSelect,
63
+ children,
64
+ open: openProp,
65
+ defaultOpen,
66
+ onOpenChange,
67
+ value: valueProp,
68
+ defaultValue,
69
+ onValueChange,
70
+ dir,
71
+ name,
72
+ autoComplete,
73
+ disabled,
74
+ required,
75
+ form
76
+ } = props;
77
+ const popperScope = usePopperScope(__scopeSelect);
78
+ const [trigger, setTrigger] = React.useState(null);
79
+ const [valueNode, setValueNode] = React.useState(null);
80
+ const [valueNodeHasChildren, setValueNodeHasChildren] = React.useState(false);
81
+ const direction = useDirection(dir);
82
+ const [open, setOpen] = useControllableState({
83
+ prop: openProp,
84
+ defaultProp: defaultOpen ?? false,
85
+ onChange: onOpenChange,
86
+ caller: SELECT_NAME
87
+ });
88
+ const [value, setValue] = useControllableState({
89
+ prop: valueProp,
90
+ defaultProp: defaultValue,
91
+ onChange: onValueChange,
92
+ caller: SELECT_NAME
93
+ });
94
+ const triggerPointerDownPosRef = React.useRef(null);
95
+ const isFormControl = trigger ? form || !!trigger.closest("form") : true;
96
+ const [nativeOptionsSet, setNativeOptionsSet] = React.useState(/* @__PURE__ */ new Set());
97
+ const nativeSelectKey = Array.from(nativeOptionsSet).map((option) => option.props.value).join(";");
98
+ return /* @__PURE__ */ jsx(Root2$1, { ...popperScope, children: /* @__PURE__ */ jsxs(
99
+ SelectProvider,
100
+ {
101
+ required,
102
+ scope: __scopeSelect,
103
+ trigger,
104
+ onTriggerChange: setTrigger,
105
+ valueNode,
106
+ onValueNodeChange: setValueNode,
107
+ valueNodeHasChildren,
108
+ onValueNodeHasChildrenChange: setValueNodeHasChildren,
109
+ contentId: useId(),
110
+ value,
111
+ onValueChange: setValue,
112
+ open,
113
+ onOpenChange: setOpen,
114
+ dir: direction,
115
+ triggerPointerDownPosRef,
116
+ disabled,
117
+ children: [
118
+ /* @__PURE__ */ jsx(Collection.Provider, { scope: __scopeSelect, children: /* @__PURE__ */ jsx(
119
+ SelectNativeOptionsProvider,
120
+ {
121
+ scope: props.__scopeSelect,
122
+ onNativeOptionAdd: React.useCallback((option) => {
123
+ setNativeOptionsSet((prev) => new Set(prev).add(option));
124
+ }, []),
125
+ onNativeOptionRemove: React.useCallback((option) => {
126
+ setNativeOptionsSet((prev) => {
127
+ const optionsSet = new Set(prev);
128
+ optionsSet.delete(option);
129
+ return optionsSet;
130
+ });
131
+ }, []),
132
+ children
133
+ }
134
+ ) }),
135
+ isFormControl ? /* @__PURE__ */ jsxs(
136
+ SelectBubbleInput,
137
+ {
138
+ "aria-hidden": true,
139
+ required,
140
+ tabIndex: -1,
141
+ name,
142
+ autoComplete,
143
+ value,
144
+ onChange: (event) => setValue(event.target.value),
145
+ disabled,
146
+ form,
147
+ children: [
148
+ value === void 0 ? /* @__PURE__ */ jsx("option", { value: "" }) : null,
149
+ Array.from(nativeOptionsSet)
150
+ ]
151
+ },
152
+ nativeSelectKey
153
+ ) : null
154
+ ]
155
+ }
156
+ ) });
157
+ };
158
+ Select$1.displayName = SELECT_NAME;
159
+ var TRIGGER_NAME = "SelectTrigger";
160
+ var SelectTrigger$1 = React.forwardRef(
161
+ (props, forwardedRef) => {
162
+ const { __scopeSelect, disabled = false, ...triggerProps } = props;
163
+ const popperScope = usePopperScope(__scopeSelect);
164
+ const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
165
+ const isDisabled = context.disabled || disabled;
166
+ const composedRefs = useComposedRefs(forwardedRef, context.onTriggerChange);
167
+ const getItems = useCollection(__scopeSelect);
168
+ const pointerTypeRef = React.useRef("touch");
169
+ const [searchRef, handleTypeaheadSearch, resetTypeahead] = useTypeaheadSearch((search) => {
170
+ const enabledItems = getItems().filter((item) => !item.disabled);
171
+ const currentItem = enabledItems.find((item) => item.value === context.value);
172
+ const nextItem = findNextItem(enabledItems, search, currentItem);
173
+ if (nextItem !== void 0) {
174
+ context.onValueChange(nextItem.value);
175
+ }
176
+ });
177
+ const handleOpen = (pointerEvent) => {
178
+ if (!isDisabled) {
179
+ context.onOpenChange(true);
180
+ resetTypeahead();
181
+ }
182
+ if (pointerEvent) {
183
+ context.triggerPointerDownPosRef.current = {
184
+ x: Math.round(pointerEvent.pageX),
185
+ y: Math.round(pointerEvent.pageY)
186
+ };
187
+ }
188
+ };
189
+ return /* @__PURE__ */ jsx(Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsx(
190
+ Primitive.button,
191
+ {
192
+ type: "button",
193
+ role: "combobox",
194
+ "aria-controls": context.contentId,
195
+ "aria-expanded": context.open,
196
+ "aria-required": context.required,
197
+ "aria-autocomplete": "none",
198
+ dir: context.dir,
199
+ "data-state": context.open ? "open" : "closed",
200
+ disabled: isDisabled,
201
+ "data-disabled": isDisabled ? "" : void 0,
202
+ "data-placeholder": shouldShowPlaceholder(context.value) ? "" : void 0,
203
+ ...triggerProps,
204
+ ref: composedRefs,
205
+ onClick: composeEventHandlers(triggerProps.onClick, (event) => {
206
+ event.currentTarget.focus();
207
+ if (pointerTypeRef.current !== "mouse") {
208
+ handleOpen(event);
209
+ }
210
+ }),
211
+ onPointerDown: composeEventHandlers(triggerProps.onPointerDown, (event) => {
212
+ pointerTypeRef.current = event.pointerType;
213
+ const target = event.target;
214
+ if (target.hasPointerCapture(event.pointerId)) {
215
+ target.releasePointerCapture(event.pointerId);
216
+ }
217
+ if (event.button === 0 && event.ctrlKey === false && event.pointerType === "mouse") {
218
+ handleOpen(event);
219
+ event.preventDefault();
220
+ }
221
+ }),
222
+ onKeyDown: composeEventHandlers(triggerProps.onKeyDown, (event) => {
223
+ const isTypingAhead = searchRef.current !== "";
224
+ const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
225
+ if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
226
+ if (isTypingAhead && event.key === " ") return;
227
+ if (OPEN_KEYS.includes(event.key)) {
228
+ handleOpen();
229
+ event.preventDefault();
230
+ }
231
+ })
232
+ }
233
+ ) });
234
+ }
235
+ );
236
+ SelectTrigger$1.displayName = TRIGGER_NAME;
237
+ var VALUE_NAME = "SelectValue";
238
+ var SelectValue$1 = React.forwardRef(
239
+ (props, forwardedRef) => {
240
+ const { __scopeSelect, className, style, children, placeholder = "", ...valueProps } = props;
241
+ const context = useSelectContext(VALUE_NAME, __scopeSelect);
242
+ const { onValueNodeHasChildrenChange } = context;
243
+ const hasChildren = children !== void 0;
244
+ const composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange);
245
+ useLayoutEffect2(() => {
246
+ onValueNodeHasChildrenChange(hasChildren);
247
+ }, [onValueNodeHasChildrenChange, hasChildren]);
248
+ return /* @__PURE__ */ jsx(
249
+ Primitive.span,
250
+ {
251
+ ...valueProps,
252
+ ref: composedRefs,
253
+ style: { pointerEvents: "none" },
254
+ children: shouldShowPlaceholder(context.value) ? /* @__PURE__ */ jsx(Fragment, { children: placeholder }) : children
255
+ }
256
+ );
257
+ }
258
+ );
259
+ SelectValue$1.displayName = VALUE_NAME;
260
+ var ICON_NAME = "SelectIcon";
261
+ var SelectIcon = React.forwardRef(
262
+ (props, forwardedRef) => {
263
+ const { __scopeSelect, children, ...iconProps } = props;
264
+ return /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...iconProps, ref: forwardedRef, children: children || "\u25BC" });
265
+ }
266
+ );
267
+ SelectIcon.displayName = ICON_NAME;
268
+ var PORTAL_NAME = "SelectPortal";
269
+ var SelectPortal = (props) => {
270
+ return /* @__PURE__ */ jsx(Portal$1, { asChild: true, ...props });
271
+ };
272
+ SelectPortal.displayName = PORTAL_NAME;
273
+ var CONTENT_NAME = "SelectContent";
274
+ var SelectContent$1 = React.forwardRef(
275
+ (props, forwardedRef) => {
276
+ const context = useSelectContext(CONTENT_NAME, props.__scopeSelect);
277
+ const [fragment, setFragment] = React.useState();
278
+ useLayoutEffect2(() => {
279
+ setFragment(new DocumentFragment());
280
+ }, []);
281
+ if (!context.open) {
282
+ const frag = fragment;
283
+ return frag ? ReactDOM.createPortal(
284
+ /* @__PURE__ */ jsx(SelectContentProvider, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsx(Collection.Slot, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsx("div", { children: props.children }) }) }),
285
+ frag
286
+ ) : null;
287
+ }
288
+ return /* @__PURE__ */ jsx(SelectContentImpl, { ...props, ref: forwardedRef });
289
+ }
290
+ );
291
+ SelectContent$1.displayName = CONTENT_NAME;
292
+ var CONTENT_MARGIN = 10;
293
+ var [SelectContentProvider, useSelectContentContext] = createSelectContext(CONTENT_NAME);
294
+ var CONTENT_IMPL_NAME = "SelectContentImpl";
295
+ var Slot = createSlot("SelectContent.RemoveScroll");
296
+ var SelectContentImpl = React.forwardRef(
297
+ (props, forwardedRef) => {
298
+ const {
299
+ __scopeSelect,
300
+ position = "item-aligned",
301
+ onCloseAutoFocus,
302
+ onEscapeKeyDown,
303
+ onPointerDownOutside,
304
+ //
305
+ // PopperContent props
306
+ side,
307
+ sideOffset,
308
+ align,
309
+ alignOffset,
310
+ arrowPadding,
311
+ collisionBoundary,
312
+ collisionPadding,
313
+ sticky,
314
+ hideWhenDetached,
315
+ avoidCollisions,
316
+ //
317
+ ...contentProps
318
+ } = props;
319
+ const context = useSelectContext(CONTENT_NAME, __scopeSelect);
320
+ const [content, setContent] = React.useState(null);
321
+ const [viewport, setViewport] = React.useState(null);
322
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
323
+ const [selectedItem, setSelectedItem] = React.useState(null);
324
+ const [selectedItemText, setSelectedItemText] = React.useState(
325
+ null
326
+ );
327
+ const getItems = useCollection(__scopeSelect);
328
+ const [isPositioned, setIsPositioned] = React.useState(false);
329
+ const firstValidItemFoundRef = React.useRef(false);
330
+ React.useEffect(() => {
331
+ if (content) return hideOthers(content);
332
+ }, [content]);
333
+ useFocusGuards();
334
+ const focusFirst = React.useCallback(
335
+ (candidates) => {
336
+ const [firstItem, ...restItems] = getItems().map((item) => item.ref.current);
337
+ const [lastItem] = restItems.slice(-1);
338
+ const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
339
+ for (const candidate of candidates) {
340
+ if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
341
+ candidate?.scrollIntoView({ block: "nearest" });
342
+ if (candidate === firstItem && viewport) viewport.scrollTop = 0;
343
+ if (candidate === lastItem && viewport) viewport.scrollTop = viewport.scrollHeight;
344
+ candidate?.focus();
345
+ if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
346
+ }
347
+ },
348
+ [getItems, viewport]
349
+ );
350
+ const focusSelectedItem = React.useCallback(
351
+ () => focusFirst([selectedItem, content]),
352
+ [focusFirst, selectedItem, content]
353
+ );
354
+ React.useEffect(() => {
355
+ if (isPositioned) {
356
+ focusSelectedItem();
357
+ }
358
+ }, [isPositioned, focusSelectedItem]);
359
+ const { onOpenChange, triggerPointerDownPosRef } = context;
360
+ React.useEffect(() => {
361
+ if (content) {
362
+ let pointerMoveDelta = { x: 0, y: 0 };
363
+ const handlePointerMove = (event) => {
364
+ pointerMoveDelta = {
365
+ x: Math.abs(Math.round(event.pageX) - (triggerPointerDownPosRef.current?.x ?? 0)),
366
+ y: Math.abs(Math.round(event.pageY) - (triggerPointerDownPosRef.current?.y ?? 0))
367
+ };
368
+ };
369
+ const handlePointerUp = (event) => {
370
+ if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) {
371
+ event.preventDefault();
372
+ } else {
373
+ if (!content.contains(event.target)) {
374
+ onOpenChange(false);
375
+ }
376
+ }
377
+ document.removeEventListener("pointermove", handlePointerMove);
378
+ triggerPointerDownPosRef.current = null;
379
+ };
380
+ if (triggerPointerDownPosRef.current !== null) {
381
+ document.addEventListener("pointermove", handlePointerMove);
382
+ document.addEventListener("pointerup", handlePointerUp, { capture: true, once: true });
383
+ }
384
+ return () => {
385
+ document.removeEventListener("pointermove", handlePointerMove);
386
+ document.removeEventListener("pointerup", handlePointerUp, { capture: true });
387
+ };
388
+ }
389
+ }, [content, onOpenChange, triggerPointerDownPosRef]);
390
+ React.useEffect(() => {
391
+ const close = () => onOpenChange(false);
392
+ window.addEventListener("blur", close);
393
+ window.addEventListener("resize", close);
394
+ return () => {
395
+ window.removeEventListener("blur", close);
396
+ window.removeEventListener("resize", close);
397
+ };
398
+ }, [onOpenChange]);
399
+ const [searchRef, handleTypeaheadSearch] = useTypeaheadSearch((search) => {
400
+ const enabledItems = getItems().filter((item) => !item.disabled);
401
+ const currentItem = enabledItems.find((item) => item.ref.current === document.activeElement);
402
+ const nextItem = findNextItem(enabledItems, search, currentItem);
403
+ if (nextItem) {
404
+ setTimeout(() => nextItem.ref.current.focus());
405
+ }
406
+ });
407
+ const itemRefCallback = React.useCallback(
408
+ (node, value, disabled) => {
409
+ const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
410
+ const isSelectedItem = context.value !== void 0 && context.value === value;
411
+ if (isSelectedItem || isFirstValidItem) {
412
+ setSelectedItem(node);
413
+ if (isFirstValidItem) firstValidItemFoundRef.current = true;
414
+ }
415
+ },
416
+ [context.value]
417
+ );
418
+ const handleItemLeave = React.useCallback(() => content?.focus(), [content]);
419
+ const itemTextRefCallback = React.useCallback(
420
+ (node, value, disabled) => {
421
+ const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
422
+ const isSelectedItem = context.value !== void 0 && context.value === value;
423
+ if (isSelectedItem || isFirstValidItem) {
424
+ setSelectedItemText(node);
425
+ }
426
+ },
427
+ [context.value]
428
+ );
429
+ const SelectPosition = position === "popper" ? SelectPopperPosition : SelectItemAlignedPosition;
430
+ const popperContentProps = SelectPosition === SelectPopperPosition ? {
431
+ side,
432
+ sideOffset,
433
+ align,
434
+ alignOffset,
435
+ arrowPadding,
436
+ collisionBoundary,
437
+ collisionPadding,
438
+ sticky,
439
+ hideWhenDetached,
440
+ avoidCollisions
441
+ } : {};
442
+ return /* @__PURE__ */ jsx(
443
+ SelectContentProvider,
444
+ {
445
+ scope: __scopeSelect,
446
+ content,
447
+ viewport,
448
+ onViewportChange: setViewport,
449
+ itemRefCallback,
450
+ selectedItem,
451
+ onItemLeave: handleItemLeave,
452
+ itemTextRefCallback,
453
+ focusSelectedItem,
454
+ selectedItemText,
455
+ position,
456
+ isPositioned,
457
+ searchRef,
458
+ children: /* @__PURE__ */ jsx(RemoveScroll, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsx(
459
+ FocusScope,
460
+ {
461
+ asChild: true,
462
+ trapped: context.open,
463
+ onMountAutoFocus: (event) => {
464
+ event.preventDefault();
465
+ },
466
+ onUnmountAutoFocus: composeEventHandlers(onCloseAutoFocus, (event) => {
467
+ context.trigger?.focus({ preventScroll: true });
468
+ event.preventDefault();
469
+ }),
470
+ children: /* @__PURE__ */ jsx(
471
+ DismissableLayer,
472
+ {
473
+ asChild: true,
474
+ disableOutsidePointerEvents: true,
475
+ onEscapeKeyDown,
476
+ onPointerDownOutside,
477
+ onFocusOutside: (event) => event.preventDefault(),
478
+ onDismiss: () => context.onOpenChange(false),
479
+ children: /* @__PURE__ */ jsx(
480
+ SelectPosition,
481
+ {
482
+ role: "listbox",
483
+ id: context.contentId,
484
+ "data-state": context.open ? "open" : "closed",
485
+ dir: context.dir,
486
+ onContextMenu: (event) => event.preventDefault(),
487
+ ...contentProps,
488
+ ...popperContentProps,
489
+ onPlaced: () => setIsPositioned(true),
490
+ ref: composedRefs,
491
+ style: {
492
+ // flex layout so we can place the scroll buttons properly
493
+ display: "flex",
494
+ flexDirection: "column",
495
+ // reset the outline by default as the content MAY get focused
496
+ outline: "none",
497
+ ...contentProps.style
498
+ },
499
+ onKeyDown: composeEventHandlers(contentProps.onKeyDown, (event) => {
500
+ const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
501
+ if (event.key === "Tab") event.preventDefault();
502
+ if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
503
+ if (["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
504
+ const items = getItems().filter((item) => !item.disabled);
505
+ let candidateNodes = items.map((item) => item.ref.current);
506
+ if (["ArrowUp", "End"].includes(event.key)) {
507
+ candidateNodes = candidateNodes.slice().reverse();
508
+ }
509
+ if (["ArrowUp", "ArrowDown"].includes(event.key)) {
510
+ const currentElement = event.target;
511
+ const currentIndex = candidateNodes.indexOf(currentElement);
512
+ candidateNodes = candidateNodes.slice(currentIndex + 1);
513
+ }
514
+ setTimeout(() => focusFirst(candidateNodes));
515
+ event.preventDefault();
516
+ }
517
+ })
518
+ }
519
+ )
520
+ }
521
+ )
522
+ }
523
+ ) })
524
+ }
525
+ );
526
+ }
527
+ );
528
+ SelectContentImpl.displayName = CONTENT_IMPL_NAME;
529
+ var ITEM_ALIGNED_POSITION_NAME = "SelectItemAlignedPosition";
530
+ var SelectItemAlignedPosition = React.forwardRef((props, forwardedRef) => {
531
+ const { __scopeSelect, onPlaced, ...popperProps } = props;
532
+ const context = useSelectContext(CONTENT_NAME, __scopeSelect);
533
+ const contentContext = useSelectContentContext(CONTENT_NAME, __scopeSelect);
534
+ const [contentWrapper, setContentWrapper] = React.useState(null);
535
+ const [content, setContent] = React.useState(null);
536
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
537
+ const getItems = useCollection(__scopeSelect);
538
+ const shouldExpandOnScrollRef = React.useRef(false);
539
+ const shouldRepositionRef = React.useRef(true);
540
+ const { viewport, selectedItem, selectedItemText, focusSelectedItem } = contentContext;
541
+ const position = React.useCallback(() => {
542
+ if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
543
+ const triggerRect = context.trigger.getBoundingClientRect();
544
+ const contentRect = content.getBoundingClientRect();
545
+ const valueNodeRect = context.valueNode.getBoundingClientRect();
546
+ const itemTextRect = selectedItemText.getBoundingClientRect();
547
+ if (context.dir !== "rtl") {
548
+ const itemTextOffset = itemTextRect.left - contentRect.left;
549
+ const left = valueNodeRect.left - itemTextOffset;
550
+ const leftDelta = triggerRect.left - left;
551
+ const minContentWidth = triggerRect.width + leftDelta;
552
+ const contentWidth = Math.max(minContentWidth, contentRect.width);
553
+ const rightEdge = window.innerWidth - CONTENT_MARGIN;
554
+ const clampedLeft = clamp(left, [
555
+ CONTENT_MARGIN,
556
+ // Prevents the content from going off the starting edge of the
557
+ // viewport. It may still go off the ending edge, but this can be
558
+ // controlled by the user since they may want to manage overflow in a
559
+ // specific way.
560
+ // https://github.com/radix-ui/primitives/issues/2049
561
+ Math.max(CONTENT_MARGIN, rightEdge - contentWidth)
562
+ ]);
563
+ contentWrapper.style.minWidth = minContentWidth + "px";
564
+ contentWrapper.style.left = clampedLeft + "px";
565
+ } else {
566
+ const itemTextOffset = contentRect.right - itemTextRect.right;
567
+ const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
568
+ const rightDelta = window.innerWidth - triggerRect.right - right;
569
+ const minContentWidth = triggerRect.width + rightDelta;
570
+ const contentWidth = Math.max(minContentWidth, contentRect.width);
571
+ const leftEdge = window.innerWidth - CONTENT_MARGIN;
572
+ const clampedRight = clamp(right, [
573
+ CONTENT_MARGIN,
574
+ Math.max(CONTENT_MARGIN, leftEdge - contentWidth)
575
+ ]);
576
+ contentWrapper.style.minWidth = minContentWidth + "px";
577
+ contentWrapper.style.right = clampedRight + "px";
578
+ }
579
+ const items = getItems();
580
+ const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
581
+ const itemsHeight = viewport.scrollHeight;
582
+ const contentStyles = window.getComputedStyle(content);
583
+ const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
584
+ const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
585
+ const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
586
+ const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
587
+ const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth;
588
+ const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
589
+ const viewportStyles = window.getComputedStyle(viewport);
590
+ const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
591
+ const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
592
+ const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - CONTENT_MARGIN;
593
+ const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
594
+ const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
595
+ const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
596
+ const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
597
+ const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
598
+ const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
599
+ if (willAlignWithoutTopOverflow) {
600
+ const isLastItem = items.length > 0 && selectedItem === items[items.length - 1].ref.current;
601
+ contentWrapper.style.bottom = "0px";
602
+ const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
603
+ const clampedTriggerMiddleToBottomEdge = Math.max(
604
+ triggerMiddleToBottomEdge,
605
+ selectedItemHalfHeight + // viewport might have padding bottom, include it to avoid a scrollable viewport
606
+ (isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth
607
+ );
608
+ const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
609
+ contentWrapper.style.height = height + "px";
610
+ } else {
611
+ const isFirstItem = items.length > 0 && selectedItem === items[0].ref.current;
612
+ contentWrapper.style.top = "0px";
613
+ const clampedTopEdgeToTriggerMiddle = Math.max(
614
+ topEdgeToTriggerMiddle,
615
+ contentBorderTopWidth + viewport.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
616
+ (isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight
617
+ );
618
+ const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
619
+ contentWrapper.style.height = height + "px";
620
+ viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
621
+ }
622
+ contentWrapper.style.margin = `${CONTENT_MARGIN}px 0`;
623
+ contentWrapper.style.minHeight = minContentHeight + "px";
624
+ contentWrapper.style.maxHeight = availableHeight + "px";
625
+ onPlaced?.();
626
+ requestAnimationFrame(() => shouldExpandOnScrollRef.current = true);
627
+ }
628
+ }, [
629
+ getItems,
630
+ context.trigger,
631
+ context.valueNode,
632
+ contentWrapper,
633
+ content,
634
+ viewport,
635
+ selectedItem,
636
+ selectedItemText,
637
+ context.dir,
638
+ onPlaced
639
+ ]);
640
+ useLayoutEffect2(() => position(), [position]);
641
+ const [contentZIndex, setContentZIndex] = React.useState();
642
+ useLayoutEffect2(() => {
643
+ if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
644
+ }, [content]);
645
+ const handleScrollButtonChange = React.useCallback(
646
+ (node) => {
647
+ if (node && shouldRepositionRef.current === true) {
648
+ position();
649
+ focusSelectedItem?.();
650
+ shouldRepositionRef.current = false;
651
+ }
652
+ },
653
+ [position, focusSelectedItem]
654
+ );
655
+ return /* @__PURE__ */ jsx(
656
+ SelectViewportProvider,
657
+ {
658
+ scope: __scopeSelect,
659
+ contentWrapper,
660
+ shouldExpandOnScrollRef,
661
+ onScrollButtonChange: handleScrollButtonChange,
662
+ children: /* @__PURE__ */ jsx(
663
+ "div",
664
+ {
665
+ ref: setContentWrapper,
666
+ style: {
667
+ display: "flex",
668
+ flexDirection: "column",
669
+ position: "fixed",
670
+ zIndex: contentZIndex
671
+ },
672
+ children: /* @__PURE__ */ jsx(
673
+ Primitive.div,
674
+ {
675
+ ...popperProps,
676
+ ref: composedRefs,
677
+ style: {
678
+ // When we get the height of the content, it includes borders. If we were to set
679
+ // the height without having `boxSizing: 'border-box'` it would be too big.
680
+ boxSizing: "border-box",
681
+ // We need to ensure the content doesn't get taller than the wrapper
682
+ maxHeight: "100%",
683
+ ...popperProps.style
684
+ }
685
+ }
686
+ )
687
+ }
688
+ )
689
+ }
690
+ );
691
+ });
692
+ SelectItemAlignedPosition.displayName = ITEM_ALIGNED_POSITION_NAME;
693
+ var POPPER_POSITION_NAME = "SelectPopperPosition";
694
+ var SelectPopperPosition = React.forwardRef((props, forwardedRef) => {
695
+ const {
696
+ __scopeSelect,
697
+ align = "start",
698
+ collisionPadding = CONTENT_MARGIN,
699
+ ...popperProps
700
+ } = props;
701
+ const popperScope = usePopperScope(__scopeSelect);
702
+ return /* @__PURE__ */ jsx(
703
+ Content,
704
+ {
705
+ ...popperScope,
706
+ ...popperProps,
707
+ ref: forwardedRef,
708
+ align,
709
+ collisionPadding,
710
+ style: {
711
+ // Ensure border-box for floating-ui calculations
712
+ boxSizing: "border-box",
713
+ ...popperProps.style,
714
+ // re-namespace exposed content custom properties
715
+ ...{
716
+ "--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
717
+ "--radix-select-content-available-width": "var(--radix-popper-available-width)",
718
+ "--radix-select-content-available-height": "var(--radix-popper-available-height)",
719
+ "--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
720
+ "--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
721
+ }
722
+ }
723
+ }
724
+ );
725
+ });
726
+ SelectPopperPosition.displayName = POPPER_POSITION_NAME;
727
+ var [SelectViewportProvider, useSelectViewportContext] = createSelectContext(CONTENT_NAME, {});
728
+ var VIEWPORT_NAME = "SelectViewport";
729
+ var SelectViewport = React.forwardRef(
730
+ (props, forwardedRef) => {
731
+ const { __scopeSelect, nonce, ...viewportProps } = props;
732
+ const contentContext = useSelectContentContext(VIEWPORT_NAME, __scopeSelect);
733
+ const viewportContext = useSelectViewportContext(VIEWPORT_NAME, __scopeSelect);
734
+ const composedRefs = useComposedRefs(forwardedRef, contentContext.onViewportChange);
735
+ const prevScrollTopRef = React.useRef(0);
736
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
737
+ /* @__PURE__ */ jsx(
738
+ "style",
739
+ {
740
+ dangerouslySetInnerHTML: {
741
+ __html: `[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`
742
+ },
743
+ nonce
744
+ }
745
+ ),
746
+ /* @__PURE__ */ jsx(Collection.Slot, { scope: __scopeSelect, children: /* @__PURE__ */ jsx(
747
+ Primitive.div,
748
+ {
749
+ "data-radix-select-viewport": "",
750
+ role: "presentation",
751
+ ...viewportProps,
752
+ ref: composedRefs,
753
+ style: {
754
+ // we use position: 'relative' here on the `viewport` so that when we call
755
+ // `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
756
+ // (independent of the scrollUpButton).
757
+ position: "relative",
758
+ flex: 1,
759
+ // Viewport should only be scrollable in the vertical direction.
760
+ // This won't work in vertical writing modes, so we'll need to
761
+ // revisit this if/when that is supported
762
+ // https://developer.chrome.com/blog/vertical-form-controls
763
+ overflow: "hidden auto",
764
+ ...viewportProps.style
765
+ },
766
+ onScroll: composeEventHandlers(viewportProps.onScroll, (event) => {
767
+ const viewport = event.currentTarget;
768
+ const { contentWrapper, shouldExpandOnScrollRef } = viewportContext;
769
+ if (shouldExpandOnScrollRef?.current && contentWrapper) {
770
+ const scrolledBy = Math.abs(prevScrollTopRef.current - viewport.scrollTop);
771
+ if (scrolledBy > 0) {
772
+ const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
773
+ const cssMinHeight = parseFloat(contentWrapper.style.minHeight);
774
+ const cssHeight = parseFloat(contentWrapper.style.height);
775
+ const prevHeight = Math.max(cssMinHeight, cssHeight);
776
+ if (prevHeight < availableHeight) {
777
+ const nextHeight = prevHeight + scrolledBy;
778
+ const clampedNextHeight = Math.min(availableHeight, nextHeight);
779
+ const heightDiff = nextHeight - clampedNextHeight;
780
+ contentWrapper.style.height = clampedNextHeight + "px";
781
+ if (contentWrapper.style.bottom === "0px") {
782
+ viewport.scrollTop = heightDiff > 0 ? heightDiff : 0;
783
+ contentWrapper.style.justifyContent = "flex-end";
784
+ }
785
+ }
786
+ }
787
+ }
788
+ prevScrollTopRef.current = viewport.scrollTop;
789
+ })
790
+ }
791
+ ) })
792
+ ] });
793
+ }
794
+ );
795
+ SelectViewport.displayName = VIEWPORT_NAME;
796
+ var GROUP_NAME = "SelectGroup";
797
+ var [SelectGroupContextProvider, useSelectGroupContext] = createSelectContext(GROUP_NAME);
798
+ var SelectGroup$1 = React.forwardRef(
799
+ (props, forwardedRef) => {
800
+ const { __scopeSelect, ...groupProps } = props;
801
+ const groupId = useId();
802
+ return /* @__PURE__ */ jsx(SelectGroupContextProvider, { scope: __scopeSelect, id: groupId, children: /* @__PURE__ */ jsx(Primitive.div, { role: "group", "aria-labelledby": groupId, ...groupProps, ref: forwardedRef }) });
803
+ }
804
+ );
805
+ SelectGroup$1.displayName = GROUP_NAME;
806
+ var LABEL_NAME = "SelectLabel";
807
+ var SelectLabel = React.forwardRef(
808
+ (props, forwardedRef) => {
809
+ const { __scopeSelect, ...labelProps } = props;
810
+ const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
811
+ return /* @__PURE__ */ jsx(Primitive.div, { id: groupContext.id, ...labelProps, ref: forwardedRef });
812
+ }
813
+ );
814
+ SelectLabel.displayName = LABEL_NAME;
815
+ var ITEM_NAME = "SelectItem";
816
+ var [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
817
+ var SelectItem$1 = React.forwardRef(
818
+ (props, forwardedRef) => {
819
+ const {
820
+ __scopeSelect,
821
+ value,
822
+ disabled = false,
823
+ textValue: textValueProp,
824
+ ...itemProps
825
+ } = props;
826
+ const context = useSelectContext(ITEM_NAME, __scopeSelect);
827
+ const contentContext = useSelectContentContext(ITEM_NAME, __scopeSelect);
828
+ const isSelected = context.value === value;
829
+ const [textValue, setTextValue] = React.useState(textValueProp ?? "");
830
+ const [isFocused, setIsFocused] = React.useState(false);
831
+ const composedRefs = useComposedRefs(
832
+ forwardedRef,
833
+ (node) => contentContext.itemRefCallback?.(node, value, disabled)
834
+ );
835
+ const textId = useId();
836
+ const pointerTypeRef = React.useRef("touch");
837
+ const handleSelect = () => {
838
+ if (!disabled) {
839
+ context.onValueChange(value);
840
+ context.onOpenChange(false);
841
+ }
842
+ };
843
+ if (value === "") {
844
+ throw new Error(
845
+ "A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder."
846
+ );
847
+ }
848
+ return /* @__PURE__ */ jsx(
849
+ SelectItemContextProvider,
850
+ {
851
+ scope: __scopeSelect,
852
+ value,
853
+ disabled,
854
+ textId,
855
+ isSelected,
856
+ onItemTextChange: React.useCallback((node) => {
857
+ setTextValue((prevTextValue) => prevTextValue || (node?.textContent ?? "").trim());
858
+ }, []),
859
+ children: /* @__PURE__ */ jsx(
860
+ Collection.ItemSlot,
861
+ {
862
+ scope: __scopeSelect,
863
+ value,
864
+ disabled,
865
+ textValue,
866
+ children: /* @__PURE__ */ jsx(
867
+ Primitive.div,
868
+ {
869
+ role: "option",
870
+ "aria-labelledby": textId,
871
+ "data-highlighted": isFocused ? "" : void 0,
872
+ "aria-selected": isSelected && isFocused,
873
+ "data-state": isSelected ? "checked" : "unchecked",
874
+ "aria-disabled": disabled || void 0,
875
+ "data-disabled": disabled ? "" : void 0,
876
+ tabIndex: disabled ? void 0 : -1,
877
+ ...itemProps,
878
+ ref: composedRefs,
879
+ onFocus: composeEventHandlers(itemProps.onFocus, () => setIsFocused(true)),
880
+ onBlur: composeEventHandlers(itemProps.onBlur, () => setIsFocused(false)),
881
+ onClick: composeEventHandlers(itemProps.onClick, () => {
882
+ if (pointerTypeRef.current !== "mouse") handleSelect();
883
+ }),
884
+ onPointerUp: composeEventHandlers(itemProps.onPointerUp, () => {
885
+ if (pointerTypeRef.current === "mouse") handleSelect();
886
+ }),
887
+ onPointerDown: composeEventHandlers(itemProps.onPointerDown, (event) => {
888
+ pointerTypeRef.current = event.pointerType;
889
+ }),
890
+ onPointerMove: composeEventHandlers(itemProps.onPointerMove, (event) => {
891
+ pointerTypeRef.current = event.pointerType;
892
+ if (disabled) {
893
+ contentContext.onItemLeave?.();
894
+ } else if (pointerTypeRef.current === "mouse") {
895
+ event.currentTarget.focus({ preventScroll: true });
896
+ }
897
+ }),
898
+ onPointerLeave: composeEventHandlers(itemProps.onPointerLeave, (event) => {
899
+ if (event.currentTarget === document.activeElement) {
900
+ contentContext.onItemLeave?.();
901
+ }
902
+ }),
903
+ onKeyDown: composeEventHandlers(itemProps.onKeyDown, (event) => {
904
+ const isTypingAhead = contentContext.searchRef?.current !== "";
905
+ if (isTypingAhead && event.key === " ") return;
906
+ if (SELECTION_KEYS.includes(event.key)) handleSelect();
907
+ if (event.key === " ") event.preventDefault();
908
+ })
909
+ }
910
+ )
911
+ }
912
+ )
913
+ }
914
+ );
915
+ }
916
+ );
917
+ SelectItem$1.displayName = ITEM_NAME;
918
+ var ITEM_TEXT_NAME = "SelectItemText";
919
+ var SelectItemText = React.forwardRef(
920
+ (props, forwardedRef) => {
921
+ const { __scopeSelect, className, style, ...itemTextProps } = props;
922
+ const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
923
+ const contentContext = useSelectContentContext(ITEM_TEXT_NAME, __scopeSelect);
924
+ const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
925
+ const nativeOptionsContext = useSelectNativeOptionsContext(ITEM_TEXT_NAME, __scopeSelect);
926
+ const [itemTextNode, setItemTextNode] = React.useState(null);
927
+ const composedRefs = useComposedRefs(
928
+ forwardedRef,
929
+ (node) => setItemTextNode(node),
930
+ itemContext.onItemTextChange,
931
+ (node) => contentContext.itemTextRefCallback?.(node, itemContext.value, itemContext.disabled)
932
+ );
933
+ const textContent = itemTextNode?.textContent;
934
+ const nativeOption = React.useMemo(
935
+ () => /* @__PURE__ */ jsx("option", { value: itemContext.value, disabled: itemContext.disabled, children: textContent }, itemContext.value),
936
+ [itemContext.disabled, itemContext.value, textContent]
937
+ );
938
+ const { onNativeOptionAdd, onNativeOptionRemove } = nativeOptionsContext;
939
+ useLayoutEffect2(() => {
940
+ onNativeOptionAdd(nativeOption);
941
+ return () => onNativeOptionRemove(nativeOption);
942
+ }, [onNativeOptionAdd, onNativeOptionRemove, nativeOption]);
943
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
944
+ /* @__PURE__ */ jsx(Primitive.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs }),
945
+ itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null
946
+ ] });
947
+ }
948
+ );
949
+ SelectItemText.displayName = ITEM_TEXT_NAME;
950
+ var ITEM_INDICATOR_NAME = "SelectItemIndicator";
951
+ var SelectItemIndicator = React.forwardRef(
952
+ (props, forwardedRef) => {
953
+ const { __scopeSelect, ...itemIndicatorProps } = props;
954
+ const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
955
+ return itemContext.isSelected ? /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...itemIndicatorProps, ref: forwardedRef }) : null;
956
+ }
957
+ );
958
+ SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
959
+ var SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
960
+ var SelectScrollUpButton$1 = React.forwardRef((props, forwardedRef) => {
961
+ const contentContext = useSelectContentContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
962
+ const viewportContext = useSelectViewportContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
963
+ const [canScrollUp, setCanScrollUp] = React.useState(false);
964
+ const composedRefs = useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
965
+ useLayoutEffect2(() => {
966
+ if (contentContext.viewport && contentContext.isPositioned) {
967
+ let handleScroll2 = function() {
968
+ const canScrollUp2 = viewport.scrollTop > 0;
969
+ setCanScrollUp(canScrollUp2);
970
+ };
971
+ const viewport = contentContext.viewport;
972
+ handleScroll2();
973
+ viewport.addEventListener("scroll", handleScroll2);
974
+ return () => viewport.removeEventListener("scroll", handleScroll2);
975
+ }
976
+ }, [contentContext.viewport, contentContext.isPositioned]);
977
+ return canScrollUp ? /* @__PURE__ */ jsx(
978
+ SelectScrollButtonImpl,
979
+ {
980
+ ...props,
981
+ ref: composedRefs,
982
+ onAutoScroll: () => {
983
+ const { viewport, selectedItem } = contentContext;
984
+ if (viewport && selectedItem) {
985
+ viewport.scrollTop = viewport.scrollTop - selectedItem.offsetHeight;
986
+ }
987
+ }
988
+ }
989
+ ) : null;
990
+ });
991
+ SelectScrollUpButton$1.displayName = SCROLL_UP_BUTTON_NAME;
992
+ var SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
993
+ var SelectScrollDownButton$1 = React.forwardRef((props, forwardedRef) => {
994
+ const contentContext = useSelectContentContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
995
+ const viewportContext = useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
996
+ const [canScrollDown, setCanScrollDown] = React.useState(false);
997
+ const composedRefs = useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
998
+ useLayoutEffect2(() => {
999
+ if (contentContext.viewport && contentContext.isPositioned) {
1000
+ let handleScroll2 = function() {
1001
+ const maxScroll = viewport.scrollHeight - viewport.clientHeight;
1002
+ const canScrollDown2 = Math.ceil(viewport.scrollTop) < maxScroll;
1003
+ setCanScrollDown(canScrollDown2);
1004
+ };
1005
+ const viewport = contentContext.viewport;
1006
+ handleScroll2();
1007
+ viewport.addEventListener("scroll", handleScroll2);
1008
+ return () => viewport.removeEventListener("scroll", handleScroll2);
1009
+ }
1010
+ }, [contentContext.viewport, contentContext.isPositioned]);
1011
+ return canScrollDown ? /* @__PURE__ */ jsx(
1012
+ SelectScrollButtonImpl,
1013
+ {
1014
+ ...props,
1015
+ ref: composedRefs,
1016
+ onAutoScroll: () => {
1017
+ const { viewport, selectedItem } = contentContext;
1018
+ if (viewport && selectedItem) {
1019
+ viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
1020
+ }
1021
+ }
1022
+ }
1023
+ ) : null;
1024
+ });
1025
+ SelectScrollDownButton$1.displayName = SCROLL_DOWN_BUTTON_NAME;
1026
+ var SelectScrollButtonImpl = React.forwardRef((props, forwardedRef) => {
1027
+ const { __scopeSelect, onAutoScroll, ...scrollIndicatorProps } = props;
1028
+ const contentContext = useSelectContentContext("SelectScrollButton", __scopeSelect);
1029
+ const autoScrollTimerRef = React.useRef(null);
1030
+ const getItems = useCollection(__scopeSelect);
1031
+ const clearAutoScrollTimer = React.useCallback(() => {
1032
+ if (autoScrollTimerRef.current !== null) {
1033
+ window.clearInterval(autoScrollTimerRef.current);
1034
+ autoScrollTimerRef.current = null;
1035
+ }
1036
+ }, []);
1037
+ React.useEffect(() => {
1038
+ return () => clearAutoScrollTimer();
1039
+ }, [clearAutoScrollTimer]);
1040
+ useLayoutEffect2(() => {
1041
+ const activeItem = getItems().find((item) => item.ref.current === document.activeElement);
1042
+ activeItem?.ref.current?.scrollIntoView({ block: "nearest" });
1043
+ }, [getItems]);
1044
+ return /* @__PURE__ */ jsx(
1045
+ Primitive.div,
1046
+ {
1047
+ "aria-hidden": true,
1048
+ ...scrollIndicatorProps,
1049
+ ref: forwardedRef,
1050
+ style: { flexShrink: 0, ...scrollIndicatorProps.style },
1051
+ onPointerDown: composeEventHandlers(scrollIndicatorProps.onPointerDown, () => {
1052
+ if (autoScrollTimerRef.current === null) {
1053
+ autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
1054
+ }
1055
+ }),
1056
+ onPointerMove: composeEventHandlers(scrollIndicatorProps.onPointerMove, () => {
1057
+ contentContext.onItemLeave?.();
1058
+ if (autoScrollTimerRef.current === null) {
1059
+ autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
1060
+ }
1061
+ }),
1062
+ onPointerLeave: composeEventHandlers(scrollIndicatorProps.onPointerLeave, () => {
1063
+ clearAutoScrollTimer();
1064
+ })
1065
+ }
1066
+ );
1067
+ });
1068
+ var SEPARATOR_NAME = "SelectSeparator";
1069
+ var SelectSeparator = React.forwardRef(
1070
+ (props, forwardedRef) => {
1071
+ const { __scopeSelect, ...separatorProps } = props;
1072
+ return /* @__PURE__ */ jsx(Primitive.div, { "aria-hidden": true, ...separatorProps, ref: forwardedRef });
1073
+ }
1074
+ );
1075
+ SelectSeparator.displayName = SEPARATOR_NAME;
1076
+ var ARROW_NAME = "SelectArrow";
1077
+ var SelectArrow = React.forwardRef(
1078
+ (props, forwardedRef) => {
1079
+ const { __scopeSelect, ...arrowProps } = props;
1080
+ const popperScope = usePopperScope(__scopeSelect);
1081
+ const context = useSelectContext(ARROW_NAME, __scopeSelect);
1082
+ const contentContext = useSelectContentContext(ARROW_NAME, __scopeSelect);
1083
+ return context.open && contentContext.position === "popper" ? /* @__PURE__ */ jsx(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef }) : null;
1084
+ }
1085
+ );
1086
+ SelectArrow.displayName = ARROW_NAME;
1087
+ var BUBBLE_INPUT_NAME = "SelectBubbleInput";
1088
+ var SelectBubbleInput = React.forwardRef(
1089
+ ({ __scopeSelect, value, ...props }, forwardedRef) => {
1090
+ const ref = React.useRef(null);
1091
+ const composedRefs = useComposedRefs(forwardedRef, ref);
1092
+ const prevValue = usePrevious(value);
1093
+ React.useEffect(() => {
1094
+ const select = ref.current;
1095
+ if (!select) return;
1096
+ const selectProto = window.HTMLSelectElement.prototype;
1097
+ const descriptor = Object.getOwnPropertyDescriptor(
1098
+ selectProto,
1099
+ "value"
1100
+ );
1101
+ const setValue = descriptor.set;
1102
+ if (prevValue !== value && setValue) {
1103
+ const event = new Event("change", { bubbles: true });
1104
+ setValue.call(select, value);
1105
+ select.dispatchEvent(event);
1106
+ }
1107
+ }, [prevValue, value]);
1108
+ return /* @__PURE__ */ jsx(
1109
+ Primitive.select,
1110
+ {
1111
+ ...props,
1112
+ style: { ...VISUALLY_HIDDEN_STYLES, ...props.style },
1113
+ ref: composedRefs,
1114
+ defaultValue: value
1115
+ }
1116
+ );
1117
+ }
1118
+ );
1119
+ SelectBubbleInput.displayName = BUBBLE_INPUT_NAME;
1120
+ function shouldShowPlaceholder(value) {
1121
+ return value === "" || value === void 0;
1122
+ }
1123
+ function useTypeaheadSearch(onSearchChange) {
1124
+ const handleSearchChange = useCallbackRef(onSearchChange);
1125
+ const searchRef = React.useRef("");
1126
+ const timerRef = React.useRef(0);
1127
+ const handleTypeaheadSearch = React.useCallback(
1128
+ (key) => {
1129
+ const search = searchRef.current + key;
1130
+ handleSearchChange(search);
1131
+ (function updateSearch(value) {
1132
+ searchRef.current = value;
1133
+ window.clearTimeout(timerRef.current);
1134
+ if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
1135
+ })(search);
1136
+ },
1137
+ [handleSearchChange]
1138
+ );
1139
+ const resetTypeahead = React.useCallback(() => {
1140
+ searchRef.current = "";
1141
+ window.clearTimeout(timerRef.current);
1142
+ }, []);
1143
+ React.useEffect(() => {
1144
+ return () => window.clearTimeout(timerRef.current);
1145
+ }, []);
1146
+ return [searchRef, handleTypeaheadSearch, resetTypeahead];
1147
+ }
1148
+ function findNextItem(items, search, currentItem) {
1149
+ const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
1150
+ const normalizedSearch = isRepeated ? search[0] : search;
1151
+ const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
1152
+ let wrappedItems = wrapArray(items, Math.max(currentItemIndex, 0));
1153
+ const excludeCurrentItem = normalizedSearch.length === 1;
1154
+ if (excludeCurrentItem) wrappedItems = wrappedItems.filter((v) => v !== currentItem);
1155
+ const nextItem = wrappedItems.find(
1156
+ (item) => item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase())
1157
+ );
1158
+ return nextItem !== currentItem ? nextItem : void 0;
1159
+ }
1160
+ function wrapArray(array, startIndex) {
1161
+ return array.map((_, index) => array[(startIndex + index) % array.length]);
1162
+ }
1163
+ var Root2 = Select$1;
1164
+ var Trigger = SelectTrigger$1;
1165
+ var Value = SelectValue$1;
1166
+ var Icon = SelectIcon;
1167
+ var Portal = SelectPortal;
1168
+ var Content2 = SelectContent$1;
1169
+ var Viewport = SelectViewport;
1170
+ var Group = SelectGroup$1;
1171
+ var Item = SelectItem$1;
1172
+ var ItemText = SelectItemText;
1173
+ var ItemIndicator = SelectItemIndicator;
1174
+ var ScrollUpButton = SelectScrollUpButton$1;
1175
+ var ScrollDownButton = SelectScrollDownButton$1;
1176
+
1177
+ const Select = (_a) => {
1178
+ var props = __rest(_a, []);
1179
+ return (jsx(Root2, Object.assign({ "data-slot": "select" }, props)));
1180
+ };
1181
+ const SelectGroup = (_a) => {
1182
+ var props = __rest(_a, []);
1183
+ return (jsx(Group, Object.assign({ "data-slot": "select-group" }, props)));
1184
+ };
1185
+ const SelectValue = (_a) => {
1186
+ var props = __rest(_a, []);
1187
+ return (jsx(Value, Object.assign({ "data-slot": "select-value" }, props)));
1188
+ };
1189
+ const SelectTrigger = (_a) => {
1190
+ var { className, size = 'default', children } = _a, props = __rest(_a, ["className", "size", "children"]);
1191
+ return (jsxs(Trigger, Object.assign({ "data-slot": "select-trigger", "data-size": size, className: cn("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className) }, props, { children: [children, jsx(Icon, Object.assign({ asChild: true }, { children: jsx(ChevronDown, { className: "size-4 opacity-50" }) }))] })));
1192
+ };
1193
+ const SelectScrollUpButton = (_a) => {
1194
+ var { className } = _a, props = __rest(_a, ["className"]);
1195
+ return (jsx(ScrollUpButton, Object.assign({ "data-slot": "select-scroll-up-button", className: cn('flex cursor-default items-center justify-center py-1', className) }, props, { children: jsx(ChevronUp, { className: "size-4" }) })));
1196
+ };
1197
+ const SelectScrollDownButton = (_a) => {
1198
+ var { className } = _a, props = __rest(_a, ["className"]);
1199
+ return (jsx(ScrollDownButton, Object.assign({ "data-slot": "select-scroll-down-button", className: cn('flex cursor-default items-center justify-center py-1', className) }, props, { children: jsx(ChevronDown, { className: "size-4" }) })));
1200
+ };
1201
+ const SelectContent = (_a) => {
1202
+ var { className, children, position = 'item-aligned', align = 'center' } = _a, props = __rest(_a, ["className", "children", "position", "align"]);
1203
+ return (jsx(Portal, { children: jsxs(Content2, Object.assign({ "data-slot": "select-content", className: cn('bg-popover text-popover-foreground 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 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md', position === 'popper' &&
1204
+ 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1', className), position: position, align: align }, props, { children: [jsx(SelectScrollUpButton, {}), jsx(Viewport, Object.assign({ className: cn('p-1', position === 'popper' &&
1205
+ 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1') }, { children: children })), jsx(SelectScrollDownButton, {})] })) }));
1206
+ };
1207
+ const SelectItem = (_a) => {
1208
+ var { className, children } = _a, props = __rest(_a, ["className", "children"]);
1209
+ return (jsxs(Item, Object.assign({ "data-slot": "select-item", className: cn("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className) }, props, { children: [jsx("span", Object.assign({ "data-slot": "select-item-indicator", className: "absolute right-2 flex size-3.5 items-center justify-center" }, { children: jsx(ItemIndicator, { children: jsx(Check, { className: "size-4" }) }) })), jsx(ItemText, { children: children })] })));
1210
+ };
1211
+
1212
+ export { Settings2 as S, Select as a, SelectTrigger as b, SelectValue as c, SelectContent as d, SelectGroup as e, SelectItem as f, usePrevious as u };
1213
+ //# sourceMappingURL=select-98610101.js.map