@spear-ai/spectral 1.8.9 → 1.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 (53) hide show
  1. package/dist/.js +214 -210
  2. package/dist/Accordion.js +4 -4
  3. package/dist/Combobox/ComboboxBase.d.ts +8 -0
  4. package/dist/Combobox/ComboboxBase.js +80 -0
  5. package/dist/Combobox.d.ts +20 -0
  6. package/dist/Combobox.js +175 -0
  7. package/dist/ComboboxBase-CxNxYtdT.js +408 -0
  8. package/dist/ControlGroup/ControlGroupSelect.d.ts +33 -0
  9. package/dist/ControlGroup/ControlGroupSelect.js +104 -0
  10. package/dist/ControlGroup.d.ts +24 -0
  11. package/dist/ControlGroup.js +51 -0
  12. package/dist/Dialog.js +2 -2
  13. package/dist/Drawer.js +1 -1
  14. package/dist/HoverCard.js +4 -4
  15. package/dist/MultiSelect/MultiSelectBase.js +128 -126
  16. package/dist/Popover.js +1 -1
  17. package/dist/RadioGroup.js +5 -5
  18. package/dist/Select.js +1 -1
  19. package/dist/Slider.js +3 -3
  20. package/dist/Tooltip.js +6 -6
  21. package/dist/Tray.d.ts +3 -1
  22. package/dist/Tray.js +36 -32
  23. package/dist/{Combination-CQ5bXZqE.js → index-6oYKCvIn.js} +179 -178
  24. package/dist/{index-CtqlhLRO.js → index-BFOf48AQ.js} +1 -1
  25. package/dist/{index-BJ6qs9i5.js → index-BlHU_t18.js} +7 -7
  26. package/dist/{index-D2Qxe4uK.js → index-Bm1RbF6w.js} +1 -1
  27. package/dist/{index-CXltlPV-.js → index-Bv2OIg5P.js} +6 -6
  28. package/dist/{index-Cgdmxb3F.js → index-CKEI0pDv.js} +1 -1
  29. package/dist/{index-CDkQCeZY.js → index-CM_hWgfC.js} +1 -1
  30. package/dist/{index-CJKg3MVV.js → index-C_YVr64u.js} +2 -2
  31. package/dist/{index-obMGvcdD.js → index-CwSyIPrv.js} +1 -1
  32. package/dist/{index-9OmOYyjJ.js → index-Dc0No4pV.js} +2 -1
  33. package/dist/{index-DqvTB1Bv.js → index-T6XEa11q.js} +7 -7
  34. package/dist/{index-CmWCa9Ae.js → index-pBCLb6Gr.js} +5 -5
  35. package/dist/{index-WBfSMXvE.js → index-psiVrsnE.js} +1 -1
  36. package/dist/index.d.ts +3 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/primitives/button.d.ts +1 -1
  39. package/dist/primitives/button.d.ts.map +1 -1
  40. package/dist/primitives/button.js +4 -4
  41. package/dist/{InputGroup.d.ts → primitives/input-group.d.ts} +10 -7
  42. package/dist/primitives/input-group.d.ts.map +1 -0
  43. package/dist/primitives/input-group.js +74 -0
  44. package/dist/primitives/input.d.ts +6 -1
  45. package/dist/primitives/input.d.ts.map +1 -1
  46. package/dist/primitives/input.js +1 -1
  47. package/dist/primitives/popover.d.ts +10 -0
  48. package/dist/primitives/popover.d.ts.map +1 -0
  49. package/dist/primitives/popover.js +26 -0
  50. package/dist/primitives/select.js +2 -2
  51. package/dist/styles/spectral.css +2 -2
  52. package/package.json +1 -1
  53. package/dist/InputGroup.js +0 -84
