@pequity/squirrel 11.0.0 → 11.0.1
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 +199 -143
- package/dist/es/chunks/index.js +199 -143
- package/dist/squirrel.css +1 -1
- package/package.json +17 -17
package/dist/cjs/chunks/index.js
CHANGED
|
@@ -228,7 +228,28 @@ var le = (b$1) => {
|
|
|
228
228
|
};
|
|
229
229
|
return { tv: w, createTV: (u2) => ($, c2) => w($, c2 ? p(u2, c2) : u2) };
|
|
230
230
|
};
|
|
231
|
+
const concatArrays = (array1, array2) => {
|
|
232
|
+
const combinedArray = new Array(array1.length + array2.length);
|
|
233
|
+
for (let i2 = 0; i2 < array1.length; i2++) {
|
|
234
|
+
combinedArray[i2] = array1[i2];
|
|
235
|
+
}
|
|
236
|
+
for (let i2 = 0; i2 < array2.length; i2++) {
|
|
237
|
+
combinedArray[array1.length + i2] = array2[i2];
|
|
238
|
+
}
|
|
239
|
+
return combinedArray;
|
|
240
|
+
};
|
|
241
|
+
const createClassValidatorObject = (classGroupId, validator) => ({
|
|
242
|
+
classGroupId,
|
|
243
|
+
validator
|
|
244
|
+
});
|
|
245
|
+
const createClassPartObject = (nextPart = /* @__PURE__ */ new Map(), validators = null, classGroupId) => ({
|
|
246
|
+
nextPart,
|
|
247
|
+
validators,
|
|
248
|
+
classGroupId
|
|
249
|
+
});
|
|
231
250
|
const CLASS_PART_SEPARATOR = "-";
|
|
251
|
+
const EMPTY_CONFLICTS = [];
|
|
252
|
+
const ARBITRARY_PROPERTY_PREFIX = "arbitrary..";
|
|
232
253
|
const createClassGroupUtils = (config) => {
|
|
233
254
|
const classMap = createClassMap(config);
|
|
234
255
|
const {
|
|
@@ -236,103 +257,134 @@ const createClassGroupUtils = (config) => {
|
|
|
236
257
|
conflictingClassGroupModifiers
|
|
237
258
|
} = config;
|
|
238
259
|
const getClassGroupId = (className) => {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
classParts.shift();
|
|
260
|
+
if (className.startsWith("[") && className.endsWith("]")) {
|
|
261
|
+
return getGroupIdForArbitraryProperty(className);
|
|
242
262
|
}
|
|
243
|
-
|
|
263
|
+
const classParts = className.split(CLASS_PART_SEPARATOR);
|
|
264
|
+
const startIndex = classParts[0] === "" && classParts.length > 1 ? 1 : 0;
|
|
265
|
+
return getGroupRecursive(classParts, startIndex, classMap);
|
|
244
266
|
};
|
|
245
267
|
const getConflictingClassGroupIds = (classGroupId, hasPostfixModifier) => {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
268
|
+
if (hasPostfixModifier) {
|
|
269
|
+
const modifierConflicts = conflictingClassGroupModifiers[classGroupId];
|
|
270
|
+
const baseConflicts = conflictingClassGroups[classGroupId];
|
|
271
|
+
if (modifierConflicts) {
|
|
272
|
+
if (baseConflicts) {
|
|
273
|
+
return concatArrays(baseConflicts, modifierConflicts);
|
|
274
|
+
}
|
|
275
|
+
return modifierConflicts;
|
|
276
|
+
}
|
|
277
|
+
return baseConflicts || EMPTY_CONFLICTS;
|
|
249
278
|
}
|
|
250
|
-
return
|
|
279
|
+
return conflictingClassGroups[classGroupId] || EMPTY_CONFLICTS;
|
|
251
280
|
};
|
|
252
281
|
return {
|
|
253
282
|
getClassGroupId,
|
|
254
283
|
getConflictingClassGroupIds
|
|
255
284
|
};
|
|
256
285
|
};
|
|
257
|
-
const getGroupRecursive = (classParts, classPartObject) => {
|
|
258
|
-
|
|
286
|
+
const getGroupRecursive = (classParts, startIndex, classPartObject) => {
|
|
287
|
+
const classPathsLength = classParts.length - startIndex;
|
|
288
|
+
if (classPathsLength === 0) {
|
|
259
289
|
return classPartObject.classGroupId;
|
|
260
290
|
}
|
|
261
|
-
const currentClassPart = classParts[
|
|
291
|
+
const currentClassPart = classParts[startIndex];
|
|
262
292
|
const nextClassPartObject = classPartObject.nextPart.get(currentClassPart);
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
return
|
|
293
|
+
if (nextClassPartObject) {
|
|
294
|
+
const result = getGroupRecursive(classParts, startIndex + 1, nextClassPartObject);
|
|
295
|
+
if (result) return result;
|
|
266
296
|
}
|
|
267
|
-
|
|
297
|
+
const validators = classPartObject.validators;
|
|
298
|
+
if (validators === null) {
|
|
268
299
|
return void 0;
|
|
269
300
|
}
|
|
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;
|
|
301
|
+
const classRest = startIndex === 0 ? classParts.join(CLASS_PART_SEPARATOR) : classParts.slice(startIndex).join(CLASS_PART_SEPARATOR);
|
|
302
|
+
const validatorsLength = validators.length;
|
|
303
|
+
for (let i2 = 0; i2 < validatorsLength; i2++) {
|
|
304
|
+
const validatorObj = validators[i2];
|
|
305
|
+
if (validatorObj.validator(classRest)) {
|
|
306
|
+
return validatorObj.classGroupId;
|
|
282
307
|
}
|
|
283
308
|
}
|
|
309
|
+
return void 0;
|
|
284
310
|
};
|
|
311
|
+
const getGroupIdForArbitraryProperty = (className) => className.slice(1, -1).indexOf(":") === -1 ? void 0 : (() => {
|
|
312
|
+
const content = className.slice(1, -1);
|
|
313
|
+
const colonIndex = content.indexOf(":");
|
|
314
|
+
const property = content.slice(0, colonIndex);
|
|
315
|
+
return property ? ARBITRARY_PROPERTY_PREFIX + property : void 0;
|
|
316
|
+
})();
|
|
285
317
|
const createClassMap = (config) => {
|
|
286
318
|
const {
|
|
287
319
|
theme,
|
|
288
320
|
classGroups
|
|
289
321
|
} = config;
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
322
|
+
return processClassGroups(classGroups, theme);
|
|
323
|
+
};
|
|
324
|
+
const processClassGroups = (classGroups, theme) => {
|
|
325
|
+
const classMap = createClassPartObject();
|
|
294
326
|
for (const classGroupId in classGroups) {
|
|
295
|
-
|
|
327
|
+
const group = classGroups[classGroupId];
|
|
328
|
+
processClassesRecursively(group, classMap, classGroupId, theme);
|
|
296
329
|
}
|
|
297
330
|
return classMap;
|
|
298
331
|
};
|
|
299
332
|
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
|
-
|
|
333
|
+
const len = classGroup.length;
|
|
334
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
335
|
+
const classDefinition = classGroup[i2];
|
|
336
|
+
processClassDefinition(classDefinition, classPartObject, classGroupId, theme);
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
const processClassDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
|
|
340
|
+
if (typeof classDefinition === "string") {
|
|
341
|
+
processStringDefinition(classDefinition, classPartObject, classGroupId);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (typeof classDefinition === "function") {
|
|
345
|
+
processFunctionDefinition(classDefinition, classPartObject, classGroupId, theme);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
processObjectDefinition(classDefinition, classPartObject, classGroupId, theme);
|
|
349
|
+
};
|
|
350
|
+
const processStringDefinition = (classDefinition, classPartObject, classGroupId) => {
|
|
351
|
+
const classPartObjectToEdit = classDefinition === "" ? classPartObject : getPart(classPartObject, classDefinition);
|
|
352
|
+
classPartObjectToEdit.classGroupId = classGroupId;
|
|
353
|
+
};
|
|
354
|
+
const processFunctionDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
|
|
355
|
+
if (isThemeGetter(classDefinition)) {
|
|
356
|
+
processClassesRecursively(classDefinition(theme), classPartObject, classGroupId, theme);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
if (classPartObject.validators === null) {
|
|
360
|
+
classPartObject.validators = [];
|
|
361
|
+
}
|
|
362
|
+
classPartObject.validators.push(createClassValidatorObject(classGroupId, classDefinition));
|
|
363
|
+
};
|
|
364
|
+
const processObjectDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
|
|
365
|
+
const entries = Object.entries(classDefinition);
|
|
366
|
+
const len = entries.length;
|
|
367
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
368
|
+
const [key, value] = entries[i2];
|
|
369
|
+
processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
|
|
370
|
+
}
|
|
321
371
|
};
|
|
322
372
|
const getPart = (classPartObject, path) => {
|
|
323
|
-
let
|
|
324
|
-
path.split(CLASS_PART_SEPARATOR)
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
373
|
+
let current = classPartObject;
|
|
374
|
+
const parts = path.split(CLASS_PART_SEPARATOR);
|
|
375
|
+
const len = parts.length;
|
|
376
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
377
|
+
const part = parts[i2];
|
|
378
|
+
let next = current.nextPart.get(part);
|
|
379
|
+
if (!next) {
|
|
380
|
+
next = createClassPartObject();
|
|
381
|
+
current.nextPart.set(part, next);
|
|
330
382
|
}
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
return
|
|
383
|
+
current = next;
|
|
384
|
+
}
|
|
385
|
+
return current;
|
|
334
386
|
};
|
|
335
|
-
const isThemeGetter = (func) => func.isThemeGetter;
|
|
387
|
+
const isThemeGetter = (func) => "isThemeGetter" in func && func.isThemeGetter === true;
|
|
336
388
|
const createLruCache = (maxCacheSize) => {
|
|
337
389
|
if (maxCacheSize < 1) {
|
|
338
390
|
return {
|
|
@@ -342,31 +394,31 @@ const createLruCache = (maxCacheSize) => {
|
|
|
342
394
|
};
|
|
343
395
|
}
|
|
344
396
|
let cacheSize = 0;
|
|
345
|
-
let cache = /* @__PURE__ */
|
|
346
|
-
let previousCache = /* @__PURE__ */
|
|
397
|
+
let cache = /* @__PURE__ */ Object.create(null);
|
|
398
|
+
let previousCache = /* @__PURE__ */ Object.create(null);
|
|
347
399
|
const update = (key, value) => {
|
|
348
|
-
cache
|
|
400
|
+
cache[key] = value;
|
|
349
401
|
cacheSize++;
|
|
350
402
|
if (cacheSize > maxCacheSize) {
|
|
351
403
|
cacheSize = 0;
|
|
352
404
|
previousCache = cache;
|
|
353
|
-
cache = /* @__PURE__ */
|
|
405
|
+
cache = /* @__PURE__ */ Object.create(null);
|
|
354
406
|
}
|
|
355
407
|
};
|
|
356
408
|
return {
|
|
357
409
|
get(key) {
|
|
358
|
-
let value = cache
|
|
410
|
+
let value = cache[key];
|
|
359
411
|
if (value !== void 0) {
|
|
360
412
|
return value;
|
|
361
413
|
}
|
|
362
|
-
if ((value = previousCache
|
|
414
|
+
if ((value = previousCache[key]) !== void 0) {
|
|
363
415
|
update(key, value);
|
|
364
416
|
return value;
|
|
365
417
|
}
|
|
366
418
|
},
|
|
367
419
|
set(key, value) {
|
|
368
|
-
if (cache
|
|
369
|
-
cache
|
|
420
|
+
if (key in cache) {
|
|
421
|
+
cache[key] = value;
|
|
370
422
|
} else {
|
|
371
423
|
update(key, value);
|
|
372
424
|
}
|
|
@@ -375,7 +427,14 @@ const createLruCache = (maxCacheSize) => {
|
|
|
375
427
|
};
|
|
376
428
|
const IMPORTANT_MODIFIER = "!";
|
|
377
429
|
const MODIFIER_SEPARATOR = ":";
|
|
378
|
-
const
|
|
430
|
+
const EMPTY_MODIFIERS = [];
|
|
431
|
+
const createResultObject = (modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition, isExternal) => ({
|
|
432
|
+
modifiers,
|
|
433
|
+
hasImportantModifier,
|
|
434
|
+
baseClassName,
|
|
435
|
+
maybePostfixModifierPosition,
|
|
436
|
+
isExternal
|
|
437
|
+
});
|
|
379
438
|
const createParseClassName = (config) => {
|
|
380
439
|
const {
|
|
381
440
|
prefix,
|
|
@@ -387,12 +446,13 @@ const createParseClassName = (config) => {
|
|
|
387
446
|
let parenDepth = 0;
|
|
388
447
|
let modifierStart = 0;
|
|
389
448
|
let postfixModifierPosition;
|
|
390
|
-
|
|
391
|
-
|
|
449
|
+
const len = className.length;
|
|
450
|
+
for (let index = 0; index < len; index++) {
|
|
451
|
+
const currentCharacter = className[index];
|
|
392
452
|
if (bracketDepth === 0 && parenDepth === 0) {
|
|
393
453
|
if (currentCharacter === MODIFIER_SEPARATOR) {
|
|
394
454
|
modifiers.push(className.slice(modifierStart, index));
|
|
395
|
-
modifierStart = index +
|
|
455
|
+
modifierStart = index + 1;
|
|
396
456
|
continue;
|
|
397
457
|
}
|
|
398
458
|
if (currentCharacter === "/") {
|
|
@@ -400,37 +460,34 @@ const createParseClassName = (config) => {
|
|
|
400
460
|
continue;
|
|
401
461
|
}
|
|
402
462
|
}
|
|
403
|
-
if (currentCharacter === "[")
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
463
|
+
if (currentCharacter === "[") bracketDepth++;
|
|
464
|
+
else if (currentCharacter === "]") bracketDepth--;
|
|
465
|
+
else if (currentCharacter === "(") parenDepth++;
|
|
466
|
+
else if (currentCharacter === ")") parenDepth--;
|
|
467
|
+
}
|
|
468
|
+
const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.slice(modifierStart);
|
|
469
|
+
let baseClassName = baseClassNameWithImportantModifier;
|
|
470
|
+
let hasImportantModifier = false;
|
|
471
|
+
if (baseClassNameWithImportantModifier.endsWith(IMPORTANT_MODIFIER)) {
|
|
472
|
+
baseClassName = baseClassNameWithImportantModifier.slice(0, -1);
|
|
473
|
+
hasImportantModifier = true;
|
|
474
|
+
} else if (
|
|
475
|
+
/**
|
|
476
|
+
* In Tailwind CSS v3 the important modifier was at the start of the base class name. This is still supported for legacy reasons.
|
|
477
|
+
* @see https://github.com/dcastil/tailwind-merge/issues/513#issuecomment-2614029864
|
|
478
|
+
*/
|
|
479
|
+
baseClassNameWithImportantModifier.startsWith(IMPORTANT_MODIFIER)
|
|
480
|
+
) {
|
|
481
|
+
baseClassName = baseClassNameWithImportantModifier.slice(1);
|
|
482
|
+
hasImportantModifier = true;
|
|
412
483
|
}
|
|
413
|
-
const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.substring(modifierStart);
|
|
414
|
-
const baseClassName = stripImportantModifier(baseClassNameWithImportantModifier);
|
|
415
|
-
const hasImportantModifier = baseClassName !== baseClassNameWithImportantModifier;
|
|
416
484
|
const maybePostfixModifierPosition = postfixModifierPosition && postfixModifierPosition > modifierStart ? postfixModifierPosition - modifierStart : void 0;
|
|
417
|
-
return
|
|
418
|
-
modifiers,
|
|
419
|
-
hasImportantModifier,
|
|
420
|
-
baseClassName,
|
|
421
|
-
maybePostfixModifierPosition
|
|
422
|
-
};
|
|
485
|
+
return createResultObject(modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition);
|
|
423
486
|
};
|
|
424
487
|
if (prefix) {
|
|
425
488
|
const fullPrefix = prefix + MODIFIER_SEPARATOR;
|
|
426
489
|
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
|
-
};
|
|
490
|
+
parseClassName = (className) => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.slice(fullPrefix.length)) : createResultObject(EMPTY_MODIFIERS, false, className, void 0, true);
|
|
434
491
|
}
|
|
435
492
|
if (experimentalParseClassName) {
|
|
436
493
|
const parseClassNameOriginal = parseClassName;
|
|
@@ -441,36 +498,35 @@ const createParseClassName = (config) => {
|
|
|
441
498
|
}
|
|
442
499
|
return parseClassName;
|
|
443
500
|
};
|
|
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
501
|
const createSortModifiers = (config) => {
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
const
|
|
460
|
-
let
|
|
461
|
-
modifiers.
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
502
|
+
const modifierWeights = /* @__PURE__ */ new Map();
|
|
503
|
+
config.orderSensitiveModifiers.forEach((mod, index) => {
|
|
504
|
+
modifierWeights.set(mod, 1e6 + index);
|
|
505
|
+
});
|
|
506
|
+
return (modifiers) => {
|
|
507
|
+
const result = [];
|
|
508
|
+
let currentSegment = [];
|
|
509
|
+
for (let i2 = 0; i2 < modifiers.length; i2++) {
|
|
510
|
+
const modifier = modifiers[i2];
|
|
511
|
+
const isArbitrary = modifier[0] === "[";
|
|
512
|
+
const isOrderSensitive = modifierWeights.has(modifier);
|
|
513
|
+
if (isArbitrary || isOrderSensitive) {
|
|
514
|
+
if (currentSegment.length > 0) {
|
|
515
|
+
currentSegment.sort();
|
|
516
|
+
result.push(...currentSegment);
|
|
517
|
+
currentSegment = [];
|
|
518
|
+
}
|
|
519
|
+
result.push(modifier);
|
|
466
520
|
} else {
|
|
467
|
-
|
|
521
|
+
currentSegment.push(modifier);
|
|
468
522
|
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
|
|
523
|
+
}
|
|
524
|
+
if (currentSegment.length > 0) {
|
|
525
|
+
currentSegment.sort();
|
|
526
|
+
result.push(...currentSegment);
|
|
527
|
+
}
|
|
528
|
+
return result;
|
|
472
529
|
};
|
|
473
|
-
return sortModifiers;
|
|
474
530
|
};
|
|
475
531
|
const createConfigUtils = (config) => ({
|
|
476
532
|
cache: createLruCache(config.cacheSize),
|
|
@@ -516,10 +572,10 @@ const mergeClassList = (classList, configUtils) => {
|
|
|
516
572
|
}
|
|
517
573
|
hasPostfixModifier = false;
|
|
518
574
|
}
|
|
519
|
-
const variantModifier = sortModifiers(modifiers).join(":");
|
|
575
|
+
const variantModifier = modifiers.length === 0 ? "" : modifiers.length === 1 ? modifiers[0] : sortModifiers(modifiers).join(":");
|
|
520
576
|
const modifierId = hasImportantModifier ? variantModifier + IMPORTANT_MODIFIER : variantModifier;
|
|
521
577
|
const classId = modifierId + classGroupId;
|
|
522
|
-
if (classGroupsInConflict.
|
|
578
|
+
if (classGroupsInConflict.indexOf(classId) > -1) {
|
|
523
579
|
continue;
|
|
524
580
|
}
|
|
525
581
|
classGroupsInConflict.push(classId);
|
|
@@ -532,13 +588,13 @@ const mergeClassList = (classList, configUtils) => {
|
|
|
532
588
|
}
|
|
533
589
|
return result;
|
|
534
590
|
};
|
|
535
|
-
|
|
591
|
+
const twJoin = (...classLists) => {
|
|
536
592
|
let index = 0;
|
|
537
593
|
let argument;
|
|
538
594
|
let resolvedValue;
|
|
539
595
|
let string = "";
|
|
540
|
-
while (index <
|
|
541
|
-
if (argument =
|
|
596
|
+
while (index < classLists.length) {
|
|
597
|
+
if (argument = classLists[index++]) {
|
|
542
598
|
if (resolvedValue = toValue(argument)) {
|
|
543
599
|
string && (string += " ");
|
|
544
600
|
string += resolvedValue;
|
|
@@ -546,7 +602,7 @@ function twJoin() {
|
|
|
546
602
|
}
|
|
547
603
|
}
|
|
548
604
|
return string;
|
|
549
|
-
}
|
|
605
|
+
};
|
|
550
606
|
const toValue = (mix) => {
|
|
551
607
|
if (typeof mix === "string") {
|
|
552
608
|
return mix;
|
|
@@ -563,20 +619,20 @@ const toValue = (mix) => {
|
|
|
563
619
|
}
|
|
564
620
|
return string;
|
|
565
621
|
};
|
|
566
|
-
|
|
622
|
+
const createTailwindMerge = (createConfigFirst, ...createConfigRest) => {
|
|
567
623
|
let configUtils;
|
|
568
624
|
let cacheGet;
|
|
569
625
|
let cacheSet;
|
|
570
|
-
let functionToCall
|
|
571
|
-
|
|
626
|
+
let functionToCall;
|
|
627
|
+
const initTailwindMerge = (classList) => {
|
|
572
628
|
const config = createConfigRest.reduce((previousConfig, createConfigCurrent) => createConfigCurrent(previousConfig), createConfigFirst());
|
|
573
629
|
configUtils = createConfigUtils(config);
|
|
574
630
|
cacheGet = configUtils.cache.get;
|
|
575
631
|
cacheSet = configUtils.cache.set;
|
|
576
632
|
functionToCall = tailwindMerge;
|
|
577
633
|
return tailwindMerge(classList);
|
|
578
|
-
}
|
|
579
|
-
|
|
634
|
+
};
|
|
635
|
+
const tailwindMerge = (classList) => {
|
|
580
636
|
const cachedResult = cacheGet(classList);
|
|
581
637
|
if (cachedResult) {
|
|
582
638
|
return cachedResult;
|
|
@@ -584,13 +640,13 @@ function createTailwindMerge(createConfigFirst, ...createConfigRest) {
|
|
|
584
640
|
const result = mergeClassList(classList, configUtils);
|
|
585
641
|
cacheSet(classList, result);
|
|
586
642
|
return result;
|
|
587
|
-
}
|
|
588
|
-
return function callTailwindMerge() {
|
|
589
|
-
return functionToCall(twJoin.apply(null, arguments));
|
|
590
643
|
};
|
|
591
|
-
|
|
644
|
+
functionToCall = initTailwindMerge;
|
|
645
|
+
return (...args) => functionToCall(twJoin(...args));
|
|
646
|
+
};
|
|
647
|
+
const fallbackThemeArr = [];
|
|
592
648
|
const fromTheme = (key) => {
|
|
593
|
-
const themeGetter = (theme) => theme[key] ||
|
|
649
|
+
const themeGetter = (theme) => theme[key] || fallbackThemeArr;
|
|
594
650
|
themeGetter.isThemeGetter = true;
|
|
595
651
|
return themeGetter;
|
|
596
652
|
};
|
package/dist/es/chunks/index.js
CHANGED
|
@@ -227,7 +227,28 @@ var le = (b$1) => {
|
|
|
227
227
|
};
|
|
228
228
|
return { tv: w, createTV: (u2) => ($, c2) => w($, c2 ? p(u2, c2) : u2) };
|
|
229
229
|
};
|
|
230
|
+
const concatArrays = (array1, array2) => {
|
|
231
|
+
const combinedArray = new Array(array1.length + array2.length);
|
|
232
|
+
for (let i2 = 0; i2 < array1.length; i2++) {
|
|
233
|
+
combinedArray[i2] = array1[i2];
|
|
234
|
+
}
|
|
235
|
+
for (let i2 = 0; i2 < array2.length; i2++) {
|
|
236
|
+
combinedArray[array1.length + i2] = array2[i2];
|
|
237
|
+
}
|
|
238
|
+
return combinedArray;
|
|
239
|
+
};
|
|
240
|
+
const createClassValidatorObject = (classGroupId, validator) => ({
|
|
241
|
+
classGroupId,
|
|
242
|
+
validator
|
|
243
|
+
});
|
|
244
|
+
const createClassPartObject = (nextPart = /* @__PURE__ */ new Map(), validators = null, classGroupId) => ({
|
|
245
|
+
nextPart,
|
|
246
|
+
validators,
|
|
247
|
+
classGroupId
|
|
248
|
+
});
|
|
230
249
|
const CLASS_PART_SEPARATOR = "-";
|
|
250
|
+
const EMPTY_CONFLICTS = [];
|
|
251
|
+
const ARBITRARY_PROPERTY_PREFIX = "arbitrary..";
|
|
231
252
|
const createClassGroupUtils = (config) => {
|
|
232
253
|
const classMap = createClassMap(config);
|
|
233
254
|
const {
|
|
@@ -235,103 +256,134 @@ const createClassGroupUtils = (config) => {
|
|
|
235
256
|
conflictingClassGroupModifiers
|
|
236
257
|
} = config;
|
|
237
258
|
const getClassGroupId = (className) => {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
classParts.shift();
|
|
259
|
+
if (className.startsWith("[") && className.endsWith("]")) {
|
|
260
|
+
return getGroupIdForArbitraryProperty(className);
|
|
241
261
|
}
|
|
242
|
-
|
|
262
|
+
const classParts = className.split(CLASS_PART_SEPARATOR);
|
|
263
|
+
const startIndex = classParts[0] === "" && classParts.length > 1 ? 1 : 0;
|
|
264
|
+
return getGroupRecursive(classParts, startIndex, classMap);
|
|
243
265
|
};
|
|
244
266
|
const getConflictingClassGroupIds = (classGroupId, hasPostfixModifier) => {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
267
|
+
if (hasPostfixModifier) {
|
|
268
|
+
const modifierConflicts = conflictingClassGroupModifiers[classGroupId];
|
|
269
|
+
const baseConflicts = conflictingClassGroups[classGroupId];
|
|
270
|
+
if (modifierConflicts) {
|
|
271
|
+
if (baseConflicts) {
|
|
272
|
+
return concatArrays(baseConflicts, modifierConflicts);
|
|
273
|
+
}
|
|
274
|
+
return modifierConflicts;
|
|
275
|
+
}
|
|
276
|
+
return baseConflicts || EMPTY_CONFLICTS;
|
|
248
277
|
}
|
|
249
|
-
return
|
|
278
|
+
return conflictingClassGroups[classGroupId] || EMPTY_CONFLICTS;
|
|
250
279
|
};
|
|
251
280
|
return {
|
|
252
281
|
getClassGroupId,
|
|
253
282
|
getConflictingClassGroupIds
|
|
254
283
|
};
|
|
255
284
|
};
|
|
256
|
-
const getGroupRecursive = (classParts, classPartObject) => {
|
|
257
|
-
|
|
285
|
+
const getGroupRecursive = (classParts, startIndex, classPartObject) => {
|
|
286
|
+
const classPathsLength = classParts.length - startIndex;
|
|
287
|
+
if (classPathsLength === 0) {
|
|
258
288
|
return classPartObject.classGroupId;
|
|
259
289
|
}
|
|
260
|
-
const currentClassPart = classParts[
|
|
290
|
+
const currentClassPart = classParts[startIndex];
|
|
261
291
|
const nextClassPartObject = classPartObject.nextPart.get(currentClassPart);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
return
|
|
292
|
+
if (nextClassPartObject) {
|
|
293
|
+
const result = getGroupRecursive(classParts, startIndex + 1, nextClassPartObject);
|
|
294
|
+
if (result) return result;
|
|
265
295
|
}
|
|
266
|
-
|
|
296
|
+
const validators = classPartObject.validators;
|
|
297
|
+
if (validators === null) {
|
|
267
298
|
return void 0;
|
|
268
299
|
}
|
|
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;
|
|
300
|
+
const classRest = startIndex === 0 ? classParts.join(CLASS_PART_SEPARATOR) : classParts.slice(startIndex).join(CLASS_PART_SEPARATOR);
|
|
301
|
+
const validatorsLength = validators.length;
|
|
302
|
+
for (let i2 = 0; i2 < validatorsLength; i2++) {
|
|
303
|
+
const validatorObj = validators[i2];
|
|
304
|
+
if (validatorObj.validator(classRest)) {
|
|
305
|
+
return validatorObj.classGroupId;
|
|
281
306
|
}
|
|
282
307
|
}
|
|
308
|
+
return void 0;
|
|
283
309
|
};
|
|
310
|
+
const getGroupIdForArbitraryProperty = (className) => className.slice(1, -1).indexOf(":") === -1 ? void 0 : (() => {
|
|
311
|
+
const content = className.slice(1, -1);
|
|
312
|
+
const colonIndex = content.indexOf(":");
|
|
313
|
+
const property = content.slice(0, colonIndex);
|
|
314
|
+
return property ? ARBITRARY_PROPERTY_PREFIX + property : void 0;
|
|
315
|
+
})();
|
|
284
316
|
const createClassMap = (config) => {
|
|
285
317
|
const {
|
|
286
318
|
theme,
|
|
287
319
|
classGroups
|
|
288
320
|
} = config;
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
321
|
+
return processClassGroups(classGroups, theme);
|
|
322
|
+
};
|
|
323
|
+
const processClassGroups = (classGroups, theme) => {
|
|
324
|
+
const classMap = createClassPartObject();
|
|
293
325
|
for (const classGroupId in classGroups) {
|
|
294
|
-
|
|
326
|
+
const group = classGroups[classGroupId];
|
|
327
|
+
processClassesRecursively(group, classMap, classGroupId, theme);
|
|
295
328
|
}
|
|
296
329
|
return classMap;
|
|
297
330
|
};
|
|
298
331
|
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
|
-
|
|
332
|
+
const len = classGroup.length;
|
|
333
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
334
|
+
const classDefinition = classGroup[i2];
|
|
335
|
+
processClassDefinition(classDefinition, classPartObject, classGroupId, theme);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
const processClassDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
|
|
339
|
+
if (typeof classDefinition === "string") {
|
|
340
|
+
processStringDefinition(classDefinition, classPartObject, classGroupId);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (typeof classDefinition === "function") {
|
|
344
|
+
processFunctionDefinition(classDefinition, classPartObject, classGroupId, theme);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
processObjectDefinition(classDefinition, classPartObject, classGroupId, theme);
|
|
348
|
+
};
|
|
349
|
+
const processStringDefinition = (classDefinition, classPartObject, classGroupId) => {
|
|
350
|
+
const classPartObjectToEdit = classDefinition === "" ? classPartObject : getPart(classPartObject, classDefinition);
|
|
351
|
+
classPartObjectToEdit.classGroupId = classGroupId;
|
|
352
|
+
};
|
|
353
|
+
const processFunctionDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
|
|
354
|
+
if (isThemeGetter(classDefinition)) {
|
|
355
|
+
processClassesRecursively(classDefinition(theme), classPartObject, classGroupId, theme);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
if (classPartObject.validators === null) {
|
|
359
|
+
classPartObject.validators = [];
|
|
360
|
+
}
|
|
361
|
+
classPartObject.validators.push(createClassValidatorObject(classGroupId, classDefinition));
|
|
362
|
+
};
|
|
363
|
+
const processObjectDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
|
|
364
|
+
const entries = Object.entries(classDefinition);
|
|
365
|
+
const len = entries.length;
|
|
366
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
367
|
+
const [key, value] = entries[i2];
|
|
368
|
+
processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
|
|
369
|
+
}
|
|
320
370
|
};
|
|
321
371
|
const getPart = (classPartObject, path) => {
|
|
322
|
-
let
|
|
323
|
-
path.split(CLASS_PART_SEPARATOR)
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
372
|
+
let current = classPartObject;
|
|
373
|
+
const parts = path.split(CLASS_PART_SEPARATOR);
|
|
374
|
+
const len = parts.length;
|
|
375
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
376
|
+
const part = parts[i2];
|
|
377
|
+
let next = current.nextPart.get(part);
|
|
378
|
+
if (!next) {
|
|
379
|
+
next = createClassPartObject();
|
|
380
|
+
current.nextPart.set(part, next);
|
|
329
381
|
}
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
return
|
|
382
|
+
current = next;
|
|
383
|
+
}
|
|
384
|
+
return current;
|
|
333
385
|
};
|
|
334
|
-
const isThemeGetter = (func) => func.isThemeGetter;
|
|
386
|
+
const isThemeGetter = (func) => "isThemeGetter" in func && func.isThemeGetter === true;
|
|
335
387
|
const createLruCache = (maxCacheSize) => {
|
|
336
388
|
if (maxCacheSize < 1) {
|
|
337
389
|
return {
|
|
@@ -341,31 +393,31 @@ const createLruCache = (maxCacheSize) => {
|
|
|
341
393
|
};
|
|
342
394
|
}
|
|
343
395
|
let cacheSize = 0;
|
|
344
|
-
let cache = /* @__PURE__ */
|
|
345
|
-
let previousCache = /* @__PURE__ */
|
|
396
|
+
let cache = /* @__PURE__ */ Object.create(null);
|
|
397
|
+
let previousCache = /* @__PURE__ */ Object.create(null);
|
|
346
398
|
const update = (key, value) => {
|
|
347
|
-
cache
|
|
399
|
+
cache[key] = value;
|
|
348
400
|
cacheSize++;
|
|
349
401
|
if (cacheSize > maxCacheSize) {
|
|
350
402
|
cacheSize = 0;
|
|
351
403
|
previousCache = cache;
|
|
352
|
-
cache = /* @__PURE__ */
|
|
404
|
+
cache = /* @__PURE__ */ Object.create(null);
|
|
353
405
|
}
|
|
354
406
|
};
|
|
355
407
|
return {
|
|
356
408
|
get(key) {
|
|
357
|
-
let value = cache
|
|
409
|
+
let value = cache[key];
|
|
358
410
|
if (value !== void 0) {
|
|
359
411
|
return value;
|
|
360
412
|
}
|
|
361
|
-
if ((value = previousCache
|
|
413
|
+
if ((value = previousCache[key]) !== void 0) {
|
|
362
414
|
update(key, value);
|
|
363
415
|
return value;
|
|
364
416
|
}
|
|
365
417
|
},
|
|
366
418
|
set(key, value) {
|
|
367
|
-
if (cache
|
|
368
|
-
cache
|
|
419
|
+
if (key in cache) {
|
|
420
|
+
cache[key] = value;
|
|
369
421
|
} else {
|
|
370
422
|
update(key, value);
|
|
371
423
|
}
|
|
@@ -374,7 +426,14 @@ const createLruCache = (maxCacheSize) => {
|
|
|
374
426
|
};
|
|
375
427
|
const IMPORTANT_MODIFIER = "!";
|
|
376
428
|
const MODIFIER_SEPARATOR = ":";
|
|
377
|
-
const
|
|
429
|
+
const EMPTY_MODIFIERS = [];
|
|
430
|
+
const createResultObject = (modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition, isExternal) => ({
|
|
431
|
+
modifiers,
|
|
432
|
+
hasImportantModifier,
|
|
433
|
+
baseClassName,
|
|
434
|
+
maybePostfixModifierPosition,
|
|
435
|
+
isExternal
|
|
436
|
+
});
|
|
378
437
|
const createParseClassName = (config) => {
|
|
379
438
|
const {
|
|
380
439
|
prefix,
|
|
@@ -386,12 +445,13 @@ const createParseClassName = (config) => {
|
|
|
386
445
|
let parenDepth = 0;
|
|
387
446
|
let modifierStart = 0;
|
|
388
447
|
let postfixModifierPosition;
|
|
389
|
-
|
|
390
|
-
|
|
448
|
+
const len = className.length;
|
|
449
|
+
for (let index = 0; index < len; index++) {
|
|
450
|
+
const currentCharacter = className[index];
|
|
391
451
|
if (bracketDepth === 0 && parenDepth === 0) {
|
|
392
452
|
if (currentCharacter === MODIFIER_SEPARATOR) {
|
|
393
453
|
modifiers.push(className.slice(modifierStart, index));
|
|
394
|
-
modifierStart = index +
|
|
454
|
+
modifierStart = index + 1;
|
|
395
455
|
continue;
|
|
396
456
|
}
|
|
397
457
|
if (currentCharacter === "/") {
|
|
@@ -399,37 +459,34 @@ const createParseClassName = (config) => {
|
|
|
399
459
|
continue;
|
|
400
460
|
}
|
|
401
461
|
}
|
|
402
|
-
if (currentCharacter === "[")
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
462
|
+
if (currentCharacter === "[") bracketDepth++;
|
|
463
|
+
else if (currentCharacter === "]") bracketDepth--;
|
|
464
|
+
else if (currentCharacter === "(") parenDepth++;
|
|
465
|
+
else if (currentCharacter === ")") parenDepth--;
|
|
466
|
+
}
|
|
467
|
+
const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.slice(modifierStart);
|
|
468
|
+
let baseClassName = baseClassNameWithImportantModifier;
|
|
469
|
+
let hasImportantModifier = false;
|
|
470
|
+
if (baseClassNameWithImportantModifier.endsWith(IMPORTANT_MODIFIER)) {
|
|
471
|
+
baseClassName = baseClassNameWithImportantModifier.slice(0, -1);
|
|
472
|
+
hasImportantModifier = true;
|
|
473
|
+
} else if (
|
|
474
|
+
/**
|
|
475
|
+
* In Tailwind CSS v3 the important modifier was at the start of the base class name. This is still supported for legacy reasons.
|
|
476
|
+
* @see https://github.com/dcastil/tailwind-merge/issues/513#issuecomment-2614029864
|
|
477
|
+
*/
|
|
478
|
+
baseClassNameWithImportantModifier.startsWith(IMPORTANT_MODIFIER)
|
|
479
|
+
) {
|
|
480
|
+
baseClassName = baseClassNameWithImportantModifier.slice(1);
|
|
481
|
+
hasImportantModifier = true;
|
|
411
482
|
}
|
|
412
|
-
const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.substring(modifierStart);
|
|
413
|
-
const baseClassName = stripImportantModifier(baseClassNameWithImportantModifier);
|
|
414
|
-
const hasImportantModifier = baseClassName !== baseClassNameWithImportantModifier;
|
|
415
483
|
const maybePostfixModifierPosition = postfixModifierPosition && postfixModifierPosition > modifierStart ? postfixModifierPosition - modifierStart : void 0;
|
|
416
|
-
return
|
|
417
|
-
modifiers,
|
|
418
|
-
hasImportantModifier,
|
|
419
|
-
baseClassName,
|
|
420
|
-
maybePostfixModifierPosition
|
|
421
|
-
};
|
|
484
|
+
return createResultObject(modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition);
|
|
422
485
|
};
|
|
423
486
|
if (prefix) {
|
|
424
487
|
const fullPrefix = prefix + MODIFIER_SEPARATOR;
|
|
425
488
|
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
|
-
};
|
|
489
|
+
parseClassName = (className) => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.slice(fullPrefix.length)) : createResultObject(EMPTY_MODIFIERS, false, className, void 0, true);
|
|
433
490
|
}
|
|
434
491
|
if (experimentalParseClassName) {
|
|
435
492
|
const parseClassNameOriginal = parseClassName;
|
|
@@ -440,36 +497,35 @@ const createParseClassName = (config) => {
|
|
|
440
497
|
}
|
|
441
498
|
return parseClassName;
|
|
442
499
|
};
|
|
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
500
|
const createSortModifiers = (config) => {
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
const
|
|
459
|
-
let
|
|
460
|
-
modifiers.
|
|
461
|
-
const
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
501
|
+
const modifierWeights = /* @__PURE__ */ new Map();
|
|
502
|
+
config.orderSensitiveModifiers.forEach((mod, index) => {
|
|
503
|
+
modifierWeights.set(mod, 1e6 + index);
|
|
504
|
+
});
|
|
505
|
+
return (modifiers) => {
|
|
506
|
+
const result = [];
|
|
507
|
+
let currentSegment = [];
|
|
508
|
+
for (let i2 = 0; i2 < modifiers.length; i2++) {
|
|
509
|
+
const modifier = modifiers[i2];
|
|
510
|
+
const isArbitrary = modifier[0] === "[";
|
|
511
|
+
const isOrderSensitive = modifierWeights.has(modifier);
|
|
512
|
+
if (isArbitrary || isOrderSensitive) {
|
|
513
|
+
if (currentSegment.length > 0) {
|
|
514
|
+
currentSegment.sort();
|
|
515
|
+
result.push(...currentSegment);
|
|
516
|
+
currentSegment = [];
|
|
517
|
+
}
|
|
518
|
+
result.push(modifier);
|
|
465
519
|
} else {
|
|
466
|
-
|
|
520
|
+
currentSegment.push(modifier);
|
|
467
521
|
}
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
|
|
522
|
+
}
|
|
523
|
+
if (currentSegment.length > 0) {
|
|
524
|
+
currentSegment.sort();
|
|
525
|
+
result.push(...currentSegment);
|
|
526
|
+
}
|
|
527
|
+
return result;
|
|
471
528
|
};
|
|
472
|
-
return sortModifiers;
|
|
473
529
|
};
|
|
474
530
|
const createConfigUtils = (config) => ({
|
|
475
531
|
cache: createLruCache(config.cacheSize),
|
|
@@ -515,10 +571,10 @@ const mergeClassList = (classList, configUtils) => {
|
|
|
515
571
|
}
|
|
516
572
|
hasPostfixModifier = false;
|
|
517
573
|
}
|
|
518
|
-
const variantModifier = sortModifiers(modifiers).join(":");
|
|
574
|
+
const variantModifier = modifiers.length === 0 ? "" : modifiers.length === 1 ? modifiers[0] : sortModifiers(modifiers).join(":");
|
|
519
575
|
const modifierId = hasImportantModifier ? variantModifier + IMPORTANT_MODIFIER : variantModifier;
|
|
520
576
|
const classId = modifierId + classGroupId;
|
|
521
|
-
if (classGroupsInConflict.
|
|
577
|
+
if (classGroupsInConflict.indexOf(classId) > -1) {
|
|
522
578
|
continue;
|
|
523
579
|
}
|
|
524
580
|
classGroupsInConflict.push(classId);
|
|
@@ -531,13 +587,13 @@ const mergeClassList = (classList, configUtils) => {
|
|
|
531
587
|
}
|
|
532
588
|
return result;
|
|
533
589
|
};
|
|
534
|
-
|
|
590
|
+
const twJoin = (...classLists) => {
|
|
535
591
|
let index = 0;
|
|
536
592
|
let argument;
|
|
537
593
|
let resolvedValue;
|
|
538
594
|
let string = "";
|
|
539
|
-
while (index <
|
|
540
|
-
if (argument =
|
|
595
|
+
while (index < classLists.length) {
|
|
596
|
+
if (argument = classLists[index++]) {
|
|
541
597
|
if (resolvedValue = toValue(argument)) {
|
|
542
598
|
string && (string += " ");
|
|
543
599
|
string += resolvedValue;
|
|
@@ -545,7 +601,7 @@ function twJoin() {
|
|
|
545
601
|
}
|
|
546
602
|
}
|
|
547
603
|
return string;
|
|
548
|
-
}
|
|
604
|
+
};
|
|
549
605
|
const toValue = (mix) => {
|
|
550
606
|
if (typeof mix === "string") {
|
|
551
607
|
return mix;
|
|
@@ -562,20 +618,20 @@ const toValue = (mix) => {
|
|
|
562
618
|
}
|
|
563
619
|
return string;
|
|
564
620
|
};
|
|
565
|
-
|
|
621
|
+
const createTailwindMerge = (createConfigFirst, ...createConfigRest) => {
|
|
566
622
|
let configUtils;
|
|
567
623
|
let cacheGet;
|
|
568
624
|
let cacheSet;
|
|
569
|
-
let functionToCall
|
|
570
|
-
|
|
625
|
+
let functionToCall;
|
|
626
|
+
const initTailwindMerge = (classList) => {
|
|
571
627
|
const config = createConfigRest.reduce((previousConfig, createConfigCurrent) => createConfigCurrent(previousConfig), createConfigFirst());
|
|
572
628
|
configUtils = createConfigUtils(config);
|
|
573
629
|
cacheGet = configUtils.cache.get;
|
|
574
630
|
cacheSet = configUtils.cache.set;
|
|
575
631
|
functionToCall = tailwindMerge;
|
|
576
632
|
return tailwindMerge(classList);
|
|
577
|
-
}
|
|
578
|
-
|
|
633
|
+
};
|
|
634
|
+
const tailwindMerge = (classList) => {
|
|
579
635
|
const cachedResult = cacheGet(classList);
|
|
580
636
|
if (cachedResult) {
|
|
581
637
|
return cachedResult;
|
|
@@ -583,13 +639,13 @@ function createTailwindMerge(createConfigFirst, ...createConfigRest) {
|
|
|
583
639
|
const result = mergeClassList(classList, configUtils);
|
|
584
640
|
cacheSet(classList, result);
|
|
585
641
|
return result;
|
|
586
|
-
}
|
|
587
|
-
return function callTailwindMerge() {
|
|
588
|
-
return functionToCall(twJoin.apply(null, arguments));
|
|
589
642
|
};
|
|
590
|
-
|
|
643
|
+
functionToCall = initTailwindMerge;
|
|
644
|
+
return (...args) => functionToCall(twJoin(...args));
|
|
645
|
+
};
|
|
646
|
+
const fallbackThemeArr = [];
|
|
591
647
|
const fromTheme = (key) => {
|
|
592
|
-
const themeGetter = (theme) => theme[key] ||
|
|
648
|
+
const themeGetter = (theme) => theme[key] || fallbackThemeArr;
|
|
593
649
|
themeGetter.isThemeGetter = true;
|
|
594
650
|
return themeGetter;
|
|
595
651
|
};
|
package/dist/squirrel.css
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pequity/squirrel",
|
|
3
3
|
"description": "Squirrel component library",
|
|
4
|
-
"version": "11.0.
|
|
5
|
-
"packageManager": "pnpm@10.
|
|
4
|
+
"version": "11.0.1",
|
|
5
|
+
"packageManager": "pnpm@10.22.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"preinstall": "npx only-allow pnpm",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"module": "./dist/es/index.js",
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@tanstack/vue-virtual": "^3.8.3",
|
|
42
|
-
"@vuepic/vue-datepicker": "^
|
|
42
|
+
"@vuepic/vue-datepicker": "^12.0.3",
|
|
43
43
|
"floating-vue": "^5.2.2",
|
|
44
44
|
"iconify-icon": "^3.0.0",
|
|
45
45
|
"lodash-es": "^4.17.21",
|
|
@@ -56,30 +56,30 @@
|
|
|
56
56
|
"@playwright/test": "^1.56.1",
|
|
57
57
|
"@semantic-release/changelog": "^6.0.3",
|
|
58
58
|
"@semantic-release/git": "^10.0.1",
|
|
59
|
-
"@storybook/addon-a11y": "^10.0.
|
|
60
|
-
"@storybook/addon-docs": "^10.0.
|
|
61
|
-
"@storybook/addon-links": "^10.0.
|
|
62
|
-
"@storybook/addon-vitest": "^10.0.
|
|
63
|
-
"@storybook/vue3-vite": "^10.0.
|
|
59
|
+
"@storybook/addon-a11y": "^10.0.7",
|
|
60
|
+
"@storybook/addon-docs": "^10.0.7",
|
|
61
|
+
"@storybook/addon-links": "^10.0.7",
|
|
62
|
+
"@storybook/addon-vitest": "^10.0.7",
|
|
63
|
+
"@storybook/vue3-vite": "^10.0.7",
|
|
64
64
|
"@tanstack/vue-virtual": "3.13.12",
|
|
65
65
|
"@types/jsdom": "^27.0.0",
|
|
66
66
|
"@types/lodash-es": "^4.17.12",
|
|
67
|
-
"@types/node": "^24.10.
|
|
67
|
+
"@types/node": "^24.10.1",
|
|
68
68
|
"@vitejs/plugin-vue": "^6.0.1",
|
|
69
69
|
"@vitest/browser": "4.0.8",
|
|
70
70
|
"@vitest/browser-playwright": "^4.0.8",
|
|
71
71
|
"@vitest/coverage-v8": "^4.0.8",
|
|
72
72
|
"@vue/compiler-sfc": "3.5.24",
|
|
73
73
|
"@vue/test-utils": "^2.4.6",
|
|
74
|
-
"@vuepic/vue-datepicker": "12.0.
|
|
75
|
-
"autoprefixer": "^10.4.
|
|
74
|
+
"@vuepic/vue-datepicker": "12.0.3",
|
|
75
|
+
"autoprefixer": "^10.4.22",
|
|
76
76
|
"eslint": "^9.39.1",
|
|
77
|
-
"eslint-plugin-storybook": "^10.0.
|
|
77
|
+
"eslint-plugin-storybook": "^10.0.7",
|
|
78
78
|
"floating-vue": "5.2.2",
|
|
79
79
|
"glob": "^11.0.3",
|
|
80
80
|
"husky": "^9.1.7",
|
|
81
81
|
"iconify-icon": "^3.0.2",
|
|
82
|
-
"jsdom": "^27.
|
|
82
|
+
"jsdom": "^27.2.0",
|
|
83
83
|
"lint-staged": "^16.2.6",
|
|
84
84
|
"lodash-es": "4.17.21",
|
|
85
85
|
"make-coverage-badge": "^1.2.0",
|
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
"prettier-plugin-tailwindcss": "^0.7.1",
|
|
90
90
|
"resolve-tspaths": "^0.8.23",
|
|
91
91
|
"rimraf": "^6.1.0",
|
|
92
|
-
"sass": "^1.
|
|
93
|
-
"semantic-release": "^25.0.
|
|
94
|
-
"storybook": "^10.0.
|
|
92
|
+
"sass": "^1.94.0",
|
|
93
|
+
"semantic-release": "^25.0.2",
|
|
94
|
+
"storybook": "^10.0.7",
|
|
95
95
|
"svgo": "^4.0.0",
|
|
96
96
|
"tailwindcss": "^3.4.17",
|
|
97
97
|
"typescript": "5.9.3",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
},
|
|
107
107
|
"dependencies": {
|
|
108
108
|
"date-fns": "^4.1.0",
|
|
109
|
-
"tailwind-merge": "^3.
|
|
109
|
+
"tailwind-merge": "^3.4.0",
|
|
110
110
|
"tailwind-variants": "^3.1.1"
|
|
111
111
|
}
|
|
112
112
|
}
|