material-inspired-component-library 1.3.0 → 2.0.0

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/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=(()=>{var e=0;const t=t=>{let n=parseInt(window.getComputedStyle(t).getPropertyValue("max-height")),o=(t.dataset.snapheights||"").split(",").map(Number).filter(e=>!isNaN(e)&&e>0&&e<=n);return e||(e=t.getBoundingClientRect().height),[...new Set(o.concat([e,n]).sort())]},n=(e,n)=>{let o=e.getBoundingClientRect().height,i=t(e);return i.filter(e=>e>o+4)[0]||i[n?i.length-1:0]},o=(e,t)=>{e.style.setProperty("--md-sys-bottomsheet-height",`${t}px`)};return{initialize:e=>{if(!e.matches("dialog.micl-bottomsheet")||e.dataset.miclinitialized)return;e.dataset.miclinitialized="1";const i=e.querySelector(".micl-bottomsheet__headline");if(!i)return;const r=i.querySelector(".micl-bottomsheet__draghandle");r?.addEventListener("click",()=>{const t=n(e,!1);t>4&&o(e,t)});let l,a,s=!1,c=!1;function m(t){const n=t.clientY;s&&Math.abs(l-n)>4&&(s=!1,c=!0,e.classList.add("micl-bottomsheet--resizing")),c&&o(e,a+l-n)}function d(i){s=!1,e.classList.remove("micl-bottomsheet--resizing"),c&&(c=!1,i.clientY<l?o(e,n(e,!0)):e.getBoundingClientRect().height<48?(e.popover&&e.hidePopover(),o(e,a)):o(e,(e=>{let n=e.getBoundingClientRect().height,o=t(e),i=o.filter(e=>e<n-4);return i[i.length-1]||o[0]})(e)),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",d))}i.addEventListener("mousedown",t=>{t.eventPhase===Event.AT_TARGET&&(s=!0,t.preventDefault(),l=t.clientY,a=e.getBoundingClientRect().height,document.addEventListener("mousemove",m),document.addEventListener("mouseup",d))})},cleanup:e=>{e.matches("dialog.micl-bottomsheet")&&delete e.dataset.miclinitialized}}})(),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.toggle("micl-button--selected"))};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-checkbox",a={keydown:e=>{if(e.target.matches(l)&&e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&!e.target.disabled)switch(e.key){case"Enter":case" ":e.target.checked=!e.target.checked,e.preventDefault()}}},s=".micl-list-item-one,.micl-list-item-two,.micl-list-item-three",c=(()=>{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}))}}}})(),m=".micl-menu[popover]",d=(()=>{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()})}})}}})(),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 > select,.micl-textfield-filled > select",y=".micl-textfield-outlined > textarea,.micl-textfield-filled > textarea",h=(()=>{const e=".micl-textfield__character-counter";return{initialize:t=>{if(t.dataset.miclinitialized)return;if(t.dataset.miclinitialized="1",t.value&&(t.dataset.miclvalue="1"),t instanceof HTMLSelectElement||!t.maxLength)return;const n=t.parentElement?.querySelector(e);n&&(n.textContent=`${t.value.length}/${t.maxLength}`)},input:t=>{if(!t.target.matches(`${g},${f},${y}`)||!(t.target instanceof HTMLInputElement||t.target instanceof HTMLSelectElement||t.target instanceof HTMLTextAreaElement)||!t.target.dataset.miclinitialized||t.target.disabled)return;if(t.target.value?t.target.dataset.miclvalue="1":delete t.target.dataset.miclvalue,t.target instanceof HTMLSelectElement||!t.target.maxLength)return;const n=t.target.parentElement?.querySelector(e);n&&(n.textContent=`${t.target.value.length}/${t.target.maxLength}`)}}})(),v=(()=>{const e={[n]:{component:o,type:HTMLDialogElement},[i]:{component:r,type:HTMLButtonElement},[l]:{component:a,type:HTMLInputElement},[s]:{component:c,type:HTMLElement},[m]:{component:d,type:HTMLElement},[f]:{component:h,type:HTMLSelectElement},[p]:{component:u,type:HTMLInputElement},[y]:{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=>{e.parentElement&&!window.getComputedStyle(e.parentElement).getPropertyValue("--miclripple")&&window.getComputedStyle(e).getPropertyValue("--miclripple")&&e.addEventListener("pointerdown",t=>{if(t.currentTarget.classList.contains("micl-card--nonactionable"))return;let n=e.getBoundingClientRect(),o=0,i="",r="";for(;(i=e.style.item(o++))&&i;)"--x"!=i&&"--y"!=i&&(r+=`${i}:${e.style.getPropertyValue(i)};`);e.style.cssText=r+`--x:${t.clientX-n.left}px;--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 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=(()=>{var e=0;const t=t=>{let n=parseInt(window.getComputedStyle(t).getPropertyValue("max-height")),o=(t.dataset.snapheights||"").split(",").map(Number).filter(e=>!isNaN(e)&&e>0&&e<=n);return e||(e=t.getBoundingClientRect().height),[...new Set(o.concat([e,n]).sort())]},n=(e,n)=>{let o=e.getBoundingClientRect().height,i=t(e);return i.filter(e=>e>o+4)[0]||i[n?i.length-1:0]},o=(e,t)=>{e.style.setProperty("--md-sys-bottomsheet-height",`${t}px`)};return{initialize:e=>{if(!e.matches("dialog.micl-bottomsheet")||e.dataset.miclinitialized)return;e.dataset.miclinitialized="1";const i=e.querySelector(".micl-bottomsheet__headline");if(!i)return;const r=i.querySelector(".micl-bottomsheet__draghandle");r?.addEventListener("click",()=>{const t=n(e,!1);t>4&&o(e,t)});let l,a,s=!1,c=!1;function m(t){const n=t.clientY;s&&Math.abs(l-n)>4&&(s=!1,c=!0,e.classList.add("micl-bottomsheet--resizing")),c&&o(e,a+l-n)}function d(i){s=!1,e.classList.remove("micl-bottomsheet--resizing"),c&&(c=!1,i.clientY<l?o(e,n(e,!0)):e.getBoundingClientRect().height<48?(e.popover&&e.hidePopover(),o(e,a)):o(e,(e=>{let n=e.getBoundingClientRect().height,o=t(e),i=o.filter(e=>e<n-4);return i[i.length-1]||o[0]})(e)),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",d))}i.addEventListener("mousedown",t=>{t.eventPhase===Event.AT_TARGET&&(s=!0,t.preventDefault(),l=t.clientY,a=e.getBoundingClientRect().height,document.addEventListener("mousemove",m),document.addEventListener("mouseup",d))})},cleanup:e=>{e.matches("dialog.micl-bottomsheet")&&delete e.dataset.miclinitialized}}})(),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 > select,.micl-textfield-filled > select",y=".micl-textfield-outlined > textarea,.micl-textfield-filled > textarea",h=(()=>{const e=".micl-textfield__character-counter";return{initialize:t=>{if(t.dataset.miclinitialized)return;if(t.dataset.miclinitialized="1",t.value&&(t.dataset.miclvalue="1"),t instanceof HTMLSelectElement||!t.maxLength)return;const n=t.parentElement?.querySelector(e);n&&(n.textContent=`${t.value.length}/${t.maxLength}`)},input:t=>{if(!t.target.matches(`${g},${f},${y}`)||!(t.target instanceof HTMLInputElement||t.target instanceof HTMLSelectElement||t.target instanceof HTMLTextAreaElement)||!t.target.dataset.miclinitialized||t.target.disabled)return;if(t.target.value?t.target.dataset.miclvalue="1":delete t.target.dataset.miclvalue,t.target instanceof HTMLSelectElement||!t.target.maxLength)return;const n=t.target.parentElement?.querySelector(e);n&&(n.textContent=`${t.target.value.length}/${t.target.maxLength}`)}}})(),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},[f]:{component:h,type:HTMLSelectElement},[p]:{component:u,type:HTMLInputElement},[y]:{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})());
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>MICL Navigation Rail</title>
7
7
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap">
8
- <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:FILL@0..1&icon_names=arrow_back,close,dark_mode,edit,star,stars&display=block">
8
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:FILL@0..1&icon_names=dark_mode,delete,favorite,inbox,menu,menu_open,outbox&display=block">
9
9
  <link rel="stylesheet" href="themes/airblue/theme.css" id="theme-link">
