@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,764 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Cosmos fixtures for SquareGrid component
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates various square grid configurations:
|
|
5
|
+
* - Chess board with pieces
|
|
6
|
+
* - Checkers game
|
|
7
|
+
* - Go board (9x9)
|
|
8
|
+
* - Tactical game with highlighting
|
|
9
|
+
* - Drag and drop support
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { useState, useCallback } from "react";
|
|
13
|
+
import {
|
|
14
|
+
SquareGrid,
|
|
15
|
+
DefaultGridCell,
|
|
16
|
+
DefaultGridPiece,
|
|
17
|
+
DefaultChessPiece,
|
|
18
|
+
} from "../board/SquareGrid.js";
|
|
19
|
+
import type {
|
|
20
|
+
SquareCellState,
|
|
21
|
+
SquareEdgeState,
|
|
22
|
+
SquarePieceState,
|
|
23
|
+
SquareVertexState,
|
|
24
|
+
} from "../../types/player-state.js";
|
|
25
|
+
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Sample Chess Data
|
|
28
|
+
// ============================================================================
|
|
29
|
+
|
|
30
|
+
const initialChessPieces: SquarePieceState[] = [
|
|
31
|
+
// White pieces
|
|
32
|
+
{ id: "wr1", row: 7, col: 0, typeId: "rook", owner: "white" },
|
|
33
|
+
{ id: "wn1", row: 7, col: 1, typeId: "knight", owner: "white" },
|
|
34
|
+
{ id: "wb1", row: 7, col: 2, typeId: "bishop", owner: "white" },
|
|
35
|
+
{ id: "wq", row: 7, col: 3, typeId: "queen", owner: "white" },
|
|
36
|
+
{ id: "wk", row: 7, col: 4, typeId: "king", owner: "white" },
|
|
37
|
+
{ id: "wb2", row: 7, col: 5, typeId: "bishop", owner: "white" },
|
|
38
|
+
{ id: "wn2", row: 7, col: 6, typeId: "knight", owner: "white" },
|
|
39
|
+
{ id: "wr2", row: 7, col: 7, typeId: "rook", owner: "white" },
|
|
40
|
+
...Array.from({ length: 8 }, (_, i) => ({
|
|
41
|
+
id: `wp${i}`,
|
|
42
|
+
row: 6,
|
|
43
|
+
col: i,
|
|
44
|
+
typeId: "pawn",
|
|
45
|
+
owner: "white",
|
|
46
|
+
})),
|
|
47
|
+
// Black pieces
|
|
48
|
+
{ id: "br1", row: 0, col: 0, typeId: "rook", owner: "black" },
|
|
49
|
+
{ id: "bn1", row: 0, col: 1, typeId: "knight", owner: "black" },
|
|
50
|
+
{ id: "bb1", row: 0, col: 2, typeId: "bishop", owner: "black" },
|
|
51
|
+
{ id: "bq", row: 0, col: 3, typeId: "queen", owner: "black" },
|
|
52
|
+
{ id: "bk", row: 0, col: 4, typeId: "king", owner: "black" },
|
|
53
|
+
{ id: "bb2", row: 0, col: 5, typeId: "bishop", owner: "black" },
|
|
54
|
+
{ id: "bn2", row: 0, col: 6, typeId: "knight", owner: "black" },
|
|
55
|
+
{ id: "br2", row: 0, col: 7, typeId: "rook", owner: "black" },
|
|
56
|
+
...Array.from({ length: 8 }, (_, i) => ({
|
|
57
|
+
id: `bp${i}`,
|
|
58
|
+
row: 1,
|
|
59
|
+
col: i,
|
|
60
|
+
typeId: "pawn",
|
|
61
|
+
owner: "black",
|
|
62
|
+
})),
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// Sample Checkers Data
|
|
67
|
+
// ============================================================================
|
|
68
|
+
|
|
69
|
+
const initialCheckersPieces: SquarePieceState[] = [
|
|
70
|
+
// Red pieces (top)
|
|
71
|
+
...Array.from({ length: 12 }, (_, i) => {
|
|
72
|
+
const row = Math.floor(i / 4);
|
|
73
|
+
const col = (i % 4) * 2 + (row % 2 === 0 ? 1 : 0);
|
|
74
|
+
return {
|
|
75
|
+
id: `red-${i}`,
|
|
76
|
+
row,
|
|
77
|
+
col,
|
|
78
|
+
typeId: "checker",
|
|
79
|
+
owner: "red",
|
|
80
|
+
};
|
|
81
|
+
}),
|
|
82
|
+
// Black pieces (bottom)
|
|
83
|
+
...Array.from({ length: 12 }, (_, i) => {
|
|
84
|
+
const row = 5 + Math.floor(i / 4);
|
|
85
|
+
const col = (i % 4) * 2 + (row % 2 === 0 ? 1 : 0);
|
|
86
|
+
return {
|
|
87
|
+
id: `black-${i}`,
|
|
88
|
+
row,
|
|
89
|
+
col,
|
|
90
|
+
typeId: "checker",
|
|
91
|
+
owner: "black",
|
|
92
|
+
};
|
|
93
|
+
}),
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
const topologyCells: SquareCellState[] = Array.from({ length: 3 }, (_, row) =>
|
|
97
|
+
Array.from({ length: 3 }, (_, col) => ({
|
|
98
|
+
id: `cell-${row}-${col}`,
|
|
99
|
+
row,
|
|
100
|
+
col,
|
|
101
|
+
label: `${row},${col}`,
|
|
102
|
+
})),
|
|
103
|
+
).flat();
|
|
104
|
+
|
|
105
|
+
const topologyEdges: SquareEdgeState[] = [
|
|
106
|
+
{ id: "edge-north", spaceIds: ["cell-0-1", "cell-1-1"], typeId: "corridor" },
|
|
107
|
+
{ id: "edge-east", spaceIds: ["cell-1-1", "cell-1-2"], typeId: "corridor" },
|
|
108
|
+
{ id: "edge-south", spaceIds: ["cell-1-1", "cell-2-1"], typeId: "corridor" },
|
|
109
|
+
{ id: "edge-west", spaceIds: ["cell-1-0", "cell-1-1"], typeId: "corridor" },
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
const topologyVertices: SquareVertexState[] = [
|
|
113
|
+
{
|
|
114
|
+
id: "vertex-center",
|
|
115
|
+
spaceIds: ["cell-0-0", "cell-0-1", "cell-1-0", "cell-1-1"],
|
|
116
|
+
typeId: "junction",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: "vertex-east",
|
|
120
|
+
spaceIds: ["cell-0-1", "cell-0-2", "cell-1-1", "cell-1-2"],
|
|
121
|
+
typeId: "junction",
|
|
122
|
+
},
|
|
123
|
+
];
|
|
124
|
+
|
|
125
|
+
// ============================================================================
|
|
126
|
+
// Fixtures
|
|
127
|
+
// ============================================================================
|
|
128
|
+
|
|
129
|
+
export default {
|
|
130
|
+
/**
|
|
131
|
+
* Chess Board
|
|
132
|
+
* Classic 8x8 chess board with starting position
|
|
133
|
+
*/
|
|
134
|
+
"Chess Board": () => {
|
|
135
|
+
const [selectedPiece, setSelectedPiece] = useState<string | null>(null);
|
|
136
|
+
const [pieces, setPieces] = useState(initialChessPieces);
|
|
137
|
+
|
|
138
|
+
const selectedPieceData = pieces.find((p) => p.id === selectedPiece);
|
|
139
|
+
|
|
140
|
+
// Calculate valid moves (simplified - just shows forward for pawns)
|
|
141
|
+
const validMoves = new Set<string>();
|
|
142
|
+
if (selectedPieceData?.typeId === "pawn") {
|
|
143
|
+
const dir = selectedPieceData.owner === "white" ? -1 : 1;
|
|
144
|
+
validMoves.add(`${selectedPieceData.row + dir}-${selectedPieceData.col}`);
|
|
145
|
+
if (
|
|
146
|
+
(selectedPieceData.owner === "white" && selectedPieceData.row === 6) ||
|
|
147
|
+
(selectedPieceData.owner === "black" && selectedPieceData.row === 1)
|
|
148
|
+
) {
|
|
149
|
+
validMoves.add(
|
|
150
|
+
`${selectedPieceData.row + dir * 2}-${selectedPieceData.col}`,
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const handleCellClick = (row: number, col: number) => {
|
|
156
|
+
if (selectedPiece && validMoves.has(`${row}-${col}`)) {
|
|
157
|
+
setPieces((prev) =>
|
|
158
|
+
prev.map((p) => (p.id === selectedPiece ? { ...p, row, col } : p)),
|
|
159
|
+
);
|
|
160
|
+
setSelectedPiece(null);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const handlePieceClick = (pieceId: string) => {
|
|
165
|
+
setSelectedPiece(pieceId === selectedPiece ? null : pieceId);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<div className="p-6 bg-slate-900 min-h-screen">
|
|
170
|
+
<h2 className="text-xl font-bold text-white mb-4">Chess Board</h2>
|
|
171
|
+
<p className="text-slate-400 mb-4">
|
|
172
|
+
Click pieces to select. Shows valid moves for pawns.
|
|
173
|
+
</p>
|
|
174
|
+
|
|
175
|
+
<SquareGrid
|
|
176
|
+
rows={8}
|
|
177
|
+
cols={8}
|
|
178
|
+
pieces={pieces}
|
|
179
|
+
cellSize={70}
|
|
180
|
+
showCoordinates={true}
|
|
181
|
+
coordinateStyle="algebraic"
|
|
182
|
+
renderCell={(row, col) => (
|
|
183
|
+
<DefaultGridCell
|
|
184
|
+
size={70}
|
|
185
|
+
isLight={(row + col) % 2 === 0}
|
|
186
|
+
lightColor="#f0d9b5"
|
|
187
|
+
darkColor="#b58863"
|
|
188
|
+
isSelected={
|
|
189
|
+
selectedPieceData?.row === row && selectedPieceData?.col === col
|
|
190
|
+
}
|
|
191
|
+
isValidMove={
|
|
192
|
+
validMoves.has(`${row}-${col}`) &&
|
|
193
|
+
!pieces.some((p) => p.row === row && p.col === col)
|
|
194
|
+
}
|
|
195
|
+
isCapture={
|
|
196
|
+
validMoves.has(`${row}-${col}`) &&
|
|
197
|
+
pieces.some((p) => p.row === row && p.col === col)
|
|
198
|
+
}
|
|
199
|
+
onClick={() => handleCellClick(row, col)}
|
|
200
|
+
/>
|
|
201
|
+
)}
|
|
202
|
+
renderPiece={(piece) => (
|
|
203
|
+
<DefaultChessPiece
|
|
204
|
+
size={70}
|
|
205
|
+
type={piece.typeId}
|
|
206
|
+
owner={piece.owner as "white" | "black"}
|
|
207
|
+
onClick={() => handlePieceClick(piece.id)}
|
|
208
|
+
/>
|
|
209
|
+
)}
|
|
210
|
+
/>
|
|
211
|
+
</div>
|
|
212
|
+
);
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Checkers Board
|
|
217
|
+
* 8x8 checkers with red and black pieces
|
|
218
|
+
*/
|
|
219
|
+
"Checkers Board": () => {
|
|
220
|
+
const [selectedPiece, setSelectedPiece] = useState<string | null>(null);
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<div className="p-6 bg-slate-900 min-h-screen">
|
|
224
|
+
<h2 className="text-xl font-bold text-white mb-4">Checkers Board</h2>
|
|
225
|
+
<p className="text-slate-400 mb-4">Click pieces to select</p>
|
|
226
|
+
|
|
227
|
+
<SquareGrid
|
|
228
|
+
rows={8}
|
|
229
|
+
cols={8}
|
|
230
|
+
pieces={initialCheckersPieces}
|
|
231
|
+
cellSize={65}
|
|
232
|
+
showCoordinates={false}
|
|
233
|
+
renderCell={(row, col) => (
|
|
234
|
+
<DefaultGridCell
|
|
235
|
+
size={65}
|
|
236
|
+
isLight={(row + col) % 2 === 0}
|
|
237
|
+
lightColor="#deb887"
|
|
238
|
+
darkColor="#8b4513"
|
|
239
|
+
/>
|
|
240
|
+
)}
|
|
241
|
+
renderPiece={(piece) => (
|
|
242
|
+
<g onClick={() => setSelectedPiece(piece.id)}>
|
|
243
|
+
<circle
|
|
244
|
+
r={25}
|
|
245
|
+
fill={piece.owner === "red" ? "#dc2626" : "#1e293b"}
|
|
246
|
+
stroke={piece.owner === "red" ? "#b91c1c" : "#0f172a"}
|
|
247
|
+
strokeWidth={3}
|
|
248
|
+
className="cursor-pointer"
|
|
249
|
+
/>
|
|
250
|
+
<circle
|
|
251
|
+
r={18}
|
|
252
|
+
fill="none"
|
|
253
|
+
stroke={piece.owner === "red" ? "#ef4444" : "#334155"}
|
|
254
|
+
strokeWidth={2}
|
|
255
|
+
/>
|
|
256
|
+
{piece.id === selectedPiece && (
|
|
257
|
+
<circle r={28} fill="none" stroke="#fbbf24" strokeWidth={3} />
|
|
258
|
+
)}
|
|
259
|
+
</g>
|
|
260
|
+
)}
|
|
261
|
+
/>
|
|
262
|
+
</div>
|
|
263
|
+
);
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Go Board (9x9)
|
|
268
|
+
* Smaller Go board for learning
|
|
269
|
+
*/
|
|
270
|
+
"Go Board (9x9)": () => {
|
|
271
|
+
const [pieces, setPieces] = useState<SquarePieceState[]>([
|
|
272
|
+
{ id: "b1", row: 2, col: 2, typeId: "stone", owner: "black" },
|
|
273
|
+
{ id: "w1", row: 2, col: 6, typeId: "stone", owner: "white" },
|
|
274
|
+
{ id: "b2", row: 6, col: 2, typeId: "stone", owner: "black" },
|
|
275
|
+
{ id: "w2", row: 6, col: 6, typeId: "stone", owner: "white" },
|
|
276
|
+
{ id: "b3", row: 4, col: 4, typeId: "stone", owner: "black" },
|
|
277
|
+
]);
|
|
278
|
+
const [currentPlayer, setCurrentPlayer] = useState<"black" | "white">(
|
|
279
|
+
"white",
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
const handleCellClick = useCallback(
|
|
283
|
+
(row: number, col: number) => {
|
|
284
|
+
// Check if cell is occupied
|
|
285
|
+
if (pieces.some((p) => p.row === row && p.col === col)) return;
|
|
286
|
+
|
|
287
|
+
const newPiece: SquarePieceState = {
|
|
288
|
+
id: `${currentPlayer}-${Date.now()}`,
|
|
289
|
+
row,
|
|
290
|
+
col,
|
|
291
|
+
typeId: "stone",
|
|
292
|
+
owner: currentPlayer,
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
setPieces((prev) => [...prev, newPiece]);
|
|
296
|
+
setCurrentPlayer((prev) => (prev === "black" ? "white" : "black"));
|
|
297
|
+
},
|
|
298
|
+
[pieces, currentPlayer],
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
const cellSize = 55;
|
|
302
|
+
const starPoints = new Set(["2-2", "2-6", "6-2", "6-6", "4-4"]);
|
|
303
|
+
|
|
304
|
+
return (
|
|
305
|
+
<div className="p-6 bg-slate-900 min-h-screen">
|
|
306
|
+
<h2 className="text-xl font-bold text-white mb-4">Go Board (9x9)</h2>
|
|
307
|
+
<p className="text-slate-400 mb-4">
|
|
308
|
+
Current player:{" "}
|
|
309
|
+
<span
|
|
310
|
+
className={
|
|
311
|
+
currentPlayer === "black" ? "text-slate-300" : "text-amber-200"
|
|
312
|
+
}
|
|
313
|
+
>
|
|
314
|
+
{currentPlayer}
|
|
315
|
+
</span>
|
|
316
|
+
. Click to place a stone.
|
|
317
|
+
</p>
|
|
318
|
+
|
|
319
|
+
<SquareGrid
|
|
320
|
+
rows={9}
|
|
321
|
+
cols={9}
|
|
322
|
+
pieces={pieces}
|
|
323
|
+
cellSize={cellSize}
|
|
324
|
+
showCoordinates={true}
|
|
325
|
+
coordinateStyle="numeric"
|
|
326
|
+
renderCell={(row, col) => (
|
|
327
|
+
<g
|
|
328
|
+
onClick={() => handleCellClick(row, col)}
|
|
329
|
+
className="cursor-pointer"
|
|
330
|
+
>
|
|
331
|
+
<rect width={cellSize} height={cellSize} fill="#dcb35c" />
|
|
332
|
+
{/* Grid lines */}
|
|
333
|
+
<line
|
|
334
|
+
x1={cellSize / 2}
|
|
335
|
+
y1={row === 0 ? cellSize / 2 : 0}
|
|
336
|
+
x2={cellSize / 2}
|
|
337
|
+
y2={row === 8 ? cellSize / 2 : cellSize}
|
|
338
|
+
stroke="#8b6914"
|
|
339
|
+
strokeWidth={1}
|
|
340
|
+
/>
|
|
341
|
+
<line
|
|
342
|
+
x1={col === 0 ? cellSize / 2 : 0}
|
|
343
|
+
y1={cellSize / 2}
|
|
344
|
+
x2={col === 8 ? cellSize / 2 : cellSize}
|
|
345
|
+
y2={cellSize / 2}
|
|
346
|
+
stroke="#8b6914"
|
|
347
|
+
strokeWidth={1}
|
|
348
|
+
/>
|
|
349
|
+
{/* Star points */}
|
|
350
|
+
{starPoints.has(`${row}-${col}`) && (
|
|
351
|
+
<circle
|
|
352
|
+
cx={cellSize / 2}
|
|
353
|
+
cy={cellSize / 2}
|
|
354
|
+
r={4}
|
|
355
|
+
fill="#8b6914"
|
|
356
|
+
/>
|
|
357
|
+
)}
|
|
358
|
+
</g>
|
|
359
|
+
)}
|
|
360
|
+
renderPiece={(piece) => (
|
|
361
|
+
<circle
|
|
362
|
+
r={22}
|
|
363
|
+
fill={piece.owner === "black" ? "#1e293b" : "#f8fafc"}
|
|
364
|
+
stroke={piece.owner === "black" ? "#0f172a" : "#cbd5e1"}
|
|
365
|
+
strokeWidth={2}
|
|
366
|
+
style={{ filter: "drop-shadow(2px 2px 2px rgba(0,0,0,0.4))" }}
|
|
367
|
+
/>
|
|
368
|
+
)}
|
|
369
|
+
/>
|
|
370
|
+
</div>
|
|
371
|
+
);
|
|
372
|
+
},
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Tactical Game with Highlighting
|
|
376
|
+
* Shows movement ranges and attack indicators
|
|
377
|
+
*/
|
|
378
|
+
"Tactical Game": () => {
|
|
379
|
+
const [selectedUnit, setSelectedUnit] = useState<string | null>("unit-1");
|
|
380
|
+
|
|
381
|
+
const units: SquarePieceState[] = [
|
|
382
|
+
{ id: "unit-1", row: 3, col: 3, typeId: "warrior", owner: "player1" },
|
|
383
|
+
{ id: "unit-2", row: 5, col: 5, typeId: "archer", owner: "player1" },
|
|
384
|
+
{ id: "enemy-1", row: 2, col: 4, typeId: "warrior", owner: "enemy" },
|
|
385
|
+
{ id: "enemy-2", row: 4, col: 6, typeId: "archer", owner: "enemy" },
|
|
386
|
+
];
|
|
387
|
+
|
|
388
|
+
const selectedUnitData = units.find((u) => u.id === selectedUnit);
|
|
389
|
+
const unitsByPosition = new Map(units.map((u) => [`${u.row}-${u.col}`, u]));
|
|
390
|
+
|
|
391
|
+
// Calculate movement range
|
|
392
|
+
const validMoves = new Set<string>();
|
|
393
|
+
const captureMoves = new Set<string>();
|
|
394
|
+
|
|
395
|
+
if (selectedUnitData) {
|
|
396
|
+
const range = selectedUnitData.typeId === "warrior" ? 2 : 3;
|
|
397
|
+
for (let dr = -range; dr <= range; dr++) {
|
|
398
|
+
for (let dc = -range; dc <= range; dc++) {
|
|
399
|
+
if (Math.abs(dr) + Math.abs(dc) <= range && (dr !== 0 || dc !== 0)) {
|
|
400
|
+
const newRow = selectedUnitData.row + dr;
|
|
401
|
+
const newCol = selectedUnitData.col + dc;
|
|
402
|
+
if (newRow >= 0 && newRow < 8 && newCol >= 0 && newCol < 8) {
|
|
403
|
+
const occupant = unitsByPosition.get(`${newRow}-${newCol}`);
|
|
404
|
+
if (occupant && occupant.owner !== selectedUnitData.owner) {
|
|
405
|
+
captureMoves.add(`${newRow}-${newCol}`);
|
|
406
|
+
} else if (!occupant) {
|
|
407
|
+
validMoves.add(`${newRow}-${newCol}`);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return (
|
|
416
|
+
<div className="p-6 bg-slate-900 min-h-screen">
|
|
417
|
+
<h2 className="text-xl font-bold text-white mb-4">Tactical Game</h2>
|
|
418
|
+
<p className="text-slate-400 mb-4">
|
|
419
|
+
Click friendly units to see movement range. Green = move, Red = attack
|
|
420
|
+
</p>
|
|
421
|
+
|
|
422
|
+
<SquareGrid
|
|
423
|
+
rows={8}
|
|
424
|
+
cols={8}
|
|
425
|
+
pieces={units}
|
|
426
|
+
cellSize={65}
|
|
427
|
+
showCoordinates={false}
|
|
428
|
+
renderCell={(row, col) => (
|
|
429
|
+
<DefaultGridCell
|
|
430
|
+
size={65}
|
|
431
|
+
isLight={(row + col) % 2 === 0}
|
|
432
|
+
lightColor="#4a5568"
|
|
433
|
+
darkColor="#2d3748"
|
|
434
|
+
isSelected={
|
|
435
|
+
selectedUnitData?.row === row && selectedUnitData?.col === col
|
|
436
|
+
}
|
|
437
|
+
isValidMove={validMoves.has(`${row}-${col}`)}
|
|
438
|
+
isCapture={captureMoves.has(`${row}-${col}`)}
|
|
439
|
+
/>
|
|
440
|
+
)}
|
|
441
|
+
renderPiece={(piece) => {
|
|
442
|
+
const isSelected = piece.id === selectedUnit;
|
|
443
|
+
return (
|
|
444
|
+
<g
|
|
445
|
+
onClick={() => {
|
|
446
|
+
if (piece.owner === "player1") setSelectedUnit(piece.id);
|
|
447
|
+
}}
|
|
448
|
+
className={piece.owner === "player1" ? "cursor-pointer" : ""}
|
|
449
|
+
>
|
|
450
|
+
<circle
|
|
451
|
+
r={isSelected ? 26 : 24}
|
|
452
|
+
fill={piece.owner === "player1" ? "#3b82f6" : "#ef4444"}
|
|
453
|
+
stroke={isSelected ? "#fbbf24" : "#1e293b"}
|
|
454
|
+
strokeWidth={isSelected ? 3 : 2}
|
|
455
|
+
/>
|
|
456
|
+
<text
|
|
457
|
+
textAnchor="middle"
|
|
458
|
+
dominantBaseline="middle"
|
|
459
|
+
fill="white"
|
|
460
|
+
fontSize={20}
|
|
461
|
+
>
|
|
462
|
+
{piece.typeId === "warrior" ? "⚔️" : "🏹"}
|
|
463
|
+
</text>
|
|
464
|
+
</g>
|
|
465
|
+
);
|
|
466
|
+
}}
|
|
467
|
+
/>
|
|
468
|
+
</div>
|
|
469
|
+
);
|
|
470
|
+
},
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Drag and Drop (Click-to-Move)
|
|
474
|
+
* Interactive movement for pieces
|
|
475
|
+
*/
|
|
476
|
+
"Click to Move": () => {
|
|
477
|
+
const [pieces, setPieces] = useState<SquarePieceState[]>([
|
|
478
|
+
{ id: "p1", row: 0, col: 0, typeId: "token", owner: "blue" },
|
|
479
|
+
{ id: "p2", row: 0, col: 1, typeId: "token", owner: "red" },
|
|
480
|
+
{ id: "p3", row: 0, col: 2, typeId: "token", owner: "green" },
|
|
481
|
+
]);
|
|
482
|
+
const [selectedPiece, setSelectedPiece] = useState<string | null>(null);
|
|
483
|
+
|
|
484
|
+
const playerColors: Record<string, string> = {
|
|
485
|
+
blue: "#3b82f6",
|
|
486
|
+
red: "#ef4444",
|
|
487
|
+
green: "#22c55e",
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
const handleCellClick = (row: number, col: number) => {
|
|
491
|
+
if (selectedPiece) {
|
|
492
|
+
// Check if cell is occupied by another piece
|
|
493
|
+
if (
|
|
494
|
+
pieces.some(
|
|
495
|
+
(p) => p.row === row && p.col === col && p.id !== selectedPiece,
|
|
496
|
+
)
|
|
497
|
+
) {
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
setPieces((prev) =>
|
|
501
|
+
prev.map((p) => (p.id === selectedPiece ? { ...p, row, col } : p)),
|
|
502
|
+
);
|
|
503
|
+
setSelectedPiece(null);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
return (
|
|
508
|
+
<div className="p-6 bg-slate-900 min-h-screen">
|
|
509
|
+
<h2 className="text-xl font-bold text-white mb-4">Click to Move</h2>
|
|
510
|
+
<p className="text-slate-400 mb-4">
|
|
511
|
+
Click a piece to select, then click a cell to move
|
|
512
|
+
</p>
|
|
513
|
+
|
|
514
|
+
<SquareGrid
|
|
515
|
+
rows={6}
|
|
516
|
+
cols={6}
|
|
517
|
+
pieces={pieces}
|
|
518
|
+
cellSize={80}
|
|
519
|
+
showCoordinates={false}
|
|
520
|
+
renderCell={(row, col) => (
|
|
521
|
+
<DefaultGridCell
|
|
522
|
+
size={80}
|
|
523
|
+
isLight={(row + col) % 2 === 0}
|
|
524
|
+
lightColor="#e2e8f0"
|
|
525
|
+
darkColor="#94a3b8"
|
|
526
|
+
onClick={() => handleCellClick(row, col)}
|
|
527
|
+
/>
|
|
528
|
+
)}
|
|
529
|
+
renderPiece={(piece) => (
|
|
530
|
+
<DefaultGridPiece
|
|
531
|
+
size={80}
|
|
532
|
+
color={playerColors[piece.owner ?? "blue"]}
|
|
533
|
+
label={piece.id.replace("p", "")}
|
|
534
|
+
onClick={() =>
|
|
535
|
+
setSelectedPiece(piece.id === selectedPiece ? null : piece.id)
|
|
536
|
+
}
|
|
537
|
+
className={
|
|
538
|
+
selectedPiece === piece.id ? "ring-4 ring-yellow-400" : ""
|
|
539
|
+
}
|
|
540
|
+
/>
|
|
541
|
+
)}
|
|
542
|
+
/>
|
|
543
|
+
</div>
|
|
544
|
+
);
|
|
545
|
+
},
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Large Grid with Pan & Zoom
|
|
549
|
+
* 16x16 grid demonstrating pan and zoom
|
|
550
|
+
*/
|
|
551
|
+
"Large Grid (Pan & Zoom)": () => {
|
|
552
|
+
const pieces: SquarePieceState[] = Array.from({ length: 20 }, (_, i) => ({
|
|
553
|
+
id: `piece-${i}`,
|
|
554
|
+
row: Math.floor(Math.random() * 16),
|
|
555
|
+
col: Math.floor(Math.random() * 16),
|
|
556
|
+
typeId: "marker",
|
|
557
|
+
owner: i % 2 === 0 ? "player1" : "player2",
|
|
558
|
+
}));
|
|
559
|
+
|
|
560
|
+
const playerColors: Record<string, string> = {
|
|
561
|
+
player1: "#f59e0b",
|
|
562
|
+
player2: "#8b5cf6",
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
return (
|
|
566
|
+
<div className="p-6 bg-slate-900 min-h-screen">
|
|
567
|
+
<h2 className="text-xl font-bold text-white mb-4">
|
|
568
|
+
Large Grid (16x16)
|
|
569
|
+
</h2>
|
|
570
|
+
<p className="text-slate-400 mb-4">Drag to pan, scroll/pinch to zoom</p>
|
|
571
|
+
|
|
572
|
+
<SquareGrid
|
|
573
|
+
rows={16}
|
|
574
|
+
cols={16}
|
|
575
|
+
pieces={pieces}
|
|
576
|
+
cellSize={40}
|
|
577
|
+
showCoordinates={true}
|
|
578
|
+
coordinateStyle="numeric"
|
|
579
|
+
width={600}
|
|
580
|
+
height={500}
|
|
581
|
+
enablePanZoom={true}
|
|
582
|
+
initialZoom={0.7}
|
|
583
|
+
minZoom={0.3}
|
|
584
|
+
maxZoom={2}
|
|
585
|
+
renderCell={(row, col) => (
|
|
586
|
+
<DefaultGridCell
|
|
587
|
+
size={40}
|
|
588
|
+
isLight={(row + col) % 2 === 0}
|
|
589
|
+
lightColor="#475569"
|
|
590
|
+
darkColor="#334155"
|
|
591
|
+
/>
|
|
592
|
+
)}
|
|
593
|
+
renderPiece={(piece) => (
|
|
594
|
+
<DefaultGridPiece
|
|
595
|
+
size={40}
|
|
596
|
+
color={playerColors[piece.owner ?? "player1"]}
|
|
597
|
+
label={piece.typeId.charAt(0).toUpperCase()}
|
|
598
|
+
/>
|
|
599
|
+
)}
|
|
600
|
+
/>
|
|
601
|
+
</div>
|
|
602
|
+
);
|
|
603
|
+
},
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Responsive Layout
|
|
607
|
+
* Grid that scales with container
|
|
608
|
+
*/
|
|
609
|
+
"Responsive Layout": () => (
|
|
610
|
+
<div className="p-6 bg-slate-900 min-h-screen">
|
|
611
|
+
<h2 className="text-xl font-bold text-white mb-4">Responsive Grid</h2>
|
|
612
|
+
<p className="text-slate-400 mb-4">Grid scales with container width</p>
|
|
613
|
+
|
|
614
|
+
<div className="w-full max-w-xl mx-auto bg-slate-800 p-4 rounded-lg">
|
|
615
|
+
<SquareGrid
|
|
616
|
+
rows={8}
|
|
617
|
+
cols={8}
|
|
618
|
+
pieces={[]}
|
|
619
|
+
cellSize={60}
|
|
620
|
+
showCoordinates={true}
|
|
621
|
+
width="100%"
|
|
622
|
+
height={520}
|
|
623
|
+
renderCell={(row, col) => (
|
|
624
|
+
<DefaultGridCell
|
|
625
|
+
size={60}
|
|
626
|
+
isLight={(row + col) % 2 === 0}
|
|
627
|
+
lightColor="#f0d9b5"
|
|
628
|
+
darkColor="#b58863"
|
|
629
|
+
/>
|
|
630
|
+
)}
|
|
631
|
+
renderPiece={() => null}
|
|
632
|
+
/>
|
|
633
|
+
</div>
|
|
634
|
+
</div>
|
|
635
|
+
),
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Tiled Topology Overlays
|
|
639
|
+
* Demonstrates the shared edge and vertex interaction pattern used by tiled boards.
|
|
640
|
+
*/
|
|
641
|
+
"Tiled Topology Overlays": () => {
|
|
642
|
+
const [selectedEdgeId, setSelectedEdgeId] = useState<string | null>(null);
|
|
643
|
+
const [selectedVertexId, setSelectedVertexId] = useState<string | null>(
|
|
644
|
+
null,
|
|
645
|
+
);
|
|
646
|
+
|
|
647
|
+
const highlightedCellIds = new Set<string>();
|
|
648
|
+
topologyEdges
|
|
649
|
+
.find((edge) => edge.id === selectedEdgeId)
|
|
650
|
+
?.spaceIds.forEach((spaceId) => highlightedCellIds.add(spaceId));
|
|
651
|
+
topologyVertices
|
|
652
|
+
.find((vertex) => vertex.id === selectedVertexId)
|
|
653
|
+
?.spaceIds.forEach((spaceId) => highlightedCellIds.add(spaceId));
|
|
654
|
+
|
|
655
|
+
return (
|
|
656
|
+
<div className="p-6 bg-slate-950 min-h-screen">
|
|
657
|
+
<h2 className="text-xl font-bold text-white mb-4">
|
|
658
|
+
Tiled Topology Overlays
|
|
659
|
+
</h2>
|
|
660
|
+
<p className="text-slate-400 mb-4 max-w-2xl">
|
|
661
|
+
Reducer views can project cells, edges, and vertices separately while
|
|
662
|
+
the UI uses the same edge and vertex interaction pattern as HexGrid.
|
|
663
|
+
</p>
|
|
664
|
+
|
|
665
|
+
<SquareGrid
|
|
666
|
+
rows={3}
|
|
667
|
+
cols={3}
|
|
668
|
+
cells={topologyCells}
|
|
669
|
+
pieces={[]}
|
|
670
|
+
edges={topologyEdges}
|
|
671
|
+
vertices={topologyVertices}
|
|
672
|
+
cellSize={92}
|
|
673
|
+
showCoordinates={false}
|
|
674
|
+
interactiveEdges={{
|
|
675
|
+
selectTargetId: (edgeId) =>
|
|
676
|
+
setSelectedEdgeId((current) =>
|
|
677
|
+
current === edgeId ? null : edgeId,
|
|
678
|
+
),
|
|
679
|
+
}}
|
|
680
|
+
interactiveVertices={{
|
|
681
|
+
selectTargetId: (vertexId) =>
|
|
682
|
+
setSelectedVertexId((current) =>
|
|
683
|
+
current === vertexId ? null : vertexId,
|
|
684
|
+
),
|
|
685
|
+
}}
|
|
686
|
+
renderInteractiveEdge={(_edge, position, state) => (
|
|
687
|
+
<line
|
|
688
|
+
x1={position.x1}
|
|
689
|
+
y1={position.y1}
|
|
690
|
+
x2={position.x2}
|
|
691
|
+
y2={position.y2}
|
|
692
|
+
stroke={state.isHovered ? "#38bdf8" : "rgba(14,165,233,0.2)"}
|
|
693
|
+
strokeWidth={state.isHovered ? 14 : 10}
|
|
694
|
+
strokeLinecap="round"
|
|
695
|
+
pointerEvents="stroke"
|
|
696
|
+
/>
|
|
697
|
+
)}
|
|
698
|
+
renderInteractiveVertex={(_vertex, position, state) => (
|
|
699
|
+
<circle
|
|
700
|
+
cx={position.x}
|
|
701
|
+
cy={position.y}
|
|
702
|
+
r={state.isHovered ? 16 : 12}
|
|
703
|
+
fill={state.isHovered ? "rgba(251,146,60,0.5)" : "transparent"}
|
|
704
|
+
stroke="rgba(251,146,60,0.8)"
|
|
705
|
+
strokeWidth={2}
|
|
706
|
+
/>
|
|
707
|
+
)}
|
|
708
|
+
renderCell={(row, col) => {
|
|
709
|
+
const cellId = `cell-${row}-${col}`;
|
|
710
|
+
return (
|
|
711
|
+
<DefaultGridCell
|
|
712
|
+
size={92}
|
|
713
|
+
isLight={(row + col) % 2 === 0}
|
|
714
|
+
lightColor="#e2e8f0"
|
|
715
|
+
darkColor="#cbd5e1"
|
|
716
|
+
isHighlighted={highlightedCellIds.has(cellId)}
|
|
717
|
+
highlightColor="rgba(14, 165, 233, 0.24)"
|
|
718
|
+
/>
|
|
719
|
+
);
|
|
720
|
+
}}
|
|
721
|
+
renderPiece={() => null}
|
|
722
|
+
renderEdge={(edge, position) => {
|
|
723
|
+
const isActive = edge.id === selectedEdgeId;
|
|
724
|
+
return (
|
|
725
|
+
<line
|
|
726
|
+
x1={position.x1}
|
|
727
|
+
y1={position.y1}
|
|
728
|
+
x2={position.x2}
|
|
729
|
+
y2={position.y2}
|
|
730
|
+
stroke={isActive ? "#0f172a" : "#64748b"}
|
|
731
|
+
strokeWidth={isActive ? 8 : 4}
|
|
732
|
+
strokeLinecap="round"
|
|
733
|
+
className="transition-all duration-150"
|
|
734
|
+
/>
|
|
735
|
+
);
|
|
736
|
+
}}
|
|
737
|
+
renderVertex={(vertex, position) => {
|
|
738
|
+
const isActive = vertex.id === selectedVertexId;
|
|
739
|
+
return (
|
|
740
|
+
<circle
|
|
741
|
+
cx={position.x}
|
|
742
|
+
cy={position.y}
|
|
743
|
+
r={isActive ? 11 : 7}
|
|
744
|
+
fill={isActive ? "#f97316" : "#fb923c"}
|
|
745
|
+
stroke="#fff7ed"
|
|
746
|
+
strokeWidth={isActive ? 3 : 2}
|
|
747
|
+
className="transition-all duration-150"
|
|
748
|
+
/>
|
|
749
|
+
);
|
|
750
|
+
}}
|
|
751
|
+
/>
|
|
752
|
+
|
|
753
|
+
<div className="mt-4 grid gap-3 sm:grid-cols-2">
|
|
754
|
+
<div className="rounded-lg border border-slate-800 bg-slate-900 p-3 text-slate-200">
|
|
755
|
+
Edge target: {selectedEdgeId ?? "none"}
|
|
756
|
+
</div>
|
|
757
|
+
<div className="rounded-lg border border-slate-800 bg-slate-900 p-3 text-slate-200">
|
|
758
|
+
Vertex target: {selectedVertexId ?? "none"}
|
|
759
|
+
</div>
|
|
760
|
+
</div>
|
|
761
|
+
</div>
|
|
762
|
+
);
|
|
763
|
+
},
|
|
764
|
+
};
|