@dxos/react-ui-gameboard 0.8.3 → 0.8.4-main.28f8d3d

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.
Files changed (70) hide show
  1. package/dist/lib/browser/index.mjs +407 -381
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +407 -381
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/components/Chessboard/Chessboard.d.ts +15 -0
  8. package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -0
  9. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +28 -0
  10. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -0
  11. package/dist/types/src/{Chessboard → components/Chessboard}/chess.d.ts +20 -7
  12. package/dist/types/src/components/Chessboard/chess.d.ts.map +1 -0
  13. package/dist/types/src/components/Chessboard/index.d.ts.map +1 -0
  14. package/dist/types/src/components/Gameboard/Gameboard.d.ts +37 -0
  15. package/dist/types/src/components/Gameboard/Gameboard.d.ts.map +1 -0
  16. package/dist/types/src/{Board → components/Gameboard}/Piece.d.ts +3 -2
  17. package/dist/types/src/components/Gameboard/Piece.d.ts.map +1 -0
  18. package/dist/types/src/components/Gameboard/Square.d.ts.map +1 -0
  19. package/dist/types/src/components/Gameboard/index.d.ts +4 -0
  20. package/dist/types/src/components/Gameboard/index.d.ts.map +1 -0
  21. package/dist/types/src/{Board → components/Gameboard}/types.d.ts +2 -1
  22. package/dist/types/src/components/Gameboard/types.d.ts.map +1 -0
  23. package/dist/types/src/components/Gameboard/util.d.ts.map +1 -0
  24. package/dist/types/src/components/index.d.ts +3 -0
  25. package/dist/types/src/components/index.d.ts.map +1 -0
  26. package/dist/types/src/index.d.ts +1 -2
  27. package/dist/types/src/index.d.ts.map +1 -1
  28. package/dist/types/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +19 -14
  30. package/src/{Chessboard → components/Chessboard}/Chessboard.stories.tsx +33 -30
  31. package/src/components/Chessboard/Chessboard.tsx +191 -0
  32. package/src/{Chessboard → components/Chessboard}/chess.ts +88 -28
  33. package/src/components/Gameboard/Gameboard.tsx +139 -0
  34. package/src/{Board → components/Gameboard}/Piece.tsx +19 -20
  35. package/src/{Board → components/Gameboard}/Square.tsx +4 -4
  36. package/src/components/Gameboard/index.ts +8 -0
  37. package/src/{Board → components/Gameboard}/types.ts +3 -1
  38. package/src/components/index.ts +6 -0
  39. package/src/index.ts +1 -2
  40. package/dist/lib/node/index.cjs +0 -1039
  41. package/dist/lib/node/index.cjs.map +0 -7
  42. package/dist/lib/node/meta.json +0 -1
  43. package/dist/types/src/Board/Board.d.ts +0 -15
  44. package/dist/types/src/Board/Board.d.ts.map +0 -1
  45. package/dist/types/src/Board/Container.d.ts +0 -14
  46. package/dist/types/src/Board/Container.d.ts.map +0 -1
  47. package/dist/types/src/Board/Piece.d.ts.map +0 -1
  48. package/dist/types/src/Board/Square.d.ts.map +0 -1
  49. package/dist/types/src/Board/context.d.ts +0 -10
  50. package/dist/types/src/Board/context.d.ts.map +0 -1
  51. package/dist/types/src/Board/index.d.ts +0 -8
  52. package/dist/types/src/Board/index.d.ts.map +0 -1
  53. package/dist/types/src/Board/types.d.ts.map +0 -1
  54. package/dist/types/src/Board/util.d.ts.map +0 -1
  55. package/dist/types/src/Chessboard/Chessboard.d.ts +0 -14
  56. package/dist/types/src/Chessboard/Chessboard.d.ts.map +0 -1
  57. package/dist/types/src/Chessboard/Chessboard.stories.d.ts +0 -16
  58. package/dist/types/src/Chessboard/Chessboard.stories.d.ts.map +0 -1
  59. package/dist/types/src/Chessboard/chess.d.ts.map +0 -1
  60. package/dist/types/src/Chessboard/index.d.ts.map +0 -1
  61. package/src/Board/Board.tsx +0 -86
  62. package/src/Board/Container.tsx +0 -25
  63. package/src/Board/context.ts +0 -22
  64. package/src/Board/index.ts +0 -12
  65. package/src/Chessboard/Chessboard.tsx +0 -190
  66. /package/dist/types/src/{Chessboard → components/Chessboard}/index.d.ts +0 -0
  67. /package/dist/types/src/{Board → components/Gameboard}/Square.d.ts +0 -0
  68. /package/dist/types/src/{Board → components/Gameboard}/util.d.ts +0 -0
  69. /package/src/{Chessboard → components/Chessboard}/index.ts +0 -0
  70. /package/src/{Board → components/Gameboard}/util.ts +0 -0
