@streamlinedfi/div 0.1.1 → 0.2.0

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/index.cjs ADDED
@@ -0,0 +1,64 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _styledcomponents = require('styled-components'); var _styledcomponents2 = _interopRequireDefault(_styledcomponents);var{entries:Y}=Object,h=e=>e.charAt(0).toUpperCase()+e.slice(1),j=(e="")=>_nullishCoalesce(_optionalChain([e, 'access', _2 => _2.match, 'call', _3 => _3(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g), 'optionalAccess', _4 => _4.map, 'call', _5 => _5(t=>t.toLowerCase()), 'optionalAccess', _6 => _6.join, 'call', _7 => _7("-")]), () => (""));function s(e,t){return/(px|%)$/.test(e)||typeof e=="string"||e===0?e:t.spacing(e)}function n(e){return typeof e=="number"?`${e}px`:e}function a(e,t,...i){let o;for(let l=0;l<i.length;l++){let g=i[l];if(t){let d=e[`$${t}$${g}`];if(d){o=d;break}}let u=e[`$${g}`];if(u){o=u;break}}return o}function f(e,t,...i){return!!a(e,t,...i)}var v=null;function P(e){if(v)return v;let t={};return Y(e).forEach(([i,o])=>{i.split("|").forEach(l=>{t[l]=o})}),v=t,t}var $=null;function S(e){return $||($=new RegExp(`^\\$(${e.Breakpoints.keys.join("|")})(\\$.*)`),$)}function W(e,t){if(e){if([100,200,300,400,500,600,700,800,900].includes(e))return`color: ${t[`fill${e}`]};`;if(typeof e=="string")return t[e]?`color: ${t[e]};`:`color: ${e};`}return""}var z=e=>typeof e=="number"?`${e}px`:e;var{fromEntries:D}=Object,F=D(["display","align","vAlign","alignItems","alignContent","alignSelf","justifyContent","justifySelf","flexDirection","flexBasis","flexWrap","pointerEvents","cursor","position","opacity","backgroundColor","backgroundImage","backgroundSize","backgroundPosition","backgroundRepeat","transform","transformOrigin","textDecoration","textWrap","animation","fontWeight","gap","gridTemplateColumns","gridTemplateRows","wordBreak","whiteSpace","textOverflow","overflow","overflowX","overflowY","textAlign","transitionDelay","filter","listStyle","objectFit","objectPosition","willChange","boxSizing"].map(e=>[e,1])),I={inline:"display: inline",block:"display: block",flex:`
2
+ display: flex;
3
+ width: 100%;
4
+ `,autoFlex:`
5
+ display: flex;
6
+ width: auto;
7
+ `,grid:`
8
+ display: grid;
9
+ `,hide:"display: none",inlineBlock:"display: inline-block",inlineFlex:"display: inline-flex","column|col":"flex-direction: column;",row:"flex-direction: row;",spaceBetween:"justify-content: space-between;",wrap:"flex-wrap: wrap;",innerCenter:(e,t)=>f(e,t,"flex","inlineFlex")?`
10
+ justify-content: center;
11
+ align-items: center;
12
+ `:`
13
+ text-align: center;
14
+ ${f(e,t,"h","height")?`line-height: ${a(e,t,"h","height")};`:""}
15
+ `,innerLeft:(e,t)=>f(e,t,"flex","inlineFlex")?f(e,t,"column","col")?"align-items: flex-start;":"justify-content: flex-start;":"text-align: left;",innerRight:(e,t)=>f(e,t,"flex","inlineFlex")?f(e,t,"column","col")?"align-items: flex-end;":"justify-content: flex-end;":"text-align: right;",innerTop:(e,t)=>f(e,t,"flex","inlineFlex")?f(e,t,"column","col")?"justify-content: flex-start;":"align-items: flex-start;":"",innerBottom:(e,t)=>f(e,t,"flex","inlineFlex")?f(e,t,"column","col")?"justify-content: flex-end;":"align-items: flex-end;":"",outerCenter:`
16
+ margin-left: auto;
17
+ margin-right: auto;
18
+ `,grow:{css:"flex-grow",format:Number},shrink:{css:"flex-shrink"},"colReverse|columnReverse":{css:"flex-direction: column-reverse;"},reverse:{css:"flex-direction: row-reverse;"},"width|w":{css:"width",format:n},"minWidth|minW":{css:"min-width",format:n},"maxWidth|maxW":{css:(e,t)=>`
19
+ width: 100%;
20
+ max-width: ${n(a(e,t,"maxWidth","maxW"))};
21
+ `},"height|h":{css:"height",format:n},"minHeight|minH":{css:"min-height",format:n},"maxHeight|maxH":{css:(e,t)=>`
22
+ height: 100%;
23
+ max-height: ${n(a(e,t,"maxHeight","maxH"))};
24
+ `},"lineHeight|lineH|lh":{css:"line-height",format:n},pointer:"cursor: pointer;",relative:"position: relative",absolute:"position: absolute",fixed:"position: fixed",static:"position: static",cover:`
25
+ position: absolute;
26
+ top: 0;
27
+ left: 0;
28
+ width: 100%;
29
+ height: 100%;
30
+ `,"zIndex|z":{css:"z-index",withTheme:!0},top:{css:"top",format:n},right:{css:"right",format:n},bottom:{css:"bottom",format:n},left:{css:"left",format:n},"padding|p":{css:"padding",format:s},"paddingTop|pt":{css:"padding-top",format:s},"paddingRight|pr":{css:"padding-right",format:s},"paddingBottom|pb":{css:"padding-bottom",format:s},"paddingLeft|pl":{css:"padding-left",format:s},"paddingX|px":{css:(e,t)=>`
31
+ padding-left: ${s(a(e,t,"paddingX","px"))};
32
+ padding-right: ${s(a(e,t,"paddingX","px"))};
33
+ `},"paddingY|py":{css:(e,t)=>`
34
+ padding-top: ${s(a(e,t,"paddingY","py"))};
35
+ padding-bottom: ${s(a(e,t,"paddingY","py"))};
36
+ `},"margin|m":{css:"margin",format:s},"marginTop|mt":{css:"margin-top",format:s},"marginRight|mr":{css:"margin-right",format:s},"marginBottom|mb":{css:"margin-bottom",format:s},"marginLeft|ml":{css:"margin-left",format:s},"marginX|mx":{css:(e,t)=>`
37
+ margin-left: ${s(a(e,t,"marginX","mx"))};
38
+ margin-right: ${s(a(e,t,"marginX","mx"))};
39
+ `},"marginY|my":{css:(e,t)=>`
40
+ margin-top: ${s(a(e,t,"marginY","my"))};
41
+ margin-bottom: ${s(a(e,t,"marginY","my"))};
42
+ `},"background|bg":{css:"background",withTheme:!0},"borderRadius|radius":{css:(e,t)=>{let i=a(e,t,"borderRadius","radius");return Array.isArray(i)?`
43
+ border-top-left-radius: ${n(i[0])};
44
+ border-top-right-radius: ${n(i[1])};
45
+ border-bottom-right-radius: ${n(i[2])};
46
+ border-bottom-left-radius: ${n(i[3])};
47
+ `:`border-radius: ${n(i)}`}},borderTopLeftRadius:{css:"border-top-left-radius",format:n},borderTopRightRadius:{css:"border-top-right-radius",format:n},borderBottomRightRadius:{css:"border-bottom-right-radius",format:n},borderBottomLeftRadius:{css:"border-bottom-left-radius",format:n},borderColor:{css:"border-color",withTheme:!0},borderImage:{css:"border-image",withTheme:!0},...[["border","border"],["borderTop","border-top"],["borderRight","border-right"],["borderBottom","border-bottom"],["borderLeft","border-left"]].reduce((e,[t,i])=>({...e,[t]:{css:(o,l,g)=>{let u=a(o,l,_optionalChain([g, 'optionalAccess', _8 => _8.length])?[t,...g].join("$"):t),d=typeof u=="function"?u(o.theme):u;return/^\d/.test(d)?`${i}: ${d}`:`${i}: 1px solid ${d}`}}}),{}),transition:(e,t)=>{let i=a(e,t,"transition");return typeof i=="string"?`transition: ${i}`:"transition: all .2s"},"boxShadow|shadow":{css:"box-shadow",withTheme:!0},textShadow:{css:"text-shadow",withTheme:!0},color:{css:"color",withTheme:!0},fill:{css:"fill",withTheme:!0},fontSize:{css:"font-size",format:n},outline:{css:"outline",withTheme:!0}};var{keys:V}=Object;function R(e,t){let i="",o=P(t),l=S(e.theme),g=-1,u=V(e);for(;++g<u.length;){let d=u[g];if(/^\$/.test(d)){let x=e[d];if(x!==!1){let E=d.match(l)||[],[,b,H]=E,T=(H||d).slice(1).split("$"),y=T[0],c=T.slice(1),C=o[y]||F[y]&&j(y);if(C){let m=C,B=m.withTheme&&typeof x=="function"?x(e.theme):x,X=m.format?m.format(B,e.theme):B,p="";typeof m=="string"?p=m:typeof m=="function"?p=m(e,b,c):typeof m.css=="function"?p=m.css(e,b,c):p=m.css;let r="",k=p.match(/:/g);k&&k.length>1?r=p:k===null?r=`${p}: ${X};`:r=`${p.replace(/;$/,"")};`,c.includes("important")&&(r=r.replace(/;/g," !important;")),c.includes("hover")&&!c.includes("focus")&&(r=`&:hover,&:focus { ${r} }`),c.includes("hover")&&c.includes("focus")&&(r=`&:hover { ${r} }`),c.includes("focus")&&(r=`&:focus { ${r} }`),c.includes("active")&&(r=`&:active { ${r} }`),c.includes("last")&&(r=`&:last-child { ${r} }`),c.includes("odd")&&(r=`&:nth-child(odd) { ${r} }`),c.includes("even")&&(r=`&:nth-child(even) { ${r} }`),b&&(r=`${e.theme.Breakpoints.getCssMedia(e.theme.Breakpoints[h(b)])} { ${r} }`),i+=r}}}}return i}var w=e=>R(e,I),G=_styledcomponents2.default.div`
48
+ ${e=>w(e)}
49
+ `,M= exports.Div =G;var U={weight:"font-weight",size:{css:"font-size",format:z},color:{css:(e,t,i)=>{let o=i.includes("hover")?e.$color$hover:e.$color;return W(o,e.theme)}},tnum:'font-feature-settings: "tnum";letter-spacing:-0.04em;',breakWord:"word-break: break-word;",noBreak:"white-space: nowrap;",uppercase:"text-transform: uppercase;",serif:'font-family: "Times New Roman", Times, serif',"spacing|letterSpacing":"letter-spacing",left:"text-align: left;",right:"text-align: right;",center:"text-align: center;",lineThrough:"text-decoration: line-through",linearGradient:e=>`
50
+ -webkit-text-fill-color: transparent;
51
+ text-fill-color: transparent;
52
+ -webkit-background-clip: text;
53
+ background-clip: text;
54
+ background-image: linear-gradient(${typeof e.$linearGradient=="function"?e.$linearGradient(e.theme):e.$linearGradient});
55
+ `,ellipsis:`
56
+ white-space: nowrap;
57
+ overflow: hidden;
58
+ text-overflow: ellipsis;
59
+ max-width: 100%;
60
+ `,underline:"text-decoration: underline;"},N=_styledcomponents2.default.p`
61
+ ${e=>w(e)}
62
+ ${e=>R(e,U)}
63
+ `,q= exports.Text =N;var{keys:J,entries:A,fromEntries:L}=Object,Q=()=>typeof window<"u"&&typeof document<"u"?document.body.clientWidth:0,_=e=>({getCssMedia:({min:t,max:i})=>t&&i?`@media (min-width: ${t}px) and (max-width: ${i}px)`:t?`@media (min-width: ${t}px)`:`@media (max-width: ${i}px)`,keys:J(e),...L(A(e).map(([t,{min:i,max:o}])=>[h(t),{min:i,max:o}])),...L(A(e).map(([t,{min:i=0,max:o=1/0}])=>[`is${h(t)}`,(l=Q())=>l!==0&&l>=i&&l<=o]))}),K=e=>(t,i=0,o=!0)=>(t||1)*e+i+(o?"px":0);function ee({theme:e,breakpoints:t,spacingUnit:i}){let o=_(t);return{theme:{...e,Breakpoints:o,spacing:K(i)},Breakpoints:o}}var te=ee;var we=M;exports.Div = M; exports.Text = q; exports.createUISystem = te; exports.default = we; exports.divMixin = w;
64
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Div.js","../src/utils.js","../src/rules.js","../src/Text.js","../src/createUISystem.js"],"names":["entries","upperFirst","str","kebabCase","string","x","spacing","val","theme","pixelate","fromEntries"],"mappings":"AAAA,04BAAmB,GCAb,CAAE,OAAA,CAAAA,CAAQ,CAAA,CAAI,MAAA,CAEPC,CAAAA,CAAaC,CAAAA,EAAOA,CAAAA,CAAI,MAAA,CAAO,CAAC,CAAA,CAAE,WAAA,CAAY,CAAA,CAAIA,CAAAA,CAAI,KAAA,CAAM,CAAC,CAAA,CAE7DC,CAAAA,CAAY,CAACC,CAAAA,CAAS,EAAA,CAAA,mCACjCA,CAAAA,qBACG,KAAA,mBAAM,oEAAoE,CAAA,6BACzE,GAAA,mBAAIC,CAAAA,EAAKA,CAAAA,CAAE,WAAA,CAAY,CAAC,CAAA,6BACxB,IAAA,mBAAK,GAAG,GAAA,SAAK,IAAA,CAEZ,SAASC,CAAAA,CAAQC,CAAAA,CAAKC,CAAAA,CAAO,CASlC,MARI,SAAA,CAAU,IAAA,CAAKD,CAAG,CAAA,EAIlB,OAAOA,CAAAA,EAAQ,QAAA,EAIfA,CAAAA,GAAQ,CAAA,CACHA,CAAAA,CAGFC,CAAAA,CAAM,OAAA,CAAQD,CAAG,CAC1B,CAEO,SAASE,CAAAA,CAASF,CAAAA,CAAK,CAC5B,OAAI,OAAOA,CAAAA,EAAQ,QAAA,CACV,CAAA,EAAA;AC6BH;AAAA;AAII,EAAA;AAAA;AAAA;AAIJ,EAAA;AAAA;AAYA,EAAA;AAAA;AAAA;AAIA,QAAA;AAAA;AAME,UAAA;AAgB0B,QAAA;AAWrB;AAAA;AA4BY,EAAA;AAAA;AAEgD,iBAAA;AAYhD,IAAA;AAAA;AAEkD,kBAAA;AAcpE,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4CP,EAAA;AAMyE,oBAAA;AACC,qBAAA;AAIjD,IAAA;AAC+C,mBAAA;AACG,sBAAA;AAwBlD,IAAA;AAC8C,mBAAA;AACC,oBAAA;AAI/C,IAAA;AAC6C,kBAAA;AACG,qBAAA;AAa5D,IAAA;AACwC,kCAAA;AACC,mCAAA;AACG,sCAAA;AACD,qCAAA;AA0BxD,QAAA;AFhL0B,EAAA;AGzGf;AAQc;AAAA;AAAA;AAAA;AASvB,sCAAA;AAEQ,EAAA;AAAA;AAAA;AAAA;AAAA;AASQ,EAAA;AACQ,EAAA;AACY,EAAA;ACxBjCG","file":"/Users/jason/Code/streamlined.fi/_div/dist/index.cjs","sourcesContent":["import styled from 'styled-components';\nimport { cssWhiteList, divRules } from './rules';\nimport {\n getMediaPropRegex,\n getRuleIndex,\n kebabCase,\n upperFirst,\n} from './utils';\n\nconst { keys } = Object;\n\n/**\n * @example\n * <Div\n * $w={690}\n * $h={420}\n * $mobile$w={320}\n * />\n */\n\nexport function renderCss(props, rules) {\n let css = '';\n\n const ruleIndex = getRuleIndex(rules);\n const mediaPropRegex = getMediaPropRegex(props.theme);\n\n let i = -1;\n const propKeys = keys(props);\n while (++i < propKeys.length) {\n const propExt = propKeys[i];\n\n if (/^\\$/.test(propExt)) {\n const value = props[propExt];\n\n if (value !== false) {\n const match = propExt.match(mediaPropRegex) || [];\n const [, media, mediaPropExt] = match;\n\n const cleanProp = (mediaPropExt || propExt).slice(1);\n const parts = cleanProp.split('$');\n const prop = parts[0];\n const extensions = parts.slice(1);\n\n const foundRule =\n ruleIndex[prop] || (cssWhiteList[prop] && kebabCase(prop));\n\n if (foundRule) {\n const config = foundRule;\n const outputValue =\n config.withTheme && typeof value === 'function'\n ? value(props.theme)\n : value;\n const formattedValue = config.format\n ? config.format(outputValue, props.theme)\n : outputValue;\n\n let ruleCss = '';\n if (typeof config === 'string') {\n ruleCss = config;\n } else if (typeof config === 'function') {\n ruleCss = config(props, media, extensions);\n } else if (typeof config.css === 'function') {\n ruleCss = config.css(props, media, extensions);\n } else {\n ruleCss = config.css;\n }\n\n let cssString = '';\n const colons = ruleCss.match(/:/g);\n if (colons && colons.length > 1) {\n cssString = ruleCss;\n } else if (colons === null) {\n cssString = `${ruleCss}: ${formattedValue};`;\n } else {\n cssString = `${ruleCss.replace(/;$/, '')};`;\n }\n\n if (extensions.includes('important')) {\n cssString = cssString.replace(/;/g, ' !important;');\n }\n\n if (extensions.includes('hover') && !extensions.includes('focus')) {\n cssString = `&:hover,&:focus { ${cssString} }`;\n }\n\n if (extensions.includes('hover') && extensions.includes('focus')) {\n cssString = `&:hover { ${cssString} }`;\n }\n\n if (extensions.includes('focus')) {\n cssString = `&:focus { ${cssString} }`;\n }\n\n if (extensions.includes('active')) {\n cssString = `&:active { ${cssString} }`;\n }\n\n if (extensions.includes('last')) {\n cssString = `&:last-child { ${cssString} }`;\n }\n\n if (extensions.includes('odd')) {\n cssString = `&:nth-child(odd) { ${cssString} }`;\n }\n\n if (extensions.includes('even')) {\n cssString = `&:nth-child(even) { ${cssString} }`;\n }\n\n if (media) {\n const cssMedia = props.theme.Breakpoints.getCssMedia(\n props.theme.Breakpoints[upperFirst(media)],\n );\n cssString = `${cssMedia} { ${cssString} }`;\n }\n\n css += cssString;\n }\n }\n }\n }\n\n return css;\n}\n\nexport const divMixin = props => renderCss(props, divRules);\n\nconst Div = styled.div`\n ${props => divMixin(props)}\n`;\n\nexport default Div;\n","const { entries } = Object;\n\nexport const upperFirst = str => str.charAt(0).toUpperCase() + str.slice(1);\n\nexport const kebabCase = (string = '') =>\n string\n .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)\n ?.map(x => x.toLowerCase())\n ?.join('-') ?? '';\n\nexport function spacing(val, theme) {\n if (/(px|%)$/.test(val)) {\n return val;\n }\n\n if (typeof val === 'string') {\n return val;\n }\n\n if (val === 0) {\n return val;\n }\n\n return theme.spacing(val);\n}\n\nexport function pixelate(val) {\n if (typeof val === 'number') {\n return `${val}px`;\n }\n return val;\n}\n\nexport function getPropValue(props, media, ...propKeys) {\n let value;\n for (let i = 0; i < propKeys.length; i++) {\n const key = propKeys[i];\n if (media) {\n const mediaVal = props[`$${media}$${key}`];\n if (mediaVal) {\n value = mediaVal;\n break;\n }\n }\n const val = props[`$${key}`];\n if (val) {\n value = val;\n break;\n }\n }\n\n return value;\n}\n\nexport function isPropPresent(props, media, ...propKeys) {\n return !!getPropValue(props, media, ...propKeys);\n}\n\nlet ruleIndex = null;\nexport function getRuleIndex(rules) {\n if (ruleIndex) return ruleIndex;\n\n const index = {};\n entries(rules).forEach(([ruleProp, config]) => {\n ruleProp.split('|').forEach(prop => {\n index[prop] = config;\n });\n });\n ruleIndex = index;\n\n return index;\n}\n\nlet mediaPropRegex = null;\nexport function getMediaPropRegex(theme) {\n if (mediaPropRegex) return mediaPropRegex;\n\n mediaPropRegex = new RegExp(\n `^\\\\$(${theme.Breakpoints.keys.join('|')})(\\\\$.*)`,\n );\n\n return mediaPropRegex;\n}\n\nexport function colorMixin(color, theme) {\n if (color) {\n if ([100, 200, 300, 400, 500, 600, 700, 800, 900].includes(color)) {\n return `color: ${theme[`fill${color}`]};`;\n }\n\n if (typeof color === 'string') {\n if (theme[color]) {\n return `color: ${theme[color]};`;\n }\n return `color: ${color};`;\n }\n }\n\n return '';\n}\n\nexport const sizeFormatter = value => {\n if (typeof value === 'number') {\n return `${value}px`;\n }\n return value;\n};\n","/* eslint-disable no-nested-ternary */\nimport { getPropValue, isPropPresent, pixelate, spacing } from './utils';\n\nconst { fromEntries } = Object;\n\nexport const cssWhiteList = fromEntries(\n [\n 'display',\n 'align',\n 'vAlign',\n 'alignItems',\n 'alignContent',\n 'alignSelf',\n 'justifyContent',\n 'justifySelf',\n 'flexDirection',\n 'flexBasis',\n 'flexWrap',\n 'pointerEvents',\n 'cursor',\n 'position',\n 'opacity',\n 'backgroundColor',\n 'backgroundImage',\n 'backgroundSize',\n 'backgroundPosition',\n 'backgroundRepeat',\n 'transform',\n 'transformOrigin',\n 'textDecoration',\n 'textWrap',\n 'animation',\n 'fontWeight',\n 'gap',\n 'gridTemplateColumns',\n 'gridTemplateRows',\n 'wordBreak',\n 'whiteSpace',\n 'textOverflow',\n 'overflow',\n 'overflowX',\n 'overflowY',\n 'textAlign',\n 'transitionDelay',\n 'filter',\n 'listStyle',\n 'objectFit',\n 'objectPosition',\n 'willChange',\n 'boxSizing',\n ].map(prop => [prop, 1]),\n);\n\n// short hand rules for the div component\nexport const divRules = {\n inline: 'display: inline',\n block: 'display: block',\n flex: `\n display: flex;\n width: 100%;\n `,\n autoFlex: `\n display: flex;\n width: auto;\n `,\n grid: `\n display: grid;\n `,\n hide: 'display: none',\n inlineBlock: 'display: inline-block',\n inlineFlex: 'display: inline-flex',\n 'column|col': 'flex-direction: column;',\n row: 'flex-direction: row;',\n spaceBetween: 'justify-content: space-between;',\n wrap: 'flex-wrap: wrap;',\n innerCenter: (props, media) =>\n isPropPresent(props, media, 'flex', 'inlineFlex')\n ? `\n justify-content: center;\n align-items: center;\n `\n : `\n text-align: center;\n ${\n isPropPresent(props, media, 'h', 'height')\n ? `line-height: ${getPropValue(props, media, 'h', 'height')};`\n : ''\n }\n `,\n innerLeft: (props, media) =>\n isPropPresent(props, media, 'flex', 'inlineFlex')\n ? isPropPresent(props, media, 'column', 'col')\n ? 'align-items: flex-start;'\n : 'justify-content: flex-start;'\n : 'text-align: left;',\n innerRight: (props, media) =>\n isPropPresent(props, media, 'flex', 'inlineFlex')\n ? isPropPresent(props, media, 'column', 'col')\n ? 'align-items: flex-end;'\n : 'justify-content: flex-end;'\n : 'text-align: right;',\n innerTop: (props, media) => {\n return isPropPresent(props, media, 'flex', 'inlineFlex')\n ? isPropPresent(props, media, 'column', 'col')\n ? 'justify-content: flex-start;'\n : 'align-items: flex-start;'\n : '';\n },\n innerBottom: (props, media) =>\n isPropPresent(props, media, 'flex', 'inlineFlex')\n ? isPropPresent(props, media, 'column', 'col')\n ? 'justify-content: flex-end;'\n : 'align-items: flex-end;'\n : '',\n outerCenter: `\n margin-left: auto;\n margin-right: auto;\n `,\n grow: {\n css: 'flex-grow',\n format: Number,\n },\n shrink: {\n css: 'flex-shrink',\n },\n 'colReverse|columnReverse': {\n css: 'flex-direction: column-reverse;',\n },\n reverse: {\n css: 'flex-direction: row-reverse;',\n },\n\n // dimensions\n 'width|w': {\n css: 'width',\n format: pixelate,\n },\n 'minWidth|minW': {\n css: 'min-width',\n format: pixelate,\n },\n 'maxWidth|maxW': {\n css: (props, media) => `\n width: 100%;\n max-width: ${pixelate(getPropValue(props, media, 'maxWidth', 'maxW'))};\n `,\n },\n 'height|h': {\n css: 'height',\n format: pixelate,\n },\n 'minHeight|minH': {\n css: 'min-height',\n format: pixelate,\n },\n 'maxHeight|maxH': {\n css: (props, media) => `\n height: 100%;\n max-height: ${pixelate(getPropValue(props, media, 'maxHeight', 'maxH'))};\n `,\n },\n 'lineHeight|lineH|lh': {\n css: 'line-height',\n format: pixelate,\n },\n pointer: 'cursor: pointer;',\n\n // position\n relative: 'position: relative',\n absolute: 'position: absolute',\n fixed: 'position: fixed',\n static: 'position: static',\n cover: `\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n `,\n 'zIndex|z': {\n css: 'z-index',\n withTheme: true,\n },\n top: {\n css: 'top',\n format: pixelate,\n },\n right: {\n css: 'right',\n format: pixelate,\n },\n bottom: {\n css: 'bottom',\n format: pixelate,\n },\n left: {\n css: 'left',\n format: pixelate,\n },\n\n 'padding|p': {\n css: 'padding',\n format: spacing,\n },\n 'paddingTop|pt': {\n css: 'padding-top',\n format: spacing,\n },\n 'paddingRight|pr': {\n css: 'padding-right',\n format: spacing,\n },\n 'paddingBottom|pb': {\n css: 'padding-bottom',\n format: spacing,\n },\n 'paddingLeft|pl': {\n css: 'padding-left',\n format: spacing,\n },\n 'paddingX|px': {\n css: (props, media) => `\n padding-left: ${spacing(getPropValue(props, media, 'paddingX', 'px'))};\n padding-right: ${spacing(getPropValue(props, media, 'paddingX', 'px'))};\n `,\n },\n 'paddingY|py': {\n css: (props, media) => `\n padding-top: ${spacing(getPropValue(props, media, 'paddingY', 'py'))};\n padding-bottom: ${spacing(getPropValue(props, media, 'paddingY', 'py'))};\n `,\n },\n 'margin|m': {\n css: 'margin',\n format: spacing,\n },\n 'marginTop|mt': {\n css: 'margin-top',\n format: spacing,\n },\n 'marginRight|mr': {\n css: 'margin-right',\n format: spacing,\n },\n 'marginBottom|mb': {\n css: 'margin-bottom',\n format: spacing,\n },\n 'marginLeft|ml': {\n css: 'margin-left',\n format: spacing,\n },\n 'marginX|mx': {\n css: (props, media) => `\n margin-left: ${spacing(getPropValue(props, media, 'marginX', 'mx'))};\n margin-right: ${spacing(getPropValue(props, media, 'marginX', 'mx'))};\n `,\n },\n 'marginY|my': {\n css: (props, media) => `\n margin-top: ${spacing(getPropValue(props, media, 'marginY', 'my'))};\n margin-bottom: ${spacing(getPropValue(props, media, 'marginY', 'my'))};\n `,\n },\n\n // style\n 'background|bg': {\n css: 'background',\n withTheme: true,\n },\n 'borderRadius|radius': {\n css: (props, media) => {\n const radius = getPropValue(props, media, 'borderRadius', 'radius');\n if (Array.isArray(radius)) {\n return `\n border-top-left-radius: ${pixelate(radius[0])};\n border-top-right-radius: ${pixelate(radius[1])};\n border-bottom-right-radius: ${pixelate(radius[2])};\n border-bottom-left-radius: ${pixelate(radius[3])};\n `;\n }\n return `border-radius: ${pixelate(radius)}`;\n },\n },\n borderTopLeftRadius: {\n css: 'border-top-left-radius',\n format: pixelate,\n },\n borderTopRightRadius: {\n css: 'border-top-right-radius',\n format: pixelate,\n },\n borderBottomRightRadius: {\n css: 'border-bottom-right-radius',\n format: pixelate,\n },\n borderBottomLeftRadius: {\n css: 'border-bottom-left-radius',\n format: pixelate,\n },\n borderColor: {\n css: 'border-color',\n withTheme: true,\n },\n borderImage: {\n css: 'border-image',\n withTheme: true,\n },\n ...[\n ['border', 'border'],\n ['borderTop', 'border-top'],\n ['borderRight', 'border-right'],\n ['borderBottom', 'border-bottom'],\n ['borderLeft', 'border-left'],\n ].reduce(\n (rules, [jsKey, cssKey]) => ({\n ...rules,\n [jsKey]: {\n css: (props, media, extensions) => {\n const propValue = getPropValue(\n props,\n media,\n extensions?.length ? [jsKey, ...extensions].join('$') : jsKey,\n );\n\n // withTheme\n const value =\n typeof propValue === 'function'\n ? propValue(props.theme)\n : propValue;\n\n if (!/^\\d/.test(value)) {\n return `${cssKey}: 1px solid ${value}`;\n }\n return `${cssKey}: ${value}`;\n },\n },\n }),\n {},\n ),\n transition: (props, media) => {\n const value = getPropValue(props, media, 'transition');\n return typeof value === 'string'\n ? `transition: ${value}`\n : 'transition: all .2s';\n },\n 'boxShadow|shadow': {\n css: 'box-shadow',\n withTheme: true,\n },\n textShadow: {\n css: 'text-shadow',\n withTheme: true,\n },\n color: {\n css: 'color',\n withTheme: true,\n },\n fill: {\n css: 'fill',\n withTheme: true,\n },\n fontSize: {\n css: 'font-size',\n format: pixelate,\n },\n outline: {\n css: 'outline',\n withTheme: true,\n },\n};\n","import styled from 'styled-components';\nimport { colorMixin, sizeFormatter } from './utils';\n\nimport { divMixin, renderCss } from './Div';\n\nconst textRules = {\n weight: 'font-weight',\n size: {\n css: 'font-size',\n format: sizeFormatter,\n },\n color: {\n css: (props, media, extensions) => {\n const color = extensions.includes('hover')\n ? props.$color$hover\n : props.$color;\n\n return colorMixin(color, props.theme);\n },\n },\n tnum: 'font-feature-settings: \"tnum\";letter-spacing:-0.04em;',\n breakWord: 'word-break: break-word;',\n noBreak: 'white-space: nowrap;',\n uppercase: 'text-transform: uppercase;',\n serif: 'font-family: \"Times New Roman\", Times, serif',\n 'spacing|letterSpacing': `letter-spacing`,\n left: 'text-align: left;',\n right: 'text-align: right;',\n center: 'text-align: center;',\n lineThrough: 'text-decoration: line-through',\n // underline: 'text-decoration: underline;',\n linearGradient: props => `\n -webkit-text-fill-color: transparent;\n text-fill-color: transparent;\n -webkit-background-clip: text;\n background-clip: text;\n background-image: linear-gradient(${\n typeof props.$linearGradient === 'function'\n ? props.$linearGradient(props.theme)\n : props.$linearGradient\n });\n `,\n ellipsis: `\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 100%;\n `,\n underline: 'text-decoration: underline;',\n};\n\nconst Text = styled.p`\n ${props => divMixin(props)}\n ${props => renderCss(props, textRules)}\n`;\n\nexport default Text;\n","import { upperFirst } from './utils';\n\nconst { keys, entries, fromEntries } = Object;\n\nconst getDefaultWidth = () => {\n return typeof window !== 'undefined' && typeof document !== 'undefined'\n ? document.body.clientWidth\n : 0;\n};\n\nconst createBreakpoints = breakpoints => {\n return {\n getCssMedia: ({ min, max }) => {\n if (min && max) {\n return `@media (min-width: ${min}px) and (max-width: ${max}px)`;\n }\n\n if (min) {\n return `@media (min-width: ${min}px)`;\n }\n\n return `@media (max-width: ${max}px)`;\n },\n keys: keys(breakpoints),\n ...fromEntries(\n entries(breakpoints).map(([key, { min, max }]) => {\n return [upperFirst(key), { min, max }];\n }),\n ),\n ...fromEntries(\n entries(breakpoints).map(([key, { min = 0, max = Infinity }]) => {\n return [\n `is${upperFirst(key)}`,\n (width = getDefaultWidth()) =>\n width !== 0 && width >= min && width <= max,\n ];\n }),\n ),\n };\n};\n\nconst createSpacing = spacingUnit => (multiplier, adjuster = 0, usePx = true) =>\n (multiplier || 1) * spacingUnit + adjuster + (usePx ? 'px' : 0);\n\nfunction createUISystem({ theme, breakpoints, spacingUnit }) {\n const Breakpoints = createBreakpoints(breakpoints);\n\n return {\n theme: {\n ...theme,\n Breakpoints,\n spacing: createSpacing(spacingUnit),\n },\n Breakpoints,\n };\n}\n\nexport default createUISystem;\n"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,64 @@
1
+ import O from"styled-components";var{entries:Y}=Object,h=e=>e.charAt(0).toUpperCase()+e.slice(1),j=(e="")=>e.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)?.map(t=>t.toLowerCase())?.join("-")??"";function s(e,t){return/(px|%)$/.test(e)||typeof e=="string"||e===0?e:t.spacing(e)}function n(e){return typeof e=="number"?`${e}px`:e}function a(e,t,...i){let o;for(let l=0;l<i.length;l++){let g=i[l];if(t){let d=e[`$${t}$${g}`];if(d){o=d;break}}let u=e[`$${g}`];if(u){o=u;break}}return o}function f(e,t,...i){return!!a(e,t,...i)}var v=null;function P(e){if(v)return v;let t={};return Y(e).forEach(([i,o])=>{i.split("|").forEach(l=>{t[l]=o})}),v=t,t}var $=null;function S(e){return $||($=new RegExp(`^\\$(${e.Breakpoints.keys.join("|")})(\\$.*)`),$)}function W(e,t){if(e){if([100,200,300,400,500,600,700,800,900].includes(e))return`color: ${t[`fill${e}`]};`;if(typeof e=="string")return t[e]?`color: ${t[e]};`:`color: ${e};`}return""}var z=e=>typeof e=="number"?`${e}px`:e;var{fromEntries:D}=Object,F=D(["display","align","vAlign","alignItems","alignContent","alignSelf","justifyContent","justifySelf","flexDirection","flexBasis","flexWrap","pointerEvents","cursor","position","opacity","backgroundColor","backgroundImage","backgroundSize","backgroundPosition","backgroundRepeat","transform","transformOrigin","textDecoration","textWrap","animation","fontWeight","gap","gridTemplateColumns","gridTemplateRows","wordBreak","whiteSpace","textOverflow","overflow","overflowX","overflowY","textAlign","transitionDelay","filter","listStyle","objectFit","objectPosition","willChange","boxSizing"].map(e=>[e,1])),I={inline:"display: inline",block:"display: block",flex:`
2
+ display: flex;
3
+ width: 100%;
4
+ `,autoFlex:`
5
+ display: flex;
6
+ width: auto;
7
+ `,grid:`
8
+ display: grid;
9
+ `,hide:"display: none",inlineBlock:"display: inline-block",inlineFlex:"display: inline-flex","column|col":"flex-direction: column;",row:"flex-direction: row;",spaceBetween:"justify-content: space-between;",wrap:"flex-wrap: wrap;",innerCenter:(e,t)=>f(e,t,"flex","inlineFlex")?`
10
+ justify-content: center;
11
+ align-items: center;
12
+ `:`
13
+ text-align: center;
14
+ ${f(e,t,"h","height")?`line-height: ${a(e,t,"h","height")};`:""}
15
+ `,innerLeft:(e,t)=>f(e,t,"flex","inlineFlex")?f(e,t,"column","col")?"align-items: flex-start;":"justify-content: flex-start;":"text-align: left;",innerRight:(e,t)=>f(e,t,"flex","inlineFlex")?f(e,t,"column","col")?"align-items: flex-end;":"justify-content: flex-end;":"text-align: right;",innerTop:(e,t)=>f(e,t,"flex","inlineFlex")?f(e,t,"column","col")?"justify-content: flex-start;":"align-items: flex-start;":"",innerBottom:(e,t)=>f(e,t,"flex","inlineFlex")?f(e,t,"column","col")?"justify-content: flex-end;":"align-items: flex-end;":"",outerCenter:`
16
+ margin-left: auto;
17
+ margin-right: auto;
18
+ `,grow:{css:"flex-grow",format:Number},shrink:{css:"flex-shrink"},"colReverse|columnReverse":{css:"flex-direction: column-reverse;"},reverse:{css:"flex-direction: row-reverse;"},"width|w":{css:"width",format:n},"minWidth|minW":{css:"min-width",format:n},"maxWidth|maxW":{css:(e,t)=>`
19
+ width: 100%;
20
+ max-width: ${n(a(e,t,"maxWidth","maxW"))};
21
+ `},"height|h":{css:"height",format:n},"minHeight|minH":{css:"min-height",format:n},"maxHeight|maxH":{css:(e,t)=>`
22
+ height: 100%;
23
+ max-height: ${n(a(e,t,"maxHeight","maxH"))};
24
+ `},"lineHeight|lineH|lh":{css:"line-height",format:n},pointer:"cursor: pointer;",relative:"position: relative",absolute:"position: absolute",fixed:"position: fixed",static:"position: static",cover:`
25
+ position: absolute;
26
+ top: 0;
27
+ left: 0;
28
+ width: 100%;
29
+ height: 100%;
30
+ `,"zIndex|z":{css:"z-index",withTheme:!0},top:{css:"top",format:n},right:{css:"right",format:n},bottom:{css:"bottom",format:n},left:{css:"left",format:n},"padding|p":{css:"padding",format:s},"paddingTop|pt":{css:"padding-top",format:s},"paddingRight|pr":{css:"padding-right",format:s},"paddingBottom|pb":{css:"padding-bottom",format:s},"paddingLeft|pl":{css:"padding-left",format:s},"paddingX|px":{css:(e,t)=>`
31
+ padding-left: ${s(a(e,t,"paddingX","px"))};
32
+ padding-right: ${s(a(e,t,"paddingX","px"))};
33
+ `},"paddingY|py":{css:(e,t)=>`
34
+ padding-top: ${s(a(e,t,"paddingY","py"))};
35
+ padding-bottom: ${s(a(e,t,"paddingY","py"))};
36
+ `},"margin|m":{css:"margin",format:s},"marginTop|mt":{css:"margin-top",format:s},"marginRight|mr":{css:"margin-right",format:s},"marginBottom|mb":{css:"margin-bottom",format:s},"marginLeft|ml":{css:"margin-left",format:s},"marginX|mx":{css:(e,t)=>`
37
+ margin-left: ${s(a(e,t,"marginX","mx"))};
38
+ margin-right: ${s(a(e,t,"marginX","mx"))};
39
+ `},"marginY|my":{css:(e,t)=>`
40
+ margin-top: ${s(a(e,t,"marginY","my"))};
41
+ margin-bottom: ${s(a(e,t,"marginY","my"))};
42
+ `},"background|bg":{css:"background",withTheme:!0},"borderRadius|radius":{css:(e,t)=>{let i=a(e,t,"borderRadius","radius");return Array.isArray(i)?`
43
+ border-top-left-radius: ${n(i[0])};
44
+ border-top-right-radius: ${n(i[1])};
45
+ border-bottom-right-radius: ${n(i[2])};
46
+ border-bottom-left-radius: ${n(i[3])};
47
+ `:`border-radius: ${n(i)}`}},borderTopLeftRadius:{css:"border-top-left-radius",format:n},borderTopRightRadius:{css:"border-top-right-radius",format:n},borderBottomRightRadius:{css:"border-bottom-right-radius",format:n},borderBottomLeftRadius:{css:"border-bottom-left-radius",format:n},borderColor:{css:"border-color",withTheme:!0},borderImage:{css:"border-image",withTheme:!0},...[["border","border"],["borderTop","border-top"],["borderRight","border-right"],["borderBottom","border-bottom"],["borderLeft","border-left"]].reduce((e,[t,i])=>({...e,[t]:{css:(o,l,g)=>{let u=a(o,l,g?.length?[t,...g].join("$"):t),d=typeof u=="function"?u(o.theme):u;return/^\d/.test(d)?`${i}: ${d}`:`${i}: 1px solid ${d}`}}}),{}),transition:(e,t)=>{let i=a(e,t,"transition");return typeof i=="string"?`transition: ${i}`:"transition: all .2s"},"boxShadow|shadow":{css:"box-shadow",withTheme:!0},textShadow:{css:"text-shadow",withTheme:!0},color:{css:"color",withTheme:!0},fill:{css:"fill",withTheme:!0},fontSize:{css:"font-size",format:n},outline:{css:"outline",withTheme:!0}};var{keys:V}=Object;function R(e,t){let i="",o=P(t),l=S(e.theme),g=-1,u=V(e);for(;++g<u.length;){let d=u[g];if(/^\$/.test(d)){let x=e[d];if(x!==!1){let E=d.match(l)||[],[,b,H]=E,T=(H||d).slice(1).split("$"),y=T[0],c=T.slice(1),C=o[y]||F[y]&&j(y);if(C){let m=C,B=m.withTheme&&typeof x=="function"?x(e.theme):x,X=m.format?m.format(B,e.theme):B,p="";typeof m=="string"?p=m:typeof m=="function"?p=m(e,b,c):typeof m.css=="function"?p=m.css(e,b,c):p=m.css;let r="",k=p.match(/:/g);k&&k.length>1?r=p:k===null?r=`${p}: ${X};`:r=`${p.replace(/;$/,"")};`,c.includes("important")&&(r=r.replace(/;/g," !important;")),c.includes("hover")&&!c.includes("focus")&&(r=`&:hover,&:focus { ${r} }`),c.includes("hover")&&c.includes("focus")&&(r=`&:hover { ${r} }`),c.includes("focus")&&(r=`&:focus { ${r} }`),c.includes("active")&&(r=`&:active { ${r} }`),c.includes("last")&&(r=`&:last-child { ${r} }`),c.includes("odd")&&(r=`&:nth-child(odd) { ${r} }`),c.includes("even")&&(r=`&:nth-child(even) { ${r} }`),b&&(r=`${e.theme.Breakpoints.getCssMedia(e.theme.Breakpoints[h(b)])} { ${r} }`),i+=r}}}}return i}var w=e=>R(e,I),G=O.div`
48
+ ${e=>w(e)}
49
+ `,M=G;import Z from"styled-components";var U={weight:"font-weight",size:{css:"font-size",format:z},color:{css:(e,t,i)=>{let o=i.includes("hover")?e.$color$hover:e.$color;return W(o,e.theme)}},tnum:'font-feature-settings: "tnum";letter-spacing:-0.04em;',breakWord:"word-break: break-word;",noBreak:"white-space: nowrap;",uppercase:"text-transform: uppercase;",serif:'font-family: "Times New Roman", Times, serif',"spacing|letterSpacing":"letter-spacing",left:"text-align: left;",right:"text-align: right;",center:"text-align: center;",lineThrough:"text-decoration: line-through",linearGradient:e=>`
50
+ -webkit-text-fill-color: transparent;
51
+ text-fill-color: transparent;
52
+ -webkit-background-clip: text;
53
+ background-clip: text;
54
+ background-image: linear-gradient(${typeof e.$linearGradient=="function"?e.$linearGradient(e.theme):e.$linearGradient});
55
+ `,ellipsis:`
56
+ white-space: nowrap;
57
+ overflow: hidden;
58
+ text-overflow: ellipsis;
59
+ max-width: 100%;
60
+ `,underline:"text-decoration: underline;"},N=Z.p`
61
+ ${e=>w(e)}
62
+ ${e=>R(e,U)}
63
+ `,q=N;var{keys:J,entries:A,fromEntries:L}=Object,Q=()=>typeof window<"u"&&typeof document<"u"?document.body.clientWidth:0,_=e=>({getCssMedia:({min:t,max:i})=>t&&i?`@media (min-width: ${t}px) and (max-width: ${i}px)`:t?`@media (min-width: ${t}px)`:`@media (max-width: ${i}px)`,keys:J(e),...L(A(e).map(([t,{min:i,max:o}])=>[h(t),{min:i,max:o}])),...L(A(e).map(([t,{min:i=0,max:o=1/0}])=>[`is${h(t)}`,(l=Q())=>l!==0&&l>=i&&l<=o]))}),K=e=>(t,i=0,o=!0)=>(t||1)*e+i+(o?"px":0);function ee({theme:e,breakpoints:t,spacingUnit:i}){let o=_(t);return{theme:{...e,Breakpoints:o,spacing:K(i)},Breakpoints:o}}var te=ee;var we=M;export{M as Div,q as Text,te as createUISystem,we as default,w as divMixin};
64
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Div.js","../src/utils.js","../src/rules.js","../src/Text.js","../src/createUISystem.js","../src/index.js"],"sourcesContent":["import styled from 'styled-components';\nimport { cssWhiteList, divRules } from './rules';\nimport {\n getMediaPropRegex,\n getRuleIndex,\n kebabCase,\n upperFirst,\n} from './utils';\n\nconst { keys } = Object;\n\n/**\n * @example\n * <Div\n * $w={690}\n * $h={420}\n * $mobile$w={320}\n * />\n */\n\nexport function renderCss(props, rules) {\n let css = '';\n\n const ruleIndex = getRuleIndex(rules);\n const mediaPropRegex = getMediaPropRegex(props.theme);\n\n let i = -1;\n const propKeys = keys(props);\n while (++i < propKeys.length) {\n const propExt = propKeys[i];\n\n if (/^\\$/.test(propExt)) {\n const value = props[propExt];\n\n if (value !== false) {\n const match = propExt.match(mediaPropRegex) || [];\n const [, media, mediaPropExt] = match;\n\n const cleanProp = (mediaPropExt || propExt).slice(1);\n const parts = cleanProp.split('$');\n const prop = parts[0];\n const extensions = parts.slice(1);\n\n const foundRule =\n ruleIndex[prop] || (cssWhiteList[prop] && kebabCase(prop));\n\n if (foundRule) {\n const config = foundRule;\n const outputValue =\n config.withTheme && typeof value === 'function'\n ? value(props.theme)\n : value;\n const formattedValue = config.format\n ? config.format(outputValue, props.theme)\n : outputValue;\n\n let ruleCss = '';\n if (typeof config === 'string') {\n ruleCss = config;\n } else if (typeof config === 'function') {\n ruleCss = config(props, media, extensions);\n } else if (typeof config.css === 'function') {\n ruleCss = config.css(props, media, extensions);\n } else {\n ruleCss = config.css;\n }\n\n let cssString = '';\n const colons = ruleCss.match(/:/g);\n if (colons && colons.length > 1) {\n cssString = ruleCss;\n } else if (colons === null) {\n cssString = `${ruleCss}: ${formattedValue};`;\n } else {\n cssString = `${ruleCss.replace(/;$/, '')};`;\n }\n\n if (extensions.includes('important')) {\n cssString = cssString.replace(/;/g, ' !important;');\n }\n\n if (extensions.includes('hover') && !extensions.includes('focus')) {\n cssString = `&:hover,&:focus { ${cssString} }`;\n }\n\n if (extensions.includes('hover') && extensions.includes('focus')) {\n cssString = `&:hover { ${cssString} }`;\n }\n\n if (extensions.includes('focus')) {\n cssString = `&:focus { ${cssString} }`;\n }\n\n if (extensions.includes('active')) {\n cssString = `&:active { ${cssString} }`;\n }\n\n if (extensions.includes('last')) {\n cssString = `&:last-child { ${cssString} }`;\n }\n\n if (extensions.includes('odd')) {\n cssString = `&:nth-child(odd) { ${cssString} }`;\n }\n\n if (extensions.includes('even')) {\n cssString = `&:nth-child(even) { ${cssString} }`;\n }\n\n if (media) {\n const cssMedia = props.theme.Breakpoints.getCssMedia(\n props.theme.Breakpoints[upperFirst(media)],\n );\n cssString = `${cssMedia} { ${cssString} }`;\n }\n\n css += cssString;\n }\n }\n }\n }\n\n return css;\n}\n\nexport const divMixin = props => renderCss(props, divRules);\n\nconst Div = styled.div`\n ${props => divMixin(props)}\n`;\n\nexport default Div;\n","const { entries } = Object;\n\nexport const upperFirst = str => str.charAt(0).toUpperCase() + str.slice(1);\n\nexport const kebabCase = (string = '') =>\n string\n .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)\n ?.map(x => x.toLowerCase())\n ?.join('-') ?? '';\n\nexport function spacing(val, theme) {\n if (/(px|%)$/.test(val)) {\n return val;\n }\n\n if (typeof val === 'string') {\n return val;\n }\n\n if (val === 0) {\n return val;\n }\n\n return theme.spacing(val);\n}\n\nexport function pixelate(val) {\n if (typeof val === 'number') {\n return `${val}px`;\n }\n return val;\n}\n\nexport function getPropValue(props, media, ...propKeys) {\n let value;\n for (let i = 0; i < propKeys.length; i++) {\n const key = propKeys[i];\n if (media) {\n const mediaVal = props[`$${media}$${key}`];\n if (mediaVal) {\n value = mediaVal;\n break;\n }\n }\n const val = props[`$${key}`];\n if (val) {\n value = val;\n break;\n }\n }\n\n return value;\n}\n\nexport function isPropPresent(props, media, ...propKeys) {\n return !!getPropValue(props, media, ...propKeys);\n}\n\nlet ruleIndex = null;\nexport function getRuleIndex(rules) {\n if (ruleIndex) return ruleIndex;\n\n const index = {};\n entries(rules).forEach(([ruleProp, config]) => {\n ruleProp.split('|').forEach(prop => {\n index[prop] = config;\n });\n });\n ruleIndex = index;\n\n return index;\n}\n\nlet mediaPropRegex = null;\nexport function getMediaPropRegex(theme) {\n if (mediaPropRegex) return mediaPropRegex;\n\n mediaPropRegex = new RegExp(\n `^\\\\$(${theme.Breakpoints.keys.join('|')})(\\\\$.*)`,\n );\n\n return mediaPropRegex;\n}\n\nexport function colorMixin(color, theme) {\n if (color) {\n if ([100, 200, 300, 400, 500, 600, 700, 800, 900].includes(color)) {\n return `color: ${theme[`fill${color}`]};`;\n }\n\n if (typeof color === 'string') {\n if (theme[color]) {\n return `color: ${theme[color]};`;\n }\n return `color: ${color};`;\n }\n }\n\n return '';\n}\n\nexport const sizeFormatter = value => {\n if (typeof value === 'number') {\n return `${value}px`;\n }\n return value;\n};\n","/* eslint-disable no-nested-ternary */\nimport { getPropValue, isPropPresent, pixelate, spacing } from './utils';\n\nconst { fromEntries } = Object;\n\nexport const cssWhiteList = fromEntries(\n [\n 'display',\n 'align',\n 'vAlign',\n 'alignItems',\n 'alignContent',\n 'alignSelf',\n 'justifyContent',\n 'justifySelf',\n 'flexDirection',\n 'flexBasis',\n 'flexWrap',\n 'pointerEvents',\n 'cursor',\n 'position',\n 'opacity',\n 'backgroundColor',\n 'backgroundImage',\n 'backgroundSize',\n 'backgroundPosition',\n 'backgroundRepeat',\n 'transform',\n 'transformOrigin',\n 'textDecoration',\n 'textWrap',\n 'animation',\n 'fontWeight',\n 'gap',\n 'gridTemplateColumns',\n 'gridTemplateRows',\n 'wordBreak',\n 'whiteSpace',\n 'textOverflow',\n 'overflow',\n 'overflowX',\n 'overflowY',\n 'textAlign',\n 'transitionDelay',\n 'filter',\n 'listStyle',\n 'objectFit',\n 'objectPosition',\n 'willChange',\n 'boxSizing',\n ].map(prop => [prop, 1]),\n);\n\n// short hand rules for the div component\nexport const divRules = {\n inline: 'display: inline',\n block: 'display: block',\n flex: `\n display: flex;\n width: 100%;\n `,\n autoFlex: `\n display: flex;\n width: auto;\n `,\n grid: `\n display: grid;\n `,\n hide: 'display: none',\n inlineBlock: 'display: inline-block',\n inlineFlex: 'display: inline-flex',\n 'column|col': 'flex-direction: column;',\n row: 'flex-direction: row;',\n spaceBetween: 'justify-content: space-between;',\n wrap: 'flex-wrap: wrap;',\n innerCenter: (props, media) =>\n isPropPresent(props, media, 'flex', 'inlineFlex')\n ? `\n justify-content: center;\n align-items: center;\n `\n : `\n text-align: center;\n ${\n isPropPresent(props, media, 'h', 'height')\n ? `line-height: ${getPropValue(props, media, 'h', 'height')};`\n : ''\n }\n `,\n innerLeft: (props, media) =>\n isPropPresent(props, media, 'flex', 'inlineFlex')\n ? isPropPresent(props, media, 'column', 'col')\n ? 'align-items: flex-start;'\n : 'justify-content: flex-start;'\n : 'text-align: left;',\n innerRight: (props, media) =>\n isPropPresent(props, media, 'flex', 'inlineFlex')\n ? isPropPresent(props, media, 'column', 'col')\n ? 'align-items: flex-end;'\n : 'justify-content: flex-end;'\n : 'text-align: right;',\n innerTop: (props, media) => {\n return isPropPresent(props, media, 'flex', 'inlineFlex')\n ? isPropPresent(props, media, 'column', 'col')\n ? 'justify-content: flex-start;'\n : 'align-items: flex-start;'\n : '';\n },\n innerBottom: (props, media) =>\n isPropPresent(props, media, 'flex', 'inlineFlex')\n ? isPropPresent(props, media, 'column', 'col')\n ? 'justify-content: flex-end;'\n : 'align-items: flex-end;'\n : '',\n outerCenter: `\n margin-left: auto;\n margin-right: auto;\n `,\n grow: {\n css: 'flex-grow',\n format: Number,\n },\n shrink: {\n css: 'flex-shrink',\n },\n 'colReverse|columnReverse': {\n css: 'flex-direction: column-reverse;',\n },\n reverse: {\n css: 'flex-direction: row-reverse;',\n },\n\n // dimensions\n 'width|w': {\n css: 'width',\n format: pixelate,\n },\n 'minWidth|minW': {\n css: 'min-width',\n format: pixelate,\n },\n 'maxWidth|maxW': {\n css: (props, media) => `\n width: 100%;\n max-width: ${pixelate(getPropValue(props, media, 'maxWidth', 'maxW'))};\n `,\n },\n 'height|h': {\n css: 'height',\n format: pixelate,\n },\n 'minHeight|minH': {\n css: 'min-height',\n format: pixelate,\n },\n 'maxHeight|maxH': {\n css: (props, media) => `\n height: 100%;\n max-height: ${pixelate(getPropValue(props, media, 'maxHeight', 'maxH'))};\n `,\n },\n 'lineHeight|lineH|lh': {\n css: 'line-height',\n format: pixelate,\n },\n pointer: 'cursor: pointer;',\n\n // position\n relative: 'position: relative',\n absolute: 'position: absolute',\n fixed: 'position: fixed',\n static: 'position: static',\n cover: `\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n `,\n 'zIndex|z': {\n css: 'z-index',\n withTheme: true,\n },\n top: {\n css: 'top',\n format: pixelate,\n },\n right: {\n css: 'right',\n format: pixelate,\n },\n bottom: {\n css: 'bottom',\n format: pixelate,\n },\n left: {\n css: 'left',\n format: pixelate,\n },\n\n 'padding|p': {\n css: 'padding',\n format: spacing,\n },\n 'paddingTop|pt': {\n css: 'padding-top',\n format: spacing,\n },\n 'paddingRight|pr': {\n css: 'padding-right',\n format: spacing,\n },\n 'paddingBottom|pb': {\n css: 'padding-bottom',\n format: spacing,\n },\n 'paddingLeft|pl': {\n css: 'padding-left',\n format: spacing,\n },\n 'paddingX|px': {\n css: (props, media) => `\n padding-left: ${spacing(getPropValue(props, media, 'paddingX', 'px'))};\n padding-right: ${spacing(getPropValue(props, media, 'paddingX', 'px'))};\n `,\n },\n 'paddingY|py': {\n css: (props, media) => `\n padding-top: ${spacing(getPropValue(props, media, 'paddingY', 'py'))};\n padding-bottom: ${spacing(getPropValue(props, media, 'paddingY', 'py'))};\n `,\n },\n 'margin|m': {\n css: 'margin',\n format: spacing,\n },\n 'marginTop|mt': {\n css: 'margin-top',\n format: spacing,\n },\n 'marginRight|mr': {\n css: 'margin-right',\n format: spacing,\n },\n 'marginBottom|mb': {\n css: 'margin-bottom',\n format: spacing,\n },\n 'marginLeft|ml': {\n css: 'margin-left',\n format: spacing,\n },\n 'marginX|mx': {\n css: (props, media) => `\n margin-left: ${spacing(getPropValue(props, media, 'marginX', 'mx'))};\n margin-right: ${spacing(getPropValue(props, media, 'marginX', 'mx'))};\n `,\n },\n 'marginY|my': {\n css: (props, media) => `\n margin-top: ${spacing(getPropValue(props, media, 'marginY', 'my'))};\n margin-bottom: ${spacing(getPropValue(props, media, 'marginY', 'my'))};\n `,\n },\n\n // style\n 'background|bg': {\n css: 'background',\n withTheme: true,\n },\n 'borderRadius|radius': {\n css: (props, media) => {\n const radius = getPropValue(props, media, 'borderRadius', 'radius');\n if (Array.isArray(radius)) {\n return `\n border-top-left-radius: ${pixelate(radius[0])};\n border-top-right-radius: ${pixelate(radius[1])};\n border-bottom-right-radius: ${pixelate(radius[2])};\n border-bottom-left-radius: ${pixelate(radius[3])};\n `;\n }\n return `border-radius: ${pixelate(radius)}`;\n },\n },\n borderTopLeftRadius: {\n css: 'border-top-left-radius',\n format: pixelate,\n },\n borderTopRightRadius: {\n css: 'border-top-right-radius',\n format: pixelate,\n },\n borderBottomRightRadius: {\n css: 'border-bottom-right-radius',\n format: pixelate,\n },\n borderBottomLeftRadius: {\n css: 'border-bottom-left-radius',\n format: pixelate,\n },\n borderColor: {\n css: 'border-color',\n withTheme: true,\n },\n borderImage: {\n css: 'border-image',\n withTheme: true,\n },\n ...[\n ['border', 'border'],\n ['borderTop', 'border-top'],\n ['borderRight', 'border-right'],\n ['borderBottom', 'border-bottom'],\n ['borderLeft', 'border-left'],\n ].reduce(\n (rules, [jsKey, cssKey]) => ({\n ...rules,\n [jsKey]: {\n css: (props, media, extensions) => {\n const propValue = getPropValue(\n props,\n media,\n extensions?.length ? [jsKey, ...extensions].join('$') : jsKey,\n );\n\n // withTheme\n const value =\n typeof propValue === 'function'\n ? propValue(props.theme)\n : propValue;\n\n if (!/^\\d/.test(value)) {\n return `${cssKey}: 1px solid ${value}`;\n }\n return `${cssKey}: ${value}`;\n },\n },\n }),\n {},\n ),\n transition: (props, media) => {\n const value = getPropValue(props, media, 'transition');\n return typeof value === 'string'\n ? `transition: ${value}`\n : 'transition: all .2s';\n },\n 'boxShadow|shadow': {\n css: 'box-shadow',\n withTheme: true,\n },\n textShadow: {\n css: 'text-shadow',\n withTheme: true,\n },\n color: {\n css: 'color',\n withTheme: true,\n },\n fill: {\n css: 'fill',\n withTheme: true,\n },\n fontSize: {\n css: 'font-size',\n format: pixelate,\n },\n outline: {\n css: 'outline',\n withTheme: true,\n },\n};\n","import styled from 'styled-components';\nimport { colorMixin, sizeFormatter } from './utils';\n\nimport { divMixin, renderCss } from './Div';\n\nconst textRules = {\n weight: 'font-weight',\n size: {\n css: 'font-size',\n format: sizeFormatter,\n },\n color: {\n css: (props, media, extensions) => {\n const color = extensions.includes('hover')\n ? props.$color$hover\n : props.$color;\n\n return colorMixin(color, props.theme);\n },\n },\n tnum: 'font-feature-settings: \"tnum\";letter-spacing:-0.04em;',\n breakWord: 'word-break: break-word;',\n noBreak: 'white-space: nowrap;',\n uppercase: 'text-transform: uppercase;',\n serif: 'font-family: \"Times New Roman\", Times, serif',\n 'spacing|letterSpacing': `letter-spacing`,\n left: 'text-align: left;',\n right: 'text-align: right;',\n center: 'text-align: center;',\n lineThrough: 'text-decoration: line-through',\n // underline: 'text-decoration: underline;',\n linearGradient: props => `\n -webkit-text-fill-color: transparent;\n text-fill-color: transparent;\n -webkit-background-clip: text;\n background-clip: text;\n background-image: linear-gradient(${\n typeof props.$linearGradient === 'function'\n ? props.$linearGradient(props.theme)\n : props.$linearGradient\n });\n `,\n ellipsis: `\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 100%;\n `,\n underline: 'text-decoration: underline;',\n};\n\nconst Text = styled.p`\n ${props => divMixin(props)}\n ${props => renderCss(props, textRules)}\n`;\n\nexport default Text;\n","import { upperFirst } from './utils';\n\nconst { keys, entries, fromEntries } = Object;\n\nconst getDefaultWidth = () => {\n return typeof window !== 'undefined' && typeof document !== 'undefined'\n ? document.body.clientWidth\n : 0;\n};\n\nconst createBreakpoints = breakpoints => {\n return {\n getCssMedia: ({ min, max }) => {\n if (min && max) {\n return `@media (min-width: ${min}px) and (max-width: ${max}px)`;\n }\n\n if (min) {\n return `@media (min-width: ${min}px)`;\n }\n\n return `@media (max-width: ${max}px)`;\n },\n keys: keys(breakpoints),\n ...fromEntries(\n entries(breakpoints).map(([key, { min, max }]) => {\n return [upperFirst(key), { min, max }];\n }),\n ),\n ...fromEntries(\n entries(breakpoints).map(([key, { min = 0, max = Infinity }]) => {\n return [\n `is${upperFirst(key)}`,\n (width = getDefaultWidth()) =>\n width !== 0 && width >= min && width <= max,\n ];\n }),\n ),\n };\n};\n\nconst createSpacing = spacingUnit => (multiplier, adjuster = 0, usePx = true) =>\n (multiplier || 1) * spacingUnit + adjuster + (usePx ? 'px' : 0);\n\nfunction createUISystem({ theme, breakpoints, spacingUnit }) {\n const Breakpoints = createBreakpoints(breakpoints);\n\n return {\n theme: {\n ...theme,\n Breakpoints,\n spacing: createSpacing(spacingUnit),\n },\n Breakpoints,\n };\n}\n\nexport default createUISystem;\n","import Div, { divMixin } from './Div';\nimport Text from './Text';\nimport createUISystem from './createUISystem';\n\nexport default Div;\n\nexport { createUISystem, Div, divMixin, Text };\n"],"mappings":"AAAA,OAAOA,MAAY,oBCAnB,GAAM,CAAE,QAAAC,CAAQ,EAAI,OAEPC,EAAaC,GAAOA,EAAI,OAAO,CAAC,EAAE,YAAY,EAAIA,EAAI,MAAM,CAAC,EAE7DC,EAAY,CAACC,EAA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,CAAC,CACtC,CACH,EACA,GAAGL,EACDD,EAAQI,CAAW,EAAE,IAAI,CAAC,CAACG,EAAK,CAAE,IAAAF,EAAM,EAAG,IAAAC,EAAM,GAAS,CAAC,IAClD,CACL,KAAKE,EAAWD,CAAG,CAAC,GACpB,CAACE,EAAQP,EAAgB,IACvBO,IAAU,GAAKA,GAASJ,GAAOI,GAASH,CAC5C,CACD,CACH,CACF,GAGII,EAAgBC,GAAe,CAACC,EAAYC,EAAW,EAAGC,EAAQ,MACrEF,GAAc,GAAKD,EAAcE,GAAYC,EAAQ,KAAO,GAE/D,SAASC,GAAe,CAAE,MAAAC,EAAO,YAAAZ,EAAa,YAAAO,CAAY,EAAG,CAC3D,IAAMM,EAAcd,EAAkBC,CAAW,EAEjD,MAAO,CACL,MAAO,CACL,GAAGY,EACH,YAAAC,EACA,QAASP,EAAcC,CAAW,CACpC,EACA,YAAAM,CACF,CACF,CAEA,IAAOC,GAAQH,GCrDf,IAAOI,GAAQC","names":["styled","entries","upperFirst","str","kebabCase","string","x","spacing","val","theme","pixelate","getPropValue","props","media","propKeys","value","i","key","mediaVal","isPropPresent","ruleIndex","getRuleIndex","rules","index","ruleProp","config","prop","mediaPropRegex","getMediaPropRegex","colorMixin","color","sizeFormatter","fromEntries","cssWhiteList","prop","divRules","props","media","isPropPresent","getPropValue","pixelate","spacing","radius","rules","jsKey","cssKey","extensions","propValue","value","keys","renderCss","props","rules","css","ruleIndex","getRuleIndex","mediaPropRegex","getMediaPropRegex","i","propKeys","propExt","value","match","media","mediaPropExt","parts","prop","extensions","foundRule","cssWhiteList","kebabCase","config","outputValue","formattedValue","ruleCss","cssString","colons","upperFirst","divMixin","divRules","Div","styled","Div_default","styled","textRules","sizeFormatter","props","media","extensions","color","colorMixin","Text","styled","divMixin","renderCss","Text_default","keys","entries","fromEntries","getDefaultWidth","createBreakpoints","breakpoints","min","max","key","upperFirst","width","createSpacing","spacingUnit","multiplier","adjuster","usePx","createUISystem","theme","Breakpoints","createUISystem_default","index_default","Div_default"]}
@@ -0,0 +1 @@
1
+ {"inputs":{"src/utils.js":{"bytes":2145,"imports":[],"format":"esm"},"src/rules.js":{"bytes":8476,"imports":[{"path":"src/utils.js","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/Div.js":{"bytes":3564,"imports":[{"path":"styled-components","kind":"import-statement","external":true},{"path":"src/rules.js","kind":"import-statement","original":"./rules"},{"path":"src/utils.js","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/Text.js":{"bytes":1566,"imports":[{"path":"styled-components","kind":"import-statement","external":true},{"path":"src/utils.js","kind":"import-statement","original":"./utils"},{"path":"src/Div.js","kind":"import-statement","original":"./Div"}],"format":"esm"},"src/createUISystem.js":{"bytes":1443,"imports":[{"path":"src/utils.js","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/index.js":{"bytes":183,"imports":[{"path":"src/Div.js","kind":"import-statement","original":"./Div"},{"path":"src/Text.js","kind":"import-statement","original":"./Text"},{"path":"src/createUISystem.js","kind":"import-statement","original":"./createUISystem"}],"format":"esm"}},"outputs":{"dist/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":29018},"dist/index.cjs":{"imports":[{"path":"styled-components","kind":"import-statement","external":true},{"path":"styled-components","kind":"import-statement","external":true}],"exports":["Div","Text","createUISystem","default","divMixin"],"entryPoint":"src/index.js","inputs":{"src/Div.js":{"bytesInOutput":1159},"src/utils.js":{"bytesInOutput":963},"src/rules.js":{"bytesInOutput":5249},"src/Text.js":{"bytesInOutput":1053},"src/createUISystem.js":{"bytesInOutput":599},"src/index.js":{"bytesInOutput":9}},"bytes":9109}}}
@@ -0,0 +1 @@
1
+ {"inputs":{"src/utils.js":{"bytes":2145,"imports":[],"format":"esm"},"src/rules.js":{"bytes":8476,"imports":[{"path":"src/utils.js","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/Div.js":{"bytes":3564,"imports":[{"path":"styled-components","kind":"import-statement","external":true},{"path":"src/rules.js","kind":"import-statement","original":"./rules"},{"path":"src/utils.js","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/Text.js":{"bytes":1566,"imports":[{"path":"styled-components","kind":"import-statement","external":true},{"path":"src/utils.js","kind":"import-statement","original":"./utils"},{"path":"src/Div.js","kind":"import-statement","original":"./Div"}],"format":"esm"},"src/createUISystem.js":{"bytes":1443,"imports":[{"path":"src/utils.js","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/index.js":{"bytes":183,"imports":[{"path":"src/Div.js","kind":"import-statement","original":"./Div"},{"path":"src/Text.js","kind":"import-statement","original":"./Text"},{"path":"src/createUISystem.js","kind":"import-statement","original":"./createUISystem"}],"format":"esm"}},"outputs":{"dist/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":29018},"dist/index.mjs":{"imports":[{"path":"styled-components","kind":"import-statement","external":true},{"path":"styled-components","kind":"import-statement","external":true}],"exports":["Div","Text","createUISystem","default","divMixin"],"entryPoint":"src/index.js","inputs":{"src/Div.js":{"bytesInOutput":1159},"src/utils.js":{"bytesInOutput":963},"src/rules.js":{"bytesInOutput":5249},"src/Text.js":{"bytesInOutput":1053},"src/createUISystem.js":{"bytesInOutput":599},"src/index.js":{"bytesInOutput":9}},"bytes":9109}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamlinedfi/div",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Streamlined Div is a styled-components extension of the html div for building products with speed",
5
5
  "author": "Streamlined Finance",
6
6
  "repository": {
@@ -12,11 +12,34 @@
12
12
  "url": "https://github.com/streamlinedfi/div/issues"
13
13
  },
14
14
  "homepage": "https://github.com/streamlinedfi/div#readme",
15
- "main": "src/index.js",
15
+ "type": "module",
16
+ "main": "./dist/index.cjs",
17
+ "module": "./dist/index.mjs",
18
+ "exports": {
19
+ ".": {
20
+ "import": "./dist/index.mjs",
21
+ "require": "./dist/index.cjs"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "README.md",
27
+ "LICENSE",
28
+ "package.json"
29
+ ],
16
30
  "scripts": {
17
- "test": "echo \"Error: no test specified\" && exit 1"
31
+ "test": "echo \"Error: no test specified\" && exit 1",
32
+ "build": "tsup",
33
+ "dev": "tsup --watch",
34
+ "analyze": "npx esbuild-visualizer --metadata ./dist/metafile-esm.json"
18
35
  },
19
36
  "peerDependencies": {
37
+ "react": "^19.2.0",
38
+ "react-dom": "^19.2.0",
20
39
  "styled-components": "^6.1.19"
40
+ },
41
+ "devDependencies": {
42
+ "tsup": "^8.5.0",
43
+ "typescript": "^5.9.3"
21
44
  }
22
45
  }
package/src/Div.js DELETED
@@ -1,132 +0,0 @@
1
- import styled from 'styled-components';
2
- import { cssWhiteList, divRules } from './rules';
3
- import {
4
- getMediaPropRegex,
5
- getRuleIndex,
6
- kebabCase,
7
- upperFirst,
8
- } from './utils';
9
-
10
- const { keys } = Object;
11
-
12
- /**
13
- * @example
14
- * <Div
15
- * $w={690}
16
- * $h={420}
17
- * $mobile$w={320}
18
- * />
19
- */
20
-
21
- export function renderCss(props, rules) {
22
- let css = '';
23
-
24
- const ruleIndex = getRuleIndex(rules);
25
- const mediaPropRegex = getMediaPropRegex(props.theme);
26
-
27
- let i = -1;
28
- const propKeys = keys(props);
29
- while (++i < propKeys.length) {
30
- const propExt = propKeys[i];
31
-
32
- if (/^\$/.test(propExt)) {
33
- const value = props[propExt];
34
-
35
- if (value !== false) {
36
- const match = propExt.match(mediaPropRegex) || [];
37
- const [, media, mediaPropExt] = match;
38
-
39
- const cleanProp = (mediaPropExt || propExt).slice(1);
40
- const parts = cleanProp.split('$');
41
- const prop = parts[0];
42
- const extensions = parts.slice(1);
43
-
44
- const foundRule =
45
- ruleIndex[prop] || (cssWhiteList[prop] && kebabCase(prop));
46
-
47
- if (foundRule) {
48
- const config = foundRule;
49
- const outputValue =
50
- config.withTheme && typeof value === 'function'
51
- ? value(props.theme)
52
- : value;
53
- const formattedValue = config.format
54
- ? config.format(outputValue, props.theme)
55
- : outputValue;
56
-
57
- let ruleCss = '';
58
- if (typeof config === 'string') {
59
- ruleCss = config;
60
- } else if (typeof config === 'function') {
61
- ruleCss = config(props, media, extensions);
62
- } else if (typeof config.css === 'function') {
63
- ruleCss = config.css(props, media, extensions);
64
- } else {
65
- ruleCss = config.css;
66
- }
67
-
68
- let cssString = '';
69
- const colons = ruleCss.match(/:/g);
70
- if (colons && colons.length > 1) {
71
- cssString = ruleCss;
72
- } else if (colons === null) {
73
- cssString = `${ruleCss}: ${formattedValue};`;
74
- } else {
75
- cssString = `${ruleCss.replace(/;$/, '')};`;
76
- }
77
-
78
- if (extensions.includes('important')) {
79
- cssString = cssString.replace(/;/g, ' !important;');
80
- }
81
-
82
- if (extensions.includes('hover') && !extensions.includes('focus')) {
83
- cssString = `&:hover,&:focus { ${cssString} }`;
84
- }
85
-
86
- if (extensions.includes('hover') && extensions.includes('focus')) {
87
- cssString = `&:hover { ${cssString} }`;
88
- }
89
-
90
- if (extensions.includes('focus')) {
91
- cssString = `&:focus { ${cssString} }`;
92
- }
93
-
94
- if (extensions.includes('active')) {
95
- cssString = `&:active { ${cssString} }`;
96
- }
97
-
98
- if (extensions.includes('last')) {
99
- cssString = `&:last-child { ${cssString} }`;
100
- }
101
-
102
- if (extensions.includes('odd')) {
103
- cssString = `&:nth-child(odd) { ${cssString} }`;
104
- }
105
-
106
- if (extensions.includes('even')) {
107
- cssString = `&:nth-child(even) { ${cssString} }`;
108
- }
109
-
110
- if (media) {
111
- const cssMedia = props.theme.Breakpoints.getCssMedia(
112
- props.theme.Breakpoints[upperFirst(media)],
113
- );
114
- cssString = `${cssMedia} { ${cssString} }`;
115
- }
116
-
117
- css += cssString;
118
- }
119
- }
120
- }
121
- }
122
-
123
- return css;
124
- }
125
-
126
- export const divMixin = props => renderCss(props, divRules);
127
-
128
- const Div = styled.div`
129
- ${props => divMixin(props)}
130
- `;
131
-
132
- export default Div;
package/src/Text.js DELETED
@@ -1,58 +0,0 @@
1
- import isFunction from 'lodash/isFunction';
2
- import styled from 'styled-components';
3
- import { colorMixin, sizeFormatter } from './utils';
4
-
5
- import { divMixin, renderCss } from './Div';
6
-
7
- const textRules = {
8
- weight: 'font-weight',
9
- size: {
10
- css: 'font-size',
11
- format: sizeFormatter,
12
- },
13
- color: {
14
- css: (props, media, extensions) => {
15
- const color = extensions.includes('hover')
16
- ? props.$color$hover
17
- : props.$color;
18
-
19
- return colorMixin(color, props.theme);
20
- },
21
- },
22
- tnum: 'font-feature-settings: "tnum";letter-spacing:-0.04em;',
23
- breakWord: 'word-break: break-word;',
24
- noBreak: 'white-space: nowrap;',
25
- uppercase: 'text-transform: uppercase;',
26
- serif: 'font-family: "Times New Roman", Times, serif',
27
- 'spacing|letterSpacing': `letter-spacing`,
28
- left: 'text-align: left;',
29
- right: 'text-align: right;',
30
- center: 'text-align: center;',
31
- lineThrough: 'text-decoration: line-through',
32
- // underline: 'text-decoration: underline;',
33
- linearGradient: props => `
34
- -webkit-text-fill-color: transparent;
35
- text-fill-color: transparent;
36
- -webkit-background-clip: text;
37
- background-clip: text;
38
- background-image: linear-gradient(${
39
- isFunction(props.$linearGradient)
40
- ? props.$linearGradient(props.theme)
41
- : props.$linearGradient
42
- });
43
- `,
44
- ellipsis: `
45
- white-space: nowrap;
46
- overflow: hidden;
47
- text-overflow: ellipsis;
48
- max-width: 100%;
49
- `,
50
- underline: 'text-decoration: underline;',
51
- };
52
-
53
- const Text = styled.p`
54
- ${props => divMixin(props)}
55
- ${props => renderCss(props, textRules)}
56
- `;
57
-
58
- export default Text;
@@ -1,58 +0,0 @@
1
- import { upperFirst } from './utils';
2
-
3
- const { keys, entries, fromEntries } = Object;
4
-
5
- const getDefaultWidth = () => {
6
- return typeof window !== 'undefined' && typeof document !== 'undefined'
7
- ? document.body.clientWidth
8
- : 0;
9
- };
10
-
11
- const createBreakpoints = breakpoints => {
12
- return {
13
- getCssMedia: ({ min, max }) => {
14
- if (min && max) {
15
- return `@media (min-width: ${min}px) and (max-width: ${max}px)`;
16
- }
17
-
18
- if (min) {
19
- return `@media (min-width: ${min}px)`;
20
- }
21
-
22
- return `@media (max-width: ${max}px)`;
23
- },
24
- keys: keys(breakpoints),
25
- ...fromEntries(
26
- entries(breakpoints).map(([key, { min, max }]) => {
27
- return [upperFirst(key), { min, max }];
28
- }),
29
- ),
30
- ...fromEntries(
31
- entries(breakpoints).map(([key, { min = 0, max = Infinity }]) => {
32
- return [
33
- `is${upperFirst(key)}`,
34
- (width = getDefaultWidth()) =>
35
- width !== 0 && width >= min && width <= max,
36
- ];
37
- }),
38
- ),
39
- };
40
- };
41
-
42
- const createSpacing = spacingUnit => (multiplier, adjuster = 0, usePx = true) =>
43
- (multiplier || 1) * spacingUnit + adjuster + (usePx ? 'px' : 0);
44
-
45
- function createUISystem({ theme, breakpoints, spacingUnit }) {
46
- const Breakpoints = createBreakpoints(breakpoints);
47
-
48
- return {
49
- theme: {
50
- ...theme,
51
- Breakpoints,
52
- spacing: createSpacing(spacingUnit),
53
- },
54
- Breakpoints,
55
- };
56
- }
57
-
58
- export default createUISystem;
package/src/index.js DELETED
@@ -1,7 +0,0 @@
1
- import Div, { divMixin } from './Div';
2
- import Text from './Text';
3
- import createUISystem from './createUISystem';
4
-
5
- export default Div;
6
-
7
- export { createUISystem, Div, divMixin, Text };