@symbo.ls/scratch 3.14.781 → 3.14.783
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/defaultConfig/index.js +1 -1
- package/dist/cjs/src/factory.js +1 -1
- package/dist/cjs/src/set.js +1 -1
- package/dist/cjs/src/system/index.js +1 -1
- package/dist/cjs/src/system/skin.js +1 -0
- package/dist/cjs/src/system/spacing.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/sequence.js +1 -1
- package/dist/esm/src/defaultConfig/index.js +1 -1
- package/dist/esm/src/factory.js +1 -1
- package/dist/esm/src/set.js +1 -1
- package/dist/esm/src/system/index.js +1 -1
- package/dist/esm/src/system/skin.js +1 -0
- package/dist/esm/src/system/spacing.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/sequence.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var m=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var a=(e,t)=>{for(var p in t)m(e,p,{get:t[p],enumerable:!0})},f=(e,t,p,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let x of n(t))!i.call(e,x)&&x!==p&&m(e,x,{get:()=>t[x],enumerable:!(s=c(t,x))||s.enumerable});return e},r=(e,t,p)=>(f(e,t,"default"),p&&f(p,t,"default"));var h=e=>f(m({},"__esModule",{value:!0}),e);var o={};a(o,{reset:()=>k,shape:()=>z,sizes:()=>v,skins:()=>b,vars:()=>u});module.exports=h(o);r(o,require("./sequence.js"),module.exports);r(o,require("./unit.js"),module.exports);r(o,require("./typography.js"),module.exports);r(o,require("./font.js"),module.exports);r(o,require("./font-family.js"),module.exports);r(o,require("./media.js"),module.exports);r(o,require("./spacing.js"),module.exports);r(o,require("./color.js"),module.exports);r(o,require("./theme.js"),module.exports);r(o,require("./shadow.js"),module.exports);r(o,require("./icons.js"),module.exports);r(o,require("./timing.js"),module.exports);r(o,require("./document.js"),module.exports);r(o,require("./responsive.js"),module.exports);r(o,require("./animation.js"),module.exports);r(o,require("./svg.js"),module.exports);r(o,require("./templates.js"),module.exports);r(o,require("./grid.js"),module.exports);r(o,require("./class.js"),module.exports);const k={},u={},v={},z={},b={};
|
package/dist/cjs/src/factory.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var A=Object.create;var m=Object.defineProperty;var
|
|
1
|
+
"use strict";var A=Object.create;var m=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var P=(e,t)=>{for(var o in t)m(e,o,{get:t[o],enumerable:!0})},T=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of y(t))!R.call(e,n)&&n!==o&&m(e,n,{get:()=>t[n],enumerable:!(s=V(t,n))||s.enumerable});return e};var I=(e,t,o)=>(o=e!=null?A(F(e)):{},T(t||!e||!e.__esModule?m(o,"default",{value:e,enumerable:!0}):o,e)),k=e=>T(m({},"__esModule",{value:!0}),e);var X={};P(X,{CONFIG:()=>i,CONFIG_MERGE_EXL:()=>b,FACTORY:()=>l,activateConfig:()=>E,aliasCaseVariants:()=>C,createConfig:()=>B,cssMediaVars:()=>d,cssVars:()=>v,defineResolvedThemeSignal:()=>p,defineThemeSignal:()=>f,getActiveConfig:()=>O,getResolvedThemeSignal:()=>j,getThemeSignal:()=>M,popConfig:()=>L,pushConfig:()=>G,setActiveConfig:()=>w,toCamel:()=>x});module.exports=k(X);var r=require("@symbo.ls/utils"),h=require("@symbo.ls/signal"),D=I(require("./defaultConfig/index.js"),1);const v={},d={},b=new Set,g=D,S={},x=e=>e.replace(/_([a-z])/g,(t,o)=>o.toUpperCase());for(const e in g){const t=e.toLowerCase();S[t]=g[e];const o=x(t);o!==t&&(S[o]=g[e]),t!==e&&(S[e]=g[e])}const i={verbose:!1,useVariable:!0,useReset:!0,globalTheme:"auto",cssVars:v,cssMediaVars:d,CSS_VARS:v,CSS_MEDIA_VARS:d,cssSkinVars:{},cssSkinFallback:{},_scratchConfig:!0,...S},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,h.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},M=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,h.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},j=e=>e?p(e):null;f(i),p(i);const _=(0,r.deepClone)(i),l={active:"0",0:i},E=e=>((0,r.isDefined)(e)&&(l.active=e),l[e||l.active]),u=[],G=e=>{e&&e._scratchConfig&&u.push(e)},L=()=>{u.pop()},O=e=>u.length?u[u.length-1]:l[e||l.active]||i,w=e=>{if((0,r.isObject)(e))return l.active="1",l[1]=(0,r.deepMerge)(e,(0,r.deepClone)(_),b),C(l[1]),f(l[1]),p(l[1]),e},N=["useReset","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultIcons","useDefaultConfig"],U=["useVariable","globalTheme","verbose"],z=[["fontfamily","fontFamily","font_family"],["fontfamilytypes","fontFamilyTypes"],["semanticicons","semanticIcons"],["svgdata","svgData"]],C=e=>{for(const t of z){let o;for(const s of t){const n=e[s];(0,r.isObject)(n)&&(o=o?(0,r.deepMerge)(o,n,b):n)}if(o)for(const s of t)(0,r.isObject)(e[s])&&(e[s]=o)}},B=(e,t,{cleanBase:o=!1}={})=>{const s=o?null:O(),n=(0,r.deepClone)(!o&&s&&s._scratchConfig?s:_);for(const c of N)delete n[c];for(const c of U)Object.prototype.hasOwnProperty.call(_,c)?n[c]=_[c]:delete n[c];const a=(0,r.deepMerge)(t||{},n,b);return a.cssVars={},a.cssMediaVars={},a.CSS_VARS=a.cssVars,a.CSS_MEDIA_VARS=a.cssMediaVars,a.cssSkinVars={},a.cssSkinFallback={},a._scratchConfig=!0,C(a),f(a),p(a),e&&(l[e]=a),a};
|
package/dist/cjs/src/set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var R=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var B=(t,s)=>{for(var e in s)R(t,e,{get:s[e],enumerable:!0})},K=(t,s,e,
|
|
1
|
+
"use strict";var R=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var B=(t,s)=>{for(var e in s)R(t,e,{get:s[e],enumerable:!0})},K=(t,s,e,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of $(s))!z.call(t,n)&&n!==e&&R(t,n,{get:()=>s[n],enumerable:!(r=Y(s,n))||r.enumerable});return t};var U=t=>K(R({},"__esModule",{value:!0}),t);var N={};B(N,{VALUE_TRANSFORMERS:()=>D,changeGlobalTheme:()=>Q,set:()=>G,setEach:()=>I,setValue:()=>F});module.exports=U(N);var m=require("./factory.js"),o=require("./system/index.js"),_=require("@symbo.ls/utils"),g=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)}}},X=(t,s)=>{const e=(0,m.getActiveConfig)(),{cssVars:r}=e,n=s.startsWith("--")?s:`--${s}`;return r[n]=t,t},d=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:d,semanticicons:d,svg:o.setSVG,svgData:d,typography:d,shadow:o.setShadow,spacing:d,media:d,grid:d,class:d,timing:d,reset:d,unit:d,animation:d,vars:X,sizes:d,shape:d,skins:d},J=(t,s,e,r)=>{(0,g.parkHostObject)(t,e,s);const n={};for(const i of r)t[i]===s&&(t[i]=n);return t.verbose&&console.warn("[scratch] design-system family",e,"resolved to a host object; parked it and allocated a plain bucket"),n},F=(t,s,e)=>{const r=(0,m.getActiveConfig)(),n=(0,m.toCamel)(t),i=n.toLowerCase(),u=r[n]||r[i]||r[t],c=(0,g.isHostObject)(u)?J(r,u,i,[n,i,t]):u,h=D[n]||D[i];if(h)try{const l=h(s,e);return c&&(c[e]=l),c}catch(l){r.verbose&&console.warn("Error setting",i,"value",s,e,l)}if(!h){const l=c||(r[i]={});return l[e]=s,l}r.verbose&&console.warn("Can not find",i,"method in scratch")},I=(t,s)=>{const e=(0,m.getActiveConfig)(),r=t.toLowerCase();return(0,g.isHostObject)(s)?((0,g.parkHostObject)(e,r,s),e.verbose&&console.warn("[scratch] ignoring host object passed as the",r,"design-system family"),e[r]||e[t]):s==null?(e.verbose&&console.warn("[scratch] skipping empty design-system family",r),e[r]||e[t]):(Object.keys(s).sort((i,u)=>{const c=(0,_.isObject)(s[i])||(0,_.isArray)(s[i])?1:0,h=(0,_.isObject)(s[u])||(0,_.isArray)(s[u])?1:0;return c-h}).forEach(i=>{try{return F(r,s[i],i)}catch(u){e.verbose&&console.warn("Error setting",r,"value",s[i],i,u)}}),e[r]||e[t])},Q=(t,s)=>{const e=s||(0,m.getActiveConfig)();e.globalTheme=t;const n=(0,g.resolveConfigDocument)(e)||(typeof document<"u"?document:null),i=n&&n.defaultView||(typeof window<"u"?window:null);if(n){const c=e.themeRoot||n.documentElement,h=t&&t!=="auto";if(c[T]=e,h)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 l=y=>{const S=y.matches?"dark":"light";c.setAttribute("data-theme",S),e.resolvedTheme=S},v=i.matchMedia("(prefers-color-scheme: dark)");l(v),c.style.colorScheme="light dark",W(e,v,l)}else w(e),c.setAttribute("data-theme","light"),e.resolvedTheme="light",c.style.colorScheme="light"}const u=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const c in e.cssVars)c.startsWith(u)&&delete e.cssVars[c];for(const c in e.cssMediaVars)delete e.cssMediaVars[c];if(n&&e.cssVars){const c=e.scopeSelector||":root",h=n.styleSheets;for(let l=0;l<h.length;l++)try{const v=h[l].cssRules;for(let y=0;y<v.length;y++)if(v[y].selectorText===c){for(const S in e.cssVars)v[y].style.setProperty(S,e.cssVars[S]);return e}}catch{}}return e},Z={},G=(t,s=Z)=>{let e=s.config||(0,m.getActiveConfig)();const{version:r,verbose:n,useVariable:i,useReset:u,useSvgSprite:c,useFontImport:h,useIconSprite:l,globalTheme:v,themeRoot:y,useDocumentTheme:S,useDefaultConfig:L,semanticIcons:A,hoverMedia:k,files:C,assets:M,...p}=t;s.newConfig&&(e=(0,m.setActiveConfig)(s.newConfig)),(0,g.isDomDocument)(p.document)&&(e.__domDocument=p.document,delete p.document),(0,g.isDomDocument)(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),C!==void 0&&(e.files=C),M!==void 0&&(e.assets=M),n!==void 0&&(e.verbose=n),i!==void 0&&(e.useVariable=i),u!==void 0&&(e.useReset=u),h!==void 0&&(e.useFontImport=h),c!==void 0&&(e.useSvgSprite=c),l!==void 0&&(e.useIconSprite=l),S!==void 0&&(e.useDocumentTheme=S),v!==void 0&&(e.globalTheme=v),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),k!==void 0&&(e.hoverMedia=k),e.verbose&&console.log(e);const E=(0,g.resolveConfigDocument)(e)||(typeof document<"u"?document:null),V=E&&E.defaultView||(typeof window<"u"?window:null),f=E&&(e.themeRoot||E.documentElement);if(f&&typeof f.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")w(e),f.setAttribute("data-theme",e.globalTheme),e.resolvedTheme=e.globalTheme,f[T]=e,e.globalTheme==="dark"||e.globalTheme==="light"?f.style.colorScheme=e.globalTheme:f.style.colorScheme="light dark";else if(f[T]&&f[T]!==e&&f.hasAttribute("data-theme"))w(e),e.resolvedTheme=f.getAttribute("data-theme");else if(V&&V.matchMedia){const b=H=>{const O=H.matches?"dark":"light";f.setAttribute("data-theme",O),e.resolvedTheme=O},j=V.matchMedia("(prefers-color-scheme: dark)");b(j),f.style.colorScheme="light dark",f[T]=e,W(e,j,b)}else w(e),f.setAttribute("data-theme","light"),e.resolvedTheme="light",f.style.colorScheme="light",f[T]=e;e.__svgCache||(e.__svgCache={}),(0,m.aliasCaseVariants)(p);const x=Object.keys(p).filter(a=>!a.startsWith("__")),P=new Set(x);if(x.forEach(a=>{const b=a.toLowerCase();b!==a&&P.has(b)&&(0,_.deepMerge)(p[b],p[a],m.CONFIG_MERGE_EXL)}),x.map(a=>{const b=a.toLowerCase();if(!(b!==a&&P.has(b)))return I(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,o.applyTypographySequence)()}catch(a){e.verbose&&console.warn("Error applying typography sequence",a)}if(p.spacing)try{(0,o.applySpacingSequence)()}catch(a){e.verbose&&console.warn("Error applying spacing sequence",a)}if(p.timing)try{(0,o.applyTimingSequence)()}catch(a){e.verbose&&console.warn("Error applying timing sequence",a)}try{(0,o.applySkins)()}catch(a){e.verbose&&console.warn("Error applying skins",a)}(0,o.applyDocument)();const q=(0,o.applyReset)();return q&&(e.reset=q),e};
|
|
@@ -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("./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
|
+
"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);o(r,require("./skin.js"),module.exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var h=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var g=(n,e)=>{for(var t in e)h(n,t,{get:e[t],enumerable:!0})},x=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of v(e))!V.call(n,r)&&r!==t&&h(n,r,{get:()=>e[r],enumerable:!(o=O(e,r))||o.enumerable});return n};var R=n=>x(h({},"__esModule",{value:!0}),n);var j={};g(j,{__resetSkinWarnings:()=>F,applySkins:()=>P,buildSkinVarStyles:()=>_});module.exports=R(j);var c=require("@symbo.ls/utils"),w=require("../factory.js");const C=new Set(["fallback"]),S=new Set,u=(n,e)=>{S.has(n)||(S.add(n),(0,c.isLoudDevRuntime)()&&console.warn(e))},F=()=>{S.clear()},p=n=>{for(const e in n)delete n[e];return n},P=()=>{const n=(0,w.getActiveConfig)(),e=(0,c.isObject)(n.cssSkinVars)?p(n.cssSkinVars):n.cssSkinVars={},t=(0,c.isObject)(n.cssSkinFallback)?p(n.cssSkinFallback):n.cssSkinFallback={},o=n.skins;if(!(0,c.isObject)(o))return e;const r=n.varPrefix?n.varPrefix+"-":"",i=n.color||{},k=n.cssVars||{},y=s=>(0,c.isString)(s)&&Object.prototype.hasOwnProperty.call(i,s)?`var(--${r}color-${s})`:s;for(const s in o){const a=o[s];if(!(0,c.isObject)(a))continue;const m={};for(const l in a){if(C.has(l))continue;const $=a[l];if((0,c.isObject)($))for(const f in $){const d=`--${r}theme-${l}-${f}`;n.useVariable!==!1&&!(d in k)&&u(`${s}/${l}/${f}`,`[scratch] skin "${s}" rewrites theme "${l}" param "${f}", which the theme does not declare \u2014 no element reads ${d}, so the skin changes nothing there. Declare "${f}" on the "${l}" theme (its no-skin value).`),m[d]=y($[f])}}e[s]=m,(0,c.isString)(a.fallback)&&(t[s]=a.fallback)}for(const s in t){const a=t[s];e[a]||(u(`${s}/fallback/${a}`,`[scratch] skin "${s}" falls back to "${a}", which is not a declared skin \u2014 the reduced-transparency fallback is skipped.`),delete t[s])}return e},b=(n,e)=>{const t=`[data-skin="${n}"]`;return!e||e===":root"?`:root${t}, ${t}`:`${e}${t}, ${t} ${e}, ${e} ${t}`},_=(n,e,t)=>{const o={};if(!(0,c.isObject)(n))return o;for(const i in n)o[b(i,t)]=n[i];const r={};for(const i in e||{}){const k=n[e[i]];k&&(r[b(i,t)]=k)}return Object.keys(r).length&&(o["@media (prefers-reduced-transparency: reduce)"]=r),o};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var B=(t,e)=>{for(var n in e)p(t,n,{get:e[n],enumerable:!0})},C=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let
|
|
1
|
+
"use strict";var p=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var B=(t,e)=>{for(var n in e)p(t,n,{get:e[n],enumerable:!0})},C=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of q(e))!G.call(t,o)&&o!==n&&p(t,o,{get:()=>e[o],enumerable:!(s=I(e,o))||s.enumerable});return t};var f=t=>C(p({},"__esModule",{value:!0}),t);var M={};B(M,{applySpacingSequence:()=>A,checkIfBoxSize:()=>y,getSpacingBasedOnRatio:()=>N,getSpacingByKey:()=>h,splitSpacedValue:()=>F});module.exports=f(M);var m=require("@symbo.ls/utils"),a=require("@symbo.ls/utils"),g=require("../factory.js"),i=require("../utils/index.js");const b=t=>{const n=(0,g.getActiveConfig)().spacing||{},s=parseFloat(t.spacingRatio),o={...n,ratio:Number.isFinite(s)?s:n.ratio,sequence:{},scales:{}};return(0,i.generateSequence)(o),o},k=t=>{for(const e in t){const n=t[e];if(!(e.slice(0,1)==="@"))continue;const{type:o,base:r,ratio:c,range:u,subSequence:S,h1Matches:l,unit:d}=t;(0,a.merge)(n,{type:o,base:r,ratio:c,range:u,subSequence:S,h1Matches:l,unit:d,sequence:{},scales:{},templates:{},vars:{}}),(0,i.generateSequence)(n),(0,i.applyMediaSequenceVars)(t,e)}},y=t=>{const e=t.toLowerCase(),n=e.includes("width")||e.includes("height"),s=e.includes("border")||e.includes("outline");return n&&!s},A=()=>{const t=(0,g.getActiveConfig)(),{spacing:e}=t;(0,i.generateSequence)(e),(0,i.applySequenceVars)(e),k(e)},V=t=>{const e=(0,g.getActiveConfig)(),{spacing:n}=e;return!t||!t.sequence?n:Object.keys(t.sequence).length>0?t:(0,i.generateSequence)(t)},h=(t,e="padding",n,s)=>{const o=V(n);if((0,a.isString)(t)){if(!s&&/^(?:env|var)\(/.test(t.trim()))return{[e]:t};if(!s&&t.includes("(")){const c=(0,i.getFnPrefixAndValue)(t);s=c[0],t=c[1]}}const r=s?[t]:(0,a.isString)(t)&&t.includes("(")?(0,i.splitTopLevelSpaces)(t):(0,m.arrayzeValue)(t);if((0,a.isArray)(r)){if(r.length>1){let c="";e==="borderWidth"&&(e="border",c="Width");const u={2:["Block","Inline"],3:["BlockStart","Inline","BlockEnd"],4:["BlockStart","InlineEnd","BlockEnd","InlineStart"]},S=(l,d)=>(0,i.getSequenceValuePropertyPair)(r[d],e+l+c,o,s);return u[r.length].map((l,d)=>S(l,d))}return(0,i.getSequenceValuePropertyPair)(t,e,o,s)}},N=(t,e,n,s)=>{const o=(0,g.getActiveConfig)(),{spacing:r}=o;let c=n||t[e];if(!s&&(0,a.isString)(c)&&/^(?:env|var)\(/.test(c.trim()))return{[e]:c};if(!s&&(0,a.isString)(c)&&c.includes("(")){const u=(0,i.getFnPrefixAndValue)(c);s=u[0],c=u[1]}if(t.spacingRatio){const u=b(t);return h(c,e,u,s)}return h(c,e,r,s)},F=t=>{const e=n=>{const s=["+","-","*","/"].includes(n),o=i.CSS_UNITS.some(c=>t.includes(c));return s||o?n:n.length<3&&/[A-Z]/.test(n)?n+"_default":n};return t.split(",").map(n=>n.trim()).map(e).join(",").split(" ").map(e).join(" ")};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var x=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var K=(e,n)=>{for(var o in n)x(e,o,{get:n[o],enumerable:!0})},N=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of X(n))!Y.call(e,i)&&i!==o&&x(e,i,{get:()=>n[i],enumerable:!(r=J(n,i))||r.enumerable});return e};var F=e=>N(x({},"__esModule",{value:!0}),e);var le={};K(le,{getMediaTheme:()=>M,getTheme:()=>oe,setMediaTheme:()=>A,setTheme:()=>ie});module.exports=F(le);var $=require("./color.js"),B=require("./shadow.js"),T=require("./border.js"),O=require("../factory.js"),V=require("../utils/color.js"),a=require("@symbo.ls/utils");const G=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"]),L=["color","Color","background","Background","fill","Fill","stroke","Stroke"],D=e=>{for(let n=0;n<L.length;n++)if(e.includes(L[n]))return!0;return!1},I={boxShadow:B.resolveShadowValue,textShadow:B.resolveShadowValue,border:T.resolveBorderValue,borderTop:T.resolveBorderValue,borderRight:T.resolveBorderValue,borderBottom:T.resolveBorderValue,borderLeft:T.resolveBorderValue,outline:T.resolveBorderValue,columnRule:T.resolveBorderValue},ee=e=>{if(!e)return!1;const n=(0,V.parseColorToken)(e);return!n||!n.name||n.passthrough||n.cssVar?!1:n.alpha!==void 0||n.tone!==void 0},W=new Set,ne=(e,n,o,r,i,l)=>{if(!(0,a.isLoudDevRuntime)())return;const c=`${e}::${n}::${o||""}::${r}`;W.has(c)||(W.add(c),console.warn(`[smbls/scratch] theme param "${n}" on "${e}"`+(o?` (${o})`:"")+` did not fully resolve: "${r}" -> "${i}" still contains the unresolved token "${l}". This is not valid CSS \u2014 the browser will drop the whole declaration. Register "${l}" as a design-system color token or fix the typo.`))},_=(e,n,o,r)=>{const i=I[n];if(!i)return(0,$.getColor)(o,r);let l=null;const c=i(o,r,b=>{!l&&ee(b)&&(l=b)});return l&&ne(e,n,r,o,c,l),c},oe=(e,n)=>M(e,n),re=e=>(0,a.isObject)(e)&&(0,a.isObjectLike)(e.value),te=e=>{for(const n in e){const o=e[n];if((0,a.isString)(o)&&o.startsWith("var(--"))return!0}return!1},ie=(e,n)=>{const o=(0,O.getActiveConfig)();return re(e)?!o.useVariable&&te(e)?e:A(e.value,n):A(e,n)},z=(e,n)=>{const o=new Set;for(const r of n){const i=r.slice(0,1);if(!(i==="@"||i==="."||i===":")&&D(r))for(const l in e){if(o.has(l))continue;const c=e[l]?.[r];if(c===void 0)continue;const b=(0,$.getColor)(c,`@${l}`);b!==void 0&&(0,a.isString)(b)&&/^[a-z][a-zA-Z]+$/.test(b)&&!G.has(b)&&o.add(l)}}return o},se=e=>e.startsWith("[data-theme=")||e.startsWith("@media"),R=(e,n)=>{for(const o in n){const r=n[o];(0,a.isObject)(r)?R(e[o]||(e[o]={}),r):e[o]=r}return e},H=(e,n,o,r)=>{if(R(e,{[`[data-theme="${n}"] &`]:o}),n!=="light"&&n!=="dark")return;const i=(0,$.schemeMediaQuery)(n,r);i&&R(e,{[i]:{[(0,$.schemeGuardSelector)(r)]:o}})},U=(e,n,o,r)=>{const i=o.globalTheme!==void 0?o.globalTheme:"auto",l=i&&i!=="auto"?String(i).replace(/^'|'$/g,""):null,c=new Set(r?Object.keys(r):[]);for(const u in e)if(e[u])for(const s of Object.keys(e[u]))c.add(s);const b=z(e,c),f={};for(const u of c){const s=u.slice(0,1);if(s==="@")continue;if(s==="."||s===":"){const d={};for(const S in e)(0,a.isObjectLike)(e[S]?.[u])&&(d[S]=e[S][u]);const h=r&&(0,a.isObjectLike)(r[u])?r[u]:void 0;if(!Object.keys(d).length&&!h)continue;const y=s==="."?u.slice(1):u.replace(/^:+/,"");f[u]=U(d,`${n}-${y}`,o,h);continue}const t=r&&!(0,a.isObjectLike)(r[u])?r[u]:void 0,g=new Set(Object.keys(e));t!==void 0&&(g.add("light"),g.add("dark"),l&&g.add(l));const p={};let k;for(const d of g){if(b.has(d))continue;let h=e[d]?.[u];if((h===void 0||(0,a.isObjectLike)(h))&&(h=t),h===void 0)continue;const y=_(n,u,h,`@${d}`);y!==void 0&&(p[d]=y,(l&&d===l||!l&&(d==="light"||k===void 0))&&(k=y))}const m={},w=Object.keys(p).filter(d=>p[d]!==k);if(w.length){const d=p.light!==void 0?p.light:k,h=p.dark!==void 0?p.dark:k;if(D(u)&&(0,$.isPlainColor)(d)&&(0,$.isPlainColor)(h)){m[u]=d===h?d:`light-dark(${d}, ${h})`;for(const y in p)y==="light"||y==="dark"||H(m,y,{[u]:p[y]},o)}else{k!==void 0&&(m[u]=k);for(const y of w)H(m,y,{[u]:p[y]},o)}}else{if(k===void 0)continue;m[u]=k}R(f,m),f[`.${u}`]=m}return(f.background||f.color||f.backgroundColor)&&(f[".inversed"]={color:f.background||f.backgroundColor,background:f.color}),f},E=(e,n,o,r)=>{const{cssVars:i}=o;o.cssMediaVars||(o.cssMediaVars={});const l=o.cssMediaVars,c=o.globalTheme!==void 0?o.globalTheme:"auto",b=c&&c!=="auto"?String(c).replace(/^'|'$/g,""):null,f={},u=new Set(r?Object.keys(r):[]);for(const t in e)if(e[t])for(const g of Object.keys(e[t]))u.add(g);const s=z(e,u);for(const t of u){const g=t.slice(0,1),p=(0,a.isObjectLike)(r?.[t])||Object.values(e).some(k=>(0,a.isObjectLike)(k?.[t]));if(g==="."&&p){const k=t.slice(1),m={};for(const d in e)(0,a.isObjectLike)(e[d]?.[t])&&(m[d]=e[d][t]);const w=(0,a.isObjectLike)(r?.[t])?r[t]:void 0;f[t]=E(m,`${n}-${k}`,o,w)}else if(g===":"&&p){const k=t.replace(/^:+/,""),m={};for(const d in e)(0,a.isObjectLike)(e[d]?.[t])&&(m[d]=e[d][t]);const w=(0,a.isObjectLike)(r?.[t])?r[t]:void 0;f[t]=E(m,`${n}-${k}`,o,w)}else if(g!=="@"&&g!=="."&&g!==":"){const m=`--${o.varPrefix?o.varPrefix+"-":""}theme-${n}-${t}`,w=r&&!(0,a.isObjectLike)(r[t])?r[t]:void 0,d=new Set(Object.keys(e));w!==void 0&&(d.add("light"),d.add("dark"),b&&d.add(b));let h,y=!1;for(const S of d){if(s.has(S))continue;let j=e[S]?.[t];if((j===void 0||(0,a.isObjectLike)(j))&&(j=w),j===void 0)continue;const v=_(n,t,j,`@${S}`);if(v===void 0)continue;y=!0,(b&&S===b||!b&&(S==="light"||h===void 0))&&(h=v);const C=`[data-theme="${S}"]`;if(l[C]||(l[C]={}),l[C][m]=v,S==="dark"||S==="light"){const q=`@media (prefers-color-scheme: ${S})`;l[q]||(l[q]={}),l[q][m]=v}}if(h!==void 0&&(i[m]=h),!y)continue;f[t]=`var(${m})`,f[`.${t}`]={[t]:f[t]}}}return(f.background||f.color||f.backgroundColor)&&(f[".inversed"]={color:f.background||f.backgroundColor,background:f.color}),f},A=(e,n,o,r)=>{const i=(0,O.getActiveConfig)(),{cssVars:l}=i,c={value:e},b=!o&&!r;let f,u;if((0,a.isObjectLike)(e)){if(b&&i.useVariable){const s={},t={};for(const g in e)g.startsWith("@")?(0,a.isObjectLike)(e[g])&&(s[g.slice(1)]=e[g]):t[g]=e[g];(Object.keys(s).length||Object.keys(t).length)&&(u=E(s,n,i,t),Object.assign(c,u))}else if(b){const s={},t={};for(const g in e)g.startsWith("@")?(0,a.isObjectLike)(e[g])&&(s[g.slice(1)]=e[g]):t[g]=e[g];f=U(s,n,i,t),Object.assign(c,f)}for(const s in e){const t=s.slice(0,1),g=e[s];if(t==="@"||t===":"||t==="."){const p=t==="@"&&s;c[s]=A(g,n,s,r||p)}else if(!b){const p=_(n,s,g,r),k=[...new Set([r,o].filter(h=>h).map(h=>h.slice(1)))],m=k.length?"-"+k.join("-"):"",d=`--${i.varPrefix?i.varPrefix+"-":""}theme-${n}${m}-${s}`;i.useVariable?(i.useThemeSuffixedVars&&(l[d]=p),c[s]=`var(${d})`):c[s]=p,c[`.${s}`]={[s]:c[s]}}}if(f)for(const s in f){const t=s.slice(0,1);(t==="."||t===":")&&(0,a.isObjectLike)(e[s])&&(c[s]=f[s])}if(u)for(const s in u){const t=s.slice(0,1);(t==="."||t===":")&&(0,a.isObjectLike)(e[s])&&(c[s]=u[s])}!c[".inversed"]&&(c.background||c.color||c.backgroundColor)&&(c[".inversed"]={color:c.background||c.backgroundColor,background:c.color})}if((0,a.isString)(e)&&(0,V.isCSSVar)(e)){const t=i.theme[e.slice(2)];return M(t,r)}return c},P=(e,n)=>{const o={};for(const r in e){const i=r.slice(0,1);if((0,a.isObjectLike)(e[r]))if(n&&se(r))o[r]=R({},e[r]);else{if(i==="@")continue;i===":"?o[`&${r}`]=P(e[r],n):i==="."&&(o[`&${r}`]=P(e[r],n))}else o[r]=e[r]}return o},Q=(e,n)=>{const o=n.shift();return e[o]?Q(e[o],n):e},Z=(e,n)=>(0,a.isArray)(n)?Q(e,n):(0,a.isString)(n)&&e[n]?e[n]:e,ce=(e,n)=>(0,a.isString)(e)&&(0,V.isCSSVar)(e)?M(e.slice(2)):e,ae=e=>ce(e,ae),M=(e,n)=>{const o=(0,O.getActiveConfig)();if((0,a.isString)(e)&&(0,V.isCSSVar)(e)&&(e=M(e.slice(2))),!e||!(0,a.isString)(e)){o.verbose&&console.warn(`${e} - Theme is not a string`);return}const[r,...i]=(0,a.isArray)(e)?e:e.split(" ");let l=o.theme[r];return l&&i.length?l=Z(l,i):l&&n&&(l=Z(l,n)),P(l,!o.useVariable)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var m=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var R=(r,t)=>{for(var e in t)m(r,e,{get:t[e],enumerable:!0})},T=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of C(t))!E.call(r,n)&&n!==e&&m(r,n,{get:()=>t[n],enumerable:!(i=B(t,n))||i.enumerable});return r};var O=r=>T(m({},"__esModule",{value:!0}),r);var b={};R(b,{resolveColorsInGradient:()=>g,splitTransition:()=>L,transformBackgroundImage:()=>V,transformBorder:()=>G,transformBorderRadius:()=>D,transformBoxShadow:()=>z,transformDuration:()=>K,transformGridTemplate:()=>F,transformShadow:()=>_,transformSize:()=>h,transformSizeRatio:()=>W,transformTextStroke:()=>I,transformTransition:()=>j,transfromGap:()=>$});module.exports=O(b);var f=require("@symbo.ls/utils"),d=require("../factory.js"),s=require("../system/index.js"),o=require("../utils/index.js");const A=new Set(["to","top","bottom","left","right","center","at","circle","ellipse","closest-side","farthest-side","closest-corner","farthest-corner"]),S=/^-?[A-Z][0-9]?$/,G=r=>(0,s.resolveBorderValue)(r),I=r=>{if((0,f.isString)(r))return 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 e=(0,s.getColor)(t);return(0,o.isResolvedColor)(e)?e:t}).join(" ")},_=(r,t)=>(0,s.getShadow)(r,t),z=(r,t)=>{if((0,f.isString)(r))return o.CSS_NATIVE_COLOR_REGEX.test(r)?r:(0,o.splitTopLevelCommas)(r).map(e=>(e=e.trim(),e?e.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 n=(0,s.getColor)(i);if((0,o.isResolvedColor)(n)){const l=(0,s.getMediaColor)(i,t);return(0,f.isObject)(l)?Object.values(l).filter(p=>p.includes(": "+t))[0]:l}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(", ")},g=(r,t)=>{const e=r.indexOf("(");if(e===-1)return r;const i=r.slice(0,e+1),n=r.slice(e+1,r.lastIndexOf(")")),u=")",p=(0,o.splitTopLevelCommas)(n).map(a=>(a=a.trim(),a.split(/\s+/).map(c=>{if(!c||/^\d/.test(c)||c==="0"||A.has(c)||c==="transparent"||o.CSS_NATIVE_COLOR_REGEX.test(c))return c;const x=(0,s.getColor)(c);return(0,o.isResolvedColor)(x)?x:c}).join(" ")));return i+p.join(", ")+u},V=(r,t)=>{if(!(0,f.isString)(r))return;const e=(0,d.getActiveConfig)();return(0,o.splitTopLevelCommas)(r).map(i=>{const n=i.trim();if((0,o.isCSSVar)(n))return`var(${n})`;if(/^var\(/.test(n)||n.includes("url"))return n;if(e.gradient?.[n]){const u=(0,s.getMediaColor)(n,t);if((0,f.isString)(u))return u;if((0,f.isObject)(u)){for(const l in u)if((0,f.isString)(u[l]))return u[l]}return n}return n.includes("gradient")?g(n,t):n.includes("/")||n.startsWith("http")||n.includes(".")&&!(0,o.parseColorToken)(n)?`url(${n})`:n}).join(", ")},$=r=>(0,f.isString)(r)&&
|
|
1
|
+
"use strict";var m=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var R=(r,t)=>{for(var e in t)m(r,e,{get:t[e],enumerable:!0})},T=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of C(t))!E.call(r,n)&&n!==e&&m(r,n,{get:()=>t[n],enumerable:!(i=B(t,n))||i.enumerable});return r};var O=r=>T(m({},"__esModule",{value:!0}),r);var b={};R(b,{resolveColorsInGradient:()=>g,splitTransition:()=>L,transformBackgroundImage:()=>V,transformBorder:()=>G,transformBorderRadius:()=>D,transformBoxShadow:()=>z,transformDuration:()=>K,transformGridTemplate:()=>F,transformShadow:()=>_,transformSize:()=>h,transformSizeRatio:()=>W,transformTextStroke:()=>I,transformTransition:()=>j,transfromGap:()=>$});module.exports=O(b);var f=require("@symbo.ls/utils"),d=require("../factory.js"),s=require("../system/index.js"),o=require("../utils/index.js");const A=new Set(["to","top","bottom","left","right","center","at","circle","ellipse","closest-side","farthest-side","closest-corner","farthest-corner"]),S=/^-?[A-Z][0-9]?$/,G=r=>(0,s.resolveBorderValue)(r),I=r=>{if((0,f.isString)(r))return 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 e=(0,s.getColor)(t);return(0,o.isResolvedColor)(e)?e:t}).join(" ")},_=(r,t)=>(0,s.getShadow)(r,t),z=(r,t)=>{if((0,f.isString)(r))return o.CSS_NATIVE_COLOR_REGEX.test(r)?r:(0,o.splitTopLevelCommas)(r).map(e=>(e=e.trim(),e?e.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 n=(0,s.getColor)(i);if((0,o.isResolvedColor)(n)){const l=(0,s.getMediaColor)(i,t);return(0,f.isObject)(l)?Object.values(l).filter(p=>p.includes(": "+t))[0]:l}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(", ")},g=(r,t)=>{const e=r.indexOf("(");if(e===-1)return r;const i=r.slice(0,e+1),n=r.slice(e+1,r.lastIndexOf(")")),u=")",p=(0,o.splitTopLevelCommas)(n).map(a=>(a=a.trim(),a.split(/\s+/).map(c=>{if(!c||/^\d/.test(c)||c==="0"||A.has(c)||c==="transparent"||o.CSS_NATIVE_COLOR_REGEX.test(c))return c;const x=(0,s.getColor)(c);return(0,o.isResolvedColor)(x)?x:c}).join(" ")));return i+p.join(", ")+u},V=(r,t)=>{if(!(0,f.isString)(r))return;const e=(0,d.getActiveConfig)();return(0,o.splitTopLevelCommas)(r).map(i=>{const n=i.trim();if((0,o.isCSSVar)(n))return`var(${n})`;if(/^var\(/.test(n)||n.includes("url"))return n;if(e.gradient?.[n]){const u=(0,s.getMediaColor)(n,t);if((0,f.isString)(u))return u;if((0,f.isObject)(u)){for(const l in u)if((0,f.isString)(u[l]))return u[l]}return n}return n.includes("gradient")?g(n,t):n.includes("/")||n.startsWith("http")||n.includes(".")&&!(0,o.parseColorToken)(n)?`url(${n})`:n}).join(", ")},$=r=>(0,f.isString)(r)&&(0,o.splitTopLevelSpaces)(r).map(t=>(0,s.getSpacingByKey)(t,"gap").gap).join(" "),F=r=>{if(!(0,f.isString)(r))return r;const t=(0,d.getActiveConfig)();return(0,o.splitTopLevelSpaces)(r).map(e=>S.test(e)?(0,o.getSequenceValue)(e,t.spacing):e).join(" ")},j=r=>{if(!(0,f.isString)(r))return;const t=r.split(" ");return t.length?t.map(e=>(0,o.isCSSVar)(e)?`var(${e})`:e.length<3||e.includes("ms")?(0,s.getTimingByKey)(e).timing||e:(0,s.getTimingFunction)(e)?(0,s.getTimingFunction)(e):e).join(" "):r},K=(r,t,e)=>{if((0,f.isString)(r))return r.split(",").map(i=>(0,s.getTimingByKey)(i).timing||i).join(",")},L=r=>{if(!(0,f.isString)(r))return;const t=r.split(",");if(t.length)return t.map(j).join(",")};function h(r,t,e={},i={}){let n=f.exec.call(this,t||e[r]);if(n==null)return;let u;if((0,f.isString)(n)){if(/^(?:env|var)\(/.test(n.trim()))return{[r]:n};if(n.includes("(")){const a=(0,o.getFnPrefixAndValue)(n);u=a[0],n=a[1]}const l=e.scaleBoxSize,p=(0,s.checkIfBoxSize)(r);!l&&p&&!i.ratio&&(n=(0,s.splitSpacedValue)(n))}return i.ratio?(0,s.getSpacingBasedOnRatio)(e,r,n,u):(0,s.getSpacingByKey)(n,r,void 0,u)}const W=(r,t=null,e)=>h(r,t,e,{ratio:!0}),q=(r,t,e)=>(0,f.isString)(r)?(0,o.splitTopLevelSpaces)(r).map(i=>S.test(i)?(0,s.getSpacingBasedOnRatio)(t,e,i)[e]:i).join(" "):r,D=(r,t,e,i="borderRadius")=>{if((0,f.isString)(r))return{[i]:(0,o.splitTopLevelSpaces)(r).map(n=>{const u=(0,s.getShapeByKey)(n);return u!==void 0?q(u,t,e):(0,s.getSpacingBasedOnRatio)(t,e,n)[e]}).join(" ")}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var M=Object.defineProperty;var
|
|
1
|
+
"use strict";var M=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var W=(t,n)=>{for(var e in n)M(t,e,{get:n[e],enumerable:!0})},B=(t,n,e,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of k(n))!H.call(t,r)&&r!==e&&M(t,r,{get:()=>n[r],enumerable:!(s=G(n,r))||s.enumerable});return t};var Z=t=>B(M({},"__esModule",{value:!0}),t);var st={};W(st,{findHeadingLetter:()=>F,findHeadings:()=>rt,generateSequence:()=>tt,generateSequencePosition:()=>nt,generateSubSequence:()=>I,getFnPrefixAndValue:()=>z,getSequenceValue:()=>U,getSequenceValueBySymbols:()=>K,getSequenceValuePropertyPair:()=>et,getSubratio:()=>P,getSubratioDifference:()=>R,numToLetterMap:()=>S,setScalingVar:()=>O,setSubScalingVar:()=>D});module.exports=Z(st);var w=require("@symbo.ls/utils"),N=require("@symbo.ls/utils"),E=require("@symbo.ls/utils"),C=require("../factory.js"),y=require("./unit.js"),j=require("./color.js");const S={"-6":"U","-5":"V","-4":"W","-3":"X","-2":"Y","-1":"Z",0:"A",1:"B",2:"C",3:"D",4:"E",5:"F",6:"G",7:"H",8:"I",9:"J",10:"K",11:"L",12:"M",13:"N",14:"O",15:"P",16:"Q",17:"R",18:"S",19:"T"},A=(t,n)=>{const{key:e,variable:s,value:r,scaling:i,index:o,scalingVariable:l}=t;n.sequence[e]={key:e,decimal:~~(r*100)/100,val:~~r,scaling:i,index:o,scalingVariable:l,variable:s},n.scales[e]=i;const a=T.has(n.unit)?"rem":n.unit;n.vars[s]=i+a},z=t=>{if(!t.includes("("))return t;const n=t.trim(),e=n.indexOf("("),s=n.slice(0,e);let r=0,i=-1;for(let o=e;o<n.length;o++){const l=n[o];if(l==="(")r++;else if(l===")"&&(r--,r===0)){i=o;break}}return i===-1||/\s/.test(s)||n.slice(i+1).trim()!==""?[void 0,t]:[s,n.slice(e+1,i)]},L="\0",J=(t,n)=>{let e="",s=0,r="";for(const i of t){if(s===0&&i!=="("){e+=i;continue}r+=i,i==="("?s++:i===")"&&(s--,s===0&&(e+=L+n.length+L,n.push(r),r=""))}return e+r},Q=(t,n)=>t.indexOf(L)===-1?t:t.replace(/\u0000(\d+)\u0000/g,(e,s)=>n[Number(s)]),X=/^(calc|min|max|clamp)\((.*)\)$/,Y=(t,n)=>{const e=X.exec(t);return e?`${e[1]}(${K(e[2],n)})`:t.indexOf("(")!==-1?t:U(t,n)},T=new Set(["vw","vh","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh"]),O=(t,n)=>{const{base:e,type:s,unit:r}=n,i=T.has(r)?"rem":r,o=((0,y.isScalingUnit)(i)?1:e)+i;if(t===0)return o;const a="--"+(n.varPrefix?n.varPrefix+"-":"")+(s&&s.replace(".","-")),d=`${a}-ratio`;if(t>0){const u=S[t-1];return`calc(var(${a}-${u}) * var(${d}))`}if(t<0){const u=S[t+1],g=Math.abs(t),h=Math.pow(_,2*g),m=S[g];return m?`max(calc(var(${a}-${u}) / var(${d})), calc(var(${a}-${m}) / ${h.toFixed(4)}))`:`calc(var(${a}-${u}) / var(${d}))`}},D=(t,n,e,s)=>{const{type:r}=s,o=t===2&&n.length===2?t+1:t,d=`${"--"+(s.varPrefix?s.varPrefix+"-":"")+(r&&r.replace(".","-"))}-sub-ratio-`;return`calc(var(${e}) * var(${d+o}))`},R=(t,n)=>{const s=(t*n-t)/1.618,r=t*n-s,i=t+s,o=(r+i)/2;return[r,o,i]},P=(t,n)=>R(t,n).map(e=>e/t),I=(t,n)=>{const{key:e,base:s,value:r,ratio:i,variable:o,index:l}=t,d=~~(r*i)-~~r;let u;const[g,h,m]=R(r,i);d>16?u=[g,h,m]:u=[g,m],u.forEach((p,c)=>{const $=~~(p/s*1e3)/1e3,b=o+(c+1),V=l+(c+1)/10,f=D(c+1,u,o,n),x={key:e+(c+1),variable:b,value:p,scaling:$,scalingVariable:f,index:V};A(x,n)})},_=1.618,q=(t,n,e)=>{if(t>=0)return n*Math.pow(e,t);const s=Math.abs(t),r=n*Math.pow(e,t),i=n*Math.pow(e,s)/Math.pow(_,2*s);return Math.max(r,i)},tt=t=>{const{type:n,base:e,ratio:s,range:r,subSequence:i}=t,o=Math.abs(r[0])+Math.abs(r[1]),a="--"+(t.varPrefix?t.varPrefix+"-":"")+(n&&n.replace(".","-"))+"-";for(let d=0;d<=o;d++){const u=r[1]-d,g=S[u],h=q(u,e,s),m=~~(h/e*100)/100,p=a+g,c=O(u,t),$={key:g,variable:p,value:h,base:e,scaling:m,scalingVariable:c,ratio:s,index:u};A($,t),i&&I($,t)}return t},nt=(t,n=0)=>{const{type:e,base:s,ratio:r,subSequence:i}=t,o=(0,w.isString)(n)?n:S[n],l=(0,w.isString)(n)?Object.entries(S).find(([,$])=>$===n)?.[0]:n;if(!o)return console.warn(`Position ${n} is out of range in numToLetterMap`),null;const a={sequence:{},scales:{},vars:{},...t},d=s*Math.pow(r,l),u=~~(d/s*100)/100,m="--"+(t.varPrefix?t.varPrefix+"-":"")+(e&&e.replace(".","-"))+"-"+o,p=O(l,t),c={key:o,variable:m,value:d,base:s,scaling:u,scalingVariable:p,ratio:r,index:l};return A(c,a),i&&I(c,a),a},U=(t="A",n)=>{const e=(0,C.getActiveConfig)(),{unit:s}=e;if((0,w.isString)(t)&&(0,j.isCSSVar)(t))return`var(${t})`;if((0,w.isString)(t)&&/^(?:env|var|calc|min|max|clamp)\(/.test(t.trim()))return t;if((0,w.isString)(t)){const f=e.sizes;if(f){const x=f[t]||f[t.toLowerCase()];if(x!==void 0)return t.slice(0,1)==="-"?`calc(${x} * -1)`:x}}const{sequence:r,unit:i=s.default,useVariable:o}=n,l=/^-?[a-zA-Z]/i,a=l.test(t);if((0,y.isRawUnitValue)(t)||!a||["none","auto","max-content","min-content","fit-content","inherit","initial","unset","revert","revert-layer"].includes(t))return t;const h=`--${n.varPrefix?n.varPrefix+"-":""}${(0,N.toDashCase)(n.type.replace(".","-"))}-`,m=t.toUpperCase(),p=m.slice(0,1)==="-"?"-":"";let c=p?m.slice(1):m,$="";c.includes("_")&&($="_"+c.split("_")[1].toLowerCase(),c=c.split("_")[0]);const b=f=>l.test(f)?`var(${h}${f}${$})`:f;if(c.includes("+")){const[f,x]=c.split("+"),v=`${b(f)} + ${b(x)}`;return p?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("*")){const[f,x]=c.split("*"),v=`${b(f)} * ${b(x)}`;return p?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("-")){const[f,x]=c.split("-"),v=`${b(f)} - ${b(x)}`;return p?`calc((${v}) * -1)`:`calc(${v})`}if(!r[c]&&c.length===2&&(e.verbose&&console.warn(c,"- value is not found because `subSequence` is set to false"),c=c.slice(0,1)),o||e.useVariable){const f=`var(${h}${c}${$})`;return p?`calc(${f} * -1)`:f}const V=r?r[c]:null;if(!V){if(console.warn("can't find",r,c),(0,E.isLoudDevRuntime)())throw new Error(`[smbls] Unresolvable design-system token "${t}"`+(n.type?` for sequence "${n.type}"`:"")+" \u2014 not a registered `sizes` name and not a valid spacing/typography/timing sequence letter. The CSS property using it would silently be dropped in production. Register the token in `designSystem/sizes.js` (or the relevant sequence family) or fix the typo.");return}return i==="ms"||i==="s"?p+V.val+i:p+V.scaling+i},K=(t,n)=>{if(!["+","-","*","/",","].filter(o=>t.includes(o+" ")).length)return t;const s=/(\s+-\s+|\s*[+*/,]\s*)/,r=[];return J(t,r).split(s).map(o=>{const l=Q(o,r),a=l.trim();return!a||["+","-","*","/",","].includes(a)?l:Y(a,n)}).join("")},et=(t,n,e,s)=>{if(typeof t!="string")return(0,C.getActiveConfig)().verbose&&console.warn(n,t,"is not a string"),{[n]:t};if(t==="-"||t==="")return{};if(!s&&t.includes("(")){if(/^(?:env|var)\(/.test(t.trim()))return{[n]:t};const i=z(t);s=i[0],t=i[1]}return["+","-","*","/",","].filter(i=>t.includes(i+" ")).length?t=K(t,e):t=U(t,e),{[n]:s?`${s}(${t})`:t}},F=(t,n)=>S[t-n],rt=t=>{const{h1Matches:n,sequence:e}=t;return new Array(6).fill(null).map((s,r)=>{const i=F(n,r);return e[i]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./sequence.js";export*from"./unit.js";export*from"./typography.js";export*from"./font.js";export*from"./font-family.js";export*from"./media.js";export*from"./spacing.js";export*from"./color.js";export*from"./theme.js";export*from"./shadow.js";export*from"./icons.js";export*from"./timing.js";export*from"./document.js";export*from"./responsive.js";export*from"./animation.js";export*from"./svg.js";export*from"./templates.js";export*from"./grid.js";export*from"./class.js";const o={},r={},t={},e={};export{o as reset,e as shape,t as sizes,r as vars};
|
|
1
|
+
export*from"./sequence.js";export*from"./unit.js";export*from"./typography.js";export*from"./font.js";export*from"./font-family.js";export*from"./media.js";export*from"./spacing.js";export*from"./color.js";export*from"./theme.js";export*from"./shadow.js";export*from"./icons.js";export*from"./timing.js";export*from"./document.js";export*from"./responsive.js";export*from"./animation.js";export*from"./svg.js";export*from"./templates.js";export*from"./grid.js";export*from"./class.js";const o={},r={},t={},e={},p={};export{o as reset,e as shape,t as sizes,p as skins,r as vars};
|
package/dist/esm/src/factory.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{deepClone as
|
|
1
|
+
import{deepClone as _,deepMerge as b,isDefined as l,isObject as h}from"@symbo.ls/utils";import{createSignal as d}from"@symbo.ls/signal";import*as O from"./defaultConfig/index.js";const C={},T={},v=new Set,f=O,p={},A=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=A(t);o!==t&&(p[o]=f[e]),t!==e&&(p[e]=f[e])}const i={verbose:!1,useVariable:!0,useReset:!0,globalTheme:"auto",cssVars:C,cssMediaVars:T,CSS_VARS:C,CSS_MEDIA_VARS:T,cssSkinVars:{},cssSkinFallback:{},_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=d(l(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},k=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=d(l(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},D=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)},E=()=>{u.pop()},V=e=>u.length?u[u.length-1]:a[e||a.active]||i,G=e=>{if(h(e))return a.active="1",a[1]=b(e,_(S),v),x(a[1]),m(a[1]),g(a[1]),e},y=["useReset","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultIcons","useDefaultConfig"],F=["useVariable","globalTheme","verbose"],R=[["fontfamily","fontFamily","font_family"],["fontfamilytypes","fontFamilyTypes"],["semanticicons","semanticIcons"],["svgdata","svgData"]],x=e=>{for(const t of R){let o;for(const s of t){const n=e[s];h(n)&&(o=o?b(o,n,v):n)}if(o)for(const s of t)h(e[s])&&(e[s]=o)}},L=(e,t,{cleanBase:o=!1}={})=>{const s=o?null:V(),n=_(!o&&s&&s._scratchConfig?s:S);for(const c of y)delete n[c];for(const c of F)Object.prototype.hasOwnProperty.call(S,c)?n[c]=S[c]:delete n[c];const r=b(t||{},n,v);return r.cssVars={},r.cssMediaVars={},r.CSS_VARS=r.cssVars,r.CSS_MEDIA_VARS=r.cssMediaVars,r.cssSkinVars={},r.cssSkinFallback={},r._scratchConfig=!0,x(r),m(r),g(r),e&&(a[e]=r),r};export{i as CONFIG,v as CONFIG_MERGE_EXL,a as FACTORY,M as activateConfig,x as aliasCaseVariants,L as createConfig,T as cssMediaVars,C as cssVars,g as defineResolvedThemeSignal,m as defineThemeSignal,V as getActiveConfig,D as getResolvedThemeSignal,k as getThemeSignal,E as popConfig,j as pushConfig,G as setActiveConfig,A as toCamel};
|
package/dist/esm/src/set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CONFIG_MERGE_EXL as $,aliasCaseVariants as z,getActiveConfig as S,setActiveConfig as B,toCamel as K}from"./factory.js";import{setColor as U,setGradient as X,setFont as J,setFontFamily as
|
|
1
|
+
import{CONFIG_MERGE_EXL as $,aliasCaseVariants as z,getActiveConfig as S,setActiveConfig as B,toCamel as K}from"./factory.js";import{setColor as U,setGradient as X,setFont as J,setFontFamily as M,setTheme as Q,setSvgIcon as Z,setSVG as G,applyTypographySequence as N,applySpacingSequence as ee,applyReset as te,applyTimingSequence as se,applyDocument as oe,applySkins as re,setShadow as ne}from"./system/index.js";import{deepMerge as ie,isObject as P,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)},I=(t,s,e)=>{if(!(!t||!s)){b(t),t.__prefersListener=e,t.__prefersMq=s;try{s.addEventListener("change",e)}catch{s.addListener(e)}}},ce=(t,s)=>{const e=S(),{cssVars:n}=e,i=s.startsWith("--")?s:`--${s}`;return n[i]=t,t},f=t=>t,H={color:U,gradient:X,font:J,fontFamily:M,fontfamily:M,theme:Q,icons:Z,semanticIcons:f,semanticicons:f,svg:G,svgData:f,typography:f,shadow:ne,spacing:f,media:f,grid:f,class:f,timing:f,reset:f,unit:f,animation:f,vars:ce,sizes:f,shape:f,skins:f},ae=(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},le=(t,s,e)=>{const n=S(),i=K(t),o=i.toLowerCase(),d=n[i]||n[o]||n[t],r=O(d)?ae(n,d,o,[i,o,t]):d,m=H[i]||H[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")},fe=(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=P(s[o])||q(s[o])?1:0,m=P(s[d])||q(s[d])?1:0;return r-m}).forEach(o=>{try{return le(n,s[o],o)}catch(d){e.verbose&&console.warn("Error setting",n,"value",s[o],o,d)}}),e[n]||e[t])},ye=(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},h=o.matchMedia("(prefers-color-scheme: dark)");a(h),r.style.colorScheme="light dark",I(e,h,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 h=m[a].cssRules;for(let g=0;g<h.length;g++)if(h[g].selectorText===r){for(const v in e.cssVars)h[g].style.setProperty(v,e.cssVars[v]);return e}}catch{}}return e},de={},be=(t,s=de)=>{let e=s.config||S();const{version:n,verbose:i,useVariable:o,useReset:d,useSvgSprite:r,useFontImport:m,useIconSprite:a,globalTheme:h,themeRoot:g,useDocumentTheme:v,useDefaultConfig:E,semanticIcons:V,hoverMedia:x,files:R,assets:D,...u}=t;s.newConfig&&(e=B(s.newConfig)),j(u.document)&&(e.__domDocument=u.document,delete u.document),j(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),R!==void 0&&(e.files=R),D!==void 0&&(e.assets=D),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),h!==void 0&&(e.globalTheme=h),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),l=_&&(e.themeRoot||_.documentElement);if(l&&typeof l.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")b(e),l.setAttribute("data-theme",e.globalTheme),e.resolvedTheme=e.globalTheme,l[y]=e,e.globalTheme==="dark"||e.globalTheme==="light"?l.style.colorScheme=e.globalTheme:l.style.colorScheme="light dark";else if(l[y]&&l[y]!==e&&l.hasAttribute("data-theme"))b(e),e.resolvedTheme=l.getAttribute("data-theme");else if(T&&T.matchMedia){const p=Y=>{const C=Y.matches?"dark":"light";l.setAttribute("data-theme",C),e.resolvedTheme=C},k=T.matchMedia("(prefers-color-scheme: dark)");p(k),l.style.colorScheme="light dark",l[y]=e,I(e,k,p)}else b(e),l.setAttribute("data-theme","light"),e.resolvedTheme="light",l.style.colorScheme="light",l[y]=e;e.__svgCache||(e.__svgCache={}),z(u);const w=Object.keys(u).filter(c=>!c.startsWith("__")),L=new Set(w);if(w.forEach(c=>{const p=c.toLowerCase();p!==c&&L.has(p)&&ie(u[p],u[c],$)}),w.map(c=>{const p=c.toLowerCase();if(!(p!==c&&L.has(p)))return fe(c,u[c])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),u.typography)try{N()}catch(c){e.verbose&&console.warn("Error applying typography sequence",c)}if(u.spacing)try{ee()}catch(c){e.verbose&&console.warn("Error applying spacing sequence",c)}if(u.timing)try{se()}catch(c){e.verbose&&console.warn("Error applying timing sequence",c)}try{re()}catch(c){e.verbose&&console.warn("Error applying skins",c)}oe();const A=te();return A&&(e.reset=A),e};export{H as VALUE_TRANSFORMERS,ye as changeGlobalTheme,be as set,fe as setEach,le as setValue};
|
|
@@ -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"./border.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";export*from"./skin.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isObject as l,isString as m,isLoudDevRuntime as y}from"@symbo.ls/utils";import{getActiveConfig as O}from"../factory.js";const v=new Set(["fallback"]),h=new Set,u=(n,e)=>{h.has(n)||(h.add(n),y()&&console.warn(e))},x=()=>{h.clear()},p=n=>{for(const e in n)delete n[e];return n},R=()=>{const n=O(),e=l(n.cssSkinVars)?p(n.cssSkinVars):n.cssSkinVars={},s=l(n.cssSkinFallback)?p(n.cssSkinFallback):n.cssSkinFallback={},c=n.skins;if(!l(c))return e;const a=n.varPrefix?n.varPrefix+"-":"",o=n.color||{},k=n.cssVars||{},w=t=>m(t)&&Object.prototype.hasOwnProperty.call(o,t)?`var(--${a}color-${t})`:t;for(const t in c){const r=c[t];if(!l(r))continue;const S={};for(const i in r){if(v.has(i))continue;const $=r[i];if(l($))for(const f in $){const d=`--${a}theme-${i}-${f}`;n.useVariable!==!1&&!(d in k)&&u(`${t}/${i}/${f}`,`[scratch] skin "${t}" rewrites theme "${i}" param "${f}", which the theme does not declare \u2014 no element reads ${d}, so the skin changes nothing there. Declare "${f}" on the "${i}" theme (its no-skin value).`),S[d]=w($[f])}}e[t]=S,m(r.fallback)&&(s[t]=r.fallback)}for(const t in s){const r=s[t];e[r]||(u(`${t}/fallback/${r}`,`[scratch] skin "${t}" falls back to "${r}", which is not a declared skin \u2014 the reduced-transparency fallback is skipped.`),delete s[t])}return e},b=(n,e)=>{const s=`[data-skin="${n}"]`;return!e||e===":root"?`:root${s}, ${s}`:`${e}${s}, ${s} ${e}, ${e} ${s}`},C=(n,e,s)=>{const c={};if(!l(n))return c;for(const o in n)c[b(o,s)]=n[o];const a={};for(const o in e||{}){const k=n[e[o]];k&&(a[b(o,s)]=k)}return Object.keys(a).length&&(c["@media (prefers-reduced-transparency: reduce)"]=a),c};export{x as __resetSkinWarnings,R as applySkins,C as buildSkinVarStyles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{arrayzeValue as I}from"@symbo.ls/utils";import{isArray as q,isString as
|
|
1
|
+
import{arrayzeValue as I}from"@symbo.ls/utils";import{isArray as q,isString as l,merge as G}from"@symbo.ls/utils";import{getActiveConfig as d}from"../factory.js";import{CSS_UNITS as B,applyMediaSequenceVars as C,applySequenceVars as f,generateSequence as g,getFnPrefixAndValue as p,getSequenceValuePropertyPair as h,splitTopLevelSpaces as b}from"../utils/index.js";const k=t=>{const n=d().spacing||{},s=parseFloat(t.spacingRatio),i={...n,ratio:Number.isFinite(s)?s:n.ratio,sequence:{},scales:{}};return g(i),i},y=t=>{for(const e in t){const n=t[e];if(!(e.slice(0,1)==="@"))continue;const{type:i,base:o,ratio:c,range:r,subSequence:S,h1Matches:a,unit:u}=t;G(n,{type:i,base:o,ratio:c,range:r,subSequence:S,h1Matches:a,unit:u,sequence:{},scales:{},templates:{},vars:{}}),g(n),C(t,e)}},L=t=>{const e=t.toLowerCase(),n=e.includes("width")||e.includes("height"),s=e.includes("border")||e.includes("outline");return n&&!s},O=()=>{const t=d(),{spacing:e}=t;g(e),f(e),y(e)},A=t=>{const e=d(),{spacing:n}=e;return!t||!t.sequence?n:Object.keys(t.sequence).length>0?t:g(t)},m=(t,e="padding",n,s)=>{const i=A(n);if(l(t)){if(!s&&/^(?:env|var)\(/.test(t.trim()))return{[e]:t};if(!s&&t.includes("(")){const c=p(t);s=c[0],t=c[1]}}const o=s?[t]:l(t)&&t.includes("(")?b(t):I(t);if(q(o)){if(o.length>1){let c="";e==="borderWidth"&&(e="border",c="Width");const r={2:["Block","Inline"],3:["BlockStart","Inline","BlockEnd"],4:["BlockStart","InlineEnd","BlockEnd","InlineStart"]},S=(a,u)=>h(o[u],e+a+c,i,s);return r[o.length].map((a,u)=>S(a,u))}return h(t,e,i,s)}},j=(t,e,n,s)=>{const i=d(),{spacing:o}=i;let c=n||t[e];if(!s&&l(c)&&/^(?:env|var)\(/.test(c.trim()))return{[e]:c};if(!s&&l(c)&&c.includes("(")){const r=p(c);s=r[0],c=r[1]}if(t.spacingRatio){const r=k(t);return m(c,e,r,s)}return m(c,e,o,s)},w=t=>{const e=n=>{const s=["+","-","*","/"].includes(n),i=B.some(c=>t.includes(c));return s||i?n:n.length<3&&/[A-Z]/.test(n)?n+"_default":n};return t.split(",").map(n=>n.trim()).map(e).join(",").split(" ").map(e).join(" ")};export{O as applySpacingSequence,L as checkIfBoxSize,j as getSpacingBasedOnRatio,m as getSpacingByKey,w as splitSpacedValue};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getColor as
|
|
1
|
+
import{getColor as P,isPlainColor as B,schemeMediaQuery as K,schemeGuardSelector as N}from"./color.js";import{resolveShadowValue as L}from"./shadow.js";import{resolveBorderValue as $}from"./border.js";import{getActiveConfig as A}from"../factory.js";import{isCSSVar as C,parseColorToken as F}from"../utils/color.js";import{isObject as D,isString as T,isObjectLike as k,isArray as W,isLoudDevRuntime as G}from"@symbo.ls/utils";const I=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"]),z=["color","Color","background","Background","fill","Fill","stroke","Stroke"],H=e=>{for(let n=0;n<z.length;n++)if(e.includes(z[n]))return!0;return!1},ee={boxShadow:L,textShadow:L,border:$,borderTop:$,borderRight:$,borderBottom:$,borderLeft:$,outline:$,columnRule:$},ne=e=>{if(!e)return!1;const n=F(e);return!n||!n.name||n.passthrough||n.cssVar?!1:n.alpha!==void 0||n.tone!==void 0},U=new Set,oe=(e,n,o,r,a,c)=>{if(!G())return;const s=`${e}::${n}::${o||""}::${r}`;U.has(s)||(U.add(s),console.warn(`[smbls/scratch] theme param "${n}" on "${e}"`+(o?` (${o})`:"")+` did not fully resolve: "${r}" -> "${a}" still contains the unresolved token "${c}". This is not valid CSS \u2014 the browser will drop the whole declaration. Register "${c}" as a design-system color token or fix the typo.`))},q=(e,n,o,r)=>{const a=ee[n];if(!a)return P(o,r);let c=null;const s=a(o,r,m=>{!c&&ne(m)&&(c=m)});return c&&oe(e,n,r,o,s,c),s},he=(e,n)=>M(e,n),re=e=>D(e)&&k(e.value),te=e=>{for(const n in e){const o=e[n];if(T(o)&&o.startsWith("var(--"))return!0}return!1},me=(e,n)=>{const o=A();return re(e)?!o.useVariable&&te(e)?e:_(e.value,n):_(e,n)},Q=(e,n)=>{const o=new Set;for(const r of n){const a=r.slice(0,1);if(!(a==="@"||a==="."||a===":")&&H(r))for(const c in e){if(o.has(c))continue;const s=e[c]?.[r];if(s===void 0)continue;const m=P(s,`@${c}`);m!==void 0&&T(m)&&/^[a-z][a-zA-Z]+$/.test(m)&&!I.has(m)&&o.add(c)}}return o},ie=e=>e.startsWith("[data-theme=")||e.startsWith("@media"),j=(e,n)=>{for(const o in n){const r=n[o];D(r)?j(e[o]||(e[o]={}),r):e[o]=r}return e},Z=(e,n,o,r)=>{if(j(e,{[`[data-theme="${n}"] &`]:o}),n!=="light"&&n!=="dark")return;const a=K(n,r);a&&j(e,{[a]:{[N(r)]:o}})},J=(e,n,o,r)=>{const a=o.globalTheme!==void 0?o.globalTheme:"auto",c=a&&a!=="auto"?String(a).replace(/^'|'$/g,""):null,s=new Set(r?Object.keys(r):[]);for(const d in e)if(e[d])for(const i of Object.keys(e[d]))s.add(i);const m=Q(e,s),u={};for(const d of s){const i=d.slice(0,1);if(i==="@")continue;if(i==="."||i===":"){const l={};for(const S in e)k(e[S]?.[d])&&(l[S]=e[S][d]);const g=r&&k(r[d])?r[d]:void 0;if(!Object.keys(l).length&&!g)continue;const y=i==="."?d.slice(1):d.replace(/^:+/,"");u[d]=J(l,`${n}-${y}`,o,g);continue}const t=r&&!k(r[d])?r[d]:void 0,f=new Set(Object.keys(e));t!==void 0&&(f.add("light"),f.add("dark"),c&&f.add(c));const p={};let b;for(const l of f){if(m.has(l))continue;let g=e[l]?.[d];if((g===void 0||k(g))&&(g=t),g===void 0)continue;const y=q(n,d,g,`@${l}`);y!==void 0&&(p[l]=y,(c&&l===c||!c&&(l==="light"||b===void 0))&&(b=y))}const h={},w=Object.keys(p).filter(l=>p[l]!==b);if(w.length){const l=p.light!==void 0?p.light:b,g=p.dark!==void 0?p.dark:b;if(H(d)&&B(l)&&B(g)){h[d]=l===g?l:`light-dark(${l}, ${g})`;for(const y in p)y==="light"||y==="dark"||Z(h,y,{[d]:p[y]},o)}else{b!==void 0&&(h[d]=b);for(const y of w)Z(h,y,{[d]:p[y]},o)}}else{if(b===void 0)continue;h[d]=b}j(u,h),u[`.${d}`]=h}return(u.background||u.color||u.backgroundColor)&&(u[".inversed"]={color:u.background||u.backgroundColor,background:u.color}),u},x=(e,n,o,r)=>{const{cssVars:a}=o;o.cssMediaVars||(o.cssMediaVars={});const c=o.cssMediaVars,s=o.globalTheme!==void 0?o.globalTheme:"auto",m=s&&s!=="auto"?String(s).replace(/^'|'$/g,""):null,u={},d=new Set(r?Object.keys(r):[]);for(const t in e)if(e[t])for(const f of Object.keys(e[t]))d.add(f);const i=Q(e,d);for(const t of d){const f=t.slice(0,1),p=k(r?.[t])||Object.values(e).some(b=>k(b?.[t]));if(f==="."&&p){const b=t.slice(1),h={};for(const l in e)k(e[l]?.[t])&&(h[l]=e[l][t]);const w=k(r?.[t])?r[t]:void 0;u[t]=x(h,`${n}-${b}`,o,w)}else if(f===":"&&p){const b=t.replace(/^:+/,""),h={};for(const l in e)k(e[l]?.[t])&&(h[l]=e[l][t]);const w=k(r?.[t])?r[t]:void 0;u[t]=x(h,`${n}-${b}`,o,w)}else if(f!=="@"&&f!=="."&&f!==":"){const h=`--${o.varPrefix?o.varPrefix+"-":""}theme-${n}-${t}`,w=r&&!k(r[t])?r[t]:void 0,l=new Set(Object.keys(e));w!==void 0&&(l.add("light"),l.add("dark"),m&&l.add(m));let g,y=!1;for(const S of l){if(i.has(S))continue;let V=e[S]?.[t];if((V===void 0||k(V))&&(V=w),V===void 0)continue;const R=q(n,t,V,`@${S}`);if(R===void 0)continue;y=!0,(m&&S===m||!m&&(S==="light"||g===void 0))&&(g=R);const v=`[data-theme="${S}"]`;if(c[v]||(c[v]={}),c[v][h]=R,S==="dark"||S==="light"){const O=`@media (prefers-color-scheme: ${S})`;c[O]||(c[O]={}),c[O][h]=R}}if(g!==void 0&&(a[h]=g),!y)continue;u[t]=`var(${h})`,u[`.${t}`]={[t]:u[t]}}}return(u.background||u.color||u.backgroundColor)&&(u[".inversed"]={color:u.background||u.backgroundColor,background:u.color}),u},_=(e,n,o,r)=>{const a=A(),{cssVars:c}=a,s={value:e},m=!o&&!r;let u,d;if(k(e)){if(m&&a.useVariable){const i={},t={};for(const f in e)f.startsWith("@")?k(e[f])&&(i[f.slice(1)]=e[f]):t[f]=e[f];(Object.keys(i).length||Object.keys(t).length)&&(d=x(i,n,a,t),Object.assign(s,d))}else if(m){const i={},t={};for(const f in e)f.startsWith("@")?k(e[f])&&(i[f.slice(1)]=e[f]):t[f]=e[f];u=J(i,n,a,t),Object.assign(s,u)}for(const i in e){const t=i.slice(0,1),f=e[i];if(t==="@"||t===":"||t==="."){const p=t==="@"&&i;s[i]=_(f,n,i,r||p)}else if(!m){const p=q(n,i,f,r),b=[...new Set([r,o].filter(g=>g).map(g=>g.slice(1)))],h=b.length?"-"+b.join("-"):"",l=`--${a.varPrefix?a.varPrefix+"-":""}theme-${n}${h}-${i}`;a.useVariable?(a.useThemeSuffixedVars&&(c[l]=p),s[i]=`var(${l})`):s[i]=p,s[`.${i}`]={[i]:s[i]}}}if(u)for(const i in u){const t=i.slice(0,1);(t==="."||t===":")&&k(e[i])&&(s[i]=u[i])}if(d)for(const i in d){const t=i.slice(0,1);(t==="."||t===":")&&k(e[i])&&(s[i]=d[i])}!s[".inversed"]&&(s.background||s.color||s.backgroundColor)&&(s[".inversed"]={color:s.background||s.backgroundColor,background:s.color})}if(T(e)&&C(e)){const t=a.theme[e.slice(2)];return M(t,r)}return s},E=(e,n)=>{const o={};for(const r in e){const a=r.slice(0,1);if(k(e[r]))if(n&&ie(r))o[r]=j({},e[r]);else{if(a==="@")continue;a===":"?o[`&${r}`]=E(e[r],n):a==="."&&(o[`&${r}`]=E(e[r],n))}else o[r]=e[r]}return o},X=(e,n)=>{const o=n.shift();return e[o]?X(e[o],n):e},Y=(e,n)=>W(n)?X(e,n):T(n)&&e[n]?e[n]:e,se=(e,n)=>T(e)&&C(e)?M(e.slice(2)):e,ce=e=>se(e,ce),M=(e,n)=>{const o=A();if(T(e)&&C(e)&&(e=M(e.slice(2))),!e||!T(e)){o.verbose&&console.warn(`${e} - Theme is not a string`);return}const[r,...a]=W(e)?e:e.split(" ");let c=o.theme[r];return c&&a.length?c=Y(c,a):c&&n&&(c=Y(c,n)),E(c,!o.useVariable)};export{M as getMediaTheme,he as getTheme,_ as setMediaTheme,me as setTheme};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isString as u,isObject as
|
|
1
|
+
import{isString as u,isObject as B,exec as A}from"@symbo.ls/utils";import{getActiveConfig as C}from"../factory.js";import{getSpacingByKey as m,getColor as d,getShadow as G,getShapeByKey as I,getMediaColor as E,getTimingByKey as R,getTimingFunction as T,getSpacingBasedOnRatio as x,checkIfBoxSize as _,splitSpacedValue as z,resolveBorderValue as V}from"../system/index.js";import{getFnPrefixAndValue as $,isResolvedColor as S,isCSSVar as a,CSS_NATIVE_COLOR_REGEX as g,splitTopLevelCommas as j,splitTopLevelSpaces as p,parseColorToken as F,getSequenceValue as K}from"../utils/index.js";const L=new Set(["to","top","bottom","left","right","center","at","circle","ellipse","closest-side","farthest-side","closest-corner","farthest-corner"]),O=/^-?[A-Z][0-9]?$/,X=r=>V(r),Y=r=>{if(u(r))return g.test(r)?r:r.split(/\s+/).map(e=>{if(e=e.trim(),!e)return"";if(a(e))return`var(${e})`;if(/^\d/.test(e)||e.includes("px")||e==="0")return e;const t=d(e);return S(t)?t:e}).join(" ")},Z=(r,e)=>G(r,e),y=(r,e)=>{if(u(r))return g.test(r)?r:j(r).map(t=>(t=t.trim(),t?t.split(/\s+/).map(i=>{if(i=i.trim(),!i)return"";if(a(i))return`var(${i})`;if(i==="inset"||i==="none")return i;const n=d(i);if(S(n)){const f=E(i,e);return B(f)?Object.values(f).filter(l=>l.includes(": "+e))[0]:f}if(/^\d/.test(i)||i==="0"||i.includes("px")||i.slice(-2)==="em")return i;const s=m(i,"shadow");return s&&s.shadow?s.shadow:i}).join(" "):"")).join(", ")},W=(r,e)=>{const t=r.indexOf("(");if(t===-1)return r;const i=r.slice(0,t+1),n=r.slice(t+1,r.lastIndexOf(")")),s=")",l=j(n).map(c=>(c=c.trim(),c.split(/\s+/).map(o=>{if(!o||/^\d/.test(o)||o==="0"||L.has(o)||o==="transparent"||g.test(o))return o;const h=d(o);return S(h)?h:o}).join(" ")));return i+l.join(", ")+s},H=(r,e)=>{if(!u(r))return;const t=C();return j(r).map(i=>{const n=i.trim();if(a(n))return`var(${n})`;if(/^var\(/.test(n)||n.includes("url"))return n;if(t.gradient?.[n]){const s=E(n,e);if(u(s))return s;if(B(s)){for(const f in s)if(u(s[f]))return s[f]}return n}return n.includes("gradient")?W(n,e):n.includes("/")||n.startsWith("http")||n.includes(".")&&!F(n)?`url(${n})`:n}).join(", ")},J=r=>u(r)&&p(r).map(e=>m(e,"gap").gap).join(" "),N=r=>{if(!u(r))return r;const e=C();return p(r).map(t=>O.test(t)?K(t,e.spacing):t).join(" ")},q=r=>{if(!u(r))return;const e=r.split(" ");return e.length?e.map(t=>a(t)?`var(${t})`:t.length<3||t.includes("ms")?R(t).timing||t:T(t)?T(t):t).join(" "):r},k=(r,e,t)=>{if(u(r))return r.split(",").map(i=>R(i).timing||i).join(",")},v=r=>{if(!u(r))return;const e=r.split(",");if(e.length)return e.map(q).join(",")};function D(r,e,t={},i={}){let n=A.call(this,e||t[r]);if(n==null)return;let s;if(u(n)){if(/^(?:env|var)\(/.test(n.trim()))return{[r]:n};if(n.includes("(")){const c=$(n);s=c[0],n=c[1]}const f=t.scaleBoxSize,l=_(r);!f&&l&&!i.ratio&&(n=z(n))}return i.ratio?x(t,r,n,s):m(n,r,void 0,s)}const rr=(r,e=null,t)=>D(r,e,t,{ratio:!0}),b=(r,e,t)=>u(r)?p(r).map(i=>O.test(i)?x(e,t,i)[t]:i).join(" "):r,tr=(r,e,t,i="borderRadius")=>{if(u(r))return{[i]:p(r).map(n=>{const s=I(n);return s!==void 0?b(s,e,t):x(e,t,n)[t]}).join(" ")}};export{W as resolveColorsInGradient,v as splitTransition,H as transformBackgroundImage,X as transformBorder,tr as transformBorderRadius,y as transformBoxShadow,k as transformDuration,N as transformGridTemplate,Z as transformShadow,D as transformSize,rr as transformSizeRatio,Y as transformTextStroke,q as transformTransition,J as transfromGap};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isString as V}from"@symbo.ls/utils";import{toDashCase as
|
|
1
|
+
import{isString as V}from"@symbo.ls/utils";import{toDashCase as T}from"@symbo.ls/utils";import{isLoudDevRuntime as _}from"@symbo.ls/utils";import{getActiveConfig as A}from"../factory.js";import{isRawUnitValue as N,isScalingUnit as E}from"./unit.js";import{isCSSVar as j}from"./color.js";const S={"-6":"U","-5":"V","-4":"W","-3":"X","-2":"Y","-1":"Z",0:"A",1:"B",2:"C",3:"D",4:"E",5:"F",6:"G",7:"H",8:"I",9:"J",10:"K",11:"L",12:"M",13:"N",14:"O",15:"P",16:"Q",17:"R",18:"S",19:"T"},y=(t,n)=>{const{key:e,variable:r,value:s,scaling:i,index:o,scalingVariable:l}=t;n.sequence[e]={key:e,decimal:~~(s*100)/100,val:~~s,scaling:i,index:o,scalingVariable:l,variable:r},n.scales[e]=i;const a=L.has(n.unit)?"rem":n.unit;n.vars[r]=i+a},z=t=>{if(!t.includes("("))return t;const n=t.trim(),e=n.indexOf("("),r=n.slice(0,e);let s=0,i=-1;for(let o=e;o<n.length;o++){const l=n[o];if(l==="(")s++;else if(l===")"&&(s--,s===0)){i=o;break}}return i===-1||/\s/.test(r)||n.slice(i+1).trim()!==""?[void 0,t]:[r,n.slice(e+1,i)]},M="\0",D=(t,n)=>{let e="",r=0,s="";for(const i of t){if(r===0&&i!=="("){e+=i;continue}s+=i,i==="("?r++:i===")"&&(r--,r===0&&(e+=M+n.length+M,n.push(s),s=""))}return e+s},F=(t,n)=>t.indexOf(M)===-1?t:t.replace(/\u0000(\d+)\u0000/g,(e,r)=>n[Number(r)]),G=/^(calc|min|max|clamp)\((.*)\)$/,k=(t,n)=>{const e=G.exec(t);return e?`${e[1]}(${K(e[2],n)})`:t.indexOf("(")!==-1?t:U(t,n)},L=new Set(["vw","vh","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh"]),C=(t,n)=>{const{base:e,type:r,unit:s}=n,i=L.has(s)?"rem":s,o=(E(i)?1:e)+i;if(t===0)return o;const a="--"+(n.varPrefix?n.varPrefix+"-":"")+(r&&r.replace(".","-")),d=`${a}-ratio`;if(t>0){const u=S[t-1];return`calc(var(${a}-${u}) * var(${d}))`}if(t<0){const u=S[t+1],g=Math.abs(t),h=Math.pow(I,2*g),m=S[g];return m?`max(calc(var(${a}-${u}) / var(${d})), calc(var(${a}-${m}) / ${h.toFixed(4)}))`:`calc(var(${a}-${u}) / var(${d}))`}},H=(t,n,e,r)=>{const{type:s}=r,o=t===2&&n.length===2?t+1:t,d=`${"--"+(r.varPrefix?r.varPrefix+"-":"")+(s&&s.replace(".","-"))}-sub-ratio-`;return`calc(var(${e}) * var(${d+o}))`},O=(t,n)=>{const r=(t*n-t)/1.618,s=t*n-r,i=t+r,o=(s+i)/2;return[s,o,i]},q=(t,n)=>O(t,n).map(e=>e/t),R=(t,n)=>{const{key:e,base:r,value:s,ratio:i,variable:o,index:l}=t,d=~~(s*i)-~~s;let u;const[g,h,m]=O(s,i);d>16?u=[g,h,m]:u=[g,m],u.forEach((p,c)=>{const $=~~(p/r*1e3)/1e3,b=o+(c+1),w=l+(c+1)/10,f=H(c+1,u,o,n),x={key:e+(c+1),variable:b,value:p,scaling:$,scalingVariable:f,index:w};y(x,n)})},I=1.618,W=(t,n,e)=>{if(t>=0)return n*Math.pow(e,t);const r=Math.abs(t),s=n*Math.pow(e,t),i=n*Math.pow(e,r)/Math.pow(I,2*r);return Math.max(s,i)},tt=t=>{const{type:n,base:e,ratio:r,range:s,subSequence:i}=t,o=Math.abs(s[0])+Math.abs(s[1]),a="--"+(t.varPrefix?t.varPrefix+"-":"")+(n&&n.replace(".","-"))+"-";for(let d=0;d<=o;d++){const u=s[1]-d,g=S[u],h=W(u,e,r),m=~~(h/e*100)/100,p=a+g,c=C(u,t),$={key:g,variable:p,value:h,base:e,scaling:m,scalingVariable:c,ratio:r,index:u};y($,t),i&&R($,t)}return t},nt=(t,n=0)=>{const{type:e,base:r,ratio:s,subSequence:i}=t,o=V(n)?n:S[n],l=V(n)?Object.entries(S).find(([,$])=>$===n)?.[0]:n;if(!o)return console.warn(`Position ${n} is out of range in numToLetterMap`),null;const a={sequence:{},scales:{},vars:{},...t},d=r*Math.pow(s,l),u=~~(d/r*100)/100,m="--"+(t.varPrefix?t.varPrefix+"-":"")+(e&&e.replace(".","-"))+"-"+o,p=C(l,t),c={key:o,variable:m,value:d,base:r,scaling:u,scalingVariable:p,ratio:s,index:l};return y(c,a),i&&R(c,a),a},U=(t="A",n)=>{const e=A(),{unit:r}=e;if(V(t)&&j(t))return`var(${t})`;if(V(t)&&/^(?:env|var|calc|min|max|clamp)\(/.test(t.trim()))return t;if(V(t)){const f=e.sizes;if(f){const x=f[t]||f[t.toLowerCase()];if(x!==void 0)return t.slice(0,1)==="-"?`calc(${x} * -1)`:x}}const{sequence:s,unit:i=r.default,useVariable:o}=n,l=/^-?[a-zA-Z]/i,a=l.test(t);if(N(t)||!a||["none","auto","max-content","min-content","fit-content","inherit","initial","unset","revert","revert-layer"].includes(t))return t;const h=`--${n.varPrefix?n.varPrefix+"-":""}${T(n.type.replace(".","-"))}-`,m=t.toUpperCase(),p=m.slice(0,1)==="-"?"-":"";let c=p?m.slice(1):m,$="";c.includes("_")&&($="_"+c.split("_")[1].toLowerCase(),c=c.split("_")[0]);const b=f=>l.test(f)?`var(${h}${f}${$})`:f;if(c.includes("+")){const[f,x]=c.split("+"),v=`${b(f)} + ${b(x)}`;return p?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("*")){const[f,x]=c.split("*"),v=`${b(f)} * ${b(x)}`;return p?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("-")){const[f,x]=c.split("-"),v=`${b(f)} - ${b(x)}`;return p?`calc((${v}) * -1)`:`calc(${v})`}if(!s[c]&&c.length===2&&(e.verbose&&console.warn(c,"- value is not found because `subSequence` is set to false"),c=c.slice(0,1)),o||e.useVariable){const f=`var(${h}${c}${$})`;return p?`calc(${f} * -1)`:f}const w=s?s[c]:null;if(!w){if(console.warn("can't find",s,c),_())throw new Error(`[smbls] Unresolvable design-system token "${t}"`+(n.type?` for sequence "${n.type}"`:"")+" \u2014 not a registered `sizes` name and not a valid spacing/typography/timing sequence letter. The CSS property using it would silently be dropped in production. Register the token in `designSystem/sizes.js` (or the relevant sequence family) or fix the typo.");return}return i==="ms"||i==="s"?p+w.val+i:p+w.scaling+i},K=(t,n)=>{if(!["+","-","*","/",","].filter(o=>t.includes(o+" ")).length)return t;const r=/(\s+-\s+|\s*[+*/,]\s*)/,s=[];return D(t,s).split(r).map(o=>{const l=F(o,s),a=l.trim();return!a||["+","-","*","/",","].includes(a)?l:k(a,n)}).join("")},et=(t,n,e,r)=>{if(typeof t!="string")return A().verbose&&console.warn(n,t,"is not a string"),{[n]:t};if(t==="-"||t==="")return{};if(!r&&t.includes("(")){if(/^(?:env|var)\(/.test(t.trim()))return{[n]:t};const i=z(t);r=i[0],t=i[1]}return["+","-","*","/",","].filter(i=>t.includes(i+" ")).length?t=K(t,e):t=U(t,e),{[n]:r?`${r}(${t})`:t}},B=(t,n)=>S[t-n],rt=t=>{const{h1Matches:n,sequence:e}=t;return new Array(6).fill(null).map((r,s)=>{const i=B(n,s);return e[i]})};export{B as findHeadingLetter,rt as findHeadings,tt as generateSequence,nt as generateSequencePosition,R as generateSubSequence,z as getFnPrefixAndValue,U as getSequenceValue,K as getSequenceValueBySymbols,et as getSequenceValuePropertyPair,q as getSubratio,O as getSubratioDifference,S as numToLetterMap,C as setScalingVar,H as setSubScalingVar};
|