@wirecore/wirelayer-react 0.7.0 → 0.9.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.
Files changed (67) hide show
  1. package/dist/ContextMenu-GCeoPu8T.js +1523 -0
  2. package/dist/{Input-C8T3WLd5.js → Input-CtYSQznO.js} +41 -40
  3. package/dist/PasswordInput-CxZXGV2m.js +449 -0
  4. package/dist/Select-CGyqfOm3.js +256 -0
  5. package/dist/components/Alert/Alert.d.ts +3 -1
  6. package/dist/components/Alert/Alert.d.ts.map +1 -1
  7. package/dist/components/Avatar/Avatar.d.ts +3 -1
  8. package/dist/components/Avatar/Avatar.d.ts.map +1 -1
  9. package/dist/components/Card/Card.d.ts +3 -1
  10. package/dist/components/Card/Card.d.ts.map +1 -1
  11. package/dist/components/Checkbox/Checkbox.d.ts +9 -5
  12. package/dist/components/Checkbox/Checkbox.d.ts.map +1 -1
  13. package/dist/components/Code/Code.d.ts +11 -0
  14. package/dist/components/Code/Code.d.ts.map +1 -0
  15. package/dist/components/Combobox/Combobox.d.ts +10 -1
  16. package/dist/components/Combobox/Combobox.d.ts.map +1 -1
  17. package/dist/components/ContextMenu/ContextMenu.d.ts +14 -4
  18. package/dist/components/ContextMenu/ContextMenu.d.ts.map +1 -1
  19. package/dist/components/Dialog/Dialog.d.ts +12 -3
  20. package/dist/components/Dialog/Dialog.d.ts.map +1 -1
  21. package/dist/components/Input/Input.d.ts +7 -2
  22. package/dist/components/Input/Input.d.ts.map +1 -1
  23. package/dist/components/Menu/Menu.d.ts +27 -3
  24. package/dist/components/Menu/Menu.d.ts.map +1 -1
  25. package/dist/components/NativeSelect/NativeSelect.d.ts +14 -8
  26. package/dist/components/NativeSelect/NativeSelect.d.ts.map +1 -1
  27. package/dist/components/NumberInput/NumberInput.d.ts +12 -4
  28. package/dist/components/NumberInput/NumberInput.d.ts.map +1 -1
  29. package/dist/components/PasswordInput/PasswordInput.d.ts +7 -2
  30. package/dist/components/PasswordInput/PasswordInput.d.ts.map +1 -1
  31. package/dist/components/Progress/Progress.d.ts +15 -1
  32. package/dist/components/Progress/Progress.d.ts.map +1 -1
  33. package/dist/components/RadioGroup/RadioGroup.d.ts +16 -7
  34. package/dist/components/RadioGroup/RadioGroup.d.ts.map +1 -1
  35. package/dist/components/RadioGroup/RadioGroupItem.d.ts +3 -2
  36. package/dist/components/RadioGroup/RadioGroupItem.d.ts.map +1 -1
  37. package/dist/components/RadioGroup/context.d.ts +3 -0
  38. package/dist/components/RadioGroup/context.d.ts.map +1 -0
  39. package/dist/components/SegmentedControl/SegmentedControl.d.ts +14 -5
  40. package/dist/components/SegmentedControl/SegmentedControl.d.ts.map +1 -1
  41. package/dist/components/Select/Select.d.ts +20 -5
  42. package/dist/components/Select/Select.d.ts.map +1 -1
  43. package/dist/components/Stepper/Stepper.d.ts +3 -1
  44. package/dist/components/Stepper/Stepper.d.ts.map +1 -1
  45. package/dist/components/Tabs/Tabs.d.ts +11 -2
  46. package/dist/components/Tabs/Tabs.d.ts.map +1 -1
  47. package/dist/components/Textarea/Textarea.d.ts +7 -2
  48. package/dist/components/Textarea/Textarea.d.ts.map +1 -1
  49. package/dist/components/Wizard/Wizard.d.ts +11 -3
  50. package/dist/components/Wizard/Wizard.d.ts.map +1 -1
  51. package/dist/data-table.js +3 -3
  52. package/dist/form.js +1 -1
  53. package/dist/hooks/index.d.ts +1 -1
  54. package/dist/hooks/index.d.ts.map +1 -1
  55. package/dist/hooks/media.d.ts +7 -0
  56. package/dist/hooks/media.d.ts.map +1 -1
  57. package/dist/index.d.ts +5 -3
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +2111 -2026
  60. package/dist/pdf.js +2 -2
  61. package/dist/sources/Code.css +2 -0
  62. package/llms-full.txt +106 -28
  63. package/llms.txt +6 -4
  64. package/package.json +3 -3
  65. package/dist/ContextMenu-BD72S5n6.js +0 -1452
  66. package/dist/PasswordInput-SjO66gZB.js +0 -422
  67. package/dist/Select-7rfeNmJb.js +0 -242
