@pure-ds/core 0.7.58 → 0.7.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -38,7 +38,7 @@ export class AutoComplete extends EventTarget {
|
|
|
38
38
|
setText(options: any): void;
|
|
39
39
|
resultClick(event: any): void;
|
|
40
40
|
blurHandler(): void;
|
|
41
|
-
clear(): void;
|
|
41
|
+
clear(_reason: any, options?: {}): void;
|
|
42
42
|
cacheTmr: NodeJS.Timeout;
|
|
43
43
|
show(): void;
|
|
44
44
|
getViewBounds(): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pds-autocomplete.d.ts","sourceRoot":"","sources":["../../../../src/js/pds-autocomplete.js"],"names":[],"mappings":"AAgBA;IAwBC,8CAYC;IA2uBD,qDACqC,SAAI,SAaxC;IA5xBD,wDAqBC;IAlBA;;;;;MAMC;IAED,eAAuB;IACvB,WAAsB;IAEtB,gBAA2C;IAC3C,sBAAuB;IACvB,iBAAkB;IAClB,eAAiB;IACjB,qBAAqB;IAmBtB,yBAGC;IAED,eA8BC;IA7BA,2BAA+C;IA+BhD;;;;;MAMC;IAED;;;;;MAOC;IAED,2BA2BC;IAED,0BAEC;IAED,6BAkDC;IA7CA,uBAAyB;IAWxB,kBAA4D;IAoC9D,4BAiBC;IAED,8BAEC;IAED,oBAKC;IAED,
|
|
1
|
+
{"version":3,"file":"pds-autocomplete.d.ts","sourceRoot":"","sources":["../../../../src/js/pds-autocomplete.js"],"names":[],"mappings":"AAgBA;IAwBC,8CAYC;IA2uBD,qDACqC,SAAI,SAaxC;IA5xBD,wDAqBC;IAlBA;;;;;MAMC;IAED,eAAuB;IACvB,WAAsB;IAEtB,gBAA2C;IAC3C,sBAAuB;IACvB,iBAAkB;IAClB,eAAiB;IACjB,qBAAqB;IAmBtB,yBAGC;IAED,eA8BC;IA7BA,2BAA+C;IA+BhD;;;;;MAMC;IAED;;;;;MAOC;IAED,2BA2BC;IAED,0BAEC;IAED,6BAkDC;IA7CA,uBAAyB;IAWxB,kBAA4D;IAoC9D,4BAiBC;IAED,8BAEC;IAED,oBAKC;IAED,wCAaC;IAHA,yBAEiB;IAGlB,aAuBC;IAED;;;MAOC;IAED,aAEC;IAED,cAGC;IAED,wCAgEC;IAED,iCAeC;IAED,+BAmBC;IAED,+BAGC;IAED,sCAgBC;IAED,sCAcC;IAED,iDAuCC;IALC,6BAA0D;IAO5D,kCAQC;IAED,gEAmBC;IAED,wCAKC;IAED,oCAQC;IAED,oCAQC;IAED,kCASC;IAED,6DAqGC;IA/EA,yBAAoC;IACpC,2BAAwC;IAiNzC,6DAYC;IA7ID,yFAwBC;IAED,kFAwCC;IAED,iFA2DC;IAgBD,0CAKC;IAED,uCAGC;IAED,sCAKC;CAiBD"}
|
package/package.json
CHANGED
package/public/assets/js/app.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var mt=Object.defineProperty;var ht=(e,t)=>()=>(e&&(t=e(e=0)),t);var De=(e,t)=>{for(var n in t)mt(e,n,{get:t[n],enumerable:!0})};var Ie={};De(Ie,{AutoDefiner:()=>he});async function Pt(...e){let t={};e.length&&typeof e[e.length-1]=="object"&&(t=e.pop()||{});let n=e,{baseURL:o,mapper:i=p=>`${p}.js`,onError:r=(p,c)=>console.error(`[defineWebComponents] ${p}:`,c)}=t,d=o?new URL(o,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),S=p=>p.toLowerCase().replace(/(^|-)([a-z])/g,(c,f,A)=>A.toUpperCase()),L=async p=>{try{if(customElements.get(p))return{tag:p,status:"already-defined"};let c=i(p),A=await import(c instanceof URL?c.href:new URL(c,d).href),m=A?.default??A?.[S(p)];if(!m){if(customElements.get(p))return{tag:p,status:"self-defined"};throw new Error(`No export found for ${p}. Expected default export or named export "${S(p)}".`)}return customElements.get(p)?{tag:p,status:"race-already-defined"}:(customElements.define(p,m),{tag:p,status:"defined"})}catch(c){throw r(p,c),c}};return Promise.all(n.map(L))}var he,Fe=ht(()=>{he=class{constructor(t={}){let{baseURL:n,mapper:o,onError:i,predicate:r=()=>!0,attributeModule:d="data-module",root:S=document,scanExisting:L=!0,debounceMs:p=16,observeShadows:c=!0,enhancers:f=[],patchAttachShadow:A=!0}=t,m=new Set,E=new Set,j=new Set,a=new Map,l=new WeakMap,h=new WeakMap,u=0,y=!1,_=null,R=g=>{if(!g||!f.length)return;let w=h.get(g);w||(w=new Set,h.set(g,w));for(let b of f)if(!(!b.selector||!b.run)&&!w.has(b.selector))try{g.matches&&g.matches(b.selector)&&(b.run(g),w.add(b.selector))}catch(k){console.warn(`[AutoDefiner] Error applying enhancer for selector "${b.selector}":`,k)}},x=(g,w)=>{if(!y&&!(!g||!g.includes("-"))&&!customElements.get(g)&&!E.has(g)&&!j.has(g)){if(w&&w.getAttribute){let b=w.getAttribute(d);b&&!a.has(g)&&a.set(g,b)}m.add(g),P()}},P=()=>{u||(u=setTimeout(Pe,p))},T=g=>{if(g){if(g.nodeType===1){let w=g,b=w.tagName?.toLowerCase();b&&b.includes("-")&&!customElements.get(b)&&r(b,w)&&x(b,w),R(w),c&&w.shadowRoot&&ae(w.shadowRoot)}g.querySelectorAll&&g.querySelectorAll("*").forEach(w=>{let b=w.tagName?.toLowerCase();b&&b.includes("-")&&!customElements.get(b)&&r(b,w)&&x(b,w),R(w),c&&w.shadowRoot&&ae(w.shadowRoot)})}},ae=g=>{if(!g||l.has(g))return;T(g);let w=new MutationObserver(b=>{for(let k of b)k.addedNodes?.forEach(z=>{T(z)}),k.type==="attributes"&&k.target&&T(k.target)});w.observe(g,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[d,...f.map(b=>b.selector).filter(b=>b.startsWith("data-"))]}),l.set(g,w)};async function Pe(){if(clearTimeout(u),u=0,!m.size)return;let g=Array.from(m);m.clear(),g.forEach(w=>E.add(w));try{let w=b=>a.get(b)??(o?o(b):`${b}.js`);await Pt(...g,{baseURL:n,mapper:w,onError:(b,k)=>{j.add(b),i?.(b,k)}})}catch{}finally{g.forEach(w=>E.delete(w))}}let ke=S===document?document.documentElement:S,Re=new MutationObserver(g=>{for(let w of g)w.addedNodes?.forEach(b=>{T(b)}),w.type==="attributes"&&w.target&&T(w.target)});if(Re.observe(ke,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[d,...f.map(g=>g.selector).filter(g=>g.startsWith("data-"))]}),c&&A&&Element.prototype.attachShadow){let g=Element.prototype.attachShadow;Element.prototype.attachShadow=function(b){let k=g.call(this,b);if(b&&b.mode==="open"){ae(k);let z=this.tagName?.toLowerCase();z&&z.includes("-")&&!customElements.get(z)&&x(z,this)}return k},_=()=>Element.prototype.attachShadow=g}return L&&T(ke),{stop(){y=!0,Re.disconnect(),_&&_(),u&&(clearTimeout(u),u=0),l.forEach(g=>g.disconnect())},flush:Pe}}static async define(...t){let n={};t.length&&typeof t[t.length-1]=="object"&&(n=t.pop()||{});let o=t,{baseURL:i,mapper:r=c=>`${c}.js`,onError:d=(c,f)=>console.error(`[defineWebComponents] ${c}:`,f)}=n,S=i?new URL(i,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),L=c=>c.toLowerCase().replace(/(^|-)([a-z])/g,(f,A,m)=>m.toUpperCase()),p=async c=>{try{if(customElements.get(c))return{tag:c,status:"already-defined"};let f=r(c),m=await import(f instanceof URL?f.href:new URL(f,S).href),E=m?.default??m?.[L(c)];if(!E){if(customElements.get(c))return{tag:c,status:"self-defined"};throw new Error(`No export found for ${c}. Expected default export or named export "${L(c)}".`)}return customElements.get(c)?{tag:c,status:"race-already-defined"}:(customElements.define(c,E),{tag:c,status:"defined"})}catch(f){throw d(c,f),f}};return Promise.all(o.map(p))}}});var le=class extends EventTarget{constructor(){super(),this.mode=null,this.compiled=null,this.log=()=>{},this.logHandler=null}},Ce="__PURE_DS_PDS_SINGLETON__",de=typeof globalThis<"u"?globalThis:window,ce=de?.[Ce],s=ce&&typeof ce.addEventListener=="function"?ce:new le;de&&(de[Ce]=s);typeof s.log!="function"&&(s.log=(e="log",t,...n)=>{if(typeof console>"u")return;let o=typeof console[e]=="function"?console[e].bind(console):typeof console.log=="function"?console.log.bind(console):null;o&&(n.length>0?o(t,...n):o(t))});typeof s.logHandler!="function"&&(s.logHandler=null);var ue=class{constructor(){this._mode="static",this._staticPaths={tokens:"/assets/pds/styles/pds-tokens.css.js",primitives:"/assets/pds/styles/pds-primitives.css.js",components:"/assets/pds/styles/pds-components.css.js",utilities:"/assets/pds/styles/pds-utilities.css.js",styles:"/assets/pds/styles/pds-styles.css.js"}}setLiveMode(){this._mode="live"}setStaticMode(t={}){this._mode="static",this._staticPaths={...this._staticPaths,...t}}async getStylesheet(t){if(this._mode==="live")return null;try{return(await import(this._staticPaths[t]))[t]}catch(n){s.log("error",`Registry: failed to load static ${t}:`,n),s.log("error",`Registry: looking for ${this._staticPaths[t]}`),s.log("error","Registry: make sure you've run 'npm run pds:build' and configured PDS.start() with the correct static.root path");let o=new CSSStyleSheet;return o.replaceSync("/* Failed to load "+t+" */"),o}}get mode(){return this._mode}get isLive(){return this._mode==="live"}},$=new ue;async function Te(e,t=[],n=null){try{let o=n?.primitivesStylesheet?n.primitivesStylesheet:await $.getStylesheet("primitives");e.adoptedStyleSheets=[o,...t]}catch(o){let i=e.host?.tagName?.toLowerCase()||"unknown";s.log("error",`Adopter: <${i}> failed to adopt primitives:`,o),e.adoptedStyleSheets=t}}async function ze(e,t=["primitives"],n=[],o=null){let i=Array.isArray(n)?n.filter(Boolean):[];if(i.length){let d=(Array.isArray(e.adoptedStyleSheets)?e.adoptedStyleSheets:[]).filter(S=>!i.includes(S));e.adoptedStyleSheets=[...d,...i]}try{let d=(await Promise.all(t.map(async S=>{if(o)switch(S){case"tokens":return o.tokensStylesheet;case"primitives":return o.primitivesStylesheet;case"components":return o.componentsStylesheet;case"utilities":return o.utilitiesStylesheet;default:break}return $.getStylesheet(S)}))).filter(S=>S!==null);e.adoptedStyleSheets=[...d,...i]}catch(r){let d=e.host?.tagName?.toLowerCase()||"unknown";s.log("error",`Adopter: <${d}> failed to adopt layers:`,r),e.adoptedStyleSheets=i}}function $e(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var Ue={FontWeights:{light:300,normal:400,medium:500,semibold:600,bold:700},LineHeights:{tight:1.25,normal:1.5,relaxed:1.75},BorderWidths:{hairline:.5,thin:1,medium:2,thick:3},RadiusSizes:{none:0,small:4,medium:8,large:16,xlarge:24,xxlarge:32},ShadowDepths:{none:"none",light:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",medium:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",deep:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",extreme:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},TransitionSpeeds:{fast:150,normal:250,slow:350},AnimationEasings:{linear:"linear",ease:"ease","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out",bounce:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},TouchTargetSizes:{compact:36,standard:44,comfortable:48,spacious:56},LinkStyles:{inline:"inline",block:"block",button:"button"},FocusStyles:{ring:"ring",outline:"outline",border:"border",glow:"glow"},TabSizes:{compact:2,standard:4,wide:8},SelectIcons:{chevron:"chevron",arrow:"arrow",caret:"caret",none:"none"},IconSizes:{xs:16,sm:20,md:24,lg:32,xl:48,"2xl":64,"3xl":96}};var me={};De(me,{deepMerge:()=>Me,enQueue:()=>gt,escapeForRegExp:()=>St,fragmentFromTemplateLike:()=>pe,humanizeIdentifier:()=>Et,isObject:()=>K,isUrl:()=>bt,openCenteredWindow:()=>Lt,parseFragment:()=>G,parseHTML:()=>fe,throttle:()=>yt,withTimeout:()=>wt});function K(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Me(e,t){let n={...e};return K(e)&&K(t)&&Object.keys(t).forEach(o=>{K(t[o])?o in e?n[o]=Me(e[o],t[o]):Object.assign(n,{[o]:t[o]}):Object.assign(n,{[o]:t[o]})}),n}function pe(e){let t=Array.isArray(e?.strings)?e.strings:[],n=Array.isArray(e?.values)?e.values:[],o=new Set,i=[],r=/(\s)(\.[\w-]+)=["']?\s*$/,d=/(\s)(@[\w-]+)=["']?\s*$/,S=/(\s)(\?[\w-]+)=["']?\s*$/,L=/(\s)([\w:-]+)=["']?\s*$/,p=/=["']\s*$/,c=!1;for(let a=0;a<t.length;a+=1){let l=t[a]??"";if(c&&(l=l.replace(/^["']/,""),c=!1),a<n.length){let h=`pds-val-${a}`,u=l.match(r),y=l.match(d),_=l.match(S),R=l.match(L);if(u){let x=u[2].slice(1);c=p.test(t[a]??""),l=l.replace(r,`$1data-pds-bind-${a}="prop:${x}:${h}"`),o.add(a)}else if(y){let x=y[2].slice(1);c=p.test(t[a]??""),l=l.replace(d,`$1data-pds-bind-${a}="event:${x}:${h}"`),o.add(a)}else if(_){let x=_[2].slice(1);c=p.test(t[a]??""),l=l.replace(S,`$1data-pds-bind-${a}="boolean:${x}:${h}"`),o.add(a)}else if(R){let x=R[2];c=p.test(t[a]??""),l=l.replace(L,`$1data-pds-bind-${a}="attr:${x}:${h}"`),o.add(a)}}i.push(l),a<n.length&&!o.has(a)&&i.push(`<!--pds-val-${a}-->`)}let f=document.createElement("template");f.innerHTML=i.join("");let A=(a,l)=>{let h=a.parentNode;if(!h)return;if(l==null){h.removeChild(a);return}let u=y=>{if(y!=null){if(y instanceof Node){h.insertBefore(y,a);return}if(Array.isArray(y)){y.forEach(_=>u(_));return}h.insertBefore(document.createTextNode(String(y)),a)}};u(l),h.removeChild(a)},m=document.createTreeWalker(f.content,NodeFilter.SHOW_COMMENT),E=[];for(;m.nextNode();){let a=m.currentNode;a?.nodeValue?.startsWith("pds-val-")&&E.push(a)}return E.forEach(a=>{let l=Number(a.nodeValue.replace("pds-val-",""));A(a,n[l])}),f.content.querySelectorAll("*").forEach(a=>{[...a.attributes].forEach(l=>{if(!l.name.startsWith("data-pds-bind-"))return;let h=l.value.indexOf(":"),u=l.value.lastIndexOf(":");if(h<=0||u<=h){a.removeAttribute(l.name);return}let y=l.value.slice(0,h),_=l.value.slice(h+1,u),R=l.value.slice(u+1),x=Number(String(R).replace("pds-val-","")),P=n[x];if(!_||!Number.isInteger(x)){a.removeAttribute(l.name);return}y==="prop"?a[_]=P:y==="event"?(typeof P=="function"||P&&typeof P.handleEvent=="function")&&a.addEventListener(_,P):y==="boolean"?P?a.setAttribute(_,""):a.removeAttribute(_):y==="attr"&&(P==null||P===!1?a.removeAttribute(_):a.setAttribute(_,String(P))),a.removeAttribute(l.name)})}),f.content}function G(e,...t){if(Array.isArray(e)&&Object.prototype.hasOwnProperty.call(e,"raw"))return pe({strings:Array.from(e),values:t});if(Array.isArray(e?.strings)&&Array.isArray(e?.values))return pe({strings:e.strings,values:e.values});let o=document.createElement("template");return o.innerHTML=String(e??""),o.content}function fe(e,...t){return G(e,...t).childNodes}function yt(e,t=100){let n;return function(...i){let r=()=>{clearTimeout(n),e(...i)};clearTimeout(n),n=setTimeout(r,t)}}function gt(e){setTimeout(e,0)}function bt(e){try{if(typeof e!="string"||e.indexOf(`
|
|
2
2
|
`)!==-1||e.indexOf(" ")!==-1||e.startsWith("#/"))return!1;let t=new URL(e,window.location.origin);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function wt(e,t,n="Operation"){return!t||t<=0?e:new Promise((o,i)=>{let r=setTimeout(()=>{i(new Error(`${n} timed out after ${t}ms`))},t);Promise.resolve(e).then(d=>{clearTimeout(r),o(d)}).catch(d=>{clearTimeout(r),i(d)})})}function St(e){return String(e).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Lt(e,t,n){let o=window.screen.width/2-t/2,i=window.screen.height/2-n/2;return window.open(e,"",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=${t}, height=${n}, top=${i}, left=${o}`)}function Et(e){if(e==null)return"";let t=String(e).trim();return t?t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim():""}var Ne="pds",_t=/^([a-z][a-z0-9+\-.]*:)?\/\//i,Oe=/^[a-z]:/i;function N(e=""){return e.endsWith("/")?e:`${e}/`}function vt(e="",t=Ne){let n=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(n)?n:`${n}/${t}`}function At(e){return e.replace(/^\.\/+/,"")}function xt(e){return Oe.test(e)?e.replace(Oe,"").replace(/^\/+/,""):e}function jt(e){return e.startsWith("public/")?e.substring(7):e}function q(e,t={}){let n=t.segment||Ne,o=t.defaultRoot||`/assets/${n}/`,i=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!i||typeof i!="string")return N(o);let r=i.trim();return r?(r=r.replace(/\\/g,"/"),r=vt(r,n),r=N(r),_t.test(r)?r:(r=At(r),r=xt(r),r.startsWith("/")||(r=jt(r),r.startsWith("/")||(r=`/${r}`),r=r.replace(/\/+/g,(d,S)=>S===0?d:"/")),N(r))):N(o)}var ye=null;async function kt(){return ye||(ye=Promise.resolve().then(()=>(Fe(),Ie)).then(e=>e?.AutoDefiner||e?.default?.AutoDefiner||e?.default).then(e=>{if(typeof e!="function")throw new Error("AutoDefiner constructor not found in pure-web/auto-definer");return e})),ye}var Rt=/^[a-z][a-z0-9+\-.]*:\/\//i,I=(()=>{try{return import.meta.url}catch{return}})(),J=e=>typeof e=="string"&&e.length&&!e.endsWith("/")?`${e}/`:e;function V(e,t={}){if(!e||Rt.test(e))return e;let{preferModule:n=!0}=t,o=()=>{if(!I)return null;try{return new URL(e,I).href}catch{return null}},i=()=>{if(typeof window>"u"||!window.location?.origin)return null;try{return new URL(e,window.location.origin).href}catch{return null}};return(n?o()||i():i()||o())||e}var We=(()=>{if(I)try{let e=new URL(I);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",I).href}catch{return}})(),Be=!1;function He(e){Be||typeof document>"u"||(Be=!0,e.addEventListener("pds:ready",t=>{let n=t.detail?.mode;n&&document.documentElement.classList.add(`pds-${n}`,"pds-ready")}))}function Ke({manageTheme:e,themeStorageKey:t,applyResolvedTheme:n,setupSystemListenerIfNeeded:o}){let i="light",r=null;if(e&&typeof window<"u"){try{r=localStorage.getItem(t)||null}catch{r=null}try{n?.(r),o?.(r)}catch{}r?r==="system"?i=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":i=r:i=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:i,storedTheme:r}}function Q(e,{resolvePublicAssetURL:t}){let n=!!(e?.public?.root||e?.static?.root),o=t(e);return!n&&We&&(o=We),J(V(o))}async function Ge(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:n="/auto-define/",autoDefinePreload:o=[],autoDefineMapper:i=null,enhancers:r=[],autoDefineOverrides:d=null,autoDefinePreferModule:S=!0}=e,L=(()=>{let c=new Map;return(t||[]).forEach(f=>c.set(f.selector,f)),(r||[]).forEach(f=>c.set(f.selector,f)),Array.from(c.values())})(),p=null;if(typeof window<"u"&&typeof document<"u"){let c=await kt(),f=u=>{switch(u){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${u}.js`}},{mapper:A,enhancers:m,...E}=d&&typeof d=="object"?d:{},j=m?Array.isArray(m)?m:typeof m=="object"?Object.values(m):[]:[],a=(()=>{let u=new Map;return(L||[]).forEach(y=>{y?.selector&&u.set(y.selector,y)}),(j||[]).forEach(y=>{if(!y?.selector)return;let _=u.get(y.selector)||null;u.set(y.selector,{..._||{},...y,run:typeof y?.run=="function"?y.run:_?.run})}),Array.from(u.values())})(),h={baseURL:n&&J(V(n,{preferModule:S})),predefine:o,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:a,onError:(u,y)=>{if(typeof u=="string"&&u.startsWith("pds-")){let R=["pds-form","pds-drawer"].includes(u),x=y?.message?.includes("#pds/lit")||y?.message?.includes("Failed to resolve module specifier");R&&x?s.log("error",`\u274C PDS component <${u}> requires Lit but #pds/lit is not in import map.
|
|
3
|
-
See: https://github.com/Pure-Web-Foundation/pure-ds/blob/main/readme.md#lit-components-not-working`):s.log("warn",`\u26A0\uFE0F PDS component <${u}> not found. Assets may not be installed.`)}else s.log("error",`\u274C Auto-define error for <${u}>:`,y)},...E,mapper:u=>{if(customElements.get(u))return null;if(typeof i=="function")try{let y=i(u);return y===void 0?f(u):y}catch(y){return s.log("warn","Custom autoDefine.mapper error; falling back to default:",y?.message||y),f(u)}return f(u)}};p=new c(h),o.length>0&&typeof c.define=="function"&&await c.define(...o,{baseURL:n,mapper:h.mapper,onError:h.onError})}return{autoDefiner:p,mergedEnhancers:L}}var ge=["light","dark"],be=new Set(ge);function Dt(e){let n=(Array.isArray(e?.themes)?e.themes.map(o=>String(o).toLowerCase()):ge).filter(o=>be.has(o));return n.length?n:ge}function we(e,{preferDocument:t=!0}={}){let n=String(e||"").toLowerCase();if(be.has(n))return n;if(t&&typeof document<"u"){let o=document.documentElement?.getAttribute("data-theme");if(be.has(o))return o}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function qe(e,t){let n=we(t);return Dt(e).includes(n)}var Ct=new Set(["log","warn","error","debug","info"]),Tt="__PURE_DS_PDS_SINGLETON__",Se=null,Le=null;function Ve(){try{let t=(typeof globalThis<"u"?globalThis:window)?.[Tt];if(t&&typeof t=="object")return t}catch{return null}return null}function zt(e){return!e||typeof e!="object"?null:{mode:e.mode==="live"||e.mode==="static"?e.mode:null,debug:e.debug===!0,thisArg:e.thisArg}}function $t(e){if(typeof e!="string")return"log";let t=e.toLowerCase();return Ct.has(t)?t:"log"}function Ut(){if(typeof Le=="function")try{let t=zt(Le());if(t)return t}catch{}let e=Ve();if(e){let t=e?.mode||e?.compiled?.mode||(e?.registry?.isLive?"live":"static"),n=(e?.debug||e?.currentConfig?.debug||e?.currentConfig?.design?.debug||e?.compiled?.debug||e?.compiled?.design?.debug||!1)===!0;return{mode:t,debug:n,thisArg:e}}return{mode:null,debug:!1}}function Mt(){if(typeof Se=="function")try{let t=Se();if(typeof t=="function")return t}catch{}let e=Ve();return typeof e?.logHandler=="function"?e.logHandler:null}function Je(e,t,...n){if(typeof console>"u")return;let o=typeof console[e]=="function"?console[e].bind(console):typeof console.log=="function"?console.log.bind(console):null;o&&(n.length>0?o(t,...n):o(t))}function Ot(e,t){let n=t?.debug===!0;return!(t?.mode==="static"&&!n||!n&&e!=="error"&&e!=="warn")}function Qe({getLogger:e,getContext:t}={}){Se=typeof e=="function"?e:null,Le=typeof t=="function"?t:null}function Ye(e="log",t,...n){let o=$t(e),i=Ut(),r=Mt();if(r)try{r.call(i?.thisArg,o,t,...n);return}catch(d){Je("error","Custom log handler failed:",d)}Ot(o,i)&&Je(o,t,...n)}var Y=class{constructor(t={},n=null){let o=t&&typeof t=="object"?t:{},i=n||(typeof document<"u"?document:new EventTarget),r=new WeakMap,d=m=>m.map(E=>String(E)).join("."),S,L=(m,E,j,a)=>{let l=d(m),h={property:E,path:l,value:j,oldValue:a};i.dispatchEvent(new CustomEvent(`change:${l}`,{detail:h,bubbles:!0,composed:!0})),i.dispatchEvent(new CustomEvent("change",{detail:{...h,state:S},bubbles:!0,composed:!0}))},p=(m,E)=>(typeof E=="function"&&i.addEventListener(m,E),S),c=(m,E)=>(typeof E=="function"&&i.removeEventListener(m,E),S),f=(m,E)=>{if(typeof E=="function"){let j=a=>{E(a),i.removeEventListener(m,j)};i.addEventListener(m,j)}return S},A=(m,E)=>{if(!m||typeof m!="object")return m;if(r.has(m))return r.get(m);let j=new Proxy(m,{get(a,l,h){if(l==="on")return p;if(l==="off")return c;if(l==="once")return f;let u=Reflect.get(a,l,h);return u&&typeof u=="object"?A(u,[...E,l]):u},set(a,l,h,u){let y=Reflect.get(a,l,u);return Object.is(y,h)?!0:Reflect.set(a,l,h,u)?(L([...E,l],l,h,y),!0):!1},deleteProperty(a,l){if(!Reflect.has(a,l))return!0;let h=a[l];return Reflect.deleteProperty(a,l)?(L([...E,l],l,void 0,h),!0):!1}});return r.set(m,j),j};return S=A(o,[]),S}};function Ze(e,t,n){if(!e||!t||typeof n!="object")return()=>{};let o={};return Object.entries(n).forEach(([i,r])=>{o[i]=d=>{typeof r=="function"&&r(e,d.detail.value,d.detail.oldValue)},t.on(`change:${i}`,o[i])}),()=>{Object.entries(o).forEach(([i,r])=>{t.off(`change:${i}`,r)})}}typeof s.initializing!="boolean"&&(s.initializing=!1);"currentPreset"in s||(s.currentPreset=null);typeof s.debug!="boolean"&&(s.debug=!1);"currentConfig"in s||(s.currentConfig=null);"compiled"in s||(s.compiled=null);typeof s.logHandler!="function"&&(s.logHandler=null);"mode"in s||(s.mode=null);var Z=null,X=null,ee=null,te=null,ne=null,oe=null,et="__pdsLocalizationRuntime";function U(){if(oe)return oe;let e=s?.[et];return e&&typeof e=="object"?(oe=e,e):null}function Nt(e){let t=e&&typeof e=="object"?e:null;oe=t,s[et]=t}Qe({getLogger:()=>typeof s.logHandler=="function"?s.logHandler:null,getContext:()=>{let e=s?.mode||s?.compiled?.mode||(s?.registry?.isLive?"live":"static"),t=(s?.debug||s?.currentConfig?.debug||s?.currentConfig?.design?.debug||s?.compiled?.debug||s?.compiled?.design?.debug||!1)===!0;return{mode:e,debug:t,thisArg:s}}});s.log=(e="log",t,...n)=>{Ye(e,t,...n)};var v={locale:"en",messages:{},hasProvider:!1},se=new Set;function tt(e){return!!e&&typeof e!="string"&&typeof e=="object"&&"strTag"in e}function nt(e=[]){let t="";for(let n=0;n<=e.length-1;n+=1)t+=e[n],n<e.length-1&&(t+=`{${n}}`);return t}function It(e,t){return String(e).replace(/\{(\d+)\}/g,(n,o)=>t(Number(o)))}function Ft(e){if(!e||typeof e!="object")return{};let t={};for(let[n,o]of Object.entries(e)){if(typeof o=="string"){t[n]=o;continue}o&&typeof o=="object"&&typeof o.content=="string"&&(t[n]=o.content)}return t}function Wt(e,...t){return{strTag:!0,strings:Array.from(e||[]),values:t,raw:Array.from(e?.raw||[])}}function Bt(e){if(!e)return"";if(tt(e)){let n=nt(e.strings||[]),o=v.messages[n]||n;return It(o,i=>e.values?.[i])}let t=String(e);return v.messages[t]||t}function Ht(e){if(!e)return;let t=tt(e)?nt(e.strings||[]):String(e);typeof t=="string"&&t.length>0&&se.add(t)}function ot(e){if(!e||typeof e.msg!="function"||se.size===0)return;let t=Array.from(se);se.clear();for(let n of t)try{e.msg(n)}catch{}}async function W(){let e=U();return e||(ne||(ne=import(B("pds-localization.js")).then(n=>{if(typeof n?.msg!="function"||typeof n?.str!="function"||typeof n?.configureLocalization!="function"||typeof n?.loadLocale!="function"||typeof n?.setLocale!="function"||typeof n?.getLocalizationState!="function")throw new Error("Failed to load localization runtime exports");return Nt(n),ot(n),n}).catch(n=>{throw ne=null,n})),ne)}var M=(e,t={})=>{let n=U();return typeof n?.msg=="function"?n.msg(e,t):(Ht(e),Bt(e,t))},ie=(e,...t)=>{let n=U();return typeof n?.str=="function"?n.str(e,...t):Wt(e,...t)},re=(e=null)=>{let t=U();if(typeof t?.configureLocalization=="function")return t.configureLocalization(e);if(!e||typeof e!="object")return v.locale="en",v.messages={},v.hasProvider=!1,{locale:v.locale,messages:{...v.messages},hasProvider:v.hasProvider};typeof e.locale=="string"&&e.locale.trim()&&(v.locale=e.locale.trim()),Object.prototype.hasOwnProperty.call(e,"messages")&&(v.messages=Ft(e.messages));let n=!!(e.provider||e.translate||e.loadLocale||e.setLocale);return v.hasProvider=n,n&&W().then(o=>{o.configureLocalization(e),ot(o)}).catch(()=>{}),{locale:v.locale,messages:{...v.messages},hasProvider:v.hasProvider}},st=async e=>(await W()).loadLocale(e),rt=async(e,t={})=>(await W()).setLocale(e,t),it=()=>{let e=U();return typeof e?.getLocalizationState=="function"?e.getLocalizationState():{locale:v.locale,messages:{...v.messages},hasProvider:v.hasProvider}},at=(e={})=>{let t=U();if(typeof t?.createJSONLocalization=="function")return t.createJSONLocalization(e);let n=typeof e?.locale=="string"&&e.locale.trim()?e.locale.trim().toLowerCase():"en",o=Array.isArray(e?.locales)?e.locales.map(L=>String(L||"").trim().toLowerCase()).filter(Boolean):[],i=Array.from(new Set([n,...o])),r=null,d=async()=>(r||(r=W().then(L=>typeof L?.createJSONLocalization=="function"?L.createJSONLocalization(e):null).catch(()=>null)),r),S=async(L="loadLocale")=>{let p=await d();if(!p||typeof p!="object")return null;let c=p.provider;if(!c||typeof c!="object")return null;let f=c[L];return typeof f=="function"?f:L==="setLocale"&&typeof c.loadLocale=="function"?c.loadLocale:null};return{locale:n,locales:[...i],provider:{locales:[...i],async loadLocale(L={}){let p=await S("loadLocale");return typeof p!="function"?{}:p(L)},async setLocale(L={}){let p=await S("setLocale");return typeof p!="function"?{}:p(L)}}}};function B(e,t){return t&&typeof t=="string"?t:`${Q(s.currentConfig||{},{resolvePublicAssetURL:q})}core/${e}`}async function Kt(){return Array.isArray(s.defaultEnhancers)&&s.defaultEnhancers.length>0?s.defaultEnhancers:(te||(te=import(B("pds-enhancers.js",s.currentConfig?.enhancersURL)).then(t=>{let n=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return s.defaultEnhancers=n,n}).catch(t=>{throw te=null,t})),te)}async function Gt(){return typeof s.ask=="function"&&s.ask!==ct?s.ask:(X||(X=import(B("pds-ask.js",s.currentConfig?.askURL)).then(t=>{let n=t?.ask;if(typeof n!="function")throw new Error("Failed to load ask helper");return s.ask=n,n}).catch(t=>{throw X=null,t})),X)}async function H(){return typeof s.toast=="function"&&s.toast!==O?s.toast:(ee||(ee=import(B("pds-toast.js",s.currentConfig?.toastURL)).then(t=>{let n=t?.toast;if(typeof n!="function")throw new Error("Failed to load toast helper");return s.toast=n,n}).catch(t=>{throw ee=null,t})),ee)}async function ct(...e){return(await Gt())(...e)}async function O(...e){return(await H())(...e)}O.success=async(...e)=>(await H()).success(...e);O.error=async(...e)=>(await H()).error(...e);O.warning=async(...e)=>(await H()).warning(...e);O.info=async(...e)=>(await H()).info(...e);var Xe=function(e="log",t,...n){s.log(e,t,...n)};function _e(e){if(e==null)return e;if(typeof e=="function")return;if(typeof e!="object")return e;if(Array.isArray(e))return e.map(n=>_e(n)).filter(n=>n!==void 0);let t={};for(let[n,o]of Object.entries(e)){let i=_e(o);i!==void 0&&(t[n]=i)}return t}function lt(e,t=new WeakSet){if(!e||typeof e!="object"||t.has(e))return e;t.add(e),Object.freeze(e);for(let n of Object.keys(e))lt(e[n],t);return e}function ve(e){return e==null||typeof e!="object"?e:lt(structuredClone(_e(e)))}async function qt(e,t={}){if(t?.runtimeConfig===!1||typeof fetch!="function")return null;let n=t?.runtimeConfigURL||`${e}pds-runtime-config.json`;try{let o=await fetch(n,{cache:"no-store"});return o.ok?await o.json():null}catch{return null}}s.registry=$;s.enums=Ue;s.adoptLayers=ze;s.adoptPrimitives=Te;var Jt=fe;s.parse=Jt;var Ae=G;s.html=Ae;s.State=Y;s.bindState=Ze;s.createStylesheet=$e;s.isLiveMode=()=>$.isLive;s.ask=ct;s.toast=O;s.common=me;s.msg=M;s.str=ie;s.configureLocalization=re;s.loadLocale=st;s.setLocale=rt;s.getLocalizationState=it;s.createJSONLocalization=at;s.i18n={msg:M,str:ie,configure:re,loadLocale:st,setLocale:rt,getState:it,createJSONLocalization:at};s.AutoComplete=null;s.loadAutoComplete=async()=>{if(s.AutoComplete&&typeof s.AutoComplete.connect=="function")return s.AutoComplete;let e=B("pds-autocomplete.js",s.currentConfig?.autoCompleteURL);return Z||(Z=import(e).then(t=>{let n=t?.AutoComplete||t?.default?.AutoComplete||t?.default||null;if(!n)throw new Error("AutoComplete export not found in module");return s.AutoComplete=n,n}).catch(t=>{throw Z=null,t})),Z};function dt(e){let t=typeof CustomEvent=="function";try{let n=t?new CustomEvent("pds:ready",{detail:e}):new Event("pds:ready");s.dispatchEvent(n)}catch{}if(typeof document<"u")if(t){let n={detail:e,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:ready",n))}catch{}try{document.dispatchEvent(new CustomEvent("pds-ready",n))}catch{}}else{try{document.dispatchEvent(new Event("pds:ready"))}catch{}try{document.dispatchEvent(new Event("pds-ready"))}catch{}}}function ut(e={}){let t=typeof CustomEvent=="function",n={at:Date.now(),...e};try{let o=t?new CustomEvent("pds:config-changed",{detail:n}):new Event("pds:config-changed");s.dispatchEvent(o)}catch{}if(typeof document<"u")if(t){let o={detail:n,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:config-changed",o))}catch{}}else try{document.dispatchEvent(new Event("pds:config-changed"))}catch{}}var Ee="pure-ds-theme",C=null,F=null;function xe(e){try{if(typeof document>"u")return;let t="light";e?e==="system"?t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t=e:t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",document.documentElement.setAttribute("data-theme",t)}catch{}}function je(e){try{if(C&&F){try{typeof C.removeEventListener=="function"?C.removeEventListener("change",F):typeof C.removeListener=="function"&&C.removeListener(F)}catch{}C=null,F=null}if(e==="system"&&typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=o=>{let i=o?.matches===void 0?t.matches:o.matches;try{let r=i?"dark":"light";document.documentElement.setAttribute("data-theme",r),s.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:r,source:"system"}}))}catch{}};C=t,F=n,typeof t.addEventListener=="function"?t.addEventListener("change",n):typeof t.addListener=="function"&&t.addListener(n)}}catch{}}var Vt=Object.getOwnPropertyDescriptor(s,"theme");Vt||Object.defineProperty(s,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(Ee)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=s.currentConfig?.design||null,n=we(e);if(t&&!qe(t,n)){let o=t?.name||s.currentPreset?.name||s.currentConfig?.preset||"current preset";s.log("warn",`PDS theme "${n}" not supported by preset "${o}".`),s.dispatchEvent(new CustomEvent("pds:theme:blocked",{detail:{theme:e,resolvedTheme:n,preset:o}}));return}e==null?localStorage.removeItem(Ee):localStorage.setItem(Ee,e),xe(e),je(e),s.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});s.defaultEnhancers=[];async function Qt(e){s.initializing=!0;try{let t=e&&e.mode||"live",{mode:n,...o}=e||{};s.mode=t,s.logHandler=typeof o?.log=="function"?o.log:null,s.currentConfig=ve(o);let i=o&&typeof o.localization=="object"&&o.localization?o.localization:null;i?(await W(),re(i)):re(null);let r;if(t==="static")r=await Yt(o);else{let{localization:S,...L}=o||{},p=Q(L,{resolvePublicAssetURL:q}),c=L?.managerURL||L?.public?.managerURL||L?.manager?.url||new URL("core/pds-manager.js",p).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:f}=await import(c);r=await f(s,L,{emitReady:dt,emitConfigChanged:ut,applyResolvedTheme:xe,setupSystemListenerIfNeeded:je})}s.compiled=ve(r?.config||null);let d=s?.compiled?.design?.icons?.externalPath||"/assets/img/icons/";return s.log("info",`startup ready; external icon path: ${d}`),r}finally{s.initializing=!1}}s.start=Qt;async function Yt(e){if(!e||typeof e!="object")throw new Error("PDS.start({ mode: 'static', ... }) requires a valid configuration object");let t=e.applyGlobalStyles??!0,n=e.manageTheme??!0,o=e.themeStorageKey??"pure-ds-theme",i=e.staticPaths??{},r=Q(e,{resolvePublicAssetURL:q}),d=e&&e.autoDefine||null,S;d&&d.baseURL?S=J(V(d.baseURL,{preferModule:!1})):S=`${r}components/`;let L=d&&Array.isArray(d.predefine)&&d.predefine||[],p=d&&typeof d.mapper=="function"&&d.mapper||null;try{He(s);let{resolvedTheme:c}=Ke({manageTheme:n,themeStorageKey:o,applyResolvedTheme:xe,setupSystemListenerIfNeeded:je}),f=await qt(r,e),A=Array.isArray(e?.enhancers)?e.enhancers:e?.enhancers&&typeof e.enhancers=="object"?Object.values(e.enhancers):[],m=f?.config?{...f.config,...e,design:e?.design||f.config.design,preset:e?.preset||f.config.preset}:{...e},E={tokens:`${r}styles/pds-tokens.css.js`,primitives:`${r}styles/pds-primitives.css.js`,components:`${r}styles/pds-components.css.js`,utilities:`${r}styles/pds-utilities.css.js`,styles:`${r}styles/pds-styles.css.js`},j=f?.paths||{};if(i={...E,...j,...i},s.registry.setStaticMode(i),t&&typeof document<"u")try{let h=await s.registry.getStylesheet("styles");if(h){h._pds=!0;let u=(document.adoptedStyleSheets||[]).filter(y=>y._pds!==!0);document.adoptedStyleSheets=[...u,h],ut({mode:"static",source:"static:styles-applied"})}}catch(h){Xe.call(s,"warn","Failed to apply static styles:",h)}let a=null,l=[];try{let h=await Kt(),u=await Ge({autoDefineBaseURL:S,autoDefinePreload:L,autoDefineMapper:p,enhancers:A,autoDefineOverrides:d||null,autoDefinePreferModule:!(d&&d.baseURL)},{baseEnhancers:h});a=u.autoDefiner,l=u.mergedEnhancers||[]}catch(h){Xe.call(s,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",h)}return s.compiled=ve({mode:"static",...m,theme:c,enhancers:l}),dt({mode:"static",config:m,theme:c,autoDefiner:a}),{config:m,theme:c,autoDefiner:a}}catch(c){throw s.dispatchEvent(new CustomEvent("pds:error",{detail:{error:c}})),c}}var Zt=s.createJSONLocalization({locale:"en-US",locales:["en-US","nl-NL"],aliases:{en:["en-US"],nl:["nl-NL"]},basePath:"/assets/locales"}),pt={mode:"live",liveEdit:!0,preset:"default",localization:Zt,autoDefine:{predefine:["pds-icon","pds-drawer","pds-toaster"]},log(e,t,...n){(this?.mode||this?.compiled?.mode||"live")!=="static"&&(typeof console[e]=="function"?console[e]:console.log)(`[PDS] ${t}`,...n)}};var D={name:"@pure-ds/core",shortname:"pds",version:"0.7.58",description:"Why develop a Design System when you can generate one?",repository:{type:"git",url:"git+https://github.com/Pure-Web-Foundation/pure-ds.git"},bugs:{url:"https://github.com/Pure-Web-Foundation/pure-ds/issues"},homepage:"https://puredesignsystem.z6.web.core.windows.net/",keywords:["design-system","css","web-components","lit","constructable-stylesheets","tokens","utilities","a11y"],type:"module",main:"./public/assets/pds/core.js",module:"./public/assets/pds/core.js",types:"./dist/types/pds.d.ts",bin:{"pds-build":"packages/pds-cli/bin/pds-static.js","pds-sync-assets":"packages/pds-cli/bin/sync-assets.js","pds-build-icons":"packages/pds-cli/bin/pds-build-icons.js","pds-import":"packages/pds-cli/bin/pds-import.js","pds-setup-copilot":"packages/pds-cli/bin/pds-setup-copilot.js","pds-setup-mcp":"packages/pds-cli/bin/pds-setup-mcp.js","pds-init-config":"packages/pds-cli/bin/pds-init-config.js","pds-bootstrap":"packages/pds-cli/bin/pds-bootstrap.js","pds-mcp-server":"packages/pds-cli/bin/pds-mcp-server.js","pds-mcp-health":"packages/pds-cli/bin/pds-mcp-health.js","pds-mcp-eval":"packages/pds-cli/bin/pds-mcp-eval.js"},exports:{".":{types:"./src/js/pds.d.ts",import:"./public/assets/pds/core.js"},"./localization":{types:"./dist/types/src/js/pds-localization.d.ts",import:"./public/assets/pds/core/pds-localization.js"},"./lit":{types:"./dist/types/src/js/lit.d.ts",import:"./public/assets/pds/external/lit.js"},"./pds-core":"./src/js/pds.js","./auto-define/*":"./public/auto-define/*"},files:[".github/copilot-instructions.md",".cursorrules","dist/types/","public/assets/js/","public/assets/pds/components/","public/assets/pds/templates/","public/assets/pds/core.js","public/assets/pds/core/","public/assets/pds/external/","public/assets/pds/vscode-custom-data.json","public/assets/pds/pds.css-data.json","public/assets/pds/pds-css-complete.json","public/auto-define/","public/pds/components/","public/assets/pds/icons/pds-icons.svg","packages/pds-cli/bin/","packages/pds-cli/lib/","src/js/pds.d.ts","src/js/pds.js","src/js/pds-singleton.js","src/js/common/","src/js/pds-live-manager/","src/js/pds-core/","custom-elements.json","custom-elements-manifest.config.js","pds.html-data.json","pds.css-data.json","LOCALIZATION.md","readme.md","INTELLISENSE.md","CSS-INTELLISENSE-LIMITATION.md","CSS-INTELLISENSE-QUICK-REF.md"],scripts:{dev:"node esbuild-dev.js",prebuild:"npm run types",build:"node esbuild-build.js",types:"tsc -p tsconfig.json && node scripts/sync-types.mjs",postinstall:"node packages/pds-cli/bin/postinstall.mjs","prepds:build":"npm run types","pds:build":"node packages/pds-cli/bin/pds-static.js","pds:build-icons":"node packages/pds-cli/bin/pds-build-icons.js","pds:bootstrap":"node packages/pds-cli/bin/pds-bootstrap.js","pds:manifest":"node packages/pds-cli/bin/generate-manifest.js","pds:css-data":"node packages/pds-cli/bin/generate-css-data.js","pds:import":"node packages/pds-cli/bin/pds-import.js","pds:dx":"node packages/pds-cli/bin/pds-dx.js","pds:mcp:server":"node packages/pds-cli/bin/pds-mcp-server.js","pds:mcp:health":"node packages/pds-cli/bin/pds-mcp-health.js","pds:mcp:eval":"node packages/pds-cli/bin/pds-mcp-eval.js","storybook:generate":"cd packages/pds-storybook && npm run generate-stories","storybook:dev":"cd packages/pds-storybook && npm run storybook:dev","storybook:build":"cd packages/pds-storybook && npm run storybook:build"},author:"Marc van Neerven",license:"ISC",engines:{node:">=18"},publishConfig:{access:"public"},devDependencies:{"@custom-elements-manifest/analyzer":"^0.9.9","@types/node":"^22.10.2",esbuild:"^0.19.0","fs-extra":"^11.1.1",typescript:"^5.6.3"},dependencies:{lit:"^3.3.2","pure-web":"1.1.32"},customElements:"custom-elements.json"};await s.start(pt);document.documentElement.lang="en";var ft=typeof D.repository=="string"?D.repository:D.repository?.url,en=ft?ft.replace(/^git\+/,"").replace(/\.git$/,""):"",Tn=D.homepage||en,zn=D.bugs?.url||"";document.body.appendChild(Ae`
|
|
3
|
+
See: https://github.com/Pure-Web-Foundation/pure-ds/blob/main/readme.md#lit-components-not-working`):s.log("warn",`\u26A0\uFE0F PDS component <${u}> not found. Assets may not be installed.`)}else s.log("error",`\u274C Auto-define error for <${u}>:`,y)},...E,mapper:u=>{if(customElements.get(u))return null;if(typeof i=="function")try{let y=i(u);return y===void 0?f(u):y}catch(y){return s.log("warn","Custom autoDefine.mapper error; falling back to default:",y?.message||y),f(u)}return f(u)}};p=new c(h),o.length>0&&typeof c.define=="function"&&await c.define(...o,{baseURL:n,mapper:h.mapper,onError:h.onError})}return{autoDefiner:p,mergedEnhancers:L}}var ge=["light","dark"],be=new Set(ge);function Dt(e){let n=(Array.isArray(e?.themes)?e.themes.map(o=>String(o).toLowerCase()):ge).filter(o=>be.has(o));return n.length?n:ge}function we(e,{preferDocument:t=!0}={}){let n=String(e||"").toLowerCase();if(be.has(n))return n;if(t&&typeof document<"u"){let o=document.documentElement?.getAttribute("data-theme");if(be.has(o))return o}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function qe(e,t){let n=we(t);return Dt(e).includes(n)}var Ct=new Set(["log","warn","error","debug","info"]),Tt="__PURE_DS_PDS_SINGLETON__",Se=null,Le=null;function Ve(){try{let t=(typeof globalThis<"u"?globalThis:window)?.[Tt];if(t&&typeof t=="object")return t}catch{return null}return null}function zt(e){return!e||typeof e!="object"?null:{mode:e.mode==="live"||e.mode==="static"?e.mode:null,debug:e.debug===!0,thisArg:e.thisArg}}function $t(e){if(typeof e!="string")return"log";let t=e.toLowerCase();return Ct.has(t)?t:"log"}function Ut(){if(typeof Le=="function")try{let t=zt(Le());if(t)return t}catch{}let e=Ve();if(e){let t=e?.mode||e?.compiled?.mode||(e?.registry?.isLive?"live":"static"),n=(e?.debug||e?.currentConfig?.debug||e?.currentConfig?.design?.debug||e?.compiled?.debug||e?.compiled?.design?.debug||!1)===!0;return{mode:t,debug:n,thisArg:e}}return{mode:null,debug:!1}}function Mt(){if(typeof Se=="function")try{let t=Se();if(typeof t=="function")return t}catch{}let e=Ve();return typeof e?.logHandler=="function"?e.logHandler:null}function Je(e,t,...n){if(typeof console>"u")return;let o=typeof console[e]=="function"?console[e].bind(console):typeof console.log=="function"?console.log.bind(console):null;o&&(n.length>0?o(t,...n):o(t))}function Ot(e,t){let n=t?.debug===!0;return!(t?.mode==="static"&&!n||!n&&e!=="error"&&e!=="warn")}function Qe({getLogger:e,getContext:t}={}){Se=typeof e=="function"?e:null,Le=typeof t=="function"?t:null}function Ye(e="log",t,...n){let o=$t(e),i=Ut(),r=Mt();if(r)try{r.call(i?.thisArg,o,t,...n);return}catch(d){Je("error","Custom log handler failed:",d)}Ot(o,i)&&Je(o,t,...n)}var Y=class{constructor(t={},n=null){let o=t&&typeof t=="object"?t:{},i=n||(typeof document<"u"?document:new EventTarget),r=new WeakMap,d=m=>m.map(E=>String(E)).join("."),S,L=(m,E,j,a)=>{let l=d(m),h={property:E,path:l,value:j,oldValue:a};i.dispatchEvent(new CustomEvent(`change:${l}`,{detail:h,bubbles:!0,composed:!0})),i.dispatchEvent(new CustomEvent("change",{detail:{...h,state:S},bubbles:!0,composed:!0}))},p=(m,E)=>(typeof E=="function"&&i.addEventListener(m,E),S),c=(m,E)=>(typeof E=="function"&&i.removeEventListener(m,E),S),f=(m,E)=>{if(typeof E=="function"){let j=a=>{E(a),i.removeEventListener(m,j)};i.addEventListener(m,j)}return S},A=(m,E)=>{if(!m||typeof m!="object")return m;if(r.has(m))return r.get(m);let j=new Proxy(m,{get(a,l,h){if(l==="on")return p;if(l==="off")return c;if(l==="once")return f;let u=Reflect.get(a,l,h);return u&&typeof u=="object"?A(u,[...E,l]):u},set(a,l,h,u){let y=Reflect.get(a,l,u);return Object.is(y,h)?!0:Reflect.set(a,l,h,u)?(L([...E,l],l,h,y),!0):!1},deleteProperty(a,l){if(!Reflect.has(a,l))return!0;let h=a[l];return Reflect.deleteProperty(a,l)?(L([...E,l],l,void 0,h),!0):!1}});return r.set(m,j),j};return S=A(o,[]),S}};function Ze(e,t,n){if(!e||!t||typeof n!="object")return()=>{};let o={};return Object.entries(n).forEach(([i,r])=>{o[i]=d=>{typeof r=="function"&&r(e,d.detail.value,d.detail.oldValue)},t.on(`change:${i}`,o[i])}),()=>{Object.entries(o).forEach(([i,r])=>{t.off(`change:${i}`,r)})}}typeof s.initializing!="boolean"&&(s.initializing=!1);"currentPreset"in s||(s.currentPreset=null);typeof s.debug!="boolean"&&(s.debug=!1);"currentConfig"in s||(s.currentConfig=null);"compiled"in s||(s.compiled=null);typeof s.logHandler!="function"&&(s.logHandler=null);"mode"in s||(s.mode=null);var Z=null,X=null,ee=null,te=null,ne=null,oe=null,et="__pdsLocalizationRuntime";function U(){if(oe)return oe;let e=s?.[et];return e&&typeof e=="object"?(oe=e,e):null}function Nt(e){let t=e&&typeof e=="object"?e:null;oe=t,s[et]=t}Qe({getLogger:()=>typeof s.logHandler=="function"?s.logHandler:null,getContext:()=>{let e=s?.mode||s?.compiled?.mode||(s?.registry?.isLive?"live":"static"),t=(s?.debug||s?.currentConfig?.debug||s?.currentConfig?.design?.debug||s?.compiled?.debug||s?.compiled?.design?.debug||!1)===!0;return{mode:e,debug:t,thisArg:s}}});s.log=(e="log",t,...n)=>{Ye(e,t,...n)};var v={locale:"en",messages:{},hasProvider:!1},se=new Set;function tt(e){return!!e&&typeof e!="string"&&typeof e=="object"&&"strTag"in e}function nt(e=[]){let t="";for(let n=0;n<=e.length-1;n+=1)t+=e[n],n<e.length-1&&(t+=`{${n}}`);return t}function It(e,t){return String(e).replace(/\{(\d+)\}/g,(n,o)=>t(Number(o)))}function Ft(e){if(!e||typeof e!="object")return{};let t={};for(let[n,o]of Object.entries(e)){if(typeof o=="string"){t[n]=o;continue}o&&typeof o=="object"&&typeof o.content=="string"&&(t[n]=o.content)}return t}function Wt(e,...t){return{strTag:!0,strings:Array.from(e||[]),values:t,raw:Array.from(e?.raw||[])}}function Bt(e){if(!e)return"";if(tt(e)){let n=nt(e.strings||[]),o=v.messages[n]||n;return It(o,i=>e.values?.[i])}let t=String(e);return v.messages[t]||t}function Ht(e){if(!e)return;let t=tt(e)?nt(e.strings||[]):String(e);typeof t=="string"&&t.length>0&&se.add(t)}function ot(e){if(!e||typeof e.msg!="function"||se.size===0)return;let t=Array.from(se);se.clear();for(let n of t)try{e.msg(n)}catch{}}async function W(){let e=U();return e||(ne||(ne=import(B("pds-localization.js")).then(n=>{if(typeof n?.msg!="function"||typeof n?.str!="function"||typeof n?.configureLocalization!="function"||typeof n?.loadLocale!="function"||typeof n?.setLocale!="function"||typeof n?.getLocalizationState!="function")throw new Error("Failed to load localization runtime exports");return Nt(n),ot(n),n}).catch(n=>{throw ne=null,n})),ne)}var M=(e,t={})=>{let n=U();return typeof n?.msg=="function"?n.msg(e,t):(Ht(e),Bt(e,t))},ie=(e,...t)=>{let n=U();return typeof n?.str=="function"?n.str(e,...t):Wt(e,...t)},re=(e=null)=>{let t=U();if(typeof t?.configureLocalization=="function")return t.configureLocalization(e);if(!e||typeof e!="object")return v.locale="en",v.messages={},v.hasProvider=!1,{locale:v.locale,messages:{...v.messages},hasProvider:v.hasProvider};typeof e.locale=="string"&&e.locale.trim()&&(v.locale=e.locale.trim()),Object.prototype.hasOwnProperty.call(e,"messages")&&(v.messages=Ft(e.messages));let n=!!(e.provider||e.translate||e.loadLocale||e.setLocale);return v.hasProvider=n,n&&W().then(o=>{o.configureLocalization(e),ot(o)}).catch(()=>{}),{locale:v.locale,messages:{...v.messages},hasProvider:v.hasProvider}},st=async e=>(await W()).loadLocale(e),rt=async(e,t={})=>(await W()).setLocale(e,t),it=()=>{let e=U();return typeof e?.getLocalizationState=="function"?e.getLocalizationState():{locale:v.locale,messages:{...v.messages},hasProvider:v.hasProvider}},at=(e={})=>{let t=U();if(typeof t?.createJSONLocalization=="function")return t.createJSONLocalization(e);let n=typeof e?.locale=="string"&&e.locale.trim()?e.locale.trim().toLowerCase():"en",o=Array.isArray(e?.locales)?e.locales.map(L=>String(L||"").trim().toLowerCase()).filter(Boolean):[],i=Array.from(new Set([n,...o])),r=null,d=async()=>(r||(r=W().then(L=>typeof L?.createJSONLocalization=="function"?L.createJSONLocalization(e):null).catch(()=>null)),r),S=async(L="loadLocale")=>{let p=await d();if(!p||typeof p!="object")return null;let c=p.provider;if(!c||typeof c!="object")return null;let f=c[L];return typeof f=="function"?f:L==="setLocale"&&typeof c.loadLocale=="function"?c.loadLocale:null};return{locale:n,locales:[...i],provider:{locales:[...i],async loadLocale(L={}){let p=await S("loadLocale");return typeof p!="function"?{}:p(L)},async setLocale(L={}){let p=await S("setLocale");return typeof p!="function"?{}:p(L)}}}};function B(e,t){return t&&typeof t=="string"?t:`${Q(s.currentConfig||{},{resolvePublicAssetURL:q})}core/${e}`}async function Kt(){return Array.isArray(s.defaultEnhancers)&&s.defaultEnhancers.length>0?s.defaultEnhancers:(te||(te=import(B("pds-enhancers.js",s.currentConfig?.enhancersURL)).then(t=>{let n=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return s.defaultEnhancers=n,n}).catch(t=>{throw te=null,t})),te)}async function Gt(){return typeof s.ask=="function"&&s.ask!==ct?s.ask:(X||(X=import(B("pds-ask.js",s.currentConfig?.askURL)).then(t=>{let n=t?.ask;if(typeof n!="function")throw new Error("Failed to load ask helper");return s.ask=n,n}).catch(t=>{throw X=null,t})),X)}async function H(){return typeof s.toast=="function"&&s.toast!==O?s.toast:(ee||(ee=import(B("pds-toast.js",s.currentConfig?.toastURL)).then(t=>{let n=t?.toast;if(typeof n!="function")throw new Error("Failed to load toast helper");return s.toast=n,n}).catch(t=>{throw ee=null,t})),ee)}async function ct(...e){return(await Gt())(...e)}async function O(...e){return(await H())(...e)}O.success=async(...e)=>(await H()).success(...e);O.error=async(...e)=>(await H()).error(...e);O.warning=async(...e)=>(await H()).warning(...e);O.info=async(...e)=>(await H()).info(...e);var Xe=function(e="log",t,...n){s.log(e,t,...n)};function _e(e){if(e==null)return e;if(typeof e=="function")return;if(typeof e!="object")return e;if(Array.isArray(e))return e.map(n=>_e(n)).filter(n=>n!==void 0);let t={};for(let[n,o]of Object.entries(e)){let i=_e(o);i!==void 0&&(t[n]=i)}return t}function lt(e,t=new WeakSet){if(!e||typeof e!="object"||t.has(e))return e;t.add(e),Object.freeze(e);for(let n of Object.keys(e))lt(e[n],t);return e}function ve(e){return e==null||typeof e!="object"?e:lt(structuredClone(_e(e)))}async function qt(e,t={}){if(t?.runtimeConfig===!1||typeof fetch!="function")return null;let n=t?.runtimeConfigURL||`${e}pds-runtime-config.json`;try{let o=await fetch(n,{cache:"no-store"});return o.ok?await o.json():null}catch{return null}}s.registry=$;s.enums=Ue;s.adoptLayers=ze;s.adoptPrimitives=Te;var Jt=fe;s.parse=Jt;var Ae=G;s.html=Ae;s.State=Y;s.bindState=Ze;s.createStylesheet=$e;s.isLiveMode=()=>$.isLive;s.ask=ct;s.toast=O;s.common=me;s.msg=M;s.str=ie;s.configureLocalization=re;s.loadLocale=st;s.setLocale=rt;s.getLocalizationState=it;s.createJSONLocalization=at;s.i18n={msg:M,str:ie,configure:re,loadLocale:st,setLocale:rt,getState:it,createJSONLocalization:at};s.AutoComplete=null;s.loadAutoComplete=async()=>{if(s.AutoComplete&&typeof s.AutoComplete.connect=="function")return s.AutoComplete;let e=B("pds-autocomplete.js",s.currentConfig?.autoCompleteURL);return Z||(Z=import(e).then(t=>{let n=t?.AutoComplete||t?.default?.AutoComplete||t?.default||null;if(!n)throw new Error("AutoComplete export not found in module");return s.AutoComplete=n,n}).catch(t=>{throw Z=null,t})),Z};function dt(e){let t=typeof CustomEvent=="function";try{let n=t?new CustomEvent("pds:ready",{detail:e}):new Event("pds:ready");s.dispatchEvent(n)}catch{}if(typeof document<"u")if(t){let n={detail:e,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:ready",n))}catch{}try{document.dispatchEvent(new CustomEvent("pds-ready",n))}catch{}}else{try{document.dispatchEvent(new Event("pds:ready"))}catch{}try{document.dispatchEvent(new Event("pds-ready"))}catch{}}}function ut(e={}){let t=typeof CustomEvent=="function",n={at:Date.now(),...e};try{let o=t?new CustomEvent("pds:config-changed",{detail:n}):new Event("pds:config-changed");s.dispatchEvent(o)}catch{}if(typeof document<"u")if(t){let o={detail:n,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:config-changed",o))}catch{}}else try{document.dispatchEvent(new Event("pds:config-changed"))}catch{}}var Ee="pure-ds-theme",C=null,F=null;function xe(e){try{if(typeof document>"u")return;let t="light";e?e==="system"?t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t=e:t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",document.documentElement.setAttribute("data-theme",t)}catch{}}function je(e){try{if(C&&F){try{typeof C.removeEventListener=="function"?C.removeEventListener("change",F):typeof C.removeListener=="function"&&C.removeListener(F)}catch{}C=null,F=null}if(e==="system"&&typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=o=>{let i=o?.matches===void 0?t.matches:o.matches;try{let r=i?"dark":"light";document.documentElement.setAttribute("data-theme",r),s.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:r,source:"system"}}))}catch{}};C=t,F=n,typeof t.addEventListener=="function"?t.addEventListener("change",n):typeof t.addListener=="function"&&t.addListener(n)}}catch{}}var Vt=Object.getOwnPropertyDescriptor(s,"theme");Vt||Object.defineProperty(s,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(Ee)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=s.currentConfig?.design||null,n=we(e);if(t&&!qe(t,n)){let o=t?.name||s.currentPreset?.name||s.currentConfig?.preset||"current preset";s.log("warn",`PDS theme "${n}" not supported by preset "${o}".`),s.dispatchEvent(new CustomEvent("pds:theme:blocked",{detail:{theme:e,resolvedTheme:n,preset:o}}));return}e==null?localStorage.removeItem(Ee):localStorage.setItem(Ee,e),xe(e),je(e),s.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});s.defaultEnhancers=[];async function Qt(e){s.initializing=!0;try{let t=e&&e.mode||"live",{mode:n,...o}=e||{};s.mode=t,s.logHandler=typeof o?.log=="function"?o.log:null,s.currentConfig=ve(o);let i=o&&typeof o.localization=="object"&&o.localization?o.localization:null;i?(await W(),re(i)):re(null);let r;if(t==="static")r=await Yt(o);else{let{localization:S,...L}=o||{},p=Q(L,{resolvePublicAssetURL:q}),c=L?.managerURL||L?.public?.managerURL||L?.manager?.url||new URL("core/pds-manager.js",p).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:f}=await import(c);r=await f(s,L,{emitReady:dt,emitConfigChanged:ut,applyResolvedTheme:xe,setupSystemListenerIfNeeded:je})}s.compiled=ve(r?.config||null);let d=s?.compiled?.design?.icons?.externalPath||"/assets/img/icons/";return s.log("info",`startup ready; external icon path: ${d}`),r}finally{s.initializing=!1}}s.start=Qt;async function Yt(e){if(!e||typeof e!="object")throw new Error("PDS.start({ mode: 'static', ... }) requires a valid configuration object");let t=e.applyGlobalStyles??!0,n=e.manageTheme??!0,o=e.themeStorageKey??"pure-ds-theme",i=e.staticPaths??{},r=Q(e,{resolvePublicAssetURL:q}),d=e&&e.autoDefine||null,S;d&&d.baseURL?S=J(V(d.baseURL,{preferModule:!1})):S=`${r}components/`;let L=d&&Array.isArray(d.predefine)&&d.predefine||[],p=d&&typeof d.mapper=="function"&&d.mapper||null;try{He(s);let{resolvedTheme:c}=Ke({manageTheme:n,themeStorageKey:o,applyResolvedTheme:xe,setupSystemListenerIfNeeded:je}),f=await qt(r,e),A=Array.isArray(e?.enhancers)?e.enhancers:e?.enhancers&&typeof e.enhancers=="object"?Object.values(e.enhancers):[],m=f?.config?{...f.config,...e,design:e?.design||f.config.design,preset:e?.preset||f.config.preset}:{...e},E={tokens:`${r}styles/pds-tokens.css.js`,primitives:`${r}styles/pds-primitives.css.js`,components:`${r}styles/pds-components.css.js`,utilities:`${r}styles/pds-utilities.css.js`,styles:`${r}styles/pds-styles.css.js`},j=f?.paths||{};if(i={...E,...j,...i},s.registry.setStaticMode(i),t&&typeof document<"u")try{let h=await s.registry.getStylesheet("styles");if(h){h._pds=!0;let u=(document.adoptedStyleSheets||[]).filter(y=>y._pds!==!0);document.adoptedStyleSheets=[...u,h],ut({mode:"static",source:"static:styles-applied"})}}catch(h){Xe.call(s,"warn","Failed to apply static styles:",h)}let a=null,l=[];try{let h=await Kt(),u=await Ge({autoDefineBaseURL:S,autoDefinePreload:L,autoDefineMapper:p,enhancers:A,autoDefineOverrides:d||null,autoDefinePreferModule:!(d&&d.baseURL)},{baseEnhancers:h});a=u.autoDefiner,l=u.mergedEnhancers||[]}catch(h){Xe.call(s,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",h)}return s.compiled=ve({mode:"static",...m,theme:c,enhancers:l}),dt({mode:"static",config:m,theme:c,autoDefiner:a}),{config:m,theme:c,autoDefiner:a}}catch(c){throw s.dispatchEvent(new CustomEvent("pds:error",{detail:{error:c}})),c}}var Zt=s.createJSONLocalization({locale:"en-US",locales:["en-US","nl-NL"],aliases:{en:["en-US"],nl:["nl-NL"]},basePath:"/assets/locales"}),pt={mode:"live",liveEdit:!0,preset:"default",localization:Zt,autoDefine:{predefine:["pds-icon","pds-drawer","pds-toaster"]},log(e,t,...n){(this?.mode||this?.compiled?.mode||"live")!=="static"&&(typeof console[e]=="function"?console[e]:console.log)(`[PDS] ${t}`,...n)}};var D={name:"@pure-ds/core",shortname:"pds",version:"0.7.59",description:"Why develop a Design System when you can generate one?",repository:{type:"git",url:"git+https://github.com/Pure-Web-Foundation/pure-ds.git"},bugs:{url:"https://github.com/Pure-Web-Foundation/pure-ds/issues"},homepage:"https://puredesignsystem.z6.web.core.windows.net/",keywords:["design-system","css","web-components","lit","constructable-stylesheets","tokens","utilities","a11y"],type:"module",main:"./public/assets/pds/core.js",module:"./public/assets/pds/core.js",types:"./dist/types/pds.d.ts",bin:{"pds-build":"packages/pds-cli/bin/pds-static.js","pds-sync-assets":"packages/pds-cli/bin/sync-assets.js","pds-build-icons":"packages/pds-cli/bin/pds-build-icons.js","pds-import":"packages/pds-cli/bin/pds-import.js","pds-setup-copilot":"packages/pds-cli/bin/pds-setup-copilot.js","pds-setup-mcp":"packages/pds-cli/bin/pds-setup-mcp.js","pds-init-config":"packages/pds-cli/bin/pds-init-config.js","pds-bootstrap":"packages/pds-cli/bin/pds-bootstrap.js","pds-mcp-server":"packages/pds-cli/bin/pds-mcp-server.js","pds-mcp-health":"packages/pds-cli/bin/pds-mcp-health.js","pds-mcp-eval":"packages/pds-cli/bin/pds-mcp-eval.js"},exports:{".":{types:"./src/js/pds.d.ts",import:"./public/assets/pds/core.js"},"./localization":{types:"./dist/types/src/js/pds-localization.d.ts",import:"./public/assets/pds/core/pds-localization.js"},"./lit":{types:"./dist/types/src/js/lit.d.ts",import:"./public/assets/pds/external/lit.js"},"./pds-core":"./src/js/pds.js","./auto-define/*":"./public/auto-define/*"},files:[".github/copilot-instructions.md",".cursorrules","dist/types/","public/assets/js/","public/assets/pds/components/","public/assets/pds/templates/","public/assets/pds/core.js","public/assets/pds/core/","public/assets/pds/external/","public/assets/pds/vscode-custom-data.json","public/assets/pds/pds.css-data.json","public/assets/pds/pds-css-complete.json","public/auto-define/","public/pds/components/","public/assets/pds/icons/pds-icons.svg","packages/pds-cli/bin/","packages/pds-cli/lib/","src/js/pds.d.ts","src/js/pds.js","src/js/pds-singleton.js","src/js/common/","src/js/pds-live-manager/","src/js/pds-core/","custom-elements.json","custom-elements-manifest.config.js","pds.html-data.json","pds.css-data.json","LOCALIZATION.md","readme.md","INTELLISENSE.md","CSS-INTELLISENSE-LIMITATION.md","CSS-INTELLISENSE-QUICK-REF.md"],scripts:{dev:"node esbuild-dev.js",prebuild:"npm run types",build:"node esbuild-build.js",types:"tsc -p tsconfig.json && node scripts/sync-types.mjs",postinstall:"node packages/pds-cli/bin/postinstall.mjs","prepds:build":"npm run types","pds:build":"node packages/pds-cli/bin/pds-static.js","pds:build-icons":"node packages/pds-cli/bin/pds-build-icons.js","pds:bootstrap":"node packages/pds-cli/bin/pds-bootstrap.js","pds:manifest":"node packages/pds-cli/bin/generate-manifest.js","pds:css-data":"node packages/pds-cli/bin/generate-css-data.js","pds:import":"node packages/pds-cli/bin/pds-import.js","pds:dx":"node packages/pds-cli/bin/pds-dx.js","pds:mcp:server":"node packages/pds-cli/bin/pds-mcp-server.js","pds:mcp:health":"node packages/pds-cli/bin/pds-mcp-health.js","pds:mcp:eval":"node packages/pds-cli/bin/pds-mcp-eval.js","storybook:generate":"cd packages/pds-storybook && npm run generate-stories","storybook:dev":"cd packages/pds-storybook && npm run storybook:dev","storybook:build":"cd packages/pds-storybook && npm run storybook:build"},author:"Marc van Neerven",license:"ISC",engines:{node:">=18"},publishConfig:{access:"public"},devDependencies:{"@custom-elements-manifest/analyzer":"^0.9.9","@types/node":"^22.10.2",esbuild:"^0.19.0","fs-extra":"^11.1.1",typescript:"^5.6.3"},dependencies:{lit:"^3.3.2","pure-web":"1.1.32"},customElements:"custom-elements.json"};await s.start(pt);document.documentElement.lang="en";var ft=typeof D.repository=="string"?D.repository:D.repository?.url,en=ft?ft.replace(/^git\+/,"").replace(/\.git$/,""):"",Tn=D.homepage||en,zn=D.bugs?.url||"";document.body.appendChild(Ae`
|
|
4
4
|
<div class="container text-center">
|
|
5
5
|
<img src="/assets/img/pds-logo.svg" alt="PDS Logo" title="${M("PDS Logo")}" width="64" height="64" />
|
|
6
6
|
<header class="container section">
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function A(a){let t=Array.isArray(a?.strings)?a.strings:[],e=Array.isArray(a?.values)?a.values:[],s=new Set,r=[],n=/(\s)(\.[\w-]+)=["']?\s*$/,i=/(\s)(@[\w-]+)=["']?\s*$/,l=/(\s)(\?[\w-]+)=["']?\s*$/,h=/(\s)([\w:-]+)=["']?\s*$/,f=/=["']\s*$/,g=!1;for(let o=0;o<t.length;o+=1){let u=t[o]??"";if(g&&(u=u.replace(/^["']/,""),g=!1),o<e.length){let m=`pds-val-${o}`,x=u.match(n),y=u.match(i),
|
|
2
|
-
`)!==-1||a.indexOf(" ")!==-1||a.startsWith("#/"))return!1;let t=new URL(a,window.location.origin);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function P(a,t,e="Operation"){return!t||t<=0?a:new Promise((s,r)=>{let n=setTimeout(()=>{r(new Error(`${e} timed out after ${t}ms`))},t);Promise.resolve(a).then(i=>{clearTimeout(n),s(i)}).catch(i=>{clearTimeout(n),r(i)})})}function H(a){return String(a).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function L(a,t,e){let s=window.screen.width/2-t/2,r=window.screen.height/2-e/2;return window.open(a,"",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=${t}, height=${e}, top=${r}, left=${s}`)}function M(a){if(a==null)return"";let t=String(a).trim();return t?t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim():""}var E={result:"ac-suggestion",item:"ac-itm"},O=class a extends EventTarget{constructor(t,e,s={}){super(),this.settings={emptyResultsText:"",progressive:!
|
|
1
|
+
function A(a){let t=Array.isArray(a?.strings)?a.strings:[],e=Array.isArray(a?.values)?a.values:[],s=new Set,r=[],n=/(\s)(\.[\w-]+)=["']?\s*$/,i=/(\s)(@[\w-]+)=["']?\s*$/,l=/(\s)(\?[\w-]+)=["']?\s*$/,h=/(\s)([\w:-]+)=["']?\s*$/,f=/=["']\s*$/,g=!1;for(let o=0;o<t.length;o+=1){let u=t[o]??"";if(g&&(u=u.replace(/^["']/,""),g=!1),o<e.length){let m=`pds-val-${o}`,x=u.match(n),y=u.match(i),b=u.match(l),C=u.match(h);if(x){let w=x[2].slice(1);g=f.test(t[o]??""),u=u.replace(n,`$1data-pds-bind-${o}="prop:${w}:${m}"`),s.add(o)}else if(y){let w=y[2].slice(1);g=f.test(t[o]??""),u=u.replace(i,`$1data-pds-bind-${o}="event:${w}:${m}"`),s.add(o)}else if(b){let w=b[2].slice(1);g=f.test(t[o]??""),u=u.replace(l,`$1data-pds-bind-${o}="boolean:${w}:${m}"`),s.add(o)}else if(C){let w=C[2];g=f.test(t[o]??""),u=u.replace(h,`$1data-pds-bind-${o}="attr:${w}:${m}"`),s.add(o)}}r.push(u),o<e.length&&!s.has(o)&&r.push(`<!--pds-val-${o}-->`)}let p=document.createElement("template");p.innerHTML=r.join("");let c=(o,u)=>{let m=o.parentNode;if(!m)return;if(u==null){m.removeChild(o);return}let x=y=>{if(y!=null){if(y instanceof Node){m.insertBefore(y,o);return}if(Array.isArray(y)){y.forEach(b=>x(b));return}m.insertBefore(document.createTextNode(String(y)),o)}};x(u),m.removeChild(o)},d=document.createTreeWalker(p.content,NodeFilter.SHOW_COMMENT),v=[];for(;d.nextNode();){let o=d.currentNode;o?.nodeValue?.startsWith("pds-val-")&&v.push(o)}return v.forEach(o=>{let u=Number(o.nodeValue.replace("pds-val-",""));c(o,e[u])}),p.content.querySelectorAll("*").forEach(o=>{[...o.attributes].forEach(u=>{if(!u.name.startsWith("data-pds-bind-"))return;let m=u.value.indexOf(":"),x=u.value.lastIndexOf(":");if(m<=0||x<=m){o.removeAttribute(u.name);return}let y=u.value.slice(0,m),b=u.value.slice(m+1,x),C=u.value.slice(x+1),w=Number(String(C).replace("pds-val-","")),$=e[w];if(!b||!Number.isInteger(w)){o.removeAttribute(u.name);return}y==="prop"?o[b]=$:y==="event"?(typeof $=="function"||$&&typeof $.handleEvent=="function")&&o.addEventListener(b,$):y==="boolean"?$?o.setAttribute(b,""):o.removeAttribute(b):y==="attr"&&($==null||$===!1?o.removeAttribute(b):o.setAttribute(b,String($))),o.removeAttribute(u.name)})}),p.content}function N(a,...t){if(Array.isArray(a)&&Object.prototype.hasOwnProperty.call(a,"raw"))return A({strings:Array.from(a),values:t});if(Array.isArray(a?.strings)&&Array.isArray(a?.values))return A({strings:a.strings,values:a.values});let s=document.createElement("template");return s.innerHTML=String(a??""),s.content}function S(a,...t){return N(a,...t).childNodes}function D(a,t=100){let e;return function(...r){let n=()=>{clearTimeout(e),a(...r)};clearTimeout(e),e=setTimeout(n,t)}}function I(a){setTimeout(a,0)}function k(a){try{if(typeof a!="string"||a.indexOf(`
|
|
2
|
+
`)!==-1||a.indexOf(" ")!==-1||a.startsWith("#/"))return!1;let t=new URL(a,window.location.origin);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function P(a,t,e="Operation"){return!t||t<=0?a:new Promise((s,r)=>{let n=setTimeout(()=>{r(new Error(`${e} timed out after ${t}ms`))},t);Promise.resolve(a).then(i=>{clearTimeout(n),s(i)}).catch(i=>{clearTimeout(n),r(i)})})}function H(a){return String(a).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function L(a,t,e){let s=window.screen.width/2-t/2,r=window.screen.height/2-e/2;return window.open(a,"",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=${t}, height=${e}, top=${r}, left=${s}`)}function M(a){if(a==null)return"";let t=String(a).trim();return t?t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim():""}var E={result:"ac-suggestion",item:"ac-itm"},O=class a extends EventTarget{constructor(t,e,s={}){super(),this.settings={emptyResultsText:"",progressive:!0,maxConcurrentCategories:3,categoryTimeoutMs:0,...s},this.container=t,this.input=e,this.input.setAttribute("autocomplete","off"),this.categories=s.categories||{},this.caches=new Map,this.rowIndex=-1,this.results=[],this.requestToken=0,I(this.attach.bind(this))}static connect(t,e){let s=t.target;if(!s._autoComplete){if(!e?.categories)throw Error("Missing autocomplete settings");s._autoComplete=new a(s.parentNode,s,e),t.type==="focus"&&setTimeout(()=>{s._autoComplete.focusHandler(t)},100)}return s._autoComplete}on(t,e){return this.input.addEventListener(t,e),this}attach(){this.resultsDiv=document.createElement("div"),this.resultsDiv.title="",this.resultsDiv.classList.add(E.result),this.container.offsetWidth>100&&(this.resultsDiv.style.width=`${this.container.offsetWidth}px`),this.resultsDiv.addEventListener("mousedown",this.resultClick.bind(this)),this.container.classList.add("ac-container"),this.input.classList.add("ac-input");let t=getComputedStyle(this.input);this.container.style.setProperty("--ac-bg-default",t.backgroundColor),this.container.style.setProperty("--ac-color-default",t.color);let e=t.accentColor;e!=="auto"&&this.container.style.setProperty("--ac-accent-color",e),(this.container?.shadowRoot??this.container).appendChild(this.resultsDiv),this.controller().clear("attach"),this.on("input",D(this.inputHandler.bind(this),this.settings.throttleInputMs??300)).on("focus",this.focusHandler.bind(this)).on("focusout",this.blurHandler.bind(this)).on("keyup",this.keyUpHandler.bind(this)).on("keydown",this.keyDownHandler.bind(this))}controller(){let t=this.internalController();return typeof this.settings.controller=="function"&&(t=this.settings.controller(this)??t),t}internalController(){return{show:this.show.bind(this),hide:this.hide.bind(this),clear:this.clear.bind(this),empty:()=>{}}}moveResult(t){this.controller().show();let e=this.acItems?.length??0;if(!e)return;this.rowIndex=this.rowIndex+t,this.rowIndex<=0?this.rowIndex=0:this.rowIndex>e-1&&(this.rowIndex=0);for(let r of this.acItems)r.classList.remove("selected");let s=this.getSelectedDiv();s?(s.classList.add("selected"),s.scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"})):this.focusHandler({target:this.input})}getSelectedDiv(){return this.resultsDiv?.querySelector(`div:nth-child(${this.rowIndex+1})`)}selectResult(t){let e=t||this.getSelectedDiv();if(!e)return;let s=Number.parseInt(e.getAttribute("data-index"),10);this.resultClicked=!0;let r=Number.isInteger(s)?this.results[s]:null;if(!r)return;let n=this.categories[r.category]??{},i=typeof n.action=="function"?n.action:this.setText.bind(this);n.newTab&&(this.tabWindow=L("about:blank",960,700));let l={...r,search:this.input.value,selectedItem:e};e.classList.add("ac-active"),setTimeout(()=>{this.controller().hide("result-selected"),typeof l.action=="function"?l.action(l):(i(l),n.newTab&&this.tabWindow&&(l.url?this.tabWindow.location.href=l.url:this.tabWindow.close())),this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.controller().clear("result-selected");let h=new Event("result-selected");h.detail=l,this.input.dispatchEvent(h)},0)}setText(t){let e=!1;this.input?(this.input.value=t.text,e=!0):this.container?.autoCompleteInput?(this.container.autoCompleteInput.value=t.text,e=!0):"value"in this.container&&(this.container.value=t.text,e=!0),e&&this.input&&this.input.dispatchEvent(new Event("input",{bubbles:!0})),this.controller().hide("settext")}resultClick(t){this.selectResult(t.target.closest(`.${E.item}`))}blurHandler(){setTimeout(()=>{this.resultClicked||this.controller().clear("blurred"),this.resultClicked=!1},100)}clear(t,e={}){this.settings.debug||this.resultsDiv&&(this.resultsDiv.innerHTML="",e.preserveOpen||this.controller().hide("clear"),this.cacheTmr&&clearTimeout(this.cacheTmr),this.cacheTmr=setTimeout(()=>{this.caches.clear()},5*60*1e3))}show(){if(!this.resultsDiv.classList.contains("ac-active")){let t=this.getViewBounds();this.resultsDiv.style.position="absolute",t.rect.width>100&&(this.resultsDiv.style.width=`${t.rect.width}px`),this.settings.direction=this.settings.direction??t.suggestedDirection,this.resultsDiv.setAttribute("data-direction",this.settings.direction),this.settings.direction==="up"?(this.resultsDiv.style.top="unset",this.resultsDiv.style.bottom=`${t.rect.height+20}px`,this.rowIndex=this.acItems.length):(this.resultsDiv.style.bottom="unset",this.resultsDiv.style.top=`${t.rect.height}px`,this.rowIndex=-1),this.resultsDiv.style.maxWidth="unset",this.resultsDiv.classList.toggle("ac-active",!0)}}getViewBounds(){let t=this.input.getBoundingClientRect();return{rect:t,suggestedDirection:t.top+t.height+500>window.innerHeight?"up":"down"}}hide(){this.resultsDiv.classList.toggle("ac-active",!1)}empty(){this.resultsDiv.innerHTML=`<div class="ac-empty">${this.settings.emptyResultsText}</div>`,this.controller().show()}async inputHandler(t){this.cacheTmr&&clearTimeout(this.cacheTmr);let e={search:t.target.value,categories:this.categories},s=this.requestToken+1,r=this.settings.progressive===!0,n="",i=!1;this.container.classList.add("search-running");let l=(g,p={})=>{!r||p.token!==this.requestToken||(i=!0,n=this.resultsSignature(g),this.resultsHandler(g,e),this.input.dispatchEvent(new CustomEvent("results:partial",{detail:{results:g,token:p.token,pending:p.pending??0,completed:p.completed??0,settled:p.settled??!1}})))},h=await this.getItems(e,t,{onProgress:l,forceToken:s}).catch(()=>[]);if(s!==this.requestToken){this.container.classList.remove("search-running");return}let f=this.resultsSignature(h);(!i||f!==n)&&this.resultsHandler(h,e),this.input.dispatchEvent(new CustomEvent("results:complete",{detail:{results:h,token:s,pending:0,completed:Object.keys(this.categories||{}).length,settled:!0}})),this.container.classList.remove("search-running")}keyDownHandler(t){switch(t.key){case"Enter":t.stopPropagation(),t.preventDefault();break;case"ArrowDown":I(()=>this.moveResult(1));break;case"ArrowUp":I(()=>this.moveResult(-1));break;default:break}}keyUpHandler(t){switch(t.key){case"Escape":this.controller().hide("escape");break;case"Enter":this.getSelectedDiv()&&(this.container.preventEnter=!0,t.stopPropagation(),t.preventDefault(),this.selectResult(),setTimeout(()=>{this.container.preventEnter=!1},10));break;default:break}}focusHandler(t){this.controller().clear("focus"),this.suggest(t.target.value,t)}suggest(t,e){this.input.focus();let s={suggest:!0,search:t||"",categories:this.categories};this.getItems(s,e).then(r=>{this.input.dispatchEvent(new CustomEvent("show-results",{detail:{results:r}})),this.resultsHandler(r,s)})}sort(t,e){return t.sort((s,r)=>{let n=e.categories[s.category],i=e.categories[r.category],l=typeof n.sortIndex=="function"?n.sortIndex(e):n.sortIndex??0;return(typeof i.sortIndex=="function"?i.sortIndex(e):i.sortIndex??0)>l?1:-1})}resultsHandler(t,e){this.results=t,this.rowIndex=-1,this.resultsDiv.innerHTML="";let s=0,r=(n,i)=>{let l=this.formatCategoryLabel(i.category);return`
|
|
3
3
|
<div title="${i.tooltip||""}" data-index="${s}" class="${`${E.item} cat-${i.category} ${i.class??""}`.trim()}"${i.style?` style="${i.style}"`:""}>
|
|
4
4
|
${this.handleImageOrIcon(i)}
|
|
5
5
|
<span class="text">${this.formatResultItem(i,e,n)}</span>
|
|
6
6
|
${this.settings.hideCategory?"":`<span class="category">${l}</span>`}
|
|
7
|
-
</div>`};t.forEach(n=>{let i=e.categories[n.category]||{};if(n.element)this.resultsDiv.appendChild(n.element);else{let h=S(r(i,typeof n=="string"?{text:n}:n)),f=Array.from(h).find(g=>g&&g.nodeType===Node.ELEMENT_NODE);f&&this.resultsDiv.appendChild(f)}s+=1}),t.length?(this.acItems=this.resultsDiv.querySelectorAll(".ac-itm"),this.controller().show()):e.search.length&&this.controller().empty()}handleImageOrIcon(t){return t.image?`<img src="${t.image}"/>`:typeof this.settings.iconHandler=="function"?this.settings.iconHandler(t):`<svg-icon icon="${t.icon}"></svg-icon>`}formatResultItem(t,e,s){let r=typeof t=="string"?{text:t}:t,n=r.text;return e.search&&(n=n.replace("%search%",e.search),r.description=r.description?.replace("%search%",e.search)),n=this.highlight(n,e.search),r.description&&(n=`<div>${n}</div><small>${r.description}</small>`),s.format&&(n=s.format({item:r,result:n,options:e})),n}formatCategoryLabel(t){return this.settings.humanizeCategoryLabels===!1?t||"":M(t||"")}highlight(t,e){if(!e)return t;try{let s=new RegExp(`(${H(e)})`,"gi");return t.replace(s,'<span class="txt-hl">$1</span>')}catch{return t}}resultsSignature(t){return!Array.isArray(t)||t.length===0?"":t.map(e=>!e||typeof e!="object"?String(e):`${e.category??""}|${e.id??""}|${e.value??""}|${e.text??""}`).join("||")}getCacheKey(t){let e=this.settings.locale||document?.documentElement?.lang||navigator?.language||"",s=String(t?.search??"").trim().toLowerCase(),r=Object.keys(t?.categories||{}).join(",");return`${e}::${s}::${r}`}async getItems(t,e,s={}){this.aborter&&this.aborter.abort();let r=s.forceToken||this.requestToken+1;this.requestToken=r;let n=this.getCacheKey(t);if(this.settings.cache!==!1&&this.caches.has(n)){let c=this.caches.get(n);return typeof s.onProgress=="function"&&s.onProgress(c,{token:r,pending:0,completed:Object.keys(t.categories||{}).length,settled:!0}),c}this.aborter=new AbortController,this.aborterSignal=this.aborter.signal;let i=this.items,l=this.settings.map,h=c=>typeof c=="string"?{text:c}:c,f=c=>l?c.map(d=>({text:d[l]})):c.map(d=>h(d)),g=c=>(this.settings.max&&this.settings.max>0&&(c.length=this.settings.max),c),p=c=>{let d=this.sort(c,t);return this.settings.cache!==!1&&this.caches.set(n,d),d};if(k(i)){if(this.settings.minlength>0&&(!t.search||t.search.length<this.settings.minlength))return p([]);let c=this.formatSearch(i,t),d=await fetch(c,{signal:this.aborterSignal});if(d.status!==200)throw Error(`HTTP error ${d.status} - ${c}`);let T=f(await d.json()).filter(o=>this.isMatch(t,o));return p(g(T))}if(Array.isArray(i)){let c=!0;return this.items=i.map(d=>typeof d=="string"?{text:d}:(c=!1,d)),c&&this.container.classList.add("simple"),p(g(f(this.items)))}if(typeof i=="function"){t.control=this.container;let c=this.settings.progressive===!0,d=await this.items(t,e,{progressive:c,token:r,onProgress:s.onProgress});return p(f(d))}return Promise.resolve(i.apply(this,t)).then(c=>p(c))}async runCategorySearch(t,e,s){let r=Number(this.settings.categoryTimeoutMs||0),n={...t,signal:this.aborterSignal};try{let i=await P(Promise.resolve(s.getItems(n)),r,`Category "${e}"`);return(Array.isArray(i)?i:[]).map(h=>{let f=typeof h=="string"?{text:h}:h;return f.category=e,f})}catch(i){return console.warn(`Error loading items for omniBox category '${e}'.`,i),[]}}async runCategoriesSequentially(t,e,s={}){let r=[],n=0;for(let[i,l]of e){let h=l||{};if(h.trigger=h.trigger??(()=>!0),h.getItems=h.getItems??(()=>[]),t.results=r,!h.trigger(t)){n+=1;continue}let f=await this.runCategorySearch(t,i,h);if(this.aborterSignal?.aborted)return r;if(r=r.concat(f),n+=1,typeof s.onProgress=="function"&&this.requestToken===s.token){let g=this.sort([...r],t);s.onProgress(g,{token:s.token,pending:Math.max(0,e.length-n),completed:n,settled:n===e.length})}}return r}async runCategoriesProgressive(t,e,s={}){let r=Math.max(1,Number(this.settings.maxConcurrentCategories||3)),n=[];for(let[c,d]of e){let
|
|
7
|
+
</div>`};t.forEach(n=>{let i=e.categories[n.category]||{};if(n.element)this.resultsDiv.appendChild(n.element);else{let h=S(r(i,typeof n=="string"?{text:n}:n)),f=Array.from(h).find(g=>g&&g.nodeType===Node.ELEMENT_NODE);f&&this.resultsDiv.appendChild(f)}s+=1}),t.length?(this.acItems=this.resultsDiv.querySelectorAll(".ac-itm"),this.controller().show()):e.search.length&&this.controller().empty()}handleImageOrIcon(t){return t.image?`<img src="${t.image}"/>`:typeof this.settings.iconHandler=="function"?this.settings.iconHandler(t):`<svg-icon icon="${t.icon}"></svg-icon>`}formatResultItem(t,e,s){let r=typeof t=="string"?{text:t}:t,n=r.text;return e.search&&(n=n.replace("%search%",e.search),r.description=r.description?.replace("%search%",e.search)),n=this.highlight(n,e.search),r.description&&(n=`<div>${n}</div><small>${r.description}</small>`),s.format&&(n=s.format({item:r,result:n,options:e})),n}formatCategoryLabel(t){return this.settings.humanizeCategoryLabels===!1?t||"":M(t||"")}highlight(t,e){if(!e)return t;try{let s=new RegExp(`(${H(e)})`,"gi");return t.replace(s,'<span class="txt-hl">$1</span>')}catch{return t}}resultsSignature(t){return!Array.isArray(t)||t.length===0?"":t.map(e=>!e||typeof e!="object"?String(e):`${e.category??""}|${e.id??""}|${e.value??""}|${e.text??""}`).join("||")}getCacheKey(t){let e=this.settings.locale||document?.documentElement?.lang||navigator?.language||"",s=String(t?.search??"").trim().toLowerCase(),r=Object.keys(t?.categories||{}).join(",");return`${e}::${s}::${r}`}async getItems(t,e,s={}){this.aborter&&this.aborter.abort();let r=s.forceToken||this.requestToken+1;this.requestToken=r;let n=this.getCacheKey(t);if(this.settings.cache!==!1&&this.caches.has(n)){let c=this.caches.get(n);return typeof s.onProgress=="function"&&s.onProgress(c,{token:r,pending:0,completed:Object.keys(t.categories||{}).length,settled:!0}),c}this.aborter=new AbortController,this.aborterSignal=this.aborter.signal;let i=this.items,l=this.settings.map,h=c=>typeof c=="string"?{text:c}:c,f=c=>l?c.map(d=>({text:d[l]})):c.map(d=>h(d)),g=c=>(this.settings.max&&this.settings.max>0&&(c.length=this.settings.max),c),p=c=>{let d=this.sort(c,t);return this.settings.cache!==!1&&this.caches.set(n,d),d};if(k(i)){if(this.settings.minlength>0&&(!t.search||t.search.length<this.settings.minlength))return p([]);let c=this.formatSearch(i,t),d=await fetch(c,{signal:this.aborterSignal});if(d.status!==200)throw Error(`HTTP error ${d.status} - ${c}`);let T=f(await d.json()).filter(o=>this.isMatch(t,o));return p(g(T))}if(Array.isArray(i)){let c=!0;return this.items=i.map(d=>typeof d=="string"?{text:d}:(c=!1,d)),c&&this.container.classList.add("simple"),p(g(f(this.items)))}if(typeof i=="function"){t.control=this.container;let c=this.settings.progressive===!0,d=await this.items(t,e,{progressive:c,token:r,onProgress:s.onProgress});return p(f(d))}return Promise.resolve(i.apply(this,t)).then(c=>p(c))}async runCategorySearch(t,e,s){let r=Number(this.settings.categoryTimeoutMs||0),n={...t,signal:this.aborterSignal};try{let i=await P(Promise.resolve(s.getItems(n)),r,`Category "${e}"`);return(Array.isArray(i)?i:[]).map(h=>{let f=typeof h=="string"?{text:h}:h;return f.category=e,f})}catch(i){return console.warn(`Error loading items for omniBox category '${e}'.`,i),[]}}async runCategoriesSequentially(t,e,s={}){let r=[],n=0;for(let[i,l]of e){let h=l||{};if(h.trigger=h.trigger??(()=>!0),h.getItems=h.getItems??(()=>[]),t.results=r,!h.trigger(t)){n+=1;continue}let f=await this.runCategorySearch(t,i,h);if(this.aborterSignal?.aborted)return r;if(r=r.concat(f),n+=1,typeof s.onProgress=="function"&&this.requestToken===s.token){let g=this.sort([...r],t);s.onProgress(g,{token:s.token,pending:Math.max(0,e.length-n),completed:n,settled:n===e.length})}}return r}async runCategoriesProgressive(t,e,s={}){let r=Math.max(1,Number(this.settings.maxConcurrentCategories||3)),n=[];for(let[c,d]of e){let v=d||{};v.trigger=v.trigger??(()=>!0),v.getItems=v.getItems??(()=>[]),t.results=[],v.trigger(t)&&n.push([c,v])}if(!n.length)return[];let i=0,l=0,h=[],f=async()=>{for(;i<n.length;){let c=i;i+=1;let[d,v]=n[c],T=await this.runCategorySearch(t,d,v);if(this.aborterSignal?.aborted)return;if(h.push(...T),l+=1,typeof s.onProgress=="function"&&this.requestToken===s.token){let o=this.sort([...h],t);s.onProgress(o,{token:s.token,pending:Math.max(0,n.length-l),completed:l,settled:l===n.length})}}},g=[],p=Math.min(r,n.length);for(let c=0;c<p;c+=1)g.push(f());return await Promise.all(g),h}async items(t,e,s={}){t.results=[],t.signal=this.aborterSignal;let r=Object.entries(t.categories||{});return r.length?s.progressive?this.runCategoriesProgressive(t,r,s):this.runCategoriesSequentially(t,r,s):[]}formatSearch(t,e){return t.indexOf("%search%")?t.replace("%search%",e.search||""):`${t}?${this.createQueryParam(e)}`}createQueryParam(t){let e=t.suggest?"&suggest=true":"";return`q=${t.text}${e}`}isMatch(t,e){return e.text?.indexOf("%search%")>=0?!0:t.search?e.text?.toLowerCase().indexOf(t.search.toLowerCase())>=0:t.suggest}static textFilter(t,e){return function(r){if(!t.search)return!0;if(r.hidden)return!1;let i=(e?r[e]:r).match(new RegExp(t.search,"gi"));return i||(r.config?.tags?r.config.tags.some(l=>l.match(new RegExp(t.search,"gi"))):!1)}}};export{O as AutoComplete};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function A(a){let t=Array.isArray(a?.strings)?a.strings:[],e=Array.isArray(a?.values)?a.values:[],s=new Set,r=[],n=/(\s)(\.[\w-]+)=["']?\s*$/,i=/(\s)(@[\w-]+)=["']?\s*$/,l=/(\s)(\?[\w-]+)=["']?\s*$/,h=/(\s)([\w:-]+)=["']?\s*$/,f=/=["']\s*$/,g=!1;for(let o=0;o<t.length;o+=1){let u=t[o]??"";if(g&&(u=u.replace(/^["']/,""),g=!1),o<e.length){let m=`pds-val-${o}`,x=u.match(n),y=u.match(i),
|
|
2
|
-
`)!==-1||a.indexOf(" ")!==-1||a.startsWith("#/"))return!1;let t=new URL(a,window.location.origin);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function P(a,t,e="Operation"){return!t||t<=0?a:new Promise((s,r)=>{let n=setTimeout(()=>{r(new Error(`${e} timed out after ${t}ms`))},t);Promise.resolve(a).then(i=>{clearTimeout(n),s(i)}).catch(i=>{clearTimeout(n),r(i)})})}function H(a){return String(a).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function L(a,t,e){let s=window.screen.width/2-t/2,r=window.screen.height/2-e/2;return window.open(a,"",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=${t}, height=${e}, top=${r}, left=${s}`)}function M(a){if(a==null)return"";let t=String(a).trim();return t?t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim():""}var E={result:"ac-suggestion",item:"ac-itm"},O=class a extends EventTarget{constructor(t,e,s={}){super(),this.settings={emptyResultsText:"",progressive:!
|
|
1
|
+
function A(a){let t=Array.isArray(a?.strings)?a.strings:[],e=Array.isArray(a?.values)?a.values:[],s=new Set,r=[],n=/(\s)(\.[\w-]+)=["']?\s*$/,i=/(\s)(@[\w-]+)=["']?\s*$/,l=/(\s)(\?[\w-]+)=["']?\s*$/,h=/(\s)([\w:-]+)=["']?\s*$/,f=/=["']\s*$/,g=!1;for(let o=0;o<t.length;o+=1){let u=t[o]??"";if(g&&(u=u.replace(/^["']/,""),g=!1),o<e.length){let m=`pds-val-${o}`,x=u.match(n),y=u.match(i),b=u.match(l),C=u.match(h);if(x){let w=x[2].slice(1);g=f.test(t[o]??""),u=u.replace(n,`$1data-pds-bind-${o}="prop:${w}:${m}"`),s.add(o)}else if(y){let w=y[2].slice(1);g=f.test(t[o]??""),u=u.replace(i,`$1data-pds-bind-${o}="event:${w}:${m}"`),s.add(o)}else if(b){let w=b[2].slice(1);g=f.test(t[o]??""),u=u.replace(l,`$1data-pds-bind-${o}="boolean:${w}:${m}"`),s.add(o)}else if(C){let w=C[2];g=f.test(t[o]??""),u=u.replace(h,`$1data-pds-bind-${o}="attr:${w}:${m}"`),s.add(o)}}r.push(u),o<e.length&&!s.has(o)&&r.push(`<!--pds-val-${o}-->`)}let p=document.createElement("template");p.innerHTML=r.join("");let c=(o,u)=>{let m=o.parentNode;if(!m)return;if(u==null){m.removeChild(o);return}let x=y=>{if(y!=null){if(y instanceof Node){m.insertBefore(y,o);return}if(Array.isArray(y)){y.forEach(b=>x(b));return}m.insertBefore(document.createTextNode(String(y)),o)}};x(u),m.removeChild(o)},d=document.createTreeWalker(p.content,NodeFilter.SHOW_COMMENT),v=[];for(;d.nextNode();){let o=d.currentNode;o?.nodeValue?.startsWith("pds-val-")&&v.push(o)}return v.forEach(o=>{let u=Number(o.nodeValue.replace("pds-val-",""));c(o,e[u])}),p.content.querySelectorAll("*").forEach(o=>{[...o.attributes].forEach(u=>{if(!u.name.startsWith("data-pds-bind-"))return;let m=u.value.indexOf(":"),x=u.value.lastIndexOf(":");if(m<=0||x<=m){o.removeAttribute(u.name);return}let y=u.value.slice(0,m),b=u.value.slice(m+1,x),C=u.value.slice(x+1),w=Number(String(C).replace("pds-val-","")),$=e[w];if(!b||!Number.isInteger(w)){o.removeAttribute(u.name);return}y==="prop"?o[b]=$:y==="event"?(typeof $=="function"||$&&typeof $.handleEvent=="function")&&o.addEventListener(b,$):y==="boolean"?$?o.setAttribute(b,""):o.removeAttribute(b):y==="attr"&&($==null||$===!1?o.removeAttribute(b):o.setAttribute(b,String($))),o.removeAttribute(u.name)})}),p.content}function N(a,...t){if(Array.isArray(a)&&Object.prototype.hasOwnProperty.call(a,"raw"))return A({strings:Array.from(a),values:t});if(Array.isArray(a?.strings)&&Array.isArray(a?.values))return A({strings:a.strings,values:a.values});let s=document.createElement("template");return s.innerHTML=String(a??""),s.content}function S(a,...t){return N(a,...t).childNodes}function D(a,t=100){let e;return function(...r){let n=()=>{clearTimeout(e),a(...r)};clearTimeout(e),e=setTimeout(n,t)}}function I(a){setTimeout(a,0)}function k(a){try{if(typeof a!="string"||a.indexOf(`
|
|
2
|
+
`)!==-1||a.indexOf(" ")!==-1||a.startsWith("#/"))return!1;let t=new URL(a,window.location.origin);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function P(a,t,e="Operation"){return!t||t<=0?a:new Promise((s,r)=>{let n=setTimeout(()=>{r(new Error(`${e} timed out after ${t}ms`))},t);Promise.resolve(a).then(i=>{clearTimeout(n),s(i)}).catch(i=>{clearTimeout(n),r(i)})})}function H(a){return String(a).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function L(a,t,e){let s=window.screen.width/2-t/2,r=window.screen.height/2-e/2;return window.open(a,"",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=${t}, height=${e}, top=${r}, left=${s}`)}function M(a){if(a==null)return"";let t=String(a).trim();return t?t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim():""}var E={result:"ac-suggestion",item:"ac-itm"},O=class a extends EventTarget{constructor(t,e,s={}){super(),this.settings={emptyResultsText:"",progressive:!0,maxConcurrentCategories:3,categoryTimeoutMs:0,...s},this.container=t,this.input=e,this.input.setAttribute("autocomplete","off"),this.categories=s.categories||{},this.caches=new Map,this.rowIndex=-1,this.results=[],this.requestToken=0,I(this.attach.bind(this))}static connect(t,e){let s=t.target;if(!s._autoComplete){if(!e?.categories)throw Error("Missing autocomplete settings");s._autoComplete=new a(s.parentNode,s,e),t.type==="focus"&&setTimeout(()=>{s._autoComplete.focusHandler(t)},100)}return s._autoComplete}on(t,e){return this.input.addEventListener(t,e),this}attach(){this.resultsDiv=document.createElement("div"),this.resultsDiv.title="",this.resultsDiv.classList.add(E.result),this.container.offsetWidth>100&&(this.resultsDiv.style.width=`${this.container.offsetWidth}px`),this.resultsDiv.addEventListener("mousedown",this.resultClick.bind(this)),this.container.classList.add("ac-container"),this.input.classList.add("ac-input");let t=getComputedStyle(this.input);this.container.style.setProperty("--ac-bg-default",t.backgroundColor),this.container.style.setProperty("--ac-color-default",t.color);let e=t.accentColor;e!=="auto"&&this.container.style.setProperty("--ac-accent-color",e),(this.container?.shadowRoot??this.container).appendChild(this.resultsDiv),this.controller().clear("attach"),this.on("input",D(this.inputHandler.bind(this),this.settings.throttleInputMs??300)).on("focus",this.focusHandler.bind(this)).on("focusout",this.blurHandler.bind(this)).on("keyup",this.keyUpHandler.bind(this)).on("keydown",this.keyDownHandler.bind(this))}controller(){let t=this.internalController();return typeof this.settings.controller=="function"&&(t=this.settings.controller(this)??t),t}internalController(){return{show:this.show.bind(this),hide:this.hide.bind(this),clear:this.clear.bind(this),empty:()=>{}}}moveResult(t){this.controller().show();let e=this.acItems?.length??0;if(!e)return;this.rowIndex=this.rowIndex+t,this.rowIndex<=0?this.rowIndex=0:this.rowIndex>e-1&&(this.rowIndex=0);for(let r of this.acItems)r.classList.remove("selected");let s=this.getSelectedDiv();s?(s.classList.add("selected"),s.scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"})):this.focusHandler({target:this.input})}getSelectedDiv(){return this.resultsDiv?.querySelector(`div:nth-child(${this.rowIndex+1})`)}selectResult(t){let e=t||this.getSelectedDiv();if(!e)return;let s=Number.parseInt(e.getAttribute("data-index"),10);this.resultClicked=!0;let r=Number.isInteger(s)?this.results[s]:null;if(!r)return;let n=this.categories[r.category]??{},i=typeof n.action=="function"?n.action:this.setText.bind(this);n.newTab&&(this.tabWindow=L("about:blank",960,700));let l={...r,search:this.input.value,selectedItem:e};e.classList.add("ac-active"),setTimeout(()=>{this.controller().hide("result-selected"),typeof l.action=="function"?l.action(l):(i(l),n.newTab&&this.tabWindow&&(l.url?this.tabWindow.location.href=l.url:this.tabWindow.close())),this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.controller().clear("result-selected");let h=new Event("result-selected");h.detail=l,this.input.dispatchEvent(h)},0)}setText(t){let e=!1;this.input?(this.input.value=t.text,e=!0):this.container?.autoCompleteInput?(this.container.autoCompleteInput.value=t.text,e=!0):"value"in this.container&&(this.container.value=t.text,e=!0),e&&this.input&&this.input.dispatchEvent(new Event("input",{bubbles:!0})),this.controller().hide("settext")}resultClick(t){this.selectResult(t.target.closest(`.${E.item}`))}blurHandler(){setTimeout(()=>{this.resultClicked||this.controller().clear("blurred"),this.resultClicked=!1},100)}clear(t,e={}){this.settings.debug||this.resultsDiv&&(this.resultsDiv.innerHTML="",e.preserveOpen||this.controller().hide("clear"),this.cacheTmr&&clearTimeout(this.cacheTmr),this.cacheTmr=setTimeout(()=>{this.caches.clear()},5*60*1e3))}show(){if(!this.resultsDiv.classList.contains("ac-active")){let t=this.getViewBounds();this.resultsDiv.style.position="absolute",t.rect.width>100&&(this.resultsDiv.style.width=`${t.rect.width}px`),this.settings.direction=this.settings.direction??t.suggestedDirection,this.resultsDiv.setAttribute("data-direction",this.settings.direction),this.settings.direction==="up"?(this.resultsDiv.style.top="unset",this.resultsDiv.style.bottom=`${t.rect.height+20}px`,this.rowIndex=this.acItems.length):(this.resultsDiv.style.bottom="unset",this.resultsDiv.style.top=`${t.rect.height}px`,this.rowIndex=-1),this.resultsDiv.style.maxWidth="unset",this.resultsDiv.classList.toggle("ac-active",!0)}}getViewBounds(){let t=this.input.getBoundingClientRect();return{rect:t,suggestedDirection:t.top+t.height+500>window.innerHeight?"up":"down"}}hide(){this.resultsDiv.classList.toggle("ac-active",!1)}empty(){this.resultsDiv.innerHTML=`<div class="ac-empty">${this.settings.emptyResultsText}</div>`,this.controller().show()}async inputHandler(t){this.cacheTmr&&clearTimeout(this.cacheTmr);let e={search:t.target.value,categories:this.categories},s=this.requestToken+1,r=this.settings.progressive===!0,n="",i=!1;this.container.classList.add("search-running");let l=(g,p={})=>{!r||p.token!==this.requestToken||(i=!0,n=this.resultsSignature(g),this.resultsHandler(g,e),this.input.dispatchEvent(new CustomEvent("results:partial",{detail:{results:g,token:p.token,pending:p.pending??0,completed:p.completed??0,settled:p.settled??!1}})))},h=await this.getItems(e,t,{onProgress:l,forceToken:s}).catch(()=>[]);if(s!==this.requestToken){this.container.classList.remove("search-running");return}let f=this.resultsSignature(h);(!i||f!==n)&&this.resultsHandler(h,e),this.input.dispatchEvent(new CustomEvent("results:complete",{detail:{results:h,token:s,pending:0,completed:Object.keys(this.categories||{}).length,settled:!0}})),this.container.classList.remove("search-running")}keyDownHandler(t){switch(t.key){case"Enter":t.stopPropagation(),t.preventDefault();break;case"ArrowDown":I(()=>this.moveResult(1));break;case"ArrowUp":I(()=>this.moveResult(-1));break;default:break}}keyUpHandler(t){switch(t.key){case"Escape":this.controller().hide("escape");break;case"Enter":this.getSelectedDiv()&&(this.container.preventEnter=!0,t.stopPropagation(),t.preventDefault(),this.selectResult(),setTimeout(()=>{this.container.preventEnter=!1},10));break;default:break}}focusHandler(t){this.controller().clear("focus"),this.suggest(t.target.value,t)}suggest(t,e){this.input.focus();let s={suggest:!0,search:t||"",categories:this.categories};this.getItems(s,e).then(r=>{this.input.dispatchEvent(new CustomEvent("show-results",{detail:{results:r}})),this.resultsHandler(r,s)})}sort(t,e){return t.sort((s,r)=>{let n=e.categories[s.category],i=e.categories[r.category],l=typeof n.sortIndex=="function"?n.sortIndex(e):n.sortIndex??0;return(typeof i.sortIndex=="function"?i.sortIndex(e):i.sortIndex??0)>l?1:-1})}resultsHandler(t,e){this.results=t,this.rowIndex=-1,this.resultsDiv.innerHTML="";let s=0,r=(n,i)=>{let l=this.formatCategoryLabel(i.category);return`
|
|
3
3
|
<div title="${i.tooltip||""}" data-index="${s}" class="${`${E.item} cat-${i.category} ${i.class??""}`.trim()}"${i.style?` style="${i.style}"`:""}>
|
|
4
4
|
${this.handleImageOrIcon(i)}
|
|
5
5
|
<span class="text">${this.formatResultItem(i,e,n)}</span>
|
|
6
6
|
${this.settings.hideCategory?"":`<span class="category">${l}</span>`}
|
|
7
|
-
</div>`};t.forEach(n=>{let i=e.categories[n.category]||{};if(n.element)this.resultsDiv.appendChild(n.element);else{let h=S(r(i,typeof n=="string"?{text:n}:n)),f=Array.from(h).find(g=>g&&g.nodeType===Node.ELEMENT_NODE);f&&this.resultsDiv.appendChild(f)}s+=1}),t.length?(this.acItems=this.resultsDiv.querySelectorAll(".ac-itm"),this.controller().show()):e.search.length&&this.controller().empty()}handleImageOrIcon(t){return t.image?`<img src="${t.image}"/>`:typeof this.settings.iconHandler=="function"?this.settings.iconHandler(t):`<svg-icon icon="${t.icon}"></svg-icon>`}formatResultItem(t,e,s){let r=typeof t=="string"?{text:t}:t,n=r.text;return e.search&&(n=n.replace("%search%",e.search),r.description=r.description?.replace("%search%",e.search)),n=this.highlight(n,e.search),r.description&&(n=`<div>${n}</div><small>${r.description}</small>`),s.format&&(n=s.format({item:r,result:n,options:e})),n}formatCategoryLabel(t){return this.settings.humanizeCategoryLabels===!1?t||"":M(t||"")}highlight(t,e){if(!e)return t;try{let s=new RegExp(`(${H(e)})`,"gi");return t.replace(s,'<span class="txt-hl">$1</span>')}catch{return t}}resultsSignature(t){return!Array.isArray(t)||t.length===0?"":t.map(e=>!e||typeof e!="object"?String(e):`${e.category??""}|${e.id??""}|${e.value??""}|${e.text??""}`).join("||")}getCacheKey(t){let e=this.settings.locale||document?.documentElement?.lang||navigator?.language||"",s=String(t?.search??"").trim().toLowerCase(),r=Object.keys(t?.categories||{}).join(",");return`${e}::${s}::${r}`}async getItems(t,e,s={}){this.aborter&&this.aborter.abort();let r=s.forceToken||this.requestToken+1;this.requestToken=r;let n=this.getCacheKey(t);if(this.settings.cache!==!1&&this.caches.has(n)){let c=this.caches.get(n);return typeof s.onProgress=="function"&&s.onProgress(c,{token:r,pending:0,completed:Object.keys(t.categories||{}).length,settled:!0}),c}this.aborter=new AbortController,this.aborterSignal=this.aborter.signal;let i=this.items,l=this.settings.map,h=c=>typeof c=="string"?{text:c}:c,f=c=>l?c.map(d=>({text:d[l]})):c.map(d=>h(d)),g=c=>(this.settings.max&&this.settings.max>0&&(c.length=this.settings.max),c),p=c=>{let d=this.sort(c,t);return this.settings.cache!==!1&&this.caches.set(n,d),d};if(k(i)){if(this.settings.minlength>0&&(!t.search||t.search.length<this.settings.minlength))return p([]);let c=this.formatSearch(i,t),d=await fetch(c,{signal:this.aborterSignal});if(d.status!==200)throw Error(`HTTP error ${d.status} - ${c}`);let T=f(await d.json()).filter(o=>this.isMatch(t,o));return p(g(T))}if(Array.isArray(i)){let c=!0;return this.items=i.map(d=>typeof d=="string"?{text:d}:(c=!1,d)),c&&this.container.classList.add("simple"),p(g(f(this.items)))}if(typeof i=="function"){t.control=this.container;let c=this.settings.progressive===!0,d=await this.items(t,e,{progressive:c,token:r,onProgress:s.onProgress});return p(f(d))}return Promise.resolve(i.apply(this,t)).then(c=>p(c))}async runCategorySearch(t,e,s){let r=Number(this.settings.categoryTimeoutMs||0),n={...t,signal:this.aborterSignal};try{let i=await P(Promise.resolve(s.getItems(n)),r,`Category "${e}"`);return(Array.isArray(i)?i:[]).map(h=>{let f=typeof h=="string"?{text:h}:h;return f.category=e,f})}catch(i){return console.warn(`Error loading items for omniBox category '${e}'.`,i),[]}}async runCategoriesSequentially(t,e,s={}){let r=[],n=0;for(let[i,l]of e){let h=l||{};if(h.trigger=h.trigger??(()=>!0),h.getItems=h.getItems??(()=>[]),t.results=r,!h.trigger(t)){n+=1;continue}let f=await this.runCategorySearch(t,i,h);if(this.aborterSignal?.aborted)return r;if(r=r.concat(f),n+=1,typeof s.onProgress=="function"&&this.requestToken===s.token){let g=this.sort([...r],t);s.onProgress(g,{token:s.token,pending:Math.max(0,e.length-n),completed:n,settled:n===e.length})}}return r}async runCategoriesProgressive(t,e,s={}){let r=Math.max(1,Number(this.settings.maxConcurrentCategories||3)),n=[];for(let[c,d]of e){let
|
|
7
|
+
</div>`};t.forEach(n=>{let i=e.categories[n.category]||{};if(n.element)this.resultsDiv.appendChild(n.element);else{let h=S(r(i,typeof n=="string"?{text:n}:n)),f=Array.from(h).find(g=>g&&g.nodeType===Node.ELEMENT_NODE);f&&this.resultsDiv.appendChild(f)}s+=1}),t.length?(this.acItems=this.resultsDiv.querySelectorAll(".ac-itm"),this.controller().show()):e.search.length&&this.controller().empty()}handleImageOrIcon(t){return t.image?`<img src="${t.image}"/>`:typeof this.settings.iconHandler=="function"?this.settings.iconHandler(t):`<svg-icon icon="${t.icon}"></svg-icon>`}formatResultItem(t,e,s){let r=typeof t=="string"?{text:t}:t,n=r.text;return e.search&&(n=n.replace("%search%",e.search),r.description=r.description?.replace("%search%",e.search)),n=this.highlight(n,e.search),r.description&&(n=`<div>${n}</div><small>${r.description}</small>`),s.format&&(n=s.format({item:r,result:n,options:e})),n}formatCategoryLabel(t){return this.settings.humanizeCategoryLabels===!1?t||"":M(t||"")}highlight(t,e){if(!e)return t;try{let s=new RegExp(`(${H(e)})`,"gi");return t.replace(s,'<span class="txt-hl">$1</span>')}catch{return t}}resultsSignature(t){return!Array.isArray(t)||t.length===0?"":t.map(e=>!e||typeof e!="object"?String(e):`${e.category??""}|${e.id??""}|${e.value??""}|${e.text??""}`).join("||")}getCacheKey(t){let e=this.settings.locale||document?.documentElement?.lang||navigator?.language||"",s=String(t?.search??"").trim().toLowerCase(),r=Object.keys(t?.categories||{}).join(",");return`${e}::${s}::${r}`}async getItems(t,e,s={}){this.aborter&&this.aborter.abort();let r=s.forceToken||this.requestToken+1;this.requestToken=r;let n=this.getCacheKey(t);if(this.settings.cache!==!1&&this.caches.has(n)){let c=this.caches.get(n);return typeof s.onProgress=="function"&&s.onProgress(c,{token:r,pending:0,completed:Object.keys(t.categories||{}).length,settled:!0}),c}this.aborter=new AbortController,this.aborterSignal=this.aborter.signal;let i=this.items,l=this.settings.map,h=c=>typeof c=="string"?{text:c}:c,f=c=>l?c.map(d=>({text:d[l]})):c.map(d=>h(d)),g=c=>(this.settings.max&&this.settings.max>0&&(c.length=this.settings.max),c),p=c=>{let d=this.sort(c,t);return this.settings.cache!==!1&&this.caches.set(n,d),d};if(k(i)){if(this.settings.minlength>0&&(!t.search||t.search.length<this.settings.minlength))return p([]);let c=this.formatSearch(i,t),d=await fetch(c,{signal:this.aborterSignal});if(d.status!==200)throw Error(`HTTP error ${d.status} - ${c}`);let T=f(await d.json()).filter(o=>this.isMatch(t,o));return p(g(T))}if(Array.isArray(i)){let c=!0;return this.items=i.map(d=>typeof d=="string"?{text:d}:(c=!1,d)),c&&this.container.classList.add("simple"),p(g(f(this.items)))}if(typeof i=="function"){t.control=this.container;let c=this.settings.progressive===!0,d=await this.items(t,e,{progressive:c,token:r,onProgress:s.onProgress});return p(f(d))}return Promise.resolve(i.apply(this,t)).then(c=>p(c))}async runCategorySearch(t,e,s){let r=Number(this.settings.categoryTimeoutMs||0),n={...t,signal:this.aborterSignal};try{let i=await P(Promise.resolve(s.getItems(n)),r,`Category "${e}"`);return(Array.isArray(i)?i:[]).map(h=>{let f=typeof h=="string"?{text:h}:h;return f.category=e,f})}catch(i){return console.warn(`Error loading items for omniBox category '${e}'.`,i),[]}}async runCategoriesSequentially(t,e,s={}){let r=[],n=0;for(let[i,l]of e){let h=l||{};if(h.trigger=h.trigger??(()=>!0),h.getItems=h.getItems??(()=>[]),t.results=r,!h.trigger(t)){n+=1;continue}let f=await this.runCategorySearch(t,i,h);if(this.aborterSignal?.aborted)return r;if(r=r.concat(f),n+=1,typeof s.onProgress=="function"&&this.requestToken===s.token){let g=this.sort([...r],t);s.onProgress(g,{token:s.token,pending:Math.max(0,e.length-n),completed:n,settled:n===e.length})}}return r}async runCategoriesProgressive(t,e,s={}){let r=Math.max(1,Number(this.settings.maxConcurrentCategories||3)),n=[];for(let[c,d]of e){let v=d||{};v.trigger=v.trigger??(()=>!0),v.getItems=v.getItems??(()=>[]),t.results=[],v.trigger(t)&&n.push([c,v])}if(!n.length)return[];let i=0,l=0,h=[],f=async()=>{for(;i<n.length;){let c=i;i+=1;let[d,v]=n[c],T=await this.runCategorySearch(t,d,v);if(this.aborterSignal?.aborted)return;if(h.push(...T),l+=1,typeof s.onProgress=="function"&&this.requestToken===s.token){let o=this.sort([...h],t);s.onProgress(o,{token:s.token,pending:Math.max(0,n.length-l),completed:l,settled:l===n.length})}}},g=[],p=Math.min(r,n.length);for(let c=0;c<p;c+=1)g.push(f());return await Promise.all(g),h}async items(t,e,s={}){t.results=[],t.signal=this.aborterSignal;let r=Object.entries(t.categories||{});return r.length?s.progressive?this.runCategoriesProgressive(t,r,s):this.runCategoriesSequentially(t,r,s):[]}formatSearch(t,e){return t.indexOf("%search%")?t.replace("%search%",e.search||""):`${t}?${this.createQueryParam(e)}`}createQueryParam(t){let e=t.suggest?"&suggest=true":"";return`q=${t.text}${e}`}isMatch(t,e){return e.text?.indexOf("%search%")>=0?!0:t.search?e.text?.toLowerCase().indexOf(t.search.toLowerCase())>=0:t.suggest}static textFilter(t,e){return function(r){if(!t.search)return!0;if(r.hidden)return!1;let i=(e?r[e]:r).match(new RegExp(t.search,"gi"));return i||(r.config?.tags?r.config.tags.some(l=>l.match(new RegExp(t.search,"gi"))):!1)}}};export{O as AutoComplete};
|