@pure-ds/core 0.7.49 → 0.7.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/src/js/common/common.d.ts +16 -3
- package/dist/types/src/js/common/common.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-generator.d.ts.map +1 -1
- package/package.json +1 -1
- package/public/assets/js/app.js +8 -6
- package/public/assets/js/pds-ask.js +6 -6
- package/public/assets/js/pds-manager.js +144 -135
- package/public/assets/js/pds.js +2 -2
- package/public/assets/pds/core/pds-ask.js +6 -6
- package/public/assets/pds/core/pds-manager.js +144 -135
- package/public/assets/pds/core.js +2 -2
- package/src/js/common/common.js +111 -23
- package/src/js/pds-core/pds-generator.js +14 -5
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var nt=Object.defineProperty;var ot=(e,t)=>{for(var n in t)nt(e,n,{get:t[n],enumerable:!0})};var ie=class extends EventTarget{constructor(){super(),this.mode=null,this.compiled=null,this.log=()=>{},this.logHandler=null}},Le="__PURE_DS_PDS_SINGLETON__",ae=typeof globalThis<"u"?globalThis:window,se=ae?.[Le],r=se&&typeof se.addEventListener=="function"?se:new ie;ae&&(ae[Le]=r);typeof r.log!="function"&&(r.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 r.logHandler!="function"&&(r.logHandler=null);var ce=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){r.log("error",`Registry: failed to load static ${t}:`,n),r.log("error",`Registry: looking for ${this._staticPaths[t]}`),r.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"}},C=new ce;async function Ee(e,t=[],n=null){try{let o=n?.primitivesStylesheet?n.primitivesStylesheet:await C.getStylesheet("primitives");e.adoptedStyleSheets=[o,...t]}catch(o){let c=e.host?.tagName?.toLowerCase()||"unknown";r.log("error",`Adopter: <${c}> failed to adopt primitives:`,o),e.adoptedStyleSheets=t}}async function Ae(e,t=["primitives"],n=[],o=null){let c=Array.isArray(n)?n.filter(Boolean):[];if(c.length){let l=(Array.isArray(e.adoptedStyleSheets)?e.adoptedStyleSheets:[]).filter(g=>!c.includes(g));e.adoptedStyleSheets=[...l,...c]}try{let l=(await Promise.all(t.map(async g=>{if(o)switch(g){case"tokens":return o.tokensStylesheet;case"primitives":return o.primitivesStylesheet;case"components":return o.componentsStylesheet;case"utilities":return o.utilitiesStylesheet;default:break}return C.getStylesheet(g)}))).filter(g=>g!==null);e.adoptedStyleSheets=[...l,...c]}catch(s){let l=e.host?.tagName?.toLowerCase()||"unknown";r.log("error",`Adopter: <${l}> failed to adopt layers:`,s),e.adoptedStyleSheets=c}}function ve(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var Pe={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 ue={};ot(ue,{deepMerge:()=>Re,fragmentFromTemplateLike:()=>rt,isObject:()=>W,parseHTML:()=>le});function W(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Re(e,t){let n={...e};return W(e)&&W(t)&&Object.keys(t).forEach(o=>{W(t[o])?o in e?n[o]=Re(e[o],t[o]):Object.assign(n,{[o]:t[o]}):Object.assign(n,{[o]:t[o]})}),n}function rt(e){let t=Array.isArray(e?.strings)?e.strings:[],n=Array.isArray(e?.values)?e.values:[],o=new Set,c=[],s=/(\s)(\.[\w-]+)=\s*$/;for(let i=0;i<t.length;i+=1){let S=t[i]??"",m=S.match(s);if(m&&i<n.length){let _=m[2].slice(1),A=`pds-val-${i}`;S=S.replace(s,`$1data-pds-prop="${_}:${A}"`),o.add(i)}c.push(S),i<n.length&&!o.has(i)&&c.push(`<!--pds-val-${i}-->`)}let l=document.createElement("template");l.innerHTML=c.join("");let g=(i,S)=>{let m=i.parentNode;if(!m)return;if(S==null){m.removeChild(i);return}let L=_=>{if(_!=null){if(_ instanceof Node){m.insertBefore(_,i);return}if(Array.isArray(_)){_.forEach(A=>L(A));return}m.insertBefore(document.createTextNode(String(_)),i)}};L(S),m.removeChild(i)},y=document.createTreeWalker(l.content,NodeFilter.SHOW_COMMENT),u=[];for(;y.nextNode();){let i=y.currentNode;i?.nodeValue?.startsWith("pds-val-")&&u.push(i)}return u.forEach(i=>{let S=Number(i.nodeValue.replace("pds-val-",""));g(i,n[S])}),l.content.querySelectorAll("*").forEach(i=>{let S=i.getAttribute("data-pds-prop");if(!S)return;let[m,L]=S.split(":"),_=Number(String(L).replace("pds-val-",""));m&&Number.isInteger(_)&&(i[m]=n[_]),i.removeAttribute("data-pds-prop")}),l.content}function le(e){return new DOMParser().parseFromString(e,"text/html").body.childNodes}var De="pds",st=/^([a-z][a-z0-9+\-.]*:)?\/\//i,xe=/^[a-z]:/i;function U(e=""){return e.endsWith("/")?e:`${e}/`}function it(e="",t=De){let n=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(n)?n:`${n}/${t}`}function at(e){return e.replace(/^\.\/+/,"")}function ct(e){return xe.test(e)?e.replace(xe,"").replace(/^\/+/,""):e}function lt(e){return e.startsWith("public/")?e.substring(7):e}function H(e,t={}){let n=t.segment||De,o=t.defaultRoot||`/assets/${n}/`,c=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!c||typeof c!="string")return U(o);let s=c.trim();return s?(s=s.replace(/\\/g,"/"),s=it(s,n),s=U(s),st.test(s)?s:(s=at(s),s=ct(s),s.startsWith("/")||(s=lt(s),s.startsWith("/")||(s=`/${s}`),s=s.replace(/\/+/g,(l,g)=>g===0?l:"/")),U(s))):U(o)}async function ut(...e){let t={};e.length&&typeof e[e.length-1]=="object"&&(t=e.pop()||{});let n=e,{baseURL:o,mapper:c=u=>`${u}.js`,onError:s=(u,a)=>console.error(`[defineWebComponents] ${u}:`,a)}=t,l=o?new URL(o,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),g=u=>u.toLowerCase().replace(/(^|-)([a-z])/g,(a,i,S)=>S.toUpperCase()),y=async u=>{try{if(customElements.get(u))return{tag:u,status:"already-defined"};let a=c(u),S=await import(a instanceof URL?a.href:new URL(a,l).href),m=S?.default??S?.[g(u)];if(!m){if(customElements.get(u))return{tag:u,status:"self-defined"};throw new Error(`No export found for ${u}. Expected default export or named export "${g(u)}".`)}return customElements.get(u)?{tag:u,status:"race-already-defined"}:(customElements.define(u,m),{tag:u,status:"defined"})}catch(a){throw s(u,a),a}};return Promise.all(n.map(y))}var B=class{constructor(t={}){let{baseURL:n,mapper:o,onError:c,predicate:s=()=>!0,attributeModule:l="data-module",root:g=document,scanExisting:y=!0,debounceMs:u=16,observeShadows:a=!0,enhancers:i=[],patchAttachShadow:S=!0}=t,m=new Set,L=new Set,_=new Set,A=new Map,P=new WeakMap,E=new WeakMap,h=0,w=!1,R=null,F=d=>{if(!d||!i.length)return;let p=E.get(d);p||(p=new Set,E.set(d,p));for(let f of i)if(!(!f.selector||!f.run)&&!p.has(f.selector))try{d.matches&&d.matches(f.selector)&&(f.run(d),p.add(f.selector))}catch(v){console.warn(`[AutoDefiner] Error applying enhancer for selector "${f.selector}":`,v)}},M=(d,p)=>{if(!w&&!(!d||!d.includes("-"))&&!customElements.get(d)&&!L.has(d)&&!_.has(d)){if(p&&p.getAttribute){let f=p.getAttribute(l);f&&!A.has(d)&&A.set(d,f)}m.add(d),tt()}},tt=()=>{h||(h=setTimeout(Se,u))},D=d=>{if(d){if(d.nodeType===1){let p=d,f=p.tagName?.toLowerCase();f&&f.includes("-")&&!customElements.get(f)&&s(f,p)&&M(f,p),F(p),a&&p.shadowRoot&&re(p.shadowRoot)}d.querySelectorAll&&d.querySelectorAll("*").forEach(p=>{let f=p.tagName?.toLowerCase();f&&f.includes("-")&&!customElements.get(f)&&s(f,p)&&M(f,p),F(p),a&&p.shadowRoot&&re(p.shadowRoot)})}},re=d=>{if(!d||P.has(d))return;D(d);let p=new MutationObserver(f=>{for(let v of f)v.addedNodes?.forEach(z=>{D(z)}),v.type==="attributes"&&v.target&&D(v.target)});p.observe(d,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...i.map(f=>f.selector).filter(f=>f.startsWith("data-"))]}),P.set(d,p)};async function Se(){if(clearTimeout(h),h=0,!m.size)return;let d=Array.from(m);m.clear(),d.forEach(p=>L.add(p));try{let p=f=>A.get(f)??(o?o(f):`${f}.js`);await ut(...d,{baseURL:n,mapper:p,onError:(f,v)=>{_.add(f),c?.(f,v)}})}catch{}finally{d.forEach(p=>L.delete(p))}}let _e=g===document?document.documentElement:g,be=new MutationObserver(d=>{for(let p of d)p.addedNodes?.forEach(f=>{D(f)}),p.type==="attributes"&&p.target&&D(p.target)});if(be.observe(_e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...i.map(d=>d.selector).filter(d=>d.startsWith("data-"))]}),a&&S&&Element.prototype.attachShadow){let d=Element.prototype.attachShadow;Element.prototype.attachShadow=function(f){let v=d.call(this,f);if(f&&f.mode==="open"){re(v);let z=this.tagName?.toLowerCase();z&&z.includes("-")&&!customElements.get(z)&&M(z,this)}return v},R=()=>Element.prototype.attachShadow=d}return y&&D(_e),{stop(){w=!0,be.disconnect(),R&&R(),h&&(clearTimeout(h),h=0),P.forEach(d=>d.disconnect())},flush:Se}}static async define(...t){let n={};t.length&&typeof t[t.length-1]=="object"&&(n=t.pop()||{});let o=t,{baseURL:c,mapper:s=a=>`${a}.js`,onError:l=(a,i)=>console.error(`[defineWebComponents] ${a}:`,i)}=n,g=c?new URL(c,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),y=a=>a.toLowerCase().replace(/(^|-)([a-z])/g,(i,S,m)=>m.toUpperCase()),u=async a=>{try{if(customElements.get(a))return{tag:a,status:"already-defined"};let i=s(a),m=await import(i instanceof URL?i.href:new URL(i,g).href),L=m?.default??m?.[y(a)];if(!L){if(customElements.get(a))return{tag:a,status:"self-defined"};throw new Error(`No export found for ${a}. Expected default export or named export "${y(a)}".`)}return customElements.get(a)?{tag:a,status:"race-already-defined"}:(customElements.define(a,L),{tag:a,status:"defined"})}catch(i){throw l(a,i),i}};return Promise.all(o.map(u))}};var dt=/^[a-z][a-z0-9+\-.]*:\/\//i,j=(()=>{try{return import.meta.url}catch{return}})(),K=e=>typeof e=="string"&&e.length&&!e.endsWith("/")?`${e}/`:e;function G(e,t={}){if(!e||dt.test(e))return e;let{preferModule:n=!0}=t,o=()=>{if(!j)return null;try{return new URL(e,j).href}catch{return null}},c=()=>{if(typeof window>"u"||!window.location?.origin)return null;try{return new URL(e,window.location.origin).href}catch{return null}};return(n?o()||c():c()||o())||e}var ze=(()=>{if(j)try{let e=new URL(j);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",j).href}catch{return}})(),Ce=!1;function Te(e){Ce||typeof document>"u"||(Ce=!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 c="light",s=null;if(e&&typeof window<"u"){try{s=localStorage.getItem(t)||null}catch{s=null}try{n?.(s),o?.(s)}catch{}s?s==="system"?c=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":c=s:c=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:c,storedTheme:s}}function q(e,{resolvePublicAssetURL:t}){let n=!!(e?.public?.root||e?.static?.root),o=t(e);return!n&&ze&&(o=ze),K(G(o))}async function Me(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:n="/auto-define/",autoDefinePreload:o=[],autoDefineMapper:c=null,enhancers:s=[],autoDefineOverrides:l=null,autoDefinePreferModule:g=!0}=e,y=(()=>{let a=new Map;return(t||[]).forEach(i=>a.set(i.selector,i)),(s||[]).forEach(i=>a.set(i.selector,i)),Array.from(a.values())})(),u=null;if(typeof window<"u"&&typeof document<"u"){let a=B,i=h=>{switch(h){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${h}.js`}},{mapper:S,enhancers:m,...L}=l&&typeof l=="object"?l:{},_=m?Array.isArray(m)?m:typeof m=="object"?Object.values(m):[]:[],A=(()=>{let h=new Map;return(y||[]).forEach(w=>{w?.selector&&h.set(w.selector,w)}),(_||[]).forEach(w=>{if(!w?.selector)return;let R=h.get(w.selector)||null;h.set(w.selector,{...R||{},...w,run:typeof w?.run=="function"?w.run:R?.run})}),Array.from(h.values())})(),E={baseURL:n&&K(G(n,{preferModule:g})),predefine:o,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:A,onError:(h,w)=>{if(typeof h=="string"&&h.startsWith("pds-")){let F=["pds-form","pds-drawer"].includes(h),M=w?.message?.includes("#pds/lit")||w?.message?.includes("Failed to resolve module specifier");F&&M?r.log("error",`\u274C PDS component <${h}> requires Lit but #pds/lit is not in import map.
|
|
2
|
-
See: https://github.com/Pure-Web-Foundation/pure-ds/blob/main/readme.md#lit-components-not-working`):r.log("warn",`\u26A0\uFE0F PDS component <${h}> not found. Assets may not be installed.`)}else r.log("error",`\u274C Auto-define error for <${h}>:`,w)},...L,mapper:h=>{if(customElements.get(h))return null;if(typeof c=="function")try{let w=c(h);return w===void 0?i(h):w}catch(w){return r.log("warn","Custom autoDefine.mapper error; falling back to default:",w?.message||w),i(h)}return i(h)}};u=new a(E),o.length>0&&typeof a.define=="function"&&await a.define(...o,{baseURL:n,mapper:E.mapper,onError:E.onError})}return{autoDefiner:u,mergedEnhancers:y}}var de=["light","dark"],fe=new Set(de);function ft(e){let n=(Array.isArray(e?.themes)?e.themes.map(o=>String(o).toLowerCase()):de).filter(o=>fe.has(o));return n.length?n:de}function pe(e,{preferDocument:t=!0}={}){let n=String(e||"").toLowerCase();if(fe.has(n))return n;if(t&&typeof document<"u"){let o=document.documentElement?.getAttribute("data-theme");if(fe.has(o))return o}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Ue(e,t){let n=pe(t);return ft(e).includes(n)}var pt=new Set(["log","warn","error","debug","info"]),mt="__PURE_DS_PDS_SINGLETON__",me=null,he=null;function Oe(){try{let t=(typeof globalThis<"u"?globalThis:window)?.[mt];if(t&&typeof t=="object")return t}catch{return null}return null}function ht(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 yt(e){if(typeof e!="string")return"log";let t=e.toLowerCase();return pt.has(t)?t:"log"}function gt(){if(typeof he=="function")try{let t=ht(he());if(t)return t}catch{}let e=Oe();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 wt(){if(typeof me=="function")try{let t=me();if(typeof t=="function")return t}catch{}let e=Oe();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 St(e,t){let n=t?.debug===!0;return!(t?.mode==="static"&&!n||!n&&e!=="error"&&e!=="warn")}function Ne({getLogger:e,getContext:t}={}){me=typeof e=="function"?e:null,he=typeof t=="function"?t:null}function $e(e="log",t,...n){let o=yt(e),c=gt(),s=wt();if(s)try{s.call(c?.thisArg,o,t,...n);return}catch(l){je("error","Custom log handler failed:",l)}St(o,c)&&je(o,t,...n)}typeof r.initializing!="boolean"&&(r.initializing=!1);"currentPreset"in r||(r.currentPreset=null);typeof r.debug!="boolean"&&(r.debug=!1);"currentConfig"in r||(r.currentConfig=null);"compiled"in r||(r.compiled=null);typeof r.logHandler!="function"&&(r.logHandler=null);"mode"in r||(r.mode=null);var J=null,V=null,Y=null,Q=null,Z=null,X=null,Fe="__pdsLocalizationRuntime";function T(){if(X)return X;let e=r?.[Fe];return e&&typeof e=="object"?(X=e,e):null}function _t(e){let t=e&&typeof e=="object"?e:null;X=t,r[Fe]=t}Ne({getLogger:()=>typeof r.logHandler=="function"?r.logHandler:null,getContext:()=>{let e=r?.mode||r?.compiled?.mode||(r?.registry?.isLive?"live":"static"),t=(r?.debug||r?.currentConfig?.debug||r?.currentConfig?.design?.debug||r?.compiled?.debug||r?.compiled?.design?.debug||!1)===!0;return{mode:e,debug:t,thisArg:r}}});r.log=(e="log",t,...n)=>{$e(e,t,...n)};var b={locale:"en",messages:{},hasProvider:!1},ee=new Set;function We(e){return!!e&&typeof e!="string"&&typeof e=="object"&&"strTag"in e}function He(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 bt(e,t){return String(e).replace(/\{(\d+)\}/g,(n,o)=>t(Number(o)))}function Lt(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 Et(e,...t){return{strTag:!0,strings:Array.from(e||[]),values:t,raw:Array.from(e?.raw||[])}}function At(e){if(!e)return"";if(We(e)){let n=He(e.strings||[]),o=b.messages[n]||n;return bt(o,c=>e.values?.[c])}let t=String(e);return b.messages[t]||t}function vt(e){if(!e)return;let t=We(e)?He(e.strings||[]):String(e);typeof t=="string"&&t.length>0&&ee.add(t)}function Be(e){if(!e||typeof e.msg!="function"||ee.size===0)return;let t=Array.from(ee);ee.clear();for(let n of t)try{e.msg(n)}catch{}}async function N(){let e=T();return e||(Z||(Z=import($("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 _t(n),Be(n),n}).catch(n=>{throw Z=null,n})),Z)}var Ke=(e,t={})=>{let n=T();return typeof n?.msg=="function"?n.msg(e,t):(vt(e),At(e,t))},Ge=(e,...t)=>{let n=T();return typeof n?.str=="function"?n.str(e,...t):Et(e,...t)},te=(e=null)=>{let t=T();if(typeof t?.configureLocalization=="function")return t.configureLocalization(e);if(!e||typeof e!="object")return b.locale="en",b.messages={},b.hasProvider=!1,{locale:b.locale,messages:{...b.messages},hasProvider:b.hasProvider};typeof e.locale=="string"&&e.locale.trim()&&(b.locale=e.locale.trim()),Object.prototype.hasOwnProperty.call(e,"messages")&&(b.messages=Lt(e.messages));let n=!!(e.provider||e.translate||e.loadLocale||e.setLocale);return b.hasProvider=n,n&&N().then(o=>{o.configureLocalization(e),Be(o)}).catch(()=>{}),{locale:b.locale,messages:{...b.messages},hasProvider:b.hasProvider}},qe=async e=>(await N()).loadLocale(e),Je=async(e,t={})=>(await N()).setLocale(e,t),Ve=()=>{let e=T();return typeof e?.getLocalizationState=="function"?e.getLocalizationState():{locale:b.locale,messages:{...b.messages},hasProvider:b.hasProvider}},Ye=(e={})=>{let t=T();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(y=>String(y||"").trim().toLowerCase()).filter(Boolean):[],c=Array.from(new Set([n,...o])),s=null,l=async()=>(s||(s=N().then(y=>typeof y?.createJSONLocalization=="function"?y.createJSONLocalization(e):null).catch(()=>null)),s),g=async(y="loadLocale")=>{let u=await l();if(!u||typeof u!="object")return null;let a=u.provider;if(!a||typeof a!="object")return null;let i=a[y];return typeof i=="function"?i:y==="setLocale"&&typeof a.loadLocale=="function"?a.loadLocale:null};return{locale:n,locales:[...c],provider:{locales:[...c],async loadLocale(y={}){let u=await g("loadLocale");return typeof u!="function"?{}:u(y)},async setLocale(y={}){let u=await g("setLocale");return typeof u!="function"?{}:u(y)}}}};function $(e,t){return t&&typeof t=="string"?t:`${q(r.currentConfig||{},{resolvePublicAssetURL:H})}core/${e}`}async function Pt(){return Array.isArray(r.defaultEnhancers)&&r.defaultEnhancers.length>0?r.defaultEnhancers:(Q||(Q=import($("pds-enhancers.js",r.currentConfig?.enhancersURL)).then(t=>{let n=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return r.defaultEnhancers=n,n}).catch(t=>{throw Q=null,t})),Q)}async function Rt(){return typeof r.ask=="function"&&r.ask!==Qe?r.ask:(V||(V=import($("pds-ask.js",r.currentConfig?.askURL)).then(t=>{let n=t?.ask;if(typeof n!="function")throw new Error("Failed to load ask helper");return r.ask=n,n}).catch(t=>{throw V=null,t})),V)}async function I(){return typeof r.toast=="function"&&r.toast!==k?r.toast:(Y||(Y=import($("pds-toast.js",r.currentConfig?.toastURL)).then(t=>{let n=t?.toast;if(typeof n!="function")throw new Error("Failed to load toast helper");return r.toast=n,n}).catch(t=>{throw Y=null,t})),Y)}async function Qe(...e){return(await Rt())(...e)}async function k(...e){return(await I())(...e)}k.success=async(...e)=>(await I()).success(...e);k.error=async(...e)=>(await I()).error(...e);k.warning=async(...e)=>(await I()).warning(...e);k.info=async(...e)=>(await I()).info(...e);var Ie=function(e="log",t,...n){r.log(e,t,...n)};function ge(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=>ge(n)).filter(n=>n!==void 0);let t={};for(let[n,o]of Object.entries(e)){let c=ge(o);c!==void 0&&(t[n]=c)}return t}function Ze(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))Ze(e[n],t);return e}function we(e){return e==null||typeof e!="object"?e:Ze(structuredClone(ge(e)))}async function xt(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}}r.registry=C;r.enums=Pe;r.adoptLayers=Ae;r.adoptPrimitives=Ee;r.parse=le;r.createStylesheet=ve;r.isLiveMode=()=>C.isLive;r.ask=Qe;r.toast=k;r.common=ue;r.msg=Ke;r.str=Ge;r.configureLocalization=te;r.loadLocale=qe;r.setLocale=Je;r.getLocalizationState=Ve;r.createJSONLocalization=Ye;r.i18n={msg:Ke,str:Ge,configure:te,loadLocale:qe,setLocale:Je,getState:Ve,createJSONLocalization:Ye};r.AutoComplete=null;r.loadAutoComplete=async()=>{if(r.AutoComplete&&typeof r.AutoComplete.connect=="function")return r.AutoComplete;let e=$("pds-autocomplete.js",r.currentConfig?.autoCompleteURL);return J||(J=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 r.AutoComplete=n,n}).catch(t=>{throw J=null,t})),J};function Xe(e){let t=typeof CustomEvent=="function";try{let n=t?new CustomEvent("pds:ready",{detail:e}):new Event("pds:ready");r.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 et(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");r.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 ye="pure-ds-theme",x=null,O=null;function ne(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 oe(e){try{if(x&&O){try{typeof x.removeEventListener=="function"?x.removeEventListener("change",O):typeof x.removeListener=="function"&&x.removeListener(O)}catch{}x=null,O=null}if(e==="system"&&typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=o=>{let c=o?.matches===void 0?t.matches:o.matches;try{let s=c?"dark":"light";document.documentElement.setAttribute("data-theme",s),r.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:s,source:"system"}}))}catch{}};x=t,O=n,typeof t.addEventListener=="function"?t.addEventListener("change",n):typeof t.addListener=="function"&&t.addListener(n)}}catch{}}var Dt=Object.getOwnPropertyDescriptor(r,"theme");Dt||Object.defineProperty(r,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(ye)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=r.currentConfig?.design||null,n=pe(e);if(t&&!Ue(t,n)){let o=t?.name||r.currentPreset?.name||r.currentConfig?.preset||"current preset";r.log("warn",`PDS theme "${n}" not supported by preset "${o}".`),r.dispatchEvent(new CustomEvent("pds:theme:blocked",{detail:{theme:e,resolvedTheme:n,preset:o}}));return}e==null?localStorage.removeItem(ye):localStorage.setItem(ye,e),ne(e),oe(e),r.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});r.defaultEnhancers=[];async function zt(e){r.initializing=!0;try{let t=e&&e.mode||"live",{mode:n,...o}=e||{};r.mode=t,r.logHandler=typeof o?.log=="function"?o.log:null,r.currentConfig=we(o);let c=o&&typeof o.localization=="object"&&o.localization?o.localization:null;c?(await N(),te(c)):te(null);let s;if(t==="static")s=await Ct(o);else{let{localization:g,...y}=o||{},u=q(y,{resolvePublicAssetURL:H}),a=y?.managerURL||y?.public?.managerURL||y?.manager?.url||new URL("core/pds-manager.js",u).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:i}=await import(a);s=await i(r,y,{emitReady:Xe,emitConfigChanged:et,applyResolvedTheme:ne,setupSystemListenerIfNeeded:oe})}r.compiled=we(s?.config||null);let l=r?.compiled?.design?.icons?.externalPath||"/assets/img/icons/";return r.log("info",`startup ready; external icon path: ${l}`),s}finally{r.initializing=!1}}r.start=zt;async function Ct(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",c=e.staticPaths??{},s=q(e,{resolvePublicAssetURL:H}),l=e&&e.autoDefine||null,g;l&&l.baseURL?g=K(G(l.baseURL,{preferModule:!1})):g=`${s}components/`;let y=l&&Array.isArray(l.predefine)&&l.predefine||[],u=l&&typeof l.mapper=="function"&&l.mapper||null;try{Te(r);let{resolvedTheme:a}=ke({manageTheme:n,themeStorageKey:o,applyResolvedTheme:ne,setupSystemListenerIfNeeded:oe}),i=await xt(s,e),S=Array.isArray(e?.enhancers)?e.enhancers:e?.enhancers&&typeof e.enhancers=="object"?Object.values(e.enhancers):[],m=i?.config?{...i.config,...e,design:e?.design||i.config.design,preset:e?.preset||i.config.preset}:{...e},L={tokens:`${s}styles/pds-tokens.css.js`,primitives:`${s}styles/pds-primitives.css.js`,components:`${s}styles/pds-components.css.js`,utilities:`${s}styles/pds-utilities.css.js`,styles:`${s}styles/pds-styles.css.js`},_=i?.paths||{};if(c={...L,..._,...c},r.registry.setStaticMode(c),t&&typeof document<"u")try{let E=await r.registry.getStylesheet("styles");if(E){E._pds=!0;let h=(document.adoptedStyleSheets||[]).filter(w=>w._pds!==!0);document.adoptedStyleSheets=[...h,E],et({mode:"static",source:"static:styles-applied"})}}catch(E){Ie.call(r,"warn","Failed to apply static styles:",E)}let A=null,P=[];try{let E=await Pt(),h=await Me({autoDefineBaseURL:g,autoDefinePreload:y,autoDefineMapper:u,enhancers:S,autoDefineOverrides:l||null,autoDefinePreferModule:!(l&&l.baseURL)},{baseEnhancers:E});A=h.autoDefiner,P=h.mergedEnhancers||[]}catch(E){Ie.call(r,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",E)}return r.compiled=we({mode:"static",...m,theme:a,enhancers:P}),Xe({mode:"static",config:m,theme:a,autoDefiner:A}),{config:m,theme:a,autoDefiner:A}}catch(a){throw r.dispatchEvent(new CustomEvent("pds:error",{detail:{error:a}})),a}}var tn=ne,nn=oe;export{r as PDS,tn as applyResolvedTheme,te as configureLocalization,Ye as createJSONLocalization,Ve as getLocalizationState,qe as loadLocale,Ke as msg,Je as setLocale,nn as setupSystemListenerIfNeeded,Ge as str};
|
|
1
|
+
var rt=Object.defineProperty;var ot=(e,t)=>{for(var n in t)rt(e,n,{get:t[n],enumerable:!0})};var ie=class extends EventTarget{constructor(){super(),this.mode=null,this.compiled=null,this.log=()=>{},this.logHandler=null}},Ee="__PURE_DS_PDS_SINGLETON__",ae=typeof globalThis<"u"?globalThis:window,se=ae?.[Ee],o=se&&typeof se.addEventListener=="function"?se:new ie;ae&&(ae[Ee]=o);typeof o.log!="function"&&(o.log=(e="log",t,...n)=>{if(typeof console>"u")return;let r=typeof console[e]=="function"?console[e].bind(console):typeof console.log=="function"?console.log.bind(console):null;r&&(n.length>0?r(t,...n):r(t))});typeof o.logHandler!="function"&&(o.logHandler=null);var ce=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){o.log("error",`Registry: failed to load static ${t}:`,n),o.log("error",`Registry: looking for ${this._staticPaths[t]}`),o.log("error","Registry: make sure you've run 'npm run pds:build' and configured PDS.start() with the correct static.root path");let r=new CSSStyleSheet;return r.replaceSync("/* Failed to load "+t+" */"),r}}get mode(){return this._mode}get isLive(){return this._mode==="live"}},T=new ce;async function ve(e,t=[],n=null){try{let r=n?.primitivesStylesheet?n.primitivesStylesheet:await T.getStylesheet("primitives");e.adoptedStyleSheets=[r,...t]}catch(r){let a=e.host?.tagName?.toLowerCase()||"unknown";o.log("error",`Adopter: <${a}> failed to adopt primitives:`,r),e.adoptedStyleSheets=t}}async function Ae(e,t=["primitives"],n=[],r=null){let a=Array.isArray(n)?n.filter(Boolean):[];if(a.length){let l=(Array.isArray(e.adoptedStyleSheets)?e.adoptedStyleSheets:[]).filter(S=>!a.includes(S));e.adoptedStyleSheets=[...l,...a]}try{let l=(await Promise.all(t.map(async S=>{if(r)switch(S){case"tokens":return r.tokensStylesheet;case"primitives":return r.primitivesStylesheet;case"components":return r.componentsStylesheet;case"utilities":return r.utilitiesStylesheet;default:break}return T.getStylesheet(S)}))).filter(S=>S!==null);e.adoptedStyleSheets=[...l,...a]}catch(s){let l=e.host?.tagName?.toLowerCase()||"unknown";o.log("error",`Adopter: <${l}> failed to adopt layers:`,s),e.adoptedStyleSheets=a}}function Pe(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var xe={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 de={};ot(de,{deepMerge:()=>Re,fragmentFromTemplateLike:()=>le,isObject:()=>W,parseHTML:()=>ue});function W(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Re(e,t){let n={...e};return W(e)&&W(t)&&Object.keys(t).forEach(r=>{W(t[r])?r in e?n[r]=Re(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})}),n}function le(e){let t=Array.isArray(e?.strings)?e.strings:[],n=Array.isArray(e?.values)?e.values:[],r=new Set,a=[],s=/(\s)(\.[\w-]+)=\s*$/,l=/(\s)(@[\w-]+)=\s*$/,S=/(\s)(\?[\w-]+)=\s*$/,g=/(\s)([\w:-]+)=\s*$/;for(let c=0;c<t.length;c+=1){let y=t[c]??"";if(c<n.length){let _=`pds-val-${c}`,v=y.match(s),w=y.match(l),u=y.match(S),b=y.match(g);if(v){let E=v[2].slice(1);y=y.replace(s,`$1data-pds-bind-${c}="prop:${E}:${_}"`),r.add(c)}else if(w){let E=w[2].slice(1);y=y.replace(l,`$1data-pds-bind-${c}="event:${E}:${_}"`),r.add(c)}else if(u){let E=u[2].slice(1);y=y.replace(S,`$1data-pds-bind-${c}="boolean:${E}:${_}"`),r.add(c)}else if(b){let E=b[2];y=y.replace(g,`$1data-pds-bind-${c}="attr:${E}:${_}"`),r.add(c)}}a.push(y),c<n.length&&!r.has(c)&&a.push(`<!--pds-val-${c}-->`)}let d=document.createElement("template");d.innerHTML=a.join("");let i=(c,y)=>{let _=c.parentNode;if(!_)return;if(y==null){_.removeChild(c);return}let v=w=>{if(w!=null){if(w instanceof Node){_.insertBefore(w,c);return}if(Array.isArray(w)){w.forEach(u=>v(u));return}_.insertBefore(document.createTextNode(String(w)),c)}};v(y),_.removeChild(c)},m=document.createTreeWalker(d.content,NodeFilter.SHOW_COMMENT),P=[];for(;m.nextNode();){let c=m.currentNode;c?.nodeValue?.startsWith("pds-val-")&&P.push(c)}return P.forEach(c=>{let y=Number(c.nodeValue.replace("pds-val-",""));i(c,n[y])}),d.content.querySelectorAll("*").forEach(c=>{[...c.attributes].forEach(y=>{if(!y.name.startsWith("data-pds-bind-"))return;let _=y.value.indexOf(":"),v=y.value.lastIndexOf(":");if(_<=0||v<=_){c.removeAttribute(y.name);return}let w=y.value.slice(0,_),u=y.value.slice(_+1,v),b=y.value.slice(v+1),E=Number(String(b).replace("pds-val-","")),x=n[E];if(!u||!Number.isInteger(E)){c.removeAttribute(y.name);return}w==="prop"?c[u]=x:w==="event"?(typeof x=="function"||x&&typeof x.handleEvent=="function")&&c.addEventListener(u,x):w==="boolean"?x?c.setAttribute(u,""):c.removeAttribute(u):w==="attr"&&(x==null||x===!1?c.removeAttribute(u):c.setAttribute(u,String(x))),c.removeAttribute(y.name)})}),d.content}function ue(e,...t){return Array.isArray(e)&&Object.prototype.hasOwnProperty.call(e,"raw")?le({strings:Array.from(e),values:t}).childNodes:Array.isArray(e?.strings)&&Array.isArray(e?.values)?le({strings:e.strings,values:e.values}).childNodes:new DOMParser().parseFromString(String(e??""),"text/html").body.childNodes}var ze="pds",st=/^([a-z][a-z0-9+\-.]*:)?\/\//i,De=/^[a-z]:/i;function j(e=""){return e.endsWith("/")?e:`${e}/`}function it(e="",t=ze){let n=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(n)?n:`${n}/${t}`}function at(e){return e.replace(/^\.\/+/,"")}function ct(e){return De.test(e)?e.replace(De,"").replace(/^\/+/,""):e}function lt(e){return e.startsWith("public/")?e.substring(7):e}function B(e,t={}){let n=t.segment||ze,r=t.defaultRoot||`/assets/${n}/`,a=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!a||typeof a!="string")return j(r);let s=a.trim();return s?(s=s.replace(/\\/g,"/"),s=it(s,n),s=j(s),st.test(s)?s:(s=at(s),s=ct(s),s.startsWith("/")||(s=lt(s),s.startsWith("/")||(s=`/${s}`),s=s.replace(/\/+/g,(l,S)=>S===0?l:"/")),j(s))):j(r)}async function ut(...e){let t={};e.length&&typeof e[e.length-1]=="object"&&(t=e.pop()||{});let n=e,{baseURL:r,mapper:a=d=>`${d}.js`,onError:s=(d,i)=>console.error(`[defineWebComponents] ${d}:`,i)}=t,l=r?new URL(r,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),S=d=>d.toLowerCase().replace(/(^|-)([a-z])/g,(i,m,P)=>P.toUpperCase()),g=async d=>{try{if(customElements.get(d))return{tag:d,status:"already-defined"};let i=a(d),P=await import(i instanceof URL?i.href:new URL(i,l).href),L=P?.default??P?.[S(d)];if(!L){if(customElements.get(d))return{tag:d,status:"self-defined"};throw new Error(`No export found for ${d}. Expected default export or named export "${S(d)}".`)}return customElements.get(d)?{tag:d,status:"race-already-defined"}:(customElements.define(d,L),{tag:d,status:"defined"})}catch(i){throw s(d,i),i}};return Promise.all(n.map(g))}var H=class{constructor(t={}){let{baseURL:n,mapper:r,onError:a,predicate:s=()=>!0,attributeModule:l="data-module",root:S=document,scanExisting:g=!0,debounceMs:d=16,observeShadows:i=!0,enhancers:m=[],patchAttachShadow:P=!0}=t,L=new Set,c=new Set,y=new Set,_=new Map,v=new WeakMap,w=new WeakMap,u=0,b=!1,E=null,x=f=>{if(!f||!m.length)return;let h=w.get(f);h||(h=new Set,w.set(f,h));for(let p of m)if(!(!p.selector||!p.run)&&!h.has(p.selector))try{f.matches&&f.matches(p.selector)&&(p.run(f),h.add(p.selector))}catch(R){console.warn(`[AutoDefiner] Error applying enhancer for selector "${p.selector}":`,R)}},U=(f,h)=>{if(!b&&!(!f||!f.includes("-"))&&!customElements.get(f)&&!c.has(f)&&!y.has(f)){if(h&&h.getAttribute){let p=h.getAttribute(l);p&&!_.has(f)&&_.set(f,p)}L.add(f),nt()}},nt=()=>{u||(u=setTimeout(Se,d))},z=f=>{if(f){if(f.nodeType===1){let h=f,p=h.tagName?.toLowerCase();p&&p.includes("-")&&!customElements.get(p)&&s(p,h)&&U(p,h),x(h),i&&h.shadowRoot&&oe(h.shadowRoot)}f.querySelectorAll&&f.querySelectorAll("*").forEach(h=>{let p=h.tagName?.toLowerCase();p&&p.includes("-")&&!customElements.get(p)&&s(p,h)&&U(p,h),x(h),i&&h.shadowRoot&&oe(h.shadowRoot)})}},oe=f=>{if(!f||v.has(f))return;z(f);let h=new MutationObserver(p=>{for(let R of p)R.addedNodes?.forEach(C=>{z(C)}),R.type==="attributes"&&R.target&&z(R.target)});h.observe(f,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...m.map(p=>p.selector).filter(p=>p.startsWith("data-"))]}),v.set(f,h)};async function Se(){if(clearTimeout(u),u=0,!L.size)return;let f=Array.from(L);L.clear(),f.forEach(h=>c.add(h));try{let h=p=>_.get(p)??(r?r(p):`${p}.js`);await ut(...f,{baseURL:n,mapper:h,onError:(p,R)=>{y.add(p),a?.(p,R)}})}catch{}finally{f.forEach(h=>c.delete(h))}}let _e=S===document?document.documentElement:S,Le=new MutationObserver(f=>{for(let h of f)h.addedNodes?.forEach(p=>{z(p)}),h.type==="attributes"&&h.target&&z(h.target)});if(Le.observe(_e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...m.map(f=>f.selector).filter(f=>f.startsWith("data-"))]}),i&&P&&Element.prototype.attachShadow){let f=Element.prototype.attachShadow;Element.prototype.attachShadow=function(p){let R=f.call(this,p);if(p&&p.mode==="open"){oe(R);let C=this.tagName?.toLowerCase();C&&C.includes("-")&&!customElements.get(C)&&U(C,this)}return R},E=()=>Element.prototype.attachShadow=f}return g&&z(_e),{stop(){b=!0,Le.disconnect(),E&&E(),u&&(clearTimeout(u),u=0),v.forEach(f=>f.disconnect())},flush:Se}}static async define(...t){let n={};t.length&&typeof t[t.length-1]=="object"&&(n=t.pop()||{});let r=t,{baseURL:a,mapper:s=i=>`${i}.js`,onError:l=(i,m)=>console.error(`[defineWebComponents] ${i}:`,m)}=n,S=a?new URL(a,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),g=i=>i.toLowerCase().replace(/(^|-)([a-z])/g,(m,P,L)=>L.toUpperCase()),d=async i=>{try{if(customElements.get(i))return{tag:i,status:"already-defined"};let m=s(i),L=await import(m instanceof URL?m.href:new URL(m,S).href),c=L?.default??L?.[g(i)];if(!c){if(customElements.get(i))return{tag:i,status:"self-defined"};throw new Error(`No export found for ${i}. Expected default export or named export "${g(i)}".`)}return customElements.get(i)?{tag:i,status:"race-already-defined"}:(customElements.define(i,c),{tag:i,status:"defined"})}catch(m){throw l(i,m),m}};return Promise.all(r.map(d))}};var dt=/^[a-z][a-z0-9+\-.]*:\/\//i,$=(()=>{try{return import.meta.url}catch{return}})(),K=e=>typeof e=="string"&&e.length&&!e.endsWith("/")?`${e}/`:e;function G(e,t={}){if(!e||dt.test(e))return e;let{preferModule:n=!0}=t,r=()=>{if(!$)return null;try{return new URL(e,$).href}catch{return null}},a=()=>{if(typeof window>"u"||!window.location?.origin)return null;try{return new URL(e,window.location.origin).href}catch{return null}};return(n?r()||a():a()||r())||e}var Ce=(()=>{if($)try{let e=new URL($);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",$).href}catch{return}})(),Te=!1;function Me(e){Te||typeof document>"u"||(Te=!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:r}){let a="light",s=null;if(e&&typeof window<"u"){try{s=localStorage.getItem(t)||null}catch{s=null}try{n?.(s),r?.(s)}catch{}s?s==="system"?a=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":a=s:a=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:a,storedTheme:s}}function q(e,{resolvePublicAssetURL:t}){let n=!!(e?.public?.root||e?.static?.root),r=t(e);return!n&&Ce&&(r=Ce),K(G(r))}async function Ue(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:n="/auto-define/",autoDefinePreload:r=[],autoDefineMapper:a=null,enhancers:s=[],autoDefineOverrides:l=null,autoDefinePreferModule:S=!0}=e,g=(()=>{let i=new Map;return(t||[]).forEach(m=>i.set(m.selector,m)),(s||[]).forEach(m=>i.set(m.selector,m)),Array.from(i.values())})(),d=null;if(typeof window<"u"&&typeof document<"u"){let i=H,m=u=>{switch(u){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${u}.js`}},{mapper:P,enhancers:L,...c}=l&&typeof l=="object"?l:{},y=L?Array.isArray(L)?L:typeof L=="object"?Object.values(L):[]:[],_=(()=>{let u=new Map;return(g||[]).forEach(b=>{b?.selector&&u.set(b.selector,b)}),(y||[]).forEach(b=>{if(!b?.selector)return;let E=u.get(b.selector)||null;u.set(b.selector,{...E||{},...b,run:typeof b?.run=="function"?b.run:E?.run})}),Array.from(u.values())})(),w={baseURL:n&&K(G(n,{preferModule:S})),predefine:r,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:_,onError:(u,b)=>{if(typeof u=="string"&&u.startsWith("pds-")){let x=["pds-form","pds-drawer"].includes(u),U=b?.message?.includes("#pds/lit")||b?.message?.includes("Failed to resolve module specifier");x&&U?o.log("error",`\u274C PDS component <${u}> requires Lit but #pds/lit is not in import map.
|
|
2
|
+
See: https://github.com/Pure-Web-Foundation/pure-ds/blob/main/readme.md#lit-components-not-working`):o.log("warn",`\u26A0\uFE0F PDS component <${u}> not found. Assets may not be installed.`)}else o.log("error",`\u274C Auto-define error for <${u}>:`,b)},...c,mapper:u=>{if(customElements.get(u))return null;if(typeof a=="function")try{let b=a(u);return b===void 0?m(u):b}catch(b){return o.log("warn","Custom autoDefine.mapper error; falling back to default:",b?.message||b),m(u)}return m(u)}};d=new i(w),r.length>0&&typeof i.define=="function"&&await i.define(...r,{baseURL:n,mapper:w.mapper,onError:w.onError})}return{autoDefiner:d,mergedEnhancers:g}}var fe=["light","dark"],pe=new Set(fe);function ft(e){let n=(Array.isArray(e?.themes)?e.themes.map(r=>String(r).toLowerCase()):fe).filter(r=>pe.has(r));return n.length?n:fe}function me(e,{preferDocument:t=!0}={}){let n=String(e||"").toLowerCase();if(pe.has(n))return n;if(t&&typeof document<"u"){let r=document.documentElement?.getAttribute("data-theme");if(pe.has(r))return r}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function je(e,t){let n=me(t);return ft(e).includes(n)}var pt=new Set(["log","warn","error","debug","info"]),mt="__PURE_DS_PDS_SINGLETON__",he=null,ye=null;function Oe(){try{let t=(typeof globalThis<"u"?globalThis:window)?.[mt];if(t&&typeof t=="object")return t}catch{return null}return null}function ht(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 yt(e){if(typeof e!="string")return"log";let t=e.toLowerCase();return pt.has(t)?t:"log"}function gt(){if(typeof ye=="function")try{let t=ht(ye());if(t)return t}catch{}let e=Oe();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 wt(){if(typeof he=="function")try{let t=he();if(typeof t=="function")return t}catch{}let e=Oe();return typeof e?.logHandler=="function"?e.logHandler:null}function $e(e,t,...n){if(typeof console>"u")return;let r=typeof console[e]=="function"?console[e].bind(console):typeof console.log=="function"?console.log.bind(console):null;r&&(n.length>0?r(t,...n):r(t))}function bt(e,t){let n=t?.debug===!0;return!(t?.mode==="static"&&!n||!n&&e!=="error"&&e!=="warn")}function Ne({getLogger:e,getContext:t}={}){he=typeof e=="function"?e:null,ye=typeof t=="function"?t:null}function Ie(e="log",t,...n){let r=yt(e),a=gt(),s=wt();if(s)try{s.call(a?.thisArg,r,t,...n);return}catch(l){$e("error","Custom log handler failed:",l)}bt(r,a)&&$e(r,t,...n)}typeof o.initializing!="boolean"&&(o.initializing=!1);"currentPreset"in o||(o.currentPreset=null);typeof o.debug!="boolean"&&(o.debug=!1);"currentConfig"in o||(o.currentConfig=null);"compiled"in o||(o.compiled=null);typeof o.logHandler!="function"&&(o.logHandler=null);"mode"in o||(o.mode=null);var J=null,V=null,Y=null,Q=null,Z=null,X=null,We="__pdsLocalizationRuntime";function M(){if(X)return X;let e=o?.[We];return e&&typeof e=="object"?(X=e,e):null}function St(e){let t=e&&typeof e=="object"?e:null;X=t,o[We]=t}Ne({getLogger:()=>typeof o.logHandler=="function"?o.logHandler:null,getContext:()=>{let e=o?.mode||o?.compiled?.mode||(o?.registry?.isLive?"live":"static"),t=(o?.debug||o?.currentConfig?.debug||o?.currentConfig?.design?.debug||o?.compiled?.debug||o?.compiled?.design?.debug||!1)===!0;return{mode:e,debug:t,thisArg:o}}});o.log=(e="log",t,...n)=>{Ie(e,t,...n)};var A={locale:"en",messages:{},hasProvider:!1},ee=new Set;function Be(e){return!!e&&typeof e!="string"&&typeof e=="object"&&"strTag"in e}function He(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 _t(e,t){return String(e).replace(/\{(\d+)\}/g,(n,r)=>t(Number(r)))}function Lt(e){if(!e||typeof e!="object")return{};let t={};for(let[n,r]of Object.entries(e)){if(typeof r=="string"){t[n]=r;continue}r&&typeof r=="object"&&typeof r.content=="string"&&(t[n]=r.content)}return t}function Et(e,...t){return{strTag:!0,strings:Array.from(e||[]),values:t,raw:Array.from(e?.raw||[])}}function vt(e){if(!e)return"";if(Be(e)){let n=He(e.strings||[]),r=A.messages[n]||n;return _t(r,a=>e.values?.[a])}let t=String(e);return A.messages[t]||t}function At(e){if(!e)return;let t=Be(e)?He(e.strings||[]):String(e);typeof t=="string"&&t.length>0&&ee.add(t)}function Ke(e){if(!e||typeof e.msg!="function"||ee.size===0)return;let t=Array.from(ee);ee.clear();for(let n of t)try{e.msg(n)}catch{}}async function N(){let e=M();return e||(Z||(Z=import(I("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 St(n),Ke(n),n}).catch(n=>{throw Z=null,n})),Z)}var Ge=(e,t={})=>{let n=M();return typeof n?.msg=="function"?n.msg(e,t):(At(e),vt(e,t))},qe=(e,...t)=>{let n=M();return typeof n?.str=="function"?n.str(e,...t):Et(e,...t)},te=(e=null)=>{let t=M();if(typeof t?.configureLocalization=="function")return t.configureLocalization(e);if(!e||typeof e!="object")return A.locale="en",A.messages={},A.hasProvider=!1,{locale:A.locale,messages:{...A.messages},hasProvider:A.hasProvider};typeof e.locale=="string"&&e.locale.trim()&&(A.locale=e.locale.trim()),Object.prototype.hasOwnProperty.call(e,"messages")&&(A.messages=Lt(e.messages));let n=!!(e.provider||e.translate||e.loadLocale||e.setLocale);return A.hasProvider=n,n&&N().then(r=>{r.configureLocalization(e),Ke(r)}).catch(()=>{}),{locale:A.locale,messages:{...A.messages},hasProvider:A.hasProvider}},Je=async e=>(await N()).loadLocale(e),Ve=async(e,t={})=>(await N()).setLocale(e,t),Ye=()=>{let e=M();return typeof e?.getLocalizationState=="function"?e.getLocalizationState():{locale:A.locale,messages:{...A.messages},hasProvider:A.hasProvider}},Qe=(e={})=>{let t=M();if(typeof t?.createJSONLocalization=="function")return t.createJSONLocalization(e);let n=typeof e?.locale=="string"&&e.locale.trim()?e.locale.trim().toLowerCase():"en",r=Array.isArray(e?.locales)?e.locales.map(g=>String(g||"").trim().toLowerCase()).filter(Boolean):[],a=Array.from(new Set([n,...r])),s=null,l=async()=>(s||(s=N().then(g=>typeof g?.createJSONLocalization=="function"?g.createJSONLocalization(e):null).catch(()=>null)),s),S=async(g="loadLocale")=>{let d=await l();if(!d||typeof d!="object")return null;let i=d.provider;if(!i||typeof i!="object")return null;let m=i[g];return typeof m=="function"?m:g==="setLocale"&&typeof i.loadLocale=="function"?i.loadLocale:null};return{locale:n,locales:[...a],provider:{locales:[...a],async loadLocale(g={}){let d=await S("loadLocale");return typeof d!="function"?{}:d(g)},async setLocale(g={}){let d=await S("setLocale");return typeof d!="function"?{}:d(g)}}}};function I(e,t){return t&&typeof t=="string"?t:`${q(o.currentConfig||{},{resolvePublicAssetURL:B})}core/${e}`}async function Pt(){return Array.isArray(o.defaultEnhancers)&&o.defaultEnhancers.length>0?o.defaultEnhancers:(Q||(Q=import(I("pds-enhancers.js",o.currentConfig?.enhancersURL)).then(t=>{let n=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return o.defaultEnhancers=n,n}).catch(t=>{throw Q=null,t})),Q)}async function xt(){return typeof o.ask=="function"&&o.ask!==Ze?o.ask:(V||(V=import(I("pds-ask.js",o.currentConfig?.askURL)).then(t=>{let n=t?.ask;if(typeof n!="function")throw new Error("Failed to load ask helper");return o.ask=n,n}).catch(t=>{throw V=null,t})),V)}async function F(){return typeof o.toast=="function"&&o.toast!==k?o.toast:(Y||(Y=import(I("pds-toast.js",o.currentConfig?.toastURL)).then(t=>{let n=t?.toast;if(typeof n!="function")throw new Error("Failed to load toast helper");return o.toast=n,n}).catch(t=>{throw Y=null,t})),Y)}async function Ze(...e){return(await xt())(...e)}async function k(...e){return(await F())(...e)}k.success=async(...e)=>(await F()).success(...e);k.error=async(...e)=>(await F()).error(...e);k.warning=async(...e)=>(await F()).warning(...e);k.info=async(...e)=>(await F()).info(...e);var Fe=function(e="log",t,...n){o.log(e,t,...n)};function we(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=>we(n)).filter(n=>n!==void 0);let t={};for(let[n,r]of Object.entries(e)){let a=we(r);a!==void 0&&(t[n]=a)}return t}function Xe(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))Xe(e[n],t);return e}function be(e){return e==null||typeof e!="object"?e:Xe(structuredClone(we(e)))}async function Rt(e,t={}){if(t?.runtimeConfig===!1||typeof fetch!="function")return null;let n=t?.runtimeConfigURL||`${e}pds-runtime-config.json`;try{let r=await fetch(n,{cache:"no-store"});return r.ok?await r.json():null}catch{return null}}o.registry=T;o.enums=xe;o.adoptLayers=Ae;o.adoptPrimitives=ve;o.parse=ue;o.createStylesheet=Pe;o.isLiveMode=()=>T.isLive;o.ask=Ze;o.toast=k;o.common=de;o.msg=Ge;o.str=qe;o.configureLocalization=te;o.loadLocale=Je;o.setLocale=Ve;o.getLocalizationState=Ye;o.createJSONLocalization=Qe;o.i18n={msg:Ge,str:qe,configure:te,loadLocale:Je,setLocale:Ve,getState:Ye,createJSONLocalization:Qe};o.AutoComplete=null;o.loadAutoComplete=async()=>{if(o.AutoComplete&&typeof o.AutoComplete.connect=="function")return o.AutoComplete;let e=I("pds-autocomplete.js",o.currentConfig?.autoCompleteURL);return J||(J=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 o.AutoComplete=n,n}).catch(t=>{throw J=null,t})),J};function et(e){let t=typeof CustomEvent=="function";try{let n=t?new CustomEvent("pds:ready",{detail:e}):new Event("pds:ready");o.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 tt(e={}){let t=typeof CustomEvent=="function",n={at:Date.now(),...e};try{let r=t?new CustomEvent("pds:config-changed",{detail:n}):new Event("pds:config-changed");o.dispatchEvent(r)}catch{}if(typeof document<"u")if(t){let r={detail:n,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:config-changed",r))}catch{}}else try{document.dispatchEvent(new Event("pds:config-changed"))}catch{}}var ge="pure-ds-theme",D=null,O=null;function ne(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 re(e){try{if(D&&O){try{typeof D.removeEventListener=="function"?D.removeEventListener("change",O):typeof D.removeListener=="function"&&D.removeListener(O)}catch{}D=null,O=null}if(e==="system"&&typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=r=>{let a=r?.matches===void 0?t.matches:r.matches;try{let s=a?"dark":"light";document.documentElement.setAttribute("data-theme",s),o.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:s,source:"system"}}))}catch{}};D=t,O=n,typeof t.addEventListener=="function"?t.addEventListener("change",n):typeof t.addListener=="function"&&t.addListener(n)}}catch{}}var Dt=Object.getOwnPropertyDescriptor(o,"theme");Dt||Object.defineProperty(o,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(ge)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=o.currentConfig?.design||null,n=me(e);if(t&&!je(t,n)){let r=t?.name||o.currentPreset?.name||o.currentConfig?.preset||"current preset";o.log("warn",`PDS theme "${n}" not supported by preset "${r}".`),o.dispatchEvent(new CustomEvent("pds:theme:blocked",{detail:{theme:e,resolvedTheme:n,preset:r}}));return}e==null?localStorage.removeItem(ge):localStorage.setItem(ge,e),ne(e),re(e),o.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});o.defaultEnhancers=[];async function zt(e){o.initializing=!0;try{let t=e&&e.mode||"live",{mode:n,...r}=e||{};o.mode=t,o.logHandler=typeof r?.log=="function"?r.log:null,o.currentConfig=be(r);let a=r&&typeof r.localization=="object"&&r.localization?r.localization:null;a?(await N(),te(a)):te(null);let s;if(t==="static")s=await Ct(r);else{let{localization:S,...g}=r||{},d=q(g,{resolvePublicAssetURL:B}),i=g?.managerURL||g?.public?.managerURL||g?.manager?.url||new URL("core/pds-manager.js",d).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:m}=await import(i);s=await m(o,g,{emitReady:et,emitConfigChanged:tt,applyResolvedTheme:ne,setupSystemListenerIfNeeded:re})}o.compiled=be(s?.config||null);let l=o?.compiled?.design?.icons?.externalPath||"/assets/img/icons/";return o.log("info",`startup ready; external icon path: ${l}`),s}finally{o.initializing=!1}}o.start=zt;async function Ct(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,r=e.themeStorageKey??"pure-ds-theme",a=e.staticPaths??{},s=q(e,{resolvePublicAssetURL:B}),l=e&&e.autoDefine||null,S;l&&l.baseURL?S=K(G(l.baseURL,{preferModule:!1})):S=`${s}components/`;let g=l&&Array.isArray(l.predefine)&&l.predefine||[],d=l&&typeof l.mapper=="function"&&l.mapper||null;try{Me(o);let{resolvedTheme:i}=ke({manageTheme:n,themeStorageKey:r,applyResolvedTheme:ne,setupSystemListenerIfNeeded:re}),m=await Rt(s,e),P=Array.isArray(e?.enhancers)?e.enhancers:e?.enhancers&&typeof e.enhancers=="object"?Object.values(e.enhancers):[],L=m?.config?{...m.config,...e,design:e?.design||m.config.design,preset:e?.preset||m.config.preset}:{...e},c={tokens:`${s}styles/pds-tokens.css.js`,primitives:`${s}styles/pds-primitives.css.js`,components:`${s}styles/pds-components.css.js`,utilities:`${s}styles/pds-utilities.css.js`,styles:`${s}styles/pds-styles.css.js`},y=m?.paths||{};if(a={...c,...y,...a},o.registry.setStaticMode(a),t&&typeof document<"u")try{let w=await o.registry.getStylesheet("styles");if(w){w._pds=!0;let u=(document.adoptedStyleSheets||[]).filter(b=>b._pds!==!0);document.adoptedStyleSheets=[...u,w],tt({mode:"static",source:"static:styles-applied"})}}catch(w){Fe.call(o,"warn","Failed to apply static styles:",w)}let _=null,v=[];try{let w=await Pt(),u=await Ue({autoDefineBaseURL:S,autoDefinePreload:g,autoDefineMapper:d,enhancers:P,autoDefineOverrides:l||null,autoDefinePreferModule:!(l&&l.baseURL)},{baseEnhancers:w});_=u.autoDefiner,v=u.mergedEnhancers||[]}catch(w){Fe.call(o,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",w)}return o.compiled=be({mode:"static",...L,theme:i,enhancers:v}),et({mode:"static",config:L,theme:i,autoDefiner:_}),{config:L,theme:i,autoDefiner:_}}catch(i){throw o.dispatchEvent(new CustomEvent("pds:error",{detail:{error:i}})),i}}var tn=ne,nn=re;export{o as PDS,tn as applyResolvedTheme,te as configureLocalization,Qe as createJSONLocalization,Ye as getLocalizationState,Je as loadLocale,Ge as msg,Ve as setLocale,nn as setupSystemListenerIfNeeded,qe as str};
|
package/src/js/common/common.js
CHANGED
|
@@ -31,20 +31,48 @@ export function fragmentFromTemplateLike(templateLike) {
|
|
|
31
31
|
const htmlParts = [];
|
|
32
32
|
|
|
33
33
|
const propBindingPattern = /(\s)(\.[\w-]+)=\s*$/;
|
|
34
|
+
const eventBindingPattern = /(\s)(@[\w-]+)=\s*$/;
|
|
35
|
+
const booleanBindingPattern = /(\s)(\?[\w-]+)=\s*$/;
|
|
36
|
+
const attrBindingPattern = /(\s)([\w:-]+)=\s*$/;
|
|
34
37
|
|
|
35
38
|
for (let i = 0; i < strings.length; i += 1) {
|
|
36
39
|
let chunk = strings[i] ?? "";
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (match && i < values.length) {
|
|
40
|
-
const propToken = match[2];
|
|
41
|
-
const propName = propToken.slice(1);
|
|
40
|
+
if (i < values.length) {
|
|
42
41
|
const marker = `pds-val-${i}`;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
);
|
|
47
|
-
|
|
42
|
+
const propMatch = chunk.match(propBindingPattern);
|
|
43
|
+
const eventMatch = chunk.match(eventBindingPattern);
|
|
44
|
+
const boolMatch = chunk.match(booleanBindingPattern);
|
|
45
|
+
const attrMatch = chunk.match(attrBindingPattern);
|
|
46
|
+
|
|
47
|
+
if (propMatch) {
|
|
48
|
+
const propName = propMatch[2].slice(1);
|
|
49
|
+
chunk = chunk.replace(
|
|
50
|
+
propBindingPattern,
|
|
51
|
+
`$1data-pds-bind-${i}="prop:${propName}:${marker}"`
|
|
52
|
+
);
|
|
53
|
+
consumedValues.add(i);
|
|
54
|
+
} else if (eventMatch) {
|
|
55
|
+
const eventName = eventMatch[2].slice(1);
|
|
56
|
+
chunk = chunk.replace(
|
|
57
|
+
eventBindingPattern,
|
|
58
|
+
`$1data-pds-bind-${i}="event:${eventName}:${marker}"`
|
|
59
|
+
);
|
|
60
|
+
consumedValues.add(i);
|
|
61
|
+
} else if (boolMatch) {
|
|
62
|
+
const attrName = boolMatch[2].slice(1);
|
|
63
|
+
chunk = chunk.replace(
|
|
64
|
+
booleanBindingPattern,
|
|
65
|
+
`$1data-pds-bind-${i}="boolean:${attrName}:${marker}"`
|
|
66
|
+
);
|
|
67
|
+
consumedValues.add(i);
|
|
68
|
+
} else if (attrMatch) {
|
|
69
|
+
const attrName = attrMatch[2];
|
|
70
|
+
chunk = chunk.replace(
|
|
71
|
+
attrBindingPattern,
|
|
72
|
+
`$1data-pds-bind-${i}="attr:${attrName}:${marker}"`
|
|
73
|
+
);
|
|
74
|
+
consumedValues.add(i);
|
|
75
|
+
}
|
|
48
76
|
}
|
|
49
77
|
|
|
50
78
|
htmlParts.push(chunk);
|
|
@@ -99,24 +127,84 @@ export function fragmentFromTemplateLike(templateLike) {
|
|
|
99
127
|
|
|
100
128
|
const elements = tpl.content.querySelectorAll("*");
|
|
101
129
|
elements.forEach((el) => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
130
|
+
[...el.attributes].forEach((attr) => {
|
|
131
|
+
if (!attr.name.startsWith("data-pds-bind-")) return;
|
|
132
|
+
|
|
133
|
+
const firstColon = attr.value.indexOf(":");
|
|
134
|
+
const lastColon = attr.value.lastIndexOf(":");
|
|
135
|
+
if (firstColon <= 0 || lastColon <= firstColon) {
|
|
136
|
+
el.removeAttribute(attr.name);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const kind = attr.value.slice(0, firstColon);
|
|
141
|
+
const bindingName = attr.value.slice(firstColon + 1, lastColon);
|
|
142
|
+
const markerValue = attr.value.slice(lastColon + 1);
|
|
143
|
+
const index = Number(String(markerValue).replace("pds-val-", ""));
|
|
144
|
+
const value = values[index];
|
|
145
|
+
|
|
146
|
+
if (!bindingName || !Number.isInteger(index)) {
|
|
147
|
+
el.removeAttribute(attr.name);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (kind === "prop") {
|
|
152
|
+
el[bindingName] = value;
|
|
153
|
+
} else if (kind === "event") {
|
|
154
|
+
if (typeof value === "function" || (value && typeof value.handleEvent === "function")) {
|
|
155
|
+
el.addEventListener(bindingName, value);
|
|
156
|
+
}
|
|
157
|
+
} else if (kind === "boolean") {
|
|
158
|
+
if (value) {
|
|
159
|
+
el.setAttribute(bindingName, "");
|
|
160
|
+
} else {
|
|
161
|
+
el.removeAttribute(bindingName);
|
|
162
|
+
}
|
|
163
|
+
} else if (kind === "attr") {
|
|
164
|
+
if (value == null || value === false) {
|
|
165
|
+
el.removeAttribute(bindingName);
|
|
166
|
+
} else {
|
|
167
|
+
el.setAttribute(bindingName, String(value));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
el.removeAttribute(attr.name);
|
|
172
|
+
});
|
|
110
173
|
});
|
|
111
174
|
|
|
112
175
|
return tpl.content;
|
|
113
176
|
}
|
|
114
177
|
|
|
115
178
|
/**
|
|
116
|
-
* Parses an HTML string
|
|
117
|
-
*
|
|
179
|
+
* Parses either an HTML string or a tagged template into DOM nodes.
|
|
180
|
+
*
|
|
181
|
+
* Supports two modes:
|
|
182
|
+
* 1. String mode: PDS.parse(htmlString) - returns NodeList, no binding support
|
|
183
|
+
* Example: PDS.parse(`<button class="btn">Click</button>`)
|
|
184
|
+
*
|
|
185
|
+
* 2. Tagged template mode: PDS.parse`...` - supports Lit-like bindings
|
|
186
|
+
* Bindings: `.prop=${value}`, `@event=${handler}`, `?boolean=${flag}`, `attr=${value}`
|
|
187
|
+
* Example: PDS.parse`<h1 @click=${handler}>...</h1>`
|
|
188
|
+
*
|
|
189
|
+
* @param {string | TemplateStringsArray | {strings: string[], values: unknown[]}} html
|
|
190
|
+
* @param {...unknown} values
|
|
118
191
|
* @returns {NodeListOf<ChildNode>}
|
|
119
192
|
*/
|
|
120
|
-
export function parseHTML(html) {
|
|
121
|
-
|
|
122
|
-
|
|
193
|
+
export function parseHTML(html, ...values) {
|
|
194
|
+
// Tagged template mode: html is TemplateStringsArray
|
|
195
|
+
const isTaggedTemplate =
|
|
196
|
+
Array.isArray(html) && Object.prototype.hasOwnProperty.call(html, "raw");
|
|
197
|
+
|
|
198
|
+
if (isTaggedTemplate) {
|
|
199
|
+
return fragmentFromTemplateLike({ strings: Array.from(html), values }).childNodes;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Object mode: {strings, values} prepared shape
|
|
203
|
+
if (Array.isArray(html?.strings) && Array.isArray(html?.values)) {
|
|
204
|
+
return fragmentFromTemplateLike({ strings: html.strings, values: html.values }).childNodes;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// String mode: plain HTML string (no binding support)
|
|
208
|
+
// This is the backward-compatible path
|
|
209
|
+
return new DOMParser().parseFromString(String(html ?? ""), "text/html").body.childNodes;
|
|
210
|
+
}
|
|
@@ -3397,14 +3397,18 @@ a.btn-working {
|
|
|
3397
3397
|
|
|
3398
3398
|
/* Skeleton loading animation */
|
|
3399
3399
|
.skeleton {
|
|
3400
|
+
--skeleton-base: color-mix(in oklab, var(--color-text-primary) 8%, transparent);
|
|
3401
|
+
--skeleton-highlight: color-mix(in oklab, var(--color-text-primary) 16%, transparent);
|
|
3400
3402
|
background: linear-gradient(
|
|
3401
3403
|
90deg,
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3404
|
+
var(--skeleton-base) 0%,
|
|
3405
|
+
var(--skeleton-highlight) 50%,
|
|
3406
|
+
var(--skeleton-base) 100%
|
|
3405
3407
|
);
|
|
3406
3408
|
background-size: 200% 100%;
|
|
3407
|
-
animation:
|
|
3409
|
+
animation:
|
|
3410
|
+
pds-skeleton-fade-in 220ms ease-out both,
|
|
3411
|
+
pds-skeleton 1.5s ease-in-out infinite 220ms;
|
|
3408
3412
|
border-radius: var(--radius-sm);
|
|
3409
3413
|
|
|
3410
3414
|
&::before {
|
|
@@ -3412,6 +3416,11 @@ a.btn-working {
|
|
|
3412
3416
|
}
|
|
3413
3417
|
}
|
|
3414
3418
|
|
|
3419
|
+
@keyframes pds-skeleton-fade-in {
|
|
3420
|
+
from { opacity: 0; }
|
|
3421
|
+
to { opacity: 1; }
|
|
3422
|
+
}
|
|
3423
|
+
|
|
3415
3424
|
@keyframes pds-skeleton {
|
|
3416
3425
|
0% { background-position: 200% 0; }
|
|
3417
3426
|
100% { background-position: -200% 0; }
|
|
@@ -4503,7 +4512,7 @@ a.icon-only {
|
|
|
4503
4512
|
/* Basic dropdown host */
|
|
4504
4513
|
nav[data-dropdown] {
|
|
4505
4514
|
position: relative;
|
|
4506
|
-
display:
|
|
4515
|
+
display: flex;
|
|
4507
4516
|
padding: 0;
|
|
4508
4517
|
|
|
4509
4518
|
& > :last-child {
|