@gfazioli/mantine-text-animate 1.0.0

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.
Files changed (73) hide show
  1. package/CODE_OF_CONDUCT.md +128 -0
  2. package/CONTRIBUTING.md +18 -0
  3. package/LICENSE +21 -0
  4. package/README.md +178 -0
  5. package/dist/cjs/NumberTicker/NumberTicker.cjs +84 -0
  6. package/dist/cjs/NumberTicker/NumberTicker.cjs.map +1 -0
  7. package/dist/cjs/NumberTicker/NumberTicker.module.css.cjs +7 -0
  8. package/dist/cjs/NumberTicker/NumberTicker.module.css.cjs.map +1 -0
  9. package/dist/cjs/NumberTicker/use-number-ticker.cjs +158 -0
  10. package/dist/cjs/NumberTicker/use-number-ticker.cjs.map +1 -0
  11. package/dist/cjs/Spinner/Spinner.cjs +93 -0
  12. package/dist/cjs/Spinner/Spinner.cjs.map +1 -0
  13. package/dist/cjs/Spinner/Spinner.module.css.cjs +7 -0
  14. package/dist/cjs/Spinner/Spinner.module.css.cjs.map +1 -0
  15. package/dist/cjs/TextAnimate.cjs +148 -0
  16. package/dist/cjs/TextAnimate.cjs.map +1 -0
  17. package/dist/cjs/TextAnimate.module.css.cjs +7 -0
  18. package/dist/cjs/TextAnimate.module.css.cjs.map +1 -0
  19. package/dist/cjs/TextTicker/TextTicker.cjs +93 -0
  20. package/dist/cjs/TextTicker/TextTicker.cjs.map +1 -0
  21. package/dist/cjs/TextTicker/TextTicker.module.css.cjs +7 -0
  22. package/dist/cjs/TextTicker/TextTicker.module.css.cjs.map +1 -0
  23. package/dist/cjs/TextTicker/use-text-ticker.cjs +227 -0
  24. package/dist/cjs/TextTicker/use-text-ticker.cjs.map +1 -0
  25. package/dist/cjs/Typewriter/Typewriter.cjs +87 -0
  26. package/dist/cjs/Typewriter/Typewriter.cjs.map +1 -0
  27. package/dist/cjs/Typewriter/Typewriter.module.css.cjs +7 -0
  28. package/dist/cjs/Typewriter/Typewriter.module.css.cjs.map +1 -0
  29. package/dist/cjs/Typewriter/use-typewriter.cjs +144 -0
  30. package/dist/cjs/Typewriter/use-typewriter.cjs.map +1 -0
  31. package/dist/cjs/index.cjs +15 -0
  32. package/dist/cjs/index.cjs.map +1 -0
  33. package/dist/esm/NumberTicker/NumberTicker.mjs +82 -0
  34. package/dist/esm/NumberTicker/NumberTicker.mjs.map +1 -0
  35. package/dist/esm/NumberTicker/NumberTicker.module.css.mjs +5 -0
  36. package/dist/esm/NumberTicker/NumberTicker.module.css.mjs.map +1 -0
  37. package/dist/esm/NumberTicker/use-number-ticker.mjs +156 -0
  38. package/dist/esm/NumberTicker/use-number-ticker.mjs.map +1 -0
  39. package/dist/esm/Spinner/Spinner.mjs +91 -0
  40. package/dist/esm/Spinner/Spinner.mjs.map +1 -0
  41. package/dist/esm/Spinner/Spinner.module.css.mjs +5 -0
  42. package/dist/esm/Spinner/Spinner.module.css.mjs.map +1 -0
  43. package/dist/esm/TextAnimate.mjs +146 -0
  44. package/dist/esm/TextAnimate.mjs.map +1 -0
  45. package/dist/esm/TextAnimate.module.css.mjs +5 -0
  46. package/dist/esm/TextAnimate.module.css.mjs.map +1 -0
  47. package/dist/esm/TextTicker/TextTicker.mjs +91 -0
  48. package/dist/esm/TextTicker/TextTicker.mjs.map +1 -0
  49. package/dist/esm/TextTicker/TextTicker.module.css.mjs +5 -0
  50. package/dist/esm/TextTicker/TextTicker.module.css.mjs.map +1 -0
  51. package/dist/esm/TextTicker/use-text-ticker.mjs +225 -0
  52. package/dist/esm/TextTicker/use-text-ticker.mjs.map +1 -0
  53. package/dist/esm/Typewriter/Typewriter.mjs +85 -0
  54. package/dist/esm/Typewriter/Typewriter.mjs.map +1 -0
  55. package/dist/esm/Typewriter/Typewriter.module.css.mjs +5 -0
  56. package/dist/esm/Typewriter/Typewriter.module.css.mjs.map +1 -0
  57. package/dist/esm/Typewriter/use-typewriter.mjs +142 -0
  58. package/dist/esm/Typewriter/use-typewriter.mjs.map +1 -0
  59. package/dist/esm/index.mjs +5 -0
  60. package/dist/esm/index.mjs.map +1 -0
  61. package/dist/styles.css +1 -0
  62. package/dist/styles.layer.css +1 -0
  63. package/dist/types/NumberTicker/NumberTicker.d.ts +53 -0
  64. package/dist/types/NumberTicker/use-number-ticker.d.ts +88 -0
  65. package/dist/types/Spinner/Spinner.d.ts +93 -0
  66. package/dist/types/TextAnimate.d.ts +174 -0
  67. package/dist/types/TextTicker/TextTicker.d.ts +49 -0
  68. package/dist/types/TextTicker/use-text-ticker.d.ts +114 -0
  69. package/dist/types/Typewriter/Typewriter.d.ts +67 -0
  70. package/dist/types/Typewriter/use-typewriter.d.ts +67 -0
  71. package/dist/types/index.d.mts +9 -0
  72. package/dist/types/index.d.ts +9 -0
  73. package/package.json +45 -0