@@ -0,0 +1,37 @@
1
+ import React, { type PropsWithChildren } from 'react';
2
+ import { type ThemedClassName } from '@dxos/react-ui';
3
+ import { type PieceProps } from './Piece';
4
+ import { type SquareProps } from './Square';
5
+ import { type GameboardModel, type Move, type PieceRecord } from './types';
6
+ export type GameboardContextValue<M extends GameboardModel> = {
7
+ model: M;
8
+ dragging?: boolean;
9
+ promoting?: PieceRecord;
10
+ onPromotion: (move: Move) => void;
11
+ };
12
+ declare const useGameboardContext: <M extends GameboardModel>(consumerName: string) => GameboardContextValue<M>;
13
+ type GameboardRootProps<M extends GameboardModel> = PropsWithChildren<{
14
+ model?: M;
15
+ onDrop?: (move: Move) => boolean;
16
+ }>;
17
+ type GameboardContentProps = ThemedClassName<PropsWithChildren<{
18
+ grow?: boolean;
19
+ contain?: boolean;
20
+ }>>;
21
+ export declare const Gameboard: {
22
+ Root: {
23
+ <M extends GameboardModel>({ children, model, onDrop }: GameboardRootProps<M>): React.JSX.Element;
24
+ displayName: string;
25
+ };
26
+ Content: React.ForwardRefExoticComponent<Omit<React.PropsWithChildren<{
27
+ grow?: boolean;
28
+ contain?: boolean;
29
+ }>, "className"> & {
30
+ classNames?: import("@dxos/react-ui-types").ClassNameValue;
31
+ } & React.RefAttributes<HTMLDivElement>>;
32
+ Piece: React.MemoExoticComponent<({ classNames, Component, piece, orientation, bounds, label, onClick }: PieceProps) => React.JSX.Element>;
33
+ Square: React.MemoExoticComponent<({ location, bounds, label, classNames }: SquareProps) => React.JSX.Element>;
34
+ };
35
+ export { useGameboardContext };
36
+ export type { GameboardRootProps, GameboardContentProps, PieceProps as GameboardPieceProps, SquareProps as GameboardSquareProps, };
37
+ //# sourceMappingURL=Gameboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Gameboard.d.ts","sourceRoot":"","sources":["../../../../../src/components/Gameboard/Gameboard.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAgD,MAAM,OAAO,CAAC;AAGpG,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,IAAI,EAAE,KAAK,WAAW,EAAuB,MAAM,SAAS,CAAC;AAEhG,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,cAAc,IAAI;IAC5D,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACnC,CAAC;AAIF,QAAA,MAAM,mBAAmB,GAAI,CAAC,SAAS,cAAc,EAAE,cAAc,MAAM,KAAG,qBAAqB,CAAC,CAAC,CAEpG,CAAC;AAMF,KAAK,kBAAkB,CAAC,CAAC,SAAS,cAAc,IAAI,iBAAiB,CAAC;IACpE,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;CAClC,CAAC,CAAC;AAkEH,KAAK,qBAAqB,GAAG,eAAe,CAAC,iBAAiB,CAAC;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,CAAC;AAsBvG,eAAO,MAAM,SAAS;;SAnFC,CAAC,SAAS,cAAc,+BAA+B,kBAAkB,CAAC,CAAC,CAAC;;;;eA6D3B,OAAO;kBAAY,OAAO;;;;;;CA2BjG,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,IAAI,mBAAmB,EACjC,WAAW,IAAI,oBAAoB,GACpC,CAAC"}
@@ -3,11 +3,12 @@ import { type ThemedClassName } from '@dxos/react-ui';
3
3
  import { type PieceRecord, type Player } from './types';
