@symbo.ls/scratch 3.14.105 → 3.14.315
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 +17 -1
- package/dist/cjs/src/defaultConfig/index.js +1 -1
- package/dist/cjs/src/set.js +1 -1
- package/dist/cjs/src/system/color.js +1 -1
- package/dist/cjs/src/utils/color.js +1 -1
- package/dist/cjs/src/utils/sequence.js +1 -1
- package/dist/esm/src/defaultConfig/index.js +1 -1
- package/dist/esm/src/set.js +1 -1
- package/dist/esm/src/system/color.js +1 -1
- package/dist/esm/src/utils/color.js +1 -1
- package/dist/esm/src/utils/sequence.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
# @symbo.ls/scratch
|
|
2
2
|
|
|
3
|
+
## 3.14.315
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Auto-generated cross-repo patch release.
|
|
8
|
+
|
|
9
|
+
## 3.14.135
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Auto-generated cross-repo patch release.
|
|
14
|
+
|
|
3
15
|
## 3.14.105
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
6
18
|
|
|
7
|
-
-
|
|
19
|
+
- Manual patch bump triggered via workflow_dispatch (scope: all).
|
|
20
|
+
No source change behind this bump — released to refresh dist or
|
|
21
|
+
coordinate a cross-package version line.
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @symbo.ls/utils@3.14.105
|
|
8
24
|
|
|
9
25
|
## 3.14.104
|
|
10
26
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var m=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var a=(e,t)=>{for(var p in t)m(e,p,{get:t[p],enumerable:!0})},f=(e,t,p,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let x of n(t))!i.call(e,x)&&x!==p&&m(e,x,{get:()=>t[x],enumerable:!(s=c(t,x))||s.enumerable});return e},r=(e,t,p)=>(f(e,t,"default"),p&&f(p,t,"default"));var u=e=>f(m({},"__esModule",{value:!0}),e);var o={};a(o,{reset:()=>v,sizes:()=>b,vars:()=>z});module.exports=u(o);r(o,require("./sequence.js"),module.exports);r(o,require("./unit.js"),module.exports);r(o,require("./typography.js"),module.exports);r(o,require("./font.js"),module.exports);r(o,require("./font-family.js"),module.exports);r(o,require("./media.js"),module.exports);r(o,require("./spacing.js"),module.exports);r(o,require("./color.js"),module.exports);r(o,require("./theme.js"),module.exports);r(o,require("./shadow.js"),module.exports);r(o,require("./icons.js"),module.exports);r(o,require("./timing.js"),module.exports);r(o,require("./document.js"),module.exports);r(o,require("./responsive.js"),module.exports);r(o,require("./animation.js"),module.exports);r(o,require("./svg.js"),module.exports);r(o,require("./templates.js"),module.exports);r(o,require("./grid.js"),module.exports);r(o,require("./class.js"),module.exports);const v={},z={},b={};
|
package/dist/cjs/src/set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var x=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var M=(t,s)=>{for(var e in s)x(t,e,{get:s[e],enumerable:!0})},k=(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 j=t=>k(x({},"__esModule",{value:!0}),t);var
|
|
1
|
+
"use strict";var x=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var M=(t,s)=>{for(var e in s)x(t,e,{get:s[e],enumerable:!0})},k=(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 j=t=>k(x({},"__esModule",{value:!0}),t);var U={};M(U,{VALUE_TRANSFORMERS:()=>E,changeGlobalTheme:()=>Y,set:()=>z,setEach:()=>P,setValue:()=>D});module.exports=j(U);var p=require("./factory.js"),o=require("./system/index.js"),S=require("@symbo.ls/utils");const W=(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:W,sizes:l},D=(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")},P=(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 D(c,s[i],i)}catch(f){e.verbose&&console.warn("Error setting",c,"value",s[i],i,f)}}),e[c]||e[t]},Y=(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 v in e.cssVars)m[g].style.setProperty(v,e.cssVars[v]);return e}}catch{}}return e},$={},z=(t,s=$)=>{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:v,useDefaultConfig:I,semanticIcons:R,files:A,assets:F,...b}=t;s.newConfig&&(e=(0,p.setActiveConfig)(s.newConfig)),A!==void 0&&(e.files=A),F!==void 0&&(e.assets=F),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),v!==void 0&&(e.useDocumentTheme=v),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),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=O=>{y.setAttribute("data-theme",O.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),_=new Set(T);if(T.forEach(a=>{const h=a.toLowerCase();h!==a&&_.has(h)&&(0,S.deepMerge)(b[h],b[a])}),T.map(a=>{const h=a.toLowerCase();if(!(h!==a&&_.has(h)))return P(a,b[a])}),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(a){e.verbose&&console.warn("Error applying typography sequence",a)}if(b.spacing)try{(0,o.applySpacingSequence)()}catch(a){e.verbose&&console.warn("Error applying spacing sequence",a)}if(b.timing)try{(0,o.applyTimingSequence)()}catch(a){e.verbose&&console.warn("Error applying timing sequence",a)}(0,o.applyDocument)();const L=(0,o.applyReset)();return L&&(e.reset=L),e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var I=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var T=(r,
|
|
1
|
+
"use strict";var I=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var T=(r,e)=>{for(var d in e)I(r,d,{get:e[d],enumerable:!0})},D=(r,e,d,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of w(e))!P.call(r,l)&&l!==d&&I(r,l,{get:()=>e[l],enumerable:!(s=j(e,l))||s.enumerable});return r};var E=r=>D(I({},"__esModule",{value:!0}),r);var q={};T(q,{getColor:()=>M,getMediaColor:()=>L,setColor:()=>G,setGradient:()=>N});module.exports=E(q);var c=require("@symbo.ls/utils"),F=require("../factory.js"),b=require("../utils/index.js");const M=(r,e,d)=>{const s=d||(0,F.getActiveConfig)();if(!(0,c.isString)(r)){s.verbose&&console.warn(r,"- type for color is not valid");return}if((0,b.isCSSVar)(r))return`var(${r})`;e&&r[e]&&(r=r[e]);let l,g,t;if((0,c.isArray)(r))[l,g,t]=r;else{const n=(0,b.parseColorToken)(r);if(!n){const{color:m,gradient:O}=s;let V=O[r]||m[r];return V?(e&&V[e]&&(V=V[e]),s.useVariable?`var(${V.var})`:V.value):r}if(n.passthrough)return n.passthrough;if(n.cssVar)return`var(${n.cssVar})`;l=n.name,g=n.alpha,t=n.tone}const{color:h,gradient:A}=s;let f=h[l]||A[l];if(!f)return s.verbose&&console.warn("Can't find color ",l),r;e&&(f[e]?f=f[e]:s.verbose&&console.warn(r," - does not have ",e));let $=f.rgb;if(!$){const n=s.useVariable?`var(${f.var})`:f.value;if(g&&n){const m=Math.round(parseFloat(g)*100);return`color-mix(in srgb, ${n} ${m}%, transparent)`}return n}return t&&!f[t]&&($=(0,b.getRgbTone)($,t),f[t]={rgb:$,var:`${f.var}-${t}`}),f[t]&&($=f[t].rgb),g?`rgba(${$}, ${g})`:t?`rgba(${$}, 1)`:s.useVariable?`var(${f.var})`:`rgb(${$})`},L=(r,e,d)=>{const s=d||(0,F.getActiveConfig)();if(e||(e=s.globalTheme==="auto"?null:s.globalTheme),!(0,c.isString)(r)){s.verbose&&console.warn(r,"- type for color is not valid");return}if((0,b.isCSSVar)(r))return`var(${r})`;let l,g,t;if((0,c.isArray)(r))l=r[0];else{const n=(0,b.parseColorToken)(r);if(n){if(n.passthrough)return n.passthrough;if(n.cssVar)return`var(${n.cssVar})`;l=n.name,g=n.alpha,t=n.tone}else l=r}const{color:h,gradient:A}=s,f=h[l]||A[l],$=(0,c.isObject)(f);if($&&f.value)return M(r,`@${e}`,d);if($){if(s.useVariable&&f.var)return g||t?M(r,null,d):`var(${f.var})`;if(e)return M(r,`@${e}`,d);{const n={};for(const m in f){if(m.charCodeAt(0)!==64)continue;const O=s.media[m.slice(1)];if(!O)continue;const V="@media "+(O==="print"?`${O}`:`screen and ${O}`);n[V]=M(r,m,d)}return n}}else return s.verbose&&console.warn("Can't find color",r),r},G=(r,e,d)=>{const s=(0,F.getActiveConfig)();if((0,c.isString)(r)&&(0,b.isCSSVar)(r)){const a=r.slice(2);if(r=M(a),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const o=a.split(" ");let i=s.color[o[0]];if(i&&!i.value&&!i.rgb&&((0,c.isString)(i)||(0,c.isArray)(i)||(0,c.isObject)(i))&&(s.color[o[0]]=G(i,o[0]),i=s.color[o[0]]),i&&i.value){let u=i.rgb;const C=o[1]!==void 0?o[1]:"1",p=o[2];p&&(u=(0,b.getRgbTone)(u,p)),r=`rgba(${u}, ${C})`}else{const u=o[2],C=o[1]!==void 0?o[1]:"1";if(u)try{const p=(0,b.colorStringToRgbaArray)(o[0]);p&&p.length>=3?r=`rgba(${(0,b.getRgbTone)(p.slice(0,3).join(", "),u)}, ${C})`:r=o[0]}catch{r=o[0]}else r=o[0]}}}if((0,c.isArray)(r)&&(r={"@light":r[0],"@dark":r[1]}),(0,c.isObject)(r)){const a={};for(const o in r)a[o]=G(r[o],e,o.slice(0,1)==="@"?o.slice(1):o);if(s.useVariable){const i=`--${s.varPrefix?s.varPrefix+"-":""}color-${e}`;let u;const C={};for(const p in a){if(p.charCodeAt(0)!==64)continue;const R=p.slice(1),x=a[p],S=x&&(x.value||x);!S||typeof S!="string"||(C[R]=S,(R==="light"||u===void 0)&&(u=S))}if(u!==void 0){s.cssVars[i]=u,s.cssMediaVars||(s.cssMediaVars={});for(const p in C){const R=`[data-theme="${p}"]`;if(s.cssMediaVars[R]||(s.cssMediaVars[R]={}),s.cssMediaVars[R][i]=C[p],p==="light"||p==="dark"){const x=`@media (prefers-color-scheme: ${p})`;s.cssMediaVars[x]||(s.cssMediaVars[x]={}),s.cssMediaVars[x][i]=C[p]}}a.var=i}}return a}const g=`--${s.varPrefix?s.varPrefix+"-":""}color-${e}`+(d?`-${d}`:"");let t=r.value||r;if((0,c.isString)(t)&&t.includes(".")&&!t.includes("(")){const[a,o]=t.split("."),i=s.color[a];i&&i.rgb&&(t=`rgba(${i.rgb}, ${parseFloat("0."+o)||1})`)}if((0,c.isString)(t)&&!t.includes("(")&&!t.startsWith("#")){const a=(0,b.parseColorToken)(t);if(a&&a.name&&!a.passthrough&&!a.cssVar){const o=s.color[a.name];o&&!o.value&&!o.rgb&&((0,c.isString)(o)||(0,c.isArray)(o)||(0,c.isObject)(o))&&(s.color[a.name]=G(o,a.name));const i=s.color[a.name];if(i&&i.rgb){let u=i.rgb;a.tone&&(u=(0,b.getRgbTone)(u,a.tone));const C=a.alpha?parseFloat(a.alpha):1;t=`rgba(${u}, ${C})`}}}const h=(0,b.colorStringToRgbaArray)(t),[A,f,$,n=1]=h,m=parseFloat(n.toFixed(2)),O=`${A}, ${f}, ${$}`,V=`rgba(${O}, ${m})`;return s.useVariable&&(s.cssVars[g]=V),{var:g,rgb:O,alpha:m,value:V}},N=(r,e,d)=>{const s=(0,F.getActiveConfig)();if((0,c.isString)(r)&&(0,b.isCSSVar)(r)&&(r=M(r.slice(2))),(0,c.isArray)(r))return{"@light":N(r[0],e,"light"),"@dark":N(r[0],e,"dark")};if((0,c.isObject)(r)){const t={};for(const h in r)t[h]=N(r[h],e,h.slice(0,1)==="@"?h.slice(1):h);return t}const g=`--${s.varPrefix?s.varPrefix+"-":""}gradient-${e}`+(d?`-${d}`:"");return s.useVariable&&(s.cssVars[g]=r.value||r),{var:g,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
|
|
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 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var A=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var H=(t,n)=>{for(var e in n)A(t,e,{get:n[e],enumerable:!0})},Z=(t,n,e,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of E(n))!G.call(t,r)&&r!==e&&A(t,r,{get:()=>n[r],enumerable:!(s=z(n,r))||s.enumerable});return t};var B=t=>Z(A({},"__esModule",{value:!0}),t);var q={};H(q,{findHeadingLetter:()=>W,findHeadings:()=>P,generateSequence:()=>X,generateSequencePosition:()=>Y,generateSubSequence:()=>U,getFnPrefixAndValue:()=>F,getSequenceValue:()=>K,getSequenceValueBySymbols:()=>D,getSequenceValuePropertyPair:()=>k,getSubratio:()=>J,getSubratioDifference:()=>O,numToLetterMap:()=>b,setScalingVar:()=>C,setSubScalingVar:()=>j});module.exports=B(q);var M=require("@symbo.ls/utils"),T=require("@symbo.ls/utils"),L=require("../factory.js"),y=require("./unit.js"),_=require("./color.js");const b={"-6":"U","-5":"V","-4":"W","-3":"X","-2":"Y","-1":"Z",0:"A",1:"B",2:"C",3:"D",4:"E",5:"F",6:"G",7:"H",8:"I",9:"J",10:"K",11:"L",12:"M",13:"N",14:"O",15:"P",16:"Q",17:"R",18:"S",19:"T"},I=(t,n)=>{const{key:e,variable:s,value:r,scaling:i,index:o,scalingVariable:p}=t;n.sequence[e]={key:e,decimal:~~(r*100)/100,val:~~r,scaling:i,index:o,scalingVariable:p,variable:s},n.scales[e]=i;const l=N.has(n.unit)?"rem":n.unit;n.vars[s]=i+l},F=t=>{if(!t.includes("("))return t;const n=t.split("(")[0],e=t.slice(t.indexOf("(")+1,t.lastIndexOf(")"));return[n,e]},N=new Set(["vw","vh","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh"]),C=(t,n)=>{const{base:e,type:s,unit:r}=n,i=N.has(r)?"rem":r,o=((0,y.isScalingUnit)(i)?1:e)+i;if(t===0)return o;const l="--"+(n.varPrefix?n.varPrefix+"-":"")+(s&&s.replace(".","-")),u=`${l}-ratio`;if(t>0){const f=b[t-1];return`calc(var(${l}-${f}) * var(${u}))`}if(t<0){const f=b[t+1],$=Math.abs(t),h=Math.pow(R,2*$),x=b[$];return x?`max(calc(var(${l}-${f}) / var(${u})), calc(var(${l}-${x}) / ${h.toFixed(4)}))`:`calc(var(${l}-${f}) / var(${u}))`}},j=(t,n,e,s)=>{const{type:r}=s,o=t===2&&n.length===2?t+1:t,u=`${"--"+(s.varPrefix?s.varPrefix+"-":"")+(r&&r.replace(".","-"))}-sub-ratio-`;return`calc(var(${e}) * var(${u+o}))`},O=(t,n)=>{const s=(t*n-t)/1.618,r=t*n-s,i=t+s,o=(r+i)/2;return[r,o,i]},J=(t,n)=>O(t,n).map(e=>e/t),U=(t,n)=>{const{key:e,base:s,value:r,ratio:i,variable:o,index:p}=t,u=~~(r*i)-~~r;let f;const[$,h,x]=O(r,i);u>16?f=[$,h,x]:f=[$,x],f.forEach((d,c)=>{const g=~~(d/s*1e3)/1e3,m=o+(c+1),S=p+(c+1)/10,V=j(c+1,f,o,n),a={key:e+(c+1),variable:m,value:d,scaling:g,scalingVariable:V,index:S};I(a,n)})},R=1.618,Q=(t,n,e)=>{if(t>=0)return n*Math.pow(e,t);const s=Math.abs(t),r=n*Math.pow(e,t),i=n*Math.pow(e,s)/Math.pow(R,2*s);return Math.max(r,i)},X=t=>{const{type:n,base:e,ratio:s,range:r,subSequence:i}=t,o=Math.abs(r[0])+Math.abs(r[1]),l="--"+(t.varPrefix?t.varPrefix+"-":"")+(n&&n.replace(".","-"))+"-";for(let u=0;u<=o;u++){const f=r[1]-u,$=b[f],h=Q(f,e,s),x=~~(h/e*100)/100,d=l+$,c=C(f,t),g={key:$,variable:d,value:h,base:e,scaling:x,scalingVariable:c,ratio:s,index:f};I(g,t),i&&U(g,t)}return t},Y=(t,n=0)=>{const{type:e,base:s,ratio:r,subSequence:i}=t,o=(0,M.isString)(n)?n:b[n],p=(0,M.isString)(n)?Object.entries(b).find(([,g])=>g===n)?.[0]:n;if(!o)return console.warn(`Position ${n} is out of range in numToLetterMap`),null;const l={sequence:{},scales:{},vars:{},...t},u=s*Math.pow(r,p),f=~~(u/s*100)/100,x="--"+(t.varPrefix?t.varPrefix+"-":"")+(e&&e.replace(".","-"))+"-"+o,d=C(p,t),c={key:o,variable:x,value:u,base:s,scaling:f,scalingVariable:d,ratio:r,index:p};return I(c,l),i&&U(c,l),l},K=(t="A",n)=>{const e=(0,L.getActiveConfig)(),{unit:s}=e;if((0,M.isString)(t)&&(0,_.isCSSVar)(t))return`var(${t})`;const{sequence:r,unit:i=s.default,useVariable:o}=n,p=/^-?[a-zA-Z]/i,l=p.test(t);if(y.CSS_UNITS.some(a=>t.includes(a))||!l||["none","auto","max-content","min-content","fit-content","inherit","initial","unset","revert","revert-layer"].includes(t))return t;const h=`--${n.varPrefix?n.varPrefix+"-":""}${(0,T.toDashCase)(n.type.replace(".","-"))}-`,x=t.toUpperCase(),d=x.slice(0,1)==="-"?"-":"";let c=d?x.slice(1):x,g="";c.includes("_")&&(g="_"+c.split("_")[1].toLowerCase(),c=c.split("_")[0]);const m=a=>p.test(a)?`var(${h}${a}${g})`:a;if(c.includes("+")){const[a,w]=c.split("+"),v=`${m(a)} + ${m(w)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("*")){const[a,w]=c.split("*"),v=`${m(a)} * ${m(w)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("-")){const[a,w]=c.split("-"),v=`${m(a)} - ${m(w)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}const S=e.sizes;if(S){const a=S[t]||S[t.toLowerCase()];if(a!==void 0)return d?`calc(${a} * -1)`:a}if(!r[c]&&c.length===2&&(e.verbose&&console.warn(c,"- value is not found because `subSequence` is set to false"),c=c.slice(0,1)),o||e.useVariable){const a=`var(${h}${c}${g})`;return d?`calc(${a} * -1)`:a}const V=r?r[c]:null;return V?i==="ms"||i==="s"?d+V.val+i:d+V.scaling+i:console.warn("can't find",r,c)},D=(t,n)=>{if(!["+","-","*","/",","].filter(i=>t.includes(i+" ")).length)return t;const s=/(\s*[+\-*/,]\s*)/;return t.split(s).map(i=>{const o=i.trim();return!o||["+","-","*","/",","].includes(o)?i:K(o,n)}).join("")},k=(t,n,e,s)=>{if(typeof t!="string")return(0,L.getActiveConfig)().verbose&&console.warn(n,t,"is not a string"),{[n]:t};if(t==="-"||t==="")return{};if(!s&&t.includes("(")){const i=F(t);s=i[0],t=i[1]}return["+","-","*","/",","].filter(i=>t.includes(i+" ")).length?t=D(t,e):t=K(t,e),{[n]:s?`${s}(${t})`:t}},W=(t,n)=>b[t-n],P=t=>{const{h1Matches:n,sequence:e}=t;return new Array(6).fill(null).map((s,r)=>{const i=W(n,r);return e[i]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./sequence.js";export*from"./unit.js";export*from"./typography.js";export*from"./font.js";export*from"./font-family.js";export*from"./media.js";export*from"./spacing.js";export*from"./color.js";export*from"./theme.js";export*from"./shadow.js";export*from"./icons.js";export*from"./timing.js";export*from"./document.js";export*from"./responsive.js";export*from"./animation.js";export*from"./svg.js";export*from"./templates.js";export*from"./grid.js";export*from"./class.js";const r={},
|
|
1
|
+
export*from"./sequence.js";export*from"./unit.js";export*from"./typography.js";export*from"./font.js";export*from"./font-family.js";export*from"./media.js";export*from"./spacing.js";export*from"./color.js";export*from"./theme.js";export*from"./shadow.js";export*from"./icons.js";export*from"./timing.js";export*from"./document.js";export*from"./responsive.js";export*from"./animation.js";export*from"./svg.js";export*from"./templates.js";export*from"./grid.js";export*from"./class.js";const o={},r={},t={};export{o as reset,t as sizes,r as vars};
|
package/dist/esm/src/set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getActiveConfig as S,setActiveConfig as D,toCamel as P}from"./factory.js";import{setColor as N,setGradient as q,setFont as G,setFontFamily as F,setTheme as M,setSvgIcon as k,setSVG as j,applyTypographySequence as W,applySpacingSequence as Y,applyReset as $,applyTimingSequence as
|
|
1
|
+
import{getActiveConfig as S,setActiveConfig as D,toCamel as P}from"./factory.js";import{setColor as N,setGradient as q,setFont as G,setFontFamily as F,setTheme as M,setSvgIcon as k,setSVG as j,applyTypographySequence as W,applySpacingSequence as Y,applyReset as $,applyTimingSequence as z,applyDocument as U,setShadow as B}from"./system/index.js";import{deepMerge as H,isObject as _,isArray as L}from"@symbo.ls/utils";const J=(t,o)=>{const e=S(),{cssVars:c}=e,r=o.startsWith("--")?o:`--${o}`;return c[r]=t,t},f=t=>t,O={color:N,gradient:q,font:G,fontFamily:F,fontfamily:F,theme:M,icons:k,semanticIcons:f,semanticicons:f,svg:j,svgData:f,typography:f,shadow:B,spacing:f,media:f,grid:f,class:f,timing:f,reset:f,unit:f,animation:f,vars:J,sizes:f},K=(t,o,e)=>{const c=S(),r=P(t),n=r.toLowerCase(),a=c[r]||c[n]||c[t],s=O[r]||O[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")},Q=(t,o)=>{const e=S(),c=t.toLowerCase();return Object.keys(o).sort((n,a)=>{const s=_(o[n])||L(o[n])?1:0,l=_(o[a])||L(o[a])?1:0;return s-l}).forEach(n=>{try{return K(c,o[n],n)}catch(a){e.verbose&&console.warn("Error setting",c,"value",o[n],n,a)}}),e[c]||e[t]},ne=(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},X={},re=(t,o=X)=>{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,files:x,assets:E,...p}=t;o.newConfig&&(e=D(o.newConfig)),x!==void 0&&(e.files=x),E!==void 0&&(e.assets=E),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),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=A=>{g.setAttribute("data-theme",A.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),I=new Set(C);if(C.forEach(i=>{const m=i.toLowerCase();m!==i&&I.has(m)&&H(p[m],p[i])}),C.map(i=>{const m=i.toLowerCase();if(!(m!==i&&I.has(m)))return Q(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{W()}catch(i){e.verbose&&console.warn("Error applying typography sequence",i)}if(p.spacing)try{Y()}catch(i){e.verbose&&console.warn("Error applying spacing sequence",i)}if(p.timing)try{z()}catch(i){e.verbose&&console.warn("Error applying timing sequence",i)}U();const R=$();return R&&(e.reset=R),e};export{O as VALUE_TRANSFORMERS,ne as changeGlobalTheme,re as set,Q as setEach,K as setValue};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as
|
|
1
|
+
import{isObject as F,isArray as x,isString as C}from"@symbo.ls/utils";import{getActiveConfig as G}from"../factory.js";import{colorStringToRgbaArray as T,getRgbTone as N,isCSSVar as I,parseColorToken as j}from"../utils/index.js";const M=(r,n,p)=>{const s=p||G();if(!C(r)){s.verbose&&console.warn(r,"- type for color is not valid");return}if(I(r))return`var(${r})`;n&&r[n]&&(r=r[n]);let b,l,o;if(x(r))[b,l,o]=r;else{const t=j(r);if(!t){const{color:h,gradient:m}=s;let $=m[r]||h[r];return $?(n&&$[n]&&($=$[n]),s.useVariable?`var(${$.var})`:$.value):r}if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;b=t.name,l=t.alpha,o=t.tone}const{color:u,gradient:A}=s;let c=u[b]||A[b];if(!c)return s.verbose&&console.warn("Can't find color ",b),r;n&&(c[n]?c=c[n]:s.verbose&&console.warn(r," - does not have ",n));let g=c.rgb;if(!g){const t=s.useVariable?`var(${c.var})`:c.value;if(l&&t){const h=Math.round(parseFloat(l)*100);return`color-mix(in srgb, ${t} ${h}%, transparent)`}return t}return o&&!c[o]&&(g=N(g,o),c[o]={rgb:g,var:`${c.var}-${o}`}),c[o]&&(g=c[o].rgb),l?`rgba(${g}, ${l})`:o?`rgba(${g}, 1)`:s.useVariable?`var(${c.var})`:`rgb(${g})`},q=(r,n,p)=>{const s=p||G();if(n||(n=s.globalTheme==="auto"?null:s.globalTheme),!C(r)){s.verbose&&console.warn(r,"- type for color is not valid");return}if(I(r))return`var(${r})`;let b,l,o;if(x(r))b=r[0];else{const t=j(r);if(t){if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;b=t.name,l=t.alpha,o=t.tone}else b=r}const{color:u,gradient:A}=s,c=u[b]||A[b],g=F(c);if(g&&c.value)return M(r,`@${n}`,p);if(g){if(s.useVariable&&c.var)return l||o?M(r,null,p):`var(${c.var})`;if(n)return M(r,`@${n}`,p);{const t={};for(const h in c){if(h.charCodeAt(0)!==64)continue;const m=s.media[h.slice(1)];if(!m)continue;const $="@media "+(m==="print"?`${m}`:`screen and ${m}`);t[$]=M(r,h,p)}return t}}else return s.verbose&&console.warn("Can't find color",r),r},w=(r,n,p)=>{const s=G();if(C(r)&&I(r)){const a=r.slice(2);if(r=M(a),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const e=a.split(" ");let i=s.color[e[0]];if(i&&!i.value&&!i.rgb&&(C(i)||x(i)||F(i))&&(s.color[e[0]]=w(i,e[0]),i=s.color[e[0]]),i&&i.value){let d=i.rgb;const V=e[1]!==void 0?e[1]:"1",f=e[2];f&&(d=N(d,f)),r=`rgba(${d}, ${V})`}else{const d=e[2],V=e[1]!==void 0?e[1]:"1";if(d)try{const f=T(e[0]);f&&f.length>=3?r=`rgba(${N(f.slice(0,3).join(", "),d)}, ${V})`:r=e[0]}catch{r=e[0]}else r=e[0]}}}if(x(r)&&(r={"@light":r[0],"@dark":r[1]}),F(r)){const a={};for(const e in r)a[e]=w(r[e],n,e.slice(0,1)==="@"?e.slice(1):e);if(s.useVariable){const i=`--${s.varPrefix?s.varPrefix+"-":""}color-${n}`;let d;const V={};for(const f in a){if(f.charCodeAt(0)!==64)continue;const O=f.slice(1),R=a[f],S=R&&(R.value||R);!S||typeof S!="string"||(V[O]=S,(O==="light"||d===void 0)&&(d=S))}if(d!==void 0){s.cssVars[i]=d,s.cssMediaVars||(s.cssMediaVars={});for(const f in V){const O=`[data-theme="${f}"]`;if(s.cssMediaVars[O]||(s.cssMediaVars[O]={}),s.cssMediaVars[O][i]=V[f],f==="light"||f==="dark"){const R=`@media (prefers-color-scheme: ${f})`;s.cssMediaVars[R]||(s.cssMediaVars[R]={}),s.cssMediaVars[R][i]=V[f]}}a.var=i}}return a}const l=`--${s.varPrefix?s.varPrefix+"-":""}color-${n}`+(p?`-${p}`:"");let o=r.value||r;if(C(o)&&o.includes(".")&&!o.includes("(")){const[a,e]=o.split("."),i=s.color[a];i&&i.rgb&&(o=`rgba(${i.rgb}, ${parseFloat("0."+e)||1})`)}if(C(o)&&!o.includes("(")&&!o.startsWith("#")){const a=j(o);if(a&&a.name&&!a.passthrough&&!a.cssVar){const e=s.color[a.name];e&&!e.value&&!e.rgb&&(C(e)||x(e)||F(e))&&(s.color[a.name]=w(e,a.name));const i=s.color[a.name];if(i&&i.rgb){let d=i.rgb;a.tone&&(d=N(d,a.tone));const V=a.alpha?parseFloat(a.alpha):1;o=`rgba(${d}, ${V})`}}}const u=T(o),[A,c,g,t=1]=u,h=parseFloat(t.toFixed(2)),m=`${A}, ${c}, ${g}`,$=`rgba(${m}, ${h})`;return s.useVariable&&(s.cssVars[l]=$),{var:l,rgb:m,alpha:h,value:$}},P=(r,n,p)=>{const s=G();if(C(r)&&I(r)&&(r=M(r.slice(2))),x(r))return{"@light":P(r[0],n,"light"),"@dark":P(r[0],n,"dark")};if(F(r)){const o={};for(const u in r)o[u]=P(r[u],n,u.slice(0,1)==="@"?u.slice(1):u);return o}const l=`--${s.varPrefix?s.varPrefix+"-":""}gradient-${n}`+(p?`-${p}`:"");return s.useVariable&&(s.cssVars[l]=r.value||r),{var:l,value:r.value||r}};export{M as getColor,q as getMediaColor,w as setColor,P as setGradient};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{document as
|
|
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 +1 @@
|
|
|
1
|
-
import{isString as
|
|
1
|
+
import{isString as M}from"@symbo.ls/utils";import{toDashCase as N}from"@symbo.ls/utils";import{getActiveConfig as A}from"../factory.js";import{CSS_UNITS as R,isScalingUnit as T}from"./unit.js";import{isCSSVar as _}from"./color.js";const b={"-6":"U","-5":"V","-4":"W","-3":"X","-2":"Y","-1":"Z",0:"A",1:"B",2:"C",3:"D",4:"E",5:"F",6:"G",7:"H",8:"I",9:"J",10:"K",11:"L",12:"M",13:"N",14:"O",15:"P",16:"Q",17:"R",18:"S",19:"T"},y=(t,n)=>{const{key:r,variable:s,value:i,scaling:e,index:o,scalingVariable:p}=t;n.sequence[r]={key:r,decimal:~~(i*100)/100,val:~~i,scaling:e,index:o,scalingVariable:p,variable:s},n.scales[r]=e;const l=I.has(n.unit)?"rem":n.unit;n.vars[s]=e+l},F=t=>{if(!t.includes("("))return t;const n=t.split("(")[0],r=t.slice(t.indexOf("(")+1,t.lastIndexOf(")"));return[n,r]},I=new Set(["vw","vh","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh"]),L=(t,n)=>{const{base:r,type:s,unit:i}=n,e=I.has(i)?"rem":i,o=(T(e)?1:r)+e;if(t===0)return o;const l="--"+(n.varPrefix?n.varPrefix+"-":"")+(s&&s.replace(".","-")),u=`${l}-ratio`;if(t>0){const f=b[t-1];return`calc(var(${l}-${f}) * var(${u}))`}if(t<0){const f=b[t+1],$=Math.abs(t),h=Math.pow(U,2*$),x=b[$];return x?`max(calc(var(${l}-${f}) / var(${u})), calc(var(${l}-${x}) / ${h.toFixed(4)}))`:`calc(var(${l}-${f}) / var(${u}))`}},j=(t,n,r,s)=>{const{type:i}=s,o=t===2&&n.length===2?t+1:t,u=`${"--"+(s.varPrefix?s.varPrefix+"-":"")+(i&&i.replace(".","-"))}-sub-ratio-`;return`calc(var(${r}) * var(${u+o}))`},C=(t,n)=>{const s=(t*n-t)/1.618,i=t*n-s,e=t+s,o=(i+e)/2;return[i,o,e]},J=(t,n)=>C(t,n).map(r=>r/t),O=(t,n)=>{const{key:r,base:s,value:i,ratio:e,variable:o,index:p}=t,u=~~(i*e)-~~i;let f;const[$,h,x]=C(i,e);u>16?f=[$,h,x]:f=[$,x],f.forEach((d,c)=>{const g=~~(d/s*1e3)/1e3,m=o+(c+1),S=p+(c+1)/10,V=j(c+1,f,o,n),a={key:r+(c+1),variable:m,value:d,scaling:g,scalingVariable:V,index:S};y(a,n)})},U=1.618,D=(t,n,r)=>{if(t>=0)return n*Math.pow(r,t);const s=Math.abs(t),i=n*Math.pow(r,t),e=n*Math.pow(r,s)/Math.pow(U,2*s);return Math.max(i,e)},Q=t=>{const{type:n,base:r,ratio:s,range:i,subSequence:e}=t,o=Math.abs(i[0])+Math.abs(i[1]),l="--"+(t.varPrefix?t.varPrefix+"-":"")+(n&&n.replace(".","-"))+"-";for(let u=0;u<=o;u++){const f=i[1]-u,$=b[f],h=D(f,r,s),x=~~(h/r*100)/100,d=l+$,c=L(f,t),g={key:$,variable:d,value:h,base:r,scaling:x,scalingVariable:c,ratio:s,index:f};y(g,t),e&&O(g,t)}return t},X=(t,n=0)=>{const{type:r,base:s,ratio:i,subSequence:e}=t,o=M(n)?n:b[n],p=M(n)?Object.entries(b).find(([,g])=>g===n)?.[0]:n;if(!o)return console.warn(`Position ${n} is out of range in numToLetterMap`),null;const l={sequence:{},scales:{},vars:{},...t},u=s*Math.pow(i,p),f=~~(u/s*100)/100,x="--"+(t.varPrefix?t.varPrefix+"-":"")+(r&&r.replace(".","-"))+"-"+o,d=L(p,t),c={key:o,variable:x,value:u,base:s,scaling:f,scalingVariable:d,ratio:i,index:p};return y(c,l),e&&O(c,l),l},K=(t="A",n)=>{const r=A(),{unit:s}=r;if(M(t)&&_(t))return`var(${t})`;const{sequence:i,unit:e=s.default,useVariable:o}=n,p=/^-?[a-zA-Z]/i,l=p.test(t);if(R.some(a=>t.includes(a))||!l||["none","auto","max-content","min-content","fit-content","inherit","initial","unset","revert","revert-layer"].includes(t))return t;const h=`--${n.varPrefix?n.varPrefix+"-":""}${N(n.type.replace(".","-"))}-`,x=t.toUpperCase(),d=x.slice(0,1)==="-"?"-":"";let c=d?x.slice(1):x,g="";c.includes("_")&&(g="_"+c.split("_")[1].toLowerCase(),c=c.split("_")[0]);const m=a=>p.test(a)?`var(${h}${a}${g})`:a;if(c.includes("+")){const[a,w]=c.split("+"),v=`${m(a)} + ${m(w)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("*")){const[a,w]=c.split("*"),v=`${m(a)} * ${m(w)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("-")){const[a,w]=c.split("-"),v=`${m(a)} - ${m(w)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}const S=r.sizes;if(S){const a=S[t]||S[t.toLowerCase()];if(a!==void 0)return d?`calc(${a} * -1)`:a}if(!i[c]&&c.length===2&&(r.verbose&&console.warn(c,"- value is not found because `subSequence` is set to false"),c=c.slice(0,1)),o||r.useVariable){const a=`var(${h}${c}${g})`;return d?`calc(${a} * -1)`:a}const V=i?i[c]:null;return V?e==="ms"||e==="s"?d+V.val+e:d+V.scaling+e:console.warn("can't find",i,c)},W=(t,n)=>{if(!["+","-","*","/",","].filter(e=>t.includes(e+" ")).length)return t;const s=/(\s*[+\-*/,]\s*)/;return t.split(s).map(e=>{const o=e.trim();return!o||["+","-","*","/",","].includes(o)?e:K(o,n)}).join("")},Y=(t,n,r,s)=>{if(typeof t!="string")return A().verbose&&console.warn(n,t,"is not a string"),{[n]:t};if(t==="-"||t==="")return{};if(!s&&t.includes("(")){const e=F(t);s=e[0],t=e[1]}return["+","-","*","/",","].filter(e=>t.includes(e+" ")).length?t=W(t,r):t=K(t,r),{[n]:s?`${s}(${t})`:t}},z=(t,n)=>b[t-n],k=t=>{const{h1Matches:n,sequence:r}=t;return new Array(6).fill(null).map((s,i)=>{const e=z(n,i);return r[e]})};export{z as findHeadingLetter,k as findHeadings,Q as generateSequence,X as generateSequencePosition,O as generateSubSequence,F as getFnPrefixAndValue,K as getSequenceValue,W as getSequenceValueBySymbols,Y as getSequenceValuePropertyPair,J as getSubratio,C as getSubratioDifference,b as numToLetterMap,L as setScalingVar,j as setSubScalingVar};
|