beercss 2.2.1 → 2.2.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 CHANGED
@@ -135,8 +135,8 @@ This project was guided by the **"Germany Beer Purity Law"** or **"Reinheitsgebo
135
135
  From jsdelivr.net.
136
136
 
137
137
  ```html
138
- <link href="https://cdn.jsdelivr.net/npm/beercss@2.2.1/dist/cdn/beer.min.css" rel="stylesheet" />
139
- <script src="https://cdn.jsdelivr.net/npm/beercss@2.2.1/dist/cdn/beer.min.js" type="text/javascript"></script>
138
+ <link href="https://cdn.jsdelivr.net/npm/beercss@2.2.2/dist/cdn/beer.min.css" rel="stylesheet" />
139
+ <script src="https://cdn.jsdelivr.net/npm/beercss@2.2.2/dist/cdn/beer.min.js" type="text/javascript"></script>
140
140
  <script src="https://cdn.jsdelivr.net/npm/material-dynamic-colors@0.0.10/dist/cdn/material-dynamic-colors.min.js" type="text/javascript"></script>
141
141
  ```
142
142
 
@@ -168,8 +168,8 @@ You can use this html to setup your project. See on [Codepen](https://codepen.io
168
168
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
169
169
  <meta name="google" content="notranslate">
170
170
  <title>Hello world</title>
171
- <link href="https://cdn.jsdelivr.net/npm/beercss@2.2.1/dist/cdn/beer.min.css" rel="stylesheet">
172
- <script src="https://cdn.jsdelivr.net/npm/beercss@2.2.1/dist/cdn/beer.min.js" type="text/javascript"></script>
171
+ <link href="https://cdn.jsdelivr.net/npm/beercss@2.2.2/dist/cdn/beer.min.css" rel="stylesheet">
172
+ <script src="https://cdn.jsdelivr.net/npm/beercss@2.2.2/dist/cdn/beer.min.js" type="text/javascript"></script>
173
173
  <script src="https://cdn.jsdelivr.net/npm/material-dynamic-colors@0.0.10/dist/cdn/material-dynamic-colors.min.js" type="text/javascript"></script>
174
174
  </head>
175
175
  <body class="light">
@@ -1 +1 @@
1
- (()=>{if(window.ui)return;let g=null,x=null,k=null,m={light:"",dark:""};const q=()=>"fxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let e=Math.random()*16|0;return(r=="x"?e:e&3|8).toString(16)}),u=(r,e)=>{try{return typeof r=="string"?(e||document).querySelector(r):r}catch{}},c=(r,e)=>{try{return typeof r=="string"?(e||document).querySelectorAll(r):r}catch{}},a=(r,e)=>r?r.classList.contains(e):!1,p=(r,e)=>{!r||r.classList.add(e)},l=(r,e)=>{!r||r.classList.remove(e)},s=(r,e,t)=>{r.addEventListener(e,t,!0)},Y=(r,e,t)=>{r.removeEventListener(e,t,!0)},D=(r,e)=>{if(!!e)return e.parentNode.insertBefore(r,e)},F=r=>{if(!!r)return r.previousElementSibling},B=r=>{if(!!r)return r.nextElementSibling},f=r=>{if(!!r)return r.parentElement},T=r=>{let e=document.createElement("div");for(let t in r)e[t]=r[t];return e},v=r=>{let e=r,t=f(r),o=u("label",t),i=a(t,"border")&&!a(t,"fill");if(document.activeElement==r||e.value||/date|time/.test(e.type)){if(i&&o){let n=a(o,"active")?o.offsetWidth:Math.round(o.offsetWidth/1.33),b=a(t,"round")?20:12,C=n+b+8;e.style.clipPath=`polygon(0% 0%, ${b}rem 0%, ${b}rem 8rem, ${C}rem 8rem, ${C}rem 0%, 100% 0%, 100% 100%, 0% 100%)`}else e.style.clipPath="";p(o,"active")}else l(o,"active"),e.style.clipPath="";r.getAttribute("data-ui")&&z(r)},j=r=>{let e=r.currentTarget;/input/i.test(e.tagName)||z(e)},L=r=>{let e=r.currentTarget,t=u("input:not([type=file]):not([type=checkbox]):not([type=radio]), select, textarea",f(e));t&&t.focus()},A=r=>{let e=r.currentTarget;v(e)},S=r=>{let e=r.currentTarget;v(e)},E=r=>{let e=r.currentTarget;c(".dropdown.active").forEach(o=>l(o,"active")),Y(e,"click",E)},$=r=>{let e=r.currentTarget;l(e,"active"),g&&clearTimeout(g)},_=r=>{let e=r.currentTarget;w(e)},N=r=>{let e=r.currentTarget;w(e,r)},M=()=>{x&&clearTimeout(x),x=setTimeout(y,180)},w=(r,e)=>{if(e){if(e.key!=="Enter")return;let i=e.currentTarget,d=B(i);return!d||!/file/i.test(d.type)?void 0:d.click()}let t=r,o=F(r);!o||!/text/i.test(o.type)||(o.value=Array.from(t.files).map(i=>i.name).join(", "),o.readOnly=!0,o.addEventListener("keydown",N),v(o))},z=(r,e,t)=>{if(e||(e=u(r.getAttribute("data-ui"))),a(e,"modal"))return O(r,e);if(a(e,"dropdown"))return P(r,e);if(a(e,"toast"))return H(r,e,t);if(a(e,"page"))return I(r,e);if(a(e,"progress"))return U(e,t);if(h(r),a(e,"active"))return l(e,"active");p(e,"active")},h=r=>{let e=f(r);if(!a(e,"tabs"))return;c("a",e).forEach(o=>l(o,"active")),p(r,"active")},I=(r,e)=>{h(r);let t=f(e);for(let o=0;o<t.children.length;o++)a(t.children[o],"page")&&l(t.children[o],"active");p(e,"active")},P=(r,e)=>{if(h(r),a(e,"active"))return l(e,"active");c(".dropdown.active").forEach(o=>l(o,"active")),p(e,"active"),s(document.body,"click",E)},O=(r,e)=>{h(r);let t=F(e);a(t,"overlay")||(t=T({className:"overlay active"}),D(t,e)),t.onclick=()=>{l(r,"active"),l(e,"active"),l(t,"active")};let o=a(e,"active"),i=f(e);/nav/i.test(i.tagName)&&c(".modal, a, .overlay",i).forEach(n=>l(n,"active")),o?(l(r,"active"),l(t,"active"),l(e,"active")):(!/button/i.test(r.tagName)&&!a(r,"button")&&!a(r,"chip")&&p(r,"active"),p(t,"active"),p(e,"active"))},H=(r,e,t)=>{h(r),c(".toast.active").forEach(i=>l(i,"active")),p(e,"active"),s(e,"click",$),g&&clearTimeout(g),!(t&&t==-1)&&(g=setTimeout(()=>{l(e,"active")},t&&t?t:6e3))},U=(r,e)=>{let t=r;if(a(t,"left"))return t.style.clipPath=`polygon(0% 0%, 0% 100%, ${e}% 100%, ${e}% 0%)`;if(a(t,"top"))return t.style.clipPath=`polygon(0% 0%, 100% 0%, 100% ${e}%, 0% ${e}%)`;if(a(t,"right"))return t.style.clipPath=`polygon(100% 0%, 100% 100%, ${100-e}% 100%, ${100-e}% 0%)`;if(a(t,"bottom"))return t.style.clipPath=`polygon(0% 100%, 100% 100%, 100% ${100-e}%, 0% ${100-e}%)`},R=()=>{if(m.light&&m.dark)return m;let r=document.createElement("body");r.className="light",document.body.appendChild(r);let e=document.createElement("body");e.className="dark",document.body.appendChild(e);let t=getComputedStyle(r),o=getComputedStyle(e),i=["--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","--outline","--surface-variant","--on-surface-variant","--inverse-surface","--inverse-on-surface"];for(let d=0;d<i.length;d++)m.light+=i[d]+":"+t.getPropertyValue(i[d])+";",m.dark+=i[d]+":"+o.getPropertyValue(i[d])+";";return document.body.removeChild(r),document.body.removeChild(e),m},V=r=>{if(!r||!window.materialDynamicColors)return R();let e=/dark/i.test(document.body.className)?"dark":"light";return r&&r.light&&r.dark?(m.light=r.light,m.dark=r.dark,document.body.setAttribute("style",r[e]),r):window.materialDynamicColors(r).then(t=>{const o=i=>{let d="";for(let n in i){let b=n.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase();d+="--"+b+":"+i[n]+";"}return d};return m.light=o(t.light),m.dark=o(t.dark),document.body.setAttribute("style",m[e]),m})},W=r=>r?(document.body.classList.remove("light","dark"),document.body.classList.add(r),window.materialDynamicColors&&document.body.setAttribute("style",m[r]),r):/dark/i.test(document.body.className)?"dark":"light",Z=()=>{k||(k=new MutationObserver(M),k.observe(document.body,{childList:!0,subtree:!0}),y())},y=(r,e)=>{if(r){if(r=="setup")return Z();if(r=="guid")return q();if(r=="mode")return W(e);if(r=="theme")return V(e);let n=u(r),b=u("[data-ui='#"+n.id+"']");z(b,n,e)}c("[data-ui]").forEach(n=>s(n,"click",j)),c(".field > label").forEach(n=>s(n,"click",L)),c(".field > input:not([type=file]):not([type=checkbox]):not([type=radio]), .field > select, .field > textarea").forEach(n=>{s(n,"focus",A),s(n,"blur",S),v(n)}),c(".field > input[type=file]").forEach(n=>{s(n,"change",_),w(n)})};window.ui=y,window.addEventListener("load",()=>y("setup"))})();
1
+ (()=>{if(window.ui)return;let m=null,x=null,k=null,s={light:"",dark:""};const A=t=>new Promise(e=>setTimeout(e,t)),L=()=>"fxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)}),f=(t,e)=>{try{return typeof t=="string"?(e||document).querySelector(t):t}catch{}},u=(t,e)=>{try{return typeof t=="string"?(e||document).querySelectorAll(t):t}catch{}},i=(t,e)=>t?t.classList.contains(e):!1,d=(t,e)=>{!t||t.classList.add(e)},o=(t,e)=>{!t||t.classList.remove(e)},y=(t,e,r)=>{t.addEventListener(e,r,!0)},P=(t,e,r)=>{t.removeEventListener(e,r,!0)},N=(t,e)=>{if(!!e)return e.parentNode.insertBefore(t,e)},E=t=>{if(!!t)return t.previousElementSibling},S=t=>{if(!!t)return t.nextElementSibling},v=t=>{if(!!t)return t.parentElement},D=t=>{let e=document.createElement("div");for(let r in t)e[r]=t[r];return e},g=t=>{let e=t,r=v(t),n=f("label",r),a=i(r,"border")&&!i(r,"fill");if(document.activeElement==t||e.value||/date|time/.test(e.type)){if(a&&n){let l=i(n,"active")?n.offsetWidth:Math.round(n.offsetWidth/1.33),p=i(r,"round")?20:12,$=l+p+8;e.style.clipPath=`polygon(0% 0%, ${p}rem 0%, ${p}rem 8rem, ${$}rem 8rem, ${$}rem 0%, 100% 0%, 100% 100%, 0% 100%)`}else e.style.clipPath="";d(n,"active")}else o(n,"active"),e.style.clipPath="";t.getAttribute("data-ui")&&T(t)},M=t=>{let e=t.currentTarget;/input/i.test(e.tagName)||T(e)},q=t=>{let e=t.currentTarget,r=f("input:not([type=file]):not([type=checkbox]):not([type=radio]), select, textarea",v(e));r&&r.focus()},B=t=>{let e=t.currentTarget;g(e)},F=t=>{let e=t.currentTarget;g(e)},C=t=>{let e=t.currentTarget;u(".dropdown.active").forEach(n=>o(n,"active")),P(e,"click",C)},_=t=>{let e=t.currentTarget;o(e,"active"),m&&clearTimeout(m)},I=t=>{let e=t.currentTarget;w(e)},O=t=>{let e=t.currentTarget;w(e,t)},V=()=>{x&&clearTimeout(x),x=setTimeout(b,180)},w=(t,e)=>{if(e){if(e.key!=="Enter")return;let a=e.currentTarget,c=S(a);return!c||!/file/i.test(c.type)?void 0:c.click()}let r=t,n=E(t);!n||!/text/i.test(n.type)||(n.value=Array.from(r.files).map(a=>a.name).join(", "),n.readOnly=!0,n.addEventListener("keydown",O),g(n))},T=(t,e,r)=>{if(e||(e=f(t.getAttribute("data-ui"))),i(e,"modal"))return z(t,e);if(i(e,"dropdown"))return Z(t,e);if(i(e,"toast"))return K(t,e,r);if(i(e,"page"))return W(t,e);if(i(e,"progress"))return j(e,r);if(h(t),i(e,"active"))return o(e,"active");d(e,"active")},h=t=>{let e=v(t);if(!i(e,"tabs"))return;u("a",e).forEach(n=>o(n,"active")),d(t,"active")},W=(t,e)=>{h(t);let r=v(e);for(let n=0;n<r.children.length;n++)i(r.children[n],"page")&&o(r.children[n],"active");d(e,"active")},Z=(t,e)=>{if(h(t),i(e,"active"))return o(e,"active");u(".dropdown.active").forEach(n=>o(n,"active")),d(e,"active"),y(document.body,"click",C)},z=async(t,e)=>{h(t);let r=E(e);i(r,"overlay")||(r=D({className:"overlay"}),N(r,e),await A(90)),r.onclick=()=>{o(t,"active"),o(e,"active"),o(r,"active")};let n=i(e,"active"),a=v(e);/nav/i.test(a.tagName)&&u(".modal, a, .overlay",a).forEach(l=>o(l,"active")),n?(o(t,"active"),o(r,"active"),o(e,"active")):(!/button/i.test(t.tagName)&&!i(t,"button")&&!i(t,"chip")&&d(t,"active"),d(r,"active"),d(e,"active"))},K=(t,e,r)=>{h(t),u(".toast.active").forEach(a=>o(a,"active")),d(e,"active"),y(e,"click",_),m&&clearTimeout(m),!(r&&r==-1)&&(m=setTimeout(()=>{o(e,"active")},r&&r?r:6e3))},j=(t,e)=>{let r=t;if(i(r,"left"))return r.style.clipPath=`polygon(0% 0%, 0% 100%, ${e}% 100%, ${e}% 0%)`;if(i(r,"top"))return r.style.clipPath=`polygon(0% 0%, 100% 0%, 100% ${e}%, 0% ${e}%)`;if(i(r,"right"))return r.style.clipPath=`polygon(100% 0%, 100% 100%, ${100-e}% 100%, ${100-e}% 0%)`;if(i(r,"bottom"))return r.style.clipPath=`polygon(0% 100%, 100% 100%, 100% ${100-e}%, 0% ${100-e}%)`},G=()=>{if(s.light&&s.dark)return s;let t=document.createElement("body");t.className="light",document.body.appendChild(t);let e=document.createElement("body");e.className="dark",document.body.appendChild(e);let r=getComputedStyle(t),n=getComputedStyle(e),a=["--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","--outline","--surface-variant","--on-surface-variant","--inverse-surface","--inverse-on-surface"];for(let c=0;c<a.length;c++)s.light+=a[c]+":"+r.getPropertyValue(a[c])+";",s.dark+=a[c]+":"+n.getPropertyValue(a[c])+";";return document.body.removeChild(t),document.body.removeChild(e),s},H=t=>{if(!t||!window.materialDynamicColors)return G();let e=/dark/i.test(document.body.className)?"dark":"light";return t&&t.light&&t.dark?(s.light=t.light,s.dark=t.dark,document.body.setAttribute("style",t[e]),t):window.materialDynamicColors(t).then(r=>{const n=a=>{let c="";for(let l in a){let p=l.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase();c+="--"+p+":"+a[l]+";"}return c};return s.light=n(r.light),s.dark=n(r.dark),document.body.setAttribute("style",s[e]),s})},J=t=>t?(document.body.classList.remove("light","dark"),document.body.classList.add(t),window.materialDynamicColors&&document.body.setAttribute("style",s[t]),t):/dark/i.test(document.body.className)?"dark":"light",Q=()=>{k||(k=new MutationObserver(V),k.observe(document.body,{childList:!0,subtree:!0}),b())},b=(t,e)=>{if(t){if(t=="setup")return Q();if(t=="guid")return L();if(t=="mode")return J(e);if(t=="theme")return H(e);let l=f(t),p=f("[data-ui='#"+l.id+"']");T(p,l,e)}u("[data-ui]").forEach(l=>y(l,"click",M)),u(".field > label").forEach(l=>y(l,"click",q)),u(".field > input:not([type=file]):not([type=checkbox]):not([type=radio]), .field > select, .field > textarea").forEach(l=>{y(l,"focus",B),y(l,"blur",F),g(l)}),u(".field > input[type=file]").forEach(l=>{y(l,"change",I),w(l)})};window.ui=b,window.addEventListener("load",()=>b("setup"))})();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Everton and Leonardo",
3
3
  "description": "Build material design interfaces in record time... without stress for devs.",
4
4
  "homepage": "https://www.beercss.com/",
5
- "version": "2.2.1",
5
+ "version": "2.2.2",
6
6
  "name": "beercss",
7
7
  "license": "MIT",
8
8
  "type": "module",
package/src/cdn/beer.ts CHANGED
@@ -14,6 +14,10 @@
14
14
  dark: ""
15
15
  }
16
16
 
17
+ const wait = (milliseconds:number) => {
18
+ return new Promise((resolve) => setTimeout(resolve, milliseconds));
19
+ }
20
+
17
21
  const guid = ():string => {
18
22
  return "fxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c:string) => {
19
23
  let r = (Math.random() * 16) | 0,
@@ -232,13 +236,14 @@
232
236
  on(document.body, "click", onClickDocument);
233
237
  }
234
238
 
235
- const modal = (from:Element, to:Element) => {
239
+ const modal = async (from:Element, to:Element) => {
236
240
  tab(from);
237
241
 
238
242
  let overlay = prev(to) as HTMLElement;
239
243
  if (!hasClass(overlay, "overlay")) {
240
- overlay = create({ className: "overlay active" });
244
+ overlay = create({ className: "overlay" });
241
245
  insertBefore(overlay, to);
246
+ await wait(90);
242
247
  }
243
248
 
244
249
  overlay.onclick = () => {