@adamosuiteservices/ui 2.15.1 → 2.16.1

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.
@@ -0,0 +1,614 @@
1
+ "use client";
2
+ import { j as v } from "./jsx-runtime-BzflLqGi.js";
3
+ import { B as je } from "./button-B0lWuG-D.js";
4
+ import { C as Re } from "./checkbox-B-Lu1-qJ.js";
5
+ import { I as ee } from "./icon-DKAhvlX_.js";
6
+ import { c as A } from "./index-CRiPKpXj.js";
7
+ import * as l from "react";
8
+ import { useRef as Ae, useState as pe } from "react";
9
+ import { R as Le, P as Ne, O as $e, a as Me } from "./index-BIydBVaH.js";
10
+ import { P as z } from "./index-BMWt1NBG.js";
11
+ import { u as U } from "./index-Cv867SGx.js";
12
+ import { c as te } from "./index-DLcqcWxM.js";
13
+ import { P as Pe, a as De, b as ze } from "./popover-DcQ18EVl.js";
14
+ var he = 1, Fe = 0.9, Oe = 0.8, Ve = 0.17, de = 0.1, ue = 0.999, Ke = 0.9999, Te = 0.99, qe = /[\\\/_+.#"@\[\(\{&]/, _e = /[\\\/_+.#"@\[\(\{&]/g, Be = /[\s-]/, be = /[\s-]/g;
15
+ function se(e, n, r, g, o, m, p) {
16
+ if (m === n.length) return o === e.length ? he : Te;
17
+ var f = `${o},${m}`;
18
+ if (p[f] !== void 0) return p[f];
19
+ for (var y = g.charAt(m), d = r.indexOf(y, o), x = 0, c, S, I, j; d >= 0; ) c = se(e, n, r, g, d + 1, m + 1, p), c > x && (d === o ? c *= he : qe.test(e.charAt(d - 1)) ? (c *= Oe, I = e.slice(o, d - 1).match(_e), I && o > 0 && (c *= Math.pow(ue, I.length))) : Be.test(e.charAt(d - 1)) ? (c *= Fe, j = e.slice(o, d - 1).match(be), j && o > 0 && (c *= Math.pow(ue, j.length))) : (c *= Ve, o > 0 && (c *= Math.pow(ue, d - o))), e.charAt(d) !== n.charAt(m) && (c *= Ke)), (c < de && r.charAt(d - 1) === g.charAt(m + 1) || g.charAt(m + 1) === g.charAt(m) && r.charAt(d - 1) !== g.charAt(m)) && (S = se(e, n, r, g, d + 1, m + 2, p), S * de > c && (c = S * de)), c > x && (x = c), d = r.indexOf(y, d + 1);
20
+ return p[f] = x, x;
21
+ }
22
+ function ve(e) {
23
+ return e.toLowerCase().replace(be, " ");
24
+ }
25
+ function We(e, n, r) {
26
+ return e = r && r.length > 0 ? `${e + " " + r.join(" ")}` : e, se(e, n, ve(e), ve(n), 0, 0, {});
27
+ }
28
+ var Z = '[cmdk-group=""]', ce = '[cmdk-group-items=""]', Ge = '[cmdk-group-heading=""]', xe = '[cmdk-item=""]', ge = `${xe}:not([aria-disabled="true"])`, me = "cmdk-item-select", W = "data-value", Ue = (e, n, r) => We(e, n, r), ye = l.createContext(void 0), re = () => l.useContext(ye), we = l.createContext(void 0), fe = () => l.useContext(we), ke = l.createContext(void 0), Se = l.forwardRef((e, n) => {
29
+ let r = G(() => {
30
+ var t, u;
31
+ 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() } };
32
+ }), g = G(() => /* @__PURE__ */ new Set()), o = G(() => /* @__PURE__ */ new Map()), m = G(() => /* @__PURE__ */ new Map()), p = G(() => /* @__PURE__ */ new Set()), f = Ie(e), { label: y, children: d, value: x, onValueChange: c, filter: S, shouldFilter: I, loop: j, disablePointerSelection: F = !1, vimBindings: R = !0, ...O } = e, $ = U(), J = U(), X = U(), L = l.useRef(null), s = at();
33
+ q(() => {
34
+ if (x !== void 0) {
35
+ let t = x.trim();
36
+ r.current.value = t, E.emit();
37
+ }
38
+ }, [x]), q(() => {
39
+ s(6, Y);
40
+ }, []);
41
+ let E = l.useMemo(() => ({ subscribe: (t) => (p.current.add(t), () => p.current.delete(t)), snapshot: () => r.current, setState: (t, u, b) => {
42
+ var i, a, h, w;
43
+ if (!Object.is(r.current[t], u)) {
44
+ if (r.current[t] = u, t === "search") N(), _(), s(1, V);
45
+ else if (t === "value") {
46
+ if (document.activeElement.hasAttribute("cmdk-input") || document.activeElement.hasAttribute("cmdk-root")) {
47
+ let k = document.getElementById(X);
48
+ k ? k.focus() : (i = document.getElementById($)) == null || i.focus();
49
+ }
50
+ if (s(7, () => {
51
+ var k;
52
+ r.current.selectedItemId = (k = M()) == null ? void 0 : k.id, E.emit();
53
+ }), b || s(5, Y), ((a = f.current) == null ? void 0 : a.value) !== void 0) {
54
+ let k = u ?? "";
55
+ (w = (h = f.current).onValueChange) == null || w.call(h, k);
56
+ return;
57
+ }
58
+ }
59
+ E.emit();
60
+ }
61
+ }, emit: () => {
62
+ p.current.forEach((t) => t());
63
+ } }), []), C = l.useMemo(() => ({ value: (t, u, b) => {
64
+ var i;
65
+ u !== ((i = m.current.get(t)) == null ? void 0 : i.value) && (m.current.set(t, { value: u, keywords: b }), r.current.filtered.items.set(t, ne(u, b)), s(2, () => {
66
+ _(), E.emit();
67
+ }));
68
+ }, item: (t, u) => (g.current.add(t), u && (o.current.has(u) ? o.current.get(u).add(t) : o.current.set(u, /* @__PURE__ */ new Set([t]))), s(3, () => {
69
+ N(), _(), r.current.value || V(), E.emit();
70
+ }), () => {
71
+ m.current.delete(t), g.current.delete(t), r.current.filtered.items.delete(t);
72
+ let b = M();
73
+ s(4, () => {
74
+ N(), b?.getAttribute("id") === t && V(), E.emit();
75
+ });
76
+ }), group: (t) => (o.current.has(t) || o.current.set(t, /* @__PURE__ */ new Set()), () => {
77
+ m.current.delete(t), o.current.delete(t);
78
+ }), filter: () => f.current.shouldFilter, label: y || e["aria-label"], getDisablePointerSelection: () => f.current.disablePointerSelection, listId: $, inputId: X, labelId: J, listInnerRef: L }), []);
79
+ function ne(t, u) {
80
+ var b, i;
81
+ let a = (i = (b = f.current) == null ? void 0 : b.filter) != null ? i : Ue;
82
+ return t ? a(t, r.current.search, u) : 0;
83
+ }
84
+ function _() {
85
+ if (!r.current.search || f.current.shouldFilter === !1) return;
86
+ let t = r.current.filtered.items, u = [];
87
+ r.current.filtered.groups.forEach((i) => {
88
+ let a = o.current.get(i), h = 0;
89
+ a.forEach((w) => {
90
+ let k = t.get(w);
91
+ h = Math.max(k, h);
92
+ }), u.push([i, h]);
93
+ });
94
+ let b = L.current;
95
+ P().sort((i, a) => {
96
+ var h, w;
97
+ let k = i.getAttribute("id"), T = a.getAttribute("id");
98
+ return ((h = t.get(T)) != null ? h : 0) - ((w = t.get(k)) != null ? w : 0);
99
+ }).forEach((i) => {
100
+ let a = i.closest(ce);
101
+ a ? a.appendChild(i.parentElement === a ? i : i.closest(`${ce} > *`)) : b.appendChild(i.parentElement === b ? i : i.closest(`${ce} > *`));
102
+ }), u.sort((i, a) => a[1] - i[1]).forEach((i) => {
103
+ var a;
104
+ let h = (a = L.current) == null ? void 0 : a.querySelector(`${Z}[${W}="${encodeURIComponent(i[0])}"]`);
105
+ h?.parentElement.appendChild(h);
106
+ });
107
+ }
108
+ function V() {
109
+ let t = P().find((b) => b.getAttribute("aria-disabled") !== "true"), u = t?.getAttribute(W);
110
+ E.setState("value", u || void 0);
111
+ }
112
+ function N() {
113
+ var t, u, b, i;
114
+ if (!r.current.search || f.current.shouldFilter === !1) {
115
+ r.current.filtered.count = g.current.size;
116
+ return;
117
+ }
118
+ r.current.filtered.groups = /* @__PURE__ */ new Set();
119
+ let a = 0;
120
+ for (let h of g.current) {
121
+ let w = (u = (t = m.current.get(h)) == null ? void 0 : t.value) != null ? u : "", k = (i = (b = m.current.get(h)) == null ? void 0 : b.keywords) != null ? i : [], T = ne(w, k);
122
+ r.current.filtered.items.set(h, T), T > 0 && a++;
123
+ }
124
+ for (let [h, w] of o.current) for (let k of w) if (r.current.filtered.items.get(k) > 0) {
125
+ r.current.filtered.groups.add(h);
126
+ break;
127
+ }
128
+ r.current.filtered.count = a;
129
+ }
130
+ function Y() {
131
+ var t, u, b;
132
+ let i = M();
133
+ i && (((t = i.parentElement) == null ? void 0 : t.firstChild) === i && ((b = (u = i.closest(Z)) == null ? void 0 : u.querySelector(Ge)) == null || b.scrollIntoView({ block: "nearest" })), i.scrollIntoView({ block: "nearest" }));
134
+ }
135
+ function M() {
136
+ var t;
137
+ return (t = L.current) == null ? void 0 : t.querySelector(`${xe}[aria-selected="true"]`);
138
+ }
139
+ function P() {
140
+ var t;
141
+ return Array.from(((t = L.current) == null ? void 0 : t.querySelectorAll(ge)) || []);
142
+ }
143
+ function B(t) {
144
+ let u = P()[t];
145
+ u && E.setState("value", u.getAttribute(W));
146
+ }
147
+ function K(t) {
148
+ var u;
149
+ let b = M(), i = P(), a = i.findIndex((w) => w === b), h = i[a + t];
150
+ (u = f.current) != null && u.loop && (h = a + t < 0 ? i[i.length - 1] : a + t === i.length ? i[0] : i[a + t]), h && E.setState("value", h.getAttribute(W));
151
+ }
152
+ function ae(t) {
153
+ let u = M(), b = u?.closest(Z), i;
154
+ for (; b && !i; ) b = t > 0 ? rt(b, Z) : nt(b, Z), i = b?.querySelector(ge);
155
+ i ? E.setState("value", i.getAttribute(W)) : K(t);
156
+ }
157
+ let Q = () => B(P().length - 1), le = (t) => {
158
+ t.preventDefault(), t.metaKey ? Q() : t.altKey ? ae(1) : K(1);
159
+ }, ie = (t) => {
160
+ t.preventDefault(), t.metaKey ? B(0) : t.altKey ? ae(-1) : K(-1);
161
+ };
162
+ return l.createElement(z.div, { ref: n, tabIndex: -1, ...O, "cmdk-root": "", onKeyDown: (t) => {
163
+ var u;
164
+ (u = O.onKeyDown) == null || u.call(O, t);
165
+ let b = t.nativeEvent.isComposing || t.keyCode === 229;
166
+ if (!(t.defaultPrevented || b)) switch (t.key) {
167
+ case "n":
168
+ case "j": {
169
+ R && t.ctrlKey && le(t);
170
+ break;
171
+ }
172
+ case "ArrowDown": {
173
+ le(t);
174
+ break;
175
+ }
176
+ case "p":
177
+ case "k": {
178
+ R && t.ctrlKey && ie(t);
179
+ break;
180
+ }
181
+ case "ArrowUp": {
182
+ ie(t);
183
+ break;
184
+ }
185
+ case "Home": {
186
+ t.preventDefault(), B(0);
187
+ break;
188
+ }
189
+ case "End": {
190
+ t.preventDefault(), Q();
191
+ break;
192
+ }
193
+ case "Enter": {
194
+ t.preventDefault();
195
+ let i = M();
196
+ if (i) {
197
+ let a = new Event(me);
198
+ i.dispatchEvent(a);
199
+ }
200
+ }
201
+ }
202
+ } }, l.createElement("label", { "cmdk-label": "", htmlFor: C.inputId, id: C.labelId, style: it }, y), oe(e, (t) => l.createElement(we.Provider, { value: E }, l.createElement(ye.Provider, { value: C }, t))));
203
+ }), He = l.forwardRef((e, n) => {
204
+ var r, g;
205
+ let o = U(), m = l.useRef(null), p = l.useContext(ke), f = re(), y = Ie(e), d = (g = (r = y.current) == null ? void 0 : r.forceMount) != null ? g : p?.forceMount;
206
+ q(() => {
207
+ if (!d) return f.item(o, p?.id);
208
+ }, [d]);
209
+ let x = Ee(o, m, [e.value, e.children, m], e.keywords), c = fe(), S = D((s) => s.value && s.value === x.current), I = D((s) => d || f.filter() === !1 ? !0 : s.search ? s.filtered.items.get(o) > 0 : !0);
210
+ l.useEffect(() => {
211
+ let s = m.current;
212
+ if (!(!s || e.disabled)) return s.addEventListener(me, j), () => s.removeEventListener(me, j);
213
+ }, [I, e.onSelect, e.disabled]);
214
+ function j() {
215
+ var s, E;
216
+ F(), (E = (s = y.current).onSelect) == null || E.call(s, x.current);
217
+ }
218
+ function F() {
219
+ c.setState("value", x.current, !0);
220
+ }
221
+ if (!I) return null;
222
+ let { disabled: R, value: O, onSelect: $, forceMount: J, keywords: X, ...L } = e;
223
+ return l.createElement(z.div, { ref: te(m, n), ...L, id: o, "cmdk-item": "", role: "option", "aria-disabled": !!R, "aria-selected": !!S, "data-disabled": !!R, "data-selected": !!S, onPointerMove: R || f.getDisablePointerSelection() ? void 0 : F, onClick: R ? void 0 : j }, e.children);
224
+ }), Je = l.forwardRef((e, n) => {
225
+ let { heading: r, children: g, forceMount: o, ...m } = e, p = U(), f = l.useRef(null), y = l.useRef(null), d = U(), x = re(), c = D((I) => o || x.filter() === !1 ? !0 : I.search ? I.filtered.groups.has(p) : !0);
226
+ q(() => x.group(p), []), Ee(p, f, [e.value, e.heading, y]);
227
+ let S = l.useMemo(() => ({ id: p, forceMount: o }), [o]);
228
+ return l.createElement(z.div, { ref: te(f, n), ...m, "cmdk-group": "", role: "presentation", hidden: c ? void 0 : !0 }, r && l.createElement("div", { ref: y, "cmdk-group-heading": "", "aria-hidden": !0, id: d }, r), oe(e, (I) => l.createElement("div", { "cmdk-group-items": "", role: "group", "aria-labelledby": r ? d : void 0 }, l.createElement(ke.Provider, { value: S }, I))));
229
+ }), Xe = l.forwardRef((e, n) => {
230
+ let { alwaysRender: r, ...g } = e, o = l.useRef(null), m = D((p) => !p.search);
231
+ return !r && !m ? null : l.createElement(z.div, { ref: te(o, n), ...g, "cmdk-separator": "", role: "separator" });
232
+ }), Ye = l.forwardRef((e, n) => {
233
+ let { onValueChange: r, ...g } = e, o = e.value != null, m = fe(), p = D((d) => d.search), f = D((d) => d.selectedItemId), y = re();
234
+ return l.useEffect(() => {
235
+ e.value != null && m.setState("search", e.value);
236
+ }, [e.value]), l.createElement(z.input, { ref: n, ...g, "cmdk-input": "", autoComplete: "off", autoCorrect: "off", spellCheck: !1, "aria-autocomplete": "list", role: "combobox", "aria-expanded": !0, "aria-controls": y.listId, "aria-labelledby": y.labelId, "aria-activedescendant": f, id: y.inputId, type: "text", value: o ? e.value : p, onChange: (d) => {
237
+ o || m.setState("search", d.target.value), r?.(d.target.value);
238
+ } });
239
+ }), Qe = l.forwardRef((e, n) => {
240
+ let { children: r, label: g = "Suggestions", ...o } = e, m = l.useRef(null), p = l.useRef(null), f = D((d) => d.selectedItemId), y = re();
241
+ return l.useEffect(() => {
242
+ if (p.current && m.current) {
243
+ let d = p.current, x = m.current, c, S = new ResizeObserver(() => {
244
+ c = requestAnimationFrame(() => {
245
+ let I = d.offsetHeight;
246
+ x.style.setProperty("--cmdk-list-height", I.toFixed(1) + "px");
247
+ });
248
+ });
249
+ return S.observe(d), () => {
250
+ cancelAnimationFrame(c), S.unobserve(d);
251
+ };
252
+ }
253
+ }, []), l.createElement(z.div, { ref: te(m, n), ...o, "cmdk-list": "", role: "listbox", tabIndex: -1, "aria-activedescendant": f, "aria-label": g, id: y.listId }, oe(e, (d) => l.createElement("div", { ref: te(p, y.listInnerRef), "cmdk-list-sizer": "" }, d)));
254
+ }), Ze = l.forwardRef((e, n) => {
255
+ let { open: r, onOpenChange: g, overlayClassName: o, contentClassName: m, container: p, ...f } = e;
256
+ return l.createElement(Le, { open: r, onOpenChange: g }, l.createElement(Ne, { container: p }, l.createElement($e, { "cmdk-overlay": "", className: o }), l.createElement(Me, { "aria-label": e.label, "cmdk-dialog": "", className: m }, l.createElement(Se, { ref: n, ...f }))));
257
+ }), et = l.forwardRef((e, n) => D((r) => r.filtered.count === 0) ? l.createElement(z.div, { ref: n, ...e, "cmdk-empty": "", role: "presentation" }) : null), tt = l.forwardRef((e, n) => {
258
+ let { progress: r, children: g, label: o = "Loading...", ...m } = e;
259
+ return l.createElement(z.div, { ref: n, ...m, "cmdk-loading": "", role: "progressbar", "aria-valuenow": r, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": o }, oe(e, (p) => l.createElement("div", { "aria-hidden": !0 }, p)));
260
+ }), H = Object.assign(Se, { List: Qe, Item: He, Input: Ye, Group: Je, Separator: Xe, Dialog: Ze, Empty: et, Loading: tt });
261
+ function rt(e, n) {
262
+ let r = e.nextElementSibling;
263
+ for (; r; ) {
264
+ if (r.matches(n)) return r;
265
+ r = r.nextElementSibling;
266
+ }
267
+ }
268
+ function nt(e, n) {
269
+ let r = e.previousElementSibling;
270
+ for (; r; ) {
271
+ if (r.matches(n)) return r;
272
+ r = r.previousElementSibling;
273
+ }
274
+ }
275
+ function Ie(e) {
276
+ let n = l.useRef(e);
277
+ return q(() => {
278
+ n.current = e;
279
+ }), n;
280
+ }
281
+ var q = typeof window > "u" ? l.useEffect : l.useLayoutEffect;
282
+ function G(e) {
283
+ let n = l.useRef();
284
+ return n.current === void 0 && (n.current = e()), n;
285
+ }
286
+ function D(e) {
287
+ let n = fe(), r = () => e(n.snapshot());
288
+ return l.useSyncExternalStore(n.subscribe, r, r);
289
+ }
290
+ function Ee(e, n, r, g = []) {
291
+ let o = l.useRef(), m = re();
292
+ return q(() => {
293
+ var p;
294
+ let f = (() => {
295
+ var d;
296
+ for (let x of r) {
297
+ if (typeof x == "string") return x.trim();
298
+ if (typeof x == "object" && "current" in x) return x.current ? (d = x.current.textContent) == null ? void 0 : d.trim() : o.current;
299
+ }
300
+ })(), y = g.map((d) => d.trim());
301
+ m.value(e, f, y), (p = n.current) == null || p.setAttribute(W, f), o.current = f;
302
+ }), o;
303
+ }
304
+ var at = () => {
305
+ let [e, n] = l.useState(), r = G(() => /* @__PURE__ */ new Map());
306
+ return q(() => {
307
+ r.current.forEach((g) => g()), r.current = /* @__PURE__ */ new Map();
308
+ }, [e]), (g, o) => {
309
+ r.current.set(g, o), n({});
310
+ };
311
+ };
312
+ function lt(e) {
313
+ let n = e.type;
314
+ return typeof n == "function" ? n(e.props) : "render" in n ? n.render(e.props) : e;
315
+ }
316
+ function oe({ asChild: e, children: n }, r) {
317
+ return e && l.isValidElement(n) ? l.cloneElement(lt(n), { ref: n.ref }, r(n.props.children)) : r(n);
318
+ }
319
+ var it = { position: "absolute", width: "1px", height: "1px", padding: "0", margin: "-1px", overflow: "hidden", clip: "rect(0, 0, 0, 0)", whiteSpace: "nowrap", borderWidth: "0" };
320
+ function ot({
321
+ className: e,
322
+ ...n
323
+ }) {
324
+ return /* @__PURE__ */ v.jsx(
325
+ H,
326
+ {
327
+ "data-slot": "command",
328
+ className: A(
329
+ `
330
+ adm:flex adm:h-full adm:w-full adm:flex-col adm:overflow-hidden
331
+ adm:rounded-md adm:bg-popover adm:text-popover-foreground
332
+ `,
333
+ e
334
+ ),
335
+ ...n
336
+ }
337
+ );
338
+ }
339
+ function dt({
340
+ className: e,
341
+ ...n
342
+ }) {
343
+ return /* @__PURE__ */ v.jsxs(
344
+ "div",
345
+ {
346
+ "data-slot": "command-input-wrapper",
347
+ className: `
348
+ adm:flex adm:h-10 adm:items-center adm:gap-2
349
+ adm:rounded-t-[calc(var(--radius)-1px)] adm:border-b adm:px-3
350
+ adm:*:data-[slot=icon]:shrink-0 adm:*:data-[slot=icon]:text-lg
351
+ adm:*:data-[slot=icon]:opacity-50
352
+ `,
353
+ children: [
354
+ /* @__PURE__ */ v.jsx(ee, { symbol: "search" }),
355
+ /* @__PURE__ */ v.jsx(
356
+ H.Input,
357
+ {
358
+ "data-slot": "command-input",
359
+ className: A(
360
+ `
361
+ adm:flex adm:h-10 adm:w-full adm:rounded-md adm:bg-transparent
362
+ adm:py-3 adm:text-sm adm:outline-hidden
363
+ adm:placeholder:text-muted-foreground
364
+ adm:disabled:cursor-not-allowed adm:disabled:opacity-50
365
+ `,
366
+ e
367
+ ),
368
+ ...n
369
+ }
370
+ )
371
+ ]
372
+ }
373
+ );
374
+ }
375
+ function ut({
376
+ className: e,
377
+ ...n
378
+ }) {
379
+ return /* @__PURE__ */ v.jsx(
380
+ H.List,
381
+ {
382
+ "data-slot": "command-list",
383
+ className: A(
384
+ `
385
+ adm:max-h-[300px] adm:scroll-py-1 adm:overflow-x-hidden
386
+ adm:overflow-y-auto
387
+ `,
388
+ e
389
+ ),
390
+ ...n
391
+ }
392
+ );
393
+ }
394
+ function ct({
395
+ className: e,
396
+ ...n
397
+ }) {
398
+ return /* @__PURE__ */ v.jsx(
399
+ H.Empty,
400
+ {
401
+ "data-slot": "command-empty",
402
+ className: A("adm:py-6 adm:text-center adm:text-sm", e),
403
+ ...n
404
+ }
405
+ );
406
+ }
407
+ function st({
408
+ className: e,
409
+ ...n
410
+ }) {
411
+ return /* @__PURE__ */ v.jsx(
412
+ H.Group,
413
+ {
414
+ "data-slot": "command-group",
415
+ className: A(
416
+ `
417
+ adm:overflow-hidden adm:text-foreground
418
+ adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:px-2
419
+ adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:py-1.5
420
+ adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:text-xs
421
+ adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:font-medium
422
+ adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:text-muted-foreground
423
+ adm:[&_[data-slot=command-item]:last-of-type]:rounded-b-[calc(var(--radius)-1px)]
424
+ adm:[&_[data-slot=command-item]:last-of-type]:border-b-0
425
+ `,
426
+ e
427
+ ),
428
+ ...n
429
+ }
430
+ );
431
+ }
432
+ function mt({
433
+ className: e,
434
+ ...n
435
+ }) {
436
+ return /* @__PURE__ */ v.jsx(
437
+ H.Item,
438
+ {
439
+ "data-slot": "command-item",
440
+ className: A(
441
+ `
442
+ adm:relative adm:flex adm:h-10 adm:cursor-default adm:items-center
443
+ adm:gap-2 adm:border-b adm:px-3 adm:text-sm adm:outline-hidden
444
+ adm:select-none
445
+ adm:data-[disabled=true]:pointer-events-none
446
+ adm:data-[disabled=true]:opacity-50
447
+ adm:data-[selected=true]:bg-accent
448
+ adm:data-[selected=true]:text-accent-foreground
449
+ adm:[&_svg]:pointer-events-none adm:[&_svg]:shrink-0
450
+ adm:[&_svg:not([class*=size-])]:size-4
451
+ adm:[&_svg:not([class*=text-])]:text-muted-foreground
452
+ `,
453
+ e
454
+ ),
455
+ ...n
456
+ }
457
+ );
458
+ }
459
+ function It({
460
+ searchable: e,
461
+ multiple: n,
462
+ icon: r,
463
+ value: g,
464
+ onValueChange: o,
465
+ labels: m,
466
+ options: p,
467
+ classNames: f,
468
+ selectedFeedback: y = "checkbox",
469
+ alwaysShowPlaceholder: d = !1,
470
+ valuePosition: x = "right",
471
+ renders: c,
472
+ ref: S,
473
+ "aria-invalid": I,
474
+ disabled: j,
475
+ searchBy: F = "both",
476
+ filter: R
477
+ }) {
478
+ const O = Ae(null), [$, J] = pe(!1), [X, L] = pe(n ? [] : ""), s = g !== void 0 ? g : X, C = { ...{
479
+ placeholder: "Select options...",
480
+ searchPlaceholder: "Search options...",
481
+ noItemsFound: "No options found.",
482
+ multipleSelected: (a) => `${a} options selected`
483
+ }, ...m }, ne = (a, h, w) => {
484
+ const k = h.toLowerCase().trim(), T = a.toLowerCase().trim();
485
+ return R ? R(a, h, w) : F === "label" && w && w.length > 0 ? w[0].toLowerCase().trim().includes(k) ? 1 : 0 : F === "value" ? T.includes(k) ? 1 : 0 : F === "both" && (w && w.length > 0 && w[0].toLowerCase().trim().includes(k) || T.includes(k)) ? 1 : 0;
486
+ }, _ = (a) => {
487
+ o ? o(a) : L(a);
488
+ }, V = () => n && Array.isArray(s) ? s.length === 0 ? null : s.length === 1 ? p.find((a) => a.value === s[0])?.label : C.multipleSelected?.(s.length) || `${s.length} options selected` : !n && typeof s == "string" && s ? p.find((a) => a.value === s)?.label : null, N = () => n && Array.isArray(s) ? s.length > 0 : typeof s == "string" && s !== "", Y = (a) => n && Array.isArray(s) ? s.includes(a) : s === a, M = (a) => {
489
+ if (n) {
490
+ const h = Array.isArray(s) ? s : [], w = h.includes(a) ? h.filter((k) => k !== a) : [...h, a];
491
+ _(w);
492
+ } else
493
+ _(a === s ? "" : a), J(!1);
494
+ }, P = (a) => {
495
+ const h = Y(a), w = p.find((k) => k.value === a);
496
+ return c?.selectedFeedback ? c.selectedFeedback({
497
+ option: w,
498
+ isSelected: h,
499
+ type: y
500
+ }) : y === "check" ? /* @__PURE__ */ v.jsx(
501
+ "span",
502
+ {
503
+ className: A(`
504
+ adm:absolute adm:right-2 adm:flex adm:size-3.5 adm:items-center
505
+ adm:justify-center
506
+ `, f?.check),
507
+ children: h && /* @__PURE__ */ v.jsx(ee, { symbol: "check", className: "adm:text-lg" })
508
+ }
509
+ ) : /* @__PURE__ */ v.jsx(
510
+ Re,
511
+ {
512
+ checked: h,
513
+ className: f?.checkbox
514
+ }
515
+ );
516
+ }, B = () => c?.placeholder ? c.placeholder({
517
+ text: C.placeholder || "",
518
+ hasValue: N()
519
+ }) : /* @__PURE__ */ v.jsx("span", { className: "adm:opacity-70", children: C.placeholder }), K = () => c?.displayValue ? c.displayValue({
520
+ text: V() ?? null,
521
+ value: s
522
+ }) : /* @__PURE__ */ v.jsx("span", { children: V() }), ae = () => d ? /* @__PURE__ */ v.jsxs("span", { className: "adm:flex adm:items-center adm:gap-2", children: [
523
+ r && /* @__PURE__ */ v.jsx(ee, { symbol: r, className: "adm:opacity-50" }),
524
+ B(),
525
+ N() && x === "left" && K()
526
+ ] }) : /* @__PURE__ */ v.jsxs("span", { className: "adm:flex adm:items-center adm:gap-2", children: [
527
+ r && /* @__PURE__ */ v.jsx(ee, { symbol: r, className: "adm:opacity-50" }),
528
+ N() ? K() : B()
529
+ ] }), Q = () => c?.triggerIcon ? c.triggerIcon({
530
+ open: $
531
+ }) : /* @__PURE__ */ v.jsx(ee, { symbol: "expand_more", className: "adm:opacity-50" }), le = () => d && N() && x === "right" ? /* @__PURE__ */ v.jsxs("span", { className: "adm:flex adm:items-center adm:gap-2", children: [
532
+ K(),
533
+ Q()
534
+ ] }) : /* @__PURE__ */ v.jsx("span", { className: "adm:flex adm:items-center adm:gap-2", children: Q() }), ie = () => c?.trigger ? c.trigger({
535
+ open: $,
536
+ value: s,
537
+ displayText: V() || "",
538
+ placeholder: C.placeholder || "",
539
+ hasValue: N(),
540
+ icon: r
541
+ }) : /* @__PURE__ */ v.jsxs(
542
+ je,
543
+ {
544
+ ref: (a) => {
545
+ O.current = a, S && (typeof S == "function" ? S(a) : S.current = a);
546
+ },
547
+ variant: "outline",
548
+ role: "combobox",
549
+ "aria-expanded": $,
550
+ "aria-invalid": I,
551
+ disabled: j,
552
+ className: A("adm:justify-between adm:rounded-md adm:font-normal", f?.trigger),
553
+ children: [
554
+ ae(),
555
+ le()
556
+ ]
557
+ }
558
+ ), t = () => e ? c?.searchInput ? c.searchInput({
559
+ placeholder: C.searchPlaceholder || ""
560
+ }) : /* @__PURE__ */ v.jsx(
561
+ dt,
562
+ {
563
+ placeholder: C.searchPlaceholder,
564
+ className: f?.input
565
+ }
566
+ ) : null, u = () => c?.empty ? c.empty({
567
+ text: C.noItemsFound || ""
568
+ }) : /* @__PURE__ */ v.jsx(v.Fragment, { children: C.noItemsFound }), b = (a) => c?.optionLabel ? c.optionLabel({
569
+ option: a
570
+ }) : /* @__PURE__ */ v.jsx(v.Fragment, { children: a.label }), i = (a) => c?.option ? /* @__PURE__ */ v.jsx("div", { children: c.option({
571
+ option: a,
572
+ isSelected: Y(a.value),
573
+ selectedFeedback: y
574
+ }) }, a.value) : /* @__PURE__ */ v.jsxs(
575
+ mt,
576
+ {
577
+ value: a.value,
578
+ keywords: [a.label],
579
+ onSelect: M,
580
+ disabled: a.disabled,
581
+ className: A(
582
+ f?.item,
583
+ y === "check" && "adm:pr-10"
584
+ ),
585
+ children: [
586
+ y === "checkbox" && P(a.value),
587
+ b(a),
588
+ y === "check" && P(a.value)
589
+ ]
590
+ },
591
+ a.value
592
+ );
593
+ return /* @__PURE__ */ v.jsxs(Pe, { open: $, onOpenChange: J, children: [
594
+ /* @__PURE__ */ v.jsx(De, { asChild: !0, children: ie() }),
595
+ /* @__PURE__ */ v.jsx(
596
+ ze,
597
+ {
598
+ align: "start",
599
+ className: A("adm:p-0", f?.popover),
600
+ style: { minWidth: O.current?.offsetWidth },
601
+ children: /* @__PURE__ */ v.jsxs(ot, { filter: ne, className: f?.command, children: [
602
+ t(),
603
+ /* @__PURE__ */ v.jsxs(ut, { className: f?.list, children: [
604
+ /* @__PURE__ */ v.jsx(ct, { className: f?.empty, children: u() }),
605
+ /* @__PURE__ */ v.jsx(st, { className: f?.group, children: p.map((a) => i(a)) })
606
+ ] })
607
+ ] })
608
+ }
609
+ )
610
+ ] });
611
+ }
612
+ export {
613
+ It as C
614
+ };
package/dist/combobox.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./combobox-hTCtPMUL.cjs");exports.Combobox=o.Combobox;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./combobox-BalI1GHE.cjs");exports.Combobox=o.Combobox;
package/dist/combobox.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as m } from "./combobox-DGuQtXjP.js";
1
+ import { C as m } from "./combobox-CtSJw4m1.js";
2
2
  export {
3
3
  m as Combobox
4
4
  };
