@dxos/react-ui-gameboard 0.7.5-labs.071a3e2

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 (130) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +21 -0
  3. package/dist/lib/browser/index.mjs +903 -0
  4. package/dist/lib/browser/index.mjs.map +7 -0
  5. package/dist/lib/browser/meta.json +1 -0
  6. package/dist/lib/node/index.cjs +908 -0
  7. package/dist/lib/node/index.cjs.map +7 -0
  8. package/dist/lib/node/meta.json +1 -0
  9. package/dist/lib/node-esm/index.mjs +904 -0
  10. package/dist/lib/node-esm/index.mjs.map +7 -0
  11. package/dist/lib/node-esm/meta.json +1 -0
  12. package/dist/types/src/Board/Board.d.ts +15 -0
  13. package/dist/types/src/Board/Board.d.ts.map +1 -0
  14. package/dist/types/src/Board/Container.d.ts +14 -0
  15. package/dist/types/src/Board/Container.d.ts.map +1 -0
  16. package/dist/types/src/Board/Piece.d.ts +13 -0
  17. package/dist/types/src/Board/Piece.d.ts.map +1 -0
  18. package/dist/types/src/Board/Square.d.ts +11 -0
  19. package/dist/types/src/Board/Square.d.ts.map +1 -0
  20. package/dist/types/src/Board/context.d.ts +10 -0
  21. package/dist/types/src/Board/context.d.ts.map +1 -0
  22. package/dist/types/src/Board/index.d.ts +8 -0
  23. package/dist/types/src/Board/index.d.ts.map +1 -0
  24. package/dist/types/src/Board/types.d.ts +35 -0
  25. package/dist/types/src/Board/types.d.ts.map +1 -0
  26. package/dist/types/src/Board/util.d.ts +3 -0
  27. package/dist/types/src/Board/util.d.ts.map +1 -0
  28. package/dist/types/src/Chessboard/Chessboard.d.ts +14 -0
  29. package/dist/types/src/Chessboard/Chessboard.d.ts.map +1 -0
  30. package/dist/types/src/Chessboard/Chessboard.stories.d.ts +16 -0
  31. package/dist/types/src/Chessboard/Chessboard.stories.d.ts.map +1 -0
  32. package/dist/types/src/Chessboard/chess.d.ts +40 -0
  33. package/dist/types/src/Chessboard/chess.d.ts.map +1 -0
  34. package/dist/types/src/Chessboard/index.d.ts +3 -0
  35. package/dist/types/src/Chessboard/index.d.ts.map +1 -0
  36. package/dist/types/src/gen/pieces/chess/alpha/bB.d.ts +5 -0
  37. package/dist/types/src/gen/pieces/chess/alpha/bB.d.ts.map +1 -0
  38. package/dist/types/src/gen/pieces/chess/alpha/bK.d.ts +5 -0
  39. package/dist/types/src/gen/pieces/chess/alpha/bK.d.ts.map +1 -0
  40. package/dist/types/src/gen/pieces/chess/alpha/bN.d.ts +5 -0
  41. package/dist/types/src/gen/pieces/chess/alpha/bN.d.ts.map +1 -0
  42. package/dist/types/src/gen/pieces/chess/alpha/bP.d.ts +5 -0
  43. package/dist/types/src/gen/pieces/chess/alpha/bP.d.ts.map +1 -0
  44. package/dist/types/src/gen/pieces/chess/alpha/bQ.d.ts +5 -0
  45. package/dist/types/src/gen/pieces/chess/alpha/bQ.d.ts.map +1 -0
  46. package/dist/types/src/gen/pieces/chess/alpha/bR.d.ts +5 -0
  47. package/dist/types/src/gen/pieces/chess/alpha/bR.d.ts.map +1 -0
  48. package/dist/types/src/gen/pieces/chess/alpha/index.d.ts +13 -0
  49. package/dist/types/src/gen/pieces/chess/alpha/index.d.ts.map +1 -0
  50. package/dist/types/src/gen/pieces/chess/alpha/wB.d.ts +5 -0
  51. package/dist/types/src/gen/pieces/chess/alpha/wB.d.ts.map +1 -0
  52. package/dist/types/src/gen/pieces/chess/alpha/wK.d.ts +5 -0
  53. package/dist/types/src/gen/pieces/chess/alpha/wK.d.ts.map +1 -0
  54. package/dist/types/src/gen/pieces/chess/alpha/wN.d.ts +5 -0
  55. package/dist/types/src/gen/pieces/chess/alpha/wN.d.ts.map +1 -0
  56. package/dist/types/src/gen/pieces/chess/alpha/wP.d.ts +5 -0
  57. package/dist/types/src/gen/pieces/chess/alpha/wP.d.ts.map +1 -0
  58. package/dist/types/src/gen/pieces/chess/alpha/wQ.d.ts +5 -0
  59. package/dist/types/src/gen/pieces/chess/alpha/wQ.d.ts.map +1 -0
  60. package/dist/types/src/gen/pieces/chess/alpha/wR.d.ts +5 -0
  61. package/dist/types/src/gen/pieces/chess/alpha/wR.d.ts.map +1 -0
  62. package/dist/types/src/gen/pieces/chess/cburnett/bB.d.ts +5 -0
  63. package/dist/types/src/gen/pieces/chess/cburnett/bB.d.ts.map +1 -0
  64. package/dist/types/src/gen/pieces/chess/cburnett/bK.d.ts +5 -0
  65. package/dist/types/src/gen/pieces/chess/cburnett/bK.d.ts.map +1 -0
  66. package/dist/types/src/gen/pieces/chess/cburnett/bN.d.ts +5 -0
  67. package/dist/types/src/gen/pieces/chess/cburnett/bN.d.ts.map +1 -0
  68. package/dist/types/src/gen/pieces/chess/cburnett/bP.d.ts +5 -0
  69. package/dist/types/src/gen/pieces/chess/cburnett/bP.d.ts.map +1 -0
  70. package/dist/types/src/gen/pieces/chess/cburnett/bQ.d.ts +5 -0
  71. package/dist/types/src/gen/pieces/chess/cburnett/bQ.d.ts.map +1 -0
  72. package/dist/types/src/gen/pieces/chess/cburnett/bR.d.ts +5 -0
  73. package/dist/types/src/gen/pieces/chess/cburnett/bR.d.ts.map +1 -0
  74. package/dist/types/src/gen/pieces/chess/cburnett/index.d.ts +13 -0
  75. package/dist/types/src/gen/pieces/chess/cburnett/index.d.ts.map +1 -0
  76. package/dist/types/src/gen/pieces/chess/cburnett/wB.d.ts +5 -0
  77. package/dist/types/src/gen/pieces/chess/cburnett/wB.d.ts.map +1 -0
  78. package/dist/types/src/gen/pieces/chess/cburnett/wK.d.ts +5 -0
  79. package/dist/types/src/gen/pieces/chess/cburnett/wK.d.ts.map +1 -0
  80. package/dist/types/src/gen/pieces/chess/cburnett/wN.d.ts +5 -0
  81. package/dist/types/src/gen/pieces/chess/cburnett/wN.d.ts.map +1 -0
  82. package/dist/types/src/gen/pieces/chess/cburnett/wP.d.ts +5 -0
  83. package/dist/types/src/gen/pieces/chess/cburnett/wP.d.ts.map +1 -0
  84. package/dist/types/src/gen/pieces/chess/cburnett/wQ.d.ts +5 -0
  85. package/dist/types/src/gen/pieces/chess/cburnett/wQ.d.ts.map +1 -0
  86. package/dist/types/src/gen/pieces/chess/cburnett/wR.d.ts +5 -0
  87. package/dist/types/src/gen/pieces/chess/cburnett/wR.d.ts.map +1 -0
  88. package/dist/types/src/index.d.ts +3 -0
  89. package/dist/types/src/index.d.ts.map +1 -0
  90. package/dist/types/tsconfig.tsbuildinfo +1 -0
  91. package/package.json +61 -0
  92. package/src/Board/Board.tsx +86 -0
  93. package/src/Board/Container.tsx +25 -0
  94. package/src/Board/Piece.tsx +135 -0
  95. package/src/Board/Square.tsx +74 -0
  96. package/src/Board/context.ts +22 -0
  97. package/src/Board/index.ts +12 -0
  98. package/src/Board/types.ts +58 -0
  99. package/src/Board/util.ts +16 -0
  100. package/src/Chessboard/Chessboard.stories.tsx +108 -0
  101. package/src/Chessboard/Chessboard.tsx +190 -0
  102. package/src/Chessboard/chess.ts +213 -0
  103. package/src/Chessboard/index.ts +7 -0
  104. package/src/gen/pieces/chess/alpha/bB.tsx +12 -0
  105. package/src/gen/pieces/chess/alpha/bK.tsx +15 -0
  106. package/src/gen/pieces/chess/alpha/bN.tsx +15 -0
  107. package/src/gen/pieces/chess/alpha/bP.tsx +11 -0
  108. package/src/gen/pieces/chess/alpha/bQ.tsx +12 -0
  109. package/src/gen/pieces/chess/alpha/bR.tsx +12 -0
  110. package/src/gen/pieces/chess/alpha/index.ts +12 -0
  111. package/src/gen/pieces/chess/alpha/wB.tsx +15 -0
  112. package/src/gen/pieces/chess/alpha/wK.tsx +15 -0
  113. package/src/gen/pieces/chess/alpha/wN.tsx +15 -0
  114. package/src/gen/pieces/chess/alpha/wP.tsx +15 -0
  115. package/src/gen/pieces/chess/alpha/wQ.tsx +15 -0
  116. package/src/gen/pieces/chess/alpha/wR.tsx +15 -0
  117. package/src/gen/pieces/chess/cburnett/bB.tsx +15 -0
  118. package/src/gen/pieces/chess/cburnett/bK.tsx +26 -0
  119. package/src/gen/pieces/chess/cburnett/bN.tsx +24 -0
  120. package/src/gen/pieces/chess/cburnett/bP.tsx +13 -0
  121. package/src/gen/pieces/chess/cburnett/bQ.tsx +30 -0
  122. package/src/gen/pieces/chess/cburnett/bR.tsx +19 -0
  123. package/src/gen/pieces/chess/cburnett/index.ts +12 -0
  124. package/src/gen/pieces/chess/cburnett/wB.tsx +15 -0
  125. package/src/gen/pieces/chess/cburnett/wK.tsx +21 -0
  126. package/src/gen/pieces/chess/cburnett/wN.tsx +18 -0
  127. package/src/gen/pieces/chess/cburnett/wP.tsx +14 -0
  128. package/src/gen/pieces/chess/cburnett/wQ.tsx +16 -0
  129. package/src/gen/pieces/chess/cburnett/wR.tsx +14 -0
  130. package/src/index.ts +6 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wN.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/alpha/wN.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBAW5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { SVGProps } from 'react';
