@pure-ds/core 0.7.62 → 0.7.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/src/js/pds-core/pds-enhancers-meta.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-generator.d.ts.map +1 -1
- package/package.json +1 -1
- package/public/assets/js/app.js +1 -1
- package/public/assets/js/pds-enhancers.js +1 -1
- package/public/assets/js/pds-manager.js +404 -267
- package/public/assets/pds/components/pds-form.js +3 -3
- package/public/assets/pds/core/pds-enhancers.js +1 -1
- package/public/assets/pds/core/pds-manager.js +404 -267
- package/src/js/pds-core/pds-enhancers-meta.js +58 -9
- package/src/js/pds-core/pds-enhancers.js +193 -0
- package/src/js/pds-core/pds-generator.js +118 -0
|
@@ -1647,7 +1647,7 @@ export class SchemaForm extends LitElement {
|
|
|
1647
1647
|
// Fallback text input
|
|
1648
1648
|
this.#renderers.set(
|
|
1649
1649
|
"*",
|
|
1650
|
-
({ id, path, value, attrs, set }) => html`
|
|
1650
|
+
({ id, path, value, attrs, set, ui }) => html`
|
|
1651
1651
|
<input
|
|
1652
1652
|
id=${id}
|
|
1653
1653
|
name=${path}
|
|
@@ -1660,7 +1660,7 @@ export class SchemaForm extends LitElement {
|
|
|
1660
1660
|
?readonly=${!!attrs.readOnly}
|
|
1661
1661
|
?disabled=${!!attrs.disabled}
|
|
1662
1662
|
?required=${!!attrs.required}
|
|
1663
|
-
autocomplete=${ifDefined(attrs.autocomplete)}
|
|
1663
|
+
autocomplete=${ifDefined(ui?.["ui:autocomplete"] ?? attrs.autocomplete)}
|
|
1664
1664
|
@input=${(e) => set(e.target.value)}
|
|
1665
1665
|
/>
|
|
1666
1666
|
`
|
|
@@ -1681,7 +1681,7 @@ export class SchemaForm extends LitElement {
|
|
|
1681
1681
|
?readonly=${!!attrs.readOnly}
|
|
1682
1682
|
?disabled=${!!attrs.disabled}
|
|
1683
1683
|
?required=${!!attrs.required}
|
|
1684
|
-
autocomplete=${ifDefined(attrs.autocomplete)}
|
|
1684
|
+
autocomplete=${ifDefined(ui?.["ui:autocomplete"] ?? attrs.autocomplete)}
|
|
1685
1685
|
list=${ifDefined(ui?.["ui:datalist"] ? `${id}-datalist` : attrs.list)}
|
|
1686
1686
|
@input=${(e) => set(e.target.value)}
|
|
1687
1687
|
/>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var ge=new Set(["log","warn","error","debug","info"]),he="__PURE_DS_PDS_SINGLETON__",G=null,X=null;function Z(){try{let t=(typeof globalThis<"u"?globalThis:window)?.[he];if(t&&typeof t=="object")return t}catch{return null}return null}function ye(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 be(e){if(typeof e!="string")return"log";let t=e.toLowerCase();return ge.has(t)?t:"log"}function me(){if(typeof X=="function")try{let t=ye(X());if(t)return t}catch{}let e=Z();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 ve(){if(typeof G=="function")try{let t=G();if(typeof t=="function")return t}catch{}let e=Z();return typeof e?.logHandler=="function"?e.logHandler:null}function Y(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 Le(e,t){let n=t?.debug===!0;return!(t?.mode==="static"&&!n||!n&&e!=="error"&&e!=="warn")}function J(e="log",t,...n){let o=be(e),r=me(),s=ve();if(s)try{s.call(r?.thisArg,o,t,...n);return}catch(a){Y("error","Custom log handler failed:",a)}Le(o,r)&&Y(o,t,...n)}var we="en",u={defaultLocale:we,provider:null,messagesByLocale:new Map,loadingByLocale:new Map,observer:null,reconcileTimer:null,requestedKeys:new Set,textNodeKeyMap:new WeakMap,attributeKeyMap:new WeakMap,valueToKeys:new Map,missingWarnings:new Set},Ae=["title","placeholder","aria-label","aria-description","aria-placeholder","aria-roledescription","alt","label"],_e=e=>!!e&&typeof e!="string"&&typeof e=="object"&&"strTag"in e;function _(e){return String(e||"").trim().toLowerCase()}function Ee(e){let t=_(e);return t?t.split("-")[0]||t:""}function S(e){let t=_(e);if(!t)return u.defaultLocale;let n=u.provider?.resolveLocale;if(typeof n=="function"){let o=_(n(e));if(o)return o}return t}function xe(e){let t="";for(let n=0;n<=e.length-1;n+=1)t+=e[n],n<e.length-1&&(t+=`{${n}}`);return t}function T(e,t){return String(e).replace(/\{(\d+)\}/g,(n,o)=>t(Number(o)))}function F(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 Se(e){let t=_(e);if(!t)return[u.defaultLocale];let n=Ee(t);return!n||n===t?[t]:[t,n]}function Q(e,t){let n=S(e);u.messagesByLocale.set(n,F(t))}function ne(e){typeof e=="string"&&e.length>0&&u.requestedKeys.add(e)}function ee(e,t){if(typeof e!="string"||!e.length)return;let n=typeof t=="string"?t:String(t||"");n.length&&(u.valueToKeys.has(n)||u.valueToKeys.set(n,new Set),u.valueToKeys.get(n).add(e))}function D(e){let t=Se(e);for(let n of t)if(u.messagesByLocale.has(n))return{locale:n,messages:u.messagesByLocale.get(n)};return null}async function q(e,t="explicit"){let n=S(e),o=D(n);if(o)return o.messages;let r=n;if(u.loadingByLocale.has(r))return u.loadingByLocale.get(r);if(!u.provider)return{};let s=u.provider.loadLocale||u.provider.setLocale||null;if(typeof s!="function")return{};let a={locale:n,defaultLocale:u.defaultLocale,reason:t,loadedLocales:Array.from(u.messagesByLocale.keys()),messages:{...D(n)?.messages||{}},load:t==="set-default"||t==="explicit-load"},i;try{i=s(a)}catch{return{}}if(i&&typeof i.then=="function"){let l=i.then(p=>{let f=F(p);return Q(n,f),f}).catch(()=>({})).finally(()=>{u.loadingByLocale.delete(r)});return u.loadingByLocale.set(r,l),l}let d=F(i);return Q(n,d),d}function Ce(e){if(!e||typeof e!="object")return"";let n=typeof Element<"u"&&e instanceof Element||e?.nodeType===1?e:null;if(!n)return"";if(n.hasAttribute?.("lang"))return _(n.getAttribute("lang"));let o=n.closest?.("[lang]");return o&&o.getAttribute?_(o.getAttribute("lang")):""}function R(e={}){if(typeof e?.lang=="string"&&e.lang.trim())return S(e.lang);let t=e?.element||e?.scope||e?.host||e?.contextElement||null,n=Ce(t);if(n)return S(n);if(typeof document<"u"&&document.documentElement){let o=_(document.documentElement.getAttribute("lang"));if(o)return S(o)}return u.defaultLocale}function Me(){let e=new Set([u.defaultLocale]);if(typeof document>"u")return e;let t=_(document.documentElement?.getAttribute?.("lang"));t&&e.add(S(t));let n=document.querySelectorAll?.("[lang]")||[];for(let o of n){let r=_(o.getAttribute("lang"));r&&e.add(S(r))}return e}async function Te(e){for(let t of e)await q(t,"lang-detected")}function qe(e){for(let t of Array.from(u.messagesByLocale.keys()))e.has(t)||u.messagesByLocale.delete(t)}function Oe(e){let t=String(e||""),n=(t.match(/^\s*/)||[""])[0],o=(t.match(/\s*$/)||[""])[0],r=n.length,s=t.length-o.length,a=s>=r?t.slice(r,s):"";return{leading:n,core:a,trailing:o}}function te(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ke(e,t){let n=typeof e=="string"?e:String(e||""),o=typeof t=="string"?t:String(t||""),r=/\{(\d+)\}/g,s=Array.from(n.matchAll(r));if(!s.length)return n===o?[]:null;let a=[],i="^",d=0;for(let f of s){let h=f.index??0;i+=te(n.slice(d,h)),i+="([\\s\\S]*?)",a.push(Number(f[1])),d=h+f[0].length}i+=te(n.slice(d)),i+="$";let l=new RegExp(i).exec(o);if(!l)return null;let p=[];for(let f=1;f<l.length;f+=1){let h=a[f-1],y=l[f];if(Object.prototype.hasOwnProperty.call(p,h)&&p[h]!==y)return null;p[h]=y}return p}function j(e,t){if(typeof e!="string"||!e.length)return[];let n=[e];for(let[,o]of u.messagesByLocale.entries()){let r=o?.[e];typeof r=="string"&&r.length&&n.push(r)}for(let o of n){let r=ke(o,t);if(r)return r}return[]}function oe(e){if(!e)return null;let t=u.valueToKeys.get(e);if(t&&t.size>0){for(let o of t)if(u.requestedKeys.has(o))return o}if(u.requestedKeys.has(e))return e;let n=Array.from(u.messagesByLocale.entries());for(let o of u.requestedKeys)for(let[,r]of n)if(r&&r[o]===e)return o;return null}function re(e){if(!e)return null;let t=null;for(let[n,o]of u.valueToKeys.entries()){if(typeof n!="string"||!n.length||n===e)continue;let r=e.indexOf(n);if(r!==-1)for(let s of o){if(!u.requestedKeys.has(s))continue;let a=j(s,n),i={key:s,matchedText:n,start:r,end:r+n.length,values:a};(!t||i.matchedText.length>t.matchedText.length)&&(t=i);break}}return t}async function Pe(e){if(!e||e.nodeType!==3)return;let t=e.parentElement||null;if(!t)return;let{leading:n,core:o,trailing:r}=Oe(e.nodeValue);if(!o)return;let s=u.textNodeKeyMap.get(e)||null;if((!s||!u.requestedKeys.has(s))&&(s=oe(o)),!s){let f=re(o);if(!f)return;let h=R({element:t});await q(h,"text-node");let y=O(f.key,f.values,{element:t},null),v=f.values.length?T(y,P=>f.values[P]):y,k=o.slice(0,f.start)+v+o.slice(f.end),C=`${n}${k}${r}`;C!==e.nodeValue&&(e.nodeValue=C);return}u.textNodeKeyMap.set(e,s);let a=R({element:t});await q(a,"text-node");let i=j(s,o),d=O(s,i,{element:t},null),l=i.length?T(d,f=>i[f]):d,p=`${n}${l}${r}`;p!==e.nodeValue&&(e.nodeValue=p)}async function De(){if(typeof document>"u"||u.requestedKeys.size===0)return;let e=document.body||document.documentElement;if(!e||typeof document.createTreeWalker!="function")return;let t=[],n=new Set,o=s=>{!s||n.has(s)||(n.add(s),t.push(s))};o(e);for(let s=0;s<t.length;s+=1){let a=t[s];if(!a||typeof a.querySelectorAll!="function")continue;let i=a.querySelectorAll("*");for(let d of i){let l=d?.shadowRoot;l&&o(l)}}let r=[];for(let s of t){let a=document.createTreeWalker(s,NodeFilter.SHOW_TEXT);for(;a.nextNode();)r.push(a.currentNode)}for(let s of r)await Pe(s)}function Re(e){let t=u.attributeKeyMap.get(e);return t||(t=new Map,u.attributeKeyMap.set(e,t)),t}async function Be(e,t){if(!e||typeof e.getAttribute!="function")return;let n=e.getAttribute(t);if(typeof n!="string"||!n.length)return;let o=Re(e),r=o.get(t)||null;if((!r||!u.requestedKeys.has(r))&&(r=oe(n)),!r){let l=re(n);if(!l)return;let p=R({element:e});await q(p,"attribute");let f=O(l.key,l.values,{element:e},null),h=l.values.length?T(f,v=>l.values[v]):f,y=n.slice(0,l.start)+h+n.slice(l.end);y!==n&&e.setAttribute(t,y),o.set(t,l.key);return}o.set(t,r);let s=R({element:e});await q(s,"attribute");let a=j(r,n),i=O(r,a,{element:e},null),d=a.length?T(i,l=>a[l]):i;d!==n&&e.setAttribute(t,d)}async function Ke(){if(typeof document>"u"||u.requestedKeys.size===0)return;let e=document.body||document.documentElement;if(!e)return;let t=[],n=new Set,o=r=>{!r||n.has(r)||(n.add(r),t.push(r))};o(e);for(let r=0;r<t.length;r+=1){let s=t[r];if(!s||typeof s.querySelectorAll!="function")continue;let a=s.querySelectorAll("*");for(let i of a){let d=i?.shadowRoot;d&&o(d)}}for(let r of t){if(!r||typeof r.querySelectorAll!="function")continue;let s=r.querySelectorAll("*");for(let a of s)for(let i of Ae)a.hasAttribute(i)&&await Be(a,i)}}async function ze(){let e=Me();await Te(e),await De(),await Ke(),qe(e)}function We(){typeof window>"u"||(u.reconcileTimer&&clearTimeout(u.reconcileTimer),u.reconcileTimer=setTimeout(()=>{u.reconcileTimer=null,ze()},16))}function O(e,t=[],n={},o=null){let r=R(n),s=D(r);s||q(r,"msg");let a=D(r)?.messages||{},i=D(u.defaultLocale)?.messages||{},d={key:e,values:t,options:n,locale:r,defaultLocale:u.defaultLocale,messages:a,messagesByLocale:Object.fromEntries(Array.from(u.messagesByLocale.entries())),template:o},l,p=!!s,f=r===u.defaultLocale;typeof u.provider?.translate=="function"&&(l=u.provider.translate(d));let h=null;if(l==null&&(l=a[e]),l==null&&(l=i[e],h=l==null?null:"default"),l==null&&(l=e,h="key"),p&&!f&&h){let v=`${r}::${e}`;u.missingWarnings.has(v)||(u.missingWarnings.add(v),J("warn",`[i18n] Missing translation for locale "${r}" and key "${e}"; using ${h} fallback.`))}let y=typeof l=="string"?l:String(l);if(ee(e,y),Array.isArray(t)&&t.length>0){let v=T(y,k=>t[k]);v!==y&&ee(e,v)}return y}var Ie=(e,t,n={})=>{let o=xe(e);ne(o);let r=O(o,t,n,{strings:e,values:t});return T(r,s=>t[s])};var B=(e,t={})=>{if(!e)return"";if(_e(e))return Ie(e.strings,e.values,t);let n=String(e);ne(n);let o=O(n,[],t,null);return!t?.element&&!t?.scope&&!t?.host&&!t?.contextElement&&!t?.lang&&We(),o};var $e=[{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 Fe(e){e.dataset.enhancedAccordion||(e.dataset.enhancedAccordion="true",e.addEventListener("toggle",t=>{t.target.open&&t.target.parentElement===e&&e.querySelectorAll(":scope > details[open]").forEach(n=>{n!==t.target&&(n.open=!1)})},!0))}function je(e){if(e.dataset.enhancedDropdown)return;e.dataset.enhancedDropdown="true";let t=e.lastElementChild,n=e.classList.contains("split-button");if(!t)return;let o=e.querySelector("[data-dropdown-toggle]")||e.querySelector("button"),r=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype&&"hidePopover"in HTMLElement.prototype;o&&!o.hasAttribute("type")&&o.setAttribute("type","button"),t.id||(t.id=`dropdown-${Math.random().toString(36).slice(2,9)}`);let s=t.tagName?.toLowerCase()==="menu",a=8;s&&!t.hasAttribute("role")&&t.setAttribute("role","menu"),t.hasAttribute("aria-hidden")||t.setAttribute("aria-hidden","true"),o&&(o.setAttribute("aria-haspopup","true"),o.setAttribute("aria-controls",t.id),o.setAttribute("aria-expanded","false"));let i=()=>!n||!s?null:t.querySelector(":scope > li[data-default]")||t.querySelector(":scope > li"),d=c=>c?c.querySelector(":scope > a, :scope > button")||c.firstElementChild:null,l=()=>{if(!n||!o)return null;let c=e.querySelector(":scope > [data-dropdown-default]");return c||(c=document.createElement("button"),c.setAttribute("type","button"),c.setAttribute("data-dropdown-default",""),c.className=o.className,e.insertBefore(c,o),c)},p=(c,g)=>{if(!c||!g)return;c.replaceChildren(...Array.from(g.childNodes).map(m=>m.cloneNode(!0)));let b=g.getAttribute("aria-label")||g.textContent?.replace(/\s+/g," ").trim()||B("Default action");c.setAttribute("aria-label",b),c.title=b},f=()=>{if(!n)return;let c=l(),g=i(),b=d(g);if(!c||!b)return;p(c,b);let m=()=>{b&&typeof b.click=="function"&&b.click()};c.addEventListener("click",L=>{L.preventDefault(),m()})};if(!r){let c="__PDS_DROPDOWN_POPOVER_WARNED__";globalThis[c]||(globalThis[c]=!0,console.warn("[PDS] nav[data-dropdown] requires the Popover API. Add a popover polyfill (recommended: @oddbird/popover-polyfill) for browsers without support."));return}f(),t.setAttribute("popover","auto");let h=()=>{let c=t.getAttribute("style");t.style.visibility="hidden",t.style.display="inline-block",t.style.pointerEvents="none";let g=t.getBoundingClientRect(),b=Math.max(t.offsetWidth||0,t.scrollWidth||0,g.width||0,1),m=Math.max(t.offsetHeight||0,t.scrollHeight||0,g.height||0,1);return c===null?t.removeAttribute("style"):t.setAttribute("style",c),{width:b,height:m}},y=()=>{try{return t.matches(":popover-open")}catch{return!1}},v=()=>{t.setAttribute("aria-hidden","true"),o?.setAttribute("aria-expanded","false")},k=()=>{t.setAttribute("aria-hidden","false"),o?.setAttribute("aria-expanded","true")},C=()=>{let c=(e.getAttribute("data-direction")||e.getAttribute("data-dropdown-direction")||e.getAttribute("data-mode")||"auto").toLowerCase();if(c==="up"||c==="down")return c;let g=(o||e).getBoundingClientRect(),{height:b}=h(),m=Math.max(0,window.innerHeight-g.bottom),L=Math.max(0,g.top),A=m>=b,w=L>=b;return A&&!w?"down":w&&!A?"up":A&&w?"down":L>m?"up":"down"},P=()=>{let c=(e.getAttribute("data-align")||e.getAttribute("data-dropdown-align")||"auto").toLowerCase();if(c==="left"||c==="right"||c==="start"||c==="end")return c==="start"?"left":c==="end"?"right":c;let g=(o||e).getBoundingClientRect(),{width:b}=h(),m=Math.max(0,window.innerWidth-g.left),L=Math.max(0,g.right),A=m>=b,w=L>=b;return A&&!w?"left":w&&!A?"right":A&&w?"left":L>m?"right":"left"},ae=(c,g=8)=>{let b=getComputedStyle(e).getPropertyValue(c).trim();if(!b)return g;let m=document.createElement("span");m.style.position="fixed",m.style.visibility="hidden",m.style.pointerEvents="none",m.style.height=b,document.body.appendChild(m);let L=Number.parseFloat(getComputedStyle(m).height);return m.remove(),Number.isFinite(L)?L:g},se=()=>{["position","left","top","right","bottom","margin-top","margin-bottom","max-width","max-inline-size","max-height","overflow"].forEach(c=>t.style.removeProperty(c))},K=()=>{if(!y())return;let c=(o||e).getBoundingClientRect(),g=window.visualViewport,b=g?.width||document.documentElement?.clientWidth||window.innerWidth,m=g?.height||document.documentElement?.clientHeight||window.innerHeight,L=g?.offsetLeft||0,A=g?.offsetTop||0,w=Math.max(1,b-a*2),pe=Math.max(1,m-a*2);t.style.maxWidth=`${Math.round(w)}px`,t.style.maxInlineSize=`${Math.round(w)}px`,t.style.maxHeight=`${Math.round(pe)}px`,t.style.overflow="auto";let{width:I,height:N}=h(),V=ae("--spacing-2",8),H=C(),U=P();e.dataset.dropdownDirection=H,e.dataset.dropdownAlign=U;let z=U==="right"?c.right-I:c.left;I>=w-1?z=L+a:z=Math.max(L+a,Math.min(z,L+b-I-a));let $=H==="up"?c.top-V-N:c.bottom+V;$=Math.max(A+a,Math.min($,A+m-N-a)),Object.assign(t.style,{position:"fixed",left:`${Math.round(z)}px`,top:`${Math.round($)}px`,right:"auto",bottom:"auto",marginTop:"0",marginBottom:"0"})},E=null,ie=()=>{E||(E=()=>K(),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0))},ce=()=>{E&&(window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0),E=null)},M=null,x=null,le=()=>{M||typeof document>"u"||(M=()=>{y()&&(e.dataset.dropdownDirection=C(),e.dataset.dropdownAlign=P(),x!==null&&cancelAnimationFrame(x),x=requestAnimationFrame(()=>{x=null,y()&&K()}))},document.addEventListener("pds:config-changed",M))},ue=()=>{!M||typeof document>"u"||(document.removeEventListener("pds:config-changed",M),M=null,x!==null&&(cancelAnimationFrame(x),x=null))};t.addEventListener("toggle",c=>{if(c.newState==="open"){k(),K(),ie(),le();return}v(),ce(),ue(),se()});let de=()=>{y()||(e.dataset.dropdownDirection=C(),e.dataset.dropdownAlign=P(),t.showPopover(),requestAnimationFrame(()=>K()))},W=()=>{y()&&t.hidePopover()},fe=()=>{y()?W():de()};v(),t.addEventListener("click",c=>{let g=c.target instanceof Element?c.target:c.target?.parentElement;g&&g.closest("[data-dropdown-close]")&&W()}),o?.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),fe()}),e.addEventListener("keydown",c=>{c.key==="Escape"&&(W(),o?.focus())})}function Ne(e){if(e.dataset.enhancedToggle)return;e.dataset.enhancedToggle="true";let t=e.querySelector('input[type="checkbox"]');if(!t)return;e.hasAttribute("tabindex")||e.setAttribute("tabindex","0"),e.setAttribute("role","switch"),e.setAttribute("aria-checked",t.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),e.insertBefore(n,t.nextSibling);let r=()=>{e.setAttribute("aria-checked",t.checked?"true":"false")},s=()=>{t.disabled||(t.checked=!t.checked,r(),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})))};e.addEventListener("click",a=>{a.preventDefault(),s()}),e.addEventListener("keydown",a=>{(a.key===" "||a.key==="Enter")&&(a.preventDefault(),s())}),t.addEventListener("change",r)}function Ve(e){if(e.dataset.enhancedColorInput)return;let t=e.querySelector('input[type="color"]');if(!t)return;e.dataset.enhancedColorInput="true";let n=e.querySelector(":scope > .color-control"),o=e.querySelector(":scope > .color-control > .color-swatch"),r=e.querySelector(":scope > .color-control > output");n||(n=document.createElement("span"),n.className="color-control",t.before(n)),o||(o=document.createElement("span"),o.className="color-swatch",n.appendChild(o)),t.parentElement!==o&&o.appendChild(t),r||(r=document.createElement("output"),n.appendChild(r));let s=()=>{if(t.dataset.colorUnset==="1"){r.value="",r.textContent=B("not set"),n.dataset.value="",n.dataset.unset="1",o.dataset.unset="1";return}r.value=t.value,r.textContent=t.value,n.dataset.value=t.value,delete n.dataset.unset,delete o.dataset.unset};s();let a=()=>{t.dataset.colorUnset==="1"&&(t.dataset.colorUnset="0"),s()};t.addEventListener("input",a,{passive:!0}),t.addEventListener("change",a,{passive:!0})}function He(e){if(e.dataset.enhancedRange)return;let t=a=>{if(e.dataset.enhancedRangeProgrammatic)return;e.dataset.enhancedRangeProgrammatic="1";let i=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),"value")||Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");i?.get&&i?.set&&Object.defineProperty(e,"value",{configurable:!0,enumerable:i.enumerable,get(){return i.get.call(this)},set(l){i.set.call(this,l),a()}}),new MutationObserver(l=>{l.some(f=>{let h=f.attributeName;return h==="value"||h==="min"||h==="max"})&&a()}).observe(e,{attributes:!0,attributeFilter:["value","min","max"]})},n=e.closest("label"),o=n?.classList.contains("range-output"),r=e.id||`range-${Math.random().toString(36).substring(2,11)}`,s=`${r}-output`;if(e.id=r,o){let a=n.querySelector("span");if(a&&!a.classList.contains("range-output-wrapper")){let i=a.getAttribute("data-range-label")||n.getAttribute("data-range-label")||"",d=document.createElement("span");d.className="range-output-wrapper",d.style.display="flex",d.style.justifyContent="space-between",d.style.alignItems="center";let l=document.createElement("span");l.textContent=i||a.textContent,d.appendChild(l);let p=document.createElement("output");p.id=s,p.setAttribute("for",r),p.style.color="var(--surface-text-secondary, var(--color-text-secondary))",p.style.fontSize="0.875rem",p.textContent=e.value,d.appendChild(p),a.textContent="",a.appendChild(d);let f=()=>{p.textContent=e.value};e.addEventListener("input",f),e.addEventListener("change",f),t(f),f()}}else{let a=e.closest(".range-container");a||(a=document.createElement("div"),a.className="range-container",e.parentNode?.insertBefore(a,e),a.appendChild(e)),a.style.position="relative";let i=document.createElement("output");i.id=s,i.setAttribute("for",r),i.className="range-bubble",i.setAttribute("aria-live","polite"),a.appendChild(i);let d=()=>{let f=parseFloat(e.min)||0,h=parseFloat(e.max)||100,y=parseFloat(e.value),v=(y-f)/(h-f);i.style.left=`calc(${v*100}% )`,i.textContent=String(y)},l=()=>i.classList.add("visible"),p=()=>i.classList.remove("visible");e.addEventListener("input",d),e.addEventListener("pointerdown",l),e.addEventListener("pointerup",p),e.addEventListener("pointerleave",p),e.addEventListener("focus",l),e.addEventListener("blur",p),e.addEventListener("change",d),t(d),d()}e.dataset.enhancedRange="1"}function Ue(e){if(e.dataset.enhancedRequired)return;e.dataset.enhancedRequired="true";let t=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 r=document.createElement("span");r.classList.add("required-asterisk"),r.textContent="*",r.style.marginLeft="4px";let s=o.querySelector("span, [data-label]");if(s)s.appendChild(r);else{let i=o.querySelector("input, select, textarea");i?o.insertBefore(r,i):o.appendChild(r)}let a=n.closest("form");if(a&&!a.querySelector(".required-legend")){let i=document.createElement("small");i.classList.add("required-legend"),i.textContent=B("* Required fields"),a.insertBefore(i,a.querySelector(".form-actions")||a.lastElementChild)}};e.querySelectorAll("[required]").forEach(n=>{t(n)})}function Ge(e){if(e.dataset.enhancedOpenGroup)return;e.dataset.enhancedOpenGroup="true",e.classList.add("flex","flex-wrap","buttons");let t=document.createElement("input");t.type="text",t.placeholder=B("Add item..."),t.classList.add("input-text","input-sm"),t.style.width="auto";let n=()=>e.querySelector('input[type="radio"], input[type="checkbox"]');e.appendChild(t),t.addEventListener("keydown",o=>{if(o.key==="Enter"||o.key==="Tab"){let r=t.value.trim();if(r){o.preventDefault();let s=n(),a=s?.type==="radio"?"radio":"checkbox",i=`open-group-${Math.random().toString(36).substring(2,11)}`,d=document.createElement("label"),l=document.createElement("span");l.setAttribute("data-label",""),l.textContent=r;let p=document.createElement("input");p.type=a,p.name=s?.name||e.getAttribute("data-name")||"open-group",p.value=r,p.id=i,d.appendChild(l),d.appendChild(p),e.insertBefore(d,t),t.value=""}}else if(o.key==="Backspace"&&t.value===""){o.preventDefault();let r=e.querySelectorAll("label");r.length>0&&r[r.length-1].remove()}})}function Xe(e){if(e.dataset.enhancedClip)return;e.dataset.enhancedClip="true",e.hasAttribute("tabindex")||e.setAttribute("tabindex","0"),e.hasAttribute("role")||e.setAttribute("role","button");let t=()=>{let o=e.getAttribute("data-clip-open")==="true";e.setAttribute("aria-expanded",o?"true":"false")},n=()=>{let o=e.getAttribute("data-clip-open")==="true";e.setAttribute("data-clip-open",o?"false":"true"),t()};e.addEventListener("click",o=>{o.defaultPrevented||n()}),e.addEventListener("keydown",o=>{(o.key===" "||o.key==="Enter")&&(o.preventDefault(),n())}),t()}function Ye(e){if(e.dataset.enhancedBtnWorking)return;e.dataset.enhancedBtnWorking="true";let t=null,n=!1;new MutationObserver(r=>{r.forEach(s=>{if(s.attributeName==="class"){let a=e.classList.contains("btn-working"),i=e.querySelector("pds-icon");if(a)if(i)t||(t=i.getAttribute("icon")),i.setAttribute("icon","circle-notch");else{let d=document.createElement("pds-icon");d.setAttribute("icon","circle-notch"),d.setAttribute("size","sm"),e.insertBefore(d,e.firstChild),n=!0}else s.oldValue?.includes("btn-working")&&i&&(n?(i.remove(),n=!1):t&&(i.setAttribute("icon",t),t=null))}})}).observe(e,{attributes:!0,attributeFilter:["class"],attributeOldValue:!0})}var Ze=new Map([[".accordion",Fe],["nav[data-dropdown]",je],["label[data-toggle]",Ne],["label[data-color]",Ve],['input[type="range"]',He],["form[data-required]",Ue],["fieldset[role=group][data-open]",Ge],["[data-clip]",Xe],["button, a[class*='btn-']",Ye]]),Je=$e.map(e=>({...e,run:Ze.get(e.selector)||(()=>{})}));export{Je as defaultPDSEnhancers};
|
|
1
|
+
var gt=new Set(["log","warn","error","debug","info"]),ht="__PURE_DS_PDS_SINGLETON__",Z=null,X=null;function J(){try{let e=(typeof globalThis<"u"?globalThis:window)?.[ht];if(e&&typeof e=="object")return e}catch{return null}return null}function bt(t){return!t||typeof t!="object"?null:{mode:t.mode==="live"||t.mode==="static"?t.mode:null,debug:t.debug===!0,thisArg:t.thisArg}}function yt(t){if(typeof t!="string")return"log";let e=t.toLowerCase();return gt.has(e)?e:"log"}function mt(){if(typeof X=="function")try{let e=bt(X());if(e)return e}catch{}let t=J();if(t){let e=t?.mode||t?.compiled?.mode||(t?.registry?.isLive?"live":"static"),n=(t?.debug||t?.currentConfig?.debug||t?.currentConfig?.design?.debug||t?.compiled?.debug||t?.compiled?.design?.debug||!1)===!0;return{mode:e,debug:n,thisArg:t}}return{mode:null,debug:!1}}function vt(){if(typeof Z=="function")try{let e=Z();if(typeof e=="function")return e}catch{}let t=J();return typeof t?.logHandler=="function"?t.logHandler:null}function Y(t,e,...n){if(typeof console>"u")return;let o=typeof console[t]=="function"?console[t].bind(console):typeof console.log=="function"?console.log.bind(console):null;o&&(n.length>0?o(e,...n):o(e))}function Lt(t,e){let n=e?.debug===!0;return!(e?.mode==="static"&&!n||!n&&t!=="error"&&t!=="warn")}function Q(t="log",e,...n){let o=yt(t),r=mt(),s=vt();if(s)try{s.call(r?.thisArg,o,e,...n);return}catch(a){Y("error","Custom log handler failed:",a)}Lt(o,r)&&Y(o,e,...n)}var wt="en",u={defaultLocale:wt,provider:null,messagesByLocale:new Map,loadingByLocale:new Map,observer:null,reconcileTimer:null,requestedKeys:new Set,textNodeKeyMap:new WeakMap,attributeKeyMap:new WeakMap,valueToKeys:new Map,missingWarnings:new Set},At=["title","placeholder","aria-label","aria-description","aria-placeholder","aria-roledescription","alt","label"],Et=t=>!!t&&typeof t!="string"&&typeof t=="object"&&"strTag"in t;function S(t){return String(t||"").trim().toLowerCase()}function _t(t){let e=S(t);return e?e.split("-")[0]||e:""}function q(t){let e=S(t);if(!e)return u.defaultLocale;let n=u.provider?.resolveLocale;if(typeof n=="function"){let o=S(n(t));if(o)return o}return e}function xt(t){let e="";for(let n=0;n<=t.length-1;n+=1)e+=t[n],n<t.length-1&&(e+=`{${n}}`);return e}function O(t,e){return String(t).replace(/\{(\d+)\}/g,(n,o)=>e(Number(o)))}function j(t){if(!t||typeof t!="object")return{};let e={};for(let[n,o]of Object.entries(t)){if(typeof o=="string"){e[n]=o;continue}o&&typeof o=="object"&&typeof o.content=="string"&&(e[n]=o.content)}return e}function St(t){let e=S(t);if(!e)return[u.defaultLocale];let n=_t(e);return!n||n===e?[e]:[e,n]}function tt(t,e){let n=q(t);u.messagesByLocale.set(n,j(e))}function ot(t){typeof t=="string"&&t.length>0&&u.requestedKeys.add(t)}function et(t,e){if(typeof t!="string"||!t.length)return;let n=typeof e=="string"?e:String(e||"");n.length&&(u.valueToKeys.has(n)||u.valueToKeys.set(n,new Set),u.valueToKeys.get(n).add(t))}function B(t){let e=St(t);for(let n of e)if(u.messagesByLocale.has(n))return{locale:n,messages:u.messagesByLocale.get(n)};return null}async function P(t,e="explicit"){let n=q(t),o=B(n);if(o)return o.messages;let r=n;if(u.loadingByLocale.has(r))return u.loadingByLocale.get(r);if(!u.provider)return{};let s=u.provider.loadLocale||u.provider.setLocale||null;if(typeof s!="function")return{};let a={locale:n,defaultLocale:u.defaultLocale,reason:e,loadedLocales:Array.from(u.messagesByLocale.keys()),messages:{...B(n)?.messages||{}},load:e==="set-default"||e==="explicit-load"},i;try{i=s(a)}catch{return{}}if(i&&typeof i.then=="function"){let c=i.then(g=>{let f=j(g);return tt(n,f),f}).catch(()=>({})).finally(()=>{u.loadingByLocale.delete(r)});return u.loadingByLocale.set(r,c),c}let d=j(i);return tt(n,d),d}function Ct(t){if(!t||typeof t!="object")return"";let n=typeof Element<"u"&&t instanceof Element||t?.nodeType===1?t:null;if(!n)return"";if(n.hasAttribute?.("lang"))return S(n.getAttribute("lang"));let o=n.closest?.("[lang]");return o&&o.getAttribute?S(o.getAttribute("lang")):""}function R(t={}){if(typeof t?.lang=="string"&&t.lang.trim())return q(t.lang);let e=t?.element||t?.scope||t?.host||t?.contextElement||null,n=Ct(e);if(n)return q(n);if(typeof document<"u"&&document.documentElement){let o=S(document.documentElement.getAttribute("lang"));if(o)return q(o)}return u.defaultLocale}function Mt(){let t=new Set([u.defaultLocale]);if(typeof document>"u")return t;let e=S(document.documentElement?.getAttribute?.("lang"));e&&t.add(q(e));let n=document.querySelectorAll?.("[lang]")||[];for(let o of n){let r=S(o.getAttribute("lang"));r&&t.add(q(r))}return t}async function Tt(t){for(let e of t)await P(e,"lang-detected")}function qt(t){for(let e of Array.from(u.messagesByLocale.keys()))t.has(e)||u.messagesByLocale.delete(e)}function kt(t){let e=String(t||""),n=(e.match(/^\s*/)||[""])[0],o=(e.match(/\s*$/)||[""])[0],r=n.length,s=e.length-o.length,a=s>=r?e.slice(r,s):"";return{leading:n,core:a,trailing:o}}function nt(t){return String(t||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ot(t,e){let n=typeof t=="string"?t:String(t||""),o=typeof e=="string"?e:String(e||""),r=/\{(\d+)\}/g,s=Array.from(n.matchAll(r));if(!s.length)return n===o?[]:null;let a=[],i="^",d=0;for(let f of s){let h=f.index??0;i+=nt(n.slice(d,h)),i+="([\\s\\S]*?)",a.push(Number(f[1])),d=h+f[0].length}i+=nt(n.slice(d)),i+="$";let c=new RegExp(i).exec(o);if(!c)return null;let g=[];for(let f=1;f<c.length;f+=1){let h=a[f-1],y=c[f];if(Object.prototype.hasOwnProperty.call(g,h)&&g[h]!==y)return null;g[h]=y}return g}function V(t,e){if(typeof t!="string"||!t.length)return[];let n=[t];for(let[,o]of u.messagesByLocale.entries()){let r=o?.[t];typeof r=="string"&&r.length&&n.push(r)}for(let o of n){let r=Ot(o,e);if(r)return r}return[]}function rt(t){if(!t)return null;let e=u.valueToKeys.get(t);if(e&&e.size>0){for(let o of e)if(u.requestedKeys.has(o))return o}if(u.requestedKeys.has(t))return t;let n=Array.from(u.messagesByLocale.entries());for(let o of u.requestedKeys)for(let[,r]of n)if(r&&r[o]===t)return o;return null}function at(t){if(!t)return null;let e=null;for(let[n,o]of u.valueToKeys.entries()){if(typeof n!="string"||!n.length||n===t)continue;let r=t.indexOf(n);if(r!==-1)for(let s of o){if(!u.requestedKeys.has(s))continue;let a=V(s,n),i={key:s,matchedText:n,start:r,end:r+n.length,values:a};(!e||i.matchedText.length>e.matchedText.length)&&(e=i);break}}return e}async function Pt(t){if(!t||t.nodeType!==3)return;let e=t.parentElement||null;if(!e)return;let{leading:n,core:o,trailing:r}=kt(t.nodeValue);if(!o)return;let s=u.textNodeKeyMap.get(t)||null;if((!s||!u.requestedKeys.has(s))&&(s=rt(o)),!s){let f=at(o);if(!f)return;let h=R({element:e});await P(h,"text-node");let y=D(f.key,f.values,{element:e},null),w=f.values.length?O(y,_=>f.values[_]):y,p=o.slice(0,f.start)+w+o.slice(f.end),L=`${n}${p}${r}`;L!==t.nodeValue&&(t.nodeValue=L);return}u.textNodeKeyMap.set(t,s);let a=R({element:e});await P(a,"text-node");let i=V(s,o),d=D(s,i,{element:e},null),c=i.length?O(d,f=>i[f]):d,g=`${n}${c}${r}`;g!==t.nodeValue&&(t.nodeValue=g)}async function Dt(){if(typeof document>"u"||u.requestedKeys.size===0)return;let t=document.body||document.documentElement;if(!t||typeof document.createTreeWalker!="function")return;let e=[],n=new Set,o=s=>{!s||n.has(s)||(n.add(s),e.push(s))};o(t);for(let s=0;s<e.length;s+=1){let a=e[s];if(!a||typeof a.querySelectorAll!="function")continue;let i=a.querySelectorAll("*");for(let d of i){let c=d?.shadowRoot;c&&o(c)}}let r=[];for(let s of e){let a=document.createTreeWalker(s,NodeFilter.SHOW_TEXT);for(;a.nextNode();)r.push(a.currentNode)}for(let s of r)await Pt(s)}function Bt(t){let e=u.attributeKeyMap.get(t);return e||(e=new Map,u.attributeKeyMap.set(t,e)),e}async function Rt(t,e){if(!t||typeof t.getAttribute!="function")return;let n=t.getAttribute(e);if(typeof n!="string"||!n.length)return;let o=Bt(t),r=o.get(e)||null;if((!r||!u.requestedKeys.has(r))&&(r=rt(n)),!r){let c=at(n);if(!c)return;let g=R({element:t});await P(g,"attribute");let f=D(c.key,c.values,{element:t},null),h=c.values.length?O(f,w=>c.values[w]):f,y=n.slice(0,c.start)+h+n.slice(c.end);y!==n&&t.setAttribute(e,y),o.set(e,c.key);return}o.set(e,r);let s=R({element:t});await P(s,"attribute");let a=V(r,n),i=D(r,a,{element:t},null),d=a.length?O(i,c=>a[c]):i;d!==n&&t.setAttribute(e,d)}async function zt(){if(typeof document>"u"||u.requestedKeys.size===0)return;let t=document.body||document.documentElement;if(!t)return;let e=[],n=new Set,o=r=>{!r||n.has(r)||(n.add(r),e.push(r))};o(t);for(let r=0;r<e.length;r+=1){let s=e[r];if(!s||typeof s.querySelectorAll!="function")continue;let a=s.querySelectorAll("*");for(let i of a){let d=i?.shadowRoot;d&&o(d)}}for(let r of e){if(!r||typeof r.querySelectorAll!="function")continue;let s=r.querySelectorAll("*");for(let a of s)for(let i of At)a.hasAttribute(i)&&await Rt(a,i)}}async function Kt(){let t=Mt();await Tt(t),await Dt(),await zt(),qt(t)}function $t(){typeof window>"u"||(u.reconcileTimer&&clearTimeout(u.reconcileTimer),u.reconcileTimer=setTimeout(()=>{u.reconcileTimer=null,Kt()},16))}function D(t,e=[],n={},o=null){let r=R(n),s=B(r);s||P(r,"msg");let a=B(r)?.messages||{},i=B(u.defaultLocale)?.messages||{},d={key:t,values:e,options:n,locale:r,defaultLocale:u.defaultLocale,messages:a,messagesByLocale:Object.fromEntries(Array.from(u.messagesByLocale.entries())),template:o},c,g=!!s,f=r===u.defaultLocale;typeof u.provider?.translate=="function"&&(c=u.provider.translate(d));let h=null;if(c==null&&(c=a[t]),c==null&&(c=i[t],h=c==null?null:"default"),c==null&&(c=t,h="key"),g&&!f&&h){let w=`${r}::${t}`;u.missingWarnings.has(w)||(u.missingWarnings.add(w),Q("warn",`[i18n] Missing translation for locale "${r}" and key "${t}"; using ${h} fallback.`))}let y=typeof c=="string"?c:String(c);if(et(t,y),Array.isArray(e)&&e.length>0){let w=O(y,p=>e[p]);w!==y&&et(t,w)}return y}var It=(t,e,n={})=>{let o=xt(t);ot(o);let r=D(o,e,n,{strings:t,values:e});return O(r,s=>e[s])};var M=(t,e={})=>{if(!t)return"";if(Et(t))return It(t.strings,t.values,e);let n=String(t);ot(n);let o=D(n,[],e,null);return!e?.element&&!e?.scope&&!e?.host&&!e?.contextElement&&!e?.lang&&$t(),o};var Wt=[{selector:".accordion"},{selector:"nav[data-dropdown]"},{selector:"label[data-toggle]"},{selector:"label[data-color]"},{selector:'input[autocomplete="one-time-code"]'},{selector:'input[type="range"]'},{selector:"form[data-required]"},{selector:"fieldset[role=group][data-open]"},{selector:"[data-clip]"},{selector:"button, a[class*='btn-']"}];function Ft(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 jt(t){if(t.dataset.enhancedDropdown)return;t.dataset.enhancedDropdown="true";let e=t.lastElementChild,n=t.classList.contains("split-button");if(!e)return;let o=t.querySelector("[data-dropdown-toggle]")||t.querySelector("button"),r=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype&&"hidePopover"in HTMLElement.prototype;o&&!o.hasAttribute("type")&&o.setAttribute("type","button"),e.id||(e.id=`dropdown-${Math.random().toString(36).slice(2,9)}`);let s=e.tagName?.toLowerCase()==="menu",a=8;s&&!e.hasAttribute("role")&&e.setAttribute("role","menu"),e.hasAttribute("aria-hidden")||e.setAttribute("aria-hidden","true"),o&&(o.setAttribute("aria-haspopup","true"),o.setAttribute("aria-controls",e.id),o.setAttribute("aria-expanded","false"));let i=()=>!n||!s?null:e.querySelector(":scope > li[data-default]")||e.querySelector(":scope > li"),d=l=>l?l.querySelector(":scope > a, :scope > button")||l.firstElementChild:null,c=()=>{if(!n||!o)return null;let l=t.querySelector(":scope > [data-dropdown-default]");return l||(l=document.createElement("button"),l.setAttribute("type","button"),l.setAttribute("data-dropdown-default",""),l.className=o.className,t.insertBefore(l,o),l)},g=(l,b)=>{if(!l||!b)return;l.replaceChildren(...Array.from(b.childNodes).map(v=>v.cloneNode(!0)));let m=b.getAttribute("aria-label")||b.textContent?.replace(/\s+/g," ").trim()||M("Default action");l.setAttribute("aria-label",m),l.title=m},f=()=>{if(!n)return;let l=c(),b=i(),m=d(b);if(!l||!m)return;g(l,m);let v=()=>{m&&typeof m.click=="function"&&m.click()};l.addEventListener("click",A=>{A.preventDefault(),v()})};if(!r){let l="__PDS_DROPDOWN_POPOVER_WARNED__";globalThis[l]||(globalThis[l]=!0,console.warn("[PDS] nav[data-dropdown] requires the Popover API. Add a popover polyfill (recommended: @oddbird/popover-polyfill) for browsers without support."));return}f(),e.setAttribute("popover","auto");let h=()=>{let l=e.getAttribute("style");e.style.visibility="hidden",e.style.display="inline-block",e.style.pointerEvents="none";let b=e.getBoundingClientRect(),m=Math.max(e.offsetWidth||0,e.scrollWidth||0,b.width||0,1),v=Math.max(e.offsetHeight||0,e.scrollHeight||0,b.height||0,1);return l===null?e.removeAttribute("style"):e.setAttribute("style",l),{width:m,height:v}},y=()=>{try{return e.matches(":popover-open")}catch{return!1}},w=()=>{e.setAttribute("aria-hidden","true"),o?.setAttribute("aria-expanded","false")},p=()=>{e.setAttribute("aria-hidden","false"),o?.setAttribute("aria-expanded","true")},L=()=>{let l=(t.getAttribute("data-direction")||t.getAttribute("data-dropdown-direction")||t.getAttribute("data-mode")||"auto").toLowerCase();if(l==="up"||l==="down")return l;let b=(o||t).getBoundingClientRect(),{height:m}=h(),v=Math.max(0,window.innerHeight-b.bottom),A=Math.max(0,b.top),x=v>=m,E=A>=m;return x&&!E?"down":E&&!x?"up":x&&E?"down":A>v?"up":"down"},_=()=>{let l=(t.getAttribute("data-align")||t.getAttribute("data-dropdown-align")||"auto").toLowerCase();if(l==="left"||l==="right"||l==="start"||l==="end")return l==="start"?"left":l==="end"?"right":l;let b=(o||t).getBoundingClientRect(),{width:m}=h(),v=Math.max(0,window.innerWidth-b.left),A=Math.max(0,b.right),x=v>=m,E=A>=m;return x&&!E?"left":E&&!x?"right":x&&E?"left":A>v?"right":"left"},z=(l,b=8)=>{let m=getComputedStyle(t).getPropertyValue(l).trim();if(!m)return b;let v=document.createElement("span");v.style.position="fixed",v.style.visibility="hidden",v.style.pointerEvents="none",v.style.height=m,document.body.appendChild(v);let A=Number.parseFloat(getComputedStyle(v).height);return v.remove(),Number.isFinite(A)?A:b},st=()=>{["position","left","top","right","bottom","margin-top","margin-bottom","max-width","max-inline-size","max-height","overflow"].forEach(l=>e.style.removeProperty(l))},K=()=>{if(!y())return;let l=(o||t).getBoundingClientRect(),b=window.visualViewport,m=b?.width||document.documentElement?.clientWidth||window.innerWidth,v=b?.height||document.documentElement?.clientHeight||window.innerHeight,A=b?.offsetLeft||0,x=b?.offsetTop||0,E=Math.max(1,m-a*2),pt=Math.max(1,v-a*2);e.style.maxWidth=`${Math.round(E)}px`,e.style.maxInlineSize=`${Math.round(E)}px`,e.style.maxHeight=`${Math.round(pt)}px`,e.style.overflow="auto";let{width:W,height:N}=h(),H=z("--spacing-2",8),U=L(),G=_();t.dataset.dropdownDirection=U,t.dataset.dropdownAlign=G;let $=G==="right"?l.right-W:l.left;W>=E-1?$=A+a:$=Math.max(A+a,Math.min($,A+m-W-a));let F=U==="up"?l.top-H-N:l.bottom+H;F=Math.max(x+a,Math.min(F,x+v-N-a)),Object.assign(e.style,{position:"fixed",left:`${Math.round($)}px`,top:`${Math.round(F)}px`,right:"auto",bottom:"auto",marginTop:"0",marginBottom:"0"})},C=null,it=()=>{C||(C=()=>K(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0))},ct=()=>{C&&(window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0),C=null)},k=null,T=null,lt=()=>{k||typeof document>"u"||(k=()=>{y()&&(t.dataset.dropdownDirection=L(),t.dataset.dropdownAlign=_(),T!==null&&cancelAnimationFrame(T),T=requestAnimationFrame(()=>{T=null,y()&&K()}))},document.addEventListener("pds:config-changed",k))},ut=()=>{!k||typeof document>"u"||(document.removeEventListener("pds:config-changed",k),k=null,T!==null&&(cancelAnimationFrame(T),T=null))};e.addEventListener("toggle",l=>{if(l.newState==="open"){p(),K(),it(),lt();return}w(),ct(),ut(),st()});let dt=()=>{y()||(t.dataset.dropdownDirection=L(),t.dataset.dropdownAlign=_(),e.showPopover(),requestAnimationFrame(()=>K()))},I=()=>{y()&&e.hidePopover()},ft=()=>{y()?I():dt()};w(),e.addEventListener("click",l=>{let b=l.target instanceof Element?l.target:l.target?.parentElement;b&&b.closest("[data-dropdown-close]")&&I()}),o?.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),ft()}),t.addEventListener("keydown",l=>{l.key==="Escape"&&(I(),o?.focus())})}function Vt(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 r=()=>{t.setAttribute("aria-checked",e.checked?"true":"false")},s=()=>{e.disabled||(e.checked=!e.checked,r(),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})))};t.addEventListener("click",a=>{a.preventDefault(),s()}),t.addEventListener("keydown",a=>{(a.key===" "||a.key==="Enter")&&(a.preventDefault(),s())}),e.addEventListener("change",r)}function Nt(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"),r=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),r||(r=document.createElement("output"),n.appendChild(r));let s=()=>{if(e.dataset.colorUnset==="1"){r.value="",r.textContent=M("not set"),n.dataset.value="",n.dataset.unset="1",o.dataset.unset="1";return}r.value=e.value,r.textContent=e.value,n.dataset.value=e.value,delete n.dataset.unset,delete o.dataset.unset};s();let a=()=>{e.dataset.colorUnset==="1"&&(e.dataset.colorUnset="0"),s()};e.addEventListener("input",a,{passive:!0}),e.addEventListener("change",a,{passive:!0})}function Ht(t){if(t.dataset.enhancedOneTimeCode)return;t.dataset.enhancedOneTimeCode="true";let e=Number.parseInt(t.getAttribute("data-otp-length")||t.getAttribute("maxlength")||"6",10),n=Number.isFinite(e)&&e>0?e:6,o=t.getAttribute("data-otp-autosubmit")!=="false",r=t.getAttribute("data-otp-format")==="alphanumeric",s=t.getAttribute("data-otp-status-id")||`${t.id||`otp-${Math.random().toString(36).slice(2,9)}`}-status`,a=p=>{let L=String(p||"").replace(/\s+/g,"");return(r?L.replace(/[^0-9a-z]/gi,""):L.replace(/\D+/g,"")).slice(0,n)};t.classList.add("input-otp"),t.dataset.otpLength=String(n),t.dataset.otpComplete="false",t.style.setProperty("--otp-digits",String(n)),t.style.setProperty("--_otp-digit","0"),(!t.hasAttribute("type")||t.getAttribute("type")?.toLowerCase()==="number")&&t.setAttribute("type","text"),t.setAttribute("maxlength",String(n)),t.hasAttribute("inputmode")||t.setAttribute("inputmode",r?"text":"numeric"),t.hasAttribute("enterkeyhint")||t.setAttribute("enterkeyhint","done"),t.hasAttribute("autocapitalize")||t.setAttribute("autocapitalize","off"),t.hasAttribute("spellcheck")||t.setAttribute("spellcheck","false"),t.hasAttribute("pattern")||t.setAttribute("pattern",r?`[0-9A-Za-z]{${n}}`:`\\d{${n}}`),!t.hasAttribute("aria-label")&&!t.labels?.length&&t.setAttribute("aria-label",M("One-time code"));let i=t.form||t.closest("form"),d=!1,c=null,g=()=>{let p=typeof t.selectionStart=="number"?t.selectionStart:t.value.length,L=Math.max(0,Math.min(p,Math.max(n-1,0)));t.style.setProperty("--_otp-digit",String(L))},f=()=>{typeof t.scrollLeft=="number"&&(t.scrollLeft=0)};if(typeof document<"u"){c=document.getElementById(s),c||(c=document.createElement("span"),c.id=s,c.className="otp-status",c.setAttribute("aria-live","polite"),c.setAttribute("aria-atomic","true"),t.insertAdjacentElement("afterend",c));let p=new Set((t.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));p.add(s),t.setAttribute("aria-describedby",Array.from(p).join(" "))}let h=()=>{if(!c)return;let p=t.value.length;c.textContent=p===0?M("Enter the verification code"):p>=n?M("Code complete"):`${p}/${n}`},y=()=>{!o||d||!i||typeof i.checkValidity=="function"&&!i.checkValidity()||(d=!0,requestAnimationFrame(()=>{d=!1;let p=t.getAttribute("data-otp-submit-selector"),L=p?i.querySelector(p):void 0;typeof i.requestSubmit=="function"?i.requestSubmit(L||void 0):i.submit()}))},w=(p,{dispatchChange:L=!1}={})=>{let _=a(p);t.value!==_&&(t.value=_);let z=_.length===n;t.dataset.otpComplete=z?"true":"false",h(),g(),f(),L&&t.dispatchEvent(new Event("change",{bubbles:!0})),z&&y()};t.addEventListener("beforeinput",p=>{if(p.defaultPrevented||p.inputType?.startsWith("delete")||typeof p.data!="string"||p.data.length===0)return;!a(p.data)&&p.data.trim()&&p.preventDefault()}),t.addEventListener("input",()=>{w(t.value);try{let p=t.value.length;t.setSelectionRange(p,p)}catch{}g(),f()}),["focus","click","keyup","select"].forEach(p=>{t.addEventListener(p,()=>{requestAnimationFrame(()=>{g(),f()})})}),t.addEventListener("paste",p=>{let L=p.clipboardData?.getData("text")||"";L&&(p.preventDefault(),t.value=a(L),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})))}),t.addEventListener("keydown",p=>{p.key==="Enter"&&t.value.length===n&&y()}),w(t.value)}function Ut(t){if(t.dataset.enhancedRange)return;let e=a=>{if(t.dataset.enhancedRangeProgrammatic)return;t.dataset.enhancedRangeProgrammatic="1";let i=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),"value")||Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");i?.get&&i?.set&&Object.defineProperty(t,"value",{configurable:!0,enumerable:i.enumerable,get(){return i.get.call(this)},set(c){i.set.call(this,c),a()}}),new MutationObserver(c=>{c.some(f=>{let h=f.attributeName;return h==="value"||h==="min"||h==="max"})&&a()}).observe(t,{attributes:!0,attributeFilter:["value","min","max"]})},n=t.closest("label"),o=n?.classList.contains("range-output"),r=t.id||`range-${Math.random().toString(36).substring(2,11)}`,s=`${r}-output`;if(t.id=r,o){let a=n.querySelector("span");if(a&&!a.classList.contains("range-output-wrapper")){let i=a.getAttribute("data-range-label")||n.getAttribute("data-range-label")||"",d=document.createElement("span");d.className="range-output-wrapper",d.style.display="flex",d.style.justifyContent="space-between",d.style.alignItems="center";let c=document.createElement("span");c.textContent=i||a.textContent,d.appendChild(c);let g=document.createElement("output");g.id=s,g.setAttribute("for",r),g.style.color="var(--surface-text-secondary, var(--color-text-secondary))",g.style.fontSize="0.875rem",g.textContent=t.value,d.appendChild(g),a.textContent="",a.appendChild(d);let f=()=>{g.textContent=t.value};t.addEventListener("input",f),t.addEventListener("change",f),e(f),f()}}else{let a=t.closest(".range-container");a||(a=document.createElement("div"),a.className="range-container",t.parentNode?.insertBefore(a,t),a.appendChild(t)),a.style.position="relative";let i=document.createElement("output");i.id=s,i.setAttribute("for",r),i.className="range-bubble",i.setAttribute("aria-live","polite"),a.appendChild(i);let d=()=>{let f=parseFloat(t.min)||0,h=parseFloat(t.max)||100,y=parseFloat(t.value),w=(y-f)/(h-f);i.style.left=`calc(${w*100}% )`,i.textContent=String(y)},c=()=>i.classList.add("visible"),g=()=>i.classList.remove("visible");t.addEventListener("input",d),t.addEventListener("pointerdown",c),t.addEventListener("pointerup",g),t.addEventListener("pointerleave",g),t.addEventListener("focus",c),t.addEventListener("blur",g),t.addEventListener("change",d),e(d),d()}t.dataset.enhancedRange="1"}function Gt(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 r=document.createElement("span");r.classList.add("required-asterisk"),r.textContent="*",r.style.marginLeft="4px";let s=o.querySelector("span, [data-label]");if(s)s.appendChild(r);else{let i=o.querySelector("input, select, textarea");i?o.insertBefore(r,i):o.appendChild(r)}let a=n.closest("form");if(a&&!a.querySelector(".required-legend")){let i=document.createElement("small");i.classList.add("required-legend"),i.textContent=M("* Required fields"),a.insertBefore(i,a.querySelector(".form-actions")||a.lastElementChild)}};t.querySelectorAll("[required]").forEach(n=>{e(n)})}function Zt(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=M("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 r=e.value.trim();if(r){o.preventDefault();let s=n(),a=s?.type==="radio"?"radio":"checkbox",i=`open-group-${Math.random().toString(36).substring(2,11)}`,d=document.createElement("label"),c=document.createElement("span");c.setAttribute("data-label",""),c.textContent=r;let g=document.createElement("input");g.type=a,g.name=s?.name||t.getAttribute("data-name")||"open-group",g.value=r,g.id=i,d.appendChild(c),d.appendChild(g),t.insertBefore(d,e),e.value=""}}else if(o.key==="Backspace"&&e.value===""){o.preventDefault();let r=t.querySelectorAll("label");r.length>0&&r[r.length-1].remove()}})}function Xt(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 Yt(t){if(t.dataset.enhancedBtnWorking)return;t.dataset.enhancedBtnWorking="true";let e=null,n=!1;new MutationObserver(r=>{r.forEach(s=>{if(s.attributeName==="class"){let a=t.classList.contains("btn-working"),i=t.querySelector("pds-icon");if(a)if(i)e||(e=i.getAttribute("icon")),i.setAttribute("icon","circle-notch");else{let d=document.createElement("pds-icon");d.setAttribute("icon","circle-notch"),d.setAttribute("size","sm"),t.insertBefore(d,t.firstChild),n=!0}else s.oldValue?.includes("btn-working")&&i&&(n?(i.remove(),n=!1):e&&(i.setAttribute("icon",e),e=null))}})}).observe(t,{attributes:!0,attributeFilter:["class"],attributeOldValue:!0})}var Jt=new Map([[".accordion",Ft],["nav[data-dropdown]",jt],["label[data-toggle]",Vt],["label[data-color]",Nt],['input[autocomplete="one-time-code"]',Ht],['input[type="range"]',Ut],["form[data-required]",Gt],["fieldset[role=group][data-open]",Zt],["[data-clip]",Xt],["button, a[class*='btn-']",Yt]]),Qt=Wt.map(t=>({...t,run:Jt.get(t.selector)||(()=>{})}));export{Qt as defaultPDSEnhancers};
|