@@ -0,0 +1,93 @@
1
+ import React from 'react';
2
+ import { type BoxProps, type MantineSize, type PolymorphicFactory, type StylesApiProps } from '@mantine/core';
3
+ export type SpinnerStylesNames = 'root' | 'char' | 'container';
4
+ export type SpinnerCssVariables = {
5
+ root: '--text-animate-spinner-radius' | '--text-animate-spinner-speed' | '--text-animate-spinner-char-offset';
6
+ };
7
+ export interface SpinnerBaseProps {
8
+ /**
9
+ * The text content to animate
10
+ */
11
+ children: string;
12
+ /**
13
+ * The radius of the circle in pixels or Mantine size
14
+ * @default "md"
15
+ */
16
+ radius?: MantineSize | number | string;
17
+ /**
18
+ * The rotation speed in seconds per full rotation
19
+ * @default 10
20
+ */
21
+ speed?: number;
22
+ /**
23
+ * The rotation direction
24
+ * @default "clockwise"
25
+ */
26
+ direction?: 'clockwise' | 'counterclockwise';
27
+ /**
28
+ * Whether the spinner is currently rotating
29
+ * @default true
30
+ */
31
+ animate?: boolean;
32
+ /**
33
+ * Character offset in degrees (0-360)
34
+ * @default 0
35
+ */
36
+ charOffset?: number;
37
+ /**
38
+ * Whether to reverse the text direction
39
+ * @default false
40
+ */
41
+ reverseText?: boolean;
42
+ /**
43
+ * Whether to repeat the text to fill the circle
44
+ * @default false
45
+ */
46
+ repeatText?: boolean;
47
+ /**
48
+ * Number of times to repeat the text (only used if repeatText is true)
49
+ * @default 1
50
+ */
51
+ repeatCount?: number;
52
+ }
53
+ export interface SpinnerProps extends BoxProps, SpinnerBaseProps, StylesApiProps<SpinnerFactory> {
54
+ }
55
+ export type SpinnerFactory = PolymorphicFactory<{
56
+ props: SpinnerProps;
57
+ defaultComponent: 'div';
58
+ defaultRef: HTMLDivElement;
59
+ stylesNames: SpinnerStylesNames;
60
+ vars: SpinnerCssVariables;
61
+ }>;
62
+ /**
63
+ * Spinner Component
64
+ *
65
+ * A component that displays text in a circle and rotates it.
66
+ */
67
+ export declare const Spinner: (<C = "div">(props: import("@mantine/core").PolymorphicComponentProps<C, SpinnerProps>) => React.ReactElement) & Omit<React.FunctionComponent<(SpinnerProps & {
68
+ component?: any;
69
+ } & Omit<Omit<any, "ref">, "component" | keyof SpinnerProps> & {
70
+ ref?: any;
71
+ renderRoot?: (props: any) => any;
72
+ }) | (SpinnerProps & {
73
+ component: React.ElementType;
74
+ renderRoot?: (props: Record<string, any>) => any;
75
+ })>, never> & import("@mantine/core/lib/core/factory/factory").ThemeExtend<{
76
+ props: SpinnerProps;
77
+ defaultComponent: "div";
78
+ defaultRef: HTMLDivElement;
79
+ stylesNames: SpinnerStylesNames;
80
+ vars: SpinnerCssVariables;
81
+ }> & import("@mantine/core/lib/core/factory/factory").ComponentClasses<{
82
+ props: SpinnerProps;
83
+ defaultComponent: "div";
84
+ defaultRef: HTMLDivElement;
85
+ stylesNames: SpinnerStylesNames;
86
+ vars: SpinnerCssVariables;
87
+ }> & import("@mantine/core/lib/core/factory/polymorphic-factory").PolymorphicComponentWithProps<{
88
+ props: SpinnerProps;
89
+ defaultComponent: "div";
90
+ defaultRef: HTMLDivElement;
91
+ stylesNames: SpinnerStylesNames;
92
+ vars: SpinnerCssVariables;
93
+ }>;
@@ -0,0 +1,174 @@
1
+ import React from 'react';
2
+ import { type BoxProps, type MantineSize, type PolymorphicFactory, type StylesApiProps } from '@mantine/core';
3
+ import { NumberTicker } from './NumberTicker/NumberTicker';
4
+ import { Spinner } from './Spinner/Spinner';
5
+ import { TextTicker } from './TextTicker/TextTicker';
6
+ import { Typewriter } from './Typewriter/Typewriter';
7
+ /**
8
+ * Type defining how text should be split for animation
9
+ * - text: Animate the entire text as one unit
10
+ * - word: Animate each word separately
11
+ * - character: Animate each character separately
12
+ * - line: Animate each line separately (split by newlines)
13
+ */
14
+ export type AnimationType = 'text' | 'word' | 'character' | 'line';
15
+ /**
16
+ * Available animation variants
17
+ */
18
+ export type AnimationVariant = 'fade' | 'blur' | 'scale' | 'slideUp' | 'slideDown' | 'slideUpElastic' | 'slideDownElastic' | 'slideLeft' | 'slideRight' | 'slideLeftElastic' | 'slideRightElastic' | 'blurUp' | 'blurDown';
19
+ /**
20
+ * Animation direction
21
+ */
22
+ type AnimationDirection = 'in' | 'out' | 'static' | 'none' | false | undefined;
23
+ interface AnimateProps {
24
+ /**
25
+ * Controls the distance for slide animations (in pixels)
26
+ * @default 20
27
+ */
28
+ translateDistance?: MantineSize;
29
+ /**
30
+ * Controls the scale factor for scale animations
31
+ * For scaleUp: initial scale = 1 - scaleAmount (e.g., 0.8 means start at 0.2)
32
+ * For scaleDown: initial scale = 1 + scaleAmount (e.g., 0.8 means start at 1.8)
33
+ * @default 0.8
34
+ */
35
+ scaleAmount?: number;
36
+ /**
37
+ * Controls the blur amount for blur animations (in pixels)
38
+ * @default 10
39
+ */
40
+ blurAmount?: MantineSize;
41
+ }
42
+ export type TextAnimateStylesNames = 'root' | 'segment';
43
+ export type TextAnimateCssVariables = {
44
+ root: '--text-animate-translation-distance' | '--text-animate-blur-amount' | '--text-animate-scale-amount';
45
+ };
46
+ export type TextAnimateDirection = 'horizontal' | 'vertical';
47
+ export type TextAnimateIn = 'positive' | 'negative';
48
+ export type TextAnimateOut = TextAnimateIn;
49
+ export interface TextAnimateBaseProps {
50
+ /**
51
+ * The text content to animate
52
+ */
53
+ children: string;
54
+ /**
55
+ * The class name to be applied to each segment
56
+ */
57
+ segmentClassName?: string;
58
+ /**
59
+ * The delay before the animation starts (in seconds)
60
+ * @default 0
61
+ */
62
+ delay?: number;
63
+ /**
64
+ * The duration of the animation (in seconds)
65
+ * @default 0.3
66
+ */
67
+ duration?: number;
68
+ /**
69
+ * How to split the text for animation
70
+ * @default "word"
71
+ */
72
+ by?: AnimationType;
73
+ /**
74
+ * Controls the animation direction
75
+ * - `in`: Animate elements in (appear)
76
+ * - `out`: Animate elements out (disappear)
77
+ * - `static`: Do not animate
78
+ * - `none`: Do not animate
79
+ * @default undefined (no animation)
80
+ */
81
+ animate?: AnimationDirection;
82
+ /**
83
+ * The animation preset to use
84
+ * @default "fadeIn"
85
+ */
86
+ animation?: AnimationVariant;
87
+ /**
88
+ * The delay between each segment's animation (in seconds)
89
+ * This controls the staggered timing between segments
90
+ * @default Based on animation type (0.03-0.06)
91
+ */
92
+ segmentDelay?: number;
93
+ /**
94
+ * Animation properties to control intensity of animations
95
+ * @default { translateDistance: 20, scaleAmount: 0.8, blurAmount: 10 }
96
+ */
97
+ animateProps?: AnimateProps;
98
+ /**
99
+ * Callback function to be called when the animation starts
100
+ * @param animate The direction of the animation
101
+ */
102
+ onAnimationStart?: (animate: 'in' | 'out') => void;
103
+ /**
104
+ * Callback function to be called when the animation ends
105
+ * @param animate The direction of the animation
106
+ */
107
+ onAnimationEnd?: (animate: 'in' | 'out') => void;
108
+ }
109
+ export interface TextAnimateProps extends BoxProps, TextAnimateBaseProps, StylesApiProps<TextAnimateFactory> {
110
+ }
111
+ export type TextAnimateFactory = PolymorphicFactory<{
112
+ props: TextAnimateProps;
113
+ defaultComponent: 'div';
114
+ defaultRef: HTMLDivElement;
115
+ stylesNames: TextAnimateStylesNames;
116
+ vars: TextAnimateCssVariables;
117
+ staticComponents: {
118
+ Typewriter: typeof Typewriter;
119
+ Spinner: typeof Spinner;
120
+ NumberTicker: typeof NumberTicker;
121
+ TextTicker: typeof TextTicker;
122
+ };
123
+ }>;
124
+ export declare const TextAnimate: (<C = "div">(props: import("@mantine/core").PolymorphicComponentProps<C, TextAnimateProps>) => React.ReactElement) & Omit<React.FunctionComponent<(TextAnimateProps & {
125
+ component?: any;
126
+ } & Omit<Omit<any, "ref">, "component" | keyof TextAnimateProps> & {
127
+ ref?: any;
128
+ renderRoot?: (props: any) => any;
129
+ }) | (TextAnimateProps & {
130
+ component: React.ElementType;
131
+ renderRoot?: (props: Record<string, any>) => any;
132
+ })>, never> & import("@mantine/core/lib/core/factory/factory").ThemeExtend<{
133
+ props: TextAnimateProps;
134
+ defaultComponent: "div";
135
+ defaultRef: HTMLDivElement;
136
+ stylesNames: TextAnimateStylesNames;
137
+ vars: TextAnimateCssVariables;
138
+ staticComponents: {
139
+ Typewriter: typeof Typewriter;
140
+ Spinner: typeof Spinner;
141
+ NumberTicker: typeof NumberTicker;
142
+ TextTicker: typeof TextTicker;
143
+ };
144
+ }> & import("@mantine/core/lib/core/factory/factory").ComponentClasses<{
145
+ props: TextAnimateProps;
146
+ defaultComponent: "div";
147
+ defaultRef: HTMLDivElement;
148
+ stylesNames: TextAnimateStylesNames;
149
+ vars: TextAnimateCssVariables;
150
+ staticComponents: {
151
+ Typewriter: typeof Typewriter;
152
+ Spinner: typeof Spinner;
153
+ NumberTicker: typeof NumberTicker;
154
+ TextTicker: typeof TextTicker;
155
+ };
156
+ }> & import("@mantine/core/lib/core/factory/polymorphic-factory").PolymorphicComponentWithProps<{
157
+ props: TextAnimateProps;
158
+ defaultComponent: "div";
159
+ defaultRef: HTMLDivElement;
160
+ stylesNames: TextAnimateStylesNames;
161
+ vars: TextAnimateCssVariables;
162
+ staticComponents: {
163
+ Typewriter: typeof Typewriter;
164
+ Spinner: typeof Spinner;
165
+ NumberTicker: typeof NumberTicker;
166
+ TextTicker: typeof TextTicker;
167
+ };
168
+ }> & {
169
+ Typewriter: typeof Typewriter;
170
+ Spinner: typeof Spinner;
171
+ NumberTicker: typeof NumberTicker;
172
+ TextTicker: typeof TextTicker;
173
+ };
174
+ export {};
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import { type BoxProps, type PolymorphicFactory, type StylesApiProps } from '@mantine/core';
3
+ import { type TextTickerBaseProps } from './use-text-ticker';
4
+ export type TextTickerStylesNames = 'root';
5
+ export type TextTickerCssVariables = {
6
+ root: '--text-ticker-animation-duration' | '--text-ticker-animation-delay';
7
+ };
8
+ export interface TextTickerProps extends BoxProps, TextTickerBaseProps, StylesApiProps<TextTickerFactory> {
9
+ }
10
+ export type TextTickerFactory = PolymorphicFactory<{
11
+ props: TextTickerProps;
12
+ defaultComponent: 'p';
13
+ defaultRef: HTMLParagraphElement;
14
+ stylesNames: TextTickerStylesNames;
15
+ vars: TextTickerCssVariables;
16
+ }>;
17
+ /**
18
+ * TextTicker Component
19
+ *
20
+ * A component that animates text from random characters to a target string.
21
+ * This implementation uses the useTextTicker hook internally.
22
+ */
23
+ export declare const TextTicker: (<C = "p">(props: import("@mantine/core").PolymorphicComponentProps<C, TextTickerProps>) => React.ReactElement) & Omit<React.FunctionComponent<(TextTickerProps & {
24
+ component?: any;
25
+ } & Omit<Omit<any, "ref">, "component" | keyof TextTickerProps> & {
26
+ ref?: any;
27
+ renderRoot?: (props: any) => any;
28
+ }) | (TextTickerProps & {
29
+ component: React.ElementType;
30
+ renderRoot?: (props: Record<string, any>) => any;
31
+ })>, never> & import("@mantine/core/lib/core/factory/factory").ThemeExtend<{
32
+ props: TextTickerProps;
33
+ defaultComponent: "p";
34
+ defaultRef: HTMLParagraphElement;
35
+ stylesNames: TextTickerStylesNames;
36
+ vars: TextTickerCssVariables;
37
+ }> & import("@mantine/core/lib/core/factory/factory").ComponentClasses<{
38
+ props: TextTickerProps;
39
+ defaultComponent: "p";
40
+ defaultRef: HTMLParagraphElement;
41
+ stylesNames: TextTickerStylesNames;
42
+ vars: TextTickerCssVariables;
43
+ }> & import("@mantine/core/lib/core/factory/polymorphic-factory").PolymorphicComponentWithProps<{
44
+ props: TextTickerProps;
45
+ defaultComponent: "p";
46
+ defaultRef: HTMLParagraphElement;
47
+ stylesNames: TextTickerStylesNames;
48
+ vars: TextTickerCssVariables;
49
+ }>;
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Available easing functions for the animation
3
+ */
4
+ export type TextTickerEasing = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out';
5
+ /**
6
+ * Character sets for random characters
7
+ */
8
+ export type TextTickerCharacterSet = 'alphanumeric' | 'alphabetic' | 'numeric' | 'symbols' | 'custom';
9
+ /**
10
+ * Direction for revealing the target text
11
+ */
12
+ export type TextTickerRevealDirection = 'left-to-right' | 'right-to-left' | 'center-out' | 'random';
13
+ /**
14
+ * Initial text display options
15
+ */
16
+ export type TextTickerInitialDisplay = 'none' | 'random' | 'target';
17
+ /**
18
+ * Base props shared between TextTicker component and useTextTicker hook
19
+ */
20
+ export interface TextTickerBaseProps {
21
+ /**
22
+ * The target text to animate to
23
+ */
24
+ value: string;
25
+ /**
26
+ * Initial text display option
27
+ * - `none`: Display nothing until animation starts
28
+ * - `random`: Display random characters until animation starts
29
+ * - `target`: Display the target text immediately
30
+ * @default "random"
31
+ */
32
+ initialText?: TextTickerInitialDisplay;
33
+ /**
34
+ * Whether the animation should be active
35
+ * @default true
36
+ */
37
+ animate?: boolean;
38
+ /**
39
+ * Character set to use for random characters
40
+ * @default "alphanumeric"
41
+ */
42
+ characterSet?: TextTickerCharacterSet;
43
+ /**
44
+ * Custom characters to use when characterSet is `custom`
45
+ * @default ""
46
+ */
47
+ customCharacters?: string;
48
+ /**
49
+ * Delay before starting the animation in seconds
50
+ * @default 0
51
+ */
52
+ delay?: number;
53
+ /**
54
+ * Animation speed multiplier (higher = faster)
55
+ * @default 1
56
+ */
57
+ speed?: number;
58
+ /**
59
+ * Easing function for the animation
60
+ * @default "ease-out"
61
+ */
62
+ easing?: TextTickerEasing;
63
+ /**
64
+ * Speed multiplier for random character changes (higher = more frequent changes)
65
+ * @default 1
66
+ */
67
+ randomChangeSpeed?: number;
68
+ /**
69
+ * Direction for revealing the target text
70
+ * @default "left-to-right"
71
+ */
72
+ revealDirection?: TextTickerRevealDirection;
73
+ /**
74
+ * Callback function called when animation completes
75
+ */
76
+ onCompleted?: () => void;
77
+ }
78
+ /**
79
+ * Hook props interface extending the base props
80
+ */
81
+ export interface UseTextTickerProps extends TextTickerBaseProps {
82
+ }
83
+ /**
84
+ * Return value interface for the useTextTicker hook
85
+ */
86
+ export interface UseTextTickerResult {
87
+ /**
88
+ * The current text being displayed
89
+ */
90
+ text: string;
91
+ /**
92
+ * Function to start the animation
93
+ */
94
+ start: () => void;
95
+ /**
96
+ * Function to stop the animation while keeping the current text
97
+ */
98
+ stop: () => void;
99
+ /**
100
+ * Function to reset the animation to the initial text
101
+ */
102
+ reset: () => void;
103
+ /**
104
+ * Whether the animation is currently running
105
+ */
106
+ isAnimating: boolean;
107
+ }
108
+ /**
109
+ * Hook that provides text ticker animation functionality
110
+ *
111
+ * This hook powers the TextTicker component and can be used independently
112
+ * for more advanced use cases.
113
+ */
114
+ export declare function useTextTicker({ value, initialText, animate, characterSet, customCharacters, delay, speed, easing, randomChangeSpeed, revealDirection, onCompleted, }: UseTextTickerProps): UseTextTickerResult;
@@ -0,0 +1,67 @@
1
+ import React from 'react';
2
+ import { type BoxProps, type PolymorphicFactory, type StylesApiProps } from '@mantine/core';
3
+ import { type TypewriterBaseProps } from './use-typewriter';
4
+ export type TypewriterStylesNames = 'root' | 'cursor';
5
+ export type TypewriterCssVariables = {};
6
+ export interface TypewriterComponentProps extends TypewriterBaseProps {
7
+ /**
8
+ * The left section to display before the text
9
+ */
10
+ leftSection?: React.ReactNode;
11
+ /**
12
+ * Whether to show a cursor
13
+ * @default true
14
+ */
15
+ withCursor?: boolean;
16
+ /**
17
+ * The cursor character or ReactNode
18
+ * @default "|"
19
+ */
20
+ cursorChar?: React.ReactNode | string;
21
+ /**
22
+ * Whether the cursor should blink
23
+ * @default true
24
+ */
25
+ withBlink?: boolean;
26
+ }
27
+ export interface TypewriterProps extends BoxProps, TypewriterComponentProps, StylesApiProps<TypewriterFactory> {
28
+ }
29
+ export type TypewriterFactory = PolymorphicFactory<{
30
+ props: TypewriterProps;
31
+ defaultComponent: 'p';
32
+ defaultRef: HTMLParagraphElement;
33
+ stylesNames: TypewriterStylesNames;
34
+ vars: TypewriterCssVariables;
35
+ }>;
36
+ /**
37
+ * Typewriter Component
38
+ *
39
+ * A component that creates a typewriter effect using TextAnimate.
40
+ */
41
+ export declare const Typewriter: (<C = "p">(props: import("@mantine/core").PolymorphicComponentProps<C, TypewriterProps>) => React.ReactElement) & Omit<React.FunctionComponent<(TypewriterProps & {
42
+ component?: any;
43
+ } & Omit<Omit<any, "ref">, "component" | keyof TypewriterProps> & {
44
+ ref?: any;
45
+ renderRoot?: (props: any) => any;
46
+ }) | (TypewriterProps & {
47
+ component: React.ElementType;
48
+ renderRoot?: (props: Record<string, any>) => any;
49
+ })>, never> & import("@mantine/core/lib/core/factory/factory").ThemeExtend<{
50
+ props: TypewriterProps;
51
+ defaultComponent: "p";
52
+ defaultRef: HTMLParagraphElement;
53
+ stylesNames: TypewriterStylesNames;
54
+ vars: TypewriterCssVariables;
55
+ }> & import("@mantine/core/lib/core/factory/factory").ComponentClasses<{
56
+ props: TypewriterProps;
57
+ defaultComponent: "p";
58
+ defaultRef: HTMLParagraphElement;
59
+ stylesNames: TypewriterStylesNames;
60
+ vars: TypewriterCssVariables;
61
+ }> & import("@mantine/core/lib/core/factory/polymorphic-factory").PolymorphicComponentWithProps<{
62
+ props: TypewriterProps;
63
+ defaultComponent: "p";
64
+ defaultRef: HTMLParagraphElement;
65
+ stylesNames: TypewriterStylesNames;
66
+ vars: TypewriterCssVariables;
67
+ }>;
@@ -0,0 +1,67 @@
1
+ export interface TypewriterBaseProps {
2
+ /**
3
+ * The text or array of texts to display in typewriter effect
4
+ */
5
+ value: string | string[];
6
+ /**
7
+ * Controls if the animation is running (`true`) or reset (false)
8
+ * @default true
9
+ */
10
+ animate?: boolean;
11
+ /**
12
+ * Whether to display text in multiple lines
13
+ * @default false
14
+ */
15
+ multiline?: boolean;
16
+ /**
17
+ * The typing speed in seconds per character
18
+ * @default 0.03
19
+ */
20
+ speed?: number;
21
+ /**
22
+ * The delay between text changes in milliseconds (when using multiple texts)
23
+ * @default 2000
24
+ */
25
+ delay?: number;
26
+ /**
27
+ * Whether to loop through the texts
28
+ * @default true
29
+ */
30
+ loop?: boolean;
31
+ /**
32
+ * Callback function to be called when the typing animation ends
33
+ */
34
+ onTypeEnd?: () => void;
35
+ /**
36
+ * Callback function to be called when the typing animation is looped
37
+ * and the animation is about to start again
38
+ */
39
+ onTypeLoop?: () => void;
40
+ }
41
+ export interface UseTypewriterResult {
42
+ /**
43
+ * The current text being displayed
44
+ * If multiline is true, this will be an array of strings
45
+ */
46
+ text: string | string[];
47
+ /**
48
+ * Whether the typewriter is currently typing
49
+ */
50
+ isTyping: boolean;
51
+ /**
52
+ * Start the typewriter animation
53
+ */
54
+ start: () => void;
55
+ /**
56
+ * Stop the typewriter animation
57
+ */
58
+ stop: () => void;
59
+ /**
60
+ * Reset the typewriter to its initial state
61
+ */
62
+ reset: () => void;
63
+ }
64
+ /**
65
+ * A hook that creates a typewriter effect
66
+ */
67
+ export declare function useTypewriter(options: TypewriterBaseProps): UseTypewriterResult;
@@ -0,0 +1,9 @@
1
+ export { TextAnimate } from './TextAnimate';
2
+ export type { TextAnimateBaseProps, TextAnimateCssVariables, TextAnimateDirection, TextAnimateFactory, TextAnimateIn, TextAnimateOut, TextAnimateProps, } from './TextAnimate';
3
+ export type { NumberTickerFactory, NumberTickerProps } from './NumberTicker/NumberTicker';
4
+ export type { SpinnerFactory, SpinnerProps } from './Spinner/Spinner';
5
+ export type { TextTickerFactory, TextTickerProps } from './TextTicker/TextTicker';
6
+ export type { TypewriterFactory, TypewriterProps } from './Typewriter/Typewriter';
7
+ export { useNumberTicker } from './NumberTicker/use-number-ticker';
8
+ export { useTextTicker } from './TextTicker/use-text-ticker';
9
+ export { useTypewriter } from './Typewriter/use-typewriter';
@@ -0,0 +1,9 @@
1
+ export { TextAnimate } from './TextAnimate';
2
+ export type { TextAnimateBaseProps, TextAnimateCssVariables, TextAnimateDirection, TextAnimateFactory, TextAnimateIn, TextAnimateOut, TextAnimateProps, } from './TextAnimate';
3
+ export type { NumberTickerFactory, NumberTickerProps } from './NumberTicker/NumberTicker';
4
+ export type { SpinnerFactory, SpinnerProps } from './Spinner/Spinner';
5
+ export type { TextTickerFactory, TextTickerProps } from './TextTicker/TextTicker';
6
+ export type { TypewriterFactory, TypewriterProps } from './Typewriter/Typewriter';
7
+ export { useNumberTicker } from './NumberTicker/use-number-ticker';
8
+ export { useTextTicker } from './TextTicker/use-text-ticker';
9
+ export { useTypewriter } from './Typewriter/use-typewriter';
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@gfazioli/mantine-text-animate",
3
+ "version": "1.0.0",
4
+ "description": "TextAnimate component is a wrapper for any component that can be flipped. It is used to create cards, flip boxes and more.",
5
+ "homepage": "https://gfazioli.github.io/mantine-text-animate/",
6
+ "packageManager": "yarn@4.0.1",
7
+ "license": "MIT",
8
+ "author": "Giovambattista Fazioli <giovambattista.fazioli@gmail.com>",
9
+ "keywords": [
10
+ "animation",
11
+ "card",
12
+ "extension",
13
+ "flip",
14
+ "mantine",
15
+ "react",
16
+ "react-component",
17
+ "typescript",
18
+ "widget"
19
+ ],
20
+ "main": "./dist/cjs/index.cjs",
21
+ "module": "./dist/esm/index.mjs",
22
+ "types": "./dist/types/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "import": {
26
+ "types": "./dist/types/index.d.mts",
27
+ "default": "./dist/esm/index.mjs"
28
+ },
29
+ "require": {
30
+ "types": "./dist/types/index.d.ts",
31
+ "default": "./dist/cjs/index.cjs"
32
+ }
33
+ },
34
+ "./styles.css": "./dist/styles.css",
35
+ "./styles.layer.css": "./dist/styles.layer.css"
36
+ },
37
+ "repository": "https://github.com/gfazioli/mantine-text-animate.git",
38
+ "peerDependencies": {
39
+ "@mantine/core": ">=7.0.0",
40
+ "@mantine/hooks": ">=7.0.0",
41
+ "react": "^18.x || ^19.x",
42
+ "react-dom": "^18.x || ^19.x"
43
+ },
44
+ "bugs": "https://github.com/gfazioli/mantine-text-animate/issues"
45
+ }