@scriptonita/chess-football-ui 0.6.0 → 0.7.0
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/index.cjs +329 -173
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +103 -3
- package/dist/index.d.ts +103 -3
- package/dist/index.js +320 -174
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -9,16 +9,28 @@ interface GameBoardProps {
|
|
|
9
9
|
showCoordinates?: boolean;
|
|
10
10
|
/** When true, the board is keyboard-operable (arrows move a cursor, Enter acts). */
|
|
11
11
|
keyboardNav?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Desktop-only row above the grid with the ball-holder chip and the keyboard
|
|
14
|
+
* shortcuts button. Pass `false` when the app renders `BallHolderChip` and
|
|
15
|
+
* `KeyboardShortcutsList` itself (e.g. in a side panel) so nothing is shown twice.
|
|
16
|
+
*/
|
|
17
|
+
toolbar?: boolean;
|
|
12
18
|
}
|
|
13
|
-
declare function GameBoard({ userSide, showCoordinates, keyboardNav }: GameBoardProps): react.JSX.Element | null;
|
|
19
|
+
declare function GameBoard({ userSide, showCoordinates, keyboardNav, toolbar }: GameBoardProps): react.JSX.Element | null;
|
|
14
20
|
|
|
15
21
|
interface GamePieceProps {
|
|
16
22
|
piece: Piece;
|
|
17
23
|
isSelected: boolean;
|
|
18
24
|
hasBall: boolean;
|
|
19
25
|
onClick: (e: React.MouseEvent) => void;
|
|
26
|
+
/**
|
|
27
|
+
* True while the piece is travelling between squares. The chip lifts
|
|
28
|
+
* slightly and its ground shadow drops away, so the move reads as the
|
|
29
|
+
* piece being picked up and slid across the turf rather than dragged.
|
|
30
|
+
*/
|
|
31
|
+
isMoving?: boolean;
|
|
20
32
|
}
|
|
21
|
-
declare function GamePiece({ piece, isSelected, hasBall, onClick }: GamePieceProps): react.JSX.Element;
|
|
33
|
+
declare function GamePiece({ piece, isSelected, hasBall, onClick, isMoving }: GamePieceProps): react.JSX.Element;
|
|
22
34
|
|
|
23
35
|
interface FootballProps {
|
|
24
36
|
className?: string;
|
|
@@ -76,6 +88,71 @@ declare function MoveHistory({ scrollable, limit, className }: MoveHistoryProps)
|
|
|
76
88
|
|
|
77
89
|
declare function StaticGameBoard(): react.JSX.Element;
|
|
78
90
|
|
|
91
|
+
declare const PITCH_COLS = 9;
|
|
92
|
+
declare const PITCH_ROWS = 12;
|
|
93
|
+
/** The two goal boxes: files c–g on the first two and last two ranks. */
|
|
94
|
+
declare const isGoalAreaSquare: (x: number, y: number) => boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Goal-box shading: an inset box-shadow that darkens the square *over* its own
|
|
97
|
+
* green, so the box reads as a distinct zone (the king's area) while the
|
|
98
|
+
* checkerboard alternation stays visible — opponents enter it square by square
|
|
99
|
+
* and need to read their moves there. An inset shadow (rather than a flat
|
|
100
|
+
* replacement colour) keeps the app's tokens in charge of the hue and composes
|
|
101
|
+
* with Tailwind's `ring-*` utilities on the live board's highlighted squares.
|
|
102
|
+
*/
|
|
103
|
+
declare const GOAL_AREA_SHADE_CLASS = "shadow-[inset_0_0_0_100vmax_rgba(0,0,0,0.32)]";
|
|
104
|
+
/**
|
|
105
|
+
* Base classes of one pitch square. Every board renderer — the live GameBoard,
|
|
106
|
+
* StaticGameBoard, and any app-side mini board built on PitchSurface — derives
|
|
107
|
+
* its squares from here, so the field reads identically everywhere. Colours
|
|
108
|
+
* come from the app's `field-green-*` design tokens.
|
|
109
|
+
*/
|
|
110
|
+
declare function pitchSquareClass(x: number, y: number): string;
|
|
111
|
+
interface GrassOverlayProps {
|
|
112
|
+
className?: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Decorative turf texture for the pitch. Absolutely positioned over the square
|
|
116
|
+
* grid and click-through, so it sits between the squares and the pieces without
|
|
117
|
+
* affecting hit-testing or the per-square highlight classes.
|
|
118
|
+
*/
|
|
119
|
+
declare function GrassOverlay({ className }: GrassOverlayProps): react.JSX.Element;
|
|
120
|
+
interface PitchMarkingsProps {
|
|
121
|
+
className?: string;
|
|
122
|
+
children?: React.ReactNode;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The painted pitch lines — touchline, goal boxes, halfway line, centre circle,
|
|
126
|
+
* spots and the two "D" arcs — drawn to look like chalk on grass: a roughened,
|
|
127
|
+
* slightly displaced edge and a noise-driven alpha so the coverage is powdery
|
|
128
|
+
* rather than a crisp vector stroke. A faint, wider unfiltered pass underneath
|
|
129
|
+
* acts as the dust halo the line leaves on the turf.
|
|
130
|
+
*
|
|
131
|
+
* Static and cached by the browser as its own layer; anything dynamic that
|
|
132
|
+
* shares the board's coordinate space (e.g. the pass-trajectory preview) should
|
|
133
|
+
* live in a separate <svg> so a hover repaint never re-runs this filter.
|
|
134
|
+
*/
|
|
135
|
+
declare function PitchMarkings({ className, children }: PitchMarkingsProps): react.JSX.Element;
|
|
136
|
+
interface PitchSurfaceProps {
|
|
137
|
+
className?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Extra classes for a given square (e.g. a highlighted area in a rules
|
|
140
|
+
* diagram). Falsy return values are ignored.
|
|
141
|
+
*/
|
|
142
|
+
squareClassName?: (x: number, y: number) => string | false | null | undefined;
|
|
143
|
+
/** Layers rendered above the markings — pieces, ball, overlays. */
|
|
144
|
+
children?: React.ReactNode;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The complete, non-interactive pitch: squares, turf grain and chalk lines, in
|
|
148
|
+
* that order, inside a container-query wrapper so pieces can size themselves
|
|
149
|
+
* with `cqw`. Callers put their own frame (border/radius) around it and their
|
|
150
|
+
* own piece layer inside it. The interactive GameBoard renders its own square
|
|
151
|
+
* grid (it needs per-square handlers) but builds every square from the same
|
|
152
|
+
* `pitchSquareClass`, and stacks the same GrassOverlay + PitchMarkings.
|
|
153
|
+
*/
|
|
154
|
+
declare function PitchSurface({ className, squareClassName, children }: PitchSurfaceProps): react.JSX.Element;
|
|
155
|
+
|
|
79
156
|
interface TurnBannerProps {
|
|
80
157
|
isMyTurn: boolean;
|
|
81
158
|
/** Override for the "not my turn" label (e.g. "Bot pensando…" in training mode). */
|
|
@@ -101,6 +178,29 @@ interface MobileHistoryProps {
|
|
|
101
178
|
}
|
|
102
179
|
declare function MobileHistory({ className }: MobileHistoryProps): react.JSX.Element | null;
|
|
103
180
|
|
|
181
|
+
interface BallHolderChipProps {
|
|
182
|
+
className?: string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* §12b: a persistent, always-visible answer to "whose ball is it" — the piece
|
|
186
|
+
* type currently holding the ball, drawn as a mini chip. Additive to the subtle
|
|
187
|
+
* per-piece ring on the board. Renders nothing while the ball is loose.
|
|
188
|
+
*
|
|
189
|
+
* GameBoard shows it in its own toolbar by default; apps with a side panel can
|
|
190
|
+
* pass `toolbar={false}` to the board and place this chip wherever it reads best.
|
|
191
|
+
*/
|
|
192
|
+
declare function BallHolderChip({ className }: BallHolderChipProps): react.JSX.Element | null;
|
|
193
|
+
|
|
194
|
+
interface KeyboardShortcutsListProps {
|
|
195
|
+
className?: string;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* §12: the legend of the board's keyboard shortcuts. GameBoard shows it in a
|
|
199
|
+
* popover behind a "?" button in its toolbar; apps that pass `toolbar={false}`
|
|
200
|
+
* can render the list inline in a side panel instead.
|
|
201
|
+
*/
|
|
202
|
+
declare function KeyboardShortcutsList({ className }: KeyboardShortcutsListProps): react.JSX.Element;
|
|
203
|
+
|
|
104
204
|
interface ActionPointsProps {
|
|
105
205
|
total: number;
|
|
106
206
|
remaining: number;
|
|
@@ -183,4 +283,4 @@ declare function useGameT(): GameTranslator;
|
|
|
183
283
|
|
|
184
284
|
declare function cn(...inputs: ClassValue[]): string;
|
|
185
285
|
|
|
186
|
-
export { ActionPoints, Avatar, AvatarFallback, AvatarImage, Button, type ButtonProps, ConfirmDialog, EventToast, Football, GAME_I18N_KEYS, GameBoard, GameControls, type GameI18nKey, GameI18nProvider, GamePiece, type GameTranslator, MiniScoreboard, MobileHistory, MoveHistory, Scoreboard, SelectedPieceDetail, StaticGameBoard, TurnBanner, cn, useGameT };
|
|
286
|
+
export { ActionPoints, Avatar, AvatarFallback, AvatarImage, BallHolderChip, Button, type ButtonProps, ConfirmDialog, EventToast, Football, GAME_I18N_KEYS, GOAL_AREA_SHADE_CLASS, GameBoard, GameControls, type GameI18nKey, GameI18nProvider, GamePiece, type GameTranslator, GrassOverlay, KeyboardShortcutsList, MiniScoreboard, MobileHistory, MoveHistory, PITCH_COLS, PITCH_ROWS, PitchMarkings, PitchSurface, Scoreboard, SelectedPieceDetail, StaticGameBoard, TurnBanner, cn, isGoalAreaSquare, pitchSquareClass, useGameT };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,16 +9,28 @@ interface GameBoardProps {
|
|
|
9
9
|
showCoordinates?: boolean;
|
|
10
10
|
/** When true, the board is keyboard-operable (arrows move a cursor, Enter acts). */
|
|
11
11
|
keyboardNav?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Desktop-only row above the grid with the ball-holder chip and the keyboard
|
|
14
|
+
* shortcuts button. Pass `false` when the app renders `BallHolderChip` and
|
|
15
|
+
* `KeyboardShortcutsList` itself (e.g. in a side panel) so nothing is shown twice.
|
|
16
|
+
*/
|
|
17
|
+
toolbar?: boolean;
|
|
12
18
|
}
|
|
13
|
-
declare function GameBoard({ userSide, showCoordinates, keyboardNav }: GameBoardProps): react.JSX.Element | null;
|
|
19
|
+
declare function GameBoard({ userSide, showCoordinates, keyboardNav, toolbar }: GameBoardProps): react.JSX.Element | null;
|
|
14
20
|
|
|
15
21
|
interface GamePieceProps {
|
|
16
22
|
piece: Piece;
|
|
17
23
|
isSelected: boolean;
|
|
18
24
|
hasBall: boolean;
|
|
19
25
|
onClick: (e: React.MouseEvent) => void;
|
|
26
|
+
/**
|
|
27
|
+
* True while the piece is travelling between squares. The chip lifts
|
|
28
|
+
* slightly and its ground shadow drops away, so the move reads as the
|
|
29
|
+
* piece being picked up and slid across the turf rather than dragged.
|
|
30
|
+
*/
|
|
31
|
+
isMoving?: boolean;
|
|
20
32
|
}
|
|
21
|
-
declare function GamePiece({ piece, isSelected, hasBall, onClick }: GamePieceProps): react.JSX.Element;
|
|
33
|
+
declare function GamePiece({ piece, isSelected, hasBall, onClick, isMoving }: GamePieceProps): react.JSX.Element;
|
|
22
34
|
|
|
23
35
|
interface FootballProps {
|
|
24
36
|
className?: string;
|
|
@@ -76,6 +88,71 @@ declare function MoveHistory({ scrollable, limit, className }: MoveHistoryProps)
|
|
|
76
88
|
|
|
77
89
|
declare function StaticGameBoard(): react.JSX.Element;
|
|
78
90
|
|
|
91
|
+
declare const PITCH_COLS = 9;
|
|
92
|
+
declare const PITCH_ROWS = 12;
|
|
93
|
+
/** The two goal boxes: files c–g on the first two and last two ranks. */
|
|
94
|
+
declare const isGoalAreaSquare: (x: number, y: number) => boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Goal-box shading: an inset box-shadow that darkens the square *over* its own
|
|
97
|
+
* green, so the box reads as a distinct zone (the king's area) while the
|
|
98
|
+
* checkerboard alternation stays visible — opponents enter it square by square
|
|
99
|
+
* and need to read their moves there. An inset shadow (rather than a flat
|
|
100
|
+
* replacement colour) keeps the app's tokens in charge of the hue and composes
|
|
101
|
+
* with Tailwind's `ring-*` utilities on the live board's highlighted squares.
|
|
102
|
+
*/
|
|
103
|
+
declare const GOAL_AREA_SHADE_CLASS = "shadow-[inset_0_0_0_100vmax_rgba(0,0,0,0.32)]";
|
|
104
|
+
/**
|
|
105
|
+
* Base classes of one pitch square. Every board renderer — the live GameBoard,
|
|
106
|
+
* StaticGameBoard, and any app-side mini board built on PitchSurface — derives
|
|
107
|
+
* its squares from here, so the field reads identically everywhere. Colours
|
|
108
|
+
* come from the app's `field-green-*` design tokens.
|
|
109
|
+
*/
|
|
110
|
+
declare function pitchSquareClass(x: number, y: number): string;
|
|
111
|
+
interface GrassOverlayProps {
|
|
112
|
+
className?: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Decorative turf texture for the pitch. Absolutely positioned over the square
|
|
116
|
+
* grid and click-through, so it sits between the squares and the pieces without
|
|
117
|
+
* affecting hit-testing or the per-square highlight classes.
|
|
118
|
+
*/
|
|
119
|
+
declare function GrassOverlay({ className }: GrassOverlayProps): react.JSX.Element;
|
|
120
|
+
interface PitchMarkingsProps {
|
|
121
|
+
className?: string;
|
|
122
|
+
children?: React.ReactNode;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The painted pitch lines — touchline, goal boxes, halfway line, centre circle,
|
|
126
|
+
* spots and the two "D" arcs — drawn to look like chalk on grass: a roughened,
|
|
127
|
+
* slightly displaced edge and a noise-driven alpha so the coverage is powdery
|
|
128
|
+
* rather than a crisp vector stroke. A faint, wider unfiltered pass underneath
|
|
129
|
+
* acts as the dust halo the line leaves on the turf.
|
|
130
|
+
*
|
|
131
|
+
* Static and cached by the browser as its own layer; anything dynamic that
|
|
132
|
+
* shares the board's coordinate space (e.g. the pass-trajectory preview) should
|
|
133
|
+
* live in a separate <svg> so a hover repaint never re-runs this filter.
|
|
134
|
+
*/
|
|
135
|
+
declare function PitchMarkings({ className, children }: PitchMarkingsProps): react.JSX.Element;
|
|
136
|
+
interface PitchSurfaceProps {
|
|
137
|
+
className?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Extra classes for a given square (e.g. a highlighted area in a rules
|
|
140
|
+
* diagram). Falsy return values are ignored.
|
|
141
|
+
*/
|
|
142
|
+
squareClassName?: (x: number, y: number) => string | false | null | undefined;
|
|
143
|
+
/** Layers rendered above the markings — pieces, ball, overlays. */
|
|
144
|
+
children?: React.ReactNode;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The complete, non-interactive pitch: squares, turf grain and chalk lines, in
|
|
148
|
+
* that order, inside a container-query wrapper so pieces can size themselves
|
|
149
|
+
* with `cqw`. Callers put their own frame (border/radius) around it and their
|
|
150
|
+
* own piece layer inside it. The interactive GameBoard renders its own square
|
|
151
|
+
* grid (it needs per-square handlers) but builds every square from the same
|
|
152
|
+
* `pitchSquareClass`, and stacks the same GrassOverlay + PitchMarkings.
|
|
153
|
+
*/
|
|
154
|
+
declare function PitchSurface({ className, squareClassName, children }: PitchSurfaceProps): react.JSX.Element;
|
|
155
|
+
|
|
79
156
|
interface TurnBannerProps {
|
|
80
157
|
isMyTurn: boolean;
|
|
81
158
|
/** Override for the "not my turn" label (e.g. "Bot pensando…" in training mode). */
|
|
@@ -101,6 +178,29 @@ interface MobileHistoryProps {
|
|
|
101
178
|
}
|
|
102
179
|
declare function MobileHistory({ className }: MobileHistoryProps): react.JSX.Element | null;
|
|
103
180
|
|
|
181
|
+
interface BallHolderChipProps {
|
|
182
|
+
className?: string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* §12b: a persistent, always-visible answer to "whose ball is it" — the piece
|
|
186
|
+
* type currently holding the ball, drawn as a mini chip. Additive to the subtle
|
|
187
|
+
* per-piece ring on the board. Renders nothing while the ball is loose.
|
|
188
|
+
*
|
|
189
|
+
* GameBoard shows it in its own toolbar by default; apps with a side panel can
|
|
190
|
+
* pass `toolbar={false}` to the board and place this chip wherever it reads best.
|
|
191
|
+
*/
|
|
192
|
+
declare function BallHolderChip({ className }: BallHolderChipProps): react.JSX.Element | null;
|
|
193
|
+
|
|
194
|
+
interface KeyboardShortcutsListProps {
|
|
195
|
+
className?: string;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* §12: the legend of the board's keyboard shortcuts. GameBoard shows it in a
|
|
199
|
+
* popover behind a "?" button in its toolbar; apps that pass `toolbar={false}`
|
|
200
|
+
* can render the list inline in a side panel instead.
|
|
201
|
+
*/
|
|
202
|
+
declare function KeyboardShortcutsList({ className }: KeyboardShortcutsListProps): react.JSX.Element;
|
|
203
|
+
|
|
104
204
|
interface ActionPointsProps {
|
|
105
205
|
total: number;
|
|
106
206
|
remaining: number;
|
|
@@ -183,4 +283,4 @@ declare function useGameT(): GameTranslator;
|
|
|
183
283
|
|
|
184
284
|
declare function cn(...inputs: ClassValue[]): string;
|
|
185
285
|
|
|
186
|
-
export { ActionPoints, Avatar, AvatarFallback, AvatarImage, Button, type ButtonProps, ConfirmDialog, EventToast, Football, GAME_I18N_KEYS, GameBoard, GameControls, type GameI18nKey, GameI18nProvider, GamePiece, type GameTranslator, MiniScoreboard, MobileHistory, MoveHistory, Scoreboard, SelectedPieceDetail, StaticGameBoard, TurnBanner, cn, useGameT };
|
|
286
|
+
export { ActionPoints, Avatar, AvatarFallback, AvatarImage, BallHolderChip, Button, type ButtonProps, ConfirmDialog, EventToast, Football, GAME_I18N_KEYS, GOAL_AREA_SHADE_CLASS, GameBoard, GameControls, type GameI18nKey, GameI18nProvider, GamePiece, type GameTranslator, GrassOverlay, KeyboardShortcutsList, MiniScoreboard, MobileHistory, MoveHistory, PITCH_COLS, PITCH_ROWS, PitchMarkings, PitchSurface, Scoreboard, SelectedPieceDetail, StaticGameBoard, TurnBanner, cn, isGoalAreaSquare, pitchSquareClass, useGameT };
|