material-inspired-component-library 3.0.1 → 3.0.2
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/README.md +2 -2
- package/components/appbar/index.scss +2 -2
- package/components/badge/index.scss +22 -7
- package/components/button/index.scss +2 -2
- package/components/card/README.md +9 -5
- package/components/card/index.scss +49 -22
- package/components/dialog/index.scss +3 -3
- package/components/divider/README.md +3 -3
- package/components/divider/index.scss +18 -27
- package/components/iconbutton/index.scss +2 -2
- package/components/list/index.scss +2 -2
- package/components/navigationrail/index.scss +5 -3
- package/components/radio/README.md +1 -1
- package/components/select/index.scss +5 -2
- package/components/slider/index.scss +4 -4
- package/components/stepper/index.scss +85 -0
- package/components/stepper/index.ts +163 -0
- package/components/switch/README.md +26 -4
- package/components/switch/index.scss +24 -23
- package/components/textfield/index.scss +1 -0
- package/components/textfield/index.ts +54 -20
- package/dist/appbar.css +1 -1
- package/dist/badge.css +1 -1
- package/dist/button.css +1 -1
- package/dist/card.css +1 -1
- package/dist/components/stepper/index.d.ts +5 -0
- package/dist/components/textfield/index.d.ts +2 -1
- package/dist/dialog.css +1 -1
- package/dist/divider.css +1 -1
- package/dist/iconbutton.css +1 -1
- package/dist/layout.css +1 -1
- package/dist/list.css +1 -1
- package/dist/micl.css +1 -1
- package/dist/micl.js +1 -1
- package/dist/navigationrail.css +1 -1
- package/dist/select.css +1 -1
- package/dist/slider.css +1 -1
- package/dist/stepper.css +1 -0
- package/dist/stepper.js +1 -0
- package/dist/switch.css +1 -1
- package/dist/textfield.css +1 -1
- package/docs/card.html +25 -7
- package/docs/divider.html +7 -1
- package/docs/index.html +9 -10
- package/docs/micl.css +1 -1
- package/docs/micl.js +1 -1
- package/docs/navigationrail.html +2 -3
- package/docs/radio.html +1 -1
- package/docs/switch.html +41 -26
- package/layout/index.scss +9 -2
- package/micl.ts +22 -26
- package/package.json +2 -1
- package/styles.scss +1 -0
package/docs/micl.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.micl=t():e.micl=t()}(self,()=>(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};return(()=>{e.r(t),e.d(t,{default:()=>v});const n="dialog.micl-bottomsheet",o=(()=>{const e=e=>{let t=parseInt(e.dataset.miclfitheight||"0",10),n=parseInt(window.getComputedStyle(e).getPropertyValue("max-block-size"),10),o=(e.dataset.miclsnapheights||"").split(",").map(Number).filter(e=>!isNaN(e)&&e>=0&&e<=n);return t<1&&(t=Math.min(e.getBoundingClientRect().height,n),e.dataset.miclfitheight=`${t}`),[...new Set(o.concat([t]).sort())]},t=(t,n)=>{let o=t.getBoundingClientRect().height,i=e(t);return i.filter(e=>e>o+4)[0]||i[n?i.length-1:0]},o=(e,t)=>{t<1?(delete e.dataset.miclfitheight,e.style.removeProperty("--md-sys-bottomsheet-height"),e[e.popover?"hidePopover":"close"]()):e.style.setProperty("--md-sys-bottomsheet-height",`${t}px`)};return{initialize:i=>{if(!i.matches(n)||i.dataset.miclinitialized)return;i.dataset.miclinitialized="1";const r=i.querySelector(".micl-bottomsheet__headline");if(!r)return;const l=r.querySelector(".micl-bottomsheet__draghandle");l?.addEventListener("click",()=>{o(i,t(i,!1))});let a,s,c=!1,m=!1;function d(e){const t=e.clientY;c&&Math.abs(a-t)>4&&(c=!1,m=!0,i.classList.add("micl-bottomsheet--resizing")),m&&o(i,s+a-t)}function p(n){c=!1,i.classList.remove("micl-bottomsheet--resizing"),m&&(m=!1,n.clientY<a?o(i,t(i,!0)):i.getBoundingClientRect().height<48?o(i,0):o(i,(t=>{let n=t.getBoundingClientRect().height,o=e(t),i=o.filter(e=>e<n-4);return i[i.length-1]||o[0]})(i)),document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",p))}r.addEventListener("mousedown",e=>{e.eventPhase===Event.AT_TARGET&&(c=!0,e.preventDefault(),a=e.clientY,s=i.getBoundingClientRect().height,document.addEventListener("mousemove",d),document.addEventListener("mouseup",p))})},cleanup:e=>{e.matches(n)&&(e.classList.remove("micl-bottomsheet--resizing"),delete e.dataset.miclinitialized,delete e.dataset.miclfitheight)}}})(),i="button[popovertarget],button.micl-button--toggle",r=(()=>{const e=e=>{e.target&&e.target instanceof HTMLButtonElement&&(e.target.popoverTargetElement instanceof HTMLDialogElement&&(e.target.popoverTargetElement.open?e.target.popoverTargetElement.close():e.target.popoverTargetElement.showModal()),e.target.classList.contains("micl-button--toggle")&&(e.target.classList.add("micl-button--toggled"),e.target.classList.toggle("micl-button--selected"),e.target.dataset.miclalt&&([e.target.textContent,e.target.dataset.miclalt]=[e.target.dataset.miclalt,e.target.textContent])))};return{initialize:t=>{t.matches("button[popovertarget],button.micl-button--toggle")&&!t.dataset.miclinitialized&&(t.dataset.miclinitialized="1",(t.popoverTargetElement instanceof HTMLDialogElement&&!t.popoverTargetElement.hasAttribute("popover")||t.classList.contains("micl-button--toggle"))&&t.addEventListener("click",e))},cleanup:t=>{t.matches("button[popovertarget],button.micl-button--toggle")&&(document.removeEventListener("click",e),delete t.dataset.miclinitialized)}}})(),l=".micl-list-item-one,.micl-list-item-two,.micl-list-item-three",a=(()=>{const e=e=>!!e&&e.classList.contains("micl-list-item--disabled");return{keydown:t=>{if(!(t instanceof KeyboardEvent&&t.target instanceof Element&&t.target.matches(".micl-list-item-one,.micl-list-item-two,.micl-list-item-three")))return;const n=t.target.parentElement;if(!n)return;let o=[];if(n instanceof HTMLDetailsElement?o=Array.from(n.parentElement?.children||[]).map(t=>{let n=t.querySelector(":scope > summary");return e(n)?null:n}).filter(e=>!!e):n instanceof HTMLUListElement&&(o=Array.from(n.children).map(t=>t instanceof HTMLLIElement&&!e(t)?t:null).filter(e=>!!e)),0===o.length)return;let i=o.findIndex(e=>(e=>!!e&&e.matches(":has(input[type=checkbox]:checked)"))(e)),r=o.findIndex(e=>0===e.tabIndex),l=r;switch(t.key){case"ArrowDown":l=(r+1)%o.length,t.preventDefault();break;case"ArrowUp":l=(r-1+o.length)%o.length,t.preventDefault();break;case"Tab":-1===i?0!==r&&(o[r].tabIndex=-1,o[0].tabIndex=0):i!==r&&(o[r].tabIndex=-1,o[i].tabIndex=0);break;case"Enter":case" ":const e=t.target.querySelector("input[type=checkbox]");e instanceof HTMLInputElement&&(e.checked=!e.checked)}if(l!==r){o[r].tabIndex=-1,o[l].tabIndex=0,o[l].focus();const e=o[l].querySelector(":scope > button");e?.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0,cancelable:!0,view:window}))}}}})(),s=".micl-menu[popover]",c=(()=>{const e=(e,t)=>{const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return(n.x>o.x?"right ":"left ")+(n.y>o.y?"bottom":"top")};return{initialize:t=>{if(!t.matches(".micl-menu[popover]")||t.dataset.miclinitialized)return;t.dataset.miclinitialized="1";const n=document.querySelector(`[popovertarget="${t.id}"]`);n&&t.addEventListener("beforetoggle",o=>{"open"===o.oldState&&(t.style.transformOrigin=e(n,t))}),n&&t.addEventListener("toggle",o=>{"closed"===o.oldState&&(t.style.transformOrigin=e(n,t))}),t.querySelectorAll(":scope > ul.micl-list > li > button[popovertarget]").forEach(e=>{if(e.popoverTargetElement?.matches(".micl-menu[popover]")){let t,n=`--${e.popoverTargetElement.id}`;e.popoverTargetElement instanceof HTMLElement&&(e.style.setProperty("anchor-name",n),e.popoverTargetElement.style.insetBlockStart=`anchor(${n} start)`,e.popoverTargetElement.style.insetInlineStart=`anchor(${n} end)`),e.addEventListener("mouseenter",()=>{e.popoverTargetElement instanceof HTMLElement&&e.popoverTargetElement.showPopover()}),e.addEventListener("mouseleave",()=>{t=setTimeout(()=>{e.popoverTargetElement instanceof HTMLElement&&!e.popoverTargetElement.matches(":hover")&&e.popoverTargetElement.hidePopover()},100)}),e.popoverTargetElement.addEventListener("mouseenter",()=>{clearTimeout(t)}),e.popoverTargetElement.addEventListener("mouseleave",()=>{e.popoverTargetElement instanceof HTMLElement&&e.popoverTargetElement.hidePopover()})}})}}})(),m=".micl-navigationrail__item[for]:not(.micl-navigationrail__item--disabled)",d={keydown:e=>{if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLLabelElement&&e.target.matches(m)))return;const t=document.getElementById(e.target.htmlFor);if(t)switch(e.key){case"Enter":case" ":e.preventDefault(),t.checked||(t.checked=!t.checked)}}},p="input[type=range].micl-slider-xs,input[type=range].micl-slider-s,input[type=range].micl-slider-m,input[type=range].micl-slider-l,input[type=range].micl-slider-xl",u=(()=>{const e=String.fromCharCode(8226),t=String.fromCharCode(8201),n=e=>e.parentElement?.classList.contains("micl-slider__container")?e.parentElement:null,o=(e,t)=>{e.dataset.miclsliderticks=t},i=e=>{let t=JSON.stringify(e.value+""),o=n(e);o&&(o.style.setProperty("--md-sys-slider-value",e.value),o.style.setProperty("--md-sys-slider-tip",t)),e.style.setProperty("--md-sys-slider-value",e.value),e.style.setProperty("--md-sys-slider-tip",t)};return{initialize:r=>{if(!r.matches(p))return;(e=>{let t=e.max||"100";n(e)?.style.setProperty("--md-sys-slider-max",t),e.style.setProperty("--md-sys-slider-max",t)})(r),(e=>{let t=e.min||"0";n(e)?.style.setProperty("--md-sys-slider-min",t),e.style.setProperty("--md-sys-slider-min",t)})(r),i(r),(e=>{let t=n(e);if(t){const n=window.getComputedStyle(e);["--md-sys-slider-handle-height","--md-sys-slider-track-height"].forEach(e=>{t.style.setProperty(e,n.getPropertyValue(e))})}})(r);const l=parseFloat(r.max),a=parseFloat(r.min),s=r.getBoundingClientRect(),c=((e,t,n)=>{const o=[];return e.list&&t>n&&e.list.querySelectorAll("option[value]").forEach(e=>{let i=parseFloat(e.value);!isNaN(i)&&i>=n&&i<=t&&o.push(i)}),o})(r,l,a).sort((e,t)=>e-t).map(e=>Math.round(100*(e-a)/(l-a)));if(c.length>0){const n=document.createElement("canvas"),i=n.getContext("2d");if(i){i.font=window.getComputedStyle(r).getPropertyValue("font");let n=i.measureText(t).width,l=i.measureText(e).width,a=s.width-10,m=0,d="";c.forEach(o=>{let i=a*o/100,r=Math.round((i-m)/n)-1;for(let e=0;e<r;e++)d+=t,m+=n;d+=e,m+=l}),o(r,d)}n.remove()}else o(r,e)},input:e=>{e.target.matches(p)&&e.target instanceof HTMLInputElement&&!e.target.disabled&&i(e.target)}}})(),g=".micl-textfield-outlined > input,.micl-textfield-filled > input",f=".micl-textfield-outlined > textarea,.micl-textfield-filled > textarea",y=".micl-textfield-filled > select,.micl-textfield-outlined > select",h=(()=>{const e=e=>{if(!e.parentElement||e instanceof HTMLSelectElement||!e.maxLength)return;const t=e.parentElement.querySelector(".micl-textfield__character-counter");t&&(t.textContent=`${e.value.length}/${e.maxLength}`)};return{initialize:t=>{t.dataset.miclinitialized||(t.dataset.miclinitialized="1",t.value&&(t.dataset.miclvalue="1"),t instanceof HTMLSelectElement&&t.addEventListener("mousedown",e=>{const n=t.getBoundingClientRect(),o=n.top,i=window.innerHeight-n.bottom;!t.matches(":open")&&t.style.setProperty("--md-sys-select-picker-origin",o>i?"left bottom":"left top")}),e(t))},input:t=>{t.target.matches(`${g},${y},${f}`)&&(t.target instanceof HTMLInputElement||t.target instanceof HTMLSelectElement||t.target instanceof HTMLTextAreaElement)&&t.target.dataset.miclinitialized&&!t.target.disabled&&(t.target.value?t.target.dataset.miclvalue="1":delete t.target.dataset.miclvalue,e(t.target))}}})(),v=(()=>{const e={[n]:{component:o,type:HTMLDialogElement},[i]:{component:r,type:HTMLButtonElement},[l]:{component:a,type:HTMLElement},[s]:{component:c,type:HTMLElement},[m]:{component:d,type:HTMLLabelElement},[y]:{component:h,type:HTMLSelectElement},[p]:{component:u,type:HTMLInputElement},[f]:{component:h,type:HTMLTextAreaElement},[g]:{component:h,type:HTMLInputElement}},t=Object.keys(e).join(","),v=t=>{for(const[n,{component:o,type:i}]of Object.entries(e))if(t.matches(n)&&t instanceof i&&"function"==typeof o.initialize)return void o.initialize(t)},E=e=>{e.querySelectorAll(t).forEach(v),e.querySelectorAll('[class*="micl-"]').forEach(e=>{"1"===window.getComputedStyle(e).getPropertyValue("--micl-ripple")&&e.addEventListener("pointerdown",t=>{if(t.currentTarget.classList.contains("micl-card--nonactionable"))return;t.stopPropagation();let n=e.getBoundingClientRect();e.style.setProperty("--micl-x",t.clientX-n.left+"px"),e.style.setProperty("--micl-y",t.clientY-n.top+"px")})})},b=t=>{for(const[n,{component:o,type:i}]of Object.entries(e))if(t.matches(n)&&t instanceof i&&"function"==typeof o.cleanup)return void o.cleanup(t)},L=e=>{e.querySelectorAll(t).forEach(b)},T=()=>{new MutationObserver(e=>{e.forEach(e=>{"childList"===e.type&&(e.addedNodes.forEach(e=>{e instanceof HTMLElement&&(e.matches(t)&&v(e),e.querySelectorAll(t).forEach(v))}),e.removedNodes.forEach(e=>{e instanceof HTMLElement&&(e.matches(t)&&b(e),L(e))}))})}).observe(document.body,{childList:!0,subtree:!0}),E(document),document.addEventListener("input",t=>{for(const[n,{component:o,type:i}]of Object.entries(e))if(t.target.matches(n)&&t.target instanceof i&&"function"==typeof o.input)return void o.input(t)}),document.addEventListener("keydown",t=>{for(const[n,{component:o,type:i}]of Object.entries(e))if(t.target.matches(n)&&t.target instanceof i&&"function"==typeof o.keydown)return void o.keydown(t)})},x=()=>{document.removeEventListener("DOMContentLoaded",x),T()};return"loading"!==document.readyState?T():document.addEventListener("DOMContentLoaded",x),{initialize:()=>E(document),cleanup:()=>L(document)}})()})(),t})());
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.micl=t():e.micl=t()}(self,()=>(()=>{"use strict";var e={d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};return(()=>{e.r(t),e.d(t,{default:()=>L});const n="dialog.micl-bottomsheet",i=(()=>{const e=e=>{let t=parseInt(e.dataset.miclfitheight||"0",10),n=parseInt(window.getComputedStyle(e).getPropertyValue("max-block-size"),10),i=(e.dataset.miclsnapheights||"").split(",").map(Number).filter(e=>!isNaN(e)&&e>=0&&e<=n);return t<1&&(t=Math.min(e.getBoundingClientRect().height,n),e.dataset.miclfitheight=`${t}`),[...new Set(i.concat([t]).sort())]},t=(t,n)=>{let i=t.getBoundingClientRect().height,r=e(t);return r.filter(e=>e>i+4)[0]||r[n?r.length-1:0]},i=(e,t)=>{t<1?(delete e.dataset.miclfitheight,e.style.removeProperty("--md-sys-bottomsheet-height"),e[e.popover?"hidePopover":"close"]()):e.style.setProperty("--md-sys-bottomsheet-height",`${t}px`)};return{initialize:r=>{if(!r.matches(n)||r.dataset.miclinitialized)return;r.dataset.miclinitialized="1";const l=r.querySelector(".micl-bottomsheet__headline");if(!l)return;const o=l.querySelector(".micl-bottomsheet__draghandle");o?.addEventListener("click",()=>{i(r,t(r,!1))});let a,s,c=!1,m=!1;function d(e){const t=e.clientY;c&&Math.abs(a-t)>4&&(c=!1,m=!0,r.classList.add("micl-bottomsheet--resizing")),m&&i(r,s+a-t)}function p(n){c=!1,r.classList.remove("micl-bottomsheet--resizing"),m&&(m=!1,n.clientY<a?i(r,t(r,!0)):r.getBoundingClientRect().height<48?i(r,0):i(r,(t=>{let n=t.getBoundingClientRect().height,i=e(t),r=i.filter(e=>e<n-4);return r[r.length-1]||i[0]})(r)),document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",p))}l.addEventListener("mousedown",e=>{e.eventPhase===Event.AT_TARGET&&(c=!0,e.preventDefault(),a=e.clientY,s=r.getBoundingClientRect().height,document.addEventListener("mousemove",d),document.addEventListener("mouseup",p))})},cleanup:e=>{e.matches(n)&&(e.classList.remove("micl-bottomsheet--resizing"),delete e.dataset.miclinitialized,delete e.dataset.miclfitheight)}}})(),r="button[popovertarget],button.micl-button--toggle",l=(()=>{const e=e=>{e.target&&e.target instanceof HTMLButtonElement&&(e.target.popoverTargetElement instanceof HTMLDialogElement&&(e.target.popoverTargetElement.open?e.target.popoverTargetElement.close():e.target.popoverTargetElement.showModal()),e.target.classList.contains("micl-button--toggle")&&(e.target.classList.add("micl-button--toggled"),e.target.classList.toggle("micl-button--selected"),e.target.dataset.miclalt&&([e.target.textContent,e.target.dataset.miclalt]=[e.target.dataset.miclalt,e.target.textContent])))};return{initialize:t=>{t.matches("button[popovertarget],button.micl-button--toggle")&&!t.dataset.miclinitialized&&(t.dataset.miclinitialized="1",(t.popoverTargetElement instanceof HTMLDialogElement&&!t.popoverTargetElement.hasAttribute("popover")||t.classList.contains("micl-button--toggle"))&&t.addEventListener("click",e))},cleanup:t=>{t.matches("button[popovertarget],button.micl-button--toggle")&&(document.removeEventListener("click",e),delete t.dataset.miclinitialized)}}})(),o=".micl-list-item-one,.micl-list-item-two,.micl-list-item-three",a=(()=>{const e=e=>!!e&&e.classList.contains("micl-list-item--disabled");return{keydown:t=>{if(!(t instanceof KeyboardEvent&&t.target instanceof Element&&t.target.matches(".micl-list-item-one,.micl-list-item-two,.micl-list-item-three")))return;const n=t.target.parentElement;if(!n)return;let i=[];if(n instanceof HTMLDetailsElement?i=Array.from(n.parentElement?.children||[]).map(t=>{let n=t.querySelector(":scope > summary");return e(n)?null:n}).filter(e=>!!e):n instanceof HTMLUListElement&&(i=Array.from(n.children).map(t=>t instanceof HTMLLIElement&&!e(t)?t:null).filter(e=>!!e)),0===i.length)return;let r=i.findIndex(e=>(e=>!!e&&e.matches(":has(input[type=checkbox]:checked)"))(e)),l=i.findIndex(e=>0===e.tabIndex),o=l;switch(t.key){case"ArrowDown":o=(l+1)%i.length,t.preventDefault();break;case"ArrowUp":o=(l-1+i.length)%i.length,t.preventDefault();break;case"Tab":-1===r?0!==l&&(i[l].tabIndex=-1,i[0].tabIndex=0):r!==l&&(i[l].tabIndex=-1,i[r].tabIndex=0);break;case"Enter":case" ":const e=t.target.querySelector("input[type=checkbox]");e instanceof HTMLInputElement&&(e.checked=!e.checked)}if(o!==l){i[l].tabIndex=-1,i[o].tabIndex=0,i[o].focus();const e=i[o].querySelector(":scope > button");e?.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0,cancelable:!0,view:window}))}}}})(),s=".micl-menu[popover]",c=(()=>{const e=(e,t)=>{const n=e.getBoundingClientRect(),i=t.getBoundingClientRect();return(n.x>i.x?"right ":"left ")+(n.y>i.y?"bottom":"top")};return{initialize:t=>{if(!t.matches(".micl-menu[popover]")||t.dataset.miclinitialized)return;t.dataset.miclinitialized="1";const n=document.querySelector(`[popovertarget="${t.id}"]`);n&&t.addEventListener("beforetoggle",i=>{"open"===i.oldState&&(t.style.transformOrigin=e(n,t))}),n&&t.addEventListener("toggle",i=>{"closed"===i.oldState&&(t.style.transformOrigin=e(n,t))}),t.querySelectorAll(":scope > ul.micl-list > li > button[popovertarget]").forEach(e=>{if(e.popoverTargetElement?.matches(".micl-menu[popover]")){let t,n=`--${e.popoverTargetElement.id}`;e.popoverTargetElement instanceof HTMLElement&&(e.style.setProperty("anchor-name",n),e.popoverTargetElement.style.insetBlockStart=`anchor(${n} start)`,e.popoverTargetElement.style.insetInlineStart=`anchor(${n} end)`),e.addEventListener("mouseenter",()=>{e.popoverTargetElement instanceof HTMLElement&&e.popoverTargetElement.showPopover()}),e.addEventListener("mouseleave",()=>{t=setTimeout(()=>{e.popoverTargetElement instanceof HTMLElement&&!e.popoverTargetElement.matches(":hover")&&e.popoverTargetElement.hidePopover()},100)}),e.popoverTargetElement.addEventListener("mouseenter",()=>{clearTimeout(t)}),e.popoverTargetElement.addEventListener("mouseleave",()=>{e.popoverTargetElement instanceof HTMLElement&&e.popoverTargetElement.hidePopover()})}})}}})(),m=".micl-navigationrail__item[for]:not(.micl-navigationrail__item--disabled)",d={keydown:e=>{if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLLabelElement&&e.target.matches(m)))return;const t=document.getElementById(e.target.htmlFor);if(t)switch(e.key){case"Enter":case" ":e.preventDefault(),t.checked||(t.checked=!t.checked)}}},p="input[type=range].micl-slider-xs,input[type=range].micl-slider-s,input[type=range].micl-slider-m,input[type=range].micl-slider-l,input[type=range].micl-slider-xl",u=(()=>{const e=String.fromCharCode(8226),t=String.fromCharCode(8201),n=e=>e.parentElement?.classList.contains("micl-slider__container")?e.parentElement:null,i=(e,t)=>{e.dataset.miclsliderticks=t},r=e=>{let t=JSON.stringify(e.value+""),i=n(e);i&&(i.style.setProperty("--md-sys-slider-value",e.value),i.style.setProperty("--md-sys-slider-tip",t)),e.style.setProperty("--md-sys-slider-value",e.value),e.style.setProperty("--md-sys-slider-tip",t)};return{initialize:l=>{if(!l.matches(p))return;(e=>{let t=e.max||"100";n(e)?.style.setProperty("--md-sys-slider-max",t),e.style.setProperty("--md-sys-slider-max",t)})(l),(e=>{let t=e.min||"0";n(e)?.style.setProperty("--md-sys-slider-min",t),e.style.setProperty("--md-sys-slider-min",t)})(l),r(l),(e=>{let t=n(e);if(t){const n=window.getComputedStyle(e);["--md-sys-slider-handle-height","--md-sys-slider-track-height"].forEach(e=>{t.style.setProperty(e,n.getPropertyValue(e))})}})(l);const o=parseFloat(l.max),a=parseFloat(l.min),s=l.getBoundingClientRect(),c=((e,t,n)=>{const i=[];return e.list&&t>n&&e.list.querySelectorAll("option[value]").forEach(e=>{let r=parseFloat(e.value);!isNaN(r)&&r>=n&&r<=t&&i.push(r)}),i})(l,o,a).sort((e,t)=>e-t).map(e=>Math.round(100*(e-a)/(o-a)));if(c.length>0){const n=document.createElement("canvas"),r=n.getContext("2d");if(r){r.font=window.getComputedStyle(l).getPropertyValue("font");let n=r.measureText(t).width,o=r.measureText(e).width,a=s.width-10,m=0,d="";c.forEach(i=>{let r=a*i/100,l=Math.round((r-m)/n)-1;for(let e=0;e<l;e++)d+=t,m+=n;d+=e,m+=o}),i(l,d)}n.remove()}else i(l,e)},input:e=>{e.target.matches(p)&&e.target instanceof HTMLInputElement&&!e.target.disabled&&r(e.target)}}})(),g=".micl-stepper",f=(()=>{const e=e=>{let t=e.querySelector(".micl-stepper__step--current");return t||(t=e.querySelector(".micl-stepper__step"),t?(t.classList.add("micl-stepper__step--current"),t):null)},t=e=>{e.currentTarget&&"transform"===e.propertyName&&(e.currentTarget.classList.remove("micl-stepper__step--fromcurrent","micl-stepper__step--tocurrent"),e.currentTarget.removeEventListener("transitionend",t))},n=(e,t)=>{t&&e.forEach(e=>{e.classList.toggle("micl-hidden",!t[e.classList.contains("micl-stepper--gonext")?"nextElementSibling":"previousElementSibling"]?.classList.contains("micl-stepper__step"))})},i=(e,t)=>{e.querySelectorAll("[data-step]").forEach(e=>{e.classList.toggle("micl-hidden",e.dataset.step!==t.dataset.miclstep)})};return{initialize:r=>{if(!r.matches(g)||r.dataset.miclinitialized)return;r.dataset.miclinitialized="1",r.querySelectorAll(".micl-stepper__step").forEach((e,t)=>{e.dataset.miclstep=`${t+1}`});const l=e(r),o=r.querySelectorAll("button.micl-stepper--goback,button.micl-stepper--gonext");n([...o],l),l&&i(r,l),o.forEach(l=>{l.addEventListener("click",()=>{const a=(t=>{let n=e(t);return n&&(n.querySelectorAll("input:required,select:required,textarea:required").forEach(e=>{e.checkValidity()||(n=null)}),n?.querySelectorAll("fieldset.micl-checkbox-group[data-miclname]").forEach(e=>{let t=0;e.querySelectorAll(`.micl-checkbox[name="${e.dataset.miclname}"]`).forEach(e=>{e.checked&&t++}),0===t&&console.log("NOT ENGOUGH CHECKS")})),n})(r);if(!a)return;const s=a[l.classList.contains("micl-stepper--gonext")?"nextElementSibling":"previousElementSibling"];s?.classList.contains("micl-stepper__step")&&(a.addEventListener("transitionend",t),a.classList.add("micl-stepper__step--fromcurrent"),a.offsetHeight,s.addEventListener("transitionend",t),s.classList.add("micl-stepper__step--tocurrent"),s.offsetHeight,s.classList.add("micl-stepper__step--current"),a.classList.remove("micl-stepper__step--current"),a.offsetHeight,n([...o],s),i(r,s))})})}}})(),h=".micl-textfield-outlined > input,.micl-textfield-filled > input",y=".micl-textfield-outlined > textarea,.micl-textfield-filled > textarea",v=".micl-textfield-filled > select,.micl-textfield-outlined > select",E=(()=>{const e=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement,t=e=>{if(!e.parentElement||e instanceof HTMLSelectElement||!e.maxLength)return;const t=e.parentElement.querySelector(".micl-textfield__character-counter");t&&(t.textContent=`${e.value.length}/${e.maxLength}`)},n=(e,t)=>{if(e.required){e.parentElement?.classList.toggle("micl-textfield--error",!t);const n=e.parentElement?.querySelector(".micl-textfield__supporting-text");n&&(t||"micltext"in n.dataset||(n.dataset.micltext=n.textContent),n.textContent=e.validationMessage||n.dataset.micltext||"")}};return{initialize:e=>{e.dataset.miclinitialized||(e.dataset.miclinitialized="1",e.value&&(e.dataset.miclvalue="1"),e instanceof HTMLSelectElement&&e.addEventListener("mousedown",()=>{const t=e.getBoundingClientRect(),n=t.top,i=window.innerHeight-t.bottom;!e.matches(":open")&&e.style.setProperty("--md-sys-select-picker-origin",n>i?"left bottom":"left top")}),t(e))},input:i=>{e(i.target)&&i.target.matches(`${h},${v},${y}`)&&i.target.dataset.miclinitialized&&!i.target.disabled&&(i.target.value?i.target.dataset.miclvalue="1":delete i.target.dataset.miclvalue,n(i.target,!0),t(i.target))},invalid:t=>{e(t.target)&&n(t.target)}}})(),L=(()=>{const e={[n]:{component:i,type:HTMLDialogElement},[r]:{component:l,type:HTMLButtonElement},[o]:{component:a,type:HTMLElement},[s]:{component:c,type:HTMLElement},[m]:{component:d,type:HTMLLabelElement},[v]:{component:E,type:HTMLSelectElement},[p]:{component:u,type:HTMLInputElement},[g]:{component:f,type:HTMLElement},[y]:{component:E,type:HTMLTextAreaElement},[h]:{component:E,type:HTMLInputElement}},t=Object.keys(e).join(","),L=t=>{for(const[n,{component:i,type:r}]of Object.entries(e))if(t.matches(n)&&t instanceof r&&"function"==typeof i.initialize)return void i.initialize(t)},b=e=>{e.querySelectorAll(t).forEach(L),e.querySelectorAll('[class*="micl-"]').forEach(e=>{"1"===window.getComputedStyle(e).getPropertyValue("--micl-ripple")&&e.addEventListener("pointerdown",t=>{if(t.currentTarget.classList.contains("micl-card--nonactionable"))return;t.stopPropagation();let n=e.getBoundingClientRect();e.style.setProperty("--micl-x",t.clientX-n.left+"px"),e.style.setProperty("--micl-y",t.clientY-n.top+"px")})})},T=t=>{for(const[n,{component:i,type:r}]of Object.entries(e))if(t.matches(n)&&t instanceof r&&"function"==typeof i.cleanup)return void i.cleanup(t)},x=e=>{e.querySelectorAll(t).forEach(T)},S=t=>{for(const[n,{component:i,type:r}]of Object.entries(e))if(t.target.matches(n)&&t.target instanceof r&&["input","invalid","keydown"].includes(t.type)&&"function"==typeof i[t.type])return void i[t.type]?.(t)},M=()=>{new MutationObserver(e=>{e.forEach(e=>{"childList"===e.type&&(e.addedNodes.forEach(e=>{e instanceof HTMLElement&&(e.matches(t)&&L(e),e.querySelectorAll(t).forEach(L))}),e.removedNodes.forEach(e=>{e instanceof HTMLElement&&(e.matches(t)&&T(e),x(e))}))})}).observe(document.body,{childList:!0,subtree:!0}),b(document),document.addEventListener("input",S),document.addEventListener("keydown",S),document.addEventListener("invalid",S,!0)},_=()=>{document.removeEventListener("DOMContentLoaded",_),M()};return"loading"!==document.readyState?M():document.addEventListener("DOMContentLoaded",_),{initialize:()=>b(document),cleanup:()=>x(document)}})()})(),t})());
|
package/docs/navigationrail.html
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
<label for="item1" class="micl-navigationrail__item" tabindex="0">
|
|
29
29
|
<span class="micl-navigationrail__icon material-symbols-outlined" style="anchor-name:--inbox" aria-hidden="true">inbox</span>
|
|
30
30
|
<span class="micl-navigationrail__text">Inbox</span>
|
|
31
|
+
<span class="micl-badge" style="position-anchor:--inbox">97</span>
|
|
31
32
|
</label>
|
|
32
33
|
<input type="radio" id="item2" name="navitem" value="email_outbox">
|
|
33
34
|
<label for="item2" class="micl-navigationrail__item" tabindex="0">
|
|
@@ -38,6 +39,7 @@
|
|
|
38
39
|
<label for="item3" class="micl-navigationrail__item" tabindex="0">
|
|
39
40
|
<span class="micl-navigationrail__icon material-symbols-outlined" style="anchor-name:--favorites" aria-hidden="true">favorite</span>
|
|
40
41
|
<span class="micl-navigationrail__text">Favorites</span>
|
|
42
|
+
<span class="micl-badge micl-badge--small" style="position-anchor:--favorites"></span>
|
|
41
43
|
</label>
|
|
42
44
|
<input type="radio" id="item4" name="navitem" value="email_trash">
|
|
43
45
|
<label for="item4" class="micl-navigationrail__item" tabindex="0">
|
|
@@ -45,9 +47,6 @@
|
|
|
45
47
|
<span class="micl-navigationrail__text">Trash</span>
|
|
46
48
|
</label>
|
|
47
49
|
</div>
|
|
48
|
-
|
|
49
|
-
<span class="micl-badge" style="position-anchor:--inbox;--md-sys-badge-block-offset:4px;--md-sys-badge-inline-offset:16px">97</span>
|
|
50
|
-
<span class="micl-badge micl-badge--small" style="position-anchor:--favorites;--md-sys-badge-block-offset:4px;--md-sys-badge-inline-offset:16px"></span>
|
|
51
50
|
<!-- </nav> -->
|
|
52
51
|
</dialog>
|
|
53
52
|
<main class="micl-body">
|
package/docs/radio.html
CHANGED
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
</div>
|
|
107
107
|
<div class="micl-card__content docs-code">
|
|
108
108
|
<pre><code>
|
|
109
|
-
<div
|
|
109
|
+
<div class="micl-flex--vcenter">
|
|
110
110
|
<input type="radio" class="micl-radio" id="id0" name="choices" checked value="v0">
|
|
111
111
|
<label for="id0" class="md-sys-typescale-body-medium">First Choice</label>
|
|
112
112
|
</div>
|
package/docs/switch.html
CHANGED
|
@@ -17,16 +17,19 @@
|
|
|
17
17
|
flex-direction: column;
|
|
18
18
|
align-items: flex-end;
|
|
19
19
|
}
|
|
20
|
-
.
|
|
21
|
-
display: flex;
|
|
22
|
-
align-items: center;
|
|
20
|
+
.micl-flex--vcenter {
|
|
23
21
|
column-gap: 16px;
|
|
24
|
-
height: 48px;
|
|
25
22
|
}
|
|
26
|
-
.micl-card-outlined.unselectedicon .
|
|
23
|
+
.micl-card-outlined.unselectedicon .micl-flex--vcenter {
|
|
27
24
|
width: 100%;
|
|
28
25
|
justify-content: space-between;
|
|
29
26
|
}
|
|
27
|
+
.micl-card-outlined.unselectedicon label {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
flex-basis: 100%;
|
|
31
|
+
margin-block: 12px;
|
|
32
|
+
}
|
|
30
33
|
.noicons input[type=checkbox].micl-switch {
|
|
31
34
|
--md-sys-switch-selected-icon: "";
|
|
32
35
|
--md-sys-switch-unselected-icon: "";
|
|
@@ -60,19 +63,19 @@
|
|
|
60
63
|
<h2>Switches with icons</h2>
|
|
61
64
|
</div>
|
|
62
65
|
<div class="micl-card__content">
|
|
63
|
-
<div class="
|
|
66
|
+
<div class="micl-flex--vcenter">
|
|
64
67
|
<input type="checkbox" class="micl-switch" id="myswitch1" checked value="c1" role="switch">
|
|
65
68
|
<label for="myswitch1" class="md-sys-typescale-body-medium">First Choice</label>
|
|
66
69
|
</div>
|
|
67
|
-
<div class="
|
|
70
|
+
<div class="micl-flex--vcenter">
|
|
68
71
|
<input type="checkbox" class="micl-switch" id="myswitch2" value="c2" role="switch">
|
|
69
72
|
<label for="myswitch2" class="md-sys-typescale-body-medium">Second Choice</label>
|
|
70
73
|
</div>
|
|
71
|
-
<div class="
|
|
74
|
+
<div class="micl-flex--vcenter">
|
|
72
75
|
<input type="checkbox" class="micl-switch" id="myswitch3" value="c3" disabled role="switch">
|
|
73
76
|
<label for="myswitch3" class="md-sys-typescale-body-medium">Third Choice (disabled)</label>
|
|
74
77
|
</div>
|
|
75
|
-
<div class="
|
|
78
|
+
<div class="micl-flex--vcenter">
|
|
76
79
|
<input type="checkbox" class="micl-switch" id="myswitch4" value="c4" checked disabled role="switch">
|
|
77
80
|
<label for="myswitch4" class="md-sys-typescale-body-medium">Fourth Choice (disabled)</label>
|
|
78
81
|
</div>
|
|
@@ -83,19 +86,19 @@
|
|
|
83
86
|
<h2>Switches without icons</h2>
|
|
84
87
|
</div>
|
|
85
88
|
<div class="micl-card__content">
|
|
86
|
-
<div class="
|
|
89
|
+
<div class="micl-flex--vcenter">
|
|
87
90
|
<label for="myswitch5" class="md-sys-typescale-body-medium">First Choice</label>
|
|
88
91
|
<input type="checkbox" class="micl-switch" id="myswitch5" checked value="c1" role="switch">
|
|
89
92
|
</div>
|
|
90
|
-
<div class="
|
|
93
|
+
<div class="micl-flex--vcenter">
|
|
91
94
|
<label for="myswitch6" class="md-sys-typescale-body-medium">Second Choice</label>
|
|
92
95
|
<input type="checkbox" class="micl-switch" id="myswitch6" value="c2" role="switch">
|
|
93
96
|
</div>
|
|
94
|
-
<div class="
|
|
97
|
+
<div class="micl-flex--vcenter">
|
|
95
98
|
<label for="myswitch7" class="md-sys-typescale-body-medium">Third Choice (disabled)</label>
|
|
96
99
|
<input type="checkbox" class="micl-switch" id="myswitch7" value="c3" disabled role="switch">
|
|
97
100
|
</div>
|
|
98
|
-
<div class="
|
|
101
|
+
<div class="micl-flex--vcenter">
|
|
99
102
|
<label for="myswitch8" class="md-sys-typescale-body-medium">Fourth Choice (disabled)</label>
|
|
100
103
|
<input type="checkbox" class="micl-switch" id="myswitch8" value="c4" checked disabled role="switch">
|
|
101
104
|
</div>
|
|
@@ -108,19 +111,19 @@
|
|
|
108
111
|
<h2>Switches with selected icon</h2>
|
|
109
112
|
</div>
|
|
110
113
|
<div class="micl-card__content">
|
|
111
|
-
<div class="
|
|
114
|
+
<div class="micl-flex--vcenter">
|
|
112
115
|
<input type="checkbox" class="micl-switch" id="myswitch9" checked value="c1" role="switch">
|
|
113
116
|
<label for="myswitch9" class="md-sys-typescale-body-medium">First Choice</label>
|
|
114
117
|
</div>
|
|
115
|
-
<div class="
|
|
118
|
+
<div class="micl-flex--vcenter">
|
|
116
119
|
<input type="checkbox" class="micl-switch" id="myswitch10" value="c2" role="switch">
|
|
117
120
|
<label for="myswitch10" class="md-sys-typescale-body-medium">Second Choice</label>
|
|
118
121
|
</div>
|
|
119
|
-
<div class="
|
|
122
|
+
<div class="micl-flex--vcenter">
|
|
120
123
|
<input type="checkbox" class="micl-switch" id="myswitch11" value="c3" disabled role="switch">
|
|
121
124
|
<label for="myswitch11" class="md-sys-typescale-body-medium">Third Choice (disabled)</label>
|
|
122
125
|
</div>
|
|
123
|
-
<div class="
|
|
126
|
+
<div class="micl-flex--vcenter">
|
|
124
127
|
<input type="checkbox" class="micl-switch" id="myswitch12" value="c4" checked disabled role="switch">
|
|
125
128
|
<label for="myswitch12" class="md-sys-typescale-body-medium">Fourth Choice (disabled)</label>
|
|
126
129
|
</div>
|
|
@@ -132,20 +135,32 @@
|
|
|
132
135
|
<h2>Switches with unselected icon</h2>
|
|
133
136
|
</div>
|
|
134
137
|
<div class="micl-card__content">
|
|
135
|
-
<div class="
|
|
136
|
-
<label for="myswitch13"
|
|
138
|
+
<div class="micl-flex--vcenter">
|
|
139
|
+
<label for="myswitch13">
|
|
140
|
+
<span class="md-sys-typescale-body-large">First Choice</span>
|
|
141
|
+
<span class="md-sys-typescale-body-small">This is the first choice</span>
|
|
142
|
+
</label>
|
|
137
143
|
<input type="checkbox" class="micl-switch" id="myswitch13" checked value="c1" role="switch">
|
|
138
144
|
</div>
|
|
139
|
-
<div class="
|
|
140
|
-
<label for="myswitch14"
|
|
145
|
+
<div class="micl-flex--vcenter">
|
|
146
|
+
<label for="myswitch14">
|
|
147
|
+
<span class="md-sys-typescale-body-large">Second Choice</span>
|
|
148
|
+
<span class="md-sys-typescale-body-small">This is the second choice</span>
|
|
149
|
+
</label>
|
|
141
150
|
<input type="checkbox" class="micl-switch" id="myswitch14" value="c2" role="switch">
|
|
142
151
|
</div>
|
|
143
|
-
<div class="
|
|
144
|
-
<label for="myswitch15"
|
|
152
|
+
<div class="micl-flex--vcenter">
|
|
153
|
+
<label for="myswitch15">
|
|
154
|
+
<span class="md-sys-typescale-body-large">Third Choice</span>
|
|
155
|
+
<span class="md-sys-typescale-body-small">This is the third choice</span>
|
|
156
|
+
</label>
|
|
145
157
|
<input type="checkbox" class="micl-switch" id="myswitch15" value="c3" disabled role="switch">
|
|
146
158
|
</div>
|
|
147
|
-
<div class="
|
|
148
|
-
<label for="myswitch16"
|
|
159
|
+
<div class="micl-flex--vcenter">
|
|
160
|
+
<label for="myswitch16">
|
|
161
|
+
<span class="md-sys-typescale-body-large">Fourth Choice</span>
|
|
162
|
+
<span class="md-sys-typescale-body-small">This is the fourth choice</span>
|
|
163
|
+
</label>
|
|
149
164
|
<input type="checkbox" class="micl-switch" id="myswitch16" value="c4" checked disabled role="switch">
|
|
150
165
|
</div>
|
|
151
166
|
</div>
|
|
@@ -160,7 +175,7 @@
|
|
|
160
175
|
</div>
|
|
161
176
|
<div class="micl-card__content docs-code">
|
|
162
177
|
<pre><code>
|
|
163
|
-
<div style="
|
|
178
|
+
<div class="micl-flex--vcenter" style="column-gap:16px">
|
|
164
179
|
<input type="checkbox" class="micl-switch" id="id0" checked value="v0" role="switch">
|
|
165
180
|
<label for="id0" class="md-sys-typescale-body-medium">First Choice</label>
|
|
166
181
|
</div>
|
package/layout/index.scss
CHANGED
|
@@ -46,6 +46,8 @@ $md-sys-padding-l: 20px;
|
|
|
46
46
|
$md-sys-padding-xl: 24px;
|
|
47
47
|
$md-sys-padding-xxl: 28px;
|
|
48
48
|
|
|
49
|
+
$md-sys-icon-size: 24px;
|
|
50
|
+
|
|
49
51
|
:root {
|
|
50
52
|
--md-sys-layout-pane-spacer: #{$md-sys-pane-spacer};
|
|
51
53
|
|
|
@@ -57,6 +59,8 @@ $md-sys-padding-xxl: 28px;
|
|
|
57
59
|
--md-sys-layout-padding-xl: #{$md-sys-padding-xl};
|
|
58
60
|
--md-sys-layout-padding-xxl: #{$md-sys-padding-xxl};
|
|
59
61
|
|
|
62
|
+
--md-sys-layout-icon-size: #{$md-sys-icon-size};
|
|
63
|
+
|
|
60
64
|
@media (max-width: $md-sys-window-compact-max) {
|
|
61
65
|
--md-sys-layout-window-margin: #{$md-sys-window-margin-compact};
|
|
62
66
|
}
|
|
@@ -229,6 +233,10 @@ $md-sys-padding-xxl: 28px;
|
|
|
229
233
|
}
|
|
230
234
|
}
|
|
231
235
|
|
|
236
|
+
.micl-hidden {
|
|
237
|
+
display: none !important;
|
|
238
|
+
}
|
|
239
|
+
|
|
232
240
|
.micl-flex--vcenter {
|
|
233
241
|
display: flex;
|
|
234
242
|
flex-direction: row;
|
|
@@ -239,8 +247,7 @@ $md-sys-padding-xxl: 28px;
|
|
|
239
247
|
box-sizing: border-box;
|
|
240
248
|
display: grid;
|
|
241
249
|
grid-template-columns: 48px 1fr;
|
|
242
|
-
|
|
243
|
-
row-gap: 24px;
|
|
250
|
+
row-gap: var(--md-sys-layout-padding-xl, 24px);
|
|
244
251
|
background-color: inherit;
|
|
245
252
|
}
|
|
246
253
|
.micl-grid-iconfield__icon {
|
package/micl.ts
CHANGED
|
@@ -25,17 +25,20 @@ import _list, { listSelector } from './components/list';
|
|
|
25
25
|
import _menu, { menuSelector } from './components/menu';
|
|
26
26
|
import _navigationrail, { navigationrailSelector } from './components/navigationrail';
|
|
27
27
|
import _slider, { sliderSelector } from './components/slider';
|
|
28
|
+
import _stepper, { stepperSelector } from './components/stepper';
|
|
28
29
|
import _textfield, { textfieldSelector, textareaSelector, selectSelector } from './components/textfield';
|
|
29
30
|
|
|
30
31
|
interface ComponentEntry<T extends HTMLElement> {
|
|
31
32
|
component: {
|
|
32
33
|
initialize?: (element: T) => void,
|
|
33
34
|
input? : (event: Event) => void,
|
|
35
|
+
invalid? : (event: Event) => void,
|
|
34
36
|
keydown? : (event: Event) => void,
|
|
35
37
|
cleanup? : (element: T) => void
|
|
36
38
|
};
|
|
37
39
|
type: new () => T;
|
|
38
40
|
}
|
|
41
|
+
type ComponentKey = keyof ComponentEntry<any>['component'];
|
|
39
42
|
|
|
40
43
|
export default (() =>
|
|
41
44
|
{
|
|
@@ -47,6 +50,7 @@ export default (() =>
|
|
|
47
50
|
[navigationrailSelector]: { component: _navigationrail, type: HTMLLabelElement },
|
|
48
51
|
[selectSelector] : { component: _textfield, type: HTMLSelectElement },
|
|
49
52
|
[sliderSelector] : { component: _slider, type: HTMLInputElement },
|
|
53
|
+
[stepperSelector] : { component: _stepper, type: HTMLElement },
|
|
50
54
|
[textareaSelector] : { component: _textfield, type: HTMLTextAreaElement },
|
|
51
55
|
[textfieldSelector] : { component: _textfield, type: HTMLInputElement }
|
|
52
56
|
};
|
|
@@ -108,6 +112,21 @@ export default (() =>
|
|
|
108
112
|
parent.querySelectorAll<HTMLElement>(selector).forEach(cleanupComponent);
|
|
109
113
|
};
|
|
110
114
|
|
|
115
|
+
const handleEvent = (event: Event): void =>
|
|
116
|
+
{
|
|
117
|
+
for (const [selector, { component, type }] of Object.entries(componentMap)) {
|
|
118
|
+
if (
|
|
119
|
+
(event.target as Element).matches(selector)
|
|
120
|
+
&& event.target instanceof type
|
|
121
|
+
&& ['input', 'invalid', 'keydown'].includes(event.type)
|
|
122
|
+
&& typeof component[event.type as ComponentKey] === 'function'
|
|
123
|
+
) {
|
|
124
|
+
component[event.type as ComponentKey]?.(event);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
111
130
|
const activate = () =>
|
|
112
131
|
{
|
|
113
132
|
const observer = new MutationObserver(mutations =>
|
|
@@ -142,32 +161,9 @@ export default (() =>
|
|
|
142
161
|
initializeComponents(document);
|
|
143
162
|
|
|
144
163
|
// Delegated Event Handlers
|
|
145
|
-
document.addEventListener('input',
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (
|
|
149
|
-
(event.target as Element).matches(selector)
|
|
150
|
-
&& event.target instanceof type
|
|
151
|
-
&& typeof component.input === 'function'
|
|
152
|
-
) {
|
|
153
|
-
component.input(event);
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
document.addEventListener('keydown', event =>
|
|
159
|
-
{
|
|
160
|
-
for (const [selector, { component, type }] of Object.entries(componentMap)) {
|
|
161
|
-
if (
|
|
162
|
-
(event.target as Element).matches(selector)
|
|
163
|
-
&& event.target instanceof type
|
|
164
|
-
&& typeof component.keydown === 'function'
|
|
165
|
-
) {
|
|
166
|
-
component.keydown(event);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
});
|
|
164
|
+
document.addEventListener('input', handleEvent);
|
|
165
|
+
document.addEventListener('keydown', handleEvent);
|
|
166
|
+
document.addEventListener('invalid', handleEvent, true);
|
|
171
167
|
};
|
|
172
168
|
|
|
173
169
|
const loaded = () =>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "material-inspired-component-library",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "The Material-Inspired Component Library (MICL) offers a collection of beautifully crafted components leveraging native HTML markup, designed to align with the Material Design 3 guidelines.",
|
|
5
5
|
"author": "MICL Hermana <micl.hermana@proton.me> (https://github.com/henkpb/micl)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"UI",
|
|
13
13
|
"UX",
|
|
14
14
|
"CSS",
|
|
15
|
+
"HTML",
|
|
15
16
|
"accordion",
|
|
16
17
|
"app bar",
|
|
17
18
|
"badge",
|