effcss 4.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* EffCSS v4.0
|
|
2
|
+
* EffCSS v4.1.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=Symbol("noParse"),r=(e,n,i)=>{var a,l,o;let c=""+e;return null==n?"":"object"!=typeof n||n.hasOwnProperty(s)?""===n?c+";":`${u=c,u.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))}:${""+n};`:(!i||(null===(a=i.startsWith)||void 0===a?void 0:a.call(i,"@"))||(null===(l=c.startsWith)||void 0===l?void 0:l.call(c,"&"))||(null===(o=c.startsWith)||void 0===o?void 0:o.call(c,"@"))?"":"&")+c+`{${t(n,((e,t)=>e+r(...t,c)),"")}}`;var u},n="@layer",i="@starting-style",a=e=>`(${e})`,l=e=>"string"==typeof e,o=()=>{const e=e=>({toString:()=>`(min-width:${l(e)?e:e+"rem"})`}),t=e=>({toString:()=>`(max-width:${l(e)?e:e+"rem"})`}),s=(s,r)=>({toString:()=>`${e(s)} and ${t(r)}`});return{up:e,down:t,between:s,only:e=>s(e,e)}},c=(e,t)=>e?"string"==typeof e?e.includes("(")||t?e:a(e):e+"":"",u=(e={})=>{const{type:t,condition:s}=e,r=c(s),n="object"==typeof s&&"or"===s.type,i=`@media${t?" "+t:""}${t&&r?" and":""}${r?" "+(t&&n?a(r):r):""}`;return Object.defineProperties((e=>({[i]:e})),{all:{get:()=>u({condition:s,type:"all"})},print:{get:()=>u({condition:s,type:"print"})},screen:{get:()=>u({condition:s,type:"screen"})},where:{value:e=>u({condition:e,type:t})},toString:{value:()=>i}})},h=({condition:e}={})=>{const t=c(e),s="@supports"+(t?" "+t:"");return Object.defineProperties((e=>({[s]:e})),{where:{value:e=>h({condition:e})},toString:{value:()=>s}})},g=e=>({[i]:e});g.toString=i;const m=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=>m({root:t,limit:e,mode:r})},root:{value:e=>m({root:e,limit:s,mode:r})},both:{value:()=>m({root:t,limit:s,mode:[!1,!0]})},none:{value:()=>m({root:t,limit:s,mode:[!0,!1]})},low:{value:()=>m({root:t,limit:s,mode:[!0,!0]})},high:{value:()=>m({root:t,limit:s,mode:[!1,!1]})},toString:{value:()=>n}})},d=e=>{const t={cp:1,lay:1,kf:1,cq:1},r=(n={})=>{const{scroll:i,type:a,name:l,condition:o}=n,u=c(o),h=`@container${l?" "+l:""}${u?" "+u:""}`;return Object.defineProperties((e=>({[h]:e})),{container:{value:(l||"none")+" / "+(a&&i?`${a} scroll-state`:i?"scroll-state":a||"normal"),enumerable:!0},named:{get:()=>r({scroll:i,condition:o,name:l||e.name(["cq",t.cq++]),type:a})},size:{get:()=>r({name:l,scroll:i,condition:o,type:"size"})},isize:{get:()=>r({name:l,scroll:i,condition:o,type:"inline-size"})},scroll:{get:()=>r({name:l,scroll:!0,condition:o,type:a})},where:{value:e=>r({name:l,scroll:i,condition:e,type:a})},[s]:{value:!0},toString:{value:()=>h}})},i=({name:s}={})=>{const r=`${n}${s?" "+s:""}`,a=e=>({[r]:e});return a.toString=()=>r,Object.defineProperties(a,{named:{get:()=>i({name:s||e.name(["lay",t.lay++])})},list:{value:(...e)=>({[n+(e.map((e=>(e+"").split(n)[1])).filter(Boolean).join(",")||s)]:""})}})};return{layer:i(),supports:h(),keyframes:r=>{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:l,fm:o}=e;return{animation:[t,s,r,i,a,l,o,n].filter(Boolean).join(" ")}}),{[i]:{value:r,enumerable:!0},toString:{value:()=>n},[s]:{value:!0}})},property:(r={})=>{const{syn:n='"*"',inh:i=!0,ini:a,def:l}=r,o="--"+e.name(["cp",t.cp++]),c=`var(${o}${void 0!==l?","+l:""})`,u="@property "+o;return Object.defineProperties((e=>({[o]:e})),{[u]:{value:{syntax:n,inherits:i,initialValue:a},enumerable:!0},toString:{value:()=>c},fallback:{value:e=>`var(${o},${e})`},[s]:{value:!0}})},scope:m({}),media:u({}),container:r({}),startingStyle:g,$logic:{and:(...e)=>Object.defineProperties({type:"and",value:e},{toString:{value:()=>e.filter(Boolean).map((e=>{const t=c(e);return"object"==typeof e&&"or"===e.type?a(t):t})).join(" and ")}}),or:(...e)=>Object.defineProperties({type:"or",value:e},{toString:{value:()=>e.filter(Boolean).map((e=>c(e))).join(" or ")}}),not:e=>"object"==typeof e&&"not"===e.type?e.value[0]:Object.defineProperties({type:"not",value:[e]},{toString:{value:()=>`not (${c(e,!0)})`}})},$width:o()}},p=(e,t)=>`calc(${e} * 1${t})`,b=e=>p(e,"px"),f=e=>p(e,"vh"),$=e=>p(e,"vw"),y=e=>p(e,"vmin"),v=e=>p(e,"vmax"),j=e=>p(e,"em"),O=e=>p(e,"rem"),x=e=>p(e,"deg"),w=e=>p(e,"rad"),k=e=>p(e,"rad"),S=e=>p(e,"ms"),_=e=>p(e,"s"),z=e=>p(e,"%"),A=e=>p(e,"cqw"),P=e=>p(e,"cqh"),q=e=>p(e,"cqi"),C=e=>p(e,"cqb"),E=e=>p(e,"cqmin"),N=e=>p(e,"cqmax"),T=Object.fromEntries,M=Object.entries,B=":first-",W=":last-",R=":only-",I="child",V=":nth-",D="of-type",J=V+I,K=":focus",L={r:":root",h:":hover",f:K,fv:K+"-visible",a:":active",v:":visited",val:":valid",inv:":invalid",e:":empty",d:":disabled",rq:":required",o:":optional",m:":modal",l:":link",ph:":placeholder",ch:":checked",po:":popover-open",fc:B+I,lc:W+I,oc:R+I,odd:J+"(odd)",even:J+"(even)",ft:B+D,lt:W+D,ot:R+D,bef:"::before",aft:"::after",bd:"::backdrop"},F={has:":has",not:":not",is:":is",wh:":where",st:":state",nthc:J,ntho:V+D,dir:":dir",lang:":lang"},H=e=>`oklch(${e})`,Z=e=>H(`from ${e}`),G=(e,t=.1)=>Z(`${e} calc(l + ${t}) c h / alpha)`),Q=(e,t=.1)=>Z(`${e} calc(l - ${t}) c h / alpha)`),U=(e,t=.1)=>Z(`${e} l c h / calc(alpha + ${t}))`),X=(e,t=.1)=>Z(`${e} l c h / calc(alpha - ${t}))`),Y=(e,t=.04)=>Z(`${e} l calc(c + ${t}) h / alpha)`),ee=(e,t=.04)=>Z(`${e} l calc(c - ${t}) h / alpha)`),te=(e,t=30)=>Z(`${e} l c calc(h${"number"==typeof t?t>0?" + "+t:" - "+-t:t}) / alpha)`),se=e=>{class t{constructor(e={}){this.state={l:"l",c:"base",h:"pri",a:1,m:"bg"},Object.assign(this,{[s]:!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},re="coef",ne=e=>{class t{constructor(e={}){this.state={center:8},this.state=Object.assign(this.state,e)}get min(){return e(`${re}.${this.state.center-4}`)}get xxs(){return e(`${re}.${this.state.center-3}`)}get xs(){return e(`${re}.${this.state.center-2}`)}get s(){return e(`${re}.${this.state.center-1}`)}get m(){return e(`${re}.${this.state.center}`)}get l(){return e(`${re}.${this.state.center+1}`)}get xl(){return e(`${re}.${this.state.center+2}`)}get xxl(){return e(`${re}.${this.state.center+3}`)}get max(){return e(`${re}.${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},ie=Object.assign,ae=Object.entries,le=Array.isArray,oe=(e,t)=>Array.from(Array(e).entries()).reduce(((e,[s])=>ie(e,t(s+1))),{}),ce=(e,t)=>ae(e).reduce(((e,[s,r])=>ie(e,t(s,r))),{}),ue=(e,t,s={})=>e?t:s,he=(...e)=>e.join("-"),ge=(...e)=>e.join(),me=(...e)=>e.join(" "),de=(e,...t)=>t.length?t.reduce(((e,t)=>(t&&e&&"object"==typeof t&&ae(t).forEach((([t,s])=>{s&&"object"==typeof s&&e[t]?le(e[t])&&le(s)?e[t]=[...e[t],...s]:de(e[t],s||{}):e[t]=s})),e)),e):e,pe=e=>{const{scope:s,globalKey:n}=e,i=s(n).varExp,a=(e=1)=>`calc(${1!==e?e+" * ":""}${i("time")} * 1ms)`,l=(e=1)=>`calc(${1!==e?e+" * ":""}${i("angle")} * 1deg)`,o=(e=1)=>`calc(${1!==e?e+" * ":""}${i("size")} * 1px)`;return{compile:({key:e,maker:n})=>{const c=s(e),u=c.selector,h=d(c);return g=n({dash:he,comma:ge,space:me,range:oe,each:ce,when:ue,merge:de,themeVar:i,size:o,time:a,angle:l,bem:u,pseudo:Object.assign(T(M(L).map((([e,t])=>{function s(e=""){return e+t}return s.toString=()=>t,[e,s]}))),T(M(F).map((([e,t])=>{function s(e,s=""){return s+t+`(${e})`}return s.toString=()=>t,[e,s]})))),color:{oklch:H,lighten:G,darken:Q,saturate:Y,desaturate:ee,fadein:U,fadeout:X,spin:te},palette:se(i),coef:ne(i),units:{px:b,vh:f,vw:$,vmin:y,vmax:v,em:j,rem:O,deg:x,rad:w,turn:k,ms:S,s:_,pc:z,cqw:A,cqh:P,cqb:C,cqi:q,cqmin:E,cqmax:N},at:h}),t(g,((e,t)=>e+r(...t)),"");var g}}},be=Symbol("effcss-stylesheet");class fe{constructor(){this.disabled=!1,this.cssRules=[]}replaceSync(e){e&&(this.cssRules=[{cssText:e}])}}function $e({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 l=(e,t)=>t.hasOwnProperty(be)?t:Object.defineProperties(t,{[be]:{value:e}}),o=e=>{var t;return e.adoptedStyleSheets=[...(null===(t=e.adoptedStyleSheets)||void 0===t?void 0:t.length)?[...e.adoptedStyleSheets].filter((e=>!e.hasOwnProperty(be))):[],...i]},c=()=>{a=a.reduce(((e,t)=>{const s=t.deref();return s&&(o(s),e.push(t)),e}),[])},u=e=>e?r[e]:void 0,h=(e,t)=>{if(!r[e]){r[e]=l(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 fe);return n.replaceSync(s),n=l(e,n),!!n.cssRules.length&&h(e,n)},register:e=>{a.findIndex((t=>t.deref()===e))>=0||(a.push(new WeakRef(e)),o(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 ye=({prefix:e})=>{let t=0;return{get initial(){return e+0},get current(){return e+t},next(){return t++,this.current}}},ve=({prefix:e})=>{const t=new Set,s=new Map,r=ye({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])))}}},je=void 0,Oe=Object.entries,xe=Object.defineProperties,we=e=>"string"==typeof e,ke=e=>null!==e&&"object"==typeof e,Se=e=>e.split("."),_e=(e,t)=>Oe(e).reduce(((e,[s,r])=>{if(ke(r)){const n=Oe(r);n.length?e.push(...n.reduce(((e,[r,n])=>{if((e=>null!==e&&e!==je)(r)&&t&&e.push([s,r,je,je]),ke(n)){const t=Oe(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,je,je,je])}return e}),[]),ze=(e,t,s,r)=>""+(((e,t)=>`${e||""}${t?"__"+t:""}`)(e,t)+(s?"_"+s:"")+(s&&r?"_"+r:""))||"_",Ae=(e,t)=>"."+(t?e+(t.startsWith("_")?"":"-")+t:e),Pe=(e,t)=>`[data-${e}${t?`~="${t}"`:""}]`;const qe=e=>e||"",Ce=Object.assign,Ee=Object.entries,Ne="theme",Te=e=>Number((.1*184+.9*e).toFixed(2)),Me={time:200,size:16,angle:30,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:Te(142),inf:Te(264),war:Te(109),dan:Te(29)},$light:{lightness:{bg:{xl:.98,l:.93,m:.88,s:.83,xs:.78},fg:{xl:0,l:.12,m:.24,s:.36,xs:.48}},chroma:{bg:{gray:0,pale:.01,base:.04,rich:.7},fg:{gray:0,pale:.07,base:.11,rich:.15}}},$dark:{lightness:{bg:{xl:.24,l:.3,m:.36,s:.42,xs:.48},fg:{xl:.98,l:.93,m:.86,s:.79,xs:.72}},chroma:{bg:{pale:.02,base:.06,rich:.1},fg:{pale:.06,base:.1,rich:.14}}}},Be=({provider:t,init:s,scope:r,onChange:n})=>{const i={"":Me},a=[],l={get:(e="")=>i[e],add(e,t){i[t]||(i[t]=de({$light:{},$dark:{}},e),a.push({type:"add",payload:{params:e,name:t}}),null==n||n())},delete(e){i[e]&&""!==e&&(this.current===e&&this.switch(),delete i[e],a.push({type:"delete",payload:{name:e}}),null==n||n())},update(e,t=""){i[t]&&(i[t]=de({$light:{},$dark:{}},i[t],e),a.push({type:"update",payload:{params:e,name:t}}),null==n||n())},switch(e=""){i[e]&&t.setAttribute(Ne,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 Ee(e).reduce(((e,[s,n])=>n&&"object"==typeof n?Ce(e,a(n,[...t,s])):(e[r.varName([...t,s])]=n,e)),{})}return Object.assign(Object.assign({},a(i)),{$light:a(s),$dark:a(n)})})(s):{$light:{},$dark:{}}},get list(){const t=e(i,[""]);return Object.keys(t)},get current(){return t.getAttribute(Ne)||""},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"delete":l.delete(t.name);break;case"update":l.update(t.params,t.name)}})),l},We="effcss",Re=We+"-provider",Ie="script",Ve="style",De="size",Je="time",Ke="angle",Le=We+"changes",Fe="data-"+We,He="prefers-color-scheme",Ze=`${He}: light`,Ge=`${He}: dark`,Qe={mode:"a",pre:"f"},Ue=e=>"boolean"==typeof e,Xe=(e,t)=>{const s=((e,t)=>e.getAttribute(t)||Qe[t])(e,t);return(e=>"string"==typeof e?Number(e):null)(s)},Ye=(e,t,s)=>null===s?e.removeAttribute(t):e.setAttribute(t,s+""),et=e=>`:root:has([is=${Re}]${e?`[${e}]`:""})`,tt=({theme:t,attrs:s,scope:r})=>({bem:n,each:i,themeVar:a,merge:l,pseudo:{r:o},at:{media:c},units:{px:u}})=>{const h=s.size,g=s.time,m=s.angle,d=t.vars(),{$dark:p={},$light:b={}}=d,f=e(d,["$dark","$light"]);return l({[et()]:Object.assign(Object.assign(Object.assign(Object.assign({},f),c.where(Ze)(b)),c.where(Ge)(p)),{[o()]:{fontSize:u(a("size"))}})},i(t.list,((s,r)=>{const i=t.vars(r),{$dark:a={},$light:l={}}=i,o=e(i,["$dark","$light"]),u=Object.assign(Object.assign(Object.assign({},o),c.where(Ze)(l)),c.where(Ge)(a));return{[et(`theme=${s}`)]:u,[n(`..theme.${s}`)]:u}})),h&&{[et(De)]:{[r.varName("size")]:h}},g&&{[et(Je)]:{[r.varName("time")]:g}},m&&{[et(Ke)]:{[r.varName("angle")]:m}})},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){Ye(e,De,t)},get:()=>Xe(e,De)},time:{set(t){Ye(e,Je,t)},get:()=>Xe(e,Je)},angle:{set(t){Ye(e,Ke,t)},get:()=>Xe(e,Ke)}});const l=ve({prefix:e.pre}),o=((e={})=>{const{mode:t,min:s,dict:r={}}=e;let n;n="a"===t?Pe:Ae;const i=e=>{let s=0,r=qe,a=qe;const l=i.dict;l&&(l[e]||(l[e]={}),r=t=>{var r;return null!==(r=l[e][t])&&void 0!==r?r:l[e][t]=(s++).toString(36)},a=t=>l[e][t]);let o=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=qe);const h=e=>"--"+o(we(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 l=we(e);return i=l||Array.isArray(e)?[...(l?[e]:e).reduce(((e,i)=>([t,s,r,n]=Se(i),e.add(u(a(ze(t,s)))),r&&e.add(u(a(ze(t,s,r,n)))),e)),new Set).values()].join(" "):e&&_e(e,!0).map((([e,t,s,r])=>u(a(ze(e,t,s,r))))).join(" "),xe({[c]:i},{toString:{value:()=>`${c}="${i}"`},$:{value:i}})};return{selector:t=>{const[s,i,a,l]=Se(t);return n(e,r(ze(s,i,a,l)))},attr:g,name:o,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=o(l.key()),u=pe({scope:o,globalKey:l.key()}),h=$e({initStyles:t,emulate:s});e.theme=Be({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,l=(e,t)=>r.compile({key:t,maker:e}),o=e=>{let r=t.use(e);return s&&!s.get(r)&&s.pack(r,s.hydrate(r)||l(e,r)),a(r)},c=(...e)=>0===e.length?[o(n)]:e.map((e=>o(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)||l(e,n)),a(n)):c(e)[0]},css:l,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:o,processor:u,manager:h,collector:l,globalMaker:n});Object.defineProperties(e,{_c:{value:l},_s:{value:o},_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 ${Fe}="${e}">${[...t.cssRules].map((e=>e.cssText)).join("")}</style>`)).join("");let r=Ve,n="";const a={is:Re,min:e.getAttribute("min"),mode:e.getAttribute("mode"),size:e.getAttribute("size"),time:e.getAttribute("time"),angle:e.getAttribute("angle")};if(!i){r=Ie,a.type="application/json";const t={theme:e.theme.actions};e.min&&l.keys.length>1&&(t.dict=o.dict),n=JSON.stringify(t)}return s+`<${r} ${Object.entries(a).map((([e,t])=>null!=t&&t!==Qe[e]?""===t?e:`${e}="${t}"`:"")).filter(Boolean).join(" ")}${e.theme.current?` theme="${e.theme.current}"`:""}>${n}</${r}>`}}}),Object.assign(e,g)};const rt=(e={})=>{let{noscript:t,attrs:s={}}=e,{mode:r=Qe.mode,min:n,pre:i=Qe.prefix,size:a=null,time:l=null,angle:o=null}=s;return new class{get tagName(){return""}get textContent(){return""}getAttribute(e){const t=this.attributes[e];return null!=t?Ue(t)?"":t+"":null}setAttribute(e,t){this.attributes[e]=t+"",e!==De&&e!==Je&&e!==Ke||this._customize()}removeAttribute(e){delete this.attributes[e]}get makers(){return this._c.makers}constructor(){this.attributes={size:a?a+"":null,time:l?l+"":null,angle:o?o+"":null,pre:i,mode:r,min:n?"":null},this._customize=()=>{const e=this.size,t=this.time,s=this.angle,r=tt({theme:this.theme,attrs:{size:e,time:t,angle:s},scope:this._s(this._c.key())});this.remake(r,this._),this._=r},st(this,{emulate:!0,onChange:this._customize,globalMaker:this._,noscript:t}),this._customize()}}},nt=(t={})=>{const{emulate:s}=t,r=e(t,["emulate"]),n=null===globalThis||void 0===globalThis?void 0:globalThis.document;if(n&&!s){void 0===nt.isDefined&&(nt.isDefined=function(){const e=globalThis.document,t=globalThis.customElements;if(null==t?void 0:t.get(Re))return!1;{class s extends HTMLScriptElement{constructor(){super(...arguments),this._customize=()=>{const e=this.size,t=this.time,s=this.angle,r=tt({theme:this.theme,attrs:{size:e,time:t,angle:s},scope:this._s(this._c.key())});this.remake(r,this._),this._=r}}static get observedAttributes(){return[De,Je,Ke]}get makers(){return this._c.makers}attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){st(this,{initStyles:[...e.querySelectorAll(Ve+`[${Fe}]`)],onChange:this._customize,globalMaker:this._}),this._customize();const t=this;this._n={set adoptedStyleSheets(e){t.dispatchEvent(new CustomEvent(Le,{detail:{styles:e},bubbles:!0}))}},this._m.register(this._n),this._m.register(e)}}return t.define(Re,s,{extends:Ie}),!0}}());const e=n.querySelector(`[is=${Re}]`);if(e)return e;const t=n.createElement(Ie,{is:Re});t.setAttribute("is",Re);const s=null==r?void 0:r.attrs;return s&&Object.entries(s).map((([e,s])=>s&&Qe[e]!==s&&t.setAttribute(e,Ue(s)?"":s+""))),n.head.appendChild(t),t}return rt(r)};export{Qe as DEFAULT_ATTRS,Re as TAG_NAME,nt 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=Symbol("noParse"),r=(e,n,i)=>{var a,o,l;let c=""+e;return null==n?"":"object"!=typeof n||n.hasOwnProperty(s)?""===n?c+";":`${u=c,u.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))}:${""+n};`:(!i||(null===(a=i.startsWith)||void 0===a?void 0:a.call(i,"@"))||(null===(o=c.startsWith)||void 0===o?void 0:o.call(c,"&"))||(null===(l=c.startsWith)||void 0===l?void 0:l.call(c,"@"))?"":"&")+c+`{${t(n,((e,t)=>e+r(...t,c)),"")}}`;var u},n="@layer",i="@starting-style",a=e=>`(${e})`,o=e=>"string"==typeof e,l={and:(...e)=>Object.defineProperties({type:"and",value:e},{toString:{value:()=>e.filter(Boolean).map((e=>{const t=d(e);return"object"==typeof e&&"or"===e.type?a(t):t})).join(" and ")}}),or:(...e)=>Object.defineProperties({type:"or",value:e},{toString:{value:()=>e.filter(Boolean).map((e=>d(e))).join(" or ")}}),not:e=>"object"==typeof e&&"not"===e.type?e.value[0]:Object.defineProperties({type:"not",value:[e]},{toString:{value:()=>`not (${d(e,!0)})`}})},c=e=>{const t=t=>({toString:()=>`(min-${e}:${o(t)?t:t+"rem"})`}),s=t=>({toString:()=>`(max-${e}:${o(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)}},u=c("width"),h=c("height"),g=c("inline-size"),m=c("block-size"),d=(e,t)=>e?"string"==typeof e?e.includes("(")||t?e:a(e):e+"":"",p=(e={})=>{const{type:t,condition:s}=e,r=d(s),n="object"==typeof s&&"or"===s.type,i=`@media${t?" "+t:""}${t&&r?" and":""}${r?" "+(t&&n?a(r):r):""}`;return Object.defineProperties((e=>({[i]:e})),{all:{get:()=>p({condition:s,type:"all"})},print:{get:()=>p({condition:s,type:"print"})},screen:{get:()=>p({condition:s,type:"screen"})},where:{value:e=>p({condition:e,type:t})},toString:{value:()=>i}})},b=p({}),f=({condition:e}={})=>{const t=d(e),s="@supports"+(t?" "+t:"");return Object.defineProperties((e=>({[s]:e})),{where:{value:e=>f({condition:e})},toString:{value:()=>s}})},$=f(),y=e=>({[i]:e});y.toString=i;const v=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=>v({root:t,limit:e,mode:r})},root:{value:e=>v({root:e,limit:s,mode:r})},both:{value:()=>v({root:t,limit:s,mode:[!1,!0]})},none:{value:()=>v({root:t,limit:s,mode:[!0,!1]})},low:{value:()=>v({root:t,limit:s,mode:[!0,!0]})},high:{value:()=>v({root:t,limit:s,mode:[!1,!1]})},toString:{value:()=>n}})},j=v({}),O=(e,t)=>`calc(${e} * 1${t})`,x=e=>O(e,"px"),w=e=>O(e,"vh"),k=e=>O(e,"vw"),S=e=>O(e,"vmin"),_=e=>O(e,"vmax"),z=e=>O(e,"em"),A=e=>O(e,"rem"),P=e=>O(e,"deg"),q=e=>O(e,"rad"),C=e=>O(e,"rad"),E=e=>O(e,"ms"),N=e=>O(e,"s"),T=e=>O(e,"%"),M=e=>O(e,"cqw"),B=e=>O(e,"cqh"),W=e=>O(e,"cqi"),R=e=>O(e,"cqb"),I=e=>O(e,"cqmin"),V=e=>O(e,"cqmax"),D=Object.fromEntries,J=Object.entries,K=":first-",L=":last-",F=":only-",H="child",Z=":nth-",G="of-type",Q=Z+H,U=":focus",X={r:":root",h:":hover",f:U,fv:U+"-visible",a:":active",v:":visited",val:":valid",inv:":invalid",e:":empty",d:":disabled",rq:":required",o:":optional",m:":modal",l:":link",ph:":placeholder",ch:":checked",po:":popover-open",fc:K+H,lc:L+H,oc:F+H,odd:Q+"(odd)",even:Q+"(even)",ft:K+G,lt:L+G,ot:F+G,bef:"::before",aft:"::after",bd:"::backdrop"},Y={has:":has",not:":not",is:":is",wh:":where",st:":state",nthc:Q,ntho:Z+G,dir:":dir",lang:":lang"},ee=e=>`oklch(${e})`,te=e=>ee(`from ${e}`),se=(e,t=.1)=>te(`${e} calc(l + ${t}) c h / alpha)`),re=(e,t=.1)=>te(`${e} calc(l - ${t}) c h / alpha)`),ne=(e,t=.1)=>te(`${e} l c h / calc(alpha + ${t}))`),ie=(e,t=.1)=>te(`${e} l c h / calc(alpha - ${t}))`),ae=(e,t=.04)=>te(`${e} l calc(c + ${t}) h / alpha)`),oe=(e,t=.04)=>te(`${e} l calc(c - ${t}) h / alpha)`),le=(e,t=30)=>te(`${e} l c calc(h${"number"==typeof t?t>0?" + "+t:" - "+-t:t}) / alpha)`),ce=e=>{class t{constructor(e={}){this.state={l:"l",c:"base",h:"pri",a:1,m:"bg"},Object.assign(this,{[s]:!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},ue="coef",he=e=>{class t{constructor(e={}){this.state={center:8},this.state=Object.assign(this.state,e)}get min(){return e(`${ue}.${this.state.center-4}`)}get xxs(){return e(`${ue}.${this.state.center-3}`)}get xs(){return e(`${ue}.${this.state.center-2}`)}get s(){return e(`${ue}.${this.state.center-1}`)}get m(){return e(`${ue}.${this.state.center}`)}get l(){return e(`${ue}.${this.state.center+1}`)}get xl(){return e(`${ue}.${this.state.center+2}`)}get xxl(){return e(`${ue}.${this.state.center+3}`)}get max(){return e(`${ue}.${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},ge=Object.assign,me=Object.entries,de=Array.isArray,pe=e=>"object"==typeof e,be=(e,t)=>Array.from(Array(e).entries()).reduce(((e,[s])=>ge(e,t(s+1))),{}),fe=(e,t)=>me(e).reduce(((e,[s,r])=>ge(e,t(s,r))),{}),$e=(e,t,s={})=>e?t:s,ye=(...e)=>e.join("-"),ve=(...e)=>e.join(),je=(...e)=>e.join(" "),Oe=(e,...t)=>t.length?t.reduce(((e,t)=>(t&&e&&pe(t)&&me(t).forEach((([t,s])=>{s&&pe(s)&&e[t]?de(e[t])&&de(s)?e[t]=[...e[t],...s]:Oe(e[t],s||{}):e[t]=s})),e)),e):e,xe=Object.assign(D(J(X).map((([e,t])=>{function s(e=""){return e+t}return s.toString=()=>t,[e,s]}))),D(J(Y).map((([e,t])=>{function s(e,s=""){return s+t+`(${e})`}return s.toString=()=>t,[e,s]})))),we={oklch:ee,lighten:se,darken:re,saturate:ae,desaturate:oe,fadein:ne,fadeout:ie,spin:le},ke={px:x,vh:w,vw:k,vmin:S,vmax:_,em:z,rem:A,deg:P,rad:q,turn:C,ms:E,s:N,pc:T,cqw:M,cqh:B,cqb:R,cqi:W,cqmin:I,cqmax:V},Se=e=>1!==e?e+" * ":"",_e=e=>{const{scope:i,globalKey:a}=e,o=i(a).varExp,c=(e=1)=>ke.ms(Se(e)+o("time")),p=(e=1)=>ke.deg(Se(e)+o("angle")),f=(e=1)=>ke.px(Se(e)+o("size"));return{compile:({key:e,maker:a})=>{const v=i(e),O=v.selector,x=(e=>{const t={cp:1,lay:1,kf:1,cq:1},r=(n={})=>{const{scroll:i,type:a,name:o,condition:l}=n,c=d(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:()=>r({scroll:i,condition:l,name:o||e.name(["cq",t.cq++]),type:a})},size:{get:()=>r({name:o,scroll:i,condition:l,type:"size"})},isize:{get:()=>r({name:o,scroll:i,condition:l,type:"inline-size"})},scroll:{get:()=>r({name:o,scroll:!0,condition:l,type:a})},where:{value:e=>r({name:o,scroll:i,condition:e,type:a})},[s]:{value:!0},toString:{value:()=>u}})},i=({name:s}={})=>{const r=`${n}${s?" "+s:""}`,a=e=>({[r]:e});return a.toString=()=>r,Object.defineProperties(a,{named:{get:()=>i({name:s||e.name(["lay",t.lay++])})},list:{value:(...e)=>({[n+(e.map((e=>(e+"").split(n)[1])).filter(Boolean).join(",")||s)]:""})}})};return{layer:i(),supports:$,keyframes:r=>{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:r,enumerable:!0},toString:{value:()=>n},[s]:{value:!0}})},property:(r={})=>{const{syn:n='"*"',inh:i=!0,ini:a,def:o}=r,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})`},[s]:{value:!0}})},scope:j,media:b,container:r({}),startingStyle:y,$logic:l,$width:u,$height:h,$block:m,$inline:g}})(v);return w=a({dash:ye,comma:ve,space:je,range:be,each:fe,when:$e,merge:Oe,themeVar:o,size:f,time:c,angle:p,bem:O,pseudo:xe,color:we,palette:ce(o),coef:he(o),units:ke,at:x}),t(w,((e,t)=>e+r(...t)),"");var w}}},ze=Symbol("effcss-stylesheet");class Ae{constructor(){this.disabled=!1,this.cssRules=[]}replaceSync(e){e&&(this.cssRules=[{cssText:e}])}}function Pe({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(ze)?t:Object.defineProperties(t,{[ze]:{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(ze))):[],...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 Ae);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 qe=({prefix:e})=>{let t=0;return{get initial(){return e+0},get current(){return e+t},next(){return t++,this.current}}},Ce=({prefix:e})=>{const t=new Set,s=new Map,r=qe({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])))}}},Ee=void 0,Ne=Object.entries,Te=Object.defineProperties,Me=e=>"string"==typeof e,Be=e=>null!==e&&"object"==typeof e,We=e=>e.split("."),Re=(e,t)=>Ne(e).reduce(((e,[s,r])=>{if(Be(r)){const n=Ne(r);n.length?e.push(...n.reduce(((e,[r,n])=>{if((e=>null!==e&&e!==Ee)(r)&&t&&e.push([s,r,Ee,Ee]),Be(n)){const t=Ne(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,Ee,Ee,Ee])}return e}),[]),Ie=(e,t,s,r)=>""+(((e,t)=>`${e||""}${t?"__"+t:""}`)(e,t)+(s?"_"+s:"")+(s&&r?"_"+r:""))||"_",Ve=(e,t)=>"."+(t?e+(t.startsWith("_")?"":"-")+t:e),De=(e,t)=>`[data-${e}${t?`~="${t}"`:""}]`;const Je=e=>e||"",Ke=Object.assign,Le=Object.entries,Fe="theme",He="delete",Ze="update",Ge="$light",Qe="$dark",Ue="lightness",Xe="chroma",Ye=e=>Number((.1*184+.9*e).toFixed(2)),et={time:200,size:16,angle:30,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:Ye(142),inf:Ye(264),war:Ye(109),dan:Ye(29)},[Ge]:{[Ue]:{bg:{xl:.98,l:.93,m:.88,s:.83,xs:.78},fg:{xl:0,l:.12,m:.24,s:.36,xs:.48}},[Xe]:{bg:{gray:0,pale:.01,base:.04,rich:.7},fg:{gray:0,pale:.07,base:.11,rich:.15}}},[Qe]:{[Ue]:{bg:{xl:.24,l:.3,m:.36,s:.42,xs:.48},fg:{xl:.98,l:.93,m:.86,s:.79,xs:.72}},[Xe]:{bg:{pale:.02,base:.06,rich:.1},fg:{pale:.06,base:.1,rich:.14}}}},tt=({provider:t,init:s,scope:r,onChange:n})=>{const i={"":et},a=[],o={get:(e="")=>i[e],add(e,t){i[t]||(i[t]=Oe({[Ge]:{},[Qe]:{}},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:He,payload:{name:e}}),null==n||n())},update(e,t=""){i[t]&&(i[t]=Oe({[Ge]:{},[Qe]:{}},i[t],e),a.push({type:Ze,payload:{params:e,name:t}}),null==n||n())},switch(e=""){i[e]&&t.setAttribute(Fe,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 Le(e).reduce(((e,[s,n])=>n&&"object"==typeof n?Ke(e,a(n,[...t,s])):(e[r.varName([...t,s])]=n,e)),{})}return Object.assign(Object.assign({},a(i)),{[Ge]:a(s),[Qe]:a(n)})})(s):{[Ge]:{},[Qe]:{}}},get list(){const t=e(i,[""]);return Object.keys(t)},get current(){return t.getAttribute(Fe)||""},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 He:o.delete(t.name);break;case Ze:o.update(t.params,t.name)}})),o},st="effcss",rt=st+"-provider",nt="script",it="style",at="size",ot="time",lt="angle",ct=st+"changes",ut="data-"+st,ht="prefers-color-scheme",gt=`${ht}: light`,mt=`${ht}: dark`,dt={mode:"a",pre:"f"},pt=e=>"boolean"==typeof e,bt=(e,t)=>{const s=((e,t)=>e.getAttribute(t)||dt[t])(e,t);return(e=>"string"==typeof e?Number(e):null)(s)},ft=(e,t,s)=>null===s?e.removeAttribute(t):e.setAttribute(t,s+""),$t=e=>`:root:has([is=${rt}]${e?`[${e}]`:""})`,yt=({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=t.vars(),{$dark:p={},$light:b={}}=d,f=e(d,["$dark","$light"]);return o({[$t()]:Object.assign(Object.assign(Object.assign(Object.assign({},f),c.where(gt)(b)),c.where(mt)(p)),{[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(gt)(o)),c.where(mt)(a));return{[$t(`theme=${s}`)]:u,[n(`..theme.${s}`)]:u}})),h&&{[$t(at)]:{[r.varName(at)]:h}},g&&{[$t(ot)]:{[r.varName(ot)]:g}},m&&{[$t(lt)]:{[r.varName(lt)]:m}})},vt=(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){ft(e,at,t)},get:()=>bt(e,at)},time:{set(t){ft(e,ot,t)},get:()=>bt(e,ot)},angle:{set(t){ft(e,lt,t)},get:()=>bt(e,lt)}});const o=Ce({prefix:e.pre}),l=((e={})=>{const{mode:t,min:s,dict:r={}}=e;let n;n="a"===t?De:Ve;const i=e=>{let s=0,r=Je,a=Je;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,...Me(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=Je);const h=e=>"--"+l(Me(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=Me(e);return i=o||Array.isArray(e)?[...(o?[e]:e).reduce(((e,i)=>([t,s,r,n]=We(i),e.add(u(a(Ie(t,s)))),r&&e.add(u(a(Ie(t,s,r,n)))),e)),new Set).values()].join(" "):e&&Re(e,!0).map((([e,t,s,r])=>u(a(Ie(e,t,s,r))))).join(" "),Te({[c]:i},{toString:{value:()=>`${c}="${i}"`},$:{value:i}})};return{selector:t=>{const[s,i,a,o]=We(t);return n(e,r(Ie(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=_e({scope:l,globalKey:o.key()}),h=Pe({initStyles:t,emulate:s});e.theme=tt({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 ${ut}="${e}">${[...t.cssRules].map((e=>e.cssText)).join("")}</style>`)).join("");let r=it,n="";const a={is:rt,min:e.getAttribute("min"),mode:e.getAttribute("mode"),size:e.getAttribute(at),time:e.getAttribute(ot),angle:e.getAttribute(lt)};if(!i){r=nt,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!==dt[e]?""===t?e:`${e}="${t}"`:"")).filter(Boolean).join(" ")}${e.theme.current?` theme="${e.theme.current}"`:""}>${n}</${r}>`}}}),Object.assign(e,g)};const jt=(e={})=>{let{noscript:t,attrs:s={}}=e,{mode:r=dt.mode,min:n,pre:i=dt.prefix,size:a=null,time:o=null,angle:l=null}=s;return new class{get tagName(){return""}get textContent(){return""}getAttribute(e){const t=this.attributes[e];return null!=t?pt(t)?"":t+"":null}setAttribute(e,t){this.attributes[e]=t+"",e!==at&&e!==ot&&e!==lt||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,pre:i,mode:r,min:n?"":null},this._customize=()=>{const e=this.size,t=this.time,s=this.angle,r=yt({theme:this.theme,attrs:{size:e,time:t,angle:s},scope:this._s(this._c.key())});this.remake(r,this._),this._=r},vt(this,{emulate:!0,onChange:this._customize,globalMaker:this._,noscript:t}),this._customize()}}},Ot=(t={})=>{const{emulate:s}=t,r=e(t,["emulate"]),n=null===globalThis||void 0===globalThis?void 0:globalThis.document;if(n&&!s){void 0===Ot.isDefined&&(Ot.isDefined=function(){const e=globalThis.document,t=globalThis.customElements;if(null==t?void 0:t.get(rt))return!1;{class s extends HTMLScriptElement{constructor(){super(...arguments),this._customize=()=>{const e=this.size,t=this.time,s=this.angle,r=yt({theme:this.theme,attrs:{size:e,time:t,angle:s},scope:this._s(this._c.key())});this.remake(r,this._),this._=r}}static get observedAttributes(){return[at,ot,lt]}get makers(){return this._c.makers}attributeChangedCallback(){this.isConnected&&this._customize()}connectedCallback(){vt(this,{initStyles:[...e.querySelectorAll(it+`[${ut}]`)],onChange:this._customize,globalMaker:this._}),this._customize();const t=this;this._n={set adoptedStyleSheets(e){t.dispatchEvent(new CustomEvent(ct,{detail:{styles:e},bubbles:!0}))}},this._m.register(this._n),this._m.register(e)}}return t.define(rt,s,{extends:nt}),!0}}());const e=n.querySelector(`[is=${rt}]`);if(e)return e;const t=n.createElement(nt,{is:rt});t.setAttribute("is",rt);const s=null==r?void 0:r.attrs;return s&&Object.entries(s).map((([e,s])=>s&&dt[e]!==s&&t.setAttribute(e,pt(s)?"":s+""))),n.head.appendChild(t),t}return jt(r)};export{dt as DEFAULT_ATTRS,rt as TAG_NAME,Ot as useStyleProvider};
|
|
@@ -218,5 +218,56 @@ export declare const resolveAtRules: (ctx: ReturnType<ReturnType<TCreateScope>>)
|
|
|
218
218
|
toString: () => string;
|
|
219
219
|
};
|
|
220
220
|
};
|
|
221
|
+
/**
|
|
222
|
+
* Height condition maker
|
|
223
|
+
*/
|
|
224
|
+
$height: {
|
|
225
|
+
up: (val: string | number) => {
|
|
226
|
+
toString: () => string;
|
|
227
|
+
};
|
|
228
|
+
down: (val: string | number) => {
|
|
229
|
+
toString: () => string;
|
|
230
|
+
};
|
|
231
|
+
between: (from: string | number, to: string | number) => {
|
|
232
|
+
toString: () => string;
|
|
233
|
+
};
|
|
234
|
+
only: (val: string | number) => {
|
|
235
|
+
toString: () => string;
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Block-size condition maker
|
|
240
|
+
*/
|
|
241
|
+
$block: {
|
|
242
|
+
up: (val: string | number) => {
|
|
243
|
+
toString: () => string;
|
|
244
|
+
};
|
|
245
|
+
down: (val: string | number) => {
|
|
246
|
+
toString: () => string;
|
|
247
|
+
};
|
|
248
|
+
between: (from: string | number, to: string | number) => {
|
|
249
|
+
toString: () => string;
|
|
250
|
+
};
|
|
251
|
+
only: (val: string | number) => {
|
|
252
|
+
toString: () => string;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Inline-size condition maker
|
|
257
|
+
*/
|
|
258
|
+
$inline: {
|
|
259
|
+
up: (val: string | number) => {
|
|
260
|
+
toString: () => string;
|
|
261
|
+
};
|
|
262
|
+
down: (val: string | number) => {
|
|
263
|
+
toString: () => string;
|
|
264
|
+
};
|
|
265
|
+
between: (from: string | number, to: string | number) => {
|
|
266
|
+
toString: () => string;
|
|
267
|
+
};
|
|
268
|
+
only: (val: string | number) => {
|
|
269
|
+
toString: () => string;
|
|
270
|
+
};
|
|
271
|
+
};
|
|
221
272
|
};
|
|
222
273
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effcss",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Self-confident CSS-in-JS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"ui",
|
|
13
13
|
"typescript",
|
|
14
14
|
"css",
|
|
15
|
-
"css-in-js"
|
|
15
|
+
"css-in-js",
|
|
16
|
+
"css-in-ts"
|
|
16
17
|
],
|
|
17
18
|
"author": "Marat Sabitov",
|
|
18
19
|
"license": "Apache-2.0",
|