Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@eox/itemfilter

Package Overview
Dependencies
Maintainers
5
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eox/itemfilter - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

test/reducedWidth.cy.ts

1640

dist/eox-itemfilter.js

@@ -1,55 +0,55 @@

var ut = Object.defineProperty;
var ft = (e, t, s) => t in e ? ut(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
var x = (e, t, s) => (ft(e, typeof t != "symbol" ? t + "" : t, s), s);
function A(e) {
return Array.isArray ? Array.isArray(e) : st(e) === "[object Array]";
var he = Object.defineProperty;
var ue = (s, e, t) => e in s ? he(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
var b = (s, e, t) => (ue(s, typeof e != "symbol" ? e + "" : e, t), t);
function L(s) {
return Array.isArray ? Array.isArray(s) : se(s) === "[object Array]";
}
const dt = 1 / 0;
function gt(e) {
if (typeof e == "string")
return e;
let t = e + "";
return t == "0" && 1 / e == -dt ? "-0" : t;
const fe = 1 / 0;
function de(s) {
if (typeof s == "string")
return s;
let e = s + "";
return e == "0" && 1 / s == -fe ? "-0" : e;
}
function pt(e) {
return e == null ? "" : gt(e);
function ge(s) {
return s == null ? "" : de(s);
}
function S(e) {
return typeof e == "string";
function w(s) {
return typeof s == "string";
}
function tt(e) {
return typeof e == "number";
function ee(s) {
return typeof s == "number";
}
function mt(e) {
return e === !0 || e === !1 || yt(e) && st(e) == "[object Boolean]";
function pe(s) {
return s === !0 || s === !1 || me(s) && se(s) == "[object Boolean]";
}
function et(e) {
return typeof e == "object";
function te(s) {
return typeof s == "object";
}
function yt(e) {
return et(e) && e !== null;
function me(s) {
return te(s) && s !== null;
}
function m(e) {
return e != null;
function y(s) {
return s != null;
}
function H(e) {
return !e.trim().length;
function P(s) {
return !s.trim().length;
}
function st(e) {
return e == null ? e === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(e);
function se(s) {
return s == null ? s === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(s);
}
const Mt = "Incorrect 'index' type", Et = (e) => `Invalid value for key ${e}`, xt = (e) => `Pattern length exceeds max of ${e}.`, St = (e) => `Missing ${e} property in key`, It = (e) => `Property 'weight' in key '${e}' must be a positive integer`, Q = Object.prototype.hasOwnProperty;
class At {
constructor(t) {
const ye = "Incorrect 'index' type", xe = (s) => `Invalid value for key ${s}`, Me = (s) => `Pattern length exceeds max of ${s}.`, Ee = (s) => `Missing ${s} property in key`, we = (s) => `Property 'weight' in key '${s}' must be a positive integer`, G = Object.prototype.hasOwnProperty;
class Se {
constructor(e) {
this._keys = [], this._keyMap = {};
let s = 0;
t.forEach((n) => {
let r = rt(n);
s += r.weight, this._keys.push(r), this._keyMap[r.id] = r, s += r.weight;
}), this._keys.forEach((n) => {
n.weight /= s;
let t = 0;
e.forEach((r) => {
let i = ie(r);
t += i.weight, this._keys.push(i), this._keyMap[i.id] = i, t += i.weight;
}), this._keys.forEach((r) => {
r.weight /= t;
});
}
get(t) {
return this._keyMap[t];
get(e) {
return this._keyMap[e];
}

@@ -63,46 +63,46 @@ keys() {

}
function rt(e) {
let t = null, s = null, n = null, r = 1, i = null;
if (S(e) || A(e))
n = e, t = X(e), s = K(e);
function ie(s) {
let e = null, t = null, r = null, i = 1, c = null;
if (w(s) || L(s))
r = s, e = Q(s), t = B(s);
else {
if (!Q.call(e, "name"))
throw new Error(St("name"));
const c = e.name;
if (n = c, Q.call(e, "weight") && (r = e.weight, r <= 0))
throw new Error(It(c));
t = X(c), s = K(c), i = e.getFn;
if (!G.call(s, "name"))
throw new Error(Ee("name"));
const n = s.name;
if (r = n, G.call(s, "weight") && (i = s.weight, i <= 0))
throw new Error(we(n));
e = Q(n), t = B(n), c = s.getFn;
}
return { path: t, id: s, weight: r, src: n, getFn: i };
return { path: e, id: t, weight: i, src: r, getFn: c };
}
function X(e) {
return A(e) ? e : e.split(".");
function Q(s) {
return L(s) ? s : s.split(".");
}
function K(e) {
return A(e) ? e.join(".") : e;
function B(s) {
return L(s) ? s.join(".") : s;
}
function _t(e, t) {
let s = [], n = !1;
const r = (i, c, o) => {
if (m(i))
if (!c[o])
s.push(i);
function Le(s, e) {
let t = [], r = !1;
const i = (c, n, o) => {
if (y(c))
if (!n[o])
t.push(c);
else {
let a = c[o];
const h = i[a];
if (!m(h))
let l = n[o];
const a = c[l];
if (!y(a))
return;
if (o === c.length - 1 && (S(h) || tt(h) || mt(h)))
s.push(pt(h));
else if (A(h)) {
n = !0;
for (let l = 0, u = h.length; l < u; l += 1)
r(h[l], c, o + 1);
if (o === n.length - 1 && (w(a) || ee(a) || pe(a)))
t.push(ge(a));
else if (L(a)) {
r = !0;
for (let h = 0, u = a.length; h < u; h += 1)
i(a[h], n, o + 1);
} else
c.length && r(h, c, o + 1);
n.length && i(a, n, o + 1);
}
};
return r(e, S(t) ? t.split(".") : t, 0), n ? s : s[0];
return i(s, w(e) ? e.split(".") : e, 0), r ? t : t[0];
}
const wt = {
const Ae = {
// Whether the matches should be included in the result set. When `true`, each record in the result

@@ -117,3 +117,3 @@ // set will include the indices of the matched characters.

minMatchCharLength: 1
}, Lt = {
}, Ie = {
// When `true`, the algorithm continues searching to the end of the input even if a perfect

@@ -129,4 +129,4 @@ // match is found before the end of the same input.

// Default sort function: sort by ascending score, ascending index
sortFn: (e, t) => e.score === t.score ? e.idx < t.idx ? -1 : 1 : e.score < t.score ? -1 : 1
}, Rt = {
sortFn: (s, e) => s.score === e.score ? s.idx < e.idx ? -1 : 1 : s.score < e.score ? -1 : 1
}, be = {
// Approximately where in the text is the pattern expected to be found?

@@ -143,3 +143,3 @@ location: 0,

distance: 100
}, bt = {
}, _e = {
// When `true`, it enables the use of unix-like search commands

@@ -149,3 +149,3 @@ useExtendedSearch: !1,

// The default will search nested paths *ie foo.bar.baz*
getFn: _t,
getFn: Le,
// When `true`, search will ignore `location` and `distance`, so it won't matter

@@ -162,62 +162,62 @@ // where in the string the pattern appears.

};
var f = {
...Lt,
...wt,
...Rt,
...bt
var d = {
...Ie,
...Ae,
...be,
..._e
};
const kt = /[^ ]+/g;
function Tt(e = 1, t = 3) {
const s = /* @__PURE__ */ new Map(), n = Math.pow(10, t);
const Re = /[^ ]+/g;
function ve(s = 1, e = 3) {
const t = /* @__PURE__ */ new Map(), r = Math.pow(10, e);
return {
get(r) {
const i = r.match(kt).length;
if (s.has(i))
return s.get(i);
const c = 1 / Math.pow(i, 0.5 * e), o = parseFloat(Math.round(c * n) / n);
return s.set(i, o), o;
get(i) {
const c = i.match(Re).length;
if (t.has(c))
return t.get(c);
const n = 1 / Math.pow(c, 0.5 * s), o = parseFloat(Math.round(n * r) / r);
return t.set(c, o), o;
},
clear() {
s.clear();
t.clear();
}
};
}
class Y {
class V {
constructor({
getFn: t = f.getFn,
fieldNormWeight: s = f.fieldNormWeight
getFn: e = d.getFn,
fieldNormWeight: t = d.fieldNormWeight
} = {}) {
this.norm = Tt(s, 3), this.getFn = t, this.isCreated = !1, this.setIndexRecords();
this.norm = ve(t, 3), this.getFn = e, this.isCreated = !1, this.setIndexRecords();
}
setSources(t = []) {
this.docs = t;
setSources(e = []) {
this.docs = e;
}
setIndexRecords(t = []) {
this.records = t;
setIndexRecords(e = []) {
this.records = e;
}
setKeys(t = []) {
this.keys = t, this._keysMap = {}, t.forEach((s, n) => {
this._keysMap[s.id] = n;
setKeys(e = []) {
this.keys = e, this._keysMap = {}, e.forEach((t, r) => {
this._keysMap[t.id] = r;
});
}
create() {
this.isCreated || !this.docs.length || (this.isCreated = !0, S(this.docs[0]) ? this.docs.forEach((t, s) => {
this._addString(t, s);
}) : this.docs.forEach((t, s) => {
this._addObject(t, s);
this.isCreated || !this.docs.length || (this.isCreated = !0, w(this.docs[0]) ? this.docs.forEach((e, t) => {
this._addString(e, t);
}) : this.docs.forEach((e, t) => {
this._addObject(e, t);
}), this.norm.clear());
}
// Adds a doc to the end of the index
add(t) {
const s = this.size();
S(t) ? this._addString(t, s) : this._addObject(t, s);
add(e) {
const t = this.size();
w(e) ? this._addString(e, t) : this._addObject(e, t);
}
// Removes the doc at the specified index of the index
removeAt(t) {
this.records.splice(t, 1);
for (let s = t, n = this.size(); s < n; s += 1)
this.records[s].i -= 1;
removeAt(e) {
this.records.splice(e, 1);
for (let t = e, r = this.size(); t < r; t += 1)
this.records[t].i -= 1;
}
getValueForItemAtKeyId(t, s) {
return t[this._keysMap[s]];
getValueForItemAtKeyId(e, t) {
return e[this._keysMap[t]];
}

@@ -227,34 +227,34 @@ size() {

}
_addString(t, s) {
if (!m(t) || H(t))
_addString(e, t) {
if (!y(e) || P(e))
return;
let n = {
v: t,
i: s,
n: this.norm.get(t)
let r = {
v: e,
i: t,
n: this.norm.get(e)
};
this.records.push(n);
this.records.push(r);
}
_addObject(t, s) {
let n = { i: s, $: {} };
this.keys.forEach((r, i) => {
let c = r.getFn ? r.getFn(t) : this.getFn(t, r.path);
if (m(c)) {
if (A(c)) {
_addObject(e, t) {
let r = { i: t, $: {} };
this.keys.forEach((i, c) => {
let n = i.getFn ? i.getFn(e) : this.getFn(e, i.path);
if (y(n)) {
if (L(n)) {
let o = [];
const a = [{ nestedArrIndex: -1, value: c }];
for (; a.length; ) {
const { nestedArrIndex: h, value: l } = a.pop();
if (m(l))
if (S(l) && !H(l)) {
const l = [{ nestedArrIndex: -1, value: n }];
for (; l.length; ) {
const { nestedArrIndex: a, value: h } = l.pop();
if (y(h))
if (w(h) && !P(h)) {
let u = {
v: l,
i: h,
n: this.norm.get(l)
v: h,
i: a,
n: this.norm.get(h)
};
o.push(u);
} else
A(l) && l.forEach((u, d) => {
a.push({
nestedArrIndex: d,
L(h) && h.forEach((u, f) => {
l.push({
nestedArrIndex: f,
value: u

@@ -264,12 +264,12 @@ });

}
n.$[i] = o;
} else if (S(c) && !H(c)) {
r.$[c] = o;
} else if (w(n) && !P(n)) {
let o = {
v: c,
n: this.norm.get(c)
v: n,
n: this.norm.get(n)
};
n.$[i] = o;
r.$[c] = o;
}
}
}), this.records.push(n);
}), this.records.push(r);
}

@@ -283,163 +283,163 @@ toJSON() {

}
function nt(e, t, { getFn: s = f.getFn, fieldNormWeight: n = f.fieldNormWeight } = {}) {
const r = new Y({ getFn: s, fieldNormWeight: n });
return r.setKeys(e.map(rt)), r.setSources(t), r.create(), r;
function re(s, e, { getFn: t = d.getFn, fieldNormWeight: r = d.fieldNormWeight } = {}) {
const i = new V({ getFn: t, fieldNormWeight: r });
return i.setKeys(s.map(ie)), i.setSources(e), i.create(), i;
}
function $t(e, { getFn: t = f.getFn, fieldNormWeight: s = f.fieldNormWeight } = {}) {
const { keys: n, records: r } = e, i = new Y({ getFn: t, fieldNormWeight: s });
return i.setKeys(n), i.setIndexRecords(r), i;
function Te(s, { getFn: e = d.getFn, fieldNormWeight: t = d.fieldNormWeight } = {}) {
const { keys: r, records: i } = s, c = new V({ getFn: e, fieldNormWeight: t });
return c.setKeys(r), c.setIndexRecords(i), c;
}
function v(e, {
errors: t = 0,
currentLocation: s = 0,
expectedLocation: n = 0,
distance: r = f.distance,
ignoreLocation: i = f.ignoreLocation
function C(s, {
errors: e = 0,
currentLocation: t = 0,
expectedLocation: r = 0,
distance: i = d.distance,
ignoreLocation: c = d.ignoreLocation
} = {}) {
const c = t / e.length;
if (i)
return c;
const o = Math.abs(n - s);
return r ? c + o / r : o ? 1 : c;
const n = e / s.length;
if (c)
return n;
const o = Math.abs(r - t);
return i ? n + o / i : o ? 1 : n;
}
function Nt(e = [], t = f.minMatchCharLength) {
let s = [], n = -1, r = -1, i = 0;
for (let c = e.length; i < c; i += 1) {
let o = e[i];
o && n === -1 ? n = i : !o && n !== -1 && (r = i - 1, r - n + 1 >= t && s.push([n, r]), n = -1);
function ke(s = [], e = d.minMatchCharLength) {
let t = [], r = -1, i = -1, c = 0;
for (let n = s.length; c < n; c += 1) {
let o = s[c];
o && r === -1 ? r = c : !o && r !== -1 && (i = c - 1, i - r + 1 >= e && t.push([r, i]), r = -1);
}
return e[i - 1] && i - n >= t && s.push([n, i - 1]), s;
return s[c - 1] && c - r >= e && t.push([r, c - 1]), t;
}
const k = 32;
function Ot(e, t, s, {
location: n = f.location,
distance: r = f.distance,
threshold: i = f.threshold,
findAllMatches: c = f.findAllMatches,
minMatchCharLength: o = f.minMatchCharLength,
includeMatches: a = f.includeMatches,
ignoreLocation: h = f.ignoreLocation
const v = 32;
function $e(s, e, t, {
location: r = d.location,
distance: i = d.distance,
threshold: c = d.threshold,
findAllMatches: n = d.findAllMatches,
minMatchCharLength: o = d.minMatchCharLength,
includeMatches: l = d.includeMatches,
ignoreLocation: a = d.ignoreLocation
} = {}) {
if (t.length > k)
throw new Error(xt(k));
const l = t.length, u = e.length, d = Math.max(0, Math.min(n, u));
let g = i, p = d;
const y = o > 1 || a, R = y ? Array(u) : [];
let I;
for (; (I = e.indexOf(t, p)) > -1; ) {
let M = v(t, {
currentLocation: I,
expectedLocation: d,
distance: r,
ignoreLocation: h
if (e.length > v)
throw new Error(Me(v));
const h = e.length, u = s.length, f = Math.max(0, Math.min(r, u));
let g = c, p = f;
const m = o > 1 || l, E = m ? Array(u) : [];
let S;
for (; (S = s.indexOf(e, p)) > -1; ) {
let x = C(e, {
currentLocation: S,
expectedLocation: f,
distance: i,
ignoreLocation: a
});
if (g = Math.min(M, g), p = I + l, y) {
let _ = 0;
for (; _ < l; )
R[I + _] = 1, _ += 1;
if (g = Math.min(x, g), p = S + h, m) {
let A = 0;
for (; A < h; )
E[S + A] = 1, A += 1;
}
}
p = -1;
let T = [], b = 1, O = l + u;
const lt = 1 << l - 1;
for (let M = 0; M < l; M += 1) {
let _ = 0, w = O;
for (; _ < w; )
v(t, {
errors: M,
currentLocation: d + w,
expectedLocation: d,
distance: r,
ignoreLocation: h
}) <= g ? _ = w : O = w, w = Math.floor((O - _) / 2 + _);
O = w;
let G = Math.max(1, d - w + 1), j = c ? u : Math.min(d + w, u) + l, $ = Array(j + 2);
$[j + 1] = (1 << M) - 1;
for (let E = j; E >= G; E -= 1) {
let C = E - 1, U = s[e.charAt(C)];
if (y && (R[C] = +!!U), $[E] = ($[E + 1] << 1 | 1) & U, M && ($[E] |= (T[E + 1] | T[E]) << 1 | 1 | T[E + 1]), $[E] & lt && (b = v(t, {
errors: M,
currentLocation: C,
expectedLocation: d,
distance: r,
ignoreLocation: h
}), b <= g)) {
if (g = b, p = C, p <= d)
let T = [], R = 1, N = h + u;
const ae = 1 << h - 1;
for (let x = 0; x < h; x += 1) {
let A = 0, I = N;
for (; A < I; )
C(e, {
errors: x,
currentLocation: f + I,
expectedLocation: f,
distance: i,
ignoreLocation: a
}) <= g ? A = I : N = I, I = Math.floor((N - A) / 2 + A);
N = I;
let U = Math.max(1, f - I + 1), H = n ? u : Math.min(f + I, u) + h, k = Array(H + 2);
k[H + 1] = (1 << x) - 1;
for (let M = H; M >= U; M -= 1) {
let O = M - 1, Y = t[s.charAt(O)];
if (m && (E[O] = +!!Y), k[M] = (k[M + 1] << 1 | 1) & Y, x && (k[M] |= (T[M + 1] | T[M]) << 1 | 1 | T[M + 1]), k[M] & ae && (R = C(e, {
errors: x,
currentLocation: O,
expectedLocation: f,
distance: i,
ignoreLocation: a
}), R <= g)) {
if (g = R, p = O, p <= f)
break;
G = Math.max(1, 2 * d - p);
U = Math.max(1, 2 * f - p);
}
}
if (v(t, {
errors: M + 1,
currentLocation: d,
expectedLocation: d,
distance: r,
ignoreLocation: h
if (C(e, {
errors: x + 1,
currentLocation: f,
expectedLocation: f,
distance: i,
ignoreLocation: a
}) > g)
break;
T = $;
T = k;
}
const P = {
const j = {
isMatch: p >= 0,
// Count exact matches (those with a score of 0) to be "almost" exact
score: Math.max(1e-3, b)
score: Math.max(1e-3, R)
};
if (y) {
const M = Nt(R, o);
M.length ? a && (P.indices = M) : P.isMatch = !1;
if (m) {
const x = ke(E, o);
x.length ? l && (j.indices = x) : j.isMatch = !1;
}
return P;
return j;
}
function Ct(e) {
let t = {};
for (let s = 0, n = e.length; s < n; s += 1) {
const r = e.charAt(s);
t[r] = (t[r] || 0) | 1 << n - s - 1;
function Ne(s) {
let e = {};
for (let t = 0, r = s.length; t < r; t += 1) {
const i = s.charAt(t);
e[i] = (e[i] || 0) | 1 << r - t - 1;
}
return t;
return e;
}
class it {
constructor(t, {
location: s = f.location,
threshold: n = f.threshold,
distance: r = f.distance,
includeMatches: i = f.includeMatches,
findAllMatches: c = f.findAllMatches,
minMatchCharLength: o = f.minMatchCharLength,
isCaseSensitive: a = f.isCaseSensitive,
ignoreLocation: h = f.ignoreLocation
class ne {
constructor(e, {
location: t = d.location,
threshold: r = d.threshold,
distance: i = d.distance,
includeMatches: c = d.includeMatches,
findAllMatches: n = d.findAllMatches,
minMatchCharLength: o = d.minMatchCharLength,
isCaseSensitive: l = d.isCaseSensitive,
ignoreLocation: a = d.ignoreLocation
} = {}) {
if (this.options = {
location: s,
threshold: n,
distance: r,
includeMatches: i,
findAllMatches: c,
location: t,
threshold: r,
distance: i,
includeMatches: c,
findAllMatches: n,
minMatchCharLength: o,
isCaseSensitive: a,
ignoreLocation: h
}, this.pattern = a ? t : t.toLowerCase(), this.chunks = [], !this.pattern.length)
isCaseSensitive: l,
ignoreLocation: a
}, this.pattern = l ? e : e.toLowerCase(), this.chunks = [], !this.pattern.length)
return;
const l = (d, g) => {
const h = (f, g) => {
this.chunks.push({
pattern: d,
alphabet: Ct(d),
pattern: f,
alphabet: Ne(f),
startIndex: g
});
}, u = this.pattern.length;
if (u > k) {
let d = 0;
const g = u % k, p = u - g;
for (; d < p; )
l(this.pattern.substr(d, k), d), d += k;
if (u > v) {
let f = 0;
const g = u % v, p = u - g;
for (; f < p; )
h(this.pattern.substr(f, v), f), f += v;
if (g) {
const y = u - k;
l(this.pattern.substr(y), y);
const m = u - v;
h(this.pattern.substr(m), m);
}
} else
l(this.pattern, 0);
h(this.pattern, 0);
}
searchIn(t) {
const { isCaseSensitive: s, includeMatches: n } = this.options;
if (s || (t = t.toLowerCase()), this.pattern === t) {
searchIn(e) {
const { isCaseSensitive: t, includeMatches: r } = this.options;
if (t || (e = e.toLowerCase()), this.pattern === e) {
let p = {

@@ -449,41 +449,41 @@ isMatch: !0,

};
return n && (p.indices = [[0, t.length - 1]]), p;
return r && (p.indices = [[0, e.length - 1]]), p;
}
const {
location: r,
distance: i,
threshold: c,
location: i,
distance: c,
threshold: n,
findAllMatches: o,
minMatchCharLength: a,
ignoreLocation: h
minMatchCharLength: l,
ignoreLocation: a
} = this.options;
let l = [], u = 0, d = !1;
this.chunks.forEach(({ pattern: p, alphabet: y, startIndex: R }) => {
const { isMatch: I, score: T, indices: b } = Ot(t, p, y, {
location: r + R,
distance: i,
threshold: c,
let h = [], u = 0, f = !1;
this.chunks.forEach(({ pattern: p, alphabet: m, startIndex: E }) => {
const { isMatch: S, score: T, indices: R } = $e(e, p, m, {
location: i + E,
distance: c,
threshold: n,
findAllMatches: o,
minMatchCharLength: a,
includeMatches: n,
ignoreLocation: h
minMatchCharLength: l,
includeMatches: r,
ignoreLocation: a
});
I && (d = !0), u += T, I && b && (l = [...l, ...b]);
S && (f = !0), u += T, S && R && (h = [...h, ...R]);
});
let g = {
isMatch: d,
score: d ? u / this.chunks.length : 1
isMatch: f,
score: f ? u / this.chunks.length : 1
};
return d && n && (g.indices = l), g;
return f && r && (g.indices = h), g;
}
}
class L {
constructor(t) {
this.pattern = t;
class _ {
constructor(e) {
this.pattern = e;
}
static isMultiMatch(t) {
return J(t, this.multiRegex);
static isMultiMatch(e) {
return X(e, this.multiRegex);
}
static isSingleMatch(t) {
return J(t, this.singleRegex);
static isSingleMatch(e) {
return X(e, this.singleRegex);
}

@@ -493,9 +493,9 @@ search() {

}
function J(e, t) {
const s = e.match(t);
return s ? s[1] : null;
function X(s, e) {
const t = s.match(e);
return t ? t[1] : null;
}
class vt extends L {
constructor(t) {
super(t);
class Oe extends _ {
constructor(e) {
super(e);
}

@@ -511,7 +511,7 @@ static get type() {

}
search(t) {
const s = t === this.pattern;
search(e) {
const t = e === this.pattern;
return {
isMatch: s,
score: s ? 0 : 1,
isMatch: t,
score: t ? 0 : 1,
indices: [0, this.pattern.length - 1]

@@ -521,5 +521,5 @@ };

}
class Ft extends L {
constructor(t) {
super(t);
class Ce extends _ {
constructor(e) {
super(e);
}

@@ -535,14 +535,14 @@ static get type() {

}
search(t) {
const n = t.indexOf(this.pattern) === -1;
search(e) {
const r = e.indexOf(this.pattern) === -1;
return {
isMatch: n,
score: n ? 0 : 1,
indices: [0, t.length - 1]
isMatch: r,
score: r ? 0 : 1,
indices: [0, e.length - 1]
};
}
}
class Pt extends L {
constructor(t) {
super(t);
class Fe extends _ {
constructor(e) {
super(e);
}

@@ -558,7 +558,7 @@ static get type() {

}
search(t) {
const s = t.startsWith(this.pattern);
search(e) {
const t = e.startsWith(this.pattern);
return {
isMatch: s,
score: s ? 0 : 1,
isMatch: t,
score: t ? 0 : 1,
indices: [0, this.pattern.length - 1]

@@ -568,5 +568,5 @@ };

}
class jt extends L {
constructor(t) {
super(t);
class je extends _ {
constructor(e) {
super(e);
}

@@ -582,14 +582,14 @@ static get type() {

}
search(t) {
const s = !t.startsWith(this.pattern);
search(e) {
const t = !e.startsWith(this.pattern);
return {
isMatch: s,
score: s ? 0 : 1,
indices: [0, t.length - 1]
isMatch: t,
score: t ? 0 : 1,
indices: [0, e.length - 1]
};
}
}
class Ht extends L {
constructor(t) {
super(t);
class He extends _ {
constructor(e) {
super(e);
}

@@ -605,14 +605,14 @@ static get type() {

}
search(t) {
const s = t.endsWith(this.pattern);
search(e) {
const t = e.endsWith(this.pattern);
return {
isMatch: s,
score: s ? 0 : 1,
indices: [t.length - this.pattern.length, t.length - 1]
isMatch: t,
score: t ? 0 : 1,
indices: [e.length - this.pattern.length, e.length - 1]
};
}
}
class Kt extends L {
constructor(t) {
super(t);
class Pe extends _ {
constructor(e) {
super(e);
}

@@ -628,31 +628,31 @@ static get type() {

}
search(t) {
const s = !t.endsWith(this.pattern);
search(e) {
const t = !e.endsWith(this.pattern);
return {
isMatch: s,
score: s ? 0 : 1,
indices: [0, t.length - 1]
isMatch: t,
score: t ? 0 : 1,
indices: [0, e.length - 1]
};
}
}
class ct extends L {
constructor(t, {
location: s = f.location,
threshold: n = f.threshold,
distance: r = f.distance,
includeMatches: i = f.includeMatches,
findAllMatches: c = f.findAllMatches,
minMatchCharLength: o = f.minMatchCharLength,
isCaseSensitive: a = f.isCaseSensitive,
ignoreLocation: h = f.ignoreLocation
class ce extends _ {
constructor(e, {
location: t = d.location,
threshold: r = d.threshold,
distance: i = d.distance,
includeMatches: c = d.includeMatches,
findAllMatches: n = d.findAllMatches,
minMatchCharLength: o = d.minMatchCharLength,
isCaseSensitive: l = d.isCaseSensitive,
ignoreLocation: a = d.ignoreLocation
} = {}) {
super(t), this._bitapSearch = new it(t, {
location: s,
threshold: n,
distance: r,
includeMatches: i,
findAllMatches: c,
super(e), this._bitapSearch = new ne(e, {
location: t,
threshold: r,
distance: i,
includeMatches: c,
findAllMatches: n,
minMatchCharLength: o,
isCaseSensitive: a,
ignoreLocation: h
isCaseSensitive: l,
ignoreLocation: a
});

@@ -669,9 +669,9 @@ }

}
search(t) {
return this._bitapSearch.searchIn(t);
search(e) {
return this._bitapSearch.searchIn(e);
}
}
class ot extends L {
constructor(t) {
super(t);
class oe extends _ {
constructor(e) {
super(e);
}

@@ -687,42 +687,42 @@ static get type() {

}
search(t) {
let s = 0, n;
const r = [], i = this.pattern.length;
for (; (n = t.indexOf(this.pattern, s)) > -1; )
s = n + i, r.push([n, s - 1]);
const c = !!r.length;
search(e) {
let t = 0, r;
const i = [], c = this.pattern.length;
for (; (r = e.indexOf(this.pattern, t)) > -1; )
t = r + c, i.push([r, t - 1]);
const n = !!i.length;
return {
isMatch: c,
score: c ? 0 : 1,
indices: r
isMatch: n,
score: n ? 0 : 1,
indices: i
};
}
}
const B = [
vt,
ot,
Pt,
jt,
Kt,
Ht,
Ft,
ct
], q = B.length, Bt = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, Dt = "|";
function Wt(e, t = {}) {
return e.split(Dt).map((s) => {
let n = s.trim().split(Bt).filter((i) => i && !!i.trim()), r = [];
for (let i = 0, c = n.length; i < c; i += 1) {
const o = n[i];
let a = !1, h = -1;
for (; !a && ++h < q; ) {
const l = B[h];
let u = l.isMultiMatch(o);
u && (r.push(new l(u, t)), a = !0);
const K = [
Oe,
oe,
Fe,
je,
Pe,
He,
Ce,
ce
], J = K.length, Be = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, Ke = "|";
function We(s, e = {}) {
return s.split(Ke).map((t) => {
let r = t.trim().split(Be).filter((c) => c && !!c.trim()), i = [];
for (let c = 0, n = r.length; c < n; c += 1) {
const o = r[c];
let l = !1, a = -1;
for (; !l && ++a < J; ) {
const h = K[a];
let u = h.isMultiMatch(o);
u && (i.push(new h(u, e)), l = !0);
}
if (!a)
for (h = -1; ++h < q; ) {
const l = B[h];
let u = l.isSingleMatch(o);
if (!l)
for (a = -1; ++a < J; ) {
const h = K[a];
let u = h.isSingleMatch(o);
if (u) {
r.push(new l(u, t));
i.push(new h(u, e));
break;

@@ -732,34 +732,34 @@ }

}
return r;
return i;
});
}
const zt = /* @__PURE__ */ new Set([ct.type, ot.type]);
class Vt {
constructor(t, {
isCaseSensitive: s = f.isCaseSensitive,
includeMatches: n = f.includeMatches,
minMatchCharLength: r = f.minMatchCharLength,
ignoreLocation: i = f.ignoreLocation,
findAllMatches: c = f.findAllMatches,
location: o = f.location,
threshold: a = f.threshold,
distance: h = f.distance
const De = /* @__PURE__ */ new Set([ce.type, oe.type]);
class ze {
constructor(e, {
isCaseSensitive: t = d.isCaseSensitive,
includeMatches: r = d.includeMatches,
minMatchCharLength: i = d.minMatchCharLength,
ignoreLocation: c = d.ignoreLocation,
findAllMatches: n = d.findAllMatches,
location: o = d.location,
threshold: l = d.threshold,
distance: a = d.distance
} = {}) {
this.query = null, this.options = {
isCaseSensitive: s,
includeMatches: n,
minMatchCharLength: r,
findAllMatches: c,
ignoreLocation: i,
isCaseSensitive: t,
includeMatches: r,
minMatchCharLength: i,
findAllMatches: n,
ignoreLocation: c,
location: o,
threshold: a,
distance: h
}, this.pattern = s ? t : t.toLowerCase(), this.query = Wt(this.pattern, this.options);
threshold: l,
distance: a
}, this.pattern = t ? e : e.toLowerCase(), this.query = We(this.pattern, this.options);
}
static condition(t, s) {
return s.useExtendedSearch;
static condition(e, t) {
return t.useExtendedSearch;
}
searchIn(t) {
const s = this.query;
if (!s)
searchIn(e) {
const t = this.query;
if (!t)
return {

@@ -769,26 +769,26 @@ isMatch: !1,

};
const { includeMatches: n, isCaseSensitive: r } = this.options;
t = r ? t : t.toLowerCase();
let i = 0, c = [], o = 0;
for (let a = 0, h = s.length; a < h; a += 1) {
const l = s[a];
c.length = 0, i = 0;
for (let u = 0, d = l.length; u < d; u += 1) {
const g = l[u], { isMatch: p, indices: y, score: R } = g.search(t);
const { includeMatches: r, isCaseSensitive: i } = this.options;
e = i ? e : e.toLowerCase();
let c = 0, n = [], o = 0;
for (let l = 0, a = t.length; l < a; l += 1) {
const h = t[l];
n.length = 0, c = 0;
for (let u = 0, f = h.length; u < f; u += 1) {
const g = h[u], { isMatch: p, indices: m, score: E } = g.search(e);
if (p) {
if (i += 1, o += R, n) {
const I = g.constructor.type;
zt.has(I) ? c = [...c, ...y] : c.push(y);
if (c += 1, o += E, r) {
const S = g.constructor.type;
De.has(S) ? n = [...n, ...m] : n.push(m);
}
} else {
o = 0, i = 0, c.length = 0;
o = 0, c = 0, n.length = 0;
break;
}
}
if (i) {
if (c) {
let u = {
isMatch: !0,
score: o / i
score: o / c
};
return n && (u.indices = c), u;
return r && (u.indices = n), u;
}

@@ -802,13 +802,13 @@ }

}
const D = [];
function Yt(...e) {
D.push(...e);
const W = [];
function qe(...s) {
W.push(...s);
}
function W(e, t) {
for (let s = 0, n = D.length; s < n; s += 1) {
let r = D[s];
if (r.condition(e, t))
return new r(e, t);
function D(s, e) {
for (let t = 0, r = W.length; t < r; t += 1) {
let i = W[t];
if (i.condition(s, e))
return new i(s, e);
}
return new it(e, t);
return new ne(s, e);
}

@@ -821,87 +821,87 @@ const F = {

PATTERN: "$val"
}, V = (e) => !!(e[F.AND] || e[F.OR]), Gt = (e) => !!e[z.PATH], Ut = (e) => !A(e) && et(e) && !V(e), Z = (e) => ({
[F.AND]: Object.keys(e).map((t) => ({
[t]: e[t]
}, q = (s) => !!(s[F.AND] || s[F.OR]), Ve = (s) => !!s[z.PATH], Ue = (s) => !L(s) && te(s) && !q(s), Z = (s) => ({
[F.AND]: Object.keys(s).map((e) => ({
[e]: s[e]
}))
});
function at(e, t, { auto: s = !0 } = {}) {
const n = (r) => {
let i = Object.keys(r);
const c = Gt(r);
if (!c && i.length > 1 && !V(r))
return n(Z(r));
if (Ut(r)) {
const a = c ? r[z.PATH] : i[0], h = c ? r[z.PATTERN] : r[a];
if (!S(h))
throw new Error(Et(a));
const l = {
keyId: K(a),
pattern: h
function le(s, e, { auto: t = !0 } = {}) {
const r = (i) => {
let c = Object.keys(i);
const n = Ve(i);
if (!n && c.length > 1 && !q(i))
return r(Z(i));
if (Ue(i)) {
const l = n ? i[z.PATH] : c[0], a = n ? i[z.PATTERN] : i[l];
if (!w(a))
throw new Error(xe(l));
const h = {
keyId: B(l),
pattern: a
};
return s && (l.searcher = W(h, t)), l;
return t && (h.searcher = D(a, e)), h;
}
let o = {
children: [],
operator: i[0]
operator: c[0]
};
return i.forEach((a) => {
const h = r[a];
A(h) && h.forEach((l) => {
o.children.push(n(l));
return c.forEach((l) => {
const a = i[l];
L(a) && a.forEach((h) => {
o.children.push(r(h));
});
}), o;
};
return V(e) || (e = Z(e)), n(e);
return q(s) || (s = Z(s)), r(s);
}
function Qt(e, { ignoreFieldNorm: t = f.ignoreFieldNorm }) {
e.forEach((s) => {
let n = 1;
s.matches.forEach(({ key: r, norm: i, score: c }) => {
const o = r ? r.weight : null;
n *= Math.pow(
c === 0 && o ? Number.EPSILON : c,
(o || 1) * (t ? 1 : i)
function Ye(s, { ignoreFieldNorm: e = d.ignoreFieldNorm }) {
s.forEach((t) => {
let r = 1;
t.matches.forEach(({ key: i, norm: c, score: n }) => {
const o = i ? i.weight : null;
r *= Math.pow(
n === 0 && o ? Number.EPSILON : n,
(o || 1) * (e ? 1 : c)
);
}), s.score = n;
}), t.score = r;
});
}
function Xt(e, t) {
const s = e.matches;
t.matches = [], m(s) && s.forEach((n) => {
if (!m(n.indices) || !n.indices.length)
function Ge(s, e) {
const t = s.matches;
e.matches = [], y(t) && t.forEach((r) => {
if (!y(r.indices) || !r.indices.length)
return;
const { indices: r, value: i } = n;
let c = {
indices: r,
value: i
const { indices: i, value: c } = r;
let n = {
indices: i,
value: c
};
n.key && (c.key = n.key.src), n.idx > -1 && (c.refIndex = n.idx), t.matches.push(c);
r.key && (n.key = r.key.src), r.idx > -1 && (n.refIndex = r.idx), e.matches.push(n);
});
}
function Jt(e, t) {
t.score = e.score;
function Qe(s, e) {
e.score = s.score;
}
function qt(e, t, {
includeMatches: s = f.includeMatches,
includeScore: n = f.includeScore
function Xe(s, e, {
includeMatches: t = d.includeMatches,
includeScore: r = d.includeScore
} = {}) {
const r = [];
return s && r.push(Xt), n && r.push(Jt), e.map((i) => {
const { idx: c } = i, o = {
item: t[c],
refIndex: c
const i = [];
return t && i.push(Ge), r && i.push(Qe), s.map((c) => {
const { idx: n } = c, o = {
item: e[n],
refIndex: n
};
return r.length && r.forEach((a) => {
a(i, o);
return i.length && i.forEach((l) => {
l(c, o);
}), o;
});
}
class N {
constructor(t, s = {}, n) {
this.options = { ...f, ...s }, this.options.useExtendedSearch, this._keyStore = new At(this.options.keys), this.setCollection(t, n);
class $ {
constructor(e, t = {}, r) {
this.options = { ...d, ...t }, this.options.useExtendedSearch, this._keyStore = new Se(this.options.keys), this.setCollection(e, r);
}
setCollection(t, s) {
if (this._docs = t, s && !(s instanceof Y))
throw new Error(Mt);
this._myIndex = s || nt(this.options.keys, this._docs, {
setCollection(e, t) {
if (this._docs = e, t && !(t instanceof V))
throw new Error(ye);
this._myIndex = t || re(this.options.keys, this._docs, {
getFn: this.options.getFn,

@@ -911,15 +911,15 @@ fieldNormWeight: this.options.fieldNormWeight

}
add(t) {
m(t) && (this._docs.push(t), this._myIndex.add(t));
add(e) {
y(e) && (this._docs.push(e), this._myIndex.add(e));
}
remove(t = () => !1) {
const s = [];
for (let n = 0, r = this._docs.length; n < r; n += 1) {
const i = this._docs[n];
t(i, n) && (this.removeAt(n), n -= 1, r -= 1, s.push(i));
remove(e = () => !1) {
const t = [];
for (let r = 0, i = this._docs.length; r < i; r += 1) {
const c = this._docs[r];
e(c, r) && (this.removeAt(r), r -= 1, i -= 1, t.push(c));
}
return s;
return t;
}
removeAt(t) {
this._docs.splice(t, 1), this._myIndex.removeAt(t);
removeAt(e) {
this._docs.splice(e, 1), this._myIndex.removeAt(e);
}

@@ -929,41 +929,41 @@ getIndex() {

}
search(t, { limit: s = -1 } = {}) {
search(e, { limit: t = -1 } = {}) {
const {
includeMatches: n,
includeScore: r,
shouldSort: i,
sortFn: c,
includeMatches: r,
includeScore: i,
shouldSort: c,
sortFn: n,
ignoreFieldNorm: o
} = this.options;
let a = S(t) ? S(this._docs[0]) ? this._searchStringList(t) : this._searchObjectList(t) : this._searchLogical(t);
return Qt(a, { ignoreFieldNorm: o }), i && a.sort(c), tt(s) && s > -1 && (a = a.slice(0, s)), qt(a, this._docs, {
includeMatches: n,
includeScore: r
let l = w(e) ? w(this._docs[0]) ? this._searchStringList(e) : this._searchObjectList(e) : this._searchLogical(e);
return Ye(l, { ignoreFieldNorm: o }), c && l.sort(n), ee(t) && t > -1 && (l = l.slice(0, t)), Xe(l, this._docs, {
includeMatches: r,
includeScore: i
});
}
_searchStringList(t) {
const s = W(t, this.options), { records: n } = this._myIndex, r = [];
return n.forEach(({ v: i, i: c, n: o }) => {
if (!m(i))
_searchStringList(e) {
const t = D(e, this.options), { records: r } = this._myIndex, i = [];
return r.forEach(({ v: c, i: n, n: o }) => {
if (!y(c))
return;
const { isMatch: a, score: h, indices: l } = s.searchIn(i);
a && r.push({
item: i,
idx: c,
matches: [{ score: h, value: i, norm: o, indices: l }]
const { isMatch: l, score: a, indices: h } = t.searchIn(c);
l && i.push({
item: c,
idx: n,
matches: [{ score: a, value: c, norm: o, indices: h }]
});
}), r;
}), i;
}
_searchLogical(t) {
const s = at(t, this.options), n = (o, a, h) => {
_searchLogical(e) {
const t = le(e, this.options), r = (o, l, a) => {
if (!o.children) {
const { keyId: u, searcher: d } = o, g = this._findMatches({
const { keyId: u, searcher: f } = o, g = this._findMatches({
key: this._keyStore.get(u),
value: this._myIndex.getValueForItemAtKeyId(a, u),
searcher: d
value: this._myIndex.getValueForItemAtKeyId(l, u),
searcher: f
});
return g && g.length ? [
{
idx: h,
item: a,
idx: a,
item: l,
matches: g

@@ -973,86 +973,205 @@ }

}
const l = [];
for (let u = 0, d = o.children.length; u < d; u += 1) {
const g = o.children[u], p = n(g, a, h);
const h = [];
for (let u = 0, f = o.children.length; u < f; u += 1) {
const g = o.children[u], p = r(g, l, a);
if (p.length)
l.push(...p);
h.push(...p);
else if (o.operator === F.AND)
return [];
}
return l;
}, r = this._myIndex.records, i = {}, c = [];
return r.forEach(({ $: o, i: a }) => {
if (m(o)) {
let h = n(s, o, a);
h.length && (i[a] || (i[a] = { idx: a, item: o, matches: [] }, c.push(i[a])), h.forEach(({ matches: l }) => {
i[a].matches.push(...l);
return h;
}, i = this._myIndex.records, c = {}, n = [];
return i.forEach(({ $: o, i: l }) => {
if (y(o)) {
let a = r(t, o, l);
a.length && (c[l] || (c[l] = { idx: l, item: o, matches: [] }, n.push(c[l])), a.forEach(({ matches: h }) => {
c[l].matches.push(...h);
}));
}
}), c;
}), n;
}
_searchObjectList(t) {
const s = W(t, this.options), { keys: n, records: r } = this._myIndex, i = [];
return r.forEach(({ $: c, i: o }) => {
if (!m(c))
_searchObjectList(e) {
const t = D(e, this.options), { keys: r, records: i } = this._myIndex, c = [];
return i.forEach(({ $: n, i: o }) => {
if (!y(n))
return;
let a = [];
n.forEach((h, l) => {
a.push(
let l = [];
r.forEach((a, h) => {
l.push(
...this._findMatches({
key: h,
value: c[l],
searcher: s
key: a,
value: n[h],
searcher: t
})
);
}), a.length && i.push({
}), l.length && c.push({
idx: o,
item: c,
matches: a
item: n,
matches: l
});
}), i;
}), c;
}
_findMatches({ key: t, value: s, searcher: n }) {
if (!m(s))
_findMatches({ key: e, value: t, searcher: r }) {
if (!y(t))
return [];
let r = [];
if (A(s))
s.forEach(({ v: i, i: c, n: o }) => {
if (!m(i))
let i = [];
if (L(t))
t.forEach(({ v: c, i: n, n: o }) => {
if (!y(c))
return;
const { isMatch: a, score: h, indices: l } = n.searchIn(i);
a && r.push({
score: h,
key: t,
value: i,
idx: c,
const { isMatch: l, score: a, indices: h } = r.searchIn(c);
l && i.push({
score: a,
key: e,
value: c,
idx: n,
norm: o,
indices: l
indices: h
});
});
else {
const { v: i, n: c } = s, { isMatch: o, score: a, indices: h } = n.searchIn(i);
o && r.push({ score: a, key: t, value: i, norm: c, indices: h });
const { v: c, n } = t, { isMatch: o, score: l, indices: a } = r.searchIn(c);
o && i.push({ score: l, key: e, value: c, norm: n, indices: a });
}
return r;
return i;
}
}
N.version = "6.6.2";
N.createIndex = nt;
N.parseIndex = $t;
N.config = f;
N.parseQuery = at;
Yt(Vt);
const Zt = `
$.version = "6.6.2";
$.createIndex = re;
$.parseIndex = Te;
$.config = d;
$.parseQuery = le;
qe(ze);
const Je = `
<style>
:host {
display: block;
display: flex;
box-sizing: border-box;
height: 100%;
overflow: hidden;
}
*, *:before, *:after {
box-sizing: inherit;
}
form {
height: 100%;
max-width: 100%;
display: flex;
flex-direction: column;
}
ul {
padding-left: 0;
margin-top: 0;
}
li {
list-style: none;
}
li span {
font-size: small;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
label {
display: flex;
align-items: center;
}
details {
margin-bottom: 0.5rem;
}
details summary > * {
display: inline;
}
details summary {
display: flex;
align-items: center;
}
#details-filter summary {
justify-content: space-between;
}
#details-results summary {
list-style: none;
}
#details-filter summary svg,
#details-results summary svg {
width: 24px;
height: 24px;
transition: all ease-in-out 0.3s;
}
#details-results summary svg {
transform: rotate(-90deg);
}
#details-filter[open] summary svg {
transform: rotate(180deg);
}
#details-results[open] summary svg {
transform: rotate(0deg);
}
li span,
details summary {
text-transform: capitalize;
}
li,
label,
details,
input[type=checkbox],
input[type=radio] {
cursor: pointer;
}
input[type=checkbox],
input[type=radio] {
margin: 0;
margin-right: 0.5rem;
}
input[type=text] {
display: none;
width: 100%;
margin-bottom: 0.5rem;
}
section {
padding-left: 1rem;
padding-right: 1rem;
}
section:first-of-type {
padding-top: 1rem;
}
#section-results {
overflow: hidden;
flex: 1;
display: flex;
flex-direction: column;
}
#container-results {
margin-right: -1rem;
}
ul#results {
padding-right: 1rem;
}
ul#results li {
padding-left: 0.5rem;
}
.scroll {
height: 100%;
overflow-x: hidden;
overflow-y: auto;
}
</style>
<div>
<slot></slot>
<ul id="filters"></ul>
<input type="text" />
<ul id="results"></ul>
</div>
`, te = `
<form>
<section>
<input type="text" placeholder="Search" />
</section>
<section>
<slot name="filterstitle"></slot>
<ul id="filters"></ul>
</section>
<section id="section-results">
<div>
<slot name="resultstitle"></slot>
</div>
<div id="container-results" class="scroll">
<ul id="results"></ul>
</div>
</section>
</form>
`, Ze = `
<li>

@@ -1064,42 +1183,68 @@ <label>

</li>
`, ee = `
<details open>
<summary>TITLE</summar>
`, et = `
<details id="details-filter">
<summary>
<small>
<strong class="title">
FILTERTITLE
</strong>
</small>
<div>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>chevron-down</title><path d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z" /></svg>
</div>
</summary>
<ul></ul>
</details>
`, se = (e, t = "highlight") => {
const s = (r, i, c) => {
const o = i.split(".");
let a;
for (a = 0; a < o.length - 1; a++)
r = r[o[a]];
r[o[a]] = c;
}, n = (r, i = []) => {
let c = "", o = 0;
return i.forEach((a) => {
const h = a[1] + 1;
c += [
r.substring(o, a[0]),
`<mark class="${t}">`,
r.substring(a[0], h),
`, tt = `
<li>
<label>
<input type="radio" name="result" />
<span class="title">RESULTTITLE</span>
</label>
</li>
`, st = `
<details id="details-results" open>
<summary>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>chevron-down</title><path d="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z" /></svg>
<strong class="title">
SUMMARYTITLE
</strong>
<span style="margin-left: 0.25rem">(<span class="count"></span>)</span>
</summary>
<ul></ul>
</details>
`, it = (s, e = "highlight") => {
const t = (i, c, n) => {
const o = c.split(".");
let l;
for (l = 0; l < o.length - 1; l++)
i = i[o[l]];
i[o[l]] = n;
}, r = (i, c = []) => {
let n = "", o = 0;
return c.forEach((l) => {
const a = l[1] + 1;
n += [
i.substring(o, l[0]),
`<mark class="${e}">`,
i.substring(l[0], a),
"</mark>"
].join(""), o = h;
}), c += r.substring(o), c;
].join(""), o = a;
}), n += i.substring(o), n;
};
return e.filter(({ matches: r }) => r && r.length).map(({ item: r, matches: i }) => {
const c = { ...r };
return i.forEach((o) => {
o.key === "name" && s(
c,
return s.filter(({ matches: i }) => i && i.length).map(({ item: i, matches: c }) => {
const n = { ...i };
return c.forEach((o) => {
o.key === "name" && t(
n,
o.key,
n(o.value, o.indices)
r(o.value, o.indices)
);
}), c;
}), n;
});
}, ht = document.createElement("template");
ht.innerHTML = Zt;
class re extends HTMLElement {
};
class rt extends HTMLElement {
constructor() {
super();
x(this, "shadowRoot");
b(this, "shadowRoot");
/**

@@ -1109,23 +1254,13 @@ * Apply JSON items to itemfilter.

*/
x(this, "apply");
/**
* The filter properties.
* @param filterProperties
*/
x(this, "filterProperties");
x(this, "items");
x(this, "fuse");
b(this, "apply");
b(this, "items");
b(this, "fuse");
// TODO proper typing
x(this, "filters");
x(this, "aggregateBy");
/**
* Aggregate results by a property key
*/
x(this, "aggregateResults");
/**
* Native fuse.js config override
*/
x(this, "fuseConfig");
this.filters = {}, this.shadowRoot = this.attachShadow({ mode: "open" }), this.shadowRoot.appendChild(ht.content.cloneNode(!0)), this.apply = (r) => {
this.items = r, this.fuse = new N(this.items, {
b(this, "filters");
b(this, "aggregateBy");
b(this, "config");
this.filters = {}, this.shadowRoot = this.attachShadow({ mode: "open" });
const t = document.createElement("template");
t.innerHTML = Je, this.shadowRoot.appendChild(t.content.cloneNode(!0)), this.apply = (n) => {
this.config.enableSearch && (this.shadowRoot.querySelector("input[type=text").style.display = "block"), this.items = n, this.fuse = new $(this.items, {
minMatchCharLength: 1,

@@ -1135,29 +1270,55 @@ includeMatches: !0,

// @ts-ignore
keys: ["name", ...this.filterProperties],
keys: ["name", ...this.config.filterProperties],
useExtendedSearch: !0,
...this.fuseConfig
}), this.filterProperties.forEach((i) => {
const c = [
...this.config.fuseConfig
}), this.config.filterProperties.forEach((o) => {
const l = [
...new Set(
this.items.reduce((a, h) => a.concat(h[i]), [])
this.items.reduce((f, g) => f.concat(g[o]), [])
)
].sort(), o = this.shadowRoot.querySelector("ul#filters");
c.forEach((a) => {
const h = document.createElement("template");
h.innerHTML = te;
const l = h.content.cloneNode(!0);
l.querySelector("input[type='checkbox']").setAttribute("data-filter-key", i), l.querySelector("input[type='checkbox']").setAttribute("data-filter-value", a), l.querySelector("span.title").innerHTML = a, o.appendChild(l);
}), this.aggregateResults === i && (this.aggregateBy = c);
}), s();
].sort(), a = this.shadowRoot.querySelector("ul#filters"), h = document.createElement("template");
h.innerHTML = et;
const u = h.content.cloneNode(!0);
u.querySelector(".title").innerHTML = o, u.querySelector("details").setAttribute("data-filter", o), a.appendChild(u), l.forEach((f) => {
const g = document.createElement("template");
g.innerHTML = Ze;
const p = g.content.cloneNode(!0), m = p.querySelector("input[type='checkbox']");
m.setAttribute("data-filter-key", o), m.setAttribute("name", "filter"), this.config.exclusiveFilters === !0 && (m.type = "radio"), m.setAttribute("data-filter-value", f), p.querySelector("span.title").innerHTML = f, this.shadowRoot.querySelector(`details[data-filter='${o}']`).appendChild(p);
}), this.config.aggregateResults === o && (this.aggregateBy = l);
}), r(), this.config.matchAllWhenEmpty !== !1 && i(this.items);
};
const s = () => {
this.shadowRoot.querySelectorAll("input[type='checkbox']").forEach((r) => {
r.addEventListener("click", (i) => {
const c = i.target, o = c.getAttribute("data-filter-key"), a = c.getAttribute("data-filter-value");
c.checked ? (this.filters[o] || (this.filters[o] = []), this.filters[o].push(a)) : (this.filters[o].splice(
const r = () => {
const n = this.shadowRoot.querySelectorAll(
`input[type="${this.config.exclusiveFilters === !0 ? "radio" : "checkbox"}"]`
), o = (l) => {
n.forEach((a) => {
var f, g;
const h = a.getAttribute("data-filter-key"), u = a.getAttribute("data-filter-value");
if (a.checked)
this.filters[h] || (this.filters[h] = []), this.filters[h].includes(u) || this.filters[h].push(u);
else {
if (l === a) {
if (!this.filters[h])
return;
this.filters[h].splice(
// @ts-ignore
this.filters[h].indexOf(u),
1
);
} else
this.config.exclusiveFilters === !0 && // @ts-ignore
this.filters[h] && // @ts-ignore
this.filters[h].includes(u) && ((f = this.filters[h]) == null || f.splice(
// @ts-ignore
this.filters[h].indexOf(u),
1
));
((g = this.filters[h]) == null ? void 0 : g.length) === 0 && delete this.filters[h];
}
});
};
n.forEach((l) => {
l.addEventListener("click", (a) => {
o(a.target), this.config.matchAllWhenEmpty !== !1 && Object.keys(this.filters).length === 0 ? i(this.items) : c(
// @ts-ignore
this.filters[o].indexOf(a),
1
), this.filters[o].length === 0 && delete this.filters[o]), n(
// @ts-ignore
this.shadowRoot.querySelector("input[type='text']").value

@@ -1167,71 +1328,82 @@ );

});
}, n = (r, i = this.filters) => {
const c = Object.entries(i).reduce(
(h, [l, u]) => {
const d = (g) => {
const p = {};
p[l] = `=${g}`, h.push(p);
};
return Array.isArray(u) ? u.forEach((g) => d(g)) : d(u), h;
},
[]
), o = se(
this.fuse.search({
...r.length && Object.keys(c).length ? {
$and: [
{ name: r },
{
$or: c
}
]
} : {
$or: [
{ name: r },
{
$or: c
}
]
}
})
), a = this.shadowRoot.querySelector("ul#results");
if (a.innerHTML = "", this.aggregateResults) {
const h = document.createElement("template");
h.innerHTML = ee, this.aggregateBy.forEach((l) => {
}, i = (n) => {
const o = this.shadowRoot.querySelector("ul#results");
if (o.innerHTML = "", this.config.aggregateResults) {
const l = document.createElement("template");
l.innerHTML = st, this.aggregateBy.forEach((a) => {
if (
// @ts-ignore
!o.find(
(d) => Array.isArray(d[this.aggregateResults]) ? d[this.aggregateResults].includes(l) : d[this.aggregateResults] === l
!n.find(
(u) => Array.isArray(u[this.config.aggregateResults]) ? u[this.config.aggregateResults].includes(a) : u[this.config.aggregateResults] === a
)
)
return;
const u = h.content.cloneNode(!0);
u.querySelector("summary").innerHTML = l, u.querySelector("details").setAttribute("data-aggregate", l), a.appendChild(u);
const h = l.content.cloneNode(!0);
h.querySelector("summary .title").innerHTML = a, h.querySelector("details").setAttribute("data-aggregate", a), o.appendChild(h);
});
}
o.forEach((h) => {
n.forEach((l) => {
const a = document.createElement("template");
a.innerHTML = tt;
const h = a.content.cloneNode(!0);
h.querySelector(".title").innerHTML = l.name;
let u;
if (this.aggregateBy) {
const l = h[this.aggregateResults];
if (Array.isArray(l))
l.forEach((u) => {
const d = document.createElement("li");
d.innerHTML = h.name, this.shadowRoot.querySelector(`details[data-aggregate=${u}]`).appendChild(d);
});
else {
const u = document.createElement("li");
u.innerHTML = h.name, this.shadowRoot.querySelector(`details[data-aggregate=${l}]`).appendChild(u);
}
} else {
const l = document.createElement("li");
l.innerHTML = h.name, a.appendChild(l);
const f = l[this.config.aggregateResults];
Array.isArray(f) ? f.forEach((g) => {
u = this.shadowRoot.querySelector(
`details[data-aggregate=${g}]`
);
}) : u = this.shadowRoot.querySelector(
`details[data-aggregate=${f}]`
);
} else
u = o;
h.querySelector("input").addEventListener("click", () => {
this.config.onSelect && this.config.onSelect(l);
}), u.appendChild(h);
}), this.config.aggregateResults && this.shadowRoot.querySelectorAll("#results details").forEach((a) => {
a.querySelector("summary .count").innerHTML = a.querySelectorAll("li").length;
});
}, c = (n, o = this.filters) => {
const l = Object.entries(o).reduce(
(u, [f, g]) => {
const p = (m) => {
const E = {};
E[f] = `=${m}`, u.push(E);
};
return Array.isArray(g) ? g.forEach((m) => p(m)) : p(g), u;
},
[]
), a = this.fuse.search({
...n.length && Object.keys(l).length ? {
$and: [
{ name: n },
{
$or: l
}
]
} : {
$or: [
{ name: n },
{
$or: l
}
]
}
});
}), h = this.config.enableHighlighting ? it(a) : (
// @ts-ignore
a.map((u) => u.item)
);
i(h);
};
this.shadowRoot.querySelector("input[type='text']").addEventListener("input", (r) => {
n(r.target.value);
this.shadowRoot.querySelector("input[type='text']").addEventListener("input", (n) => {
const o = n.target.value;
!o && this.config.matchAllWhenEmpty !== !1 ? i(this.items) : c(o);
});
}
}
customElements.define("eox-itemfilter", re);
customElements.define("eox-itemfilter", rt);
export {
re as EOxItemFilter
rt as EOxItemFilter
};
{
"name": "@eox/itemfilter",
"version": "0.0.2",
"version": "0.1.0",
"type": "module",

@@ -5,0 +5,0 @@ "devDependencies": {

@@ -12,4 +12,13 @@ import { EOxItemFilter } from "../src/main";

const EOxItemFilter = <EOxItemFilter>$el[0];
EOxItemFilter.filterProperties = ["themes", "code"];
EOxItemFilter.aggregateResults = "themes";
EOxItemFilter.config = {
filterProperties: ["themes"],
aggregateResults: "themes",
enableSearch: true,
// enableHighlighting: false,
// onSelect: (item: any) => {
// console.log(item);
// },
// matchAllWhenEmpty: true,
// exclusiveFilters: true,
};
EOxItemFilter.apply(testItems);

@@ -16,0 +25,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc