vue-command-palette
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -1,6 +0,11 @@ | ||
import type { ItemInfo } from './types'; | ||
declare const _sfc_main: import("vue").DefineComponent<Readonly<import("vue").ExtractPropTypes<{}>>, { | ||
import type { ItemInfo, Noop } from './types'; | ||
declare const _sfc_main: import("vue").DefineComponent<{}, { | ||
SELECT_EVENT: string; | ||
VALUE_ATTR: string; | ||
props: { | ||
shortcut?: string[] | undefined; | ||
perform?: Noop | undefined; | ||
}; | ||
emit: (e: 'select', itemInfo: ItemInfo) => void; | ||
current: Set<string>; | ||
selectedNode: import("vue").Ref<string>; | ||
@@ -20,6 +25,7 @@ filtered: import("vue").Ref<{ | ||
isRender: import("vue").ComputedRef<boolean>; | ||
currentKeys: import("vue").ComputedRef<string[]>; | ||
handleSelect: () => void; | ||
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "select"[], "select", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<Readonly<import("vue").ExtractPropTypes<{}>>>> & { | ||
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "select"[], "select", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>> & { | ||
onSelect?: ((...args: any[]) => any) | undefined; | ||
}, {}>; | ||
export default _sfc_main; |
@@ -16,1 +16,2 @@ import type { DefineComponent } from 'vue'; | ||
}; | ||
export declare type Noop = () => void; |
@@ -1,85 +0,215 @@ | ||
import { ref as N, watch as ae, unref as L, reactive as Ze, computed as K, toRefs as qe, defineComponent as S, provide as et, nextTick as te, onMounted as tt, openBlock as F, createElementBlock as W, normalizeClass as st, createElementVNode as V, renderSlot as z, onBeforeUnmount as _e, createBlock as we, Teleport as nt, createVNode as rt, Transition as it, withCtx as xe, createCommentVNode as le, withDirectives as Oe, toDisplayString as ot, vShow as Ne, watchEffect as ve, h as ne } from "vue"; | ||
var be; | ||
const ct = typeof window < "u"; | ||
ct && ((be = window == null ? void 0 : window.navigator) == null ? void 0 : be.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent); | ||
function Ae(s) { | ||
return typeof s == "function" ? s() : L(s); | ||
import { ref as T, watch as ee, getCurrentScope as lt, onScopeDispose as ut, unref as O, reactive as he, computed as $, toRefs as ht, defineComponent as x, provide as dt, nextTick as ne, onMounted as ft, openBlock as D, createElementBlock as H, normalizeClass as mt, createElementVNode as B, renderSlot as Q, onBeforeUnmount as we, createBlock as Oe, Teleport as pt, createVNode as gt, Transition as _t, withCtx as ke, createCommentVNode as de, withDirectives as Be, toDisplayString as vt, vShow as Ge, watchEffect as Me, h as ie } from "vue"; | ||
var Ce; | ||
const We = typeof window < "u", yt = (n) => typeof n == "string", oe = () => { | ||
}; | ||
We && ((Ce = window == null ? void 0 : window.navigator) == null ? void 0 : Ce.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent); | ||
function fe(n) { | ||
return typeof n == "function" ? n() : O(n); | ||
} | ||
function at(s, e) { | ||
function t(...n) { | ||
s(() => e.apply(this, n), { fn: e, thisArg: this, args: n }); | ||
function Et(n, e) { | ||
function t(...s) { | ||
n(() => e.apply(this, s), { fn: e, thisArg: this, args: s }); | ||
} | ||
return t; | ||
} | ||
function lt(s, e = {}) { | ||
let t, n; | ||
return (i) => { | ||
const o = Ae(s), c = Ae(e.maxWait); | ||
if (t && clearTimeout(t), o <= 0 || c !== void 0 && c <= 0) | ||
return n && (clearTimeout(n), n = null), i(); | ||
c && !n && (n = setTimeout(() => { | ||
t && clearTimeout(t), n = null, i(); | ||
}, c)), t = setTimeout(() => { | ||
n && clearTimeout(n), n = null, i(); | ||
}, o); | ||
function It(n, e = {}) { | ||
let t, s; | ||
return (o) => { | ||
const i = fe(n), a = fe(e.maxWait); | ||
if (t && clearTimeout(t), i <= 0 || a !== void 0 && a <= 0) | ||
return s && (clearTimeout(s), s = null), o(); | ||
a && !s && (s = setTimeout(() => { | ||
t && clearTimeout(t), s = null, o(); | ||
}, a)), t = setTimeout(() => { | ||
s && clearTimeout(s), s = null, o(); | ||
}, i); | ||
}; | ||
} | ||
function Fe(s, e = 200, t = {}) { | ||
return at(lt(e, t), s); | ||
function St(n) { | ||
return n; | ||
} | ||
function oe(s, e = 200, t = {}) { | ||
function wt(n) { | ||
return lt() ? (ut(n), !0) : !1; | ||
} | ||
function Ue(n, e = 200, t = {}) { | ||
return Et(It(e, t), n); | ||
} | ||
function le(n, e = 200, t = {}) { | ||
if (e <= 0) | ||
return s; | ||
const n = N(s.value), r = Fe(() => { | ||
n.value = s.value; | ||
return n; | ||
const s = T(n.value), r = Ue(() => { | ||
s.value = n.value; | ||
}, e, t); | ||
return ae(s, () => r()), n; | ||
return ee(n, () => r()), s; | ||
} | ||
function P(s) { | ||
return Array.isArray ? Array.isArray(s) : De(s) === "[object Array]"; | ||
function ze(n, e, t) { | ||
return ee(n, (s, r, o) => { | ||
s && e(s, r, o); | ||
}, t); | ||
} | ||
const ut = 1 / 0; | ||
function ht(s) { | ||
if (typeof s == "string") | ||
return s; | ||
let e = s + ""; | ||
return e == "0" && 1 / s == -ut ? "-0" : e; | ||
function Mt(n) { | ||
var e; | ||
const t = fe(n); | ||
return (e = t == null ? void 0 : t.$el) != null ? e : t; | ||
} | ||
function dt(s) { | ||
return s == null ? "" : ht(s); | ||
const Qe = We ? window : void 0; | ||
function se(...n) { | ||
let e, t, s, r; | ||
if (yt(n[0]) ? ([t, s, r] = n, e = Qe) : [e, t, s, r] = n, !e) | ||
return oe; | ||
let o = oe; | ||
const i = ee(() => Mt(e), (c) => { | ||
o(), c && (c.addEventListener(t, s, r), o = () => { | ||
c.removeEventListener(t, s, r), o = oe; | ||
}); | ||
}, { immediate: !0, flush: "post" }), a = () => { | ||
i(), o(); | ||
}; | ||
return wt(a), a; | ||
} | ||
function T(s) { | ||
return typeof s == "string"; | ||
const me = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, pe = "__vueuse_ssr_handlers__"; | ||
me[pe] = me[pe] || {}; | ||
me[pe]; | ||
const bt = { | ||
ctrl: "control", | ||
command: "meta", | ||
cmd: "meta", | ||
option: "alt", | ||
up: "arrowup", | ||
down: "arrowdown", | ||
left: "arrowleft", | ||
right: "arrowright" | ||
}; | ||
function xt(n = {}) { | ||
const { | ||
reactive: e = !1, | ||
target: t = Qe, | ||
aliasMap: s = bt, | ||
passive: r = !0, | ||
onEventFired: o = oe | ||
} = n, i = he(/* @__PURE__ */ new Set()), a = { toJSON() { | ||
return {}; | ||
}, current: i }, c = e ? he(a) : a, u = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(); | ||
function d(f, g) { | ||
f in c && (e ? c[f] = g : c[f].value = g); | ||
} | ||
function p() { | ||
for (const f of h) | ||
d(f, !1); | ||
} | ||
function _(f, g) { | ||
var I, M; | ||
const S = (I = f.key) == null ? void 0 : I.toLowerCase(), W = [(M = f.code) == null ? void 0 : M.toLowerCase(), S].filter(Boolean); | ||
S && (g ? i.add(S) : i.delete(S)); | ||
for (const A of W) | ||
h.add(A), d(A, g); | ||
S === "meta" && !g ? (u.forEach((A) => { | ||
i.delete(A), d(A, !1); | ||
}), u.clear()) : typeof f.getModifierState == "function" && f.getModifierState("Meta") && g && [...i, ...W].forEach((A) => u.add(A)); | ||
} | ||
se(t, "keydown", (f) => (_(f, !0), o(f)), { passive: r }), se(t, "keyup", (f) => (_(f, !1), o(f)), { passive: r }), se("blur", p, { passive: !0 }), se("focus", p, { passive: !0 }); | ||
const y = new Proxy(c, { | ||
get(f, g, I) { | ||
if (typeof g != "string") | ||
return Reflect.get(f, g, I); | ||
if (g = g.toLowerCase(), g in s && (g = s[g]), !(g in c)) | ||
if (/[+_-]/.test(g)) { | ||
const S = g.split(/[+_-]/g).map((C) => C.trim()); | ||
c[g] = $(() => S.every((C) => O(y[C]))); | ||
} else | ||
c[g] = T(!1); | ||
const M = Reflect.get(f, g, I); | ||
return e ? O(M) : M; | ||
} | ||
}); | ||
return y; | ||
} | ||
function Ke(s) { | ||
return typeof s == "number"; | ||
var Te; | ||
(function(n) { | ||
n.UP = "UP", n.RIGHT = "RIGHT", n.DOWN = "DOWN", n.LEFT = "LEFT", n.NONE = "NONE"; | ||
})(Te || (Te = {})); | ||
var At = Object.defineProperty, $e = Object.getOwnPropertySymbols, Rt = Object.prototype.hasOwnProperty, Lt = Object.prototype.propertyIsEnumerable, Ne = (n, e, t) => e in n ? At(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, Ot = (n, e) => { | ||
for (var t in e || (e = {})) | ||
Rt.call(e, t) && Ne(n, t, e[t]); | ||
if ($e) | ||
for (var t of $e(e)) | ||
Lt.call(e, t) && Ne(n, t, e[t]); | ||
return n; | ||
}; | ||
const kt = { | ||
easeInSine: [0.12, 0, 0.39, 0], | ||
easeOutSine: [0.61, 1, 0.88, 1], | ||
easeInOutSine: [0.37, 0, 0.63, 1], | ||
easeInQuad: [0.11, 0, 0.5, 0], | ||
easeOutQuad: [0.5, 1, 0.89, 1], | ||
easeInOutQuad: [0.45, 0, 0.55, 1], | ||
easeInCubic: [0.32, 0, 0.67, 0], | ||
easeOutCubic: [0.33, 1, 0.68, 1], | ||
easeInOutCubic: [0.65, 0, 0.35, 1], | ||
easeInQuart: [0.5, 0, 0.75, 0], | ||
easeOutQuart: [0.25, 1, 0.5, 1], | ||
easeInOutQuart: [0.76, 0, 0.24, 1], | ||
easeInQuint: [0.64, 0, 0.78, 0], | ||
easeOutQuint: [0.22, 1, 0.36, 1], | ||
easeInOutQuint: [0.83, 0, 0.17, 1], | ||
easeInExpo: [0.7, 0, 0.84, 0], | ||
easeOutExpo: [0.16, 1, 0.3, 1], | ||
easeInOutExpo: [0.87, 0, 0.13, 1], | ||
easeInCirc: [0.55, 0, 1, 0.45], | ||
easeOutCirc: [0, 0.55, 0.45, 1], | ||
easeInOutCirc: [0.85, 0, 0.15, 1], | ||
easeInBack: [0.36, 0, 0.66, -0.56], | ||
easeOutBack: [0.34, 1.56, 0.64, 1], | ||
easeInOutBack: [0.68, -0.6, 0.32, 1.6] | ||
}; | ||
Ot({ | ||
linear: St | ||
}, kt); | ||
function j(n) { | ||
return Array.isArray ? Array.isArray(n) : Je(n) === "[object Array]"; | ||
} | ||
function ft(s) { | ||
return s === !0 || s === !1 || mt(s) && De(s) == "[object Boolean]"; | ||
const Ct = 1 / 0; | ||
function Tt(n) { | ||
if (typeof n == "string") | ||
return n; | ||
let e = n + ""; | ||
return e == "0" && 1 / n == -Ct ? "-0" : e; | ||
} | ||
function Pe(s) { | ||
return typeof s == "object"; | ||
function $t(n) { | ||
return n == null ? "" : Tt(n); | ||
} | ||
function mt(s) { | ||
return Pe(s) && s !== null; | ||
function F(n) { | ||
return typeof n == "string"; | ||
} | ||
function b(s) { | ||
return s != null; | ||
function He(n) { | ||
return typeof n == "number"; | ||
} | ||
function ce(s) { | ||
return !s.trim().length; | ||
function Nt(n) { | ||
return n === !0 || n === !1 || Pt(n) && Je(n) == "[object Boolean]"; | ||
} | ||
function De(s) { | ||
return s == null ? s === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(s); | ||
function Ye(n) { | ||
return typeof n == "object"; | ||
} | ||
const pt = "Incorrect 'index' type", gt = (s) => `Invalid value for key ${s}`, _t = (s) => `Pattern length exceeds max of ${s}.`, vt = (s) => `Missing ${s} property in key`, Et = (s) => `Property 'weight' in key '${s}' must be a positive integer`, ke = Object.prototype.hasOwnProperty; | ||
class yt { | ||
function Pt(n) { | ||
return Ye(n) && n !== null; | ||
} | ||
function k(n) { | ||
return n != null; | ||
} | ||
function ue(n) { | ||
return !n.trim().length; | ||
} | ||
function Je(n) { | ||
return n == null ? n === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(n); | ||
} | ||
const Ft = "Incorrect 'index' type", Kt = (n) => `Invalid value for key ${n}`, Dt = (n) => `Pattern length exceeds max of ${n}.`, jt = (n) => `Missing ${n} property in key`, Vt = (n) => `Property 'weight' in key '${n}' must be a positive integer`, Pe = Object.prototype.hasOwnProperty; | ||
class Bt { | ||
constructor(e) { | ||
this._keys = [], this._keyMap = {}; | ||
let t = 0; | ||
e.forEach((n) => { | ||
let r = Ve(n); | ||
e.forEach((s) => { | ||
let r = Xe(s); | ||
t += r.weight, this._keys.push(r), this._keyMap[r.id] = r, t += r.weight; | ||
}), this._keys.forEach((n) => { | ||
n.weight /= t; | ||
}), this._keys.forEach((s) => { | ||
s.weight /= t; | ||
}); | ||
@@ -97,50 +227,50 @@ } | ||
} | ||
function Ve(s) { | ||
let e = null, t = null, n = null, r = 1, i = null; | ||
if (T(s) || P(s)) | ||
n = s, e = Re(s), t = ue(s); | ||
function Xe(n) { | ||
let e = null, t = null, s = null, r = 1, o = null; | ||
if (F(n) || j(n)) | ||
s = n, e = Fe(n), t = ge(n); | ||
else { | ||
if (!ke.call(s, "name")) | ||
throw new Error(vt("name")); | ||
const o = s.name; | ||
if (n = o, ke.call(s, "weight") && (r = s.weight, r <= 0)) | ||
throw new Error(Et(o)); | ||
e = Re(o), t = ue(o), i = s.getFn; | ||
if (!Pe.call(n, "name")) | ||
throw new Error(jt("name")); | ||
const i = n.name; | ||
if (s = i, Pe.call(n, "weight") && (r = n.weight, r <= 0)) | ||
throw new Error(Vt(i)); | ||
e = Fe(i), t = ge(i), o = n.getFn; | ||
} | ||
return { path: e, id: t, weight: r, src: n, getFn: i }; | ||
return { path: e, id: t, weight: r, src: s, getFn: o }; | ||
} | ||
function Re(s) { | ||
return P(s) ? s : s.split("."); | ||
function Fe(n) { | ||
return j(n) ? n : n.split("."); | ||
} | ||
function ue(s) { | ||
return P(s) ? s.join(".") : s; | ||
function ge(n) { | ||
return j(n) ? n.join(".") : n; | ||
} | ||
function St(s, e) { | ||
let t = [], n = !1; | ||
const r = (i, o, c) => { | ||
if (!!b(i)) | ||
if (!o[c]) | ||
t.push(i); | ||
function Gt(n, e) { | ||
let t = [], s = !1; | ||
const r = (o, i, a) => { | ||
if (!!k(o)) | ||
if (!i[a]) | ||
t.push(o); | ||
else { | ||
let a = o[c]; | ||
const u = i[a]; | ||
if (!b(u)) | ||
let c = i[a]; | ||
const u = o[c]; | ||
if (!k(u)) | ||
return; | ||
if (c === o.length - 1 && (T(u) || Ke(u) || ft(u))) | ||
t.push(dt(u)); | ||
else if (P(u)) { | ||
n = !0; | ||
for (let h = 0, f = u.length; h < f; h += 1) | ||
r(u[h], o, c + 1); | ||
if (a === i.length - 1 && (F(u) || He(u) || Nt(u))) | ||
t.push($t(u)); | ||
else if (j(u)) { | ||
s = !0; | ||
for (let h = 0, d = u.length; h < d; h += 1) | ||
r(u[h], i, a + 1); | ||
} else | ||
o.length && r(u, o, c + 1); | ||
i.length && r(u, i, a + 1); | ||
} | ||
}; | ||
return r(s, T(e) ? e.split(".") : e, 0), n ? t : t[0]; | ||
return r(n, F(e) ? e.split(".") : e, 0), s ? t : t[0]; | ||
} | ||
const It = { | ||
const Wt = { | ||
includeMatches: !1, | ||
findAllMatches: !1, | ||
minMatchCharLength: 1 | ||
}, Mt = { | ||
}, Ut = { | ||
isCaseSensitive: !1, | ||
@@ -150,10 +280,10 @@ includeScore: !1, | ||
shouldSort: !0, | ||
sortFn: (s, e) => s.score === e.score ? s.idx < e.idx ? -1 : 1 : s.score < e.score ? -1 : 1 | ||
}, wt = { | ||
sortFn: (n, e) => n.score === e.score ? n.idx < e.idx ? -1 : 1 : n.score < e.score ? -1 : 1 | ||
}, zt = { | ||
location: 0, | ||
threshold: 0.6, | ||
distance: 100 | ||
}, xt = { | ||
}, Qt = { | ||
useExtendedSearch: !1, | ||
getFn: St, | ||
getFn: Gt, | ||
ignoreLocation: !1, | ||
@@ -164,17 +294,17 @@ ignoreFieldNorm: !1, | ||
var m = { | ||
...Mt, | ||
...It, | ||
...wt, | ||
...xt | ||
...Ut, | ||
...Wt, | ||
...zt, | ||
...Qt | ||
}; | ||
const bt = /[^ ]+/g; | ||
function At(s = 1, e = 3) { | ||
const t = /* @__PURE__ */ new Map(), n = Math.pow(10, e); | ||
const Ht = /[^ ]+/g; | ||
function Yt(n = 1, e = 3) { | ||
const t = /* @__PURE__ */ new Map(), s = Math.pow(10, e); | ||
return { | ||
get(r) { | ||
const i = r.match(bt).length; | ||
if (t.has(i)) | ||
return t.get(i); | ||
const o = 1 / Math.pow(i, 0.5 * s), c = parseFloat(Math.round(o * n) / n); | ||
return t.set(i, c), c; | ||
const o = r.match(Ht).length; | ||
if (t.has(o)) | ||
return t.get(o); | ||
const i = 1 / Math.pow(o, 0.5 * n), a = parseFloat(Math.round(i * s) / s); | ||
return t.set(o, a), a; | ||
}, | ||
@@ -186,3 +316,3 @@ clear() { | ||
} | ||
class Ee { | ||
class be { | ||
constructor({ | ||
@@ -192,3 +322,3 @@ getFn: e = m.getFn, | ||
} = {}) { | ||
this.norm = At(t, 3), this.getFn = e, this.isCreated = !1, this.setIndexRecords(); | ||
this.norm = Yt(t, 3), this.getFn = e, this.isCreated = !1, this.setIndexRecords(); | ||
} | ||
@@ -202,8 +332,8 @@ setSources(e = []) { | ||
setKeys(e = []) { | ||
this.keys = e, this._keysMap = {}, e.forEach((t, n) => { | ||
this._keysMap[t.id] = n; | ||
this.keys = e, this._keysMap = {}, e.forEach((t, s) => { | ||
this._keysMap[t.id] = s; | ||
}); | ||
} | ||
create() { | ||
this.isCreated || !this.docs.length || (this.isCreated = !0, T(this.docs[0]) ? this.docs.forEach((e, t) => { | ||
this.isCreated || !this.docs.length || (this.isCreated = !0, F(this.docs[0]) ? this.docs.forEach((e, t) => { | ||
this._addString(e, t); | ||
@@ -216,7 +346,7 @@ }) : this.docs.forEach((e, t) => { | ||
const t = this.size(); | ||
T(e) ? this._addString(e, t) : this._addObject(e, t); | ||
F(e) ? this._addString(e, t) : this._addObject(e, t); | ||
} | ||
removeAt(e) { | ||
this.records.splice(e, 1); | ||
for (let t = e, n = this.size(); t < n; t += 1) | ||
for (let t = e, s = this.size(); t < s; t += 1) | ||
this.records[t].i -= 1; | ||
@@ -231,5 +361,5 @@ } | ||
_addString(e, t) { | ||
if (!b(e) || ce(e)) | ||
if (!k(e) || ue(e)) | ||
return; | ||
let n = { | ||
let s = { | ||
v: e, | ||
@@ -239,17 +369,17 @@ i: t, | ||
}; | ||
this.records.push(n); | ||
this.records.push(s); | ||
} | ||
_addObject(e, t) { | ||
let n = { i: t, $: {} }; | ||
this.keys.forEach((r, i) => { | ||
let o = r.getFn ? r.getFn(e) : this.getFn(e, r.path); | ||
if (!!b(o)) { | ||
if (P(o)) { | ||
let c = []; | ||
const a = [{ nestedArrIndex: -1, value: o }]; | ||
for (; a.length; ) { | ||
const { nestedArrIndex: u, value: h } = a.pop(); | ||
if (!!b(h)) | ||
if (T(h) && !ce(h)) { | ||
let f = { | ||
let s = { i: t, $: {} }; | ||
this.keys.forEach((r, o) => { | ||
let i = r.getFn ? r.getFn(e) : this.getFn(e, r.path); | ||
if (!!k(i)) { | ||
if (j(i)) { | ||
let a = []; | ||
const c = [{ nestedArrIndex: -1, value: i }]; | ||
for (; c.length; ) { | ||
const { nestedArrIndex: u, value: h } = c.pop(); | ||
if (!!k(h)) | ||
if (F(h) && !ue(h)) { | ||
let d = { | ||
v: h, | ||
@@ -259,21 +389,21 @@ i: u, | ||
}; | ||
c.push(f); | ||
a.push(d); | ||
} else | ||
P(h) && h.forEach((f, d) => { | ||
a.push({ | ||
nestedArrIndex: d, | ||
value: f | ||
j(h) && h.forEach((d, p) => { | ||
c.push({ | ||
nestedArrIndex: p, | ||
value: d | ||
}); | ||
}); | ||
} | ||
n.$[i] = c; | ||
} else if (T(o) && !ce(o)) { | ||
let c = { | ||
v: o, | ||
n: this.norm.get(o) | ||
s.$[o] = a; | ||
} else if (F(i) && !ue(i)) { | ||
let a = { | ||
v: i, | ||
n: this.norm.get(i) | ||
}; | ||
n.$[i] = c; | ||
s.$[o] = a; | ||
} | ||
} | ||
}), this.records.push(n); | ||
}), this.records.push(s); | ||
} | ||
@@ -287,127 +417,127 @@ toJSON() { | ||
} | ||
function je(s, e, { getFn: t = m.getFn, fieldNormWeight: n = m.fieldNormWeight } = {}) { | ||
const r = new Ee({ getFn: t, fieldNormWeight: n }); | ||
return r.setKeys(s.map(Ve)), r.setSources(e), r.create(), r; | ||
function Ze(n, e, { getFn: t = m.getFn, fieldNormWeight: s = m.fieldNormWeight } = {}) { | ||
const r = new be({ getFn: t, fieldNormWeight: s }); | ||
return r.setKeys(n.map(Xe)), r.setSources(e), r.create(), r; | ||
} | ||
function kt(s, { getFn: e = m.getFn, fieldNormWeight: t = m.fieldNormWeight } = {}) { | ||
const { keys: n, records: r } = s, i = new Ee({ getFn: e, fieldNormWeight: t }); | ||
return i.setKeys(n), i.setIndexRecords(r), i; | ||
function Jt(n, { getFn: e = m.getFn, fieldNormWeight: t = m.fieldNormWeight } = {}) { | ||
const { keys: s, records: r } = n, o = new be({ getFn: e, fieldNormWeight: t }); | ||
return o.setKeys(s), o.setIndexRecords(r), o; | ||
} | ||
function se(s, { | ||
function re(n, { | ||
errors: e = 0, | ||
currentLocation: t = 0, | ||
expectedLocation: n = 0, | ||
expectedLocation: s = 0, | ||
distance: r = m.distance, | ||
ignoreLocation: i = m.ignoreLocation | ||
ignoreLocation: o = m.ignoreLocation | ||
} = {}) { | ||
const o = e / s.length; | ||
if (i) | ||
return o; | ||
const c = Math.abs(n - t); | ||
return r ? o + c / r : c ? 1 : o; | ||
const i = e / n.length; | ||
if (o) | ||
return i; | ||
const a = Math.abs(s - t); | ||
return r ? i + a / r : a ? 1 : i; | ||
} | ||
function Rt(s = [], e = m.minMatchCharLength) { | ||
let t = [], n = -1, r = -1, i = 0; | ||
for (let o = s.length; i < o; i += 1) { | ||
let c = s[i]; | ||
c && n === -1 ? n = i : !c && n !== -1 && (r = i - 1, r - n + 1 >= e && t.push([n, r]), n = -1); | ||
function Xt(n = [], e = m.minMatchCharLength) { | ||
let t = [], s = -1, r = -1, o = 0; | ||
for (let i = n.length; o < i; o += 1) { | ||
let a = n[o]; | ||
a && s === -1 ? s = o : !a && s !== -1 && (r = o - 1, r - s + 1 >= e && t.push([s, r]), s = -1); | ||
} | ||
return s[i - 1] && i - n >= e && t.push([n, i - 1]), t; | ||
return n[o - 1] && o - s >= e && t.push([s, o - 1]), t; | ||
} | ||
const U = 32; | ||
function Lt(s, e, t, { | ||
location: n = m.location, | ||
const z = 32; | ||
function Zt(n, e, t, { | ||
location: s = m.location, | ||
distance: r = m.distance, | ||
threshold: i = m.threshold, | ||
findAllMatches: o = m.findAllMatches, | ||
minMatchCharLength: c = m.minMatchCharLength, | ||
includeMatches: a = m.includeMatches, | ||
threshold: o = m.threshold, | ||
findAllMatches: i = m.findAllMatches, | ||
minMatchCharLength: a = m.minMatchCharLength, | ||
includeMatches: c = m.includeMatches, | ||
ignoreLocation: u = m.ignoreLocation | ||
} = {}) { | ||
if (e.length > U) | ||
throw new Error(_t(U)); | ||
const h = e.length, f = s.length, d = Math.max(0, Math.min(n, f)); | ||
let p = i, v = d; | ||
const w = c > 1 || a, I = w ? Array(f) : []; | ||
let A; | ||
for (; (A = s.indexOf(e, v)) > -1; ) { | ||
let M = se(e, { | ||
currentLocation: A, | ||
expectedLocation: d, | ||
if (e.length > z) | ||
throw new Error(Dt(z)); | ||
const h = e.length, d = n.length, p = Math.max(0, Math.min(s, d)); | ||
let _ = o, y = p; | ||
const f = a > 1 || c, g = f ? Array(d) : []; | ||
let I; | ||
for (; (I = n.indexOf(e, y)) > -1; ) { | ||
let R = re(e, { | ||
currentLocation: I, | ||
expectedLocation: p, | ||
distance: r, | ||
ignoreLocation: u | ||
}); | ||
if (p = Math.min(M, p), v = A + h, w) { | ||
let $ = 0; | ||
for (; $ < h; ) | ||
I[A + $] = 1, $ += 1; | ||
if (_ = Math.min(R, _), y = I + h, f) { | ||
let N = 0; | ||
for (; N < h; ) | ||
g[I + N] = 1, N += 1; | ||
} | ||
} | ||
v = -1; | ||
let k = [], R = 1, G = h + f; | ||
const q = 1 << h - 1; | ||
for (let M = 0; M < h; M += 1) { | ||
let $ = 0, x = G; | ||
for (; $ < x; ) | ||
se(e, { | ||
errors: M, | ||
currentLocation: d + x, | ||
expectedLocation: d, | ||
y = -1; | ||
let M = [], S = 1, C = h + d; | ||
const W = 1 << h - 1; | ||
for (let R = 0; R < h; R += 1) { | ||
let N = 0, L = C; | ||
for (; N < L; ) | ||
re(e, { | ||
errors: R, | ||
currentLocation: p + L, | ||
expectedLocation: p, | ||
distance: r, | ||
ignoreLocation: u | ||
}) <= p ? $ = x : G = x, x = Math.floor((G - $) / 2 + $); | ||
G = x; | ||
let O = Math.max(1, d - x + 1), X = o ? f : Math.min(d + x, f) + h, C = Array(X + 2); | ||
C[X + 1] = (1 << M) - 1; | ||
for (let y = X; y >= O; y -= 1) { | ||
let B = y - 1, Z = t[s.charAt(B)]; | ||
if (w && (I[B] = +!!Z), C[y] = (C[y + 1] << 1 | 1) & Z, M && (C[y] |= (k[y + 1] | k[y]) << 1 | 1 | k[y + 1]), C[y] & q && (R = se(e, { | ||
errors: M, | ||
currentLocation: B, | ||
expectedLocation: d, | ||
}) <= _ ? N = L : C = L, L = Math.floor((C - N) / 2 + N); | ||
C = L; | ||
let K = Math.max(1, p - L + 1), X = i ? d : Math.min(p + L, d) + h, P = Array(X + 2); | ||
P[X + 1] = (1 << R) - 1; | ||
for (let b = X; b >= K; b -= 1) { | ||
let U = b - 1, q = t[n.charAt(U)]; | ||
if (f && (g[U] = +!!q), P[b] = (P[b + 1] << 1 | 1) & q, R && (P[b] |= (M[b + 1] | M[b]) << 1 | 1 | M[b + 1]), P[b] & W && (S = re(e, { | ||
errors: R, | ||
currentLocation: U, | ||
expectedLocation: p, | ||
distance: r, | ||
ignoreLocation: u | ||
}), R <= p)) { | ||
if (p = R, v = B, v <= d) | ||
}), S <= _)) { | ||
if (_ = S, y = U, y <= p) | ||
break; | ||
O = Math.max(1, 2 * d - v); | ||
K = Math.max(1, 2 * p - y); | ||
} | ||
} | ||
if (se(e, { | ||
errors: M + 1, | ||
currentLocation: d, | ||
expectedLocation: d, | ||
if (re(e, { | ||
errors: R + 1, | ||
currentLocation: p, | ||
expectedLocation: p, | ||
distance: r, | ||
ignoreLocation: u | ||
}) > p) | ||
}) > _) | ||
break; | ||
k = C; | ||
M = P; | ||
} | ||
const Y = { | ||
isMatch: v >= 0, | ||
score: Math.max(1e-3, R) | ||
const A = { | ||
isMatch: y >= 0, | ||
score: Math.max(1e-3, S) | ||
}; | ||
if (w) { | ||
const M = Rt(I, c); | ||
M.length ? a && (Y.indices = M) : Y.isMatch = !1; | ||
if (f) { | ||
const R = Xt(g, a); | ||
R.length ? c && (A.indices = R) : A.isMatch = !1; | ||
} | ||
return Y; | ||
return A; | ||
} | ||
function $t(s) { | ||
function qt(n) { | ||
let e = {}; | ||
for (let t = 0, n = s.length; t < n; t += 1) { | ||
const r = s.charAt(t); | ||
e[r] = (e[r] || 0) | 1 << n - t - 1; | ||
for (let t = 0, s = n.length; t < s; t += 1) { | ||
const r = n.charAt(t); | ||
e[r] = (e[r] || 0) | 1 << s - t - 1; | ||
} | ||
return e; | ||
} | ||
class Ge { | ||
class qe { | ||
constructor(e, { | ||
location: t = m.location, | ||
threshold: n = m.threshold, | ||
threshold: s = m.threshold, | ||
distance: r = m.distance, | ||
includeMatches: i = m.includeMatches, | ||
findAllMatches: o = m.findAllMatches, | ||
minMatchCharLength: c = m.minMatchCharLength, | ||
isCaseSensitive: a = m.isCaseSensitive, | ||
includeMatches: o = m.includeMatches, | ||
findAllMatches: i = m.findAllMatches, | ||
minMatchCharLength: a = m.minMatchCharLength, | ||
isCaseSensitive: c = m.isCaseSensitive, | ||
ignoreLocation: u = m.ignoreLocation | ||
@@ -417,26 +547,26 @@ } = {}) { | ||
location: t, | ||
threshold: n, | ||
threshold: s, | ||
distance: r, | ||
includeMatches: i, | ||
findAllMatches: o, | ||
minMatchCharLength: c, | ||
isCaseSensitive: a, | ||
includeMatches: o, | ||
findAllMatches: i, | ||
minMatchCharLength: a, | ||
isCaseSensitive: c, | ||
ignoreLocation: u | ||
}, this.pattern = a ? e : e.toLowerCase(), this.chunks = [], !this.pattern.length) | ||
}, this.pattern = c ? e : e.toLowerCase(), this.chunks = [], !this.pattern.length) | ||
return; | ||
const h = (d, p) => { | ||
const h = (p, _) => { | ||
this.chunks.push({ | ||
pattern: d, | ||
alphabet: $t(d), | ||
startIndex: p | ||
pattern: p, | ||
alphabet: qt(p), | ||
startIndex: _ | ||
}); | ||
}, f = this.pattern.length; | ||
if (f > U) { | ||
let d = 0; | ||
const p = f % U, v = f - p; | ||
for (; d < v; ) | ||
h(this.pattern.substr(d, U), d), d += U; | ||
if (p) { | ||
const w = f - U; | ||
h(this.pattern.substr(w), w); | ||
}, d = this.pattern.length; | ||
if (d > z) { | ||
let p = 0; | ||
const _ = d % z, y = d - _; | ||
for (; p < y; ) | ||
h(this.pattern.substr(p, z), p), p += z; | ||
if (_) { | ||
const f = d - z; | ||
h(this.pattern.substr(f), f); | ||
} | ||
@@ -447,39 +577,39 @@ } else | ||
searchIn(e) { | ||
const { isCaseSensitive: t, includeMatches: n } = this.options; | ||
const { isCaseSensitive: t, includeMatches: s } = this.options; | ||
if (t || (e = e.toLowerCase()), this.pattern === e) { | ||
let v = { | ||
let y = { | ||
isMatch: !0, | ||
score: 0 | ||
}; | ||
return n && (v.indices = [[0, e.length - 1]]), v; | ||
return s && (y.indices = [[0, e.length - 1]]), y; | ||
} | ||
const { | ||
location: r, | ||
distance: i, | ||
threshold: o, | ||
findAllMatches: c, | ||
minMatchCharLength: a, | ||
distance: o, | ||
threshold: i, | ||
findAllMatches: a, | ||
minMatchCharLength: c, | ||
ignoreLocation: u | ||
} = this.options; | ||
let h = [], f = 0, d = !1; | ||
this.chunks.forEach(({ pattern: v, alphabet: w, startIndex: I }) => { | ||
const { isMatch: A, score: k, indices: R } = Lt(e, v, w, { | ||
location: r + I, | ||
distance: i, | ||
threshold: o, | ||
findAllMatches: c, | ||
minMatchCharLength: a, | ||
includeMatches: n, | ||
let h = [], d = 0, p = !1; | ||
this.chunks.forEach(({ pattern: y, alphabet: f, startIndex: g }) => { | ||
const { isMatch: I, score: M, indices: S } = Zt(e, y, f, { | ||
location: r + g, | ||
distance: o, | ||
threshold: i, | ||
findAllMatches: a, | ||
minMatchCharLength: c, | ||
includeMatches: s, | ||
ignoreLocation: u | ||
}); | ||
A && (d = !0), f += k, A && R && (h = [...h, ...R]); | ||
I && (p = !0), d += M, I && S && (h = [...h, ...S]); | ||
}); | ||
let p = { | ||
isMatch: d, | ||
score: d ? f / this.chunks.length : 1 | ||
let _ = { | ||
isMatch: p, | ||
score: p ? d / this.chunks.length : 1 | ||
}; | ||
return d && n && (p.indices = h), p; | ||
return p && s && (_.indices = h), _; | ||
} | ||
} | ||
class j { | ||
class G { | ||
constructor(e) { | ||
@@ -489,6 +619,6 @@ this.pattern = e; | ||
static isMultiMatch(e) { | ||
return Le(e, this.multiRegex); | ||
return Ke(e, this.multiRegex); | ||
} | ||
static isSingleMatch(e) { | ||
return Le(e, this.singleRegex); | ||
return Ke(e, this.singleRegex); | ||
} | ||
@@ -498,7 +628,7 @@ search() { | ||
} | ||
function Le(s, e) { | ||
const t = s.match(e); | ||
function Ke(n, e) { | ||
const t = n.match(e); | ||
return t ? t[1] : null; | ||
} | ||
class Ct extends j { | ||
class en extends G { | ||
constructor(e) { | ||
@@ -525,3 +655,3 @@ super(e); | ||
} | ||
class Tt extends j { | ||
class tn extends G { | ||
constructor(e) { | ||
@@ -540,6 +670,6 @@ super(e); | ||
search(e) { | ||
const n = e.indexOf(this.pattern) === -1; | ||
const s = e.indexOf(this.pattern) === -1; | ||
return { | ||
isMatch: n, | ||
score: n ? 0 : 1, | ||
isMatch: s, | ||
score: s ? 0 : 1, | ||
indices: [0, e.length - 1] | ||
@@ -549,3 +679,3 @@ }; | ||
} | ||
class Ot extends j { | ||
class nn extends G { | ||
constructor(e) { | ||
@@ -572,3 +702,3 @@ super(e); | ||
} | ||
class Nt extends j { | ||
class sn extends G { | ||
constructor(e) { | ||
@@ -595,3 +725,3 @@ super(e); | ||
} | ||
class Ft extends j { | ||
class rn extends G { | ||
constructor(e) { | ||
@@ -618,3 +748,3 @@ super(e); | ||
} | ||
class Kt extends j { | ||
class on extends G { | ||
constructor(e) { | ||
@@ -641,21 +771,21 @@ super(e); | ||
} | ||
class Be extends j { | ||
class et extends G { | ||
constructor(e, { | ||
location: t = m.location, | ||
threshold: n = m.threshold, | ||
threshold: s = m.threshold, | ||
distance: r = m.distance, | ||
includeMatches: i = m.includeMatches, | ||
findAllMatches: o = m.findAllMatches, | ||
minMatchCharLength: c = m.minMatchCharLength, | ||
isCaseSensitive: a = m.isCaseSensitive, | ||
includeMatches: o = m.includeMatches, | ||
findAllMatches: i = m.findAllMatches, | ||
minMatchCharLength: a = m.minMatchCharLength, | ||
isCaseSensitive: c = m.isCaseSensitive, | ||
ignoreLocation: u = m.ignoreLocation | ||
} = {}) { | ||
super(e), this._bitapSearch = new Ge(e, { | ||
super(e), this._bitapSearch = new qe(e, { | ||
location: t, | ||
threshold: n, | ||
threshold: s, | ||
distance: r, | ||
includeMatches: i, | ||
findAllMatches: o, | ||
minMatchCharLength: c, | ||
isCaseSensitive: a, | ||
includeMatches: o, | ||
findAllMatches: i, | ||
minMatchCharLength: a, | ||
isCaseSensitive: c, | ||
ignoreLocation: u | ||
@@ -677,3 +807,3 @@ }); | ||
} | ||
class Ue extends j { | ||
class tt extends G { | ||
constructor(e) { | ||
@@ -692,10 +822,10 @@ super(e); | ||
search(e) { | ||
let t = 0, n; | ||
const r = [], i = this.pattern.length; | ||
for (; (n = e.indexOf(this.pattern, t)) > -1; ) | ||
t = n + i, r.push([n, t - 1]); | ||
const o = !!r.length; | ||
let t = 0, s; | ||
const r = [], o = this.pattern.length; | ||
for (; (s = e.indexOf(this.pattern, t)) > -1; ) | ||
t = s + o, r.push([s, t - 1]); | ||
const i = !!r.length; | ||
return { | ||
isMatch: o, | ||
score: o ? 0 : 1, | ||
isMatch: i, | ||
score: i ? 0 : 1, | ||
indices: r | ||
@@ -705,29 +835,29 @@ }; | ||
} | ||
const he = [ | ||
Ct, | ||
Ue, | ||
Ot, | ||
Nt, | ||
Kt, | ||
Ft, | ||
Tt, | ||
Be | ||
], $e = he.length, Pt = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, Dt = "|"; | ||
function Vt(s, e = {}) { | ||
return s.split(Dt).map((t) => { | ||
let n = t.trim().split(Pt).filter((i) => i && !!i.trim()), r = []; | ||
for (let i = 0, o = n.length; i < o; i += 1) { | ||
const c = n[i]; | ||
let a = !1, u = -1; | ||
for (; !a && ++u < $e; ) { | ||
const h = he[u]; | ||
let f = h.isMultiMatch(c); | ||
f && (r.push(new h(f, e)), a = !0); | ||
const _e = [ | ||
en, | ||
tt, | ||
nn, | ||
sn, | ||
on, | ||
rn, | ||
tn, | ||
et | ||
], De = _e.length, cn = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, an = "|"; | ||
function ln(n, e = {}) { | ||
return n.split(an).map((t) => { | ||
let s = t.trim().split(cn).filter((o) => o && !!o.trim()), r = []; | ||
for (let o = 0, i = s.length; o < i; o += 1) { | ||
const a = s[o]; | ||
let c = !1, u = -1; | ||
for (; !c && ++u < De; ) { | ||
const h = _e[u]; | ||
let d = h.isMultiMatch(a); | ||
d && (r.push(new h(d, e)), c = !0); | ||
} | ||
if (!a) | ||
for (u = -1; ++u < $e; ) { | ||
const h = he[u]; | ||
let f = h.isSingleMatch(c); | ||
if (f) { | ||
r.push(new h(f, e)); | ||
if (!c) | ||
for (u = -1; ++u < De; ) { | ||
const h = _e[u]; | ||
let d = h.isSingleMatch(a); | ||
if (d) { | ||
r.push(new h(d, e)); | ||
break; | ||
@@ -740,12 +870,12 @@ } | ||
} | ||
const jt = /* @__PURE__ */ new Set([Be.type, Ue.type]); | ||
class Gt { | ||
const un = /* @__PURE__ */ new Set([et.type, tt.type]); | ||
class hn { | ||
constructor(e, { | ||
isCaseSensitive: t = m.isCaseSensitive, | ||
includeMatches: n = m.includeMatches, | ||
includeMatches: s = m.includeMatches, | ||
minMatchCharLength: r = m.minMatchCharLength, | ||
ignoreLocation: i = m.ignoreLocation, | ||
findAllMatches: o = m.findAllMatches, | ||
location: c = m.location, | ||
threshold: a = m.threshold, | ||
ignoreLocation: o = m.ignoreLocation, | ||
findAllMatches: i = m.findAllMatches, | ||
location: a = m.location, | ||
threshold: c = m.threshold, | ||
distance: u = m.distance | ||
@@ -755,10 +885,10 @@ } = {}) { | ||
isCaseSensitive: t, | ||
includeMatches: n, | ||
includeMatches: s, | ||
minMatchCharLength: r, | ||
findAllMatches: o, | ||
ignoreLocation: i, | ||
location: c, | ||
threshold: a, | ||
findAllMatches: i, | ||
ignoreLocation: o, | ||
location: a, | ||
threshold: c, | ||
distance: u | ||
}, this.pattern = t ? e : e.toLowerCase(), this.query = Vt(this.pattern, this.options); | ||
}, this.pattern = t ? e : e.toLowerCase(), this.query = ln(this.pattern, this.options); | ||
} | ||
@@ -775,26 +905,26 @@ static condition(e, t) { | ||
}; | ||
const { includeMatches: n, isCaseSensitive: r } = this.options; | ||
const { includeMatches: s, isCaseSensitive: r } = this.options; | ||
e = r ? e : e.toLowerCase(); | ||
let i = 0, o = [], c = 0; | ||
for (let a = 0, u = t.length; a < u; a += 1) { | ||
const h = t[a]; | ||
o.length = 0, i = 0; | ||
for (let f = 0, d = h.length; f < d; f += 1) { | ||
const p = h[f], { isMatch: v, indices: w, score: I } = p.search(e); | ||
if (v) { | ||
if (i += 1, c += I, n) { | ||
const A = p.constructor.type; | ||
jt.has(A) ? o = [...o, ...w] : o.push(w); | ||
let o = 0, i = [], a = 0; | ||
for (let c = 0, u = t.length; c < u; c += 1) { | ||
const h = t[c]; | ||
i.length = 0, o = 0; | ||
for (let d = 0, p = h.length; d < p; d += 1) { | ||
const _ = h[d], { isMatch: y, indices: f, score: g } = _.search(e); | ||
if (y) { | ||
if (o += 1, a += g, s) { | ||
const I = _.constructor.type; | ||
un.has(I) ? i = [...i, ...f] : i.push(f); | ||
} | ||
} else { | ||
c = 0, i = 0, o.length = 0; | ||
a = 0, o = 0, i.length = 0; | ||
break; | ||
} | ||
} | ||
if (i) { | ||
let f = { | ||
if (o) { | ||
let d = { | ||
isMatch: !0, | ||
score: c / i | ||
score: a / o | ||
}; | ||
return n && (f.indices = o), f; | ||
return s && (d.indices = i), d; | ||
} | ||
@@ -808,105 +938,105 @@ } | ||
} | ||
const de = []; | ||
function Bt(...s) { | ||
de.push(...s); | ||
const ve = []; | ||
function dn(...n) { | ||
ve.push(...n); | ||
} | ||
function fe(s, e) { | ||
for (let t = 0, n = de.length; t < n; t += 1) { | ||
let r = de[t]; | ||
if (r.condition(s, e)) | ||
return new r(s, e); | ||
function ye(n, e) { | ||
for (let t = 0, s = ve.length; t < s; t += 1) { | ||
let r = ve[t]; | ||
if (r.condition(n, e)) | ||
return new r(n, e); | ||
} | ||
return new Ge(s, e); | ||
return new qe(n, e); | ||
} | ||
const re = { | ||
const ce = { | ||
AND: "$and", | ||
OR: "$or" | ||
}, me = { | ||
}, Ee = { | ||
PATH: "$path", | ||
PATTERN: "$val" | ||
}, pe = (s) => !!(s[re.AND] || s[re.OR]), Ut = (s) => !!s[me.PATH], zt = (s) => !P(s) && Pe(s) && !pe(s), Ce = (s) => ({ | ||
[re.AND]: Object.keys(s).map((e) => ({ | ||
[e]: s[e] | ||
}, Ie = (n) => !!(n[ce.AND] || n[ce.OR]), fn = (n) => !!n[Ee.PATH], mn = (n) => !j(n) && Ye(n) && !Ie(n), je = (n) => ({ | ||
[ce.AND]: Object.keys(n).map((e) => ({ | ||
[e]: n[e] | ||
})) | ||
}); | ||
function ze(s, e, { auto: t = !0 } = {}) { | ||
const n = (r) => { | ||
let i = Object.keys(r); | ||
const o = Ut(r); | ||
if (!o && i.length > 1 && !pe(r)) | ||
return n(Ce(r)); | ||
if (zt(r)) { | ||
const a = o ? r[me.PATH] : i[0], u = o ? r[me.PATTERN] : r[a]; | ||
if (!T(u)) | ||
throw new Error(gt(a)); | ||
function nt(n, e, { auto: t = !0 } = {}) { | ||
const s = (r) => { | ||
let o = Object.keys(r); | ||
const i = fn(r); | ||
if (!i && o.length > 1 && !Ie(r)) | ||
return s(je(r)); | ||
if (mn(r)) { | ||
const c = i ? r[Ee.PATH] : o[0], u = i ? r[Ee.PATTERN] : r[c]; | ||
if (!F(u)) | ||
throw new Error(Kt(c)); | ||
const h = { | ||
keyId: ue(a), | ||
keyId: ge(c), | ||
pattern: u | ||
}; | ||
return t && (h.searcher = fe(u, e)), h; | ||
return t && (h.searcher = ye(u, e)), h; | ||
} | ||
let c = { | ||
let a = { | ||
children: [], | ||
operator: i[0] | ||
operator: o[0] | ||
}; | ||
return i.forEach((a) => { | ||
const u = r[a]; | ||
P(u) && u.forEach((h) => { | ||
c.children.push(n(h)); | ||
return o.forEach((c) => { | ||
const u = r[c]; | ||
j(u) && u.forEach((h) => { | ||
a.children.push(s(h)); | ||
}); | ||
}), c; | ||
}), a; | ||
}; | ||
return pe(s) || (s = Ce(s)), n(s); | ||
return Ie(n) || (n = je(n)), s(n); | ||
} | ||
function Wt(s, { ignoreFieldNorm: e = m.ignoreFieldNorm }) { | ||
s.forEach((t) => { | ||
let n = 1; | ||
t.matches.forEach(({ key: r, norm: i, score: o }) => { | ||
const c = r ? r.weight : null; | ||
n *= Math.pow( | ||
o === 0 && c ? Number.EPSILON : o, | ||
(c || 1) * (e ? 1 : i) | ||
function pn(n, { ignoreFieldNorm: e = m.ignoreFieldNorm }) { | ||
n.forEach((t) => { | ||
let s = 1; | ||
t.matches.forEach(({ key: r, norm: o, score: i }) => { | ||
const a = r ? r.weight : null; | ||
s *= Math.pow( | ||
i === 0 && a ? Number.EPSILON : i, | ||
(a || 1) * (e ? 1 : o) | ||
); | ||
}), t.score = n; | ||
}), t.score = s; | ||
}); | ||
} | ||
function Ht(s, e) { | ||
const t = s.matches; | ||
e.matches = [], b(t) && t.forEach((n) => { | ||
if (!b(n.indices) || !n.indices.length) | ||
function gn(n, e) { | ||
const t = n.matches; | ||
e.matches = [], k(t) && t.forEach((s) => { | ||
if (!k(s.indices) || !s.indices.length) | ||
return; | ||
const { indices: r, value: i } = n; | ||
let o = { | ||
const { indices: r, value: o } = s; | ||
let i = { | ||
indices: r, | ||
value: i | ||
value: o | ||
}; | ||
n.key && (o.key = n.key.src), n.idx > -1 && (o.refIndex = n.idx), e.matches.push(o); | ||
s.key && (i.key = s.key.src), s.idx > -1 && (i.refIndex = s.idx), e.matches.push(i); | ||
}); | ||
} | ||
function Yt(s, e) { | ||
e.score = s.score; | ||
function _n(n, e) { | ||
e.score = n.score; | ||
} | ||
function Qt(s, e, { | ||
function vn(n, e, { | ||
includeMatches: t = m.includeMatches, | ||
includeScore: n = m.includeScore | ||
includeScore: s = m.includeScore | ||
} = {}) { | ||
const r = []; | ||
return t && r.push(Ht), n && r.push(Yt), s.map((i) => { | ||
const { idx: o } = i, c = { | ||
item: e[o], | ||
refIndex: o | ||
return t && r.push(gn), s && r.push(_n), n.map((o) => { | ||
const { idx: i } = o, a = { | ||
item: e[i], | ||
refIndex: i | ||
}; | ||
return r.length && r.forEach((a) => { | ||
a(i, c); | ||
}), c; | ||
return r.length && r.forEach((c) => { | ||
c(o, a); | ||
}), a; | ||
}); | ||
} | ||
class H { | ||
constructor(e, t = {}, n) { | ||
this.options = { ...m, ...t }, this.options.useExtendedSearch, this._keyStore = new yt(this.options.keys), this.setCollection(e, n); | ||
class Y { | ||
constructor(e, t = {}, s) { | ||
this.options = { ...m, ...t }, this.options.useExtendedSearch, this._keyStore = new Bt(this.options.keys), this.setCollection(e, s); | ||
} | ||
setCollection(e, t) { | ||
if (this._docs = e, t && !(t instanceof Ee)) | ||
throw new Error(pt); | ||
this._myIndex = t || je(this.options.keys, this._docs, { | ||
if (this._docs = e, t && !(t instanceof be)) | ||
throw new Error(Ft); | ||
this._myIndex = t || Ze(this.options.keys, this._docs, { | ||
getFn: this.options.getFn, | ||
@@ -917,9 +1047,9 @@ fieldNormWeight: this.options.fieldNormWeight | ||
add(e) { | ||
!b(e) || (this._docs.push(e), this._myIndex.add(e)); | ||
!k(e) || (this._docs.push(e), this._myIndex.add(e)); | ||
} | ||
remove(e = () => !1) { | ||
const t = []; | ||
for (let n = 0, r = this._docs.length; n < r; n += 1) { | ||
const i = this._docs[n]; | ||
e(i, n) && (this.removeAt(n), n -= 1, r -= 1, t.push(i)); | ||
for (let s = 0, r = this._docs.length; s < r; s += 1) { | ||
const o = this._docs[s]; | ||
e(o, s) && (this.removeAt(s), s -= 1, r -= 1, t.push(o)); | ||
} | ||
@@ -936,11 +1066,11 @@ return t; | ||
const { | ||
includeMatches: n, | ||
includeMatches: s, | ||
includeScore: r, | ||
shouldSort: i, | ||
sortFn: o, | ||
ignoreFieldNorm: c | ||
shouldSort: o, | ||
sortFn: i, | ||
ignoreFieldNorm: a | ||
} = this.options; | ||
let a = T(e) ? T(this._docs[0]) ? this._searchStringList(e) : this._searchObjectList(e) : this._searchLogical(e); | ||
return Wt(a, { ignoreFieldNorm: c }), i && a.sort(o), Ke(t) && t > -1 && (a = a.slice(0, t)), Qt(a, this._docs, { | ||
includeMatches: n, | ||
let c = F(e) ? F(this._docs[0]) ? this._searchStringList(e) : this._searchObjectList(e) : this._searchLogical(e); | ||
return pn(c, { ignoreFieldNorm: a }), o && c.sort(i), He(t) && t > -1 && (c = c.slice(0, t)), vn(c, this._docs, { | ||
includeMatches: s, | ||
includeScore: r | ||
@@ -950,11 +1080,11 @@ }); | ||
_searchStringList(e) { | ||
const t = fe(e, this.options), { records: n } = this._myIndex, r = []; | ||
return n.forEach(({ v: i, i: o, n: c }) => { | ||
if (!b(i)) | ||
const t = ye(e, this.options), { records: s } = this._myIndex, r = []; | ||
return s.forEach(({ v: o, i, n: a }) => { | ||
if (!k(o)) | ||
return; | ||
const { isMatch: a, score: u, indices: h } = t.searchIn(i); | ||
a && r.push({ | ||
item: i, | ||
idx: o, | ||
matches: [{ score: u, value: i, norm: c, indices: h }] | ||
const { isMatch: c, score: u, indices: h } = t.searchIn(o); | ||
c && r.push({ | ||
item: o, | ||
idx: i, | ||
matches: [{ score: u, value: o, norm: a, indices: h }] | ||
}); | ||
@@ -964,14 +1094,14 @@ }), r; | ||
_searchLogical(e) { | ||
const t = ze(e, this.options), n = (c, a, u) => { | ||
if (!c.children) { | ||
const { keyId: f, searcher: d } = c, p = this._findMatches({ | ||
key: this._keyStore.get(f), | ||
value: this._myIndex.getValueForItemAtKeyId(a, f), | ||
searcher: d | ||
const t = nt(e, this.options), s = (a, c, u) => { | ||
if (!a.children) { | ||
const { keyId: d, searcher: p } = a, _ = this._findMatches({ | ||
key: this._keyStore.get(d), | ||
value: this._myIndex.getValueForItemAtKeyId(c, d), | ||
searcher: p | ||
}); | ||
return p && p.length ? [ | ||
return _ && _.length ? [ | ||
{ | ||
idx: u, | ||
item: a, | ||
matches: p | ||
item: c, | ||
matches: _ | ||
} | ||
@@ -981,56 +1111,56 @@ ] : []; | ||
const h = []; | ||
for (let f = 0, d = c.children.length; f < d; f += 1) { | ||
const p = c.children[f], v = n(p, a, u); | ||
if (v.length) | ||
h.push(...v); | ||
else if (c.operator === re.AND) | ||
for (let d = 0, p = a.children.length; d < p; d += 1) { | ||
const _ = a.children[d], y = s(_, c, u); | ||
if (y.length) | ||
h.push(...y); | ||
else if (a.operator === ce.AND) | ||
return []; | ||
} | ||
return h; | ||
}, r = this._myIndex.records, i = {}, o = []; | ||
return r.forEach(({ $: c, i: a }) => { | ||
if (b(c)) { | ||
let u = n(t, c, a); | ||
u.length && (i[a] || (i[a] = { idx: a, item: c, matches: [] }, o.push(i[a])), u.forEach(({ matches: h }) => { | ||
i[a].matches.push(...h); | ||
}, r = this._myIndex.records, o = {}, i = []; | ||
return r.forEach(({ $: a, i: c }) => { | ||
if (k(a)) { | ||
let u = s(t, a, c); | ||
u.length && (o[c] || (o[c] = { idx: c, item: a, matches: [] }, i.push(o[c])), u.forEach(({ matches: h }) => { | ||
o[c].matches.push(...h); | ||
})); | ||
} | ||
}), o; | ||
}), i; | ||
} | ||
_searchObjectList(e) { | ||
const t = fe(e, this.options), { keys: n, records: r } = this._myIndex, i = []; | ||
return r.forEach(({ $: o, i: c }) => { | ||
if (!b(o)) | ||
const t = ye(e, this.options), { keys: s, records: r } = this._myIndex, o = []; | ||
return r.forEach(({ $: i, i: a }) => { | ||
if (!k(i)) | ||
return; | ||
let a = []; | ||
n.forEach((u, h) => { | ||
a.push( | ||
let c = []; | ||
s.forEach((u, h) => { | ||
c.push( | ||
...this._findMatches({ | ||
key: u, | ||
value: o[h], | ||
value: i[h], | ||
searcher: t | ||
}) | ||
); | ||
}), a.length && i.push({ | ||
idx: c, | ||
item: o, | ||
matches: a | ||
}), c.length && o.push({ | ||
idx: a, | ||
item: i, | ||
matches: c | ||
}); | ||
}), i; | ||
}), o; | ||
} | ||
_findMatches({ key: e, value: t, searcher: n }) { | ||
if (!b(t)) | ||
_findMatches({ key: e, value: t, searcher: s }) { | ||
if (!k(t)) | ||
return []; | ||
let r = []; | ||
if (P(t)) | ||
t.forEach(({ v: i, i: o, n: c }) => { | ||
if (!b(i)) | ||
if (j(t)) | ||
t.forEach(({ v: o, i, n: a }) => { | ||
if (!k(o)) | ||
return; | ||
const { isMatch: a, score: u, indices: h } = n.searchIn(i); | ||
a && r.push({ | ||
const { isMatch: c, score: u, indices: h } = s.searchIn(o); | ||
c && r.push({ | ||
score: u, | ||
key: e, | ||
value: i, | ||
idx: o, | ||
norm: c, | ||
value: o, | ||
idx: i, | ||
norm: a, | ||
indices: h | ||
@@ -1040,4 +1170,4 @@ }); | ||
else { | ||
const { v: i, n: o } = t, { isMatch: c, score: a, indices: u } = n.searchIn(i); | ||
c && r.push({ score: a, key: e, value: i, norm: o, indices: u }); | ||
const { v: o, n: i } = t, { isMatch: a, score: c, indices: u } = s.searchIn(o); | ||
a && r.push({ score: c, key: e, value: o, norm: i, indices: u }); | ||
} | ||
@@ -1047,9 +1177,9 @@ return r; | ||
} | ||
H.version = "6.6.2"; | ||
H.createIndex = je; | ||
H.parseIndex = kt; | ||
H.config = m; | ||
H.parseQuery = ze; | ||
Bt(Gt); | ||
const Te = Ze({ | ||
Y.version = "6.6.2"; | ||
Y.createIndex = Ze; | ||
Y.parseIndex = Jt; | ||
Y.config = m; | ||
Y.parseQuery = nt; | ||
dn(hn); | ||
const Ve = he({ | ||
selectedNode: "", | ||
@@ -1064,18 +1194,18 @@ selectedGroup: "", | ||
} | ||
}), Q = () => ({ | ||
isSearching: K(() => Te.search !== ""), | ||
...qe(Te) | ||
}), J = () => ({ | ||
isSearching: $(() => Ve.search !== ""), | ||
...ht(Ve) | ||
}); | ||
function Xt(s) { | ||
return { all: s = s || /* @__PURE__ */ new Map(), on: function(e, t) { | ||
var n = s.get(e); | ||
n ? n.push(t) : s.set(e, [t]); | ||
function yn(n) { | ||
return { all: n = n || /* @__PURE__ */ new Map(), on: function(e, t) { | ||
var s = n.get(e); | ||
s ? s.push(t) : n.set(e, [t]); | ||
}, off: function(e, t) { | ||
var n = s.get(e); | ||
n && (t ? n.splice(n.indexOf(t) >>> 0, 1) : s.set(e, [])); | ||
var s = n.get(e); | ||
s && (t ? s.splice(s.indexOf(t) >>> 0, 1) : n.set(e, [])); | ||
}, emit: function(e, t) { | ||
var n = s.get(e); | ||
n && n.slice().map(function(r) { | ||
var s = n.get(e); | ||
s && s.slice().map(function(r) { | ||
r(t); | ||
}), (n = s.get("*")) && n.slice().map(function(r) { | ||
}), (s = n.get("*")) && s.slice().map(function(r) { | ||
r(e, t); | ||
@@ -1085,7 +1215,7 @@ }); | ||
} | ||
const Jt = Xt(), ie = () => ({ | ||
emitter: Jt | ||
const En = yn(), ae = () => ({ | ||
emitter: En | ||
}); | ||
function Zt(s, e) { | ||
let t = s.nextElementSibling; | ||
function In(n, e) { | ||
let t = n.nextElementSibling; | ||
for (; t; ) { | ||
@@ -1097,4 +1227,4 @@ if (t.matches(e)) | ||
} | ||
function qt(s, e) { | ||
let t = s.previousElementSibling; | ||
function Sn(n, e) { | ||
let t = n.previousElementSibling; | ||
for (; t; ) { | ||
@@ -1106,6 +1236,6 @@ if (t.matches(e)) | ||
} | ||
const es = { "command-root": "" }, ts = S({ | ||
const wn = { "command-root": "" }, Mn = x({ | ||
name: "Command" | ||
}), ge = /* @__PURE__ */ S({ | ||
...ts, | ||
}), Se = /* @__PURE__ */ x({ | ||
...Mn, | ||
props: { | ||
@@ -1118,65 +1248,65 @@ theme: { | ||
emits: ["select-item"], | ||
setup(s, { emit: e }) { | ||
const t = s, n = '[command-item=""]', r = "command-item-key", i = '[command-group=""]', o = "command-group-key", c = '[command-group-heading=""]', a = `${n}:not([aria-disabled="true"])`, u = `${n}[aria-selected="true"]`, h = "command-item-select", f = "data-value", d = { | ||
setup(n, { emit: e }) { | ||
const t = n, s = '[command-item=""]', r = "command-item-key", o = '[command-group=""]', i = "command-group-key", a = '[command-group-heading=""]', c = `${s}:not([aria-disabled="true"])`, u = `${s}[aria-selected="true"]`, h = "command-item-select", d = "data-value", p = { | ||
threshold: 0.2, | ||
keys: ["label"] | ||
}; | ||
et("theme", t.theme || "default"); | ||
const { selectedNode: p, search: v, dataValue: w, filtered: I } = Q(), { emitter: A } = ie(), k = N(), R = oe(N(/* @__PURE__ */ new Map()), 333), G = oe(N(/* @__PURE__ */ new Set()), 333), q = oe(N(/* @__PURE__ */ new Map())), Y = K(() => { | ||
dt("theme", t.theme || "default"); | ||
const { selectedNode: _, search: y, dataValue: f, filtered: g } = J(), { emitter: I } = ae(), M = T(), S = le(T(/* @__PURE__ */ new Map()), 333), C = le(T(/* @__PURE__ */ new Set()), 333), W = le(T(/* @__PURE__ */ new Map())), A = $(() => { | ||
const l = []; | ||
for (const [_, g] of R.value.entries()) | ||
for (const [E, v] of S.value.entries()) | ||
l.push({ | ||
key: _, | ||
label: g | ||
key: E, | ||
label: v | ||
}); | ||
return l; | ||
}), M = K(() => { | ||
const l = H.createIndex(d.keys, Y.value); | ||
return new H(Y.value, d, l); | ||
}), $ = () => { | ||
var _, g, E; | ||
const l = x(); | ||
l && (((_ = l.parentElement) == null ? void 0 : _.firstElementChild) === l && ((E = (g = l.closest(i)) == null ? void 0 : g.querySelector(c)) == null || E.scrollIntoView({ block: "nearest" })), l.scrollIntoView({ block: "nearest" })); | ||
}, x = () => { | ||
}), R = $(() => { | ||
const l = Y.createIndex(p.keys, A.value); | ||
return new Y(A.value, p, l); | ||
}), N = () => { | ||
var E, v, w; | ||
const l = L(); | ||
l && (((E = l.parentElement) == null ? void 0 : E.firstElementChild) === l && ((w = (v = l.closest(o)) == null ? void 0 : v.querySelector(a)) == null || w.scrollIntoView({ block: "nearest" })), l.scrollIntoView({ block: "nearest" })); | ||
}, L = () => { | ||
var l; | ||
return (l = k.value) == null ? void 0 : l.querySelector(u); | ||
}, O = (l = k.value) => { | ||
const _ = l == null ? void 0 : l.querySelectorAll( | ||
a | ||
return (l = M.value) == null ? void 0 : l.querySelector(u); | ||
}, K = (l = M.value) => { | ||
const E = l == null ? void 0 : l.querySelectorAll( | ||
c | ||
); | ||
return _ ? Array.from(_) : []; | ||
return E ? Array.from(E) : []; | ||
}, X = () => { | ||
var _; | ||
const l = (_ = k.value) == null ? void 0 : _.querySelectorAll( | ||
i | ||
var E; | ||
const l = (E = M.value) == null ? void 0 : E.querySelectorAll( | ||
o | ||
); | ||
return l ? Array.from(l) : []; | ||
}, C = () => { | ||
const [l] = O(); | ||
l && l.getAttribute(r) && (p.value = l.getAttribute(r) || ""); | ||
}, J = (l) => { | ||
const g = O()[l]; | ||
g && (p.value = g.getAttribute(r) || ""); | ||
}, y = (l) => { | ||
const _ = x(), g = O(), E = g.findIndex((ee) => ee === _), D = g[E + l]; | ||
D ? p.value = D.getAttribute(r) || "" : l > 0 ? J(0) : J(g.length - 1); | ||
}, B = (l) => { | ||
const _ = x(); | ||
let g = _ == null ? void 0 : _.closest(i), E = null; | ||
for (; g && !E; ) | ||
g = l > 0 ? Zt(g, i) : qt(g, i), E = g == null ? void 0 : g.querySelector(a); | ||
E ? p.value = E.getAttribute(r) || "" : y(l); | ||
}, Z = () => J(0), ye = () => J(O().length - 1), Se = (l) => { | ||
l.preventDefault(), l.metaKey ? ye() : l.altKey ? B(1) : y(1); | ||
}, Ie = (l) => { | ||
l.preventDefault(), l.metaKey ? Z() : l.altKey ? B(-1) : y(-1); | ||
}, He = (l) => { | ||
}, P = () => { | ||
const [l] = K(); | ||
l && l.getAttribute(r) && (_.value = l.getAttribute(r) || ""); | ||
}, Z = (l) => { | ||
const v = K()[l]; | ||
v && (_.value = v.getAttribute(r) || ""); | ||
}, b = (l) => { | ||
const E = L(), v = K(), w = v.findIndex((te) => te === E), V = v[w + l]; | ||
V ? _.value = V.getAttribute(r) || "" : l > 0 ? Z(0) : Z(v.length - 1); | ||
}, U = (l) => { | ||
const E = L(); | ||
let v = E == null ? void 0 : E.closest(o), w = null; | ||
for (; v && !w; ) | ||
v = l > 0 ? In(v, o) : Sn(v, o), w = v == null ? void 0 : v.querySelector(c); | ||
w ? _.value = w.getAttribute(r) || "" : b(l); | ||
}, q = () => Z(0), xe = () => Z(K().length - 1), Ae = (l) => { | ||
l.preventDefault(), l.metaKey ? xe() : l.altKey ? U(1) : b(1); | ||
}, Re = (l) => { | ||
l.preventDefault(), l.metaKey ? q() : l.altKey ? U(-1) : b(-1); | ||
}, rt = (l) => { | ||
switch (l.key) { | ||
case "n": | ||
case "j": { | ||
l.ctrlKey && Se(l); | ||
l.ctrlKey && Ae(l); | ||
break; | ||
} | ||
case "ArrowDown": { | ||
Se(l); | ||
Ae(l); | ||
break; | ||
@@ -1186,92 +1316,92 @@ } | ||
case "k": { | ||
l.ctrlKey && Ie(l); | ||
l.ctrlKey && Re(l); | ||
break; | ||
} | ||
case "ArrowUp": { | ||
Ie(l); | ||
Re(l); | ||
break; | ||
} | ||
case "Home": { | ||
Z(); | ||
q(); | ||
break; | ||
} | ||
case "End": { | ||
ye(); | ||
xe(); | ||
break; | ||
} | ||
case "Enter": { | ||
const _ = x(); | ||
if (_) { | ||
const g = new Event(h); | ||
_.dispatchEvent(g); | ||
const E = L(); | ||
if (E) { | ||
const v = new Event(h); | ||
E.dispatchEvent(v); | ||
} | ||
} | ||
} | ||
}, Ye = () => { | ||
if (!v.value) { | ||
I.value.count = G.value.size; | ||
}, ot = () => { | ||
if (!y.value) { | ||
g.value.count = C.value.size; | ||
return; | ||
} | ||
I.value.groups = new Set(""); | ||
const l = /* @__PURE__ */ new Map(), _ = M.value.search(v.value).map((g) => g.item); | ||
for (const { key: g, label: E } of _) | ||
l.set(g, E); | ||
for (const [g, E] of q.value) | ||
for (const D of E) | ||
l.get(D) && I.value.groups.add(g); | ||
te(() => { | ||
I.value.count = l.size, I.value.items = l; | ||
g.value.groups = new Set(""); | ||
const l = /* @__PURE__ */ new Map(), E = R.value.search(y.value).map((v) => v.item); | ||
for (const { key: v, label: w } of E) | ||
l.set(v, w); | ||
for (const [v, w] of W.value) | ||
for (const V of w) | ||
l.get(V) && g.value.groups.add(v); | ||
ne(() => { | ||
g.value.count = l.size, g.value.items = l; | ||
}); | ||
}, Me = () => { | ||
const l = O(), _ = X(); | ||
for (const g of l) { | ||
const E = g.getAttribute(r) || "", D = g.getAttribute(f) || ""; | ||
G.value.add(E), R.value.set(E, D), I.value.count = R.value.size; | ||
}, Le = () => { | ||
const l = K(), E = X(); | ||
for (const v of l) { | ||
const w = v.getAttribute(r) || "", V = v.getAttribute(d) || ""; | ||
C.value.add(w), S.value.set(w, V), g.value.count = S.value.size; | ||
} | ||
for (const g of _) { | ||
const E = O(g), D = g.getAttribute(o) || "", ee = new Set(""); | ||
for (const Xe of E) { | ||
const Je = Xe.getAttribute(r) || ""; | ||
ee.add(Je); | ||
for (const v of E) { | ||
const w = K(v), V = v.getAttribute(i) || "", te = new Set(""); | ||
for (const ct of w) { | ||
const at = ct.getAttribute(r) || ""; | ||
te.add(at); | ||
} | ||
q.value.set(D, ee); | ||
W.value.set(V, te); | ||
} | ||
}; | ||
ae( | ||
() => p.value, | ||
ee( | ||
() => _.value, | ||
(l) => { | ||
l && te($); | ||
l && ne(N); | ||
}, | ||
{ deep: !0 } | ||
), ae( | ||
() => v.value, | ||
), ee( | ||
() => y.value, | ||
(l) => { | ||
Ye(), te(C); | ||
ot(), ne(P); | ||
} | ||
), A.on("selectItem", (l) => { | ||
), I.on("selectItem", (l) => { | ||
e("select-item", l); | ||
}); | ||
const Qe = Fe((l) => { | ||
l && (Me(), te(C)); | ||
const it = Ue((l) => { | ||
l && (Le(), ne(P)); | ||
}, 100); | ||
return A.on("rerenderList", Qe), tt(() => { | ||
Me(), C(); | ||
}), (l, _) => (F(), W("div", { | ||
class: st(s.theme), | ||
onKeydown: He, | ||
return I.on("rerenderList", it), ft(() => { | ||
Le(), P(); | ||
}), (l, E) => (D(), H("div", { | ||
class: mt(n.theme), | ||
onKeydown: rt, | ||
ref_key: "commandRef", | ||
ref: k | ||
ref: M | ||
}, [ | ||
V("div", es, [ | ||
z(l.$slots, "default") | ||
B("div", wn, [ | ||
Q(l.$slots, "default") | ||
]) | ||
], 34)); | ||
} | ||
}), ss = { "command-dialog": "" }, ns = { "command-dialog-mask": "" }, rs = { "command-dialog-wrapper": "" }, is = { "command-dialog-header": "" }, os = { "command-dialog-body": "" }, cs = { | ||
}), bn = { "command-dialog": "" }, xn = { "command-dialog-mask": "" }, An = { "command-dialog-wrapper": "" }, Rn = { "command-dialog-header": "" }, Ln = { "command-dialog-body": "" }, On = { | ||
key: 0, | ||
"command-dialog-footer": "" | ||
}, as = S({ | ||
}, kn = x({ | ||
name: "Command.Dialog" | ||
}), ls = /* @__PURE__ */ S({ | ||
...as, | ||
}), Cn = /* @__PURE__ */ x({ | ||
...kn, | ||
props: { | ||
@@ -1281,33 +1411,38 @@ visible: { type: Boolean }, | ||
}, | ||
emits: ["select-item", "keydown"], | ||
setup(s, { emit: e }) { | ||
const { search: t, filtered: n } = Q(), { emitter: r } = ie(); | ||
return r.on("selectItem", (i) => { | ||
e("select-item", i); | ||
}), _e(() => { | ||
t.value = "", n.value.count = 0, n.value.items = /* @__PURE__ */ new Map(), n.value.groups = /* @__PURE__ */ new Set(); | ||
}), (i, o) => (F(), we(nt, { to: "body" }, [ | ||
rt(it, { | ||
emits: ["select-item"], | ||
setup(n, { emit: e }) { | ||
const t = n, { search: s, filtered: r } = J(), { emitter: o } = ae(), i = T(); | ||
o.on("selectItem", (c) => { | ||
e("select-item", c); | ||
}); | ||
const a = () => { | ||
s.value = "", r.value.count = 0, r.value.items = /* @__PURE__ */ new Map(), r.value.groups = /* @__PURE__ */ new Set(); | ||
}; | ||
return ze(() => t.visible, a), we(a), (c, u) => (D(), Oe(pt, { | ||
to: "body", | ||
ref_key: "dialogRef", | ||
ref: i | ||
}, [ | ||
gt(_t, { | ||
name: "command-dialog", | ||
appear: "" | ||
}, { | ||
default: xe(() => [ | ||
s.visible ? (F(), we(ge, { | ||
default: ke(() => [ | ||
n.visible ? (D(), Oe(Se, { | ||
key: 0, | ||
theme: s.theme, | ||
onKeydown: o[0] || (o[0] = (c) => e("keydown", c)) | ||
theme: n.theme | ||
}, { | ||
default: xe(() => [ | ||
V("div", ss, [ | ||
V("div", ns, [ | ||
V("div", rs, [ | ||
V("div", is, [ | ||
z(i.$slots, "header") | ||
default: ke(() => [ | ||
B("div", bn, [ | ||
B("div", xn, [ | ||
B("div", An, [ | ||
B("div", Rn, [ | ||
Q(c.$slots, "header") | ||
]), | ||
V("div", os, [ | ||
z(i.$slots, "body") | ||
B("div", Ln, [ | ||
Q(c.$slots, "body") | ||
]), | ||
i.$slots.footer ? (F(), W("div", cs, [ | ||
z(i.$slots, "footer") | ||
])) : le("", !0) | ||
c.$slots.footer ? (D(), H("div", On, [ | ||
Q(c.$slots, "footer") | ||
])) : de("", !0) | ||
]) | ||
@@ -1318,46 +1453,46 @@ ]) | ||
_: 3 | ||
}, 8, ["theme"])) : le("", !0) | ||
}, 8, ["theme"])) : de("", !0) | ||
]), | ||
_: 3 | ||
}) | ||
])); | ||
], 512)); | ||
} | ||
}); | ||
let We = (s = 21) => crypto.getRandomValues(new Uint8Array(s)).reduce((e, t) => (t &= 63, t < 36 ? e += t.toString(36) : t < 62 ? e += (t - 26).toString(36).toUpperCase() : t > 62 ? e += "-" : e += "_", e), ""); | ||
const us = ["command-group-key", "data-value"], hs = { | ||
let st = (n = 21) => crypto.getRandomValues(new Uint8Array(n)).reduce((e, t) => (t &= 63, t < 36 ? e += t.toString(36) : t < 62 ? e += (t - 26).toString(36).toUpperCase() : t > 62 ? e += "-" : e += "_", e), ""); | ||
const Tn = ["command-group-key", "data-value"], $n = { | ||
key: 0, | ||
"command-group-heading": "" | ||
}, ds = { | ||
}, Nn = { | ||
"command-group-items": "", | ||
role: "group" | ||
}, fs = S({ | ||
}, Pn = x({ | ||
name: "Command.Group" | ||
}), ms = /* @__PURE__ */ S({ | ||
...fs, | ||
}), Fn = /* @__PURE__ */ x({ | ||
...Pn, | ||
props: { | ||
heading: null | ||
}, | ||
setup(s) { | ||
const e = K(() => `command-group-${We()}`), { filtered: t, isSearching: n } = Q(), r = K( | ||
() => n.value ? t.value.groups.has(e.value) : !0 | ||
setup(n) { | ||
const e = $(() => `command-group-${st()}`), { filtered: t, isSearching: s } = J(), r = $( | ||
() => s.value ? t.value.groups.has(e.value) : !0 | ||
); | ||
return (i, o) => Oe((F(), W("div", { | ||
return (o, i) => Be((D(), H("div", { | ||
"command-group": "", | ||
role: "presentation", | ||
key: L(e), | ||
"command-group-key": L(e), | ||
"data-value": s.heading | ||
key: O(e), | ||
"command-group-key": O(e), | ||
"data-value": n.heading | ||
}, [ | ||
s.heading ? (F(), W("div", hs, ot(s.heading), 1)) : le("", !0), | ||
V("div", ds, [ | ||
z(i.$slots, "default") | ||
n.heading ? (D(), H("div", $n, vt(n.heading), 1)) : de("", !0), | ||
B("div", Nn, [ | ||
Q(o.$slots, "default") | ||
]) | ||
], 8, us)), [ | ||
[Ne, L(r)] | ||
], 8, Tn)), [ | ||
[Ge, O(r)] | ||
]); | ||
} | ||
}), ps = ["placeholder", "value"], gs = S({ | ||
}), Kn = ["placeholder", "value"], Dn = x({ | ||
name: "Command.Input" | ||
}), _s = /* @__PURE__ */ S({ | ||
...gs, | ||
}), jn = /* @__PURE__ */ x({ | ||
...Dn, | ||
props: { | ||
@@ -1368,11 +1503,11 @@ placeholder: null, | ||
emits: ["input", "update:value"], | ||
setup(s, { emit: e }) { | ||
const t = N(null), { search: n } = Q(), r = K(() => n.value), i = (o) => { | ||
const c = o, a = o.target; | ||
n.value = a == null ? void 0 : a.value, e("input", c), e("update:value", n.value); | ||
setup(n, { emit: e }) { | ||
const t = T(null), { search: s } = J(), r = $(() => s.value), o = (i) => { | ||
const a = i, c = i.target; | ||
s.value = c == null ? void 0 : c.value, e("input", a), e("update:value", s.value); | ||
}; | ||
return ve(() => { | ||
var o; | ||
(o = t.value) == null || o.focus(); | ||
}), (o, c) => (F(), W("input", { | ||
return Me(() => { | ||
var i; | ||
(i = t.value) == null || i.focus(); | ||
}), (i, a) => (D(), H("input", { | ||
ref_key: "inputRef", | ||
@@ -1388,66 +1523,72 @@ ref: t, | ||
"aria-expanded": !0, | ||
placeholder: s.placeholder, | ||
value: L(r), | ||
onInput: i | ||
}, null, 40, ps)); | ||
placeholder: n.placeholder, | ||
value: O(r), | ||
onInput: o | ||
}, null, 40, Kn)); | ||
} | ||
}), vs = ["aria-selected", "aria-disabled", "command-item-key"], Es = S({ | ||
}), Vn = ["aria-selected", "aria-disabled", "command-item-key"], Bn = x({ | ||
name: "Command.Item" | ||
}), ys = /* @__PURE__ */ S({ | ||
...Es, | ||
}), Gn = /* @__PURE__ */ x({ | ||
...Bn, | ||
props: { | ||
shortcut: null, | ||
perform: null | ||
}, | ||
emits: ["select"], | ||
setup(s, { emit: e }) { | ||
const t = "command-item-select", n = "data-value", { selectedNode: r, filtered: i, isSearching: o } = Q(), { emitter: c } = ie(), a = N(), u = K(() => `command-item-${We()}`), h = K(() => { | ||
const d = i.value.items.get(u.value); | ||
return o.value ? d !== void 0 : !0; | ||
}), f = () => { | ||
var p; | ||
const d = { | ||
key: u.value, | ||
value: ((p = a.value) == null ? void 0 : p.getAttribute(n)) || "" | ||
setup(n, { emit: e }) { | ||
const t = n, s = "command-item-select", r = "data-value", { current: o } = xt(), { selectedNode: i, filtered: a, isSearching: c } = J(), { emitter: u } = ae(), h = T(), d = $(() => `command-item-${st()}`), p = $(() => { | ||
const f = a.value.items.get(d.value); | ||
return c.value ? f !== void 0 : !0; | ||
}), _ = $(() => Array.from(o)), y = () => { | ||
var g; | ||
const f = { | ||
key: d.value, | ||
value: ((g = h.value) == null ? void 0 : g.getAttribute(r)) || "" | ||
}; | ||
e("select", d), c.emit("selectItem", d); | ||
e("select", f), u.emit("selectItem", f); | ||
}; | ||
return ve(() => { | ||
var d; | ||
(d = a.value) == null || d.addEventListener(t, f); | ||
}), _e(() => { | ||
var d; | ||
(d = a.value) == null || d.removeEventListener(t, f); | ||
}), (d, p) => Oe((F(), W("div", { | ||
return ze(_, (f) => { | ||
t.shortcut && t.shortcut.length > 0 && t.shortcut.every((I) => o.has(I.toLowerCase())) && t.perform && t.perform(); | ||
}), Me(() => { | ||
var f; | ||
(f = h.value) == null || f.addEventListener(s, y); | ||
}), we(() => { | ||
var f; | ||
(f = h.value) == null || f.removeEventListener(s, y); | ||
}), (f, g) => Be((D(), H("div", { | ||
ref_key: "itemRef", | ||
ref: a, | ||
ref: h, | ||
"command-item": "", | ||
role: "option", | ||
"aria-selected": L(r) === L(u), | ||
"aria-disabled": !L(h), | ||
key: L(u), | ||
"command-item-key": L(u), | ||
onClick: f | ||
"aria-selected": O(i) === O(d), | ||
"aria-disabled": !O(p), | ||
key: O(d), | ||
"command-item-key": O(d), | ||
onClick: y | ||
}, [ | ||
z(d.$slots, "default") | ||
], 8, vs)), [ | ||
[Ne, L(h)] | ||
Q(f.$slots, "default") | ||
], 8, Vn)), [ | ||
[Ge, O(p)] | ||
]); | ||
} | ||
}), Ss = S({ | ||
}), Wn = x({ | ||
name: "Command.List" | ||
}), Is = /* @__PURE__ */ S({ | ||
...Ss, | ||
setup(s) { | ||
const { emitter: e } = ie(), t = N(), n = N(); | ||
let r = null, i; | ||
return ve(() => { | ||
i = n.value; | ||
const o = t.value; | ||
i && o && (r = new ResizeObserver((c) => { | ||
const a = i == null ? void 0 : i.getBoundingClientRect().height; | ||
o == null || o.style.setProperty( | ||
}), Un = /* @__PURE__ */ x({ | ||
...Wn, | ||
setup(n) { | ||
const { emitter: e } = ae(), t = T(), s = T(); | ||
let r = null, o; | ||
return Me(() => { | ||
o = s.value; | ||
const i = t.value; | ||
o && i && (r = new ResizeObserver((a) => { | ||
const c = o == null ? void 0 : o.getBoundingClientRect().height; | ||
i == null || i.style.setProperty( | ||
"--command-list-height", | ||
`${a == null ? void 0 : a.toFixed(1)}px` | ||
`${c == null ? void 0 : c.toFixed(1)}px` | ||
), e.emit("rerenderList", !0); | ||
}), r.observe(i)); | ||
}), _e(() => { | ||
r !== null && i && r.unobserve(i); | ||
}), (o, c) => (F(), W("div", { | ||
}), r.observe(o)); | ||
}), we(() => { | ||
r !== null && o && r.unobserve(o); | ||
}), (i, a) => (D(), H("div", { | ||
"command-list": "", | ||
@@ -1459,16 +1600,16 @@ role: "listbox", | ||
}, [ | ||
V("div", { | ||
B("div", { | ||
"command-list-sizer": "", | ||
ref_key: "heightRef", | ||
ref: n | ||
ref: s | ||
}, [ | ||
z(o.$slots, "default") | ||
Q(i.$slots, "default") | ||
], 512) | ||
], 512)); | ||
} | ||
}), Ms = S({ | ||
}), zn = x({ | ||
name: "Command.Empty", | ||
setup(s, { attrs: e, slots: t }) { | ||
const { filtered: n } = Q(), r = K(() => n.value.count === 0); | ||
return () => r.value ? ne( | ||
setup(n, { attrs: e, slots: t }) { | ||
const { filtered: s } = J(), r = $(() => s.value.count === 0); | ||
return () => r.value ? ie( | ||
"div", | ||
@@ -1481,3 +1622,3 @@ { | ||
t | ||
) : ne("div", { | ||
) : ie("div", { | ||
"command-empty": "hidden", | ||
@@ -1491,6 +1632,6 @@ role: "presentation", | ||
} | ||
}), ws = S({ | ||
}), Qn = x({ | ||
name: "Command.Loading", | ||
setup(s, { attrs: e, slots: t }) { | ||
return () => ne( | ||
setup(n, { attrs: e, slots: t }) { | ||
return () => ie( | ||
"div", | ||
@@ -1505,6 +1646,6 @@ { | ||
} | ||
}), xs = S({ | ||
}), Hn = x({ | ||
name: "Command.Separator", | ||
setup(s, { attrs: e, slots: t }) { | ||
return () => ne("div", { | ||
setup(n, { attrs: e, slots: t }) { | ||
return () => ie("div", { | ||
"command-separator": "", | ||
@@ -1515,15 +1656,15 @@ role: "separator", | ||
} | ||
}), As = Object.assign(ge, { | ||
Dialog: ls, | ||
Empty: Ms, | ||
Group: ms, | ||
Input: _s, | ||
Item: ys, | ||
List: Is, | ||
Loading: ws, | ||
Separator: xs, | ||
Root: ge | ||
}), Jn = Object.assign(Se, { | ||
Dialog: Cn, | ||
Empty: zn, | ||
Group: Fn, | ||
Input: jn, | ||
Item: Gn, | ||
List: Un, | ||
Loading: Qn, | ||
Separator: Hn, | ||
Root: Se | ||
}); | ||
export { | ||
As as Command | ||
Jn as Command | ||
}; |
{ | ||
"name": "vue-command-palette", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"type": "module", | ||
@@ -39,2 +39,3 @@ "author": "xiaoluoboding <xiaoluoboding@gmail.com>", | ||
"@vueuse/core": "^9.1.1", | ||
"highlight.js": "^11.6.0", | ||
"sass": "^1.54.8", | ||
@@ -41,0 +42,0 @@ "typescript": "^4.6.4", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81803
1829
15