@tenoxui/moxie 0.5.0-alpha.1 → 0.5.0-alpha.2
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.d.ts +0 -1
- package/dist/index.es.js +152 -154
- 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 Z=Object.defineProperty;var W=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,
|
1
|
+
"use strict";var Z=Object.defineProperty;var W=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var x=(d,t,s)=>t in d?Z(d,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):d[t]=s,P=(d,t)=>{for(var s in t||(t={}))_.call(t,s)&&x(d,s,t[s]);if(W)for(var s of W(t))w.call(t,s)&&x(d,s,t[s]);return d};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class S{constructor({property:t={},values:s={},classes:e={}}={}){this.property=P({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 c=[...this.getAllClassNames(e)];return[...l,...c,...t].sort((i,n)=>n.length-i.length)}regexp(t){const s=this.getTypePrefixes(t).join("|"),e="\\[[^\\]]+\\]",l="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",c="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+l+"|"+r+"))|"+e+"|"+l+"|"+r,i=`(${s}|\\[[^\\]]+\\])`,n="(?:-)",u="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+l+"|(?:\\$[^\\s\\/]+))",a="([a-zA-Z%]*)",o="(?:\\/(-?(?:\\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:c,type:i,separator:n,value:u,unit:a,secondValuePattern:o,all:"(?:("+c+"):)?"+i+n+u+a+o}}parse(t,s){const e=this.regexp(s),l=t.match(new RegExp(e.all));if(l){const[,c,i,n,u,a,o]=l,y=`${c?`${c}:`:""}${i}-${n}${u}${a?`/${a}${o}`:""}`;return[c,i,n,u||"",a,o,y]}const r=t.match(new RegExp(`(?:(${e.prefix}):)?${e.type}`));return r?[r[1],r[2],"","",void 0,void 0,t]:null}processValue(t,s,e){if(!t)return"";const l=r=>r.replace(/\{([^}]+)\}/g,(c,i)=>{const n=this.values,u=n!==null?typeof n[e]=="object"?n[e][i]:n[i]:void 0;return typeof u=="string"?u:c});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="",c="",i){const n=this.property[t],u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let a=null,o=s||"";const y=o.match(u);if(y&&(a=y[1].trim(),o=y[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!s||s.includes(a+":")||r))return null;let h;s.includes(a+":")?h=s.startsWith("(")?`(${o})`:`[${o}]`:h=s;const $=this.processValue(h,e,t),p=this.processValue(r,c,t);if(t.startsWith("[")&&t.endsWith("]")){if(!s||r)return null;const f=t.slice(1,-1).split(",").map(m=>m.trim().startsWith("--")?String(m.trim()):this.toKebabCase(String(m.trim())));return{className:`${t}-${s}${e}`,cssRules:f.length===1?f[0]:f,value:$,prefix:l}}if(n){if(typeof n=="object"&&"property"in n){const m=n.group&&this.values[n.group][$]?this.values[n.group][$]:e?s:$,g=typeof n.property=="function"?n.property({value:s.startsWith("[")?$:m,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":c?r:p,secondUnit:s.startsWith("[")?"":c,key:a,raw:i}):n.property,b=n.value||"{0}";let C;if(typeof b=="function")C=b({value:m,unit:e,secondValue:c?r:p,secondUnit:c,key:a,raw:i});else if(typeof b=="string"){const A=n.group||t,V=this.processValue(h,e,A);this.values[A]&&typeof this.values[A]=="object"&&this.values[A][h]?C=this.values[A][h]:b.includes("{")?C=this.parseValuePattern(A,b,V,"",p,""):C=$}else C=null;const j=`${t}${s?`-${s}${e}`:""}${r?`/${r}${c}`:""}`;return typeof n.property=="string"&&typeof b=="string"&&(s.includes(a+":")||!b.includes("{1")&&r)?null:{className:j,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:b===null||g===null||g.includes(":")||g.includes("value:")?null:s.startsWith("[")?$:C,prefix:l}}const f=typeof n=="function"?n({value:s.startsWith("[")?$:e?s:$,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":c?r:p,secondUnit:s.startsWith("[")?"":c,key:a,raw:i}):n;return{className:`${t}${s?"-"+s+e:""}${r?`/${r}${c}`:""}`,cssRules:f?Array.isArray(n)?f:typeof f=="string"&&(f.includes(":")||f.startsWith("value:"))?f.startsWith("value:")?f.slice(6):this.toKebabCase(String(f)):this.toKebabCase(String(f)):null,value:typeof f=="string"&&f.includes(":")?null:$,prefix:l}}return null}parseValuePattern(t,s,e,l,r,c){if(!s.includes("{0}")&&!s.includes("{1")&&!s.includes("||"))return s;const[i,n]=s.split("||").map(o=>o.trim()),u=this.processValue(e,l,t),a=this.processValue(r,c,t);if(s.includes("{0}")&&s.includes("{1")||s.includes("{1")){let o=i;if(e&&(o=o.replace("{0}",u)),s.includes("{1")){const y=o.match(/{1([^}]*)}/);if(s.includes("{1}"))r?o=r.startsWith("[")?a:o.replace("{1}",a):o=n;else if(y){const h=y[0],$=y[1].trim();let p=a;!p&&$.includes("|")?p=$.split("|")[1].trim():p||(p=""),o=e.startsWith("[")?u:o.replace(h,p)}}return e?o:n||i}else return e?e.startsWith("[")?u:i.replace("{0}",u):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="",c=""){if(!t)return null;const i=this.getParentClass(t);if(i.length>0){const n=i.map(o=>{const y=this.classes[o];if(!y||s&&!y[t].includes("||")||s&&!y[t].includes("|"))return null;const h=this.parseValuePattern(t,y[t]||"",s,e,r,c);return`${this.toKebabCase(String(o))}: ${h}`}).filter(Boolean).join("; "),u=t.slice(-(s+e).length),a=`${t}${s?`-${s}${e}`:""}${r?`/${r}${c}`:""}`;return{className:s===u?t:a,cssRules:n,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[c,i,n,u,a,o]=r;if(!i)continue;const y=this.getParentClass(`${i}-${n}`).length>0?`${i}-${n}`:i;try{const h=this.processCustomClass(y,n,u,c,a,o);if(h){const{className:$,cssRules:p,prefix:f}=h;if(!p||p==="null")continue;e.push({className:$,cssRules:p,value:null,prefix:f,raw:r});continue}}catch(h){console.warn(`Error processing custom class "${l}":`,h)}try{const h=this.processShorthand(i,n,u,c,a,o,r);if(h){const{className:$,cssRules:p,value:f,prefix:m}=h;if(!p||p==="null")continue;e.push({className:$,cssRules:p,value:f,prefix:m,raw:r})}}catch(h){console.warn(`Error processing shorthand "${l}":`,h)}}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.d.ts
CHANGED
@@ -18,7 +18,6 @@ export declare class TenoxUI {
|
|
18
18
|
secondValuePattern: string;
|
19
19
|
all: string;
|
20
20
|
};
|
21
|
-
private generateClassNameRegEx;
|
22
21
|
parse(className: string, safelist?: string[]): Parsed;
|
23
22
|
processValue(value: string, unit: string, group: string): string;
|
24
23
|
processShorthand(type: string | undefined, value: string | undefined, unit: string | undefined, prefix: string | undefined, secondValue?: string | undefined, secondUnit?: string | undefined, raw?: Parsed): ProcessedStyle | null;
|
package/dist/index.es.js
CHANGED
@@ -1,129 +1,127 @@
|
|
1
|
-
var
|
1
|
+
var S = Object.defineProperty;
|
2
2
|
var W = Object.getOwnPropertySymbols;
|
3
|
-
var Z = Object.prototype.hasOwnProperty,
|
4
|
-
var x = (
|
5
|
-
for (var
|
6
|
-
Z.call(
|
3
|
+
var Z = Object.prototype.hasOwnProperty, w = Object.prototype.propertyIsEnumerable;
|
4
|
+
var x = (d, t, s) => t in d ? S(d, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : d[t] = s, P = (d, t) => {
|
5
|
+
for (var s in t || (t = {}))
|
6
|
+
Z.call(t, s) && x(d, s, t[s]);
|
7
7
|
if (W)
|
8
|
-
for (var
|
9
|
-
|
10
|
-
return
|
8
|
+
for (var s of W(t))
|
9
|
+
w.call(t, s) && x(d, s, t[s]);
|
10
|
+
return d;
|
11
11
|
};
|
12
|
-
class
|
13
|
-
constructor({ property:
|
12
|
+
class R {
|
13
|
+
constructor({ property: t = {}, values: s = {}, classes: e = {} } = {}) {
|
14
14
|
this.property = P({
|
15
15
|
// use moxie-* 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: i, secondValue: r }) => r ? null : i
|
18
|
-
},
|
18
|
+
}, t), this.values = s, 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(t) {
|
21
|
+
if (/^(webkit|moz|ms|o)[A-Z]/.test(t)) {
|
22
|
+
const s = t.match(/^(webkit|moz|ms|o)/);
|
23
|
+
if (s) {
|
24
|
+
const e = s[0];
|
25
|
+
return `-${e}${t.slice(e.length).replace(/[A-Z]/g, (i) => `-${i.toLowerCase()}`)}`;
|
26
26
|
}
|
27
27
|
}
|
28
|
-
return
|
28
|
+
return t.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
|
29
29
|
}
|
30
|
-
escapeCSSSelector(
|
31
|
-
return
|
30
|
+
escapeCSSSelector(t) {
|
31
|
+
return t.replace(/^(\d)/, "\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g, "\\$1");
|
32
32
|
}
|
33
|
-
getAllClassNames(
|
34
|
-
if (!
|
35
|
-
const
|
36
|
-
return Object.entries(
|
33
|
+
getAllClassNames(t) {
|
34
|
+
if (!t) return [];
|
35
|
+
const s = /* @__PURE__ */ new Set();
|
36
|
+
return Object.entries(t).forEach(([e, i]) => {
|
37
37
|
i && typeof i == "object" && Object.keys(i).forEach((r) => {
|
38
|
-
|
38
|
+
s.add(r);
|
39
39
|
});
|
40
|
-
}), Array.from(
|
40
|
+
}), Array.from(s);
|
41
41
|
}
|
42
|
-
getTypePrefixes(
|
43
|
-
const
|
42
|
+
getTypePrefixes(t = []) {
|
43
|
+
const s = this.property, e = this.classes, i = Object.keys(s);
|
44
44
|
if (!e)
|
45
|
-
return [...i, ...
|
45
|
+
return [...i, ...t].sort((l, n) => n.length - l.length);
|
46
46
|
const c = [...this.getAllClassNames(e)];
|
47
|
-
return [...i, ...c, ...
|
47
|
+
return [...i, ...c, ...t].sort((l, n) => n.length - l.length);
|
48
48
|
}
|
49
|
-
regexp(
|
50
|
-
const
|
49
|
+
regexp(t) {
|
50
|
+
const s = this.getTypePrefixes(t).join("|"), e = "\\[[^\\]]+\\]", i = "\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)", r = "\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}", c = (
|
51
51
|
// Simple prefix (hover, md, focus, etc.)
|
52
52
|
"[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:" + e + "|" + i + "|" + r + "))|" + // Direct bracket, parenthesis, or brace content
|
53
53
|
e + "|" + i + "|" + r
|
54
|
-
), l = `(${
|
54
|
+
), l = `(${s}|\\[[^\\]]+\\])`, n = "(?:-)", u = "(-?(?:\\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
|
-
i + "|(?:\\$[^\\s\\/]+))",
|
57
|
+
i + "|(?:\\$[^\\s\\/]+))", o = "([a-zA-Z%]*)", a = "(?:\\/(-?(?:\\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%]*))?";
|
58
58
|
return {
|
59
59
|
prefix: c,
|
60
60
|
type: l,
|
61
61
|
separator: n,
|
62
|
-
value:
|
63
|
-
unit:
|
62
|
+
value: u,
|
63
|
+
unit: o,
|
64
64
|
secondValuePattern: a,
|
65
|
-
all: "(?:(" + c + "):)?" + l + n +
|
65
|
+
all: "(?:(" + c + "):)?" + l + n + u + o + a
|
66
66
|
};
|
67
67
|
}
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
const
|
75
|
-
|
76
|
-
const [, r, c, l, n, o, u] = i, a = l ? l === "dummy" ? "" : l.replace("-dummy", "") : "", $ = o ? o === "dummy" ? "" : o.replace("-dummy", "") : "", h = `${r ? `${r}:` : ""}${c}${a ? `-${a}` : ""}${n}${o ? `/${$}${u}` : ""}`;
|
77
|
-
return [r, c, a, n || "", $, u, h];
|
68
|
+
parse(t, s) {
|
69
|
+
const e = this.regexp(s), i = t.match(new RegExp(e.all));
|
70
|
+
if (i) {
|
71
|
+
const [, c, l, n, u, o, a] = i, y = `${c ? `${c}:` : ""}${l}-${n}${u}${o ? `/${o}${a}` : ""}`;
|
72
|
+
return [c, l, n, u || "", o, a, y];
|
73
|
+
}
|
74
|
+
const r = t.match(new RegExp(`(?:(${e.prefix}):)?${e.type}`));
|
75
|
+
return r ? [r[1], r[2], "", "", void 0, void 0, t] : null;
|
78
76
|
}
|
79
77
|
// unique value parser
|
80
|
-
processValue(
|
81
|
-
if (!
|
78
|
+
processValue(t, s, e) {
|
79
|
+
if (!t) return "";
|
82
80
|
const i = (r) => r.replace(/\{([^}]+)\}/g, (c, l) => {
|
83
|
-
const n = this.values,
|
84
|
-
return typeof
|
81
|
+
const n = this.values, u = n !== null ? typeof n[e] == "object" ? n[e][l] : n[l] : void 0;
|
82
|
+
return typeof u == "string" ? u : c;
|
85
83
|
});
|
86
|
-
if (typeof this.values == "object" && this.values !== null && (this.values[e] && typeof this.values[e] == "object" && this.values[e][
|
87
|
-
return typeof this.values[e] == "object" && this.values[e] !== null ? this.values[e][
|
88
|
-
if (
|
89
|
-
return `var(--${
|
90
|
-
if (
|
91
|
-
const r =
|
84
|
+
if (typeof this.values == "object" && this.values !== null && (this.values[e] && typeof this.values[e] == "object" && this.values[e][t] || this.values[t]))
|
85
|
+
return typeof this.values[e] == "object" && this.values[e] !== null ? this.values[e][t] : this.values[t];
|
86
|
+
if (t.startsWith("$"))
|
87
|
+
return `var(--${t.slice(1)})`;
|
88
|
+
if (t.startsWith("[") && t.endsWith("]") || t.startsWith("(") && t.endsWith(")")) {
|
89
|
+
const r = t.slice(1, -1).replace(/\\\_/g, "m0x13c55").replace(/\_/g, " ").replace(/m0x13c55/g, "_");
|
92
90
|
return r.includes("{") ? i(r) : r.startsWith("--") ? `var(${r})` : r;
|
93
91
|
}
|
94
|
-
return
|
92
|
+
return t + (s || "");
|
95
93
|
}
|
96
|
-
processShorthand(
|
97
|
-
const n = this.property[
|
98
|
-
let
|
99
|
-
const
|
100
|
-
if (
|
94
|
+
processShorthand(t = "", s = "", e = "", i, r = "", c = "", l) {
|
95
|
+
const n = this.property[t], u = /^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;
|
96
|
+
let o = null, a = s || "";
|
97
|
+
const y = a.match(u);
|
98
|
+
if (y && (o = y[1].trim(), a = y[2].trim()), (typeof n == "string" || Array.isArray(n)) && (!s || s.includes(o + ":") || r))
|
101
99
|
return null;
|
102
100
|
let h;
|
103
|
-
|
104
|
-
const
|
105
|
-
if (
|
106
|
-
if (!
|
107
|
-
const
|
108
|
-
(
|
101
|
+
s.includes(o + ":") ? h = s.startsWith("(") ? `(${a})` : `[${a}]` : h = s;
|
102
|
+
const $ = this.processValue(h, e, t), p = this.processValue(r, c, t);
|
103
|
+
if (t.startsWith("[") && t.endsWith("]")) {
|
104
|
+
if (!s || r) return null;
|
105
|
+
const f = t.slice(1, -1).split(",").map(
|
106
|
+
(m) => m.trim().startsWith("--") ? String(m.trim()) : this.toKebabCase(String(m.trim()))
|
109
107
|
);
|
110
108
|
return {
|
111
|
-
className: `${
|
112
|
-
cssRules:
|
113
|
-
value:
|
109
|
+
className: `${t}-${s}${e}`,
|
110
|
+
cssRules: f.length === 1 ? f[0] : f,
|
111
|
+
value: $,
|
114
112
|
prefix: i
|
115
113
|
};
|
116
114
|
}
|
117
115
|
if (n) {
|
118
116
|
if (typeof n == "object" && "property" in n) {
|
119
|
-
const
|
117
|
+
const m = n.group && this.values[n.group][$] ? this.values[n.group][$] : e ? s : $, g = (
|
120
118
|
// handle `properties.property` function
|
121
119
|
typeof n.property == "function" ? n.property({
|
122
|
-
value:
|
123
|
-
unit:
|
124
|
-
secondValue:
|
125
|
-
secondUnit:
|
126
|
-
key:
|
120
|
+
value: s.startsWith("[") ? $ : m,
|
121
|
+
unit: s.startsWith("[") ? "" : e,
|
122
|
+
secondValue: s.startsWith("[") ? "" : c ? r : p,
|
123
|
+
secondUnit: s.startsWith("[") ? "" : c,
|
124
|
+
key: o,
|
127
125
|
raw: l
|
128
126
|
}) : (
|
129
127
|
// defaulting to string property
|
@@ -133,29 +131,29 @@ class w {
|
|
133
131
|
n.property
|
134
132
|
)
|
135
133
|
), C = n.value || "{0}";
|
136
|
-
let
|
134
|
+
let b;
|
137
135
|
if (typeof C == "function")
|
138
|
-
|
139
|
-
value:
|
136
|
+
b = C({
|
137
|
+
value: m,
|
140
138
|
unit: e,
|
141
|
-
secondValue: c ? r :
|
139
|
+
secondValue: c ? r : p,
|
142
140
|
secondUnit: c,
|
143
|
-
key:
|
141
|
+
key: o,
|
144
142
|
raw: l
|
145
143
|
});
|
146
144
|
else if (typeof C == "string") {
|
147
|
-
const
|
148
|
-
this.values[
|
149
|
-
|
145
|
+
const A = n.group || t, j = this.processValue(h, e, A);
|
146
|
+
this.values[A] && typeof this.values[A] == "object" && this.values[A][h] ? b = this.values[A][h] : C.includes("{") ? b = this.parseValuePattern(
|
147
|
+
A,
|
150
148
|
C,
|
151
|
-
|
149
|
+
j,
|
152
150
|
"",
|
153
|
-
|
151
|
+
p,
|
154
152
|
""
|
155
|
-
) :
|
156
|
-
} else
|
157
|
-
const V = `${
|
158
|
-
return typeof n.property == "string" && typeof C == "string" && (
|
153
|
+
) : b = $;
|
154
|
+
} else b = null;
|
155
|
+
const V = `${t}${s ? `-${s}${e}` : ""}${r ? `/${r}${c}` : ""}`;
|
156
|
+
return typeof n.property == "string" && typeof C == "string" && (s.includes(o + ":") || !C.includes("{1") && r) ? null : {
|
159
157
|
className: V,
|
160
158
|
cssRules: (
|
161
159
|
// if not property, or when `properties.property` as function return null
|
@@ -167,21 +165,21 @@ class w {
|
|
167
165
|
)
|
168
166
|
) : null
|
169
167
|
),
|
170
|
-
value: C === null || g === null || g.includes(":") || g.includes("value:") ? null :
|
168
|
+
value: C === null || g === null || g.includes(":") || g.includes("value:") ? null : s.startsWith("[") ? $ : b,
|
171
169
|
prefix: i
|
172
170
|
};
|
173
171
|
}
|
174
|
-
const
|
172
|
+
const f = (
|
175
173
|
// handle `properties` as function
|
176
174
|
// e.g. m: ({ value, unit }) => `margin: ${value}${unit || 'px'}`
|
177
175
|
// m-4 => margin: 4px
|
178
176
|
// m-4rem => margin: 4rem
|
179
177
|
typeof n == "function" ? n({
|
180
|
-
value:
|
181
|
-
unit:
|
182
|
-
secondValue:
|
183
|
-
secondUnit:
|
184
|
-
key:
|
178
|
+
value: s.startsWith("[") ? $ : e ? s : $,
|
179
|
+
unit: s.startsWith("[") ? "" : e,
|
180
|
+
secondValue: s.startsWith("[") ? "" : c ? r : p,
|
181
|
+
secondUnit: s.startsWith("[") ? "" : c,
|
182
|
+
key: o,
|
185
183
|
raw: l
|
186
184
|
}) : (
|
187
185
|
// e.g. { property: { bg: 'background' } }
|
@@ -190,62 +188,62 @@ class w {
|
|
190
188
|
)
|
191
189
|
);
|
192
190
|
return {
|
193
|
-
className: `${
|
194
|
-
cssRules:
|
195
|
-
value: typeof
|
191
|
+
className: `${t}${s ? "-" + s + e : ""}${r ? `/${r}${c}` : ""}`,
|
192
|
+
cssRules: f ? Array.isArray(n) ? f : typeof f == "string" && (f.includes(":") || f.startsWith("value:")) ? f.startsWith("value:") ? f.slice(6) : this.toKebabCase(String(f)) : this.toKebabCase(String(f)) : null,
|
193
|
+
value: typeof f == "string" && f.includes(":") ? null : $,
|
196
194
|
prefix: i
|
197
195
|
};
|
198
196
|
}
|
199
197
|
return null;
|
200
198
|
}
|
201
|
-
parseValuePattern(
|
202
|
-
if (!
|
203
|
-
return
|
204
|
-
const [l, n] =
|
205
|
-
if (
|
199
|
+
parseValuePattern(t, s, e, i, r, c) {
|
200
|
+
if (!s.includes("{0}") && !s.includes("{1") && !s.includes("||"))
|
201
|
+
return s;
|
202
|
+
const [l, n] = s.split("||").map((a) => a.trim()), u = this.processValue(e, i, t), o = this.processValue(r, c, t);
|
203
|
+
if (s.includes("{0}") && s.includes("{1") || s.includes("{1")) {
|
206
204
|
let a = l;
|
207
|
-
if (e && (a = a.replace("{0}",
|
208
|
-
const
|
209
|
-
if (
|
210
|
-
r ? a = r.startsWith("[") ?
|
211
|
-
else if (
|
212
|
-
const h =
|
213
|
-
let
|
214
|
-
!
|
205
|
+
if (e && (a = a.replace("{0}", u)), s.includes("{1")) {
|
206
|
+
const y = a.match(/{1([^}]*)}/);
|
207
|
+
if (s.includes("{1}"))
|
208
|
+
r ? a = r.startsWith("[") ? o : a.replace("{1}", o) : a = n;
|
209
|
+
else if (y) {
|
210
|
+
const h = y[0], $ = y[1].trim();
|
211
|
+
let p = o;
|
212
|
+
!p && $.includes("|") ? p = $.split("|")[1].trim() : p || (p = ""), a = e.startsWith("[") ? u : a.replace(h, p);
|
215
213
|
}
|
216
214
|
}
|
217
215
|
return e ? a : n || l;
|
218
216
|
} else
|
219
|
-
return e ? e.startsWith("[") ?
|
217
|
+
return e ? e.startsWith("[") ? u : l.replace("{0}", u) : n || l;
|
220
218
|
}
|
221
|
-
getParentClass(
|
219
|
+
getParentClass(t) {
|
222
220
|
return Object.keys(this.classes).filter(
|
223
|
-
(
|
224
|
-
this.classes[
|
225
|
-
|
221
|
+
(s) => Object.prototype.hasOwnProperty.call(
|
222
|
+
this.classes[s],
|
223
|
+
t
|
226
224
|
)
|
227
225
|
);
|
228
226
|
}
|
229
|
-
processCustomClass(
|
230
|
-
if (!
|
231
|
-
const l = this.getParentClass(
|
227
|
+
processCustomClass(t, s = "", e = "", i = "", r = "", c = "") {
|
228
|
+
if (!t) return null;
|
229
|
+
const l = this.getParentClass(t);
|
232
230
|
if (l.length > 0) {
|
233
231
|
const n = l.map((a) => {
|
234
|
-
const
|
235
|
-
if (
|
232
|
+
const y = this.classes[a];
|
233
|
+
if (!y || s && !y[t].includes("||") || s && !y[t].includes("|"))
|
236
234
|
return null;
|
237
235
|
const h = this.parseValuePattern(
|
238
|
-
s,
|
239
|
-
$[s] || "",
|
240
236
|
t,
|
237
|
+
y[t] || "",
|
238
|
+
s,
|
241
239
|
e,
|
242
240
|
r,
|
243
241
|
c
|
244
242
|
);
|
245
243
|
return `${this.toKebabCase(String(a))}: ${h}`;
|
246
|
-
}).filter(Boolean).join("; "),
|
244
|
+
}).filter(Boolean).join("; "), u = t.slice(-(s + e).length), o = `${t}${s ? `-${s}${e}` : ""}${r ? `/${r}${c}` : ""}`;
|
247
245
|
return {
|
248
|
-
className:
|
246
|
+
className: s === u ? t : o,
|
249
247
|
cssRules: n,
|
250
248
|
value: null,
|
251
249
|
prefix: i
|
@@ -253,34 +251,34 @@ class w {
|
|
253
251
|
}
|
254
252
|
return null;
|
255
253
|
}
|
256
|
-
process(
|
254
|
+
process(t) {
|
257
255
|
try {
|
258
|
-
const
|
259
|
-
for (const i of
|
256
|
+
const s = Array.isArray(t) ? t : t.split(/\s+/), e = [];
|
257
|
+
for (const i of s)
|
260
258
|
try {
|
261
259
|
if (!i) continue;
|
262
260
|
const r = this.parse(i);
|
263
261
|
if (!r) continue;
|
264
|
-
const [c, l, n,
|
262
|
+
const [c, l, n, u, o, a] = r;
|
265
263
|
if (!l) continue;
|
266
|
-
const
|
264
|
+
const y = this.getParentClass(`${l}-${n}`).length > 0 ? `${l}-${n}` : l;
|
267
265
|
try {
|
268
266
|
const h = this.processCustomClass(
|
269
|
-
|
267
|
+
y,
|
270
268
|
n,
|
271
|
-
o,
|
272
|
-
c,
|
273
269
|
u,
|
270
|
+
c,
|
271
|
+
o,
|
274
272
|
a
|
275
273
|
);
|
276
274
|
if (h) {
|
277
|
-
const { className:
|
278
|
-
if (!
|
275
|
+
const { className: $, cssRules: p, prefix: f } = h;
|
276
|
+
if (!p || p === "null") continue;
|
279
277
|
e.push({
|
280
|
-
className:
|
281
|
-
cssRules:
|
278
|
+
className: $,
|
279
|
+
cssRules: p,
|
282
280
|
value: null,
|
283
|
-
prefix:
|
281
|
+
prefix: f,
|
284
282
|
raw: r
|
285
283
|
});
|
286
284
|
continue;
|
@@ -292,20 +290,20 @@ class w {
|
|
292
290
|
const h = this.processShorthand(
|
293
291
|
l,
|
294
292
|
n,
|
295
|
-
o,
|
296
|
-
c,
|
297
293
|
u,
|
294
|
+
c,
|
295
|
+
o,
|
298
296
|
a,
|
299
297
|
r
|
300
298
|
);
|
301
299
|
if (h) {
|
302
|
-
const { className:
|
303
|
-
if (!
|
300
|
+
const { className: $, cssRules: p, value: f, prefix: m } = h;
|
301
|
+
if (!p || p === "null") continue;
|
304
302
|
e.push({
|
305
|
-
className:
|
306
|
-
cssRules:
|
307
|
-
value:
|
308
|
-
prefix:
|
303
|
+
className: $,
|
304
|
+
cssRules: p,
|
305
|
+
value: f,
|
306
|
+
prefix: m,
|
309
307
|
raw: r
|
310
308
|
});
|
311
309
|
}
|
@@ -316,12 +314,12 @@ class w {
|
|
316
314
|
console.warn(`Failed to process class \`${i}\`:`, r);
|
317
315
|
}
|
318
316
|
return e;
|
319
|
-
} catch (
|
320
|
-
return console.error("Critical error in process method:",
|
317
|
+
} catch (s) {
|
318
|
+
return console.error("Critical error in process method:", s), [];
|
321
319
|
}
|
322
320
|
}
|
323
321
|
}
|
324
322
|
export {
|
325
|
-
|
326
|
-
|
323
|
+
R as TenoxUI,
|
324
|
+
R as default
|
327
325
|
};
|
package/dist/index.iife.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var __tenoxui_moxie__=function(m){"use strict";var Z=Object.defineProperty;var x=Object.getOwnPropertySymbols;var
|
1
|
+
var __tenoxui_moxie__=function(m){"use strict";var Z=Object.defineProperty;var x=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var _=(m,g,b)=>g in m?Z(m,g,{enumerable:!0,configurable:!0,writable:!0,value:b}):m[g]=b,S=(m,g)=>{for(var b in g||(g={}))w.call(g,b)&&_(m,b,g[b]);if(x)for(var b of x(g))z.call(g,b)&&_(m,b,g[b]);return m};class g{constructor({property:t={},values:s={},classes:e={}}={}){this.property=S({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 c=[...this.getAllClassNames(e)];return[...i,...c,...t].sort((l,n)=>n.length-l.length)}regexp(t){const s=this.getTypePrefixes(t).join("|"),e="\\[[^\\]]+\\]",i="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",c="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+i+"|"+r+"))|"+e+"|"+i+"|"+r,l=`(${s}|\\[[^\\]]+\\])`,n="(?:-)",u="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))",o="([a-zA-Z%]*)",a="(?:\\/(-?(?:\\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:c,type:l,separator:n,value:u,unit:o,secondValuePattern:a,all:"(?:("+c+"):)?"+l+n+u+o+a}}parse(t,s){const e=this.regexp(s),i=t.match(new RegExp(e.all));if(i){const[,c,l,n,u,o,a]=i,y=`${c?`${c}:`:""}${l}-${n}${u}${o?`/${o}${a}`:""}`;return[c,l,n,u||"",o,a,y]}const r=t.match(new RegExp(`(?:(${e.prefix}):)?${e.type}`));return r?[r[1],r[2],"","",void 0,void 0,t]:null}processValue(t,s,e){if(!t)return"";const i=r=>r.replace(/\{([^}]+)\}/g,(c,l)=>{const n=this.values,u=n!==null?typeof n[e]=="object"?n[e][l]:n[l]:void 0;return typeof u=="string"?u:c});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="",c="",l){const n=this.property[t],u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let o=null,a=s||"";const y=a.match(u);if(y&&(o=y[1].trim(),a=y[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!s||s.includes(o+":")||r))return null;let h;s.includes(o+":")?h=s.startsWith("(")?`(${a})`:`[${a}]`:h=s;const $=this.processValue(h,e,t),p=this.processValue(r,c,t);if(t.startsWith("[")&&t.endsWith("]")){if(!s||r)return null;const f=t.slice(1,-1).split(",").map(C=>C.trim().startsWith("--")?String(C.trim()):this.toKebabCase(String(C.trim())));return{className:`${t}-${s}${e}`,cssRules:f.length===1?f[0]:f,value:$,prefix:i}}if(n){if(typeof n=="object"&&"property"in n){const C=n.group&&this.values[n.group][$]?this.values[n.group][$]:e?s:$,d=typeof n.property=="function"?n.property({value:s.startsWith("[")?$:C,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":c?r:p,secondUnit:s.startsWith("[")?"":c,key:o,raw:l}):n.property,A=n.value||"{0}";let W;if(typeof A=="function")W=A({value:C,unit:e,secondValue:c?r:p,secondUnit:c,key:o,raw:l});else if(typeof A=="string"){const P=n.group||t,V=this.processValue(h,e,P);this.values[P]&&typeof this.values[P]=="object"&&this.values[P][h]?W=this.values[P][h]:A.includes("{")?W=this.parseValuePattern(P,A,V,"",p,""):W=$}else W=null;const j=`${t}${s?`-${s}${e}`:""}${r?`/${r}${c}`:""}`;return typeof n.property=="string"&&typeof A=="string"&&(s.includes(o+":")||!A.includes("{1")&&r)?null:{className:j,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:A===null||d===null||d.includes(":")||d.includes("value:")?null:s.startsWith("[")?$:W,prefix:i}}const f=typeof n=="function"?n({value:s.startsWith("[")?$:e?s:$,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":c?r:p,secondUnit:s.startsWith("[")?"":c,key:o,raw:l}):n;return{className:`${t}${s?"-"+s+e:""}${r?`/${r}${c}`:""}`,cssRules:f?Array.isArray(n)?f:typeof f=="string"&&(f.includes(":")||f.startsWith("value:"))?f.startsWith("value:")?f.slice(6):this.toKebabCase(String(f)):this.toKebabCase(String(f)):null,value:typeof f=="string"&&f.includes(":")?null:$,prefix:i}}return null}parseValuePattern(t,s,e,i,r,c){if(!s.includes("{0}")&&!s.includes("{1")&&!s.includes("||"))return s;const[l,n]=s.split("||").map(a=>a.trim()),u=this.processValue(e,i,t),o=this.processValue(r,c,t);if(s.includes("{0}")&&s.includes("{1")||s.includes("{1")){let a=l;if(e&&(a=a.replace("{0}",u)),s.includes("{1")){const y=a.match(/{1([^}]*)}/);if(s.includes("{1}"))r?a=r.startsWith("[")?o:a.replace("{1}",o):a=n;else if(y){const h=y[0],$=y[1].trim();let p=o;!p&&$.includes("|")?p=$.split("|")[1].trim():p||(p=""),a=e.startsWith("[")?u:a.replace(h,p)}}return e?a:n||l}else return e?e.startsWith("[")?u:l.replace("{0}",u):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="",c=""){if(!t)return null;const l=this.getParentClass(t);if(l.length>0){const n=l.map(a=>{const y=this.classes[a];if(!y||s&&!y[t].includes("||")||s&&!y[t].includes("|"))return null;const h=this.parseValuePattern(t,y[t]||"",s,e,r,c);return`${this.toKebabCase(String(a))}: ${h}`}).filter(Boolean).join("; "),u=t.slice(-(s+e).length),o=`${t}${s?`-${s}${e}`:""}${r?`/${r}${c}`:""}`;return{className:s===u?t:o,cssRules:n,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[c,l,n,u,o,a]=r;if(!l)continue;const y=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const h=this.processCustomClass(y,n,u,c,o,a);if(h){const{className:$,cssRules:p,prefix:f}=h;if(!p||p==="null")continue;e.push({className:$,cssRules:p,value:null,prefix:f,raw:r});continue}}catch(h){console.warn(`Error processing custom class "${i}":`,h)}try{const h=this.processShorthand(l,n,u,c,o,a,r);if(h){const{className:$,cssRules:p,value:f,prefix:C}=h;if(!p||p==="null")continue;e.push({className:$,cssRules:p,value:f,prefix:C,raw:r})}}catch(h){console.warn(`Error processing shorthand "${i}":`,h)}}catch(r){console.warn(`Failed to process class \`${i}\`:`,r)}return e}catch(s){return console.error("Critical error in process method:",s),[]}}}return m.TenoxUI=g,m.default=g,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),m}({});
|
package/dist/index.umd.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
(function(
|
1
|
+
(function(g,y){typeof exports=="object"&&typeof module!="undefined"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(g=typeof globalThis!="undefined"?globalThis:g||self,y(g.__tenoxui_moxie__={}))})(this,function(g){"use strict";var Z=Object.defineProperty;var P=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var _=(g,y,b)=>y in g?Z(g,y,{enumerable:!0,configurable:!0,writable:!0,value:b}):g[y]=b,j=(g,y)=>{for(var b in y||(y={}))w.call(y,b)&&_(g,b,y[b]);if(P)for(var b of P(y))z.call(y,b)&&_(g,b,y[b]);return g};class y{constructor({property:t={},values:s={},classes:e={}}={}){this.property=j({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="(?:-)",u="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+i+"|(?:\\$[^\\s\\/]+))",a="([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:u,unit:a,secondValuePattern:c,all:"(?:("+o+"):)?"+l+n+u+a+c}}parse(t,s){const e=this.regexp(s),i=t.match(new RegExp(e.all));if(i){const[,o,l,n,u,a,c]=i,d=`${o?`${o}:`:""}${l}-${n}${u}${a?`/${a}${c}`:""}`;return[o,l,n,u||"",a,c,d]}const r=t.match(new RegExp(`(?:(${e.prefix}):)?${e.type}`));return r?[r[1],r[2],"","",void 0,void 0,t]:null}processValue(t,s,e){if(!t)return"";const i=r=>r.replace(/\{([^}]+)\}/g,(o,l)=>{const n=this.values,u=n!==null?typeof n[e]=="object"?n[e][l]:n[l]:void 0;return typeof u=="string"?u: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],u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let a=null,c=s||"";const d=c.match(u);if(d&&(a=d[1].trim(),c=d[2].trim()),(typeof n=="string"||Array.isArray(n))&&(!s||s.includes(a+":")||r))return null;let h;s.includes(a+":")?h=s.startsWith("(")?`(${c})`:`[${c}]`:h=s;const $=this.processValue(h,e,t),p=this.processValue(r,o,t);if(t.startsWith("[")&&t.endsWith("]")){if(!s||r)return null;const f=t.slice(1,-1).split(",").map(C=>C.trim().startsWith("--")?String(C.trim()):this.toKebabCase(String(C.trim())));return{className:`${t}-${s}${e}`,cssRules:f.length===1?f[0]:f,value:$,prefix:i}}if(n){if(typeof n=="object"&&"property"in n){const C=n.group&&this.values[n.group][$]?this.values[n.group][$]:e?s:$,m=typeof n.property=="function"?n.property({value:s.startsWith("[")?$:C,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":o?r:p,secondUnit:s.startsWith("[")?"":o,key:a,raw:l}):n.property,x=n.value||"{0}";let A;if(typeof x=="function")A=x({value:C,unit:e,secondValue:o?r:p,secondUnit:o,key:a,raw:l});else if(typeof x=="string"){const W=n.group||t,V=this.processValue(h,e,W);this.values[W]&&typeof this.values[W]=="object"&&this.values[W][h]?A=this.values[W][h]:x.includes("{")?A=this.parseValuePattern(W,x,V,"",p,""):A=$}else A=null;const S=`${t}${s?`-${s}${e}`:""}${r?`/${r}${o}`:""}`;return typeof n.property=="string"&&typeof x=="string"&&(s.includes(a+":")||!x.includes("{1")&&r)?null:{className:S,cssRules:m?Array.isArray(m)?m:typeof m=="string"&&(m.includes(":")||m.includes("value:"))?m.includes("value:")?m.slice(6):this.toKebabCase(String(m)):this.toKebabCase(String(m)):null,value:x===null||m===null||m.includes(":")||m.includes("value:")?null:s.startsWith("[")?$:A,prefix:i}}const f=typeof n=="function"?n({value:s.startsWith("[")?$:e?s:$,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":o?r:p,secondUnit:s.startsWith("[")?"":o,key:a,raw:l}):n;return{className:`${t}${s?"-"+s+e:""}${r?`/${r}${o}`:""}`,cssRules:f?Array.isArray(n)?f:typeof f=="string"&&(f.includes(":")||f.startsWith("value:"))?f.startsWith("value:")?f.slice(6):this.toKebabCase(String(f)):this.toKebabCase(String(f)):null,value:typeof f=="string"&&f.includes(":")?null:$,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()),u=this.processValue(e,i,t),a=this.processValue(r,o,t);if(s.includes("{0}")&&s.includes("{1")||s.includes("{1")){let c=l;if(e&&(c=c.replace("{0}",u)),s.includes("{1")){const d=c.match(/{1([^}]*)}/);if(s.includes("{1}"))r?c=r.startsWith("[")?a:c.replace("{1}",a):c=n;else if(d){const h=d[0],$=d[1].trim();let p=a;!p&&$.includes("|")?p=$.split("|")[1].trim():p||(p=""),c=e.startsWith("[")?u:c.replace(h,p)}}return e?c:n||l}else return e?e.startsWith("[")?u:l.replace("{0}",u):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);if(l.length>0){const n=l.map(c=>{const d=this.classes[c];if(!d||s&&!d[t].includes("||")||s&&!d[t].includes("|"))return null;const h=this.parseValuePattern(t,d[t]||"",s,e,r,o);return`${this.toKebabCase(String(c))}: ${h}`}).filter(Boolean).join("; "),u=t.slice(-(s+e).length),a=`${t}${s?`-${s}${e}`:""}${r?`/${r}${o}`:""}`;return{className:s===u?t:a,cssRules:n,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,u,a,c]=r;if(!l)continue;const d=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const h=this.processCustomClass(d,n,u,o,a,c);if(h){const{className:$,cssRules:p,prefix:f}=h;if(!p||p==="null")continue;e.push({className:$,cssRules:p,value:null,prefix:f,raw:r});continue}}catch(h){console.warn(`Error processing custom class "${i}":`,h)}try{const h=this.processShorthand(l,n,u,o,a,c,r);if(h){const{className:$,cssRules:p,value:f,prefix:C}=h;if(!p||p==="null")continue;e.push({className:$,cssRules:p,value:f,prefix:C,raw:r})}}catch(h){console.warn(`Error processing shorthand "${i}":`,h)}}catch(r){console.warn(`Failed to process class \`${i}\`:`,r)}return e}catch(s){return console.error("Critical error in process method:",s),[]}}}g.TenoxUI=y,g.default=y,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|