10
10
  <link rel="stylesheet" href="micl.css">
11
11
  <link rel="stylesheet" href="docs.css">
@@ -20,53 +20,59 @@
20
20
  </style>
21
21
  </head>
22
22
  <body class="light">
23
+ <!-- <dialog id="mynavigationrail1" class="micl-navigationrail" closedby="closerequest"> -->
24
+ <!-- <div id="mynavigationrail1" class="micl-navigationrail" popover="manual"> -->
25
+ <div id="mynavigationrail1" class="micl-navigationrail">
26
+ <div class="micl-navigationrail__headline">
27
+ <button type="button" class="micl-iconbutton-standard-s micl-button--toggle material-symbols-outlined" popovertarget="mynavigationrail1" data-miclalt="menu_open" aria-label="Toggle navigation rail">menu</button>
28
+ </div>
29
+ <div class="micl-navigationrail__content">
30
+ <input type="radio" id="item1" name="navitem" value="email_inbox" checked>
31
+ <label for="item1" class="micl-navigationrail__item" tabindex="0">
32
+ <span class="micl-navigationrail__icon material-symbols-outlined" style="anchor-name:--inbox" aria-hidden="true">inbox</span>
33
+ <span class="micl-navigationrail__text">Inbox</span>
34
+ </label>
35
+ <input type="radio" id="item2" name="navitem" value="email_outbox">
36
+ <label for="item2" class="micl-navigationrail__item" tabindex="0">
37
+ <span class="micl-navigationrail__icon material-symbols-outlined" aria-hidden="true">outbox</span>
38
+ <span class="micl-navigationrail__text">Outbox</span>
39
+ </label>
40
+ <input type="radio" id="item3" name="navitem" value="email_favorites">
41
+ <label for="item3" class="micl-navigationrail__item" tabindex="0">
42
+ <span class="micl-navigationrail__icon material-symbols-outlined" style="anchor-name:--favorites" aria-hidden="true">favorite</span>
43
+ <span class="micl-navigationrail__text">Favorites</span>
44
+ </label>
45
+ <input type="radio" id="item4" name="navitem" value="email_trash">
46
+ <label for="item4" class="micl-navigationrail__item" tabindex="0">
47
+ <span class="micl-navigationrail__icon material-symbols-outlined" aria-hidden="true">delete</span>
48
+ <span class="micl-navigationrail__text">Trash</span>
49
+ </label>
50
+ </div>
51
+
52
+ <span class="micl-badge-large" style="position-anchor:--inbox;--md-sys-badge-block-offset:4px;--md-sys-badge-inline-offset:16px">97</span>
53
+ <span class="micl-badge-small" style="position-anchor:--favorites;--md-sys-badge-block-offset:4px;--md-sys-badge-inline-offset:16px"></span>
54
+ </div>
55
+ <!-- </dialog> -->
56
+
23
57
  <div class="headline">
