@symbo.ls/scratch 3.14.600 → 3.14.650
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
package/dist/cjs/src/set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var x=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";var x=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var k=(t,s)=>{for(var e in s)x(t,e,{get:s[e],enumerable:!0})},j=(t,s,e,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of q(s))!G.call(t,n)&&n!==e&&x(t,n,{get:()=>s[n],enumerable:!(c=N(s,n))||c.enumerable});return t};var W=t=>j(x({},"__esModule",{value:!0}),t);var B={};k(B,{VALUE_TRANSFORMERS:()=>E,changeGlobalTheme:()=>$,set:()=>U,setEach:()=>M,setValue:()=>P});module.exports=W(B);var p=require("./factory.js"),o=require("./system/index.js"),S=require("@symbo.ls/utils");const Y=(t,s)=>{const e=(0,p.getActiveConfig)(),{cssVars:c}=e,n=s.startsWith("--")?s:`--${s}`;return c[n]=t,t},l=t=>t,E={color:o.setColor,gradient:o.setGradient,font:o.setFont,fontFamily:o.setFontFamily,fontfamily:o.setFontFamily,theme:o.setTheme,icons:o.setSvgIcon,semanticIcons:l,semanticicons:l,svg:o.setSVG,svgData:l,typography:l,shadow:o.setShadow,spacing:l,media:l,grid:l,class:l,timing:l,reset:l,unit:l,animation:l,vars:Y,sizes:l},P=(t,s,e)=>{const c=(0,p.getActiveConfig)(),n=(0,p.toCamel)(t),i=n.toLowerCase(),f=c[n]||c[i]||c[t],r=E[n]||E[i];if(r)try{const d=r(s,e);return f&&(f[e]=d),f}catch(d){c.verbose&&console.warn("Error setting",i,"value",s,e,d)}c.verbose&&console.warn("Can not find",i,"method in scratch")},M=(t,s)=>{const e=(0,p.getActiveConfig)(),c=t.toLowerCase();return Object.keys(s).sort((i,f)=>{const r=(0,S.isObject)(s[i])||(0,S.isArray)(s[i])?1:0,d=(0,S.isObject)(s[f])||(0,S.isArray)(s[f])?1:0;return r-d}).forEach(i=>{try{return P(c,s[i],i)}catch(f){e.verbose&&console.warn("Error setting",c,"value",s[i],i,f)}}),e[c]||e[t]},$=(t,s)=>{const e=s||(0,p.getActiveConfig)();e.globalTheme=t;const n=(e.document&&e.document.documentElement?e.document:null)||(typeof document<"u"?document:null),i=n&&n.defaultView||(typeof window<"u"?window:null);if(n){const r=e.themeRoot||n.documentElement;if(t&&t!=="auto")r.setAttribute("data-theme",t),t==="dark"||t==="light"?r.style.colorScheme=t:r.style.colorScheme="light dark";else if(i&&i.matchMedia){const u=g=>{r.setAttribute("data-theme",g.matches?"dark":"light")},m=i.matchMedia("(prefers-color-scheme: dark)");if(u(m),r.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=u;try{m.addEventListener("change",u)}catch{m.addListener(u)}}}else r.setAttribute("data-theme","light"),r.style.colorScheme="light"}const f=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const r in e.cssVars)r.startsWith(f)&&delete e.cssVars[r];for(const r in e.cssMediaVars)delete e.cssMediaVars[r];if(n&&e.cssVars){const r=e.scopeSelector||":root",d=n.styleSheets;for(let u=0;u<d.length;u++)try{const m=d[u].cssRules;for(let g=0;g<m.length;g++)if(m[g].selectorText===r){for(const b in e.cssVars)m[g].style.setProperty(b,e.cssVars[b]);return e}}catch{}}return e},z={},U=(t,s=z)=>{let e=s.config||(0,p.getActiveConfig)();const{version:c,verbose:n,useVariable:i,useReset:f,useSvgSprite:r,useFontImport:d,useIconSprite:u,globalTheme:m,themeRoot:g,useDocumentTheme:b,useDefaultConfig:I,semanticIcons:R,hoverMedia:A,files:F,assets:_,...v}=t;s.newConfig&&(e=(0,p.setActiveConfig)(s.newConfig)),F!==void 0&&(e.files=F),_!==void 0&&(e.assets=_),n!==void 0&&(e.verbose=n),i!==void 0&&(e.useVariable=i),f!==void 0&&(e.useReset=f),d!==void 0&&(e.useFontImport=d),r!==void 0&&(e.useSvgSprite=r),u!==void 0&&(e.useIconSprite=u),b!==void 0&&(e.useDocumentTheme=b),m!==void 0&&(e.globalTheme=m),g!==void 0&&(e.themeRoot=g),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),I!==void 0&&(e.useDefaultConfig=I),R!==void 0&&(e.semanticIcons=R),A!==void 0&&(e.hoverMedia=A),e.verbose&&console.log(e);const C=(e.document&&e.document.documentElement?e.document:null)||(typeof document<"u"?document:null),w=C&&C.defaultView||(typeof window<"u"?window:null),y=C&&(e.themeRoot||C.documentElement);if(y&&typeof y.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")y.setAttribute("data-theme",e.globalTheme),e.globalTheme==="dark"||e.globalTheme==="light"?y.style.colorScheme=e.globalTheme:y.style.colorScheme="light dark";else if(w&&w.matchMedia){const h=D=>{y.setAttribute("data-theme",D.matches?"dark":"light")},V=w.matchMedia("(prefers-color-scheme: dark)");if(h(V),y.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=h;try{V.addEventListener("change",h)}catch{V.addListener(h)}}}else y.setAttribute("data-theme","light"),y.style.colorScheme="light";e.__svgCache||(e.__svgCache={});const T=Object.keys(v),L=new Set(T);if(T.forEach(a=>{const h=a.toLowerCase();h!==a&&L.has(h)&&(0,S.deepMerge)(v[h],v[a])}),T.map(a=>{const h=a.toLowerCase();if(!(h!==a&&L.has(h)))return M(a,v[a])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),v.typography)try{(0,o.applyTypographySequence)()}catch(a){e.verbose&&console.warn("Error applying typography sequence",a)}if(v.spacing)try{(0,o.applySpacingSequence)()}catch(a){e.verbose&&console.warn("Error applying spacing sequence",a)}if(v.timing)try{(0,o.applyTimingSequence)()}catch(a){e.verbose&&console.warn("Error applying timing sequence",a)}(0,o.applyDocument)();const O=(0,o.applyReset)();return O&&(e.reset=O),e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var
|
|
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 i of q(e))!G.call(t,i)&&i!==n&&p(t,i,{get:()=>e[i],enumerable:!(s=I(e,i))||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"),u=require("@symbo.ls/utils"),g=require("../factory.js"),o=require("../utils/index.js");const b=t=>{const n=(0,g.getActiveConfig)().spacing||{},s=parseFloat(t.spacingRatio),i={...n,ratio:Number.isFinite(s)?s:n.ratio,sequence:{},scales:{}};return(0,o.generateSequence)(i),i},k=t=>{for(const e in t){const n=t[e];if(!(e.slice(0,1)==="@"))continue;const{type:i,base:r,ratio:c,range:a,subSequence:S,h1Matches:l,unit:d}=t;(0,u.merge)(n,{type:i,base:r,ratio:c,range:a,subSequence:S,h1Matches:l,unit:d,sequence:{},scales:{},templates:{},vars:{}}),(0,o.generateSequence)(n),(0,o.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,o.generateSequence)(e),(0,o.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,o.generateSequence)(t)},h=(t,e="padding",n,s)=>{const i=V(n);if((0,u.isString)(t)){if(!s&&/^(?:env|var)\(/.test(t.trim()))return{[e]:t};if(!s&&t.includes("(")){const c=(0,o.getFnPrefixAndValue)(t);s=c[0],t=c[1]}}const r=s?[t]:(0,m.arrayzeValue)(t);if((0,u.isArray)(r)){if(r.length>1){let c="";e==="borderWidth"&&(e="border",c="Width");const a={2:["Block","Inline"],3:["BlockStart","Inline","BlockEnd"],4:["BlockStart","InlineEnd","BlockEnd","InlineStart"]},S=(l,d)=>(0,o.getSequenceValuePropertyPair)(r[d],e+l+c,i,s);return a[r.length].map((l,d)=>S(l,d))}return(0,o.getSequenceValuePropertyPair)(t,e,i,s)}},N=(t,e,n,s)=>{const i=(0,g.getActiveConfig)(),{spacing:r}=i;let c=n||t[e];if(!s&&(0,u.isString)(c)&&/^(?:env|var)\(/.test(c.trim()))return{[e]:c};if(!s&&(0,u.isString)(c)&&c.includes("(")){const a=(0,o.getFnPrefixAndValue)(c);s=a[0],c=a[1]}if(t.spacingRatio){const a=b(t);return h(c,e,a,s)}return h(c,e,r,s)},F=t=>{const e=n=>{const s=["+","-","*","/"].includes(n),i=o.CSS_UNITS.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(" ")};
|
package/dist/esm/src/set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getActiveConfig as S,setActiveConfig as
|
|
1
|
+
import{getActiveConfig as S,setActiveConfig as P,toCamel as M}from"./factory.js";import{setColor as N,setGradient as q,setFont as G,setFontFamily as _,setTheme as k,setSvgIcon as j,setSVG as W,applyTypographySequence as Y,applySpacingSequence as $,applyReset as z,applyTimingSequence as U,applyDocument as B,setShadow as H}from"./system/index.js";import{deepMerge as J,isObject as L,isArray as O}from"@symbo.ls/utils";const K=(t,o)=>{const e=S(),{cssVars:c}=e,r=o.startsWith("--")?o:`--${o}`;return c[r]=t,t},f=t=>t,D={color:N,gradient:q,font:G,fontFamily:_,fontfamily:_,theme:k,icons:j,semanticIcons:f,semanticicons:f,svg:W,svgData:f,typography:f,shadow:H,spacing:f,media:f,grid:f,class:f,timing:f,reset:f,unit:f,animation:f,vars:K,sizes:f},Q=(t,o,e)=>{const c=S(),r=M(t),n=r.toLowerCase(),a=c[r]||c[n]||c[t],s=D[r]||D[n];if(s)try{const l=s(o,e);return a&&(a[e]=l),a}catch(l){c.verbose&&console.warn("Error setting",n,"value",o,e,l)}c.verbose&&console.warn("Can not find",n,"method in scratch")},X=(t,o)=>{const e=S(),c=t.toLowerCase();return Object.keys(o).sort((n,a)=>{const s=L(o[n])||O(o[n])?1:0,l=L(o[a])||O(o[a])?1:0;return s-l}).forEach(n=>{try{return Q(c,o[n],n)}catch(a){e.verbose&&console.warn("Error setting",c,"value",o[n],n,a)}}),e[c]||e[t]},re=(t,o)=>{const e=o||S();e.globalTheme=t;const r=(e.document&&e.document.documentElement?e.document:null)||(typeof document<"u"?document:null),n=r&&r.defaultView||(typeof window<"u"?window:null);if(r){const s=e.themeRoot||r.documentElement;if(t&&t!=="auto")s.setAttribute("data-theme",t),t==="dark"||t==="light"?s.style.colorScheme=t:s.style.colorScheme="light dark";else if(n&&n.matchMedia){const d=h=>{s.setAttribute("data-theme",h.matches?"dark":"light")},u=n.matchMedia("(prefers-color-scheme: dark)");if(d(u),s.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=d;try{u.addEventListener("change",d)}catch{u.addListener(d)}}}else s.setAttribute("data-theme","light"),s.style.colorScheme="light"}const a=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const s in e.cssVars)s.startsWith(a)&&delete e.cssVars[s];for(const s in e.cssMediaVars)delete e.cssMediaVars[s];if(r&&e.cssVars){const s=e.scopeSelector||":root",l=r.styleSheets;for(let d=0;d<l.length;d++)try{const u=l[d].cssRules;for(let h=0;h<u.length;h++)if(u[h].selectorText===s){for(const y in e.cssVars)u[h].style.setProperty(y,e.cssVars[y]);return e}}catch{}}return e},Z={},ie=(t,o=Z)=>{let e=o.config||S();const{version:c,verbose:r,useVariable:n,useReset:a,useSvgSprite:s,useFontImport:l,useIconSprite:d,globalTheme:u,themeRoot:h,useDocumentTheme:y,useDefaultConfig:T,semanticIcons:V,hoverMedia:x,files:E,assets:I,...p}=t;o.newConfig&&(e=P(o.newConfig)),E!==void 0&&(e.files=E),I!==void 0&&(e.assets=I),r!==void 0&&(e.verbose=r),n!==void 0&&(e.useVariable=n),a!==void 0&&(e.useReset=a),l!==void 0&&(e.useFontImport=l),s!==void 0&&(e.useSvgSprite=s),d!==void 0&&(e.useIconSprite=d),y!==void 0&&(e.useDocumentTheme=y),u!==void 0&&(e.globalTheme=u),h!==void 0&&(e.themeRoot=h),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),T!==void 0&&(e.useDefaultConfig=T),V!==void 0&&(e.semanticIcons=V),x!==void 0&&(e.hoverMedia=x),e.verbose&&console.log(e);const v=(e.document&&e.document.documentElement?e.document:null)||(typeof document<"u"?document:null),b=v&&v.defaultView||(typeof window<"u"?window:null),g=v&&(e.themeRoot||v.documentElement);if(g&&typeof g.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")g.setAttribute("data-theme",e.globalTheme),e.globalTheme==="dark"||e.globalTheme==="light"?g.style.colorScheme=e.globalTheme:g.style.colorScheme="light dark";else if(b&&b.matchMedia){const m=F=>{g.setAttribute("data-theme",F.matches?"dark":"light")},w=b.matchMedia("(prefers-color-scheme: dark)");if(m(w),g.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=m;try{w.addEventListener("change",m)}catch{w.addListener(m)}}}else g.setAttribute("data-theme","light"),g.style.colorScheme="light";e.__svgCache||(e.__svgCache={});const C=Object.keys(p),R=new Set(C);if(C.forEach(i=>{const m=i.toLowerCase();m!==i&&R.has(m)&&J(p[m],p[i])}),C.map(i=>{const m=i.toLowerCase();if(!(m!==i&&R.has(m)))return X(i,p[i])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),p.typography)try{Y()}catch(i){e.verbose&&console.warn("Error applying typography sequence",i)}if(p.spacing)try{$()}catch(i){e.verbose&&console.warn("Error applying spacing sequence",i)}if(p.timing)try{U()}catch(i){e.verbose&&console.warn("Error applying timing sequence",i)}B();const A=z();return A&&(e.reset=A),e};export{D as VALUE_TRANSFORMERS,re as changeGlobalTheme,ie as set,X as setEach,Q as setValue};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{arrayzeValue as I}from"@symbo.ls/utils";import{isArray as
|
|
1
|
+
import{arrayzeValue as I}from"@symbo.ls/utils";import{isArray as q,isString as S,merge as G}from"@symbo.ls/utils";import{getActiveConfig as l}from"../factory.js";import{CSS_UNITS as B,applyMediaSequenceVars as C,applySequenceVars as f,generateSequence as d,getFnPrefixAndValue as p,getSequenceValuePropertyPair as h}from"../utils/index.js";const b=t=>{const n=l().spacing||{},s=parseFloat(t.spacingRatio),i={...n,ratio:Number.isFinite(s)?s:n.ratio,sequence:{},scales:{}};return d(i),i},k=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:g,h1Matches:a,unit:u}=t;G(n,{type:i,base:o,ratio:c,range:r,subSequence:g,h1Matches:a,unit:u,sequence:{},scales:{},templates:{},vars:{}}),d(n),C(t,e)}},M=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=l(),{spacing:e}=t;d(e),f(e),k(e)},y=t=>{const e=l(),{spacing:n}=e;return!t||!t.sequence?n:Object.keys(t.sequence).length>0?t:d(t)},m=(t,e="padding",n,s)=>{const i=y(n);if(S(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]: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"]},g=(a,u)=>h(o[u],e+a+c,i,s);return r[o.length].map((a,u)=>g(a,u))}return h(t,e,i,s)}},j=(t,e,n,s)=>{const i=l(),{spacing:o}=i;let c=n||t[e];if(!s&&S(c)&&/^(?:env|var)\(/.test(c.trim()))return{[e]:c};if(!s&&S(c)&&c.includes("(")){const r=p(c);s=r[0],c=r[1]}if(t.spacingRatio){const r=b(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,M as checkIfBoxSize,j as getSpacingBasedOnRatio,m as getSpacingByKey,w as splitSpacedValue};
|