@tenoxui/moxie 0.5.0-alpha.2 → 0.6.0
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 +1 -1
- package/dist/index.es.js +48 -45
- package/dist/index.iife.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +6 -3
package/dist/index.cjs.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var Z=Object.defineProperty;var W=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var x=(
|
1
|
+
"use strict";var Z=Object.defineProperty;var W=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var x=(m,t,s)=>t in m?Z(m,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):m[t]=s,P=(m,t)=>{for(var s in t||(t={}))_.call(t,s)&&x(m,s,t[s]);if(W)for(var s of W(t))w.call(t,s)&&x(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=P({moxie:({key:n,secondValue:r})=>r?null:n},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,n=>`-${n.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,n])=>{n&&typeof n=="object"&&Object.keys(n).forEach(r=>{s.add(r)})}),Array.from(s)}getTypePrefixes(t=[]){const s=this.property,e=this.classes,n=Object.keys(s);if(!e)return[...n,...t].sort((i,l)=>l.length-i.length);const c=[...this.getAllClassNames(e)];return[...n,...c,...t].sort((i,l)=>l.length-i.length)}regexp(t){const s=this.getTypePrefixes(t).join("|"),e="\\[[^\\]]+\\]",n="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",r="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",c="[a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-(?:"+e+"|"+n+"|"+r+"))|"+e+"|"+n+"|"+r,i=`(${s}|\\[[^\\]]+\\])`,l="(?:-)",u="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+e+"|"+r+"|"+n+"|(?:\\$[^\\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+"|"+n+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:c,type:i,separator:l,value:u,unit:a,secondValuePattern:o,all:"(?:("+c+"):)?"+i+l+u+a+o}}parse(t,s){const e=this.regexp(s),n=t.match(new RegExp(e.all));if(n){const[,c,i,l,u,a,o]=n,$=`${c?`${c}:`:""}${i}-${l}${u}${a?`/${a}${o}`:""}`;return[c,i,l,u||"",a,o,$]}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 n=r=>r.replace(/\{([^}]+)\}/g,(c,i)=>{const l=this.values,u=l!==null?typeof l[e]=="object"?l[e][i]:l[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("{")?n(r):r.startsWith("--")?`var(${r})`:r}return t+(s||"")}processShorthand(t="",s="",e="",n,r="",c="",i){const l=this.property[t],u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let a=null,o=s||"";const $=o.match(u);if($&&(a=$[1].trim(),o=$[2].trim()),(typeof l=="string"||Array.isArray(l))&&(!s||s.includes(a+":")||r))return null;let h;s.includes(a+":")?h=s.startsWith("(")?`(${o})`:`[${o}]`:h=s;const y=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(b=>b.trim().startsWith("--")?String(b.trim()):this.toKebabCase(String(b.trim())));return{className:`${t}-${s}${e}`,cssRules:f.length===1?f[0]:f,value:y,prefix:n}}if(l){if(typeof l=="object"&&"property"in l){const b=l.group&&this.values[l.group][y]?this.values[l.group][y]:e?s:y,g=typeof l.property=="function"?l.property({value:s.startsWith("[")?y:b,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":c?r:p,secondUnit:s.startsWith("[")?"":c,key:a,raw:i}):l.property,d=l.value||"{0}";let C;if(typeof d=="function")C=d({value:b,unit:e,secondValue:c?r:p,secondUnit:c,key:a,raw:i});else if(typeof d=="string"){const A=l.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]:d.includes("{")?C=this.parseValuePattern(A,d,V,"",p,""):C=y}else if(Array.isArray(d)){if(!d.includes(s+e)||r)return null;C=s+e}else C=null;const j=`${t}${s?`-${s}${e}`:""}${r?`/${r}${c}`:""}`;return typeof l.property=="string"&&typeof d=="string"&&(s.includes(a+":")||!d.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:d===null||g===null||g.includes(":")||g.includes("value:")?null:s.startsWith("[")?y:C,prefix:n}}const f=typeof l=="function"?l({value:s.startsWith("[")?y:e?s:y,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":c?r:p,secondUnit:s.startsWith("[")?"":c,key:a,raw:i}):l;return{className:`${t}${s?"-"+s+e:""}${r?`/${r}${c}`:""}`,cssRules:f?Array.isArray(l)?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:y,prefix:n}}return null}parseValuePattern(t,s,e,n,r,c){if(!s.includes("{0}")&&!s.includes("{1")&&!s.includes("||"))return s;const[i,l]=s.split("||").map(o=>o.trim()),u=this.processValue(e,n,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 $=o.match(/{1([^}]*)}/);if(s.includes("{1}"))r?o=r.startsWith("[")?a:o.replace("{1}",a):o=l;else if($){const h=$[0],y=$[1].trim();let p=a;!p&&y.includes("|")?p=y.split("|")[1].trim():p||(p=""),o=e.startsWith("[")?u:o.replace(h,p)}}return e?o:l||i}else return e?e.startsWith("[")?u:i.replace("{0}",u):l||i}getParentClass(t){return Object.keys(this.classes).filter(s=>Object.prototype.hasOwnProperty.call(this.classes[s],t))}processCustomClass(t,s="",e="",n="",r="",c=""){if(!t)return null;const i=this.getParentClass(t);if(i.length>0){const l=i.map(o=>{const $=this.classes[o];if(!$||s&&!$[t].includes("||")||s&&!$[t].includes("|"))return null;const h=this.parseValuePattern(t,$[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:l,value:null,prefix:n}}return null}process(t){try{const s=Array.isArray(t)?t:t.split(/\s+/),e=[];for(const n of s)try{if(!n)continue;const r=this.parse(n);if(!r)continue;const[c,i,l,u,a,o]=r;if(!i)continue;const $=this.getParentClass(`${i}-${l}`).length>0?`${i}-${l}`:i;try{const h=this.processCustomClass($,l,u,c,a,o);if(h){const{className:y,cssRules:p,prefix:f}=h;if(!p||p==="null")continue;e.push({className:y,cssRules:p,value:null,prefix:f,raw:r});continue}}catch(h){console.warn(`Error processing custom class "${n}":`,h)}try{const h=this.processShorthand(i,l,u,c,a,o,r);if(h){const{className:y,cssRules:p,value:f,prefix:b}=h;if(!p||p==="null")continue;e.push({className:y,cssRules:p,value:f,prefix:b,raw:r})}}catch(h){console.warn(`Error processing shorthand "${n}":`,h)}}catch(r){console.warn(`Failed to process class \`${n}\`:`,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
@@ -1,5 +1,4 @@
|
|
1
1
|
import type { Config, Parsed, ProcessedStyle, Results } from './types';
|
2
|
-
export * from './types';
|
3
2
|
export declare class TenoxUI {
|
4
3
|
private property;
|
5
4
|
private values;
|
@@ -26,4 +25,5 @@ export declare class TenoxUI {
|
|
26
25
|
processCustomClass(className: string | undefined, value?: string | undefined, unit?: string | undefined, prefix?: string | undefined, secValue?: string | undefined, secUnit?: string | undefined): ProcessedStyle | null;
|
27
26
|
process(classNames: string | string[]): Results[];
|
28
27
|
}
|
28
|
+
export * from './types';
|
29
29
|
export default TenoxUI;
|
package/dist/index.es.js
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
var
|
1
|
+
var V = Object.defineProperty;
|
2
2
|
var W = Object.getOwnPropertySymbols;
|
3
3
|
var Z = Object.prototype.hasOwnProperty, w = Object.prototype.propertyIsEnumerable;
|
4
|
-
var x = (
|
4
|
+
var x = (m, t, s) => t in m ? V(m, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : m[t] = s, P = (m, t) => {
|
5
5
|
for (var s in t || (t = {}))
|
6
|
-
Z.call(t, s) && x(
|
6
|
+
Z.call(t, s) && x(m, s, t[s]);
|
7
7
|
if (W)
|
8
8
|
for (var s of W(t))
|
9
|
-
w.call(t, s) && x(
|
10
|
-
return
|
9
|
+
w.call(t, s) && x(m, s, t[s]);
|
10
|
+
return m;
|
11
11
|
};
|
12
12
|
class R {
|
13
13
|
constructor({ property: t = {}, values: s = {}, classes: e = {} } = {}) {
|
14
14
|
this.property = P({
|
15
|
-
// use moxie-* to access all properties and variables
|
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: i, secondValue: r }) => r ? null : i
|
18
18
|
}, t), this.values = s, this.classes = e;
|
@@ -68,8 +68,8 @@ class R {
|
|
68
68
|
parse(t, s) {
|
69
69
|
const e = this.regexp(s), i = t.match(new RegExp(e.all));
|
70
70
|
if (i) {
|
71
|
-
const [, c, l, n, u, o, a] = i,
|
72
|
-
return [c, l, n, u || "", o, a,
|
71
|
+
const [, c, l, n, u, o, a] = i, $ = `${c ? `${c}:` : ""}${l}-${n}${u}${o ? `/${o}${a}` : ""}`;
|
72
|
+
return [c, l, n, u || "", o, a, $];
|
73
73
|
}
|
74
74
|
const r = t.match(new RegExp(`(?:(${e.prefix}):)?${e.type}`));
|
75
75
|
return r ? [r[1], r[2], "", "", void 0, void 0, t] : null;
|
@@ -94,30 +94,30 @@ class R {
|
|
94
94
|
processShorthand(t = "", s = "", e = "", i, r = "", c = "", l) {
|
95
95
|
const n = this.property[t], u = /^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;
|
96
96
|
let o = null, a = s || "";
|
97
|
-
const
|
98
|
-
if (
|
97
|
+
const $ = a.match(u);
|
98
|
+
if ($ && (o = $[1].trim(), a = $[2].trim()), (typeof n == "string" || Array.isArray(n)) && (!s || s.includes(o + ":") || r))
|
99
99
|
return null;
|
100
100
|
let h;
|
101
101
|
s.includes(o + ":") ? h = s.startsWith("(") ? `(${a})` : `[${a}]` : h = s;
|
102
|
-
const
|
102
|
+
const y = this.processValue(h, e, t), p = this.processValue(r, c, t);
|
103
103
|
if (t.startsWith("[") && t.endsWith("]")) {
|
104
104
|
if (!s || r) return null;
|
105
105
|
const f = t.slice(1, -1).split(",").map(
|
106
|
-
(
|
106
|
+
(C) => C.trim().startsWith("--") ? String(C.trim()) : this.toKebabCase(String(C.trim()))
|
107
107
|
);
|
108
108
|
return {
|
109
109
|
className: `${t}-${s}${e}`,
|
110
110
|
cssRules: f.length === 1 ? f[0] : f,
|
111
|
-
value:
|
111
|
+
value: y,
|
112
112
|
prefix: i
|
113
113
|
};
|
114
114
|
}
|
115
115
|
if (n) {
|
116
116
|
if (typeof n == "object" && "property" in n) {
|
117
|
-
const
|
117
|
+
const C = n.group && this.values[n.group][y] ? this.values[n.group][y] : e ? s : y, g = (
|
118
118
|
// handle `properties.property` function
|
119
119
|
typeof n.property == "function" ? n.property({
|
120
|
-
value: s.startsWith("[") ?
|
120
|
+
value: s.startsWith("[") ? y : C,
|
121
121
|
unit: s.startsWith("[") ? "" : e,
|
122
122
|
secondValue: s.startsWith("[") ? "" : c ? r : p,
|
123
123
|
secondUnit: s.startsWith("[") ? "" : c,
|
@@ -130,31 +130,34 @@ class R {
|
|
130
130
|
// and has support for second value
|
131
131
|
n.property
|
132
132
|
)
|
133
|
-
),
|
133
|
+
), d = n.value || "{0}";
|
134
134
|
let b;
|
135
|
-
if (typeof
|
136
|
-
b =
|
137
|
-
value:
|
135
|
+
if (typeof d == "function")
|
136
|
+
b = d({
|
137
|
+
value: C,
|
138
138
|
unit: e,
|
139
139
|
secondValue: c ? r : p,
|
140
140
|
secondUnit: c,
|
141
141
|
key: o,
|
142
142
|
raw: l
|
143
143
|
});
|
144
|
-
else if (typeof
|
145
|
-
const A = n.group || t,
|
146
|
-
this.values[A] && typeof this.values[A] == "object" && this.values[A][h] ? b = this.values[A][h] :
|
144
|
+
else if (typeof d == "string") {
|
145
|
+
const A = n.group || t, S = this.processValue(h, e, A);
|
146
|
+
this.values[A] && typeof this.values[A] == "object" && this.values[A][h] ? b = this.values[A][h] : d.includes("{") ? b = this.parseValuePattern(
|
147
147
|
A,
|
148
|
-
|
149
|
-
|
148
|
+
d,
|
149
|
+
S,
|
150
150
|
"",
|
151
151
|
p,
|
152
152
|
""
|
153
|
-
) : b =
|
153
|
+
) : b = y;
|
154
|
+
} else if (Array.isArray(d)) {
|
155
|
+
if (!d.includes(s + e) || r) return null;
|
156
|
+
b = s + e;
|
154
157
|
} else b = null;
|
155
|
-
const
|
156
|
-
return typeof n.property == "string" && typeof
|
157
|
-
className:
|
158
|
+
const j = `${t}${s ? `-${s}${e}` : ""}${r ? `/${r}${c}` : ""}`;
|
159
|
+
return typeof n.property == "string" && typeof d == "string" && (s.includes(o + ":") || !d.includes("{1") && r) ? null : {
|
160
|
+
className: j,
|
158
161
|
cssRules: (
|
159
162
|
// if not property, or when `properties.property` as function return null
|
160
163
|
g ? Array.isArray(g) ? g : (
|
@@ -165,7 +168,7 @@ class R {
|
|
165
168
|
)
|
166
169
|
) : null
|
167
170
|
),
|
168
|
-
value:
|
171
|
+
value: d === null || g === null || g.includes(":") || g.includes("value:") ? null : s.startsWith("[") ? y : b,
|
169
172
|
prefix: i
|
170
173
|
};
|
171
174
|
}
|
@@ -175,7 +178,7 @@ class R {
|
|
175
178
|
// m-4 => margin: 4px
|
176
179
|
// m-4rem => margin: 4rem
|
177
180
|
typeof n == "function" ? n({
|
178
|
-
value: s.startsWith("[") ?
|
181
|
+
value: s.startsWith("[") ? y : e ? s : y,
|
179
182
|
unit: s.startsWith("[") ? "" : e,
|
180
183
|
secondValue: s.startsWith("[") ? "" : c ? r : p,
|
181
184
|
secondUnit: s.startsWith("[") ? "" : c,
|
@@ -190,7 +193,7 @@ class R {
|
|
190
193
|
return {
|
191
194
|
className: `${t}${s ? "-" + s + e : ""}${r ? `/${r}${c}` : ""}`,
|
192
195
|
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
|
+
value: typeof f == "string" && f.includes(":") ? null : y,
|
194
197
|
prefix: i
|
195
198
|
};
|
196
199
|
}
|
@@ -203,13 +206,13 @@ class R {
|
|
203
206
|
if (s.includes("{0}") && s.includes("{1") || s.includes("{1")) {
|
204
207
|
let a = l;
|
205
208
|
if (e && (a = a.replace("{0}", u)), s.includes("{1")) {
|
206
|
-
const
|
209
|
+
const $ = a.match(/{1([^}]*)}/);
|
207
210
|
if (s.includes("{1}"))
|
208
211
|
r ? a = r.startsWith("[") ? o : a.replace("{1}", o) : a = n;
|
209
|
-
else if (
|
210
|
-
const h =
|
212
|
+
else if ($) {
|
213
|
+
const h = $[0], y = $[1].trim();
|
211
214
|
let p = o;
|
212
|
-
!p &&
|
215
|
+
!p && y.includes("|") ? p = y.split("|")[1].trim() : p || (p = ""), a = e.startsWith("[") ? u : a.replace(h, p);
|
213
216
|
}
|
214
217
|
}
|
215
218
|
return e ? a : n || l;
|
@@ -229,12 +232,12 @@ class R {
|
|
229
232
|
const l = this.getParentClass(t);
|
230
233
|
if (l.length > 0) {
|
231
234
|
const n = l.map((a) => {
|
232
|
-
const
|
233
|
-
if (
|
235
|
+
const $ = this.classes[a];
|
236
|
+
if (!$ || s && !$[t].includes("||") || s && !$[t].includes("|"))
|
234
237
|
return null;
|
235
238
|
const h = this.parseValuePattern(
|
236
239
|
t,
|
237
|
-
|
240
|
+
$[t] || "",
|
238
241
|
s,
|
239
242
|
e,
|
240
243
|
r,
|
@@ -261,10 +264,10 @@ class R {
|
|
261
264
|
if (!r) continue;
|
262
265
|
const [c, l, n, u, o, a] = r;
|
263
266
|
if (!l) continue;
|
264
|
-
const
|
267
|
+
const $ = this.getParentClass(`${l}-${n}`).length > 0 ? `${l}-${n}` : l;
|
265
268
|
try {
|
266
269
|
const h = this.processCustomClass(
|
267
|
-
|
270
|
+
$,
|
268
271
|
n,
|
269
272
|
u,
|
270
273
|
c,
|
@@ -272,10 +275,10 @@ class R {
|
|
272
275
|
a
|
273
276
|
);
|
274
277
|
if (h) {
|
275
|
-
const { className:
|
278
|
+
const { className: y, cssRules: p, prefix: f } = h;
|
276
279
|
if (!p || p === "null") continue;
|
277
280
|
e.push({
|
278
|
-
className:
|
281
|
+
className: y,
|
279
282
|
cssRules: p,
|
280
283
|
value: null,
|
281
284
|
prefix: f,
|
@@ -297,13 +300,13 @@ class R {
|
|
297
300
|
r
|
298
301
|
);
|
299
302
|
if (h) {
|
300
|
-
const { className:
|
303
|
+
const { className: y, cssRules: p, value: f, prefix: C } = h;
|
301
304
|
if (!p || p === "null") continue;
|
302
305
|
e.push({
|
303
|
-
className:
|
306
|
+
className: y,
|
304
307
|
cssRules: p,
|
305
308
|
value: f,
|
306
|
-
prefix:
|
309
|
+
prefix: C,
|
307
310
|
raw: r
|
308
311
|
});
|
309
312
|
}
|
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 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
|
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,$=`${c?`${c}:`:""}${l}-${n}${u}${o?`/${o}${a}`:""}`;return[c,l,n,u||"",o,a,$]}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 $=a.match(u);if($&&(o=$[1].trim(),a=$[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 y=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(A=>A.trim().startsWith("--")?String(A.trim()):this.toKebabCase(String(A.trim())));return{className:`${t}-${s}${e}`,cssRules:f.length===1?f[0]:f,value:y,prefix:i}}if(n){if(typeof n=="object"&&"property"in n){const A=n.group&&this.values[n.group][y]?this.values[n.group][y]:e?s:y,d=typeof n.property=="function"?n.property({value:s.startsWith("[")?y:A,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":c?r:p,secondUnit:s.startsWith("[")?"":c,key:o,raw:l}):n.property,C=n.value||"{0}";let W;if(typeof C=="function")W=C({value:A,unit:e,secondValue:c?r:p,secondUnit:c,key:o,raw:l});else if(typeof C=="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]:C.includes("{")?W=this.parseValuePattern(P,C,V,"",p,""):W=y}else if(Array.isArray(C)){if(!C.includes(s+e)||r)return null;W=s+e}else W=null;const j=`${t}${s?`-${s}${e}`:""}${r?`/${r}${c}`:""}`;return typeof n.property=="string"&&typeof C=="string"&&(s.includes(o+":")||!C.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:C===null||d===null||d.includes(":")||d.includes("value:")?null:s.startsWith("[")?y:W,prefix:i}}const f=typeof n=="function"?n({value:s.startsWith("[")?y:e?s:y,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:y,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 $=a.match(/{1([^}]*)}/);if(s.includes("{1}"))r?a=r.startsWith("[")?o:a.replace("{1}",o):a=n;else if($){const h=$[0],y=$[1].trim();let p=o;!p&&y.includes("|")?p=y.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 $=this.classes[a];if(!$||s&&!$[t].includes("||")||s&&!$[t].includes("|"))return null;const h=this.parseValuePattern(t,$[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 $=this.getParentClass(`${l}-${n}`).length>0?`${l}-${n}`:l;try{const h=this.processCustomClass($,n,u,c,o,a);if(h){const{className:y,cssRules:p,prefix:f}=h;if(!p||p==="null")continue;e.push({className:y,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:y,cssRules:p,value:f,prefix:A}=h;if(!p||p==="null")continue;e.push({className:y,cssRules:p,value:f,prefix:A,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(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(
|
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(A=>A.trim().startsWith("--")?String(A.trim()):this.toKebabCase(String(A.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 A=n.group&&this.values[n.group][$]?this.values[n.group][$]:e?s:$,m=typeof n.property=="function"?n.property({value:s.startsWith("[")?$:A,unit:s.startsWith("[")?"":e,secondValue:s.startsWith("[")?"":o?r:p,secondUnit:s.startsWith("[")?"":o,key:a,raw:l}):n.property,C=n.value||"{0}";let x;if(typeof C=="function")x=C({value:A,unit:e,secondValue:o?r:p,secondUnit:o,key:a,raw:l});else if(typeof C=="string"){const W=n.group||t,V=this.processValue(h,e,W);this.values[W]&&typeof this.values[W]=="object"&&this.values[W][h]?x=this.values[W][h]:C.includes("{")?x=this.parseValuePattern(W,C,V,"",p,""):x=$}else if(Array.isArray(C)){if(!C.includes(s+e)||r)return null;x=s+e}else x=null;const S=`${t}${s?`-${s}${e}`:""}${r?`/${r}${o}`:""}`;return typeof n.property=="string"&&typeof C=="string"&&(s.includes(a+":")||!C.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:C===null||m===null||m.includes(":")||m.includes("value:")?null:s.startsWith("[")?$:x,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:A}=h;if(!p||p==="null")continue;e.push({className:$,cssRules:p,value:f,prefix:A,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"}})});
|
package/dist/types/index.d.ts
CHANGED
@@ -8,7 +8,7 @@ export type PropertyParams = {
|
|
8
8
|
raw?: Parsed;
|
9
9
|
};
|
10
10
|
export type PropertyParamValue = GetCSSProperty | ((params: PropertyParams) => null | GetCSSProperty);
|
11
|
-
export type ValuePropType = string | ((params: PropertyParams) => string | null) | null;
|
11
|
+
export type ValuePropType = string | string[] | ((params: PropertyParams) => string | null) | null;
|
12
12
|
export type PropertyValue = PropertyParamValue | {
|
13
13
|
property?: PropertyParamValue;
|
14
14
|
value?: ValuePropType;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tenoxui/moxie",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.6.0",
|
4
4
|
"description": "Very lightweight utility-first CSS engine for style generation",
|
5
5
|
"author": "NOuSantx <nousantx@gmail.com>",
|
6
6
|
"license": "MIT",
|
@@ -43,9 +43,12 @@
|
|
43
43
|
},
|
44
44
|
"scripts": {
|
45
45
|
"dev": "vite build --watch",
|
46
|
-
"build": "
|
46
|
+
"build": "vite build",
|
47
47
|
"test": "vitest run",
|
48
|
-
"test:watch": "vitest"
|
48
|
+
"test:watch": "vitest",
|
49
|
+
"type:check": "tsc --noEmit",
|
50
|
+
"type:build": "tsc --declaration --emitDeclarationOnly --outDir dist",
|
51
|
+
"build:prod": "pnpm type:check && pnpm build && pnpm type:build"
|
49
52
|
},
|
50
53
|
"devDependencies": {
|
51
54
|
"typescript": "^5.7.3",
|