@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,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ - Demonstrating empathy and kindness toward other people
21
+ - Being respectful of differing opinions, viewpoints, and experiences
22
+ - Giving and gracefully accepting constructive feedback
23
+ - Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ - Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ - The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ - Trolling, insulting or derogatory comments, and personal or political attacks
33
+ - Public or private harassment
34
+ - Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ - Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ ionut.florescu@gmail.com.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
@@ -0,0 +1,18 @@
1
+ # Contributing
2
+
3
+ 👏 Thank you for considering contributing to this project.
4
+
5
+ ## Bug Reports
6
+
7
+ When encountering issues with software or applications, submitting a detailed bug report can significantly help developers in understanding and resolving the problem efficiently. A well-written bug report should include clear steps to reproduce the issue, the expected behavior, and the actual outcome.
8
+
9
+ Furthermore, providing information such as system specifications, error messages, and screenshots can aid in pinpointing the root cause of the bug. By utilizing platforms like GitHub, users can create issue tickets with relevant details, facilitating effective communication between users and developers. Remember, a comprehensive bug report not only assists in bug resolution but also improves the overall quality of the software.
10
+
11
+ 🐛 [GitHub issue](https://github.com/gfazioli/mantine-text-animate/issues)
12
+
13
+
14
+ ## Code contributors
15
+
16
+ Here's a list of all the people who have contributed to the codebase of this project so far:
17
+
18
+ [![Contributors list](https://contrib.rocks/image?repo=gfazioli/mantine-text-animate)](https://github.com/gfazioli/mantine-text-animate/graphs/contributors)
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Giovambattista Fazioli
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,178 @@
1
+ # Mantine TextAnimate Component
2
+
3
+ <div align="center">
4
+
5
+ ![Mantine TextAnimate Component](https://github.com/gfazioli/mantine-text-animate/assets/432181/cf1917a3-e7eb-4ecb-a525-85ff933c601d)
6
+
7
+ </div>
8
+
9
+ ---
10
+
11
+ <div align="center">
12
+
13
+ [![NPM version](https://img.shields.io/npm/v/%40gfazioli%2Fmantine-text-animate?style=for-the-badge)](https://www.npmjs.com/package/@gfazioli/mantine-text-animate)
14
+ [![NPM Downloads](https://img.shields.io/npm/dm/%40gfazioli%2Fmantine-text-animate?style=for-the-badge)](https://www.npmjs.com/package/@gfazioli/mantine-text-animate)
15
+ [![NPM Downloads](https://img.shields.io/npm/dy/%40gfazioli%2Fmantine-text-animate?style=for-the-badge&label=%20&color=f90)](https://www.npmjs.com/package/@gfazioli/mantine-text-animate)
16
+ ![NPM License](https://img.shields.io/npm/l/%40gfazioli%2Fmantine-text-animate?style=for-the-badge)
17
+
18
+ </div>
19
+
20
+ ## Overview
21
+
22
+ This component is created on top of the [Mantine](https://mantine.dev/) library.
23
+
24
+ [![Mantine UI Library](https://img.shields.io/badge/-MANTINE_UI_LIBRARY-blue?style=for-the-badge&labelColor=black&logo=mantine
25
+ )](https://mantine.dev/)
26
+
27
+ The `TextAnimate` component allows you to animate text with various effects.
28
+ Additionally, it provides other sub components such as `TextAnimate.TextTicker`, `TextAnimate.Typewriter`, `TextAnimate.NumberTicker`, and `TextAnimate.Spinner`.
29
+ You can also use three useful hooks: `useTextTicker`, `useTypewriter`, and `useNumberTicker`.
30
+
31
+ [![Video](https://img.shields.io/badge/-Watch_the_Video-blue?style=for-the-badge&labelColor=black&logo=youtube
32
+ )](https://youtu.be/RzRUb3IDcDw)
33
+ [![Demo and Documentation](https://img.shields.io/badge/-Demo_%26_Documentation-blue?style=for-the-badge&labelColor=black&logo=typescript
34
+ )](https://gfazioli.github.io/mantine-text-animate/)
35
+ [![Mantine Extensions HUB](https://img.shields.io/badge/-Mantine_Extensions_Hub-blue?style=for-the-badge&labelColor=blue
36
+ )](https://mantine-extensions.vercel.app/)
37
+
38
+ 👉 You can find more components on the [Mantine Extensions Hub](https://mantine-extensions.vercel.app/) library.
39
+
40
+
41
+ ## Installation
42
+
43
+ ```sh
44
+ npm install @gfazioli/mantine-text-animate
45
+ ```
46
+ or
47
+
48
+ ```sh
49
+ yarn add @gfazioli/mantine-text-animate
50
+ ```
51
+
52
+ After installation import package styles at the root of your application:
53
+
54
+ ```tsx
55
+ import '@gfazioli/mantine-text-animate/styles.css';
56
+ ```
57
+
58
+ ## Usage
59
+
60
+ ```tsx
61
+ import { TextAnimate } from '@gfazioli/mantine-text-animate';
62
+
63
+ function Demo() {
64
+ return (
65
+ <TextAnimate animate="in" animation="slideUp" by="character">
66
+ Mantine TextAnimate component
67
+ </TextAnimate>
68
+ );
69
+ }
70
+ ```
71
+
72
+ ### TextAnimate.Typewriter
73
+
74
+ ```tsx
75
+ import { TextAnimate } from '@gfazioli/mantine-text-animate';
76
+
77
+ function Demo() {
78
+ return (
79
+ <TextAnimate.Typewriter value="Hello, World! Mantine Typewriter component" animate />
80
+ );
81
+ }
82
+ ```
83
+
84
+ #### useTypewriter
85
+
86
+ ```tsx
87
+ import { useTypewriter } from '@gfazioli/mantine-text-animate'
88
+
89
+ function Demo() {
90
+ const { text, start, stop, reset, isTyping } = useTypewriter({
91
+ value: ['Hello', 'From', 'Mantine useTypewriter() hook'],
92
+ });
93
+
94
+ return (
95
+ <div>{text}</div>
96
+ );
97
+ }
98
+ ```
99
+
100
+ ### TextAnimate.Spinner
101
+
102
+ ```tsx
103
+ import { TextAnimate } from '@gfazioli/mantine-text-animate';
104
+
105
+ function Demo() {
106
+ return (
107
+ <TextAnimate.Spinner>★ SPINNING TEXT EXAMPLE ★</TextAnimate.Spinner>
108
+ );
109
+ }
110
+ ```
111
+
112
+ ### TextAnimate.NumberTicker
113
+
114
+
115
+ ```tsx
116
+ import { TextAnimate } from '@gfazioli/mantine-text-animate';
117
+
118
+ function Demo() {
119
+ return (
120
+ <TextAnimate.NumberTicker value={100} animate />
121
+ );
122
+ }
123
+ ```
124
+
125
+ #### useNumberTicker
126
+
127
+ ```tsx
128
+ import { useNumberTicker } from '@gfazioli/mantine-text-animate'
129
+
130
+ function Demo() {
131
+ const { text, isAnimating, start, stop, reset, displayValue } = useNumberTicker({
132
+ value: 64,
133
+ startValue: 0,
134
+ delay: 0,
135
+ decimalPlaces: 0,
136
+ speed: 0.2,
137
+ easing: 'ease-out',
138
+ animate: true,
139
+ });
140
+
141
+ return (
142
+ <div>{text}</div>
143
+ );
144
+ }
145
+ ```
146
+
147
+ ### TextAnimate.TextTicker
148
+
149
+
150
+ ```tsx
151
+ import { TextAnimate } from '@gfazioli/mantine-text-animate';
152
+
153
+ function Demo() {
154
+ return (
155
+ <TextAnimate.TextTicker value="Hello, World! Mantine TextTicker component" animate />
156
+ );
157
+ }
158
+ ```
159
+
160
+ #### useNumberTicker
161
+
162
+ ```tsx
163
+ import { useTextTicker } from '@gfazioli/mantine-text-animate'
164
+
165
+ function Demo() {
166
+ const { text, isAnimating, start, stop, reset } = useTextTicker({
167
+ value: 'Mantine useTextTicker',
168
+ delay: 0,
169
+ speed: 0.2,
170
+ easing: 'ease-out',
171
+ animate: true,
172
+ });
173
+
174
+ return (
175
+ <div>{text}</div>
176
+ );
177
+ }
178
+ ```
@@ -0,0 +1,84 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ var React = require('react');
5
+ var core = require('@mantine/core');
6
+ var useNumberTicker = require('./use-number-ticker.cjs');
7
+ var NumberTicker_module = require('./NumberTicker.module.css.cjs');
8
+
9
+ const defaultProps = {
10
+ startValue: 0,
11
+ delay: 0,
12
+ decimalPlaces: 0,
13
+ speed: 1,
14
+ easing: "ease-out",
15
+ animate: true
16
+ };
17
+ const varsResolver = core.createVarsResolver((_, { delay, speed }) => ({
18
+ root: {
19
+ "--number-ticker-animation-duration": `${1 / (speed || 1)}s`,
20
+ "--number-ticker-animation-delay": `${delay || 0}s`
21
+ }
22
+ }));
23
+ const NumberTicker = core.polymorphicFactory((_props, ref) => {
24
+ const props = core.useProps("NumberTicker", defaultProps, _props);
25
+ const {
26
+ value,
27
+ startValue,
28
+ delay,
29
+ decimalPlaces,
30
+ speed,
31
+ easing,
32
+ animate,
33
+ onCompleted,
34
+ classNames,
35
+ style,
36
+ styles,
37
+ unstyled,
38
+ vars,
39
+ className,
40
+ ...others
41
+ } = props;
42
+ const { text } = useNumberTicker.useNumberTicker({
43
+ value,
44
+ startValue,
45
+ delay,
46
+ decimalPlaces,
47
+ speed,
48
+ easing,
49
+ animate,
50
+ onCompleted
51
+ });
52
+ const getStyles = core.useStyles({
53
+ name: "NumberTicker",
54
+ props,
55
+ classes: NumberTicker_module,
56
+ className,
57
+ style,
58
+ classNames,
59
+ styles,
60
+ unstyled,
61
+ vars,
62
+ varsResolver
63
+ });
64
+ return /* @__PURE__ */ React.createElement(
65
+ core.Box,
66
+ {
67
+ ref,
68
+ ...getStyles("root", {
69
+ style: {
70
+ display: "inline-block",
71
+ fontVariantNumeric: "tabular-nums",
72
+ letterSpacing: "wider"
73
+ }
74
+ }),
75
+ component: "p",
76
+ ...others
77
+ },
78
+ text
79
+ );
80
+ });
81
+ NumberTicker.displayName = "NumberTicker";
82
+
83
+ exports.NumberTicker = NumberTicker;
84
+ //# sourceMappingURL=NumberTicker.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NumberTicker.cjs","sources":["../../../src/NumberTicker/NumberTicker.tsx"],"sourcesContent":["import React from 'react';\nimport {\n Box,\n createVarsResolver,\n polymorphicFactory,\n useProps,\n useStyles,\n type BoxProps,\n type PolymorphicFactory,\n type StylesApiProps,\n} from '@mantine/core';\nimport { useNumberTicker, type NumberTickerBaseProps } from './use-number-ticker';\nimport classes from './NumberTicker.module.css';\n\nexport type NumberTickerStylesNames = 'root';\n\nexport type NumberTickerCssVariables = {\n root: '--number-ticker-animation-duration' | '--number-ticker-animation-delay';\n};\n\nexport type NumberTickerEasing = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out';\n\nexport interface NumberTickerProps\n extends BoxProps,\n NumberTickerBaseProps,\n StylesApiProps<NumberTickerFactory> {}\n\nexport type NumberTickerFactory = PolymorphicFactory<{\n props: NumberTickerProps;\n defaultComponent: 'p';\n defaultRef: HTMLParagraphElement;\n stylesNames: NumberTickerStylesNames;\n vars: NumberTickerCssVariables;\n}>;\n\nconst defaultProps: Partial<NumberTickerProps> = {\n startValue: 0,\n delay: 0,\n decimalPlaces: 0,\n speed: 1,\n easing: 'ease-out',\n animate: true,\n};\n\nconst varsResolver = createVarsResolver<NumberTickerFactory>((_, { delay, speed }) => ({\n root: {\n '--number-ticker-animation-duration': `${1 / (speed || 1)}s`,\n '--number-ticker-animation-delay': `${delay || 0}s`,\n },\n}));\n\n/**\n * NumberTicker Component\n *\n * A component that animates a number counting up or down to a target value.\n * This implementation uses the useNumberTicker hook internally.\n *\n * The animation can be controlled using the `started` prop, which allows\n * you to start and stop the animation programmatically.\n */\nexport const NumberTicker = polymorphicFactory<NumberTickerFactory>((_props, ref) => {\n const props = useProps('NumberTicker', defaultProps, _props);\n\n const {\n value,\n startValue,\n delay,\n decimalPlaces,\n speed,\n easing,\n animate,\n onCompleted,\n\n classNames,\n style,\n styles,\n unstyled,\n vars,\n className,\n\n ...others\n } = props;\n\n // Use the hook with mapped props\n const { text } = useNumberTicker({\n value,\n startValue,\n delay,\n decimalPlaces,\n speed,\n easing,\n animate,\n onCompleted,\n });\n\n const getStyles = useStyles<NumberTickerFactory>({\n name: 'NumberTicker',\n props,\n classes,\n className,\n style,\n classNames,\n styles,\n unstyled,\n vars,\n varsResolver,\n });\n\n return (\n <Box\n ref={ref}\n {...getStyles('root', {\n style: {\n display: 'inline-block',\n fontVariantNumeric: 'tabular-nums',\n letterSpacing: 'wider',\n },\n })}\n component=\"p\"\n {...others}\n >\n {text}\n </Box>\n );\n});\n\nNumberTicker.displayName = 'NumberTicker';\n"],"names":["createVarsResolver","polymorphicFactory","useProps","useNumberTicker","useStyles","classes","Box"],"mappings":";;;;;;;;AAUA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,YAAY,CAAG,CAAA,CAAA,CAAA;AACrB,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,EAAE,CAAC,CAAA;AACf,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAK,EAAE,CAAC,CAAA;AACV,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,EAAE,CAAC,CAAA;AAClB,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAK,EAAE,CAAC,CAAA;AACV,CAAE,CAAA,CAAA,C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,CAAC,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAG,CAAc,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;"}
@@ -0,0 +1,7 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ var classes = {"root":"me_de58e29c"};
5
+
6
+ module.exports = classes;
7
+ //# sourceMappingURL=NumberTicker.module.css.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NumberTicker.module.css.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -0,0 +1,158 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ var React = require('react');
5
+
6
+ const easingFunctions = {
7
+ // No easing, no acceleration
8
+ linear: (t) => t,
9
+ // Accelerating from zero velocity
10
+ "ease-in": (t) => t * t,
11
+ // Decelerating to zero velocity
12
+ "ease-out": (t) => 1 - Math.pow(1 - t, 2),
13
+ // Acceleration until halfway, then deceleration
14
+ "ease-in-out": (t) => t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2
15
+ };
16
+ function useNumberTicker({
17
+ value,
18
+ startValue = 0,
19
+ delay = 0,
20
+ decimalPlaces = 0,
21
+ speed = 1,
22
+ easing = "ease-out",
23
+ animate = true,
24
+ onCompleted
25
+ }) {
26
+ const [displayValue, setDisplayValue] = React.useState(startValue);
27
+ const [isAnimating, setIsAnimating] = React.useState(false);
28
+ const animationRef = React.useRef(null);
29
+ const delayTimerRef = React.useRef(null);
30
+ const startTimeRef = React.useRef(0);
31
+ const animationCompletedRef = React.useRef(false);
32
+ const animateRef = React.useRef(animate);
33
+ const isFirstRenderRef = React.useRef(true);
34
+ const prevValueRef = React.useRef(value);
35
+ const prevStartValueRef = React.useRef(startValue);
36
+ const formatNumber = (num) => {
37
+ return Intl.NumberFormat("en-US", {
38
+ minimumFractionDigits: decimalPlaces,
39
+ maximumFractionDigits: decimalPlaces
40
+ }).format(num);
41
+ };
42
+ const animateFrame = (timestamp, from, to) => {
43
+ if (!startTimeRef.current) {
44
+ startTimeRef.current = timestamp;
45
+ }
46
+ const elapsed = timestamp - startTimeRef.current;
47
+ const duration = 1e3 / speed;
48
+ const progress = Math.min(elapsed / duration, 1);
49
+ const easingFunction = easingFunctions[easing] || easingFunctions["ease-out"];
50
+ const easedProgress = easingFunction(progress);
51
+ const valueRange = to - from;
52
+ const currentValue = from + valueRange * easedProgress;
53
+ setDisplayValue(currentValue);
54
+ if (progress < 1) {
55
+ animationRef.current = requestAnimationFrame((time) => animateFrame(time, from, to));
56
+ } else {
57
+ setDisplayValue(to);
58
+ setIsAnimating(false);
59
+ startTimeRef.current = 0;
60
+ animationCompletedRef.current = true;
61
+ if (onCompleted) {
62
+ onCompleted();
63
+ }
64
+ }
65
+ };
66
+ const cleanupAnimation = () => {
67
+ if (animationRef.current) {
68
+ cancelAnimationFrame(animationRef.current);
69
+ animationRef.current = null;
70
+ }
71
+ if (delayTimerRef.current) {
72
+ clearTimeout(delayTimerRef.current);
73
+ delayTimerRef.current = null;
74
+ }
75
+ };
76
+ const startAnimationFrom = (fromValue, toValue) => {
77
+ if (isAnimating && toValue === value && fromValue === displayValue) return;
78
+ cleanupAnimation();
79
+ startTimeRef.current = 0;
80
+ animationCompletedRef.current = false;
81
+ setIsAnimating(true);
82
+ delayTimerRef.current = setTimeout(() => {
83
+ animationRef.current = requestAnimationFrame(
84
+ (time) => animateFrame(time, fromValue, toValue)
85
+ );
86
+ }, delay * 1e3);
87
+ };
88
+ const start = () => {
89
+ animationCompletedRef.current = false;
90
+ startAnimationFrom(startValue, value);
91
+ };
92
+ const stop = () => {
93
+ cleanupAnimation();
94
+ setIsAnimating(false);
95
+ };
96
+ const reset = () => {
97
+ stop();
98
+ setDisplayValue(startValue);
99
+ animationCompletedRef.current = false;
100
+ };
101
+ React.useEffect(() => {
102
+ if (isFirstRenderRef.current) {
103
+ setDisplayValue(startValue);
104
+ isFirstRenderRef.current = false;
105
+ if (animate) {
106
+ startAnimationFrom(startValue, value);
107
+ }
108
+ }
109
+ }, []);
110
+ React.useEffect(() => {
111
+ if (animate !== animateRef.current) {
112
+ animateRef.current = animate;
113
+ if (animate) {
114
+ animationCompletedRef.current = false;
115
+ cleanupAnimation();
116
+ setDisplayValue(startValue);
117
+ startAnimationFrom(startValue, value);
118
+ } else if (isAnimating) {
119
+ stop();
120
+ }
121
+ }
122
+ }, [animate, value, startValue, isAnimating]);
123
+ React.useEffect(() => {
124
+ const valueChanged = value !== prevValueRef.current;
125
+ const startValueChanged = startValue !== prevStartValueRef.current;
126
+ prevValueRef.current = value;
127
+ prevStartValueRef.current = startValue;
128
+ if (valueChanged || startValueChanged) {
129
+ if (isAnimating) {
130
+ startAnimationFrom(displayValue, value);
131
+ } else if (animationCompletedRef.current && valueChanged) {
132
+ if (animate) {
133
+ startAnimationFrom(displayValue, value);
134
+ }
135
+ } else if (animate) {
136
+ startAnimationFrom(startValue, value);
137
+ } else {
138
+ setDisplayValue(startValue);
139
+ }
140
+ }
141
+ }, [value, startValue, animate, isAnimating, displayValue]);
142
+ React.useEffect(() => {
143
+ return () => {
144
+ cleanupAnimation();
145
+ };
146
+ }, []);
147
+ return {
148
+ text: formatNumber(displayValue),
149
+ displayValue,
150
+ start,
151
+ stop,
152
+ reset,
153
+ isAnimating
154
+ };
155
+ }
156
+
157
+ exports.useNumberTicker = useNumberTicker;
158
+ //# sourceMappingURL=use-number-ticker.cjs.map