58
+ <!-- <button type="button" class="micl-iconbutton-standard-s micl-button--toggle material-symbols-outlined" style="margin:8px 0 0 8px" popovertarget="mynavigationrail1" aria-label="Toggle navigation rail">menu</button> -->
24
59
  <h1 class="md-sys-typescale-emphasized-display-small">Navigation rails</h1>
25
60
  <div id="settings-placeholder"></div>
26
61
  </div>
27
62
 
28
63
  <div class="cards">
29
- <div class="micl-card-filled">
30
- <div class="micl-card__content">
31
- <dialog id="mynavigationrail1" class="micl-navigationrail" closedby="closerequest">
32
- <div class="micl-navigationrail__headline">
33
- <h2>Title</h2>
34
- <button class="micl-iconbutton-standard-s material-symbols-outlined" popovertarget="mynavigationrail1">close</button>
35
- </div>
36
- <div class="micl-navigationrail__content">
37
- <button type="button" class="micl-button-tonal-m micl-button--square">
38
- <span class="micl-button__icon material-symbols-outlined">edit</span>
39
- Label
40
- </button>
41
- <p>Label</p>
42
- <button type="button" class="micl-button-tonal-m">
43
- <span class="micl-button__icon material-symbols-outlined">stars</span>
44
- Label
45
- </button>
46
- <button type="button" class="micl-button-text-xs">
47
- <span class="micl-button__icon material-symbols-outlined">stars</span>
48
- Label
49
- </button>
50
- <button type="button" class="micl-button-text-xs">
51
- <span class="micl-button__icon material-symbols-outlined">star</span>
52
- Label
53
- </button>
54
- <p class="md-sys-typescale-title-small">Section Header</p>
55
- <button type="button" class="micl-button-text-xs">
56
- <span class="micl-button__icon material-symbols-outlined">stars</span>
57
- Label
58
- </button>
59
- <span>Label</span>
60
- <button type="button" class="micl-button-text-xs">
61
- <span class="micl-button__icon material-symbols-outlined">star</span>
62
- Label
63
- </button>
64
- <span>Label</span>
65
- </div>
66
- </dialog>
67
- <button type="button" class="micl-button-filled-m" popovertarget="mynavigationrail1">Open Standard Navigation Rail</button>
68
- </div>
69
- </div>
64
+ <div class="micl-card-filled" style="height:400px"></div>
65
+ <div class="micl-card-filled" style="height:400px"></div>
66
+ <div class="micl-card-filled" style="height:400px"></div>
67
+ <div class="micl-card-filled" style="height:400px"></div>
68
+ <div class="micl-card-filled" style="height:400px"></div>
69
+ <div class="micl-card-filled" style="height:400px"></div>
70
+ <div class="micl-card-filled" style="height:400px"></div>
71
+ <div class="micl-card-filled" style="height:400px"></div>
72
+ <div class="micl-card-filled" style="height:400px"></div>
73
+ <div class="micl-card-filled" style="height:400px"></div>
74
+ <div class="micl-card-filled" style="height:400px"></div>
75
+ <div class="micl-card-filled" style="height:400px"></div>
70
76
  </div>
