@symbo.ls/scratch 3.14.700 → 3.14.702
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 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var M=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var H=(t,n)=>{for(var e in n)M(t,e,{get:n[e],enumerable:!0})},Z=(t,n,e,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of W(n))!G.call(t,r)&&r!==e&&M(t,r,{get:()=>n[r],enumerable:!(s=E(n,r))||s.enumerable});return t};var k=t=>Z(M({},"__esModule",{value:!0}),t);var P={};H(P,{findHeadingLetter:()=>_,findHeadings:()=>q,generateSequence:()=>Q,generateSequencePosition:()=>X,generateSubSequence:()=>O,getFnPrefixAndValue:()=>D,getSequenceValue:()=>U,getSequenceValueBySymbols:()=>N,getSequenceValuePropertyPair:()=>Y,getSubratio:()=>B,getSubratioDifference:()=>C,numToLetterMap:()=>S,setScalingVar:()=>I,setSubScalingVar:()=>F});module.exports=k(P);var w=require("@symbo.ls/utils"),T=require("@symbo.ls/utils"),j=require("@symbo.ls/utils"),L=require("../factory.js"),y=require("./unit.js"),z=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: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=R.has(n.unit)?"rem":n.unit;n.vars[s]=i+l},D=t=>{if(!t.includes("("))return t;const n=t.split("(")[0],e=t.slice(t.indexOf("(")+1,t.lastIndexOf(")"));return[n,e]},R=new Set(["vw","vh","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh"]),I=(t,n)=>{const{base:e,type:s,unit:r}=n,i=R.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(".","-")),d=`${l}-ratio`;if(t>0){const f=S[t-1];return`calc(var(${l}-${f}) * var(${d}))`}if(t<0){const f=S[t+1],g=Math.abs(t),h=Math.pow(K,2*g),m=S[g];return m?`max(calc(var(${l}-${f}) / var(${d})), calc(var(${l}-${m}) / ${h.toFixed(4)}))`:`calc(var(${l}-${f}) / var(${d}))`}},F=(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}))`},C=(t,n)=>{const s=(t*n-t)/1.618,r=t*n-s,i=t+s,o=(r+i)/2;return[r,o,i]},B=(t,n)=>C(t,n).map(e=>e/t),O=(t,n)=>{const{key:e,base:s,value:r,ratio:i,variable:o,index:p}=t,d=~~(r*i)-~~r;let f;const[g,h,m]=C(r,i);d>16?f=[g,h,m]:f=[g,m],f.forEach((u,c)=>{const $=~~(u/s*1e3)/1e3,v=o+(c+1),V=p+(c+1)/10,a=F(c+1,f,o,n),x={key:e+(c+1),variable:v,value:u,scaling:$,scalingVariable:a,index:V};A(x,n)})},K=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),i=n*Math.pow(e,s)/Math.pow(K,2*s);return Math.max(r,i)},Q=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 d=0;d<=o;d++){const f=r[1]-d,g=S[f],h=J(f,e,s),m=~~(h/e*100)/100,u=l+g,c=I(f,t),$={key:g,variable:u,value:h,base:e,scaling:m,scalingVariable:c,ratio:s,index:f};A($,t),i&&O($,t)}return t},X=(t,n=0)=>{const{type:e,base:s,ratio:r,subSequence:i}=t,o=(0,w.isString)(n)?n:S[n],p=(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 l={sequence:{},scales:{},vars:{},...t},d=s*Math.pow(r,p),f=~~(d/s*100)/100,m="--"+(t.varPrefix?t.varPrefix+"-":"")+(e&&e.replace(".","-"))+"-"+o,u=I(p,t),c={key:o,variable:m,value:d,base:s,scaling:f,scalingVariable:u,ratio:r,index:p};return A(c,l),i&&O(c,l),l},U=(t="A",n)=>{const e=(0,L.getActiveConfig)(),{unit:s}=e;if((0,w.isString)(t)&&(0,z.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 a=e.sizes;if(a){const x=a[t]||a[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,p=/^-?[a-zA-Z]/i,l=p.test(t);if((0,y.isRawUnitValue)(t)||!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(".","-"))}-`,m=t.toUpperCase(),u=m.slice(0,1)==="-"?"-":"";let c=u?m.slice(1):m,$="";c.includes("_")&&($="_"+c.split("_")[1].toLowerCase(),c=c.split("_")[0]);const v=a=>p.test(a)?`var(${h}${a}${$})`:a;if(c.includes("+")){const[a,x]=c.split("+"),b=`${v(a)} + ${v(x)}`;return u?`calc((${b}) * -1)`:`calc(${b})`}else if(c.includes("*")){const[a,x]=c.split("*"),b=`${v(a)} * ${v(x)}`;return u?`calc((${b}) * -1)`:`calc(${b})`}else if(c.includes("-")){const[a,x]=c.split("-"),b=`${v(a)} - ${v(x)}`;return u?`calc((${b}) * -1)`:`calc(${b})`}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}${$})`;return u?`calc(${a} * -1)`:a}const V=r?r[c]:null;if(!V){if(console.warn("can't find",r,c),(0,j.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"?u+V.val+i:u+V.scaling+i},N=(t,n)=>{if(!["+","-","*","/",","].filter(i=>t.includes(i+" ")).length)return t;const s=/(\s+-\s+|\s*[+*/,]\s*)/;return t.split(s).map(i=>{const o=i.trim();return!o||["+","-","*","/",","].includes(o)?i:U(o,n)}).join("")},Y=(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("(")){if(/^(?:env|var)\(/.test(t.trim()))return{[n]:t};const i=D(t);s=i[0],t=i[1]}return["+","-","*","/",","].filter(i=>t.includes(i+" ")).length?t=N(t,e):t=U(t,e),{[n]:s?`${s}(${t})`:t}},_=(t,n)=>S[t-n],q=t=>{const{h1Matches:n,sequence:e}=t;return new Array(6).fill(null).map((s,r)=>{const i=_(n,r);return e[i]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isString as
|
|
1
|
+
import{isString as V}from"@symbo.ls/utils";import{toDashCase as R}from"@symbo.ls/utils";import{isLoudDevRuntime as K}from"@symbo.ls/utils";import{getActiveConfig as M}from"../factory.js";import{isRawUnitValue as T,isScalingUnit as j}from"./unit.js";import{isCSSVar as z}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: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=A.has(n.unit)?"rem":n.unit;n.vars[s]=e+l},D=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"]),L=(t,n)=>{const{base:r,type:s,unit:i}=n,e=A.has(i)?"rem":i,o=(j(e)?1:r)+e;if(t===0)return o;const l="--"+(n.varPrefix?n.varPrefix+"-":"")+(s&&s.replace(".","-")),d=`${l}-ratio`;if(t>0){const f=S[t-1];return`calc(var(${l}-${f}) * var(${d}))`}if(t<0){const f=S[t+1],g=Math.abs(t),h=Math.pow(O,2*g),m=S[g];return m?`max(calc(var(${l}-${f}) / var(${d})), calc(var(${l}-${m}) / ${h.toFixed(4)}))`:`calc(var(${l}-${f}) / var(${d}))`}},F=(t,n,r,s)=>{const{type:i}=s,o=t===2&&n.length===2?t+1:t,d=`${"--"+(s.varPrefix?s.varPrefix+"-":"")+(i&&i.replace(".","-"))}-sub-ratio-`;return`calc(var(${r}) * var(${d+o}))`},I=(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)=>I(t,n).map(r=>r/t),C=(t,n)=>{const{key:r,base:s,value:i,ratio:e,variable:o,index:p}=t,d=~~(i*e)-~~i;let f;const[g,h,m]=I(i,e);d>16?f=[g,h,m]:f=[g,m],f.forEach((u,c)=>{const $=~~(u/s*1e3)/1e3,v=o+(c+1),w=p+(c+1)/10,a=F(c+1,f,o,n),x={key:r+(c+1),variable:v,value:u,scaling:$,scalingVariable:a,index:w};y(x,n)})},O=1.618,N=(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(O,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 d=0;d<=o;d++){const f=i[1]-d,g=S[f],h=N(f,r,s),m=~~(h/r*100)/100,u=l+g,c=L(f,t),$={key:g,variable:u,value:h,base:r,scaling:m,scalingVariable:c,ratio:s,index:f};y($,t),e&&C($,t)}return t},X=(t,n=0)=>{const{type:r,base:s,ratio:i,subSequence:e}=t,o=V(n)?n:S[n],p=V(n)?Object.entries(S).find(([,$])=>$===n)?.[0]:n;if(!o)return console.warn(`Position ${n} is out of range in numToLetterMap`),null;const l={sequence:{},scales:{},vars:{},...t},d=s*Math.pow(i,p),f=~~(d/s*100)/100,m="--"+(t.varPrefix?t.varPrefix+"-":"")+(r&&r.replace(".","-"))+"-"+o,u=L(p,t),c={key:o,variable:m,value:d,base:s,scaling:f,scalingVariable:u,ratio:i,index:p};return y(c,l),e&&C(c,l),l},U=(t="A",n)=>{const r=M(),{unit:s}=r;if(V(t)&&z(t))return`var(${t})`;if(V(t)&&/^(?:env|var|calc|min|max|clamp)\(/.test(t.trim()))return t;if(V(t)){const a=r.sizes;if(a){const x=a[t]||a[t.toLowerCase()];if(x!==void 0)return t.slice(0,1)==="-"?`calc(${x} * -1)`:x}}const{sequence:i,unit:e=s.default,useVariable:o}=n,p=/^-?[a-zA-Z]/i,l=p.test(t);if(T(t)||!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+"-":""}${R(n.type.replace(".","-"))}-`,m=t.toUpperCase(),u=m.slice(0,1)==="-"?"-":"";let c=u?m.slice(1):m,$="";c.includes("_")&&($="_"+c.split("_")[1].toLowerCase(),c=c.split("_")[0]);const v=a=>p.test(a)?`var(${h}${a}${$})`:a;if(c.includes("+")){const[a,x]=c.split("+"),b=`${v(a)} + ${v(x)}`;return u?`calc((${b}) * -1)`:`calc(${b})`}else if(c.includes("*")){const[a,x]=c.split("*"),b=`${v(a)} * ${v(x)}`;return u?`calc((${b}) * -1)`:`calc(${b})`}else if(c.includes("-")){const[a,x]=c.split("-"),b=`${v(a)} - ${v(x)}`;return u?`calc((${b}) * -1)`:`calc(${b})`}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}${$})`;return u?`calc(${a} * -1)`:a}const w=i?i[c]:null;if(!w){if(console.warn("can't find",i,c),K())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 e==="ms"||e==="s"?u+w.val+e:u+w.scaling+e},_=(t,n)=>{if(!["+","-","*","/",","].filter(e=>t.includes(e+" ")).length)return t;const s=/(\s+-\s+|\s*[+*/,]\s*)/;return t.split(s).map(e=>{const o=e.trim();return!o||["+","-","*","/",","].includes(o)?e:U(o,n)}).join("")},Y=(t,n,r,s)=>{if(typeof t!="string")return M().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 e=D(t);s=e[0],t=e[1]}return["+","-","*","/",","].filter(e=>t.includes(e+" ")).length?t=_(t,r):t=U(t,r),{[n]:s?`${s}(${t})`:t}},E=(t,n)=>S[t-n],q=t=>{const{h1Matches:n,sequence:r}=t;return new Array(6).fill(null).map((s,i)=>{const e=E(n,i);return r[e]})};export{E as findHeadingLetter,q as findHeadings,Q as generateSequence,X as generateSequencePosition,C as generateSubSequence,D as getFnPrefixAndValue,U as getSequenceValue,_ as getSequenceValueBySymbols,Y as getSequenceValuePropertyPair,J as getSubratio,I as getSubratioDifference,S as numToLetterMap,L as setScalingVar,F 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.
|
|
5
|
+
"version": "3.14.702",
|
|
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.702",
|
|
37
37
|
"color-contrast-checker": "^1.5.0"
|
|
38
38
|
},
|
|
39
39
|
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|