@claspo/common 5.2.1-theme.13 → 5.2.1

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.
@@ -0,0 +1,8 @@
1
+ export default class DocumentCssVarsReplace {
2
+ static replaceVars(document: any, colorsMap: {
3
+ [k: string]: string;
4
+ }): any;
5
+ static replaceValues(document: any, cssVarsMap: {
6
+ [k: string]: string;
7
+ }): any;
8
+ }
@@ -0,0 +1 @@
1
+ export default class DocumentCssVarsReplace{static replaceVars(s,e){const t=Object.assign(Object.assign({},s.shared.cssVars),e);let a=JSON.stringify(s);return Object.keys(t).forEach(s=>{let e=`var(--${s})`,r=t[s];a=a.split(e).join(r)}),JSON.parse(a)}static replaceValues(s,e){let t=JSON.stringify(s);return Object.keys(e).forEach(s=>{let a=e[s],r=`var(--${s})`;t=t.split(a).join(r)}),JSON.parse(t)}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claspo/common",
3
- "version": "5.2.1-theme.13",
3
+ "version": "5.2.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -1,3 +0,0 @@
1
- export default class ThemeCssVars extends CssVarsOperations {
2
- }
3
- import CssVarsOperations from "./CssVarsOperations";
@@ -1 +0,0 @@
1
- import CssVarsOperations from"./CssVarsOperations";function toCssVarToken(r){return`cl-schema-${r}`}function getRgbaColor(r){return(null==r?void 0:r.startsWith("rgb("))?r.replace("rgb(","rgba(").replace(")",", 1)"):r}function hex(r){var t="0123456789abcdef",e=parseInt(r);return 0==e||isNaN(r)?"00":(e=Math.round(Math.min(Math.max(0,e),255)),t.charAt((e-e%16)/16)+t.charAt(e%16))}function convertToHex(r){return hex(r[0])+hex(r[1])+hex(r[2])}function trim(r){return"#"==r.charAt(0)?r.substring(1,7):r}function convertToRGB(r){var t=[];return t[0]=parseInt(trim(r).substring(0,2),16),t[1]=parseInt(trim(r).substring(2,4),16),t[2]=parseInt(trim(r).substring(4,6),16),t}function parseColorToRGB(r){if(!r)return[0,0,0,1];const t=r.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(t){return[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10),t[4]?parseFloat(t[4]):1]}if(r.startsWith("#")){const t=trim(r);if(3===t.length){return[parseInt(t[0]+t[0],16),parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),1]}if(6===t.length){const r=convertToRGB(t);return[r[0],r[1],r[2],1]}}return[0,0,0,1]}function generateGradientColors(r,t,e){if(!r||!t||e<=0)return[];const n=parseColorToRGB(r),s=parseColorToRGB(t),o=[];for(let r=0;r<e;r++){const t=r/(e-1||1),a=Math.round(n[0]+(s[0]-n[0])*t),i=Math.round(n[1]+(s[1]-n[1])*t),u=Math.round(n[2]+(s[2]-n[2])*t),c=void 0!==n[3]&&void 0!==s[3]?n[3]+(s[3]-n[3])*t:1;o.push(`rgba(${a}, ${i}, ${u}, ${c})`)}return o}function prepareKeys(r){const t=Object.keys(r).reduce((t,e)=>(t[toCssVarToken(e)]=r[e],t),{}),e=getRgbaColor(r.text),n=generateGradientColors(getRgbaColor(r.background),e,18);return n.pop(),n.shift(),n.forEach((r,e)=>{t[toCssVarToken(`background-${e+1}`)]=r}),t}export default class ThemeCssVars extends CssVarsOperations{static override(r={},t){const e=prepareKeys(r);super.override(e,t)}static apply(r={},t){const e=prepareKeys(r);super.apply(e,t)}static get(r,t){const e=toCssVarToken(r);return super.get(e,t)}}