@vaneui/ui 0.1.5 → 0.1.6

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/index.esm.js CHANGED
@@ -437,75 +437,6 @@ TextAlignTheme.defaultClasses = {
437
437
  textJustify: "text-justify",
438
438
  };
439
439
 
440
- const isObject = (item) => {
441
- return item !== null && typeof item === 'object' && !Array.isArray(item);
442
- };
443
- const deepMerge = (target, source) => {
444
- const output = Object.assign(Object.create(Object.getPrototypeOf(target)), target);
445
- for (const key in source) {
446
- if (Object.prototype.hasOwnProperty.call(source, key)) {
447
- const sourceValue = source[key];
448
- const targetValue = output[key];
449
- if (sourceValue === undefined) {
450
- continue;
451
- }
452
- // Special case: If the key is 'defaults', use the contextual mergeDefaults function.
453
- if (key === 'defaults' &&
454
- isObject(targetValue) &&
455
- isObject(sourceValue)) {
456
- output[key] = mergeDefaults(targetValue, sourceValue);
457
- }
458
- // For all other objects, use the standard recursive deep merge.
459
- else if (isObject(targetValue) && isObject(sourceValue)) {
460
- output[key] = deepMerge(targetValue, sourceValue);
461
- }
462
- // For non-object values, just assign the value from the source.
463
- else {
464
- output[key] = sourceValue;
465
- }
466
- }
467
- }
468
- return output;
469
- };
470
- const deepClone = (source) => {
471
- if (!isObject(source)) {
472
- return source;
473
- }
474
- const output = Object.assign(Object.create(Object.getPrototypeOf(source)), source);
475
- for (const key in output) {
476
- if (Object.prototype.hasOwnProperty.call(output, key)) {
477
- output[key] = deepClone(output[key]);
478
- }
479
- }
480
- return output;
481
- };
482
- const findGroup = (key) => EXCLUSIVE_KEY_GROUPS.find(group => group.includes(key));
483
- const mergeDefaults = (baseDefaults, overrideDefaults) => {
484
- const finalDefaults = { ...baseDefaults };
485
- // Iterate over the override keys to apply them.
486
- for (const key in overrideDefaults) {
487
- if (Object.prototype.hasOwnProperty.call(overrideDefaults, key)) {
488
- const overrideValue = overrideDefaults[key];
489
- // If the override is setting a key to true...
490
- if (overrideValue) {
491
- // Find the exclusive group this key belongs to (e.g., SIZE_KEYS).
492
- const group = findGroup(key);
493
- // If the key is part of an exclusive group...
494
- if (group) {
495
- // ...set all other keys in that group to false.
496
- group.forEach(groupKey => {
497
- if (groupKey !== key) {
498
- finalDefaults[groupKey] = false;
499
- }
500
- });
501
- }
502
- }
503
- finalDefaults[key] = overrideValue;
504
- }
505
- }
506
- return finalDefaults;
507
- };
508
-
509
440
  class DisplayTheme extends BaseTheme {
510
441
  constructor(initialConfig) {
511
442
  super();
@@ -3244,29 +3175,27 @@ const getDefaultConfig = () => {
3244
3175
  };
3245
3176
  const twMerge = /*#__PURE__*/createTailwindMerge(getDefaultConfig);
3246
3177
 
3178
+ const defaultLayoutTheme = {
3179
+ hide: new HideTheme(),
3180
+ items: new ItemsTheme(),
3181
+ justify: new JustifyTheme(),
3182
+ position: new PositionTheme(),
3183
+ display: new DisplayTheme()
3184
+ };
3185
+ const defaultTypographyTheme = {
3186
+ fontFamily: new FontFamilyTheme(),
3187
+ fontWeight: new FontWeightTheme(),
3188
+ fontStyle: new FontStyleTheme(),
3189
+ textDecoration: new TextDecorationTheme(),
3190
+ textTransform: new TextTransformTheme(),
3191
+ textAlign: new TextAlignTheme()
3192
+ };
3247
3193
  class ComponentTheme {
3248
3194
  constructor(tag, base, subThemes, defaults = {}) {
3249
3195
  this.tag = tag;
3250
3196
  this.base = base;
3251
3197
  this.defaults = defaults;
3252
- const defaultInternalThemes = {
3253
- layout: {
3254
- hide: new HideTheme(),
3255
- items: new ItemsTheme(),
3256
- justify: new JustifyTheme(),
3257
- position: new PositionTheme(),
3258
- display: new DisplayTheme()
3259
- },
3260
- typography: {
3261
- fontFamily: new FontFamilyTheme(),
3262
- fontWeight: new FontWeightTheme(),
3263
- fontStyle: new FontStyleTheme(),
3264
- textDecoration: new TextDecorationTheme(),
3265
- textTransform: new TextTransformTheme(),
3266
- textAlign: new TextAlignTheme()
3267
- }
3268
- };
3269
- this.themes = deepMerge(defaultInternalThemes, subThemes);
3198
+ this.themes = subThemes;
3270
3199
  }
3271
3200
  getClasses(props, defaults = this.defaults) {
3272
3201
  const user = props;
@@ -3379,57 +3308,6 @@ RadiusTheme.defaultClasses = {
3379
3308
  }
3380
3309
  };
3381
3310
 
3382
- class ShadowTheme extends BaseTheme {
3383
- constructor(initial) {
3384
- super();
3385
- SHADOW_KEYS.forEach((key) => {
3386
- var _a;
3387
- this[key] = (_a = initial === null || initial === void 0 ? void 0 : initial[key]) !== null && _a !== void 0 ? _a : ShadowTheme.defaultClasses[key];
3388
- });
3389
- }
3390
- getClasses(props, defaults) {
3391
- const size = pickFirstTruthyKey(props, defaults, SIZE_KEYS) || 'md';
3392
- const key = pickFirstTruthyKey(props, defaults, SHADOW_KEYS);
3393
- if (key === undefined) {
3394
- return [];
3395
- }
3396
- const isModeStringMap = MODE_KEYS.every(m => typeof this[key][m] === "string");
3397
- return MODE_KEYS.map(mode => isModeStringMap
3398
- ? this[key][mode]
3399
- : this[key][mode][size]);
3400
- }
3401
- }
3402
- ShadowTheme.defaultClasses = {
3403
- shadow: {
3404
- base: {
3405
- xs: "shadow-2xs",
3406
- sm: "shadow-xs",
3407
- md: "shadow-sm",
3408
- lg: "shadow-md",
3409
- xl: "shadow-lg"
3410
- },
3411
- hover: {
3412
- xs: "hover:shadow-xs",
3413
- sm: "hover:shadow-sm",
3414
- md: "hover:shadow-md",
3415
- lg: "hover:shadow-lg",
3416
- xl: "hover:shadow-xl"
3417
- },
3418
- active: {
3419
- xs: "active:shadow-xs",
3420
- sm: "active:shadow-sm",
3421
- md: "active:shadow-md",
3422
- lg: "active:shadow-lg",
3423
- xl: "active:shadow-xl"
3424
- },
3425
- },
3426
- noShadow: {
3427
- base: "shadow-none",
3428
- hover: "hover:shadow-none",
3429
- active: "active:shadow-none",
3430
- }
3431
- };
3432
-
3433
3311
  class BorderTheme extends BaseTheme {
3434
3312
  constructor(initial) {
3435
3313
  super();
@@ -3766,6 +3644,35 @@ const filledRingAppearanceClasses = {
3766
3644
  transparent: "ring-transparent",
3767
3645
  };
3768
3646
 
3647
+ class ShadowAppearanceTheme extends BaseTheme {
3648
+ constructor(initial) {
3649
+ super();
3650
+ TEXT_APPEARANCE_KEYS.forEach((key) => {
3651
+ var _a;
3652
+ this[key] = (_a = initial === null || initial === void 0 ? void 0 : initial[key]) !== null && _a !== void 0 ? _a : ShadowAppearanceTheme.defaultShadow;
3653
+ });
3654
+ }
3655
+ getClasses(props, defaults) {
3656
+ const appearance = pickFirstTruthyKey(props, defaults, TEXT_APPEARANCE_KEYS) || 'default';
3657
+ const size = pickFirstTruthyKey(props, defaults, SIZE_KEYS) || 'md';
3658
+ const key = pickFirstTruthyKey(props, defaults, SHADOW_KEYS);
3659
+ if (key === undefined || key === 'noShadow') {
3660
+ return [];
3661
+ }
3662
+ return MODE_KEYS.map(mode => { var _a, _b, _c; return (_c = (_b = (_a = this[appearance]) === null || _a === void 0 ? void 0 : _a[size]) === null || _b === void 0 ? void 0 : _b[mode]) !== null && _c !== void 0 ? _c : ""; });
3663
+ }
3664
+ static createTheme(src = {}) {
3665
+ return new ShadowAppearanceTheme(src);
3666
+ }
3667
+ }
3668
+ ShadowAppearanceTheme.defaultShadow = {
3669
+ xs: { base: "shadow-2xs", hover: "hover:shadow-xs", active: "" },
3670
+ sm: { base: "shadow-xs", hover: "hover:shadow-sm", active: "" },
3671
+ md: { base: "shadow-sm", hover: "hover:shadow-md", active: "" },
3672
+ lg: { base: "shadow-md", hover: "hover:shadow-lg", active: "" },
3673
+ xl: { base: "shadow-lg", hover: "hover:shadow-xl", active: "" }
3674
+ };
3675
+
3769
3676
  class GenericVariantTheme extends BaseTheme {
3770
3677
  constructor(variantInstances) {
3771
3678
  super();
@@ -3793,6 +3700,13 @@ class GenericVariantTheme extends BaseTheme {
3793
3700
  })
3794
3701
  });
3795
3702
  }
3703
+ static createUIElementShadowTheme() {
3704
+ //transparent UI elements won't have a shadow
3705
+ return new GenericVariantTheme({
3706
+ outline: ShadowAppearanceTheme.createTheme({ transparent: undefined, link: undefined }),
3707
+ filled: ShadowAppearanceTheme.createTheme({ transparent: undefined, link: undefined })
3708
+ });
3709
+ }
3796
3710
  static createBorderAppearanceTheme() {
3797
3711
  return new GenericVariantTheme({
3798
3712
  outline: TextAppearanceTheme.createTheme({ base: borderAppearanceClasses }),
@@ -3867,15 +3781,16 @@ const defaultButtonTheme = new ComponentTheme("button", "w-fit h-fit cursor-poin
3867
3781
  lg: 'text-lg',
3868
3782
  xl: 'text-xl',
3869
3783
  }),
3870
- shadow: new ShadowTheme(),
3871
3784
  },
3872
3785
  appearance: {
3873
3786
  background: GenericVariantTheme.createBgAppearanceTheme(),
3874
3787
  text: GenericVariantTheme.createUIElementTextTheme(),
3875
3788
  border: GenericVariantTheme.createBorderAppearanceTheme(),
3876
3789
  ring: GenericVariantTheme.createRingAppearanceTheme(),
3790
+ shadow: GenericVariantTheme.createUIElementShadowTheme()
3877
3791
  },
3878
3792
  layout: {
3793
+ ...defaultLayoutTheme,
3879
3794
  border: new BorderTheme(),
3880
3795
  ring: new RingTheme(),
3881
3796
  radius: new RadiusTheme({
@@ -3888,6 +3803,7 @@ const defaultButtonTheme = new ComponentTheme("button", "w-fit h-fit cursor-poin
3888
3803
  }
3889
3804
  }),
3890
3805
  },
3806
+ typography: defaultTypographyTheme,
3891
3807
  }, {
3892
3808
  md: true,
3893
3809
  inlineFlex: true,
@@ -3941,16 +3857,17 @@ const defaultBadgeTheme = new ComponentTheme("span", "w-fit h-fit transition-all
3941
3857
  md: 'text-base',
3942
3858
  lg: 'text-lg',
3943
3859
  xl: 'text-xl',
3944
- }),
3945
- shadow: new ShadowTheme(),
3860
+ })
3946
3861
  },
