@symbo.ls/scratch 3.14.104 → 3.14.135

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @symbo.ls/scratch
2
2
 
3
+ ## 3.14.135
4
+
5
+ ### Patch Changes
6
+
7
+ - Auto-generated cross-repo patch release.
8
+
9
+ ## 3.14.105
10
+
11
+ ### Patch Changes
12
+
13
+ - Manual patch bump triggered via workflow_dispatch (scope: all).
14
+ No source change behind this bump — released to refresh dist or
15
+ coordinate a cross-package version line.
16
+ - Updated dependencies
17
+ - @symbo.ls/utils@3.14.105
18
+
3
19
  ## 3.14.104
4
20
 
5
21
  ### Patch Changes
@@ -1 +1 @@
1
- "use strict";var m=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var i=(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))!a.call(e,x)&&x!==p&&m(e,x,{get:()=>t[x],enumerable:!(s=c(t,x))||s.enumerable});return e},o=(e,t,p)=>(f(e,t,"default"),p&&f(p,t,"default"));var u=e=>f(m({},"__esModule",{value:!0}),e);var r={};i(r,{reset:()=>v,vars:()=>b});module.exports=u(r);o(r,require("./sequence.js"),module.exports);o(r,require("./unit.js"),module.exports);o(r,require("./typography.js"),module.exports);o(r,require("./font.js"),module.exports);o(r,require("./font-family.js"),module.exports);o(r,require("./media.js"),module.exports);o(r,require("./spacing.js"),module.exports);o(r,require("./color.js"),module.exports);o(r,require("./theme.js"),module.exports);o(r,require("./shadow.js"),module.exports);o(r,require("./icons.js"),module.exports);o(r,require("./timing.js"),module.exports);o(r,require("./document.js"),module.exports);o(r,require("./responsive.js"),module.exports);o(r,require("./animation.js"),module.exports);o(r,require("./svg.js"),module.exports);o(r,require("./templates.js"),module.exports);o(r,require("./grid.js"),module.exports);o(r,require("./class.js"),module.exports);const v={},b={};
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 u=e=>f(m({},"__esModule",{value:!0}),e);var o={};a(o,{reset:()=>v,sizes:()=>b,vars:()=>z});module.exports=u(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 v={},z={},b={};
@@ -1 +1 @@
1
- "use strict";var x=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var M=(t,s)=>{for(var e in s)x(t,e,{get:s[e],enumerable:!0})},k=(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 j=t=>k(x({},"__esModule",{value:!0}),t);var z={};M(z,{VALUE_TRANSFORMERS:()=>E,changeGlobalTheme:()=>Y,set:()=>U,setEach:()=>P,setValue:()=>D});module.exports=j(z);var p=require("./factory.js"),o=require("./system/index.js"),S=require("@symbo.ls/utils");const W=(t,s)=>{const e=(0,p.getActiveConfig)(),{cssVars:c}=e,n=s.startsWith("--")?s:`--${s}`;return c[n]=t,t},d=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: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:W},D=(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 l=r(s,e);return f&&(f[e]=l),f}catch(l){c.verbose&&console.warn("Error setting",i,"value",s,e,l)}c.verbose&&console.warn("Can not find",i,"method in scratch")},P=(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,l=(0,S.isObject)(s[f])||(0,S.isArray)(s[f])?1:0;return r-l}).forEach(i=>{try{return D(c,s[i],i)}catch(f){e.verbose&&console.warn("Error setting",c,"value",s[i],i,f)}}),e[c]||e[t]},Y=(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",l=n.styleSheets;for(let u=0;u<l.length;u++)try{const m=l[u].cssRules;for(let g=0;g<m.length;g++)if(m[g].selectorText===r){for(const v in e.cssVars)m[g].style.setProperty(v,e.cssVars[v]);return e}}catch{}}return e},$={},U=(t,s=$)=>{let e=s.config||(0,p.getActiveConfig)();const{version:c,verbose:n,useVariable:i,useReset:f,useSvgSprite:r,useFontImport:l,useIconSprite:u,globalTheme:m,themeRoot:g,useDocumentTheme:v,useDefaultConfig:I,semanticIcons:R,files:A,assets:F,...b}=t;s.newConfig&&(e=(0,p.setActiveConfig)(s.newConfig)),A!==void 0&&(e.files=A),F!==void 0&&(e.assets=F),n!==void 0&&(e.verbose=n),i!==void 0&&(e.useVariable=i),f!==void 0&&(e.useReset=f),l!==void 0&&(e.useFontImport=l),r!==void 0&&(e.useSvgSprite=r),u!==void 0&&(e.useIconSprite=u),v!==void 0&&(e.useDocumentTheme=v),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),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=O=>{y.setAttribute("data-theme",O.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),_=new Set(T);if(T.forEach(a=>{const h=a.toLowerCase();h!==a&&_.has(h)&&(0,S.deepMerge)(b[h],b[a])}),T.map(a=>{const h=a.toLowerCase();if(!(h!==a&&_.has(h)))return P(a,b[a])}),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(a){e.verbose&&console.warn("Error applying typography sequence",a)}if(b.spacing)try{(0,o.applySpacingSequence)()}catch(a){e.verbose&&console.warn("Error applying spacing sequence",a)}if(b.timing)try{(0,o.applyTimingSequence)()}catch(a){e.verbose&&console.warn("Error applying timing sequence",a)}(0,o.applyDocument)();const L=(0,o.applyReset)();return L&&(e.reset=L),e};
1
+ "use strict";var x=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var M=(t,s)=>{for(var e in s)x(t,e,{get:s[e],enumerable:!0})},k=(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 j=t=>k(x({},"__esModule",{value:!0}),t);var U={};M(U,{VALUE_TRANSFORMERS:()=>E,changeGlobalTheme:()=>Y,set:()=>z,setEach:()=>P,setValue:()=>D});module.exports=j(U);var p=require("./factory.js"),o=require("./system/index.js"),S=require("@symbo.ls/utils");const W=(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:W,sizes:l},D=(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")},P=(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 D(c,s[i],i)}catch(f){e.verbose&&console.warn("Error setting",c,"value",s[i],i,f)}}),e[c]||e[t]},Y=(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 v in e.cssVars)m[g].style.setProperty(v,e.cssVars[v]);return e}}catch{}}return e},$={},z=(t,s=$)=>{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:v,useDefaultConfig:I,semanticIcons:R,files:A,assets:F,...b}=t;s.newConfig&&(e=(0,p.setActiveConfig)(s.newConfig)),A!==void 0&&(e.files=A),F!==void 0&&(e.assets=F),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),v!==void 0&&(e.useDocumentTheme=v),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),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=O=>{y.setAttribute("data-theme",O.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),_=new Set(T);if(T.forEach(a=>{const h=a.toLowerCase();h!==a&&_.has(h)&&(0,S.deepMerge)(b[h],b[a])}),T.map(a=>{const h=a.toLowerCase();if(!(h!==a&&_.has(h)))return P(a,b[a])}),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(a){e.verbose&&console.warn("Error applying typography sequence",a)}if(b.spacing)try{(0,o.applySpacingSequence)()}catch(a){e.verbose&&console.warn("Error applying spacing sequence",a)}if(b.timing)try{(0,o.applyTimingSequence)()}catch(a){e.verbose&&console.warn("Error applying timing sequence",a)}(0,o.applyDocument)();const L=(0,o.applyReset)();return L&&(e.reset=L),e};
@@ -1 +1 @@
1
- "use strict";var y=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var E=(t,n)=>{for(var e in n)y(t,e,{get:n[e],enumerable:!0})},z=(t,n,e,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of G(n))!H.call(t,r)&&r!==e&&y(t,r,{get:()=>n[r],enumerable:!(s=W(n,r))||s.enumerable});return t};var B=t=>z(y({},"__esModule",{value:!0}),t);var P={};E(P,{findHeadingLetter:()=>D,findHeadings:()=>k,generateSequence:()=>Q,generateSequencePosition:()=>X,generateSubSequence:()=>C,getFnPrefixAndValue:()=>_,getSequenceValue:()=>U,getSequenceValueBySymbols:()=>j,getSequenceValuePropertyPair:()=>Y,getSubratio:()=>Z,getSubratioDifference:()=>O,numToLetterMap:()=>b,setScalingVar:()=>L,setSubScalingVar:()=>F});module.exports=B(P);var w=require("@symbo.ls/utils"),R=require("@symbo.ls/utils"),I=require("../factory.js"),M=require("./unit.js"),T=require("./color.js");const b={"-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:c,index:o,scalingVariable:p}=t;n.sequence[e]={key:e,decimal:~~(r*100)/100,val:~~r,scaling:c,index:o,scalingVariable:p,variable:s},n.scales[e]=c;const a=K.has(n.unit)?"rem":n.unit;n.vars[s]=c+a},_=t=>{if(!t.includes("("))return t;const n=t.split("(")[0],e=t.slice(t.indexOf("(")+1,t.lastIndexOf(")"));return[n,e]},K=new Set(["vw","vh","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh"]),L=(t,n)=>{const{base:e,type:s,unit:r}=n,c=K.has(r)?"rem":r,o=((0,M.isScalingUnit)(c)?1:e)+c;if(t===0)return o;const a="--"+(n.varPrefix?n.varPrefix+"-":"")+(s&&s.replace(".","-")),u=`${a}-ratio`;if(t>0){const l=b[t-1];return`calc(var(${a}-${l}) * var(${u}))`}if(t<0){const l=b[t+1],$=Math.abs(t),h=Math.pow(N,2*$),x=b[$];return x?`max(calc(var(${a}-${l}) / var(${u})), calc(var(${a}-${x}) / ${h.toFixed(4)}))`:`calc(var(${a}-${l}) / var(${u}))`}},F=(t,n,e,s)=>{const{type:r}=s,o=t===2&&n.length===2?t+1:t,u=`${"--"+(s.varPrefix?s.varPrefix+"-":"")+(r&&r.replace(".","-"))}-sub-ratio-`;return`calc(var(${e}) * var(${u+o}))`},O=(t,n)=>{const s=(t*n-t)/1.618,r=t*n-s,c=t+s,o=(r+c)/2;return[r,o,c]},Z=(t,n)=>O(t,n).map(e=>e/t),C=(t,n)=>{const{key:e,base:s,value:r,ratio:c,variable:o,index:p}=t,u=~~(r*c)-~~r;let l;const[$,h,x]=O(r,c);u>16?l=[$,h,x]:l=[$,x],l.forEach((d,i)=>{const g=~~(d/s*1e3)/1e3,m=o+(i+1),V=p+(i+1)/10,f=F(i+1,l,o,n),S={key:e+(i+1),variable:m,value:d,scaling:g,scalingVariable:f,index:V};A(S,n)})},N=1.618,J=(t,n,e)=>{if(t>=0)return n*Math.pow(e,t);const s=Math.abs(t),r=n*Math.pow(e,t),c=n*Math.pow(e,s)/Math.pow(N,2*s);return Math.max(r,c)},Q=t=>{const{type:n,base:e,ratio:s,range:r,subSequence:c}=t,o=Math.abs(r[0])+Math.abs(r[1]),a="--"+(t.varPrefix?t.varPrefix+"-":"")+(n&&n.replace(".","-"))+"-";for(let u=0;u<=o;u++){const l=r[1]-u,$=b[l],h=J(l,e,s),x=~~(h/e*100)/100,d=a+$,i=L(l,t),g={key:$,variable:d,value:h,base:e,scaling:x,scalingVariable:i,ratio:s,index:l};A(g,t),c&&C(g,t)}return t},X=(t,n=0)=>{const{type:e,base:s,ratio:r,subSequence:c}=t,o=(0,w.isString)(n)?n:b[n],p=(0,w.isString)(n)?Object.entries(b).find(([,g])=>g===n)?.[0]:n;if(!o)return console.warn(`Position ${n} is out of range in numToLetterMap`),null;const a={sequence:{},scales:{},vars:{},...t},u=s*Math.pow(r,p),l=~~(u/s*100)/100,x="--"+(t.varPrefix?t.varPrefix+"-":"")+(e&&e.replace(".","-"))+"-"+o,d=L(p,t),i={key:o,variable:x,value:u,base:s,scaling:l,scalingVariable:d,ratio:r,index:p};return A(i,a),c&&C(i,a),a},U=(t="A",n)=>{const e=(0,I.getActiveConfig)(),{unit:s}=e;if((0,w.isString)(t)&&(0,T.isCSSVar)(t))return`var(${t})`;const{sequence:r,unit:c=s.default,useVariable:o}=n,p=/^-?[a-zA-Z]/i,a=p.test(t);if(M.CSS_UNITS.some(f=>t.includes(f))||!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,R.toDashCase)(n.type.replace(".","-"))}-`,x=t.toUpperCase(),d=x.slice(0,1)==="-"?"-":"";let i=d?x.slice(1):x,g="";i.includes("_")&&(g="_"+i.split("_")[1].toLowerCase(),i=i.split("_")[0]);const m=f=>p.test(f)?`var(${h}${f}${g})`:f;if(i.includes("+")){const[f,S]=i.split("+"),v=`${m(f)} + ${m(S)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}else if(i.includes("*")){const[f,S]=i.split("*"),v=`${m(f)} * ${m(S)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}else if(i.includes("-")){const[f,S]=i.split("-"),v=`${m(f)} - ${m(S)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}if(!r[i]&&i.length===2&&(e.verbose&&console.warn(i,"- value is not found because `subSequence` is set to false"),i=i.slice(0,1)),o||e.useVariable){const f=`var(${h}${i}${g})`;return d?`calc(${f} * -1)`:f}const V=r?r[i]:null;return V?c==="ms"||c==="s"?d+V.val+c:d+V.scaling+c:console.warn("can't find",r,i)},j=(t,n)=>{if(!["+","-","*","/",","].filter(c=>t.includes(c+" ")).length)return t;const s=/(\s*[+\-*/,]\s*)/;return t.split(s).map(c=>{const o=c.trim();return!o||["+","-","*","/",","].includes(o)?c:U(o,n)}).join("")},Y=(t,n,e,s)=>{if(typeof t!="string")return(0,I.getActiveConfig)().verbose&&console.warn(n,t,"is not a string"),{[n]:t};if(t==="-"||t==="")return{};if(!s&&t.includes("(")){const c=_(t);s=c[0],t=c[1]}return["+","-","*","/",","].filter(c=>t.includes(c+" ")).length?t=j(t,e):t=U(t,e),{[n]:s?`${s}(${t})`:t}},D=(t,n)=>b[t-n],k=t=>{const{h1Matches:n,sequence:e}=t;return new Array(6).fill(null).map((s,r)=>{const c=D(n,r);return e[c]})};
1
+ "use strict";var A=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var H=(t,n)=>{for(var e in n)A(t,e,{get:n[e],enumerable:!0})},Z=(t,n,e,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of E(n))!G.call(t,r)&&r!==e&&A(t,r,{get:()=>n[r],enumerable:!(s=z(n,r))||s.enumerable});return t};var B=t=>Z(A({},"__esModule",{value:!0}),t);var q={};H(q,{findHeadingLetter:()=>W,findHeadings:()=>P,generateSequence:()=>X,generateSequencePosition:()=>Y,generateSubSequence:()=>U,getFnPrefixAndValue:()=>F,getSequenceValue:()=>K,getSequenceValueBySymbols:()=>D,getSequenceValuePropertyPair:()=>k,getSubratio:()=>J,getSubratioDifference:()=>O,numToLetterMap:()=>b,setScalingVar:()=>C,setSubScalingVar:()=>j});module.exports=B(q);var M=require("@symbo.ls/utils"),T=require("@symbo.ls/utils"),L=require("../factory.js"),y=require("./unit.js"),_=require("./color.js");const b={"-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"},I=(t,n)=>{const{key:e,variable:s,value:r,scaling:i,index:o,scalingVariable:p}=t;n.sequence[e]={key:e,decimal:~~(r*100)/100,val:~~r,scaling:i,index:o,scalingVariable:p,variable:s},n.scales[e]=i;const l=N.has(n.unit)?"rem":n.unit;n.vars[s]=i+l},F=t=>{if(!t.includes("("))return t;const n=t.split("(")[0],e=t.slice(t.indexOf("(")+1,t.lastIndexOf(")"));return[n,e]},N=new Set(["vw","vh","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh"]),C=(t,n)=>{const{base:e,type:s,unit:r}=n,i=N.has(r)?"rem":r,o=((0,y.isScalingUnit)(i)?1:e)+i;if(t===0)return o;const l="--"+(n.varPrefix?n.varPrefix+"-":"")+(s&&s.replace(".","-")),u=`${l}-ratio`;if(t>0){const f=b[t-1];return`calc(var(${l}-${f}) * var(${u}))`}if(t<0){const f=b[t+1],$=Math.abs(t),h=Math.pow(R,2*$),x=b[$];return x?`max(calc(var(${l}-${f}) / var(${u})), calc(var(${l}-${x}) / ${h.toFixed(4)}))`:`calc(var(${l}-${f}) / var(${u}))`}},j=(t,n,e,s)=>{const{type:r}=s,o=t===2&&n.length===2?t+1:t,u=`${"--"+(s.varPrefix?s.varPrefix+"-":"")+(r&&r.replace(".","-"))}-sub-ratio-`;return`calc(var(${e}) * var(${u+o}))`},O=(t,n)=>{const s=(t*n-t)/1.618,r=t*n-s,i=t+s,o=(r+i)/2;return[r,o,i]},J=(t,n)=>O(t,n).map(e=>e/t),U=(t,n)=>{const{key:e,base:s,value:r,ratio:i,variable:o,index:p}=t,u=~~(r*i)-~~r;let f;const[$,h,x]=O(r,i);u>16?f=[$,h,x]:f=[$,x],f.forEach((d,c)=>{const g=~~(d/s*1e3)/1e3,m=o+(c+1),S=p+(c+1)/10,V=j(c+1,f,o,n),a={key:e+(c+1),variable:m,value:d,scaling:g,scalingVariable:V,index:S};I(a,n)})},R=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(R,2*s);return Math.max(r,i)},X=t=>{const{type:n,base:e,ratio:s,range:r,subSequence:i}=t,o=Math.abs(r[0])+Math.abs(r[1]),l="--"+(t.varPrefix?t.varPrefix+"-":"")+(n&&n.replace(".","-"))+"-";for(let u=0;u<=o;u++){const f=r[1]-u,$=b[f],h=Q(f,e,s),x=~~(h/e*100)/100,d=l+$,c=C(f,t),g={key:$,variable:d,value:h,base:e,scaling:x,scalingVariable:c,ratio:s,index:f};I(g,t),i&&U(g,t)}return t},Y=(t,n=0)=>{const{type:e,base:s,ratio:r,subSequence:i}=t,o=(0,M.isString)(n)?n:b[n],p=(0,M.isString)(n)?Object.entries(b).find(([,g])=>g===n)?.[0]:n;if(!o)return console.warn(`Position ${n} is out of range in numToLetterMap`),null;const l={sequence:{},scales:{},vars:{},...t},u=s*Math.pow(r,p),f=~~(u/s*100)/100,x="--"+(t.varPrefix?t.varPrefix+"-":"")+(e&&e.replace(".","-"))+"-"+o,d=C(p,t),c={key:o,variable:x,value:u,base:s,scaling:f,scalingVariable:d,ratio:r,index:p};return I(c,l),i&&U(c,l),l},K=(t="A",n)=>{const e=(0,L.getActiveConfig)(),{unit:s}=e;if((0,M.isString)(t)&&(0,_.isCSSVar)(t))return`var(${t})`;const{sequence:r,unit:i=s.default,useVariable:o}=n,p=/^-?[a-zA-Z]/i,l=p.test(t);if(y.CSS_UNITS.some(a=>t.includes(a))||!l||["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,T.toDashCase)(n.type.replace(".","-"))}-`,x=t.toUpperCase(),d=x.slice(0,1)==="-"?"-":"";let c=d?x.slice(1):x,g="";c.includes("_")&&(g="_"+c.split("_")[1].toLowerCase(),c=c.split("_")[0]);const m=a=>p.test(a)?`var(${h}${a}${g})`:a;if(c.includes("+")){const[a,w]=c.split("+"),v=`${m(a)} + ${m(w)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("*")){const[a,w]=c.split("*"),v=`${m(a)} * ${m(w)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("-")){const[a,w]=c.split("-"),v=`${m(a)} - ${m(w)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}const S=e.sizes;if(S){const a=S[t]||S[t.toLowerCase()];if(a!==void 0)return d?`calc(${a} * -1)`:a}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 a=`var(${h}${c}${g})`;return d?`calc(${a} * -1)`:a}const V=r?r[c]:null;return V?i==="ms"||i==="s"?d+V.val+i:d+V.scaling+i:console.warn("can't find",r,c)},D=(t,n)=>{if(!["+","-","*","/",","].filter(i=>t.includes(i+" ")).length)return t;const s=/(\s*[+\-*/,]\s*)/;return t.split(s).map(i=>{const o=i.trim();return!o||["+","-","*","/",","].includes(o)?i:K(o,n)}).join("")},k=(t,n,e,s)=>{if(typeof t!="string")return(0,L.getActiveConfig)().verbose&&console.warn(n,t,"is not a string"),{[n]:t};if(t==="-"||t==="")return{};if(!s&&t.includes("(")){const i=F(t);s=i[0],t=i[1]}return["+","-","*","/",","].filter(i=>t.includes(i+" ")).length?t=D(t,e):t=K(t,e),{[n]:s?`${s}(${t})`:t}},W=(t,n)=>b[t-n],P=t=>{const{h1Matches:n,sequence:e}=t;return new Array(6).fill(null).map((s,r)=>{const i=W(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 r={},o={};export{r as reset,o 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={};export{o as reset,t as sizes,r as vars};
@@ -1 +1 @@
1
- import{getActiveConfig as S,setActiveConfig as D,toCamel as P}from"./factory.js";import{setColor as N,setGradient as q,setFont as G,setFontFamily as F,setTheme as M,setSvgIcon as k,setSVG as j,applyTypographySequence as W,applySpacingSequence as Y,applyReset as $,applyTimingSequence as U,applyDocument as z,setShadow as B}from"./system/index.js";import{deepMerge as H,isObject as _,isArray as L}from"@symbo.ls/utils";const J=(t,o)=>{const e=S(),{cssVars:c}=e,r=o.startsWith("--")?o:`--${o}`;return c[r]=t,t},l=t=>t,O={color:N,gradient:q,font:G,fontFamily:F,fontfamily:F,theme:M,icons:k,semanticIcons:l,semanticicons:l,svg:j,svgData:l,typography:l,shadow:B,spacing:l,media:l,grid:l,class:l,timing:l,reset:l,unit:l,animation:l,vars:J},K=(t,o,e)=>{const c=S(),r=P(t),n=r.toLowerCase(),a=c[r]||c[n]||c[t],s=O[r]||O[n];if(s)try{const f=s(o,e);return a&&(a[e]=f),a}catch(f){c.verbose&&console.warn("Error setting",n,"value",o,e,f)}c.verbose&&console.warn("Can not find",n,"method in scratch")},Q=(t,o)=>{const e=S(),c=t.toLowerCase();return Object.keys(o).sort((n,a)=>{const s=_(o[n])||L(o[n])?1:0,f=_(o[a])||L(o[a])?1:0;return s-f}).forEach(n=>{try{return K(c,o[n],n)}catch(a){e.verbose&&console.warn("Error setting",c,"value",o[n],n,a)}}),e[c]||e[t]},ne=(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",f=r.styleSheets;for(let d=0;d<f.length;d++)try{const u=f[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},X={},re=(t,o=X)=>{let e=o.config||S();const{version:c,verbose:r,useVariable:n,useReset:a,useSvgSprite:s,useFontImport:f,useIconSprite:d,globalTheme:u,themeRoot:h,useDocumentTheme:y,useDefaultConfig:T,semanticIcons:V,files:x,assets:E,...p}=t;o.newConfig&&(e=D(o.newConfig)),x!==void 0&&(e.files=x),E!==void 0&&(e.assets=E),r!==void 0&&(e.verbose=r),n!==void 0&&(e.useVariable=n),a!==void 0&&(e.useReset=a),f!==void 0&&(e.useFontImport=f),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),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=A=>{g.setAttribute("data-theme",A.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),I=new Set(C);if(C.forEach(i=>{const m=i.toLowerCase();m!==i&&I.has(m)&&H(p[m],p[i])}),C.map(i=>{const m=i.toLowerCase();if(!(m!==i&&I.has(m)))return Q(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{W()}catch(i){e.verbose&&console.warn("Error applying typography sequence",i)}if(p.spacing)try{Y()}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)}z();const R=$();return R&&(e.reset=R),e};export{O as VALUE_TRANSFORMERS,ne as changeGlobalTheme,re as set,Q as setEach,K as setValue};
1
+ import{getActiveConfig as S,setActiveConfig as D,toCamel as P}from"./factory.js";import{setColor as N,setGradient as q,setFont as G,setFontFamily as F,setTheme as M,setSvgIcon as k,setSVG as j,applyTypographySequence as W,applySpacingSequence as Y,applyReset as $,applyTimingSequence as z,applyDocument as U,setShadow as B}from"./system/index.js";import{deepMerge as H,isObject as _,isArray as L}from"@symbo.ls/utils";const J=(t,o)=>{const e=S(),{cssVars:c}=e,r=o.startsWith("--")?o:`--${o}`;return c[r]=t,t},f=t=>t,O={color:N,gradient:q,font:G,fontFamily:F,fontfamily:F,theme:M,icons:k,semanticIcons:f,semanticicons:f,svg:j,svgData:f,typography:f,shadow:B,spacing:f,media:f,grid:f,class:f,timing:f,reset:f,unit:f,animation:f,vars:J,sizes:f},K=(t,o,e)=>{const c=S(),r=P(t),n=r.toLowerCase(),a=c[r]||c[n]||c[t],s=O[r]||O[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")},Q=(t,o)=>{const e=S(),c=t.toLowerCase();return Object.keys(o).sort((n,a)=>{const s=_(o[n])||L(o[n])?1:0,l=_(o[a])||L(o[a])?1:0;return s-l}).forEach(n=>{try{return K(c,o[n],n)}catch(a){e.verbose&&console.warn("Error setting",c,"value",o[n],n,a)}}),e[c]||e[t]},ne=(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},X={},re=(t,o=X)=>{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,files:x,assets:E,...p}=t;o.newConfig&&(e=D(o.newConfig)),x!==void 0&&(e.files=x),E!==void 0&&(e.assets=E),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),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=A=>{g.setAttribute("data-theme",A.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),I=new Set(C);if(C.forEach(i=>{const m=i.toLowerCase();m!==i&&I.has(m)&&H(p[m],p[i])}),C.map(i=>{const m=i.toLowerCase();if(!(m!==i&&I.has(m)))return Q(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{W()}catch(i){e.verbose&&console.warn("Error applying typography sequence",i)}if(p.spacing)try{Y()}catch(i){e.verbose&&console.warn("Error applying spacing sequence",i)}if(p.timing)try{z()}catch(i){e.verbose&&console.warn("Error applying timing sequence",i)}U();const R=$();return R&&(e.reset=R),e};export{O as VALUE_TRANSFORMERS,ne as changeGlobalTheme,re as set,Q as setEach,K as setValue};
@@ -1 +1 @@
1
- import{isString as w}from"@symbo.ls/utils";import{toDashCase as K}from"@symbo.ls/utils";import{getActiveConfig as y}from"../factory.js";import{CSS_UNITS as N,isScalingUnit as R}from"./unit.js";import{isCSSVar as T}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"},M=(t,n)=>{const{key:r,variable:s,value:c,scaling:e,index:o,scalingVariable:p}=t;n.sequence[r]={key:r,decimal:~~(c*100)/100,val:~~c,scaling:e,index:o,scalingVariable:p,variable:s},n.scales[r]=e;const a=A.has(n.unit)?"rem":n.unit;n.vars[s]=e+a},_=t=>{if(!t.includes("("))return t;const n=t.split("(")[0],r=t.slice(t.indexOf("(")+1,t.lastIndexOf(")"));return[n,r]},A=new Set(["vw","vh","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh"]),I=(t,n)=>{const{base:r,type:s,unit:c}=n,e=A.has(c)?"rem":c,o=(R(e)?1:r)+e;if(t===0)return o;const a="--"+(n.varPrefix?n.varPrefix+"-":"")+(s&&s.replace(".","-")),u=`${a}-ratio`;if(t>0){const l=S[t-1];return`calc(var(${a}-${l}) * var(${u}))`}if(t<0){const l=S[t+1],$=Math.abs(t),h=Math.pow(C,2*$),x=S[$];return x?`max(calc(var(${a}-${l}) / var(${u})), calc(var(${a}-${x}) / ${h.toFixed(4)}))`:`calc(var(${a}-${l}) / var(${u}))`}},F=(t,n,r,s)=>{const{type:c}=s,o=t===2&&n.length===2?t+1:t,u=`${"--"+(s.varPrefix?s.varPrefix+"-":"")+(c&&c.replace(".","-"))}-sub-ratio-`;return`calc(var(${r}) * var(${u+o}))`},L=(t,n)=>{const s=(t*n-t)/1.618,c=t*n-s,e=t+s,o=(c+e)/2;return[c,o,e]},Z=(t,n)=>L(t,n).map(r=>r/t),O=(t,n)=>{const{key:r,base:s,value:c,ratio:e,variable:o,index:p}=t,u=~~(c*e)-~~c;let l;const[$,h,x]=L(c,e);u>16?l=[$,h,x]:l=[$,x],l.forEach((d,i)=>{const g=~~(d/s*1e3)/1e3,m=o+(i+1),V=p+(i+1)/10,f=F(i+1,l,o,n),b={key:r+(i+1),variable:m,value:d,scaling:g,scalingVariable:f,index:V};M(b,n)})},C=1.618,j=(t,n,r)=>{if(t>=0)return n*Math.pow(r,t);const s=Math.abs(t),c=n*Math.pow(r,t),e=n*Math.pow(r,s)/Math.pow(C,2*s);return Math.max(c,e)},J=t=>{const{type:n,base:r,ratio:s,range:c,subSequence:e}=t,o=Math.abs(c[0])+Math.abs(c[1]),a="--"+(t.varPrefix?t.varPrefix+"-":"")+(n&&n.replace(".","-"))+"-";for(let u=0;u<=o;u++){const l=c[1]-u,$=S[l],h=j(l,r,s),x=~~(h/r*100)/100,d=a+$,i=I(l,t),g={key:$,variable:d,value:h,base:r,scaling:x,scalingVariable:i,ratio:s,index:l};M(g,t),e&&O(g,t)}return t},Q=(t,n=0)=>{const{type:r,base:s,ratio:c,subSequence:e}=t,o=w(n)?n:S[n],p=w(n)?Object.entries(S).find(([,g])=>g===n)?.[0]:n;if(!o)return console.warn(`Position ${n} is out of range in numToLetterMap`),null;const a={sequence:{},scales:{},vars:{},...t},u=s*Math.pow(c,p),l=~~(u/s*100)/100,x="--"+(t.varPrefix?t.varPrefix+"-":"")+(r&&r.replace(".","-"))+"-"+o,d=I(p,t),i={key:o,variable:x,value:u,base:s,scaling:l,scalingVariable:d,ratio:c,index:p};return M(i,a),e&&O(i,a),a},U=(t="A",n)=>{const r=y(),{unit:s}=r;if(w(t)&&T(t))return`var(${t})`;const{sequence:c,unit:e=s.default,useVariable:o}=n,p=/^-?[a-zA-Z]/i,a=p.test(t);if(N.some(f=>t.includes(f))||!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+"-":""}${K(n.type.replace(".","-"))}-`,x=t.toUpperCase(),d=x.slice(0,1)==="-"?"-":"";let i=d?x.slice(1):x,g="";i.includes("_")&&(g="_"+i.split("_")[1].toLowerCase(),i=i.split("_")[0]);const m=f=>p.test(f)?`var(${h}${f}${g})`:f;if(i.includes("+")){const[f,b]=i.split("+"),v=`${m(f)} + ${m(b)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}else if(i.includes("*")){const[f,b]=i.split("*"),v=`${m(f)} * ${m(b)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}else if(i.includes("-")){const[f,b]=i.split("-"),v=`${m(f)} - ${m(b)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}if(!c[i]&&i.length===2&&(r.verbose&&console.warn(i,"- value is not found because `subSequence` is set to false"),i=i.slice(0,1)),o||r.useVariable){const f=`var(${h}${i}${g})`;return d?`calc(${f} * -1)`:f}const V=c?c[i]:null;return V?e==="ms"||e==="s"?d+V.val+e:d+V.scaling+e:console.warn("can't find",c,i)},D=(t,n)=>{if(!["+","-","*","/",","].filter(e=>t.includes(e+" ")).length)return t;const s=/(\s*[+\-*/,]\s*)/;return t.split(s).map(e=>{const o=e.trim();return!o||["+","-","*","/",","].includes(o)?e:U(o,n)}).join("")},X=(t,n,r,s)=>{if(typeof t!="string")return y().verbose&&console.warn(n,t,"is not a string"),{[n]:t};if(t==="-"||t==="")return{};if(!s&&t.includes("(")){const e=_(t);s=e[0],t=e[1]}return["+","-","*","/",","].filter(e=>t.includes(e+" ")).length?t=D(t,r):t=U(t,r),{[n]:s?`${s}(${t})`:t}},W=(t,n)=>S[t-n],Y=t=>{const{h1Matches:n,sequence:r}=t;return new Array(6).fill(null).map((s,c)=>{const e=W(n,c);return r[e]})};export{W as findHeadingLetter,Y as findHeadings,J as generateSequence,Q as generateSequencePosition,O as generateSubSequence,_ as getFnPrefixAndValue,U as getSequenceValue,D as getSequenceValueBySymbols,X as getSequenceValuePropertyPair,Z as getSubratio,L as getSubratioDifference,S as numToLetterMap,I as setScalingVar,F as setSubScalingVar};
1
+ import{isString as M}from"@symbo.ls/utils";import{toDashCase as N}from"@symbo.ls/utils";import{getActiveConfig as A}from"../factory.js";import{CSS_UNITS as R,isScalingUnit as T}from"./unit.js";import{isCSSVar as _}from"./color.js";const b={"-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:r,variable:s,value:i,scaling:e,index:o,scalingVariable:p}=t;n.sequence[r]={key:r,decimal:~~(i*100)/100,val:~~i,scaling:e,index:o,scalingVariable:p,variable:s},n.scales[r]=e;const l=I.has(n.unit)?"rem":n.unit;n.vars[s]=e+l},F=t=>{if(!t.includes("("))return t;const n=t.split("(")[0],r=t.slice(t.indexOf("(")+1,t.lastIndexOf(")"));return[n,r]},I=new Set(["vw","vh","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh"]),L=(t,n)=>{const{base:r,type:s,unit:i}=n,e=I.has(i)?"rem":i,o=(T(e)?1:r)+e;if(t===0)return o;const l="--"+(n.varPrefix?n.varPrefix+"-":"")+(s&&s.replace(".","-")),u=`${l}-ratio`;if(t>0){const f=b[t-1];return`calc(var(${l}-${f}) * var(${u}))`}if(t<0){const f=b[t+1],$=Math.abs(t),h=Math.pow(U,2*$),x=b[$];return x?`max(calc(var(${l}-${f}) / var(${u})), calc(var(${l}-${x}) / ${h.toFixed(4)}))`:`calc(var(${l}-${f}) / var(${u}))`}},j=(t,n,r,s)=>{const{type:i}=s,o=t===2&&n.length===2?t+1:t,u=`${"--"+(s.varPrefix?s.varPrefix+"-":"")+(i&&i.replace(".","-"))}-sub-ratio-`;return`calc(var(${r}) * var(${u+o}))`},C=(t,n)=>{const s=(t*n-t)/1.618,i=t*n-s,e=t+s,o=(i+e)/2;return[i,o,e]},J=(t,n)=>C(t,n).map(r=>r/t),O=(t,n)=>{const{key:r,base:s,value:i,ratio:e,variable:o,index:p}=t,u=~~(i*e)-~~i;let f;const[$,h,x]=C(i,e);u>16?f=[$,h,x]:f=[$,x],f.forEach((d,c)=>{const g=~~(d/s*1e3)/1e3,m=o+(c+1),S=p+(c+1)/10,V=j(c+1,f,o,n),a={key:r+(c+1),variable:m,value:d,scaling:g,scalingVariable:V,index:S};y(a,n)})},U=1.618,D=(t,n,r)=>{if(t>=0)return n*Math.pow(r,t);const s=Math.abs(t),i=n*Math.pow(r,t),e=n*Math.pow(r,s)/Math.pow(U,2*s);return Math.max(i,e)},Q=t=>{const{type:n,base:r,ratio:s,range:i,subSequence:e}=t,o=Math.abs(i[0])+Math.abs(i[1]),l="--"+(t.varPrefix?t.varPrefix+"-":"")+(n&&n.replace(".","-"))+"-";for(let u=0;u<=o;u++){const f=i[1]-u,$=b[f],h=D(f,r,s),x=~~(h/r*100)/100,d=l+$,c=L(f,t),g={key:$,variable:d,value:h,base:r,scaling:x,scalingVariable:c,ratio:s,index:f};y(g,t),e&&O(g,t)}return t},X=(t,n=0)=>{const{type:r,base:s,ratio:i,subSequence:e}=t,o=M(n)?n:b[n],p=M(n)?Object.entries(b).find(([,g])=>g===n)?.[0]:n;if(!o)return console.warn(`Position ${n} is out of range in numToLetterMap`),null;const l={sequence:{},scales:{},vars:{},...t},u=s*Math.pow(i,p),f=~~(u/s*100)/100,x="--"+(t.varPrefix?t.varPrefix+"-":"")+(r&&r.replace(".","-"))+"-"+o,d=L(p,t),c={key:o,variable:x,value:u,base:s,scaling:f,scalingVariable:d,ratio:i,index:p};return y(c,l),e&&O(c,l),l},K=(t="A",n)=>{const r=A(),{unit:s}=r;if(M(t)&&_(t))return`var(${t})`;const{sequence:i,unit:e=s.default,useVariable:o}=n,p=/^-?[a-zA-Z]/i,l=p.test(t);if(R.some(a=>t.includes(a))||!l||["none","auto","max-content","min-content","fit-content","inherit","initial","unset","revert","revert-layer"].includes(t))return t;const h=`--${n.varPrefix?n.varPrefix+"-":""}${N(n.type.replace(".","-"))}-`,x=t.toUpperCase(),d=x.slice(0,1)==="-"?"-":"";let c=d?x.slice(1):x,g="";c.includes("_")&&(g="_"+c.split("_")[1].toLowerCase(),c=c.split("_")[0]);const m=a=>p.test(a)?`var(${h}${a}${g})`:a;if(c.includes("+")){const[a,w]=c.split("+"),v=`${m(a)} + ${m(w)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("*")){const[a,w]=c.split("*"),v=`${m(a)} * ${m(w)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}else if(c.includes("-")){const[a,w]=c.split("-"),v=`${m(a)} - ${m(w)}`;return d?`calc((${v}) * -1)`:`calc(${v})`}const S=r.sizes;if(S){const a=S[t]||S[t.toLowerCase()];if(a!==void 0)return d?`calc(${a} * -1)`:a}if(!i[c]&&c.length===2&&(r.verbose&&console.warn(c,"- value is not found because `subSequence` is set to false"),c=c.slice(0,1)),o||r.useVariable){const a=`var(${h}${c}${g})`;return d?`calc(${a} * -1)`:a}const V=i?i[c]:null;return V?e==="ms"||e==="s"?d+V.val+e:d+V.scaling+e:console.warn("can't find",i,c)},W=(t,n)=>{if(!["+","-","*","/",","].filter(e=>t.includes(e+" ")).length)return t;const s=/(\s*[+\-*/,]\s*)/;return t.split(s).map(e=>{const o=e.trim();return!o||["+","-","*","/",","].includes(o)?e:K(o,n)}).join("")},Y=(t,n,r,s)=>{if(typeof t!="string")return A().verbose&&console.warn(n,t,"is not a string"),{[n]:t};if(t==="-"||t==="")return{};if(!s&&t.includes("(")){const e=F(t);s=e[0],t=e[1]}return["+","-","*","/",","].filter(e=>t.includes(e+" ")).length?t=W(t,r):t=K(t,r),{[n]:s?`${s}(${t})`:t}},z=(t,n)=>b[t-n],k=t=>{const{h1Matches:n,sequence:r}=t;return new Array(6).fill(null).map((s,i)=>{const e=z(n,i);return r[e]})};export{z as findHeadingLetter,k as findHeadings,Q as generateSequence,X as generateSequencePosition,O as generateSubSequence,F as getFnPrefixAndValue,K as getSequenceValue,W as getSequenceValueBySymbols,Y as getSequenceValuePropertyPair,J as getSubratio,C as getSubratioDifference,b as numToLetterMap,L as setScalingVar,j as setSubScalingVar};
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.104",
5
+ "version": "3.14.135",
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.104",
36
+ "@symbo.ls/utils": "^3.14.105",
37
37
  "color-contrast-checker": "^1.5.0"
38
38
  },
39
39
  "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",