@dreamboard-games/ui-sdk 0.0.41
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/LICENSE +89 -0
- package/NOTICE +1 -0
- package/README.md +154 -0
- package/dist/components/ActionButton.d.ts +13 -0
- package/dist/components/ActionButton.d.ts.map +1 -0
- package/dist/components/ActionButton.js +14 -0
- package/dist/components/ActionPanel.d.ts +33 -0
- package/dist/components/ActionPanel.d.ts.map +1 -0
- package/dist/components/ActionPanel.js +148 -0
- package/dist/components/Card.d.ts +29 -0
- package/dist/components/Card.d.ts.map +1 -0
- package/dist/components/Card.js +220 -0
- package/dist/components/ChromeSuppressionContext.d.ts +7 -0
- package/dist/components/ChromeSuppressionContext.d.ts.map +1 -0
- package/dist/components/ChromeSuppressionContext.js +34 -0
- package/dist/components/CostDisplay.d.ts +22 -0
- package/dist/components/CostDisplay.d.ts.map +1 -0
- package/dist/components/CostDisplay.js +41 -0
- package/dist/components/DiceRoller.d.ts +30 -0
- package/dist/components/DiceRoller.d.ts.map +1 -0
- package/dist/components/DiceRoller.js +319 -0
- package/dist/components/Drawer.d.ts +19 -0
- package/dist/components/Drawer.d.ts.map +1 -0
- package/dist/components/Drawer.js +55 -0
- package/dist/components/ErrorBoundary.d.ts +24 -0
- package/dist/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/components/ErrorBoundary.js +37 -0
- package/dist/components/GameEndDisplay.d.ts +27 -0
- package/dist/components/GameEndDisplay.d.ts.map +1 -0
- package/dist/components/GameEndDisplay.js +185 -0
- package/dist/components/GameSkeleton.d.ts +12 -0
- package/dist/components/GameSkeleton.d.ts.map +1 -0
- package/dist/components/GameSkeleton.js +54 -0
- package/dist/components/Hand.d.ts +99 -0
- package/dist/components/Hand.d.ts.map +1 -0
- package/dist/components/Hand.js +162 -0
- package/dist/components/HandDock.d.ts +35 -0
- package/dist/components/HandDock.d.ts.map +1 -0
- package/dist/components/HandDock.js +124 -0
- package/dist/components/InteractionForm.d.ts +50 -0
- package/dist/components/InteractionForm.d.ts.map +1 -0
- package/dist/components/InteractionForm.js +402 -0
- package/dist/components/MoreActions.d.ts +49 -0
- package/dist/components/MoreActions.d.ts.map +1 -0
- package/dist/components/MoreActions.js +64 -0
- package/dist/components/PhaseIndicator.d.ts +35 -0
- package/dist/components/PhaseIndicator.d.ts.map +1 -0
- package/dist/components/PhaseIndicator.js +212 -0
- package/dist/components/PlayArea.d.ts +28 -0
- package/dist/components/PlayArea.d.ts.map +1 -0
- package/dist/components/PlayArea.js +48 -0
- package/dist/components/PluginRuntime.d.ts +37 -0
- package/dist/components/PluginRuntime.d.ts.map +1 -0
- package/dist/components/PluginRuntime.js +47 -0
- package/dist/components/PrimaryActionButton.d.ts +98 -0
- package/dist/components/PrimaryActionButton.d.ts.map +1 -0
- package/dist/components/PrimaryActionButton.js +183 -0
- package/dist/components/PrimaryButton.d.ts +20 -0
- package/dist/components/PrimaryButton.d.ts.map +1 -0
- package/dist/components/PrimaryButton.js +5 -0
- package/dist/components/PromptDialogHost.d.ts +15 -0
- package/dist/components/PromptDialogHost.d.ts.map +1 -0
- package/dist/components/PromptDialogHost.js +22 -0
- package/dist/components/ResourceCounter.d.ts +38 -0
- package/dist/components/ResourceCounter.d.ts.map +1 -0
- package/dist/components/ResourceCounter.js +118 -0
- package/dist/components/ThemedButton.d.ts +12 -0
- package/dist/components/ThemedButton.d.ts.map +1 -0
- package/dist/components/ThemedButton.js +38 -0
- package/dist/components/Toast.d.ts +35 -0
- package/dist/components/Toast.d.ts.map +1 -0
- package/dist/components/Toast.js +116 -0
- package/dist/components/board/HexGrid.d.ts +344 -0
- package/dist/components/board/HexGrid.d.ts.map +1 -0
- package/dist/components/board/HexGrid.js +340 -0
- package/dist/components/board/NetworkGraph.d.ts +100 -0
- package/dist/components/board/NetworkGraph.d.ts.map +1 -0
- package/dist/components/board/NetworkGraph.js +123 -0
- package/dist/components/board/SlotSystem.d.ts +71 -0
- package/dist/components/board/SlotSystem.d.ts.map +1 -0
- package/dist/components/board/SlotSystem.js +87 -0
- package/dist/components/board/SquareGrid.d.ts +188 -0
- package/dist/components/board/SquareGrid.d.ts.map +1 -0
- package/dist/components/board/SquareGrid.js +328 -0
- package/dist/components/board/TrackBoard.d.ts +113 -0
- package/dist/components/board/TrackBoard.d.ts.map +1 -0
- package/dist/components/board/TrackBoard.js +135 -0
- package/dist/components/board/ZoneMap.d.ts +88 -0
- package/dist/components/board/ZoneMap.d.ts.map +1 -0
- package/dist/components/board/ZoneMap.js +133 -0
- package/dist/components/board/hex-board-view.d.ts +69 -0
- package/dist/components/board/hex-board-view.d.ts.map +1 -0
- package/dist/components/board/hex-board-view.js +60 -0
- package/dist/components/board/index.d.ts +23 -0
- package/dist/components/board/index.d.ts.map +1 -0
- package/dist/components/board/index.js +40 -0
- package/dist/components/board/interaction-accessibility.d.ts +5 -0
- package/dist/components/board/interaction-accessibility.d.ts.map +1 -0
- package/dist/components/board/interaction-accessibility.js +13 -0
- package/dist/components/board/target-layer.d.ts +13 -0
- package/dist/components/board/target-layer.d.ts.map +1 -0
- package/dist/components/board/target-layer.js +10 -0
- package/dist/components/card-render-content.type-test.d.ts +2 -0
- package/dist/components/card-render-content.type-test.d.ts.map +1 -0
- package/dist/components/card-render-content.type-test.js +1 -0
- package/dist/components/index.d.ts +34 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +35 -0
- package/dist/components/interaction-dialog-behavior.d.ts +15 -0
- package/dist/components/interaction-dialog-behavior.d.ts.map +1 -0
- package/dist/components/interaction-dialog-behavior.js +9 -0
- package/dist/components/surfaces/BlockerSurface.d.ts +27 -0
- package/dist/components/surfaces/BlockerSurface.d.ts.map +1 -0
- package/dist/components/surfaces/BlockerSurface.js +38 -0
- package/dist/components/surfaces/BoardSurface.d.ts +77 -0
- package/dist/components/surfaces/BoardSurface.d.ts.map +1 -0
- package/dist/components/surfaces/BoardSurface.js +180 -0
- package/dist/components/surfaces/ChromeSurface.d.ts +29 -0
- package/dist/components/surfaces/ChromeSurface.d.ts.map +1 -0
- package/dist/components/surfaces/ChromeSurface.js +34 -0
- package/dist/components/surfaces/ExhaustivenessAudit.d.ts +32 -0
- package/dist/components/surfaces/ExhaustivenessAudit.d.ts.map +1 -0
- package/dist/components/surfaces/ExhaustivenessAudit.js +65 -0
- package/dist/components/surfaces/InboxSurface.d.ts +40 -0
- package/dist/components/surfaces/InboxSurface.d.ts.map +1 -0
- package/dist/components/surfaces/InboxSurface.js +99 -0
- package/dist/components/surfaces/MarketSurface.d.ts +62 -0
- package/dist/components/surfaces/MarketSurface.d.ts.map +1 -0
- package/dist/components/surfaces/MarketSurface.js +242 -0
- package/dist/components/surfaces/PanelSurface.d.ts +111 -0
- package/dist/components/surfaces/PanelSurface.d.ts.map +1 -0
- package/dist/components/surfaces/PanelSurface.js +180 -0
- package/dist/components/surfaces/PlayerCardsSurface.d.ts +104 -0
- package/dist/components/surfaces/PlayerCardsSurface.d.ts.map +1 -0
- package/dist/components/surfaces/PlayerCardsSurface.js +178 -0
- package/dist/components/surfaces/internal/CardZoneFollowUpForm.d.ts +7 -0
- package/dist/components/surfaces/internal/CardZoneFollowUpForm.d.ts.map +1 -0
- package/dist/components/surfaces/internal/CardZoneFollowUpForm.js +9 -0
- package/dist/components/surfaces/internal/DefaultInteractionButton.d.ts +71 -0
- package/dist/components/surfaces/internal/DefaultInteractionButton.d.ts.map +1 -0
- package/dist/components/surfaces/internal/DefaultInteractionButton.js +82 -0
- package/dist/components/surfaces/internal/useCardZoneInteractions.d.ts +21 -0
- package/dist/components/surfaces/internal/useCardZoneInteractions.d.ts.map +1 -0
- package/dist/components/surfaces/internal/useCardZoneInteractions.js +202 -0
- package/dist/components/surfaces/types.d.ts +59 -0
- package/dist/components/surfaces/types.d.ts.map +1 -0
- package/dist/components/surfaces/types.js +1 -0
- package/dist/context/ClientParamSchemaContext.d.ts +21 -0
- package/dist/context/ClientParamSchemaContext.d.ts.map +1 -0
- package/dist/context/ClientParamSchemaContext.js +12 -0
- package/dist/context/InteractionDraftContext.d.ts +69 -0
- package/dist/context/InteractionDraftContext.d.ts.map +1 -0
- package/dist/context/InteractionDraftContext.js +145 -0
- package/dist/context/PluginSessionContext.d.ts +33 -0
- package/dist/context/PluginSessionContext.d.ts.map +1 -0
- package/dist/context/PluginSessionContext.js +38 -0
- package/dist/context/PluginStateContext.d.ts +116 -0
- package/dist/context/PluginStateContext.d.ts.map +1 -0
- package/dist/context/PluginStateContext.js +186 -0
- package/dist/context/RuntimeContext.d.ts +49 -0
- package/dist/context/RuntimeContext.d.ts.map +1 -0
- package/dist/context/RuntimeContext.js +67 -0
- package/dist/defaults/components.d.ts +52 -0
- package/dist/defaults/components.d.ts.map +1 -0
- package/dist/defaults/components.js +159 -0
- package/dist/defaults/index.d.ts +2 -0
- package/dist/defaults/index.d.ts.map +1 -0
- package/dist/defaults/index.js +1 -0
- package/dist/errors/ValidationError.d.ts +10 -0
- package/dist/errors/ValidationError.d.ts.map +1 -0
- package/dist/errors/ValidationError.js +23 -0
- package/dist/helpers/cards.d.ts +3 -0
- package/dist/helpers/cards.d.ts.map +1 -0
- package/dist/helpers/cards.js +11 -0
- package/dist/helpers/track-board.d.ts +79 -0
- package/dist/helpers/track-board.d.ts.map +1 -0
- package/dist/helpers/track-board.js +56 -0
- package/dist/hooks/useActivePlayers.d.ts +16 -0
- package/dist/hooks/useActivePlayers.d.ts.map +1 -0
- package/dist/hooks/useActivePlayers.js +17 -0
- package/dist/hooks/useBoardInteractions.d.ts +110 -0
- package/dist/hooks/useBoardInteractions.d.ts.map +1 -0
- package/dist/hooks/useBoardInteractions.js +248 -0
- package/dist/hooks/useBoardTopology.d.ts +23 -0
- package/dist/hooks/useBoardTopology.d.ts.map +1 -0
- package/dist/hooks/useBoardTopology.js +128 -0
- package/dist/hooks/useCards.d.ts +3 -0
- package/dist/hooks/useCards.d.ts.map +1 -0
- package/dist/hooks/useCards.js +5 -0
- package/dist/hooks/useGameSelector.d.ts +13 -0
- package/dist/hooks/useGameSelector.d.ts.map +1 -0
- package/dist/hooks/useGameSelector.js +67 -0
- package/dist/hooks/useGameView.d.ts +6 -0
- package/dist/hooks/useGameView.d.ts.map +1 -0
- package/dist/hooks/useGameView.js +7 -0
- package/dist/hooks/useHandLayout.d.ts +120 -0
- package/dist/hooks/useHandLayout.d.ts.map +1 -0
- package/dist/hooks/useHandLayout.js +235 -0
- package/dist/hooks/useHexBoard.d.ts +19 -0
- package/dist/hooks/useHexBoard.d.ts.map +1 -0
- package/dist/hooks/useHexBoard.js +28 -0
- package/dist/hooks/useHexGrid.d.ts +56 -0
- package/dist/hooks/useHexGrid.d.ts.map +1 -0
- package/dist/hooks/useHexGrid.js +112 -0
- package/dist/hooks/useInteractionByKey.d.ts +29 -0
- package/dist/hooks/useInteractionByKey.d.ts.map +1 -0
- package/dist/hooks/useInteractionByKey.js +263 -0
- package/dist/hooks/useInteractionHandle.d.ts +103 -0
- package/dist/hooks/useInteractionHandle.d.ts.map +1 -0
- package/dist/hooks/useInteractionHandle.js +254 -0
- package/dist/hooks/useIsMobile.d.ts +7 -0
- package/dist/hooks/useIsMobile.d.ts.map +1 -0
- package/dist/hooks/useIsMobile.js +29 -0
- package/dist/hooks/useIsMyTurn.d.ts +6 -0
- package/dist/hooks/useIsMyTurn.d.ts.map +1 -0
- package/dist/hooks/useIsMyTurn.js +11 -0
- package/dist/hooks/useLobby.d.ts +28 -0
- package/dist/hooks/useLobby.d.ts.map +1 -0
- package/dist/hooks/useLobby.js +60 -0
- package/dist/hooks/useMe.d.ts +11 -0
- package/dist/hooks/useMe.d.ts.map +1 -0
- package/dist/hooks/useMe.js +32 -0
- package/dist/hooks/usePanZoom.d.ts +113 -0
- package/dist/hooks/usePanZoom.d.ts.map +1 -0
- package/dist/hooks/usePanZoom.js +165 -0
- package/dist/hooks/usePlayerInfo.d.ts +4 -0
- package/dist/hooks/usePlayerInfo.d.ts.map +1 -0
- package/dist/hooks/usePlayerInfo.js +21 -0
- package/dist/hooks/usePlayerTurnOrder.d.ts +15 -0
- package/dist/hooks/usePlayerTurnOrder.d.ts.map +1 -0
- package/dist/hooks/usePlayerTurnOrder.js +22 -0
- package/dist/hooks/usePluginRuntime.d.ts +45 -0
- package/dist/hooks/usePluginRuntime.d.ts.map +1 -0
- package/dist/hooks/usePluginRuntime.js +92 -0
- package/dist/hooks/useSeatInbox.d.ts +22 -0
- package/dist/hooks/useSeatInbox.d.ts.map +1 -0
- package/dist/hooks/useSeatInbox.js +43 -0
- package/dist/hooks/useSimultaneousPhase.d.ts +7 -0
- package/dist/hooks/useSimultaneousPhase.d.ts.map +1 -0
- package/dist/hooks/useSimultaneousPhase.js +8 -0
- package/dist/hooks/useSquareBoard.d.ts +21 -0
- package/dist/hooks/useSquareBoard.d.ts.map +1 -0
- package/dist/hooks/useSquareBoard.js +67 -0
- package/dist/hooks/useSquareGrid.d.ts +96 -0
- package/dist/hooks/useSquareGrid.d.ts.map +1 -0
- package/dist/hooks/useSquareGrid.js +152 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/internal/ui/alert.d.ts +8 -0
- package/dist/internal/ui/alert.d.ts.map +1 -0
- package/dist/internal/ui/alert.js +11 -0
- package/dist/internal/ui/button.d.ts +10 -0
- package/dist/internal/ui/button.d.ts.map +1 -0
- package/dist/internal/ui/button.js +21 -0
- package/dist/internal/ui/dialog.d.ts +16 -0
- package/dist/internal/ui/dialog.d.ts.map +1 -0
- package/dist/internal/ui/dialog.js +35 -0
- package/dist/internal/ui/input.d.ts +3 -0
- package/dist/internal/ui/input.d.ts.map +1 -0
- package/dist/internal/ui/input.js +5 -0
- package/dist/internal/ui/label.d.ts +4 -0
- package/dist/internal/ui/label.d.ts.map +1 -0
- package/dist/internal/ui/label.js +7 -0
- package/dist/internal/ui/select.d.ts +9 -0
- package/dist/internal/ui/select.d.ts.map +1 -0
- package/dist/internal/ui/select.js +23 -0
- package/dist/internal/ui/tooltip.d.ts +7 -0
- package/dist/internal/ui/tooltip.d.ts.map +1 -0
- package/dist/internal/ui/tooltip.js +16 -0
- package/dist/internal/ui/utils.d.ts +3 -0
- package/dist/internal/ui/utils.d.ts.map +1 -0
- package/dist/internal/ui/utils.js +4 -0
- package/dist/internal.d.ts +7 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +4 -0
- package/dist/plugin-styles.css +246 -0
- package/dist/primitives/board.d.ts +29 -0
- package/dist/primitives/board.d.ts.map +1 -0
- package/dist/primitives/board.js +163 -0
- package/dist/primitives/game-ui-provider.d.ts +12 -0
- package/dist/primitives/game-ui-provider.d.ts.map +1 -0
- package/dist/primitives/game-ui-provider.js +7 -0
- package/dist/primitives/index.d.ts +8 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +7 -0
- package/dist/primitives/interaction.d.ts +52 -0
- package/dist/primitives/interaction.d.ts.map +1 -0
- package/dist/primitives/interaction.js +250 -0
- package/dist/primitives/phase.d.ts +15 -0
- package/dist/primitives/phase.d.ts.map +1 -0
- package/dist/primitives/phase.js +18 -0
- package/dist/primitives/player-roster.d.ts +64 -0
- package/dist/primitives/player-roster.d.ts.map +1 -0
- package/dist/primitives/player-roster.js +149 -0
- package/dist/primitives/primitive-props.d.ts +15 -0
- package/dist/primitives/primitive-props.d.ts.map +1 -0
- package/dist/primitives/primitive-props.js +39 -0
- package/dist/primitives/prompt.d.ts +44 -0
- package/dist/primitives/prompt.d.ts.map +1 -0
- package/dist/primitives/prompt.js +101 -0
- package/dist/primitives/zone.d.ts +31 -0
- package/dist/primitives/zone.d.ts.map +1 -0
- package/dist/primitives/zone.js +58 -0
- package/dist/reducer.d.ts +21 -0
- package/dist/reducer.d.ts.map +1 -0
- package/dist/reducer.js +14 -0
- package/dist/runtime/createPluginRuntimeAPI.d.ts +67 -0
- package/dist/runtime/createPluginRuntimeAPI.d.ts.map +1 -0
- package/dist/runtime/createPluginRuntimeAPI.js +419 -0
- package/dist/theme/ThemeProvider.d.ts +98 -0
- package/dist/theme/ThemeProvider.d.ts.map +1 -0
- package/dist/theme/ThemeProvider.js +148 -0
- package/dist/theme/board.d.ts +42 -0
- package/dist/theme/board.d.ts.map +1 -0
- package/dist/theme/board.js +34 -0
- package/dist/theme/css-vars.d.ts +31 -0
- package/dist/theme/css-vars.d.ts.map +1 -0
- package/dist/theme/css-vars.js +88 -0
- package/dist/theme/derive.d.ts +66 -0
- package/dist/theme/derive.d.ts.map +1 -0
- package/dist/theme/derive.js +161 -0
- package/dist/theme/index.d.ts +22 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +20 -0
- package/dist/theme/presets/arcade.d.ts +10 -0
- package/dist/theme/presets/arcade.d.ts.map +1 -0
- package/dist/theme/presets/arcade.js +257 -0
- package/dist/theme/presets/studio.d.ts +10 -0
- package/dist/theme/presets/studio.d.ts.map +1 -0
- package/dist/theme/presets/studio.js +257 -0
- package/dist/theme/presets/tabletop.d.ts +15 -0
- package/dist/theme/presets/tabletop.d.ts.map +1 -0
- package/dist/theme/presets/tabletop.js +262 -0
- package/dist/theme/tokens.d.ts +345 -0
- package/dist/theme/tokens.d.ts.map +1 -0
- package/dist/theme/tokens.js +57 -0
- package/dist/types/player-state.d.ts +337 -0
- package/dist/types/player-state.d.ts.map +1 -0
- package/dist/types/player-state.js +1 -0
- package/dist/types/plugin-state.d.ts +324 -0
- package/dist/types/plugin-state.d.ts.map +1 -0
- package/dist/types/plugin-state.js +1 -0
- package/dist/types/reducer-state.d.ts +10 -0
- package/dist/types/reducer-state.d.ts.map +1 -0
- package/dist/types/reducer-state.js +1 -0
- package/dist/types/runtime-api.d.ts +99 -0
- package/dist/types/runtime-api.d.ts.map +1 -0
- package/dist/types/runtime-api.js +1 -0
- package/dist/types/tiled-board.d.ts +187 -0
- package/dist/types/tiled-board.d.ts.map +1 -0
- package/dist/types/tiled-board.js +226 -0
- package/dist/ui-contract.d.ts +78 -0
- package/dist/ui-contract.d.ts.map +1 -0
- package/dist/ui-contract.js +15 -0
- package/dist/ui-sdk.d.ts +3409 -0
- package/dist/utils/interaction-inputs.d.ts +22 -0
- package/dist/utils/interaction-inputs.d.ts.map +1 -0
- package/dist/utils/interaction-inputs.js +219 -0
- package/dist/utils/interaction-labels.d.ts +4 -0
- package/dist/utils/interaction-labels.d.ts.map +1 -0
- package/dist/utils/interaction-labels.js +18 -0
- package/dist/utils/interaction-status.d.ts +15 -0
- package/dist/utils/interaction-status.d.ts.map +1 -0
- package/dist/utils/interaction-status.js +31 -0
- package/package.json +101 -0
- package/src/components/ActionButton.tsx +48 -0
- package/src/components/ActionPanel.tsx +310 -0
- package/src/components/Card.tsx +385 -0
- package/src/components/ChromeSuppressionContext.tsx +70 -0
- package/src/components/CostDisplay.test.tsx +23 -0
- package/src/components/CostDisplay.tsx +145 -0
- package/src/components/DiceRoller.tsx +601 -0
- package/src/components/Drawer.tsx +179 -0
- package/src/components/ErrorBoundary.tsx +119 -0
- package/src/components/GameEndDisplay.test.tsx +19 -0
- package/src/components/GameEndDisplay.tsx +398 -0
- package/src/components/GameSkeleton.tsx +260 -0
- package/src/components/Hand.tsx +387 -0
- package/src/components/HandDock.tsx +257 -0
- package/src/components/InteractionForm.test.tsx +303 -0
- package/src/components/InteractionForm.tsx +1029 -0
- package/src/components/MoreActions.test.tsx +93 -0
- package/src/components/MoreActions.tsx +143 -0
- package/src/components/PhaseIndicator.tsx +341 -0
- package/src/components/PlayArea.tsx +125 -0
- package/src/components/PluginRuntime.tsx +92 -0
- package/src/components/PrimaryActionButton.test.tsx +138 -0
- package/src/components/PrimaryActionButton.tsx +351 -0
- package/src/components/PrimaryButton.tsx +44 -0
- package/src/components/PromptDialogHost.tsx +92 -0
- package/src/components/ResourceCounter.test.tsx +29 -0
- package/src/components/ResourceCounter.tsx +275 -0
- package/src/components/ThemedButton.tsx +78 -0
- package/src/components/Toast.tsx +251 -0
- package/src/components/__fixtures__/ActionButton.fixture.tsx +234 -0
- package/src/components/__fixtures__/ActionPanel.fixture.tsx +298 -0
- package/src/components/__fixtures__/Card.fixture.tsx +185 -0
- package/src/components/__fixtures__/CostDisplay.fixture.tsx +156 -0
- package/src/components/__fixtures__/DiceRoller.fixture.tsx +435 -0
- package/src/components/__fixtures__/Drawer.fixture.tsx +113 -0
- package/src/components/__fixtures__/ErrorBoundary.fixture.tsx +82 -0
- package/src/components/__fixtures__/GameEndDisplay.fixture.tsx +188 -0
- package/src/components/__fixtures__/GameSkeleton.fixture.tsx +46 -0
- package/src/components/__fixtures__/Hand.fixture.tsx +522 -0
- package/src/components/__fixtures__/HexGrid.fixture.tsx +1181 -0
- package/src/components/__fixtures__/NetworkGraph.fixture.tsx +599 -0
- package/src/components/__fixtures__/PhaseIndicator.fixture.tsx +181 -0
- package/src/components/__fixtures__/PlayArea.fixture.tsx +221 -0
- package/src/components/__fixtures__/ResourceCounter.fixture.tsx +227 -0
- package/src/components/__fixtures__/SlotSystem.fixture.tsx +824 -0
- package/src/components/__fixtures__/SquareGrid.fixture.tsx +764 -0
- package/src/components/__fixtures__/Toast.fixture.tsx +97 -0
- package/src/components/__fixtures__/TrackBoard.fixture.tsx +685 -0
- package/src/components/__fixtures__/ZoneMap.fixture.tsx +754 -0
- package/src/components/board/HexGrid.tsx +1294 -0
- package/src/components/board/NetworkGraph.tsx +476 -0
- package/src/components/board/SlotSystem.tsx +339 -0
- package/src/components/board/SquareGrid.tsx +1165 -0
- package/src/components/board/TrackBoard.tsx +496 -0
- package/src/components/board/ZoneMap.tsx +448 -0
- package/src/components/board/hex-board-view.test.tsx +114 -0
- package/src/components/board/hex-board-view.ts +123 -0
- package/src/components/board/index.ts +142 -0
- package/src/components/board/interaction-accessibility.ts +21 -0
- package/src/components/board/target-layer-grids.test.tsx +420 -0
- package/src/components/board/target-layer.ts +30 -0
- package/src/components/card-render-content.type-test.ts +27 -0
- package/src/components/index.ts +208 -0
- package/src/components/interaction-dialog-behavior.test.ts +23 -0
- package/src/components/interaction-dialog-behavior.ts +22 -0
- package/src/components/surfaces/BlockerSurface.test.tsx +158 -0
- package/src/components/surfaces/BlockerSurface.tsx +127 -0
- package/src/components/surfaces/BoardSurface.tsx +340 -0
- package/src/components/surfaces/ChromeSurface.tsx +123 -0
- package/src/components/surfaces/ExhaustivenessAudit.tsx +91 -0
- package/src/components/surfaces/InboxSurface.test.tsx +149 -0
- package/src/components/surfaces/InboxSurface.tsx +245 -0
- package/src/components/surfaces/MarketSurface.tsx +544 -0
- package/src/components/surfaces/PanelSurface.test.tsx +496 -0
- package/src/components/surfaces/PanelSurface.tsx +458 -0
- package/src/components/surfaces/PlayerCardsSurface.tsx +525 -0
- package/src/components/surfaces/internal/CardZoneFollowUpForm.tsx +35 -0
- package/src/components/surfaces/internal/DefaultInteractionButton.tsx +219 -0
- package/src/components/surfaces/internal/useCardZoneInteractions.ts +311 -0
- package/src/components/surfaces/types.ts +100 -0
- package/src/context/ClientParamSchemaContext.tsx +44 -0
- package/src/context/InteractionDraftContext.tsx +204 -0
- package/src/context/PluginSessionContext.tsx +47 -0
- package/src/context/PluginStateContext.tsx +254 -0
- package/src/context/RuntimeContext.tsx +96 -0
- package/src/defaults/components.tsx +442 -0
- package/src/defaults/defaults.test.tsx +230 -0
- package/src/defaults/index.ts +1 -0
- package/src/errors/ValidationError.ts +29 -0
- package/src/helpers/cards.ts +19 -0
- package/src/helpers/track-board.ts +211 -0
- package/src/hooks/useActivePlayers.ts +19 -0
- package/src/hooks/useBoardInteractions.test.tsx +622 -0
- package/src/hooks/useBoardInteractions.ts +434 -0
- package/src/hooks/useBoardTopology.ts +316 -0
- package/src/hooks/useCards.test.tsx +129 -0
- package/src/hooks/useCards.ts +10 -0
- package/src/hooks/useGameSelector.ts +105 -0
- package/src/hooks/useGameView.ts +9 -0
- package/src/hooks/useHandLayout.ts +349 -0
- package/src/hooks/useHexBoard.ts +74 -0
- package/src/hooks/useHexGrid.ts +185 -0
- package/src/hooks/useInteractionByKey.ts +349 -0
- package/src/hooks/useInteractionHandle.ts +437 -0
- package/src/hooks/useIsMobile.ts +35 -0
- package/src/hooks/useIsMyTurn.test.tsx +99 -0
- package/src/hooks/useIsMyTurn.ts +15 -0
- package/src/hooks/useLobby.ts +76 -0
- package/src/hooks/useMe.ts +48 -0
- package/src/hooks/usePanZoom.ts +278 -0
- package/src/hooks/usePlayerInfo.ts +28 -0
- package/src/hooks/usePlayerTurnOrder.ts +23 -0
- package/src/hooks/usePluginRuntime.test.tsx +102 -0
- package/src/hooks/usePluginRuntime.ts +130 -0
- package/src/hooks/useSeatInbox.ts +61 -0
- package/src/hooks/useSimultaneousPhase.ts +10 -0
- package/src/hooks/useSquareBoard.ts +124 -0
- package/src/hooks/useSquareGrid.ts +328 -0
- package/src/index.test.ts +474 -0
- package/src/index.ts +148 -0
- package/src/internal/ui/alert.tsx +51 -0
- package/src/internal/ui/button.tsx +58 -0
- package/src/internal/ui/dialog.tsx +134 -0
- package/src/internal/ui/input.tsx +21 -0
- package/src/internal/ui/label.tsx +21 -0
- package/src/internal/ui/select.tsx +129 -0
- package/src/internal/ui/tooltip.tsx +54 -0
- package/src/internal/ui/utils.ts +5 -0
- package/src/internal.ts +18 -0
- package/src/plugin-styles.css +246 -0
- package/src/primitives/board.test.tsx +139 -0
- package/src/primitives/board.tsx +267 -0
- package/src/primitives/game-ui-provider.tsx +35 -0
- package/src/primitives/index.ts +83 -0
- package/src/primitives/interaction.test.tsx +420 -0
- package/src/primitives/interaction.tsx +405 -0
- package/src/primitives/phase.test.tsx +82 -0
- package/src/primitives/phase.tsx +43 -0
- package/src/primitives/player-roster.test.tsx +168 -0
- package/src/primitives/player-roster.tsx +301 -0
- package/src/primitives/primitive-props.tsx +82 -0
- package/src/primitives/prompt.test.tsx +159 -0
- package/src/primitives/prompt.tsx +203 -0
- package/src/primitives/zone.tsx +113 -0
- package/src/reducer.ts +42 -0
- package/src/runtime/createPluginRuntimeAPI.ts +605 -0
- package/src/theme/ThemeProvider.test.tsx +36 -0
- package/src/theme/ThemeProvider.tsx +252 -0
- package/src/theme/board.ts +61 -0
- package/src/theme/css-vars.ts +105 -0
- package/src/theme/derive.ts +240 -0
- package/src/theme/index.ts +61 -0
- package/src/theme/presets/arcade.ts +261 -0
- package/src/theme/presets/studio.ts +261 -0
- package/src/theme/presets/tabletop.ts +266 -0
- package/src/theme/theme.test.ts +258 -0
- package/src/theme/tokens.ts +392 -0
- package/src/types/player-state.ts +445 -0
- package/src/types/plugin-state.ts +407 -0
- package/src/types/reducer-state.ts +24 -0
- package/src/types/runtime-api.ts +114 -0
- package/src/types/tiled-board.ts +785 -0
- package/src/ui-contract.ts +168 -0
- package/src/utils/interaction-inputs.test.ts +109 -0
- package/src/utils/interaction-inputs.ts +331 -0
- package/src/utils/interaction-labels.ts +23 -0
- package/src/utils/interaction-status.ts +59 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, } from "react";
|
|
3
|
+
import { useBoardInteractions } from "../hooks/useBoardInteractions.js";
|
|
4
|
+
import { useInteractionHandle } from "../hooks/useInteractionHandle.js";
|
|
5
|
+
import { usePluginState } from "../context/PluginStateContext.js";
|
|
6
|
+
import { inputByKey, inputKeyForTarget, interactionInputKeys, } from "../utils/interaction-inputs.js";
|
|
7
|
+
import { composeEventHandlers, renderPrimitive, } from "./primitive-props.js";
|
|
8
|
+
const BoardContext = createContext(null);
|
|
9
|
+
export function useBoardPrimitiveContext() {
|
|
10
|
+
const value = useContext(BoardContext);
|
|
11
|
+
if (!value) {
|
|
12
|
+
throw new Error("Board primitives must be rendered inside <Board.Root>.");
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
export function BoardRoot({ children, targetKinds, ...props }) {
|
|
17
|
+
const board = useBoardInteractions({ targetKinds });
|
|
18
|
+
return (_jsx(BoardContext.Provider, { value: board, children: renderPrimitive("div", {
|
|
19
|
+
...props,
|
|
20
|
+
"data-dreamboard-board-root": "",
|
|
21
|
+
children,
|
|
22
|
+
}) }));
|
|
23
|
+
}
|
|
24
|
+
export function BoardTarget({ interaction, input, ...props }) {
|
|
25
|
+
const descriptor = usePluginState((state) => interaction
|
|
26
|
+
? state.gameplay.availableInteractions.find((candidate) => candidate.interactionKey === interaction ||
|
|
27
|
+
candidate.interactionId === interaction)
|
|
28
|
+
: undefined);
|
|
29
|
+
if (interaction) {
|
|
30
|
+
return descriptor ? (_jsx(ExplicitBoardTarget, { descriptor: descriptor, input: input, ...props })) : (_jsx(UnavailableBoardTarget, { interaction: interaction, input: input, ...props }));
|
|
31
|
+
}
|
|
32
|
+
return _jsx(UnambiguousBoardTarget, { input: input, ...props });
|
|
33
|
+
}
|
|
34
|
+
function UnambiguousBoardTarget({ kind, value, extraInputs, onSelect, onSelectError, disabled, onClick, children, ...props }) {
|
|
35
|
+
const board = useBoardPrimitiveContext();
|
|
36
|
+
const eligible = board.isEligible(value, kind);
|
|
37
|
+
const ambiguous = isAmbiguousBoardTarget(board.interactions, kind, value);
|
|
38
|
+
const isDisabled = disabled ?? (!eligible || ambiguous);
|
|
39
|
+
return renderPrimitive("button", {
|
|
40
|
+
type: "button",
|
|
41
|
+
...props,
|
|
42
|
+
children,
|
|
43
|
+
disabled: isDisabled,
|
|
44
|
+
"aria-disabled": isDisabled,
|
|
45
|
+
"data-dreamboard-board-target": "",
|
|
46
|
+
"data-target-kind": kind,
|
|
47
|
+
"data-target-id": value,
|
|
48
|
+
"data-eligible": eligible,
|
|
49
|
+
"data-ambiguous": ambiguous || undefined,
|
|
50
|
+
"data-disabled": isDisabled || undefined,
|
|
51
|
+
onClick: composeEventHandlers(onClick, () => {
|
|
52
|
+
if (isDisabled)
|
|
53
|
+
return;
|
|
54
|
+
void board.select[kind](value, resolveExtraInputs(extraInputs, value))
|
|
55
|
+
.then((interactionKey) => {
|
|
56
|
+
onSelect?.(interactionKey);
|
|
57
|
+
})
|
|
58
|
+
.catch((error) => {
|
|
59
|
+
onSelectError?.(error);
|
|
60
|
+
if (!onSelectError)
|
|
61
|
+
throw error;
|
|
62
|
+
});
|
|
63
|
+
}),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function ExplicitBoardTarget({ descriptor, kind, value, input, extraInputs, onSelect, onSelectError, disabled, onClick, children, ...props }) {
|
|
67
|
+
const handle = useInteractionHandle(descriptor);
|
|
68
|
+
const inputKey = input ?? inputKeyForTarget(descriptor, kind, value);
|
|
69
|
+
const inputDescriptor = inputKey
|
|
70
|
+
? inputByKey(descriptor, inputKey)
|
|
71
|
+
: undefined;
|
|
72
|
+
const eligible = inputDescriptor !== undefined &&
|
|
73
|
+
inputDescriptor.domain.type === "target" &&
|
|
74
|
+
inputDescriptor.domain.targetKind === kind &&
|
|
75
|
+
(inputDescriptor.domain.eligibleTargets === undefined ||
|
|
76
|
+
inputDescriptor.domain.eligibleTargets.includes(value));
|
|
77
|
+
const isDisabled = disabled ?? (!descriptor.available || !eligible);
|
|
78
|
+
return renderPrimitive("button", {
|
|
79
|
+
type: "button",
|
|
80
|
+
...props,
|
|
81
|
+
children,
|
|
82
|
+
disabled: isDisabled,
|
|
83
|
+
"aria-disabled": isDisabled,
|
|
84
|
+
"data-dreamboard-board-target": "",
|
|
85
|
+
"data-target-kind": kind,
|
|
86
|
+
"data-target-id": value,
|
|
87
|
+
"data-interaction-id": descriptor.interactionId,
|
|
88
|
+
"data-interaction-key": descriptor.interactionKey,
|
|
89
|
+
"data-input-name": inputKey ?? undefined,
|
|
90
|
+
"data-eligible": eligible,
|
|
91
|
+
"data-disabled": isDisabled || undefined,
|
|
92
|
+
onClick: composeEventHandlers(onClick, () => {
|
|
93
|
+
if (isDisabled || !inputKey)
|
|
94
|
+
return;
|
|
95
|
+
const resolvedExtraInputs = resolveExtraInputs(extraInputs, value);
|
|
96
|
+
for (const [key, extraValue] of Object.entries(resolvedExtraInputs)) {
|
|
97
|
+
handle.setInput(key, extraValue);
|
|
98
|
+
}
|
|
99
|
+
handle.setInput(inputKey, value);
|
|
100
|
+
if (descriptor.commit.mode !== "autoWhenReady") {
|
|
101
|
+
handle.arm();
|
|
102
|
+
onSelect?.(descriptor.interactionKey);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const params = {
|
|
106
|
+
...handle.draft,
|
|
107
|
+
...resolvedExtraInputs,
|
|
108
|
+
[inputKey]: value,
|
|
109
|
+
};
|
|
110
|
+
for (const required of interactionInputKeys(descriptor)) {
|
|
111
|
+
if (!(required in params))
|
|
112
|
+
params[required] = null;
|
|
113
|
+
}
|
|
114
|
+
void handle
|
|
115
|
+
.submit(params)
|
|
116
|
+
.then(() => {
|
|
117
|
+
onSelect?.(descriptor.interactionKey);
|
|
118
|
+
})
|
|
119
|
+
.catch((error) => {
|
|
120
|
+
onSelectError?.(error);
|
|
121
|
+
if (!onSelectError)
|
|
122
|
+
throw error;
|
|
123
|
+
});
|
|
124
|
+
}),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function UnavailableBoardTarget({ kind, value, interaction, input, disabled, children, ...props }) {
|
|
128
|
+
const isDisabled = disabled ?? true;
|
|
129
|
+
return renderPrimitive("button", {
|
|
130
|
+
type: "button",
|
|
131
|
+
...props,
|
|
132
|
+
children,
|
|
133
|
+
disabled: isDisabled,
|
|
134
|
+
"aria-disabled": isDisabled,
|
|
135
|
+
"data-dreamboard-board-target": "",
|
|
136
|
+
"data-target-kind": kind,
|
|
137
|
+
"data-target-id": value,
|
|
138
|
+
"data-interaction-key": interaction,
|
|
139
|
+
"data-input-name": input,
|
|
140
|
+
"data-eligible": false,
|
|
141
|
+
"data-disabled": isDisabled || undefined,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function resolveExtraInputs(extraInputs, targetId) {
|
|
145
|
+
return typeof extraInputs === "function"
|
|
146
|
+
? extraInputs(targetId)
|
|
147
|
+
: (extraInputs ?? {});
|
|
148
|
+
}
|
|
149
|
+
function isAmbiguousBoardTarget(descriptors, kind, value) {
|
|
150
|
+
const matches = descriptors.flatMap((descriptor) => {
|
|
151
|
+
if (!descriptor.available)
|
|
152
|
+
return [];
|
|
153
|
+
const inputKey = inputKeyForTarget(descriptor, kind, value);
|
|
154
|
+
if (!inputKey)
|
|
155
|
+
return [];
|
|
156
|
+
return [descriptor.interactionKey];
|
|
157
|
+
});
|
|
158
|
+
return matches.length > 1;
|
|
159
|
+
}
|
|
160
|
+
export const Board = {
|
|
161
|
+
Root: BoardRoot,
|
|
162
|
+
Target: BoardTarget,
|
|
163
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type PluginStateProviderProps } from "../context/PluginStateContext.js";
|
|
3
|
+
import { type InteractionUiStoreApi } from "../context/InteractionDraftContext.js";
|
|
4
|
+
import type { RuntimeAPI } from "../types/runtime-api.js";
|
|
5
|
+
export interface GameUIProviderProps {
|
|
6
|
+
runtime: RuntimeAPI;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
loadingComponent?: PluginStateProviderProps["loadingComponent"];
|
|
9
|
+
interactionStore?: InteractionUiStoreApi;
|
|
10
|
+
}
|
|
11
|
+
export declare function GameUIProvider({ runtime, children, loadingComponent, interactionStore, }: GameUIProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=game-ui-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"game-ui-provider.d.ts","sourceRoot":"","sources":["../../src/primitives/game-ui-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,UAAU,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB,gBAAgB,CAAC,EAAE,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;IAChE,gBAAgB,CAAC,EAAE,qBAAqB,CAAC;CAC1C;AAED,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,GACjB,EAAE,mBAAmB,2CAUrB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PluginStateProvider, } from "../context/PluginStateContext.js";
|
|
3
|
+
import { RuntimeProvider } from "../context/RuntimeContext.js";
|
|
4
|
+
import { InteractionUiProvider, } from "../context/InteractionDraftContext.js";
|
|
5
|
+
export function GameUIProvider({ runtime, children, loadingComponent, interactionStore, }) {
|
|
6
|
+
return (_jsx(RuntimeProvider, { runtime: runtime, children: _jsx(PluginStateProvider, { loadingComponent: loadingComponent, children: _jsx(InteractionUiProvider, { store: interactionStore, children: children }) }) }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Board, BoardRoot, BoardTarget, useBoardPrimitiveContext, type BoardRootProps, type BoardTargetExtraInputs, type BoardTargetProps, } from "./board.js";
|
|
2
|
+
export { Interaction, InteractionCardInput, InteractionDescription, InteractionInput, InteractionLabel, InteractionRoot, InteractionSubmit, InteractionTrigger, InteractionUnavailableMessage, InteractionValidationMessage, useInteractionPrimitiveContext, type InteractionCardInputProps, type InteractionInputProps, type InteractionPartProps, type InteractionRootProps, type InteractionSubmitProps, type InteractionTriggerProps, } from "./interaction.js";
|
|
3
|
+
export { Phase, PhaseSwitch, type PhaseFallback, type PhaseRouteMap, type PhaseSwitchProps, } from "./phase.js";
|
|
4
|
+
export { PlayerRoster, PlayerRosterBadges, PlayerRosterEmpty, PlayerRosterList, PlayerRosterName, PlayerRosterRoot, PlayerRosterScore, PlayerRosterSwitchButton, type PlayerRosterBadge, type PlayerRosterComponents, type PlayerRosterEntry, type PlayerRosterListProps, type PlayerRosterPartProps, type PlayerRosterRootProps, type PlayerRosterSwitchButtonProps, } from "./player-roster.js";
|
|
5
|
+
export { Prompt, PromptInbox, PromptInboxEmpty, PromptInboxItems, PromptInboxRoot, PromptMessage, PromptOption, PromptOptions, PromptRoot, PromptTitle, type PromptOptionProps, type PromptRootProps, } from "./prompt.js";
|
|
6
|
+
export { composeEventHandlers, renderPrimitive, type PrimitiveCommonProps, type PrimitiveDataAttributes, } from "./primitive-props.js";
|
|
7
|
+
export { Zone, ZoneItem, ZoneList, ZoneRoot, useZoneCardContext, useZonePrimitiveContext, type ZoneItemProps, type ZoneListProps, type ZoneRootProps, } from "./zone.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,SAAS,EACT,WAAW,EACX,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,6BAA6B,EAC7B,4BAA4B,EAC5B,8BAA8B,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,6BAA6B,GACnC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,WAAW,EACX,KAAK,iBAAiB,EACtB,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,GAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Board, BoardRoot, BoardTarget, useBoardPrimitiveContext, } from "./board.js";
|
|
2
|
+
export { Interaction, InteractionCardInput, InteractionDescription, InteractionInput, InteractionLabel, InteractionRoot, InteractionSubmit, InteractionTrigger, InteractionUnavailableMessage, InteractionValidationMessage, useInteractionPrimitiveContext, } from "./interaction.js";
|
|
3
|
+
export { Phase, PhaseSwitch, } from "./phase.js";
|
|
4
|
+
export { PlayerRoster, PlayerRosterBadges, PlayerRosterEmpty, PlayerRosterList, PlayerRosterName, PlayerRosterRoot, PlayerRosterScore, PlayerRosterSwitchButton, } from "./player-roster.js";
|
|
5
|
+
export { Prompt, PromptInbox, PromptInboxEmpty, PromptInboxItems, PromptInboxRoot, PromptMessage, PromptOption, PromptOptions, PromptRoot, PromptTitle, } from "./prompt.js";
|
|
6
|
+
export { composeEventHandlers, renderPrimitive, } from "./primitive-props.js";
|
|
7
|
+
export { Zone, ZoneItem, ZoneList, ZoneRoot, useZoneCardContext, useZonePrimitiveContext, } from "./zone.js";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type HTMLAttributes, type InputHTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import { useInteractionHandle } from "../hooks/useInteractionHandle.js";
|
|
3
|
+
import type { InteractionInputKey, InteractionKey } from "../ui-contract.js";
|
|
4
|
+
import type { InteractionDescriptor } from "../types/plugin-state.js";
|
|
5
|
+
import { type PrimitiveCommonProps } from "./primitive-props.js";
|
|
6
|
+
interface InteractionContextValue {
|
|
7
|
+
interaction: string;
|
|
8
|
+
descriptor: InteractionDescriptor | null;
|
|
9
|
+
handle: ReturnType<typeof useInteractionHandle> | null;
|
|
10
|
+
}
|
|
11
|
+
export declare function useInteractionPrimitiveContext(): InteractionContextValue;
|
|
12
|
+
export interface InteractionRootProps<Interaction extends string = InteractionKey> {
|
|
13
|
+
interaction: Interaction;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
unavailable?: "render" | "hide";
|
|
16
|
+
}
|
|
17
|
+
export declare function InteractionRoot<Interaction extends string = InteractionKey>({ interaction, children, unavailable, }: InteractionRootProps<Interaction>): import("react/jsx-runtime").JSX.Element | null;
|
|
18
|
+
export type InteractionPartProps = PrimitiveCommonProps & HTMLAttributes<HTMLElement>;
|
|
19
|
+
export declare function InteractionLabel({ children, ...props }: InteractionPartProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
20
|
+
export declare function InteractionDescription({ children, ...props }: InteractionPartProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
21
|
+
export declare function InteractionUnavailableMessage({ children, ...props }: InteractionPartProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
22
|
+
export declare function InteractionValidationMessage({ children, ...props }: InteractionPartProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
23
|
+
export type InteractionTriggerProps = PrimitiveCommonProps & ButtonHTMLAttributes<HTMLButtonElement>;
|
|
24
|
+
export declare function InteractionTrigger({ disabled, onClick, ...props }: InteractionTriggerProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
25
|
+
export type InteractionSubmitProps = PrimitiveCommonProps & ButtonHTMLAttributes<HTMLButtonElement>;
|
|
26
|
+
export declare function InteractionSubmit({ disabled, onClick, ...props }: InteractionSubmitProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
27
|
+
export type InteractionInputProps = PrimitiveCommonProps & Omit<InputHTMLAttributes<HTMLInputElement>, "name"> & {
|
|
28
|
+
name: string;
|
|
29
|
+
parse?: (value: string) => unknown;
|
|
30
|
+
};
|
|
31
|
+
export declare function InteractionInput({ name, parse, onChange, disabled, ...props }: InteractionInputProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
32
|
+
export type InteractionCardInputProps<Input extends string = InteractionInputKey> = PrimitiveCommonProps & ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
33
|
+
input: Input;
|
|
34
|
+
value?: string;
|
|
35
|
+
card?: string;
|
|
36
|
+
selected?: boolean;
|
|
37
|
+
onSelectedChange?: (selected: boolean) => void;
|
|
38
|
+
};
|
|
39
|
+
export declare function InteractionCardInput<Input extends string = InteractionInputKey>({ input, value, card, selected, onSelectedChange, onClick, disabled, children, ...props }: InteractionCardInputProps<Input>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
40
|
+
export declare const Interaction: {
|
|
41
|
+
Root: typeof InteractionRoot;
|
|
42
|
+
Trigger: typeof InteractionTrigger;
|
|
43
|
+
Label: typeof InteractionLabel;
|
|
44
|
+
Description: typeof InteractionDescription;
|
|
45
|
+
UnavailableMessage: typeof InteractionUnavailableMessage;
|
|
46
|
+
ValidationMessage: typeof InteractionValidationMessage;
|
|
47
|
+
Input: typeof InteractionInput;
|
|
48
|
+
CardInput: typeof InteractionCardInput;
|
|
49
|
+
Submit: typeof InteractionSubmit;
|
|
50
|
+
};
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=interaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction.d.ts","sourceRoot":"","sources":["../../src/primitives/interaction.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo, } from "react";
|
|
3
|
+
import { useInteractionHandle } from "../hooks/useInteractionHandle.js";
|
|
4
|
+
import { useInteractionUiStore } from "../context/InteractionDraftContext.js";
|
|
5
|
+
import { usePluginState } from "../context/PluginStateContext.js";
|
|
6
|
+
import { inputByKey, isManyTargetSelectable, toggleManyValue, } from "../utils/interaction-inputs.js";
|
|
7
|
+
import { interactionLabel } from "../utils/interaction-labels.js";
|
|
8
|
+
import { composeEventHandlers, renderPrimitive, } from "./primitive-props.js";
|
|
9
|
+
import { useZoneCardContext } from "./zone.js";
|
|
10
|
+
const InteractionContext = createContext(null);
|
|
11
|
+
function humanizeInteraction(value) {
|
|
12
|
+
const parts = value.split(".");
|
|
13
|
+
const leaf = parts[parts.length - 1] ?? value;
|
|
14
|
+
return leaf
|
|
15
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
16
|
+
.replace(/[-_]+/g, " ")
|
|
17
|
+
.replace(/\s+/g, " ")
|
|
18
|
+
.trim()
|
|
19
|
+
.replace(/^./, (first) => first.toUpperCase());
|
|
20
|
+
}
|
|
21
|
+
export function useInteractionPrimitiveContext() {
|
|
22
|
+
const value = useContext(InteractionContext);
|
|
23
|
+
if (!value) {
|
|
24
|
+
throw new Error("Interaction primitives must be rendered inside <Interaction.Root>.");
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
function useInteractionDescriptor(interaction) {
|
|
29
|
+
return usePluginState((state) => state.gameplay.availableInteractions.find((descriptor) => descriptor.interactionKey === interaction ||
|
|
30
|
+
descriptor.interactionId === interaction));
|
|
31
|
+
}
|
|
32
|
+
function ResolvedInteractionRoot({ interaction, descriptor, children, }) {
|
|
33
|
+
const handle = useInteractionHandle(descriptor);
|
|
34
|
+
const value = useMemo(() => ({ interaction, descriptor, handle }), [descriptor, handle, interaction]);
|
|
35
|
+
return (_jsx(InteractionContext.Provider, { value: value, children: children }));
|
|
36
|
+
}
|
|
37
|
+
export function InteractionRoot({ interaction, children, unavailable = "render", }) {
|
|
38
|
+
const descriptor = useInteractionDescriptor(interaction);
|
|
39
|
+
if (!descriptor) {
|
|
40
|
+
if (unavailable === "hide")
|
|
41
|
+
return null;
|
|
42
|
+
return (_jsx(InteractionContext.Provider, { value: {
|
|
43
|
+
interaction,
|
|
44
|
+
descriptor: null,
|
|
45
|
+
handle: null,
|
|
46
|
+
}, children: children }));
|
|
47
|
+
}
|
|
48
|
+
if (!descriptor.available && unavailable === "hide") {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return (_jsx(ResolvedInteractionRoot, { interaction: interaction, descriptor: descriptor, children: children }));
|
|
52
|
+
}
|
|
53
|
+
export function InteractionLabel({ children, ...props }) {
|
|
54
|
+
const { descriptor, interaction } = useInteractionPrimitiveContext();
|
|
55
|
+
return renderPrimitive("span", {
|
|
56
|
+
...props,
|
|
57
|
+
"data-dreamboard-interaction-label": "",
|
|
58
|
+
children: children ??
|
|
59
|
+
(descriptor
|
|
60
|
+
? interactionLabel(descriptor)
|
|
61
|
+
: humanizeInteraction(interaction)),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export function InteractionDescription({ children, ...props }) {
|
|
65
|
+
const content = children;
|
|
66
|
+
if (!content)
|
|
67
|
+
return null;
|
|
68
|
+
return renderPrimitive("span", {
|
|
69
|
+
...props,
|
|
70
|
+
"data-dreamboard-interaction-description": "",
|
|
71
|
+
children: content,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export function InteractionUnavailableMessage({ children, ...props }) {
|
|
75
|
+
const { descriptor, handle } = useInteractionPrimitiveContext();
|
|
76
|
+
const reason = children ?? handle?.unavailableReason ?? descriptor?.unavailableReason;
|
|
77
|
+
if (!reason)
|
|
78
|
+
return null;
|
|
79
|
+
return renderPrimitive("span", {
|
|
80
|
+
...props,
|
|
81
|
+
"data-dreamboard-interaction-unavailable": "",
|
|
82
|
+
children: reason,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
export function InteractionValidationMessage({ children, ...props }) {
|
|
86
|
+
const { handle } = useInteractionPrimitiveContext();
|
|
87
|
+
const validation = handle?.validateDraft();
|
|
88
|
+
const message = children ??
|
|
89
|
+
validation?.formErrors[0] ??
|
|
90
|
+
Object.values(validation?.fieldErrors ?? {})[0]?.[0] ??
|
|
91
|
+
(validation?.missing[0]
|
|
92
|
+
? `${String(validation.missing[0])} is required.`
|
|
93
|
+
: null);
|
|
94
|
+
if (!message)
|
|
95
|
+
return null;
|
|
96
|
+
return renderPrimitive("span", {
|
|
97
|
+
...props,
|
|
98
|
+
"data-dreamboard-interaction-validation": "",
|
|
99
|
+
children: message,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
export function InteractionTrigger({ disabled, onClick, ...props }) {
|
|
103
|
+
const { descriptor, handle } = useInteractionPrimitiveContext();
|
|
104
|
+
const isDisabled = disabled === true || !descriptor?.available;
|
|
105
|
+
return renderPrimitive("button", {
|
|
106
|
+
type: "button",
|
|
107
|
+
...props,
|
|
108
|
+
disabled: isDisabled,
|
|
109
|
+
"aria-disabled": isDisabled,
|
|
110
|
+
"data-dreamboard-interaction-trigger": "",
|
|
111
|
+
"data-interaction-id": descriptor?.interactionId,
|
|
112
|
+
"data-interaction-key": descriptor?.interactionKey,
|
|
113
|
+
"data-available": descriptor?.available ?? false,
|
|
114
|
+
"data-disabled": isDisabled || undefined,
|
|
115
|
+
"data-state": handle?.isArmed ? "armed" : "idle",
|
|
116
|
+
onClick: composeEventHandlers(onClick, () => {
|
|
117
|
+
handle?.arm();
|
|
118
|
+
}),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
export function InteractionSubmit({ disabled, onClick, ...props }) {
|
|
122
|
+
const { descriptor, handle } = useInteractionPrimitiveContext();
|
|
123
|
+
const isSubmitting = handle?.status === "submitting";
|
|
124
|
+
const isDisabled = disabled === true ||
|
|
125
|
+
!descriptor?.available ||
|
|
126
|
+
!handle?.isReady ||
|
|
127
|
+
isSubmitting;
|
|
128
|
+
return renderPrimitive("button", {
|
|
129
|
+
type: "button",
|
|
130
|
+
...props,
|
|
131
|
+
disabled: isDisabled,
|
|
132
|
+
"aria-disabled": isDisabled,
|
|
133
|
+
"data-dreamboard-interaction-submit": "",
|
|
134
|
+
"data-interaction-id": descriptor?.interactionId,
|
|
135
|
+
"data-interaction-key": descriptor?.interactionKey,
|
|
136
|
+
"data-available": descriptor?.available ?? false,
|
|
137
|
+
"data-disabled": isDisabled || undefined,
|
|
138
|
+
"data-ready": handle?.isReady ?? false,
|
|
139
|
+
"data-submitting": isSubmitting || undefined,
|
|
140
|
+
"data-state": handle?.status ?? "unavailable",
|
|
141
|
+
onClick: composeEventHandlers(onClick, () => {
|
|
142
|
+
void handle?.submitDraft();
|
|
143
|
+
}),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
export function InteractionInput({ name, parse, onChange, disabled, ...props }) {
|
|
147
|
+
const { descriptor, handle } = useInteractionPrimitiveContext();
|
|
148
|
+
const value = handle?.draft[name];
|
|
149
|
+
const isDisabled = disabled === true || !descriptor?.available;
|
|
150
|
+
return renderPrimitive("input", {
|
|
151
|
+
...props,
|
|
152
|
+
name,
|
|
153
|
+
disabled: isDisabled,
|
|
154
|
+
"aria-disabled": isDisabled,
|
|
155
|
+
"data-dreamboard-interaction-input": "",
|
|
156
|
+
"data-input-name": name,
|
|
157
|
+
"data-disabled": isDisabled || undefined,
|
|
158
|
+
"data-selected": value !== undefined || undefined,
|
|
159
|
+
onChange: composeEventHandlers(onChange, (event) => {
|
|
160
|
+
const target = event.currentTarget;
|
|
161
|
+
handle?.setInput(name, parse ? parse(target.value) : target.value);
|
|
162
|
+
}),
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
export function InteractionCardInput({ input, value, card, selected, onSelectedChange, onClick, disabled, children, ...props }) {
|
|
166
|
+
const { descriptor, handle } = useInteractionPrimitiveContext();
|
|
167
|
+
const store = useInteractionUiStore();
|
|
168
|
+
const zoneCard = useZoneCardContext();
|
|
169
|
+
const cardId = value ?? card ?? zoneCard?.cardId;
|
|
170
|
+
const cardDescriptor = usePluginState((state) => {
|
|
171
|
+
if (!cardId || !zoneCard)
|
|
172
|
+
return undefined;
|
|
173
|
+
return state.gameplay.zones[zoneCard.zone]?.playableByCardId[cardId]?.find((candidate) => candidate.interactionKey === descriptor?.interactionKey &&
|
|
174
|
+
candidate.inputs.some((candidateInput) => candidateInput.key === input));
|
|
175
|
+
});
|
|
176
|
+
const inputDescriptor = descriptor
|
|
177
|
+
? inputByKey(descriptor, input)
|
|
178
|
+
: undefined;
|
|
179
|
+
const liveDraft = descriptor ? store.getDraft(descriptor.interactionKey) : {};
|
|
180
|
+
const currentValue = liveDraft[input] ?? handle?.draft[input] ?? handle?.values[input];
|
|
181
|
+
const selection = inputDescriptor?.domain.selection;
|
|
182
|
+
const selectedByDraft = selection?.mode === "many"
|
|
183
|
+
? Array.isArray(currentValue) &&
|
|
184
|
+
currentValue.map((item) => String(item)).includes(String(cardId))
|
|
185
|
+
: currentValue !== undefined &&
|
|
186
|
+
cardId !== undefined &&
|
|
187
|
+
String(currentValue) === String(cardId);
|
|
188
|
+
const isSelected = selected ?? selectedByDraft;
|
|
189
|
+
const eligibleTargets = inputDescriptor?.domain.type === "target"
|
|
190
|
+
? inputDescriptor.domain.eligibleTargets
|
|
191
|
+
: undefined;
|
|
192
|
+
const isCardInput = inputDescriptor?.domain.type === "target" &&
|
|
193
|
+
inputDescriptor.domain.targetKind === "card";
|
|
194
|
+
const isEligible = cardId !== undefined &&
|
|
195
|
+
isCardInput &&
|
|
196
|
+
(eligibleTargets === undefined || eligibleTargets.includes(cardId));
|
|
197
|
+
const isSelectable = cardId !== undefined &&
|
|
198
|
+
inputDescriptor !== undefined &&
|
|
199
|
+
isManyTargetSelectable(inputDescriptor, currentValue, cardId);
|
|
200
|
+
const isCandidateAvailable = cardDescriptor?.available ?? true;
|
|
201
|
+
const validation = handle?.validateDraft();
|
|
202
|
+
const fieldErrors = validation?.fieldErrors[input] ?? [];
|
|
203
|
+
const isInvalid = fieldErrors.length > 0;
|
|
204
|
+
const isDisabled = disabled === true ||
|
|
205
|
+
!descriptor?.available ||
|
|
206
|
+
!cardId ||
|
|
207
|
+
!isEligible ||
|
|
208
|
+
!handle;
|
|
209
|
+
return renderPrimitive("button", {
|
|
210
|
+
type: "button",
|
|
211
|
+
...props,
|
|
212
|
+
children,
|
|
213
|
+
disabled: isDisabled,
|
|
214
|
+
"aria-disabled": isDisabled,
|
|
215
|
+
"aria-pressed": isSelected,
|
|
216
|
+
"data-dreamboard-interaction-card-input": "",
|
|
217
|
+
"data-input-name": input,
|
|
218
|
+
"data-card-id": cardId,
|
|
219
|
+
"data-zone": zoneCard?.zone,
|
|
220
|
+
"data-selected": isSelected || undefined,
|
|
221
|
+
"data-eligible": isEligible,
|
|
222
|
+
"data-selectable": isSelectable,
|
|
223
|
+
"data-card-available": isCandidateAvailable,
|
|
224
|
+
"data-invalid": isInvalid || undefined,
|
|
225
|
+
"data-disabled": isDisabled || undefined,
|
|
226
|
+
"data-missing-resource": cardId ? undefined : true,
|
|
227
|
+
onClick: composeEventHandlers(onClick, () => {
|
|
228
|
+
if (isDisabled || !cardId || !handle || !inputDescriptor)
|
|
229
|
+
return;
|
|
230
|
+
const nextValue = selection?.mode === "many"
|
|
231
|
+
? toggleManyValue(currentValue, cardId, selection)
|
|
232
|
+
: cardId;
|
|
233
|
+
handle.setInput(input, nextValue);
|
|
234
|
+
onSelectedChange?.(selection?.mode === "many"
|
|
235
|
+
? Array.isArray(nextValue) && nextValue.includes(cardId)
|
|
236
|
+
: true);
|
|
237
|
+
}),
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
export const Interaction = {
|
|
241
|
+
Root: InteractionRoot,
|
|
242
|
+
Trigger: InteractionTrigger,
|
|
243
|
+
Label: InteractionLabel,
|
|
244
|
+
Description: InteractionDescription,
|
|
245
|
+
UnavailableMessage: InteractionUnavailableMessage,
|
|
246
|
+
ValidationMessage: InteractionValidationMessage,
|
|
247
|
+
Input: InteractionInput,
|
|
248
|
+
CardInput: InteractionCardInput,
|
|
249
|
+
Submit: InteractionSubmit,
|
|
250
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
import type { PhaseKey } from "../ui-contract.js";
|
|
3
|
+
export type PhaseRouteMap<Phase extends string = PhaseKey> = {
|
|
4
|
+
readonly [Key in Phase]: () => ReactNode;
|
|
5
|
+
};
|
|
6
|
+
export type PhaseFallback = ReactNode | ((phase: string | null) => ReactNode);
|
|
7
|
+
export interface PhaseSwitchProps<Phase extends string = PhaseKey> {
|
|
8
|
+
routes: PhaseRouteMap<Phase>;
|
|
9
|
+
fallback?: PhaseFallback;
|
|
10
|
+
}
|
|
11
|
+
export declare function PhaseSwitch<Phase extends string = PhaseKey>({ routes, fallback, }: PhaseSwitchProps<Phase>): ReactElement | null;
|
|
12
|
+
export declare const Phase: {
|
|
13
|
+
Switch: typeof PhaseSwitch;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=phase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phase.d.ts","sourceRoot":"","sources":["../../src/primitives/phase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,MAAM,GAAG,QAAQ,IAAI;IAC3D,QAAQ,EAAE,GAAG,IAAI,KAAK,GAAG,MAAM,SAAS;CACzC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC;AAE9E,MAAM,WAAW,gBAAgB,CAAC,KAAK,SAAS,MAAM,GAAG,QAAQ;IAC/D,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IAC7B,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAgBD,wBAAgB,WAAW,CAAC,KAAK,SAAS,MAAM,GAAG,QAAQ,EAAE,EAC3D,MAAM,EACN,QAAQ,GACT,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,YAAY,GAAG,IAAI,CAM/C;AAED,eAAO,MAAM,KAAK;;CAEjB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { usePluginState } from "../context/PluginStateContext.js";
|
|
3
|
+
function hasRoute(routes, phase) {
|
|
4
|
+
return Object.prototype.hasOwnProperty.call(routes, phase);
|
|
5
|
+
}
|
|
6
|
+
function renderFallback(fallback, phase) {
|
|
7
|
+
return typeof fallback === "function" ? fallback(phase) : (fallback ?? null);
|
|
8
|
+
}
|
|
9
|
+
export function PhaseSwitch({ routes, fallback, }) {
|
|
10
|
+
const phase = usePluginState((state) => state.gameplay.currentPhase);
|
|
11
|
+
if (phase && hasRoute(routes, phase)) {
|
|
12
|
+
return _jsx(_Fragment, { children: routes[phase]() });
|
|
13
|
+
}
|
|
14
|
+
return _jsx(_Fragment, { children: renderFallback(fallback, phase) });
|
|
15
|
+
}
|
|
16
|
+
export const Phase = {
|
|
17
|
+
Switch: PhaseSwitch,
|
|
18
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type HTMLAttributes, type ReactElement, type ReactNode } from "react";
|
|
2
|
+
import type { PlayerId } from "@dreamboard/manifest-contract";
|
|
3
|
+
import { type PrimitiveCommonProps } from "./primitive-props.js";
|
|
4
|
+
export interface PlayerRosterBadge {
|
|
5
|
+
key: string;
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
tooltip?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface PlayerRosterEntry {
|
|
11
|
+
playerId: PlayerId;
|
|
12
|
+
name: string;
|
|
13
|
+
color?: string;
|
|
14
|
+
index: number;
|
|
15
|
+
isActive: boolean;
|
|
16
|
+
isCurrentPlayer: boolean;
|
|
17
|
+
isControllable: boolean;
|
|
18
|
+
canSwitchToPlayer: boolean;
|
|
19
|
+
score?: number;
|
|
20
|
+
scoreLabel?: string;
|
|
21
|
+
badges: readonly PlayerRosterBadge[];
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
export interface PlayerRosterRootProps {
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
order?: "turn" | "self-first";
|
|
27
|
+
include?: "all" | "self" | "opponents";
|
|
28
|
+
score?: (playerId: PlayerId) => number | undefined;
|
|
29
|
+
scoreLabel?: string | ((playerId: PlayerId) => string | undefined);
|
|
30
|
+
badges?: (playerId: PlayerId) => ReadonlyArray<PlayerRosterBadge | null | false | undefined>;
|
|
31
|
+
metadata?: (playerId: PlayerId) => Record<string, unknown> | undefined;
|
|
32
|
+
}
|
|
33
|
+
export declare function PlayerRosterRoot({ children, order, include, score, scoreLabel, badges, metadata, }: PlayerRosterRootProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export type PlayerRosterListProps = Omit<PrimitiveCommonProps, "children"> & Omit<HTMLAttributes<HTMLElement>, "children"> & {
|
|
35
|
+
children?: (player: PlayerRosterEntry) => ReactNode;
|
|
36
|
+
};
|
|
37
|
+
export declare function PlayerRosterList({ children, ...props }: PlayerRosterListProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
38
|
+
export declare function PlayerRosterEmpty({ children }: {
|
|
39
|
+
children?: ReactNode;
|
|
40
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
41
|
+
export type PlayerRosterSwitchButtonProps = Omit<PrimitiveCommonProps, "children"> & ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
42
|
+
player: PlayerRosterEntry;
|
|
43
|
+
children?: ReactNode;
|
|
44
|
+
};
|
|
45
|
+
export declare function PlayerRosterSwitchButton({ player, disabled, onClick, ...props }: PlayerRosterSwitchButtonProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
46
|
+
export type PlayerRosterPartProps = PrimitiveCommonProps & HTMLAttributes<HTMLElement> & {
|
|
47
|
+
player: PlayerRosterEntry;
|
|
48
|
+
};
|
|
49
|
+
export interface PlayerRosterComponents {
|
|
50
|
+
Root(props: PlayerRosterRootProps): ReactElement | null;
|
|
51
|
+
List(props: PlayerRosterListProps): ReactElement;
|
|
52
|
+
Empty(props: {
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
}): ReactElement | null;
|
|
55
|
+
SwitchButton(props: PlayerRosterSwitchButtonProps): ReactElement;
|
|
56
|
+
Name(props: PlayerRosterPartProps): ReactElement;
|
|
57
|
+
Score(props: PlayerRosterPartProps): ReactElement | null;
|
|
58
|
+
Badges(props: PlayerRosterPartProps): ReactElement | null;
|
|
59
|
+
}
|
|
60
|
+
export declare function PlayerRosterName({ player, children, ...props }: PlayerRosterPartProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
61
|
+
export declare function PlayerRosterScore({ player, children, ...props }: PlayerRosterPartProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
62
|
+
export declare function PlayerRosterBadges({ player, children, ...props }: PlayerRosterPartProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
63
|
+
export declare const PlayerRoster: PlayerRosterComponents;
|
|
64
|
+
//# sourceMappingURL=player-roster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"player-roster.d.ts","sourceRoot":"","sources":["../../src/primitives/player-roster.tsx"],"names":[],"mappings":"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"}
|