@@ -173,6 +173,10 @@ type ComboboxProps = Readonly<{
173
173
  "aria-invalid"?: "true" | "false" | boolean;
174
174
  /** Standard disabled prop */
175
175
  disabled?: boolean;
176
+ /** Specifies which field(s) to search by: "label" (default), "value", or "both" */
177
+ searchBy?: "label" | "value" | "both";
178
+ /** Custom filter function for advanced search behavior. Receives (value, search, keywords) and should return a number (0 = no match, >0 = match with ranking) */
179
+ filter?: (value: string, search: string, keywords?: string[]) => number;
176
180
  }>;
177
181
  /**
178
182
  * A flexible combobox component with support for single/multiple selection, search, and extensive customization.
@@ -227,5 +231,5 @@ type ComboboxProps = Readonly<{
227
231
  * />
228
232
  * ```
229
233
  */
230
- declare function Combobox({ searchable, multiple, icon, value: controlledValue, onValueChange, labels, options, classNames, selectedFeedback, alwaysShowPlaceholder, valuePosition, renders, ref, "aria-invalid": ariaInvalid, disabled, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
234
+ declare function Combobox({ searchable, multiple, icon, value: controlledValue, onValueChange, labels, options, classNames, selectedFeedback, alwaysShowPlaceholder, valuePosition, renders, ref, "aria-invalid": ariaInvalid, disabled, searchBy, filter: customFilter, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
231
235
  export { Combobox };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./jsx-runtime-BB_1_6y_.cjs"),j=require("./button-DVrteFz9.cjs"),m=require("./calendar-CpUN6BGK.cjs"),q=require("./combobox-hTCtPMUL.cjs"),p=require("./popover-cGp_rNLg.cjs"),o=require("react");function L(c,n,u){return m.addDays(c,-n,u)}function P({dateRange:c,onDateRangeChange:n,labels:u,combobox:R,calendar:v,"aria-invalid":h,disabled:D}){const x=o.useRef(null),d=o.useRef(void 0),[i,s]=o.useState(void 0),[g,r]=o.useState(!1),[l,C]=o.useState(c),t={...{last7Days:"Last 7 days",last30Days:"Last 30 days",last90Days:"Last 90 days",custom:"Custom",placeholder:"Date",cancel:"Cancel",apply:"Apply"},...u},E=e=>{const f=m.startOfDay(new Date),b={"7_days":7,"30_days":30,"90_days":90}[e];return b?{from:L(f,b),to:f}:{from:void 0,to:void 0}},y=e=>{s(d.current),r(!1)},S=e=>{if(e==="custom"){d.current=i,s(e),r(!0);return}s(e),n(E(e))},k=()=>{if(l?.from&&l?.to){n(l),s("custom"),r(!1);return}s(d.current),r(!1)};return a.jsxRuntimeExports.jsxs(a.jsxRuntimeExports.Fragment,{children:[a.jsxRuntimeExports.jsx(q.Combobox,{alwaysShowPlaceholder:!0,selectedFeedback:"check",icon:"calendar_today",options:[{label:t.last7Days,value:"7_days"},{label:t.last30Days,value:"30_days"},{label:t.last90Days,value:"90_days"},{label:t.custom,value:"custom"}],labels:{placeholder:t.placeholder},value:i,onValueChange:S,"aria-invalid":h,disabled:D,ref:e=>{x.current=e},...R}),a.jsxRuntimeExports.jsxs(p.Popover,{open:g,onOpenChange:e=>{!e&&i==="custom"&&y()},children:[a.jsxRuntimeExports.jsx(p.PopoverAnchor,{virtualRef:x}),a.jsxRuntimeExports.jsxs(p.PopoverContent,{align:"start",children:[a.jsxRuntimeExports.jsx(m.Calendar,{required:!0,mode:"range",selected:l,onSelect:C,captionLayout:"dropdown",classNames:{root:"adm:p-0!"},...v}),a.jsxRuntimeExports.jsxs("div",{className:"adm:mt-2 adm:flex adm:justify-end adm:gap-2",children:[a.jsxRuntimeExports.jsx(j.Button,{variant:"link",onClick:()=>y(),children:t.cancel}),a.jsxRuntimeExports.jsx(j.Button,{variant:"link",onClick:k,children:t.apply})]})]})]})]})}exports.DatePickerSelector=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./jsx-runtime-BB_1_6y_.cjs"),j=require("./button-DVrteFz9.cjs"),s=require("./calendar-CpUN6BGK.cjs"),L=require("./combobox-BalI1GHE.cjs"),x=require("./popover-cGp_rNLg.cjs"),l=require("react");function R(c,u,m){return s.addDays(c,-u,m)}function T({dateRange:c,onDateRangeChange:u,labels:m,combobox:h,calendar:D,"aria-invalid":g,disabled:C}){const f=l.useRef(null),p=l.useRef(void 0),E=e=>{if(!e.from||!e.to)return;const r=s.startOfDay(new Date),b=[{value:"7_days",days:7},{value:"30_days",days:30},{value:"90_days",days:90}];for(const n of b){const q=R(r,n.days);if(s.startOfDay(e.from).getTime()===q.getTime()&&s.startOfDay(e.to).getTime()===r.getTime())return n.value}return"custom"},[y,o]=l.useState(()=>E(c)),[_,d]=l.useState(!1),[i,S]=l.useState(c),a={...{last7Days:"Last 7 days",last30Days:"Last 30 days",last90Days:"Last 90 days",custom:"Custom",placeholder:"Date",cancel:"Cancel",apply:"Apply"},...m},k=e=>{const r=s.startOfDay(new Date),n={"7_days":7,"30_days":30,"90_days":90}[e];return n?{from:R(r,n),to:r}:{from:void 0,to:void 0}},v=e=>{o(p.current),d(!1)},O=e=>{if(e==="custom"){p.current=y,o(e),d(!0);return}o(e),u(k(e))},P=()=>{if(i?.from&&i?.to){u(i),o("custom"),d(!1);return}o(p.current),d(!1)};return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(L.Combobox,{alwaysShowPlaceholder:!0,selectedFeedback:"check",icon:"calendar_today",options:[{label:a.last7Days,value:"7_days"},{label:a.last30Days,value:"30_days"},{label:a.last90Days,value:"90_days"},{label:a.custom,value:"custom"}],labels:{placeholder:a.placeholder},value:y,onValueChange:O,"aria-invalid":g,disabled:C,ref:e=>{f.current=e},...h}),t.jsxRuntimeExports.jsxs(x.Popover,{open:_,onOpenChange:e=>{!e&&y==="custom"&&v()},children:[t.jsxRuntimeExports.jsx(x.PopoverAnchor,{virtualRef:f}),t.jsxRuntimeExports.jsxs(x.PopoverContent,{align:"start",children:[t.jsxRuntimeExports.jsx(s.Calendar,{required:!0,mode:"range",selected:i,onSelect:S,captionLayout:"dropdown",classNames:{root:"adm:p-0!"},...D}),t.jsxRuntimeExports.jsxs("div",{className:"adm:mt-2 adm:flex adm:justify-end adm:gap-2",children:[t.jsxRuntimeExports.jsx(j.Button,{variant:"link",onClick:()=>v(),children:a.cancel}),t.jsxRuntimeExports.jsx(j.Button,{variant:"link",onClick:P,children:a.apply})]})]})]})]})}exports.DatePickerSelector=T;