@tenoxui/moxie 0.3.1 → 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.cjs +371 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +305 -216
- package/dist/index.es.js.map +1 -1
- package/dist/index.iife.js +374 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.umd.js +375 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/index.d.ts +8 -12
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
@@ -1,283 +1,372 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var
|
4
|
-
var
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
14
|
-
this.property =
|
15
|
-
moxie: ({ key
|
16
|
-
},
|
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(
|
19
|
-
if (/^(webkit|moz|ms|o)[A-Z]/.test(
|
20
|
-
const
|
21
|
-
if (
|
22
|
-
const
|
23
|
-
return `-${
|
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
|
34
|
+
return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
27
35
|
}
|
28
|
-
escapeCSSSelector(
|
29
|
-
return
|
36
|
+
escapeCSSSelector(str) {
|
37
|
+
return str.replace(/([ #{}.:;?%&,@+*~'"!^$[\]()=>|/])/g, "\\$1");
|
30
38
|
}
|
31
|
-
getAllClassNames(
|
32
|
-
if (!
|
33
|
-
const
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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(
|
41
|
-
const
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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(
|
48
|
-
const
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
78
|
+
prefixPattern + typePattern + separator + valuePattern + unitPattern + secondaryPattern
|
55
79
|
);
|
56
80
|
}
|
57
|
-
parse(
|
58
|
-
if (Object.values(this.classes).some((
|
59
|
-
return [void 0,
|
60
|
-
|
61
|
-
|
62
|
-
const
|
63
|
-
|
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(
|
67
|
-
if (!
|
68
|
-
const
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
116
|
+
return value + (unit || "");
|
81
117
|
}
|
82
|
-
processShorthand(
|
83
|
-
const
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
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: `${`[${
|
97
|
-
cssRules
|
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
|
147
|
+
prefix
|
102
148
|
};
|
103
149
|
}
|
104
|
-
if (
|
105
|
-
if (typeof
|
106
|
-
const
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
secondUnit:
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
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 (
|
124
|
-
const
|
125
|
-
|
126
|
-
|
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
|
129
|
-
cssRules: Array.isArray(
|
130
|
-
value:
|
131
|
-
prefix
|
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
|
135
|
-
value:
|
136
|
-
unit
|
137
|
-
secondValue:
|
138
|
-
secondUnit
|
139
|
-
key:
|
140
|
-
}) :
|
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: `${
|
143
|
-
cssRules: Array.isArray(
|
144
|
-
value: typeof
|
145
|
-
prefix
|
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(
|
151
|
-
if (!
|
152
|
-
return
|
153
|
-
const [
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
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
|
167
|
-
} else
|
168
|
-
return
|
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(
|
236
|
+
getParentClass(className) {
|
171
237
|
return Object.keys(this.classes).filter(
|
172
|
-
(
|
173
|
-
this.classes[
|
174
|
-
|
238
|
+
(cssProperty) => Object.prototype.hasOwnProperty.call(
|
239
|
+
this.classes[cssProperty],
|
240
|
+
className
|
175
241
|
)
|
176
242
|
);
|
177
243
|
}
|
178
|
-
processCustomClass(
|
179
|
-
if (!
|
180
|
-
const
|
181
|
-
if (
|
182
|
-
const
|
183
|
-
const
|
184
|
-
if (!
|
185
|
-
const
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
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(
|
194
|
-
}).filter(Boolean).join("; ")
|
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:
|
197
|
-
cssRules:
|
264
|
+
className: value === isValueType ? className : finalClassName,
|
265
|
+
cssRules: rules,
|
198
266
|
value: null,
|
199
|
-
prefix
|
267
|
+
prefix
|
200
268
|
};
|
201
269
|
}
|
202
270
|
return null;
|
203
271
|
}
|
204
|
-
processAlias(
|
205
|
-
const
|
206
|
-
if (!
|
207
|
-
const
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
const
|
212
|
-
|
213
|
-
|
214
|
-
|
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
|
219
|
-
Array.isArray(
|
220
|
-
|
221
|
-
|
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
|
-
|
225
|
-
|
302
|
+
});
|
303
|
+
return {
|
304
|
+
className,
|
305
|
+
cssRules: combinedRules.join("; "),
|
226
306
|
value: null,
|
227
|
-
prefix
|
307
|
+
prefix
|
228
308
|
};
|
229
309
|
}
|
230
|
-
process(
|
231
|
-
const
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
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:
|
325
|
+
prefix: getPrefix
|
242
326
|
});
|
243
327
|
return;
|
244
328
|
}
|
245
|
-
const
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
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 (
|
257
|
-
const { className:
|
258
|
-
|
259
|
-
className:
|
260
|
-
cssRules
|
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:
|
350
|
+
prefix: prefix2
|
263
351
|
});
|
264
352
|
return;
|
265
353
|
}
|
266
|
-
const
|
267
|
-
if (
|
268
|
-
const { className:
|
269
|
-
|
270
|
-
className:
|
271
|
-
cssRules
|
272
|
-
value:
|
273
|
-
prefix:
|
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
|
-
})
|
364
|
+
});
|
365
|
+
return results;
|
277
366
|
}
|
278
367
|
}
|
279
368
|
export {
|
280
|
-
|
281
|
-
|
369
|
+
TenoxUI,
|
370
|
+
TenoxUI as default
|
282
371
|
};
|
283
372
|
//# sourceMappingURL=index.es.js.map
|