@symbo.ls/scratch 3.14.766 → 3.14.771

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @symbo.ls/scratch
2
2
 
3
+ ## 3.14.771
4
+
5
+ ### Patch Changes
6
+
7
+ - Auto-generated cross-repo patch release.
8
+
9
+ ## 3.14.769
10
+
11
+ ### Patch Changes
12
+
13
+ - Auto-generated cross-repo patch release.
14
+
3
15
  ## 3.14.766
4
16
 
5
17
  ### Patch Changes
@@ -1 +1 @@
1
- "use strict";var T=Object.create;var p=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var y=(e,t)=>{for(var o in t)p(e,o,{get:t[o],enumerable:!0})},b=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of x(t))!V.call(e,n)&&n!==o&&p(e,n,{get:()=>t[n],enumerable:!(r=d(t,n))||r.enumerable});return e};var F=(e,t,o)=>(o=e!=null?T(O(e)):{},b(t||!e||!e.__esModule?p(o,"default",{value:e,enumerable:!0}):o,e)),D=e=>b(p({},"__esModule",{value:!0}),e);var U={};y(U,{CONFIG:()=>f,FACTORY:()=>c,activateConfig:()=>R,createConfig:()=>k,cssMediaVars:()=>C,cssVars:()=>S,defineThemeSignal:()=>u,getActiveConfig:()=>A,getThemeSignal:()=>P,popConfig:()=>L,pushConfig:()=>M,setActiveConfig:()=>j,toCamel:()=>v});module.exports=D(U);var s=require("@symbo.ls/utils"),h=require("@symbo.ls/signal"),I=F(require("./defaultConfig/index.js"),1);const S={},C={},g=I,m={},v=e=>e.replace(/_([a-z])/g,(t,o)=>o.toUpperCase());for(const e in g){const t=e.toLowerCase();m[t]=g[e];const o=v(t);o!==t&&(m[o]=g[e]),t!==e&&(m[e]=g[e])}const f={verbose:!1,useVariable:!0,useReset:!0,globalTheme:"auto",cssVars:S,cssMediaVars:C,CSS_VARS:S,CSS_MEDIA_VARS:C,_scratchConfig:!0,...m},u=(e,t)=>{if(!e)return null;if(e.__globalThemeSignal)return(0,s.isDefined)(t)&&e.__globalThemeSignal.set(t),e.__globalThemeSignal;const o=(0,s.isDefined)(t)?t:e.globalTheme,r=(0,h.createSignal)((0,s.isDefined)(o)?o:"auto");return Object.defineProperty(e,"globalTheme",{get(){return r.get()},set(n){r.set(n)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"__globalThemeSignal",{value:r,enumerable:!1,configurable:!0,writable:!0}),r},P=e=>e?u(e):null;u(f);const _=(0,s.deepClone)(f),c={active:"0",0:f},R=e=>((0,s.isDefined)(e)&&(c.active=e),c[e||c.active]),l=[],M=e=>{e&&e._scratchConfig&&l.push(e)},L=()=>{l.pop()},A=e=>l.length?l[l.length-1]:c[e||c.active]||f,j=e=>{if((0,s.isObject)(e))return c.active="1",c[1]=(0,s.deepMerge)(e,(0,s.deepClone)(_)),u(c[1]),e},G=["useReset","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultIcons","useDefaultConfig"],w=["useVariable","globalTheme","verbose"],E=[["fontfamily","fontFamily","font_family"],["fontfamilytypes","fontFamilyTypes"],["semanticicons","semanticIcons"],["svgdata","svgData"]],N=e=>{for(const t of E){let o;for(const r of t){const n=e[r];(0,s.isObject)(n)&&(o=o?(0,s.deepMerge)(n,o):n)}if(o)for(const r of t)(0,s.isObject)(e[r])&&(e[r]=o)}},k=(e,t,{cleanBase:o=!1}={})=>{const r=o?null:A(),n=(0,s.deepClone)(!o&&r&&r._scratchConfig?r:_);for(const i of G)delete n[i];for(const i of w)Object.prototype.hasOwnProperty.call(_,i)?n[i]=_[i]:delete n[i];const a=(0,s.deepMerge)(t||{},n);return a.cssVars={},a.cssMediaVars={},a.CSS_VARS=a.cssVars,a.CSS_MEDIA_VARS=a.cssMediaVars,a._scratchConfig=!0,N(a),u(a),e&&(c[e]=a),a};
1
+ "use strict";var x=Object.create;var m=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var P=(e,t)=>{for(var o in t)m(e,o,{get:t[o],enumerable:!0})},d=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of O(t))!V.call(e,n)&&n!==o&&m(e,n,{get:()=>t[n],enumerable:!(s=A(t,n))||s.enumerable});return e};var R=(e,t,o)=>(o=e!=null?x(y(e)):{},d(t||!e||!e.__esModule?m(o,"default",{value:e,enumerable:!0}):o,e)),F=e=>d(m({},"__esModule",{value:!0}),e);var B={};P(B,{CONFIG:()=>i,FACTORY:()=>l,activateConfig:()=>j,createConfig:()=>z,cssMediaVars:()=>v,cssVars:()=>h,defineResolvedThemeSignal:()=>p,defineThemeSignal:()=>f,getActiveConfig:()=>T,getResolvedThemeSignal:()=>M,getThemeSignal:()=>I,popConfig:()=>w,pushConfig:()=>L,setActiveConfig:()=>G,toCamel:()=>C});module.exports=F(B);var r=require("@symbo.ls/utils"),b=require("@symbo.ls/signal"),D=R(require("./defaultConfig/index.js"),1);const h={},v={},g=D,_={},C=e=>e.replace(/_([a-z])/g,(t,o)=>o.toUpperCase());for(const e in g){const t=e.toLowerCase();_[t]=g[e];const o=C(t);o!==t&&(_[o]=g[e]),t!==e&&(_[e]=g[e])}const i={verbose:!1,useVariable:!0,useReset:!0,globalTheme:"auto",cssVars:h,cssMediaVars:v,CSS_VARS:h,CSS_MEDIA_VARS:v,_scratchConfig:!0,..._},f=(e,t)=>{if(!e)return null;if(e.__globalThemeSignal)return(0,r.isDefined)(t)&&e.__globalThemeSignal.set(t),e.__globalThemeSignal;const o=(0,r.isDefined)(t)?t:e.globalTheme,s=(0,b.createSignal)((0,r.isDefined)(o)?o:"auto");return Object.defineProperty(e,"globalTheme",{get(){return s.get()},set(n){s.set(n)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"__globalThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},I=e=>e?f(e):null,p=(e,t)=>{if(!e)return null;if(e.__resolvedThemeSignal)return(0,r.isDefined)(t)&&e.__resolvedThemeSignal.set(t),e.__resolvedThemeSignal;const o=(0,r.isDefined)(t)?t:e.resolvedTheme,s=(0,b.createSignal)((0,r.isDefined)(o)?o:null);return Object.defineProperty(e,"resolvedTheme",{get(){return s.get()},set(n){s.set(n)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"__resolvedThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},M=e=>e?p(e):null;f(i),p(i);const S=(0,r.deepClone)(i),l={active:"0",0:i},j=e=>((0,r.isDefined)(e)&&(l.active=e),l[e||l.active]),u=[],L=e=>{e&&e._scratchConfig&&u.push(e)},w=()=>{u.pop()},T=e=>u.length?u[u.length-1]:l[e||l.active]||i,G=e=>{if((0,r.isObject)(e))return l.active="1",l[1]=(0,r.deepMerge)(e,(0,r.deepClone)(S)),f(l[1]),p(l[1]),e},E=["useReset","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultIcons","useDefaultConfig"],N=["useVariable","globalTheme","verbose"],k=[["fontfamily","fontFamily","font_family"],["fontfamilytypes","fontFamilyTypes"],["semanticicons","semanticIcons"],["svgdata","svgData"]],U=e=>{for(const t of k){let o;for(const s of t){const n=e[s];(0,r.isObject)(n)&&(o=o?(0,r.deepMerge)(n,o):n)}if(o)for(const s of t)(0,r.isObject)(e[s])&&(e[s]=o)}},z=(e,t,{cleanBase:o=!1}={})=>{const s=o?null:T(),n=(0,r.deepClone)(!o&&s&&s._scratchConfig?s:S);for(const c of E)delete n[c];for(const c of N)Object.prototype.hasOwnProperty.call(S,c)?n[c]=S[c]:delete n[c];const a=(0,r.deepMerge)(t||{},n);return a.cssVars={},a.cssMediaVars={},a.CSS_VARS=a.cssVars,a.CSS_MEDIA_VARS=a.cssMediaVars,a._scratchConfig=!0,U(a),f(a),p(a),e&&(l[e]=a),a};
@@ -1 +1 @@
1
- "use strict";var x=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var W=(t,s)=>{for(var e in s)x(t,e,{get:s[e],enumerable:!0})},N=(t,s,e,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of q(s))!G.call(t,n)&&n!==e&&x(t,n,{get:()=>s[n],enumerable:!(c=j(s,n))||c.enumerable});return t};var H=t=>N(x({},"__esModule",{value:!0}),t);var J={};W(J,{VALUE_TRANSFORMERS:()=>D,changeGlobalTheme:()=>z,set:()=>U,setEach:()=>M,setValue:()=>k});module.exports=H(J);var b=require("./factory.js"),o=require("./system/index.js"),S=require("@symbo.ls/utils"),u=require("./utils/host.js");const Y=(t,s)=>{const e=(0,b.getActiveConfig)(),{cssVars:c}=e,n=s.startsWith("--")?s:`--${s}`;return c[n]=t,t},l=t=>t,D={color:o.setColor,gradient:o.setGradient,font:o.setFont,fontFamily:o.setFontFamily,fontfamily:o.setFontFamily,theme:o.setTheme,icons:o.setSvgIcon,semanticIcons:l,semanticicons:l,svg:o.setSVG,svgData:l,typography:l,shadow:o.setShadow,spacing:l,media:l,grid:l,class:l,timing:l,reset:l,unit:l,animation:l,vars:Y,sizes:l,shape:l},$=(t,s,e,c)=>{(0,u.parkHostObject)(t,e,s);const n={};for(const r of c)t[r]===s&&(t[r]=n);return t.verbose&&console.warn("[scratch] design-system family",e,"resolved to a host object; parked it and allocated a plain bucket"),n},k=(t,s,e)=>{const c=(0,b.getActiveConfig)(),n=(0,b.toCamel)(t),r=n.toLowerCase(),d=c[n]||c[r]||c[t],i=(0,u.isHostObject)(d)?$(c,d,r,[n,r,t]):d,m=D[n]||D[r];if(m)try{const a=m(s,e);return i&&(i[e]=a),i}catch(a){c.verbose&&console.warn("Error setting",r,"value",s,e,a)}if(!m){const a=i||(c[r]={});return a[e]=s,a}c.verbose&&console.warn("Can not find",r,"method in scratch")},M=(t,s)=>{const e=(0,b.getActiveConfig)(),c=t.toLowerCase();return(0,u.isHostObject)(s)?((0,u.parkHostObject)(e,c,s),e.verbose&&console.warn("[scratch] ignoring host object passed as the",c,"design-system family"),e[c]||e[t]):(Object.keys(s).sort((r,d)=>{const i=(0,S.isObject)(s[r])||(0,S.isArray)(s[r])?1:0,m=(0,S.isObject)(s[d])||(0,S.isArray)(s[d])?1:0;return i-m}).forEach(r=>{try{return k(c,s[r],r)}catch(d){e.verbose&&console.warn("Error setting",c,"value",s[r],r,d)}}),e[c]||e[t])},z=(t,s)=>{const e=s||(0,b.getActiveConfig)();e.globalTheme=t;const n=(0,u.resolveConfigDocument)(e)||(typeof document<"u"?document:null),r=n&&n.defaultView||(typeof window<"u"?window:null);if(n){const i=e.themeRoot||n.documentElement;if(t&&t!=="auto")i.setAttribute("data-theme",t),t==="dark"||t==="light"?i.style.colorScheme=t:i.style.colorScheme="light dark";else if(r&&r.matchMedia){const a=p=>{i.setAttribute("data-theme",p.matches?"dark":"light")},h=r.matchMedia("(prefers-color-scheme: dark)");if(a(h),i.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=a;try{h.addEventListener("change",a)}catch{h.addListener(a)}}}else i.setAttribute("data-theme","light"),i.style.colorScheme="light"}const d=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const i in e.cssVars)i.startsWith(d)&&delete e.cssVars[i];for(const i in e.cssMediaVars)delete e.cssMediaVars[i];if(n&&e.cssVars){const i=e.scopeSelector||":root",m=n.styleSheets;for(let a=0;a<m.length;a++)try{const h=m[a].cssRules;for(let p=0;p<h.length;p++)if(h[p].selectorText===i){for(const w in e.cssVars)h[p].style.setProperty(w,e.cssVars[w]);return e}}catch{}}return e},B={},U=(t,s=B)=>{let e=s.config||(0,b.getActiveConfig)();const{version:c,verbose:n,useVariable:r,useReset:d,useSvgSprite:i,useFontImport:m,useIconSprite:a,globalTheme:h,themeRoot:p,useDocumentTheme:w,useDefaultConfig:E,semanticIcons:R,hoverMedia:A,files:L,assets:F,...y}=t;s.newConfig&&(e=(0,b.setActiveConfig)(s.newConfig)),(0,u.isDomDocument)(y.document)&&(e.__domDocument=y.document,delete y.document),(0,u.isDomDocument)(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),L!==void 0&&(e.files=L),F!==void 0&&(e.assets=F),n!==void 0&&(e.verbose=n),r!==void 0&&(e.useVariable=r),d!==void 0&&(e.useReset=d),m!==void 0&&(e.useFontImport=m),i!==void 0&&(e.useSvgSprite=i),a!==void 0&&(e.useIconSprite=a),w!==void 0&&(e.useDocumentTheme=w),h!==void 0&&(e.globalTheme=h),p!==void 0&&(e.themeRoot=p),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),E!==void 0&&(e.useDefaultConfig=E),R!==void 0&&(e.semanticIcons=R),A!==void 0&&(e.hoverMedia=A),e.verbose&&console.log(e);const C=(0,u.resolveConfigDocument)(e)||(typeof document<"u"?document:null),_=C&&C.defaultView||(typeof window<"u"?window:null),v=C&&(e.themeRoot||C.documentElement);if(v&&typeof v.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")v.setAttribute("data-theme",e.globalTheme),e.globalTheme==="dark"||e.globalTheme==="light"?v.style.colorScheme=e.globalTheme:v.style.colorScheme="light dark";else if(_&&_.matchMedia){const g=P=>{v.setAttribute("data-theme",P.matches?"dark":"light")},V=_.matchMedia("(prefers-color-scheme: dark)");if(g(V),v.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=g;try{V.addEventListener("change",g)}catch{V.addListener(g)}}}else v.setAttribute("data-theme","light"),v.style.colorScheme="light";e.__svgCache||(e.__svgCache={});const T=Object.keys(y).filter(f=>!f.startsWith("__")),I=new Set(T);if(T.forEach(f=>{const g=f.toLowerCase();g!==f&&I.has(g)&&(0,S.deepMerge)(y[g],y[f])}),T.map(f=>{const g=f.toLowerCase();if(!(g!==f&&I.has(g)))return M(f,y[f])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),y.typography)try{(0,o.applyTypographySequence)()}catch(f){e.verbose&&console.warn("Error applying typography sequence",f)}if(y.spacing)try{(0,o.applySpacingSequence)()}catch(f){e.verbose&&console.warn("Error applying spacing sequence",f)}if(y.timing)try{(0,o.applyTimingSequence)()}catch(f){e.verbose&&console.warn("Error applying timing sequence",f)}(0,o.applyDocument)();const O=(0,o.applyReset)();return O&&(e.reset=O),e};
1
+ "use strict";var x=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var N=(t,s)=>{for(var e in s)x(t,e,{get:s[e],enumerable:!0})},H=(t,s,e,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of G(s))!W.call(t,r)&&r!==e&&x(t,r,{get:()=>s[r],enumerable:!(c=q(s,r))||c.enumerable});return t};var Y=t=>H(x({},"__esModule",{value:!0}),t);var K={};N(K,{VALUE_TRANSFORMERS:()=>D,changeGlobalTheme:()=>B,set:()=>J,setEach:()=>j,setValue:()=>M});module.exports=Y(K);var v=require("./factory.js"),o=require("./system/index.js"),T=require("@symbo.ls/utils"),u=require("./utils/host.js");const $=(t,s)=>{const e=(0,v.getActiveConfig)(),{cssVars:c}=e,r=s.startsWith("--")?s:`--${s}`;return c[r]=t,t},f=t=>t,D={color:o.setColor,gradient:o.setGradient,font:o.setFont,fontFamily:o.setFontFamily,fontfamily:o.setFontFamily,theme:o.setTheme,icons:o.setSvgIcon,semanticIcons:f,semanticicons:f,svg:o.setSVG,svgData:f,typography:f,shadow:o.setShadow,spacing:f,media:f,grid:f,class:f,timing:f,reset:f,unit:f,animation:f,vars:$,sizes:f,shape:f},z=(t,s,e,c)=>{(0,u.parkHostObject)(t,e,s);const r={};for(const n of c)t[n]===s&&(t[n]=r);return t.verbose&&console.warn("[scratch] design-system family",e,"resolved to a host object; parked it and allocated a plain bucket"),r},M=(t,s,e)=>{const c=(0,v.getActiveConfig)(),r=(0,v.toCamel)(t),n=r.toLowerCase(),d=c[r]||c[n]||c[t],i=(0,u.isHostObject)(d)?z(c,d,n,[r,n,t]):d,m=D[r]||D[n];if(m)try{const a=m(s,e);return i&&(i[e]=a),i}catch(a){c.verbose&&console.warn("Error setting",n,"value",s,e,a)}if(!m){const a=i||(c[n]={});return a[e]=s,a}c.verbose&&console.warn("Can not find",n,"method in scratch")},j=(t,s)=>{const e=(0,v.getActiveConfig)(),c=t.toLowerCase();return(0,u.isHostObject)(s)?((0,u.parkHostObject)(e,c,s),e.verbose&&console.warn("[scratch] ignoring host object passed as the",c,"design-system family"),e[c]||e[t]):(Object.keys(s).sort((n,d)=>{const i=(0,T.isObject)(s[n])||(0,T.isArray)(s[n])?1:0,m=(0,T.isObject)(s[d])||(0,T.isArray)(s[d])?1:0;return i-m}).forEach(n=>{try{return M(c,s[n],n)}catch(d){e.verbose&&console.warn("Error setting",c,"value",s[n],n,d)}}),e[c]||e[t])},B=(t,s)=>{const e=s||(0,v.getActiveConfig)();e.globalTheme=t;const r=(0,u.resolveConfigDocument)(e)||(typeof document<"u"?document:null),n=r&&r.defaultView||(typeof window<"u"?window:null);if(r){const i=e.themeRoot||r.documentElement;if(t&&t!=="auto")i.setAttribute("data-theme",t),e.resolvedTheme=t,t==="dark"||t==="light"?i.style.colorScheme=t:i.style.colorScheme="light dark";else if(n&&n.matchMedia){const a=p=>{const S=p.matches?"dark":"light";i.setAttribute("data-theme",S),e.resolvedTheme=S},h=n.matchMedia("(prefers-color-scheme: dark)");if(a(h),i.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=a;try{h.addEventListener("change",a)}catch{h.addListener(a)}}}else i.setAttribute("data-theme","light"),e.resolvedTheme="light",i.style.colorScheme="light"}const d=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const i in e.cssVars)i.startsWith(d)&&delete e.cssVars[i];for(const i in e.cssMediaVars)delete e.cssMediaVars[i];if(r&&e.cssVars){const i=e.scopeSelector||":root",m=r.styleSheets;for(let a=0;a<m.length;a++)try{const h=m[a].cssRules;for(let p=0;p<h.length;p++)if(h[p].selectorText===i){for(const S in e.cssVars)h[p].style.setProperty(S,e.cssVars[S]);return e}}catch{}}return e},U={},J=(t,s=U)=>{let e=s.config||(0,v.getActiveConfig)();const{version:c,verbose:r,useVariable:n,useReset:d,useSvgSprite:i,useFontImport:m,useIconSprite:a,globalTheme:h,themeRoot:p,useDocumentTheme:S,useDefaultConfig:E,semanticIcons:R,hoverMedia:A,files:L,assets:F,...y}=t;s.newConfig&&(e=(0,v.setActiveConfig)(s.newConfig)),(0,u.isDomDocument)(y.document)&&(e.__domDocument=y.document,delete y.document),(0,u.isDomDocument)(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),L!==void 0&&(e.files=L),F!==void 0&&(e.assets=F),r!==void 0&&(e.verbose=r),n!==void 0&&(e.useVariable=n),d!==void 0&&(e.useReset=d),m!==void 0&&(e.useFontImport=m),i!==void 0&&(e.useSvgSprite=i),a!==void 0&&(e.useIconSprite=a),S!==void 0&&(e.useDocumentTheme=S),h!==void 0&&(e.globalTheme=h),p!==void 0&&(e.themeRoot=p),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),E!==void 0&&(e.useDefaultConfig=E),R!==void 0&&(e.semanticIcons=R),A!==void 0&&(e.hoverMedia=A),e.verbose&&console.log(e);const w=(0,u.resolveConfigDocument)(e)||(typeof document<"u"?document:null),C=w&&w.defaultView||(typeof window<"u"?window:null),b=w&&(e.themeRoot||w.documentElement);if(b&&typeof b.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")b.setAttribute("data-theme",e.globalTheme),e.resolvedTheme=e.globalTheme,e.globalTheme==="dark"||e.globalTheme==="light"?b.style.colorScheme=e.globalTheme:b.style.colorScheme="light dark";else if(C&&C.matchMedia){const g=P=>{const k=P.matches?"dark":"light";b.setAttribute("data-theme",k),e.resolvedTheme=k},V=C.matchMedia("(prefers-color-scheme: dark)");if(g(V),b.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=g;try{V.addEventListener("change",g)}catch{V.addListener(g)}}}else b.setAttribute("data-theme","light"),e.resolvedTheme="light",b.style.colorScheme="light";e.__svgCache||(e.__svgCache={});const _=Object.keys(y).filter(l=>!l.startsWith("__")),I=new Set(_);if(_.forEach(l=>{const g=l.toLowerCase();g!==l&&I.has(g)&&(0,T.deepMerge)(y[g],y[l])}),_.map(l=>{const g=l.toLowerCase();if(!(g!==l&&I.has(g)))return j(l,y[l])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),y.typography)try{(0,o.applyTypographySequence)()}catch(l){e.verbose&&console.warn("Error applying typography sequence",l)}if(y.spacing)try{(0,o.applySpacingSequence)()}catch(l){e.verbose&&console.warn("Error applying spacing sequence",l)}if(y.timing)try{(0,o.applyTimingSequence)()}catch(l){e.verbose&&console.warn("Error applying timing sequence",l)}(0,o.applyDocument)();const O=(0,o.applyReset)();return O&&(e.reset=O),e};
@@ -1 +1 @@
1
- "use strict";var w=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var q=(r,s)=>{for(var a in s)w(r,a,{get:s[a],enumerable:!0})},O=(r,s,a,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let l of j(s))!L.call(r,l)&&l!==a&&w(r,l,{get:()=>s[l],enumerable:!(e=T(s,l))||e.enumerable});return r};var _=r=>O(w({},"__esModule",{value:!0}),r);var Q={};q(Q,{STANDARD_SCHEME_QUERIES:()=>P,getColor:()=>C,getMediaColor:()=>H,setAdaptiveSchemeVar:()=>E,setColor:()=>M,setGradient:()=>D});module.exports=_(Q);var c=require("@symbo.ls/utils"),S=require("../factory.js"),g=require("../utils/index.js");const P={light:"(prefers-color-scheme: light)",dark:"(prefers-color-scheme: dark)"},C=(r,s,a)=>{const e=a||(0,S.getActiveConfig)();if(!(0,c.isString)(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if((0,g.isCSSVar)(r))return`var(${r})`;s&&r[s]&&(r=r[s]);let l,f,o;if((0,c.isArray)(r))[l,f,o]=r;else{const n=(0,g.parseColorToken)(r);if(!n){const{color:V,gradient:A}=e;let $=A[r]||V[r];return $?(s&&$[s]&&($=$[s]),e.useVariable?`var(${$.var})`:$.value):r}if(n.passthrough)return n.passthrough;if(n.cssVar)return`var(${n.cssVar})`;l=n.name,f=n.alpha,o=n.tone}const{color:p,gradient:b}=e;let t=p[l]||b[l];if(!t)return e.verbose&&console.warn("Can't find color ",l),r;if(s)if(t[s]!==void 0)t=t[s];else if((0,c.isArray)(t)){const n=s.charCodeAt(0)===64?s.slice(1):s;n==="dark"?t=t[1]!==void 0?t[1]:t[0]:(n!=="light"&&e.verbose&&console.warn(r," - array-form color tokens only support light/dark; falling back to the light slot for scheme",s),t=t[0])}else e.verbose&&console.warn(r," - does not have ",s);if((0,c.isString)(t))return C(t,null,a);let d=t.rgb;if(!d){const n=e.useVariable?`var(${t.var})`:t.value;if(f&&n){const V=Math.round(parseFloat(f)*100);return`color-mix(in srgb, ${n} ${V}%, transparent)`}return n}return o&&!t[o]&&(d=(0,g.getRgbTone)(d,o),t[o]={rgb:d,var:`${t.var}-${o}`}),t[o]&&(d=t[o].rgb),f?`rgba(${d}, ${f})`:o?`rgba(${d}, 1)`:e.useVariable?`var(${t.var})`:`rgb(${d})`},H=(r,s,a)=>{const e=a||(0,S.getActiveConfig)();if(s||(s=e.globalTheme==="auto"?null:e.globalTheme),!(0,c.isString)(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if((0,g.isCSSVar)(r))return`var(${r})`;let l,f,o;if((0,c.isArray)(r))l=r[0];else{const n=(0,g.parseColorToken)(r);if(n){if(n.passthrough)return n.passthrough;if(n.cssVar)return`var(${n.cssVar})`;l=n.name,f=n.alpha,o=n.tone}else l=r}const{color:p,gradient:b}=e,t=p[l]||b[l],d=(0,c.isObject)(t);if(d&&t.value)return C(r,`@${s}`,a);if(d){if(e.useVariable&&t.var)return f||o?C(r,null,a):`var(${t.var})`;if(s)return C(r,`@${s}`,a);{const n={};for(const V in t){if(V.charCodeAt(0)!==64)continue;const A=V.slice(1),$=e.media&&e.media[A]||P[A];if(!$)continue;const u="@media "+($==="print"?`${$}`:`screen and ${$}`);n[u]=C(r,V,a)}return n}}else return e.verbose&&console.warn("Can't find color",r),r},E=(r,s,a,e)=>{const f=`--${e.varPrefix?e.varPrefix+"-":""}${s}-${a}`;let o;const p={};for(const b in r){if(b.charCodeAt(0)!==64)continue;const t=b.slice(1),d=r[b],n=d&&(d.value||d);!n||typeof n!="string"||(p[t]=n,(t==="light"||o===void 0)&&(o=n))}if(o!==void 0){e.cssVars[f]=o,e.cssMediaVars||(e.cssMediaVars={});for(const b in p){const t=`[data-theme="${b}"]`;if(e.cssMediaVars[t]||(e.cssMediaVars[t]={}),e.cssMediaVars[t][f]=p[b],b==="light"||b==="dark"){const d=`@media (prefers-color-scheme: ${b})`;e.cssMediaVars[d]||(e.cssMediaVars[d]={}),e.cssMediaVars[d][f]=p[b]}}return r.var=f,f}},M=(r,s,a)=>{const e=(0,S.getActiveConfig)();if((0,c.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,c.isString)(r)&&(0,g.isCSSVar)(r)){const u=r.slice(2);if(r=C(u),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const i=u.split(" ");let h=e.color[i[0]];if(h&&!h.value&&!h.rgb&&((0,c.isString)(h)||(0,c.isArray)(h)||(0,c.isObject)(h))&&(e.color[i[0]]=M(h,i[0]),h=e.color[i[0]]),h&&h.value){let m=h.rgb;const x=i[1]!==void 0?i[1]:"1",R=i[2];R&&(m=(0,g.getRgbTone)(m,R)),r=`rgba(${m}, ${x})`}else{const m=i[2],x=i[1]!==void 0?i[1]:"1";if(m)try{const R=(0,g.colorStringToRgbaArray)(i[0]);R&&R.length>=3?r=`rgba(${(0,g.getRgbTone)(R.slice(0,3).join(", "),m)}, ${x})`:r=i[0]}catch{r=i[0]}else r=i[0]}}}if((0,c.isArray)(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),(0,c.isObject)(r)){const u={};for(const i in r)i!=="var"&&(u[i]=M(r[i],s,i.slice(0,1)==="@"?i.slice(1):i));return e.useVariable&&E(u,"color",s,e),u}const f=`--${e.varPrefix?e.varPrefix+"-":""}color-${s}`+(a?`-${a}`:"");let o=r.value||r;if((0,c.isString)(o)&&!o.includes("(")&&!o.startsWith("#")){const u=(0,g.parseColorToken)(o);if(u&&u.name&&!u.passthrough&&!u.cssVar){const i=e.color[u.name];i&&!i.value&&!i.rgb&&((0,c.isString)(i)||(0,c.isArray)(i)||(0,c.isObject)(i))&&(e.color[u.name]=M(i,u.name));const h=e.color[u.name];if(h&&h.rgb){let m=h.rgb;u.tone&&(m=(0,g.getRgbTone)(m,u.tone));const x=u.alpha?parseFloat(u.alpha):1;o=`rgba(${m}, ${x})`}}}const p=(0,g.colorStringToRgbaArray)(o),[b,t,d,n=1]=p,V=parseFloat(n.toFixed(2)),A=`${b}, ${t}, ${d}`,$=`rgba(${A}, ${V})`;return e.useVariable&&(e.cssVars[f]=$),{var:f,rgb:A,alpha:V,value:$}},D=(r,s,a)=>{const e=(0,S.getActiveConfig)();if((0,c.isObject)(r)&&r.value!==void 0&&r.var!==void 0)return e.useVariable&&(e.cssVars[r.var]=r.value),r;if((0,c.isString)(r)&&(0,g.isCSSVar)(r)&&(r=C(r.slice(2))),(0,c.isArray)(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),(0,c.isObject)(r)){const o={};for(const p in r)p!=="var"&&(o[p]=D(r[p],s,p.slice(0,1)==="@"?p.slice(1):p));return e.useVariable&&E(o,"gradient",s,e),o}const f=`--${e.varPrefix?e.varPrefix+"-":""}gradient-${s}`+(a?`-${a}`:"");return e.useVariable&&(e.cssVars[f]=r.value||r),{var:f,value:r.value||r}};
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 +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("./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("./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);
@@ -0,0 +1 @@
1
+ "use strict";var C=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var T=(a,e)=>{for(var l in e)C(a,l,{get:e[l],enumerable:!0})},ee=(a,e,l,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _(e))!k.call(a,o)&&o!==l&&C(a,o,{get:()=>e[o],enumerable:!(c=Z(e,o))||c.enumerable});return a};var te=a=>ee(C({},"__esModule",{value:!0}),a);var re={};T(re,{getSafeInk:()=>K,getSafeInkInfo:()=>oe});module.exports=te(re);var j=require("@symbo.ls/utils"),F=require("../factory.js"),r=require("../utils/index.js"),g=require("./color.js");const K=(a,e,l={},c)=>{const o=c||(0,F.getActiveConfig)(),{min:N=4.5,large:O=!1,scheme:V,meta:B=!1,maxIterations:E=15}=l,v=O?3:N,m=V||(o.globalTheme&&o.globalTheme!=="auto"?o.globalTheme:"light"),I=(0,j.isString)(e)?e:String(e),h=(0,r.parseColorToken)(a),x=h&&!h.passthrough&&!h.cssVar?h.name:null,b=(t,n)=>B?{value:t,...n}:t;if(x){const t=o.color[`${x}Safe`];if(t){const n=`${I}@${m}`,s=t[n]!==void 0?t[n]:t[I];if(s!==void 0){const D=s&&s.rgb!==void 0?o.useVariable&&s.var?`var(${s.var})`:s.value:(0,g.getColor)(s,null,o);return b(D,{ratio:null,deviation:0,derived:!1,overridden:!0})}}}const M=(0,g.getColor)(a,m?`@${m}`:null,o),i=(0,g.resolveColorRgb)(a,o,m),p=(0,g.resolveColorRgb)(e,o,m);if(!i||!p)return o.verbose&&console.warn("getSafeInk: could not resolve",a,e,"\u2014 returning hue unchanged"),b(M,{ratio:null,deviation:0,derived:!1,overridden:!1,unresolved:!0});const f=(0,r.compositeOverBackdrop)(p.rgb,p.alpha),G=(0,r.compositeOverBackdrop)(i.rgb,i.alpha,f),L=(0,r.contrastRatio)(G,f);if(L>=v-.02)return b(M,{ratio:L,deviation:0,derived:!1,overridden:!1});const[H,P,q]=(0,r.rgbToHSL)(i.rgb[0]/255,i.rgb[1]/255,i.rgb[2]/255),u=q*100,y=(0,r.relativeLuminance)(f)>.5,z=y?u:100-u,w=t=>{const n=y?u-t:u+t,s=Math.max(0,Math.min(100,n));return{rgb:(0,r.hslToRgb)(H,P,s/100).map(Y=>Math.max(0,Math.min(1,Y))*255),L:s}},R=t=>{const{rgb:n}=w(t),s=(0,r.compositeOverBackdrop)(n,i.alpha,f);return(0,r.contrastRatio)(s,f)};let S=0,d=z;const A=R(d)>=v;if(A)for(let t=0;t<E;t++){const n=(S+d)/2;R(n)>=v?d=n:S=n}else S=d;const{rgb:J,L:Q}=w(d),$=J.map(t=>Math.round(t)),U=R(d),W=i.alpha<1?`rgba(${$.join(", ")}, ${i.alpha})`:`rgb(${$.join(", ")})`,X=Math.abs(Q-u);return b(W,{rgb:$,ratio:U,startRatio:L,deviation:X,derived:!0,overridden:!1,reachable:A})},oe=(a,e,l={},c)=>K(a,e,{...l,meta:!0},c);
@@ -1 +1 @@
1
- "use strict";var c=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var S=(t,e)=>{for(var r in e)c(t,r,{get:e[r],enumerable:!0})},$=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!M.call(t,n)&&n!==r&&c(t,n,{get:()=>e[n],enumerable:!(s=R(e,n))||s.enumerable});return t};var I=t=>$(c({},"__esModule",{value:!0}),t);var X={};S(X,{CSS_NATIVE_COLOR_REGEX:()=>b,changeLightness:()=>_,colorStringToRgbaArray:()=>p,getColorShade:()=>m,getRgbTone:()=>G,hexToRgb:()=>E,hexToRgbArray:()=>h,hexToRgba:()=>A,hslToRgb:()=>g,isCSSVar:()=>d,isResolvedColor:()=>V,mixTwoColors:()=>O,mixTwoRgb:()=>F,mixTwoRgba:()=>x,opacify:()=>H,parseColorToken:()=>j,rgbArrayToHex:()=>u,rgbToHSL:()=>f,rgbToHex:()=>L,splitTopLevelCommas:()=>z});module.exports=I(X);var i=require("@symbo.ls/utils");const p=t=>{if(t==="")return[0,0,0,0];if(t.toLowerCase()==="transparent")return[0,0,0,0];if(t[0]==="#")return t.length<7&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(t.length>4?t[4]+t[4]:"")),[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16),t.length>7?parseInt(t.substr(7,2),16)/255:1];if(t.indexOf("rgb")===-1&&i.document&&i.window){const e=i.document.body.appendChild(i.document.createElement("fictum")),r="rgb(1, 2, 3)";if(e.style.color=r,e.style.color!==r){i.document.body.removeChild(e);return}if(e.style.color=t,e.style.color===r||e.style.color==="")return i.document.body.removeChild(e),[0,0,0,0];t=i.window.getComputedStyle(e).color,i.document.body.removeChild(e)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(e=>+e)):[0,0,0,0]},O=(t,e,r=.5)=>(t=p(t),e=p(e),x(t,e,r)),E=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgb(${r},${s},${n})`},h=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return[r,s,n]},L=(t,e,r)=>"#"+(1<<24|t<<16|e<<8|r).toString(16).slice(1),u=([t,e,r])=>((1<<24)+(t<<16)+(e<<8)+r).toString(16).slice(1),A=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgba(${r},${s},${n},${e})`},F=(t,e,r=.5)=>{const s=[];for(let n=0;n<3;n++)s[n]=~~(t[n]+(e[n]-t[n])*r);return`rgb(${s})`},_=(t,e)=>{const[r,s,n]=e,a=Math.max(0,Math.min(100,n+parseFloat(t)));return[r,s,a]},f=(t,e,r)=>{const s=Math.max(t,e,r),n=s-Math.min(t,e,r),a=1-Math.abs(s+s-n-1),o=n&&(s==t?(e-r)/n:s==e?2+(r-t)/n:4+(t-e)/n);return[60*(o<0?o+6:o),a?n/a:0,(s+s-n)/2]},g=(t,e,r,s=e*Math.min(r,1-r),n=(a,o=(a+t/30)%12)=>r-s*Math.max(Math.min(o-3,9-o,1),-1))=>[n(0),n(8),n(4)],m=(t,e)=>{const r=parseInt(t,16);let s=(r>>16)+e;s>255?s=255:s<0&&(s=0);let n=(r>>8&255)+e;n>255?n=255:n<0&&(n=0);let a=(r&255)+e;return a>255?a=255:a<0&&(a=0),((a|n<<8|s<<16)+16777216).toString(16).slice(1)},x=(t,e,r=.5)=>{const s=[];for(let n=0;n<4;n++){const a=n===3?o=>o:Math.round;s[n]=a(t[n]+(e[n]-t[n])*r)}return`rgba(${s})`},H=(t,e)=>{const r=p(t);if(!r){(0,i.isNotProduction)()&&console.warn(t+" color is not rgba");return}return r[3]=e,`rgba(${r})`},d=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,b=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,N=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,j=t=>{if(!(0,i.isString)(t))return null;if(b.test(t))return{passthrough:t};if(d(t))return{cssVar:t};const e=t.match(N);if(!e)return null;const[,r,s,n]=e,a=s!==void 0?`0.${s}`:void 0,o=n&&n[0]==="="?n.slice(1):n;return{name:r,alpha:a,tone:o}},V=t=>(0,i.isString)(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),z=t=>{const e=[];let r="",s=0;for(const n of t){if(n==="("?s+=1:n===")"&&s>0&&(s-=1),n===","&&s===0){e.push(r),r="";continue}r+=n}return(r.length||!e.length)&&e.push(r),e},G=(t,e)=>{(0,i.isString)(t)&&t.includes("rgb")&&(t=p(t).join(", ")),(0,i.isString)(t)&&(t=t.split(",").map(n=>parseFloat(n.trim()))),(0,i.isNumber)(e)&&(e+="");const r=u(t),s=e.slice(0,1);if(s==="-"||s==="+"){const n=m(r,parseFloat(e));return h(n).join(", ")}else{const[n,a,o]=t,[l,w]=f(n/255,a/255,o/255),C=Math.max(0,Math.min(100,parseFloat(e)))/100;return g(l,w,C).map(T=>Math.round(Math.max(0,Math.min(1,T))*255)).join(", ")}};
1
+ "use strict";var u=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var I=(t,e)=>{for(var r in e)u(t,r,{get:e[r],enumerable:!0})},L=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of S(e))!$.call(t,n)&&n!==r&&u(t,n,{get:()=>e[n],enumerable:!(s=y(e,n))||s.enumerable});return t};var O=t=>L(u({},"__esModule",{value:!0}),t);var K={};I(K,{CSS_NATIVE_COLOR_REGEX:()=>w,changeLightness:()=>N,colorStringToRgbaArray:()=>c,compositeOverBackdrop:()=>k,contrastRatio:()=>Z,getColorShade:()=>d,getRgbTone:()=>D,hexToRgb:()=>A,hexToRgbArray:()=>f,hexToRgba:()=>_,hslToRgb:()=>g,isCSSVar:()=>b,isResolvedColor:()=>G,mixTwoColors:()=>E,mixTwoRgb:()=>H,mixTwoRgba:()=>l,opacify:()=>j,parseColorToken:()=>z,relativeLuminance:()=>h,rgbArrayToHex:()=>x,rgbToHSL:()=>m,rgbToHex:()=>F,splitTopLevelCommas:()=>X,toLinearChannel:()=>p});module.exports=O(K);var a=require("@symbo.ls/utils");const c=t=>{if(t==="")return[0,0,0,0];if(t.toLowerCase()==="transparent")return[0,0,0,0];if(t[0]==="#")return t.length<7&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(t.length>4?t[4]+t[4]:"")),[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16),t.length>7?parseInt(t.substr(7,2),16)/255:1];if(t.indexOf("rgb")===-1&&a.document&&a.window){const e=a.document.body.appendChild(a.document.createElement("fictum")),r="rgb(1, 2, 3)";if(e.style.color=r,e.style.color!==r){a.document.body.removeChild(e);return}if(e.style.color=t,e.style.color===r||e.style.color==="")return a.document.body.removeChild(e),[0,0,0,0];t=a.window.getComputedStyle(e).color,a.document.body.removeChild(e)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(e=>+e)):[0,0,0,0]},E=(t,e,r=.5)=>(t=c(t),e=c(e),l(t,e,r)),A=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgb(${r},${s},${n})`},f=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(o=>parseInt(o,16));return[r,s,n]},F=(t,e,r)=>"#"+(1<<24|t<<16|e<<8|r).toString(16).slice(1),x=([t,e,r])=>((1<<24)+(t<<16)+(e<<8)+r).toString(16).slice(1),_=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgba(${r},${s},${n},${e})`},H=(t,e,r=.5)=>{const s=[];for(let n=0;n<3;n++)s[n]=~~(t[n]+(e[n]-t[n])*r);return`rgb(${s})`},N=(t,e)=>{const[r,s,n]=e,o=Math.max(0,Math.min(100,n+parseFloat(t)));return[r,s,o]},m=(t,e,r)=>{const s=Math.max(t,e,r),n=s-Math.min(t,e,r),o=1-Math.abs(s+s-n-1),i=n&&(s==t?(e-r)/n:s==e?2+(r-t)/n:4+(t-e)/n);return[60*(i<0?i+6:i),o?n/o:0,(s+s-n)/2]},g=(t,e,r,s=e*Math.min(r,1-r),n=(o,i=(o+t/30)%12)=>r-s*Math.max(Math.min(i-3,9-i,1),-1))=>[n(0),n(8),n(4)],d=(t,e)=>{const r=parseInt(t,16);let s=(r>>16)+e;s>255?s=255:s<0&&(s=0);let n=(r>>8&255)+e;n>255?n=255:n<0&&(n=0);let o=(r&255)+e;return o>255?o=255:o<0&&(o=0),((o|n<<8|s<<16)+16777216).toString(16).slice(1)},l=(t,e,r=.5)=>{const s=[];for(let n=0;n<4;n++){const o=n===3?i=>i:Math.round;s[n]=o(t[n]+(e[n]-t[n])*r)}return`rgba(${s})`},j=(t,e)=>{const r=c(t);if(!r){(0,a.isNotProduction)()&&console.warn(t+" color is not rgba");return}return r[3]=e,`rgba(${r})`},b=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,w=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,V=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,z=t=>{if(!(0,a.isString)(t))return null;if(w.test(t))return{passthrough:t};if(b(t))return{cssVar:t};const e=t.match(V);if(!e)return null;const[,r,s,n]=e,o=s!==void 0?`0.${s}`:void 0,i=n&&n[0]==="="?n.slice(1):n;return{name:r,alpha:o,tone:i}},G=t=>(0,a.isString)(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),X=t=>{const e=[];let r="",s=0;for(const n of t){if(n==="("?s+=1:n===")"&&s>0&&(s-=1),n===","&&s===0){e.push(r),r="";continue}r+=n}return(r.length||!e.length)&&e.push(r),e},p=t=>(t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)),h=t=>.2126*p(t[0])+.7152*p(t[1])+.0722*p(t[2]),Z=(t,e)=>{const r=h(t)+.05,s=h(e)+.05;return r>s?r/s:s/r},k=(t,e=1,r=[255,255,255])=>e>=1?t:t.map((s,n)=>s*e+r[n]*(1-e)),D=(t,e)=>{(0,a.isString)(t)&&t.includes("rgb")&&(t=c(t).join(", ")),(0,a.isString)(t)&&(t=t.split(",").map(n=>parseFloat(n.trim()))),(0,a.isNumber)(e)&&(e+="");const r=x(t),s=e.slice(0,1);if(s==="-"||s==="+"){const n=d(r,parseFloat(e));return f(n).join(", ")}else{const[n,o,i]=t,[C,T]=m(n/255,o/255,i/255),R=Math.max(0,Math.min(100,parseFloat(e)))/100;return g(C,T,R).map(M=>Math.round(Math.max(0,Math.min(1,M))*255)).join(", ")}};
@@ -1 +1 @@
1
- import{deepClone as _,deepMerge as S,isDefined as l,isObject as C}from"@symbo.ls/utils";import{createSignal as v}from"@symbo.ls/signal";import*as A from"./defaultConfig/index.js";const b={},h={},f=A,u={},T=e=>e.replace(/_([a-z])/g,(o,t)=>t.toUpperCase());for(const e in f){const o=e.toLowerCase();u[o]=f[e];const t=T(o);t!==o&&(u[t]=f[e]),o!==e&&(u[e]=f[e])}const p={verbose:!1,useVariable:!0,useReset:!0,globalTheme:"auto",cssVars:b,cssMediaVars:h,CSS_VARS:b,CSS_MEDIA_VARS:h,_scratchConfig:!0,...u},g=(e,o)=>{if(!e)return null;if(e.__globalThemeSignal)return l(o)&&e.__globalThemeSignal.set(o),e.__globalThemeSignal;const t=l(o)?o:e.globalTheme,s=v(l(t)?t:"auto");return Object.defineProperty(e,"globalTheme",{get(){return s.get()},set(n){s.set(n)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"__globalThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},I=e=>e?g(e):null;g(p);const m=_(p),a={active:"0",0:p},P=e=>(l(e)&&(a.active=e),a[e||a.active]),i=[],R=e=>{e&&e._scratchConfig&&i.push(e)},M=()=>{i.pop()},d=e=>i.length?i[i.length-1]:a[e||a.active]||p,L=e=>{if(C(e))return a.active="1",a[1]=S(e,_(m)),g(a[1]),e},x=["useReset","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultIcons","useDefaultConfig"],O=["useVariable","globalTheme","verbose"],V=[["fontfamily","fontFamily","font_family"],["fontfamilytypes","fontFamilyTypes"],["semanticicons","semanticIcons"],["svgdata","svgData"]],y=e=>{for(const o of V){let t;for(const s of o){const n=e[s];C(n)&&(t=t?S(n,t):n)}if(t)for(const s of o)C(e[s])&&(e[s]=t)}},j=(e,o,{cleanBase:t=!1}={})=>{const s=t?null:d(),n=_(!t&&s&&s._scratchConfig?s:m);for(const c of x)delete n[c];for(const c of O)Object.prototype.hasOwnProperty.call(m,c)?n[c]=m[c]:delete n[c];const r=S(o||{},n);return r.cssVars={},r.cssMediaVars={},r.CSS_VARS=r.cssVars,r.CSS_MEDIA_VARS=r.cssMediaVars,r._scratchConfig=!0,y(r),g(r),e&&(a[e]=r),r};export{p as CONFIG,a as FACTORY,P as activateConfig,j as createConfig,h as cssMediaVars,b as cssVars,g as defineThemeSignal,d as getActiveConfig,I as getThemeSignal,M as popConfig,R as pushConfig,L as setActiveConfig,T as toCamel};
1
+ import{deepClone as S,deepMerge as b,isDefined as l,isObject as h}from"@symbo.ls/utils";import{createSignal as v}from"@symbo.ls/signal";import*as T from"./defaultConfig/index.js";const d={},C={},f=T,p={},x=e=>e.replace(/_([a-z])/g,(t,o)=>o.toUpperCase());for(const e in f){const t=e.toLowerCase();p[t]=f[e];const o=x(t);o!==t&&(p[o]=f[e]),t!==e&&(p[e]=f[e])}const i={verbose:!1,useVariable:!0,useReset:!0,globalTheme:"auto",cssVars:d,cssMediaVars:C,CSS_VARS:d,CSS_MEDIA_VARS:C,_scratchConfig:!0,...p},m=(e,t)=>{if(!e)return null;if(e.__globalThemeSignal)return l(t)&&e.__globalThemeSignal.set(t),e.__globalThemeSignal;const o=l(t)?t:e.globalTheme,s=v(l(o)?o:"auto");return Object.defineProperty(e,"globalTheme",{get(){return s.get()},set(r){s.set(r)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"__globalThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},D=e=>e?m(e):null,g=(e,t)=>{if(!e)return null;if(e.__resolvedThemeSignal)return l(t)&&e.__resolvedThemeSignal.set(t),e.__resolvedThemeSignal;const o=l(t)?t:e.resolvedTheme,s=v(l(o)?o:null);return Object.defineProperty(e,"resolvedTheme",{get(){return s.get()},set(r){s.set(r)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"__resolvedThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},I=e=>e?g(e):null;m(i),g(i);const _=S(i),a={active:"0",0:i},M=e=>(l(e)&&(a.active=e),a[e||a.active]),u=[],j=e=>{e&&e._scratchConfig&&u.push(e)},L=()=>{u.pop()},A=e=>u.length?u[u.length-1]:a[e||a.active]||i,w=e=>{if(h(e))return a.active="1",a[1]=b(e,S(_)),m(a[1]),g(a[1]),e},O=["useReset","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultIcons","useDefaultConfig"],y=["useVariable","globalTheme","verbose"],V=[["fontfamily","fontFamily","font_family"],["fontfamilytypes","fontFamilyTypes"],["semanticicons","semanticIcons"],["svgdata","svgData"]],P=e=>{for(const t of V){let o;for(const s of t){const r=e[s];h(r)&&(o=o?b(r,o):r)}if(o)for(const s of t)h(e[s])&&(e[s]=o)}},G=(e,t,{cleanBase:o=!1}={})=>{const s=o?null:A(),r=S(!o&&s&&s._scratchConfig?s:_);for(const c of O)delete r[c];for(const c of y)Object.prototype.hasOwnProperty.call(_,c)?r[c]=_[c]:delete r[c];const n=b(t||{},r);return n.cssVars={},n.cssMediaVars={},n.CSS_VARS=n.cssVars,n.CSS_MEDIA_VARS=n.cssMediaVars,n._scratchConfig=!0,P(n),m(n),g(n),e&&(a[e]=n),n};export{i as CONFIG,a as FACTORY,M as activateConfig,G as createConfig,C as cssMediaVars,d as cssVars,g as defineResolvedThemeSignal,m as defineThemeSignal,A as getActiveConfig,I as getResolvedThemeSignal,D as getThemeSignal,L as popConfig,j as pushConfig,w as setActiveConfig,x as toCamel};
@@ -1 +1 @@
1
- import{getActiveConfig as b,setActiveConfig as q,toCamel as G}from"./factory.js";import{setColor as W,setGradient as N,setFont as H,setFontFamily as L,setTheme as Y,setSvgIcon as $,setSVG as z,applyTypographySequence as B,applySpacingSequence as U,applyReset as J,applyTimingSequence as K,applyDocument as Q,setShadow as X}from"./system/index.js";import{deepMerge as Z,isObject as F,isArray as I}from"@symbo.ls/utils";import{isDomDocument as O,isHostObject as P,parkHostObject as k,resolveConfigDocument as M}from"./utils/host.js";const ee=(t,s)=>{const e=b(),{cssVars:r}=e,i=s.startsWith("--")?s:`--${s}`;return r[i]=t,t},f=t=>t,j={color:W,gradient:N,font:H,fontFamily:L,fontfamily:L,theme:Y,icons:$,semanticIcons:f,semanticicons:f,svg:z,svgData:f,typography:f,shadow:X,spacing:f,media:f,grid:f,class:f,timing:f,reset:f,unit:f,animation:f,vars:ee,sizes:f,shape:f},te=(t,s,e,r)=>{k(t,e,s);const i={};for(const o of r)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},se=(t,s,e)=>{const r=b(),i=G(t),o=i.toLowerCase(),l=r[i]||r[o]||r[t],n=P(l)?te(r,l,o,[i,o,t]):l,d=j[i]||j[o];if(d)try{const c=d(s,e);return n&&(n[e]=c),n}catch(c){r.verbose&&console.warn("Error setting",o,"value",s,e,c)}if(!d){const c=n||(r[o]={});return c[e]=s,c}r.verbose&&console.warn("Can not find",o,"method in scratch")},oe=(t,s)=>{const e=b(),r=t.toLowerCase();return P(s)?(k(e,r,s),e.verbose&&console.warn("[scratch] ignoring host object passed as the",r,"design-system family"),e[r]||e[t]):(Object.keys(s).sort((o,l)=>{const n=F(s[o])||I(s[o])?1:0,d=F(s[l])||I(s[l])?1:0;return n-d}).forEach(o=>{try{return se(r,s[o],o)}catch(l){e.verbose&&console.warn("Error setting",r,"value",s[o],o,l)}}),e[r]||e[t])},de=(t,s)=>{const e=s||b();e.globalTheme=t;const i=M(e)||(typeof document<"u"?document:null),o=i&&i.defaultView||(typeof window<"u"?window:null);if(i){const n=e.themeRoot||i.documentElement;if(t&&t!=="auto")n.setAttribute("data-theme",t),t==="dark"||t==="light"?n.style.colorScheme=t:n.style.colorScheme="light dark";else if(o&&o.matchMedia){const c=h=>{n.setAttribute("data-theme",h.matches?"dark":"light")},m=o.matchMedia("(prefers-color-scheme: dark)");if(c(m),n.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=c;try{m.addEventListener("change",c)}catch{m.addListener(c)}}}else n.setAttribute("data-theme","light"),n.style.colorScheme="light"}const l=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const n in e.cssVars)n.startsWith(l)&&delete e.cssVars[n];for(const n in e.cssMediaVars)delete e.cssMediaVars[n];if(i&&e.cssVars){const n=e.scopeSelector||":root",d=i.styleSheets;for(let c=0;c<d.length;c++)try{const m=d[c].cssRules;for(let h=0;h<m.length;h++)if(m[h].selectorText===n){for(const y in e.cssVars)m[h].style.setProperty(y,e.cssVars[y]);return e}}catch{}}return e},ne={},me=(t,s=ne)=>{let e=s.config||b();const{version:r,verbose:i,useVariable:o,useReset:l,useSvgSprite:n,useFontImport:d,useIconSprite:c,globalTheme:m,themeRoot:h,useDocumentTheme:y,useDefaultConfig:_,semanticIcons:T,hoverMedia:V,files:x,assets:D,...g}=t;s.newConfig&&(e=q(s.newConfig)),O(g.document)&&(e.__domDocument=g.document,delete g.document),O(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),x!==void 0&&(e.files=x),D!==void 0&&(e.assets=D),i!==void 0&&(e.verbose=i),o!==void 0&&(e.useVariable=o),l!==void 0&&(e.useReset=l),d!==void 0&&(e.useFontImport=d),n!==void 0&&(e.useSvgSprite=n),c!==void 0&&(e.useIconSprite=c),y!==void 0&&(e.useDocumentTheme=y),m!==void 0&&(e.globalTheme=m),h!==void 0&&(e.themeRoot=h),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),_!==void 0&&(e.useDefaultConfig=_),T!==void 0&&(e.semanticIcons=T),V!==void 0&&(e.hoverMedia=V),e.verbose&&console.log(e);const v=M(e)||(typeof document<"u"?document:null),S=v&&v.defaultView||(typeof window<"u"?window:null),p=v&&(e.themeRoot||v.documentElement);if(p&&typeof p.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")p.setAttribute("data-theme",e.globalTheme),e.globalTheme==="dark"||e.globalTheme==="light"?p.style.colorScheme=e.globalTheme:p.style.colorScheme="light dark";else if(S&&S.matchMedia){const u=A=>{p.setAttribute("data-theme",A.matches?"dark":"light")},C=S.matchMedia("(prefers-color-scheme: dark)");if(u(C),p.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=u;try{C.addEventListener("change",u)}catch{C.addListener(u)}}}else p.setAttribute("data-theme","light"),p.style.colorScheme="light";e.__svgCache||(e.__svgCache={});const w=Object.keys(g).filter(a=>!a.startsWith("__")),E=new Set(w);if(w.forEach(a=>{const u=a.toLowerCase();u!==a&&E.has(u)&&Z(g[u],g[a])}),w.map(a=>{const u=a.toLowerCase();if(!(u!==a&&E.has(u)))return oe(a,g[a])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),g.typography)try{B()}catch(a){e.verbose&&console.warn("Error applying typography sequence",a)}if(g.spacing)try{U()}catch(a){e.verbose&&console.warn("Error applying spacing sequence",a)}if(g.timing)try{K()}catch(a){e.verbose&&console.warn("Error applying timing sequence",a)}Q();const R=J();return R&&(e.reset=R),e};export{j as VALUE_TRANSFORMERS,de as changeGlobalTheme,me as set,oe as setEach,se as setValue};
1
+ import{getActiveConfig as v,setActiveConfig as G,toCamel as W}from"./factory.js";import{setColor as N,setGradient as H,setFont as Y,setFontFamily as F,setTheme as $,setSvgIcon as z,setSVG as B,applyTypographySequence as U,applySpacingSequence as J,applyReset as K,applyTimingSequence as Q,applyDocument as X,setShadow as Z}from"./system/index.js";import{deepMerge as ee,isObject as I,isArray as O}from"@symbo.ls/utils";import{isDomDocument as P,isHostObject as k,parkHostObject as M,resolveConfigDocument as j}from"./utils/host.js";const te=(t,s)=>{const e=v(),{cssVars:n}=e,i=s.startsWith("--")?s:`--${s}`;return n[i]=t,t},l=t=>t,q={color:N,gradient:H,font:Y,fontFamily:F,fontfamily:F,theme:$,icons:z,semanticIcons:l,semanticicons:l,svg:B,svgData:l,typography:l,shadow:Z,spacing:l,media:l,grid:l,class:l,timing:l,reset:l,unit:l,animation:l,vars:te,sizes:l,shape:l},se=(t,s,e,n)=>{M(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},oe=(t,s,e)=>{const n=v(),i=W(t),o=i.toLowerCase(),f=n[i]||n[o]||n[t],r=k(f)?se(n,f,o,[i,o,t]):f,d=q[i]||q[o];if(d)try{const c=d(s,e);return r&&(r[e]=c),r}catch(c){n.verbose&&console.warn("Error setting",o,"value",s,e,c)}if(!d){const c=r||(n[o]={});return c[e]=s,c}n.verbose&&console.warn("Can not find",o,"method in scratch")},re=(t,s)=>{const e=v(),n=t.toLowerCase();return k(s)?(M(e,n,s),e.verbose&&console.warn("[scratch] ignoring host object passed as the",n,"design-system family"),e[n]||e[t]):(Object.keys(s).sort((o,f)=>{const r=I(s[o])||O(s[o])?1:0,d=I(s[f])||O(s[f])?1:0;return r-d}).forEach(o=>{try{return oe(n,s[o],o)}catch(f){e.verbose&&console.warn("Error setting",n,"value",s[o],o,f)}}),e[n]||e[t])},me=(t,s)=>{const e=s||v();e.globalTheme=t;const i=j(e)||(typeof document<"u"?document:null),o=i&&i.defaultView||(typeof window<"u"?window:null);if(i){const r=e.themeRoot||i.documentElement;if(t&&t!=="auto")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 c=h=>{const y=h.matches?"dark":"light";r.setAttribute("data-theme",y),e.resolvedTheme=y},m=o.matchMedia("(prefers-color-scheme: dark)");if(c(m),r.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=c;try{m.addEventListener("change",c)}catch{m.addListener(c)}}}else r.setAttribute("data-theme","light"),e.resolvedTheme="light",r.style.colorScheme="light"}const f=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const r in e.cssVars)r.startsWith(f)&&delete e.cssVars[r];for(const r in e.cssMediaVars)delete e.cssMediaVars[r];if(i&&e.cssVars){const r=e.scopeSelector||":root",d=i.styleSheets;for(let c=0;c<d.length;c++)try{const m=d[c].cssRules;for(let h=0;h<m.length;h++)if(m[h].selectorText===r){for(const y in e.cssVars)m[h].style.setProperty(y,e.cssVars[y]);return e}}catch{}}return e},ne={},ue=(t,s=ne)=>{let e=s.config||v();const{version:n,verbose:i,useVariable:o,useReset:f,useSvgSprite:r,useFontImport:d,useIconSprite:c,globalTheme:m,themeRoot:h,useDocumentTheme:y,useDefaultConfig:C,semanticIcons:_,hoverMedia:V,files:x,assets:D,...g}=t;s.newConfig&&(e=G(s.newConfig)),P(g.document)&&(e.__domDocument=g.document,delete g.document),P(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),x!==void 0&&(e.files=x),D!==void 0&&(e.assets=D),i!==void 0&&(e.verbose=i),o!==void 0&&(e.useVariable=o),f!==void 0&&(e.useReset=f),d!==void 0&&(e.useFontImport=d),r!==void 0&&(e.useSvgSprite=r),c!==void 0&&(e.useIconSprite=c),y!==void 0&&(e.useDocumentTheme=y),m!==void 0&&(e.globalTheme=m),h!==void 0&&(e.themeRoot=h),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),C!==void 0&&(e.useDefaultConfig=C),_!==void 0&&(e.semanticIcons=_),V!==void 0&&(e.hoverMedia=V),e.verbose&&console.log(e);const b=j(e)||(typeof document<"u"?document:null),S=b&&b.defaultView||(typeof window<"u"?window:null),p=b&&(e.themeRoot||b.documentElement);if(p&&typeof p.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")p.setAttribute("data-theme",e.globalTheme),e.resolvedTheme=e.globalTheme,e.globalTheme==="dark"||e.globalTheme==="light"?p.style.colorScheme=e.globalTheme:p.style.colorScheme="light dark";else if(S&&S.matchMedia){const u=A=>{const L=A.matches?"dark":"light";p.setAttribute("data-theme",L),e.resolvedTheme=L},w=S.matchMedia("(prefers-color-scheme: dark)");if(u(w),p.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=u;try{w.addEventListener("change",u)}catch{w.addListener(u)}}}else p.setAttribute("data-theme","light"),e.resolvedTheme="light",p.style.colorScheme="light";e.__svgCache||(e.__svgCache={});const T=Object.keys(g).filter(a=>!a.startsWith("__")),E=new Set(T);if(T.forEach(a=>{const u=a.toLowerCase();u!==a&&E.has(u)&&ee(g[u],g[a])}),T.map(a=>{const u=a.toLowerCase();if(!(u!==a&&E.has(u)))return re(a,g[a])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),g.typography)try{U()}catch(a){e.verbose&&console.warn("Error applying typography sequence",a)}if(g.spacing)try{J()}catch(a){e.verbose&&console.warn("Error applying spacing sequence",a)}if(g.timing)try{Q()}catch(a){e.verbose&&console.warn("Error applying timing sequence",a)}X();const R=K();return R&&(e.reset=R),e};export{q as VALUE_TRANSFORMERS,me as changeGlobalTheme,ue as set,re as setEach,oe as setValue};
@@ -1 +1 @@
1
- import{isObject as A,isArray as R,isString as V}from"@symbo.ls/utils";import{getActiveConfig as M}from"../factory.js";import{colorStringToRgbaArray as T,getRgbTone as w,isCSSVar as E,parseColorToken as P}from"../utils/index.js";const L={light:"(prefers-color-scheme: light)",dark:"(prefers-color-scheme: dark)"},x=(r,n,u)=>{const e=u||M();if(!V(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if(E(r))return`var(${r})`;n&&r[n]&&(r=r[n]);let g,c,o;if(R(r))[g,c,o]=r;else{const t=P(r);if(!t){const{color:h,gradient:m}=e;let b=m[r]||h[r];return b?(n&&b[n]&&(b=b[n]),e.useVariable?`var(${b.var})`:b.value):r}if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;g=t.name,c=t.alpha,o=t.tone}const{color:d,gradient:l}=e;let s=d[g]||l[g];if(!s)return e.verbose&&console.warn("Can't find color ",g),r;if(n)if(s[n]!==void 0)s=s[n];else if(R(s)){const t=n.charCodeAt(0)===64?n.slice(1):n;t==="dark"?s=s[1]!==void 0?s[1]:s[0]:(t!=="light"&&e.verbose&&console.warn(r," - array-form color tokens only support light/dark; falling back to the light slot for scheme",n),s=s[0])}else e.verbose&&console.warn(r," - does not have ",n);if(V(s))return x(s,null,u);let a=s.rgb;if(!a){const t=e.useVariable?`var(${s.var})`:s.value;if(c&&t){const h=Math.round(parseFloat(c)*100);return`color-mix(in srgb, ${t} ${h}%, transparent)`}return t}return o&&!s[o]&&(a=w(a,o),s[o]={rgb:a,var:`${s.var}-${o}`}),s[o]&&(a=s[o].rgb),c?`rgba(${a}, ${c})`:o?`rgba(${a}, 1)`:e.useVariable?`var(${s.var})`:`rgb(${a})`},U=(r,n,u)=>{const e=u||M();if(n||(n=e.globalTheme==="auto"?null:e.globalTheme),!V(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if(E(r))return`var(${r})`;let g,c,o;if(R(r))g=r[0];else{const t=P(r);if(t){if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;g=t.name,c=t.alpha,o=t.tone}else g=r}const{color:d,gradient:l}=e,s=d[g]||l[g],a=A(s);if(a&&s.value)return x(r,`@${n}`,u);if(a){if(e.useVariable&&s.var)return c||o?x(r,null,u):`var(${s.var})`;if(n)return x(r,`@${n}`,u);{const t={};for(const h in s){if(h.charCodeAt(0)!==64)continue;const m=h.slice(1),b=e.media&&e.media[m]||L[m];if(!b)continue;const f="@media "+(b==="print"?`${b}`:`screen and ${b}`);t[f]=x(r,h,u)}return t}}else return e.verbose&&console.warn("Can't find color",r),r},j=(r,n,u,e)=>{const c=`--${e.varPrefix?e.varPrefix+"-":""}${n}-${u}`;let o;const d={};for(const l in r){if(l.charCodeAt(0)!==64)continue;const s=l.slice(1),a=r[l],t=a&&(a.value||a);!t||typeof t!="string"||(d[s]=t,(s==="light"||o===void 0)&&(o=t))}if(o!==void 0){e.cssVars[c]=o,e.cssMediaVars||(e.cssMediaVars={});for(const l in d){const s=`[data-theme="${l}"]`;if(e.cssMediaVars[s]||(e.cssMediaVars[s]={}),e.cssMediaVars[s][c]=d[l],l==="light"||l==="dark"){const a=`@media (prefers-color-scheme: ${l})`;e.cssMediaVars[a]||(e.cssMediaVars[a]={}),e.cssMediaVars[a][c]=d[l]}}return r.var=c,c}},D=(r,n,u)=>{const e=M();if(A(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(V(r)&&E(r)){const f=r.slice(2);if(r=x(f),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const i=f.split(" ");let p=e.color[i[0]];if(p&&!p.value&&!p.rgb&&(V(p)||R(p)||A(p))&&(e.color[i[0]]=D(p,i[0]),p=e.color[i[0]]),p&&p.value){let $=p.rgb;const S=i[1]!==void 0?i[1]:"1",C=i[2];C&&($=w($,C)),r=`rgba(${$}, ${S})`}else{const $=i[2],S=i[1]!==void 0?i[1]:"1";if($)try{const C=T(i[0]);C&&C.length>=3?r=`rgba(${w(C.slice(0,3).join(", "),$)}, ${S})`:r=i[0]}catch{r=i[0]}else r=i[0]}}}if(R(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),A(r)){const f={};for(const i in r)i!=="var"&&(f[i]=D(r[i],n,i.slice(0,1)==="@"?i.slice(1):i));return e.useVariable&&j(f,"color",n,e),f}const c=`--${e.varPrefix?e.varPrefix+"-":""}color-${n}`+(u?`-${u}`:"");let o=r.value||r;if(V(o)&&!o.includes("(")&&!o.startsWith("#")){const f=P(o);if(f&&f.name&&!f.passthrough&&!f.cssVar){const i=e.color[f.name];i&&!i.value&&!i.rgb&&(V(i)||R(i)||A(i))&&(e.color[f.name]=D(i,f.name));const p=e.color[f.name];if(p&&p.rgb){let $=p.rgb;f.tone&&($=w($,f.tone));const S=f.alpha?parseFloat(f.alpha):1;o=`rgba(${$}, ${S})`}}}const d=T(o),[l,s,a,t=1]=d,h=parseFloat(t.toFixed(2)),m=`${l}, ${s}, ${a}`,b=`rgba(${m}, ${h})`;return e.useVariable&&(e.cssVars[c]=b),{var:c,rgb:m,alpha:h,value:b}},q=(r,n,u)=>{const e=M();if(A(r)&&r.value!==void 0&&r.var!==void 0)return e.useVariable&&(e.cssVars[r.var]=r.value),r;if(V(r)&&E(r)&&(r=x(r.slice(2))),R(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),A(r)){const o={};for(const d in r)d!=="var"&&(o[d]=q(r[d],n,d.slice(0,1)==="@"?d.slice(1):d));return e.useVariable&&j(o,"gradient",n,e),o}const c=`--${e.varPrefix?e.varPrefix+"-":""}gradient-${n}`+(u?`-${u}`:"");return e.useVariable&&(e.cssVars[c]=r.value||r),{var:c,value:r.value||r}};export{L as STANDARD_SCHEME_QUERIES,x as getColor,U as getMediaColor,j as setAdaptiveSchemeVar,D as setColor,q as setGradient};
1
+ import{isObject as C,isArray as R,isString as $}from"@symbo.ls/utils";import{getActiveConfig as M}from"../factory.js";import{colorStringToRgbaArray as E,getRgbTone as w,isCSSVar as P,parseColorToken as D}from"../utils/index.js";const O={light:"(prefers-color-scheme: light)",dark:"(prefers-color-scheme: dark)"},S=(r,a,g)=>{const e=g||M();if(!$(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if(P(r))return`var(${r})`;a&&r[a]&&(r=r[a]);let f,d,s;if(R(r))[f,d,s]=r;else{const t=D(r);if(!t){const{color:o,gradient:V}=e;let h=V[r]||o[r];return h?(a&&h[a]&&(h=h[a]),e.useVariable?`var(${h.var})`:h.value):r}if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;f=t.name,d=t.alpha,s=t.tone}const{color:p,gradient:c}=e;let n=p[f]||c[f];if(!n)return e.verbose&&console.warn("Can't find color ",f),r;if(a)if(n[a]!==void 0)n=n[a];else if(R(n)){const t=a.charCodeAt(0)===64?a.slice(1):a;t==="dark"?n=n[1]!==void 0?n[1]:n[0]:(t!=="light"&&e.verbose&&console.warn(r," - array-form color tokens only support light/dark; falling back to the light slot for scheme",a),n=n[0])}else e.verbose&&console.warn(r," - does not have ",a);if($(n))return S(n,null,g);let u=n.rgb;if(!u){const t=e.useVariable?`var(${n.var})`:n.value;if((d||s)&&t){const o=d!==void 0?d:1;if(!s)return`rgb(from ${t} r g b / ${o})`;if(s.charCodeAt(0)===43||s.charCodeAt(0)===45){const h=parseFloat(s),l=h<0?"-":"+",i=Math.abs(h);return`rgb(from ${t} calc(r ${l} ${i}) calc(g ${l} ${i}) calc(b ${l} ${i}) / ${o})`}return`hsl(from ${t} h s ${s}% / ${o})`}return t}return s&&!n[s]&&(u=w(u,s),n[s]={rgb:u,var:`${n.var}-${s}`}),n[s]&&(u=n[s].rgb),d?`rgba(${u}, ${d})`:s?`rgba(${u}, 1)`:e.useVariable?`var(${n.var})`:`rgb(${u})`},j=(r,a,g)=>{const e=a||M();if(!$(r))return null;const f=D(r);if(f){if(f.passthrough){const o=E(f.passthrough);return o&&o.length>=3?{rgb:[o[0],o[1],o[2]],alpha:o[3]!==void 0?o[3]:1}:null}if(f.cssVar)return null}const d=f?f.name:r,{color:s,gradient:p}=e;let c=s[d]||p[d];if(!c){const o=E(r);return!o||o.length<3||o[0]===0&&o[1]===0&&o[2]===0&&o[3]===0&&r.toLowerCase()!=="transparent"?null:{rgb:[o[0],o[1],o[2]],alpha:o[3]!==void 0?o[3]:1}}if($(c))return j(c,e,g);if(c.rgb===void 0&&C(c)){const o=`@${g||"light"}`;c=c[o]!==void 0?c[o]:c["@light"]}if(!c||c.rgb===void 0)return null;let n=c.rgb;f&&f.tone&&(n=w(n,f.tone));const u=$(n)?n.split(",").map(o=>parseFloat(o.trim())):n,t=f&&f.alpha!==void 0?parseFloat(f.alpha):c.alpha!==void 0?c.alpha:1;return{rgb:u,alpha:t}},Q=(r,a,g)=>{const e=g||M();if(a||(a=e.globalTheme==="auto"?null:e.globalTheme),!$(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if(P(r))return`var(${r})`;let f,d,s;if(R(r))f=r[0];else{const t=D(r);if(t){if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;f=t.name,d=t.alpha,s=t.tone}else f=r}const{color:p,gradient:c}=e,n=p[f]||c[f],u=C(n);if(u&&n.value)return S(r,`@${a}`,g);if(u){if(e.useVariable&&n.var)return d||s?S(r,null,g):`var(${n.var})`;if(a)return S(r,`@${a}`,g);{const t={};for(const o in n){if(o.charCodeAt(0)!==64)continue;const V=o.slice(1),h=e.media&&e.media[V]||O[V];if(!h)continue;const l="@media "+(h==="print"?`${h}`:`screen and ${h}`);t[l]=S(r,o,g)}return t}}else return e.verbose&&console.warn("Can't find color",r),r},L=(r,a,g,e)=>{const d=`--${e.varPrefix?e.varPrefix+"-":""}${a}-${g}`;let s;const p={};for(const c in r){if(c.charCodeAt(0)!==64)continue;const n=c.slice(1),u=r[c],t=u&&(u.value||u);!t||typeof t!="string"||(p[n]=t,(n==="light"||s===void 0)&&(s=t))}if(s!==void 0){e.cssVars[d]=s,e.cssMediaVars||(e.cssMediaVars={});for(const c in p){const n=`[data-theme="${c}"]`;if(e.cssMediaVars[n]||(e.cssMediaVars[n]={}),e.cssMediaVars[n][d]=p[c],c==="light"||c==="dark"){const u=`@media (prefers-color-scheme: ${c})`;e.cssMediaVars[u]||(e.cssMediaVars[u]={}),e.cssMediaVars[u][d]=p[c]}}return r.var=d,d}},T=(r,a,g)=>{const e=M();if(C(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($(r)&&P(r)){const l=r.slice(2);if(r=S(l),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const i=l.split(" ");let b=e.color[i[0]];if(b&&!b.value&&!b.rgb&&($(b)||R(b)||C(b))&&(e.color[i[0]]=T(b,i[0]),b=e.color[i[0]]),b&&b.value){let m=b.rgb;const x=i[1]!==void 0?i[1]:"1",A=i[2];A&&(m=w(m,A)),r=`rgba(${m}, ${x})`}else{const m=i[2],x=i[1]!==void 0?i[1]:"1";if(m)try{const A=E(i[0]);A&&A.length>=3?r=`rgba(${w(A.slice(0,3).join(", "),m)}, ${x})`:r=i[0]}catch{r=i[0]}else r=i[0]}}}if(R(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),C(r)){const l={};for(const i in r)i!=="var"&&(l[i]=T(r[i],a,i.slice(0,1)==="@"?i.slice(1):i));return e.useVariable&&L(l,"color",a,e),l}const d=`--${e.varPrefix?e.varPrefix+"-":""}color-${a}`+(g?`-${g}`:"");let s=r.value||r;if($(s)&&!s.includes("(")&&!s.startsWith("#")){const l=D(s);if(l&&l.name&&!l.passthrough&&!l.cssVar){const i=e.color[l.name];i&&!i.value&&!i.rgb&&($(i)||R(i)||C(i))&&(e.color[l.name]=T(i,l.name));const b=e.color[l.name];if(b&&b.rgb){let m=b.rgb;l.tone&&(m=w(m,l.tone));const x=l.alpha?parseFloat(l.alpha):1;s=`rgba(${m}, ${x})`}}}const p=E(s),[c,n,u,t=1]=p,o=parseFloat(t.toFixed(2)),V=`${c}, ${n}, ${u}`,h=`rgba(${V}, ${o})`;return e.useVariable&&(e.cssVars[d]=h),{var:d,rgb:V,alpha:o,value:h}},F=(r,a,g)=>{const e=M();if(C(r)&&r.value!==void 0&&r.var!==void 0)return e.useVariable&&(e.cssVars[r.var]=r.value),r;if($(r)&&P(r)&&(r=S(r.slice(2))),R(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),C(r)){const s={};for(const p in r)p!=="var"&&(s[p]=F(r[p],a,p.slice(0,1)==="@"?p.slice(1):p));return e.useVariable&&L(s,"gradient",a,e),s}const d=`--${e.varPrefix?e.varPrefix+"-":""}gradient-${a}`+(g?`-${g}`:"");return e.useVariable&&(e.cssVars[d]=r.value||r),{var:d,value:r.value||r}};export{O as STANDARD_SCHEME_QUERIES,S as getColor,Q as getMediaColor,j as resolveColorRgb,L as setAdaptiveSchemeVar,T as setColor,F as setGradient};
@@ -1 +1 @@
1
- export*from"./color.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"./timing.js";export*from"./document.js";export*from"./svg.js";export*from"./reset.js";
@@ -0,0 +1 @@
1
+ import{isString as X}from"@symbo.ls/utils";import{getActiveConfig as Y}from"../factory.js";import{parseColorToken as Z,rgbToHSL as _,hslToRgb as k,relativeLuminance as T,contrastRatio as A,compositeOverBackdrop as S}from"../utils/index.js";import{getColor as D,resolveColorRgb as j}from"./color.js";const ee=(s,n,f={},u)=>{const r=u||Y(),{min:F=4.5,large:K=!1,scheme:N,meta:O=!1,maxIterations:V=15}=f,h=K?3:F,l=N||(r.globalTheme&&r.globalTheme!=="auto"?r.globalTheme:"light"),$=X(n)?n:String(n),g=Z(s),C=g&&!g.passthrough&&!g.cssVar?g.name:null,m=(e,t)=>O?{value:e,...t}:e;if(C){const e=r.color[`${C}Safe`];if(e){const t=`${$}@${l}`,o=e[t]!==void 0?e[t]:e[$];if(o!==void 0){const w=o&&o.rgb!==void 0?r.useVariable&&o.var?`var(${o.var})`:o.value:D(o,null,r);return m(w,{ratio:null,deviation:0,derived:!1,overridden:!0})}}}const I=D(s,l?`@${l}`:null,r),a=j(s,r,l),b=j(n,r,l);if(!a||!b)return r.verbose&&console.warn("getSafeInk: could not resolve",s,n,"\u2014 returning hue unchanged"),m(I,{ratio:null,deviation:0,derived:!1,overridden:!1,unresolved:!0});const c=S(b.rgb,b.alpha),B=S(a.rgb,a.alpha,c),v=A(B,c);if(v>=h-.02)return m(I,{ratio:v,deviation:0,derived:!1,overridden:!1});const[E,G,H]=_(a.rgb[0]/255,a.rgb[1]/255,a.rgb[2]/255),d=H*100,x=T(c)>.5,P=x?d:100-d,M=e=>{const t=x?d-e:d+e,o=Math.max(0,Math.min(100,t));return{rgb:k(E,G,o/100).map(W=>Math.max(0,Math.min(1,W))*255),L:o}},p=e=>{const{rgb:t}=M(e),o=S(t,a.alpha,c);return A(o,c)};let L=0,i=P;const y=p(i)>=h;if(y)for(let e=0;e<V;e++){const t=(L+i)/2;p(t)>=h?i=t:L=t}else L=i;const{rgb:q,L:z}=M(i),R=q.map(e=>Math.round(e)),J=p(i),Q=a.alpha<1?`rgba(${R.join(", ")}, ${a.alpha})`:`rgb(${R.join(", ")})`,U=Math.abs(z-d);return m(Q,{rgb:R,ratio:J,startRatio:v,deviation:U,derived:!0,overridden:!1,reachable:y})},ne=(s,n,f={},u)=>ee(s,n,{...f,meta:!0},u);export{ee as getSafeInk,ne as getSafeInkInfo};
@@ -1 +1 @@
1
- import{document as o,window as h,isString as p,isNumber as x,isNotProduction as d}from"@symbo.ls/utils";const c=t=>{if(t==="")return[0,0,0,0];if(t.toLowerCase()==="transparent")return[0,0,0,0];if(t[0]==="#")return t.length<7&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(t.length>4?t[4]+t[4]:"")),[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16),t.length>7?parseInt(t.substr(7,2),16)/255:1];if(t.indexOf("rgb")===-1&&o&&h){const e=o.body.appendChild(o.createElement("fictum")),r="rgb(1, 2, 3)";if(e.style.color=r,e.style.color!==r){o.body.removeChild(e);return}if(e.style.color=t,e.style.color===r||e.style.color==="")return o.body.removeChild(e),[0,0,0,0];t=h.getComputedStyle(e).color,o.body.removeChild(e)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(e=>+e)):[0,0,0,0]},O=(t,e,r=.5)=>(t=c(t),e=c(e),R(t,e,r)),E=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgb(${r},${s},${n})`},b=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return[r,s,n]},L=(t,e,r)=>"#"+(1<<24|t<<16|e<<8|r).toString(16).slice(1),l=([t,e,r])=>((1<<24)+(t<<16)+(e<<8)+r).toString(16).slice(1),A=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgba(${r},${s},${n},${e})`},F=(t,e,r=.5)=>{const s=[];for(let n=0;n<3;n++)s[n]=~~(t[n]+(e[n]-t[n])*r);return`rgb(${s})`},_=(t,e)=>{const[r,s,n]=e,a=Math.max(0,Math.min(100,n+parseFloat(t)));return[r,s,a]},w=(t,e,r)=>{const s=Math.max(t,e,r),n=s-Math.min(t,e,r),a=1-Math.abs(s+s-n-1),i=n&&(s==t?(e-r)/n:s==e?2+(r-t)/n:4+(t-e)/n);return[60*(i<0?i+6:i),a?n/a:0,(s+s-n)/2]},C=(t,e,r,s=e*Math.min(r,1-r),n=(a,i=(a+t/30)%12)=>r-s*Math.max(Math.min(i-3,9-i,1),-1))=>[n(0),n(8),n(4)],T=(t,e)=>{const r=parseInt(t,16);let s=(r>>16)+e;s>255?s=255:s<0&&(s=0);let n=(r>>8&255)+e;n>255?n=255:n<0&&(n=0);let a=(r&255)+e;return a>255?a=255:a<0&&(a=0),((a|n<<8|s<<16)+16777216).toString(16).slice(1)},R=(t,e,r=.5)=>{const s=[];for(let n=0;n<4;n++){const a=n===3?i=>i:Math.round;s[n]=a(t[n]+(e[n]-t[n])*r)}return`rgba(${s})`},H=(t,e)=>{const r=c(t);if(!r){d()&&console.warn(t+" color is not rgba");return}return r[3]=e,`rgba(${r})`},y=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,M=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,S=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,N=t=>{if(!p(t))return null;if(M.test(t))return{passthrough:t};if(y(t))return{cssVar:t};const e=t.match(S);if(!e)return null;const[,r,s,n]=e,a=s!==void 0?`0.${s}`:void 0,i=n&&n[0]==="="?n.slice(1):n;return{name:r,alpha:a,tone:i}},j=t=>p(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),V=t=>{const e=[];let r="",s=0;for(const n of t){if(n==="("?s+=1:n===")"&&s>0&&(s-=1),n===","&&s===0){e.push(r),r="";continue}r+=n}return(r.length||!e.length)&&e.push(r),e},z=(t,e)=>{p(t)&&t.includes("rgb")&&(t=c(t).join(", ")),p(t)&&(t=t.split(",").map(n=>parseFloat(n.trim()))),x(e)&&(e+="");const r=l(t),s=e.slice(0,1);if(s==="-"||s==="+"){const n=T(r,parseFloat(e));return b(n).join(", ")}else{const[n,a,i]=t,[u,f]=w(n/255,a/255,i/255),g=Math.max(0,Math.min(100,parseFloat(e)))/100;return C(u,f,g).map(m=>Math.round(Math.max(0,Math.min(1,m))*255)).join(", ")}};export{M as CSS_NATIVE_COLOR_REGEX,_ as changeLightness,c as colorStringToRgbaArray,T as getColorShade,z as getRgbTone,E as hexToRgb,b as hexToRgbArray,A as hexToRgba,C as hslToRgb,y as isCSSVar,j as isResolvedColor,O as mixTwoColors,F as mixTwoRgb,R as mixTwoRgba,H as opacify,N as parseColorToken,l as rgbArrayToHex,w as rgbToHSL,L as rgbToHex,V as splitTopLevelCommas};
1
+ import{document as i,window as h,isString as c,isNumber as l,isNotProduction as b}from"@symbo.ls/utils";const p=t=>{if(t==="")return[0,0,0,0];if(t.toLowerCase()==="transparent")return[0,0,0,0];if(t[0]==="#")return t.length<7&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(t.length>4?t[4]+t[4]:"")),[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16),t.length>7?parseInt(t.substr(7,2),16)/255:1];if(t.indexOf("rgb")===-1&&i&&h){const e=i.body.appendChild(i.createElement("fictum")),r="rgb(1, 2, 3)";if(e.style.color=r,e.style.color!==r){i.body.removeChild(e);return}if(e.style.color=t,e.style.color===r||e.style.color==="")return i.body.removeChild(e),[0,0,0,0];t=h.getComputedStyle(e).color,i.body.removeChild(e)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(e=>+e)):[0,0,0,0]},E=(t,e,r=.5)=>(t=p(t),e=p(e),y(t,e,r)),A=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgb(${r},${s},${n})`},w=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(o=>parseInt(o,16));return[r,s,n]},F=(t,e,r)=>"#"+(1<<24|t<<16|e<<8|r).toString(16).slice(1),C=([t,e,r])=>((1<<24)+(t<<16)+(e<<8)+r).toString(16).slice(1),_=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgba(${r},${s},${n},${e})`},H=(t,e,r=.5)=>{const s=[];for(let n=0;n<3;n++)s[n]=~~(t[n]+(e[n]-t[n])*r);return`rgb(${s})`},N=(t,e)=>{const[r,s,n]=e,o=Math.max(0,Math.min(100,n+parseFloat(t)));return[r,s,o]},T=(t,e,r)=>{const s=Math.max(t,e,r),n=s-Math.min(t,e,r),o=1-Math.abs(s+s-n-1),a=n&&(s==t?(e-r)/n:s==e?2+(r-t)/n:4+(t-e)/n);return[60*(a<0?a+6:a),o?n/o:0,(s+s-n)/2]},R=(t,e,r,s=e*Math.min(r,1-r),n=(o,a=(o+t/30)%12)=>r-s*Math.max(Math.min(a-3,9-a,1),-1))=>[n(0),n(8),n(4)],M=(t,e)=>{const r=parseInt(t,16);let s=(r>>16)+e;s>255?s=255:s<0&&(s=0);let n=(r>>8&255)+e;n>255?n=255:n<0&&(n=0);let o=(r&255)+e;return o>255?o=255:o<0&&(o=0),((o|n<<8|s<<16)+16777216).toString(16).slice(1)},y=(t,e,r=.5)=>{const s=[];for(let n=0;n<4;n++){const o=n===3?a=>a:Math.round;s[n]=o(t[n]+(e[n]-t[n])*r)}return`rgba(${s})`},j=(t,e)=>{const r=p(t);if(!r){b()&&console.warn(t+" color is not rgba");return}return r[3]=e,`rgba(${r})`},S=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,$=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,I=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,V=t=>{if(!c(t))return null;if($.test(t))return{passthrough:t};if(S(t))return{cssVar:t};const e=t.match(I);if(!e)return null;const[,r,s,n]=e,o=s!==void 0?`0.${s}`:void 0,a=n&&n[0]==="="?n.slice(1):n;return{name:r,alpha:o,tone:a}},z=t=>c(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),G=t=>{const e=[];let r="",s=0;for(const n of t){if(n==="("?s+=1:n===")"&&s>0&&(s-=1),n===","&&s===0){e.push(r),r="";continue}r+=n}return(r.length||!e.length)&&e.push(r),e},u=t=>(t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)),f=t=>.2126*u(t[0])+.7152*u(t[1])+.0722*u(t[2]),X=(t,e)=>{const r=f(t)+.05,s=f(e)+.05;return r>s?r/s:s/r},Z=(t,e=1,r=[255,255,255])=>e>=1?t:t.map((s,n)=>s*e+r[n]*(1-e)),k=(t,e)=>{c(t)&&t.includes("rgb")&&(t=p(t).join(", ")),c(t)&&(t=t.split(",").map(n=>parseFloat(n.trim()))),l(e)&&(e+="");const r=C(t),s=e.slice(0,1);if(s==="-"||s==="+"){const n=M(r,parseFloat(e));return w(n).join(", ")}else{const[n,o,a]=t,[x,m]=T(n/255,o/255,a/255),g=Math.max(0,Math.min(100,parseFloat(e)))/100;return R(x,m,g).map(d=>Math.round(Math.max(0,Math.min(1,d))*255)).join(", ")}};export{$ as CSS_NATIVE_COLOR_REGEX,N as changeLightness,p as colorStringToRgbaArray,Z as compositeOverBackdrop,X as contrastRatio,M as getColorShade,k as getRgbTone,A as hexToRgb,w as hexToRgbArray,_ as hexToRgba,R as hslToRgb,S as isCSSVar,z as isResolvedColor,E as mixTwoColors,H as mixTwoRgb,y as mixTwoRgba,j as opacify,V as parseColorToken,f as relativeLuminance,C as rgbArrayToHex,T as rgbToHSL,F as rgbToHex,G as splitTopLevelCommas,u as toLinearChannel};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@symbo.ls/scratch",
3
3
  "description": "Φ / CSS framework and methodology.",
4
4
  "author": "symbo.ls",
5
- "version": "3.14.766",
5
+ "version": "3.14.771",
6
6
  "files": [
7
7
  "dist",
8
8
  "*.js",