@hadoku/game-ui 0.1.219 → 0.1.221
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/seats/SeatChip.d.ts +20 -12
- package/dist/seats/SeatChip.js +17 -14
- package/package.json +4 -4
package/dist/seats/SeatChip.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
1
2
|
import type { Look } from '@wolffm/platform-wire/look';
|
|
2
3
|
import '../components/Button.css';
|
|
3
4
|
import './SeatChip.css';
|
|
@@ -35,9 +36,8 @@ export interface SeatListProps {
|
|
|
35
36
|
/**
|
|
36
37
|
* Whether the viewer leads the room: gates every seat-shaping control — AI/Remove-AI on an open
|
|
37
38
|
* or bot-held seat, Close/Open, and Remove/Bot on a member's seat — and an open seat's Close
|
|
38
|
-
* past `realSeatCount`.
|
|
39
|
-
*
|
|
40
|
-
* leader should ever see at all — Close/Open and the member Remove/Bot were already gated).
|
|
39
|
+
* past `realSeatCount`. A non-leader sees none of them: the server would refuse each, and a
|
|
40
|
+
* control nobody but the leader can use is not drawn for anyone else.
|
|
41
41
|
*/
|
|
42
42
|
iLead: boolean;
|
|
43
43
|
/** An event's room before its seats open: nobody sits, nor gives a seat to the bot. */
|
|
@@ -57,22 +57,30 @@ export interface SeatListProps {
|
|
|
57
57
|
onOpenSeat?: (seat: number) => void;
|
|
58
58
|
/**
|
|
59
59
|
* The leader removes a SEATED human (never a bot — that is `onBotOff`), landing them a
|
|
60
|
-
* spectator (`rooms-protocol`'s seat op
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* `iLead` same as Close/Open, and never offered on the viewer's own seat (`occupant.mine`):
|
|
64
|
-
* standing is `onSit` elsewhere, not a self-removal.
|
|
60
|
+
* spectator (`rooms-protocol`'s seat op). Absent: no Remove button is drawn on anyone's seat.
|
|
61
|
+
* Gated on `iLead` same as Close/Open, and never offered on the viewer's own seat
|
|
62
|
+
* (`occupant.mine`): standing is `onSit` elsewhere, not a self-removal.
|
|
65
63
|
*/
|
|
66
64
|
onRemoveMember?: (seat: number, memberId: string) => void;
|
|
67
65
|
/**
|
|
68
|
-
* The leader puts the bot in a SEATED human's place, in one action
|
|
69
|
-
*
|
|
70
|
-
*
|
|
66
|
+
* The leader puts the bot in a SEATED human's place, in one action — the generic `seats/bot`
|
|
67
|
+
* op, addressed by seat; distinct from `onBotOn`, which only ever offers the bot an OPEN seat.
|
|
68
|
+
* Absent: no Bot
|
|
71
69
|
* button is drawn on a member's seat. Gated on `iLead`, never offered on the viewer's own seat.
|
|
72
70
|
*/
|
|
73
71
|
onBotReplace?: (seat: number, memberId: string) => void;
|
|
74
72
|
/** The leader hands the room to a seated member. Absent: no Lead button. Gated on `iLead`, never on the viewer's own seat. */
|
|
75
73
|
onMakeLeader?: (memberId: string) => void;
|
|
74
|
+
/**
|
|
75
|
+
* An open seat's own action, drawn for anyone in place of the leader's AI and Close: a table whose
|
|
76
|
+
* empty seat starts a game against the AI, say. Null where the seat offers nothing. Absent: the
|
|
77
|
+
* leader's AI and Close.
|
|
78
|
+
*/
|
|
79
|
+
openAction?: (seat: number) => ReactNode;
|
|
80
|
+
/** The viewer's own seat's control, drawn in place of its ready pill (a ready button). Absent: the pill. */
|
|
81
|
+
mineAction?: ReactNode;
|
|
82
|
+
/** More classes on the strip, for a caller that lays it out its own way. */
|
|
83
|
+
className?: string;
|
|
76
84
|
}
|
|
77
85
|
/** A strip of seats, one `<li>` each: dashed-open / "×"-closed / the bot's own look / a member's avatar, a label underneath, every action its own always-visible button. */
|
|
78
|
-
export declare function SeatList({ slots, iLead, shut, readiness, fieldFixed, realSeatCount, mySeat, onSit, onBotOn, onBotOff, onCloseSeat, onOpenSeat, onRemoveMember, onBotReplace, onMakeLeader }: SeatListProps): import("react").JSX.Element;
|
|
86
|
+
export declare function SeatList({ slots, iLead, shut, readiness, fieldFixed, realSeatCount, mySeat, onSit, onBotOn, onBotOff, onCloseSeat, onOpenSeat, onRemoveMember, onBotReplace, onMakeLeader, openAction, mineAction, className }: SeatListProps): import("react").JSX.Element;
|
package/dist/seats/SeatChip.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* `@hadoku/shared`; a future game classifies its own seats the same way, into the same four shapes).
|
|
3
|
+
* The seat chip, shared: one seat's own avatar, name, ready ring, leader crown and actions (sit,
|
|
4
|
+
* bot on/off, close/open). Platform: knows nothing of a draft pod, a Magic match or any other
|
|
5
|
+
* game's own seat semantics — the caller classifies each seat into a `SeatOccupant` first (Magic's
|
|
6
|
+
* `PodSeats.tsx` does, reading `isPodAi`/`CLOSED_SEAT` from `@hadoku/shared`; another game
|
|
7
|
+
* classifies its own seats the same way, into the same four shapes).
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* The markup's class names and `data-testid`s — `pod-seats`, `pod-seats__seat`, `pod-seat-<n>`, …
|
|
10
|
+
* — are a contract: cardtable's CSS (`PodSeats.css`), its DOM tests (`PodSeats.test.ts`) and the
|
|
11
|
+
* e2e helpers (`e2e/podSeats.ts`) key off them. An open seat says so with `data-seat-open`. A
|
|
12
|
+
* table that draws its seats its own way passes slots (`openAction`, `mineAction`, `className`)
|
|
13
|
+
* rather than a copy of this strip.
|
|
14
14
|
* Its paint is `./SeatChip.css`, after `.ct-action`'s: a game drawing the seats at its own scale
|
|
15
15
|
* (bomberman's overlay, over its board) sets that file's custom properties, never a copy of it.
|
|
16
16
|
*/
|
|
@@ -25,13 +25,14 @@ import './SeatChip.css';
|
|
|
25
25
|
/** The same crown `magic-room-ui.tsx` draws for its own direct uses — duplicated, not imported, so this file pulls in nothing of Magic's. */
|
|
26
26
|
export const SEAT_CROWN_PATH = 'M2 9V3.5l2.2 2L6 2.6l1.8 2.9L10 3.5V9Z';
|
|
27
27
|
/** A strip of seats, one `<li>` each: dashed-open / "×"-closed / the bot's own look / a member's avatar, a label underneath, every action its own always-visible button. */
|
|
28
|
-
export function SeatList({ slots, iLead, shut = false, readiness = true, fieldFixed = false, realSeatCount, mySeat, onSit, onBotOn, onBotOff, onCloseSeat, onOpenSeat, onRemoveMember, onBotReplace, onMakeLeader }) {
|
|
28
|
+
export function SeatList({ slots, iLead, shut = false, readiness = true, fieldFixed = false, realSeatCount, mySeat, onSit, onBotOn, onBotOff, onCloseSeat, onOpenSeat, onRemoveMember, onBotReplace, onMakeLeader, openAction, mineAction, className }) {
|
|
29
29
|
// Below 560px the strip scrolls sideways: its edges say which way more seats are.
|
|
30
30
|
const strip = useRef(null);
|
|
31
31
|
useEdgeCue(strip);
|
|
32
|
-
return (_jsx("ul", { className:
|
|
32
|
+
return (_jsx("ul", { className: className === undefined ? 'pod-seats edge-cue' : `pod-seats edge-cue ${className}`, "data-testid": "pod-seats", ref: strip, children: slots.map(({ seat, occupant }) => {
|
|
33
33
|
if (occupant.kind === 'open') {
|
|
34
|
-
|
|
34
|
+
const own = openAction?.(seat);
|
|
35
|
+
return (_jsxs("li", { className: "pod-seats__seat", "data-testid": `pod-seat-${seat}`, "data-seat-open": "", children: [_jsx(ActionButton, { action: "sit", className: "pod-seats__avatar pod-seats__avatar--open", "data-testid": "pod-seat-sit", "data-seat": seat, "aria-label": `Sit in seat ${seat + 1}`, disabled: shut || (mySeat !== null && seat >= realSeatCount), onPress: () => onSit?.(seat), children: _jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "M12 5v14M5 12h14" }) }) }), _jsx("span", { className: "pod-seats__label", children: "Open" }), openAction === undefined && !fieldFixed && iLead && (_jsxs("span", { className: "pod-seats__actions", children: [_jsx(ActionButton, { action: "ai", className: "pod-seats__action ct-action", "data-testid": "pod-seat-ai", "data-seat": seat, "aria-label": `Fill seat ${seat + 1} with AI`, disabled: shut, onPress: () => onBotOn?.(seat), children: _jsx("span", { className: "ct-action__label", children: "AI" }) }), seat < realSeatCount && (_jsx(ActionButton, { action: "close", className: "pod-seats__action ct-action", "data-testid": "pod-seat-close", "data-seat": seat, "aria-label": `Close seat ${seat + 1}`, onPress: () => onCloseSeat?.(seat), children: _jsx("span", { className: "ct-action__label", children: "Close" }) }))] })), own !== undefined && own !== null && own !== false && _jsx("span", { className: "pod-seats__actions", children: own })] }, seat));
|
|
35
36
|
}
|
|
36
37
|
if (occupant.kind === 'closed') {
|
|
37
38
|
return (_jsxs("li", { className: "pod-seats__seat", "data-testid": `pod-seat-${seat}`, "data-closed": "", children: [_jsx("span", { className: "pod-seats__avatar pod-seats__avatar--closed", "aria-hidden": "true", children: "\u00D7" }), _jsx("span", { className: "pod-seats__label", children: "Closed" }), iLead && (_jsx("span", { className: "pod-seats__actions", children: _jsx(ActionButton, { action: "open", className: "pod-seats__action ct-action", "data-testid": "pod-seat-open", "data-seat": seat, "aria-label": `Open seat ${seat + 1}`, onPress: () => onOpenSeat?.(seat), children: _jsx("span", { className: "ct-action__label", children: "Open" }) }) }))] }, seat));
|
|
@@ -41,6 +42,8 @@ export function SeatList({ slots, iLead, shut = false, readiness = true, fieldFi
|
|
|
41
42
|
}
|
|
42
43
|
const { id, name, avatarId, look, ready, leader, mine } = occupant;
|
|
43
44
|
const face = { id: avatarId ?? null, look };
|
|
44
|
-
return (_jsxs("li", { className: "pod-seats__seat", "data-testid": `pod-seat-${seat}`, "data-mine": mine ? '' : undefined, children: [_jsxs("span", { className: "pod-seats__avatar-wrap", children: [_jsx("span", { className: "pod-seats__avatar", "data-ready": readiness ? (ready ? 'true' : 'false') : undefined, children: _jsx(Avatar, { ...face, fallback: "initial", name: name, className: "pod-seats__avatar-img", fallbackClassName: "pod-seats__avatar-fallback" }) }), leader && (_jsxs("svg", { className: "pod-seats__crown", "data-testid": `pod-seat-${seat}-leader`, viewBox: "0 0 12 12", role: "img", "aria-label": "Room owner", children: [_jsx("title", { children: "Room owner" }), _jsx("path", { d: SEAT_CROWN_PATH })] }))] }), _jsx(PlayerName, { name: name, className: "pod-seats__label" }),
|
|
45
|
+
return (_jsxs("li", { className: "pod-seats__seat", "data-testid": `pod-seat-${seat}`, "data-mine": mine ? '' : undefined, children: [_jsxs("span", { className: "pod-seats__avatar-wrap", children: [_jsx("span", { className: "pod-seats__avatar", "data-ready": readiness ? (ready ? 'true' : 'false') : undefined, children: _jsx(Avatar, { ...face, fallback: "initial", name: name, className: "pod-seats__avatar-img", fallbackClassName: "pod-seats__avatar-fallback" }) }), leader && (_jsxs("svg", { className: "pod-seats__crown", "data-testid": `pod-seat-${seat}-leader`, viewBox: "0 0 12 12", role: "img", "aria-label": "Room owner", children: [_jsx("title", { children: "Room owner" }), _jsx("path", { d: SEAT_CROWN_PATH })] }))] }), _jsx(PlayerName, { name: name, className: "pod-seats__label" }), mine && mineAction !== undefined
|
|
46
|
+
? mineAction
|
|
47
|
+
: readiness && _jsx(StatusPill, { testId: `pod-seat-${seat}-ready`, state: ready ? 'yes' : 'no', mark: ready ? 'tick' : 'ring', label: ready ? 'ready' : 'not ready' }), iLead && !mine && (onRemoveMember !== undefined || onBotReplace !== undefined || onMakeLeader !== undefined) && (_jsxs("span", { className: "pod-seats__actions", children: [onRemoveMember !== undefined && (_jsx(ActionButton, { action: "remove", className: "pod-seats__action ct-action", "data-testid": "pod-seat-remove", "data-seat": seat, "aria-label": `Remove ${name} from the table`, onPress: () => onRemoveMember(seat, id), children: _jsx("span", { className: "ct-action__label", children: "Remove" }) })), onBotReplace !== undefined && (_jsx(ActionButton, { action: "bot-replace", className: "pod-seats__action ct-action", "data-testid": "pod-seat-bot-replace", "data-seat": seat, "aria-label": `Put the bot in ${name}'s seat`, onPress: () => onBotReplace(seat, id), children: _jsx("span", { className: "ct-action__label", children: "Bot" }) })), onMakeLeader !== undefined && (_jsx(ActionButton, { action: "make-leader", className: "pod-seats__action ct-action", "data-testid": "pod-seat-make-leader", "data-seat": seat, "aria-label": `Make ${name} the room leader`, onPress: () => onMakeLeader(id), children: _jsx("svg", { className: "pod-seats__action-icon", viewBox: "0 0 12 12", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: SEAT_CROWN_PATH }) }) }))] }))] }, seat));
|
|
45
48
|
}) }));
|
|
46
49
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadoku/game-ui",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "0.1.221",
|
|
4
|
+
"gitHead": "6db2b0d6cae6d1813362faedd2a1a3bef801dcf8",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "The browser parts any hosted game shares, above ui-shell: the room shell and session, seats and looks, the room route, the front page's generic pieces (gate, polls, gallery, patch notes), the bundle slot and relay channel a game's client mounts in, settings and trim screens, the HTTP and socket helpers, and the generic components (modal, popover, avatar, action button, radio cards). Knows no game; Magic's UI (games/magic/ui) plugs in, composed by the site (apps/ui). MIT; imports only react, react-dom, socket.io-client, @wolffm/* and the platform packages.",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"react-dom": "^19.2.8"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.
|
|
57
|
-
"@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.
|
|
56
|
+
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.225",
|
|
57
|
+
"@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.225",
|
|
58
58
|
"@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.3",
|
|
59
59
|
"@wolffm/rooms-client": "npm:@hadoku/rooms-client@^0.45.152",
|
|
60
60
|
"@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.152",
|