@tenoxui/moxie 0.3.0 → 0.3.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.es.js CHANGED
@@ -1,283 +1,372 @@
1
- var j = Object.defineProperty;
2
- var R = Object.getOwnPropertySymbols;
3
- var z = Object.prototype.hasOwnProperty, S = Object.prototype.propertyIsEnumerable;
4
- var V = (P, s, e) => s in P ? j(P, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : P[s] = e, W = (P, s) => {
5
- for (var e in s || (s = {}))
6
- z.call(s, e) && V(P, e, s[e]);
7
- if (R)
8
- for (var e of R(s))
9
- S.call(s, e) && V(P, e, s[e]);
10
- return P;
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
11
16
  };
12
- class _ {
13
- constructor({ property: s = {}, values: e = {}, classes: t = {}, aliases: n = {} } = {}) {
14
- this.property = W({
15
- moxie: ({ key: r }) => r
16
- }, s), this.values = e, this.classes = t, this.aliases = n;
17
+ class TenoxUI {
18
+ constructor({ property = {}, values = {}, classes = {}, aliases = {} } = {}) {
19
+ this.property = __spreadValues({
20
+ moxie: ({ key }) => key
21
+ }, property);
22
+ this.values = values;
23
+ this.classes = classes;
24
+ this.aliases = aliases;
17
25
  }
18
- toKebabCase(s) {
19
- if (/^(webkit|moz|ms|o)[A-Z]/.test(s)) {
20
- const e = s.match(/^(webkit|moz|ms|o)/);
21
- if (e) {
22
- const t = e[0];
23
- return `-${t}${s.slice(t.length).replace(/[A-Z]/g, (n) => `-${n.toLowerCase()}`)}`;
26
+ toKebabCase(str) {
27
+ if (/^(webkit|moz|ms|o)[A-Z]/.test(str)) {
28
+ const match = str.match(/^(webkit|moz|ms|o)/);
29
+ if (match) {
30
+ const prefix = match[0];
31
+ return `-${prefix}${str.slice(prefix.length).replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;
24
32
  }
25
33
  }
26
- return s.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
34
+ return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
27
35
  }
28
- escapeCSSSelector(s) {
29
- return s.replace(/([ #{}.:;?%&,@+*~'"!^$[\]()=>|/])/g, "\\$1");
36
+ escapeCSSSelector(str) {
37
+ return str.replace(/([ #{}.:;?%&,@+*~'"!^$[\]()=>|/])/g, "\\$1");
30
38
  }
31
- getAllClassNames(s) {
32
- if (!s) return [];
33
- const e = /* @__PURE__ */ new Set();
34
- return Object.entries(s).forEach(([t, n]) => {
35
- n && typeof n == "object" && Object.keys(n).forEach((r) => {
36
- e.add(r);
37
- });
38
- }), Array.from(e);
39
+ getAllClassNames(classRegistry) {
40
+ if (!classRegistry) return [];
41
+ const classNames = /* @__PURE__ */ new Set();
42
+ Object.entries(classRegistry).forEach(([property, classObj]) => {
43
+ if (classObj && typeof classObj === "object") {
44
+ Object.keys(classObj).forEach((className) => {
45
+ classNames.add(className);
46
+ });
47
+ }
48
+ });
49
+ return Array.from(classNames);
39
50
  }
40
- getTypePrefixes(s = []) {
41
- const e = this.property, t = this.classes, n = Object.keys(e);
42
- if (!t)
43
- return [...n, ...s].sort((i, l) => l.length - i.length).join("|");
44
- const c = [...this.getAllClassNames(t)];
45
- return [...n, ...c, ...s].sort((i, l) => l.length - i.length).join("|");
51
+ getTypePrefixes(safelist = []) {
52
+ const styleAttribute = this.property;
53
+ const classRegistry = this.classes;
54
+ const propertyTypes = Object.keys(styleAttribute);
55
+ if (!classRegistry) {
56
+ return [...propertyTypes, ...safelist].sort((a, b) => b.length - a.length).join("|");
57
+ }
58
+ const classConfigs = this.getAllClassNames(classRegistry);
59
+ const classPatterns = [...classConfigs];
60
+ return [...propertyTypes, ...classPatterns, ...safelist].sort((a, b) => b.length - a.length).join("|");
46
61
  }
47
- generateClassNameRegEx(s) {
48
- const e = this.getTypePrefixes(s), t = "\\[[^\\]]+\\]", n = "\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)", r = "\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}", c = "(?:([a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-" + t + ")|" + // Direct bracket, parenthesis, or brace content
49
- t + "|" + n + "|" + r + "):)?", i = `(${e}|\\[[^\\]]+\\])`, l = "(?:-)?", h = "(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + // Hex colors
50
- t + "|" + // Bracket content
51
- r + "|" + // Curly brace content
52
- n + "|(?:\\$[^\\s\\/]+))", f = "([a-zA-Z%]*)", a = "(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + t + "|" + r + "|" + n + "|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";
62
+ generateClassNameRegEx(safelist) {
63
+ const typePrefixes = this.getTypePrefixes(safelist);
64
+ const nestedBracketPattern = "\\[[^\\]]+\\]";
65
+ const nestedParenPattern = "\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)";
66
+ const nestedBracePattern = "\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}";
67
+ const prefixPattern = "(?:([a-zA-Z0-9_-]+|[a-zA-Z0-9_-]+(?:-" + nestedBracketPattern + ")|" + // Direct bracket, parenthesis, or brace content
68
+ nestedBracketPattern + "|" + nestedParenPattern + "|" + nestedBracePattern + "):)?";
69
+ const typePattern = `(${typePrefixes}|\\[[^\\]]+\\])`;
70
+ const separator = "(?:-)?";
71
+ const valuePattern = "(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + // Hex colors
72
+ nestedBracketPattern + "|" + // Bracket content
73
+ nestedBracePattern + "|" + // Curly brace content
74
+ nestedParenPattern + "|(?:\\$[^\\s\\/]+))";
75
+ const unitPattern = "([a-zA-Z%]*)";
76
+ const secondaryPattern = "(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|" + nestedBracketPattern + "|" + nestedBracePattern + "|" + nestedParenPattern + "|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";
53
77
  return new RegExp(
54
- c + i + l + h + f + a
78
+ prefixPattern + typePattern + separator + valuePattern + unitPattern + secondaryPattern
55
79
  );
56
80
  }
57
- parse(s, e) {
58
- if (Object.values(this.classes).some((p) => p == null ? void 0 : p[s]))
59
- return [void 0, s, "", "", void 0, void 0];
60
- const t = this.generateClassNameRegEx(e), n = (s + "-dummy").match(t);
61
- if (!n) return null;
62
- const [, r, c, i, l, h, f] = n, a = i === "dummy" ? "" : i.replace("-dummy", "");
63
- return [r, c, a, l || "", h, f];
81
+ parse(className, safelist) {
82
+ if (Object.values(this.classes).some((classObj) => classObj == null ? void 0 : classObj[className])) {
83
+ return [void 0, className, "", "", void 0, void 0];
84
+ }
85
+ const classNameRegEx = this.generateClassNameRegEx(safelist);
86
+ const match = (className + "-dummy").match(classNameRegEx);
87
+ if (!match) return null;
88
+ const [, prefix, type, value, unit, secValue, secUnit] = match;
89
+ const finalValue = value === "dummy" ? "" : value.replace("-dummy", "");
90
+ return [prefix, type, finalValue, unit || "", secValue, secUnit];
64
91
  }
65
92
  // unique value parser
66
- processValue(s, e, t) {
67
- if (!s) return "";
68
- const n = (r) => r.replace(/\{([^}]+)\}/g, (c, i) => {
69
- const l = this.values, h = l !== null ? typeof l[t] == "object" ? l[t][i] : l[i] : void 0;
70
- return typeof h == "string" ? h : c;
71
- });
72
- if (typeof this.values == "object" && this.values !== null && (this.values[t] && typeof this.values[t] == "object" && this.values[t][s] || this.values[s]))
73
- return typeof this.values[t] == "object" && this.values[t] !== null ? this.values[t][s] : this.values[s];
74
- if (s.startsWith("$"))
75
- return `var(--${s.slice(1)})`;
76
- if (s.startsWith("[") && s.endsWith("]") || s.startsWith("(") && s.endsWith(")")) {
77
- const r = s.slice(1, -1).replace(/_/g, " ");
78
- return r.includes("{") ? n(r) : r.startsWith("--") ? `var(${r})` : r;
93
+ processValue(value, unit, group) {
94
+ if (!value) return "";
95
+ const replaceWithValueRegistry = (text) => {
96
+ return text.replace(/\{([^}]+)\}/g, (match, key) => {
97
+ const valueRegistry = this.values;
98
+ const val = valueRegistry !== null ? typeof valueRegistry[group] === "object" ? valueRegistry[group][key] : valueRegistry[key] : void 0;
99
+ return typeof val === "string" ? val : match;
100
+ });
101
+ };
102
+ if (typeof this.values === "object" && this.values !== null && (this.values[group] && typeof this.values[group] === "object" && this.values[group][value] || this.values[value])) {
103
+ if (typeof this.values[group] === "object" && this.values[group] !== null) {
104
+ return this.values[group][value];
105
+ }
106
+ return this.values[value];
107
+ } else if (value.startsWith("$")) {
108
+ return `var(--${value.slice(1)})`;
109
+ } else if (value.startsWith("[") && value.endsWith("]") || value.startsWith("(") && value.endsWith(")")) {
110
+ const cleanValue = value.slice(1, -1).replace(/_/g, " ");
111
+ if (cleanValue.includes("{")) {
112
+ return replaceWithValueRegistry(cleanValue);
113
+ }
114
+ return cleanValue.startsWith("--") ? `var(${cleanValue})` : cleanValue;
79
115
  }
80
- return s + (e || "");
116
+ return value + (unit || "");
81
117
  }
82
- processShorthand(s = "", e = "", t = "", n, r = "", c = "", i = !0) {
83
- const l = this.property[s], h = /^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;
84
- let f = null, a = e || "";
85
- const p = a.match(h);
86
- p && (f = p[1].trim(), a = p[2].trim());
87
- let o;
88
- e.includes(f + ":") ? o = e.startsWith("(") ? `(${a})` : `[${a}]` : o = e;
89
- const u = this.processValue(o, t, s), m = this.processValue(r, c, s);
90
- if (s.startsWith("[") && s.endsWith("]")) {
91
- const d = s.slice(1, -1).split(",").map((y) => y.trim()).map((y) => {
92
- const $ = this.property[y] || y;
93
- return `${typeof $ == "string" && $.startsWith("--") ? String($) : this.toKebabCase(String($))}: ${u}`;
118
+ processShorthand(type = "", value = "", unit = "", prefix, secondValue = "", secondUnit = "", isHyphen = true) {
119
+ const properties = this.property[type];
120
+ const pattern = /^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;
121
+ let extractedFor = null;
122
+ let cleanValue = value || "";
123
+ const matchValue = cleanValue.match(pattern);
124
+ if (matchValue) {
125
+ extractedFor = matchValue[1].trim();
126
+ cleanValue = matchValue[2].trim();
127
+ }
128
+ let finalCleanValue;
129
+ if (value.includes(extractedFor + ":")) {
130
+ finalCleanValue = value.startsWith("(") ? `(${cleanValue})` : `[${cleanValue}]`;
131
+ } else finalCleanValue = value;
132
+ const finalValue = this.processValue(finalCleanValue, unit, type);
133
+ const finalSecValue = this.processValue(secondValue, secondUnit, type);
134
+ if (type.startsWith("[") && type.endsWith("]")) {
135
+ const items = type.slice(1, -1).split(",").map((item) => item.trim());
136
+ const cssRules = items.map((item) => {
137
+ const prop = this.property[item] || item;
138
+ const finalProperty = typeof prop === "string" && prop.startsWith("--") ? String(prop) : this.toKebabCase(String(prop));
139
+ return `${finalProperty}: ${finalValue}`;
94
140
  }).join("; ");
95
141
  return {
96
- className: `${`[${s.slice(1, -1)}]${i ? "-" : ""}${e}${t}`}`,
97
- cssRules: d,
142
+ className: `${`[${type.slice(1, -1)}]${isHyphen ? "-" : ""}${value}${unit}`}`,
143
+ cssRules,
98
144
  // return css rules directly
99
145
  value: null,
100
146
  // and set value to null to prevent value duplication
101
- prefix: n
147
+ prefix
102
148
  };
103
149
  }
104
- if (l) {
105
- if (typeof l == "object" && "property" in l && "value" in l) {
106
- const d = typeof l.property == "function" ? l.property({
107
- value: t ? e : u,
108
- unit: t,
109
- secondValue: c ? r : m,
110
- secondUnit: c,
111
- key: f
112
- }) : l.property, y = l.value;
113
- let $;
114
- if (typeof y == "function")
115
- $ = y({
116
- value: t ? e : u,
117
- unit: t,
118
- secondValue: c ? r : m,
119
- secondUnit: c,
120
- key: f,
121
- property: d
150
+ if (properties) {
151
+ if (typeof properties === "object" && "property" in properties && "value" in properties) {
152
+ const groupValue = properties.group && this.values[properties.group] ? this.values[properties.group][finalValue] : unit ? value : finalValue;
153
+ const property = typeof properties.property === "function" ? properties.property({
154
+ value: groupValue,
155
+ unit,
156
+ secondValue: secondUnit ? secondValue : finalSecValue,
157
+ secondUnit,
158
+ key: extractedFor
159
+ }) : properties.property;
160
+ const template = properties.value;
161
+ let processedValue;
162
+ if (typeof template === "function") {
163
+ processedValue = template({
164
+ value: groupValue,
165
+ unit,
166
+ secondValue: secondUnit ? secondValue : finalSecValue,
167
+ secondUnit,
168
+ key: extractedFor,
169
+ property
122
170
  });
123
- else if (y && typeof y == "string") {
124
- const C = l.group || s, A = this.processValue(o, t, C);
125
- console.log(o), $ = this.values[o] || this.values[C][o] || o.includes("{") || y.includes("{") ? this.parseValuePattern(C, y, A, "", m, "") : u;
126
- } else $ = null;
171
+ } else if (template && typeof template === "string") {
172
+ const valuesGroup = properties.group || type;
173
+ const newValue = this.processValue(finalCleanValue, unit, valuesGroup);
174
+ processedValue = this.values[finalCleanValue] || this.values[valuesGroup][finalCleanValue] || finalCleanValue.includes("{") || template.includes("{") ? this.parseValuePattern(valuesGroup, template, newValue, "", finalSecValue, "") : finalValue;
175
+ } else processedValue = null;
176
+ const className = `${type}${value ? `${isHyphen ? isHyphen ? "-" : "" : ""}${value}${unit}` : ""}${secondValue ? `/${secondValue}${secondUnit}` : ""}`;
127
177
  return {
128
- className: `${s}${e ? `${i && i ? "-" : ""}${e}${t}` : ""}${r ? `/${r}${c}` : ""}`,
129
- cssRules: Array.isArray(d) || typeof d == "string" && d.includes(":") ? d : this.toKebabCase(String(d)),
130
- value: y === null ? null : e.startsWith("[") ? u : $,
131
- prefix: n
178
+ className,
179
+ cssRules: Array.isArray(property) ? property : typeof property === "string" && property.includes(":") ? property : this.toKebabCase(String(property)),
180
+ value: template === null ? null : value.startsWith("[") ? finalValue : processedValue,
181
+ prefix
132
182
  };
133
183
  }
134
- const g = typeof l == "function" ? l({
135
- value: t ? e : u,
136
- unit: t,
137
- secondValue: c ? r : m,
138
- secondUnit: c,
139
- key: f
140
- }) : l;
184
+ const finalRegProperty = typeof properties === "function" ? properties({
185
+ value: unit ? value : finalValue,
186
+ unit,
187
+ secondValue: secondUnit ? secondValue : finalSecValue,
188
+ secondUnit,
189
+ key: extractedFor
190
+ }) : properties;
141
191
  return {
142
- className: `${s}${e ? (i ? "-" : "") + e + t : ""}`,
143
- cssRules: Array.isArray(l) ? g : typeof g == "string" && g.startsWith("value:") ? g.slice(6) : this.toKebabCase(String(g)),
144
- value: typeof g == "string" && g.startsWith("value:") ? null : u,
145
- prefix: n
192
+ className: `${type}${value ? (isHyphen ? "-" : "") + value + unit : ""}`,
193
+ cssRules: Array.isArray(properties) ? finalRegProperty : typeof finalRegProperty === "string" && finalRegProperty.startsWith("value:") ? finalRegProperty.slice(6) : this.toKebabCase(String(finalRegProperty)),
194
+ value: typeof finalRegProperty === "string" && finalRegProperty.startsWith("value:") ? null : finalValue,
195
+ prefix
146
196
  };
147
197
  }
148
198
  return null;
149
199
  }
150
- parseValuePattern(s, e, t, n, r, c) {
151
- if (!e.includes("{0}") && !e.includes("{1") && !e.includes("||"))
152
- return e;
153
- const [i, l] = e.split("||").map((a) => a.trim()), h = this.processValue(t, n, s), f = this.processValue(r, c, s);
154
- if (e.includes("{0}") && e.includes("{1") || e.includes("{1")) {
155
- let a = i;
156
- if (t && (a = a.replace("{0}", h)), e.includes("{1")) {
157
- const p = a.match(/{1([^}]*)}/);
158
- if (e.includes("{1}"))
159
- r ? a = r.startsWith("[") ? f : a.replace("{1}", f) : a = l;
160
- else if (p) {
161
- const o = p[0], u = p[1].trim();
162
- let m = f;
163
- !m && u.includes("|") ? m = u.split("|")[1].trim() : m || (m = ""), a = t.startsWith("[") ? h : a.replace(o, m);
200
+ parseValuePattern(group, pattern, inputValue, inputUnit, inputSecValue, inputSecUnit) {
201
+ if (!pattern.includes("{0}") && !pattern.includes("{1") && !pattern.includes("||"))
202
+ return pattern;
203
+ const [value, defaultValue] = pattern.split("||").map((s) => s.trim());
204
+ const finalValue = this.processValue(inputValue, inputUnit, group);
205
+ const finalSecValue = this.processValue(inputSecValue, inputSecUnit, group);
206
+ if (pattern.includes("{0}") && pattern.includes("{1") || pattern.includes("{1")) {
207
+ let computedValue = value;
208
+ if (inputValue) {
209
+ computedValue = computedValue.replace("{0}", finalValue);
210
+ }
211
+ if (pattern.includes("{1")) {
212
+ const match = computedValue.match(/{1([^}]*)}/);
213
+ if (pattern.includes("{1}")) {
214
+ if (inputSecValue) {
215
+ computedValue = inputSecValue.startsWith("[") ? finalSecValue : computedValue.replace("{1}", finalSecValue);
216
+ } else {
217
+ computedValue = defaultValue;
218
+ }
219
+ } else if (match) {
220
+ const fullMatch = match[0];
221
+ const innerContent = match[1].trim();
222
+ let replacementValue = finalSecValue;
223
+ if (!replacementValue && innerContent.includes("|")) {
224
+ replacementValue = innerContent.split("|")[1].trim();
225
+ } else if (!replacementValue) {
226
+ replacementValue = "";
227
+ }
228
+ computedValue = inputValue.startsWith("[") ? finalValue : computedValue.replace(fullMatch, replacementValue);
164
229
  }
165
230
  }
166
- return t ? a : l || i;
167
- } else
168
- return t ? t.startsWith("[") ? h : i.replace("{0}", h) : l || i;
231
+ return inputValue ? computedValue : defaultValue || value;
232
+ } else {
233
+ return inputValue ? inputValue.startsWith("[") ? finalValue : value.replace("{0}", finalValue) : defaultValue || value;
234
+ }
169
235
  }
170
- getParentClass(s) {
236
+ getParentClass(className) {
171
237
  return Object.keys(this.classes).filter(
172
- (e) => Object.prototype.hasOwnProperty.call(
173
- this.classes[e],
174
- s
238
+ (cssProperty) => Object.prototype.hasOwnProperty.call(
239
+ this.classes[cssProperty],
240
+ className
175
241
  )
176
242
  );
177
243
  }
178
- processCustomClass(s, e = "", t = "", n = "", r = "", c = "", i = !0) {
179
- if (!s) return null;
180
- const l = this.getParentClass(s);
181
- if (l.length > 0) {
182
- const h = l.map((p) => {
183
- const o = this.classes[p];
184
- if (!o) return "";
185
- const u = this.parseValuePattern(
186
- s,
187
- o[s] || "",
188
- e,
189
- t,
190
- r,
191
- c
244
+ processCustomClass(className, value = "", unit = "", prefix = "", secValue = "", secUnit = "", isHyphen = true) {
245
+ if (!className) return null;
246
+ const properties = this.getParentClass(className);
247
+ if (properties.length > 0) {
248
+ const rules = properties.map((prop) => {
249
+ const classObj = this.classes[prop];
250
+ if (!classObj) return "";
251
+ const processedValue = this.parseValuePattern(
252
+ className,
253
+ classObj[className] || "",
254
+ value,
255
+ unit,
256
+ secValue,
257
+ secUnit
192
258
  );
193
- return `${this.toKebabCase(String(p))}: ${u}`;
194
- }).filter(Boolean).join("; "), f = s.slice(-(e + t).length), a = `${s}${e ? `${i ? "-" : ""}${e}${t}` : ""}${r ? `/${r}${c}` : ""}`;
259
+ return `${this.toKebabCase(String(prop))}: ${processedValue}`;
260
+ }).filter(Boolean).join("; ");
261
+ const isValueType = className.slice(-(value + unit).length);
262
+ const finalClassName = `${className}${value ? `${isHyphen ? "-" : ""}${value}${unit}` : ""}${secValue ? `/${secValue}${secUnit}` : ""}`;
195
263
  return {
196
- className: e === f ? s : a,
197
- cssRules: h,
264
+ className: value === isValueType ? className : finalClassName,
265
+ cssRules: rules,
198
266
  value: null,
199
- prefix: n
267
+ prefix
200
268
  };
201
269
  }
202
270
  return null;
203
271
  }
204
- processAlias(s, e = "") {
205
- const t = this.aliases[s];
206
- if (!t) return null;
207
- const n = t.split(" "), r = [];
208
- return n.forEach((c) => {
209
- const [i, l] = c.split(":"), h = l || i, f = l ? i : void 0, a = this.parse(c), p = a || [f, h, "", ""];
210
- if (!p) return;
211
- const [o, u, m, g, d, y] = p, $ = this.processShorthand(u, m, g, void 0, d, y), x = this.processCustomClass(u, m, g, o, d, y);
212
- if (x) {
213
- const { cssRules: C } = x;
214
- r.push(C);
272
+ processAlias(className, prefix = "") {
273
+ const alias = this.aliases[className];
274
+ if (!alias) return null;
275
+ const aliasClasses = alias.split(" ");
276
+ const combinedRules = [];
277
+ aliasClasses.forEach((aliasClass) => {
278
+ const [rprefix, rtype] = aliasClass.split(":");
279
+ const getType = rtype || rprefix;
280
+ const getPrefix = rtype ? rprefix : void 0;
281
+ const parts = this.parse(aliasClass);
282
+ const parsed = parts ? parts : [getPrefix, getType, "", ""];
283
+ if (!parsed) return;
284
+ const [prefix2, type, value, unit, secValue, secUnit] = parsed;
285
+ const result = this.processShorthand(type, value, unit, void 0, secValue, secUnit);
286
+ const shouldClasses = this.processCustomClass(type, value, unit, prefix2, secValue, secUnit);
287
+ if (shouldClasses) {
288
+ const { cssRules } = shouldClasses;
289
+ combinedRules.push(cssRules);
215
290
  return;
216
291
  }
217
- if ($) {
218
- const C = $.value !== null ? `: ${$.value}` : "";
219
- Array.isArray($.cssRules) ? $.cssRules.forEach((A) => {
220
- r.push(`${this.toKebabCase(A)}${C}`);
221
- }) : r.push(`${$.cssRules}${C}`);
292
+ if (result) {
293
+ const value2 = result.value !== null ? `: ${result.value}` : "";
294
+ if (Array.isArray(result.cssRules)) {
295
+ result.cssRules.forEach((rule) => {
296
+ combinedRules.push(`${this.toKebabCase(rule)}${value2}`);
297
+ });
298
+ } else {
299
+ combinedRules.push(`${result.cssRules}${value2}`);
300
+ }
222
301
  }
223
- }), {
224
- className: s,
225
- cssRules: r.join("; "),
302
+ });
303
+ return {
304
+ className,
305
+ cssRules: combinedRules.join("; "),
226
306
  value: null,
227
- prefix: e
307
+ prefix
228
308
  };
229
309
  }
230
- process(s) {
231
- const e = Array.isArray(s) ? s : s.split(/\s+/), t = [];
232
- return e.forEach((n) => {
233
- if (!n) return this;
234
- const [r, c] = n.split(":"), i = c || r, l = c ? r : void 0, h = this.processAlias(i, l);
235
- if (h) {
236
- const { className: A, cssRules: b } = h;
237
- t.push({
238
- className: A,
239
- cssRules: b,
310
+ process(classNames) {
311
+ const classList = Array.isArray(classNames) ? classNames : classNames.split(/\s+/);
312
+ const results = [];
313
+ classList.forEach((className) => {
314
+ if (!className) return this;
315
+ const [rprefix, rtype] = className.split(":");
316
+ const getType = rtype || rprefix;
317
+ const getPrefix = rtype ? rprefix : void 0;
318
+ const aliasResult = this.processAlias(getType, getPrefix);
319
+ if (aliasResult) {
320
+ const { className: aliasClassName, cssRules } = aliasResult;
321
+ results.push({
322
+ className: aliasClassName,
323
+ cssRules,
240
324
  value: null,
241
- prefix: l
325
+ prefix: getPrefix
242
326
  });
243
327
  return;
244
328
  }
245
- const f = this.parse(n), a = f || [l, i, "", ""];
246
- if (!a) return this;
247
- const [p, o, u, m, g, d] = a, y = !n.includes((o || "") + (u || "")), $ = this.getParentClass(`${o}${y ? "-" : ""}${u}`).length > 0 ? `${o}${y ? "-" : ""}${u}` : o, x = this.processCustomClass(
248
- $,
249
- u,
250
- m,
251
- p,
252
- g,
253
- d,
254
- y
329
+ const parts = this.parse(className);
330
+ const parsed = parts ? parts : [getPrefix, getType, "", ""];
331
+ if (!parsed) return this;
332
+ const [prefix, type, value, unit, secValue, secUnit] = parsed;
333
+ const isHyphen = !className.includes((type || "") + (value || ""));
334
+ const classFromClasses = this.getParentClass(`${type}${isHyphen ? "-" : ""}${value}`).length > 0 ? `${type}${isHyphen ? "-" : ""}${value}` : type;
335
+ const shouldClasses = this.processCustomClass(
336
+ classFromClasses,
337
+ value,
338
+ unit,
339
+ prefix,
340
+ secValue,
341
+ secUnit,
342
+ isHyphen
255
343
  );
256
- if (x) {
257
- const { className: A, cssRules: b, prefix: v } = x;
258
- t.push({
259
- className: A,
260
- cssRules: b,
344
+ if (shouldClasses) {
345
+ const { className: className2, cssRules, prefix: prefix2 } = shouldClasses;
346
+ results.push({
347
+ className: className2,
348
+ cssRules,
261
349
  value: null,
262
- prefix: v
350
+ prefix: prefix2
263
351
  });
264
352
  return;
265
353
  }
266
- const C = this.processShorthand(o, u, m, p, g, d, y);
267
- if (C) {
268
- const { className: A, cssRules: b, value: v, prefix: Z } = C;
269
- t.push({
270
- className: A,
271
- cssRules: b,
272
- value: v,
273
- prefix: Z
354
+ const result = this.processShorthand(type, value, unit, prefix, secValue, secUnit, isHyphen);
355
+ if (result) {
356
+ const { className: className2, cssRules, value: ruleValue, prefix: rulePrefix } = result;
357
+ results.push({
358
+ className: className2,
359
+ cssRules,
360
+ value: ruleValue,
361
+ prefix: rulePrefix
274
362
  });
275
363
  }
276
- }), t;
364
+ });
365
+ return results;
277
366
  }
278
367
  }
279
368
  export {
280
- _ as TenoxUI,
281
- _ as default
369
+ TenoxUI,
370
+ TenoxUI as default
282
371
  };
283
372
  //# sourceMappingURL=index.es.js.map