@@ -0,0 +1,175 @@
1
+ "use client";
2
+ import "./styles/main.css";
3
+ import { jsxs as c, jsx as o } from "react/jsx-runtime";
4
+ import { _ as I, C as $, a as H, b as J } from "./ComboboxBase-CxNxYtdT.js";
5
+ import "./Icons/AnalyzeIcon.js";
6
+ import "./Icons/AnnotationsIcon.js";
7
+ import "./Icons/ApprovedIcon.js";
8
+ import "./Icons/ArrowDownIcon.js";
9
+ import "./Icons/ArrowUpIcon.js";
10
+ import "./Icons/BoxToolIcon.js";
11
+ import "./Icons/CalendarIcon.js";
12
+ import "./Icons/CheckCircleIcon.js";
13
+ import "./Icons/CheckSquareIcon.js";
14
+ import "./Icons/CheckmarkIcon.js";
15
+ import { ChevronDownIcon as Q } from "./Icons/ChevronDownIcon.js";
16
+ import "./Icons/ChevronUpIcon.js";
17
+ import "./Icons/ClockIcon.js";
18
+ import "./Icons/CloseCircleIcon.js";
19
+ import "./Icons/CloseIcon.js";
20
+ import "./Icons/DashboardIcon.js";
21
+ import "./Icons/DatabaseIcon.js";
22
+ import "./Icons/DeleteIcon.js";
23
+ import "./Icons/DurationIcon.js";
24
+ import "./Icons/EditIcon.js";
25
+ import "./Icons/EmailIcon.js";
26
+ import "./Icons/EraserIcon.js";
27
+ import "./Icons/ErrorIcon.js";
28
+ import "./Icons/EyeClosedIcon.js";
29
+ import "./Icons/EyeClosedIcon2.js";
30
+ import "./Icons/EyeOpenIcon.js";
31
+ import "./Icons/FileDownloadIcon.js";
32
+ import "./Icons/GoToFirstIcon.js";
33
+ import "./Icons/GoToLastIcon.js";
34
+ import "./Icons/HarmonicCursorsIcon.js";
35
+ import "./Icons/InfoIcon.js";
36
+ import "./Icons/KeyboardIcon.js";
37
+ import "./Icons/LabelIcon.js";
38
+ import "./Icons/LassoIcon.js";
39
+ import "./Icons/LineToolIcon.js";
40
+ import "./Icons/LiveViewIcon.js";
41
+ import { LoaderIcon as U } from "./Icons/LoaderIcon.js";
42
+ import "./Icons/LocationIcon.js";
43
+ import "./Icons/LogoutIcon.js";
44
+ import "./Icons/MeasureIcon.js";
45
+ import "./Icons/MessagesIcon.js";
46
+ import "./Icons/MetadataIcon.js";
47
+ import "./Icons/MinusIcon.js";
48
+ import "./Icons/OntologyIcon.js";
49
+ import "./Icons/PanelIconClose.js";
50
+ import "./Icons/PanelIconOpen.js";
51
+ import "./Icons/PlayIcon.js";
52
+ import "./Icons/PlusIcon.js";
53
+ import "./Icons/PolygonIcon.js";
54
+ import "./Icons/ResetIcon.js";
55
+ import "./Icons/ReviewedIcon.js";
56
+ import "./Icons/ScissorsIcon.js";
57
+ import "./Icons/SearchIcon.js";
58
+ import "./Icons/SettingsIcon.js";
59
+ import "./Icons/SortAscendingIcon.js";
60
+ import "./Icons/SortAtoZIcon.js";
61
+ import "./Icons/SortDescendingIcon.js";
62
+ import "./Icons/SortZtoAIcon.js";
63
+ import "./Icons/StackIcon.js";
64
+ import "./Icons/StarIcon.js";
65
+ import "./Icons/TrashIcon.js";
66
+ import "./Icons/UndoIcon.js";
67
+ import "./Icons/User2Icon.js";
68
+ import "./Icons/UserIcon.js";
69
+ import "./Icons/WarningIcon.js";
70
+ import "./Icons/ZoomAllIcon.js";
71
+ import "./Icons/ZoomXIcon.js";
72
+ import "./Icons/ZoomYIcon.js";
73
+ import { Label as W } from "./Label.js";
74
+ import { InputGroup as X, InputGroupAddon as Y } from "./primitives/input-group.js";
75
+ import { useFormFieldId as Z, useFormFieldState as oo, getAriaProps as to, getFormFieldCSSProperties as ro, getStateClasses as eo, ErrorMessage as io, LoadingState as no, EmptyState as mo, getErrorMessageId as ao } from "./utils/formFieldUtils.js";
76
+ import { cn as n } from "./utils/twUtils.js";
77
+ import { useRef as N, useState as y, useCallback as so } from "react";
78
+ const po = ({
79
+ className: S,
80
+ disabled: F,
81
+ emptyMessage: g = "No options found.",
82
+ errorMessage: x,
83
+ id: D,
84
+ label: e,
85
+ labelClassName: E,
86
+ loadingMessage: k = "Loading…",
87
+ name: u,
88
+ onValueChange: z,
89
+ options: b = [],
90
+ placeholder: L = "Search…",
91
+ ref: A,
92
+ required: O,
93
+ state: m = "default",
94
+ value: a = "",
95
+ "aria-describedby": P,
96
+ "aria-label": f
97
+ }) => {
98
+ process.env.NODE_ENV !== "production" && !e && !f && console.warn("Combobox: provide either `label` or `aria-label` for an accessible name.");
99
+ const v = N(null), C = N(null), s = Z(D, u), p = `${s}-listbox`, w = ao(s), { isDisabled: r, isLoading: l, isInvalid: R } = oo(F, m), V = to(m, P, O, w), [d, i] = y(!1), [_, h] = y(""), j = b.find((t) => t.value === a), B = (t) => {
100
+ z?.(t === a ? "" : t), h(""), i(!1);
101
+ }, G = (t) => {
102
+ t.key === "Escape" && i(!1);
103
+ }, K = so(() => {
104
+ requestAnimationFrame(() => {
105
+ C.current?.contains(document.activeElement) || (i(!1), h(""));
106
+ });
107
+ }, []), M = () => {
108
+ r || l || (v.current?.focus(), i(!0));
109
+ }, T = () => l ? /* @__PURE__ */ o("div", { id: p, role: "listbox", children: /* @__PURE__ */ o(no, { message: k }) }) : b.length === 0 ? /* @__PURE__ */ o("div", { id: p, role: "listbox", children: /* @__PURE__ */ o(mo, { message: g }) }) : /* @__PURE__ */ c($, { id: p, children: [
110
+ /* @__PURE__ */ o(H, { children: g }),
111
+ b.map((t) => /* @__PURE__ */ o(J, { "data-checked": a === t.value || void 0, disabled: t.disabled, onMouseDown: (q) => q.preventDefault(), onSelect: () => B(t.value), value: t.label, children: t.label }, t.value))
112
+ ] });
113
+ return /* @__PURE__ */ c("div", { className: "w-full", ref: A, children: [
114
+ u && /* @__PURE__ */ o("input", { type: "hidden", name: u, value: a, disabled: r }),
115
+ e && /* @__PURE__ */ o(W, { className: n("text-text-primary mb-2 block", E, r && "text-text-secondary"), "data-testid": "spectral-combobox-label", htmlFor: s, children: e }),
116
+ /* @__PURE__ */ c(I, { ref: C, label: f ?? e, onKeyDown: G, className: n("relative w-full", S), children: [
117
+ /* @__PURE__ */ c(
118
+ X,
119
+ {
120
+ "data-slot": "combobox-content",
121
+ "data-state": m,
122
+ "data-testid": "spectral-combobox-trigger",
123
+ className: n(
124
+ "border-input-border bg-input-bg h-12 cursor-pointer border-2",
125
+ "hover:border-input-border--hover transition duration-200",
126
+ "focus-within:border-input-border--focus focus-within:outline-none",
127
+ "ring-0!",
128
+ eo(m),
129
+ d && "border-input-border--focus",
130
+ r && "pointer-events-none"
131
+ ),
132
+ onClick: M,
133
+ style: ro(),
134
+ children: [
135
+ /* @__PURE__ */ o(
136
+ I.Input,
137
+ {
138
+ ref: v,
139
+ autoComplete: "off",
140
+ "data-slot": "input-group-control",
141
+ "aria-controls": p,
142
+ "aria-expanded": d,
143
+ "aria-label": f ?? e,
144
+ className: "placeholder:text-input-text-placeholder min-w-0 flex-1 border-0 bg-transparent px-3 py-1 text-base outline-hidden focus-visible:ring-0 focus-visible:outline-none",
145
+ disabled: r,
146
+ id: s,
147
+ onBlur: K,
148
+ onFocus: () => !r && !l && i(!0),
149
+ onValueChange: h,
150
+ placeholder: j?.label ?? L,
151
+ role: "combobox",
152
+ value: _,
153
+ ...V
154
+ }
155
+ ),
156
+ /* @__PURE__ */ o(Y, { align: "inline-end", children: l ? /* @__PURE__ */ o(U, { className: "text-muted-foreground size-5 motion-safe:animate-spin" }) : /* @__PURE__ */ o(Q, { className: n("text-muted-foreground size-5 shrink-0 transition-transform duration-200", d && "rotate-180") }) })
157
+ ]
158
+ }
159
+ ),
160
+ /* @__PURE__ */ o(
161
+ "div",
162
+ {
163
+ className: n("border-input-border bg-input-bg absolute top-full left-0 z-50 mt-1 w-full rounded-lg border p-1 shadow-md", "motion-safe:animate-in motion-safe:fade-in-0 motion-safe:zoom-in-95 motion-safe:slide-in-from-top-2", !d && "hidden"),
164
+ "data-testid": "spectral-combobox-content",
165
+ children: T()
166
+ }
167
+ )
168
+ ] }),
169
+ R && x && /* @__PURE__ */ o(io, { dataTestId: "spectral-combobox-error-message", id: w, message: x })
170
+ ] });
171
+ };
172
+ po.displayName = "Combobox";
173
+ export {
174
+ po as Combobox
175
+ };
@@ -0,0 +1,408 @@
1
+ import "./styles/main.css";
2
+ import { jsx as S, jsxs as he } from "react/jsx-runtime";
3
+ import "./Icons/AnalyzeIcon.js";
4
+ import "./Icons/AnnotationsIcon.js";
5
+ import "./Icons/ApprovedIcon.js";
6
+ import "./Icons/ArrowDownIcon.js";
7
+ import "./Icons/ArrowUpIcon.js";
8
+ import "./Icons/BoxToolIcon.js";
9
+ import "./Icons/CalendarIcon.js";
10
+ import "./Icons/CheckCircleIcon.js";
11
+ import "./Icons/CheckSquareIcon.js";
12
+ import { CheckmarkIcon as Ce } from "./Icons/CheckmarkIcon.js";
13
+ import "./Icons/ChevronDownIcon.js";
14
+ import "./Icons/ChevronUpIcon.js";
15
+ import "./Icons/ClockIcon.js";
16
+ import "./Icons/CloseCircleIcon.js";
17
+ import "./Icons/CloseIcon.js";
18
+ import "./Icons/DashboardIcon.js";
19
+ import "./Icons/DatabaseIcon.js";
20
+ import "./Icons/DeleteIcon.js";
21
+ import "./Icons/DurationIcon.js";
22
+ import "./Icons/EditIcon.js";
23
+ import "./Icons/EmailIcon.js";
24
+ import "./Icons/EraserIcon.js";
25
+ import "./Icons/ErrorIcon.js";
26
+ import "./Icons/EyeClosedIcon.js";
27
+ import "./Icons/EyeClosedIcon2.js";
28
+ import "./Icons/EyeOpenIcon.js";
29
+ import "./Icons/FileDownloadIcon.js";
30
+ import "./Icons/GoToFirstIcon.js";
31
+ import "./Icons/GoToLastIcon.js";
32
+ import "./Icons/HarmonicCursorsIcon.js";
33
+ import "./Icons/InfoIcon.js";
34
+ import "./Icons/KeyboardIcon.js";
35
+ import "./Icons/LabelIcon.js";
36
+ import "./Icons/LassoIcon.js";
37
+ import "./Icons/LineToolIcon.js";
38
+ import "./Icons/LiveViewIcon.js";
39
+ import "./Icons/LoaderIcon.js";
40
+ import "./Icons/LocationIcon.js";
41
+ import "./Icons/LogoutIcon.js";
42
+ import "./Icons/MeasureIcon.js";
43
+ import "./Icons/MessagesIcon.js";
44
+ import "./Icons/MetadataIcon.js";
45
+ import "./Icons/MinusIcon.js";
46
+ import "./Icons/OntologyIcon.js";
47
+ import "./Icons/PanelIconClose.js";
48
+ import "./Icons/PanelIconOpen.js";
49
+ import "./Icons/PlayIcon.js";
50
+ import "./Icons/PlusIcon.js";
51
+ import "./Icons/PolygonIcon.js";
52
+ import "./Icons/ResetIcon.js";
53
+ import "./Icons/ReviewedIcon.js";
54
+ import "./Icons/ScissorsIcon.js";
55
+ import { SearchIcon as Se } from "./Icons/SearchIcon.js";
56
+ import "./Icons/SettingsIcon.js";
57
+ import "./Icons/SortAscendingIcon.js";
58
+ import "./Icons/SortAtoZIcon.js";
59
+ import "./Icons/SortDescendingIcon.js";
60
+ import "./Icons/SortZtoAIcon.js";
61
+ import "./Icons/StackIcon.js";
62
+ import "./Icons/StarIcon.js";
63
+ import "./Icons/TrashIcon.js";
64
+ import "./Icons/UndoIcon.js";
65
+ import "./Icons/User2Icon.js";
66
+ import "./Icons/UserIcon.js";
67
+ import "./Icons/WarningIcon.js";
68
+ import "./Icons/ZoomAllIcon.js";
69
+ import "./Icons/ZoomXIcon.js";
70
+ import "./Icons/ZoomYIcon.js";
71
+ import { InputGroup as Re, InputGroupAddon as Ae } from "./primitives/input-group.js";
72
+ import { cn as V } from "./utils/twUtils.js";
73
+ import { R as Me, P as $e, O as De, a as Ne } from "./index-pBCLb6Gr.js";
74
+ import * as l from "react";
75
+ import { P as A, h as q } from "./index-Dc0No4pV.js";
76
+ import { u as P } from "./index-CwSyIPrv.js";
77
+ var pe = 1, Fe = 0.9, Ke = 0.8, Pe = 0.17, ee = 0.1, te = 0.999, je = 0.9999, Le = 0.99, qe = /[\\\/_+.#"@\[\(\{&]/, Ve = /[\\\/_+.#"@\[\(\{&]/g, Oe = /[\s-]/, ge = /[\s-]/g;
78
+ function ne(e, n, r, m, a, c, d) {
79
+ if (c === n.length) return a === e.length ? pe : Le;
80
+ var p = `${a},${c}`;
81
+ if (d[p] !== void 0) return d[p];
82
+ for (var b = m.charAt(c), i = r.indexOf(b, a), v = 0, h, I, x, C; i >= 0; ) h = ne(e, n, r, m, i + 1, c + 1, d), h > v && (i === a ? h *= pe : qe.test(e.charAt(i - 1)) ? (h *= Ke, x = e.slice(a, i - 1).match(Ve), x && a > 0 && (h *= Math.pow(te, x.length))) : Oe.test(e.charAt(i - 1)) ? (h *= Fe, C = e.slice(a, i - 1).match(ge), C && a > 0 && (h *= Math.pow(te, C.length))) : (h *= Pe, a > 0 && (h *= Math.pow(te, i - a))), e.charAt(i) !== n.charAt(c) && (h *= je)), (h < ee && r.charAt(i - 1) === m.charAt(c + 1) || m.charAt(c + 1) === m.charAt(c) && r.charAt(i - 1) !== m.charAt(c)) && (I = ne(e, n, r, m, i + 1, c + 2, d), I * ee > h && (h = I * ee)), h > v && (v = h), i = r.indexOf(b, i + 1);
83
+ return d[p] = v, v;
84
+ }
85
+ function fe(e) {
86
+ return e.toLowerCase().replace(ge, " ");
87
+ }
88
+ function ze(e, n, r) {
89
+ return e = r && r.length > 0 ? `${e + " " + r.join(" ")}` : e, ne(e, n, fe(e), fe(n), 0, 0, {});
90
+ }
91
+ var L = '[cmdk-group=""]', re = '[cmdk-group-items=""]', Be = '[cmdk-group-heading=""]', be = '[cmdk-item=""]', ve = `${be}:not([aria-disabled="true"])`, le = "cmdk-item-select", F = "data-value", Ge = (e, n, r) => ze(e, n, r), ye = l.createContext(void 0), O = () => l.useContext(ye), we = l.createContext(void 0), oe = () => l.useContext(we), xe = l.createContext(void 0), ke = l.forwardRef((e, n) => {
92
+ let r = K(() => {
93
+ var t, u;
94
+ return { search: "", value: (u = (t = e.value) != null ? t : e.defaultValue) != null ? u : "", selectedItemId: void 0, filtered: { count: 0, items: /* @__PURE__ */ new Map(), groups: /* @__PURE__ */ new Set() } };
95
+ }), m = K(() => /* @__PURE__ */ new Set()), a = K(() => /* @__PURE__ */ new Map()), c = K(() => /* @__PURE__ */ new Map()), d = K(() => /* @__PURE__ */ new Set()), p = Ee(e), { label: b, children: i, value: v, onValueChange: h, filter: I, shouldFilter: x, loop: C, disablePointerSelection: H = !1, vimBindings: M = !0, ...B } = e, T = P(), ae = P(), W = P(), $ = l.useRef(null), y = et();
96
+ D(() => {
97
+ if (v !== void 0) {
98
+ let t = v.trim();
99
+ r.current.value = t, k.emit();
100
+ }
101
+ }, [v]), D(() => {
102
+ y(6, ue);
103
+ }, []);
104
+ let k = l.useMemo(() => ({ subscribe: (t) => (d.current.add(t), () => d.current.delete(t)), snapshot: () => r.current, setState: (t, u, s) => {
105
+ var o, f, g, E;
106
+ if (!Object.is(r.current[t], u)) {
107
+ if (r.current[t] = u, t === "search") Q(), X(), y(1, Y);
108
+ else if (t === "value") {
109
+ if (document.activeElement.hasAttribute("cmdk-input") || document.activeElement.hasAttribute("cmdk-root")) {
110
+ let w = document.getElementById(W);
111
+ w ? w.focus() : (o = document.getElementById(T)) == null || o.focus();
112
+ }
113
+ if (y(7, () => {
114
+ var w;
115
+ r.current.selectedItemId = (w = N()) == null ? void 0 : w.id, k.emit();
116
+ }), s || y(5, ue), ((f = p.current) == null ? void 0 : f.value) !== void 0) {
117
+ let w = u ?? "";
118
+ (E = (g = p.current).onValueChange) == null || E.call(g, w);
119
+ return;
120
+ }
121
+ }
122
+ k.emit();
123
+ }
124
+ }, emit: () => {
125
+ d.current.forEach((t) => t());
126
+ } }), []), J = l.useMemo(() => ({ value: (t, u, s) => {
127
+ var o;
128
+ u !== ((o = c.current.get(t)) == null ? void 0 : o.value) && (c.current.set(t, { value: u, keywords: s }), r.current.filtered.items.set(t, ie(u, s)), y(2, () => {
129
+ X(), k.emit();
130
+ }));
131
+ }, item: (t, u) => (m.current.add(t), u && (a.current.has(u) ? a.current.get(u).add(t) : a.current.set(u, /* @__PURE__ */ new Set([t]))), y(3, () => {
132
+ Q(), X(), r.current.value || Y(), k.emit();
133
+ }), () => {
134
+ c.current.delete(t), m.current.delete(t), r.current.filtered.items.delete(t);
135
+ let s = N();
136
+ y(4, () => {
137
+ Q(), s?.getAttribute("id") === t && Y(), k.emit();
138
+ });
139
+ }), group: (t) => (a.current.has(t) || a.current.set(t, /* @__PURE__ */ new Set()), () => {
140
+ c.current.delete(t), a.current.delete(t);
141
+ }), filter: () => p.current.shouldFilter, label: b || e["aria-label"], getDisablePointerSelection: () => p.current.disablePointerSelection, listId: T, inputId: W, labelId: ae, listInnerRef: $ }), []);
142
+ function ie(t, u) {
143
+ var s, o;
144
+ let f = (o = (s = p.current) == null ? void 0 : s.filter) != null ? o : Ge;
145
+ return t ? f(t, r.current.search, u) : 0;
146
+ }
147
+ function X() {
148
+ if (!r.current.search || p.current.shouldFilter === !1) return;
149
+ let t = r.current.filtered.items, u = [];
150
+ r.current.filtered.groups.forEach((o) => {
151
+ let f = a.current.get(o), g = 0;
152
+ f.forEach((E) => {
153
+ let w = t.get(E);
154
+ g = Math.max(w, g);
155
+ }), u.push([o, g]);
156
+ });
157
+ let s = $.current;
158
+ j().sort((o, f) => {
159
+ var g, E;
160
+ let w = o.getAttribute("id"), G = f.getAttribute("id");
161
+ return ((g = t.get(G)) != null ? g : 0) - ((E = t.get(w)) != null ? E : 0);
162
+ }).forEach((o) => {
163
+ let f = o.closest(re);
164
+ f ? f.appendChild(o.parentElement === f ? o : o.closest(`${re} > *`)) : s.appendChild(o.parentElement === s ? o : o.closest(`${re} > *`));
165
+ }), u.sort((o, f) => f[1] - o[1]).forEach((o) => {
166
+ var f;
167
+ let g = (f = $.current) == null ? void 0 : f.querySelector(`${L}[${F}="${encodeURIComponent(o[0])}"]`);
168
+ g?.parentElement.appendChild(g);
169
+ });
170
+ }
171
+ function Y() {
172
+ let t = j().find((s) => s.getAttribute("aria-disabled") !== "true"), u = t?.getAttribute(F);
173
+ k.setState("value", u || void 0);
174
+ }
175
+ function Q() {
176
+ var t, u, s, o;
177
+ if (!r.current.search || p.current.shouldFilter === !1) {
178
+ r.current.filtered.count = m.current.size;
179
+ return;
180
+ }
181
+ r.current.filtered.groups = /* @__PURE__ */ new Set();
182
+ let f = 0;
183
+ for (let g of m.current) {
184
+ let E = (u = (t = c.current.get(g)) == null ? void 0 : t.value) != null ? u : "", w = (o = (s = c.current.get(g)) == null ? void 0 : s.keywords) != null ? o : [], G = ie(E, w);
185
+ r.current.filtered.items.set(g, G), G > 0 && f++;
186
+ }
187
+ for (let [g, E] of a.current) for (let w of E) if (r.current.filtered.items.get(w) > 0) {
188
+ r.current.filtered.groups.add(g);
189
+ break;
190
+ }
191
+ r.current.filtered.count = f;
192
+ }
193
+ function ue() {
194
+ var t, u, s;
195
+ let o = N();
196
+ o && (((t = o.parentElement) == null ? void 0 : t.firstChild) === o && ((s = (u = o.closest(L)) == null ? void 0 : u.querySelector(Be)) == null || s.scrollIntoView({ block: "nearest" })), o.scrollIntoView({ block: "nearest" }));
197
+ }
198
+ function N() {
199
+ var t;
200
+ return (t = $.current) == null ? void 0 : t.querySelector(`${be}[aria-selected="true"]`);
201
+ }
202
+ function j() {
203
+ var t;
204
+ return Array.from(((t = $.current) == null ? void 0 : t.querySelectorAll(ve)) || []);
205
+ }
206
+ function Z(t) {
207
+ let u = j()[t];
208
+ u && k.setState("value", u.getAttribute(F));
209
+ }
210
+ function _(t) {
211
+ var u;
212
+ let s = N(), o = j(), f = o.findIndex((E) => E === s), g = o[f + t];
213
+ (u = p.current) != null && u.loop && (g = f + t < 0 ? o[o.length - 1] : f + t === o.length ? o[0] : o[f + t]), g && k.setState("value", g.getAttribute(F));
214
+ }
215
+ function ce(t) {
216
+ let u = N(), s = u?.closest(L), o;
217
+ for (; s && !o; ) s = t > 0 ? Ze(s, L) : _e(s, L), o = s?.querySelector(ve);
218
+ o ? k.setState("value", o.getAttribute(F)) : _(t);
219
+ }
220
+ let de = () => Z(j().length - 1), se = (t) => {
221
+ t.preventDefault(), t.metaKey ? de() : t.altKey ? ce(1) : _(1);
222
+ }, me = (t) => {
223
+ t.preventDefault(), t.metaKey ? Z(0) : t.altKey ? ce(-1) : _(-1);
224
+ };
225
+ return l.createElement(A.div, { ref: n, tabIndex: -1, ...B, "cmdk-root": "", onKeyDown: (t) => {
226
+ var u;
227
+ (u = B.onKeyDown) == null || u.call(B, t);
228
+ let s = t.nativeEvent.isComposing || t.keyCode === 229;
229
+ if (!(t.defaultPrevented || s)) switch (t.key) {
230
+ case "n":
231
+ case "j": {
232
+ M && t.ctrlKey && se(t);
233
+ break;
234
+ }
235
+ case "ArrowDown": {
236
+ se(t);
237
+ break;
238
+ }
239
+ case "p":
240
+ case "k": {
241
+ M && t.ctrlKey && me(t);
242
+ break;
243
+ }
244
+ case "ArrowUp": {
245
+ me(t);
246
+ break;
247
+ }
248
+ case "Home": {
249
+ t.preventDefault(), Z(0);
250
+ break;
251
+ }
252
+ case "End": {
253
+ t.preventDefault(), de();
254
+ break;
255
+ }
256
+ case "Enter": {
257
+ t.preventDefault();
258
+ let o = N();
259
+ if (o) {
260
+ let f = new Event(le);
261
+ o.dispatchEvent(f);
262
+ }
263
+ }
264
+ }
265
+ } }, l.createElement("label", { "cmdk-label": "", htmlFor: J.inputId, id: J.labelId, style: rt }, b), U(e, (t) => l.createElement(we.Provider, { value: k }, l.createElement(ye.Provider, { value: J }, t))));
266
+ }), Ue = l.forwardRef((e, n) => {
267
+ var r, m;
268
+ let a = P(), c = l.useRef(null), d = l.useContext(xe), p = O(), b = Ee(e), i = (m = (r = b.current) == null ? void 0 : r.forceMount) != null ? m : d?.forceMount;
269
+ D(() => {
270
+ if (!i) return p.item(a, d?.id);
271
+ }, [i]);
272
+ let v = Ie(a, c, [e.value, e.children, c], e.keywords), h = oe(), I = R((y) => y.value && y.value === v.current), x = R((y) => i || p.filter() === !1 ? !0 : y.search ? y.filtered.items.get(a) > 0 : !0);
273
+ l.useEffect(() => {
274
+ let y = c.current;
275
+ if (!(!y || e.disabled)) return y.addEventListener(le, C), () => y.removeEventListener(le, C);
276
+ }, [x, e.onSelect, e.disabled]);
277
+ function C() {
278
+ var y, k;
279
+ H(), (k = (y = b.current).onSelect) == null || k.call(y, v.current);
280
+ }
281
+ function H() {
282
+ h.setState("value", v.current, !0);
283
+ }
284
+ if (!x) return null;
285
+ let { disabled: M, value: B, onSelect: T, forceMount: ae, keywords: W, ...$ } = e;
286
+ return l.createElement(A.div, { ref: q(c, n), ...$, id: a, "cmdk-item": "", role: "option", "aria-disabled": !!M, "aria-selected": !!I, "data-disabled": !!M, "data-selected": !!I, onPointerMove: M || p.getDisablePointerSelection() ? void 0 : H, onClick: M ? void 0 : C }, e.children);
287
+ }), He = l.forwardRef((e, n) => {
288
+ let { heading: r, children: m, forceMount: a, ...c } = e, d = P(), p = l.useRef(null), b = l.useRef(null), i = P(), v = O(), h = R((x) => a || v.filter() === !1 ? !0 : x.search ? x.filtered.groups.has(d) : !0);
289
+ D(() => v.group(d), []), Ie(d, p, [e.value, e.heading, b]);
290
+ let I = l.useMemo(() => ({ id: d, forceMount: a }), [a]);
291
+ return l.createElement(A.div, { ref: q(p, n), ...c, "cmdk-group": "", role: "presentation", hidden: h ? void 0 : !0 }, r && l.createElement("div", { ref: b, "cmdk-group-heading": "", "aria-hidden": !0, id: i }, r), U(e, (x) => l.createElement("div", { "cmdk-group-items": "", role: "group", "aria-labelledby": r ? i : void 0 }, l.createElement(xe.Provider, { value: I }, x))));
292
+ }), Te = l.forwardRef((e, n) => {
293
+ let { alwaysRender: r, ...m } = e, a = l.useRef(null), c = R((d) => !d.search);
294
+ return !r && !c ? null : l.createElement(A.div, { ref: q(a, n), ...m, "cmdk-separator": "", role: "separator" });
295
+ }), We = l.forwardRef((e, n) => {
296
+ let { onValueChange: r, ...m } = e, a = e.value != null, c = oe(), d = R((i) => i.search), p = R((i) => i.selectedItemId), b = O();
297
+ return l.useEffect(() => {
298
+ e.value != null && c.setState("search", e.value);
299
+ }, [e.value]), l.createElement(A.input, { ref: n, ...m, "cmdk-input": "", autoComplete: "off", autoCorrect: "off", spellCheck: !1, "aria-autocomplete": "list", role: "combobox", "aria-expanded": !0, "aria-controls": b.listId, "aria-labelledby": b.labelId, "aria-activedescendant": p, id: b.inputId, type: "text", value: a ? e.value : d, onChange: (i) => {
300
+ a || c.setState("search", i.target.value), r?.(i.target.value);
301
+ } });
302
+ }), Je = l.forwardRef((e, n) => {
303
+ let { children: r, label: m = "Suggestions", ...a } = e, c = l.useRef(null), d = l.useRef(null), p = R((i) => i.selectedItemId), b = O();
304
+ return l.useEffect(() => {
305
+ if (d.current && c.current) {
306
+ let i = d.current, v = c.current, h, I = new ResizeObserver(() => {
307
+ h = requestAnimationFrame(() => {
308
+ let x = i.offsetHeight;
309
+ v.style.setProperty("--cmdk-list-height", x.toFixed(1) + "px");
310
+ });
311
+ });
312
+ return I.observe(i), () => {
313
+ cancelAnimationFrame(h), I.unobserve(i);
314
+ };
315
+ }
316
+ }, []), l.createElement(A.div, { ref: q(c, n), ...a, "cmdk-list": "", role: "listbox", tabIndex: -1, "aria-activedescendant": p, "aria-label": m, id: b.listId }, U(e, (i) => l.createElement("div", { ref: q(d, b.listInnerRef), "cmdk-list-sizer": "" }, i)));
317
+ }), Xe = l.forwardRef((e, n) => {
318
+ let { open: r, onOpenChange: m, overlayClassName: a, contentClassName: c, container: d, ...p } = e;
319
+ return l.createElement(Me, { open: r, onOpenChange: m }, l.createElement($e, { container: d }, l.createElement(De, { "cmdk-overlay": "", className: a }), l.createElement(Ne, { "aria-label": e.label, "cmdk-dialog": "", className: c }, l.createElement(ke, { ref: n, ...p }))));
320
+ }), Ye = l.forwardRef((e, n) => R((r) => r.filtered.count === 0) ? l.createElement(A.div, { ref: n, ...e, "cmdk-empty": "", role: "presentation" }) : null), Qe = l.forwardRef((e, n) => {
321
+ let { progress: r, children: m, label: a = "Loading...", ...c } = e;
322
+ return l.createElement(A.div, { ref: n, ...c, "cmdk-loading": "", role: "progressbar", "aria-valuenow": r, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": a }, U(e, (d) => l.createElement("div", { "aria-hidden": !0 }, d)));
323
+ }), z = Object.assign(ke, { List: Je, Item: Ue, Input: We, Group: He, Separator: Te, Dialog: Xe, Empty: Ye, Loading: Qe });
324
+ function Ze(e, n) {
325
+ let r = e.nextElementSibling;
326
+ for (; r; ) {
327
+ if (r.matches(n)) return r;
328
+ r = r.nextElementSibling;
329
+ }
330
+ }
331
+ function _e(e, n) {
332
+ let r = e.previousElementSibling;
333
+ for (; r; ) {
334
+ if (r.matches(n)) return r;
335
+ r = r.previousElementSibling;
336
+ }
337
+ }
338
+ function Ee(e) {
339
+ let n = l.useRef(e);
340
+ return D(() => {
341
+ n.current = e;
342
+ }), n;
343
+ }
344
+ var D = typeof window > "u" ? l.useEffect : l.useLayoutEffect;
345
+ function K(e) {
346
+ let n = l.useRef();
347
+ return n.current === void 0 && (n.current = e()), n;
348
+ }
349
+ function R(e) {
350
+ let n = oe(), r = () => e(n.snapshot());
351
+ return l.useSyncExternalStore(n.subscribe, r, r);
352
+ }
353
+ function Ie(e, n, r, m = []) {
354
+ let a = l.useRef(), c = O();
355
+ return D(() => {
356
+ var d;
357
+ let p = (() => {
358
+ var i;
359
+ for (let v of r) {
360
+ if (typeof v == "string") return v.trim();
361
+ if (typeof v == "object" && "current" in v) return v.current ? (i = v.current.textContent) == null ? void 0 : i.trim() : a.current;
362
+ }
363
+ })(), b = m.map((i) => i.trim());
364
+ c.value(e, p, b), (d = n.current) == null || d.setAttribute(F, p), a.current = p;
365
+ }), a;
366
+ }
367
+ var et = () => {
368
+ let [e, n] = l.useState(), r = K(() => /* @__PURE__ */ new Map());
369
+ return D(() => {
370
+ r.current.forEach((m) => m()), r.current = /* @__PURE__ */ new Map();
371
+ }, [e]), (m, a) => {
372
+ r.current.set(m, a), n({});
373
+ };
374
+ };
375
+ function tt(e) {
376
+ let n = e.type;
377
+ return typeof n == "function" ? n(e.props) : "render" in n ? n.render(e.props) : e;
378
+ }
379
+ function U({ asChild: e, children: n }, r) {
380
+ return e && l.isValidElement(n) ? l.cloneElement(tt(n), { ref: n.ref }, r(n.props.children)) : r(n);
381
+ }
382
+ var rt = { position: "absolute", width: "1px", height: "1px", padding: "0", margin: "-1px", overflow: "hidden", clip: "rect(0, 0, 0, 0)", whiteSpace: "nowrap", borderWidth: "0" };
383
+ const Er = ({ className: e, ...n }) => /* @__PURE__ */ S(z, { "data-slot": "command", className: V("bg-popover text-popover-foreground flex size-full flex-col overflow-hidden rounded-xl! p-1", e), ...n }), Ir = ({ className: e, ...n }) => /* @__PURE__ */ S("div", { "data-slot": "command-input-wrapper", className: "p-1 pb-0", children: /* @__PURE__ */ he(Re, { className: "border-input/30 bg-input/30 h-8! rounded-lg! shadow-none! *:data-[slot=input-group-addon]:pl-2!", children: [
384
+ /* @__PURE__ */ S(z.Input, { "data-slot": "command-input", className: V("w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50", e), ...n }),
385
+ /* @__PURE__ */ S(Ae, { children: /* @__PURE__ */ S(Se, { className: "size-4 shrink-0 opacity-50" }) })
386
+ ] }) }), Cr = ({ className: e, ...n }) => /* @__PURE__ */ S(z.List, { "data-slot": "command-list", className: V("no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none", e), ...n }), Sr = ({ className: e, ...n }) => /* @__PURE__ */ S(z.Empty, { "data-slot": "command-empty", className: V("py-6 text-center text-sm", e), ...n }), Rr = ({ className: e, children: n, ...r }) => /* @__PURE__ */ he(
387
+ z.Item,
388
+ {
389
+ "data-slot": "command-item",
390
+ className: V(
391
+ "group/command-item data-selected:bg-muted data-selected:text-foreground data-selected:*:[svg]:text-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
392
+ e
393
+ ),
394
+ ...r,
395
+ children: [
396
+ n,
397
+ /* @__PURE__ */ S(Ce, { className: "ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100" })
398
+ ]
399
+ }
400
+ );
401
+ export {
402
+ Cr as C,
403
+ z as _,
404
+ Sr as a,
405
+ Rr as b,
406
+ Er as c,
407
+ Ir as d
408
+ };
@@ -0,0 +1,33 @@
1
+ import { ControlGroupProps } from './ControlGroup';
2
+ import { Select } from '../primitives/select';
3
+ import { FormFieldState } from '../utils/formFieldUtils';
4
+ import { ComponentProps } from 'react';
5
+ export interface SelectOptionType {
6
+ label: string;
7
+ value: string;
8
+ }
9
+ /** `inline`: `inputPlaceholder` / `selectPlaceholder` show inside the fields. `above`: same strings render as labels above each control (no inner placeholders). */
10
+ export type ControlGroupSelectCaptionLayout = 'above' | 'inline';
11
+ export interface ControlGroupSelectProps extends ComponentProps<typeof Select>, Pick<ControlGroupProps, 'orientation'> {
12
+ /** Accessible name for the group wrapper (use when there is no visible group heading). */
13
+ ariaLabel?: string;
14
+ amountStep?: number;
15
+ captionLayout?: ControlGroupSelectCaptionLayout;
16
+ className?: string;
17
+ dataTestId?: string;
18
+ disabled?: boolean;
19
+ errorMessage?: string | string[] | Record<string, unknown> | null;
20
+ maxAmount?: number;
21
+ minAmount?: number;
22
+ inputPlaceholder?: string;
23
+ /** When `captionLayout` is `inline`, overrides the input's accessible name (defaults to `inputPlaceholder` when set). */
24
+ inputAriaLabel?: string;
25
+ selectPlaceholder?: string;
26
+ /** When `captionLayout` is `inline` and `selectPlaceholder` is empty, sets the select trigger's accessible name. */
27
+ selectAriaLabel?: string;
28
+ selectOptions: SelectOptionType[];
29
+ state?: FormFieldState;
30
+ type?: 'number' | 'text';
31
+ }
32
+ export declare const ControlGroupSelect: ({ amountStep, ariaLabel, captionLayout, className, dataTestId, disabled, errorMessage, inputAriaLabel, inputPlaceholder, maxAmount, minAmount, orientation, selectAriaLabel, selectOptions, selectPlaceholder, state, type, ...selectProps }: ControlGroupSelectProps) => import("react/jsx-runtime").JSX.Element;
33
+ //# sourceMappingURL=ControlGroupSelect.d.ts.map