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