@plyaz/ui 0.4.9 → 0.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/dist/ui.cjs.js +120 -1
  2. package/dist/ui.es.js +3371 -38
  3. package/package.json +2 -2
  4. package/dist/ui.cjs10.js +0 -4
  5. package/dist/ui.cjs11.js +0 -1
  6. package/dist/ui.cjs12.js +0 -1
  7. package/dist/ui.cjs13.js +0 -1
  8. package/dist/ui.cjs14.js +0 -19
  9. package/dist/ui.cjs15.js +0 -7
  10. package/dist/ui.cjs16.js +0 -53
  11. package/dist/ui.cjs17.js +0 -1
  12. package/dist/ui.cjs18.js +0 -1
  13. package/dist/ui.cjs19.js +0 -31
  14. package/dist/ui.cjs20.js +0 -1
  15. package/dist/ui.cjs21.js +0 -1
  16. package/dist/ui.cjs22.js +0 -1
  17. package/dist/ui.cjs23.js +0 -6
  18. package/dist/ui.cjs24.js +0 -6
  19. package/dist/ui.cjs25.js +0 -6
  20. package/dist/ui.cjs26.js +0 -1
  21. package/dist/ui.cjs27.js +0 -1
  22. package/dist/ui.cjs28.js +0 -9
  23. package/dist/ui.cjs29.js +0 -14
  24. package/dist/ui.cjs3.js +0 -1
  25. package/dist/ui.cjs30.js +0 -1
  26. package/dist/ui.cjs31.js +0 -1
  27. package/dist/ui.cjs32.js +0 -1
  28. package/dist/ui.cjs33.js +0 -1
  29. package/dist/ui.cjs34.js +0 -1
  30. package/dist/ui.cjs35.js +0 -1
  31. package/dist/ui.cjs36.js +0 -1
  32. package/dist/ui.cjs37.js +0 -1
  33. package/dist/ui.cjs38.js +0 -1
  34. package/dist/ui.cjs39.js +0 -1
  35. package/dist/ui.cjs4.js +0 -5
  36. package/dist/ui.cjs40.js +0 -1
  37. package/dist/ui.cjs41.js +0 -1
  38. package/dist/ui.cjs42.js +0 -1
  39. package/dist/ui.cjs43.js +0 -1
  40. package/dist/ui.cjs44.js +0 -1
  41. package/dist/ui.cjs45.js +0 -1
  42. package/dist/ui.cjs46.js +0 -1
  43. package/dist/ui.cjs47.js +0 -1
  44. package/dist/ui.cjs48.js +0 -1
  45. package/dist/ui.cjs49.js +0 -1
  46. package/dist/ui.cjs5.js +0 -1
  47. package/dist/ui.cjs50.js +0 -1
  48. package/dist/ui.cjs51.js +0 -1
  49. package/dist/ui.cjs52.js +0 -1
  50. package/dist/ui.cjs53.js +0 -1
  51. package/dist/ui.cjs54.js +0 -1
  52. package/dist/ui.cjs55.js +0 -1
  53. package/dist/ui.cjs56.js +0 -1
  54. package/dist/ui.cjs57.js +0 -1
  55. package/dist/ui.cjs58.js +0 -1
  56. package/dist/ui.cjs59.js +0 -6
  57. package/dist/ui.cjs6.js +0 -1
  58. package/dist/ui.cjs60.js +0 -6
  59. package/dist/ui.cjs61.js +0 -6
  60. package/dist/ui.cjs62.js +0 -6
  61. package/dist/ui.cjs63.js +0 -1
  62. package/dist/ui.cjs64.js +0 -1
  63. package/dist/ui.cjs65.js +0 -1
  64. package/dist/ui.cjs66.js +0 -1
  65. package/dist/ui.cjs67.js +0 -1
  66. package/dist/ui.cjs68.js +0 -1
  67. package/dist/ui.cjs69.js +0 -4
  68. package/dist/ui.cjs7.js +0 -1
  69. package/dist/ui.cjs70.js +0 -1
  70. package/dist/ui.cjs71.js +0 -1
  71. package/dist/ui.cjs72.js +0 -1
  72. package/dist/ui.cjs73.js +0 -1
  73. package/dist/ui.cjs74.js +0 -1
  74. package/dist/ui.cjs75.js +0 -38
  75. package/dist/ui.cjs76.js +0 -1
  76. package/dist/ui.cjs77.js +0 -1
  77. package/dist/ui.cjs78.js +0 -1
  78. package/dist/ui.cjs79.js +0 -1
  79. package/dist/ui.cjs8.js +0 -7
  80. package/dist/ui.cjs80.js +0 -1
  81. package/dist/ui.cjs81.js +0 -1
  82. package/dist/ui.cjs82.js +0 -1
  83. package/dist/ui.cjs83.js +0 -1
  84. package/dist/ui.cjs84.js +0 -1
  85. package/dist/ui.cjs9.js +0 -1
  86. package/dist/ui.es10.js +0 -24
  87. package/dist/ui.es11.js +0 -20
  88. package/dist/ui.es12.js +0 -33
  89. package/dist/ui.es13.js +0 -25
  90. package/dist/ui.es14.js +0 -40
  91. package/dist/ui.es15.js +0 -46
  92. package/dist/ui.es16.js +0 -214
  93. package/dist/ui.es17.js +0 -5
  94. package/dist/ui.es18.js +0 -17
  95. package/dist/ui.es19.js +0 -135
  96. package/dist/ui.es20.js +0 -53
  97. package/dist/ui.es21.js +0 -8
  98. package/dist/ui.es22.js +0 -863
  99. package/dist/ui.es23.js +0 -12
  100. package/dist/ui.es24.js +0 -12
  101. package/dist/ui.es25.js +0 -12
  102. package/dist/ui.es26.js +0 -10
  103. package/dist/ui.es27.js +0 -4
  104. package/dist/ui.es28.js +0 -35
  105. package/dist/ui.es29.js +0 -247
  106. package/dist/ui.es3.js +0 -9
  107. package/dist/ui.es30.js +0 -35
  108. package/dist/ui.es31.js +0 -29
  109. package/dist/ui.es32.js +0 -2731
  110. package/dist/ui.es33.js +0 -6
  111. package/dist/ui.es34.js +0 -9
  112. package/dist/ui.es35.js +0 -48
  113. package/dist/ui.es36.js +0 -55
  114. package/dist/ui.es37.js +0 -10
  115. package/dist/ui.es38.js +0 -127
  116. package/dist/ui.es39.js +0 -17
  117. package/dist/ui.es4.js +0 -25
  118. package/dist/ui.es40.js +0 -137
  119. package/dist/ui.es41.js +0 -13
  120. package/dist/ui.es42.js +0 -220
  121. package/dist/ui.es43.js +0 -16
  122. package/dist/ui.es44.js +0 -36
  123. package/dist/ui.es45.js +0 -13
  124. package/dist/ui.es46.js +0 -54
  125. package/dist/ui.es47.js +0 -6
  126. package/dist/ui.es48.js +0 -8
  127. package/dist/ui.es49.js +0 -30
  128. package/dist/ui.es5.js +0 -46
  129. package/dist/ui.es50.js +0 -52
  130. package/dist/ui.es51.js +0 -11
  131. package/dist/ui.es52.js +0 -4
  132. package/dist/ui.es53.js +0 -4
  133. package/dist/ui.es54.js +0 -14
  134. package/dist/ui.es55.js +0 -208
  135. package/dist/ui.es56.js +0 -24
  136. package/dist/ui.es57.js +0 -27
  137. package/dist/ui.es58.js +0 -400
  138. package/dist/ui.es59.js +0 -27
  139. package/dist/ui.es6.js +0 -37
  140. package/dist/ui.es60.js +0 -24
  141. package/dist/ui.es61.js +0 -41
  142. package/dist/ui.es62.js +0 -20
  143. package/dist/ui.es63.js +0 -27
  144. package/dist/ui.es64.js +0 -31
  145. package/dist/ui.es65.js +0 -7
  146. package/dist/ui.es66.js +0 -7
  147. package/dist/ui.es67.js +0 -5
  148. package/dist/ui.es68.js +0 -26
  149. package/dist/ui.es69.js +0 -112
  150. package/dist/ui.es7.js +0 -29
  151. package/dist/ui.es70.js +0 -18
  152. package/dist/ui.es71.js +0 -527
  153. package/dist/ui.es72.js +0 -130
  154. package/dist/ui.es73.js +0 -136
  155. package/dist/ui.es74.js +0 -67
  156. package/dist/ui.es75.js +0 -71
  157. package/dist/ui.es76.js +0 -11
  158. package/dist/ui.es77.js +0 -16
  159. package/dist/ui.es78.js +0 -68
  160. package/dist/ui.es79.js +0 -6
  161. package/dist/ui.es8.js +0 -27
  162. package/dist/ui.es80.js +0 -25
  163. package/dist/ui.es81.js +0 -25
  164. package/dist/ui.es82.js +0 -15
  165. package/dist/ui.es83.js +0 -30
  166. package/dist/ui.es84.js +0 -7
  167. package/dist/ui.es9.js +0 -25
