@pequity/squirrel 11.0.0 → 11.0.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/cjs/chunks/index.js +559 -345
- package/dist/cjs/chunks/p-btn.js +1 -1
- package/dist/cjs/dateLocale.js +37 -38
- package/dist/cjs/index.js +8 -7
- package/dist/cjs/inputClasses.js +3 -3
- package/dist/es/chunks/index.js +559 -345
- package/dist/es/chunks/p-btn.js +2 -2
- package/dist/es/dateLocale.js +37 -38
- package/dist/es/index.js +37 -36
- package/dist/es/inputClasses.js +4 -4
- package/dist/squirrel/components/p-link/p-link.vue.d.ts +2 -2
- package/dist/squirrel/components/p-pagination-info/p-pagination-info.vue.d.ts +2 -2
- package/dist/squirrel/components/p-table/p-table.vue.d.ts +3 -1
- package/dist/squirrel/components/p-table-header-cell/p-table-header-cell.vue.d.ts +2 -2
- package/dist/squirrel.css +1 -1
- package/package.json +31 -31
- package/squirrel/plugin/index.spec.ts +10 -10
- package/squirrel/plugin/index.ts +2 -2
- package/squirrel/utils/dateLocale.spec.ts +5 -5
- package/squirrel/utils/dateLocale.ts +3 -3
- /package/squirrel/locales/{fr-CA.json → fr-FR.json} +0 -0
package/dist/cjs/chunks/index.js
CHANGED
|
@@ -1,234 +1,389 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var SPACE_REGEX = /\s+/g;
|
|
3
|
+
var removeExtraSpaces = (str) => {
|
|
4
|
+
if (typeof str !== "string" || !str) return str;
|
|
5
|
+
return str.replace(SPACE_REGEX, " ").trim();
|
|
6
|
+
};
|
|
7
|
+
var cx = (...classnames) => {
|
|
8
|
+
const classList = [];
|
|
9
|
+
const buildClassString = (input) => {
|
|
10
|
+
if (!input && input !== 0 && input !== 0n) return;
|
|
11
|
+
if (Array.isArray(input)) {
|
|
12
|
+
for (let i = 0, len = input.length; i < len; i++) buildClassString(input[i]);
|
|
7
13
|
return;
|
|
8
14
|
}
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
} else if (
|
|
14
|
-
|
|
15
|
-
for (let
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const type = typeof input;
|
|
16
|
+
if (type === "string" || type === "number" || type === "bigint") {
|
|
17
|
+
if (type === "number" && input !== input) return;
|
|
18
|
+
classList.push(String(input));
|
|
19
|
+
} else if (type === "object") {
|
|
20
|
+
const keys = Object.keys(input);
|
|
21
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
22
|
+
const key = keys[i];
|
|
23
|
+
if (input[key]) classList.push(key);
|
|
18
24
|
}
|
|
19
25
|
}
|
|
20
26
|
};
|
|
21
|
-
for (let
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
for (let i = 0, len = classnames.length; i < len; i++) {
|
|
28
|
+
const c = classnames[i];
|
|
29
|
+
if (c !== null && c !== void 0) buildClassString(c);
|
|
24
30
|
}
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
return classList.length > 0 ? removeExtraSpaces(classList.join(" ")) : void 0;
|
|
32
|
+
};
|
|
33
|
+
var falsyToString = (value) => value === false ? "false" : value === true ? "true" : value === 0 ? "0" : value;
|
|
34
|
+
var isEmptyObject = (obj) => {
|
|
35
|
+
if (!obj || typeof obj !== "object") return true;
|
|
36
|
+
for (const _ in obj) return false;
|
|
29
37
|
return true;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
};
|
|
39
|
+
var isEqual = (obj1, obj2) => {
|
|
40
|
+
if (obj1 === obj2) return true;
|
|
41
|
+
if (!obj1 || !obj2) return false;
|
|
42
|
+
const keys1 = Object.keys(obj1);
|
|
43
|
+
const keys2 = Object.keys(obj2);
|
|
44
|
+
if (keys1.length !== keys2.length) return false;
|
|
45
|
+
for (let i = 0; i < keys1.length; i++) {
|
|
46
|
+
const key = keys1[i];
|
|
47
|
+
if (!keys2.includes(key)) return false;
|
|
48
|
+
if (obj1[key] !== obj2[key]) return false;
|
|
38
49
|
}
|
|
39
50
|
return true;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
};
|
|
52
|
+
var joinObjects = (obj1, obj2) => {
|
|
53
|
+
for (const key in obj2) {
|
|
54
|
+
if (Object.prototype.hasOwnProperty.call(obj2, key)) {
|
|
55
|
+
const val2 = obj2[key];
|
|
56
|
+
if (key in obj1) {
|
|
57
|
+
obj1[key] = cx(obj1[key], val2);
|
|
58
|
+
} else {
|
|
59
|
+
obj1[key] = val2;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
44
62
|
}
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
63
|
+
return obj1;
|
|
64
|
+
};
|
|
65
|
+
var flat = (arr, target) => {
|
|
66
|
+
for (let i = 0; i < arr.length; i++) {
|
|
67
|
+
const el = arr[i];
|
|
68
|
+
if (Array.isArray(el)) flat(el, target);
|
|
69
|
+
else if (el) target.push(el);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var flatMergeArrays = (...arrays) => {
|
|
73
|
+
const result = [];
|
|
74
|
+
flat(arrays, result);
|
|
75
|
+
const filtered = [];
|
|
76
|
+
for (let i = 0; i < result.length; i++) {
|
|
77
|
+
if (result[i]) filtered.push(result[i]);
|
|
50
78
|
}
|
|
79
|
+
return filtered;
|
|
51
80
|
};
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
} else
|
|
81
|
+
var mergeObjects = (obj1, obj2) => {
|
|
82
|
+
const result = {};
|
|
83
|
+
for (const key in obj1) {
|
|
84
|
+
const val1 = obj1[key];
|
|
85
|
+
if (key in obj2) {
|
|
86
|
+
const val2 = obj2[key];
|
|
87
|
+
if (Array.isArray(val1) || Array.isArray(val2)) {
|
|
88
|
+
result[key] = flatMergeArrays(val2, val1);
|
|
89
|
+
} else if (typeof val1 === "object" && typeof val2 === "object" && val1 && val2) {
|
|
90
|
+
result[key] = mergeObjects(val1, val2);
|
|
91
|
+
} else {
|
|
92
|
+
result[key] = val2 + " " + val1;
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
result[key] = val1;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
for (const key in obj2) {
|
|
99
|
+
if (!(key in obj1)) {
|
|
100
|
+
result[key] = obj2[key];
|
|
101
|
+
}
|
|
66
102
|
}
|
|
67
|
-
|
|
68
|
-
return n;
|
|
103
|
+
return result;
|
|
69
104
|
};
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
105
|
+
var defaultConfig = {
|
|
106
|
+
twMerge: true,
|
|
107
|
+
twMergeConfig: {}
|
|
108
|
+
};
|
|
109
|
+
function createState() {
|
|
110
|
+
let cachedTwMerge = null;
|
|
111
|
+
let cachedTwMergeConfig = {};
|
|
112
|
+
let didTwMergeConfigChange = false;
|
|
113
|
+
return {
|
|
114
|
+
get cachedTwMerge() {
|
|
115
|
+
return cachedTwMerge;
|
|
116
|
+
},
|
|
117
|
+
set cachedTwMerge(value) {
|
|
118
|
+
cachedTwMerge = value;
|
|
119
|
+
},
|
|
120
|
+
get cachedTwMergeConfig() {
|
|
121
|
+
return cachedTwMergeConfig;
|
|
122
|
+
},
|
|
123
|
+
set cachedTwMergeConfig(value) {
|
|
124
|
+
cachedTwMergeConfig = value;
|
|
125
|
+
},
|
|
126
|
+
get didTwMergeConfigChange() {
|
|
127
|
+
return didTwMergeConfigChange;
|
|
128
|
+
},
|
|
129
|
+
set didTwMergeConfigChange(value) {
|
|
130
|
+
didTwMergeConfigChange = value;
|
|
131
|
+
},
|
|
132
|
+
reset() {
|
|
133
|
+
cachedTwMerge = null;
|
|
134
|
+
cachedTwMergeConfig = {};
|
|
135
|
+
didTwMergeConfigChange = false;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
88
138
|
}
|
|
89
|
-
var
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
139
|
+
var state = createState();
|
|
140
|
+
var getTailwindVariants = (cn2) => {
|
|
141
|
+
const tv2 = (options, configProp) => {
|
|
142
|
+
const {
|
|
143
|
+
extend = null,
|
|
144
|
+
slots: slotProps = {},
|
|
145
|
+
variants: variantsProps = {},
|
|
146
|
+
compoundVariants: compoundVariantsProps = [],
|
|
147
|
+
compoundSlots = [],
|
|
148
|
+
defaultVariants: defaultVariantsProps = {}
|
|
149
|
+
} = options;
|
|
150
|
+
const config = { ...defaultConfig, ...configProp };
|
|
151
|
+
const base = extend?.base ? cx(extend.base, options?.base) : options?.base;
|
|
152
|
+
const variants = extend?.variants && !isEmptyObject(extend.variants) ? mergeObjects(variantsProps, extend.variants) : variantsProps;
|
|
153
|
+
const defaultVariants = extend?.defaultVariants && !isEmptyObject(extend.defaultVariants) ? { ...extend.defaultVariants, ...defaultVariantsProps } : defaultVariantsProps;
|
|
154
|
+
if (!isEmptyObject(config.twMergeConfig) && !isEqual(config.twMergeConfig, state.cachedTwMergeConfig)) {
|
|
155
|
+
state.didTwMergeConfigChange = true;
|
|
156
|
+
state.cachedTwMergeConfig = config.twMergeConfig;
|
|
157
|
+
}
|
|
158
|
+
const isExtendedSlotsEmpty = isEmptyObject(extend?.slots);
|
|
159
|
+
const componentSlots = !isEmptyObject(slotProps) ? {
|
|
160
|
+
// add "base" to the slots object
|
|
161
|
+
base: cx(options?.base, isExtendedSlotsEmpty && extend?.base),
|
|
162
|
+
...slotProps
|
|
163
|
+
} : {};
|
|
164
|
+
const slots = isExtendedSlotsEmpty ? componentSlots : joinObjects(
|
|
165
|
+
{ ...extend?.slots },
|
|
166
|
+
isEmptyObject(componentSlots) ? { base: options?.base } : componentSlots
|
|
167
|
+
);
|
|
168
|
+
const compoundVariants = isEmptyObject(extend?.compoundVariants) ? compoundVariantsProps : flatMergeArrays(extend?.compoundVariants, compoundVariantsProps);
|
|
169
|
+
const component = (props) => {
|
|
170
|
+
if (isEmptyObject(variants) && isEmptyObject(slotProps) && isExtendedSlotsEmpty) {
|
|
171
|
+
return cn2(base, props?.class, props?.className)(config);
|
|
172
|
+
}
|
|
173
|
+
if (compoundVariants && !Array.isArray(compoundVariants)) {
|
|
174
|
+
throw new TypeError(
|
|
175
|
+
`The "compoundVariants" prop must be an array. Received: ${typeof compoundVariants}`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
if (compoundSlots && !Array.isArray(compoundSlots)) {
|
|
179
|
+
throw new TypeError(
|
|
180
|
+
`The "compoundSlots" prop must be an array. Received: ${typeof compoundSlots}`
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
const getVariantValue = (variant, vrs = variants, _slotKey = null, slotProps2 = null) => {
|
|
184
|
+
const variantObj = vrs[variant];
|
|
185
|
+
if (!variantObj || isEmptyObject(variantObj)) {
|
|
186
|
+
return null;
|
|
115
187
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
if (s === null) return null;
|
|
122
|
-
let i2 = h(s), l = Array.isArray(d$1.responsiveVariants) && d$1.responsiveVariants.length > 0 || d$1.responsiveVariants === true, f2 = E?.[t], o = [];
|
|
123
|
-
if (typeof i2 == "object" && l) for (let [C2, H] of Object.entries(i2)) {
|
|
124
|
-
let te = r[H];
|
|
125
|
-
if (C2 === "initial") {
|
|
126
|
-
f2 = H;
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
Array.isArray(d$1.responsiveVariants) && !d$1.responsiveVariants.includes(C2) || (o = Y(C2, te, o, n));
|
|
188
|
+
const variantProp = slotProps2?.[variant] ?? props?.[variant];
|
|
189
|
+
if (variantProp === null) return null;
|
|
190
|
+
const variantKey = falsyToString(variantProp);
|
|
191
|
+
if (typeof variantKey === "object") {
|
|
192
|
+
return null;
|
|
130
193
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
194
|
+
const defaultVariantProp = defaultVariants?.[variant];
|
|
195
|
+
const key = variantKey != null ? variantKey : falsyToString(defaultVariantProp);
|
|
196
|
+
const value = variantObj[key || "false"];
|
|
197
|
+
return value;
|
|
198
|
+
};
|
|
199
|
+
const getVariantClassNames = () => {
|
|
200
|
+
if (!variants) return null;
|
|
201
|
+
const keys = Object.keys(variants);
|
|
202
|
+
const result = [];
|
|
203
|
+
for (let i = 0; i < keys.length; i++) {
|
|
204
|
+
const value = getVariantValue(keys[i], variants);
|
|
205
|
+
if (value) result.push(value);
|
|
139
206
|
}
|
|
140
|
-
return
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
207
|
+
return result;
|
|
208
|
+
};
|
|
209
|
+
const getVariantClassNamesBySlotKey = (slotKey, slotProps2) => {
|
|
210
|
+
if (!variants || typeof variants !== "object") return null;
|
|
211
|
+
const result = [];
|
|
212
|
+
for (const variant in variants) {
|
|
213
|
+
const variantValue = getVariantValue(variant, variants, slotKey, slotProps2);
|
|
214
|
+
const value = slotKey === "base" && typeof variantValue === "string" ? variantValue : variantValue && variantValue[slotKey];
|
|
215
|
+
if (value) result.push(value);
|
|
147
216
|
}
|
|
148
|
-
return
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
217
|
+
return result;
|
|
218
|
+
};
|
|
219
|
+
const propsWithoutUndefined = {};
|
|
220
|
+
for (const prop in props) {
|
|
221
|
+
const value = props[prop];
|
|
222
|
+
if (value !== void 0) propsWithoutUndefined[prop] = value;
|
|
153
223
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
224
|
+
const getCompleteProps = (key, slotProps2) => {
|
|
225
|
+
const initialProp = typeof props?.[key] === "object" ? {
|
|
226
|
+
[key]: props[key]?.initial
|
|
227
|
+
} : {};
|
|
228
|
+
return {
|
|
229
|
+
...defaultVariants,
|
|
230
|
+
...propsWithoutUndefined,
|
|
231
|
+
...initialProp,
|
|
232
|
+
...slotProps2
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
const getCompoundVariantsValue = (cv = [], slotProps2) => {
|
|
236
|
+
const result = [];
|
|
237
|
+
const cvLength = cv.length;
|
|
238
|
+
for (let i = 0; i < cvLength; i++) {
|
|
239
|
+
const { class: tvClass, className: tvClassName, ...compoundVariantOptions } = cv[i];
|
|
240
|
+
let isValid = true;
|
|
241
|
+
const completeProps = getCompleteProps(null, slotProps2);
|
|
242
|
+
for (const key in compoundVariantOptions) {
|
|
243
|
+
const value = compoundVariantOptions[key];
|
|
244
|
+
const completePropsValue = completeProps[key];
|
|
245
|
+
if (Array.isArray(value)) {
|
|
246
|
+
if (!value.includes(completePropsValue)) {
|
|
247
|
+
isValid = false;
|
|
166
248
|
break;
|
|
167
249
|
}
|
|
168
250
|
} else {
|
|
169
|
-
if ((
|
|
170
|
-
|
|
171
|
-
|
|
251
|
+
if ((value == null || value === false) && (completePropsValue == null || completePropsValue === false))
|
|
252
|
+
continue;
|
|
253
|
+
if (completePropsValue !== value) {
|
|
254
|
+
isValid = false;
|
|
172
255
|
break;
|
|
173
256
|
}
|
|
174
257
|
}
|
|
175
258
|
}
|
|
176
|
-
|
|
259
|
+
if (isValid) {
|
|
260
|
+
if (tvClass) result.push(tvClass);
|
|
261
|
+
if (tvClassName) result.push(tvClassName);
|
|
262
|
+
}
|
|
177
263
|
}
|
|
178
|
-
return
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
264
|
+
return result;
|
|
265
|
+
};
|
|
266
|
+
const getCompoundVariantClassNamesBySlot = (slotProps2) => {
|
|
267
|
+
const compoundClassNames = getCompoundVariantsValue(compoundVariants, slotProps2);
|
|
268
|
+
if (!Array.isArray(compoundClassNames)) return compoundClassNames;
|
|
269
|
+
const result = {};
|
|
270
|
+
const cnFn = cn2;
|
|
271
|
+
for (let i = 0; i < compoundClassNames.length; i++) {
|
|
272
|
+
const className = compoundClassNames[i];
|
|
273
|
+
if (typeof className === "string") {
|
|
274
|
+
result.base = cnFn(result.base, className)(config);
|
|
275
|
+
} else if (typeof className === "object") {
|
|
276
|
+
for (const slot in className) {
|
|
277
|
+
result[slot] = cnFn(result[slot], className[slot])(config);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
187
280
|
}
|
|
188
|
-
return
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
281
|
+
return result;
|
|
282
|
+
};
|
|
283
|
+
const getCompoundSlotClassNameBySlot = (slotProps2) => {
|
|
284
|
+
if (compoundSlots.length < 1) return null;
|
|
285
|
+
const result = {};
|
|
286
|
+
const completeProps = getCompleteProps(null, slotProps2);
|
|
287
|
+
for (let i = 0; i < compoundSlots.length; i++) {
|
|
288
|
+
const {
|
|
289
|
+
slots: slots2 = [],
|
|
290
|
+
class: slotClass,
|
|
291
|
+
className: slotClassName,
|
|
292
|
+
...slotVariants
|
|
293
|
+
} = compoundSlots[i];
|
|
294
|
+
if (!isEmptyObject(slotVariants)) {
|
|
295
|
+
let isValid = true;
|
|
296
|
+
for (const key in slotVariants) {
|
|
297
|
+
const completePropsValue = completeProps[key];
|
|
298
|
+
const slotVariantValue = slotVariants[key];
|
|
299
|
+
if (completePropsValue === void 0 || (Array.isArray(slotVariantValue) ? !slotVariantValue.includes(completePropsValue) : slotVariantValue !== completePropsValue)) {
|
|
300
|
+
isValid = false;
|
|
200
301
|
break;
|
|
201
302
|
}
|
|
202
303
|
}
|
|
203
|
-
if (!
|
|
304
|
+
if (!isValid) continue;
|
|
204
305
|
}
|
|
205
|
-
for (let
|
|
206
|
-
|
|
207
|
-
|
|
306
|
+
for (let j = 0; j < slots2.length; j++) {
|
|
307
|
+
const slotName = slots2[j];
|
|
308
|
+
if (!result[slotName]) result[slotName] = [];
|
|
309
|
+
result[slotName].push([slotClass, slotClassName]);
|
|
208
310
|
}
|
|
209
311
|
}
|
|
210
|
-
return
|
|
312
|
+
return result;
|
|
211
313
|
};
|
|
212
|
-
if (!
|
|
213
|
-
|
|
214
|
-
if (typeof
|
|
215
|
-
|
|
216
|
-
for (
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
314
|
+
if (!isEmptyObject(slotProps) || !isExtendedSlotsEmpty) {
|
|
315
|
+
const slotsFns = {};
|
|
316
|
+
if (typeof slots === "object" && !isEmptyObject(slots)) {
|
|
317
|
+
const cnFn = cn2;
|
|
318
|
+
for (const slotKey in slots) {
|
|
319
|
+
slotsFns[slotKey] = (slotProps2) => {
|
|
320
|
+
const compoundVariantClasses = getCompoundVariantClassNamesBySlot(slotProps2);
|
|
321
|
+
const compoundSlotClasses = getCompoundSlotClassNameBySlot(slotProps2);
|
|
322
|
+
return cnFn(
|
|
323
|
+
slots[slotKey],
|
|
324
|
+
getVariantClassNamesBySlotKey(slotKey, slotProps2),
|
|
325
|
+
compoundVariantClasses ? compoundVariantClasses[slotKey] : void 0,
|
|
326
|
+
compoundSlotClasses ? compoundSlotClasses[slotKey] : void 0,
|
|
327
|
+
slotProps2?.class,
|
|
328
|
+
slotProps2?.className
|
|
329
|
+
)(config);
|
|
330
|
+
};
|
|
331
|
+
}
|
|
220
332
|
}
|
|
221
|
-
return
|
|
333
|
+
return slotsFns;
|
|
222
334
|
}
|
|
223
|
-
return
|
|
224
|
-
|
|
225
|
-
|
|
335
|
+
return cn2(
|
|
336
|
+
base,
|
|
337
|
+
getVariantClassNames(),
|
|
338
|
+
getCompoundVariantsValue(compoundVariants),
|
|
339
|
+
props?.class,
|
|
340
|
+
props?.className
|
|
341
|
+
)(config);
|
|
226
342
|
};
|
|
227
|
-
|
|
343
|
+
const getVariantKeys = () => {
|
|
344
|
+
if (!variants || typeof variants !== "object") return;
|
|
345
|
+
return Object.keys(variants);
|
|
346
|
+
};
|
|
347
|
+
component.variantKeys = getVariantKeys();
|
|
348
|
+
component.extend = extend;
|
|
349
|
+
component.base = base;
|
|
350
|
+
component.slots = slots;
|
|
351
|
+
component.variants = variants;
|
|
352
|
+
component.defaultVariants = defaultVariants;
|
|
353
|
+
component.compoundSlots = compoundSlots;
|
|
354
|
+
component.compoundVariants = compoundVariants;
|
|
355
|
+
return component;
|
|
356
|
+
};
|
|
357
|
+
const createTV2 = (configProp) => {
|
|
358
|
+
return (options, config) => tv2(options, config ? mergeObjects(configProp, config) : configProp);
|
|
228
359
|
};
|
|
229
|
-
return {
|
|
360
|
+
return {
|
|
361
|
+
tv: tv2,
|
|
362
|
+
createTV: createTV2
|
|
363
|
+
};
|
|
364
|
+
};
|
|
365
|
+
const concatArrays = (array1, array2) => {
|
|
366
|
+
const combinedArray = new Array(array1.length + array2.length);
|
|
367
|
+
for (let i = 0; i < array1.length; i++) {
|
|
368
|
+
combinedArray[i] = array1[i];
|
|
369
|
+
}
|
|
370
|
+
for (let i = 0; i < array2.length; i++) {
|
|
371
|
+
combinedArray[array1.length + i] = array2[i];
|
|
372
|
+
}
|
|
373
|
+
return combinedArray;
|
|
230
374
|
};
|
|
375
|
+
const createClassValidatorObject = (classGroupId, validator) => ({
|
|
376
|
+
classGroupId,
|
|
377
|
+
validator
|
|
378
|
+
});
|
|
379
|
+
const createClassPartObject = (nextPart = /* @__PURE__ */ new Map(), validators = null, classGroupId) => ({
|
|
380
|
+
nextPart,
|
|
381
|
+
validators,
|
|
382
|
+
classGroupId
|
|
383
|
+
});
|
|
231
384
|
const CLASS_PART_SEPARATOR = "-";
|
|
385
|
+
const EMPTY_CONFLICTS = [];
|
|
386
|
+
const ARBITRARY_PROPERTY_PREFIX = "arbitrary..";
|
|
232
387
|
const createClassGroupUtils = (config) => {
|
|
233
388
|
const classMap = createClassMap(config);
|
|
234
389
|
const {
|
|
@@ -236,103 +391,134 @@ const createClassGroupUtils = (config) => {
|
|
|
236
391
|
conflictingClassGroupModifiers
|
|
237
392
|
} = config;
|
|
238
393
|
const getClassGroupId = (className) => {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
classParts.shift();
|
|
394
|
+
if (className.startsWith("[") && className.endsWith("]")) {
|
|
395
|
+
return getGroupIdForArbitraryProperty(className);
|
|
242
396
|
}
|
|
243
|
-
|
|
397
|
+
const classParts = className.split(CLASS_PART_SEPARATOR);
|
|
398
|
+
const startIndex = classParts[0] === "" && classParts.length > 1 ? 1 : 0;
|
|
399
|
+
return getGroupRecursive(classParts, startIndex, classMap);
|
|
244
400
|
};
|
|
245
401
|
const getConflictingClassGroupIds = (classGroupId, hasPostfixModifier) => {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
402
|
+
if (hasPostfixModifier) {
|
|
403
|
+
const modifierConflicts = conflictingClassGroupModifiers[classGroupId];
|
|
404
|
+
const baseConflicts = conflictingClassGroups[classGroupId];
|
|
405
|
+
if (modifierConflicts) {
|
|
406
|
+
if (baseConflicts) {
|
|
407
|
+
return concatArrays(baseConflicts, modifierConflicts);
|
|
408
|
+
}
|
|
409
|
+
return modifierConflicts;
|
|
410
|
+
}
|
|
411
|
+
return baseConflicts || EMPTY_CONFLICTS;
|
|
249
412
|
}
|
|
250
|
-
return
|
|
413
|
+
return conflictingClassGroups[classGroupId] || EMPTY_CONFLICTS;
|
|
251
414
|
};
|
|
252
415
|
return {
|
|
253
416
|
getClassGroupId,
|
|
254
417
|
getConflictingClassGroupIds
|
|
255
418
|
};
|
|
256
419
|
};
|
|
257
|
-
const getGroupRecursive = (classParts, classPartObject) => {
|
|
258
|
-
|
|
420
|
+
const getGroupRecursive = (classParts, startIndex, classPartObject) => {
|
|
421
|
+
const classPathsLength = classParts.length - startIndex;
|
|
422
|
+
if (classPathsLength === 0) {
|
|
259
423
|
return classPartObject.classGroupId;
|
|
260
424
|
}
|
|
261
|
-
const currentClassPart = classParts[
|
|
425
|
+
const currentClassPart = classParts[startIndex];
|
|
262
426
|
const nextClassPartObject = classPartObject.nextPart.get(currentClassPart);
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
return
|
|
427
|
+
if (nextClassPartObject) {
|
|
428
|
+
const result = getGroupRecursive(classParts, startIndex + 1, nextClassPartObject);
|
|
429
|
+
if (result) return result;
|
|
266
430
|
}
|
|
267
|
-
|
|
431
|
+
const validators = classPartObject.validators;
|
|
432
|
+
if (validators === null) {
|
|
268
433
|
return void 0;
|
|
269
434
|
}
|
|
270
|
-
const classRest = classParts.join(CLASS_PART_SEPARATOR);
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const getGroupIdForArbitraryProperty = (className) => {
|
|
277
|
-
if (arbitraryPropertyRegex.test(className)) {
|
|
278
|
-
const arbitraryPropertyClassName = arbitraryPropertyRegex.exec(className)[1];
|
|
279
|
-
const property = arbitraryPropertyClassName?.substring(0, arbitraryPropertyClassName.indexOf(":"));
|
|
280
|
-
if (property) {
|
|
281
|
-
return "arbitrary.." + property;
|
|
435
|
+
const classRest = startIndex === 0 ? classParts.join(CLASS_PART_SEPARATOR) : classParts.slice(startIndex).join(CLASS_PART_SEPARATOR);
|
|
436
|
+
const validatorsLength = validators.length;
|
|
437
|
+
for (let i = 0; i < validatorsLength; i++) {
|
|
438
|
+
const validatorObj = validators[i];
|
|
439
|
+
if (validatorObj.validator(classRest)) {
|
|
440
|
+
return validatorObj.classGroupId;
|
|
282
441
|
}
|
|
283
442
|
}
|
|
443
|
+
return void 0;
|
|
284
444
|
};
|
|
445
|
+
const getGroupIdForArbitraryProperty = (className) => className.slice(1, -1).indexOf(":") === -1 ? void 0 : (() => {
|
|
446
|
+
const content = className.slice(1, -1);
|
|
447
|
+
const colonIndex = content.indexOf(":");
|
|
448
|
+
const property = content.slice(0, colonIndex);
|
|
449
|
+
return property ? ARBITRARY_PROPERTY_PREFIX + property : void 0;
|
|
450
|
+
})();
|
|
285
451
|
const createClassMap = (config) => {
|
|
286
452
|
const {
|
|
287
453
|
theme,
|
|
288
454
|
classGroups
|
|
289
455
|
} = config;
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
456
|
+
return processClassGroups(classGroups, theme);
|
|
457
|
+
};
|
|
458
|
+
const processClassGroups = (classGroups, theme) => {
|
|
459
|
+
const classMap = createClassPartObject();
|
|
294
460
|
for (const classGroupId in classGroups) {
|
|
295
|
-
|
|
461
|
+
const group = classGroups[classGroupId];
|
|
462
|
+
processClassesRecursively(group, classMap, classGroupId, theme);
|
|
296
463
|
}
|
|
297
464
|
return classMap;
|
|
298
465
|
};
|
|
299
466
|
const processClassesRecursively = (classGroup, classPartObject, classGroupId, theme) => {
|
|
300
|
-
classGroup.
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
467
|
+
const len = classGroup.length;
|
|
468
|
+
for (let i = 0; i < len; i++) {
|
|
469
|
+
const classDefinition = classGroup[i];
|
|
470
|
+
processClassDefinition(classDefinition, classPartObject, classGroupId, theme);
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
const processClassDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
|
|
474
|
+
if (typeof classDefinition === "string") {
|
|
475
|
+
processStringDefinition(classDefinition, classPartObject, classGroupId);
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
if (typeof classDefinition === "function") {
|
|
479
|
+
processFunctionDefinition(classDefinition, classPartObject, classGroupId, theme);
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
processObjectDefinition(classDefinition, classPartObject, classGroupId, theme);
|
|
483
|
+
};
|
|
484
|
+
const processStringDefinition = (classDefinition, classPartObject, classGroupId) => {
|
|
485
|
+
const classPartObjectToEdit = classDefinition === "" ? classPartObject : getPart(classPartObject, classDefinition);
|
|
486
|
+
classPartObjectToEdit.classGroupId = classGroupId;
|
|
487
|
+
};
|
|
488
|
+
const processFunctionDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
|
|
489
|
+
if (isThemeGetter(classDefinition)) {
|
|
490
|
+
processClassesRecursively(classDefinition(theme), classPartObject, classGroupId, theme);
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
if (classPartObject.validators === null) {
|
|
494
|
+
classPartObject.validators = [];
|
|
495
|
+
}
|
|
496
|
+
classPartObject.validators.push(createClassValidatorObject(classGroupId, classDefinition));
|
|
497
|
+
};
|
|
498
|
+
const processObjectDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
|
|
499
|
+
const entries = Object.entries(classDefinition);
|
|
500
|
+
const len = entries.length;
|
|
501
|
+
for (let i = 0; i < len; i++) {
|
|
502
|
+
const [key, value] = entries[i];
|
|
503
|
+
processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
|
|
504
|
+
}
|
|
321
505
|
};
|
|
322
506
|
const getPart = (classPartObject, path) => {
|
|
323
|
-
let
|
|
324
|
-
path.split(CLASS_PART_SEPARATOR)
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
507
|
+
let current = classPartObject;
|
|
508
|
+
const parts = path.split(CLASS_PART_SEPARATOR);
|
|
509
|
+
const len = parts.length;
|
|
510
|
+
for (let i = 0; i < len; i++) {
|
|
511
|
+
const part = parts[i];
|
|
512
|
+
let next = current.nextPart.get(part);
|
|
513
|
+
if (!next) {
|
|
514
|
+
next = createClassPartObject();
|
|
515
|
+
current.nextPart.set(part, next);
|
|
330
516
|
}
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
return
|
|
517
|
+
current = next;
|
|
518
|
+
}
|
|
519
|
+
return current;
|
|
334
520
|
};
|
|
335
|
-
const isThemeGetter = (func) => func.isThemeGetter;
|
|
521
|
+
const isThemeGetter = (func) => "isThemeGetter" in func && func.isThemeGetter === true;
|
|
336
522
|
const createLruCache = (maxCacheSize) => {
|
|
337
523
|
if (maxCacheSize < 1) {
|
|
338
524
|
return {
|
|
@@ -342,31 +528,31 @@ const createLruCache = (maxCacheSize) => {
|
|
|
342
528
|
};
|
|
343
529
|
}
|
|
344
530
|
let cacheSize = 0;
|
|
345
|
-
let cache = /* @__PURE__ */
|
|
346
|
-
let previousCache = /* @__PURE__ */
|
|
531
|
+
let cache = /* @__PURE__ */ Object.create(null);
|
|
532
|
+
let previousCache = /* @__PURE__ */ Object.create(null);
|
|
347
533
|
const update = (key, value) => {
|
|
348
|
-
cache
|
|
534
|
+
cache[key] = value;
|
|
349
535
|
cacheSize++;
|
|
350
536
|
if (cacheSize > maxCacheSize) {
|
|
351
537
|
cacheSize = 0;
|
|
352
538
|
previousCache = cache;
|
|
353
|
-
cache = /* @__PURE__ */
|
|
539
|
+
cache = /* @__PURE__ */ Object.create(null);
|
|
354
540
|
}
|
|
355
541
|
};
|
|
356
542
|
return {
|
|
357
543
|
get(key) {
|
|
358
|
-
let value = cache
|
|
544
|
+
let value = cache[key];
|
|
359
545
|
if (value !== void 0) {
|
|
360
546
|
return value;
|
|
361
547
|
}
|
|
362
|
-
if ((value = previousCache
|
|
548
|
+
if ((value = previousCache[key]) !== void 0) {
|
|
363
549
|
update(key, value);
|
|
364
550
|
return value;
|
|
365
551
|
}
|
|
366
552
|
},
|
|
367
553
|
set(key, value) {
|
|
368
|
-
if (cache
|
|
369
|
-
cache
|
|
554
|
+
if (key in cache) {
|
|
555
|
+
cache[key] = value;
|
|
370
556
|
} else {
|
|
371
557
|
update(key, value);
|
|
372
558
|
}
|
|
@@ -375,7 +561,14 @@ const createLruCache = (maxCacheSize) => {
|
|
|
375
561
|
};
|
|
376
562
|
const IMPORTANT_MODIFIER = "!";
|
|
377
563
|
const MODIFIER_SEPARATOR = ":";
|
|
378
|
-
const
|
|
564
|
+
const EMPTY_MODIFIERS = [];
|
|
565
|
+
const createResultObject = (modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition, isExternal) => ({
|
|
566
|
+
modifiers,
|
|
567
|
+
hasImportantModifier,
|
|
568
|
+
baseClassName,
|
|
569
|
+
maybePostfixModifierPosition,
|
|
570
|
+
isExternal
|
|
571
|
+
});
|
|
379
572
|
const createParseClassName = (config) => {
|
|
380
573
|
const {
|
|
381
574
|
prefix,
|
|
@@ -387,12 +580,13 @@ const createParseClassName = (config) => {
|
|
|
387
580
|
let parenDepth = 0;
|
|
388
581
|
let modifierStart = 0;
|
|
389
582
|
let postfixModifierPosition;
|
|
390
|
-
|
|
391
|
-
|
|
583
|
+
const len = className.length;
|
|
584
|
+
for (let index = 0; index < len; index++) {
|
|
585
|
+
const currentCharacter = className[index];
|
|
392
586
|
if (bracketDepth === 0 && parenDepth === 0) {
|
|
393
587
|
if (currentCharacter === MODIFIER_SEPARATOR) {
|
|
394
588
|
modifiers.push(className.slice(modifierStart, index));
|
|
395
|
-
modifierStart = index +
|
|
589
|
+
modifierStart = index + 1;
|
|
396
590
|
continue;
|
|
397
591
|
}
|
|
398
592
|
if (currentCharacter === "/") {
|
|
@@ -400,37 +594,34 @@ const createParseClassName = (config) => {
|
|
|
400
594
|
continue;
|
|
401
595
|
}
|
|
402
596
|
}
|
|
403
|
-
if (currentCharacter === "[")
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
597
|
+
if (currentCharacter === "[") bracketDepth++;
|
|
598
|
+
else if (currentCharacter === "]") bracketDepth--;
|
|
599
|
+
else if (currentCharacter === "(") parenDepth++;
|
|
600
|
+
else if (currentCharacter === ")") parenDepth--;
|
|
601
|
+
}
|
|
602
|
+
const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.slice(modifierStart);
|
|
603
|
+
let baseClassName = baseClassNameWithImportantModifier;
|
|
604
|
+
let hasImportantModifier = false;
|
|
605
|
+
if (baseClassNameWithImportantModifier.endsWith(IMPORTANT_MODIFIER)) {
|
|
606
|
+
baseClassName = baseClassNameWithImportantModifier.slice(0, -1);
|
|
607
|
+
hasImportantModifier = true;
|
|
608
|
+
} else if (
|
|
609
|
+
/**
|
|
610
|
+
* In Tailwind CSS v3 the important modifier was at the start of the base class name. This is still supported for legacy reasons.
|
|
611
|
+
* @see https://github.com/dcastil/tailwind-merge/issues/513#issuecomment-2614029864
|
|
612
|
+
*/
|
|
613
|
+
baseClassNameWithImportantModifier.startsWith(IMPORTANT_MODIFIER)
|
|
614
|
+
) {
|
|
615
|
+
baseClassName = baseClassNameWithImportantModifier.slice(1);
|
|
616
|
+
hasImportantModifier = true;
|
|
412
617
|
}
|
|
413
|
-
const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.substring(modifierStart);
|
|
414
|
-
const baseClassName = stripImportantModifier(baseClassNameWithImportantModifier);
|
|
415
|
-
const hasImportantModifier = baseClassName !== baseClassNameWithImportantModifier;
|
|
416
618
|
const maybePostfixModifierPosition = postfixModifierPosition && postfixModifierPosition > modifierStart ? postfixModifierPosition - modifierStart : void 0;
|
|
417
|
-
return
|
|
418
|
-
modifiers,
|
|
419
|
-
hasImportantModifier,
|
|
420
|
-
baseClassName,
|
|
421
|
-
maybePostfixModifierPosition
|
|
422
|
-
};
|
|
619
|
+
return createResultObject(modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition);
|
|
423
620
|
};
|
|
424
621
|
if (prefix) {
|
|
425
622
|
const fullPrefix = prefix + MODIFIER_SEPARATOR;
|
|
426
623
|
const parseClassNameOriginal = parseClassName;
|
|
427
|
-
parseClassName = (className) => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.
|
|
428
|
-
isExternal: true,
|
|
429
|
-
modifiers: [],
|
|
430
|
-
hasImportantModifier: false,
|
|
431
|
-
baseClassName: className,
|
|
432
|
-
maybePostfixModifierPosition: void 0
|
|
433
|
-
};
|
|
624
|
+
parseClassName = (className) => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.slice(fullPrefix.length)) : createResultObject(EMPTY_MODIFIERS, false, className, void 0, true);
|
|
434
625
|
}
|
|
435
626
|
if (experimentalParseClassName) {
|
|
436
627
|
const parseClassNameOriginal = parseClassName;
|
|
@@ -441,36 +632,35 @@ const createParseClassName = (config) => {
|
|
|
441
632
|
}
|
|
442
633
|
return parseClassName;
|
|
443
634
|
};
|
|
444
|
-
const stripImportantModifier = (baseClassName) => {
|
|
445
|
-
if (baseClassName.endsWith(IMPORTANT_MODIFIER)) {
|
|
446
|
-
return baseClassName.substring(0, baseClassName.length - 1);
|
|
447
|
-
}
|
|
448
|
-
if (baseClassName.startsWith(IMPORTANT_MODIFIER)) {
|
|
449
|
-
return baseClassName.substring(1);
|
|
450
|
-
}
|
|
451
|
-
return baseClassName;
|
|
452
|
-
};
|
|
453
635
|
const createSortModifiers = (config) => {
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
const
|
|
460
|
-
let
|
|
461
|
-
modifiers.
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
636
|
+
const modifierWeights = /* @__PURE__ */ new Map();
|
|
637
|
+
config.orderSensitiveModifiers.forEach((mod, index) => {
|
|
638
|
+
modifierWeights.set(mod, 1e6 + index);
|
|
639
|
+
});
|
|
640
|
+
return (modifiers) => {
|
|
641
|
+
const result = [];
|
|
642
|
+
let currentSegment = [];
|
|
643
|
+
for (let i = 0; i < modifiers.length; i++) {
|
|
644
|
+
const modifier = modifiers[i];
|
|
645
|
+
const isArbitrary = modifier[0] === "[";
|
|
646
|
+
const isOrderSensitive = modifierWeights.has(modifier);
|
|
647
|
+
if (isArbitrary || isOrderSensitive) {
|
|
648
|
+
if (currentSegment.length > 0) {
|
|
649
|
+
currentSegment.sort();
|
|
650
|
+
result.push(...currentSegment);
|
|
651
|
+
currentSegment = [];
|
|
652
|
+
}
|
|
653
|
+
result.push(modifier);
|
|
466
654
|
} else {
|
|
467
|
-
|
|
655
|
+
currentSegment.push(modifier);
|
|
468
656
|
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
|
|
657
|
+
}
|
|
658
|
+
if (currentSegment.length > 0) {
|
|
659
|
+
currentSegment.sort();
|
|
660
|
+
result.push(...currentSegment);
|
|
661
|
+
}
|
|
662
|
+
return result;
|
|
472
663
|
};
|
|
473
|
-
return sortModifiers;
|
|
474
664
|
};
|
|
475
665
|
const createConfigUtils = (config) => ({
|
|
476
666
|
cache: createLruCache(config.cacheSize),
|
|
@@ -516,29 +706,29 @@ const mergeClassList = (classList, configUtils) => {
|
|
|
516
706
|
}
|
|
517
707
|
hasPostfixModifier = false;
|
|
518
708
|
}
|
|
519
|
-
const variantModifier = sortModifiers(modifiers).join(":");
|
|
709
|
+
const variantModifier = modifiers.length === 0 ? "" : modifiers.length === 1 ? modifiers[0] : sortModifiers(modifiers).join(":");
|
|
520
710
|
const modifierId = hasImportantModifier ? variantModifier + IMPORTANT_MODIFIER : variantModifier;
|
|
521
711
|
const classId = modifierId + classGroupId;
|
|
522
|
-
if (classGroupsInConflict.
|
|
712
|
+
if (classGroupsInConflict.indexOf(classId) > -1) {
|
|
523
713
|
continue;
|
|
524
714
|
}
|
|
525
715
|
classGroupsInConflict.push(classId);
|
|
526
716
|
const conflictGroups = getConflictingClassGroupIds(classGroupId, hasPostfixModifier);
|
|
527
|
-
for (let
|
|
528
|
-
const group = conflictGroups[
|
|
717
|
+
for (let i = 0; i < conflictGroups.length; ++i) {
|
|
718
|
+
const group = conflictGroups[i];
|
|
529
719
|
classGroupsInConflict.push(modifierId + group);
|
|
530
720
|
}
|
|
531
721
|
result = originalClassName + (result.length > 0 ? " " + result : result);
|
|
532
722
|
}
|
|
533
723
|
return result;
|
|
534
724
|
};
|
|
535
|
-
|
|
725
|
+
const twJoin = (...classLists) => {
|
|
536
726
|
let index = 0;
|
|
537
727
|
let argument;
|
|
538
728
|
let resolvedValue;
|
|
539
729
|
let string = "";
|
|
540
|
-
while (index <
|
|
541
|
-
if (argument =
|
|
730
|
+
while (index < classLists.length) {
|
|
731
|
+
if (argument = classLists[index++]) {
|
|
542
732
|
if (resolvedValue = toValue(argument)) {
|
|
543
733
|
string && (string += " ");
|
|
544
734
|
string += resolvedValue;
|
|
@@ -546,16 +736,16 @@ function twJoin() {
|
|
|
546
736
|
}
|
|
547
737
|
}
|
|
548
738
|
return string;
|
|
549
|
-
}
|
|
739
|
+
};
|
|
550
740
|
const toValue = (mix) => {
|
|
551
741
|
if (typeof mix === "string") {
|
|
552
742
|
return mix;
|
|
553
743
|
}
|
|
554
744
|
let resolvedValue;
|
|
555
745
|
let string = "";
|
|
556
|
-
for (let
|
|
557
|
-
if (mix[
|
|
558
|
-
if (resolvedValue = toValue(mix[
|
|
746
|
+
for (let k = 0; k < mix.length; k++) {
|
|
747
|
+
if (mix[k]) {
|
|
748
|
+
if (resolvedValue = toValue(mix[k])) {
|
|
559
749
|
string && (string += " ");
|
|
560
750
|
string += resolvedValue;
|
|
561
751
|
}
|
|
@@ -563,20 +753,20 @@ const toValue = (mix) => {
|
|
|
563
753
|
}
|
|
564
754
|
return string;
|
|
565
755
|
};
|
|
566
|
-
|
|
756
|
+
const createTailwindMerge = (createConfigFirst, ...createConfigRest) => {
|
|
567
757
|
let configUtils;
|
|
568
758
|
let cacheGet;
|
|
569
759
|
let cacheSet;
|
|
570
|
-
let functionToCall
|
|
571
|
-
|
|
760
|
+
let functionToCall;
|
|
761
|
+
const initTailwindMerge = (classList) => {
|
|
572
762
|
const config = createConfigRest.reduce((previousConfig, createConfigCurrent) => createConfigCurrent(previousConfig), createConfigFirst());
|
|
573
763
|
configUtils = createConfigUtils(config);
|
|
574
764
|
cacheGet = configUtils.cache.get;
|
|
575
765
|
cacheSet = configUtils.cache.set;
|
|
576
766
|
functionToCall = tailwindMerge;
|
|
577
767
|
return tailwindMerge(classList);
|
|
578
|
-
}
|
|
579
|
-
|
|
768
|
+
};
|
|
769
|
+
const tailwindMerge = (classList) => {
|
|
580
770
|
const cachedResult = cacheGet(classList);
|
|
581
771
|
if (cachedResult) {
|
|
582
772
|
return cachedResult;
|
|
@@ -584,13 +774,13 @@ function createTailwindMerge(createConfigFirst, ...createConfigRest) {
|
|
|
584
774
|
const result = mergeClassList(classList, configUtils);
|
|
585
775
|
cacheSet(classList, result);
|
|
586
776
|
return result;
|
|
587
|
-
}
|
|
588
|
-
return function callTailwindMerge() {
|
|
589
|
-
return functionToCall(twJoin.apply(null, arguments));
|
|
590
777
|
};
|
|
591
|
-
|
|
778
|
+
functionToCall = initTailwindMerge;
|
|
779
|
+
return (...args) => functionToCall(twJoin(...args));
|
|
780
|
+
};
|
|
781
|
+
const fallbackThemeArr = [];
|
|
592
782
|
const fromTheme = (key) => {
|
|
593
|
-
const themeGetter = (theme) => theme[key] ||
|
|
783
|
+
const themeGetter = (theme) => theme[key] || fallbackThemeArr;
|
|
594
784
|
themeGetter.isThemeGetter = true;
|
|
595
785
|
return themeGetter;
|
|
596
786
|
};
|
|
@@ -3227,13 +3417,37 @@ const mergeArrayProperties = (baseObject, mergeObject, key) => {
|
|
|
3227
3417
|
};
|
|
3228
3418
|
const extendTailwindMerge = (configExtension, ...createConfig) => typeof configExtension === "function" ? createTailwindMerge(getDefaultConfig, configExtension, ...createConfig) : createTailwindMerge(() => mergeConfigs(getDefaultConfig(), configExtension), ...createConfig);
|
|
3229
3419
|
const twMerge = /* @__PURE__ */ createTailwindMerge(getDefaultConfig);
|
|
3230
|
-
var
|
|
3231
|
-
|
|
3232
|
-
|
|
3420
|
+
var createTwMerge = (cachedTwMergeConfig) => {
|
|
3421
|
+
return isEmptyObject(cachedTwMergeConfig) ? twMerge : extendTailwindMerge({
|
|
3422
|
+
...cachedTwMergeConfig,
|
|
3423
|
+
extend: {
|
|
3424
|
+
theme: cachedTwMergeConfig.theme,
|
|
3425
|
+
classGroups: cachedTwMergeConfig.classGroups,
|
|
3426
|
+
conflictingClassGroupModifiers: cachedTwMergeConfig.conflictingClassGroupModifiers,
|
|
3427
|
+
conflictingClassGroups: cachedTwMergeConfig.conflictingClassGroups,
|
|
3428
|
+
...cachedTwMergeConfig.extend
|
|
3429
|
+
}
|
|
3430
|
+
});
|
|
3431
|
+
};
|
|
3432
|
+
var executeMerge = (classnames, config) => {
|
|
3433
|
+
const base = cx(classnames);
|
|
3434
|
+
if (!base || !(config?.twMerge ?? true)) return base;
|
|
3435
|
+
if (!state.cachedTwMerge || state.didTwMergeConfigChange) {
|
|
3436
|
+
state.didTwMergeConfigChange = false;
|
|
3437
|
+
state.cachedTwMerge = createTwMerge(state.cachedTwMergeConfig);
|
|
3438
|
+
}
|
|
3439
|
+
return state.cachedTwMerge(base) || void 0;
|
|
3440
|
+
};
|
|
3441
|
+
var cn = (...classnames) => {
|
|
3442
|
+
return executeMerge(classnames, {});
|
|
3443
|
+
};
|
|
3444
|
+
var cnMerge = (...classnames) => {
|
|
3445
|
+
return (config) => executeMerge(classnames, config);
|
|
3233
3446
|
};
|
|
3234
|
-
var { createTV
|
|
3235
|
-
exports.
|
|
3236
|
-
exports.
|
|
3237
|
-
exports.
|
|
3238
|
-
exports.
|
|
3239
|
-
exports.
|
|
3447
|
+
var { createTV, tv } = getTailwindVariants(cnMerge);
|
|
3448
|
+
exports.cn = cn;
|
|
3449
|
+
exports.cnMerge = cnMerge;
|
|
3450
|
+
exports.createTV = createTV;
|
|
3451
|
+
exports.cx = cx;
|
|
3452
|
+
exports.defaultConfig = defaultConfig;
|
|
3453
|
+
exports.tv = tv;
|