@tenoxui/moxie 0.4.3 → 0.4.4
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.js +1 -1
- package/dist/index.es.js +105 -102
- package/dist/index.iife.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -2
package/dist/index.cjs.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var Z=Object.defineProperty;var W=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var V=(
|
1
|
+
"use strict";var Z=Object.defineProperty;var W=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var V=(A,t,e)=>t in A?Z(A,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):A[t]=e,S=(A,t)=>{for(var e in t||(t={}))_.call(t,e)&&V(A,e,t[e]);if(W)for(var e of W(t))j.call(t,e)&&V(A,e,t[e]);return A};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class v{constructor({property:t={},values:e={},classes:s={},alwaysUseHyphens:n=!0}={}){this.property=S({moxie:({key:r,secondValue:l})=>l?null:r},t),this.values=e,this.classes=s,this.useHyphens=n}toKebabCase(t){if(/^(webkit|moz|ms|o)[A-Z]/.test(t)){const e=t.match(/^(webkit|moz|ms|o)/);if(e){const s=e[0];return`-${s}${t.slice(s.length).replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}`}}return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}escapeCSSSelector(t){return t.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(t){if(!t)return[];const e=new Set;return Object.entries(t).forEach(([s,n])=>{n&&typeof n=="object"&&Object.keys(n).forEach(r=>{e.add(r)})}),Array.from(e)}getTypePrefixes(t=[]){const e=this.property,s=this.classes,n=Object.keys(e);if(!s)return[...n,...t].sort((a,i)=>i.length-a.length);const l=[...this.getAllClassNames(s)];return[...n,...l,...t].sort((a,i)=>i.length-a.length)}regexp(t){const e=this.getTypePrefixes(t).join("|"),s="\\[[^\\]]+\\]",n="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",l="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+s+"|"+n+"|"+r+"))|"+s+"|"+n+"|"+r,a=`(${e}|\\[[^\\]]+\\])`,i=this.useHyphens?"(?:-)":"(?:-)?",h="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))",y="([a-zA-Z%]*)",c="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:l,type:a,separator:i,value:h,unit:y,secondValuePattern:c,all:"(?:("+l+"):)?"+a+i+h+y+c}}generateClassNameRegEx(t=[]){return new RegExp(this.regexp(t).all)}parse(t,e){if(Object.values(this.classes).some(o=>o==null?void 0:o[t]))return[void 0,t,"","",void 0,void 0,t];const s=this.generateClassNameRegEx(e),n=(t+"-dummy").match(s);if(!n)return null;const[,r,l,a,i,h,y]=n,c=a?a==="dummy"?"":a.replace("-dummy",""):"",f=h?h==="dummy"?"":h.replace("-dummy",""):"";return[r,l,c,i||"",f,y,t]}processValue(t,e,s){if(!t)return"";const n=r=>r.replace(/\{([^}]+)\}/g,(l,a)=>{const i=this.values,h=i!==null?typeof i[s]=="object"?i[s][a]:i[a]:void 0;return typeof h=="string"?h:l});if(typeof this.values=="object"&&this.values!==null&&(this.values[s]&&typeof this.values[s]=="object"&&this.values[s][t]||this.values[t]))return typeof this.values[s]=="object"&&this.values[s]!==null?this.values[s][t]:this.values[t];if(t.startsWith("$"))return`var(--${t.slice(1)})`;if(t.startsWith("[")&&t.endsWith("]")||t.startsWith("(")&&t.endsWith(")")){const r=t.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?n(r):r.startsWith("--")?`var(${r})`:r}return t+(e||"")}processShorthand(t="",e="",s="",n,r="",l="",a=!0){const i=this.property[t],h=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let y=null,c=e||"";const f=c.match(h);f&&(y=f[1].trim(),c=f[2].trim());let o;e.includes(y+":")?o=e.startsWith("(")?`(${c})`:`[${c}]`:o=e;const p=this.processValue(o,s,t),g=this.processValue(r,l,t);if(t.startsWith("[")&&t.endsWith("]")){const C=t.slice(1,-1).split(",").map(u=>u.trim()).map(u=>`${u?u.startsWith("--")?String(u):this.toKebabCase(String(u)):null}: ${p}`).join("; ");return{className:`${`[${t.slice(1,-1)}]${a?"-":""}${e}${s}`}`,cssRules:C,value:null,prefix:n}}if(i){if(typeof i=="object"&&"property"in i){const C=i.group&&this.values[i.group][p]?this.values[i.group][p]:s?e:p,u=typeof i.property=="function"?i.property({value:e.startsWith("[")?p:C,unit:e.startsWith("[")?"":s,secondValue:e.startsWith("[")?"":l?r:g,secondUnit:e.startsWith("[")?"":l,key:y}):i.property,m=i.value||"{0}";let b;if(typeof m=="function")b=m({value:C,unit:s,secondValue:l?r:g,secondUnit:l,key:y});else if(typeof m=="string"){const d=i.group||t,P=this.processValue(o,s,d);this.values[d]&&typeof this.values[d]=="object"&&this.values[d][o]?b=this.values[d][o]:m.includes("{")?b=this.parseValuePattern(d,m,P,"",g,""):b=p}else b=null;const x=`${t}${e?`${a&&a?"-":""}${e}${s}`:""}${r?`/${r}${l}`:""}`;return typeof i.property=="string"&&typeof m=="string"&&!m.includes("{1")&&r?null:{className:x,cssRules:u?Array.isArray(u)?u:typeof u=="string"&&(u.includes(":")||u.includes("value:"))?u.includes("value:")?u.slice(6):this.toKebabCase(String(u)):this.toKebabCase(String(u)):null,value:m===null||u===null||u.includes(":")||u.includes("value:")?null:e.startsWith("[")?p:b,prefix:n}}const $=typeof i=="function"?i({value:e.startsWith("[")?p:s?e:p,unit:e.startsWith("[")?"":s,secondValue:e.startsWith("[")?"":l?r:g,secondUnit:e.startsWith("[")?"":l,key:y}):i;return(typeof i=="string"||Array.isArray(i))&&r?null:{className:`${t}${e?(a?"-":"")+e+s:""}${r?`/${r}${l}`:""}`,cssRules:$?Array.isArray(i)?$:typeof $=="string"&&($.includes(":")||$.startsWith("value:"))?$.startsWith("value:")?$.slice(6):this.toKebabCase(String($)):this.toKebabCase(String($)):null,value:typeof $=="string"&&$.includes(":")?null:p,prefix:n}}return null}parseValuePattern(t,e,s,n,r,l){if(!e.includes("{0}")&&!e.includes("{1")&&!e.includes("||"))return e;const[a,i]=e.split("||").map(c=>c.trim()),h=this.processValue(s,n,t),y=this.processValue(r,l,t);if(e.includes("{0}")&&e.includes("{1")||e.includes("{1")){let c=a;if(s&&(c=c.replace("{0}",h)),e.includes("{1")){const f=c.match(/{1([^}]*)}/);if(e.includes("{1}"))r?c=r.startsWith("[")?y:c.replace("{1}",y):c=i;else if(f){const o=f[0],p=f[1].trim();let g=y;!g&&p.includes("|")?g=p.split("|")[1].trim():g||(g=""),c=s.startsWith("[")?h:c.replace(o,g)}}return s?c:i||a}else return s?s.startsWith("[")?h:a.replace("{0}",h):i||a}getParentClass(t){return Object.keys(this.classes).filter(e=>Object.prototype.hasOwnProperty.call(this.classes[e],t))}processCustomClass(t,e="",s="",n="",r="",l="",a=!0){if(!t)return null;const i=this.getParentClass(t);if(i.length>0){const h=i.map(f=>{const o=this.classes[f];if(!o||e&&!o[t].includes("||")||e&&!o[t].includes("|"))return"";const p=this.parseValuePattern(t,o[t]||"",e,s,r,l);return`${this.toKebabCase(String(f))}: ${p}`}).filter(Boolean).join("; "),y=t.slice(-(e+s).length),c=`${t}${e?`${a?"-":""}${e}${s}`:""}${r?`/${r}${l}`:""}`;return{className:e===y?t:c,cssRules:h,value:null,prefix:n}}return null}process(t){const e=Array.isArray(t)?t:t.split(/\s+/),s=[];return e.forEach(n=>{if(!n)return this;const[r,l]=n.split(":"),a=l||r,i=l?r:void 0,h=this.parse(n),y=h||[i,a,"",""];if(!y)return this;const[c,f,o,p,g,$]=y,C=!n.includes((f||"")+(o||"")),u=this.getParentClass(`${f}${C?"-":""}${o}`).length>0?`${f}${C?"-":""}${o}`:f,m=this.processCustomClass(u,o,p,c,g,$,C);if(m){const{className:x,cssRules:d,prefix:P}=m;if(!d||d==="null")return;s.push({className:x,cssRules:d,value:null,prefix:P,raw:[P,f,o,p,g,$]});return}const b=this.processShorthand(f,o,p,c,g,$,C);if(b){const{className:x,cssRules:d,value:P,prefix:R}=b;if(!d||d==="null")return;s.push({className:x,cssRules:d,value:P,prefix:R,raw:[c,f,o,p,g,$]})}}),s}}exports.TenoxUI=v;exports.default=v;
|
package/dist/index.es.js
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
-
var
|
2
|
-
var
|
1
|
+
var R = Object.defineProperty;
|
2
|
+
var W = Object.getOwnPropertySymbols;
|
3
3
|
var Z = Object.prototype.hasOwnProperty, z = Object.prototype.propertyIsEnumerable;
|
4
|
-
var V = (
|
4
|
+
var V = (x, t, s) => t in x ? R(x, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : x[t] = s, S = (x, t) => {
|
5
5
|
for (var s in t || (t = {}))
|
6
|
-
Z.call(t, s) && V(
|
7
|
-
if (
|
8
|
-
for (var s of
|
9
|
-
z.call(t, s) && V(
|
10
|
-
return
|
6
|
+
Z.call(t, s) && V(x, s, t[s]);
|
7
|
+
if (W)
|
8
|
+
for (var s of W(t))
|
9
|
+
z.call(t, s) && V(x, s, t[s]);
|
10
|
+
return x;
|
11
11
|
};
|
12
12
|
class _ {
|
13
13
|
constructor({ property: t = {}, values: s = {}, classes: e = {}, alwaysUseHyphens: n = !0 } = {}) {
|
14
|
-
this.property =
|
15
|
-
moxie
|
14
|
+
this.property = S({
|
15
|
+
// use moxie-* to access all properties and variables
|
16
|
+
// e.g. `moxie-(color:red)` => `color: red`, `moxie-(--my-var:20px_1rem)` => `--my-var: 20px 1rem`
|
17
|
+
moxie: ({ key: r, secondValue: l }) => l ? null : r
|
16
18
|
}, t), this.values = s, this.classes = e, this.useHyphens = n;
|
17
19
|
}
|
18
20
|
toKebabCase(t) {
|
@@ -26,7 +28,7 @@ class _ {
|
|
26
28
|
return t.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
|
27
29
|
}
|
28
30
|
escapeCSSSelector(t) {
|
29
|
-
return t.replace(/([
|
31
|
+
return t.replace(/^(\d)/, "\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g, "\\$1");
|
30
32
|
}
|
31
33
|
getAllClassNames(t) {
|
32
34
|
if (!t) return [];
|
@@ -40,27 +42,27 @@ class _ {
|
|
40
42
|
getTypePrefixes(t = []) {
|
41
43
|
const s = this.property, e = this.classes, n = Object.keys(s);
|
42
44
|
if (!e)
|
43
|
-
return [...n, ...t].sort((
|
44
|
-
const
|
45
|
-
return [...n, ...
|
45
|
+
return [...n, ...t].sort((a, i) => i.length - a.length);
|
46
|
+
const l = [...this.getAllClassNames(e)];
|
47
|
+
return [...n, ...l, ...t].sort((a, i) => i.length - a.length);
|
46
48
|
}
|
47
49
|
regexp(t) {
|
48
|
-
const s = this.getTypePrefixes(t).join("|"), e = "\\[[^\\]]+\\]", n = "\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)", r = "\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",
|
50
|
+
const s = this.getTypePrefixes(t).join("|"), e = "\\[[^\\]]+\\]", n = "\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)", r = "\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}", l = (
|
49
51
|
// Simple prefix (hover, md, focus, etc.)
|
50
52
|
"[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:" + e + "|" + n + "|" + r + "))|" + // Direct bracket, parenthesis, or brace content
|
51
53
|
e + "|" + n + "|" + r
|
52
|
-
),
|
54
|
+
), a = `(${s}|\\[[^\\]]+\\])`, i = this.useHyphens ? "(?:-)" : "(?:-)?", h = "(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + // Hex colors
|
53
55
|
e + "|" + // Bracket content
|
54
56
|
r + "|" + // Curly brace content
|
55
|
-
n + "|(?:\\$[^\\s\\/]+))",
|
57
|
+
n + "|(?:\\$[^\\s\\/]+))", y = "([a-zA-Z%]*)", c = "(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + e + "|" + r + "|" + n + "|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";
|
56
58
|
return {
|
57
|
-
prefix:
|
58
|
-
type:
|
59
|
+
prefix: l,
|
60
|
+
type: a,
|
59
61
|
separator: i,
|
60
|
-
value:
|
61
|
-
unit:
|
62
|
+
value: h,
|
63
|
+
unit: y,
|
62
64
|
secondValuePattern: c,
|
63
|
-
all: "(?:(" +
|
65
|
+
all: "(?:(" + l + "):)?" + a + i + h + y + c
|
64
66
|
};
|
65
67
|
}
|
66
68
|
generateClassNameRegEx(t = []) {
|
@@ -71,15 +73,15 @@ class _ {
|
|
71
73
|
return [void 0, t, "", "", void 0, void 0, t];
|
72
74
|
const e = this.generateClassNameRegEx(s), n = (t + "-dummy").match(e);
|
73
75
|
if (!n) return null;
|
74
|
-
const [, r,
|
75
|
-
return [r,
|
76
|
+
const [, r, l, a, i, h, y] = n, c = a ? a === "dummy" ? "" : a.replace("-dummy", "") : "", f = h ? h === "dummy" ? "" : h.replace("-dummy", "") : "";
|
77
|
+
return [r, l, c, i || "", f, y, t];
|
76
78
|
}
|
77
79
|
// unique value parser
|
78
80
|
processValue(t, s, e) {
|
79
81
|
if (!t) return "";
|
80
|
-
const n = (r) => r.replace(/\{([^}]+)\}/g, (
|
81
|
-
const i = this.values,
|
82
|
-
return typeof
|
82
|
+
const n = (r) => r.replace(/\{([^}]+)\}/g, (l, a) => {
|
83
|
+
const i = this.values, h = i !== null ? typeof i[e] == "object" ? i[e][a] : i[a] : void 0;
|
84
|
+
return typeof h == "string" ? h : l;
|
83
85
|
});
|
84
86
|
if (typeof this.values == "object" && this.values !== null && (this.values[e] && typeof this.values[e] == "object" && this.values[e][t] || this.values[t]))
|
85
87
|
return typeof this.values[e] == "object" && this.values[e] !== null ? this.values[e][t] : this.values[t];
|
@@ -91,18 +93,18 @@ class _ {
|
|
91
93
|
}
|
92
94
|
return t + (s || "");
|
93
95
|
}
|
94
|
-
processShorthand(t = "", s = "", e = "", n, r = "",
|
95
|
-
const i = this.property[t],
|
96
|
-
let
|
97
|
-
const f = c.match(
|
98
|
-
f && (
|
96
|
+
processShorthand(t = "", s = "", e = "", n, r = "", l = "", a = !0) {
|
97
|
+
const i = this.property[t], h = /^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;
|
98
|
+
let y = null, c = s || "";
|
99
|
+
const f = c.match(h);
|
100
|
+
f && (y = f[1].trim(), c = f[2].trim());
|
99
101
|
let o;
|
100
|
-
s.includes(
|
101
|
-
const p = this.processValue(o, e, t), g = this.processValue(r,
|
102
|
+
s.includes(y + ":") ? o = s.startsWith("(") ? `(${c})` : `[${c}]` : o = s;
|
103
|
+
const p = this.processValue(o, e, t), g = this.processValue(r, l, t);
|
102
104
|
if (t.startsWith("[") && t.endsWith("]")) {
|
103
|
-
const C = t.slice(1, -1).split(",").map((
|
105
|
+
const C = t.slice(1, -1).split(",").map((u) => u.trim()).map((u) => `${u ? u.startsWith("--") ? String(u) : this.toKebabCase(String(u)) : null}: ${p}`).join("; ");
|
104
106
|
return {
|
105
|
-
className: `${`[${t.slice(1, -1)}]${
|
107
|
+
className: `${`[${t.slice(1, -1)}]${a ? "-" : ""}${s}${e}`}`,
|
106
108
|
cssRules: C,
|
107
109
|
// return css rules directly
|
108
110
|
value: null,
|
@@ -112,75 +114,76 @@ class _ {
|
|
112
114
|
}
|
113
115
|
if (i) {
|
114
116
|
if (typeof i == "object" && "property" in i) {
|
115
|
-
const C = i.group && this.values[i.group][p] ? this.values[i.group][p] : e ? s : p,
|
117
|
+
const C = i.group && this.values[i.group][p] ? this.values[i.group][p] : e ? s : p, u = typeof i.property == "function" ? i.property({
|
116
118
|
value: s.startsWith("[") ? p : C,
|
117
119
|
unit: s.startsWith("[") ? "" : e,
|
118
|
-
secondValue: s.startsWith("[") ? "" :
|
119
|
-
secondUnit: s.startsWith("[") ? "" :
|
120
|
-
key:
|
121
|
-
}) : i.property,
|
122
|
-
let
|
123
|
-
if (typeof
|
124
|
-
|
120
|
+
secondValue: s.startsWith("[") ? "" : l ? r : g,
|
121
|
+
secondUnit: s.startsWith("[") ? "" : l,
|
122
|
+
key: y
|
123
|
+
}) : i.property, m = i.value || "{0}";
|
124
|
+
let A;
|
125
|
+
if (typeof m == "function")
|
126
|
+
A = m({
|
125
127
|
value: C,
|
126
128
|
unit: e,
|
127
|
-
secondValue:
|
128
|
-
secondUnit:
|
129
|
-
key:
|
129
|
+
secondValue: l ? r : g,
|
130
|
+
secondUnit: l,
|
131
|
+
key: y
|
130
132
|
});
|
131
|
-
else if (typeof
|
132
|
-
const
|
133
|
-
this.values[
|
134
|
-
$,
|
133
|
+
else if (typeof m == "string") {
|
134
|
+
const d = i.group || t, P = this.processValue(o, e, d);
|
135
|
+
this.values[d] && typeof this.values[d] == "object" && this.values[d][o] ? A = this.values[d][o] : m.includes("{") ? A = this.parseValuePattern(
|
135
136
|
d,
|
136
|
-
|
137
|
+
m,
|
138
|
+
P,
|
137
139
|
"",
|
138
140
|
g,
|
139
141
|
""
|
140
|
-
) :
|
141
|
-
} else
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
142
|
+
) : A = p;
|
143
|
+
} else A = null;
|
144
|
+
const b = `${t}${s ? `${a && a ? "-" : ""}${s}${e}` : ""}${r ? `/${r}${l}` : ""}`;
|
145
|
+
return typeof i.property == "string" && typeof m == "string" && !m.includes("{1") && r ? null : {
|
146
|
+
className: b,
|
147
|
+
cssRules: u ? Array.isArray(u) ? u : typeof u == "string" && (u.includes(":") || u.includes("value:")) ? u.includes("value:") ? u.slice(6) : this.toKebabCase(String(u)) : this.toKebabCase(String(u)) : null,
|
148
|
+
value: m === null || u === null || u.includes(":") || u.includes("value:") ? null : s.startsWith("[") ? p : A,
|
146
149
|
prefix: n
|
147
150
|
};
|
148
151
|
}
|
149
|
-
const
|
152
|
+
const $ = typeof i == "function" ? i({
|
150
153
|
value: s.startsWith("[") ? p : e ? s : p,
|
151
154
|
unit: s.startsWith("[") ? "" : e,
|
152
|
-
secondValue: s.startsWith("[") ? "" :
|
153
|
-
secondUnit: s.startsWith("[") ? "" :
|
154
|
-
key:
|
155
|
+
secondValue: s.startsWith("[") ? "" : l ? r : g,
|
156
|
+
secondUnit: s.startsWith("[") ? "" : l,
|
157
|
+
key: y
|
155
158
|
}) : i;
|
156
|
-
return {
|
157
|
-
className: `${t}${s ? (
|
158
|
-
cssRules: Array.isArray(i) ?
|
159
|
-
value: typeof
|
159
|
+
return (typeof i == "string" || Array.isArray(i)) && r ? null : {
|
160
|
+
className: `${t}${s ? (a ? "-" : "") + s + e : ""}${r ? `/${r}${l}` : ""}`,
|
161
|
+
cssRules: $ ? Array.isArray(i) ? $ : typeof $ == "string" && ($.includes(":") || $.startsWith("value:")) ? $.startsWith("value:") ? $.slice(6) : this.toKebabCase(String($)) : this.toKebabCase(String($)) : null,
|
162
|
+
value: typeof $ == "string" && $.includes(":") ? null : p,
|
160
163
|
prefix: n
|
161
164
|
};
|
162
165
|
}
|
163
166
|
return null;
|
164
167
|
}
|
165
|
-
parseValuePattern(t, s, e, n, r,
|
168
|
+
parseValuePattern(t, s, e, n, r, l) {
|
166
169
|
if (!s.includes("{0}") && !s.includes("{1") && !s.includes("||"))
|
167
170
|
return s;
|
168
|
-
const [
|
171
|
+
const [a, i] = s.split("||").map((c) => c.trim()), h = this.processValue(e, n, t), y = this.processValue(r, l, t);
|
169
172
|
if (s.includes("{0}") && s.includes("{1") || s.includes("{1")) {
|
170
|
-
let c =
|
171
|
-
if (e && (c = c.replace("{0}",
|
173
|
+
let c = a;
|
174
|
+
if (e && (c = c.replace("{0}", h)), s.includes("{1")) {
|
172
175
|
const f = c.match(/{1([^}]*)}/);
|
173
176
|
if (s.includes("{1}"))
|
174
|
-
r ? c = r.startsWith("[") ?
|
177
|
+
r ? c = r.startsWith("[") ? y : c.replace("{1}", y) : c = i;
|
175
178
|
else if (f) {
|
176
179
|
const o = f[0], p = f[1].trim();
|
177
|
-
let g =
|
178
|
-
!g && p.includes("|") ? g = p.split("|")[1].trim() : g || (g = ""), c = e.startsWith("[") ?
|
180
|
+
let g = y;
|
181
|
+
!g && p.includes("|") ? g = p.split("|")[1].trim() : g || (g = ""), c = e.startsWith("[") ? h : c.replace(o, g);
|
179
182
|
}
|
180
183
|
}
|
181
|
-
return e ? c : i ||
|
184
|
+
return e ? c : i || a;
|
182
185
|
} else
|
183
|
-
return e ? e.startsWith("[") ?
|
186
|
+
return e ? e.startsWith("[") ? h : a.replace("{0}", h) : i || a;
|
184
187
|
}
|
185
188
|
getParentClass(t) {
|
186
189
|
return Object.keys(this.classes).filter(
|
@@ -190,11 +193,11 @@ class _ {
|
|
190
193
|
)
|
191
194
|
);
|
192
195
|
}
|
193
|
-
processCustomClass(t, s = "", e = "", n = "", r = "",
|
196
|
+
processCustomClass(t, s = "", e = "", n = "", r = "", l = "", a = !0) {
|
194
197
|
if (!t) return null;
|
195
198
|
const i = this.getParentClass(t);
|
196
199
|
if (i.length > 0) {
|
197
|
-
const
|
200
|
+
const h = i.map((f) => {
|
198
201
|
const o = this.classes[f];
|
199
202
|
if (!o || s && !o[t].includes("||") || s && !o[t].includes("|"))
|
200
203
|
return "";
|
@@ -204,13 +207,13 @@ class _ {
|
|
204
207
|
s,
|
205
208
|
e,
|
206
209
|
r,
|
207
|
-
|
210
|
+
l
|
208
211
|
);
|
209
212
|
return `${this.toKebabCase(String(f))}: ${p}`;
|
210
|
-
}).filter(Boolean).join("; "),
|
213
|
+
}).filter(Boolean).join("; "), y = t.slice(-(s + e).length), c = `${t}${s ? `${a ? "-" : ""}${s}${e}` : ""}${r ? `/${r}${l}` : ""}`;
|
211
214
|
return {
|
212
|
-
className: s ===
|
213
|
-
cssRules:
|
215
|
+
className: s === y ? t : c,
|
216
|
+
cssRules: h,
|
214
217
|
value: null,
|
215
218
|
prefix: n
|
216
219
|
};
|
@@ -221,39 +224,39 @@ class _ {
|
|
221
224
|
const s = Array.isArray(t) ? t : t.split(/\s+/), e = [];
|
222
225
|
return s.forEach((n) => {
|
223
226
|
if (!n) return this;
|
224
|
-
const [r,
|
225
|
-
if (!
|
226
|
-
const [c, f, o, p, g,
|
227
|
-
|
227
|
+
const [r, l] = n.split(":"), a = l || r, i = l ? r : void 0, h = this.parse(n), y = h || [i, a, "", ""];
|
228
|
+
if (!y) return this;
|
229
|
+
const [c, f, o, p, g, $] = y, C = !n.includes((f || "") + (o || "")), u = this.getParentClass(`${f}${C ? "-" : ""}${o}`).length > 0 ? `${f}${C ? "-" : ""}${o}` : f, m = this.processCustomClass(
|
230
|
+
u,
|
228
231
|
o,
|
229
232
|
p,
|
230
233
|
c,
|
231
234
|
g,
|
232
|
-
|
235
|
+
$,
|
233
236
|
C
|
234
237
|
);
|
235
|
-
if (
|
236
|
-
const { className:
|
237
|
-
if (
|
238
|
+
if (m) {
|
239
|
+
const { className: b, cssRules: d, prefix: P } = m;
|
240
|
+
if (!d || d === "null") return;
|
238
241
|
e.push({
|
239
|
-
className:
|
240
|
-
cssRules:
|
242
|
+
className: b,
|
243
|
+
cssRules: d,
|
241
244
|
value: null,
|
242
|
-
prefix:
|
243
|
-
raw:
|
245
|
+
prefix: P,
|
246
|
+
raw: [P, f, o, p, g, $]
|
244
247
|
});
|
245
248
|
return;
|
246
249
|
}
|
247
|
-
const
|
248
|
-
if (
|
249
|
-
const { className:
|
250
|
-
if (
|
250
|
+
const A = this.processShorthand(f, o, p, c, g, $, C);
|
251
|
+
if (A) {
|
252
|
+
const { className: b, cssRules: d, value: P, prefix: v } = A;
|
253
|
+
if (!d || d === "null") return;
|
251
254
|
e.push({
|
252
|
-
className:
|
253
|
-
cssRules:
|
254
|
-
value:
|
255
|
-
prefix:
|
256
|
-
raw:
|
255
|
+
className: b,
|
256
|
+
cssRules: d,
|
257
|
+
value: P,
|
258
|
+
prefix: v,
|
259
|
+
raw: [c, f, o, p, g, $]
|
257
260
|
});
|
258
261
|
}
|
259
262
|
}), e;
|
package/dist/index.iife.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var __tenoxui_moxie__=function(
|
1
|
+
var __tenoxui_moxie__=function(C){"use strict";var Z=Object.defineProperty;var V=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var v=(C,m,A)=>m in C?Z(C,m,{enumerable:!0,configurable:!0,writable:!0,value:A}):C[m]=A,S=(C,m)=>{for(var A in m||(m={}))j.call(m,A)&&v(C,A,m[A]);if(V)for(var A of V(m))z.call(m,A)&&v(C,A,m[A]);return C};class m{constructor({property:t={},values:e={},classes:s={},alwaysUseHyphens:n=!0}={}){this.property=S({moxie:({key:r,secondValue:l})=>l?null:r},t),this.values=e,this.classes=s,this.useHyphens=n}toKebabCase(t){if(/^(webkit|moz|ms|o)[A-Z]/.test(t)){const e=t.match(/^(webkit|moz|ms|o)/);if(e){const s=e[0];return`-${s}${t.slice(s.length).replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}`}}return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}escapeCSSSelector(t){return t.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(t){if(!t)return[];const e=new Set;return Object.entries(t).forEach(([s,n])=>{n&&typeof n=="object"&&Object.keys(n).forEach(r=>{e.add(r)})}),Array.from(e)}getTypePrefixes(t=[]){const e=this.property,s=this.classes,n=Object.keys(e);if(!s)return[...n,...t].sort((a,i)=>i.length-a.length);const l=[...this.getAllClassNames(s)];return[...n,...l,...t].sort((a,i)=>i.length-a.length)}regexp(t){const e=this.getTypePrefixes(t).join("|"),s="\\[[^\\]]+\\]",n="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",l="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+s+"|"+n+"|"+r+"))|"+s+"|"+n+"|"+r,a=`(${e}|\\[[^\\]]+\\])`,i=this.useHyphens?"(?:-)":"(?:-)?",h="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))",y="([a-zA-Z%]*)",c="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:l,type:a,separator:i,value:h,unit:y,secondValuePattern:c,all:"(?:("+l+"):)?"+a+i+h+y+c}}generateClassNameRegEx(t=[]){return new RegExp(this.regexp(t).all)}parse(t,e){if(Object.values(this.classes).some(o=>o==null?void 0:o[t]))return[void 0,t,"","",void 0,void 0,t];const s=this.generateClassNameRegEx(e),n=(t+"-dummy").match(s);if(!n)return null;const[,r,l,a,i,h,y]=n,c=a?a==="dummy"?"":a.replace("-dummy",""):"",f=h?h==="dummy"?"":h.replace("-dummy",""):"";return[r,l,c,i||"",f,y,t]}processValue(t,e,s){if(!t)return"";const n=r=>r.replace(/\{([^}]+)\}/g,(l,a)=>{const i=this.values,h=i!==null?typeof i[s]=="object"?i[s][a]:i[a]:void 0;return typeof h=="string"?h:l});if(typeof this.values=="object"&&this.values!==null&&(this.values[s]&&typeof this.values[s]=="object"&&this.values[s][t]||this.values[t]))return typeof this.values[s]=="object"&&this.values[s]!==null?this.values[s][t]:this.values[t];if(t.startsWith("$"))return`var(--${t.slice(1)})`;if(t.startsWith("[")&&t.endsWith("]")||t.startsWith("(")&&t.endsWith(")")){const r=t.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?n(r):r.startsWith("--")?`var(${r})`:r}return t+(e||"")}processShorthand(t="",e="",s="",n,r="",l="",a=!0){const i=this.property[t],h=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let y=null,c=e||"";const f=c.match(h);f&&(y=f[1].trim(),c=f[2].trim());let o;e.includes(y+":")?o=e.startsWith("(")?`(${c})`:`[${c}]`:o=e;const p=this.processValue(o,s,t),g=this.processValue(r,l,t);if(t.startsWith("[")&&t.endsWith("]")){const P=t.slice(1,-1).split(",").map(u=>u.trim()).map(u=>`${u?u.startsWith("--")?String(u):this.toKebabCase(String(u)):null}: ${p}`).join("; ");return{className:`${`[${t.slice(1,-1)}]${a?"-":""}${e}${s}`}`,cssRules:P,value:null,prefix:n}}if(i){if(typeof i=="object"&&"property"in i){const P=i.group&&this.values[i.group][p]?this.values[i.group][p]:s?e:p,u=typeof i.property=="function"?i.property({value:e.startsWith("[")?p:P,unit:e.startsWith("[")?"":s,secondValue:e.startsWith("[")?"":l?r:g,secondUnit:e.startsWith("[")?"":l,key:y}):i.property,b=i.value||"{0}";let x;if(typeof b=="function")x=b({value:P,unit:s,secondValue:l?r:g,secondUnit:l,key:y});else if(typeof b=="string"){const d=i.group||t,W=this.processValue(o,s,d);this.values[d]&&typeof this.values[d]=="object"&&this.values[d][o]?x=this.values[d][o]:b.includes("{")?x=this.parseValuePattern(d,b,W,"",g,""):x=p}else x=null;const _=`${t}${e?`${a&&a?"-":""}${e}${s}`:""}${r?`/${r}${l}`:""}`;return typeof i.property=="string"&&typeof b=="string"&&!b.includes("{1")&&r?null:{className:_,cssRules:u?Array.isArray(u)?u:typeof u=="string"&&(u.includes(":")||u.includes("value:"))?u.includes("value:")?u.slice(6):this.toKebabCase(String(u)):this.toKebabCase(String(u)):null,value:b===null||u===null||u.includes(":")||u.includes("value:")?null:e.startsWith("[")?p:x,prefix:n}}const $=typeof i=="function"?i({value:e.startsWith("[")?p:s?e:p,unit:e.startsWith("[")?"":s,secondValue:e.startsWith("[")?"":l?r:g,secondUnit:e.startsWith("[")?"":l,key:y}):i;return(typeof i=="string"||Array.isArray(i))&&r?null:{className:`${t}${e?(a?"-":"")+e+s:""}${r?`/${r}${l}`:""}`,cssRules:$?Array.isArray(i)?$:typeof $=="string"&&($.includes(":")||$.startsWith("value:"))?$.startsWith("value:")?$.slice(6):this.toKebabCase(String($)):this.toKebabCase(String($)):null,value:typeof $=="string"&&$.includes(":")?null:p,prefix:n}}return null}parseValuePattern(t,e,s,n,r,l){if(!e.includes("{0}")&&!e.includes("{1")&&!e.includes("||"))return e;const[a,i]=e.split("||").map(c=>c.trim()),h=this.processValue(s,n,t),y=this.processValue(r,l,t);if(e.includes("{0}")&&e.includes("{1")||e.includes("{1")){let c=a;if(s&&(c=c.replace("{0}",h)),e.includes("{1")){const f=c.match(/{1([^}]*)}/);if(e.includes("{1}"))r?c=r.startsWith("[")?y:c.replace("{1}",y):c=i;else if(f){const o=f[0],p=f[1].trim();let g=y;!g&&p.includes("|")?g=p.split("|")[1].trim():g||(g=""),c=s.startsWith("[")?h:c.replace(o,g)}}return s?c:i||a}else return s?s.startsWith("[")?h:a.replace("{0}",h):i||a}getParentClass(t){return Object.keys(this.classes).filter(e=>Object.prototype.hasOwnProperty.call(this.classes[e],t))}processCustomClass(t,e="",s="",n="",r="",l="",a=!0){if(!t)return null;const i=this.getParentClass(t);if(i.length>0){const h=i.map(f=>{const o=this.classes[f];if(!o||e&&!o[t].includes("||")||e&&!o[t].includes("|"))return"";const p=this.parseValuePattern(t,o[t]||"",e,s,r,l);return`${this.toKebabCase(String(f))}: ${p}`}).filter(Boolean).join("; "),y=t.slice(-(e+s).length),c=`${t}${e?`${a?"-":""}${e}${s}`:""}${r?`/${r}${l}`:""}`;return{className:e===y?t:c,cssRules:h,value:null,prefix:n}}return null}process(t){const e=Array.isArray(t)?t:t.split(/\s+/),s=[];return e.forEach(n=>{if(!n)return this;const[r,l]=n.split(":"),a=l||r,i=l?r:void 0,h=this.parse(n),y=h||[i,a,"",""];if(!y)return this;const[c,f,o,p,g,$]=y,P=!n.includes((f||"")+(o||"")),u=this.getParentClass(`${f}${P?"-":""}${o}`).length>0?`${f}${P?"-":""}${o}`:f,b=this.processCustomClass(u,o,p,c,g,$,P);if(b){const{className:_,cssRules:d,prefix:W}=b;if(!d||d==="null")return;s.push({className:_,cssRules:d,value:null,prefix:W,raw:[W,f,o,p,g,$]});return}const x=this.processShorthand(f,o,p,c,g,$,P);if(x){const{className:_,cssRules:d,value:W,prefix:R}=x;if(!d||d==="null")return;s.push({className:_,cssRules:d,value:W,prefix:R,raw:[c,f,o,p,g,$]})}}),s}}return C.TenoxUI=m,C.default=m,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),C}({});
|
package/dist/index.umd.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
(function(
|
1
|
+
(function(g,d){typeof exports=="object"&&typeof module!="undefined"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(g=typeof globalThis!="undefined"?globalThis:g||self,d(g.__tenoxui_moxie__={}))})(this,function(g){"use strict";var R=Object.defineProperty;var V=Object.getOwnPropertySymbols;var Z=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var S=(g,d,C)=>d in g?R(g,d,{enumerable:!0,configurable:!0,writable:!0,value:C}):g[d]=C,v=(g,d)=>{for(var C in d||(d={}))Z.call(d,C)&&S(g,C,d[C]);if(V)for(var C of V(d))z.call(d,C)&&S(g,C,d[C]);return g};class d{constructor({property:e={},values:t={},classes:s={},alwaysUseHyphens:n=!0}={}){this.property=v({moxie:({key:r,secondValue:l})=>l?null:r},e),this.values=t,this.classes=s,this.useHyphens=n}toKebabCase(e){if(/^(webkit|moz|ms|o)[A-Z]/.test(e)){const t=e.match(/^(webkit|moz|ms|o)/);if(t){const s=t[0];return`-${s}${e.slice(s.length).replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}`}}return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}escapeCSSSelector(e){return e.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(e){if(!e)return[];const t=new Set;return Object.entries(e).forEach(([s,n])=>{n&&typeof n=="object"&&Object.keys(n).forEach(r=>{t.add(r)})}),Array.from(t)}getTypePrefixes(e=[]){const t=this.property,s=this.classes,n=Object.keys(t);if(!s)return[...n,...e].sort((a,i)=>i.length-a.length);const l=[...this.getAllClassNames(s)];return[...n,...l,...e].sort((a,i)=>i.length-a.length)}regexp(e){const t=this.getTypePrefixes(e).join("|"),s="\\[[^\\]]+\\]",n="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",l="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+s+"|"+n+"|"+r+"))|"+s+"|"+n+"|"+r,a=`(${t}|\\[[^\\]]+\\])`,i=this.useHyphens?"(?:-)":"(?:-)?",f="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))",y="([a-zA-Z%]*)",o="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+s+"|"+r+"|"+n+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:l,type:a,separator:i,value:f,unit:y,secondValuePattern:o,all:"(?:("+l+"):)?"+a+i+f+y+o}}generateClassNameRegEx(e=[]){return new RegExp(this.regexp(e).all)}parse(e,t){if(Object.values(this.classes).some(c=>c==null?void 0:c[e]))return[void 0,e,"","",void 0,void 0,e];const s=this.generateClassNameRegEx(t),n=(e+"-dummy").match(s);if(!n)return null;const[,r,l,a,i,f,y]=n,o=a?a==="dummy"?"":a.replace("-dummy",""):"",h=f?f==="dummy"?"":f.replace("-dummy",""):"";return[r,l,o,i||"",h,y,e]}processValue(e,t,s){if(!e)return"";const n=r=>r.replace(/\{([^}]+)\}/g,(l,a)=>{const i=this.values,f=i!==null?typeof i[s]=="object"?i[s][a]:i[a]:void 0;return typeof f=="string"?f:l});if(typeof this.values=="object"&&this.values!==null&&(this.values[s]&&typeof this.values[s]=="object"&&this.values[s][e]||this.values[e]))return typeof this.values[s]=="object"&&this.values[s]!==null?this.values[s][e]:this.values[e];if(e.startsWith("$"))return`var(--${e.slice(1)})`;if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("(")&&e.endsWith(")")){const r=e.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return r.includes("{")?n(r):r.startsWith("--")?`var(${r})`:r}return e+(t||"")}processShorthand(e="",t="",s="",n,r="",l="",a=!0){const i=this.property[e],f=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let y=null,o=t||"";const h=o.match(f);h&&(y=h[1].trim(),o=h[2].trim());let c;t.includes(y+":")?c=t.startsWith("(")?`(${o})`:`[${o}]`:c=t;const p=this.processValue(c,s,e),m=this.processValue(r,l,e);if(e.startsWith("[")&&e.endsWith("]")){const A=e.slice(1,-1).split(",").map(u=>u.trim()).map(u=>`${u?u.startsWith("--")?String(u):this.toKebabCase(String(u)):null}: ${p}`).join("; ");return{className:`${`[${e.slice(1,-1)}]${a?"-":""}${t}${s}`}`,cssRules:A,value:null,prefix:n}}if(i){if(typeof i=="object"&&"property"in i){const A=i.group&&this.values[i.group][p]?this.values[i.group][p]:s?t:p,u=typeof i.property=="function"?i.property({value:t.startsWith("[")?p:A,unit:t.startsWith("[")?"":s,secondValue:t.startsWith("[")?"":l?r:m,secondUnit:t.startsWith("[")?"":l,key:y}):i.property,b=i.value||"{0}";let P;if(typeof b=="function")P=b({value:A,unit:s,secondValue:l?r:m,secondUnit:l,key:y});else if(typeof b=="string"){const x=i.group||e,W=this.processValue(c,s,x);this.values[x]&&typeof this.values[x]=="object"&&this.values[x][c]?P=this.values[x][c]:b.includes("{")?P=this.parseValuePattern(x,b,W,"",m,""):P=p}else P=null;const _=`${e}${t?`${a&&a?"-":""}${t}${s}`:""}${r?`/${r}${l}`:""}`;return typeof i.property=="string"&&typeof b=="string"&&!b.includes("{1")&&r?null:{className:_,cssRules:u?Array.isArray(u)?u:typeof u=="string"&&(u.includes(":")||u.includes("value:"))?u.includes("value:")?u.slice(6):this.toKebabCase(String(u)):this.toKebabCase(String(u)):null,value:b===null||u===null||u.includes(":")||u.includes("value:")?null:t.startsWith("[")?p:P,prefix:n}}const $=typeof i=="function"?i({value:t.startsWith("[")?p:s?t:p,unit:t.startsWith("[")?"":s,secondValue:t.startsWith("[")?"":l?r:m,secondUnit:t.startsWith("[")?"":l,key:y}):i;return(typeof i=="string"||Array.isArray(i))&&r?null:{className:`${e}${t?(a?"-":"")+t+s:""}${r?`/${r}${l}`:""}`,cssRules:$?Array.isArray(i)?$:typeof $=="string"&&($.includes(":")||$.startsWith("value:"))?$.startsWith("value:")?$.slice(6):this.toKebabCase(String($)):this.toKebabCase(String($)):null,value:typeof $=="string"&&$.includes(":")?null:p,prefix:n}}return null}parseValuePattern(e,t,s,n,r,l){if(!t.includes("{0}")&&!t.includes("{1")&&!t.includes("||"))return t;const[a,i]=t.split("||").map(o=>o.trim()),f=this.processValue(s,n,e),y=this.processValue(r,l,e);if(t.includes("{0}")&&t.includes("{1")||t.includes("{1")){let o=a;if(s&&(o=o.replace("{0}",f)),t.includes("{1")){const h=o.match(/{1([^}]*)}/);if(t.includes("{1}"))r?o=r.startsWith("[")?y:o.replace("{1}",y):o=i;else if(h){const c=h[0],p=h[1].trim();let m=y;!m&&p.includes("|")?m=p.split("|")[1].trim():m||(m=""),o=s.startsWith("[")?f:o.replace(c,m)}}return s?o:i||a}else return s?s.startsWith("[")?f:a.replace("{0}",f):i||a}getParentClass(e){return Object.keys(this.classes).filter(t=>Object.prototype.hasOwnProperty.call(this.classes[t],e))}processCustomClass(e,t="",s="",n="",r="",l="",a=!0){if(!e)return null;const i=this.getParentClass(e);if(i.length>0){const f=i.map(h=>{const c=this.classes[h];if(!c||t&&!c[e].includes("||")||t&&!c[e].includes("|"))return"";const p=this.parseValuePattern(e,c[e]||"",t,s,r,l);return`${this.toKebabCase(String(h))}: ${p}`}).filter(Boolean).join("; "),y=e.slice(-(t+s).length),o=`${e}${t?`${a?"-":""}${t}${s}`:""}${r?`/${r}${l}`:""}`;return{className:t===y?e:o,cssRules:f,value:null,prefix:n}}return null}process(e){const t=Array.isArray(e)?e:e.split(/\s+/),s=[];return t.forEach(n=>{if(!n)return this;const[r,l]=n.split(":"),a=l||r,i=l?r:void 0,f=this.parse(n),y=f||[i,a,"",""];if(!y)return this;const[o,h,c,p,m,$]=y,A=!n.includes((h||"")+(c||"")),u=this.getParentClass(`${h}${A?"-":""}${c}`).length>0?`${h}${A?"-":""}${c}`:h,b=this.processCustomClass(u,c,p,o,m,$,A);if(b){const{className:_,cssRules:x,prefix:W}=b;if(!x||x==="null")return;s.push({className:_,cssRules:x,value:null,prefix:W,raw:[W,h,c,p,m,$]});return}const P=this.processShorthand(h,c,p,o,m,$,A);if(P){const{className:_,cssRules:x,value:W,prefix:j}=P;if(!x||x==="null")return;s.push({className:_,cssRules:x,value:W,prefix:j,raw:[o,h,c,p,m,$]})}}),s}}g.TenoxUI=d,g.default=d,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/types/index.d.ts
CHANGED
@@ -13,7 +13,7 @@ export type ValueParams = {
|
|
13
13
|
secondValue?: string;
|
14
14
|
secondUnit?: string;
|
15
15
|
};
|
16
|
-
export type PropertyParamValue = GetCSSProperty | ((params: PropertyParams) => GetCSSProperty);
|
16
|
+
export type PropertyParamValue = GetCSSProperty | ((params: PropertyParams) => null | GetCSSProperty);
|
17
17
|
export type ValuePropType = string | ((params: ValueParams) => string | null) | null;
|
18
18
|
export type PropertyValue = PropertyParamValue | {
|
19
19
|
property?: PropertyParamValue;
|
@@ -32,7 +32,7 @@ export interface Config {
|
|
32
32
|
export type Parsed = null | (string | undefined)[];
|
33
33
|
export type ProcessedStyle = {
|
34
34
|
className: string;
|
35
|
-
cssRules: string | string[];
|
35
|
+
cssRules: string | string[] | null;
|
36
36
|
value: string | null;
|
37
37
|
prefix?: string | null;
|
38
38
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tenoxui/moxie",
|
3
|
-
"version": "0.4.
|
3
|
+
"version": "0.4.4",
|
4
4
|
"description": "Very lightweight utility-first CSS engine for style generation",
|
5
5
|
"author": "NOuSantx <nousantx@gmail.com>",
|
6
6
|
"license": "MIT",
|
@@ -23,7 +23,6 @@
|
|
23
23
|
"README.md",
|
24
24
|
"LICENSE"
|
25
25
|
],
|
26
|
-
"type": "module",
|
27
26
|
"types": "./dist/index.d.ts",
|
28
27
|
"main": "./dist/index.cjs.js",
|
29
28
|
"module": "./dist/index.es.js",
|