3
+ declare const SvgWP: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
4
+ export default SvgWP;
5
+ //# sourceMappingURL=wP.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wP.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/alpha/wP.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBAW5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { SVGProps } from 'react';
3
+ declare const SvgWQ: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
4
+ export default SvgWQ;
5
+ //# sourceMappingURL=wQ.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wQ.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/alpha/wQ.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBAW5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { SVGProps } from 'react';
3
+ declare const SvgWR: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
4
+ export default SvgWR;
5
+ //# sourceMappingURL=wR.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wR.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/alpha/wR.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBAW5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { SVGProps } from 'react';
3
+ declare const SvgBB: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
4
+ export default SvgBB;
5
+ //# sourceMappingURL=bB.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bB.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/cburnett/bB.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBAW5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { SVGProps } from 'react';
3
+ declare const SvgBK: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
4
+ export default SvgBK;
5
+ //# sourceMappingURL=bK.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bK.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/cburnett/bK.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBAsB5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { SVGProps } from 'react';
3
+ declare const SvgBN: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
4
+ export default SvgBN;
5
+ //# sourceMappingURL=bN.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bN.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/cburnett/bN.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBAoB5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { SVGProps } from 'react';
3
+ declare const SvgBP: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
4
+ export default SvgBP;
5
+ //# sourceMappingURL=bP.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bP.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/cburnett/bP.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBAS5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { SVGProps } from 'react';
3
+ declare const SvgBQ: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
4
+ export default SvgBQ;
5
+ //# sourceMappingURL=bQ.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bQ.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/cburnett/bQ.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBA0B5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { SVGProps } from 'react';
3
+ declare const SvgBR: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
4
+ export default SvgBR;
5
+ //# sourceMappingURL=bR.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bR.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/cburnett/bR.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBAe5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,13 @@
1
+ export { default as BB } from './bB';
2
+ export { default as BK } from './bK';
3
+ export { default as BN } from './bN';
4
+ export { default as BP } from './bP';
5
+ export { default as BQ } from './bQ';
6
+ export { default as BR } from './bR';
7
+ export { default as WB } from './wB';
8
+ export { default as WK } from './wK';
9
+ export { default as WN } from './wN';
10
+ export { default as WP } from './wP';
11
+ export { default as WQ } from './wQ';
12
+ export { default as WR } from './wR';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/cburnett/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,MAAM,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { SVGProps } from 'react';
3
+ declare const SvgWB: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
4
+ export default SvgWB;
5
+ //# sourceMappingURL=wB.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wB.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/cburnett/wB.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBAW5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { SVGProps } from 'react';
3
+ declare const SvgWK: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
4
+ export default SvgWK;
5
+ //# sourceMappingURL=wK.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wK.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/cburnett/wK.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBAiB5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { SVGProps } from 'react';
3
+ declare const SvgWN: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
4
+ export default SvgWN;
5
+ //# sourceMappingURL=wN.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wN.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/cburnett/wN.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBAc5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { SVGProps } from 'react';
3
+ declare const SvgWP: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
4
+ export default SvgWP;
5
+ //# sourceMappingURL=wP.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wP.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/cburnett/wP.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBAU5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { SVGProps } from 'react';
3
+ declare const SvgWQ: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
4
+ export default SvgWQ;
5
+ //# sourceMappingURL=wQ.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wQ.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/cburnett/wQ.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBAY5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { SVGProps } from 'react';
3
+ declare const SvgWR: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
4
+ export default SvgWR;
5
+ //# sourceMappingURL=wR.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wR.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/pieces/chess/cburnett/wR.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,QAAA,MAAM,KAAK,UAAW,QAAQ,CAAC,aAAa,CAAC,sBAU5C,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './Board';
2
+ export * from './Chessboard';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":"5.7.3"}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@dxos/react-ui-gameboard",
3
+ "version": "0.7.5-labs.071a3e2",
4
+ "description": "Game board.",
5
+ "homepage": "https://dxos.org",
6
+ "bugs": "https://github.com/dxos/dxos/issues",
7
+ "license": "MIT",
8
+ "author": "DXOS.org",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/types/src/index.d.ts",
12
+ "browser": "./dist/lib/browser/index.mjs",
13
+ "node": "./dist/lib/node-esm/index.mjs"
14
+ }
15
+ },
16
+ "types": "dist/types/src/index.d.ts",
17
+ "files": [
18
+ "dist",
19
+ "src"
20
+ ],
21
+ "dependencies": {
22
+ "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
23
+ "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.3",
24
+ "@preact/signals-core": "^1.6.0",
25
+ "chess.js": "^1.0.0",
26
+ "react-resize-detector": "^11.0.1",
27
+ "@dxos/debug": "0.7.5-labs.071a3e2",
28
+ "@dxos/log": "0.7.5-labs.071a3e2",
29
+ "@dxos/node-std": "0.7.5-labs.071a3e2",
30
+ "@dxos/invariant": "0.7.5-labs.071a3e2",
31
+ "@dxos/util": "0.7.5-labs.071a3e2"
32
+ },
33
+ "devDependencies": {
34
+ "@svgr/cli": "^8.1.0",
35
+ "@types/lodash.defaultsdeep": "^4.6.6",
36
+ "@types/react": "~18.2.0",
37
+ "@types/react-dom": "~18.2.0",
38
+ "lodash.defaultsdeep": "^4.6.1",
39
+ "react": "~18.2.0",
40
+ "react-dom": "~18.2.0",
41
+ "vite": "5.4.7",
42
+ "@dxos/react-ui": "0.7.5-labs.071a3e2",
43
+ "@dxos/react-ui-theme": "0.7.5-labs.071a3e2",
44
+ "@dxos/storybook-utils": "0.7.5-labs.071a3e2"
45
+ },
46
+ "peerDependencies": {
47
+ "react": "~18.2.0",
48
+ "react-dom": "~18.2.0",
49
+ "@dxos/react-ui": "0.7.5-labs.071a3e2",
50
+ "@dxos/react-ui-theme": "0.7.5-labs.071a3e2"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "scripts": {
56
+ "gen:pieces": "pnpm gen:pieces:chess",
57
+ "gen:pieces:chess": "pnpm gen:pieces:chess:alpha && pnpm gen:pieces:chess:cburnett",
58
+ "gen:pieces:chess:alpha": "pnpm svgr --typescript --filename-case=camel --out-dir ./src/gen/pieces/chess/alpha ./assets/pieces/chess/alpha",
59
+ "gen:pieces:chess:cburnett": "pnpm svgr --typescript --filename-case=camel --out-dir ./src/gen/pieces/chess/cburnett ./assets/pieces/chess/cburnett"
60
+ }
61
+ }
@@ -0,0 +1,86 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
6
+ import React, { type PropsWithChildren, useCallback, useEffect, useState } from 'react';
7
+
8
+ import { log } from '@dxos/log';
9
+ import { type ThemedClassName } from '@dxos/react-ui';
10
+ import { mx } from '@dxos/react-ui-theme';
11
+
12
+ import { Container } from './Container';
13
+ import { BoardContext, type BoardContextType } from './context';
14
+ import { type BoardModel, isLocation, isPiece, type Move, type PieceRecord } from './types';
15
+
16
+ type RootProps = ThemedClassName<
17
+ PropsWithChildren<{
18
+ model?: BoardModel;
19
+ onDrop?: (move: Move) => boolean;
20
+ }>
21
+ >;
22
+
23
+ /**
24
+ * Generic board container.
25
+ */
26
+ const Root = ({ children, classNames, model, onDrop }: RootProps) => {
27
+ const [dragging, setDragging] = useState(false);
28
+ const [promoting, setPromoting] = useState<PieceRecord | undefined>();
29
+
30
+ // Handle promotion.
31
+ const onPromotion = useCallback<BoardContextType['onPromotion']>((move) => {
32
+ log('onPromotion', { move });
33
+ setPromoting(undefined);
34
+ onDrop?.(move);
35
+ }, []);
36
+
37
+ useEffect(() => {
38
+ if (!model) {
39
+ return;
40
+ }
41
+
42
+ // TODO(burdon): Should target specific container.
43
+ return monitorForElements({
44
+ onDragStart: ({ source }) => {
45
+ log('onDragStart', { source });
46
+ setDragging(true);
47
+ },
48
+ onDrop: ({ source, location }) => {
49
+ log('onDrop', { source, location });
50
+ const target = location.current.dropTargets[0];
51
+ if (!target) {
52
+ return;
53
+ }
54
+
55
+ const targetLocation = target.data.location;
56
+ const piece = source.data.piece;
57
+ if (!isLocation(targetLocation) || !isPiece(piece)) {
58
+ return;
59
+ }
60
+
61
+ const move: Move = { from: piece.location, to: targetLocation, piece: piece.type };
62
+ if (model.canPromote?.(move)) {
63
+ setPromoting({ ...piece, location: targetLocation });
64
+ } else {
65
+ onDrop?.(move);
66
+ }
67
+
68
+ setDragging(false);
69
+ },
70
+ });
71
+ }, [model]);
72
+
73
+ return (
74
+ <BoardContext.Provider value={{ model, dragging, promoting, onPromotion }}>
75
+ <Container classNames={mx('aspect-square', classNames)}>{children}</Container>
76
+ </BoardContext.Provider>
77
+ );
78
+ };
79
+
80
+ Root.displayName = 'Board.Root';
81
+
82
+ export const Board = {
83
+ Root,
84
+ };
85
+
86
+ export type { RootProps as BoardRootProps };
@@ -0,0 +1,25 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { forwardRef, type PropsWithChildren } from 'react';
6
+
7
+ import { type ThemedClassName } from '@dxos/react-ui';
8
+ import { mx } from '@dxos/react-ui-theme';
9
+
10
+ export type ContainerProps = ThemedClassName<
11
+ PropsWithChildren<{
12
+ style?: React.CSSProperties;
13
+ }>
14
+ >;
15
+
16
+ /**
17
+ * Container centers the board.
18
+ */
19
+ export const Container = forwardRef<HTMLDivElement, ContainerProps>(({ children, classNames, style }, forwardedRef) => {
20
+ return (
21
+ <div ref={forwardedRef} style={style} className='flex w-full h-full justify-center overflow-hidden'>
22
+ <div className={mx('max-w-full max-h-full content-center', classNames)}>{children}</div>
23
+ </div>
24
+ );
25
+ });
@@ -0,0 +1,135 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
6
+ // import { preserveOffsetOnSource } from '@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source';
7
+ import { centerUnderPointer } from '@atlaskit/pragmatic-drag-and-drop/element/center-under-pointer';
8
+ import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
9
+ import React, { useState, useRef, useEffect, type FC, type SVGProps, memo } from 'react';
10
+ import { createPortal } from 'react-dom';
11
+
12
+ import { invariant } from '@dxos/invariant';
13
+ import { log } from '@dxos/log';
14
+ import { useDynamicRef, useTrackProps, type ThemedClassName } from '@dxos/react-ui';
15
+ import { mx } from '@dxos/react-ui-theme';
16
+
17
+ import { useBoardContext } from './context';
18
+ import { isEqualLocation, isLocation, type Location, type PieceRecord, type Player } from './types';
19
+ import { type DOMRectBounds } from './util';
20
+
21
+ export type PieceProps = ThemedClassName<{
22
+ piece: PieceRecord;
23
+ bounds: DOMRectBounds;
24
+ label?: string;
25
+ orientation?: Player;
26
+ Component: FC<SVGProps<SVGSVGElement>>;
27
+ }>;
28
+
29
+ export const Piece = memo(({ classNames, piece, orientation, bounds, label, Component }: PieceProps) => {
30
+ useTrackProps({ classNames, piece, orientation, bounds, label, Component }, Piece.displayName, false);
31
+ const { model } = useBoardContext();
32
+
33
+ const { dragging: isDragging, promoting } = useBoardContext();
34
+ const promotingRef = useDynamicRef(promoting);
35
+ const [dragging, setDragging] = useState(false);
36
+ const [preview, setPreview] = useState<HTMLElement>();
37
+
38
+ // Current position.
39
+ const [current, setCurrent] = useState<{ location?: Location; bounds?: DOMRectBounds }>({});
40
+
41
+ const ref = useRef<HTMLDivElement>(null);
42
+ useEffect(() => {
43
+ const el = ref.current;
44
+ invariant(el);
45
+
46
+ return draggable({
47
+ element: el,
48
+ getInitialData: () => ({ piece }),
49
+ onGenerateDragPreview: ({ nativeSetDragImage, location, source }) => {
50
+ log('onGenerateDragPreview', { source: source.data });
51
+ setCustomNativeDragPreview({
52
+ getOffset: centerUnderPointer,
53
+ // getOffset: preserveOffsetOnSource({
54
+ // element: source.element,
55
+ // input: location.current.input,
56
+ // }),
57
+ render: ({ container }) => {
58
+ setPreview(container);
59
+ const { width, height } = el.getBoundingClientRect();
60
+ container.style.width = width + 'px';
61
+ container.style.height = height + 'px';
62
+ return () => {
63
+ setPreview(undefined);
64
+ };
65
+ },
66
+ nativeSetDragImage,
67
+ });
68
+ },
69
+ canDrag: () => !promotingRef.current && model?.turn === piece.side,
70
+ onDragStart: () => setDragging(true),
71
+ onDrop: ({ location: { current } }) => {
72
+ const location = current.dropTargets[0].data.location;
73
+ if (isLocation(location)) {
74
+ setCurrent((current) => ({ ...current, location }));
75
+ }
76
+
77
+ setDragging(false);
78
+ },
79
+ });
80
+ }, [model, piece]);
81
+
82
+ // Must update position independently of render cycle (otherwise animation is interrupted).
83
+ useEffect(() => {
84
+ requestAnimationFrame(() => {
85
+ if (!ref.current || !bounds) {
86
+ return;
87
+ }
88
+
89
+ // Check if piece moved.
90
+ if (!current.location || !isEqualLocation(current.location, piece.location)) {
91
+ ref.current.style.transition = 'top 400ms ease-out, left 400ms ease-out';
92
+ ref.current.style.top = bounds.top + 'px';
93
+ ref.current.style.left = bounds.left + 'px';
94
+ setCurrent({ location: piece.location, bounds });
95
+ } else if (current.bounds !== bounds) {
96
+ ref.current.style.transition = 'none';
97
+ ref.current.style.top = bounds.top + 'px';
98
+ ref.current.style.left = bounds.left + 'px';
99
+ setCurrent({ location: piece.location, bounds });
100
+ }
101
+ });
102
+ }, [current, piece.location, bounds]);
103
+
104
+ return (
105
+ <>
106
+ <div
107
+ ref={ref}
108
+ style={{
109
+ width: bounds?.width,
110
+ height: bounds?.height,
111
+ }}
112
+ className={mx(
113
+ 'absolute',
114
+ classNames,
115
+ // orientation === 'black' && '_rotate-180',
116
+ dragging && 'opacity-20', // Must not unmount component while dragging.
117
+ isDragging && 'pointer-events-none', // Don't block the square's drop target.
118
+ )}
119
+ >
120
+ <Component className='grow' />
121
+ {label && <div className='absolute inset-1 text-xs text-black'>{label}</div>}
122
+ </div>
123
+
124
+ {preview &&
125
+ createPortal(
126
+ <div className={mx(classNames)}>
127
+ <Component className='grow' />
128
+ </div>,
129
+ preview,
130
+ )}
131
+ </>
132
+ );
133
+ });
134
+
135
+ Piece.displayName = 'Piece';
@@ -0,0 +1,74 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
6
+ import React, { useRef, useState, useEffect, memo } from 'react';
7
+
8
+ import { invariant } from '@dxos/invariant';
9
+ import { log } from '@dxos/log';
10
+ import { type ThemedClassName } from '@dxos/react-ui';
11
+ import { mx } from '@dxos/react-ui-theme';
12
+
13
+ import { useBoardContext } from './context';
14
+ import { isPiece, type Location } from './types';
15
+ import { type DOMRectBounds } from './util';
16
+
17
+ type HoveredState = 'idle' | 'validMove' | 'invalidMove';
18
+
19
+ export type SquareProps = ThemedClassName<{
20
+ location: Location;
21
+ bounds: DOMRectBounds;
22
+ label?: string;
23
+ }>;
24
+
25
+ export const Square = memo(({ location, bounds, label, classNames }: SquareProps) => {
26
+ const ref = useRef<HTMLDivElement>(null);
27
+ const [state, setState] = useState<HoveredState>('idle');
28
+ const { model } = useBoardContext();
29
+
30
+ useEffect(() => {
31
+ const el = ref.current;
32
+ invariant(el);
33
+
34
+ return dropTargetForElements({
35
+ element: el,
36
+ getData: () => ({ location }),
37
+ canDrop: ({ source }) => {
38
+ log('canDrop', { source: source.data });
39
+ return true;
40
+ },
41
+ onDragEnter: ({ source }) => {
42
+ log('onDragEnter', { source: source.data });
43
+ const piece = source.data.piece;
44
+ if (!isPiece(piece)) {
45
+ return;
46
+ }
47
+
48
+ if (model?.isValidMove({ from: piece.location, to: location, piece: piece.type })) {
49
+ setState('validMove');
50
+ } else {
51
+ setState('invalidMove');
52
+ }
53
+ },
54
+ onDragLeave: () => setState('idle'),
55
+ onDrop: () => setState('idle'),
56
+ });
57
+ }, [model, location]);
58
+
59
+ return (
60
+ <div
61
+ ref={ref}
62
+ style={bounds}
63
+ className={mx(
64
+ 'absolute flex justify-center items-center border-2 box-border select-none',
65
+ classNames,
66
+ state === 'validMove' ? 'border-neutral-800' : 'border-transparent',
67
+ )}
68
+ >
69
+ {label && <div className={mx('absolute bottom-1 left-1 text-xs text-neutral-500')}>{label}</div>}
70
+ </div>
71
+ );
72
+ });
73
+
74
+ Square.displayName = 'Square';
@@ -0,0 +1,22 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { createContext, useContext } from 'react';
6
+
7
+ import { raise } from '@dxos/debug';
8
+
9
+ import { type PieceRecord, type BoardModel, type Move } from './types';
10
+
11
+ export type BoardContextType = {
12
+ model?: BoardModel;
13
+ dragging?: boolean; // TODO(burdon): Change to PieceRecord.
14
+ promoting?: PieceRecord;
15
+ onPromotion: (move: Move) => void;
16
+ };
17
+
18
+ export const BoardContext = createContext<BoardContextType | undefined>(undefined);
19
+
20
+ export const useBoardContext = () => {
21
+ return useContext(BoardContext) ?? raise(new Error('Missing BoardContext'));
22
+ };
@@ -0,0 +1,12 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './context';
6
+ export * from './types';
7
+ export * from './util';
8
+
9
+ export * from './Board';
10
+ export * from './Container';
11
+ export * from './Square';
12
+ export * from './Piece';