@symbo.ls/scratch 3.14.678 → 3.14.685
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 +8 -0
- package/dist/cjs/src/set.js +1 -1
- package/dist/esm/src/set.js +1 -1
- package/package.json +2 -2
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 k=(t
|
|
1
|
+
"use strict";var x=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var k=(s,t)=>{for(var e in t)x(s,e,{get:t[e],enumerable:!0})},j=(s,t,e,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of q(t))!G.call(s,r)&&r!==e&&x(s,r,{get:()=>t[r],enumerable:!(c=N(t,r))||c.enumerable});return s};var W=s=>j(x({},"__esModule",{value:!0}),s);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=(s,t)=>{const e=(0,p.getActiveConfig)(),{cssVars:c}=e,r=t.startsWith("--")?t:`--${t}`;return c[r]=s,s},d=s=>s,E={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:Y,sizes:d},P=(s,t,e)=>{const c=(0,p.getActiveConfig)(),r=(0,p.toCamel)(s),i=r.toLowerCase(),l=c[r]||c[i]||c[s],n=E[r]||E[i];if(n)try{const a=n(t,e);return l&&(l[e]=a),l}catch(a){c.verbose&&console.warn("Error setting",i,"value",t,e,a)}if(!n){const a=l||c[i]||(c[i]={});return a[e]=t,a}c.verbose&&console.warn("Can not find",i,"method in scratch")},M=(s,t)=>{const e=(0,p.getActiveConfig)(),c=s.toLowerCase();return Object.keys(t).sort((i,l)=>{const n=(0,S.isObject)(t[i])||(0,S.isArray)(t[i])?1:0,a=(0,S.isObject)(t[l])||(0,S.isArray)(t[l])?1:0;return n-a}).forEach(i=>{try{return P(c,t[i],i)}catch(l){e.verbose&&console.warn("Error setting",c,"value",t[i],i,l)}}),e[c]||e[s]},$=(s,t)=>{const e=t||(0,p.getActiveConfig)();e.globalTheme=s;const r=(e.document&&e.document.documentElement?e.document:null)||(typeof document<"u"?document:null),i=r&&r.defaultView||(typeof window<"u"?window:null);if(r){const n=e.themeRoot||r.documentElement;if(s&&s!=="auto")n.setAttribute("data-theme",s),s==="dark"||s==="light"?n.style.colorScheme=s:n.style.colorScheme="light dark";else if(i&&i.matchMedia){const u=g=>{n.setAttribute("data-theme",g.matches?"dark":"light")},m=i.matchMedia("(prefers-color-scheme: dark)");if(u(m),n.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=u;try{m.addEventListener("change",u)}catch{m.addListener(u)}}}else n.setAttribute("data-theme","light"),n.style.colorScheme="light"}const l=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const n in e.cssVars)n.startsWith(l)&&delete e.cssVars[n];for(const n in e.cssMediaVars)delete e.cssMediaVars[n];if(r&&e.cssVars){const n=e.scopeSelector||":root",a=r.styleSheets;for(let u=0;u<a.length;u++)try{const m=a[u].cssRules;for(let g=0;g<m.length;g++)if(m[g].selectorText===n){for(const v in e.cssVars)m[g].style.setProperty(v,e.cssVars[v]);return e}}catch{}}return e},z={},U=(s,t=z)=>{let e=t.config||(0,p.getActiveConfig)();const{version:c,verbose:r,useVariable:i,useReset:l,useSvgSprite:n,useFontImport:a,useIconSprite:u,globalTheme:m,themeRoot:g,useDocumentTheme:v,useDefaultConfig:I,semanticIcons:R,hoverMedia:A,files:F,assets:_,...b}=s;t.newConfig&&(e=(0,p.setActiveConfig)(t.newConfig)),F!==void 0&&(e.files=F),_!==void 0&&(e.assets=_),r!==void 0&&(e.verbose=r),i!==void 0&&(e.useVariable=i),l!==void 0&&(e.useReset=l),a!==void 0&&(e.useFontImport=a),n!==void 0&&(e.useSvgSprite=n),u!==void 0&&(e.useIconSprite=u),v!==void 0&&(e.useDocumentTheme=v),m!==void 0&&(e.globalTheme=m),g!==void 0&&(e.themeRoot=g),s.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=s.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(b),L=new Set(T);if(T.forEach(f=>{const h=f.toLowerCase();h!==f&&L.has(h)&&(0,S.deepMerge)(b[h],b[f])}),T.map(f=>{const h=f.toLowerCase();if(!(h!==f&&L.has(h)))return M(f,b[f])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),b.typography)try{(0,o.applyTypographySequence)()}catch(f){e.verbose&&console.warn("Error applying typography sequence",f)}if(b.spacing)try{(0,o.applySpacingSequence)()}catch(f){e.verbose&&console.warn("Error applying spacing sequence",f)}if(b.timing)try{(0,o.applyTimingSequence)()}catch(f){e.verbose&&console.warn("Error applying timing sequence",f)}(0,o.applyDocument)();const O=(0,o.applyReset)();return O&&(e.reset=O),e};
|
package/dist/esm/src/set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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=(
|
|
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=(s,o)=>{const e=S(),{cssVars:i}=e,r=o.startsWith("--")?o:`--${o}`;return i[r]=s,s},l=s=>s,D={color:N,gradient:q,font:G,fontFamily:_,fontfamily:_,theme:k,icons:j,semanticIcons:l,semanticicons:l,svg:W,svgData:l,typography:l,shadow:H,spacing:l,media:l,grid:l,class:l,timing:l,reset:l,unit:l,animation:l,vars:K,sizes:l},Q=(s,o,e)=>{const i=S(),r=M(s),n=r.toLowerCase(),f=i[r]||i[n]||i[s],t=D[r]||D[n];if(t)try{const c=t(o,e);return f&&(f[e]=c),f}catch(c){i.verbose&&console.warn("Error setting",n,"value",o,e,c)}if(!t){const c=f||i[n]||(i[n]={});return c[e]=o,c}i.verbose&&console.warn("Can not find",n,"method in scratch")},X=(s,o)=>{const e=S(),i=s.toLowerCase();return Object.keys(o).sort((n,f)=>{const t=L(o[n])||O(o[n])?1:0,c=L(o[f])||O(o[f])?1:0;return t-c}).forEach(n=>{try{return Q(i,o[n],n)}catch(f){e.verbose&&console.warn("Error setting",i,"value",o[n],n,f)}}),e[i]||e[s]},re=(s,o)=>{const e=o||S();e.globalTheme=s;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 t=e.themeRoot||r.documentElement;if(s&&s!=="auto")t.setAttribute("data-theme",s),s==="dark"||s==="light"?t.style.colorScheme=s:t.style.colorScheme="light dark";else if(n&&n.matchMedia){const d=h=>{t.setAttribute("data-theme",h.matches?"dark":"light")},u=n.matchMedia("(prefers-color-scheme: dark)");if(d(u),t.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=d;try{u.addEventListener("change",d)}catch{u.addListener(d)}}}else t.setAttribute("data-theme","light"),t.style.colorScheme="light"}const f=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const t in e.cssVars)t.startsWith(f)&&delete e.cssVars[t];for(const t in e.cssMediaVars)delete e.cssMediaVars[t];if(r&&e.cssVars){const t=e.scopeSelector||":root",c=r.styleSheets;for(let d=0;d<c.length;d++)try{const u=c[d].cssRules;for(let h=0;h<u.length;h++)if(u[h].selectorText===t){for(const y in e.cssVars)u[h].style.setProperty(y,e.cssVars[y]);return e}}catch{}}return e},Z={},ie=(s,o=Z)=>{let e=o.config||S();const{version:i,verbose:r,useVariable:n,useReset:f,useSvgSprite:t,useFontImport:c,useIconSprite:d,globalTheme:u,themeRoot:h,useDocumentTheme:y,useDefaultConfig:T,semanticIcons:V,hoverMedia:x,files:E,assets:I,...p}=s;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),f!==void 0&&(e.useReset=f),c!==void 0&&(e.useFontImport=c),t!==void 0&&(e.useSvgSprite=t),d!==void 0&&(e.useIconSprite=d),y!==void 0&&(e.useDocumentTheme=y),u!==void 0&&(e.globalTheme=u),h!==void 0&&(e.themeRoot=h),s.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=s.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 b=(e.document&&e.document.documentElement?e.document:null)||(typeof document<"u"?document:null),v=b&&b.defaultView||(typeof window<"u"?window:null),g=b&&(e.themeRoot||b.documentElement);if(g&&typeof g.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")g.setAttribute("data-theme",e.globalTheme),e.globalTheme==="dark"||e.globalTheme==="light"?g.style.colorScheme=e.globalTheme:g.style.colorScheme="light dark";else if(v&&v.matchMedia){const m=F=>{g.setAttribute("data-theme",F.matches?"dark":"light")},w=v.matchMedia("(prefers-color-scheme: dark)");if(m(w),g.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=m;try{w.addEventListener("change",m)}catch{w.addListener(m)}}}else g.setAttribute("data-theme","light"),g.style.colorScheme="light";e.__svgCache||(e.__svgCache={});const C=Object.keys(p),R=new Set(C);if(C.forEach(a=>{const m=a.toLowerCase();m!==a&&R.has(m)&&J(p[m],p[a])}),C.map(a=>{const m=a.toLowerCase();if(!(m!==a&&R.has(m)))return X(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{Y()}catch(a){e.verbose&&console.warn("Error applying typography sequence",a)}if(p.spacing)try{$()}catch(a){e.verbose&&console.warn("Error applying spacing sequence",a)}if(p.timing)try{U()}catch(a){e.verbose&&console.warn("Error applying timing sequence",a)}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};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@symbo.ls/scratch",
|
|
3
3
|
"description": "Φ / CSS framework and methodology.",
|
|
4
4
|
"author": "symbo.ls",
|
|
5
|
-
"version": "3.14.
|
|
5
|
+
"version": "3.14.685",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
8
8
|
"*.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"prepublishOnly": "npm run build"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@symbo.ls/utils": "^3.14.
|
|
36
|
+
"@symbo.ls/utils": "^3.14.685",
|
|
37
37
|
"color-contrast-checker": "^1.5.0"
|
|
38
38
|
},
|
|
39
39
|
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|