@moonwitness/ui 0.0.0-stage → 7.1.1
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/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +147 -2
- package/TOKENS.md +62 -0
- package/dist/cartoon/anime-avatar.d.ts +8 -0
- package/dist/cartoon/anime-avatar.js +135 -0
- package/dist/cartoon/anime-stage.d.ts +67 -0
- package/dist/cartoon/anime-stage.js +106 -0
- package/dist/cartoon/index.d.ts +113 -0
- package/dist/cartoon/index.js +119 -0
- package/dist/cartoon.d.ts +59 -0
- package/dist/cartoon.js +238 -0
- package/dist/characters.d.ts +71 -0
- package/dist/characters.js +543 -0
- package/dist/components/accordion.d.ts +11 -0
- package/dist/components/accordion.js +26 -0
- package/dist/components/alert.d.ts +14 -0
- package/dist/components/alert.js +36 -0
- package/dist/components/appearance-menu.d.ts +22 -0
- package/dist/components/appearance-menu.js +64 -0
- package/dist/components/artwork-frame.d.ts +10 -0
- package/dist/components/artwork-frame.js +12 -0
- package/dist/components/audio.d.ts +19 -0
- package/dist/components/audio.js +49 -0
- package/dist/components/avatar.d.ts +9 -0
- package/dist/components/avatar.js +28 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +21 -0
- package/dist/components/brand-mark.d.ts +13 -0
- package/dist/components/brand-mark.js +32 -0
- package/dist/components/breadcrumbs.d.ts +15 -0
- package/dist/components/breadcrumbs.js +25 -0
- package/dist/components/button.d.ts +17 -0
- package/dist/components/button.js +119 -0
- package/dist/components/card.d.ts +20 -0
- package/dist/components/card.js +57 -0
- package/dist/components/character-badge.d.ts +9 -0
- package/dist/components/character-badge.js +19 -0
- package/dist/components/character-preview.d.ts +10 -0
- package/dist/components/character-preview.js +47 -0
- package/dist/components/character-stage.d.ts +54 -0
- package/dist/components/character-stage.js +38 -0
- package/dist/components/chart.d.ts +36 -0
- package/dist/components/chart.js +154 -0
- package/dist/components/checkbox.d.ts +7 -0
- package/dist/components/checkbox.js +15 -0
- package/dist/components/comic-panel.d.ts +17 -0
- package/dist/components/comic-panel.js +118 -0
- package/dist/components/comic-theater.d.ts +19 -0
- package/dist/components/comic-theater.js +54 -0
- package/dist/components/command.d.ts +32 -0
- package/dist/components/command.js +56 -0
- package/dist/components/confirm-dialog.d.ts +19 -0
- package/dist/components/confirm-dialog.js +32 -0
- package/dist/components/copy-button.d.ts +14 -0
- package/dist/components/copy-button.js +17 -0
- package/dist/components/date-picker.d.ts +21 -0
- package/dist/components/date-picker.js +45 -0
- package/dist/components/dialog.d.ts +20 -0
- package/dist/components/dialog.js +51 -0
- package/dist/components/dna-icon.d.ts +24 -0
- package/dist/components/dna-icon.js +14 -0
- package/dist/components/dropdown-menu.d.ts +13 -0
- package/dist/components/dropdown-menu.js +26 -0
- package/dist/components/effects.d.ts +143 -0
- package/dist/components/effects.js +248 -0
- package/dist/components/empty-state.d.ts +15 -0
- package/dist/components/empty-state.js +18 -0
- package/dist/components/epistemic-branch-panel.d.ts +10 -0
- package/dist/components/epistemic-branch-panel.js +45 -0
- package/dist/components/error-state.d.ts +20 -0
- package/dist/components/error-state.js +44 -0
- package/dist/components/field.d.ts +13 -0
- package/dist/components/field.js +35 -0
- package/dist/components/filter-facet-bar.d.ts +15 -0
- package/dist/components/filter-facet-bar.js +38 -0
- package/dist/components/inbox-popover.d.ts +28 -0
- package/dist/components/inbox-popover.js +14 -0
- package/dist/components/input.d.ts +7 -0
- package/dist/components/input.js +8 -0
- package/dist/components/kanban-board.d.ts +21 -0
- package/dist/components/kanban-board.js +38 -0
- package/dist/components/label.d.ts +6 -0
- package/dist/components/label.js +7 -0
- package/dist/components/layered-scene.d.ts +74 -0
- package/dist/components/layered-scene.js +316 -0
- package/dist/components/log-console.d.ts +29 -0
- package/dist/components/log-console.js +82 -0
- package/dist/components/metric-tile.d.ts +15 -0
- package/dist/components/metric-tile.js +30 -0
- package/dist/components/mode-picker.d.ts +9 -0
- package/dist/components/mode-picker.js +72 -0
- package/dist/components/motion-timeline.d.ts +56 -0
- package/dist/components/motion-timeline.js +215 -0
- package/dist/components/number-input.d.ts +29 -0
- package/dist/components/number-input.js +45 -0
- package/dist/components/page-header.d.ts +16 -0
- package/dist/components/page-header.js +48 -0
- package/dist/components/pagination.d.ts +10 -0
- package/dist/components/pagination.js +17 -0
- package/dist/components/panel.d.ts +18 -0
- package/dist/components/panel.js +28 -0
- package/dist/components/paper-note.d.ts +6 -0
- package/dist/components/paper-note.js +35 -0
- package/dist/components/popover.d.ts +11 -0
- package/dist/components/popover.js +29 -0
- package/dist/components/progress.d.ts +17 -0
- package/dist/components/progress.js +26 -0
- package/dist/components/quest-card.d.ts +82 -0
- package/dist/components/quest-card.js +89 -0
- package/dist/components/radio-group.d.ts +8 -0
- package/dist/components/radio-group.js +23 -0
- package/dist/components/riot-sticker.d.ts +28 -0
- package/dist/components/riot-sticker.js +61 -0
- package/dist/components/scene-particles.d.ts +31 -0
- package/dist/components/scene-particles.js +90 -0
- package/dist/components/scene-transitions.d.ts +16 -0
- package/dist/components/scene-transitions.js +51 -0
- package/dist/components/section-ribbon.d.ts +17 -0
- package/dist/components/section-ribbon.js +21 -0
- package/dist/components/select-field.d.ts +7 -0
- package/dist/components/select-field.js +8 -0
- package/dist/components/select.d.ts +14 -0
- package/dist/components/select.js +22 -0
- package/dist/components/separator.d.ts +9 -0
- package/dist/components/separator.js +12 -0
- package/dist/components/sheet.d.ts +14 -0
- package/dist/components/sheet.js +39 -0
- package/dist/components/skeleton.d.ts +7 -0
- package/dist/components/skeleton.js +11 -0
- package/dist/components/sketch-annotation.d.ts +22 -0
- package/dist/components/sketch-annotation.js +21 -0
- package/dist/components/smart-button-box.d.ts +24 -0
- package/dist/components/smart-button-box.js +26 -0
- package/dist/components/speech-bubble.d.ts +33 -0
- package/dist/components/speech-bubble.js +18 -0
- package/dist/components/spinner.d.ts +11 -0
- package/dist/components/spinner.js +10 -0
- package/dist/components/sprite-player.d.ts +50 -0
- package/dist/components/sprite-player.js +230 -0
- package/dist/components/status-bar.d.ts +14 -0
- package/dist/components/status-bar.js +16 -0
- package/dist/components/status-pill.d.ts +11 -0
- package/dist/components/status-pill.js +20 -0
- package/dist/components/switch.d.ts +15 -0
- package/dist/components/switch.js +16 -0
- package/dist/components/table.d.ts +15 -0
- package/dist/components/table.js +66 -0
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +24 -0
- package/dist/components/tag-input.d.ts +17 -0
- package/dist/components/tag-input.js +79 -0
- package/dist/components/textarea.d.ts +7 -0
- package/dist/components/textarea.js +8 -0
- package/dist/components/toast.d.ts +7 -0
- package/dist/components/toast.js +8 -0
- package/dist/components/toolbar.d.ts +8 -0
- package/dist/components/toolbar.js +11 -0
- package/dist/components/tooltip.d.ts +9 -0
- package/dist/components/tooltip.js +18 -0
- package/dist/components/update-banner.d.ts +14 -0
- package/dist/components/update-banner.js +39 -0
- package/dist/components/xv-primitives.d.ts +63 -0
- package/dist/components/xv-primitives.js +53 -0
- package/dist/dna.d.ts +26 -0
- package/dist/dna.js +79 -0
- package/dist/game/boss-hud.d.ts +73 -0
- package/dist/game/boss-hud.js +78 -0
- package/dist/game/index.d.ts +194 -0
- package/dist/game/index.js +222 -0
- package/dist/game/tactical.d.ts +41 -0
- package/dist/game/tactical.js +46 -0
- package/dist/game.d.ts +95 -0
- package/dist/game.js +263 -0
- package/dist/icons/activity.d.ts +7 -0
- package/dist/icons/activity.js +8 -0
- package/dist/icons/add.d.ts +7 -0
- package/dist/icons/add.js +8 -0
- package/dist/icons/addon.d.ts +7 -0
- package/dist/icons/addon.js +8 -0
- package/dist/icons/anime-anger.d.ts +7 -0
- package/dist/icons/anime-anger.js +8 -0
- package/dist/icons/anime-shock.d.ts +7 -0
- package/dist/icons/anime-shock.js +8 -0
- package/dist/icons/anime-sparkle.d.ts +7 -0
- package/dist/icons/anime-sparkle.js +8 -0
- package/dist/icons/anime-sweatdrop.d.ts +7 -0
- package/dist/icons/anime-sweatdrop.js +8 -0
- package/dist/icons/archive.d.ts +7 -0
- package/dist/icons/archive.js +8 -0
- package/dist/icons/arrow-left.d.ts +7 -0
- package/dist/icons/arrow-left.js +8 -0
- package/dist/icons/arrow-right.d.ts +7 -0
- package/dist/icons/arrow-right.js +8 -0
- package/dist/icons/attachment.d.ts +7 -0
- package/dist/icons/attachment.js +8 -0
- package/dist/icons/bank.d.ts +7 -0
- package/dist/icons/bank.js +8 -0
- package/dist/icons/bolt.d.ts +7 -0
- package/dist/icons/bolt.js +8 -0
- package/dist/icons/book-open.d.ts +7 -0
- package/dist/icons/book-open.js +8 -0
- package/dist/icons/bookmark.d.ts +7 -0
- package/dist/icons/bookmark.js +8 -0
- package/dist/icons/boss-skull.d.ts +7 -0
- package/dist/icons/boss-skull.js +8 -0
- package/dist/icons/calendar-clock.d.ts +7 -0
- package/dist/icons/calendar-clock.js +8 -0
- package/dist/icons/calendar.d.ts +7 -0
- package/dist/icons/calendar.js +8 -0
- package/dist/icons/check-circle.d.ts +7 -0
- package/dist/icons/check-circle.js +8 -0
- package/dist/icons/check-square.d.ts +7 -0
- package/dist/icons/check-square.js +8 -0
- package/dist/icons/check.d.ts +7 -0
- package/dist/icons/check.js +8 -0
- package/dist/icons/chevron-right.d.ts +7 -0
- package/dist/icons/chevron-right.js +8 -0
- package/dist/icons/chevrons-left.d.ts +7 -0
- package/dist/icons/chevrons-left.js +8 -0
- package/dist/icons/chevrons-right.d.ts +7 -0
- package/dist/icons/chevrons-right.js +8 -0
- package/dist/icons/clapperboard.d.ts +7 -0
- package/dist/icons/clapperboard.js +8 -0
- package/dist/icons/clock.d.ts +7 -0
- package/dist/icons/clock.js +8 -0
- package/dist/icons/close.d.ts +7 -0
- package/dist/icons/close.js +8 -0
- package/dist/icons/code.d.ts +7 -0
- package/dist/icons/code.js +8 -0
- package/dist/icons/columns.d.ts +7 -0
- package/dist/icons/columns.js +8 -0
- package/dist/icons/combo-flame.d.ts +7 -0
- package/dist/icons/combo-flame.js +8 -0
- package/dist/icons/company.d.ts +7 -0
- package/dist/icons/company.js +8 -0
- package/dist/icons/credit-card.d.ts +7 -0
- package/dist/icons/credit-card.js +8 -0
- package/dist/icons/critical-star.d.ts +7 -0
- package/dist/icons/critical-star.js +8 -0
- package/dist/icons/currency.d.ts +7 -0
- package/dist/icons/currency.js +8 -0
- package/dist/icons/delete.d.ts +7 -0
- package/dist/icons/delete.js +8 -0
- package/dist/icons/document.d.ts +7 -0
- package/dist/icons/document.js +8 -0
- package/dist/icons/download.d.ts +7 -0
- package/dist/icons/download.js +8 -0
- package/dist/icons/dpad.d.ts +7 -0
- package/dist/icons/dpad.js +8 -0
- package/dist/icons/edit.d.ts +7 -0
- package/dist/icons/edit.js +8 -0
- package/dist/icons/element-fire.d.ts +7 -0
- package/dist/icons/element-fire.js +8 -0
- package/dist/icons/element-ice.d.ts +7 -0
- package/dist/icons/element-ice.js +8 -0
- package/dist/icons/element-solar.d.ts +7 -0
- package/dist/icons/element-solar.js +8 -0
- package/dist/icons/element-void.d.ts +7 -0
- package/dist/icons/element-void.js +8 -0
- package/dist/icons/element-volt.d.ts +7 -0
- package/dist/icons/element-volt.js +8 -0
- package/dist/icons/element-wind.d.ts +7 -0
- package/dist/icons/element-wind.js +8 -0
- package/dist/icons/error.d.ts +7 -0
- package/dist/icons/error.js +8 -0
- package/dist/icons/external-link.d.ts +7 -0
- package/dist/icons/external-link.js +8 -0
- package/dist/icons/field.d.ts +7 -0
- package/dist/icons/field.js +8 -0
- package/dist/icons/file-spreadsheet.d.ts +7 -0
- package/dist/icons/file-spreadsheet.js +8 -0
- package/dist/icons/filter.d.ts +7 -0
- package/dist/icons/filter.js +8 -0
- package/dist/icons/gacha-ticket.d.ts +7 -0
- package/dist/icons/gacha-ticket.js +8 -0
- package/dist/icons/gamepad.d.ts +7 -0
- package/dist/icons/gamepad.js +8 -0
- package/dist/icons/globe.d.ts +7 -0
- package/dist/icons/globe.js +8 -0
- package/dist/icons/grid.d.ts +7 -0
- package/dist/icons/grid.js +8 -0
- package/dist/icons/hash.d.ts +7 -0
- package/dist/icons/hash.js +8 -0
- package/dist/icons/heart-hp.d.ts +7 -0
- package/dist/icons/heart-hp.js +8 -0
- package/dist/icons/history.d.ts +7 -0
- package/dist/icons/history.js +8 -0
- package/dist/icons/home.d.ts +7 -0
- package/dist/icons/home.js +8 -0
- package/dist/icons/image.d.ts +7 -0
- package/dist/icons/image.js +8 -0
- package/dist/icons/impact-slash.d.ts +7 -0
- package/dist/icons/impact-slash.js +8 -0
- package/dist/icons/inbox.d.ts +7 -0
- package/dist/icons/inbox.js +8 -0
- package/dist/icons/index.d.ts +120 -0
- package/dist/icons/index.js +120 -0
- package/dist/icons/info.d.ts +7 -0
- package/dist/icons/info.js +8 -0
- package/dist/icons/jobs.d.ts +7 -0
- package/dist/icons/jobs.js +8 -0
- package/dist/icons/katana.d.ts +7 -0
- package/dist/icons/katana.js +8 -0
- package/dist/icons/key.d.ts +7 -0
- package/dist/icons/key.js +8 -0
- package/dist/icons/keyboard.d.ts +7 -0
- package/dist/icons/keyboard.js +8 -0
- package/dist/icons/keyframe-diamond.d.ts +7 -0
- package/dist/icons/keyframe-diamond.js +8 -0
- package/dist/icons/knowledge.d.ts +7 -0
- package/dist/icons/knowledge.js +8 -0
- package/dist/icons/language.d.ts +7 -0
- package/dist/icons/language.js +8 -0
- package/dist/icons/lock.d.ts +7 -0
- package/dist/icons/lock.js +8 -0
- package/dist/icons/logout.d.ts +7 -0
- package/dist/icons/logout.js +8 -0
- package/dist/icons/loot-chest.d.ts +7 -0
- package/dist/icons/loot-chest.js +8 -0
- package/dist/icons/mail.d.ts +7 -0
- package/dist/icons/mail.js +8 -0
- package/dist/icons/mana-crystal.d.ts +7 -0
- package/dist/icons/mana-crystal.js +8 -0
- package/dist/icons/map-pin.d.ts +7 -0
- package/dist/icons/map-pin.js +8 -0
- package/dist/icons/mecha-helm.d.ts +7 -0
- package/dist/icons/mecha-helm.js +8 -0
- package/dist/icons/menu.d.ts +7 -0
- package/dist/icons/menu.js +8 -0
- package/dist/icons/message.d.ts +7 -0
- package/dist/icons/message.js +8 -0
- package/dist/icons/model.d.ts +7 -0
- package/dist/icons/model.js +8 -0
- package/dist/icons/moon.d.ts +7 -0
- package/dist/icons/moon.js +8 -0
- package/dist/icons/notification.d.ts +7 -0
- package/dist/icons/notification.js +8 -0
- package/dist/icons/partner.d.ts +7 -0
- package/dist/icons/partner.js +8 -0
- package/dist/icons/pause.d.ts +7 -0
- package/dist/icons/pause.js +8 -0
- package/dist/icons/phone.d.ts +7 -0
- package/dist/icons/phone.js +8 -0
- package/dist/icons/play.d.ts +7 -0
- package/dist/icons/play.js +8 -0
- package/dist/icons/potion-flask.d.ts +7 -0
- package/dist/icons/potion-flask.js +8 -0
- package/dist/icons/quest-scroll.d.ts +7 -0
- package/dist/icons/quest-scroll.js +8 -0
- package/dist/icons/radar-ping.d.ts +7 -0
- package/dist/icons/radar-ping.js +8 -0
- package/dist/icons/refresh.d.ts +7 -0
- package/dist/icons/refresh.js +8 -0
- package/dist/icons/relation.d.ts +7 -0
- package/dist/icons/relation.js +8 -0
- package/dist/icons/save.d.ts +7 -0
- package/dist/icons/save.js +8 -0
- package/dist/icons/search.d.ts +7 -0
- package/dist/icons/search.js +8 -0
- package/dist/icons/security.d.ts +7 -0
- package/dist/icons/security.js +8 -0
- package/dist/icons/send.d.ts +7 -0
- package/dist/icons/send.js +8 -0
- package/dist/icons/settings.d.ts +7 -0
- package/dist/icons/settings.js +8 -0
- package/dist/icons/shield-crest.d.ts +7 -0
- package/dist/icons/shield-crest.js +8 -0
- package/dist/icons/shuriken.d.ts +7 -0
- package/dist/icons/shuriken.js +8 -0
- package/dist/icons/signal-off.d.ts +7 -0
- package/dist/icons/signal-off.js +8 -0
- package/dist/icons/signal.d.ts +7 -0
- package/dist/icons/signal.js +8 -0
- package/dist/icons/skill-node.d.ts +7 -0
- package/dist/icons/skill-node.js +8 -0
- package/dist/icons/smartphone.d.ts +7 -0
- package/dist/icons/smartphone.js +8 -0
- package/dist/icons/sort-ascending.d.ts +7 -0
- package/dist/icons/sort-ascending.js +8 -0
- package/dist/icons/sort-descending.d.ts +7 -0
- package/dist/icons/sort-descending.js +8 -0
- package/dist/icons/sort.d.ts +7 -0
- package/dist/icons/sort.js +8 -0
- package/dist/icons/sparkle.d.ts +7 -0
- package/dist/icons/sparkle.js +8 -0
- package/dist/icons/speech-burst.d.ts +7 -0
- package/dist/icons/speech-burst.js +8 -0
- package/dist/icons/story.d.ts +7 -0
- package/dist/icons/story.js +8 -0
- package/dist/icons/sun.d.ts +7 -0
- package/dist/icons/sun.js +8 -0
- package/dist/icons/tag.d.ts +7 -0
- package/dist/icons/tag.js +8 -0
- package/dist/icons/team.d.ts +7 -0
- package/dist/icons/team.js +8 -0
- package/dist/icons/trophy-crown.d.ts +7 -0
- package/dist/icons/trophy-crown.js +8 -0
- package/dist/icons/upload.d.ts +7 -0
- package/dist/icons/upload.js +8 -0
- package/dist/icons/user.d.ts +7 -0
- package/dist/icons/user.js +8 -0
- package/dist/icons/users.d.ts +7 -0
- package/dist/icons/users.js +8 -0
- package/dist/icons/visibility-off.d.ts +7 -0
- package/dist/icons/visibility-off.js +8 -0
- package/dist/icons/visibility.d.ts +7 -0
- package/dist/icons/visibility.js +8 -0
- package/dist/icons/volume-off.d.ts +7 -0
- package/dist/icons/volume-off.js +8 -0
- package/dist/icons/volume.d.ts +7 -0
- package/dist/icons/volume.js +8 -0
- package/dist/icons/warning.d.ts +7 -0
- package/dist/icons/warning.js +8 -0
- package/dist/icons/workflow.d.ts +7 -0
- package/dist/icons/workflow.js +8 -0
- package/dist/icons.d.ts +124 -0
- package/dist/icons.js +361 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +83 -0
- package/dist/lib/asset-registry.d.ts +104 -0
- package/dist/lib/asset-registry.js +328 -0
- package/dist/lib/audio-runtime.d.ts +23 -0
- package/dist/lib/audio-runtime.js +254 -0
- package/dist/lib/character-adapter.d.ts +63 -0
- package/dist/lib/character-adapter.js +232 -0
- package/dist/lib/character-registry.d.ts +159 -0
- package/dist/lib/character-registry.js +1950 -0
- package/dist/lib/cn.d.ts +2 -0
- package/dist/lib/cn.js +4 -0
- package/dist/lib/compose-refs.d.ts +7 -0
- package/dist/lib/compose-refs.js +14 -0
- package/dist/lib/sanitize-url.d.ts +6 -0
- package/dist/lib/sanitize-url.js +44 -0
- package/dist/lib/scene-camera.d.ts +70 -0
- package/dist/lib/scene-camera.js +317 -0
- package/dist/lib/scene-playback.d.ts +93 -0
- package/dist/lib/scene-playback.js +447 -0
- package/dist/lib/scene-soundscape.d.ts +35 -0
- package/dist/lib/scene-soundscape.js +117 -0
- package/dist/lib/scene-test-harness.d.ts +17 -0
- package/dist/lib/scene-test-harness.js +140 -0
- package/dist/lib/scene-timeline.d.ts +59 -0
- package/dist/lib/scene-timeline.js +280 -0
- package/dist/lib/use-animation-visibility.d.ts +7 -0
- package/dist/lib/use-animation-visibility.js +31 -0
- package/dist/lib/use-modal-focus.d.ts +6 -0
- package/dist/lib/use-modal-focus.js +211 -0
- package/dist/lib/use-reduced-motion.d.ts +5 -0
- package/dist/lib/use-reduced-motion.js +31 -0
- package/dist/motion/easing-presets.d.ts +21 -0
- package/dist/motion/easing-presets.js +207 -0
- package/dist/motion/index.d.ts +153 -0
- package/dist/motion/index.js +311 -0
- package/dist/motion/physics.d.ts +30 -0
- package/dist/motion/physics.js +178 -0
- package/dist/motion/timeline-math.d.ts +78 -0
- package/dist/motion/timeline-math.js +216 -0
- package/dist/motion.d.ts +76 -0
- package/dist/motion.js +316 -0
- package/dist/pixelfx-registry.d.ts +127 -0
- package/dist/pixelfx-registry.js +861 -0
- package/dist/pixelfx.d.ts +161 -0
- package/dist/pixelfx.js +510 -0
- package/dist/provider.d.ts +27 -0
- package/dist/provider.js +15 -0
- package/dist/skin-catalog.d.ts +20 -0
- package/dist/skin-catalog.js +215 -0
- package/dist/skin-tokens.d.ts +3 -0
- package/dist/skin-tokens.js +390 -0
- package/dist/tailwind-preset.css +109 -0
- package/dist/templates/battle-arena.d.ts +2 -0
- package/dist/templates/battle-arena.js +351 -0
- package/dist/templates/index.d.ts +3 -0
- package/dist/templates/index.js +77 -0
- package/dist/templates.d.ts +4 -0
- package/dist/templates.js +78 -0
- package/dist/themes/dna-presets.d.ts +18 -0
- package/dist/themes/dna-presets.js +84 -0
- package/dist/themes/index.d.ts +11 -0
- package/dist/themes/index.js +10 -0
- package/dist/themes/provider.d.ts +26 -0
- package/dist/themes/provider.js +96 -0
- package/dist/themes/types.d.ts +42 -0
- package/dist/themes/types.js +47 -0
- package/dist/themes.d.ts +2 -0
- package/dist/themes.js +2 -0
- package/dist/token-exporter.d.ts +5 -0
- package/dist/token-exporter.js +4 -0
- package/dist/token-exporters.d.ts +28 -0
- package/dist/token-exporters.js +257 -0
- package/dist/token-seeds.d.ts +38 -0
- package/dist/token-seeds.js +272 -0
- package/dist/token-snapshot.d.ts +21 -0
- package/dist/token-snapshot.js +131 -0
- package/dist/tokens.bundle.json +1669 -0
- package/dist/tokens.generated.css +599 -0
- package/dist/tokens.w3c.json +1931 -0
- package/dist/utils.d.ts +12 -0
- package/dist/utils.js +49 -0
- package/package.json +543 -4
- package/scripts/generate-icons.mjs +110 -0
- package/scripts/generate-token-artifacts.mjs +90 -0
- package/scripts/icon-svg-to-jsx.mjs +249 -0
- package/scripts/verification-diagnostics.mjs +40 -0
- package/scripts/verify-package.mjs +412 -0
- package/src/cartoon/anime-avatar.tsx +628 -0
- package/src/cartoon/anime-stage.tsx +458 -0
- package/src/cartoon/index.tsx +542 -0
- package/src/cartoon.tsx +645 -0
- package/src/characters.ts +625 -0
- package/src/components/accordion.tsx +77 -0
- package/src/components/alert.tsx +139 -0
- package/src/components/appearance-menu.tsx +181 -0
- package/src/components/artwork-frame.tsx +49 -0
- package/src/components/audio.tsx +97 -0
- package/src/components/avatar.tsx +75 -0
- package/src/components/badge.tsx +94 -0
- package/src/components/brand-mark.tsx +73 -0
- package/src/components/breadcrumbs.tsx +98 -0
- package/src/components/button.tsx +340 -0
- package/src/components/card.tsx +171 -0
- package/src/components/character-badge.tsx +58 -0
- package/src/components/character-preview.tsx +104 -0
- package/src/components/character-stage.tsx +225 -0
- package/src/components/chart.tsx +481 -0
- package/src/components/checkbox.tsx +64 -0
- package/src/components/comic-panel.tsx +301 -0
- package/src/components/comic-theater.tsx +170 -0
- package/src/components/command.tsx +189 -0
- package/src/components/confirm-dialog.tsx +129 -0
- package/src/components/copy-button.tsx +62 -0
- package/src/components/date-picker.tsx +126 -0
- package/src/components/dialog.tsx +164 -0
- package/src/components/dna-icon.tsx +77 -0
- package/src/components/dropdown-menu.tsx +87 -0
- package/src/components/effects.tsx +1021 -0
- package/src/components/empty-state.tsx +93 -0
- package/src/components/epistemic-branch-panel.tsx +101 -0
- package/src/components/error-state.tsx +137 -0
- package/src/components/field.tsx +96 -0
- package/src/components/filter-facet-bar.tsx +91 -0
- package/src/components/inbox-popover.tsx +146 -0
- package/src/components/input.tsx +25 -0
- package/src/components/kanban-board.tsx +190 -0
- package/src/components/label.tsx +19 -0
- package/src/components/layered-scene.tsx +555 -0
- package/src/components/log-console.tsx +261 -0
- package/src/components/metric-tile.tsx +99 -0
- package/src/components/mode-picker.tsx +149 -0
- package/src/components/motion-timeline.tsx +848 -0
- package/src/components/number-input.tsx +104 -0
- package/src/components/page-header.tsx +123 -0
- package/src/components/pagination.tsx +83 -0
- package/src/components/panel.tsx +121 -0
- package/src/components/paper-note.tsx +77 -0
- package/src/components/popover.tsx +72 -0
- package/src/components/progress.tsx +127 -0
- package/src/components/quest-card.tsx +319 -0
- package/src/components/radio-group.tsx +50 -0
- package/src/components/riot-sticker.tsx +151 -0
- package/src/components/scene-particles.tsx +196 -0
- package/src/components/scene-transitions.tsx +130 -0
- package/src/components/section-ribbon.tsx +94 -0
- package/src/components/select-field.tsx +27 -0
- package/src/components/select.tsx +81 -0
- package/src/components/separator.tsx +58 -0
- package/src/components/sheet.tsx +96 -0
- package/src/components/skeleton.tsx +35 -0
- package/src/components/sketch-annotation.tsx +87 -0
- package/src/components/smart-button-box.tsx +114 -0
- package/src/components/speech-bubble.tsx +116 -0
- package/src/components/spinner.tsx +69 -0
- package/src/components/sprite-player.tsx +412 -0
- package/src/components/status-bar.tsx +63 -0
- package/src/components/status-pill.tsx +68 -0
- package/src/components/switch.tsx +76 -0
- package/src/components/table.tsx +163 -0
- package/src/components/tabs.tsx +101 -0
- package/src/components/tag-input.tsx +170 -0
- package/src/components/textarea.tsx +25 -0
- package/src/components/toast.tsx +14 -0
- package/src/components/toolbar.tsx +39 -0
- package/src/components/tooltip.tsx +49 -0
- package/src/components/update-banner.tsx +220 -0
- package/src/components/xv-primitives.tsx +256 -0
- package/src/dna.tsx +137 -0
- package/src/game/boss-hud.tsx +384 -0
- package/src/game/index.tsx +886 -0
- package/src/game/tactical.tsx +245 -0
- package/src/game.tsx +770 -0
- package/src/icons/activity.tsx +38 -0
- package/src/icons/add.tsx +38 -0
- package/src/icons/addon.tsx +37 -0
- package/src/icons/anime-anger.tsx +37 -0
- package/src/icons/anime-shock.tsx +37 -0
- package/src/icons/anime-sparkle.tsx +38 -0
- package/src/icons/anime-sweatdrop.tsx +38 -0
- package/src/icons/archive.tsx +37 -0
- package/src/icons/arrow-left.tsx +37 -0
- package/src/icons/arrow-right.tsx +37 -0
- package/src/icons/attachment.tsx +38 -0
- package/src/icons/bank.tsx +37 -0
- package/src/icons/bolt.tsx +37 -0
- package/src/icons/book-open.tsx +37 -0
- package/src/icons/bookmark.tsx +37 -0
- package/src/icons/boss-skull.tsx +40 -0
- package/src/icons/calendar-clock.tsx +40 -0
- package/src/icons/calendar.tsx +38 -0
- package/src/icons/check-circle.tsx +38 -0
- package/src/icons/check-square.tsx +38 -0
- package/src/icons/check.tsx +37 -0
- package/src/icons/chevron-right.tsx +37 -0
- package/src/icons/chevrons-left.tsx +37 -0
- package/src/icons/chevrons-right.tsx +37 -0
- package/src/icons/clapperboard.tsx +38 -0
- package/src/icons/clock.tsx +38 -0
- package/src/icons/close.tsx +37 -0
- package/src/icons/code.tsx +37 -0
- package/src/icons/columns.tsx +38 -0
- package/src/icons/combo-flame.tsx +38 -0
- package/src/icons/company.tsx +38 -0
- package/src/icons/credit-card.tsx +38 -0
- package/src/icons/critical-star.tsx +37 -0
- package/src/icons/currency.tsx +38 -0
- package/src/icons/delete.tsx +37 -0
- package/src/icons/document.tsx +38 -0
- package/src/icons/download.tsx +37 -0
- package/src/icons/dpad.tsx +38 -0
- package/src/icons/edit.tsx +38 -0
- package/src/icons/element-fire.tsx +37 -0
- package/src/icons/element-ice.tsx +38 -0
- package/src/icons/element-solar.tsx +38 -0
- package/src/icons/element-void.tsx +38 -0
- package/src/icons/element-volt.tsx +38 -0
- package/src/icons/element-wind.tsx +37 -0
- package/src/icons/error.tsx +38 -0
- package/src/icons/external-link.tsx +38 -0
- package/src/icons/field.tsx +38 -0
- package/src/icons/file-spreadsheet.tsx +38 -0
- package/src/icons/filter.tsx +37 -0
- package/src/icons/gacha-ticket.tsx +38 -0
- package/src/icons/gamepad.tsx +40 -0
- package/src/icons/globe.tsx +38 -0
- package/src/icons/grid.tsx +40 -0
- package/src/icons/hash.tsx +37 -0
- package/src/icons/heart-hp.tsx +38 -0
- package/src/icons/history.tsx +37 -0
- package/src/icons/home.tsx +37 -0
- package/src/icons/image.tsx +39 -0
- package/src/icons/impact-slash.tsx +38 -0
- package/src/icons/inbox.tsx +38 -0
- package/src/icons/index.ts +120 -0
- package/src/icons/info.tsx +38 -0
- package/src/icons/jobs.tsx +38 -0
- package/src/icons/katana.tsx +38 -0
- package/src/icons/key.tsx +38 -0
- package/src/icons/keyboard.tsx +38 -0
- package/src/icons/keyframe-diamond.tsx +38 -0
- package/src/icons/knowledge.tsx +38 -0
- package/src/icons/language.tsx +39 -0
- package/src/icons/lock.tsx +38 -0
- package/src/icons/logout.tsx +37 -0
- package/src/icons/loot-chest.tsx +39 -0
- package/src/icons/mail.tsx +38 -0
- package/src/icons/mana-crystal.tsx +38 -0
- package/src/icons/map-pin.tsx +38 -0
- package/src/icons/mecha-helm.tsx +38 -0
- package/src/icons/menu.tsx +37 -0
- package/src/icons/message.tsx +38 -0
- package/src/icons/model.tsx +38 -0
- package/src/icons/moon.tsx +37 -0
- package/src/icons/notification.tsx +38 -0
- package/src/icons/partner.tsx +41 -0
- package/src/icons/pause.tsx +37 -0
- package/src/icons/phone.tsx +37 -0
- package/src/icons/play.tsx +37 -0
- package/src/icons/potion-flask.tsx +40 -0
- package/src/icons/quest-scroll.tsx +39 -0
- package/src/icons/radar-ping.tsx +40 -0
- package/src/icons/refresh.tsx +38 -0
- package/src/icons/relation.tsx +40 -0
- package/src/icons/save.tsx +38 -0
- package/src/icons/search.tsx +38 -0
- package/src/icons/security.tsx +38 -0
- package/src/icons/send.tsx +38 -0
- package/src/icons/settings.tsx +39 -0
- package/src/icons/shield-crest.tsx +38 -0
- package/src/icons/shuriken.tsx +38 -0
- package/src/icons/signal-off.tsx +37 -0
- package/src/icons/signal.tsx +37 -0
- package/src/icons/skill-node.tsx +40 -0
- package/src/icons/smartphone.tsx +38 -0
- package/src/icons/sort-ascending.tsx +37 -0
- package/src/icons/sort-descending.tsx +37 -0
- package/src/icons/sort.tsx +37 -0
- package/src/icons/sparkle.tsx +38 -0
- package/src/icons/speech-burst.tsx +37 -0
- package/src/icons/story.tsx +37 -0
- package/src/icons/sun.tsx +38 -0
- package/src/icons/tag.tsx +38 -0
- package/src/icons/team.tsx +40 -0
- package/src/icons/trophy-crown.tsx +39 -0
- package/src/icons/upload.tsx +37 -0
- package/src/icons/user.tsx +38 -0
- package/src/icons/users.tsx +39 -0
- package/src/icons/visibility-off.tsx +38 -0
- package/src/icons/visibility.tsx +38 -0
- package/src/icons/volume-off.tsx +37 -0
- package/src/icons/volume.tsx +37 -0
- package/src/icons/warning.tsx +38 -0
- package/src/icons/workflow.tsx +40 -0
- package/src/icons.tsx +965 -0
- package/src/index.ts +89 -0
- package/src/lib/asset-registry.ts +534 -0
- package/src/lib/audio-runtime.ts +314 -0
- package/src/lib/character-adapter.ts +370 -0
- package/src/lib/character-registry.ts +2368 -0
- package/src/lib/cn.ts +6 -0
- package/src/lib/compose-refs.ts +16 -0
- package/src/lib/sanitize-url.ts +51 -0
- package/src/lib/scene-camera.ts +483 -0
- package/src/lib/scene-playback.ts +622 -0
- package/src/lib/scene-soundscape.ts +151 -0
- package/src/lib/scene-test-harness.ts +200 -0
- package/src/lib/scene-timeline.ts +398 -0
- package/src/lib/use-animation-visibility.ts +45 -0
- package/src/lib/use-modal-focus.ts +270 -0
- package/src/lib/use-reduced-motion.ts +37 -0
- package/src/motion/easing-presets.ts +262 -0
- package/src/motion/index.tsx +894 -0
- package/src/motion/physics.ts +259 -0
- package/src/motion/timeline-math.ts +358 -0
- package/src/motion.tsx +639 -0
- package/src/pixelfx-registry.ts +1190 -0
- package/src/pixelfx-types.d.ts +73 -0
- package/src/pixelfx.tsx +994 -0
- package/src/provider.tsx +63 -0
- package/src/skin-catalog.ts +270 -0
- package/src/skin-tokens.ts +425 -0
- package/src/styles/components.css +8007 -0
- package/src/styles/tokens.css +952 -0
- package/src/styles/visual-universe.css +149 -0
- package/src/styles/xv-primitives.css +192 -0
- package/src/templates/battle-arena.tsx +688 -0
- package/src/templates/index.tsx +314 -0
- package/src/templates.tsx +225 -0
- package/src/themes/dna-presets.ts +119 -0
- package/src/themes/index.ts +43 -0
- package/src/themes/provider.tsx +162 -0
- package/src/themes/types.ts +111 -0
- package/src/themes.ts +9 -0
- package/src/token-exporter.ts +12 -0
- package/src/token-exporters.ts +343 -0
- package/src/token-seeds.ts +335 -0
- package/src/token-snapshot.ts +179 -0
- package/src/utils.ts +58 -0
- package/styles.css +3 -0
|
@@ -0,0 +1,886 @@
|
|
|
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
|
+
type ReactNode,
|
|
13
|
+
} from "react";
|
|
14
|
+
import { cn } from "../lib/cn.js";
|
|
15
|
+
import { getCharacterById } from "../lib/character-registry.js";
|
|
16
|
+
import { AnimeCharacterSvg } from "../cartoon/anime-avatar.js";
|
|
17
|
+
import { clampUnit, useMotion } from "../motion/index.js";
|
|
18
|
+
export {
|
|
19
|
+
AchievementBadge,
|
|
20
|
+
QuestCard,
|
|
21
|
+
RewardPanel,
|
|
22
|
+
type AchievementBadgeProps,
|
|
23
|
+
type QuestCardProps,
|
|
24
|
+
type QuestStatus,
|
|
25
|
+
type RewardBadgeEntry,
|
|
26
|
+
type RewardPanelProps,
|
|
27
|
+
} from "../components/quest-card.js";
|
|
28
|
+
export {
|
|
29
|
+
AchievementToast,
|
|
30
|
+
BossHealthBar,
|
|
31
|
+
LootRevealCard,
|
|
32
|
+
TurnOrderStrip,
|
|
33
|
+
type AchievementToastProps,
|
|
34
|
+
type BossHealthBarProps,
|
|
35
|
+
type LootRarity,
|
|
36
|
+
type LootRevealCardProps,
|
|
37
|
+
type TurnOrderEntry,
|
|
38
|
+
type TurnOrderStripProps,
|
|
39
|
+
} from "./boss-hud.js";
|
|
40
|
+
export {
|
|
41
|
+
SkillTreeGraph,
|
|
42
|
+
TacticalRadar,
|
|
43
|
+
type RadarBlip,
|
|
44
|
+
type SkillNodeState,
|
|
45
|
+
type SkillTreeGraphProps,
|
|
46
|
+
type SkillTreeNode,
|
|
47
|
+
type TacticalRadarProps,
|
|
48
|
+
} from "./tactical.js";
|
|
49
|
+
|
|
50
|
+
export type StatGaugeTone = "hp" | "mp" | "xp" | "shield" | "stamina";
|
|
51
|
+
export type StatGaugeVariant = "straight" | "arcade-skew" | "segmented";
|
|
52
|
+
|
|
53
|
+
export type StatGaugeProps = ComponentPropsWithoutRef<"div"> & {
|
|
54
|
+
label: string;
|
|
55
|
+
value: number;
|
|
56
|
+
max: number;
|
|
57
|
+
tone?: StatGaugeTone;
|
|
58
|
+
variant?: StatGaugeVariant;
|
|
59
|
+
segments?: number;
|
|
60
|
+
lowThreshold?: number;
|
|
61
|
+
showNumbers?: boolean;
|
|
62
|
+
trailDelayMs?: number;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const StatGauge = forwardRef<HTMLDivElement, StatGaugeProps>(
|
|
66
|
+
function StatGauge(
|
|
67
|
+
{
|
|
68
|
+
label,
|
|
69
|
+
value,
|
|
70
|
+
max,
|
|
71
|
+
tone = "hp",
|
|
72
|
+
variant = "straight",
|
|
73
|
+
segments = 10,
|
|
74
|
+
lowThreshold = 0.25,
|
|
75
|
+
showNumbers = true,
|
|
76
|
+
trailDelayMs = 260,
|
|
77
|
+
className,
|
|
78
|
+
...props
|
|
79
|
+
},
|
|
80
|
+
ref,
|
|
81
|
+
) {
|
|
82
|
+
const { reducedMotion } = useMotion();
|
|
83
|
+
const safeMax = Math.max(1, max);
|
|
84
|
+
const clamped = Math.min(safeMax, Math.max(0, value));
|
|
85
|
+
const ratio = clampUnit(clamped / safeMax);
|
|
86
|
+
const [trailRatio, setTrailRatio] = useState(ratio);
|
|
87
|
+
const [hitFlash, setHitFlash] = useState(false);
|
|
88
|
+
const prevRef = useRef(clamped);
|
|
89
|
+
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const prev = prevRef.current;
|
|
92
|
+
prevRef.current = clamped;
|
|
93
|
+
if (clamped < prev && !reducedMotion) {
|
|
94
|
+
setHitFlash(true);
|
|
95
|
+
const flashTimer = window.setTimeout(() => setHitFlash(false), 180);
|
|
96
|
+
const trailTimer = window.setTimeout(
|
|
97
|
+
() => setTrailRatio(ratio),
|
|
98
|
+
trailDelayMs,
|
|
99
|
+
);
|
|
100
|
+
return () => {
|
|
101
|
+
window.clearTimeout(flashTimer);
|
|
102
|
+
window.clearTimeout(trailTimer);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
setTrailRatio(ratio);
|
|
106
|
+
return undefined;
|
|
107
|
+
}, [clamped, ratio, reducedMotion, trailDelayMs]);
|
|
108
|
+
|
|
109
|
+
const isCritical = ratio > 0 && ratio <= lowThreshold;
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<div
|
|
113
|
+
ref={ref}
|
|
114
|
+
data-slot="stat-gauge"
|
|
115
|
+
data-tone={tone}
|
|
116
|
+
data-variant={variant}
|
|
117
|
+
data-critical={isCritical ? "true" : "false"}
|
|
118
|
+
data-hit={hitFlash ? "true" : "false"}
|
|
119
|
+
data-reduced-motion={reducedMotion ? "true" : "false"}
|
|
120
|
+
className={cn("mw-ui-game-gauge", className)}
|
|
121
|
+
{...props}
|
|
122
|
+
>
|
|
123
|
+
<div className="mw-ui-game-gauge-header">
|
|
124
|
+
<span className="mw-ui-game-gauge-label">{label}</span>
|
|
125
|
+
{showNumbers ? (
|
|
126
|
+
<span className="mw-ui-game-gauge-numbers">
|
|
127
|
+
{Math.round(clamped)} / {Math.round(safeMax)}
|
|
128
|
+
</span>
|
|
129
|
+
) : null}
|
|
130
|
+
</div>
|
|
131
|
+
<div
|
|
132
|
+
role="progressbar"
|
|
133
|
+
aria-label={label}
|
|
134
|
+
aria-valuemin={0}
|
|
135
|
+
aria-valuemax={safeMax}
|
|
136
|
+
aria-valuenow={Math.round(clamped)}
|
|
137
|
+
className="mw-ui-game-gauge-track"
|
|
138
|
+
>
|
|
139
|
+
<div
|
|
140
|
+
className="mw-ui-game-gauge-trail"
|
|
141
|
+
style={{ width: `${Math.round(trailRatio * 1000) / 10}%` }}
|
|
142
|
+
/>
|
|
143
|
+
<div
|
|
144
|
+
className="mw-ui-game-gauge-fill"
|
|
145
|
+
style={{ width: `${Math.round(ratio * 1000) / 10}%` }}
|
|
146
|
+
/>
|
|
147
|
+
{variant === "segmented" ? (
|
|
148
|
+
<div className="mw-ui-game-gauge-segments" aria-hidden="true">
|
|
149
|
+
{Array.from({ length: Math.max(2, segments) }).map((_, idx) => (
|
|
150
|
+
<span key={idx} className="mw-ui-game-gauge-segment" />
|
|
151
|
+
))}
|
|
152
|
+
</div>
|
|
153
|
+
) : null}
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
},
|
|
158
|
+
);
|
|
159
|
+
StatGauge.displayName = "StatGauge";
|
|
160
|
+
|
|
161
|
+
export interface DialogueChoice {
|
|
162
|
+
readonly id: string;
|
|
163
|
+
readonly label: string;
|
|
164
|
+
readonly hint?: string;
|
|
165
|
+
readonly disabled?: boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export type DialogueBoxProps = ComponentPropsWithoutRef<"section"> & {
|
|
169
|
+
characterId?: string;
|
|
170
|
+
speaker?: string;
|
|
171
|
+
roleTitle?: string;
|
|
172
|
+
text: string;
|
|
173
|
+
portrait?: ReactNode;
|
|
174
|
+
charsPerSec?: number;
|
|
175
|
+
instant?: boolean;
|
|
176
|
+
choices?: readonly DialogueChoice[];
|
|
177
|
+
onChoiceSelect?: (choice: DialogueChoice) => void;
|
|
178
|
+
onAdvance?: () => void;
|
|
179
|
+
onTypingProgress?: (visibleChars: number, isTyping: boolean) => void;
|
|
180
|
+
advanceLabel?: string;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const DialogueBox = forwardRef<HTMLElement, DialogueBoxProps>(
|
|
184
|
+
function DialogueBox(
|
|
185
|
+
{
|
|
186
|
+
characterId,
|
|
187
|
+
speaker,
|
|
188
|
+
roleTitle,
|
|
189
|
+
text,
|
|
190
|
+
portrait,
|
|
191
|
+
charsPerSec = 42,
|
|
192
|
+
instant = false,
|
|
193
|
+
choices,
|
|
194
|
+
onChoiceSelect,
|
|
195
|
+
onAdvance,
|
|
196
|
+
onTypingProgress,
|
|
197
|
+
advanceLabel = "Continue",
|
|
198
|
+
className,
|
|
199
|
+
...props
|
|
200
|
+
},
|
|
201
|
+
ref,
|
|
202
|
+
) {
|
|
203
|
+
const { reducedMotion, triggerSfx } = useMotion();
|
|
204
|
+
const profile = getCharacterById(characterId);
|
|
205
|
+
const resolvedSpeaker = speaker ?? profile?.name ?? "Speaker";
|
|
206
|
+
const resolvedRole = roleTitle ?? profile?.title;
|
|
207
|
+
const skipTyping = instant || reducedMotion || charsPerSec <= 0;
|
|
208
|
+
const [visibleChars, setVisibleChars] = useState(
|
|
209
|
+
skipTyping ? text.length : 0,
|
|
210
|
+
);
|
|
211
|
+
const [autoMode, setAutoMode] = useState(false);
|
|
212
|
+
|
|
213
|
+
const isTyping = visibleChars < text.length;
|
|
214
|
+
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
setVisibleChars(skipTyping ? text.length : 0);
|
|
217
|
+
}, [text, skipTyping]);
|
|
218
|
+
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
onTypingProgress?.(visibleChars, visibleChars < text.length);
|
|
221
|
+
}, [visibleChars, text.length, onTypingProgress]);
|
|
222
|
+
|
|
223
|
+
useEffect(() => {
|
|
224
|
+
if (!isTyping) return;
|
|
225
|
+
const stepMs = Math.max(12, Math.round(1000 / Math.max(1, charsPerSec)));
|
|
226
|
+
const timer = window.setTimeout(() => {
|
|
227
|
+
setVisibleChars((prev) => {
|
|
228
|
+
const next = Math.min(text.length, prev + 1);
|
|
229
|
+
if (next % 3 === 0)
|
|
230
|
+
triggerSfx("dialogue-blip", profile?.voicePitch ?? 1);
|
|
231
|
+
return next;
|
|
232
|
+
});
|
|
233
|
+
}, stepMs);
|
|
234
|
+
return () => window.clearTimeout(timer);
|
|
235
|
+
}, [
|
|
236
|
+
isTyping,
|
|
237
|
+
visibleChars,
|
|
238
|
+
text.length,
|
|
239
|
+
charsPerSec,
|
|
240
|
+
profile?.voicePitch,
|
|
241
|
+
triggerSfx,
|
|
242
|
+
]);
|
|
243
|
+
|
|
244
|
+
useEffect(() => {
|
|
245
|
+
if (
|
|
246
|
+
!autoMode ||
|
|
247
|
+
isTyping ||
|
|
248
|
+
!onAdvance ||
|
|
249
|
+
(choices && choices.length > 0)
|
|
250
|
+
)
|
|
251
|
+
return;
|
|
252
|
+
const timer = window.setTimeout(() => onAdvance(), 1400);
|
|
253
|
+
return () => window.clearTimeout(timer);
|
|
254
|
+
}, [autoMode, isTyping, onAdvance, choices]);
|
|
255
|
+
|
|
256
|
+
const handlePrimaryAction = useCallback(() => {
|
|
257
|
+
if (isTyping) {
|
|
258
|
+
setVisibleChars(text.length);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
triggerSfx("click-soft");
|
|
262
|
+
onAdvance?.();
|
|
263
|
+
}, [isTyping, text.length, onAdvance, triggerSfx]);
|
|
264
|
+
|
|
265
|
+
const resolvedPortrait =
|
|
266
|
+
portrait ??
|
|
267
|
+
(characterId ? (
|
|
268
|
+
<AnimeCharacterSvg
|
|
269
|
+
characterId={characterId}
|
|
270
|
+
mood={profile?.defaultMood ?? "neutral"}
|
|
271
|
+
phoneme={isTyping ? "wide" : "closed"}
|
|
272
|
+
/>
|
|
273
|
+
) : null);
|
|
274
|
+
|
|
275
|
+
return (
|
|
276
|
+
<section
|
|
277
|
+
ref={ref}
|
|
278
|
+
aria-label={`Dialogue from ${resolvedSpeaker}`}
|
|
279
|
+
data-slot="dialogue-box"
|
|
280
|
+
data-typing={isTyping ? "true" : "false"}
|
|
281
|
+
className={cn("mw-ui-game-dialogue", className)}
|
|
282
|
+
{...props}
|
|
283
|
+
>
|
|
284
|
+
{resolvedPortrait ? (
|
|
285
|
+
<div className="mw-ui-game-dialogue-portrait">{resolvedPortrait}</div>
|
|
286
|
+
) : null}
|
|
287
|
+
<div className="mw-ui-game-dialogue-body">
|
|
288
|
+
<div className="mw-ui-game-dialogue-head">
|
|
289
|
+
<div className="mw-ui-game-dialogue-speaker-wrap">
|
|
290
|
+
<span className="mw-ui-game-dialogue-speaker">
|
|
291
|
+
{resolvedSpeaker}
|
|
292
|
+
</span>
|
|
293
|
+
{resolvedRole ? (
|
|
294
|
+
<span className="mw-ui-game-dialogue-role">{resolvedRole}</span>
|
|
295
|
+
) : null}
|
|
296
|
+
</div>
|
|
297
|
+
<div className="mw-ui-game-dialogue-controls">
|
|
298
|
+
<button
|
|
299
|
+
type="button"
|
|
300
|
+
className="mw-ui-game-mini-btn"
|
|
301
|
+
aria-pressed={autoMode}
|
|
302
|
+
onClick={() => setAutoMode((prev) => !prev)}
|
|
303
|
+
>
|
|
304
|
+
Auto {autoMode ? "ON" : "OFF"}
|
|
305
|
+
</button>
|
|
306
|
+
{isTyping ? (
|
|
307
|
+
<button
|
|
308
|
+
type="button"
|
|
309
|
+
className="mw-ui-game-mini-btn"
|
|
310
|
+
onClick={() => setVisibleChars(text.length)}
|
|
311
|
+
>
|
|
312
|
+
Skip
|
|
313
|
+
</button>
|
|
314
|
+
) : null}
|
|
315
|
+
</div>
|
|
316
|
+
</div>
|
|
317
|
+
|
|
318
|
+
<p className="mw-ui-game-dialogue-text" aria-live="polite">
|
|
319
|
+
{text.slice(0, visibleChars)}
|
|
320
|
+
{isTyping ? (
|
|
321
|
+
<span aria-hidden="true" className="mw-ui-game-dialogue-caret" />
|
|
322
|
+
) : null}
|
|
323
|
+
</p>
|
|
324
|
+
|
|
325
|
+
{!isTyping && choices && choices.length > 0 ? (
|
|
326
|
+
<div
|
|
327
|
+
className="mw-ui-game-dialogue-choices"
|
|
328
|
+
role="group"
|
|
329
|
+
aria-label="Dialogue choices"
|
|
330
|
+
>
|
|
331
|
+
{choices.map((choice, idx) => (
|
|
332
|
+
<button
|
|
333
|
+
key={choice.id}
|
|
334
|
+
type="button"
|
|
335
|
+
disabled={choice.disabled}
|
|
336
|
+
className="mw-ui-game-choice-btn"
|
|
337
|
+
onClick={() => {
|
|
338
|
+
triggerSfx("toggle-pop");
|
|
339
|
+
onChoiceSelect?.(choice);
|
|
340
|
+
}}
|
|
341
|
+
>
|
|
342
|
+
<span className="mw-ui-game-choice-index">{idx + 1}</span>
|
|
343
|
+
<span>{choice.label}</span>
|
|
344
|
+
{choice.hint ? (
|
|
345
|
+
<small className="mw-ui-game-choice-hint">
|
|
346
|
+
{choice.hint}
|
|
347
|
+
</small>
|
|
348
|
+
) : null}
|
|
349
|
+
</button>
|
|
350
|
+
))}
|
|
351
|
+
</div>
|
|
352
|
+
) : onAdvance ? (
|
|
353
|
+
<div className="mw-ui-game-dialogue-footer">
|
|
354
|
+
<button
|
|
355
|
+
type="button"
|
|
356
|
+
className="mw-ui-game-advance-btn"
|
|
357
|
+
onClick={handlePrimaryAction}
|
|
358
|
+
>
|
|
359
|
+
<span>{isTyping ? "Reveal" : advanceLabel}</span>
|
|
360
|
+
<span aria-hidden="true" className="mw-ui-game-advance-arrow">
|
|
361
|
+
▸
|
|
362
|
+
</span>
|
|
363
|
+
</button>
|
|
364
|
+
</div>
|
|
365
|
+
) : null}
|
|
366
|
+
</div>
|
|
367
|
+
</section>
|
|
368
|
+
);
|
|
369
|
+
},
|
|
370
|
+
);
|
|
371
|
+
DialogueBox.displayName = "DialogueBox";
|
|
372
|
+
|
|
373
|
+
export interface CombatTextEvent {
|
|
374
|
+
readonly id: string | number;
|
|
375
|
+
readonly text: string;
|
|
376
|
+
readonly tone?: "damage" | "crit" | "heal" | "status";
|
|
377
|
+
readonly xPercent?: number;
|
|
378
|
+
readonly yPercent?: number;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export type FloatingCombatTextProps = ComponentPropsWithoutRef<"div"> & {
|
|
382
|
+
events: readonly CombatTextEvent[];
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
export const FloatingCombatText = forwardRef<
|
|
386
|
+
HTMLDivElement,
|
|
387
|
+
FloatingCombatTextProps
|
|
388
|
+
>(function FloatingCombatText({ events, className, ...props }, ref) {
|
|
389
|
+
const { reducedMotion } = useMotion();
|
|
390
|
+
return (
|
|
391
|
+
<div
|
|
392
|
+
ref={ref}
|
|
393
|
+
aria-live="polite"
|
|
394
|
+
data-slot="floating-combat-text"
|
|
395
|
+
data-reduced-motion={reducedMotion ? "true" : "false"}
|
|
396
|
+
className={cn("mw-ui-game-combat-layer", className)}
|
|
397
|
+
{...props}
|
|
398
|
+
>
|
|
399
|
+
{events.map((evt) => (
|
|
400
|
+
<span
|
|
401
|
+
key={evt.id}
|
|
402
|
+
data-tone={evt.tone ?? "damage"}
|
|
403
|
+
className="mw-ui-game-combat-pop"
|
|
404
|
+
style={
|
|
405
|
+
{
|
|
406
|
+
left: `${evt.xPercent ?? 50}%`,
|
|
407
|
+
top: `${evt.yPercent ?? 40}%`,
|
|
408
|
+
} as CSSProperties
|
|
409
|
+
}
|
|
410
|
+
>
|
|
411
|
+
{evt.text}
|
|
412
|
+
</span>
|
|
413
|
+
))}
|
|
414
|
+
</div>
|
|
415
|
+
);
|
|
416
|
+
});
|
|
417
|
+
FloatingCombatText.displayName = "FloatingCombatText";
|
|
418
|
+
|
|
419
|
+
export type ItemRarity = "common" | "rare" | "epic" | "legendary";
|
|
420
|
+
|
|
421
|
+
export interface HotbarSlotItem {
|
|
422
|
+
readonly id: string;
|
|
423
|
+
readonly label: string;
|
|
424
|
+
readonly hotkey?: string;
|
|
425
|
+
readonly icon?: ReactNode;
|
|
426
|
+
readonly count?: number;
|
|
427
|
+
readonly rarity?: ItemRarity;
|
|
428
|
+
readonly cooldownProgress?: number; // 0 = ready, 1 = just triggered
|
|
429
|
+
readonly cooldownSeconds?: number;
|
|
430
|
+
readonly active?: boolean;
|
|
431
|
+
readonly disabled?: boolean;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export type InventoryGridProps = ComponentPropsWithoutRef<"div"> & {
|
|
435
|
+
items: readonly HotbarSlotItem[];
|
|
436
|
+
columns?: number;
|
|
437
|
+
onActivate?: (item: HotbarSlotItem) => void;
|
|
438
|
+
ariaLabel?: string;
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
export const InventoryGrid = forwardRef<HTMLDivElement, InventoryGridProps>(
|
|
442
|
+
function InventoryGrid(
|
|
443
|
+
{
|
|
444
|
+
items,
|
|
445
|
+
columns = 4,
|
|
446
|
+
onActivate,
|
|
447
|
+
ariaLabel = "Inventory slots",
|
|
448
|
+
className,
|
|
449
|
+
style,
|
|
450
|
+
...props
|
|
451
|
+
},
|
|
452
|
+
ref,
|
|
453
|
+
) {
|
|
454
|
+
const { triggerSfx } = useMotion();
|
|
455
|
+
return (
|
|
456
|
+
<div
|
|
457
|
+
ref={ref}
|
|
458
|
+
role="group"
|
|
459
|
+
aria-label={ariaLabel}
|
|
460
|
+
data-slot="inventory-grid"
|
|
461
|
+
className={cn("mw-ui-game-inventory", className)}
|
|
462
|
+
style={
|
|
463
|
+
{
|
|
464
|
+
...style,
|
|
465
|
+
"--mw-grid-cols": String(Math.max(1, columns)),
|
|
466
|
+
} as CSSProperties
|
|
467
|
+
}
|
|
468
|
+
{...props}
|
|
469
|
+
>
|
|
470
|
+
{items.map((item) => {
|
|
471
|
+
const cooling = (item.cooldownProgress ?? 0) > 0;
|
|
472
|
+
const pct = Math.round(clampUnit(item.cooldownProgress ?? 0) * 100);
|
|
473
|
+
return (
|
|
474
|
+
<button
|
|
475
|
+
key={item.id}
|
|
476
|
+
type="button"
|
|
477
|
+
disabled={item.disabled || cooling}
|
|
478
|
+
data-rarity={item.rarity ?? "common"}
|
|
479
|
+
data-active={item.active ? "true" : "false"}
|
|
480
|
+
data-cooling={cooling ? "true" : "false"}
|
|
481
|
+
aria-label={`${item.label}${item.hotkey ? ` (Key ${item.hotkey})` : ""}${
|
|
482
|
+
cooling && item.cooldownSeconds
|
|
483
|
+
? `, ${item.cooldownSeconds.toFixed(1)}s cooldown`
|
|
484
|
+
: ""
|
|
485
|
+
}`}
|
|
486
|
+
className="mw-ui-game-slot"
|
|
487
|
+
onClick={() => {
|
|
488
|
+
triggerSfx("click-soft");
|
|
489
|
+
onActivate?.(item);
|
|
490
|
+
}}
|
|
491
|
+
>
|
|
492
|
+
{item.hotkey ? (
|
|
493
|
+
<span className="mw-ui-game-slot-key">{item.hotkey}</span>
|
|
494
|
+
) : null}
|
|
495
|
+
<span className="mw-ui-game-slot-icon" aria-hidden="true">
|
|
496
|
+
{item.icon ?? item.label.slice(0, 2).toUpperCase()}
|
|
497
|
+
</span>
|
|
498
|
+
<span className="mw-ui-game-slot-label">{item.label}</span>
|
|
499
|
+
{typeof item.count === "number" ? (
|
|
500
|
+
<span className="mw-ui-game-slot-count">×{item.count}</span>
|
|
501
|
+
) : null}
|
|
502
|
+
{cooling ? (
|
|
503
|
+
<span
|
|
504
|
+
aria-hidden="true"
|
|
505
|
+
className="mw-ui-game-slot-cooldown"
|
|
506
|
+
style={{ height: `${pct}%` }}
|
|
507
|
+
>
|
|
508
|
+
{item.cooldownSeconds
|
|
509
|
+
? `${item.cooldownSeconds.toFixed(1)}s`
|
|
510
|
+
: null}
|
|
511
|
+
</span>
|
|
512
|
+
) : null}
|
|
513
|
+
</button>
|
|
514
|
+
);
|
|
515
|
+
})}
|
|
516
|
+
</div>
|
|
517
|
+
);
|
|
518
|
+
},
|
|
519
|
+
);
|
|
520
|
+
InventoryGrid.displayName = "InventoryGrid";
|
|
521
|
+
|
|
522
|
+
export const ActionHotbar = forwardRef<HTMLDivElement, InventoryGridProps>(
|
|
523
|
+
function ActionHotbar(
|
|
524
|
+
{ items, columns, ariaLabel = "Action hotbar", className, ...props },
|
|
525
|
+
ref,
|
|
526
|
+
) {
|
|
527
|
+
return (
|
|
528
|
+
<InventoryGrid
|
|
529
|
+
ref={ref}
|
|
530
|
+
items={items}
|
|
531
|
+
columns={columns ?? items.length}
|
|
532
|
+
ariaLabel={ariaLabel}
|
|
533
|
+
className={cn("mw-ui-game-hotbar", className)}
|
|
534
|
+
{...props}
|
|
535
|
+
/>
|
|
536
|
+
);
|
|
537
|
+
},
|
|
538
|
+
);
|
|
539
|
+
ActionHotbar.displayName = "ActionHotbar";
|
|
540
|
+
|
|
541
|
+
export type ComboCounterProps = ComponentPropsWithoutRef<"div"> & {
|
|
542
|
+
count: number;
|
|
543
|
+
label?: string;
|
|
544
|
+
decayProgress?: number; // 0..1 remaining time
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
export function resolveComboTier(
|
|
548
|
+
count: number,
|
|
549
|
+
): "C" | "B" | "A" | "S" | "SS" | "SSS" {
|
|
550
|
+
if (count >= 25) return "SSS";
|
|
551
|
+
if (count >= 16) return "SS";
|
|
552
|
+
if (count >= 10) return "S";
|
|
553
|
+
if (count >= 6) return "A";
|
|
554
|
+
if (count >= 3) return "B";
|
|
555
|
+
return "C";
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export const ComboCounter = forwardRef<HTMLDivElement, ComboCounterProps>(
|
|
559
|
+
function ComboCounter(
|
|
560
|
+
{ count, label = "CHAIN", decayProgress = 1, className, ...props },
|
|
561
|
+
ref,
|
|
562
|
+
) {
|
|
563
|
+
const tier = resolveComboTier(count);
|
|
564
|
+
return (
|
|
565
|
+
<div
|
|
566
|
+
ref={ref}
|
|
567
|
+
role="status"
|
|
568
|
+
aria-live="polite"
|
|
569
|
+
data-slot="combo-counter"
|
|
570
|
+
data-tier={tier}
|
|
571
|
+
data-active={count > 0 ? "true" : "false"}
|
|
572
|
+
className={cn("mw-ui-game-combo", className)}
|
|
573
|
+
{...props}
|
|
574
|
+
>
|
|
575
|
+
<div className="mw-ui-game-combo-top">
|
|
576
|
+
<span className="mw-ui-game-combo-tier">{tier}</span>
|
|
577
|
+
<span key={count} className="mw-ui-game-combo-count">
|
|
578
|
+
×{count}
|
|
579
|
+
</span>
|
|
580
|
+
<span className="mw-ui-game-combo-label">{label}</span>
|
|
581
|
+
</div>
|
|
582
|
+
<div className="mw-ui-game-combo-bar" aria-hidden="true">
|
|
583
|
+
<div
|
|
584
|
+
className="mw-ui-game-combo-fill"
|
|
585
|
+
style={{ width: `${Math.round(clampUnit(decayProgress) * 100)}%` }}
|
|
586
|
+
/>
|
|
587
|
+
</div>
|
|
588
|
+
</div>
|
|
589
|
+
);
|
|
590
|
+
},
|
|
591
|
+
);
|
|
592
|
+
ComboCounter.displayName = "ComboCounter";
|
|
593
|
+
|
|
594
|
+
export interface RadialMenuOption {
|
|
595
|
+
readonly id: string;
|
|
596
|
+
readonly label: string;
|
|
597
|
+
readonly badge?: string;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
export type RadialMenuProps = Omit<
|
|
601
|
+
ComponentPropsWithoutRef<"div">,
|
|
602
|
+
"onSelect"
|
|
603
|
+
> & {
|
|
604
|
+
options: readonly RadialMenuOption[];
|
|
605
|
+
activeId?: string;
|
|
606
|
+
onSelect?: (option: RadialMenuOption) => void;
|
|
607
|
+
centerLabel?: string;
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
export const RadialMenu = forwardRef<HTMLDivElement, RadialMenuProps>(
|
|
611
|
+
function RadialMenu(
|
|
612
|
+
{ options, activeId, onSelect, centerLabel = "ACT", className, ...props },
|
|
613
|
+
ref,
|
|
614
|
+
) {
|
|
615
|
+
const { triggerSfx } = useMotion();
|
|
616
|
+
const radius = 64;
|
|
617
|
+
return (
|
|
618
|
+
<div
|
|
619
|
+
ref={ref}
|
|
620
|
+
role="group"
|
|
621
|
+
aria-label="Radial quick actions"
|
|
622
|
+
data-slot="radial-menu"
|
|
623
|
+
className={cn("mw-ui-game-radial", className)}
|
|
624
|
+
{...props}
|
|
625
|
+
>
|
|
626
|
+
<span className="mw-ui-game-radial-center">{centerLabel}</span>
|
|
627
|
+
{options.map((opt, idx) => {
|
|
628
|
+
const angle =
|
|
629
|
+
(idx / Math.max(1, options.length)) * Math.PI * 2 - Math.PI / 2;
|
|
630
|
+
const x = Math.round(Math.cos(angle) * radius);
|
|
631
|
+
const y = Math.round(Math.sin(angle) * radius);
|
|
632
|
+
const isSelected = activeId === opt.id;
|
|
633
|
+
return (
|
|
634
|
+
<button
|
|
635
|
+
key={opt.id}
|
|
636
|
+
type="button"
|
|
637
|
+
aria-pressed={isSelected}
|
|
638
|
+
data-active={isSelected ? "true" : "false"}
|
|
639
|
+
className="mw-ui-game-radial-btn"
|
|
640
|
+
style={{ transform: `translate(${x}px, ${y}px)` }}
|
|
641
|
+
onClick={() => {
|
|
642
|
+
triggerSfx("toggle-pop");
|
|
643
|
+
onSelect?.(opt);
|
|
644
|
+
}}
|
|
645
|
+
>
|
|
646
|
+
<span>{opt.label}</span>
|
|
647
|
+
{opt.badge ? <small>{opt.badge}</small> : null}
|
|
648
|
+
</button>
|
|
649
|
+
);
|
|
650
|
+
})}
|
|
651
|
+
</div>
|
|
652
|
+
);
|
|
653
|
+
},
|
|
654
|
+
);
|
|
655
|
+
RadialMenu.displayName = "RadialMenu";
|
|
656
|
+
|
|
657
|
+
export type InputPromptPlatform = "keyboard" | "xbox" | "playstation";
|
|
658
|
+
|
|
659
|
+
export type InputPromptBadgeProps = ComponentPropsWithoutRef<"kbd"> & {
|
|
660
|
+
input: string;
|
|
661
|
+
platform?: InputPromptPlatform;
|
|
662
|
+
actionLabel?: string;
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
export const InputPromptBadge = forwardRef<HTMLElement, InputPromptBadgeProps>(
|
|
666
|
+
function InputPromptBadge(
|
|
667
|
+
{ input, platform = "keyboard", actionLabel, className, ...props },
|
|
668
|
+
ref,
|
|
669
|
+
) {
|
|
670
|
+
return (
|
|
671
|
+
<kbd
|
|
672
|
+
ref={ref}
|
|
673
|
+
data-slot="input-prompt-badge"
|
|
674
|
+
data-platform={platform}
|
|
675
|
+
className={cn("mw-ui-game-prompt", className)}
|
|
676
|
+
{...props}
|
|
677
|
+
>
|
|
678
|
+
<span className="mw-ui-game-prompt-key">{input}</span>
|
|
679
|
+
{actionLabel ? (
|
|
680
|
+
<span className="mw-ui-game-prompt-action">{actionLabel}</span>
|
|
681
|
+
) : null}
|
|
682
|
+
</kbd>
|
|
683
|
+
);
|
|
684
|
+
},
|
|
685
|
+
);
|
|
686
|
+
InputPromptBadge.displayName = "InputPromptBadge";
|
|
687
|
+
|
|
688
|
+
export interface GamepadNavOptions {
|
|
689
|
+
readonly itemCount: number;
|
|
690
|
+
readonly initialIndex?: number;
|
|
691
|
+
readonly enabled?: boolean;
|
|
692
|
+
readonly onConfirm?: (index: number) => void;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
export function useGamepadNavigation({
|
|
696
|
+
itemCount,
|
|
697
|
+
initialIndex = 0,
|
|
698
|
+
enabled = true,
|
|
699
|
+
onConfirm,
|
|
700
|
+
}: GamepadNavOptions) {
|
|
701
|
+
const [activeIndex, setActiveIndex] = useState(
|
|
702
|
+
itemCount > 0 ? Math.min(itemCount - 1, Math.max(0, initialIndex)) : 0,
|
|
703
|
+
);
|
|
704
|
+
|
|
705
|
+
const move = useCallback(
|
|
706
|
+
(delta: number) => {
|
|
707
|
+
if (itemCount <= 0) return;
|
|
708
|
+
setActiveIndex((prev) => (prev + delta + itemCount) % itemCount);
|
|
709
|
+
},
|
|
710
|
+
[itemCount],
|
|
711
|
+
);
|
|
712
|
+
|
|
713
|
+
const handleKeyDown = useCallback(
|
|
714
|
+
(event: { key: string; preventDefault?: () => void }) => {
|
|
715
|
+
if (!enabled || itemCount <= 0) return;
|
|
716
|
+
if (
|
|
717
|
+
event.key === "ArrowDown" ||
|
|
718
|
+
event.key === "ArrowRight" ||
|
|
719
|
+
event.key === "s" ||
|
|
720
|
+
event.key === "d"
|
|
721
|
+
) {
|
|
722
|
+
event.preventDefault?.();
|
|
723
|
+
move(1);
|
|
724
|
+
} else if (
|
|
725
|
+
event.key === "ArrowUp" ||
|
|
726
|
+
event.key === "ArrowLeft" ||
|
|
727
|
+
event.key === "w" ||
|
|
728
|
+
event.key === "a"
|
|
729
|
+
) {
|
|
730
|
+
event.preventDefault?.();
|
|
731
|
+
move(-1);
|
|
732
|
+
} else if (event.key === "Enter" || event.key === " ") {
|
|
733
|
+
event.preventDefault?.();
|
|
734
|
+
onConfirm?.(activeIndex);
|
|
735
|
+
}
|
|
736
|
+
},
|
|
737
|
+
[enabled, itemCount, move, onConfirm, activeIndex],
|
|
738
|
+
);
|
|
739
|
+
|
|
740
|
+
return useMemo(
|
|
741
|
+
() => ({ activeIndex, setActiveIndex, move, handleKeyDown }),
|
|
742
|
+
[activeIndex, move, handleKeyDown],
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
export type GameTitleScreenProps = ComponentPropsWithoutRef<"section"> & {
|
|
747
|
+
title: string;
|
|
748
|
+
subtitle?: string;
|
|
749
|
+
menuItems: readonly { readonly id: string; readonly label: string }[];
|
|
750
|
+
onSelectItem: (id: string) => void;
|
|
751
|
+
footerPrompt?: string;
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
export const GameTitleScreen = forwardRef<HTMLElement, GameTitleScreenProps>(
|
|
755
|
+
function GameTitleScreen(
|
|
756
|
+
{
|
|
757
|
+
title,
|
|
758
|
+
subtitle,
|
|
759
|
+
menuItems,
|
|
760
|
+
onSelectItem,
|
|
761
|
+
footerPrompt = "PRESS ENTER OR CLICK TO START",
|
|
762
|
+
className,
|
|
763
|
+
...props
|
|
764
|
+
},
|
|
765
|
+
ref,
|
|
766
|
+
) {
|
|
767
|
+
const { triggerSfx } = useMotion();
|
|
768
|
+
const nav = useGamepadNavigation({
|
|
769
|
+
itemCount: menuItems.length,
|
|
770
|
+
onConfirm: (idx) => {
|
|
771
|
+
const item = menuItems[idx];
|
|
772
|
+
if (item) {
|
|
773
|
+
triggerSfx("level-up");
|
|
774
|
+
onSelectItem(item.id);
|
|
775
|
+
}
|
|
776
|
+
},
|
|
777
|
+
});
|
|
778
|
+
|
|
779
|
+
return (
|
|
780
|
+
<section
|
|
781
|
+
ref={ref}
|
|
782
|
+
tabIndex={0}
|
|
783
|
+
onKeyDown={nav.handleKeyDown}
|
|
784
|
+
data-slot="game-title-screen"
|
|
785
|
+
className={cn("mw-ui-game-title-screen", className)}
|
|
786
|
+
{...props}
|
|
787
|
+
>
|
|
788
|
+
<div className="mw-ui-game-title-head">
|
|
789
|
+
<h3 className="mw-ui-game-title-heading">{title}</h3>
|
|
790
|
+
{subtitle ? <p className="mw-ui-game-title-sub">{subtitle}</p> : null}
|
|
791
|
+
</div>
|
|
792
|
+
<div
|
|
793
|
+
className="mw-ui-game-title-menu"
|
|
794
|
+
role="menu"
|
|
795
|
+
aria-label={`${title} menu`}
|
|
796
|
+
>
|
|
797
|
+
{menuItems.map((item, idx) => (
|
|
798
|
+
<button
|
|
799
|
+
key={item.id}
|
|
800
|
+
type="button"
|
|
801
|
+
role="menuitem"
|
|
802
|
+
data-active={nav.activeIndex === idx ? "true" : "false"}
|
|
803
|
+
className="mw-ui-game-title-btn"
|
|
804
|
+
onMouseEnter={() => nav.setActiveIndex(idx)}
|
|
805
|
+
onClick={() => {
|
|
806
|
+
nav.setActiveIndex(idx);
|
|
807
|
+
triggerSfx("level-up");
|
|
808
|
+
onSelectItem(item.id);
|
|
809
|
+
}}
|
|
810
|
+
>
|
|
811
|
+
<span aria-hidden="true" className="mw-ui-game-title-cursor">
|
|
812
|
+
▶
|
|
813
|
+
</span>
|
|
814
|
+
<span>{item.label}</span>
|
|
815
|
+
</button>
|
|
816
|
+
))}
|
|
817
|
+
</div>
|
|
818
|
+
<p className="mw-ui-game-title-footer">{footerPrompt}</p>
|
|
819
|
+
</section>
|
|
820
|
+
);
|
|
821
|
+
},
|
|
822
|
+
);
|
|
823
|
+
GameTitleScreen.displayName = "GameTitleScreen";
|
|
824
|
+
|
|
825
|
+
export type PauseMenuOverlayProps = ComponentPropsWithoutRef<"div"> & {
|
|
826
|
+
open: boolean;
|
|
827
|
+
title?: string;
|
|
828
|
+
onResume: () => void;
|
|
829
|
+
onRestart?: () => void;
|
|
830
|
+
children?: ReactNode;
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
export const PauseMenuOverlay = forwardRef<
|
|
834
|
+
HTMLDivElement,
|
|
835
|
+
PauseMenuOverlayProps
|
|
836
|
+
>(function PauseMenuOverlay(
|
|
837
|
+
{
|
|
838
|
+
open,
|
|
839
|
+
title = "PAUSED",
|
|
840
|
+
onResume,
|
|
841
|
+
onRestart,
|
|
842
|
+
children,
|
|
843
|
+
className,
|
|
844
|
+
...props
|
|
845
|
+
},
|
|
846
|
+
ref,
|
|
847
|
+
) {
|
|
848
|
+
if (!open) return null;
|
|
849
|
+
return (
|
|
850
|
+
<div
|
|
851
|
+
ref={ref}
|
|
852
|
+
role="dialog"
|
|
853
|
+
aria-modal="true"
|
|
854
|
+
aria-label={title}
|
|
855
|
+
data-slot="pause-menu-overlay"
|
|
856
|
+
className={cn("mw-ui-game-pause", className)}
|
|
857
|
+
{...props}
|
|
858
|
+
>
|
|
859
|
+
<div className="mw-ui-game-pause-card">
|
|
860
|
+
<h4 className="mw-ui-game-pause-title">{title}</h4>
|
|
861
|
+
{children}
|
|
862
|
+
<div className="mw-ui-game-pause-actions">
|
|
863
|
+
<button
|
|
864
|
+
type="button"
|
|
865
|
+
className="mw-ui-button"
|
|
866
|
+
data-variant="default"
|
|
867
|
+
onClick={onResume}
|
|
868
|
+
>
|
|
869
|
+
Resume
|
|
870
|
+
</button>
|
|
871
|
+
{onRestart ? (
|
|
872
|
+
<button
|
|
873
|
+
type="button"
|
|
874
|
+
className="mw-ui-button"
|
|
875
|
+
data-variant="outline"
|
|
876
|
+
onClick={onRestart}
|
|
877
|
+
>
|
|
878
|
+
Restart
|
|
879
|
+
</button>
|
|
880
|
+
) : null}
|
|
881
|
+
</div>
|
|
882
|
+
</div>
|
|
883
|
+
</div>
|
|
884
|
+
);
|
|
885
|
+
});
|
|
886
|
+
PauseMenuOverlay.displayName = "PauseMenuOverlay";
|