@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,185 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* End-of-game winner display and scoreboard overlay.
|
|
4
|
+
*
|
|
5
|
+
* Visual styling derives entirely from the active {@link useTheme}
|
|
6
|
+
* (semantic + intent + elevation tokens). The win moment is the
|
|
7
|
+
* Peak-end anchor of the session, so the surface intentionally pushes
|
|
8
|
+
* the loudest theme signals (display typeface, primary intent,
|
|
9
|
+
* elevation.overlay) without inventing one-off colours.
|
|
10
|
+
*/
|
|
11
|
+
import { motion } from "framer-motion";
|
|
12
|
+
import { Trophy, Home, Crown, Medal } from "lucide-react";
|
|
13
|
+
import { useEffect, useState } from "react";
|
|
14
|
+
import { Dialog, DialogContent, DialogTitle } from "../internal/ui/dialog.js";
|
|
15
|
+
import { useTheme } from "../theme/ThemeProvider.js";
|
|
16
|
+
import { chipStyle, intentForVariant, surfaceStyle, } from "../theme/derive.js";
|
|
17
|
+
import { ThemedButton } from "./ThemedButton.js";
|
|
18
|
+
function rankIntent(rank) {
|
|
19
|
+
if (rank === 1)
|
|
20
|
+
return "warning"; // gold
|
|
21
|
+
if (rank === 2)
|
|
22
|
+
return "secondary"; // silver
|
|
23
|
+
if (rank === 3)
|
|
24
|
+
return "info"; // bronze-ish (no bronze in palette)
|
|
25
|
+
return "secondary";
|
|
26
|
+
}
|
|
27
|
+
function RankIcon({ rank, theme }) {
|
|
28
|
+
const intent = intentForVariant(theme, rankIntent(rank));
|
|
29
|
+
if (rank === 1) {
|
|
30
|
+
return (_jsx(Trophy, { width: 20, height: 20, strokeWidth: 3, "aria-hidden": "true", style: { color: intent.solid } }));
|
|
31
|
+
}
|
|
32
|
+
if (rank === 2 || rank === 3) {
|
|
33
|
+
return (_jsx(Medal, { width: 20, height: 20, strokeWidth: 2.5, "aria-hidden": "true", style: { color: intent.solid } }));
|
|
34
|
+
}
|
|
35
|
+
return (_jsxs("span", { style: {
|
|
36
|
+
width: 20,
|
|
37
|
+
textAlign: "center",
|
|
38
|
+
color: theme.semantic.text.muted,
|
|
39
|
+
fontFamily: theme.typography.fontFamily.tabular,
|
|
40
|
+
fontWeight: theme.typography.fontWeight.bold,
|
|
41
|
+
}, children: ["#", rank] }));
|
|
42
|
+
}
|
|
43
|
+
export function GameEndDisplay({ isGameOver, scores, winnerMessage, showDetails = false, onReturnToLobby, className, }) {
|
|
44
|
+
const theme = useTheme();
|
|
45
|
+
const reducedMotion = theme.motion.reducedMotion === "true";
|
|
46
|
+
const [isOpen, setIsOpen] = useState(isGameOver);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
setIsOpen(isGameOver);
|
|
49
|
+
}, [isGameOver]);
|
|
50
|
+
if (!isGameOver)
|
|
51
|
+
return null;
|
|
52
|
+
const winner = scores.find((s) => s.isWinner) || scores[0];
|
|
53
|
+
const sortedScores = [...scores].sort((a, b) => b.score - a.score);
|
|
54
|
+
const winningIntent = theme.semantic.intent.warning;
|
|
55
|
+
const title = `${winner?.name ?? "Game"} Wins!`;
|
|
56
|
+
return (_jsx(Dialog, { open: isOpen, onOpenChange: setIsOpen, children: _jsxs(DialogContent, { className: `border-0 p-6 text-center shadow-none sm:max-w-lg ${className ?? ""}`, overlayClassName: "bg-black/50 backdrop-blur-md", "aria-describedby": undefined, style: {
|
|
57
|
+
...surfaceStyle(theme, { tone: "sheet", radius: "hud" }),
|
|
58
|
+
width: "100%",
|
|
59
|
+
maxWidth: 480,
|
|
60
|
+
padding: `${theme.space[8]} ${theme.space[6]}`,
|
|
61
|
+
textAlign: "center",
|
|
62
|
+
boxShadow: theme.elevation.overlay,
|
|
63
|
+
overflow: "hidden",
|
|
64
|
+
backgroundImage: `radial-gradient(circle at top, ${winningIntent.soft} 0%, ${theme.semantic.surface.sheet} 60%)`,
|
|
65
|
+
fontFamily: theme.typography.fontFamily.body,
|
|
66
|
+
}, children: [_jsx(DialogTitle, { className: "sr-only", children: title }), _jsx(motion.div, { initial: reducedMotion
|
|
67
|
+
? { scale: 1 }
|
|
68
|
+
: { scale: 0.95, rotate: -180, opacity: 0 }, animate: reducedMotion ? { scale: 1 } : { scale: 1, rotate: 0, opacity: 1 }, transition: {
|
|
69
|
+
type: "spring",
|
|
70
|
+
stiffness: 200,
|
|
71
|
+
damping: 15,
|
|
72
|
+
delay: reducedMotion ? 0 : 0.2,
|
|
73
|
+
}, style: {
|
|
74
|
+
marginBottom: theme.space[6],
|
|
75
|
+
display: "inline-flex",
|
|
76
|
+
alignItems: "center",
|
|
77
|
+
justifyContent: "center",
|
|
78
|
+
width: 96,
|
|
79
|
+
height: 96,
|
|
80
|
+
borderRadius: theme.radius.pill,
|
|
81
|
+
background: winningIntent.soft,
|
|
82
|
+
border: `3px solid ${winningIntent.border}`,
|
|
83
|
+
boxShadow: theme.elevation.lifted,
|
|
84
|
+
}, children: _jsx(Trophy, { width: 48, height: 48, strokeWidth: 2.5, "aria-hidden": "true", style: { color: winningIntent.solid } }) }), _jsxs(motion.div, { initial: reducedMotion ? { opacity: 0 } : { opacity: 0, y: 10 }, animate: reducedMotion ? { opacity: 1 } : { opacity: 1, y: 0 }, transition: { delay: reducedMotion ? 0 : 0.4 }, children: [_jsx("h2", { "aria-hidden": "true", style: {
|
|
85
|
+
margin: 0,
|
|
86
|
+
fontFamily: theme.typography.fontFamily.display,
|
|
87
|
+
fontSize: theme.typography.fontSize["3xl"],
|
|
88
|
+
fontWeight: theme.typography.fontWeight.bold,
|
|
89
|
+
color: theme.semantic.text.primary,
|
|
90
|
+
marginBottom: theme.space[2],
|
|
91
|
+
lineHeight: theme.typography.lineHeight.tight,
|
|
92
|
+
}, children: title }), winnerMessage && (_jsx("p", { style: {
|
|
93
|
+
margin: 0,
|
|
94
|
+
marginBottom: theme.space[6],
|
|
95
|
+
display: "inline-block",
|
|
96
|
+
...chipStyle(theme, { variant: "warning", size: "md" }),
|
|
97
|
+
fontSize: theme.typography.fontSize.sm,
|
|
98
|
+
}, children: winnerMessage }))] }), _jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { delay: reducedMotion ? 0 : 0.6 }, style: {
|
|
99
|
+
display: "flex",
|
|
100
|
+
flexDirection: "column",
|
|
101
|
+
gap: theme.space[3],
|
|
102
|
+
marginBottom: theme.space[8],
|
|
103
|
+
textAlign: "left",
|
|
104
|
+
}, role: "list", "aria-label": "Final scores", children: sortedScores.map((player, index) => {
|
|
105
|
+
const rank = index + 1;
|
|
106
|
+
const intent = intentForVariant(theme, rankIntent(rank));
|
|
107
|
+
const isWinner = player.isWinner ?? rank === 1;
|
|
108
|
+
return (_jsxs(motion.div, { initial: reducedMotion ? { opacity: 0 } : { opacity: 0, x: -20 }, animate: reducedMotion ? { opacity: 1 } : { opacity: 1, x: 0 }, transition: {
|
|
109
|
+
delay: reducedMotion ? 0 : 0.6 + index * 0.1,
|
|
110
|
+
}, style: {
|
|
111
|
+
display: "flex",
|
|
112
|
+
alignItems: "center",
|
|
113
|
+
justifyContent: "space-between",
|
|
114
|
+
padding: theme.space[3],
|
|
115
|
+
background: isWinner
|
|
116
|
+
? intent.soft
|
|
117
|
+
: theme.semantic.surface.card,
|
|
118
|
+
border: `1px solid ${isWinner ? intent.border : theme.semantic.border.subtle}`,
|
|
119
|
+
borderRadius: theme.radius.lg,
|
|
120
|
+
boxShadow: isWinner
|
|
121
|
+
? theme.elevation.hover
|
|
122
|
+
: theme.elevation.rest,
|
|
123
|
+
}, role: "listitem", children: [_jsxs("div", { style: {
|
|
124
|
+
display: "flex",
|
|
125
|
+
alignItems: "center",
|
|
126
|
+
gap: theme.space[3],
|
|
127
|
+
}, children: [_jsx(RankIcon, { rank: rank, theme: theme }), _jsx("span", { style: {
|
|
128
|
+
fontFamily: theme.typography.fontFamily.body,
|
|
129
|
+
fontSize: theme.typography.fontSize.lg,
|
|
130
|
+
fontWeight: theme.typography.fontWeight.bold,
|
|
131
|
+
color: isWinner
|
|
132
|
+
? intent.onSoft
|
|
133
|
+
: theme.semantic.text.primary,
|
|
134
|
+
}, children: player.name }), isWinner && (_jsx(Crown, { width: 20, height: 20, strokeWidth: 3, "aria-label": "Winner", style: { color: intent.solid } }))] }), _jsx("span", { style: {
|
|
135
|
+
fontFamily: theme.typography.fontFamily.tabular,
|
|
136
|
+
fontSize: theme.typography.fontSize["2xl"],
|
|
137
|
+
fontWeight: theme.typography.fontWeight.bold,
|
|
138
|
+
color: isWinner
|
|
139
|
+
? intent.onSoft
|
|
140
|
+
: theme.semantic.text.primary,
|
|
141
|
+
paddingInline: theme.space[2],
|
|
142
|
+
paddingBlock: theme.space[0.5],
|
|
143
|
+
background: theme.semantic.surface.inset,
|
|
144
|
+
borderRadius: theme.radius.md,
|
|
145
|
+
border: `1px solid ${theme.semantic.border.subtle}`,
|
|
146
|
+
}, children: player.score })] }, player.playerId));
|
|
147
|
+
}) }), showDetails && winner?.details && (_jsxs(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { delay: reducedMotion ? 0 : 0.8 }, style: {
|
|
148
|
+
marginBottom: theme.space[8],
|
|
149
|
+
padding: theme.space[4],
|
|
150
|
+
background: theme.semantic.surface.inset,
|
|
151
|
+
border: `1px dashed ${theme.semantic.border.default}`,
|
|
152
|
+
borderRadius: theme.radius.lg,
|
|
153
|
+
textAlign: "left",
|
|
154
|
+
}, children: [_jsxs("h3", { style: {
|
|
155
|
+
margin: 0,
|
|
156
|
+
marginBottom: theme.space[3],
|
|
157
|
+
fontFamily: theme.typography.fontFamily.display,
|
|
158
|
+
fontSize: theme.typography.fontSize.md,
|
|
159
|
+
fontWeight: theme.typography.fontWeight.bold,
|
|
160
|
+
color: theme.semantic.text.primary,
|
|
161
|
+
display: "flex",
|
|
162
|
+
alignItems: "center",
|
|
163
|
+
gap: theme.space[2],
|
|
164
|
+
}, children: [_jsx("span", { style: {
|
|
165
|
+
width: 8,
|
|
166
|
+
height: 8,
|
|
167
|
+
background: theme.semantic.intent.primary.solid,
|
|
168
|
+
borderRadius: theme.radius.pill,
|
|
169
|
+
display: "inline-block",
|
|
170
|
+
} }), "Score Breakdown"] }), _jsx("div", { style: {
|
|
171
|
+
display: "flex",
|
|
172
|
+
flexDirection: "column",
|
|
173
|
+
gap: theme.space[2],
|
|
174
|
+
}, children: Object.entries(winner.details).map(([key, value]) => (_jsxs("div", { style: {
|
|
175
|
+
display: "flex",
|
|
176
|
+
justifyContent: "space-between",
|
|
177
|
+
fontSize: theme.typography.fontSize.md,
|
|
178
|
+
color: theme.semantic.text.primary,
|
|
179
|
+
}, children: [_jsx("span", { style: { textTransform: "capitalize" }, children: key.replace(/([A-Z])/g, " $1") }), _jsx("span", { style: {
|
|
180
|
+
fontFamily: theme.typography.fontFamily.tabular,
|
|
181
|
+
fontWeight: theme.typography.fontWeight.bold,
|
|
182
|
+
}, children: value })] }, key))) })] })), onReturnToLobby && (_jsx(motion.div, { initial: reducedMotion ? { opacity: 0 } : { opacity: 0, y: 10 }, animate: reducedMotion ? { opacity: 1 } : { opacity: 1, y: 0 }, transition: { delay: reducedMotion ? 0 : 1 }, style: { display: "flex", justifyContent: "center" }, children: _jsxs(ThemedButton, { type: "button", variant: "primary", size: "lg", onClick: onReturnToLobby, style: {
|
|
183
|
+
gap: theme.space[2],
|
|
184
|
+
}, children: [_jsx(Home, { size: 20, strokeWidth: 3, "aria-hidden": "true" }), "Return to Lobby"] }) }))] }) }));
|
|
185
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GameSkeleton - Loading state component
|
|
3
|
+
*
|
|
4
|
+
* Displays animated placeholders while game content loads
|
|
5
|
+
*/
|
|
6
|
+
export interface GameSkeletonProps {
|
|
7
|
+
variant?: "default" | "cards" | "players" | "minimal";
|
|
8
|
+
message?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function GameSkeleton({ variant, message, className, }: GameSkeletonProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=GameSkeleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GameSkeleton.d.ts","sourceRoot":"","sources":["../../src/components/GameSkeleton.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA8DD,wBAAgB,YAAY,CAAC,EAC3B,OAAmB,EACnB,OAA2B,EAC3B,SAAS,GACV,EAAE,iBAAiB,2CAwKnB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* GameSkeleton - Loading state component
|
|
4
|
+
*
|
|
5
|
+
* Displays animated placeholders while game content loads
|
|
6
|
+
*/
|
|
7
|
+
import { motion } from "framer-motion";
|
|
8
|
+
import { clsx } from "clsx";
|
|
9
|
+
import { Loader2 } from "lucide-react";
|
|
10
|
+
const CARD_SKELETON_KEYS = ["card-1", "card-2", "card-3", "card-4", "card-5"];
|
|
11
|
+
const PLAYER_SKELETON_KEYS = ["player-1", "player-2", "player-3", "player-4"];
|
|
12
|
+
const HAND_SKELETON_KEYS = [
|
|
13
|
+
"hand-card-1",
|
|
14
|
+
"hand-card-2",
|
|
15
|
+
"hand-card-3",
|
|
16
|
+
"hand-card-4",
|
|
17
|
+
"hand-card-5",
|
|
18
|
+
"hand-card-6",
|
|
19
|
+
];
|
|
20
|
+
function SkeletonBox({ className, animate = true, }) {
|
|
21
|
+
return (_jsx(motion.div, { className: clsx("bg-slate-200 rounded", className), animate: animate
|
|
22
|
+
? {
|
|
23
|
+
opacity: [0.5, 1, 0.5],
|
|
24
|
+
}
|
|
25
|
+
: undefined, transition: {
|
|
26
|
+
duration: 1.5,
|
|
27
|
+
repeat: Infinity,
|
|
28
|
+
ease: "easeInOut",
|
|
29
|
+
}, "aria-hidden": "true" }));
|
|
30
|
+
}
|
|
31
|
+
function CardSkeleton({ size = "md" }) {
|
|
32
|
+
const sizeClasses = {
|
|
33
|
+
sm: "w-16 h-24 sm:w-20 sm:h-28",
|
|
34
|
+
md: "w-20 h-32 sm:w-24 sm:h-36",
|
|
35
|
+
lg: "w-24 h-36 sm:w-32 sm:h-48",
|
|
36
|
+
};
|
|
37
|
+
return (_jsx(motion.div, { className: clsx("rounded-lg sm:rounded-xl overflow-hidden", sizeClasses[size]), initial: { opacity: 0, y: 20 }, animate: { opacity: 1, y: 0 }, transition: { type: "spring", stiffness: 300, damping: 25 }, children: _jsx(SkeletonBox, { className: "w-full h-full" }) }));
|
|
38
|
+
}
|
|
39
|
+
function PlayerSkeleton() {
|
|
40
|
+
return (_jsxs("div", { className: "flex items-center gap-3 p-3 bg-white/80 rounded-xl border-2 border-slate-200", children: [_jsx(SkeletonBox, { className: "w-12 h-12 sm:w-14 sm:h-14 rounded-full" }), _jsxs("div", { className: "flex-1 space-y-2", children: [_jsx(SkeletonBox, { className: "h-4 w-24 sm:w-32" }), _jsx(SkeletonBox, { className: "h-3 w-16 sm:w-20" })] })] }));
|
|
41
|
+
}
|
|
42
|
+
export function GameSkeleton({ variant = "default", message = "Loading game...", className, }) {
|
|
43
|
+
if (variant === "minimal") {
|
|
44
|
+
return (_jsxs("div", { className: clsx("flex flex-col items-center justify-center min-h-screen p-8 bg-gradient-to-br from-slate-50 to-slate-100", className), role: "status", "aria-live": "polite", "aria-label": message, children: [_jsx(motion.div, { animate: { rotate: 360 }, transition: { duration: 1, repeat: Infinity, ease: "linear" }, children: _jsx(Loader2, { size: 48, className: "text-blue-500", "aria-hidden": "true" }) }), _jsx(motion.p, { className: "mt-4 text-slate-600 text-lg font-medium", initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { delay: 0.2 }, children: message })] }));
|
|
45
|
+
}
|
|
46
|
+
if (variant === "cards") {
|
|
47
|
+
return (_jsxs("div", { className: clsx("flex flex-col items-center justify-center min-h-screen p-4 sm:p-8", className), role: "status", "aria-live": "polite", "aria-label": message, children: [_jsx("div", { className: "flex gap-2 sm:gap-4 mb-8", children: CARD_SKELETON_KEYS.map((key, i) => (_jsx(motion.div, { initial: { opacity: 0, y: 20 }, animate: { opacity: 1, y: 0 }, transition: { delay: i * 0.1 }, children: _jsx(CardSkeleton, {}) }, key))) }), _jsx(motion.p, { className: "text-slate-600 text-sm sm:text-base", initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { delay: 0.5 }, children: message })] }));
|
|
48
|
+
}
|
|
49
|
+
if (variant === "players") {
|
|
50
|
+
return (_jsxs("div", { className: clsx("flex flex-col items-center justify-center min-h-screen p-4 sm:p-8", className), role: "status", "aria-live": "polite", "aria-label": message, children: [_jsx("div", { className: "w-full max-w-md space-y-4 mb-8", children: PLAYER_SKELETON_KEYS.map((key, i) => (_jsx(motion.div, { initial: { opacity: 0, x: -20 }, animate: { opacity: 1, x: 0 }, transition: { delay: i * 0.1 }, children: _jsx(PlayerSkeleton, {}) }, key))) }), _jsx(motion.p, { className: "text-slate-600 text-sm sm:text-base", initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { delay: 0.4 }, children: message })] }));
|
|
51
|
+
}
|
|
52
|
+
// Default variant - complete game layout
|
|
53
|
+
return (_jsxs("div", { className: clsx("min-h-screen p-4 sm:p-8 bg-gradient-to-br from-slate-50 to-slate-100", className), role: "status", "aria-live": "polite", "aria-label": message, children: [_jsxs("div", { className: "flex items-center justify-between mb-6 sm:mb-8", children: [_jsx(SkeletonBox, { className: "h-8 w-32 sm:w-48" }), _jsx(SkeletonBox, { className: "h-8 w-20 sm:w-32" })] }), _jsx("div", { className: "grid grid-cols-2 lg:grid-cols-4 gap-3 sm:gap-4 mb-6 sm:mb-8", children: PLAYER_SKELETON_KEYS.map((key, i) => (_jsx(motion.div, { initial: { opacity: 0, scale: 0.9 }, animate: { opacity: 1, scale: 1 }, transition: { delay: i * 0.1 }, children: _jsx(PlayerSkeleton, {}) }, key))) }), _jsx("div", { className: "mb-6 sm:mb-8", children: _jsx(SkeletonBox, { className: "w-full h-48 sm:h-64 rounded-2xl" }) }), _jsx("div", { className: "flex justify-center gap-2 sm:gap-4", children: HAND_SKELETON_KEYS.map((key, i) => (_jsx(motion.div, { initial: { opacity: 0, y: 20 }, animate: { opacity: 1, y: 0 }, transition: { delay: 0.4 + i * 0.05 }, children: _jsx(CardSkeleton, {}) }, key))) }), _jsxs(motion.div, { className: "flex items-center justify-center mt-8", initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { delay: 0.8 }, children: [_jsx(Loader2, { size: 24, className: "text-blue-500 animate-spin mr-3", "aria-hidden": "true" }), _jsx("p", { className: "text-slate-600 text-sm sm:text-base font-medium", children: message })] })] }));
|
|
54
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Player hand with adaptive overlap, automatic drawer fallback, and keyboard navigation.
|
|
3
|
+
* For full control, use the `useHandLayout` hook directly.
|
|
4
|
+
*/
|
|
5
|
+
import { type CardSize, type HandLayout } from "../hooks/useHandLayout.js";
|
|
6
|
+
import { type ViewCard } from "./Card.js";
|
|
7
|
+
import type { ReactNode } from "react";
|
|
8
|
+
export interface HandCardRenderProps<CardData extends ViewCard = ViewCard> {
|
|
9
|
+
card: CardData;
|
|
10
|
+
index: number;
|
|
11
|
+
isHovered: boolean;
|
|
12
|
+
isSelected: boolean;
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
zIndex: number;
|
|
16
|
+
cardDimensions: {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface HandDrawerRenderProps<CardData extends ViewCard = ViewCard> {
|
|
22
|
+
cards: readonly CardData[];
|
|
23
|
+
selectedIds: readonly string[];
|
|
24
|
+
cardCount: number;
|
|
25
|
+
selectedCount: number;
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
cardDimensions: {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface HandEmptyRenderProps {
|
|
33
|
+
layout: HandLayout;
|
|
34
|
+
}
|
|
35
|
+
export interface HandContainerRenderProps {
|
|
36
|
+
totalWidth: number;
|
|
37
|
+
totalHeight: number;
|
|
38
|
+
cardDimensions: {
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
};
|
|
42
|
+
children: ReactNode;
|
|
43
|
+
onMouseMove: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
44
|
+
onMouseLeave: () => void;
|
|
45
|
+
}
|
|
46
|
+
export interface HandProps<CardData extends ViewCard = ViewCard> {
|
|
47
|
+
cards: readonly CardData[];
|
|
48
|
+
selectedIds?: readonly string[];
|
|
49
|
+
disabled?: boolean;
|
|
50
|
+
cardSize?: CardSize;
|
|
51
|
+
layout?: HandLayout;
|
|
52
|
+
"aria-label"?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Called when a card is clicked. Wired into the default `renderCard`;
|
|
55
|
+
* ignored when the caller supplies a custom `renderCard`.
|
|
56
|
+
*/
|
|
57
|
+
onCardClick?: (cardId: string) => void;
|
|
58
|
+
/** Per-card content renderer forwarded to the default `<Card>`. */
|
|
59
|
+
renderCardContent?: (card: CardData) => ReactNode;
|
|
60
|
+
/** Defaults to a positioned `<Card>` honouring click/selection state. */
|
|
61
|
+
renderCard?: (props: HandCardRenderProps<CardData>) => ReactNode;
|
|
62
|
+
/** Defaults to a compact "View N cards" button that's keyboard-activatable. */
|
|
63
|
+
renderDrawer?: (props: HandDrawerRenderProps<CardData>) => ReactNode;
|
|
64
|
+
/** Defaults to a subtle "No cards in hand" placeholder. */
|
|
65
|
+
renderEmpty?: (props: HandEmptyRenderProps) => ReactNode;
|
|
66
|
+
renderContainer?: (props: HandContainerRenderProps) => ReactNode;
|
|
67
|
+
className?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Hand component with customizable rendering via render props.
|
|
71
|
+
*
|
|
72
|
+
* `renderCard`, `renderDrawer`, and `renderEmpty` are all optional — the
|
|
73
|
+
* defaults render the built-in `<Card>` with the supplied `onCardClick` /
|
|
74
|
+
* `renderCardContent`, a compact drawer fallback on small screens, and a
|
|
75
|
+
* muted empty placeholder. Override any of them when you need a different
|
|
76
|
+
* visual treatment.
|
|
77
|
+
*
|
|
78
|
+
* For complete control over layout and interactions, use the
|
|
79
|
+
* `useHandLayout` hook directly.
|
|
80
|
+
*
|
|
81
|
+
* @example Zero-config
|
|
82
|
+
* ```tsx
|
|
83
|
+
* <Hand cards={cards} onCardClick={(id) => play(id)} />
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @example Custom card content
|
|
87
|
+
* ```tsx
|
|
88
|
+
* <Hand
|
|
89
|
+
* cards={cards}
|
|
90
|
+
* onCardClick={(id) => play(id)}
|
|
91
|
+
* renderCardContent={(card) => <DevCardFace card={card} />}
|
|
92
|
+
* />
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function Hand<CardData extends ViewCard = ViewCard>({ cards, selectedIds, disabled, cardSize, layout, "aria-label": ariaLabel, onCardClick, renderCardContent, renderCard, renderDrawer, renderEmpty, renderContainer, className, }: HandProps<CardData>): import("react/jsx-runtime").JSX.Element;
|
|
96
|
+
export { useHandLayout } from "../hooks/useHandLayout.js";
|
|
97
|
+
export type { UseHandLayoutOptions, UseHandLayoutReturn, CardPositionProps, CardSize, HandLayout, } from "../hooks/useHandLayout.js";
|
|
98
|
+
export type { ViewCard } from "./Card.js";
|
|
99
|
+
//# sourceMappingURL=Hand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Hand.d.ts","sourceRoot":"","sources":["../../src/components/Hand.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,UAAU,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAQ,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,MAAM,WAAW,mBAAmB,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ;IACvE,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACnD;AAED,MAAM,WAAW,qBAAqB,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ;IACzE,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC3B,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACnD;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IAC3D,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,SAAS,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ;IAC7D,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,mEAAmE;IACnE,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,SAAS,CAAC;IAClD,yEAAyE;IACzE,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,CAAC,QAAQ,CAAC,KAAK,SAAS,CAAC;IACjE,+EAA+E;IAC/E,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,CAAC,QAAQ,CAAC,KAAK,SAAS,CAAC;IACrE,2DAA2D;IAC3D,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,SAAS,CAAC;IACzD,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,SAAS,CAAC;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAsDD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,IAAI,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ,EAAE,EACzD,KAAK,EACL,WAAgC,EAChC,QAAgB,EAChB,QAAe,EACf,MAAkB,EAClB,YAAY,EAAE,SAAuB,EACrC,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,eAAe,EACf,SAAS,GACV,EAAE,SAAS,CAAC,QAAQ,CAAC,2CAkNrB;AAGD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,UAAU,GACX,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Player hand with adaptive overlap, automatic drawer fallback, and keyboard navigation.
|
|
4
|
+
* For full control, use the `useHandLayout` hook directly.
|
|
5
|
+
*/
|
|
6
|
+
import { clsx } from "clsx";
|
|
7
|
+
import { useCallback, useState } from "react";
|
|
8
|
+
import { useHandLayout, } from "../hooks/useHandLayout.js";
|
|
9
|
+
import { Card } from "./Card.js";
|
|
10
|
+
import { useTheme } from "../theme/ThemeProvider.js";
|
|
11
|
+
const EMPTY_SELECTED_IDS = [];
|
|
12
|
+
/**
|
|
13
|
+
* Drawer-mode placeholder rendered when the hand can't fit on screen.
|
|
14
|
+
* Pulls colours, radii, shadow, and typography from the active theme so
|
|
15
|
+
* apps that swap themes get a consistent look without overriding
|
|
16
|
+
* `renderDrawer`. Authors needing a full drawer UI (modals, swipe
|
|
17
|
+
* sheets) opt in via `renderDrawer`.
|
|
18
|
+
*/
|
|
19
|
+
function DefaultDrawer({ cardCount, selectedCount, }) {
|
|
20
|
+
const theme = useTheme();
|
|
21
|
+
const label = `View ${cardCount} card${cardCount === 1 ? "" : "s"}${selectedCount > 0 ? ` (${selectedCount} selected)` : ""}`;
|
|
22
|
+
return (_jsx("div", { style: {
|
|
23
|
+
background: theme.semantic.surface.card,
|
|
24
|
+
border: `1px solid ${theme.semantic.border.default}`,
|
|
25
|
+
borderRadius: theme.radius.md,
|
|
26
|
+
paddingBlock: theme.space[1.5],
|
|
27
|
+
paddingInline: theme.space[3],
|
|
28
|
+
boxShadow: theme.elevation.rest,
|
|
29
|
+
fontFamily: theme.typography.fontFamily.body,
|
|
30
|
+
fontSize: theme.typography.fontSize.xs,
|
|
31
|
+
fontWeight: theme.typography.fontWeight.bold,
|
|
32
|
+
color: theme.semantic.text.muted,
|
|
33
|
+
}, children: label }));
|
|
34
|
+
}
|
|
35
|
+
function DefaultEmpty() {
|
|
36
|
+
const theme = useTheme();
|
|
37
|
+
return (_jsx("span", { style: {
|
|
38
|
+
fontFamily: theme.typography.fontFamily.body,
|
|
39
|
+
fontSize: theme.typography.fontSize.xs,
|
|
40
|
+
color: theme.semantic.text.disabled,
|
|
41
|
+
}, children: "No cards in hand" }));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Hand component with customizable rendering via render props.
|
|
45
|
+
*
|
|
46
|
+
* `renderCard`, `renderDrawer`, and `renderEmpty` are all optional — the
|
|
47
|
+
* defaults render the built-in `<Card>` with the supplied `onCardClick` /
|
|
48
|
+
* `renderCardContent`, a compact drawer fallback on small screens, and a
|
|
49
|
+
* muted empty placeholder. Override any of them when you need a different
|
|
50
|
+
* visual treatment.
|
|
51
|
+
*
|
|
52
|
+
* For complete control over layout and interactions, use the
|
|
53
|
+
* `useHandLayout` hook directly.
|
|
54
|
+
*
|
|
55
|
+
* @example Zero-config
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <Hand cards={cards} onCardClick={(id) => play(id)} />
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @example Custom card content
|
|
61
|
+
* ```tsx
|
|
62
|
+
* <Hand
|
|
63
|
+
* cards={cards}
|
|
64
|
+
* onCardClick={(id) => play(id)}
|
|
65
|
+
* renderCardContent={(card) => <DevCardFace card={card} />}
|
|
66
|
+
* />
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export function Hand({ cards, selectedIds = EMPTY_SELECTED_IDS, disabled = false, cardSize = "md", layout = "overlap", "aria-label": ariaLabel = "Your hand", onCardClick, renderCardContent, renderCard, renderDrawer, renderEmpty, renderContainer, className, }) {
|
|
70
|
+
const defaultRenderCard = useCallback((props) => (_jsx("div", { className: "absolute bottom-0 transition-all duration-150 ease-out", style: {
|
|
71
|
+
left: props.x,
|
|
72
|
+
zIndex: props.zIndex,
|
|
73
|
+
transform: `translateY(${props.y}px)`,
|
|
74
|
+
}, children: _jsx(Card, { card: props.card, selected: props.isSelected, disabled: disabled, size: cardSize, onCardClick: onCardClick, renderContent: renderCardContent }) }, props.card.id)), [cardSize, disabled, onCardClick, renderCardContent]);
|
|
75
|
+
const effectiveRenderCard = renderCard ?? defaultRenderCard;
|
|
76
|
+
const effectiveRenderDrawer = renderDrawer ?? DefaultDrawer;
|
|
77
|
+
const effectiveRenderEmpty = renderEmpty ?? DefaultEmpty;
|
|
78
|
+
const cardCount = cards.length;
|
|
79
|
+
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
80
|
+
const { containerRef, cardsContainerRef, totalWidth, useDrawerMode, cardDimensions, constants, hoveredIndex, handleMouseMove, handleMouseLeave, getCardPosition, } = useHandLayout({
|
|
81
|
+
cardCount,
|
|
82
|
+
cardSize,
|
|
83
|
+
layout,
|
|
84
|
+
});
|
|
85
|
+
const selectedCount = cards.filter((c) => selectedIds.includes(c.id)).length;
|
|
86
|
+
const handleKeyDown = useCallback((e) => {
|
|
87
|
+
if (cardCount === 0)
|
|
88
|
+
return;
|
|
89
|
+
switch (e.key) {
|
|
90
|
+
case "ArrowLeft":
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
setFocusedIndex((prev) => (prev <= 0 ? cardCount - 1 : prev - 1));
|
|
93
|
+
break;
|
|
94
|
+
case "ArrowRight":
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
setFocusedIndex((prev) => (prev >= cardCount - 1 ? 0 : prev + 1));
|
|
97
|
+
break;
|
|
98
|
+
case "Home":
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
setFocusedIndex(0);
|
|
101
|
+
break;
|
|
102
|
+
case "End":
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
setFocusedIndex(cardCount - 1);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}, [cardCount]);
|
|
108
|
+
// Drawer mode - delegate to user's render function
|
|
109
|
+
if (useDrawerMode && layout === "overlap" && cardCount > 0) {
|
|
110
|
+
return (_jsx("div", { ref: containerRef, className: clsx("relative w-full flex items-center justify-center py-4", className), role: "group", "aria-label": `${ariaLabel} - ${cardCount} card${cardCount !== 1 ? "s" : ""}`, children: effectiveRenderDrawer({
|
|
111
|
+
cards,
|
|
112
|
+
selectedIds,
|
|
113
|
+
cardCount,
|
|
114
|
+
selectedCount,
|
|
115
|
+
disabled,
|
|
116
|
+
cardDimensions,
|
|
117
|
+
}) }));
|
|
118
|
+
}
|
|
119
|
+
// Empty hand
|
|
120
|
+
if (cardCount === 0) {
|
|
121
|
+
return (_jsx("div", { ref: containerRef, className: clsx("relative w-full flex items-end justify-center py-4 sm:py-6", className), role: "group", "aria-label": `${ariaLabel} - empty`, children: effectiveRenderEmpty({ layout }) }));
|
|
122
|
+
}
|
|
123
|
+
const renderedCards = cards.map((card, index) => {
|
|
124
|
+
const isSelected = selectedIds.includes(card.id);
|
|
125
|
+
const isFocused = focusedIndex === index;
|
|
126
|
+
const isHovered = hoveredIndex === index || isFocused;
|
|
127
|
+
const position = getCardPosition(index, isHovered, isSelected);
|
|
128
|
+
return effectiveRenderCard({
|
|
129
|
+
card,
|
|
130
|
+
index,
|
|
131
|
+
isHovered,
|
|
132
|
+
isSelected,
|
|
133
|
+
x: position.x,
|
|
134
|
+
y: position.y,
|
|
135
|
+
zIndex: position.zIndex,
|
|
136
|
+
cardDimensions,
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
if (layout === "spread") {
|
|
140
|
+
return (_jsx("div", { ref: containerRef, className: clsx("relative w-full flex items-end justify-center py-4 sm:py-6", className), role: "group", "aria-label": `${ariaLabel} - ${cardCount} card${cardCount !== 1 ? "s" : ""}`, tabIndex: 0, onKeyDown: handleKeyDown, onBlur: () => setFocusedIndex(-1), children: _jsx("div", { className: "flex gap-1 justify-center flex-wrap", children: renderedCards }) }));
|
|
141
|
+
}
|
|
142
|
+
// Overlap/Stack layout
|
|
143
|
+
const totalHeight = cardDimensions.height + constants.hoverLift + 8;
|
|
144
|
+
const containerProps = {
|
|
145
|
+
totalWidth,
|
|
146
|
+
totalHeight,
|
|
147
|
+
cardDimensions,
|
|
148
|
+
children: renderedCards,
|
|
149
|
+
onMouseMove: handleMouseMove,
|
|
150
|
+
onMouseLeave: handleMouseLeave,
|
|
151
|
+
};
|
|
152
|
+
// Allow custom container rendering
|
|
153
|
+
if (renderContainer) {
|
|
154
|
+
return (_jsx("div", { ref: containerRef, className: clsx("relative w-full flex items-end justify-center py-4 sm:py-6 overflow-visible", className), role: "group", "aria-label": `${ariaLabel} - ${cardCount} card${cardCount !== 1 ? "s" : ""}`, children: renderContainer(containerProps) }));
|
|
155
|
+
}
|
|
156
|
+
return (_jsx("div", { ref: containerRef, className: clsx("relative w-full flex items-end justify-center py-4 sm:py-6 overflow-visible", className), role: "group", "aria-label": `${ariaLabel} - ${cardCount} card${cardCount !== 1 ? "s" : ""}`, tabIndex: 0, onKeyDown: handleKeyDown, onBlur: () => setFocusedIndex(-1), children: _jsx("div", { ref: cardsContainerRef, className: "relative", style: {
|
|
157
|
+
width: layout === "overlap" ? totalWidth : undefined,
|
|
158
|
+
height: totalHeight,
|
|
159
|
+
}, onMouseMove: handleMouseMove, onMouseLeave: handleMouseLeave, children: renderedCards }) }));
|
|
160
|
+
}
|
|
161
|
+
// Re-export types and hook for users who want full control
|
|
162
|
+
export { useHandLayout } from "../hooks/useHandLayout.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
export type HandDockMode = "inline" | "drawer" | "hidden";
|
|
3
|
+
export type HandDockPlacement = "bottom-left" | "bottom-center" | "bottom-right";
|
|
4
|
+
export interface HandDockToggleContext {
|
|
5
|
+
label: string;
|
|
6
|
+
count: number;
|
|
7
|
+
open: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface HandDockPresentation {
|
|
10
|
+
/**
|
|
11
|
+
* `inline` preserves the normal shell hand strip. `drawer` collapses the
|
|
12
|
+
* zone behind a viewport-safe toggle. `hidden` suppresses the zone entirely.
|
|
13
|
+
*/
|
|
14
|
+
mode?: HandDockMode;
|
|
15
|
+
/** Initial drawer state. Defaults to closed. */
|
|
16
|
+
defaultOpen?: boolean;
|
|
17
|
+
/** Where the drawer toggle/tray docks in the viewport. */
|
|
18
|
+
placement?: HandDockPlacement;
|
|
19
|
+
/** Toggle label override. Receives card count and open state. */
|
|
20
|
+
toggleLabel?: ReactNode | ((context: HandDockToggleContext) => ReactNode);
|
|
21
|
+
/** Width of the opened tray. */
|
|
22
|
+
maxWidth?: CSSProperties["maxWidth"];
|
|
23
|
+
/** Height of the opened tray before it scrolls. */
|
|
24
|
+
maxHeight?: CSSProperties["maxHeight"];
|
|
25
|
+
/** Extra style escape hatch for the outer dock. */
|
|
26
|
+
style?: CSSProperties;
|
|
27
|
+
}
|
|
28
|
+
export interface HandDockProps {
|
|
29
|
+
label: string;
|
|
30
|
+
count: number;
|
|
31
|
+
presentation?: HandDockPresentation;
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
}
|
|
34
|
+
export declare function HandDock({ label, count, presentation, children, }: HandDockProps): import("react/jsx-runtime").JSX.Element | null;
|
|
35
|
+
//# sourceMappingURL=HandDock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HandDock.d.ts","sourceRoot":"","sources":["../../src/components/HandDock.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAa5E,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC1D,MAAM,MAAM,iBAAiB,GACzB,aAAa,GACb,eAAe,GACf,cAAc,CAAC;AAEnB,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,iEAAiE;IACjE,WAAW,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,OAAO,EAAE,qBAAqB,KAAK,SAAS,CAAC,CAAC;IAC1E,gCAAgC;IAChC,QAAQ,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IACrC,mDAAmD;IACnD,SAAS,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACvC,mDAAmD;IACnD,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAyDD,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,KAAK,EACL,YAAY,EACZ,QAAQ,GACT,EAAE,aAAa,kDAgJf"}
|