@moonwitness/ui 7.3.0 → 8.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 (261) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/pixelfx-boundary.js +1 -1
  3. package/package.json +2 -3
  4. package/scripts/consumer-smoke.mjs +0 -45
  5. package/scripts/generate-icons.mjs +0 -110
  6. package/scripts/generate-token-artifacts.mjs +0 -90
  7. package/scripts/icon-svg-to-jsx.mjs +0 -249
  8. package/scripts/verification-diagnostics.mjs +0 -40
  9. package/scripts/verify-package.mjs +0 -412
  10. package/src/cartoon/anime-avatar.tsx +0 -628
  11. package/src/cartoon/anime-stage.tsx +0 -458
  12. package/src/cartoon/index.tsx +0 -542
  13. package/src/cartoon.tsx +0 -645
  14. package/src/characters.ts +0 -625
  15. package/src/components/accordion.tsx +0 -77
  16. package/src/components/alert.tsx +0 -139
  17. package/src/components/appearance-menu.tsx +0 -181
  18. package/src/components/artwork-frame.tsx +0 -49
  19. package/src/components/audio.tsx +0 -97
  20. package/src/components/avatar.tsx +0 -75
  21. package/src/components/badge.tsx +0 -94
  22. package/src/components/brand-mark.tsx +0 -73
  23. package/src/components/breadcrumbs.tsx +0 -98
  24. package/src/components/button.tsx +0 -340
  25. package/src/components/card.tsx +0 -171
  26. package/src/components/character-badge.tsx +0 -58
  27. package/src/components/character-preview.tsx +0 -104
  28. package/src/components/character-stage.tsx +0 -225
  29. package/src/components/chart.tsx +0 -481
  30. package/src/components/checkbox.tsx +0 -64
  31. package/src/components/comic-panel.tsx +0 -301
  32. package/src/components/comic-theater.tsx +0 -170
  33. package/src/components/command.tsx +0 -189
  34. package/src/components/confirm-dialog.tsx +0 -129
  35. package/src/components/copy-button.tsx +0 -62
  36. package/src/components/date-picker.tsx +0 -126
  37. package/src/components/dialog.tsx +0 -164
  38. package/src/components/dna-icon.tsx +0 -77
  39. package/src/components/dropdown-menu.tsx +0 -87
  40. package/src/components/effects.tsx +0 -1021
  41. package/src/components/empty-state.tsx +0 -93
  42. package/src/components/epistemic-branch-panel.tsx +0 -101
  43. package/src/components/error-state.tsx +0 -137
  44. package/src/components/field.tsx +0 -96
  45. package/src/components/filter-facet-bar.tsx +0 -91
  46. package/src/components/inbox-popover.tsx +0 -146
  47. package/src/components/input.tsx +0 -25
  48. package/src/components/kanban-board.tsx +0 -190
  49. package/src/components/label.tsx +0 -19
  50. package/src/components/layered-scene.tsx +0 -555
  51. package/src/components/log-console.tsx +0 -261
  52. package/src/components/metric-tile.tsx +0 -99
  53. package/src/components/mode-picker.tsx +0 -149
  54. package/src/components/motion-timeline.tsx +0 -848
  55. package/src/components/number-input.tsx +0 -104
  56. package/src/components/page-header.tsx +0 -123
  57. package/src/components/pagination.tsx +0 -83
  58. package/src/components/panel.tsx +0 -121
  59. package/src/components/paper-note.tsx +0 -77
  60. package/src/components/popover.tsx +0 -72
  61. package/src/components/progress.tsx +0 -127
  62. package/src/components/quest-card.tsx +0 -319
  63. package/src/components/radio-group.tsx +0 -50
  64. package/src/components/riot-sticker.tsx +0 -151
  65. package/src/components/scene-particles.tsx +0 -196
  66. package/src/components/scene-transitions.tsx +0 -130
  67. package/src/components/section-ribbon.tsx +0 -94
  68. package/src/components/select-field.tsx +0 -27
  69. package/src/components/select.tsx +0 -81
  70. package/src/components/separator.tsx +0 -58
  71. package/src/components/sheet.tsx +0 -96
  72. package/src/components/skeleton.tsx +0 -35
  73. package/src/components/sketch-annotation.tsx +0 -87
  74. package/src/components/smart-button-box.tsx +0 -114
  75. package/src/components/speech-bubble.tsx +0 -116
  76. package/src/components/spinner.tsx +0 -69
  77. package/src/components/sprite-player.tsx +0 -412
  78. package/src/components/status-bar.tsx +0 -63
  79. package/src/components/status-pill.tsx +0 -68
  80. package/src/components/switch.tsx +0 -76
  81. package/src/components/table.tsx +0 -163
  82. package/src/components/tabs.tsx +0 -101
  83. package/src/components/tag-input.tsx +0 -170
  84. package/src/components/textarea.tsx +0 -25
  85. package/src/components/toast.tsx +0 -14
  86. package/src/components/toolbar.tsx +0 -39
  87. package/src/components/tooltip.tsx +0 -49
  88. package/src/components/update-banner.tsx +0 -220
  89. package/src/components/xv-primitives.tsx +0 -256
  90. package/src/css-exports.ts +0 -142
  91. package/src/dna.tsx +0 -137
  92. package/src/game/boss-hud.tsx +0 -384
  93. package/src/game/index.tsx +0 -886
  94. package/src/game/tactical.tsx +0 -245
  95. package/src/game.tsx +0 -770
  96. package/src/icons/activity.tsx +0 -38
  97. package/src/icons/add.tsx +0 -38
  98. package/src/icons/addon.tsx +0 -37
  99. package/src/icons/anime-anger.tsx +0 -37
  100. package/src/icons/anime-shock.tsx +0 -37
  101. package/src/icons/anime-sparkle.tsx +0 -38
  102. package/src/icons/anime-sweatdrop.tsx +0 -38
  103. package/src/icons/archive.tsx +0 -37
  104. package/src/icons/arrow-left.tsx +0 -37
  105. package/src/icons/arrow-right.tsx +0 -37
  106. package/src/icons/attachment.tsx +0 -38
  107. package/src/icons/bank.tsx +0 -37
  108. package/src/icons/bolt.tsx +0 -37
  109. package/src/icons/book-open.tsx +0 -37
  110. package/src/icons/bookmark.tsx +0 -37
  111. package/src/icons/boss-skull.tsx +0 -40
  112. package/src/icons/calendar-clock.tsx +0 -40
  113. package/src/icons/calendar.tsx +0 -38
  114. package/src/icons/check-circle.tsx +0 -38
  115. package/src/icons/check-square.tsx +0 -38
  116. package/src/icons/check.tsx +0 -37
  117. package/src/icons/chevron-right.tsx +0 -37
  118. package/src/icons/chevrons-left.tsx +0 -37
  119. package/src/icons/chevrons-right.tsx +0 -37
  120. package/src/icons/clapperboard.tsx +0 -38
  121. package/src/icons/clock.tsx +0 -38
  122. package/src/icons/close.tsx +0 -37
  123. package/src/icons/code.tsx +0 -37
  124. package/src/icons/columns.tsx +0 -38
  125. package/src/icons/combo-flame.tsx +0 -38
  126. package/src/icons/company.tsx +0 -38
  127. package/src/icons/credit-card.tsx +0 -38
  128. package/src/icons/critical-star.tsx +0 -37
  129. package/src/icons/currency.tsx +0 -38
  130. package/src/icons/delete.tsx +0 -37
  131. package/src/icons/document.tsx +0 -38
  132. package/src/icons/download.tsx +0 -37
  133. package/src/icons/dpad.tsx +0 -38
  134. package/src/icons/edit.tsx +0 -38
  135. package/src/icons/element-fire.tsx +0 -37
  136. package/src/icons/element-ice.tsx +0 -38
  137. package/src/icons/element-solar.tsx +0 -38
  138. package/src/icons/element-void.tsx +0 -38
  139. package/src/icons/element-volt.tsx +0 -38
  140. package/src/icons/element-wind.tsx +0 -37
  141. package/src/icons/error.tsx +0 -38
  142. package/src/icons/external-link.tsx +0 -38
  143. package/src/icons/field.tsx +0 -38
  144. package/src/icons/file-spreadsheet.tsx +0 -38
  145. package/src/icons/filter.tsx +0 -37
  146. package/src/icons/gacha-ticket.tsx +0 -38
  147. package/src/icons/gamepad.tsx +0 -40
  148. package/src/icons/globe.tsx +0 -38
  149. package/src/icons/grid.tsx +0 -40
  150. package/src/icons/hash.tsx +0 -37
  151. package/src/icons/heart-hp.tsx +0 -38
  152. package/src/icons/history.tsx +0 -37
  153. package/src/icons/home.tsx +0 -37
  154. package/src/icons/image.tsx +0 -39
  155. package/src/icons/impact-slash.tsx +0 -38
  156. package/src/icons/inbox.tsx +0 -38
  157. package/src/icons/index.ts +0 -120
  158. package/src/icons/info.tsx +0 -38
  159. package/src/icons/jobs.tsx +0 -38
  160. package/src/icons/katana.tsx +0 -38
  161. package/src/icons/key.tsx +0 -38
  162. package/src/icons/keyboard.tsx +0 -38
  163. package/src/icons/keyframe-diamond.tsx +0 -38
  164. package/src/icons/knowledge.tsx +0 -38
  165. package/src/icons/language.tsx +0 -39
  166. package/src/icons/lock.tsx +0 -38
  167. package/src/icons/logout.tsx +0 -37
  168. package/src/icons/loot-chest.tsx +0 -39
  169. package/src/icons/mail.tsx +0 -38
  170. package/src/icons/mana-crystal.tsx +0 -38
  171. package/src/icons/map-pin.tsx +0 -38
  172. package/src/icons/mecha-helm.tsx +0 -38
  173. package/src/icons/menu.tsx +0 -37
  174. package/src/icons/message.tsx +0 -38
  175. package/src/icons/model.tsx +0 -38
  176. package/src/icons/moon.tsx +0 -37
  177. package/src/icons/notification.tsx +0 -38
  178. package/src/icons/partner.tsx +0 -41
  179. package/src/icons/pause.tsx +0 -37
  180. package/src/icons/phone.tsx +0 -37
  181. package/src/icons/play.tsx +0 -37
  182. package/src/icons/potion-flask.tsx +0 -40
  183. package/src/icons/quest-scroll.tsx +0 -39
  184. package/src/icons/radar-ping.tsx +0 -40
  185. package/src/icons/refresh.tsx +0 -38
  186. package/src/icons/relation.tsx +0 -40
  187. package/src/icons/save.tsx +0 -38
  188. package/src/icons/search.tsx +0 -38
  189. package/src/icons/security.tsx +0 -38
  190. package/src/icons/send.tsx +0 -38
  191. package/src/icons/settings.tsx +0 -39
  192. package/src/icons/shield-crest.tsx +0 -38
  193. package/src/icons/shuriken.tsx +0 -38
  194. package/src/icons/signal-off.tsx +0 -37
  195. package/src/icons/signal.tsx +0 -37
  196. package/src/icons/skill-node.tsx +0 -40
  197. package/src/icons/smartphone.tsx +0 -38
  198. package/src/icons/sort-ascending.tsx +0 -37
  199. package/src/icons/sort-descending.tsx +0 -37
  200. package/src/icons/sort.tsx +0 -37
  201. package/src/icons/sparkle.tsx +0 -38
  202. package/src/icons/speech-burst.tsx +0 -37
  203. package/src/icons/story.tsx +0 -37
  204. package/src/icons/sun.tsx +0 -38
  205. package/src/icons/tag.tsx +0 -38
  206. package/src/icons/team.tsx +0 -40
  207. package/src/icons/trophy-crown.tsx +0 -39
  208. package/src/icons/upload.tsx +0 -37
  209. package/src/icons/user.tsx +0 -38
  210. package/src/icons/users.tsx +0 -39
  211. package/src/icons/visibility-off.tsx +0 -38
  212. package/src/icons/visibility.tsx +0 -38
  213. package/src/icons/volume-off.tsx +0 -37
  214. package/src/icons/volume.tsx +0 -37
  215. package/src/icons/warning.tsx +0 -38
  216. package/src/icons/workflow.tsx +0 -40
  217. package/src/icons.tsx +0 -965
  218. package/src/index.ts +0 -89
  219. package/src/lib/asset-registry.ts +0 -534
  220. package/src/lib/audio-runtime.ts +0 -314
  221. package/src/lib/character-adapter.ts +0 -370
  222. package/src/lib/character-registry.ts +0 -2368
  223. package/src/lib/cn.ts +0 -6
  224. package/src/lib/compose-refs.ts +0 -16
  225. package/src/lib/sanitize-url.ts +0 -51
  226. package/src/lib/scene-camera.ts +0 -483
  227. package/src/lib/scene-playback.ts +0 -622
  228. package/src/lib/scene-soundscape.ts +0 -151
  229. package/src/lib/scene-test-harness.ts +0 -200
  230. package/src/lib/scene-timeline.ts +0 -398
  231. package/src/lib/use-animation-visibility.ts +0 -45
  232. package/src/lib/use-modal-focus.ts +0 -270
  233. package/src/lib/use-reduced-motion.ts +0 -37
  234. package/src/motion/easing-presets.ts +0 -262
  235. package/src/motion/index.tsx +0 -894
  236. package/src/motion/physics.ts +0 -259
  237. package/src/motion/timeline-math.ts +0 -358
  238. package/src/motion.tsx +0 -639
  239. package/src/pixelfx-boundary.ts +0 -188
  240. package/src/pixelfx-registry.ts +0 -1190
  241. package/src/pixelfx-types.d.ts +0 -73
  242. package/src/pixelfx.tsx +0 -1022
  243. package/src/provider.tsx +0 -63
  244. package/src/skin-catalog.ts +0 -306
  245. package/src/skin-tokens.ts +0 -425
  246. package/src/ssr/init-script.ts +0 -281
  247. package/src/ssr/resolve-skin.ts +0 -217
  248. package/src/ssr/theme-mismatch-dev.ts +0 -181
  249. package/src/templates/battle-arena.tsx +0 -688
  250. package/src/templates/index.tsx +0 -314
  251. package/src/templates.tsx +0 -225
  252. package/src/themes/dna-presets.ts +0 -119
  253. package/src/themes/index.ts +0 -56
  254. package/src/themes/provider.tsx +0 -183
  255. package/src/themes/types.ts +0 -111
  256. package/src/themes.ts +0 -9
  257. package/src/token-exporter.ts +0 -12
  258. package/src/token-exporters.ts +0 -343
  259. package/src/token-seeds.ts +0 -335
  260. package/src/token-snapshot.ts +0 -179
  261. package/src/utils.ts +0 -58
