@windrun-huaiin/third-ui 29.2.0 → 30.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 (102) hide show
  1. package/dist/fuma/mdx/cheet-table.d.ts +13 -0
  2. package/dist/fuma/mdx/cheet-table.js +295 -0
  3. package/dist/fuma/mdx/cheet-table.mjs +293 -0
  4. package/dist/fuma/mdx/index.d.ts +1 -0
  5. package/dist/fuma/mdx/index.js +2 -0
  6. package/dist/fuma/mdx/index.mjs +1 -0
  7. package/dist/fuma/server/features/widgets.js +2 -0
  8. package/dist/fuma/server/features/widgets.mjs +2 -0
  9. package/dist/lib/fuma-schema-check-util.d.ts +1 -1
  10. package/dist/main/alert-dialog/confirm-dialog.d.ts +2 -1
  11. package/dist/main/alert-dialog/confirm-dialog.js +3 -3
  12. package/dist/main/alert-dialog/confirm-dialog.mjs +4 -4
  13. package/dist/main/alert-dialog/dialog-loading-action.d.ts +2 -1
  14. package/dist/main/alert-dialog/dialog-loading-action.js +6 -3
  15. package/dist/main/alert-dialog/dialog-loading-action.mjs +6 -3
  16. package/dist/main/alert-dialog/dialog-styles.d.ts +4 -2
  17. package/dist/main/alert-dialog/dialog-styles.js +8 -4
  18. package/dist/main/alert-dialog/dialog-styles.mjs +7 -5
  19. package/dist/main/alert-dialog/high-priority-confirm-dialog.d.ts +2 -1
  20. package/dist/main/alert-dialog/high-priority-confirm-dialog.js +7 -7
  21. package/dist/main/alert-dialog/high-priority-confirm-dialog.mjs +8 -8
  22. package/dist/main/alert-dialog/info-dialog.d.ts +2 -1
  23. package/dist/main/alert-dialog/info-dialog.js +3 -3
  24. package/dist/main/alert-dialog/info-dialog.mjs +4 -4
  25. package/dist/main/alert-dialog/undoable-confirm-dialog.d.ts +2 -1
  26. package/dist/main/alert-dialog/undoable-confirm-dialog.js +4 -4
  27. package/dist/main/alert-dialog/undoable-confirm-dialog.mjs +5 -5
  28. package/dist/main/anime/anime-beam-frame.d.ts +3 -0
  29. package/dist/main/anime/anime-beam-frame.js +63 -0
  30. package/dist/main/anime/anime-beam-frame.mjs +61 -0
  31. package/dist/main/anime/anime-spiral-loading.d.ts +10 -0
  32. package/dist/main/anime/anime-spiral-loading.js +77 -0
  33. package/dist/main/anime/anime-spiral-loading.mjs +75 -0
  34. package/dist/main/anime/index.d.ts +2 -0
  35. package/dist/main/anime/index.js +10 -0
  36. package/dist/main/anime/index.mjs +3 -0
  37. package/dist/main/beam-frame/animate.d.ts +3 -0
  38. package/dist/main/beam-frame/animate.js +63 -0
  39. package/dist/main/beam-frame/animate.mjs +61 -0
  40. package/dist/main/beam-frame/beam-frame.d.ts +4 -0
  41. package/dist/main/beam-frame/beam-frame.js +262 -0
  42. package/dist/main/beam-frame/beam-frame.mjs +258 -0
  43. package/dist/main/beam-frame/index.d.ts +4 -0
  44. package/dist/main/beam-frame/index.js +11 -0
  45. package/dist/main/beam-frame/index.mjs +3 -0
  46. package/dist/main/beam-frame/motion.d.ts +3 -0
  47. package/dist/main/beam-frame/motion.js +61 -0
  48. package/dist/main/beam-frame/motion.mjs +59 -0
  49. package/dist/main/beam-frame/share-config.d.ts +54 -0
  50. package/dist/main/beam-frame/share-config.js +161 -0
  51. package/dist/main/beam-frame/share-config.mjs +152 -0
  52. package/dist/main/beam-frame-config.d.ts +54 -0
  53. package/dist/main/beam-frame-config.js +161 -0
  54. package/dist/main/beam-frame-config.mjs +152 -0
  55. package/dist/main/calendar/random-date-range-dialog.d.ts +5 -2
  56. package/dist/main/calendar/random-date-range-dialog.js +239 -109
  57. package/dist/main/calendar/random-date-range-dialog.mjs +242 -112
  58. package/dist/main/cta.js +17 -1
  59. package/dist/main/cta.mjs +18 -2
  60. package/dist/main/delayed-img.d.ts +1 -1
  61. package/dist/main/delayed-img.js +8 -5
  62. package/dist/main/delayed-img.mjs +8 -5
  63. package/dist/main/info-tooltip.js +70 -9
  64. package/dist/main/info-tooltip.mjs +70 -9
  65. package/dist/main/loading-frame/index.d.ts +1 -0
  66. package/dist/main/loading.d.ts +2 -1
  67. package/dist/main/loading.js +64 -26
  68. package/dist/main/loading.mjs +64 -26
  69. package/dist/main/motion/index.d.ts +1 -0
  70. package/dist/main/motion/index.js +9 -0
  71. package/dist/main/motion/index.mjs +2 -0
  72. package/dist/main/motion/motion-beam-frame.d.ts +3 -0
  73. package/dist/main/motion/motion-beam-frame.js +61 -0
  74. package/dist/main/motion/motion-beam-frame.mjs +59 -0
  75. package/dist/main/snake-loading-frame.d.ts +7 -3
  76. package/dist/main/snake-loading-frame.js +44 -252
  77. package/dist/main/snake-loading-frame.mjs +46 -254
  78. package/package.json +16 -5
  79. package/src/fuma/mdx/cheet-table.tsx +650 -0
  80. package/src/fuma/mdx/index.ts +1 -0
  81. package/src/fuma/server/features/widgets.tsx +2 -0
  82. package/src/main/alert-dialog/confirm-dialog.tsx +5 -2
  83. package/src/main/alert-dialog/dialog-loading-action.tsx +22 -5
  84. package/src/main/alert-dialog/dialog-styles.ts +13 -3
  85. package/src/main/alert-dialog/high-priority-confirm-dialog.tsx +29 -24
  86. package/src/main/alert-dialog/info-dialog.tsx +5 -2
  87. package/src/main/alert-dialog/undoable-confirm-dialog.tsx +21 -18
  88. package/src/main/anime/anime-beam-frame.tsx +128 -0
  89. package/src/main/anime/anime-spiral-loading.tsx +123 -0
  90. package/src/main/anime/index.ts +9 -0
  91. package/src/main/beam-frame-config.tsx +341 -0
  92. package/src/main/calendar/random-date-range-dialog.tsx +242 -74
  93. package/src/main/cta.tsx +50 -21
  94. package/src/main/delayed-img.tsx +9 -4
  95. package/src/main/info-tooltip.tsx +116 -20
  96. package/src/main/loading-frame/index.ts +4 -0
  97. package/src/main/loading.tsx +75 -24
  98. package/src/main/motion/index.ts +8 -0
  99. package/src/main/motion/motion-beam-frame.tsx +137 -0
  100. package/src/main/snake-loading-frame.tsx +95 -496
  101. package/src/styles/cta.css +21 -4
  102. package/src/styles/third-ui.css +0 -20
