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