@@ -1,422 +0,0 @@
1
- "use client";
2
- import { a as e, n as t } from "./RecipesProvider-0idafuGm.js";
3
- import { r as n, t as r } from "./InputStatus-hVzkU_4q.js";
4
- import { checkPasswordRequirements as i, clampDialogOffset as a, closeTab as o, controlIds as s, dialog as c, dialogMoveForKey as l, dialogMoveKeys as u, passwordInput as d, passwordStrength as f, scrollEdges as p, setTextControlValue as m, tabs as h } from "@wirecore/wirelayer-recipes";
5
- import { Check as g, ChevronLeft as _, ChevronRight as v, Circle as y, Eye as b, EyeOff as x, Maximize2 as S, Minimize2 as C, X as w } from "lucide-react";
6
- import { createContext as T, useContext as E, useEffect as D, useId as O, useRef as k, useState as A } from "react";
7
- import { jsx as j, jsxs as M } from "react/jsx-runtime";
8
- import { Portal as N } from "@ark-ui/react/portal";
9
- import { useFieldContext as P } from "@ark-ui/react/field";
10
- import { Tabs as F } from "@ark-ui/react/tabs";
11
- import { Dialog as I, useDialogContext as L } from "@ark-ui/react/dialog";
12
- import { PasswordInput as R } from "@ark-ui/react/password-input";
13
- //#region src/components/Tabs/Tabs.tsx
14
- function z({ classes: e, value: n, defaultValue: r, onValueChange: i, label: a, orientation: o, activationMode: s, lazyMount: c, unmountOnExit: l, className: u, ...d }) {
15
- let f = t("tabs", h, e)();
16
- return /* @__PURE__ */ j(F.Root, {
17
- ...d,
18
- className: f.base({ class: u }),
19
- value: n,
20
- defaultValue: r,
21
- onValueChange: (e) => i?.(e.value),
22
- orientation: o,
23
- activationMode: s,
24
- lazyMount: c,
25
- unmountOnExit: l,
26
- translations: a ? { listLabel: a } : void 0
27
- });
28
- }
29
- function B({ scrollable: e = !1, className: n, children: r, ...i }) {
30
- let a = t("tabs", h)(), o = k(null), [s, c] = A({
31
- start: !1,
32
- end: !1
33
- }), l = () => o.current && c(p(o.current));
34
- D(() => {
35
- if (!e || !o.current) return;
36
- l();
37
- let t = new ResizeObserver(l);
38
- return t.observe(o.current), () => t.disconnect();
39
- }, [e]);
40
- let u = (e) => {
41
- let t = o.current;
42
- if (!t) return;
43
- let n = getComputedStyle(t).direction === "rtl", r = t.clientWidth * .8 * (e ? 1 : -1) * (n ? -1 : 1), i = !matchMedia("(prefers-reduced-motion: reduce)").matches;
44
- t.scrollBy({
45
- left: r,
46
- behavior: i ? "smooth" : "auto"
47
- });
48
- };
49
- return e ? /* @__PURE__ */ M("div", {
50
- className: a.scroller(),
51
- children: [
52
- s.start && /* @__PURE__ */ j("button", {
53
- type: "button",
54
- tabIndex: -1,
55
- "aria-hidden": "true",
56
- "data-side": "start",
57
- className: a.scrollButton(),
58
- onClick: () => u(!1),
59
- children: /* @__PURE__ */ j(_, { className: a.scrollIcon() })
60
- }),
61
- /* @__PURE__ */ j(F.List, {
62
- ...i,
63
- ref: o,
64
- className: a.list({ class: [a.scrollList(), n] }),
65
- onScroll: (e) => {
66
- l(), i.onScroll?.(e);
67
- },
68
- children: r
69
- }),
70
- s.end && /* @__PURE__ */ j("button", {
71
- type: "button",
72
- tabIndex: -1,
73
- "aria-hidden": "true",
74
- "data-side": "end",
75
- className: a.scrollButton(),
76
- onClick: () => u(!0),
77
- children: /* @__PURE__ */ j(v, { className: a.scrollIcon() })
78
- })
79
- ]
80
- }) : /* @__PURE__ */ j(F.List, {
81
- ...i,
82
- className: a.list({ class: n }),
83
- children: r
84
- });
85
- }
86
- function V({ classes: e, value: n, icon: r, disabled: i, closable: a = !1, onClose: s, className: c, children: l, onKeyDown: u, ...d }) {
87
- let f = t("tabs", h, e)({ closable: a }), p = /* @__PURE__ */ M(F.Trigger, {
88
- ...d,
89
- className: f.trigger({ class: c }),
90
- value: n,
91
- disabled: i,
92
- ...a ? {
93
- "aria-keyshortcuts": "Delete",
94
- onKeyDown: (e) => {
95
- u?.(e), !(e.key !== "Delete" || e.defaultPrevented || i) && (e.preventDefault(), o(e.currentTarget, () => s?.(n)));
96
- }
97
- } : { onKeyDown: u },
98
- children: [r && /* @__PURE__ */ j(r, {
99
- className: f.icon(),
100
- "aria-hidden": "true"
101
- }), l]
102
- });
103
- return a ? /* @__PURE__ */ M("span", {
104
- role: "presentation",
105
- className: f.tab(),
106
- children: [p, /* @__PURE__ */ j("button", {
107
- type: "button",
108
- tabIndex: -1,
109
- "aria-hidden": "true",
110
- className: f.close(),
111
- disabled: i,
112
- onClick: (e) => {
113
- let t = e.currentTarget.parentElement?.querySelector("[role=tab]");
114
- t && o(t, () => s?.(n));
115
- },
116
- children: /* @__PURE__ */ j(w, { className: f.closeIcon() })
117
- })]
118
- }) : p;
119
- }
120
- function H({ classes: e, value: n, className: r, ...i }) {
121
- let a = t("tabs", h, e)();
122
- return /* @__PURE__ */ j(F.Content, {
123
- ...i,
124
- className: a.content({ class: r }),
125
- value: n
126
- });
127
- }
128
- //#endregion
129
- //#region src/components/Dialog/Dialog.tsx
130
- var U = T({ modal: !0 });
131
- function W({ open: e, defaultOpen: t, onOpenChange: n, role: r = "dialog", modal: i = !0, closeOnEscape: a = !0, closeOnInteractOutside: o, children: s }) {
132
- return /* @__PURE__ */ j(U.Provider, {
133
- value: { modal: i },
134
- children: /* @__PURE__ */ j(I.Root, {
135
- open: e,
136
- defaultOpen: t,
137
- onOpenChange: (e) => n?.(e.open),
138
- role: r,
139
- modal: i,
140
- closeOnEscape: a,
141
- closeOnInteractOutside: o,
142
- lazyMount: !0,
143
- unmountOnExit: !0,
144
- children: s
145
- })
146
- });
147
- }
148
- function G({ children: e }) {
149
- return /* @__PURE__ */ j(I.Trigger, {
150
- asChild: !0,
151
- children: e
152
- });
153
- }
154
- function K({ children: e }) {
155
- return /* @__PURE__ */ j(I.CloseTrigger, {
156
- asChild: !0,
157
- children: e
158
- });
159
- }
160
- function q(e, t) {
161
- let [n, r] = A({
162
- x: 0,
163
- y: 0
164
- }), i = k(null), [o, s] = A(t);
165
- o !== t && (s(t), t || r({
166
- x: 0,
167
- y: 0
168
- }));
169
- let c = (e, t, n) => {
170
- let i = t.getBoundingClientRect(), o = {
171
- x: i.x - n.x,
172
- y: i.y - n.y,
173
- width: i.width,
174
- height: i.height
175
- };
176
- r(a(e, o, {
177
- width: innerWidth,
178
- height: innerHeight
179
- }));
180
- };
181
- return {
182
- header: {
183
- onPointerDown(t) {
184
- if (!e || t.button !== 0 || t.target.closest("button, a, input")) return;
185
- let r = t.currentTarget.closest("[data-part=content]");
186
- r && (i.current = {
187
- id: t.pointerId,
188
- x: t.clientX,
189
- y: t.clientY,
190
- origin: n,
191
- content: r
192
- }, t.currentTarget.setPointerCapture?.(t.pointerId), t.preventDefault());
193
- },
194
- onPointerMove(e) {
195
- let t = i.current;
196
- t && e.pointerId === t.id && c({
197
- x: t.origin.x + e.clientX - t.x,
198
- y: t.origin.y + e.clientY - t.y
199
- }, t.content, n);
200
- },
201
- onPointerUp() {
202
- i.current = null;
203
- },
204
- onPointerCancel() {
205
- i.current = null;
206
- }
207
- },
208
- onKeyDown: (t) => {
209
- if (!e) return;
210
- let r = l(t);
211
- r && (t.preventDefault(), c({
212
- x: n.x + r.x,
213
- y: n.y + r.y
214
- }, t.currentTarget, n));
215
- },
216
- style: e && (n.x || n.y) ? { translate: `${n.x}px ${n.y}px` } : void 0
217
- };
218
- }
219
- function J({ classes: n, title: r, hideTitle: i, description: a, icon: o, status: s, size: l, position: d, fullscreen: f, maximizable: p, maximized: m, defaultMaximized: h, onMaximizedChange: g, draggable: _, closable: v = !0, scrollBehavior: y, responsive: b = !0, closeLabel: x, maximizeLabel: T, restoreLabel: D, footer: O, portalTarget: k, className: P, style: F, onKeyDown: R, children: z, ...B }) {
220
- let V = t("dialog", c, n), H = e(), { modal: W } = E(U), G = L(), [K, J] = A(h ?? !1), Y = m ?? K, X = () => {
221
- J(!Y), g?.(!Y);
222
- }, Z = q(!!_ && !Y && !f, G.open), Q = V({
223
- status: s,
224
- size: l,
225
- position: d,
226
- scrollBehavior: y,
227
- fullscreen: f || Y,
228
- responsive: b,
229
- draggable: _ && !Y,
230
- maximizable: p,
231
- hideTitle: i
232
- }), $ = Y ? C : S;
233
- return /* @__PURE__ */ M(N, {
234
- ...k ? { container: { current: k } } : {},
235
- children: [W && /* @__PURE__ */ j(I.Backdrop, { className: Q.backdrop() }), /* @__PURE__ */ j(I.Positioner, {
236
- className: Q.positioner(),
237
- children: /* @__PURE__ */ M(I.Content, {
238
- ...B,
239
- ..._ ? { "aria-keyshortcuts": u } : {},
240
- className: Q.content({ class: P }),
241
- style: Z.style ? {
242
- ...F,
243
- ...Z.style
244
- } : F,
245
- onKeyDown: (e) => {
246
- R?.(e), _ && Z.onKeyDown(e);
247
- },
248
- children: [
249
- /* @__PURE__ */ M("div", {
250
- className: Q.header(),
251
- ..._ ? Z.header : {},
252
- children: [
253
- o && /* @__PURE__ */ j("span", {
254
- className: Q.iconBox(),
255
- children: /* @__PURE__ */ j(o, {
256
- className: Q.icon(),
257
- "aria-hidden": "true"
258
- })
259
- }),
260
- p && /* @__PURE__ */ j("button", {
261
- type: "button",
262
- className: Q.maximize(),
263
- "aria-label": Y ? D ?? H.dialog.restore : T ?? H.dialog.maximize,
264
- onClick: X,
265
- children: /* @__PURE__ */ j($, {
266
- className: Q.maximizeIcon(),
267
- "aria-hidden": "true"
268
- })
269
- }),
270
- v && /* @__PURE__ */ j(I.CloseTrigger, {
271
- className: Q.close(),
272
- "aria-label": x ?? H.common.close,
273
- children: /* @__PURE__ */ j(w, {
274
- className: Q.closeIcon(),
275
- "aria-hidden": "true"
276
- })
277
- })
278
- ]
279
- }),
280
- /* @__PURE__ */ M("div", {
281
- className: Q.body(),
282
- children: [
283
- /* @__PURE__ */ j(I.Title, {
284
- className: Q.title(),
285
- children: r
286
- }),
287
- a && /* @__PURE__ */ j(I.Description, {
288
- className: Q.description(),
289
- children: a
290
- }),
291
- z
292
- ]
293
- }),
294
- O && /* @__PURE__ */ j("div", {
295
- className: Q.footer(),
296
- children: O
297
- })
298
- ]
299
- })
300
- })]
301
- });
302
- }
303
- //#endregion
304
- //#region src/components/PasswordInput/PasswordInput.tsx
305
- function Y({ classes: a, size: o, invalid: c, success: l, disabled: u, readOnly: p, required: h, name: _, defaultVisible: v, visible: S, onVisibleChange: C, autoComplete: w = "current-password", strength: T = !1, requirements: E, loading: D = !1, clearable: N = !1, clearLabel: F, id: I, className: L, style: z, ...B }) {
306
- let V = t("passwordInput", d, a), H = e(), U = P(), W = n(), G = !(c || U?.invalid) && (!!l || W.success), K = V({
307
- size: o,
308
- success: G
309
- }), q = O(), [J, Y] = A(String(B.defaultValue ?? "")), X = B.value === void 0 ? J : String(B.value), Z = f(X), Q = X ? H.passwordStrength.levels[Z] : "", $ = i(X, E ?? []), ee = T || E?.length ? [
310
- U?.ariaDescribedby,
311
- T && `${q}strength`,
312
- E?.length && `${q}requirements`
313
- ].filter(Boolean).join(" ") : void 0, te = k(null), ne = () => {
314
- let e = te.current?.querySelector("input");
315
- e && (m(e), e.focus());
316
- };
317
- return /* @__PURE__ */ M(R.Root, {
318
- className: K.base({ class: L }),
319
- style: z,
320
- invalid: c,
321
- disabled: u,
322
- readOnly: p,
323
- required: h,
324
- name: _,
325
- defaultVisible: v,
326
- visible: S,
327
- onVisibilityChange: (e) => C?.(e.visible),
328
- autoComplete: w,
329
- translations: H.passwordInput,
330
- ...s(I, "input", { input: U?.ids.control }),
331
- children: [
332
- /* @__PURE__ */ M(R.Control, {
333
- ref: te,
334
- className: K.control(),
335
- children: [
336
- /* @__PURE__ */ j(R.Input, {
337
- ...B,
338
- "aria-describedby": ee,
339
- "aria-busy": D || void 0,
340
- className: K.input(),
341
- onChange: (e) => {
342
- Y(e.target.value), B.onChange?.(e);
343
- }
344
- }),
345
- (D || N || G) && /* @__PURE__ */ j(r, {
346
- loading: D,
347
- clear: N && !!X && !(u || U?.disabled) && !(p || U?.readOnly),
348
- clearLabel: F ?? H.field.clear,
349
- onClear: ne,
350
- success: G,
351
- classes: {
352
- spinner: K.spinner(),
353
- clear: K.clear(),
354
- clearIcon: K.clearIcon(),
355
- statusIcon: K.statusIcon()
356
- }
357
- }),
358
- /* @__PURE__ */ j(R.VisibilityTrigger, {
359
- className: K.toggle(),
360
- children: /* @__PURE__ */ j(R.Indicator, {
361
- fallback: /* @__PURE__ */ j(b, {
362
- className: K.toggleIcon(),
363
- "aria-hidden": "true"
364
- }),
365
- children: /* @__PURE__ */ j(x, {
366
- className: K.toggleIcon(),
367
- "aria-hidden": "true"
368
- })
369
- })
370
- })
371
- ]
372
- }),
373
- T && /* @__PURE__ */ M("div", {
374
- className: K.strength(),
375
- children: [/* @__PURE__ */ j("div", {
376
- className: K.meter(),
377
- "aria-hidden": "true",
378
- children: [
379
- 1,
380
- 2,
381
- 3,
382
- 4
383
- ].map((e) => /* @__PURE__ */ j("span", {
384
- className: K.bar(),
385
- "data-level": Z,
386
- "data-filled": e <= Z || void 0
387
- }, e))
388
- }), /* @__PURE__ */ j("span", {
389
- id: `${q}strength`,
390
- className: K.strengthText(),
391
- "aria-live": "polite",
392
- children: Q && H.passwordStrength.label(Q)
393
- })]
394
- }),
395
- !!E?.length && /* @__PURE__ */ j("ul", {
396
- id: `${q}requirements`,
397
- className: K.requirements(),
398
- "aria-label": H.passwordRequirements.label,
399
- children: E.map((e, t) => /* @__PURE__ */ M("li", {
400
- className: K.requirement(),
401
- "data-met": $[t] || void 0,
402
- children: [
403
- $[t] ? /* @__PURE__ */ j(g, {
404
- className: K.requirementIcon(),
405
- "aria-hidden": "true"
406
- }) : /* @__PURE__ */ j(y, {
407
- className: K.requirementIcon(),
408
- "aria-hidden": "true"
409
- }),
410
- e.label,
411
- /* @__PURE__ */ j("span", {
412
- className: K.requirementState(),
413
- children: `: ${$[t] ? H.passwordRequirements.met : H.passwordRequirements.unmet}`
414
- })
415
- ]
416
- }, e.label))
417
- })
418
- ]
419
- });
420
- }
421
- //#endregion
422
- export { U as a, H as c, J as i, B as l, W as n, G as o, K as r, z as s, Y as t, V as u };
@@ -1,242 +0,0 @@
1
- "use client";
2
- import { a as e, n as t } from "./RecipesProvider-0idafuGm.js";
3
- import { a as n, c as r, n as i, o as a } from "./Highlight-43-H9459.js";
4
- import { controlIds as o, select as s, spinner as c } from "@wirecore/wirelayer-recipes";
5
- import { ChevronDown as l, LoaderCircle as u, X as d } from "lucide-react";
6
- import { useEffect as f, useId as ee, useMemo as p, useState as te } from "react";
7
- import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
8
- import { Portal as ne } from "@ark-ui/react/portal";
9
- import { useFieldContext as _ } from "@ark-ui/react/field";
10
- import { createListCollection as re } from "@ark-ui/react/collection";
11
- import { Select as v } from "@ark-ui/react/select";
12
- //#region src/components/Spinner/Spinner.tsx
13
- var y = 2 * Math.PI * 9;
14
- function b({ classes: n, size: r, label: i, value: a, className: o, ...s }) {
15
- let l = t("spinner", c, n), d = e(), f = l({ size: r });
16
- if (a !== void 0) {
17
- let e = Math.min(100, Math.max(0, a));
18
- return /* @__PURE__ */ h("span", {
19
- ...s,
20
- className: f.base({ class: o }),
21
- role: "progressbar",
22
- "aria-label": i ?? d.common.loading,
23
- "aria-valuemin": 0,
24
- "aria-valuemax": 100,
25
- "aria-valuenow": e,
26
- "aria-valuetext": `${Math.round(e)} %`,
27
- children: /* @__PURE__ */ g("svg", {
28
- className: f.ring(),
29
- viewBox: "0 0 24 24",
30
- "aria-hidden": "true",
31
- children: [/* @__PURE__ */ h("circle", {
32
- className: f.ringTrack(),
33
- cx: "12",
34
- cy: "12",
35
- r: "9",
36
- strokeWidth: "3"
37
- }), /* @__PURE__ */ h("circle", {
38
- className: f.ringRange(),
39
- cx: "12",
40
- cy: "12",
41
- r: "9",
42
- strokeWidth: "3",
43
- strokeLinecap: "round",
44
- strokeDasharray: `${e / 100 * y} ${y}`
45
- })]
46
- })
47
- });
48
- }
49
- return /* @__PURE__ */ g("span", {
50
- ...s,
51
- className: f.base({ class: o }),
52
- role: "status",
53
- children: [/* @__PURE__ */ h(u, {
54
- className: f.icon(),
55
- "aria-hidden": "true"
56
- }), /* @__PURE__ */ h("span", {
57
- className: f.label(),
58
- children: i ?? d.common.loading
59
- })]
60
- });
61
- }
62
- //#endregion
63
- //#region src/components/Select/Select.tsx
64
- function x({ classes: c, items: y, value: b, defaultValue: x, onValueChange: ie, placeholder: ae, disabled: oe, invalid: se, required: ce, name: S, itemValue: le, itemLabel: ue, itemDisabled: de, itemGroup: fe, itemKeywords: pe, valueKey: me, clearable: C, loading: w, loadingText: he, size: ge, filter: T, manualFilter: E, onFilterChange: D, emptyText: _e, hasMore: ve, onLoadMore: ye, dataSource: O, minSearchLength: be, pageSize: k, standalone: A, renderItem: j, renderValue: M, id: N, className: xe, style: Se, onKeyDown: Ce, ...P }) {
65
- let F = t("select", s, c)({
66
- size: ge,
67
- clearable: C
68
- }), I = _(), L = e(), R = L.select, z = {
69
- itemValue: le,
70
- itemLabel: ue,
71
- itemDisabled: de,
72
- itemGroup: fe,
73
- itemKeywords: pe,
74
- valueKey: me
75
- }, [B, V] = te(""), H = r({
76
- items: y,
77
- source: O,
78
- accessors: z,
79
- pageSize: k,
80
- minSearchLength: be
81
- }), { options: U, groups: we, ordered: W, firstFor: Te } = n(H.items, z, T && !E && !O ? B : ""), G = p(() => [...U, ...H.resolvedOptions], [U, H.resolvedOptions]), { selected: K, keys: q, commit: J, commitKeys: Ee } = a({
82
- multiple: !1,
83
- value: b,
84
- defaultValue: x,
85
- accessors: z,
86
- items: G,
87
- onChange: ie,
88
- check: {
89
- component: "Select",
90
- ready: !O && !w && y.length > 0
91
- }
92
- }), De = q.join("\0");
93
- f(() => {
94
- H.resolve(q, G);
95
- }, [De, O]);
96
- let Y = w || H.loading, X = K[0], Oe = p(() => re({
97
- items: W,
98
- itemToString: (e) => e.label,
99
- itemToValue: (e) => e.key,
100
- isItemDisabled: (e) => e.disabled
101
- }), [W]), Z = ee(), Q = X?.icon, ke = {
102
- item: F.item(),
103
- itemText: F.itemText(),
104
- icon: F.icon(),
105
- itemIndicator: F.itemIndicator(),
106
- itemBody: F.itemBody(),
107
- itemDescription: F.itemDescription(),
108
- group: F.group(),
109
- groupLabel: F.groupLabel(),
110
- loading: F.loading(),
111
- loadingIcon: F.loadingIcon(),
112
- sentinel: F.sentinel(),
113
- empty: F.empty()
114
- }, $ = /* @__PURE__ */ h(i, {
115
- parts: v,
116
- groups: we,
117
- classes: ke,
118
- loading: Y,
119
- loadingText: he ?? L.common.loading,
120
- hasMore: ve || H.hasMore,
121
- onLoadMore: () => O ? H.loadMore() : ye?.(),
122
- emptyText: _e ?? H.emptyText ?? (B ? L.common.noResults : L.common.empty),
123
- renderItem: j
124
- });
125
- function Ae(e) {
126
- Ce?.(e), C && K.length && (e.key === "Backspace" || e.key === "Delete") && (e.preventDefault(), J([]));
127
- }
128
- function je(e, t) {
129
- V(t), D?.(t), O && H.search(t);
130
- let n = E || O ? void 0 : Te(t);
131
- n && requestAnimationFrame(() => e.setHighlightValue(n.key));
132
- }
133
- return /* @__PURE__ */ g(v.Root, {
134
- className: F.base({ class: xe }),
135
- style: Se,
136
- collection: Oe,
137
- value: q,
138
- onValueChange: (e) => Ee(e.value, e.items),
139
- onOpenChange: (e) => {
140
- e.open && H.open(), !e.open && B && (V(""), D?.(""), O && H.search(""));
141
- },
142
- disabled: oe,
143
- invalid: se,
144
- required: ce,
145
- name: S,
146
- ...o(N, "trigger", {
147
- label: I?.ids.label,
148
- hiddenSelect: I?.ids.control
149
- }, A),
150
- positioning: {
151
- sameWidth: !0,
152
- gutter: 4
153
- },
154
- composite: !T,
155
- lazyMount: !0,
156
- unmountOnExit: !0,
157
- children: [
158
- /* @__PURE__ */ g(v.Control, {
159
- ...C ? { className: F.control() } : {},
160
- children: [/* @__PURE__ */ g(v.Trigger, {
161
- ...P,
162
- className: F.trigger(),
163
- "aria-busy": w || void 0,
164
- onKeyDown: Ae,
165
- children: [/* @__PURE__ */ h("span", {
166
- className: F.value(),
167
- children: M && X ? M(X.item) : /* @__PURE__ */ g(m, { children: [Q && /* @__PURE__ */ h(Q, {
168
- className: F.icon(),
169
- "aria-hidden": "true"
170
- }), /* @__PURE__ */ h(v.ValueText, {
171
- placeholder: ae ?? L.common.placeholder,
172
- children: X?.label || void 0
173
- })] })
174
- }), /* @__PURE__ */ h(v.Indicator, {
175
- className: F.indicator(),
176
- children: w ? /* @__PURE__ */ h(u, {
177
- className: F.spinner(),
178
- "aria-hidden": "true"
179
- }) : /* @__PURE__ */ h(l, {
180
- className: F.indicatorIcon(),
181
- "aria-hidden": "true"
182
- })
183
- })]
184
- }), C && /* @__PURE__ */ h(v.Context, { children: (e) => X && !e.disabled && /* @__PURE__ */ h("button", {
185
- type: "button",
186
- tabIndex: -1,
187
- className: F.clear(),
188
- "aria-label": R.clear,
189
- onClick: () => {
190
- J([]), e.focus();
191
- },
192
- children: /* @__PURE__ */ h(d, {
193
- className: F.clearIcon(),
194
- "aria-hidden": "true"
195
- })
196
- }) })]
197
- }),
198
- /* @__PURE__ */ h(ne, { children: /* @__PURE__ */ h(v.Positioner, { children: /* @__PURE__ */ h(v.Content, {
199
- className: F.content(),
200
- "aria-busy": Y || void 0,
201
- "aria-label": T ? P["aria-label"] : void 0,
202
- children: T ? /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("div", {
203
- className: F.header(),
204
- children: /* @__PURE__ */ h(v.Context, { children: (e) => /* @__PURE__ */ h("input", {
205
- type: "text",
206
- role: "combobox",
207
- autoComplete: "off",
208
- "aria-autocomplete": "list",
209
- "aria-expanded": "true",
210
- "data-autofocus": "",
211
- "aria-controls": Z,
212
- "aria-activedescendant": e.highlightedItem ? e.getItemProps({ item: e.highlightedItem }).id : void 0,
213
- "aria-label": R.filter,
214
- placeholder: L.combobox.search,
215
- value: B,
216
- className: F.search(),
217
- onChange: (t) => je(e, t.target.value),
218
- onKeyDown: (e) => {
219
- [
220
- " ",
221
- "Home",
222
- "End"
223
- ].includes(e.key) && e.stopPropagation();
224
- }
225
- }) })
226
- }), /* @__PURE__ */ h(v.List, {
227
- id: Z,
228
- className: F.list(),
229
- children: $
230
- })] }) : $
231
- }) }) }),
232
- /* @__PURE__ */ h(v.HiddenSelect, {}),
233
- O && /* @__PURE__ */ h("span", {
234
- role: "status",
235
- className: F.status(),
236
- children: H.announcement
237
- })
238
- ]
239
- });
240
- }
241
- //#endregion
242
- export { b as n, x as t };