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