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