3947
3862
  appearance: {
3948
3863
  background: GenericVariantTheme.createSimpleBgAppearanceTheme(),
3949
3864
  text: GenericVariantTheme.createUIElementTextTheme(),
3950
3865
  border: GenericVariantTheme.createBorderAppearanceTheme(),
3951
3866
  ring: GenericVariantTheme.createRingAppearanceTheme(),
3867
+ shadow: GenericVariantTheme.createUIElementShadowTheme()
3952
3868
  },
3953
3869
  layout: {
3870
+ ...defaultLayoutTheme,
3954
3871
  border: new BorderTheme(),
3955
3872
  ring: new RingTheme(),
3956
3873
  radius: new RadiusTheme({
@@ -3963,6 +3880,7 @@ const defaultBadgeTheme = new ComponentTheme("span", "w-fit h-fit transition-all
3963
3880
  }
3964
3881
  }),
3965
3882
  },
3883
+ typography: defaultTypographyTheme,
3966
3884
  }, {
3967
3885
  md: true,
3968
3886
  inlineFlex: true,
@@ -4013,16 +3931,17 @@ const defaultChipTheme = new ComponentTheme("span", "w-fit h-fit transition-all
4013
3931
  lg: 'gap-2.5',
4014
3932
  xl: 'gap-3',
4015
3933
  }
4016
- }),
4017
- shadow: new ShadowTheme(),
3934
+ })
4018
3935
  },
