effcss 4.3.0 → 4.4.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.4.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"));return{compile:({key:e,maker:a})=>{const $=s(e),j=$.selector,x=(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}})($);return w=a({dash:we,comma:ke,space:Se,range:je,each:Oe,when:xe,merge:_e,themeVar:o,size:b,time:l,angle:u,bem:j,pseudo:Ae,color:me(o),palette:de(o),coef:be(o),units:ze,at:x}),t(w,((e,t)=>e+n(...t)),"");var w}}},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",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=at+"changes",pt="data-"+at,bt="prefers-color-scheme",ft=`${bt}: light`,$t=`${bt}: dark`,yt={mode:"a",pre:"f"},vt=e=>"boolean"==typeof e,jt=(e,t)=>{const s=((e,t)=>e.getAttribute(t)||yt[t])(e,t);return(e=>"string"==typeof e?Number(e):null)(s)},Ot=(e,t,s)=>null===s?e.removeAttribute(t):e.setAttribute(t,s+""),xt=e=>`:root:has([is=${ot}]${e?`[${e}]`:""})`,wt=({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=t.vars(),{$dark:b={},$light:f={}}=p,$=e(p,["$dark","$light"]);return o({[xt()]:Object.assign(Object.assign(Object.assign(Object.assign({},$),c.where(ft)(f)),c.where($t)(b)),{[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(ft)(o)),c.where($t)(a));return{[xt(`theme=${s}`)]:u,[n(`..theme.${s}`)]:u}})),h&&{[xt(ut)]:{[r.varName(ut)]:h}},g&&{[xt(ht)]:{[r.varName(ht)]:g}},m&&{[xt(gt)]:{[r.varName(gt)]:m}},d&&{[xt(mt)]:{[r.varName(mt)]:d}})},kt=(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){Ot(e,ut,t)},get:()=>jt(e,ut)},time:{set(t){Ot(e,ht,t)},get:()=>jt(e,ht)},angle:{set(t){Ot(e,gt,t)},get:()=>jt(e,gt)},color:{set(t){Ot(e,mt,t)},get:()=>e.getAttribute(mt)}});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 ${pt}="${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)};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!==yt[e]?""===t?e:`${e}="${t}"`:"")).filter(Boolean).join(" ")}${e.theme.current?` theme="${e.theme.current}"`:""}>${n}</${r}>`}}}),Object.assign(e,g)},St=Symbol(ot),_t=[ut,ht,gt,mt],At=new Set(_t);const zt=(e={})=>{let{noscript:t,attrs:s={}}=e,{mode:r=yt.mode,min:n,pre:i=yt.prefix,size:a=null,time:o=null,angle:l=null,color:c=null}=s;return new class{get tagName(){return""}get textContent(){return""}getAttribute(e){const t=this.attributes[e];return null!=t?vt(t)?"":t+"":null}setAttribute(e,t){this.attributes[e]=t+"",At.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,pre:i,mode:r,min:n?"":null},this._customize=()=>{const e=this.size,t=this.time,s=this.angle,r=this.color,n=wt({theme:this.theme,attrs:{size:e,time:t,angle:s,color:r},scope:this._s(this._c.key())});this.remake(n,this._),this._=n},kt(this,{emulate:!0,onChange:this._customize,globalMaker:this._,noscript:t}),this._customize()}}},Pt=(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[St];if(r&&o)a=o;else if(i&&!s){void 0===Pt.isDefined&&(Pt.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=wt({theme:this.theme,attrs:{size:e,time:t,angle:s,color:r},scope:this._s(this._c.key())});this.remake(n,this._),this._=n}}static get observedAttributes(){return _t}get makers(){return this._c.makers}attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){kt(this,{initStyles:[...e.querySelectorAll(ct+`[${pt}]`)],onChange:this._customize,globalMaker:this._}),this._customize();const t=this;this._n={set adoptedStyleSheets(e){t.dispatchEvent(new CustomEvent(dt,{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&&yt[t]!==s&&e.setAttribute(t,vt(s)?"":s+""))),i.head.appendChild(e),a=e}}else a=zt(n);return r&&!o&&(globalThis[St]=a),a};export{yt as DEFAULT_ATTRS,ot as TAG_NAME,Pt as useStyleProvider};
|
|
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,6 +7,12 @@ import { resolvePalette } from './_process/palette';
|
|
|
7
7
|
import { resolveCoef } from './_process/coef';
|
|
8
8
|
import { dash, comma, space, range, each, when, merge } from './utils';
|
|
9
9
|
type TScope = ReturnType<ReturnType<TCreateScope>>;
|
|
10
|
+
type TBezier = {
|
|
11
|
+
x1?: number;
|
|
12
|
+
y1?: number;
|
|
13
|
+
x2?: number;
|
|
14
|
+
y2?: number;
|
|
15
|
+
};
|
|
10
16
|
export interface IMakerParams {
|
|
11
17
|
dash: typeof dash;
|
|
12
18
|
comma: typeof comma;
|
|
@@ -61,6 +67,10 @@ export interface IMakerParams {
|
|
|
61
67
|
* Scalable angle value
|
|
62
68
|
*/
|
|
63
69
|
angle: (coef?: number | string) => string;
|
|
70
|
+
/**
|
|
71
|
+
* Easing function
|
|
72
|
+
*/
|
|
73
|
+
easing: (bezier?: TBezier) => string;
|
|
64
74
|
}
|
|
65
75
|
export type TProcessor = {
|
|
66
76
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type TStrOrNum = string | number;
|
|
2
|
-
type TJoinArr = (...val:
|
|
2
|
+
type TJoinArr = (...val: any[]) => string;
|
|
3
3
|
export declare const range: (size: number, handler: (k: number) => object) => object;
|
|
4
4
|
export declare const each: <V extends Record<TStrOrNum, any>>(rules: V, handler: (k: V extends ArrayLike<any> ? string : keyof V, v: V extends ArrayLike<any> ? NoInfer<V[number]> : NoInfer<V[keyof V]>) => object) => object;
|
|
5
5
|
export declare const when: (condition: number | boolean | undefined | null, rules: object, otherwise?: object) => object;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -37,6 +37,10 @@ export type TProviderAttrs = {
|
|
|
37
37
|
* Root color string
|
|
38
38
|
*/
|
|
39
39
|
color: string;
|
|
40
|
+
/**
|
|
41
|
+
* Root easing function
|
|
42
|
+
*/
|
|
43
|
+
easing: string;
|
|
40
44
|
};
|
|
41
45
|
type TResolveAttr = ReturnType<TScopeResolver>['attr'];
|
|
42
46
|
/**
|
|
@@ -117,6 +121,15 @@ export interface IStyleProvider {
|
|
|
117
121
|
* @param val - angle value in ms
|
|
118
122
|
*/
|
|
119
123
|
set color(val: string | null);
|
|
124
|
+
/**
|
|
125
|
+
* Get root easing function
|
|
126
|
+
*/
|
|
127
|
+
get easing(): string | null;
|
|
128
|
+
/**
|
|
129
|
+
* Set root easing function
|
|
130
|
+
* @param val - easing function
|
|
131
|
+
*/
|
|
132
|
+
set easing(val: string | null);
|
|
120
133
|
/**
|
|
121
134
|
* Use stylesheet makers
|
|
122
135
|
* @param makers - stylesheet makers
|