@dreamboard-games/ui-sdk 0.0.43 → 0.0.46
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/dist/components/ActionButton.d.ts.map +1 -1
- package/dist/components/ActionButton.js +2 -1
- package/dist/components/Card.d.ts +1 -1
- package/dist/components/Card.d.ts.map +1 -1
- package/dist/components/DiceRoller.d.ts +3 -2
- package/dist/components/DiceRoller.d.ts.map +1 -1
- package/dist/components/DiceRoller.js +4 -13
- package/dist/components/ErrorBoundary.d.ts.map +1 -1
- package/dist/components/ErrorBoundary.js +94 -2
- package/dist/components/InteractionForm.d.ts +1 -1
- package/dist/components/InteractionForm.d.ts.map +1 -1
- package/dist/components/InteractionForm.js +29 -15
- package/dist/components/PrimaryActionButton.d.ts.map +1 -1
- package/dist/components/PrimaryActionButton.js +7 -6
- package/dist/components/ResourceCounter.d.ts +59 -25
- package/dist/components/ResourceCounter.d.ts.map +1 -1
- package/dist/components/ResourceCounter.js +106 -115
- package/dist/components/Toast.d.ts +13 -6
- package/dist/components/Toast.d.ts.map +1 -1
- package/dist/components/Toast.js +10 -5
- package/dist/components/board/HexGrid.js +6 -6
- package/dist/components/board/target-layer.d.ts +18 -2
- package/dist/components/board/target-layer.d.ts.map +1 -1
- package/dist/components/board/target-layer.js +20 -3
- package/dist/components/index.d.ts +3 -4
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +3 -4
- package/dist/components/surfaces/InboxSurface.d.ts.map +1 -1
- package/dist/components/surfaces/InboxSurface.js +2 -6
- package/dist/components/surfaces/PlayerCardsSurface.js +2 -2
- package/dist/components/surfaces/internal/CardZoneRoutedForm.d.ts +7 -0
- package/dist/components/surfaces/internal/CardZoneRoutedForm.d.ts.map +1 -0
- package/dist/components/surfaces/internal/CardZoneRoutedForm.js +9 -0
- package/dist/components/surfaces/internal/DefaultInteractionButton.d.ts.map +1 -1
- package/dist/components/surfaces/internal/DefaultInteractionButton.js +5 -8
- package/dist/components/surfaces/internal/useCardZoneInteractions.d.ts +2 -2
- package/dist/components/surfaces/internal/useCardZoneInteractions.d.ts.map +1 -1
- package/dist/components/surfaces/internal/useCardZoneInteractions.js +19 -43
- package/dist/context/InteractionDraftContext.d.ts +11 -2
- package/dist/context/InteractionDraftContext.d.ts.map +1 -1
- package/dist/context/InteractionDraftContext.js +41 -4
- package/dist/defaults/components.d.ts +0 -5
- package/dist/defaults/components.d.ts.map +1 -1
- package/dist/defaults/components.js +7 -11
- package/dist/hooks/useBoardInteractions.d.ts +35 -12
- package/dist/hooks/useBoardInteractions.d.ts.map +1 -1
- package/dist/hooks/useBoardInteractions.js +186 -82
- package/dist/hooks/useInteractionHandle.d.ts +1 -1
- package/dist/hooks/useInteractionHandle.d.ts.map +1 -1
- package/dist/hooks/useInteractionHandle.js +12 -27
- package/dist/index.d.ts +11 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -14
- package/dist/primitives/board.d.ts +53 -3
- package/dist/primitives/board.d.ts.map +1 -1
- package/dist/primitives/board.js +65 -41
- package/dist/primitives/dialog-lifecycle.d.ts +17 -0
- package/dist/primitives/dialog-lifecycle.d.ts.map +1 -0
- package/dist/primitives/dialog-lifecycle.js +24 -0
- package/dist/primitives/dice.d.ts +31 -0
- package/dist/primitives/dice.d.ts.map +1 -0
- package/dist/primitives/dice.js +33 -0
- package/dist/primitives/game.d.ts +55 -0
- package/dist/primitives/game.d.ts.map +1 -0
- package/dist/primitives/game.js +101 -0
- package/dist/primitives/index.d.ts +7 -4
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +7 -4
- package/dist/primitives/interaction-form-binding.d.ts +12 -0
- package/dist/primitives/interaction-form-binding.d.ts.map +1 -0
- package/dist/primitives/interaction-form-binding.js +14 -0
- package/dist/primitives/interaction-submit.d.ts +23 -0
- package/dist/primitives/interaction-submit.d.ts.map +1 -0
- package/dist/primitives/interaction-submit.js +41 -0
- package/dist/primitives/interaction.d.ts +76 -6
- package/dist/primitives/interaction.d.ts.map +1 -1
- package/dist/primitives/interaction.js +210 -26
- package/dist/primitives/player-roster.d.ts +2 -1
- package/dist/primitives/player-roster.d.ts.map +1 -1
- package/dist/primitives/prompt.d.ts +36 -11
- package/dist/primitives/prompt.d.ts.map +1 -1
- package/dist/primitives/prompt.js +29 -17
- package/dist/primitives/ui.d.ts +9 -0
- package/dist/primitives/ui.d.ts.map +1 -0
- package/dist/primitives/ui.js +7 -0
- package/dist/primitives/zone.d.ts +111 -5
- package/dist/primitives/zone.d.ts.map +1 -1
- package/dist/primitives/zone.js +349 -9
- package/dist/reducer.d.ts +2 -14
- package/dist/reducer.d.ts.map +1 -1
- package/dist/reducer.js +1 -14
- package/dist/runtime/createPluginRuntimeAPI.js +1 -1
- package/dist/types/hex-color.d.ts +7 -0
- package/dist/types/hex-color.d.ts.map +1 -0
- package/dist/types/hex-color.js +13 -0
- package/dist/types/player-state.d.ts +28 -14
- package/dist/types/player-state.d.ts.map +1 -1
- package/dist/types/plugin-state.d.ts +9 -3
- package/dist/types/plugin-state.d.ts.map +1 -1
- package/dist/ui-contract.d.ts +119 -14
- package/dist/ui-contract.d.ts.map +1 -1
- package/dist/ui-contract.js +4 -3
- package/dist/ui-sdk.d.ts +1637 -1245
- package/dist/utils/interaction-inputs.d.ts +8 -5
- package/dist/utils/interaction-inputs.d.ts.map +1 -1
- package/dist/utils/interaction-inputs.js +82 -14
- package/dist/utils/interaction-router.d.ts +31 -0
- package/dist/utils/interaction-router.d.ts.map +1 -0
- package/dist/utils/interaction-router.js +114 -0
- package/package.json +2 -1
- package/src/components/ActionButton.tsx +2 -1
- package/src/components/Card.tsx +1 -1
- package/src/components/DiceRoller.tsx +13 -22
- package/src/components/ErrorBoundary.test.tsx +19 -0
- package/src/components/ErrorBoundary.tsx +113 -24
- package/src/components/InteractionForm.test.tsx +24 -0
- package/src/components/InteractionForm.tsx +48 -23
- package/src/components/PrimaryActionButton.tsx +19 -5
- package/src/components/ResourceCounter.test.tsx +13 -13
- package/src/components/ResourceCounter.tsx +238 -244
- package/src/components/Toast.tsx +23 -10
- package/src/components/__fixtures__/ResourceCounter.fixture.tsx +70 -169
- package/src/components/board/HexGrid.tsx +6 -6
- package/src/components/board/target-layer.ts +44 -5
- package/src/components/index.ts +17 -10
- package/src/components/surfaces/InboxSurface.tsx +7 -5
- package/src/components/surfaces/PlayerCardsSurface.tsx +6 -6
- package/src/components/surfaces/internal/CardZoneRoutedForm.tsx +35 -0
- package/src/components/surfaces/internal/DefaultInteractionButton.tsx +17 -7
- package/src/components/surfaces/internal/useCardZoneInteractions.ts +25 -67
- package/src/context/InteractionDraftContext.tsx +51 -5
- package/src/defaults/components.tsx +12 -50
- package/src/defaults/defaults.test.tsx +1 -50
- package/src/hooks/useBoardInteractions.test.tsx +240 -17
- package/src/hooks/useBoardInteractions.ts +330 -105
- package/src/hooks/useInteractionHandle.ts +23 -28
- package/src/index.test.ts +60 -40
- package/src/index.ts +30 -36
- package/src/primitives/board.test.tsx +73 -0
- package/src/primitives/board.tsx +191 -40
- package/src/primitives/dialog-lifecycle.ts +58 -0
- package/src/primitives/dice.test.tsx +47 -0
- package/src/primitives/dice.tsx +79 -0
- package/src/primitives/game.test.tsx +98 -0
- package/src/primitives/game.tsx +213 -0
- package/src/primitives/index.ts +84 -0
- package/src/primitives/interaction-form-binding.tsx +56 -0
- package/src/primitives/interaction-submit.ts +90 -0
- package/src/primitives/interaction.test.tsx +396 -0
- package/src/primitives/interaction.tsx +451 -31
- package/src/primitives/player-roster.tsx +2 -1
- package/src/primitives/prompt.test.tsx +94 -3
- package/src/primitives/prompt.tsx +87 -48
- package/src/primitives/ui.test.tsx +131 -0
- package/src/primitives/ui.tsx +13 -0
- package/src/primitives/zone.test.tsx +305 -0
- package/src/primitives/zone.tsx +660 -12
- package/src/reducer.ts +7 -20
- package/src/runtime/createPluginRuntimeAPI.ts +1 -1
- package/src/types/hex-color.ts +20 -0
- package/src/types/player-state.ts +36 -18
- package/src/types/plugin-state.ts +10 -3
- package/src/ui-contract.ts +253 -21
- package/src/utils/interaction-inputs.test.ts +400 -0
- package/src/utils/interaction-inputs.ts +113 -11
- package/src/utils/interaction-router.ts +200 -0
- package/type-stubs/manifest-contract.d.ts +42 -0
- package/type-stubs/manifest-contract.d.ts.map +1 -0
- package/type-stubs/manifest-contract.js +72 -0
- package/type-stubs/ui-contract.d.ts +5 -0
- package/type-stubs/ui-contract.d.ts.map +1 -0
- package/type-stubs/ui-contract.js +1 -0
|
@@ -1,118 +1,109 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, createElement, useContext, useMemo, } from "react";
|
|
3
|
+
import { composeEventHandlers, renderPrimitive, } from "../primitives/index.js";
|
|
4
|
+
const ResourceCounterItemContext = createContext(null);
|
|
5
|
+
function useResourceCounterItemContext() {
|
|
6
|
+
const value = useContext(ResourceCounterItemContext);
|
|
7
|
+
if (!value) {
|
|
8
|
+
throw new Error("ResourceCounter item primitives must be rendered inside <ResourceCounter.Item>.");
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
function renderResourceIcon(icon, props = {}) {
|
|
13
|
+
if (typeof icon === "function") {
|
|
14
|
+
return createElement(icon, {
|
|
15
|
+
"aria-hidden": true,
|
|
16
|
+
strokeWidth: 2.5,
|
|
17
|
+
...props,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const { strokeWidth: _strokeWidth, "aria-hidden": ariaHidden, ...spanProps } = props;
|
|
21
|
+
return (_jsx("span", { "aria-hidden": ariaHidden === undefined ? true : ariaHidden !== "false", ...spanProps, children: icon }));
|
|
22
|
+
}
|
|
23
|
+
function resolveResourceChildren(children, resource) {
|
|
24
|
+
return typeof children === "function" ? children(resource) : children;
|
|
25
|
+
}
|
|
26
|
+
export function ResourceCounterRoot({ resources, counts, zero = "show", onResourceClick, children, "aria-label": ariaLabel, ...props }) {
|
|
27
|
+
const items = useMemo(() => resources
|
|
28
|
+
.map((resource) => {
|
|
29
|
+
const count = counts[resource.type] ?? 0;
|
|
30
|
+
return {
|
|
31
|
+
...resource,
|
|
32
|
+
count,
|
|
33
|
+
isZero: count === 0,
|
|
34
|
+
interactive: Boolean(onResourceClick),
|
|
35
|
+
select: () => onResourceClick?.(resource.type),
|
|
36
|
+
renderIcon: (iconProps) => renderResourceIcon(resource.icon, iconProps),
|
|
37
|
+
dataAttributes: {
|
|
38
|
+
"data-resource-id": resource.type,
|
|
39
|
+
"data-resource-count": count,
|
|
40
|
+
"data-resource-zero": count === 0 || undefined,
|
|
41
|
+
"data-interactive": onResourceClick ? true : undefined,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
})
|
|
45
|
+
.filter((resource) => zero === "show" || !resource.isZero), [counts, onResourceClick, resources, zero]);
|
|
46
|
+
return renderPrimitive("div", {
|
|
47
|
+
role: "list",
|
|
48
|
+
"aria-label": ariaLabel ?? "Resource counts",
|
|
49
|
+
"data-dreamboard-resource-counter": "",
|
|
50
|
+
...props,
|
|
51
|
+
children: items.map((resource) => (_jsx(ResourceCounterItemContext.Provider, { value: resource, children: children }, resource.type))),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export function ResourceCounterItem({ children, onClick, "aria-label": ariaLabel, ...props }) {
|
|
55
|
+
const resource = useResourceCounterItemContext();
|
|
56
|
+
return renderPrimitive("span", {
|
|
57
|
+
role: "listitem",
|
|
58
|
+
"aria-label": ariaLabel ?? `${resource.label}: ${resource.count}`,
|
|
59
|
+
...resource.dataAttributes,
|
|
60
|
+
...props,
|
|
61
|
+
onClick: composeEventHandlers(onClick, resource.interactive ? resource.select : undefined),
|
|
62
|
+
children: resolveResourceChildren(children, resource),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export function ResourceCounterIcon({ className, strokeWidth, "aria-hidden": ariaHidden, }) {
|
|
66
|
+
const resource = useResourceCounterItemContext();
|
|
67
|
+
return resource.renderIcon({
|
|
68
|
+
className,
|
|
69
|
+
strokeWidth,
|
|
70
|
+
"aria-hidden": ariaHidden,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export function ResourceCounterCount({ children, ...props }) {
|
|
74
|
+
const resource = useResourceCounterItemContext();
|
|
75
|
+
return renderPrimitive("span", {
|
|
76
|
+
...props,
|
|
77
|
+
"data-dreamboard-resource-count": "",
|
|
78
|
+
children: resolveResourceChildren(children ?? resource.count, resource),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export function ResourceCounterLabel({ children, ...props }) {
|
|
82
|
+
const resource = useResourceCounterItemContext();
|
|
83
|
+
return renderPrimitive("span", {
|
|
84
|
+
...props,
|
|
85
|
+
"data-dreamboard-resource-label": "",
|
|
86
|
+
children: resolveResourceChildren(children ?? resource.label, resource),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
export function createResourceCounter(resources) {
|
|
90
|
+
return {
|
|
91
|
+
Root(props) {
|
|
92
|
+
return createElement((ResourceCounterRoot), {
|
|
93
|
+
...props,
|
|
94
|
+
resources,
|
|
95
|
+
});
|
|
42
96
|
},
|
|
97
|
+
Item: ResourceCounterItem,
|
|
98
|
+
Icon: ResourceCounterIcon,
|
|
99
|
+
Count: ResourceCounterCount,
|
|
100
|
+
Label: ResourceCounterLabel,
|
|
43
101
|
};
|
|
44
|
-
const styles = sizeConfig[size];
|
|
45
|
-
const filteredResources = showZero
|
|
46
|
-
? resources
|
|
47
|
-
: resources.filter((r) => (counts[r.type] ?? 0) > 0);
|
|
48
|
-
// Base chip styling pulled from the theme. Caller-supplied
|
|
49
|
-
// `bgColor`/`textColor` (Tailwind classes) override these inline
|
|
50
|
-
// defaults via the `style` cascade — when a Tailwind class sets
|
|
51
|
-
// `background-color`, it wins because we don't pass `background`
|
|
52
|
-
// when the caller provided a `bgColor` class.
|
|
53
|
-
const baseChipStyle = (bgColorClass) => ({
|
|
54
|
-
display: "inline-flex",
|
|
55
|
-
alignItems: "center",
|
|
56
|
-
gap: styles.gap,
|
|
57
|
-
paddingBlock: styles.paddingBlock,
|
|
58
|
-
paddingInline: styles.paddingInline,
|
|
59
|
-
borderRadius: theme.radius.md,
|
|
60
|
-
border: `2px solid ${theme.semantic.border.default}`,
|
|
61
|
-
background: bgColorClass ? undefined : theme.semantic.surface.card,
|
|
62
|
-
boxShadow: theme.elevation.rest,
|
|
63
|
-
fontFamily: theme.typography.fontFamily.body,
|
|
64
|
-
transition: `transform ${theme.motion.duration.fast} ${theme.motion.easing.out}, box-shadow ${theme.motion.duration.normal} ${theme.motion.easing.out}`,
|
|
65
|
-
});
|
|
66
|
-
return (_jsx("div", { className: clsx(layout === "grid" && "grid", layout === "row" && "flex flex-wrap", layout === "compact" && "flex flex-wrap", layout === "row" && "gap-3 sm:gap-4", layout === "compact" && "gap-2", layout === "grid" && "gap-3 sm:gap-4", className), style: layout === "grid"
|
|
67
|
-
? {
|
|
68
|
-
gridTemplateColumns: `repeat(${columns}, 1fr)`,
|
|
69
|
-
fontFamily: theme.typography.fontFamily.body,
|
|
70
|
-
}
|
|
71
|
-
: { fontFamily: theme.typography.fontFamily.body }, role: "list", "aria-label": "Resource counts", children: _jsx(TooltipProvider, { delayDuration: 200, children: _jsx(AnimatePresence, { mode: "popLayout", children: filteredResources.map(({ type, label, icon, iconColor, bgColor, textColor }) => {
|
|
72
|
-
const count = counts[type] ?? 0;
|
|
73
|
-
const iconNode = typeof icon === "function" ? (createElement(icon, {
|
|
74
|
-
className: clsx(styles.icon, iconColor),
|
|
75
|
-
strokeWidth: 2.5,
|
|
76
|
-
"aria-hidden": "true",
|
|
77
|
-
})) : (_jsx("span", { className: clsx(styles.icon, iconColor), "aria-hidden": "true", style: {
|
|
78
|
-
display: "inline-flex",
|
|
79
|
-
alignItems: "center",
|
|
80
|
-
justifyContent: "center",
|
|
81
|
-
fontSize: "1.1em",
|
|
82
|
-
}, children: icon }));
|
|
83
|
-
const content = (_jsxs(_Fragment, { children: [iconNode, _jsx(motion.span, { initial: reducedMotion ? { scale: 1 } : { scale: 1.5 }, animate: { scale: 1 }, className: clsx("font-bold", textColor), style: {
|
|
84
|
-
fontSize: styles.fontSize,
|
|
85
|
-
fontFamily: theme.typography.fontFamily.tabular,
|
|
86
|
-
fontWeight: theme.typography.fontWeight.bold,
|
|
87
|
-
color: textColor
|
|
88
|
-
? undefined
|
|
89
|
-
: theme.semantic.text.primary,
|
|
90
|
-
}, children: count }, count)] }));
|
|
91
|
-
const sharedClassName = clsx("flex items-center focus-visible:outline-none", bgColor, onResourceClick
|
|
92
|
-
? "cursor-pointer focus-visible:ring-2 focus-visible:ring-offset-2"
|
|
93
|
-
: "cursor-help");
|
|
94
|
-
const sharedStyle = {
|
|
95
|
-
...baseChipStyle(bgColor),
|
|
96
|
-
color: textColor ? undefined : theme.semantic.text.primary,
|
|
97
|
-
};
|
|
98
|
-
const focusVisibleStyle = onResourceClick
|
|
99
|
-
? {
|
|
100
|
-
// Theming the focus ring requires a CSS variable hop
|
|
101
|
-
// because Tailwind's focus-visible:ring-offset uses
|
|
102
|
-
// `--tw-ring-offset-color`. We expose the theme
|
|
103
|
-
// border.focus token here so consumers without our
|
|
104
|
-
// Tailwind preset still get a visible ring.
|
|
105
|
-
"--tw-ring-color": theme.semantic.border.focus,
|
|
106
|
-
"--tw-ring-offset-color": theme.semantic.surface.app,
|
|
107
|
-
}
|
|
108
|
-
: {};
|
|
109
|
-
const chip = onResourceClick ? (_jsx("button", { type: "button", onClick: () => onResourceClick(type), className: sharedClassName, style: { ...sharedStyle, ...focusVisibleStyle }, "aria-label": `${label}: ${count}`, children: content })) : (_jsx("div", { className: sharedClassName, style: sharedStyle, "aria-label": `${label}: ${count}`, children: content }));
|
|
110
|
-
return (_jsx(motion.div, { layout: !reducedMotion, initial: reducedMotion
|
|
111
|
-
? { opacity: 0, scale: 1 }
|
|
112
|
-
: { opacity: 0, scale: 0.8 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.8 }, whileHover: onResourceClick && !reducedMotion
|
|
113
|
-
? { scale: 1.05 }
|
|
114
|
-
: undefined, whileTap: onResourceClick && !reducedMotion
|
|
115
|
-
? { scale: 0.95 }
|
|
116
|
-
: undefined, role: "listitem", children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: chip }), _jsxs(TooltipContent, { side: "top", sideOffset: 6, children: [_jsx("p", { className: "font-sans text-sm font-bold", children: label }), _jsxs("p", { className: "font-sans text-xs font-normal opacity-90", children: ["Quantity: ", count] })] })] }) }, type));
|
|
117
|
-
}) }) }) }));
|
|
118
102
|
}
|
|
103
|
+
export const ResourceCounter = {
|
|
104
|
+
Root: ResourceCounterRoot,
|
|
105
|
+
Item: ResourceCounterItem,
|
|
106
|
+
Icon: ResourceCounterIcon,
|
|
107
|
+
Count: ResourceCounterCount,
|
|
108
|
+
Label: ResourceCounterLabel,
|
|
109
|
+
};
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Plugin-internal toast notification system.
|
|
3
3
|
*
|
|
4
|
-
* `<ToastProvider>` exposes
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* is intentionally NOT wired to the host notification stream:
|
|
4
|
+
* `<ToastProvider>` exposes `<Toast.Actions>` for game-specific feedback
|
|
5
|
+
* ("Resource gained", "Card discarded", "Tip: rotate the board with R", …).
|
|
6
|
+
* It is intentionally NOT wired to the host notification stream:
|
|
8
7
|
* `YOUR_TURN`, `PROMPT_OPENED` and `ACTION_REJECTED` events are owned
|
|
9
8
|
* by `@dreamboard/ui-host-runtime`'s `<HostFeedbackToaster>` and must
|
|
10
9
|
* not be mirrored from inside the plugin tree.
|
|
11
10
|
*/
|
|
12
11
|
import { type ReactNode } from "react";
|
|
13
12
|
export type ToastType = "success" | "error" | "info" | "warning";
|
|
14
|
-
export interface
|
|
13
|
+
export interface ToastNotification {
|
|
15
14
|
id: string;
|
|
16
15
|
type: ToastType;
|
|
17
16
|
message: string;
|
|
18
17
|
duration?: number;
|
|
19
18
|
}
|
|
20
19
|
interface ToastContextValue {
|
|
21
|
-
toasts:
|
|
20
|
+
toasts: ToastNotification[];
|
|
22
21
|
show: (message: string, type?: ToastType, duration?: number) => void;
|
|
23
22
|
dismiss: (id: string) => void;
|
|
24
23
|
success: (message: string, duration?: number) => void;
|
|
@@ -26,10 +25,18 @@ interface ToastContextValue {
|
|
|
26
25
|
info: (message: string, duration?: number) => void;
|
|
27
26
|
warning: (message: string, duration?: number) => void;
|
|
28
27
|
}
|
|
28
|
+
export type ToastActionsValue = ToastContextValue;
|
|
29
29
|
export interface ToastProviderProps {
|
|
30
30
|
children: ReactNode;
|
|
31
31
|
}
|
|
32
32
|
export declare function ToastProvider({ children }: ToastProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
33
33
|
export declare function useToast(): ToastContextValue;
|
|
34
|
+
export interface ToastActionsProps {
|
|
35
|
+
children: (actions: ToastActionsValue) => ReactNode;
|
|
36
|
+
}
|
|
37
|
+
export declare function ToastActions({ children }: ToastActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export declare const Toast: {
|
|
39
|
+
readonly Actions: typeof ToastActions;
|
|
40
|
+
};
|
|
34
41
|
export {};
|
|
35
42
|
//# sourceMappingURL=Toast.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../src/components/Toast.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../src/components/Toast.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAMf,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEjE,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,iBAAiB;IACzB,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACvD;AAID,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CA4D7D;AAED,wBAAgB,QAAQ,sBAMvB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,SAAS,CAAC;CACrD;AAED,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,2CAE3D;AAED,eAAO,MAAM,KAAK;;CAER,CAAC"}
|
package/dist/components/Toast.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* Plugin-internal toast notification system.
|
|
4
4
|
*
|
|
5
|
-
* `<ToastProvider>` exposes
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* is intentionally NOT wired to the host notification stream:
|
|
5
|
+
* `<ToastProvider>` exposes `<Toast.Actions>` for game-specific feedback
|
|
6
|
+
* ("Resource gained", "Card discarded", "Tip: rotate the board with R", …).
|
|
7
|
+
* It is intentionally NOT wired to the host notification stream:
|
|
9
8
|
* `YOUR_TURN`, `PROMPT_OPENED` and `ACTION_REJECTED` events are owned
|
|
10
9
|
* by `@dreamboard/ui-host-runtime`'s `<HostFeedbackToaster>` and must
|
|
11
10
|
* not be mirrored from inside the plugin tree.
|
|
@@ -56,6 +55,12 @@ export function useToast() {
|
|
|
56
55
|
}
|
|
57
56
|
return context;
|
|
58
57
|
}
|
|
58
|
+
export function ToastActions({ children }) {
|
|
59
|
+
return _jsx(_Fragment, { children: children(useToast()) });
|
|
60
|
+
}
|
|
61
|
+
export const Toast = {
|
|
62
|
+
Actions: ToastActions,
|
|
63
|
+
};
|
|
59
64
|
function ToastContainer({ toasts, onDismiss, }) {
|
|
60
65
|
return (_jsx("div", { className: "fixed bottom-4 right-4 z-50 flex flex-col gap-2 pointer-events-none", role: "region", "aria-live": "polite", "aria-label": "Notifications", children: _jsx(AnimatePresence, { children: toasts.map((toast) => (_jsx(ToastItem, { toast: toast, onDismiss: onDismiss }, toast.id))) }) }));
|
|
61
66
|
}
|
|
@@ -295,11 +295,11 @@ function HexGridImpl(props) {
|
|
|
295
295
|
const isSelectable = isInteractiveTargetSelectable(interactiveSpaces, state);
|
|
296
296
|
return (_jsxs("g", { transform: `translate(${pos.x}, ${pos.y})`, role: isSelectable ? "button" : undefined, className: clsx(isSelectable && "cursor-pointer"), onPointerEnter: () => setHoveredSpaceId(space.id), onPointerLeave: () => setHoveredSpaceId((currentId) => currentId === space.id ? null : currentId), onClick: isSelectable
|
|
297
297
|
? () => {
|
|
298
|
-
void
|
|
298
|
+
void state.select?.();
|
|
299
299
|
}
|
|
300
300
|
: undefined, onKeyDown: (event) => handleKeyboardActivation(event, isSelectable
|
|
301
301
|
? () => {
|
|
302
|
-
void
|
|
302
|
+
void state.select?.();
|
|
303
303
|
}
|
|
304
304
|
: undefined), tabIndex: isSelectable ? 0 : undefined, "aria-label": isSelectable ? `Select space ${space.id}` : undefined, children: [isSelectable && (_jsx("polygon", { points: buildTileGeometry(pos).points({
|
|
305
305
|
inset: hexSize * 0.05,
|
|
@@ -316,11 +316,11 @@ function HexGridImpl(props) {
|
|
|
316
316
|
const touchTargetLength = Math.hypot(edge.position.x2 - edge.position.x1, edge.position.y2 - edge.position.y1);
|
|
317
317
|
return (_jsxs("g", { role: isSelectable ? "button" : undefined, className: clsx(isSelectable && "cursor-pointer"), onPointerEnter: () => setHoveredEdgeId(edge.id), onPointerLeave: () => setHoveredEdgeId((currentId) => currentId === edge.id ? null : currentId), onClick: isSelectable
|
|
318
318
|
? () => {
|
|
319
|
-
void
|
|
319
|
+
void state.select?.();
|
|
320
320
|
}
|
|
321
321
|
: undefined, onKeyDown: (event) => handleKeyboardActivation(event, isSelectable
|
|
322
322
|
? () => {
|
|
323
|
-
void
|
|
323
|
+
void state.select?.();
|
|
324
324
|
}
|
|
325
325
|
: undefined), tabIndex: isSelectable ? 0 : undefined, "aria-label": isSelectable ? `Select edge ${edge.id}` : undefined, children: [isSelectable && (_jsx("rect", { x: edge.position.midX - touchTargetLength / 2, y: edge.position.midY - interactiveEdgeSize, width: touchTargetLength, height: interactiveEdgeSize * 2, rx: interactiveEdgeSize, fill: "rgba(255,255,255,0.001)", transform: `rotate(${edge.position.edgeAngle} ${edge.position.midX} ${edge.position.midY})`, pointerEvents: "all" })), renderInteractiveEdge ? (renderInteractiveEdge(edge, edge.position, state)) : state.isEnabled && state.isEligible ? (_jsx(DefaultInteractiveEdge, { position: edge.position, isHovered: state.isHovered, strokeWidth: interactiveEdgeSize * 0.6 })) : null] }, edge.id));
|
|
326
326
|
}) })), interactiveVertices && resolvedVertexPositions.length > 0 && (_jsx("g", { className: "interactive-vertices", role: "list", "aria-label": "Interactive vertices for placement", children: resolvedVertexPositions.map(({ interactiveVertex: vertex }) => {
|
|
@@ -328,11 +328,11 @@ function HexGridImpl(props) {
|
|
|
328
328
|
const isSelectable = isInteractiveTargetSelectable(interactiveVertices, state);
|
|
329
329
|
return (_jsxs("g", { role: isSelectable ? "button" : undefined, className: clsx(isSelectable && "cursor-pointer"), onPointerEnter: () => setHoveredVertexId(vertex.id), onPointerLeave: () => setHoveredVertexId((currentId) => currentId === vertex.id ? null : currentId), onClick: isSelectable
|
|
330
330
|
? () => {
|
|
331
|
-
void
|
|
331
|
+
void state.select?.();
|
|
332
332
|
}
|
|
333
333
|
: undefined, onKeyDown: (event) => handleKeyboardActivation(event, isSelectable
|
|
334
334
|
? () => {
|
|
335
|
-
void
|
|
335
|
+
void state.select?.();
|
|
336
336
|
}
|
|
337
337
|
: undefined), tabIndex: isSelectable ? 0 : undefined, "aria-label": isSelectable ? `Select vertex ${vertex.id}` : undefined, children: [isSelectable && (_jsx("circle", { cx: vertex.position.x, cy: vertex.position.y, r: interactiveVertexSize * 1.5, fill: "rgba(255,255,255,0.001)", pointerEvents: "all" })), renderInteractiveVertex ? (renderInteractiveVertex(vertex, vertex.position, state)) : state.isEnabled && state.isEligible ? (_jsx(DefaultInteractiveVertex, { position: vertex.position, isHovered: state.isHovered, size: interactiveVertexSize * 0.6 })) : null] }, vertex.id));
|
|
338
338
|
}) })), effectivePanZoom && transform.zoom !== 1 && (_jsxs("g", { transform: `translate(${viewBoxX + 10}, ${viewBoxY + viewBoxHeight - 30})`, children: [_jsx("rect", { x: 0, y: 0, width: 60, height: 20, rx: 4, fill: "rgba(0,0,0,0.6)" }), _jsxs("text", { x: 30, y: 14, textAnchor: "middle", fill: "white", fontSize: 12, children: [Math.round(transform.zoom * 100), "%"] })] }))] }));
|
|
@@ -1,9 +1,25 @@
|
|
|
1
|
+
import type { BoardTargetKind } from "../../utils/interaction-inputs.js";
|
|
2
|
+
export interface InteractiveTargetState {
|
|
3
|
+
kind?: BoardTargetKind;
|
|
4
|
+
id: string;
|
|
5
|
+
eligible: boolean;
|
|
6
|
+
selectable: boolean;
|
|
7
|
+
hovered: boolean;
|
|
8
|
+
interactionKey?: string;
|
|
9
|
+
interactionId?: string;
|
|
10
|
+
inputKey?: string;
|
|
11
|
+
pending: boolean;
|
|
12
|
+
conflict: boolean;
|
|
13
|
+
unavailableReason?: string;
|
|
14
|
+
select?: () => unknown | Promise<unknown>;
|
|
15
|
+
}
|
|
1
16
|
export interface InteractiveTargetLayer {
|
|
2
17
|
enabled?: boolean;
|
|
3
18
|
eligible?: ReadonlySet<string>;
|
|
4
|
-
selectTargetId?: (targetId: string) =>
|
|
19
|
+
selectTargetId?: (targetId: string) => unknown | Promise<unknown>;
|
|
20
|
+
targetState?: (targetId: string) => Partial<InteractiveTargetState>;
|
|
5
21
|
}
|
|
6
|
-
export interface InteractiveTargetRenderState {
|
|
22
|
+
export interface InteractiveTargetRenderState extends InteractiveTargetState {
|
|
7
23
|
isEnabled: boolean;
|
|
8
24
|
isEligible: boolean;
|
|
9
25
|
isHovered: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"target-layer.d.ts","sourceRoot":"","sources":["../../../src/components/board/target-layer.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/B,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"target-layer.d.ts","sourceRoot":"","sources":["../../../src/components/board/target-layer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEzE,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/B,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClE,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACrE;AAED,MAAM,WAAW,4BAA6B,SAAQ,sBAAsB;IAC1E,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,sBAAsB,EAC7B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,OAAO,GACjB,4BAA4B,CAuB9B;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,sBAAsB,EAC7B,KAAK,EAAE,4BAA4B,GAClC,OAAO,CAMT"}
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
export function interactiveTargetRenderState(layer, targetId, isHovered) {
|
|
2
|
+
const enabled = layer.enabled !== false;
|
|
3
|
+
const eligible = layer.eligible?.has(targetId) ?? true;
|
|
4
|
+
const extra = layer.targetState?.(targetId) ?? {};
|
|
5
|
+
const selectable = extra.selectable ?? (enabled && eligible && !!layer.selectTargetId);
|
|
2
6
|
return {
|
|
3
|
-
|
|
4
|
-
|
|
7
|
+
id: targetId,
|
|
8
|
+
...extra,
|
|
9
|
+
eligible: extra.eligible ?? eligible,
|
|
10
|
+
selectable,
|
|
11
|
+
hovered: isHovered,
|
|
12
|
+
pending: extra.pending ?? false,
|
|
13
|
+
conflict: extra.conflict ?? false,
|
|
14
|
+
select: extra.select ??
|
|
15
|
+
(layer.selectTargetId
|
|
16
|
+
? () => layer.selectTargetId?.(targetId)
|
|
17
|
+
: undefined),
|
|
18
|
+
isEnabled: enabled,
|
|
19
|
+
isEligible: extra.eligible ?? eligible,
|
|
5
20
|
isHovered,
|
|
6
21
|
};
|
|
7
22
|
}
|
|
8
23
|
export function isInteractiveTargetSelectable(layer, state) {
|
|
9
|
-
return state.isEnabled &&
|
|
24
|
+
return (state.isEnabled &&
|
|
25
|
+
state.selectable &&
|
|
26
|
+
!!(state.select ?? layer.selectTargetId));
|
|
10
27
|
}
|
|
@@ -4,24 +4,23 @@ export { Hand, type HandProps } from "./Hand.js";
|
|
|
4
4
|
export { HandDock, type HandDockMode, type HandDockPlacement, type HandDockPresentation, type HandDockProps, type HandDockToggleContext, } from "./HandDock.js";
|
|
5
5
|
export { PlayArea, type PlayAreaProps } from "./PlayArea.js";
|
|
6
6
|
export { GameSkeleton, type GameSkeletonProps } from "./GameSkeleton.js";
|
|
7
|
-
export { ToastProvider,
|
|
7
|
+
export { Toast, ToastActions, ToastProvider, type ToastActionsProps, type ToastActionsValue, type ToastNotification, type ToastType, } from "./Toast.js";
|
|
8
8
|
export { ErrorBoundary, type ErrorBoundaryProps } from "./ErrorBoundary.js";
|
|
9
9
|
export { PluginRuntime, type PluginRuntimeProps } from "./PluginRuntime.js";
|
|
10
10
|
export { Drawer, DrawerPortal, DrawerOverlay, DrawerTrigger, DrawerClose, DrawerContent, DrawerHeader, DrawerFooter, DrawerTitle, DrawerDescription, } from "./Drawer.js";
|
|
11
11
|
export { Dialog, DialogPortal, DialogOverlay, DialogTrigger, DialogClose, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, } from "../internal/ui/dialog.js";
|
|
12
|
-
export { ResourceCounter, type ResourceCounterProps, type ResourceDisplayConfig, } from "./ResourceCounter.js";
|
|
12
|
+
export { ResourceCounter, ResourceCounterCount, ResourceCounterIcon, ResourceCounterItem, ResourceCounterLabel, ResourceCounterRoot, createResourceCounter, type BoundResourceCounterRootProps, type ResourceCounterComponents, type ResourceCounterItemState, type ResourceCounterPartProps, type ResourceCounterProps, type ResourceCounterRootProps, type ResourceDisplayConfig, type ResourceIconProps, } from "./ResourceCounter.js";
|
|
13
13
|
export { CostDisplay, type CostDisplayProps, type ResourceDefinition, } from "./CostDisplay.js";
|
|
14
14
|
export { ActionButton, type ActionButtonProps } from "./ActionButton.js";
|
|
15
15
|
export { PrimaryButton, type PrimaryButtonProps } from "./PrimaryButton.js";
|
|
16
16
|
export { ThemedButton, type ThemedButtonProps } from "./ThemedButton.js";
|
|
17
17
|
export { PrimaryActionButton, type PrimaryActionButtonProps, type PrimaryActionAttention, } from "./PrimaryActionButton.js";
|
|
18
|
-
export { InteractionForm,
|
|
18
|
+
export { InteractionForm, defaultFormInputs, hasDefaultInteractionFormFields, type InteractionFormProps, } from "./InteractionForm.js";
|
|
19
19
|
export { ActionPanel, ActionGroup, type ActionPanelProps, type ActionGroupProps, } from "./ActionPanel.js";
|
|
20
20
|
export { MoreActions, type MoreActionsProps } from "./MoreActions.js";
|
|
21
21
|
export { DiceRoller, type DiceRollerProps } from "./DiceRoller.js";
|
|
22
22
|
export { PhaseIndicator, type PhaseIndicatorProps } from "./PhaseIndicator.js";
|
|
23
23
|
export { GameEndDisplay, type GameEndDisplayProps, type PlayerScore, } from "./GameEndDisplay.js";
|
|
24
|
-
export { PromptDialogHost, type PromptDialogHostProps, } from "./PromptDialogHost.js";
|
|
25
24
|
export { NetworkGraph, DefaultNetworkNode, DefaultNetworkEdge, DefaultNetworkPiece, type NetworkGraphProps, type NetworkNode, type NetworkEdge, type NetworkPiece, type DefaultNetworkNodeProps, type DefaultNetworkEdgeProps, type DefaultNetworkPieceProps, } from "./board/NetworkGraph.js";
|
|
26
25
|
export { ZoneMap, DefaultZone, DefaultZonePieces, DefaultZonePiece, type ZoneMapProps, type ZoneDefinition, type ZonePiece, type ZoneShape, type ZoneHighlightType, type DefaultZoneProps, type DefaultZonePiecesProps, type DefaultZonePieceProps, } from "./board/ZoneMap.js";
|
|
27
26
|
export { TrackBoard, DefaultTrackSpace, DefaultTrackPiece, DefaultTrackConnection, DefaultTrackJump, type TrackBoardProps, type TrackSpace, type TrackPiece, type DefaultTrackSpaceProps, type DefaultTrackPieceProps, type DefaultTrackConnectionProps, type DefaultTrackJumpProps, } from "./board/TrackBoard.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,iEAAiE;AAGjE,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,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BAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,OAAO,EACP,QAAQ,EACR,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,gBAAgB,GACtB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -6,25 +6,24 @@ export { HandDock, } from "./HandDock.js";
|
|
|
6
6
|
export { PlayArea } from "./PlayArea.js";
|
|
7
7
|
// Other UI components
|
|
8
8
|
export { GameSkeleton } from "./GameSkeleton.js";
|
|
9
|
-
export {
|
|
9
|
+
export { Toast, ToastActions, ToastProvider, } from "./Toast.js";
|
|
10
10
|
export { ErrorBoundary } from "./ErrorBoundary.js";
|
|
11
11
|
export { PluginRuntime } from "./PluginRuntime.js";
|
|
12
12
|
export { Drawer, DrawerPortal, DrawerOverlay, DrawerTrigger, DrawerClose, DrawerContent, DrawerHeader, DrawerFooter, DrawerTitle, DrawerDescription, } from "./Drawer.js";
|
|
13
13
|
export { Dialog, DialogPortal, DialogOverlay, DialogTrigger, DialogClose, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, } from "../internal/ui/dialog.js";
|
|
14
14
|
// Game UI primitives (SDK v0.1.0+)
|
|
15
|
-
export { ResourceCounter, } from "./ResourceCounter.js";
|
|
15
|
+
export { ResourceCounter, ResourceCounterCount, ResourceCounterIcon, ResourceCounterItem, ResourceCounterLabel, ResourceCounterRoot, createResourceCounter, } from "./ResourceCounter.js";
|
|
16
16
|
export { CostDisplay, } from "./CostDisplay.js";
|
|
17
17
|
export { ActionButton } from "./ActionButton.js";
|
|
18
18
|
export { PrimaryButton } from "./PrimaryButton.js";
|
|
19
19
|
export { ThemedButton } from "./ThemedButton.js";
|
|
20
20
|
export { PrimaryActionButton, } from "./PrimaryActionButton.js";
|
|
21
|
-
export { InteractionForm,
|
|
21
|
+
export { InteractionForm, defaultFormInputs, hasDefaultInteractionFormFields, } from "./InteractionForm.js";
|
|
22
22
|
export { ActionPanel, ActionGroup, } from "./ActionPanel.js";
|
|
23
23
|
export { MoreActions } from "./MoreActions.js";
|
|
24
24
|
export { DiceRoller } from "./DiceRoller.js";
|
|
25
25
|
export { PhaseIndicator } from "./PhaseIndicator.js";
|
|
26
26
|
export { GameEndDisplay, } from "./GameEndDisplay.js";
|
|
27
|
-
export { PromptDialogHost, } from "./PromptDialogHost.js";
|
|
28
27
|
// Board primitives (SDK v0.2.0+)
|
|
29
28
|
export { NetworkGraph, DefaultNetworkNode, DefaultNetworkEdge, DefaultNetworkPiece, } from "./board/NetworkGraph.js";
|
|
30
29
|
export { ZoneMap, DefaultZone, DefaultZonePieces, DefaultZonePiece, } from "./board/ZoneMap.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InboxSurface.d.ts","sourceRoot":"","sources":["../../../src/components/surfaces/InboxSurface.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,qCAAqC,CAAC;AAG7C,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"InboxSurface.d.ts","sourceRoot":"","sources":["../../../src/components/surfaces/InboxSurface.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,qCAAqC,CAAC;AAG7C,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,6BAA6B,CAAC;AAMrC,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,iBAAiB,CAChC,CAAC,SAAS,MAAM,GAAG,KAAK,EACxB,WAAW,SAAS,OAAO,CAAC,2BAA2B,CAAC,GAAG,EAAE;IAE7D;;;;;OAKG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IAC1C;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,CACX,UAAU,EAAE,qBAAqB,CAAC,CAAC,CAAC,EACpC,MAAM,EAAE,iBAAiB,CACvB,mBAAmB,CAAC,WAAW,EAAE,CAAC,CAAC,EACnC,0BAA0B,CAAC,WAAW,EAAE,CAAC,CAAC,CAC3C,KACE,SAAS,CAAC;IACf,uEAAuE;IACvE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,gFAAgF;IAChF,sBAAsB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,CAAC,SAAS,MAAM,GAAG,KAAK,EACxB,WAAW,SAAS,OAAO,CAAC,2BAA2B,CAAC,GAAG,EAAE,EAC7D,EACA,MAAM,EACN,UAAU,EACV,KAAY,EACZ,sBAAsB,GACvB,EAAE,iBAAiB,CAAC,CAAC,EAAE,WAAW,CAAC,2CA4BnC"}
|
|
@@ -6,6 +6,7 @@ import { surfaceStyle } from "../../theme/derive.js";
|
|
|
6
6
|
import { useTheme } from "../../theme/ThemeProvider.js";
|
|
7
7
|
import { interactionInputKeys } from "../../utils/interaction-inputs.js";
|
|
8
8
|
import { interactionLabel } from "../../utils/interaction-labels.js";
|
|
9
|
+
import { submitInteractionParams } from "../../primitives/interaction-submit.js";
|
|
9
10
|
import { DefaultInteractionButton } from "./internal/DefaultInteractionButton.js";
|
|
10
11
|
import { ThemedButton } from "../ThemedButton.js";
|
|
11
12
|
/**
|
|
@@ -84,12 +85,7 @@ function PromptOptionsCard({ descriptor, handle, options, }) {
|
|
|
84
85
|
return;
|
|
85
86
|
setPendingOptionId(option.id);
|
|
86
87
|
try {
|
|
87
|
-
await handle
|
|
88
|
-
}
|
|
89
|
-
catch {
|
|
90
|
-
// Submission errors flow through the runtime's
|
|
91
|
-
// notification channel; we swallow here so the option
|
|
92
|
-
// buttons re-enable on failure.
|
|
88
|
+
await submitInteractionParams(handle, { [inputKey]: option.id }, {}, { unhandledError: "ignore" });
|
|
93
89
|
}
|
|
94
90
|
finally {
|
|
95
91
|
setPendingOptionId(null);
|
|
@@ -6,7 +6,7 @@ import { Card } from "../Card.js";
|
|
|
6
6
|
import { Drawer, DrawerContent, DrawerHeader, DrawerTitle } from "../Drawer.js";
|
|
7
7
|
import { Hand } from "../Hand.js";
|
|
8
8
|
import { useCardZoneInteractions, } from "./internal/useCardZoneInteractions.js";
|
|
9
|
-
import {
|
|
9
|
+
import { CardZoneRoutedForm } from "./internal/CardZoneRoutedForm.js";
|
|
10
10
|
export function definePlayerCardsSurface(config) {
|
|
11
11
|
return config;
|
|
12
12
|
}
|
|
@@ -174,5 +174,5 @@ function PlayerCardsFan({ node, zone, surfaceRenderCardContent, }) {
|
|
|
174
174
|
return renderCardContent(card, renderCtx);
|
|
175
175
|
}
|
|
176
176
|
: undefined }) }, props.card.id));
|
|
177
|
-
} }), zone.
|
|
177
|
+
} }), zone.routedInteraction ? (_jsx(Fragment, { children: _jsx(CardZoneRoutedForm, { descriptor: zone.routedInteraction, onDone: () => zone.setRoutedInteraction(null) }, zone.routedInteraction.interactionKey) })) : null] }));
|
|
178
178
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { InteractionDescriptor } from "../../../types/plugin-state.js";
|
|
2
|
+
import type { InteractionParamsByKeyShape } from "../types.js";
|
|
3
|
+
export declare function CardZoneRoutedForm<I extends string, ParamsByKey extends Partial<InteractionParamsByKeyShape> = {}>({ descriptor, onDone, }: {
|
|
4
|
+
descriptor: InteractionDescriptor<I>;
|
|
5
|
+
onDone: () => void;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=CardZoneRoutedForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CardZoneRoutedForm.d.ts","sourceRoot":"","sources":["../../../../src/components/surfaces/internal/CardZoneRoutedForm.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAEV,2BAA2B,EAE5B,MAAM,aAAa,CAAC;AAErB,wBAAgB,kBAAkB,CAChC,CAAC,SAAS,MAAM,EAChB,WAAW,SAAS,OAAO,CAAC,2BAA2B,CAAC,GAAG,EAAE,EAC7D,EACA,UAAU,EACV,MAAM,GACP,EAAE;IACD,UAAU,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACrC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,2CAgBA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { InteractionForm } from "../../InteractionForm.js";
|
|
3
|
+
import { useInteractionHandle } from "../../../hooks/useInteractionHandle.js";
|
|
4
|
+
export function CardZoneRoutedForm({ descriptor, onDone, }) {
|
|
5
|
+
const handle = useInteractionHandle(descriptor);
|
|
6
|
+
return (_jsx(InteractionForm, { descriptor: descriptor, handle: handle, hiddenFields: [
|
|
7
|
+
"cardId",
|
|
8
|
+
], onCancel: onDone, onSubmitSuccess: onDone }));
|
|
9
|
+
}
|
|
@@ -1 +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;
|
|
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;AAY5E,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,6BAA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