@waveso/ui 0.0.10 → 0.1.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.
- package/dist/accordion.d.ts +24 -8
- package/dist/accordion.d.ts.map +1 -0
- package/dist/accordion.js +50 -73
- package/dist/accordion.js.map +1 -1
- package/dist/action-bar.d.ts +83 -0
- package/dist/action-bar.d.ts.map +1 -0
- package/dist/action-bar.js +264 -0
- package/dist/action-bar.js.map +1 -0
- package/dist/alert-dialog.d.ts +56 -21
- package/dist/alert-dialog.d.ts.map +1 -0
- package/dist/alert-dialog.js +75 -127
- package/dist/alert-dialog.js.map +1 -1
- package/dist/alert.d.ts +26 -11
- package/dist/alert.d.ts.map +1 -0
- package/dist/alert.js +37 -68
- package/dist/alert.js.map +1 -1
- package/dist/animate.d.ts +117 -75
- package/dist/animate.d.ts.map +1 -0
- package/dist/animate.js +259 -223
- package/dist/animate.js.map +1 -1
- package/dist/aspect-ratio.d.ts +11 -6
- package/dist/aspect-ratio.d.ts.map +1 -0
- package/dist/aspect-ratio.js +12 -14
- package/dist/aspect-ratio.js.map +1 -1
- package/dist/autocomplete.d.ts +91 -25
- package/dist/autocomplete.d.ts.map +1 -0
- package/dist/autocomplete.js +119 -181
- package/dist/autocomplete.js.map +1 -1
- package/dist/avatar.d.ts +32 -11
- package/dist/avatar.d.ts.map +1 -0
- package/dist/avatar.js +42 -89
- package/dist/avatar.js.map +1 -1
- package/dist/badge.d.ts +15 -8
- package/dist/badge.d.ts.map +1 -0
- package/dist/badge.js +34 -48
- package/dist/badge.js.map +1 -1
- package/dist/breadcrumb.d.ts +35 -11
- package/dist/breadcrumb.d.ts.map +1 -0
- package/dist/breadcrumb.js +60 -110
- package/dist/breadcrumb.js.map +1 -1
- package/dist/button-group.d.ts +26 -13
- package/dist/button-group.d.ts.map +1 -0
- package/dist/button-group.js +38 -76
- package/dist/button-group.js.map +1 -1
- package/dist/button.d.ts +17 -10
- package/dist/button.d.ts.map +1 -0
- package/dist/button.js +50 -3
- package/dist/button.js.map +1 -1
- package/dist/card.d.ts +35 -11
- package/dist/card.d.ts.map +1 -0
- package/dist/card.js +43 -82
- package/dist/card.js.map +1 -1
- package/dist/checkbox.d.ts +6 -4
- package/dist/checkbox.d.ts.map +1 -0
- package/dist/checkbox.js +21 -29
- package/dist/checkbox.js.map +1 -1
- package/dist/collapsible.d.ts +15 -7
- package/dist/collapsible.d.ts.map +1 -0
- package/dist/collapsible.js +19 -8
- package/dist/collapsible.js.map +1 -1
- package/dist/combobox.d.ts +83 -23
- package/dist/combobox.d.ts.map +1 -0
- package/dist/combobox.js +149 -247
- package/dist/combobox.js.map +1 -1
- package/dist/context-menu.d.ts +80 -26
- package/dist/context-menu.d.ts.map +1 -0
- package/dist/context-menu.js +108 -164
- package/dist/context-menu.js.map +1 -1
- package/dist/count.d.ts +45 -31
- package/dist/count.d.ts.map +1 -0
- package/dist/count.js +170 -165
- package/dist/count.js.map +1 -1
- package/dist/dialog.d.ts +61 -28
- package/dist/dialog.d.ts.map +1 -0
- package/dist/dialog.js +77 -120
- package/dist/dialog.js.map +1 -1
- package/dist/direction.d.ts +2 -1
- package/dist/direction.js +3 -3
- package/dist/drawer.d.ts +45 -15
- package/dist/drawer.d.ts.map +1 -0
- package/dist/drawer.js +93 -5
- package/dist/drawer.js.map +1 -1
- package/dist/encrypted-text.d.ts +25 -12
- package/dist/encrypted-text.d.ts.map +1 -0
- package/dist/encrypted-text.js +102 -134
- package/dist/encrypted-text.js.map +1 -1
- package/dist/field.d.ts +37 -21
- package/dist/field.d.ts.map +1 -0
- package/dist/field.js +52 -3
- package/dist/field.js.map +1 -1
- package/dist/film-grain-shader.d.ts +6 -0
- package/dist/film-grain-shader.d.ts.map +1 -0
- package/dist/film-grain-shader.js +88 -0
- package/dist/film-grain-shader.js.map +1 -0
- package/dist/film-grain-webgl.d.ts +20 -0
- package/dist/film-grain-webgl.d.ts.map +1 -0
- package/dist/film-grain-webgl.js +306 -0
- package/dist/film-grain-webgl.js.map +1 -0
- package/dist/film-grain.d.ts +21 -11
- package/dist/film-grain.d.ts.map +1 -0
- package/dist/film-grain.js +28 -420
- package/dist/film-grain.js.map +1 -1
- package/dist/form.d.ts +64 -49
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +112 -91
- package/dist/form.js.map +1 -1
- package/dist/gradient-reveal-text.d.ts +35 -22
- package/dist/gradient-reveal-text.d.ts.map +1 -0
- package/dist/gradient-reveal-text.js +238 -205
- package/dist/gradient-reveal-text.js.map +1 -1
- package/dist/hooks/use-mobile.d.ts +3 -1
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +28 -2
- package/dist/hooks/use-mobile.js.map +1 -1
- package/dist/infinite-scroll.d.ts +29 -15
- package/dist/infinite-scroll.d.ts.map +1 -0
- package/dist/infinite-scroll.js +69 -99
- package/dist/infinite-scroll.js.map +1 -1
- package/dist/input-group.d.ts +41 -18
- package/dist/input-group.d.ts.map +1 -0
- package/dist/input-group.js +80 -6
- package/dist/input-group.js.map +1 -1
- package/dist/input-otp.d.ts +26 -10
- package/dist/input-otp.d.ts.map +1 -0
- package/dist/input-otp.js +40 -70
- package/dist/input-otp.js.map +1 -1
- package/dist/input.d.ts +10 -4
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +16 -3
- package/dist/input.js.map +1 -1
- package/dist/item.d.ts +58 -23
- package/dist/item.d.ts.map +1 -0
- package/dist/item.js +102 -160
- package/dist/item.js.map +1 -1
- package/dist/kbd.d.ts +12 -4
- package/dist/kbd.d.ts.map +1 -0
- package/dist/kbd.js +15 -24
- package/dist/kbd.js.map +1 -1
- package/dist/label.d.ts +9 -4
- package/dist/label.d.ts.map +1 -0
- package/dist/label.js +12 -16
- package/dist/label.js.map +1 -1
- package/dist/lib/focus.d.ts +42 -0
- package/dist/lib/focus.d.ts.map +1 -0
- package/dist/lib/focus.js +21 -0
- package/dist/lib/focus.js.map +1 -0
- package/dist/lib/internal-icons.d.ts +32 -0
- package/dist/lib/internal-icons.d.ts.map +1 -0
- package/dist/lib/internal-icons.js +222 -0
- package/dist/lib/internal-icons.js.map +1 -0
- package/dist/lib/utils.d.ts +4 -2
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +12 -2
- package/dist/lib/utils.js.map +1 -1
- package/dist/masonry.d.ts +25 -11
- package/dist/masonry.d.ts.map +1 -0
- package/dist/masonry.js +188 -229
- package/dist/masonry.js.map +1 -1
- package/dist/menu.d.ts +84 -26
- package/dist/menu.d.ts.map +1 -0
- package/dist/menu.js +141 -4
- package/dist/menu.js.map +1 -1
- package/dist/menubar.d.ts +60 -22
- package/dist/menubar.d.ts.map +1 -0
- package/dist/menubar.js +80 -52
- package/dist/menubar.js.map +1 -1
- package/dist/pagination.d.ts +38 -17
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +68 -107
- package/dist/pagination.js.map +1 -1
- package/dist/popover.d.ts +56 -14
- package/dist/popover.d.ts.map +1 -0
- package/dist/popover.js +62 -87
- package/dist/popover.js.map +1 -1
- package/dist/preview-card.d.ts +28 -9
- package/dist/preview-card.d.ts.map +1 -0
- package/dist/preview-card.js +40 -60
- package/dist/preview-card.js.map +1 -1
- package/dist/progress.d.ts +28 -9
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +35 -60
- package/dist/progress.js.map +1 -1
- package/dist/radio-group.d.ts +14 -8
- package/dist/radio-group.d.ts.map +1 -0
- package/dist/radio-group.js +18 -22
- package/dist/radio-group.js.map +1 -1
- package/dist/radio.d.ts +14 -6
- package/dist/radio.d.ts.map +1 -0
- package/dist/radio.js +24 -3
- package/dist/radio.js.map +1 -1
- package/dist/scroll-area.d.ts +16 -6
- package/dist/scroll-area.d.ts.map +1 -0
- package/dist/scroll-area.js +34 -55
- package/dist/scroll-area.js.map +1 -1
- package/dist/select.d.ts +66 -18
- package/dist/select.d.ts.map +1 -0
- package/dist/select.js +105 -185
- package/dist/select.js.map +1 -1
- package/dist/separator.d.ts +11 -5
- package/dist/separator.d.ts.map +1 -0
- package/dist/separator.js +17 -3
- package/dist/separator.js.map +1 -1
- package/dist/sidebar.d.ts +172 -79
- package/dist/sidebar.d.ts.map +1 -0
- package/dist/sidebar.js +363 -585
- package/dist/sidebar.js.map +1 -1
- package/dist/skeleton.d.ts +8 -3
- package/dist/skeleton.d.ts.map +1 -0
- package/dist/skeleton.js +13 -3
- package/dist/skeleton.js.map +1 -1
- package/dist/slider.d.ts +16 -6
- package/dist/slider.d.ts.map +1 -0
- package/dist/slider.js +40 -67
- package/dist/slider.js.map +1 -1
- package/dist/spinner.d.ts +8 -3
- package/dist/spinner.d.ts.map +1 -0
- package/dist/spinner.js +15 -4
- package/dist/spinner.js.map +1 -1
- package/dist/switch.d.ts +12 -6
- package/dist/switch.d.ts.map +1 -0
- package/dist/switch.js +18 -25
- package/dist/switch.js.map +1 -1
- package/dist/table.d.ts +37 -11
- package/dist/table.d.ts.map +1 -0
- package/dist/table.js +51 -88
- package/dist/table.js.map +1 -1
- package/dist/tabs.d.ts +28 -12
- package/dist/tabs.d.ts.map +1 -0
- package/dist/tabs.js +40 -74
- package/dist/tabs.js.map +1 -1
- package/dist/textarea.d.ts +13 -6
- package/dist/textarea.d.ts.map +1 -0
- package/dist/textarea.js +19 -3
- package/dist/textarea.js.map +1 -1
- package/dist/toast.d.ts +63 -39
- package/dist/toast.d.ts.map +1 -0
- package/dist/toast.js +177 -215
- package/dist/toast.js.map +1 -1
- package/dist/toggle-group.d.ts +26 -12
- package/dist/toggle-group.d.ts.map +1 -0
- package/dist/toggle-group.js +49 -73
- package/dist/toggle-group.js.map +1 -1
- package/dist/toggle.d.ts +17 -10
- package/dist/toggle.d.ts.map +1 -0
- package/dist/toggle.js +38 -3
- package/dist/toggle.js.map +1 -1
- package/dist/tooltip.d.ts +35 -14
- package/dist/tooltip.d.ts.map +1 -0
- package/dist/tooltip.js +52 -3
- package/dist/tooltip.js.map +1 -1
- package/dist/typewriter.d.ts +44 -31
- package/dist/typewriter.d.ts.map +1 -0
- package/dist/typewriter.js +185 -185
- package/dist/typewriter.js.map +1 -1
- package/package.json +6 -6
- package/dist/chunk-45VQAWIM.js +0 -228
- package/dist/chunk-45VQAWIM.js.map +0 -1
- package/dist/chunk-6Y7LPQMO.js +0 -11
- package/dist/chunk-6Y7LPQMO.js.map +0 -1
- package/dist/chunk-76UQO56T.js +0 -19
- package/dist/chunk-76UQO56T.js.map +0 -1
- package/dist/chunk-7F4MPMLJ.js +0 -17
- package/dist/chunk-7F4MPMLJ.js.map +0 -1
- package/dist/chunk-BKTJYX4M.js +0 -143
- package/dist/chunk-BKTJYX4M.js.map +0 -1
- package/dist/chunk-D5XPEJ6T.js +0 -36
- package/dist/chunk-D5XPEJ6T.js.map +0 -1
- package/dist/chunk-DIGOLJIR.js +0 -105
- package/dist/chunk-DIGOLJIR.js.map +0 -1
- package/dist/chunk-IQ7YQ5XA.js +0 -141
- package/dist/chunk-IQ7YQ5XA.js.map +0 -1
- package/dist/chunk-NCHHHWTB.js +0 -85
- package/dist/chunk-NCHHHWTB.js.map +0 -1
- package/dist/chunk-OUFYQLVN.js +0 -56
- package/dist/chunk-OUFYQLVN.js.map +0 -1
- package/dist/chunk-QFSEK4M6.js +0 -22
- package/dist/chunk-QFSEK4M6.js.map +0 -1
- package/dist/chunk-QRW37LRP.js +0 -25
- package/dist/chunk-QRW37LRP.js.map +0 -1
- package/dist/chunk-RPQHL6C5.js +0 -26
- package/dist/chunk-RPQHL6C5.js.map +0 -1
- package/dist/chunk-V4ZX4YCP.js +0 -66
- package/dist/chunk-V4ZX4YCP.js.map +0 -1
- package/dist/chunk-YTSQQTSF.js +0 -44
- package/dist/chunk-YTSQQTSF.js.map +0 -1
- package/dist/chunk-ZZZH3JGW.js +0 -23
- package/dist/chunk-ZZZH3JGW.js.map +0 -1
- package/dist/direction.js.map +0 -1
package/dist/count.d.ts
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
|
+
//#region src/count.d.ts
|
|
4
5
|
interface CountProps {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
6
|
+
/** Target number or Date to count to */
|
|
7
|
+
to: number | Date;
|
|
8
|
+
/** Starting number. Default: 0. Ignored when `to` is a Date. */
|
|
9
|
+
from?: number;
|
|
10
|
+
/** Animation duration in milliseconds. Default: 900. Ignored when `to` is a Date. */
|
|
11
|
+
duration?: number;
|
|
12
|
+
/** Delay before starting in seconds. Default: 0 */
|
|
13
|
+
delay?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Format the value for display.
|
|
16
|
+
* - For numbers: receives the current interpolated number.
|
|
17
|
+
* - For dates: receives remaining milliseconds.
|
|
18
|
+
* Default: toLocaleString() for numbers, dd:hh:mm:ss for dates.
|
|
19
|
+
*/
|
|
20
|
+
format?: (value: number) => string;
|
|
21
|
+
/** Prefix string (e.g., "$"). Default: '' */
|
|
22
|
+
prefix?: string;
|
|
23
|
+
/** Suffix string (e.g., "%", "+"). Default: '' */
|
|
24
|
+
suffix?: string;
|
|
25
|
+
/** Element to render into. Receives the formatted value as children. */
|
|
26
|
+
children: ReactElement;
|
|
27
|
+
/** Trigger once. Default: true */
|
|
28
|
+
once?: boolean;
|
|
29
|
+
/** Easing function. Default: easeOut. Ignored when `to` is a Date. */
|
|
30
|
+
easing?: (t: number) => number;
|
|
31
|
+
/** Called when the count finishes (reaches target or date passes). */
|
|
32
|
+
onComplete?: () => void;
|
|
32
33
|
}
|
|
33
34
|
/** @deprecated Use `Count` instead. `CountUp` is an alias kept for backwards compatibility. */
|
|
34
35
|
type CountUpProps = CountProps;
|
|
@@ -66,8 +67,21 @@ declare function easeOut(t: number): number;
|
|
|
66
67
|
* </Count>
|
|
67
68
|
* ```
|
|
68
69
|
*/
|
|
69
|
-
declare function Count({
|
|
70
|
+
declare function Count({
|
|
71
|
+
to,
|
|
72
|
+
from: start,
|
|
73
|
+
duration,
|
|
74
|
+
delay,
|
|
75
|
+
format,
|
|
76
|
+
prefix,
|
|
77
|
+
suffix,
|
|
78
|
+
children,
|
|
79
|
+
once,
|
|
80
|
+
easing,
|
|
81
|
+
onComplete
|
|
82
|
+
}: CountProps): _$react_jsx_runtime0.JSX.Element;
|
|
70
83
|
/** @deprecated Use `Count` instead */
|
|
71
84
|
declare const CountUp: typeof Count;
|
|
72
|
-
|
|
85
|
+
//#endregion
|
|
73
86
|
export { Count, type CountProps, CountUp, type CountUpProps, easeOut };
|
|
87
|
+
//# sourceMappingURL=count.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"count.d.ts","names":[],"sources":["../src/count.tsx"],"mappings":";;;;UAeU,UAAA;;EAER,EAAA,WAAa,IAAA;EAFL;EAIR,IAAA;;EAEA,QAAA;EAJA;EAMA,KAAA;EAJA;;;;;;EAWA,MAAA,IAAU,KAAA;EAMV;EAJA,MAAA;EAMA;EAJA,MAAA;EAMU;EAJV,QAAA,EAAU,YAAA;EAMA;EAJV,IAAA;EAQG;EANH,MAAA,IAAU,CAAA;;EAEV,UAAA;AAAA;AAI4B;AAAA,KAAzB,YAAA,GAAe,UAAA;;iBAKX,OAAA,CAAQ,CAAA;;AAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwEjB,KAAA,CAAA;EACP,EAAA;EACA,IAAA,EAAM,KAAA;EACN,QAAA;EACA,KAAA;EACA,MAAA;EACA,MAAA;EACA,MAAA;EACA,QAAA;EACA,IAAA;EACA,MAAA;EACA;AAAA,GACC,UAAA,GAAU,oBAAA,CAAA,GAAA,CAAA,OAAA;;cAyLP,OAAA,SAAO,KAAA"}
|
package/dist/count.js
CHANGED
|
@@ -1,176 +1,181 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { jsx } from
|
|
4
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { cloneElement, isValidElement, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { useInView } from "motion/react";
|
|
5
|
+
//#region src/count.tsx
|
|
6
|
+
/** Cubic ease-out: fast start, smooth deceleration */
|
|
5
7
|
function easeOut(t) {
|
|
6
|
-
|
|
8
|
+
return 1 - Math.pow(1 - t, 3);
|
|
7
9
|
}
|
|
8
10
|
function formatCountdown(ms) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
|
|
11
|
+
if (ms <= 0) return "00:00:00";
|
|
12
|
+
const totalSeconds = Math.floor(ms / 1e3);
|
|
13
|
+
const days = Math.floor(totalSeconds / 86400);
|
|
14
|
+
const hours = Math.floor(totalSeconds % 86400 / 3600);
|
|
15
|
+
const minutes = Math.floor(totalSeconds % 3600 / 60);
|
|
16
|
+
const seconds = totalSeconds % 60;
|
|
17
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
18
|
+
if (days > 0) return `${days}d ${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
|
|
19
|
+
return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
|
|
20
20
|
}
|
|
21
21
|
function mergeRef(internalRef, externalRef) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
};
|
|
22
|
+
return (el) => {
|
|
23
|
+
internalRef.current = el;
|
|
24
|
+
if (typeof externalRef === "function") externalRef(el);
|
|
25
|
+
else if (externalRef && typeof externalRef === "object") externalRef.current = el;
|
|
26
|
+
};
|
|
29
27
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Animated number counter. Counts up, counts down, or live-counts to a date.
|
|
30
|
+
*
|
|
31
|
+
* Direction is automatic — if `from < to` it counts up, if `from > to` it
|
|
32
|
+
* counts down. When `to` is a Date, it becomes a live countdown that ticks
|
|
33
|
+
* every second.
|
|
34
|
+
*
|
|
35
|
+
* Zero wrapper — injects the formatted value as children via cloneElement.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* // Count up
|
|
40
|
+
* <Count to={1234}>
|
|
41
|
+
* <span className="text-4xl font-bold tabular-nums" />
|
|
42
|
+
* </Count>
|
|
43
|
+
*
|
|
44
|
+
* // Count down
|
|
45
|
+
* <Count from={100} to={0} onComplete={() => alert("Done!")}>
|
|
46
|
+
* <span className="text-4xl font-bold tabular-nums" />
|
|
47
|
+
* </Count>
|
|
48
|
+
*
|
|
49
|
+
* // Live countdown to a date
|
|
50
|
+
* <Count to={new Date("2026-04-01T00:00:00")}>
|
|
51
|
+
* <span className="text-2xl font-mono tabular-nums" />
|
|
52
|
+
* </Count>
|
|
53
|
+
*
|
|
54
|
+
* // Custom date format
|
|
55
|
+
* <Count to={launchDate} format={(ms) => `${Math.ceil(ms / 86400000)} days left`}>
|
|
56
|
+
* <span className="text-xl" />
|
|
57
|
+
* </Count>
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
function Count({ to, from: start = 0, duration = 900, delay = 0, format, prefix = "", suffix = "", children, once = true, easing = easeOut, onComplete }) {
|
|
61
|
+
if (to instanceof Date) return /* @__PURE__ */ jsx(DateCount, {
|
|
62
|
+
to,
|
|
63
|
+
delay,
|
|
64
|
+
format,
|
|
65
|
+
prefix,
|
|
66
|
+
suffix,
|
|
67
|
+
once,
|
|
68
|
+
onComplete,
|
|
69
|
+
children
|
|
70
|
+
});
|
|
71
|
+
return /* @__PURE__ */ jsx(NumberCount, {
|
|
72
|
+
to,
|
|
73
|
+
from: start,
|
|
74
|
+
duration,
|
|
75
|
+
delay,
|
|
76
|
+
format,
|
|
77
|
+
prefix,
|
|
78
|
+
suffix,
|
|
79
|
+
once,
|
|
80
|
+
easing,
|
|
81
|
+
onComplete,
|
|
82
|
+
children
|
|
83
|
+
});
|
|
75
84
|
}
|
|
76
|
-
function NumberCount({
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const childProps = children.props;
|
|
123
|
-
const existingRef = childProps.ref;
|
|
124
|
-
return cloneElement(children, {
|
|
125
|
-
ref: mergeRef(ref, existingRef),
|
|
126
|
-
children: `${prefix}${formatFn(display)}${suffix}`
|
|
127
|
-
});
|
|
85
|
+
function NumberCount({ to, from: start, duration, delay, format, prefix, suffix, children, once, easing, onComplete }) {
|
|
86
|
+
const ref = useRef(null);
|
|
87
|
+
const isInView = useInView(ref, {
|
|
88
|
+
once,
|
|
89
|
+
margin: "-50px"
|
|
90
|
+
});
|
|
91
|
+
const [display, setDisplay] = useState(start);
|
|
92
|
+
const hasAnimated = useRef(false);
|
|
93
|
+
const formatFn = format ?? ((n) => Number.isInteger(to) ? Math.round(n).toLocaleString() : n.toLocaleString());
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (!isInView || hasAnimated.current) return;
|
|
96
|
+
hasAnimated.current = true;
|
|
97
|
+
const delayMs = delay * 1e3;
|
|
98
|
+
let raf;
|
|
99
|
+
let startTime;
|
|
100
|
+
const timer = setTimeout(() => {
|
|
101
|
+
const animate = (timestamp) => {
|
|
102
|
+
if (!startTime) startTime = timestamp;
|
|
103
|
+
const elapsed = timestamp - startTime;
|
|
104
|
+
const progress = Math.min(elapsed / duration, 1);
|
|
105
|
+
const easedProgress = easing(progress);
|
|
106
|
+
setDisplay(start + (to - start) * easedProgress);
|
|
107
|
+
if (progress < 1) raf = requestAnimationFrame(animate);
|
|
108
|
+
else onComplete?.();
|
|
109
|
+
};
|
|
110
|
+
raf = requestAnimationFrame(animate);
|
|
111
|
+
}, delayMs);
|
|
112
|
+
return () => {
|
|
113
|
+
clearTimeout(timer);
|
|
114
|
+
cancelAnimationFrame(raf);
|
|
115
|
+
};
|
|
116
|
+
}, [
|
|
117
|
+
isInView,
|
|
118
|
+
to,
|
|
119
|
+
start,
|
|
120
|
+
duration,
|
|
121
|
+
delay,
|
|
122
|
+
easing,
|
|
123
|
+
onComplete
|
|
124
|
+
]);
|
|
125
|
+
if (!isValidElement(children)) return children;
|
|
126
|
+
const existingRef = children.props.ref;
|
|
127
|
+
return cloneElement(children, {
|
|
128
|
+
ref: mergeRef(ref, existingRef),
|
|
129
|
+
children: `${prefix}${formatFn(display)}${suffix}`
|
|
130
|
+
});
|
|
128
131
|
}
|
|
129
|
-
function DateCount({
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
132
|
+
function DateCount({ to, delay, format, prefix, suffix, children, once, onComplete }) {
|
|
133
|
+
const ref = useRef(null);
|
|
134
|
+
const isInView = useInView(ref, {
|
|
135
|
+
once,
|
|
136
|
+
margin: "-50px"
|
|
137
|
+
});
|
|
138
|
+
const [remaining, setRemaining] = useState(() => Math.max(0, to.getTime() - Date.now()));
|
|
139
|
+
const [started, setStarted] = useState(false);
|
|
140
|
+
const completedRef = useRef(false);
|
|
141
|
+
const formatFn = format ?? formatCountdown;
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (!isInView || started) return;
|
|
144
|
+
const timer = setTimeout(() => setStarted(true), delay * 1e3);
|
|
145
|
+
return () => clearTimeout(timer);
|
|
146
|
+
}, [
|
|
147
|
+
isInView,
|
|
148
|
+
delay,
|
|
149
|
+
started
|
|
150
|
+
]);
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (!started) return;
|
|
153
|
+
const tick = () => {
|
|
154
|
+
const ms = Math.max(0, to.getTime() - Date.now());
|
|
155
|
+
setRemaining(ms);
|
|
156
|
+
if (ms <= 0 && !completedRef.current) {
|
|
157
|
+
completedRef.current = true;
|
|
158
|
+
onComplete?.();
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
tick();
|
|
162
|
+
const interval = setInterval(tick, 1e3);
|
|
163
|
+
return () => clearInterval(interval);
|
|
164
|
+
}, [
|
|
165
|
+
started,
|
|
166
|
+
to,
|
|
167
|
+
onComplete
|
|
168
|
+
]);
|
|
169
|
+
if (!isValidElement(children)) return children;
|
|
170
|
+
const existingRef = children.props.ref;
|
|
171
|
+
return cloneElement(children, {
|
|
172
|
+
ref: mergeRef(ref, existingRef),
|
|
173
|
+
children: `${prefix}${formatFn(remaining)}${suffix}`
|
|
174
|
+
});
|
|
171
175
|
}
|
|
172
|
-
|
|
173
|
-
|
|
176
|
+
/** @deprecated Use `Count` instead */
|
|
177
|
+
const CountUp = Count;
|
|
178
|
+
//#endregion
|
|
174
179
|
export { Count, CountUp, easeOut };
|
|
175
|
-
|
|
180
|
+
|
|
176
181
|
//# sourceMappingURL=count.js.map
|
package/dist/count.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/count.tsx"],"names":[],"mappings":";;;;AAmDA,SAAS,QAAQ,CAAA,EAAmB;AAClC,EAAA,OAAO,CAAA,GAAI,IAAA,CAAK,GAAA,CAAI,CAAA,GAAI,GAAG,CAAC,CAAA;AAC9B;AAIA,SAAS,gBAAgB,EAAA,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A;AAC9B;AAKA,IAAM,OAAA,GAAU","file":"count.js","sourcesContent":["\"use client\"\n\nimport {\n type ReactElement,\n type Ref,\n cloneElement,\n isValidElement,\n useEffect,\n useRef,\n useState,\n} from \"react\"\nimport { useInView } from \"motion/react\"\n\n// ── Types ────────────────────────────────────────────────────────────\n\ninterface CountProps {\n /** Target number or Date to count to */\n to: number | Date\n /** Starting number. Default: 0. Ignored when `to` is a Date. */\n from?: number\n /** Animation duration in milliseconds. Default: 900. Ignored when `to` is a Date. */\n duration?: number\n /** Delay before starting in seconds. Default: 0 */\n delay?: number\n /**\n * Format the value for display.\n * - For numbers: receives the current interpolated number.\n * - For dates: receives remaining milliseconds.\n * Default: toLocaleString() for numbers, dd:hh:mm:ss for dates.\n */\n format?: (value: number) => string\n /** Prefix string (e.g., \"$\"). Default: '' */\n prefix?: string\n /** Suffix string (e.g., \"%\", \"+\"). Default: '' */\n suffix?: string\n /** Element to render into. Receives the formatted value as children. */\n children: ReactElement\n /** Trigger once. Default: true */\n once?: boolean\n /** Easing function. Default: easeOut. Ignored when `to` is a Date. */\n easing?: (t: number) => number\n /** Called when the count finishes (reaches target or date passes). */\n onComplete?: () => void\n}\n\n/** @deprecated Use `Count` instead. `CountUp` is an alias kept for backwards compatibility. */\ntype CountUpProps = CountProps\n\n// ── Easing ───────────────────────────────────────────────────────────\n\n/** Cubic ease-out: fast start, smooth deceleration */\nfunction easeOut(t: number): number {\n return 1 - Math.pow(1 - t, 3)\n}\n\n// ── Date Formatting ──────────────────────────────────────────────────\n\nfunction formatCountdown(ms: number): string {\n if (ms <= 0) return \"00:00:00\"\n\n const totalSeconds = Math.floor(ms / 1000)\n const days = Math.floor(totalSeconds / 86400)\n const hours = Math.floor((totalSeconds % 86400) / 3600)\n const minutes = Math.floor((totalSeconds % 3600) / 60)\n const seconds = totalSeconds % 60\n\n const pad = (n: number) => String(n).padStart(2, \"0\")\n\n if (days > 0) {\n return `${days}d ${pad(hours)}:${pad(minutes)}:${pad(seconds)}`\n }\n return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`\n}\n\n// ── Ref Merge ────────────────────────────────────────────────────────\n\nfunction mergeRef(\n internalRef: React.RefObject<HTMLElement | null>,\n externalRef?: Ref<HTMLElement>,\n) {\n return (el: HTMLElement | null) => {\n ;(internalRef as { current: HTMLElement | null }).current = el\n if (typeof externalRef === \"function\") externalRef(el)\n else if (externalRef && typeof externalRef === \"object\") {\n ;(externalRef as { current: HTMLElement | null }).current = el\n }\n }\n}\n\n// ── Count ────────────────────────────────────────────────────────────\n\n/**\n * Animated number counter. Counts up, counts down, or live-counts to a date.\n *\n * Direction is automatic — if `from < to` it counts up, if `from > to` it\n * counts down. When `to` is a Date, it becomes a live countdown that ticks\n * every second.\n *\n * Zero wrapper — injects the formatted value as children via cloneElement.\n *\n * @example\n * ```tsx\n * // Count up\n * <Count to={1234}>\n * <span className=\"text-4xl font-bold tabular-nums\" />\n * </Count>\n *\n * // Count down\n * <Count from={100} to={0} onComplete={() => alert(\"Done!\")}>\n * <span className=\"text-4xl font-bold tabular-nums\" />\n * </Count>\n *\n * // Live countdown to a date\n * <Count to={new Date(\"2026-04-01T00:00:00\")}>\n * <span className=\"text-2xl font-mono tabular-nums\" />\n * </Count>\n *\n * // Custom date format\n * <Count to={launchDate} format={(ms) => `${Math.ceil(ms / 86400000)} days left`}>\n * <span className=\"text-xl\" />\n * </Count>\n * ```\n */\nfunction Count({\n to,\n from: start = 0,\n duration = 900,\n delay = 0,\n format,\n prefix = \"\",\n suffix = \"\",\n children,\n once = true,\n easing = easeOut,\n onComplete,\n}: CountProps) {\n const isDate = to instanceof Date\n\n if (isDate) {\n return (\n <DateCount\n to={to}\n delay={delay}\n format={format}\n prefix={prefix}\n suffix={suffix}\n once={once}\n onComplete={onComplete}\n >\n {children}\n </DateCount>\n )\n }\n\n return (\n <NumberCount\n to={to}\n from={start}\n duration={duration}\n delay={delay}\n format={format}\n prefix={prefix}\n suffix={suffix}\n once={once}\n easing={easing}\n onComplete={onComplete}\n >\n {children}\n </NumberCount>\n )\n}\n\n// ── Number Count (up or down) ────────────────────────────────────────\n\nfunction NumberCount({\n to,\n from: start,\n duration,\n delay,\n format,\n prefix,\n suffix,\n children,\n once,\n easing,\n onComplete,\n}: {\n to: number\n from: number\n duration: number\n delay: number\n format?: (value: number) => string\n prefix: string\n suffix: string\n children: ReactElement\n once: boolean\n easing: (t: number) => number\n onComplete?: () => void\n}) {\n const ref = useRef<HTMLElement>(null)\n const isInView = useInView(ref, { once, margin: \"-50px\" })\n const [display, setDisplay] = useState(start)\n const hasAnimated = useRef(false)\n\n const formatFn = format ?? ((n: number) =>\n Number.isInteger(to) ? Math.round(n).toLocaleString() : n.toLocaleString()\n )\n\n useEffect(() => {\n if (!isInView || hasAnimated.current) return\n hasAnimated.current = true\n\n const delayMs = delay * 1000\n let raf: number\n let startTime: number\n\n const timer = setTimeout(() => {\n const animate = (timestamp: number) => {\n if (!startTime) startTime = timestamp\n const elapsed = timestamp - startTime\n const progress = Math.min(elapsed / duration, 1)\n const easedProgress = easing(progress)\n const current = start + (to - start) * easedProgress\n\n setDisplay(current)\n\n if (progress < 1) {\n raf = requestAnimationFrame(animate)\n } else {\n onComplete?.()\n }\n }\n\n raf = requestAnimationFrame(animate)\n }, delayMs)\n\n return () => {\n clearTimeout(timer)\n cancelAnimationFrame(raf)\n }\n }, [isInView, to, start, duration, delay, easing, onComplete])\n\n if (!isValidElement(children)) return children\n\n const childProps = children.props as Record<string, unknown>\n const existingRef = (childProps as { ref?: Ref<HTMLElement> }).ref\n\n return cloneElement(children, {\n ref: mergeRef(ref, existingRef),\n children: `${prefix}${formatFn(display)}${suffix}`,\n } as Record<string, unknown>)\n}\n\n// ── Date Count (live countdown) ──────────────────────────────────────\n\nfunction DateCount({\n to,\n delay,\n format,\n prefix,\n suffix,\n children,\n once,\n onComplete,\n}: {\n to: Date\n delay: number\n format?: (value: number) => string\n prefix: string\n suffix: string\n children: ReactElement\n once: boolean\n onComplete?: () => void\n}) {\n const ref = useRef<HTMLElement>(null)\n const isInView = useInView(ref, { once, margin: \"-50px\" })\n const [remaining, setRemaining] = useState(() => Math.max(0, to.getTime() - Date.now()))\n const [started, setStarted] = useState(false)\n const completedRef = useRef(false)\n\n const formatFn = format ?? formatCountdown\n\n useEffect(() => {\n if (!isInView || started) return\n const timer = setTimeout(() => setStarted(true), delay * 1000)\n return () => clearTimeout(timer)\n }, [isInView, delay, started])\n\n useEffect(() => {\n if (!started) return\n\n const tick = () => {\n const ms = Math.max(0, to.getTime() - Date.now())\n setRemaining(ms)\n\n if (ms <= 0 && !completedRef.current) {\n completedRef.current = true\n onComplete?.()\n }\n }\n\n tick()\n const interval = setInterval(tick, 1000)\n return () => clearInterval(interval)\n }, [started, to, onComplete])\n\n if (!isValidElement(children)) return children\n\n const childProps = children.props as Record<string, unknown>\n const existingRef = (childProps as { ref?: Ref<HTMLElement> }).ref\n\n return cloneElement(children, {\n ref: mergeRef(ref, existingRef),\n children: `${prefix}${formatFn(remaining)}${suffix}`,\n } as Record<string, unknown>)\n}\n\n// ── Exports ──────────────────────────────────────────────────────────\n\n/** @deprecated Use `Count` instead */\nconst CountUp = Count\n\nexport { Count, CountUp, easeOut }\nexport type { CountProps, CountUpProps }\n"]}
|
|
1
|
+
{"version":3,"file":"count.js","names":[],"sources":["../src/count.tsx"],"sourcesContent":["\"use client\"\n\nimport {\n type ReactElement,\n type Ref,\n cloneElement,\n isValidElement,\n useEffect,\n useRef,\n useState,\n} from \"react\"\nimport { useInView } from \"motion/react\"\n\n// ── Types ────────────────────────────────────────────────────────────\n\ninterface CountProps {\n /** Target number or Date to count to */\n to: number | Date\n /** Starting number. Default: 0. Ignored when `to` is a Date. */\n from?: number\n /** Animation duration in milliseconds. Default: 900. Ignored when `to` is a Date. */\n duration?: number\n /** Delay before starting in seconds. Default: 0 */\n delay?: number\n /**\n * Format the value for display.\n * - For numbers: receives the current interpolated number.\n * - For dates: receives remaining milliseconds.\n * Default: toLocaleString() for numbers, dd:hh:mm:ss for dates.\n */\n format?: (value: number) => string\n /** Prefix string (e.g., \"$\"). Default: '' */\n prefix?: string\n /** Suffix string (e.g., \"%\", \"+\"). Default: '' */\n suffix?: string\n /** Element to render into. Receives the formatted value as children. */\n children: ReactElement\n /** Trigger once. Default: true */\n once?: boolean\n /** Easing function. Default: easeOut. Ignored when `to` is a Date. */\n easing?: (t: number) => number\n /** Called when the count finishes (reaches target or date passes). */\n onComplete?: () => void\n}\n\n/** @deprecated Use `Count` instead. `CountUp` is an alias kept for backwards compatibility. */\ntype CountUpProps = CountProps\n\n// ── Easing ───────────────────────────────────────────────────────────\n\n/** Cubic ease-out: fast start, smooth deceleration */\nfunction easeOut(t: number): number {\n return 1 - Math.pow(1 - t, 3)\n}\n\n// ── Date Formatting ──────────────────────────────────────────────────\n\nfunction formatCountdown(ms: number): string {\n if (ms <= 0) return \"00:00:00\"\n\n const totalSeconds = Math.floor(ms / 1000)\n const days = Math.floor(totalSeconds / 86400)\n const hours = Math.floor((totalSeconds % 86400) / 3600)\n const minutes = Math.floor((totalSeconds % 3600) / 60)\n const seconds = totalSeconds % 60\n\n const pad = (n: number) => String(n).padStart(2, \"0\")\n\n if (days > 0) {\n return `${days}d ${pad(hours)}:${pad(minutes)}:${pad(seconds)}`\n }\n return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`\n}\n\n// ── Ref Merge ────────────────────────────────────────────────────────\n\nfunction mergeRef(\n internalRef: React.RefObject<HTMLElement | null>,\n externalRef?: Ref<HTMLElement>,\n) {\n return (el: HTMLElement | null) => {\n ;(internalRef as { current: HTMLElement | null }).current = el\n if (typeof externalRef === \"function\") externalRef(el)\n else if (externalRef && typeof externalRef === \"object\") {\n ;(externalRef as { current: HTMLElement | null }).current = el\n }\n }\n}\n\n// ── Count ────────────────────────────────────────────────────────────\n\n/**\n * Animated number counter. Counts up, counts down, or live-counts to a date.\n *\n * Direction is automatic — if `from < to` it counts up, if `from > to` it\n * counts down. When `to` is a Date, it becomes a live countdown that ticks\n * every second.\n *\n * Zero wrapper — injects the formatted value as children via cloneElement.\n *\n * @example\n * ```tsx\n * // Count up\n * <Count to={1234}>\n * <span className=\"text-4xl font-bold tabular-nums\" />\n * </Count>\n *\n * // Count down\n * <Count from={100} to={0} onComplete={() => alert(\"Done!\")}>\n * <span className=\"text-4xl font-bold tabular-nums\" />\n * </Count>\n *\n * // Live countdown to a date\n * <Count to={new Date(\"2026-04-01T00:00:00\")}>\n * <span className=\"text-2xl font-mono tabular-nums\" />\n * </Count>\n *\n * // Custom date format\n * <Count to={launchDate} format={(ms) => `${Math.ceil(ms / 86400000)} days left`}>\n * <span className=\"text-xl\" />\n * </Count>\n * ```\n */\nfunction Count({\n to,\n from: start = 0,\n duration = 900,\n delay = 0,\n format,\n prefix = \"\",\n suffix = \"\",\n children,\n once = true,\n easing = easeOut,\n onComplete,\n}: CountProps) {\n const isDate = to instanceof Date\n\n if (isDate) {\n return (\n <DateCount\n to={to}\n delay={delay}\n format={format}\n prefix={prefix}\n suffix={suffix}\n once={once}\n onComplete={onComplete}\n >\n {children}\n </DateCount>\n )\n }\n\n return (\n <NumberCount\n to={to}\n from={start}\n duration={duration}\n delay={delay}\n format={format}\n prefix={prefix}\n suffix={suffix}\n once={once}\n easing={easing}\n onComplete={onComplete}\n >\n {children}\n </NumberCount>\n )\n}\n\n// ── Number Count (up or down) ────────────────────────────────────────\n\nfunction NumberCount({\n to,\n from: start,\n duration,\n delay,\n format,\n prefix,\n suffix,\n children,\n once,\n easing,\n onComplete,\n}: {\n to: number\n from: number\n duration: number\n delay: number\n format?: (value: number) => string\n prefix: string\n suffix: string\n children: ReactElement\n once: boolean\n easing: (t: number) => number\n onComplete?: () => void\n}) {\n const ref = useRef<HTMLElement>(null)\n const isInView = useInView(ref, { once, margin: \"-50px\" })\n const [display, setDisplay] = useState(start)\n const hasAnimated = useRef(false)\n\n const formatFn = format ?? ((n: number) =>\n Number.isInteger(to) ? Math.round(n).toLocaleString() : n.toLocaleString()\n )\n\n useEffect(() => {\n if (!isInView || hasAnimated.current) return\n hasAnimated.current = true\n\n const delayMs = delay * 1000\n let raf: number\n let startTime: number\n\n const timer = setTimeout(() => {\n const animate = (timestamp: number) => {\n if (!startTime) startTime = timestamp\n const elapsed = timestamp - startTime\n const progress = Math.min(elapsed / duration, 1)\n const easedProgress = easing(progress)\n const current = start + (to - start) * easedProgress\n\n setDisplay(current)\n\n if (progress < 1) {\n raf = requestAnimationFrame(animate)\n } else {\n onComplete?.()\n }\n }\n\n raf = requestAnimationFrame(animate)\n }, delayMs)\n\n return () => {\n clearTimeout(timer)\n cancelAnimationFrame(raf)\n }\n }, [isInView, to, start, duration, delay, easing, onComplete])\n\n if (!isValidElement(children)) return children\n\n const childProps = children.props as Record<string, unknown>\n const existingRef = (childProps as { ref?: Ref<HTMLElement> }).ref\n\n return cloneElement(children, {\n ref: mergeRef(ref, existingRef),\n children: `${prefix}${formatFn(display)}${suffix}`,\n } as Record<string, unknown>)\n}\n\n// ── Date Count (live countdown) ──────────────────────────────────────\n\nfunction DateCount({\n to,\n delay,\n format,\n prefix,\n suffix,\n children,\n once,\n onComplete,\n}: {\n to: Date\n delay: number\n format?: (value: number) => string\n prefix: string\n suffix: string\n children: ReactElement\n once: boolean\n onComplete?: () => void\n}) {\n const ref = useRef<HTMLElement>(null)\n const isInView = useInView(ref, { once, margin: \"-50px\" })\n const [remaining, setRemaining] = useState(() => Math.max(0, to.getTime() - Date.now()))\n const [started, setStarted] = useState(false)\n const completedRef = useRef(false)\n\n const formatFn = format ?? formatCountdown\n\n useEffect(() => {\n if (!isInView || started) return\n const timer = setTimeout(() => setStarted(true), delay * 1000)\n return () => clearTimeout(timer)\n }, [isInView, delay, started])\n\n useEffect(() => {\n if (!started) return\n\n const tick = () => {\n const ms = Math.max(0, to.getTime() - Date.now())\n setRemaining(ms)\n\n if (ms <= 0 && !completedRef.current) {\n completedRef.current = true\n onComplete?.()\n }\n }\n\n tick()\n const interval = setInterval(tick, 1000)\n return () => clearInterval(interval)\n }, [started, to, onComplete])\n\n if (!isValidElement(children)) return children\n\n const childProps = children.props as Record<string, unknown>\n const existingRef = (childProps as { ref?: Ref<HTMLElement> }).ref\n\n return cloneElement(children, {\n ref: mergeRef(ref, existingRef),\n children: `${prefix}${formatFn(remaining)}${suffix}`,\n } as Record<string, unknown>)\n}\n\n// ── Exports ──────────────────────────────────────────────────────────\n\n/** @deprecated Use `Count` instead */\nconst CountUp = Count\n\nexport { Count, CountUp, easeOut }\nexport type { CountProps, CountUpProps }\n"],"mappings":";;;;;;AAmDA,SAAS,QAAQ,GAAmB;AAClC,QAAO,IAAI,KAAK,IAAI,IAAI,GAAG,EAAE;;AAK/B,SAAS,gBAAgB,IAAoB;AAC3C,KAAI,MAAM,EAAG,QAAO;CAEpB,MAAM,eAAe,KAAK,MAAM,KAAK,IAAK;CAC1C,MAAM,OAAO,KAAK,MAAM,eAAe,MAAM;CAC7C,MAAM,QAAQ,KAAK,MAAO,eAAe,QAAS,KAAK;CACvD,MAAM,UAAU,KAAK,MAAO,eAAe,OAAQ,GAAG;CACtD,MAAM,UAAU,eAAe;CAE/B,MAAM,OAAO,MAAc,OAAO,EAAE,CAAC,SAAS,GAAG,IAAI;AAErD,KAAI,OAAO,EACT,QAAO,GAAG,KAAK,IAAI,IAAI,MAAM,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG,IAAI,QAAQ;AAE/D,QAAO,GAAG,IAAI,MAAM,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG,IAAI,QAAQ;;AAKtD,SAAS,SACP,aACA,aACA;AACA,SAAQ,OAA2B;AAC/B,cAAgD,UAAU;AAC5D,MAAI,OAAO,gBAAgB,WAAY,aAAY,GAAG;WAC7C,eAAe,OAAO,gBAAgB,SAC3C,aAAgD,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuClE,SAAS,MAAM,EACb,IACA,MAAM,QAAQ,GACd,WAAW,KACX,QAAQ,GACR,QACA,SAAS,IACT,SAAS,IACT,UACA,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|
-
import * as
|
|
2
|
-
import * as
|
|
3
|
-
import { Dialog as Dialog$1 } from
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
|
|
4
4
|
|
|
5
|
+
//#region src/dialog.d.ts
|
|
5
6
|
type DialogProps = React.ComponentProps<typeof Dialog$1.Root> & {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
/**
|
|
8
|
+
* When `true`, clicking outside the dialog does not close it and
|
|
9
|
+
* `FloatingFocusManager` sets `closeOnFocusOut: false`.
|
|
10
|
+
* This prevents the focus-manager from swallowing click events on
|
|
11
|
+
* interactive elements inside the popup (buttons, switches, etc.).
|
|
12
|
+
*
|
|
13
|
+
* Use this for dialogs that contain forms, wizards, or other complex
|
|
14
|
+
* interactive content.
|
|
15
|
+
*
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
disablePointerDismissal?: boolean;
|
|
18
19
|
};
|
|
19
20
|
type DialogTriggerProps = React.ComponentProps<typeof Dialog$1.Trigger>;
|
|
20
21
|
type DialogPortalProps = React.ComponentProps<typeof Dialog$1.Portal>;
|
|
@@ -24,20 +25,52 @@ type DialogPopupProps = React.ComponentProps<typeof Dialog$1.Popup>;
|
|
|
24
25
|
type DialogTitleProps = React.ComponentProps<typeof Dialog$1.Title>;
|
|
25
26
|
type DialogDescriptionProps = React.ComponentProps<typeof Dialog$1.Description>;
|
|
26
27
|
type DialogContentProps = DialogPopupProps & {
|
|
27
|
-
|
|
28
|
+
showCloseButton?: boolean;
|
|
28
29
|
};
|
|
29
30
|
type DialogFooterProps = React.ComponentProps<"div"> & {
|
|
30
|
-
|
|
31
|
+
showCloseButton?: boolean;
|
|
31
32
|
};
|
|
32
|
-
declare function Dialog({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
declare function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
declare function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
declare function Dialog({
|
|
34
|
+
disablePointerDismissal,
|
|
35
|
+
...props
|
|
36
|
+
}: DialogProps): _$react_jsx_runtime0.JSX.Element;
|
|
37
|
+
declare function DialogTrigger({
|
|
38
|
+
...props
|
|
39
|
+
}: DialogTriggerProps): _$react_jsx_runtime0.JSX.Element;
|
|
40
|
+
declare function DialogPortal({
|
|
41
|
+
...props
|
|
42
|
+
}: DialogPortalProps): _$react_jsx_runtime0.JSX.Element;
|
|
43
|
+
declare function DialogClose({
|
|
44
|
+
...props
|
|
45
|
+
}: DialogCloseProps): _$react_jsx_runtime0.JSX.Element;
|
|
46
|
+
declare function DialogOverlay({
|
|
47
|
+
className,
|
|
48
|
+
...props
|
|
49
|
+
}: DialogOverlayProps): _$react_jsx_runtime0.JSX.Element;
|
|
50
|
+
declare function DialogContent({
|
|
51
|
+
className,
|
|
52
|
+
children,
|
|
53
|
+
showCloseButton,
|
|
54
|
+
...props
|
|
55
|
+
}: DialogContentProps): _$react_jsx_runtime0.JSX.Element;
|
|
56
|
+
declare function DialogHeader({
|
|
57
|
+
className,
|
|
58
|
+
...props
|
|
59
|
+
}: React.ComponentProps<"div">): _$react_jsx_runtime0.JSX.Element;
|
|
60
|
+
declare function DialogFooter({
|
|
61
|
+
className,
|
|
62
|
+
showCloseButton,
|
|
63
|
+
children,
|
|
64
|
+
...props
|
|
65
|
+
}: DialogFooterProps): _$react_jsx_runtime0.JSX.Element;
|
|
66
|
+
declare function DialogTitle({
|
|
67
|
+
className,
|
|
68
|
+
...props
|
|
69
|
+
}: DialogTitleProps): _$react_jsx_runtime0.JSX.Element;
|
|
70
|
+
declare function DialogDescription({
|
|
71
|
+
className,
|
|
72
|
+
...props
|
|
73
|
+
}: DialogDescriptionProps): _$react_jsx_runtime0.JSX.Element;
|
|
74
|
+
//#endregion
|
|
43
75
|
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger };
|
|
76
|
+
//# sourceMappingURL=dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","names":[],"sources":["../src/dialog.tsx"],"mappings":";;;;;KASK,WAAA,GAAc,KAAA,CAAM,cAAA,QAAsB,QAAA,CAAgB,IAAA;;;AANE;;;;;;;;;EAkB/D,uBAAA;AAAA;AAAA,KAEG,kBAAA,GAAqB,KAAA,CAAM,cAAA,QAAsB,QAAA,CAAgB,OAAA;AAAA,KACjE,iBAAA,GAAoB,KAAA,CAAM,cAAA,QAAsB,QAAA,CAAgB,MAAA;AAAA,KAChE,gBAAA,GAAmB,KAAA,CAAM,cAAA,QAAsB,QAAA,CAAgB,KAAA;AAAA,KAC/D,kBAAA,GAAqB,KAAA,CAAM,cAAA,QAAsB,QAAA,CAAgB,QAAA;AAAA,KACjE,gBAAA,GAAmB,KAAA,CAAM,cAAA,QAAsB,QAAA,CAAgB,KAAA;AAAA,KAC/D,gBAAA,GAAmB,KAAA,CAAM,cAAA,QAAsB,QAAA,CAAgB,KAAA;AAAA,KAC/D,sBAAA,GAAyB,KAAA,CAAM,cAAA,QAAsB,QAAA,CAAgB,WAAA;AAAA,KAErE,kBAAA,GAAqB,gBAAA;EACxB,eAAA;AAAA;AAAA,KAGG,iBAAA,GAAoB,KAAA,CAAM,cAAA;EAC7B,eAAA;AAAA;AAAA,iBAGO,MAAA,CAAA;EAAS,uBAAA;EAAA,GAA4B;AAAA,GAAS,WAAA,GAAW,oBAAA,CAAA,GAAA,CAAA,OAAA;AAAA,iBAIzD,aAAA,CAAA;EAAA,GAAmB;AAAA,GAAS,kBAAA,GAAkB,oBAAA,CAAA,GAAA,CAAA,OAAA;AAAA,iBAI9C,YAAA,CAAA;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