effcss 1.2.0 → 1.2.2

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.
Files changed (47) hide show
  1. package/README.md +48 -99
  2. package/dist/build/define-provider-with-configs.min.js +1 -1
  3. package/dist/build/define-provider.min.js +1 -1
  4. package/dist/css/dict.js +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/types/src/_provider/constants.d.ts +2 -2
  7. package/dist/types/src/_provider/manage.d.ts +4 -3
  8. package/dist/types/src/_provider/process.d.ts +7 -13
  9. package/dist/types/src/configs/basic/Agent.d.ts +2 -2
  10. package/dist/types/src/configs/basic/AgentColor.d.ts +2 -2
  11. package/dist/types/src/configs/basic/Animation.d.ts +2 -2
  12. package/dist/types/src/configs/basic/Background.d.ts +2 -2
  13. package/dist/types/src/configs/basic/Border.d.ts +2 -2
  14. package/dist/types/src/configs/basic/BorderExt.d.ts +2 -2
  15. package/dist/types/src/configs/basic/Box.d.ts +2 -2
  16. package/dist/types/src/configs/basic/Color.d.ts +2 -2
  17. package/dist/types/src/configs/basic/Column.d.ts +2 -2
  18. package/dist/types/src/configs/basic/FlexContainer.d.ts +2 -2
  19. package/dist/types/src/configs/basic/FlexItem.d.ts +2 -2
  20. package/dist/types/src/configs/basic/Font.d.ts +2 -2
  21. package/dist/types/src/configs/basic/GridContainer.d.ts +2 -2
  22. package/dist/types/src/configs/basic/GridItem.d.ts +2 -2
  23. package/dist/types/src/configs/basic/Indent.d.ts +2 -2
  24. package/dist/types/src/configs/basic/Inset.d.ts +2 -2
  25. package/dist/types/src/configs/basic/Mask.d.ts +2 -2
  26. package/dist/types/src/configs/basic/Object.d.ts +2 -2
  27. package/dist/types/src/configs/basic/Outline.d.ts +2 -2
  28. package/dist/types/src/configs/basic/Scroll.d.ts +2 -2
  29. package/dist/types/src/configs/basic/ScrollExt.d.ts +2 -2
  30. package/dist/types/src/configs/basic/Size.d.ts +2 -2
  31. package/dist/types/src/configs/basic/SizeExt.d.ts +2 -2
  32. package/dist/types/src/configs/basic/Text.d.ts +2 -2
  33. package/dist/types/src/configs/basic/Transform.d.ts +2 -2
  34. package/dist/types/src/configs/basic/Transition.d.ts +2 -2
  35. package/dist/types/src/configs/basic/User.d.ts +2 -2
  36. package/dist/types/src/configs/basic/View.d.ts +2 -2
  37. package/dist/types/src/configs/ext/Keyframes.d.ts +2 -2
  38. package/dist/types/src/configs/ext/Reset.d.ts +2 -2
  39. package/dist/types/src/css/functions.d.ts +2 -2
  40. package/dist/types/src/index.d.ts +22 -6
  41. package/dist/types/src/types.d.ts +221 -255
  42. package/dist/types/src/utils.d.ts +108 -25
  43. package/dist/utils.js +1 -1
  44. package/package.json +1 -1
  45. package/dist/types/allConfigs.d.ts +0 -1
  46. package/dist/types/defineProvider.d.ts +0 -1
  47. package/dist/types/defineProviderWithConfigs.d.ts +0 -1
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{values as e,keys as t}from"./css/dict.js";import{toCqw as s,toCqh as i,toCqb as r,toCqi as n,toCqmin as o,toCqmax as l,toVw as c,toVh as a,toVmin as h,toVmax as p,toPercent as d,toSpan as u,toRem as m,toDeg as _,toMs as f,toPx as y}from"./css/functions.js";import{COMPONENT_NAME as v,SETTINGS_ID as S,PREFIX as g}from"./utils.js";"function"==typeof SuppressedError&&SuppressedError;const b={light:{lig:{def:.75,c:.05,s:.65,m:.75,l:.85,n:.9}},dark:{lig:{def:.4,n:.25,s:.3,m:.4,l:.5,c:.95}},root:e},$=e=>`{${e}}`,x=Object.assign.bind(Object),j=(e,t)=>`${e}:${t};`,O=(e,t)=>["@property",e,$(j("syntax",t.syn||'"*"')+j("inherits",t.inh||!1)+(t.ini?j("initial-value",t.ini):""))].join(" "),k=e=>`var(${e})`,w=({l:e,c:t,h:s,a:i=1})=>`oklch(${e} ${t} ${s} / ${i})`,A=["l","c","h","a"],N={selector:({b:e,e:t,m:s,mv:i,s:r})=>`.${e}${(t?"__"+t:"")+(s?"_"+s:"")+(s&&i?"_"+i:"")+(r?":"+r:"")}`,attr:e=>t=>s=>{const i=e+(t?"__"+t:"");return{class:i+(s?" "+(null==s?void 0:s.split(" ").map((e=>i+"_"+e.split("-").join("_"))).join(" ")):"")}}},E={selector:({b:e,e:t,m:s,mv:i,s:r})=>`[data-${e}${t?"-"+t:""}${s?'~="'+s+(i?"-"+i:"")+(r?":"+r:"")+'"':""}]`,attr:e=>t=>s=>({[`data-${e}${t?"-"+t:""}`]:s||""})};class q{constructor(e){this.baseStyles="",this._prefix="eff",this._mode="a",this._initkey="init",this._params=b,this._compKeys={},this._compValues={},this._analyzeParams=e=>{var t,v;if(e)for(const t in e)this._params[t]=x(this._params[t]||{},e[t]);const{time:S,rem:g,szu:b,sz:$,sp:j,rad:O,th:k,perc:w,bp:A,fsz:N,lsp:E,tr:q,sk:z,rot:V,fb:R,ra:W,ca:I,ins:K,cqw:P,cqh:C,cqb:T,cqi:M,cqmin:B,cqmax:H,vw:J,vh:L,vmin:D,vmax:F}=this._params.root;this._params.root=x(this._params.root,{cqw:s(P),cqh:i(C),cqb:r(T),cqi:n(M),cqmin:o(B),cqmax:l(H),vw:c(J),vh:a(L),vmin:h(D),vmax:p(F),fb:d(R),ra:u(W),ca:u(I),ins:d(K),sz:x(m($)||{},b),sp:x(m(j)||{},b),rad:m(O),th:m(k),bp:m(A),fsz:m(N),lsp:m(E),tr:m(q),sk:_(z),rot:_(V),perc:d(w),time:f(S),rem:y(g)});const G=function(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(s[i[r]]=e[i[r]])}return s}(this._params,["root"]),Q=Object.entries(G),U={_mode:{root:{}}},X={};Q.forEach((([e,t])=>{U._mode[e]||(U._mode[e]={}),Object.entries(t).forEach((([t,s])=>{Object.entries(s).forEach((([s,i])=>{const r=this._prepareVarName(t,s);U._mode[e][r]=i,U._mode.root[r]||(U._mode.root[r]=i,X[t]||(X[t]={}),X[t][s]=`var(${r})`)}))}))})),this._compValues=X,this._compKeys=Object.entries(this._params.root.bp||{}).reduce(((e,[t,s])=>(e[`min_${t}_`]=`@media (min-width:${s})`,e[`max_${t}_`]=`@media (max-width:${s})`,e)),{}),this._initkey&&(this.baseStyles=this.compile(this._initkey,{c:Object.assign(Object.assign(Object.assign(Object.assign({},U),{$r_:Object.assign(Object.assign({},U._mode.root),{$c:"{uni.inh}",$fsz:"{rem.def}",$ff:"{ff.def}",$:{$c:"{uni.inh}",$fsz:"{rem.def}",$ff:"{ff.def}"}})}),(null===(t=U._mode)||void 0===t?void 0:t.dark)?{$dark_:{$r_:U._mode.dark}}:{}),(null===(v=U._mode)||void 0===v?void 0:v.light)?{$light_:{$r_:U._mode.light}}:{})}))},this.parseSelector=e=>{let t,s,i,r;return e.startsWith("__")?[t,s,i]=e.slice(2).split("_"):[t,s,i]=e.split("_"),i&&([i,r]=i.split(":")),{e:t,m:s,mv:i,s:r}},this._prepareVarName=(...e)=>["-",this._prefix,...e].join("-"),this._prepareKeyframesName=(...e)=>[this._prefix,...e].join("-"),this.compile=(e,s)=>{const{_:i,kf:r,k:n={},v:o={},c:l}=s,c=this.bem.selector.bind(this),a=this.parseSelector;let h=x({},l),p=x({},n),d=x({_:{}},o),u="";if(i)for(let t in i){const s=i[t];if("c"===s.typ){const i={};A.forEach((r=>{const n=t+r,o=this._prepareVarName(e,n);i[r]=o,p["_"+n]=i[r],u+=O(o,s)})),d._[t]=w({l:k(i.l),c:k(i.c),h:k(i.h),a:k(i.a)}),s.all&&(h["_"+t+"l"]=`&lig=>${this._prepareVarName(e,t+"l")}:{1}`,h["_"+t+"c"]=`&chr=>${this._prepareVarName(e,t+"c")}:{1}`,h["_"+t+"h"]=`&hue=>${this._prepareVarName(e,t+"h")}:{1}`,h["_"+t+"a"]=`&alp=>${this._prepareVarName(e,t+"a")}:{1}`)}else{const i=this._prepareVarName(e,t);p["_"+t]=i,d._[t]=k(i),u+=O(i,s)}}const m=e=>p[e]||this._compKeys[e]||t[e],_=e=>d[e]||this._compValues[e]||this._params.root[e],f=e=>e.replaceAll(/\{(.+?)\}/g,((e,t)=>{const[s,i]=t.split(".");if(i){const e=_(s);return(null==e?void 0:e[i])||(null==e?void 0:e.def)}return m(s)})),y=e=>{const t=e.split("?");let s;for(let e in t){const i=t[e],[r,n]=i.split("=>"),[o,l,c]=r.match(/(\w+)(\[[\w,]+\])?/),a=_(l);if(!a)continue;s=a;let h=Object.entries(s);const p=null==c?void 0:c.slice(1,-1).split(",");if(p){const e=new Set(p);h=h.filter((([t,s])=>e.has(t)))}if(n){let[e,t]=n.split("|");void 0===t&&(t=e,e=""),h=h.map((([s,i])=>[e.replace("{0}",s)||s,f(t.replaceAll("{1}",i))]))}(p||n)&&(s=Object.fromEntries(h));break}return s};function v(t,s,i){var r,n,o,l;let h=""+t;if((null===(r=null==t?void 0:t.startsWith)||void 0===r?void 0:r.call(t,"$"))&&(h=m(t.slice(1)),!h))return"";if(Array.isArray(s))return v(h,Object.assign({},...s.map((e=>"string"==typeof e?y(e):e))),i);if(null==s)return"";if("object"==typeof s){const t=!i||(null===(n=i.startsWith)||void 0===n?void 0:n.call(i,"@"))||h.startsWith("&")||h.startsWith("@")?"":"&";if(h.startsWith("_")){const{e:i,m:r,mv:n}=a(h);return r&&"string"!=typeof n?Object.entries(s).reduce(((s,[n,o])=>{let l;return l="object"==typeof o?Object.entries(o).reduce(((e,t)=>e+v(...t,h)),""):o+";",s+t+c({b:e,e:i,m:r,mv:n})+$(l)}),""):t+c({b:e,e:i,m:r,mv:n})+$(Object.entries(s).reduce(((e,t)=>e+v(...t,h)),""))}return t+h+$(Object.entries(s).reduce(((e,t)=>e+v(...t,h)),""))}{let e=""+s;return(null===(o=null==e?void 0:e.startsWith)||void 0===o?void 0:o.call(e,"&"))?v(h,y(e.slice(1)),i):(null===(l=null==e?void 0:e.includes)||void 0===l?void 0:l.call(e,"{"))?v(h,f(e),i):j(h,s)}}let S="";if(r)for(let t in r){const s=r[t],i=this._prepareKeyframesName(e,t);p["kf_"+t]=i,S+=`@keyframes ${i} `+$(Object.entries(s).reduce(((e,[t,s])=>e+t+(String(+t)===t?"%":"")+$(Object.entries(s).reduce(((e,t)=>e+v(...t)),""))),""))}return u+S+Object.entries(h).reduce(((e,t)=>e+v(...t)),"")};const{mode:v="a",params:S,prefix:g="eff",initkey:q="init"}=e;this._prefix=g,this._initkey=q,this.bem="c"===v?N:E,this._analyzeParams(S)}expandSelector(e,t){const{e:s,m:i,mv:r,s:n}=this.parseSelector(t),o=n&&this._getStateSelector(n);return[this.bem.selector({b:e,e:s,m:i,mv:r}),this.bem.selector({b:e,e:s,m:i,mv:r,s:n})+"{"+o]}_getStateSelector(e){const s=e+"_",i=this._compKeys[s]||t[s];if(i)return(i.startsWith("&")||i.startsWith("@")?"":"&")+i}}class z{constructor(e){if(this._stylesheets={},this._rules={},this._expandedSelectors={},this._styleSheetsArray=[],this._listeners=[],this.get=e=>this._stylesheets[e],this.getAll=()=>this._stylesheets,this.add=(e,t)=>{if(!this._stylesheets[e])return this._stylesheets[e]=t,this._styleSheetsArray.push(t),this.cacheRules(e,t),this.notify(),!0},this.remove=e=>{const t=this.get(e);if(!t)return;const s=this._styleSheetsArray.findIndex((e=>e===t));return s>-1&&(this._styleSheetsArray.splice(s,1),delete this._stylesheets[e],delete this._rules[e],delete this._expandedSelectors[e]),this.notify(),!0},this.pack=(e,t)=>{const s=new CSSStyleSheet;if(s.replaceSync(t),s.cssRules.length)return this.add(e,s);console.log(`StyleSheet '${e}' is empty`)},this.cacheRules=(e,t)=>{[...t.cssRules].forEach((t=>{const s=t.cssText.split(" {")[0];s&&(this._rules[e]||(this._rules[e]={}),this._rules[e][s]=t)})),this._expandedSelectors[e]=new Set},this.getExpandedSelectors=e=>this._expandedSelectors[e],this.expandRule=(e,t,s)=>{const i=this._rules[e];if(!i)return void console.log(`No stylesheet found with key '${e}'`);const r=i[t];if(!r)return void console.log(`No rule with selector '${t}' found in stylesheet with key '${e}'`);const[n,o]=r.cssText.split("{");if(r.parentStyleSheet){const t=s+"{"+o+"}",n=r.parentStyleSheet.insertRule(t,r.parentStyleSheet.cssRules.length),l=r.parentStyleSheet.cssRules[n],c=s.split("{")[0];return i[c]=l,this._expandedSelectors[e].add(c),!0}},this.apply=e=>{e.adoptedStyleSheets=this._styleSheetsArray},this.registerNode=e=>{this._listeners.push(new WeakRef(e)),this.apply(e)},this.unregisterNode=e=>{const t=this._listeners.findIndex((t=>t.deref()===e));t>=0&&this._listeners.splice(t,1)},this.notify=()=>{this._listeners=this._listeners.reduce(((e,t)=>{const s=t.deref();return s&&(this.apply(s),e.push(t)),e}),[])},e)for(let t in e)this.pack(t,e[t])}removeAll(){return this._styleSheetsArray.splice(0),this._stylesheets={},this._rules={},this._expandedSelectors={},this.notify(),!0}}function V(e){customElements.define((null==e?void 0:e.name)||v,class extends HTMLElement{get settingsId(){return this.getAttribute("settingsid")||S}get prefix(){return this.getAttribute("prefix")||g}get mode(){return this.getAttribute("mode")}get isolated(){return this.getAttribute("isolated")}get initkey(){var e;return null!==(e=this.getAttribute("initkey"))&&void 0!==e?e:"init"}constructor(){super(),this._sources=new Map,this.getSettings=()=>{var t;const s=null===(t=null===document||void 0===document?void 0:document.getElementById(this.settingsId))||void 0===t?void 0:t.textContent;return s?JSON.parse(s):(null==e?void 0:e.config)||{}},this.compileStyleSheet=(e,t)=>{var s,i;const r=null===(s=this.processor)||void 0===s?void 0:s.compile(e,t);if(r&&(null===(i=this.manager)||void 0===i?void 0:i.pack(e,r)))return this._sources.set(t,e),!0},this.useStyleSheet=e=>{var t;let s=this._sources.get(e);return s||(s=this.prefix+this._sources.size.toString(36),this.compileStyleSheet(s,e)),null===(t=this.processor)||void 0===t?void 0:t.bem.attr(s)},this.expandStyleSheet=(e,t)=>{var s;const i=null===(s=this.manager)||void 0===s?void 0:s.getExpandedSelectors(e);if(this.processor&&i){const s=new Set(t).difference(i),r=s.size;return r&&this.processor&&s.keys().forEach((t=>{var s;const[i,r]=this.processor.expandSelector(e,t);null===(s=this.manager)||void 0===s||s.expandRule(e,i,r)})),r}},this.processStyles=(e,t)=>{if(e)for(let t in e){const s=e[t];this.compileStyleSheet(t,s)}if(t)for(let e in t){const s=t[e];this.expandStyleSheet(e,s)}return!0}}connectedCallback(){const e=this.getSettings(),{params:t,styles:s,ext:i}=e,r=this.initkey;this.processor=function(e){return new q(e)}({prefix:this.prefix,mode:this.mode,initkey:r,params:t}),this.manager=function(e){return new z(e)}(r?{[r]:`${v} {display: contents;}`+this.processor.baseStyles}:{}),this.processStyles(s,i),null===this.isolated&&this.manager.registerNode(document)}})}export{V as defineStyleProvider};
1
+ import{values as e,keys as t}from"./css/dict.js";import{toCqw as s,toCqh as i,toCqb as r,toCqi as n,toCqmin as o,toCqmax as l,toVw as c,toVh as a,toVmin as h,toVmax as p,toPercent as d,toSpan as u,toRem as m,toDeg as _,toMs as f,toPx as y}from"./css/functions.js";import{COMPONENT_NAME as v,SETTINGS_ID as S,PREFIX as g}from"./utils.js";"function"==typeof SuppressedError&&SuppressedError;const b={light:{lig:{def:.75,c:.05,s:.65,m:.75,l:.85,n:.9}},dark:{lig:{def:.4,n:.25,s:.3,m:.4,l:.5,c:.95}},root:e},$=e=>`{${e}}`,x=Object.assign.bind(Object),j=(e,t)=>`${e}:${t};`,O=(e,t)=>["@property",e,$(j("syntax",t.syn||'"*"')+j("inherits",t.inh||!1)+(t.ini?j("initial-value",t.ini):""))].join(" "),k=e=>`var(${e})`,w=({l:e,c:t,h:s,a:i=1})=>`oklch(${e} ${t} ${s} / ${i})`,A=["l","c","h","a"],N={selector:({b:e,e:t,m:s,mv:i,s:r})=>`.${e}${(t?"__"+t:"")+(s?"_"+s:"")+(s&&i?"_"+i:"")+(r?":"+r:"")}`,attr:e=>t=>s=>{const i=e+(t?"__"+t:"");return{class:i+(s?" "+(null==s?void 0:s.split(" ").map((e=>i+"_"+e.split("-").join("_"))).join(" ")):"")}}},E={selector:({b:e,e:t,m:s,mv:i,s:r})=>`[data-${e}${t?"-"+t:""}${s?'~="'+s+(i?"-"+i:"")+(r?":"+r:"")+'"':""}]`,attr:e=>t=>s=>({[`data-${e}${t?"-"+t:""}`]:s||""})};class q{constructor(e){this.baseStyles="",this._prefix="eff",this._mode="a",this._initkey="init",this._params=b,this._compKeys={},this._compValues={},this._analyzeParams=e=>{var t,v;if(e)for(const t in e)this._params[t]=x(this._params[t]||{},e[t]);const{time:S,rem:g,szu:b,sz:$,sp:j,rad:O,th:k,perc:w,bp:A,fsz:N,lsp:E,tr:q,sk:z,rot:V,fb:R,ra:W,ca:I,ins:K,cqw:P,cqh:C,cqb:T,cqi:M,cqmin:B,cqmax:H,vw:J,vh:L,vmin:D,vmax:F}=this._params.root;this._params.root=x(this._params.root,{cqw:s(P),cqh:i(C),cqb:r(T),cqi:n(M),cqmin:o(B),cqmax:l(H),vw:c(J),vh:a(L),vmin:h(D),vmax:p(F),fb:d(R),ra:u(W),ca:u(I),ins:d(K),sz:x(m($)||{},b),sp:x(m(j)||{},b),rad:m(O),th:m(k),bp:m(A),fsz:m(N),lsp:m(E),tr:m(q),sk:_(z),rot:_(V),perc:d(w),time:f(S),rem:y(g)});const G=function(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(s[i[r]]=e[i[r]])}return s}(this._params,["root"]),Q=Object.entries(G),U={_mode:{root:{}}},X={};Q.forEach((([e,t])=>{U._mode[e]||(U._mode[e]={}),Object.entries(t).forEach((([t,s])=>{Object.entries(s).forEach((([s,i])=>{const r=this._prepareVarName(t,s);U._mode[e][r]=i,U._mode.root[r]||(U._mode.root[r]=i,X[t]||(X[t]={}),X[t][s]=`var(${r})`)}))}))})),this._compValues=X,this._compKeys=Object.entries(this._params.root.bp||{}).reduce(((e,[t,s])=>(e[`min_${t}_`]=`@media (min-width:${s})`,e[`max_${t}_`]=`@media (max-width:${s})`,e)),{}),this._initkey&&(this.baseStyles=this.compile(this._initkey,{c:Object.assign(Object.assign(Object.assign(Object.assign({},U),{$r_:Object.assign(Object.assign({},U._mode.root),{$c:"{uni.inh}",$fsz:"{rem.def}",$ff:"{ff.def}",$:{$c:"{uni.inh}",$fsz:"{rem.def}",$ff:"{ff.def}"}})}),(null===(t=U._mode)||void 0===t?void 0:t.dark)?{$dark_:{$r_:U._mode.dark}}:{}),(null===(v=U._mode)||void 0===v?void 0:v.light)?{$light_:{$r_:U._mode.light}}:{})}))},this.parseSelector=e=>{let t,s,i,r;return e.startsWith("__")?[t,s,i]=e.slice(2).split("_"):[t,s,i]=e.split("_"),i&&([i,r]=i.split(":")),{e:t,m:s,mv:i,s:r}},this._prepareVarName=(...e)=>["-",this._prefix,...e].join("-"),this._prepareKeyframesName=(...e)=>[this._prefix,...e].join("-"),this.compile=(e,s)=>{const{_:i,kf:r,k:n={},v:o={},c:l}=s,c=this.bem.selector.bind(this),a=this.parseSelector;let h=x({},l),p=x({},n),d=x({_:{}},o),u="";if(i)for(let t in i){const s=i[t];if("c"===s.typ){const i={};A.forEach((r=>{const n=t+r,o=this._prepareVarName(e,n);i[r]=o,p["_"+n]=i[r],u+=O(o,s)})),d._[t]=w({l:k(i.l),c:k(i.c),h:k(i.h),a:k(i.a)}),s.all&&(h["_"+t+"l"]=`&lig=>${this._prepareVarName(e,t+"l")}:{1}`,h["_"+t+"c"]=`&chr=>${this._prepareVarName(e,t+"c")}:{1}`,h["_"+t+"h"]=`&hue=>${this._prepareVarName(e,t+"h")}:{1}`,h["_"+t+"a"]=`&alp=>${this._prepareVarName(e,t+"a")}:{1}`)}else{const i=this._prepareVarName(e,t);p["_"+t]=i,d._[t]=k(i),u+=O(i,s)}}const m=e=>p[e]||this._compKeys[e]||t[e],_=e=>d[e]||this._compValues[e]||this._params.root[e],f=e=>e.replaceAll(/\{(.+?)\}/g,((e,t)=>{const[s,i]=t.split(".");if(i){const e=_(s);return""+((null==e?void 0:e[i])||(null==e?void 0:e.def)||"")}return""+(m(s)||"")})),y=e=>{const t=e.split("?");let s;for(let e in t){const i=t[e],[r,n]=i.split("=>"),o=r.match(/(\w+)(\[[\w,]+\])?/);if(!o)continue;const[l,c,a]=o,h=_(c);if(!h)continue;s=h;let p=Object.entries(s);const d=null==a?void 0:a.slice(1,-1).split(",");if(d){const e=new Set(d);p=p.filter((([t,s])=>e.has(t)))}if(n){let[e,t]=n.split("|");void 0===t&&(t=e,e=""),p=p.map((([s,i])=>[e.replace("{0}",s)||s,f(t.replaceAll("{1}",""+i))]))}(d||n)&&(s=Object.fromEntries(p));break}return s};function v(t,s,i){var r,n,o,l;let h=""+t;if((null===(r=null==t?void 0:t.startsWith)||void 0===r?void 0:r.call(t,"$"))&&(h=m(t.slice(1)),!h))return"";if(Array.isArray(s))return v(h,Object.assign({},...s.map((e=>"string"==typeof e?y(e):e))),i);if(null==s)return"";if("object"==typeof s){const t=!i||(null===(n=i.startsWith)||void 0===n?void 0:n.call(i,"@"))||h.startsWith("&")||h.startsWith("@")?"":"&";if(h.startsWith("_")){const{e:i,m:r,mv:n}=a(h);return r&&"string"!=typeof n?Object.entries(s).reduce(((s,[n,o])=>{let l;return l="object"==typeof o?Object.entries(o).reduce(((e,t)=>e+v(...t,h)),""):o+";",s+t+c({b:e,e:i,m:r,mv:n})+$(l)}),""):t+c({b:e,e:i,m:r,mv:n})+$(Object.entries(s).reduce(((e,t)=>e+v(...t,h)),""))}return t+h+$(Object.entries(s).reduce(((e,t)=>e+v(...t,h)),""))}{let e=""+s;return(null===(o=null==e?void 0:e.startsWith)||void 0===o?void 0:o.call(e,"&"))?v(h,y(e.slice(1)),i):(null===(l=null==e?void 0:e.includes)||void 0===l?void 0:l.call(e,"{"))?v(h,f(e),i):j(h,e)}}let S="";if(r)for(let t in r){const s=r[t],i=this._prepareKeyframesName(e,t);p["kf_"+t]=i,S+=`@keyframes ${i} `+$(Object.entries(s).reduce(((e,[t,s])=>e+t+(String(+t)===t?"%":"")+$(Object.entries(s).reduce(((e,t)=>e+v(...t)),""))),""))}return u+S+Object.entries(h).reduce(((e,t)=>e+v(...t)),"")};const{mode:v="a",params:S,prefix:g="eff",initkey:q="init"}=e;this._prefix=g,this._initkey=q,this.bem="c"===v?N:E,this._analyzeParams(S)}expandSelector(e,t){const{e:s,m:i,mv:r,s:n}=this.parseSelector(t),o=n&&this._getStateSelector(n);return[this.bem.selector({b:e,e:s,m:i,mv:r}),this.bem.selector({b:e,e:s,m:i,mv:r,s:n})+"{"+o]}_getStateSelector(e){const s=e+"_",i=this._compKeys[s]||t[s];if(i)return(i.startsWith("&")||i.startsWith("@")?"":"&")+i}}function z(e){return new q(e)}class V{constructor(e){if(this._stylesheets={},this._rules={},this._expandedSelectors={},this._styleSheetsArray=[],this._listeners=[],this.get=e=>this._stylesheets[e],this.getAll=()=>this._stylesheets,this.add=(e,t)=>{if(!this._stylesheets[e])return this._stylesheets[e]=t,this._styleSheetsArray.push(t),this.cacheRules(e,t),this.notify(),!0},this.remove=e=>{const t=this.get(e);if(!t)return;const s=this._styleSheetsArray.findIndex((e=>e===t));return s>-1&&(this._styleSheetsArray.splice(s,1),delete this._stylesheets[e],delete this._rules[e],delete this._expandedSelectors[e]),this.notify(),!0},this.pack=(e,t)=>{const s=new CSSStyleSheet;if(s.replaceSync(t),s.cssRules.length)return this.add(e,s);console.log(`StyleSheet '${e}' is empty`)},this.cacheRules=(e,t)=>{[...t.cssRules].forEach((t=>{const s=t.cssText.split(" {")[0];s&&(this._rules[e]||(this._rules[e]={}),this._rules[e][s]=t)})),this._expandedSelectors[e]=new Set},this.getExpandedSelectors=e=>this._expandedSelectors[e],this.expandRule=(e,t,s)=>{const i=this._rules[e];if(!i)return void console.log(`No stylesheet found with key '${e}'`);const r=i[t];if(!r)return void console.log(`No rule with selector '${t}' found in stylesheet with key '${e}'`);const[n,o]=r.cssText.split("{");if(r.parentStyleSheet){const t=s+"{"+o+"}",n=r.parentStyleSheet.insertRule(t,r.parentStyleSheet.cssRules.length),l=r.parentStyleSheet.cssRules[n],c=s.split("{")[0];return i[c]=l,this._expandedSelectors[e].add(c),!0}},this.apply=e=>{e.adoptedStyleSheets=this._styleSheetsArray},this.registerNode=e=>{this._listeners.push(new WeakRef(e)),this.apply(e)},this.unregisterNode=e=>{const t=this._listeners.findIndex((t=>t.deref()===e));t>=0&&this._listeners.splice(t,1)},this.notify=()=>{this._listeners=this._listeners.reduce(((e,t)=>{const s=t.deref();return s&&(this.apply(s),e.push(t)),e}),[])},e)for(let t in e)this.pack(t,e[t])}removeAll(){return this._styleSheetsArray.splice(0),this._stylesheets={},this._rules={},this._expandedSelectors={},this.notify(),!0}}function R(e){return new V(e)}const W=z,I=R;function K(e){customElements.define((null==e?void 0:e.name)||v,class extends HTMLElement{get settingsId(){return this.getAttribute("settingsid")||S}get prefix(){return this.getAttribute("prefix")||g}get mode(){return this.getAttribute("mode")}get isolated(){return this.getAttribute("isolated")}get initkey(){var e;return null!==(e=this.getAttribute("initkey"))&&void 0!==e?e:"init"}constructor(){super(),this._sources=new Map,this.getSettings=()=>{var t;const s=null===(t=null===document||void 0===document?void 0:document.getElementById(this.settingsId))||void 0===t?void 0:t.textContent;return s?JSON.parse(s):(null==e?void 0:e.config)||{}},this.compileStyleSheet=(e,t)=>{var s,i;const r=null===(s=this.processor)||void 0===s?void 0:s.compile(e,t);if(r&&(null===(i=this.manager)||void 0===i?void 0:i.pack(e,r)))return this._sources.set(t,e),!0},this.useStyleSheet=e=>{var t;let s=this._sources.get(e);return s||(s=this.prefix+this._sources.size.toString(36),this.compileStyleSheet(s,e)),null===(t=this.processor)||void 0===t?void 0:t.bem.attr(s)},this.expandStyleSheet=(e,t)=>{var s,i;const r=null===(s=this.manager)||void 0===s?void 0:s.getExpandedSelectors(e);if(this.processor&&r){const s=new Set(t).difference(r),n=s.size;if(n&&(null===(i=this.processor)||void 0===i?void 0:i.expandSelector)){const t=this.processor.expandSelector;return s.keys().forEach((s=>{var i;const[r,n]=t(e,s);null===(i=this.manager)||void 0===i||i.expandRule(e,r,n)})),n}}},this.processStyles=(e,t)=>{if(e)for(let t in e){const s=e[t];this.compileStyleSheet(t,s)}if(t)for(let e in t){const s=t[e];this.expandStyleSheet(e,s)}return!0}}connectedCallback(){const e=this.getSettings(),{params:t,styles:s,ext:i}=e,r=this.initkey;this.processor=z({prefix:this.prefix,mode:this.mode,initkey:r,params:t}),this.manager=R(r?{[r]:`${v} {display: contents;}`+this.processor.baseStyles}:{}),this.processStyles(s,i),null===this.isolated&&this.manager.registerNode(document)}})}export{I as createStyleManager,W as createStyleProcessor,K as defineStyleProvider};
@@ -1,5 +1,5 @@
1
- import { TModeValues } from 'types';
1
+ import { TDisplayModeValues } from '../types';
2
2
  /**
3
3
  * Default style params
4
4
  */
