@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/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
|
};
|