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