@@ -0,0 +1,63 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var React = require('react');
6
+ var animejs = require('animejs');
7
+ var react = require('motion/react');
8
+ var beamFrameConfig = require('../beam-frame-config.js');
9
+
10
+ function AnimeBeamLayer({ isRunning, duration, radius, size, }) {
11
+ const aroundBeamRef = React.useRef(null);
12
+ const animationRef = React.useRef(null);
13
+ const hasStartedRef = React.useRef(false);
14
+ const auraGradientId = React.useId().replace(/:/g, '');
15
+ const softGlowFilterId = React.useId().replace(/:/g, '');
16
+ React.useEffect(() => {
17
+ var _a;
18
+ const node = aroundBeamRef.current;
19
+ if (!node) {
20
+ return undefined;
21
+ }
22
+ if (isRunning) {
23
+ hasStartedRef.current = true;
24
+ }
25
+ node.style.opacity = isRunning || hasStartedRef.current ? 'var(--beam-frame-beam-opacity)' : '0';
26
+ if (!isRunning) {
27
+ (_a = animationRef.current) === null || _a === void 0 ? void 0 : _a.pause();
28
+ return undefined;
29
+ }
30
+ if (animationRef.current) {
31
+ animationRef.current.speed = beamFrameConfig.BASE_DURATION_SECONDS / duration;
32
+ animationRef.current.play();
33
+ return undefined;
34
+ }
35
+ animationRef.current = animejs.waapi.animate(node, {
36
+ strokeDashoffset: [0, -1],
37
+ loop: true,
38
+ duration: beamFrameConfig.BASE_DURATION_SECONDS * 1000,
39
+ ease: 'linear',
40
+ });
41
+ animationRef.current.speed = beamFrameConfig.BASE_DURATION_SECONDS / duration;
42
+ return undefined;
43
+ }, [duration, isRunning]);
44
+ React.useEffect(() => {
45
+ return () => {
46
+ var _a;
47
+ (_a = animationRef.current) === null || _a === void 0 ? void 0 : _a.revert();
48
+ animationRef.current = null;
49
+ };
50
+ }, []);
51
+ return (jsxRuntime.jsx(beamFrameConfig.BeamSvgLayer, { beamRef: aroundBeamRef, auraGradientId: auraGradientId, softGlowFilterId: softGlowFilterId, radius: radius, size: size }));
52
+ }
53
+ function AnimeBeamFrame(props) {
54
+ const { children, active = false, interactive = true, tone = 'theme', duration = beamFrameConfig.BASE_DURATION_SECONDS, radius, className, } = props;
55
+ const prefersReducedMotion = react.useReducedMotion();
56
+ const { isRunning, interactionProps } = beamFrameConfig.useInteractiveRunning(active, interactive);
57
+ const shouldRun = isRunning && !prefersReducedMotion;
58
+ const normalizedDuration = beamFrameConfig.normalizeDuration(duration);
59
+ const { ref, size } = beamFrameConfig.useMeasuredFrameSize();
60
+ return (jsxRuntime.jsx(beamFrameConfig.BeamFrameShell, { active: active, interactive: interactive, tone: tone, duration: normalizedDuration, radius: radius, className: className, isRunning: shouldRun, interactionProps: interactionProps, rootRef: ref, renderBeam: () => (jsxRuntime.jsx(AnimeBeamLayer, { isRunning: shouldRun, duration: normalizedDuration, radius: radius, size: size })), children: children }));
61
+ }
62
+
63
+ exports.AnimeBeamFrame = AnimeBeamFrame;
@@ -0,0 +1,61 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useRef, useId, useEffect } from 'react';
4
+ import { waapi } from 'animejs';
5
+ import { useReducedMotion } from 'motion/react';
6
+ import { BASE_DURATION_SECONDS, useInteractiveRunning, useMeasuredFrameSize, BeamFrameShell, normalizeDuration, BeamSvgLayer } from '../beam-frame-config.mjs';
7
+
8
+ function AnimeBeamLayer({ isRunning, duration, radius, size, }) {
9
+ const aroundBeamRef = useRef(null);
10
+ const animationRef = useRef(null);
11
+ const hasStartedRef = useRef(false);
12
+ const auraGradientId = useId().replace(/:/g, '');
13
+ const softGlowFilterId = useId().replace(/:/g, '');
14
+ useEffect(() => {
15
+ var _a;
16
+ const node = aroundBeamRef.current;
17
+ if (!node) {
18
+ return undefined;
19
+ }
20
+ if (isRunning) {
21
+ hasStartedRef.current = true;
22
+ }
23
+ node.style.opacity = isRunning || hasStartedRef.current ? 'var(--beam-frame-beam-opacity)' : '0';
24
+ if (!isRunning) {
25
+ (_a = animationRef.current) === null || _a === void 0 ? void 0 : _a.pause();
26
+ return undefined;
27
+ }
28
+ if (animationRef.current) {
29
+ animationRef.current.speed = BASE_DURATION_SECONDS / duration;
30
+ animationRef.current.play();
31
+ return undefined;
32
+ }
33
+ animationRef.current = waapi.animate(node, {
34
+ strokeDashoffset: [0, -1],
35
+ loop: true,
36
+ duration: BASE_DURATION_SECONDS * 1000,
37
+ ease: 'linear',
38
+ });
39
+ animationRef.current.speed = BASE_DURATION_SECONDS / duration;
40
+ return undefined;
41
+ }, [duration, isRunning]);
42
+ useEffect(() => {
43
+ return () => {
44
+ var _a;
45
+ (_a = animationRef.current) === null || _a === void 0 ? void 0 : _a.revert();
46
+ animationRef.current = null;
47
+ };
48
+ }, []);
49
+ return (jsx(BeamSvgLayer, { beamRef: aroundBeamRef, auraGradientId: auraGradientId, softGlowFilterId: softGlowFilterId, radius: radius, size: size }));
50
+ }
51
+ function AnimeBeamFrame(props) {
52
+ const { children, active = false, interactive = true, tone = 'theme', duration = BASE_DURATION_SECONDS, radius, className, } = props;
53
+ const prefersReducedMotion = useReducedMotion();
54
+ const { isRunning, interactionProps } = useInteractiveRunning(active, interactive);
55
+ const shouldRun = isRunning && !prefersReducedMotion;
56
+ const normalizedDuration = normalizeDuration(duration);
57
+ const { ref, size } = useMeasuredFrameSize();
58
+ return (jsx(BeamFrameShell, { active: active, interactive: interactive, tone: tone, duration: normalizedDuration, radius: radius, className: className, isRunning: shouldRun, interactionProps: interactionProps, rootRef: ref, renderBeam: () => (jsx(AnimeBeamLayer, { isRunning: shouldRun, duration: normalizedDuration, radius: radius, size: size })), children: children }));
59
+ }
60
+
61
+ export { AnimeBeamFrame };
@@ -0,0 +1,10 @@
1
+ export interface AnimeSpiralLoadingProps {
2
+ className?: string;
3
+ dotCount?: number;
4
+ duration?: number;
5
+ distanceRem?: number;
6
+ dotSizeEm?: number;
7
+ fontSize?: number;
8
+ paused?: boolean;
9
+ }
10
+ export declare function AnimeSpiralLoading({ className, dotCount, duration, distanceRem, dotSizeEm, fontSize, paused, }: AnimeSpiralLoadingProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,77 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var React = require('react');
6
+ var animejs = require('animejs');
7
+ var utils = require('@windrun-huaiin/lib/utils');
8
+
9
+ const DEFAULT_DOT_COUNT = 2024;
10
+ const DEFAULT_DURATION = 10000;
11
+ const DEFAULT_DISTANCE_REM = 20;
12
+ const DEFAULT_DOT_SIZE_EM = 1;
13
+ const DEFAULT_FONT_SIZE = 20;
14
+ function AnimeSpiralLoading({ className, dotCount = DEFAULT_DOT_COUNT, duration = DEFAULT_DURATION, distanceRem = DEFAULT_DISTANCE_REM, dotSizeEm = DEFAULT_DOT_SIZE_EM, fontSize = DEFAULT_FONT_SIZE, paused = false, }) {
15
+ const rootRef = React.useRef(null);
16
+ const timelineRef = React.useRef(null);
17
+ const pausedRef = React.useRef(paused);
18
+ const safeDotCount = Math.max(1, Math.floor(dotCount));
19
+ const safeDuration = Math.max(1, duration);
20
+ const angle = React.useMemo(() => (index) => animejs.utils.mapRange(index, 0, safeDotCount, 0, Math.PI * 100), [safeDotCount]);
21
+ const dots = React.useMemo(() => Array.from({ length: safeDotCount }, (_, index) => {
22
+ const hue = animejs.utils.round((360 / safeDotCount) * index, 0);
23
+ return {
24
+ id: index,
25
+ background: `hsl(${hue}, 60%, 60%)`,
26
+ };
27
+ }), [safeDotCount]);
28
+ pausedRef.current = paused;
29
+ React.useEffect(() => {
30
+ var _a;
31
+ const root = rootRef.current;
32
+ if (!root) {
33
+ return undefined;
34
+ }
35
+ const dotNodes = Array.from(root.querySelectorAll('[data-anime-spiral-dot]'));
36
+ (_a = timelineRef.current) === null || _a === void 0 ? void 0 : _a.revert();
37
+ timelineRef.current = animejs.createTimeline()
38
+ .add(dotNodes, {
39
+ x: (_target, i) => `${Math.sin(angle(i)) * distanceRem}rem`,
40
+ y: (_target, i) => `${Math.cos(angle(i)) * distanceRem}rem`,
41
+ scale: [0, 0.4, 0.2, 0.9, 0],
42
+ playbackEase: 'inOutSine',
43
+ loop: true,
44
+ duration: safeDuration,
45
+ }, animejs.stagger([0, safeDuration]))
46
+ .init()
47
+ .seek(safeDuration);
48
+ if (pausedRef.current) {
49
+ timelineRef.current.pause();
50
+ }
51
+ return () => {
52
+ var _a;
53
+ (_a = timelineRef.current) === null || _a === void 0 ? void 0 : _a.revert();
54
+ timelineRef.current = null;
55
+ };
56
+ }, [angle, distanceRem, safeDuration, dots]);
57
+ React.useEffect(() => {
58
+ const timeline = timelineRef.current;
59
+ if (!timeline) {
60
+ return;
61
+ }
62
+ if (paused) {
63
+ timeline.pause();
64
+ }
65
+ else {
66
+ timeline.play();
67
+ }
68
+ }, [paused]);
69
+ return (jsxRuntime.jsx("div", { ref: rootRef, className: utils.cn('relative h-dvh w-full overflow-hidden', className), style: { fontSize }, "aria-hidden": "true", children: dots.map(dot => (jsxRuntime.jsx("div", { "data-anime-spiral-dot": "", className: "absolute left-1/2 top-1/2 rounded-full", style: {
70
+ width: `${dotSizeEm}em`,
71
+ height: `${dotSizeEm}em`,
72
+ margin: `${dotSizeEm / -2}em 0 0 ${dotSizeEm / -2}em`,
73
+ backgroundColor: dot.background,
74
+ } }, dot.id))) }));
75
+ }
76
+
77
+ exports.AnimeSpiralLoading = AnimeSpiralLoading;
@@ -0,0 +1,75 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useRef, useMemo, useEffect } from 'react';
4
+ import { utils, createTimeline, stagger } from 'animejs';
5
+ import { cn } from '@windrun-huaiin/lib/utils';
6
+
7
+ const DEFAULT_DOT_COUNT = 2024;
8
+ const DEFAULT_DURATION = 10000;
9
+ const DEFAULT_DISTANCE_REM = 20;
10
+ const DEFAULT_DOT_SIZE_EM = 1;
11
+ const DEFAULT_FONT_SIZE = 20;
12
+ function AnimeSpiralLoading({ className, dotCount = DEFAULT_DOT_COUNT, duration = DEFAULT_DURATION, distanceRem = DEFAULT_DISTANCE_REM, dotSizeEm = DEFAULT_DOT_SIZE_EM, fontSize = DEFAULT_FONT_SIZE, paused = false, }) {
13
+ const rootRef = useRef(null);
14
+ const timelineRef = useRef(null);
15
+ const pausedRef = useRef(paused);
16
+ const safeDotCount = Math.max(1, Math.floor(dotCount));
17
+ const safeDuration = Math.max(1, duration);
18
+ const angle = useMemo(() => (index) => utils.mapRange(index, 0, safeDotCount, 0, Math.PI * 100), [safeDotCount]);
19
+ const dots = useMemo(() => Array.from({ length: safeDotCount }, (_, index) => {
20
+ const hue = utils.round((360 / safeDotCount) * index, 0);
21
+ return {
22
+ id: index,
23
+ background: `hsl(${hue}, 60%, 60%)`,
24
+ };
25
+ }), [safeDotCount]);
26
+ pausedRef.current = paused;
27
+ useEffect(() => {
28
+ var _a;
29
+ const root = rootRef.current;
30
+ if (!root) {
31
+ return undefined;
32
+ }
33
+ const dotNodes = Array.from(root.querySelectorAll('[data-anime-spiral-dot]'));
34
+ (_a = timelineRef.current) === null || _a === void 0 ? void 0 : _a.revert();
35
+ timelineRef.current = createTimeline()
36
+ .add(dotNodes, {
37
+ x: (_target, i) => `${Math.sin(angle(i)) * distanceRem}rem`,
38
+ y: (_target, i) => `${Math.cos(angle(i)) * distanceRem}rem`,
39
+ scale: [0, 0.4, 0.2, 0.9, 0],
40
+ playbackEase: 'inOutSine',
41
+ loop: true,
42
+ duration: safeDuration,
43
+ }, stagger([0, safeDuration]))
44
+ .init()
45
+ .seek(safeDuration);
46
+ if (pausedRef.current) {
47
+ timelineRef.current.pause();
48
+ }
49
+ return () => {
50
+ var _a;
51
+ (_a = timelineRef.current) === null || _a === void 0 ? void 0 : _a.revert();
52
+ timelineRef.current = null;
53
+ };
54
+ }, [angle, distanceRem, safeDuration, dots]);
55
+ useEffect(() => {
56
+ const timeline = timelineRef.current;
57
+ if (!timeline) {
58
+ return;
59
+ }
60
+ if (paused) {
61
+ timeline.pause();
62
+ }
63
+ else {
64
+ timeline.play();
65
+ }
66
+ }, [paused]);
67
+ return (jsx("div", { ref: rootRef, className: cn('relative h-dvh w-full overflow-hidden', className), style: { fontSize }, "aria-hidden": "true", children: dots.map(dot => (jsx("div", { "data-anime-spiral-dot": "", className: "absolute left-1/2 top-1/2 rounded-full", style: {
68
+ width: `${dotSizeEm}em`,
69
+ height: `${dotSizeEm}em`,
70
+ margin: `${dotSizeEm / -2}em 0 0 ${dotSizeEm / -2}em`,
71
+ backgroundColor: dot.background,
72
+ } }, dot.id))) }));
73
+ }
74
+
75
+ export { AnimeSpiralLoading };
@@ -0,0 +1,2 @@
1
+ export { AnimeBeamFrame, type BeamFrameProps, type BeamFrameTone, } from './anime-beam-frame';
2
+ export { AnimeSpiralLoading, type AnimeSpiralLoadingProps } from './anime-spiral-loading';
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var animeBeamFrame = require('./anime-beam-frame.js');
5
+ var animeSpiralLoading = require('./anime-spiral-loading.js');
6
+
7
+
8
+
9
+ exports.AnimeBeamFrame = animeBeamFrame.AnimeBeamFrame;
10
+ exports.AnimeSpiralLoading = animeSpiralLoading.AnimeSpiralLoading;
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ export { AnimeBeamFrame } from './anime-beam-frame.mjs';
3
+ export { AnimeSpiralLoading } from './anime-spiral-loading.mjs';
@@ -0,0 +1,3 @@
1
+ import { type BeamFrameProps } from './share-config';
2
+ export type { BeamFrameProps, BeamFrameTone } from './share-config';
3
+ export declare function AnimeBeamFrame(props: BeamFrameProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,63 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var React = require('react');
6
+ var animejs = require('animejs');
7
+ var react = require('motion/react');
8
+ var shareConfig = require('./share-config.js');
9
+
10
+ function AnimeBeamLayer({ isRunning, duration, radius, size, }) {
11
+ const aroundBeamRef = React.useRef(null);
12
+ const animationRef = React.useRef(null);
13
+ const hasStartedRef = React.useRef(false);
14
+ const auraGradientId = React.useId().replace(/:/g, '');
15
+ const softGlowFilterId = React.useId().replace(/:/g, '');
16
+ React.useEffect(() => {
17
+ var _a;
18
+ const node = aroundBeamRef.current;
19
+ if (!node) {
20
+ return undefined;
21
+ }
22
+ if (isRunning) {
23
+ hasStartedRef.current = true;
24
+ }
25
+ node.style.opacity = isRunning || hasStartedRef.current ? 'var(--beam-frame-beam-opacity)' : '0';
26
+ if (!isRunning) {
27
+ (_a = animationRef.current) === null || _a === void 0 ? void 0 : _a.pause();
28
+ return undefined;
29
+ }
30
+ if (animationRef.current) {
31
+ animationRef.current.speed = shareConfig.BASE_DURATION_SECONDS / duration;
32
+ animationRef.current.play();
33
+ return undefined;
34
+ }
35
+ animationRef.current = animejs.waapi.animate(node, {
36
+ strokeDashoffset: [0, -1],
37
+ loop: true,
38
+ duration: shareConfig.BASE_DURATION_SECONDS * 1000,
39
+ ease: 'linear',
40
+ });
41
+ animationRef.current.speed = shareConfig.BASE_DURATION_SECONDS / duration;
42
+ return undefined;
43
+ }, [duration, isRunning]);
44
+ React.useEffect(() => {
45
+ return () => {
46
+ var _a;
47
+ (_a = animationRef.current) === null || _a === void 0 ? void 0 : _a.revert();
48
+ animationRef.current = null;
49
+ };
50
+ }, []);
51
+ return (jsxRuntime.jsx(shareConfig.BeamSvgLayer, { beamRef: aroundBeamRef, auraGradientId: auraGradientId, softGlowFilterId: softGlowFilterId, radius: radius, size: size }));
52
+ }
53
+ function AnimeBeamFrame(props) {
54
+ const { children, active = false, interactive = true, tone = 'theme', duration = shareConfig.BASE_DURATION_SECONDS, radius, className, } = props;
55
+ const prefersReducedMotion = react.useReducedMotion();
56
+ const { isRunning, interactionProps } = shareConfig.useInteractiveRunning(active, interactive);
57
+ const shouldRun = isRunning && !prefersReducedMotion;
58
+ const normalizedDuration = shareConfig.normalizeDuration(duration);
59
+ const { ref, size } = shareConfig.useMeasuredFrameSize();
60
+ return (jsxRuntime.jsx(shareConfig.BeamFrameShell, { active: active, interactive: interactive, tone: tone, duration: normalizedDuration, radius: radius, className: className, isRunning: shouldRun, interactionProps: interactionProps, rootRef: ref, renderBeam: () => (jsxRuntime.jsx(AnimeBeamLayer, { isRunning: shouldRun, duration: normalizedDuration, radius: radius, size: size })), children: children }));
61
+ }
62
+
63
+ exports.AnimeBeamFrame = AnimeBeamFrame;
@@ -0,0 +1,61 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useRef, useId, useEffect } from 'react';
4
+ import { waapi } from 'animejs';
5
+ import { useReducedMotion } from 'motion/react';
6
+ import { BASE_DURATION_SECONDS, useInteractiveRunning, useMeasuredFrameSize, BeamFrameShell, normalizeDuration, BeamSvgLayer } from './share-config.mjs';
7
+
8
+ function AnimeBeamLayer({ isRunning, duration, radius, size, }) {
9
+ const aroundBeamRef = useRef(null);
10
+ const animationRef = useRef(null);
11
+ const hasStartedRef = useRef(false);
12
+ const auraGradientId = useId().replace(/:/g, '');
13
+ const softGlowFilterId = useId().replace(/:/g, '');
14
+ useEffect(() => {
15
+ var _a;
16
+ const node = aroundBeamRef.current;
17
+ if (!node) {
18
+ return undefined;
19
+ }
20
+ if (isRunning) {
21
+ hasStartedRef.current = true;
22
+ }
23
+ node.style.opacity = isRunning || hasStartedRef.current ? 'var(--beam-frame-beam-opacity)' : '0';
24
+ if (!isRunning) {
25
+ (_a = animationRef.current) === null || _a === void 0 ? void 0 : _a.pause();
26
+ return undefined;
27
+ }
28
+ if (animationRef.current) {
29
+ animationRef.current.speed = BASE_DURATION_SECONDS / duration;
30
+ animationRef.current.play();
31
+ return undefined;
32
+ }
33
+ animationRef.current = waapi.animate(node, {
34
+ strokeDashoffset: [0, -1],
35
+ loop: true,
36
+ duration: BASE_DURATION_SECONDS * 1000,
37
+ ease: 'linear',
38
+ });
39
+ animationRef.current.speed = BASE_DURATION_SECONDS / duration;
40
+ return undefined;
41
+ }, [duration, isRunning]);
42
+ useEffect(() => {
43
+ return () => {
44
+ var _a;
45
+ (_a = animationRef.current) === null || _a === void 0 ? void 0 : _a.revert();
46
+ animationRef.current = null;
47
+ };
48
+ }, []);
49
+ return (jsx(BeamSvgLayer, { beamRef: aroundBeamRef, auraGradientId: auraGradientId, softGlowFilterId: softGlowFilterId, radius: radius, size: size }));
50
+ }
51
+ function AnimeBeamFrame(props) {
52
+ const { children, active = false, interactive = true, tone = 'theme', duration = BASE_DURATION_SECONDS, radius, className, } = props;
53
+ const prefersReducedMotion = useReducedMotion();
54
+ const { isRunning, interactionProps } = useInteractiveRunning(active, interactive);
55
+ const shouldRun = isRunning && !prefersReducedMotion;
56
+ const normalizedDuration = normalizeDuration(duration);
57
+ const { ref, size } = useMeasuredFrameSize();
58
+ return (jsx(BeamFrameShell, { active: active, interactive: interactive, tone: tone, duration: normalizedDuration, radius: radius, className: className, isRunning: shouldRun, interactionProps: interactionProps, rootRef: ref, renderBeam: () => (jsx(AnimeBeamLayer, { isRunning: shouldRun, duration: normalizedDuration, radius: radius, size: size })), children: children }));
59
+ }
60
+
61
+ export { AnimeBeamFrame };
@@ -0,0 +1,4 @@
1
+ export { AnimeBeamFrame } from './animate';
2
+ export { MotionBeamFrame } from './motion';
3
+ export { MotionBeamFrame as BeamFrame } from './motion';
4
+ export type { BeamFrameProps, BeamFrameTone } from './share-config';