4
4
  import { type DOMRectBounds } from './util';
5
5
  export type PieceProps = ThemedClassName<{
6
+ Component: FC<SVGProps<SVGSVGElement>>;
6
7
  piece: PieceRecord;
7
8
  bounds: DOMRectBounds;
8
9
  label?: string;
9
10
  orientation?: Player;
10
- Component: FC<SVGProps<SVGSVGElement>>;
11
+ onClick?: () => void;
11
12
  }>;
12
- export declare const Piece: React.MemoExoticComponent<({ classNames, piece, orientation, bounds, label, Component }: PieceProps) => React.JSX.Element>;
13
+ export declare const Piece: React.MemoExoticComponent<({ classNames, Component, piece, orientation, bounds, label, onClick }: PieceProps) => React.JSX.Element>;
13
14
  //# sourceMappingURL=Piece.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Piece.d.ts","sourceRoot":"","sources":["../../../../../src/components/Gameboard/Piece.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,QAAQ,EAAqC,MAAM,OAAO,CAAC;AAKzF,OAAO,EAAE,KAAK,eAAe,EAAgC,MAAM,gBAAgB,CAAC;AAIpF,OAAO,EAAiB,KAAK,WAAW,EAAE,KAAK,MAAM,EAA+B,MAAM,SAAS,CAAC;AACpG,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5C,MAAM,MAAM,UAAU,GAAG,eAAe,CAAC;IACvC,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;IACvC,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC,CAAC;AAEH,eAAO,MAAM,KAAK,oGAAgF,UAAU,uBAuG1G,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Square.d.ts","sourceRoot":"","sources":["../../../../../src/components/Gameboard/Square.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA4C,MAAM,OAAO,CAAC;AAIjE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItD,OAAO,EAAE,KAAK,QAAQ,EAAW,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAI5C,MAAM,MAAM,WAAW,GAAG,eAAe,CAAC;IACxC,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,eAAO,MAAM,MAAM,sEAAkD,WAAW,uBA+C9E,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export * from './util';
3
+ export * from './Gameboard';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Gameboard/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AAEvB,cAAc,aAAa,CAAC"}
@@ -26,8 +26,9 @@ export declare const isEqualLocation: (l1: Location, l2: Location) => boolean;
26
26
  /**
27
27
  * Generic board model.
28
28
  */
29
- export interface BoardModel<T extends PieceType = PieceType> {
29
+ export interface GameboardModel<T extends PieceType = PieceType> {
30
30
  turn: Player;
31
+ /** @reactive */
31
32
  pieces: ReadonlySignal<PieceMap<T>>;
32
33
  isValidMove: (move: Move) => boolean;
33
34
  canPromote?: (move: Move) => boolean;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/Gameboard/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAEvC,MAAM,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAExC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI;IACzD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAEvF,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,EAAE,EAAE,QAAQ,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,UAAU,QAAQ,KAAG,MAA4B,CAAC;AACnF,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,KAAG,QAAkD,CAAC;AAGlG,eAAO,MAAM,OAAO,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,WAMtB,CAAC;AAG7B,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,QACwC,CAAC;AAE9F,eAAO,MAAM,eAAe,GAAI,IAAI,QAAQ,EAAE,IAAI,QAAQ,KAAG,OAA6C,CAAC;AAE3G;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB;IAChB,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;IACrC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;CACtC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../../src/components/Gameboard/util.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC,CAAC;AAE/E,eAAO,MAAM,iBAAiB,GAAI,WAAW,WAAW,EAAE,SAAS,WAAW,KAAG,aAShF,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './Gameboard';
2
+ export * from './Chessboard';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
@@ -1,3 +1,2 @@
1
- export * from './Board';
2
- export * from './Chessboard';
1
+ export * from './components';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC"}