@gfazioli/mantine-text-animate 2.4.2 → 3.0.1
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/README.md +1 -1
- package/dist/cjs/Gradient/Gradient.cjs +80 -0
- package/dist/cjs/Gradient/Gradient.cjs.map +1 -0
- package/dist/cjs/Gradient/Gradient.module.css.cjs +7 -0
- package/dist/cjs/Gradient/Gradient.module.css.cjs.map +1 -0
- package/dist/cjs/Highlight/Highlight.cjs +78 -0
- package/dist/cjs/Highlight/Highlight.cjs.map +1 -0
- package/dist/cjs/Highlight/Highlight.module.css.cjs +7 -0
- package/dist/cjs/Highlight/Highlight.module.css.cjs.map +1 -0
- package/dist/cjs/Morphing/Morphing.cjs +79 -0
- package/dist/cjs/Morphing/Morphing.cjs.map +1 -0
- package/dist/cjs/Morphing/Morphing.module.css.cjs +7 -0
- package/dist/cjs/Morphing/Morphing.module.css.cjs.map +1 -0
- package/dist/cjs/Morphing/use-morphing.cjs +240 -0
- package/dist/cjs/Morphing/use-morphing.cjs.map +1 -0
- package/dist/cjs/NumberTicker/NumberTicker.cjs +11 -3
- package/dist/cjs/NumberTicker/NumberTicker.cjs.map +1 -1
- package/dist/cjs/NumberTicker/use-number-ticker.cjs +15 -3
- package/dist/cjs/NumberTicker/use-number-ticker.cjs.map +1 -1
- package/dist/cjs/RotatingText/RotatingText.cjs +71 -0
- package/dist/cjs/RotatingText/RotatingText.cjs.map +1 -0
- package/dist/cjs/RotatingText/RotatingText.module.css.cjs +7 -0
- package/dist/cjs/RotatingText/RotatingText.module.css.cjs.map +1 -0
- package/dist/cjs/RotatingText/use-rotating-text.cjs +112 -0
- package/dist/cjs/RotatingText/use-rotating-text.cjs.map +1 -0
- package/dist/cjs/Spinner/Spinner.cjs +42 -31
- package/dist/cjs/Spinner/Spinner.cjs.map +1 -1
- package/dist/cjs/SplitFlap/SplitFlap.cjs +92 -0
- package/dist/cjs/SplitFlap/SplitFlap.cjs.map +1 -0
- package/dist/cjs/SplitFlap/SplitFlap.module.css.cjs +7 -0
- package/dist/cjs/SplitFlap/SplitFlap.module.css.cjs.map +1 -0
- package/dist/cjs/SplitFlap/use-split-flap.cjs +258 -0
- package/dist/cjs/SplitFlap/use-split-flap.cjs.map +1 -0
- package/dist/cjs/TextAnimate.cjs +114 -29
- package/dist/cjs/TextAnimate.cjs.map +1 -1
- package/dist/cjs/TextTicker/TextTicker.cjs +6 -0
- package/dist/cjs/TextTicker/TextTicker.cjs.map +1 -1
- package/dist/cjs/TextTicker/use-text-ticker.cjs +97 -7
- package/dist/cjs/TextTicker/use-text-ticker.cjs.map +1 -1
- package/dist/cjs/Typewriter/Typewriter.cjs +40 -20
- package/dist/cjs/Typewriter/Typewriter.cjs.map +1 -1
- package/dist/cjs/Typewriter/use-typewriter.cjs +85 -6
- package/dist/cjs/Typewriter/use-typewriter.cjs.map +1 -1
- package/dist/cjs/index.cjs +8 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/use-text-animate.cjs +38 -0
- package/dist/cjs/use-text-animate.cjs.map +1 -0
- package/dist/esm/Gradient/Gradient.mjs +78 -0
- package/dist/esm/Gradient/Gradient.mjs.map +1 -0
- package/dist/esm/Gradient/Gradient.module.css.mjs +5 -0
- package/dist/esm/Gradient/Gradient.module.css.mjs.map +1 -0
- package/dist/esm/Highlight/Highlight.mjs +76 -0
- package/dist/esm/Highlight/Highlight.mjs.map +1 -0
- package/dist/esm/Highlight/Highlight.module.css.mjs +5 -0
- package/dist/esm/Highlight/Highlight.module.css.mjs.map +1 -0
- package/dist/esm/Morphing/Morphing.mjs +77 -0
- package/dist/esm/Morphing/Morphing.mjs.map +1 -0
- package/dist/esm/Morphing/Morphing.module.css.mjs +5 -0
- package/dist/esm/Morphing/Morphing.module.css.mjs.map +1 -0
- package/dist/esm/Morphing/use-morphing.mjs +238 -0
- package/dist/esm/Morphing/use-morphing.mjs.map +1 -0
- package/dist/esm/NumberTicker/NumberTicker.mjs +11 -3
- package/dist/esm/NumberTicker/NumberTicker.mjs.map +1 -1
- package/dist/esm/NumberTicker/use-number-ticker.mjs +15 -3
- package/dist/esm/NumberTicker/use-number-ticker.mjs.map +1 -1
- package/dist/esm/RotatingText/RotatingText.mjs +69 -0
- package/dist/esm/RotatingText/RotatingText.mjs.map +1 -0
- package/dist/esm/RotatingText/RotatingText.module.css.mjs +5 -0
- package/dist/esm/RotatingText/RotatingText.module.css.mjs.map +1 -0
- package/dist/esm/RotatingText/use-rotating-text.mjs +110 -0
- package/dist/esm/RotatingText/use-rotating-text.mjs.map +1 -0
- package/dist/esm/Spinner/Spinner.mjs +43 -32
- package/dist/esm/Spinner/Spinner.mjs.map +1 -1
- package/dist/esm/SplitFlap/SplitFlap.mjs +90 -0
- package/dist/esm/SplitFlap/SplitFlap.mjs.map +1 -0
- package/dist/esm/SplitFlap/SplitFlap.module.css.mjs +5 -0
- package/dist/esm/SplitFlap/SplitFlap.module.css.mjs.map +1 -0
- package/dist/esm/SplitFlap/use-split-flap.mjs +256 -0
- package/dist/esm/SplitFlap/use-split-flap.mjs.map +1 -0
- package/dist/esm/TextAnimate.mjs +115 -30
- package/dist/esm/TextAnimate.mjs.map +1 -1
- package/dist/esm/TextTicker/TextTicker.mjs +6 -0
- package/dist/esm/TextTicker/TextTicker.mjs.map +1 -1
- package/dist/esm/TextTicker/use-text-ticker.mjs +97 -7
- package/dist/esm/TextTicker/use-text-ticker.mjs.map +1 -1
- package/dist/esm/Typewriter/Typewriter.mjs +40 -20
- package/dist/esm/Typewriter/Typewriter.mjs.map +1 -1
- package/dist/esm/Typewriter/use-typewriter.mjs +86 -7
- package/dist/esm/Typewriter/use-typewriter.mjs.map +1 -1
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/use-text-animate.mjs +36 -0
- package/dist/esm/use-text-animate.mjs.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/styles.layer.css +1 -1
- package/dist/types/Gradient/Gradient.d.ts +73 -0
- package/dist/types/Highlight/Highlight.d.ts +78 -0
- package/dist/types/Morphing/Morphing.d.ts +50 -0
- package/dist/types/Morphing/use-morphing.d.ts +73 -0
- package/dist/types/NumberTicker/NumberTicker.d.ts +9 -1
- package/dist/types/NumberTicker/use-number-ticker.d.ts +8 -1
- package/dist/types/RotatingText/RotatingText.d.ts +55 -0
- package/dist/types/RotatingText/use-rotating-text.d.ts +49 -0
- package/dist/types/Spinner/Spinner.d.ts +7 -4
- package/dist/types/SplitFlap/SplitFlap.d.ts +85 -0
- package/dist/types/SplitFlap/use-split-flap.d.ts +85 -0
- package/dist/types/TextAnimate.d.ts +76 -1
- package/dist/types/TextTicker/use-text-ticker.d.ts +15 -1
- package/dist/types/Typewriter/use-typewriter.d.ts +26 -2
- package/dist/types/index.d.mts +10 -1
- package/dist/types/index.d.ts +10 -1
- package/dist/types/use-text-animate.d.ts +36 -0
- package/package.json +1 -1
|
@@ -44,6 +44,13 @@ export interface NumberTickerBaseProps {
|
|
|
44
44
|
* Callback function called when animation completes
|
|
45
45
|
*/
|
|
46
46
|
onCompleted?: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Custom format function that overrides the default Intl.NumberFormat.
|
|
49
|
+
* When provided, this function is used to format the displayed value.
|
|
50
|
+
* @param value The current numeric value
|
|
51
|
+
* @returns The formatted string representation
|
|
52
|
+
*/
|
|
53
|
+
formatValue?: (value: number) => string;
|
|
47
54
|
}
|
|
48
55
|
/**
|
|
49
56
|
* Hook props interface extending the base props
|
|
@@ -85,4 +92,4 @@ export interface UseNumberTickerResult {
|
|
|
85
92
|
* This hook powers the NumberTicker component and can be used independently
|
|
86
93
|
* for more advanced use cases.
|
|
87
94
|
*/
|
|
88
|
-
export declare function useNumberTicker({ value, startValue, delay, decimalPlaces, speed, easing, animate, onCompleted, }: UseNumberTickerProps): UseNumberTickerResult;
|
|
95
|
+
export declare function useNumberTicker({ value, startValue, delay, decimalPlaces, speed, easing, animate, onCompleted, formatValue, }: UseNumberTickerProps): UseNumberTickerResult;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type BoxProps, type PolymorphicFactory, type StylesApiProps } from '@mantine/core';
|
|
3
|
+
import { type RotatingTextBaseProps } from './use-rotating-text';
|
|
4
|
+
export type RotatingTextStylesNames = 'root' | 'text' | 'entering' | 'exiting';
|
|
5
|
+
export type RotatingTextCssVariables = {
|
|
6
|
+
root: '--text-animate-rotating-speed';
|
|
7
|
+
};
|
|
8
|
+
export type RotatingTextAnimation = 'slideUp' | 'slideDown' | 'fade' | 'blur' | 'blurUp' | 'blurDown';
|
|
9
|
+
export interface RotatingTextProps extends BoxProps, RotatingTextBaseProps, StylesApiProps<RotatingTextFactory> {
|
|
10
|
+
/**
|
|
11
|
+
* Animation variant for the transition
|
|
12
|
+
* @default 'slideUp'
|
|
13
|
+
*/
|
|
14
|
+
animation?: RotatingTextAnimation;
|
|
15
|
+
}
|
|
16
|
+
export type RotatingTextFactory = PolymorphicFactory<{
|
|
17
|
+
props: RotatingTextProps;
|
|
18
|
+
defaultComponent: 'span';
|
|
19
|
+
defaultRef: HTMLSpanElement;
|
|
20
|
+
stylesNames: RotatingTextStylesNames;
|
|
21
|
+
vars: RotatingTextCssVariables;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* RotatingText Component
|
|
25
|
+
*
|
|
26
|
+
* A component that cycles through an array of text strings with smooth
|
|
27
|
+
* enter/exit animations, similar to an animated text carousel.
|
|
28
|
+
*/
|
|
29
|
+
export declare const RotatingText: (<C = "span">(props: import("@mantine/core").PolymorphicComponentProps<C, RotatingTextProps>) => React.ReactElement) & Omit<React.FunctionComponent<(RotatingTextProps & {
|
|
30
|
+
component?: any;
|
|
31
|
+
} & Omit<Omit<any, "ref">, "component" | keyof RotatingTextProps> & {
|
|
32
|
+
ref?: any;
|
|
33
|
+
renderRoot?: (props: any) => any;
|
|
34
|
+
}) | (RotatingTextProps & {
|
|
35
|
+
component: React.ElementType;
|
|
36
|
+
renderRoot?: (props: Record<string, any>) => any;
|
|
37
|
+
})>, never> & import("@mantine/core").ThemeExtend<{
|
|
38
|
+
props: RotatingTextProps;
|
|
39
|
+
defaultComponent: "span";
|
|
40
|
+
defaultRef: HTMLSpanElement;
|
|
41
|
+
stylesNames: RotatingTextStylesNames;
|
|
42
|
+
vars: RotatingTextCssVariables;
|
|
43
|
+
}> & import("@mantine/core").ComponentClasses<{
|
|
44
|
+
props: RotatingTextProps;
|
|
45
|
+
defaultComponent: "span";
|
|
46
|
+
defaultRef: HTMLSpanElement;
|
|
47
|
+
stylesNames: RotatingTextStylesNames;
|
|
48
|
+
vars: RotatingTextCssVariables;
|
|
49
|
+
}> & import("@mantine/core").PolymorphicComponentWithProps<{
|
|
50
|
+
props: RotatingTextProps;
|
|
51
|
+
defaultComponent: "span";
|
|
52
|
+
defaultRef: HTMLSpanElement;
|
|
53
|
+
stylesNames: RotatingTextStylesNames;
|
|
54
|
+
vars: RotatingTextCssVariables;
|
|
55
|
+
}>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface RotatingTextBaseProps {
|
|
2
|
+
/**
|
|
3
|
+
* Array of text strings to rotate through
|
|
4
|
+
*/
|
|
5
|
+
values: string[];
|
|
6
|
+
/**
|
|
7
|
+
* Whether the rotation animation is active
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
animate?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Time in milliseconds each text stays visible before rotating
|
|
13
|
+
* @default 3000
|
|
14
|
+
*/
|
|
15
|
+
interval?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Animation speed multiplier (higher = faster transition)
|
|
18
|
+
* @default 1
|
|
19
|
+
*/
|
|
20
|
+
speed?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Callback fired when the text rotates to a new index
|
|
23
|
+
*/
|
|
24
|
+
onCycle?: (index: number) => void;
|
|
25
|
+
}
|
|
26
|
+
export interface UseRotatingTextResult {
|
|
27
|
+
/** Index of the currently displayed text */
|
|
28
|
+
currentIndex: number;
|
|
29
|
+
/** The currently displayed text */
|
|
30
|
+
currentText: string;
|
|
31
|
+
/** Index of the next text to display */
|
|
32
|
+
nextIndex: number;
|
|
33
|
+
/** The next text to display */
|
|
34
|
+
nextText: string;
|
|
35
|
+
/** Whether a transition animation is in progress */
|
|
36
|
+
isTransitioning: boolean;
|
|
37
|
+
/** Callback to attach to the entering element's onAnimationEnd */
|
|
38
|
+
onTransitionEnd: () => void;
|
|
39
|
+
/** Start the rotation */
|
|
40
|
+
start: () => void;
|
|
41
|
+
/** Stop the rotation */
|
|
42
|
+
stop: () => void;
|
|
43
|
+
/** Reset to the first text */
|
|
44
|
+
reset: () => void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A hook that creates a rotating text effect, cycling through an array of strings
|
|
48
|
+
*/
|
|
49
|
+
export declare function useRotatingText(options: RotatingTextBaseProps): UseRotatingTextResult;
|
|
@@ -6,17 +6,20 @@ export type SpinnerCssVariables = {
|
|
|
6
6
|
};
|
|
7
7
|
export interface SpinnerBaseProps {
|
|
8
8
|
/**
|
|
9
|
-
* The text content to animate
|
|
9
|
+
* The text content to animate.
|
|
10
|
+
* Pass a string for text processing (repeat/reverse), or an array of ReactNode
|
|
11
|
+
* for custom content (repeat/reverse will be skipped).
|
|
12
|
+
* When passing ReactNode[], you must provide an explicit `aria-label`.
|
|
10
13
|
*/
|
|
11
|
-
children: string;
|
|
14
|
+
children: string | React.ReactNode[];
|
|
12
15
|
/**
|
|
13
16
|
* The radius of the circle in pixels or Mantine size
|
|
14
17
|
* @default "md"
|
|
15
18
|
*/
|
|
16
19
|
radius?: MantineSize | number | string;
|
|
17
20
|
/**
|
|
18
|
-
* The rotation speed
|
|
19
|
-
* @default
|
|
21
|
+
* The rotation speed multiplier (higher = faster)
|
|
22
|
+
* @default 2
|
|
20
23
|
*/
|
|
21
24
|
speed?: number;
|
|
22
25
|
/**
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type BoxProps, type MantineColor, type MantineRadius, type PolymorphicFactory, type StylesApiProps } from '@mantine/core';
|
|
3
|
+
import { type SplitFlapBaseProps } from './use-split-flap';
|
|
4
|
+
export type SplitFlapStylesNames = 'root' | 'character' | 'charTop' | 'charBottom' | 'flapTop' | 'flapBottom';
|
|
5
|
+
export type SplitFlapCssVariables = {
|
|
6
|
+
root: '--text-animate-split-flap-bg' | '--text-animate-split-flap-color' | '--text-animate-split-flap-gap' | '--text-animate-split-flap-flip-duration' | '--text-animate-split-flap-char-width' | '--text-animate-split-flap-char-height' | '--text-animate-split-flap-radius' | '--text-animate-split-flap-divider-color';
|
|
7
|
+
};
|
|
8
|
+
export interface SplitFlapProps extends BoxProps, SplitFlapBaseProps, StylesApiProps<SplitFlapFactory> {
|
|
9
|
+
/**
|
|
10
|
+
* Background color of each flap
|
|
11
|
+
* @default '#1a1a2e'
|
|
12
|
+
*/
|
|
13
|
+
bg?: MantineColor;
|
|
14
|
+
/**
|
|
15
|
+
* Text color
|
|
16
|
+
* @default '#e0e0e0'
|
|
17
|
+
*/
|
|
18
|
+
textColor?: MantineColor;
|
|
19
|
+
/**
|
|
20
|
+
* Gap between characters in px
|
|
21
|
+
* @default 4
|
|
22
|
+
*/
|
|
23
|
+
gap?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Width of each character cell
|
|
26
|
+
* @default '1.2em'
|
|
27
|
+
*/
|
|
28
|
+
charWidth?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Height of each character cell
|
|
31
|
+
* @default '1.8em'
|
|
32
|
+
*/
|
|
33
|
+
charHeight?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Border radius of each flap card
|
|
36
|
+
* @default '4px'
|
|
37
|
+
*/
|
|
38
|
+
radius?: MantineRadius;
|
|
39
|
+
/**
|
|
40
|
+
* Color of the horizontal divider line between top and bottom halves.
|
|
41
|
+
* Set to 'transparent' to hide it.
|
|
42
|
+
* @default 'rgba(0,0,0,0.3)'
|
|
43
|
+
*/
|
|
44
|
+
dividerColor?: MantineColor;
|
|
45
|
+
}
|
|
46
|
+
export type SplitFlapFactory = PolymorphicFactory<{
|
|
47
|
+
props: SplitFlapProps;
|
|
48
|
+
defaultComponent: 'div';
|
|
49
|
+
defaultRef: HTMLDivElement;
|
|
50
|
+
stylesNames: SplitFlapStylesNames;
|
|
51
|
+
vars: SplitFlapCssVariables;
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* SplitFlap Component
|
|
55
|
+
*
|
|
56
|
+
* An airport departure board (split-flap display) effect that animates text
|
|
57
|
+
* by cycling each character through a character set with a 3D flip animation.
|
|
58
|
+
*/
|
|
59
|
+
export declare const SplitFlap: (<C = "div">(props: import("@mantine/core").PolymorphicComponentProps<C, SplitFlapProps>) => React.ReactElement) & Omit<React.FunctionComponent<(SplitFlapProps & {
|
|
60
|
+
component?: any;
|
|
61
|
+
} & Omit<Omit<any, "ref">, "component" | keyof SplitFlapProps> & {
|
|
62
|
+
ref?: any;
|
|
63
|
+
renderRoot?: (props: any) => any;
|
|
64
|
+
}) | (SplitFlapProps & {
|
|
65
|
+
component: React.ElementType;
|
|
66
|
+
renderRoot?: (props: Record<string, any>) => any;
|
|
67
|
+
})>, never> & import("@mantine/core").ThemeExtend<{
|
|
68
|
+
props: SplitFlapProps;
|
|
69
|
+
defaultComponent: "div";
|
|
70
|
+
defaultRef: HTMLDivElement;
|
|
71
|
+
stylesNames: SplitFlapStylesNames;
|
|
72
|
+
vars: SplitFlapCssVariables;
|
|
73
|
+
}> & import("@mantine/core").ComponentClasses<{
|
|
74
|
+
props: SplitFlapProps;
|
|
75
|
+
defaultComponent: "div";
|
|
76
|
+
defaultRef: HTMLDivElement;
|
|
77
|
+
stylesNames: SplitFlapStylesNames;
|
|
78
|
+
vars: SplitFlapCssVariables;
|
|
79
|
+
}> & import("@mantine/core").PolymorphicComponentWithProps<{
|
|
80
|
+
props: SplitFlapProps;
|
|
81
|
+
defaultComponent: "div";
|
|
82
|
+
defaultRef: HTMLDivElement;
|
|
83
|
+
stylesNames: SplitFlapStylesNames;
|
|
84
|
+
vars: SplitFlapCssVariables;
|
|
85
|
+
}>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the state of a single character in the split-flap display
|
|
3
|
+
*/
|
|
4
|
+
export interface SplitFlapCharacter {
|
|
5
|
+
/** The character currently displayed */
|
|
6
|
+
current: string;
|
|
7
|
+
/** The next character to flip to */
|
|
8
|
+
next: string;
|
|
9
|
+
/** Whether this character is currently mid-flip */
|
|
10
|
+
isFlipping: boolean;
|
|
11
|
+
/** Whether this character has reached its target */
|
|
12
|
+
settled: boolean;
|
|
13
|
+
/** Key that changes on every flip step — used to force-remount flap elements so CSS animations restart */
|
|
14
|
+
flipKey: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Base props shared between SplitFlap component and useSplitFlap hook
|
|
18
|
+
*/
|
|
19
|
+
export interface SplitFlapBaseProps {
|
|
20
|
+
/**
|
|
21
|
+
* The target text to display (will be uppercased)
|
|
22
|
+
*/
|
|
23
|
+
value: string;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the animation should be active
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
animate?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Speed multiplier (higher = faster)
|
|
31
|
+
* @default 1
|
|
32
|
+
*/
|
|
33
|
+
speed?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Character set to cycle through
|
|
36
|
+
* @default 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 '
|
|
37
|
+
*/
|
|
38
|
+
characterSet?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Duration of each flip in milliseconds
|
|
41
|
+
* @default 300
|
|
42
|
+
*/
|
|
43
|
+
flipDuration?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Delay between each character starting its animation in milliseconds
|
|
46
|
+
* @default 80
|
|
47
|
+
*/
|
|
48
|
+
staggerDelay?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Delay before the animation starts in seconds
|
|
51
|
+
* @default 0
|
|
52
|
+
*/
|
|
53
|
+
delay?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Callback fired when all characters have settled
|
|
56
|
+
*/
|
|
57
|
+
onCompleted?: () => void;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Hook props interface extending the base props
|
|
61
|
+
*/
|
|
62
|
+
export interface UseSplitFlapProps extends SplitFlapBaseProps {
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Return value interface for the useSplitFlap hook
|
|
66
|
+
*/
|
|
67
|
+
export interface UseSplitFlapResult {
|
|
68
|
+
/** Current state of each character */
|
|
69
|
+
characters: SplitFlapCharacter[];
|
|
70
|
+
/** Start or restart the animation */
|
|
71
|
+
start: () => void;
|
|
72
|
+
/** Stop the animation, keeping current state */
|
|
73
|
+
stop: () => void;
|
|
74
|
+
/** Reset all characters to space */
|
|
75
|
+
reset: () => void;
|
|
76
|
+
/** Whether the animation is currently running */
|
|
77
|
+
isAnimating: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Hook that provides split-flap (airport departure board) animation functionality.
|
|
81
|
+
*
|
|
82
|
+
* Each character cycles through the characterSet in order until reaching
|
|
83
|
+
* the target character, with staggered start times for a realistic effect.
|
|
84
|
+
*/
|
|
85
|
+
export declare function useSplitFlap({ value, animate, speed: _speed, characterSet, flipDuration, staggerDelay, delay, onCompleted, }: UseSplitFlapProps): UseSplitFlapResult;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type BoxProps, type MantineSize, type PolymorphicFactory, type StylesApiProps, type TextProps, type TextStylesNames, type TextVariant } from '@mantine/core';
|
|
3
|
+
import { Gradient } from './Gradient/Gradient';
|
|
4
|
+
import { Highlight } from './Highlight/Highlight';
|
|
5
|
+
import { Morphing } from './Morphing/Morphing';
|
|
3
6
|
import { NumberTicker } from './NumberTicker/NumberTicker';
|
|
7
|
+
import { RotatingText } from './RotatingText/RotatingText';
|
|
4
8
|
import { Spinner } from './Spinner/Spinner';
|
|
9
|
+
import { SplitFlap } from './SplitFlap/SplitFlap';
|
|
5
10
|
import { TextTicker } from './TextTicker/TextTicker';
|
|
6
11
|
import { Typewriter } from './Typewriter/Typewriter';
|
|
7
12
|
/**
|
|
@@ -19,7 +24,7 @@ export type TextAnimateAnimationVariant = 'fade' | 'blur' | 'scale' | 'slideUp'
|
|
|
19
24
|
/**
|
|
20
25
|
* Animation direction
|
|
21
26
|
*/
|
|
22
|
-
export type TextAnimateAnimationDirection = 'in' | 'out' | 'static' | 'none' | false | undefined;
|
|
27
|
+
export type TextAnimateAnimationDirection = 'in' | 'out' | 'loop' | 'static' | 'none' | false | undefined;
|
|
23
28
|
interface TextAnimateAnimateProps {
|
|
24
29
|
/**
|
|
25
30
|
* Controls the distance for slide animations (in pixels)
|
|
@@ -39,6 +44,28 @@ interface TextAnimateAnimateProps {
|
|
|
39
44
|
*/
|
|
40
45
|
blurAmount?: MantineSize;
|
|
41
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Trigger mode for TextAnimate animation
|
|
49
|
+
* - `mount`: Animate on mount (default behavior)
|
|
50
|
+
* - `inView`: Animate when the element enters the viewport
|
|
51
|
+
* - `manual`: Do not auto-animate; control via `animate` prop only
|
|
52
|
+
*/
|
|
53
|
+
export type TextAnimateTrigger = 'mount' | 'inView' | 'manual';
|
|
54
|
+
/**
|
|
55
|
+
* Options for the IntersectionObserver when trigger is "inView"
|
|
56
|
+
*/
|
|
57
|
+
export interface TextAnimateTriggerOptions {
|
|
58
|
+
/**
|
|
59
|
+
* IntersectionObserver threshold (0-1)
|
|
60
|
+
* @default 0.1
|
|
61
|
+
*/
|
|
62
|
+
threshold?: number;
|
|
63
|
+
/**
|
|
64
|
+
* IntersectionObserver root margin
|
|
65
|
+
* @default "0px"
|
|
66
|
+
*/
|
|
67
|
+
rootMargin?: string;
|
|
68
|
+
}
|
|
42
69
|
export type TextAnimateStylesNames = 'root' | 'segment' | TextStylesNames;
|
|
43
70
|
export type TextAnimateCssVariables = {
|
|
44
71
|
root: '--text-animate-translation-distance' | '--text-animate-blur-amount' | '--text-animate-scale-amount';
|
|
@@ -105,6 +132,29 @@ export interface TextAnimateBaseProps {
|
|
|
105
132
|
* @param animate The direction of the animation
|
|
106
133
|
*/
|
|
107
134
|
onAnimationEnd?: (animate: 'in' | 'out') => void;
|
|
135
|
+
/**
|
|
136
|
+
* Callback function called when all segments have completed their animation
|
|
137
|
+
* @param animate The direction of the animation
|
|
138
|
+
*/
|
|
139
|
+
onAnimationComplete?: (animate: 'in' | 'out') => void;
|
|
140
|
+
/**
|
|
141
|
+
* Trigger mode for animation
|
|
142
|
+
* - `mount`: Animate on mount (default, preserves v2 behavior)
|
|
143
|
+
* - `inView`: Animate when element enters the viewport via IntersectionObserver
|
|
144
|
+
* - `manual`: Do not auto-animate; control via `animate` prop only
|
|
145
|
+
* @default "mount"
|
|
146
|
+
*/
|
|
147
|
+
trigger?: TextAnimateTrigger;
|
|
148
|
+
/**
|
|
149
|
+
* Options for IntersectionObserver when trigger is "inView"
|
|
150
|
+
*/
|
|
151
|
+
triggerOptions?: TextAnimateTriggerOptions;
|
|
152
|
+
/**
|
|
153
|
+
* Delay in milliseconds between loop phases (in→pause→out→pause→in)
|
|
154
|
+
* Only used when `animate="loop"`
|
|
155
|
+
* @default 2000
|
|
156
|
+
*/
|
|
157
|
+
loopDelay?: number;
|
|
108
158
|
}
|
|
109
159
|
export interface TextAnimateProps extends BoxProps, Omit<TextProps, 'classNames' | 'styles' | 'unstyled' | 'vars' | 'attributes'>, TextAnimateBaseProps, StylesApiProps<TextAnimateFactory> {
|
|
110
160
|
}
|
|
@@ -120,6 +170,11 @@ export type TextAnimateFactory = PolymorphicFactory<{
|
|
|
120
170
|
Spinner: typeof Spinner;
|
|
121
171
|
NumberTicker: typeof NumberTicker;
|
|
122
172
|
TextTicker: typeof TextTicker;
|
|
173
|
+
Gradient: typeof Gradient;
|
|
174
|
+
Highlight: typeof Highlight;
|
|
175
|
+
SplitFlap: typeof SplitFlap;
|
|
176
|
+
Morphing: typeof Morphing;
|
|
177
|
+
RotatingText: typeof RotatingText;
|
|
123
178
|
};
|
|
124
179
|
}>;
|
|
125
180
|
export declare const TextAnimate: (<C = "p">(props: import("@mantine/core").PolymorphicComponentProps<C, TextAnimateProps>) => React.ReactElement) & Omit<React.FunctionComponent<(TextAnimateProps & {
|
|
@@ -142,6 +197,11 @@ export declare const TextAnimate: (<C = "p">(props: import("@mantine/core").Poly
|
|
|
142
197
|
Spinner: typeof Spinner;
|
|
143
198
|
NumberTicker: typeof NumberTicker;
|
|
144
199
|
TextTicker: typeof TextTicker;
|
|
200
|
+
Gradient: typeof Gradient;
|
|
201
|
+
Highlight: typeof Highlight;
|
|
202
|
+
SplitFlap: typeof SplitFlap;
|
|
203
|
+
Morphing: typeof Morphing;
|
|
204
|
+
RotatingText: typeof RotatingText;
|
|
145
205
|
};
|
|
146
206
|
}> & import("@mantine/core").ComponentClasses<{
|
|
147
207
|
props: TextAnimateProps;
|
|
@@ -155,6 +215,11 @@ export declare const TextAnimate: (<C = "p">(props: import("@mantine/core").Poly
|
|
|
155
215
|
Spinner: typeof Spinner;
|
|
156
216
|
NumberTicker: typeof NumberTicker;
|
|
157
217
|
TextTicker: typeof TextTicker;
|
|
218
|
+
Gradient: typeof Gradient;
|
|
219
|
+
Highlight: typeof Highlight;
|
|
220
|
+
SplitFlap: typeof SplitFlap;
|
|
221
|
+
Morphing: typeof Morphing;
|
|
222
|
+
RotatingText: typeof RotatingText;
|
|
158
223
|
};
|
|
159
224
|
}> & import("@mantine/core").PolymorphicComponentWithProps<{
|
|
160
225
|
props: TextAnimateProps;
|
|
@@ -168,11 +233,21 @@ export declare const TextAnimate: (<C = "p">(props: import("@mantine/core").Poly
|
|
|
168
233
|
Spinner: typeof Spinner;
|
|
169
234
|
NumberTicker: typeof NumberTicker;
|
|
170
235
|
TextTicker: typeof TextTicker;
|
|
236
|
+
Gradient: typeof Gradient;
|
|
237
|
+
Highlight: typeof Highlight;
|
|
238
|
+
SplitFlap: typeof SplitFlap;
|
|
239
|
+
Morphing: typeof Morphing;
|
|
240
|
+
RotatingText: typeof RotatingText;
|
|
171
241
|
};
|
|
172
242
|
}> & {
|
|
173
243
|
Typewriter: typeof Typewriter;
|
|
174
244
|
Spinner: typeof Spinner;
|
|
175
245
|
NumberTicker: typeof NumberTicker;
|
|
176
246
|
TextTicker: typeof TextTicker;
|
|
247
|
+
Gradient: typeof Gradient;
|
|
248
|
+
Highlight: typeof Highlight;
|
|
249
|
+
SplitFlap: typeof SplitFlap;
|
|
250
|
+
Morphing: typeof Morphing;
|
|
251
|
+
RotatingText: typeof RotatingText;
|
|
177
252
|
};
|
|
178
253
|
export {};
|
|
@@ -70,6 +70,20 @@ export interface TextTickerBaseProps {
|
|
|
70
70
|
* @default "left-to-right"
|
|
71
71
|
*/
|
|
72
72
|
revealDirection?: TextTickerRevealDirection;
|
|
73
|
+
/**
|
|
74
|
+
* When set, enables "scramble" mode: each character cycles through random characters
|
|
75
|
+
* for exactly this duration (in ms) before settling on the target.
|
|
76
|
+
* This replaces the default probabilistic reveal with a deterministic per-character timer.
|
|
77
|
+
* @example 800
|
|
78
|
+
*/
|
|
79
|
+
scrambleDuration?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Delay in milliseconds between each character starting its scramble animation.
|
|
82
|
+
* Only used when `scrambleDuration` is set.
|
|
83
|
+
* Creates a wave-like "decryption" effect from the reveal direction.
|
|
84
|
+
* @default 50
|
|
85
|
+
*/
|
|
86
|
+
staggerDelay?: number;
|
|
73
87
|
/**
|
|
74
88
|
* Callback function called when animation completes
|
|
75
89
|
*/
|
|
@@ -111,4 +125,4 @@ export interface UseTextTickerResult {
|
|
|
111
125
|
* This hook powers the TextTicker component and can be used independently
|
|
112
126
|
* for more advanced use cases.
|
|
113
127
|
*/
|
|
114
|
-
export declare function useTextTicker({ value, initialText, animate, characterSet, customCharacters, delay, speed, easing, randomChangeSpeed, revealDirection, onCompleted, }: UseTextTickerProps): UseTextTickerResult;
|
|
128
|
+
export declare function useTextTicker({ value, initialText, animate, characterSet, customCharacters, delay, speed, easing, randomChangeSpeed, revealDirection, scrambleDuration, staggerDelay, onCompleted, }: UseTextTickerProps): UseTextTickerResult;
|
|
@@ -14,8 +14,8 @@ export interface TypewriterBaseProps {
|
|
|
14
14
|
*/
|
|
15
15
|
multiline?: boolean;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @default
|
|
17
|
+
* Animation speed multiplier (higher = faster)
|
|
18
|
+
* @default 1
|
|
19
19
|
*/
|
|
20
20
|
speed?: number;
|
|
21
21
|
/**
|
|
@@ -37,6 +37,30 @@ export interface TypewriterBaseProps {
|
|
|
37
37
|
* and the animation is about to start again
|
|
38
38
|
*/
|
|
39
39
|
onTypeLoop?: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Callback function called for each character typed
|
|
42
|
+
* @param char The character that was typed
|
|
43
|
+
* @param index The index of the character in the current text
|
|
44
|
+
*/
|
|
45
|
+
onCharType?: (char: string, index: number) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Map of character indices to custom pause durations (in milliseconds)
|
|
48
|
+
* The typing will pause for the specified duration at the given character index
|
|
49
|
+
* @example { 5: 1000, 10: 500 } — pause 1s after char 5, 500ms after char 10
|
|
50
|
+
*/
|
|
51
|
+
pauseAt?: Record<number, number>;
|
|
52
|
+
/**
|
|
53
|
+
* Whether to play a mechanical keyboard click sound on each character typed
|
|
54
|
+
* Uses Web Audio API to synthesize sounds. Requires user gesture to start AudioContext.
|
|
55
|
+
* Respects `prefers-reduced-motion`.
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
withSound?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Volume of the typing sound (0 to 1)
|
|
61
|
+
* @default 0.3
|
|
62
|
+
*/
|
|
63
|
+
soundVolume?: number;
|
|
40
64
|
}
|
|
41
65
|
export interface UseTypewriterResult {
|
|
42
66
|
/**
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
export { TextAnimate } from './TextAnimate';
|
|
2
|
-
export type { TextAnimateAnimationDirection, TextAnimateAnimationType, TextAnimateAnimationVariant, TextAnimateBaseProps, TextAnimateCssVariables, TextAnimateDirection, TextAnimateFactory, TextAnimateIn, TextAnimateOut, TextAnimateProps, TextAnimateStylesNames, } from './TextAnimate';
|
|
2
|
+
export type { TextAnimateAnimationDirection, TextAnimateAnimationType, TextAnimateAnimationVariant, TextAnimateBaseProps, TextAnimateCssVariables, TextAnimateDirection, TextAnimateFactory, TextAnimateIn, TextAnimateOut, TextAnimateProps, TextAnimateStylesNames, TextAnimateTrigger, TextAnimateTriggerOptions, } from './TextAnimate';
|
|
3
|
+
export type { GradientFactory, GradientProps } from './Gradient/Gradient';
|
|
4
|
+
export type { HighlightFactory, HighlightProps } from './Highlight/Highlight';
|
|
5
|
+
export type { MorphingFactory, MorphingProps } from './Morphing/Morphing';
|
|
3
6
|
export type { NumberTickerFactory, NumberTickerProps } from './NumberTicker/NumberTicker';
|
|
7
|
+
export type { RotatingTextFactory, RotatingTextProps } from './RotatingText/RotatingText';
|
|
4
8
|
export type { SpinnerFactory, SpinnerProps } from './Spinner/Spinner';
|
|
9
|
+
export type { SplitFlapFactory, SplitFlapProps } from './SplitFlap/SplitFlap';
|
|
5
10
|
export type { TextTickerFactory, TextTickerProps } from './TextTicker/TextTicker';
|
|
6
11
|
export type { TypewriterFactory, TypewriterProps } from './Typewriter/Typewriter';
|
|
12
|
+
export { useMorphing } from './Morphing/use-morphing';
|
|
13
|
+
export { useRotatingText } from './RotatingText/use-rotating-text';
|
|
7
14
|
export { useNumberTicker, type NumberTickerEasing } from './NumberTicker/use-number-ticker';
|
|
15
|
+
export { useSplitFlap } from './SplitFlap/use-split-flap';
|
|
16
|
+
export { useTextAnimate, type UseTextAnimateResult } from './use-text-animate';
|
|
8
17
|
export { useTextTicker } from './TextTicker/use-text-ticker';
|
|
9
18
|
export { useTypewriter } from './Typewriter/use-typewriter';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
export { TextAnimate } from './TextAnimate';
|
|
2
|
-
export type { TextAnimateAnimationDirection, TextAnimateAnimationType, TextAnimateAnimationVariant, TextAnimateBaseProps, TextAnimateCssVariables, TextAnimateDirection, TextAnimateFactory, TextAnimateIn, TextAnimateOut, TextAnimateProps, TextAnimateStylesNames, } from './TextAnimate';
|
|
2
|
+
export type { TextAnimateAnimationDirection, TextAnimateAnimationType, TextAnimateAnimationVariant, TextAnimateBaseProps, TextAnimateCssVariables, TextAnimateDirection, TextAnimateFactory, TextAnimateIn, TextAnimateOut, TextAnimateProps, TextAnimateStylesNames, TextAnimateTrigger, TextAnimateTriggerOptions, } from './TextAnimate';
|
|
3
|
+
export type { GradientFactory, GradientProps } from './Gradient/Gradient';
|
|
4
|
+
export type { HighlightFactory, HighlightProps } from './Highlight/Highlight';
|
|
5
|
+
export type { MorphingFactory, MorphingProps } from './Morphing/Morphing';
|
|
3
6
|
export type { NumberTickerFactory, NumberTickerProps } from './NumberTicker/NumberTicker';
|
|
7
|
+
export type { RotatingTextFactory, RotatingTextProps } from './RotatingText/RotatingText';
|
|
4
8
|
export type { SpinnerFactory, SpinnerProps } from './Spinner/Spinner';
|
|
9
|
+
export type { SplitFlapFactory, SplitFlapProps } from './SplitFlap/SplitFlap';
|
|
5
10
|
export type { TextTickerFactory, TextTickerProps } from './TextTicker/TextTicker';
|
|
6
11
|
export type { TypewriterFactory, TypewriterProps } from './Typewriter/Typewriter';
|
|
12
|
+
export { useMorphing } from './Morphing/use-morphing';
|
|
13
|
+
export { useRotatingText } from './RotatingText/use-rotating-text';
|
|
7
14
|
export { useNumberTicker, type NumberTickerEasing } from './NumberTicker/use-number-ticker';
|
|
15
|
+
export { useSplitFlap } from './SplitFlap/use-split-flap';
|
|
16
|
+
export { useTextAnimate, type UseTextAnimateResult } from './use-text-animate';
|
|
8
17
|
export { useTextTicker } from './TextTicker/use-text-ticker';
|
|
9
18
|
export { useTypewriter } from './Typewriter/use-typewriter';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { TextAnimateAnimationDirection } from './TextAnimate';
|
|
2
|
+
export interface UseTextAnimateResult {
|
|
3
|
+
/**
|
|
4
|
+
* The current animation direction
|
|
5
|
+
*/
|
|
6
|
+
animate: TextAnimateAnimationDirection;
|
|
7
|
+
/**
|
|
8
|
+
* Set the animation direction
|
|
9
|
+
*/
|
|
10
|
+
setAnimate: (direction: TextAnimateAnimationDirection) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Replay the animation by forcing a remount via key change
|
|
13
|
+
*/
|
|
14
|
+
replay: () => void;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the animation is currently running
|
|
17
|
+
*/
|
|
18
|
+
isAnimating: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Key to pass to TextAnimate for remount-based replay
|
|
21
|
+
*/
|
|
22
|
+
key: number;
|
|
23
|
+
/**
|
|
24
|
+
* Callback to pass to TextAnimate's onAnimationComplete prop
|
|
25
|
+
*/
|
|
26
|
+
onAnimationComplete: (direction: 'in' | 'out') => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Hook that provides control over TextAnimate component
|
|
30
|
+
*
|
|
31
|
+
* Returns state and controls for managing TextAnimate animation direction,
|
|
32
|
+
* replay capability, and animation status tracking.
|
|
33
|
+
*
|
|
34
|
+
* @param initialDirection - The initial animation direction
|
|
35
|
+
*/
|
|
36
|
+
export declare function useTextAnimate(initialDirection?: TextAnimateAnimationDirection): UseTextAnimateResult;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gfazioli/mantine-text-animate",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "The TextAnimate component allows you to animate text with various effects.",
|
|
5
5
|
"homepage": "https://gfazioli.github.io/mantine-text-animate/",
|
|
6
6
|
"packageManager": "yarn@4.0.1",
|