@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,71 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
import type { ButtonVariant } from "../../../theme/derive.js";
|
|
3
|
+
import type { InteractionHandle, InteractionParamsShape } from "../../../hooks/useInteractionHandle.js";
|
|
4
|
+
import type { InteractionDescriptor } from "../../../types/plugin-state.js";
|
|
5
|
+
export interface SubmittedActionConfig {
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
variant?: ButtonVariant;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Default button used by every surface that does not get an explicit
|
|
12
|
+
* renderer override. The button reads its visual style from the active
|
|
13
|
+
* {@link useTheme()} via {@link buttonStyle}; styling is no longer
|
|
14
|
+
* configurable per call site. Authors who need a different look should
|
|
15
|
+
* either:
|
|
16
|
+
*
|
|
17
|
+
* 1. Mount a different theme via `<ThemeProvider>`, or
|
|
18
|
+
* 2. Provide a per-interaction renderer override on the surrounding
|
|
19
|
+
* surface and draw their own button.
|
|
20
|
+
*
|
|
21
|
+
* The mapping from `descriptor.emphasis` to a {@link ButtonVariant}:
|
|
22
|
+
*
|
|
23
|
+
* - `"primary"` → `primary`
|
|
24
|
+
* - `"destructive"` → `danger`
|
|
25
|
+
* - `"secondary"` (or unset) → `secondary`
|
|
26
|
+
*
|
|
27
|
+
* Override the mapping per call site with the `variant` prop when the
|
|
28
|
+
* descriptor's emphasis hint is wrong (e.g. an unavailable confirm that
|
|
29
|
+
* should still look prominent).
|
|
30
|
+
*/
|
|
31
|
+
export interface DefaultInteractionButtonProps<Params extends InteractionParamsShape = InteractionParamsShape> {
|
|
32
|
+
descriptor: InteractionDescriptor;
|
|
33
|
+
handle: InteractionHandle<Params>;
|
|
34
|
+
/** Override the variant inferred from `descriptor.emphasis`. */
|
|
35
|
+
variant?: ButtonVariant;
|
|
36
|
+
/** Content slot before the descriptor's icon and label. */
|
|
37
|
+
leading?: ReactNode;
|
|
38
|
+
/** Content slot after the descriptor's label. */
|
|
39
|
+
trailing?: ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Prefer `descriptor.shortLabel` over `label`. Set by surfaces that
|
|
42
|
+
* group lots of interactions in a tight row.
|
|
43
|
+
*/
|
|
44
|
+
compact?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Button size token. Defaults to `md` (or `sm` when {@link compact}
|
|
47
|
+
* is set, preserving the historical sub-row geometry). Surfaces that
|
|
48
|
+
* resolve a salience tier — e.g. {@link PanelSurface} — pass
|
|
49
|
+
* `lg` for hero items so the visual weight matches the importance.
|
|
50
|
+
*/
|
|
51
|
+
size?: "sm" | "md" | "lg";
|
|
52
|
+
/** Submit params forwarded to `handle.submit`. Defaults to `{}`. */
|
|
53
|
+
params?: Record<string, unknown>;
|
|
54
|
+
/** Copy and visual overrides once this interaction has been submitted. */
|
|
55
|
+
whenSubmitted?: SubmittedActionConfig;
|
|
56
|
+
/** Additional inline style merged after the resolved button style. */
|
|
57
|
+
style?: CSSProperties;
|
|
58
|
+
/** Start expanded when the descriptor needs form input. */
|
|
59
|
+
defaultFormOpen?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Additional `data-*` attribute forwarded onto the `<button>` so
|
|
62
|
+
* surfaces can tag DOM nodes for tests / theming hooks (e.g.
|
|
63
|
+
* `data-panel-tier="hero"`).
|
|
64
|
+
*/
|
|
65
|
+
"data-panel-tier"?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @see DefaultInteractionButtonProps
|
|
69
|
+
*/
|
|
70
|
+
export declare function DefaultInteractionButton<Params extends InteractionParamsShape = InteractionParamsShape>({ descriptor, handle, variant: variantOverride, leading, trailing, compact, size, params, whenSubmitted, style, defaultFormOpen, "data-panel-tier": panelTier, }: DefaultInteractionButtonProps<Params>): import("react/jsx-runtime").JSX.Element;
|
|
71
|
+
//# sourceMappingURL=DefaultInteractionButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultInteractionButton.d.ts","sourceRoot":"","sources":["../../../../src/components/surfaces/internal/DefaultInteractionButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,EACV,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAQ5E,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,6BAA6B,CAC5C,MAAM,SAAS,sBAAsB,GAAG,sBAAsB;IAE9D,UAAU,EAAE,qBAAqB,CAAC;IAClC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAClC,gEAAgE;IAChE,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,0EAA0E;IAC1E,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,sEAAsE;IACtE,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,SAAS,sBAAsB,GAAG,sBAAsB,EAC9D,EACA,UAAU,EACV,MAAM,EACN,OAAO,EAAE,eAAe,EACxB,OAAO,EACP,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,MAAM,EACN,aAAa,EACb,KAAK,EACL,eAAuB,EACvB,iBAAiB,EAAE,SAAS,GAC7B,EAAE,6BAA6B,CAAC,MAAM,CAAC,2CA8GvC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useTheme } from "../../../theme/ThemeProvider.js";
|
|
4
|
+
import { InteractionForm, hasDefaultInteractionFormFields, } from "../../InteractionForm.js";
|
|
5
|
+
import { interactionLabel } from "../../../utils/interaction-labels.js";
|
|
6
|
+
import { ThemedButton } from "../../ThemedButton.js";
|
|
7
|
+
/**
|
|
8
|
+
* @see DefaultInteractionButtonProps
|
|
9
|
+
*/
|
|
10
|
+
export function DefaultInteractionButton({ descriptor, handle, variant: variantOverride, leading, trailing, compact, size, params, whenSubmitted, style, defaultFormOpen = false, "data-panel-tier": panelTier, }) {
|
|
11
|
+
const theme = useTheme();
|
|
12
|
+
const [pending, setPending] = useState(false);
|
|
13
|
+
const [formOpen, setFormOpen] = useState(defaultFormOpen);
|
|
14
|
+
const submitted = handle.status === "submitted";
|
|
15
|
+
const fallbackLabel = interactionLabel(descriptor);
|
|
16
|
+
const variant = submitted
|
|
17
|
+
? (whenSubmitted?.variant ?? "submitted")
|
|
18
|
+
: (variantOverride ?? "secondary");
|
|
19
|
+
const disabled = submitted ||
|
|
20
|
+
!descriptor.available ||
|
|
21
|
+
pending ||
|
|
22
|
+
handle.status === "submitting";
|
|
23
|
+
const needsForm = hasDefaultInteractionFormFields(descriptor);
|
|
24
|
+
const label = submitted
|
|
25
|
+
? (whenSubmitted?.label ?? fallbackLabel)
|
|
26
|
+
: fallbackLabel;
|
|
27
|
+
const tooltip = descriptor.available
|
|
28
|
+
? undefined
|
|
29
|
+
: formatUnavailableReason(descriptor.unavailableReason);
|
|
30
|
+
// Resolve size with the historical default — `compact` keeps `sm`
|
|
31
|
+
// for grouped sub-rows so existing call sites that rely on the
|
|
32
|
+
// tighter geometry don't change. Otherwise honour the explicit
|
|
33
|
+
// `size` prop, falling back to `md`.
|
|
34
|
+
const resolvedSize = size ?? (compact ? "sm" : "md");
|
|
35
|
+
const button = (_jsxs(ThemedButton, { type: "button", variant: variant, size: resolvedSize, pressed: pending || handle.status === "submitting", "aria-label": typeof label === "string" ? label : fallbackLabel, "aria-expanded": needsForm ? formOpen : undefined, "aria-disabled": disabled || undefined, "data-interaction-id": descriptor.interactionId, "data-emphasis": "secondary", "data-panel-tier": panelTier, "data-available": descriptor.available && !submitted ? "true" : "false", "data-action-state": submitted
|
|
36
|
+
? "submitted"
|
|
37
|
+
: handle.status === "submitting"
|
|
38
|
+
? "submitting"
|
|
39
|
+
: descriptor.available
|
|
40
|
+
? "available"
|
|
41
|
+
: "unavailable", title: tooltip, disabled: disabled, style: style, onClick: async (event) => {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
if (disabled)
|
|
44
|
+
return;
|
|
45
|
+
if (needsForm) {
|
|
46
|
+
setFormOpen((open) => !open);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
setPending(true);
|
|
50
|
+
try {
|
|
51
|
+
if (params !== undefined) {
|
|
52
|
+
await handle.submit(params);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
await handle.submitDraft();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Descriptor-level availability is authoritative; submission
|
|
60
|
+
// errors flow through the runtime's error channel. We swallow
|
|
61
|
+
// here so consumers without an error boundary don't see an
|
|
62
|
+
// unhandled rejection warning.
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
setPending(false);
|
|
66
|
+
}
|
|
67
|
+
}, children: [leading, submitted && whenSubmitted?.icon ? (_jsx("span", { "aria-hidden": true, style: { fontSize: "1.1em" }, children: whenSubmitted.icon })) : null, _jsx("span", { children: label }), trailing] }));
|
|
68
|
+
if (!needsForm)
|
|
69
|
+
return button;
|
|
70
|
+
return (_jsxs("span", { "data-default-interaction": true, style: {
|
|
71
|
+
display: "inline-flex",
|
|
72
|
+
flexDirection: "column",
|
|
73
|
+
alignItems: "stretch",
|
|
74
|
+
gap: theme.space[2],
|
|
75
|
+
}, children: [button, formOpen ? (_jsx(InteractionForm, { descriptor: descriptor, handle: handle, onCancel: () => setFormOpen(false), onSubmitSuccess: () => setFormOpen(false) })) : null] }));
|
|
76
|
+
}
|
|
77
|
+
function formatUnavailableReason(reason) {
|
|
78
|
+
if (reason === "INSUFFICIENT_RESOURCES") {
|
|
79
|
+
return "Insufficient resources";
|
|
80
|
+
}
|
|
81
|
+
return reason;
|
|
82
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { InteractionDescriptor } from "../../../types/plugin-state.js";
|
|
2
|
+
import type { InteractionActionState, InteractionDisabledReason } from "../../../utils/interaction-status.js";
|
|
3
|
+
import type { ViewCard } from "@dreamboard/sdk-types";
|
|
4
|
+
export interface CardZoneInteractionContext<I extends string = string> {
|
|
5
|
+
card: ViewCard;
|
|
6
|
+
interactions: ReadonlyArray<InteractionDescriptor<I>>;
|
|
7
|
+
play: ((params?: Record<string, unknown>) => Promise<void>) | null;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
disabledReason?: InteractionDisabledReason;
|
|
10
|
+
actionState: InteractionActionState;
|
|
11
|
+
selected: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function useCardZoneInteractions<I extends string = string>(zoneId: string, _options: {
|
|
14
|
+
surface: "hand" | "market";
|
|
15
|
+
}): {
|
|
16
|
+
cards: readonly ViewCard<string, string, Record<string, unknown>>[];
|
|
17
|
+
contexts: readonly CardZoneInteractionContext<I>[];
|
|
18
|
+
followUp: InteractionDescriptor<I> | null;
|
|
19
|
+
setFollowUp: import("react").Dispatch<import("react").SetStateAction<InteractionDescriptor<I> | null>>;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=useCardZoneInteractions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCardZoneInteractions.d.ts","sourceRoot":"","sources":["../../../../src/components/surfaces/internal/useCardZoneInteractions.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,qBAAqB,EAEtB,MAAM,gCAAgC,CAAC;AAUxC,OAAO,KAAK,EACV,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,WAAW,0BAA0B,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACnE,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;IACnE,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,yBAAyB,CAAC;IAC3C,WAAW,EAAE,sBAAsB,CAAC;IACpC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAC/D,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE;IAAE,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE;;;;;EA0NzC"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from "react";
|
|
2
|
+
import { useStore } from "zustand";
|
|
3
|
+
import { useInteractionUiStore } from "../../../context/InteractionDraftContext.js";
|
|
4
|
+
import { usePluginSession } from "../../../context/PluginSessionContext.js";
|
|
5
|
+
import { usePluginState } from "../../../context/PluginStateContext.js";
|
|
6
|
+
import { useRuntimeContext } from "../../../context/RuntimeContext.js";
|
|
7
|
+
import { hasInteractionFieldErrors, inputByTarget, interactionArmScope, interactionInputKeys, isInputValueReady, toggleManyValue, validateInteractionInputDomains, } from "../../../utils/interaction-inputs.js";
|
|
8
|
+
export function useCardZoneInteractions(zoneId, _options) {
|
|
9
|
+
const runtime = useRuntimeContext();
|
|
10
|
+
const { controllingPlayerId } = usePluginSession();
|
|
11
|
+
const draftStore = useInteractionUiStore();
|
|
12
|
+
const draftSnapshot = useStore(draftStore, (state) => state.drafts);
|
|
13
|
+
const submittingSnapshot = useStore(draftStore, (state) => state.submitting);
|
|
14
|
+
const [followUp, setFollowUp] = useState(null);
|
|
15
|
+
const zone = usePluginState((s) => s.gameplay.zones?.[zoneId]);
|
|
16
|
+
const simultaneousPhase = usePluginState((s) => s.gameplay.simultaneousPhase);
|
|
17
|
+
const cards = useMemo(() => {
|
|
18
|
+
if (!zone)
|
|
19
|
+
return [];
|
|
20
|
+
const list = [];
|
|
21
|
+
for (const cardId of zone.cardIds) {
|
|
22
|
+
const serialized = zone.cardsById[cardId];
|
|
23
|
+
if (!serialized)
|
|
24
|
+
continue;
|
|
25
|
+
try {
|
|
26
|
+
list.push(JSON.parse(serialized));
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// Skip malformed card snapshots defensively.
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return list;
|
|
33
|
+
}, [zone]);
|
|
34
|
+
const submitInteractionDraft = useCallback(async (descriptor, params) => {
|
|
35
|
+
if (!controllingPlayerId)
|
|
36
|
+
return;
|
|
37
|
+
if (draftStore.isSubmitting(descriptor.interactionKey))
|
|
38
|
+
return;
|
|
39
|
+
draftStore.setSubmitting(descriptor.interactionKey, true);
|
|
40
|
+
try {
|
|
41
|
+
await runtime.submitInteraction(controllingPlayerId, descriptor.interactionId, params);
|
|
42
|
+
draftStore.clearInput(descriptor.interactionKey);
|
|
43
|
+
const armScope = interactionArmScope(descriptor);
|
|
44
|
+
if (draftStore.getArmed(armScope) === descriptor.interactionKey) {
|
|
45
|
+
draftStore.arm(armScope, null);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
draftStore.setSubmitting(descriptor.interactionKey, false);
|
|
50
|
+
}
|
|
51
|
+
}, [controllingPlayerId, draftStore, runtime]);
|
|
52
|
+
const playCardInteraction = useCallback(async (card, descriptor, params) => {
|
|
53
|
+
if (!controllingPlayerId)
|
|
54
|
+
return;
|
|
55
|
+
const cardInput = resolveCardInput(descriptor, card.id);
|
|
56
|
+
if (!cardInput)
|
|
57
|
+
return;
|
|
58
|
+
const cardInputKey = cardInput.key;
|
|
59
|
+
const currentDraft = draftStore.getDraft(descriptor.interactionKey);
|
|
60
|
+
const nextCardValue = cardInput.domain.type === "target" &&
|
|
61
|
+
cardInput.domain.selection?.mode === "many"
|
|
62
|
+
? toggleManyValue(currentDraft[cardInputKey], card.id, cardInput.domain.selection)
|
|
63
|
+
: card.id;
|
|
64
|
+
const nextDraft = {
|
|
65
|
+
...currentDraft,
|
|
66
|
+
...(params ?? {}),
|
|
67
|
+
[cardInputKey]: nextCardValue,
|
|
68
|
+
};
|
|
69
|
+
for (const [key, value] of Object.entries(params ?? {})) {
|
|
70
|
+
draftStore.setInput(descriptor.interactionKey, key, value);
|
|
71
|
+
}
|
|
72
|
+
draftStore.setInput(descriptor.interactionKey, cardInputKey, nextCardValue);
|
|
73
|
+
if (cardInput.domain.type === "target" &&
|
|
74
|
+
cardInput.domain.selection?.mode === "many") {
|
|
75
|
+
if (descriptor.commit.mode === "autoWhenReady" &&
|
|
76
|
+
isDraftReady(descriptor, nextDraft)) {
|
|
77
|
+
await submitInteractionDraft(descriptor, nextDraft);
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const remaining = descriptor.inputs.filter((input) => {
|
|
82
|
+
const value = nextDraft[input.key] ??
|
|
83
|
+
("defaultValue" in input ? input.defaultValue : undefined);
|
|
84
|
+
return input.key !== cardInputKey && value === undefined;
|
|
85
|
+
});
|
|
86
|
+
const needsBoardTarget = descriptor.inputs.some((input) => {
|
|
87
|
+
const value = nextDraft[input.key] ??
|
|
88
|
+
("defaultValue" in input ? input.defaultValue : undefined);
|
|
89
|
+
return (input.key !== cardInputKey &&
|
|
90
|
+
input.domain.type === "target" &&
|
|
91
|
+
value === undefined);
|
|
92
|
+
});
|
|
93
|
+
if (needsBoardTarget) {
|
|
94
|
+
setFollowUp(null);
|
|
95
|
+
draftStore.arm(interactionArmScope(descriptor), descriptor.interactionKey);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (remaining.length > 0) {
|
|
99
|
+
setFollowUp(descriptor);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (!isDraftReady(descriptor, nextDraft) ||
|
|
103
|
+
descriptor.commit.mode !== "autoWhenReady") {
|
|
104
|
+
setFollowUp(null);
|
|
105
|
+
draftStore.arm(interactionArmScope(descriptor), descriptor.interactionKey);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
await submitInteractionDraft(descriptor, nextDraft);
|
|
109
|
+
}, [controllingPlayerId, draftStore, submitInteractionDraft]);
|
|
110
|
+
const contexts = useMemo(() => {
|
|
111
|
+
if (!zone)
|
|
112
|
+
return [];
|
|
113
|
+
return cards.map((card) => {
|
|
114
|
+
const interactions = zone.playableByCardId[card.id] ?? [];
|
|
115
|
+
const submittedInteraction = interactions.find((d) => controllingPlayerId !== null &&
|
|
116
|
+
simultaneousPhase?.phaseName === d.phaseName &&
|
|
117
|
+
simultaneousPhase.interactionId === d.interactionId &&
|
|
118
|
+
simultaneousPhase.sealedPlayerIds.includes(controllingPlayerId));
|
|
119
|
+
const submittingInteraction = interactions.find((d) => draftStore.isSubmitting(d.interactionKey));
|
|
120
|
+
const selected = interactions.some((d) => isCardSelected(d, card.id, draftStore.getDraft(d.interactionKey)));
|
|
121
|
+
const blockedState = submittedInteraction
|
|
122
|
+
? "submitted"
|
|
123
|
+
: submittingInteraction
|
|
124
|
+
? "submitting"
|
|
125
|
+
: null;
|
|
126
|
+
const available = blockedState
|
|
127
|
+
? []
|
|
128
|
+
: interactions.filter((d) => d.available !== false &&
|
|
129
|
+
isCardInteractionSelectable(d, card.id, draftStore.getDraft(d.interactionKey)));
|
|
130
|
+
const first = available.length === 1 ? available[0] : undefined;
|
|
131
|
+
const limited = !blockedState &&
|
|
132
|
+
interactions.some((d) => d.available !== false &&
|
|
133
|
+
!isCardInteractionSelectable(d, card.id, draftStore.getDraft(d.interactionKey)));
|
|
134
|
+
const disabled = blockedState !== null || available.length === 0;
|
|
135
|
+
return {
|
|
136
|
+
card,
|
|
137
|
+
interactions,
|
|
138
|
+
play: first
|
|
139
|
+
? (params) => playCardInteraction(card, first, params)
|
|
140
|
+
: null,
|
|
141
|
+
disabled,
|
|
142
|
+
disabledReason: blockedState ??
|
|
143
|
+
(limited ? "selection-limit" : disabled ? "unavailable" : undefined),
|
|
144
|
+
actionState: blockedState ?? (disabled ? "unavailable" : "available"),
|
|
145
|
+
selected,
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
}, [
|
|
149
|
+
cards,
|
|
150
|
+
controllingPlayerId,
|
|
151
|
+
draftSnapshot,
|
|
152
|
+
draftStore,
|
|
153
|
+
playCardInteraction,
|
|
154
|
+
simultaneousPhase,
|
|
155
|
+
submittingSnapshot,
|
|
156
|
+
zone,
|
|
157
|
+
]);
|
|
158
|
+
return { cards, contexts, followUp, setFollowUp };
|
|
159
|
+
}
|
|
160
|
+
function isCardSelected(descriptor, cardId, draft) {
|
|
161
|
+
const input = resolveCardInput(descriptor, cardId);
|
|
162
|
+
if (!input)
|
|
163
|
+
return false;
|
|
164
|
+
const current = draft[input.key];
|
|
165
|
+
return Array.isArray(current)
|
|
166
|
+
? current.map((item) => String(item)).includes(cardId)
|
|
167
|
+
: String(current) === cardId;
|
|
168
|
+
}
|
|
169
|
+
function isCardInteractionSelectable(descriptor, cardId, draft) {
|
|
170
|
+
const input = resolveCardInput(descriptor, cardId);
|
|
171
|
+
if (!input || input.domain.type !== "target")
|
|
172
|
+
return true;
|
|
173
|
+
const selection = input.domain.selection;
|
|
174
|
+
if (selection?.mode !== "many" || !selection.distinct)
|
|
175
|
+
return true;
|
|
176
|
+
const current = draft[input.key];
|
|
177
|
+
if (!Array.isArray(current))
|
|
178
|
+
return true;
|
|
179
|
+
if (current.map((item) => String(item)).includes(cardId))
|
|
180
|
+
return true;
|
|
181
|
+
return selection.max === undefined || current.length < selection.max;
|
|
182
|
+
}
|
|
183
|
+
function isDraftReady(descriptor, draft) {
|
|
184
|
+
const fieldErrors = validateInteractionInputDomains(descriptor, draft);
|
|
185
|
+
if (hasInteractionFieldErrors(fieldErrors))
|
|
186
|
+
return false;
|
|
187
|
+
return interactionInputKeys(descriptor).every((key) => {
|
|
188
|
+
const input = descriptor.inputs.find((candidate) => candidate.key === key);
|
|
189
|
+
const value = draft[key] ??
|
|
190
|
+
(input && "defaultValue" in input ? input.defaultValue : undefined);
|
|
191
|
+
return input ? isInputValueReady(input, value) : value !== undefined;
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
function resolveCardInput(descriptor, cardId) {
|
|
195
|
+
const targetInput = inputByTarget(descriptor, "card", cardId);
|
|
196
|
+
if (targetInput)
|
|
197
|
+
return targetInput;
|
|
198
|
+
if (interactionInputKeys(descriptor).includes("cardId")) {
|
|
199
|
+
return descriptor.inputs.find((input) => input.key === "cardId") ?? null;
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { InteractionHandle, InteractionParamsShape } from "../../hooks/useInteractionHandle.js";
|
|
3
|
+
import type { InteractionDescriptor } from "../../types/plugin-state.js";
|
|
4
|
+
import type { SubmittedActionConfig } from "./internal/DefaultInteractionButton.js";
|
|
5
|
+
export type InteractionParamsByKeyShape = Record<string, InteractionParamsShape | {
|
|
6
|
+
params: InteractionParamsShape;
|
|
7
|
+
defaulted?: string;
|
|
8
|
+
}>;
|
|
9
|
+
export type InteractionParamsOf<ParamsByKey extends Partial<InteractionParamsByKeyShape>, Key extends string> = Key extends keyof ParamsByKey ? ParamsByKey[Key] extends {
|
|
10
|
+
params: infer Params extends InteractionParamsShape;
|
|
11
|
+
} ? Params : ParamsByKey[Key] extends InteractionParamsShape ? ParamsByKey[Key] : InteractionParamsShape : InteractionParamsShape;
|
|
12
|
+
export type InteractionDefaultedKeysOf<ParamsByKey extends Partial<InteractionParamsByKeyShape>, Key extends string> = Key extends keyof ParamsByKey ? ParamsByKey[Key] extends {
|
|
13
|
+
defaulted?: infer Defaulted extends string;
|
|
14
|
+
} ? Extract<Defaulted, keyof InteractionParamsOf<ParamsByKey, Key> & string> : never : never;
|
|
15
|
+
/**
|
|
16
|
+
* Per-interaction renderer overrides for a surface. Partial: when omitted
|
|
17
|
+
* entirely, the surface uses its built-in default renderer for every
|
|
18
|
+
* interaction. When present, every key MUST be a valid member of `I` —
|
|
19
|
+
* typos are a compile-time error against the generated `*Interactions`
|
|
20
|
+
* id alias from `@dreamboard/ui-contract`.
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* import type { PanelInteractions } from "@dreamboard/ui-contract";
|
|
24
|
+
*
|
|
25
|
+
* <PanelSurface<PanelInteractions> render={{ rollDice: ... }} />
|
|
26
|
+
* // ✗ <PanelSurface<PanelInteractions> render={{ rolldice: ... }} />
|
|
27
|
+
* // ^^^^^^^^^ typo: not assignable
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* If you want compile-time exhaustiveness (every interaction id in `I`
|
|
31
|
+
* must have an explicit renderer), use {@link ExhaustiveSurfaceRenderMap}
|
|
32
|
+
* instead.
|
|
33
|
+
*/
|
|
34
|
+
export interface DefaultInteractionRenderConfig {
|
|
35
|
+
whenSubmitted?: SubmittedActionConfig;
|
|
36
|
+
}
|
|
37
|
+
export type SurfaceRenderEntry<D, H> = ((descriptor: D, handle: H) => ReactNode) | DefaultInteractionRenderConfig;
|
|
38
|
+
export type SurfaceRenderMap<I extends string, ParamsByKey extends Partial<InteractionParamsByKeyShape> = {}> = {
|
|
39
|
+
[K in I]?: SurfaceRenderEntry<InteractionDescriptor<K>, InteractionHandle<InteractionParamsOf<ParamsByKey, K>, InteractionDefaultedKeysOf<ParamsByKey, K>>>;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Exhaustive (required) variant of {@link SurfaceRenderMap}. Every key of
|
|
43
|
+
* `I` MUST have an explicit renderer — useful when authors want the
|
|
44
|
+
* compiler to enforce that no interaction id slips through without a
|
|
45
|
+
* deliberate visual treatment.
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* import type { PanelInteractions } from "@dreamboard/ui-contract";
|
|
49
|
+
* import type { ExhaustiveSurfaceRenderMap } from "@dreamboard/ui-sdk";
|
|
50
|
+
*
|
|
51
|
+
* const panelRenderers: ExhaustiveSurfaceRenderMap<PanelInteractions> = {
|
|
52
|
+
* rollDice: ...,
|
|
53
|
+
* buildSettlement: ...,
|
|
54
|
+
* // omitting any id here is a compile-time error
|
|
55
|
+
* };
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export type ExhaustiveSurfaceRenderMap<I extends string, ParamsByKey extends Partial<InteractionParamsByKeyShape> = {}> = Required<SurfaceRenderMap<I, ParamsByKey>>;
|
|
59
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/surfaces/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EACV,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAEpF,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAC9C,MAAM,EACJ,sBAAsB,GACtB;IACE,MAAM,EAAE,sBAAsB,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CACJ,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAC7B,WAAW,SAAS,OAAO,CAAC,2BAA2B,CAAC,EACxD,GAAG,SAAS,MAAM,IAChB,GAAG,SAAS,MAAM,WAAW,GAC7B,WAAW,CAAC,GAAG,CAAC,SAAS;IACvB,MAAM,EAAE,MAAM,MAAM,SAAS,sBAAsB,CAAC;CACrD,GACC,MAAM,GACN,WAAW,CAAC,GAAG,CAAC,SAAS,sBAAsB,GAC7C,WAAW,CAAC,GAAG,CAAC,GAChB,sBAAsB,GAC1B,sBAAsB,CAAC;AAE3B,MAAM,MAAM,0BAA0B,CACpC,WAAW,SAAS,OAAO,CAAC,2BAA2B,CAAC,EACxD,GAAG,SAAS,MAAM,IAChB,GAAG,SAAS,MAAM,WAAW,GAC7B,WAAW,CAAC,GAAG,CAAC,SAAS;IAAE,SAAS,CAAC,EAAE,MAAM,SAAS,SAAS,MAAM,CAAA;CAAE,GACrE,OAAO,CAAC,SAAS,EAAE,MAAM,mBAAmB,CAAC,WAAW,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,GACxE,KAAK,GACP,KAAK,CAAC;AAEV;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,8BAA8B;IAC7C,aAAa,CAAC,EAAE,qBAAqB,CAAC;CACvC;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAC/B,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,SAAS,CAAC,GACzC,8BAA8B,CAAC;AAEnC,MAAM,MAAM,gBAAgB,CAC1B,CAAC,SAAS,MAAM,EAChB,WAAW,SAAS,OAAO,CAAC,2BAA2B,CAAC,GAAG,EAAE,IAC3D;KACD,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,kBAAkB,CAC3B,qBAAqB,CAAC,CAAC,CAAC,EACxB,iBAAiB,CACf,mBAAmB,CAAC,WAAW,EAAE,CAAC,CAAC,EACnC,0BAA0B,CAAC,WAAW,EAAE,CAAC,CAAC,CAC3C,CACF;CACF,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,0BAA0B,CACpC,CAAC,SAAS,MAAM,EAChB,WAAW,SAAS,OAAO,CAAC,2BAA2B,CAAC,GAAG,EAAE,IAC3D,QAAQ,CAAC,gBAAgB,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ClientParamSchema {
|
|
2
|
+
safeParse: (value: unknown) => {
|
|
3
|
+
success: true;
|
|
4
|
+
data: Record<string, unknown>;
|
|
5
|
+
} | {
|
|
6
|
+
success: false;
|
|
7
|
+
error: {
|
|
8
|
+
issues: ReadonlyArray<{
|
|
9
|
+
path: readonly PropertyKey[];
|
|
10
|
+
message: string;
|
|
11
|
+
}>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export type ClientParamSchemaMap = Readonly<Record<string, Readonly<Record<string, ClientParamSchema>>>>;
|
|
16
|
+
export declare function ClientParamSchemaProvider({ schemas, children, }: {
|
|
17
|
+
schemas?: ClientParamSchemaMap;
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function useClientParamSchema(phaseName: string | null | undefined, interactionId: string): ClientParamSchema | undefined;
|
|
21
|
+
//# sourceMappingURL=ClientParamSchemaContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientParamSchemaContext.d.ts","sourceRoot":"","sources":["../../src/context/ClientParamSchemaContext.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KACtB;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAChD;QACE,OAAO,EAAE,KAAK,CAAC;QACf,KAAK,EAAE;YACL,MAAM,EAAE,aAAa,CAAC;gBACpB,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;gBAC7B,OAAO,EAAE,MAAM,CAAC;aACjB,CAAC,CAAC;SACJ,CAAC;KACH,CAAC;CACP;AAED,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CACzC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAC5D,CAAC;AAIF,wBAAgB,yBAAyB,CAAC,EACxC,OAAO,EACP,QAAQ,GACT,EAAE;IACD,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,2CAMA;AAED,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,aAAa,EAAE,MAAM,GACpB,iBAAiB,GAAG,SAAS,CAI/B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const ClientParamSchemaContext = createContext({});
|
|
4
|
+
export function ClientParamSchemaProvider({ schemas, children, }) {
|
|
5
|
+
return (_jsx(ClientParamSchemaContext.Provider, { value: schemas ?? {}, children: children }));
|
|
6
|
+
}
|
|
7
|
+
export function useClientParamSchema(phaseName, interactionId) {
|
|
8
|
+
const schemas = useContext(ClientParamSchemaContext);
|
|
9
|
+
if (!phaseName)
|
|
10
|
+
return undefined;
|
|
11
|
+
return schemas[phaseName]?.[interactionId];
|
|
12
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type StoreApi } from "zustand/vanilla";
|
|
3
|
+
type Draft = Readonly<Record<string, unknown>>;
|
|
4
|
+
interface DraftState {
|
|
5
|
+
drafts: Readonly<Record<string, Draft>>;
|
|
6
|
+
arms: Readonly<Record<string, string>>;
|
|
7
|
+
submitting: Readonly<Record<string, true>>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Imperative API exposed to `useInteractionHandle` and `<BoardSurface>`.
|
|
11
|
+
* Intentionally small; the vanilla zustand store underneath powers
|
|
12
|
+
* fine-grained subscriptions via {@link useDraft} and {@link useArmed}.
|
|
13
|
+
*/
|
|
14
|
+
export interface InteractionUiStore {
|
|
15
|
+
/** Read the current draft for an interaction id. Never undefined. */
|
|
16
|
+
getDraft(interactionId: string): Draft;
|
|
17
|
+
/** Merge a single input key into the draft. Creates the draft if needed. */
|
|
18
|
+
setInput(interactionId: string, key: string, value: unknown): void;
|
|
19
|
+
/** Clear a single input, or the whole draft if `key` is omitted. */
|
|
20
|
+
clearInput(interactionId: string, key?: string): void;
|
|
21
|
+
/** Clear every draft and arming state. */
|
|
22
|
+
clearAll(): void;
|
|
23
|
+
/** Which interaction (if any) is currently armed on the given surface. */
|
|
24
|
+
getArmed(surface: string): string | null;
|
|
25
|
+
/** Arm a specific interaction on a surface. Pass `null` to disarm. */
|
|
26
|
+
arm(surface: string, interactionId: string | null): void;
|
|
27
|
+
/** True while a local submission is in flight before the host echo arrives. */
|
|
28
|
+
isSubmitting(interactionId: string): boolean;
|
|
29
|
+
/** Mark or clear a local submission in flight. */
|
|
30
|
+
setSubmitting(interactionId: string, submitting: boolean): void;
|
|
31
|
+
}
|
|
32
|
+
/** Vanilla zustand store implementing {@link InteractionUiStore}. */
|
|
33
|
+
export type InteractionUiStoreApi = StoreApi<DraftState> & InteractionUiStore;
|
|
34
|
+
export declare function createInteractionUiStore(): InteractionUiStoreApi;
|
|
35
|
+
/**
|
|
36
|
+
* React provider that holds draft input state shared across every surface
|
|
37
|
+
* inside the tree. Auto-installed by `<PluginRuntime>`; authors rarely
|
|
38
|
+
* mount it directly. Mount manually when rendering surface components in
|
|
39
|
+
* isolation (e.g., Storybook, snapshot tests).
|
|
40
|
+
*
|
|
41
|
+
* ```tsx
|
|
42
|
+
* <InteractionUiProvider>
|
|
43
|
+
* <PanelSurface />
|
|
44
|
+
* <BoardSurface>{(ctx) => <Board ctx={ctx} />}</BoardSurface>
|
|
45
|
+
* </InteractionUiProvider>
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function InteractionUiProvider({ children, store, }: {
|
|
49
|
+
children: ReactNode;
|
|
50
|
+
store?: InteractionUiStoreApi;
|
|
51
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
/**
|
|
53
|
+
* Access the active draft store. Falls back to an inert in-memory store
|
|
54
|
+
* when no provider is mounted, so surface hooks remain callable in bare
|
|
55
|
+
* test harnesses without crashing — draft state simply isn't shared
|
|
56
|
+
* across components in that case.
|
|
57
|
+
*/
|
|
58
|
+
export declare function useInteractionUiStore(): InteractionUiStoreApi;
|
|
59
|
+
/**
|
|
60
|
+
* Subscribe to the draft for a single interaction id with per-slice
|
|
61
|
+
* re-renders. Returns a stable empty object when the draft is unset.
|
|
62
|
+
*/
|
|
63
|
+
export declare function useInteractionDraft(interactionId: string): Draft;
|
|
64
|
+
/** Subscribe to the armed interaction id on a given surface. */
|
|
65
|
+
export declare function useArmedInteraction(surface: string): string | null;
|
|
66
|
+
/** Subscribe to local submitting status for a single interaction key. */
|
|
67
|
+
export declare function useInteractionSubmitting(interactionId: string): boolean;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=InteractionDraftContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InteractionDraftContext.d.ts","sourceRoot":"","sources":["../../src/context/InteractionDraftContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG7D,KAAK,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAI/C,UAAU,UAAU;IAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IACxC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACvC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;CAC5C;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,KAAK,CAAC;IACvC,4EAA4E;IAC5E,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACnE,oEAAoE;IACpE,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtD,0CAA0C;IAC1C,QAAQ,IAAI,IAAI,CAAC;IACjB,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACzC,sEAAsE;IACtE,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IACzD,+EAA+E;IAC/E,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7C,kDAAkD;IAClD,aAAa,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;CACjE;AAED,qEAAqE;AACrE,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,kBAAkB,CAAC;AAE9E,wBAAgB,wBAAwB,IAAI,qBAAqB,CA0FhE;AAID;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,qBAAqB,CAAC;CAC/B,2CAOA;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,qBAAqB,CAI7D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,KAAK,CAQhE;AAED,gEAAgE;AAChE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGlE;AAED,yEAAyE;AACzE,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAMvE"}
|