vue-command-kit 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -242
- package/dist/__tests__/highlight.test.d.ts +1 -0
- package/dist/types.d.ts +4 -0
- package/dist/utils/highlight.d.ts +9 -0
- package/dist/utils/shortcut.d.ts +12 -0
- package/dist/vue-cmdk.js +322 -288
- package/dist/vue-cmdk.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/vue-cmdk.js
CHANGED
|
@@ -1,149 +1,145 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
const
|
|
1
|
+
import { ref as M, computed as b, watch as k, onUnmounted as ie, provide as T, defineComponent as I, openBlock as d, createElementBlock as v, unref as p, renderSlot as x, inject as P, createElementVNode as w, createCommentVNode as L, toDisplayString as Q, isVNode as ce, normalizeClass as de, createBlock as V, resolveDynamicComponent as fe, Fragment as C, renderList as G, createTextVNode as A, createVNode as B, withCtx as H, nextTick as me, Teleport as ve, Transition as pe } from "vue";
|
|
2
|
+
const he = {
|
|
3
3
|
"⌘": "metaKey",
|
|
4
4
|
"⌃": "ctrlKey",
|
|
5
5
|
"⌥": "altKey",
|
|
6
6
|
"⇧": "shiftKey"
|
|
7
|
-
},
|
|
8
|
-
function ge(
|
|
9
|
-
if (!
|
|
10
|
-
const e =
|
|
11
|
-
if (!e) return { key:
|
|
12
|
-
const [,
|
|
13
|
-
for (const l of
|
|
14
|
-
const
|
|
15
|
-
|
|
7
|
+
}, ye = /^([⌘⌃⌥⇧]+)(.+)$/;
|
|
8
|
+
function ge(a) {
|
|
9
|
+
if (!a) return null;
|
|
10
|
+
const e = ye.exec(a);
|
|
11
|
+
if (!e) return { key: a.toLowerCase() };
|
|
12
|
+
const [, o, i] = e, u = {};
|
|
13
|
+
for (const l of o) {
|
|
14
|
+
const c = he[l];
|
|
15
|
+
c && (u[c] = !0);
|
|
16
16
|
}
|
|
17
|
-
return { ...
|
|
17
|
+
return { ...u, key: i.toLowerCase() };
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return e ?
|
|
19
|
+
function _e(a, e) {
|
|
20
|
+
return e ? a.key.toLowerCase() === e.key && !!a.metaKey == !!e.metaKey && !!a.ctrlKey == !!e.ctrlKey && !!a.altKey == !!e.altKey && !!a.shiftKey == !!e.shiftKey : !1;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const R = "__ungrouped__";
|
|
23
|
+
function ke(a, e) {
|
|
24
|
+
const o = typeof a == "function" ? { filter: a } : a ?? {}, { filter: i, shouldFilter: u = !0, loop: l = !0 } = o, c = M(!1), n = M(""), t = M(0), m = M(), f = M([]), S = () => {
|
|
25
|
+
c.value = !c.value;
|
|
26
|
+
}, s = () => {
|
|
27
|
+
c.value = !0, t.value = 0;
|
|
28
|
+
}, $ = () => {
|
|
29
|
+
c.value = !1, n.value = "";
|
|
29
30
|
};
|
|
30
|
-
function
|
|
31
|
-
if (!y.trim()) return
|
|
32
|
-
const
|
|
33
|
-
return
|
|
34
|
-
var D,
|
|
35
|
-
return !!(g.value.toLowerCase().includes(
|
|
31
|
+
function _(r, y) {
|
|
32
|
+
if (!y.trim()) return r;
|
|
33
|
+
const h = y.toLowerCase();
|
|
34
|
+
return r.filter((g) => {
|
|
35
|
+
var D, z;
|
|
36
|
+
return !!(g.forceMount || g.value.toLowerCase().includes(h) || (D = g.label) != null && D.toLowerCase().includes(h) || (z = g.keywords) != null && z.some((re) => re.toLowerCase().includes(h)));
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
+
function O(r) {
|
|
39
40
|
const y = /* @__PURE__ */ new Map();
|
|
40
|
-
for (const g of
|
|
41
|
-
const D = g.group ||
|
|
41
|
+
for (const g of r) {
|
|
42
|
+
const D = g.group || R;
|
|
42
43
|
y.has(D) ? y.get(D).push(g) : y.set(D, [g]);
|
|
43
44
|
}
|
|
44
|
-
const
|
|
45
|
-
y.has(
|
|
45
|
+
const h = [];
|
|
46
|
+
y.has(R) && (h.push({ heading: "", items: y.get(R) }), y.delete(R));
|
|
46
47
|
for (const g of [...y.keys()].sort())
|
|
47
|
-
|
|
48
|
-
return
|
|
48
|
+
h.push({ heading: g, items: y.get(g) });
|
|
49
|
+
return h;
|
|
49
50
|
}
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
51
|
+
const K = b(() => {
|
|
52
|
+
if (i) {
|
|
53
|
+
const r = i(f.value, n.value);
|
|
54
|
+
if (r !== null) return r;
|
|
54
55
|
}
|
|
55
|
-
return
|
|
56
|
-
}),
|
|
56
|
+
return u ? _(f.value, n.value) : f.value;
|
|
57
|
+
}), le = b(() => O(K.value));
|
|
58
|
+
function ne() {
|
|
59
|
+
const r = K.value.length;
|
|
60
|
+
r !== 0 && (l ? t.value = (t.value + 1) % r : t.value = Math.min(t.value + 1, r - 1));
|
|
61
|
+
}
|
|
57
62
|
function se() {
|
|
58
|
-
const
|
|
59
|
-
|
|
63
|
+
const r = K.value.length;
|
|
64
|
+
r !== 0 && (l ? t.value = (t.value - 1 + r) % r : t.value = Math.max(t.value - 1, 0));
|
|
60
65
|
}
|
|
61
66
|
function ue() {
|
|
62
|
-
const u = Q.value.length;
|
|
63
|
-
u !== 0 && (l ? t.value = (t.value - 1 + u) % u : t.value = Math.max(t.value - 1, 0));
|
|
64
|
-
}
|
|
65
|
-
function re() {
|
|
66
67
|
var y;
|
|
67
|
-
const
|
|
68
|
-
|
|
68
|
+
const r = K.value[t.value];
|
|
69
|
+
r && !r.disabled && (m.value = r.value, (y = r.onSelect) == null || y.call(r, r), e == null || e(r), $());
|
|
69
70
|
}
|
|
70
|
-
function
|
|
71
|
+
function j(r) {
|
|
71
72
|
var y;
|
|
72
|
-
for (const
|
|
73
|
-
if (
|
|
74
|
-
const g = ge(
|
|
75
|
-
if (
|
|
76
|
-
|
|
73
|
+
for (const h of f.value) {
|
|
74
|
+
if (h.disabled || !h.shortcut) continue;
|
|
75
|
+
const g = ge(h.shortcut);
|
|
76
|
+
if (_e(r, g)) {
|
|
77
|
+
r.preventDefault(), r.stopPropagation(), m.value = h.value, (y = h.onSelect) == null || y.call(h, h), e == null || e(h), $();
|
|
77
78
|
return;
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
let E = null;
|
|
82
83
|
return k(
|
|
83
|
-
|
|
84
|
-
(
|
|
85
|
-
E && (E(), E = null),
|
|
84
|
+
f,
|
|
85
|
+
(r) => {
|
|
86
|
+
E && (E(), E = null), r.some((h) => h.shortcut) && typeof window < "u" && (window.addEventListener("keydown", j), E = () => window.removeEventListener("keydown", j));
|
|
86
87
|
},
|
|
87
|
-
{ immediate: !0
|
|
88
|
+
{ immediate: !0 }
|
|
88
89
|
), ie(() => {
|
|
89
90
|
E && E();
|
|
90
91
|
}), {
|
|
91
|
-
visible:
|
|
92
|
+
visible: c,
|
|
92
93
|
searchQuery: n,
|
|
93
94
|
activeIndex: t,
|
|
94
|
-
selectedValue:
|
|
95
|
-
items:
|
|
96
|
-
toggle:
|
|
97
|
-
open:
|
|
98
|
-
close:
|
|
99
|
-
defaultFilter:
|
|
100
|
-
groupItems:
|
|
101
|
-
filteredItems:
|
|
102
|
-
groupedItems:
|
|
103
|
-
selectNext:
|
|
104
|
-
selectPrev:
|
|
105
|
-
selectCurrent:
|
|
95
|
+
selectedValue: m,
|
|
96
|
+
items: f,
|
|
97
|
+
toggle: S,
|
|
98
|
+
open: s,
|
|
99
|
+
close: $,
|
|
100
|
+
defaultFilter: _,
|
|
101
|
+
groupItems: O,
|
|
102
|
+
filteredItems: K,
|
|
103
|
+
groupedItems: le,
|
|
104
|
+
selectNext: ne,
|
|
105
|
+
selectPrev: se,
|
|
106
|
+
selectCurrent: ue
|
|
106
107
|
};
|
|
107
108
|
}
|
|
108
|
-
const
|
|
109
|
-
function J(
|
|
109
|
+
const N = Symbol("cmdk-state"), X = Symbol("cmdk-loading"), be = Symbol("cmdk-close-on-select"), U = Symbol("cmdk-select-handler"), Y = Symbol("cmdk-item-index-map");
|
|
110
|
+
function J(a, e, o) {
|
|
110
111
|
const {
|
|
111
|
-
filter:
|
|
112
|
-
loading:
|
|
112
|
+
filter: i,
|
|
113
|
+
loading: u = !1,
|
|
113
114
|
closeOnSelect: l = !0,
|
|
114
|
-
shouldFilter:
|
|
115
|
+
shouldFilter: c = !0,
|
|
115
116
|
loop: n = !0
|
|
116
|
-
} =
|
|
117
|
-
e("select",
|
|
117
|
+
} = a, m = ke({ filter: i, shouldFilter: c, loop: n }, (s) => {
|
|
118
|
+
e("select", s), e("update:value", s.value), l && m.close();
|
|
118
119
|
});
|
|
119
120
|
k(
|
|
120
|
-
() =>
|
|
121
|
-
(
|
|
122
|
-
|
|
121
|
+
() => a.value,
|
|
122
|
+
(s) => {
|
|
123
|
+
s !== void 0 && (m.selectedValue.value = s);
|
|
123
124
|
},
|
|
124
125
|
{ immediate: !0 }
|
|
125
|
-
),
|
|
126
|
-
e("select",
|
|
126
|
+
), T(N, m), T(X, () => u), T(be, () => l), T(U, (s) => {
|
|
127
|
+
e("select", s), e("update:value", s.value), l && m.close();
|
|
127
128
|
});
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
-
return
|
|
129
|
+
const f = b(() => {
|
|
130
|
+
const s = /* @__PURE__ */ new Map();
|
|
131
|
+
return m.filteredItems.value.forEach(($, _) => s.set($.value, _)), s;
|
|
131
132
|
});
|
|
132
|
-
|
|
133
|
-
function
|
|
134
|
-
e("select",
|
|
133
|
+
T(Y, () => f.value);
|
|
134
|
+
function S(s) {
|
|
135
|
+
e("select", s), e("update:value", s.value), l && m.close();
|
|
135
136
|
}
|
|
136
|
-
return { state:
|
|
137
|
+
return { state: m, handleSelect: S };
|
|
137
138
|
}
|
|
138
|
-
const Ce = {
|
|
139
|
-
"data-cmdk-root": "",
|
|
140
|
-
role: "combobox",
|
|
141
|
-
"aria-expanded": "true",
|
|
142
|
-
"aria-haspopup": "listbox"
|
|
143
|
-
}, Ie = /* @__PURE__ */ $({
|
|
139
|
+
const Ce = ["aria-expanded", "aria-label"], we = /* @__PURE__ */ I({
|
|
144
140
|
__name: "CommandMenu",
|
|
145
141
|
props: {
|
|
146
|
-
visible: { type: Boolean, default: !
|
|
142
|
+
visible: { type: Boolean, default: !1 },
|
|
147
143
|
searchQuery: {},
|
|
148
144
|
placeholder: { default: "Type a command or search..." },
|
|
149
145
|
filter: {},
|
|
@@ -156,161 +152,183 @@ const Ce = {
|
|
|
156
152
|
value: {}
|
|
157
153
|
},
|
|
158
154
|
emits: ["update:visible", "update:searchQuery", "update:value", "select"],
|
|
159
|
-
setup(
|
|
160
|
-
const
|
|
155
|
+
setup(a, { expose: e, emit: o }) {
|
|
156
|
+
const i = a, u = o, { state: l, handleSelect: c } = J(
|
|
161
157
|
{
|
|
162
|
-
filter:
|
|
163
|
-
loading:
|
|
164
|
-
closeOnSelect:
|
|
165
|
-
shouldFilter:
|
|
166
|
-
loop:
|
|
167
|
-
value:
|
|
158
|
+
filter: i.filter,
|
|
159
|
+
loading: i.loading,
|
|
160
|
+
closeOnSelect: i.closeOnSelect,
|
|
161
|
+
shouldFilter: i.shouldFilter,
|
|
162
|
+
loop: i.loop,
|
|
163
|
+
value: i.value
|
|
168
164
|
},
|
|
169
|
-
|
|
165
|
+
u
|
|
170
166
|
);
|
|
171
167
|
return k(
|
|
172
|
-
() =>
|
|
168
|
+
() => i.visible,
|
|
173
169
|
(n) => {
|
|
174
170
|
n !== void 0 && (l.visible.value = n);
|
|
175
171
|
},
|
|
176
172
|
{ immediate: !0 }
|
|
177
|
-
), k(l.visible, (n) =>
|
|
178
|
-
() =>
|
|
173
|
+
), k(l.visible, (n) => u("update:visible", n)), k(
|
|
174
|
+
() => i.searchQuery,
|
|
179
175
|
(n) => {
|
|
180
176
|
n !== void 0 && (l.searchQuery.value = n);
|
|
181
177
|
}
|
|
182
|
-
), k(l.searchQuery, (n) =>
|
|
178
|
+
), k(l.searchQuery, (n) => u("update:searchQuery", n)), e({
|
|
183
179
|
open: l.open,
|
|
184
180
|
close: l.close,
|
|
185
181
|
toggle: l.toggle,
|
|
186
182
|
searchQuery: l.searchQuery,
|
|
187
183
|
items: l.items,
|
|
188
184
|
filteredItems: l.filteredItems
|
|
189
|
-
}), (n, t) => (d(),
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
185
|
+
}), (n, t) => (d(), v("div", {
|
|
186
|
+
"data-cmdk-root": "",
|
|
187
|
+
role: "combobox",
|
|
188
|
+
"aria-expanded": p(l).visible.value,
|
|
189
|
+
"aria-label": a.label ?? "Command menu",
|
|
190
|
+
"aria-haspopup": "listbox"
|
|
191
|
+
}, [
|
|
192
|
+
x(n.$slots, "default", {
|
|
193
|
+
items: p(l).items,
|
|
194
|
+
filteredItems: p(l).filteredItems,
|
|
195
|
+
searchQuery: p(l).searchQuery,
|
|
196
|
+
selectNext: p(l).selectNext,
|
|
197
|
+
selectPrev: p(l).selectPrev,
|
|
198
|
+
selectCurrent: p(l).selectCurrent,
|
|
199
|
+
handleSelect: p(c)
|
|
198
200
|
})
|
|
199
|
-
]));
|
|
201
|
+
], 8, Ce));
|
|
200
202
|
}
|
|
201
203
|
});
|
|
202
|
-
function
|
|
203
|
-
const
|
|
204
|
-
if (
|
|
204
|
+
function F(a, e) {
|
|
205
|
+
const o = P(a);
|
|
206
|
+
if (o == null)
|
|
205
207
|
throw new Error(
|
|
206
208
|
`[vue-cmdk] <${e}> must be used inside <CommandMenu> or <CommandDialog>.`
|
|
207
209
|
);
|
|
208
|
-
return
|
|
210
|
+
return o;
|
|
209
211
|
}
|
|
210
|
-
const
|
|
212
|
+
const Ie = ["value", "placeholder", "aria-activedescendant", "autofocus"], W = /* @__PURE__ */ I({
|
|
211
213
|
__name: "CommandInput",
|
|
212
214
|
props: {
|
|
213
215
|
placeholder: { default: "Type a command or search..." },
|
|
214
216
|
autoFocus: { type: Boolean, default: !0 }
|
|
215
217
|
},
|
|
216
|
-
setup(
|
|
217
|
-
const
|
|
218
|
-
}),
|
|
219
|
-
e({ inputRef:
|
|
220
|
-
const l =
|
|
221
|
-
const t =
|
|
218
|
+
setup(a, { expose: e }) {
|
|
219
|
+
const o = F(N, "CommandInput"), i = P(U, () => {
|
|
220
|
+
}), u = M(null);
|
|
221
|
+
e({ inputRef: u });
|
|
222
|
+
const l = b(() => {
|
|
223
|
+
const t = o.filteredItems.value[o.activeIndex.value];
|
|
222
224
|
return t ? `cmdk-item-${t.value}` : void 0;
|
|
223
225
|
});
|
|
224
|
-
function
|
|
225
|
-
const
|
|
226
|
-
|
|
226
|
+
function c(t) {
|
|
227
|
+
const m = t.target;
|
|
228
|
+
m && (o.searchQuery.value = m.value, o.activeIndex.value = 0);
|
|
227
229
|
}
|
|
228
230
|
function n(t) {
|
|
229
|
-
var
|
|
231
|
+
var m;
|
|
230
232
|
if (t.key === "ArrowDown")
|
|
231
|
-
t.preventDefault(),
|
|
233
|
+
t.preventDefault(), o.selectNext();
|
|
232
234
|
else if (t.key === "ArrowUp")
|
|
233
|
-
t.preventDefault(),
|
|
235
|
+
t.preventDefault(), o.selectPrev();
|
|
234
236
|
else if (t.key === "Enter") {
|
|
235
237
|
t.preventDefault();
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
+
const f = o.filteredItems.value[o.activeIndex.value];
|
|
239
|
+
f && !f.disabled && ((m = f.onSelect) == null || m.call(f, f), i(f));
|
|
238
240
|
}
|
|
239
241
|
}
|
|
240
|
-
return (t,
|
|
242
|
+
return (t, m) => (d(), v("input", {
|
|
241
243
|
ref_key: "inputRef",
|
|
242
|
-
ref:
|
|
244
|
+
ref: u,
|
|
243
245
|
"data-cmdk-input": "",
|
|
244
|
-
value:
|
|
245
|
-
placeholder:
|
|
246
|
+
value: p(o).searchQuery.value,
|
|
247
|
+
placeholder: a.placeholder,
|
|
246
248
|
role: "searchbox",
|
|
247
249
|
"aria-activedescendant": l.value,
|
|
248
250
|
autocomplete: "off",
|
|
249
251
|
autocorrect: "off",
|
|
250
252
|
spellcheck: "false",
|
|
251
|
-
autofocus:
|
|
252
|
-
onInput:
|
|
253
|
+
autofocus: a.autoFocus,
|
|
254
|
+
onInput: c,
|
|
253
255
|
onKeydown: n
|
|
254
|
-
}, null, 40,
|
|
256
|
+
}, null, 40, Ie));
|
|
255
257
|
}
|
|
256
|
-
}),
|
|
258
|
+
}), Se = {
|
|
257
259
|
key: 0,
|
|
258
260
|
"data-cmdk-empty": ""
|
|
259
|
-
}, Z = /* @__PURE__ */
|
|
261
|
+
}, Z = /* @__PURE__ */ I({
|
|
260
262
|
__name: "CommandEmpty",
|
|
261
|
-
setup(
|
|
262
|
-
const e =
|
|
263
|
-
return (
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
setup(a) {
|
|
264
|
+
const e = F(N, "CommandEmpty");
|
|
265
|
+
return (o, i) => p(e).searchQuery.value && p(e).filteredItems.value.length === 0 ? (d(), v("div", Se, [
|
|
266
|
+
x(o.$slots, "default", {}, () => [
|
|
267
|
+
i[0] || (i[0] = w("span", null, "No results found.", -1))
|
|
266
268
|
])
|
|
267
|
-
])) :
|
|
269
|
+
])) : L("", !0);
|
|
268
270
|
}
|
|
269
271
|
}), $e = {
|
|
270
272
|
key: 0,
|
|
271
273
|
"data-cmdk-loading": ""
|
|
272
|
-
},
|
|
274
|
+
}, q = /* @__PURE__ */ I({
|
|
273
275
|
__name: "CommandLoading",
|
|
274
276
|
props: {
|
|
275
277
|
loading: { type: Boolean }
|
|
276
278
|
},
|
|
277
|
-
setup(
|
|
278
|
-
return (e,
|
|
279
|
-
|
|
280
|
-
|
|
279
|
+
setup(a) {
|
|
280
|
+
return (e, o) => a.loading ? (d(), v("div", $e, [
|
|
281
|
+
x(e.$slots, "default", {}, () => [
|
|
282
|
+
o[0] || (o[0] = w("span", null, "Loading...", -1))
|
|
281
283
|
])
|
|
282
|
-
])) :
|
|
284
|
+
])) : L("", !0);
|
|
283
285
|
}
|
|
284
286
|
}), xe = {
|
|
285
287
|
"data-cmdk-group": "",
|
|
286
288
|
role: "group"
|
|
287
|
-
},
|
|
289
|
+
}, Le = {
|
|
288
290
|
key: 0,
|
|
289
291
|
"data-cmdk-group-heading": "",
|
|
290
292
|
role: "presentation"
|
|
291
|
-
},
|
|
293
|
+
}, Me = {
|
|
292
294
|
"data-cmdk-group-items": "",
|
|
293
295
|
role: "group"
|
|
294
|
-
},
|
|
296
|
+
}, ee = /* @__PURE__ */ I({
|
|
295
297
|
__name: "CommandGroup",
|
|
296
298
|
props: {
|
|
297
|
-
heading: {}
|
|
299
|
+
heading: {},
|
|
300
|
+
forceMount: { type: Boolean }
|
|
298
301
|
},
|
|
299
|
-
setup(
|
|
300
|
-
return (e,
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
302
|
+
setup(a) {
|
|
303
|
+
return (e, o) => (d(), v("div", xe, [
|
|
304
|
+
a.heading ? (d(), v("div", Le, Q(a.heading), 1)) : L("", !0),
|
|
305
|
+
w("div", Me, [
|
|
306
|
+
x(e.$slots, "default")
|
|
304
307
|
])
|
|
305
308
|
]));
|
|
306
309
|
}
|
|
307
|
-
})
|
|
310
|
+
});
|
|
311
|
+
function Ee(a, e) {
|
|
312
|
+
if (!e.trim()) return [{ text: a, highlighted: !1 }];
|
|
313
|
+
const o = a.toLowerCase(), i = e.toLowerCase(), u = [];
|
|
314
|
+
let l = 0;
|
|
315
|
+
for (; l < a.length; ) {
|
|
316
|
+
const c = o.indexOf(i, l);
|
|
317
|
+
if (c === -1) {
|
|
318
|
+
u.push({ text: a.slice(l), highlighted: !1 });
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
c > l && u.push({ text: a.slice(l, c), highlighted: !1 }), u.push({ text: a.slice(c, c + e.length), highlighted: !0 }), l = c + e.length;
|
|
322
|
+
}
|
|
323
|
+
return u;
|
|
324
|
+
}
|
|
325
|
+
const De = ["id", "aria-selected", "aria-disabled", "data-value"], Qe = {
|
|
308
326
|
key: 0,
|
|
309
327
|
"data-cmdk-item-icon": ""
|
|
310
|
-
},
|
|
328
|
+
}, Be = { "data-cmdk-item-label": "" }, Ke = { key: 0 }, Te = { key: 1 }, Fe = {
|
|
311
329
|
key: 1,
|
|
312
330
|
"data-cmdk-item-shortcut": ""
|
|
313
|
-
},
|
|
331
|
+
}, te = /* @__PURE__ */ I({
|
|
314
332
|
__name: "CommandItem",
|
|
315
333
|
props: {
|
|
316
334
|
value: {},
|
|
@@ -318,98 +336,111 @@ const Se = ["value", "placeholder", "aria-activedescendant", "autofocus"], W = /
|
|
|
318
336
|
keywords: { default: void 0 },
|
|
319
337
|
shortcut: { default: void 0 },
|
|
320
338
|
disabled: { type: Boolean, default: !1 },
|
|
339
|
+
forceMount: { type: Boolean, default: !1 },
|
|
321
340
|
icon: { type: [Object, Function], default: void 0 },
|
|
322
341
|
onSelect: { type: Function, default: void 0 }
|
|
323
342
|
},
|
|
324
|
-
setup(
|
|
325
|
-
const e =
|
|
343
|
+
setup(a) {
|
|
344
|
+
const e = a, o = F(N, "CommandItem"), i = P(Y, () => /* @__PURE__ */ new Map()), u = b(() => `cmdk-item-${e.value}`), l = b(() => ({
|
|
326
345
|
value: e.value,
|
|
327
346
|
label: e.label,
|
|
328
347
|
keywords: e.keywords,
|
|
329
348
|
shortcut: e.shortcut,
|
|
330
349
|
disabled: e.disabled,
|
|
350
|
+
forceMount: e.forceMount,
|
|
331
351
|
icon: e.icon,
|
|
332
352
|
onSelect: e.onSelect
|
|
333
|
-
})),
|
|
334
|
-
const
|
|
335
|
-
return (
|
|
336
|
-
}), t =
|
|
353
|
+
})), c = b(() => e.icon ? ce(e.icon) ? () => e.icon : e.icon : null), n = b(() => {
|
|
354
|
+
const s = o.filteredItems.value[o.activeIndex.value];
|
|
355
|
+
return (s == null ? void 0 : s.value) === e.value;
|
|
356
|
+
}), t = P(U, () => {
|
|
357
|
+
}), m = b(() => e.label || e.value), f = b(() => {
|
|
358
|
+
const s = o.searchQuery.value;
|
|
359
|
+
return s.trim() ? Ee(m.value, s) : null;
|
|
337
360
|
});
|
|
338
|
-
function
|
|
339
|
-
var
|
|
340
|
-
e.disabled || ((
|
|
361
|
+
function S() {
|
|
362
|
+
var s;
|
|
363
|
+
e.disabled || ((s = e.onSelect) == null || s.call(e, l.value), t(l.value));
|
|
341
364
|
}
|
|
342
|
-
return (
|
|
343
|
-
id:
|
|
365
|
+
return (s, $) => (d(), v("div", {
|
|
366
|
+
id: u.value,
|
|
344
367
|
"data-cmdk-item": "",
|
|
345
368
|
role: "option",
|
|
346
369
|
"aria-selected": n.value,
|
|
347
|
-
"aria-disabled":
|
|
348
|
-
"data-value":
|
|
349
|
-
class:
|
|
350
|
-
onClick:
|
|
351
|
-
onPointerenter:
|
|
352
|
-
const
|
|
353
|
-
|
|
370
|
+
"aria-disabled": a.disabled,
|
|
371
|
+
"data-value": a.value,
|
|
372
|
+
class: de({ active: n.value, disabled: a.disabled }),
|
|
373
|
+
onClick: S,
|
|
374
|
+
onPointerenter: $[0] || ($[0] = () => {
|
|
375
|
+
const _ = p(i)().get(a.value);
|
|
376
|
+
_ !== void 0 && (p(o).activeIndex.value = _);
|
|
354
377
|
})
|
|
355
378
|
}, [
|
|
356
|
-
|
|
379
|
+
x(s.$slots, "default", {
|
|
357
380
|
item: l.value,
|
|
358
381
|
active: n.value
|
|
359
382
|
}, () => [
|
|
360
|
-
|
|
361
|
-
(d(),
|
|
362
|
-
])) :
|
|
363
|
-
|
|
364
|
-
|
|
383
|
+
c.value ? (d(), v("span", Qe, [
|
|
384
|
+
(d(), V(fe(c.value)))
|
|
385
|
+
])) : L("", !0),
|
|
386
|
+
w("span", Be, [
|
|
387
|
+
f.value ? (d(!0), v(C, { key: 0 }, G(f.value, (_, O) => (d(), v(C, { key: O }, [
|
|
388
|
+
_.highlighted ? (d(), v("mark", Ke, Q(_.text), 1)) : (d(), v("span", Te, Q(_.text), 1))
|
|
389
|
+
], 64))), 128)) : (d(), v(C, { key: 1 }, [
|
|
390
|
+
A(Q(m.value), 1)
|
|
391
|
+
], 64))
|
|
392
|
+
]),
|
|
393
|
+
a.shortcut ? (d(), v("span", Fe, Q(a.shortcut), 1)) : L("", !0)
|
|
365
394
|
])
|
|
366
|
-
], 42,
|
|
395
|
+
], 42, De));
|
|
367
396
|
}
|
|
368
|
-
}),
|
|
369
|
-
const a = o.__vccOpts || o;
|
|
370
|
-
for (const [s, r] of e)
|
|
371
|
-
a[s] = r;
|
|
372
|
-
return a;
|
|
373
|
-
}, Fe = {}, Ne = {
|
|
397
|
+
}), Ne = {
|
|
374
398
|
"data-cmdk-separator": "",
|
|
375
399
|
role: "separator"
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
|
|
400
|
+
}, ae = /* @__PURE__ */ I({
|
|
401
|
+
__name: "CommandSeparator",
|
|
402
|
+
props: {
|
|
403
|
+
alwaysRender: { type: Boolean }
|
|
404
|
+
},
|
|
405
|
+
setup(a) {
|
|
406
|
+
return (e, o) => (d(), v("div", Ne));
|
|
407
|
+
}
|
|
408
|
+
}), Oe = {
|
|
381
409
|
"data-cmdk-list": "",
|
|
382
410
|
role: "listbox"
|
|
383
411
|
}, Re = {
|
|
384
412
|
"aria-live": "polite",
|
|
385
413
|
"aria-atomic": "true",
|
|
386
414
|
class: "sr-only"
|
|
387
|
-
},
|
|
415
|
+
}, oe = /* @__PURE__ */ I({
|
|
388
416
|
__name: "CommandList",
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
417
|
+
props: {
|
|
418
|
+
alwaysRenderSeparator: { type: Boolean }
|
|
419
|
+
},
|
|
420
|
+
setup(a) {
|
|
421
|
+
const e = F(N, "CommandList"), o = F(X, "CommandList");
|
|
422
|
+
return (i, u) => (d(), v("div", Oe, [
|
|
423
|
+
w("div", Re, [
|
|
424
|
+
p(e).searchQuery.value && p(e).filteredItems.value.length === 0 ? (d(), v(C, { key: 0 }, [
|
|
425
|
+
A("No results found")
|
|
426
|
+
], 64)) : p(o)() ? (d(), v(C, { key: 1 }, [
|
|
427
|
+
A("Loading")
|
|
428
|
+
], 64)) : (d(), v(C, { key: 2 }, [
|
|
429
|
+
A(Q(p(e).filteredItems.value.length) + " items", 1)
|
|
399
430
|
], 64))
|
|
400
431
|
]),
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
loading:
|
|
432
|
+
B(Z),
|
|
433
|
+
B(q, {
|
|
434
|
+
loading: p(o)()
|
|
404
435
|
}, null, 8, ["loading"]),
|
|
405
|
-
(d(!0),
|
|
436
|
+
(d(!0), v(C, null, G(p(e).groupedItems.value, (l, c) => (d(), v(C, {
|
|
406
437
|
key: l.heading || "__ungrouped__"
|
|
407
438
|
}, [
|
|
408
|
-
|
|
439
|
+
B(ee, {
|
|
409
440
|
heading: l.heading
|
|
410
441
|
}, {
|
|
411
|
-
default:
|
|
412
|
-
(d(!0),
|
|
442
|
+
default: H(() => [
|
|
443
|
+
(d(!0), v(C, null, G(l.items, (n) => (d(), V(te, {
|
|
413
444
|
key: n.value,
|
|
414
445
|
value: n.value,
|
|
415
446
|
label: n.label,
|
|
@@ -422,17 +453,18 @@ const ae = /* @__PURE__ */ Be(Fe, [["render", Oe]]), Te = {
|
|
|
422
453
|
]),
|
|
423
454
|
_: 2
|
|
424
455
|
}, 1032, ["heading"]),
|
|
425
|
-
|
|
456
|
+
a.alwaysRenderSeparator || c !== p(e).groupedItems.value.length - 1 ? (d(), V(ae, { key: 0 })) : L("", !0)
|
|
426
457
|
], 64))), 128))
|
|
427
458
|
]));
|
|
428
459
|
}
|
|
429
460
|
}), Ae = ["aria-label"], Pe = { "data-cmdk-dialog-wrapper": "" }, Ve = { "data-cmdk-dialog-header": "" }, Ge = { "data-cmdk-dialog-body": "" }, Ue = {
|
|
430
461
|
key: 0,
|
|
431
462
|
"data-cmdk-dialog-footer": ""
|
|
432
|
-
}, je = /* @__PURE__ */
|
|
463
|
+
}, je = /* @__PURE__ */ I({
|
|
433
464
|
__name: "CommandDialog",
|
|
434
465
|
props: {
|
|
435
466
|
items: { default: () => [] },
|
|
467
|
+
container: {},
|
|
436
468
|
visible: { type: Boolean, default: !1 },
|
|
437
469
|
searchQuery: {},
|
|
438
470
|
placeholder: { default: "Type a command or search..." },
|
|
@@ -446,115 +478,117 @@ const ae = /* @__PURE__ */ Be(Fe, [["render", Oe]]), Te = {
|
|
|
446
478
|
value: {}
|
|
447
479
|
},
|
|
448
480
|
emits: ["update:visible", "update:searchQuery", "update:value", "select"],
|
|
449
|
-
setup(
|
|
450
|
-
const
|
|
481
|
+
setup(a, { emit: e }) {
|
|
482
|
+
const o = a, i = e, { state: u } = J(
|
|
451
483
|
{
|
|
452
|
-
filter:
|
|
453
|
-
loading:
|
|
454
|
-
closeOnSelect:
|
|
455
|
-
shouldFilter:
|
|
456
|
-
loop:
|
|
457
|
-
value:
|
|
484
|
+
filter: o.filter,
|
|
485
|
+
loading: o.loading,
|
|
486
|
+
closeOnSelect: o.closeOnSelect,
|
|
487
|
+
shouldFilter: o.shouldFilter,
|
|
488
|
+
loop: o.loop,
|
|
489
|
+
value: o.value
|
|
458
490
|
},
|
|
459
|
-
|
|
460
|
-
), l =
|
|
491
|
+
i
|
|
492
|
+
), l = M(null);
|
|
461
493
|
k(
|
|
462
|
-
() =>
|
|
494
|
+
() => o.items,
|
|
463
495
|
(t) => {
|
|
464
|
-
|
|
496
|
+
u.items.value = t;
|
|
465
497
|
},
|
|
466
498
|
{ immediate: !0 }
|
|
467
499
|
), k(
|
|
468
|
-
() =>
|
|
500
|
+
() => o.visible,
|
|
469
501
|
(t) => {
|
|
470
|
-
|
|
502
|
+
u.visible.value = t;
|
|
471
503
|
},
|
|
472
504
|
{ immediate: !0 }
|
|
473
505
|
), k(
|
|
474
|
-
() =>
|
|
506
|
+
() => o.searchQuery,
|
|
475
507
|
(t) => {
|
|
476
|
-
t !== void 0 && (
|
|
508
|
+
t !== void 0 && (u.searchQuery.value = t);
|
|
477
509
|
}
|
|
478
|
-
), k(
|
|
479
|
-
var
|
|
480
|
-
|
|
510
|
+
), k(u.searchQuery, (t) => i("update:searchQuery", t)), k(u.visible, async (t) => {
|
|
511
|
+
var m, f;
|
|
512
|
+
i("update:visible", t), t && (await me(), (f = (m = l.value) == null ? void 0 : m.inputRef) == null || f.focus());
|
|
481
513
|
});
|
|
482
|
-
function
|
|
483
|
-
t.target === t.currentTarget &&
|
|
514
|
+
function c(t) {
|
|
515
|
+
t.target === t.currentTarget && u.close();
|
|
484
516
|
}
|
|
485
517
|
function n(t) {
|
|
486
|
-
if (t.key === "Escape" && (t.preventDefault(),
|
|
487
|
-
const
|
|
518
|
+
if (t.key === "Escape" && (t.preventDefault(), u.close()), t.key === "Tab") {
|
|
519
|
+
const f = t.currentTarget.querySelectorAll(
|
|
488
520
|
'input, button, [href], select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
489
521
|
);
|
|
490
|
-
if (
|
|
491
|
-
const
|
|
492
|
-
t.shiftKey ? document.activeElement ===
|
|
522
|
+
if (f.length === 0) return;
|
|
523
|
+
const S = f[0], s = f[f.length - 1];
|
|
524
|
+
t.shiftKey ? document.activeElement === S && (t.preventDefault(), s.focus()) : document.activeElement === s && (t.preventDefault(), S.focus());
|
|
493
525
|
}
|
|
494
526
|
}
|
|
495
|
-
return (t,
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
527
|
+
return (t, m) => (d(), V(ve, {
|
|
528
|
+
to: a.container ?? "body"
|
|
529
|
+
}, [
|
|
530
|
+
B(pe, { name: "cmdk-dialog" }, {
|
|
531
|
+
default: H(() => [
|
|
532
|
+
p(u).visible.value ? (d(), v("div", {
|
|
499
533
|
key: 0,
|
|
500
534
|
"data-cmdk-dialog": "",
|
|
501
535
|
role: "dialog",
|
|
502
536
|
"aria-modal": "true",
|
|
503
|
-
"aria-label":
|
|
537
|
+
"aria-label": o.label ?? "Command menu",
|
|
504
538
|
onKeydown: n
|
|
505
539
|
}, [
|
|
506
|
-
|
|
540
|
+
w("div", {
|
|
507
541
|
"data-cmdk-dialog-mask": "",
|
|
508
542
|
"aria-hidden": "true",
|
|
509
|
-
onClick:
|
|
543
|
+
onClick: c
|
|
510
544
|
}),
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
545
|
+
w("div", Pe, [
|
|
546
|
+
w("div", Ve, [
|
|
547
|
+
x(t.$slots, "header", {}, () => [
|
|
548
|
+
B(W, {
|
|
515
549
|
ref_key: "commandInputRef",
|
|
516
550
|
ref: l,
|
|
517
|
-
placeholder:
|
|
518
|
-
"auto-focus":
|
|
551
|
+
placeholder: a.placeholder,
|
|
552
|
+
"auto-focus": a.autoFocus
|
|
519
553
|
}, null, 8, ["placeholder", "auto-focus"])
|
|
520
554
|
])
|
|
521
555
|
]),
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
556
|
+
w("div", Ge, [
|
|
557
|
+
x(t.$slots, "body", {}, () => [
|
|
558
|
+
B(oe)
|
|
525
559
|
])
|
|
526
560
|
]),
|
|
527
|
-
t.$slots.footer ? (d(),
|
|
528
|
-
|
|
529
|
-
])) :
|
|
561
|
+
t.$slots.footer ? (d(), v("div", Ue, [
|
|
562
|
+
x(t.$slots, "footer")
|
|
563
|
+
])) : L("", !0)
|
|
530
564
|
])
|
|
531
|
-
], 40, Ae)) :
|
|
565
|
+
], 40, Ae)) : L("", !0)
|
|
532
566
|
]),
|
|
533
567
|
_: 3
|
|
534
568
|
})
|
|
535
|
-
]));
|
|
569
|
+
], 8, ["to"]));
|
|
536
570
|
}
|
|
537
|
-
}),
|
|
538
|
-
Menu:
|
|
571
|
+
}), He = {
|
|
572
|
+
Menu: we,
|
|
539
573
|
Dialog: je,
|
|
540
574
|
Input: W,
|
|
541
|
-
List:
|
|
542
|
-
Group:
|
|
543
|
-
Item:
|
|
575
|
+
List: oe,
|
|
576
|
+
Group: ee,
|
|
577
|
+
Item: te,
|
|
544
578
|
Empty: Z,
|
|
545
579
|
Separator: ae,
|
|
546
|
-
Loading:
|
|
580
|
+
Loading: q
|
|
547
581
|
};
|
|
548
582
|
export {
|
|
549
|
-
|
|
583
|
+
He as Command,
|
|
550
584
|
je as CommandDialog,
|
|
551
585
|
Z as CommandEmpty,
|
|
552
|
-
|
|
586
|
+
ee as CommandGroup,
|
|
553
587
|
W as CommandInput,
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
588
|
+
te as CommandItem,
|
|
589
|
+
oe as CommandList,
|
|
590
|
+
q as CommandLoading,
|
|
591
|
+
we as CommandMenu,
|
|
558
592
|
ae as CommandSeparator,
|
|
559
|
-
|
|
593
|
+
ke as useCommandMenu
|
|
560
594
|
};
|