71
77
 
72
78
  <script src="micl.js"></script>
package/micl.ts CHANGED
@@ -21,9 +21,9 @@
21
21
 
22
22
  import _bottomsheet, { bottomsheetSelector } from './components/bottomsheet';
23
23
  import _button, { buttonSelector } from './components/button';
24
- import _checkbox, { checkboxSelector } from './components/checkbox';
25
24
  import _list, { listSelector } from './components/list';
26
25
  import _menu, { menuSelector } from './components/menu';
26
+ import _navigationrail, { navigationrailSelector } from './components/navigationrail';
27
27
  import _slider, { sliderSelector } from './components/slider';
28
28
  import _textfield, { textfieldSelector, selectSelector, textareaSelector } from './components/textfield';
29
29
 
@@ -40,15 +40,15 @@ interface ComponentEntry<T extends HTMLElement> {
40
40
  export default (() =>
41
41
  {
42
42
  const componentMap: Record<string, ComponentEntry<any>> = {
43
- [bottomsheetSelector]: { component: _bottomsheet, type: HTMLDialogElement },
44
- [buttonSelector] : { component: _button, type: HTMLButtonElement },
45
- [checkboxSelector] : { component: _checkbox, type: HTMLInputElement },
46
- [listSelector] : { component: _list, type: HTMLElement },
47
- [menuSelector] : { component: _menu, type: HTMLElement },
48
- [selectSelector] : { component: _textfield, type: HTMLSelectElement },
49
- [sliderSelector] : { component: _slider, type: HTMLInputElement },
50
- [textareaSelector] : { component: _textfield, type: HTMLTextAreaElement },
51
- [textfieldSelector] : { component: _textfield, type: HTMLInputElement }
43
+ [bottomsheetSelector] : { component: _bottomsheet, type: HTMLDialogElement },
44
+ [buttonSelector] : { component: _button, type: HTMLButtonElement },
45
+ [listSelector] : { component: _list, type: HTMLElement },
46
+ [menuSelector] : { component: _menu, type: HTMLElement },
47
+ [navigationrailSelector]: { component: _navigationrail, type: HTMLLabelElement },
48
+ [selectSelector] : { component: _textfield, type: HTMLSelectElement },
49
+ [sliderSelector] : { component: _slider, type: HTMLInputElement },
50
+ [textareaSelector] : { component: _textfield, type: HTMLTextAreaElement },
51
+ [textfieldSelector] : { component: _textfield, type: HTMLInputElement }
52
52
  };
53
53
 
54
54
  const selector = Object.keys(componentMap).join(',');
@@ -71,26 +71,19 @@ export default (() =>
71
71
  {
72
72
  parent.querySelectorAll<HTMLElement>(selector).forEach(initializeComponent);
73
73
 
74
- parent.querySelectorAll<HTMLElement>('[class*="micl-"]').forEach(element => {
75
- if (
76
- element.parentElement
77
- && !window.getComputedStyle(element.parentElement).getPropertyValue('--miclripple')
78
- && window.getComputedStyle(element).getPropertyValue('--miclripple')
79
- ) {
80
- element.addEventListener('pointerdown', e => {
74
+ parent.querySelectorAll<HTMLElement>('[class*="micl-"]').forEach(element =>
75
+ {
76
+ if (window.getComputedStyle(element).getPropertyValue('--micl-ripple') === '1') {
77
+ element.addEventListener('pointerdown', e =>
78
+ {
81
79
  if ((e.currentTarget as Element).classList.contains('micl-card--nonactionable')) {
82
80
  return;
83
81
  }
84
- let r = element.getBoundingClientRect(),
85
- i = 0,
86
- name = '',
87
- styles = '';
88
- while ((name = element.style.item(i++)) && name) {
89
- if ((name != '--x') && (name != '--y')) {
90
- styles += `${name}:${element.style.getPropertyValue(name)};`;
91
- }
92
- }
93
- element.style.cssText = styles + `--x:${e.clientX - r.left}px;--y:${e.clientY - r.top}px`;
82
+ e.stopPropagation();
83
+
84
+ let r = element.getBoundingClientRect();
85
+ element.style.setProperty('--micl-x', `${e.clientX - r.left}px`);
86
+ element.style.setProperty('--micl-y', `${e.clientY - r.top}px`);
94
87
  });
95
88
  }
96
89
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "material-inspired-component-library",
3
- "version": "1.3.0",
3
+ "version": "2.0.0",
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",
@@ -11,7 +11,9 @@
11
11
  "front-end",
12
12
  "UI",
13
13
  "UX",
14
+ "CSS",
14
15
  "accordion",
16
+ "badge",
15
17
  "bottomsheet",
16
18
  "button",
17
19
  "card",
@@ -21,6 +23,7 @@
21
23
  "iconbutton",
22
24
  "list",
23
25
  "menu",
26
+ "navigation rail",
24
27
  "radio button",
25
28
  "sidesheet",
26
29
  "slider",
package/styles.scss CHANGED
@@ -38,6 +38,23 @@
38
38
  @use 'components/select';
39
39
  @use 'components/card';
40
40
  @use 'components/dialog';
41
+ @use 'components/badge';
41
42
  @use 'components/sidesheet';
42
43
  @use 'components/bottomsheet';
43
44
  @use 'components/navigationrail';
45
+
46
+ @property --micl-ripple {
47
+ syntax: '<integer>';
48
+ inherits: false;
49
+ initial-value: 0;
50
+ }
51
+ @property --micl-x {
52
+ syntax: '<length>';
53
+ inherits: false;
54
+ initial-value: -100000px;
55
+ }
56
+ @property --micl-y {
57
+ syntax: '<length>';
58
+ inherits: false;
59
+ initial-value: -100000px;
60
+ }
@@ -1,5 +0,0 @@
1
- export declare const checkboxSelector = ".micl-checkbox";
2
- declare const _default: {
3
- keydown: (event: Event) => void;
4
- };
5
- export default _default;