@dxos/react-ui-gameboard 0.8.4-main.e098934 → 0.8.4-main.e8ec1fe
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/lib/browser/index.mjs +13 -39
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +13 -39
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Chessboard/Chessboard.d.ts +2 -2
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -1
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +2 -3
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -1
- package/dist/types/src/components/Gameboard/Gameboard.d.ts +1 -1
- package/dist/types/src/components/Gameboard/Piece.d.ts +1 -1
- package/dist/types/src/components/Gameboard/Piece.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -19
- package/src/components/Chessboard/Chessboard.stories.tsx +3 -5
- package/src/components/Chessboard/Chessboard.tsx +3 -4
- package/src/components/Gameboard/Piece.tsx +2 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-gameboard",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.e8ec1fe",
|
|
4
4
|
"description": "Game board.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -27,34 +27,34 @@
|
|
|
27
27
|
"@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
|
|
28
28
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.3",
|
|
29
29
|
"@preact-signals/safe-react": "^0.9.0",
|
|
30
|
-
"@preact/signals-core": "^1.
|
|
30
|
+
"@preact/signals-core": "^1.12.1",
|
|
31
31
|
"@radix-ui/react-context": "1.1.1",
|
|
32
32
|
"chess.js": "^1.4.0",
|
|
33
33
|
"react-resize-detector": "^11.0.1",
|
|
34
|
-
"@dxos/debug": "0.8.4-main.
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
34
|
+
"@dxos/debug": "0.8.4-main.e8ec1fe",
|
|
35
|
+
"@dxos/invariant": "0.8.4-main.e8ec1fe",
|
|
36
|
+
"@dxos/log": "0.8.4-main.e8ec1fe",
|
|
37
|
+
"@dxos/util": "0.8.4-main.e8ec1fe",
|
|
38
|
+
"@dxos/node-std": "0.8.4-main.e8ec1fe"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@svgr/cli": "^8.1.0",
|
|
42
42
|
"@types/lodash.defaultsdeep": "^4.6.6",
|
|
43
|
-
"@types/react": "~
|
|
44
|
-
"@types/react-dom": "~
|
|
43
|
+
"@types/react": "~19.2.2",
|
|
44
|
+
"@types/react-dom": "~19.2.2",
|
|
45
45
|
"lodash.defaultsdeep": "^4.6.1",
|
|
46
|
-
"react": "~
|
|
47
|
-
"react-dom": "~
|
|
48
|
-
"vite": "7.1.
|
|
49
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
46
|
+
"react": "~19.2.0",
|
|
47
|
+
"react-dom": "~19.2.0",
|
|
48
|
+
"vite": "7.1.9",
|
|
49
|
+
"@dxos/react-ui": "0.8.4-main.e8ec1fe",
|
|
50
|
+
"@dxos/react-ui-theme": "0.8.4-main.e8ec1fe",
|
|
51
|
+
"@dxos/storybook-utils": "0.8.4-main.e8ec1fe"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"react": "
|
|
55
|
-
"react-dom": "
|
|
56
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
57
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
54
|
+
"react": "^19.0.0",
|
|
55
|
+
"react-dom": "^19.0.0",
|
|
56
|
+
"@dxos/react-ui": "0.8.4-main.e8ec1fe",
|
|
57
|
+
"@dxos/react-ui-theme": "0.8.4-main.e8ec1fe"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { Button, Toolbar } from '@dxos/react-ui';
|
|
11
|
-
import { withLayout, withTheme } from '@dxos/
|
|
9
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
10
|
|
|
13
11
|
import { Gameboard, type GameboardRootProps, type Move, type Player } from '../Gameboard';
|
|
14
12
|
|
|
@@ -64,7 +62,7 @@ const GridStory = () => {
|
|
|
64
62
|
}, []);
|
|
65
63
|
|
|
66
64
|
return (
|
|
67
|
-
<div className='
|
|
65
|
+
<div className='bs-full aspect-square mx-auto'>
|
|
68
66
|
<div className='grid grid-cols-3 gap-2'>
|
|
69
67
|
{models.map((model, i) => (
|
|
70
68
|
<div key={i} className='aspect-square'>
|
|
@@ -82,7 +80,7 @@ const meta = {
|
|
|
82
80
|
title: 'ui/react-ui-gameboard/Chessboard',
|
|
83
81
|
component: Chessboard,
|
|
84
82
|
render: DefaultStory,
|
|
85
|
-
decorators: [withTheme, withLayout({
|
|
83
|
+
decorators: [withTheme, withLayout({ container: 'column' })],
|
|
86
84
|
} satisfies Meta<typeof Chessboard>;
|
|
87
85
|
|
|
88
86
|
export default meta;
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
import React, { type PropsWithChildren, forwardRef, memo, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
6
|
import { useResizeDetector } from 'react-resize-detector';
|
|
7
7
|
|
|
8
|
-
import { type ThemedClassName, useForwardedRef
|
|
8
|
+
import { type ThemedClassName, useForwardedRef } from '@dxos/react-ui';
|
|
9
9
|
import { mx } from '@dxos/react-ui-theme';
|
|
10
|
-
import {
|
|
10
|
+
import { isNonNullable } from '@dxos/util';
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
type DOMRectBounds,
|
|
@@ -37,7 +37,6 @@ export type ChessboardProps = ThemedClassName<
|
|
|
37
37
|
*/
|
|
38
38
|
const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
|
|
39
39
|
({ classNames, orientation, showLabels, debug, rows = 8, cols = 8 }, forwardedRef) => {
|
|
40
|
-
useTrackProps({ orientation, showLabels, debug }, Chessboard.displayName, false);
|
|
41
40
|
const targetRef = useForwardedRef(forwardedRef);
|
|
42
41
|
const { width, height } = useResizeDetector({ targetRef, refreshRate: 200 });
|
|
43
42
|
const { model, promoting, onPromotion } = useGameboardContext<ChessModel>(Chessboard.displayName!);
|
|
@@ -94,7 +93,7 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
|
|
|
94
93
|
const bounds = grid[locationToString(piece.location)];
|
|
95
94
|
return { piece, bounds };
|
|
96
95
|
})
|
|
97
|
-
.filter(
|
|
96
|
+
.filter(isNonNullable);
|
|
98
97
|
}, [grid, model?.pieces.value, promoting]);
|
|
99
98
|
|
|
100
99
|
return (
|
|
@@ -10,7 +10,7 @@ import { createPortal } from 'react-dom';
|
|
|
10
10
|
|
|
11
11
|
import { invariant } from '@dxos/invariant';
|
|
12
12
|
import { log } from '@dxos/log';
|
|
13
|
-
import { type ThemedClassName, useDynamicRef
|
|
13
|
+
import { type ThemedClassName, useDynamicRef } from '@dxos/react-ui';
|
|
14
14
|
import { mx } from '@dxos/react-ui-theme';
|
|
15
15
|
|
|
16
16
|
import { useGameboardContext } from './Gameboard';
|
|
@@ -26,8 +26,7 @@ export type PieceProps = ThemedClassName<{
|
|
|
26
26
|
onClick?: () => void;
|
|
27
27
|
}>;
|
|
28
28
|
|
|
29
|
-
export const Piece = memo(({ classNames, Component, piece,
|
|
30
|
-
useTrackProps({ classNames, Component, piece, orientation, bounds, label }, Piece.displayName, false);
|
|
29
|
+
export const Piece = memo(({ classNames, Component, piece, bounds, label, onClick }: PieceProps) => {
|
|
31
30
|
const { model, dragging: isDragging, promoting } = useGameboardContext(Piece.displayName!);
|
|
32
31
|
const promotingRef = useDynamicRef(promoting);
|
|
33
32
|
const [dragging, setDragging] = useState(false);
|