package/dist/ui.es22.js DELETED
@@ -1,863 +0,0 @@
1
- import * as t from "react";
2
- import * as Re from "react-dom";
3
- import { clamp as Te } from "./ui.es33.js";
4
- import { composeEventHandlers as E } from "./ui.es34.js";
5
- import { createCollection as nt } from "./ui.es35.js";
6
- import { useComposedRefs as k } from "./ui.es31.js";
7
- import { createContextScope as rt } from "./ui.es36.js";
8
- import { useDirection as st } from "./ui.es37.js";
9
- import { DismissableLayer as lt } from "./ui.es38.js";
10
- import { useFocusGuards as ct } from "./ui.es39.js";
11
- import { FocusScope as it } from "./ui.es40.js";
12
- import { useId as ye } from "./ui.es41.js";
13
- import { createPopperScope as Ee, Root as at, Anchor as dt, Content as ut, Arrow as pt } from "./ui.es42.js";
14
- import { Portal as ft } from "./ui.es43.js";
15
- import { Primitive as M } from "./ui.es44.js";
16
- import { createSlot as mt } from "./ui.es20.js";
17
- import { useCallbackRef as ht } from "./ui.es45.js";
18
- import { useControllableState as Pe } from "./ui.es46.js";
19
- import { useLayoutEffect as z } from "./ui.es47.js";
20
- import { usePrevious as vt } from "./ui.es48.js";
21
- import { VISUALLY_HIDDEN_STYLES as gt } from "./ui.es49.js";
22
- import { hideOthers as St } from "./ui.es50.js";
23
- import xt from "./ui.es51.js";
24
- import { j as d } from "./ui.es17.js";
25
- var wt = [" ", "Enter", "ArrowUp", "ArrowDown"], Ct = [" ", "Enter"], J = "Select", [ie, ae, yt] = nt(J), [te, io] = rt(J, [
26
- yt,
27
- Ee
28
- ]), de = Ee(), [It, Y] = te(J), [Tt, Pt] = te(J), be = (n) => {
29
- const {
30
- __scopeSelect: c,
31
- children: e,
32
- open: i,
33
- defaultOpen: l,
34
- onOpenChange: p,
35
- value: r,
36
- defaultValue: s,
37
- onValueChange: o,
38
- dir: f,
39
- name: g,
40
- autoComplete: w,
41
- disabled: P,
42
- required: R,
43
- form: T
44
- } = n, a = de(c), [v, C] = t.useState(null), [u, h] = t.useState(null), [A, O] = t.useState(!1), oe = st(f), [b, L] = Pe({
45
- prop: i,
46
- defaultProp: l ?? !1,
47
- onChange: p,
48
- caller: J
49
- }), [W, X] = Pe({
50
- prop: r,
51
- defaultProp: s,
52
- onChange: o,
53
- caller: J
54
- }), B = t.useRef(null), V = v ? T || !!v.closest("form") : !0, [K, H] = t.useState(/* @__PURE__ */ new Set()), F = Array.from(K).map((_) => _.props.value).join(";");
55
- return /* @__PURE__ */ d.jsx(at, { ...a, children: /* @__PURE__ */ d.jsxs(
56
- It,
57
- {
58
- required: R,
59
- scope: c,
60
- trigger: v,
61
- onTriggerChange: C,
62
- valueNode: u,
63
- onValueNodeChange: h,
64
- valueNodeHasChildren: A,
65
- onValueNodeHasChildrenChange: O,
66
- contentId: ye(),
67
- value: W,
68
- onValueChange: X,
69
- open: b,
70
- onOpenChange: L,
71
- dir: oe,
72
- triggerPointerDownPosRef: B,
73
- disabled: P,
74
- children: [
75
- /* @__PURE__ */ d.jsx(ie.Provider, { scope: c, children: /* @__PURE__ */ d.jsx(
76
- Tt,
77
- {
78
- scope: n.__scopeSelect,
79
- onNativeOptionAdd: t.useCallback((_) => {
80
- H((j) => new Set(j).add(_));
81
- }, []),
82
- onNativeOptionRemove: t.useCallback((_) => {
83
- H((j) => {
84
- const U = new Set(j);
85
- return U.delete(_), U;
86
- });
87
- }, []),
88
- children: e
89
- }
90
- ) }),
91
- V ? /* @__PURE__ */ d.jsxs(
92
- Qe,
93
- {
94
- "aria-hidden": !0,
95
- required: R,
96
- tabIndex: -1,
97
- name: g,
98
- autoComplete: w,
99
- value: W,
100
- onChange: (_) => X(_.target.value),
101
- disabled: P,
102
- form: T,
103
- children: [
104
- W === void 0 ? /* @__PURE__ */ d.jsx("option", { value: "" }) : null,
105
- Array.from(K)
106
- ]
107
- },
108
- F
109
- ) : null
110
- ]
111
- }
112
- ) });
113
- };
114
- be.displayName = J;
115
- var _e = "SelectTrigger", Ne = t.forwardRef(
116
- (n, c) => {
117
- const { __scopeSelect: e, disabled: i = !1, ...l } = n, p = de(e), r = Y(_e, e), s = r.disabled || i, o = k(c, r.onTriggerChange), f = ae(e), g = t.useRef("touch"), [w, P, R] = tt((a) => {
118
- const v = f().filter((h) => !h.disabled), C = v.find((h) => h.value === r.value), u = ot(v, a, C);
119
- u !== void 0 && r.onValueChange(u.value);
120
- }), T = (a) => {
121
- s || (r.onOpenChange(!0), R()), a && (r.triggerPointerDownPosRef.current = {
122
- x: Math.round(a.pageX),
123
- y: Math.round(a.pageY)
124
- });
125
- };
126
- return /* @__PURE__ */ d.jsx(dt, { asChild: !0, ...p, children: /* @__PURE__ */ d.jsx(
127
- M.button,
128
- {
129
- type: "button",
130
- role: "combobox",
131
- "aria-controls": r.contentId,
132
- "aria-expanded": r.open,
133
- "aria-required": r.required,
134
- "aria-autocomplete": "none",
135
- dir: r.dir,
136
- "data-state": r.open ? "open" : "closed",
137
- disabled: s,
138
- "data-disabled": s ? "" : void 0,
139
- "data-placeholder": et(r.value) ? "" : void 0,
140
- ...l,
141
- ref: o,
142
- onClick: E(l.onClick, (a) => {
143
- a.currentTarget.focus(), g.current !== "mouse" && T(a);
144
- }),
145
- onPointerDown: E(l.onPointerDown, (a) => {
146
- g.current = a.pointerType;
147
- const v = a.target;
148
- v.hasPointerCapture(a.pointerId) && v.releasePointerCapture(a.pointerId), a.button === 0 && a.ctrlKey === !1 && a.pointerType === "mouse" && (T(a), a.preventDefault());
149
- }),
150
- onKeyDown: E(l.onKeyDown, (a) => {
151
- const v = w.current !== "";
152
- !(a.ctrlKey || a.altKey || a.metaKey) && a.key.length === 1 && P(a.key), !(v && a.key === " ") && wt.includes(a.key) && (T(), a.preventDefault());
153
- })
154
- }
155
- ) });
156
- }
157
- );
158
- Ne.displayName = _e;
159
- var Me = "SelectValue", Ae = t.forwardRef(
160
- (n, c) => {
161
- const { __scopeSelect: e, className: i, style: l, children: p, placeholder: r = "", ...s } = n, o = Y(Me, e), { onValueNodeHasChildrenChange: f } = o, g = p !== void 0, w = k(c, o.onValueNodeChange);
162
- return z(() => {
163
- f(g);
164
- }, [f, g]), /* @__PURE__ */ d.jsx(
165
- M.span,
166
- {
167
- ...s,
168
- ref: w,
169
- style: { pointerEvents: "none" },
170
- children: et(o.value) ? /* @__PURE__ */ d.jsx(d.Fragment, { children: r }) : p
171
- }
172
- );
173
- }
174
- );
175
- Ae.displayName = Me;
176
- var Rt = "SelectIcon", Oe = t.forwardRef(
177
- (n, c) => {
178
- const { __scopeSelect: e, children: i, ...l } = n;
179
- return /* @__PURE__ */ d.jsx(M.span, { "aria-hidden": !0, ...l, ref: c, children: i || "▼" });
180
- }
181
- );
182
- Oe.displayName = Rt;
183
- var Et = "SelectPortal", De = (n) => /* @__PURE__ */ d.jsx(ft, { asChild: !0, ...n });
184
- De.displayName = Et;
185
- var Q = "SelectContent", Le = t.forwardRef(
186
- (n, c) => {
187
- const e = Y(Q, n.__scopeSelect), [i, l] = t.useState();
188
- if (z(() => {
189
- l(new DocumentFragment());
190
- }, []), !e.open) {
191
- const p = i;
192
- return p ? Re.createPortal(
193
- /* @__PURE__ */ d.jsx(je, { scope: n.__scopeSelect, children: /* @__PURE__ */ d.jsx(ie.Slot, { scope: n.__scopeSelect, children: /* @__PURE__ */ d.jsx("div", { children: n.children }) }) }),
194
- p
195
- ) : null;
196
- }
197
- return /* @__PURE__ */ d.jsx(ke, { ...n, ref: c });
198
- }
199
- );
200
- Le.displayName = Q;
201
- var D = 10, [je, q] = te(Q), bt = "SelectContentImpl", _t = mt("SelectContent.RemoveScroll"), ke = t.forwardRef(
202
- (n, c) => {
203
- const {
204
- __scopeSelect: e,
205
- position: i = "item-aligned",
206
- onCloseAutoFocus: l,
207
- onEscapeKeyDown: p,
208
- onPointerDownOutside: r,
209
- //
210
- // PopperContent props
211
- side: s,
212
- sideOffset: o,
213
- align: f,
214
- alignOffset: g,
215
- arrowPadding: w,
216
- collisionBoundary: P,
217
- collisionPadding: R,
218
- sticky: T,
219
- hideWhenDetached: a,
220
- avoidCollisions: v,
221
- //
222
- ...C
223
- } = n, u = Y(Q, e), [h, A] = t.useState(null), [O, oe] = t.useState(null), b = k(c, (m) => A(m)), [L, W] = t.useState(null), [X, B] = t.useState(
224
- null
225
- ), V = ae(e), [K, H] = t.useState(!1), F = t.useRef(!1);
226
- t.useEffect(() => {
227
- if (h) return St(h);
228
- }, [h]), ct();
229
- const _ = t.useCallback(
230
- (m) => {
231
- const [I, ...N] = V().map((x) => x.ref.current), [y] = N.slice(-1), S = document.activeElement;
232
- for (const x of m)
233
- if (x === S || (x == null || x.scrollIntoView({ block: "nearest" }), x === I && O && (O.scrollTop = 0), x === y && O && (O.scrollTop = O.scrollHeight), x == null || x.focus(), document.activeElement !== S)) return;
234
- },
235
- [V, O]
236
- ), j = t.useCallback(
237
- () => _([L, h]),
238
- [_, L, h]
239
- );
240
- t.useEffect(() => {
241
- K && j();
242
- }, [K, j]);
243
- const { onOpenChange: U, triggerPointerDownPosRef: G } = u;
244
- t.useEffect(() => {
245
- if (h) {
246
- let m = { x: 0, y: 0 };
247
- const I = (y) => {
248
- var S, x;
249
- m = {
250
- x: Math.abs(Math.round(y.pageX) - (((S = G.current) == null ? void 0 : S.x) ?? 0)),
251
- y: Math.abs(Math.round(y.pageY) - (((x = G.current) == null ? void 0 : x.y) ?? 0))
252
- };
253
- }, N = (y) => {
254
- m.x <= 10 && m.y <= 10 ? y.preventDefault() : h.contains(y.target) || U(!1), document.removeEventListener("pointermove", I), G.current = null;
255
- };
256
- return G.current !== null && (document.addEventListener("pointermove", I), document.addEventListener("pointerup", N, { capture: !0, once: !0 })), () => {
257
- document.removeEventListener("pointermove", I), document.removeEventListener("pointerup", N, { capture: !0 });
258
- };
259
- }
260
- }, [h, U, G]), t.useEffect(() => {
261
- const m = () => U(!1);
262
- return window.addEventListener("blur", m), window.addEventListener("resize", m), () => {
263
- window.removeEventListener("blur", m), window.removeEventListener("resize", m);
264
- };
265
- }, [U]);
266
- const [ue, se] = tt((m) => {
267
- const I = V().filter((S) => !S.disabled), N = I.find((S) => S.ref.current === document.activeElement), y = ot(I, m, N);
268
- y && setTimeout(() => y.ref.current.focus());
269
- }), pe = t.useCallback(
270
- (m, I, N) => {
271
- const y = !F.current && !N;
272
- (u.value !== void 0 && u.value === I || y) && (W(m), y && (F.current = !0));
273
- },
274
- [u.value]
275
- ), fe = t.useCallback(() => h == null ? void 0 : h.focus(), [h]), ee = t.useCallback(
276
- (m, I, N) => {
277
- const y = !F.current && !N;
278
- (u.value !== void 0 && u.value === I || y) && B(m);
279
- },
280
- [u.value]
281
- ), le = i === "popper" ? ge : Be, ne = le === ge ? {
282
- side: s,
283
- sideOffset: o,
284
- align: f,
285
- alignOffset: g,
286
- arrowPadding: w,
287
- collisionBoundary: P,
288
- collisionPadding: R,
289
- sticky: T,
290
- hideWhenDetached: a,
291
- avoidCollisions: v
292
- } : {};
293
- return /* @__PURE__ */ d.jsx(
294
- je,
295
- {
296
- scope: e,
297
- content: h,
298
- viewport: O,
299
- onViewportChange: oe,
300
- itemRefCallback: pe,
301
- selectedItem: L,
302
- onItemLeave: fe,
303
- itemTextRefCallback: ee,
304
- focusSelectedItem: j,
305
- selectedItemText: X,
306
- position: i,
307
- isPositioned: K,
308
- searchRef: ue,
309
- children: /* @__PURE__ */ d.jsx(xt, { as: _t, allowPinchZoom: !0, children: /* @__PURE__ */ d.jsx(
310
- it,
311
- {
312
- asChild: !0,
313
- trapped: u.open,
314
- onMountAutoFocus: (m) => {
315
- m.preventDefault();
316
- },
317
- onUnmountAutoFocus: E(l, (m) => {
318
- var I;
319
- (I = u.trigger) == null || I.focus({ preventScroll: !0 }), m.preventDefault();
320
- }),
321
- children: /* @__PURE__ */ d.jsx(
322
- lt,
323
- {
324
- asChild: !0,
325
- disableOutsidePointerEvents: !0,
326
- onEscapeKeyDown: p,
327
- onPointerDownOutside: r,
328
- onFocusOutside: (m) => m.preventDefault(),
329
- onDismiss: () => u.onOpenChange(!1),
330
- children: /* @__PURE__ */ d.jsx(
331
- le,
332
- {
333
- role: "listbox",
334
- id: u.contentId,
335
- "data-state": u.open ? "open" : "closed",
336
- dir: u.dir,
337
- onContextMenu: (m) => m.preventDefault(),
338
- ...C,
339
- ...ne,
340
- onPlaced: () => H(!0),
341
- ref: b,
342
- style: {
343
- // flex layout so we can place the scroll buttons properly
344
- display: "flex",
345
- flexDirection: "column",
346
- // reset the outline by default as the content MAY get focused
347
- outline: "none",
348
- ...C.style
349
- },
350
- onKeyDown: E(C.onKeyDown, (m) => {
351
- const I = m.ctrlKey || m.altKey || m.metaKey;
352
- if (m.key === "Tab" && m.preventDefault(), !I && m.key.length === 1 && se(m.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(m.key)) {
353
- let y = V().filter((S) => !S.disabled).map((S) => S.ref.current);
354
- if (["ArrowUp", "End"].includes(m.key) && (y = y.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(m.key)) {
355
- const S = m.target, x = y.indexOf(S);
356
- y = y.slice(x + 1);
357
- }
358
- setTimeout(() => _(y)), m.preventDefault();
359
- }
360
- })
361
- }
362
- )
363
- }
364
- )
365
- }
366
- ) })
367
- }
368
- );
369
- }
370
- );
371
- ke.displayName = bt;
372
- var Nt = "SelectItemAlignedPosition", Be = t.forwardRef((n, c) => {
373
- const { __scopeSelect: e, onPlaced: i, ...l } = n, p = Y(Q, e), r = q(Q, e), [s, o] = t.useState(null), [f, g] = t.useState(null), w = k(c, (b) => g(b)), P = ae(e), R = t.useRef(!1), T = t.useRef(!0), { viewport: a, selectedItem: v, selectedItemText: C, focusSelectedItem: u } = r, h = t.useCallback(() => {
374
- if (p.trigger && p.valueNode && s && f && a && v && C) {
375
- const b = p.trigger.getBoundingClientRect(), L = f.getBoundingClientRect(), W = p.valueNode.getBoundingClientRect(), X = C.getBoundingClientRect();
376
- if (p.dir !== "rtl") {
377
- const S = X.left - L.left, x = W.left - S, Z = b.left - x, $ = b.width + Z, me = Math.max($, L.width), he = window.innerWidth - D, ve = Te(x, [
378
- D,
379
- // Prevents the content from going off the starting edge of the
380
- // viewport. It may still go off the ending edge, but this can be
381
- // controlled by the user since they may want to manage overflow in a
382
- // specific way.
383
- // https://github.com/radix-ui/primitives/issues/2049
384
- Math.max(D, he - me)
385
- ]);
386
- s.style.minWidth = $ + "px", s.style.left = ve + "px";
387
- } else {
388
- const S = L.right - X.right, x = window.innerWidth - W.right - S, Z = window.innerWidth - b.right - x, $ = b.width + Z, me = Math.max($, L.width), he = window.innerWidth - D, ve = Te(x, [
389
- D,
390
- Math.max(D, he - me)
391
- ]);
392
- s.style.minWidth = $ + "px", s.style.right = ve + "px";
393
- }
394
- const B = P(), V = window.innerHeight - D * 2, K = a.scrollHeight, H = window.getComputedStyle(f), F = parseInt(H.borderTopWidth, 10), _ = parseInt(H.paddingTop, 10), j = parseInt(H.borderBottomWidth, 10), U = parseInt(H.paddingBottom, 10), G = F + _ + K + U + j, ue = Math.min(v.offsetHeight * 5, G), se = window.getComputedStyle(a), pe = parseInt(se.paddingTop, 10), fe = parseInt(se.paddingBottom, 10), ee = b.top + b.height / 2 - D, le = V - ee, ne = v.offsetHeight / 2, m = v.offsetTop + ne, I = F + _ + m, N = G - I;
395
- if (I <= ee) {
396
- const S = B.length > 0 && v === B[B.length - 1].ref.current;
397
- s.style.bottom = "0px";
398
- const x = f.clientHeight - a.offsetTop - a.offsetHeight, Z = Math.max(
399
- le,
400
- ne + // viewport might have padding bottom, include it to avoid a scrollable viewport
401
- (S ? fe : 0) + x + j
402
- ), $ = I + Z;
403
- s.style.height = $ + "px";
404
- } else {
405
- const S = B.length > 0 && v === B[0].ref.current;
406
- s.style.top = "0px";
407
- const Z = Math.max(
408
- ee,
409
- F + a.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
410
- (S ? pe : 0) + ne
411
- ) + N;
412
- s.style.height = Z + "px", a.scrollTop = I - ee + a.offsetTop;
413
- }
414
- s.style.margin = `${D}px 0`, s.style.minHeight = ue + "px", s.style.maxHeight = V + "px", i == null || i(), requestAnimationFrame(() => R.current = !0);
415
- }
416
- }, [
417
- P,
418
- p.trigger,
419
- p.valueNode,
420
- s,
421
- f,
422
- a,
423
- v,
424
- C,
425
- p.dir,
426
- i
427
- ]);
428
- z(() => h(), [h]);
429
- const [A, O] = t.useState();
430
- z(() => {
431
- f && O(window.getComputedStyle(f).zIndex);
432
- }, [f]);
433
- const oe = t.useCallback(
434
- (b) => {
435
- b && T.current === !0 && (h(), u == null || u(), T.current = !1);
436
- },
437
- [h, u]
438
- );
439
- return /* @__PURE__ */ d.jsx(
440
- At,
441
- {
442
- scope: e,
443
- contentWrapper: s,
444
- shouldExpandOnScrollRef: R,
445
- onScrollButtonChange: oe,
446
- children: /* @__PURE__ */ d.jsx(
447
- "div",
448
- {
449
- ref: o,
450
- style: {
451
- display: "flex",
452
- flexDirection: "column",
453
- position: "fixed",
454
- zIndex: A
455
- },
456
- children: /* @__PURE__ */ d.jsx(
457
- M.div,
458
- {
459
- ...l,
460
- ref: w,
461
- style: {
462
- // When we get the height of the content, it includes borders. If we were to set
463
- // the height without having `boxSizing: 'border-box'` it would be too big.
464
- boxSizing: "border-box",
465
- // We need to ensure the content doesn't get taller than the wrapper
466
- maxHeight: "100%",
467
- ...l.style
468
- }
469
- }
470
- )
471
- }
472
- )
473
- }
474
- );
475
- });
476
- Be.displayName = Nt;
477
- var Mt = "SelectPopperPosition", ge = t.forwardRef((n, c) => {
478
- const {
479
- __scopeSelect: e,
480
- align: i = "start",
481
- collisionPadding: l = D,
482
- ...p
483
- } = n, r = de(e);
484
- return /* @__PURE__ */ d.jsx(
485
- ut,
486
- {
487
- ...r,
488
- ...p,
489
- ref: c,
490
- align: i,
491
- collisionPadding: l,
492
- style: {
493
- // Ensure border-box for floating-ui calculations
494
- boxSizing: "border-box",
495
- ...p.style,
496
- "--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
497
- "--radix-select-content-available-width": "var(--radix-popper-available-width)",
498
- "--radix-select-content-available-height": "var(--radix-popper-available-height)",
499
- "--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
500
- "--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
501
- }
502
- }
503
- );
504
- });
505
- ge.displayName = Mt;
506
- var [At, Ie] = te(Q, {}), Se = "SelectViewport", Ve = t.forwardRef(
507
- (n, c) => {
508
- const { __scopeSelect: e, nonce: i, ...l } = n, p = q(Se, e), r = Ie(Se, e), s = k(c, p.onViewportChange), o = t.useRef(0);
509
- return /* @__PURE__ */ d.jsxs(d.Fragment, { children: [
510
- /* @__PURE__ */ d.jsx(
511
- "style",
512
- {
513
- dangerouslySetInnerHTML: {
514
- __html: "[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"
515
- },
516
- nonce: i
517
- }
518
- ),
519
- /* @__PURE__ */ d.jsx(ie.Slot, { scope: e, children: /* @__PURE__ */ d.jsx(
520
- M.div,
521
- {
522
- "data-radix-select-viewport": "",
523
- role: "presentation",
524
- ...l,
525
- ref: s,
526
- style: {
527
- // we use position: 'relative' here on the `viewport` so that when we call
528
- // `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
529
- // (independent of the scrollUpButton).
530
- position: "relative",
531
- flex: 1,
532
- // Viewport should only be scrollable in the vertical direction.
533
- // This won't work in vertical writing modes, so we'll need to
534
- // revisit this if/when that is supported
535
- // https://developer.chrome.com/blog/vertical-form-controls
536
- overflow: "hidden auto",
537
- ...l.style
538
- },
539
- onScroll: E(l.onScroll, (f) => {
540
- const g = f.currentTarget, { contentWrapper: w, shouldExpandOnScrollRef: P } = r;
541
- if (P != null && P.current && w) {
542
- const R = Math.abs(o.current - g.scrollTop);
543
- if (R > 0) {
544
- const T = window.innerHeight - D * 2, a = parseFloat(w.style.minHeight), v = parseFloat(w.style.height), C = Math.max(a, v);
545
- if (C < T) {
546
- const u = C + R, h = Math.min(T, u), A = u - h;
547
- w.style.height = h + "px", w.style.bottom === "0px" && (g.scrollTop = A > 0 ? A : 0, w.style.justifyContent = "flex-end");
548
- }
549
- }
550
- }
551
- o.current = g.scrollTop;
552
- })
553
- }
554
- ) })
555
- ] });
556
- }
557
- );
558
- Ve.displayName = Se;
559
- var He = "SelectGroup", [Ot, Dt] = te(He), Fe = t.forwardRef(
560
- (n, c) => {
561
- const { __scopeSelect: e, ...i } = n, l = ye();
562
- return /* @__PURE__ */ d.jsx(Ot, { scope: e, id: l, children: /* @__PURE__ */ d.jsx(M.div, { role: "group", "aria-labelledby": l, ...i, ref: c }) });
563
- }
564
- );
565
- Fe.displayName = He;
566
- var Ue = "SelectLabel", We = t.forwardRef(
567
- (n, c) => {
568
- const { __scopeSelect: e, ...i } = n, l = Dt(Ue, e);
569
- return /* @__PURE__ */ d.jsx(M.div, { id: l.id, ...i, ref: c });
570
- }
571
- );
572
- We.displayName = Ue;
573
- var ce = "SelectItem", [Lt, Ke] = te(ce), Ge = t.forwardRef(
574
- (n, c) => {
575
- const {
576
- __scopeSelect: e,
577
- value: i,
578
- disabled: l = !1,
579
- textValue: p,
580
- ...r
581
- } = n, s = Y(ce, e), o = q(ce, e), f = s.value === i, [g, w] = t.useState(p ?? ""), [P, R] = t.useState(!1), T = k(
582
- c,
583
- (u) => {
584
- var h;
585
- return (h = o.itemRefCallback) == null ? void 0 : h.call(o, u, i, l);
586
- }
587
- ), a = ye(), v = t.useRef("touch"), C = () => {
588
- l || (s.onValueChange(i), s.onOpenChange(!1));
589
- };
590
- if (i === "")
591
- throw new Error(
592
- "A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder."
593
- );
594
- return /* @__PURE__ */ d.jsx(
595
- Lt,
596
- {
597
- scope: e,
598
- value: i,
599
- disabled: l,
600
- textId: a,
601
- isSelected: f,
602
- onItemTextChange: t.useCallback((u) => {
603
- w((h) => h || ((u == null ? void 0 : u.textContent) ?? "").trim());
604
- }, []),
605
- children: /* @__PURE__ */ d.jsx(
606
- ie.ItemSlot,
607
- {
608
- scope: e,
609
- value: i,
610
- disabled: l,
611
- textValue: g,
612
- children: /* @__PURE__ */ d.jsx(
613
- M.div,
614
- {
615
- role: "option",
616
- "aria-labelledby": a,
617
- "data-highlighted": P ? "" : void 0,
618
- "aria-selected": f && P,
619
- "data-state": f ? "checked" : "unchecked",
620
- "aria-disabled": l || void 0,
621
- "data-disabled": l ? "" : void 0,
622
- tabIndex: l ? void 0 : -1,
623
- ...r,
624
- ref: T,
625
- onFocus: E(r.onFocus, () => R(!0)),
626
- onBlur: E(r.onBlur, () => R(!1)),
627
- onClick: E(r.onClick, () => {
628
- v.current !== "mouse" && C();
629
- }),
630
- onPointerUp: E(r.onPointerUp, () => {
631
- v.current === "mouse" && C();
632
- }),
633
- onPointerDown: E(r.onPointerDown, (u) => {
634
- v.current = u.pointerType;
635
- }),
636
- onPointerMove: E(r.onPointerMove, (u) => {
637
- var h;
638
- v.current = u.pointerType, l ? (h = o.onItemLeave) == null || h.call(o) : v.current === "mouse" && u.currentTarget.focus({ preventScroll: !0 });
639
- }),
640
- onPointerLeave: E(r.onPointerLeave, (u) => {
641
- var h;
642
- u.currentTarget === document.activeElement && ((h = o.onItemLeave) == null || h.call(o));
643
- }),
644
- onKeyDown: E(r.onKeyDown, (u) => {
645
- var A;
646
- ((A = o.searchRef) == null ? void 0 : A.current) !== "" && u.key === " " || (Ct.includes(u.key) && C(), u.key === " " && u.preventDefault());
647
- })
648
- }
649
- )
650
- }
651
- )
652
- }
653
- );
654
- }
655
- );
656
- Ge.displayName = ce;
657
- var re = "SelectItemText", ze = t.forwardRef(
658
- (n, c) => {
659
- const { __scopeSelect: e, className: i, style: l, ...p } = n, r = Y(re, e), s = q(re, e), o = Ke(re, e), f = Pt(re, e), [g, w] = t.useState(null), P = k(
660
- c,
661
- (C) => w(C),
662
- o.onItemTextChange,
663
- (C) => {
664
- var u;
665
- return (u = s.itemTextRefCallback) == null ? void 0 : u.call(s, C, o.value, o.disabled);
666
- }
667
- ), R = g == null ? void 0 : g.textContent, T = t.useMemo(
668
- () => /* @__PURE__ */ d.jsx("option", { value: o.value, disabled: o.disabled, children: R }, o.value),
669
- [o.disabled, o.value, R]
670
- ), { onNativeOptionAdd: a, onNativeOptionRemove: v } = f;
671
- return z(() => (a(T), () => v(T)), [a, v, T]), /* @__PURE__ */ d.jsxs(d.Fragment, { children: [
672
- /* @__PURE__ */ d.jsx(M.span, { id: o.textId, ...p, ref: P }),
673
- o.isSelected && r.valueNode && !r.valueNodeHasChildren ? Re.createPortal(p.children, r.valueNode) : null
674
- ] });
675
- }
676
- );
677
- ze.displayName = re;
678
- var Ye = "SelectItemIndicator", qe = t.forwardRef(
679
- (n, c) => {
680
- const { __scopeSelect: e, ...i } = n;
681
- return Ke(Ye, e).isSelected ? /* @__PURE__ */ d.jsx(M.span, { "aria-hidden": !0, ...i, ref: c }) : null;
682
- }
683
- );
684
- qe.displayName = Ye;
685
- var xe = "SelectScrollUpButton", Xe = t.forwardRef((n, c) => {
686
- const e = q(xe, n.__scopeSelect), i = Ie(xe, n.__scopeSelect), [l, p] = t.useState(!1), r = k(c, i.onScrollButtonChange);
687
- return z(() => {
688
- if (e.viewport && e.isPositioned) {
689
- let s = function() {
690
- const f = o.scrollTop > 0;
691
- p(f);
692
- };
693
- const o = e.viewport;
694
- return s(), o.addEventListener("scroll", s), () => o.removeEventListener("scroll", s);
695
- }
696
- }, [e.viewport, e.isPositioned]), l ? /* @__PURE__ */ d.jsx(
697
- $e,
698
- {
699
- ...n,
700
- ref: r,
701
- onAutoScroll: () => {
702
- const { viewport: s, selectedItem: o } = e;
703
- s && o && (s.scrollTop = s.scrollTop - o.offsetHeight);
704
- }
705
- }
706
- ) : null;
707
- });
708
- Xe.displayName = xe;
709
- var we = "SelectScrollDownButton", Ze = t.forwardRef((n, c) => {
710
- const e = q(we, n.__scopeSelect), i = Ie(we, n.__scopeSelect), [l, p] = t.useState(!1), r = k(c, i.onScrollButtonChange);
711
- return z(() => {
712
- if (e.viewport && e.isPositioned) {
713
- let s = function() {
714
- const f = o.scrollHeight - o.clientHeight, g = Math.ceil(o.scrollTop) < f;
715
- p(g);
716
- };
717
- const o = e.viewport;
718
- return s(), o.addEventListener("scroll", s), () => o.removeEventListener("scroll", s);
719
- }
720
- }, [e.viewport, e.isPositioned]), l ? /* @__PURE__ */ d.jsx(
721
- $e,
722
- {
723
- ...n,
724
- ref: r,
725
- onAutoScroll: () => {
726
- const { viewport: s, selectedItem: o } = e;
727
- s && o && (s.scrollTop = s.scrollTop + o.offsetHeight);
728
- }
729
- }
730
- ) : null;
731
- });
732
- Ze.displayName = we;
733
- var $e = t.forwardRef((n, c) => {
734
- const { __scopeSelect: e, onAutoScroll: i, ...l } = n, p = q("SelectScrollButton", e), r = t.useRef(null), s = ae(e), o = t.useCallback(() => {
735
- r.current !== null && (window.clearInterval(r.current), r.current = null);
736
- }, []);
737
- return t.useEffect(() => () => o(), [o]), z(() => {
738
- var g;
739
- const f = s().find((w) => w.ref.current === document.activeElement);
740
- (g = f == null ? void 0 : f.ref.current) == null || g.scrollIntoView({ block: "nearest" });
741
- }, [s]), /* @__PURE__ */ d.jsx(
742
- M.div,
743
- {
744
- "aria-hidden": !0,
745
- ...l,
746
- ref: c,
747
- style: { flexShrink: 0, ...l.style },
748
- onPointerDown: E(l.onPointerDown, () => {
749
- r.current === null && (r.current = window.setInterval(i, 50));
750
- }),
751
- onPointerMove: E(l.onPointerMove, () => {
752
- var f;
753
- (f = p.onItemLeave) == null || f.call(p), r.current === null && (r.current = window.setInterval(i, 50));
754
- }),
755
- onPointerLeave: E(l.onPointerLeave, () => {
756
- o();
757
- })
758
- }
759
- );
760
- }), jt = "SelectSeparator", Je = t.forwardRef(
761
- (n, c) => {
762
- const { __scopeSelect: e, ...i } = n;
763
- return /* @__PURE__ */ d.jsx(M.div, { "aria-hidden": !0, ...i, ref: c });
764
- }
765
- );
766
- Je.displayName = jt;
767
- var Ce = "SelectArrow", kt = t.forwardRef(
768
- (n, c) => {
769
- const { __scopeSelect: e, ...i } = n, l = de(e), p = Y(Ce, e), r = q(Ce, e);
770
- return p.open && r.position === "popper" ? /* @__PURE__ */ d.jsx(pt, { ...l, ...i, ref: c }) : null;
771
- }
772
- );
773
- kt.displayName = Ce;
774
- var Bt = "SelectBubbleInput", Qe = t.forwardRef(
775
- ({ __scopeSelect: n, value: c, ...e }, i) => {
776
- const l = t.useRef(null), p = k(i, l), r = vt(c);
777
- return t.useEffect(() => {
778
- const s = l.current;
779
- if (!s) return;
780
- const o = window.HTMLSelectElement.prototype, g = Object.getOwnPropertyDescriptor(
781
- o,
782
- "value"
783
- ).set;
784
- if (r !== c && g) {
785
- const w = new Event("change", { bubbles: !0 });
786
- g.call(s, c), s.dispatchEvent(w);
787
- }
788
- }, [r, c]), /* @__PURE__ */ d.jsx(
789
- M.select,
790
- {
791
- ...e,
792
- style: { ...gt, ...e.style },
793
- ref: p,
794
- defaultValue: c
795
- }
796
- );
797
- }
798
- );
799
- Qe.displayName = Bt;
800
- function et(n) {
801
- return n === "" || n === void 0;
802
- }
803
- function tt(n) {
804
- const c = ht(n), e = t.useRef(""), i = t.useRef(0), l = t.useCallback(
805
- (r) => {
806
- const s = e.current + r;
807
- c(s), function o(f) {
808
- e.current = f, window.clearTimeout(i.current), f !== "" && (i.current = window.setTimeout(() => o(""), 1e3));
809
- }(s);
810
- },
811
- [c]
812
- ), p = t.useCallback(() => {
813
- e.current = "", window.clearTimeout(i.current);
814
- }, []);
815
- return t.useEffect(() => () => window.clearTimeout(i.current), []), [e, l, p];
816
- }
817
- function ot(n, c, e) {
818
- const l = c.length > 1 && Array.from(c).every((f) => f === c[0]) ? c[0] : c, p = e ? n.indexOf(e) : -1;
819
- let r = Vt(n, Math.max(p, 0));
820
- l.length === 1 && (r = r.filter((f) => f !== e));
821
- const o = r.find(
822
- (f) => f.textValue.toLowerCase().startsWith(l.toLowerCase())
823
- );
824
- return o !== e ? o : void 0;
825
- }
826
- function Vt(n, c) {
827
- return n.map((e, i) => n[(c + i) % n.length]);
828
- }
829
- var ao = be, uo = Ne, po = Ae, fo = Oe, mo = De, ho = Le, vo = Ve, go = Fe, So = We, xo = Ge, wo = ze, Co = qe, yo = Xe, Io = Ze, To = Je;
830
- export {
831
- ho as Content,
832
- go as Group,
833
- fo as Icon,
834
- xo as Item,
835
- Co as ItemIndicator,
836
- wo as ItemText,
837
- So as Label,
838
- mo as Portal,
839
- ao as Root,
840
- Io as ScrollDownButton,
841
- yo as ScrollUpButton,
842
- be as Select,
843
- kt as SelectArrow,
844
- Le as SelectContent,
845
- Fe as SelectGroup,
846
- Oe as SelectIcon,
847
- Ge as SelectItem,
848
- qe as SelectItemIndicator,
849
- ze as SelectItemText,
850
- We as SelectLabel,
851
- De as SelectPortal,
852
- Ze as SelectScrollDownButton,
853
- Xe as SelectScrollUpButton,
854
- Je as SelectSeparator,
855
- Ne as SelectTrigger,
856
- Ae as SelectValue,
857
- Ve as SelectViewport,
858
- To as Separator,
859
- uo as Trigger,
860
- po as Value,
861
- vo as Viewport,
862
- io as createSelectScope
863
- };