@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,525 @@
|
|
|
1
|
+
import { Fragment, useMemo, useState, type ReactNode } from "react";
|
|
2
|
+
import type { ViewCard } from "@dreamboard/sdk-types";
|
|
3
|
+
import { usePluginState } from "../../context/PluginStateContext.js";
|
|
4
|
+
import type { CardSize, HandLayout } from "../../hooks/useHandLayout.js";
|
|
5
|
+
import { useTheme } from "../../theme/ThemeProvider.js";
|
|
6
|
+
import { Card } from "../Card.js";
|
|
7
|
+
import { Drawer, DrawerContent, DrawerHeader, DrawerTitle } from "../Drawer.js";
|
|
8
|
+
import { Hand } from "../Hand.js";
|
|
9
|
+
import {
|
|
10
|
+
useCardZoneInteractions,
|
|
11
|
+
type CardZoneInteractionContext,
|
|
12
|
+
} from "./internal/useCardZoneInteractions.js";
|
|
13
|
+
import { CardZoneFollowUpForm } from "./internal/CardZoneFollowUpForm.js";
|
|
14
|
+
import type { InteractionParamsByKeyShape } from "./types.js";
|
|
15
|
+
|
|
16
|
+
export type PlayerCardsLayout<ZoneKey extends string = string> =
|
|
17
|
+
| PlayerCardZoneNode<ZoneKey>
|
|
18
|
+
| PlayerCardsGroup<ZoneKey>;
|
|
19
|
+
|
|
20
|
+
export interface PlayerCardsGroup<ZoneKey extends string = string> {
|
|
21
|
+
kind: "group";
|
|
22
|
+
direction: "row" | "column";
|
|
23
|
+
children: ReadonlyArray<PlayerCardsLayout<ZoneKey>>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface PlayerCardZoneModel<I extends string = string> {
|
|
27
|
+
zoneId: string;
|
|
28
|
+
label: string;
|
|
29
|
+
totalCount: number;
|
|
30
|
+
visibleCards: readonly ViewCard[];
|
|
31
|
+
hiddenCount: number;
|
|
32
|
+
hiddenCardIds: readonly string[];
|
|
33
|
+
contexts: ReadonlyArray<CardZoneInteractionContext<I>>;
|
|
34
|
+
contextsByCardId: ReadonlyMap<string, CardZoneInteractionContext<I>>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type PlayerCardZoneNode<ZoneKey extends string = string> =
|
|
38
|
+
| PlayerCardsPileNode<ZoneKey>
|
|
39
|
+
| PlayerCardsFanNode<ZoneKey>
|
|
40
|
+
| PlayerCardsCustomNode<ZoneKey>;
|
|
41
|
+
|
|
42
|
+
export interface PlayerCardsPileNode<ZoneKey extends string = string> {
|
|
43
|
+
kind: "pile";
|
|
44
|
+
zone: ZoneKey;
|
|
45
|
+
label?: string;
|
|
46
|
+
top?: "first" | "last";
|
|
47
|
+
details?: "drawer" | "none";
|
|
48
|
+
/**
|
|
49
|
+
* Explicit override for the count badge. Use when the player view
|
|
50
|
+
* hides the zone's `cardIds` (private decks, hidden draw piles) so
|
|
51
|
+
* the SDK's auto-derived `zone.totalCount` reads zero. The reducer
|
|
52
|
+
* still owns the source of truth — pass it through `defineView`.
|
|
53
|
+
*/
|
|
54
|
+
count?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Explicit override for the visible top-card preview. Use when the
|
|
57
|
+
* top card isn't part of the player's zone projection but is known
|
|
58
|
+
* via a custom view field. Falls back to {@link top} selection over
|
|
59
|
+
* `zone.visibleCards` when omitted.
|
|
60
|
+
*/
|
|
61
|
+
topCard?: ViewCard | null;
|
|
62
|
+
/**
|
|
63
|
+
* Replace just the visible top-card / face-down preview while keeping
|
|
64
|
+
* the SDK's button + count badge + drawer machinery. Use this when you
|
|
65
|
+
* want a custom card face but still want clicks to open the drawer.
|
|
66
|
+
*/
|
|
67
|
+
renderPreview?: (zone: PlayerCardZoneModel) => ReactNode;
|
|
68
|
+
/** Replace the empty-state (no cards) preview only. */
|
|
69
|
+
renderEmpty?: (zone: PlayerCardZoneModel) => ReactNode;
|
|
70
|
+
/**
|
|
71
|
+
* Per-card content renderer used by the default drawer body. Authors
|
|
72
|
+
* who supply this on every node can hoist it to the surface root via
|
|
73
|
+
* {@link PlayerCardsSurfaceConfig.renderCardContent}.
|
|
74
|
+
*/
|
|
75
|
+
renderCardContent?: (
|
|
76
|
+
card: ViewCard,
|
|
77
|
+
ctx: CardZoneInteractionContext,
|
|
78
|
+
) => ReactNode;
|
|
79
|
+
/** Replace the drawer body wholesale. */
|
|
80
|
+
renderDrawerContent?: (zone: PlayerCardZoneModel) => ReactNode;
|
|
81
|
+
/**
|
|
82
|
+
* Escape hatch — replaces the pile entirely (button, count badge,
|
|
83
|
+
* drawer, click handling). Prefer {@link renderPreview} +
|
|
84
|
+
* {@link renderDrawerContent} so authors don't accidentally drop the
|
|
85
|
+
* default click-to-open behavior. Reserved for cases that need fully
|
|
86
|
+
* bespoke chrome.
|
|
87
|
+
*/
|
|
88
|
+
renderPile?: (zone: PlayerCardZoneModel) => ReactNode;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface PlayerCardsFanNode<ZoneKey extends string = string> {
|
|
92
|
+
kind: "fan";
|
|
93
|
+
zone: ZoneKey;
|
|
94
|
+
label?: string;
|
|
95
|
+
renderCardContent?: (
|
|
96
|
+
card: ViewCard,
|
|
97
|
+
ctx: CardZoneInteractionContext,
|
|
98
|
+
) => ReactNode;
|
|
99
|
+
renderZone?: (zone: PlayerCardZoneModel) => ReactNode;
|
|
100
|
+
cardSize?: CardSize;
|
|
101
|
+
layout?: HandLayout;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface PlayerCardsCustomNode<ZoneKey extends string = string> {
|
|
105
|
+
kind: "custom";
|
|
106
|
+
zone: ZoneKey;
|
|
107
|
+
label?: string;
|
|
108
|
+
renderZone: (zone: PlayerCardZoneModel) => ReactNode;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface PlayerCardsSurfaceConfig<ZoneKey extends string = string> {
|
|
112
|
+
layout: PlayerCardsLayout<ZoneKey>;
|
|
113
|
+
/**
|
|
114
|
+
* Default per-card content renderer inherited by every `pile` and
|
|
115
|
+
* `fan` in the layout. Per-node `renderCardContent` (on a fan) or
|
|
116
|
+
* `renderCardContent` / `renderPreview` (on a pile) still wins. Set
|
|
117
|
+
* this once at the surface root to avoid passing the same `<CardFace>`
|
|
118
|
+
* to every zone.
|
|
119
|
+
*/
|
|
120
|
+
renderCardContent?: (
|
|
121
|
+
card: ViewCard,
|
|
122
|
+
ctx: CardZoneInteractionContext,
|
|
123
|
+
) => ReactNode;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface PlayerCardsSurfaceProps<ZoneKey extends string = string>
|
|
127
|
+
extends PlayerCardsSurfaceConfig<ZoneKey> {
|
|
128
|
+
empty?: ReactNode;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function definePlayerCardsSurface<
|
|
132
|
+
const Config extends PlayerCardsSurfaceConfig<string>,
|
|
133
|
+
>(config: Config): Config {
|
|
134
|
+
return config;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function row<const ZoneKey extends string>(
|
|
138
|
+
children: ReadonlyArray<PlayerCardsLayout<ZoneKey>>,
|
|
139
|
+
): PlayerCardsGroup<ZoneKey> {
|
|
140
|
+
return { kind: "group", direction: "row", children };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function column<const ZoneKey extends string>(
|
|
144
|
+
children: ReadonlyArray<PlayerCardsLayout<ZoneKey>>,
|
|
145
|
+
): PlayerCardsGroup<ZoneKey> {
|
|
146
|
+
return { kind: "group", direction: "column", children };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function pile<const ZoneKey extends string>(
|
|
150
|
+
zone: ZoneKey,
|
|
151
|
+
options: Omit<PlayerCardsPileNode<ZoneKey>, "kind" | "zone"> = {},
|
|
152
|
+
): PlayerCardsPileNode<ZoneKey> {
|
|
153
|
+
return { kind: "pile", zone, ...options };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function fan<const ZoneKey extends string>(
|
|
157
|
+
zone: ZoneKey,
|
|
158
|
+
options: Omit<PlayerCardsFanNode<ZoneKey>, "kind" | "zone"> = {},
|
|
159
|
+
): PlayerCardsFanNode<ZoneKey> {
|
|
160
|
+
return { kind: "fan", zone, ...options };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function custom<const ZoneKey extends string>(
|
|
164
|
+
zone: ZoneKey,
|
|
165
|
+
options: Omit<PlayerCardsCustomNode<ZoneKey>, "kind" | "zone">,
|
|
166
|
+
): PlayerCardsCustomNode<ZoneKey> {
|
|
167
|
+
return { kind: "custom", zone, ...options };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function PlayerCardsSurface<
|
|
171
|
+
I extends string = never,
|
|
172
|
+
ParamsByKey extends Partial<InteractionParamsByKeyShape> = {},
|
|
173
|
+
ZoneKey extends string = string,
|
|
174
|
+
>({
|
|
175
|
+
layout,
|
|
176
|
+
renderCardContent,
|
|
177
|
+
empty = null,
|
|
178
|
+
}: PlayerCardsSurfaceProps<ZoneKey>) {
|
|
179
|
+
if (!layout) return <>{empty}</>;
|
|
180
|
+
return (
|
|
181
|
+
<PlayerCardsLayoutNode<I, ParamsByKey>
|
|
182
|
+
layout={layout}
|
|
183
|
+
surfaceRenderCardContent={renderCardContent}
|
|
184
|
+
/>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function PlayerCardsLayoutNode<
|
|
189
|
+
I extends string,
|
|
190
|
+
ParamsByKey extends Partial<InteractionParamsByKeyShape>,
|
|
191
|
+
>({
|
|
192
|
+
layout,
|
|
193
|
+
surfaceRenderCardContent,
|
|
194
|
+
}: {
|
|
195
|
+
layout: PlayerCardsLayout<string>;
|
|
196
|
+
surfaceRenderCardContent?: (
|
|
197
|
+
card: ViewCard,
|
|
198
|
+
ctx: CardZoneInteractionContext,
|
|
199
|
+
) => ReactNode;
|
|
200
|
+
}) {
|
|
201
|
+
const theme = useTheme();
|
|
202
|
+
if (layout.kind === "group") {
|
|
203
|
+
return (
|
|
204
|
+
<div
|
|
205
|
+
data-player-cards-group={layout.direction}
|
|
206
|
+
style={{
|
|
207
|
+
display: "flex",
|
|
208
|
+
flexDirection: layout.direction,
|
|
209
|
+
gap: theme.space[2],
|
|
210
|
+
alignItems: layout.direction === "row" ? "flex-end" : "stretch",
|
|
211
|
+
// Fill the parent so flex children (especially the fan with
|
|
212
|
+
// `flex: 1 1 ...`) can grow to use the available width.
|
|
213
|
+
// Without this, the row collapses to its children's intrinsic
|
|
214
|
+
// size and the fan never gets room to spread.
|
|
215
|
+
width: "100%",
|
|
216
|
+
minWidth: 0,
|
|
217
|
+
}}
|
|
218
|
+
>
|
|
219
|
+
{layout.children.map((child, index) => (
|
|
220
|
+
<PlayerCardsLayoutNode<I, ParamsByKey>
|
|
221
|
+
key={index}
|
|
222
|
+
layout={child as PlayerCardsLayout<string>}
|
|
223
|
+
surfaceRenderCardContent={surfaceRenderCardContent}
|
|
224
|
+
/>
|
|
225
|
+
))}
|
|
226
|
+
</div>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
return (
|
|
230
|
+
<PlayerCardsZoneNode<I, ParamsByKey>
|
|
231
|
+
node={layout}
|
|
232
|
+
surfaceRenderCardContent={surfaceRenderCardContent}
|
|
233
|
+
/>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function PlayerCardsZoneNode<
|
|
238
|
+
I extends string,
|
|
239
|
+
ParamsByKey extends Partial<InteractionParamsByKeyShape>,
|
|
240
|
+
>({
|
|
241
|
+
node,
|
|
242
|
+
surfaceRenderCardContent,
|
|
243
|
+
}: {
|
|
244
|
+
node: PlayerCardZoneNode<string>;
|
|
245
|
+
surfaceRenderCardContent?: (
|
|
246
|
+
card: ViewCard,
|
|
247
|
+
ctx: CardZoneInteractionContext,
|
|
248
|
+
) => ReactNode;
|
|
249
|
+
}) {
|
|
250
|
+
const zone = usePlayerCardZone<I>(String(node.zone), node.label);
|
|
251
|
+
if (node.kind === "custom") return <>{node.renderZone(zone)}</>;
|
|
252
|
+
if (node.kind === "pile") {
|
|
253
|
+
return (
|
|
254
|
+
<PlayerCardsPile
|
|
255
|
+
node={node}
|
|
256
|
+
zone={zone}
|
|
257
|
+
surfaceRenderCardContent={surfaceRenderCardContent}
|
|
258
|
+
/>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
return (
|
|
262
|
+
<PlayerCardsFan<I, ParamsByKey>
|
|
263
|
+
node={node}
|
|
264
|
+
zone={zone}
|
|
265
|
+
surfaceRenderCardContent={surfaceRenderCardContent}
|
|
266
|
+
/>
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function usePlayerCardZone<I extends string>(
|
|
271
|
+
zoneId: string,
|
|
272
|
+
label?: string,
|
|
273
|
+
): PlayerCardZoneModel<I> & ReturnType<typeof useCardZoneInteractions<I>> {
|
|
274
|
+
const interactions = useCardZoneInteractions<I>(zoneId, { surface: "hand" });
|
|
275
|
+
const zone = usePluginState((s) => s.gameplay.zones?.[zoneId]);
|
|
276
|
+
return useMemo(() => {
|
|
277
|
+
const cardIds = zone?.cardIds ?? [];
|
|
278
|
+
const visibleIds = new Set(interactions.cards.map((card) => card.id));
|
|
279
|
+
const contextsByCardId = new Map(
|
|
280
|
+
interactions.contexts.map((ctx) => [ctx.card.id, ctx] as const),
|
|
281
|
+
);
|
|
282
|
+
return {
|
|
283
|
+
...interactions,
|
|
284
|
+
zoneId,
|
|
285
|
+
label: label ?? zoneId,
|
|
286
|
+
totalCount: cardIds.length,
|
|
287
|
+
visibleCards: interactions.cards,
|
|
288
|
+
hiddenCount: Math.max(0, cardIds.length - interactions.cards.length),
|
|
289
|
+
hiddenCardIds: cardIds.filter((cardId) => !visibleIds.has(cardId)),
|
|
290
|
+
contexts: interactions.contexts,
|
|
291
|
+
contextsByCardId,
|
|
292
|
+
};
|
|
293
|
+
}, [interactions, label, zone?.cardIds, zoneId]);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function PlayerCardsPile({
|
|
297
|
+
node,
|
|
298
|
+
zone,
|
|
299
|
+
surfaceRenderCardContent,
|
|
300
|
+
}: {
|
|
301
|
+
node: PlayerCardsPileNode<string>;
|
|
302
|
+
zone: PlayerCardZoneModel;
|
|
303
|
+
surfaceRenderCardContent?: (
|
|
304
|
+
card: ViewCard,
|
|
305
|
+
ctx: CardZoneInteractionContext,
|
|
306
|
+
) => ReactNode;
|
|
307
|
+
}) {
|
|
308
|
+
const [open, setOpen] = useState(false);
|
|
309
|
+
const top = node.top ?? "first";
|
|
310
|
+
const previewCard =
|
|
311
|
+
node.topCard !== undefined
|
|
312
|
+
? node.topCard
|
|
313
|
+
: top === "last"
|
|
314
|
+
? (zone.visibleCards[zone.visibleCards.length - 1] ?? null)
|
|
315
|
+
: (zone.visibleCards[0] ?? null);
|
|
316
|
+
const totalCount = node.count ?? zone.totalCount;
|
|
317
|
+
const drawerEnabled = (node.details ?? "drawer") !== "none";
|
|
318
|
+
const cardContent = node.renderCardContent ?? surfaceRenderCardContent;
|
|
319
|
+
|
|
320
|
+
// Full escape hatch — author owns button + drawer + everything.
|
|
321
|
+
if (node.renderPile) return <>{node.renderPile(zone)}</>;
|
|
322
|
+
|
|
323
|
+
const previewNode = node.renderPreview ? (
|
|
324
|
+
node.renderPreview(zone)
|
|
325
|
+
) : previewCard ? (
|
|
326
|
+
<Card
|
|
327
|
+
card={previewCard}
|
|
328
|
+
disabled
|
|
329
|
+
size="sm"
|
|
330
|
+
renderContent={
|
|
331
|
+
cardContent
|
|
332
|
+
? (card) => {
|
|
333
|
+
const ctx = zone.contextsByCardId.get(card.id);
|
|
334
|
+
return cardContent(card, ctx ?? emptyZoneContext(card));
|
|
335
|
+
}
|
|
336
|
+
: undefined
|
|
337
|
+
}
|
|
338
|
+
/>
|
|
339
|
+
) : node.renderEmpty ? (
|
|
340
|
+
node.renderEmpty(zone)
|
|
341
|
+
) : (
|
|
342
|
+
<div
|
|
343
|
+
aria-label="Hidden card"
|
|
344
|
+
style={{
|
|
345
|
+
width: 72,
|
|
346
|
+
height: 100,
|
|
347
|
+
borderRadius: 8,
|
|
348
|
+
border: "2px solid #111",
|
|
349
|
+
background:
|
|
350
|
+
"repeating-linear-gradient(135deg, #ddd, #ddd 6px, #bbb 6px, #bbb 12px)",
|
|
351
|
+
}}
|
|
352
|
+
/>
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
return (
|
|
356
|
+
<>
|
|
357
|
+
<button
|
|
358
|
+
type="button"
|
|
359
|
+
data-player-cards-pile={zone.zoneId}
|
|
360
|
+
onClick={() => {
|
|
361
|
+
if (drawerEnabled) setOpen(true);
|
|
362
|
+
}}
|
|
363
|
+
style={{
|
|
364
|
+
display: "flex",
|
|
365
|
+
flexDirection: "column",
|
|
366
|
+
alignItems: "center",
|
|
367
|
+
gap: 6,
|
|
368
|
+
border: 0,
|
|
369
|
+
background: "transparent",
|
|
370
|
+
padding: 0,
|
|
371
|
+
cursor: drawerEnabled ? "pointer" : "default",
|
|
372
|
+
}}
|
|
373
|
+
>
|
|
374
|
+
<span style={{ fontSize: 12, fontWeight: 700 }}>{zone.label}</span>
|
|
375
|
+
<div style={{ position: "relative", minWidth: 72, minHeight: 100 }}>
|
|
376
|
+
{previewNode}
|
|
377
|
+
<span
|
|
378
|
+
data-player-cards-pile-count
|
|
379
|
+
style={{
|
|
380
|
+
position: "absolute",
|
|
381
|
+
right: -6,
|
|
382
|
+
bottom: -6,
|
|
383
|
+
borderRadius: 999,
|
|
384
|
+
padding: "2px 6px",
|
|
385
|
+
background: "#111",
|
|
386
|
+
color: "#fff",
|
|
387
|
+
fontSize: 12,
|
|
388
|
+
}}
|
|
389
|
+
>
|
|
390
|
+
{totalCount}
|
|
391
|
+
</span>
|
|
392
|
+
</div>
|
|
393
|
+
</button>
|
|
394
|
+
<Drawer open={open} onOpenChange={setOpen}>
|
|
395
|
+
<DrawerContent>
|
|
396
|
+
<DrawerHeader>
|
|
397
|
+
<DrawerTitle>{zone.label}</DrawerTitle>
|
|
398
|
+
</DrawerHeader>
|
|
399
|
+
{node.renderDrawerContent ? (
|
|
400
|
+
node.renderDrawerContent(zone)
|
|
401
|
+
) : (
|
|
402
|
+
<div style={{ display: "flex", flexWrap: "wrap", gap: 8 }}>
|
|
403
|
+
{zone.visibleCards.map((card) => (
|
|
404
|
+
<Card
|
|
405
|
+
key={card.id}
|
|
406
|
+
card={card}
|
|
407
|
+
disabled
|
|
408
|
+
size="sm"
|
|
409
|
+
renderContent={
|
|
410
|
+
cardContent
|
|
411
|
+
? (c) => {
|
|
412
|
+
const ctx = zone.contextsByCardId.get(c.id);
|
|
413
|
+
return cardContent(c, ctx ?? emptyZoneContext(c));
|
|
414
|
+
}
|
|
415
|
+
: undefined
|
|
416
|
+
}
|
|
417
|
+
/>
|
|
418
|
+
))}
|
|
419
|
+
{Array.from({ length: zone.hiddenCount }).map((_, index) => (
|
|
420
|
+
<div key={index}>Hidden card</div>
|
|
421
|
+
))}
|
|
422
|
+
</div>
|
|
423
|
+
)}
|
|
424
|
+
</DrawerContent>
|
|
425
|
+
</Drawer>
|
|
426
|
+
</>
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function emptyZoneContext(card: ViewCard): CardZoneInteractionContext {
|
|
431
|
+
return {
|
|
432
|
+
card,
|
|
433
|
+
interactions: [],
|
|
434
|
+
play: null,
|
|
435
|
+
disabled: true,
|
|
436
|
+
actionState: "unavailable",
|
|
437
|
+
selected: false,
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function PlayerCardsFan<
|
|
442
|
+
I extends string,
|
|
443
|
+
ParamsByKey extends Partial<InteractionParamsByKeyShape>,
|
|
444
|
+
>({
|
|
445
|
+
node,
|
|
446
|
+
zone,
|
|
447
|
+
surfaceRenderCardContent,
|
|
448
|
+
}: {
|
|
449
|
+
node: PlayerCardsFanNode<string>;
|
|
450
|
+
zone: PlayerCardZoneModel<I> & ReturnType<typeof useCardZoneInteractions<I>>;
|
|
451
|
+
surfaceRenderCardContent?: (
|
|
452
|
+
card: ViewCard,
|
|
453
|
+
ctx: CardZoneInteractionContext,
|
|
454
|
+
) => ReactNode;
|
|
455
|
+
}) {
|
|
456
|
+
const cardSize = node.cardSize ?? "md";
|
|
457
|
+
if (node.renderZone) return <>{node.renderZone(zone)}</>;
|
|
458
|
+
const renderCardContent = node.renderCardContent ?? surfaceRenderCardContent;
|
|
459
|
+
return (
|
|
460
|
+
// `min-width: 0` lets the flex item shrink below its intrinsic
|
|
461
|
+
// content width when the row's other children need space. `Hand`
|
|
462
|
+
// self-clamps card positions to the measured container width via
|
|
463
|
+
// `useHandLayout`, so cards no longer bleed into sibling piles
|
|
464
|
+
// without us needing to clip the wrapper (which would also
|
|
465
|
+
// suppress the hover-lift translateY above the dock chrome).
|
|
466
|
+
<div
|
|
467
|
+
data-player-cards-fan={zone.zoneId}
|
|
468
|
+
style={{ flex: "1 1 280px", minWidth: 0 }}
|
|
469
|
+
>
|
|
470
|
+
<Hand
|
|
471
|
+
cards={zone.visibleCards}
|
|
472
|
+
cardSize={cardSize}
|
|
473
|
+
layout={node.layout}
|
|
474
|
+
renderCard={(props) => {
|
|
475
|
+
const ctx = zone.contextsByCardId.get(props.card.id);
|
|
476
|
+
const disabled = ctx?.disabled ?? true;
|
|
477
|
+
return (
|
|
478
|
+
<div
|
|
479
|
+
key={props.card.id}
|
|
480
|
+
className="absolute bottom-0 transition-all duration-150 ease-out"
|
|
481
|
+
style={{
|
|
482
|
+
left: props.x,
|
|
483
|
+
zIndex: props.zIndex,
|
|
484
|
+
transform: `translateY(${props.y}px)`,
|
|
485
|
+
}}
|
|
486
|
+
>
|
|
487
|
+
<Card
|
|
488
|
+
card={props.card}
|
|
489
|
+
selected={props.isSelected}
|
|
490
|
+
disabled={disabled}
|
|
491
|
+
size={cardSize}
|
|
492
|
+
onCardClick={
|
|
493
|
+
disabled
|
|
494
|
+
? undefined
|
|
495
|
+
: (cardId) => {
|
|
496
|
+
const clickedCtx = zone.contextsByCardId.get(cardId);
|
|
497
|
+
if (clickedCtx?.play) void clickedCtx.play();
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
renderContent={
|
|
501
|
+
renderCardContent
|
|
502
|
+
? (card) => {
|
|
503
|
+
const renderCtx = zone.contextsByCardId.get(card.id);
|
|
504
|
+
if (!renderCtx) return null;
|
|
505
|
+
return renderCardContent(card, renderCtx);
|
|
506
|
+
}
|
|
507
|
+
: undefined
|
|
508
|
+
}
|
|
509
|
+
/>
|
|
510
|
+
</div>
|
|
511
|
+
);
|
|
512
|
+
}}
|
|
513
|
+
/>
|
|
514
|
+
{zone.followUp ? (
|
|
515
|
+
<Fragment>
|
|
516
|
+
<CardZoneFollowUpForm<I, ParamsByKey>
|
|
517
|
+
key={zone.followUp.interactionKey}
|
|
518
|
+
descriptor={zone.followUp}
|
|
519
|
+
onDone={() => zone.setFollowUp(null)}
|
|
520
|
+
/>
|
|
521
|
+
</Fragment>
|
|
522
|
+
) : null}
|
|
523
|
+
</div>
|
|
524
|
+
);
|
|
525
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { InteractionForm } from "../../InteractionForm.js";
|
|
2
|
+
import { useInteractionHandle } from "../../../hooks/useInteractionHandle.js";
|
|
3
|
+
import type { InteractionDescriptor } from "../../../types/plugin-state.js";
|
|
4
|
+
import type {
|
|
5
|
+
InteractionDefaultedKeysOf,
|
|
6
|
+
InteractionParamsByKeyShape,
|
|
7
|
+
InteractionParamsOf,
|
|
8
|
+
} from "../types.js";
|
|
9
|
+
|
|
10
|
+
export function CardZoneFollowUpForm<
|
|
11
|
+
I extends string,
|
|
12
|
+
ParamsByKey extends Partial<InteractionParamsByKeyShape> = {},
|
|
13
|
+
>({
|
|
14
|
+
descriptor,
|
|
15
|
+
onDone,
|
|
16
|
+
}: {
|
|
17
|
+
descriptor: InteractionDescriptor<I>;
|
|
18
|
+
onDone: () => void;
|
|
19
|
+
}) {
|
|
20
|
+
const handle = useInteractionHandle<
|
|
21
|
+
InteractionParamsOf<ParamsByKey, I>,
|
|
22
|
+
InteractionDefaultedKeysOf<ParamsByKey, I>
|
|
23
|
+
>(descriptor);
|
|
24
|
+
return (
|
|
25
|
+
<InteractionForm
|
|
26
|
+
descriptor={descriptor}
|
|
27
|
+
handle={handle}
|
|
28
|
+
hiddenFields={[
|
|
29
|
+
"cardId" as keyof InteractionParamsOf<ParamsByKey, I> & string,
|
|
30
|
+
]}
|
|
31
|
+
onCancel={onDone}
|
|
32
|
+
onSubmitSuccess={onDone}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|