5
- export declare const defaultParams: TModeValues;
5
+ export declare const defaultParams: TDisplayModeValues;
@@ -1,6 +1,7 @@
1
- import { IStyleManager } from 'types';
1
+ import { IStyleManager } from '../types';
2
2
  /**
3
- * Create Style Manager instance
4
- * @param params
3
+ * Create {@link IStyleManager | style manager}
4
+ * @param params - manager params
5
+ * @returns IStyleManager
5
6
  */
6
7
  export declare function createManager(params: Record<string, string>): IStyleManager;
@@ -1,19 +1,12 @@
1
- import { IStyleProcessor } from 'types';
2
- /**
3
- * Style generation mode
4
- * @description
5
- * `a` - attributes
6
- * `c` - classes
7
- */
8
- export type TStyleMode = 'a' | 'c';
1
+ import { IStyleProcessor, TStyleMode } from '../types';
9
2
  /**
10
3
  * Processor constructor params
11
4
  * @private
12
5
  */
13
6
  interface IConstructorParams {
14
- mode: TStyleMode | null;
15
- prefix: string | null;
16
- initkey: string | null;
7
+ mode?: TStyleMode | null;
8
+ prefix?: string | null;
9
+ initkey?: string | null;
17
10
  params: Record<string, Record<string, object>>;
18
11
  }
