@stackific/md3 0.1.2 → 0.1.3

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/md3.js CHANGED
@@ -1 +1 @@
1
- const G=[],H=new WeakMap,E=navigator.userAgent.includes("Chrome");navigator.userAgent.includes("Firefox");navigator.userAgent.includes("Safari");navigator.userAgent.includes("Windows");const et=navigator.userAgent.includes("Macintosh");navigator.userAgent.includes("Linux");navigator.userAgent.includes("Android");const nt=/iPad|iPhone|iPod/.test(navigator.userAgent);function Ft(){var t,e;return((e=(t=window==null?void 0:window.matchMedia)==null?void 0:t.call(window,"(prefers-color-scheme: dark)"))==null?void 0:e.matches)??!1}async function it(t){await new Promise(e=>setTimeout(e,t))}function St(){return"fxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function v(t,e){try{return typeof t=="string"?(e??document).querySelector(t):t}catch{return null}}function f(t,e){try{return typeof t=="string"?(e??document).querySelectorAll(t):t??G}catch{return G}}function s(t,e){return(t==null?void 0:t.classList.contains(e))??!1}function h(t,e){var n;return((n=t==null?void 0:t.tagName)==null?void 0:n.toLowerCase())===e}function A(t,e){var n;return((n=t==null?void 0:t.type)==null?void 0:n.toLowerCase())===e}function y(t,e){if(t instanceof NodeList)for(let n=0;n<t.length;n++)t[n].classList.add(e);else t==null||t.classList.add(e)}function g(t,e){if(t instanceof NodeList)for(let n=0;n<t.length;n++)t[n].classList.remove(e);else t==null||t.classList.remove(e)}function x(t,e,n,i=!0){t!=null&&t.addEventListener&&t.addEventListener(e,n,i)}function c(t,e,n,i=!0){if(!t)return;let o=H.get(t);o||(o=new Map,H.set(t,o));const u=e+(i?"1":"0");let r=o.get(u);r||(r=new Set,o.set(u,r)),!r.has(n)&&(r.add(n),x(t,e,n,i))}function F(t,e,n,i=!0){t!=null&&t.removeEventListener&&t.removeEventListener(e,n,i)}function Mt(t,e){var n;(n=e==null?void 0:e.parentNode)==null||n.insertBefore(t,e)}function B(t){return t==null?void 0:t.previousElementSibling}function O(t){return t==null?void 0:t.nextElementSibling}function w(t){return t==null?void 0:t.parentElement}function Dt(t){const e=document.createElement("div");for(const n of Object.keys(t))e.setAttribute(n,t[n]);return e}function P(){var t,e;(e=(t=document.activeElement)==null?void 0:t.blur)==null||e.call(t)}function Lt(t){return f(`[data-ui="#${t}"]`)}function It(t){return v(`[data-ui="#${t}"]`)}function _t(t){t.id&&s(t,"page")&&(t=It(t.id)??t);const e=w(t);if(!s(e,"tabs")&&!s(e,"tabbed")&&!h(e,"nav"))return;const n=f("a",e);for(let i=0;i<n.length;i++)g(n[i],"active");!h(t,"button")&&!s(t,"button")&&!s(t,"chip")&&y(t,"active")}function rt(){const t=getComputedStyle(document.documentElement).getPropertyValue("--size")||"16px";return t.includes("%")?parseInt(t)*16/100:t.includes("em")?parseInt(t)*16:parseInt(t)}function q(t){t.placeholder||(t.placeholder=" ")}function Bt(t){const e=t.currentTarget,n=w(e),i=v("input:not([type=file], [type=checkbox], [type=radio]), select, textarea",n);i&&i.focus()}function $(t){T(t.currentTarget)}function R(t){T(t.currentTarget)}function Ot(t){z(t.currentTarget)}function Pt(t){j(t.currentTarget)}function qt(t){z(t.currentTarget,t)}function $t(t){j(t.currentTarget,t)}function Rt(t){var i;const e=t.currentTarget,n=v("input",w(e));n&&((i=e.textContent)!=null&&i.includes("visibility"))&&(n.type==="password"?(n.type="text",e.textContent="visibility_off"):(n.type="password",e.textContent="visibility"))}function zt(t){ot(t.currentTarget)}function jt(t){const e=t.target.closest(".field > label");e&&(Object.defineProperty(t,"currentTarget",{value:e,configurable:!0}),Bt(t))}function Kt(){const t=document.body;t&&c(t,"click",jt)}function Nt(){const t=f(".field > input:not([type=file], [type=color], [type=range])");for(let e=0;e<t.length;e++)c(t[e],"focus",$),c(t[e],"blur",R),T(t[e])}function Ut(){const t=f(".field > select");for(let e=0;e<t.length;e++)c(t[e],"focus",$),c(t[e],"blur",R)}function Wt(){const t=f(".field > input[type=file]");for(let e=0;e<t.length;e++)c(t[e],"change",Ot),z(t[e])}function Yt(){const t=f(".field > input[type=color]");for(let e=0;e<t.length;e++)c(t[e],"change",Pt),j(t[e])}function Gt(){const t=f(".field > textarea");for(let e=0;e<t.length;e++)c(t[e],"focus",$),c(t[e],"blur",R),q(t[e]),!(E&&!et&&!nt)&&(c(t[e],"input",zt),ot(t[e]))}function Ht(){const t=f(".field:has(> input[type=password]) > i, a");for(let e=0;e<t.length;e++)c(t[e],"click",Rt)}function T(t){A(t,"number")&&!t.value&&(t.value=""),q(t)}function z(t,e){if((e==null?void 0:e.key)==="Enter"){const i=B(t);if(!A(i,"file"))return;i.click();return}const n=O(t);A(n,"text")&&(n.value=t.files?Array.from(t.files).map(i=>i.name).join(", "):"",n.readOnly=!0,c(n,"keydown",qt,!1),T(n))}function j(t,e){if((e==null?void 0:e.key)==="Enter"){const i=B(t);if(!A(i,"color"))return;i.click();return}const n=O(t);A(n,"text")&&(n.readOnly=!0,n.value=t.value,c(n,"keydown",$t,!1),T(n))}function ot(t){if(q(t),t.hasAttribute("rows"))return;const e=rt();t.style.blockSize="auto",t.style.blockSize=`${t.scrollHeight-e}px`}function Vt(){Kt(),Nt(),Ut(),Wt(),Yt(),Gt(),Ht()}function V(t){const e=t.target;!h(e,"input")&&!h(e,"select")||(e.type==="range"?(e.focus(),ct(e)):at())}function Zt(t){if(!window.matchMedia("(pointer: coarse)").matches)return;t.target.blur()}function at(){const t=document.body,e=f(".slider > input[type=range]");e.length?x(t,"input",V,!1):F(t,"input",V,!1);for(let n=0;n<e.length;n++)ct(e[n])}function ct(t){c(t,"change",Zt);const e=w(t),n=v("span",e),i=f("input",e);if(!i.length||!n)return;const o=rt(),u=s(e,"max")?0:.25*o*100/i[0].offsetWidth,r=[],l=[];for(let m=0,Tt=i.length;m<Tt;m++){const U=parseFloat(i[m].min)||0,Ct=parseFloat(i[m].max)||100,W=parseFloat(i[m].value)||0,Y=(W-U)*100/(Ct-U),Et=u/2-u*Y/100;r.push(Y+Et),l.push(W)}let p=r[0],d=0,N=100-d-p,S=l[0],M=l[1]||0;i.length>1&&(p=Math.abs(r[1]-r[0]),d=r[1]>r[0]?r[0]:r[1],N=100-d-p,M>S&&(S=l[1]||0,M=l[0])),requestAnimationFrame(()=>{e.style.cssText=`--_start: ${d}%; --_end: ${N}%; --_value1: '${S}'; --_value2: '${M}';`})}function Xt(){at()}const Z={red:"#F44336",pink:"#E91E63",purple:"#9C27B0","deep-purple":"#673AB7",blue:"#2196F3","light-blue":"#03A9F4",cyan:"#00BCD4",green:"#4CAF50","light-green":"#8BC34A",lime:"#CDDC39",yellow:"#FFEB3B",amber:"#FFC107",orange:"#FF9800","deep-orange":"#FF5722",brown:"#795548","blue-grey":"#607D8B",stackific:"#1447E6","hello-pumpkin":"#FF8F00","sea-lettuce":"#63A002",olive:"#7C7C67",nord:"#5E81AC","vega-violet":"#AD46FF","wild-strawberry":"#F6339A","heliotrope-magenta":"#E12AFB","voodoo-violet":"#804792","red-orchid":"#C0001C","green-brown":"#6E5D00",shakshuka:"#AB350F","purple-honeycreeper":"#8E51FF",maldives:"#00B8DB",verditer:"#00BBA7",fennel:"#00BC7D",gold:"#EFB100","vitamin-c":"#FD9A00",burtuqali:"#FF6900"},ut=["stackific","hello-pumpkin","sea-lettuce","olive","nord","vega-violet","wild-strawberry","heliotrope-magenta","voodoo-violet","red-orchid","green-brown","shakshuka","purple-honeycreeper","maldives","verditer","fennel","gold","vitamin-c","burtuqali"],a={light:"",dark:""},st="md3:mode",lt="md3:theme";function Qt(){return ut.slice()}function Jt(){var t;try{return((t=globalThis.localStorage)==null?void 0:t.getItem(lt))||null}catch{return null}}function te(t){var e;try{(e=globalThis.localStorage)==null||e.setItem(lt,t)}catch{}}function b(){return document==null?void 0:document.documentElement}function ft(){var t;try{return((t=globalThis.localStorage)==null?void 0:t.getItem(st))||null}catch{return null}}function ee(t){var e;try{(e=globalThis.localStorage)==null||e.setItem(st,t)}catch{}}function X(){var e,n;const t=(n=(e=b())==null?void 0:e.dataset)==null?void 0:n.mode;return t==="auto"||t==="light"||t==="dark"?t:ft()||"auto"}function _(){var e,n;const t=(n=(e=b())==null?void 0:e.dataset)==null?void 0:n.mode;return t==="light"||t==="dark"?t:Ft()?"dark":"light"}function ne(){if(a.light&&a.dark)return a;const t=b();if(!t)return a;const e=t.dataset.mode,n=i=>{t.dataset.mode=i;const o=getComputedStyle(t),u=["--primary","--on-primary","--primary-container","--on-primary-container","--secondary","--on-secondary","--secondary-container","--on-secondary-container","--tertiary","--on-tertiary","--tertiary-container","--on-tertiary-container","--error","--on-error","--error-container","--on-error-container","--background","--on-background","--surface","--on-surface","--surface-variant","--on-surface-variant","--outline","--outline-variant","--shadow","--scrim","--inverse-surface","--inverse-on-surface","--inverse-primary","--surface-dim","--surface-bright","--surface-container-lowest","--surface-container-low","--surface-container","--surface-container-high","--surface-container-highest"];let r="";for(let l=0,p=u.length;l<p;l++)r+=u[l]+":"+o.getPropertyValue(u[l])+";";return r};try{a.light=n("light"),a.dark=n("dark")}finally{e===void 0?delete t.dataset.mode:t.dataset.mode=e}return a}async function dt(t){const e=b();if(!t)return ne();if(t.light&&t.dark)return a.light=t.light,a.dark=t.dark,e.setAttribute("style",t[_()]),t;if(typeof t=="string"&&ut.includes(t))return te(t),e.dataset.theme=t,e.removeAttribute("style"),a.light="",a.dark="",{light:"",dark:""};typeof t=="string"&&Z[t]&&(t=Z[t]);const n=globalThis.materialDynamicColors;if(typeof n!="function")throw new Error('ui("theme", source) requires material-dynamic-colors. Install it and `import "material-dynamic-colors"` once at app entry, or include the CDN script.');return n(t).then(i=>{const o=u=>{let r="";for(const l of Object.keys(u)){const p=u[l],d=l.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase();r+="--"+d+":"+p+";"}return r};return a.light=o(i.light),a.dark=o(i.dark),e.setAttribute("style",a[_()]),a})}function pt(t){const e=b();return e?(t&&(t!=="auto"&&t!=="light"&&t!=="dark"&&(t="auto"),ee(t),e.dataset.mode=t,a.light&&a.dark&&e.setAttribute("style",a[_()])),X()):t}let Q=!1;function ie(){if(Q||typeof globalThis.matchMedia!="function")return;const t=globalThis.matchMedia("(prefers-color-scheme: dark)"),e=()=>{const n=b();!n||n.dataset.mode!=="auto"||!a.light||!a.dark||n.setAttribute("style",a[t.matches?"dark":"light"])};t.addEventListener?t.addEventListener("change",e):t.addListener&&t.addListener(e),Q=!0}const C=[];function gt(t){if(t.key==="Escape"){const e=t.currentTarget;yt(e,e)}}function re(t){(v("[autofocus]",t)??t).focus()}function ht(t,e){g(Lt(t.id),"active"),g(t,"active"),g(e,"active"),t.close(),C.pop();const n=C[C.length-1];n&&n.focus()}async function oe(t,e,n,i){!h(i,"button")&&!s(i,"button")&&!s(i,"chip")&&y(i,"active"),y(e,"active"),y(t,"active"),n?t.showModal():t.show(),await it(90),n||x(t,"keydown",gt,!1),C.push(t),re(t)}function ae(t){const e=t.currentTarget,n=O(e);h(n,"dialog")&&ht(n,e)}async function yt(t,e){P();let n=B(e);const i=s(e,"active")||e.open,o=s(e,"modal");o||F(e,"keydown",gt,!1),s(n,"overlay")||(n=Dt({class:"overlay"}),Mt(n,e),await it(90)),o||c(n,"click",ae,!1),i?ht(e,n):oe(e,n,o,t)}let D;function vt(t){F(document.body,"click",vt);const e=t.target,n=f("menu.active");for(let i=0;i<n.length;i++)bt(e,n[i],t)}function ce(t){setTimeout(()=>{const e=v(".field > input",t);e?e.focus():t.focus()},90)}function bt(t,e,n){D&&clearTimeout(D),D=setTimeout(()=>{x(document.body,"click",vt),h(document.activeElement,"input")||P();const i=s(e,"active"),o=(n==null?void 0:n.target)===t,u=!!t.closest("menu");if(!i&&u||i&&o){g(e,"active");return}g(f("menu.active"),"active"),y(e,"active"),ce(e)},90)}let k;function ue(t){const e=t.currentTarget;g(e,"active"),k&&clearTimeout(k)}function se(t,e){P();const n=f(".snackbar.active");for(let i=0;i<n.length;i++)g(n[i],"active");y(t,"active"),c(t,"click",ue),k&&clearTimeout(k),e!==-1&&(k=setTimeout(()=>{g(t,"active")},e??6e3))}function le(t){const e=w(t);e&&g(f(":scope > .page",e),"active"),y(t,"active")}function mt(t){const e=t instanceof MouseEvent,n=t.currentTarget,i=n.getBoundingClientRect(),o=Math.max(i.width,i.height),u=o/2,r=e?t.clientX-i.left-u:i.width/2-u,l=e?t.clientY-i.top-u:i.height/2-u,p=document.createElement("div");p.className="ripple-js";const d=document.createElement("div");d.style.inlineSize=d.style.blockSize=`${o}px`,d.style.left=`${r}px`,d.style.top=`${l}px`,c(d,"animationend",()=>{p.remove()}),p.appendChild(d),n.appendChild(p)}function fe(t){const e=t.target.closest(".slow-ripple, .ripple, .fast-ripple");e&&(Object.defineProperty(t,"currentTarget",{value:e,configurable:!0}),mt(t))}function de(t){const e=t.target.closest(".slow-ripple, .ripple, .fast-ripple");!e||t.key!==" "||(Object.defineProperty(t,"currentTarget",{value:e,configurable:!0}),mt(t))}function pe(){const t=document.body;t&&(c(t,"mousedown",fe),c(t,"keydown",de))}function J(t){const e=t.target;h(e,"progress")?kt(e):At()}function kt(t){requestAnimationFrame(()=>{if(!t.hasAttribute("value")&&!t.hasAttribute("max")){const e=s(t,"circle")?"50":"100";t.style.setProperty("--_value",e),t.setAttribute("value",e),t.setAttribute("max","100"),t.classList.add("indeterminate")}else t.style.setProperty("--_value",String(t.value))})}function At(){if(E&&!et&&!nt)return;const t=document.body,e=f("progress");e.length?x(t,"input",J,!1):F(t,"input",J,!1);for(let n=0;n<e.length;n++)kt(e[n])}let L,I=null;function tt(){L&&clearTimeout(L),L=setTimeout(()=>wt(),180)}async function K(t,e,n,i){if(!e&&(e=v(t.getAttribute("data-ui")),!e)){t.classList.toggle("active");return}if(_t(t),h(e,"dialog")){requestAnimationFrame(()=>yt(t,e));return}if(h(e,"menu")){requestAnimationFrame(()=>bt(t,e,i));return}if(s(e,"snackbar")){requestAnimationFrame(()=>se(e,n));return}if(s(e,"page")){requestAnimationFrame(()=>le(e));return}if(s(e,"active")){g(t,"active"),g(e,"active");return}y(e,"active")}function xt(){globalThis.ui||I||!globalThis.MutationObserver||(I=new MutationObserver(tt),I.observe(document.body,{childList:!0,subtree:!0}),tt())}function ge(t){const e=t.target.closest("[data-ui]");e&&K(e,null,null,t)}function he(t){const e=t.target.closest("[data-ui]");e&&h(e,"a")&&!e.getAttribute("href")&&t.key==="Enter"&&K(e,null,null,t)}function ye(){const t=document.body;t&&(c(t,"click",ge),c(t,"keydown",he))}function wt(t,e){if(t){if(t==="setup"){xt();return}if(t==="guid")return St();if(t==="mode")return pt(e);if(t==="theme")return dt(e);if(t==="themes")return Qt();const n=v(t);if(!n)return;K(n,n,e)}ye(),Vt(),pe(),Xt(),At()}function ve(){var e;if(globalThis.ui)return;const t=(e=globalThis.document)==null?void 0:e.documentElement;if(t){pt(ft()||t.dataset.mode||"auto");const n=Jt();n&&dt(n)}ie(),xt(),globalThis.ui=wt}ve();
1
+ const G=[],H=new WeakMap,E=navigator.userAgent.includes("Chrome");navigator.userAgent.includes("Firefox");navigator.userAgent.includes("Safari");navigator.userAgent.includes("Windows");const et=navigator.userAgent.includes("Macintosh");navigator.userAgent.includes("Linux");navigator.userAgent.includes("Android");const nt=/iPad|iPhone|iPod/.test(navigator.userAgent);function Ft(){var t,e;return((e=(t=window==null?void 0:window.matchMedia)==null?void 0:t.call(window,"(prefers-color-scheme: dark)"))==null?void 0:e.matches)??!1}async function it(t){await new Promise(e=>setTimeout(e,t))}function St(){return"fxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function v(t,e){try{return typeof t=="string"?(e??document).querySelector(t):t}catch{return null}}function f(t,e){try{return typeof t=="string"?(e??document).querySelectorAll(t):t??G}catch{return G}}function s(t,e){return(t==null?void 0:t.classList.contains(e))??!1}function h(t,e){var n;return((n=t==null?void 0:t.tagName)==null?void 0:n.toLowerCase())===e}function A(t,e){var n;return((n=t==null?void 0:t.type)==null?void 0:n.toLowerCase())===e}function y(t,e){if(t instanceof NodeList)for(let n=0;n<t.length;n++)t[n].classList.add(e);else t==null||t.classList.add(e)}function g(t,e){if(t instanceof NodeList)for(let n=0;n<t.length;n++)t[n].classList.remove(e);else t==null||t.classList.remove(e)}function x(t,e,n,i=!0){t!=null&&t.addEventListener&&t.addEventListener(e,n,i)}function c(t,e,n,i=!0){if(!t)return;let o=H.get(t);o||(o=new Map,H.set(t,o));const u=e+(i?"1":"0");let r=o.get(u);r||(r=new Set,o.set(u,r)),!r.has(n)&&(r.add(n),x(t,e,n,i))}function F(t,e,n,i=!0){t!=null&&t.removeEventListener&&t.removeEventListener(e,n,i)}function Mt(t,e){var n;(n=e==null?void 0:e.parentNode)==null||n.insertBefore(t,e)}function B(t){return t==null?void 0:t.previousElementSibling}function O(t){return t==null?void 0:t.nextElementSibling}function w(t){return t==null?void 0:t.parentElement}function Dt(t){const e=document.createElement("div");for(const n of Object.keys(t))e.setAttribute(n,t[n]);return e}function P(){var t,e;(e=(t=document.activeElement)==null?void 0:t.blur)==null||e.call(t)}function Lt(t){return f(`[data-ui="#${t}"]`)}function It(t){return v(`[data-ui="#${t}"]`)}function _t(t){t.id&&s(t,"page")&&(t=It(t.id)??t);const e=w(t);if(!s(e,"tabs")&&!s(e,"tabbed")&&!h(e,"nav"))return;const n=f("a",e);for(let i=0;i<n.length;i++)g(n[i],"active");!h(t,"button")&&!s(t,"button")&&!s(t,"chip")&&y(t,"active")}function rt(){const t=getComputedStyle(document.documentElement).getPropertyValue("--size")||"16px";return t.includes("%")?parseInt(t)*16/100:t.includes("em")?parseInt(t)*16:parseInt(t)}function q(t){t.placeholder||(t.placeholder=" ")}function Bt(t){const e=t.currentTarget,n=w(e),i=v("input:not([type=file], [type=checkbox], [type=radio]), select, textarea",n);i&&i.focus()}function $(t){T(t.currentTarget)}function R(t){T(t.currentTarget)}function Ot(t){z(t.currentTarget)}function Pt(t){j(t.currentTarget)}function qt(t){z(t.currentTarget,t)}function $t(t){j(t.currentTarget,t)}function Rt(t){var i;const e=t.currentTarget,n=v("input",w(e));n&&((i=e.textContent)!=null&&i.includes("visibility"))&&(n.type==="password"?(n.type="text",e.textContent="visibility_off"):(n.type="password",e.textContent="visibility"))}function zt(t){ot(t.currentTarget)}function jt(t){const e=t.target.closest(".field > label");e&&(Object.defineProperty(t,"currentTarget",{value:e,configurable:!0}),Bt(t))}function Kt(){const t=document.body;t&&c(t,"click",jt)}function Nt(){const t=f(".field > input:not([type=file], [type=color], [type=range])");for(let e=0;e<t.length;e++)c(t[e],"focus",$),c(t[e],"blur",R),T(t[e])}function Ut(){const t=f(".field > select");for(let e=0;e<t.length;e++)c(t[e],"focus",$),c(t[e],"blur",R)}function Wt(){const t=f(".field > input[type=file]");for(let e=0;e<t.length;e++)c(t[e],"change",Ot),z(t[e])}function Yt(){const t=f(".field > input[type=color]");for(let e=0;e<t.length;e++)c(t[e],"change",Pt),j(t[e])}function Gt(){const t=f(".field > textarea");for(let e=0;e<t.length;e++)c(t[e],"focus",$),c(t[e],"blur",R),q(t[e]),!(E&&!et&&!nt)&&(c(t[e],"input",zt),ot(t[e]))}function Ht(){const t=f(".field:has(> input[type=password]) > i, a");for(let e=0;e<t.length;e++)c(t[e],"click",Rt)}function T(t){A(t,"number")&&!t.value&&(t.value=""),q(t)}function z(t,e){if((e==null?void 0:e.key)==="Enter"){const i=B(t);if(!A(i,"file"))return;i.click();return}const n=O(t);A(n,"text")&&(n.value=t.files?Array.from(t.files).map(i=>i.name).join(", "):"",n.readOnly=!0,c(n,"keydown",qt,!1),T(n))}function j(t,e){if((e==null?void 0:e.key)==="Enter"){const i=B(t);if(!A(i,"color"))return;i.click();return}const n=O(t);A(n,"text")&&(n.readOnly=!0,n.value=t.value,c(n,"keydown",$t,!1),T(n))}function ot(t){if(q(t),t.hasAttribute("rows"))return;const e=rt();t.style.blockSize="auto",t.style.blockSize=`${t.scrollHeight-e}px`}function Vt(){Kt(),Nt(),Ut(),Wt(),Yt(),Gt(),Ht()}function V(t){const e=t.target;!h(e,"input")&&!h(e,"select")||(e.type==="range"?(e.focus(),ct(e)):at())}function Zt(t){if(!window.matchMedia("(pointer: coarse)").matches)return;t.target.blur()}function at(){const t=document.body,e=f(".slider > input[type=range]");e.length?x(t,"input",V,!1):F(t,"input",V,!1);for(let n=0;n<e.length;n++)ct(e[n])}function ct(t){c(t,"change",Zt);const e=w(t),n=v("span",e),i=f("input",e);if(!i.length||!n)return;const o=rt(),u=s(e,"max")?0:.25*o*100/i[0].offsetWidth,r=[],l=[];for(let m=0,Tt=i.length;m<Tt;m++){const U=parseFloat(i[m].min)||0,Ct=parseFloat(i[m].max)||100,W=parseFloat(i[m].value)||0,Y=(W-U)*100/(Ct-U),Et=u/2-u*Y/100;r.push(Y+Et),l.push(W)}let p=r[0],d=0,N=100-d-p,S=l[0],M=l[1]||0;i.length>1&&(p=Math.abs(r[1]-r[0]),d=r[1]>r[0]?r[0]:r[1],N=100-d-p,M>S&&(S=l[1]||0,M=l[0])),requestAnimationFrame(()=>{e.style.cssText=`--_start: ${d}%; --_end: ${N}%; --_value1: '${S}'; --_value2: '${M}';`})}function Xt(){at()}const Z={red:"#F44336",pink:"#E91E63",purple:"#9C27B0","deep-purple":"#673AB7",blue:"#2196F3","light-blue":"#03A9F4",cyan:"#00BCD4",green:"#4CAF50","light-green":"#8BC34A",lime:"#CDDC39",yellow:"#FFEB3B",amber:"#FFC107",orange:"#FF9800","deep-orange":"#FF5722",brown:"#795548","blue-grey":"#607D8B",stackific:"#1447E6","hello-pumpkin":"#FF8F00","sea-lettuce":"#63A002",olive:"#7C7C67",nord:"#5E81AC","vega-violet":"#AD46FF","wild-strawberry":"#F6339A","heliotrope-magenta":"#E12AFB","voodoo-violet":"#804792","red-orchid":"#C0001C","green-brown":"#6E5D00",shakshuka:"#AB350F","purple-honeycreeper":"#8E51FF",maldives:"#00B8DB",verditer:"#00BBA7",fennel:"#00BC7D",gold:"#EFB100",burtuqali:"#FF6900"},ut=["stackific","hello-pumpkin","sea-lettuce","olive","nord","vega-violet","wild-strawberry","heliotrope-magenta","voodoo-violet","red-orchid","green-brown","shakshuka","purple-honeycreeper","maldives","verditer","fennel","gold","burtuqali"],a={light:"",dark:""},st="md3:mode",lt="md3:theme";function Qt(){return ut.slice()}function Jt(){var t;try{return((t=globalThis.localStorage)==null?void 0:t.getItem(lt))||null}catch{return null}}function te(t){var e;try{(e=globalThis.localStorage)==null||e.setItem(lt,t)}catch{}}function b(){return document==null?void 0:document.documentElement}function ft(){var t;try{return((t=globalThis.localStorage)==null?void 0:t.getItem(st))||null}catch{return null}}function ee(t){var e;try{(e=globalThis.localStorage)==null||e.setItem(st,t)}catch{}}function X(){var e,n;const t=(n=(e=b())==null?void 0:e.dataset)==null?void 0:n.mode;return t==="auto"||t==="light"||t==="dark"?t:ft()||"auto"}function _(){var e,n;const t=(n=(e=b())==null?void 0:e.dataset)==null?void 0:n.mode;return t==="light"||t==="dark"?t:Ft()?"dark":"light"}function ne(){if(a.light&&a.dark)return a;const t=b();if(!t)return a;const e=t.dataset.mode,n=i=>{t.dataset.mode=i;const o=getComputedStyle(t),u=["--primary","--on-primary","--primary-container","--on-primary-container","--secondary","--on-secondary","--secondary-container","--on-secondary-container","--tertiary","--on-tertiary","--tertiary-container","--on-tertiary-container","--error","--on-error","--error-container","--on-error-container","--background","--on-background","--surface","--on-surface","--surface-variant","--on-surface-variant","--outline","--outline-variant","--shadow","--scrim","--inverse-surface","--inverse-on-surface","--inverse-primary","--surface-dim","--surface-bright","--surface-container-lowest","--surface-container-low","--surface-container","--surface-container-high","--surface-container-highest"];let r="";for(let l=0,p=u.length;l<p;l++)r+=u[l]+":"+o.getPropertyValue(u[l])+";";return r};try{a.light=n("light"),a.dark=n("dark")}finally{e===void 0?delete t.dataset.mode:t.dataset.mode=e}return a}async function dt(t){const e=b();if(!t)return ne();if(t.light&&t.dark)return a.light=t.light,a.dark=t.dark,e.setAttribute("style",t[_()]),t;if(typeof t=="string"&&ut.includes(t))return te(t),e.dataset.theme=t,e.removeAttribute("style"),a.light="",a.dark="",{light:"",dark:""};typeof t=="string"&&Z[t]&&(t=Z[t]);const n=globalThis.materialDynamicColors;if(typeof n!="function")throw new Error('ui("theme", source) requires material-dynamic-colors. Install it and `import "material-dynamic-colors"` once at app entry, or include the CDN script.');return n(t).then(i=>{const o=u=>{let r="";for(const l of Object.keys(u)){const p=u[l],d=l.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase();r+="--"+d+":"+p+";"}return r};return a.light=o(i.light),a.dark=o(i.dark),e.setAttribute("style",a[_()]),a})}function pt(t){const e=b();return e?(t&&(t!=="auto"&&t!=="light"&&t!=="dark"&&(t="auto"),ee(t),e.dataset.mode=t,a.light&&a.dark&&e.setAttribute("style",a[_()])),X()):t}let Q=!1;function ie(){if(Q||typeof globalThis.matchMedia!="function")return;const t=globalThis.matchMedia("(prefers-color-scheme: dark)"),e=()=>{const n=b();!n||n.dataset.mode!=="auto"||!a.light||!a.dark||n.setAttribute("style",a[t.matches?"dark":"light"])};t.addEventListener?t.addEventListener("change",e):t.addListener&&t.addListener(e),Q=!0}const C=[];function gt(t){if(t.key==="Escape"){const e=t.currentTarget;yt(e,e)}}function re(t){(v("[autofocus]",t)??t).focus()}function ht(t,e){g(Lt(t.id),"active"),g(t,"active"),g(e,"active"),t.close(),C.pop();const n=C[C.length-1];n&&n.focus()}async function oe(t,e,n,i){!h(i,"button")&&!s(i,"button")&&!s(i,"chip")&&y(i,"active"),y(e,"active"),y(t,"active"),n?t.showModal():t.show(),await it(90),n||x(t,"keydown",gt,!1),C.push(t),re(t)}function ae(t){const e=t.currentTarget,n=O(e);h(n,"dialog")&&ht(n,e)}async function yt(t,e){P();let n=B(e);const i=s(e,"active")||e.open,o=s(e,"modal");o||F(e,"keydown",gt,!1),s(n,"overlay")||(n=Dt({class:"overlay"}),Mt(n,e),await it(90)),o||c(n,"click",ae,!1),i?ht(e,n):oe(e,n,o,t)}let D;function vt(t){F(document.body,"click",vt);const e=t.target,n=f("menu.active");for(let i=0;i<n.length;i++)bt(e,n[i],t)}function ce(t){setTimeout(()=>{const e=v(".field > input",t);e?e.focus():t.focus()},90)}function bt(t,e,n){D&&clearTimeout(D),D=setTimeout(()=>{x(document.body,"click",vt),h(document.activeElement,"input")||P();const i=s(e,"active"),o=(n==null?void 0:n.target)===t,u=!!t.closest("menu");if(!i&&u||i&&o){g(e,"active");return}g(f("menu.active"),"active"),y(e,"active"),ce(e)},90)}let k;function ue(t){const e=t.currentTarget;g(e,"active"),k&&clearTimeout(k)}function se(t,e){P();const n=f(".snackbar.active");for(let i=0;i<n.length;i++)g(n[i],"active");y(t,"active"),c(t,"click",ue),k&&clearTimeout(k),e!==-1&&(k=setTimeout(()=>{g(t,"active")},e??6e3))}function le(t){const e=w(t);e&&g(f(":scope > .page",e),"active"),y(t,"active")}function mt(t){const e=t instanceof MouseEvent,n=t.currentTarget,i=n.getBoundingClientRect(),o=Math.max(i.width,i.height),u=o/2,r=e?t.clientX-i.left-u:i.width/2-u,l=e?t.clientY-i.top-u:i.height/2-u,p=document.createElement("div");p.className="ripple-js";const d=document.createElement("div");d.style.inlineSize=d.style.blockSize=`${o}px`,d.style.left=`${r}px`,d.style.top=`${l}px`,c(d,"animationend",()=>{p.remove()}),p.appendChild(d),n.appendChild(p)}function fe(t){const e=t.target.closest(".slow-ripple, .ripple, .fast-ripple");e&&(Object.defineProperty(t,"currentTarget",{value:e,configurable:!0}),mt(t))}function de(t){const e=t.target.closest(".slow-ripple, .ripple, .fast-ripple");!e||t.key!==" "||(Object.defineProperty(t,"currentTarget",{value:e,configurable:!0}),mt(t))}function pe(){const t=document.body;t&&(c(t,"mousedown",fe),c(t,"keydown",de))}function J(t){const e=t.target;h(e,"progress")?kt(e):At()}function kt(t){requestAnimationFrame(()=>{if(!t.hasAttribute("value")&&!t.hasAttribute("max")){const e=s(t,"circle")?"50":"100";t.style.setProperty("--_value",e),t.setAttribute("value",e),t.setAttribute("max","100"),t.classList.add("indeterminate")}else t.style.setProperty("--_value",String(t.value))})}function At(){if(E&&!et&&!nt)return;const t=document.body,e=f("progress");e.length?x(t,"input",J,!1):F(t,"input",J,!1);for(let n=0;n<e.length;n++)kt(e[n])}let L,I=null;function tt(){L&&clearTimeout(L),L=setTimeout(()=>wt(),180)}async function K(t,e,n,i){if(!e&&(e=v(t.getAttribute("data-ui")),!e)){t.classList.toggle("active");return}if(_t(t),h(e,"dialog")){requestAnimationFrame(()=>yt(t,e));return}if(h(e,"menu")){requestAnimationFrame(()=>bt(t,e,i));return}if(s(e,"snackbar")){requestAnimationFrame(()=>se(e,n));return}if(s(e,"page")){requestAnimationFrame(()=>le(e));return}if(s(e,"active")){g(t,"active"),g(e,"active");return}y(e,"active")}function xt(){globalThis.ui||I||!globalThis.MutationObserver||(I=new MutationObserver(tt),I.observe(document.body,{childList:!0,subtree:!0}),tt())}function ge(t){const e=t.target.closest("[data-ui]");e&&K(e,null,null,t)}function he(t){const e=t.target.closest("[data-ui]");e&&h(e,"a")&&!e.getAttribute("href")&&t.key==="Enter"&&K(e,null,null,t)}function ye(){const t=document.body;t&&(c(t,"click",ge),c(t,"keydown",he))}function wt(t,e){if(t){if(t==="setup"){xt();return}if(t==="guid")return St();if(t==="mode")return pt(e);if(t==="theme")return dt(e);if(t==="themes")return Qt();const n=v(t);if(!n)return;K(n,n,e)}ye(),Vt(),pe(),Xt(),At()}function ve(){var e;if(globalThis.ui)return;const t=(e=globalThis.document)==null?void 0:e.documentElement;if(t){pt(ft()||t.dataset.mode||"auto");const n=Jt();n&&dt(n)}ie(),xt(),globalThis.ui=wt}ve();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackific/md3",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Material Design 3 framework — SCSS + plain-JS. M3 tokens, palette utilities, dialogs, menus, sliders, snackbars; optional runtime theme generation when the consumer brings material-dynamic-colors.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",