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