19
12
  /**
@@ -22,8 +15,9 @@ interface IConstructorParams {
22
15
  */
23
16
  export declare const curlyBraces: (val: string | number) => string;
24
17
  /**
25
- * Create Style Processor instance
26
- * @param params
18
+ * Create {@link IStyleProcessor | style processor}
19
+ * @param params - processor params
20
+ * @returns IStyleProcessor
27
21
  */
28
22
  export declare function createProcessor(params: IConstructorParams): IStyleProcessor;
29
23
  export {};
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -1,6 +1,6 @@
1
- import { TStyleConfig } from 'types';
1
+ import { TStyleSheetConfig } from '../../types';
2
2
  export interface IKeyframesConfig {
3
3
  an: 'zoomIn' | 'zoomOut' | 'pulse' | 'heartBeat' | 'bounceIn' | 'bounceOut' | 'fadeIn' | 'fadeInRight' | 'fadeInLeft' | 'fadeInDown' | 'fadeInUp' | 'fadeOut' | 'fadeOutRight' | 'fadeOutLeft' | 'fadeOutDown' | 'fadeOutUp' | 'flipInX' | 'flipInY' | 'flipOutX' | 'flipOutY' | 'slideInDown' | 'slideInLeft' | 'slideInRight' | 'slideInUp' | 'slideOutDown' | 'slideOutLeft' | 'slideOutRight' | 'slideOutUp';
4
4
  }
