@vaneui/ui 0.0.17 → 0.0.19
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/complex.css +34 -706
- package/dist/components/theme/components/theme/themeContext.d.ts +8 -4
- package/dist/components/theme/components/ui/theme/common/ComponentTheme.d.ts +2 -2
- package/dist/components/theme/components/utils/componentUtils.d.ts +1 -1
- package/dist/components/theme/index.js +207 -193
- package/dist/components/theme/index.js.map +1 -1
- package/dist/components/theme/themeContext.d.ts +8 -4
- package/dist/components/ui/theme/common/ComponentTheme.d.ts +2 -2
- package/dist/components/utils/componentUtils.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +210 -194
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +211 -193
- package/dist/index.js.map +1 -1
- package/dist/ui.css +34 -706
- package/package.json +2 -2
|
@@ -259,25 +259,25 @@ const positionClasses = {
|
|
|
259
259
|
static: "static"
|
|
260
260
|
};
|
|
261
261
|
const shadowClasses = {
|
|
262
|
-
xs: "shadow-
|
|
263
|
-
sm: "shadow-
|
|
264
|
-
md: "shadow-
|
|
265
|
-
lg: "shadow-
|
|
266
|
-
xl: "shadow-
|
|
262
|
+
xs: "shadow-2xs",
|
|
263
|
+
sm: "shadow-xs",
|
|
264
|
+
md: "shadow-sm",
|
|
265
|
+
lg: "shadow-md",
|
|
266
|
+
xl: "shadow-lg"
|
|
267
267
|
};
|
|
268
268
|
const hoverShadowClasses = {
|
|
269
|
-
xs: "hover:shadow-
|
|
270
|
-
sm: "hover:shadow-
|
|
271
|
-
md: "hover:shadow-
|
|
272
|
-
lg: "hover:shadow-
|
|
273
|
-
xl: "hover:shadow-
|
|
269
|
+
xs: "hover:shadow-xs",
|
|
270
|
+
sm: "hover:shadow-sm",
|
|
271
|
+
md: "hover:shadow-md",
|
|
272
|
+
lg: "hover:shadow-lg",
|
|
273
|
+
xl: "hover:shadow-xl"
|
|
274
274
|
};
|
|
275
275
|
const activeShadowClasses = {
|
|
276
|
-
xs: "active:shadow-
|
|
277
|
-
sm: "active:shadow-
|
|
278
|
-
md: "active:shadow-
|
|
279
|
-
lg: "active:shadow-
|
|
280
|
-
xl: "active:shadow-
|
|
276
|
+
xs: "active:shadow-xs",
|
|
277
|
+
sm: "active:shadow-sm",
|
|
278
|
+
md: "active:shadow-md",
|
|
279
|
+
lg: "active:shadow-lg",
|
|
280
|
+
xl: "active:shadow-xl"
|
|
281
281
|
};
|
|
282
282
|
const noRingModeClasses = {
|
|
283
283
|
base: "ring-0",
|
|
@@ -295,27 +295,26 @@ const noShadowModeClasses = {
|
|
|
295
295
|
active: "active:shadow-none",
|
|
296
296
|
};
|
|
297
297
|
|
|
298
|
-
function
|
|
298
|
+
function pickFirstTruthyKeyOptional(collection, keys) {
|
|
299
299
|
for (const k of keys) {
|
|
300
|
-
if (
|
|
300
|
+
if (collection[k] === true)
|
|
301
301
|
return k;
|
|
302
302
|
}
|
|
303
|
-
return
|
|
303
|
+
return undefined;
|
|
304
304
|
}
|
|
305
305
|
/**
|
|
306
306
|
* Pick the first truthy key from props, then from defaults, then fallback.
|
|
307
307
|
*/
|
|
308
|
-
function
|
|
309
|
-
//
|
|
310
|
-
const explicit =
|
|
308
|
+
function pickFirstTruthyKey(props, defaults, keys) {
|
|
309
|
+
// first check explicit usage in props
|
|
310
|
+
const explicit = pickFirstTruthyKeyOptional(props, keys);
|
|
311
311
|
if (explicit)
|
|
312
312
|
return explicit;
|
|
313
|
-
//
|
|
314
|
-
const def =
|
|
313
|
+
// then check component‐level defaults
|
|
314
|
+
const def = pickFirstTruthyKeyOptional(defaults, keys);
|
|
315
315
|
if (def)
|
|
316
316
|
return def;
|
|
317
|
-
|
|
318
|
-
return fallback;
|
|
317
|
+
return undefined;
|
|
319
318
|
}
|
|
320
319
|
|
|
321
320
|
class HideTheme extends BaseTheme {
|
|
@@ -327,81 +326,12 @@ class HideTheme extends BaseTheme {
|
|
|
327
326
|
});
|
|
328
327
|
}
|
|
329
328
|
getClasses(props, defaults) {
|
|
330
|
-
const key =
|
|
329
|
+
const key = pickFirstTruthyKey(props, defaults, HIDE_KEYS);
|
|
331
330
|
return [key ? this[key] : ''];
|
|
332
331
|
}
|
|
333
332
|
}
|
|
334
333
|
HideTheme.defaultClasses = hideClasses;
|
|
335
334
|
|
|
336
|
-
const isObject = (item) => {
|
|
337
|
-
return item !== null && typeof item === 'object' && !Array.isArray(item);
|
|
338
|
-
};
|
|
339
|
-
const deepMerge = (target, source) => {
|
|
340
|
-
const output = Object.assign(Object.create(Object.getPrototypeOf(target)), target);
|
|
341
|
-
for (const key in source) {
|
|
342
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
343
|
-
const sourceValue = source[key];
|
|
344
|
-
const targetValue = output[key];
|
|
345
|
-
if (sourceValue === undefined) {
|
|
346
|
-
continue;
|
|
347
|
-
}
|
|
348
|
-
// Special case: If the key is 'defaults', use the contextual mergeDefaults function.
|
|
349
|
-
if (key === 'defaults' &&
|
|
350
|
-
isObject(targetValue) &&
|
|
351
|
-
isObject(sourceValue)) {
|
|
352
|
-
output[key] = mergeDefaults(targetValue, sourceValue);
|
|
353
|
-
}
|
|
354
|
-
// For all other objects, use the standard recursive deep merge.
|
|
355
|
-
else if (isObject(targetValue) && isObject(sourceValue)) {
|
|
356
|
-
output[key] = deepMerge(targetValue, sourceValue);
|
|
357
|
-
}
|
|
358
|
-
// For non-object values, just assign the value from the source.
|
|
359
|
-
else {
|
|
360
|
-
output[key] = sourceValue;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
return output;
|
|
365
|
-
};
|
|
366
|
-
const deepClone = (source) => {
|
|
367
|
-
if (!isObject(source)) {
|
|
368
|
-
return source;
|
|
369
|
-
}
|
|
370
|
-
const output = Object.assign(Object.create(Object.getPrototypeOf(source)), source);
|
|
371
|
-
for (const key in output) {
|
|
372
|
-
if (Object.prototype.hasOwnProperty.call(output, key)) {
|
|
373
|
-
output[key] = deepClone(output[key]);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
return output;
|
|
377
|
-
};
|
|
378
|
-
const findGroup = (key) => EXCLUSIVE_KEY_GROUPS.find(group => group.includes(key));
|
|
379
|
-
const mergeDefaults = (baseDefaults, overrideDefaults) => {
|
|
380
|
-
const finalDefaults = { ...baseDefaults };
|
|
381
|
-
// Iterate over the override keys to apply them.
|
|
382
|
-
for (const key in overrideDefaults) {
|
|
383
|
-
if (Object.prototype.hasOwnProperty.call(overrideDefaults, key)) {
|
|
384
|
-
const overrideValue = overrideDefaults[key];
|
|
385
|
-
// If the override is setting a key to true...
|
|
386
|
-
if (overrideValue) {
|
|
387
|
-
// Find the exclusive group this key belongs to (e.g., SIZE_KEYS).
|
|
388
|
-
const group = findGroup(key);
|
|
389
|
-
// If the key is part of an exclusive group...
|
|
390
|
-
if (group) {
|
|
391
|
-
// ...set all other keys in that group to false.
|
|
392
|
-
group.forEach(groupKey => {
|
|
393
|
-
if (groupKey !== key) {
|
|
394
|
-
finalDefaults[groupKey] = false;
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
finalDefaults[key] = overrideValue;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
return finalDefaults;
|
|
403
|
-
};
|
|
404
|
-
|
|
405
335
|
class ItemsTheme extends BaseTheme {
|
|
406
336
|
constructor(initialConfig) {
|
|
407
337
|
super();
|
|
@@ -411,7 +341,7 @@ class ItemsTheme extends BaseTheme {
|
|
|
411
341
|
});
|
|
412
342
|
}
|
|
413
343
|
getClasses(props, defaults) {
|
|
414
|
-
const pickedKey =
|
|
344
|
+
const pickedKey = pickFirstTruthyKey(props, defaults, ITEMS_KEYS);
|
|
415
345
|
return [pickedKey && this[pickedKey] ? this[pickedKey] : ''];
|
|
416
346
|
}
|
|
417
347
|
}
|
|
@@ -432,7 +362,7 @@ class JustifyTheme extends BaseTheme {
|
|
|
432
362
|
});
|
|
433
363
|
}
|
|
434
364
|
getClasses(props, defaults) {
|
|
435
|
-
const key =
|
|
365
|
+
const key = pickFirstTruthyKey(props, defaults, JUSTIFY_KEYS);
|
|
436
366
|
return [key ? this[key] : ''];
|
|
437
367
|
}
|
|
438
368
|
}
|
|
@@ -447,7 +377,7 @@ class PositionTheme extends BaseTheme {
|
|
|
447
377
|
});
|
|
448
378
|
}
|
|
449
379
|
getClasses(props, defaults) {
|
|
450
|
-
const key =
|
|
380
|
+
const key = pickFirstTruthyKey(props, defaults, POSITION_KEYS);
|
|
451
381
|
return [key ? this[key] : ''];
|
|
452
382
|
}
|
|
453
383
|
}
|
|
@@ -530,6 +460,21 @@ const textSizeClasses = {
|
|
|
530
460
|
xl: "text-xl",
|
|
531
461
|
};
|
|
532
462
|
|
|
463
|
+
class FontStyleTheme extends BaseTheme {
|
|
464
|
+
constructor(initial) {
|
|
465
|
+
super();
|
|
466
|
+
FONT_STYLE_KEYS.forEach((key) => {
|
|
467
|
+
var _a;
|
|
468
|
+
this[key] = (_a = initial === null || initial === void 0 ? void 0 : initial[key]) !== null && _a !== void 0 ? _a : FontStyleTheme.defaultClasses[key];
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
getClasses(props, defaults) {
|
|
472
|
+
const key = pickFirstTruthyKey(props, defaults, FONT_STYLE_KEYS);
|
|
473
|
+
return [key ? this[key] : '']; // No default for font style
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
FontStyleTheme.defaultClasses = fontStyleClasses;
|
|
477
|
+
|
|
533
478
|
class FontFamilyTheme extends BaseTheme {
|
|
534
479
|
constructor(initial) {
|
|
535
480
|
super();
|
|
@@ -539,7 +484,7 @@ class FontFamilyTheme extends BaseTheme {
|
|
|
539
484
|
});
|
|
540
485
|
}
|
|
541
486
|
getClasses(props, defaults) {
|
|
542
|
-
const key =
|
|
487
|
+
const key = pickFirstTruthyKey(props, defaults, FONT_FAMILY_KEYS);
|
|
543
488
|
return [this[key !== null && key !== void 0 ? key : 'sans'] || ''];
|
|
544
489
|
}
|
|
545
490
|
}
|
|
@@ -554,27 +499,12 @@ class FontWeightTheme extends BaseTheme {
|
|
|
554
499
|
});
|
|
555
500
|
}
|
|
556
501
|
getClasses(props, defaults) {
|
|
557
|
-
const key =
|
|
502
|
+
const key = pickFirstTruthyKey(props, defaults, FONT_WEIGHT_KEYS);
|
|
558
503
|
return [this[key !== null && key !== void 0 ? key : 'normal'] || '']; // Default to 'normal' if no key is provided
|
|
559
504
|
}
|
|
560
505
|
}
|
|
561
506
|
FontWeightTheme.defaultClasses = fontWeightClasses;
|
|
562
507
|
|
|
563
|
-
class FontStyleTheme extends BaseTheme {
|
|
564
|
-
constructor(initial) {
|
|
565
|
-
super();
|
|
566
|
-
FONT_STYLE_KEYS.forEach((key) => {
|
|
567
|
-
var _a;
|
|
568
|
-
this[key] = (_a = initial === null || initial === void 0 ? void 0 : initial[key]) !== null && _a !== void 0 ? _a : FontStyleTheme.defaultClasses[key];
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
getClasses(props, defaults) {
|
|
572
|
-
const key = pickKey(props, defaults, FONT_STYLE_KEYS);
|
|
573
|
-
return [key ? this[key] : '']; // No default for font style
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
FontStyleTheme.defaultClasses = fontStyleClasses;
|
|
577
|
-
|
|
578
508
|
class TextDecorationTheme extends BaseTheme {
|
|
579
509
|
constructor(initial) {
|
|
580
510
|
super();
|
|
@@ -584,7 +514,7 @@ class TextDecorationTheme extends BaseTheme {
|
|
|
584
514
|
});
|
|
585
515
|
}
|
|
586
516
|
getClasses(props, defaults) {
|
|
587
|
-
const key =
|
|
517
|
+
const key = pickFirstTruthyKey(props, defaults, TEXT_DECORATION_KEYS);
|
|
588
518
|
return [key ? this[key] : '']; // No default for text decoration
|
|
589
519
|
}
|
|
590
520
|
}
|
|
@@ -599,7 +529,7 @@ class TextTransformTheme extends BaseTheme {
|
|
|
599
529
|
});
|
|
600
530
|
}
|
|
601
531
|
getClasses(props, defaults) {
|
|
602
|
-
const key =
|
|
532
|
+
const key = pickFirstTruthyKey(props, defaults, TEXT_TRANSFORM_KEYS);
|
|
603
533
|
return [key ? this[key] : '']; // No default for text transform
|
|
604
534
|
}
|
|
605
535
|
}
|
|
@@ -614,12 +544,81 @@ class TextAlignTheme extends BaseTheme {
|
|
|
614
544
|
});
|
|
615
545
|
}
|
|
616
546
|
getClasses(props, defaults) {
|
|
617
|
-
const key =
|
|
547
|
+
const key = pickFirstTruthyKey(props, defaults, TEXT_ALIGN_KEYS);
|
|
618
548
|
return [key ? this[key] : '']; // No default for text align
|
|
619
549
|
}
|
|
620
550
|
}
|
|
621
551
|
TextAlignTheme.defaultClasses = textAlignClasses;
|
|
622
552
|
|
|
553
|
+
const isObject = (item) => {
|
|
554
|
+
return item !== null && typeof item === 'object' && !Array.isArray(item);
|
|
555
|
+
};
|
|
556
|
+
const deepMerge = (target, source) => {
|
|
557
|
+
const output = Object.assign(Object.create(Object.getPrototypeOf(target)), target);
|
|
558
|
+
for (const key in source) {
|
|
559
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
560
|
+
const sourceValue = source[key];
|
|
561
|
+
const targetValue = output[key];
|
|
562
|
+
if (sourceValue === undefined) {
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
// Special case: If the key is 'defaults', use the contextual mergeDefaults function.
|
|
566
|
+
if (key === 'defaults' &&
|
|
567
|
+
isObject(targetValue) &&
|
|
568
|
+
isObject(sourceValue)) {
|
|
569
|
+
output[key] = mergeDefaults(targetValue, sourceValue);
|
|
570
|
+
}
|
|
571
|
+
// For all other objects, use the standard recursive deep merge.
|
|
572
|
+
else if (isObject(targetValue) && isObject(sourceValue)) {
|
|
573
|
+
output[key] = deepMerge(targetValue, sourceValue);
|
|
574
|
+
}
|
|
575
|
+
// For non-object values, just assign the value from the source.
|
|
576
|
+
else {
|
|
577
|
+
output[key] = sourceValue;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
return output;
|
|
582
|
+
};
|
|
583
|
+
const deepClone = (source) => {
|
|
584
|
+
if (!isObject(source)) {
|
|
585
|
+
return source;
|
|
586
|
+
}
|
|
587
|
+
const output = Object.assign(Object.create(Object.getPrototypeOf(source)), source);
|
|
588
|
+
for (const key in output) {
|
|
589
|
+
if (Object.prototype.hasOwnProperty.call(output, key)) {
|
|
590
|
+
output[key] = deepClone(output[key]);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
return output;
|
|
594
|
+
};
|
|
595
|
+
const findGroup = (key) => EXCLUSIVE_KEY_GROUPS.find(group => group.includes(key));
|
|
596
|
+
const mergeDefaults = (baseDefaults, overrideDefaults) => {
|
|
597
|
+
const finalDefaults = { ...baseDefaults };
|
|
598
|
+
// Iterate over the override keys to apply them.
|
|
599
|
+
for (const key in overrideDefaults) {
|
|
600
|
+
if (Object.prototype.hasOwnProperty.call(overrideDefaults, key)) {
|
|
601
|
+
const overrideValue = overrideDefaults[key];
|
|
602
|
+
// If the override is setting a key to true...
|
|
603
|
+
if (overrideValue) {
|
|
604
|
+
// Find the exclusive group this key belongs to (e.g., SIZE_KEYS).
|
|
605
|
+
const group = findGroup(key);
|
|
606
|
+
// If the key is part of an exclusive group...
|
|
607
|
+
if (group) {
|
|
608
|
+
// ...set all other keys in that group to false.
|
|
609
|
+
group.forEach(groupKey => {
|
|
610
|
+
if (groupKey !== key) {
|
|
611
|
+
finalDefaults[groupKey] = false;
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
finalDefaults[key] = overrideValue;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
return finalDefaults;
|
|
620
|
+
};
|
|
621
|
+
|
|
623
622
|
class ComponentTheme {
|
|
624
623
|
constructor(tag, base, subThemes, defaults = {}) {
|
|
625
624
|
this.tag = tag;
|
|
@@ -675,7 +674,7 @@ class SizeTheme extends BaseTheme {
|
|
|
675
674
|
});
|
|
676
675
|
}
|
|
677
676
|
getClasses(props, defaults) {
|
|
678
|
-
const size =
|
|
677
|
+
const size = pickFirstTruthyKey(props, defaults, SIZE_KEYS);
|
|
679
678
|
return [this[size !== null && size !== void 0 ? size : 'md'] || ''];
|
|
680
679
|
}
|
|
681
680
|
}
|
|
@@ -696,8 +695,8 @@ class GapTheme extends BaseTheme {
|
|
|
696
695
|
});
|
|
697
696
|
}
|
|
698
697
|
getClasses(props, defaults) {
|
|
699
|
-
const size =
|
|
700
|
-
const key =
|
|
698
|
+
const size = pickFirstTruthyKey(props, defaults, SIZE_KEYS) || 'md';
|
|
699
|
+
const key = pickFirstTruthyKey(props, defaults, GAP_KEYS) || 'noGap';
|
|
701
700
|
return [typeof this[key] === 'string' ? this[key] : this[key][size]];
|
|
702
701
|
}
|
|
703
702
|
}
|
|
@@ -721,8 +720,8 @@ class RadiusTheme extends BaseTheme {
|
|
|
721
720
|
});
|
|
722
721
|
}
|
|
723
722
|
getClasses(props, defaults) {
|
|
724
|
-
const size =
|
|
725
|
-
const shape =
|
|
723
|
+
const size = pickFirstTruthyKey(props, defaults, SIZE_KEYS) || 'md';
|
|
724
|
+
const shape = pickFirstTruthyKey(props, defaults, SHAPE_KEYS) || 'rounded';
|
|
726
725
|
return [typeof this[shape] === 'string' ? this[shape] : this[shape][size]];
|
|
727
726
|
}
|
|
728
727
|
}
|
|
@@ -741,8 +740,8 @@ class ShadowTheme extends BaseTheme {
|
|
|
741
740
|
});
|
|
742
741
|
}
|
|
743
742
|
getClasses(props, defaults) {
|
|
744
|
-
const size =
|
|
745
|
-
const key =
|
|
743
|
+
const size = pickFirstTruthyKey(props, defaults, SIZE_KEYS) || 'md';
|
|
744
|
+
const key = pickFirstTruthyKey(props, defaults, SHADOW_KEYS);
|
|
746
745
|
if (key === undefined) {
|
|
747
746
|
return [];
|
|
748
747
|
}
|
|
@@ -772,7 +771,7 @@ class BorderTheme extends BaseTheme {
|
|
|
772
771
|
});
|
|
773
772
|
}
|
|
774
773
|
getClasses(props, defaults) {
|
|
775
|
-
const key =
|
|
774
|
+
const key = pickFirstTruthyKey(props, defaults, BORDER_KEYS);
|
|
776
775
|
if (!key || !this[key]) {
|
|
777
776
|
return MODE_KEYS.map(() => '');
|
|
778
777
|
}
|
|
@@ -786,10 +785,15 @@ BorderTheme.defaultClasses = {
|
|
|
786
785
|
active: "active:border",
|
|
787
786
|
},
|
|
788
787
|
noBorder: {
|
|
789
|
-
base: "
|
|
790
|
-
hover: "
|
|
791
|
-
active: "
|
|
788
|
+
base: "",
|
|
789
|
+
hover: "",
|
|
790
|
+
active: "",
|
|
792
791
|
},
|
|
792
|
+
//noBorder: {
|
|
793
|
+
// base: "border-none",
|
|
794
|
+
// hover: "hover:border-none",
|
|
795
|
+
// active: "active:border-none",
|
|
796
|
+
//},
|
|
793
797
|
};
|
|
794
798
|
|
|
795
799
|
class RingTheme extends BaseTheme {
|
|
@@ -803,7 +807,7 @@ class RingTheme extends BaseTheme {
|
|
|
803
807
|
});
|
|
804
808
|
}
|
|
805
809
|
getClasses(props, defaults) {
|
|
806
|
-
const key =
|
|
810
|
+
const key = pickFirstTruthyKey(props, defaults, RING_KEYS);
|
|
807
811
|
if (!key || !this[key]) {
|
|
808
812
|
return MODE_KEYS.map(() => '');
|
|
809
813
|
}
|
|
@@ -824,8 +828,8 @@ class PxTheme extends BaseTheme {
|
|
|
824
828
|
});
|
|
825
829
|
}
|
|
826
830
|
getClasses(props, defaults) {
|
|
827
|
-
const size =
|
|
828
|
-
const key =
|
|
831
|
+
const size = pickFirstTruthyKey(props, defaults, SIZE_KEYS) || 'md';
|
|
832
|
+
const key = pickFirstTruthyKey(props, defaults, PADDING_KEYS) || 'noPadding';
|
|
829
833
|
return [typeof this[key] === 'string' ? this[key] : this[key][size]];
|
|
830
834
|
}
|
|
831
835
|
}
|
|
@@ -849,8 +853,8 @@ class PyTheme extends BaseTheme {
|
|
|
849
853
|
});
|
|
850
854
|
}
|
|
851
855
|
getClasses(props, defaults) {
|
|
852
|
-
const size =
|
|
853
|
-
const key =
|
|
856
|
+
const size = pickFirstTruthyKey(props, defaults, SIZE_KEYS) || 'md';
|
|
857
|
+
const key = pickFirstTruthyKey(props, defaults, PADDING_KEYS) || 'noPadding';
|
|
854
858
|
return [typeof this[key] === 'string' ? this[key] : this[key][size]];
|
|
855
859
|
}
|
|
856
860
|
}
|
|
@@ -878,7 +882,7 @@ class TextAppearanceTheme extends BaseTheme {
|
|
|
878
882
|
});
|
|
879
883
|
}
|
|
880
884
|
getClasses(props, defaults) {
|
|
881
|
-
const pickedAppearanceKey =
|
|
885
|
+
const pickedAppearanceKey = pickFirstTruthyKey(props, defaults, TEXT_APPEARANCE_KEYS) || 'default';
|
|
882
886
|
const modesForAppearance = this[pickedAppearanceKey];
|
|
883
887
|
if (!modesForAppearance) {
|
|
884
888
|
return MODE_KEYS.map(() => '');
|
|
@@ -1100,7 +1104,7 @@ class VariantTheme extends BaseTheme {
|
|
|
1100
1104
|
});
|
|
1101
1105
|
}
|
|
1102
1106
|
getClasses(props, defaults) {
|
|
1103
|
-
const activeVariantKey =
|
|
1107
|
+
const activeVariantKey = pickFirstTruthyKey(props, defaults, VARIANT_KEYS) || 'outline';
|
|
1104
1108
|
const activeTextAppearanceTheme = this[activeVariantKey];
|
|
1105
1109
|
if (!activeTextAppearanceTheme) {
|
|
1106
1110
|
return [];
|
|
@@ -1157,8 +1161,8 @@ const defaultButtonTheme = new ComponentTheme("button", "w-fit h-fit cursor-poin
|
|
|
1157
1161
|
px: new PxTheme({
|
|
1158
1162
|
padding: {
|
|
1159
1163
|
xs: 'px-2',
|
|
1160
|
-
sm: 'px-
|
|
1161
|
-
md: 'px-
|
|
1164
|
+
sm: 'px-3',
|
|
1165
|
+
md: 'px-4',
|
|
1162
1166
|
lg: 'px-5',
|
|
1163
1167
|
xl: 'px-6',
|
|
1164
1168
|
}
|
|
@@ -1168,25 +1172,25 @@ const defaultButtonTheme = new ComponentTheme("button", "w-fit h-fit cursor-poin
|
|
|
1168
1172
|
xs: 'py-1',
|
|
1169
1173
|
sm: 'py-1.5',
|
|
1170
1174
|
md: 'py-2',
|
|
1171
|
-
lg: 'py-
|
|
1172
|
-
xl: 'py-
|
|
1175
|
+
lg: 'py-2.5',
|
|
1176
|
+
xl: 'py-3',
|
|
1173
1177
|
}
|
|
1174
1178
|
}),
|
|
1175
1179
|
gap: new GapTheme({
|
|
1176
1180
|
gap: {
|
|
1177
|
-
xs: 'gap-1
|
|
1178
|
-
sm: 'gap-
|
|
1179
|
-
md: 'gap-
|
|
1180
|
-
lg: 'gap-
|
|
1181
|
-
xl: 'gap-
|
|
1181
|
+
xs: 'gap-1',
|
|
1182
|
+
sm: 'gap-1.5',
|
|
1183
|
+
md: 'gap-2',
|
|
1184
|
+
lg: 'gap-2.5',
|
|
1185
|
+
xl: 'gap-3',
|
|
1182
1186
|
}
|
|
1183
1187
|
}),
|
|
1184
1188
|
text: new SizeTheme({
|
|
1185
|
-
xs: 'text-xs
|
|
1186
|
-
sm: 'text-sm
|
|
1189
|
+
xs: 'text-xs',
|
|
1190
|
+
sm: 'text-sm',
|
|
1187
1191
|
md: 'text-base',
|
|
1188
|
-
lg: 'text-lg
|
|
1189
|
-
xl: 'text-xl
|
|
1192
|
+
lg: 'text-lg',
|
|
1193
|
+
xl: 'text-xl',
|
|
1190
1194
|
}),
|
|
1191
1195
|
shadow: new ShadowTheme(),
|
|
1192
1196
|
},
|
|
@@ -1229,36 +1233,36 @@ const defaultBadgeTheme = new ComponentTheme("span", "w-fit h-fit inline-flex tr
|
|
|
1229
1233
|
px: new PxTheme({
|
|
1230
1234
|
padding: {
|
|
1231
1235
|
xs: "px-2",
|
|
1232
|
-
sm: "px-
|
|
1233
|
-
md: "px-
|
|
1236
|
+
sm: "px-3",
|
|
1237
|
+
md: "px-4",
|
|
1234
1238
|
lg: "px-5",
|
|
1235
1239
|
xl: "px-6"
|
|
1236
1240
|
}
|
|
1237
1241
|
}),
|
|
1238
1242
|
py: new PyTheme({
|
|
1239
1243
|
padding: {
|
|
1240
|
-
xs:
|
|
1241
|
-
sm:
|
|
1242
|
-
md:
|
|
1243
|
-
lg:
|
|
1244
|
-
xl:
|
|
1244
|
+
xs: 'py-1',
|
|
1245
|
+
sm: 'py-1.5',
|
|
1246
|
+
md: 'py-2',
|
|
1247
|
+
lg: 'py-2.5',
|
|
1248
|
+
xl: 'py-3',
|
|
1245
1249
|
}
|
|
1246
1250
|
}),
|
|
1247
1251
|
gap: new GapTheme({
|
|
1248
1252
|
gap: {
|
|
1249
|
-
xs:
|
|
1250
|
-
sm:
|
|
1251
|
-
md:
|
|
1252
|
-
lg:
|
|
1253
|
-
xl:
|
|
1253
|
+
xs: 'gap-1',
|
|
1254
|
+
sm: 'gap-1.5',
|
|
1255
|
+
md: 'gap-2',
|
|
1256
|
+
lg: 'gap-2.5',
|
|
1257
|
+
xl: 'gap-3',
|
|
1254
1258
|
}
|
|
1255
1259
|
}),
|
|
1256
1260
|
text: new SizeTheme({
|
|
1257
|
-
xs: 'text-xs
|
|
1258
|
-
sm: 'text-sm
|
|
1261
|
+
xs: 'text-xs',
|
|
1262
|
+
sm: 'text-sm',
|
|
1259
1263
|
md: 'text-base',
|
|
1260
|
-
lg: 'text-lg
|
|
1261
|
-
xl: 'text-xl
|
|
1264
|
+
lg: 'text-lg',
|
|
1265
|
+
xl: 'text-xl',
|
|
1262
1266
|
}),
|
|
1263
1267
|
shadow: new ShadowTheme(),
|
|
1264
1268
|
},
|
|
@@ -1308,26 +1312,26 @@ const defaultChipTheme = new ComponentTheme("span", "w-fit h-fit inline-flex gap
|
|
|
1308
1312
|
padding: {
|
|
1309
1313
|
xs: 'px-2',
|
|
1310
1314
|
sm: 'px-2.5',
|
|
1311
|
-
md: 'px-3
|
|
1312
|
-
lg: 'px-5',
|
|
1313
|
-
xl: 'px-
|
|
1315
|
+
md: 'px-3',
|
|
1316
|
+
lg: 'px-3.5',
|
|
1317
|
+
xl: 'px-4',
|
|
1314
1318
|
}
|
|
1315
1319
|
}),
|
|
1316
1320
|
py: new PyTheme({
|
|
1317
1321
|
padding: {
|
|
1318
|
-
xs: 'py-
|
|
1319
|
-
sm: 'py-1
|
|
1320
|
-
md: 'py-
|
|
1321
|
-
lg: 'py-
|
|
1322
|
-
xl: 'py-
|
|
1322
|
+
xs: 'py-0.5',
|
|
1323
|
+
sm: 'py-1',
|
|
1324
|
+
md: 'py-1.5',
|
|
1325
|
+
lg: 'py-2',
|
|
1326
|
+
xl: 'py-2.5',
|
|
1323
1327
|
}
|
|
1324
1328
|
}),
|
|
1325
1329
|
text: new SizeTheme({
|
|
1326
1330
|
xs: 'text-xs',
|
|
1327
1331
|
sm: 'text-sm',
|
|
1328
|
-
md: 'text-
|
|
1329
|
-
lg: 'text-
|
|
1330
|
-
xl: 'text-
|
|
1332
|
+
md: 'text-base',
|
|
1333
|
+
lg: 'text-lg',
|
|
1334
|
+
xl: 'text-xl',
|
|
1331
1335
|
}),
|
|
1332
1336
|
gap: new GapTheme({
|
|
1333
1337
|
gap: {
|
|
@@ -1436,9 +1440,8 @@ class DirectionTheme extends BaseTheme {
|
|
|
1436
1440
|
});
|
|
1437
1441
|
}
|
|
1438
1442
|
getClasses(props, defaults) {
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
const reverse = pickKey(props, defaults, DIRECTION_REVERSE_KEYS);
|
|
1443
|
+
let direction = pickFirstTruthyKey(props, defaults, FLEX_DIRECTION_KEYS) || 'column';
|
|
1444
|
+
const reverse = pickFirstTruthyKey(props, defaults, DIRECTION_REVERSE_KEYS);
|
|
1442
1445
|
if (reverse) {
|
|
1443
1446
|
switch (direction) {
|
|
1444
1447
|
case "column":
|
|
@@ -1468,7 +1471,7 @@ class WrapTheme extends BaseTheme {
|
|
|
1468
1471
|
});
|
|
1469
1472
|
}
|
|
1470
1473
|
getClasses(props, defaults) {
|
|
1471
|
-
const key =
|
|
1474
|
+
const key = pickFirstTruthyKey(props, defaults, WRAP_KEYS);
|
|
1472
1475
|
return key ? [this[key]] : [];
|
|
1473
1476
|
}
|
|
1474
1477
|
}
|
|
@@ -1495,7 +1498,7 @@ class LayoutAppearanceTheme extends BaseTheme {
|
|
|
1495
1498
|
});
|
|
1496
1499
|
}
|
|
1497
1500
|
getClasses(props, defaults) {
|
|
1498
|
-
const pickedAppearanceKey =
|
|
1501
|
+
const pickedAppearanceKey = pickFirstTruthyKey(props, defaults, APPEARANCE_KEYS) || 'default';
|
|
1499
1502
|
const modesForAppearance = this[pickedAppearanceKey];
|
|
1500
1503
|
if (!modesForAppearance) {
|
|
1501
1504
|
return MODE_KEYS.map(() => '');
|
|
@@ -1543,7 +1546,7 @@ class BreakpointTheme extends BaseTheme {
|
|
|
1543
1546
|
});
|
|
1544
1547
|
}
|
|
1545
1548
|
getClasses(props, defaults) {
|
|
1546
|
-
const key =
|
|
1549
|
+
const key = pickFirstTruthyKey(props, defaults, BREAKPOINT_KEYS);
|
|
1547
1550
|
if (!key)
|
|
1548
1551
|
return [];
|
|
1549
1552
|
return [this[key] || ''];
|
|
@@ -1739,18 +1742,18 @@ const defaultSectionTheme = new ComponentTheme("div", "w-full flex flex-col", {
|
|
|
1739
1742
|
}),
|
|
1740
1743
|
py: new PyTheme({
|
|
1741
1744
|
padding: {
|
|
1742
|
-
xs: 'py-3',
|
|
1743
|
-
sm: 'py-
|
|
1744
|
-
md: 'py-
|
|
1745
|
+
xs: 'py-4 max-md:py-3',
|
|
1746
|
+
sm: 'py-8 max-md:py-6',
|
|
1747
|
+
md: 'py-12 max-md:py-6',
|
|
1745
1748
|
lg: 'py-16 max-lg:py-14 max-md:py-12',
|
|
1746
1749
|
xl: 'py-20 max-lg:py-16 max-md:py-12',
|
|
1747
1750
|
}
|
|
1748
1751
|
}),
|
|
1749
1752
|
gap: new GapTheme({
|
|
1750
1753
|
gap: {
|
|
1751
|
-
xs: 'gap-
|
|
1752
|
-
sm: 'gap-
|
|
1753
|
-
md: 'gap-
|
|
1754
|
+
xs: 'gap-4',
|
|
1755
|
+
sm: 'gap-6',
|
|
1756
|
+
md: 'gap-8',
|
|
1754
1757
|
lg: 'gap-12',
|
|
1755
1758
|
xl: 'gap-16',
|
|
1756
1759
|
}
|
|
@@ -1834,16 +1837,27 @@ const defaultTheme = {
|
|
|
1834
1837
|
list: listTheme,
|
|
1835
1838
|
};
|
|
1836
1839
|
const ThemeContext = createContext(defaultTheme);
|
|
1837
|
-
function ThemeProvider({ children, theme: themeObject = {}, themeOverride }) {
|
|
1840
|
+
function ThemeProvider({ children, theme: themeObject = {}, themeDefaults, themeOverride }) {
|
|
1838
1841
|
const mergedTheme = useMemo(() => {
|
|
1839
|
-
let
|
|
1842
|
+
let finalTheme = themeObject
|
|
1840
1843
|
? deepMerge(defaultTheme, themeObject)
|
|
1841
1844
|
: defaultTheme;
|
|
1842
1845
|
if (typeof themeOverride === 'function') {
|
|
1843
|
-
const themeToModify = deepClone(
|
|
1844
|
-
|
|
1846
|
+
const themeToModify = deepClone(finalTheme);
|
|
1847
|
+
finalTheme = themeOverride(themeToModify);
|
|
1848
|
+
}
|
|
1849
|
+
if (themeDefaults !== undefined) {
|
|
1850
|
+
for (const key in themeDefaults) {
|
|
1851
|
+
const componentKey = key;
|
|
1852
|
+
const componentTheme = finalTheme[componentKey];
|
|
1853
|
+
const themeDefault = themeDefaults[componentKey];
|
|
1854
|
+
if (themeDefault !== undefined) {
|
|
1855
|
+
finalTheme[componentKey].defaults =
|
|
1856
|
+
mergeDefaults(componentTheme.defaults, themeDefaults[componentKey]);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1845
1859
|
}
|
|
1846
|
-
return
|
|
1860
|
+
return finalTheme;
|
|
1847
1861
|
}, [themeObject, themeOverride]);
|
|
1848
1862
|
return (jsx(ThemeContext.Provider, { value: mergedTheme, children: children }));
|
|
1849
1863
|
}
|