@windrun-huaiin/third-ui 29.2.1 → 30.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/fuma/fuma-page-genarator.d.ts +2 -6
- package/dist/fuma/fuma-page-genarator.js +3 -2
- package/dist/fuma/fuma-page-genarator.mjs +3 -2
- package/dist/fuma/mdx/cheet-table.d.ts +13 -0
- package/dist/fuma/mdx/cheet-table.js +295 -0
- package/dist/fuma/mdx/cheet-table.mjs +293 -0
- package/dist/fuma/mdx/index.d.ts +1 -0
- package/dist/fuma/mdx/index.js +2 -0
- package/dist/fuma/mdx/index.mjs +1 -0
- package/dist/fuma/server/features/widgets.js +2 -0
- package/dist/fuma/server/features/widgets.mjs +2 -0
- package/dist/lib/fuma-schema-check-util.d.ts +1 -1
- package/dist/main/404-page.d.ts +12 -0
- package/dist/main/404-page.js +66 -0
- package/dist/main/404-page.mjs +64 -0
- package/dist/main/alert-dialog/confirm-dialog.js +1 -1
- package/dist/main/alert-dialog/confirm-dialog.mjs +2 -2
- package/dist/main/alert-dialog/dialog-loading-action.js +5 -2
- package/dist/main/alert-dialog/dialog-loading-action.mjs +5 -2
- package/dist/main/alert-dialog/dialog-styles.d.ts +4 -2
- package/dist/main/alert-dialog/dialog-styles.js +8 -4
- package/dist/main/alert-dialog/dialog-styles.mjs +7 -5
- package/dist/main/alert-dialog/high-priority-confirm-dialog.js +5 -5
- package/dist/main/alert-dialog/high-priority-confirm-dialog.mjs +6 -6
- package/dist/main/alert-dialog/info-dialog.js +1 -1
- package/dist/main/alert-dialog/info-dialog.mjs +2 -2
- package/dist/main/alert-dialog/undoable-confirm-dialog.js +2 -2
- package/dist/main/alert-dialog/undoable-confirm-dialog.mjs +3 -3
- package/dist/main/anime/anime-404-page.d.ts +14 -0
- package/dist/main/anime/anime-404-page.js +197 -0
- package/dist/main/anime/anime-404-page.mjs +195 -0
- package/dist/main/anime/anime-beam-frame.d.ts +3 -0
- package/dist/main/anime/anime-beam-frame.js +63 -0
- package/dist/main/anime/anime-beam-frame.mjs +61 -0
- package/dist/main/anime/anime-not-found-page.d.ts +7 -0
- package/dist/main/anime/anime-not-found-page.js +142 -0
- package/dist/main/anime/anime-not-found-page.mjs +140 -0
- package/dist/main/anime/anime-spiral-loading.d.ts +10 -0
- package/dist/main/anime/anime-spiral-loading.js +77 -0
- package/dist/main/anime/anime-spiral-loading.mjs +75 -0
- package/dist/main/anime/index.d.ts +3 -0
- package/dist/main/anime/index.js +12 -0
- package/dist/main/anime/index.mjs +4 -0
- package/dist/main/beam-frame/animate.d.ts +3 -0
- package/dist/main/beam-frame/animate.js +63 -0
- package/dist/main/beam-frame/animate.mjs +61 -0
- package/dist/main/beam-frame/beam-frame.d.ts +4 -0
- package/dist/main/beam-frame/beam-frame.js +262 -0
- package/dist/main/beam-frame/beam-frame.mjs +258 -0
- package/dist/main/beam-frame/index.d.ts +4 -0
- package/dist/main/beam-frame/index.js +11 -0
- package/dist/main/beam-frame/index.mjs +3 -0
- package/dist/main/beam-frame/motion.d.ts +3 -0
- package/dist/main/beam-frame/motion.js +61 -0
- package/dist/main/beam-frame/motion.mjs +59 -0
- package/dist/main/beam-frame/share-config.d.ts +54 -0
- package/dist/main/beam-frame/share-config.js +161 -0
- package/dist/main/beam-frame/share-config.mjs +152 -0
- package/dist/main/beam-frame-config.d.ts +54 -0
- package/dist/main/beam-frame-config.js +161 -0
- package/dist/main/beam-frame-config.mjs +152 -0
- package/dist/main/calendar/random-date-range-dialog.js +177 -51
- package/dist/main/calendar/random-date-range-dialog.mjs +178 -52
- package/dist/main/cta.js +17 -1
- package/dist/main/cta.mjs +18 -2
- package/dist/main/delayed-img.d.ts +1 -1
- package/dist/main/delayed-img.js +8 -5
- package/dist/main/delayed-img.mjs +8 -5
- package/dist/main/index.d.ts +1 -0
- package/dist/main/index.js +2 -0
- package/dist/main/index.mjs +1 -0
- package/dist/main/info-tooltip.js +70 -9
- package/dist/main/info-tooltip.mjs +70 -9
- package/dist/main/loading-frame/index.d.ts +1 -0
- package/dist/main/loading.d.ts +2 -1
- package/dist/main/loading.js +64 -26
- package/dist/main/loading.mjs +64 -26
- package/dist/main/motion/creative-left-panel.d.ts +7 -0
- package/dist/main/motion/creative-left-panel.js +11 -0
- package/dist/main/motion/creative-left-panel.mjs +9 -0
- package/dist/main/motion/creative-right-panel.d.ts +7 -0
- package/dist/main/motion/creative-right-panel.js +11 -0
- package/dist/main/motion/creative-right-panel.mjs +9 -0
- package/dist/main/motion/index.d.ts +1 -0
- package/dist/main/motion/index.js +9 -0
- package/dist/main/motion/index.mjs +2 -0
- package/dist/main/motion/motion-beam-frame.d.ts +3 -0
- package/dist/main/motion/motion-beam-frame.js +61 -0
- package/dist/main/motion/motion-beam-frame.mjs +59 -0
- package/dist/main/snake-loading-frame.d.ts +7 -3
- package/dist/main/snake-loading-frame.js +45 -252
- package/dist/main/snake-loading-frame.mjs +47 -254
- package/package.json +16 -5
- package/src/fuma/fuma-page-genarator.tsx +2 -22
- package/src/fuma/mdx/cheet-table.tsx +650 -0
- package/src/fuma/mdx/index.ts +1 -0
- package/src/fuma/server/features/widgets.tsx +2 -0
- package/src/main/404-page.tsx +162 -0
- package/src/main/alert-dialog/confirm-dialog.tsx +2 -1
- package/src/main/alert-dialog/dialog-loading-action.tsx +7 -5
- package/src/main/alert-dialog/dialog-styles.ts +13 -3
- package/src/main/alert-dialog/high-priority-confirm-dialog.tsx +26 -23
- package/src/main/alert-dialog/info-dialog.tsx +2 -1
- package/src/main/alert-dialog/undoable-confirm-dialog.tsx +18 -17
- package/src/main/anime/anime-404-page.tsx +344 -0
- package/src/main/anime/anime-beam-frame.tsx +128 -0
- package/src/main/anime/anime-spiral-loading.tsx +123 -0
- package/src/main/anime/index.ts +10 -0
- package/src/main/beam-frame-config.tsx +341 -0
- package/src/main/calendar/random-date-range-dialog.tsx +225 -69
- package/src/main/cta.tsx +50 -21
- package/src/main/delayed-img.tsx +9 -4
- package/src/main/index.ts +1 -0
- package/src/main/info-tooltip.tsx +116 -20
- package/src/main/loading-frame/index.ts +4 -0
- package/src/main/loading.tsx +75 -24
- package/src/main/motion/index.ts +8 -0
- package/src/main/motion/motion-beam-frame.tsx +137 -0
- package/src/main/snake-loading-frame.tsx +95 -496
- package/src/styles/cta.css +21 -4
- package/src/styles/third-ui.css +0 -20
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useRef, useEffect, useId } from 'react';
|
|
4
|
+
import { waapi } from 'animejs';
|
|
5
|
+
import { useReducedMotion, animate } from 'motion/react';
|
|
6
|
+
import { themeName } from '@windrun-huaiin/base-ui/lib';
|
|
7
|
+
import { cn } from '@windrun-huaiin/lib/utils';
|
|
8
|
+
|
|
9
|
+
const THEME_PALETTES = {
|
|
10
|
+
purple: { a: '#AC62FD', b: '#EC4899', c: '#6366F1' },
|
|
11
|
+
orange: { a: '#F97316', b: '#F59E0B', c: '#EF4444' },
|
|
12
|
+
indigo: { a: '#6366F1', b: '#3B82F6', c: '#06B6D4' },
|
|
13
|
+
emerald: { a: '#10B981', b: '#14B8A6', c: '#22C55E' },
|
|
14
|
+
rose: { a: '#F43F5E', b: '#EC4899', c: '#FB7185' },
|
|
15
|
+
};
|
|
16
|
+
const TONE_PALETTES = {
|
|
17
|
+
rainbow: { a: '#22D3EE', b: '#A855F7', c: '#F97316' },
|
|
18
|
+
mono: { a: '#E5E7EB', b: '#94A3B8', c: '#FFFFFF' },
|
|
19
|
+
warm: { a: '#F97316', b: '#FBBF24', c: '#EF4444' },
|
|
20
|
+
cool: { a: '#06B6D4', b: '#6366F1', c: '#14B8A6' },
|
|
21
|
+
};
|
|
22
|
+
const INTENSITY_STYLE = {
|
|
23
|
+
subtle: {
|
|
24
|
+
beamOpacity: 0.86,
|
|
25
|
+
glowOpacity: 0.16,
|
|
26
|
+
beamLength: 0.24,
|
|
27
|
+
beamWidth: 2.2,
|
|
28
|
+
haloWidth: 6,
|
|
29
|
+
},
|
|
30
|
+
regular: {
|
|
31
|
+
beamOpacity: 1,
|
|
32
|
+
glowOpacity: 0.24,
|
|
33
|
+
beamLength: 0.34,
|
|
34
|
+
beamWidth: 3,
|
|
35
|
+
haloWidth: 8,
|
|
36
|
+
},
|
|
37
|
+
strong: {
|
|
38
|
+
beamOpacity: 1,
|
|
39
|
+
glowOpacity: 0.32,
|
|
40
|
+
beamLength: 0.46,
|
|
41
|
+
beamWidth: 4,
|
|
42
|
+
haloWidth: 10,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
const BASE_BORDER_OPACITY = 0.18;
|
|
46
|
+
const BASE_DURATION_SECONDS = 1.8;
|
|
47
|
+
const DEFAULT_RADIUS = 24;
|
|
48
|
+
function getPalette(tone) {
|
|
49
|
+
var _a;
|
|
50
|
+
if (tone !== 'theme') {
|
|
51
|
+
return TONE_PALETTES[tone];
|
|
52
|
+
}
|
|
53
|
+
return (_a = THEME_PALETTES[themeName]) !== null && _a !== void 0 ? _a : THEME_PALETTES.purple;
|
|
54
|
+
}
|
|
55
|
+
function normalizeDuration(duration) {
|
|
56
|
+
if (!Number.isFinite(duration)) {
|
|
57
|
+
return 1.8;
|
|
58
|
+
}
|
|
59
|
+
return Math.max(0.4, duration);
|
|
60
|
+
}
|
|
61
|
+
function useMeasuredFrameSize() {
|
|
62
|
+
const ref = useRef(null);
|
|
63
|
+
const [size, setSize] = useState({ width: 0, height: 0 });
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
const node = ref.current;
|
|
66
|
+
if (!node) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
const updateSize = () => {
|
|
70
|
+
const rect = node.getBoundingClientRect();
|
|
71
|
+
setSize({
|
|
72
|
+
width: Math.max(0, rect.width),
|
|
73
|
+
height: Math.max(0, rect.height),
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
updateSize();
|
|
77
|
+
const observer = new ResizeObserver(updateSize);
|
|
78
|
+
observer.observe(node);
|
|
79
|
+
return () => observer.disconnect();
|
|
80
|
+
}, []);
|
|
81
|
+
return { ref, size };
|
|
82
|
+
}
|
|
83
|
+
function useInteractiveRunning(active, interactive) {
|
|
84
|
+
const [isInteractiveRunning, setIsInteractiveRunning] = useState(false);
|
|
85
|
+
const interactionProps = interactive
|
|
86
|
+
? {
|
|
87
|
+
onMouseEnter: () => setIsInteractiveRunning(true),
|
|
88
|
+
onMouseLeave: () => setIsInteractiveRunning(false),
|
|
89
|
+
onFocus: () => setIsInteractiveRunning(true),
|
|
90
|
+
onBlur: () => setIsInteractiveRunning(false),
|
|
91
|
+
}
|
|
92
|
+
: {};
|
|
93
|
+
return {
|
|
94
|
+
isRunning: active || isInteractiveRunning,
|
|
95
|
+
interactionProps,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function createRootStyle({ intensity, tone, radius, }) {
|
|
99
|
+
const palette = getPalette(tone);
|
|
100
|
+
const intensityStyle = INTENSITY_STYLE[intensity];
|
|
101
|
+
const frameRadius = radius !== null && radius !== void 0 ? radius : DEFAULT_RADIUS;
|
|
102
|
+
const svgRadius = Math.max(0, Math.min(49, frameRadius));
|
|
103
|
+
return {
|
|
104
|
+
'--beam-frame-radius': `${frameRadius}px`,
|
|
105
|
+
'--beam-frame-svg-radius': svgRadius,
|
|
106
|
+
'--beam-frame-color-a': palette.a,
|
|
107
|
+
'--beam-frame-color-b': palette.b,
|
|
108
|
+
'--beam-frame-color-c': palette.c,
|
|
109
|
+
'--beam-frame-border-opacity': BASE_BORDER_OPACITY,
|
|
110
|
+
'--beam-frame-beam-opacity': intensityStyle.beamOpacity,
|
|
111
|
+
'--beam-frame-glow-opacity': intensityStyle.glowOpacity,
|
|
112
|
+
'--beam-frame-beam-length': intensityStyle.beamLength,
|
|
113
|
+
'--beam-frame-beam-width': intensityStyle.beamWidth,
|
|
114
|
+
'--beam-frame-halo-width': intensityStyle.haloWidth,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function createBaseBorderBackground() {
|
|
118
|
+
return 'rgba(148, 163, 184, var(--beam-frame-border-opacity))';
|
|
119
|
+
}
|
|
120
|
+
function createBorderRingMask() {
|
|
121
|
+
return {
|
|
122
|
+
WebkitMask: 'linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)',
|
|
123
|
+
WebkitMaskComposite: 'xor',
|
|
124
|
+
maskComposite: 'exclude',
|
|
125
|
+
padding: '1px',
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function BeamFrameShell({ children, className, tone, intensity, radius, isRunning, interactionProps, renderBeam, rootRef, }) {
|
|
129
|
+
return (jsxs("div", Object.assign({ ref: rootRef, className: cn('group/beam-frame relative isolate overflow-hidden rounded-[var(--beam-frame-radius)] p-px', className), "data-beam-running": isRunning ? 'true' : 'false', style: createRootStyle({ intensity, tone, radius }) }, interactionProps, { children: [jsx("div", { "aria-hidden": "true", className: "pointer-events-none absolute inset-0 z-0 rounded-[inherit]", style: Object.assign({ background: createBaseBorderBackground() }, createBorderRingMask()) }), renderBeam(isRunning), jsx("div", { className: "relative z-10 rounded-[calc(var(--beam-frame-radius)-1px)]", children: children })] })));
|
|
130
|
+
}
|
|
131
|
+
function MotionAroundBeam({ isRunning, duration, radius, size, }) {
|
|
132
|
+
const gradientId = useId().replace(/:/g, '');
|
|
133
|
+
const haloGradientId = useId().replace(/:/g, '');
|
|
134
|
+
const beamGroupRef = useRef(null);
|
|
135
|
+
const controlsRef = useRef(null);
|
|
136
|
+
const hasStartedRef = useRef(false);
|
|
137
|
+
const strokeWidth = 3;
|
|
138
|
+
const width = Math.max(1, size.width);
|
|
139
|
+
const height = Math.max(1, size.height);
|
|
140
|
+
const rectOffset = strokeWidth / 2;
|
|
141
|
+
const rectWidth = Math.max(1, width - strokeWidth);
|
|
142
|
+
const rectHeight = Math.max(1, height - strokeWidth);
|
|
143
|
+
const rectRadius = Math.max(0, Math.min(radius !== null && radius !== void 0 ? radius : DEFAULT_RADIUS, rectWidth / 2, rectHeight / 2));
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
var _a;
|
|
146
|
+
const node = beamGroupRef.current;
|
|
147
|
+
if (!node) {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
if (isRunning) {
|
|
151
|
+
hasStartedRef.current = true;
|
|
152
|
+
}
|
|
153
|
+
node.style.opacity = isRunning || hasStartedRef.current ? 'var(--beam-frame-beam-opacity)' : '0';
|
|
154
|
+
if (!isRunning) {
|
|
155
|
+
(_a = controlsRef.current) === null || _a === void 0 ? void 0 : _a.pause();
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
if (controlsRef.current) {
|
|
159
|
+
controlsRef.current.speed = BASE_DURATION_SECONDS / duration;
|
|
160
|
+
controlsRef.current.play();
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
controlsRef.current = animate(node, { strokeDashoffset: [0, -1] }, {
|
|
164
|
+
duration: BASE_DURATION_SECONDS,
|
|
165
|
+
repeat: Infinity,
|
|
166
|
+
ease: 'linear',
|
|
167
|
+
});
|
|
168
|
+
controlsRef.current.speed = BASE_DURATION_SECONDS / duration;
|
|
169
|
+
return undefined;
|
|
170
|
+
}, [duration, isRunning]);
|
|
171
|
+
useEffect(() => {
|
|
172
|
+
return () => {
|
|
173
|
+
var _a;
|
|
174
|
+
(_a = controlsRef.current) === null || _a === void 0 ? void 0 : _a.stop();
|
|
175
|
+
controlsRef.current = null;
|
|
176
|
+
};
|
|
177
|
+
}, []);
|
|
178
|
+
return (jsxs("svg", { "aria-hidden": "true", className: "pointer-events-none absolute inset-0 z-0 h-full w-full overflow-visible", preserveAspectRatio: "none", viewBox: `0 0 ${width} ${height}`, children: [jsxs("g", { ref: beamGroupRef, opacity: "0", children: [jsx("rect", { x: rectOffset, y: rectOffset, width: rectWidth, height: rectHeight, rx: rectRadius, ry: rectRadius, pathLength: "1", fill: "none", stroke: `url(#${haloGradientId})`, strokeLinecap: "round", strokeWidth: "var(--beam-frame-halo-width)", vectorEffect: "non-scaling-stroke", style: {
|
|
179
|
+
strokeDasharray: 'calc(var(--beam-frame-beam-length) * 0.86) calc(1 - var(--beam-frame-beam-length) * 0.86)',
|
|
180
|
+
}, opacity: "var(--beam-frame-glow-opacity)" }), jsx("rect", { x: rectOffset, y: rectOffset, width: rectWidth, height: rectHeight, rx: rectRadius, ry: rectRadius, pathLength: "1", fill: "none", stroke: `url(#${gradientId})`, strokeLinecap: "round", strokeWidth: "var(--beam-frame-beam-width)", vectorEffect: "non-scaling-stroke", style: {
|
|
181
|
+
strokeDasharray: 'var(--beam-frame-beam-length) calc(1 - var(--beam-frame-beam-length))',
|
|
182
|
+
} })] }), jsxs("defs", { children: [jsxs("linearGradient", { id: haloGradientId, x1: "0%", x2: "100%", y1: "0%", y2: "100%", children: [jsx("stop", { offset: "0%", stopColor: "var(--beam-frame-color-a)", stopOpacity: "0.18" }), jsx("stop", { offset: "34%", stopColor: "var(--beam-frame-color-b)", stopOpacity: "0.72" }), jsx("stop", { offset: "54%", stopColor: "var(--beam-frame-color-c)", stopOpacity: "1" }), jsx("stop", { offset: "74%", stopColor: "var(--beam-frame-color-a)", stopOpacity: "0.66" }), jsx("stop", { offset: "100%", stopColor: "var(--beam-frame-color-b)", stopOpacity: "0.18" })] }), jsxs("linearGradient", { id: gradientId, x1: "0%", x2: "100%", y1: "0%", y2: "100%", children: [jsx("stop", { offset: "0%", stopColor: "var(--beam-frame-color-a)", stopOpacity: "0.52" }), jsx("stop", { offset: "34%", stopColor: "var(--beam-frame-color-b)", stopOpacity: "0.9" }), jsx("stop", { offset: "50%", stopColor: "var(--beam-frame-color-c)", stopOpacity: "1" }), jsx("stop", { offset: "68%", stopColor: "var(--beam-frame-color-a)", stopOpacity: "0.86" }), jsx("stop", { offset: "100%", stopColor: "var(--beam-frame-color-c)", stopOpacity: "0.52" })] })] })] }));
|
|
183
|
+
}
|
|
184
|
+
function MotionBeamFrame(props) {
|
|
185
|
+
const { children, active = false, interactive = true, intensity = 'regular', tone = 'theme', duration = 1.8, radius, className, } = props;
|
|
186
|
+
const prefersReducedMotion = useReducedMotion();
|
|
187
|
+
const { isRunning, interactionProps } = useInteractiveRunning(active, interactive);
|
|
188
|
+
const shouldRun = isRunning && !prefersReducedMotion;
|
|
189
|
+
const normalizedDuration = normalizeDuration(duration);
|
|
190
|
+
const { ref, size } = useMeasuredFrameSize();
|
|
191
|
+
return (jsx(BeamFrameShell, { active: active, interactive: interactive, intensity: intensity, tone: tone, duration: normalizedDuration, radius: radius, className: className, isRunning: shouldRun, interactionProps: interactionProps, rootRef: ref, renderBeam: () => (jsx(MotionAroundBeam, { isRunning: shouldRun, duration: normalizedDuration, radius: radius, size: size })), children: children }));
|
|
192
|
+
}
|
|
193
|
+
function AnimeBeamLayer({ isRunning, duration, radius, size, }) {
|
|
194
|
+
const aroundBeamRef = useRef(null);
|
|
195
|
+
const animationRef = useRef(null);
|
|
196
|
+
const hasStartedRef = useRef(false);
|
|
197
|
+
const gradientId = useId().replace(/:/g, '');
|
|
198
|
+
const haloGradientId = useId().replace(/:/g, '');
|
|
199
|
+
const strokeWidth = 3;
|
|
200
|
+
const width = Math.max(1, size.width);
|
|
201
|
+
const height = Math.max(1, size.height);
|
|
202
|
+
const rectOffset = strokeWidth / 2;
|
|
203
|
+
const rectWidth = Math.max(1, width - strokeWidth);
|
|
204
|
+
const rectHeight = Math.max(1, height - strokeWidth);
|
|
205
|
+
const rectRadius = Math.max(0, Math.min(radius !== null && radius !== void 0 ? radius : DEFAULT_RADIUS, rectWidth / 2, rectHeight / 2));
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
var _a;
|
|
208
|
+
const node = aroundBeamRef.current;
|
|
209
|
+
if (!node) {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
if (isRunning) {
|
|
213
|
+
hasStartedRef.current = true;
|
|
214
|
+
}
|
|
215
|
+
node.style.opacity = isRunning || hasStartedRef.current ? 'var(--beam-frame-beam-opacity)' : '0';
|
|
216
|
+
if (!isRunning) {
|
|
217
|
+
(_a = animationRef.current) === null || _a === void 0 ? void 0 : _a.pause();
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
if (animationRef.current) {
|
|
221
|
+
animationRef.current.playbackRate = BASE_DURATION_SECONDS / duration;
|
|
222
|
+
animationRef.current.play();
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
animationRef.current = waapi.animate(node, {
|
|
226
|
+
strokeDashoffset: [0, -1],
|
|
227
|
+
loop: true,
|
|
228
|
+
duration: BASE_DURATION_SECONDS * 1000,
|
|
229
|
+
ease: 'linear',
|
|
230
|
+
});
|
|
231
|
+
animationRef.current.playbackRate = BASE_DURATION_SECONDS / duration;
|
|
232
|
+
return undefined;
|
|
233
|
+
}, [duration, isRunning]);
|
|
234
|
+
useEffect(() => {
|
|
235
|
+
return () => {
|
|
236
|
+
var _a;
|
|
237
|
+
(_a = animationRef.current) === null || _a === void 0 ? void 0 : _a.revert();
|
|
238
|
+
animationRef.current = null;
|
|
239
|
+
};
|
|
240
|
+
}, []);
|
|
241
|
+
return (jsxs("svg", { "aria-hidden": "true", className: "pointer-events-none absolute inset-0 z-0 h-full w-full overflow-visible", preserveAspectRatio: "none", viewBox: `0 0 ${width} ${height}`, children: [jsxs("g", { ref: aroundBeamRef, opacity: "0", children: [jsx("rect", { x: rectOffset, y: rectOffset, width: rectWidth, height: rectHeight, rx: rectRadius, ry: rectRadius, pathLength: "1", fill: "none", stroke: `url(#${haloGradientId})`, strokeLinecap: "round", strokeWidth: "var(--beam-frame-halo-width)", vectorEffect: "non-scaling-stroke", style: {
|
|
242
|
+
strokeDasharray: 'calc(var(--beam-frame-beam-length) * 0.86) calc(1 - var(--beam-frame-beam-length) * 0.86)',
|
|
243
|
+
}, opacity: "var(--beam-frame-glow-opacity)" }), jsx("rect", { x: rectOffset, y: rectOffset, width: rectWidth, height: rectHeight, rx: rectRadius, ry: rectRadius, pathLength: "1", fill: "none", stroke: `url(#${gradientId})`, strokeLinecap: "round", strokeWidth: "var(--beam-frame-beam-width)", vectorEffect: "non-scaling-stroke", style: {
|
|
244
|
+
strokeDasharray: 'var(--beam-frame-beam-length) calc(1 - var(--beam-frame-beam-length))',
|
|
245
|
+
} })] }), jsxs("defs", { children: [jsxs("linearGradient", { id: haloGradientId, x1: "0%", x2: "100%", y1: "0%", y2: "100%", children: [jsx("stop", { offset: "0%", stopColor: "var(--beam-frame-color-a)", stopOpacity: "0.18" }), jsx("stop", { offset: "34%", stopColor: "var(--beam-frame-color-b)", stopOpacity: "0.72" }), jsx("stop", { offset: "54%", stopColor: "var(--beam-frame-color-c)", stopOpacity: "1" }), jsx("stop", { offset: "74%", stopColor: "var(--beam-frame-color-a)", stopOpacity: "0.66" }), jsx("stop", { offset: "100%", stopColor: "var(--beam-frame-color-b)", stopOpacity: "0.18" })] }), jsxs("linearGradient", { id: gradientId, x1: "0%", x2: "100%", y1: "0%", y2: "100%", children: [jsx("stop", { offset: "0%", stopColor: "var(--beam-frame-color-a)", stopOpacity: "0.52" }), jsx("stop", { offset: "34%", stopColor: "var(--beam-frame-color-b)", stopOpacity: "0.9" }), jsx("stop", { offset: "50%", stopColor: "var(--beam-frame-color-c)", stopOpacity: "1" }), jsx("stop", { offset: "68%", stopColor: "var(--beam-frame-color-a)", stopOpacity: "0.86" }), jsx("stop", { offset: "100%", stopColor: "var(--beam-frame-color-c)", stopOpacity: "0.52" })] })] })] }));
|
|
246
|
+
}
|
|
247
|
+
function AnimeBeamFrame(props) {
|
|
248
|
+
const { children, active = false, interactive = true, intensity = 'regular', tone = 'theme', duration = 1.8, radius, className, } = props;
|
|
249
|
+
const prefersReducedMotion = useReducedMotion();
|
|
250
|
+
const { isRunning, interactionProps } = useInteractiveRunning(active, interactive);
|
|
251
|
+
const shouldRun = isRunning && !prefersReducedMotion;
|
|
252
|
+
const normalizedDuration = normalizeDuration(duration);
|
|
253
|
+
const { ref, size } = useMeasuredFrameSize();
|
|
254
|
+
return (jsx(BeamFrameShell, { active: active, interactive: interactive, intensity: intensity, 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 }));
|
|
255
|
+
}
|
|
256
|
+
const BeamFrame = MotionBeamFrame;
|
|
257
|
+
|
|
258
|
+
export { AnimeBeamFrame, BeamFrame, MotionBeamFrame };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var animate = require('./animate.js');
|
|
5
|
+
var motion = require('./motion.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.AnimeBeamFrame = animate.AnimeBeamFrame;
|
|
10
|
+
exports.BeamFrame = motion.MotionBeamFrame;
|
|
11
|
+
exports.MotionBeamFrame = motion.MotionBeamFrame;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var react = require('motion/react');
|
|
7
|
+
var shareConfig = require('./share-config.js');
|
|
8
|
+
|
|
9
|
+
function MotionAroundBeam({ isRunning, duration, radius, size, }) {
|
|
10
|
+
const auraGradientId = React.useId().replace(/:/g, '');
|
|
11
|
+
const softGlowFilterId = React.useId().replace(/:/g, '');
|
|
12
|
+
const beamGroupRef = React.useRef(null);
|
|
13
|
+
const controlsRef = React.useRef(null);
|
|
14
|
+
const hasStartedRef = React.useRef(false);
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
var _a;
|
|
17
|
+
const node = beamGroupRef.current;
|
|
18
|
+
if (!node) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
if (isRunning) {
|
|
22
|
+
hasStartedRef.current = true;
|
|
23
|
+
}
|
|
24
|
+
node.style.opacity = isRunning || hasStartedRef.current ? 'var(--beam-frame-beam-opacity)' : '0';
|
|
25
|
+
if (!isRunning) {
|
|
26
|
+
(_a = controlsRef.current) === null || _a === void 0 ? void 0 : _a.pause();
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
if (controlsRef.current) {
|
|
30
|
+
controlsRef.current.speed = shareConfig.BASE_DURATION_SECONDS / duration;
|
|
31
|
+
controlsRef.current.play();
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
controlsRef.current = react.animate(node, { strokeDashoffset: [0, -1] }, {
|
|
35
|
+
duration: shareConfig.BASE_DURATION_SECONDS,
|
|
36
|
+
repeat: Infinity,
|
|
37
|
+
ease: 'linear',
|
|
38
|
+
});
|
|
39
|
+
controlsRef.current.speed = shareConfig.BASE_DURATION_SECONDS / duration;
|
|
40
|
+
return undefined;
|
|
41
|
+
}, [duration, isRunning]);
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
return () => {
|
|
44
|
+
var _a;
|
|
45
|
+
(_a = controlsRef.current) === null || _a === void 0 ? void 0 : _a.stop();
|
|
46
|
+
controlsRef.current = null;
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
49
|
+
return (jsxRuntime.jsx(shareConfig.BeamSvgLayer, { beamRef: beamGroupRef, auraGradientId: auraGradientId, softGlowFilterId: softGlowFilterId, radius: radius, size: size }));
|
|
50
|
+
}
|
|
51
|
+
function MotionBeamFrame(props) {
|
|
52
|
+
const { children, active = false, interactive = true, tone = 'theme', duration = shareConfig.BASE_DURATION_SECONDS, radius, className, } = props;
|
|
53
|
+
const prefersReducedMotion = react.useReducedMotion();
|
|
54
|
+
const { isRunning, interactionProps } = shareConfig.useInteractiveRunning(active, interactive);
|
|
55
|
+
const shouldRun = isRunning && !prefersReducedMotion;
|
|
56
|
+
const normalizedDuration = shareConfig.normalizeDuration(duration);
|
|
57
|
+
const { ref, size } = shareConfig.useMeasuredFrameSize();
|
|
58
|
+
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(MotionAroundBeam, { isRunning: shouldRun, duration: normalizedDuration, radius: radius, size: size })), children: children }));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.MotionBeamFrame = MotionBeamFrame;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useId, useRef, useEffect } from 'react';
|
|
4
|
+
import { useReducedMotion, animate } from 'motion/react';
|
|
5
|
+
import { BASE_DURATION_SECONDS, useInteractiveRunning, useMeasuredFrameSize, BeamFrameShell, normalizeDuration, BeamSvgLayer } from './share-config.mjs';
|
|
6
|
+
|
|
7
|
+
function MotionAroundBeam({ isRunning, duration, radius, size, }) {
|
|
8
|
+
const auraGradientId = useId().replace(/:/g, '');
|
|
9
|
+
const softGlowFilterId = useId().replace(/:/g, '');
|
|
10
|
+
const beamGroupRef = useRef(null);
|
|
11
|
+
const controlsRef = useRef(null);
|
|
12
|
+
const hasStartedRef = useRef(false);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
var _a;
|
|
15
|
+
const node = beamGroupRef.current;
|
|
16
|
+
if (!node) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
if (isRunning) {
|
|
20
|
+
hasStartedRef.current = true;
|
|
21
|
+
}
|
|
22
|
+
node.style.opacity = isRunning || hasStartedRef.current ? 'var(--beam-frame-beam-opacity)' : '0';
|
|
23
|
+
if (!isRunning) {
|
|
24
|
+
(_a = controlsRef.current) === null || _a === void 0 ? void 0 : _a.pause();
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
if (controlsRef.current) {
|
|
28
|
+
controlsRef.current.speed = BASE_DURATION_SECONDS / duration;
|
|
29
|
+
controlsRef.current.play();
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
controlsRef.current = animate(node, { strokeDashoffset: [0, -1] }, {
|
|
33
|
+
duration: BASE_DURATION_SECONDS,
|
|
34
|
+
repeat: Infinity,
|
|
35
|
+
ease: 'linear',
|
|
36
|
+
});
|
|
37
|
+
controlsRef.current.speed = BASE_DURATION_SECONDS / duration;
|
|
38
|
+
return undefined;
|
|
39
|
+
}, [duration, isRunning]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
return () => {
|
|
42
|
+
var _a;
|
|
43
|
+
(_a = controlsRef.current) === null || _a === void 0 ? void 0 : _a.stop();
|
|
44
|
+
controlsRef.current = null;
|
|
45
|
+
};
|
|
46
|
+
}, []);
|
|
47
|
+
return (jsx(BeamSvgLayer, { beamRef: beamGroupRef, auraGradientId: auraGradientId, softGlowFilterId: softGlowFilterId, radius: radius, size: size }));
|
|
48
|
+
}
|
|
49
|
+
function MotionBeamFrame(props) {
|
|
50
|
+
const { children, active = false, interactive = true, tone = 'theme', duration = BASE_DURATION_SECONDS, radius, className, } = props;
|
|
51
|
+
const prefersReducedMotion = useReducedMotion();
|
|
52
|
+
const { isRunning, interactionProps } = useInteractiveRunning(active, interactive);
|
|
53
|
+
const shouldRun = isRunning && !prefersReducedMotion;
|
|
54
|
+
const normalizedDuration = normalizeDuration(duration);
|
|
55
|
+
const { ref, size } = useMeasuredFrameSize();
|
|
56
|
+
return (jsx(BeamFrameShell, { active: active, interactive: interactive, tone: tone, duration: normalizedDuration, radius: radius, className: className, isRunning: shouldRun, interactionProps: interactionProps, rootRef: ref, renderBeam: () => (jsx(MotionAroundBeam, { isRunning: shouldRun, duration: normalizedDuration, radius: radius, size: size })), children: children }));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { MotionBeamFrame };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { DOMAttributes, ReactNode, RefObject } from 'react';
|
|
2
|
+
export type BeamFrameTone = 'theme' | 'rainbow' | 'mono' | 'warm' | 'cool';
|
|
3
|
+
export type BeamFrameProps = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
active?: boolean;
|
|
6
|
+
interactive?: boolean;
|
|
7
|
+
tone?: BeamFrameTone;
|
|
8
|
+
duration?: number;
|
|
9
|
+
radius?: number;
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
export type BeamFrameRenderProps = Required<Pick<BeamFrameProps, 'active' | 'interactive' | 'tone' | 'duration'>> & Pick<BeamFrameProps, 'children' | 'className' | 'radius'>;
|
|
13
|
+
export type FrameSize = {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
};
|
|
17
|
+
export declare const BASE_DURATION_SECONDS = 3.6;
|
|
18
|
+
export declare const DEFAULT_RADIUS = 24;
|
|
19
|
+
export declare function normalizeDuration(duration: number): number;
|
|
20
|
+
export declare function useMeasuredFrameSize<T extends HTMLElement>(): {
|
|
21
|
+
ref: RefObject<T | null>;
|
|
22
|
+
size: FrameSize;
|
|
23
|
+
};
|
|
24
|
+
export declare function useInteractiveRunning(active: boolean, interactive: boolean): {
|
|
25
|
+
isRunning: boolean;
|
|
26
|
+
interactionProps: Pick<DOMAttributes<HTMLDivElement>, "onFocus" | "onBlur" | "onMouseEnter" | "onMouseLeave">;
|
|
27
|
+
};
|
|
28
|
+
export declare function BeamFrameShell({ children, className, tone, radius, isRunning, interactionProps, renderBeam, rootRef, }: BeamFrameRenderProps & {
|
|
29
|
+
isRunning: boolean;
|
|
30
|
+
interactionProps: Pick<DOMAttributes<HTMLDivElement>, 'onBlur' | 'onFocus' | 'onMouseEnter' | 'onMouseLeave'>;
|
|
31
|
+
renderBeam: () => ReactNode;
|
|
32
|
+
rootRef: RefObject<HTMLDivElement | null>;
|
|
33
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export declare function createBeamGeometry({ radius, size, }: {
|
|
35
|
+
radius?: number;
|
|
36
|
+
size: FrameSize;
|
|
37
|
+
}): {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
rectOffset: number;
|
|
41
|
+
rectWidth: number;
|
|
42
|
+
rectHeight: number;
|
|
43
|
+
rectRadius: number;
|
|
44
|
+
rectRight: number;
|
|
45
|
+
rectBottom: number;
|
|
46
|
+
extendedRoundedPath: string;
|
|
47
|
+
};
|
|
48
|
+
export declare function BeamSvgLayer({ beamRef, auraGradientId, softGlowFilterId, radius, size, }: {
|
|
49
|
+
beamRef: RefObject<SVGGElement | null>;
|
|
50
|
+
auraGradientId: string;
|
|
51
|
+
softGlowFilterId: string;
|
|
52
|
+
radius?: number;
|
|
53
|
+
size: FrameSize;
|
|
54
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var lib = require('@windrun-huaiin/base-ui/lib');
|
|
7
|
+
var utils = require('@windrun-huaiin/lib/utils');
|
|
8
|
+
|
|
9
|
+
const THEME_PALETTES = {
|
|
10
|
+
purple: { a: '#AC62FD', b: '#EC4899', c: '#6366F1' },
|
|
11
|
+
orange: { a: '#F97316', b: '#F59E0B', c: '#EF4444' },
|
|
12
|
+
indigo: { a: '#6366F1', b: '#3B82F6', c: '#06B6D4' },
|
|
13
|
+
emerald: { a: '#10B981', b: '#14B8A6', c: '#22C55E' },
|
|
14
|
+
rose: { a: '#F43F5E', b: '#EC4899', c: '#FB7185' },
|
|
15
|
+
};
|
|
16
|
+
const TONE_PALETTES = {
|
|
17
|
+
rainbow: { a: '#FF3D77', b: '#3388FF', c: '#00FF88' },
|
|
18
|
+
mono: { a: '#E5E7EB', b: '#94A3B8', c: '#FFFFFF' },
|
|
19
|
+
warm: { a: '#F97316', b: '#FBBF24', c: '#EF4444' },
|
|
20
|
+
cool: { a: '#06B6D4', b: '#6366F1', c: '#14B8A6' },
|
|
21
|
+
};
|
|
22
|
+
const BEAM_FRAME_STYLE = {
|
|
23
|
+
ambientGlowOpacity: 0.24,
|
|
24
|
+
beamOpacity: 1.0,
|
|
25
|
+
auraOpacity: 0.86,
|
|
26
|
+
auraLength: 0.08,
|
|
27
|
+
traceLength: 0.42,
|
|
28
|
+
traceWidth: 1.15,
|
|
29
|
+
ambientGlowWidth: 7,
|
|
30
|
+
auraWidth: 8.5,
|
|
31
|
+
};
|
|
32
|
+
const BASE_BORDER_OPACITY = 0.18;
|
|
33
|
+
const BASE_DURATION_SECONDS = 3.6;
|
|
34
|
+
const DEFAULT_RADIUS = 24;
|
|
35
|
+
function getPalette(tone) {
|
|
36
|
+
var _a;
|
|
37
|
+
if (tone !== 'theme') {
|
|
38
|
+
return TONE_PALETTES[tone];
|
|
39
|
+
}
|
|
40
|
+
return (_a = THEME_PALETTES[lib.themeName]) !== null && _a !== void 0 ? _a : THEME_PALETTES.purple;
|
|
41
|
+
}
|
|
42
|
+
function normalizeDuration(duration) {
|
|
43
|
+
if (!Number.isFinite(duration)) {
|
|
44
|
+
return BASE_DURATION_SECONDS;
|
|
45
|
+
}
|
|
46
|
+
return Math.max(0.4, duration);
|
|
47
|
+
}
|
|
48
|
+
function useMeasuredFrameSize() {
|
|
49
|
+
const ref = React.useRef(null);
|
|
50
|
+
const [size, setSize] = React.useState({ width: 0, height: 0 });
|
|
51
|
+
React.useEffect(() => {
|
|
52
|
+
const node = ref.current;
|
|
53
|
+
if (!node) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
const updateSize = () => {
|
|
57
|
+
const rect = node.getBoundingClientRect();
|
|
58
|
+
setSize({
|
|
59
|
+
width: Math.max(0, rect.width),
|
|
60
|
+
height: Math.max(0, rect.height),
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
updateSize();
|
|
64
|
+
const observer = new ResizeObserver(updateSize);
|
|
65
|
+
observer.observe(node);
|
|
66
|
+
return () => observer.disconnect();
|
|
67
|
+
}, []);
|
|
68
|
+
return { ref, size };
|
|
69
|
+
}
|
|
70
|
+
function useInteractiveRunning(active, interactive) {
|
|
71
|
+
const [isInteractiveRunning, setIsInteractiveRunning] = React.useState(false);
|
|
72
|
+
const interactionProps = interactive
|
|
73
|
+
? {
|
|
74
|
+
onMouseEnter: () => setIsInteractiveRunning(true),
|
|
75
|
+
onMouseLeave: () => setIsInteractiveRunning(false),
|
|
76
|
+
onFocus: () => setIsInteractiveRunning(true),
|
|
77
|
+
onBlur: () => setIsInteractiveRunning(false),
|
|
78
|
+
}
|
|
79
|
+
: {};
|
|
80
|
+
return {
|
|
81
|
+
isRunning: active || isInteractiveRunning,
|
|
82
|
+
interactionProps,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function createRootStyle({ tone, radius, }) {
|
|
86
|
+
const palette = getPalette(tone);
|
|
87
|
+
const frameRadius = radius !== null && radius !== void 0 ? radius : DEFAULT_RADIUS;
|
|
88
|
+
return {
|
|
89
|
+
'--beam-frame-radius': `${frameRadius}px`,
|
|
90
|
+
'--beam-frame-color-a': palette.a,
|
|
91
|
+
'--beam-frame-color-b': palette.b,
|
|
92
|
+
'--beam-frame-color-c': palette.c,
|
|
93
|
+
'--beam-frame-border-opacity': BASE_BORDER_OPACITY,
|
|
94
|
+
'--beam-frame-ambient-glow-opacity': BEAM_FRAME_STYLE.ambientGlowOpacity,
|
|
95
|
+
'--beam-frame-beam-opacity': BEAM_FRAME_STYLE.beamOpacity,
|
|
96
|
+
'--beam-frame-aura-opacity': BEAM_FRAME_STYLE.auraOpacity,
|
|
97
|
+
'--beam-frame-aura-length': BEAM_FRAME_STYLE.auraLength,
|
|
98
|
+
'--beam-frame-aura-dash-pattern': 'var(--beam-frame-aura-length) calc(1 - var(--beam-frame-aura-length))',
|
|
99
|
+
'--beam-frame-trace-length': BEAM_FRAME_STYLE.traceLength,
|
|
100
|
+
'--beam-frame-trace-dash-pattern': 'var(--beam-frame-trace-length) calc(1 - var(--beam-frame-trace-length))',
|
|
101
|
+
'--beam-frame-trace-width': BEAM_FRAME_STYLE.traceWidth,
|
|
102
|
+
'--beam-frame-ambient-glow-width': BEAM_FRAME_STYLE.ambientGlowWidth,
|
|
103
|
+
'--beam-frame-aura-width': BEAM_FRAME_STYLE.auraWidth,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function BeamFrameShell({ children, className, tone, radius, isRunning, interactionProps, renderBeam, rootRef, }) {
|
|
107
|
+
return (jsxRuntime.jsxs("div", Object.assign({ ref: rootRef, className: utils.cn('group/beam-frame relative isolate overflow-hidden rounded-(--beam-frame-radius) p-px', className), "data-beam-running": isRunning ? 'true' : 'false', style: createRootStyle({ tone, radius }) }, interactionProps, { children: [renderBeam(), jsxRuntime.jsx("div", { className: "relative z-10 rounded-[calc(var(--beam-frame-radius)-1px)]", children: children })] })));
|
|
108
|
+
}
|
|
109
|
+
function createBeamGeometry({ radius, size, }) {
|
|
110
|
+
const strokeWidth = 3;
|
|
111
|
+
const width = Math.max(1, size.width);
|
|
112
|
+
const height = Math.max(1, size.height);
|
|
113
|
+
const rectOffset = strokeWidth / 2;
|
|
114
|
+
const rectWidth = Math.max(1, width - strokeWidth);
|
|
115
|
+
const rectHeight = Math.max(1, height - strokeWidth);
|
|
116
|
+
const rectRadius = Math.max(0, Math.min(radius !== null && radius !== void 0 ? radius : DEFAULT_RADIUS, rectWidth / 2, rectHeight / 2));
|
|
117
|
+
const rectRight = rectOffset + rectWidth;
|
|
118
|
+
const rectBottom = rectOffset + rectHeight;
|
|
119
|
+
const roundedPathLap = [
|
|
120
|
+
`H ${rectRight - rectRadius}`,
|
|
121
|
+
`A ${rectRadius} ${rectRadius} 0 0 1 ${rectRight} ${rectOffset + rectRadius}`,
|
|
122
|
+
`V ${rectBottom - rectRadius}`,
|
|
123
|
+
`A ${rectRadius} ${rectRadius} 0 0 1 ${rectRight - rectRadius} ${rectBottom}`,
|
|
124
|
+
`H ${rectOffset + rectRadius}`,
|
|
125
|
+
`A ${rectRadius} ${rectRadius} 0 0 1 ${rectOffset} ${rectBottom - rectRadius}`,
|
|
126
|
+
`V ${rectOffset + rectRadius}`,
|
|
127
|
+
`A ${rectRadius} ${rectRadius} 0 0 1 ${rectOffset + rectRadius} ${rectOffset}`,
|
|
128
|
+
].join(' ');
|
|
129
|
+
const extendedRoundedPath = `M ${rectOffset + rectRadius} ${rectOffset} ${roundedPathLap} ${roundedPathLap}`;
|
|
130
|
+
return {
|
|
131
|
+
width,
|
|
132
|
+
height,
|
|
133
|
+
rectOffset,
|
|
134
|
+
rectWidth,
|
|
135
|
+
rectHeight,
|
|
136
|
+
rectRadius,
|
|
137
|
+
rectRight,
|
|
138
|
+
rectBottom,
|
|
139
|
+
extendedRoundedPath,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function BeamSvgLayer({ beamRef, auraGradientId, softGlowFilterId, radius, size, }) {
|
|
143
|
+
const { width, height, rectOffset, rectWidth, rectHeight, rectRadius, rectRight, rectBottom, extendedRoundedPath, } = createBeamGeometry({
|
|
144
|
+
radius,
|
|
145
|
+
size,
|
|
146
|
+
});
|
|
147
|
+
return (jsxRuntime.jsxs("svg", { "aria-hidden": "true", className: "pointer-events-none absolute inset-0 z-20 h-full w-full overflow-visible", preserveAspectRatio: "none", viewBox: `0 0 ${width} ${height}`, children: [jsxRuntime.jsxs("g", { ref: beamRef, opacity: "0", style: { mixBlendMode: 'plus-lighter' }, children: [jsxRuntime.jsx("rect", { x: rectOffset, y: rectOffset, width: rectWidth, height: rectHeight, rx: rectRadius, ry: rectRadius, pathLength: "1", fill: "none", stroke: `url(#${auraGradientId})`, strokeLinecap: "round", strokeWidth: "var(--beam-frame-ambient-glow-width)", vectorEffect: "non-scaling-stroke", filter: `url(#${softGlowFilterId})`, opacity: "var(--beam-frame-ambient-glow-opacity)" }), jsxRuntime.jsx("path", { d: extendedRoundedPath, pathLength: "2", fill: "none", stroke: `url(#${auraGradientId})`, strokeLinecap: "round", strokeWidth: "var(--beam-frame-aura-width)", vectorEffect: "non-scaling-stroke", filter: `url(#${softGlowFilterId})`, style: {
|
|
148
|
+
strokeDasharray: 'var(--beam-frame-aura-dash-pattern)',
|
|
149
|
+
}, opacity: "var(--beam-frame-aura-opacity)" }), jsxRuntime.jsx("path", { d: extendedRoundedPath, pathLength: "2", fill: "none", stroke: `url(#${auraGradientId})`, strokeLinecap: "round", strokeWidth: "var(--beam-frame-trace-width)", vectorEffect: "non-scaling-stroke", style: {
|
|
150
|
+
strokeDasharray: 'var(--beam-frame-trace-dash-pattern)',
|
|
151
|
+
}, opacity: "var(--beam-frame-beam-opacity)" })] }), jsxRuntime.jsxs("defs", { children: [jsxRuntime.jsx("filter", { id: softGlowFilterId, x: "-40%", y: "-40%", width: "180%", height: "180%", children: jsxRuntime.jsx("feGaussianBlur", { stdDeviation: "8" }) }), jsxRuntime.jsxs("linearGradient", { id: auraGradientId, x1: rectOffset, x2: rectRight, y1: rectOffset, y2: rectBottom, gradientUnits: "userSpaceOnUse", children: [jsxRuntime.jsx("stop", { offset: "0%", stopColor: "var(--beam-frame-color-a)", stopOpacity: "0.58" }), jsxRuntime.jsx("stop", { offset: "22%", stopColor: "var(--beam-frame-color-b)", stopOpacity: "0.78" }), jsxRuntime.jsx("stop", { offset: "44%", stopColor: "var(--beam-frame-color-c)", stopOpacity: "0.96" }), jsxRuntime.jsx("stop", { offset: "58%", stopColor: "var(--beam-frame-color-b)", stopOpacity: "1" }), jsxRuntime.jsx("stop", { offset: "78%", stopColor: "var(--beam-frame-color-a)", stopOpacity: "0.82" }), jsxRuntime.jsx("stop", { offset: "100%", stopColor: "var(--beam-frame-color-c)", stopOpacity: "0.58" })] })] })] }));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
exports.BASE_DURATION_SECONDS = BASE_DURATION_SECONDS;
|
|
155
|
+
exports.BeamFrameShell = BeamFrameShell;
|
|
156
|
+
exports.BeamSvgLayer = BeamSvgLayer;
|
|
157
|
+
exports.DEFAULT_RADIUS = DEFAULT_RADIUS;
|
|
158
|
+
exports.createBeamGeometry = createBeamGeometry;
|
|
159
|
+
exports.normalizeDuration = normalizeDuration;
|
|
160
|
+
exports.useInteractiveRunning = useInteractiveRunning;
|
|
161
|
+
exports.useMeasuredFrameSize = useMeasuredFrameSize;
|