4019
3936
  appearance: {
4020
3937
  background: GenericVariantTheme.createSimpleBgAppearanceTheme(),
4021
3938
  text: GenericVariantTheme.createUIElementTextTheme(),
4022
3939
  border: GenericVariantTheme.createBorderAppearanceTheme(),
4023
3940
  ring: GenericVariantTheme.createRingAppearanceTheme(),
3941
+ shadow: GenericVariantTheme.createUIElementShadowTheme()
4024
3942
  },
4025
3943
  layout: {
3944
+ ...defaultLayoutTheme,
4026
3945
  radius: new RadiusTheme({
4027
3946
  rounded: {
4028
3947
  xs: 'rounded-sm',
@@ -4035,6 +3954,7 @@ const defaultChipTheme = new ComponentTheme("span", "w-fit h-fit transition-all
4035
3954
  border: new BorderTheme(),
4036
3955
  ring: new RingTheme(),
4037
3956
  },
3957
+ typography: defaultTypographyTheme,
4038
3958
  }, {
4039
3959
  md: true,
4040
3960
  inlineFlex: true,
@@ -4050,6 +3970,75 @@ const defaultChipTheme = new ComponentTheme("span", "w-fit h-fit transition-all
4050
3970
  ring: true,
4051
3971
  });
4052
3972
 
3973
+ const isObject = (item) => {
3974
+ return item !== null && typeof item === 'object' && !Array.isArray(item);
3975
+ };
3976
+ const deepMerge = (target, source) => {
3977
+ const output = Object.assign(Object.create(Object.getPrototypeOf(target)), target);
3978
+ for (const key in source) {
3979
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
3980
+ const sourceValue = source[key];
3981
+ const targetValue = output[key];
3982
+ if (sourceValue === undefined) {
3983
+ continue;
3984
+ }
3985
+ // Special case: If the key is 'defaults', use the contextual mergeDefaults function.
3986
+ if (key === 'defaults' &&
3987
+ isObject(targetValue) &&
3988
+ isObject(sourceValue)) {
3989
+ output[key] = mergeDefaults(targetValue, sourceValue);
3990
+ }
3991
+ // For all other objects, use the standard recursive deep merge.
3992
+ else if (isObject(targetValue) && isObject(sourceValue)) {
3993
+ output[key] = deepMerge(targetValue, sourceValue);
3994
+ }
3995
+ // For non-object values, just assign the value from the source.
3996
+ else {
3997
+ output[key] = sourceValue;
3998
+ }
3999
+ }
4000
+ }
4001
+ return output;
4002
+ };
4003
+ const deepClone = (source) => {
4004
+ if (!isObject(source)) {
4005
+ return source;
4006
+ }
4007
+ const output = Object.assign(Object.create(Object.getPrototypeOf(source)), source);
4008
+ for (const key in output) {
4009
+ if (Object.prototype.hasOwnProperty.call(output, key)) {
4010
+ output[key] = deepClone(output[key]);
4011
+ }
4012
+ }
4013
+ return output;
4014
+ };
4015
+ const findGroup = (key) => EXCLUSIVE_KEY_GROUPS.find(group => group.includes(key));
4016
+ const mergeDefaults = (baseDefaults, overrideDefaults) => {
4017
+ const finalDefaults = { ...baseDefaults };
4018
+ // Iterate over the override keys to apply them.
4019
+ for (const key in overrideDefaults) {
4020
+ if (Object.prototype.hasOwnProperty.call(overrideDefaults, key)) {
4021
+ const overrideValue = overrideDefaults[key];
4022
+ // If the override is setting a key to true...
4023
+ if (overrideValue) {
4024
+ // Find the exclusive group this key belongs to (e.g., SIZE_KEYS).
4025
+ const group = findGroup(key);
4026
+ // If the key is part of an exclusive group...
4027
+ if (group) {
4028
+ // ...set all other keys in that group to false.
4029
+ group.forEach(groupKey => {
4030
+ if (groupKey !== key) {
4031
+ finalDefaults[groupKey] = false;
4032
+ }
4033
+ });
4034
+ }
4035
+ }
4036
+ finalDefaults[key] = overrideValue;
4037
+ }
4038
+ }
4039
+ return finalDefaults;
4040
+ };
4041
+
4053
4042
  const typographyThemeDefaults = {
4054
4043
  md: true,
4055
4044
  default: true,
@@ -4063,7 +4052,8 @@ const createTypographyComponentTheme = (tag, base = "text-balance", textSizeMap
4063
4052
  },
4064
4053
  appearance: {
4065
4054
  text: TextAppearanceTheme.createTheme({ base: textAppearanceClasses }),
4066
- }
4055
+ },
4056
+ typography: defaultTypographyTheme,
4067
4057
  }, defaults);
