@pure-ds/core 0.7.53 → 0.7.54
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/pds.d.ts +9 -6
- package/dist/types/public/assets/pds/components/pds-toaster.d.ts +12 -2
- package/dist/types/public/assets/pds/components/pds-toaster.d.ts.map +1 -1
- package/dist/types/src/js/common/common.d.ts.map +1 -1
- package/dist/types/src/js/common/toast.d.ts +20 -10
- package/dist/types/src/js/common/toast.d.ts.map +1 -1
- package/package.json +1 -1
- package/public/assets/js/app.js +5 -5
- package/public/assets/js/pds-ask.js +9 -9
- package/public/assets/js/pds-manager.js +78 -78
- package/public/assets/js/pds.js +2 -2
- package/public/assets/pds/components/pds-toaster.js +22 -1
- package/public/assets/pds/core/pds-ask.js +9 -9
- package/public/assets/pds/core/pds-manager.js +78 -78
- package/public/assets/pds/core.js +2 -2
- package/src/js/common/common.js +20 -4
- package/src/js/common/toast.js +14 -5
- package/src/js/pds-core/pds-enhancers-meta.js +135 -135
- package/src/js/pds.d.ts +9 -6
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var ot=Object.defineProperty;var st=(e,t)=>{for(var n in t)ot(e,n,{get:t[n],enumerable:!0})};var ae=class extends EventTarget{constructor(){super(),this.mode=null,this.compiled=null,this.log=()=>{},this.logHandler=null}},ve="__PURE_DS_PDS_SINGLETON__",ce=typeof globalThis<"u"?globalThis:window,ie=ce?.[ve],o=ie&&typeof ie.addEventListener=="function"?ie:new ae;ce&&(ce[ve]=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 le=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"}},C=new le;async function Ae(e,t=[],n=null){try{let r=n?.primitivesStylesheet?n.primitivesStylesheet:await C.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 Pe(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 C.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 xe(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var Re={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 fe={};st(fe,{deepMerge:()=>De,fragmentFromTemplateLike:()=>ue,isObject:()=>W,parseFragment:()=>B,parseHTML:()=>de});function W(e){return e&&typeof e=="object"&&!Array.isArray(e)}function De(e,t){let n={...e};return W(e)&&W(t)&&Object.keys(t).forEach(r=>{W(t[r])?r in e?n[r]=De(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})}),n}function ue(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 B(e,...t){if(Array.isArray(e)&&Object.prototype.hasOwnProperty.call(e,"raw"))return ue({strings:Array.from(e),values:t});if(Array.isArray(e?.strings)&&Array.isArray(e?.values))return ue({strings:e.strings,values:e.values});let r=document.createElement("template");return r.innerHTML=String(e??""),r.content}function de(e,...t){return B(e,...t).childNodes}var ze="pds",it=/^([a-z][a-z0-9+\-.]*:)?\/\//i,Te=/^[a-z]:/i;function j(e=""){return e.endsWith("/")?e:`${e}/`}function at(e="",t=ze){let n=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(n)?n:`${n}/${t}`}function ct(e){return e.replace(/^\.\/+/,"")}function lt(e){return Te.test(e)?e.replace(Te,"").replace(/^\/+/,""):e}function ut(e){return e.startsWith("public/")?e.substring(7):e}function H(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=at(s,n),s=j(s),it.test(s)?s:(s=ct(s),s=lt(s),s.startsWith("/")||(s=ut(s),s.startsWith("/")||(s=`/${s}`),s=s.replace(/\/+/g,(l,S)=>S===0?l:"/")),j(s))):j(r)}async function dt(...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 K=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),rt()}},rt=()=>{u||(u=setTimeout(_e,d))},T=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&&se(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&&se(h.shadowRoot)})}},se=f=>{if(!f||v.has(f))return;T(f);let h=new MutationObserver(p=>{for(let R of p)R.addedNodes?.forEach(z=>{T(z)}),R.type==="attributes"&&R.target&&T(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 _e(){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 dt(...f,{baseURL:n,mapper:h,onError:(p,R)=>{y.add(p),a?.(p,R)}})}catch{}finally{f.forEach(h=>c.delete(h))}}let Le=S===document?document.documentElement:S,Ee=new MutationObserver(f=>{for(let h of f)h.addedNodes?.forEach(p=>{T(p)}),h.type==="attributes"&&h.target&&T(h.target)});if(Ee.observe(Le,{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"){se(R);let z=this.tagName?.toLowerCase();z&&z.includes("-")&&!customElements.get(z)&&U(z,this)}return R},E=()=>Element.prototype.attachShadow=f}return g&&T(Le),{stop(){b=!0,Ee.disconnect(),E&&E(),u&&(clearTimeout(u),u=0),v.forEach(f=>f.disconnect())},flush:_e}}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 ft=/^[a-z][a-z0-9+\-.]*:\/\//i,$=(()=>{try{return import.meta.url}catch{return}})(),G=e=>typeof e=="string"&&e.length&&!e.endsWith("/")?`${e}/`:e;function q(e,t={}){if(!e||ft.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}})(),Me=!1;function ke(e){Me||typeof document>"u"||(Me=!0,e.addEventListener("pds:ready",t=>{let n=t.detail?.mode;n&&document.documentElement.classList.add(`pds-${n}`,"pds-ready")}))}function Ue({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 J(e,{resolvePublicAssetURL:t}){let n=!!(e?.public?.root||e?.static?.root),r=t(e);return!n&&Ce&&(r=Ce),G(q(r))}async function je(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=K,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&&G(q(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 pe=["light","dark"],me=new Set(pe);function pt(e){let n=(Array.isArray(e?.themes)?e.themes.map(r=>String(r).toLowerCase()):pe).filter(r=>me.has(r));return n.length?n:pe}function he(e,{preferDocument:t=!0}={}){let n=String(e||"").toLowerCase();if(me.has(n))return n;if(t&&typeof document<"u"){let r=document.documentElement?.getAttribute("data-theme");if(me.has(r))return r}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function $e(e,t){let n=he(t);return pt(e).includes(n)}var mt=new Set(["log","warn","error","debug","info"]),ht="__PURE_DS_PDS_SINGLETON__",ye=null,ge=null;function Ne(){try{let t=(typeof globalThis<"u"?globalThis:window)?.[ht];if(t&&typeof t=="object")return t}catch{return null}return null}function yt(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 gt(e){if(typeof e!="string")return"log";let t=e.toLowerCase();return mt.has(t)?t:"log"}function wt(){if(typeof ge=="function")try{let t=yt(ge());if(t)return t}catch{}let e=Ne();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 bt(){if(typeof ye=="function")try{let t=ye();if(typeof t=="function")return t}catch{}let e=Ne();return typeof e?.logHandler=="function"?e.logHandler:null}function Oe(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 St(e,t){let n=t?.debug===!0;return!(t?.mode==="static"&&!n||!n&&e!=="error"&&e!=="warn")}function Ie({getLogger:e,getContext:t}={}){ye=typeof e=="function"?e:null,ge=typeof t=="function"?t:null}function Fe(e="log",t,...n){let r=gt(e),a=wt(),s=bt();if(s)try{s.call(a?.thisArg,r,t,...n);return}catch(l){Oe("error","Custom log handler failed:",l)}St(r,a)&&Oe(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 V=null,Y=null,Q=null,Z=null,X=null,ee=null,Be="__pdsLocalizationRuntime";function M(){if(ee)return ee;let e=o?.[Be];return e&&typeof e=="object"?(ee=e,e):null}function _t(e){let t=e&&typeof e=="object"?e:null;ee=t,o[Be]=t}Ie({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)=>{Fe(e,t,...n)};var A={locale:"en",messages:{},hasProvider:!1},te=new Set;function He(e){return!!e&&typeof e!="string"&&typeof e=="object"&&"strTag"in e}function Ke(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 Lt(e,t){return String(e).replace(/\{(\d+)\}/g,(n,r)=>t(Number(r)))}function Et(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 vt(e,...t){return{strTag:!0,strings:Array.from(e||[]),values:t,raw:Array.from(e?.raw||[])}}function At(e){if(!e)return"";if(He(e)){let n=Ke(e.strings||[]),r=A.messages[n]||n;return Lt(r,a=>e.values?.[a])}let t=String(e);return A.messages[t]||t}function Pt(e){if(!e)return;let t=He(e)?Ke(e.strings||[]):String(e);typeof t=="string"&&t.length>0&&te.add(t)}function Ge(e){if(!e||typeof e.msg!="function"||te.size===0)return;let t=Array.from(te);te.clear();for(let n of t)try{e.msg(n)}catch{}}async function N(){let e=M();return e||(X||(X=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 _t(n),Ge(n),n}).catch(n=>{throw X=null,n})),X)}var qe=(e,t={})=>{let n=M();return typeof n?.msg=="function"?n.msg(e,t):(Pt(e),At(e,t))},Je=(e,...t)=>{let n=M();return typeof n?.str=="function"?n.str(e,...t):vt(e,...t)},ne=(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=Et(e.messages));let n=!!(e.provider||e.translate||e.loadLocale||e.setLocale);return A.hasProvider=n,n&&N().then(r=>{r.configureLocalization(e),Ge(r)}).catch(()=>{}),{locale:A.locale,messages:{...A.messages},hasProvider:A.hasProvider}},Ve=async e=>(await N()).loadLocale(e),Ye=async(e,t={})=>(await N()).setLocale(e,t),Qe=()=>{let e=M();return typeof e?.getLocalizationState=="function"?e.getLocalizationState():{locale:A.locale,messages:{...A.messages},hasProvider:A.hasProvider}},Ze=(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:`${J(o.currentConfig||{},{resolvePublicAssetURL:H})}core/${e}`}async function xt(){return Array.isArray(o.defaultEnhancers)&&o.defaultEnhancers.length>0?o.defaultEnhancers:(Z||(Z=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 Z=null,t})),Z)}async function Rt(){return typeof o.ask=="function"&&o.ask!==Xe?o.ask:(Y||(Y=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 Y=null,t})),Y)}async function F(){return typeof o.toast=="function"&&o.toast!==k?o.toast:(Q||(Q=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 Q=null,t})),Q)}async function Xe(...e){return(await Rt())(...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 We=function(e="log",t,...n){o.log(e,t,...n)};function be(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=>be(n)).filter(n=>n!==void 0);let t={};for(let[n,r]of Object.entries(e)){let a=be(r);a!==void 0&&(t[n]=a)}return t}function et(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))et(e[n],t);return e}function Se(e){return e==null||typeof e!="object"?e:et(structuredClone(be(e)))}async function Dt(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=C;o.enums=Re;o.adoptLayers=Pe;o.adoptPrimitives=Ae;var Tt=de;o.parse=Tt;var zt=B;o.html=zt;o.createStylesheet=xe;o.isLiveMode=()=>C.isLive;o.ask=Xe;o.toast=k;o.common=fe;o.msg=qe;o.str=Je;o.configureLocalization=ne;o.loadLocale=Ve;o.setLocale=Ye;o.getLocalizationState=Qe;o.createJSONLocalization=Ze;o.i18n={msg:qe,str:Je,configure:ne,loadLocale:Ve,setLocale:Ye,getState:Qe,createJSONLocalization:Ze};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 V||(V=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 V=null,t})),V};function tt(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 nt(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 we="pure-ds-theme",D=null,O=null;function re(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(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 Ct=Object.getOwnPropertyDescriptor(o,"theme");Ct||Object.defineProperty(o,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(we)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=o.currentConfig?.design||null,n=he(e);if(t&&!$e(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(we):localStorage.setItem(we,e),re(e),oe(e),o.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});o.defaultEnhancers=[];async function Mt(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=Se(r);let a=r&&typeof r.localization=="object"&&r.localization?r.localization:null;a?(await N(),ne(a)):ne(null);let s;if(t==="static")s=await kt(r);else{let{localization:S,...g}=r||{},d=J(g,{resolvePublicAssetURL:H}),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:tt,emitConfigChanged:nt,applyResolvedTheme:re,setupSystemListenerIfNeeded:oe})}o.compiled=Se(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=Mt;async function kt(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=J(e,{resolvePublicAssetURL:H}),l=e&&e.autoDefine||null,S;l&&l.baseURL?S=G(q(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{ke(o);let{resolvedTheme:i}=Ue({manageTheme:n,themeStorageKey:r,applyResolvedTheme:re,setupSystemListenerIfNeeded:oe}),m=await Dt(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],nt({mode:"static",source:"static:styles-applied"})}}catch(w){We.call(o,"warn","Failed to apply static styles:",w)}let _=null,v=[];try{let w=await xt(),u=await je({autoDefineBaseURL:S,autoDefinePreload:g,autoDefineMapper:d,enhancers:P,autoDefineOverrides:l||null,autoDefinePreferModule:!(l&&l.baseURL)},{baseEnhancers:w});_=u.autoDefiner,v=u.mergedEnhancers||[]}catch(w){We.call(o,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",w)}return o.compiled=Se({mode:"static",...L,theme:i,enhancers:v}),tt({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 on=re,sn=oe;export{o as PDS,on as applyResolvedTheme,ne as configureLocalization,Ze as createJSONLocalization,Qe as getLocalizationState,zt as html,Ve as loadLocale,qe as msg,Tt as parse,Ye as setLocale,sn as setupSystemListenerIfNeeded,Je as str};
|
|
1
|
+
var rt=Object.defineProperty;var st=(e,t)=>{for(var n in t)rt(e,n,{get:t[n],enumerable:!0})};var ce=class extends EventTarget{constructor(){super(),this.mode=null,this.compiled=null,this.log=()=>{},this.logHandler=null}},Ae="__PURE_DS_PDS_SINGLETON__",le=typeof globalThis<"u"?globalThis:window,ae=le?.[Ae],r=ae&&typeof ae.addEventListener=="function"?ae:new ce;le&&(le[Ae]=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 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){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"}},k=new ue;async function Pe(e,t=[],n=null){try{let o=n?.primitivesStylesheet?n.primitivesStylesheet:await k.getStylesheet("primitives");e.adoptedStyleSheets=[o,...t]}catch(o){let a=e.host?.tagName?.toLowerCase()||"unknown";r.log("error",`Adopter: <${a}> failed to adopt primitives:`,o),e.adoptedStyleSheets=t}}async function xe(e,t=["primitives"],n=[],o=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(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 k.getStylesheet(S)}))).filter(S=>S!==null);e.adoptedStyleSheets=[...l,...a]}catch(s){let l=e.host?.tagName?.toLowerCase()||"unknown";r.log("error",`Adopter: <${l}> failed to adopt layers:`,s),e.adoptedStyleSheets=a}}function Re(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var De={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 pe={};st(pe,{deepMerge:()=>Te,fragmentFromTemplateLike:()=>de,isObject:()=>B,parseFragment:()=>H,parseHTML:()=>fe});function B(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Te(e,t){let n={...e};return B(e)&&B(t)&&Object.keys(t).forEach(o=>{B(t[o])?o in e?n[o]=Te(e[o],t[o]):Object.assign(n,{[o]:t[o]}):Object.assign(n,{[o]:t[o]})}),n}function de(e){let t=Array.isArray(e?.strings)?e.strings:[],n=Array.isArray(e?.values)?e.values:[],o=new Set,a=[],s=/(\s)(\.[\w-]+)=["']?\s*$/,l=/(\s)(@[\w-]+)=["']?\s*$/,S=/(\s)(\?[\w-]+)=["']?\s*$/,w=/(\s)([\w:-]+)=["']?\s*$/,u=/=["']\s*$/,i=!1;for(let c=0;c<t.length;c+=1){let y=t[c]??"";if(i&&(y=y.replace(/^["']/,""),i=!1),c<n.length){let b=`pds-val-${c}`,d=y.match(s),h=y.match(l),L=y.match(S),D=y.match(w);if(d){let v=d[2].slice(1);i=u.test(t[c]??""),y=y.replace(s,`$1data-pds-bind-${c}="prop:${v}:${b}"`),o.add(c)}else if(h){let v=h[2].slice(1);i=u.test(t[c]??""),y=y.replace(l,`$1data-pds-bind-${c}="event:${v}:${b}"`),o.add(c)}else if(L){let v=L[2].slice(1);i=u.test(t[c]??""),y=y.replace(S,`$1data-pds-bind-${c}="boolean:${v}:${b}"`),o.add(c)}else if(D){let v=D[2];i=u.test(t[c]??""),y=y.replace(w,`$1data-pds-bind-${c}="attr:${v}:${b}"`),o.add(c)}}a.push(y),c<n.length&&!o.has(c)&&a.push(`<!--pds-val-${c}-->`)}let f=document.createElement("template");f.innerHTML=a.join("");let A=(c,y)=>{let b=c.parentNode;if(!b)return;if(y==null){b.removeChild(c);return}let d=h=>{if(h!=null){if(h instanceof Node){b.insertBefore(h,c);return}if(Array.isArray(h)){h.forEach(L=>d(L));return}b.insertBefore(document.createTextNode(String(h)),c)}};d(y),b.removeChild(c)},_=document.createTreeWalker(f.content,NodeFilter.SHOW_COMMENT),P=[];for(;_.nextNode();){let c=_.currentNode;c?.nodeValue?.startsWith("pds-val-")&&P.push(c)}return P.forEach(c=>{let y=Number(c.nodeValue.replace("pds-val-",""));A(c,n[y])}),f.content.querySelectorAll("*").forEach(c=>{[...c.attributes].forEach(y=>{if(!y.name.startsWith("data-pds-bind-"))return;let b=y.value.indexOf(":"),d=y.value.lastIndexOf(":");if(b<=0||d<=b){c.removeAttribute(y.name);return}let h=y.value.slice(0,b),L=y.value.slice(b+1,d),D=y.value.slice(d+1),v=Number(String(D).replace("pds-val-","")),x=n[v];if(!L||!Number.isInteger(v)){c.removeAttribute(y.name);return}h==="prop"?c[L]=x:h==="event"?(typeof x=="function"||x&&typeof x.handleEvent=="function")&&c.addEventListener(L,x):h==="boolean"?x?c.setAttribute(L,""):c.removeAttribute(L):h==="attr"&&(x==null||x===!1?c.removeAttribute(L):c.setAttribute(L,String(x))),c.removeAttribute(y.name)})}),f.content}function H(e,...t){if(Array.isArray(e)&&Object.prototype.hasOwnProperty.call(e,"raw"))return de({strings:Array.from(e),values:t});if(Array.isArray(e?.strings)&&Array.isArray(e?.values))return de({strings:e.strings,values:e.values});let o=document.createElement("template");return o.innerHTML=String(e??""),o.content}function fe(e,...t){return H(e,...t).childNodes}var Ce="pds",it=/^([a-z][a-z0-9+\-.]*:)?\/\//i,ze=/^[a-z]:/i;function $(e=""){return e.endsWith("/")?e:`${e}/`}function at(e="",t=Ce){let n=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(n)?n:`${n}/${t}`}function ct(e){return e.replace(/^\.\/+/,"")}function lt(e){return ze.test(e)?e.replace(ze,"").replace(/^\/+/,""):e}function ut(e){return e.startsWith("public/")?e.substring(7):e}function K(e,t={}){let n=t.segment||Ce,o=t.defaultRoot||`/assets/${n}/`,a=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!a||typeof a!="string")return $(o);let s=a.trim();return s?(s=s.replace(/\\/g,"/"),s=at(s,n),s=$(s),it.test(s)?s:(s=ct(s),s=lt(s),s.startsWith("/")||(s=ut(s),s.startsWith("/")||(s=`/${s}`),s=s.replace(/\/+/g,(l,S)=>S===0?l:"/")),$(s))):$(o)}async function dt(...e){let t={};e.length&&typeof e[e.length-1]=="object"&&(t=e.pop()||{});let n=e,{baseURL:o,mapper:a=u=>`${u}.js`,onError:s=(u,i)=>console.error(`[defineWebComponents] ${u}:`,i)}=t,l=o?new URL(o,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),S=u=>u.toLowerCase().replace(/(^|-)([a-z])/g,(i,f,A)=>A.toUpperCase()),w=async u=>{try{if(customElements.get(u))return{tag:u,status:"already-defined"};let i=a(u),A=await import(i instanceof URL?i.href:new URL(i,l).href),_=A?.default??A?.[S(u)];if(!_){if(customElements.get(u))return{tag:u,status:"self-defined"};throw new Error(`No export found for ${u}. Expected default export or named export "${S(u)}".`)}return customElements.get(u)?{tag:u,status:"race-already-defined"}:(customElements.define(u,_),{tag:u,status:"defined"})}catch(i){throw s(u,i),i}};return Promise.all(n.map(w))}var G=class{constructor(t={}){let{baseURL:n,mapper:o,onError:a,predicate:s=()=>!0,attributeModule:l="data-module",root:S=document,scanExisting:w=!0,debounceMs:u=16,observeShadows:i=!0,enhancers:f=[],patchAttachShadow:A=!0}=t,_=new Set,P=new Set,T=new Set,c=new Map,y=new WeakMap,b=new WeakMap,d=0,h=!1,L=null,D=p=>{if(!p||!f.length)return;let g=b.get(p);g||(g=new Set,b.set(p,g));for(let m of f)if(!(!m.selector||!m.run)&&!g.has(m.selector))try{p.matches&&p.matches(m.selector)&&(m.run(p),g.add(m.selector))}catch(R){console.warn(`[AutoDefiner] Error applying enhancer for selector "${m.selector}":`,R)}},v=(p,g)=>{if(!h&&!(!p||!p.includes("-"))&&!customElements.get(p)&&!P.has(p)&&!T.has(p)){if(g&&g.getAttribute){let m=g.getAttribute(l);m&&!c.has(p)&&c.set(p,m)}_.add(p),x()}},x=()=>{d||(d=setTimeout(Le,u))},C=p=>{if(p){if(p.nodeType===1){let g=p,m=g.tagName?.toLowerCase();m&&m.includes("-")&&!customElements.get(m)&&s(m,g)&&v(m,g),D(g),i&&g.shadowRoot&&ie(g.shadowRoot)}p.querySelectorAll&&p.querySelectorAll("*").forEach(g=>{let m=g.tagName?.toLowerCase();m&&m.includes("-")&&!customElements.get(m)&&s(m,g)&&v(m,g),D(g),i&&g.shadowRoot&&ie(g.shadowRoot)})}},ie=p=>{if(!p||y.has(p))return;C(p);let g=new MutationObserver(m=>{for(let R of m)R.addedNodes?.forEach(M=>{C(M)}),R.type==="attributes"&&R.target&&C(R.target)});g.observe(p,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...f.map(m=>m.selector).filter(m=>m.startsWith("data-"))]}),y.set(p,g)};async function Le(){if(clearTimeout(d),d=0,!_.size)return;let p=Array.from(_);_.clear(),p.forEach(g=>P.add(g));try{let g=m=>c.get(m)??(o?o(m):`${m}.js`);await dt(...p,{baseURL:n,mapper:g,onError:(m,R)=>{T.add(m),a?.(m,R)}})}catch{}finally{p.forEach(g=>P.delete(g))}}let Ee=S===document?document.documentElement:S,ve=new MutationObserver(p=>{for(let g of p)g.addedNodes?.forEach(m=>{C(m)}),g.type==="attributes"&&g.target&&C(g.target)});if(ve.observe(Ee,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...f.map(p=>p.selector).filter(p=>p.startsWith("data-"))]}),i&&A&&Element.prototype.attachShadow){let p=Element.prototype.attachShadow;Element.prototype.attachShadow=function(m){let R=p.call(this,m);if(m&&m.mode==="open"){ie(R);let M=this.tagName?.toLowerCase();M&&M.includes("-")&&!customElements.get(M)&&v(M,this)}return R},L=()=>Element.prototype.attachShadow=p}return w&&C(Ee),{stop(){h=!0,ve.disconnect(),L&&L(),d&&(clearTimeout(d),d=0),y.forEach(p=>p.disconnect())},flush:Le}}static async define(...t){let n={};t.length&&typeof t[t.length-1]=="object"&&(n=t.pop()||{});let o=t,{baseURL:a,mapper:s=i=>`${i}.js`,onError:l=(i,f)=>console.error(`[defineWebComponents] ${i}:`,f)}=n,S=a?new URL(a,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),w=i=>i.toLowerCase().replace(/(^|-)([a-z])/g,(f,A,_)=>_.toUpperCase()),u=async i=>{try{if(customElements.get(i))return{tag:i,status:"already-defined"};let f=s(i),_=await import(f instanceof URL?f.href:new URL(f,S).href),P=_?.default??_?.[w(i)];if(!P){if(customElements.get(i))return{tag:i,status:"self-defined"};throw new Error(`No export found for ${i}. Expected default export or named export "${w(i)}".`)}return customElements.get(i)?{tag:i,status:"race-already-defined"}:(customElements.define(i,P),{tag:i,status:"defined"})}catch(f){throw l(i,f),f}};return Promise.all(o.map(u))}};var ft=/^[a-z][a-z0-9+\-.]*:\/\//i,O=(()=>{try{return import.meta.url}catch{return}})(),q=e=>typeof e=="string"&&e.length&&!e.endsWith("/")?`${e}/`:e;function J(e,t={}){if(!e||ft.test(e))return e;let{preferModule:n=!0}=t,o=()=>{if(!O)return null;try{return new URL(e,O).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?o()||a():a()||o())||e}var Me=(()=>{if(O)try{let e=new URL(O);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",O).href}catch{return}})(),ke=!1;function Ue(e){ke||typeof document>"u"||(ke=!0,e.addEventListener("pds:ready",t=>{let n=t.detail?.mode;n&&document.documentElement.classList.add(`pds-${n}`,"pds-ready")}))}function je({manageTheme:e,themeStorageKey:t,applyResolvedTheme:n,setupSystemListenerIfNeeded:o}){let a="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"?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 V(e,{resolvePublicAssetURL:t}){let n=!!(e?.public?.root||e?.static?.root),o=t(e);return!n&&Me&&(o=Me),q(J(o))}async function $e(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:n="/auto-define/",autoDefinePreload:o=[],autoDefineMapper:a=null,enhancers:s=[],autoDefineOverrides:l=null,autoDefinePreferModule:S=!0}=e,w=(()=>{let i=new Map;return(t||[]).forEach(f=>i.set(f.selector,f)),(s||[]).forEach(f=>i.set(f.selector,f)),Array.from(i.values())})(),u=null;if(typeof window<"u"&&typeof document<"u"){let i=G,f=d=>{switch(d){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${d}.js`}},{mapper:A,enhancers:_,...P}=l&&typeof l=="object"?l:{},T=_?Array.isArray(_)?_:typeof _=="object"?Object.values(_):[]:[],c=(()=>{let d=new Map;return(w||[]).forEach(h=>{h?.selector&&d.set(h.selector,h)}),(T||[]).forEach(h=>{if(!h?.selector)return;let L=d.get(h.selector)||null;d.set(h.selector,{...L||{},...h,run:typeof h?.run=="function"?h.run:L?.run})}),Array.from(d.values())})(),b={baseURL:n&&q(J(n,{preferModule:S})),predefine:o,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:c,onError:(d,h)=>{if(typeof d=="string"&&d.startsWith("pds-")){let D=["pds-form","pds-drawer"].includes(d),v=h?.message?.includes("#pds/lit")||h?.message?.includes("Failed to resolve module specifier");D&&v?r.log("error",`\u274C PDS component <${d}> 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 <${d}> not found. Assets may not be installed.`)}else r.log("error",`\u274C Auto-define error for <${d}>:`,h)},...P,mapper:d=>{if(customElements.get(d))return null;if(typeof a=="function")try{let h=a(d);return h===void 0?f(d):h}catch(h){return r.log("warn","Custom autoDefine.mapper error; falling back to default:",h?.message||h),f(d)}return f(d)}};u=new i(b),o.length>0&&typeof i.define=="function"&&await i.define(...o,{baseURL:n,mapper:b.mapper,onError:b.onError})}return{autoDefiner:u,mergedEnhancers:w}}var me=["light","dark"],he=new Set(me);function pt(e){let n=(Array.isArray(e?.themes)?e.themes.map(o=>String(o).toLowerCase()):me).filter(o=>he.has(o));return n.length?n:me}function ye(e,{preferDocument:t=!0}={}){let n=String(e||"").toLowerCase();if(he.has(n))return n;if(t&&typeof document<"u"){let o=document.documentElement?.getAttribute("data-theme");if(he.has(o))return o}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Oe(e,t){let n=ye(t);return pt(e).includes(n)}var mt=new Set(["log","warn","error","debug","info"]),ht="__PURE_DS_PDS_SINGLETON__",ge=null,we=null;function Ie(){try{let t=(typeof globalThis<"u"?globalThis:window)?.[ht];if(t&&typeof t=="object")return t}catch{return null}return null}function yt(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 gt(e){if(typeof e!="string")return"log";let t=e.toLowerCase();return mt.has(t)?t:"log"}function wt(){if(typeof we=="function")try{let t=yt(we());if(t)return t}catch{}let e=Ie();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 bt(){if(typeof ge=="function")try{let t=ge();if(typeof t=="function")return t}catch{}let e=Ie();return typeof e?.logHandler=="function"?e.logHandler:null}function Ne(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 Fe({getLogger:e,getContext:t}={}){ge=typeof e=="function"?e:null,we=typeof t=="function"?t:null}function We(e="log",t,...n){let o=gt(e),a=wt(),s=bt();if(s)try{s.call(a?.thisArg,o,t,...n);return}catch(l){Ne("error","Custom log handler failed:",l)}St(o,a)&&Ne(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 Q=null,Y=null,Z=null,X=null,ee=null,te=null,He="__pdsLocalizationRuntime";function U(){if(te)return te;let e=r?.[He];return e&&typeof e=="object"?(te=e,e):null}function _t(e){let t=e&&typeof e=="object"?e:null;te=t,r[He]=t}Fe({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)=>{We(e,t,...n)};var E={locale:"en",messages:{},hasProvider:!1},ne=new Set;function Ke(e){return!!e&&typeof e!="string"&&typeof e=="object"&&"strTag"in e}function Ge(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 Lt(e,t){return String(e).replace(/\{(\d+)\}/g,(n,o)=>t(Number(o)))}function Et(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 vt(e,...t){return{strTag:!0,strings:Array.from(e||[]),values:t,raw:Array.from(e?.raw||[])}}function At(e){if(!e)return"";if(Ke(e)){let n=Ge(e.strings||[]),o=E.messages[n]||n;return Lt(o,a=>e.values?.[a])}let t=String(e);return E.messages[t]||t}function Pt(e){if(!e)return;let t=Ke(e)?Ge(e.strings||[]):String(e);typeof t=="string"&&t.length>0&&ne.add(t)}function qe(e){if(!e||typeof e.msg!="function"||ne.size===0)return;let t=Array.from(ne);ne.clear();for(let n of t)try{e.msg(n)}catch{}}async function I(){let e=U();return e||(ee||(ee=import(F("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),qe(n),n}).catch(n=>{throw ee=null,n})),ee)}var Je=(e,t={})=>{let n=U();return typeof n?.msg=="function"?n.msg(e,t):(Pt(e),At(e,t))},Ve=(e,...t)=>{let n=U();return typeof n?.str=="function"?n.str(e,...t):vt(e,...t)},oe=(e=null)=>{let t=U();if(typeof t?.configureLocalization=="function")return t.configureLocalization(e);if(!e||typeof e!="object")return E.locale="en",E.messages={},E.hasProvider=!1,{locale:E.locale,messages:{...E.messages},hasProvider:E.hasProvider};typeof e.locale=="string"&&e.locale.trim()&&(E.locale=e.locale.trim()),Object.prototype.hasOwnProperty.call(e,"messages")&&(E.messages=Et(e.messages));let n=!!(e.provider||e.translate||e.loadLocale||e.setLocale);return E.hasProvider=n,n&&I().then(o=>{o.configureLocalization(e),qe(o)}).catch(()=>{}),{locale:E.locale,messages:{...E.messages},hasProvider:E.hasProvider}},Qe=async e=>(await I()).loadLocale(e),Ye=async(e,t={})=>(await I()).setLocale(e,t),Ze=()=>{let e=U();return typeof e?.getLocalizationState=="function"?e.getLocalizationState():{locale:E.locale,messages:{...E.messages},hasProvider:E.hasProvider}},Xe=(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(w=>String(w||"").trim().toLowerCase()).filter(Boolean):[],a=Array.from(new Set([n,...o])),s=null,l=async()=>(s||(s=I().then(w=>typeof w?.createJSONLocalization=="function"?w.createJSONLocalization(e):null).catch(()=>null)),s),S=async(w="loadLocale")=>{let u=await l();if(!u||typeof u!="object")return null;let i=u.provider;if(!i||typeof i!="object")return null;let f=i[w];return typeof f=="function"?f:w==="setLocale"&&typeof i.loadLocale=="function"?i.loadLocale:null};return{locale:n,locales:[...a],provider:{locales:[...a],async loadLocale(w={}){let u=await S("loadLocale");return typeof u!="function"?{}:u(w)},async setLocale(w={}){let u=await S("setLocale");return typeof u!="function"?{}:u(w)}}}};function F(e,t){return t&&typeof t=="string"?t:`${V(r.currentConfig||{},{resolvePublicAssetURL:K})}core/${e}`}async function xt(){return Array.isArray(r.defaultEnhancers)&&r.defaultEnhancers.length>0?r.defaultEnhancers:(X||(X=import(F("pds-enhancers.js",r.currentConfig?.enhancersURL)).then(t=>{let n=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return r.defaultEnhancers=n,n}).catch(t=>{throw X=null,t})),X)}async function Rt(){return typeof r.ask=="function"&&r.ask!==et?r.ask:(Y||(Y=import(F("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 Y=null,t})),Y)}async function W(){return typeof r.toast=="function"&&r.toast!==j?r.toast:(Z||(Z=import(F("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 Z=null,t})),Z)}async function et(...e){return(await Rt())(...e)}async function j(...e){return(await W())(...e)}j.success=async(...e)=>(await W()).success(...e);j.error=async(...e)=>(await W()).error(...e);j.warning=async(...e)=>(await W()).warning(...e);j.info=async(...e)=>(await W()).info(...e);var Be=function(e="log",t,...n){r.log(e,t,...n)};function Se(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=>Se(n)).filter(n=>n!==void 0);let t={};for(let[n,o]of Object.entries(e)){let a=Se(o);a!==void 0&&(t[n]=a)}return t}function tt(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))tt(e[n],t);return e}function _e(e){return e==null||typeof e!="object"?e:tt(structuredClone(Se(e)))}async function Dt(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=k;r.enums=De;r.adoptLayers=xe;r.adoptPrimitives=Pe;var Tt=fe;r.parse=Tt;var zt=H;r.html=zt;r.createStylesheet=Re;r.isLiveMode=()=>k.isLive;r.ask=et;r.toast=j;r.common=pe;r.msg=Je;r.str=Ve;r.configureLocalization=oe;r.loadLocale=Qe;r.setLocale=Ye;r.getLocalizationState=Ze;r.createJSONLocalization=Xe;r.i18n={msg:Je,str:Ve,configure:oe,loadLocale:Qe,setLocale:Ye,getState:Ze,createJSONLocalization:Xe};r.AutoComplete=null;r.loadAutoComplete=async()=>{if(r.AutoComplete&&typeof r.AutoComplete.connect=="function")return r.AutoComplete;let e=F("pds-autocomplete.js",r.currentConfig?.autoCompleteURL);return Q||(Q=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 Q=null,t})),Q};function nt(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 ot(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 be="pure-ds-theme",z=null,N=null;function re(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 se(e){try{if(z&&N){try{typeof z.removeEventListener=="function"?z.removeEventListener("change",N):typeof z.removeListener=="function"&&z.removeListener(N)}catch{}z=null,N=null}if(e==="system"&&typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=o=>{let a=o?.matches===void 0?t.matches:o.matches;try{let s=a?"dark":"light";document.documentElement.setAttribute("data-theme",s),r.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:s,source:"system"}}))}catch{}};z=t,N=n,typeof t.addEventListener=="function"?t.addEventListener("change",n):typeof t.addListener=="function"&&t.addListener(n)}}catch{}}var Ct=Object.getOwnPropertyDescriptor(r,"theme");Ct||Object.defineProperty(r,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(be)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=r.currentConfig?.design||null,n=ye(e);if(t&&!Oe(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(be):localStorage.setItem(be,e),re(e),se(e),r.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});r.defaultEnhancers=[];async function Mt(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=_e(o);let a=o&&typeof o.localization=="object"&&o.localization?o.localization:null;a?(await I(),oe(a)):oe(null);let s;if(t==="static")s=await kt(o);else{let{localization:S,...w}=o||{},u=V(w,{resolvePublicAssetURL:K}),i=w?.managerURL||w?.public?.managerURL||w?.manager?.url||new URL("core/pds-manager.js",u).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:f}=await import(i);s=await f(r,w,{emitReady:nt,emitConfigChanged:ot,applyResolvedTheme:re,setupSystemListenerIfNeeded:se})}r.compiled=_e(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=Mt;async function kt(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",a=e.staticPaths??{},s=V(e,{resolvePublicAssetURL:K}),l=e&&e.autoDefine||null,S;l&&l.baseURL?S=q(J(l.baseURL,{preferModule:!1})):S=`${s}components/`;let w=l&&Array.isArray(l.predefine)&&l.predefine||[],u=l&&typeof l.mapper=="function"&&l.mapper||null;try{Ue(r);let{resolvedTheme:i}=je({manageTheme:n,themeStorageKey:o,applyResolvedTheme:re,setupSystemListenerIfNeeded:se}),f=await Dt(s,e),A=Array.isArray(e?.enhancers)?e.enhancers:e?.enhancers&&typeof e.enhancers=="object"?Object.values(e.enhancers):[],_=f?.config?{...f.config,...e,design:e?.design||f.config.design,preset:e?.preset||f.config.preset}:{...e},P={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`},T=f?.paths||{};if(a={...P,...T,...a},r.registry.setStaticMode(a),t&&typeof document<"u")try{let b=await r.registry.getStylesheet("styles");if(b){b._pds=!0;let d=(document.adoptedStyleSheets||[]).filter(h=>h._pds!==!0);document.adoptedStyleSheets=[...d,b],ot({mode:"static",source:"static:styles-applied"})}}catch(b){Be.call(r,"warn","Failed to apply static styles:",b)}let c=null,y=[];try{let b=await xt(),d=await $e({autoDefineBaseURL:S,autoDefinePreload:w,autoDefineMapper:u,enhancers:A,autoDefineOverrides:l||null,autoDefinePreferModule:!(l&&l.baseURL)},{baseEnhancers:b});c=d.autoDefiner,y=d.mergedEnhancers||[]}catch(b){Be.call(r,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",b)}return r.compiled=_e({mode:"static",..._,theme:i,enhancers:y}),nt({mode:"static",config:_,theme:i,autoDefiner:c}),{config:_,theme:i,autoDefiner:c}}catch(i){throw r.dispatchEvent(new CustomEvent("pds:error",{detail:{error:i}})),i}}var rn=re,sn=se;export{r as PDS,rn as applyResolvedTheme,oe as configureLocalization,Xe as createJSONLocalization,Ze as getLocalizationState,zt as html,Qe as loadLocale,Je as msg,Tt as parse,Ye as setLocale,sn as setupSystemListenerIfNeeded,Ve as str};
|
package/src/js/common/common.js
CHANGED
|
@@ -30,13 +30,25 @@ export function fragmentFromTemplateLike(templateLike) {
|
|
|
30
30
|
const consumedValues = new Set();
|
|
31
31
|
const htmlParts = [];
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
33
|
+
// Patterns handle both quoted (attr="${val}") and unquoted (attr=${val}) forms.
|
|
34
|
+
const propBindingPattern = /(\s)(\.[\w-]+)=["']?\s*$/;
|
|
35
|
+
const eventBindingPattern = /(\s)(@[\w-]+)=["']?\s*$/;
|
|
36
|
+
const booleanBindingPattern = /(\s)(\?[\w-]+)=["']?\s*$/;
|
|
37
|
+
const attrBindingPattern = /(\s)([\w:-]+)=["']?\s*$/;
|
|
38
|
+
// Detects whether the original string used a quoted binding (e.g. attr="..."),
|
|
39
|
+
// so we can strip the matching closing quote from the next string part.
|
|
40
|
+
const quotedBindingPattern = /=["']\s*$/;
|
|
41
|
+
|
|
42
|
+
let skipLeadingQuote = false;
|
|
37
43
|
|
|
38
44
|
for (let i = 0; i < strings.length; i += 1) {
|
|
39
45
|
let chunk = strings[i] ?? "";
|
|
46
|
+
|
|
47
|
+
if (skipLeadingQuote) {
|
|
48
|
+
chunk = chunk.replace(/^["']/, "");
|
|
49
|
+
skipLeadingQuote = false;
|
|
50
|
+
}
|
|
51
|
+
|
|
40
52
|
if (i < values.length) {
|
|
41
53
|
const marker = `pds-val-${i}`;
|
|
42
54
|
const propMatch = chunk.match(propBindingPattern);
|
|
@@ -46,6 +58,7 @@ export function fragmentFromTemplateLike(templateLike) {
|
|
|
46
58
|
|
|
47
59
|
if (propMatch) {
|
|
48
60
|
const propName = propMatch[2].slice(1);
|
|
61
|
+
skipLeadingQuote = quotedBindingPattern.test(strings[i] ?? "");
|
|
49
62
|
chunk = chunk.replace(
|
|
50
63
|
propBindingPattern,
|
|
51
64
|
`$1data-pds-bind-${i}="prop:${propName}:${marker}"`
|
|
@@ -53,6 +66,7 @@ export function fragmentFromTemplateLike(templateLike) {
|
|
|
53
66
|
consumedValues.add(i);
|
|
54
67
|
} else if (eventMatch) {
|
|
55
68
|
const eventName = eventMatch[2].slice(1);
|
|
69
|
+
skipLeadingQuote = quotedBindingPattern.test(strings[i] ?? "");
|
|
56
70
|
chunk = chunk.replace(
|
|
57
71
|
eventBindingPattern,
|
|
58
72
|
`$1data-pds-bind-${i}="event:${eventName}:${marker}"`
|
|
@@ -60,6 +74,7 @@ export function fragmentFromTemplateLike(templateLike) {
|
|
|
60
74
|
consumedValues.add(i);
|
|
61
75
|
} else if (boolMatch) {
|
|
62
76
|
const attrName = boolMatch[2].slice(1);
|
|
77
|
+
skipLeadingQuote = quotedBindingPattern.test(strings[i] ?? "");
|
|
63
78
|
chunk = chunk.replace(
|
|
64
79
|
booleanBindingPattern,
|
|
65
80
|
`$1data-pds-bind-${i}="boolean:${attrName}:${marker}"`
|
|
@@ -67,6 +82,7 @@ export function fragmentFromTemplateLike(templateLike) {
|
|
|
67
82
|
consumedValues.add(i);
|
|
68
83
|
} else if (attrMatch) {
|
|
69
84
|
const attrName = attrMatch[2];
|
|
85
|
+
skipLeadingQuote = quotedBindingPattern.test(strings[i] ?? "");
|
|
70
86
|
chunk = chunk.replace(
|
|
71
87
|
attrBindingPattern,
|
|
72
88
|
`$1data-pds-bind-${i}="attr:${attrName}:${marker}"`
|
package/src/js/common/toast.js
CHANGED
|
@@ -34,7 +34,8 @@ async function ensureToaster() {
|
|
|
34
34
|
* @param {boolean} [options.persistent=false] - If true, toast won't auto-dismiss (requires manual close)
|
|
35
35
|
* @param {boolean} [options.html=false] - Render `message` as HTML (trusted content only)
|
|
36
36
|
* @param {{label: string, onClick?: Function, dismissOnClick?: boolean}} [options.action] - Optional action button config
|
|
37
|
-
* @
|
|
37
|
+
* @param {boolean} [options.returnToastElement=false] - If true, resolves to the rendered toast element instead of toast ID
|
|
38
|
+
* @returns {Promise<string|HTMLElement|null>} Toast ID by default, or toast element when returnToastElement is true
|
|
38
39
|
*
|
|
39
40
|
* @example
|
|
40
41
|
* // Simple success toast
|
|
@@ -67,6 +68,14 @@ async function ensureToaster() {
|
|
|
67
68
|
* // ... later
|
|
68
69
|
* const toaster = document.querySelector('pds-toaster');
|
|
69
70
|
* toaster.dismissToast(toastId);
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* // Get toast element directly for live updates
|
|
74
|
+
* const toastEl = await PDS.toast('Syncing draft... 0%', {
|
|
75
|
+
* persistent: true,
|
|
76
|
+
* returnToastElement: true
|
|
77
|
+
* });
|
|
78
|
+
* toastEl?.querySelector('.toast-content p').textContent = 'Syncing draft... 35%';
|
|
70
79
|
*/
|
|
71
80
|
export async function toast(message, options = {}) {
|
|
72
81
|
const toaster = await ensureToaster();
|
|
@@ -78,7 +87,7 @@ export async function toast(message, options = {}) {
|
|
|
78
87
|
*
|
|
79
88
|
* @param {string} message - The success message
|
|
80
89
|
* @param {Object} [options={}] - Additional toast options (type is preset to 'success')
|
|
81
|
-
* @returns {Promise<string>} Toast ID
|
|
90
|
+
* @returns {Promise<string|HTMLElement|null>} Toast ID by default, or toast element when returnToastElement is true
|
|
82
91
|
*
|
|
83
92
|
* @example
|
|
84
93
|
* await PDS.toast.success('Profile updated!');
|
|
@@ -92,7 +101,7 @@ toast.success = async function(message, options = {}) {
|
|
|
92
101
|
*
|
|
93
102
|
* @param {string} message - The error message
|
|
94
103
|
* @param {Object} [options={}] - Additional toast options (type is preset to 'error')
|
|
95
|
-
* @returns {Promise<string>} Toast ID
|
|
104
|
+
* @returns {Promise<string|HTMLElement|null>} Toast ID by default, or toast element when returnToastElement is true
|
|
96
105
|
*
|
|
97
106
|
* @example
|
|
98
107
|
* await PDS.toast.error('Failed to connect to server');
|
|
@@ -106,7 +115,7 @@ toast.error = async function(message, options = {}) {
|
|
|
106
115
|
*
|
|
107
116
|
* @param {string} message - The warning message
|
|
108
117
|
* @param {Object} [options={}] - Additional toast options (type is preset to 'warning')
|
|
109
|
-
* @returns {Promise<string>} Toast ID
|
|
118
|
+
* @returns {Promise<string|HTMLElement|null>} Toast ID by default, or toast element when returnToastElement is true
|
|
110
119
|
*
|
|
111
120
|
* @example
|
|
112
121
|
* await PDS.toast.warning('Session will expire in 5 minutes');
|
|
@@ -120,7 +129,7 @@ toast.warning = async function(message, options = {}) {
|
|
|
120
129
|
*
|
|
121
130
|
* @param {string} message - The information message
|
|
122
131
|
* @param {Object} [options={}] - Additional toast options (type is preset to 'information')
|
|
123
|
-
* @returns {Promise<string>} Toast ID
|
|
132
|
+
* @returns {Promise<string|HTMLElement|null>} Toast ID by default, or toast element when returnToastElement is true
|
|
124
133
|
*
|
|
125
134
|
* @example
|
|
126
135
|
* await PDS.toast.info('New features available!');
|
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PDS Enhancer Metadata (live mode only)
|
|
3
|
-
*
|
|
4
|
-
* This file contains description and demoHtml for runtime inspection tools.
|
|
5
|
-
* It is intentionally kept separate from pds-enhancers.js to keep the
|
|
6
|
-
* production pds.js bundle lean.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export const defaultPDSEnhancerMetadata = [
|
|
10
|
-
{
|
|
11
|
-
selector: ".accordion",
|
|
12
|
-
description:
|
|
13
|
-
"Ensures only one <details> element can be open at a time within the accordion.",
|
|
14
|
-
demoHtml: `
|
|
15
|
-
<div class="accordion">
|
|
16
|
-
<details>
|
|
17
|
-
<summary>Section 1</summary>
|
|
18
|
-
<p>Content for section 1</p>
|
|
19
|
-
</details>
|
|
20
|
-
<details>
|
|
21
|
-
<summary>Section 2</summary>
|
|
22
|
-
<p>Content for section 2</p>
|
|
23
|
-
</details>
|
|
24
|
-
<details>
|
|
25
|
-
<summary>Section 3</summary>
|
|
26
|
-
<p>Content for section 3</p>
|
|
27
|
-
</details>
|
|
28
|
-
</div>
|
|
29
|
-
`.trim(),
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
selector: "nav[data-dropdown]",
|
|
33
|
-
description:
|
|
34
|
-
"Enhances a nav element with data-dropdown to toggle its last child as a dropdown panel (menu, card, form, etc.). Add data-dropdown-close to any clickable descendant that should close the menu on selection.",
|
|
35
|
-
attributes: [
|
|
36
|
-
{
|
|
37
|
-
name: "data-dropdown-close",
|
|
38
|
-
description:
|
|
39
|
-
"When clicked (or when a descendant is clicked), closes the currently open dropdown popover.",
|
|
40
|
-
appliesTo: "Any clickable element inside nav[data-dropdown] menu/panel content",
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
demoHtml: `
|
|
44
|
-
<nav data-dropdown>
|
|
45
|
-
<button class="btn-primary">Menu</button>
|
|
46
|
-
<menu>
|
|
47
|
-
<li><a href="#open">Open</a></li>
|
|
48
|
-
<li><a href="#settings" data-dropdown-close>Open settings and close</a></li>
|
|
49
|
-
</menu>
|
|
50
|
-
</nav>
|
|
51
|
-
`.trim(),
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
selector: "label[data-toggle]",
|
|
55
|
-
description: "Creates a toggle switch element from a checkbox.",
|
|
56
|
-
demoHtml: `
|
|
57
|
-
<label data-toggle>
|
|
58
|
-
<input type="checkbox">
|
|
59
|
-
<span data-label>Enable notifications</span>
|
|
60
|
-
</label>
|
|
61
|
-
`.trim(),
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
selector: "label[data-color]",
|
|
65
|
-
description:
|
|
66
|
-
"Wraps color inputs with a styled control shell and synced hex output while keeping the native picker.",
|
|
67
|
-
demoHtml: `
|
|
68
|
-
<label data-color>
|
|
69
|
-
<span>Brand color</span>
|
|
70
|
-
<input type="color" value="#7c3aed">
|
|
71
|
-
</label>
|
|
72
|
-
`.trim(),
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
selector: 'input[type="range"]',
|
|
76
|
-
description: "Enhances range inputs with an attached <output>.",
|
|
77
|
-
demoHtml: `
|
|
78
|
-
<label class="range-output">
|
|
79
|
-
<span data-label>Volume</span>
|
|
80
|
-
<input type="range" min="0" max="100" value="40">
|
|
81
|
-
</label>
|
|
82
|
-
`.trim(),
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
selector: "form[data-required]",
|
|
86
|
-
description:
|
|
87
|
-
"Enhances required form fields using an asterisk in the label.",
|
|
88
|
-
demoHtml: `
|
|
89
|
-
<form data-required action="#" method="post">
|
|
90
|
-
<label>
|
|
91
|
-
<span>Field Label</span>
|
|
92
|
-
<input type="text" required>
|
|
93
|
-
</label>
|
|
94
|
-
<nav class="form-actions">
|
|
95
|
-
<button type="submit" class="btn-primary">Submit</button>
|
|
96
|
-
</nav>
|
|
97
|
-
</form>
|
|
98
|
-
`.trim(),
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
selector: "fieldset[role=group][data-open]",
|
|
102
|
-
description:
|
|
103
|
-
"Enhances a checkbox/radio group to be open (have a way to add and remove items).",
|
|
104
|
-
demoHtml: `
|
|
105
|
-
<fieldset role="group" data-open>
|
|
106
|
-
<label>
|
|
107
|
-
<span data-label>Test</span>
|
|
108
|
-
<input value="lala" name="test1" type="radio" />
|
|
109
|
-
</label>
|
|
110
|
-
</fieldset>
|
|
111
|
-
`.trim(),
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
selector: "[data-clip]",
|
|
115
|
-
description:
|
|
116
|
-
"Enables click/keyboard toggling for line-clamped content blocks.",
|
|
117
|
-
demoHtml: `
|
|
118
|
-
<div data-clip="2" data-clip-more="more...">
|
|
119
|
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
|
120
|
-
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.</p>
|
|
121
|
-
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse.</p>
|
|
122
|
-
</div>
|
|
123
|
-
`.trim(),
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
selector: "button, a[class*='btn-']",
|
|
127
|
-
description:
|
|
128
|
-
"Automatically manages spinner icon for buttons with .btn-working class",
|
|
129
|
-
demoHtml: `
|
|
130
|
-
<button class="btn-primary btn-working">
|
|
131
|
-
<span>Saving</span>
|
|
132
|
-
</button>
|
|
133
|
-
`.trim(),
|
|
134
|
-
},
|
|
135
|
-
];
|
|
1
|
+
/**
|
|
2
|
+
* PDS Enhancer Metadata (live mode only)
|
|
3
|
+
*
|
|
4
|
+
* This file contains description and demoHtml for runtime inspection tools.
|
|
5
|
+
* It is intentionally kept separate from pds-enhancers.js to keep the
|
|
6
|
+
* production pds.js bundle lean.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const defaultPDSEnhancerMetadata = [
|
|
10
|
+
{
|
|
11
|
+
selector: ".accordion",
|
|
12
|
+
description:
|
|
13
|
+
"Ensures only one <details> element can be open at a time within the accordion.",
|
|
14
|
+
demoHtml: `
|
|
15
|
+
<div class="accordion">
|
|
16
|
+
<details>
|
|
17
|
+
<summary>Section 1</summary>
|
|
18
|
+
<p>Content for section 1</p>
|
|
19
|
+
</details>
|
|
20
|
+
<details>
|
|
21
|
+
<summary>Section 2</summary>
|
|
22
|
+
<p>Content for section 2</p>
|
|
23
|
+
</details>
|
|
24
|
+
<details>
|
|
25
|
+
<summary>Section 3</summary>
|
|
26
|
+
<p>Content for section 3</p>
|
|
27
|
+
</details>
|
|
28
|
+
</div>
|
|
29
|
+
`.trim(),
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
selector: "nav[data-dropdown]",
|
|
33
|
+
description:
|
|
34
|
+
"Enhances a nav element with data-dropdown to toggle its last child as a dropdown panel (menu, card, form, etc.). Add data-dropdown-close to any clickable descendant that should close the menu on selection.",
|
|
35
|
+
attributes: [
|
|
36
|
+
{
|
|
37
|
+
name: "data-dropdown-close",
|
|
38
|
+
description:
|
|
39
|
+
"When clicked (or when a descendant is clicked), closes the currently open dropdown popover.",
|
|
40
|
+
appliesTo: "Any clickable element inside nav[data-dropdown] menu/panel content",
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
demoHtml: `
|
|
44
|
+
<nav data-dropdown>
|
|
45
|
+
<button class="btn-primary">Menu</button>
|
|
46
|
+
<menu>
|
|
47
|
+
<li><a href="#open">Open</a></li>
|
|
48
|
+
<li><a href="#settings" data-dropdown-close>Open settings and close</a></li>
|
|
49
|
+
</menu>
|
|
50
|
+
</nav>
|
|
51
|
+
`.trim(),
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
selector: "label[data-toggle]",
|
|
55
|
+
description: "Creates a toggle switch element from a checkbox.",
|
|
56
|
+
demoHtml: `
|
|
57
|
+
<label data-toggle>
|
|
58
|
+
<input type="checkbox">
|
|
59
|
+
<span data-label>Enable notifications</span>
|
|
60
|
+
</label>
|
|
61
|
+
`.trim(),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
selector: "label[data-color]",
|
|
65
|
+
description:
|
|
66
|
+
"Wraps color inputs with a styled control shell and synced hex output while keeping the native picker.",
|
|
67
|
+
demoHtml: `
|
|
68
|
+
<label data-color>
|
|
69
|
+
<span>Brand color</span>
|
|
70
|
+
<input type="color" value="#7c3aed">
|
|
71
|
+
</label>
|
|
72
|
+
`.trim(),
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
selector: 'input[type="range"]',
|
|
76
|
+
description: "Enhances range inputs with an attached <output>.",
|
|
77
|
+
demoHtml: `
|
|
78
|
+
<label class="range-output">
|
|
79
|
+
<span data-label>Volume</span>
|
|
80
|
+
<input type="range" min="0" max="100" value="40">
|
|
81
|
+
</label>
|
|
82
|
+
`.trim(),
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
selector: "form[data-required]",
|
|
86
|
+
description:
|
|
87
|
+
"Enhances required form fields using an asterisk in the label.",
|
|
88
|
+
demoHtml: `
|
|
89
|
+
<form data-required action="#" method="post">
|
|
90
|
+
<label>
|
|
91
|
+
<span>Field Label</span>
|
|
92
|
+
<input type="text" required>
|
|
93
|
+
</label>
|
|
94
|
+
<nav class="form-actions">
|
|
95
|
+
<button type="submit" class="btn-primary">Submit</button>
|
|
96
|
+
</nav>
|
|
97
|
+
</form>
|
|
98
|
+
`.trim(),
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
selector: "fieldset[role=group][data-open]",
|
|
102
|
+
description:
|
|
103
|
+
"Enhances a checkbox/radio group to be open (have a way to add and remove items).",
|
|
104
|
+
demoHtml: `
|
|
105
|
+
<fieldset role="group" data-open>
|
|
106
|
+
<label>
|
|
107
|
+
<span data-label>Test</span>
|
|
108
|
+
<input value="lala" name="test1" type="radio" />
|
|
109
|
+
</label>
|
|
110
|
+
</fieldset>
|
|
111
|
+
`.trim(),
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
selector: "[data-clip]",
|
|
115
|
+
description:
|
|
116
|
+
"Enables click/keyboard toggling for line-clamped content blocks.",
|
|
117
|
+
demoHtml: `
|
|
118
|
+
<div data-clip="2" data-clip-more="more...">
|
|
119
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
|
120
|
+
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.</p>
|
|
121
|
+
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse.</p>
|
|
122
|
+
</div>
|
|
123
|
+
`.trim(),
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
selector: "button, a[class*='btn-']",
|
|
127
|
+
description:
|
|
128
|
+
"Automatically manages spinner icon for buttons with .btn-working class",
|
|
129
|
+
demoHtml: `
|
|
130
|
+
<button class="btn-primary btn-working">
|
|
131
|
+
<span>Saving</span>
|
|
132
|
+
</button>
|
|
133
|
+
`.trim(),
|
|
134
|
+
},
|
|
135
|
+
];
|
package/src/js/pds.d.ts
CHANGED
|
@@ -403,7 +403,8 @@ export class PDS extends EventTarget {
|
|
|
403
403
|
* @param options.duration - Duration in milliseconds (auto-calculated if not provided)
|
|
404
404
|
* @param options.closable - Whether toast can be manually closed (default: true)
|
|
405
405
|
* @param options.persistent - If true, toast won't auto-dismiss (default: false)
|
|
406
|
-
|
|
406
|
+
* @param options.returnToastElement - If true, returns the live toast element instead of the toast ID
|
|
407
|
+
* @returns Toast ID (default), or live toast element when returnToastElement is true
|
|
407
408
|
*
|
|
408
409
|
* @example
|
|
409
410
|
* await PDS.toast('Changes saved!', { type: 'success' });
|
|
@@ -419,6 +420,7 @@ export class PDS extends EventTarget {
|
|
|
419
420
|
duration?: number;
|
|
420
421
|
closable?: boolean;
|
|
421
422
|
persistent?: boolean;
|
|
423
|
+
returnToastElement?: false;
|
|
422
424
|
}
|
|
423
425
|
): Promise<string>;
|
|
424
426
|
|
|
@@ -433,11 +435,12 @@ export class PDS extends EventTarget {
|
|
|
433
435
|
* await PDS.toast.success('Profile updated!');
|
|
434
436
|
*/
|
|
435
437
|
static toast: {
|
|
436
|
-
(message: string, options
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
438
|
+
(message: string, options: { type?: 'information' | 'success' | 'warning' | 'error'; title?: string; duration?: number; closable?: boolean; persistent?: boolean; returnToastElement: true }): Promise<HTMLElement | null>;
|
|
439
|
+
(message: string, options?: { type?: 'information' | 'success' | 'warning' | 'error'; title?: string; duration?: number; closable?: boolean; persistent?: boolean; returnToastElement?: false }): Promise<string>;
|
|
440
|
+
success(message: string, options?: { title?: string; duration?: number; closable?: boolean; persistent?: boolean; returnToastElement?: boolean }): Promise<string | HTMLElement | null>;
|
|
441
|
+
error(message: string, options?: { title?: string; duration?: number; closable?: boolean; persistent?: boolean; returnToastElement?: boolean }): Promise<string | HTMLElement | null>;
|
|
442
|
+
warning(message: string, options?: { title?: string; duration?: number; closable?: boolean; persistent?: boolean; returnToastElement?: boolean }): Promise<string | HTMLElement | null>;
|
|
443
|
+
info(message: string, options?: { title?: string; duration?: number; closable?: boolean; persistent?: boolean; returnToastElement?: boolean }): Promise<string | HTMLElement | null>;
|
|
441
444
|
};
|
|
442
445
|
|
|
443
446
|
/**
|