@strapi/ui-primitives 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,216 +1,169 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import { useComposedRefs } from "@radix-ui/react-compose-refs";
4
- import { createContextScope, createContext } from "@radix-ui/react-context";
5
- import { Slot } from "@radix-ui/react-slot";
6
- import { composeEventHandlers as composeEventHandlers$1 } from "@radix-ui/primitive";
7
- import { DismissableLayer } from "@radix-ui/react-dismissable-layer";
8
- import { useFocusGuards } from "@radix-ui/react-focus-guards";
9
- import { FocusScope } from "@radix-ui/react-focus-scope";
10
- import { useId } from "@radix-ui/react-id";
11
- import * as PopperPrimitive from "@radix-ui/react-popper";
12
- import { createPopperScope } from "@radix-ui/react-popper";
13
- import { Portal as Portal$2 } from "@radix-ui/react-portal";
14
- import { Primitive } from "@radix-ui/react-primitive";
15
- import { useControllableState } from "@radix-ui/react-use-controllable-state";
16
- import { useLayoutEffect } from "@radix-ui/react-use-layout-effect";
17
- import { hideOthers } from "aria-hidden";
18
- import * as ReactDOM from "react-dom";
19
- import { RemoveScroll } from "react-remove-scroll";
20
- import { useVirtualizer } from "@tanstack/react-virtual";
21
- import { clamp } from "@radix-ui/number";
22
- import { createCollection as createCollection$1 } from "@radix-ui/react-collection";
23
- import { useDirection } from "@radix-ui/react-direction";
24
- import { usePrevious } from "@radix-ui/react-use-previous";
25
- import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
26
- function createCollection(name) {
27
- const PROVIDER_NAME = `${name}CollectionProvider`;
28
- const [createCollectionContext, createCollectionScope2] = createContextScope(PROVIDER_NAME);
29
- const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(PROVIDER_NAME, {
1
+ import { jsx as d, jsxs as ye, Fragment as Se } from "react/jsx-runtime";
2
+ import * as s from "react";
3
+ import { useComposedRefs as A } from "@radix-ui/react-compose-refs";
4
+ import { createContextScope as st, createContext as it } from "@radix-ui/react-context";
5
+ import { Slot as Ee } from "@radix-ui/react-slot";
6
+ import { composeEventHandlers as P } from "@radix-ui/primitive";
7
+ import { DismissableLayer as ct } from "@radix-ui/react-dismissable-layer";
8
+ import { useFocusGuards as at } from "@radix-ui/react-focus-guards";
9
+ import { FocusScope as ut } from "@radix-ui/react-focus-scope";
10
+ import { useId as se } from "@radix-ui/react-id";
11
+ import * as ie from "@radix-ui/react-popper";
12
+ import { createPopperScope as dt } from "@radix-ui/react-popper";
13
+ import { Portal as pt } from "@radix-ui/react-portal";
14
+ import { Primitive as N } from "@radix-ui/react-primitive";
15
+ import { useControllableState as de } from "@radix-ui/react-use-controllable-state";
16
+ import { useLayoutEffect as $ } from "@radix-ui/react-use-layout-effect";
17
+ import { hideOthers as ft } from "aria-hidden";
18
+ import * as we from "react-dom";
19
+ import { RemoveScroll as mt } from "react-remove-scroll";
20
+ import { useVirtualizer as jt } from "@tanstack/react-virtual";
21
+ import { clamp as rt } from "@radix-ui/number";
22
+ import { createCollection as Yt } from "@radix-ui/react-collection";
23
+ import { useDirection as qt } from "@radix-ui/react-direction";
24
+ import { usePrevious as Xt } from "@radix-ui/react-use-previous";
25
+ import { VisuallyHidden as Zt } from "@radix-ui/react-visually-hidden";
26
+ function Jt(o) {
27
+ const i = `${o}CollectionProvider`, [e, t] = st(i), [n, r] = e(i, {
30
28
  collectionRef: { current: null },
31
29
  itemMap: /* @__PURE__ */ new Map(),
32
30
  listeners: /* @__PURE__ */ new Set()
33
- });
34
- const CollectionProvider = (props) => {
35
- const { scope, children } = props;
36
- const ref = React.useRef(null);
37
- const itemMap = React.useRef(/* @__PURE__ */ new Map()).current;
38
- const listeners = React.useRef(/* @__PURE__ */ new Set()).current;
39
- return /* @__PURE__ */ jsx(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, listeners, children });
31
+ }), c = (u) => {
32
+ const { scope: f, children: h } = u, b = s.useRef(null), x = s.useRef(/* @__PURE__ */ new Map()).current, p = s.useRef(/* @__PURE__ */ new Set()).current;
33
+ return /* @__PURE__ */ d(n, { scope: f, itemMap: x, collectionRef: b, listeners: p, children: h });
40
34
  };
41
- CollectionProvider.displayName = PROVIDER_NAME;
42
- const COLLECTION_SLOT_NAME = `${name}CollectionSlot`;
43
- const CollectionSlot = React.forwardRef((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(Slot, { ref: composedRefs, children });
35
+ c.displayName = i;
36
+ const l = `${o}CollectionSlot`, a = s.forwardRef((u, f) => {
37
+ const { scope: h, children: b } = u, x = r(l, h), p = A(f, x.collectionRef);
38
+ return /* @__PURE__ */ d(Ee, { ref: p, children: b });
48
39
  });
49
- CollectionSlot.displayName = COLLECTION_SLOT_NAME;
50
- const ITEM_SLOT_NAME = `${name}CollectionItemSlot`;
51
- const ITEM_DATA_ATTR = "data-radix-collection-item";
52
- const CollectionItemSlot = React.forwardRef((props, forwardedRef) => {
53
- const { scope, children, ...itemData } = props;
54
- const ref = React.useRef(null);
55
- const composedRefs = useComposedRefs(forwardedRef, ref);
56
- const context = useCollectionContext(ITEM_SLOT_NAME, scope);
57
- React.useEffect(() => {
58
- const previousMap = Array.from(context.itemMap.values());
59
- context.itemMap.set(ref, { ref, ...itemData });
60
- context.listeners.forEach((listener) => listener(Array.from(context.itemMap.values()), previousMap));
61
- return () => {
62
- const previousMap2 = Array.from(context.itemMap.values());
63
- context.itemMap.delete(ref);
64
- context.listeners.forEach((listener) => listener(Array.from(context.itemMap.values()), previousMap2));
40
+ a.displayName = l;
41
+ const m = `${o}CollectionItemSlot`, C = "data-radix-collection-item", v = s.forwardRef((u, f) => {
42
+ const { scope: h, children: b, ...x } = u, p = s.useRef(null), y = A(f, p), E = r(m, h);
43
+ return s.useEffect(() => {
44
+ const O = Array.from(E.itemMap.values());
45
+ return E.itemMap.set(p, { ref: p, ...x }), E.listeners.forEach((F) => F(Array.from(E.itemMap.values()), O)), () => {
46
+ const F = Array.from(E.itemMap.values());
47
+ E.itemMap.delete(p), E.listeners.forEach((_) => _(Array.from(E.itemMap.values()), F));
65
48
  };
66
- });
67
- return /* @__PURE__ */ jsx(Slot, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
49
+ }), /* @__PURE__ */ d(Ee, { [C]: "", ref: y, children: b });
68
50
  });
69
- CollectionItemSlot.displayName = ITEM_SLOT_NAME;
70
- function useCollection2(scope) {
71
- const context = useCollectionContext(`${name}CollectionConsumer`, scope);
72
- const getItems = React.useCallback(() => {
73
- const collectionNode = context.collectionRef.current;
74
- if (!collectionNode)
75
- return [];
76
- const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
77
- const items = Array.from(context.itemMap.values());
78
- const orderedItems = items.sort(
79
- (a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
51
+ v.displayName = m;
52
+ function g(u) {
53
+ const f = r(`${o}CollectionConsumer`, u), h = s.useCallback(() => {
54
+ const x = f.collectionRef.current;
55
+ if (!x) return [];
56
+ const p = Array.from(x.querySelectorAll(`[${C}]`));
57
+ return Array.from(f.itemMap.values()).sort(
58
+ (O, F) => p.indexOf(O.ref.current) - p.indexOf(F.ref.current)
80
59
  );
81
- return orderedItems;
82
- }, [context.collectionRef, context.itemMap]);
83
- const subscribe = React.useCallback(
84
- (listener) => {
85
- context.listeners.add(listener);
86
- return () => context.listeners.delete(listener);
87
- },
88
- [context.listeners]
60
+ }, [f.collectionRef, f.itemMap]), b = s.useCallback(
61
+ (x) => (f.listeners.add(x), () => f.listeners.delete(x)),
62
+ [f.listeners]
89
63
  );
90
- return { getItems, subscribe };
64
+ return { getItems: h, subscribe: b };
91
65
  }
92
66
  return [
93
- { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
94
- useCollection2,
95
- createCollectionScope2
67
+ { Provider: c, Slot: a, ItemSlot: v },
68
+ g,
69
+ t
96
70
  ];
97
71
  }
98
- const cache = /* @__PURE__ */ new Map();
99
- function useCollator(locale, options) {
100
- const cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : "");
101
- if (cache.has(cacheKey)) {
102
- return cache.get(cacheKey);
103
- }
104
- const formatter = new Intl.Collator(locale, options);
105
- cache.set(cacheKey, formatter);
106
- return formatter;
72
+ const Pe = /* @__PURE__ */ new Map();
73
+ function Qt(o, i) {
74
+ const e = o + (i ? Object.entries(i).sort((n, r) => n[0] < r[0] ? -1 : 1).join() : "");
75
+ if (Pe.has(e))
76
+ return Pe.get(e);
77
+ const t = new Intl.Collator(o, i);
78
+ return Pe.set(e, t), t;
107
79
  }
108
- function useFilter(locale, options) {
109
- const collator = useCollator(locale, {
80
+ function De(o, i) {
81
+ const e = Qt(o, {
110
82
  usage: "search",
111
- ...options
83
+ ...i
112
84
  });
113
85
  return {
114
- startsWith(string, substring) {
115
- if (substring.length === 0) {
116
- return true;
117
- }
118
- string = string.normalize("NFC");
119
- substring = substring.normalize("NFC");
120
- return collator.compare(string.slice(0, substring.length), substring) === 0;
86
+ startsWith(t, n) {
87
+ return n.length === 0 ? !0 : (t = t.normalize("NFC"), n = n.normalize("NFC"), e.compare(t.slice(0, n.length), n) === 0);
121
88
  },
122
- endsWith(string, substring) {
123
- if (substring.length === 0) {
124
- return true;
125
- }
126
- string = string.normalize("NFC");
127
- substring = substring.normalize("NFC");
128
- return collator.compare(string.slice(-substring.length), substring) === 0;
89
+ endsWith(t, n) {
90
+ return n.length === 0 ? !0 : (t = t.normalize("NFC"), n = n.normalize("NFC"), e.compare(t.slice(-n.length), n) === 0);
129
91
  },
130
- contains(string, substring) {
131
- if (substring.length === 0) {
132
- return true;
92
+ contains(t, n) {
93
+ if (n.length === 0)
94
+ return !0;
95
+ t = t.normalize("NFC"), n = n.normalize("NFC");
96
+ let r = 0;
97
+ const c = n.length;
98
+ for (; r + c <= t.length; r++) {
99
+ const l = t.slice(r, r + c);
100
+ if (e.compare(n, l) === 0)
101
+ return !0;
133
102
  }
134
- string = string.normalize("NFC");
135
- substring = substring.normalize("NFC");
136
- let scan = 0;
137
- const sliceLen = substring.length;
138
- for (; scan + sliceLen <= string.length; scan++) {
139
- const slice = string.slice(scan, scan + sliceLen);
140
- if (collator.compare(substring, slice) === 0) {
141
- return true;
142
- }
143
- }
144
- return false;
103
+ return !1;
145
104
  }
146
105
  };
147
106
  }
148
- const usePrev = (value) => {
149
- const ref = React.useRef();
150
- React.useEffect(() => {
151
- ref.current = value;
152
- });
153
- return ref.current;
154
- };
155
- const VirtualizedViewport = React.forwardRef(
156
- ({ children, estimatedItemSize = 40, overscan = 5, getItemCount, onViewportChange, ...props }, forwardedRef) => {
157
- const parentRef = React.useRef(null);
158
- const composedRefs = useComposedRefs(forwardedRef, parentRef, onViewportChange);
159
- const childArray = React.useMemo(() => React.Children.toArray(children), [children]);
160
- const virtualizer = useVirtualizer({
161
- count: getItemCount(),
162
- getScrollElement: () => parentRef.current,
163
- estimateSize: () => estimatedItemSize,
164
- overscan
165
- });
166
- const virtualItems = virtualizer.getVirtualItems();
167
- return /* @__PURE__ */ jsxs(Fragment, { children: [
168
- /* @__PURE__ */ jsx(
107
+ const eo = (o) => {
108
+ const i = s.useRef();
109
+ return s.useEffect(() => {
110
+ i.current = o;
111
+ }), i.current;
112
+ }, ht = s.forwardRef(
113
+ ({ children: o, estimatedItemSize: i = 40, overscan: e = 5, getItemCount: t, onViewportChange: n, ...r }, c) => {
114
+ const l = s.useRef(null), a = A(c, l, n), m = s.useMemo(() => s.Children.toArray(o), [o]), C = jt({
115
+ count: t(),
116
+ getScrollElement: () => l.current,
117
+ estimateSize: () => i,
118
+ overscan: e
119
+ }), v = C.getVirtualItems();
120
+ return /* @__PURE__ */ ye(Se, { children: [
121
+ /* @__PURE__ */ d(
169
122
  "style",
170
123
  {
171
124
  dangerouslySetInnerHTML: {
172
- __html: `[data-radix-combobox-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-combobox-viewport]::-webkit-scrollbar{display:none}`
125
+ __html: "[data-radix-combobox-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-combobox-viewport]::-webkit-scrollbar{display:none}"
173
126
  }
174
127
  }
175
128
  ),
176
- /* @__PURE__ */ jsx(
177
- Primitive.div,
129
+ /* @__PURE__ */ d(
130
+ N.div,
178
131
  {
179
132
  "data-radix-combobox-viewport": "",
180
133
  role: "presentation",
181
- ...props,
182
- ref: composedRefs,
134
+ ...r,
135
+ ref: a,
183
136
  style: {
184
137
  position: "relative",
185
138
  flex: 1,
186
139
  overflow: "auto",
187
- ...props.style
140
+ ...r.style
188
141
  },
189
- children: /* @__PURE__ */ jsx(
142
+ children: /* @__PURE__ */ d(
190
143
  "div",
191
144
  {
192
145
  style: {
193
- height: `${virtualizer.getTotalSize()}px`,
146
+ height: `${C.getTotalSize()}px`,
194
147
  width: "100%",
195
148
  position: "relative"
196
149
  },
197
- children: virtualItems.map((virtualItem) => {
198
- const child = childArray[virtualItem.index];
199
- return /* @__PURE__ */ jsx(
150
+ children: v.map((g) => {
151
+ const u = m[g.index];
152
+ return /* @__PURE__ */ d(
200
153
  "div",
201
154
  {
202
- "data-index": virtualItem.index,
203
- ref: virtualizer.measureElement,
155
+ "data-index": g.index,
156
+ ref: C.measureElement,
204
157
  style: {
205
158
  position: "absolute",
206
159
  top: 0,
207
160
  left: 0,
208
161
  width: "100%",
209
- transform: `translateY(${virtualItem.start}px)`
162
+ transform: `translateY(${g.start}px)`
210
163
  },
211
- children: child
164
+ children: u
212
165
  },
213
- virtualItem.key
166
+ g.key
214
167
  );
215
168
  })
216
169
  }
@@ -220,515 +173,352 @@ const VirtualizedViewport = React.forwardRef(
220
173
  ] });
221
174
  }
222
175
  );
223
- VirtualizedViewport.displayName = "VirtualizedViewport";
224
- const OPEN_KEYS$1 = [" ", "Enter", "ArrowUp", "ArrowDown"];
225
- const SELECTION_KEYS$1 = ["Enter"];
226
- const defaultIsPrintableCharacter = (str) => {
227
- return Boolean(str.length === 1 && str.match(/\S| /));
228
- };
229
- const COMBOBOX_NAME = "Combobox";
230
- const [Collection$1, useCollection$1] = createCollection(COMBOBOX_NAME);
231
- const [ComboboxProvider, useComboboxContext] = createContext(COMBOBOX_NAME);
232
- const ComboboxProviders = ({ children }) => /* @__PURE__ */ jsx(PopperPrimitive.Root, { children: /* @__PURE__ */ jsx(Collection$1.Provider, { scope: void 0, children }) });
233
- const formatAutocomplete = (autocomplete) => {
234
- if (typeof autocomplete === "string") {
235
- if (autocomplete === "none") {
236
- return {
237
- type: autocomplete,
238
- filter: void 0
239
- };
240
- }
241
- return {
242
- type: autocomplete,
243
- filter: "startsWith"
244
- };
245
- }
246
- return autocomplete;
247
- };
248
- const Combobox = (props) => {
176
+ ht.displayName = "VirtualizedViewport";
177
+ const to = [" ", "Enter", "ArrowUp", "ArrowDown"], oo = ["Enter"], no = (o) => !!(o.length === 1 && o.match(/\S| /)), gt = "Combobox", [re, xe] = Jt(gt), [ro, Y] = it(gt), lo = ({ children: o }) => /* @__PURE__ */ d(ie.Root, { children: /* @__PURE__ */ d(re.Provider, { scope: void 0, children: o }) }), so = (o) => typeof o == "string" ? o === "none" ? {
178
+ type: o,
179
+ filter: void 0
180
+ } : {
181
+ type: o,
182
+ filter: "startsWith"
183
+ } : o, io = (o) => {
249
184
  const {
250
- allowCustomValue = false,
251
- autocomplete = "none",
252
- children,
253
- open: openProp,
254
- defaultOpen,
255
- onOpenChange,
256
- value: valueProp,
257
- defaultValue,
258
- onValueChange,
259
- disabled,
260
- required = false,
261
- locale = "en-EN",
262
- onTextValueChange,
263
- textValue: textValueProp,
264
- defaultTextValue,
265
- filterValue: filterValueProp,
266
- defaultFilterValue,
267
- onFilterValueChange,
268
- isPrintableCharacter = defaultIsPrintableCharacter,
269
- visible = false,
270
- virtualized = "auto",
271
- estimatedItemSize = 40,
272
- overscan = 5
273
- } = props;
274
- const [trigger, setTrigger] = React.useState(null);
275
- const [viewport, setViewport] = React.useState(null);
276
- const [content, setContent] = React.useState(null);
277
- const [visuallyFocussedItem, setVisuallyFocussedItem] = React.useState(null);
278
- const [open = false, setOpen] = useControllableState({
279
- prop: openProp,
280
- defaultProp: defaultOpen,
281
- onChange: onOpenChange
282
- });
283
- const [value, setValue] = useControllableState({
284
- prop: valueProp,
285
- defaultProp: defaultValue,
286
- onChange: onValueChange
287
- });
288
- const [textValue, setTextValue] = useControllableState({
289
- prop: textValueProp,
290
- defaultProp: allowCustomValue && !defaultTextValue ? valueProp : defaultTextValue,
291
- onChange: onTextValueChange
292
- });
293
- const [filterValue, setFilterValue] = useControllableState({
294
- prop: filterValueProp,
295
- defaultProp: defaultFilterValue,
296
- onChange: onFilterValueChange
297
- });
298
- const id = useId();
299
- const focusFirst = React.useCallback(
300
- (candidates, items) => {
301
- const allItems = items.map((item) => item.ref.current);
302
- const [firstItem, ...restItems] = allItems;
303
- const [lastItem] = restItems.slice(-1);
304
- const PREVIOUSLY_FOCUSED_ELEMENT = visuallyFocussedItem ?? items.find((item) => item.value === value)?.ref.current;
305
- for (const candidate of candidates) {
306
- if (candidate === PREVIOUSLY_FOCUSED_ELEMENT)
307
- return;
308
- candidate?.scrollIntoView({ block: "nearest" });
309
- if (candidate === firstItem && viewport)
310
- viewport.scrollTop = 0;
311
- if (candidate === lastItem && viewport)
312
- viewport.scrollTop = viewport.scrollHeight;
313
- setVisuallyFocussedItem(candidate);
314
- if (autocomplete === "both") {
315
- const item = items.find((item2) => item2.ref.current === candidate);
316
- if (item) {
317
- setTextValue(item.textValue);
318
- }
185
+ allowCustomValue: i = !1,
186
+ autocomplete: e = "none",
187
+ children: t,
188
+ open: n,
189
+ defaultOpen: r,
190
+ onOpenChange: c,
191
+ value: l,
192
+ defaultValue: a,
193
+ onValueChange: m,
194
+ disabled: C,
195
+ required: v = !1,
196
+ locale: g = "en-EN",
197
+ onTextValueChange: u,
198
+ textValue: f,
199
+ defaultTextValue: h,
200
+ filterValue: b,
201
+ defaultFilterValue: x,
202
+ onFilterValueChange: p,
203
+ isPrintableCharacter: y = no,
204
+ visible: E = !1,
205
+ virtualized: O = "auto",
206
+ estimatedItemSize: F = 40,
207
+ overscan: _ = 5
208
+ } = o, [k, Z] = s.useState(null), [U, z] = s.useState(null), [R, H] = s.useState(null), [L, W] = s.useState(null), [J = !1, Q] = de({
209
+ prop: n,
210
+ defaultProp: r,
211
+ onChange: c
212
+ }), [K, G] = de({
213
+ prop: l,
214
+ defaultProp: a,
215
+ onChange: m
216
+ }), [ce, ee] = de({
217
+ prop: f,
218
+ defaultProp: i && !h ? l : h,
219
+ onChange: u
220
+ }), [fe, me] = de({
221
+ prop: b,
222
+ defaultProp: x,
223
+ onChange: p
224
+ }), te = se(), ae = s.useCallback(
225
+ (S, I) => {
226
+ var j;
227
+ const M = I.map((D) => D.ref.current), [V, ...T] = M, [w] = T.slice(-1), B = L ?? ((j = I.find((D) => D.value === K)) == null ? void 0 : j.ref.current);
228
+ for (const D of S) {
229
+ if (D === B) return;
230
+ if (D == null || D.scrollIntoView({ block: "nearest" }), D === V && U && (U.scrollTop = 0), D === w && U && (U.scrollTop = U.scrollHeight), W(D), e === "both") {
231
+ const ue = I.find((he) => he.ref.current === D);
232
+ ue && ee(ue.textValue);
319
233
  }
320
- if (candidate !== PREVIOUSLY_FOCUSED_ELEMENT)
321
- return;
234
+ if (D !== B) return;
322
235
  }
323
236
  },
324
- [autocomplete, setTextValue, viewport, visuallyFocussedItem, value]
325
- );
326
- const autocompleteObject = formatAutocomplete(autocomplete);
327
- React.useEffect(() => {
328
- if (autocomplete !== "both") {
329
- setVisuallyFocussedItem(null);
330
- }
331
- }, [textValue, autocomplete]);
332
- React.useEffect(() => {
333
- if (content && trigger)
334
- return hideOthers([content, trigger]);
335
- }, [content, trigger]);
336
- return /* @__PURE__ */ jsx(ComboboxProviders, { children: /* @__PURE__ */ jsx(
337
- ComboboxProvider,
237
+ [e, ee, U, L, K]
238
+ ), ne = so(e);
239
+ return s.useEffect(() => {
240
+ e !== "both" && W(null);
241
+ }, [ce, e]), s.useEffect(() => {
242
+ if (R && k) return ft([R, k]);
243
+ }, [R, k]), /* @__PURE__ */ d(lo, { children: /* @__PURE__ */ d(
244
+ ro,
338
245
  {
339
- allowCustomValue,
340
- autocomplete: autocompleteObject,
341
- required,
342
- trigger,
343
- onTriggerChange: setTrigger,
344
- contentId: id,
345
- value,
346
- onValueChange: setValue,
347
- open,
348
- onOpenChange: setOpen,
349
- disabled,
350
- locale,
351
- focusFirst,
352
- textValue,
353
- onTextValueChange: setTextValue,
354
- onViewportChange: setViewport,
355
- onContentChange: setContent,
356
- visuallyFocussedItem,
357
- filterValue,
358
- onFilterValueChange: setFilterValue,
359
- onVisuallyFocussedItemChange: setVisuallyFocussedItem,
360
- isPrintableCharacter,
361
- visible,
362
- virtualized,
363
- estimatedItemSize,
364
- overscan,
365
- children
246
+ allowCustomValue: i,
247
+ autocomplete: ne,
248
+ required: v,
249
+ trigger: k,
250
+ onTriggerChange: Z,
251
+ contentId: te,
252
+ value: K,
253
+ onValueChange: G,
254
+ open: J,
255
+ onOpenChange: Q,
256
+ disabled: C,
257
+ locale: g,
258
+ focusFirst: ae,
259
+ textValue: ce,
260
+ onTextValueChange: ee,
261
+ onViewportChange: z,
262
+ onContentChange: H,
263
+ visuallyFocussedItem: L,
264
+ filterValue: fe,
265
+ onFilterValueChange: me,
266
+ onVisuallyFocussedItemChange: W,
267
+ isPrintableCharacter: y,
268
+ visible: E,
269
+ virtualized: O,
270
+ estimatedItemSize: F,
271
+ overscan: _,
272
+ children: t
366
273
  }
367
274
  ) });
368
- };
369
- const TRIGGER_NAME$1 = "ComboboxTrigger";
370
- const ComboboxTrigger = React.forwardRef((props, forwardedRef) => {
371
- const { ...triggerProps } = props;
372
- const context = useComboboxContext(TRIGGER_NAME$1);
373
- const handleOpen = () => {
374
- if (!context.disabled) {
375
- context.onOpenChange(true);
376
- }
275
+ }, xt = "ComboboxTrigger", Ct = s.forwardRef((o, i) => {
276
+ const { ...e } = o, t = Y(xt), n = () => {
277
+ t.disabled || t.onOpenChange(!0);
377
278
  };
378
- return /* @__PURE__ */ jsx(PopperPrimitive.Anchor, { asChild: true, children: /* @__PURE__ */ jsx(
379
- FocusScope,
279
+ return /* @__PURE__ */ d(ie.Anchor, { asChild: !0, children: /* @__PURE__ */ d(
280
+ ut,
380
281
  {
381
- asChild: true,
382
- trapped: context.open,
383
- onMountAutoFocus: (event) => {
384
- event.preventDefault();
282
+ asChild: !0,
283
+ trapped: t.open,
284
+ onMountAutoFocus: (r) => {
285
+ r.preventDefault();
385
286
  },
386
- onUnmountAutoFocus: (event) => {
387
- context.trigger?.focus({ preventScroll: true });
388
- document.getSelection()?.empty();
389
- event.preventDefault();
287
+ onUnmountAutoFocus: (r) => {
288
+ var c, l;
289
+ (c = t.trigger) == null || c.focus({ preventScroll: !0 }), (l = document.getSelection()) == null || l.empty(), r.preventDefault();
390
290
  },
391
- children: /* @__PURE__ */ jsx(
291
+ children: /* @__PURE__ */ d(
392
292
  "div",
393
293
  {
394
- ref: forwardedRef,
395
- "data-disabled": context.disabled ? "" : void 0,
396
- ...triggerProps,
397
- onClick: composeEventHandlers$1(triggerProps.onClick, (event) => {
398
- if (context.disabled) {
399
- event.preventDefault();
294
+ ref: i,
295
+ "data-disabled": t.disabled ? "" : void 0,
296
+ ...e,
297
+ onClick: P(e.onClick, (r) => {
298
+ var c;
299
+ if (t.disabled) {
300
+ r.preventDefault();
400
301
  return;
401
302
  }
402
- context.trigger?.focus();
303
+ (c = t.trigger) == null || c.focus();
403
304
  }),
404
- onPointerDown: composeEventHandlers$1(triggerProps.onPointerDown, (event) => {
405
- if (context.disabled) {
406
- event.preventDefault();
305
+ onPointerDown: P(e.onPointerDown, (r) => {
306
+ var a;
307
+ if (t.disabled) {
308
+ r.preventDefault();
407
309
  return;
408
310
  }
409
- const target = event.target;
410
- if (target.hasPointerCapture(event.pointerId)) {
411
- target.releasePointerCapture(event.pointerId);
412
- }
413
- const buttonTarg = target.closest("button") ?? target.closest("div");
414
- if (buttonTarg !== event.currentTarget) {
415
- return;
416
- }
417
- if (event.button === 0 && event.ctrlKey === false) {
418
- handleOpen();
419
- context.trigger?.focus();
420
- }
311
+ const c = r.target;
312
+ c.hasPointerCapture(r.pointerId) && c.releasePointerCapture(r.pointerId), (c.closest("button") ?? c.closest("div")) === r.currentTarget && r.button === 0 && r.ctrlKey === !1 && (n(), (a = t.trigger) == null || a.focus());
421
313
  })
422
314
  }
423
315
  )
424
316
  }
425
317
  ) });
426
318
  });
427
- ComboboxTrigger.displayName = TRIGGER_NAME$1;
428
- const INPUT_NAME = "ComboboxInput";
429
- const ComboxboxTextInput = React.forwardRef((props, forwardedRef) => {
430
- const context = useComboboxContext(INPUT_NAME);
431
- const inputRef = React.useRef(null);
432
- const { getItems } = useCollection$1(void 0);
433
- const { startsWith } = useFilter(context.locale, { sensitivity: "base" });
434
- const isDisabled = context.disabled;
435
- const composedRefs = useComposedRefs(inputRef, forwardedRef, context.onTriggerChange);
436
- const handleOpen = () => {
437
- if (!isDisabled) {
438
- context.onOpenChange(true);
439
- }
440
- };
441
- const previousFilter = usePrev(context.filterValue);
442
- useLayoutEffect(() => {
443
- const timeout = setTimeout(() => {
444
- if (context.textValue === "" || context.textValue === void 0 || context.filterValue === "" || context.filterValue === void 0)
319
+ Ct.displayName = xt;
320
+ const vt = "ComboboxInput", bt = s.forwardRef((o, i) => {
321
+ var C;
322
+ const e = Y(vt), t = s.useRef(null), { getItems: n } = xe(void 0), { startsWith: r } = De(e.locale, { sensitivity: "base" }), c = e.disabled, l = A(t, i, e.onTriggerChange), a = () => {
323
+ c || e.onOpenChange(!0);
324
+ }, m = eo(e.filterValue);
325
+ return $(() => {
326
+ const v = setTimeout(() => {
327
+ var f;
328
+ if (e.textValue === "" || e.textValue === void 0 || e.filterValue === "" || e.filterValue === void 0)
445
329
  return;
446
- const firstItem = getItems().find(
447
- (item) => item.type === "option" && startsWith(item.textValue, context.textValue)
448
- );
449
- const characterChangedAtIndex = findChangedIndex(previousFilter ?? "", context.filterValue);
450
- if (firstItem && !context.visuallyFocussedItem && characterChangedAtIndex === context.filterValue.length) {
451
- inputRef.current?.setSelectionRange(context.filterValue.length, context.textValue.length);
452
- }
330
+ const g = n().find(
331
+ (h) => h.type === "option" && r(h.textValue, e.textValue)
332
+ ), u = wo(m ?? "", e.filterValue);
333
+ g && !e.visuallyFocussedItem && u === e.filterValue.length && ((f = t.current) == null || f.setSelectionRange(e.filterValue.length, e.textValue.length));
453
334
  });
454
- return () => clearTimeout(timeout);
455
- }, [context.textValue, context.filterValue, startsWith, context.visuallyFocussedItem, getItems, previousFilter]);
456
- return /* @__PURE__ */ jsx(
335
+ return () => clearTimeout(v);
336
+ }, [e.textValue, e.filterValue, r, e.visuallyFocussedItem, n, m]), /* @__PURE__ */ d(
457
337
  "input",
458
338
  {
459
339
  type: "text",
460
340
  role: "combobox",
461
- "aria-controls": context.contentId,
462
- "aria-expanded": context.open,
463
- "aria-required": context.required,
464
- "aria-autocomplete": context.autocomplete.type,
465
- "data-state": context.open ? "open" : "closed",
466
- "aria-disabled": isDisabled,
467
- "aria-activedescendant": context.visuallyFocussedItem?.id,
468
- disabled: isDisabled,
469
- "data-disabled": isDisabled ? "" : void 0,
470
- "data-placeholder": context.textValue === void 0 ? "" : void 0,
471
- value: context.textValue ?? "",
472
- ...props,
473
- ref: composedRefs,
474
- onKeyDown: composeEventHandlers$1(props.onKeyDown, (event) => {
475
- if (["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
476
- if (!context.open) {
477
- handleOpen();
478
- }
479
- setTimeout(() => {
480
- const items = getItems().filter((item) => !item.disabled && item.isVisible);
481
- let candidateNodes = items.map((item) => item.ref.current);
482
- if (["ArrowUp", "End"].includes(event.key)) {
483
- candidateNodes = candidateNodes.slice().reverse();
484
- }
485
- if (["ArrowUp", "ArrowDown"].includes(event.key)) {
486
- const currentElement = context.visuallyFocussedItem ?? getItems().find((item) => item.value === context.value)?.ref.current;
487
- if (currentElement) {
488
- let currentIndex = candidateNodes.indexOf(currentElement);
489
- if (currentIndex === candidateNodes.length - 1) {
490
- currentIndex = -1;
491
- }
492
- candidateNodes = candidateNodes.slice(currentIndex + 1);
341
+ "aria-controls": e.contentId,
342
+ "aria-expanded": e.open,
343
+ "aria-required": e.required,
344
+ "aria-autocomplete": e.autocomplete.type,
345
+ "data-state": e.open ? "open" : "closed",
346
+ "aria-disabled": c,
347
+ "aria-activedescendant": (C = e.visuallyFocussedItem) == null ? void 0 : C.id,
348
+ disabled: c,
349
+ "data-disabled": c ? "" : void 0,
350
+ "data-placeholder": e.textValue === void 0 ? "" : void 0,
351
+ value: e.textValue ?? "",
352
+ ...o,
353
+ ref: l,
354
+ onKeyDown: P(o.onKeyDown, (v) => {
355
+ var g, u;
356
+ if (["ArrowUp", "ArrowDown", "Home", "End"].includes(v.key))
357
+ e.open || a(), setTimeout(() => {
358
+ var b;
359
+ let h = n().filter((x) => !x.disabled && x.isVisible).map((x) => x.ref.current);
360
+ if (["ArrowUp", "End"].includes(v.key) && (h = h.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(v.key)) {
361
+ const x = e.visuallyFocussedItem ?? ((b = n().find((p) => p.value === e.value)) == null ? void 0 : b.ref.current);
362
+ if (x) {
363
+ let p = h.indexOf(x);
364
+ p === h.length - 1 && (p = -1), h = h.slice(p + 1);
493
365
  }
494
366
  }
495
- if (["ArrowDown"].includes(event.key) && context.autocomplete.type === "both" && candidateNodes.length > 1) {
496
- const [firstItem, ...restItems] = candidateNodes;
497
- const firstItemText = getItems().find((item) => item.ref.current === firstItem).textValue;
498
- if (context.textValue === firstItemText) {
499
- candidateNodes = restItems;
500
- }
367
+ if (["ArrowDown"].includes(v.key) && e.autocomplete.type === "both" && h.length > 1) {
368
+ const [x, ...p] = h, y = n().find((E) => E.ref.current === x).textValue;
369
+ e.textValue === y && (h = p);
501
370
  }
502
- context.focusFirst(candidateNodes, getItems());
503
- });
504
- event.preventDefault();
505
- } else if (["Tab"].includes(event.key) && context.open) {
506
- event.preventDefault();
507
- } else if (["Escape"].includes(event.key)) {
508
- if (context.open) {
509
- context.onOpenChange(false);
371
+ e.focusFirst(h, n());
372
+ }), v.preventDefault();
373
+ else if (["Tab"].includes(v.key) && e.open)
374
+ v.preventDefault();
375
+ else if (["Escape"].includes(v.key))
376
+ e.open ? e.onOpenChange(!1) : (e.onValueChange(void 0), e.onTextValueChange("")), v.preventDefault();
377
+ else if (oo.includes(v.key)) {
378
+ if (e.visuallyFocussedItem) {
379
+ const f = n().find((h) => h.ref.current === e.visuallyFocussedItem);
380
+ f && (e.onValueChange(f.value), e.onTextValueChange(f.textValue), e.autocomplete.type === "both" && e.onFilterValueChange(f.textValue), (g = f.ref.current) == null || g.click());
510
381
  } else {
511
- context.onValueChange(void 0);
512
- context.onTextValueChange("");
513
- }
514
- event.preventDefault();
515
- } else if (SELECTION_KEYS$1.includes(event.key)) {
516
- if (context.visuallyFocussedItem) {
517
- const focussedItem = getItems().find((item) => item.ref.current === context.visuallyFocussedItem);
518
- if (focussedItem) {
519
- context.onValueChange(focussedItem.value);
520
- context.onTextValueChange(focussedItem.textValue);
521
- if (context.autocomplete.type === "both") {
522
- context.onFilterValueChange(focussedItem.textValue);
523
- }
524
- focussedItem.ref.current?.click();
525
- }
526
- } else {
527
- const matchedItem = getItems().find(
528
- (item) => item.type === "option" && !item.disabled && item.textValue === context.textValue
382
+ const f = n().find(
383
+ (h) => h.type === "option" && !h.disabled && h.textValue === e.textValue
529
384
  );
530
- if (matchedItem) {
531
- context.onValueChange(matchedItem.value);
532
- context.onTextValueChange(matchedItem.textValue);
533
- if (context.autocomplete.type === "both") {
534
- context.onFilterValueChange(matchedItem.textValue);
535
- }
536
- matchedItem.ref.current?.click();
537
- }
385
+ f && (e.onValueChange(f.value), e.onTextValueChange(f.textValue), e.autocomplete.type === "both" && e.onFilterValueChange(f.textValue), (u = f.ref.current) == null || u.click());
538
386
  }
539
- context.onOpenChange(false);
540
- event.preventDefault();
541
- } else {
542
- context.onVisuallyFocussedItemChange(null);
543
- }
387
+ e.onOpenChange(!1), v.preventDefault();
388
+ } else
389
+ e.onVisuallyFocussedItemChange(null);
544
390
  }),
545
- onChange: composeEventHandlers$1(props.onChange, (event) => {
546
- context.onTextValueChange(event.currentTarget.value);
547
- if (context.autocomplete.type === "both") {
548
- context.onFilterValueChange(event.currentTarget.value);
549
- }
391
+ onChange: P(o.onChange, (v) => {
392
+ e.onTextValueChange(v.currentTarget.value), e.autocomplete.type === "both" && e.onFilterValueChange(v.currentTarget.value);
550
393
  }),
551
- onKeyUp: composeEventHandlers$1(props.onKeyUp, (event) => {
552
- if (!context.open && (context.isPrintableCharacter(event.key) || ["Backspace"].includes(event.key))) {
553
- handleOpen();
554
- }
555
- setTimeout(() => {
556
- if (context.autocomplete.type === "both" && context.isPrintableCharacter(event.key) && context.filterValue !== void 0) {
557
- const value = context.filterValue;
558
- const firstItem = getItems().find((item) => startsWith(item.textValue, value));
559
- if (firstItem) {
560
- context.onTextValueChange(firstItem.textValue);
561
- }
562
- }
563
- });
564
- if (context.autocomplete.type === "none" && context.isPrintableCharacter(event.key)) {
565
- const value = context.textValue ?? "";
566
- const nextItem = getItems().find((item) => startsWith(item.textValue, value));
567
- if (nextItem) {
568
- context.onVisuallyFocussedItemChange(nextItem.ref.current);
569
- nextItem.ref.current?.scrollIntoView();
394
+ onKeyUp: P(o.onKeyUp, (v) => {
395
+ var g;
396
+ if (!e.open && (e.isPrintableCharacter(v.key) || ["Backspace"].includes(v.key)) && a(), setTimeout(() => {
397
+ if (e.autocomplete.type === "both" && e.isPrintableCharacter(v.key) && e.filterValue !== void 0) {
398
+ const u = e.filterValue, f = n().find((h) => r(h.textValue, u));
399
+ f && e.onTextValueChange(f.textValue);
570
400
  }
401
+ }), e.autocomplete.type === "none" && e.isPrintableCharacter(v.key)) {
402
+ const u = e.textValue ?? "", f = n().find((h) => r(h.textValue, u));
403
+ f && (e.onVisuallyFocussedItemChange(f.ref.current), (g = f.ref.current) == null || g.scrollIntoView());
571
404
  }
572
405
  }),
573
- onBlur: composeEventHandlers$1(props.onBlur, () => {
574
- if (context.open) {
406
+ onBlur: P(o.onBlur, () => {
407
+ if (e.open)
575
408
  return;
576
- }
577
- context.onVisuallyFocussedItemChange(null);
578
- const [activeItem] = getItems().filter(
579
- (item) => item.textValue === context.textValue && item.type === "option"
409
+ e.onVisuallyFocussedItemChange(null);
410
+ const [v] = n().filter(
411
+ (u) => u.textValue === e.textValue && u.type === "option"
580
412
  );
581
- if (activeItem) {
582
- context.onValueChange(activeItem.value);
583
- if (context.autocomplete.type === "both") {
584
- context.onFilterValueChange(activeItem.textValue);
585
- }
413
+ if (v) {
414
+ e.onValueChange(v.value), e.autocomplete.type === "both" && e.onFilterValueChange(v.textValue);
586
415
  return;
587
416
  }
588
- if (context.allowCustomValue) {
589
- context.onValueChange(context.textValue);
590
- if (context.autocomplete.type === "both") {
591
- context.onFilterValueChange(context.textValue);
592
- }
417
+ if (e.allowCustomValue) {
418
+ e.onValueChange(e.textValue), e.autocomplete.type === "both" && e.onFilterValueChange(e.textValue);
593
419
  return;
594
420
  }
595
- const [previousItem] = getItems().filter((item) => item.value === context.value && item.type === "option");
596
- if (previousItem && context.textValue !== "") {
597
- context.onTextValueChange(previousItem.textValue);
598
- if (context.autocomplete.type === "both") {
599
- context.onFilterValueChange(previousItem.textValue);
600
- }
601
- } else {
602
- context.onValueChange(void 0);
603
- context.onTextValueChange("");
604
- }
421
+ const [g] = n().filter((u) => u.value === e.value && u.type === "option");
422
+ g && e.textValue !== "" ? (e.onTextValueChange(g.textValue), e.autocomplete.type === "both" && e.onFilterValueChange(g.textValue)) : (e.onValueChange(void 0), e.onTextValueChange(""));
605
423
  })
606
424
  }
607
425
  );
608
426
  });
609
- ComboxboxTextInput.displayName = "ComboboxTextInput";
610
- const ComboboxIcon = React.forwardRef((props, forwardedRef) => {
611
- const { children, ...iconProps } = props;
612
- const context = useComboboxContext(INPUT_NAME);
613
- const isDisabled = context.disabled;
614
- const handleOpen = () => {
615
- if (!isDisabled) {
616
- context.onOpenChange(true);
617
- context.trigger?.focus();
618
- }
427
+ bt.displayName = "ComboboxTextInput";
428
+ const yt = s.forwardRef((o, i) => {
429
+ const { children: e, ...t } = o, n = Y(vt), r = n.disabled, c = () => {
430
+ var l;
431
+ r || (n.onOpenChange(!0), (l = n.trigger) == null || l.focus());
619
432
  };
620
- return /* @__PURE__ */ jsx(
621
- Primitive.button,
433
+ return /* @__PURE__ */ d(
434
+ N.button,
622
435
  {
623
- "aria-hidden": true,
436
+ "aria-hidden": !0,
624
437
  type: "button",
625
- "aria-disabled": isDisabled,
626
- "aria-controls": context.contentId,
627
- "aria-expanded": context.open,
628
- disabled: isDisabled,
629
- "data-disabled": isDisabled ? "" : void 0,
630
- ...iconProps,
438
+ "aria-disabled": r,
439
+ "aria-controls": n.contentId,
440
+ "aria-expanded": n.open,
441
+ disabled: r,
442
+ "data-disabled": r ? "" : void 0,
443
+ ...t,
631
444
  tabIndex: -1,
632
- ref: forwardedRef,
633
- onClick: composeEventHandlers$1(iconProps.onClick, () => {
634
- context.trigger?.focus();
445
+ ref: i,
446
+ onClick: P(t.onClick, () => {
447
+ var l;
448
+ (l = n.trigger) == null || l.focus();
635
449
  }),
636
- onPointerDown: composeEventHandlers$1(iconProps.onPointerDown, (event) => {
637
- if (event.button === 0 && event.ctrlKey === false) {
638
- handleOpen();
639
- event.preventDefault();
640
- }
450
+ onPointerDown: P(t.onPointerDown, (l) => {
451
+ l.button === 0 && l.ctrlKey === !1 && (c(), l.preventDefault());
641
452
  }),
642
- onKeyDown: composeEventHandlers$1(iconProps.onKeyDown, (event) => {
643
- if (OPEN_KEYS$1.includes(event.key)) {
644
- handleOpen();
645
- event.preventDefault();
646
- }
453
+ onKeyDown: P(t.onKeyDown, (l) => {
454
+ to.includes(l.key) && (c(), l.preventDefault());
647
455
  }),
648
- children: children || "▼"
456
+ children: e || "▼"
649
457
  }
650
458
  );
651
459
  });
652
- ComboboxIcon.displayName = "ComboboxIcon";
653
- const PORTAL_NAME$1 = "ComboboxPortal";
654
- const ComboboxPortal = (props) => {
655
- return /* @__PURE__ */ jsx(Portal$2, { asChild: true, ...props });
656
- };
657
- ComboboxPortal.displayName = PORTAL_NAME$1;
658
- const CONTENT_NAME$1 = "ComboboxContent";
659
- const ComboboxContent = React.forwardRef((props, forwardedRef) => {
660
- const context = useComboboxContext(CONTENT_NAME$1);
661
- const { getItems } = useCollection$1(void 0);
662
- const [fragment, setFragment] = React.useState();
663
- useLayoutEffect(() => {
664
- setFragment(new DocumentFragment());
665
- }, []);
666
- useLayoutEffect(() => {
667
- if (context.open && context.autocomplete.type === "none") {
668
- setTimeout(() => {
669
- const activeItem = getItems().find((item) => item.value === context.value);
670
- activeItem?.ref.current?.scrollIntoView({ block: "nearest" });
671
- });
672
- }
673
- }, [getItems, context.autocomplete, context.value, context.open]);
674
- if (!context.open) {
675
- const frag = fragment;
676
- return frag ? ReactDOM.createPortal(
677
- /* @__PURE__ */ jsx(Collection$1.Slot, { scope: void 0, children: /* @__PURE__ */ jsx("div", { children: props.children }) }),
678
- frag
460
+ yt.displayName = "ComboboxIcon";
461
+ const co = "ComboboxPortal", St = (o) => /* @__PURE__ */ d(pt, { asChild: !0, ...o });
462
+ St.displayName = co;
463
+ const ke = "ComboboxContent", wt = s.forwardRef((o, i) => {
464
+ const e = Y(ke), { getItems: t } = xe(void 0), [n, r] = s.useState();
465
+ if ($(() => {
466
+ r(new DocumentFragment());
467
+ }, []), $(() => {
468
+ e.open && e.autocomplete.type === "none" && setTimeout(() => {
469
+ var l;
470
+ const c = t().find((a) => a.value === e.value);
471
+ (l = c == null ? void 0 : c.ref.current) == null || l.scrollIntoView({ block: "nearest" });
472
+ });
473
+ }, [t, e.autocomplete, e.value, e.open]), !e.open) {
474
+ const c = n;
475
+ return c ? we.createPortal(
476
+ /* @__PURE__ */ d(re.Slot, { scope: void 0, children: /* @__PURE__ */ d("div", { children: o.children }) }),
477
+ c
679
478
  ) : null;
680
479
  }
681
- return /* @__PURE__ */ jsx(ComboboxContentImpl, { ...props, ref: forwardedRef });
480
+ return /* @__PURE__ */ d(It, { ...o, ref: i });
682
481
  });
683
- ComboboxContent.displayName = CONTENT_NAME$1;
684
- const CONTENT_MARGIN$1 = 10;
685
- const ComboboxContentImpl = React.forwardRef(
686
- (props, forwardedRef) => {
687
- const { onEscapeKeyDown, onPointerDownOutside, ...contentProps } = props;
688
- const context = useComboboxContext(CONTENT_NAME$1);
689
- const composedRefs = useComposedRefs(forwardedRef, (node) => context.onContentChange(node));
690
- const { onOpenChange } = context;
691
- useFocusGuards();
692
- React.useEffect(() => {
693
- const close = () => {
694
- onOpenChange(false);
482
+ wt.displayName = ke;
483
+ const ao = 10, It = s.forwardRef(
484
+ (o, i) => {
485
+ const { onEscapeKeyDown: e, onPointerDownOutside: t, ...n } = o, r = Y(ke), c = A(i, (a) => r.onContentChange(a)), { onOpenChange: l } = r;
486
+ return at(), s.useEffect(() => {
487
+ const a = () => {
488
+ l(!1);
695
489
  };
696
- window.addEventListener("blur", close);
697
- window.addEventListener("resize", close);
698
- return () => {
699
- window.removeEventListener("blur", close);
700
- window.removeEventListener("resize", close);
490
+ return window.addEventListener("blur", a), window.addEventListener("resize", a), () => {
491
+ window.removeEventListener("blur", a), window.removeEventListener("resize", a);
701
492
  };
702
- }, [onOpenChange]);
703
- return /* @__PURE__ */ jsx(RemoveScroll, { allowPinchZoom: true, children: /* @__PURE__ */ jsx(
704
- DismissableLayer,
493
+ }, [l]), /* @__PURE__ */ d(mt, { allowPinchZoom: !0, children: /* @__PURE__ */ d(
494
+ ct,
705
495
  {
706
- asChild: true,
707
- onEscapeKeyDown,
708
- onPointerDownOutside,
709
- onFocusOutside: (event) => {
710
- event.preventDefault();
496
+ asChild: !0,
497
+ onEscapeKeyDown: e,
498
+ onPointerDownOutside: t,
499
+ onFocusOutside: (a) => {
500
+ a.preventDefault();
711
501
  },
712
502
  onDismiss: () => {
713
- context.onOpenChange(false);
714
- context.trigger?.focus({ preventScroll: true });
503
+ var a;
504
+ r.onOpenChange(!1), (a = r.trigger) == null || a.focus({ preventScroll: !0 });
715
505
  },
716
- children: /* @__PURE__ */ jsx(
717
- ComboboxPopperPosition,
506
+ children: /* @__PURE__ */ d(
507
+ Tt,
718
508
  {
719
509
  role: "listbox",
720
- id: context.contentId,
721
- "data-state": context.open ? "open" : "closed",
722
- onContextMenu: (event) => event.preventDefault(),
723
- ...contentProps,
724
- ref: composedRefs,
510
+ id: r.contentId,
511
+ "data-state": r.open ? "open" : "closed",
512
+ onContextMenu: (a) => a.preventDefault(),
513
+ ...n,
514
+ ref: c,
725
515
  style: {
726
516
  // flex layout so we can place the scroll buttons properly
727
517
  display: "flex",
728
518
  flexDirection: "column",
729
519
  // reset the outline by default as the content MAY get focused
730
520
  outline: "none",
731
- ...contentProps.style
521
+ ...n.style
732
522
  }
733
523
  }
734
524
  )
@@ -736,71 +526,60 @@ const ComboboxContentImpl = React.forwardRef(
736
526
  ) });
737
527
  }
738
528
  );
739
- ComboboxContentImpl.displayName = "ComboboxContentImpl";
740
- const ComboboxPopperPosition = React.forwardRef(
741
- (props, forwardedRef) => {
742
- const { align = "start", collisionPadding = CONTENT_MARGIN$1, ...popperProps } = props;
743
- return /* @__PURE__ */ jsx(
744
- PopperPrimitive.Content,
529
+ It.displayName = "ComboboxContentImpl";
530
+ const Tt = s.forwardRef(
531
+ (o, i) => {
532
+ const { align: e = "start", collisionPadding: t = ao, ...n } = o;
533
+ return /* @__PURE__ */ d(
534
+ ie.Content,
745
535
  {
746
- ...popperProps,
747
- ref: forwardedRef,
748
- align,
749
- collisionPadding,
536
+ ...n,
537
+ ref: i,
538
+ align: e,
539
+ collisionPadding: t,
750
540
  style: {
751
541
  // Ensure border-box for floating-ui calculations
752
542
  boxSizing: "border-box",
753
- ...popperProps.style,
754
- // re-namespace exposed content custom properties
755
- ...{
756
- "--radix-combobox-content-transform-origin": "var(--radix-popper-transform-origin)",
757
- "--radix-combobox-content-available-width": "var(--radix-popper-available-width)",
758
- "--radix-combobox-content-available-height": "var(--radix-popper-available-height)",
759
- "--radix-combobox-trigger-width": "var(--radix-popper-anchor-width)",
760
- "--radix-combobox-trigger-height": "var(--radix-popper-anchor-height)"
761
- }
543
+ ...n.style,
544
+ "--radix-combobox-content-transform-origin": "var(--radix-popper-transform-origin)",
545
+ "--radix-combobox-content-available-width": "var(--radix-popper-available-width)",
546
+ "--radix-combobox-content-available-height": "var(--radix-popper-available-height)",
547
+ "--radix-combobox-trigger-width": "var(--radix-popper-anchor-width)",
548
+ "--radix-combobox-trigger-height": "var(--radix-popper-anchor-height)"
762
549
  }
763
550
  }
764
551
  );
765
552
  }
766
553
  );
767
- ComboboxPopperPosition.displayName = "ComboboxPopperPosition";
768
- const VIEWPORT_NAME$1 = "ComboboxViewport";
769
- const ComboboxViewport = React.forwardRef((props, forwardedRef) => {
770
- const comboboxContext = useComboboxContext(VIEWPORT_NAME$1);
771
- const composedRefs = useComposedRefs(forwardedRef, comboboxContext.onViewportChange);
772
- const childArray = React.useMemo(() => React.Children.toArray(props.children), [props.children]);
773
- const itemCount = childArray.length;
774
- const shouldVirtualize = comboboxContext.virtualized === true || comboboxContext.virtualized === "auto" && itemCount > 100;
775
- if (shouldVirtualize) {
776
- return /* @__PURE__ */ jsx(Collection$1.Slot, { scope: void 0, children: /* @__PURE__ */ jsx(
777
- VirtualizedViewport,
778
- {
779
- ...props,
780
- ref: composedRefs,
781
- getItemCount: () => itemCount,
782
- estimatedItemSize: comboboxContext.estimatedItemSize,
783
- overscan: comboboxContext.overscan,
784
- onViewportChange: comboboxContext.onViewportChange
785
- }
786
- ) });
787
- }
788
- return /* @__PURE__ */ jsxs(Fragment, { children: [
789
- /* @__PURE__ */ jsx(
554
+ Tt.displayName = "ComboboxPopperPosition";
555
+ const Vt = "ComboboxViewport", Pt = s.forwardRef((o, i) => {
556
+ const e = Y(Vt), t = A(i, e.onViewportChange), r = s.useMemo(() => s.Children.toArray(o.children), [o.children]).length;
557
+ return e.virtualized === !0 || e.virtualized === "auto" && r > 100 ? /* @__PURE__ */ d(re.Slot, { scope: void 0, children: /* @__PURE__ */ d(
558
+ ht,
559
+ {
560
+ ...o,
561
+ ref: t,
562
+ getItemCount: () => r,
563
+ estimatedItemSize: e.estimatedItemSize,
564
+ overscan: e.overscan,
565
+ onViewportChange: e.onViewportChange
566
+ }
567
+ ) }) : /* @__PURE__ */ ye(Se, { children: [
568
+ /* @__PURE__ */ d(
790
569
  "style",
791
570
  {
792
571
  dangerouslySetInnerHTML: {
793
- __html: `[data-radix-combobox-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-combobox-viewport]::-webkit-scrollbar{display:none}`
572
+ __html: "[data-radix-combobox-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-combobox-viewport]::-webkit-scrollbar{display:none}"
794
573
  }
795
574
  }
796
575
  ),
797
- /* @__PURE__ */ jsx(Collection$1.Slot, { scope: void 0, children: /* @__PURE__ */ jsx(
798
- Primitive.div,
576
+ /* @__PURE__ */ d(re.Slot, { scope: void 0, children: /* @__PURE__ */ d(
577
+ N.div,
799
578
  {
800
579
  "data-radix-combobox-viewport": "",
801
580
  role: "presentation",
802
- ...props,
803
- ref: composedRefs,
581
+ ...o,
582
+ ref: t,
804
583
  style: {
805
584
  // we use position: 'relative' here on the `viewport` so that when we call
806
585
  // `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
@@ -808,774 +587,542 @@ const ComboboxViewport = React.forwardRef((props, forwardedRef) => {
808
587
  position: "relative",
809
588
  flex: 1,
810
589
  overflow: "auto",
811
- ...props.style
590
+ ...o.style
812
591
  }
813
592
  }
814
593
  ) })
815
594
  ] });
816
595
  });
817
- ComboboxViewport.displayName = VIEWPORT_NAME$1;
818
- const ITEM_NAME$1 = "ComboboxItem";
819
- const [ComboboxItemProvider, useComboboxItemContext] = createContext(ITEM_NAME$1);
820
- const ComboboxItem = React.forwardRef((props, forwardedRef) => {
821
- const { value, disabled = false, textValue: textValueProp, ...restProps } = props;
822
- const [fragment, setFragment] = React.useState();
823
- useLayoutEffect(() => {
824
- setFragment(new DocumentFragment());
596
+ Pt.displayName = Vt;
597
+ const Ie = "ComboboxItem", [lt, Fe] = it(Ie), Le = s.forwardRef((o, i) => {
598
+ const { value: e, disabled: t = !1, textValue: n, ...r } = o, [c, l] = s.useState();
599
+ $(() => {
600
+ l(new DocumentFragment());
825
601
  }, []);
826
- const { onTextValueChange, textValue: contextTextValue, ...context } = useComboboxContext(ITEM_NAME$1);
827
- const textId = useId();
828
- const [textValue, setTextValue] = React.useState(textValueProp ?? "");
829
- const isSelected = context.value === value;
830
- const { startsWith, contains } = useFilter(context.locale, { sensitivity: "base" });
831
- const handleTextValueChange = React.useCallback((node) => {
832
- setTextValue((prevTextValue) => {
833
- return prevTextValue || (node?.textContent ?? "").trim();
834
- });
602
+ const { onTextValueChange: a, textValue: m, ...C } = Y(Ie), v = se(), [g, u] = s.useState(n ?? ""), f = C.value === e, { startsWith: h, contains: b } = De(C.locale, { sensitivity: "base" }), x = s.useCallback((p) => {
603
+ u((y) => y || ((p == null ? void 0 : p.textContent) ?? "").trim());
835
604
  }, []);
836
- React.useEffect(() => {
837
- if (isSelected && contextTextValue === void 0 && textValue !== "") {
838
- onTextValueChange(textValue);
839
- }
840
- }, [textValue, isSelected, contextTextValue, onTextValueChange]);
841
- if (context.autocomplete.type === "both" && textValue && context.filterValue && !startsWith(textValue, context.filterValue) || context.autocomplete.type === "list" && context.autocomplete.filter === "startsWith" && textValue && contextTextValue && !startsWith(textValue, contextTextValue) || context.autocomplete.type === "list" && context.autocomplete.filter === "contains" && textValue && contextTextValue && !contains(textValue, contextTextValue)) {
842
- return fragment ? ReactDOM.createPortal(
843
- /* @__PURE__ */ jsx(
844
- ComboboxItemProvider,
845
- {
846
- textId,
847
- onTextValueChange: handleTextValueChange,
848
- isSelected,
849
- textValue,
850
- children: /* @__PURE__ */ jsx(
851
- Collection$1.ItemSlot,
852
- {
853
- scope: void 0,
854
- value,
855
- textValue,
856
- disabled,
857
- type: "option",
858
- isVisible: false,
859
- children: /* @__PURE__ */ jsx(ComboboxItemImpl, { ref: forwardedRef, value, disabled, ...restProps })
860
- }
861
- )
862
- }
863
- ),
864
- fragment
865
- ) : null;
866
- }
867
- return /* @__PURE__ */ jsx(
868
- ComboboxItemProvider,
605
+ return s.useEffect(() => {
606
+ f && m === void 0 && g !== "" && a(g);
607
+ }, [g, f, m, a]), C.autocomplete.type === "both" && g && C.filterValue && !h(g, C.filterValue) || C.autocomplete.type === "list" && C.autocomplete.filter === "startsWith" && g && m && !h(g, m) || C.autocomplete.type === "list" && C.autocomplete.filter === "contains" && g && m && !b(g, m) ? c ? we.createPortal(
608
+ /* @__PURE__ */ d(
609
+ lt,
610
+ {
611
+ textId: v,
612
+ onTextValueChange: x,
613
+ isSelected: f,
614
+ textValue: g,
615
+ children: /* @__PURE__ */ d(
616
+ re.ItemSlot,
617
+ {
618
+ scope: void 0,
619
+ value: e,
620
+ textValue: g,
621
+ disabled: t,
622
+ type: "option",
623
+ isVisible: !1,
624
+ children: /* @__PURE__ */ d(Ne, { ref: i, value: e, disabled: t, ...r })
625
+ }
626
+ )
627
+ }
628
+ ),
629
+ c
630
+ ) : null : /* @__PURE__ */ d(
631
+ lt,
869
632
  {
870
- textId,
871
- onTextValueChange: handleTextValueChange,
872
- isSelected,
873
- textValue,
874
- children: /* @__PURE__ */ jsx(
875
- Collection$1.ItemSlot,
633
+ textId: v,
634
+ onTextValueChange: x,
635
+ isSelected: f,
636
+ textValue: g,
637
+ children: /* @__PURE__ */ d(
638
+ re.ItemSlot,
876
639
  {
877
640
  scope: void 0,
878
- value,
879
- textValue,
880
- disabled,
641
+ value: e,
642
+ textValue: g,
643
+ disabled: t,
881
644
  type: "option",
882
- isVisible: true,
883
- children: /* @__PURE__ */ jsx(ComboboxItemImpl, { ref: forwardedRef, value, disabled, ...restProps })
645
+ isVisible: !0,
646
+ children: /* @__PURE__ */ d(Ne, { ref: i, value: e, disabled: t, ...r })
884
647
  }
885
648
  )
886
649
  }
887
650
  );
888
651
  });
889
- ComboboxItem.displayName = ITEM_NAME$1;
890
- const ITEM_IMPL_NAME = "ComboboxItemImpl";
891
- const ComboboxItemImpl = React.forwardRef((props, forwardedRef) => {
892
- const { value, disabled = false, ...restProps } = props;
893
- const itemRef = React.useRef(null);
894
- const composedRefs = useComposedRefs(forwardedRef, itemRef);
895
- const { getItems } = useCollection$1(void 0);
896
- const { onTextValueChange, visuallyFocussedItem, ...context } = useComboboxContext(ITEM_NAME$1);
897
- const { isSelected, textValue, textId } = useComboboxItemContext(ITEM_IMPL_NAME);
898
- const handleSelect = () => {
899
- if (!disabled) {
900
- context.onValueChange(value);
901
- onTextValueChange(textValue);
902
- context.onOpenChange(false);
903
- if (context.autocomplete.type === "both") {
904
- context.onFilterValueChange(textValue);
905
- }
906
- context.trigger?.focus({ preventScroll: true });
907
- }
908
- };
909
- const isFocused = React.useMemo(() => {
910
- return visuallyFocussedItem === getItems().find((item) => item.ref.current === itemRef.current)?.ref.current;
911
- }, [getItems, visuallyFocussedItem]);
912
- const id = useId();
913
- return /* @__PURE__ */ jsx(
914
- Primitive.div,
652
+ Le.displayName = Ie;
653
+ const Et = "ComboboxItemImpl", Ne = s.forwardRef((o, i) => {
654
+ const { value: e, disabled: t = !1, ...n } = o, r = s.useRef(null), c = A(i, r), { getItems: l } = xe(void 0), { onTextValueChange: a, visuallyFocussedItem: m, ...C } = Y(Ie), { isSelected: v, textValue: g, textId: u } = Fe(Et), f = () => {
655
+ var x;
656
+ t || (C.onValueChange(e), a(g), C.onOpenChange(!1), C.autocomplete.type === "both" && C.onFilterValueChange(g), (x = C.trigger) == null || x.focus({ preventScroll: !0 }));
657
+ }, h = s.useMemo(() => {
658
+ var x;
659
+ return m === ((x = l().find((p) => p.ref.current === r.current)) == null ? void 0 : x.ref.current);
660
+ }, [l, m]), b = se();
661
+ return /* @__PURE__ */ d(
662
+ N.div,
915
663
  {
916
664
  role: "option",
917
- "aria-labelledby": textId,
918
- "data-highlighted": isFocused ? "" : void 0,
919
- "aria-selected": isSelected && isFocused,
920
- "data-state": isSelected ? "checked" : "unchecked",
921
- "aria-disabled": disabled || void 0,
922
- "data-disabled": disabled ? "" : void 0,
923
- tabIndex: disabled ? void 0 : -1,
924
- ...restProps,
925
- id,
926
- ref: composedRefs,
927
- onPointerUp: composeEventHandlers$1(restProps.onPointerUp, handleSelect)
665
+ "aria-labelledby": u,
666
+ "data-highlighted": h ? "" : void 0,
667
+ "aria-selected": v && h,
668
+ "data-state": v ? "checked" : "unchecked",
669
+ "aria-disabled": t || void 0,
670
+ "data-disabled": t ? "" : void 0,
671
+ tabIndex: t ? void 0 : -1,
672
+ ...n,
673
+ id: b,
674
+ ref: c,
675
+ onPointerUp: P(n.onPointerUp, f)
928
676
  }
929
677
  );
930
678
  });
931
- ComboboxItemImpl.displayName = ITEM_IMPL_NAME;
932
- const ITEM_TEXT_NAME$1 = "ComboboxItemText";
933
- const ComboboxItemText = React.forwardRef((props, forwardedRef) => {
934
- const { className: _unusedClassName, style: _unusedStyle, ...itemTextProps } = props;
935
- const itemContext = useComboboxItemContext(ITEM_TEXT_NAME$1);
936
- const composedRefs = useComposedRefs(forwardedRef, itemContext.onTextValueChange);
937
- return /* @__PURE__ */ jsx(Primitive.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs });
679
+ Ne.displayName = Et;
680
+ const Nt = "ComboboxItemText", Rt = s.forwardRef((o, i) => {
681
+ const { className: e, style: t, ...n } = o, r = Fe(Nt), c = A(i, r.onTextValueChange);
682
+ return /* @__PURE__ */ d(N.span, { id: r.textId, ...n, ref: c });
938
683
  });
939
- ComboboxItemText.displayName = ITEM_TEXT_NAME$1;
940
- const ITEM_INDICATOR_NAME$1 = "ComboboxItemIndicator";
941
- const ComboboxItemIndicator = React.forwardRef((props, forwardedRef) => {
942
- const { isSelected } = useComboboxItemContext(ITEM_INDICATOR_NAME$1);
943
- return isSelected ? /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...props, ref: forwardedRef }) : null;
684
+ Rt.displayName = Nt;
685
+ const At = "ComboboxItemIndicator", _t = s.forwardRef((o, i) => {
686
+ const { isSelected: e } = Fe(At);
687
+ return e ? /* @__PURE__ */ d(N.span, { "aria-hidden": !0, ...o, ref: i }) : null;
944
688
  });
945
- ComboboxItemIndicator.displayName = ITEM_INDICATOR_NAME$1;
946
- const NO_VALUE_FOUND_NAME = "ComboboxNoValueFound";
947
- const ComboboxNoValueFound = React.forwardRef((props, ref) => {
689
+ _t.displayName = At;
690
+ const Be = "ComboboxNoValueFound", Mt = s.forwardRef((o, i) => {
948
691
  const {
949
- textValue = "",
950
- filterValue = "",
951
- visible = false,
952
- locale,
953
- autocomplete
954
- } = useComboboxContext(NO_VALUE_FOUND_NAME);
955
- const [items, setItems] = React.useState([]);
956
- const { subscribe } = useCollection$1(void 0);
957
- const { startsWith, contains } = useFilter(locale, { sensitivity: "base" });
958
- React.useEffect(() => {
959
- const unsub = subscribe((state) => {
960
- if (visible) {
961
- const filteredItems = state.filter((item) => item.type !== "create");
962
- setItems(filteredItems);
963
- } else {
964
- setItems(state);
965
- }
692
+ textValue: e = "",
693
+ filterValue: t = "",
694
+ visible: n = !1,
695
+ locale: r,
696
+ autocomplete: c
697
+ } = Y(Be), [l, a] = s.useState([]), { subscribe: m } = xe(void 0), { startsWith: C, contains: v } = De(r, { sensitivity: "base" });
698
+ return s.useEffect(() => {
699
+ const g = m((u) => {
700
+ if (n) {
701
+ const f = u.filter((h) => h.type !== "create");
702
+ a(f);
703
+ } else
704
+ a(u);
966
705
  });
967
706
  return () => {
968
- unsub();
707
+ g();
969
708
  };
970
- }, [visible, subscribe]);
971
- if (autocomplete.type === "none" && items.length > 0)
972
- return null;
973
- if (autocomplete.type === "list" && autocomplete.filter === "startsWith" && items.some((item) => startsWith(item.textValue, textValue))) {
974
- return null;
975
- }
976
- if (autocomplete.type === "both" && items.some((item) => startsWith(item.textValue, filterValue))) {
977
- return null;
978
- }
979
- if (autocomplete.type === "list" && autocomplete.filter === "contains" && items.some((item) => contains(item.textValue, textValue))) {
980
- return null;
981
- }
982
- return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref });
709
+ }, [n, m]), c.type === "none" && l.length > 0 || c.type === "list" && c.filter === "startsWith" && l.some((g) => C(g.textValue, e)) || c.type === "both" && l.some((g) => C(g.textValue, t)) || c.type === "list" && c.filter === "contains" && l.some((g) => v(g.textValue, e)) ? null : /* @__PURE__ */ d(N.div, { ...o, ref: i });
983
710
  });
984
- ComboboxNoValueFound.displayName = NO_VALUE_FOUND_NAME;
985
- const ComboboxCreateItem = React.forwardRef((props, ref) => {
986
- const { disabled = false, ...restProps } = props;
987
- const context = useComboboxContext(NO_VALUE_FOUND_NAME);
988
- const { textValue, visuallyFocussedItem } = context;
989
- const { getItems, subscribe } = useCollection$1(void 0);
990
- const itemRef = React.useRef(null);
991
- const [show, setShow] = React.useState(false);
992
- const composedRefs = useComposedRefs(ref, itemRef);
993
- const isFocused = React.useMemo(() => {
994
- return visuallyFocussedItem === getItems().find((item) => item.ref.current === itemRef.current)?.ref.current;
995
- }, [getItems, visuallyFocussedItem]);
996
- const id = useId();
997
- const handleSelect = () => {
998
- if (!disabled && textValue) {
999
- context.onValueChange(textValue);
1000
- context.onTextValueChange(textValue);
1001
- context.onOpenChange(false);
1002
- if (context.autocomplete.type === "both") {
1003
- context.onFilterValueChange(textValue);
1004
- }
1005
- context.trigger?.focus({ preventScroll: true });
1006
- }
711
+ Mt.displayName = Be;
712
+ const Ot = s.forwardRef((o, i) => {
713
+ const { disabled: e = !1, ...t } = o, n = Y(Be), { textValue: r, visuallyFocussedItem: c } = n, { getItems: l, subscribe: a } = xe(void 0), m = s.useRef(null), [C, v] = s.useState(!1), g = A(i, m), u = s.useMemo(() => {
714
+ var b;
715
+ return c === ((b = l().find((x) => x.ref.current === m.current)) == null ? void 0 : b.ref.current);
716
+ }, [l, c]), f = se(), h = () => {
717
+ var b;
718
+ !e && r && (n.onValueChange(r), n.onTextValueChange(r), n.onOpenChange(!1), n.autocomplete.type === "both" && n.onFilterValueChange(r), (b = n.trigger) == null || b.focus({ preventScroll: !0 }));
1007
719
  };
1008
- useLayoutEffect(() => {
1009
- const unsub = subscribe((state) => {
1010
- setShow(!state.some((item) => item.textValue === textValue && item.type !== "create"));
720
+ return $(() => {
721
+ const b = a((x) => {
722
+ v(!x.some((p) => p.textValue === r && p.type !== "create"));
1011
723
  });
1012
- if (getItems().length === 0) {
1013
- setShow(true);
1014
- }
1015
- return () => {
1016
- unsub();
724
+ return l().length === 0 && v(!0), () => {
725
+ b();
1017
726
  };
1018
- }, [textValue, subscribe, getItems]);
1019
- if ((!textValue || !show) && !context.visible) {
1020
- return null;
1021
- }
1022
- return /* @__PURE__ */ jsx(
1023
- Collection$1.ItemSlot,
727
+ }, [r, a, l]), (!r || !C) && !n.visible ? null : /* @__PURE__ */ d(
728
+ re.ItemSlot,
1024
729
  {
1025
730
  scope: void 0,
1026
- value: textValue ?? "",
1027
- textValue: textValue ?? "",
1028
- disabled,
1029
- isVisible: true,
731
+ value: r ?? "",
732
+ textValue: r ?? "",
733
+ disabled: e,
734
+ isVisible: !0,
1030
735
  type: "create",
1031
- children: /* @__PURE__ */ jsx(
1032
- Primitive.div,
736
+ children: /* @__PURE__ */ d(
737
+ N.div,
1033
738
  {
1034
739
  role: "option",
1035
- tabIndex: disabled ? void 0 : -1,
1036
- "aria-disabled": disabled || void 0,
1037
- "data-disabled": disabled ? "" : void 0,
1038
- "data-highlighted": isFocused ? "" : void 0,
1039
- ...restProps,
1040
- id,
1041
- ref: composedRefs,
1042
- onPointerUp: composeEventHandlers$1(restProps.onPointerUp, handleSelect)
740
+ tabIndex: e ? void 0 : -1,
741
+ "aria-disabled": e || void 0,
742
+ "data-disabled": e ? "" : void 0,
743
+ "data-highlighted": u ? "" : void 0,
744
+ ...t,
745
+ id: f,
746
+ ref: g,
747
+ onPointerUp: P(t.onPointerUp, h)
1043
748
  }
1044
749
  )
1045
750
  }
1046
751
  );
1047
752
  });
1048
- ComboboxCreateItem.displayName = "ComboboxCreateItem";
1049
- const Root$1 = Combobox;
1050
- const Trigger$1 = ComboboxTrigger;
1051
- const TextInput = ComboxboxTextInput;
1052
- const Icon$1 = ComboboxIcon;
1053
- const Portal$1 = ComboboxPortal;
1054
- const Content$1 = ComboboxContent;
1055
- const Viewport$1 = ComboboxViewport;
1056
- const Item$1 = ComboboxItem;
1057
- const ItemText$1 = ComboboxItemText;
1058
- const ItemIndicator$1 = ComboboxItemIndicator;
1059
- const NoValueFound = ComboboxNoValueFound;
1060
- const CreateItem = ComboboxCreateItem;
1061
- function findChangedIndex(a, b) {
1062
- const length = Math.min(a.length, b.length);
1063
- for (let i = 0; i < length; i++) {
1064
- if (a[i] !== b[i]) {
1065
- return i;
1066
- }
1067
- }
1068
- return length;
753
+ Ot.displayName = "ComboboxCreateItem";
754
+ const uo = io, po = Ct, fo = bt, mo = yt, ho = St, go = wt, xo = Pt, Co = Le, vo = Rt, bo = _t, yo = Mt, So = Ot;
755
+ function wo(o, i) {
756
+ const e = Math.min(o.length, i.length);
757
+ for (let t = 0; t < e; t++)
758
+ if (o[t] !== i[t])
759
+ return t;
760
+ return e;
1069
761
  }
1070
- const Combobox$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
762
+ const Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1071
763
  __proto__: null,
1072
- ComboboxItem,
1073
- Content: Content$1,
1074
- CreateItem,
1075
- Icon: Icon$1,
1076
- Item: Item$1,
1077
- ItemIndicator: ItemIndicator$1,
1078
- ItemText: ItemText$1,
1079
- NoValueFound,
1080
- Portal: Portal$1,
1081
- Root: Root$1,
1082
- TextInput,
1083
- Trigger: Trigger$1,
1084
- Viewport: Viewport$1
764
+ ComboboxItem: Le,
765
+ Content: go,
766
+ CreateItem: So,
767
+ Icon: mo,
768
+ Item: Co,
769
+ ItemIndicator: bo,
770
+ ItemText: vo,
771
+ NoValueFound: yo,
772
+ Portal: ho,
773
+ Root: uo,
774
+ TextInput: fo,
775
+ Trigger: po,
776
+ Viewport: xo
1085
777
  }, Symbol.toStringTag, { value: "Module" }));
1086
- function useCallbackRef(callback) {
1087
- const callbackRef = React.useRef(callback);
1088
- React.useEffect(() => {
1089
- callbackRef.current = callback;
1090
- });
1091
- return React.useMemo(() => (...args) => callbackRef.current?.(...args), []);
778
+ function Io(o) {
779
+ const i = s.useRef(o);
780
+ return s.useEffect(() => {
781
+ i.current = o;
782
+ }), s.useMemo(() => (...e) => {
783
+ var t;
784
+ return (t = i.current) == null ? void 0 : t.call(i, ...e);
785
+ }, []);
1092
786
  }
1093
- const OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
1094
- const SELECTION_KEYS = [" ", "Enter"];
1095
- const SELECT_NAME = "Select";
1096
- const [Collection, useCollection, createCollectionScope] = createCollection$1(SELECT_NAME);
1097
- const [createSelectContext, createSelectScope] = createContextScope(SELECT_NAME, [
1098
- createCollectionScope,
1099
- createPopperScope
1100
- ]);
1101
- const usePopperScope = createPopperScope();
1102
- const [SelectProvider, useSelectContext] = createSelectContext(SELECT_NAME);
1103
- const [SelectNativeOptionsProvider, useSelectNativeOptionsContext] = createSelectContext(SELECT_NAME);
1104
- const Select = (props) => {
787
+ const To = [" ", "Enter", "ArrowUp", "ArrowDown"], Vo = [" ", "Enter"], Ce = "Select", [Te, ve, Po] = Yt(Ce), [pe, Eo] = st(Ce, [
788
+ Po,
789
+ dt
790
+ ]), Ve = dt(), [No, X] = pe(Ce), [Ro, Ao] = pe(Ce), $e = (o) => {
1105
791
  const {
1106
- __scopeSelect,
1107
- children,
1108
- open: openProp,
1109
- defaultOpen,
1110
- onOpenChange,
1111
- value: valueProp,
1112
- defaultValue,
1113
- onValueChange,
1114
- dir,
792
+ __scopeSelect: i,
793
+ children: e,
794
+ open: t,
795
+ defaultOpen: n,
796
+ onOpenChange: r,
797
+ value: c,
798
+ defaultValue: l,
799
+ onValueChange: a,
800
+ dir: m,
1115
801
  // name,
1116
802
  // autoComplete,
1117
- disabled,
1118
- required,
1119
- multi = false
1120
- } = props;
1121
- const popperScope = usePopperScope(__scopeSelect);
1122
- const [trigger, setTrigger] = React.useState(null);
1123
- const [valueNode, setValueNode] = React.useState(null);
1124
- const [valueNodeHasChildren, setValueNodeHasChildren] = React.useState(false);
1125
- const direction = useDirection(dir);
1126
- const [open = false, setOpen] = useControllableState({
1127
- prop: openProp,
1128
- defaultProp: defaultOpen,
1129
- onChange: onOpenChange
1130
- });
1131
- const [value, setValue] = useControllableState({
1132
- prop: valueProp,
1133
- defaultProp: defaultValue,
1134
- onChange(value2) {
1135
- if (onValueChange) {
1136
- if (Array.isArray(value2)) {
1137
- onValueChange(value2);
1138
- } else {
1139
- onValueChange(value2);
1140
- }
1141
- }
803
+ disabled: C,
804
+ required: v,
805
+ multi: g = !1
806
+ } = o, u = Ve(i), [f, h] = s.useState(null), [b, x] = s.useState(null), [p, y] = s.useState(!1), E = qt(m), [O = !1, F] = de({
807
+ prop: t,
808
+ defaultProp: n,
809
+ onChange: r
810
+ }), [_, k] = de({
811
+ prop: c,
812
+ defaultProp: l,
813
+ onChange(R) {
814
+ a && (Array.isArray(R), a(R));
1142
815
  }
1143
- });
1144
- const triggerPointerDownPosRef = React.useRef(null);
1145
- const [_nativeOptionsSet, setNativeOptionsSet] = React.useState(/* @__PURE__ */ new Set());
1146
- return /* @__PURE__ */ jsx(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ jsx(
1147
- SelectProvider,
816
+ }), Z = s.useRef(null), [U, z] = s.useState(/* @__PURE__ */ new Set());
817
+ return /* @__PURE__ */ d(ie.Root, { ...u, children: /* @__PURE__ */ d(
818
+ No,
1148
819
  {
1149
- required,
1150
- scope: __scopeSelect,
1151
- trigger,
1152
- onTriggerChange: setTrigger,
1153
- valueNode,
1154
- onValueNodeChange: setValueNode,
1155
- valueNodeHasChildren,
1156
- onValueNodeHasChildrenChange: setValueNodeHasChildren,
1157
- contentId: useId(),
1158
- value,
1159
- onValueChange: setValue,
1160
- open,
1161
- onOpenChange: setOpen,
1162
- dir: direction,
1163
- triggerPointerDownPosRef,
1164
- disabled,
1165
- multi,
1166
- children: /* @__PURE__ */ jsx(Collection.Provider, { scope: __scopeSelect, children: /* @__PURE__ */ jsx(
1167
- SelectNativeOptionsProvider,
820
+ required: v,
821
+ scope: i,
822
+ trigger: f,
823
+ onTriggerChange: h,
824
+ valueNode: b,
825
+ onValueNodeChange: x,
826
+ valueNodeHasChildren: p,
827
+ onValueNodeHasChildrenChange: y,
828
+ contentId: se(),
829
+ value: _,
830
+ onValueChange: k,
831
+ open: O,
832
+ onOpenChange: F,
833
+ dir: E,
834
+ triggerPointerDownPosRef: Z,
835
+ disabled: C,
836
+ multi: g,
837
+ children: /* @__PURE__ */ d(Te.Provider, { scope: i, children: /* @__PURE__ */ d(
838
+ Ro,
1168
839
  {
1169
- scope: props.__scopeSelect,
1170
- onNativeOptionAdd: React.useCallback((option) => {
1171
- setNativeOptionsSet((prev) => new Set(prev).add(option));
840
+ scope: o.__scopeSelect,
841
+ onNativeOptionAdd: s.useCallback((R) => {
842
+ z((H) => new Set(H).add(R));
1172
843
  }, []),
1173
- onNativeOptionRemove: React.useCallback((option) => {
1174
- setNativeOptionsSet((prev) => {
1175
- const optionsSet = new Set(prev);
1176
- optionsSet.delete(option);
1177
- return optionsSet;
844
+ onNativeOptionRemove: s.useCallback((R) => {
845
+ z((H) => {
846
+ const L = new Set(H);
847
+ return L.delete(R), L;
1178
848
  });
1179
849
  }, []),
1180
- children
850
+ children: e
1181
851
  }
1182
852
  ) })
1183
853
  }
1184
854
  ) });
1185
855
  };
1186
- Select.displayName = SELECT_NAME;
1187
- const TRIGGER_NAME = "SelectTrigger";
1188
- const SelectTrigger = React.forwardRef(
1189
- (props, forwardedRef) => {
1190
- const { __scopeSelect, ...triggerProps } = props;
1191
- const popperScope = usePopperScope(__scopeSelect);
1192
- const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
1193
- const isDisabled = context.disabled;
1194
- const composedRefs = useComposedRefs(forwardedRef, context.onTriggerChange);
1195
- const getItems = useCollection(__scopeSelect);
1196
- const [searchRef, handleTypeaheadSearch, resetTypeahead] = useTypeaheadSearch((search) => {
1197
- const enabledItems = getItems().filter((item) => !item.disabled);
1198
- const currentItem = enabledItems.find((item) => item.value === context.value);
1199
- const nextItem = findNextItem(enabledItems, search, currentItem);
1200
- if (nextItem !== void 0 && !Array.isArray(nextItem.value)) {
1201
- const newValue = context.multi ? [nextItem.value] : nextItem.value;
1202
- context.onValueChange(newValue);
1203
- }
1204
- });
1205
- const handleOpen = () => {
1206
- if (!isDisabled) {
1207
- context.onOpenChange(true);
1208
- resetTypeahead();
856
+ $e.displayName = Ce;
857
+ const Dt = "SelectTrigger", Ue = s.forwardRef(
858
+ (o, i) => {
859
+ const { __scopeSelect: e, ...t } = o, n = Ve(e), r = X(Dt, e), c = r.disabled, l = A(i, r.onTriggerChange), a = ve(e), [m, C, v] = zt((u) => {
860
+ const f = a().filter((x) => !x.disabled), h = f.find((x) => x.value === r.value), b = Kt(f, u, h);
861
+ if (b !== void 0 && !Array.isArray(b.value)) {
862
+ const x = r.multi ? [b.value] : b.value;
863
+ r.onValueChange(x);
1209
864
  }
865
+ }), g = () => {
866
+ c || (r.onOpenChange(!0), v());
1210
867
  };
1211
- return /* @__PURE__ */ jsx(PopperPrimitive.Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsx(
1212
- Primitive.div,
868
+ return /* @__PURE__ */ d(ie.Anchor, { asChild: !0, ...n, children: /* @__PURE__ */ d(
869
+ N.div,
1213
870
  {
1214
871
  role: "combobox",
1215
- "aria-controls": context.contentId,
1216
- "aria-expanded": context.open,
1217
- "aria-required": context.required,
872
+ "aria-controls": r.contentId,
873
+ "aria-expanded": r.open,
874
+ "aria-required": r.required,
1218
875
  "aria-autocomplete": "none",
1219
- dir: context.dir,
1220
- "data-state": context.open ? "open" : "closed",
1221
- "data-disabled": isDisabled ? "" : void 0,
1222
- "data-placeholder": context.value === void 0 ? "" : void 0,
1223
- tabIndex: isDisabled ? void 0 : 0,
1224
- ...triggerProps,
1225
- ref: composedRefs,
1226
- onClick: composeEventHandlers$1(triggerProps.onClick, (event) => {
1227
- event.currentTarget.focus();
876
+ dir: r.dir,
877
+ "data-state": r.open ? "open" : "closed",
878
+ "data-disabled": c ? "" : void 0,
879
+ "data-placeholder": r.value === void 0 ? "" : void 0,
880
+ tabIndex: c ? void 0 : 0,
881
+ ...t,
882
+ ref: l,
883
+ onClick: P(t.onClick, (u) => {
884
+ u.currentTarget.focus();
1228
885
  }),
1229
- onPointerDown: composeEventHandlers$1(triggerProps.onPointerDown, (event) => {
1230
- const target = event.target;
1231
- if (target.hasPointerCapture(event.pointerId)) {
1232
- target.releasePointerCapture(event.pointerId);
1233
- }
1234
- const buttonTarg = target.closest("button") ?? target.closest("div");
1235
- if (buttonTarg !== event.currentTarget) {
1236
- return;
1237
- }
1238
- if (event.button === 0 && event.ctrlKey === false) {
1239
- handleOpen();
1240
- context.triggerPointerDownPosRef.current = {
1241
- x: Math.round(event.pageX),
1242
- y: Math.round(event.pageY)
1243
- };
1244
- event.preventDefault();
1245
- }
886
+ onPointerDown: P(t.onPointerDown, (u) => {
887
+ const f = u.target;
888
+ f.hasPointerCapture(u.pointerId) && f.releasePointerCapture(u.pointerId), (f.closest("button") ?? f.closest("div")) === u.currentTarget && u.button === 0 && u.ctrlKey === !1 && (g(), r.triggerPointerDownPosRef.current = {
889
+ x: Math.round(u.pageX),
890
+ y: Math.round(u.pageY)
891
+ }, u.preventDefault());
1246
892
  }),
1247
- onKeyDown: composeEventHandlers$1(triggerProps.onKeyDown, (event) => {
1248
- const isTypingAhead = searchRef.current !== "";
1249
- const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
1250
- const target = event.target;
1251
- const buttonTarg = target.closest("button") ?? target.closest("div");
1252
- if (buttonTarg !== event.currentTarget) {
1253
- return;
1254
- }
1255
- if (!isModifierKey && event.key.length === 1)
1256
- handleTypeaheadSearch(event.key);
1257
- if (isTypingAhead && event.key === " ")
1258
- return;
1259
- if (OPEN_KEYS.includes(event.key)) {
1260
- handleOpen();
1261
- event.preventDefault();
1262
- }
893
+ onKeyDown: P(t.onKeyDown, (u) => {
894
+ const f = m.current !== "", h = u.ctrlKey || u.altKey || u.metaKey, b = u.target;
895
+ (b.closest("button") ?? b.closest("div")) === u.currentTarget && (!h && u.key.length === 1 && C(u.key), !(f && u.key === " ") && To.includes(u.key) && (g(), u.preventDefault()));
1263
896
  })
1264
897
  }
1265
898
  ) });
1266
899
  }
1267
900
  );
1268
- SelectTrigger.displayName = TRIGGER_NAME;
1269
- const VALUE_NAME = "SelectValue";
1270
- const SelectValue = React.forwardRef(
1271
- (props, forwardedRef) => {
1272
- const { __scopeSelect, children, placeholder, ...valueProps } = props;
1273
- const context = useSelectContext(VALUE_NAME, __scopeSelect);
1274
- const { onValueNodeHasChildrenChange } = context;
1275
- const hasChildren = children !== void 0;
1276
- const composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange);
1277
- const [valuedItems, setValuedItems] = React.useState([]);
1278
- const getItems = useCollection(__scopeSelect);
1279
- useLayoutEffect(() => {
1280
- onValueNodeHasChildrenChange(hasChildren);
1281
- }, [onValueNodeHasChildrenChange, hasChildren]);
1282
- React.useLayoutEffect(() => {
1283
- if (Array.isArray(context.value) && valuedItems.length !== context.value.length) {
1284
- const timeout = setTimeout(() => {
1285
- const valuedItems2 = getItems().filter(
1286
- (item) => !Array.isArray(item.value) ? context.value?.includes(item.value) : false
901
+ Ue.displayName = Dt;
902
+ const kt = "SelectValue", He = s.forwardRef(
903
+ (o, i) => {
904
+ const { __scopeSelect: e, children: t, placeholder: n, ...r } = o, c = X(kt, e), { onValueNodeHasChildrenChange: l } = c, a = t !== void 0, m = A(i, c.onValueNodeChange), [C, v] = s.useState([]), g = ve(e);
905
+ $(() => {
906
+ l(a);
907
+ }, [l, a]), s.useLayoutEffect(() => {
908
+ if (Array.isArray(c.value) && C.length !== c.value.length) {
909
+ const f = setTimeout(() => {
910
+ const h = g().filter(
911
+ (b) => {
912
+ var x;
913
+ return Array.isArray(b.value) ? !1 : (x = c.value) == null ? void 0 : x.includes(b.value);
914
+ }
1287
915
  );
1288
- setValuedItems(valuedItems2);
916
+ v(h);
1289
917
  });
1290
918
  return () => {
1291
- clearTimeout(timeout);
919
+ clearTimeout(f);
1292
920
  };
1293
921
  }
1294
- }, [context.value, getItems, valuedItems]);
1295
- let renderValue;
1296
- if ((context.value === void 0 || context.value.length === 0) && placeholder !== void 0) {
1297
- renderValue = /* @__PURE__ */ jsx("span", { children: placeholder });
1298
- } else if (typeof children === "function") {
1299
- if (Array.isArray(context.value)) {
1300
- const childrenArray = context.value.map((value) => {
1301
- const valueItem = valuedItems.find((item) => item.value === value);
1302
- if (!valueItem) {
1303
- return null;
1304
- }
1305
- return children({ value, textValue: valueItem?.textValue });
922
+ }, [c.value, g, C]);
923
+ let u;
924
+ if ((c.value === void 0 || c.value.length === 0) && n !== void 0)
925
+ u = /* @__PURE__ */ d("span", { children: n });
926
+ else if (typeof t == "function")
927
+ if (Array.isArray(c.value)) {
928
+ const f = c.value.map((h) => {
929
+ const b = C.find((x) => x.value === h);
930
+ return b ? t({ value: h, textValue: b == null ? void 0 : b.textValue }) : null;
1306
931
  });
1307
- renderValue = childrenArray.every((child) => child === null) ? placeholder : childrenArray;
1308
- } else {
1309
- renderValue = children(context.value);
1310
- }
1311
- } else {
1312
- renderValue = children;
1313
- }
1314
- return /* @__PURE__ */ jsx(Primitive.span, { ...valueProps, ref: composedRefs, children: renderValue || null });
932
+ u = f.every((h) => h === null) ? n : f;
933
+ } else
934
+ u = t(c.value);
935
+ else
936
+ u = t;
937
+ return /* @__PURE__ */ d(N.span, { ...r, ref: m, children: u || null });
1315
938
  }
1316
939
  );
1317
- SelectValue.displayName = VALUE_NAME;
1318
- const ICON_NAME = "SelectIcon";
1319
- const SelectIcon = React.forwardRef(
1320
- (props, forwardedRef) => {
1321
- const { __scopeSelect, children, ...iconProps } = props;
1322
- return /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...iconProps, ref: forwardedRef, children: children || "▼" });
940
+ He.displayName = kt;
941
+ const _o = "SelectIcon", We = s.forwardRef(
942
+ (o, i) => {
943
+ const { __scopeSelect: e, children: t, ...n } = o;
944
+ return /* @__PURE__ */ d(N.span, { "aria-hidden": !0, ...n, ref: i, children: t || "▼" });
1323
945
  }
1324
946
  );
1325
- SelectIcon.displayName = ICON_NAME;
1326
- const PORTAL_NAME = "SelectPortal";
1327
- const SelectPortal = (props) => {
1328
- return /* @__PURE__ */ jsx(Portal$2, { asChild: true, ...props });
1329
- };
1330
- SelectPortal.displayName = PORTAL_NAME;
1331
- const CONTENT_NAME = "SelectContent";
1332
- const SelectContent = React.forwardRef(
1333
- (props, forwardedRef) => {
1334
- const context = useSelectContext(CONTENT_NAME, props.__scopeSelect);
1335
- const [fragment, setFragment] = React.useState();
1336
- useLayoutEffect(() => {
1337
- setFragment(new DocumentFragment());
1338
- }, []);
1339
- if (!context.open) {
1340
- const frag = fragment;
1341
- return frag ? ReactDOM.createPortal(
1342
- /* @__PURE__ */ jsx(SelectContentProvider, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsx(Collection.Slot, { scope: props.__scopeSelect, children: /* @__PURE__ */ jsx("div", { children: props.children }) }) }),
1343
- frag
947
+ We.displayName = _o;
948
+ const Mo = "SelectPortal", ze = (o) => /* @__PURE__ */ d(pt, { asChild: !0, ...o });
949
+ ze.displayName = Mo;
950
+ const le = "SelectContent", Ke = s.forwardRef(
951
+ (o, i) => {
952
+ const e = X(le, o.__scopeSelect), [t, n] = s.useState();
953
+ if ($(() => {
954
+ n(new DocumentFragment());
955
+ }, []), !e.open) {
956
+ const r = t;
957
+ return r ? we.createPortal(
958
+ /* @__PURE__ */ d(Ft, { scope: o.__scopeSelect, children: /* @__PURE__ */ d(Te.Slot, { scope: o.__scopeSelect, children: /* @__PURE__ */ d("div", { children: o.children }) }) }),
959
+ r
1344
960
  ) : null;
1345
961
  }
1346
- return /* @__PURE__ */ jsx(SelectContentImpl, { ...props, ref: forwardedRef });
962
+ return /* @__PURE__ */ d(Lt, { ...o, ref: i });
1347
963
  }
1348
964
  );
1349
- SelectContent.displayName = CONTENT_NAME;
1350
- const CONTENT_MARGIN = 10;
1351
- const [SelectContentProvider, useSelectContentContext] = createSelectContext(CONTENT_NAME);
1352
- const CONTENT_IMPL_NAME = "SelectContentImpl";
1353
- const SelectContentImpl = React.forwardRef(
1354
- (props, forwardedRef) => {
965
+ Ke.displayName = le;
966
+ const q = 10, [Ft, oe] = pe(le), Oo = "SelectContentImpl", Lt = s.forwardRef(
967
+ (o, i) => {
1355
968
  const {
1356
- __scopeSelect,
1357
- position = "item-aligned",
1358
- onCloseAutoFocus,
1359
- onEscapeKeyDown,
1360
- onPointerDownOutside,
969
+ __scopeSelect: e,
970
+ position: t = "item-aligned",
971
+ onCloseAutoFocus: n,
972
+ onEscapeKeyDown: r,
973
+ onPointerDownOutside: c,
1361
974
  //
1362
975
  // PopperContent props
1363
- side,
1364
- sideOffset,
1365
- align,
1366
- alignOffset,
1367
- arrowPadding,
1368
- collisionBoundary,
1369
- collisionPadding,
1370
- sticky,
1371
- hideWhenDetached,
1372
- avoidCollisions,
976
+ side: l,
977
+ sideOffset: a,
978
+ align: m,
979
+ alignOffset: C,
980
+ arrowPadding: v,
981
+ collisionBoundary: g,
982
+ collisionPadding: u,
983
+ sticky: f,
984
+ hideWhenDetached: h,
985
+ avoidCollisions: b,
1373
986
  //
1374
- ...contentProps
1375
- } = props;
1376
- const context = useSelectContext(CONTENT_NAME, __scopeSelect);
1377
- const [content, setContent] = React.useState(null);
1378
- const [viewport, setViewport] = React.useState(null);
1379
- const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
1380
- const [selectedItem, setSelectedItem] = React.useState(null);
1381
- const [selectedItemText, setSelectedItemText] = React.useState(null);
1382
- const getItems = useCollection(__scopeSelect);
1383
- const [isPositioned, setIsPositioned] = React.useState(false);
1384
- const firstValidItemFoundRef = React.useRef(false);
1385
- React.useEffect(() => {
1386
- if (content)
1387
- return hideOthers(content);
1388
- }, [content]);
1389
- useFocusGuards();
1390
- const focusFirst = React.useCallback(
1391
- (candidates) => {
1392
- const [firstItem, ...restItems] = getItems().map((item) => item.ref.current);
1393
- const [lastItem] = restItems.slice(-1);
1394
- const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
1395
- for (const candidate of candidates) {
1396
- if (candidate === PREVIOUSLY_FOCUSED_ELEMENT)
1397
- return;
1398
- candidate?.scrollIntoView({ block: "nearest" });
1399
- if (candidate === firstItem && viewport)
1400
- viewport.scrollTop = 0;
1401
- if (candidate === lastItem && viewport)
1402
- viewport.scrollTop = viewport.scrollHeight;
1403
- candidate?.focus();
1404
- if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT)
1405
- return;
1406
- }
987
+ ...x
988
+ } = o, p = X(le, e), [y, E] = s.useState(null), [O, F] = s.useState(null), _ = A(i, (S) => E(S)), [k, Z] = s.useState(null), [U, z] = s.useState(null), R = ve(e), [H, L] = s.useState(!1), W = s.useRef(!1);
989
+ s.useEffect(() => {
990
+ if (y) return ft(y);
991
+ }, [y]), at();
992
+ const J = s.useCallback(
993
+ (S) => {
994
+ const [I, ...M] = R().map((w) => w.ref.current), [V] = M.slice(-1), T = document.activeElement;
995
+ for (const w of S)
996
+ if (w === T || (w == null || w.scrollIntoView({ block: "nearest" }), w === I && O && (O.scrollTop = 0), w === V && O && (O.scrollTop = O.scrollHeight), w == null || w.focus(), document.activeElement !== T)) return;
1407
997
  },
1408
- [getItems, viewport]
998
+ [R, O]
999
+ ), Q = s.useCallback(
1000
+ () => J([k, y]),
1001
+ [J, k, y]
1409
1002
  );
1410
- const focusSelectedItem = React.useCallback(
1411
- () => focusFirst([selectedItem, content]),
1412
- [focusFirst, selectedItem, content]
1413
- );
1414
- React.useEffect(() => {
1415
- if (isPositioned) {
1416
- focusSelectedItem();
1417
- }
1418
- }, [isPositioned, focusSelectedItem]);
1419
- const { onOpenChange, triggerPointerDownPosRef } = context;
1420
- React.useEffect(() => {
1421
- if (content) {
1422
- let pointerMoveDelta = { x: 0, y: 0 };
1423
- const handlePointerMove = (event) => {
1424
- pointerMoveDelta = {
1425
- x: Math.abs(Math.round(event.pageX) - (triggerPointerDownPosRef.current?.x ?? 0)),
1426
- y: Math.abs(Math.round(event.pageY) - (triggerPointerDownPosRef.current?.y ?? 0))
1003
+ s.useEffect(() => {
1004
+ H && Q();
1005
+ }, [H, Q]);
1006
+ const { onOpenChange: K, triggerPointerDownPosRef: G } = p;
1007
+ s.useEffect(() => {
1008
+ if (y) {
1009
+ let S = { x: 0, y: 0 };
1010
+ const I = (V) => {
1011
+ var T, w;
1012
+ S = {
1013
+ x: Math.abs(Math.round(V.pageX) - (((T = G.current) == null ? void 0 : T.x) ?? 0)),
1014
+ y: Math.abs(Math.round(V.pageY) - (((w = G.current) == null ? void 0 : w.y) ?? 0))
1427
1015
  };
1016
+ }, M = (V) => {
1017
+ S.x <= 10 && S.y <= 10 ? V.preventDefault() : y.contains(V.target) || K(!1), document.removeEventListener("pointermove", I), G.current = null;
1428
1018
  };
1429
- const handlePointerUp = (event) => {
1430
- if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) {
1431
- event.preventDefault();
1432
- } else if (!content.contains(event.target)) {
1433
- onOpenChange(false);
1434
- }
1435
- document.removeEventListener("pointermove", handlePointerMove);
1436
- triggerPointerDownPosRef.current = null;
1437
- };
1438
- if (triggerPointerDownPosRef.current !== null) {
1439
- document.addEventListener("pointermove", handlePointerMove);
1440
- document.addEventListener("pointerup", handlePointerUp, { capture: true, once: true });
1441
- }
1442
- return () => {
1443
- document.removeEventListener("pointermove", handlePointerMove);
1444
- document.removeEventListener("pointerup", handlePointerUp, { capture: true });
1019
+ return G.current !== null && (document.addEventListener("pointermove", I), document.addEventListener("pointerup", M, { capture: !0, once: !0 })), () => {
1020
+ document.removeEventListener("pointermove", I), document.removeEventListener("pointerup", M, { capture: !0 });
1445
1021
  };
1446
1022
  }
1447
- }, [content, onOpenChange, triggerPointerDownPosRef]);
1448
- React.useEffect(() => {
1449
- const close = () => onOpenChange(false);
1450
- window.addEventListener("blur", close);
1451
- window.addEventListener("resize", close);
1452
- return () => {
1453
- window.removeEventListener("blur", close);
1454
- window.removeEventListener("resize", close);
1023
+ }, [y, K, G]), s.useEffect(() => {
1024
+ const S = () => K(!1);
1025
+ return window.addEventListener("blur", S), window.addEventListener("resize", S), () => {
1026
+ window.removeEventListener("blur", S), window.removeEventListener("resize", S);
1455
1027
  };
1456
- }, [onOpenChange]);
1457
- const [searchRef, handleTypeaheadSearch] = useTypeaheadSearch((search) => {
1458
- const enabledItems = getItems().filter((item) => !item.disabled);
1459
- const currentItem = enabledItems.find((item) => item.ref.current === document.activeElement);
1460
- const nextItem = findNextItem(enabledItems, search, currentItem);
1461
- if (nextItem) {
1462
- setTimeout(() => nextItem.ref.current.focus());
1463
- }
1464
- });
1465
- const itemRefCallback = React.useCallback(
1466
- (node, value, disabled) => {
1467
- const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
1468
- const isSelectedItem = context.value !== void 0 && context.value === value;
1469
- if (isSelectedItem || isFirstValidItem) {
1470
- setSelectedItem(node);
1471
- if (isFirstValidItem)
1472
- firstValidItemFoundRef.current = true;
1473
- }
1028
+ }, [K]);
1029
+ const [ce, ee] = zt((S) => {
1030
+ const I = R().filter((T) => !T.disabled), M = I.find((T) => T.ref.current === document.activeElement), V = Kt(I, S, M);
1031
+ V && setTimeout(() => V.ref.current.focus());
1032
+ }), fe = s.useCallback(
1033
+ (S, I, M) => {
1034
+ const V = !W.current && !M;
1035
+ (p.value !== void 0 && p.value === I || V) && (Z(S), V && (W.current = !0));
1474
1036
  },
1475
- [context.value]
1476
- );
1477
- const handleItemLeave = React.useCallback(() => content?.focus(), [content]);
1478
- const itemTextRefCallback = React.useCallback(
1479
- (node, value, disabled) => {
1480
- const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
1481
- const isSelectedItem = context.value !== void 0 && (Array.isArray(value) ? value.every((v) => context.value?.includes(v)) : context.value === value);
1482
- if (isSelectedItem || isFirstValidItem) {
1483
- setSelectedItemText(node);
1484
- }
1037
+ [p.value]
1038
+ ), me = s.useCallback(() => y == null ? void 0 : y.focus(), [y]), te = s.useCallback(
1039
+ (S, I, M) => {
1040
+ const V = !W.current && !M;
1041
+ (p.value !== void 0 && (Array.isArray(I) ? I.every((w) => {
1042
+ var B;
1043
+ return (B = p.value) == null ? void 0 : B.includes(w);
1044
+ }) : p.value === I) || V) && z(S);
1485
1045
  },
1486
- [context.value]
1487
- );
1488
- const SelectPosition = position === "popper" ? SelectPopperPosition : SelectItemAlignedPosition;
1489
- const popperContentProps = SelectPosition === SelectPopperPosition ? {
1490
- side,
1491
- sideOffset,
1492
- align,
1493
- alignOffset,
1494
- arrowPadding,
1495
- collisionBoundary,
1496
- collisionPadding,
1497
- sticky,
1498
- hideWhenDetached,
1499
- avoidCollisions
1046
+ [p.value]
1047
+ ), ae = t === "popper" ? Re : Bt, ne = ae === Re ? {
1048
+ side: l,
1049
+ sideOffset: a,
1050
+ align: m,
1051
+ alignOffset: C,
1052
+ arrowPadding: v,
1053
+ collisionBoundary: g,
1054
+ collisionPadding: u,
1055
+ sticky: f,
1056
+ hideWhenDetached: h,
1057
+ avoidCollisions: b
1500
1058
  } : {};
1501
- return /* @__PURE__ */ jsx(
1502
- SelectContentProvider,
1059
+ return /* @__PURE__ */ d(
1060
+ Ft,
1503
1061
  {
1504
- scope: __scopeSelect,
1505
- content,
1506
- viewport,
1507
- onViewportChange: setViewport,
1508
- itemRefCallback,
1509
- selectedItem,
1510
- onItemLeave: handleItemLeave,
1511
- itemTextRefCallback,
1512
- focusSelectedItem,
1513
- selectedItemText,
1514
- position,
1515
- isPositioned,
1516
- searchRef,
1517
- children: /* @__PURE__ */ jsx(RemoveScroll, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsx(
1518
- FocusScope,
1062
+ scope: e,
1063
+ content: y,
1064
+ viewport: O,
1065
+ onViewportChange: F,
1066
+ itemRefCallback: fe,
1067
+ selectedItem: k,
1068
+ onItemLeave: me,
1069
+ itemTextRefCallback: te,
1070
+ focusSelectedItem: Q,
1071
+ selectedItemText: U,
1072
+ position: t,
1073
+ isPositioned: H,
1074
+ searchRef: ce,
1075
+ children: /* @__PURE__ */ d(mt, { as: Ee, allowPinchZoom: !0, children: /* @__PURE__ */ d(
1076
+ ut,
1519
1077
  {
1520
- asChild: true,
1521
- trapped: context.open,
1522
- onMountAutoFocus: (event) => {
1523
- event.preventDefault();
1078
+ asChild: !0,
1079
+ trapped: p.open,
1080
+ onMountAutoFocus: (S) => {
1081
+ S.preventDefault();
1524
1082
  },
1525
- onUnmountAutoFocus: composeEventHandlers$1(onCloseAutoFocus, (event) => {
1526
- context.trigger?.focus({ preventScroll: true });
1527
- document.getSelection()?.empty();
1528
- event.preventDefault();
1083
+ onUnmountAutoFocus: P(n, (S) => {
1084
+ var I, M;
1085
+ (I = p.trigger) == null || I.focus({ preventScroll: !0 }), (M = document.getSelection()) == null || M.empty(), S.preventDefault();
1529
1086
  }),
1530
- children: /* @__PURE__ */ jsx(
1531
- DismissableLayer,
1087
+ children: /* @__PURE__ */ d(
1088
+ ct,
1532
1089
  {
1533
- asChild: true,
1534
- disableOutsidePointerEvents: true,
1535
- onEscapeKeyDown,
1536
- onPointerDownOutside,
1537
- onFocusOutside: (event) => event.preventDefault(),
1538
- onDismiss: () => context.onOpenChange(false),
1539
- children: /* @__PURE__ */ jsx(
1540
- SelectPosition,
1090
+ asChild: !0,
1091
+ disableOutsidePointerEvents: !0,
1092
+ onEscapeKeyDown: r,
1093
+ onPointerDownOutside: c,
1094
+ onFocusOutside: (S) => S.preventDefault(),
1095
+ onDismiss: () => p.onOpenChange(!1),
1096
+ children: /* @__PURE__ */ d(
1097
+ ae,
1541
1098
  {
1542
1099
  role: "listbox",
1543
- id: context.contentId,
1544
- "data-state": context.open ? "open" : "closed",
1545
- "aria-multiselectable": context.multi ? "true" : void 0,
1546
- dir: context.dir,
1547
- onContextMenu: (event) => event.preventDefault(),
1548
- ...contentProps,
1549
- ...popperContentProps,
1550
- onPlaced: () => setIsPositioned(true),
1551
- ref: composedRefs,
1100
+ id: p.contentId,
1101
+ "data-state": p.open ? "open" : "closed",
1102
+ "aria-multiselectable": p.multi ? "true" : void 0,
1103
+ dir: p.dir,
1104
+ onContextMenu: (S) => S.preventDefault(),
1105
+ ...x,
1106
+ ...ne,
1107
+ onPlaced: () => L(!0),
1108
+ ref: _,
1552
1109
  style: {
1553
1110
  // flex layout so we can place the scroll buttons properly
1554
1111
  display: "flex",
1555
1112
  flexDirection: "column",
1556
1113
  // reset the outline by default as the content MAY get focused
1557
1114
  outline: "none",
1558
- ...contentProps.style
1115
+ ...x.style
1559
1116
  },
1560
- onKeyDown: composeEventHandlers$1(contentProps.onKeyDown, (event) => {
1561
- const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
1562
- if (event.key === "Tab")
1563
- event.preventDefault();
1564
- if (!isModifierKey && event.key.length === 1)
1565
- handleTypeaheadSearch(event.key);
1566
- if (["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
1567
- const items = getItems().filter((item) => !item.disabled);
1568
- let candidateNodes = items.map((item) => item.ref.current);
1569
- if (["ArrowUp", "End"].includes(event.key)) {
1570
- candidateNodes = candidateNodes.slice().reverse();
1571
- }
1572
- if (["ArrowUp", "ArrowDown"].includes(event.key)) {
1573
- const currentElement = event.target;
1574
- const currentIndex = candidateNodes.indexOf(currentElement);
1575
- candidateNodes = candidateNodes.slice(currentIndex + 1);
1117
+ onKeyDown: P(x.onKeyDown, (S) => {
1118
+ const I = S.ctrlKey || S.altKey || S.metaKey;
1119
+ if (S.key === "Tab" && S.preventDefault(), !I && S.key.length === 1 && ee(S.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(S.key)) {
1120
+ let V = R().filter((T) => !T.disabled).map((T) => T.ref.current);
1121
+ if (["ArrowUp", "End"].includes(S.key) && (V = V.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(S.key)) {
1122
+ const T = S.target, w = V.indexOf(T);
1123
+ V = V.slice(w + 1);
1576
1124
  }
1577
- setTimeout(() => focusFirst(candidateNodes));
1578
- event.preventDefault();
1125
+ setTimeout(() => J(V)), S.preventDefault();
1579
1126
  }
1580
1127
  })
1581
1128
  }
@@ -1588,153 +1135,93 @@ const SelectContentImpl = React.forwardRef(
1588
1135
  );
1589
1136
  }
1590
1137
  );
1591
- SelectContentImpl.displayName = CONTENT_IMPL_NAME;
1592
- const ITEM_ALIGNED_POSITION_NAME = "SelectItemAlignedPosition";
1593
- const SelectItemAlignedPosition = React.forwardRef(
1594
- (props, forwardedRef) => {
1595
- const { __scopeSelect, onPlaced, ...popperProps } = props;
1596
- const context = useSelectContext(CONTENT_NAME, __scopeSelect);
1597
- const contentContext = useSelectContentContext(CONTENT_NAME, __scopeSelect);
1598
- const [contentWrapper, setContentWrapper] = React.useState(null);
1599
- const [content, setContent] = React.useState(null);
1600
- const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
1601
- const getItems = useCollection(__scopeSelect);
1602
- const shouldExpandOnScrollRef = React.useRef(false);
1603
- const shouldRepositionRef = React.useRef(true);
1604
- const { viewport, selectedItem, selectedItemText, focusSelectedItem } = contentContext;
1605
- const position = React.useCallback(() => {
1606
- if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
1607
- const triggerRect = context.trigger.getBoundingClientRect();
1608
- const contentRect = content.getBoundingClientRect();
1609
- const valueNodeRect = context.valueNode.getBoundingClientRect();
1610
- const itemTextRect = selectedItemText.getBoundingClientRect();
1611
- if (context.dir !== "rtl") {
1612
- const itemTextOffset = itemTextRect.left - contentRect.left;
1613
- const left = valueNodeRect.left - itemTextOffset;
1614
- const leftDelta = triggerRect.left - left;
1615
- const minContentWidth = triggerRect.width + leftDelta;
1616
- const contentWidth = Math.max(minContentWidth, contentRect.width);
1617
- const rightEdge = window.innerWidth - CONTENT_MARGIN;
1618
- const clampedLeft = clamp(left, [CONTENT_MARGIN, rightEdge - contentWidth]);
1619
- contentWrapper.style.minWidth = `${minContentWidth}px`;
1620
- contentWrapper.style.left = `${clampedLeft}px`;
1138
+ Lt.displayName = Oo;
1139
+ const Do = "SelectItemAlignedPosition", Bt = s.forwardRef(
1140
+ (o, i) => {
1141
+ const { __scopeSelect: e, onPlaced: t, ...n } = o, r = X(le, e), c = oe(le, e), [l, a] = s.useState(null), [m, C] = s.useState(null), v = A(i, (_) => C(_)), g = ve(e), u = s.useRef(!1), f = s.useRef(!0), { viewport: h, selectedItem: b, selectedItemText: x, focusSelectedItem: p } = c, y = s.useCallback(() => {
1142
+ if (r.trigger && r.valueNode && l && m && h && b && x) {
1143
+ const _ = r.trigger.getBoundingClientRect(), k = m.getBoundingClientRect(), Z = r.valueNode.getBoundingClientRect(), U = x.getBoundingClientRect();
1144
+ if (r.dir !== "rtl") {
1145
+ const T = U.left - k.left, w = Z.left - T, B = _.left - w, j = _.width + B, D = Math.max(j, k.width), ue = window.innerWidth - q, he = rt(w, [q, ue - D]);
1146
+ l.style.minWidth = `${j}px`, l.style.left = `${he}px`;
1621
1147
  } else {
1622
- const itemTextOffset = contentRect.right - itemTextRect.right;
1623
- const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
1624
- const rightDelta = window.innerWidth - triggerRect.right - right;
1625
- const minContentWidth = triggerRect.width + rightDelta;
1626
- const contentWidth = Math.max(minContentWidth, contentRect.width);
1627
- const leftEdge = window.innerWidth - CONTENT_MARGIN;
1628
- const clampedRight = clamp(right, [CONTENT_MARGIN, leftEdge - contentWidth]);
1629
- contentWrapper.style.minWidth = `${minContentWidth}px`;
1630
- contentWrapper.style.right = `${clampedRight}px`;
1148
+ const T = k.right - U.right, w = window.innerWidth - Z.right - T, B = window.innerWidth - _.right - w, j = _.width + B, D = Math.max(j, k.width), ue = window.innerWidth - q, he = rt(w, [q, ue - D]);
1149
+ l.style.minWidth = `${j}px`, l.style.right = `${he}px`;
1631
1150
  }
1632
- const items = getItems();
1633
- const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
1634
- const itemsHeight = viewport.scrollHeight;
1635
- const contentStyles = window.getComputedStyle(content);
1636
- const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
1637
- const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
1638
- const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
1639
- const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
1640
- const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth;
1641
- const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
1642
- const viewportStyles = window.getComputedStyle(viewport);
1643
- const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
1644
- const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
1645
- const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - CONTENT_MARGIN;
1646
- const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
1647
- const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
1648
- const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
1649
- const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
1650
- const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
1651
- const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
1652
- if (willAlignWithoutTopOverflow) {
1653
- const isLastItem = selectedItem === items[items.length - 1].ref.current;
1654
- contentWrapper.style.bottom = `${0}px`;
1655
- const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
1656
- const clampedTriggerMiddleToBottomEdge = Math.max(
1657
- triggerMiddleToBottomEdge,
1658
- selectedItemHalfHeight + // viewport might have padding bottom, include it to avoid a scrollable viewport
1659
- (isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth
1660
- );
1661
- const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
1662
- contentWrapper.style.height = `${height}px`;
1151
+ const z = g(), R = window.innerHeight - q * 2, H = h.scrollHeight, L = window.getComputedStyle(m), W = parseInt(L.borderTopWidth, 10), J = parseInt(L.paddingTop, 10), Q = parseInt(L.borderBottomWidth, 10), K = parseInt(L.paddingBottom, 10), G = W + J + H + K + Q, ce = Math.min(b.offsetHeight * 5, G), ee = window.getComputedStyle(h), fe = parseInt(ee.paddingTop, 10), me = parseInt(ee.paddingBottom, 10), te = _.top + _.height / 2 - q, ae = R - te, ne = b.offsetHeight / 2, S = b.offsetTop + ne, I = W + J + S, M = G - I;
1152
+ if (I <= te) {
1153
+ const T = b === z[z.length - 1].ref.current;
1154
+ l.style.bottom = "0px";
1155
+ const w = m.clientHeight - h.offsetTop - h.offsetHeight, B = Math.max(
1156
+ ae,
1157
+ ne + // viewport might have padding bottom, include it to avoid a scrollable viewport
1158
+ (T ? me : 0) + w + Q
1159
+ ), j = I + B;
1160
+ l.style.height = `${j}px`;
1663
1161
  } else {
1664
- const isFirstItem = selectedItem === items[0].ref.current;
1665
- contentWrapper.style.top = `${0}px`;
1666
- const clampedTopEdgeToTriggerMiddle = Math.max(
1667
- topEdgeToTriggerMiddle,
1668
- contentBorderTopWidth + viewport.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
1669
- (isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight
1670
- );
1671
- const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
1672
- contentWrapper.style.height = `${height}px`;
1673
- viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
1162
+ const T = b === z[0].ref.current;
1163
+ l.style.top = "0px";
1164
+ const B = Math.max(
1165
+ te,
1166
+ W + h.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
1167
+ (T ? fe : 0) + ne
1168
+ ) + M;
1169
+ l.style.height = `${B}px`, h.scrollTop = I - te + h.offsetTop;
1674
1170
  }
1675
- contentWrapper.style.margin = `${CONTENT_MARGIN}px 0`;
1676
- contentWrapper.style.minHeight = `${minContentHeight}px`;
1677
- contentWrapper.style.maxHeight = `${availableHeight}px`;
1678
- onPlaced?.();
1679
- requestAnimationFrame(() => shouldExpandOnScrollRef.current = true);
1171
+ l.style.margin = `${q}px 0`, l.style.minHeight = `${ce}px`, l.style.maxHeight = `${R}px`, t == null || t(), requestAnimationFrame(() => u.current = !0);
1680
1172
  }
1681
1173
  }, [
1682
- getItems,
1683
- context.trigger,
1684
- context.valueNode,
1685
- contentWrapper,
1686
- content,
1687
- viewport,
1688
- selectedItem,
1689
- selectedItemText,
1690
- context.dir,
1691
- onPlaced
1174
+ g,
1175
+ r.trigger,
1176
+ r.valueNode,
1177
+ l,
1178
+ m,
1179
+ h,
1180
+ b,
1181
+ x,
1182
+ r.dir,
1183
+ t
1692
1184
  ]);
1693
- useLayoutEffect(() => position(), [position]);
1694
- const [contentZIndex, setContentZIndex] = React.useState();
1695
- useLayoutEffect(() => {
1696
- if (content)
1697
- setContentZIndex(window.getComputedStyle(content).zIndex);
1698
- }, [content]);
1699
- const handleScrollButtonChange = React.useCallback(
1700
- (node) => {
1701
- if (node && shouldRepositionRef.current === true) {
1702
- position();
1703
- focusSelectedItem?.();
1704
- shouldRepositionRef.current = false;
1705
- }
1185
+ $(() => y(), [y]);
1186
+ const [E, O] = s.useState();
1187
+ $(() => {
1188
+ m && O(window.getComputedStyle(m).zIndex);
1189
+ }, [m]);
1190
+ const F = s.useCallback(
1191
+ (_) => {
1192
+ _ && f.current === !0 && (y(), p == null || p(), f.current = !1);
1706
1193
  },
1707
- [position, focusSelectedItem]
1194
+ [y, p]
1708
1195
  );
1709
- return /* @__PURE__ */ jsx(
1710
- SelectViewportProvider,
1196
+ return /* @__PURE__ */ d(
1197
+ Fo,
1711
1198
  {
1712
- scope: __scopeSelect,
1713
- contentWrapper,
1714
- shouldExpandOnScrollRef,
1715
- onScrollButtonChange: handleScrollButtonChange,
1716
- children: /* @__PURE__ */ jsx(
1199
+ scope: e,
1200
+ contentWrapper: l,
1201
+ shouldExpandOnScrollRef: u,
1202
+ onScrollButtonChange: F,
1203
+ children: /* @__PURE__ */ d(
1717
1204
  "div",
1718
1205
  {
1719
- ref: setContentWrapper,
1206
+ ref: a,
1720
1207
  style: {
1721
1208
  display: "flex",
1722
1209
  flexDirection: "column",
1723
1210
  position: "fixed",
1724
- zIndex: contentZIndex
1211
+ zIndex: E
1725
1212
  },
1726
- children: /* @__PURE__ */ jsx(
1727
- Primitive.div,
1213
+ children: /* @__PURE__ */ d(
1214
+ N.div,
1728
1215
  {
1729
- ...popperProps,
1730
- ref: composedRefs,
1216
+ ...n,
1217
+ ref: v,
1731
1218
  style: {
1732
1219
  // When we get the height of the content, it includes borders. If we were to set
1733
1220
  // the height without having `boxSizing: 'border-box'` it would be too big.
1734
1221
  boxSizing: "border-box",
1735
1222
  // We need to ensure the content doesn't get taller than the wrapper
1736
1223
  maxHeight: "100%",
1737
- ...popperProps.style
1224
+ ...n.style
1738
1225
  }
1739
1226
  }
1740
1227
  )
@@ -1744,66 +1231,55 @@ const SelectItemAlignedPosition = React.forwardRef(
1744
1231
  );
1745
1232
  }
1746
1233
  );
1747
- SelectItemAlignedPosition.displayName = ITEM_ALIGNED_POSITION_NAME;
1748
- const POPPER_POSITION_NAME = "SelectPopperPosition";
1749
- const SelectPopperPosition = React.forwardRef(
1750
- (props, forwardedRef) => {
1751
- const { __scopeSelect, align = "start", collisionPadding = CONTENT_MARGIN, ...popperProps } = props;
1752
- const popperScope = usePopperScope(__scopeSelect);
1753
- return /* @__PURE__ */ jsx(
1754
- PopperPrimitive.Content,
1234
+ Bt.displayName = Do;
1235
+ const ko = "SelectPopperPosition", Re = s.forwardRef(
1236
+ (o, i) => {
1237
+ const { __scopeSelect: e, align: t = "start", collisionPadding: n = q, ...r } = o, c = Ve(e);
1238
+ return /* @__PURE__ */ d(
1239
+ ie.Content,
1755
1240
  {
1756
- ...popperScope,
1757
- ...popperProps,
1758
- ref: forwardedRef,
1759
- align,
1760
- collisionPadding,
1241
+ ...c,
1242
+ ...r,
1243
+ ref: i,
1244
+ align: t,
1245
+ collisionPadding: n,
1761
1246
  style: {
1762
1247
  // Ensure border-box for floating-ui calculations
1763
1248
  boxSizing: "border-box",
1764
- ...popperProps.style,
1765
- // re-namespace exposed content custom properties
1766
- ...{
1767
- "--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
1768
- "--radix-select-content-available-width": "var(--radix-popper-available-width)",
1769
- "--radix-select-content-available-height": "var(--radix-popper-available-height)",
1770
- "--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
1771
- "--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
1772
- }
1249
+ ...r.style,
1250
+ "--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
1251
+ "--radix-select-content-available-width": "var(--radix-popper-available-width)",
1252
+ "--radix-select-content-available-height": "var(--radix-popper-available-height)",
1253
+ "--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
1254
+ "--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
1773
1255
  }
1774
1256
  }
1775
1257
  );
1776
1258
  }
1777
1259
  );
1778
- SelectPopperPosition.displayName = POPPER_POSITION_NAME;
1779
- const [SelectViewportProvider, useSelectViewportContext] = createSelectContext(
1780
- CONTENT_NAME,
1260
+ Re.displayName = ko;
1261
+ const [Fo, Ge] = pe(
1262
+ le,
1781
1263
  {}
1782
- );
1783
- const VIEWPORT_NAME = "SelectViewport";
1784
- const SelectViewport = React.forwardRef(
1785
- (props, forwardedRef) => {
1786
- const { __scopeSelect, ...viewportProps } = props;
1787
- const contentContext = useSelectContentContext(VIEWPORT_NAME, __scopeSelect);
1788
- const viewportContext = useSelectViewportContext(VIEWPORT_NAME, __scopeSelect);
1789
- const composedRefs = useComposedRefs(forwardedRef, contentContext.onViewportChange);
1790
- const prevScrollTopRef = React.useRef(0);
1791
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1792
- /* @__PURE__ */ jsx(
1264
+ ), Ae = "SelectViewport", je = s.forwardRef(
1265
+ (o, i) => {
1266
+ const { __scopeSelect: e, ...t } = o, n = oe(Ae, e), r = Ge(Ae, e), c = A(i, n.onViewportChange), l = s.useRef(0);
1267
+ return /* @__PURE__ */ ye(Se, { children: [
1268
+ /* @__PURE__ */ d(
1793
1269
  "style",
1794
1270
  {
1795
1271
  dangerouslySetInnerHTML: {
1796
- __html: `[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`
1272
+ __html: "[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"
1797
1273
  }
1798
1274
  }
1799
1275
  ),
1800
- /* @__PURE__ */ jsx(Collection.Slot, { scope: __scopeSelect, children: /* @__PURE__ */ jsx(
1801
- Primitive.div,
1276
+ /* @__PURE__ */ d(Te.Slot, { scope: e, children: /* @__PURE__ */ d(
1277
+ N.div,
1802
1278
  {
1803
1279
  "data-radix-select-viewport": "",
1804
1280
  role: "presentation",
1805
- ...viewportProps,
1806
- ref: composedRefs,
1281
+ ...t,
1282
+ ref: c,
1807
1283
  style: {
1808
1284
  // we use position: 'relative' here on the `viewport` so that when we call
1809
1285
  // `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
@@ -1811,139 +1287,104 @@ const SelectViewport = React.forwardRef(
1811
1287
  position: "relative",
1812
1288
  flex: 1,
1813
1289
  overflow: "auto",
1814
- ...viewportProps.style
1290
+ ...t.style
1815
1291
  },
1816
- onScroll: composeEventHandlers$1(viewportProps.onScroll, (event) => {
1817
- const viewport = event.currentTarget;
1818
- const { contentWrapper, shouldExpandOnScrollRef } = viewportContext;
1819
- if (shouldExpandOnScrollRef?.current && contentWrapper) {
1820
- const scrolledBy = Math.abs(prevScrollTopRef.current - viewport.scrollTop);
1821
- if (scrolledBy > 0) {
1822
- const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
1823
- const cssMinHeight = parseFloat(contentWrapper.style.minHeight);
1824
- const cssHeight = parseFloat(contentWrapper.style.height);
1825
- const prevHeight = Math.max(cssMinHeight, cssHeight);
1826
- if (prevHeight < availableHeight) {
1827
- const nextHeight = prevHeight + scrolledBy;
1828
- const clampedNextHeight = Math.min(availableHeight, nextHeight);
1829
- const heightDiff = nextHeight - clampedNextHeight;
1830
- contentWrapper.style.height = `${clampedNextHeight}px`;
1831
- if (contentWrapper.style.bottom === "0px") {
1832
- viewport.scrollTop = heightDiff > 0 ? heightDiff : 0;
1833
- contentWrapper.style.justifyContent = "flex-end";
1834
- }
1292
+ onScroll: P(t.onScroll, (a) => {
1293
+ const m = a.currentTarget, { contentWrapper: C, shouldExpandOnScrollRef: v } = r;
1294
+ if (v != null && v.current && C) {
1295
+ const g = Math.abs(l.current - m.scrollTop);
1296
+ if (g > 0) {
1297
+ const u = window.innerHeight - q * 2, f = parseFloat(C.style.minHeight), h = parseFloat(C.style.height), b = Math.max(f, h);
1298
+ if (b < u) {
1299
+ const x = b + g, p = Math.min(u, x), y = x - p;
1300
+ C.style.height = `${p}px`, C.style.bottom === "0px" && (m.scrollTop = y > 0 ? y : 0, C.style.justifyContent = "flex-end");
1835
1301
  }
1836
1302
  }
1837
1303
  }
1838
- prevScrollTopRef.current = viewport.scrollTop;
1304
+ l.current = m.scrollTop;
1839
1305
  })
1840
1306
  }
1841
1307
  ) })
1842
1308
  ] });
1843
1309
  }
1844
1310
  );
1845
- SelectViewport.displayName = VIEWPORT_NAME;
1846
- const GROUP_NAME = "SelectGroup";
1847
- const [SelectGroupContextProvider, useSelectGroupContext] = createSelectContext(GROUP_NAME);
1848
- const SelectGroup = React.forwardRef(
1849
- (props, forwardedRef) => {
1850
- const { __scopeSelect, ...groupProps } = props;
1851
- const groupId = useId();
1852
- return /* @__PURE__ */ jsx(SelectGroupContextProvider, { scope: __scopeSelect, id: groupId, children: /* @__PURE__ */ jsx(Primitive.div, { role: "group", "aria-labelledby": groupId, ...groupProps, ref: forwardedRef }) });
1311
+ je.displayName = Ae;
1312
+ const $t = "SelectGroup", [Lo, Bo] = pe($t), Ye = s.forwardRef(
1313
+ (o, i) => {
1314
+ const { __scopeSelect: e, ...t } = o, n = se();
1315
+ return /* @__PURE__ */ d(Lo, { scope: e, id: n, children: /* @__PURE__ */ d(N.div, { role: "group", "aria-labelledby": n, ...t, ref: i }) });
1853
1316
  }
1854
1317
  );
1855
- SelectGroup.displayName = GROUP_NAME;
1856
- const LABEL_NAME = "SelectLabel";
1857
- const SelectLabel = React.forwardRef(
1858
- (props, forwardedRef) => {
1859
- const { __scopeSelect, ...labelProps } = props;
1860
- const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
1861
- return /* @__PURE__ */ jsx(Primitive.div, { id: groupContext.id, ...labelProps, ref: forwardedRef });
1318
+ Ye.displayName = $t;
1319
+ const Ut = "SelectLabel", qe = s.forwardRef(
1320
+ (o, i) => {
1321
+ const { __scopeSelect: e, ...t } = o, n = Bo(Ut, e);
1322
+ return /* @__PURE__ */ d(N.div, { id: n.id, ...t, ref: i });
1862
1323
  }
1863
1324
  );
1864
- SelectLabel.displayName = LABEL_NAME;
1865
- const ITEM_NAME = "SelectItem";
1866
- const [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
1867
- const SelectItem = React.forwardRef(
1868
- (props, forwardedRef) => {
1869
- const { __scopeSelect, value, disabled = false, textValue: textValueProp, ...itemProps } = props;
1870
- const context = useSelectContext(ITEM_NAME, __scopeSelect);
1871
- const contentContext = useSelectContentContext(ITEM_NAME, __scopeSelect);
1872
- const isSelected = typeof value === "string" ? Array.isArray(context.value) ? context.value.includes(value) : context.value === value : value.every((v) => context.value?.includes(v));
1873
- const isIntermediate = Array.isArray(context.value) && Array.isArray(value) && value.some((v) => context.value?.includes(v));
1874
- const [textValue, setTextValue] = React.useState(textValueProp ?? "");
1875
- const [isFocused, setIsFocused] = React.useState(false);
1876
- const composedRefs = useComposedRefs(
1877
- forwardedRef,
1878
- (node) => contentContext.itemRefCallback?.(node, value, disabled)
1879
- );
1880
- const textId = useId();
1881
- const handleSelect = () => {
1882
- if (!disabled) {
1883
- let newValue = context.multi && typeof value === "string" ? [value] : value;
1884
- if (isIntermediate && !isSelected) {
1885
- context.onValueChange(newValue);
1886
- } else if (Array.isArray(context.value)) {
1887
- newValue = toggleArrayValue(value, context.value);
1888
- }
1889
- context.onValueChange(newValue);
1890
- if (!context.multi) {
1891
- context.onOpenChange(false);
1892
- }
1325
+ qe.displayName = Ut;
1326
+ const be = "SelectItem", [$o, Ht] = pe(be), Xe = s.forwardRef(
1327
+ (o, i) => {
1328
+ const { __scopeSelect: e, value: t, disabled: n = !1, textValue: r, ...c } = o, l = X(be, e), a = oe(be, e), m = typeof t == "string" ? Array.isArray(l.value) ? l.value.includes(t) : l.value === t : t.every((p) => {
1329
+ var y;
1330
+ return (y = l.value) == null ? void 0 : y.includes(p);
1331
+ }), C = Array.isArray(l.value) && Array.isArray(t) && t.some((p) => {
1332
+ var y;
1333
+ return (y = l.value) == null ? void 0 : y.includes(p);
1334
+ }), [v, g] = s.useState(r ?? ""), [u, f] = s.useState(!1), h = A(
1335
+ i,
1336
+ (p) => {
1337
+ var y;
1338
+ return (y = a.itemRefCallback) == null ? void 0 : y.call(a, p, t, n);
1339
+ }
1340
+ ), b = se(), x = () => {
1341
+ if (!n) {
1342
+ let p = l.multi && typeof t == "string" ? [t] : t;
1343
+ C && !m ? l.onValueChange(p) : Array.isArray(l.value) && (p = Gt(t, l.value)), l.onValueChange(p), l.multi || l.onOpenChange(!1);
1893
1344
  }
1894
1345
  };
1895
- if (!context.multi && Array.isArray(value)) {
1346
+ if (!l.multi && Array.isArray(t))
1896
1347
  throw new Error("You can only pass an array of values in multi selects");
1897
- }
1898
- return /* @__PURE__ */ jsx(
1899
- SelectItemContextProvider,
1348
+ return /* @__PURE__ */ d(
1349
+ $o,
1900
1350
  {
1901
- scope: __scopeSelect,
1902
- value,
1903
- disabled,
1904
- textId,
1905
- isSelected,
1906
- isIntermediate,
1907
- onItemTextChange: React.useCallback((node) => {
1908
- setTextValue((prevTextValue) => prevTextValue || (node?.textContent ?? "").trim());
1351
+ scope: e,
1352
+ value: t,
1353
+ disabled: n,
1354
+ textId: b,
1355
+ isSelected: m,
1356
+ isIntermediate: C,
1357
+ onItemTextChange: s.useCallback((p) => {
1358
+ g((y) => y || ((p == null ? void 0 : p.textContent) ?? "").trim());
1909
1359
  }, []),
1910
- children: /* @__PURE__ */ jsx(Collection.ItemSlot, { scope: __scopeSelect, value, disabled, textValue, children: /* @__PURE__ */ jsx(
1911
- Primitive.div,
1360
+ children: /* @__PURE__ */ d(Te.ItemSlot, { scope: e, value: t, disabled: n, textValue: v, children: /* @__PURE__ */ d(
1361
+ N.div,
1912
1362
  {
1913
1363
  role: "option",
1914
- "aria-labelledby": textId,
1915
- "data-highlighted": isFocused ? "" : void 0,
1916
- "aria-selected": !context.multi ? isSelected && isFocused : void 0,
1917
- "aria-checked": context.multi ? isSelected : void 0,
1918
- "data-state": isSelected ? "checked" : "unchecked",
1919
- "aria-disabled": disabled || void 0,
1920
- "data-disabled": disabled ? "" : void 0,
1921
- tabIndex: disabled ? void 0 : -1,
1922
- ...itemProps,
1923
- ref: composedRefs,
1924
- onFocus: composeEventHandlers$1(itemProps.onFocus, () => setIsFocused(true)),
1925
- onBlur: composeEventHandlers$1(itemProps.onBlur, () => setIsFocused(false)),
1926
- onPointerUp: composeEventHandlers$1(itemProps.onPointerUp, handleSelect),
1927
- onPointerMove: composeEventHandlers$1(itemProps.onPointerMove, (event) => {
1928
- if (disabled) {
1929
- contentContext.onItemLeave?.();
1930
- } else {
1931
- event.currentTarget.focus({ preventScroll: true });
1932
- }
1364
+ "aria-labelledby": b,
1365
+ "data-highlighted": u ? "" : void 0,
1366
+ "aria-selected": l.multi ? void 0 : m && u,
1367
+ "aria-checked": l.multi ? m : void 0,
1368
+ "data-state": m ? "checked" : "unchecked",
1369
+ "aria-disabled": n || void 0,
1370
+ "data-disabled": n ? "" : void 0,
1371
+ tabIndex: n ? void 0 : -1,
1372
+ ...c,
1373
+ ref: h,
1374
+ onFocus: P(c.onFocus, () => f(!0)),
1375
+ onBlur: P(c.onBlur, () => f(!1)),
1376
+ onPointerUp: P(c.onPointerUp, x),
1377
+ onPointerMove: P(c.onPointerMove, (p) => {
1378
+ var y;
1379
+ n ? (y = a.onItemLeave) == null || y.call(a) : p.currentTarget.focus({ preventScroll: !0 });
1933
1380
  }),
1934
- onPointerLeave: composeEventHandlers$1(itemProps.onPointerLeave, (event) => {
1935
- if (event.currentTarget === document.activeElement) {
1936
- contentContext.onItemLeave?.();
1937
- }
1381
+ onPointerLeave: P(c.onPointerLeave, (p) => {
1382
+ var y;
1383
+ p.currentTarget === document.activeElement && ((y = a.onItemLeave) == null || y.call(a));
1938
1384
  }),
1939
- onKeyDown: composeEventHandlers$1(itemProps.onKeyDown, (event) => {
1940
- const isTypingAhead = contentContext.searchRef?.current !== "";
1941
- if (isTypingAhead && event.key === " ")
1942
- return;
1943
- if (SELECTION_KEYS.includes(event.key))
1944
- handleSelect();
1945
- if (event.key === " ")
1946
- event.preventDefault();
1385
+ onKeyDown: P(c.onKeyDown, (p) => {
1386
+ var E;
1387
+ ((E = a.searchRef) == null ? void 0 : E.current) !== "" && p.key === " " || (Vo.includes(p.key) && x(), p.key === " " && p.preventDefault());
1947
1388
  })
1948
1389
  }
1949
1390
  ) })
@@ -1951,345 +1392,239 @@ const SelectItem = React.forwardRef(
1951
1392
  );
1952
1393
  }
1953
1394
  );
1954
- SelectItem.displayName = ITEM_NAME;
1955
- const ITEM_TEXT_NAME = "SelectItemText";
1956
- const SelectItemText = React.forwardRef(
1957
- (props, forwardedRef) => {
1958
- const { __scopeSelect, className: _className, style: _style, ...itemTextProps } = props;
1959
- const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
1960
- const contentContext = useSelectContentContext(ITEM_TEXT_NAME, __scopeSelect);
1961
- const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
1962
- const nativeOptionsContext = useSelectNativeOptionsContext(ITEM_TEXT_NAME, __scopeSelect);
1963
- const [itemTextNode, setItemTextNode] = React.useState(null);
1964
- const composedRefs = useComposedRefs(
1965
- forwardedRef,
1966
- (node) => setItemTextNode(node),
1967
- itemContext.onItemTextChange,
1968
- (node) => contentContext.itemTextRefCallback?.(node, itemContext.value, itemContext.disabled)
1969
- );
1970
- const textContent = itemTextNode?.textContent;
1971
- const nativeOption = React.useMemo(
1972
- () => /* @__PURE__ */ jsx(
1395
+ Xe.displayName = be;
1396
+ const ge = "SelectItemText", Ze = s.forwardRef(
1397
+ (o, i) => {
1398
+ const { __scopeSelect: e, className: t, style: n, ...r } = o, c = X(ge, e), l = oe(ge, e), a = Ht(ge, e), m = Ao(ge, e), [C, v] = s.useState(null), g = A(
1399
+ i,
1400
+ (x) => v(x),
1401
+ a.onItemTextChange,
1402
+ (x) => {
1403
+ var p;
1404
+ return (p = l.itemTextRefCallback) == null ? void 0 : p.call(l, x, a.value, a.disabled);
1405
+ }
1406
+ ), u = C == null ? void 0 : C.textContent, f = s.useMemo(
1407
+ () => /* @__PURE__ */ d(
1973
1408
  "option",
1974
1409
  {
1975
- value: itemContext.value,
1976
- disabled: itemContext.disabled,
1977
- children: textContent
1410
+ value: a.value,
1411
+ disabled: a.disabled,
1412
+ children: u
1978
1413
  },
1979
- Array.isArray(itemContext.value) ? itemContext.value.join(";") : itemContext.value
1414
+ Array.isArray(a.value) ? a.value.join(";") : a.value
1980
1415
  ),
1981
- [itemContext.disabled, itemContext.value, textContent]
1982
- );
1983
- const { onNativeOptionAdd, onNativeOptionRemove } = nativeOptionsContext;
1984
- useLayoutEffect(() => {
1985
- onNativeOptionAdd(nativeOption);
1986
- return () => onNativeOptionRemove(nativeOption);
1987
- }, [onNativeOptionAdd, onNativeOptionRemove, nativeOption]);
1988
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1989
- /* @__PURE__ */ jsx(Primitive.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs }),
1990
- itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null
1416
+ [a.disabled, a.value, u]
1417
+ ), { onNativeOptionAdd: h, onNativeOptionRemove: b } = m;
1418
+ return $(() => (h(f), () => b(f)), [h, b, f]), /* @__PURE__ */ ye(Se, { children: [
1419
+ /* @__PURE__ */ d(N.span, { id: a.textId, ...r, ref: g }),
1420
+ a.isSelected && c.valueNode && !c.valueNodeHasChildren ? we.createPortal(r.children, c.valueNode) : null
1991
1421
  ] });
1992
1422
  }
1993
1423
  );
1994
- SelectItemText.displayName = ITEM_TEXT_NAME;
1995
- const ITEM_INDICATOR_NAME = "SelectItemIndicator";
1996
- const SelectItemIndicator = React.forwardRef(
1997
- (props, forwardedRef) => {
1998
- const { __scopeSelect, children, ...itemIndicatorProps } = props;
1999
- const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
2000
- if (typeof children === "function") {
2001
- return /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...itemIndicatorProps, ref: forwardedRef, children: children({
2002
- isSelected: itemContext.isSelected,
2003
- isIntermediate: itemContext.isIntermediate
2004
- }) });
2005
- }
2006
- return itemContext.isSelected ? /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...itemIndicatorProps, ref: forwardedRef, children }) : null;
1424
+ Ze.displayName = ge;
1425
+ const Wt = "SelectItemIndicator", Je = s.forwardRef(
1426
+ (o, i) => {
1427
+ const { __scopeSelect: e, children: t, ...n } = o, r = Ht(Wt, e);
1428
+ return typeof t == "function" ? /* @__PURE__ */ d(N.span, { "aria-hidden": !0, ...n, ref: i, children: t({
1429
+ isSelected: r.isSelected,
1430
+ isIntermediate: r.isIntermediate
1431
+ }) }) : r.isSelected ? /* @__PURE__ */ d(N.span, { "aria-hidden": !0, ...n, ref: i, children: t }) : null;
2007
1432
  }
2008
1433
  );
2009
- SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
2010
- const SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
2011
- const SelectScrollUpButton = React.forwardRef(
2012
- (props, forwardedRef) => {
2013
- const contentContext = useSelectContentContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
2014
- const viewportContext = useSelectViewportContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
2015
- const [canScrollUp, setCanScrollUp] = React.useState(false);
2016
- const composedRefs = useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
2017
- useLayoutEffect(() => {
2018
- if (contentContext.viewport && contentContext.isPositioned) {
2019
- const viewport = contentContext.viewport;
2020
- const handleScroll = () => {
2021
- const canScrollUp2 = viewport.scrollTop > 0;
2022
- setCanScrollUp(canScrollUp2);
1434
+ Je.displayName = Wt;
1435
+ const _e = "SelectScrollUpButton", Qe = s.forwardRef(
1436
+ (o, i) => {
1437
+ const e = oe(_e, o.__scopeSelect), t = Ge(_e, o.__scopeSelect), [n, r] = s.useState(!1), c = A(i, t.onScrollButtonChange);
1438
+ return $(() => {
1439
+ if (e.viewport && e.isPositioned) {
1440
+ const l = e.viewport, a = () => {
1441
+ const m = l.scrollTop > 0;
1442
+ r(m);
2023
1443
  };
2024
- handleScroll();
2025
- viewport.addEventListener("scroll", handleScroll);
2026
- return () => viewport.removeEventListener("scroll", handleScroll);
1444
+ return a(), l.addEventListener("scroll", a), () => l.removeEventListener("scroll", a);
2027
1445
  }
2028
- }, [contentContext.viewport, contentContext.isPositioned]);
2029
- return canScrollUp ? /* @__PURE__ */ jsx(
2030
- SelectScrollButtonImpl,
1446
+ }, [e.viewport, e.isPositioned]), n ? /* @__PURE__ */ d(
1447
+ tt,
2031
1448
  {
2032
- ...props,
2033
- ref: composedRefs,
1449
+ ...o,
1450
+ ref: c,
2034
1451
  onAutoScroll: () => {
2035
- const { viewport, selectedItem } = contentContext;
2036
- if (viewport && selectedItem) {
2037
- viewport.scrollTop -= selectedItem.offsetHeight;
2038
- }
1452
+ const { viewport: l, selectedItem: a } = e;
1453
+ l && a && (l.scrollTop -= a.offsetHeight);
2039
1454
  }
2040
1455
  }
2041
1456
  ) : null;
2042
1457
  }
2043
1458
  );
2044
- SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
2045
- const SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
2046
- const SelectScrollDownButton = React.forwardRef(
2047
- (props, forwardedRef) => {
2048
- const contentContext = useSelectContentContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
2049
- const viewportContext = useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
2050
- const [canScrollDown, setCanScrollDown] = React.useState(false);
2051
- const composedRefs = useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
2052
- useLayoutEffect(() => {
2053
- if (contentContext.viewport && contentContext.isPositioned) {
2054
- const viewport = contentContext.viewport;
2055
- const handleScroll = () => {
2056
- const maxScroll = viewport.scrollHeight - viewport.clientHeight;
2057
- const canScrollDown2 = Math.ceil(viewport.scrollTop) < maxScroll;
2058
- setCanScrollDown(canScrollDown2);
1459
+ Qe.displayName = _e;
1460
+ const Me = "SelectScrollDownButton", et = s.forwardRef(
1461
+ (o, i) => {
1462
+ const e = oe(Me, o.__scopeSelect), t = Ge(Me, o.__scopeSelect), [n, r] = s.useState(!1), c = A(i, t.onScrollButtonChange);
1463
+ return $(() => {
1464
+ if (e.viewport && e.isPositioned) {
1465
+ const l = e.viewport, a = () => {
1466
+ const m = l.scrollHeight - l.clientHeight, C = Math.ceil(l.scrollTop) < m;
1467
+ r(C);
2059
1468
  };
2060
- handleScroll();
2061
- viewport.addEventListener("scroll", handleScroll);
2062
- return () => viewport.removeEventListener("scroll", handleScroll);
1469
+ return a(), l.addEventListener("scroll", a), () => l.removeEventListener("scroll", a);
2063
1470
  }
2064
- }, [contentContext.viewport, contentContext.isPositioned]);
2065
- return canScrollDown ? /* @__PURE__ */ jsx(
2066
- SelectScrollButtonImpl,
1471
+ }, [e.viewport, e.isPositioned]), n ? /* @__PURE__ */ d(
1472
+ tt,
2067
1473
  {
2068
- ...props,
2069
- ref: composedRefs,
1474
+ ...o,
1475
+ ref: c,
2070
1476
  onAutoScroll: () => {
2071
- const { viewport, selectedItem } = contentContext;
2072
- if (viewport && selectedItem) {
2073
- viewport.scrollTop += selectedItem.offsetHeight;
2074
- }
1477
+ const { viewport: l, selectedItem: a } = e;
1478
+ l && a && (l.scrollTop += a.offsetHeight);
2075
1479
  }
2076
1480
  }
2077
1481
  ) : null;
2078
1482
  }
2079
1483
  );
2080
- SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
2081
- const SelectScrollButtonImpl = React.forwardRef(
2082
- (props, forwardedRef) => {
2083
- const { __scopeSelect, onAutoScroll, ...scrollIndicatorProps } = props;
2084
- const contentContext = useSelectContentContext("SelectScrollButton", __scopeSelect);
2085
- const autoScrollTimerRef = React.useRef(null);
2086
- const getItems = useCollection(__scopeSelect);
2087
- const clearAutoScrollTimer = React.useCallback(() => {
2088
- if (autoScrollTimerRef.current !== null) {
2089
- window.clearInterval(autoScrollTimerRef.current);
2090
- autoScrollTimerRef.current = null;
2091
- }
1484
+ et.displayName = Me;
1485
+ const tt = s.forwardRef(
1486
+ (o, i) => {
1487
+ const { __scopeSelect: e, onAutoScroll: t, ...n } = o, r = oe("SelectScrollButton", e), c = s.useRef(null), l = ve(e), a = s.useCallback(() => {
1488
+ c.current !== null && (window.clearInterval(c.current), c.current = null);
2092
1489
  }, []);
2093
- React.useEffect(() => {
2094
- return () => clearAutoScrollTimer();
2095
- }, [clearAutoScrollTimer]);
2096
- useLayoutEffect(() => {
2097
- const activeItem = getItems().find((item) => item.ref.current === document.activeElement);
2098
- activeItem?.ref.current?.scrollIntoView({ block: "nearest" });
2099
- }, [getItems]);
2100
- return /* @__PURE__ */ jsx(
2101
- Primitive.div,
1490
+ return s.useEffect(() => () => a(), [a]), $(() => {
1491
+ var C;
1492
+ const m = l().find((v) => v.ref.current === document.activeElement);
1493
+ (C = m == null ? void 0 : m.ref.current) == null || C.scrollIntoView({ block: "nearest" });
1494
+ }, [l]), /* @__PURE__ */ d(
1495
+ N.div,
2102
1496
  {
2103
- "aria-hidden": true,
2104
- ...scrollIndicatorProps,
2105
- ref: forwardedRef,
2106
- style: { flexShrink: 0, ...scrollIndicatorProps.style },
2107
- onPointerMove: composeEventHandlers$1(scrollIndicatorProps.onPointerMove, () => {
2108
- contentContext.onItemLeave?.();
2109
- if (autoScrollTimerRef.current === null) {
2110
- autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
2111
- }
1497
+ "aria-hidden": !0,
1498
+ ...n,
1499
+ ref: i,
1500
+ style: { flexShrink: 0, ...n.style },
1501
+ onPointerMove: P(n.onPointerMove, () => {
1502
+ var m;
1503
+ (m = r.onItemLeave) == null || m.call(r), c.current === null && (c.current = window.setInterval(t, 50));
2112
1504
  }),
2113
- onPointerLeave: composeEventHandlers$1(scrollIndicatorProps.onPointerLeave, () => {
2114
- clearAutoScrollTimer();
1505
+ onPointerLeave: P(n.onPointerLeave, () => {
1506
+ a();
2115
1507
  })
2116
1508
  }
2117
1509
  );
2118
1510
  }
2119
1511
  );
2120
- SelectScrollButtonImpl.displayName = "SelectScrollButtonImpl";
2121
- const SEPARATOR_NAME = "SelectSeparator";
2122
- const SelectSeparator = React.forwardRef(
2123
- (props, forwardedRef) => {
2124
- const { __scopeSelect, ...separatorProps } = props;
2125
- return /* @__PURE__ */ jsx(Primitive.div, { "aria-hidden": true, ...separatorProps, ref: forwardedRef });
1512
+ tt.displayName = "SelectScrollButtonImpl";
1513
+ const Uo = "SelectSeparator", ot = s.forwardRef(
1514
+ (o, i) => {
1515
+ const { __scopeSelect: e, ...t } = o;
1516
+ return /* @__PURE__ */ d(N.div, { "aria-hidden": !0, ...t, ref: i });
2126
1517
  }
2127
1518
  );
2128
- SelectSeparator.displayName = SEPARATOR_NAME;
2129
- const ARROW_NAME = "SelectArrow";
2130
- const SelectArrow = React.forwardRef(
2131
- (props, forwardedRef) => {
2132
- const { __scopeSelect, ...arrowProps } = props;
2133
- const popperScope = usePopperScope(__scopeSelect);
2134
- const context = useSelectContext(ARROW_NAME, __scopeSelect);
2135
- const contentContext = useSelectContentContext(ARROW_NAME, __scopeSelect);
2136
- return context.open && contentContext.position === "popper" ? /* @__PURE__ */ jsx(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef }) : null;
1519
+ ot.displayName = Uo;
1520
+ const Oe = "SelectArrow", nt = s.forwardRef(
1521
+ (o, i) => {
1522
+ const { __scopeSelect: e, ...t } = o, n = Ve(e), r = X(Oe, e), c = oe(Oe, e);
1523
+ return r.open && c.position === "popper" ? /* @__PURE__ */ d(ie.Arrow, { ...n, ...t, ref: i }) : null;
2137
1524
  }
2138
1525
  );
2139
- SelectArrow.displayName = ARROW_NAME;
2140
- const BUBBLE_SELECT_NAME = "BubbleSelect";
2141
- const BubbleSelect = React.forwardRef(
2142
- (props, forwardedRef) => {
2143
- const { value, ...selectProps } = props;
2144
- const ref = React.useRef(null);
2145
- const composedRefs = useComposedRefs(forwardedRef, ref);
2146
- const prevValue = usePrevious(value);
2147
- const context = useSelectContext(BUBBLE_SELECT_NAME, void 0);
2148
- React.useEffect(() => {
2149
- const select = ref.current;
2150
- const selectProto = window.HTMLSelectElement.prototype;
2151
- const descriptor = Object.getOwnPropertyDescriptor(selectProto, "value");
2152
- const setValue = descriptor.set;
2153
- if (prevValue !== value && setValue) {
2154
- const event = new Event("change", { bubbles: true });
2155
- setValue.call(select, value);
2156
- select.dispatchEvent(event);
1526
+ nt.displayName = Oe;
1527
+ const Ho = "BubbleSelect", Wo = s.forwardRef(
1528
+ (o, i) => {
1529
+ const { value: e, ...t } = o, n = s.useRef(null), r = A(i, n), c = Xt(e), l = X(Ho, void 0);
1530
+ s.useEffect(() => {
1531
+ const m = n.current, C = window.HTMLSelectElement.prototype, g = Object.getOwnPropertyDescriptor(C, "value").set;
1532
+ if (c !== e && g) {
1533
+ const u = new Event("change", { bubbles: !0 });
1534
+ g.call(m, e), m.dispatchEvent(u);
2157
1535
  }
2158
- }, [prevValue, value]);
2159
- let defaultValue = value;
2160
- if (context.multi && !Array.isArray(value)) {
2161
- defaultValue = [];
2162
- }
2163
- return /* @__PURE__ */ jsx(VisuallyHidden, { asChild: true, children: /* @__PURE__ */ jsx(
1536
+ }, [c, e]);
1537
+ let a = e;
1538
+ return l.multi && !Array.isArray(e) && (a = []), /* @__PURE__ */ d(Zt, { asChild: !0, children: /* @__PURE__ */ d(
2164
1539
  "select",
2165
1540
  {
2166
- ...selectProps,
2167
- multiple: context.multi ? true : void 0,
2168
- ref: composedRefs,
2169
- defaultValue
1541
+ ...t,
1542
+ multiple: l.multi ? !0 : void 0,
1543
+ ref: r,
1544
+ defaultValue: a
2170
1545
  }
2171
1546
  ) });
2172
1547
  }
2173
1548
  );
2174
- BubbleSelect.displayName = "BubbleSelect";
2175
- function useTypeaheadSearch(onSearchChange) {
2176
- const handleSearchChange = useCallbackRef(onSearchChange);
2177
- const searchRef = React.useRef("");
2178
- const timerRef = React.useRef(0);
2179
- const handleTypeaheadSearch = React.useCallback(
2180
- (key) => {
2181
- const search = searchRef.current + key;
2182
- handleSearchChange(search);
2183
- (function updateSearch(value) {
2184
- searchRef.current = value;
2185
- window.clearTimeout(timerRef.current);
2186
- if (value !== "")
2187
- timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
2188
- })(search);
1549
+ Wo.displayName = "BubbleSelect";
1550
+ function zt(o) {
1551
+ const i = Io(o), e = s.useRef(""), t = s.useRef(0), n = s.useCallback(
1552
+ (c) => {
1553
+ const l = e.current + c;
1554
+ i(l), function a(m) {
1555
+ e.current = m, window.clearTimeout(t.current), m !== "" && (t.current = window.setTimeout(() => a(""), 1e3));
1556
+ }(l);
2189
1557
  },
2190
- [handleSearchChange]
2191
- );
2192
- const resetTypeahead = React.useCallback(() => {
2193
- searchRef.current = "";
2194
- window.clearTimeout(timerRef.current);
1558
+ [i]
1559
+ ), r = s.useCallback(() => {
1560
+ e.current = "", window.clearTimeout(t.current);
2195
1561
  }, []);
2196
- React.useEffect(() => {
2197
- return () => window.clearTimeout(timerRef.current);
2198
- }, []);
2199
- return [searchRef, handleTypeaheadSearch, resetTypeahead];
1562
+ return s.useEffect(() => () => window.clearTimeout(t.current), []), [e, n, r];
2200
1563
  }
2201
- function findNextItem(items, search, currentItem) {
2202
- const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
2203
- const normalizedSearch = isRepeated ? search[0] : search;
2204
- const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
2205
- let wrappedItems = wrapArray(items, Math.max(currentItemIndex, 0));
2206
- const excludeCurrentItem = normalizedSearch.length === 1;
2207
- if (excludeCurrentItem)
2208
- wrappedItems = wrappedItems.filter((v) => v !== currentItem);
2209
- const nextItem = wrappedItems.find((item) => item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase()));
2210
- return nextItem !== currentItem ? nextItem : void 0;
1564
+ function Kt(o, i, e) {
1565
+ const n = i.length > 1 && Array.from(i).every((m) => m === i[0]) ? i[0] : i, r = e ? o.indexOf(e) : -1;
1566
+ let c = zo(o, Math.max(r, 0));
1567
+ n.length === 1 && (c = c.filter((m) => m !== e));
1568
+ const a = c.find((m) => m.textValue.toLowerCase().startsWith(n.toLowerCase()));
1569
+ return a !== e ? a : void 0;
2211
1570
  }
2212
- function wrapArray(array, startIndex) {
2213
- return array.map((_, index) => array[(startIndex + index) % array.length]);
1571
+ function zo(o, i) {
1572
+ return o.map((e, t) => o[(i + t) % o.length]);
2214
1573
  }
2215
- const toggleArrayValue = (value, array = []) => {
2216
- if (Array.isArray(value)) {
2217
- return value.reduce((acc, val) => toggleArrayValue(val, acc), array);
2218
- }
2219
- const index = array.indexOf(value);
2220
- if (index === -1) {
2221
- return [...array, value];
2222
- }
2223
- return [...array.slice(0, index), ...array.slice(index + 1)];
2224
- };
2225
- const Root = Select;
2226
- const Trigger = SelectTrigger;
2227
- const Value = SelectValue;
2228
- const Icon = SelectIcon;
2229
- const Portal = SelectPortal;
2230
- const Content = SelectContent;
2231
- const Viewport = SelectViewport;
2232
- const Group = SelectGroup;
2233
- const Label = SelectLabel;
2234
- const Item = SelectItem;
2235
- const ItemText = SelectItemText;
2236
- const ItemIndicator = SelectItemIndicator;
2237
- const ScrollUpButton = SelectScrollUpButton;
2238
- const ScrollDownButton = SelectScrollDownButton;
2239
- const Separator = SelectSeparator;
2240
- const Arrow = SelectArrow;
2241
- const Select$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1574
+ const Gt = (o, i = []) => {
1575
+ if (Array.isArray(o))
1576
+ return o.reduce((t, n) => Gt(n, t), i);
1577
+ const e = i.indexOf(o);
1578
+ return e === -1 ? [...i, o] : [...i.slice(0, e), ...i.slice(e + 1)];
1579
+ }, Ko = $e, Go = Ue, jo = He, Yo = We, qo = ze, Xo = Ke, Zo = je, Jo = Ye, Qo = qe, en = Xe, tn = Ze, on = Je, nn = Qe, rn = et, ln = ot, sn = nt, An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2242
1580
  __proto__: null,
2243
- Arrow,
2244
- Content,
2245
- Group,
2246
- Icon,
2247
- Item,
2248
- ItemIndicator,
2249
- ItemText,
2250
- Label,
2251
- Portal,
2252
- Root,
2253
- ScrollDownButton,
2254
- ScrollUpButton,
2255
- Select,
2256
- SelectArrow,
2257
- SelectContent,
2258
- SelectGroup,
2259
- SelectIcon,
2260
- SelectItem,
2261
- SelectItemIndicator,
2262
- SelectItemText,
2263
- SelectLabel,
2264
- SelectPortal,
2265
- SelectScrollDownButton,
2266
- SelectScrollUpButton,
2267
- SelectSeparator,
2268
- SelectTrigger,
2269
- SelectValue,
2270
- SelectViewport,
2271
- Separator,
2272
- Trigger,
2273
- Value,
2274
- Viewport,
2275
- createSelectScope
1581
+ Arrow: sn,
1582
+ Content: Xo,
1583
+ Group: Jo,
1584
+ Icon: Yo,
1585
+ Item: en,
1586
+ ItemIndicator: on,
1587
+ ItemText: tn,
1588
+ Label: Qo,
1589
+ Portal: qo,
1590
+ Root: Ko,
1591
+ ScrollDownButton: rn,
1592
+ ScrollUpButton: nn,
1593
+ Select: $e,
1594
+ SelectArrow: nt,
1595
+ SelectContent: Ke,
1596
+ SelectGroup: Ye,
1597
+ SelectIcon: We,
1598
+ SelectItem: Xe,
1599
+ SelectItemIndicator: Je,
1600
+ SelectItemText: Ze,
1601
+ SelectLabel: qe,
1602
+ SelectPortal: ze,
1603
+ SelectScrollDownButton: et,
1604
+ SelectScrollUpButton: Qe,
1605
+ SelectSeparator: ot,
1606
+ SelectTrigger: Ue,
1607
+ SelectValue: He,
1608
+ SelectViewport: je,
1609
+ Separator: ln,
1610
+ Trigger: Go,
1611
+ Value: jo,
1612
+ Viewport: Zo,
1613
+ createSelectScope: Eo
2276
1614
  }, Symbol.toStringTag, { value: "Module" }));
2277
- function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
2278
- return function handleEvent(event) {
2279
- originalEventHandler?.(event);
2280
- if (checkForDefaultPrevented === false || !event.defaultPrevented) {
2281
- return ourEventHandler?.(event);
2282
- }
1615
+ function _n(o, i, { checkForDefaultPrevented: e = !0 } = {}) {
1616
+ return function(n) {
1617
+ if (o == null || o(n), e === !1 || !n.defaultPrevented)
1618
+ return i == null ? void 0 : i(n);
2283
1619
  };
2284
1620
  }
2285
1621
  export {
2286
- Combobox$1 as Combobox,
2287
- Select$1 as Select,
2288
- composeEventHandlers,
2289
- createCollection,
2290
- useCallbackRef,
2291
- useCollator,
2292
- useFilter,
2293
- usePrev
1622
+ Rn as Combobox,
1623
+ An as Select,
1624
+ _n as composeEventHandlers,
1625
+ Jt as createCollection,
1626
+ Io as useCallbackRef,
1627
+ Qt as useCollator,
1628
+ De as useFilter,
1629
+ eo as usePrev
2294
1630
  };
2295
- //# sourceMappingURL=index.mjs.map