5
- declare const _default: TStyleConfig;
5
+ declare const _default: TStyleSheetConfig;
6
6
  export default _default;
@@ -1,3 +1,3 @@
1
- import { TStyleConfig } from 'types';
2
- declare const _default: TStyleConfig;
1
+ import { TStyleSheetConfig } from '../../types';
2
+ declare const _default: TStyleSheetConfig;
3
3
  export default _default;
@@ -23,13 +23,13 @@ export declare const parentheses: (val: string | number) => string;
23
23
  * @param target
24
24
  * @param transform
25
25
  */
26
- export declare const transformer: <K extends string, T, V>(target: Record<K, T>, transform: (val: [string | number, T]) => [string | number, V]) => Record<K, V>;
26
+ export declare const transformer: <K extends string, T extends (string | number), V extends (string | number)>(target: Record<K, T>, transform: (val: [string | number, T]) => [string | number, V]) => Record<K, V>;
27
27
  /**
28
28
  * Value transformer
29
29
  * @param target
30
30
  * @param transformVal
31
31
  */
32
- export declare const valTransformer: <K extends string, T, V>(target: Record<K, T>, handler: (val: T) => V) => Record<K, V>;
32
+ export declare const valTransformer: <K extends string, T extends (string | number), V extends (string | number)>(target: Record<K, T>, handler: (val: T) => V) => Record<K, V>;
33
33
  /**
34
34
  * Constructs `attr(val)` expression
35
35
  * @param val
@@ -1,11 +1,27 @@
1
+ import { IStyleConfig } from './types';
2
+ import { createProcessor } from './_provider/process';
3
+ import { createManager } from './_provider/manage';
1
4
  /**
2
- * Define style provider
5
+ * Create {@link IStyleProcessor | style processor}
6
+ */
7
+ export declare const createStyleProcessor: typeof createProcessor;
8
+ /**
9
+ * Create {@link IStyleManager | style manager}
10
+ */
11
+ export declare const createStyleManager: typeof createManager;
12
+ /**
13
+ * Define style provider as custom element
3
14
  */
4
15
  export declare function defineStyleProvider(props?: {
16
+ /**
17
+ * Element name
18
+ * @defaultValue style-provider
19
+ */
5
20
  name?: string;
6
- config?: {
7
- params?: object;
8
- styles?: object;
9
- ext?: object;
10
- };
21
+ /**
22
+ * Style config
23
+ * @description
24
+ * Will be used for initial stylesheets generation
25
+ */
26
+ config?: IStyleConfig;
11
27
  }): void;