aliveicon 1.0.21 → 1.0.23

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/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { useAnimation, motion } from 'framer-motion';
3
- import { useRef, useCallback, useEffect } from 'react';
3
+ import { useRef, useCallback, useEffect, forwardRef, useImperativeHandle } from 'react';
4
4
 
5
5
  function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
6
6
 
@@ -2959,7 +2959,7 @@ const getDefaultConfig = () => {
2959
2959
  };
2960
2960
  const twMerge = /*#__PURE__*/createTailwindMerge(getDefaultConfig);
2961
2961
 
2962
- function cn(...inputs) {
2962
+ function cn$5(...inputs) {
2963
2963
  return twMerge(clsx(inputs));
2964
2964
  }
2965
2965
  const squareVariants = {
@@ -2974,7 +2974,7 @@ const squareVariants = {
2974
2974
  transition: { duration: 0.6, ease: 'easeInOut' },
2975
2975
  },
2976
2976
  };
2977
- const pathVariants = {
2977
+ const pathVariants$2 = {
2978
2978
  normal: {
2979
2979
  opacity: 1,
2980
2980
  pathLength: 1,
@@ -3027,13 +3027,411 @@ function SquareActivity({ size = 28, className, style, autoAnimateOnLoad = false
3027
3027
  triggerAnimation();
3028
3028
  onClick?.(e);
3029
3029
  };
3030
- return (jsx("div", { className: cn('rounded-md', className), style: {
3030
+ return (jsx("div", { className: cn$5('rounded-md', className), style: {
3031
+ width: size,
3032
+ height: size,
3033
+ display: 'inline-block',
3034
+ ...style,
3035
+ }, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onClick: handleClick, ...props, children: jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", width: "100%", height: "100%", children: [jsx(motion.rect, { width: "18", height: "18", x: "3", y: "3", rx: "2", variants: squareVariants, animate: controls, initial: "normal" }), jsx(motion.path, { d: "M17 12h-2l-2 5-2-10-2 5H7", variants: pathVariants$2, animate: controls, initial: "normal", style: { strokeDasharray: 1 } })] }) }));
3036
+ }
3037
+
3038
+ function cn$4(...inputs) {
3039
+ return twMerge(clsx(inputs));
3040
+ }
3041
+ const bounceVariant$1 = {
3042
+ normal: {
3043
+ scale: 1,
3044
+ transition: {
3045
+ type: 'spring',
3046
+ stiffness: 200,
3047
+ damping: 15,
3048
+ },
3049
+ },
3050
+ animate: {
3051
+ scale: 1.2,
3052
+ transition: {
3053
+ type: 'spring',
3054
+ stiffness: 300,
3055
+ damping: 10,
3056
+ },
3057
+ },
3058
+ };
3059
+ const lineVariants$1 = {
3060
+ normal: {
3061
+ opacity: 1,
3062
+ pathLength: 1,
3063
+ pathOffset: 0,
3064
+ transition: {
3065
+ duration: 0.4,
3066
+ opacity: { duration: 0.1 },
3067
+ },
3068
+ },
3069
+ animate: {
3070
+ opacity: [0, 1],
3071
+ pathLength: [0, 1],
3072
+ pathOffset: [1, 0],
3073
+ transition: {
3074
+ duration: 0.6,
3075
+ ease: 'easeInOut',
3076
+ opacity: { duration: 0.1 },
3077
+ },
3078
+ },
3079
+ };
3080
+ const bouncePathVariants$1 = {
3081
+ hidden: {
3082
+ pathLength: 0,
3083
+ opacity: 0,
3084
+ },
3085
+ visible: (i) => ({
3086
+ pathLength: 1,
3087
+ opacity: 1,
3088
+ transition: {
3089
+ pathLength: { delay: i * 0.1, duration: 0.4, ease: 'easeInOut' },
3090
+ opacity: { delay: i * 0.1, duration: 0.2 },
3091
+ },
3092
+ }),
3093
+ };
3094
+ function ArrowDown({ size = 28, className, style, autoAnimateOnLoad = false, hoverable = true, loopOnHover = false, animateOnClick = false, isBounce = false, onMouseEnter, onMouseLeave, onClick, ...props }) {
3095
+ const controls = useAnimation();
3096
+ const loopRef = useRef(loopOnHover);
3097
+ const triggerAnimation = useCallback(async () => {
3098
+ await controls.start('animate');
3099
+ await controls.start('normal');
3100
+ if (loopRef.current)
3101
+ triggerAnimation();
3102
+ }, [controls]);
3103
+ useEffect(() => {
3104
+ loopRef.current = loopOnHover;
3105
+ }, [loopOnHover]);
3106
+ useEffect(() => {
3107
+ if (autoAnimateOnLoad)
3108
+ triggerAnimation();
3109
+ }, [autoAnimateOnLoad, triggerAnimation]);
3110
+ const handleMouseEnter = (e) => {
3111
+ if (hoverable)
3112
+ triggerAnimation();
3113
+ onMouseEnter?.(e);
3114
+ };
3115
+ const handleMouseLeave = (e) => {
3116
+ if (hoverable)
3117
+ controls.start('normal');
3118
+ onMouseLeave?.(e);
3119
+ };
3120
+ const handleClick = (e) => {
3121
+ if (animateOnClick)
3122
+ triggerAnimation();
3123
+ onClick?.(e);
3124
+ };
3125
+ const paths = [
3126
+ "M3.5 13h6",
3127
+ "m2 16 4.5-9 4.5 9",
3128
+ "M18 7v9",
3129
+ "m14 12 4 4 4-4",
3130
+ ];
3131
+ return (jsx("div", { className: cn$4('inline-block', className), style: {
3132
+ width: size,
3133
+ height: size,
3134
+ ...style,
3135
+ }, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onClick: handleClick, ...props, children: jsx(motion.svg, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", width: "100%", height: "100%", variants: isBounce ? bounceVariant$1 : undefined, animate: isBounce ? controls : undefined, initial: isBounce ? 'normal' : undefined, children: paths.map((d, i) => (jsx(motion.path, { d: d, variants: isBounce ? bouncePathVariants$1 : lineVariants$1, initial: isBounce ? 'hidden' : 'normal', animate: isBounce ? 'visible' : controls, custom: i }, i))) }) }));
3136
+ }
3137
+
3138
+ function cn$3(...inputs) {
3139
+ return twMerge(clsx(inputs));
3140
+ }
3141
+ const bounceVariant = {
3142
+ normal: {
3143
+ scale: 1,
3144
+ transition: {
3145
+ type: 'spring',
3146
+ stiffness: 200,
3147
+ damping: 15,
3148
+ },
3149
+ },
3150
+ animate: {
3151
+ scale: 1.2,
3152
+ transition: {
3153
+ type: 'spring',
3154
+ stiffness: 300,
3155
+ damping: 10,
3156
+ },
3157
+ },
3158
+ };
3159
+ const lineVariants = {
3160
+ normal: {
3161
+ opacity: 1,
3162
+ pathLength: 1,
3163
+ pathOffset: 0,
3164
+ transition: {
3165
+ duration: 0.4,
3166
+ opacity: { duration: 0.1 },
3167
+ },
3168
+ },
3169
+ animate: {
3170
+ opacity: [0, 1],
3171
+ pathLength: [0, 1],
3172
+ pathOffset: [1, 0],
3173
+ transition: {
3174
+ duration: 0.6,
3175
+ ease: 'easeInOut',
3176
+ opacity: { duration: 0.1 },
3177
+ },
3178
+ },
3179
+ };
3180
+ const bouncePathVariants = {
3181
+ hidden: {
3182
+ pathLength: 0,
3183
+ opacity: 0,
3184
+ },
3185
+ visible: (i) => ({
3186
+ pathLength: 1,
3187
+ opacity: 1,
3188
+ transition: {
3189
+ pathLength: { delay: i * 0.1, duration: 0.4, ease: 'easeInOut' },
3190
+ opacity: { delay: i * 0.1, duration: 0.2 },
3191
+ },
3192
+ }),
3193
+ };
3194
+ function ArrowUp({ size = 28, className, style, autoAnimateOnLoad = false, hoverable = true, loopOnHover = false, animateOnClick = false, isBounce = false, onMouseEnter, onMouseLeave, onClick, ...props }) {
3195
+ const controls = useAnimation();
3196
+ const loopRef = useRef(loopOnHover);
3197
+ const triggerAnimation = useCallback(async () => {
3198
+ await controls.start('animate');
3199
+ await controls.start('normal');
3200
+ if (loopRef.current)
3201
+ triggerAnimation();
3202
+ }, [controls]);
3203
+ useEffect(() => {
3204
+ loopRef.current = loopOnHover;
3205
+ }, [loopOnHover]);
3206
+ useEffect(() => {
3207
+ if (autoAnimateOnLoad)
3208
+ triggerAnimation();
3209
+ }, [autoAnimateOnLoad, triggerAnimation]);
3210
+ const handleMouseEnter = (e) => {
3211
+ if (hoverable)
3212
+ triggerAnimation();
3213
+ onMouseEnter?.(e);
3214
+ };
3215
+ const handleMouseLeave = (e) => {
3216
+ if (hoverable)
3217
+ controls.start('normal');
3218
+ onMouseLeave?.(e);
3219
+ };
3220
+ const handleClick = (e) => {
3221
+ if (animateOnClick)
3222
+ triggerAnimation();
3223
+ onClick?.(e);
3224
+ };
3225
+ const paths = [
3226
+ "M3.5 13h6", // horizontal part of the "A"
3227
+ "m2 16 4.5-9 4.5 9", // the "A" structure stays same
3228
+ "M18 16V7", // arrow line, now reversed (was 7→16, now 16→7)
3229
+ "m22 12-4-4-4 4", // arrow head pointing upward
3230
+ ];
3231
+ return (jsx("div", { className: cn$3('inline-block', className), style: {
3232
+ width: size,
3233
+ height: size,
3234
+ ...style,
3235
+ }, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onClick: handleClick, ...props, children: jsx(motion.svg, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", width: "100%", height: "100%", variants: isBounce ? bounceVariant : undefined, animate: isBounce ? controls : undefined, initial: isBounce ? 'normal' : undefined, children: paths.map((d, i) => (jsx(motion.path, { d: d, variants: isBounce ? bouncePathVariants : lineVariants, initial: isBounce ? 'hidden' : 'normal', animate: isBounce ? 'visible' : controls, custom: i }, i))) }) }));
3236
+ }
3237
+
3238
+ function cn$2(...inputs) {
3239
+ return twMerge(clsx(inputs));
3240
+ }
3241
+ const circleVariants = {
3242
+ normal: {
3243
+ scale: 1,
3244
+ opacity: 1,
3245
+ transition: { duration: 0.4 },
3246
+ },
3247
+ animate: {
3248
+ scale: [1, 1.2, 1],
3249
+ opacity: [1, 0.8, 1],
3250
+ transition: {
3251
+ duration: 0.6,
3252
+ times: [0, 0.5, 1],
3253
+ ease: 'easeInOut'
3254
+ },
3255
+ },
3256
+ };
3257
+ const pathVariants$1 = {
3258
+ normal: {
3259
+ opacity: 1,
3260
+ pathLength: 1,
3261
+ pathOffset: 0,
3262
+ transition: {
3263
+ duration: 0.4,
3264
+ opacity: { duration: 0.1 },
3265
+ },
3266
+ },
3267
+ animate: {
3268
+ opacity: [0, 1],
3269
+ pathLength: [0, 1],
3270
+ pathOffset: [1, 0],
3271
+ transition: {
3272
+ duration: 0.6,
3273
+ ease: 'linear',
3274
+ opacity: { duration: 0.1 },
3275
+ },
3276
+ },
3277
+ };
3278
+ function AccessibilityActivity({ size = 28, className, style, autoAnimateOnLoad = false, hoverable = true, loopOnHover = false, animateOnClick = false, onMouseEnter, onMouseLeave, onClick, ...props }) {
3279
+ const controls = useAnimation();
3280
+ const loopRef = useRef(loopOnHover);
3281
+ const triggerAnimation = useCallback(async () => {
3282
+ await controls.start('animate');
3283
+ await controls.start('normal');
3284
+ if (loopRef.current)
3285
+ triggerAnimation();
3286
+ }, [controls]);
3287
+ useEffect(() => {
3288
+ loopRef.current = loopOnHover;
3289
+ }, [loopOnHover]);
3290
+ useEffect(() => {
3291
+ if (autoAnimateOnLoad)
3292
+ triggerAnimation();
3293
+ }, [autoAnimateOnLoad, triggerAnimation]);
3294
+ const handleMouseEnter = (e) => {
3295
+ if (hoverable)
3296
+ triggerAnimation();
3297
+ onMouseEnter?.(e);
3298
+ };
3299
+ const handleMouseLeave = (e) => {
3300
+ if (hoverable)
3301
+ controls.start('normal');
3302
+ onMouseLeave?.(e);
3303
+ };
3304
+ const handleClick = (e) => {
3305
+ if (animateOnClick)
3306
+ triggerAnimation();
3307
+ onClick?.(e);
3308
+ };
3309
+ return (jsx("div", { className: cn$2('rounded-md', className), style: {
3310
+ width: size,
3311
+ height: size,
3312
+ display: 'inline-block',
3313
+ ...style,
3314
+ }, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onClick: handleClick, ...props, children: jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", width: "100%", height: "100%", children: [jsx(motion.circle, { cx: "16", cy: "4", r: "1", variants: circleVariants, animate: controls, initial: "normal" }), jsx(motion.path, { d: "m18 19 1-7-6 1", variants: pathVariants$1, animate: controls, initial: "normal", style: { strokeDasharray: 1 } }), jsx(motion.path, { d: "m5 8 3-3 5.5 3-2.36 3.5", variants: pathVariants$1, animate: controls, initial: "normal", style: { strokeDasharray: 1 } }), jsx(motion.path, { d: "M4.24 14.5a5 5 0 0 0 6.88 6", variants: pathVariants$1, animate: controls, initial: "normal", style: { strokeDasharray: 1 } }), jsx(motion.path, { d: "M13.76 17.5a5 5 0 0 0-6.88-6", variants: pathVariants$1, animate: controls, initial: "normal", style: { strokeDasharray: 1 } })] }) }));
3315
+ }
3316
+
3317
+ function cn$1(...inputs) {
3318
+ return twMerge(clsx(inputs));
3319
+ }
3320
+ const pathVariants = {
3321
+ normal: {
3322
+ opacity: 1,
3323
+ pathLength: 1,
3324
+ pathOffset: 0,
3325
+ transition: {
3326
+ duration: 0.4,
3327
+ opacity: { duration: 0.1 },
3328
+ },
3329
+ },
3330
+ animate: {
3331
+ opacity: [0, 1],
3332
+ pathLength: [0, 1],
3333
+ pathOffset: [1, 0],
3334
+ transition: {
3335
+ duration: 0.6,
3336
+ ease: 'linear',
3337
+ opacity: { duration: 0.1 },
3338
+ },
3339
+ },
3340
+ };
3341
+ function Activity({ size = 28, className, style, autoAnimateOnLoad = false, hoverable = true, loopOnHover = false, animateOnClick = false, onMouseEnter, onMouseLeave, onClick, ...props }) {
3342
+ const controls = useAnimation();
3343
+ const loopRef = useRef(loopOnHover);
3344
+ const triggerAnimation = useCallback(async () => {
3345
+ console.log("started animation");
3346
+ await controls.start('animate');
3347
+ await controls.start('normal');
3348
+ if (loopRef.current)
3349
+ triggerAnimation();
3350
+ }, [controls]);
3351
+ useEffect(() => {
3352
+ loopRef.current = loopOnHover;
3353
+ }, [loopOnHover]);
3354
+ useEffect(() => {
3355
+ if (autoAnimateOnLoad)
3356
+ triggerAnimation();
3357
+ }, [autoAnimateOnLoad, triggerAnimation]);
3358
+ const handleMouseEnter = (e) => {
3359
+ if (hoverable)
3360
+ triggerAnimation();
3361
+ onMouseEnter?.(e);
3362
+ };
3363
+ const handleMouseLeave = (e) => {
3364
+ if (hoverable)
3365
+ controls.start('normal');
3366
+ onMouseLeave?.(e);
3367
+ };
3368
+ const handleClick = (e) => {
3369
+ if (animateOnClick)
3370
+ triggerAnimation();
3371
+ onClick?.(e);
3372
+ };
3373
+ return (jsx("div", { className: cn$1('rounded-md', className), style: {
3031
3374
  width: size,
3032
3375
  height: size,
3033
3376
  display: 'inline-block',
3034
3377
  ...style,
3035
- }, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onClick: handleClick, ...props, children: jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", width: "100%", height: "100%", children: [jsx(motion.rect, { width: "18", height: "18", x: "3", y: "3", rx: "2", variants: squareVariants, animate: controls, initial: "normal" }), jsx(motion.path, { d: "M17 12h-2l-2 5-2-10-2 5H7", variants: pathVariants, animate: controls, initial: "normal", style: { strokeDasharray: 1 } })] }) }));
3378
+ }, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onClick: handleClick, ...props, children: jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", width: "100%", height: "100%", children: jsx(motion.path, { d: "M17 12h-2l-2 5-2-10-2 5H7", variants: pathVariants, animate: controls, initial: "normal", style: { strokeDasharray: 1 } }) }) }));
3036
3379
  }
3037
3380
 
3038
- export { SquareActivity };
3381
+ function cn(...inputs) {
3382
+ return twMerge(clsx(inputs));
3383
+ }
3384
+ const windVariants = {
3385
+ normal: (custom) => ({
3386
+ pathLength: 1,
3387
+ opacity: 1,
3388
+ pathOffset: 0,
3389
+ transition: {
3390
+ duration: 0.3,
3391
+ ease: 'easeInOut',
3392
+ delay: custom,
3393
+ },
3394
+ }),
3395
+ animate: (custom) => ({
3396
+ pathLength: [0, 1],
3397
+ opacity: [0, 1],
3398
+ pathOffset: [1, 0],
3399
+ transition: {
3400
+ duration: 0.5,
3401
+ ease: 'easeInOut',
3402
+ delay: custom,
3403
+ },
3404
+ }),
3405
+ };
3406
+ const AirVent = forwardRef(({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {
3407
+ const controls = useAnimation();
3408
+ const isControlledRef = useRef(false);
3409
+ useImperativeHandle(ref, () => {
3410
+ isControlledRef.current = true;
3411
+ return {
3412
+ startAnimation: () => controls.start('animate'),
3413
+ stopAnimation: () => controls.start('normal'),
3414
+ };
3415
+ });
3416
+ const handleMouseEnter = useCallback((e) => {
3417
+ if (!isControlledRef.current) {
3418
+ controls.start('animate');
3419
+ }
3420
+ else {
3421
+ onMouseEnter?.(e);
3422
+ }
3423
+ }, [controls, onMouseEnter]);
3424
+ const handleMouseLeave = useCallback((e) => {
3425
+ if (!isControlledRef.current) {
3426
+ controls.start('normal');
3427
+ }
3428
+ else {
3429
+ onMouseLeave?.(e);
3430
+ }
3431
+ }, [controls, onMouseLeave]);
3432
+ return (jsx("div", { className: cn(className), onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, ...props, children: jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [jsx("path", { d: "M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2" }), jsx(motion.path, { d: "M6 8h12", variants: windVariants, initial: "normal", animate: controls, custom: 0.1 }), jsx(motion.path, { d: "M18.3 17.7a2.5 2.5 0 0 1-3.16 3.83 2.53 2.53 0 0 1-1.14-2V12", variants: windVariants, initial: "normal", animate: controls, custom: 0 }), jsx(motion.path, { d: "M6.6 15.6A2 2 0 1 0 10 17v-5", variants: windVariants, initial: "normal", animate: controls, custom: 0.2 })] }) }));
3433
+ });
3434
+ AirVent.displayName = 'AirVent';
3435
+
3436
+ export { AccessibilityActivity, Activity, AirVent, ArrowDown, ArrowUp, SquareActivity };
3039
3437
  //# sourceMappingURL=index.js.map