my-animated-components 1.3.7 → 1.3.8

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.d.ts CHANGED
@@ -19,6 +19,7 @@ interface SizeProps {
19
19
  }
20
20
 
21
21
  type Color$d = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info';
22
+ type MotionVariantKey = keyof typeof motionVariants;
22
23
  interface ButtonProps extends BaseProps, SizeProps, HTMLMotionProps<'button'> {
23
24
  variant?: 'solid' | 'outline' | 'ghost';
24
25
  color?: Color$d;
@@ -26,10 +27,10 @@ interface ButtonProps extends BaseProps, SizeProps, HTMLMotionProps<'button'> {
26
27
  * Predefined motion variant name from motionVariants.
27
28
  * This will apply the corresponding animation configuration.
28
29
  */
29
- motionVariant?: keyof typeof motionVariants;
30
- whileHoverAnimation?: keyof typeof motionVariants;
31
- whileTapAnimation?: keyof typeof motionVariants;
32
- whileFocusAnimation?: keyof typeof motionVariants;
30
+ motionVariant?: MotionVariantKey;
31
+ whileHoverAnimation?: MotionVariantKey;
32
+ whileTapAnimation?: MotionVariantKey;
33
+ whileFocusAnimation?: MotionVariantKey;
33
34
  }
34
35
  declare const Button: React$1.FC<ButtonProps>;
35
36
 
package/dist/index.js CHANGED
@@ -3,6 +3,10 @@
3
3
  var React = require('react');
4
4
  var framerMotion = require('framer-motion');
5
5
 
6
+ function getVariantVisible(variantKey) {
7
+ const variant = motionVariants[variantKey]?.visible;
8
+ return typeof variant === 'function' ? undefined : variant;
9
+ }
6
10
  const motionVariants = {
7
11
  null: {},
8
12
  fadeIn: {
@@ -524,9 +528,15 @@ whileHoverAnimation, whileTapAnimation, whileFocusAnimation, ...rest }) => {
524
528
  lg: 'px-4 py-2 text-lg',
525
529
  xl: 'px-6 py-3 text-xl',
526
530
  };
527
- const computedWhileHover = whileHoverAnimation || whileHover;
528
- const computedWhileTap = whileTapAnimation || whileTap;
529
- const computedWhileFocus = whileFocusAnimation || whileFocus;
531
+ const computedWhileHover = whileHoverAnimation
532
+ ? getVariantVisible(whileHoverAnimation)
533
+ : whileHover;
534
+ const computedWhileTap = whileTapAnimation
535
+ ? getVariantVisible(whileTapAnimation)
536
+ : whileTap;
537
+ const computedWhileFocus = whileFocusAnimation
538
+ ? getVariantVisible(whileFocusAnimation)
539
+ : whileFocus;
530
540
  return (React.createElement(framerMotion.motion.button, { className: `${baseClasses} ${colorClasses[color][variant]} ${sizeClasses[size]} ${className}`, onClick: onClick, disabled: disabled, variants: motionVariants[motionVariant], initial: "hidden", animate: "visible", whileHover: computedWhileHover, whileTap: computedWhileTap, whileFocus: computedWhileFocus, ...rest }, children));
531
541
  };
532
542
 
@@ -571,9 +581,15 @@ const IconButton = ({ className = '', color = 'primary', size = 'md', icon, onCl
571
581
  lg: 'p-2.5',
572
582
  xl: 'p-3',
573
583
  };
574
- const computedWhileHover = whileHoverAnimation || whileHover;
575
- const computedWhileTap = whileTapAnimation || whileTap;
576
- const computedWhileFocus = whileFocusAnimation || whileFocus;
584
+ const computedWhileHover = whileHoverAnimation
585
+ ? getVariantVisible(whileHoverAnimation)
586
+ : whileHover;
587
+ const computedWhileTap = whileTapAnimation
588
+ ? getVariantVisible(whileTapAnimation)
589
+ : whileTap;
590
+ const computedWhileFocus = whileFocusAnimation
591
+ ? getVariantVisible(whileFocusAnimation)
592
+ : whileFocus;
577
593
  return (React.createElement(framerMotion.motion.button, { className: `${baseClasses} ${colorClasses[color][variant]} ${sizeClasses[size]} ${className}`, onClick: onClick, disabled: disabled, variants: motionVariants[motionVariant], initial: "hidden", animate: "visible", whileHover: computedWhileHover, whileTap: computedWhileTap, whileFocus: computedWhileFocus, ...rest }, icon));
578
594
  };
579
595
 
@@ -1057,9 +1073,15 @@ const Pagination = ({ className = '', currentPage, totalPages, onPageChange, col
1057
1073
  warning: 'text-yellow-600 bg-yellow-50 hover:bg-yellow-100 hover:text-yellow-700 dark:bg-yellow-800 dark:hover:bg-yellow-700',
1058
1074
  info: 'text-blue-400 bg-blue-50 hover:bg-blue-100 hover:text-blue-500 dark:bg-blue-800 dark:hover:bg-blue-700',
1059
1075
  };
1060
- const computedWhileHover = whileHoverAnimation || whileHover;
1061
- const computedWhileTap = whileTapAnimation || whileTap;
1062
- const computedWhileFocus = whileFocusAnimation || whileFocus;
1076
+ const computedWhileHover = whileHoverAnimation
1077
+ ? getVariantVisible(whileHoverAnimation)
1078
+ : whileHover;
1079
+ const computedWhileTap = whileTapAnimation
1080
+ ? getVariantVisible(whileTapAnimation)
1081
+ : whileTap;
1082
+ const computedWhileFocus = whileFocusAnimation
1083
+ ? getVariantVisible(whileFocusAnimation)
1084
+ : whileFocus;
1063
1085
  return (React.createElement(framerMotion.motion.nav, { className: `flex justify-center ${className}`, variants: motionVariants[motionVariant], initial: "hidden", animate: "visible", ...rest },
1064
1086
  React.createElement("div", { className: "w-full overflow-x-auto" },
1065
1087
  React.createElement("ul", { className: "flex items-center -space-x-px h-10" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "my-animated-components",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/index.js",