effcss 4.4.0 → 4.5.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/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* EffCSS v4.
|
|
2
|
+
* EffCSS v4.5.0
|
|
3
3
|
* {@link https://gitverse.ru/msabitov/effcss}
|
|
4
4
|
* Copyright (c) Marat Sabitov
|
|
5
5
|
* @license Apache-2.0
|
|
6
6
|
*/
|
|
7
|
-
function e(e,t){var s={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(s[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(s[r[n]]=e[r[n]])}return s}"function"==typeof SuppressedError&&SuppressedError;const t=(e,t,s)=>Object.entries(e).reduce(t,s),s=(e,t)=>{return`${s=e,s.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))}:${""+t};`;var s},r=Symbol("noParse"),n=(e,i,a)=>{var o,l,c;let u=""+e;return null==i?"":Array.isArray(i)?i.map((e=>s(u,e))).join(""):"object"!=typeof i||i.hasOwnProperty(r)?""===i?u+";":s(u,i):(!a||(null===(o=a.startsWith)||void 0===o?void 0:o.call(a,"@"))||(null===(l=u.startsWith)||void 0===l?void 0:l.call(u,"&"))||(null===(c=u.startsWith)||void 0===c?void 0:c.call(u,"@"))?"":"&")+u+`{${t(i,((e,t)=>e+n(...t,u)),"")}}`},i="@layer",a="@starting-style",o=e=>`(${e})`,l=e=>"string"==typeof e,c={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?o(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)})`}})},u=e=>{const t=t=>({toString:()=>`(min-${e}:${l(t)?t:t+"rem"})`}),s=t=>({toString:()=>`(max-${e}:${l(t)?t:t+"rem"})`}),r=(e,r)=>({toString:()=>`${t(e)} and ${s(r)}`});return{up:t,down:s,between:r,only:e=>r(e,e)}},h=u("width"),g=u("height"),m=u("inline-size"),d=u("block-size"),p=(e,t)=>e?"string"==typeof e?e.includes("(")||t?e:o(e):e+"":"",b=(e={})=>{const{type:t,condition:s}=e,r=p(s),n="object"==typeof s&&"or"===s.type,i=`@media${t?" "+t:""}${t&&r?" and":""}${r?" "+(t&&n?o(r):r):""}`;return Object.defineProperties((e=>({[i]:e})),{all:{get:()=>b({condition:s,type:"all"})},print:{get:()=>b({condition:s,type:"print"})},screen:{get:()=>b({condition:s,type:"screen"})},where:{value:e=>b({condition:e,type:t})},toString:{value:()=>i}})},f=b({}),$=({condition:e}={})=>{const t=p(e),s="@supports"+(t?" "+t:"");return Object.defineProperties((e=>({[s]:e})),{where:{value:e=>$({condition:e})},toString:{value:()=>s}})},y=$(),v=e=>({[a]:e});v.toString=a;const j=e=>{const{root:t="",limit:s="",mode:r=[!1,!1]}=e,n=`@scope ${t?`(${t}${r[0]?" > *":""})`:""}${t&&s?" ":""}${s?`to (${s}${r[1]?" > *":""})`:""}`;return Object.defineProperties((e=>({[n]:e})),{limit:{value:e=>j({root:t,limit:e,mode:r})},root:{value:e=>j({root:e,limit:s,mode:r})},both:{value:()=>j({root:t,limit:s,mode:[!1,!0]})},none:{value:()=>j({root:t,limit:s,mode:[!0,!1]})},low:{value:()=>j({root:t,limit:s,mode:[!0,!0]})},high:{value:()=>j({root:t,limit:s,mode:[!1,!1]})},toString:{value:()=>n}})},O=j({}),x=(e,t)=>`calc(${e} * 1${t})`,w=e=>x(e,"px"),k=e=>x(e,"vh"),S=e=>x(e,"vw"),_=e=>x(e,"vmin"),A=e=>x(e,"vmax"),z=e=>x(e,"em"),P=e=>x(e,"rem"),q=e=>x(e,"deg"),C=e=>x(e,"rad"),E=e=>x(e,"rad"),N=e=>x(e,"ms"),T=e=>x(e,"s"),M=e=>x(e,"%"),B=e=>x(e,"cqw"),W=e=>x(e,"cqh"),R=e=>x(e,"cqi"),I=e=>x(e,"cqb"),V=e=>x(e,"cqmin"),D=e=>x(e,"cqmax"),J=Object.fromEntries,K=Object.entries,L=":first-",F=":last-",H=":only-",Z="child",G=":nth-",Q="of-type",U=G+Z,X=":focus",Y="valid",ee="in"+Y,te=":user-",se={r:":root",h:":hover",f:X,fv:X+"-visible",a:":active",v:":visited",val:":"+Y,inv:":"+ee,uval:te+Y,uinv:te+ee,e:":empty",d:":disabled",rq:":required",o:":optional",m:":modal",l:":link",ph:":placeholder",ch:":checked",po:":popover-open",fc:L+Z,lc:F+Z,oc:H+Z,odd:U+"(odd)",even:U+"(even)",ft:L+Q,lt:F+Q,ot:H+Q,bef:"::before",aft:"::after",bd:"::backdrop"},re={has:":has",not:":not",is:":is",wh:":where",st:":state",nthc:U,ntho:G+Q,dir:":dir",lang:":lang"},ne=e=>`oklch(${e})`,ie=e=>ne(`from ${e}`),ae=(e,t=.1)=>ie(`${e} calc(l + ${t}) c h / alpha`),oe=(e,t=.1)=>ie(`${e} calc(l - ${t}) c h / alpha`),le=(e,t=.1)=>ie(`${e} l c h / calc(alpha + ${t})`),ce=(e,t=.1)=>ie(`${e} l c h / calc(alpha - ${t})`),ue=(e,t=.04)=>ie(`${e} l calc(c + ${t}) h / alpha`),he=(e,t=.04)=>ie(`${e} l calc(c - ${t}) h / alpha`),ge=(e,t=30)=>ie(`${e} l c calc(h${"number"==typeof t?t>0?" + "+t:" - "+-t:t}) / alpha`),me=e=>{const t=e("color");return{root:e=>e?ie(t+` ${e.l||"l"} ${e.c||"c"} ${e.h||"h"} / ${e.a||"1"}`):t,oklch:ne,lighten:ae,darken:oe,saturate:ue,desaturate:he,fadein:le,fadeout:ce,spin:ge}},de=e=>{class t{constructor(e={}){this.state={l:"l",c:"base",h:"pri",a:1,m:"bg"},Object.assign(this,{[r]:!0}),this.state=Object.assign(this.state,e)}get xs(){return new t(Object.assign(Object.assign({},this.state),{l:"xs"}))}get s(){return new t(Object.assign(Object.assign({},this.state),{l:"s"}))}get m(){return new t(Object.assign(Object.assign({},this.state),{l:"m"}))}get l(){return new t(Object.assign(Object.assign({},this.state),{l:"l"}))}get xl(){return new t(Object.assign(Object.assign({},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(Object.assign(Object.assign({},this.state),{c:"gray"}))}get pale(){return new t(Object.assign(Object.assign({},this.state),{c:"pale"}))}get base(){return new t(Object.assign(Object.assign({},this.state),{c:"base"}))}get rich(){return new t(Object.assign(Object.assign({},this.state),{c:"rich"}))}get chroma(){return{gray:this.gray,pale:this.pale,base:this.base,rich:this.rich}}get pri(){return new t(Object.assign(Object.assign({},this.state),{h:"pri"}))}get sec(){return new t(Object.assign(Object.assign({},this.state),{h:"sec"}))}get suc(){return new t(Object.assign(Object.assign({},this.state),{h:"suc"}))}get inf(){return new t(Object.assign(Object.assign({},this.state),{h:"inf"}))}get war(){return new t(Object.assign(Object.assign({},this.state),{h:"war"}))}get dan(){return new t(Object.assign(Object.assign({},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(Object.assign(Object.assign({},this.state),{a:e}))}get bg(){return new t(Object.assign(Object.assign({},this.state),{m:"bg"}))}get fg(){return new t(Object.assign(Object.assign({},this.state),{m:"fg"}))}toString(){const{l:t,c:s,h:r,a:n,m:i}=this.state;return`oklch(${e(`lightness.${i}.${t}`)} ${e(`chroma.${i}.${s}`)} ${e(`hue.${r}`)} / ${n})`}}return new t},pe="coef",be=e=>{class t{constructor(e={}){this.state={center:8},this.state=Object.assign(this.state,e)}get min(){return e(`${pe}.${this.state.center-4}`)}get xxs(){return e(`${pe}.${this.state.center-3}`)}get xs(){return e(`${pe}.${this.state.center-2}`)}get s(){return e(`${pe}.${this.state.center-1}`)}get m(){return e(`${pe}.${this.state.center}`)}get l(){return e(`${pe}.${this.state.center+1}`)}get xl(){return e(`${pe}.${this.state.center+2}`)}get xxl(){return e(`${pe}.${this.state.center+3}`)}get max(){return e(`${pe}.${this.state.center+4}`)}get $xxs(){return new t({center:4})}get $xs(){return new t({center:8})}get $s(){return new t({center:12})}get $m(){return new t({center:16})}get $l(){return new t({center:20})}get $xl(){return new t({center:24})}get $xxl(){return new t({center:28})}get short(){return{s:this.s,m:this.m,l:this.l}}get base(){return Object.assign(Object.assign({xs:this.xs},this.short),{xl:this.xl})}get long(){return Object.assign(Object.assign({xxs:this.xxs},this.base),{xxl:this.xxl})}get full(){return Object.assign(Object.assign({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 t},fe=Object.assign,$e=Object.entries,ye=Array.isArray,ve=e=>"object"==typeof e,je=(e,t)=>Array.from(Array(e).entries()).reduce(((e,[s])=>fe(e,t(s+1))),{}),Oe=(e,t)=>$e(e).reduce(((e,[s,r])=>fe(e,t(s,r))),{}),xe=(e,t,s={})=>e?t:s,we=(...e)=>e.join("-"),ke=(...e)=>e.join(),Se=(...e)=>e.join(" "),_e=(e,...t)=>t.length?t.reduce(((e,t)=>(t&&e&&ve(t)&&$e(t).forEach((([t,s])=>{s&&ve(s)&&e[t]?ye(e[t])&&ye(s)?e[t]=[...e[t],...s]:_e(e[t],s||{}):e[t]=s})),e)),e):e,Ae=Object.assign(J(K(se).map((([e,t])=>{function s(e=""){return e+t}return s.toString=()=>t,[e,s]}))),J(K(re).map((([e,t])=>{function s(e,s=""){return s+t+`(${e})`}return s.toString=()=>t,[e,s]})))),ze={px:w,vh:k,vw:S,vmin:_,vmax:A,em:z,rem:P,deg:q,rad:C,turn:E,ms:N,s:T,pc:M,cqw:B,cqh:W,cqb:I,cqi:R,cqmin:V,cqmax:D},Pe=e=>1!==e?e+" * ":"",qe=e=>{const{scope:s,globalKey:a}=e,o=s(a).varExp,l=(e=1)=>ze.ms(Pe(e)+o("time")),u=(e=1)=>ze.deg(Pe(e)+o("angle")),b=(e=1)=>ze.px(Pe(e)+o("size")),$=e=>e?`cubic-bezier(${e.x1||0},${e.y1||0},${e.x2||1},${e.y2||1})`:o("easing");return{compile:({key:e,maker:a})=>{const j=s(e),x=j.selector,w=(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}})},n=({name:s}={})=>{const r=`${i}${s?" "+s:""}`,a=e=>({[r]:e});return a.toString=()=>r,Object.defineProperties(a,{named:{get:()=>n({name:s||e.name(["lay",t.lay++])})},list:{value:(...e)=>({[i+(e.map((e=>(e+"").split(i)[1])).filter(Boolean).join(",")||s)]:""})}})};return{layer:n(),supports:y,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:s,del:r,ic:i,dir:a,ps:o,fm:l}=e;return{animation:[t,s,r,i,a,o,l,n].filter(Boolean).join(" ")}}),{[i]:{value:s,enumerable:!0},toString:{value:()=>n},[r]:{value:!0}})},property:(s={})=>{const{syn:n='"*"',inh:i=!0,ini:a,def:o}=s,l="--"+e.name(["cp",t.cp++]),c=`var(${l}${void 0!==o?","+o:""})`,u="@property "+l;return Object.defineProperties((e=>({[l]:e})),{[u]:{value:{syntax:n,inherits:i,initialValue:a},enumerable:!0},toString:{value:()=>c},fallback:{value:e=>`var(${l},${e})`},[r]:{value:!0}})},scope:O,media:f,container:s({}),startingStyle:v,$logic:c,$width:h,$height:g,$block:d,$inline:m}})(j);return k=a({dash:we,comma:ke,space:Se,range:je,each:Oe,when:xe,merge:_e,themeVar:o,size:b,time:l,angle:u,easing:$,bem:x,pseudo:Ae,color:me(o),palette:de(o),coef:be(o),units:ze,at:w}),t(k,((e,t)=>e+n(...t)),"");var k}}},Ce=Symbol("effcss-stylesheet");class Ee{constructor(){this.disabled=!1,this.cssRules=[]}replaceSync(e){e&&(this.cssRules=[{cssText:e}])}}function Ne({initStyles:e,emulate:t}={}){const s={};null==e||e.forEach((e=>{var t;const r=null===(t=null==e?void 0:e.dataset)||void 0===t?void 0:t.effcss;r&&(s[r]=e)}));let r={},n={},i=[],a=[];const o=(e,t)=>t.hasOwnProperty(Ce)?t:Object.defineProperties(t,{[Ce]:{value:e}}),l=e=>{var t;return e.adoptedStyleSheets=[...(null===(t=e.adoptedStyleSheets)||void 0===t?void 0:t.length)?[...e.adoptedStyleSheets].filter((e=>!e.hasOwnProperty(Ce))):[],...i]},c=()=>{a=a.reduce(((e,t)=>{const s=t.deref();return s&&(l(s),e.push(t)),e}),[])},u=e=>e?r[e]:void 0,h=(e,t)=>{if(!r[e]){r[e]=o(e,t),i.push(r[e]);const n=s[e];return n&&(n.disabled=!0),c(),!0}};return{get:u,all:()=>r,add:h,status:e=>{const t=u(e);return!(null==t?void 0: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 s=(a=t,i.findIndex((e=>e===a)));var a;return s>-1&&(i.splice(s,1),delete r[e],delete n[e]),c(),!0},removeAll:()=>(i.splice(0),r={},n={},c(),!0),pack:(e,s)=>{let n=r[e]||(!t&&globalThis.CSSStyleSheet?new globalThis.CSSStyleSheet:new Ee);return n.replaceSync(s),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=>s[e]&&!s[e].disabled&&s[e].textContent||void 0}}const Te=({prefix:e})=>{let t=0;return{get initial(){return e+0},get current(){return e+t},next(){return t++,this.current}}},Me=({prefix:e})=>{const t=new Set,s=new Map,r=Te({prefix:e});return{use(e){let n=this.key(e);return n||(n=r.current,t.add(n),s.set(e,n),r.next(),n)},remake(e,t){const r=s.get(t);return r?(s.delete(t),s.set(e,r),r):this.use(e)},key:e=>e?s.get(e)||"":r.initial,get keys(){return[...t]},get makers(){return Object.fromEntries(s.entries().map((([e,t])=>[t,e])))}}},Be=void 0,We=Object.entries,Re=Object.defineProperties,Ie=e=>"string"==typeof e,Ve=e=>null!==e&&"object"==typeof e,De=e=>e.split("."),Je=(e,t)=>We(e).reduce(((e,[s,r])=>{if(Ve(r)){const n=We(r);n.length?e.push(...n.reduce(((e,[r,n])=>{if((e=>null!==e&&e!==Be)(r)&&t&&e.push([s,r,Be,Be]),Ve(n)){const t=We(n);t.length&&e.push(...t.reduce(((e,[t,n])=>{const i=typeof n;return"string"!==i&&"number"!==i||e.push([s,r,t,n]),e}),[]))}return e}),[])):e.push([s,Be,Be,Be])}return e}),[]),Ke=(e,t,s,r)=>""+(((e,t)=>`${e||""}${t?"__"+t:""}`)(e,t)+(s?"_"+s:"")+(s&&r?"_"+r:""))||"_",Le=(e,t)=>"."+(t?e+(t.startsWith("_")?"":"-")+t:e),Fe=(e,t)=>`[data-${e}${t?`~="${t}"`:""}]`;const He=e=>e||"",Ze=Object.assign,Ge=Object.entries,Qe="theme",Ue="delete",Xe="update",Ye="$light",et="$dark",tt="lightness",st="chroma",rt=e=>Number((.1*184+.9*e).toFixed(2)),nt={time:200,size:16,angle:30,color:"#2192a7",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:2.5,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:rt(142),inf:rt(264),war:rt(109),dan:rt(29)},[Ye]:{[tt]:{bg:{xl:.98,l:.93,m:.88,s:.83,xs:.78},fg:{xl:0,l:.12,m:.24,s:.36,xs:.48}},[st]:{bg:{gray:0,pale:.01,base:.04,rich:.7},fg:{gray:0,pale:.07,base:.11,rich:.15}}},[et]:{[tt]:{bg:{xl:.24,l:.3,m:.36,s:.42,xs:.48},fg:{xl:.98,l:.93,m:.86,s:.79,xs:.72}},[st]:{bg:{pale:.02,base:.06,rich:.1},fg:{pale:.06,base:.1,rich:.14}}}},it=({provider:t,init:s,scope:r,onChange:n})=>{const i={"":nt},a=[],o={get:(e="")=>i[e],add(e,t){i[t]||(i[t]=_e({[Ye]:{},[et]:{}},e),a.push({type:"add",payload:{params:e,name:t}}),null==n||n())},delete(e){e&&i[e]&&(this.current===e&&this.switch(),delete i[e],a.push({type:Ue,payload:{name:e}}),null==n||n())},update(e,t=""){i[t]&&(i[t]=_e({[Ye]:{},[et]:{}},i[t],e),a.push({type:Xe,payload:{params:e,name:t}}),null==n||n())},switch(e=""){i[e]&&t.setAttribute(Qe,e)},vars(t=""){const s=this.get(t);return s?(t=>{var{$light:s={},$dark:n={}}=t,i=e(t,["$light","$dark"]);function a(e,t=[]){return Ge(e).reduce(((e,[s,n])=>n&&"object"==typeof n?Ze(e,a(n,[...t,s])):(e[r.varName([...t,s])]=n,e)),{})}return Object.assign(Object.assign({},a(i)),{[Ye]:a(s),[et]:a(n)})})(s):{[Ye]:{},[et]:{}}},get list(){const t=e(i,[""]);return Object.keys(t)},get current(){return t.getAttribute(Qe)||""},get all(){return i},get actions(){return a}};return null==s||s.forEach((({type:e,payload:t})=>{switch(e){case"add":o.add(t.params,t.name);break;case Ue:o.delete(t.name);break;case Xe:o.update(t.params,t.name)}})),o},at="effcss",ot=at+"-provider",lt="script",ct="style",ut="size",ht="time",gt="angle",mt="color",dt="easing",pt=at+"changes",bt="data-"+at,ft="prefers-color-scheme",$t=`${ft}: light`,yt=`${ft}: dark`,vt={mode:"a",pre:"f"},jt=e=>"boolean"==typeof e,Ot=(e,t)=>{const s=((e,t)=>e.getAttribute(t)||vt[t])(e,t);return(e=>"string"==typeof e?Number(e):null)(s)},xt=(e,t,s)=>null===s?e.removeAttribute(t):e.setAttribute(t,s+""),wt=e=>`:root:has([is=${ot}]${e?`[${e}]`:""})`,kt=({theme:t,attrs:s,scope:r})=>({bem:n,each:i,themeVar:a,merge:o,pseudo:{r:l},at:{media:c},units:{px:u}})=>{const h=s.size,g=s.time,m=s.angle,d=s.color,p=s.easing,b=t.vars(),{$dark:f={},$light:$={}}=b,y=e(b,["$dark","$light"]);return o({[wt()]:Object.assign(Object.assign(Object.assign(Object.assign({},y),c.where($t)($)),c.where(yt)(f)),{[l()]:{fontSize:u(a("size"))}})},i(t.list,((s,r)=>{const i=t.vars(r),{$dark:a={},$light:o={}}=i,l=e(i,["$dark","$light"]),u=Object.assign(Object.assign(Object.assign({},l),c.where($t)(o)),c.where(yt)(a));return{[wt(`theme=${s}`)]:u,[n(`..theme.${s}`)]:u}})),h&&{[wt(ut)]:{[r.varName(ut)]:h}},g&&{[wt(ht)]:{[r.varName(ht)]:g}},m&&{[wt(gt)]:{[r.varName(gt)]:m}},d&&{[wt(mt)]:{[r.varName(mt)]:d}},p&&{[wt(dt)]:{[r.varName(dt)]:p}})},St=(e,{initStyles:t,emulate:s,onChange:r,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:{set(t){xt(e,ut,t)},get:()=>Ot(e,ut)},time:{set(t){xt(e,ht,t)},get:()=>Ot(e,ht)},angle:{set(t){xt(e,gt,t)},get:()=>Ot(e,gt)},color:{set(t){xt(e,mt,t)},get:()=>e.getAttribute(mt)},easing:{set(t){xt(e,dt,t)},get:()=>e.getAttribute(dt)}});const o=Me({prefix:e.pre}),l=((e={})=>{const{mode:t,min:s,dict:r={}}=e;let n;n="a"===t?Fe:Le;const i=e=>{let s=0,r=He,a=He;const o=i.dict;o&&(o[e]||(o[e]={}),r=t=>{var r;return null!==(r=o[e][t])&&void 0!==r?r:o[e][t]=(s++).toString(36)},a=t=>o[e][t]);let l=t=>[e,...Ie(t)?t.split("."):t].filter(Boolean).join("-"),c="class",u=t=>t?e+(t.startsWith("_")?"":"-")+t:void 0===t?void 0:e;"a"===t&&(c="data-"+e,u=He);const h=e=>"--"+l(Ie(e)?e.split("."):e),g=e=>{if(void 0===e)return function(e){const t=({b:s,e:r,m:n})=>({b:e=>t({b:e,e:"",m:{}}),e:e=>t({b:s,e:e,m:{}}),m:(e={})=>t({b:s,e:r,m:e}),get $(){return e({[s]:{[r]:n}})}});return t({b:"",e:"",m:{}})}(g);let t,s,r,n,i="";const o=Ie(e);return i=o||Array.isArray(e)?[...(o?[e]:e).reduce(((e,i)=>([t,s,r,n]=De(i),e.add(u(a(Ke(t,s)))),r&&e.add(u(a(Ke(t,s,r,n)))),e)),new Set).values()].join(" "):e&&Je(e,!0).map((([e,t,s,r])=>u(a(Ke(e,t,s,r))))).join(" "),Re({[c]:i},{toString:{value:()=>`${c}="${i}"`},$:{value:i}})};return{selector:t=>{const[s,i,a,o]=De(t);return n(e,r(Ke(s,i,a,o)))},attr:g,name:l,varName:h,varExp:(e,t)=>`var(${h(e)}${void 0!==t?","+t:""})`}};return s&&(i.dict=r),i})({mode:e.mode,min:e.min,dict:null==a?void 0:a.dict}),c=l(o.key()),u=qe({scope:l,globalKey:o.key()}),h=Ne({initStyles:t,emulate:s});e.theme=it({provider:e,init:null==a?void 0:a.theme,onChange:r,scope:c});const g=(({scope:e,collector:t,manager:s,processor:r,globalMaker:n})=>{const i=e=>"string"==typeof e?e:t.key(e),a=s=>e(s||t.key()).attr,o=(e,t)=>r.compile({key:t,maker:e}),l=e=>{let r=t.use(e);return s&&!s.get(r)&&s.pack(r,s.hydrate(r)||o(e,r)),a(r)},c=(...e)=>0===e.length?[l(n)]:e.map((e=>l(e)));return{use:c,remake:(e,r)=>{let n=t.key(r||e);return s&&s.get(n)?(r&&t.remake(e,r),s.pack(n,s.hydrate(n)||o(e,n)),a(n)):c(e)[0]},css:o,status:e=>{const t=i(e);return!!t&&s.status(t)},on:(...e)=>s.on(...e.map(i)),off:(...e)=>s.off(...e.map(i)),stylesheets:(e=t.keys)=>e.map((e=>s.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=Object.assign({},h.all()),s=Object.entries(t).filter((([e,t])=>!t.disabled)).map((([e,t])=>`<style ${bt}="${e}">${[...t.cssRules].map((e=>e.cssText)).join("")}</style>`)).join("");let r=ct,n="";const a={is:ot,min:e.getAttribute("min"),mode:e.getAttribute("mode"),size:e.getAttribute(ut),time:e.getAttribute(ht),angle:e.getAttribute(gt),color:e.getAttribute(mt),easing:e.getAttribute(dt)};if(!i){r=lt,a.type="application/json";const t={theme:e.theme.actions};e.min&&o.keys.length>1&&(t.dict=l.dict),n=JSON.stringify(t)}return s+`<${r} ${Object.entries(a).map((([e,t])=>null!=t&&t!==vt[e]?""===t?e:`${e}="${t}"`:"")).filter(Boolean).join(" ")}${e.theme.current?` theme="${e.theme.current}"`:""}>${n}</${r}>`}}}),Object.assign(e,g)},_t=Symbol(ot),At=[ut,ht,gt,mt,dt],zt=new Set(At);const Pt=(e={})=>{let{noscript:t,attrs:s={}}=e,{mode:r=vt.mode,min:n,pre:i=vt.prefix,size:a=null,time:o=null,angle:l=null,color:c=null,easing:u=null}=s;return new class{get tagName(){return""}get textContent(){return""}getAttribute(e){const t=this.attributes[e];return null!=t?jt(t)?"":t+"":null}setAttribute(e,t){this.attributes[e]=t+"",zt.has(e)&&this._customize()}removeAttribute(e){delete this.attributes[e]}get makers(){return this._c.makers}constructor(){this.attributes={size:a?a+"":null,time:o?o+"":null,angle:l?l+"":null,color:c||null,easing:u||null,pre:i,mode:r,min:n?"":null},this._customize=()=>{const e=this.size,t=this.time,s=this.angle,r=this.color,n=this.easing,i=kt({theme:this.theme,attrs:{size:e,time:t,angle:s,color:r,easing:n},scope:this._s(this._c.key())});this.remake(i,this._),this._=i},St(this,{emulate:!0,onChange:this._customize,globalMaker:this._,noscript:t}),this._customize()}}},qt=(t={})=>{const{emulate:s,global:r}=t,n=e(t,["emulate","global"]),i=null===globalThis||void 0===globalThis?void 0:globalThis.document;let a;const o=globalThis[_t];if(r&&o)a=o;else if(i&&!s){void 0===qt.isDefined&&(qt.isDefined=function(){const e=globalThis.document,t=globalThis.customElements;if(null==t?void 0:t.get(ot))return!1;{class s extends HTMLScriptElement{constructor(){super(...arguments),this._customize=()=>{const e=this.size,t=this.time,s=this.angle,r=this.color,n=this.easing,i=kt({theme:this.theme,attrs:{size:e,time:t,angle:s,color:r,easing:n},scope:this._s(this._c.key())});this.remake(i,this._),this._=i}}static get observedAttributes(){return At}get makers(){return this._c.makers}attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){St(this,{initStyles:[...e.querySelectorAll(ct+`[${bt}]`)],onChange:this._customize,globalMaker:this._}),this._customize();const t=this;this._n={set adoptedStyleSheets(e){t.dispatchEvent(new CustomEvent(pt,{detail:{styles:e},bubbles:!0}))}},this._m.register(this._n),this._m.register(e)}}return t.define(ot,s,{extends:lt}),!0}}());const e=i.querySelector(`[is=${ot}]`);if(e)a=e;else{const e=i.createElement(lt,{is:ot});e.setAttribute("is",ot);const t=null==n?void 0:n.attrs;t&&Object.entries(t).map((([t,s])=>s&&vt[t]!==s&&e.setAttribute(t,jt(s)?"":s+""))),i.head.appendChild(e),a=e}}else a=Pt(n);return r&&!o&&(globalThis[_t]=a),a};export{vt as DEFAULT_ATTRS,ot as TAG_NAME,qt as useStyleProvider};
|
|
7
|
+
function e(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(s[n[r]]=e[n[r]])}return s}"function"==typeof SuppressedError&&SuppressedError;const t=(e,t,s)=>Object.entries(e).reduce(t,s),s=(e,t)=>{return`${s=e,s.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))}:${""+t};`;var s},n=Symbol("noParse"),r=(e,i,a)=>{var o,l,c;let u=""+e;return null==i?"":Array.isArray(i)?i.map((e=>s(u,e))).join(""):"object"!=typeof i||i.hasOwnProperty(n)?""===i?u+";":s(u,i):(!a||(null===(o=a.startsWith)||void 0===o?void 0:o.call(a,"@"))||(null===(l=u.startsWith)||void 0===l?void 0:l.call(u,"&"))||(null===(c=u.startsWith)||void 0===c?void 0:c.call(u,"@"))?"":"&")+u+`{${t(i,((e,t)=>e+r(...t,u)),"")}}`},i="@layer",a="@starting-style",o=e=>`(${e})`,l=e=>"string"==typeof e,c={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?o(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)})`}})},u=e=>{const t=t=>({toString:()=>`(min-${e}:${l(t)?t:t+"rem"})`}),s=t=>({toString:()=>`(max-${e}:${l(t)?t:t+"rem"})`}),n=(e,n)=>({toString:()=>`${t(e)} and ${s(n)}`});return{up:t,down:s,between:n,only:e=>n(e,e)}},h=u("width"),g=u("height"),m=u("inline-size"),d=u("block-size"),p=(e,t)=>e?"string"==typeof e?e.includes("(")||t?e:o(e):e+"":"",b=(e={})=>{const{type:t,condition:s}=e,n=p(s),r="object"==typeof s&&"or"===s.type,i=`@media${t?" "+t:""}${t&&n?" and":""}${n?" "+(t&&r?o(n):n):""}`;return Object.defineProperties((e=>({[i]:e})),{all:{get:()=>b({condition:s,type:"all"})},print:{get:()=>b({condition:s,type:"print"})},screen:{get:()=>b({condition:s,type:"screen"})},where:{value:e=>b({condition:e,type:t})},toString:{value:()=>i}})},$=b({}),f=({condition:e}={})=>{const t=p(e),s="@supports"+(t?" "+t:"");return Object.defineProperties((e=>({[s]:e})),{where:{value:e=>f({condition:e})},toString:{value:()=>s}})},y=f(),v=e=>({[a]:e});v.toString=a;const j=e=>{const{root:t="",limit:s="",mode:n=[!1,!1]}=e,r=`@scope ${t?`(${t}${n[0]?" > *":""})`:""}${t&&s?" ":""}${s?`to (${s}${n[1]?" > *":""})`:""}`;return Object.defineProperties((e=>({[r]:e})),{limit:{value:e=>j({root:t,limit:e,mode:n})},root:{value:e=>j({root:e,limit:s,mode:n})},both:{value:()=>j({root:t,limit:s,mode:[!1,!0]})},none:{value:()=>j({root:t,limit:s,mode:[!0,!1]})},low:{value:()=>j({root:t,limit:s,mode:[!0,!0]})},high:{value:()=>j({root:t,limit:s,mode:[!1,!1]})},toString:{value:()=>r}})},O=j({}),x=(e,t)=>`calc(${e} * 1${t})`,w=e=>x(e,"px"),S=e=>x(e,"vh"),k=e=>x(e,"vw"),_=e=>x(e,"vmin"),A=e=>x(e,"vmax"),z=e=>x(e,"em"),C=e=>x(e,"rem"),P=e=>x(e,"deg"),q=e=>x(e,"rad"),T=e=>x(e,"rad"),E=e=>x(e,"ms"),N=e=>x(e,"s"),M=e=>x(e,"%"),R=e=>x(e,"cqw"),B=e=>x(e,"cqh"),I=e=>x(e,"cqi"),W=e=>x(e,"cqb"),V=e=>x(e,"cqmin"),J=e=>x(e,"cqmax"),L=Object.fromEntries,H=Object.entries,D=":first-",K=":last-",U=":only-",F="child",Z=":nth-",G="of-type",Q=Z+F,X=":focus",Y="valid",ee="in"+Y,te=":user-",se={r:":root",h:":hover",f:X,fv:X+"-visible",a:":active",v:":visited",val:":"+Y,inv:":"+ee,uval:te+Y,uinv:te+ee,e:":empty",d:":disabled",rq:":required",o:":optional",m:":modal",l:":link",ph:":placeholder",ch:":checked",po:":popover-open",fc:D+F,lc:K+F,oc:U+F,odd:Q+"(odd)",even:Q+"(even)",ft:D+G,lt:K+G,ot:U+G,bef:"::before",aft:"::after",bd:"::backdrop"},ne={has:":has",not:":not",is:":is",wh:":where",st:":state",nthc:Q,ntho:Z+G,dir:":dir",lang:":lang"},re=e=>`oklch(${e})`,ie=e=>re(`from ${e}`),ae=(e,t=.1)=>ie(`${e} calc(l + ${t}) c h / alpha`),oe=(e,t=.1)=>ie(`${e} calc(l - ${t}) c h / alpha`),le=(e,t=.1)=>ie(`${e} l c h / calc(alpha + ${t})`),ce=(e,t=.1)=>ie(`${e} l c h / calc(alpha - ${t})`),ue=(e,t=.04)=>ie(`${e} l calc(c + ${t}) h / alpha`),he=(e,t=.04)=>ie(`${e} l calc(c - ${t}) h / alpha`),ge=(e,t=30)=>ie(`${e} l c calc(h${"number"==typeof t?t>0?" + "+t:" - "+-t:t}) / alpha`),me=e=>{const t=e("color");return{root:e=>e?ie(t+` ${e.l||"l"} ${e.c||"c"} ${e.h||"h"} / ${e.a||"1"}`):t,oklch:re,lighten:ae,darken:oe,saturate:ue,desaturate:he,fadein:le,fadeout:ce,spin:ge}},de=e=>{class t{constructor(e={}){this.state={l:"l",c:"base",h:"pri",a:1,m:"bg"},Object.assign(this,{[n]:!0}),this.state=Object.assign(this.state,e)}get xs(){return new t(Object.assign(Object.assign({},this.state),{l:"xs"}))}get s(){return new t(Object.assign(Object.assign({},this.state),{l:"s"}))}get m(){return new t(Object.assign(Object.assign({},this.state),{l:"m"}))}get l(){return new t(Object.assign(Object.assign({},this.state),{l:"l"}))}get xl(){return new t(Object.assign(Object.assign({},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(Object.assign(Object.assign({},this.state),{c:"gray"}))}get pale(){return new t(Object.assign(Object.assign({},this.state),{c:"pale"}))}get base(){return new t(Object.assign(Object.assign({},this.state),{c:"base"}))}get rich(){return new t(Object.assign(Object.assign({},this.state),{c:"rich"}))}get chroma(){return{gray:this.gray,pale:this.pale,base:this.base,rich:this.rich}}get pri(){return new t(Object.assign(Object.assign({},this.state),{h:"pri"}))}get sec(){return new t(Object.assign(Object.assign({},this.state),{h:"sec"}))}get suc(){return new t(Object.assign(Object.assign({},this.state),{h:"suc"}))}get inf(){return new t(Object.assign(Object.assign({},this.state),{h:"inf"}))}get war(){return new t(Object.assign(Object.assign({},this.state),{h:"war"}))}get dan(){return new t(Object.assign(Object.assign({},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(Object.assign(Object.assign({},this.state),{a:e}))}get bg(){return new t(Object.assign(Object.assign({},this.state),{m:"bg"}))}get fg(){return new t(Object.assign(Object.assign({},this.state),{m:"fg"}))}toString(){const{l:t,c:s,h:n,a:r,m:i}=this.state;return`oklch(${e(`lightness.${i}.${t}`)} ${e(`chroma.${i}.${s}`)} ${e(`hue.${n}`)} / ${r})`}}return new t},pe="coef",be=e=>{class t{constructor(e={}){this.state={center:8},this.state=Object.assign(this.state,e)}get min(){return e(`${pe}.${this.state.center-4}`)}get xxs(){return e(`${pe}.${this.state.center-3}`)}get xs(){return e(`${pe}.${this.state.center-2}`)}get s(){return e(`${pe}.${this.state.center-1}`)}get m(){return e(`${pe}.${this.state.center}`)}get l(){return e(`${pe}.${this.state.center+1}`)}get xl(){return e(`${pe}.${this.state.center+2}`)}get xxl(){return e(`${pe}.${this.state.center+3}`)}get max(){return e(`${pe}.${this.state.center+4}`)}get $xxs(){return new t({center:4})}get $xs(){return new t({center:8})}get $s(){return new t({center:12})}get $m(){return new t({center:16})}get $l(){return new t({center:20})}get $xl(){return new t({center:24})}get $xxl(){return new t({center:28})}get short(){return{s:this.s,m:this.m,l:this.l}}get base(){return Object.assign(Object.assign({xs:this.xs},this.short),{xl:this.xl})}get long(){return Object.assign(Object.assign({xxs:this.xxs},this.base),{xxl:this.xxl})}get full(){return Object.assign(Object.assign({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 t},$e=Object.assign,fe=Object.entries,ye=Array.isArray,ve=e=>"object"==typeof e,je=(e,t)=>Array.from(Array(e).entries()).reduce(((e,[s])=>$e(e,t(s+1))),{}),Oe=(e,t)=>fe(e).reduce(((e,[s,n])=>$e(e,t(s,n))),{}),xe=(e,t,s={})=>e?t:s,we=(...e)=>e.join("-"),Se=(...e)=>e.join(),ke=(...e)=>e.join(" "),_e=(e,...t)=>t.length?t.reduce(((e,t)=>(t&&e&&ve(t)&&fe(t).forEach((([t,s])=>{s&&ve(s)&&e[t]?ye(e[t])&&ye(s)?e[t]=[...e[t],...s]:_e(e[t],s||{}):e[t]=s})),e)),e):e,Ae=Object.assign(L(H(se).map((([e,t])=>{function s(e=""){return e+t}return s.toString=()=>t,[e,s]}))),L(H(ne).map((([e,t])=>{function s(e,s=""){return s+t+`(${e})`}return s.toString=()=>t,[e,s]})))),ze={px:w,vh:S,vw:k,vmin:_,vmax:A,em:z,rem:C,deg:P,rad:q,turn:T,ms:E,s:N,pc:M,cqw:R,cqh:B,cqb:W,cqi:I,cqmin:V,cqmax:J},Ce=e=>1!==e?e+" * ":"",Pe=e=>{const{scope:s,globalKey:a}=e,o=s(a).varExp,l=(e=1)=>ze.ms(Ce(e)+o("time")),u=(e=1)=>ze.deg(Ce(e)+o("angle")),b=(e=1)=>ze.px(Ce(e)+o("size")),f=e=>e?`cubic-bezier(${e.x1||0},${e.y1||0},${e.x2||1},${e.y2||1})`:o("easing");return{compile:({key:e,maker:a})=>{const j=s(e),x=j.selector,w=(e=>{const t={cp:1,lay:1,kf:1,cq:1},s=(r={})=>{const{scroll:i,type:a,name:o,condition:l}=r,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})},[n]:{value:!0},toString:{value:()=>u}})},r=({name:s}={})=>{const n=`${i}${s?" "+s:""}`,a=e=>({[n]:e});return a.toString=()=>n,Object.defineProperties(a,{named:{get:()=>r({name:s||e.name(["lay",t.lay++])})},list:{value:(...e)=>({[i+(e.map((e=>(e+"").split(i)[1])).filter(Boolean).join(",")||s)]:""})}})};return{layer:r(),supports:y,keyframes:s=>{const r=e.name(["kf",t.kf++]),i="@keyframes "+r;return Object.defineProperties((e=>{if(!e)return{animationName:r};const{dur:t,tf:s,del:n,ic:i,dir:a,ps:o,fm:l}=e;return{animation:[t,s,n,i,a,o,l,r].filter(Boolean).join(" ")}}),{[i]:{value:s,enumerable:!0},toString:{value:()=>r},[n]:{value:!0}})},property:(s={})=>{const{syn:r='"*"',inh:i=!0,ini:a,def:o}=s,l="--"+e.name(["cp",t.cp++]),c=`var(${l}${void 0!==o?","+o:""})`,u="@property "+l;return Object.defineProperties((e=>({[l]:e})),{[u]:{value:{syntax:r,inherits:i,initialValue:a},enumerable:!0},toString:{value:()=>c},fallback:{value:e=>`var(${l},${e})`},[n]:{value:!0}})},scope:O,media:$,container:s({}),startingStyle:v,$logic:c,$width:h,$height:g,$block:d,$inline:m}})(j),S=a({dash:we,comma:Se,space:ke,range:je,each:Oe,when:xe,merge:_e,themeVar:o,size:b,time:l,angle:u,easing:f,bem:x,pseudo:Ae,color:me(o),palette:de(o),coef:be(o),units:ze,at:w});return"string"==typeof S?S:(e=>t(e,((e,t)=>e+r(...t)),""))(S)}}},qe=Symbol("effcss-stylesheet");class Te{constructor(){this.disabled=!1,this.cssRules=[]}replaceSync(e){e&&(this.cssRules=[{cssText:e}])}}function Ee({initStyles:e,emulate:t}={}){const s={};null==e||e.forEach((e=>{var t;const n=null===(t=null==e?void 0:e.dataset)||void 0===t?void 0:t.effcss;n&&(s[n]=e)}));let n={},r={},i=[],a=[];const o=(e,t)=>t.hasOwnProperty(qe)?t:Object.defineProperties(t,{[qe]:{value:e}}),l=e=>{var t;return e.adoptedStyleSheets=[...(null===(t=e.adoptedStyleSheets)||void 0===t?void 0:t.length)?[...e.adoptedStyleSheets].filter((e=>!e.hasOwnProperty(qe))):[],...i]},c=()=>{a=a.reduce(((e,t)=>{const s=t.deref();return s&&(l(s),e.push(t)),e}),[])},u=e=>e?n[e]:void 0,h=(e,t)=>{if(!n[e]){n[e]=o(e,t),i.push(n[e]);const r=s[e];return r&&(r.disabled=!0),c(),!0}};return{get:u,all:()=>n,add:h,status:e=>{const t=u(e);return!(null==t?void 0: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 s=(a=t,i.findIndex((e=>e===a)));var a;return s>-1&&(i.splice(s,1),delete n[e],delete r[e]),c(),!0},removeAll:()=>(i.splice(0),n={},r={},c(),!0),pack:(e,s)=>{let r=n[e]||(!t&&globalThis.CSSStyleSheet?new globalThis.CSSStyleSheet:new Te);return r.replaceSync(s),r=o(e,r),!!r.cssRules.length&&h(e,r)},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=>s[e]&&!s[e].disabled&&s[e].textContent||void 0}}const Ne=({prefix:e})=>{let t=0;return{get initial(){return e+0},get current(){return e+t},next(){return t++,this.current}}},Me=({prefix:e})=>{const t=new Set,s=new Map,n=Ne({prefix:e});return{use(e){let r=this.key(e);return r||(r=n.current,t.add(r),s.set(e,r),n.next(),r)},remake(e,t){const n=s.get(t);return n?(s.delete(t),s.set(e,n),n):this.use(e)},key:e=>e?s.get(e)||"":n.initial,get keys(){return[...t]},get makers(){return Object.fromEntries(s.entries().map((([e,t])=>[t,e])))}}},Re=void 0,Be=Object.entries,Ie=Object.defineProperties,We=e=>"string"==typeof e,Ve=e=>null!==e&&"object"==typeof e,Je=e=>e.split("."),Le=(e,t)=>Be(e).reduce(((e,[s,n])=>{if(Ve(n)){const r=Be(n);r.length?e.push(...r.reduce(((e,[n,r])=>{if((e=>null!==e&&e!==Re)(n)&&t&&e.push([s,n,Re,Re]),Ve(r)){const t=Be(r);t.length&&e.push(...t.reduce(((e,[t,r])=>{const i=typeof r;return"string"!==i&&"number"!==i||e.push([s,n,t,r]),e}),[]))}return e}),[])):e.push([s,Re,Re,Re])}return e}),[]),He=(e,t,s,n)=>""+(((e,t)=>`${e||""}${t?"__"+t:""}`)(e,t)+(s?"_"+s:"")+(s&&n?"_"+n:""))||"_",De=(e,t)=>"."+(t?e+(t.startsWith("_")?"":"-")+t:e),Ke=(e,t)=>`[data-${e}${t?`~="${t}"`:""}]`;const Ue=e=>e||"",Fe=Object.assign,Ze=Object.entries,Ge="theme",Qe="delete",Xe="update",Ye="$light",et="$dark",tt="lightness",st="chroma",nt=e=>Number((.1*184+.9*e).toFixed(2)),rt={time:200,size:16,angle:30,color:"#2192a7",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:2.5,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:nt(142),inf:nt(264),war:nt(109),dan:nt(29)},[Ye]:{[tt]:{bg:{xl:.98,l:.93,m:.88,s:.83,xs:.78},fg:{xl:0,l:.12,m:.24,s:.36,xs:.48}},[st]:{bg:{gray:0,pale:.01,base:.04,rich:.7},fg:{gray:0,pale:.07,base:.11,rich:.15}}},[et]:{[tt]:{bg:{xl:.24,l:.3,m:.36,s:.42,xs:.48},fg:{xl:.98,l:.93,m:.86,s:.79,xs:.72}},[st]:{bg:{pale:.02,base:.06,rich:.1},fg:{pale:.06,base:.1,rich:.14}}}},it=({provider:t,init:s,scope:n,onChange:r})=>{const i={"":rt},a=[],o=t=>{var{$light:s={},$dark:r={}}=t,i=e(t,["$light","$dark"]);function a(e,t=[]){return Ze(e).reduce(((e,[s,r])=>r&&"object"==typeof r?Fe(e,a(r,[...t,s])):(e[n.varName([...t,s])]=r,e)),{})}return Object.assign(Object.assign({},a(i)),{[Ye]:a(s),[et]:a(r)})},l={get:(e="")=>i[e],add(e,t){i[t]||(i[t]=_e({[Ye]:{},[et]:{}},e),a.push({type:"add",payload:{params:e,name:t}}),null==r||r())},delete(e){e&&i[e]&&(this.current===e&&this.switch(),delete i[e],a.push({type:Qe,payload:{name:e}}),null==r||r())},update(e,t=""){i[t]&&(i[t]=_e({[Ye]:{},[et]:{}},i[t],e),a.push({type:Xe,payload:{params:e,name:t}}),null==r||r())},switch(e=""){i[e]&&t.setAttribute(Ge,e)},vars(e=""){const t=this.get(e);return t?o(t):{[Ye]:{},[et]:{}}},makeThemeVars:o,get list(){const t=e(i,[""]);return Object.keys(t)},get current(){return t.getAttribute(Ge)||""},get all(){return i},get actions(){return a}};return null==s||s.forEach((({type:e,payload:t})=>{switch(e){case"add":l.add(t.params,t.name);break;case Qe:l.delete(t.name);break;case Xe:l.update(t.params,t.name)}})),l},at="effcss",ot=at+"-provider",lt=at+"-override",ct="script",ut="style",ht="size",gt="time",mt="angle",dt="color",pt="easing",bt=at+"changes",$t="data-"+at,ft="prefers-color-scheme",yt=`${ft}: light`,vt=`${ft}: dark`,jt={mode:"a",pre:"f"},Ot=e=>"boolean"==typeof e,xt=(e,t)=>{const s=((e,t)=>e.getAttribute(t)||jt[t])(e,t);return(e=>"string"==typeof e?Number(e):null)(s)},wt=(e,t,s)=>null===s?e.removeAttribute(t):e.setAttribute(t,s+""),St=e=>`:root:has([is=${ot}]${e?`[${e}]`:""})`,kt=e=>Object.entries(e).reduce(((e,[t,s])=>e+t+":"+s+";"),""),_t=({theme:t,attrs:s,scope:n})=>({bem:r,each:i,themeVar:a,merge:o,pseudo:{r:l},at:{media:c},units:{px:u}})=>{const h=s.size,g=s.time,m=s.angle,d=s.color,p=s.easing,b=t.vars(),{$dark:$={},$light:f={}}=b,y=e(b,["$dark","$light"]);return o({[St()]:Object.assign(Object.assign(Object.assign(Object.assign({},y),c.where(yt)(f)),c.where(vt)($)),{[l()]:{fontSize:u(a("size"))}})},i(t.list,((s,n)=>{const i=t.vars(n),{$dark:a={},$light:o={}}=i,l=e(i,["$dark","$light"]),u=Object.assign(Object.assign(Object.assign({},l),c.where(yt)(o)),c.where(vt)(a));return{[St(`theme=${s}`)]:u,[r(`..theme.${s}`)]:u}})),h&&{[St(ht)]:{[n.varName(ht)]:h}},g&&{[St(gt)]:{[n.varName(gt)]:g}},m&&{[St(mt)]:{[n.varName(mt)]:m}},d&&{[St(dt)]:{[n.varName(dt)]:d}},p&&{[St(pt)]:{[n.varName(pt)]:p}})},At=(e,{initStyles:t,emulate:s,onChange:n,globalMaker:r,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:{set(t){wt(e,ht,t)},get:()=>xt(e,ht)},time:{set(t){wt(e,gt,t)},get:()=>xt(e,gt)},angle:{set(t){wt(e,mt,t)},get:()=>xt(e,mt)},color:{set(t){wt(e,dt,t)},get:()=>e.getAttribute(dt)},easing:{set(t){wt(e,pt,t)},get:()=>e.getAttribute(pt)}});const o=Me({prefix:e.pre}),l=((e={})=>{const{mode:t,min:s,dict:n={}}=e;let r;r="a"===t?Ke:De;const i=e=>{let s=0,n=Ue,a=Ue;const o=i.dict;o&&(o[e]||(o[e]={}),n=t=>{var n;return null!==(n=o[e][t])&&void 0!==n?n:o[e][t]=(s++).toString(36)},a=t=>o[e][t]);let l=t=>[e,...We(t)?t.split("."):t].filter(Boolean).join("-"),c="class",u=t=>t?e+(t.startsWith("_")?"":"-")+t:void 0===t?void 0:e;"a"===t&&(c="data-"+e,u=Ue);const h=e=>"--"+l(We(e)?e.split("."):e),g=e=>{if(void 0===e)return function(e){const t=({b:s,e:n,m:r})=>({b:e=>t({b:e,e:"",m:{}}),e:e=>t({b:s,e:e,m:{}}),m:(e={})=>t({b:s,e:n,m:e}),get $(){return e({[s]:{[n]:r}})}});return t({b:"",e:"",m:{}})}(g);let t,s,n,r,i="";const o=We(e);return i=o||Array.isArray(e)?[...(o?[e]:e).reduce(((e,i)=>([t,s,n,r]=Je(i),e.add(u(a(He(t,s)))),n&&e.add(u(a(He(t,s,n,r)))),e)),new Set).values()].join(" "):e&&Le(e,!0).map((([e,t,s,n])=>u(a(He(e,t,s,n))))).join(" "),Ie({[c]:i},{toString:{value:()=>`${c}="${i}"`},$:{value:i}})};return{selector:t=>{const[s,i,a,o]=Je(t);return r(e,n(He(s,i,a,o)))},attr:g,name:l,varName:h,varExp:(e,t)=>`var(${h(e)}${void 0!==t?","+t:""})`}};return s&&(i.dict=n),i})({mode:e.mode,min:e.min,dict:null==a?void 0:a.dict}),c=l(o.key()),u=Pe({scope:l,globalKey:o.key()}),h=Ee({initStyles:t,emulate:s});e.theme=it({provider:e,init:null==a?void 0:a.theme,onChange:n,scope:c});const g=(({scope:e,collector:t,manager:s,processor:n,globalMaker:r})=>{const i=e=>"string"==typeof e?e:t.key(e),a=s=>e(s||t.key()).attr,o=(e,t)=>n.compile({key:t,maker:e}),l=e=>{let n=t.use(e);return s&&!s.get(n)&&s.pack(n,s.hydrate(n)||o(e,n)),a(n)},c=(...e)=>0===e.length?[l(r)]:e.map((e=>l(e)));return{use:c,remake:(e,n)=>{let r=t.key(n||e);return s&&s.get(r)?(n&&t.remake(e,n),s.pack(r,s.hydrate(r)||o(e,r)),a(r)):c(e)[0]},css:o,status:e=>{const t=i(e);return!!t&&s.status(t)},on:(...e)=>s.on(...e.map(i)),off:(...e)=>s.off(...e.map(i)),stylesheets:(e=t.keys)=>e.map((e=>s.get(i(e))))}})({scope:l,processor:u,manager:h,collector:o,globalMaker:r});Object.defineProperties(e,{_c:{value:o},_s:{value:l},_p:{value:u},_m:{value:h},toString:{value:()=>{const t=Object.assign({},h.all()),s=Object.entries(t).filter((([e,t])=>!t.disabled)).map((([e,t])=>`<style ${$t}="${e}">${[...t.cssRules].map((e=>e.cssText)).join("")}</style>`)).join("");let n=ut,r="";const a={is:ot,min:e.getAttribute("min"),mode:e.getAttribute("mode"),size:e.getAttribute(ht),time:e.getAttribute(gt),angle:e.getAttribute(mt),color:e.getAttribute(dt),easing:e.getAttribute(pt)};if(!i){n=ct,a.type="application/json";const t={theme:e.theme.actions};e.min&&o.keys.length>1&&(t.dict=l.dict),r=JSON.stringify(t)}return s+`<${n} ${Object.entries(a).map((([e,t])=>null!=t&&t!==jt[e]?""===t?e:`${e}="${t}"`:"")).filter(Boolean).join(" ")}${e.theme.current?` theme="${e.theme.current}"`:""}>${r}</${n}>`}}}),Object.assign(e,g)},zt=Symbol(ot),Ct=[ht,gt,mt,dt,pt],Pt=new Set(Ct),qt=()=>null===globalThis||void 0===globalThis?void 0:globalThis.document.querySelector(`[is=${ot}]`);const Tt=(e={})=>{let{noscript:t,attrs:s={}}=e,{mode:n=jt.mode,min:r,pre:i=jt.prefix,size:a=null,time:o=null,angle:l=null,color:c=null,easing:u=null}=s;return new class{get tagName(){return""}get textContent(){return""}getAttribute(e){const t=this.attributes[e];return null!=t?Ot(t)?"":t+"":null}setAttribute(e,t){this.attributes[e]=t+"",Pt.has(e)&&this._customize()}removeAttribute(e){delete this.attributes[e]}get makers(){return this._c.makers}constructor(){this.attributes={size:a?a+"":null,time:o?o+"":null,angle:l?l+"":null,color:c||null,easing:u||null,pre:i,mode:n,min:r?"":null},this._customize=()=>{const e=this.size,t=this.time,s=this.angle,n=this.color,r=this.easing,i=_t({theme:this.theme,attrs:{size:e,time:t,angle:s,color:n,easing:r},scope:this._s(this._c.key())});this.remake(i,this._),this._=i},At(this,{emulate:!0,onChange:this._customize,globalMaker:this._,noscript:t}),this._customize()}}},Et=(t={})=>{const{emulate:s,global:n}=t,r=e(t,["emulate","global"]),i=null===globalThis||void 0===globalThis?void 0:globalThis.document;let a;const o=globalThis[zt];if(n&&o)a=o;else if(i&&!s){void 0===Et.isDefined&&(Et.isDefined=function(){const t=globalThis.document,s=globalThis.customElements;if(null==s?void 0:s.get(ot))return!1;{class n extends HTMLScriptElement{constructor(){super(...arguments),this._customize=()=>{const e=this.size,t=this.time,s=this.angle,n=this.color,r=this.easing,i=_t({theme:this.theme,attrs:{size:e,time:t,angle:s,color:n,easing:r},scope:this._s(this._c.key())});this.remake(i,this._),this._=i}}static get observedAttributes(){return Ct}get makers(){return this._c.makers}attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){At(this,{initStyles:[...t.querySelectorAll(ut+`[${$t}]`)],onChange:this._customize,globalMaker:this._}),this._customize();const e=this;this._n={set adoptedStyleSheets(t){e.dispatchEvent(new CustomEvent(bt,{detail:{styles:t},bubbles:!0}))}},this._m.register(this._n),this._m.register(t)}}s.define(ot,n,{extends:ct});class r extends HTMLElement{static get observedAttributes(){return["values"]}_customize(){const t=qt();if(this.shadowRoot&&t){const s=this.getAttribute("values"),n=new CSSStyleSheet;if(s){const r=t.theme.makeThemeVars(JSON.parse(decodeURIComponent(s))),{$dark:i={},$light:a={}}=r,o=e(r,["$dark","$light"]);n.replaceSync(`:host{display:contents;${kt(o)}}@media(${yt}){:host{${kt(a)}}}@media(${vt}){:host{${kt(i)}}}`)}else n.replaceSync(":host{display:contents;}");this.shadowRoot.adoptedStyleSheets=[n]}}attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){this.attachShadow({mode:"open"}).innerHTML="<slot></slot>",this._customize()}}return s.define(lt,r),!0}}());const t=qt();if(t)a=t;else{const e=i.createElement(ct,{is:ot});e.setAttribute("is",ot);const t=null==r?void 0:r.attrs;t&&Object.entries(t).map((([t,s])=>s&&jt[t]!==s&&e.setAttribute(t,Ot(s)?"":s+""))),i.head.appendChild(e),a=e}}else a=Tt(r);return n&&!o&&(globalThis[zt]=a),a},Nt=e=>encodeURIComponent(JSON.stringify(e));export{jt as DEFAULT_ATTRS,ot as TAG_NAME,lt as TAG_NAME_OVERRIDE,Nt as prepareOverrideValues,Et as useStyleProvider};
|
|
@@ -31,6 +31,7 @@ export type TThemeController = {
|
|
|
31
31
|
update(params: TThemeValue, name?: string): void;
|
|
32
32
|
switch(name?: string): void;
|
|
33
33
|
vars<T extends object = object>(theme?: string): TThemeParams<T>;
|
|
34
|
+
makeThemeVars<T extends object>(params: TThemeParams<T>): TThemeValue;
|
|
34
35
|
get list(): string[];
|
|
35
36
|
get current(): string | '';
|
|
36
37
|
get all(): Record<string, object>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -209,6 +209,7 @@ type TUseStyleProvider = {
|
|
|
209
209
|
isDefined?: boolean;
|
|
210
210
|
};
|
|
211
211
|
export declare const TAG_NAME: string;
|
|
212
|
+
export declare const TAG_NAME_OVERRIDE: string;
|
|
212
213
|
export declare const DEFAULT_ATTRS: Record<string, string>;
|
|
213
214
|
/**
|
|
214
215
|
* Use Style Provider
|
|
@@ -217,4 +218,9 @@ export declare const DEFAULT_ATTRS: Record<string, string>;
|
|
|
217
218
|
* @param settings - provider settings
|
|
218
219
|
*/
|
|
219
220
|
export declare const useStyleProvider: TUseStyleProvider;
|
|
221
|
+
/**
|
|
222
|
+
* Prepare string to override global EffCSS variables
|
|
223
|
+
* @param values - CSS variables
|
|
224
|
+
*/
|
|
225
|
+
export declare const prepareOverrideValues: (values: object) => string;
|
|
220
226
|
export {};
|