@tenoxui/moxie 0.6.3 → 0.6.5
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 -105
- package/dist/index.iife.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var R=Object.defineProperty;var W=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var P=(
|
1
|
+
"use strict";var R=Object.defineProperty;var W=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var P=(m,t,s)=>t in m?R(m,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):m[t]=s,x=(m,t)=>{for(var s in t||(t={}))j.call(t,s)&&P(m,s,t[s]);if(W)for(var s of W(t))V.call(t,s)&&P(m,s,t[s]);return m};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class S{constructor({property:t={},values:s={},classes:e={}}={}){this.property=x({moxie:({key:l,secondValue:r})=>r?null:l},t),this.values=s,this.classes=e}toKebabCase(t){if(/^(webkit|moz|ms|o)[A-Z]/.test(t)){const s=t.match(/^(webkit|moz|ms|o)/);if(s){const e=s[0];return`-${e}${t.slice(e.length).replace(/[A-Z]/g,l=>`-${l.toLowerCase()}`)}`}}return t.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`)}escapeCSSSelector(t){return t.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(t){if(!t)return[];const s=new Set;return Object.entries(t).forEach(([e,l])=>{l&&typeof l=="object"&&Object.keys(l).forEach(r=>{s.add(r)})}),Array.from(s)}getTypePrefixes(t=[]){const s=this.property,e=this.classes,l=Object.keys(s);if(!e)return[...l,...t].sort((i,n)=>n.length-i.length);const o=[...this.getAllClassNames(e)];return[...l,...o,...t].sort((i,n)=>n.length-i.length)}regexp(t){const s=this.getTypePrefixes(t).join("|"),e="\\[[^\\]]+\\]",l="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",o="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+l+"|"+r+"))|"+e+"|"+l+"|"+r,i=`(${s}|\\[[^\\]]+\\])`,n="(?:-)",h="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+l+"|(?:\\$[^\\s\\/]+))",u="([a-zA-Z%]*)",c="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+l+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:o,type:i,separator:n,value:h,unit:u,secondValuePattern:c,all:"^(?:("+o+"):)?"+i+n+h+u+c+"$"}}parse(t,s){const e=this.regexp(s),l=t.match(new RegExp(e.all));if(l){const[,o,i,n,h,u,c]=l;return[o,i,n,h||"",u,c]}const r=t.match(new RegExp(`^(?:(${e.prefix}):)?${e.type}$`));return r?[r[1],r[2],"","",void 0,void 0,t]:null}constructRaw(t,s,e,l,r,o){return`${t?`${t}:`:""}${s}${e?"-":""}${e}${l}${r?`/${r}${o}`:""}`}processValue(t,s,e){if(!t)return"";const l=r=>r.replace(/\{([^}]+)\}/g,(o,i)=>{const n=this.values,h=n!==null?typeof n[e]=="object"?n[e][i]:n[i]:void 0;return typeof h=="string"?h:o});if(typeof this.values=="object"&&this.values!==null&&(this.values[e]&&typeof this.values[e]=="object"&&this.values[e][t]||this.values[t]))return typeof this.values[e]=="object"&&this.values[e]!==null?this.values[e][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("{")?l(r):r.startsWith("--")?`var(${r})`:r}return t+(s||"")}processShorthand(t="",s="",e="",l,r="",o="",i){const n=this.property[t];if(typeof n=="object"&&!Array.isArray(n)&&!("property"in n))return null;const h=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let u=null,c=s||"";const $=c.match(h);if($&&(u=$[1].trim(),c=$[2].trim()),(typeof n=="string"&&!n.includes(":")||Array.isArray(n))&&(!s||s.includes(u+":")||r))return null;let f;s.includes(u+":")?f=s.startsWith("(")?`(${c})`:`[${c}]`:f=s;const p=this.processValue(f,e,t),y=this.processValue(r,o,t);if(t.startsWith("[")&&t.endsWith("]")){if(!s||r)return null;const a=t.slice(1,-1).split(",").map(b=>b.trim().startsWith("--")?String(b.trim()):this.toKebabCase(String(b.trim())));return{className:this.constructRaw(l,t,s,e),cssRules:a.length===1?a[0]:a,value:p,prefix:l}}if(n){if(typeof n=="object"&&"property"in n){const b=n.group&&this.values[n.group][p]?this.values[n.group][p]:e?s:p,g=typeof n.property=="function"?n.property({value:s.startsWith("[")?p:b,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":o?r:y,secondUnit:s.startsWith("[")?"":o,key:u,raw:i}):n.property,d=n.value||"{0}";let A;if(typeof d=="function")A=d({value:b,unit:e,secondValue:o?r:y,secondUnit:o,key:u,raw:i});else if(typeof d=="string"){const C=n.group||t,w=this.processValue(f,e,C);this.values[C]&&typeof this.values[C]=="object"&&this.values[C][f]?A=this.values[C][f]:d.includes("{")?A=this.parseValuePattern(C,d,w,"",y,""):A=p}else if(Array.isArray(d)){if(!d.includes(s+e)||r)return null;A=s+e}else A=null;return typeof n.property=="string"&&typeof d=="string"&&(s.includes(u+":")||!d.includes("{1")&&r)?null:{className:this.constructRaw(l,t,s,e,r,o),cssRules:g?Array.isArray(g)?g:typeof g=="string"&&(g.includes(":")||g.includes("value:"))?g.includes("value:")?g.slice(6):this.toKebabCase(String(g)):this.toKebabCase(String(g)):null,value:d===null||g===null||g.includes(":")||g.includes("value:")?null:s.startsWith("[")?p:A,prefix:l}}const a=typeof n=="function"?n({value:s.startsWith("[")?p:e?s:p,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":o?r:y,secondUnit:s.startsWith("[")?"":o,key:u,raw:i}):n;return{className:this.constructRaw(l,t,s,e,r,o),cssRules:a?Array.isArray(n)?a:typeof a=="string"&&(a.includes(":")||a.startsWith("value:"))?a.startsWith("value:")?a.slice(6):this.toKebabCase(String(a)):this.toKebabCase(String(a)):null,value:typeof a=="string"&&a.includes(":")?null:p,prefix:l}}return null}parseValuePattern(t,s,e,l,r,o){if(!s.includes("{0}")&&!s.includes("{1")&&!s.includes("||"))return s;const[i,n]=s.split("||").map(c=>c.trim()),h=this.processValue(e,l,t),u=this.processValue(r,o,t);if(s.includes("{0}")&&s.includes("{1")||s.includes("{1")){let c=i;if(e&&(c=c.replace(/\{0\}/g,h)),s.includes("{1")){s.includes("{1}")&&(r?c=r.startsWith("[")?u:c.replace(/\{1\}/g,u):c=n||i);const $=/\{1([^}]*)\}/g;let f;for(;(f=$.exec(c))!==null;){const p=f[0],y=f[1].trim();let a=u;!a&&y.includes("|")?a=y.split("|")[1].trim():a||(a=""),c=e.startsWith("[")?h:c.replace(p,a)}}return e?c:n||i}else return e?e.startsWith("[")?h:i.replace(/\{0\}/g,h):n||i}getParentClass(t){return Object.keys(this.classes).filter(s=>Object.prototype.hasOwnProperty.call(this.classes[s],t))}processCustomClass(t,s="",e="",l="",r="",o=""){if(!t)return null;const i=this.getParentClass(t),n=s&&t.endsWith(`-${s}${e}`);if(i.length>0){const h=i.map(u=>{const c=this.classes[u];if(!c||s&&!n&&c[t]&&!c[t].includes("{0}")&&!c[t].includes("|"))return null;const $=this.parseValuePattern(t,c[t]||"",s,e,r,o);return`${this.toKebabCase(String(u))}: ${$}`}).filter(Boolean).join("; ");return{className:n?t:this.constructRaw(l,t,s,e,r,o),cssRules:h,value:null,prefix:l}}return null}process(t){try{const s=Array.isArray(t)?t:t.split(/\s+/),e=[];for(const l of s)try{if(!l)continue;const r=this.parse(l);if(!r)continue;const[o,i,n,h,u,c]=r;if(!i)continue;const $=this.getParentClass(`${i}-${n}`).length>0?`${i}-${n}`:i;try{const f=this.processCustomClass($,n,h,o,u,c);if(f){const{className:p,cssRules:y,prefix:a}=f;if(!y||y==="null")continue;e.push({className:this.escapeCSSSelector(p),cssRules:y,value:null,prefix:a,raw:[...r,this.constructRaw(a,i,n,h,u,c)]});continue}}catch(f){console.warn(`Error processing custom class "${l}":`,f)}try{const f=this.processShorthand(i,n,h,o,u,c,r);if(f){const{className:p,cssRules:y,value:a,prefix:b}=f;if(!y||y==="null")continue;e.push({className:this.escapeCSSSelector(p),cssRules:y,value:a,prefix:b,raw:[...r,this.constructRaw(o,i,n,h,u,c)]})}}catch(f){console.warn(`Error processing shorthand "${l}":`,f)}}catch(r){console.warn(`Failed to process class \`${l}\`:`,r)}return e}catch(s){return console.error("Critical error in process method:",s),[]}}}exports.TenoxUI=S;exports.default=S;
|
package/dist/index.es.js
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
var S = Object.defineProperty;
|
2
2
|
var W = Object.getOwnPropertySymbols;
|
3
3
|
var R = Object.prototype.hasOwnProperty, V = Object.prototype.propertyIsEnumerable;
|
4
|
-
var P = (
|
5
|
-
for (var
|
6
|
-
R.call(
|
4
|
+
var P = (m, s, t) => s in m ? S(m, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : m[s] = t, x = (m, s) => {
|
5
|
+
for (var t in s || (s = {}))
|
6
|
+
R.call(s, t) && P(m, t, s[t]);
|
7
7
|
if (W)
|
8
|
-
for (var
|
9
|
-
V.call(
|
10
|
-
return
|
8
|
+
for (var t of W(s))
|
9
|
+
V.call(s, t) && P(m, t, s[t]);
|
10
|
+
return m;
|
11
11
|
};
|
12
12
|
class Z {
|
13
|
-
constructor({ property:
|
13
|
+
constructor({ property: s = {}, values: t = {}, classes: e = {} } = {}) {
|
14
14
|
this.property = x({
|
15
15
|
// use moxie-* utility to access all properties and variables
|
16
16
|
// e.g. `moxie-(color:red)` => `color: red`, `moxie-(--my-var:20px_1rem)` => `--my-var: 20px 1rem`
|
17
17
|
moxie: ({ key: l, secondValue: r }) => r ? null : l
|
18
|
-
},
|
18
|
+
}, s), this.values = t, this.classes = e;
|
19
19
|
}
|
20
|
-
toKebabCase(
|
21
|
-
if (/^(webkit|moz|ms|o)[A-Z]/.test(
|
22
|
-
const
|
23
|
-
if (
|
24
|
-
const e =
|
25
|
-
return `-${e}${
|
20
|
+
toKebabCase(s) {
|
21
|
+
if (/^(webkit|moz|ms|o)[A-Z]/.test(s)) {
|
22
|
+
const t = s.match(/^(webkit|moz|ms|o)/);
|
23
|
+
if (t) {
|
24
|
+
const e = t[0];
|
25
|
+
return `-${e}${s.slice(e.length).replace(/[A-Z]/g, (l) => `-${l.toLowerCase()}`)}`;
|
26
26
|
}
|
27
27
|
}
|
28
|
-
return
|
28
|
+
return s.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
|
29
29
|
}
|
30
|
-
escapeCSSSelector(
|
31
|
-
return
|
30
|
+
escapeCSSSelector(s) {
|
31
|
+
return s.replace(/^(\d)/, "\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g, "\\$1");
|
32
32
|
}
|
33
|
-
getAllClassNames(
|
34
|
-
if (!
|
35
|
-
const
|
36
|
-
return Object.entries(
|
33
|
+
getAllClassNames(s) {
|
34
|
+
if (!s) return [];
|
35
|
+
const t = /* @__PURE__ */ new Set();
|
36
|
+
return Object.entries(s).forEach(([e, l]) => {
|
37
37
|
l && typeof l == "object" && Object.keys(l).forEach((r) => {
|
38
|
-
|
38
|
+
t.add(r);
|
39
39
|
});
|
40
|
-
}), Array.from(
|
40
|
+
}), Array.from(t);
|
41
41
|
}
|
42
|
-
getTypePrefixes(
|
43
|
-
const
|
42
|
+
getTypePrefixes(s = []) {
|
43
|
+
const t = this.property, e = this.classes, l = Object.keys(t);
|
44
44
|
if (!e)
|
45
|
-
return [...l, ...
|
45
|
+
return [...l, ...s].sort((i, n) => n.length - i.length);
|
46
46
|
const a = [...this.getAllClassNames(e)];
|
47
|
-
return [...l, ...a, ...
|
47
|
+
return [...l, ...a, ...s].sort((i, n) => n.length - i.length);
|
48
48
|
}
|
49
|
-
regexp(
|
50
|
-
const
|
49
|
+
regexp(s) {
|
50
|
+
const t = this.getTypePrefixes(s).join("|"), e = "\\[[^\\]]+\\]", l = "\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)", r = "\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}", a = (
|
51
51
|
// Simple prefix (hover, md, focus, etc.)
|
52
52
|
"[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:" + e + "|" + l + "|" + r + "))|" + // Direct bracket, parenthesis, or brace content
|
53
53
|
e + "|" + l + "|" + r
|
54
|
-
), i = `(${
|
54
|
+
), i = `(${t}|\\[[^\\]]+\\])`, n = "(?:-)", h = "(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + // Hex colors
|
55
55
|
e + "|" + // Bracket content
|
56
56
|
r + "|" + // Curly brace content
|
57
57
|
l + "|(?:\\$[^\\s\\/]+))", u = "([a-zA-Z%]*)", c = "(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + e + "|" + r + "|" + l + "|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";
|
@@ -62,57 +62,57 @@ class Z {
|
|
62
62
|
value: h,
|
63
63
|
unit: u,
|
64
64
|
secondValuePattern: c,
|
65
|
-
all: "(?:(" + a + "):)?" + i + n + h + u + c
|
65
|
+
all: "^(?:(" + a + "):)?" + i + n + h + u + c + "$"
|
66
66
|
};
|
67
67
|
}
|
68
|
-
parse(
|
69
|
-
const e = this.regexp(
|
68
|
+
parse(s, t) {
|
69
|
+
const e = this.regexp(t), l = s.match(new RegExp(e.all));
|
70
70
|
if (l) {
|
71
71
|
const [, a, i, n, h, u, c] = l;
|
72
72
|
return [a, i, n, h || "", u, c];
|
73
73
|
}
|
74
|
-
const r =
|
75
|
-
return r ? [r[1], r[2], "", "", void 0, void 0,
|
74
|
+
const r = s.match(new RegExp(`^(?:(${e.prefix}):)?${e.type}$`));
|
75
|
+
return r ? [r[1], r[2], "", "", void 0, void 0, s] : null;
|
76
76
|
}
|
77
|
-
constructRaw(
|
78
|
-
return `${
|
77
|
+
constructRaw(s, t, e, l, r, a) {
|
78
|
+
return `${s ? `${s}:` : ""}${t}${e ? "-" : ""}${e}${l}${r ? `/${r}${a}` : ""}`;
|
79
79
|
}
|
80
80
|
// unique value parser
|
81
|
-
processValue(
|
82
|
-
if (!
|
81
|
+
processValue(s, t, e) {
|
82
|
+
if (!s) return "";
|
83
83
|
const l = (r) => r.replace(/\{([^}]+)\}/g, (a, i) => {
|
84
84
|
const n = this.values, h = n !== null ? typeof n[e] == "object" ? n[e][i] : n[i] : void 0;
|
85
85
|
return typeof h == "string" ? h : a;
|
86
86
|
});
|
87
|
-
if (typeof this.values == "object" && this.values !== null && (this.values[e] && typeof this.values[e] == "object" && this.values[e][
|
88
|
-
return typeof this.values[e] == "object" && this.values[e] !== null ? this.values[e][
|
89
|
-
if (
|
90
|
-
return `var(--${
|
91
|
-
if (
|
92
|
-
const r =
|
87
|
+
if (typeof this.values == "object" && this.values !== null && (this.values[e] && typeof this.values[e] == "object" && this.values[e][s] || this.values[s]))
|
88
|
+
return typeof this.values[e] == "object" && this.values[e] !== null ? this.values[e][s] : this.values[s];
|
89
|
+
if (s.startsWith("$"))
|
90
|
+
return `var(--${s.slice(1)})`;
|
91
|
+
if (s.startsWith("[") && s.endsWith("]") || s.startsWith("(") && s.endsWith(")")) {
|
92
|
+
const r = s.slice(1, -1).replace(/\\\_/g, "m0x13c55").replace(/\_/g, " ").replace(/m0x13c55/g, "_");
|
93
93
|
return r.includes("{") ? l(r) : r.startsWith("--") ? `var(${r})` : r;
|
94
94
|
}
|
95
|
-
return
|
95
|
+
return s + (t || "");
|
96
96
|
}
|
97
|
-
processShorthand(
|
98
|
-
const n = this.property[
|
97
|
+
processShorthand(s = "", t = "", e = "", l, r = "", a = "", i) {
|
98
|
+
const n = this.property[s];
|
99
99
|
if (typeof n == "object" && !Array.isArray(n) && !("property" in n))
|
100
100
|
return null;
|
101
101
|
const h = /^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;
|
102
|
-
let u = null, c =
|
103
|
-
const
|
104
|
-
if (
|
102
|
+
let u = null, c = t || "";
|
103
|
+
const $ = c.match(h);
|
104
|
+
if ($ && (u = $[1].trim(), c = $[2].trim()), (typeof n == "string" && !n.includes(":") || Array.isArray(n)) && (!t || t.includes(u + ":") || r))
|
105
105
|
return null;
|
106
106
|
let f;
|
107
|
-
|
108
|
-
const p = this.processValue(f, e,
|
109
|
-
if (
|
110
|
-
if (!
|
111
|
-
const o =
|
107
|
+
t.includes(u + ":") ? f = t.startsWith("(") ? `(${c})` : `[${c}]` : f = t;
|
108
|
+
const p = this.processValue(f, e, s), y = this.processValue(r, a, s);
|
109
|
+
if (s.startsWith("[") && s.endsWith("]")) {
|
110
|
+
if (!t || r) return null;
|
111
|
+
const o = s.slice(1, -1).split(",").map(
|
112
112
|
(A) => A.trim().startsWith("--") ? String(A.trim()) : this.toKebabCase(String(A.trim()))
|
113
113
|
);
|
114
114
|
return {
|
115
|
-
className: this.constructRaw(l,
|
115
|
+
className: this.constructRaw(l, s, t, e),
|
116
116
|
cssRules: o.length === 1 ? o[0] : o,
|
117
117
|
value: p,
|
118
118
|
prefix: l
|
@@ -120,13 +120,13 @@ class Z {
|
|
120
120
|
}
|
121
121
|
if (n) {
|
122
122
|
if (typeof n == "object" && "property" in n) {
|
123
|
-
const A = n.group && this.values[n.group][p] ? this.values[n.group][p] : e ?
|
123
|
+
const A = n.group && this.values[n.group][p] ? this.values[n.group][p] : e ? t : p, g = (
|
124
124
|
// handle `properties.property` function
|
125
125
|
typeof n.property == "function" ? n.property({
|
126
|
-
value:
|
127
|
-
unit:
|
128
|
-
secondValue:
|
129
|
-
secondUnit:
|
126
|
+
value: t.startsWith("[") ? p : A,
|
127
|
+
unit: t.startsWith("[") ? "" : e,
|
128
|
+
secondValue: t.startsWith("[") ? "" : a ? r : y,
|
129
|
+
secondUnit: t.startsWith("[") ? "" : a,
|
130
130
|
key: u,
|
131
131
|
raw: i
|
132
132
|
}) : (
|
@@ -148,7 +148,7 @@ class Z {
|
|
148
148
|
raw: i
|
149
149
|
});
|
150
150
|
else if (typeof d == "string") {
|
151
|
-
const C = n.group ||
|
151
|
+
const C = n.group || s, w = this.processValue(f, e, C);
|
152
152
|
this.values[C] && typeof this.values[C] == "object" && this.values[C][f] ? b = this.values[C][f] : d.includes("{") ? b = this.parseValuePattern(
|
153
153
|
C,
|
154
154
|
d,
|
@@ -158,11 +158,11 @@ class Z {
|
|
158
158
|
""
|
159
159
|
) : b = p;
|
160
160
|
} else if (Array.isArray(d)) {
|
161
|
-
if (!d.includes(
|
162
|
-
b =
|
161
|
+
if (!d.includes(t + e) || r) return null;
|
162
|
+
b = t + e;
|
163
163
|
} else b = null;
|
164
|
-
return typeof n.property == "string" && typeof d == "string" && (
|
165
|
-
className: this.constructRaw(l,
|
164
|
+
return typeof n.property == "string" && typeof d == "string" && (t.includes(u + ":") || !d.includes("{1") && r) ? null : {
|
165
|
+
className: this.constructRaw(l, s, t, e, r, a),
|
166
166
|
cssRules: (
|
167
167
|
// if not property, or when `properties.property` as function return null
|
168
168
|
g ? Array.isArray(g) ? g : (
|
@@ -173,7 +173,7 @@ class Z {
|
|
173
173
|
)
|
174
174
|
) : null
|
175
175
|
),
|
176
|
-
value: d === null || g === null || g.includes(":") || g.includes("value:") ? null :
|
176
|
+
value: d === null || g === null || g.includes(":") || g.includes("value:") ? null : t.startsWith("[") ? p : b,
|
177
177
|
prefix: l
|
178
178
|
};
|
179
179
|
}
|
@@ -183,10 +183,10 @@ class Z {
|
|
183
183
|
// m-4 => margin: 4px
|
184
184
|
// m-4rem => margin: 4rem
|
185
185
|
typeof n == "function" ? n({
|
186
|
-
value:
|
187
|
-
unit:
|
188
|
-
secondValue:
|
189
|
-
secondUnit:
|
186
|
+
value: t.startsWith("[") ? p : e ? t : p,
|
187
|
+
unit: t.startsWith("[") ? "" : e,
|
188
|
+
secondValue: t.startsWith("[") ? "" : a ? r : y,
|
189
|
+
secondUnit: t.startsWith("[") ? "" : a,
|
190
190
|
key: u,
|
191
191
|
raw: i
|
192
192
|
}) : (
|
@@ -196,7 +196,7 @@ class Z {
|
|
196
196
|
)
|
197
197
|
);
|
198
198
|
return {
|
199
|
-
className: this.constructRaw(l,
|
199
|
+
className: this.constructRaw(l, s, t, e, r, a),
|
200
200
|
cssRules: o ? Array.isArray(n) ? o : typeof o == "string" && (o.includes(":") || o.startsWith("value:")) ? o.startsWith("value:") ? o.slice(6) : this.toKebabCase(String(o)) : this.toKebabCase(String(o)) : null,
|
201
201
|
value: typeof o == "string" && o.includes(":") ? null : p,
|
202
202
|
prefix: l
|
@@ -204,17 +204,17 @@ class Z {
|
|
204
204
|
}
|
205
205
|
return null;
|
206
206
|
}
|
207
|
-
parseValuePattern(
|
208
|
-
if (!
|
209
|
-
return
|
210
|
-
const [i, n] =
|
211
|
-
if (
|
207
|
+
parseValuePattern(s, t, e, l, r, a) {
|
208
|
+
if (!t.includes("{0}") && !t.includes("{1") && !t.includes("||"))
|
209
|
+
return t;
|
210
|
+
const [i, n] = t.split("||").map((c) => c.trim()), h = this.processValue(e, l, s), u = this.processValue(r, a, s);
|
211
|
+
if (t.includes("{0}") && t.includes("{1") || t.includes("{1")) {
|
212
212
|
let c = i;
|
213
|
-
if (e && (c = c.replace(/\{0\}/g, h)),
|
214
|
-
|
215
|
-
const
|
213
|
+
if (e && (c = c.replace(/\{0\}/g, h)), t.includes("{1")) {
|
214
|
+
t.includes("{1}") && (r ? c = r.startsWith("[") ? u : c.replace(/\{1\}/g, u) : c = n || i);
|
215
|
+
const $ = /\{1([^}]*)\}/g;
|
216
216
|
let f;
|
217
|
-
for (; (f =
|
217
|
+
for (; (f = $.exec(c)) !== null; ) {
|
218
218
|
const p = f[0], y = f[1].trim();
|
219
219
|
let o = u;
|
220
220
|
!o && y.includes("|") ? o = y.split("|")[1].trim() : o || (o = ""), c = e.startsWith("[") ? h : c.replace(p, o);
|
@@ -224,55 +224,55 @@ class Z {
|
|
224
224
|
} else
|
225
225
|
return e ? e.startsWith("[") ? h : i.replace(/\{0\}/g, h) : n || i;
|
226
226
|
}
|
227
|
-
getParentClass(
|
227
|
+
getParentClass(s) {
|
228
228
|
return Object.keys(this.classes).filter(
|
229
|
-
(
|
230
|
-
this.classes[
|
231
|
-
|
229
|
+
(t) => Object.prototype.hasOwnProperty.call(
|
230
|
+
this.classes[t],
|
231
|
+
s
|
232
232
|
)
|
233
233
|
);
|
234
234
|
}
|
235
|
-
processCustomClass(
|
236
|
-
if (!
|
237
|
-
const i = this.getParentClass(t);
|
235
|
+
processCustomClass(s, t = "", e = "", l = "", r = "", a = "") {
|
236
|
+
if (!s) return null;
|
237
|
+
const i = this.getParentClass(s), n = t && s.endsWith(`-${t}${e}`);
|
238
238
|
if (i.length > 0) {
|
239
|
-
const
|
239
|
+
const h = i.map((u) => {
|
240
240
|
const c = this.classes[u];
|
241
|
-
if (!c || s && !c[
|
241
|
+
if (!c || t && !n && c[s] && !c[s].includes("{0}") && !c[s].includes("|"))
|
242
242
|
return null;
|
243
|
-
const
|
244
|
-
t,
|
245
|
-
c[t] || "",
|
243
|
+
const $ = this.parseValuePattern(
|
246
244
|
s,
|
245
|
+
c[s] || "",
|
246
|
+
t,
|
247
247
|
e,
|
248
248
|
r,
|
249
249
|
a
|
250
250
|
);
|
251
|
-
return `${this.toKebabCase(String(u))}: ${
|
252
|
-
}).filter(Boolean).join("; ")
|
251
|
+
return `${this.toKebabCase(String(u))}: ${$}`;
|
252
|
+
}).filter(Boolean).join("; ");
|
253
253
|
return {
|
254
|
-
className:
|
255
|
-
cssRules:
|
254
|
+
className: n ? s : this.constructRaw(l, s, t, e, r, a),
|
255
|
+
cssRules: h,
|
256
256
|
value: null,
|
257
257
|
prefix: l
|
258
258
|
};
|
259
259
|
}
|
260
260
|
return null;
|
261
261
|
}
|
262
|
-
process(
|
262
|
+
process(s) {
|
263
263
|
try {
|
264
|
-
const
|
265
|
-
for (const l of
|
264
|
+
const t = Array.isArray(s) ? s : s.split(/\s+/), e = [];
|
265
|
+
for (const l of t)
|
266
266
|
try {
|
267
267
|
if (!l) continue;
|
268
268
|
const r = this.parse(l);
|
269
269
|
if (!r) continue;
|
270
270
|
const [a, i, n, h, u, c] = r;
|
271
271
|
if (!i) continue;
|
272
|
-
const
|
272
|
+
const $ = this.getParentClass(`${i}-${n}`).length > 0 ? `${i}-${n}` : i;
|
273
273
|
try {
|
274
274
|
const f = this.processCustomClass(
|
275
|
-
|
275
|
+
$,
|
276
276
|
n,
|
277
277
|
h,
|
278
278
|
a,
|
@@ -322,8 +322,8 @@ class Z {
|
|
322
322
|
console.warn(`Failed to process class \`${l}\`:`, r);
|
323
323
|
}
|
324
324
|
return e;
|
325
|
-
} catch (
|
326
|
-
return console.error("Critical error in process method:",
|
325
|
+
} catch (t) {
|
326
|
+
return console.error("Critical error in process method:", t), [];
|
327
327
|
}
|
328
328
|
}
|
329
329
|
}
|
package/dist/index.iife.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var __tenoxui_moxie__=function(
|
1
|
+
var __tenoxui_moxie__=function($){"use strict";var _=Object.defineProperty;var S=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var w=($,g,m)=>g in $?_($,g,{enumerable:!0,configurable:!0,writable:!0,value:m}):$[g]=m,x=($,g)=>{for(var m in g||(g={}))j.call(g,m)&&w($,m,g[m]);if(S)for(var m of S(g))V.call(g,m)&&w($,m,g[m]);return $};class g{constructor({property:t={},values:s={},classes:e={}}={}){this.property=x({moxie:({key:i,secondValue:r})=>r?null:i},t),this.values=s,this.classes=e}toKebabCase(t){if(/^(webkit|moz|ms|o)[A-Z]/.test(t)){const s=t.match(/^(webkit|moz|ms|o)/);if(s){const e=s[0];return`-${e}${t.slice(e.length).replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}`}}return t.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`)}escapeCSSSelector(t){return t.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(t){if(!t)return[];const s=new Set;return Object.entries(t).forEach(([e,i])=>{i&&typeof i=="object"&&Object.keys(i).forEach(r=>{s.add(r)})}),Array.from(s)}getTypePrefixes(t=[]){const s=this.property,e=this.classes,i=Object.keys(s);if(!e)return[...i,...t].sort((l,n)=>n.length-l.length);const a=[...this.getAllClassNames(e)];return[...i,...a,...t].sort((l,n)=>n.length-l.length)}regexp(t){const s=this.getTypePrefixes(t).join("|"),e="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",a="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+i+"|"+r+"))|"+e+"|"+i+"|"+r,l=`(${s}|\\[[^\\]]+\\])`,n="(?:-)",h="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))",u="([a-zA-Z%]*)",c="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:a,type:l,separator:n,value:h,unit:u,secondValuePattern:c,all:"^(?:("+a+"):)?"+l+n+h+u+c+"$"}}parse(t,s){const e=this.regexp(s),i=t.match(new RegExp(e.all));if(i){const[,a,l,n,h,u,c]=i;return[a,l,n,h||"",u,c]}const r=t.match(new RegExp(`^(?:(${e.prefix}):)?${e.type}$`));return r?[r[1],r[2],"","",void 0,void 0,t]:null}constructRaw(t,s,e,i,r,a){return`${t?`${t}:`:""}${s}${e?"-":""}${e}${i}${r?`/${r}${a}`:""}`}processValue(t,s,e){if(!t)return"";const i=r=>r.replace(/\{([^}]+)\}/g,(a,l)=>{const n=this.values,h=n!==null?typeof n[e]=="object"?n[e][l]:n[l]:void 0;return typeof h=="string"?h:a});if(typeof this.values=="object"&&this.values!==null&&(this.values[e]&&typeof this.values[e]=="object"&&this.values[e][t]||this.values[t]))return typeof this.values[e]=="object"&&this.values[e]!==null?this.values[e][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("{")?i(r):r.startsWith("--")?`var(${r})`:r}return t+(s||"")}processShorthand(t="",s="",e="",i,r="",a="",l){const n=this.property[t];if(typeof n=="object"&&!Array.isArray(n)&&!("property"in n))return null;const h=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let u=null,c=s||"";const A=c.match(h);if(A&&(u=A[1].trim(),c=A[2].trim()),(typeof n=="string"&&!n.includes(":")||Array.isArray(n))&&(!s||s.includes(u+":")||r))return null;let f;s.includes(u+":")?f=s.startsWith("(")?`(${c})`:`[${c}]`:f=s;const p=this.processValue(f,e,t),y=this.processValue(r,a,t);if(t.startsWith("[")&&t.endsWith("]")){if(!s||r)return null;const o=t.slice(1,-1).split(",").map(C=>C.trim().startsWith("--")?String(C.trim()):this.toKebabCase(String(C.trim())));return{className:this.constructRaw(i,t,s,e),cssRules:o.length===1?o[0]:o,value:p,prefix:i}}if(n){if(typeof n=="object"&&"property"in n){const C=n.group&&this.values[n.group][p]?this.values[n.group][p]:e?s:p,d=typeof n.property=="function"?n.property({value:s.startsWith("[")?p:C,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":a?r:y,secondUnit:s.startsWith("[")?"":a,key:u,raw:l}):n.property,b=n.value||"{0}";let W;if(typeof b=="function")W=b({value:C,unit:e,secondValue:a?r:y,secondUnit:a,key:u,raw:l});else if(typeof b=="string"){const P=n.group||t,R=this.processValue(f,e,P);this.values[P]&&typeof this.values[P]=="object"&&this.values[P][f]?W=this.values[P][f]:b.includes("{")?W=this.parseValuePattern(P,b,R,"",y,""):W=p}else if(Array.isArray(b)){if(!b.includes(s+e)||r)return null;W=s+e}else W=null;return typeof n.property=="string"&&typeof b=="string"&&(s.includes(u+":")||!b.includes("{1")&&r)?null:{className:this.constructRaw(i,t,s,e,r,a),cssRules:d?Array.isArray(d)?d:typeof d=="string"&&(d.includes(":")||d.includes("value:"))?d.includes("value:")?d.slice(6):this.toKebabCase(String(d)):this.toKebabCase(String(d)):null,value:b===null||d===null||d.includes(":")||d.includes("value:")?null:s.startsWith("[")?p:W,prefix:i}}const o=typeof n=="function"?n({value:s.startsWith("[")?p:e?s:p,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":a?r:y,secondUnit:s.startsWith("[")?"":a,key:u,raw:l}):n;return{className:this.constructRaw(i,t,s,e,r,a),cssRules:o?Array.isArray(n)?o:typeof o=="string"&&(o.includes(":")||o.startsWith("value:"))?o.startsWith("value:")?o.slice(6):this.toKebabCase(String(o)):this.toKebabCase(String(o)):null,value:typeof o=="string"&&o.includes(":")?null:p,prefix:i}}return null}parseValuePattern(t,s,e,i,r,a){if(!s.includes("{0}")&&!s.includes("{1")&&!s.includes("||"))return s;const[l,n]=s.split("||").map(c=>c.trim()),h=this.processValue(e,i,t),u=this.processValue(r,a,t);if(s.includes("{0}")&&s.includes("{1")||s.includes("{1")){let c=l;if(e&&(c=c.replace(/\{0\}/g,h)),s.includes("{1")){s.includes("{1}")&&(r?c=r.startsWith("[")?u:c.replace(/\{1\}/g,u):c=n||l);const A=/\{1([^}]*)\}/g;let f;for(;(f=A.exec(c))!==null;){const p=f[0],y=f[1].trim();let o=u;!o&&y.includes("|")?o=y.split("|")[1].trim():o||(o=""),c=e.startsWith("[")?h:c.replace(p,o)}}return e?c:n||l}else return e?e.startsWith("[")?h:l.replace(/\{0\}/g,h):n||l}getParentClass(t){return Object.keys(this.classes).filter(s=>Object.prototype.hasOwnProperty.call(this.classes[s],t))}processCustomClass(t,s="",e="",i="",r="",a=""){if(!t)return null;const l=this.getParentClass(t),n=s&&t.endsWith(`-${s}${e}`);if(l.length>0){const h=l.map(u=>{const c=this.classes[u];if(!c||s&&!n&&c[t]&&!c[t].includes("{0}")&&!c[t].includes("|"))return null;const A=this.parseValuePattern(t,c[t]||"",s,e,r,a);return`${this.toKebabCase(String(u))}: ${A}`}).filter(Boolean).join("; ");return{className:n?t:this.constructRaw(i,t,s,e,r,a),cssRules:h,value:null,prefix:i}}return null}process(t){try{const s=Array.isArray(t)?t:t.split(/\s+/),e=[];for(const i of s)try{if(!i)continue;const r=this.parse(i);if(!r)continue;const[a,l,n,h,u,c]=r;if(!l)continue;const A=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const f=this.processCustomClass(A,n,h,a,u,c);if(f){const{className:p,cssRules:y,prefix:o}=f;if(!y||y==="null")continue;e.push({className:this.escapeCSSSelector(p),cssRules:y,value:null,prefix:o,raw:[...r,this.constructRaw(o,l,n,h,u,c)]});continue}}catch(f){console.warn(`Error processing custom class "${i}":`,f)}try{const f=this.processShorthand(l,n,h,a,u,c,r);if(f){const{className:p,cssRules:y,value:o,prefix:C}=f;if(!y||y==="null")continue;e.push({className:this.escapeCSSSelector(p),cssRules:y,value:o,prefix:C,raw:[...r,this.constructRaw(a,l,n,h,u,c)]})}}catch(f){console.warn(`Error processing shorthand "${i}":`,f)}}catch(r){console.warn(`Failed to process class \`${i}\`:`,r)}return e}catch(s){return console.error("Critical error in process method:",s),[]}}}return $.TenoxUI=g,$.default=g,Object.defineProperties($,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),$}({});
|
package/dist/index.umd.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
(function(d,p){typeof exports=="object"&&typeof module!="undefined"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(d=typeof globalThis!="undefined"?globalThis:d||self,p(d.__tenoxui_moxie__={}))})(this,function(d){"use strict";var _=Object.defineProperty;var P=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var S=(d,p
|
1
|
+
(function(d,p){typeof exports=="object"&&typeof module!="undefined"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(d=typeof globalThis!="undefined"?globalThis:d||self,p(d.__tenoxui_moxie__={}))})(this,function(d){"use strict";var _=Object.defineProperty;var P=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var S=(d,p,m)=>p in d?_(d,p,{enumerable:!0,configurable:!0,writable:!0,value:m}):d[p]=m,w=(d,p)=>{for(var m in p||(p={}))j.call(p,m)&&S(d,m,p[m]);if(P)for(var m of P(p))V.call(p,m)&&S(d,m,p[m]);return d};class p{constructor({property:t={},values:s={},classes:e={}}={}){this.property=w({moxie:({key:i,secondValue:r})=>r?null:i},t),this.values=s,this.classes=e}toKebabCase(t){if(/^(webkit|moz|ms|o)[A-Z]/.test(t)){const s=t.match(/^(webkit|moz|ms|o)/);if(s){const e=s[0];return`-${e}${t.slice(e.length).replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}`}}return t.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`)}escapeCSSSelector(t){return t.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}getAllClassNames(t){if(!t)return[];const s=new Set;return Object.entries(t).forEach(([e,i])=>{i&&typeof i=="object"&&Object.keys(i).forEach(r=>{s.add(r)})}),Array.from(s)}getTypePrefixes(t=[]){const s=this.property,e=this.classes,i=Object.keys(s);if(!e)return[...i,...t].sort((l,n)=>n.length-l.length);const o=[...this.getAllClassNames(e)];return[...i,...o,...t].sort((l,n)=>n.length-l.length)}regexp(t){const s=this.getTypePrefixes(t).join("|"),e="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",o="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+i+"|"+r+"))|"+e+"|"+i+"|"+r,l=`(${s}|\\[[^\\]]+\\])`,n="(?:-)",h="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))",u="([a-zA-Z%]*)",c="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:o,type:l,separator:n,value:h,unit:u,secondValuePattern:c,all:"^(?:("+o+"):)?"+l+n+h+u+c+"$"}}parse(t,s){const e=this.regexp(s),i=t.match(new RegExp(e.all));if(i){const[,o,l,n,h,u,c]=i;return[o,l,n,h||"",u,c]}const r=t.match(new RegExp(`^(?:(${e.prefix}):)?${e.type}$`));return r?[r[1],r[2],"","",void 0,void 0,t]:null}constructRaw(t,s,e,i,r,o){return`${t?`${t}:`:""}${s}${e?"-":""}${e}${i}${r?`/${r}${o}`:""}`}processValue(t,s,e){if(!t)return"";const i=r=>r.replace(/\{([^}]+)\}/g,(o,l)=>{const n=this.values,h=n!==null?typeof n[e]=="object"?n[e][l]:n[l]:void 0;return typeof h=="string"?h:o});if(typeof this.values=="object"&&this.values!==null&&(this.values[e]&&typeof this.values[e]=="object"&&this.values[e][t]||this.values[t]))return typeof this.values[e]=="object"&&this.values[e]!==null?this.values[e][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("{")?i(r):r.startsWith("--")?`var(${r})`:r}return t+(s||"")}processShorthand(t="",s="",e="",i,r="",o="",l){const n=this.property[t];if(typeof n=="object"&&!Array.isArray(n)&&!("property"in n))return null;const h=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let u=null,c=s||"";const A=c.match(h);if(A&&(u=A[1].trim(),c=A[2].trim()),(typeof n=="string"&&!n.includes(":")||Array.isArray(n))&&(!s||s.includes(u+":")||r))return null;let f;s.includes(u+":")?f=s.startsWith("(")?`(${c})`:`[${c}]`:f=s;const y=this.processValue(f,e,t),g=this.processValue(r,o,t);if(t.startsWith("[")&&t.endsWith("]")){if(!s||r)return null;const a=t.slice(1,-1).split(",").map(C=>C.trim().startsWith("--")?String(C.trim()):this.toKebabCase(String(C.trim())));return{className:this.constructRaw(i,t,s,e),cssRules:a.length===1?a[0]:a,value:y,prefix:i}}if(n){if(typeof n=="object"&&"property"in n){const C=n.group&&this.values[n.group][y]?this.values[n.group][y]:e?s:y,$=typeof n.property=="function"?n.property({value:s.startsWith("[")?y:C,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":o?r:g,secondUnit:s.startsWith("[")?"":o,key:u,raw:l}):n.property,b=n.value||"{0}";let W;if(typeof b=="function")W=b({value:C,unit:e,secondValue:o?r:g,secondUnit:o,key:u,raw:l});else if(typeof b=="string"){const x=n.group||t,R=this.processValue(f,e,x);this.values[x]&&typeof this.values[x]=="object"&&this.values[x][f]?W=this.values[x][f]:b.includes("{")?W=this.parseValuePattern(x,b,R,"",g,""):W=y}else if(Array.isArray(b)){if(!b.includes(s+e)||r)return null;W=s+e}else W=null;return typeof n.property=="string"&&typeof b=="string"&&(s.includes(u+":")||!b.includes("{1")&&r)?null:{className:this.constructRaw(i,t,s,e,r,o),cssRules:$?Array.isArray($)?$:typeof $=="string"&&($.includes(":")||$.includes("value:"))?$.includes("value:")?$.slice(6):this.toKebabCase(String($)):this.toKebabCase(String($)):null,value:b===null||$===null||$.includes(":")||$.includes("value:")?null:s.startsWith("[")?y:W,prefix:i}}const a=typeof n=="function"?n({value:s.startsWith("[")?y:e?s:y,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":o?r:g,secondUnit:s.startsWith("[")?"":o,key:u,raw:l}):n;return{className:this.constructRaw(i,t,s,e,r,o),cssRules:a?Array.isArray(n)?a:typeof a=="string"&&(a.includes(":")||a.startsWith("value:"))?a.startsWith("value:")?a.slice(6):this.toKebabCase(String(a)):this.toKebabCase(String(a)):null,value:typeof a=="string"&&a.includes(":")?null:y,prefix:i}}return null}parseValuePattern(t,s,e,i,r,o){if(!s.includes("{0}")&&!s.includes("{1")&&!s.includes("||"))return s;const[l,n]=s.split("||").map(c=>c.trim()),h=this.processValue(e,i,t),u=this.processValue(r,o,t);if(s.includes("{0}")&&s.includes("{1")||s.includes("{1")){let c=l;if(e&&(c=c.replace(/\{0\}/g,h)),s.includes("{1")){s.includes("{1}")&&(r?c=r.startsWith("[")?u:c.replace(/\{1\}/g,u):c=n||l);const A=/\{1([^}]*)\}/g;let f;for(;(f=A.exec(c))!==null;){const y=f[0],g=f[1].trim();let a=u;!a&&g.includes("|")?a=g.split("|")[1].trim():a||(a=""),c=e.startsWith("[")?h:c.replace(y,a)}}return e?c:n||l}else return e?e.startsWith("[")?h:l.replace(/\{0\}/g,h):n||l}getParentClass(t){return Object.keys(this.classes).filter(s=>Object.prototype.hasOwnProperty.call(this.classes[s],t))}processCustomClass(t,s="",e="",i="",r="",o=""){if(!t)return null;const l=this.getParentClass(t),n=s&&t.endsWith(`-${s}${e}`);if(l.length>0){const h=l.map(u=>{const c=this.classes[u];if(!c||s&&!n&&c[t]&&!c[t].includes("{0}")&&!c[t].includes("|"))return null;const A=this.parseValuePattern(t,c[t]||"",s,e,r,o);return`${this.toKebabCase(String(u))}: ${A}`}).filter(Boolean).join("; ");return{className:n?t:this.constructRaw(i,t,s,e,r,o),cssRules:h,value:null,prefix:i}}return null}process(t){try{const s=Array.isArray(t)?t:t.split(/\s+/),e=[];for(const i of s)try{if(!i)continue;const r=this.parse(i);if(!r)continue;const[o,l,n,h,u,c]=r;if(!l)continue;const A=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const f=this.processCustomClass(A,n,h,o,u,c);if(f){const{className:y,cssRules:g,prefix:a}=f;if(!g||g==="null")continue;e.push({className:this.escapeCSSSelector(y),cssRules:g,value:null,prefix:a,raw:[...r,this.constructRaw(a,l,n,h,u,c)]});continue}}catch(f){console.warn(`Error processing custom class "${i}":`,f)}try{const f=this.processShorthand(l,n,h,o,u,c,r);if(f){const{className:y,cssRules:g,value:a,prefix:C}=f;if(!g||g==="null")continue;e.push({className:this.escapeCSSSelector(y),cssRules:g,value:a,prefix:C,raw:[...r,this.constructRaw(o,l,n,h,u,c)]})}}catch(f){console.warn(`Error processing shorthand "${i}":`,f)}}catch(r){console.warn(`Failed to process class \`${i}\`:`,r)}return e}catch(s){return console.error("Critical error in process method:",s),[]}}}d.TenoxUI=p,d.default=p,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|