@prop-styles/core
Advanced tools
Comparing version 0.0.4 to 0.0.5
/*! | ||
* @prop-styles/core version 0.0.4 | ||
* @prop-styles/core version 0.0.5 | ||
* Author: Capricorncd<capricorncd@qq.com> | ||
* Homepage: https://github.com/capricorncd/prop-styles#readme | ||
* Released on: 2024-04-25 23:05:37 (GMT+0900) | ||
* Released on: 2024-04-25 23:13:06 (GMT+0900) | ||
*/ | ||
@@ -20,8 +20,8 @@ /*! | ||
function f(n) { | ||
return typeof n == "string" ? /^-?\d+(\.\d+)?$/.test(n) : c(n); | ||
return typeof n == "string" ? /^-?\d+(\.\d+)?$/.test(n) : p(n); | ||
} | ||
function c(n) { | ||
function p(n) { | ||
return Number.isFinite(n); | ||
} | ||
function p(n) { | ||
function u(n) { | ||
return typeof n > "u" || n === null; | ||
@@ -48,5 +48,5 @@ } | ||
} | ||
const R = /^(#[a-f0-9]{3,8}|(rgba?|hsla?|hwb|lab|lch|oklab|oklch|hwb|lch|light-dark)\(.+\))$/i; | ||
function k(n) { | ||
return typeof n != "string" ? !1 : R.test(n); | ||
const w = /^(#[a-f0-9]{3,8}|(rgba?|hsla?|hwb|lab|lch|oklab|oklch|hwb|lch|light-dark)\(.+\))$/i; | ||
function S(n) { | ||
return typeof n != "string" ? !1 : w.test(n); | ||
} | ||
@@ -59,3 +59,3 @@ function r(n, t, i) { | ||
} | ||
function S(n) { | ||
function R(n) { | ||
return g( | ||
@@ -66,3 +66,3 @@ n, | ||
} | ||
function C(n) { | ||
function k(n) { | ||
return g( | ||
@@ -73,3 +73,3 @@ n, | ||
} | ||
function w(n) { | ||
function C(n) { | ||
return g(n, (t, i) => [t, i]); | ||
@@ -82,3 +82,3 @@ } | ||
function I(n) { | ||
return p(n) ? null : f(n) || B(n) ? ["borderWidth", o(n)] : k(n) ? ["borderColor", n] : ["border", String(n)]; | ||
return u(n) ? null : f(n) || B(n) ? ["borderWidth", o(n)] : S(n) ? ["borderColor", n] : ["border", String(n)]; | ||
} | ||
@@ -91,4 +91,4 @@ function L(n, t, i) { | ||
if (s) { | ||
const [d, u] = s; | ||
i[d] = u; | ||
const [d, c] = s; | ||
i[d] = c; | ||
} | ||
@@ -159,7 +159,7 @@ } | ||
// display | ||
...S($), | ||
...R($), | ||
// overflow | ||
scroll: (n) => n ? [`overflow${typeof n == "string" ? n.toUpperCase() : ""}`, "auto"] : null, | ||
...C(W), | ||
...w(_), | ||
...k(W), | ||
...C(_), | ||
// border | ||
@@ -169,3 +169,5 @@ border: (n) => I(n), | ||
tempColumns: (n) => r("gridTemplateColumns", o(n, "fr")), | ||
tempRows: (n) => r("gridTemplateRows", o(n, "fr")) | ||
tempRows: (n) => r("gridTemplateRows", o(n, "fr")), | ||
whiteSpace: (n) => r("whiteSpace", n), | ||
nowrap: (n) => r("whiteSpace", n, "nowrap") | ||
}; | ||
@@ -172,0 +174,0 @@ for (const [n, t] of Object.entries(P)) |
/*! | ||
* @prop-styles/core version 0.0.4 | ||
* @prop-styles/core version 0.0.5 | ||
* Author: Capricorncd<capricorncd@qq.com> | ||
* Homepage: https://github.com/capricorncd/prop-styles#readme | ||
* Released on: 2024-04-25 23:05:37 (GMT+0900) | ||
* Released on: 2024-04-25 23:13:06 (GMT+0900) | ||
*/ | ||
(function(o,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(o=typeof globalThis<"u"?globalThis:o||self,s(o["prop-styles-core"]={}))})(this,function(o){"use strict";/*! | ||
(function(o,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(o=typeof globalThis<"u"?globalThis:o||self,a(o["prop-styles-core"]={}))})(this,function(o){"use strict";/*! | ||
* @zx-libs/utils version 0.0.4 | ||
@@ -17,2 +17,2 @@ * Author: Capricorncd<capricorncd@qq.com> | ||
* Released on: 2024/04/02 21:28:40 GMT+0900 | ||
*/function s(n){return typeof n=="string"?/^-?\d+(\.\d+)?$/.test(n):u(n)}function u(n){return Number.isFinite(n)}function c(n){return typeof n>"u"||n===null}const p=/^((-?\d+(\.\d+)?)?([a-z]+|%)?\s*)+$/i,m=/(\d+\s|\s\d+$)/;function l(n,t="px"){if(s(n))return`${n}${t}`;if(n&&typeof n=="string"){const e=n.trim().replace(/\s{2,}/g," ");return p.test(e)&&m.test(e)?e.trim().split(" ").map(r=>l(r,t)).join(" "):e}return""}function h(n="",t="-"){return n.replace(/[A-Z]/g,(e,r)=>`${r>0?t:""}${e.toLowerCase()}`)}function b(n){return typeof n=="boolean"}const y=/^(#[a-f0-9]{3,8}|(rgba?|hsla?|hwb|lab|lch|oklab|oklch|hwb|lch|light-dark)\(.+\))$/i;function S(n){return typeof n!="string"?!1:y.test(n)}function i(n,t,e){return!t&&t!==0?null:[n,e??String(t)]}function d(n,t){return n.reduce((e,r)=>(e[r]=f=>t(r,f),e),{})}function R(n){return d(n,(t,e)=>i("display",e,h(t)))}function P(n){return d(n,(t,e)=>i(t,e,l(e)))}function k(n){return d(n,(t,e)=>[t,e])}const C=/^-?\d+(\.\d+)?[a-z]+$/i;function w(n){return typeof n=="string"&&C.test(n)}function I(n){return c(n)?null:s(n)||w(n)?["borderWidth",l(n)]:S(n)?["borderColor",n]:["border",String(n)]}function L(n,t,e){let r;for(const f of Object.keys(n))if(r=t[f],r){const g=r(n[f],n);if(g){const[O,T]=g;e[O]=T}}}const _={p:"padding",pt:"paddingTop",pb:"paddingBottom",pl:"paddingLeft",pr:"paddingRight",px:"paddingInline",py:"paddingBlock",m:"margin",mt:"marginTop",mb:"marginBottom",ml:"marginLeft",mr:"marginRight",mx:"marginInline",my:"marginBlock",fs:"fontSize",lh:"lineHeight",bg:"background",fw:"fontWeight"},x=["width","minWidth","maxWidth","height","minHeight","maxHeight","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","paddingInline","paddingBlock","margin","marginTop","marginBottom","marginLeft","marginRight","marginInline","marginBlock","gap","fontSize","lineHeight"],B=["background","color"],a={radius:n=>i("borderRadius",n,l(n)),align:n=>i("alignItems",n),alignContent:n=>i("alignContent",n),justify:n=>i("justifyContent",n),justifyItems:n=>i("justifyItems",n),column:n=>i("flexDirection",n,"column"),wrap:n=>n?["flexWrap",b(n)?"wrap":n]:null,breakWord:n=>i("overflowWrap",n,"break-word"),bold:n=>i("fontWeight",n,"bold"),thin:n=>i("fontWeight",n,"500"),...R(["flex","grid","inline","inlineFlex","inlineBlock"]),scroll:n=>n?[`overflow${typeof n=="string"?n.toUpperCase():""}`,"auto"]:null,...P(x),...k(B),border:n=>I(n),fontWeight:n=>i("fontWeight",n),tempColumns:n=>i("gridTemplateColumns",l(n,"fr")),tempRows:n=>i("gridTemplateRows",l(n,"fr"))};for(const[n,t]of Object.entries(_))if(a[t])a[n]=a[t];else throw new Error(`The alias of ${n} does not exist`);function E(n,t){const e={...n.style},r={...a,...t};return L(n,r,e),e}o.createPropStyles=E,o.formatReturn=i,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}); | ||
*/function a(n){return typeof n=="string"?/^-?\d+(\.\d+)?$/.test(n):u(n)}function u(n){return Number.isFinite(n)}function c(n){return typeof n>"u"||n===null}const p=/^((-?\d+(\.\d+)?)?([a-z]+|%)?\s*)+$/i,m=/(\d+\s|\s\d+$)/;function s(n,t="px"){if(a(n))return`${n}${t}`;if(n&&typeof n=="string"){const e=n.trim().replace(/\s{2,}/g," ");return p.test(e)&&m.test(e)?e.trim().split(" ").map(r=>s(r,t)).join(" "):e}return""}function h(n="",t="-"){return n.replace(/[A-Z]/g,(e,r)=>`${r>0?t:""}${e.toLowerCase()}`)}function b(n){return typeof n=="boolean"}const y=/^(#[a-f0-9]{3,8}|(rgba?|hsla?|hwb|lab|lch|oklab|oklch|hwb|lch|light-dark)\(.+\))$/i;function S(n){return typeof n!="string"?!1:y.test(n)}function i(n,t,e){return!t&&t!==0?null:[n,e??String(t)]}function d(n,t){return n.reduce((e,r)=>(e[r]=f=>t(r,f),e),{})}function w(n){return d(n,(t,e)=>i("display",e,h(t)))}function R(n){return d(n,(t,e)=>i(t,e,s(e)))}function P(n){return d(n,(t,e)=>[t,e])}const k=/^-?\d+(\.\d+)?[a-z]+$/i;function C(n){return typeof n=="string"&&k.test(n)}function I(n){return c(n)?null:a(n)||C(n)?["borderWidth",s(n)]:S(n)?["borderColor",n]:["border",String(n)]}function L(n,t,e){let r;for(const f of Object.keys(n))if(r=t[f],r){const g=r(n[f],n);if(g){const[O,T]=g;e[O]=T}}}const _={p:"padding",pt:"paddingTop",pb:"paddingBottom",pl:"paddingLeft",pr:"paddingRight",px:"paddingInline",py:"paddingBlock",m:"margin",mt:"marginTop",mb:"marginBottom",ml:"marginLeft",mr:"marginRight",mx:"marginInline",my:"marginBlock",fs:"fontSize",lh:"lineHeight",bg:"background",fw:"fontWeight"},x=["width","minWidth","maxWidth","height","minHeight","maxHeight","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","paddingInline","paddingBlock","margin","marginTop","marginBottom","marginLeft","marginRight","marginInline","marginBlock","gap","fontSize","lineHeight"],B=["background","color"],l={radius:n=>i("borderRadius",n,s(n)),align:n=>i("alignItems",n),alignContent:n=>i("alignContent",n),justify:n=>i("justifyContent",n),justifyItems:n=>i("justifyItems",n),column:n=>i("flexDirection",n,"column"),wrap:n=>n?["flexWrap",b(n)?"wrap":n]:null,breakWord:n=>i("overflowWrap",n,"break-word"),bold:n=>i("fontWeight",n,"bold"),thin:n=>i("fontWeight",n,"500"),...w(["flex","grid","inline","inlineFlex","inlineBlock"]),scroll:n=>n?[`overflow${typeof n=="string"?n.toUpperCase():""}`,"auto"]:null,...R(x),...P(B),border:n=>I(n),fontWeight:n=>i("fontWeight",n),tempColumns:n=>i("gridTemplateColumns",s(n,"fr")),tempRows:n=>i("gridTemplateRows",s(n,"fr")),whiteSpace:n=>i("whiteSpace",n),nowrap:n=>i("whiteSpace",n,"nowrap")};for(const[n,t]of Object.entries(_))if(l[t])l[n]=l[t];else throw new Error(`The alias of ${n} does not exist`);function E(n,t){const e={...n.style},r={...l,...t};return L(n,r,e),e}o.createPropStyles=E,o.formatReturn=i,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}); |
@@ -43,2 +43,6 @@ /** | ||
wrap?: boolean | Property.FlexWrap | ||
// white-space: nowrap | ||
nowrap?: boolean | ||
// white-space | ||
whiteSpace?: Property.WhiteSpace | ||
// padding | ||
@@ -45,0 +49,0 @@ padding?: number | string |
{ | ||
"name": "@prop-styles/core", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "The library provides a static method createPropStyles to create Style objects.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.ts", |
@@ -111,2 +111,4 @@ # @prop-styles/core | ||
wrap|`boolean`/`Property.FlexWrap`|no|flex-wrap | ||
nowrap|`boolean`|no|white-space: nowrap | ||
whiteSpace|`Property.WhiteSpace`|no|white-space | ||
padding|`number`/`string`|no|padding | ||
@@ -198,2 +200,6 @@ p|`number`/`string`|no|padding | ||
wrap?: boolean | Property.FlexWrap | ||
// white-space: nowrap | ||
nowrap?: boolean | ||
// white-space | ||
whiteSpace?: Property.WhiteSpace | ||
// padding | ||
@@ -200,0 +206,0 @@ padding?: number | string |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21398
347
340