@inkeep/cxkit-primitives 0.5.37 → 0.5.39
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/atoms/cmdk/index.cjs +1 -1
- package/dist/atoms/cmdk/index.js +328 -320
- package/dist/components/embedded-search/search-provider.cjs +1 -1
- package/dist/components/embedded-search/search-provider.js +19 -12
- package/dist/components/embedded-search/transform-results.cjs +1 -1
- package/dist/components/embedded-search/transform-results.js +56 -72
- package/dist/components/embedded-search/url-query.cjs +1 -0
- package/dist/components/embedded-search/url-query.js +12 -0
- package/dist/components/embedded-search/use-inkeep-search.cjs +1 -1
- package/dist/components/embedded-search/use-inkeep-search.js +27 -149
- package/dist/components/embedded-search/use-search-filter.cjs +1 -0
- package/dist/components/embedded-search/use-search-filter.js +91 -0
- package/dist/components/embedded-search.cjs +1 -1
- package/dist/components/embedded-search.js +372 -365
- package/dist/constants/search.cjs +1 -0
- package/dist/constants/search.js +5 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +472 -41
- package/dist/index.d.ts +472 -41
- package/dist/index.js +112 -99
- package/dist/providers/base-events-provider.cjs +1 -1
- package/dist/providers/base-events-provider.js +1 -1
- package/package.json +4 -4
package/dist/atoms/cmdk/index.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import * as
|
|
1
|
+
import { jsxs as ee, jsx as g } from "react/jsx-runtime";
|
|
2
|
+
import * as K from "@radix-ui/react-dialog";
|
|
3
3
|
import * as c from "react";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
import { useCallback as ae, useMemo as Ee } from "react";
|
|
5
|
+
import { commandScore as Ce } from "./command-score.js";
|
|
6
|
+
import { Primitive as k } from "@radix-ui/react-primitive";
|
|
7
|
+
import { useId as F } from "@radix-ui/react-id";
|
|
8
|
+
import { s as we } from "../../node_modules/.pnpm/use-sync-external-store@1.4.0_react@19.0.0/node_modules/use-sync-external-store/shim/index.js";
|
|
9
|
+
import { ASK_AI_TRIGGER_VALUE as ye } from "../../constants/search.js";
|
|
10
|
+
import { useShadow as Re } from "../shadow/context.js";
|
|
11
|
+
const T = '[cmdk-group=""]', Y = '[cmdk-group-items=""]', Ie = '[cmdk-group-heading=""]', de = '[cmdk-item=""]', ue = `${de}:not([aria-disabled="true"])`, Z = "cmdk-item-select", M = "data-value", xe = (t, n, r) => Ce(t, n, r ?? []), fe = c.createContext(void 0), G = () => c.useContext(fe), me = c.createContext(void 0), te = () => c.useContext(me), ve = c.createContext(void 0), he = c.forwardRef((t, n) => {
|
|
12
|
+
const r = P(() => /* @__PURE__ */ new Set()), i = P(() => /* @__PURE__ */ new Map()), u = P(() => /* @__PURE__ */ new Map()), f = P(() => /* @__PURE__ */ new Set()), s = ge(t), {
|
|
13
|
+
label: v,
|
|
14
|
+
children: d,
|
|
15
|
+
value: S,
|
|
16
|
+
onValueChange: C,
|
|
17
|
+
filter: y,
|
|
18
|
+
shouldFilter: w,
|
|
19
|
+
loop: R,
|
|
20
|
+
disablePointerSelection: L = !1,
|
|
21
|
+
vimBindings: N = !0,
|
|
22
|
+
defaultSearch: re,
|
|
23
|
+
...U
|
|
24
|
+
} = t, h = P(() => ({
|
|
12
25
|
/** Value of the search query. */
|
|
13
|
-
search: "",
|
|
26
|
+
search: re ?? "",
|
|
14
27
|
/** Currently selected item value. */
|
|
15
|
-
value:
|
|
28
|
+
value: t.value ?? t.defaultValue ?? "",
|
|
16
29
|
/** Currently selected item id. */
|
|
17
30
|
selectedItemId: void 0,
|
|
18
31
|
filtered: {
|
|
@@ -23,321 +36,315 @@ const D = '[cmdk-group=""]', Q = '[cmdk-group-items=""]', we = '[cmdk-group-head
|
|
|
23
36
|
/** Set of groups with at least one visible item. */
|
|
24
37
|
groups: /* @__PURE__ */ new Set()
|
|
25
38
|
}
|
|
26
|
-
})),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
filter: x,
|
|
32
|
-
shouldFilter: E,
|
|
33
|
-
loop: _,
|
|
34
|
-
disablePointerSelection: he = !1,
|
|
35
|
-
vimBindings: B = !0,
|
|
36
|
-
...N
|
|
37
|
-
} = r, ee = T(), U = T(), p = T(), w = c.useRef(null), y = De();
|
|
38
|
-
A(() => {
|
|
39
|
-
if (b !== void 0) {
|
|
40
|
-
const e = b.trim();
|
|
41
|
-
t.current.value = e, S.emit();
|
|
39
|
+
})), $ = F(), j = F(), b = F(), I = c.useRef(null), x = Oe();
|
|
40
|
+
_(() => {
|
|
41
|
+
if (S !== void 0) {
|
|
42
|
+
const e = S.trim();
|
|
43
|
+
h.current.value = e, E.emit();
|
|
42
44
|
}
|
|
43
|
-
}, [
|
|
44
|
-
|
|
45
|
+
}, [S]), _(() => {
|
|
46
|
+
x(6, oe);
|
|
45
47
|
}, []);
|
|
46
|
-
const
|
|
48
|
+
const be = Re(), E = c.useMemo(() => ({
|
|
47
49
|
subscribe: (e) => (f.current.add(e), () => f.current.delete(e)),
|
|
48
|
-
snapshot: () =>
|
|
49
|
-
setState: (e,
|
|
50
|
-
if (!Object.is(
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
else if (e === "value" && (
|
|
54
|
-
|
|
55
|
-
}),
|
|
56
|
-
|
|
57
|
-
}), o ||
|
|
58
|
-
const
|
|
59
|
-
|
|
50
|
+
snapshot: () => h.current,
|
|
51
|
+
setState: (e, l, o) => {
|
|
52
|
+
if (!Object.is(h.current[e], l)) {
|
|
53
|
+
if (h.current[e] = l, e === "search")
|
|
54
|
+
W(), z(), x(1, H);
|
|
55
|
+
else if (e === "value" && (be?.shadowHost?.shadowRoot?.activeElement?.hasAttribute("cmdk-input") || x(1, () => {
|
|
56
|
+
A()?.focus();
|
|
57
|
+
}), x(7, () => {
|
|
58
|
+
h.current.selectedItemId = A()?.id, E.emit();
|
|
59
|
+
}), o || x(5, oe), s.current?.value !== void 0)) {
|
|
60
|
+
const p = l ?? "";
|
|
61
|
+
s.current.onValueChange?.(p);
|
|
60
62
|
return;
|
|
61
63
|
}
|
|
62
|
-
|
|
64
|
+
E.emit();
|
|
63
65
|
}
|
|
64
66
|
},
|
|
65
67
|
emit: () => {
|
|
66
68
|
f.current.forEach((e) => e());
|
|
67
69
|
}
|
|
68
|
-
}), []),
|
|
70
|
+
}), []), q = c.useMemo(
|
|
69
71
|
() => ({
|
|
70
72
|
// Keep id → {value, keywords} mapping up-to-date
|
|
71
|
-
value: (e,
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
value: (e, l, o) => {
|
|
74
|
+
l !== u.current.get(e)?.value && (u.current.set(e, { value: l, keywords: o }), h.current.filtered.items.set(e, ne(l, o)), x(2, () => {
|
|
75
|
+
z(), E.emit();
|
|
74
76
|
}));
|
|
75
77
|
},
|
|
76
78
|
// Track item lifecycle (mount, unmount)
|
|
77
|
-
item: (e,
|
|
78
|
-
|
|
79
|
+
item: (e, l) => (r.current.add(e), l && (i.current.has(l) ? i.current?.get(l)?.add(e) : i.current.set(l, /* @__PURE__ */ new Set([e]))), x(3, () => {
|
|
80
|
+
W(), z(), h.current.value || H(), E.emit();
|
|
79
81
|
}), () => {
|
|
80
|
-
|
|
81
|
-
const o =
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
u.current.delete(e), r.current.delete(e), h.current.filtered.items.delete(e);
|
|
83
|
+
const o = A();
|
|
84
|
+
x(4, () => {
|
|
85
|
+
W(), o?.getAttribute("id") === e && H(), E.emit();
|
|
84
86
|
});
|
|
85
87
|
}),
|
|
86
88
|
// Track group lifecycle (mount, unmount)
|
|
87
|
-
group: (e) => (
|
|
88
|
-
|
|
89
|
+
group: (e) => (i.current.has(e) || i.current.set(e, /* @__PURE__ */ new Set()), () => {
|
|
90
|
+
u.current.delete(e), i.current.delete(e);
|
|
89
91
|
}),
|
|
90
|
-
filter: () => !!
|
|
91
|
-
label:
|
|
92
|
-
getDisablePointerSelection: () => !!
|
|
93
|
-
listId:
|
|
94
|
-
inputId:
|
|
95
|
-
labelId:
|
|
96
|
-
listInnerRef:
|
|
92
|
+
filter: () => !!s.current.shouldFilter,
|
|
93
|
+
label: v || t["aria-label"] || "",
|
|
94
|
+
getDisablePointerSelection: () => !!s.current.disablePointerSelection,
|
|
95
|
+
listId: $,
|
|
96
|
+
inputId: b,
|
|
97
|
+
labelId: j,
|
|
98
|
+
listInnerRef: I
|
|
97
99
|
}),
|
|
98
100
|
[]
|
|
99
101
|
);
|
|
100
|
-
function
|
|
101
|
-
const o =
|
|
102
|
-
return e ? o?.(e,
|
|
102
|
+
function ne(e, l) {
|
|
103
|
+
const o = s.current?.filter ?? xe;
|
|
104
|
+
return e ? o?.(e, h.current.search, l) : 0;
|
|
103
105
|
}
|
|
104
|
-
function
|
|
105
|
-
if (!
|
|
106
|
-
|
|
106
|
+
function z() {
|
|
107
|
+
if (!h.current.search || // Explicitly false, because true | undefined is the default
|
|
108
|
+
s.current.shouldFilter === !1)
|
|
107
109
|
return;
|
|
108
|
-
const e =
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
let
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
}),
|
|
110
|
+
const e = h.current.filtered.items, l = [];
|
|
111
|
+
h.current.filtered.groups.forEach((a) => {
|
|
112
|
+
const m = i.current.get(a);
|
|
113
|
+
let p = 0;
|
|
114
|
+
m.forEach((X) => {
|
|
115
|
+
const Se = e.get(X);
|
|
116
|
+
p = Math.max(Se, p);
|
|
117
|
+
}), l.push([a, p]);
|
|
116
118
|
});
|
|
117
|
-
const o =
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
return (e.get(
|
|
121
|
-
}).forEach((
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
124
|
-
const
|
|
125
|
-
|
|
119
|
+
const o = I.current;
|
|
120
|
+
D().sort((a, m) => {
|
|
121
|
+
const p = a.getAttribute("id"), X = m.getAttribute("id");
|
|
122
|
+
return (e.get(X) ?? 0) - (e.get(p) ?? 0);
|
|
123
|
+
}).forEach((a) => {
|
|
124
|
+
const m = a.closest(Y);
|
|
125
|
+
if (m) {
|
|
126
|
+
const p = a.parentElement === m ? a : a.closest(`${Y} > *`);
|
|
127
|
+
p && m.appendChild(p);
|
|
126
128
|
} else {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
+
const p = a.parentElement === o ? a : a.closest(`${Y} > *`);
|
|
130
|
+
p && o?.appendChild(p);
|
|
129
131
|
}
|
|
130
|
-
}),
|
|
131
|
-
const
|
|
132
|
-
`${
|
|
132
|
+
}), l.sort((a, m) => m[1] - a[1]).forEach((a) => {
|
|
133
|
+
const m = I.current?.querySelector(
|
|
134
|
+
`${T}[${M}="${encodeURIComponent(a[0])}"]`
|
|
133
135
|
);
|
|
134
|
-
|
|
136
|
+
m?.parentElement?.appendChild(m);
|
|
135
137
|
});
|
|
136
138
|
}
|
|
137
|
-
function
|
|
138
|
-
const
|
|
139
|
-
(o) => o.getAttribute("aria-disabled") !== "true" && o.getAttribute("data-value") !==
|
|
140
|
-
)?.getAttribute(
|
|
141
|
-
|
|
139
|
+
function H() {
|
|
140
|
+
const l = D().find(
|
|
141
|
+
(o) => o.getAttribute("aria-disabled") !== "true" && o.getAttribute("data-value") !== ye
|
|
142
|
+
)?.getAttribute(M);
|
|
143
|
+
E.setState("value", l || void 0);
|
|
142
144
|
}
|
|
143
|
-
function
|
|
144
|
-
if (!
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
function W() {
|
|
146
|
+
if (!h.current.search || // Explicitly false, because true | undefined is the default
|
|
147
|
+
s.current.shouldFilter === !1) {
|
|
148
|
+
h.current.filtered.count = r.current.size;
|
|
147
149
|
return;
|
|
148
150
|
}
|
|
149
|
-
|
|
151
|
+
h.current.filtered.groups = /* @__PURE__ */ new Set();
|
|
150
152
|
let e = 0;
|
|
151
|
-
for (const
|
|
152
|
-
const o =
|
|
153
|
-
|
|
153
|
+
for (const l of r.current) {
|
|
154
|
+
const o = u.current.get(l)?.value ?? "", a = u.current.get(l)?.keywords ?? [], m = ne(o, a);
|
|
155
|
+
h.current.filtered.items.set(l, m), m > 0 && e++;
|
|
154
156
|
}
|
|
155
|
-
for (const [
|
|
156
|
-
for (const
|
|
157
|
-
const
|
|
158
|
-
if (
|
|
159
|
-
|
|
157
|
+
for (const [l, o] of i.current)
|
|
158
|
+
for (const a of o) {
|
|
159
|
+
const m = h.current.filtered.items.get(a);
|
|
160
|
+
if (m && m > 0) {
|
|
161
|
+
h.current.filtered.groups.add(l);
|
|
160
162
|
break;
|
|
161
163
|
}
|
|
162
164
|
}
|
|
163
|
-
|
|
165
|
+
h.current.filtered.count = e;
|
|
164
166
|
}
|
|
165
|
-
function
|
|
166
|
-
const e =
|
|
167
|
-
e && (e.parentElement?.firstChild === e && e.closest(
|
|
167
|
+
function oe() {
|
|
168
|
+
const e = A();
|
|
169
|
+
e && (e.parentElement?.firstChild === e && e.closest(T)?.querySelector(Ie)?.scrollIntoView({ block: "nearest" }), e.scrollIntoView({ block: "nearest" }));
|
|
168
170
|
}
|
|
169
|
-
function
|
|
170
|
-
return
|
|
171
|
+
function A() {
|
|
172
|
+
return I.current?.querySelector(`${de}[aria-selected="true"]`);
|
|
171
173
|
}
|
|
172
|
-
function
|
|
173
|
-
return Array.from(
|
|
174
|
+
function D() {
|
|
175
|
+
return Array.from(I.current?.querySelectorAll(ue) || []);
|
|
174
176
|
}
|
|
175
|
-
function
|
|
176
|
-
const o =
|
|
177
|
-
o &&
|
|
177
|
+
function J(e) {
|
|
178
|
+
const o = D()[e];
|
|
179
|
+
o && E.setState("value", o.getAttribute(M));
|
|
178
180
|
}
|
|
179
|
-
function
|
|
180
|
-
const
|
|
181
|
-
let
|
|
182
|
-
|
|
181
|
+
function Q(e) {
|
|
182
|
+
const l = A(), o = D(), a = o.findIndex((p) => p === l);
|
|
183
|
+
let m = o[a + e];
|
|
184
|
+
s.current?.loop && (m = a + e < 0 ? o[o.length - 1] : a + e === o.length ? o[0] : o[a + e]), m && E.setState("value", m.getAttribute(M));
|
|
183
185
|
}
|
|
184
|
-
function
|
|
185
|
-
let o =
|
|
186
|
-
for (; o && !
|
|
187
|
-
o = e > 0 ?
|
|
188
|
-
|
|
186
|
+
function ce(e) {
|
|
187
|
+
let o = A()?.closest(T), a;
|
|
188
|
+
for (; o && !a; )
|
|
189
|
+
o = e > 0 ? Te(o, T) : Fe(o, T), a = o?.querySelector(ue);
|
|
190
|
+
a ? E.setState("value", a.getAttribute(M)) : Q(e);
|
|
189
191
|
}
|
|
190
|
-
const
|
|
191
|
-
e.preventDefault(), e.metaKey ?
|
|
192
|
-
},
|
|
193
|
-
e.preventDefault(), e.metaKey ?
|
|
192
|
+
const se = () => J(D().length - 1), ie = (e) => {
|
|
193
|
+
e.preventDefault(), e.metaKey ? se() : e.altKey ? ce(1) : Q(1);
|
|
194
|
+
}, le = (e) => {
|
|
195
|
+
e.preventDefault(), e.metaKey ? J(0) : e.altKey ? ce(-1) : Q(-1);
|
|
194
196
|
};
|
|
195
|
-
return /* @__PURE__ */
|
|
196
|
-
|
|
197
|
+
return /* @__PURE__ */ ee(
|
|
198
|
+
k.div,
|
|
197
199
|
{
|
|
198
200
|
ref: n,
|
|
199
201
|
tabIndex: -1,
|
|
200
|
-
...
|
|
202
|
+
...U,
|
|
201
203
|
"cmdk-root": "",
|
|
202
204
|
onKeyDown: (e) => {
|
|
203
|
-
if (
|
|
205
|
+
if (U.onKeyDown?.(e), !e.defaultPrevented)
|
|
204
206
|
switch (e.key) {
|
|
205
207
|
case "n":
|
|
206
208
|
case "j": {
|
|
207
|
-
|
|
209
|
+
N && e.ctrlKey && ie(e);
|
|
208
210
|
break;
|
|
209
211
|
}
|
|
210
212
|
case "ArrowDown": {
|
|
211
|
-
|
|
213
|
+
ie(e);
|
|
212
214
|
break;
|
|
213
215
|
}
|
|
214
216
|
case "p":
|
|
215
217
|
case "k": {
|
|
216
|
-
|
|
218
|
+
N && e.ctrlKey && le(e);
|
|
217
219
|
break;
|
|
218
220
|
}
|
|
219
221
|
case "ArrowUp": {
|
|
220
|
-
|
|
222
|
+
le(e);
|
|
221
223
|
break;
|
|
222
224
|
}
|
|
223
225
|
case "Home": {
|
|
224
|
-
e.preventDefault(),
|
|
226
|
+
e.preventDefault(), J(0);
|
|
225
227
|
break;
|
|
226
228
|
}
|
|
227
229
|
case "End": {
|
|
228
|
-
e.preventDefault(),
|
|
230
|
+
e.preventDefault(), se();
|
|
229
231
|
break;
|
|
230
232
|
}
|
|
231
233
|
case "Enter":
|
|
232
234
|
if (!e.nativeEvent.isComposing && e.keyCode !== 229) {
|
|
233
235
|
e.preventDefault();
|
|
234
|
-
const
|
|
235
|
-
if (
|
|
236
|
-
const o = new Event(
|
|
237
|
-
|
|
236
|
+
const l = A();
|
|
237
|
+
if (l) {
|
|
238
|
+
const o = new Event(Z);
|
|
239
|
+
l.dispatchEvent(o);
|
|
238
240
|
}
|
|
239
241
|
}
|
|
240
242
|
}
|
|
241
243
|
},
|
|
244
|
+
style: {
|
|
245
|
+
display: "contents"
|
|
246
|
+
},
|
|
242
247
|
children: [
|
|
243
|
-
/* @__PURE__ */
|
|
248
|
+
/* @__PURE__ */ g(
|
|
244
249
|
"label",
|
|
245
250
|
{
|
|
246
251
|
"cmdk-label": "",
|
|
247
|
-
htmlFor:
|
|
248
|
-
id:
|
|
249
|
-
style:
|
|
250
|
-
children:
|
|
252
|
+
htmlFor: q.inputId,
|
|
253
|
+
id: q.labelId,
|
|
254
|
+
style: Ke,
|
|
255
|
+
children: v
|
|
251
256
|
}
|
|
252
257
|
),
|
|
253
|
-
|
|
258
|
+
B(t, (e) => /* @__PURE__ */ g(me.Provider, { value: E, children: /* @__PURE__ */ g(fe.Provider, { value: q, children: e }) }))
|
|
254
259
|
]
|
|
255
260
|
}
|
|
256
261
|
);
|
|
257
|
-
}),
|
|
258
|
-
const { id:
|
|
259
|
-
|
|
260
|
-
if (!
|
|
261
|
-
return
|
|
262
|
-
}, [
|
|
263
|
-
const
|
|
264
|
-
(
|
|
262
|
+
}), ke = c.forwardRef((t, n) => {
|
|
263
|
+
const { id: r } = t, i = c.useRef(null), u = c.useContext(ve), f = G(), s = ge(t), v = s.current?.forceMount ?? u?.forceMount;
|
|
264
|
+
_(() => {
|
|
265
|
+
if (!v)
|
|
266
|
+
return f.item(r, u?.id);
|
|
267
|
+
}, [v]);
|
|
268
|
+
const d = pe(r, i, [t.value, t.children, i], t.keywords), S = te(), C = V((b) => b.value && b.value === d.current), y = V(
|
|
269
|
+
(b) => v || f.filter() === !1 ? !0 : b.search ? b.filtered.items.get(r) > 0 : !0
|
|
265
270
|
);
|
|
266
271
|
c.useEffect(() => {
|
|
267
|
-
const
|
|
268
|
-
if (!
|
|
269
|
-
const
|
|
270
|
-
return
|
|
271
|
-
}, [
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
272
|
+
const b = i.current;
|
|
273
|
+
if (!b || t.disabled) return;
|
|
274
|
+
const I = () => R("keyboard");
|
|
275
|
+
return b.addEventListener(Z, I), () => b.removeEventListener(Z, I);
|
|
276
|
+
}, [y, t.onSelect, t.disabled]);
|
|
277
|
+
const w = ae(() => {
|
|
278
|
+
S.setState("value", d.current, !0);
|
|
279
|
+
}, [S, d]), R = ae(
|
|
280
|
+
(b = "click") => {
|
|
281
|
+
w(), s.current.onSelect?.({ value: d.current, trigger: b });
|
|
282
|
+
},
|
|
283
|
+
[w, s, d]
|
|
284
|
+
);
|
|
285
|
+
if (!y) return null;
|
|
286
|
+
const { disabled: L, value: N, onSelect: re, forceMount: U, keywords: h, ...$ } = t, j = Ee(() => O([i, n]), [i, n]);
|
|
287
|
+
return /* @__PURE__ */ g(
|
|
288
|
+
k.div,
|
|
282
289
|
{
|
|
283
|
-
ref:
|
|
284
|
-
|
|
285
|
-
id:
|
|
290
|
+
ref: j,
|
|
291
|
+
...$,
|
|
292
|
+
id: r,
|
|
286
293
|
"cmdk-item": "",
|
|
287
294
|
role: "option",
|
|
288
|
-
"aria-disabled": !!
|
|
289
|
-
"aria-selected": !!
|
|
290
|
-
"data-disabled": !!
|
|
291
|
-
"data-selected": !!
|
|
292
|
-
onPointerMove:
|
|
293
|
-
onClick:
|
|
294
|
-
onFocus:
|
|
295
|
-
children:
|
|
295
|
+
"aria-disabled": !!L,
|
|
296
|
+
"aria-selected": !!C,
|
|
297
|
+
"data-disabled": !!L,
|
|
298
|
+
"data-selected": !!C,
|
|
299
|
+
onPointerMove: L || f.getDisablePointerSelection() ? void 0 : w,
|
|
300
|
+
onClick: L ? void 0 : R,
|
|
301
|
+
onFocus: L ? void 0 : w,
|
|
302
|
+
children: t.children
|
|
296
303
|
}
|
|
297
304
|
);
|
|
298
|
-
}),
|
|
299
|
-
const { heading:
|
|
300
|
-
(
|
|
305
|
+
}), Ae = c.forwardRef((t, n) => {
|
|
306
|
+
const { heading: r, children: i, forceMount: u, ...f } = t, s = F(), v = c.useRef(null), d = c.useRef(null), S = F(), C = G(), y = V(
|
|
307
|
+
(R) => u || C.filter() === !1 ? !0 : R.search ? R.filtered.groups.has(s) : !0
|
|
301
308
|
);
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
return /* @__PURE__ */
|
|
305
|
-
|
|
309
|
+
_(() => C.group(s), []), pe(s, v, [t.value, t.heading, d]);
|
|
310
|
+
const w = c.useMemo(() => ({ id: s, forceMount: u }), [u]);
|
|
311
|
+
return /* @__PURE__ */ ee(
|
|
312
|
+
k.div,
|
|
306
313
|
{
|
|
307
|
-
ref:
|
|
308
|
-
...
|
|
314
|
+
ref: O([v, n]),
|
|
315
|
+
...f,
|
|
309
316
|
"cmdk-group": "",
|
|
310
317
|
role: "presentation",
|
|
311
|
-
hidden:
|
|
318
|
+
hidden: y ? void 0 : !0,
|
|
312
319
|
children: [
|
|
313
|
-
|
|
314
|
-
|
|
320
|
+
r && /* @__PURE__ */ g("div", { ref: d, "cmdk-group-heading": "", "aria-hidden": !0, id: S, children: r }),
|
|
321
|
+
B(t, (R) => (
|
|
315
322
|
// biome-ignore lint/a11y/useSemanticElements: <explanation>
|
|
316
|
-
/* @__PURE__ */
|
|
323
|
+
/* @__PURE__ */ g("div", { "cmdk-group-items": "", role: "group", "aria-labelledby": r ? S : void 0, children: /* @__PURE__ */ g(ve.Provider, { value: w, children: R }) })
|
|
317
324
|
))
|
|
318
325
|
]
|
|
319
326
|
}
|
|
320
327
|
);
|
|
321
|
-
}),
|
|
322
|
-
const { alwaysRender:
|
|
323
|
-
return !
|
|
324
|
-
|
|
328
|
+
}), _e = c.forwardRef((t, n) => {
|
|
329
|
+
const { alwaysRender: r, ...i } = t, u = c.useRef(null), f = V((s) => !s.search);
|
|
330
|
+
return !r && !f ? null : /* @__PURE__ */ g(
|
|
331
|
+
k.div,
|
|
325
332
|
{
|
|
326
|
-
ref:
|
|
327
|
-
...
|
|
333
|
+
ref: O([u, n]),
|
|
334
|
+
...i,
|
|
328
335
|
"cmdk-separator": "",
|
|
329
336
|
role: "separator"
|
|
330
337
|
}
|
|
331
338
|
);
|
|
332
|
-
}),
|
|
333
|
-
const { onValueChange:
|
|
339
|
+
}), Le = c.forwardRef((t, n) => {
|
|
340
|
+
const { onValueChange: r, ...i } = t, u = t.value != null, f = te(), s = V((d) => d.search), v = G();
|
|
334
341
|
return c.useEffect(() => {
|
|
335
|
-
|
|
336
|
-
}, [
|
|
337
|
-
|
|
342
|
+
t.value != null && f.setState("search", t.value);
|
|
343
|
+
}, [t.value]), /* @__PURE__ */ g(
|
|
344
|
+
k.input,
|
|
338
345
|
{
|
|
339
346
|
ref: n,
|
|
340
|
-
...
|
|
347
|
+
...i,
|
|
341
348
|
"cmdk-input": "",
|
|
342
349
|
autoComplete: "off",
|
|
343
350
|
autoCorrect: "off",
|
|
@@ -345,147 +352,147 @@ const D = '[cmdk-group=""]', Q = '[cmdk-group-items=""]', we = '[cmdk-group-head
|
|
|
345
352
|
"aria-autocomplete": "list",
|
|
346
353
|
role: "combobox",
|
|
347
354
|
"aria-expanded": !0,
|
|
348
|
-
"aria-controls":
|
|
349
|
-
"aria-labelledby":
|
|
350
|
-
id:
|
|
355
|
+
"aria-controls": v.listId,
|
|
356
|
+
"aria-labelledby": v.labelId,
|
|
357
|
+
id: v.inputId,
|
|
351
358
|
type: "text",
|
|
352
|
-
value:
|
|
353
|
-
onChange: (
|
|
354
|
-
|
|
359
|
+
value: u ? t.value : s,
|
|
360
|
+
onChange: (d) => {
|
|
361
|
+
u || f.setState("search", d.target.value), r?.(d.target.value);
|
|
355
362
|
}
|
|
356
363
|
}
|
|
357
364
|
);
|
|
358
|
-
}),
|
|
359
|
-
const { children:
|
|
365
|
+
}), Me = c.forwardRef((t, n) => {
|
|
366
|
+
const { children: r, label: i = "Suggestions", ...u } = t, f = c.useRef(null), s = c.useRef(null), v = G();
|
|
360
367
|
return c.useEffect(() => {
|
|
361
|
-
if (
|
|
362
|
-
const
|
|
363
|
-
let
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
+
if (s.current && f.current) {
|
|
369
|
+
const d = s.current, S = f.current;
|
|
370
|
+
let C;
|
|
371
|
+
const y = new ResizeObserver(() => {
|
|
372
|
+
C = requestAnimationFrame(() => {
|
|
373
|
+
const w = d.offsetHeight;
|
|
374
|
+
S.style.setProperty("--cmdk-list-height", w.toFixed(1) + "px");
|
|
368
375
|
});
|
|
369
376
|
});
|
|
370
|
-
return
|
|
371
|
-
cancelAnimationFrame(
|
|
377
|
+
return y.observe(d), () => {
|
|
378
|
+
cancelAnimationFrame(C), y.unobserve(d);
|
|
372
379
|
};
|
|
373
380
|
}
|
|
374
|
-
}, []), /* @__PURE__ */
|
|
375
|
-
|
|
381
|
+
}, []), /* @__PURE__ */ g(
|
|
382
|
+
k.div,
|
|
376
383
|
{
|
|
377
|
-
ref:
|
|
378
|
-
...
|
|
384
|
+
ref: O([f, n]),
|
|
385
|
+
...u,
|
|
379
386
|
"cmdk-list": "",
|
|
380
387
|
tabIndex: -1,
|
|
381
|
-
"aria-label":
|
|
382
|
-
id:
|
|
383
|
-
children:
|
|
388
|
+
"aria-label": i,
|
|
389
|
+
id: v.listId,
|
|
390
|
+
children: B(t, (d) => /* @__PURE__ */ g("div", { ref: O([s, v.listInnerRef]), "cmdk-list-sizer": "", children: d }))
|
|
384
391
|
}
|
|
385
392
|
);
|
|
386
|
-
}),
|
|
387
|
-
const { open:
|
|
388
|
-
return /* @__PURE__ */
|
|
389
|
-
/* @__PURE__ */
|
|
390
|
-
/* @__PURE__ */
|
|
393
|
+
}), Pe = c.forwardRef((t, n) => {
|
|
394
|
+
const { open: r, onOpenChange: i, overlayClassName: u, contentClassName: f, container: s, ...v } = t;
|
|
395
|
+
return /* @__PURE__ */ g(K.Root, { open: r, onOpenChange: i, children: /* @__PURE__ */ ee(K.Portal, { container: s, children: [
|
|
396
|
+
/* @__PURE__ */ g(K.Overlay, { "cmdk-overlay": "", className: u }),
|
|
397
|
+
/* @__PURE__ */ g(K.Content, { "aria-label": t.label, "cmdk-dialog": "", className: f, children: /* @__PURE__ */ g(he, { ref: n, ...v }) })
|
|
391
398
|
] }) });
|
|
392
|
-
}),
|
|
393
|
-
const { progress:
|
|
394
|
-
return /* @__PURE__ */
|
|
395
|
-
|
|
399
|
+
}), Ve = c.forwardRef((t, n) => V((i) => i.filtered.count === 0) ? /* @__PURE__ */ g(k.div, { ref: n, ...t, "cmdk-empty": "", role: "presentation" }) : null), De = c.forwardRef((t, n) => {
|
|
400
|
+
const { progress: r, children: i, label: u = "Loading...", ...f } = t;
|
|
401
|
+
return /* @__PURE__ */ g(
|
|
402
|
+
k.div,
|
|
396
403
|
{
|
|
397
404
|
ref: n,
|
|
398
|
-
...
|
|
405
|
+
...f,
|
|
399
406
|
"cmdk-loading": "",
|
|
400
407
|
role: "progressbar",
|
|
401
|
-
"aria-valuenow":
|
|
408
|
+
"aria-valuenow": r,
|
|
402
409
|
"aria-valuemin": 0,
|
|
403
410
|
"aria-valuemax": 100,
|
|
404
|
-
"aria-label":
|
|
405
|
-
children:
|
|
411
|
+
"aria-label": u,
|
|
412
|
+
children: B(t, (s) => /* @__PURE__ */ g("div", { "aria-hidden": !0, children: s }))
|
|
406
413
|
}
|
|
407
414
|
);
|
|
408
|
-
}),
|
|
409
|
-
List:
|
|
410
|
-
Item:
|
|
411
|
-
Input:
|
|
412
|
-
Group:
|
|
413
|
-
Separator:
|
|
414
|
-
Dialog:
|
|
415
|
-
Empty:
|
|
416
|
-
Loading:
|
|
415
|
+
}), We = Object.assign(he, {
|
|
416
|
+
List: Me,
|
|
417
|
+
Item: ke,
|
|
418
|
+
Input: Le,
|
|
419
|
+
Group: Ae,
|
|
420
|
+
Separator: _e,
|
|
421
|
+
Dialog: Pe,
|
|
422
|
+
Empty: Ve,
|
|
423
|
+
Loading: De
|
|
417
424
|
});
|
|
418
|
-
function
|
|
419
|
-
let
|
|
420
|
-
for (;
|
|
421
|
-
if (
|
|
422
|
-
|
|
425
|
+
function Te(t, n) {
|
|
426
|
+
let r = t.nextElementSibling;
|
|
427
|
+
for (; r; ) {
|
|
428
|
+
if (r.matches(n)) return r;
|
|
429
|
+
r = r.nextElementSibling;
|
|
423
430
|
}
|
|
424
431
|
}
|
|
425
|
-
function
|
|
426
|
-
let
|
|
427
|
-
for (;
|
|
428
|
-
if (
|
|
429
|
-
|
|
432
|
+
function Fe(t, n) {
|
|
433
|
+
let r = t.previousElementSibling;
|
|
434
|
+
for (; r; ) {
|
|
435
|
+
if (r.matches(n)) return r;
|
|
436
|
+
r = r.previousElementSibling;
|
|
430
437
|
}
|
|
431
438
|
}
|
|
432
|
-
function
|
|
433
|
-
const n = c.useRef(
|
|
434
|
-
return
|
|
435
|
-
n.current =
|
|
439
|
+
function ge(t) {
|
|
440
|
+
const n = c.useRef(t);
|
|
441
|
+
return _(() => {
|
|
442
|
+
n.current = t;
|
|
436
443
|
}), n;
|
|
437
444
|
}
|
|
438
|
-
const
|
|
439
|
-
function
|
|
445
|
+
const _ = typeof window > "u" ? c.useEffect : c.useLayoutEffect;
|
|
446
|
+
function P(t) {
|
|
440
447
|
const n = c.useRef(void 0);
|
|
441
|
-
return n.current === void 0 && (n.current =
|
|
448
|
+
return n.current === void 0 && (n.current = t()), n;
|
|
442
449
|
}
|
|
443
|
-
function
|
|
450
|
+
function O(t) {
|
|
444
451
|
return (n) => {
|
|
445
|
-
|
|
446
|
-
typeof
|
|
452
|
+
t.forEach((r) => {
|
|
453
|
+
typeof r == "function" ? r(n) : r != null && (r.current = n);
|
|
447
454
|
});
|
|
448
455
|
};
|
|
449
456
|
}
|
|
450
|
-
function
|
|
451
|
-
const n =
|
|
452
|
-
return
|
|
457
|
+
function V(t) {
|
|
458
|
+
const n = te(), r = () => t(n.snapshot());
|
|
459
|
+
return we.useSyncExternalStore(n.subscribe, r, r);
|
|
453
460
|
}
|
|
454
|
-
function
|
|
455
|
-
const
|
|
456
|
-
return
|
|
457
|
-
const
|
|
458
|
-
for (const
|
|
459
|
-
if (typeof
|
|
460
|
-
return
|
|
461
|
-
if (typeof
|
|
462
|
-
return
|
|
461
|
+
function pe(t, n, r, i = []) {
|
|
462
|
+
const u = c.useRef(void 0), f = G();
|
|
463
|
+
return _(() => {
|
|
464
|
+
const s = (() => {
|
|
465
|
+
for (const d of r) {
|
|
466
|
+
if (typeof d == "string")
|
|
467
|
+
return d.trim();
|
|
468
|
+
if (typeof d == "object" && "current" in d)
|
|
469
|
+
return d.current ? d.current.textContent?.trim() : u.current;
|
|
463
470
|
}
|
|
464
|
-
})(),
|
|
465
|
-
|
|
466
|
-
}),
|
|
471
|
+
})(), v = i.map((d) => d.trim());
|
|
472
|
+
f.value(t, s, v), n.current?.setAttribute(M, s), u.current = s;
|
|
473
|
+
}), u;
|
|
467
474
|
}
|
|
468
|
-
const
|
|
469
|
-
const [
|
|
470
|
-
return
|
|
471
|
-
|
|
472
|
-
}, [
|
|
473
|
-
|
|
475
|
+
const Oe = () => {
|
|
476
|
+
const [t, n] = c.useState(), r = P(() => /* @__PURE__ */ new Map());
|
|
477
|
+
return _(() => {
|
|
478
|
+
r.current.forEach((i) => i()), r.current = /* @__PURE__ */ new Map();
|
|
479
|
+
}, [t]), (i, u) => {
|
|
480
|
+
r.current.set(i, u), n({});
|
|
474
481
|
};
|
|
475
482
|
};
|
|
476
|
-
function
|
|
477
|
-
const n =
|
|
478
|
-
return typeof n == "function" ? n(
|
|
483
|
+
function Ge(t) {
|
|
484
|
+
const n = t.type;
|
|
485
|
+
return typeof n == "function" ? n(t.props) : "render" in n ? n.render(t.props) : t;
|
|
479
486
|
}
|
|
480
|
-
function
|
|
481
|
-
return
|
|
482
|
-
|
|
487
|
+
function B({ asChild: t, children: n }, r) {
|
|
488
|
+
return t && c.isValidElement(n) ? c.cloneElement(
|
|
489
|
+
Ge(n),
|
|
483
490
|
{ ref: n.ref },
|
|
484
491
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
485
|
-
|
|
486
|
-
) :
|
|
492
|
+
r(n.props.children)
|
|
493
|
+
) : r(n);
|
|
487
494
|
}
|
|
488
|
-
const
|
|
495
|
+
const Ke = {
|
|
489
496
|
position: "absolute",
|
|
490
497
|
width: "1px",
|
|
491
498
|
height: "1px",
|
|
@@ -497,15 +504,16 @@ const Fe = {
|
|
|
497
504
|
borderWidth: "0"
|
|
498
505
|
};
|
|
499
506
|
export {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
507
|
+
We as Command,
|
|
508
|
+
Pe as CommandDialog,
|
|
509
|
+
Ve as CommandEmpty,
|
|
510
|
+
Le as CommandInput,
|
|
511
|
+
ke as CommandItem,
|
|
512
|
+
Me as CommandList,
|
|
513
|
+
De as CommandLoading,
|
|
514
|
+
he as CommandRoot,
|
|
515
|
+
_e as CommandSeparator,
|
|
516
|
+
xe as defaultFilter,
|
|
517
|
+
V as useCommandState,
|
|
518
|
+
te as useCommandStore
|
|
511
519
|
};
|