@adamosuiteservices/ui 1.9.14 → 2.9.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/combobox.cjs +9 -9
- package/dist/combobox.js +167 -168
- package/dist/components/ui/combobox/combobox.d.ts +10 -14
- package/dist/icon-DTx6Y_mx.cjs +6 -0
- package/dist/icon-DmU_SEHC.js +36 -0
- package/dist/icon.cjs +1 -6
- package/dist/icon.js +2 -34
- package/dist/icons.css +1 -1
- package/docs/components/ui/combobox.md +6 -6
- package/docs/components/ui/icon.md +50 -12
- package/package.json +1 -1
package/dist/combobox.js
CHANGED
|
@@ -3,122 +3,121 @@ import { B as je } from "./button-B7ZP4LZN.js";
|
|
|
3
3
|
import { C as Ce } from "./checkbox-DhBcmKze.js";
|
|
4
4
|
import { c as M } from "./index-CRiPKpXj.js";
|
|
5
5
|
import * as a from "react";
|
|
6
|
-
import { useRef as
|
|
7
|
-
import { R as
|
|
6
|
+
import { useRef as Re, useState as pe } from "react";
|
|
7
|
+
import { R as Ae, P as Ne, O as $e, a as Me } from "./index-DniCthJA.js";
|
|
8
8
|
import { P as F } from "./index-BMWt1NBG.js";
|
|
9
|
-
import { u as
|
|
9
|
+
import { u as _ } from "./index-Cv867SGx.js";
|
|
10
10
|
import { c as ee } from "./index-DLcqcWxM.js";
|
|
11
|
-
import { c as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { C as Oe } from "./chevron-down-CpVS2Z7w.js";
|
|
11
|
+
import { c as Le } from "./createLucideIcon-B_8CJpcQ.js";
|
|
12
|
+
import { I as oe } from "./icon-DmU_SEHC.js";
|
|
13
|
+
import { P as Pe, a as De, b as Fe } from "./popover-DAwH8jUh.js";
|
|
15
14
|
/**
|
|
16
15
|
* @license lucide-react v0.546.0 - ISC
|
|
17
16
|
*
|
|
18
17
|
* This source code is licensed under the ISC license.
|
|
19
18
|
* See the LICENSE file in the root directory of this source tree.
|
|
20
19
|
*/
|
|
21
|
-
const
|
|
20
|
+
const Oe = [
|
|
22
21
|
["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
|
|
23
22
|
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
|
|
24
|
-
],
|
|
25
|
-
var
|
|
26
|
-
function
|
|
27
|
-
if (c === n.length) return o === e.length ?
|
|
23
|
+
], Ve = Le("search", Oe);
|
|
24
|
+
var he = 1, Ke = 0.9, Te = 0.8, qe = 0.17, de = 0.1, ue = 0.999, ze = 0.9999, Be = 0.99, _e = /[\\\/_+.#"@\[\(\{&]/, We = /[\\\/_+.#"@\[\(\{&]/g, Ge = /[\s-]/, be = /[\s-]/g;
|
|
25
|
+
function se(e, n, r, h, o, c, m) {
|
|
26
|
+
if (c === n.length) return o === e.length ? he : Be;
|
|
28
27
|
var s = `${o},${c}`;
|
|
29
28
|
if (m[s] !== void 0) return m[s];
|
|
30
|
-
for (var
|
|
29
|
+
for (var b = h.charAt(c), i = r.indexOf(b, o), g = 0, u, E, S, R; i >= 0; ) u = se(e, n, r, h, i + 1, c + 1, m), u > g && (i === o ? u *= he : _e.test(e.charAt(i - 1)) ? (u *= Te, S = e.slice(o, i - 1).match(We), S && o > 0 && (u *= Math.pow(ue, S.length))) : Ge.test(e.charAt(i - 1)) ? (u *= Ke, R = e.slice(o, i - 1).match(be), R && o > 0 && (u *= Math.pow(ue, R.length))) : (u *= qe, o > 0 && (u *= Math.pow(ue, i - o))), e.charAt(i) !== n.charAt(c) && (u *= ze)), (u < de && r.charAt(i - 1) === h.charAt(c + 1) || h.charAt(c + 1) === h.charAt(c) && r.charAt(i - 1) !== h.charAt(c)) && (E = se(e, n, r, h, i + 1, c + 2, m), E * de > u && (u = E * de)), u > g && (g = u), i = r.indexOf(b, i + 1);
|
|
31
30
|
return m[s] = g, g;
|
|
32
31
|
}
|
|
33
|
-
function
|
|
34
|
-
return e.toLowerCase().replace(
|
|
32
|
+
function ve(e) {
|
|
33
|
+
return e.toLowerCase().replace(be, " ");
|
|
35
34
|
}
|
|
36
|
-
function
|
|
37
|
-
return e = r && r.length > 0 ? `${e + " " + r.join(" ")}` : e,
|
|
35
|
+
function Ue(e, n, r) {
|
|
36
|
+
return e = r && r.length > 0 ? `${e + " " + r.join(" ")}` : e, se(e, n, ve(e), ve(n), 0, 0, {});
|
|
38
37
|
}
|
|
39
|
-
var Z = '[cmdk-group=""]',
|
|
38
|
+
var Z = '[cmdk-group=""]', ce = '[cmdk-group-items=""]', He = '[cmdk-group-heading=""]', xe = '[cmdk-item=""]', ge = `${xe}:not([aria-disabled="true"])`, me = "cmdk-item-select", z = "data-value", Je = (e, n, r) => Ue(e, n, r), ye = a.createContext(void 0), te = () => a.useContext(ye), ke = a.createContext(void 0), fe = () => a.useContext(ke), we = a.createContext(void 0), Se = a.forwardRef((e, n) => {
|
|
40
39
|
let r = B(() => {
|
|
41
40
|
var t, d;
|
|
42
41
|
return { search: "", value: (d = (t = e.value) != null ? t : e.defaultValue) != null ? d : "", selectedItemId: void 0, filtered: { count: 0, items: /* @__PURE__ */ new Map(), groups: /* @__PURE__ */ new Set() } };
|
|
43
|
-
}), h = B(() => /* @__PURE__ */ new Set()), o = B(() => /* @__PURE__ */ new Map()), c = B(() => /* @__PURE__ */ new Map()), m = B(() => /* @__PURE__ */ new Set()), s =
|
|
44
|
-
|
|
42
|
+
}), h = B(() => /* @__PURE__ */ new Set()), o = B(() => /* @__PURE__ */ new Map()), c = B(() => /* @__PURE__ */ new Map()), m = B(() => /* @__PURE__ */ new Set()), s = Ie(e), { label: b, children: i, value: g, onValueChange: u, filter: E, shouldFilter: S, loop: R, disablePointerSelection: G = !1, vimBindings: L = !0, ...y } = e, re = _(), A = _(), T = _(), N = a.useRef(null), k = ot();
|
|
43
|
+
K(() => {
|
|
45
44
|
if (g !== void 0) {
|
|
46
45
|
let t = g.trim();
|
|
47
|
-
r.current.value = t,
|
|
46
|
+
r.current.value = t, I.emit();
|
|
48
47
|
}
|
|
49
|
-
}, [g]),
|
|
48
|
+
}, [g]), K(() => {
|
|
50
49
|
k(6, X);
|
|
51
50
|
}, []);
|
|
52
|
-
let
|
|
53
|
-
var l,
|
|
51
|
+
let I = a.useMemo(() => ({ subscribe: (t) => (m.current.add(t), () => m.current.delete(t)), snapshot: () => r.current, setState: (t, d, v) => {
|
|
52
|
+
var l, x, w, C;
|
|
54
53
|
if (!Object.is(r.current[t], d)) {
|
|
55
|
-
if (r.current[t] = d, t === "search") J(),
|
|
54
|
+
if (r.current[t] = d, t === "search") J(), q(), k(1, O);
|
|
56
55
|
else if (t === "value") {
|
|
57
56
|
if (document.activeElement.hasAttribute("cmdk-input") || document.activeElement.hasAttribute("cmdk-root")) {
|
|
58
|
-
let
|
|
59
|
-
|
|
57
|
+
let j = document.getElementById(T);
|
|
58
|
+
j ? j.focus() : (l = document.getElementById(re)) == null || l.focus();
|
|
60
59
|
}
|
|
61
60
|
if (k(7, () => {
|
|
62
|
-
var
|
|
63
|
-
r.current.selectedItemId = (
|
|
64
|
-
}), v || k(5, X), ((
|
|
65
|
-
let
|
|
66
|
-
(
|
|
61
|
+
var j;
|
|
62
|
+
r.current.selectedItemId = (j = P()) == null ? void 0 : j.id, I.emit();
|
|
63
|
+
}), v || k(5, X), ((x = s.current) == null ? void 0 : x.value) !== void 0) {
|
|
64
|
+
let j = d ?? "";
|
|
65
|
+
(C = (w = s.current).onValueChange) == null || C.call(w, j);
|
|
67
66
|
return;
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
|
-
|
|
69
|
+
I.emit();
|
|
71
70
|
}
|
|
72
71
|
}, emit: () => {
|
|
73
72
|
m.current.forEach((t) => t());
|
|
74
73
|
} }), []), U = a.useMemo(() => ({ value: (t, d, v) => {
|
|
75
74
|
var l;
|
|
76
75
|
d !== ((l = c.current.get(t)) == null ? void 0 : l.value) && (c.current.set(t, { value: d, keywords: v }), r.current.filtered.items.set(t, H(d, v)), k(2, () => {
|
|
77
|
-
|
|
76
|
+
q(), I.emit();
|
|
78
77
|
}));
|
|
79
78
|
}, item: (t, d) => (h.current.add(t), d && (o.current.has(d) ? o.current.get(d).add(t) : o.current.set(d, /* @__PURE__ */ new Set([t]))), k(3, () => {
|
|
80
|
-
J(),
|
|
79
|
+
J(), q(), r.current.value || O(), I.emit();
|
|
81
80
|
}), () => {
|
|
82
81
|
c.current.delete(t), h.current.delete(t), r.current.filtered.items.delete(t);
|
|
83
|
-
let v =
|
|
82
|
+
let v = P();
|
|
84
83
|
k(4, () => {
|
|
85
|
-
J(), v?.getAttribute("id") === t && O(),
|
|
84
|
+
J(), v?.getAttribute("id") === t && O(), I.emit();
|
|
86
85
|
});
|
|
87
86
|
}), group: (t) => (o.current.has(t) || o.current.set(t, /* @__PURE__ */ new Set()), () => {
|
|
88
87
|
c.current.delete(t), o.current.delete(t);
|
|
89
|
-
}), filter: () => s.current.shouldFilter, label:
|
|
88
|
+
}), filter: () => s.current.shouldFilter, label: b || e["aria-label"], getDisablePointerSelection: () => s.current.disablePointerSelection, listId: re, inputId: T, labelId: A, listInnerRef: N }), []);
|
|
90
89
|
function H(t, d) {
|
|
91
90
|
var v, l;
|
|
92
|
-
let
|
|
93
|
-
return t ?
|
|
91
|
+
let x = (l = (v = s.current) == null ? void 0 : v.filter) != null ? l : Je;
|
|
92
|
+
return t ? x(t, r.current.search, d) : 0;
|
|
94
93
|
}
|
|
95
|
-
function
|
|
94
|
+
function q() {
|
|
96
95
|
if (!r.current.search || s.current.shouldFilter === !1) return;
|
|
97
96
|
let t = r.current.filtered.items, d = [];
|
|
98
97
|
r.current.filtered.groups.forEach((l) => {
|
|
99
|
-
let
|
|
100
|
-
|
|
101
|
-
let
|
|
102
|
-
w = Math.max(
|
|
98
|
+
let x = o.current.get(l), w = 0;
|
|
99
|
+
x.forEach((C) => {
|
|
100
|
+
let j = t.get(C);
|
|
101
|
+
w = Math.max(j, w);
|
|
103
102
|
}), d.push([l, w]);
|
|
104
103
|
});
|
|
105
104
|
let v = N.current;
|
|
106
|
-
V().sort((l,
|
|
107
|
-
var w,
|
|
108
|
-
let
|
|
109
|
-
return ((w = t.get(le)) != null ? w : 0) - ((
|
|
105
|
+
V().sort((l, x) => {
|
|
106
|
+
var w, C;
|
|
107
|
+
let j = l.getAttribute("id"), le = x.getAttribute("id");
|
|
108
|
+
return ((w = t.get(le)) != null ? w : 0) - ((C = t.get(j)) != null ? C : 0);
|
|
110
109
|
}).forEach((l) => {
|
|
111
|
-
let
|
|
112
|
-
|
|
113
|
-
}), d.sort((l,
|
|
114
|
-
var
|
|
115
|
-
let w = (
|
|
110
|
+
let x = l.closest(ce);
|
|
111
|
+
x ? x.appendChild(l.parentElement === x ? l : l.closest(`${ce} > *`)) : v.appendChild(l.parentElement === v ? l : l.closest(`${ce} > *`));
|
|
112
|
+
}), d.sort((l, x) => x[1] - l[1]).forEach((l) => {
|
|
113
|
+
var x;
|
|
114
|
+
let w = (x = N.current) == null ? void 0 : x.querySelector(`${Z}[${z}="${encodeURIComponent(l[0])}"]`);
|
|
116
115
|
w?.parentElement.appendChild(w);
|
|
117
116
|
});
|
|
118
117
|
}
|
|
119
118
|
function O() {
|
|
120
|
-
let t = V().find((v) => v.getAttribute("aria-disabled") !== "true"), d = t?.getAttribute(
|
|
121
|
-
|
|
119
|
+
let t = V().find((v) => v.getAttribute("aria-disabled") !== "true"), d = t?.getAttribute(z);
|
|
120
|
+
I.setState("value", d || void 0);
|
|
122
121
|
}
|
|
123
122
|
function J() {
|
|
124
123
|
var t, d, v, l;
|
|
@@ -127,43 +126,43 @@ var Z = '[cmdk-group=""]', ue = '[cmdk-group-items=""]', Je = '[cmdk-group-headi
|
|
|
127
126
|
return;
|
|
128
127
|
}
|
|
129
128
|
r.current.filtered.groups = /* @__PURE__ */ new Set();
|
|
130
|
-
let
|
|
129
|
+
let x = 0;
|
|
131
130
|
for (let w of h.current) {
|
|
132
|
-
let
|
|
133
|
-
r.current.filtered.items.set(w, le), le > 0 &&
|
|
131
|
+
let C = (d = (t = c.current.get(w)) == null ? void 0 : t.value) != null ? d : "", j = (l = (v = c.current.get(w)) == null ? void 0 : v.keywords) != null ? l : [], le = H(C, j);
|
|
132
|
+
r.current.filtered.items.set(w, le), le > 0 && x++;
|
|
134
133
|
}
|
|
135
|
-
for (let [w,
|
|
134
|
+
for (let [w, C] of o.current) for (let j of C) if (r.current.filtered.items.get(j) > 0) {
|
|
136
135
|
r.current.filtered.groups.add(w);
|
|
137
136
|
break;
|
|
138
137
|
}
|
|
139
|
-
r.current.filtered.count =
|
|
138
|
+
r.current.filtered.count = x;
|
|
140
139
|
}
|
|
141
140
|
function X() {
|
|
142
141
|
var t, d, v;
|
|
143
|
-
let l =
|
|
144
|
-
l && (((t = l.parentElement) == null ? void 0 : t.firstChild) === l && ((v = (d = l.closest(Z)) == null ? void 0 : d.querySelector(
|
|
142
|
+
let l = P();
|
|
143
|
+
l && (((t = l.parentElement) == null ? void 0 : t.firstChild) === l && ((v = (d = l.closest(Z)) == null ? void 0 : d.querySelector(He)) == null || v.scrollIntoView({ block: "nearest" })), l.scrollIntoView({ block: "nearest" }));
|
|
145
144
|
}
|
|
146
|
-
function
|
|
145
|
+
function P() {
|
|
147
146
|
var t;
|
|
148
147
|
return (t = N.current) == null ? void 0 : t.querySelector(`${xe}[aria-selected="true"]`);
|
|
149
148
|
}
|
|
150
149
|
function V() {
|
|
151
150
|
var t;
|
|
152
|
-
return Array.from(((t = N.current) == null ? void 0 : t.querySelectorAll(
|
|
151
|
+
return Array.from(((t = N.current) == null ? void 0 : t.querySelectorAll(ge)) || []);
|
|
153
152
|
}
|
|
154
153
|
function Y(t) {
|
|
155
154
|
let d = V()[t];
|
|
156
|
-
d &&
|
|
155
|
+
d && I.setState("value", d.getAttribute(z));
|
|
157
156
|
}
|
|
158
157
|
function Q(t) {
|
|
159
158
|
var d;
|
|
160
|
-
let v =
|
|
161
|
-
(d = s.current) != null && d.loop && (w =
|
|
159
|
+
let v = P(), l = V(), x = l.findIndex((C) => C === v), w = l[x + t];
|
|
160
|
+
(d = s.current) != null && d.loop && (w = x + t < 0 ? l[l.length - 1] : x + t === l.length ? l[0] : l[x + t]), w && I.setState("value", w.getAttribute(z));
|
|
162
161
|
}
|
|
163
162
|
function ne(t) {
|
|
164
|
-
let d =
|
|
165
|
-
for (; v && !l; ) v = t > 0 ?
|
|
166
|
-
l ?
|
|
163
|
+
let d = P(), v = d?.closest(Z), l;
|
|
164
|
+
for (; v && !l; ) v = t > 0 ? at(v, Z) : lt(v, Z), l = v?.querySelector(ge);
|
|
165
|
+
l ? I.setState("value", l.getAttribute(z)) : Q(t);
|
|
167
166
|
}
|
|
168
167
|
let ae = () => Y(V().length - 1), f = (t) => {
|
|
169
168
|
t.preventDefault(), t.metaKey ? ae() : t.altKey ? ne(1) : Q(1);
|
|
@@ -203,104 +202,104 @@ var Z = '[cmdk-group=""]', ue = '[cmdk-group-items=""]', Je = '[cmdk-group-headi
|
|
|
203
202
|
}
|
|
204
203
|
case "Enter": {
|
|
205
204
|
t.preventDefault();
|
|
206
|
-
let l =
|
|
205
|
+
let l = P();
|
|
207
206
|
if (l) {
|
|
208
|
-
let
|
|
209
|
-
l.dispatchEvent(
|
|
207
|
+
let x = new Event(me);
|
|
208
|
+
l.dispatchEvent(x);
|
|
210
209
|
}
|
|
211
210
|
}
|
|
212
211
|
}
|
|
213
|
-
} }, a.createElement("label", { "cmdk-label": "", htmlFor: U.inputId, id: U.labelId, style:
|
|
214
|
-
}),
|
|
212
|
+
} }, a.createElement("label", { "cmdk-label": "", htmlFor: U.inputId, id: U.labelId, style: dt }, b), ie(e, (t) => a.createElement(ke.Provider, { value: I }, a.createElement(ye.Provider, { value: U }, t))));
|
|
213
|
+
}), Xe = a.forwardRef((e, n) => {
|
|
215
214
|
var r, h;
|
|
216
|
-
let o =
|
|
217
|
-
|
|
215
|
+
let o = _(), c = a.useRef(null), m = a.useContext(we), s = te(), b = Ie(e), i = (h = (r = b.current) == null ? void 0 : r.forceMount) != null ? h : m?.forceMount;
|
|
216
|
+
K(() => {
|
|
218
217
|
if (!i) return s.item(o, m?.id);
|
|
219
218
|
}, [i]);
|
|
220
|
-
let g = Ee(o, c, [e.value, e.children, c], e.keywords), u =
|
|
219
|
+
let g = Ee(o, c, [e.value, e.children, c], e.keywords), u = fe(), E = D((k) => k.value && k.value === g.current), S = D((k) => i || s.filter() === !1 ? !0 : k.search ? k.filtered.items.get(o) > 0 : !0);
|
|
221
220
|
a.useEffect(() => {
|
|
222
221
|
let k = c.current;
|
|
223
|
-
if (!(!k || e.disabled)) return k.addEventListener(
|
|
222
|
+
if (!(!k || e.disabled)) return k.addEventListener(me, R), () => k.removeEventListener(me, R);
|
|
224
223
|
}, [S, e.onSelect, e.disabled]);
|
|
225
224
|
function R() {
|
|
226
|
-
var k,
|
|
227
|
-
G(), (
|
|
225
|
+
var k, I;
|
|
226
|
+
G(), (I = (k = b.current).onSelect) == null || I.call(k, g.current);
|
|
228
227
|
}
|
|
229
228
|
function G() {
|
|
230
229
|
u.setState("value", g.current, !0);
|
|
231
230
|
}
|
|
232
231
|
if (!S) return null;
|
|
233
|
-
let { disabled: L, value: y, onSelect: re, forceMount: A, keywords:
|
|
234
|
-
return a.createElement(F.div, { ref: ee(c, n), ...N, id: o, "cmdk-item": "", role: "option", "aria-disabled": !!L, "aria-selected": !!
|
|
232
|
+
let { disabled: L, value: y, onSelect: re, forceMount: A, keywords: T, ...N } = e;
|
|
233
|
+
return a.createElement(F.div, { ref: ee(c, n), ...N, id: o, "cmdk-item": "", role: "option", "aria-disabled": !!L, "aria-selected": !!E, "data-disabled": !!L, "data-selected": !!E, onPointerMove: L || s.getDisablePointerSelection() ? void 0 : G, onClick: L ? void 0 : R }, e.children);
|
|
234
|
+
}), Ye = a.forwardRef((e, n) => {
|
|
235
|
+
let { heading: r, children: h, forceMount: o, ...c } = e, m = _(), s = a.useRef(null), b = a.useRef(null), i = _(), g = te(), u = D((S) => o || g.filter() === !1 ? !0 : S.search ? S.filtered.groups.has(m) : !0);
|
|
236
|
+
K(() => g.group(m), []), Ee(m, s, [e.value, e.heading, b]);
|
|
237
|
+
let E = a.useMemo(() => ({ id: m, forceMount: o }), [o]);
|
|
238
|
+
return a.createElement(F.div, { ref: ee(s, n), ...c, "cmdk-group": "", role: "presentation", hidden: u ? void 0 : !0 }, r && a.createElement("div", { ref: b, "cmdk-group-heading": "", "aria-hidden": !0, id: i }, r), ie(e, (S) => a.createElement("div", { "cmdk-group-items": "", role: "group", "aria-labelledby": r ? i : void 0 }, a.createElement(we.Provider, { value: E }, S))));
|
|
235
239
|
}), Qe = a.forwardRef((e, n) => {
|
|
236
|
-
let {
|
|
237
|
-
z(() => g.group(m), []), Ee(m, s, [e.value, e.heading, x]);
|
|
238
|
-
let j = a.useMemo(() => ({ id: m, forceMount: o }), [o]);
|
|
239
|
-
return a.createElement(F.div, { ref: ee(s, n), ...c, "cmdk-group": "", role: "presentation", hidden: u ? void 0 : !0 }, r && a.createElement("div", { ref: x, "cmdk-group-heading": "", "aria-hidden": !0, id: i }, r), oe(e, (S) => a.createElement("div", { "cmdk-group-items": "", role: "group", "aria-labelledby": r ? i : void 0 }, a.createElement(ke.Provider, { value: j }, S))));
|
|
240
|
-
}), Ze = a.forwardRef((e, n) => {
|
|
241
|
-
let { alwaysRender: r, ...h } = e, o = a.useRef(null), c = P((m) => !m.search);
|
|
240
|
+
let { alwaysRender: r, ...h } = e, o = a.useRef(null), c = D((m) => !m.search);
|
|
242
241
|
return !r && !c ? null : a.createElement(F.div, { ref: ee(o, n), ...h, "cmdk-separator": "", role: "separator" });
|
|
243
|
-
}),
|
|
244
|
-
let { onValueChange: r, ...h } = e, o = e.value != null, c =
|
|
242
|
+
}), Ze = a.forwardRef((e, n) => {
|
|
243
|
+
let { onValueChange: r, ...h } = e, o = e.value != null, c = fe(), m = D((i) => i.search), s = D((i) => i.selectedItemId), b = te();
|
|
245
244
|
return a.useEffect(() => {
|
|
246
245
|
e.value != null && c.setState("search", e.value);
|
|
247
|
-
}, [e.value]), a.createElement(F.input, { ref: n, ...h, "cmdk-input": "", autoComplete: "off", autoCorrect: "off", spellCheck: !1, "aria-autocomplete": "list", role: "combobox", "aria-expanded": !0, "aria-controls":
|
|
246
|
+
}, [e.value]), a.createElement(F.input, { ref: n, ...h, "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": s, id: b.inputId, type: "text", value: o ? e.value : m, onChange: (i) => {
|
|
248
247
|
o || c.setState("search", i.target.value), r?.(i.target.value);
|
|
249
248
|
} });
|
|
250
|
-
}),
|
|
251
|
-
let { children: r, label: h = "Suggestions", ...o } = e, c = a.useRef(null), m = a.useRef(null), s =
|
|
249
|
+
}), et = a.forwardRef((e, n) => {
|
|
250
|
+
let { children: r, label: h = "Suggestions", ...o } = e, c = a.useRef(null), m = a.useRef(null), s = D((i) => i.selectedItemId), b = te();
|
|
252
251
|
return a.useEffect(() => {
|
|
253
252
|
if (m.current && c.current) {
|
|
254
|
-
let i = m.current, g = c.current, u,
|
|
253
|
+
let i = m.current, g = c.current, u, E = new ResizeObserver(() => {
|
|
255
254
|
u = requestAnimationFrame(() => {
|
|
256
255
|
let S = i.offsetHeight;
|
|
257
256
|
g.style.setProperty("--cmdk-list-height", S.toFixed(1) + "px");
|
|
258
257
|
});
|
|
259
258
|
});
|
|
260
|
-
return
|
|
261
|
-
cancelAnimationFrame(u),
|
|
259
|
+
return E.observe(i), () => {
|
|
260
|
+
cancelAnimationFrame(u), E.unobserve(i);
|
|
262
261
|
};
|
|
263
262
|
}
|
|
264
|
-
}, []), a.createElement(F.div, { ref: ee(c, n), ...o, "cmdk-list": "", role: "listbox", tabIndex: -1, "aria-activedescendant": s, "aria-label": h, id:
|
|
265
|
-
}),
|
|
263
|
+
}, []), a.createElement(F.div, { ref: ee(c, n), ...o, "cmdk-list": "", role: "listbox", tabIndex: -1, "aria-activedescendant": s, "aria-label": h, id: b.listId }, ie(e, (i) => a.createElement("div", { ref: ee(m, b.listInnerRef), "cmdk-list-sizer": "" }, i)));
|
|
264
|
+
}), tt = a.forwardRef((e, n) => {
|
|
266
265
|
let { open: r, onOpenChange: h, overlayClassName: o, contentClassName: c, container: m, ...s } = e;
|
|
267
|
-
return a.createElement(
|
|
268
|
-
}),
|
|
266
|
+
return a.createElement(Ae, { open: r, onOpenChange: h }, a.createElement(Ne, { container: m }, a.createElement($e, { "cmdk-overlay": "", className: o }), a.createElement(Me, { "aria-label": e.label, "cmdk-dialog": "", className: c }, a.createElement(Se, { ref: n, ...s }))));
|
|
267
|
+
}), rt = a.forwardRef((e, n) => D((r) => r.filtered.count === 0) ? a.createElement(F.div, { ref: n, ...e, "cmdk-empty": "", role: "presentation" }) : null), nt = a.forwardRef((e, n) => {
|
|
269
268
|
let { progress: r, children: h, label: o = "Loading...", ...c } = e;
|
|
270
|
-
return a.createElement(F.div, { ref: n, ...c, "cmdk-loading": "", role: "progressbar", "aria-valuenow": r, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": o },
|
|
271
|
-
}),
|
|
272
|
-
function
|
|
269
|
+
return a.createElement(F.div, { ref: n, ...c, "cmdk-loading": "", role: "progressbar", "aria-valuenow": r, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": o }, ie(e, (m) => a.createElement("div", { "aria-hidden": !0 }, m)));
|
|
270
|
+
}), W = Object.assign(Se, { List: et, Item: Xe, Input: Ze, Group: Ye, Separator: Qe, Dialog: tt, Empty: rt, Loading: nt });
|
|
271
|
+
function at(e, n) {
|
|
273
272
|
let r = e.nextElementSibling;
|
|
274
273
|
for (; r; ) {
|
|
275
274
|
if (r.matches(n)) return r;
|
|
276
275
|
r = r.nextElementSibling;
|
|
277
276
|
}
|
|
278
277
|
}
|
|
279
|
-
function
|
|
278
|
+
function lt(e, n) {
|
|
280
279
|
let r = e.previousElementSibling;
|
|
281
280
|
for (; r; ) {
|
|
282
281
|
if (r.matches(n)) return r;
|
|
283
282
|
r = r.previousElementSibling;
|
|
284
283
|
}
|
|
285
284
|
}
|
|
286
|
-
function
|
|
285
|
+
function Ie(e) {
|
|
287
286
|
let n = a.useRef(e);
|
|
288
|
-
return
|
|
287
|
+
return K(() => {
|
|
289
288
|
n.current = e;
|
|
290
289
|
}), n;
|
|
291
290
|
}
|
|
292
|
-
var
|
|
291
|
+
var K = typeof window > "u" ? a.useEffect : a.useLayoutEffect;
|
|
293
292
|
function B(e) {
|
|
294
293
|
let n = a.useRef();
|
|
295
294
|
return n.current === void 0 && (n.current = e()), n;
|
|
296
295
|
}
|
|
297
|
-
function
|
|
298
|
-
let n =
|
|
296
|
+
function D(e) {
|
|
297
|
+
let n = fe(), r = () => e(n.snapshot());
|
|
299
298
|
return a.useSyncExternalStore(n.subscribe, r, r);
|
|
300
299
|
}
|
|
301
300
|
function Ee(e, n, r, h = []) {
|
|
302
301
|
let o = a.useRef(), c = te();
|
|
303
|
-
return
|
|
302
|
+
return K(() => {
|
|
304
303
|
var m;
|
|
305
304
|
let s = (() => {
|
|
306
305
|
var i;
|
|
@@ -308,32 +307,32 @@ function Ee(e, n, r, h = []) {
|
|
|
308
307
|
if (typeof g == "string") return g.trim();
|
|
309
308
|
if (typeof g == "object" && "current" in g) return g.current ? (i = g.current.textContent) == null ? void 0 : i.trim() : o.current;
|
|
310
309
|
}
|
|
311
|
-
})(),
|
|
312
|
-
c.value(e, s,
|
|
310
|
+
})(), b = h.map((i) => i.trim());
|
|
311
|
+
c.value(e, s, b), (m = n.current) == null || m.setAttribute(z, s), o.current = s;
|
|
313
312
|
}), o;
|
|
314
313
|
}
|
|
315
|
-
var
|
|
314
|
+
var ot = () => {
|
|
316
315
|
let [e, n] = a.useState(), r = B(() => /* @__PURE__ */ new Map());
|
|
317
|
-
return
|
|
316
|
+
return K(() => {
|
|
318
317
|
r.current.forEach((h) => h()), r.current = /* @__PURE__ */ new Map();
|
|
319
318
|
}, [e]), (h, o) => {
|
|
320
319
|
r.current.set(h, o), n({});
|
|
321
320
|
};
|
|
322
321
|
};
|
|
323
|
-
function
|
|
322
|
+
function it(e) {
|
|
324
323
|
let n = e.type;
|
|
325
324
|
return typeof n == "function" ? n(e.props) : "render" in n ? n.render(e.props) : e;
|
|
326
325
|
}
|
|
327
|
-
function
|
|
328
|
-
return e && a.isValidElement(n) ? a.cloneElement(
|
|
326
|
+
function ie({ asChild: e, children: n }, r) {
|
|
327
|
+
return e && a.isValidElement(n) ? a.cloneElement(it(n), { ref: n.ref }, r(n.props.children)) : r(n);
|
|
329
328
|
}
|
|
330
|
-
var
|
|
331
|
-
function
|
|
329
|
+
var dt = { position: "absolute", width: "1px", height: "1px", padding: "0", margin: "-1px", overflow: "hidden", clip: "rect(0, 0, 0, 0)", whiteSpace: "nowrap", borderWidth: "0" };
|
|
330
|
+
function ut({
|
|
332
331
|
className: e,
|
|
333
332
|
...n
|
|
334
333
|
}) {
|
|
335
334
|
return /* @__PURE__ */ p.jsx(
|
|
336
|
-
|
|
335
|
+
W,
|
|
337
336
|
{
|
|
338
337
|
"data-slot": "command",
|
|
339
338
|
className: M(
|
|
@@ -347,7 +346,7 @@ function ct({
|
|
|
347
346
|
}
|
|
348
347
|
);
|
|
349
348
|
}
|
|
350
|
-
function
|
|
349
|
+
function ct({
|
|
351
350
|
className: e,
|
|
352
351
|
...n
|
|
353
352
|
}) {
|
|
@@ -359,9 +358,9 @@ function st({
|
|
|
359
358
|
adm:flex adm:h-9 adm:items-center adm:gap-2 adm:border-b adm:px-3
|
|
360
359
|
`,
|
|
361
360
|
children: [
|
|
362
|
-
/* @__PURE__ */ p.jsx(
|
|
361
|
+
/* @__PURE__ */ p.jsx(Ve, { className: "adm:size-4 adm:shrink-0 adm:opacity-50" }),
|
|
363
362
|
/* @__PURE__ */ p.jsx(
|
|
364
|
-
|
|
363
|
+
W.Input,
|
|
365
364
|
{
|
|
366
365
|
"data-slot": "command-input",
|
|
367
366
|
className: M(
|
|
@@ -380,12 +379,12 @@ function st({
|
|
|
380
379
|
}
|
|
381
380
|
);
|
|
382
381
|
}
|
|
383
|
-
function
|
|
382
|
+
function st({
|
|
384
383
|
className: e,
|
|
385
384
|
...n
|
|
386
385
|
}) {
|
|
387
386
|
return /* @__PURE__ */ p.jsx(
|
|
388
|
-
|
|
387
|
+
W.List,
|
|
389
388
|
{
|
|
390
389
|
"data-slot": "command-list",
|
|
391
390
|
className: M(
|
|
@@ -399,12 +398,12 @@ function mt({
|
|
|
399
398
|
}
|
|
400
399
|
);
|
|
401
400
|
}
|
|
402
|
-
function
|
|
401
|
+
function mt({
|
|
403
402
|
className: e,
|
|
404
403
|
...n
|
|
405
404
|
}) {
|
|
406
405
|
return /* @__PURE__ */ p.jsx(
|
|
407
|
-
|
|
406
|
+
W.Empty,
|
|
408
407
|
{
|
|
409
408
|
"data-slot": "command-empty",
|
|
410
409
|
className: M("adm:py-6 adm:text-center adm:text-sm", e),
|
|
@@ -412,12 +411,12 @@ function ft({
|
|
|
412
411
|
}
|
|
413
412
|
);
|
|
414
413
|
}
|
|
415
|
-
function
|
|
414
|
+
function ft({
|
|
416
415
|
className: e,
|
|
417
416
|
...n
|
|
418
417
|
}) {
|
|
419
418
|
return /* @__PURE__ */ p.jsx(
|
|
420
|
-
|
|
419
|
+
W.Group,
|
|
421
420
|
{
|
|
422
421
|
"data-slot": "command-group",
|
|
423
422
|
className: M(
|
|
@@ -435,12 +434,12 @@ function pt({
|
|
|
435
434
|
}
|
|
436
435
|
);
|
|
437
436
|
}
|
|
438
|
-
function
|
|
437
|
+
function pt({
|
|
439
438
|
className: e,
|
|
440
439
|
...n
|
|
441
440
|
}) {
|
|
442
441
|
return /* @__PURE__ */ p.jsx(
|
|
443
|
-
|
|
442
|
+
W.Item,
|
|
444
443
|
{
|
|
445
444
|
"data-slot": "command-item",
|
|
446
445
|
className: M(
|
|
@@ -462,7 +461,7 @@ function ht({
|
|
|
462
461
|
}
|
|
463
462
|
);
|
|
464
463
|
}
|
|
465
|
-
function
|
|
464
|
+
function Ct({
|
|
466
465
|
searchable: e,
|
|
467
466
|
multiple: n,
|
|
468
467
|
icon: r,
|
|
@@ -471,38 +470,38 @@ function At({
|
|
|
471
470
|
labels: c,
|
|
472
471
|
options: m,
|
|
473
472
|
classNames: s,
|
|
474
|
-
selectedFeedback:
|
|
473
|
+
selectedFeedback: b = "checkbox",
|
|
475
474
|
alwaysShowPlaceholder: i = !1,
|
|
476
475
|
valuePosition: g = "right",
|
|
477
476
|
renders: u
|
|
478
477
|
}) {
|
|
479
|
-
const
|
|
478
|
+
const E = Re(null), [S, R] = pe(!1), [G, L] = pe(n ? [] : ""), y = h !== void 0 ? h : G, A = { ...{
|
|
480
479
|
placeholder: "Select options...",
|
|
481
480
|
searchPlaceholder: "Search options...",
|
|
482
481
|
noItemsFound: "No options found.",
|
|
483
482
|
multipleSelected: (f) => `${f} options selected`
|
|
484
|
-
}, ...c },
|
|
483
|
+
}, ...c }, T = (f) => {
|
|
485
484
|
o ? o(f) : L(f);
|
|
486
|
-
}, N = () => n && Array.isArray(y) ? y.length === 0 ? null : y.length === 1 ? m.find((f) => f.value === y[0])?.label : A.multipleSelected?.(y.length) || `${y.length} options selected` : !n && typeof y == "string" && y ? m.find((f) => f.value === y)?.label : null, k = () => n && Array.isArray(y) ? y.length > 0 : typeof y == "string" && y !== "",
|
|
485
|
+
}, N = () => n && Array.isArray(y) ? y.length === 0 ? null : y.length === 1 ? m.find((f) => f.value === y[0])?.label : A.multipleSelected?.(y.length) || `${y.length} options selected` : !n && typeof y == "string" && y ? m.find((f) => f.value === y)?.label : null, k = () => n && Array.isArray(y) ? y.length > 0 : typeof y == "string" && y !== "", I = (f) => n && Array.isArray(y) ? y.includes(f) : y === f, U = (f) => {
|
|
487
486
|
if (n) {
|
|
488
487
|
const $ = Array.isArray(y) ? y : [], t = $.includes(f) ? $.filter((d) => d !== f) : [...$, f];
|
|
489
|
-
|
|
488
|
+
T(t);
|
|
490
489
|
} else
|
|
491
|
-
|
|
490
|
+
T(f === y ? "" : f), R(!1);
|
|
492
491
|
}, H = (f) => {
|
|
493
|
-
const $ =
|
|
492
|
+
const $ = I(f), t = m.find((d) => d.value === f);
|
|
494
493
|
return u?.selectedFeedback ? u.selectedFeedback({
|
|
495
494
|
option: t,
|
|
496
495
|
isSelected: $,
|
|
497
|
-
type:
|
|
498
|
-
}) :
|
|
496
|
+
type: b
|
|
497
|
+
}) : b === "check" ? /* @__PURE__ */ p.jsx(
|
|
499
498
|
"span",
|
|
500
499
|
{
|
|
501
500
|
className: M(`
|
|
502
501
|
adm:absolute adm:right-2 adm:flex adm:size-3.5 adm:items-center
|
|
503
502
|
adm:justify-center
|
|
504
503
|
`, s?.check),
|
|
505
|
-
children: $ && /* @__PURE__ */ p.jsx(
|
|
504
|
+
children: $ && /* @__PURE__ */ p.jsx(oe, { symbol: "check" })
|
|
506
505
|
}
|
|
507
506
|
) : /* @__PURE__ */ p.jsx(
|
|
508
507
|
Ce,
|
|
@@ -511,48 +510,48 @@ function At({
|
|
|
511
510
|
className: s?.checkbox
|
|
512
511
|
}
|
|
513
512
|
);
|
|
514
|
-
},
|
|
513
|
+
}, q = () => u?.placeholder ? u.placeholder({
|
|
515
514
|
text: A.placeholder || "",
|
|
516
515
|
hasValue: k()
|
|
517
516
|
}) : /* @__PURE__ */ p.jsx("span", { className: "adm:opacity-70", children: A.placeholder }), O = () => u?.displayValue ? u.displayValue({
|
|
518
517
|
text: N() ?? null,
|
|
519
518
|
value: y
|
|
520
519
|
}) : /* @__PURE__ */ p.jsx("span", { children: N() }), J = () => i ? /* @__PURE__ */ p.jsxs("span", { className: "adm:flex adm:items-center adm:gap-2", children: [
|
|
521
|
-
r && /* @__PURE__ */ p.jsx(
|
|
522
|
-
|
|
520
|
+
r && /* @__PURE__ */ p.jsx(oe, { symbol: r, className: "adm:opacity-50" }),
|
|
521
|
+
q(),
|
|
523
522
|
k() && g === "left" && O()
|
|
524
523
|
] }) : /* @__PURE__ */ p.jsxs("span", { className: "adm:flex adm:items-center adm:gap-2", children: [
|
|
525
|
-
r && /* @__PURE__ */ p.jsx(
|
|
526
|
-
k() ? O() :
|
|
524
|
+
r && /* @__PURE__ */ p.jsx(oe, { symbol: r, className: "adm:opacity-50" }),
|
|
525
|
+
k() ? O() : q()
|
|
527
526
|
] }), X = () => u?.triggerIcon ? u.triggerIcon({
|
|
528
527
|
open: S
|
|
529
|
-
}) : /* @__PURE__ */ p.jsx(
|
|
528
|
+
}) : /* @__PURE__ */ p.jsx(oe, { symbol: "expand_more", className: "adm:opacity-50" }), P = () => i && k() && g === "right" ? /* @__PURE__ */ p.jsxs("span", { className: "adm:flex adm:items-center adm:gap-2", children: [
|
|
530
529
|
O(),
|
|
531
530
|
X()
|
|
532
531
|
] }) : /* @__PURE__ */ p.jsx("span", { className: "adm:flex adm:items-center adm:gap-2", children: X() }), V = () => u?.trigger ? u.trigger({
|
|
533
532
|
open: S,
|
|
534
533
|
value: y,
|
|
535
|
-
displayText: N()
|
|
534
|
+
displayText: N() || "",
|
|
536
535
|
placeholder: A.placeholder || "",
|
|
537
536
|
hasValue: k(),
|
|
538
537
|
icon: r
|
|
539
538
|
}) : /* @__PURE__ */ p.jsxs(
|
|
540
539
|
je,
|
|
541
540
|
{
|
|
542
|
-
ref:
|
|
541
|
+
ref: E,
|
|
543
542
|
variant: "outline",
|
|
544
543
|
role: "combobox",
|
|
545
544
|
"aria-expanded": S,
|
|
546
545
|
className: M("adm:justify-between adm:font-normal", s?.trigger),
|
|
547
546
|
children: [
|
|
548
547
|
J(),
|
|
549
|
-
|
|
548
|
+
P()
|
|
550
549
|
]
|
|
551
550
|
}
|
|
552
551
|
), Y = () => e ? u?.searchInput ? u.searchInput({
|
|
553
552
|
placeholder: A.searchPlaceholder || ""
|
|
554
553
|
}) : /* @__PURE__ */ p.jsx(
|
|
555
|
-
|
|
554
|
+
ct,
|
|
556
555
|
{
|
|
557
556
|
placeholder: A.searchPlaceholder,
|
|
558
557
|
className: s?.input
|
|
@@ -563,39 +562,39 @@ function At({
|
|
|
563
562
|
option: f
|
|
564
563
|
}) : /* @__PURE__ */ p.jsx(p.Fragment, { children: f.label }), ae = (f) => u?.option ? /* @__PURE__ */ p.jsx("div", { children: u.option({
|
|
565
564
|
option: f,
|
|
566
|
-
isSelected:
|
|
567
|
-
selectedFeedback:
|
|
565
|
+
isSelected: I(f.value),
|
|
566
|
+
selectedFeedback: b
|
|
568
567
|
}) }, f.value) : /* @__PURE__ */ p.jsxs(
|
|
569
|
-
|
|
568
|
+
pt,
|
|
570
569
|
{
|
|
571
570
|
value: f.value,
|
|
572
571
|
onSelect: U,
|
|
573
572
|
disabled: f.disabled,
|
|
574
573
|
className: M(
|
|
575
574
|
s?.item,
|
|
576
|
-
|
|
575
|
+
b === "check" && "adm:pr-8"
|
|
577
576
|
),
|
|
578
577
|
children: [
|
|
579
|
-
|
|
578
|
+
b === "checkbox" && H(f.value),
|
|
580
579
|
ne(f),
|
|
581
|
-
|
|
580
|
+
b === "check" && H(f.value)
|
|
582
581
|
]
|
|
583
582
|
},
|
|
584
583
|
f.value
|
|
585
584
|
);
|
|
586
|
-
return /* @__PURE__ */ p.jsxs(
|
|
585
|
+
return /* @__PURE__ */ p.jsxs(Pe, { open: S, onOpenChange: R, children: [
|
|
587
586
|
/* @__PURE__ */ p.jsx(De, { asChild: !0, children: V() }),
|
|
588
587
|
/* @__PURE__ */ p.jsx(
|
|
589
|
-
|
|
588
|
+
Fe,
|
|
590
589
|
{
|
|
591
590
|
align: "start",
|
|
592
591
|
className: M("adm:p-0", s?.popover),
|
|
593
|
-
style: { minWidth:
|
|
594
|
-
children: /* @__PURE__ */ p.jsxs(
|
|
592
|
+
style: { minWidth: E.current?.offsetWidth },
|
|
593
|
+
children: /* @__PURE__ */ p.jsxs(ut, { className: s?.command, children: [
|
|
595
594
|
Y(),
|
|
596
|
-
/* @__PURE__ */ p.jsxs(
|
|
597
|
-
/* @__PURE__ */ p.jsx(
|
|
598
|
-
/* @__PURE__ */ p.jsx(
|
|
595
|
+
/* @__PURE__ */ p.jsxs(st, { className: s?.list, children: [
|
|
596
|
+
/* @__PURE__ */ p.jsx(mt, { className: s?.empty, children: Q() }),
|
|
597
|
+
/* @__PURE__ */ p.jsx(ft, { className: s?.group, children: m.map((f) => ae(f)) })
|
|
599
598
|
] })
|
|
600
599
|
] })
|
|
601
600
|
}
|
|
@@ -603,5 +602,5 @@ function At({
|
|
|
603
602
|
] });
|
|
604
603
|
}
|
|
605
604
|
export {
|
|
606
|
-
|
|
605
|
+
Ct as Combobox
|
|
607
606
|
};
|