effcss 3.0.3 → 3.1.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/LICENSE CHANGED
@@ -198,54 +198,4 @@
198
198
  distributed under the License is distributed on an "AS IS" BASIS,
199
199
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
200
  See the License for the specific language governing permissions and
201
- limitations under the License.
202
-
203
- ## Some of TensorFlow's code is derived from Caffe, which is subject to the following copyright notice:
204
-
205
- COPYRIGHT
206
-
207
- All contributions by the University of California:
208
-
209
- Copyright (c) 2014, The Regents of the University of California (Regents)
210
- All rights reserved.
211
-
212
- All other contributions:
213
-
214
- Copyright (c) 2014, the respective contributors
215
- All rights reserved.
216
-
217
- Caffe uses a shared copyright model: each contributor holds copyright over
218
- their contributions to Caffe. The project versioning records all such
219
- contribution and copyright details. If a contributor wants to further mark
220
- their specific copyright on a particular contribution, they should indicate
221
- their copyright solely in the commit message of the change when it is
222
- committed.
223
-
224
- LICENSE
225
-
226
- Redistribution and use in source and binary forms, with or without
227
- modification, are permitted provided that the following conditions are met:
228
-
229
- 1. Redistributions of source code must retain the above copyright notice, this
230
- list of conditions and the following disclaimer.
231
-
232
- 2. Redistributions in binary form must reproduce the above copyright notice,
233
- this list of conditions and the following disclaimer in the documentation
234
- and/or other materials provided with the distribution.
235
-
236
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
237
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
238
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
239
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
240
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
241
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
242
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
243
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
244
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
245
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
246
-
247
- CONTRIBUTION AGREEMENT
248
-
249
- By contributing to the BVLC/caffe repository through pull-request, comment,
250
- or otherwise, the contributor releases their content to the
251
- license and copyright terms herein.
201
+ limitations under the License.
package/README.md CHANGED
@@ -31,7 +31,7 @@ EffCSS is a self-confident CSS-in-JS library based only on the browser APIs. Use
31
31
  - [Repository](https://gitverse.ru/msabitov/effcss)
32
32
  - [Github mirror](https://github.com/msabitov/effcss)
33
33
 
34
- ## V3 examples
34
+ ## Examples
35
35
 
36
36
  - [Vanilla TS](https://stackblitz.com/edit/effcss-3-ts-vitejs?file=index.html)
37
37
  - [React](https://stackblitz.com/edit/effcss-3-react-vitejs?file=index.html)
@@ -66,9 +66,9 @@ First, define and add `Style provider` to your HTML:
66
66
  <!DOCTYPE html>
67
67
  <html lang="en">
68
68
  <head>
69
- <!-- the first script defines the style provider custom element -->
69
+ <!-- define the style provider custom element -->
70
70
  <script src="https://unpkg.com/effcss/dist/build/define-provider.min.js" crossorigin="anonymous"></script>
71
- <!-- the second script is the style provider itself -->
71
+ <!-- and create it -->
72
72
  <script is="effcss-provider"></script>
73
73
  </head>
74
74
  <body>
@@ -92,14 +92,13 @@ root.render(<App css={consumer} />);
92
92
 
93
93
  Each CSS stylesheet corresponds to a single `Stylesheet maker`. `Stylesheet maker` is a pure JS function that should return object with style rules:
94
94
 
95
- **App.js**
95
+ **App.tsx**
96
96
 
97
- ```jsx
97
+ ```tsx
98
98
  import { useRef } from 'react';
99
- import { TStyleSheetMaker } from 'effcss';
99
+ import { IStyleProvider, TStyleSheetMaker } from 'effcss';
100
100
 
101
101
  // describe your styles in BEM notation so that other people can use them
102
-
103
102
  export interface ICardMaker {
104
103
  /**
105
104
  * Card block
@@ -173,7 +172,9 @@ const myStyleSheetMaker: TStyleSheetMaker = ({ bem, pseudo, at: { kf }, merge })
173
172
  };
174
173
  };
175
174
 
176
- export const App = (props) => {
175
+ export const App = (props: {
176
+ css: IStyleProvider;
177
+ }) => {
177
178
  const { css } = props;
178
179
  const stylesRef = useRef();
179
180
  if (!stylesRef.current) {
@@ -194,7 +195,6 @@ export const App = (props) => {
194
195
  };
195
196
  }
196
197
  const styles = stylesRef.current;
197
-
198
198
  // just apply attributes to appropriate elements
199
199
  return (
200
200
  <div {...styles.card}>
@@ -1,7 +1,7 @@
1
1
  /*
2
- * EffCSS v3.0.3
2
+ * EffCSS v3.1.0
3
3
  * {@link https://gitverse.ru/msabitov/effcss}
4
4
  * Copyright (c) Marat Sabitov
5
- * @license Apache 2.0
5
+ * @license Apache-2.0
6
6
  */
7
- "function"==typeof SuppressedError&&SuppressedError;const t="@media",e="@container",s="@property",r="@keyframes",n="@layer",i="@scope",o="@supports",c=(e,s)=>{const r=t+` ${s||""}${s?" and ":""}(${e})`;return{s:r,q:e,t:s,toString:()=>r}};c.toString=()=>t;const a=t=>t+"px",l=t=>t+"vh",h=t=>t+"vw",u=t=>t+"rem",p=t=>t+"deg",d=t=>t+"ms",m=t=>t+"%",f=t=>t+"cqw",g=t=>t+"cqh",$=t=>t+"cqi",y=t=>t+"cqb",v=t=>t+"cqmin",b=t=>t+"cqmax",_=Object.fromEntries,k=Object.entries,x=":first-",S=":last-",j=":only-",w="child",q=":nth-",O="of-type",A=q+w,E=":focus",P={r:":root",h:":hover",f:E,fv:E+"-visible",a:":active",v:":visited",val:":valid",inv:":invalid",e:":empty",d:":disabled",rq:":required",o:":optional",m:":modal",l:":link",ph:":placeholder",ch:":checked",po:":popover-open",fc:x+w,lc:S+w,oc:j+w,odd:A+"(odd)",even:A+"(even)",ft:x+O,lt:S+O,ot:j+O,bef:"::before",aft:"::after",bd:"::backdrop"},C={has:":has",not:":not",is:":is",wh:":where",st:":state",nthc:A,ntho:q+O,dir:":dir",lang:":lang"},I="oklch",K=t=>I+`(${t})`,M=t=>K(`from ${t}`),W="def",B=t=>{const e=(e,s)=>"string"==typeof s?t(e,s):s;class s{constructor(t={}){this.state={l:e("l",W),c:e("c",W),h:e("h",W),a:e("a",W)},this.merge=t=>new s(Object.assign(this.state,t)),this.l=t=>this.merge({l:e("l",t)}),this.c=t=>this.merge({c:e("c",t)}),this.h=t=>this.merge({h:e("h",t)}),this.a=t=>this.merge({a:e("a",t)}),this.state=Object.assign(this.state,t)}get s(){return this.toString()}toString(){const{l:t,c:e,h:s,a:r}=this.state;return K(`${t} ${e} ${s} / ${r}`)}}return t=>new s(t)},L=(t,e=.1)=>M(`${t} calc(l + ${e}) c h / alpha)`),N=(t,e=.1)=>M(`${t} calc(l - ${e}) c h / alpha)`),R=(t,e=.1)=>M(`${t} l c h / calc(alpha + ${e}))`),z=(t,e=.1)=>M(`${t} l c h / calc(alpha - ${e}))`),H=(t,e=.04)=>M(`${t} l calc(c + ${e}) h / alpha)`),T=(t,e=.04)=>M(`${t} l calc(c - ${e}) h / alpha)`),V=(t,e=30)=>M(`${t} l c calc(h${"number"==typeof e?e>0?" + "+e:" - "+-e:e}) / alpha)`),Z=({base:t,mixin:e,method:s,bpart:r,mpart:n})=>`color-mix(in ${s||I}, ${t}${void 0!==r?` ${r}%`:""}, ${e}${void 0!==n?` ${n}%`:""})`,D=t=>({create:B(t),oklch:K,lighten:L,darken:N,saturate:H,desaturate:T,fadein:R,fadeout:z,spin:V,mix:Z}),F=Object.assign,G=Object.entries,J=Array.isArray,Q=(t,...e)=>e.length?e.reduce(((t,e)=>(G(e).forEach((([e,s])=>{s&&"object"==typeof s&&t[e]?J(t[e])&&J(s)?t[e]=[...t[e],...s]:Q(t[e],s||{}):t[e]=s})),t)),t):t,U=(t,e,s)=>Object.entries(t).reduce(e,s),X=(t,e,s)=>{var r,n,i;let o=""+t;return null==e?"":"object"==typeof e?(!s||(null===(r=s.startsWith)||void 0===r?void 0:r.call(s,"@"))||(null===(n=o.startsWith)||void 0===n?void 0:n.call(o,"&"))||(null===(i=o.startsWith)||void 0===i?void 0:i.call(o,"@"))?"":"&")+o+`{${U(e,((t,e)=>t+X(...e,o)),"")}}`:`${c=o,c.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))}:${""+e};`;var c},Y={dash:(...t)=>t.join("-"),comma:(...t)=>t.join(),space:(...t)=>t.join(" "),range:(t,e)=>Array.from(Array(t).entries()).reduce(((t,[s])=>F(t,e(s+1))),{}),each:(t,e)=>G(t).reduce(((t,[s,r])=>F(t,e(s,r))),{}),merge:Q,when:(t,e,s={})=>t?e:s},tt="width: ",et=t=>{const{scope:x,globalKey:S="",bp:j={}}=t,w=x(S),q=t=>w.varExp(...t.split("."));return{compile:({key:t,maker:S})=>{const O=x(t),A=(t=>{const a={cp:1,lay:1,kf:1,cq:1},l=(s,r)=>{const n="string"==typeof r?r:t.name("cq",a.cq++),i=e+` ${n?n+" ":""}(${s})`;return{c:n,q:s,s:i,toString:()=>i}};l.toString=()=>e;const h=(e,r)=>{const n="--"+(e||t.name("cp",a.cp++)),i=s+" "+n;return{k:n,v:`var(${n})`,s:i,r:{[i]:{syntax:(null==r?void 0:r.syn)||'"*"',inherits:(null==r?void 0:r.inh)||!1,initialValue:null==r?void 0:r.ini}},toString:()=>i}};h.toString=()=>s;const u=e=>{const s=e||t.name("kf",a.kf++),n=r+" "+s;return{k:s,s:n,toString:()=>n}};u.toString=()=>r;const p=e=>{const s=e||t.name("lay",a.lay++),r=n+" "+s;return{k:s,s:r,toString:()=>r}};p.toString=()=>n,p.toString=()=>i;const d=(t="",e=!1)=>{const s=o+` ${e?"not ":""}(${t})`;return{c:t,n:e,s:s,toString:()=>s}};return d.toString=()=>o,{pr:h,kf:u,mq:c,cq:l,lay:p,sc:(t="",e="")=>{const s=i+` ${t?`(${t})`:""}${t&&e?" ":""}${e?`to (${e})`:""}`;return{r:t,l:e,s:s,toString:()=>s}},sup:d}})(O),E=t=>{const e=j[t]||t;return"number"==typeof e?e+"rem":""},I=t=>"min-"+tt+E(t),K=t=>"max-"+tt+E(t),M=(t,e)=>"string"==typeof e?A.cq(t,e):A.mq(t),W=(t,e,s)=>""+M(I(t)+") and ("+K(e),s),B={up:(t,e)=>""+M(I(t),e),down:(t,e)=>""+M(K(t),e),between:W,only:(t,e)=>W(t,t,e)};return L=S(Object.assign(Y,{key:t,vars:q,bem:O.selector,pseudo:Object.assign(_(k(P).map((([t,e])=>{function s(t=""){return t+e}return s.toString=()=>e,[t,s]}))),_(k(C).map((([t,e])=>{function s(t,s=""){return s+e+`(${t})`}return s.toString=()=>e,[t,s]})))),color:D(w.varExp),units:{px:a,vh:l,vw:h,rem:u,deg:p,ms:d,pc:m,cqw:f,cqh:g,cqb:y,cqi:$,cqmin:v,cqmax:b},at:A,limit:B})),U(L,((t,e)=>t+X(...e)),"");var L}}};const st=void 0,rt=Object.entries,nt=Object.defineProperties,it=t=>`data-${t}`,ot=t=>"string"==typeof t,ct=t=>null!==t&&"object"==typeof t,at=(t,e)=>`${t}${e?"__"+e:""}`,lt=t=>t.split("."),ht=(t,e)=>rt(t).reduce(((t,[s,r])=>{if(ct(r)){const n=rt(r);n.length?t.push(...n.reduce(((t,[r,n])=>{if((t=>null!==t&&t!==st)(r)&&e&&t.push([s,r,st,st]),ct(n)){const e=rt(n);e.length&&t.push(...e.reduce(((t,[e,n])=>{const i=typeof n;return"string"!==i&&"number"!==i||t.push([s,r,e,n]),t}),[]))}return t}),[])):t.push([s,st,st,st])}return t}),[]),ut=(t,e,s,r)=>""+(at(t,e)+(s?"_"+s:"")+(s&&r?"_"+r:"")),pt=(t,e,s,r)=>"."+ut(t,e,s,r),dt=(t,e,s,r)=>`[${it(at(t,e))}${s&&r?`~="${s}_${r}"`:s?`~="${s}"`:""}]`,mt={def:.75,c:.05,s:.65,m:.75,l:.85,n:.9},ft="effcss-provider",gt={theme:null,hydrate:null,mode:"a",prefix:"f"},$t={bp:{"3xs":18,"2xs":24,xs:30,sm:40,md:48,lg:64,xl:80,"2xl":96},vars:{"":{rem:16,l:mt,h:{def:261.35,b:261.35,i:194.77,e:29.23,w:70.66,s:142.49},c:{def:.03,xs:.03,s:.06,m:.1,l:.15,xl:.25},a:{def:1,min:0,xs:.1,s:.25,m:.5,l:.75,xl:.9,max:1},t:{def:300,xs:100,s:200,m:300,l:450,xl:600,no:0,min:50,max:750},int:[...Array(12).keys()],fr:{0:0,"1/12":"0.0833","1/10":"0.1","1/6":"0.1667","1/5":"0.2","1/4":"0.25","3/10":"0.3","1/3":"0.3333","2/5":"0.4","5/12":"0.4167","1/2":"0.5","7/12":"0.5833","3/5":"0.6","2/3":"0.6667","7/10":"0.7","3/4":"0.75","4/5":"0.8","5/6":"0.8333","9/10":"0.9","11/12":"0.9167",1:"1"},ar:{1:1,"2/1":2,"1/2":.5,"4/3":1.3333,"3/4":.75,"9/16":.5625,"16/9":1.7778}},light:{l:mt},dark:{l:{def:.4,n:.25,s:.3,m:.4,l:.5,c:.95}}}},yt=({prefix:t})=>{let e=1;return{get base(){return t+0},get current(){return t+e},next(){return e++,this.current},reset(){e=1}}},vt=()=>{const t=new Set,e=new Map;return{use(s,r){const n=e.get(s);return n||(t.add(r),e.set(s,r),r)},useMany(t){return rt(t).map((([t,e])=>this.use(e,t)))},getKey:t=>e.get(t),get keys(){return[...t]},get makers(){return Object.fromEntries(e.entries().map((([t,e])=>[e,t])))}}},bt="theme",_t=Object.assign,kt=Object.entries,xt=Object.fromEntries,St=(t,e)=>t.getAttribute(e)||gt[e];!function(t={}){const e=window.document,s=window.customElements;if(null==s?void 0:s.get(ft))return!1;{class r extends HTMLScriptElement{constructor(){super(...arguments),this._c=vt(),this._m=function(){let t={},e={},s=[],r=[];const n=t=>t.adoptedStyleSheets=s,i=()=>{r=r.reduce(((t,e)=>{const s=e.deref();return s&&(n(s),t.push(e)),t}),[])},o=t=>s.findIndex((e=>e===t)),c=e=>e?t[e]:void 0,a=(e,r)=>{if(!t[e])return t[e]=r,s.push(r),i(),!0},l=t=>{const e=c(t);return!!e&&-1!==o(e)};return{apply:n,notify:i,getIndex:o,get:c,has:t=>!!t&&!!c(t),getAll:()=>t,add:a,status:l,on:(...t)=>{const e=t.reduce(((t,e)=>{const r=c(e);return!(!r||l(e))&&(s.push(r),t)}),!0);return i(),e},off:(...t)=>{const e=t.reduce(((t,e)=>{const r=c(e);if(r&&l(e)){const e=o(r);return s.splice(e,1),t}return!1}),!0);return i(),e},remove:r=>{const n=c(r);if(!n)return;const a=o(n);return a>-1&&(s.splice(a,1),delete t[r],delete e[r]),i(),!0},removeAll:()=>(s.splice(0),t={},e={},i(),!0),pack:(t,e)=>{const s=new CSSStyleSheet;return s.replaceSync(e),!!s.cssRules.length&&a(t,s)},replace:(e,s)=>{const r=t[e];if(r)return r.replaceSync(s),i(),!0},register:t=>{r.findIndex((e=>e.deref()===t))>=0||(r.push(new WeakRef(t)),n(t))},unregister:t=>{const e=r.findIndex((e=>e.deref()===t));e>=0&&r.splice(e,1)}}}(),this._cust=(t={})=>{const{varName:e}=this._s(this._k.base);function s(t,r){return kt(t).reduce(((t,[n,i])=>i&&"object"==typeof i?_t(t,s(i,[...r,n])):(t[e(...r,n)]=i,t)),{})}const r=xt(kt(t||{}).map((([t,e])=>[t,s(e,[])]))),{"":n={},dark:i,light:o}=r,c=function(t,e){var s={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(s[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(s[r[n]]=t[r[n]])}return s}(r,["","dark","light"]);this._=({bem:t,each:e,when:s,vars:r,merge:a,at:{mq:l}})=>{const h="prefers-color-scheme",u={light:`${h}: light`,dark:`${h}: dark`};return a({[`:root:has(script[is=${ft}])`]:a({fontSize:r("rem")},n)},s(!!i,{[l(u.dark).s]:i}),s(!!o,{[l(u.light).s]:o}),e(c,((e,s)=>({[`:root:has(script[is=${ft}][${bt}=${e}])`]:s,[t(`..theme.${e}`)]:s}))))},this.use(this._,this._k.base)},this.use=(t,e)=>{const s=e||this._k.current;let r=this._c.use(t,s);return this._m&&!this._m.has(e)&&this._m.pack(r,this.css(t,r)),e||this._k.next(),this.resolve(r)},this.usePublic=t=>xt(kt(t).map((([t,e])=>[t,this.use(e,t)]))),this.usePrivate=t=>t.map((t=>this.use(t))),this.resolve=t=>this._s(t||this._k.base).attr,this.css=(t,e)=>this._p.compile({key:e,maker:t}),this.status=t=>{const e=this.key(t);return!!e&&this._m.status(e)},this.on=(...t)=>this._m.on(...t.map(this.key)),this.off=(...t)=>this._m.off(...t.map(this.key)),this.key=t=>"string"==typeof t?t:this._c.getKey(t),this.stylesheets=(t=this._c.keys)=>t.map((t=>this._m.get(this.key(t))))}get prefix(){return St(this,"prefix")||""}get mode(){return St(this,"mode")}get hydrate(){return""===this.getAttribute("hydrate")}get settings(){return this._settings}set settings(t){var e,s,r;const n=_t({},this._settings,t),{makers:i,vars:o,bp:c,off:a}=n;c&&(null===(e=this._settings)||void 0===e?void 0:e.bp)!==c&&(this._p=et({scope:this._s,globalKey:this._k.base,bp:c})),o&&(null===(s=this._settings)||void 0===s?void 0:s.vars)!==o&&this._cust(o),i&&(null===(r=this._settings)||void 0===r?void 0:r.makers)!==i&&(this._c.useMany(i),this.usePublic(i),(null==a?void 0:a.length)&&this._settings.off!==a&&this.off(...a),this.hydrate&&this._k.reset()),this._settings=n}set theme(t){t?this.setAttribute(bt,t):this.removeAttribute(bt)}get theme(){return St(this,bt)||""}connectedCallback(){this._k=yt({prefix:this.prefix}),this._s=((t={})=>{const{mode:e}=t;let s,r;return t=>{const n=(...e)=>""+e.filter(Boolean).reduce(((t,e)=>`${t}-${e}`),t),i=(...t)=>"--"+n(...t);return"c"===e?(s=t=>{let e,s,r,i;return ot(t)?([e,s,r,i]=lt(t),pt(n(e),s,r,i)):t&&ht(t).map((([t,e,s,r])=>pt(n(t),e,s,r))).join(",")},r=t=>{let e,s,r,i;const o="class";let c="";return Array.isArray(t)?c=[...t.reduce(((t,o)=>([e,s,r,i]=lt(o),t.add(ut(n(e),s)),r&&t.add(ut(n(e),s,r,i)),t)),new Set).values()].join(" "):ot(t)?([e,s,r,i]=lt(t),c=ut(n(e),s,r,i)):c=t&&ht(t,!0).map((([t,e,s,r])=>ut(n(t),e,s,r))).join(" "),nt({[o]:c},{toString:{value:()=>`${o}="${c}"`}})}):(s=t=>{let e,s,r,i;return ot(t)?([e,s,r,i]=lt(t),dt(n(e),s,r,i)):t&&ht(t).map((([t,e,s,r])=>dt(n(t),e,s,r))).join(",")},r=t=>{let e,s,r,i,o,c,a="";if(Array.isArray(t))c=t.reduce(((t,c)=>{[e,s,r,i]=lt(c);const l=at(n(e),s);return o=it(l),a=r?i?`${r}_${i}`:`${r}`:"",t[o]&&a?t[o]=t[o]+" "+a:t[o]=a,t}),{});else if(ot(t)){[e,s,r,i]=lt(t);const l=at(n(e),s);o=it(l),a=r?i?`${r}_${i}`:`${r}`:"",c={[o]:a}}else c=t&&ht(t,!0).reduce(((t,[e,s,r,i])=>{const c=at(n(e),s);o=it(c);const l=r?i?`${r}_${i}`:`${r}`:"";return a=t[o]?t[o]+" "+l:l,t[o]=a,t}),{});return nt(c,{toString:{value:()=>rt(c).map((([t,e])=>`${t}="${e}"`)).join(" ")}}),c}),{selector:s,attr:r,name:n,varName:i,varExp:(...t)=>`var(${i(...t)})`}}})({mode:this.mode});const s=this;this._n={set adoptedStyleSheets(t){s.dispatchEvent(new CustomEvent("effcsschanges",{detail:{styles:t},bubbles:!0}))}},this._m.register(this._n),this._m.register(e),this.settings=_t({},$t,t)}toString(){return`<script ${[...this.attributes].map((t=>t.value?`${t.name}="${t.value}"`:""===t.value?t.name:"")).filter(Boolean).join(" ")}>${this.textContent}<\/script>`}}s.define(ft,r,{extends:"script"})}}();
7
+ "function"==typeof SuppressedError&&SuppressedError;const t="@media",e="@container",s="@property",r="@keyframes",n="@layer",i="@scope",o="@supports",c=(e,s)=>{const r=t+` ${s||""}${s?" and ":""}(${e})`;return{s:r,q:e,t:s,toString:()=>r}};c.toString=()=>t;const a=t=>t+"px",l=t=>t+"vh",h=t=>t+"vw",u=t=>t+"rem",d=t=>t+"deg",p=t=>t+"ms",m=t=>t+"%",f=t=>t+"cqw",g=t=>t+"cqh",$=t=>t+"cqi",v=t=>t+"cqb",y=t=>t+"cqmin",b=t=>t+"cqmax",_=Object.fromEntries,k=Object.entries,S=":first-",x=":last-",j=":only-",w="child",q=":nth-",O="of-type",A=q+w,E=":focus",P={r:":root",h:":hover",f:E,fv:E+"-visible",a:":active",v:":visited",val:":valid",inv:":invalid",e:":empty",d:":disabled",rq:":required",o:":optional",m:":modal",l:":link",ph:":placeholder",ch:":checked",po:":popover-open",fc:S+w,lc:x+w,oc:j+w,odd:A+"(odd)",even:A+"(even)",ft:S+O,lt:x+O,ot:j+O,bef:"::before",aft:"::after",bd:"::backdrop"},C={has:":has",not:":not",is:":is",wh:":where",st:":state",nthc:A,ntho:q+O,dir:":dir",lang:":lang"},I="oklch",W=t=>I+`(${t})`,K=t=>W(`from ${t}`),M="def",B=t=>{const e=(e,s)=>"string"==typeof s?t(e,s):s;class s{constructor(t={}){this.state={l:e("l",M),c:e("c",M),h:e("h",M),a:e("a",M)},this.merge=t=>new s(Object.assign(this.state,t)),this.l=t=>this.merge({l:e("l",t)}),this.c=t=>this.merge({c:e("c",t)}),this.h=t=>this.merge({h:e("h",t)}),this.a=t=>this.merge({a:e("a",t)}),this.state=Object.assign(this.state,t)}get s(){return this.toString()}toString(){const{l:t,c:e,h:s,a:r}=this.state;return W(`${t} ${e} ${s} / ${r}`)}}return t=>new s(t)},L=(t,e=.1)=>K(`${t} calc(l + ${e}) c h / alpha)`),N=(t,e=.1)=>K(`${t} calc(l - ${e}) c h / alpha)`),R=(t,e=.1)=>K(`${t} l c h / calc(alpha + ${e}))`),z=(t,e=.1)=>K(`${t} l c h / calc(alpha - ${e}))`),H=(t,e=.04)=>K(`${t} l calc(c + ${e}) h / alpha)`),T=(t,e=.04)=>K(`${t} l calc(c - ${e}) h / alpha)`),V=(t,e=30)=>K(`${t} l c calc(h${"number"==typeof e?e>0?" + "+e:" - "+-e:e}) / alpha)`),Z=({base:t,mixin:e,method:s,bpart:r,mpart:n})=>`color-mix(in ${s||I}, ${t}${void 0!==r?` ${r}%`:""}, ${e}${void 0!==n?` ${n}%`:""})`,D=t=>({create:B(t),oklch:W,lighten:L,darken:N,saturate:H,desaturate:T,fadein:R,fadeout:z,spin:V,mix:Z}),F=Object.assign,G=Object.entries,J=Array.isArray,Q=(t,...e)=>e.length?e.reduce(((t,e)=>(G(e).forEach((([e,s])=>{s&&"object"==typeof s&&t[e]?J(t[e])&&J(s)?t[e]=[...t[e],...s]:Q(t[e],s||{}):t[e]=s})),t)),t):t,U=(t,e,s)=>Object.entries(t).reduce(e,s),X=(t,e,s)=>{var r,n,i;let o=""+t;return null==e?"":"object"==typeof e?(!s||(null===(r=s.startsWith)||void 0===r?void 0:r.call(s,"@"))||(null===(n=o.startsWith)||void 0===n?void 0:n.call(o,"&"))||(null===(i=o.startsWith)||void 0===i?void 0:i.call(o,"@"))?"":"&")+o+`{${U(e,((t,e)=>t+X(...e,o)),"")}}`:`${c=o,c.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))}:${""+e};`;var c},Y={dash:(...t)=>t.join("-"),comma:(...t)=>t.join(),space:(...t)=>t.join(" "),range:(t,e)=>Array.from(Array(t).entries()).reduce(((t,[s])=>F(t,e(s+1))),{}),each:(t,e)=>G(t).reduce(((t,[s,r])=>F(t,e(s,r))),{}),merge:Q,when:(t,e,s={})=>t?e:s},tt="width: ",et=t=>{const{scope:S,globalKey:x="",bp:j={}}=t,w=S(x),q=t=>w.varExp(...t.split("."));return{compile:({key:t,maker:x})=>{const O=S(t),A=(t=>{const a={cp:1,lay:1,kf:1,cq:1},l=(s,r)=>{const n="string"==typeof r?r:t.name("cq",a.cq++),i=e+` ${n?n+" ":""}(${s})`;return{c:n,q:s,s:i,toString:()=>i}};l.toString=()=>e;const h=(e,r)=>{const n="--"+(e||t.name("cp",a.cp++)),i=s+" "+n;return{k:n,v:`var(${n})`,s:i,r:{[i]:{syntax:(null==r?void 0:r.syn)||'"*"',inherits:(null==r?void 0:r.inh)||!1,initialValue:null==r?void 0:r.ini}},toString:()=>i}};h.toString=()=>s;const u=e=>{const s=e||t.name("kf",a.kf++),n=r+" "+s;return{k:s,s:n,toString:()=>n}};u.toString=()=>r;const d=e=>{const s=e||t.name("lay",a.lay++),r=n+" "+s;return{k:s,s:r,toString:()=>r}};d.toString=()=>n,d.toString=()=>i;const p=(t="",e=!1)=>{const s=o+` ${e?"not ":""}(${t})`;return{c:t,n:e,s:s,toString:()=>s}};return p.toString=()=>o,{pr:h,kf:u,mq:c,cq:l,lay:d,sc:(t="",e="")=>{const s=i+` ${t?`(${t})`:""}${t&&e?" ":""}${e?`to (${e})`:""}`;return{r:t,l:e,s:s,toString:()=>s}},sup:p}})(O),E=t=>{const e=j[t]||t;return"number"==typeof e?e+"rem":""},I=t=>"min-"+tt+E(t),W=t=>"max-"+tt+E(t),K=(t,e)=>"string"==typeof e?A.cq(t,e):A.mq(t),M=(t,e,s)=>""+K(I(t)+") and ("+W(e),s),B={up:(t,e)=>""+K(I(t),e),down:(t,e)=>""+K(W(t),e),between:M,only:(t,e)=>M(t,t,e)};return L=x(Object.assign(Y,{key:t,vars:q,bem:O.selector,pseudo:Object.assign(_(k(P).map((([t,e])=>{function s(t=""){return t+e}return s.toString=()=>e,[t,s]}))),_(k(C).map((([t,e])=>{function s(t,s=""){return s+e+`(${t})`}return s.toString=()=>e,[t,s]})))),color:D(w.varExp),units:{px:a,vh:l,vw:h,rem:u,deg:d,ms:p,pc:m,cqw:f,cqh:g,cqb:v,cqi:$,cqmin:y,cqmax:b},at:A,limit:B})),U(L,((t,e)=>t+X(...e)),"");var L}}};const st=void 0,rt=Object.entries,nt=Object.defineProperties,it=t=>`data-${t}`,ot=t=>"string"==typeof t,ct=t=>null!==t&&"object"==typeof t,at=(t,e)=>`${t}${e?"__"+e:""}`,lt=t=>t.split("."),ht=(t,e)=>rt(t).reduce(((t,[s,r])=>{if(ct(r)){const n=rt(r);n.length?t.push(...n.reduce(((t,[r,n])=>{if((t=>null!==t&&t!==st)(r)&&e&&t.push([s,r,st,st]),ct(n)){const e=rt(n);e.length&&t.push(...e.reduce(((t,[e,n])=>{const i=typeof n;return"string"!==i&&"number"!==i||t.push([s,r,e,n]),t}),[]))}return t}),[])):t.push([s,st,st,st])}return t}),[]),ut=(t,e,s,r)=>""+(at(t,e)+(s?"_"+s:"")+(s&&r?"_"+r:"")),dt=(t,e,s,r)=>"."+ut(t,e,s,r),pt=(t,e,s,r)=>`[${it(at(t,e))}${s&&r?`~="${s}_${r}"`:s?`~="${s}"`:""}]`,mt={def:.75,c:.05,s:.65,m:.75,l:.85,n:.9},ft="effcss-provider",gt={theme:null,hydrate:null,mode:"a",prefix:"f"},$t={bp:{"3xs":18,"2xs":24,xs:30,sm:40,md:48,lg:64,xl:80,"2xl":96},vars:{"":{rem:16,l:mt,h:{def:261.35,b:261.35,i:194.77,e:29.23,w:70.66,s:142.49},c:{def:.03,xs:.03,s:.06,m:.1,l:.15,xl:.25},a:{def:1,min:0,xs:.1,s:.25,m:.5,l:.75,xl:.9,max:1},t:{def:300,xs:100,s:200,m:300,l:450,xl:600,no:0,min:50,max:750},int:[...Array(12).keys()],fr:{0:0,"1/12":"0.0833","1/10":"0.1","1/6":"0.1667","1/5":"0.2","1/4":"0.25","3/10":"0.3","1/3":"0.3333","2/5":"0.4","5/12":"0.4167","1/2":"0.5","7/12":"0.5833","3/5":"0.6","2/3":"0.6667","7/10":"0.7","3/4":"0.75","4/5":"0.8","5/6":"0.8333","9/10":"0.9","11/12":"0.9167",1:"1"},ar:{1:1,"2/1":2,"1/2":.5,"4/3":1.3333,"3/4":.75,"9/16":.5625,"16/9":1.7778}},light:{l:mt},dark:{l:{def:.4,n:.25,s:.3,m:.4,l:.5,c:.95}}}},vt=({prefix:t})=>{let e=1;return{get base(){return t+0},get current(){return t+e},next(){return e++,this.current},reset(){e=1}}},yt=()=>{const t=new Set,e=new Map;return{use(s,r){const n=e.get(s);return n||(t.add(r),e.set(s,r),r)},useMany(t){return rt(t).map((([t,e])=>this.use(e,t)))},getKey:t=>e.get(t),get keys(){return[...t]},get makers(){return Object.fromEntries(e.entries().map((([t,e])=>[e,t])))}}},bt="theme",_t=Object.assign,kt=Object.entries,St=Object.fromEntries,xt=(t,e)=>t.getAttribute(e)||gt[e];!function(t={}){const e=window.document,s=window.customElements;if(null==s?void 0:s.get(ft))return!1;{class r extends HTMLScriptElement{constructor(){super(...arguments),this._c=yt(),this._m=function(){let t={},e={},s=[],r=[];const n=(t,e)=>(e.toString=()=>"effcss-"+t,e),i=t=>{var e;return t.adoptedStyleSheets=[...(null===(e=t.adoptedStyleSheets)||void 0===e?void 0:e.length)?[...t.adoptedStyleSheets].filter((t=>!(t+"").startsWith("effcss-"))):[],...s]},o=()=>{r=r.reduce(((t,e)=>{const s=e.deref();return s&&(i(s),t.push(e)),t}),[])},c=t=>s.findIndex((e=>e===t)),a=e=>e?t[e]:void 0,l=(e,r)=>{if(!t[e])return t[e]=n(e,r),s.push(t[e]),o(),!0},h=t=>{const e=a(t);return!!e&&-1!==c(e)};return{apply:i,notify:o,getIndex:c,get:a,has:t=>!!t&&!!a(t),getAll:()=>t,add:l,status:h,on:(...t)=>{const e=t.reduce(((t,e)=>{const r=a(e);return!(!r||h(e))&&(s.push(r),t)}),!0);return o(),e},off:(...t)=>{const e=t.reduce(((t,e)=>{const r=a(e);if(r&&h(e)){const e=c(r);return s.splice(e,1),t}return!1}),!0);return o(),e},remove:r=>{const n=a(r);if(!n)return;const i=c(n);return i>-1&&(s.splice(i,1),delete t[r],delete e[r]),o(),!0},removeAll:()=>(s.splice(0),t={},e={},o(),!0),pack:(t,e)=>{let s=new CSSStyleSheet;return s.replaceSync(e),s=n(t,s),!!s.cssRules.length&&l(t,s)},replace:(e,s)=>{const r=t[e];if(r)return r.replaceSync(s),o(),!0},register:t=>{r.findIndex((e=>e.deref()===t))>=0||(r.push(new WeakRef(t)),i(t))},unregister:t=>{const e=r.findIndex((e=>e.deref()===t));e>=0&&r.splice(e,1)}}}(),this._cust=(t={})=>{const{varName:e}=this._s(this._k.base);function s(t,r){return kt(t).reduce(((t,[n,i])=>i&&"object"==typeof i?_t(t,s(i,[...r,n])):(t[e(...r,n)]=i,t)),{})}const r=St(kt(t||{}).map((([t,e])=>[t,s(e,[])]))),{"":n={},dark:i,light:o}=r,c=function(t,e){var s={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(s[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(s[r[n]]=t[r[n]])}return s}(r,["","dark","light"]);this._=({bem:t,each:e,when:s,vars:r,merge:a,at:{mq:l}})=>{const h="prefers-color-scheme",u={light:`${h}: light`,dark:`${h}: dark`};return a({[`:root:has(script[is=${ft}])`]:a({fontSize:r("rem")},n)},s(!!i,{[l(u.dark).s]:i}),s(!!o,{[l(u.light).s]:o}),e(c,((e,s)=>({[`:root:has(script[is=${ft}][${bt}=${e}])`]:s,[t(`..theme.${e}`)]:s}))))},this.use(this._,this._k.base)},this.use=(t,e)=>{const s=e||this._k.current;let r=this._c.use(t,s);return this._m&&!this._m.has(e)&&this._m.pack(r,this.css(t,r)),e||this._k.next(),this.resolve(r)},this.usePublic=t=>St(kt(t).map((([t,e])=>[t,this.use(e,t)]))),this.usePrivate=t=>t.map((t=>this.use(t))),this.resolve=t=>this._s(t||this._k.base).attr,this.css=(t,e)=>this._p.compile({key:e,maker:t}),this.status=t=>{const e=this.key(t);return!!e&&this._m.status(e)},this.on=(...t)=>this._m.on(...t.map(this.key)),this.off=(...t)=>this._m.off(...t.map(this.key)),this.key=t=>"string"==typeof t?t:this._c.getKey(t),this.stylesheets=(t=this._c.keys)=>t.map((t=>this._m.get(this.key(t))))}get prefix(){return xt(this,"prefix")||""}get mode(){return xt(this,"mode")}get hydrate(){return""===this.getAttribute("hydrate")}get settings(){return this._settings}set settings(t){var e,s,r;const n=_t({},this._settings,t),{makers:i,vars:o,bp:c,off:a}=n;c&&(null===(e=this._settings)||void 0===e?void 0:e.bp)!==c&&(this._p=et({scope:this._s,globalKey:this._k.base,bp:c})),o&&(null===(s=this._settings)||void 0===s?void 0:s.vars)!==o&&this._cust(o),i&&(null===(r=this._settings)||void 0===r?void 0:r.makers)!==i&&(this._c.useMany(i),this.usePublic(i),(null==a?void 0:a.length)&&this._settings.off!==a&&this.off(...a),this.hydrate&&this._k.reset()),this._settings=n}set theme(t){t?this.setAttribute(bt,t):this.removeAttribute(bt)}get theme(){return xt(this,bt)||""}connectedCallback(){this._k=vt({prefix:this.prefix}),this._s=((t={})=>{const{mode:e}=t;let s,r;return t=>{const n=(...e)=>""+e.filter(Boolean).reduce(((t,e)=>`${t}-${e}`),t),i=(...t)=>"--"+n(...t);return"c"===e?(s=t=>{let e,s,r,i;return ot(t)?([e,s,r,i]=lt(t),dt(n(e),s,r,i)):t&&ht(t).map((([t,e,s,r])=>dt(n(t),e,s,r))).join(",")},r=t=>{let e,s,r,i;const o="class";let c="";return Array.isArray(t)?c=[...t.reduce(((t,o)=>([e,s,r,i]=lt(o),t.add(ut(n(e),s)),r&&t.add(ut(n(e),s,r,i)),t)),new Set).values()].join(" "):ot(t)?([e,s,r,i]=lt(t),c=ut(n(e),s,r,i)):c=t&&ht(t,!0).map((([t,e,s,r])=>ut(n(t),e,s,r))).join(" "),nt({[o]:c},{toString:{value:()=>`${o}="${c}"`}})}):(s=t=>{let e,s,r,i;return ot(t)?([e,s,r,i]=lt(t),pt(n(e),s,r,i)):t&&ht(t).map((([t,e,s,r])=>pt(n(t),e,s,r))).join(",")},r=t=>{let e,s,r,i,o,c,a="";if(Array.isArray(t))c=t.reduce(((t,c)=>{[e,s,r,i]=lt(c);const l=at(n(e),s);return o=it(l),a=r?i?`${r}_${i}`:`${r}`:"",t[o]&&a?t[o]=t[o]+" "+a:t[o]=a,t}),{});else if(ot(t)){[e,s,r,i]=lt(t);const l=at(n(e),s);o=it(l),a=r?i?`${r}_${i}`:`${r}`:"",c={[o]:a}}else c=t&&ht(t,!0).reduce(((t,[e,s,r,i])=>{const c=at(n(e),s);o=it(c);const l=r?i?`${r}_${i}`:`${r}`:"";return a=t[o]?t[o]+" "+l:l,t[o]=a,t}),{});return nt(c,{toString:{value:()=>rt(c).map((([t,e])=>`${t}="${e}"`)).join(" ")}}),c}),{selector:s,attr:r,name:n,varName:i,varExp:(...t)=>`var(${i(...t)})`}}})({mode:this.mode});const s=this;this._n={set adoptedStyleSheets(t){s.dispatchEvent(new CustomEvent("effcsschanges",{detail:{styles:t},bubbles:!0}))}},this._m.register(this._n),this._m.register(e),this.settings=_t({},$t,t)}toString(){return`<script ${[...this.attributes].map((t=>t.value?`${t.name}="${t.value}"`:""===t.value?t.name:"")).filter(Boolean).join(" ")}>${this.textContent}<\/script>`}}s.define(ft,r,{extends:"script"})}}();
package/dist/consumer.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * EffCSS v3.0.3
2
+ * EffCSS v3.1.0
3
3
  * {@link https://gitverse.ru/msabitov/effcss}
4
4
  * Copyright (c) Marat Sabitov
5
- * @license Apache 2.0
5
+ * @license Apache-2.0
6
6
  */
7
7
  const e=void 0,t=Object.entries,r=Object.defineProperties,n=e=>`data-${e}`,s=e=>"string"==typeof e,u=e=>null!==e&&"object"==typeof e,o=(e,t)=>`${e}${t?"__"+t:""}`,i=e=>e.split("."),a=(r,n)=>t(r).reduce(((r,[s,o])=>{if(u(o)){const i=t(o);i.length?r.push(...i.reduce(((r,[o,i])=>{if((t=>null!==t&&t!==e)(o)&&n&&r.push([s,o,e,e]),u(i)){const e=t(i);e.length&&r.push(...e.reduce(((e,[t,r])=>{const n=typeof r;return"string"!==n&&"number"!==n||e.push([s,o,t,r]),e}),[]))}return r}),[])):r.push([s,e,e,e])}return r}),[]),c=(e,t,r,n)=>""+(o(e,t)+(r?"_"+r:"")+(r&&n?"_"+n:"")),l=(e,t,r,n)=>"."+c(e,t,r,n),d=(e,t,r,s)=>`[${n(o(e,t))}${r&&s?`~="${r}_${s}"`:r?`~="${r}"`:""}]`,p="effcss-provider",m={theme:null,hydrate:null,mode:"a",prefix:"f"};Array(12).keys();const $=({prefix:e})=>{let t=1;return{get base(){return e+0},get current(){return e+t},next(){return t++,this.current},reset(){t=1}}},f=()=>{const e=new Set,r=new Map;return{use(t,n){const s=r.get(t);return s||(e.add(n),r.set(t,n),n)},useMany(e){return t(e).map((([e,t])=>this.use(t,e)))},getKey:e=>r.get(e),get keys(){return[...e]},get makers(){return Object.fromEntries(r.entries().map((([e,t])=>[t,e])))}}},g=(e={})=>{var u;let g,h,y,b,v=null===(u=null===globalThis||void 0===globalThis?void 0:globalThis.document)||void 0===u?void 0:u.querySelector(`script[is=${p}]`);if(v)return v;({prefix:h,mode:y,hydrate:b,theme:g}=Object.assign({},m,e));const j=new Set,x=()=>h||m.prefix,S=()=>y||m.mode,k=()=>""===b,O=$({prefix:x()}),_=((e={})=>{const{mode:u}=e;let p,m;return e=>{const $=(...t)=>""+t.filter(Boolean).reduce(((e,t)=>`${e}-${t}`),e),f=(...e)=>"--"+$(...e);return"c"===u?(p=e=>{let t,r,n,u;return s(e)?([t,r,n,u]=i(e),l($(t),r,n,u)):e&&a(e).map((([e,t,r,n])=>l($(e),t,r,n))).join(",")},m=e=>{let t,n,u,o;const l="class";let d="";return Array.isArray(e)?d=[...e.reduce(((e,r)=>([t,n,u,o]=i(r),e.add(c($(t),n)),u&&e.add(c($(t),n,u,o)),e)),new Set).values()].join(" "):s(e)?([t,n,u,o]=i(e),d=c($(t),n,u,o)):d=e&&a(e,!0).map((([e,t,r,n])=>c($(e),t,r,n))).join(" "),r({[l]:d},{toString:{value:()=>`${l}="${d}"`}})}):(p=e=>{let t,r,n,u;return s(e)?([t,r,n,u]=i(e),d($(t),r,n,u)):e&&a(e).map((([e,t,r,n])=>d($(e),t,r,n))).join(",")},m=e=>{let u,c,l,d,p,m,f="";if(Array.isArray(e))m=e.reduce(((e,t)=>{[u,c,l,d]=i(t);const r=o($(u),c);return p=n(r),f=l?d?`${l}_${d}`:`${l}`:"",e[p]&&f?e[p]=e[p]+" "+f:e[p]=f,e}),{});else if(s(e)){[u,c,l,d]=i(e);const t=o($(u),c);p=n(t),f=l?d?`${l}_${d}`:`${l}`:"",m={[p]:f}}else m=e&&a(e,!0).reduce(((e,[t,r,s,u])=>{const i=o($(t),r);p=n(i);const a=s?u?`${s}_${u}`:`${s}`:"";return f=e[p]?e[p]+" "+a:a,e[p]=f,e}),{});return r(m,{toString:{value:()=>t(m).map((([e,t])=>`${e}="${t}"`)).join(" ")}}),m}),{selector:p,attr:m,name:$,varName:f,varExp:(...e)=>`var(${f(...e)})`}}})({mode:S()}),A=f(),w=e=>"string"==typeof e?e:A.getKey(e),E=e=>_(e||O.base).attr,P=(e,t)=>{const r=t||O.current;let n=A.use(e,r);return t||O.next(),E(n)};return{get prefix(){return x()},get mode(){return S()},get hydrate(){return k()},set theme(e){g=e},get theme(){return g||""},get settings(){return{bp:undefined,vars:undefined,off:[...j],makers:A.makers}},set settings(e){},resolve:E,use:P,usePublic:e=>Object.fromEntries(Object.entries(e).map((([e,t])=>[e,P(t,e)]))),usePrivate:e=>e.map((e=>P(e))),css:()=>"",key:w,status:e=>{const t=w(e);return!!t&&!j.has(t)},on:(...e)=>e.map(w).reduce(((e,t)=>e&&!!t&&j.delete(t)),!0),off:(...e)=>e.map(w).reduce(((e,t)=>e&&!!t&&!!j.add(t)),!0),stylesheets:()=>[],toString(){const e=A.makers;delete e[O.base];const t=Object.entries({is:p,prefix:x(),mode:S(),hydrate:k(),theme:g}).map((([e,t])=>t?`${e}="${t}"`:""===t?e:"")).filter(Boolean).join(" "),r=`document.currentScript.settings = {makers: {${e?Object.entries(e).reduce(((e,[t,r])=>e+`${e?",":""}${t}: ${r.toString().replaceAll(/\s+/g," ")}`),""):""}},${j.size?` off: [${[...j]}]`:""}}`;return`<script ${t}>${r}<\/script>`}}};export{g as createConsumer};
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * EffCSS v3.0.3
2
+ * EffCSS v3.1.0
3
3
  * {@link https://gitverse.ru/msabitov/effcss}
4
4
  * Copyright (c) Marat Sabitov
5
- * @license Apache 2.0
5
+ * @license Apache-2.0
6
6
  */
7
- "function"==typeof SuppressedError&&SuppressedError;const t="@media",e="@container",s="@property",r="@keyframes",n="@layer",i="@scope",o="@supports",c=(e,s)=>{const r=t+` ${s||""}${s?" and ":""}(${e})`;return{s:r,q:e,t:s,toString:()=>r}};c.toString=()=>t;const a=t=>t+"px",l=t=>t+"vh",h=t=>t+"vw",u=t=>t+"rem",p=t=>t+"deg",d=t=>t+"ms",m=t=>t+"%",f=t=>t+"cqw",g=t=>t+"cqh",$=t=>t+"cqi",y=t=>t+"cqb",v=t=>t+"cqmin",b=t=>t+"cqmax",_=Object.fromEntries,k=Object.entries,x=":first-",S=":last-",j=":only-",w="child",q=":nth-",O="of-type",A=q+w,E=":focus",P={r:":root",h:":hover",f:E,fv:E+"-visible",a:":active",v:":visited",val:":valid",inv:":invalid",e:":empty",d:":disabled",rq:":required",o:":optional",m:":modal",l:":link",ph:":placeholder",ch:":checked",po:":popover-open",fc:x+w,lc:S+w,oc:j+w,odd:A+"(odd)",even:A+"(even)",ft:x+O,lt:S+O,ot:j+O,bef:"::before",aft:"::after",bd:"::backdrop"},C={has:":has",not:":not",is:":is",wh:":where",st:":state",nthc:A,ntho:q+O,dir:":dir",lang:":lang"},I="oklch",K=t=>I+`(${t})`,M=t=>K(`from ${t}`),W="def",B=t=>{const e=(e,s)=>"string"==typeof s?t(e,s):s;class s{constructor(t={}){this.state={l:e("l",W),c:e("c",W),h:e("h",W),a:e("a",W)},this.merge=t=>new s(Object.assign(this.state,t)),this.l=t=>this.merge({l:e("l",t)}),this.c=t=>this.merge({c:e("c",t)}),this.h=t=>this.merge({h:e("h",t)}),this.a=t=>this.merge({a:e("a",t)}),this.state=Object.assign(this.state,t)}get s(){return this.toString()}toString(){const{l:t,c:e,h:s,a:r}=this.state;return K(`${t} ${e} ${s} / ${r}`)}}return t=>new s(t)},L=(t,e=.1)=>M(`${t} calc(l + ${e}) c h / alpha)`),N=(t,e=.1)=>M(`${t} calc(l - ${e}) c h / alpha)`),R=(t,e=.1)=>M(`${t} l c h / calc(alpha + ${e}))`),z=(t,e=.1)=>M(`${t} l c h / calc(alpha - ${e}))`),H=(t,e=.04)=>M(`${t} l calc(c + ${e}) h / alpha)`),T=(t,e=.04)=>M(`${t} l calc(c - ${e}) h / alpha)`),V=(t,e=30)=>M(`${t} l c calc(h${"number"==typeof e?e>0?" + "+e:" - "+-e:e}) / alpha)`),Z=({base:t,mixin:e,method:s,bpart:r,mpart:n})=>`color-mix(in ${s||I}, ${t}${void 0!==r?` ${r}%`:""}, ${e}${void 0!==n?` ${n}%`:""})`,D=t=>({create:B(t),oklch:K,lighten:L,darken:N,saturate:H,desaturate:T,fadein:R,fadeout:z,spin:V,mix:Z}),F=Object.assign,G=Object.entries,J=Array.isArray,Q=(t,...e)=>e.length?e.reduce(((t,e)=>(G(e).forEach((([e,s])=>{s&&"object"==typeof s&&t[e]?J(t[e])&&J(s)?t[e]=[...t[e],...s]:Q(t[e],s||{}):t[e]=s})),t)),t):t,U=(t,e,s)=>Object.entries(t).reduce(e,s),X=(t,e,s)=>{var r,n,i;let o=""+t;return null==e?"":"object"==typeof e?(!s||(null===(r=s.startsWith)||void 0===r?void 0:r.call(s,"@"))||(null===(n=o.startsWith)||void 0===n?void 0:n.call(o,"&"))||(null===(i=o.startsWith)||void 0===i?void 0:i.call(o,"@"))?"":"&")+o+`{${U(e,((t,e)=>t+X(...e,o)),"")}}`:`${c=o,c.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))}:${""+e};`;var c},Y={dash:(...t)=>t.join("-"),comma:(...t)=>t.join(),space:(...t)=>t.join(" "),range:(t,e)=>Array.from(Array(t).entries()).reduce(((t,[s])=>F(t,e(s+1))),{}),each:(t,e)=>G(t).reduce(((t,[s,r])=>F(t,e(s,r))),{}),merge:Q,when:(t,e,s={})=>t?e:s},tt="width: ",et=t=>{const{scope:x,globalKey:S="",bp:j={}}=t,w=x(S),q=t=>w.varExp(...t.split("."));return{compile:({key:t,maker:S})=>{const O=x(t),A=(t=>{const a={cp:1,lay:1,kf:1,cq:1},l=(s,r)=>{const n="string"==typeof r?r:t.name("cq",a.cq++),i=e+` ${n?n+" ":""}(${s})`;return{c:n,q:s,s:i,toString:()=>i}};l.toString=()=>e;const h=(e,r)=>{const n="--"+(e||t.name("cp",a.cp++)),i=s+" "+n;return{k:n,v:`var(${n})`,s:i,r:{[i]:{syntax:(null==r?void 0:r.syn)||'"*"',inherits:(null==r?void 0:r.inh)||!1,initialValue:null==r?void 0:r.ini}},toString:()=>i}};h.toString=()=>s;const u=e=>{const s=e||t.name("kf",a.kf++),n=r+" "+s;return{k:s,s:n,toString:()=>n}};u.toString=()=>r;const p=e=>{const s=e||t.name("lay",a.lay++),r=n+" "+s;return{k:s,s:r,toString:()=>r}};p.toString=()=>n,p.toString=()=>i;const d=(t="",e=!1)=>{const s=o+` ${e?"not ":""}(${t})`;return{c:t,n:e,s:s,toString:()=>s}};return d.toString=()=>o,{pr:h,kf:u,mq:c,cq:l,lay:p,sc:(t="",e="")=>{const s=i+` ${t?`(${t})`:""}${t&&e?" ":""}${e?`to (${e})`:""}`;return{r:t,l:e,s:s,toString:()=>s}},sup:d}})(O),E=t=>{const e=j[t]||t;return"number"==typeof e?e+"rem":""},I=t=>"min-"+tt+E(t),K=t=>"max-"+tt+E(t),M=(t,e)=>"string"==typeof e?A.cq(t,e):A.mq(t),W=(t,e,s)=>""+M(I(t)+") and ("+K(e),s),B={up:(t,e)=>""+M(I(t),e),down:(t,e)=>""+M(K(t),e),between:W,only:(t,e)=>W(t,t,e)};return L=S(Object.assign(Y,{key:t,vars:q,bem:O.selector,pseudo:Object.assign(_(k(P).map((([t,e])=>{function s(t=""){return t+e}return s.toString=()=>e,[t,s]}))),_(k(C).map((([t,e])=>{function s(t,s=""){return s+e+`(${t})`}return s.toString=()=>e,[t,s]})))),color:D(w.varExp),units:{px:a,vh:l,vw:h,rem:u,deg:p,ms:d,pc:m,cqw:f,cqh:g,cqb:y,cqi:$,cqmin:v,cqmax:b},at:A,limit:B})),U(L,((t,e)=>t+X(...e)),"");var L}}};const st=void 0,rt=Object.entries,nt=Object.defineProperties,it=t=>`data-${t}`,ot=t=>"string"==typeof t,ct=t=>null!==t&&"object"==typeof t,at=(t,e)=>`${t}${e?"__"+e:""}`,lt=t=>t.split("."),ht=(t,e)=>rt(t).reduce(((t,[s,r])=>{if(ct(r)){const n=rt(r);n.length?t.push(...n.reduce(((t,[r,n])=>{if((t=>null!==t&&t!==st)(r)&&e&&t.push([s,r,st,st]),ct(n)){const e=rt(n);e.length&&t.push(...e.reduce(((t,[e,n])=>{const i=typeof n;return"string"!==i&&"number"!==i||t.push([s,r,e,n]),t}),[]))}return t}),[])):t.push([s,st,st,st])}return t}),[]),ut=(t,e,s,r)=>""+(at(t,e)+(s?"_"+s:"")+(s&&r?"_"+r:"")),pt=(t,e,s,r)=>"."+ut(t,e,s,r),dt=(t,e,s,r)=>`[${it(at(t,e))}${s&&r?`~="${s}_${r}"`:s?`~="${s}"`:""}]`,mt={def:.75,c:.05,s:.65,m:.75,l:.85,n:.9},ft="effcss-provider",gt={theme:null,hydrate:null,mode:"a",prefix:"f"},$t={bp:{"3xs":18,"2xs":24,xs:30,sm:40,md:48,lg:64,xl:80,"2xl":96},vars:{"":{rem:16,l:mt,h:{def:261.35,b:261.35,i:194.77,e:29.23,w:70.66,s:142.49},c:{def:.03,xs:.03,s:.06,m:.1,l:.15,xl:.25},a:{def:1,min:0,xs:.1,s:.25,m:.5,l:.75,xl:.9,max:1},t:{def:300,xs:100,s:200,m:300,l:450,xl:600,no:0,min:50,max:750},int:[...Array(12).keys()],fr:{0:0,"1/12":"0.0833","1/10":"0.1","1/6":"0.1667","1/5":"0.2","1/4":"0.25","3/10":"0.3","1/3":"0.3333","2/5":"0.4","5/12":"0.4167","1/2":"0.5","7/12":"0.5833","3/5":"0.6","2/3":"0.6667","7/10":"0.7","3/4":"0.75","4/5":"0.8","5/6":"0.8333","9/10":"0.9","11/12":"0.9167",1:"1"},ar:{1:1,"2/1":2,"1/2":.5,"4/3":1.3333,"3/4":.75,"9/16":.5625,"16/9":1.7778}},light:{l:mt},dark:{l:{def:.4,n:.25,s:.3,m:.4,l:.5,c:.95}}}},yt=({prefix:t})=>{let e=1;return{get base(){return t+0},get current(){return t+e},next(){return e++,this.current},reset(){e=1}}},vt=()=>{const t=new Set,e=new Map;return{use(s,r){const n=e.get(s);return n||(t.add(r),e.set(s,r),r)},useMany(t){return rt(t).map((([t,e])=>this.use(e,t)))},getKey:t=>e.get(t),get keys(){return[...t]},get makers(){return Object.fromEntries(e.entries().map((([t,e])=>[e,t])))}}},bt="theme",_t=Object.assign,kt=Object.entries,xt=Object.fromEntries,St=(t,e)=>t.getAttribute(e)||gt[e];function jt(t={}){const e=window.document,s=window.customElements;if(null==s?void 0:s.get(ft))return!1;{class r extends HTMLScriptElement{constructor(){super(...arguments),this._c=vt(),this._m=function(){let t={},e={},s=[],r=[];const n=t=>t.adoptedStyleSheets=s,i=()=>{r=r.reduce(((t,e)=>{const s=e.deref();return s&&(n(s),t.push(e)),t}),[])},o=t=>s.findIndex((e=>e===t)),c=e=>e?t[e]:void 0,a=(e,r)=>{if(!t[e])return t[e]=r,s.push(r),i(),!0},l=t=>{const e=c(t);return!!e&&-1!==o(e)};return{apply:n,notify:i,getIndex:o,get:c,has:t=>!!t&&!!c(t),getAll:()=>t,add:a,status:l,on:(...t)=>{const e=t.reduce(((t,e)=>{const r=c(e);return!(!r||l(e))&&(s.push(r),t)}),!0);return i(),e},off:(...t)=>{const e=t.reduce(((t,e)=>{const r=c(e);if(r&&l(e)){const e=o(r);return s.splice(e,1),t}return!1}),!0);return i(),e},remove:r=>{const n=c(r);if(!n)return;const a=o(n);return a>-1&&(s.splice(a,1),delete t[r],delete e[r]),i(),!0},removeAll:()=>(s.splice(0),t={},e={},i(),!0),pack:(t,e)=>{const s=new CSSStyleSheet;return s.replaceSync(e),!!s.cssRules.length&&a(t,s)},replace:(e,s)=>{const r=t[e];if(r)return r.replaceSync(s),i(),!0},register:t=>{r.findIndex((e=>e.deref()===t))>=0||(r.push(new WeakRef(t)),n(t))},unregister:t=>{const e=r.findIndex((e=>e.deref()===t));e>=0&&r.splice(e,1)}}}(),this._cust=(t={})=>{const{varName:e}=this._s(this._k.base);function s(t,r){return kt(t).reduce(((t,[n,i])=>i&&"object"==typeof i?_t(t,s(i,[...r,n])):(t[e(...r,n)]=i,t)),{})}const r=xt(kt(t||{}).map((([t,e])=>[t,s(e,[])]))),{"":n={},dark:i,light:o}=r,c=function(t,e){var s={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(s[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(s[r[n]]=t[r[n]])}return s}(r,["","dark","light"]);this._=({bem:t,each:e,when:s,vars:r,merge:a,at:{mq:l}})=>{const h="prefers-color-scheme",u={light:`${h}: light`,dark:`${h}: dark`};return a({[`:root:has(script[is=${ft}])`]:a({fontSize:r("rem")},n)},s(!!i,{[l(u.dark).s]:i}),s(!!o,{[l(u.light).s]:o}),e(c,((e,s)=>({[`:root:has(script[is=${ft}][${bt}=${e}])`]:s,[t(`..theme.${e}`)]:s}))))},this.use(this._,this._k.base)},this.use=(t,e)=>{const s=e||this._k.current;let r=this._c.use(t,s);return this._m&&!this._m.has(e)&&this._m.pack(r,this.css(t,r)),e||this._k.next(),this.resolve(r)},this.usePublic=t=>xt(kt(t).map((([t,e])=>[t,this.use(e,t)]))),this.usePrivate=t=>t.map((t=>this.use(t))),this.resolve=t=>this._s(t||this._k.base).attr,this.css=(t,e)=>this._p.compile({key:e,maker:t}),this.status=t=>{const e=this.key(t);return!!e&&this._m.status(e)},this.on=(...t)=>this._m.on(...t.map(this.key)),this.off=(...t)=>this._m.off(...t.map(this.key)),this.key=t=>"string"==typeof t?t:this._c.getKey(t),this.stylesheets=(t=this._c.keys)=>t.map((t=>this._m.get(this.key(t))))}get prefix(){return St(this,"prefix")||""}get mode(){return St(this,"mode")}get hydrate(){return""===this.getAttribute("hydrate")}get settings(){return this._settings}set settings(t){var e,s,r;const n=_t({},this._settings,t),{makers:i,vars:o,bp:c,off:a}=n;c&&(null===(e=this._settings)||void 0===e?void 0:e.bp)!==c&&(this._p=et({scope:this._s,globalKey:this._k.base,bp:c})),o&&(null===(s=this._settings)||void 0===s?void 0:s.vars)!==o&&this._cust(o),i&&(null===(r=this._settings)||void 0===r?void 0:r.makers)!==i&&(this._c.useMany(i),this.usePublic(i),(null==a?void 0:a.length)&&this._settings.off!==a&&this.off(...a),this.hydrate&&this._k.reset()),this._settings=n}set theme(t){t?this.setAttribute(bt,t):this.removeAttribute(bt)}get theme(){return St(this,bt)||""}connectedCallback(){this._k=yt({prefix:this.prefix}),this._s=((t={})=>{const{mode:e}=t;let s,r;return t=>{const n=(...e)=>""+e.filter(Boolean).reduce(((t,e)=>`${t}-${e}`),t),i=(...t)=>"--"+n(...t);return"c"===e?(s=t=>{let e,s,r,i;return ot(t)?([e,s,r,i]=lt(t),pt(n(e),s,r,i)):t&&ht(t).map((([t,e,s,r])=>pt(n(t),e,s,r))).join(",")},r=t=>{let e,s,r,i;const o="class";let c="";return Array.isArray(t)?c=[...t.reduce(((t,o)=>([e,s,r,i]=lt(o),t.add(ut(n(e),s)),r&&t.add(ut(n(e),s,r,i)),t)),new Set).values()].join(" "):ot(t)?([e,s,r,i]=lt(t),c=ut(n(e),s,r,i)):c=t&&ht(t,!0).map((([t,e,s,r])=>ut(n(t),e,s,r))).join(" "),nt({[o]:c},{toString:{value:()=>`${o}="${c}"`}})}):(s=t=>{let e,s,r,i;return ot(t)?([e,s,r,i]=lt(t),dt(n(e),s,r,i)):t&&ht(t).map((([t,e,s,r])=>dt(n(t),e,s,r))).join(",")},r=t=>{let e,s,r,i,o,c,a="";if(Array.isArray(t))c=t.reduce(((t,c)=>{[e,s,r,i]=lt(c);const l=at(n(e),s);return o=it(l),a=r?i?`${r}_${i}`:`${r}`:"",t[o]&&a?t[o]=t[o]+" "+a:t[o]=a,t}),{});else if(ot(t)){[e,s,r,i]=lt(t);const l=at(n(e),s);o=it(l),a=r?i?`${r}_${i}`:`${r}`:"",c={[o]:a}}else c=t&&ht(t,!0).reduce(((t,[e,s,r,i])=>{const c=at(n(e),s);o=it(c);const l=r?i?`${r}_${i}`:`${r}`:"";return a=t[o]?t[o]+" "+l:l,t[o]=a,t}),{});return nt(c,{toString:{value:()=>rt(c).map((([t,e])=>`${t}="${e}"`)).join(" ")}}),c}),{selector:s,attr:r,name:n,varName:i,varExp:(...t)=>`var(${i(...t)})`}}})({mode:this.mode});const s=this;this._n={set adoptedStyleSheets(t){s.dispatchEvent(new CustomEvent("effcsschanges",{detail:{styles:t},bubbles:!0}))}},this._m.register(this._n),this._m.register(e),this.settings=_t({},$t,t)}toString(){return`<script ${[...this.attributes].map((t=>t.value?`${t.name}="${t.value}"`:""===t.value?t.name:"")).filter(Boolean).join(" ")}>${this.textContent}<\/script>`}}return s.define(ft,r,{extends:"script"}),!0}}export{jt as defineProvider};
7
+ "function"==typeof SuppressedError&&SuppressedError;const t="@media",e="@container",s="@property",r="@keyframes",n="@layer",i="@scope",o="@supports",c=(e,s)=>{const r=t+` ${s||""}${s?" and ":""}(${e})`;return{s:r,q:e,t:s,toString:()=>r}};c.toString=()=>t;const a=t=>t+"px",l=t=>t+"vh",h=t=>t+"vw",u=t=>t+"rem",d=t=>t+"deg",p=t=>t+"ms",m=t=>t+"%",f=t=>t+"cqw",g=t=>t+"cqh",$=t=>t+"cqi",v=t=>t+"cqb",y=t=>t+"cqmin",b=t=>t+"cqmax",_=Object.fromEntries,k=Object.entries,S=":first-",x=":last-",j=":only-",w="child",q=":nth-",O="of-type",A=q+w,E=":focus",P={r:":root",h:":hover",f:E,fv:E+"-visible",a:":active",v:":visited",val:":valid",inv:":invalid",e:":empty",d:":disabled",rq:":required",o:":optional",m:":modal",l:":link",ph:":placeholder",ch:":checked",po:":popover-open",fc:S+w,lc:x+w,oc:j+w,odd:A+"(odd)",even:A+"(even)",ft:S+O,lt:x+O,ot:j+O,bef:"::before",aft:"::after",bd:"::backdrop"},C={has:":has",not:":not",is:":is",wh:":where",st:":state",nthc:A,ntho:q+O,dir:":dir",lang:":lang"},I="oklch",W=t=>I+`(${t})`,K=t=>W(`from ${t}`),M="def",B=t=>{const e=(e,s)=>"string"==typeof s?t(e,s):s;class s{constructor(t={}){this.state={l:e("l",M),c:e("c",M),h:e("h",M),a:e("a",M)},this.merge=t=>new s(Object.assign(this.state,t)),this.l=t=>this.merge({l:e("l",t)}),this.c=t=>this.merge({c:e("c",t)}),this.h=t=>this.merge({h:e("h",t)}),this.a=t=>this.merge({a:e("a",t)}),this.state=Object.assign(this.state,t)}get s(){return this.toString()}toString(){const{l:t,c:e,h:s,a:r}=this.state;return W(`${t} ${e} ${s} / ${r}`)}}return t=>new s(t)},L=(t,e=.1)=>K(`${t} calc(l + ${e}) c h / alpha)`),N=(t,e=.1)=>K(`${t} calc(l - ${e}) c h / alpha)`),R=(t,e=.1)=>K(`${t} l c h / calc(alpha + ${e}))`),z=(t,e=.1)=>K(`${t} l c h / calc(alpha - ${e}))`),H=(t,e=.04)=>K(`${t} l calc(c + ${e}) h / alpha)`),T=(t,e=.04)=>K(`${t} l calc(c - ${e}) h / alpha)`),V=(t,e=30)=>K(`${t} l c calc(h${"number"==typeof e?e>0?" + "+e:" - "+-e:e}) / alpha)`),Z=({base:t,mixin:e,method:s,bpart:r,mpart:n})=>`color-mix(in ${s||I}, ${t}${void 0!==r?` ${r}%`:""}, ${e}${void 0!==n?` ${n}%`:""})`,D=t=>({create:B(t),oklch:W,lighten:L,darken:N,saturate:H,desaturate:T,fadein:R,fadeout:z,spin:V,mix:Z}),F=Object.assign,G=Object.entries,J=Array.isArray,Q=(t,...e)=>e.length?e.reduce(((t,e)=>(G(e).forEach((([e,s])=>{s&&"object"==typeof s&&t[e]?J(t[e])&&J(s)?t[e]=[...t[e],...s]:Q(t[e],s||{}):t[e]=s})),t)),t):t,U=(t,e,s)=>Object.entries(t).reduce(e,s),X=(t,e,s)=>{var r,n,i;let o=""+t;return null==e?"":"object"==typeof e?(!s||(null===(r=s.startsWith)||void 0===r?void 0:r.call(s,"@"))||(null===(n=o.startsWith)||void 0===n?void 0:n.call(o,"&"))||(null===(i=o.startsWith)||void 0===i?void 0:i.call(o,"@"))?"":"&")+o+`{${U(e,((t,e)=>t+X(...e,o)),"")}}`:`${c=o,c.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))}:${""+e};`;var c},Y={dash:(...t)=>t.join("-"),comma:(...t)=>t.join(),space:(...t)=>t.join(" "),range:(t,e)=>Array.from(Array(t).entries()).reduce(((t,[s])=>F(t,e(s+1))),{}),each:(t,e)=>G(t).reduce(((t,[s,r])=>F(t,e(s,r))),{}),merge:Q,when:(t,e,s={})=>t?e:s},tt="width: ",et=t=>{const{scope:S,globalKey:x="",bp:j={}}=t,w=S(x),q=t=>w.varExp(...t.split("."));return{compile:({key:t,maker:x})=>{const O=S(t),A=(t=>{const a={cp:1,lay:1,kf:1,cq:1},l=(s,r)=>{const n="string"==typeof r?r:t.name("cq",a.cq++),i=e+` ${n?n+" ":""}(${s})`;return{c:n,q:s,s:i,toString:()=>i}};l.toString=()=>e;const h=(e,r)=>{const n="--"+(e||t.name("cp",a.cp++)),i=s+" "+n;return{k:n,v:`var(${n})`,s:i,r:{[i]:{syntax:(null==r?void 0:r.syn)||'"*"',inherits:(null==r?void 0:r.inh)||!1,initialValue:null==r?void 0:r.ini}},toString:()=>i}};h.toString=()=>s;const u=e=>{const s=e||t.name("kf",a.kf++),n=r+" "+s;return{k:s,s:n,toString:()=>n}};u.toString=()=>r;const d=e=>{const s=e||t.name("lay",a.lay++),r=n+" "+s;return{k:s,s:r,toString:()=>r}};d.toString=()=>n,d.toString=()=>i;const p=(t="",e=!1)=>{const s=o+` ${e?"not ":""}(${t})`;return{c:t,n:e,s:s,toString:()=>s}};return p.toString=()=>o,{pr:h,kf:u,mq:c,cq:l,lay:d,sc:(t="",e="")=>{const s=i+` ${t?`(${t})`:""}${t&&e?" ":""}${e?`to (${e})`:""}`;return{r:t,l:e,s:s,toString:()=>s}},sup:p}})(O),E=t=>{const e=j[t]||t;return"number"==typeof e?e+"rem":""},I=t=>"min-"+tt+E(t),W=t=>"max-"+tt+E(t),K=(t,e)=>"string"==typeof e?A.cq(t,e):A.mq(t),M=(t,e,s)=>""+K(I(t)+") and ("+W(e),s),B={up:(t,e)=>""+K(I(t),e),down:(t,e)=>""+K(W(t),e),between:M,only:(t,e)=>M(t,t,e)};return L=x(Object.assign(Y,{key:t,vars:q,bem:O.selector,pseudo:Object.assign(_(k(P).map((([t,e])=>{function s(t=""){return t+e}return s.toString=()=>e,[t,s]}))),_(k(C).map((([t,e])=>{function s(t,s=""){return s+e+`(${t})`}return s.toString=()=>e,[t,s]})))),color:D(w.varExp),units:{px:a,vh:l,vw:h,rem:u,deg:d,ms:p,pc:m,cqw:f,cqh:g,cqb:v,cqi:$,cqmin:y,cqmax:b},at:A,limit:B})),U(L,((t,e)=>t+X(...e)),"");var L}}};const st=void 0,rt=Object.entries,nt=Object.defineProperties,it=t=>`data-${t}`,ot=t=>"string"==typeof t,ct=t=>null!==t&&"object"==typeof t,at=(t,e)=>`${t}${e?"__"+e:""}`,lt=t=>t.split("."),ht=(t,e)=>rt(t).reduce(((t,[s,r])=>{if(ct(r)){const n=rt(r);n.length?t.push(...n.reduce(((t,[r,n])=>{if((t=>null!==t&&t!==st)(r)&&e&&t.push([s,r,st,st]),ct(n)){const e=rt(n);e.length&&t.push(...e.reduce(((t,[e,n])=>{const i=typeof n;return"string"!==i&&"number"!==i||t.push([s,r,e,n]),t}),[]))}return t}),[])):t.push([s,st,st,st])}return t}),[]),ut=(t,e,s,r)=>""+(at(t,e)+(s?"_"+s:"")+(s&&r?"_"+r:"")),dt=(t,e,s,r)=>"."+ut(t,e,s,r),pt=(t,e,s,r)=>`[${it(at(t,e))}${s&&r?`~="${s}_${r}"`:s?`~="${s}"`:""}]`,mt={def:.75,c:.05,s:.65,m:.75,l:.85,n:.9},ft="effcss-provider",gt={theme:null,hydrate:null,mode:"a",prefix:"f"},$t={bp:{"3xs":18,"2xs":24,xs:30,sm:40,md:48,lg:64,xl:80,"2xl":96},vars:{"":{rem:16,l:mt,h:{def:261.35,b:261.35,i:194.77,e:29.23,w:70.66,s:142.49},c:{def:.03,xs:.03,s:.06,m:.1,l:.15,xl:.25},a:{def:1,min:0,xs:.1,s:.25,m:.5,l:.75,xl:.9,max:1},t:{def:300,xs:100,s:200,m:300,l:450,xl:600,no:0,min:50,max:750},int:[...Array(12).keys()],fr:{0:0,"1/12":"0.0833","1/10":"0.1","1/6":"0.1667","1/5":"0.2","1/4":"0.25","3/10":"0.3","1/3":"0.3333","2/5":"0.4","5/12":"0.4167","1/2":"0.5","7/12":"0.5833","3/5":"0.6","2/3":"0.6667","7/10":"0.7","3/4":"0.75","4/5":"0.8","5/6":"0.8333","9/10":"0.9","11/12":"0.9167",1:"1"},ar:{1:1,"2/1":2,"1/2":.5,"4/3":1.3333,"3/4":.75,"9/16":.5625,"16/9":1.7778}},light:{l:mt},dark:{l:{def:.4,n:.25,s:.3,m:.4,l:.5,c:.95}}}},vt=({prefix:t})=>{let e=1;return{get base(){return t+0},get current(){return t+e},next(){return e++,this.current},reset(){e=1}}},yt=()=>{const t=new Set,e=new Map;return{use(s,r){const n=e.get(s);return n||(t.add(r),e.set(s,r),r)},useMany(t){return rt(t).map((([t,e])=>this.use(e,t)))},getKey:t=>e.get(t),get keys(){return[...t]},get makers(){return Object.fromEntries(e.entries().map((([t,e])=>[e,t])))}}},bt="theme",_t=Object.assign,kt=Object.entries,St=Object.fromEntries,xt=(t,e)=>t.getAttribute(e)||gt[e];function jt(t={}){const e=window.document,s=window.customElements;if(null==s?void 0:s.get(ft))return!1;{class r extends HTMLScriptElement{constructor(){super(...arguments),this._c=yt(),this._m=function(){let t={},e={},s=[],r=[];const n=(t,e)=>(e.toString=()=>"effcss-"+t,e),i=t=>{var e;return t.adoptedStyleSheets=[...(null===(e=t.adoptedStyleSheets)||void 0===e?void 0:e.length)?[...t.adoptedStyleSheets].filter((t=>!(t+"").startsWith("effcss-"))):[],...s]},o=()=>{r=r.reduce(((t,e)=>{const s=e.deref();return s&&(i(s),t.push(e)),t}),[])},c=t=>s.findIndex((e=>e===t)),a=e=>e?t[e]:void 0,l=(e,r)=>{if(!t[e])return t[e]=n(e,r),s.push(t[e]),o(),!0},h=t=>{const e=a(t);return!!e&&-1!==c(e)};return{apply:i,notify:o,getIndex:c,get:a,has:t=>!!t&&!!a(t),getAll:()=>t,add:l,status:h,on:(...t)=>{const e=t.reduce(((t,e)=>{const r=a(e);return!(!r||h(e))&&(s.push(r),t)}),!0);return o(),e},off:(...t)=>{const e=t.reduce(((t,e)=>{const r=a(e);if(r&&h(e)){const e=c(r);return s.splice(e,1),t}return!1}),!0);return o(),e},remove:r=>{const n=a(r);if(!n)return;const i=c(n);return i>-1&&(s.splice(i,1),delete t[r],delete e[r]),o(),!0},removeAll:()=>(s.splice(0),t={},e={},o(),!0),pack:(t,e)=>{let s=new CSSStyleSheet;return s.replaceSync(e),s=n(t,s),!!s.cssRules.length&&l(t,s)},replace:(e,s)=>{const r=t[e];if(r)return r.replaceSync(s),o(),!0},register:t=>{r.findIndex((e=>e.deref()===t))>=0||(r.push(new WeakRef(t)),i(t))},unregister:t=>{const e=r.findIndex((e=>e.deref()===t));e>=0&&r.splice(e,1)}}}(),this._cust=(t={})=>{const{varName:e}=this._s(this._k.base);function s(t,r){return kt(t).reduce(((t,[n,i])=>i&&"object"==typeof i?_t(t,s(i,[...r,n])):(t[e(...r,n)]=i,t)),{})}const r=St(kt(t||{}).map((([t,e])=>[t,s(e,[])]))),{"":n={},dark:i,light:o}=r,c=function(t,e){var s={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(s[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(s[r[n]]=t[r[n]])}return s}(r,["","dark","light"]);this._=({bem:t,each:e,when:s,vars:r,merge:a,at:{mq:l}})=>{const h="prefers-color-scheme",u={light:`${h}: light`,dark:`${h}: dark`};return a({[`:root:has(script[is=${ft}])`]:a({fontSize:r("rem")},n)},s(!!i,{[l(u.dark).s]:i}),s(!!o,{[l(u.light).s]:o}),e(c,((e,s)=>({[`:root:has(script[is=${ft}][${bt}=${e}])`]:s,[t(`..theme.${e}`)]:s}))))},this.use(this._,this._k.base)},this.use=(t,e)=>{const s=e||this._k.current;let r=this._c.use(t,s);return this._m&&!this._m.has(e)&&this._m.pack(r,this.css(t,r)),e||this._k.next(),this.resolve(r)},this.usePublic=t=>St(kt(t).map((([t,e])=>[t,this.use(e,t)]))),this.usePrivate=t=>t.map((t=>this.use(t))),this.resolve=t=>this._s(t||this._k.base).attr,this.css=(t,e)=>this._p.compile({key:e,maker:t}),this.status=t=>{const e=this.key(t);return!!e&&this._m.status(e)},this.on=(...t)=>this._m.on(...t.map(this.key)),this.off=(...t)=>this._m.off(...t.map(this.key)),this.key=t=>"string"==typeof t?t:this._c.getKey(t),this.stylesheets=(t=this._c.keys)=>t.map((t=>this._m.get(this.key(t))))}get prefix(){return xt(this,"prefix")||""}get mode(){return xt(this,"mode")}get hydrate(){return""===this.getAttribute("hydrate")}get settings(){return this._settings}set settings(t){var e,s,r;const n=_t({},this._settings,t),{makers:i,vars:o,bp:c,off:a}=n;c&&(null===(e=this._settings)||void 0===e?void 0:e.bp)!==c&&(this._p=et({scope:this._s,globalKey:this._k.base,bp:c})),o&&(null===(s=this._settings)||void 0===s?void 0:s.vars)!==o&&this._cust(o),i&&(null===(r=this._settings)||void 0===r?void 0:r.makers)!==i&&(this._c.useMany(i),this.usePublic(i),(null==a?void 0:a.length)&&this._settings.off!==a&&this.off(...a),this.hydrate&&this._k.reset()),this._settings=n}set theme(t){t?this.setAttribute(bt,t):this.removeAttribute(bt)}get theme(){return xt(this,bt)||""}connectedCallback(){this._k=vt({prefix:this.prefix}),this._s=((t={})=>{const{mode:e}=t;let s,r;return t=>{const n=(...e)=>""+e.filter(Boolean).reduce(((t,e)=>`${t}-${e}`),t),i=(...t)=>"--"+n(...t);return"c"===e?(s=t=>{let e,s,r,i;return ot(t)?([e,s,r,i]=lt(t),dt(n(e),s,r,i)):t&&ht(t).map((([t,e,s,r])=>dt(n(t),e,s,r))).join(",")},r=t=>{let e,s,r,i;const o="class";let c="";return Array.isArray(t)?c=[...t.reduce(((t,o)=>([e,s,r,i]=lt(o),t.add(ut(n(e),s)),r&&t.add(ut(n(e),s,r,i)),t)),new Set).values()].join(" "):ot(t)?([e,s,r,i]=lt(t),c=ut(n(e),s,r,i)):c=t&&ht(t,!0).map((([t,e,s,r])=>ut(n(t),e,s,r))).join(" "),nt({[o]:c},{toString:{value:()=>`${o}="${c}"`}})}):(s=t=>{let e,s,r,i;return ot(t)?([e,s,r,i]=lt(t),pt(n(e),s,r,i)):t&&ht(t).map((([t,e,s,r])=>pt(n(t),e,s,r))).join(",")},r=t=>{let e,s,r,i,o,c,a="";if(Array.isArray(t))c=t.reduce(((t,c)=>{[e,s,r,i]=lt(c);const l=at(n(e),s);return o=it(l),a=r?i?`${r}_${i}`:`${r}`:"",t[o]&&a?t[o]=t[o]+" "+a:t[o]=a,t}),{});else if(ot(t)){[e,s,r,i]=lt(t);const l=at(n(e),s);o=it(l),a=r?i?`${r}_${i}`:`${r}`:"",c={[o]:a}}else c=t&&ht(t,!0).reduce(((t,[e,s,r,i])=>{const c=at(n(e),s);o=it(c);const l=r?i?`${r}_${i}`:`${r}`:"";return a=t[o]?t[o]+" "+l:l,t[o]=a,t}),{});return nt(c,{toString:{value:()=>rt(c).map((([t,e])=>`${t}="${e}"`)).join(" ")}}),c}),{selector:s,attr:r,name:n,varName:i,varExp:(...t)=>`var(${i(...t)})`}}})({mode:this.mode});const s=this;this._n={set adoptedStyleSheets(t){s.dispatchEvent(new CustomEvent("effcsschanges",{detail:{styles:t},bubbles:!0}))}},this._m.register(this._n),this._m.register(e),this.settings=_t({},$t,t)}toString(){return`<script ${[...this.attributes].map((t=>t.value?`${t.name}="${t.value}"`:""===t.value?t.name:"")).filter(Boolean).join(" ")}>${this.textContent}<\/script>`}}return s.define(ft,r,{extends:"script"}),!0}}export{jt as defineProvider};
@@ -104,8 +104,8 @@ export declare const resolveAtRules: (scope: ReturnType<ReturnType<TCreateScope>
104
104
  };
105
105
  /**
106
106
  * `@scope` selector
107
- * @param r - scope root
108
- * @param l - scope limit
107
+ * @param r - root
108
+ * @param l - limit
109
109
  */
110
110
  sc: (r?: string, l?: string) => {
111
111
  /**
@@ -125,7 +125,7 @@ export declare const resolveAtRules: (scope: ReturnType<ReturnType<TCreateScope>
125
125
  /**
126
126
  * `@supports` selector
127
127
  * @param c - condition
128
- * @param n - inverse condition
128
+ * @param n - invert condition
129
129
  */
130
130
  sup: {
131
131
  (c?: string, n?: boolean): {
@@ -1,11 +1,12 @@
1
1
  import { TCreateScope } from '../../common';
2
+ type TStrOrNum = string | number;
2
3
  type TChangeStr = (val: string) => string;
3
4
  type TChangeColor = (color: string | object, val?: number | string) => string;
4
5
  type TPaletteState = {
5
- l: string | number;
6
- c: string | number;
7
- h: string | number;
8
- a: string | number;
6
+ l: TStrOrNum;
7
+ c: TStrOrNum;
8
+ h: TStrOrNum;
9
+ a: TStrOrNum;
9
10
  };
10
11
  export declare const resolveColor: (vars: ReturnType<ReturnType<TCreateScope>>["varExp"]) => {
11
12
  /**
@@ -23,28 +24,28 @@ export declare const resolveColor: (vars: ReturnType<ReturnType<TCreateScope>>["
23
24
  */
24
25
  l: <Theme>(val: Theme extends {
25
26
  l: Record<string, number | string>;
26
- } ? Exclude<keyof Theme["l"], symbol> : string | number) => /*elided*/ any;
27
+ } ? Exclude<keyof Theme["l"], symbol> : TStrOrNum) => /*elided*/ any;
27
28
  /**
28
29
  * Set chroma
29
30
  * @param c - chroma value
30
31
  */
31
32
  c: <Theme>(val: Theme extends {
32
33
  c: Record<string, number | string>;
33
- } ? Exclude<keyof Theme["c"], symbol> : string | number) => /*elided*/ any;
34
+ } ? Exclude<keyof Theme["c"], symbol> : TStrOrNum) => /*elided*/ any;
34
35
  /**
35
36
  * Set hue
36
37
  * @param h - hue value
37
38
  */
38
39
  h: <Theme>(val: Theme extends {
39
40
  h: Record<string, number | string>;
40
- } ? Exclude<keyof Theme["h"], symbol> : string | number) => /*elided*/ any;
41
+ } ? Exclude<keyof Theme["h"], symbol> : TStrOrNum) => /*elided*/ any;
41
42
  /**
42
43
  * Set alpha
43
44
  * @param value - alpha value
44
45
  */
45
46
  a: <Theme>(val: Theme extends {
46
47
  a: Record<string, number | string>;
47
- } ? Exclude<keyof Theme["a"], symbol> : string | number) => /*elided*/ any;
48
+ } ? Exclude<keyof Theme["a"], symbol> : TStrOrNum) => /*elided*/ any;
48
49
  /**
49
50
  * Color string
50
51
  */
@@ -7,8 +7,6 @@ type TStyleRoot = {
7
7
  };
8
8
  /**
9
9
  * Style manager
10
- * @description
11
- * Manages CSS stylesheets.
12
10
  */
13
11
  interface IStyleManager {
14
12
  /**
@@ -18,7 +16,7 @@ interface IStyleManager {
18
16
  get(key?: string): CSSStyleSheet | undefined;
19
17
  /**
20
18
  * Get index of stylesheet
21
- * @param styleSheet - CSS stylesheet
19
+ * @param styleSheet - CSSStylesheet
22
20
  */
23
21
  getIndex(styleSheet: CSSStyleSheet): number;
24
22
  /**
@@ -28,13 +26,13 @@ interface IStyleManager {
28
26
  /**
29
27
  * Add stylesheet
30
28
  * @param key - stylesheet key
31
- * @param stylesheet - CSSStylesheet instance
29
+ * @param stylesheet - CSSStylesheet
32
30
  */
33
31
  add(key: string, stylesheet: CSSStyleSheet): TOptBool;
34
32
  /**
35
33
  * Replace stylesheet content
36
34
  * @param key - stylesheet key
37
- * @param styles - stylesheet content string
35
+ * @param styles - stylesheet content
38
36
  */
39
37
  replace(key: string, styles: string): TOptBool;
40
38
  /**
@@ -50,7 +48,7 @@ interface IStyleManager {
50
48
  /**
51
49
  * Pack styles into CSSStyleSheet and add it into stylesheet dictionary
52
50
  * @param key - stylesheet key
53
- * @param styles - stylesheet content string
51
+ * @param styles - stylesheet content
54
52
  */
55
53
  pack(key: string, styles: string): TOptBool;
56
54
  /**
@@ -73,7 +73,7 @@ type TCreateProcessor = (params: {
73
73
  bp?: Record<string, string | number>;
74
74
  }) => {
75
75
  /**
76
- * Compile style maker to CSS stylesheet text content
76
+ * Compile stylesheet maker to CSSStylesheet content
77
77
  * @param params - params
78
78
  */
79
79
  compile(params: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effcss",
3
- "version": "3.0.3",
3
+ "version": "3.1.0",
4
4
  "description": "Self-confident CSS-in-JS",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -15,7 +15,7 @@
15
15
  "css-in-js"
16
16
  ],
17
17
  "author": "Marat Sabitov",
18
- "license": "Apache 2.0",
18
+ "license": "Apache-2.0",
19
19
  "main": "dist/index.js",
20
20
  "types": "dist/types/src/types.d.ts",
21
21
  "exports": {