@pure-ds/core 0.7.22 → 0.7.24
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 +2 -2
- package/dist/types/public/assets/js/pds-enhancers.d.ts +4 -4
- package/dist/types/public/assets/js/pds-enhancers.d.ts.map +1 -1
- package/dist/types/public/assets/js/pds-manager.d.ts +19 -19
- package/dist/types/public/assets/js/pds-manager.d.ts.map +1 -1
- package/dist/types/public/assets/js/pds.d.ts +4 -8
- package/dist/types/public/assets/js/pds.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-icon.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-omnibox.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-enhancers.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-live.d.ts.map +1 -1
- package/dist/types/src/js/pds.d.ts +1 -39
- package/dist/types/src/js/pds.d.ts.map +1 -1
- package/package.json +1 -1
- package/public/assets/js/app.js +4 -4
- package/public/assets/js/pds-enhancers.js +1 -1
- package/public/assets/js/pds-manager.js +26 -26
- package/public/assets/js/pds.js +2 -2
- package/public/assets/pds/components/pds-icon.js +5 -25
- package/public/assets/pds/components/pds-live-edit.js +3 -8
- package/public/assets/pds/components/pds-omnibox.js +37 -1
- package/public/assets/pds/core/pds-enhancers.js +1 -1
- package/public/assets/pds/core/pds-manager.js +26 -26
- package/public/assets/pds/core.js +2 -2
- package/src/js/pds-core/pds-enhancers.js +53 -8
- package/src/js/pds-core/pds-live.js +29 -21
- package/src/js/pds.d.ts +2 -2
- package/src/js/pds.js +107 -65
package/public/assets/js/pds.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var Pe=Object.defineProperty;var De=(e,t)=>{for(var n in t)Pe(e,n,{get:t[n],enumerable:!0})};var Y=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){console.error(`[PDS Registry] Failed to load static ${t}:`,n),console.error(`[PDS Registry] Looking for: ${this._staticPaths[t]}`),console.error("[PDS 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"}},M=new Y;async function de(e,t=[],n=null){try{let r=n?.primitivesStylesheet?n.primitivesStylesheet:await M.getStylesheet("primitives");e.adoptedStyleSheets=[r,...t]}catch(r){let i=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${i}> failed to adopt primitives:`,r),e.adoptedStyleSheets=t}}async function ue(e,t=["primitives"],n=[],r=null){let i=Array.isArray(n)?n.filter(Boolean):[];if(i.length){let l=(Array.isArray(e.adoptedStyleSheets)?e.adoptedStyleSheets:[]).filter(w=>!i.includes(w));e.adoptedStyleSheets=[...l,...i]}try{let l=(await Promise.all(t.map(async w=>{if(r)switch(w){case"tokens":return r.tokensStylesheet;case"primitives":return r.primitivesStylesheet;case"components":return r.componentsStylesheet;case"utilities":return r.utilitiesStylesheet;default:break}return M.getStylesheet(w)}))).filter(w=>w!==null);e.adoptedStyleSheets=[...l,...i]}catch(s){let l=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${l}> failed to adopt layers:`,s),e.adoptedStyleSheets=i}}function pe(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var fe={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 ee={};De(ee,{deepMerge:()=>me,fragmentFromTemplateLike:()=>Me,isObject:()=>I,parseHTML:()=>Z});function I(e){return e&&typeof e=="object"&&!Array.isArray(e)}function me(e,t){let n={...e};return I(e)&&I(t)&&Object.keys(t).forEach(r=>{I(t[r])?r in e?n[r]=me(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})}),n}function Me(e){let t=Array.isArray(e?.strings)?e.strings:[],n=Array.isArray(e?.values)?e.values:[],r=new Set,i=[],s=/(\s)(\.[\w-]+)=\s*$/;for(let a=0;a<t.length;a+=1){let g=t[a]??"",m=g.match(s);if(m&&a<n.length){let S=m[2].slice(1),L=`pds-val-${a}`;g=g.replace(s,`$1data-pds-prop="${S}:${L}"`),r.add(a)}i.push(g),a<n.length&&!r.has(a)&&i.push(`<!--pds-val-${a}-->`)}let l=document.createElement("template");l.innerHTML=i.join("");let w=(a,g)=>{let m=a.parentNode;if(!m)return;if(g==null){m.removeChild(a);return}let b=S=>{if(S!=null){if(S instanceof Node){m.insertBefore(S,a);return}if(Array.isArray(S)){S.forEach(L=>b(L));return}m.insertBefore(document.createTextNode(String(S)),a)}};b(g),m.removeChild(a)},E=document.createTreeWalker(l.content,NodeFilter.SHOW_COMMENT),h=[];for(;E.nextNode();){let a=E.currentNode;a?.nodeValue?.startsWith("pds-val-")&&h.push(a)}return h.forEach(a=>{let g=Number(a.nodeValue.replace("pds-val-",""));w(a,n[g])}),l.content.querySelectorAll("*").forEach(a=>{let g=a.getAttribute("data-pds-prop");if(!g)return;let[m,b]=g.split(":"),S=Number(String(b).replace("pds-val-",""));m&&Number.isInteger(S)&&(a[m]=n[S]),a.removeAttribute("data-pds-prop")}),l.content}function Z(e){return new DOMParser().parseFromString(e,"text/html").body.childNodes}var ye="pds",ke=/^([a-z][a-z0-9+\-.]*:)?\/\//i,he=/^[a-z]:/i;function C(e=""){return e.endsWith("/")?e:`${e}/`}function Te(e="",t=ye){let n=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(n)?n:`${n}/${t}`}function Ce(e){return e.replace(/^\.\/+/,"")}function Ue(e){return he.test(e)?e.replace(he,"").replace(/^\/+/,""):e}function $e(e){return e.startsWith("public/")?e.substring(7):e}function N(e,t={}){let n=t.segment||ye,r=t.defaultRoot||`/assets/${n}/`,i=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!i||typeof i!="string")return C(r);let s=i.trim();return s?(s=s.replace(/\\/g,"/"),s=Te(s,n),s=C(s),ke.test(s)?s:(s=Ce(s),s=Ue(s),s.startsWith("/")||(s=$e(s),s.startsWith("/")||(s=`/${s}`),s=s.replace(/\/+/g,(l,w)=>w===0?l:"/")),C(s))):C(r)}async function je(...e){let t={};e.length&&typeof e[e.length-1]=="object"&&(t=e.pop()||{});let n=e,{baseURL:r,mapper:i=h=>`${h}.js`,onError:s=(h,c)=>console.error(`[defineWebComponents] ${h}:`,c)}=t,l=r?new URL(r,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),w=h=>h.toLowerCase().replace(/(^|-)([a-z])/g,(c,a,g)=>g.toUpperCase()),E=async h=>{try{if(customElements.get(h))return{tag:h,status:"already-defined"};let c=i(h),g=await import(c instanceof URL?c.href:new URL(c,l).href),m=g?.default??g?.[w(h)];if(!m){if(customElements.get(h))return{tag:h,status:"self-defined"};throw new Error(`No export found for ${h}. Expected default export or named export "${w(h)}".`)}return customElements.get(h)?{tag:h,status:"race-already-defined"}:(customElements.define(h,m),{tag:h,status:"defined"})}catch(c){throw s(h,c),c}};return Promise.all(n.map(E))}var z=class{constructor(t={}){let{baseURL:n,mapper:r,onError:i,predicate:s=()=>!0,attributeModule:l="data-module",root:w=document,scanExisting:E=!0,debounceMs:h=16,observeShadows:c=!0,enhancers:a=[],patchAttachShadow:g=!0}=t,m=new Set,b=new Set,S=new Set,L=new Map,x=new WeakMap,_=new WeakMap,p=0,y=!1,v=null,O=d=>{if(!d||!a.length)return;let f=_.get(d);f||(f=new Set,_.set(d,f));for(let u of a)if(!(!u.selector||!u.run)&&!f.has(u.selector))try{d.matches&&d.matches(u.selector)&&(u.run(d),f.add(u.selector))}catch(A){console.warn(`[AutoDefiner] Error applying enhancer for selector "${u.selector}":`,A)}},T=(d,f)=>{if(!y&&!(!d||!d.includes("-"))&&!customElements.get(d)&&!b.has(d)&&!S.has(d)){if(f&&f.getAttribute){let u=f.getAttribute(l);u&&!L.has(d)&&L.set(d,u)}m.add(d),Re()}},Re=()=>{p||(p=setTimeout(ie,h))},P=d=>{if(d){if(d.nodeType===1){let f=d,u=f.tagName?.toLowerCase();u&&u.includes("-")&&!customElements.get(u)&&s(u,f)&&T(u,f),O(f),c&&f.shadowRoot&&X(f.shadowRoot)}d.querySelectorAll&&d.querySelectorAll("*").forEach(f=>{let u=f.tagName?.toLowerCase();u&&u.includes("-")&&!customElements.get(u)&&s(u,f)&&T(u,f),O(f),c&&f.shadowRoot&&X(f.shadowRoot)})}},X=d=>{if(!d||x.has(d))return;P(d);let f=new MutationObserver(u=>{for(let A of u)A.addedNodes?.forEach(D=>{P(D)}),A.type==="attributes"&&A.target&&P(A.target)});f.observe(d,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...a.map(u=>u.selector).filter(u=>u.startsWith("data-"))]}),x.set(d,f)};async function ie(){if(clearTimeout(p),p=0,!m.size)return;let d=Array.from(m);m.clear(),d.forEach(f=>b.add(f));try{let f=u=>L.get(u)??(r?r(u):`${u}.js`);await je(...d,{baseURL:n,mapper:f,onError:(u,A)=>{S.add(u),i?.(u,A)}})}catch{}finally{d.forEach(f=>b.delete(f))}}let ce=w===document?document.documentElement:w,le=new MutationObserver(d=>{for(let f of d)f.addedNodes?.forEach(u=>{P(u)}),f.type==="attributes"&&f.target&&P(f.target)});if(le.observe(ce,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...a.map(d=>d.selector).filter(d=>d.startsWith("data-"))]}),c&&g&&Element.prototype.attachShadow){let d=Element.prototype.attachShadow;Element.prototype.attachShadow=function(u){let A=d.call(this,u);if(u&&u.mode==="open"){X(A);let D=this.tagName?.toLowerCase();D&&D.includes("-")&&!customElements.get(D)&&T(D,this)}return A},v=()=>Element.prototype.attachShadow=d}return E&&P(ce),{stop(){y=!0,le.disconnect(),v&&v(),p&&(clearTimeout(p),p=0),x.forEach(d=>d.disconnect())},flush:ie}}static async define(...t){let n={};t.length&&typeof t[t.length-1]=="object"&&(n=t.pop()||{});let r=t,{baseURL:i,mapper:s=c=>`${c}.js`,onError:l=(c,a)=>console.error(`[defineWebComponents] ${c}:`,a)}=n,w=i?new URL(i,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),E=c=>c.toLowerCase().replace(/(^|-)([a-z])/g,(a,g,m)=>m.toUpperCase()),h=async c=>{try{if(customElements.get(c))return{tag:c,status:"already-defined"};let a=s(c),m=await import(a instanceof URL?a.href:new URL(a,w).href),b=m?.default??m?.[E(c)];if(!b){if(customElements.get(c))return{tag:c,status:"self-defined"};throw new Error(`No export found for ${c}. Expected default export or named export "${E(c)}".`)}return customElements.get(c)?{tag:c,status:"race-already-defined"}:(customElements.define(c,b),{tag:c,status:"defined"})}catch(a){throw l(c,a),a}};return Promise.all(r.map(h))}};var Oe=/^[a-z][a-z0-9+\-.]*:\/\//i,U=(()=>{try{return import.meta.url}catch{return}})(),F=e=>typeof e=="string"&&e.length&&!e.endsWith("/")?`${e}/`:e;function W(e,t={}){if(!e||Oe.test(e))return e;let{preferModule:n=!0}=t,r=()=>{if(!U)return null;try{return new URL(e,U).href}catch{return null}},i=()=>{if(typeof window>"u"||!window.location?.origin)return null;try{return new URL(e,window.location.origin).href}catch{return null}};return(n?r()||i():i()||r())||e}var we=(()=>{if(U)try{let e=new URL(U);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",U).href}catch{return}})(),ge=!1;function Se(e){ge||typeof document>"u"||(ge=!0,e.addEventListener("pds:ready",t=>{let n=t.detail?.mode;n&&document.documentElement.classList.add(`pds-${n}`,"pds-ready")}))}function Ee({manageTheme:e,themeStorageKey:t,applyResolvedTheme:n,setupSystemListenerIfNeeded:r}){let i="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"?i=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":i=s:i=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:i,storedTheme:s}}function B(e,{resolvePublicAssetURL:t}){let n=!!(e?.public?.root||e?.static?.root),r=t(e);return!n&&we&&(r=we),F(W(r))}async function be(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:n="/auto-define/",autoDefinePreload:r=[],autoDefineMapper:i=null,enhancers:s=[],autoDefineOverrides:l=null,autoDefinePreferModule:w=!0}=e,E=(()=>{let c=new Map;return(t||[]).forEach(a=>c.set(a.selector,a)),(s||[]).forEach(a=>c.set(a.selector,a)),Array.from(c.values())})(),h=null;if(typeof window<"u"&&typeof document<"u"){let c=z,a=p=>{switch(p){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${p}.js`}},{mapper:g,enhancers:m,...b}=l&&typeof l=="object"?l:{},S=m?Array.isArray(m)?m:typeof m=="object"?Object.values(m):[]:[],L=(()=>{let p=new Map;return(E||[]).forEach(y=>{y?.selector&&p.set(y.selector,y)}),(S||[]).forEach(y=>{if(!y?.selector)return;let v=p.get(y.selector)||null;p.set(y.selector,{...v||{},...y,run:typeof y?.run=="function"?y.run:v?.run})}),Array.from(p.values())})(),_={baseURL:n&&F(W(n,{preferModule:w})),predefine:r,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:L,onError:(p,y)=>{if(typeof p=="string"&&p.startsWith("pds-")){let O=["pds-form","pds-drawer"].includes(p),T=y?.message?.includes("#pds/lit")||y?.message?.includes("Failed to resolve module specifier");O&&T?console.error(`\u274C PDS component <${p}> 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`):console.warn(`\u26A0\uFE0F PDS component <${
|
|
1
|
+
var Ue=Object.defineProperty;var Ce=(e,t)=>{for(var n in t)Ue(e,n,{get:t[n],enumerable:!0})};var X=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){console.error(`[PDS Registry] Failed to load static ${t}:`,n),console.error(`[PDS Registry] Looking for: ${this._staticPaths[t]}`),console.error("[PDS 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"}},M=new X;async function fe(e,t=[],n=null){try{let r=n?.primitivesStylesheet?n.primitivesStylesheet:await M.getStylesheet("primitives");e.adoptedStyleSheets=[r,...t]}catch(r){let a=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${a}> failed to adopt primitives:`,r),e.adoptedStyleSheets=t}}async function me(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(y=>!a.includes(y));e.adoptedStyleSheets=[...l,...a]}try{let l=(await Promise.all(t.map(async y=>{if(r)switch(y){case"tokens":return r.tokensStylesheet;case"primitives":return r.primitivesStylesheet;case"components":return r.componentsStylesheet;case"utilities":return r.utilitiesStylesheet;default:break}return M.getStylesheet(y)}))).filter(y=>y!==null);e.adoptedStyleSheets=[...l,...a]}catch(o){let l=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${l}> failed to adopt layers:`,o),e.adoptedStyleSheets=a}}function he(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var ye={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 ee={};Ce(ee,{deepMerge:()=>we,fragmentFromTemplateLike:()=>je,isObject:()=>I,parseHTML:()=>Z});function I(e){return e&&typeof e=="object"&&!Array.isArray(e)}function we(e,t){let n={...e};return I(e)&&I(t)&&Object.keys(t).forEach(r=>{I(t[r])?r in e?n[r]=we(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})}),n}function je(e){let t=Array.isArray(e?.strings)?e.strings:[],n=Array.isArray(e?.values)?e.values:[],r=new Set,a=[],o=/(\s)(\.[\w-]+)=\s*$/;for(let i=0;i<t.length;i+=1){let S=t[i]??"",f=S.match(o);if(f&&i<n.length){let g=f[2].slice(1),L=`pds-val-${i}`;S=S.replace(o,`$1data-pds-prop="${g}:${L}"`),r.add(i)}a.push(S),i<n.length&&!r.has(i)&&a.push(`<!--pds-val-${i}-->`)}let l=document.createElement("template");l.innerHTML=a.join("");let y=(i,S)=>{let f=i.parentNode;if(!f)return;if(S==null){f.removeChild(i);return}let b=g=>{if(g!=null){if(g instanceof Node){f.insertBefore(g,i);return}if(Array.isArray(g)){g.forEach(L=>b(L));return}f.insertBefore(document.createTextNode(String(g)),i)}};b(S),f.removeChild(i)},E=document.createTreeWalker(l.content,NodeFilter.SHOW_COMMENT),h=[];for(;E.nextNode();){let i=E.currentNode;i?.nodeValue?.startsWith("pds-val-")&&h.push(i)}return h.forEach(i=>{let S=Number(i.nodeValue.replace("pds-val-",""));y(i,n[S])}),l.content.querySelectorAll("*").forEach(i=>{let S=i.getAttribute("data-pds-prop");if(!S)return;let[f,b]=S.split(":"),g=Number(String(b).replace("pds-val-",""));f&&Number.isInteger(g)&&(i[f]=n[g]),i.removeAttribute("data-pds-prop")}),l.content}function Z(e){return new DOMParser().parseFromString(e,"text/html").body.childNodes}var ge="pds",$e=/^([a-z][a-z0-9+\-.]*:)?\/\//i,Se=/^[a-z]:/i;function U(e=""){return e.endsWith("/")?e:`${e}/`}function Oe(e="",t=ge){let n=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(n)?n:`${n}/${t}`}function Ie(e){return e.replace(/^\.\/+/,"")}function Ne(e){return Se.test(e)?e.replace(Se,"").replace(/^\/+/,""):e}function ze(e){return e.startsWith("public/")?e.substring(7):e}function N(e,t={}){let n=t.segment||ge,r=t.defaultRoot||`/assets/${n}/`,a=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!a||typeof a!="string")return U(r);let o=a.trim();return o?(o=o.replace(/\\/g,"/"),o=Oe(o,n),o=U(o),$e.test(o)?o:(o=Ie(o),o=Ne(o),o.startsWith("/")||(o=ze(o),o.startsWith("/")||(o=`/${o}`),o=o.replace(/\/+/g,(l,y)=>y===0?l:"/")),U(o))):U(r)}async function Fe(...e){let t={};e.length&&typeof e[e.length-1]=="object"&&(t=e.pop()||{});let n=e,{baseURL:r,mapper:a=h=>`${h}.js`,onError:o=(h,c)=>console.error(`[defineWebComponents] ${h}:`,c)}=t,l=r?new URL(r,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),y=h=>h.toLowerCase().replace(/(^|-)([a-z])/g,(c,i,S)=>S.toUpperCase()),E=async h=>{try{if(customElements.get(h))return{tag:h,status:"already-defined"};let c=a(h),S=await import(c instanceof URL?c.href:new URL(c,l).href),f=S?.default??S?.[y(h)];if(!f){if(customElements.get(h))return{tag:h,status:"self-defined"};throw new Error(`No export found for ${h}. Expected default export or named export "${y(h)}".`)}return customElements.get(h)?{tag:h,status:"race-already-defined"}:(customElements.define(h,f),{tag:h,status:"defined"})}catch(c){throw o(h,c),c}};return Promise.all(n.map(E))}var z=class{constructor(t={}){let{baseURL:n,mapper:r,onError:a,predicate:o=()=>!0,attributeModule:l="data-module",root:y=document,scanExisting:E=!0,debounceMs:h=16,observeShadows:c=!0,enhancers:i=[],patchAttachShadow:S=!0}=t,f=new Set,b=new Set,g=new Set,L=new Map,x=new WeakMap,_=new WeakMap,m=0,w=!1,v=null,O=d=>{if(!d||!i.length)return;let p=_.get(d);p||(p=new Set,_.set(d,p));for(let u of i)if(!(!u.selector||!u.run)&&!p.has(u.selector))try{d.matches&&d.matches(u.selector)&&(u.run(d),p.add(u.selector))}catch(A){console.warn(`[AutoDefiner] Error applying enhancer for selector "${u.selector}":`,A)}},k=(d,p)=>{if(!w&&!(!d||!d.includes("-"))&&!customElements.get(d)&&!b.has(d)&&!g.has(d)){if(p&&p.getAttribute){let u=p.getAttribute(l);u&&!L.has(d)&&L.set(d,u)}f.add(d),ke()}},ke=()=>{m||(m=setTimeout(de,h))},D=d=>{if(d){if(d.nodeType===1){let p=d,u=p.tagName?.toLowerCase();u&&u.includes("-")&&!customElements.get(u)&&o(u,p)&&k(u,p),O(p),c&&p.shadowRoot&&J(p.shadowRoot)}d.querySelectorAll&&d.querySelectorAll("*").forEach(p=>{let u=p.tagName?.toLowerCase();u&&u.includes("-")&&!customElements.get(u)&&o(u,p)&&k(u,p),O(p),c&&p.shadowRoot&&J(p.shadowRoot)})}},J=d=>{if(!d||x.has(d))return;D(d);let p=new MutationObserver(u=>{for(let A of u)A.addedNodes?.forEach(P=>{D(P)}),A.type==="attributes"&&A.target&&D(A.target)});p.observe(d,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...i.map(u=>u.selector).filter(u=>u.startsWith("data-"))]}),x.set(d,p)};async function de(){if(clearTimeout(m),m=0,!f.size)return;let d=Array.from(f);f.clear(),d.forEach(p=>b.add(p));try{let p=u=>L.get(u)??(r?r(u):`${u}.js`);await Fe(...d,{baseURL:n,mapper:p,onError:(u,A)=>{g.add(u),a?.(u,A)}})}catch{}finally{d.forEach(p=>b.delete(p))}}let ue=y===document?document.documentElement:y,pe=new MutationObserver(d=>{for(let p of d)p.addedNodes?.forEach(u=>{D(u)}),p.type==="attributes"&&p.target&&D(p.target)});if(pe.observe(ue,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...i.map(d=>d.selector).filter(d=>d.startsWith("data-"))]}),c&&S&&Element.prototype.attachShadow){let d=Element.prototype.attachShadow;Element.prototype.attachShadow=function(u){let A=d.call(this,u);if(u&&u.mode==="open"){J(A);let P=this.tagName?.toLowerCase();P&&P.includes("-")&&!customElements.get(P)&&k(P,this)}return A},v=()=>Element.prototype.attachShadow=d}return E&&D(ue),{stop(){w=!0,pe.disconnect(),v&&v(),m&&(clearTimeout(m),m=0),x.forEach(d=>d.disconnect())},flush:de}}static async define(...t){let n={};t.length&&typeof t[t.length-1]=="object"&&(n=t.pop()||{});let r=t,{baseURL:a,mapper:o=c=>`${c}.js`,onError:l=(c,i)=>console.error(`[defineWebComponents] ${c}:`,i)}=n,y=a?new URL(a,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),E=c=>c.toLowerCase().replace(/(^|-)([a-z])/g,(i,S,f)=>f.toUpperCase()),h=async c=>{try{if(customElements.get(c))return{tag:c,status:"already-defined"};let i=o(c),f=await import(i instanceof URL?i.href:new URL(i,y).href),b=f?.default??f?.[E(c)];if(!b){if(customElements.get(c))return{tag:c,status:"self-defined"};throw new Error(`No export found for ${c}. Expected default export or named export "${E(c)}".`)}return customElements.get(c)?{tag:c,status:"race-already-defined"}:(customElements.define(c,b),{tag:c,status:"defined"})}catch(i){throw l(c,i),i}};return Promise.all(r.map(h))}};var We=/^[a-z][a-z0-9+\-.]*:\/\//i,C=(()=>{try{return import.meta.url}catch{return}})(),F=e=>typeof e=="string"&&e.length&&!e.endsWith("/")?`${e}/`:e;function W(e,t={}){if(!e||We.test(e))return e;let{preferModule:n=!0}=t,r=()=>{if(!C)return null;try{return new URL(e,C).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 Ee=(()=>{if(C)try{let e=new URL(C);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",C).href}catch{return}})(),be=!1;function _e(e){be||typeof document>"u"||(be=!0,e.addEventListener("pds:ready",t=>{let n=t.detail?.mode;n&&document.documentElement.classList.add(`pds-${n}`,"pds-ready")}))}function Le({manageTheme:e,themeStorageKey:t,applyResolvedTheme:n,setupSystemListenerIfNeeded:r}){let a="light",o=null;if(e&&typeof window<"u"){try{o=localStorage.getItem(t)||null}catch{o=null}try{n?.(o),r?.(o)}catch{}o?o==="system"?a=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":a=o:a=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:a,storedTheme:o}}function B(e,{resolvePublicAssetURL:t}){let n=!!(e?.public?.root||e?.static?.root),r=t(e);return!n&&Ee&&(r=Ee),F(W(r))}async function Ae(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:n="/auto-define/",autoDefinePreload:r=[],autoDefineMapper:a=null,enhancers:o=[],autoDefineOverrides:l=null,autoDefinePreferModule:y=!0}=e,E=(()=>{let c=new Map;return(t||[]).forEach(i=>c.set(i.selector,i)),(o||[]).forEach(i=>c.set(i.selector,i)),Array.from(c.values())})(),h=null;if(typeof window<"u"&&typeof document<"u"){let c=z,i=m=>{switch(m){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${m}.js`}},{mapper:S,enhancers:f,...b}=l&&typeof l=="object"?l:{},g=f?Array.isArray(f)?f:typeof f=="object"?Object.values(f):[]:[],L=(()=>{let m=new Map;return(E||[]).forEach(w=>{w?.selector&&m.set(w.selector,w)}),(g||[]).forEach(w=>{if(!w?.selector)return;let v=m.get(w.selector)||null;m.set(w.selector,{...v||{},...w,run:typeof w?.run=="function"?w.run:v?.run})}),Array.from(m.values())})(),_={baseURL:n&&F(W(n,{preferModule:y})),predefine:r,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:L,onError:(m,w)=>{if(typeof m=="string"&&m.startsWith("pds-")){let O=["pds-form","pds-drawer"].includes(m),k=w?.message?.includes("#pds/lit")||w?.message?.includes("Failed to resolve module specifier");O&&k?console.error(`\u274C PDS component <${m}> 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`):console.warn(`\u26A0\uFE0F PDS component <${m}> not found. Assets may not be installed.`)}else console.error(`\u274C Auto-define error for <${m}>:`,w)},...b,mapper:m=>{if(customElements.get(m))return null;if(typeof a=="function")try{let w=a(m);return w===void 0?i(m):w}catch(w){return console.warn("Custom autoDefine.mapper error; falling back to default:",w?.message||w),i(m)}return i(m)}};h=new c(_),r.length>0&&typeof c.define=="function"&&await c.define(...r,{baseURL:n,mapper:_.mapper,onError:_.onError})}return{autoDefiner:h,mergedEnhancers:E}}var te=["light","dark"],ne=new Set(te);function Be(e){let n=(Array.isArray(e?.themes)?e.themes.map(r=>String(r).toLowerCase()):te).filter(r=>ne.has(r));return n.length?n:te}function re(e,{preferDocument:t=!0}={}){let n=String(e||"").toLowerCase();if(ne.has(n))return n;if(t&&typeof document<"u"){let r=document.documentElement?.getAttribute("data-theme");if(ne.has(r))return r}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function xe(e,t){let n=re(t);return Be(e).includes(n)}var ie=class extends EventTarget{},Re="__PURE_DS_PDS_SINGLETON__",ae=typeof globalThis<"u"?globalThis:window,se=ae?.[Re],s=se&&typeof se.addEventListener=="function"?se:new ie;ae&&(ae[Re]=s);typeof s.initializing!="boolean"&&(s.initializing=!1);"currentPreset"in s||(s.currentPreset=null);typeof s.debug!="boolean"&&(s.debug=!1);"currentConfig"in s||(s.currentConfig=null);"compiled"in s||(s.compiled=null);var q=null,V=null,H=null,G=null;function K(e,t){return t&&typeof t=="string"?t:`${B(s.currentConfig||{},{resolvePublicAssetURL:N})}core/${e}`}async function qe(){return Array.isArray(s.defaultEnhancers)&&s.defaultEnhancers.length>0?s.defaultEnhancers:(G||(G=import(K("pds-enhancers.js",s.currentConfig?.enhancersURL)).then(t=>{let n=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return s.defaultEnhancers=n,n}).catch(t=>{throw G=null,t})),G)}async function Ve(){return typeof s.ask=="function"&&s.ask!==De?s.ask:(V||(V=import(K("pds-ask.js",s.currentConfig?.askURL)).then(t=>{let n=t?.ask;if(typeof n!="function")throw new Error("Failed to load ask helper");return s.ask=n,n}).catch(t=>{throw V=null,t})),V)}async function $(){return typeof s.toast=="function"&&s.toast!==T?s.toast:(H||(H=import(K("pds-toast.js",s.currentConfig?.toastURL)).then(t=>{let n=t?.toast;if(typeof n!="function")throw new Error("Failed to load toast helper");return s.toast=n,n}).catch(t=>{throw H=null,t})),H)}async function De(...e){return(await Ve())(...e)}async function T(...e){return(await $())(...e)}T.success=async(...e)=>(await $()).success(...e);T.error=async(...e)=>(await $()).error(...e);T.warning=async(...e)=>(await $()).warning(...e);T.info=async(...e)=>(await $()).info(...e);var ve=function(e="log",t,...n){let r=!!(s.registry&&!s.registry.isLive),a=(this?.debug||this?.design?.debug||s.debug||!1)===!0;if(r){if(!s.debug)return}else if(!a&&e!=="error"&&e!=="warn")return;let o=console[e]||console.log;n.length>0?o(t,...n):o(t)};function ce(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=>ce(n)).filter(n=>n!==void 0);let t={};for(let[n,r]of Object.entries(e)){let a=ce(r);a!==void 0&&(t[n]=a)}return t}function Pe(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))Pe(e[n],t);return e}function le(e){return e==null||typeof e!="object"?e:Pe(structuredClone(ce(e)))}async function He(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}}s.registry=M;s.enums=ye;s.adoptLayers=me;s.adoptPrimitives=fe;s.parse=Z;s.createStylesheet=he;s.isLiveMode=()=>M.isLive;s.ask=De;s.toast=T;s.common=ee;s.AutoComplete=null;s.loadAutoComplete=async()=>{if(s.AutoComplete&&typeof s.AutoComplete.connect=="function")return s.AutoComplete;let e=K("pds-autocomplete.js",s.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 s.AutoComplete=n,n}).catch(t=>{throw q=null,t})),q};function Me(e){let t=typeof CustomEvent=="function";try{let n=t?new CustomEvent("pds:ready",{detail:e}):new Event("pds:ready");s.dispatchEvent(n)}catch{}if(typeof document<"u")if(t){let n={detail:e,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:ready",n))}catch{}try{document.dispatchEvent(new CustomEvent("pds-ready",n))}catch{}}else{try{document.dispatchEvent(new Event("pds:ready"))}catch{}try{document.dispatchEvent(new Event("pds-ready"))}catch{}}}function Te(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");s.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 oe="pure-ds-theme",R=null,j=null;function Q(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 Y(e){try{if(R&&j){try{typeof R.removeEventListener=="function"?R.removeEventListener("change",j):typeof R.removeListener=="function"&&R.removeListener(j)}catch{}R=null,j=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 o=a?"dark":"light";document.documentElement.setAttribute("data-theme",o),s.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:o,source:"system"}}))}catch{}};R=t,j=n,typeof t.addEventListener=="function"?t.addEventListener("change",n):typeof t.addListener=="function"&&t.addListener(n)}}catch{}}var Ge=Object.getOwnPropertyDescriptor(s,"theme");Ge||Object.defineProperty(s,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(oe)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=s.currentConfig?.design||null,n=re(e);if(t&&!xe(t,n)){let r=t?.name||s.currentPreset?.name||s.currentConfig?.preset||"current preset";console.warn(`PDS theme "${n}" not supported by preset "${r}".`),s.dispatchEvent(new CustomEvent("pds:theme:blocked",{detail:{theme:e,resolvedTheme:n,preset:r}}));return}e==null?localStorage.removeItem(oe):localStorage.setItem(oe,e),Q(e),Y(e),s.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});s.defaultEnhancers=[];async function Ke(e){s.initializing=!0;try{let t=e&&e.mode||"live",{mode:n,...r}=e||{};s.currentConfig=le(r);let a;if(t==="static")a=await Qe(r);else{let l=B(r,{resolvePublicAssetURL:N}),y=r?.managerURL||r?.public?.managerURL||r?.manager?.url||new URL("core/pds-manager.js",l).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:E}=await import(y);a=await E(s,r,{emitReady:Me,emitConfigChanged:Te,applyResolvedTheme:Q,setupSystemListenerIfNeeded:Y})}s.compiled=le(a?.config||null);let o=s?.compiled?.design?.icons?.externalPath||"/assets/img/icons/";return typeof console<"u"&&typeof console.info=="function"&&console.info(`[PDS] startup ready; external icon path: ${o}`),a}finally{s.initializing=!1}}s.start=Ke;async function Qe(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??{},o=B(e,{resolvePublicAssetURL:N}),l=e&&e.autoDefine||null,y;l&&l.baseURL?y=F(W(l.baseURL,{preferModule:!1})):y=`${o}components/`;let E=l&&Array.isArray(l.predefine)&&l.predefine||[],h=l&&typeof l.mapper=="function"&&l.mapper||null;try{_e(s);let{resolvedTheme:c}=Le({manageTheme:n,themeStorageKey:r,applyResolvedTheme:Q,setupSystemListenerIfNeeded:Y}),i=await He(o,e),S=Array.isArray(e?.enhancers)?e.enhancers:e?.enhancers&&typeof e.enhancers=="object"?Object.values(e.enhancers):[],f=i?.config?{...i.config,...e,design:e?.design||i.config.design,preset:e?.preset||i.config.preset}:{...e},b={tokens:`${o}styles/pds-tokens.css.js`,primitives:`${o}styles/pds-primitives.css.js`,components:`${o}styles/pds-components.css.js`,utilities:`${o}styles/pds-utilities.css.js`,styles:`${o}styles/pds-styles.css.js`},g=i?.paths||{};if(a={...b,...g,...a},s.registry.setStaticMode(a),t&&typeof document<"u")try{let _=await s.registry.getStylesheet("styles");if(_){_._pds=!0;let m=(document.adoptedStyleSheets||[]).filter(w=>w._pds!==!0);document.adoptedStyleSheets=[...m,_],Te({mode:"static",source:"static:styles-applied"})}}catch(_){ve.call(s,"warn","Failed to apply static styles:",_)}let L=null,x=[];try{let _=await qe(),m=await Ae({autoDefineBaseURL:y,autoDefinePreload:E,autoDefineMapper:h,enhancers:S,autoDefineOverrides:l||null,autoDefinePreferModule:!(l&&l.baseURL)},{baseEnhancers:_});L=m.autoDefiner,x=m.mergedEnhancers||[]}catch(_){ve.call(s,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",_)}return s.compiled=le({mode:"static",...f,theme:c,enhancers:x}),Me({mode:"static",config:f,theme:c,autoDefiner:L}),{config:f,theme:c,autoDefiner:L}}catch(c){throw s.dispatchEvent(new CustomEvent("pds:error",{detail:{error:c}})),c}}var pt=Q,ft=Y;export{s as PDS,pt as applyResolvedTheme,ft as setupSystemListenerIfNeeded};
|
|
@@ -590,21 +590,9 @@ export class SvgIcon extends HTMLElement {
|
|
|
590
590
|
*/
|
|
591
591
|
static getExternalIconPath() {
|
|
592
592
|
try {
|
|
593
|
-
const
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
PDS?.currentConfig?.icons?.externalPath,
|
|
597
|
-
PDS?.compiled?.config?.design?.icons?.externalPath,
|
|
598
|
-
PDS?.compiled?.config?.icons?.externalPath,
|
|
599
|
-
PDS?.compiled?.options?.design?.icons?.externalPath,
|
|
600
|
-
PDS?.compiled?.options?.icons?.externalPath,
|
|
601
|
-
PDS?.compiled?.tokens?.icons?.externalPath,
|
|
602
|
-
];
|
|
603
|
-
|
|
604
|
-
for (const value of candidates) {
|
|
605
|
-
if (typeof value === 'string' && value.trim()) {
|
|
606
|
-
return value;
|
|
607
|
-
}
|
|
593
|
+
const value = PDS?.compiled?.design?.icons?.externalPath;
|
|
594
|
+
if (typeof value === 'string' && value.trim()) {
|
|
595
|
+
return value;
|
|
608
596
|
}
|
|
609
597
|
} catch (e) {
|
|
610
598
|
// Ignore errors accessing config
|
|
@@ -620,16 +608,8 @@ export class SvgIcon extends HTMLElement {
|
|
|
620
608
|
*/
|
|
621
609
|
static hasConfiguredExternalIconPath() {
|
|
622
610
|
try {
|
|
623
|
-
const
|
|
624
|
-
|
|
625
|
-
PDS?.compiled?.config?.design?.icons?.externalPath,
|
|
626
|
-
PDS?.compiled?.config?.icons?.externalPath,
|
|
627
|
-
PDS?.compiled?.options?.design?.icons?.externalPath,
|
|
628
|
-
PDS?.compiled?.options?.icons?.externalPath,
|
|
629
|
-
PDS?.currentConfig?.design?.icons?.externalPath,
|
|
630
|
-
PDS?.currentConfig?.icons?.externalPath,
|
|
631
|
-
];
|
|
632
|
-
return candidates.some((value) => typeof value === 'string' && value.trim().length > 0);
|
|
611
|
+
const value = PDS?.compiled?.design?.icons?.externalPath;
|
|
612
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
633
613
|
} catch (error) {
|
|
634
614
|
return false;
|
|
635
615
|
}
|
|
@@ -1321,12 +1321,6 @@ function buildFontFamilyOmniboxSettings() {
|
|
|
1321
1321
|
|
|
1322
1322
|
return items;
|
|
1323
1323
|
},
|
|
1324
|
-
action: (options) => {
|
|
1325
|
-
const input = document.querySelector("pds-omnibox");
|
|
1326
|
-
if (input) {
|
|
1327
|
-
input.value = options.text;
|
|
1328
|
-
}
|
|
1329
|
-
},
|
|
1330
1324
|
},
|
|
1331
1325
|
},
|
|
1332
1326
|
};
|
|
@@ -1891,6 +1885,8 @@ async function createConfiguredForm({
|
|
|
1891
1885
|
form.defineRenderer(
|
|
1892
1886
|
"font-family-omnibox",
|
|
1893
1887
|
({ id, path, value, attrs, set }) => {
|
|
1888
|
+
const omnibox = document.createElement("pds-omnibox");
|
|
1889
|
+
|
|
1894
1890
|
const resolveSelectedValue = (options, actionResult, selectionEvent) => {
|
|
1895
1891
|
if (typeof actionResult === "string" && actionResult.trim()) {
|
|
1896
1892
|
return actionResult;
|
|
@@ -1956,6 +1952,7 @@ async function createConfiguredForm({
|
|
|
1956
1952
|
);
|
|
1957
1953
|
if (selected) {
|
|
1958
1954
|
set(selected);
|
|
1955
|
+
omnibox.value = selected;
|
|
1959
1956
|
}
|
|
1960
1957
|
|
|
1961
1958
|
return actionResult;
|
|
@@ -1965,8 +1962,6 @@ async function createConfiguredForm({
|
|
|
1965
1962
|
}
|
|
1966
1963
|
)
|
|
1967
1964
|
);
|
|
1968
|
-
|
|
1969
|
-
const omnibox = document.createElement("pds-omnibox");
|
|
1970
1965
|
omnibox.id = id;
|
|
1971
1966
|
omnibox.setAttribute("name", path);
|
|
1972
1967
|
omnibox.setAttribute("item-grid", "0 1fr 0");
|
|
@@ -564,12 +564,15 @@ export class PdsOmnibox extends HTMLElement {
|
|
|
564
564
|
}
|
|
565
565
|
|
|
566
566
|
if (AutoComplete && typeof AutoComplete.connect === "function") {
|
|
567
|
+
const settingsWithDefaultActions = this.#normalizeSettings(
|
|
568
|
+
this.settings,
|
|
569
|
+
);
|
|
567
570
|
const settings = {
|
|
568
571
|
//debug: true,
|
|
569
572
|
iconHandler: (item) => {
|
|
570
573
|
return item.icon ? `<pds-icon icon="${item.icon}"></pds-icon>` : null;
|
|
571
574
|
},
|
|
572
|
-
...
|
|
575
|
+
...settingsWithDefaultActions,
|
|
573
576
|
};
|
|
574
577
|
|
|
575
578
|
const container = this.#input?.parentElement;
|
|
@@ -607,6 +610,39 @@ export class PdsOmnibox extends HTMLElement {
|
|
|
607
610
|
}
|
|
608
611
|
}
|
|
609
612
|
|
|
613
|
+
#normalizeSettings(settings) {
|
|
614
|
+
if (!settings || typeof settings !== "object") return settings;
|
|
615
|
+
const categories = settings.categories;
|
|
616
|
+
if (!categories || typeof categories !== "object") return settings;
|
|
617
|
+
|
|
618
|
+
const normalizedCategories = Object.fromEntries(
|
|
619
|
+
Object.entries(categories).map(([categoryName, categoryConfig]) => {
|
|
620
|
+
if (!categoryConfig || typeof categoryConfig !== "object") {
|
|
621
|
+
return [categoryName, categoryConfig];
|
|
622
|
+
}
|
|
623
|
+
if (typeof categoryConfig.action === "function") {
|
|
624
|
+
return [categoryName, categoryConfig];
|
|
625
|
+
}
|
|
626
|
+
return [
|
|
627
|
+
categoryName,
|
|
628
|
+
{
|
|
629
|
+
...categoryConfig,
|
|
630
|
+
action: (options = {}) => {
|
|
631
|
+
const nextValue = options?.text ?? options?.value ?? options?.id ?? "";
|
|
632
|
+
this.value = nextValue == null ? "" : String(nextValue);
|
|
633
|
+
return nextValue;
|
|
634
|
+
},
|
|
635
|
+
},
|
|
636
|
+
];
|
|
637
|
+
}),
|
|
638
|
+
);
|
|
639
|
+
|
|
640
|
+
return {
|
|
641
|
+
...settings,
|
|
642
|
+
categories: normalizedCategories,
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
|
|
610
646
|
#wrapAutoCompleteResultsHandler(autoComplete) {
|
|
611
647
|
if (!autoComplete || autoComplete.__pdsSuggestionsWrapped) return;
|
|
612
648
|
autoComplete.__pdsSuggestionsWrapped = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var F=[{selector:".accordion"},{selector:"nav[data-dropdown]"},{selector:"label[data-toggle]"},{selector:"label[data-color]"},{selector:'input[type="range"]'},{selector:"form[data-required]"},{selector:"fieldset[role=group][data-open]"},{selector:"[data-clip]"},{selector:"button, a[class*='btn-']"}];function W(t){t.dataset.enhancedAccordion||(t.dataset.enhancedAccordion="true",t.addEventListener("toggle",e=>{e.target.open&&e.target.parentElement===t&&t.querySelectorAll(":scope > details[open]").forEach(n=>{n!==e.target&&(n.open=!1)})},!0))}function H(t){if(t.dataset.enhancedDropdown)return;t.dataset.enhancedDropdown="true";let e=t.lastElementChild;if(!e)return;let n=t.querySelector("[data-dropdown-toggle]")||t.querySelector("button");n&&!n.hasAttribute("type")&&n.setAttribute("type","button"),e.id||(e.id=`dropdown-${Math.random().toString(36).slice(2,9)}`);let o=e.tagName?.toLowerCase()==="menu",a=8;o&&!e.hasAttribute("role")&&e.setAttribute("role","menu"),e.hasAttribute("aria-hidden")||e.setAttribute("aria-hidden","true"),n&&(n.setAttribute("aria-haspopup","true"),n.setAttribute("aria-controls",e.id),n.setAttribute("aria-expanded","false"));let c=()=>{let s=e.getAttribute("style");e.style.visibility="hidden",e.style.display="inline-block",e.style.pointerEvents="none";let h=e.getBoundingClientRect(),f=Math.max(e.offsetWidth||0,e.scrollWidth||0,h.width||0,1),d=Math.max(e.offsetHeight||0,e.scrollHeight||0,h.height||0,1);return s===null?e.removeAttribute("style"):e.setAttribute("style",s),{width:f,height:d}},i=()=>{let s=(t.getAttribute("data-direction")||t.getAttribute("data-dropdown-direction")||t.getAttribute("data-mode")||"auto").toLowerCase();if(s==="up"||s==="down")return s;let h=(n||t).getBoundingClientRect(),{height:f}=c(),d=Math.max(0,window.innerHeight-h.bottom),b=Math.max(0,h.top),v=d>=f,y=b>=f;return v&&!y?"down":y&&!v?"up":v&&y?"down":b>d?"up":"down"},r=()=>{let s=(t.getAttribute("data-align")||t.getAttribute("data-dropdown-align")||"auto").toLowerCase();if(s==="left"||s==="right"||s==="start"||s==="end")return s==="start"?"left":s==="end"?"right":s;let h=(n||t).getBoundingClientRect(),{width:f}=c(),d=Math.max(0,window.innerWidth-h.left),b=Math.max(0,h.right),v=d>=f,y=b>=f;return v&&!y?"left":y&&!v?"right":v&&y?"left":b>d?"right":"left"},p=(s,h=8)=>{let f=getComputedStyle(t).getPropertyValue(s).trim();if(!f)return h;let d=document.createElement("span");d.style.position="fixed",d.style.visibility="hidden",d.style.pointerEvents="none",d.style.height=f,document.body.appendChild(d);let b=Number.parseFloat(getComputedStyle(d).height);return d.remove(),Number.isFinite(b)?b:h},u=()=>{e.style.removeProperty("position"),e.style.removeProperty("left"),e.style.removeProperty("top"),e.style.removeProperty("right"),e.style.removeProperty("bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("max-width"),e.style.removeProperty("max-inline-size"),e.style.removeProperty("max-height"),e.style.removeProperty("overflow")},l=()=>{e.getAttribute("aria-hidden")==="false"&&(u(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{w()})}))},w=()=>{if(e.getAttribute("aria-hidden")!=="false")return;let s=(n||t).getBoundingClientRect(),h=window.visualViewport,f=h?.width||document.documentElement?.clientWidth||window.innerWidth,d=h?.height||document.documentElement?.clientHeight||window.innerHeight,b=h?.offsetLeft||0,v=h?.offsetTop||0,y=Math.max(1,f-a*2),T=Math.max(1,d-a*2);e.style.maxWidth=`${Math.round(y)}px`,e.style.maxInlineSize=`${Math.round(y)}px`,e.style.maxHeight=`${Math.round(T)}px`,e.style.overflow="auto";let{width:k,height:M}=c(),q=p("--spacing-2",8),P=i(),R=r();t.dataset.dropdownDirection=P,t.dataset.dropdownAlign=R;let C=R==="right"?s.right-k:s.left;k>=y-1?C=b+a:C=Math.max(b+a,Math.min(C,b+f-k-a));let S=P==="up"?s.top-q-M:s.bottom+q;S=Math.max(v+a,Math.min(S,v+d-M-a)),e.style.position="fixed",e.style.left=`${Math.round(C)}px`,e.style.top=`${Math.round(S)}px`,e.style.right="auto",e.style.bottom="auto",e.style.marginTop="0",e.style.marginBottom="0"},g=null,E=()=>{g||(g=()=>w(),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0))},L=()=>{g&&(window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0),g=null)},m=null,O=()=>{m||typeof document>"u"||(m=()=>{e.getAttribute("aria-hidden")==="false"&&(t.dataset.dropdownDirection=i(),t.dataset.dropdownAlign=r(),l(),setTimeout(()=>{e.getAttribute("aria-hidden")==="false"&&l()},50),setTimeout(()=>{e.getAttribute("aria-hidden")==="false"&&l()},150))},document.addEventListener("pds:config-changed",m))},D=()=>{!m||typeof document>"u"||(document.removeEventListener("pds:config-changed",m),m=null)},A=null,I=()=>{t.dataset.dropdownDirection=i(),t.dataset.dropdownAlign=r(),e.setAttribute("aria-hidden","false"),n?.setAttribute("aria-expanded","true"),E(),O(),l(),A||(A=s=>{(s.composedPath?s.composedPath():[s.target]).some(d=>d===t)||x()},setTimeout(()=>{document.addEventListener("click",A)},0))},x=()=>{e.setAttribute("aria-hidden","true"),n?.setAttribute("aria-expanded","false"),L(),D(),u(),A&&(document.removeEventListener("click",A),A=null)},B=()=>{e.getAttribute("aria-hidden")==="false"?x():I()};n?.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),B()}),t.addEventListener("keydown",s=>{s.key==="Escape"&&(x(),n?.focus())}),t.addEventListener("focusout",s=>{s.relatedTarget&&((s.composedPath?s.composedPath():[s.relatedTarget]).some(d=>d===t)||x())})}function N(t){if(t.dataset.enhancedToggle)return;t.dataset.enhancedToggle="true";let e=t.querySelector('input[type="checkbox"]');if(!e)return;t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"),t.setAttribute("role","switch"),t.setAttribute("aria-checked",e.checked?"true":"false");let n=document.createElement("span");n.className="toggle-switch",n.setAttribute("role","presentation"),n.setAttribute("aria-hidden","true");let o=document.createElement("span");o.className="toggle-knob",n.appendChild(o),t.insertBefore(n,e.nextSibling);let a=()=>{t.setAttribute("aria-checked",e.checked?"true":"false")},c=()=>{e.disabled||(e.checked=!e.checked,a(),e.dispatchEvent(new Event("change",{bubbles:!0})))};t.addEventListener("click",i=>{i.preventDefault(),c()}),t.addEventListener("keydown",i=>{(i.key===" "||i.key==="Enter")&&(i.preventDefault(),c())}),e.addEventListener("change",a)}function $(t){if(t.dataset.enhancedColorInput)return;let e=t.querySelector('input[type="color"]');if(!e)return;t.dataset.enhancedColorInput="true";let n=t.querySelector(":scope > .color-control"),o=t.querySelector(":scope > .color-control > .color-swatch"),a=t.querySelector(":scope > .color-control > output");n||(n=document.createElement("span"),n.className="color-control",e.before(n)),o||(o=document.createElement("span"),o.className="color-swatch",n.appendChild(o)),e.parentElement!==o&&o.appendChild(e),a||(a=document.createElement("output"),n.appendChild(a));let c=()=>{if(e.dataset.colorUnset==="1"){a.value="",a.textContent="not set",n.dataset.value="",n.dataset.unset="1",o.dataset.unset="1";return}a.value=e.value,a.textContent=e.value,n.dataset.value=e.value,delete n.dataset.unset,delete o.dataset.unset};c();let i=()=>{e.dataset.colorUnset==="1"&&(e.dataset.colorUnset="0"),c()};e.addEventListener("input",i,{passive:!0}),e.addEventListener("change",i,{passive:!0})}function U(t){if(t.dataset.enhancedRange)return;let e=i=>{if(t.dataset.enhancedRangeProgrammatic)return;t.dataset.enhancedRangeProgrammatic="1";let r=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),"value")||Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");r?.get&&r?.set&&Object.defineProperty(t,"value",{configurable:!0,enumerable:r.enumerable,get(){return r.get.call(this)},set(u){r.set.call(this,u),i()}}),new MutationObserver(u=>{u.some(w=>{let g=w.attributeName;return g==="value"||g==="min"||g==="max"})&&i()}).observe(t,{attributes:!0,attributeFilter:["value","min","max"]})},n=t.closest("label"),o=n?.classList.contains("range-output"),a=t.id||`range-${Math.random().toString(36).substring(2,11)}`,c=`${a}-output`;if(t.id=a,o){let i=n.querySelector("span");if(i&&!i.classList.contains("range-output-wrapper")){let r=document.createElement("span");r.className="range-output-wrapper",r.style.display="flex",r.style.justifyContent="space-between",r.style.alignItems="center";let p=document.createElement("span");p.textContent=i.textContent,r.appendChild(p);let u=document.createElement("output");u.id=c,u.setAttribute("for",a),u.style.color="var(--surface-text-secondary, var(--color-text-secondary))",u.style.fontSize="0.875rem",u.textContent=t.value,r.appendChild(u),i.textContent="",i.appendChild(r);let l=()=>{u.textContent=t.value};t.addEventListener("input",l),t.addEventListener("change",l),e(l),l()}}else{let i=t.closest(".range-container");i||(i=document.createElement("div"),i.className="range-container",t.parentNode?.insertBefore(i,t),i.appendChild(t)),i.style.position="relative";let r=document.createElement("output");r.id=c,r.setAttribute("for",a),r.className="range-bubble",r.setAttribute("aria-live","polite"),i.appendChild(r);let p=()=>{let w=parseFloat(t.min)||0,g=parseFloat(t.max)||100,E=parseFloat(t.value),L=(E-w)/(g-w);r.style.left=`calc(${L*100}% )`,r.textContent=String(E)},u=()=>r.classList.add("visible"),l=()=>r.classList.remove("visible");t.addEventListener("input",p),t.addEventListener("pointerdown",u),t.addEventListener("pointerup",l),t.addEventListener("pointerleave",l),t.addEventListener("focus",u),t.addEventListener("blur",l),t.addEventListener("change",p),e(p),p()}t.dataset.enhancedRange="1"}function z(t){if(t.dataset.enhancedRequired)return;t.dataset.enhancedRequired="true";let e=n=>{let o;if(n.closest("[role$=group]")?o=n.closest("[role$=group]").querySelector("legend"):o=n.closest("label"),!o||o.querySelector(".required-asterisk"))return;let a=document.createElement("span");a.classList.add("required-asterisk"),a.textContent="*",a.style.marginLeft="4px";let c=o.querySelector("span, [data-label]");if(c)c.appendChild(a);else{let r=o.querySelector("input, select, textarea");r?o.insertBefore(a,r):o.appendChild(a)}let i=n.closest("form");if(i&&!i.querySelector(".required-legend")){let r=document.createElement("small");r.classList.add("required-legend"),r.textContent="* Required fields",i.insertBefore(r,i.querySelector(".form-actions")||i.lastElementChild)}};t.querySelectorAll("[required]").forEach(n=>{e(n)})}function j(t){if(t.dataset.enhancedOpenGroup)return;t.dataset.enhancedOpenGroup="true",t.classList.add("flex","flex-wrap","buttons");let e=document.createElement("input");e.type="text",e.placeholder="Add item...",e.classList.add("input-text","input-sm"),e.style.width="auto";let n=()=>t.querySelector('input[type="radio"], input[type="checkbox"]');t.appendChild(e),e.addEventListener("keydown",o=>{if(o.key==="Enter"||o.key==="Tab"){let a=e.value.trim();if(a){o.preventDefault();let c=n(),i=c?.type==="radio"?"radio":"checkbox",r=`open-group-${Math.random().toString(36).substring(2,11)}`,p=document.createElement("label"),u=document.createElement("span");u.setAttribute("data-label",""),u.textContent=a;let l=document.createElement("input");l.type=i,l.name=c?.name||t.getAttribute("data-name")||"open-group",l.value=a,l.id=r,p.appendChild(u),p.appendChild(l),t.insertBefore(p,e),e.value=""}}else if(o.key==="Backspace"&&e.value===""){o.preventDefault();let a=t.querySelectorAll("label");a.length>0&&a[a.length-1].remove()}})}function V(t){if(t.dataset.enhancedClip)return;t.dataset.enhancedClip="true",t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"),t.hasAttribute("role")||t.setAttribute("role","button");let e=()=>{let o=t.getAttribute("data-clip-open")==="true";t.setAttribute("aria-expanded",o?"true":"false")},n=()=>{let o=t.getAttribute("data-clip-open")==="true";t.setAttribute("data-clip-open",o?"false":"true"),e()};t.addEventListener("click",o=>{o.defaultPrevented||n()}),t.addEventListener("keydown",o=>{(o.key===" "||o.key==="Enter")&&(o.preventDefault(),n())}),e()}function G(t){if(t.dataset.enhancedBtnWorking)return;t.dataset.enhancedBtnWorking="true";let e=null,n=!1;new MutationObserver(a=>{a.forEach(c=>{if(c.attributeName==="class"){let i=t.classList.contains("btn-working"),r=t.querySelector("pds-icon");if(i)if(r)e||(e=r.getAttribute("icon")),r.setAttribute("icon","circle-notch");else{let p=document.createElement("pds-icon");p.setAttribute("icon","circle-notch"),p.setAttribute("size","sm"),t.insertBefore(p,t.firstChild),n=!0}else c.oldValue?.includes("btn-working")&&r&&(n?(r.remove(),n=!1):e&&(r.setAttribute("icon",e),e=null))}})}).observe(t,{attributes:!0,attributeFilter:["class"],attributeOldValue:!0})}var _=new Map([[".accordion",W],["nav[data-dropdown]",H],["label[data-toggle]",N],["label[data-color]",$],['input[type="range"]',U],["form[data-required]",z],["fieldset[role=group][data-open]",j],["[data-clip]",V],["button, a[class*='btn-']",G]]),J=F.map(t=>({...t,run:_.get(t.selector)||(()=>{})}));export{J as defaultPDSEnhancers};
|
|
1
|
+
var T=[{selector:".accordion"},{selector:"nav[data-dropdown]"},{selector:"label[data-toggle]"},{selector:"label[data-color]"},{selector:'input[type="range"]'},{selector:"form[data-required]"},{selector:"fieldset[role=group][data-open]"},{selector:"[data-clip]"},{selector:"button, a[class*='btn-']"}];function $(t){t.dataset.enhancedAccordion||(t.dataset.enhancedAccordion="true",t.addEventListener("toggle",e=>{e.target.open&&e.target.parentElement===t&&t.querySelectorAll(":scope > details[open]").forEach(n=>{n!==e.target&&(n.open=!1)})},!0))}function U(t){if(t.dataset.enhancedDropdown)return;t.dataset.enhancedDropdown="true";let e=t.lastElementChild;if(!e)return;let n=t.querySelector("[data-dropdown-toggle]")||t.querySelector("button");n&&!n.hasAttribute("type")&&n.setAttribute("type","button"),e.id||(e.id=`dropdown-${Math.random().toString(36).slice(2,9)}`);let a=e.tagName?.toLowerCase()==="menu",i=8;a&&!e.hasAttribute("role")&&e.setAttribute("role","menu"),e.hasAttribute("aria-hidden")||e.setAttribute("aria-hidden","true"),n&&(n.setAttribute("aria-haspopup","true"),n.setAttribute("aria-controls",e.id),n.setAttribute("aria-expanded","false"));let u=()=>{let r=e.getAttribute("style");e.style.visibility="hidden",e.style.display="inline-block",e.style.pointerEvents="none";let c=e.getBoundingClientRect(),p=Math.max(e.offsetWidth||0,e.scrollWidth||0,c.width||0,1),d=Math.max(e.offsetHeight||0,e.scrollHeight||0,c.height||0,1);return r===null?e.removeAttribute("style"):e.setAttribute("style",r),{width:p,height:d}},s=()=>{let r=(t.getAttribute("data-direction")||t.getAttribute("data-dropdown-direction")||t.getAttribute("data-mode")||"auto").toLowerCase();if(r==="up"||r==="down")return r;let c=(n||t).getBoundingClientRect(),{height:p}=u(),d=Math.max(0,window.innerHeight-c.bottom),g=Math.max(0,c.top),v=d>=p,b=g>=p;return v&&!b?"down":b&&!v?"up":v&&b?"down":g>d?"up":"down"},o=()=>{let r=(t.getAttribute("data-align")||t.getAttribute("data-dropdown-align")||"auto").toLowerCase();if(r==="left"||r==="right"||r==="start"||r==="end")return r==="start"?"left":r==="end"?"right":r;let c=(n||t).getBoundingClientRect(),{width:p}=u(),d=Math.max(0,window.innerWidth-c.left),g=Math.max(0,c.right),v=d>=p,b=g>=p;return v&&!b?"left":b&&!v?"right":v&&b?"left":g>d?"right":"left"},f=(r,c=8)=>{let p=getComputedStyle(t).getPropertyValue(r).trim();if(!p)return c;let d=document.createElement("span");d.style.position="fixed",d.style.visibility="hidden",d.style.pointerEvents="none",d.style.height=p,document.body.appendChild(d);let g=Number.parseFloat(getComputedStyle(d).height);return d.remove(),Number.isFinite(g)?g:c},l=()=>{e.style.removeProperty("position"),e.style.removeProperty("left"),e.style.removeProperty("top"),e.style.removeProperty("right"),e.style.removeProperty("bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("max-width"),e.style.removeProperty("max-inline-size"),e.style.removeProperty("max-height"),e.style.removeProperty("overflow")},h=r=>{if(!r)return null;if(r.parentElement)return r.parentElement;let c=r.getRootNode?.();return c instanceof ShadowRoot?c.host:null},A=()=>{let r=h(e);for(;r&&r!==document.documentElement;){let c=getComputedStyle(r),p=c.contain||"",d=c.willChange||"";if(c.transform!=="none"||c.perspective!=="none"||c.filter!=="none"||c.backdropFilter!=="none"||p.includes("paint")||p.includes("layout")||p.includes("strict")||p.includes("content")||d.includes("transform")||d.includes("perspective")||d.includes("filter"))return!0;r=h(r)}return!1},m=()=>{e.getAttribute("aria-hidden")==="false"&&(l(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{E()})}))},E=()=>{if(e.getAttribute("aria-hidden")!=="false")return;if(A()){l();return}let r=(n||t).getBoundingClientRect(),c=window.visualViewport,p=c?.width||document.documentElement?.clientWidth||window.innerWidth,d=c?.height||document.documentElement?.clientHeight||window.innerHeight,g=c?.offsetLeft||0,v=c?.offsetTop||0,b=Math.max(1,p-i*2),H=Math.max(1,d-i*2);e.style.maxWidth=`${Math.round(b)}px`,e.style.maxInlineSize=`${Math.round(b)}px`,e.style.maxHeight=`${Math.round(H)}px`,e.style.overflow="auto";let{width:S,height:M}=u(),P=f("--spacing-2",8),R=s(),O=o();t.dataset.dropdownDirection=R,t.dataset.dropdownAlign=O;let k=O==="right"?r.right-S:r.left;S>=b-1?k=g+i:k=Math.max(g+i,Math.min(k,g+p-S-i));let q=R==="up"?r.top-P-M:r.bottom+P;q=Math.max(v+i,Math.min(q,v+d-M-i)),e.style.position="fixed",e.style.left=`${Math.round(k)}px`,e.style.top=`${Math.round(q)}px`,e.style.right="auto",e.style.bottom="auto",e.style.marginTop="0",e.style.marginBottom="0"},y=null,D=()=>{y||(y=()=>E(),window.addEventListener("resize",y),window.addEventListener("scroll",y,!0))},F=()=>{y&&(window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0),y=null)},x=null,w=null,B=()=>{x||typeof document>"u"||(x=()=>{e.getAttribute("aria-hidden")==="false"&&(t.dataset.dropdownDirection=s(),t.dataset.dropdownAlign=o(),w!==null&&cancelAnimationFrame(w),w=requestAnimationFrame(()=>{w=null,e.getAttribute("aria-hidden")==="false"&&E()}))},document.addEventListener("pds:config-changed",x))},I=()=>{!x||typeof document>"u"||(document.removeEventListener("pds:config-changed",x),x=null,w!==null&&(cancelAnimationFrame(w),w=null))},C=null,N=()=>{t.dataset.dropdownDirection=s(),t.dataset.dropdownAlign=o(),e.setAttribute("aria-hidden","false"),n?.setAttribute("aria-expanded","true"),D(),B(),m(),C||(C=r=>{(r.composedPath?r.composedPath():[r.target]).some(d=>d===t)||L()},setTimeout(()=>{document.addEventListener("click",C)},0))},L=()=>{e.setAttribute("aria-hidden","true"),n?.setAttribute("aria-expanded","false"),F(),I(),l(),C&&(document.removeEventListener("click",C),C=null)},W=()=>{e.getAttribute("aria-hidden")==="false"?L():N()};n?.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),W()}),t.addEventListener("keydown",r=>{r.key==="Escape"&&(L(),n?.focus())}),t.addEventListener("focusout",r=>{r.relatedTarget&&((r.composedPath?r.composedPath():[r.relatedTarget]).some(d=>d===t)||L())})}function z(t){if(t.dataset.enhancedToggle)return;t.dataset.enhancedToggle="true";let e=t.querySelector('input[type="checkbox"]');if(!e)return;t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"),t.setAttribute("role","switch"),t.setAttribute("aria-checked",e.checked?"true":"false");let n=document.createElement("span");n.className="toggle-switch",n.setAttribute("role","presentation"),n.setAttribute("aria-hidden","true");let a=document.createElement("span");a.className="toggle-knob",n.appendChild(a),t.insertBefore(n,e.nextSibling);let i=()=>{t.setAttribute("aria-checked",e.checked?"true":"false")},u=()=>{e.disabled||(e.checked=!e.checked,i(),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})))};t.addEventListener("click",s=>{s.preventDefault(),u()}),t.addEventListener("keydown",s=>{(s.key===" "||s.key==="Enter")&&(s.preventDefault(),u())}),e.addEventListener("change",i)}function V(t){if(t.dataset.enhancedColorInput)return;let e=t.querySelector('input[type="color"]');if(!e)return;t.dataset.enhancedColorInput="true";let n=t.querySelector(":scope > .color-control"),a=t.querySelector(":scope > .color-control > .color-swatch"),i=t.querySelector(":scope > .color-control > output");n||(n=document.createElement("span"),n.className="color-control",e.before(n)),a||(a=document.createElement("span"),a.className="color-swatch",n.appendChild(a)),e.parentElement!==a&&a.appendChild(e),i||(i=document.createElement("output"),n.appendChild(i));let u=()=>{if(e.dataset.colorUnset==="1"){i.value="",i.textContent="not set",n.dataset.value="",n.dataset.unset="1",a.dataset.unset="1";return}i.value=e.value,i.textContent=e.value,n.dataset.value=e.value,delete n.dataset.unset,delete a.dataset.unset};u();let s=()=>{e.dataset.colorUnset==="1"&&(e.dataset.colorUnset="0"),u()};e.addEventListener("input",s,{passive:!0}),e.addEventListener("change",s,{passive:!0})}function j(t){if(t.dataset.enhancedRange)return;let e=s=>{if(t.dataset.enhancedRangeProgrammatic)return;t.dataset.enhancedRangeProgrammatic="1";let o=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),"value")||Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");o?.get&&o?.set&&Object.defineProperty(t,"value",{configurable:!0,enumerable:o.enumerable,get(){return o.get.call(this)},set(l){o.set.call(this,l),s()}}),new MutationObserver(l=>{l.some(A=>{let m=A.attributeName;return m==="value"||m==="min"||m==="max"})&&s()}).observe(t,{attributes:!0,attributeFilter:["value","min","max"]})},n=t.closest("label"),a=n?.classList.contains("range-output"),i=t.id||`range-${Math.random().toString(36).substring(2,11)}`,u=`${i}-output`;if(t.id=i,a){let s=n.querySelector("span");if(s&&!s.classList.contains("range-output-wrapper")){let o=document.createElement("span");o.className="range-output-wrapper",o.style.display="flex",o.style.justifyContent="space-between",o.style.alignItems="center";let f=document.createElement("span");f.textContent=s.textContent,o.appendChild(f);let l=document.createElement("output");l.id=u,l.setAttribute("for",i),l.style.color="var(--surface-text-secondary, var(--color-text-secondary))",l.style.fontSize="0.875rem",l.textContent=t.value,o.appendChild(l),s.textContent="",s.appendChild(o);let h=()=>{l.textContent=t.value};t.addEventListener("input",h),t.addEventListener("change",h),e(h),h()}}else{let s=t.closest(".range-container");s||(s=document.createElement("div"),s.className="range-container",t.parentNode?.insertBefore(s,t),s.appendChild(t)),s.style.position="relative";let o=document.createElement("output");o.id=u,o.setAttribute("for",i),o.className="range-bubble",o.setAttribute("aria-live","polite"),s.appendChild(o);let f=()=>{let A=parseFloat(t.min)||0,m=parseFloat(t.max)||100,E=parseFloat(t.value),y=(E-A)/(m-A);o.style.left=`calc(${y*100}% )`,o.textContent=String(E)},l=()=>o.classList.add("visible"),h=()=>o.classList.remove("visible");t.addEventListener("input",f),t.addEventListener("pointerdown",l),t.addEventListener("pointerup",h),t.addEventListener("pointerleave",h),t.addEventListener("focus",l),t.addEventListener("blur",h),t.addEventListener("change",f),e(f),f()}t.dataset.enhancedRange="1"}function G(t){if(t.dataset.enhancedRequired)return;t.dataset.enhancedRequired="true";let e=n=>{let a;if(n.closest("[role$=group]")?a=n.closest("[role$=group]").querySelector("legend"):a=n.closest("label"),!a||a.querySelector(".required-asterisk"))return;let i=document.createElement("span");i.classList.add("required-asterisk"),i.textContent="*",i.style.marginLeft="4px";let u=a.querySelector("span, [data-label]");if(u)u.appendChild(i);else{let o=a.querySelector("input, select, textarea");o?a.insertBefore(i,o):a.appendChild(i)}let s=n.closest("form");if(s&&!s.querySelector(".required-legend")){let o=document.createElement("small");o.classList.add("required-legend"),o.textContent="* Required fields",s.insertBefore(o,s.querySelector(".form-actions")||s.lastElementChild)}};t.querySelectorAll("[required]").forEach(n=>{e(n)})}function _(t){if(t.dataset.enhancedOpenGroup)return;t.dataset.enhancedOpenGroup="true",t.classList.add("flex","flex-wrap","buttons");let e=document.createElement("input");e.type="text",e.placeholder="Add item...",e.classList.add("input-text","input-sm"),e.style.width="auto";let n=()=>t.querySelector('input[type="radio"], input[type="checkbox"]');t.appendChild(e),e.addEventListener("keydown",a=>{if(a.key==="Enter"||a.key==="Tab"){let i=e.value.trim();if(i){a.preventDefault();let u=n(),s=u?.type==="radio"?"radio":"checkbox",o=`open-group-${Math.random().toString(36).substring(2,11)}`,f=document.createElement("label"),l=document.createElement("span");l.setAttribute("data-label",""),l.textContent=i;let h=document.createElement("input");h.type=s,h.name=u?.name||t.getAttribute("data-name")||"open-group",h.value=i,h.id=o,f.appendChild(l),f.appendChild(h),t.insertBefore(f,e),e.value=""}}else if(a.key==="Backspace"&&e.value===""){a.preventDefault();let i=t.querySelectorAll("label");i.length>0&&i[i.length-1].remove()}})}function J(t){if(t.dataset.enhancedClip)return;t.dataset.enhancedClip="true",t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"),t.hasAttribute("role")||t.setAttribute("role","button");let e=()=>{let a=t.getAttribute("data-clip-open")==="true";t.setAttribute("aria-expanded",a?"true":"false")},n=()=>{let a=t.getAttribute("data-clip-open")==="true";t.setAttribute("data-clip-open",a?"false":"true"),e()};t.addEventListener("click",a=>{a.defaultPrevented||n()}),t.addEventListener("keydown",a=>{(a.key===" "||a.key==="Enter")&&(a.preventDefault(),n())}),e()}function K(t){if(t.dataset.enhancedBtnWorking)return;t.dataset.enhancedBtnWorking="true";let e=null,n=!1;new MutationObserver(i=>{i.forEach(u=>{if(u.attributeName==="class"){let s=t.classList.contains("btn-working"),o=t.querySelector("pds-icon");if(s)if(o)e||(e=o.getAttribute("icon")),o.setAttribute("icon","circle-notch");else{let f=document.createElement("pds-icon");f.setAttribute("icon","circle-notch"),f.setAttribute("size","sm"),t.insertBefore(f,t.firstChild),n=!0}else u.oldValue?.includes("btn-working")&&o&&(n?(o.remove(),n=!1):e&&(o.setAttribute("icon",e),e=null))}})}).observe(t,{attributes:!0,attributeFilter:["class"],attributeOldValue:!0})}var Q=new Map([[".accordion",$],["nav[data-dropdown]",U],["label[data-toggle]",z],["label[data-color]",V],['input[type="range"]',j],["form[data-required]",G],["fieldset[role=group][data-open]",_],["[data-clip]",J],["button, a[class*='btn-']",K]]),X=T.map(t=>({...t,run:Q.get(t.selector)||(()=>{})}));export{X as defaultPDSEnhancers};
|