@pequity/squirrel 10.1.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/cjs/chunks/p-inline-date-picker.js +51 -84
- package/dist/cjs/dateLocale.js +886 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/p-date-picker.js +146 -2
- package/dist/cjs/p-select-pill.js +1 -1
- package/dist/es/chunks/index.js +199 -143
- package/dist/es/chunks/p-inline-date-picker.js +50 -83
- package/dist/es/dateLocale.js +886 -0
- package/dist/es/index.js +50 -50
- package/dist/es/p-date-picker.js +146 -2
- package/dist/es/p-select-pill.js +1 -1
- package/dist/squirrel/components/p-date-picker/p-date-picker.vue.d.ts +19 -23
- package/dist/squirrel/components/p-drawer/p-drawer.vue.d.ts +2 -2
- package/dist/squirrel/components/p-inline-date-picker/p-inline-date-picker.vue.d.ts +12 -13
- package/dist/squirrel/components/p-modal/p-modal.vue.d.ts +2 -2
- package/dist/squirrel/components/p-steps/p-steps.vue.d.ts +1 -1
- package/dist/squirrel/utils/dateLocale.d.ts +2 -0
- package/dist/squirrel.css +35 -2
- package/package.json +28 -27
- package/squirrel/components/p-date-picker/p-date-picker.spec.js +49 -4
- package/squirrel/components/p-date-picker/p-date-picker.vue +84 -12
- package/squirrel/components/p-inline-date-picker/p-inline-date-picker.spec.js +33 -18
- package/squirrel/components/p-inline-date-picker/p-inline-date-picker.vue +21 -10
- package/squirrel/components/p-select-pill/p-select-pill.vue +1 -1
- package/squirrel/utils/dateLocale.spec.ts +20 -0
- package/squirrel/utils/dateLocale.ts +19 -0
- package/dist/cjs/chunks/p-date-picker.js +0 -171
- package/dist/es/chunks/p-date-picker.js +0 -172
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
|
};
|