@symbo.ls/scratch 3.14.678 → 3.14.697

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @symbo.ls/scratch
2
2
 
3
+ ## 3.14.697
4
+
5
+ ### Patch Changes
6
+
7
+ - Auto-generated cross-repo patch release.
8
+
9
+ ## 3.14.685
10
+
11
+ ### Patch Changes
12
+
13
+ - Auto-generated cross-repo patch release.
14
+ - Updated dependencies
15
+ - @symbo.ls/utils@3.14.685
16
+
3
17
  ## 3.14.678
4
18
 
5
19
  ### Patch Changes
@@ -1 +1 @@
1
- "use strict";var x=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var k=(t,s)=>{for(var e in s)x(t,e,{get:s[e],enumerable:!0})},j=(t,s,e,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of q(s))!G.call(t,n)&&n!==e&&x(t,n,{get:()=>s[n],enumerable:!(c=N(s,n))||c.enumerable});return t};var W=t=>j(x({},"__esModule",{value:!0}),t);var B={};k(B,{VALUE_TRANSFORMERS:()=>E,changeGlobalTheme:()=>$,set:()=>U,setEach:()=>M,setValue:()=>P});module.exports=W(B);var p=require("./factory.js"),o=require("./system/index.js"),S=require("@symbo.ls/utils");const Y=(t,s)=>{const e=(0,p.getActiveConfig)(),{cssVars:c}=e,n=s.startsWith("--")?s:`--${s}`;return c[n]=t,t},l=t=>t,E={color:o.setColor,gradient:o.setGradient,font:o.setFont,fontFamily:o.setFontFamily,fontfamily:o.setFontFamily,theme:o.setTheme,icons:o.setSvgIcon,semanticIcons:l,semanticicons:l,svg:o.setSVG,svgData:l,typography:l,shadow:o.setShadow,spacing:l,media:l,grid:l,class:l,timing:l,reset:l,unit:l,animation:l,vars:Y,sizes:l},P=(t,s,e)=>{const c=(0,p.getActiveConfig)(),n=(0,p.toCamel)(t),i=n.toLowerCase(),f=c[n]||c[i]||c[t],r=E[n]||E[i];if(r)try{const d=r(s,e);return f&&(f[e]=d),f}catch(d){c.verbose&&console.warn("Error setting",i,"value",s,e,d)}c.verbose&&console.warn("Can not find",i,"method in scratch")},M=(t,s)=>{const e=(0,p.getActiveConfig)(),c=t.toLowerCase();return Object.keys(s).sort((i,f)=>{const r=(0,S.isObject)(s[i])||(0,S.isArray)(s[i])?1:0,d=(0,S.isObject)(s[f])||(0,S.isArray)(s[f])?1:0;return r-d}).forEach(i=>{try{return P(c,s[i],i)}catch(f){e.verbose&&console.warn("Error setting",c,"value",s[i],i,f)}}),e[c]||e[t]},$=(t,s)=>{const e=s||(0,p.getActiveConfig)();e.globalTheme=t;const n=(e.document&&e.document.documentElement?e.document:null)||(typeof document<"u"?document:null),i=n&&n.defaultView||(typeof window<"u"?window:null);if(n){const r=e.themeRoot||n.documentElement;if(t&&t!=="auto")r.setAttribute("data-theme",t),t==="dark"||t==="light"?r.style.colorScheme=t:r.style.colorScheme="light dark";else if(i&&i.matchMedia){const u=g=>{r.setAttribute("data-theme",g.matches?"dark":"light")},m=i.matchMedia("(prefers-color-scheme: dark)");if(u(m),r.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=u;try{m.addEventListener("change",u)}catch{m.addListener(u)}}}else r.setAttribute("data-theme","light"),r.style.colorScheme="light"}const f=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const r in e.cssVars)r.startsWith(f)&&delete e.cssVars[r];for(const r in e.cssMediaVars)delete e.cssMediaVars[r];if(n&&e.cssVars){const r=e.scopeSelector||":root",d=n.styleSheets;for(let u=0;u<d.length;u++)try{const m=d[u].cssRules;for(let g=0;g<m.length;g++)if(m[g].selectorText===r){for(const b in e.cssVars)m[g].style.setProperty(b,e.cssVars[b]);return e}}catch{}}return e},z={},U=(t,s=z)=>{let e=s.config||(0,p.getActiveConfig)();const{version:c,verbose:n,useVariable:i,useReset:f,useSvgSprite:r,useFontImport:d,useIconSprite:u,globalTheme:m,themeRoot:g,useDocumentTheme:b,useDefaultConfig:I,semanticIcons:R,hoverMedia:A,files:F,assets:_,...v}=t;s.newConfig&&(e=(0,p.setActiveConfig)(s.newConfig)),F!==void 0&&(e.files=F),_!==void 0&&(e.assets=_),n!==void 0&&(e.verbose=n),i!==void 0&&(e.useVariable=i),f!==void 0&&(e.useReset=f),d!==void 0&&(e.useFontImport=d),r!==void 0&&(e.useSvgSprite=r),u!==void 0&&(e.useIconSprite=u),b!==void 0&&(e.useDocumentTheme=b),m!==void 0&&(e.globalTheme=m),g!==void 0&&(e.themeRoot=g),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),I!==void 0&&(e.useDefaultConfig=I),R!==void 0&&(e.semanticIcons=R),A!==void 0&&(e.hoverMedia=A),e.verbose&&console.log(e);const C=(e.document&&e.document.documentElement?e.document:null)||(typeof document<"u"?document:null),w=C&&C.defaultView||(typeof window<"u"?window:null),y=C&&(e.themeRoot||C.documentElement);if(y&&typeof y.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")y.setAttribute("data-theme",e.globalTheme),e.globalTheme==="dark"||e.globalTheme==="light"?y.style.colorScheme=e.globalTheme:y.style.colorScheme="light dark";else if(w&&w.matchMedia){const h=D=>{y.setAttribute("data-theme",D.matches?"dark":"light")},V=w.matchMedia("(prefers-color-scheme: dark)");if(h(V),y.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=h;try{V.addEventListener("change",h)}catch{V.addListener(h)}}}else y.setAttribute("data-theme","light"),y.style.colorScheme="light";e.__svgCache||(e.__svgCache={});const T=Object.keys(v),L=new Set(T);if(T.forEach(a=>{const h=a.toLowerCase();h!==a&&L.has(h)&&(0,S.deepMerge)(v[h],v[a])}),T.map(a=>{const h=a.toLowerCase();if(!(h!==a&&L.has(h)))return M(a,v[a])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),v.typography)try{(0,o.applyTypographySequence)()}catch(a){e.verbose&&console.warn("Error applying typography sequence",a)}if(v.spacing)try{(0,o.applySpacingSequence)()}catch(a){e.verbose&&console.warn("Error applying spacing sequence",a)}if(v.timing)try{(0,o.applyTimingSequence)()}catch(a){e.verbose&&console.warn("Error applying timing sequence",a)}(0,o.applyDocument)();const O=(0,o.applyReset)();return O&&(e.reset=O),e};
1
+ "use strict";var x=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var k=(s,t)=>{for(var e in t)x(s,e,{get:t[e],enumerable:!0})},j=(s,t,e,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of q(t))!G.call(s,r)&&r!==e&&x(s,r,{get:()=>t[r],enumerable:!(c=N(t,r))||c.enumerable});return s};var W=s=>j(x({},"__esModule",{value:!0}),s);var B={};k(B,{VALUE_TRANSFORMERS:()=>E,changeGlobalTheme:()=>$,set:()=>U,setEach:()=>M,setValue:()=>P});module.exports=W(B);var p=require("./factory.js"),o=require("./system/index.js"),S=require("@symbo.ls/utils");const Y=(s,t)=>{const e=(0,p.getActiveConfig)(),{cssVars:c}=e,r=t.startsWith("--")?t:`--${t}`;return c[r]=s,s},d=s=>s,E={color:o.setColor,gradient:o.setGradient,font:o.setFont,fontFamily:o.setFontFamily,fontfamily:o.setFontFamily,theme:o.setTheme,icons:o.setSvgIcon,semanticIcons:d,semanticicons:d,svg:o.setSVG,svgData:d,typography:d,shadow:o.setShadow,spacing:d,media:d,grid:d,class:d,timing:d,reset:d,unit:d,animation:d,vars:Y,sizes:d},P=(s,t,e)=>{const c=(0,p.getActiveConfig)(),r=(0,p.toCamel)(s),i=r.toLowerCase(),l=c[r]||c[i]||c[s],n=E[r]||E[i];if(n)try{const a=n(t,e);return l&&(l[e]=a),l}catch(a){c.verbose&&console.warn("Error setting",i,"value",t,e,a)}if(!n){const a=l||c[i]||(c[i]={});return a[e]=t,a}c.verbose&&console.warn("Can not find",i,"method in scratch")},M=(s,t)=>{const e=(0,p.getActiveConfig)(),c=s.toLowerCase();return Object.keys(t).sort((i,l)=>{const n=(0,S.isObject)(t[i])||(0,S.isArray)(t[i])?1:0,a=(0,S.isObject)(t[l])||(0,S.isArray)(t[l])?1:0;return n-a}).forEach(i=>{try{return P(c,t[i],i)}catch(l){e.verbose&&console.warn("Error setting",c,"value",t[i],i,l)}}),e[c]||e[s]},$=(s,t)=>{const e=t||(0,p.getActiveConfig)();e.globalTheme=s;const r=(e.document&&e.document.documentElement?e.document:null)||(typeof document<"u"?document:null),i=r&&r.defaultView||(typeof window<"u"?window:null);if(r){const n=e.themeRoot||r.documentElement;if(s&&s!=="auto")n.setAttribute("data-theme",s),s==="dark"||s==="light"?n.style.colorScheme=s:n.style.colorScheme="light dark";else if(i&&i.matchMedia){const u=g=>{n.setAttribute("data-theme",g.matches?"dark":"light")},m=i.matchMedia("(prefers-color-scheme: dark)");if(u(m),n.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=u;try{m.addEventListener("change",u)}catch{m.addListener(u)}}}else n.setAttribute("data-theme","light"),n.style.colorScheme="light"}const l=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const n in e.cssVars)n.startsWith(l)&&delete e.cssVars[n];for(const n in e.cssMediaVars)delete e.cssMediaVars[n];if(r&&e.cssVars){const n=e.scopeSelector||":root",a=r.styleSheets;for(let u=0;u<a.length;u++)try{const m=a[u].cssRules;for(let g=0;g<m.length;g++)if(m[g].selectorText===n){for(const v in e.cssVars)m[g].style.setProperty(v,e.cssVars[v]);return e}}catch{}}return e},z={},U=(s,t=z)=>{let e=t.config||(0,p.getActiveConfig)();const{version:c,verbose:r,useVariable:i,useReset:l,useSvgSprite:n,useFontImport:a,useIconSprite:u,globalTheme:m,themeRoot:g,useDocumentTheme:v,useDefaultConfig:I,semanticIcons:R,hoverMedia:A,files:F,assets:_,...b}=s;t.newConfig&&(e=(0,p.setActiveConfig)(t.newConfig)),F!==void 0&&(e.files=F),_!==void 0&&(e.assets=_),r!==void 0&&(e.verbose=r),i!==void 0&&(e.useVariable=i),l!==void 0&&(e.useReset=l),a!==void 0&&(e.useFontImport=a),n!==void 0&&(e.useSvgSprite=n),u!==void 0&&(e.useIconSprite=u),v!==void 0&&(e.useDocumentTheme=v),m!==void 0&&(e.globalTheme=m),g!==void 0&&(e.themeRoot=g),s.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=s.useThemeSuffixedVars),I!==void 0&&(e.useDefaultConfig=I),R!==void 0&&(e.semanticIcons=R),A!==void 0&&(e.hoverMedia=A),e.verbose&&console.log(e);const C=(e.document&&e.document.documentElement?e.document:null)||(typeof document<"u"?document:null),w=C&&C.defaultView||(typeof window<"u"?window:null),y=C&&(e.themeRoot||C.documentElement);if(y&&typeof y.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")y.setAttribute("data-theme",e.globalTheme),e.globalTheme==="dark"||e.globalTheme==="light"?y.style.colorScheme=e.globalTheme:y.style.colorScheme="light dark";else if(w&&w.matchMedia){const h=D=>{y.setAttribute("data-theme",D.matches?"dark":"light")},V=w.matchMedia("(prefers-color-scheme: dark)");if(h(V),y.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=h;try{V.addEventListener("change",h)}catch{V.addListener(h)}}}else y.setAttribute("data-theme","light"),y.style.colorScheme="light";e.__svgCache||(e.__svgCache={});const T=Object.keys(b),L=new Set(T);if(T.forEach(f=>{const h=f.toLowerCase();h!==f&&L.has(h)&&(0,S.deepMerge)(b[h],b[f])}),T.map(f=>{const h=f.toLowerCase();if(!(h!==f&&L.has(h)))return M(f,b[f])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),b.typography)try{(0,o.applyTypographySequence)()}catch(f){e.verbose&&console.warn("Error applying typography sequence",f)}if(b.spacing)try{(0,o.applySpacingSequence)()}catch(f){e.verbose&&console.warn("Error applying spacing sequence",f)}if(b.timing)try{(0,o.applyTimingSequence)()}catch(f){e.verbose&&console.warn("Error applying timing sequence",f)}(0,o.applyDocument)();const O=(0,o.applyReset)();return O&&(e.reset=O),e};
@@ -1 +1 @@
1
- "use strict";var w=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var L=(r,s)=>{for(var l in s)w(r,l,{get:s[l],enumerable:!0})},q=(r,s,l,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let p of D(s))!E.call(r,p)&&p!==l&&w(r,p,{get:()=>s[p],enumerable:!(e=T(s,p))||e.enumerable});return r};var O=r=>q(w({},"__esModule",{value:!0}),r);var z={};L(z,{getColor:()=>x,getMediaColor:()=>W,setAdaptiveSchemeVar:()=>P,setColor:()=>S,setGradient:()=>j});module.exports=O(z);var a=require("@symbo.ls/utils"),M=require("../factory.js"),g=require("../utils/index.js");const x=(r,s,l)=>{const e=l||(0,M.getActiveConfig)();if(!(0,a.isString)(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if((0,g.isCSSVar)(r))return`var(${r})`;s&&r[s]&&(r=r[s]);let p,c,t;if((0,a.isArray)(r))[p,c,t]=r;else{const o=(0,g.parseColorToken)(r);if(!o){const{color:V,gradient:C}=e;let h=C[r]||V[r];return h?(s&&h[s]&&(h=h[s]),e.useVariable?`var(${h.var})`:h.value):r}if(o.passthrough)return o.passthrough;if(o.cssVar)return`var(${o.cssVar})`;p=o.name,c=o.alpha,t=o.tone}const{color:b,gradient:$}=e;let i=b[p]||$[p];if(!i)return e.verbose&&console.warn("Can't find color ",p),r;s&&(i[s]?i=i[s]:e.verbose&&console.warn(r," - does not have ",s));let f=i.rgb;if(!f){const o=e.useVariable?`var(${i.var})`:i.value;if(c&&o){const V=Math.round(parseFloat(c)*100);return`color-mix(in srgb, ${o} ${V}%, transparent)`}return o}return t&&!i[t]&&(f=(0,g.getRgbTone)(f,t),i[t]={rgb:f,var:`${i.var}-${t}`}),i[t]&&(f=i[t].rgb),c?`rgba(${f}, ${c})`:t?`rgba(${f}, 1)`:e.useVariable?`var(${i.var})`:`rgb(${f})`},W=(r,s,l)=>{const e=l||(0,M.getActiveConfig)();if(s||(s=e.globalTheme==="auto"?null:e.globalTheme),!(0,a.isString)(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if((0,g.isCSSVar)(r))return`var(${r})`;let p,c,t;if((0,a.isArray)(r))p=r[0];else{const o=(0,g.parseColorToken)(r);if(o){if(o.passthrough)return o.passthrough;if(o.cssVar)return`var(${o.cssVar})`;p=o.name,c=o.alpha,t=o.tone}else p=r}const{color:b,gradient:$}=e,i=b[p]||$[p],f=(0,a.isObject)(i);if(f&&i.value)return x(r,`@${s}`,l);if(f){if(e.useVariable&&i.var)return c||t?x(r,null,l):`var(${i.var})`;if(s)return x(r,`@${s}`,l);{const o={};for(const V in i){if(V.charCodeAt(0)!==64)continue;const C=e.media[V.slice(1)];if(!C)continue;const h="@media "+(C==="print"?`${C}`:`screen and ${C}`);o[h]=x(r,V,l)}return o}}else return e.verbose&&console.warn("Can't find color",r),r},P=(r,s,l,e)=>{const c=`--${e.varPrefix?e.varPrefix+"-":""}${s}-${l}`;let t;const b={};for(const $ in r){if($.charCodeAt(0)!==64)continue;const i=$.slice(1),f=r[$],o=f&&(f.value||f);!o||typeof o!="string"||(b[i]=o,(i==="light"||t===void 0)&&(t=o))}if(t!==void 0){e.cssVars[c]=t,e.cssMediaVars||(e.cssMediaVars={});for(const $ in b){const i=`[data-theme="${$}"]`;if(e.cssMediaVars[i]||(e.cssMediaVars[i]={}),e.cssMediaVars[i][c]=b[$],$==="light"||$==="dark"){const f=`@media (prefers-color-scheme: ${$})`;e.cssMediaVars[f]||(e.cssMediaVars[f]={}),e.cssMediaVars[f][c]=b[$]}}return r.var=c,c}},S=(r,s,l)=>{const e=(0,M.getActiveConfig)();if((0,a.isString)(r)&&(0,g.isCSSVar)(r)){const d=r.slice(2);if(r=x(d),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const n=d.split(" ");let u=e.color[n[0]];if(u&&!u.value&&!u.rgb&&((0,a.isString)(u)||(0,a.isArray)(u)||(0,a.isObject)(u))&&(e.color[n[0]]=S(u,n[0]),u=e.color[n[0]]),u&&u.value){let m=u.rgb;const A=n[1]!==void 0?n[1]:"1",R=n[2];R&&(m=(0,g.getRgbTone)(m,R)),r=`rgba(${m}, ${A})`}else{const m=n[2],A=n[1]!==void 0?n[1]:"1";if(m)try{const R=(0,g.colorStringToRgbaArray)(n[0]);R&&R.length>=3?r=`rgba(${(0,g.getRgbTone)(R.slice(0,3).join(", "),m)}, ${A})`:r=n[0]}catch{r=n[0]}else r=n[0]}}}if((0,a.isArray)(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),(0,a.isObject)(r)){const d={};for(const n in r)d[n]=S(r[n],s,n.slice(0,1)==="@"?n.slice(1):n);return e.useVariable&&P(d,"color",s,e),d}const c=`--${e.varPrefix?e.varPrefix+"-":""}color-${s}`+(l?`-${l}`:"");let t=r.value||r;if((0,a.isString)(t)&&t.includes(".")&&!t.includes("(")){const[d,n]=t.split("."),u=e.color[d];u&&u.rgb&&(t=`rgba(${u.rgb}, ${parseFloat("0."+n)||1})`)}if((0,a.isString)(t)&&!t.includes("(")&&!t.startsWith("#")){const d=(0,g.parseColorToken)(t);if(d&&d.name&&!d.passthrough&&!d.cssVar){const n=e.color[d.name];n&&!n.value&&!n.rgb&&((0,a.isString)(n)||(0,a.isArray)(n)||(0,a.isObject)(n))&&(e.color[d.name]=S(n,d.name));const u=e.color[d.name];if(u&&u.rgb){let m=u.rgb;d.tone&&(m=(0,g.getRgbTone)(m,d.tone));const A=d.alpha?parseFloat(d.alpha):1;t=`rgba(${m}, ${A})`}}}const b=(0,g.colorStringToRgbaArray)(t),[$,i,f,o=1]=b,V=parseFloat(o.toFixed(2)),C=`${$}, ${i}, ${f}`,h=`rgba(${C}, ${V})`;return e.useVariable&&(e.cssVars[c]=h),{var:c,rgb:C,alpha:V,value:h}},j=(r,s,l)=>{const e=(0,M.getActiveConfig)();if((0,a.isString)(r)&&(0,g.isCSSVar)(r)&&(r=x(r.slice(2))),(0,a.isArray)(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),(0,a.isObject)(r)){const t={};for(const b in r)t[b]=j(r[b],s,b.slice(0,1)==="@"?b.slice(1):b);return e.useVariable&&P(t,"gradient",s,e),t}const c=`--${e.varPrefix?e.varPrefix+"-":""}gradient-${s}`+(l?`-${l}`:"");return e.useVariable&&(e.cssVars[c]=r.value||r),{var:c,value:r.value||r}};
1
+ "use strict";var w=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var L=(r,s)=>{for(var d in s)w(r,d,{get:s[d],enumerable:!0})},q=(r,s,d,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let l of D(s))!E.call(r,l)&&l!==d&&w(r,l,{get:()=>s[l],enumerable:!(e=T(s,l))||e.enumerable});return r};var O=r=>q(w({},"__esModule",{value:!0}),r);var z={};L(z,{getColor:()=>R,getMediaColor:()=>W,setAdaptiveSchemeVar:()=>P,setColor:()=>S,setGradient:()=>j});module.exports=O(z);var f=require("@symbo.ls/utils"),M=require("../factory.js"),u=require("../utils/index.js");const R=(r,s,d)=>{const e=d||(0,M.getActiveConfig)();if(!(0,f.isString)(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if((0,u.isCSSVar)(r))return`var(${r})`;s&&r[s]&&(r=r[s]);let l,a,o;if((0,f.isArray)(r))[l,a,o]=r;else{const t=(0,u.parseColorToken)(r);if(!t){const{color:V,gradient:C}=e;let h=C[r]||V[r];return h?(s&&h[s]&&(h=h[s]),e.useVariable?`var(${h.var})`:h.value):r}if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;l=t.name,a=t.alpha,o=t.tone}const{color:g,gradient:b}=e;let n=g[l]||b[l];if(!n)return e.verbose&&console.warn("Can't find color ",l),r;s&&(n[s]?n=n[s]:e.verbose&&console.warn(r," - does not have ",s));let c=n.rgb;if(!c){const t=e.useVariable?`var(${n.var})`:n.value;if(a&&t){const V=Math.round(parseFloat(a)*100);return`color-mix(in srgb, ${t} ${V}%, transparent)`}return t}return o&&!n[o]&&(c=(0,u.getRgbTone)(c,o),n[o]={rgb:c,var:`${n.var}-${o}`}),n[o]&&(c=n[o].rgb),a?`rgba(${c}, ${a})`:o?`rgba(${c}, 1)`:e.useVariable?`var(${n.var})`:`rgb(${c})`},W=(r,s,d)=>{const e=d||(0,M.getActiveConfig)();if(s||(s=e.globalTheme==="auto"?null:e.globalTheme),!(0,f.isString)(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if((0,u.isCSSVar)(r))return`var(${r})`;let l,a,o;if((0,f.isArray)(r))l=r[0];else{const t=(0,u.parseColorToken)(r);if(t){if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;l=t.name,a=t.alpha,o=t.tone}else l=r}const{color:g,gradient:b}=e,n=g[l]||b[l],c=(0,f.isObject)(n);if(c&&n.value)return R(r,`@${s}`,d);if(c){if(e.useVariable&&n.var)return a||o?R(r,null,d):`var(${n.var})`;if(s)return R(r,`@${s}`,d);{const t={};for(const V in n){if(V.charCodeAt(0)!==64)continue;const C=e.media[V.slice(1)];if(!C)continue;const h="@media "+(C==="print"?`${C}`:`screen and ${C}`);t[h]=R(r,V,d)}return t}}else return e.verbose&&console.warn("Can't find color",r),r},P=(r,s,d,e)=>{const a=`--${e.varPrefix?e.varPrefix+"-":""}${s}-${d}`;let o;const g={};for(const b in r){if(b.charCodeAt(0)!==64)continue;const n=b.slice(1),c=r[b],t=c&&(c.value||c);!t||typeof t!="string"||(g[n]=t,(n==="light"||o===void 0)&&(o=t))}if(o!==void 0){e.cssVars[a]=o,e.cssMediaVars||(e.cssMediaVars={});for(const b in g){const n=`[data-theme="${b}"]`;if(e.cssMediaVars[n]||(e.cssMediaVars[n]={}),e.cssMediaVars[n][a]=g[b],b==="light"||b==="dark"){const c=`@media (prefers-color-scheme: ${b})`;e.cssMediaVars[c]||(e.cssMediaVars[c]={}),e.cssMediaVars[c][a]=g[b]}}return r.var=a,a}},S=(r,s,d)=>{const e=(0,M.getActiveConfig)();if((0,f.isString)(r)&&(0,u.isCSSVar)(r)){const p=r.slice(2);if(r=R(p),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const i=p.split(" ");let $=e.color[i[0]];if($&&!$.value&&!$.rgb&&((0,f.isString)($)||(0,f.isArray)($)||(0,f.isObject)($))&&(e.color[i[0]]=S($,i[0]),$=e.color[i[0]]),$&&$.value){let m=$.rgb;const A=i[1]!==void 0?i[1]:"1",x=i[2];x&&(m=(0,u.getRgbTone)(m,x)),r=`rgba(${m}, ${A})`}else{const m=i[2],A=i[1]!==void 0?i[1]:"1";if(m)try{const x=(0,u.colorStringToRgbaArray)(i[0]);x&&x.length>=3?r=`rgba(${(0,u.getRgbTone)(x.slice(0,3).join(", "),m)}, ${A})`:r=i[0]}catch{r=i[0]}else r=i[0]}}}if((0,f.isArray)(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),(0,f.isObject)(r)){const p={};for(const i in r)p[i]=S(r[i],s,i.slice(0,1)==="@"?i.slice(1):i);return e.useVariable&&P(p,"color",s,e),p}const a=`--${e.varPrefix?e.varPrefix+"-":""}color-${s}`+(d?`-${d}`:"");let o=r.value||r;if((0,f.isString)(o)&&!o.includes("(")&&!o.startsWith("#")){const p=(0,u.parseColorToken)(o);if(p&&p.name&&!p.passthrough&&!p.cssVar){const i=e.color[p.name];i&&!i.value&&!i.rgb&&((0,f.isString)(i)||(0,f.isArray)(i)||(0,f.isObject)(i))&&(e.color[p.name]=S(i,p.name));const $=e.color[p.name];if($&&$.rgb){let m=$.rgb;p.tone&&(m=(0,u.getRgbTone)(m,p.tone));const A=p.alpha?parseFloat(p.alpha):1;o=`rgba(${m}, ${A})`}}}const g=(0,u.colorStringToRgbaArray)(o),[b,n,c,t=1]=g,V=parseFloat(t.toFixed(2)),C=`${b}, ${n}, ${c}`,h=`rgba(${C}, ${V})`;return e.useVariable&&(e.cssVars[a]=h),{var:a,rgb:C,alpha:V,value:h}},j=(r,s,d)=>{const e=(0,M.getActiveConfig)();if((0,f.isString)(r)&&(0,u.isCSSVar)(r)&&(r=R(r.slice(2))),(0,f.isArray)(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),(0,f.isObject)(r)){const o={};for(const g in r)o[g]=j(r[g],s,g.slice(0,1)==="@"?g.slice(1):g);return e.useVariable&&P(o,"gradient",s,e),o}const a=`--${e.varPrefix?e.varPrefix+"-":""}gradient-${s}`+(d?`-${d}`:"");return e.useVariable&&(e.cssVars[a]=r.value||r),{var:a,value:r.value||r}};
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var S=(t,e)=>{for(var r in e)p(t,r,{get:e[r],enumerable:!0})},$=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of R(e))!y.call(t,n)&&n!==r&&p(t,n,{get:()=>e[n],enumerable:!(s=T(e,n))||s.enumerable});return t};var I=t=>$(p({},"__esModule",{value:!0}),t);var G={};S(G,{CSS_NATIVE_COLOR_REGEX:()=>b,changeLightness:()=>F,colorStringToRgbaArray:()=>c,getColorShade:()=>x,getRgbTone:()=>z,hexToRgb:()=>O,hexToRgbArray:()=>h,hexToRgba:()=>L,hslToRgb:()=>g,isCSSVar:()=>m,isResolvedColor:()=>V,mixTwoColors:()=>M,mixTwoRgb:()=>A,mixTwoRgba:()=>d,opacify:()=>_,parseColorToken:()=>N,rgbArrayToHex:()=>u,rgbToHSL:()=>f,rgbToHex:()=>E,splitTopLevelCommas:()=>j});module.exports=I(G);var i=require("@symbo.ls/utils");const c=t=>{if(t==="")return[0,0,0,0];if(t.toLowerCase()==="transparent")return[0,0,0,0];if(t[0]==="#")return t.length<7&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(t.length>4?t[4]+t[4]:"")),[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16),t.length>7?parseInt(t.substr(7,2),16)/255:1];if(t.indexOf("rgb")===-1&&i.document&&i.window){const e=i.document.body.appendChild(i.document.createElement("fictum")),r="rgb(1, 2, 3)";if(e.style.color=r,e.style.color!==r){i.document.body.removeChild(e);return}if(e.style.color=t,e.style.color===r||e.style.color==="")return i.document.body.removeChild(e),[0,0,0,0];t=i.window.getComputedStyle(e).color,i.document.body.removeChild(e)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(e=>+e)):[0,0,0,0]},M=(t,e,r=.5)=>(t=c(t),e=c(e),d(t,e,r)),O=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgb(${r},${s},${n})`},h=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return[r,s,n]},E=(t,e,r)=>"#"+(1<<24|t<<16|e<<8|r).toString(16).slice(1),u=([t,e,r])=>((1<<24)+(t<<16)+(e<<8)+r).toString(16).slice(1),L=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgba(${r},${s},${n},${e})`},A=(t,e,r=.5)=>{const s=[];for(let n=0;n<3;n++)s[n]=~~(t[n]+(e[n]-t[n])*r);return`rgb(${s})`},F=(t,e)=>{const[r,s,n]=e,a=Math.max(0,Math.min(100,n+parseFloat(t)));return[r,s,a]},f=(t,e,r)=>{const s=Math.max(t,e,r),n=s-Math.min(t,e,r),a=1-Math.abs(s+s-n-1),o=n&&(s==t?(e-r)/n:s==e?2+(r-t)/n:4+(t-e)/n);return[60*(o<0?o+6:o),a?n/a:0,(s+s-n)/2]},g=(t,e,r,s=e*Math.min(r,1-r),n=(a,o=(a+t/30)%12)=>r-s*Math.max(Math.min(o-3,9-o,1),-1))=>[n(0),n(8),n(4)],x=(t,e)=>{const r=parseInt(t,16);let s=(r>>16)+e;s>255?s=255:s<0&&(s=0);let n=(r>>8&255)+e;n>255?n=255:n<0&&(n=0);let a=(r&255)+e;return a>255?a=255:a<0&&(a=0),((a|n<<8|s<<16)+16777216).toString(16).slice(1)},d=(t,e,r=.5)=>{const s=[];for(let n=0;n<4;n++){const a=n===3?o=>o:Math.round;s[n]=a(t[n]+(e[n]-t[n])*r)}return`rgba(${s})`},_=(t,e)=>{const r=c(t);if(!r){(0,i.isNotProduction)()&&console.warn(t+" color is not rgba");return}return r[3]=e,`rgba(${r})`},m=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,b=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,H=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,N=t=>{if(!(0,i.isString)(t))return null;if(b.test(t))return{passthrough:t};if(m(t))return{cssVar:t};const e=t.match(H);if(!e)return null;const[,r,s,n]=e,a=s!==void 0?`0.${s}`:void 0,o=n&&n[0]==="="?n.slice(1):n;return{name:r,alpha:a,tone:o}},V=t=>(0,i.isString)(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),j=t=>{const e=[];let r="",s=0;for(const n of t){if(n==="("?s+=1:n===")"&&s>0&&(s-=1),n===","&&s===0){e.push(r),r="";continue}r+=n}return(r.length||!e.length)&&e.push(r),e},z=(t,e)=>{(0,i.isString)(t)&&t.includes("rgb")&&(t=c(t).join(", ")),(0,i.isString)(t)&&(t=t.split(",").map(n=>parseFloat(n.trim()))),(0,i.isNumber)(e)&&(e+="");const r=u(t),s=e.slice(0,1);if(s==="-"||s==="+"){const n=x(r,parseFloat(e));return h(n).join(", ")}else{const[n,a,o]=t,l=f(n,a,o),[w,C,X]=l;return g(w,C,parseFloat(e)/100*255)}};
1
+ "use strict";var c=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var S=(t,e)=>{for(var r in e)c(t,r,{get:e[r],enumerable:!0})},$=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!M.call(t,n)&&n!==r&&c(t,n,{get:()=>e[n],enumerable:!(s=R(e,n))||s.enumerable});return t};var I=t=>$(c({},"__esModule",{value:!0}),t);var X={};S(X,{CSS_NATIVE_COLOR_REGEX:()=>b,changeLightness:()=>_,colorStringToRgbaArray:()=>p,getColorShade:()=>m,getRgbTone:()=>G,hexToRgb:()=>E,hexToRgbArray:()=>h,hexToRgba:()=>A,hslToRgb:()=>g,isCSSVar:()=>d,isResolvedColor:()=>V,mixTwoColors:()=>O,mixTwoRgb:()=>F,mixTwoRgba:()=>x,opacify:()=>H,parseColorToken:()=>j,rgbArrayToHex:()=>u,rgbToHSL:()=>f,rgbToHex:()=>L,splitTopLevelCommas:()=>z});module.exports=I(X);var i=require("@symbo.ls/utils");const p=t=>{if(t==="")return[0,0,0,0];if(t.toLowerCase()==="transparent")return[0,0,0,0];if(t[0]==="#")return t.length<7&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(t.length>4?t[4]+t[4]:"")),[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16),t.length>7?parseInt(t.substr(7,2),16)/255:1];if(t.indexOf("rgb")===-1&&i.document&&i.window){const e=i.document.body.appendChild(i.document.createElement("fictum")),r="rgb(1, 2, 3)";if(e.style.color=r,e.style.color!==r){i.document.body.removeChild(e);return}if(e.style.color=t,e.style.color===r||e.style.color==="")return i.document.body.removeChild(e),[0,0,0,0];t=i.window.getComputedStyle(e).color,i.document.body.removeChild(e)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(e=>+e)):[0,0,0,0]},O=(t,e,r=.5)=>(t=p(t),e=p(e),x(t,e,r)),E=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgb(${r},${s},${n})`},h=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return[r,s,n]},L=(t,e,r)=>"#"+(1<<24|t<<16|e<<8|r).toString(16).slice(1),u=([t,e,r])=>((1<<24)+(t<<16)+(e<<8)+r).toString(16).slice(1),A=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgba(${r},${s},${n},${e})`},F=(t,e,r=.5)=>{const s=[];for(let n=0;n<3;n++)s[n]=~~(t[n]+(e[n]-t[n])*r);return`rgb(${s})`},_=(t,e)=>{const[r,s,n]=e,a=Math.max(0,Math.min(100,n+parseFloat(t)));return[r,s,a]},f=(t,e,r)=>{const s=Math.max(t,e,r),n=s-Math.min(t,e,r),a=1-Math.abs(s+s-n-1),o=n&&(s==t?(e-r)/n:s==e?2+(r-t)/n:4+(t-e)/n);return[60*(o<0?o+6:o),a?n/a:0,(s+s-n)/2]},g=(t,e,r,s=e*Math.min(r,1-r),n=(a,o=(a+t/30)%12)=>r-s*Math.max(Math.min(o-3,9-o,1),-1))=>[n(0),n(8),n(4)],m=(t,e)=>{const r=parseInt(t,16);let s=(r>>16)+e;s>255?s=255:s<0&&(s=0);let n=(r>>8&255)+e;n>255?n=255:n<0&&(n=0);let a=(r&255)+e;return a>255?a=255:a<0&&(a=0),((a|n<<8|s<<16)+16777216).toString(16).slice(1)},x=(t,e,r=.5)=>{const s=[];for(let n=0;n<4;n++){const a=n===3?o=>o:Math.round;s[n]=a(t[n]+(e[n]-t[n])*r)}return`rgba(${s})`},H=(t,e)=>{const r=p(t);if(!r){(0,i.isNotProduction)()&&console.warn(t+" color is not rgba");return}return r[3]=e,`rgba(${r})`},d=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,b=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,N=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,j=t=>{if(!(0,i.isString)(t))return null;if(b.test(t))return{passthrough:t};if(d(t))return{cssVar:t};const e=t.match(N);if(!e)return null;const[,r,s,n]=e,a=s!==void 0?`0.${s}`:void 0,o=n&&n[0]==="="?n.slice(1):n;return{name:r,alpha:a,tone:o}},V=t=>(0,i.isString)(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),z=t=>{const e=[];let r="",s=0;for(const n of t){if(n==="("?s+=1:n===")"&&s>0&&(s-=1),n===","&&s===0){e.push(r),r="";continue}r+=n}return(r.length||!e.length)&&e.push(r),e},G=(t,e)=>{(0,i.isString)(t)&&t.includes("rgb")&&(t=p(t).join(", ")),(0,i.isString)(t)&&(t=t.split(",").map(n=>parseFloat(n.trim()))),(0,i.isNumber)(e)&&(e+="");const r=u(t),s=e.slice(0,1);if(s==="-"||s==="+"){const n=m(r,parseFloat(e));return h(n).join(", ")}else{const[n,a,o]=t,[l,w]=f(n/255,a/255,o/255),C=Math.max(0,Math.min(100,parseFloat(e)))/100;return g(l,w,C).map(T=>Math.round(Math.max(0,Math.min(1,T))*255)).join(", ")}};
@@ -1 +1 @@
1
- import{getActiveConfig as S,setActiveConfig as P,toCamel as M}from"./factory.js";import{setColor as N,setGradient as q,setFont as G,setFontFamily as _,setTheme as k,setSvgIcon as j,setSVG as W,applyTypographySequence as Y,applySpacingSequence as $,applyReset as z,applyTimingSequence as U,applyDocument as B,setShadow as H}from"./system/index.js";import{deepMerge as J,isObject as L,isArray as O}from"@symbo.ls/utils";const K=(t,o)=>{const e=S(),{cssVars:c}=e,r=o.startsWith("--")?o:`--${o}`;return c[r]=t,t},f=t=>t,D={color:N,gradient:q,font:G,fontFamily:_,fontfamily:_,theme:k,icons:j,semanticIcons:f,semanticicons:f,svg:W,svgData:f,typography:f,shadow:H,spacing:f,media:f,grid:f,class:f,timing:f,reset:f,unit:f,animation:f,vars:K,sizes:f},Q=(t,o,e)=>{const c=S(),r=M(t),n=r.toLowerCase(),a=c[r]||c[n]||c[t],s=D[r]||D[n];if(s)try{const l=s(o,e);return a&&(a[e]=l),a}catch(l){c.verbose&&console.warn("Error setting",n,"value",o,e,l)}c.verbose&&console.warn("Can not find",n,"method in scratch")},X=(t,o)=>{const e=S(),c=t.toLowerCase();return Object.keys(o).sort((n,a)=>{const s=L(o[n])||O(o[n])?1:0,l=L(o[a])||O(o[a])?1:0;return s-l}).forEach(n=>{try{return Q(c,o[n],n)}catch(a){e.verbose&&console.warn("Error setting",c,"value",o[n],n,a)}}),e[c]||e[t]},re=(t,o)=>{const e=o||S();e.globalTheme=t;const r=(e.document&&e.document.documentElement?e.document:null)||(typeof document<"u"?document:null),n=r&&r.defaultView||(typeof window<"u"?window:null);if(r){const s=e.themeRoot||r.documentElement;if(t&&t!=="auto")s.setAttribute("data-theme",t),t==="dark"||t==="light"?s.style.colorScheme=t:s.style.colorScheme="light dark";else if(n&&n.matchMedia){const d=h=>{s.setAttribute("data-theme",h.matches?"dark":"light")},u=n.matchMedia("(prefers-color-scheme: dark)");if(d(u),s.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=d;try{u.addEventListener("change",d)}catch{u.addListener(d)}}}else s.setAttribute("data-theme","light"),s.style.colorScheme="light"}const a=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const s in e.cssVars)s.startsWith(a)&&delete e.cssVars[s];for(const s in e.cssMediaVars)delete e.cssMediaVars[s];if(r&&e.cssVars){const s=e.scopeSelector||":root",l=r.styleSheets;for(let d=0;d<l.length;d++)try{const u=l[d].cssRules;for(let h=0;h<u.length;h++)if(u[h].selectorText===s){for(const y in e.cssVars)u[h].style.setProperty(y,e.cssVars[y]);return e}}catch{}}return e},Z={},ie=(t,o=Z)=>{let e=o.config||S();const{version:c,verbose:r,useVariable:n,useReset:a,useSvgSprite:s,useFontImport:l,useIconSprite:d,globalTheme:u,themeRoot:h,useDocumentTheme:y,useDefaultConfig:T,semanticIcons:V,hoverMedia:x,files:E,assets:I,...p}=t;o.newConfig&&(e=P(o.newConfig)),E!==void 0&&(e.files=E),I!==void 0&&(e.assets=I),r!==void 0&&(e.verbose=r),n!==void 0&&(e.useVariable=n),a!==void 0&&(e.useReset=a),l!==void 0&&(e.useFontImport=l),s!==void 0&&(e.useSvgSprite=s),d!==void 0&&(e.useIconSprite=d),y!==void 0&&(e.useDocumentTheme=y),u!==void 0&&(e.globalTheme=u),h!==void 0&&(e.themeRoot=h),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),T!==void 0&&(e.useDefaultConfig=T),V!==void 0&&(e.semanticIcons=V),x!==void 0&&(e.hoverMedia=x),e.verbose&&console.log(e);const v=(e.document&&e.document.documentElement?e.document:null)||(typeof document<"u"?document:null),b=v&&v.defaultView||(typeof window<"u"?window:null),g=v&&(e.themeRoot||v.documentElement);if(g&&typeof g.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")g.setAttribute("data-theme",e.globalTheme),e.globalTheme==="dark"||e.globalTheme==="light"?g.style.colorScheme=e.globalTheme:g.style.colorScheme="light dark";else if(b&&b.matchMedia){const m=F=>{g.setAttribute("data-theme",F.matches?"dark":"light")},w=b.matchMedia("(prefers-color-scheme: dark)");if(m(w),g.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=m;try{w.addEventListener("change",m)}catch{w.addListener(m)}}}else g.setAttribute("data-theme","light"),g.style.colorScheme="light";e.__svgCache||(e.__svgCache={});const C=Object.keys(p),R=new Set(C);if(C.forEach(i=>{const m=i.toLowerCase();m!==i&&R.has(m)&&J(p[m],p[i])}),C.map(i=>{const m=i.toLowerCase();if(!(m!==i&&R.has(m)))return X(i,p[i])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),p.typography)try{Y()}catch(i){e.verbose&&console.warn("Error applying typography sequence",i)}if(p.spacing)try{$()}catch(i){e.verbose&&console.warn("Error applying spacing sequence",i)}if(p.timing)try{U()}catch(i){e.verbose&&console.warn("Error applying timing sequence",i)}B();const A=z();return A&&(e.reset=A),e};export{D as VALUE_TRANSFORMERS,re as changeGlobalTheme,ie as set,X as setEach,Q as setValue};
1
+ import{getActiveConfig as S,setActiveConfig as P,toCamel as M}from"./factory.js";import{setColor as N,setGradient as q,setFont as G,setFontFamily as _,setTheme as k,setSvgIcon as j,setSVG as W,applyTypographySequence as Y,applySpacingSequence as $,applyReset as z,applyTimingSequence as U,applyDocument as B,setShadow as H}from"./system/index.js";import{deepMerge as J,isObject as L,isArray as O}from"@symbo.ls/utils";const K=(s,o)=>{const e=S(),{cssVars:i}=e,r=o.startsWith("--")?o:`--${o}`;return i[r]=s,s},l=s=>s,D={color:N,gradient:q,font:G,fontFamily:_,fontfamily:_,theme:k,icons:j,semanticIcons:l,semanticicons:l,svg:W,svgData:l,typography:l,shadow:H,spacing:l,media:l,grid:l,class:l,timing:l,reset:l,unit:l,animation:l,vars:K,sizes:l},Q=(s,o,e)=>{const i=S(),r=M(s),n=r.toLowerCase(),f=i[r]||i[n]||i[s],t=D[r]||D[n];if(t)try{const c=t(o,e);return f&&(f[e]=c),f}catch(c){i.verbose&&console.warn("Error setting",n,"value",o,e,c)}if(!t){const c=f||i[n]||(i[n]={});return c[e]=o,c}i.verbose&&console.warn("Can not find",n,"method in scratch")},X=(s,o)=>{const e=S(),i=s.toLowerCase();return Object.keys(o).sort((n,f)=>{const t=L(o[n])||O(o[n])?1:0,c=L(o[f])||O(o[f])?1:0;return t-c}).forEach(n=>{try{return Q(i,o[n],n)}catch(f){e.verbose&&console.warn("Error setting",i,"value",o[n],n,f)}}),e[i]||e[s]},re=(s,o)=>{const e=o||S();e.globalTheme=s;const r=(e.document&&e.document.documentElement?e.document:null)||(typeof document<"u"?document:null),n=r&&r.defaultView||(typeof window<"u"?window:null);if(r){const t=e.themeRoot||r.documentElement;if(s&&s!=="auto")t.setAttribute("data-theme",s),s==="dark"||s==="light"?t.style.colorScheme=s:t.style.colorScheme="light dark";else if(n&&n.matchMedia){const d=h=>{t.setAttribute("data-theme",h.matches?"dark":"light")},u=n.matchMedia("(prefers-color-scheme: dark)");if(d(u),t.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=d;try{u.addEventListener("change",d)}catch{u.addListener(d)}}}else t.setAttribute("data-theme","light"),t.style.colorScheme="light"}const f=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const t in e.cssVars)t.startsWith(f)&&delete e.cssVars[t];for(const t in e.cssMediaVars)delete e.cssMediaVars[t];if(r&&e.cssVars){const t=e.scopeSelector||":root",c=r.styleSheets;for(let d=0;d<c.length;d++)try{const u=c[d].cssRules;for(let h=0;h<u.length;h++)if(u[h].selectorText===t){for(const y in e.cssVars)u[h].style.setProperty(y,e.cssVars[y]);return e}}catch{}}return e},Z={},ie=(s,o=Z)=>{let e=o.config||S();const{version:i,verbose:r,useVariable:n,useReset:f,useSvgSprite:t,useFontImport:c,useIconSprite:d,globalTheme:u,themeRoot:h,useDocumentTheme:y,useDefaultConfig:T,semanticIcons:V,hoverMedia:x,files:E,assets:I,...p}=s;o.newConfig&&(e=P(o.newConfig)),E!==void 0&&(e.files=E),I!==void 0&&(e.assets=I),r!==void 0&&(e.verbose=r),n!==void 0&&(e.useVariable=n),f!==void 0&&(e.useReset=f),c!==void 0&&(e.useFontImport=c),t!==void 0&&(e.useSvgSprite=t),d!==void 0&&(e.useIconSprite=d),y!==void 0&&(e.useDocumentTheme=y),u!==void 0&&(e.globalTheme=u),h!==void 0&&(e.themeRoot=h),s.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=s.useThemeSuffixedVars),T!==void 0&&(e.useDefaultConfig=T),V!==void 0&&(e.semanticIcons=V),x!==void 0&&(e.hoverMedia=x),e.verbose&&console.log(e);const b=(e.document&&e.document.documentElement?e.document:null)||(typeof document<"u"?document:null),v=b&&b.defaultView||(typeof window<"u"?window:null),g=b&&(e.themeRoot||b.documentElement);if(g&&typeof g.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")g.setAttribute("data-theme",e.globalTheme),e.globalTheme==="dark"||e.globalTheme==="light"?g.style.colorScheme=e.globalTheme:g.style.colorScheme="light dark";else if(v&&v.matchMedia){const m=F=>{g.setAttribute("data-theme",F.matches?"dark":"light")},w=v.matchMedia("(prefers-color-scheme: dark)");if(m(w),g.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=m;try{w.addEventListener("change",m)}catch{w.addListener(m)}}}else g.setAttribute("data-theme","light"),g.style.colorScheme="light";e.__svgCache||(e.__svgCache={});const C=Object.keys(p),R=new Set(C);if(C.forEach(a=>{const m=a.toLowerCase();m!==a&&R.has(m)&&J(p[m],p[a])}),C.map(a=>{const m=a.toLowerCase();if(!(m!==a&&R.has(m)))return X(a,p[a])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),p.typography)try{Y()}catch(a){e.verbose&&console.warn("Error applying typography sequence",a)}if(p.spacing)try{$()}catch(a){e.verbose&&console.warn("Error applying spacing sequence",a)}if(p.timing)try{U()}catch(a){e.verbose&&console.warn("Error applying timing sequence",a)}B();const A=z();return A&&(e.reset=A),e};export{D as VALUE_TRANSFORMERS,re as changeGlobalTheme,ie as set,X as setEach,Q as setValue};
@@ -1 +1 @@
1
- import{isObject as M,isArray as R,isString as m}from"@symbo.ls/utils";import{getActiveConfig as S}from"../factory.js";import{colorStringToRgbaArray as D,getRgbTone as w,isCSSVar as P,parseColorToken as j}from"../utils/index.js";const x=(r,i,u)=>{const e=u||S();if(!m(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if(P(r))return`var(${r})`;i&&r[i]&&(r=r[i]);let g,a,s;if(R(r))[g,a,s]=r;else{const t=j(r);if(!t){const{color:$,gradient:V}=e;let b=V[r]||$[r];return b?(i&&b[i]&&(b=b[i]),e.useVariable?`var(${b.var})`:b.value):r}if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;g=t.name,a=t.alpha,s=t.tone}const{color:l,gradient:p}=e;let n=l[g]||p[g];if(!n)return e.verbose&&console.warn("Can't find color ",g),r;i&&(n[i]?n=n[i]:e.verbose&&console.warn(r," - does not have ",i));let c=n.rgb;if(!c){const t=e.useVariable?`var(${n.var})`:n.value;if(a&&t){const $=Math.round(parseFloat(a)*100);return`color-mix(in srgb, ${t} ${$}%, transparent)`}return t}return s&&!n[s]&&(c=w(c,s),n[s]={rgb:c,var:`${n.var}-${s}`}),n[s]&&(c=n[s].rgb),a?`rgba(${c}, ${a})`:s?`rgba(${c}, 1)`:e.useVariable?`var(${n.var})`:`rgb(${c})`},B=(r,i,u)=>{const e=u||S();if(i||(i=e.globalTheme==="auto"?null:e.globalTheme),!m(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if(P(r))return`var(${r})`;let g,a,s;if(R(r))g=r[0];else{const t=j(r);if(t){if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;g=t.name,a=t.alpha,s=t.tone}else g=r}const{color:l,gradient:p}=e,n=l[g]||p[g],c=M(n);if(c&&n.value)return x(r,`@${i}`,u);if(c){if(e.useVariable&&n.var)return a||s?x(r,null,u):`var(${n.var})`;if(i)return x(r,`@${i}`,u);{const t={};for(const $ in n){if($.charCodeAt(0)!==64)continue;const V=e.media[$.slice(1)];if(!V)continue;const b="@media "+(V==="print"?`${V}`:`screen and ${V}`);t[b]=x(r,$,u)}return t}}else return e.verbose&&console.warn("Can't find color",r),r},E=(r,i,u,e)=>{const a=`--${e.varPrefix?e.varPrefix+"-":""}${i}-${u}`;let s;const l={};for(const p in r){if(p.charCodeAt(0)!==64)continue;const n=p.slice(1),c=r[p],t=c&&(c.value||c);!t||typeof t!="string"||(l[n]=t,(n==="light"||s===void 0)&&(s=t))}if(s!==void 0){e.cssVars[a]=s,e.cssMediaVars||(e.cssMediaVars={});for(const p in l){const n=`[data-theme="${p}"]`;if(e.cssMediaVars[n]||(e.cssMediaVars[n]={}),e.cssMediaVars[n][a]=l[p],p==="light"||p==="dark"){const c=`@media (prefers-color-scheme: ${p})`;e.cssMediaVars[c]||(e.cssMediaVars[c]={}),e.cssMediaVars[c][a]=l[p]}}return r.var=a,a}},T=(r,i,u)=>{const e=S();if(m(r)&&P(r)){const f=r.slice(2);if(r=x(f),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const o=f.split(" ");let d=e.color[o[0]];if(d&&!d.value&&!d.rgb&&(m(d)||R(d)||M(d))&&(e.color[o[0]]=T(d,o[0]),d=e.color[o[0]]),d&&d.value){let h=d.rgb;const A=o[1]!==void 0?o[1]:"1",C=o[2];C&&(h=w(h,C)),r=`rgba(${h}, ${A})`}else{const h=o[2],A=o[1]!==void 0?o[1]:"1";if(h)try{const C=D(o[0]);C&&C.length>=3?r=`rgba(${w(C.slice(0,3).join(", "),h)}, ${A})`:r=o[0]}catch{r=o[0]}else r=o[0]}}}if(R(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),M(r)){const f={};for(const o in r)f[o]=T(r[o],i,o.slice(0,1)==="@"?o.slice(1):o);return e.useVariable&&E(f,"color",i,e),f}const a=`--${e.varPrefix?e.varPrefix+"-":""}color-${i}`+(u?`-${u}`:"");let s=r.value||r;if(m(s)&&s.includes(".")&&!s.includes("(")){const[f,o]=s.split("."),d=e.color[f];d&&d.rgb&&(s=`rgba(${d.rgb}, ${parseFloat("0."+o)||1})`)}if(m(s)&&!s.includes("(")&&!s.startsWith("#")){const f=j(s);if(f&&f.name&&!f.passthrough&&!f.cssVar){const o=e.color[f.name];o&&!o.value&&!o.rgb&&(m(o)||R(o)||M(o))&&(e.color[f.name]=T(o,f.name));const d=e.color[f.name];if(d&&d.rgb){let h=d.rgb;f.tone&&(h=w(h,f.tone));const A=f.alpha?parseFloat(f.alpha):1;s=`rgba(${h}, ${A})`}}}const l=D(s),[p,n,c,t=1]=l,$=parseFloat(t.toFixed(2)),V=`${p}, ${n}, ${c}`,b=`rgba(${V}, ${$})`;return e.useVariable&&(e.cssVars[a]=b),{var:a,rgb:V,alpha:$,value:b}},L=(r,i,u)=>{const e=S();if(m(r)&&P(r)&&(r=x(r.slice(2))),R(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),M(r)){const s={};for(const l in r)s[l]=L(r[l],i,l.slice(0,1)==="@"?l.slice(1):l);return e.useVariable&&E(s,"gradient",i,e),s}const a=`--${e.varPrefix?e.varPrefix+"-":""}gradient-${i}`+(u?`-${u}`:"");return e.useVariable&&(e.cssVars[a]=r.value||r),{var:a,value:r.value||r}};export{x as getColor,B as getMediaColor,E as setAdaptiveSchemeVar,T as setColor,L as setGradient};
1
+ import{isObject as M,isArray as x,isString as C}from"@symbo.ls/utils";import{getActiveConfig as S}from"../factory.js";import{colorStringToRgbaArray as D,getRgbTone as w,isCSSVar as P,parseColorToken as j}from"../utils/index.js";const R=(r,i,p)=>{const e=p||S();if(!C(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if(P(r))return`var(${r})`;i&&r[i]&&(r=r[i]);let g,a,t;if(x(r))[g,a,t]=r;else{const s=j(r);if(!s){const{color:$,gradient:V}=e;let b=V[r]||$[r];return b?(i&&b[i]&&(b=b[i]),e.useVariable?`var(${b.var})`:b.value):r}if(s.passthrough)return s.passthrough;if(s.cssVar)return`var(${s.cssVar})`;g=s.name,a=s.alpha,t=s.tone}const{color:d,gradient:l}=e;let o=d[g]||l[g];if(!o)return e.verbose&&console.warn("Can't find color ",g),r;i&&(o[i]?o=o[i]:e.verbose&&console.warn(r," - does not have ",i));let c=o.rgb;if(!c){const s=e.useVariable?`var(${o.var})`:o.value;if(a&&s){const $=Math.round(parseFloat(a)*100);return`color-mix(in srgb, ${s} ${$}%, transparent)`}return s}return t&&!o[t]&&(c=w(c,t),o[t]={rgb:c,var:`${o.var}-${t}`}),o[t]&&(c=o[t].rgb),a?`rgba(${c}, ${a})`:t?`rgba(${c}, 1)`:e.useVariable?`var(${o.var})`:`rgb(${c})`},B=(r,i,p)=>{const e=p||S();if(i||(i=e.globalTheme==="auto"?null:e.globalTheme),!C(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if(P(r))return`var(${r})`;let g,a,t;if(x(r))g=r[0];else{const s=j(r);if(s){if(s.passthrough)return s.passthrough;if(s.cssVar)return`var(${s.cssVar})`;g=s.name,a=s.alpha,t=s.tone}else g=r}const{color:d,gradient:l}=e,o=d[g]||l[g],c=M(o);if(c&&o.value)return R(r,`@${i}`,p);if(c){if(e.useVariable&&o.var)return a||t?R(r,null,p):`var(${o.var})`;if(i)return R(r,`@${i}`,p);{const s={};for(const $ in o){if($.charCodeAt(0)!==64)continue;const V=e.media[$.slice(1)];if(!V)continue;const b="@media "+(V==="print"?`${V}`:`screen and ${V}`);s[b]=R(r,$,p)}return s}}else return e.verbose&&console.warn("Can't find color",r),r},E=(r,i,p,e)=>{const a=`--${e.varPrefix?e.varPrefix+"-":""}${i}-${p}`;let t;const d={};for(const l in r){if(l.charCodeAt(0)!==64)continue;const o=l.slice(1),c=r[l],s=c&&(c.value||c);!s||typeof s!="string"||(d[o]=s,(o==="light"||t===void 0)&&(t=s))}if(t!==void 0){e.cssVars[a]=t,e.cssMediaVars||(e.cssMediaVars={});for(const l in d){const o=`[data-theme="${l}"]`;if(e.cssMediaVars[o]||(e.cssMediaVars[o]={}),e.cssMediaVars[o][a]=d[l],l==="light"||l==="dark"){const c=`@media (prefers-color-scheme: ${l})`;e.cssMediaVars[c]||(e.cssMediaVars[c]={}),e.cssMediaVars[c][a]=d[l]}}return r.var=a,a}},T=(r,i,p)=>{const e=S();if(C(r)&&P(r)){const f=r.slice(2);if(r=R(f),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const n=f.split(" ");let u=e.color[n[0]];if(u&&!u.value&&!u.rgb&&(C(u)||x(u)||M(u))&&(e.color[n[0]]=T(u,n[0]),u=e.color[n[0]]),u&&u.value){let h=u.rgb;const A=n[1]!==void 0?n[1]:"1",m=n[2];m&&(h=w(h,m)),r=`rgba(${h}, ${A})`}else{const h=n[2],A=n[1]!==void 0?n[1]:"1";if(h)try{const m=D(n[0]);m&&m.length>=3?r=`rgba(${w(m.slice(0,3).join(", "),h)}, ${A})`:r=n[0]}catch{r=n[0]}else r=n[0]}}}if(x(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),M(r)){const f={};for(const n in r)f[n]=T(r[n],i,n.slice(0,1)==="@"?n.slice(1):n);return e.useVariable&&E(f,"color",i,e),f}const a=`--${e.varPrefix?e.varPrefix+"-":""}color-${i}`+(p?`-${p}`:"");let t=r.value||r;if(C(t)&&!t.includes("(")&&!t.startsWith("#")){const f=j(t);if(f&&f.name&&!f.passthrough&&!f.cssVar){const n=e.color[f.name];n&&!n.value&&!n.rgb&&(C(n)||x(n)||M(n))&&(e.color[f.name]=T(n,f.name));const u=e.color[f.name];if(u&&u.rgb){let h=u.rgb;f.tone&&(h=w(h,f.tone));const A=f.alpha?parseFloat(f.alpha):1;t=`rgba(${h}, ${A})`}}}const d=D(t),[l,o,c,s=1]=d,$=parseFloat(s.toFixed(2)),V=`${l}, ${o}, ${c}`,b=`rgba(${V}, ${$})`;return e.useVariable&&(e.cssVars[a]=b),{var:a,rgb:V,alpha:$,value:b}},L=(r,i,p)=>{const e=S();if(C(r)&&P(r)&&(r=R(r.slice(2))),x(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),M(r)){const t={};for(const d in r)t[d]=L(r[d],i,d.slice(0,1)==="@"?d.slice(1):d);return e.useVariable&&E(t,"gradient",i,e),t}const a=`--${e.varPrefix?e.varPrefix+"-":""}gradient-${i}`+(p?`-${p}`:"");return e.useVariable&&(e.cssVars[a]=r.value||r),{var:a,value:r.value||r}};export{R as getColor,B as getMediaColor,E as setAdaptiveSchemeVar,T as setColor,L as setGradient};
@@ -1 +1 @@
1
- import{document as o,window as h,isString as c,isNumber as x,isNotProduction as d}from"@symbo.ls/utils";const p=t=>{if(t==="")return[0,0,0,0];if(t.toLowerCase()==="transparent")return[0,0,0,0];if(t[0]==="#")return t.length<7&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(t.length>4?t[4]+t[4]:"")),[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16),t.length>7?parseInt(t.substr(7,2),16)/255:1];if(t.indexOf("rgb")===-1&&o&&h){const e=o.body.appendChild(o.createElement("fictum")),r="rgb(1, 2, 3)";if(e.style.color=r,e.style.color!==r){o.body.removeChild(e);return}if(e.style.color=t,e.style.color===r||e.style.color==="")return o.body.removeChild(e),[0,0,0,0];t=h.getComputedStyle(e).color,o.body.removeChild(e)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(e=>+e)):[0,0,0,0]},O=(t,e,r=.5)=>(t=p(t),e=p(e),T(t,e,r)),E=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgb(${r},${s},${n})`},m=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return[r,s,n]},L=(t,e,r)=>"#"+(1<<24|t<<16|e<<8|r).toString(16).slice(1),b=([t,e,r])=>((1<<24)+(t<<16)+(e<<8)+r).toString(16).slice(1),A=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgba(${r},${s},${n},${e})`},F=(t,e,r=.5)=>{const s=[];for(let n=0;n<3;n++)s[n]=~~(t[n]+(e[n]-t[n])*r);return`rgb(${s})`},_=(t,e)=>{const[r,s,n]=e,a=Math.max(0,Math.min(100,n+parseFloat(t)));return[r,s,a]},l=(t,e,r)=>{const s=Math.max(t,e,r),n=s-Math.min(t,e,r),a=1-Math.abs(s+s-n-1),i=n&&(s==t?(e-r)/n:s==e?2+(r-t)/n:4+(t-e)/n);return[60*(i<0?i+6:i),a?n/a:0,(s+s-n)/2]},w=(t,e,r,s=e*Math.min(r,1-r),n=(a,i=(a+t/30)%12)=>r-s*Math.max(Math.min(i-3,9-i,1),-1))=>[n(0),n(8),n(4)],C=(t,e)=>{const r=parseInt(t,16);let s=(r>>16)+e;s>255?s=255:s<0&&(s=0);let n=(r>>8&255)+e;n>255?n=255:n<0&&(n=0);let a=(r&255)+e;return a>255?a=255:a<0&&(a=0),((a|n<<8|s<<16)+16777216).toString(16).slice(1)},T=(t,e,r=.5)=>{const s=[];for(let n=0;n<4;n++){const a=n===3?i=>i:Math.round;s[n]=a(t[n]+(e[n]-t[n])*r)}return`rgba(${s})`},H=(t,e)=>{const r=p(t);if(!r){d()&&console.warn(t+" color is not rgba");return}return r[3]=e,`rgba(${r})`},R=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,y=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,S=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,N=t=>{if(!c(t))return null;if(y.test(t))return{passthrough:t};if(R(t))return{cssVar:t};const e=t.match(S);if(!e)return null;const[,r,s,n]=e,a=s!==void 0?`0.${s}`:void 0,i=n&&n[0]==="="?n.slice(1):n;return{name:r,alpha:a,tone:i}},V=t=>c(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),j=t=>{const e=[];let r="",s=0;for(const n of t){if(n==="("?s+=1:n===")"&&s>0&&(s-=1),n===","&&s===0){e.push(r),r="";continue}r+=n}return(r.length||!e.length)&&e.push(r),e},z=(t,e)=>{c(t)&&t.includes("rgb")&&(t=p(t).join(", ")),c(t)&&(t=t.split(",").map(n=>parseFloat(n.trim()))),x(e)&&(e+="");const r=b(t),s=e.slice(0,1);if(s==="-"||s==="+"){const n=C(r,parseFloat(e));return m(n).join(", ")}else{const[n,a,i]=t,u=l(n,a,i),[f,g,$]=u;return w(f,g,parseFloat(e)/100*255)}};export{y as CSS_NATIVE_COLOR_REGEX,_ as changeLightness,p as colorStringToRgbaArray,C as getColorShade,z as getRgbTone,E as hexToRgb,m as hexToRgbArray,A as hexToRgba,w as hslToRgb,R as isCSSVar,V as isResolvedColor,O as mixTwoColors,F as mixTwoRgb,T as mixTwoRgba,H as opacify,N as parseColorToken,b as rgbArrayToHex,l as rgbToHSL,L as rgbToHex,j as splitTopLevelCommas};
1
+ import{document as o,window as h,isString as p,isNumber as x,isNotProduction as d}from"@symbo.ls/utils";const c=t=>{if(t==="")return[0,0,0,0];if(t.toLowerCase()==="transparent")return[0,0,0,0];if(t[0]==="#")return t.length<7&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(t.length>4?t[4]+t[4]:"")),[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16),t.length>7?parseInt(t.substr(7,2),16)/255:1];if(t.indexOf("rgb")===-1&&o&&h){const e=o.body.appendChild(o.createElement("fictum")),r="rgb(1, 2, 3)";if(e.style.color=r,e.style.color!==r){o.body.removeChild(e);return}if(e.style.color=t,e.style.color===r||e.style.color==="")return o.body.removeChild(e),[0,0,0,0];t=h.getComputedStyle(e).color,o.body.removeChild(e)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(e=>+e)):[0,0,0,0]},O=(t,e,r=.5)=>(t=c(t),e=c(e),R(t,e,r)),E=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgb(${r},${s},${n})`},b=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return[r,s,n]},L=(t,e,r)=>"#"+(1<<24|t<<16|e<<8|r).toString(16).slice(1),l=([t,e,r])=>((1<<24)+(t<<16)+(e<<8)+r).toString(16).slice(1),A=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgba(${r},${s},${n},${e})`},F=(t,e,r=.5)=>{const s=[];for(let n=0;n<3;n++)s[n]=~~(t[n]+(e[n]-t[n])*r);return`rgb(${s})`},_=(t,e)=>{const[r,s,n]=e,a=Math.max(0,Math.min(100,n+parseFloat(t)));return[r,s,a]},w=(t,e,r)=>{const s=Math.max(t,e,r),n=s-Math.min(t,e,r),a=1-Math.abs(s+s-n-1),i=n&&(s==t?(e-r)/n:s==e?2+(r-t)/n:4+(t-e)/n);return[60*(i<0?i+6:i),a?n/a:0,(s+s-n)/2]},C=(t,e,r,s=e*Math.min(r,1-r),n=(a,i=(a+t/30)%12)=>r-s*Math.max(Math.min(i-3,9-i,1),-1))=>[n(0),n(8),n(4)],T=(t,e)=>{const r=parseInt(t,16);let s=(r>>16)+e;s>255?s=255:s<0&&(s=0);let n=(r>>8&255)+e;n>255?n=255:n<0&&(n=0);let a=(r&255)+e;return a>255?a=255:a<0&&(a=0),((a|n<<8|s<<16)+16777216).toString(16).slice(1)},R=(t,e,r=.5)=>{const s=[];for(let n=0;n<4;n++){const a=n===3?i=>i:Math.round;s[n]=a(t[n]+(e[n]-t[n])*r)}return`rgba(${s})`},H=(t,e)=>{const r=c(t);if(!r){d()&&console.warn(t+" color is not rgba");return}return r[3]=e,`rgba(${r})`},y=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,M=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,S=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,N=t=>{if(!p(t))return null;if(M.test(t))return{passthrough:t};if(y(t))return{cssVar:t};const e=t.match(S);if(!e)return null;const[,r,s,n]=e,a=s!==void 0?`0.${s}`:void 0,i=n&&n[0]==="="?n.slice(1):n;return{name:r,alpha:a,tone:i}},j=t=>p(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),V=t=>{const e=[];let r="",s=0;for(const n of t){if(n==="("?s+=1:n===")"&&s>0&&(s-=1),n===","&&s===0){e.push(r),r="";continue}r+=n}return(r.length||!e.length)&&e.push(r),e},z=(t,e)=>{p(t)&&t.includes("rgb")&&(t=c(t).join(", ")),p(t)&&(t=t.split(",").map(n=>parseFloat(n.trim()))),x(e)&&(e+="");const r=l(t),s=e.slice(0,1);if(s==="-"||s==="+"){const n=T(r,parseFloat(e));return b(n).join(", ")}else{const[n,a,i]=t,[u,f]=w(n/255,a/255,i/255),g=Math.max(0,Math.min(100,parseFloat(e)))/100;return C(u,f,g).map(m=>Math.round(Math.max(0,Math.min(1,m))*255)).join(", ")}};export{M as CSS_NATIVE_COLOR_REGEX,_ as changeLightness,c as colorStringToRgbaArray,T as getColorShade,z as getRgbTone,E as hexToRgb,b as hexToRgbArray,A as hexToRgba,C as hslToRgb,y as isCSSVar,j as isResolvedColor,O as mixTwoColors,F as mixTwoRgb,R as mixTwoRgba,H as opacify,N as parseColorToken,l as rgbArrayToHex,w as rgbToHSL,L as rgbToHex,V as splitTopLevelCommas};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@symbo.ls/scratch",
3
3
  "description": "Φ / CSS framework and methodology.",
4
4
  "author": "symbo.ls",
5
- "version": "3.14.678",
5
+ "version": "3.14.697",
6
6
  "files": [
7
7
  "dist",
8
8
  "*.js",
@@ -33,7 +33,7 @@
33
33
  "prepublishOnly": "npm run build"
34
34
  },
35
35
  "dependencies": {
36
- "@symbo.ls/utils": "^3.14.651",
36
+ "@symbo.ls/utils": "^3.14.685",
37
37
  "color-contrast-checker": "^1.5.0"
38
38
  },
39
39
  "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",