@symbo.ls/scratch 3.14.774 → 3.14.776
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/set.js +1 -1
- package/dist/cjs/src/system/border.js +1 -0
- package/dist/cjs/src/system/color.js +1 -1
- package/dist/cjs/src/system/font.js +1 -1
- package/dist/cjs/src/system/index.js +1 -1
- package/dist/cjs/src/system/reset.js +1 -1
- package/dist/cjs/src/system/shadow.js +1 -1
- package/dist/cjs/src/system/theme.js +1 -1
- package/dist/cjs/src/transforms/index.js +1 -1
- package/dist/cjs/src/utils/color.js +1 -1
- package/dist/cjs/src/utils/font.js +7 -7
- package/dist/esm/src/set.js +1 -1
- package/dist/esm/src/system/border.js +1 -0
- package/dist/esm/src/system/color.js +1 -1
- package/dist/esm/src/system/font.js +1 -1
- package/dist/esm/src/system/index.js +1 -1
- package/dist/esm/src/system/reset.js +1 -1
- package/dist/esm/src/system/shadow.js +1 -1
- package/dist/esm/src/system/theme.js +1 -1
- package/dist/esm/src/transforms/index.js +1 -1
- package/dist/esm/src/utils/color.js +1 -1
- package/dist/esm/src/utils/font.js +7 -7
- package/package.json +4 -5
package/dist/cjs/src/set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var D=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var B=(t,s)=>{for(var e in s)D(t,e,{get:s[e],enumerable:!0})},K=(t,s,e,o)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of $(s))!z.call(t,r)&&r!==e&&D(t,r,{get:()=>s[r],enumerable:!(o=Y(s,r))||o.enumerable});return t};var U=t=>K(D({},"__esModule",{value:!0}),t);var N={};B(N,{VALUE_TRANSFORMERS:()=>R,changeGlobalTheme:()=>X,set:()=>G,setEach:()=>H,setValue:()=>F});module.exports=U(N);var v=require("./factory.js"),n=require("./system/index.js"),_=require("@symbo.ls/utils"),h=require("./utils/host.js");const T="__smblsThemeRootOwner",w=t=>{const s=t&&t.__prefersListener,e=t&&t.__prefersMq;if(s&&e)try{typeof e.removeEventListener=="function"?e.removeEventListener("change",s):typeof e.removeListener=="function"&&e.removeListener(s)}catch{try{e.removeListener(s)}catch{}}t&&(t.__prefersListener=null,t.__prefersMq=null)},W=(t,s,e)=>{if(!(!t||!s)){w(t),t.__prefersListener=e,t.__prefersMq=s;try{s.addEventListener("change",e)}catch{s.addListener(e)}}},J=(t,s)=>{const e=(0,v.getActiveConfig)(),{cssVars:o}=e,r=s.startsWith("--")?s:`--${s}`;return o[r]=t,t},d=t=>t,R={color:n.setColor,gradient:n.setGradient,font:n.setFont,fontFamily:n.setFontFamily,fontfamily:n.setFontFamily,theme:n.setTheme,icons:n.setSvgIcon,semanticIcons:d,semanticicons:d,svg:n.setSVG,svgData:d,typography:d,shadow:n.setShadow,spacing:d,media:d,grid:d,class:d,timing:d,reset:d,unit:d,animation:d,vars:J,sizes:d,shape:d},Q=(t,s,e,o)=>{(0,h.parkHostObject)(t,e,s);const r={};for(const i of o)t[i]===s&&(t[i]=r);return t.verbose&&console.warn("[scratch] design-system family",e,"resolved to a host object; parked it and allocated a plain bucket"),r},F=(t,s,e)=>{const o=(0,v.getActiveConfig)(),r=(0,v.toCamel)(t),i=r.toLowerCase(),m=o[r]||o[i]||o[t],c=(0,h.isHostObject)(m)?Q(o,m,i,[r,i,t]):m,u=R[r]||R[i];if(u)try{const f=u(s,e);return c&&(c[e]=f),c}catch(f){o.verbose&&console.warn("Error setting",i,"value",s,e,f)}if(!u){const f=c||(o[i]={});return f[e]=s,f}o.verbose&&console.warn("Can not find",i,"method in scratch")},H=(t,s)=>{const e=(0,v.getActiveConfig)(),o=t.toLowerCase();return(0,h.isHostObject)(s)?((0,h.parkHostObject)(e,o,s),e.verbose&&console.warn("[scratch] ignoring host object passed as the",o,"design-system family"),e[o]||e[t]):s==null?(e.verbose&&console.warn("[scratch] skipping empty design-system family",o),e[o]||e[t]):(Object.keys(s).sort((i,m)=>{const c=(0,_.isObject)(s[i])||(0,_.isArray)(s[i])?1:0,u=(0,_.isObject)(s[m])||(0,_.isArray)(s[m])?1:0;return c-u}).forEach(i=>{try{return F(o,s[i],i)}catch(m){e.verbose&&console.warn("Error setting",o,"value",s[i],i,m)}}),e[o]||e[t])},X=(t,s)=>{const e=s||(0,v.getActiveConfig)();e.globalTheme=t;const r=(0,h.resolveConfigDocument)(e)||(typeof document<"u"?document:null),i=r&&r.defaultView||(typeof window<"u"?window:null);if(r){const c=e.themeRoot||r.documentElement,u=t&&t!=="auto";if(c[T]=e,u)w(e),c.setAttribute("data-theme",t),e.resolvedTheme=t,t==="dark"||t==="light"?c.style.colorScheme=t:c.style.colorScheme="light dark";else if(i&&i.matchMedia){const f=y=>{const S=y.matches?"dark":"light";c.setAttribute("data-theme",S),e.resolvedTheme=S},g=i.matchMedia("(prefers-color-scheme: dark)");f(g),c.style.colorScheme="light dark",W(e,g,f)}else w(e),c.setAttribute("data-theme","light"),e.resolvedTheme="light",c.style.colorScheme="light"}const m=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const c in e.cssVars)c.startsWith(m)&&delete e.cssVars[c];for(const c in e.cssMediaVars)delete e.cssMediaVars[c];if(r&&e.cssVars){const c=e.scopeSelector||":root",u=r.styleSheets;for(let f=0;f<u.length;f++)try{const g=u[f].cssRules;for(let y=0;y<g.length;y++)if(g[y].selectorText===c){for(const S in e.cssVars)g[y].style.setProperty(S,e.cssVars[S]);return e}}catch{}}return e},Z={},G=(t,s=Z)=>{let e=s.config||(0,v.getActiveConfig)();const{version:o,verbose:r,useVariable:i,useReset:m,useSvgSprite:c,useFontImport:u,useIconSprite:f,globalTheme:g,themeRoot:y,useDocumentTheme:S,useDefaultConfig:L,semanticIcons:A,hoverMedia:M,files:P,assets:C,...p}=t;s.newConfig&&(e=(0,v.setActiveConfig)(s.newConfig)),(0,h.isDomDocument)(p.document)&&(e.__domDocument=p.document,delete p.document),(0,h.isDomDocument)(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),P!==void 0&&(e.files=P),C!==void 0&&(e.assets=C),r!==void 0&&(e.verbose=r),i!==void 0&&(e.useVariable=i),m!==void 0&&(e.useReset=m),u!==void 0&&(e.useFontImport=u),c!==void 0&&(e.useSvgSprite=c),f!==void 0&&(e.useIconSprite=f),S!==void 0&&(e.useDocumentTheme=S),g!==void 0&&(e.globalTheme=g),y!==void 0&&(e.themeRoot=y),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),L!==void 0&&(e.useDefaultConfig=L),A!==void 0&&(e.semanticIcons=A),M!==void 0&&(e.hoverMedia=M),e.verbose&&console.log(e);const E=(0,h.resolveConfigDocument)(e)||(typeof document<"u"?document:null),V=E&&E.defaultView||(typeof window<"u"?window:null),l=E&&(e.themeRoot||E.documentElement);if(l&&typeof l.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")w(e),l.setAttribute("data-theme",e.globalTheme),e.resolvedTheme=e.globalTheme,l[T]=e,e.globalTheme==="dark"||e.globalTheme==="light"?l.style.colorScheme=e.globalTheme:l.style.colorScheme="light dark";else if(l[T]&&l[T]!==e&&l.hasAttribute("data-theme"))w(e),e.resolvedTheme=l.getAttribute("data-theme");else if(V&&V.matchMedia){const b=I=>{const O=I.matches?"dark":"light";l.setAttribute("data-theme",O),e.resolvedTheme=O},j=V.matchMedia("(prefers-color-scheme: dark)");b(j),l.style.colorScheme="light dark",l[T]=e,W(e,j,b)}else w(e),l.setAttribute("data-theme","light"),e.resolvedTheme="light",l.style.colorScheme="light",l[T]=e;e.__svgCache||(e.__svgCache={});const x=Object.keys(p).filter(a=>!a.startsWith("__")),k=new Set(x);if(x.forEach(a=>{const b=a.toLowerCase();b!==a&&k.has(b)&&(0,_.deepMerge)(p[b],p[a])}),x.map(a=>{const b=a.toLowerCase();if(!(b!==a&&k.has(b)))return H(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{(0,n.applyTypographySequence)()}catch(a){e.verbose&&console.warn("Error applying typography sequence",a)}if(p.spacing)try{(0,n.applySpacingSequence)()}catch(a){e.verbose&&console.warn("Error applying spacing sequence",a)}if(p.timing)try{(0,n.applyTimingSequence)()}catch(a){e.verbose&&console.warn("Error applying timing sequence",a)}(0,n.applyDocument)();const q=(0,n.applyReset)();return q&&(e.reset=q),e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var u=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var p=(t,e)=>{for(var n in e)u(t,n,{get:e[n],enumerable:!0})},g=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of a(e))!S.call(t,i)&&i!==n&&u(t,i,{get:()=>e[i],enumerable:!(o=m(e,i))||o.enumerable});return t};var C=t=>g(u({},"__esModule",{value:!0}),t);var h={};p(h,{resolveBorderValue:()=>b});module.exports=C(h);var c=require("./color.js"),l=require("./spacing.js"),s=require("../utils/color.js");const E=new Set(["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset","initial"]),R=t=>E.has(t),b=(t,e,n)=>{const o=t+"";if(s.CSS_NATIVE_COLOR_REGEX.test(o))return o;const i=o.trim();return i==="none"||i==="0"||i==="initial"||i==="inherit"||i==="unset"?o:o.split(/\s+/).map(r=>{if(r=r.trim(),!r)return"";if((0,s.isCSSVar)(r))return`var(${r})`;if(R(r)||/^\d/.test(r)||r==="0")return r;const f=(0,c.getColor)(r,e);if((0,s.isResolvedColor)(f))return f;n&&n(r);const d=(0,l.getSpacingByKey)(r,"border");return d&&d.border?d.border:r}).join(" ")};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var w=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var F=(r,t)=>{for(var g in t)w(r,g,{get:t[g],enumerable:!0})},q=(r,t,g,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of O(t))!j.call(r,a)&&a!==g&&w(r,a,{get:()=>t[a],enumerable:!(e=L(t,a))||e.enumerable});return r};var _=r=>q(w({},"__esModule",{value:!0}),r);var N={};F(N,{STANDARD_SCHEME_QUERIES:()=>P,getColor:()=>A,getMediaColor:()=>H,resolveColorRgb:()=>D,setAdaptiveSchemeVar:()=>E,setColor:()=>M,setGradient:()=>T});module.exports=_(N);var d=require("@symbo.ls/utils"),S=require("../factory.js"),h=require("../utils/index.js");const P={light:"(prefers-color-scheme: light)",dark:"(prefers-color-scheme: dark)"},A=(r,t,g)=>{const e=g||(0,S.getActiveConfig)();if(!(0,d.isString)(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if((0,h.isCSSVar)(r))return`var(${r})`;t&&r[t]&&(r=r[t]);let a,l,o;if((0,d.isArray)(r))[a,l,o]=r;else{const s=(0,h.parseColorToken)(r);if(!s){const{color:i,gradient:C}=e;let $=C[r]||i[r];return $?(t&&$[t]&&($=$[t]),e.useVariable?`var(${$.var})`:$.value):r}if(s.passthrough)return s.passthrough;if(s.cssVar)return`var(${s.cssVar})`;a=s.name,l=s.alpha,o=s.tone}const{color:b,gradient:f}=e;let n=b[a]||f[a];if(!n)return e.verbose&&console.warn("Can't find color ",a),r;if(t)if(n[t]!==void 0)n=n[t];else if((0,d.isArray)(n)){const s=t.charCodeAt(0)===64?t.slice(1):t;s==="dark"?n=n[1]!==void 0?n[1]:n[0]:(s!=="light"&&e.verbose&&console.warn(r," - array-form color tokens only support light/dark; falling back to the light slot for scheme",t),n=n[0])}else e.verbose&&console.warn(r," - does not have ",t);if((0,d.isString)(n))return A(n,null,g);let p=n.rgb;if(!p){const s=e.useVariable?`var(${n.var})`:n.value;if((l||o)&&s){const i=l!==void 0?l:1;if(!o)return`rgb(from ${s} r g b / ${i})`;if(o.charCodeAt(0)===43||o.charCodeAt(0)===45){const $=parseFloat(o),u=$<0?"-":"+",c=Math.abs($);return`rgb(from ${s} calc(r ${u} ${c}) calc(g ${u} ${c}) calc(b ${u} ${c}) / ${i})`}return`hsl(from ${s} h s ${o}% / ${i})`}return s}return o&&!n[o]&&(p=(0,h.getRgbTone)(p,o),n[o]={rgb:p,var:`${n.var}-${o}`}),n[o]&&(p=n[o].rgb),l?`rgba(${p}, ${l})`:o?`rgba(${p}, 1)`:e.useVariable?`var(${n.var})`:`rgb(${p})`},D=(r,t,g)=>{const e=t||(0,S.getActiveConfig)();if(!(0,d.isString)(r))return null;const a=(0,h.parseColorToken)(r);if(a){if(a.passthrough){const i=(0,h.colorStringToRgbaArray)(a.passthrough);return i&&i.length>=3?{rgb:[i[0],i[1],i[2]],alpha:i[3]!==void 0?i[3]:1}:null}if(a.cssVar)return null}const l=a?a.name:r,{color:o,gradient:b}=e;let f=o[l]||b[l];if(!f){const i=(0,h.colorStringToRgbaArray)(r);return!i||i.length<3||i[0]===0&&i[1]===0&&i[2]===0&&i[3]===0&&r.toLowerCase()!=="transparent"?null:{rgb:[i[0],i[1],i[2]],alpha:i[3]!==void 0?i[3]:1}}if((0,d.isString)(f))return D(f,e,g);if(f.rgb===void 0&&(0,d.isObject)(f)){const i=`@${g||"light"}`;f=f[i]!==void 0?f[i]:f["@light"]}if(!f||f.rgb===void 0)return null;let n=f.rgb;a&&a.tone&&(n=(0,h.getRgbTone)(n,a.tone));const p=(0,d.isString)(n)?n.split(",").map(i=>parseFloat(i.trim())):n,s=a&&a.alpha!==void 0?parseFloat(a.alpha):f.alpha!==void 0?f.alpha:1;return{rgb:p,alpha:s}},H=(r,t,g)=>{const e=g||(0,S.getActiveConfig)();if(t||(t=e.globalTheme==="auto"?null:e.globalTheme),!(0,d.isString)(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if((0,h.isCSSVar)(r))return`var(${r})`;let a,l,o;if((0,d.isArray)(r))a=r[0];else{const s=(0,h.parseColorToken)(r);if(s){if(s.passthrough)return s.passthrough;if(s.cssVar)return`var(${s.cssVar})`;a=s.name,l=s.alpha,o=s.tone}else a=r}const{color:b,gradient:f}=e,n=b[a]||f[a],p=(0,d.isObject)(n);if(p&&n.value)return A(r,`@${t}`,g);if(p){if(e.useVariable&&n.var)return l||o?A(r,null,g):`var(${n.var})`;if(t)return A(r,`@${t}`,g);{const s={};for(const i in n){if(i.charCodeAt(0)!==64)continue;const C=i.slice(1),$=e.media&&e.media[C]||P[C];if(!$)continue;const u="@media "+($==="print"?`${$}`:`screen and ${$}`);s[u]=A(r,i,g)}return s}}else return e.verbose&&console.warn("Can't find color",r),r},E=(r,t,g,e)=>{const l=`--${e.varPrefix?e.varPrefix+"-":""}${t}-${g}`;let o;const b={};for(const f in r){if(f.charCodeAt(0)!==64)continue;const n=f.slice(1),p=r[f],s=p&&(p.value||p);!s||typeof s!="string"||(b[n]=s,(n==="light"||o===void 0)&&(o=s))}if(o!==void 0){e.cssVars[l]=o,e.cssMediaVars||(e.cssMediaVars={});for(const f in b){const n=`[data-theme="${f}"]`;if(e.cssMediaVars[n]||(e.cssMediaVars[n]={}),e.cssMediaVars[n][l]=b[f],f==="light"||f==="dark"){const p=`@media (prefers-color-scheme: ${f})`;e.cssMediaVars[p]||(e.cssMediaVars[p]={}),e.cssMediaVars[p][l]=b[f]}}return r.var=l,l}},M=(r,t,g)=>{const e=(0,S.getActiveConfig)();if((0,d.isObject)(r)&&r.value!==void 0&&(r.rgb!==void 0||r.var!==void 0))return e.useVariable&&r.var&&(e.cssVars[r.var]=r.value),r;if((0,d.isString)(r)&&(0,h.isCSSVar)(r)){const u=r.slice(2);if(r=A(u),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const c=u.split(" ");let m=e.color[c[0]];if(m&&!m.value&&!m.rgb&&((0,d.isString)(m)||(0,d.isArray)(m)||(0,d.isObject)(m))&&(e.color[c[0]]=M(m,c[0]),m=e.color[c[0]]),m&&m.value){let V=m.rgb;const x=c[1]!==void 0?c[1]:"1",R=c[2];R&&(V=(0,h.getRgbTone)(V,R)),r=`rgba(${V}, ${x})`}else{const V=c[2],x=c[1]!==void 0?c[1]:"1";if(V)try{const R=(0,h.colorStringToRgbaArray)(c[0]);R&&R.length>=3?r=`rgba(${(0,h.getRgbTone)(R.slice(0,3).join(", "),V)}, ${x})`:r=c[0]}catch{r=c[0]}else r=c[0]}}}if((0,d.isArray)(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),(0,d.isObject)(r)){const u={};for(const c in r)c!=="var"&&(u[c]=M(r[c],t,c.slice(0,1)==="@"?c.slice(1):c));return e.useVariable&&E(u,"color",t,e),u}const l=`--${e.varPrefix?e.varPrefix+"-":""}color-${t}`+(g?`-${g}`:"");let o=r.value||r;if((0,d.isString)(o)&&!o.includes("(")&&!o.startsWith("#")){const u=(0,h.parseColorToken)(o);if(u&&u.name&&!u.passthrough&&!u.cssVar){const c=e.color[u.name];c&&!c.value&&!c.rgb&&((0,d.isString)(c)||(0,d.isArray)(c)||(0,d.isObject)(c))&&(e.color[u.name]=M(c,u.name));const m=e.color[u.name];if(m&&m.rgb){let V=m.rgb;u.tone&&(V=(0,h.getRgbTone)(V,u.tone));const x=u.alpha?parseFloat(u.alpha):1;o=`rgba(${V}, ${x})`}}}const b=(0,h.colorStringToRgbaArray)(o),[f,n,p,s=1]=b,i=parseFloat(s.toFixed(2)),C=`${f}, ${n}, ${p}`,$=`rgba(${C}, ${i})`;return e.useVariable&&(e.cssVars[l]=$),{var:l,rgb:C,alpha:i,value:$}},T=(r,t,g)=>{const e=(0,S.getActiveConfig)();if((0,d.isObject)(r)&&r.value!==void 0&&r.var!==void 0)return e.useVariable&&(e.cssVars[r.var]=r.value),r;if((0,d.isString)(r)&&(0,h.isCSSVar)(r)&&(r=A(r.slice(2))),(0,d.isArray)(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),(0,d.isObject)(r)){const o={};for(const b in r)b!=="var"&&(o[b]=T(r[b],t,b.slice(0,1)==="@"?b.slice(1):b));return e.useVariable&&E(o,"gradient",t,e),o}const l=`--${e.varPrefix?e.varPrefix+"-":""}gradient-${t}`+(g?`-${g}`:"");return e.useVariable&&(e.cssVars[l]=r.value||r),{var:l,value:r.value||r}};
|
|
1
|
+
"use strict";var M=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var s in t)M(e,s,{get:t[s],enumerable:!0})},N=(e,t,s,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of j(t))!_.call(e,n)&&n!==s&&M(e,n,{get:()=>t[n],enumerable:!(r=T(t,n))||r.enumerable});return e};var W=e=>N(M({},"__esModule",{value:!0}),e);var U={};v(U,{STANDARD_SCHEME_QUERIES:()=>D,getColor:()=>w,getMediaColor:()=>Q,resolveColorRgb:()=>L,setAdaptiveSchemeVar:()=>E,setColor:()=>A,setGradient:()=>P});module.exports=W(U);var c=require("@symbo.ls/utils"),R=require("../factory.js"),b=require("../utils/index.js");const D={light:"(prefers-color-scheme: light)",dark:"(prefers-color-scheme: dark)"},V=new Set,z=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]),x=new Set,F=e=>{if(!e)return!1;const{color:t,gradient:s}=e;return!!((0,c.isObject)(t)&&Object.keys(t).length||(0,c.isObject)(s)&&Object.keys(s).length)},O=(e,t,s)=>{const r=(0,c.isString)(t)?t.toLowerCase():"";if(!z.has(r)||!F(s))return e;if(!x.has(r)){x.add(r);const n=s&&s.name?` (design system \`${s.name}\`)`:"";console.warn(`[scratch] color \`${e}\` is a CSS named colour that is not in the palette${n}. Dropped rather than emitted as a raw browser colour, which renders theme-blind and can be unreadable ("looks designed", so it ships unnoticed). Define it in designSystem/color.js or use a palette token.`)}},w=(e,t,s)=>{const r=s||(0,R.getActiveConfig)();if(!(0,c.isString)(e)){r.verbose&&console.warn(e,"- type for color is not valid");return}if((0,b.isCSSVar)(e))return`var(${e})`;t&&e[t]&&(e=e[t]);let n,f,l;if((0,c.isArray)(e))[n,f,l]=e;else{const i=(0,b.parseColorToken)(e);if(!i){const{color:g,gradient:k}=r;let $=k[e]||g[e];return $?(t&&$[t]&&($=$[t]),r.useVariable?`var(${$.var})`:$.value):e}if(i.passthrough)return i.passthrough;if(i.cssVar)return`var(${i.cssVar})`;n=i.name,f=i.alpha,l=i.tone}const{color:m,gradient:d}=r;let o=m[n]||d[n];if(!o)return O(e,n,r);if(t)if(o[t]!==void 0)o=o[t];else if((0,c.isArray)(o)){const i=t.charCodeAt(0)===64?t.slice(1):t;i==="dark"?o=o[1]!==void 0?o[1]:o[0]:(i!=="light"&&r.verbose&&console.warn(e," - array-form color tokens only support light/dark; falling back to the light slot for scheme",t),o=o[0])}else r.verbose&&console.warn(e," - does not have ",t);if((0,c.isString)(o)){if(V.has(n))return o;V.add(n);try{return w(o,null,s)}finally{V.delete(n)}}let h=o.rgb;if(!h){const i=r.useVariable?`var(${o.var})`:o.value;if((f||l)&&i){const g=f!==void 0?f:1;if(!l)return`rgb(from ${i} r g b / ${g})`;if(l.charCodeAt(0)===43||l.charCodeAt(0)===45){const $=parseFloat(l),u=$<0?"-":"+",a=Math.abs($);return`rgb(from ${i} calc(r ${u} ${a}) calc(g ${u} ${a}) calc(b ${u} ${a}) / ${g})`}return`hsl(from ${i} h s ${l}% / ${g})`}return i}return l&&!o[l]&&(h=(0,b.getRgbTone)(h,l),o[l]={rgb:h,var:`${o.var}-${l}`}),o[l]&&(h=o[l].rgb),f?`rgba(${h}, ${f})`:l?`rgba(${h}, 1)`:r.useVariable?`var(${o.var})`:`rgb(${h})`},q=e=>{const t=(0,b.colorStringToRgbaArray)(e);return!t||t.length<3||t[0]===0&&t[1]===0&&t[2]===0&&t[3]===0&&e.toLowerCase()!=="transparent"?null:{rgb:[t[0],t[1],t[2]],alpha:t[3]!==void 0?t[3]:1}},H=(e,t)=>{if(!t)return e;let s=e.rgb;if(t.tone){const n=(0,b.getRgbTone)(s,t.tone);s=(0,c.isString)(n)?n.split(",").map(f=>parseFloat(f.trim())):n}const r=t.alpha!==void 0?parseFloat(t.alpha):e.alpha;return{rgb:s,alpha:r}},L=(e,t,s)=>{const r=t||(0,R.getActiveConfig)();if(!(0,c.isString)(e))return null;const n=(0,b.parseColorToken)(e);if(n){if(n.passthrough){const g=(0,b.colorStringToRgbaArray)(n.passthrough);return g&&g.length>=3?{rgb:[g[0],g[1],g[2]],alpha:g[3]!==void 0?g[3]:1}:null}if(n.cssVar)return null}const f=n?n.name:e,{color:l,gradient:m}=r;let d=l[f]||m[f];if(!d)return q(e);if((0,c.isString)(d)){let g;if(V.has(f))g=q(d);else{V.add(f);try{g=L(d,r,s)}finally{V.delete(f)}}return g?H(g,n):null}if(d.rgb===void 0&&(0,c.isObject)(d)){const g=`@${s||"light"}`;d=d[g]!==void 0?d[g]:d["@light"]}if(!d||d.rgb===void 0)return null;let o=d.rgb;n&&n.tone&&(o=(0,b.getRgbTone)(o,n.tone));const h=(0,c.isString)(o)?o.split(",").map(g=>parseFloat(g.trim())):o,i=n&&n.alpha!==void 0?parseFloat(n.alpha):d.alpha!==void 0?d.alpha:1;return{rgb:h,alpha:i}},Q=(e,t,s)=>{const r=s||(0,R.getActiveConfig)();if(t||(t=r.globalTheme==="auto"?null:r.globalTheme),!(0,c.isString)(e)){r.verbose&&console.warn(e,"- type for color is not valid");return}if((0,b.isCSSVar)(e))return`var(${e})`;let n,f,l;if((0,c.isArray)(e))n=e[0];else{const i=(0,b.parseColorToken)(e);if(i){if(i.passthrough)return i.passthrough;if(i.cssVar)return`var(${i.cssVar})`;n=i.name,f=i.alpha,l=i.tone}else n=e}const{color:m,gradient:d}=r,o=m[n]||d[n],h=(0,c.isObject)(o);if(h&&o.value)return w(e,`@${t}`,s);if(h){if(r.useVariable&&o.var)return f||l?w(e,null,s):`var(${o.var})`;if(t)return w(e,`@${t}`,s);{const i={},g=r.scopeSelector||":root",k=g===":root"?":root:not([data-theme])":`:root:not([data-theme]) ${g}:not([data-theme])`;for(const $ in o){if($.charCodeAt(0)!==64)continue;const u=$.slice(1),a=w(e,$,s);if(a!==void 0&&(i[`[data-theme="${u}"] &`]=a,u==="light"||u==="dark")){const p=r.media&&r.media[u]||D[u];if(!p)continue;const y="@media "+(p==="print"?`${p}`:`screen and ${p}`);i[y]={[`${k} &`]:a}}}return i}}else return O(e,n,r)},E=(e,t,s,r)=>{const f=`--${r.varPrefix?r.varPrefix+"-":""}${t}-${s}`;let l;const m={};for(const d in e){if(d.charCodeAt(0)!==64)continue;const o=d.slice(1),h=e[d],i=h&&(h.value||h);!i||typeof i!="string"||(m[o]=i,(o==="light"||l===void 0)&&(l=i))}if(l!==void 0){r.cssVars[f]=l,r.cssMediaVars||(r.cssMediaVars={});for(const d in m){const o=`[data-theme="${d}"]`;if(r.cssMediaVars[o]||(r.cssMediaVars[o]={}),r.cssMediaVars[o][f]=m[d],d==="light"||d==="dark"){const h=`@media (prefers-color-scheme: ${d})`;r.cssMediaVars[h]||(r.cssMediaVars[h]={}),r.cssMediaVars[h][f]=m[d]}}return e.var=f,f}},A=(e,t,s)=>{const r=(0,R.getActiveConfig)();if((0,c.isObject)(e)&&e.value!==void 0&&(e.rgb!==void 0||e.var!==void 0))return r.useVariable&&e.var&&(r.cssVars[e.var]=e.value),e;if((0,c.isString)(e)&&(0,b.isCSSVar)(e)){const u=e.slice(2);if(e=w(u),!(e.includes("rgb")||e.includes("var")||e.includes("#"))){const a=u.split(" ");let p=r.color[a[0]];if(p&&!p.value&&!p.rgb&&((0,c.isString)(p)||(0,c.isArray)(p)||(0,c.isObject)(p))&&!V.has(a[0])){V.add(a[0]);try{r.color[a[0]]=A(p,a[0])}finally{V.delete(a[0])}p=r.color[a[0]]}if(p&&p.value){let y=p.rgb;const C=a[1]!==void 0?a[1]:"1",S=a[2];S&&(y=(0,b.getRgbTone)(y,S)),e=`rgba(${y}, ${C})`}else{const y=a[2],C=a[1]!==void 0?a[1]:"1";if(y)try{const S=(0,b.colorStringToRgbaArray)(a[0]);S&&S.length>=3?e=`rgba(${(0,b.getRgbTone)(S.slice(0,3).join(", "),y)}, ${C})`:e=a[0]}catch{e=a[0]}else e=a[0]}}}if((0,c.isArray)(e)&&(e={"@light":e[0],"@dark":e[1]!==void 0?e[1]:e[0]}),(0,c.isObject)(e)){const u={};for(const a in e)a!=="var"&&(u[a]=A(e[a],t,a.slice(0,1)==="@"?a.slice(1):a));return r.useVariable&&E(u,"color",t,r),u}const f=`--${r.varPrefix?r.varPrefix+"-":""}color-${t}`+(s?`-${s}`:"");let l=e.value||e;if((0,c.isString)(l)&&!l.includes("(")&&!l.startsWith("#")){const u=(0,b.parseColorToken)(l);if(u&&u.name&&!u.passthrough&&!u.cssVar){const a=r.color[u.name];if(a&&!a.value&&!a.rgb&&((0,c.isString)(a)||(0,c.isArray)(a)||(0,c.isObject)(a))&&!V.has(u.name)){V.add(u.name);try{r.color[u.name]=A(a,u.name)}finally{V.delete(u.name)}}const p=r.color[u.name];if(p&&p.rgb){let y=p.rgb;u.tone&&(y=(0,b.getRgbTone)(y,u.tone));const C=u.alpha!==void 0?parseFloat(u.alpha):p.alpha!==void 0?p.alpha:1;l=`rgba(${y}, ${C})`}}}const m=(0,b.colorStringToRgbaArray)(l),[d,o,h,i=1]=m,g=parseFloat(i.toFixed(2)),k=`${d}, ${o}, ${h}`,$=`rgba(${k}, ${g})`;return r.useVariable&&(r.cssVars[f]=$),{var:f,rgb:k,alpha:g,value:$}},P=(e,t,s)=>{const r=(0,R.getActiveConfig)();if((0,c.isObject)(e)&&e.value!==void 0&&e.var!==void 0)return r.useVariable&&(r.cssVars[e.var]=e.value),e;if((0,c.isString)(e)&&(0,b.isCSSVar)(e)&&(e=w(e.slice(2))),(0,c.isArray)(e)&&(e={"@light":e[0],"@dark":e[1]!==void 0?e[1]:e[0]}),(0,c.isObject)(e)){const l={};for(const m in e)m!=="var"&&(l[m]=P(e[m],t,m.slice(0,1)==="@"?m.slice(1):m));return r.useVariable&&E(l,"gradient",t,r),l}const f=`--${r.varPrefix?r.varPrefix+"-":""}gradient-${t}`+(s?`-${s}`:"");return r.useVariable&&(r.cssVars[f]=e.value||e),{var:f,value:e.value||e}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var g=(t,e)=>{for(var r in e)c(t,r,{get:e[r],enumerable:!0})},O=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of p(e))!S.call(t,s)&&s!==r&&c(t,s,{get:()=>e[s],enumerable:!(i=y(e,s))||i.enumerable});return t};var h=t=>O(c({},"__esModule",{value:!0}),t);var D={};g(D,{getFontFamily:()=>C,setFont:()=>A,setFontFamily:()=>I});module.exports=h(D);var l=require("@symbo.ls/utils"),u=require("@symbo.ls/utils"),F=require("../factory.js"),o=require("../utils/index.js");const A=(t,e)=>{const r=(0,F.getActiveConfig)(),i=`--font-${e}`;if(!t||(0,l.isArray)(t)&&!t[0])return;let s;if(t.isVariable){const n=(0,o.resolveFileUrl)(t.url,r.files)||t.url;(0,o.isGoogleFontsUrl)(n)?s=(0,o.setFontImport)(n):s=(0,o.setCustomFontMedia)(e,n,t.fontWeight,{fontStretch:t.fontStretch,fontDisplay:t.fontDisplay||"swap"})}else if(t[0])s=(0,o.getFontFaceEach)(e,t,r.files);else{const n=Array.isArray(t.url)?t.url.map(f=>(0,o.resolveFileUrl)(f,r.files)||f):(0,o.resolveFileUrl)(t.url,r.files)||t.url;s=(0,o.setCustomFontMedia)(e,n,t.fontWeight,{fontStyle:t.fontStyle,fontDisplay:t.fontDisplay,fontStretch:t.fontStretch})}return{var:i,value:t,fontFace:s}},C=(t,e)=>{const r=(0,F.getActiveConfig)(),{fontFamily:i}=r;return(0,o.getDefaultOrFirstKey)(e||i,t)},I=(t,e)=>{const r=(0,F.getActiveConfig)(),{fontFamily:i,fontFamilyTypes:s}=r;let{value:n,type:f}=t;t.isDefault&&(!t.isSystemFallback||!i.default)&&(i.default=e),(0,l.isObject)(n)&&(n=(0,u.arrayzeValue)(n));const a=`--font-family-${e}`,m=`${n.join(", ")}, ${s[f]}`;return{var:a,value:m,arr:n,type:f,isSystemFallback:!!t.isSystemFallback}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(e,t,m,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let f of i(t))!u.call(e,f)&&f!==m&&s(e,f,{get:()=>t[f],enumerable:!(x=c(t,f))||x.enumerable});return e},o=(e,t,m)=>(p(e,t,"default"),m&&p(m,t,"default"));var a=e=>p(s({},"__esModule",{value:!0}),e);var r={};module.exports=a(r);o(r,require("./color.js"),module.exports);o(r,require("./ink.js"),module.exports);o(r,require("./theme.js"),module.exports);o(r,require("./font.js"),module.exports);o(r,require("./typography.js"),module.exports);o(r,require("./spacing.js"),module.exports);o(r,require("./shape.js"),module.exports);o(r,require("./shadow.js"),module.exports);o(r,require("./timing.js"),module.exports);o(r,require("./document.js"),module.exports);o(r,require("./svg.js"),module.exports);o(r,require("./reset.js"),module.exports);
|
|
1
|
+
"use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(e,t,m,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let f of i(t))!u.call(e,f)&&f!==m&&s(e,f,{get:()=>t[f],enumerable:!(x=c(t,f))||x.enumerable});return e},o=(e,t,m)=>(p(e,t,"default"),m&&p(m,t,"default"));var a=e=>p(s({},"__esModule",{value:!0}),e);var r={};module.exports=a(r);o(r,require("./color.js"),module.exports);o(r,require("./ink.js"),module.exports);o(r,require("./theme.js"),module.exports);o(r,require("./font.js"),module.exports);o(r,require("./typography.js"),module.exports);o(r,require("./spacing.js"),module.exports);o(r,require("./shape.js"),module.exports);o(r,require("./shadow.js"),module.exports);o(r,require("./border.js"),module.exports);o(r,require("./timing.js"),module.exports);o(r,require("./document.js"),module.exports);o(r,require("./svg.js"),module.exports);o(r,require("./reset.js"),module.exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var S=(i,t)=>{for(var
|
|
1
|
+
"use strict";var u=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var S=(i,t)=>{for(var e in t)u(i,e,{get:t[e],enumerable:!0})},A=(i,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of x(t))!F.call(i,o)&&o!==e&&u(i,o,{get:()=>t[o],enumerable:!(s=w(t,o))||s.enumerable});return i};var k=i=>A(u({},"__esModule",{value:!0}),i);var C={};S(C,{applyReset:()=>z});module.exports=k(C);var a=require("@symbo.ls/utils"),d=require("../factory.js"),h=require("./theme.js");const z=(i={})=>{const t=(0,d.getActiveConfig)(),e=t.typography||{},s=t.document||{},o=(0,a.isObject)(t.reset)?t.reset:t.reset={};if(o[":root"]){const r=o,n=e.templates||{};r.body={...t.useDocumentTheme?(0,h.getMediaTheme)("document"):{},...n.body},r.h1=n.h1,r.h2=n.h2,r.h3=n.h3,r.h4=n.h4,r.h5=n.h5,r.h6=n.h6}const{body:p,...b}=e.templates||{},f=t.useDocumentTheme?(0,h.getMediaTheme)("document"):{};if(o.html&&(0,a.overwriteDeep)(o.html,f),e.unit){const r=t.media||{};for(const n in e){if(n.charAt(0)!=="@")continue;const c=e[n];if(!c||c.unit===e.unit||!c.unit)continue;const g=c.unit,y=c.base||e.base,D=c.browserDefault||e.browserDefault,T=n.slice(1),l=r[T];if(!l)continue;const m="@media "+(l==="print"?l:"screen and "+l);o[m]||(o[m]={}),o[m].html||(o[m].html={}),o[m].html.fontSize=y/D+g}}return(0,a.deepMerge)((0,a.merge)(o,i),{html:{position:"absolute",width:"100%",height:"100%",top:"0",left:"0",margin:"0",WebkitFontSmoothing:"subpixel-antialiased",scrollBehavior:"smooth",...f,fontSize:e.unit?e.base/e.browserDefault+e.unit:e.browserDefault+"px",fontFamily:s.fontFamily,lineHeight:s.lineHeight},body:{boxSizing:"border-box",height:"100%",margin:0,fontFamily:s.fontFamily,fontSize:e.unit?"1"+t.unit.default:e.base/e.browserDefault+t.unit.default,...b,...p},a:{color:"currentColor"},button:{color:"inherit",font:"inherit",background:"transparent",border:"none",cursor:"pointer",appearance:"none",WebkitAppearance:"none"},"input, select, textarea":{color:"inherit",font:"inherit"},fieldset:{border:0,padding:0,margin:0}})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var h=Object.defineProperty;var
|
|
1
|
+
"use strict";var h=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var A=(r,i)=>{for(var n in i)h(r,n,{get:i[n],enumerable:!0})},$=(r,i,n,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of j(i))!l.call(r,t)&&t!==n&&h(r,t,{get:()=>i[t],enumerable:!(e=g(i,t))||e.enumerable});return r};var x=r=>$(h({},"__esModule",{value:!0}),r);var W={};A(W,{getShadow:()=>N,resolveShadowValue:()=>V,setShadow:()=>S});module.exports=x(W);var C=require("../factory.js"),p=require("./color.js"),b=require("./spacing.js"),d=require("../utils/color.js"),c=require("@symbo.ls/utils");const V=(r,i,n)=>!(0,c.isString)(r)||d.CSS_NATIVE_COLOR_REGEX.test(r)?r:(0,d.splitTopLevelCommas)(r).map(e=>(e=e.trim(),e.split(/\s+/).map(t=>{if(t=t.trim(),!t)return"";if(t.startsWith("--"))return`var(${t})`;const s=(0,p.getColor)(t,i);if((0,d.isResolvedColor)(s))return s;if(/^\d/.test(t)||t==="0"||t.includes("px")||t.slice(-2)==="em"||t==="inset"||t==="none")return t;n&&n(t);const f=(0,b.getSpacingByKey)(t,"shadow");return f&&f.shadow?f.shadow:t}).join(" "))).join(", "),S=(r,i,n,e)=>{const t=(0,C.getActiveConfig)();if((0,c.isArray)(r)){const o={"@light":S(r[0],i,"light"),"@dark":S(r[1],i,"dark")};return t.useVariable&&(0,p.setAdaptiveSchemeVar)(o,"shadow",i,t),o}if((0,c.isObject)(r)){const o={};for(const a in r)o[a]=S(r[a],i,a.startsWith("@")?a.slice(1):a);return t.useVariable&&(0,p.setAdaptiveSchemeVar)(o,"shadow",i,t),o}(0,c.isString)(r)&&!d.CSS_NATIVE_COLOR_REGEX.test(r)&&(r=V(r));const f=`--${t.varPrefix?t.varPrefix+"-":""}shadow-${i}`+(n?`-${n}`:"");return t.useVariable&&(t.cssVars[f]=r),{var:f,value:r}},N=(r,i)=>{const n=(0,C.getActiveConfig)();if(i||(i=n.globalTheme==="auto"?null:n.globalTheme),!(0,c.isString)(r)){n.verbose&&console.warn(r,"- type for color is not valid");return}if((0,d.isCSSVar)(r))return`var(${r})`;const[e]=(0,c.isArray)(r)?r:r.split(" "),s=n.shadow[e],f=(0,c.isObject)(s);if(!s)return n.verbose&&console.warn("Can't find color ",e),r;if(i){const o=s["@"+i]||s[i];if(o)return o.value!==void 0?o.value:o;n.verbose&&console.warn(r," - does not have ",i)}if(f&&s.value)return s.value;if(f){const o={};for(const a in s){if(a.charCodeAt(0)!==64)continue;const m=n.media[a.slice(1)];if(!m)continue;const O="@media "+(m==="print"?`${m}`:`screen and ${m}`),u=s[a],w=u&&(u.value!==void 0?u.value:u);w!==void 0&&(o[O]=w)}return o}return n.verbose&&console.warn("Can't find color",r),r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var R=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var F=(e,r)=>{for(var o in r)R(e,o,{get:r[o],enumerable:!0})},J=(e,r,o,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of W(r))!Z.call(e,n)&&n!==o&&R(e,n,{get:()=>r[n],enumerable:!(s=U(r,n))||s.enumerable});return e};var Q=e=>J(R({},"__esModule",{value:!0}),e);var ie={};F(ie,{getMediaTheme:()=>w,getTheme:()=>A,setMediaTheme:()=>E,setTheme:()=>ne});module.exports=Q(ie);var v=require("./color.js"),x=require("./shadow.js"),p=require("./border.js"),S=require("../factory.js"),y=require("../utils/color.js"),a=require("@symbo.ls/utils");const X=new Set(["black","white","red","green","blue","yellow","orange","purple","pink","brown","gray","grey","cyan","magenta","lime","olive","navy","teal","aqua","maroon","silver","fuchsia","transparent","currentColor","currentcolor","inherit","initial","unset","none","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","rebeccapurple"]),q=["color","Color","background","Background","fill","Fill","stroke","Stroke"],Y=e=>{for(let r=0;r<q.length;r++)if(e.includes(q[r]))return!0;return!1},I={boxShadow:x.resolveShadowValue,textShadow:x.resolveShadowValue,border:p.resolveBorderValue,borderTop:p.resolveBorderValue,borderRight:p.resolveBorderValue,borderBottom:p.resolveBorderValue,borderLeft:p.resolveBorderValue,outline:p.resolveBorderValue,columnRule:p.resolveBorderValue},K=e=>{if(!e)return!1;const r=(0,y.parseColorToken)(e);return!r||!r.name||r.passthrough||r.cssVar?!1:r.alpha!==void 0||r.tone!==void 0},_=new Set,G=(e,r,o,s,n,i)=>{if(!(0,a.isLoudDevRuntime)())return;const t=`${e}::${r}::${o||""}::${s}`;_.has(t)||(_.add(t),console.warn(`[smbls/scratch] theme param "${r}" on "${e}"`+(o?` (${o})`:"")+` did not fully resolve: "${s}" -> "${n}" still contains the unresolved token "${i}". This is not valid CSS \u2014 the browser will drop the whole declaration. Register "${i}" as a design-system color token or fix the typo.`))},L=(e,r,o,s)=>{const n=I[r];if(!n)return(0,v.getColor)(o,s);let i=null;const t=n(o,s,u=>{!i&&K(u)&&(i=u)});return i&&G(e,r,s,o,t,i),t},V=e=>{const r={},{state:o,media:s,helpers:n,...i}=e;return Object.keys(i).map(u=>{const c=["color","Color","background","border"].some(d=>u.includes(d));return r[u]=c?(0,v.getColor)(e[u]):e[u]}),r},$=e=>(e.value||(e.value=V(e)),e.value),A=(e,r)=>{const o=(0,S.getActiveConfig)();if(o.useVariable)return w(e,r);const s=o.theme;if((0,a.isString)(e)){const[n,i]=e.split(" "),t=s[n];if(t){if(!i&&!r)return $(t);e=[n,i||r]}}if((0,a.isObjectLike)(e)&&e[1]){const n=e[0],i=e[1],{helpers:t,media:u,state:l}=s[n];if(u&&u[i])return $(u[i]);if(t&&t[i])return $(t[i]);if(l&&l[i])return $(l[i])}else if((0,a.isObject)(e))return V(e)},ee=(e,r,o)=>{if((0,a.isObject)(r))e.variants.inverse.value=V(r);else if(r===!0){const{color:s,background:n}=o;e.variants.inverse={value:{color:n,background:s}}}},re=(e,r,o,s)=>{const n=A(o);s[`&:${r}`]=n,(0,a.isObject)(o)&&!o.value&&(o.value=n)},N=(e,r)=>{const{state:o}=e;return o?(Object.keys(o).map(n=>{const i=o[n];return re(e,n,i,r),e}),e):void 0},oe=(e,r,o,s)=>{const n=A(o);s[`@media (prefers-color-scheme: ${r})`]=n,(0,a.isObject)(o)&&!o.value&&(o.value=n)},H=(e,r)=>{const{media:o}=e;return o?(Object.keys(o).map(n=>{const i=o[n];return(n==="dark"||n==="light")&&oe(e,n,i,r),n==="inverse"&&ee(e,i,r),e}),e):void 0},D=(e,r)=>{const o=(0,S.getActiveConfig)(),{helpers:s}=e;return s?(Object.keys(s).map(i=>{const t=s[i];return(0,a.isString)(t)?s[i]=o.theme[t]:$(s[i]),e}),e):void 0},ne=(e,r)=>{const o=(0,S.getActiveConfig)();if(o.useVariable)return E(e,r);const{state:s,media:n,helpers:i}=e,t=V(e,r),l=`--${o.varPrefix?o.varPrefix+"-":""}theme-${r}`;return N(e,t),H(e,t),D(e,t),{var:l,value:t,state:s,media:n,helpers:i}},le={"@":(e,r)=>H(e,r),":":(e,r)=>N(e,r),".":(e,r)=>D(e,r)},O=(e,r,o)=>{const{cssVars:s}=o;o.cssMediaVars||(o.cssMediaVars={});const n=o.cssMediaVars,i=o.globalTheme!==void 0?o.globalTheme:"auto",t={},u=new Set;for(const c in e)if(e[c])for(const d of Object.keys(e[c]))u.add(d);const l=new Set;for(const c of u){const d=c.slice(0,1);if(!(d==="@"||d==="."||d===":")&&Y(c))for(const m in e){if(l.has(m))continue;const h=e[m]?.[c];if(h===void 0)continue;const f=(0,v.getColor)(h,`@${m}`);f!==void 0&&(0,a.isString)(f)&&/^[a-z][a-zA-Z]+$/.test(f)&&!X.has(f)&&l.add(m)}}for(const c of u){const d=c.slice(0,1),m=Object.values(e).some(h=>(0,a.isObjectLike)(h?.[c]));if(d==="."&&m){const h=c.slice(1),f={};for(const b in e)(0,a.isObjectLike)(e[b]?.[c])&&(f[b]=e[b][c]);t[c]=O(f,`${r}-${h}`,o)}else if(d===":"&&m){const h=c.replace(/^:+/,""),f={};for(const b in e)(0,a.isObjectLike)(e[b]?.[c])&&(f[b]=e[b][c]);t[c]=O(f,`${r}-${h}`,o)}else if(d!=="@"&&d!=="."&&d!==":"){const f=`--${o.varPrefix?o.varPrefix+"-":""}theme-${r}-${c}`,b=i&&i!=="auto"?String(i).replace(/^'|'$/g,""):null;let k;for(const g in e){if(l.has(g))continue;const P=e[g]?.[c];if(P===void 0)continue;const T=L(r,c,P,`@${g}`);if(T===void 0)continue;(b&&g===b||!b&&(g==="light"||k===void 0))&&(k=T);const C=`[data-theme="${g}"]`;if(n[C]||(n[C]={}),n[C][f]=T,g==="dark"||g==="light"){const M=`@media (prefers-color-scheme: ${g})`;n[M]||(n[M]={}),n[M][f]=T}}k!==void 0&&(s[f]=k),t[c]=`var(${f})`,t[`.${c}`]={[c]:t[c]}}}return(t.background||t.color||t.backgroundColor)&&(t[".inversed"]={color:t.background||t.backgroundColor,background:t.color}),t},E=(e,r,o,s)=>{const n=(0,S.getActiveConfig)(),{cssVars:i}=n,t={value:e},u=!o&&!s;if((0,a.isObjectLike)(e)){if(u&&n.useVariable){const l={};for(const c in e)c.startsWith("@")&&(0,a.isObjectLike)(e[c])&&(l[c.slice(1)]=e[c]);if(Object.keys(l).length){const c=O(l,r,n);Object.assign(t,c)}}for(const l in e){const c=l.slice(0,1),d=e[l];if(c==="@"||c===":"||c==="."){const m=c==="@"&&l;t[l]=E(d,r,l,s||m)}else if(!u){const m=L(r,l,d,s),h=[...new Set([s,o].filter(g=>g).map(g=>g.slice(1)))],f=h.length?"-"+h.join("-"):"",k=`--${n.varPrefix?n.varPrefix+"-":""}theme-${r}${f}-${l}`;n.useVariable?(n.useThemeSuffixedVars&&(i[k]=m),t[l]=`var(${k})`):t[l]=m,t[`.${l}`]={[l]:t[l]}}}!t[".inversed"]&&(t.background||t.color||t.backgroundColor)&&(t[".inversed"]={color:t.background||t.backgroundColor,background:t.color})}if((0,a.isString)(e)&&(0,y.isCSSVar)(e)){const c=n.theme[e.slice(2)];return w(c,s)}return t},j=e=>{const r=(0,S.getActiveConfig)(),o={};for(const s in e){const n=s.slice(0,1);if((0,a.isObjectLike)(e[s])){if(n==="@")continue;n===":"?o[`&${s}`]=j(e[s]):n==="."&&(o[`&${s}`]=j(e[s]))}else o[s]=e[s]}return o},z=(e,r)=>{const o=r.shift();return e[o]?z(e[o],r):e},B=(e,r)=>(0,a.isArray)(r)?z(e,r):(0,a.isString)(r)&&e[r]?e[r]:e,te=(e,r)=>(0,a.isString)(e)&&(0,y.isCSSVar)(e)?w(e.slice(2)):e,se=e=>te(e,se),w=(e,r)=>{const o=(0,S.getActiveConfig)();if((0,a.isString)(e)&&(0,y.isCSSVar)(e)&&(e=w(e.slice(2))),!e||!(0,a.isString)(e)){o.verbose&&console.warn(`${e} - Theme is not a string`);return}const[s,...n]=(0,a.isArray)(e)?e:e.split(" ");let i=o.theme[s];return i&&n.length?i=B(i,n):i&&r&&(i=B(i,r)),j(i)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var O=(r,t)=>{for(var n in t)m(r,n,{get:t[n],enumerable:!0})},R=(r,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of B(t))!C.call(r,e)&&e!==n&&m(r,e,{get:()=>t[e],enumerable:!(i=j(t,e))||i.enumerable});return r};var T=r=>R(m({},"__esModule",{value:!0}),r);var D={};O(D,{resolveColorsInGradient:()=>S,splitTransition:()=>W,transformBackgroundImage:()=>G,transformBorder:()=>z,transformBorderRadius:()=>b,transformBoxShadow:()=>E,transformDuration:()=>K,transformShadow:()=>A,transformSize:()=>h,transformSizeRatio:()=>_,transformTextStroke:()=>V,transformTransition:()=>g,transfromGap:()=>$});module.exports=T(D);var c=require("@symbo.ls/utils"),x=require("../factory.js"),s=require("../system/index.js"),o=require("../utils/index.js");const I=new Set(["to","top","bottom","left","right","center","at","circle","ellipse","closest-side","farthest-side","closest-corner","farthest-corner"]),z=r=>(0,s.resolveBorderValue)(r),V=r=>o.CSS_NATIVE_COLOR_REGEX.test(r)?r:r.split(/\s+/).map(t=>{if(t=t.trim(),!t)return"";if((0,o.isCSSVar)(t))return`var(${t})`;if(/^\d/.test(t)||t.includes("px")||t==="0")return t;const n=(0,s.getColor)(t);return(0,o.isResolvedColor)(n)?n:t}).join(" "),A=(r,t)=>(0,s.getShadow)(r,t),E=(r,t)=>o.CSS_NATIVE_COLOR_REGEX.test(r)?r:(0,o.splitTopLevelCommas)(r).map(n=>(n=n.trim(),n?n.split(/\s+/).map(i=>{if(i=i.trim(),!i)return"";if((0,o.isCSSVar)(i))return`var(${i})`;if(i==="inset"||i==="none")return i;const e=(0,s.getColor)(i);if((0,o.isResolvedColor)(e)){const a=(0,s.getMediaColor)(i,t);return(0,c.isObject)(a)?Object.values(a).filter(p=>p.includes(": "+t))[0]:a}if(/^\d/.test(i)||i==="0"||i.includes("px")||i.slice(-2)==="em")return i;const u=(0,s.getSpacingByKey)(i,"shadow");return u&&u.shadow?u.shadow:i}).join(" "):"")).join(", "),S=(r,t)=>{const n=r.indexOf("(");if(n===-1)return r;const i=r.slice(0,n+1),e=r.slice(n+1,r.lastIndexOf(")")),u=")",p=(0,o.splitTopLevelCommas)(e).map(l=>(l=l.trim(),l.split(/\s+/).map(f=>{if(!f||/^\d/.test(f)||f==="0"||I.has(f)||f==="transparent"||o.CSS_NATIVE_COLOR_REGEX.test(f))return f;const d=(0,s.getColor)(f);return(0,o.isResolvedColor)(d)?d:f}).join(" ")));return i+p.join(", ")+u},G=(r,t)=>{const n=(0,x.getActiveConfig)();return(0,o.splitTopLevelCommas)(r).map(i=>{const e=i.trim();if((0,o.isCSSVar)(e))return`var(${e})`;if(/^var\(/.test(e)||e.includes("url"))return e;if(n.gradient?.[e]){const u=(0,s.getMediaColor)(e,t);if((0,c.isString)(u))return u;if((0,c.isObject)(u)){for(const a in u)if((0,c.isString)(u[a]))return u[a]}return e}return e.includes("gradient")?S(e,t):e.includes("/")||e.startsWith("http")||e.includes(".")&&!(0,o.parseColorToken)(e)?`url(${e})`:e}).join(", ")},$=r=>(0,c.isString)(r)&&r.split(" ").map(t=>(0,s.getSpacingByKey)(t,"gap").gap).join(" "),g=r=>{const t=r.split(" ");return t.length?t.map(n=>(0,o.isCSSVar)(n)?`var(${n})`:n.length<3||n.includes("ms")?(0,s.getTimingByKey)(n).timing||n:(0,s.getTimingFunction)(n)?(0,s.getTimingFunction)(n):n).join(" "):r},K=(r,t,n)=>{if((0,c.isString)(r))return r.split(",").map(i=>(0,s.getTimingByKey)(i).timing||i).join(",")},W=r=>{const t=r.split(",");if(t.length)return t.map(g).join(",")};function h(r,t,n={},i={}){let e=c.exec.call(this,t||n[r]);if(e==null)return;let u;if((0,c.isString)(e)){if(/^(?:env|var)\(/.test(e.trim()))return{[r]:e};if(e.includes("(")){const l=(0,o.getFnPrefixAndValue)(e);u=l[0],e=l[1]}const a=n.scaleBoxSize,p=(0,s.checkIfBoxSize)(r);!a&&p&&!i.ratio&&(e=(0,s.splitSpacedValue)(e))}return i.ratio?(0,s.getSpacingBasedOnRatio)(n,r,e,u):(0,s.getSpacingByKey)(e,r,void 0,u)}const _=(r,t=null,n)=>h(r,t,n,{ratio:!0}),b=(r,t,n,i="borderRadius")=>{if((0,c.isString)(r))return{[i]:r.split(" ").map(e=>{const u=(0,s.getShapeByKey)(e);return u!==void 0?u:(0,s.getSpacingBasedOnRatio)(t,n,e)[n]}).join(" ")}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var g=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var E=(e,r)=>{for(var t in r)g(e,t,{get:r[t],enumerable:!0})},v=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of L(r))!q.call(e,a)&&a!==t&&g(e,a,{get:()=>r[a],enumerable:!(n=I(r,a))||n.enumerable});return e};var A=e=>v(g({},"__esModule",{value:!0}),e);var B={};E(B,{CSS_NAMED_COLOR_HEX:()=>m,CSS_NATIVE_COLOR_REGEX:()=>S,changeLightness:()=>z,colorStringToRgbaArray:()=>h,compositeOverBackdrop:()=>W,contrastRatio:()=>K,getColorShade:()=>M,getRgbTone:()=>Y,hexToRgb:()=>H,hexToRgbArray:()=>x,hexToRgba:()=>j,hslToRgb:()=>k,isCSSVar:()=>C,isResolvedColor:()=>D,linearChannelToSrgb:()=>O,mixTwoColors:()=>F,mixTwoRgb:()=>G,mixTwoRgba:()=>T,oklabToLinearSrgb:()=>_,oklabToOklch:()=>Q,oklchToGamutSafeSrgb:()=>U,oklchToOklab:()=>$,opacify:()=>P,parseColorToken:()=>X,relativeLuminance:()=>p,rgbArrayToHex:()=>y,rgbToHSL:()=>w,rgbToHex:()=>N,splitTopLevelCommas:()=>Z,srgbChannelToLinear:()=>R,srgbToOklab:()=>J,toLinearChannel:()=>u});module.exports=A(B);var s=require("@symbo.ls/utils");const m={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},h=e=>{if(e==="")return[0,0,0,0];if(e.toLowerCase()==="transparent")return[0,0,0,0];const r=m[e.toLowerCase()];if(r&&(e=r),e[0]==="#")return e.length<7&&(e="#"+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+(e.length>4?e[4]+e[4]:"")),[parseInt(e.substr(1,2),16),parseInt(e.substr(3,2),16),parseInt(e.substr(5,2),16),e.length>7?parseInt(e.substr(7,2),16)/255:1];if(e.indexOf("rgb")===-1&&s.document&&s.window){const t=s.document.body.appendChild(s.document.createElement("fictum")),n="rgb(1, 2, 3)";if(t.style.color=n,t.style.color!==n){s.document.body.removeChild(t);return}if(t.style.color=e,t.style.color===n||t.style.color==="")return s.document.body.removeChild(t),[0,0,0,0];e=s.window.getComputedStyle(t).color,s.document.body.removeChild(t)}return e.indexOf("rgb")===0?(e.indexOf("rgba")===-1&&(e=`${e}, 1`),e.match(/[\.\d]+/g).map(t=>+t)):[0,0,0,0]},F=(e,r,t=.5)=>(e=h(e),r=h(r),T(e,r,t)),H=(e,r=1)=>{const[t,n,a]=e.match(/\w\w/g).map(f=>parseInt(f,16));return`rgb(${t},${n},${a})`},x=(e,r=1)=>{const[t,n,a]=e.match(/\w\w/g).map(f=>parseInt(f,16));return[t,n,a]},N=(e,r,t)=>"#"+(1<<24|e<<16|r<<8|t).toString(16).slice(1),y=([e,r,t])=>((1<<24)+(e<<16)+(r<<8)+t).toString(16).slice(1),j=(e,r=1)=>{const[t,n,a]=e.match(/\w\w/g).map(f=>parseInt(f,16));return`rgba(${t},${n},${a},${r})`},G=(e,r,t=.5)=>{const n=[];for(let a=0;a<3;a++)n[a]=~~(e[a]+(r[a]-e[a])*t);return`rgb(${n})`},z=(e,r)=>{const[t,n,a]=r,f=Math.max(0,Math.min(100,a+parseFloat(e)));return[t,n,f]},w=(e,r,t)=>{const n=Math.max(e,r,t),a=n-Math.min(e,r,t),f=1-Math.abs(n+n-a-1),o=a&&(n==e?(r-t)/a:n==r?2+(t-e)/a:4+(e-r)/a);return[60*(o<0?o+6:o),f?a/f:0,(n+n-a)/2]},k=(e,r,t,n=r*Math.min(t,1-t),a=(f,o=(f+e/30)%12)=>t-n*Math.max(Math.min(o-3,9-o,1),-1))=>[a(0),a(8),a(4)],M=(e,r)=>{const t=parseInt(e,16);let n=(t>>16)+r;n>255?n=255:n<0&&(n=0);let a=(t>>8&255)+r;a>255?a=255:a<0&&(a=0);let f=(t&255)+r;return f>255?f=255:f<0&&(f=0),((f|a<<8|n<<16)+16777216).toString(16).slice(1)},T=(e,r,t=.5)=>{const n=[];for(let a=0;a<4;a++){const f=a===3?o=>o:Math.round;n[a]=f(e[a]+(r[a]-e[a])*t)}return`rgba(${n})`},P=(e,r)=>{const t=h(e);if(!t){(0,s.isNotProduction)()&&console.warn(e+" color is not rgba");return}return t[3]=r,`rgba(${t})`},C=e=>e.charCodeAt(0)===45&&e.charCodeAt(1)===45,S=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,V=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,X=e=>{if(!(0,s.isString)(e))return null;if(S.test(e))return{passthrough:e};if(C(e))return{cssVar:e};const r=e.match(V);if(!r)return null;const[,t,n,a]=r,f=n!==void 0?`0.${n}`:void 0,o=a&&a[0]==="="?a.slice(1):a;return{name:t,alpha:f,tone:o}},D=e=>(0,s.isString)(e)&&(e.includes("rgb")||e.includes("var(")||e.includes("#")),Z=e=>{const r=[];let t="",n=0;for(const a of e){if(a==="("?n+=1:a===")"&&n>0&&(n-=1),a===","&&n===0){r.push(t),t="";continue}t+=a}return(t.length||!r.length)&&r.push(t),r},u=e=>(e/=255,e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)),p=e=>.2126*u(e[0])+.7152*u(e[1])+.0722*u(e[2]),K=(e,r)=>{const t=p(e)+.05,n=p(r)+.05;return t>n?t/n:n/t},R=e=>(e/=255,e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)),O=e=>(e<=.0031308?e*12.92:1.055*Math.pow(e,1/2.4)-.055)*255,J=([e,r,t])=>{const[n,a,f]=[e,r,t].map(R),o=.4122214708*n+.5363325363*a+.0514459929*f,i=.2119034982*n+.6806995451*a+.1073969566*f,c=.0883024619*n+.2817188376*a+.6299787005*f,d=Math.cbrt(o),l=Math.cbrt(i),b=Math.cbrt(c);return[.2104542553*d+.793617785*l-.0040720468*b,1.9779984951*d-2.428592205*l+.4505937099*b,.0259040371*d+.7827717662*l-.808675766*b]},_=([e,r,t])=>{const n=e+.3963377774*r+.2158037573*t,a=e-.1055613458*r-.0638541728*t,f=e-.0894841775*r-1.291485548*t,o=n**3,i=a**3,c=f**3;return[4.0767416621*o-3.3077115913*i+.2309699292*c,-1.2684380046*o+2.6097574011*i-.3413193965*c,-.0041960863*o-.7034186147*i+1.707614701*c]},Q=([e,r,t])=>{let n=Math.atan2(t,r)*180/Math.PI;return n<0&&(n+=360),[e,Math.sqrt(r*r+t*t),n]},$=([e,r,t])=>{const n=t*Math.PI/180;return[e,r*Math.cos(n),r*Math.sin(n)]},U=(e,r,t,n=24)=>{const a=i=>_($([e,i,t])),f=i=>i.every(c=>c>=-1e-4&&c<=1.0001);let o=a(r);if(!f(o)){let i=0,c=r;for(let d=0;d<n;d++){const l=(i+c)/2;f(a(l))?i=l:c=l}o=a(i)}return o.map(i=>O(Math.max(0,Math.min(1,i))))},W=(e,r=1,t=[255,255,255])=>r>=1?e:e.map((n,a)=>n*r+t[a]*(1-r)),Y=(e,r)=>{(0,s.isString)(e)&&e.includes("rgb")&&(e=h(e).join(", ")),(0,s.isString)(e)&&(e=e.split(",").map(a=>parseFloat(a.trim()))),(0,s.isNumber)(r)&&(r+="");const t=y(e),n=r.slice(0,1);if(n==="-"||n==="+"){const a=M(t,parseFloat(r));return x(a).join(", ")}else{const[a,f,o]=e,[i,c]=w(a/255,f/255,o/255),d=Math.max(0,Math.min(100,parseFloat(r)))/100;return k(i,c,d).map(b=>Math.round(Math.max(0,Math.min(1,b))*255)).join(", ")}};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var y=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var U=(t,r)=>{for(var n in r)y(t,n,{get:r[n],enumerable:!0})},k=(t,r,n,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of j(r))!O.call(t,o)&&o!==n&&y(t,o,{get:()=>r[o],enumerable:!(e=D(r,o))||e.enumerable});return t};var C=t=>k(y({},"__esModule",{value:!0}),t);var M={};U(M,{getDefaultOrFirstKey:()=>W,getFontFace:()=>E,getFontFaceEach:()=>m,getFontFaceEachString:()=>v,getFontFaceString:()=>K,getFontFormat:()=>S,isGoogleFontsUrl:()=>$,resolveFileUrl:()=>a,setCustomFont:()=>i,setCustomFontMedia:()=>p,setFontImport:()=>d,setInCustomFontMedia:()=>x});module.exports=C(M);const a=(t,r)=>{if(!t||!r)return null;try{return new URL(t),null}catch{}const n=r[t];return n?n.content&&n.content.src:null},W=(t,r)=>{if(t[r])return t[r].value;const n=()=>Object.keys(t).find(o=>o!=="default"&&t[o]&&t[o].value&&!t[o].isSystemFallback);if(t.default){const o=t[t.default];if(o&&o.isSystemFallback){const s=n();if(s)return t[s].value}if(o)return o.value}const e=n()||Object.keys(t).find(o=>o!=="default"&&t[o]&&t[o].value);return e&&t[e]&&t[e].value},S=t=>{if(typeof t!="string"||!t)return null;const r=t.split(/[#?]/)[0].split(".").pop().trim();return["woff2","woff","ttf","otf","eot"].includes(r)?r:null},$=t=>t&&(t.includes("fonts.googleapis.com")||t.includes("fonts.gstatic.com")),d=t=>`@import url('${t}');`,x=t=>`@font-face { ${t} }`,i=(t,r,n,e={})=>{const f=(Array.isArray(r)?r:[r]).filter(c=>typeof c=="string"&&c).map(c=>{const l=S(c),u=l?` format('${l}')`:"";return`url('${c}')${u}`}).join(`,
|
|
2
2
|
`);return`
|
|
3
3
|
font-family: '${t}';
|
|
4
|
-
font-style: ${
|
|
5
|
-
font-weight: ${n};`:""}${
|
|
6
|
-
font-stretch: ${
|
|
7
|
-
font-display: ${
|
|
8
|
-
src: ${
|
|
9
|
-
}`,m=(t,r,n)=>Object.keys(r).map(
|
|
4
|
+
font-style: ${e.fontStyle||"normal"};${n?`
|
|
5
|
+
font-weight: ${n};`:""}${e.fontStretch?`
|
|
6
|
+
font-stretch: ${e.fontStretch};`:""}${e.fontDisplay?`
|
|
7
|
+
font-display: ${e.fontDisplay};`:""}
|
|
8
|
+
src: ${f};`},p=(t,r,n,e)=>`@font-face {${i(t,r,n,e)}
|
|
9
|
+
}`,m=(t,r,n)=>Object.keys(r).map(o=>{const{url:s,fontWeight:f,fontStyle:c,fontDisplay:l,fontStretch:u}=r[o],b=Array.isArray(s)?s.map(F=>a(F,n)||F):a(s,n)||s;return i(t,b,f,{fontStyle:c,fontDisplay:l,fontStretch:u})}),E=t=>Object.keys(t).map(n=>m(n,t[n].value)),v=(t,r,n)=>{if(r&&r.isVariable){const s=a(r.url,n)||r.url;return $(s)?d(s):p(t,s,r.fontWeight,{fontStretch:r.fontStretch,fontDisplay:r.fontDisplay||"swap"})}if(r[0])return m(t,r,n).map(x);const o=Array.isArray(r.url)?r.url.map(s=>a(s,n)||s):a(r.url,n)||r.url;return p(t,o,r.fontWeight,{fontStyle:r.fontStyle,fontDisplay:r.fontDisplay,fontStretch:r.fontStretch})},K=(t,r)=>Object.keys(t).map(e=>v(e,t[e].value,r));
|
package/dist/esm/src/set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getActiveConfig as
|
|
1
|
+
import{getActiveConfig as S,setActiveConfig as $,toCamel as z}from"./factory.js";import{setColor as B,setGradient as K,setFont as U,setFontFamily as C,setTheme as J,setSvgIcon as Q,setSVG as X,applyTypographySequence as Z,applySpacingSequence as G,applyReset as N,applyTimingSequence as ee,applyDocument as te,setShadow as se}from"./system/index.js";import{deepMerge as oe,isObject as k,isArray as q}from"@symbo.ls/utils";import{isDomDocument as j,isHostObject as O,parkHostObject as W,resolveConfigDocument as F}from"./utils/host.js";const y="__smblsThemeRootOwner",b=t=>{const s=t&&t.__prefersListener,e=t&&t.__prefersMq;if(s&&e)try{typeof e.removeEventListener=="function"?e.removeEventListener("change",s):typeof e.removeListener=="function"&&e.removeListener(s)}catch{try{e.removeListener(s)}catch{}}t&&(t.__prefersListener=null,t.__prefersMq=null)},H=(t,s,e)=>{if(!(!t||!s)){b(t),t.__prefersListener=e,t.__prefersMq=s;try{s.addEventListener("change",e)}catch{s.addListener(e)}}},re=(t,s)=>{const e=S(),{cssVars:n}=e,i=s.startsWith("--")?s:`--${s}`;return n[i]=t,t},l=t=>t,I={color:B,gradient:K,font:U,fontFamily:C,fontfamily:C,theme:J,icons:Q,semanticIcons:l,semanticicons:l,svg:X,svgData:l,typography:l,shadow:se,spacing:l,media:l,grid:l,class:l,timing:l,reset:l,unit:l,animation:l,vars:re,sizes:l,shape:l},ne=(t,s,e,n)=>{W(t,e,s);const i={};for(const o of n)t[o]===s&&(t[o]=i);return t.verbose&&console.warn("[scratch] design-system family",e,"resolved to a host object; parked it and allocated a plain bucket"),i},ie=(t,s,e)=>{const n=S(),i=z(t),o=i.toLowerCase(),d=n[i]||n[o]||n[t],r=O(d)?ne(n,d,o,[i,o,t]):d,m=I[i]||I[o];if(m)try{const a=m(s,e);return r&&(r[e]=a),r}catch(a){n.verbose&&console.warn("Error setting",o,"value",s,e,a)}if(!m){const a=r||(n[o]={});return a[e]=s,a}n.verbose&&console.warn("Can not find",o,"method in scratch")},ce=(t,s)=>{const e=S(),n=t.toLowerCase();return O(s)?(W(e,n,s),e.verbose&&console.warn("[scratch] ignoring host object passed as the",n,"design-system family"),e[n]||e[t]):s==null?(e.verbose&&console.warn("[scratch] skipping empty design-system family",n),e[n]||e[t]):(Object.keys(s).sort((o,d)=>{const r=k(s[o])||q(s[o])?1:0,m=k(s[d])||q(s[d])?1:0;return r-m}).forEach(o=>{try{return ie(n,s[o],o)}catch(d){e.verbose&&console.warn("Error setting",n,"value",s[o],o,d)}}),e[n]||e[t])},ge=(t,s)=>{const e=s||S();e.globalTheme=t;const i=F(e)||(typeof document<"u"?document:null),o=i&&i.defaultView||(typeof window<"u"?window:null);if(i){const r=e.themeRoot||i.documentElement,m=t&&t!=="auto";if(r[y]=e,m)b(e),r.setAttribute("data-theme",t),e.resolvedTheme=t,t==="dark"||t==="light"?r.style.colorScheme=t:r.style.colorScheme="light dark";else if(o&&o.matchMedia){const a=g=>{const v=g.matches?"dark":"light";r.setAttribute("data-theme",v),e.resolvedTheme=v},u=o.matchMedia("(prefers-color-scheme: dark)");a(u),r.style.colorScheme="light dark",H(e,u,a)}else b(e),r.setAttribute("data-theme","light"),e.resolvedTheme="light",r.style.colorScheme="light"}const d=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const r in e.cssVars)r.startsWith(d)&&delete e.cssVars[r];for(const r in e.cssMediaVars)delete e.cssMediaVars[r];if(i&&e.cssVars){const r=e.scopeSelector||":root",m=i.styleSheets;for(let a=0;a<m.length;a++)try{const u=m[a].cssRules;for(let g=0;g<u.length;g++)if(u[g].selectorText===r){for(const v in e.cssVars)u[g].style.setProperty(v,e.cssVars[v]);return e}}catch{}}return e},ae={},pe=(t,s=ae)=>{let e=s.config||S();const{version:n,verbose:i,useVariable:o,useReset:d,useSvgSprite:r,useFontImport:m,useIconSprite:a,globalTheme:u,themeRoot:g,useDocumentTheme:v,useDefaultConfig:E,semanticIcons:V,hoverMedia:x,files:D,assets:R,...h}=t;s.newConfig&&(e=$(s.newConfig)),j(h.document)&&(e.__domDocument=h.document,delete h.document),j(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),D!==void 0&&(e.files=D),R!==void 0&&(e.assets=R),i!==void 0&&(e.verbose=i),o!==void 0&&(e.useVariable=o),d!==void 0&&(e.useReset=d),m!==void 0&&(e.useFontImport=m),r!==void 0&&(e.useSvgSprite=r),a!==void 0&&(e.useIconSprite=a),v!==void 0&&(e.useDocumentTheme=v),u!==void 0&&(e.globalTheme=u),g!==void 0&&(e.themeRoot=g),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),E!==void 0&&(e.useDefaultConfig=E),V!==void 0&&(e.semanticIcons=V),x!==void 0&&(e.hoverMedia=x),e.verbose&&console.log(e);const _=F(e)||(typeof document<"u"?document:null),T=_&&_.defaultView||(typeof window<"u"?window:null),f=_&&(e.themeRoot||_.documentElement);if(f&&typeof f.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")b(e),f.setAttribute("data-theme",e.globalTheme),e.resolvedTheme=e.globalTheme,f[y]=e,e.globalTheme==="dark"||e.globalTheme==="light"?f.style.colorScheme=e.globalTheme:f.style.colorScheme="light dark";else if(f[y]&&f[y]!==e&&f.hasAttribute("data-theme"))b(e),e.resolvedTheme=f.getAttribute("data-theme");else if(T&&T.matchMedia){const p=Y=>{const P=Y.matches?"dark":"light";f.setAttribute("data-theme",P),e.resolvedTheme=P},M=T.matchMedia("(prefers-color-scheme: dark)");p(M),f.style.colorScheme="light dark",f[y]=e,H(e,M,p)}else b(e),f.setAttribute("data-theme","light"),e.resolvedTheme="light",f.style.colorScheme="light",f[y]=e;e.__svgCache||(e.__svgCache={});const w=Object.keys(h).filter(c=>!c.startsWith("__")),L=new Set(w);if(w.forEach(c=>{const p=c.toLowerCase();p!==c&&L.has(p)&&oe(h[p],h[c])}),w.map(c=>{const p=c.toLowerCase();if(!(p!==c&&L.has(p)))return ce(c,h[c])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),h.typography)try{Z()}catch(c){e.verbose&&console.warn("Error applying typography sequence",c)}if(h.spacing)try{G()}catch(c){e.verbose&&console.warn("Error applying spacing sequence",c)}if(h.timing)try{ee()}catch(c){e.verbose&&console.warn("Error applying timing sequence",c)}te();const A=N();return A&&(e.reset=A),e};export{I as VALUE_TRANSFORMERS,ge as changeGlobalTheme,pe as set,ce as setEach,ie as setValue};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getColor as u}from"./color.js";import{getSpacingByKey as f}from"./spacing.js";import{isResolvedColor as c,isCSSVar as l,CSS_NATIVE_COLOR_REGEX as m}from"../utils/color.js";const a=new Set(["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset","initial"]),S=i=>a.has(i),E=(i,d,n)=>{const t=i+"";if(m.test(t))return t;const e=t.trim();return e==="none"||e==="0"||e==="initial"||e==="inherit"||e==="unset"?t:t.split(/\s+/).map(r=>{if(r=r.trim(),!r)return"";if(l(r))return`var(${r})`;if(S(r)||/^\d/.test(r)||r==="0")return r;const s=u(r,d);if(c(s))return s;n&&n(r);const o=f(r,"border");return o&&o.border?o.border:r}).join(" ")};export{E as resolveBorderValue};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as
|
|
1
|
+
import{isObject as V,isArray as S,isString as m}from"@symbo.ls/utils";import{getActiveConfig as M}from"../factory.js";import{colorStringToRgbaArray as E,getRgbTone as C,isCSSVar as x,parseColorToken as O}from"../utils/index.js";const j={light:"(prefers-color-scheme: light)",dark:"(prefers-color-scheme: dark)"},y=new Set,_=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]),D=new Set,v=e=>{if(!e)return!1;const{color:t,gradient:l}=e;return!!(V(t)&&Object.keys(t).length||V(l)&&Object.keys(l).length)},L=(e,t,l)=>{const r=m(t)?t.toLowerCase():"";if(!_.has(r)||!v(l))return e;if(!D.has(r)){D.add(r);const i=l&&l.name?` (design system \`${l.name}\`)`:"";console.warn(`[scratch] color \`${e}\` is a CSS named colour that is not in the palette${i}. Dropped rather than emitted as a raw browser colour, which renders theme-blind and can be unreadable ("looks designed", so it ships unnoticed). Define it in designSystem/color.js or use a palette token.`)}},R=(e,t,l)=>{const r=l||M();if(!m(e)){r.verbose&&console.warn(e,"- type for color is not valid");return}if(x(e))return`var(${e})`;t&&e[t]&&(e=e[t]);let i,u,s;if(S(e))[i,u,s]=e;else{const a=O(e);if(!a){const{color:f,gradient:w}=r;let b=w[e]||f[e];return b?(t&&b[t]&&(b=b[t]),r.useVariable?`var(${b.var})`:b.value):e}if(a.passthrough)return a.passthrough;if(a.cssVar)return`var(${a.cssVar})`;i=a.name,u=a.alpha,s=a.tone}const{color:p,gradient:c}=r;let n=p[i]||c[i];if(!n)return L(e,i,r);if(t)if(n[t]!==void 0)n=n[t];else if(S(n)){const a=t.charCodeAt(0)===64?t.slice(1):t;a==="dark"?n=n[1]!==void 0?n[1]:n[0]:(a!=="light"&&r.verbose&&console.warn(e," - array-form color tokens only support light/dark; falling back to the light slot for scheme",t),n=n[0])}else r.verbose&&console.warn(e," - does not have ",t);if(m(n)){if(y.has(i))return n;y.add(i);try{return R(n,null,l)}finally{y.delete(i)}}let g=n.rgb;if(!g){const a=r.useVariable?`var(${n.var})`:n.value;if((u||s)&&a){const f=u!==void 0?u:1;if(!s)return`rgb(from ${a} r g b / ${f})`;if(s.charCodeAt(0)===43||s.charCodeAt(0)===45){const b=parseFloat(s),d=b<0?"-":"+",o=Math.abs(b);return`rgb(from ${a} calc(r ${d} ${o}) calc(g ${d} ${o}) calc(b ${d} ${o}) / ${f})`}return`hsl(from ${a} h s ${s}% / ${f})`}return a}return s&&!n[s]&&(g=C(g,s),n[s]={rgb:g,var:`${n.var}-${s}`}),n[s]&&(g=n[s].rgb),u?`rgba(${g}, ${u})`:s?`rgba(${g}, 1)`:r.useVariable?`var(${n.var})`:`rgb(${g})`},P=e=>{const t=E(e);return!t||t.length<3||t[0]===0&&t[1]===0&&t[2]===0&&t[3]===0&&e.toLowerCase()!=="transparent"?null:{rgb:[t[0],t[1],t[2]],alpha:t[3]!==void 0?t[3]:1}},N=(e,t)=>{if(!t)return e;let l=e.rgb;if(t.tone){const i=C(l,t.tone);l=m(i)?i.split(",").map(u=>parseFloat(u.trim())):i}const r=t.alpha!==void 0?parseFloat(t.alpha):e.alpha;return{rgb:l,alpha:r}},W=(e,t,l)=>{const r=t||M();if(!m(e))return null;const i=O(e);if(i){if(i.passthrough){const f=E(i.passthrough);return f&&f.length>=3?{rgb:[f[0],f[1],f[2]],alpha:f[3]!==void 0?f[3]:1}:null}if(i.cssVar)return null}const u=i?i.name:e,{color:s,gradient:p}=r;let c=s[u]||p[u];if(!c)return P(e);if(m(c)){let f;if(y.has(u))f=P(c);else{y.add(u);try{f=W(c,r,l)}finally{y.delete(u)}}return f?N(f,i):null}if(c.rgb===void 0&&V(c)){const f=`@${l||"light"}`;c=c[f]!==void 0?c[f]:c["@light"]}if(!c||c.rgb===void 0)return null;let n=c.rgb;i&&i.tone&&(n=C(n,i.tone));const g=m(n)?n.split(",").map(f=>parseFloat(f.trim())):n,a=i&&i.alpha!==void 0?parseFloat(i.alpha):c.alpha!==void 0?c.alpha:1;return{rgb:g,alpha:a}},B=(e,t,l)=>{const r=l||M();if(t||(t=r.globalTheme==="auto"?null:r.globalTheme),!m(e)){r.verbose&&console.warn(e,"- type for color is not valid");return}if(x(e))return`var(${e})`;let i,u,s;if(S(e))i=e[0];else{const a=O(e);if(a){if(a.passthrough)return a.passthrough;if(a.cssVar)return`var(${a.cssVar})`;i=a.name,u=a.alpha,s=a.tone}else i=e}const{color:p,gradient:c}=r,n=p[i]||c[i],g=V(n);if(g&&n.value)return R(e,`@${t}`,l);if(g){if(r.useVariable&&n.var)return u||s?R(e,null,l):`var(${n.var})`;if(t)return R(e,`@${t}`,l);{const a={},f=r.scopeSelector||":root",w=f===":root"?":root:not([data-theme])":`:root:not([data-theme]) ${f}:not([data-theme])`;for(const b in n){if(b.charCodeAt(0)!==64)continue;const d=b.slice(1),o=R(e,b,l);if(o!==void 0&&(a[`[data-theme="${d}"] &`]=o,d==="light"||d==="dark")){const h=r.media&&r.media[d]||j[d];if(!h)continue;const $="@media "+(h==="print"?`${h}`:`screen and ${h}`);a[$]={[`${w} &`]:o}}}return a}}else return L(e,i,r)},T=(e,t,l,r)=>{const u=`--${r.varPrefix?r.varPrefix+"-":""}${t}-${l}`;let s;const p={};for(const c in e){if(c.charCodeAt(0)!==64)continue;const n=c.slice(1),g=e[c],a=g&&(g.value||g);!a||typeof a!="string"||(p[n]=a,(n==="light"||s===void 0)&&(s=a))}if(s!==void 0){r.cssVars[u]=s,r.cssMediaVars||(r.cssMediaVars={});for(const c in p){const n=`[data-theme="${c}"]`;if(r.cssMediaVars[n]||(r.cssMediaVars[n]={}),r.cssMediaVars[n][u]=p[c],c==="light"||c==="dark"){const g=`@media (prefers-color-scheme: ${c})`;r.cssMediaVars[g]||(r.cssMediaVars[g]={}),r.cssMediaVars[g][u]=p[c]}}return e.var=u,u}},q=(e,t,l)=>{const r=M();if(V(e)&&e.value!==void 0&&(e.rgb!==void 0||e.var!==void 0))return r.useVariable&&e.var&&(r.cssVars[e.var]=e.value),e;if(m(e)&&x(e)){const d=e.slice(2);if(e=R(d),!(e.includes("rgb")||e.includes("var")||e.includes("#"))){const o=d.split(" ");let h=r.color[o[0]];if(h&&!h.value&&!h.rgb&&(m(h)||S(h)||V(h))&&!y.has(o[0])){y.add(o[0]);try{r.color[o[0]]=q(h,o[0])}finally{y.delete(o[0])}h=r.color[o[0]]}if(h&&h.value){let $=h.rgb;const A=o[1]!==void 0?o[1]:"1",k=o[2];k&&($=C($,k)),e=`rgba(${$}, ${A})`}else{const $=o[2],A=o[1]!==void 0?o[1]:"1";if($)try{const k=E(o[0]);k&&k.length>=3?e=`rgba(${C(k.slice(0,3).join(", "),$)}, ${A})`:e=o[0]}catch{e=o[0]}else e=o[0]}}}if(S(e)&&(e={"@light":e[0],"@dark":e[1]!==void 0?e[1]:e[0]}),V(e)){const d={};for(const o in e)o!=="var"&&(d[o]=q(e[o],t,o.slice(0,1)==="@"?o.slice(1):o));return r.useVariable&&T(d,"color",t,r),d}const u=`--${r.varPrefix?r.varPrefix+"-":""}color-${t}`+(l?`-${l}`:"");let s=e.value||e;if(m(s)&&!s.includes("(")&&!s.startsWith("#")){const d=O(s);if(d&&d.name&&!d.passthrough&&!d.cssVar){const o=r.color[d.name];if(o&&!o.value&&!o.rgb&&(m(o)||S(o)||V(o))&&!y.has(d.name)){y.add(d.name);try{r.color[d.name]=q(o,d.name)}finally{y.delete(d.name)}}const h=r.color[d.name];if(h&&h.rgb){let $=h.rgb;d.tone&&($=C($,d.tone));const A=d.alpha!==void 0?parseFloat(d.alpha):h.alpha!==void 0?h.alpha:1;s=`rgba(${$}, ${A})`}}}const p=E(s),[c,n,g,a=1]=p,f=parseFloat(a.toFixed(2)),w=`${c}, ${n}, ${g}`,b=`rgba(${w}, ${f})`;return r.useVariable&&(r.cssVars[u]=b),{var:u,rgb:w,alpha:f,value:b}},z=(e,t,l)=>{const r=M();if(V(e)&&e.value!==void 0&&e.var!==void 0)return r.useVariable&&(r.cssVars[e.var]=e.value),e;if(m(e)&&x(e)&&(e=R(e.slice(2))),S(e)&&(e={"@light":e[0],"@dark":e[1]!==void 0?e[1]:e[0]}),V(e)){const s={};for(const p in e)p!=="var"&&(s[p]=z(e[p],t,p.slice(0,1)==="@"?p.slice(1):p));return r.useVariable&&T(s,"gradient",t,r),s}const u=`--${r.varPrefix?r.varPrefix+"-":""}gradient-${t}`+(l?`-${l}`:"");return r.useVariable&&(r.cssVars[u]=e.value||e),{var:u,value:e.value||e}};export{j as STANDARD_SCHEME_QUERIES,R as getColor,B as getMediaColor,W as resolveColorRgb,T as setAdaptiveSchemeVar,q as setColor,z as setGradient};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as
|
|
1
|
+
import{isObject as a,isArray as m}from"@symbo.ls/utils";import{arrayzeValue as y}from"@symbo.ls/utils";import{getActiveConfig as f}from"../factory.js";import{getDefaultOrFirstKey as p,getFontFaceEach as S,isGoogleFontsUrl as g,setCustomFontMedia as l,setFontImport as O,resolveFileUrl as F}from"../utils/index.js";const D=(t,o)=>{const r=f(),n=`--font-${o}`;if(!t||m(t)&&!t[0])return;let s;if(t.isVariable){const e=F(t.url,r.files)||t.url;g(e)?s=O(e):s=l(o,e,t.fontWeight,{fontStretch:t.fontStretch,fontDisplay:t.fontDisplay||"swap"})}else if(t[0])s=S(o,t,r.files);else{const e=Array.isArray(t.url)?t.url.map(i=>F(i,r.files)||i):F(t.url,r.files)||t.url;s=l(o,e,t.fontWeight,{fontStyle:t.fontStyle,fontDisplay:t.fontDisplay,fontStretch:t.fontStretch})}return{var:n,value:t,fontFace:s}},N=(t,o)=>{const r=f(),{fontFamily:n}=r;return p(o||n,t)},b=(t,o)=>{const r=f(),{fontFamily:n,fontFamilyTypes:s}=r;let{value:e,type:i}=t;t.isDefault&&(!t.isSystemFallback||!n.default)&&(n.default=o),a(e)&&(e=y(e));const c=`--font-family-${o}`,u=`${e.join(", ")}, ${s[i]}`;return{var:c,value:u,arr:e,type:i,isSystemFallback:!!t.isSystemFallback}};export{N as getFontFamily,D as setFont,b as setFontFamily};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./color.js";export*from"./ink.js";export*from"./theme.js";export*from"./font.js";export*from"./typography.js";export*from"./spacing.js";export*from"./shape.js";export*from"./shadow.js";export*from"./timing.js";export*from"./document.js";export*from"./svg.js";export*from"./reset.js";
|
|
1
|
+
export*from"./color.js";export*from"./ink.js";export*from"./theme.js";export*from"./font.js";export*from"./typography.js";export*from"./spacing.js";export*from"./shape.js";export*from"./shadow.js";export*from"./border.js";export*from"./timing.js";export*from"./document.js";export*from"./svg.js";export*from"./reset.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{deepMerge as y,
|
|
1
|
+
import{deepMerge as y,isObject as D,merge as T,overwriteDeep as w}from"@symbo.ls/utils";import{getActiveConfig as x}from"../factory.js";import{getMediaTheme as l}from"./theme.js";const k=(u={})=>{const o=x(),e=o.typography||{},c=o.document||{},n=D(o.reset)?o.reset:o.reset={};if(n[":root"]){const i=n,t=e.templates||{};i.body={...o.useDocumentTheme?l("document"):{},...t.body},i.h1=t.h1,i.h2=t.h2,i.h3=t.h3,i.h4=t.h4,i.h5=t.h5,i.h6=t.h6}const{body:h,...f}=e.templates||{},m=o.useDocumentTheme?l("document"):{};if(n.html&&w(n.html,m),e.unit){const i=o.media||{};for(const t in e){if(t.charAt(0)!=="@")continue;const r=e[t];if(!r||r.unit===e.unit||!r.unit)continue;const d=r.unit,p=r.base||e.base,b=r.browserDefault||e.browserDefault,g=t.slice(1),s=i[g];if(!s)continue;const a="@media "+(s==="print"?s:"screen and "+s);n[a]||(n[a]={}),n[a].html||(n[a].html={}),n[a].html.fontSize=p/b+d}}return y(T(n,u),{html:{position:"absolute",width:"100%",height:"100%",top:"0",left:"0",margin:"0",WebkitFontSmoothing:"subpixel-antialiased",scrollBehavior:"smooth",...m,fontSize:e.unit?e.base/e.browserDefault+e.unit:e.browserDefault+"px",fontFamily:c.fontFamily,lineHeight:c.lineHeight},body:{boxSizing:"border-box",height:"100%",margin:0,fontFamily:c.fontFamily,fontSize:e.unit?"1"+o.unit.default:e.base/e.browserDefault+o.unit.default,...f,...h},a:{color:"currentColor"},button:{color:"inherit",font:"inherit",background:"transparent",border:"none",cursor:"pointer",appearance:"none",WebkitAppearance:"none"},"input, select, textarea":{color:"inherit",font:"inherit"},fieldset:{border:0,padding:0,margin:0}})};export{k as applyReset};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getActiveConfig as
|
|
1
|
+
import{getActiveConfig as S}from"../factory.js";import{getColor as O,setAdaptiveSchemeVar as h}from"./color.js";import{getSpacingByKey as g}from"./spacing.js";import{isResolvedColor as j,isCSSVar as l,splitTopLevelCommas as A,CSS_NATIVE_COLOR_REGEX as C}from"../utils/color.js";import{isObject as w,isString as p,isArray as b}from"@symbo.ls/utils";const $=(r,i,n)=>!p(r)||C.test(r)?r:A(r).map(f=>(f=f.trim(),f.split(/\s+/).map(t=>{if(t=t.trim(),!t)return"";if(t.startsWith("--"))return`var(${t})`;const s=O(t,i);if(j(s))return s;if(/^\d/.test(t)||t==="0"||t.includes("px")||t.slice(-2)==="em"||t==="inset"||t==="none")return t;n&&n(t);const e=g(t,"shadow");return e&&e.shadow?e.shadow:t}).join(" "))).join(", "),m=(r,i,n,f)=>{const t=S();if(b(r)){const o={"@light":m(r[0],i,"light"),"@dark":m(r[1],i,"dark")};return t.useVariable&&h(o,"shadow",i,t),o}if(w(r)){const o={};for(const c in r)o[c]=m(r[c],i,c.startsWith("@")?c.slice(1):c);return t.useVariable&&h(o,"shadow",i,t),o}p(r)&&!C.test(r)&&(r=$(r));const e=`--${t.varPrefix?t.varPrefix+"-":""}shadow-${i}`+(n?`-${n}`:"");return t.useVariable&&(t.cssVars[e]=r),{var:e,value:r}},I=(r,i)=>{const n=S();if(i||(i=n.globalTheme==="auto"?null:n.globalTheme),!p(r)){n.verbose&&console.warn(r,"- type for color is not valid");return}if(l(r))return`var(${r})`;const[f]=b(r)?r:r.split(" "),s=n.shadow[f],e=w(s);if(!s)return n.verbose&&console.warn("Can't find color ",f),r;if(i){const o=s["@"+i]||s[i];if(o)return o.value!==void 0?o.value:o;n.verbose&&console.warn(r," - does not have ",i)}if(e&&s.value)return s.value;if(e){const o={};for(const c in s){if(c.charCodeAt(0)!==64)continue;const a=n.media[c.slice(1)];if(!a)continue;const V="@media "+(a==="print"?`${a}`:`screen and ${a}`),d=s[c],u=d&&(d.value!==void 0?d.value:d);u!==void 0&&(o[V]=u)}return o}return n.verbose&&console.warn("Can't find color",r),r};export{I as getShadow,$ as resolveShadowValue,m as setShadow};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getColor as
|
|
1
|
+
import{getColor as R}from"./color.js";import{resolveShadowValue as E}from"./shadow.js";import{resolveBorderValue as k}from"./border.js";import{getActiveConfig as y}from"../factory.js";import{isCSSVar as O,parseColorToken as Z}from"../utils/color.js";import{isObject as T,isString as b,isObjectLike as S,isArray as P,isLoudDevRuntime as F}from"@symbo.ls/utils";const J=new Set(["black","white","red","green","blue","yellow","orange","purple","pink","brown","gray","grey","cyan","magenta","lime","olive","navy","teal","aqua","maroon","silver","fuchsia","transparent","currentColor","currentcolor","inherit","initial","unset","none","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","rebeccapurple"]),q=["color","Color","background","Background","fill","Fill","stroke","Stroke"],Q=e=>{for(let r=0;r<q.length;r++)if(e.includes(q[r]))return!0;return!1},X={boxShadow:E,textShadow:E,border:k,borderTop:k,borderRight:k,borderBottom:k,borderLeft:k,outline:k,columnRule:k},Y=e=>{if(!e)return!1;const r=Z(e);return!r||!r.name||r.passthrough||r.cssVar?!1:r.alpha!==void 0||r.tone!==void 0},_=new Set,I=(e,r,o,s,n,i)=>{if(!F())return;const t=`${e}::${r}::${o||""}::${s}`;_.has(t)||(_.add(t),console.warn(`[smbls/scratch] theme param "${r}" on "${e}"`+(o?` (${o})`:"")+` did not fully resolve: "${s}" -> "${n}" still contains the unresolved token "${i}". This is not valid CSS \u2014 the browser will drop the whole declaration. Register "${i}" as a design-system color token or fix the typo.`))},L=(e,r,o,s)=>{const n=X[r];if(!n)return R(o,s);let i=null;const t=n(o,s,a=>{!i&&Y(a)&&(i=a)});return i&&I(e,r,s,o,t,i),t},V=e=>{const r={},{state:o,media:s,helpers:n,...i}=e;return Object.keys(i).map(a=>{const c=["color","Color","background","border"].some(u=>a.includes(u));return r[a]=c?R(e[a]):e[a]}),r},$=e=>(e.value||(e.value=V(e)),e.value),N=(e,r)=>{const o=y();if(o.useVariable)return v(e,r);const s=o.theme;if(b(e)){const[n,i]=e.split(" "),t=s[n];if(t){if(!i&&!r)return $(t);e=[n,i||r]}}if(S(e)&&e[1]){const n=e[0],i=e[1],{helpers:t,media:a,state:l}=s[n];if(a&&a[i])return $(a[i]);if(t&&t[i])return $(t[i]);if(l&&l[i])return $(l[i])}else if(T(e))return V(e)},K=(e,r,o)=>{if(T(r))e.variants.inverse.value=V(r);else if(r===!0){const{color:s,background:n}=o;e.variants.inverse={value:{color:n,background:s}}}},G=(e,r,o,s)=>{const n=N(o);s[`&:${r}`]=n,T(o)&&!o.value&&(o.value=n)},H=(e,r)=>{const{state:o}=e;return o?(Object.keys(o).map(n=>{const i=o[n];return G(e,n,i,r),e}),e):void 0},ee=(e,r,o,s)=>{const n=N(o);s[`@media (prefers-color-scheme: ${r})`]=n,T(o)&&!o.value&&(o.value=n)},D=(e,r)=>{const{media:o}=e;return o?(Object.keys(o).map(n=>{const i=o[n];return(n==="dark"||n==="light")&&ee(e,n,i,r),n==="inverse"&&K(e,i,r),e}),e):void 0},z=(e,r)=>{const o=y(),{helpers:s}=e;return s?(Object.keys(s).map(i=>{const t=s[i];return b(t)?s[i]=o.theme[t]:$(s[i]),e}),e):void 0},ae=(e,r)=>{const o=y();if(o.useVariable)return B(e,r);const{state:s,media:n,helpers:i}=e,t=V(e,r),l=`--${o.varPrefix?o.varPrefix+"-":""}theme-${r}`;return H(e,t),D(e,t),z(e,t),{var:l,value:t,state:s,media:n,helpers:i}},ue={"@":(e,r)=>D(e,r),":":(e,r)=>H(e,r),".":(e,r)=>z(e,r)},j=(e,r,o)=>{const{cssVars:s}=o;o.cssMediaVars||(o.cssMediaVars={});const n=o.cssMediaVars,i=o.globalTheme!==void 0?o.globalTheme:"auto",t={},a=new Set;for(const c in e)if(e[c])for(const u of Object.keys(e[c]))a.add(u);const l=new Set;for(const c of a){const u=c.slice(0,1);if(!(u==="@"||u==="."||u===":")&&Q(c))for(const g in e){if(l.has(g))continue;const m=e[g]?.[c];if(m===void 0)continue;const d=R(m,`@${g}`);d!==void 0&&b(d)&&/^[a-z][a-zA-Z]+$/.test(d)&&!J.has(d)&&l.add(g)}}for(const c of a){const u=c.slice(0,1),g=Object.values(e).some(m=>S(m?.[c]));if(u==="."&&g){const m=c.slice(1),d={};for(const h in e)S(e[h]?.[c])&&(d[h]=e[h][c]);t[c]=j(d,`${r}-${m}`,o)}else if(u===":"&&g){const m=c.replace(/^:+/,""),d={};for(const h in e)S(e[h]?.[c])&&(d[h]=e[h][c]);t[c]=j(d,`${r}-${m}`,o)}else if(u!=="@"&&u!=="."&&u!==":"){const d=`--${o.varPrefix?o.varPrefix+"-":""}theme-${r}-${c}`,h=i&&i!=="auto"?String(i).replace(/^'|'$/g,""):null;let p;for(const f in e){if(l.has(f))continue;const A=e[f]?.[c];if(A===void 0)continue;const w=L(r,c,A,`@${f}`);if(w===void 0)continue;(h&&f===h||!h&&(f==="light"||p===void 0))&&(p=w);const C=`[data-theme="${f}"]`;if(n[C]||(n[C]={}),n[C][d]=w,f==="dark"||f==="light"){const M=`@media (prefers-color-scheme: ${f})`;n[M]||(n[M]={}),n[M][d]=w}}p!==void 0&&(s[d]=p),t[c]=`var(${d})`,t[`.${c}`]={[c]:t[c]}}}return(t.background||t.color||t.backgroundColor)&&(t[".inversed"]={color:t.background||t.backgroundColor,background:t.color}),t},B=(e,r,o,s)=>{const n=y(),{cssVars:i}=n,t={value:e},a=!o&&!s;if(S(e)){if(a&&n.useVariable){const l={};for(const c in e)c.startsWith("@")&&S(e[c])&&(l[c.slice(1)]=e[c]);if(Object.keys(l).length){const c=j(l,r,n);Object.assign(t,c)}}for(const l in e){const c=l.slice(0,1),u=e[l];if(c==="@"||c===":"||c==="."){const g=c==="@"&&l;t[l]=B(u,r,l,s||g)}else if(!a){const g=L(r,l,u,s),m=[...new Set([s,o].filter(f=>f).map(f=>f.slice(1)))],d=m.length?"-"+m.join("-"):"",p=`--${n.varPrefix?n.varPrefix+"-":""}theme-${r}${d}-${l}`;n.useVariable?(n.useThemeSuffixedVars&&(i[p]=g),t[l]=`var(${p})`):t[l]=g,t[`.${l}`]={[l]:t[l]}}}!t[".inversed"]&&(t.background||t.color||t.backgroundColor)&&(t[".inversed"]={color:t.background||t.backgroundColor,background:t.color})}if(b(e)&&O(e)){const c=n.theme[e.slice(2)];return v(c,s)}return t},x=e=>{const r=y(),o={};for(const s in e){const n=s.slice(0,1);if(S(e[s])){if(n==="@")continue;n===":"?o[`&${s}`]=x(e[s]):n==="."&&(o[`&${s}`]=x(e[s]))}else o[s]=e[s]}return o},U=(e,r)=>{const o=r.shift();return e[o]?U(e[o],r):e},W=(e,r)=>P(r)?U(e,r):b(r)&&e[r]?e[r]:e,re=(e,r)=>b(e)&&O(e)?v(e.slice(2)):e,oe=e=>re(e,oe),v=(e,r)=>{const o=y();if(b(e)&&O(e)&&(e=v(e.slice(2))),!e||!b(e)){o.verbose&&console.warn(`${e} - Theme is not a string`);return}const[s,...n]=P(e)?e:e.split(" ");let i=o.theme[s];return i&&n.length?i=W(i,n):i&&r&&(i=W(i,r)),x(i)};export{v as getMediaTheme,N as getTheme,B as setMediaTheme,ae as setTheme};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isString as
|
|
1
|
+
import{isString as c,isObject as h,exec as R}from"@symbo.ls/utils";import{getActiveConfig as T}from"../factory.js";import{getSpacingByKey as p,getColor as m,getShadow as I,getShapeByKey as z,getMediaColor as j,getTimingByKey as B,getTimingFunction as C,getSpacingBasedOnRatio as O,checkIfBoxSize as V,splitSpacedValue as A,resolveBorderValue as E}from"../system/index.js";import{getFnPrefixAndValue as G,isResolvedColor as d,isCSSVar as l,CSS_NATIVE_COLOR_REGEX as x,splitTopLevelCommas as S,parseColorToken as $}from"../utils/index.js";const K=new Set(["to","top","bottom","left","right","center","at","circle","ellipse","closest-side","farthest-side","closest-corner","farthest-corner"]),L=r=>E(r),P=r=>x.test(r)?r:r.split(/\s+/).map(e=>{if(e=e.trim(),!e)return"";if(l(e))return`var(${e})`;if(/^\d/.test(e)||e.includes("px")||e==="0")return e;const n=m(e);return d(n)?n:e}).join(" "),M=(r,e)=>I(r,e),X=(r,e)=>x.test(r)?r:S(r).map(n=>(n=n.trim(),n?n.split(/\s+/).map(i=>{if(i=i.trim(),!i)return"";if(l(i))return`var(${i})`;if(i==="inset"||i==="none")return i;const t=m(i);if(d(t)){const u=j(i,e);return h(u)?Object.values(u).filter(a=>a.includes(": "+e))[0]:u}if(/^\d/.test(i)||i==="0"||i.includes("px")||i.slice(-2)==="em")return i;const s=p(i,"shadow");return s&&s.shadow?s.shadow:i}).join(" "):"")).join(", "),W=(r,e)=>{const n=r.indexOf("(");if(n===-1)return r;const i=r.slice(0,n+1),t=r.slice(n+1,r.lastIndexOf(")")),s=")",a=S(t).map(f=>(f=f.trim(),f.split(/\s+/).map(o=>{if(!o||/^\d/.test(o)||o==="0"||K.has(o)||o==="transparent"||x.test(o))return o;const g=m(o);return d(g)?g:o}).join(" ")));return i+a.join(", ")+s},Y=(r,e)=>{const n=T();return S(r).map(i=>{const t=i.trim();if(l(t))return`var(${t})`;if(/^var\(/.test(t)||t.includes("url"))return t;if(n.gradient?.[t]){const s=j(t,e);if(c(s))return s;if(h(s)){for(const u in s)if(c(s[u]))return s[u]}return t}return t.includes("gradient")?W(t,e):t.includes("/")||t.startsWith("http")||t.includes(".")&&!$(t)?`url(${t})`:t}).join(", ")},H=r=>c(r)&&r.split(" ").map(e=>p(e,"gap").gap).join(" "),_=r=>{const e=r.split(" ");return e.length?e.map(n=>l(n)?`var(${n})`:n.length<3||n.includes("ms")?B(n).timing||n:C(n)?C(n):n).join(" "):r},J=(r,e,n)=>{if(c(r))return r.split(",").map(i=>B(i).timing||i).join(",")},Q=r=>{const e=r.split(",");if(e.length)return e.map(_).join(",")};function b(r,e,n={},i={}){let t=R.call(this,e||n[r]);if(t==null)return;let s;if(c(t)){if(/^(?:env|var)\(/.test(t.trim()))return{[r]:t};if(t.includes("(")){const f=G(t);s=f[0],t=f[1]}const u=n.scaleBoxSize,a=V(r);!u&&a&&!i.ratio&&(t=A(t))}return i.ratio?O(n,r,t,s):p(t,r,void 0,s)}const U=(r,e=null,n)=>b(r,e,n,{ratio:!0}),Z=(r,e,n,i="borderRadius")=>{if(c(r))return{[i]:r.split(" ").map(t=>{const s=z(t);return s!==void 0?s:O(e,n,t)[n]}).join(" ")}};export{W as resolveColorsInGradient,Q as splitTransition,Y as transformBackgroundImage,L as transformBorder,Z as transformBorderRadius,X as transformBoxShadow,J as transformDuration,M as transformShadow,b as transformSize,U as transformSizeRatio,P as transformTextStroke,_ as transformTransition,H as transfromGap};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{document as
|
|
1
|
+
import{document as l,window as p,isString as h,isNumber as x,isNotProduction as y}from"@symbo.ls/utils";const w={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},u=e=>{if(e==="")return[0,0,0,0];if(e.toLowerCase()==="transparent")return[0,0,0,0];const r=w[e.toLowerCase()];if(r&&(e=r),e[0]==="#")return e.length<7&&(e="#"+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+(e.length>4?e[4]+e[4]:"")),[parseInt(e.substr(1,2),16),parseInt(e.substr(3,2),16),parseInt(e.substr(5,2),16),e.length>7?parseInt(e.substr(7,2),16)/255:1];if(e.indexOf("rgb")===-1&&l&&p){const t=l.body.appendChild(l.createElement("fictum")),n="rgb(1, 2, 3)";if(t.style.color=n,t.style.color!==n){l.body.removeChild(t);return}if(t.style.color=e,t.style.color===n||t.style.color==="")return l.body.removeChild(t),[0,0,0,0];e=p.getComputedStyle(t).color,l.body.removeChild(t)}return e.indexOf("rgb")===0?(e.indexOf("rgba")===-1&&(e=`${e}, 1`),e.match(/[\.\d]+/g).map(t=>+t)):[0,0,0,0]},A=(e,r,t=.5)=>(e=u(e),r=u(r),R(e,r,t)),F=(e,r=1)=>{const[t,n,a]=e.match(/\w\w/g).map(f=>parseInt(f,16));return`rgb(${t},${n},${a})`},k=(e,r=1)=>{const[t,n,a]=e.match(/\w\w/g).map(f=>parseInt(f,16));return[t,n,a]},H=(e,r,t)=>"#"+(1<<24|e<<16|r<<8|t).toString(16).slice(1),M=([e,r,t])=>((1<<24)+(e<<16)+(r<<8)+t).toString(16).slice(1),N=(e,r=1)=>{const[t,n,a]=e.match(/\w\w/g).map(f=>parseInt(f,16));return`rgba(${t},${n},${a},${r})`},j=(e,r,t=.5)=>{const n=[];for(let a=0;a<3;a++)n[a]=~~(e[a]+(r[a]-e[a])*t);return`rgb(${n})`},G=(e,r)=>{const[t,n,a]=r,f=Math.max(0,Math.min(100,a+parseFloat(e)));return[t,n,f]},T=(e,r,t)=>{const n=Math.max(e,r,t),a=n-Math.min(e,r,t),f=1-Math.abs(n+n-a-1),o=a&&(n==e?(r-t)/a:n==r?2+(t-e)/a:4+(e-r)/a);return[60*(o<0?o+6:o),f?a/f:0,(n+n-a)/2]},C=(e,r,t,n=r*Math.min(t,1-t),a=(f,o=(f+e/30)%12)=>t-n*Math.max(Math.min(o-3,9-o,1),-1))=>[a(0),a(8),a(4)],S=(e,r)=>{const t=parseInt(e,16);let n=(t>>16)+r;n>255?n=255:n<0&&(n=0);let a=(t>>8&255)+r;a>255?a=255:a<0&&(a=0);let f=(t&255)+r;return f>255?f=255:f<0&&(f=0),((f|a<<8|n<<16)+16777216).toString(16).slice(1)},R=(e,r,t=.5)=>{const n=[];for(let a=0;a<4;a++){const f=a===3?o=>o:Math.round;n[a]=f(e[a]+(r[a]-e[a])*t)}return`rgba(${n})`},z=(e,r)=>{const t=u(e);if(!t){y()&&console.warn(e+" color is not rgba");return}return t[3]=r,`rgba(${t})`},O=e=>e.charCodeAt(0)===45&&e.charCodeAt(1)===45,_=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,$=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,P=e=>{if(!h(e))return null;if(_.test(e))return{passthrough:e};if(O(e))return{cssVar:e};const r=e.match($);if(!r)return null;const[,t,n,a]=r,f=n!==void 0?`0.${n}`:void 0,o=a&&a[0]==="="?a.slice(1):a;return{name:t,alpha:f,tone:o}},V=e=>h(e)&&(e.includes("rgb")||e.includes("var(")||e.includes("#")),X=e=>{const r=[];let t="",n=0;for(const a of e){if(a==="("?n+=1:a===")"&&n>0&&(n-=1),a===","&&n===0){r.push(t),t="";continue}t+=a}return(t.length||!r.length)&&r.push(t),r},g=e=>(e/=255,e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)),m=e=>.2126*g(e[0])+.7152*g(e[1])+.0722*g(e[2]),D=(e,r)=>{const t=m(e)+.05,n=m(r)+.05;return t>n?t/n:n/t},I=e=>(e/=255,e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)),L=e=>(e<=.0031308?e*12.92:1.055*Math.pow(e,1/2.4)-.055)*255,Z=([e,r,t])=>{const[n,a,f]=[e,r,t].map(I),o=.4122214708*n+.5363325363*a+.0514459929*f,s=.2119034982*n+.6806995451*a+.1073969566*f,i=.0883024619*n+.2817188376*a+.6299787005*f,c=Math.cbrt(o),d=Math.cbrt(s),b=Math.cbrt(i);return[.2104542553*c+.793617785*d-.0040720468*b,1.9779984951*c-2.428592205*d+.4505937099*b,.0259040371*c+.7827717662*d-.808675766*b]},q=([e,r,t])=>{const n=e+.3963377774*r+.2158037573*t,a=e-.1055613458*r-.0638541728*t,f=e-.0894841775*r-1.291485548*t,o=n**3,s=a**3,i=f**3;return[4.0767416621*o-3.3077115913*s+.2309699292*i,-1.2684380046*o+2.6097574011*s-.3413193965*i,-.0041960863*o-.7034186147*s+1.707614701*i]},K=([e,r,t])=>{let n=Math.atan2(t,r)*180/Math.PI;return n<0&&(n+=360),[e,Math.sqrt(r*r+t*t),n]},E=([e,r,t])=>{const n=t*Math.PI/180;return[e,r*Math.cos(n),r*Math.sin(n)]},J=(e,r,t,n=24)=>{const a=s=>q(E([e,s,t])),f=s=>s.every(i=>i>=-1e-4&&i<=1.0001);let o=a(r);if(!f(o)){let s=0,i=r;for(let c=0;c<n;c++){const d=(s+i)/2;f(a(d))?s=d:i=d}o=a(s)}return o.map(s=>L(Math.max(0,Math.min(1,s))))},Q=(e,r=1,t=[255,255,255])=>r>=1?e:e.map((n,a)=>n*r+t[a]*(1-r)),U=(e,r)=>{h(e)&&e.includes("rgb")&&(e=u(e).join(", ")),h(e)&&(e=e.split(",").map(a=>parseFloat(a.trim()))),x(r)&&(r+="");const t=M(e),n=r.slice(0,1);if(n==="-"||n==="+"){const a=S(t,parseFloat(r));return k(a).join(", ")}else{const[a,f,o]=e,[s,i]=T(a/255,f/255,o/255),c=Math.max(0,Math.min(100,parseFloat(r)))/100;return C(s,i,c).map(b=>Math.round(Math.max(0,Math.min(1,b))*255)).join(", ")}};export{w as CSS_NAMED_COLOR_HEX,_ as CSS_NATIVE_COLOR_REGEX,G as changeLightness,u as colorStringToRgbaArray,Q as compositeOverBackdrop,D as contrastRatio,S as getColorShade,U as getRgbTone,F as hexToRgb,k as hexToRgbArray,N as hexToRgba,C as hslToRgb,O as isCSSVar,V as isResolvedColor,L as linearChannelToSrgb,A as mixTwoColors,j as mixTwoRgb,R as mixTwoRgba,q as oklabToLinearSrgb,K as oklabToOklch,J as oklchToGamutSafeSrgb,E as oklchToOklab,z as opacify,P as parseColorToken,m as relativeLuminance,M as rgbArrayToHex,T as rgbToHSL,H as rgbToHex,X as splitTopLevelCommas,I as srgbChannelToLinear,Z as srgbToOklab,g as toLinearChannel};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a=(t,r)=>{if(!t||!r)return null;try{return new URL(t),null}catch{}const n=r[t];return n?n.content&&n.content.src:null},b=(t,r)=>{if(t[r])return t[r].value;const n=()=>Object.keys(t).find(o=>o!=="default"&&t[o]&&t[o].value&&!t[o].isSystemFallback);if(t.default){const o=t[t.default];if(o&&o.isSystemFallback){const s=n();if(s)return t[s].value}if(o)return o.value}const e=n()||Object.keys(t).find(o=>o!=="default"&&t[o]&&t[o].value);return e&&t[e]&&t[e].value},S=t=>{if(typeof t!="string"||!t)return null;const r=t.split(/[#?]/)[0].split(".").pop().trim();return["woff2","woff","ttf","otf","eot"].includes(r)?r:null},$=t=>t&&(t.includes("fonts.googleapis.com")||t.includes("fonts.gstatic.com")),d=t=>`@import url('${t}');`,x=t=>`@font-face { ${t} }`,i=(t,r,n,e={})=>{const f=(Array.isArray(r)?r:[r]).filter(c=>typeof c=="string"&&c).map(c=>{const l=S(c),u=l?` format('${l}')`:"";return`url('${c}')${u}`}).join(`,
|
|
2
2
|
`);return`
|
|
3
3
|
font-family: '${t}';
|
|
4
|
-
font-style: ${
|
|
5
|
-
font-weight: ${n};`:""}${
|
|
6
|
-
font-stretch: ${
|
|
7
|
-
font-display: ${
|
|
8
|
-
src: ${
|
|
9
|
-
}`,m=(t,r,n)=>Object.keys(r).map(
|
|
4
|
+
font-style: ${e.fontStyle||"normal"};${n?`
|
|
5
|
+
font-weight: ${n};`:""}${e.fontStretch?`
|
|
6
|
+
font-stretch: ${e.fontStretch};`:""}${e.fontDisplay?`
|
|
7
|
+
font-display: ${e.fontDisplay};`:""}
|
|
8
|
+
src: ${f};`},p=(t,r,n,e)=>`@font-face {${i(t,r,n,e)}
|
|
9
|
+
}`,m=(t,r,n)=>Object.keys(r).map(o=>{const{url:s,fontWeight:f,fontStyle:c,fontDisplay:l,fontStretch:u}=r[o],F=Array.isArray(s)?s.map(y=>a(y,n)||y):a(s,n)||s;return i(t,F,f,{fontStyle:c,fontDisplay:l,fontStretch:u})}),D=t=>Object.keys(t).map(n=>m(n,t[n].value)),v=(t,r,n)=>{if(r&&r.isVariable){const s=a(r.url,n)||r.url;return $(s)?d(s):p(t,s,r.fontWeight,{fontStretch:r.fontStretch,fontDisplay:r.fontDisplay||"swap"})}if(r[0])return m(t,r,n).map(x);const o=Array.isArray(r.url)?r.url.map(s=>a(s,n)||s):a(r.url,n)||r.url;return p(t,o,r.fontWeight,{fontStyle:r.fontStyle,fontDisplay:r.fontDisplay,fontStretch:r.fontStretch})},j=(t,r)=>Object.keys(t).map(e=>v(e,t[e].value,r));export{b as getDefaultOrFirstKey,D as getFontFace,m as getFontFaceEach,v as getFontFaceEachString,j as getFontFaceString,S as getFontFormat,$ as isGoogleFontsUrl,a as resolveFileUrl,i as setCustomFont,p as setCustomFontMedia,d as setFontImport,x as setInCustomFontMedia};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/scratch",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "\u03a6 / CSS framework and methodology.",
|
|
4
4
|
"author": "symbo.ls",
|
|
5
|
-
"version": "3.14.
|
|
5
|
+
"version": "3.14.776",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
8
8
|
"*.js",
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
"main": "./dist/cjs/index.js",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
|
-
"development": "./index.js",
|
|
19
18
|
"import": "./dist/esm/index.js",
|
|
20
19
|
"require": "./dist/cjs/index.js",
|
|
21
20
|
"default": "./dist/esm/index.js"
|
|
@@ -24,7 +23,7 @@
|
|
|
24
23
|
},
|
|
25
24
|
"source": "src/index.js",
|
|
26
25
|
"publishConfig": {
|
|
27
|
-
"access": "
|
|
26
|
+
"access": "public"
|
|
28
27
|
},
|
|
29
28
|
"scripts": {
|
|
30
29
|
"build:esm": "esbuild $(find . -type f -name \"*.js\" -not -path \"*/dist/*\" -not -path \"*/node_modules/*\" -not -path \"*/__tests__/*\" -not -path \"*/test/*\" -not -path \"*/demo/*\" -not -path \"*/demos/*\" -not -path \"*/examples/*\" -not -path \"*/fixtures/*\" -not -name \"*.test.js\") --target=es2022 --format=esm --outbase=. --outdir=dist/esm --minify --log-level=warning",
|
|
@@ -37,7 +36,7 @@
|
|
|
37
36
|
"@symbo.ls/utils": "^3.14.707",
|
|
38
37
|
"color-contrast-checker": "^1.5.0"
|
|
39
38
|
},
|
|
40
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "e7fbb40d81040e265e980564d4eeb2709fa02cb0",
|
|
41
40
|
"browser": "./dist/esm/index.js",
|
|
42
41
|
"sideEffects": true
|
|
43
42
|
}
|