@@ -1,848 +0,0 @@
1
- "use client";
2
-
3
- import {
4
- forwardRef,
5
- useCallback,
6
- useEffect,
7
- useMemo,
8
- useRef,
9
- useState,
10
- type ComponentPropsWithoutRef,
11
- type CSSProperties,
12
- } from "react";
13
- import { cn } from "../lib/cn.js";
14
- import { clampUnit, type MotionEasingName } from "../motion/physics.js";
15
- import {
16
- applyEasingPresetToKeyframes,
17
- buildEasingPreviewPathD,
18
- filterEasingPresets,
19
- getEasingPresetById,
20
- MOTION_EASING_CATEGORIES,
21
- MOTION_EASING_PRESETS,
22
- type MotionEasingApplyScope,
23
- type MotionEasingCategory,
24
- type MotionEasingPreset,
25
- } from "../motion/easing-presets.js";
26
- import {
27
- buildMotionTimelineSvgGeometry,
28
- DEFAULT_MOTION_TIMELINE_KEYFRAMES,
29
- evaluateMotionTimeline,
30
- normalizeKeyframes,
31
- type MotionTimelineKeyframe,
32
- type NormalizedMotionKeyframe,
33
- } from "../motion/timeline-math.js";
34
- import { useMotion } from "../motion/index.js";
35
- import { useComponentPixelFx } from "../pixelfx.js";
36
- import type { PixelFxProp } from "../pixelfx-registry.js";
37
-
38
- export type MotionTimelineSpeed = 0.5 | 1 | 1.5;
39
-
40
- const SPEED_OPTIONS: readonly MotionTimelineSpeed[] = [0.5, 1, 1.5];
41
-
42
- export type MotionTimelineProps = Omit<
43
- ComponentPropsWithoutRef<"div">,
44
- "onChange"
45
- > & {
46
- title?: string;
47
- subtitle?: string;
48
- keyframes?: readonly MotionTimelineKeyframe[];
49
- durationMs?: number;
50
- defaultEasing?: MotionEasingName;
51
- playing?: boolean;
52
- defaultPlaying?: boolean;
53
- onPlayingChange?: (playing: boolean) => void;
54
- progress?: number;
55
- defaultProgress?: number;
56
- onProgressChange?: (progress: number) => void;
57
- loop?: boolean;
58
- defaultLoop?: boolean;
59
- speed?: MotionTimelineSpeed;
60
- showPreview?: boolean;
61
- allowEasingEdit?: boolean;
62
- showPresetLibrary?: boolean;
63
- defaultApplyScope?: MotionEasingApplyScope;
64
- onKeyframeSelect?: (
65
- keyframe: NormalizedMotionKeyframe,
66
- index: number,
67
- ) => void;
68
- onSegmentEasingChange?: (
69
- segmentIndex: number,
70
- easing: MotionEasingName,
71
- ) => void;
72
- onApplyEasingPreset?: (
73
- easing: MotionEasingName,
74
- scope: MotionEasingApplyScope,
75
- segmentIndex: number,
76
- ) => void;
77
- fx?: PixelFxProp;
78
- };
79
-
80
- export const MotionTimeline = forwardRef<HTMLDivElement, MotionTimelineProps>(
81
- function MotionTimeline(
82
- {
83
- title = "Motion Timeline",
84
- subtitle,
85
- keyframes = DEFAULT_MOTION_TIMELINE_KEYFRAMES,
86
- durationMs = 1600,
87
- defaultEasing = "ease-out",
88
- playing: controlledPlaying,
89
- defaultPlaying = false,
90
- onPlayingChange,
91
- progress: controlledProgress,
92
- defaultProgress = 0,
93
- onProgressChange,
94
- loop: controlledLoop,
95
- defaultLoop = true,
96
- speed: controlledSpeed,
97
- showPreview = true,
98
- allowEasingEdit = false,
99
- showPresetLibrary,
100
- defaultApplyScope = "all",
101
- onKeyframeSelect,
102
- onSegmentEasingChange,
103
- onApplyEasingPreset,
104
- className,
105
- fx = "auto",
106
- ...props
107
- },
108
- ref,
109
- ) {
110
- const { reducedMotion, triggerSfx } = useMotion();
111
- const [uncontrolledPlaying, setUncontrolledPlaying] = useState(
112
- () => defaultPlaying && !reducedMotion,
113
- );
114
- const [uncontrolledProgress, setUncontrolledProgress] = useState(() =>
115
- clampUnit(defaultProgress),
116
- );
117
- const [uncontrolledLoop, setUncontrolledLoop] = useState(defaultLoop);
118
- const [uncontrolledSpeed, setUncontrolledSpeed] =
119
- useState<MotionTimelineSpeed>(1);
120
- const [presetCategory, setPresetCategory] = useState<
121
- "all" | MotionEasingCategory
122
- >("all");
123
- const [applyScope, setApplyScope] =
124
- useState<MotionEasingApplyScope>(defaultApplyScope);
125
- const [localKeyframes, setLocalKeyframes] = useState<
126
- readonly MotionTimelineKeyframe[] | null
127
- >(null);
128
-
129
- useEffect(() => {
130
- setLocalKeyframes(null);
131
- }, [keyframes]);
132
-
133
- const isPlaying = controlledPlaying ?? uncontrolledPlaying;
134
- const currentProgress = clampUnit(
135
- controlledProgress ?? uncontrolledProgress,
136
- );
137
- const isLooping = controlledLoop ?? uncontrolledLoop;
138
- const playbackSpeed = controlledSpeed ?? uncontrolledSpeed;
139
- const safeDuration = Math.max(200, durationMs);
140
- const presetLibraryVisible = showPresetLibrary ?? allowEasingEdit;
141
-
142
- const progressRef = useRef(currentProgress);
143
- progressRef.current = currentProgress;
144
-
145
- const setPlaying = useCallback(
146
- (next: boolean) => {
147
- if (controlledPlaying === undefined) {
148
- setUncontrolledPlaying(next);
149
- }
150
- onPlayingChange?.(next);
151
- },
152
- [controlledPlaying, onPlayingChange],
153
- );
154
-
155
- const setProgress = useCallback(
156
- (next: number) => {
157
- const clamped = clampUnit(next);
158
- progressRef.current = clamped;
159
- if (controlledProgress === undefined) {
160
- setUncontrolledProgress(clamped);
161
- }
162
- onProgressChange?.(clamped);
163
- },
164
- [controlledProgress, onProgressChange],
165
- );
166
-
167
- const effectiveKeyframes = localKeyframes ?? keyframes;
168
-
169
- const normalizedKeyframes = useMemo(
170
- () => normalizeKeyframes(effectiveKeyframes, defaultEasing),
171
- [effectiveKeyframes, defaultEasing],
172
- );
173
-
174
- useEffect(() => {
175
- if (!isPlaying || typeof window === "undefined") {
176
- return;
177
- }
178
-
179
- if (reducedMotion || typeof window.requestAnimationFrame !== "function") {
180
- const stepMs = 250;
181
- const intervalId = window.setInterval(() => {
182
- const delta = (stepMs * playbackSpeed) / safeDuration;
183
- let next = progressRef.current + delta;
184
- if (next >= 1) {
185
- if (isLooping) {
186
- next = next % 1;
187
- } else {
188
- setProgress(1);
189
- setPlaying(false);
190
- return;
191
- }
192
- }
193
- setProgress(next);
194
- }, stepMs);
195
- return () => window.clearInterval(intervalId);
196
- }
197
-
198
- let rafId = 0;
199
- let lastTime = performance.now();
200
-
201
- const tick = (now: number) => {
202
- const dt = Math.min(80, Math.max(0, now - lastTime));
203
- lastTime = now;
204
- const delta = (dt * playbackSpeed) / safeDuration;
205
- let next = progressRef.current + delta;
206
-
207
- if (next >= 1) {
208
- if (isLooping) {
209
- next = next % 1;
210
- } else {
211
- setProgress(1);
212
- setPlaying(false);
213
- return;
214
- }
215
- }
216
-
217
- setProgress(next);
218
- rafId = window.requestAnimationFrame(tick);
219
- };
220
-
221
- rafId = window.requestAnimationFrame(tick);
222
- return () => window.cancelAnimationFrame(rafId);
223
- }, [
224
- isPlaying,
225
- isLooping,
226
- playbackSpeed,
227
- safeDuration,
228
- reducedMotion,
229
- setPlaying,
230
- setProgress,
231
- ]);
232
-
233
- const evaluation = useMemo(
234
- () =>
235
- evaluateMotionTimeline(
236
- normalizedKeyframes,
237
- currentProgress,
238
- defaultEasing,
239
- ),
240
- [normalizedKeyframes, currentProgress, defaultEasing],
241
- );
242
-
243
- const geometry = useMemo(
244
- () =>
245
- buildMotionTimelineSvgGeometry(normalizedKeyframes, currentProgress, {
246
- width: 800,
247
- height: 196,
248
- padX: 40,
249
- padY: 28,
250
- samplesPerSegment: 32,
251
- defaultEasing,
252
- }),
253
- [normalizedKeyframes, currentProgress, defaultEasing],
254
- );
255
-
256
- const pfx = useComponentPixelFx({
257
- kind: "motion-timeline",
258
- fx,
259
- placement: "background",
260
- });
261
-
262
- const elapsedMs = Math.round(currentProgress * safeDuration);
263
- const clampedSegIndex = Math.min(
264
- Math.max(0, evaluation.segmentIndex),
265
- Math.max(0, geometry.segmentPaths.length - 1),
266
- );
267
- const activeSegment = geometry.segmentPaths[clampedSegIndex];
268
- const inspectedSegment = activeSegment;
269
-
270
- const visiblePresets = useMemo(
271
- () => filterEasingPresets(presetCategory),
272
- [presetCategory],
273
- );
274
-
275
- const activePresetMeta = useMemo(
276
- () => getEasingPresetById(inspectedSegment?.easing ?? evaluation.easing),
277
- [inspectedSegment?.easing, evaluation.easing],
278
- );
279
-
280
- const allSegmentsShareEasing = useMemo(() => {
281
- if (geometry.segmentPaths.length === 0) return null;
282
- const first = geometry.segmentPaths[0].easing;
283
- return geometry.segmentPaths.every((seg) => seg.easing === first)
284
- ? first
285
- : null;
286
- }, [geometry.segmentPaths]);
287
-
288
- const handleTogglePlay = () => {
289
- if (!isPlaying && currentProgress >= 0.999) {
290
- setProgress(0);
291
- }
292
- const next = !isPlaying;
293
- setPlaying(next);
294
- triggerSfx(next ? "drawer-whoosh" : "click-soft");
295
- };
296
-
297
- const handleReset = () => {
298
- setPlaying(false);
299
- setProgress(0);
300
- triggerSfx("click-soft");
301
- };
302
-
303
- const handleJumpToKeyframe = (
304
- kf: NormalizedMotionKeyframe,
305
- idx: number,
306
- ) => {
307
- setPlaying(false);
308
- setProgress(kf.at);
309
- onKeyframeSelect?.(kf, idx);
310
- triggerSfx("toggle-pop");
311
- };
312
-
313
- const handleSelectEasingPreset = (preset: MotionEasingPreset) => {
314
- if (onApplyEasingPreset) {
315
- onApplyEasingPreset(preset.id, applyScope, clampedSegIndex);
316
- } else if (onSegmentEasingChange) {
317
- if (applyScope === "all") {
318
- for (let i = 0; i < geometry.segmentPaths.length; i += 1) {
319
- onSegmentEasingChange(i, preset.id);
320
- }
321
- } else {
322
- onSegmentEasingChange(clampedSegIndex, preset.id);
323
- }
324
- } else {
325
- setLocalKeyframes((prev) =>
326
- applyEasingPresetToKeyframes(
327
- prev ?? normalizedKeyframes,
328
- preset.id,
329
- applyScope,
330
- clampedSegIndex,
331
- ),
332
- );
333
- }
334
- triggerSfx("toggle-pop");
335
- };
336
-
337
- const previewPuckLeft = `calc(14px + (${Math.max(-0.08, Math.min(1.08, evaluation.value)).toFixed(4)} * (100% - 56px)))`;
338
- const previewScale = (
339
- 0.86 +
340
- Math.max(0, Math.min(1.2, evaluation.value)) * 0.24
341
- ).toFixed(3);
342
-
343
- return (
344
- <div
345
- ref={ref}
346
- data-slot="motion-timeline"
347
- data-playing={isPlaying ? "true" : "false"}
348
- data-reduced-motion={reducedMotion ? "true" : "false"}
349
- className={cn("mw-ui-motion-timeline", className)}
350
- {...pfx.dataAttributes}
351
- {...pfx.handlers}
352
- {...props}
353
- >
354
- {pfx.layer}
355
- <div className="mw-ui-motion-timeline-header">
356
- <div className="mw-ui-motion-timeline-heading">
357
- <h4 className="mw-ui-motion-timeline-title">{title}</h4>
358
- {subtitle ? (
359
- <p className="mw-ui-motion-timeline-subtitle">{subtitle}</p>
360
- ) : null}
361
- </div>
362
-
363
- <div
364
- className="mw-ui-motion-timeline-controls"
365
- role="group"
366
- aria-label="Timeline playback controls"
367
- >
368
- <button
369
- type="button"
370
- className="mw-ui-motion-timeline-play"
371
- aria-pressed={isPlaying}
372
- aria-label={
373
- isPlaying
374
- ? "Pause animation timeline"
375
- : "Play animation timeline"
376
- }
377
- onClick={handleTogglePlay}
378
- >
379
- {isPlaying ? (
380
- <svg
381
- aria-hidden="true"
382
- viewBox="0 0 16 16"
383
- width="14"
384
- height="14"
385
- fill="currentColor"
386
- >
387
- <rect x="3" y="2.5" width="3.5" height="11" rx="0.75" />
388
- <rect x="9.5" y="2.5" width="3.5" height="11" rx="0.75" />
389
- </svg>
390
- ) : (
391
- <svg
392
- aria-hidden="true"
393
- viewBox="0 0 16 16"
394
- width="14"
395
- height="14"
396
- fill="currentColor"
397
- >
398
- <path d="M4 2.5L13.5 8L4 13.5V2.5Z" />
399
- </svg>
400
- )}
401
- <span>{isPlaying ? "Pause" : "Play"}</span>
402
- </button>
403
-
404
- <button
405
- type="button"
406
- className="mw-ui-motion-timeline-btn"
407
- aria-label="Reset timeline to start"
408
- onClick={handleReset}
409
- >
410
- Reset
411
- </button>
412
-
413
- {controlledLoop === undefined ? (
414
- <button
415
- type="button"
416
- className="mw-ui-motion-timeline-btn"
417
- data-active={isLooping ? "true" : "false"}
418
- aria-pressed={isLooping}
419
- onClick={() => {
420
- setUncontrolledLoop((prev) => !prev);
421
- triggerSfx("click-soft");
422
- }}
423
- >
424
- {isLooping ? "Loop: On" : "Loop: Off"}
425
- </button>
426
- ) : null}
427
-
428
- {controlledSpeed === undefined ? (
429
- <div
430
- className="mw-ui-motion-timeline-speeds"
431
- role="group"
432
- aria-label="Playback speed"
433
- >
434
- {SPEED_OPTIONS.map((rate) => (
435
- <button
436
- key={rate}
437
- type="button"
438
- className="mw-ui-motion-timeline-btn"
439
- data-active={playbackSpeed === rate ? "true" : "false"}
440
- aria-pressed={playbackSpeed === rate}
441
- onClick={() => setUncontrolledSpeed(rate)}
442
- >
443
- {rate}x
444
- </button>
445
- ))}
446
- </div>
447
- ) : null}
448
- </div>
449
- </div>
450
-
451
- <div className="mw-ui-motion-timeline-stage">
452
- <svg
453
- viewBox={`0 0 ${geometry.width} ${geometry.height}`}
454
- className="mw-ui-motion-timeline-svg"
455
- role="img"
456
- aria-label={`${title} easing curve visualization at ${Math.round(currentProgress * 100)}% progress`}
457
- >
458
- {[0, 0.25, 0.5, 0.75, 1].map((tick) => {
459
- const x =
460
- geometry.plotLeft +
461
- tick * (geometry.plotRight - geometry.plotLeft);
462
- return (
463
- <g key={tick}>
464
- <line
465
- x1={x}
466
- y1={geometry.plotTop}
467
- x2={x}
468
- y2={geometry.plotBottom}
469
- className="mw-ui-motion-timeline-grid-v"
470
- />
471
- <text
472
- x={x}
473
- y={geometry.height - 6}
474
- textAnchor="middle"
475
- className="mw-ui-motion-timeline-axis-label"
476
- >
477
- {Math.round(tick * 100)}%
478
- </text>
479
- </g>
480
- );
481
- })}
482
-
483
- <line
484
- x1={geometry.plotLeft}
485
- y1={geometry.oneY}
486
- x2={geometry.plotRight}
487
- y2={geometry.oneY}
488
- className="mw-ui-motion-timeline-grid-h"
489
- />
490
- <line
491
- x1={geometry.plotLeft}
492
- y1={(geometry.oneY + geometry.zeroY) / 2}
493
- x2={geometry.plotRight}
494
- y2={(geometry.oneY + geometry.zeroY) / 2}
495
- className="mw-ui-motion-timeline-grid-h"
496
- />
497
- <line
498
- x1={geometry.plotLeft}
499
- y1={geometry.zeroY}
500
- x2={geometry.plotRight}
501
- y2={geometry.zeroY}
502
- className="mw-ui-motion-timeline-grid-h"
503
- />
504
-
505
- <text
506
- x={geometry.plotLeft - 10}
507
- y={geometry.oneY + 3}
508
- textAnchor="end"
509
- className="mw-ui-motion-timeline-axis-label"
510
- >
511
- 1.0
512
- </text>
513
- <text
514
- x={geometry.plotLeft - 10}
515
- y={geometry.zeroY + 3}
516
- textAnchor="end"
517
- className="mw-ui-motion-timeline-axis-label"
518
- >
519
- 0.0
520
- </text>
521
-
522
- {geometry.areaPathD ? (
523
- <path
524
- d={geometry.areaPathD}
525
- className="mw-ui-motion-timeline-area"
526
- />
527
- ) : null}
528
-
529
- {geometry.segmentPaths.map((seg) => (
530
- <path
531
- key={`${seg.fromId}-${seg.toId}`}
532
- d={seg.d}
533
- data-segment-index={seg.index}
534
- data-active={
535
- seg.index === evaluation.segmentIndex ? "true" : "false"
536
- }
537
- className="mw-ui-motion-timeline-segment-path"
538
- />
539
- ))}
540
-
541
- {geometry.elapsedPathD ? (
542
- <path
543
- d={geometry.elapsedPathD}
544
- className="mw-ui-motion-timeline-elapsed-path"
545
- />
546
- ) : null}
547
-
548
- <line
549
- x1={geometry.playhead.x}
550
- y1={geometry.plotTop}
551
- x2={geometry.playhead.x}
552
- y2={geometry.plotBottom}
553
- className="mw-ui-motion-timeline-playhead-line"
554
- />
555
-
556
- {geometry.keyframeNodes.map((node, idx) => {
557
- const isReached = currentProgress + 0.001 >= node.at;
558
- const isActive = evaluation.activeKeyframe.id === node.id;
559
- const targetKf = normalizedKeyframes[idx];
560
- return (
561
- <g
562
- key={node.id}
563
- transform={`translate(${node.x.toFixed(2)}, ${node.y.toFixed(2)})`}
564
- className="mw-ui-motion-timeline-node"
565
- data-reached={isReached ? "true" : "false"}
566
- data-active={isActive ? "true" : "false"}
567
- onClick={() => {
568
- if (targetKf) handleJumpToKeyframe(targetKf, idx);
569
- }}
570
- >
571
- <polygon
572
- points="0,-6.5 6.5,0 0,6.5 -6.5,0"
573
- className="mw-ui-motion-timeline-diamond"
574
- />
575
- <text
576
- y="-11"
577
- textAnchor="middle"
578
- className="mw-ui-motion-timeline-node-label"
579
- >
580
- {node.label}
581
- </text>
582
- </g>
583
- );
584
- })}
585
-
586
- <circle
587
- cx={geometry.playhead.x}
588
- cy={geometry.playhead.y}
589
- r="6"
590
- className="mw-ui-motion-timeline-playhead-dot"
591
- />
592
- </svg>
593
-
594
- <div className="mw-ui-motion-timeline-scrubber-row">
595
- <input
596
- type="range"
597
- min={0}
598
- max={1000}
599
- step={1}
600
- value={Math.round(currentProgress * 1000)}
601
- onChange={(event) => {
602
- setPlaying(false);
603
- setProgress(Number(event.target.value) / 1000);
604
- }}
605
- aria-label="Scrub animation timeline progress"
606
- className="mw-ui-motion-timeline-scrubber"
607
- />
608
- </div>
609
-
610
- <div
611
- className="mw-ui-motion-timeline-readout"
612
- role="status"
613
- aria-live="off"
614
- >
615
- <span>
616
- time: <strong>{elapsedMs}ms</strong> / {safeDuration}ms
617
- </span>
618
- <span>
619
- progress: <strong>{Math.round(currentProgress * 100)}%</strong>
620
- </span>
621
- <span>
622
- value: <strong>{evaluation.value.toFixed(2)}</strong>
623
- </span>
624
- <span>
625
- easing: <strong>{evaluation.easing}</strong>
626
- </span>
627
- </div>
628
- </div>
629
-
630
- {showPreview ? (
631
- <div
632
- className="mw-ui-motion-timeline-preview"
633
- aria-label="Live keyframe motion preview"
634
- >
635
- <span className="mw-ui-motion-timeline-preview-label">
636
- Live Keyframe Output
637
- </span>
638
- <div className="mw-ui-motion-timeline-preview-track">
639
- {normalizedKeyframes.map((kf) => (
640
- <span
641
- key={`tick-${kf.id}`}
642
- aria-hidden="true"
643
- className="mw-ui-motion-timeline-preview-tick"
644
- style={{
645
- left: `calc(14px + (${kf.value.toFixed(4)} * (100% - 56px)) + 14px)`,
646
- }}
647
- />
648
- ))}
649
- <div
650
- className="mw-ui-motion-timeline-preview-puck"
651
- style={
652
- {
653
- left: previewPuckLeft,
654
- transform: `translateY(-50%) scale(${previewScale})`,
655
- } as CSSProperties
656
- }
657
- />
658
- </div>
659
- </div>
660
- ) : null}
661
-
662
- <div
663
- className="mw-ui-motion-timeline-keyframes"
664
- role="group"
665
- aria-label="Animation keyframes"
666
- >
667
- {normalizedKeyframes.map((kf, idx) => {
668
- const isActive = evaluation.activeKeyframe.id === kf.id;
669
- const isLast = idx === normalizedKeyframes.length - 1;
670
- const kfMs = Math.round(kf.at * safeDuration);
671
- return (
672
- <button
673
- key={kf.id}
674
- type="button"
675
- className="mw-ui-motion-timeline-kf-card"
676
- data-active={isActive ? "true" : "false"}
677
- aria-pressed={isActive}
678
- onClick={() => handleJumpToKeyframe(kf, idx)}
679
- >
680
- <span className="mw-ui-motion-timeline-kf-head">
681
- <span className="mw-ui-motion-timeline-kf-index">
682
- {String(idx + 1).padStart(2, "0")}
683
- </span>
684
- <span className="mw-ui-motion-timeline-kf-label">
685
- {kf.label}
686
- </span>
687
- <span className="mw-ui-motion-timeline-kf-time">
688
- {kfMs}ms
689
- </span>
690
- </span>
691
- <span className="mw-ui-motion-timeline-kf-meta">
692
- <span>val {kf.value.toFixed(2)}</span>
693
- {!isLast ? (
694
- <span className="mw-ui-motion-timeline-kf-easing">
695
- → {kf.easing}
696
- </span>
697
- ) : (
698
- <span className="mw-ui-motion-timeline-kf-easing">end</span>
699
- )}
700
- </span>
701
- </button>
702
- );
703
- })}
704
- </div>
705
-
706
- {presetLibraryVisible ? (
707
- <div
708
- className="mw-ui-motion-timeline-presets"
709
- data-slot="motion-timeline-preset-library"
710
- >
711
- <div className="mw-ui-motion-timeline-presets-head">
712
- <div className="mw-ui-motion-timeline-presets-meta">
713
- <span className="mw-ui-motion-timeline-presets-title">
714
- Easing Curve Preset Library ({MOTION_EASING_PRESETS.length})
715
- </span>
716
- <span className="mw-ui-motion-timeline-presets-hint">
717
- {applyScope === "all"
718
- ? "Select a curve to update all timeline segments instantly"
719
- : inspectedSegment
720
- ? `Editing Segment ${inspectedSegment.index + 1} (${normalizedKeyframes[inspectedSegment.index]?.label} → ${normalizedKeyframes[inspectedSegment.index + 1]?.label})`
721
- : "Select a curve"}
722
- {activePresetMeta
723
- ? ` · ${activePresetMeta.cssEquivalent}`
724
- : ""}
725
- </span>
726
- </div>
727
-
728
- <div
729
- className="mw-ui-motion-timeline-scope"
730
- role="group"
731
- aria-label="Easing preset apply scope"
732
- >
733
- <button
734
- type="button"
735
- className="mw-ui-motion-timeline-btn"
736
- data-active={applyScope === "all" ? "true" : "false"}
737
- aria-pressed={applyScope === "all"}
738
- onClick={() => setApplyScope("all")}
739
- >
740
- All Segments
741
- </button>
742
- <button
743
- type="button"
744
- className="mw-ui-motion-timeline-btn"
745
- data-active={applyScope === "segment" ? "true" : "false"}
746
- aria-pressed={applyScope === "segment"}
747
- onClick={() => setApplyScope("segment")}
748
- >
749
- Active Segment
750
- </button>
751
- </div>
752
- </div>
753
-
754
- <div
755
- className="mw-ui-motion-timeline-categories"
756
- role="group"
757
- aria-label="Easing preset categories"
758
- >
759
- {MOTION_EASING_CATEGORIES.map((cat) => (
760
- <button
761
- key={cat.id}
762
- type="button"
763
- className="mw-ui-motion-timeline-btn"
764
- data-active={presetCategory === cat.id ? "true" : "false"}
765
- aria-pressed={presetCategory === cat.id}
766
- onClick={() => setPresetCategory(cat.id)}
767
- >
768
- {cat.label}
769
- </button>
770
- ))}
771
- </div>
772
-
773
- <div
774
- className="mw-ui-motion-timeline-preset-grid"
775
- role="group"
776
- aria-label="Easing curve presets"
777
- >
778
- {visiblePresets.map((preset) => {
779
- const isSelected =
780
- applyScope === "all"
781
- ? allSegmentsShareEasing === preset.id
782
- : inspectedSegment?.easing === preset.id;
783
- const previewPath = buildEasingPreviewPathD(preset.id);
784
- return (
785
- <button
786
- key={preset.id}
787
- type="button"
788
- className="mw-ui-motion-timeline-preset-card"
789
- data-active={isSelected ? "true" : "false"}
790
- data-preset-id={preset.id}
791
- aria-pressed={isSelected}
792
- title={preset.description}
793
- onClick={() => handleSelectEasingPreset(preset)}
794
- >
795
- <svg
796
- viewBox="0 0 76 34"
797
- aria-hidden="true"
798
- className="mw-ui-motion-timeline-preset-svg"
799
- >
800
- <line
801
- x1="6"
802
- y1="10"
803
- x2="70"
804
- y2="10"
805
- className="mw-ui-motion-timeline-preset-guide"
806
- />
807
- <line
808
- x1="6"
809
- y1="24"
810
- x2="70"
811
- y2="24"
812
- className="mw-ui-motion-timeline-preset-guide"
813
- />
814
- <path
815
- d={previewPath}
816
- className="mw-ui-motion-timeline-preset-path"
817
- />
818
- </svg>
819
- <span className="mw-ui-motion-timeline-preset-name">
820
- {preset.label}
821
- </span>
822
- <span className="mw-ui-motion-timeline-preset-id">
823
- {preset.id}
824
- </span>
825
- </button>
826
- );
827
- })}
828
- </div>
829
- </div>
830
- ) : null}
831
- </div>
832
- );
833
- },
834
- );
835
- MotionTimeline.displayName = "MotionTimeline";
836
-
837
- export type {
838
- MotionEasingApplyScope,
839
- MotionEasingCategory,
840
- MotionEasingPreset,
841
- MotionTimelineKeyframe,
842
- NormalizedMotionKeyframe,
843
- };
844
- export {
845
- DEFAULT_MOTION_TIMELINE_KEYFRAMES,
846
- MOTION_EASING_CATEGORIES,
847
- MOTION_EASING_PRESETS,
848
- };