effcss 4.12.0 → 4.13.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/README.md +26 -57
- package/dist/index.js +2 -2
- package/dist/types/_provider/process.d.ts +11 -1
- package/dist/types/_provider/scope.d.ts +1 -1
- package/dist/types/_provider/theme.d.ts +1 -1
- package/dist/types/index.d.ts +21 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,15 +80,16 @@ Just call `useStyleProvider` in your code:
|
|
|
80
80
|
|
|
81
81
|
```jsx
|
|
82
82
|
import { useStyleProvider } from "effcss";
|
|
83
|
+
import { App } from "./App.tsx";
|
|
83
84
|
|
|
84
|
-
const
|
|
85
|
+
const styleProvider = useStyleProvider({
|
|
85
86
|
attrs: {
|
|
86
87
|
min: true // to create minified selectors
|
|
87
88
|
}
|
|
88
89
|
});
|
|
89
90
|
|
|
90
91
|
const root = createRoot(document.getElementById("root"));
|
|
91
|
-
root.render(<App
|
|
92
|
+
root.render(<App styleProvider={styleProvider} />);
|
|
92
93
|
```
|
|
93
94
|
|
|
94
95
|
Each CSS stylesheet corresponds to a single `Stylesheet maker`. `Stylesheet maker` is a JS function that should return object or string with style rules:
|
|
@@ -117,37 +118,9 @@ export type TMyMaker = {
|
|
|
117
118
|
* Card height
|
|
118
119
|
*/
|
|
119
120
|
h: 'full' | 'half';
|
|
120
|
-
/**
|
|
121
|
-
* Card logo scope
|
|
122
|
-
*/
|
|
123
|
-
logo: {
|
|
124
|
-
/**
|
|
125
|
-
* Logo width
|
|
126
|
-
*/
|
|
127
|
-
w: 's' | 'l';
|
|
128
|
-
},
|
|
129
|
-
/**
|
|
130
|
-
* Card footer scope
|
|
131
|
-
*/
|
|
132
|
-
footer: {
|
|
133
|
-
/**
|
|
134
|
-
* Footer visibility
|
|
135
|
-
*/
|
|
136
|
-
visible: '';
|
|
137
|
-
/**
|
|
138
|
-
* Footer size
|
|
139
|
-
*/
|
|
140
|
-
sz: 's' | 'm' | 'l';
|
|
141
|
-
};
|
|
142
121
|
};
|
|
143
122
|
}
|
|
144
123
|
|
|
145
|
-
const HEIGHT_COEFS = {
|
|
146
|
-
s: 1,
|
|
147
|
-
m: 2,
|
|
148
|
-
l: 4
|
|
149
|
-
};
|
|
150
|
-
|
|
151
124
|
export const myMaker: TStyleSheetMaker = ({
|
|
152
125
|
select, merge,
|
|
153
126
|
pseudo: {h},
|
|
@@ -188,24 +161,24 @@ export const myMaker: TStyleSheetMaker = ({
|
|
|
188
161
|
})
|
|
189
162
|
});
|
|
190
163
|
return {
|
|
164
|
+
// add @property rule
|
|
191
165
|
...sizeProperty,
|
|
166
|
+
// add @keyframes rule
|
|
192
167
|
...spin,
|
|
193
|
-
|
|
194
|
-
[selector('
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
168
|
+
// add rules according to the TMyMaker contract
|
|
169
|
+
[selector('fsz:16')]: {
|
|
170
|
+
// rule content
|
|
171
|
+
},
|
|
172
|
+
[selector('card')]: {
|
|
173
|
+
// rule content
|
|
174
|
+
},
|
|
175
|
+
[selector('card.rounded:')]: {
|
|
176
|
+
// rule content
|
|
177
|
+
},
|
|
178
|
+
[selector('card.h:full')]: {
|
|
179
|
+
// rule content
|
|
198
180
|
},
|
|
199
|
-
|
|
200
|
-
[selector('card.rounded:')]: { ... },
|
|
201
|
-
[selector('card.h:full')]: { ... },
|
|
202
|
-
[selector('card.footer')]: { ... },
|
|
203
|
-
[selector('card.footer.visible:')]: { ... },
|
|
204
|
-
...each(HEIGHT_COEFS, (k, v) => ({
|
|
205
|
-
[selector(`card.footer.sz:${k}`)]: {
|
|
206
|
-
height: size(v)
|
|
207
|
-
}
|
|
208
|
-
}))
|
|
181
|
+
// ... and so on
|
|
209
182
|
};
|
|
210
183
|
};
|
|
211
184
|
```
|
|
@@ -221,25 +194,21 @@ import type { TMyMaker } from './maker';
|
|
|
221
194
|
import { myMaker } from './maker';
|
|
222
195
|
|
|
223
196
|
export const App = (props: {
|
|
224
|
-
|
|
197
|
+
styleProvider: IStyleProvider;
|
|
225
198
|
}) => {
|
|
226
|
-
const styleProvider = useStyleProvider();
|
|
227
199
|
const stylesRef = useRef();
|
|
228
200
|
// put it inside ref to avoid recalculations
|
|
229
201
|
if (!stylesRef.current) {
|
|
230
|
-
|
|
231
|
-
//
|
|
232
|
-
// you don't need to look at the implementation - just create the necessary attributes
|
|
202
|
+
// thanks to the TMyMaker contract type,
|
|
203
|
+
// you don't need to look at the implementation - just pass the necessary selectors
|
|
233
204
|
stylesRef.current = {
|
|
234
205
|
// you can apply list of selectors
|
|
235
|
-
card: styleProvider.dx<TMyMaker>('card.
|
|
206
|
+
card: styleProvider.dx<TMyMaker>(myMaker, ['card.h:full', 'fsz:16']),
|
|
236
207
|
// or you can apply object with selectors
|
|
237
|
-
|
|
208
|
+
another: styleProvider.dx<TMyMaker>(myMaker, {
|
|
209
|
+
fsz: 16,
|
|
238
210
|
card: {
|
|
239
|
-
|
|
240
|
-
visible: '',
|
|
241
|
-
size: 'm'
|
|
242
|
-
}
|
|
211
|
+
h: 'full'
|
|
243
212
|
}
|
|
244
213
|
})
|
|
245
214
|
};
|
|
@@ -248,7 +217,7 @@ export const App = (props: {
|
|
|
248
217
|
// just apply attributes to appropriate elements
|
|
249
218
|
return (
|
|
250
219
|
<div {...styles.card}>
|
|
251
|
-
<div {...styles.
|
|
220
|
+
<div {...styles.another}>...</div>
|
|
252
221
|
</div>
|
|
253
222
|
);
|
|
254
223
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* EffCSS v4.
|
|
2
|
+
* EffCSS v4.13.0
|
|
3
3
|
* {@link https://sourcecraft.dev/msabitov/effcss}
|
|
4
4
|
* Copyright (c) Marat Sabitov
|
|
5
5
|
* @license Apache-2.0
|
|
6
6
|
*/
|
|
7
|
-
const e=(e,t,r)=>Object.entries(e).reduce(t,r),t=(e,t)=>{return`${r=e,r.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))}:${""+t};`;var r},r=Symbol("noParse"),s=(n,i,a)=>{let o=""+n;return null==i?"":Array.isArray(i)?i.map((e=>t(o,e))).join(""):"object"!=typeof i||i.hasOwnProperty(r)?""===i?o+";":t(o,i):(!a||a.startsWith?.("@")||o.startsWith?.("&")||o.startsWith?.("@")?"":"&")+o+`{${e(i,((e,t)=>e+s(...t,o)),"")}}`},n="@layer",i="@starting-style",a=e=>`(${e})`,o=e=>"string"==typeof e,l={and:(...e)=>Object.defineProperties({type:"and",value:e},{toString:{value:()=>e.filter(Boolean).map((e=>{const t=g(e);return"object"==typeof e&&"or"===e.type?a(t):t})).join(" and ")}}),or:(...e)=>Object.defineProperties({type:"or",value:e},{toString:{value:()=>e.filter(Boolean).map((e=>g(e))).join(" or ")}}),not:e=>"object"==typeof e&&"not"===e.type?e.value[0]:Object.defineProperties({type:"not",value:[e]},{toString:{value:()=>`not (${g(e,!0)})`}})},c=e=>{const t=t=>({toString:()=>`(min-${e}:${o(t)?t:t+"rem"})`}),r=t=>({toString:()=>`(max-${e}:${o(t)?t:t+"rem"})`}),s=(e,s)=>({toString:()=>`${t(e)} and ${r(s)}`});return{up:t,down:r,between:s,only:e=>s(e,e)}},u=c("width"),h=c("height"),m=c("inline-size"),d=c("block-size"),g=(e,t)=>e?"string"==typeof e?e.includes("(")||t?e:a(e):e+"":"",p=(e={})=>{const{type:t,condition:r}=e,s=g(r),n="object"==typeof r&&"or"===r.type,i=`@media${t?" "+t:""}${t&&s?" and":""}${s?" "+(t&&n?a(s):s):""}`;return Object.defineProperties((e=>({[i]:e})),{all:{get:()=>p({condition:r,type:"all"})},print:{get:()=>p({condition:r,type:"print"})},screen:{get:()=>p({condition:r,type:"screen"})},where:{value:e=>p({condition:e,type:t})},toString:{value:()=>i}})},b=p({}),f=({condition:e}={})=>{const t=g(e),r="@supports"+(t?" "+t:"");return Object.defineProperties((e=>({[r]:e})),{where:{value:e=>f({condition:e})},toString:{value:()=>r}})},$=f(),y=e=>({[i]:e});y.toString=i;const v=e=>{const{root:t="",limit:r="",mode:s=[!1,!1]}=e,n=`@scope ${t?`(${t}${s[0]?" > *":""})`:""}${t&&r?" ":""}${r?`to (${r}${s[1]?" > *":""})`:""}`;return Object.defineProperties((e=>({[n]:e})),{limit:{value:e=>v({root:t,limit:e,mode:s})},root:{value:e=>v({root:e,limit:r,mode:s})},both:{value:()=>v({root:t,limit:r,mode:[!1,!0]})},none:{value:()=>v({root:t,limit:r,mode:[!0,!1]})},low:{value:()=>v({root:t,limit:r,mode:[!0,!0]})},high:{value:()=>v({root:t,limit:r,mode:[!1,!1]})},toString:{value:()=>n}})},x=v({}),w=(e,t)=>`calc(${e} * 1${t})`,k=e=>w(e,"px"),j=e=>w(e,"vh"),S=e=>w(e,"vw"),_=e=>w(e,"vmin"),A=e=>w(e,"vmax"),O=e=>w(e,"em"),z=e=>w(e,"rem"),C=e=>w(e,"deg"),P=e=>w(e,"rad"),q=e=>w(e,"rad"),E=e=>w(e,"ms"),N=e=>w(e,"s"),T=e=>w(e,"%"),R=e=>w(e,"cqw"),M=e=>w(e,"cqh"),B=e=>w(e,"cqi"),W=e=>w(e,"cqb"),I=e=>w(e,"cqmin"),V=e=>w(e,"cqmax"),J=Object.fromEntries,L=Object.entries,H=":first-",D=":last-",K=":only-",U="child",F=":nth-",Z="of-type",G=F+U,Q=":focus",X="valid",Y="in"+X,ee=":user-",te="placeholder",re={r:":root",h:":hover",f:Q,fv:Q+"-visible",a:":active",v:":visited",val:":"+X,inv:":"+Y,uval:ee+X,uinv:ee+Y,e:":empty",d:":disabled",rq:":required",o:":optional",m:":modal",l:":link",phs:`:${te}-shown`,ch:":checked",po:":popover-open",fc:H+U,lc:D+U,oc:K+U,odd:G+"(odd)",even:G+"(even)",ft:H+Z,lt:D+Z,ot:K+Z,bef:"::before",aft:"::after",ph:`::${te}`,bd:"::backdrop",fl:"::first-line",dc:"::details-content",sel:"::selection"},se={has:":has",not:":not",is:":is",wh:":where",st:":state",nthc:G,ntho:F+Z,dir:":dir",lang:":lang"},ne=e=>`oklch(${e})`,ie=e=>ne(`from ${e}`),ae=e=>t=>{if(!t)return e||"currentColor";const{l:r,c:s,h:n,a:i=1}=t;return ne(r&&s&&n?(e?`from ${e} `:"")+`${r} ${s} ${n} / ${i||(e?"alpha":1)}`:`from ${e||"currentColor"} ${r||"l"} ${s||"c"} ${n||"h"} / ${i||"alpha"}`)},oe=(e,t=.1)=>ie(`${e} calc(l + ${t}) c h / alpha`),le=(e,t=.1)=>ie(`${e} calc(l - ${t}) c h / alpha`),ce=(e,t=.1)=>ie(`${e} l c h / calc(alpha + ${t})`),ue=(e,t=.1)=>ie(`${e} l c h / calc(alpha - ${t})`),he=(e,t=.04)=>ie(`${e} l calc(c + ${t}) h / alpha`),me=(e,t=.04)=>ie(`${e} l calc(c - ${t}) h / alpha`),de=e=>ie(`${e} l c calc(h + 180) / alpha`),ge=e=>ie(`${e} l 0 h / alpha`),pe=(e,t=30)=>ie(`${e} l c calc(h${"number"==typeof t?t>0?" + "+t:" - "+-t:t}) / alpha`),be=e=>"string"==typeof e?ne(e):ae(e.from)(e),fe=e=>{const t=e("color"),r=e("contrast"),s=e("neutral");return{root:ae(t),contrast:ae(r),neutral:ae(s),oklch:be,lighten:oe,darken:le,saturate:he,desaturate:me,fadein:ce,fadeout:ue,spin:pe,complement:de,grayscale:ge}},$e=e=>{class t{state={l:"l",c:"base",h:"pri",a:"1",m:"bg"};constructor(e={}){Object.assign(this,{[r]:!0}),this.state=Object.assign(this.state,e)}get xs(){return new t({...this.state,l:"xs"})}get s(){return new t({...this.state,l:"s"})}get m(){return new t({...this.state,l:"m"})}get l(){return new t({...this.state,l:"l"})}get xl(){return new t({...this.state,l:"xl"})}get lightness(){return{xs:this.xs,s:this.s,m:this.m,l:this.l,xl:this.xl}}get gray(){return new t({...this.state,c:"gray"})}get pale(){return new t({...this.state,c:"pale"})}get base(){return new t({...this.state,c:"base"})}get rich(){return new t({...this.state,c:"rich"})}get chroma(){return{gray:this.gray,pale:this.pale,base:this.base,rich:this.rich}}get pri(){return new t({...this.state,h:"pri"})}get sec(){return new t({...this.state,h:"sec"})}get suc(){return new t({...this.state,h:"suc"})}get inf(){return new t({...this.state,h:"inf"})}get war(){return new t({...this.state,h:"war"})}get dan(){return new t({...this.state,h:"dan"})}get hue(){return{pri:this.pri,sec:this.sec,suc:this.suc,inf:this.inf,war:this.war,dan:this.dan}}alpha(e=1){return new t({...this.state,a:e+""})}get bg(){return new t({...this.state,m:"bg"})}get fg(){return new t({...this.state,m:"fg"})}toString(){const{l:t,c:r,h:s,a:n,m:i}=this.state;return`oklch(${e(`lightness.${i}.${t}`)} ${e(`chroma.${i}.${r}`)} ${e(`hue.${s}`)} / ${n})`}}return new t},ye=e=>{const t=(t,r=0)=>e(`coef.${t.state.center+r}`);class r{state={center:8};constructor(e={}){this.state=Object.assign(this.state,e)}get min(){return t(this,-4)}get xxs(){return t(this,-3)}get xs(){return t(this,-2)}get s(){return t(this,-1)}get m(){return t(this)}get l(){return t(this,1)}get xl(){return t(this,2)}get xxl(){return t(this,3)}get max(){return t(this,4)}get $xxs(){return new r({center:4})}get $xs(){return new r({center:8})}get $s(){return new r({center:12})}get $m(){return new r({center:16})}get $l(){return new r({center:20})}get $xl(){return new r({center:24})}get $xxl(){return new r({center:28})}get short(){return{s:this.s,m:this.m,l:this.l}}get base(){return{xs:this.xs,...this.short,xl:this.xl}}get long(){return{xxs:this.xxs,...this.base,xxl:this.xxl}}get full(){return{min:this.min,...this.long,max:this.max}}get main(){return{min:this.min,m:this.m,max:this.max}}get sparse(){return{min:this.min,xs:this.xs,m:this.m,xl:this.xl,max:this.max}}}return new r},ve=Object.assign,xe=Object.entries,we=Array.isArray,ke=e=>"object"==typeof e,je=(e,t)=>Array.from(Array(e).entries()).reduce(((e,[r])=>ve(e,t(r+1))),{}),Se=(e,t)=>xe(e).reduce(((e,[r,s])=>ve(e,t(r,s))),{}),_e=(e,t,r={})=>e?t:r,Ae=(...e)=>e.join("-"),Oe=(...e)=>e.join(),ze=(...e)=>e.join(" "),Ce=(e,...t)=>t.length?t.reduce(((e,t)=>(t&&e&&ke(t)&&xe(t).forEach((([t,r])=>{r&&ke(r)&&e[t]?we(e[t])&&we(r)?e[t]=[...e[t],...r]:Ce(e[t],r||{}):e[t]=r})),e)),e):e,Pe=(e,t,s="")=>{const n=(n=0)=>{const i=t(e),a=n?t(e+"-"+n,i):i;return Object.defineProperties(((e=1)=>`calc(${a} * ${e}${s})`),{toString:{value:()=>`calc(${a} * 1${s})`},[r]:{value:!0}})},i={get:(e,t,r)=>"symbol"==typeof t||Number.isNaN(+t)?Reflect.get(e,t,r):n(+t)};return new Proxy(n(),i)},qe=(e,t)=>{const s=(s=0)=>{const n=t(e),i=s?t(e+"-"+s,n):n;return Object.defineProperties({},{toString:{value:()=>i},[r]:{value:!0}})},n={get:(e,t,r)=>"symbol"==typeof t||Number.isNaN(+t)?Reflect.get(e,t,r):s(+t)};return new Proxy(s(),n)},Ee=Object.assign(J(L(re).map((([e,t])=>{function r(e=""){return e&&"object"==typeof e?{[t]:e}:e+t}return r.toString=()=>t,[e,r]}))),J(L(se).map((([e,t])=>{function r(e,r=""){const s=t+`(${e})`;return r&&"object"==typeof r?{[s]:r}:r+s}return r.toString=()=>t,[e,r]})))),Ne={px:k,vh:j,vw:S,vmin:_,vmax:A,em:O,rem:z,deg:C,rad:P,turn:q,ms:E,s:N,pc:T,cqw:R,cqh:M,cqb:W,cqi:B,cqmin:I,cqmax:V},Te=e=>1!==e?e+" * ":"",Re=t=>{const{scope:i,globalKey:a}=t,o=i(a).varExp,c=(e=1)=>Ne.ms(Te(e)+o("time")),p=(e=1)=>Ne.deg(Te(e)+o("angle")),f=(e=1)=>Ne.px(Te(e)+o("size")),v=e=>e?`cubic-bezier(${e.x1||0},${e.y1||0},${e.x2||1},${e.y2||1})`:o("easing"),w={variable:o,time:Pe("time",o,"ms"),angle:Pe("angle",o,"deg"),size:Pe("size",o,"px"),easing:qe("easing",o),color:qe("color",o),contrast:qe("contrast",o),neutral:qe("neutral",o)};return{compile:({key:t,maker:a,mode:k})=>{const j=i(t,k),S=j.selector,_=j.select,A=(e=>{const t={cp:1,lay:1,kf:1,cq:1},s=(n={})=>{const{scroll:i,type:a,name:o,condition:l}=n,c=g(l),u=`@container${o?" "+o:""}${c?" "+c:""}`;return Object.defineProperties((e=>({[u]:e})),{container:{value:(o||"none")+" / "+(a&&i?`${a} scroll-state`:i?"scroll-state":a||"normal"),enumerable:!0},named:{get:()=>s({scroll:i,condition:l,name:o||e.name(["cq",t.cq++]),type:a})},size:{get:()=>s({name:o,scroll:i,condition:l,type:"size"})},isize:{get:()=>s({name:o,scroll:i,condition:l,type:"inline-size"})},scroll:{get:()=>s({name:o,scroll:!0,condition:l,type:a})},where:{value:e=>s({name:o,scroll:i,condition:e,type:a})},[r]:{value:!0},toString:{value:()=>u}})},i=({name:r}={})=>{const s=`${n}${r?" "+r:""}`,a=e=>({[s]:e});return a.toString=()=>s,Object.defineProperties(a,{named:{get:()=>i({name:r||e.name(["lay",t.lay++])})},list:{value:(...e)=>({[n+(e.map((e=>(e+"").split(n)[1])).filter(Boolean).join(",")||r)]:""})}})};return{layer:i(),supports:$,keyframes:s=>{const n=e.name(["kf",t.kf++]),i="@keyframes "+n;return Object.defineProperties((e=>{if(!e)return{animationName:n};const{dur:t,tf:r,del:s,ic:i,dir:a,ps:o,fm:l}=e;return{animation:[t,r,s,i,a,o,l,n].filter(Boolean).join(" ")}}),{[i]:{value:s,enumerable:!0},toString:{value:()=>n},[r]:{value:!0}})},property:(s={})=>{let n,i,a='"*"',o=!0;"object"==typeof s?({syn:a=a,inh:o=o,ini:n,def:i}=s):(i=s,n=s,o=!1);const l="--"+e.name(["cp",t.cp++]),c=`var(${l}${void 0!==i?","+i:""})`,u="@property "+l;return Object.defineProperties((e=>({[l]:e})),{[u]:{value:{syntax:a,inherits:o,initialValue:n},enumerable:!0},toString:{value:()=>c},fallback:{value:e=>`var(${l},${e})`},[r]:{value:!0}})},scope:x,media:b,container:s({}),startingStyle:y,$logic:l,$width:u,$height:h,$block:d,$inline:m}})(j),O=a({dash:Ae,comma:Oe,space:ze,range:je,each:Se,when:_e,merge:Ce,theme:w,themeVar:o,size:f,time:c,angle:p,easing:v,bem:S,select:_,pseudo:Ee,color:fe(o),palette:$e(o),coef:ye(o),units:Ne,at:A});return"string"==typeof O?O:(t=>e(t,((e,t)=>e+s(...t)),""))(O)}}},Me=Symbol("effcss-stylesheet");class Be{disabled=!1;cssRules=[];replaceSync(e){e&&(this.cssRules=[{cssText:e}])}}function We({initStyles:e,emulate:t}={}){const r={};e?.forEach((e=>{const t=e?.dataset?.effcss;t&&(r[t]=e)}));let s={},n={},i=[],a=[];const o=(e,t)=>t.hasOwnProperty(Me)?t:Object.defineProperties(t,{[Me]:{value:e}}),l=e=>e.adoptedStyleSheets=[...e.adoptedStyleSheets?.length?[...e.adoptedStyleSheets].filter((e=>!e.hasOwnProperty(Me))):[],...i],c=()=>{a=a.reduce(((e,t)=>{const r=t.deref();return r&&(l(r),e.push(t)),e}),[])},u=e=>e?s[e]:void 0,h=(e,t)=>{if(!s[e]){s[e]=o(e,t),i.push(s[e]);const n=r[e];return n&&(n.disabled=!0),c(),!0}};return{get:u,all:()=>s,add:h,status:e=>{const t=u(e);return!t?.disabled},on:(...e)=>{e.forEach((e=>{const t=u(e);t&&(t.disabled=!1)})),c()},off:(...e)=>{e.forEach((e=>{const t=u(e);t&&(t.disabled=!0)})),c()},remove:e=>{const t=u(e);if(!t)return;const r=(a=t,i.findIndex((e=>e===a)));var a;return r>-1&&(i.splice(r,1),delete s[e],delete n[e]),c(),!0},removeAll:()=>(i.splice(0),s={},n={},c(),!0),pack:(e,r)=>{let n=s[e]||(!t&&globalThis.CSSStyleSheet?new globalThis.CSSStyleSheet:new Be);return n.replaceSync(r),n=o(e,n),!!n.cssRules.length&&h(e,n)},register:e=>{a.findIndex((t=>t.deref()===e))>=0||(a.push(new WeakRef(e)),l(e))},unregister:e=>{const t=a.findIndex((t=>t.deref()===e));t>=0&&a.splice(t,1)},hydrate:e=>r[e]&&!r[e].disabled&&r[e].textContent||void 0}}const Ie=({prefix:e})=>{let t=0;return{get initial(){return e+0},get current(){return e+t},next(){return t++,this.current}}},Ve=({prefix:e})=>{const t=new Set,r=new Map,s=Ie({prefix:e});return{use(e){let n=this.key(e);return n||(n=s.current,t.add(n),r.set(e,n),s.next(),n)},remake(e,t){const s=r.get(t);return s?(r.delete(t),r.set(e,s),s):this.use(e)},key:e=>e?r.get(e)||"":s.initial,get keys(){return[...t]},get makers(){return Object.fromEntries(r.entries().map((([e,t])=>[t,e])))}}},Je=void 0,Le=Object.entries,He=Object.defineProperties,De=e=>"string"==typeof e,Ke=e=>null!==e&&"object"==typeof e,Ue=e=>e.split("."),Fe=(e,t="")=>Le(e).reduce(((e,[r,s])=>{const n=t?`${t}-${r}`:r;return"object"==typeof s?(e.add(n),e=e.union(Fe(s,n))):e.add(n+`_${s}`),e}),new Set),Ze=(e,t="")=>Le(e).reduce(((e,[r,s])=>{const n=t?`${t}-${r}`:r;if("object"==typeof s){const t=Ze(s,n);t.size||e.add(n),e=e.union(t)}else t&&e.add(t),e.add(n+`_${s}`);return e}),new Set),Ge=(e,t)=>Le(e).reduce(((e,[r,s])=>{if(Ke(s)){const n=Le(s);n.length?e.push(...n.reduce(((e,[s,n])=>{if((e=>null!==e&&e!==Je)(s)&&t&&e.push([r,s,Je,Je]),Ke(n)){const t=Le(n);t.length&&e.push(...t.reduce(((e,[t,n])=>{const i=typeof n;return"string"!==i&&"number"!==i||e.push([r,s,t,n]),e}),[]))}return e}),[])):e.push([r,Je,Je,Je])}return e}),[]),Qe=(e,t,r,s)=>""+(((e,t)=>`${e||""}${t?"__"+t:""}`)(e,t)+(r?"_"+r:"")+(r&&s?"_"+s:""))||"_",Xe=(e,t)=>"."+(t?e+(t.startsWith("_")?"":"-")+t:e),Ye=(e,t)=>`[data-${e}${t?`~="${t}"`:""}]`;const et=e=>e||"",tt=Object.assign,rt=Object.entries,st="theme",nt="delete",it="update",at="$light",ot="$dark",lt="lightness",ct="chroma",ut=e=>Number((.1*184+.9*e).toFixed(2)),ht={time:200,size:16,angle:30,color:"#2192a7",contrast:"light-dark(black, white)",neutral:"light-dark(white, #1b1f1f)",easing:"linear",coef:{0:0,1:.0625,2:.125,3:.25,4:.5,5:.75,6:.875,7:.9375,8:1,9:1.0625,10:1.125,11:1.25,12:1.5,13:1.75,14:1.875,15:1.9375,16:2,17:3,18:4,19:5,20:7.5,21:10,22:12,23:15,24:16,25:20,26:28,27:36,28:48,29:64,30:80,31:120,32:150},hue:{pri:184,sec:290,suc:ut(142),inf:ut(264),war:ut(109),dan:ut(29)},[at]:{[lt]:{bg:{xl:1,l:.94,m:.88,s:.83,xs:.78},fg:{xl:0,l:.12,m:.24,s:.36,xs:.48}},[ct]:{bg:{gray:0,pale:.01,base:.04,rich:.7},fg:{gray:0,pale:.07,base:.11,rich:.15}}},[ot]:{[lt]:{bg:{xl:.24,l:.3,m:.36,s:.42,xs:.48},fg:{xl:1,l:.93,m:.86,s:.79,xs:.72}},[ct]:{bg:{pale:.02,base:.06,rich:.1},fg:{pale:.06,base:.1,rich:.14}}}},mt=({provider:e,init:t,scope:r,onChange:s})=>{const n={"":ht},i=[],a=({$light:e={},$dark:t={},...s})=>{function n(e,t=[]){return rt(e).reduce(((e,[s,i])=>Array.isArray(i)?(i.forEach(((n,i)=>{e[r.varName([...t,s,i])]=n})),e):i&&"object"==typeof i?tt(e,n(i,s?[...t,s]:t)):(e[r.varName([...t,s])]=i,e)),{})}return{...n(s),[at]:n(e),[ot]:n(t)}},o={get:(e="")=>n[e],add(e,t){n[t]||(n[t]=Ce({[at]:{},[ot]:{}},e),i.push({type:"add",payload:{params:e,name:t}}),s?.())},delete(e){e&&n[e]&&(this.current===e&&this.switch(),delete n[e],i.push({type:nt,payload:{name:e}}),s?.())},update(e,t=""){n[t]&&(n[t]=Ce({[at]:{},[ot]:{}},n[t],e),i.push({type:it,payload:{params:e,name:t}}),s?.())},switch(t=""){n[t]&&e.setAttribute(st,t)},vars(e=""){const t=this.get(e);return t?a(t):{[at]:{},[ot]:{}}},makeThemeVars:a,get list(){const{"":e,...t}=n;return Object.keys(t)},get current(){return e.getAttribute(st)||""},get all(){return n},get actions(){return i}};return t?.forEach((({type:e,payload:t})=>{switch(e){case"add":o.add(t.params,t.name);break;case nt:o.delete(t.name);break;case it:o.update(t.params,t.name)}})),o},dt="effcss",gt=dt+"-provider",pt=dt+"-override",bt="values",ft=":host",$t="@media",yt="script",vt="style",xt="size",wt="time",kt="angle",jt="color",St="contrast",_t="neutral",At="easing",Ot=dt+"changes",zt="data-"+dt,Ct="prefers-color-scheme",Pt=`${Ct}: light`,qt=`${Ct}: dark`,Et={mode:"a",pre:"f"},Nt=";",Tt=e=>"boolean"==typeof e,Rt=e=>"string"==typeof e?Number(e):null,Mt=(e,t)=>{const r=((e,t)=>e.getAttribute(t)||Et[t])(e,t);if(!r)return Rt(r);const s=r.split(Nt);return s.length>1?s.map(Rt):Rt(r)},Bt=(e,t,r)=>null===r?e.removeAttribute(t):e.setAttribute(t,Array.isArray(r)?r.join(Nt):r+""),Wt=e=>`:root:has([is=${gt}]${e?`[${e}]`:""})`,It=e=>Object.entries(e).reduce(((e,[t,r])=>e+t+":"+r+";"),""),Vt=(e,t)=>e+(+t?"-"+t:""),Jt=({theme:e,attrs:t,scope:r})=>({bem:s,each:n,themeVar:i,merge:a,pseudo:{r:o},at:{media:l},units:{px:c}})=>{const{$dark:u={},$light:h={},...m}=e.vars();return a({[Wt()]:{...m,...l.where(Pt)(h),...l.where(qt)(u),[o()]:{fontSize:c(i("size"))}}},n(e.list,((t,r)=>{const{$dark:n={},$light:i={},...a}=e.vars(r),o={...a,...l.where(Pt)(i),...l.where(qt)(n)};return{[Wt(`theme=${t}`)]:o,[s(`..theme.${t}`)]:o}})),...Object.entries(t).map((([e,t])=>t&&{[Wt(e)]:n(Array.isArray(t)?t:[t],((t,s)=>({[r.varName(Vt(e,+t))]:s})))})))},Lt=(e,t)=>({set(r){Bt(e,t,r)},get:()=>Mt(e,t)}),Ht=(e,t)=>({set(r){Bt(e,t,r)},get(){const r=e.getAttribute(t);if(!r)return r;const s=r.split(Nt);return s.length>1?s:r}}),Dt=(e,{initStyles:t,emulate:r,onChange:s,globalMaker:n,noscript:i})=>{let a;e.textContent&&(a=JSON.parse(e.textContent)),Object.defineProperties(e,{pre:{get:()=>e.getAttribute("pre")||"f"},mode:{get:()=>e.getAttribute("mode")||"a"},min:{get:()=>""===e.getAttribute("min")},size:Lt(e,xt),time:Lt(e,wt),angle:Lt(e,kt),color:Ht(e,jt),easing:Ht(e,At),contrast:Ht(e,St),neutral:Ht(e,_t)});const o=Ve({prefix:e.pre}),l=((e={})=>{const{mode:t,min:r,dict:s={}}=e,n=(e,r=t)=>{let s;s="a"===r?Ye:Xe;let i=0,a=et,o=et;const l=n.dict;l&&(l[e]||(l[e]={}),a=t=>l[e][t]??(l[e][t]=(i++).toString(36)),o=t=>l[e][t]);let c=t=>[e,...De(t)?t.split("."):t].filter(Boolean).join("-"),u="class",h=t=>t?e+(t.startsWith("_")?"":"-")+t:void 0===t?void 0:e;"a"===r&&(u="data-"+e,h=et);const m=e=>"--"+c(De(e)?e.split("."):e),d=e=>He({[u]:e},{toString:{value:()=>`${u}="${e}"`},$:{value:e}}),g=e=>{if(void 0===e)return function(e){const t=({b:r,e:s,m:n})=>({b:e=>t({b:e,e:"",m:{}}),e:e=>t({b:r,e:e,m:{}}),m:(e={})=>t({b:r,e:s,m:e}),get $(){return e({[r]:{[s]:n}})}});return t({b:"",e:"",m:{}})}(g);let t,r,s,n,i="";const a=De(e);return i=a||Array.isArray(e)?[...(a?[e]:e).reduce(((e,i)=>([t,r,s,n]=Ue(i),e.add(h(o(Qe(t,r)))),s&&e.add(h(o(Qe(t,r,s,n)))),e)),new Set).values()].join(" "):e&&Ge(e,!0).map((([e,t,r,s])=>h(o(Qe(e,t,r,s))))).join(" "),d(i)};return g.list=(...e)=>{const t=[...e.reduce(((e,t)=>{const[r,s]=t.split(":");if(!r)return e;if(void 0===s)return e.add(r.replaceAll(".","-")),e;const n=r.split("."),i=n.pop(),a=n.join("-");return n.length?(e.add(a),e.add(a+`-${i}_${s}`)):e.add(`${i}_${s}`),e}),new Set).keys()].map((e=>h(o(e)))).join(" ");return d(t)},g.obj=(e,t)=>{let r=Ze;"full"===t&&(r=Fe);const s=[...r(e).values()].map((e=>h(o(e)))).join(" ");return d(s)},{select:t=>{const r=t.replaceAll(".","-").replace(":","_");return s(e,a(r))},selector:t=>{const[r,n,i,o]=Ue(t);return s(e,a(Qe(r,n,i,o)))},attr:g,name:c,varName:m,varExp:(e,t)=>`var(${m(e)}${void 0!==t?","+t:""})`}};return r&&(n.dict=s),n})({mode:e.mode,min:e.min,dict:a?.dict}),c=l(o.key()),u=Re({scope:l,globalKey:o.key()}),h=We({initStyles:t,emulate:r});e.theme=mt({provider:e,init:a?.theme,onChange:s,scope:c});const m=(({scope:e,collector:t,manager:r,processor:s,globalMaker:n})=>{const i=e=>"string"==typeof e?e:t.key(e),a=(r,s)=>e(r||t.key(),s).attr,o=(e,t,r)=>s.compile({key:t,maker:e,mode:r}),l=(e,s)=>{let n=t.use(e);return r&&!r.get(n)&&r.pack(n,r.hydrate(n)||o(e,n,s)),a(n,s)},c=(...e)=>0===e.length?[l(n)]:e.map((e=>l(e))),u=(e,t)=>{const r=l(e,"c");return Array.isArray(t)?r.list(...t).$:r.obj(t).$};u.join=(...e)=>e.reduce(((e,t)=>t?e?e+" "+t:t||"":e),"");const h=(e,t)=>{const r=l(e,"a");return Array.isArray(t)?r.list(...t):r.obj(t)};return h.join=(...e)=>e.reduce(((e,t)=>t?{...e,...t}:e),{}),{use:c,remake:(e,s)=>{let n=t.key(s||e);return r&&r.get(n)?(s&&t.remake(e,s),r.pack(n,r.hydrate(n)||o(e,n)),a(n)):c(e)[0]},css:o,cx:u,dx:h,status:e=>{const t=i(e);return!!t&&r.status(t)},on:(...e)=>r.on(...e.map(i)),off:(...e)=>r.off(...e.map(i)),stylesheets:(e=t.keys)=>e.map((e=>r.get(i(e))))}})({scope:l,processor:u,manager:h,collector:o,globalMaker:n});Object.defineProperties(e,{_c:{value:o},_s:{value:l},_p:{value:u},_m:{value:h},toString:{value:()=>{const t={...h.all()},r=Object.entries(t).filter((([e,t])=>!t.disabled)).map((([e,t])=>`<style ${zt}="${e}">${[...t.cssRules].map((e=>e.cssText)).join("")}</style>`)).join("");let s=vt,n="";const a={is:gt,min:e.getAttribute("min"),mode:e.getAttribute("mode"),size:e.getAttribute(xt),time:e.getAttribute(wt),angle:e.getAttribute(kt),color:e.getAttribute(jt),easing:e.getAttribute(At),contrast:e.getAttribute(St),neutral:e.getAttribute(_t)};if(!i){s=yt,a.type="application/json";const t={theme:e.theme.actions,dict:l.dict};n=JSON.stringify(t)}return r+`<${s} ${Object.entries(a).map((([e,t])=>null!=t&&t!==Et[e]?""===t?e:`${e}="${t}"`:"")).filter(Boolean).join(" ")}${e.theme.current?` theme="${e.theme.current}"`:""}>${n}</${s}>`}}}),Object.assign(e,m)},Kt=Symbol(gt),Ut=[xt,wt,kt,jt,At,St,_t],Ft=new Set(Ut),Zt=()=>globalThis?.document.querySelector(`[is=${gt}]`);const Gt=(e={})=>{let{noscript:t,attrs:r={}}=e,{mode:s=Et.mode,min:n,pre:i=Et.prefix,size:a=null,time:o=null,angle:l=null,color:c=null,easing:u=null,contrast:h=null,neutral:m=null}=r;return new class{get tagName(){return""}get textContent(){return""}attributes={size:a?a+"":null,time:o?o+"":null,angle:l?l+"":null,color:c||null,easing:u||null,contrast:h||null,neutral:m||null,pre:i,mode:s,min:n?"":null};getAttribute(e){const t=this.attributes[e];return null!=t?Tt(t)?"":t+"":null}setAttribute(e,t){this.attributes[e]=t+"",Ft.has(e)&&this._customize()}removeAttribute(e){delete this.attributes[e]}theme;pre;mode;min;size;angle;time;color;easing;contrast;neutral;use;remake;css;cx;dx;get makers(){return this._c.makers}status;on;off;stylesheets;_c;_m;_s;_p;_;_n;_customize=()=>{const e=this.size,t=this.time,r=this.angle,s=this.color,n=this.easing,i=this.contrast,a=this.neutral,o=Jt({theme:this.theme,attrs:{size:e,time:t,angle:r,color:s,easing:n,contrast:i,neutral:a},scope:this._s(this._c.key())});this.remake(o,this._),this._=o};constructor(){Dt(this,{emulate:!0,onChange:this._customize,globalMaker:this._,noscript:t}),this._customize()}}},Qt=(e={})=>{const{emulate:t,global:r,...s}=e,n=globalThis?.document;let i;const a=globalThis[Kt];if(r&&a)i=a;else if(n&&!t){void 0===Qt.isDefined&&(Qt.isDefined=function(){const e=globalThis.document,t=globalThis.customElements;if(t?.get(gt))return!1;{class r extends HTMLScriptElement{static get observedAttributes(){return Ut}theme;pre;mode;min;size;angle;time;color;easing;contrast;neutral;use;remake;css;cx;dx;get makers(){return this._c.makers}status;on;off;stylesheets;_c;_m;_s;_p;_;_n;_customize=()=>{const e=this.size,t=this.time,r=this.angle,s=this.color,n=this.easing,i=this.contrast,a=this.neutral,o=Jt({theme:this.theme,attrs:{size:e,time:t,angle:r,color:s,easing:n,contrast:i,neutral:a},scope:this._s(this._c.key())});this.remake(o,this._),this._=o};attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){Dt(this,{initStyles:[...e.querySelectorAll(vt+`[${zt}]`)],onChange:this._customize,globalMaker:this._}),this._customize();const t=this;this._n={set adoptedStyleSheets(e){t.dispatchEvent(new CustomEvent(Ot,{detail:{styles:e},bubbles:!0}))}},this._m.register(this._n),this._m.register(e)}disconnectedCallback(){delete globalThis[Kt]}}t.define(gt,r,{extends:yt});class s extends HTMLElement{static get observedAttributes(){return[bt,...Ut]}_customize(){const e=Zt();if(this.shadowRoot&&e){const t=this.getAttribute(bt),r=new CSSStyleSheet,s=t?JSON.parse(decodeURIComponent(t)):{};Ut.forEach((e=>{const t=this.getAttribute(e);t&&t.split(Nt).forEach(((t,r)=>{s[Vt(e,r)]=t}))}));const{$dark:n={},$light:i={},...a}=e.theme.makeThemeVars(s),o=It(i),l=It(n);r.replaceSync(ft+`{${"display:contents;"+It(a)}}`+ft+`([scheme=light]){color-scheme:light;${o}}`+ft+`([scheme=dark]){color-scheme:dark;${l}}`+$t+`(${Pt}){${ft}{${o}}}`+$t+`(${qt}){${ft}{${l}}}`),this.shadowRoot.adoptedStyleSheets=[r]}}attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){this.attachShadow({mode:"open"}).innerHTML="<slot></slot>",this._customize()}}return t.define(pt,s),!0}}());const e=Zt();if(e)i=e;else{const e=n.createElement(yt,{is:gt});e.setAttribute("is",gt);const t=s?.attrs;t&&Object.entries(t).map((([t,r])=>r&&Et[t]!==r&&e.setAttribute(t,Tt(r)?"":r+""))),n.head.appendChild(e),i=e}}else i=Gt(s);return r&&!a&&(globalThis[Kt]=i),i},Xt=e=>encodeURIComponent(JSON.stringify(e));export{Et as DEFAULT_ATTRS,gt as TAG_NAME,pt as TAG_NAME_OVERRIDE,Xt as prepareOverrideValues,Qt as useStyleProvider};
|
|
7
|
+
const e=(e,t,r)=>Object.entries(e).reduce(t,r),t=(e,t)=>{return`${r=e,r.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))}:${""+t};`;var r},r=Symbol("noParse"),s=(n,i,a)=>{let o=""+n;return null==i?"":Array.isArray(i)?i.map((e=>t(o,e))).join(""):"object"!=typeof i||i.hasOwnProperty(r)?""===i?o+";":t(o,i):(!a||a.startsWith?.("@")||o.startsWith?.("&")||o.startsWith?.("@")?"":"&")+o+`{${e(i,((e,t)=>e+s(...t,o)),"")}}`},n="@layer",i="@starting-style",a=e=>`(${e})`,o=e=>"string"==typeof e,l={and:(...e)=>Object.defineProperties({type:"and",value:e},{toString:{value:()=>e.filter(Boolean).map((e=>{const t=p(e);return"object"==typeof e&&"or"===e.type?a(t):t})).join(" and ")}}),or:(...e)=>Object.defineProperties({type:"or",value:e},{toString:{value:()=>e.filter(Boolean).map((e=>p(e))).join(" or ")}}),not:e=>"object"==typeof e&&"not"===e.type?e.value[0]:Object.defineProperties({type:"not",value:[e]},{toString:{value:()=>`not (${p(e,!0)})`}})},c=e=>{const t=t=>({toString:()=>`(min-${e}:${o(t)?t:t+"rem"})`}),r=t=>({toString:()=>`(max-${e}:${o(t)?t:t+"rem"})`}),s=(e,s)=>({toString:()=>`${t(e)} and ${r(s)}`});return{up:t,down:r,between:s,only:e=>s(e,e)}},u=c("width"),h=c("height"),m=c("inline-size"),d=c("block-size"),p=(e,t)=>e?"string"==typeof e?e.includes("(")||t?e:a(e):e+"":"",g=(e={})=>{const{type:t,condition:r}=e,s=p(r),n="object"==typeof r&&"or"===r.type,i=`@media${t?" "+t:""}${t&&s?" and":""}${s?" "+(t&&n?a(s):s):""}`;return Object.defineProperties((e=>({[i]:e})),{all:{get:()=>g({condition:r,type:"all"})},print:{get:()=>g({condition:r,type:"print"})},screen:{get:()=>g({condition:r,type:"screen"})},where:{value:e=>g({condition:e,type:t})},toString:{value:()=>i}})},b=g({}),f=({condition:e}={})=>{const t=p(e),r="@supports"+(t?" "+t:"");return Object.defineProperties((e=>({[r]:e})),{where:{value:e=>f({condition:e})},toString:{value:()=>r}})},$=f(),y=e=>({[i]:e});y.toString=i;const v=e=>{const{root:t="",limit:r="",mode:s=[!1,!1]}=e,n=`@scope ${t?`(${t}${s[0]?" > *":""})`:""}${t&&r?" ":""}${r?`to (${r}${s[1]?" > *":""})`:""}`;return Object.defineProperties((e=>({[n]:e})),{limit:{value:e=>v({root:t,limit:e,mode:s})},root:{value:e=>v({root:e,limit:r,mode:s})},both:{value:()=>v({root:t,limit:r,mode:[!1,!0]})},none:{value:()=>v({root:t,limit:r,mode:[!0,!1]})},low:{value:()=>v({root:t,limit:r,mode:[!0,!0]})},high:{value:()=>v({root:t,limit:r,mode:[!1,!1]})},toString:{value:()=>n}})},x=v({}),w=(e,t)=>`calc(${e} * 1${t})`,j=e=>w(e,"px"),k=e=>w(e,"vh"),S=e=>w(e,"vw"),_=e=>w(e,"vmin"),A=e=>w(e,"vmax"),O=e=>w(e,"em"),z=e=>w(e,"rem"),C=e=>w(e,"deg"),P=e=>w(e,"rad"),q=e=>w(e,"rad"),E=e=>w(e,"ms"),N=e=>w(e,"s"),T=e=>w(e,"%"),R=e=>w(e,"cqw"),M=e=>w(e,"cqh"),B=e=>w(e,"cqi"),W=e=>w(e,"cqb"),I=e=>w(e,"cqmin"),V=e=>w(e,"cqmax"),J=Object.fromEntries,L=Object.entries,H=":first-",D=":last-",U=":only-",F="child",Z=":nth-",G="of-type",K=Z+F,Q=":focus",X="valid",Y="in"+X,ee=":user-",te="placeholder",re={r:":root",h:":hover",f:Q,fv:Q+"-visible",a:":active",v:":visited",val:":"+X,inv:":"+Y,uval:ee+X,uinv:ee+Y,e:":empty",d:":disabled",rq:":required",o:":optional",m:":modal",l:":link",phs:`:${te}-shown`,ch:":checked",po:":popover-open",fc:H+F,lc:D+F,oc:U+F,odd:K+"(odd)",even:K+"(even)",ft:H+G,lt:D+G,ot:U+G,bef:"::before",aft:"::after",ph:`::${te}`,bd:"::backdrop",fl:"::first-line",dc:"::details-content",sel:"::selection"},se={has:":has",not:":not",is:":is",wh:":where",st:":state",nthc:K,ntho:Z+G,dir:":dir",lang:":lang"},ne=e=>`oklch(${e})`,ie=e=>ne(`from ${e}`),ae=e=>t=>{if(!t)return e||"currentColor";const{l:r,c:s,h:n,a:i=1}=t;return ne(r&&s&&n?(e?`from ${e} `:"")+`${r} ${s} ${n} / ${i||(e?"alpha":1)}`:`from ${e||"currentColor"} ${r||"l"} ${s||"c"} ${n||"h"} / ${i||"alpha"}`)},oe=(e,t=.1)=>ie(`${e} calc(l + ${t}) c h / alpha`),le=(e,t=.1)=>ie(`${e} calc(l - ${t}) c h / alpha`),ce=(e,t=.1)=>ie(`${e} l c h / calc(alpha + ${t})`),ue=(e,t=.1)=>ie(`${e} l c h / calc(alpha - ${t})`),he=(e,t=.04)=>ie(`${e} l calc(c + ${t}) h / alpha`),me=(e,t=.04)=>ie(`${e} l calc(c - ${t}) h / alpha`),de=e=>ie(`${e} l c calc(h + 180) / alpha`),pe=e=>ie(`${e} l 0 h / alpha`),ge=(e,t=30)=>ie(`${e} l c calc(h${"number"==typeof t?t>0?" + "+t:" - "+-t:t}) / alpha`),be=e=>"string"==typeof e?ne(e):ae(e.from)(e),fe=e=>{const t=e("color"),r=e("contrast"),s=e("neutral");return{root:ae(t),contrast:ae(r),neutral:ae(s),oklch:be,lighten:oe,darken:le,saturate:he,desaturate:me,fadein:ce,fadeout:ue,spin:ge,complement:de,grayscale:pe}},$e=e=>{class t{state={l:"l",c:"base",h:"pri",a:"1",m:"bg"};constructor(e={}){Object.assign(this,{[r]:!0}),this.state=Object.assign(this.state,e)}get xs(){return new t({...this.state,l:"xs"})}get s(){return new t({...this.state,l:"s"})}get m(){return new t({...this.state,l:"m"})}get l(){return new t({...this.state,l:"l"})}get xl(){return new t({...this.state,l:"xl"})}get lightness(){return{xs:this.xs,s:this.s,m:this.m,l:this.l,xl:this.xl}}get gray(){return new t({...this.state,c:"gray"})}get pale(){return new t({...this.state,c:"pale"})}get base(){return new t({...this.state,c:"base"})}get rich(){return new t({...this.state,c:"rich"})}get chroma(){return{gray:this.gray,pale:this.pale,base:this.base,rich:this.rich}}get pri(){return new t({...this.state,h:"pri"})}get sec(){return new t({...this.state,h:"sec"})}get suc(){return new t({...this.state,h:"suc"})}get inf(){return new t({...this.state,h:"inf"})}get war(){return new t({...this.state,h:"war"})}get dan(){return new t({...this.state,h:"dan"})}get hue(){return{pri:this.pri,sec:this.sec,suc:this.suc,inf:this.inf,war:this.war,dan:this.dan}}alpha(e=1){return new t({...this.state,a:e+""})}get bg(){return new t({...this.state,m:"bg"})}get fg(){return new t({...this.state,m:"fg"})}toString(){const{l:t,c:r,h:s,a:n,m:i}=this.state;return`oklch(${e(`lightness.${i}.${t}`)} ${e(`chroma.${i}.${r}`)} ${e(`hue.${s}`)} / ${n})`}}return new t},ye=e=>{const t=(t,r=0)=>e(`coef.${t.state.center+r}`);class r{state={center:8};constructor(e={}){this.state=Object.assign(this.state,e)}get min(){return t(this,-4)}get xxs(){return t(this,-3)}get xs(){return t(this,-2)}get s(){return t(this,-1)}get m(){return t(this)}get l(){return t(this,1)}get xl(){return t(this,2)}get xxl(){return t(this,3)}get max(){return t(this,4)}get $xxs(){return new r({center:4})}get $xs(){return new r({center:8})}get $s(){return new r({center:12})}get $m(){return new r({center:16})}get $l(){return new r({center:20})}get $xl(){return new r({center:24})}get $xxl(){return new r({center:28})}get short(){return{s:this.s,m:this.m,l:this.l}}get base(){return{xs:this.xs,...this.short,xl:this.xl}}get long(){return{xxs:this.xxs,...this.base,xxl:this.xxl}}get full(){return{min:this.min,...this.long,max:this.max}}get main(){return{min:this.min,m:this.m,max:this.max}}get sparse(){return{min:this.min,xs:this.xs,m:this.m,xl:this.xl,max:this.max}}}return new r},ve=Object.assign,xe=Object.entries,we=Array.isArray,je=e=>"object"==typeof e,ke=(e,t)=>Array.from(Array(e).entries()).reduce(((e,[r])=>ve(e,t(r+1))),{}),Se=(e,t)=>xe(e).reduce(((e,[r,s])=>ve(e,t(r,s))),{}),_e=(e,t,r={})=>e?t:r,Ae=(...e)=>e.join("-"),Oe=(...e)=>e.join(),ze=(...e)=>e.join(" "),Ce=(e,...t)=>t.length?t.reduce(((e,t)=>(t&&e&&je(t)&&xe(t).forEach((([t,r])=>{r&&je(r)&&e[t]?we(e[t])&&we(r)?e[t]=[...e[t],...r]:Ce(e[t],r||{}):e[t]=r})),e)),e):e,Pe=(e,t,s="")=>{const n=(n=0)=>{const i=t(e),a=n?t(e+"-"+n,i):i;return Object.defineProperties(((e=1)=>`calc(${a} * ${e}${s})`),{toString:{value:()=>`calc(${a} * 1${s})`},[r]:{value:!0}})},i={get:(e,t,r)=>"symbol"==typeof t||Number.isNaN(+t)?Reflect.get(e,t,r):n(+t)};return new Proxy(n(),i)},qe=(e,t)=>{const s=(s=0)=>{const n=t(e),i=s?t(e+"-"+s,n):n;return Object.defineProperties({},{toString:{value:()=>i},[r]:{value:!0}})},n={get:(e,t,r)=>"symbol"==typeof t||Number.isNaN(+t)?Reflect.get(e,t,r):s(+t)};return new Proxy(s(),n)},Ee=Object.assign(J(L(re).map((([e,t])=>{function r(e=""){return e&&"object"==typeof e?{[t]:e}:e+t}return r.toString=()=>t,[e,r]}))),J(L(se).map((([e,t])=>{function r(e,r=""){const s=t+`(${e})`;return r&&"object"==typeof r?{[s]:r}:r+s}return r.toString=()=>t,[e,r]})))),Ne={px:j,vh:k,vw:S,vmin:_,vmax:A,em:O,rem:z,deg:C,rad:P,turn:q,ms:E,s:N,pc:T,cqw:R,cqh:M,cqb:W,cqi:B,cqmin:I,cqmax:V},Te=e=>1!==e?e+" * ":"",Re=t=>{const{scope:i,prefix:a}=t,o=i(a).varExp,c=(e=1)=>Ne.ms(Te(e)+o("time")),g=(e=1)=>Ne.deg(Te(e)+o("angle")),f=(e=1)=>Ne.px(Te(e)+o("size")),v=e=>e?`cubic-bezier(${e.x1||0},${e.y1||0},${e.x2||1},${e.y2||1})`:o("easing"),w={variable:o,tuning:o,time:Pe("time",o,"ms"),angle:Pe("angle",o,"deg"),size:Pe("size",o,"px"),space:Pe("space",o,"px"),easing:qe("easing",o),color:qe("color",o),contrast:qe("contrast",o),neutral:qe("neutral",o)};return{compile:({key:t,maker:a,mode:j})=>{const k=i(t,j);w.tuning=k.varExp;const S=k.selector,_=k.select,A=(e=>{const t={cp:1,lay:1,kf:1,cq:1},s=(n={})=>{const{scroll:i,type:a,name:o,condition:l}=n,c=p(l),u=`@container${o?" "+o:""}${c?" "+c:""}`;return Object.defineProperties((e=>({[u]:e})),{container:{value:(o||"none")+" / "+(a&&i?`${a} scroll-state`:i?"scroll-state":a||"normal"),enumerable:!0},named:{get:()=>s({scroll:i,condition:l,name:o||e.name(["cq",t.cq++]),type:a})},size:{get:()=>s({name:o,scroll:i,condition:l,type:"size"})},isize:{get:()=>s({name:o,scroll:i,condition:l,type:"inline-size"})},scroll:{get:()=>s({name:o,scroll:!0,condition:l,type:a})},where:{value:e=>s({name:o,scroll:i,condition:e,type:a})},[r]:{value:!0},toString:{value:()=>u}})},i=({name:r}={})=>{const s=`${n}${r?" "+r:""}`,a=e=>({[s]:e});return a.toString=()=>s,Object.defineProperties(a,{named:{get:()=>i({name:r||e.name(["lay",t.lay++])})},list:{value:(...e)=>({[n+(e.map((e=>(e+"").split(n)[1])).filter(Boolean).join(",")||r)]:""})}})};return{layer:i(),supports:$,keyframes:s=>{const n=e.name(["kf",t.kf++]),i="@keyframes "+n;return Object.defineProperties((e=>{if(!e)return{animationName:n};const{dur:t,tf:r,del:s,ic:i,dir:a,ps:o,fm:l}=e;return{animation:[t,r,s,i,a,o,l,n].filter(Boolean).join(" ")}}),{[i]:{value:s,enumerable:!0},toString:{value:()=>n},[r]:{value:!0}})},property:(s={})=>{let n,i,a='"*"',o=!0;"object"==typeof s?({syn:a=a,inh:o=o,ini:n,def:i}=s):(i=s,n=s,o=!1);const l="--"+e.name(["cp",t.cp++]),c=`var(${l}${void 0!==i?","+i:""})`,u="@property "+l;return Object.defineProperties((e=>({[l]:e})),{[u]:{value:{syntax:a,inherits:o,initialValue:n},enumerable:!0},toString:{value:()=>c},fallback:{value:e=>`var(${l},${e})`},[r]:{value:!0}})},scope:x,media:b,container:s({}),startingStyle:y,$logic:l,$width:u,$height:h,$block:d,$inline:m}})(k),O=a({dash:Ae,comma:Oe,space:ze,range:ke,each:Se,when:_e,merge:Ce,theme:w,themeVar:o,size:f,time:c,angle:g,easing:v,bem:S,select:_,pseudo:Ee,color:fe(o),palette:$e(o),coef:ye(o),units:Ne,at:A});return"string"==typeof O?O:(t=>e(t,((e,t)=>e+s(...t)),""))(O)}}},Me=Symbol("effcss-stylesheet");class Be{disabled=!1;cssRules=[];replaceSync(e){e&&(this.cssRules=[{cssText:e}])}}function We({initStyles:e,emulate:t}={}){const r={};e?.forEach((e=>{const t=e?.dataset?.effcss;t&&(r[t]=e)}));let s={},n={},i=[],a=[];const o=(e,t)=>t.hasOwnProperty(Me)?t:Object.defineProperties(t,{[Me]:{value:e}}),l=e=>e.adoptedStyleSheets=[...e.adoptedStyleSheets?.length?[...e.adoptedStyleSheets].filter((e=>!e.hasOwnProperty(Me))):[],...i],c=()=>{a=a.reduce(((e,t)=>{const r=t.deref();return r&&(l(r),e.push(t)),e}),[])},u=e=>e?s[e]:void 0,h=(e,t)=>{if(!s[e]){s[e]=o(e,t),i.push(s[e]);const n=r[e];return n&&(n.disabled=!0),c(),!0}};return{get:u,all:()=>s,add:h,status:e=>{const t=u(e);return!t?.disabled},on:(...e)=>{e.forEach((e=>{const t=u(e);t&&(t.disabled=!1)})),c()},off:(...e)=>{e.forEach((e=>{const t=u(e);t&&(t.disabled=!0)})),c()},remove:e=>{const t=u(e);if(!t)return;const r=(a=t,i.findIndex((e=>e===a)));var a;return r>-1&&(i.splice(r,1),delete s[e],delete n[e]),c(),!0},removeAll:()=>(i.splice(0),s={},n={},c(),!0),pack:(e,r)=>{let n=s[e]||(!t&&globalThis.CSSStyleSheet?new globalThis.CSSStyleSheet:new Be);return n.replaceSync(r),n=o(e,n),!!n.cssRules.length&&h(e,n)},register:e=>{a.findIndex((t=>t.deref()===e))>=0||(a.push(new WeakRef(e)),l(e))},unregister:e=>{const t=a.findIndex((t=>t.deref()===e));t>=0&&a.splice(t,1)},hydrate:e=>r[e]&&!r[e].disabled&&r[e].textContent||void 0}}const Ie=({prefix:e})=>{let t=0;return{get initial(){return e},get current(){return e+(t||"")},next(){return t++,this.current}}},Ve=({prefix:e})=>{const t=new Set,r=new Map,s=Ie({prefix:e});return{use(e){let n=this.key(e);return n||(n=s.current,t.add(n),r.set(e,n),s.next(),n)},remake(e,t){const s=r.get(t);return s?(r.delete(t),r.set(e,s),s):this.use(e)},key:e=>e?r.get(e)||"":s.initial,get keys(){return[...t]},get makers(){return Object.fromEntries(r.entries().map((([e,t])=>[t,e])))}}},Je=void 0,Le=Object.entries,He=Object.defineProperties,De=e=>"string"==typeof e,Ue=e=>null!==e&&"object"==typeof e,Fe=e=>e.split("."),Ze=(e,t="")=>Le(e).reduce(((e,[r,s])=>{const n=t?`${t}-${r}`:r;return"object"==typeof s?(e.add(n),e=e.union(Ze(s,n))):e.add(n+`_${s}`),e}),new Set),Ge=(e,t="")=>Le(e).reduce(((e,[r,s])=>{const n=t?`${t}-${r}`:r;if("object"==typeof s){const t=Ge(s,n);t.size||e.add(n),e=e.union(t)}else t&&e.add(t),e.add(n+`_${s}`);return e}),new Set),Ke=(e,t)=>Le(e).reduce(((e,[r,s])=>{if(Ue(s)){const n=Le(s);n.length?e.push(...n.reduce(((e,[s,n])=>{if((e=>null!==e&&e!==Je)(s)&&t&&e.push([r,s,Je,Je]),Ue(n)){const t=Le(n);t.length&&e.push(...t.reduce(((e,[t,n])=>{const i=typeof n;return"string"!==i&&"number"!==i||e.push([r,s,t,n]),e}),[]))}return e}),[])):e.push([r,Je,Je,Je])}return e}),[]),Qe=(e,t,r,s)=>""+(((e,t)=>`${e||""}${t?"__"+t:""}`)(e,t)+(r?"_"+r:"")+(r&&s?"_"+s:""))||"_",Xe=(e,t)=>"."+(t?e+(t.startsWith("_")?"":"-")+t:e),Ye=(e,t)=>`[data-${e}${t?`~="${t}"`:""}]`;const et=e=>e||"",tt=Object.assign,rt=Object.entries,st="theme",nt="delete",it="update",at="$light",ot="$dark",lt="lightness",ct="chroma",ut=e=>Number((.1*184+.9*e).toFixed(2)),ht={time:200,size:16,space:12,angle:30,color:"#2192a7",contrast:"light-dark(black, white)",neutral:"light-dark(white, #1b1f1f)",easing:"linear",coef:{0:0,1:.0625,2:.125,3:.25,4:.5,5:.75,6:.875,7:.9375,8:1,9:1.0625,10:1.125,11:1.25,12:1.5,13:1.75,14:1.875,15:1.9375,16:2,17:3,18:4,19:5,20:7.5,21:10,22:12,23:15,24:16,25:20,26:28,27:36,28:48,29:64,30:80,31:120,32:150},hue:{pri:184,sec:290,suc:ut(142),inf:ut(264),war:ut(109),dan:ut(29)},[at]:{[lt]:{bg:{xl:1,l:.94,m:.88,s:.83,xs:.78},fg:{xl:0,l:.12,m:.24,s:.36,xs:.48}},[ct]:{bg:{gray:0,pale:.01,base:.04,rich:.7},fg:{gray:0,pale:.07,base:.11,rich:.15}}},[ot]:{[lt]:{bg:{xl:.24,l:.3,m:.36,s:.42,xs:.48},fg:{xl:1,l:.93,m:.86,s:.79,xs:.72}},[ct]:{bg:{pale:.02,base:.06,rich:.1},fg:{pale:.06,base:.1,rich:.14}}}},mt=({provider:e,init:t,scope:r,onChange:s})=>{const n={"":ht},i=[],a=({$light:e={},$dark:t={},...s})=>{function n(e,t=[]){return rt(e).reduce(((e,[s,i])=>Array.isArray(i)?(i.forEach(((n,i)=>{e[r.varName([...t,s,i])]=n})),e):i&&"object"==typeof i?tt(e,n(i,s?[...t,s]:t)):(e[r.varName([...t,s])]=i,e)),{})}return{...n(s),[at]:n(e),[ot]:n(t)}},o={get:(e="")=>n[e],add(e,t){n[t]||(n[t]=Ce({[at]:{},[ot]:{}},e),i.push({type:"add",payload:{params:e,name:t}}),s?.())},delete(e){e&&n[e]&&(this.current===e&&this.switch(),delete n[e],i.push({type:nt,payload:{name:e}}),s?.())},update(e,t=""){const r=n[t];if(r){let a;a="function"==typeof e?e(r):e,n[t]=Ce({[at]:{},[ot]:{}},r,a),i.push({type:it,payload:{params:e,name:t}}),s?.()}},switch(t=""){n[t]&&e.setAttribute(st,t)},vars(e=""){const t=this.get(e);return t?a(t):{[at]:{},[ot]:{}}},makeThemeVars:a,get list(){const{"":e,...t}=n;return Object.keys(t)},get current(){return e.getAttribute(st)||""},get all(){return n},get actions(){return i}};return t?.forEach((({type:e,payload:t})=>{switch(e){case"add":o.add(t.params,t.name);break;case nt:o.delete(t.name);break;case it:o.update(t.params,t.name)}})),o},dt="effcss",pt=dt+"-provider",gt=dt+"-override",bt="values",ft=":host",$t="@media",yt="script",vt="style",xt="size",wt="space",jt="time",kt="angle",St="color",_t="contrast",At="neutral",Ot="easing",zt=dt+"changes",Ct="data-"+dt,Pt="prefers-color-scheme",qt=`${Pt}: light`,Et=`${Pt}: dark`,Nt={mode:"a",pre:"f"},Tt=";",Rt=e=>"boolean"==typeof e,Mt=e=>"string"==typeof e?Number(e):null,Bt=(e,t)=>{const r=((e,t)=>e.getAttribute(t)||Nt[t])(e,t);if(!r)return Mt(r);const s=r.split(Tt);return s.length>1?s.map(Mt):Mt(r)},Wt=(e,t,r)=>null===r?e.removeAttribute(t):e.setAttribute(t,Array.isArray(r)?r.join(Tt):r+""),It=e=>`:root:has([is=${pt}]${e?`[${e}]`:""})`,Vt=e=>Object.entries(e).reduce(((e,[t,r])=>e+t+":"+r+";"),""),Jt=(e,t)=>e+(+t?"-"+t:""),Lt=({theme:e,attrs:t,scope:r})=>({bem:s,each:n,themeVar:i,merge:a,pseudo:{r:o},at:{media:l},units:{px:c}})=>{const{$dark:u={},$light:h={},...m}=e.vars();return a({[It()]:{...m,...l.where(qt)(h),...l.where(Et)(u),[o()]:{fontSize:c(i("size"))}}},n(e.list,((t,r)=>{const{$dark:n={},$light:i={},...a}=e.vars(r),o={...a,...l.where(qt)(i),...l.where(Et)(n)};return{[It(`theme=${t}`)]:o,[s(`..theme.${t}`)]:o}})),...Object.entries(t).map((([e,t])=>t&&{[It(e)]:n(Array.isArray(t)?t:[t],((t,s)=>({[r.varName(Jt(e,+t))]:s})))})))},Ht=(e,t)=>({set(r){Wt(e,t,r)},get:()=>Bt(e,t)}),Dt=(e,t)=>({set(r){Wt(e,t,r)},get(){const r=e.getAttribute(t);if(!r)return r;const s=r.split(Tt);return s.length>1?s:r}}),Ut=(e,{initStyles:t,emulate:r,onChange:s,globalMaker:n,noscript:i})=>{let a;e.textContent&&(a=JSON.parse(e.textContent)),Object.defineProperties(e,{pre:{get:()=>e.getAttribute("pre")||"f"},mode:{get:()=>e.getAttribute("mode")||"a"},min:{get:()=>""===e.getAttribute("min")},size:Ht(e,xt),space:Ht(e,wt),time:Ht(e,jt),angle:Ht(e,kt),color:Dt(e,St),easing:Dt(e,Ot),contrast:Dt(e,_t),neutral:Dt(e,At)});const o=e.pre,l=Ve({prefix:o}),c=((e={})=>{const{mode:t,min:r,dict:s={}}=e,n=(e,r=t)=>{let s;s="a"===r?Ye:Xe;let i=0,a=et,o=et;const l=n.dict;l&&(l[e]||(l[e]={}),a=t=>l[e][t]??(l[e][t]=(i++).toString(36)),o=t=>l[e][t]);let c=t=>[e,...De(t)?t.split("."):t].filter(Boolean).join("-"),u="class",h=t=>t?e+(t.startsWith("_")?"":"-")+t:void 0===t?void 0:e;"a"===r&&(u="data-"+e,h=et);const m=e=>"--"+c(De(e)?e.split("."):e),d=e=>He({[u]:e},{toString:{value:()=>`${u}="${e}"`},$:{value:e}}),p=e=>{if(void 0===e)return function(e){const t=({b:r,e:s,m:n})=>({b:e=>t({b:e,e:"",m:{}}),e:e=>t({b:r,e:e,m:{}}),m:(e={})=>t({b:r,e:s,m:e}),get $(){return e({[r]:{[s]:n}})}});return t({b:"",e:"",m:{}})}(p);let t,r,s,n,i="";const a=De(e);return i=a||Array.isArray(e)?[...(a?[e]:e).reduce(((e,i)=>([t,r,s,n]=Fe(i),e.add(h(o(Qe(t,r)))),s&&e.add(h(o(Qe(t,r,s,n)))),e)),new Set).values()].join(" "):e&&Ke(e,!0).map((([e,t,r,s])=>h(o(Qe(e,t,r,s))))).join(" "),d(i)};return p.list=(...e)=>{const t=[...e.reduce(((e,t)=>{const[r,s]=t.split(":");if(!r)return e;if(void 0===s)return e.add(r.replaceAll(".","-")),e;const n=r.split("."),i=n.pop(),a=n.join("-");return n.length?(e.add(a),e.add(a+`-${i}_${s}`)):e.add(`${i}_${s}`),e}),new Set).keys()].map((e=>h(o(e)))).join(" ");return d(t)},p.obj=(e,t)=>{let r=Ge;"full"===t&&(r=Ze);const s=[...r(e).values()].map((e=>h(o(e)))).join(" ");return d(s)},{select:t=>{const r=t.replaceAll(".","-").replace(":","_");return s(e,a(r))},selector:t=>{const[r,n,i,o]=Fe(t);return s(e,a(Qe(r,n,i,o)))},attr:p,name:c,varName:m,varExp:(e,t)=>`var(${m(e)}${void 0!==t?","+t:""})`}};return r&&(n.dict=s),n})({mode:e.mode,min:e.min,dict:a?.dict}),u=c(l.key()),h=Re({scope:c,prefix:o}),m=We({initStyles:t,emulate:r});e.theme=mt({provider:e,init:a?.theme,onChange:s,scope:u});const d=(({scope:e,collector:t,manager:r,processor:s,globalMaker:n})=>{const i=e=>"string"==typeof e?e:t.key(e),a=(r,s)=>e(r||t.key(),s).attr,o=(e,t,r)=>s.compile({key:t,maker:e,mode:r}),l=(e,s)=>{let n=t.use(e);return r&&!r.get(n)&&r.pack(n,r.hydrate(n)||o(e,n,s)),a(n,s)},c=(...e)=>0===e.length?[l(n)]:e.map((e=>l(e))),u=(e,t)=>{const r=l(e,"c");return Array.isArray(t)?r.list(...t).$:r.obj(t).$};u.join=(...e)=>e.reduce(((e,t)=>t?e?e+" "+t:t||"":e),"");const h=(e,t)=>{const r=l(e,"a");return Array.isArray(t)?r.list(...t):r.obj(t)};return h.join=(...e)=>e.reduce(((e,t)=>t?{...e,...t}:e),{}),{use:c,remake:(e,s)=>{let n=t.key(s||e);return r&&r.get(n)?(s&&t.remake(e,s),r.pack(n,r.hydrate(n)||o(e,n)),a(n)):c(e)[0]},css:o,cx:u,dx:h,tune:(r,s)=>{const n=t.key(s);let i={};if(n){const a=e(n);function o(e,t){"object"!=typeof t?i[a.varName(e)]=t:Object.entries(t).map((([t,r])=>{o(t&&e?e+"-"+t:e||t,r)}))}o("",r)}return i},status:e=>{const t=i(e);return!!t&&r.status(t)},on:(...e)=>r.on(...e.map(i)),off:(...e)=>r.off(...e.map(i)),stylesheets:(e=t.keys)=>e.map((e=>r.get(i(e))))}})({scope:c,processor:h,manager:m,collector:l,globalMaker:n});Object.defineProperties(e,{_c:{value:l},_s:{value:c},_p:{value:h},_m:{value:m},toString:{value:()=>{const t={...m.all()},r=Object.entries(t).filter((([e,t])=>!t.disabled)).map((([e,t])=>`<style ${Ct}="${e}">${[...t.cssRules].map((e=>e.cssText)).join("")}</style>`)).join("");let s=vt,n="";const a={is:pt,min:e.getAttribute("min"),mode:e.getAttribute("mode"),size:e.getAttribute(xt),space:e.getAttribute(wt),time:e.getAttribute(jt),angle:e.getAttribute(kt),color:e.getAttribute(St),easing:e.getAttribute(Ot),contrast:e.getAttribute(_t),neutral:e.getAttribute(At)};if(!i){s=yt,a.type="application/json";const t={theme:e.theme.actions,dict:c.dict};n=JSON.stringify(t)}return r+`<${s} ${Object.entries(a).map((([e,t])=>null!=t&&t!==Nt[e]?""===t?e:`${e}="${t}"`:"")).filter(Boolean).join(" ")}${e.theme.current?` theme="${e.theme.current}"`:""}>${n}</${s}>`}}}),Object.assign(e,d)},Ft=Symbol(pt),Zt=[xt,wt,jt,kt,St,Ot,_t,At],Gt=new Set(Zt),Kt=()=>globalThis?.document.querySelector(`[is=${pt}]`);const Qt=(e={})=>{let{noscript:t,attrs:r={}}=e,{mode:s=Nt.mode,min:n,pre:i=Nt.prefix,size:a=null,space:o=null,time:l=null,angle:c=null,easing:u=null,color:h=null,contrast:m=null,neutral:d=null}=r;return new class{get tagName(){return""}get textContent(){return""}attributes={size:a?a+"":null,space:o?o+"":null,time:l?l+"":null,angle:c?c+"":null,color:h||null,easing:u||null,contrast:m||null,neutral:d||null,pre:i,mode:s,min:n?"":null};getAttribute(e){const t=this.attributes[e];return null!=t?Rt(t)?"":t+"":null}setAttribute(e,t){this.attributes[e]=t+"",Gt.has(e)&&this._customize()}removeAttribute(e){delete this.attributes[e]}theme;pre;mode;min;size;space;angle;time;color;easing;contrast;neutral;use;remake;css;cx;dx;tune;get makers(){return this._c.makers}status;on;off;stylesheets;_c;_m;_s;_p;_;_n;_customize=()=>{const e=this.size,t=this.space,r=this.time,s=this.angle,n=this.color,i=this.easing,a=this.contrast,o=this.neutral,l=Lt({theme:this.theme,attrs:{size:e,space:t,time:r,angle:s,color:n,easing:i,contrast:a,neutral:o},scope:this._s(this._c.key())});this.remake(l,this._),this._=l};constructor(){Ut(this,{emulate:!0,onChange:this._customize,globalMaker:this._,noscript:t}),this._customize()}}},Xt=(e={})=>{const{emulate:t,global:r,...s}=e,n=globalThis?.document;let i;const a=globalThis[Ft];if(r&&a)i=a;else if(n&&!t){void 0===Xt.isDefined&&(Xt.isDefined=function(){const e=globalThis.document,t=globalThis.customElements;if(t?.get(pt))return!1;{class r extends HTMLScriptElement{static get observedAttributes(){return Zt}theme;pre;mode;min;size;space;angle;time;color;easing;contrast;neutral;use;remake;css;cx;dx;tune;get makers(){return this._c.makers}status;on;off;stylesheets;_c;_m;_s;_p;_;_n;_customize=()=>{const e=this.size,t=this.space,r=this.time,s=this.angle,n=this.color,i=this.easing,a=this.contrast,o=this.neutral,l=Lt({theme:this.theme,attrs:{size:e,space:t,time:r,angle:s,color:n,easing:i,contrast:a,neutral:o},scope:this._s(this._c.key())});this.remake(l,this._),this._=l};attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){Ut(this,{initStyles:[...e.querySelectorAll(vt+`[${Ct}]`)],onChange:this._customize,globalMaker:this._}),this._customize();const t=this;this._n={set adoptedStyleSheets(e){t.dispatchEvent(new CustomEvent(zt,{detail:{styles:e},bubbles:!0}))}},this._m.register(this._n),this._m.register(e)}disconnectedCallback(){delete globalThis[Ft]}}t.define(pt,r,{extends:yt});class s extends HTMLElement{static get observedAttributes(){return[bt,...Zt]}_customize(){const e=Kt();if(this.shadowRoot&&e){const t=this.getAttribute(bt),r=new CSSStyleSheet,s=t?JSON.parse(decodeURIComponent(t)):{};Zt.forEach((e=>{const t=this.getAttribute(e);t&&t.split(Tt).forEach(((t,r)=>{s[Jt(e,r)]=t}))}));const{$dark:n={},$light:i={},...a}=e.theme.makeThemeVars(s),o=Vt(i),l=Vt(n);r.replaceSync(ft+`{${"display:contents;"+Vt(a)}}`+ft+`([scheme=light]){color-scheme:light;${o}}`+ft+`([scheme=dark]){color-scheme:dark;${l}}`+$t+`(${qt}){${ft}{${o}}}`+$t+`(${Et}){${ft}{${l}}}`),this.shadowRoot.adoptedStyleSheets=[r]}}attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){this.attachShadow({mode:"open"}).innerHTML="<slot></slot>",this._customize()}}return t.define(gt,s),!0}}());const e=Kt();if(e)i=e;else{const e=n.createElement(yt,{is:pt});e.setAttribute("is",pt);const t=s?.attrs;t&&Object.entries(t).map((([t,r])=>r&&Nt[t]!==r&&e.setAttribute(t,Rt(r)?"":r+""))),n.head.appendChild(e),i=e}}else i=Qt(s);return r&&!a&&(globalThis[Ft]=i),i},Yt=e=>encodeURIComponent(JSON.stringify(e));export{Nt as DEFAULT_ATTRS,pt as TAG_NAME,gt as TAG_NAME_OVERRIDE,Yt as prepareOverrideValues,Xt as useStyleProvider};
|
|
@@ -101,10 +101,20 @@ export interface IMakerParams {
|
|
|
101
101
|
* @param fallback - fallback value
|
|
102
102
|
*/
|
|
103
103
|
variable: TScope['varExp'];
|
|
104
|
+
/**
|
|
105
|
+
* Get tuning value
|
|
106
|
+
* @param name - name
|
|
107
|
+
* @param fallback - fallback value
|
|
108
|
+
*/
|
|
109
|
+
tuning: TScope['varExp'];
|
|
104
110
|
/**
|
|
105
111
|
* Size variable
|
|
106
112
|
*/
|
|
107
113
|
size: TProxyNumVar;
|
|
114
|
+
/**
|
|
115
|
+
* Space variable
|
|
116
|
+
*/
|
|
117
|
+
space: TProxyNumVar;
|
|
108
118
|
/**
|
|
109
119
|
* Time variable
|
|
110
120
|
*/
|
|
@@ -144,7 +154,7 @@ export type TProcessor = {
|
|
|
144
154
|
};
|
|
145
155
|
type TCreateProcessor = (params: {
|
|
146
156
|
scope: ReturnType<TCreateScope>;
|
|
147
|
-
|
|
157
|
+
prefix: string;
|
|
148
158
|
}) => TProcessor;
|
|
149
159
|
/**
|
|
150
160
|
* Create style processor
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type Paths<T> = T extends object ? {
|
|
2
2
|
[K in keyof T]: `${Exclude<K, symbol>}${'' | Paths<T[K]> extends '' ? '' : `.${Paths<T[K]>}`}`;
|
|
3
3
|
}[keyof T] : T extends string ? T : never;
|
|
4
|
-
type TDeepPartial<T> = T extends object ? {
|
|
4
|
+
export type TDeepPartial<T> = T extends object ? {
|
|
5
5
|
[P in keyof T]?: TDeepPartial<T[P]>;
|
|
6
6
|
} : T;
|
|
7
7
|
type TBlocks<T> = Exclude<keyof T, symbol | number>;
|
|
@@ -28,7 +28,7 @@ export type TThemeController = {
|
|
|
28
28
|
get(name?: string): TThemeValue;
|
|
29
29
|
add(params: TThemeValue, name: string): void;
|
|
30
30
|
delete(name: string): void;
|
|
31
|
-
update(params: TThemeValue, name?: string): void;
|
|
31
|
+
update(params: TThemeValue | ((prev: object) => object), name?: string): void;
|
|
32
32
|
switch(name?: string): void;
|
|
33
33
|
vars<T extends object = object>(theme?: string): TThemeParams<T>;
|
|
34
34
|
makeThemeVars<T extends object>(params: TThemeParams<T>): TThemeValue;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TProcessor } from './_provider/process';
|
|
2
2
|
import type { TCollector } from './_provider/collect';
|
|
3
|
+
import type { TDeepPartial } from './_provider/scope';
|
|
3
4
|
import type { TDetails, TScopeResolver, TStyles } from './_provider/scope';
|
|
4
5
|
import type { TThemeController } from './_provider/theme';
|
|
5
6
|
export type { TShortRange, TMainRange, TBaseRange, TLongRange, TFullRange, TSparseRange } from './_provider/_process/coef';
|
|
@@ -13,6 +14,10 @@ type TAttrs = {
|
|
|
13
14
|
* Root font size in px
|
|
14
15
|
*/
|
|
15
16
|
size: number;
|
|
17
|
+
/**
|
|
18
|
+
* Root space variable in px
|
|
19
|
+
*/
|
|
20
|
+
space: number;
|
|
16
21
|
/**
|
|
17
22
|
* Root time in ms
|
|
18
23
|
*/
|
|
@@ -171,9 +176,18 @@ export interface IStyleProvider {
|
|
|
171
176
|
get size(): TNumberAttr;
|
|
172
177
|
/**
|
|
173
178
|
* Set root size value
|
|
174
|
-
* @param val -
|
|
179
|
+
* @param val - variable value in px
|
|
175
180
|
*/
|
|
176
181
|
set size(val: TNumberAttr);
|
|
182
|
+
/**
|
|
183
|
+
* Get root space value
|
|
184
|
+
*/
|
|
185
|
+
get space(): TNumberAttr;
|
|
186
|
+
/**
|
|
187
|
+
* Set root space value
|
|
188
|
+
* @param val - variable value in px
|
|
189
|
+
*/
|
|
190
|
+
set space(val: TNumberAttr);
|
|
177
191
|
/**
|
|
178
192
|
* Get root time value
|
|
179
193
|
*/
|
|
@@ -253,6 +267,12 @@ export interface IStyleProvider {
|
|
|
253
267
|
* Data attributes expression resolver
|
|
254
268
|
*/
|
|
255
269
|
dx: DX;
|
|
270
|
+
/**
|
|
271
|
+
* Tune stylesheet
|
|
272
|
+
* @param maker - stylesheet maker
|
|
273
|
+
* @param tunings - tunings object
|
|
274
|
+
*/
|
|
275
|
+
tune<T extends object>(tunings: TDeepPartial<T>, maker?: TStyleSheetMaker): object;
|
|
256
276
|
/**
|
|
257
277
|
* Is stylesheet on
|
|
258
278
|
* @param key - stylesheet key
|