4068
4058
  };
4069
4059
  // Page title specific theme
@@ -4200,30 +4190,30 @@ BreakpointTheme.defaultClasses = {
4200
4190
  xlCol: "max-xl:flex-col"
4201
4191
  };
4202
4192
 
4203
- const defaultCardTheme = new ComponentTheme("div", "overflow-hidden", {
4193
+ const defaultCardTheme = new ComponentTheme("div", "", {
4204
4194
  size: {
4205
4195
  px: new PxTheme({
4206
4196
  padding: {
4207
- xs: 'px-3',
4208
- sm: 'px-4',
4209
- md: 'px-5',
4210
- lg: 'px-6',
4211
- xl: 'px-8',
4197
+ xs: "px-2",
4198
+ sm: "px-3 max-lg:px-2",
4199
+ md: "px-4 max-lg:px-3",
4200
+ lg: "px-5 max-lg:px-4 max-md:px-3",
4201
+ xl: "px-6 max-lg:px-5 max-md:px-4"
4212
4202
  }
4213
4203
  }),
4214
4204
  py: new PyTheme({
4215
4205
  padding: {
4216
- xs: 'py-2',
4217
- sm: 'py-3',
4218
- md: 'py-4',
4219
- lg: 'py-5',
4220
- xl: 'py-6',
4206
+ xs: "py-2",
4207
+ sm: "py-3 max-lg:py-2",
4208
+ md: "py-4 max-lg:py-3",
4209
+ lg: "py-5 max-lg:py-4 max-md:py-3",
4210
+ xl: "py-6 max-lg:py-5 max-md:py-4"
4221
4211
  }
4222
4212
  }),
4223
4213
  gap: new GapTheme({ gap: commonGaps }),
4224
- shadow: new ShadowTheme(),
4225
4214
  },
4226
4215
  layout: {
4216
+ ...defaultLayoutTheme,
4227
4217
  border: new BorderTheme(),
4228
4218
  ring: new RingTheme(),
4229
4219
  radius: new RadiusTheme({
@@ -4238,6 +4228,7 @@ const defaultCardTheme = new ComponentTheme("div", "overflow-hidden", {
4238
4228
  wrap: new WrapTheme(),
4239
4229
  direction: new DirectionTheme(),
4240
4230
  breakpoint: new BreakpointTheme(),
4231
+ shadow: ShadowAppearanceTheme.createTheme(),
4241
4232
  },
4242
4233
  appearance: {
4243
4234
  background: new BgAppearanceTheme(),
@@ -4263,6 +4254,7 @@ const defaultRowTheme = new ComponentTheme("div", "flex-row", {
4263
4254
  breakpoint: new BreakpointTheme(),
4264
4255
  },
4265
4256
  layout: {
4257
+ ...defaultLayoutTheme,
4266
4258
  wrap: new WrapTheme(),
4267
4259
  },
4268
4260
  }, {
@@ -4304,6 +4296,7 @@ const defaultContainerTheme = new ComponentTheme("div", "flex-col mx-auto w-full
4304
4296
  }),
4305
4297
  },
4306
4298
  layout: {
4299
+ ...defaultLayoutTheme,
4307
4300
  border: new BorderTheme(),
4308
4301
  ring: new RingTheme(),
4309
4302
  wrap: new WrapTheme(),
@@ -4339,6 +4332,7 @@ const defaultColTheme = new ComponentTheme("div", "flex-col", {
4339
4332
  gap: new GapTheme({ gap: commonGaps }),
4340
4333
  },
4341
4334
  layout: {
4335
+ ...defaultLayoutTheme,
4342
4336
  wrap: new WrapTheme(),
4343
4337
  direction: new DirectionTheme(),
4344
4338
  },
@@ -4374,6 +4368,7 @@ const defaultStackTheme = new ComponentTheme("div", "", {
4374
4368
  }),
4375
4369
  },
4376
4370
  layout: {
4371
+ ...defaultLayoutTheme,
4377
4372
  wrap: new WrapTheme(),
4378
4373
  direction: new DirectionTheme(),
4379
4374
  },
@@ -4416,15 +4411,16 @@ const defaultSectionTheme = new ComponentTheme("div", "w-full flex-col", {
4416
4411
  xl: 'gap-16',
4417
4412
  }
4418
4413
  }),
4419
- shadow: new ShadowTheme(),
4420
4414
  },
4421
4415
  appearance: {
4422
4416
  background: new BgAppearanceTheme(),
4423
4417
  text: TextAppearanceTheme.createTheme({ base: textAppearanceClasses }),
4424
4418
  border: TextAppearanceTheme.createTheme({ base: borderAppearanceClasses }),
4425
4419
  ring: TextAppearanceTheme.createTheme({ base: ringAppearanceClasses }),
4420
+ shadow: ShadowAppearanceTheme.createTheme(),
4426
4421
  },
4427
4422
  layout: {
4423
+ ...defaultLayoutTheme,
4428
4424
  wrap: new WrapTheme(),
4429
4425
  direction: new DirectionTheme(),
4430
4426
  border: new BorderTheme(),