From 35ba21240abaa6b2092b6b1a4067d94e2cddf002 Mon Sep 17 00:00:00 2001 From: klovaaxel Date: Fri, 2 Feb 2024 20:00:11 +0100 Subject: [PATCH] Bumps version to v0.3.3 --- docs/assets/{index-OOvek-ah.js => index-10UY1yfj.js} | 5 +++-- docs/index.html | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) rename docs/assets/{index-OOvek-ah.js => index-10UY1yfj.js} (81%) diff --git a/docs/assets/index-OOvek-ah.js b/docs/assets/index-10UY1yfj.js similarity index 81% rename from docs/assets/index-OOvek-ah.js rename to docs/assets/index-10UY1yfj.js index a76207d..2f234e8 100644 --- a/docs/assets/index-OOvek-ah.js +++ b/docs/assets/index-10UY1yfj.js @@ -1,4 +1,5 @@ -var lt=Object.defineProperty;var ut=(i,e,t)=>e in i?lt(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var A=(i,e,t)=>(ut(i,typeof e!="symbol"?e+"":e,t),t);(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))t(s);new MutationObserver(s=>{for(const n of s)if(n.type==="childList")for(const r of n.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&t(r)}).observe(document,{childList:!0,subtree:!0});function e(s){const n={};return s.integrity&&(n.integrity=s.integrity),s.referrerPolicy&&(n.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?n.credentials="include":s.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function t(s){if(s.ep)return;s.ep=!0;const n=e(s);fetch(s.href,n)}})();function I(i){return Array.isArray?Array.isArray(i):st(i)==="[object Array]"}const ft=1/0;function dt(i){if(typeof i=="string")return i;let e=i+"";return e=="0"&&1/i==-ft?"-0":e}function pt(i){return i==null?"":dt(i)}function E(i){return typeof i=="string"}function tt(i){return typeof i=="number"}function gt(i){return i===!0||i===!1||_t(i)&&st(i)=="[object Boolean]"}function et(i){return typeof i=="object"}function _t(i){return et(i)&&i!==null}function _(i){return i!=null}function D(i){return!i.trim().length}function st(i){return i==null?i===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(i)}const mt="Incorrect 'index' type",Lt=i=>`Invalid value for key ${i}`,bt=i=>`Pattern length exceeds max of ${i}.`,Et=i=>`Missing ${i} property in key`,yt=i=>`Property 'weight' in key '${i}' must be a positive integer`,X=Object.prototype.hasOwnProperty;class It{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(s=>{let n=it(s);this._keys.push(n),this._keyMap[n.id]=n,t+=n.weight}),this._keys.forEach(s=>{s.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function it(i){let e=null,t=null,s=null,n=1,r=null;if(E(i)||I(i))s=i,e=J(i),t=j(i);else{if(!X.call(i,"name"))throw new Error(Et("name"));const c=i.name;if(s=c,X.call(i,"weight")&&(n=i.weight,n<=0))throw new Error(yt(c));e=J(c),t=j(c),r=i.getFn}return{path:e,id:t,weight:n,src:s,getFn:r}}function J(i){return I(i)?i:i.split(".")}function j(i){return I(i)?i.join("."):i}function Mt(i,e){let t=[],s=!1;const n=(r,c,o)=>{if(_(r))if(!c[o])t.push(r);else{let h=c[o];const a=r[h];if(!_(a))return;if(o===c.length-1&&(E(a)||tt(a)||gt(a)))t.push(pt(a));else if(I(a)){s=!0;for(let l=0,f=a.length;li.score===e.score?i.idx{this._keysMap[t.id]=s})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,E(this.docs[0])?this.docs.forEach((e,t)=>{this._addString(e,t)}):this.docs.forEach((e,t)=>{this._addObject(e,t)}),this.norm.clear())}add(e){const t=this.size();E(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,s=this.size();t{let c=n.getFn?n.getFn(e):this.getFn(e,n.path);if(_(c)){if(I(c)){let o=[];const h=[{nestedArrIndex:-1,value:c}];for(;h.length;){const{nestedArrIndex:a,value:l}=h.pop();if(_(l))if(E(l)&&!D(l)){let f={v:l,i:a,n:this.norm.get(l)};o.push(f)}else I(l)&&l.forEach((f,d)=>{h.push({nestedArrIndex:d,value:f})})}s.$[r]=o}else if(E(c)&&!D(c)){let o={v:c,n:this.norm.get(c)};s.$[r]=o}}}),this.records.push(s)}toJSON(){return{keys:this.keys,records:this.records}}}function nt(i,e,{getFn:t=u.getFn,fieldNormWeight:s=u.fieldNormWeight}={}){const n=new z({getFn:t,fieldNormWeight:s});return n.setKeys(i.map(it)),n.setSources(e),n.create(),n}function Nt(i,{getFn:e=u.getFn,fieldNormWeight:t=u.fieldNormWeight}={}){const{keys:s,records:n}=i,r=new z({getFn:e,fieldNormWeight:t});return r.setKeys(s),r.setIndexRecords(n),r}function $(i,{errors:e=0,currentLocation:t=0,expectedLocation:s=0,distance:n=u.distance,ignoreLocation:r=u.ignoreLocation}={}){const c=e/i.length;if(r)return c;const o=Math.abs(s-t);return n?c+o/n:o?1:c}function Ot(i=[],e=u.minMatchCharLength){let t=[],s=-1,n=-1,r=0;for(let c=i.length;r=e&&t.push([s,n]),s=-1)}return i[r-1]&&r-s>=e&&t.push([s,r-1]),t}const k=32;function Tt(i,e,t,{location:s=u.location,distance:n=u.distance,threshold:r=u.threshold,findAllMatches:c=u.findAllMatches,minMatchCharLength:o=u.minMatchCharLength,includeMatches:h=u.includeMatches,ignoreLocation:a=u.ignoreLocation}={}){if(e.length>k)throw new Error(bt(k));const l=e.length,f=i.length,d=Math.max(0,Math.min(s,f));let p=r,g=d;const m=o>1||h,w=m?Array(f):[];let y;for(;(y=i.indexOf(e,g))>-1;){let L=$(e,{currentLocation:y,expectedLocation:d,distance:n,ignoreLocation:a});if(p=Math.min(L,p),g=y+l,m){let M=0;for(;M=G;b-=1){let C=b-1,Y=t[i.charAt(C)];if(m&&(w[C]=+!!Y),T[b]=(T[b+1]<<1|1)&Y,L&&(T[b]|=(O[b+1]|O[b])<<1|1|O[b+1]),T[b]&at&&(S=$(e,{errors:L,currentLocation:C,expectedLocation:d,distance:n,ignoreLocation:a}),S<=p)){if(p=S,g=C,g<=d)break;G=Math.max(1,2*d-g)}}if($(e,{errors:L+1,currentLocation:d,expectedLocation:d,distance:n,ignoreLocation:a})>p)break;O=T}const F={isMatch:g>=0,score:Math.max(.001,S)};if(m){const L=Ot(w,o);L.length?h&&(F.indices=L):F.isMatch=!1}return F}function Rt(i){let e={};for(let t=0,s=i.length;t{this.chunks.push({pattern:d,alphabet:Rt(d),startIndex:p})},f=this.pattern.length;if(f>k){let d=0;const p=f%k,g=f-p;for(;d{const{isMatch:y,score:O,indices:S}=Tt(e,g,m,{location:n+w,distance:r,threshold:c,findAllMatches:o,minMatchCharLength:h,includeMatches:s,ignoreLocation:a});y&&(d=!0),f+=O,y&&S&&(l=[...l,...S])});let p={isMatch:d,score:d?f/this.chunks.length:1};return d&&s&&(p.indices=l),p}}class v{constructor(e){this.pattern=e}static isMultiMatch(e){return Q(e,this.multiRegex)}static isSingleMatch(e){return Q(e,this.singleRegex)}search(){}}function Q(i,e){const t=i.match(e);return t?t[1]:null}class Ct extends v{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class $t extends v{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const s=e.indexOf(this.pattern)===-1;return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Pt extends v{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class Ft extends v{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}class Kt extends v{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class Dt extends v{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}class ct extends v{constructor(e,{location:t=u.location,threshold:s=u.threshold,distance:n=u.distance,includeMatches:r=u.includeMatches,findAllMatches:c=u.findAllMatches,minMatchCharLength:o=u.minMatchCharLength,isCaseSensitive:h=u.isCaseSensitive,ignoreLocation:a=u.ignoreLocation}={}){super(e),this._bitapSearch=new rt(e,{location:t,threshold:s,distance:n,includeMatches:r,findAllMatches:c,minMatchCharLength:o,isCaseSensitive:h,ignoreLocation:a})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ot extends v{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t=0,s;const n=[],r=this.pattern.length;for(;(s=e.indexOf(this.pattern,t))>-1;)t=s+r,n.push([s,t-1]);const c=!!n.length;return{isMatch:c,score:c?0:1,indices:n}}}const B=[Ct,ot,Pt,Ft,Dt,Kt,$t,ct],Z=B.length,jt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Bt="|";function Ut(i,e={}){return i.split(Bt).map(t=>{let s=t.trim().split(jt).filter(r=>r&&!!r.trim()),n=[];for(let r=0,c=s.length;r!!(i[P.AND]||i[P.OR]),zt=i=>!!i[W.PATH],Gt=i=>!I(i)&&et(i)&&!V(i),q=i=>({[P.AND]:Object.keys(i).map(e=>({[e]:i[e]}))});function ht(i,e,{auto:t=!0}={}){const s=n=>{let r=Object.keys(n);const c=zt(n);if(!c&&r.length>1&&!V(n))return s(q(n));if(Gt(n)){const h=c?n[W.PATH]:r[0],a=c?n[W.PATTERN]:n[h];if(!E(a))throw new Error(Lt(h));const l={keyId:j(h),pattern:a};return t&&(l.searcher=H(a,e)),l}let o={children:[],operator:r[0]};return r.forEach(h=>{const a=n[h];I(a)&&a.forEach(l=>{o.children.push(s(l))})}),o};return V(i)||(i=q(i)),s(i)}function Yt(i,{ignoreFieldNorm:e=u.ignoreFieldNorm}){i.forEach(t=>{let s=1;t.matches.forEach(({key:n,norm:r,score:c})=>{const o=n?n.weight:null;s*=Math.pow(c===0&&o?Number.EPSILON:c,(o||1)*(e?1:r))}),t.score=s})}function Xt(i,e){const t=i.matches;e.matches=[],_(t)&&t.forEach(s=>{if(!_(s.indices)||!s.indices.length)return;const{indices:n,value:r}=s;let c={indices:n,value:r};s.key&&(c.key=s.key.src),s.idx>-1&&(c.refIndex=s.idx),e.matches.push(c)})}function Jt(i,e){e.score=i.score}function Qt(i,e,{includeMatches:t=u.includeMatches,includeScore:s=u.includeScore}={}){const n=[];return t&&n.push(Xt),s&&n.push(Jt),i.map(r=>{const{idx:c}=r,o={item:e[c],refIndex:c};return n.length&&n.forEach(h=>{h(r,o)}),o})}class N{constructor(e,t={},s){this.options={...u,...t},this.options.useExtendedSearch,this._keyStore=new It(this.options.keys),this.setCollection(e,s)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof z))throw new Error(mt);this._myIndex=t||nt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){_(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const t=[];for(let s=0,n=this._docs.length;s-1&&(h=h.slice(0,t)),Qt(h,this._docs,{includeMatches:s,includeScore:n})}_searchStringList(e){const t=H(e,this.options),{records:s}=this._myIndex,n=[];return s.forEach(({v:r,i:c,n:o})=>{if(!_(r))return;const{isMatch:h,score:a,indices:l}=t.searchIn(r);h&&n.push({item:r,idx:c,matches:[{score:a,value:r,norm:o,indices:l}]})}),n}_searchLogical(e){const t=ht(e,this.options),s=(o,h,a)=>{if(!o.children){const{keyId:f,searcher:d}=o,p=this._findMatches({key:this._keyStore.get(f),value:this._myIndex.getValueForItemAtKeyId(h,f),searcher:d});return p&&p.length?[{idx:a,item:h,matches:p}]:[]}const l=[];for(let f=0,d=o.children.length;f{if(_(o)){let a=s(t,o,h);a.length&&(r[h]||(r[h]={idx:h,item:o,matches:[]},c.push(r[h])),a.forEach(({matches:l})=>{r[h].matches.push(...l)}))}}),c}_searchObjectList(e){const t=H(e,this.options),{keys:s,records:n}=this._myIndex,r=[];return n.forEach(({$:c,i:o})=>{if(!_(c))return;let h=[];s.forEach((a,l)=>{h.push(...this._findMatches({key:a,value:c[l],searcher:t}))}),h.length&&r.push({idx:o,item:c,matches:h})}),r}_findMatches({key:e,value:t,searcher:s}){if(!_(t))return[];let n=[];if(I(t))t.forEach(({v:r,i:c,n:o})=>{if(!_(r))return;const{isMatch:h,score:a,indices:l}=s.searchIn(r);h&&n.push({score:a,key:e,value:r,idx:c,norm:o,indices:l})});else{const{v:r,n:c}=t,{isMatch:o,score:h,indices:a}=s.searchIn(r);o&&n.push({score:h,key:e,value:r,norm:c,indices:a})}return n}}N.version="7.0.0";N.createIndex=nt;N.parseIndex=Nt;N.config=u;N.parseQuery=ht;Vt(Wt);class Zt extends HTMLElement{constructor(){super();A(this,"_input",null);A(this,"_list",null);A(this,"_originalList",null);A(this,"_isAltModifierPressed",!1);A(this,"_forceValue",!1);A(this,"_fuse",null);A(this,"_fuseOptions",{includeScore:!0,keys:["dataset.display","dataset.value","innerText"]})}static get observedAttributes(){return["data-value","data-fuse-options","data-listbox"]}attributeChangedCallback(t,s,n){if(s!==n)switch(t){case"data-value":this.selectItemByValue(n,!1);break;case"data-fuse-options":this._originalList||this.fetchOriginalList(),this._fuseOptions=JSON.parse(n),this._fuse=new N(Array.from(this._originalList.cloneNode(!0).children),this._fuseOptions),this.searchList();break;case"data-listbox":this._forceValue=!!n}}connectedCallback(){const t=this.attachShadow({mode:"open"});t.innerHTML=` +var lt=Object.defineProperty;var ut=(i,e,t)=>e in i?lt(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var A=(i,e,t)=>(ut(i,typeof e!="symbol"?e+"":e,t),t);(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))t(s);new MutationObserver(s=>{for(const n of s)if(n.type==="childList")for(const r of n.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&t(r)}).observe(document,{childList:!0,subtree:!0});function e(s){const n={};return s.integrity&&(n.integrity=s.integrity),s.referrerPolicy&&(n.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?n.credentials="include":s.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function t(s){if(s.ep)return;s.ep=!0;const n=e(s);fetch(s.href,n)}})();function I(i){return Array.isArray?Array.isArray(i):st(i)==="[object Array]"}const ft=1/0;function dt(i){if(typeof i=="string")return i;let e=i+"";return e=="0"&&1/i==-ft?"-0":e}function pt(i){return i==null?"":dt(i)}function E(i){return typeof i=="string"}function tt(i){return typeof i=="number"}function gt(i){return i===!0||i===!1||_t(i)&&st(i)=="[object Boolean]"}function et(i){return typeof i=="object"}function _t(i){return et(i)&&i!==null}function _(i){return i!=null}function D(i){return!i.trim().length}function st(i){return i==null?i===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(i)}const mt="Incorrect 'index' type",Lt=i=>`Invalid value for key ${i}`,bt=i=>`Pattern length exceeds max of ${i}.`,Et=i=>`Missing ${i} property in key`,yt=i=>`Property 'weight' in key '${i}' must be a positive integer`,X=Object.prototype.hasOwnProperty;class It{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(s=>{let n=it(s);this._keys.push(n),this._keyMap[n.id]=n,t+=n.weight}),this._keys.forEach(s=>{s.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function it(i){let e=null,t=null,s=null,n=1,r=null;if(E(i)||I(i))s=i,e=J(i),t=j(i);else{if(!X.call(i,"name"))throw new Error(Et("name"));const c=i.name;if(s=c,X.call(i,"weight")&&(n=i.weight,n<=0))throw new Error(yt(c));e=J(c),t=j(c),r=i.getFn}return{path:e,id:t,weight:n,src:s,getFn:r}}function J(i){return I(i)?i:i.split(".")}function j(i){return I(i)?i.join("."):i}function Mt(i,e){let t=[],s=!1;const n=(r,c,o)=>{if(_(r))if(!c[o])t.push(r);else{let h=c[o];const a=r[h];if(!_(a))return;if(o===c.length-1&&(E(a)||tt(a)||gt(a)))t.push(pt(a));else if(I(a)){s=!0;for(let l=0,f=a.length;li.score===e.score?i.idx{this._keysMap[t.id]=s})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,E(this.docs[0])?this.docs.forEach((e,t)=>{this._addString(e,t)}):this.docs.forEach((e,t)=>{this._addObject(e,t)}),this.norm.clear())}add(e){const t=this.size();E(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,s=this.size();t{let c=n.getFn?n.getFn(e):this.getFn(e,n.path);if(_(c)){if(I(c)){let o=[];const h=[{nestedArrIndex:-1,value:c}];for(;h.length;){const{nestedArrIndex:a,value:l}=h.pop();if(_(l))if(E(l)&&!D(l)){let f={v:l,i:a,n:this.norm.get(l)};o.push(f)}else I(l)&&l.forEach((f,d)=>{h.push({nestedArrIndex:d,value:f})})}s.$[r]=o}else if(E(c)&&!D(c)){let o={v:c,n:this.norm.get(c)};s.$[r]=o}}}),this.records.push(s)}toJSON(){return{keys:this.keys,records:this.records}}}function nt(i,e,{getFn:t=u.getFn,fieldNormWeight:s=u.fieldNormWeight}={}){const n=new z({getFn:t,fieldNormWeight:s});return n.setKeys(i.map(it)),n.setSources(e),n.create(),n}function Nt(i,{getFn:e=u.getFn,fieldNormWeight:t=u.fieldNormWeight}={}){const{keys:s,records:n}=i,r=new z({getFn:e,fieldNormWeight:t});return r.setKeys(s),r.setIndexRecords(n),r}function $(i,{errors:e=0,currentLocation:t=0,expectedLocation:s=0,distance:n=u.distance,ignoreLocation:r=u.ignoreLocation}={}){const c=e/i.length;if(r)return c;const o=Math.abs(s-t);return n?c+o/n:o?1:c}function Ot(i=[],e=u.minMatchCharLength){let t=[],s=-1,n=-1,r=0;for(let c=i.length;r=e&&t.push([s,n]),s=-1)}return i[r-1]&&r-s>=e&&t.push([s,r-1]),t}const k=32;function Tt(i,e,t,{location:s=u.location,distance:n=u.distance,threshold:r=u.threshold,findAllMatches:c=u.findAllMatches,minMatchCharLength:o=u.minMatchCharLength,includeMatches:h=u.includeMatches,ignoreLocation:a=u.ignoreLocation}={}){if(e.length>k)throw new Error(bt(k));const l=e.length,f=i.length,d=Math.max(0,Math.min(s,f));let p=r,g=d;const m=o>1||h,w=m?Array(f):[];let y;for(;(y=i.indexOf(e,g))>-1;){let L=$(e,{currentLocation:y,expectedLocation:d,distance:n,ignoreLocation:a});if(p=Math.min(L,p),g=y+l,m){let M=0;for(;M=G;b-=1){let R=b-1,Y=t[i.charAt(R)];if(m&&(w[R]=+!!Y),T[b]=(T[b+1]<<1|1)&Y,L&&(T[b]|=(O[b+1]|O[b])<<1|1|O[b+1]),T[b]&at&&(S=$(e,{errors:L,currentLocation:R,expectedLocation:d,distance:n,ignoreLocation:a}),S<=p)){if(p=S,g=R,g<=d)break;G=Math.max(1,2*d-g)}}if($(e,{errors:L+1,currentLocation:d,expectedLocation:d,distance:n,ignoreLocation:a})>p)break;O=T}const F={isMatch:g>=0,score:Math.max(.001,S)};if(m){const L=Ot(w,o);L.length?h&&(F.indices=L):F.isMatch=!1}return F}function Ct(i){let e={};for(let t=0,s=i.length;t{this.chunks.push({pattern:d,alphabet:Ct(d),startIndex:p})},f=this.pattern.length;if(f>k){let d=0;const p=f%k,g=f-p;for(;d{const{isMatch:y,score:O,indices:S}=Tt(e,g,m,{location:n+w,distance:r,threshold:c,findAllMatches:o,minMatchCharLength:h,includeMatches:s,ignoreLocation:a});y&&(d=!0),f+=O,y&&S&&(l=[...l,...S])});let p={isMatch:d,score:d?f/this.chunks.length:1};return d&&s&&(p.indices=l),p}}class v{constructor(e){this.pattern=e}static isMultiMatch(e){return Q(e,this.multiRegex)}static isSingleMatch(e){return Q(e,this.singleRegex)}search(){}}function Q(i,e){const t=i.match(e);return t?t[1]:null}class Rt extends v{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class $t extends v{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const s=e.indexOf(this.pattern)===-1;return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Pt extends v{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class Ft extends v{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}class Kt extends v{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class Dt extends v{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}class ct extends v{constructor(e,{location:t=u.location,threshold:s=u.threshold,distance:n=u.distance,includeMatches:r=u.includeMatches,findAllMatches:c=u.findAllMatches,minMatchCharLength:o=u.minMatchCharLength,isCaseSensitive:h=u.isCaseSensitive,ignoreLocation:a=u.ignoreLocation}={}){super(e),this._bitapSearch=new rt(e,{location:t,threshold:s,distance:n,includeMatches:r,findAllMatches:c,minMatchCharLength:o,isCaseSensitive:h,ignoreLocation:a})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ot extends v{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t=0,s;const n=[],r=this.pattern.length;for(;(s=e.indexOf(this.pattern,t))>-1;)t=s+r,n.push([s,t-1]);const c=!!n.length;return{isMatch:c,score:c?0:1,indices:n}}}const B=[Rt,ot,Pt,Ft,Dt,Kt,$t,ct],Z=B.length,jt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Bt="|";function Ut(i,e={}){return i.split(Bt).map(t=>{let s=t.trim().split(jt).filter(r=>r&&!!r.trim()),n=[];for(let r=0,c=s.length;r!!(i[P.AND]||i[P.OR]),zt=i=>!!i[W.PATH],Gt=i=>!I(i)&&et(i)&&!V(i),q=i=>({[P.AND]:Object.keys(i).map(e=>({[e]:i[e]}))});function ht(i,e,{auto:t=!0}={}){const s=n=>{let r=Object.keys(n);const c=zt(n);if(!c&&r.length>1&&!V(n))return s(q(n));if(Gt(n)){const h=c?n[W.PATH]:r[0],a=c?n[W.PATTERN]:n[h];if(!E(a))throw new Error(Lt(h));const l={keyId:j(h),pattern:a};return t&&(l.searcher=H(a,e)),l}let o={children:[],operator:r[0]};return r.forEach(h=>{const a=n[h];I(a)&&a.forEach(l=>{o.children.push(s(l))})}),o};return V(i)||(i=q(i)),s(i)}function Yt(i,{ignoreFieldNorm:e=u.ignoreFieldNorm}){i.forEach(t=>{let s=1;t.matches.forEach(({key:n,norm:r,score:c})=>{const o=n?n.weight:null;s*=Math.pow(c===0&&o?Number.EPSILON:c,(o||1)*(e?1:r))}),t.score=s})}function Xt(i,e){const t=i.matches;e.matches=[],_(t)&&t.forEach(s=>{if(!_(s.indices)||!s.indices.length)return;const{indices:n,value:r}=s;let c={indices:n,value:r};s.key&&(c.key=s.key.src),s.idx>-1&&(c.refIndex=s.idx),e.matches.push(c)})}function Jt(i,e){e.score=i.score}function Qt(i,e,{includeMatches:t=u.includeMatches,includeScore:s=u.includeScore}={}){const n=[];return t&&n.push(Xt),s&&n.push(Jt),i.map(r=>{const{idx:c}=r,o={item:e[c],refIndex:c};return n.length&&n.forEach(h=>{h(r,o)}),o})}class N{constructor(e,t={},s){this.options={...u,...t},this.options.useExtendedSearch,this._keyStore=new It(this.options.keys),this.setCollection(e,s)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof z))throw new Error(mt);this._myIndex=t||nt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){_(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const t=[];for(let s=0,n=this._docs.length;s-1&&(h=h.slice(0,t)),Qt(h,this._docs,{includeMatches:s,includeScore:n})}_searchStringList(e){const t=H(e,this.options),{records:s}=this._myIndex,n=[];return s.forEach(({v:r,i:c,n:o})=>{if(!_(r))return;const{isMatch:h,score:a,indices:l}=t.searchIn(r);h&&n.push({item:r,idx:c,matches:[{score:a,value:r,norm:o,indices:l}]})}),n}_searchLogical(e){const t=ht(e,this.options),s=(o,h,a)=>{if(!o.children){const{keyId:f,searcher:d}=o,p=this._findMatches({key:this._keyStore.get(f),value:this._myIndex.getValueForItemAtKeyId(h,f),searcher:d});return p&&p.length?[{idx:a,item:h,matches:p}]:[]}const l=[];for(let f=0,d=o.children.length;f{if(_(o)){let a=s(t,o,h);a.length&&(r[h]||(r[h]={idx:h,item:o,matches:[]},c.push(r[h])),a.forEach(({matches:l})=>{r[h].matches.push(...l)}))}}),c}_searchObjectList(e){const t=H(e,this.options),{keys:s,records:n}=this._myIndex,r=[];return n.forEach(({$:c,i:o})=>{if(!_(c))return;let h=[];s.forEach((a,l)=>{h.push(...this._findMatches({key:a,value:c[l],searcher:t}))}),h.length&&r.push({idx:o,item:c,matches:h})}),r}_findMatches({key:e,value:t,searcher:s}){if(!_(t))return[];let n=[];if(I(t))t.forEach(({v:r,i:c,n:o})=>{if(!_(r))return;const{isMatch:h,score:a,indices:l}=s.searchIn(r);h&&n.push({score:a,key:e,value:r,idx:c,norm:o,indices:l})});else{const{v:r,n:c}=t,{isMatch:o,score:h,indices:a}=s.searchIn(r);o&&n.push({score:h,key:e,value:r,norm:c,indices:a})}return n}}N.version="7.0.0";N.createIndex=nt;N.parseIndex=Nt;N.config=u;N.parseQuery=ht;Vt(Wt);class Zt extends HTMLElement{constructor(){super();A(this,"_input",null);A(this,"_list",null);A(this,"_originalList",null);A(this,"_isAltModifierPressed",!1);A(this,"_forceValue",!1);A(this,"_fuse",null);A(this,"_fuseOptions",{includeScore:!0,keys:["dataset.display","dataset.value","innerText"]})}static get observedAttributes(){return["data-value","data-fuse-options","data-listbox"]}attributeChangedCallback(t,s,n){if(s!==n)switch(t){case"data-value":this.selectItemByValue(n,!1);break;case"data-fuse-options":this._originalList||this.fetchOriginalList(),this._fuseOptions=JSON.parse(n),this._fuse=new N(Array.from(this._originalList.cloneNode(!0).children),this._fuseOptions),this.searchList();break;case"data-listbox":this._forceValue=!!n}}connectedCallback(){const t=this.attachShadow({mode:"open"});t.innerHTML=` - `,this.fetchInput(),this.fetchList(),this.setBasicAttribbutes(),this.fetchOriginalList(),this._fuse=new N(Array.from(this._originalList.cloneNode(!0).children),this._fuseOptions),this.searchList(),this.addEventListeners(),this.forceValue()}disconnectedCallback(){this.removeEventListener("focusout",this.handleBlur.bind(this)),this._input||this.fetchList(),this._input.removeEventListener("input",this.searchList.bind(this,!0)),this._input.removeEventListener("focus",this.toggleList.bind(this,!0)),this._input.removeEventListener("keydown",this.handleComboBoxKeyPress.bind(this)),this._input.removeEventListener("keyup",this.handleKeyUp.bind(this)),this.removeEventListenersFromListItems()}fetchList(){if(this._list=this.querySelector('[slot="list"] [data-list]'),this._list||(this._list=this.querySelector('[slot="list"]')),!this._list)throw new Error("List element not found")}fetchInput(){if(this._input=this.querySelector('[slot="input"]'),!this._input)throw new Error("Input element not found")}fetchOriginalList(){this._list||this.fetchList(),this._originalList=this._list.cloneNode(!0)}removeEventListenersFromListItems(){this._list||this.fetchList();const t=this._list.children;for(let s=0;sr.item);this._list.innerHTML="",this._list.append(...s.map(r=>r.cloneNode(!0)));const n=r=>{if(r.nodeType===Node.TEXT_NODE){const c=r.textContent??"",o=document.createElement("template");o.innerHTML=this.highlightText(c,this._input.value),r.replaceWith(o.content)}else for(const c of r.childNodes)n(c)};for(const r of this._list.children)n(r);this.addEventListenersToListItems(),this.toggleList(t)}highlightText(t,s){const n=new RegExp(`[${s}]+`,"gmi");return t.replace(n,"$&")}toggleList(t=this._input.getAttribute("aria-expanded")==="true"){this._input.setAttribute("aria-expanded",`${t}`),t||this.unfocusAllItems()}focusItem(t){t&&(t.focus(),this._list.querySelectorAll("[aria-selected]").forEach(s=>s.removeAttribute("aria-selected")),t.setAttribute("aria-selected","true"))}unfocusAllItems(){this._list.querySelectorAll("[aria-selected]").forEach(t=>t.removeAttribute("aria-selected"))}selectItem(t,s=!0){this._input||this.fetchInput(),t.dataset.display?this._input.value=t.dataset.display:t.children.length||Array.from(t.children).every(n=>n.nodeName=="STRONG")?this._input.value=t.innerText:t.dataset.value?this._input.value=t.dataset.value:this._input.value="",t.dataset.value&&(this.dataset.value=t.dataset.value),this.sendChangeEvent(),s&&this._input.focus(),this.toggleList(!1),this.searchList(!1)}sendChangeEvent(){const t=new Event("change");this.dispatchEvent(t)}selectItemByValue(t,s=!0){if(!t)return;this._list||this.fetchList();const n=this._list.querySelector(`[data-value="${t}"]`);n&&this.selectItem(n,s)}clearInput(t=!0){this._input||this.fetchInput(),this._input.value="",t&&this._input.focus(),this.toggleList(!1)}handleBlur(){setTimeout(()=>{this.querySelector(":focus")||(this.forceValue(),this.toggleList(!1))},0)}forceValue(){var t;if(this._input||this.fetchInput(),this._list||this.fetchList(),this._forceValue&&((t=this._input)!=null&&t.value)){const s=this._list.children[0];s?this.selectItem(s,!1):(this.clearInput(!1),this.dataset.value="",this.sendChangeEvent())}}handleComboBoxKeyPress(t){switch(this._input||this.fetchInput(),this._list||this.fetchList(),t.key){case"ArrowDown":this._input.getAttribute("aria-expanded")!=="true"?(this.toggleList(!0),this._isAltModifierPressed||this.focusItem(this._list.children[0])):this.focusItem(this._list.children[0]),t.preventDefault();break;case"UpArrow":this._input.getAttribute("aria-expanded")!=="true"&&(this.toggleList(!0),this.focusItem(this._list.children[this._list.children.length-1])),t.preventDefault();break;case"Escape":this._input.getAttribute("aria-expanded")==="true"?this.toggleList(!1):this._input.value="",this._input.focus();break;case"Enter":this._input.getAttribute("aria-expanded")==="true"&&this.selectItem(this._list.children[0]);break;case"Alt":this._isAltModifierPressed=!0;break}}handleListKeyPress(t){this._input||this.fetchInput(),this._list||this.fetchList();const s=t.target;switch(t.key){case"Enter":this.selectItem(s);break;case"Escape":this.clearInput();break;case"ArrowDown":const n=s.nextElementSibling;n?this.focusItem(n):this.focusItem(this._list.children[0]),t.preventDefault();break;case"ArrowUp":if(this._isAltModifierPressed){this._input.focus(),this.toggleList(!1),t.preventDefault();break}const r=s.previousElementSibling;r?this.focusItem(r):this.focusItem(this._list.children[this._list.children.length-1]),t.preventDefault();break;case"ArrowRight":this._input.focus();break;case"ArrowLeft":this._input.focus();break;case"Home":this._input.focus();break;case"End":this._input.focus();break;case"Backspace":this._input.focus();break;case"Delete":this._input.focus();break;case"Alt":this._isAltModifierPressed=!0;break;default:this._input.focus();break}}handleKeyUp(t){switch(t.key){case"Alt":this._isAltModifierPressed=!1;break}}}customElements.define("combobox-framework",Zt); + `,this.fetchInput(),this.fetchList(),this.setBasicAttribbutes(),this.fetchOriginalList(),this._fuse=new N(Array.from(this._originalList.cloneNode(!0).children),this._fuseOptions),this.searchList(),this.addEventListeners(),this.forceValue()}disconnectedCallback(){this.removeEventListener("focusout",this.handleBlur.bind(this)),this._input||this.fetchList(),this._input.removeEventListener("input",this.searchList.bind(this,!0)),this._input.removeEventListener("focus",this.toggleList.bind(this,!0)),this._input.removeEventListener("keydown",this.handleComboBoxKeyPress.bind(this)),this._input.removeEventListener("keyup",this.handleKeyUp.bind(this)),this.removeEventListenersFromListItems()}fetchList(){if(this._list=this.querySelector('[slot="list"] [data-list]'),this._list||(this._list=this.querySelector('[slot="list"]')),!this._list)throw new Error("List element not found")}fetchInput(){if(this._input=this.querySelector('[slot="input"]'),!this._input)throw new Error("Input element not found")}fetchOriginalList(){this._list||this.fetchList(),this._originalList=this._list.cloneNode(!0)}removeEventListenersFromListItems(){this._list||this.fetchList();const t=this._list.children;for(let s=0;sr.item);this._list.innerHTML="",this._list.append(...s.map(r=>r.cloneNode(!0)));const n=r=>{var c,o;if(r.nodeType===Node.TEXT_NODE&&((c=r.textContent)==null?void 0:c.trim())!=""&&((o=r.textContent)==null?void 0:o.trim())!=` +`){console.log(r);const h=r.textContent??"",a=document.createElement("template");a.innerHTML=this.highlightText(h,this._input.value),r.replaceWith(a.content)}else for(const h of r.childNodes)n(h)};for(const r of this._list.children)n(r);this.addEventListenersToListItems(),this.toggleList(t)}highlightText(t,s){const n=new RegExp(`[${s}]+`,"gmi");return t.replace(n,"$&")}toggleList(t=this._input.getAttribute("aria-expanded")==="true"){this._input.setAttribute("aria-expanded",`${t}`),t||this.unfocusAllItems()}focusItem(t){t&&(t.focus(),this._list.querySelectorAll("[aria-selected]").forEach(s=>s.removeAttribute("aria-selected")),t.setAttribute("aria-selected","true"))}unfocusAllItems(){this._list.querySelectorAll("[aria-selected]").forEach(t=>t.removeAttribute("aria-selected"))}selectItem(t,s=!0){this._input||this.fetchInput(),t.dataset.display?this._input.value=t.dataset.display:t.children.length||Array.from(t.children).every(n=>n.nodeName=="STRONG")?this._input.value=t.innerText:t.dataset.value?this._input.value=t.dataset.value:this._input.value="",t.dataset.value&&(this.dataset.value=t.dataset.value),this.sendChangeEvent(),s&&this._input.focus(),this.toggleList(!1),this.searchList(!1)}sendChangeEvent(){const t=new Event("change");this.dispatchEvent(t)}selectItemByValue(t,s=!0){if(!t)return;this._list||this.fetchList();const n=this._list.querySelector(`[data-value="${t}"]`);n&&this.selectItem(n,s)}clearInput(t=!0){this._input||this.fetchInput(),this._input.value="",t&&this._input.focus(),this.toggleList(!1)}handleBlur(){setTimeout(()=>{this.querySelector(":focus")||(this.forceValue(),this.toggleList(!1))},0)}forceValue(){var t;if(this._input||this.fetchInput(),this._list||this.fetchList(),this._forceValue&&((t=this._input)!=null&&t.value)){const s=this._list.children[0];s?this.selectItem(s,!1):(this.clearInput(!1),this.dataset.value="",this.sendChangeEvent())}}handleComboBoxKeyPress(t){switch(this._input||this.fetchInput(),this._list||this.fetchList(),t.key){case"ArrowDown":this._input.getAttribute("aria-expanded")!=="true"?(this.toggleList(!0),this._isAltModifierPressed||this.focusItem(this._list.children[0])):this.focusItem(this._list.children[0]),t.preventDefault();break;case"UpArrow":this._input.getAttribute("aria-expanded")!=="true"&&(this.toggleList(!0),this.focusItem(this._list.children[this._list.children.length-1])),t.preventDefault();break;case"Escape":this._input.getAttribute("aria-expanded")==="true"?this.toggleList(!1):this._input.value="",this._input.focus();break;case"Enter":this._input.getAttribute("aria-expanded")==="true"&&this.selectItem(this._list.children[0]);break;case"Alt":this._isAltModifierPressed=!0;break}}handleListKeyPress(t){this._input||this.fetchInput(),this._list||this.fetchList();const s=t.target;switch(t.key){case"Enter":this.selectItem(s);break;case"Escape":this.clearInput();break;case"ArrowDown":const n=s.nextElementSibling;n?this.focusItem(n):this.focusItem(this._list.children[0]),t.preventDefault();break;case"ArrowUp":if(this._isAltModifierPressed){this._input.focus(),this.toggleList(!1),t.preventDefault();break}const r=s.previousElementSibling;r?this.focusItem(r):this.focusItem(this._list.children[this._list.children.length-1]),t.preventDefault();break;case"ArrowRight":this._input.focus();break;case"ArrowLeft":this._input.focus();break;case"Home":this._input.focus();break;case"End":this._input.focus();break;case"Backspace":this._input.focus();break;case"Delete":this._input.focus();break;case"Alt":this._isAltModifierPressed=!0;break;default:this._input.focus();break}}handleKeyUp(t){switch(t.key){case"Alt":this._isAltModifierPressed=!1;break}}}customElements.define("combobox-framework",Zt); diff --git a/docs/index.html b/docs/index.html index 5d9e1ee..88147dc 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,7 +4,7 @@ Combobox Framework - + diff --git a/package.json b/package.json index 0ae1c69..b22f1f8 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.3.2", + "version": "0.3.3", "name": "combobox-framework", "description": "A framework for building comboboxes", "keywords": [