@dxos/react-ui-gameboard 0.8.4-main.9735255 → 0.8.4-main.9be5663bfe

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-gameboard",
3
- "version": "0.8.4-main.9735255",
3
+ "version": "0.8.4-main.9be5663bfe",
4
4
  "description": "Game board.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -30,15 +30,15 @@
30
30
  "dependencies": {
31
31
  "@atlaskit/pragmatic-drag-and-drop": "1.7.7",
32
32
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "1.1.0",
33
- "@effect-atom/atom-react": "^0.4.6",
33
+ "@effect-atom/atom-react": "^0.5.0",
34
34
  "@radix-ui/react-context": "1.1.1",
35
35
  "chess.js": "^1.0.0",
36
36
  "react-resize-detector": "^11.0.1",
37
- "@dxos/debug": "0.8.4-main.9735255",
38
- "@dxos/invariant": "0.8.4-main.9735255",
39
- "@dxos/log": "0.8.4-main.9735255",
40
- "@dxos/node-std": "0.8.4-main.9735255",
41
- "@dxos/util": "0.8.4-main.9735255"
37
+ "@dxos/debug": "0.8.4-main.9be5663bfe",
38
+ "@dxos/invariant": "0.8.4-main.9be5663bfe",
39
+ "@dxos/log": "0.8.4-main.9be5663bfe",
40
+ "@dxos/util": "0.8.4-main.9be5663bfe",
41
+ "@dxos/node-std": "0.8.4-main.9be5663bfe"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@svgr/cli": "^8.1.0",
@@ -48,16 +48,16 @@
48
48
  "lodash.defaultsdeep": "^4.6.1",
49
49
  "react": "~19.2.3",
50
50
  "react-dom": "~19.2.3",
51
- "vite": "7.1.9",
52
- "@dxos/react-ui": "0.8.4-main.9735255",
53
- "@dxos/ui-theme": "0.8.4-main.9735255",
54
- "@dxos/storybook-utils": "0.8.4-main.9735255"
51
+ "vite": "^7.1.11",
52
+ "@dxos/react-ui": "0.8.4-main.9be5663bfe",
53
+ "@dxos/ui-theme": "0.8.4-main.9be5663bfe",
54
+ "@dxos/storybook-utils": "0.8.4-main.9be5663bfe"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "react": "~19.2.3",
58
58
  "react-dom": "~19.2.3",
59
- "@dxos/react-ui": "0.8.4-main.9735255",
60
- "@dxos/ui-theme": "0.8.4-main.9735255"
59
+ "@dxos/ui-theme": "0.8.4-main.9be5663bfe",
60
+ "@dxos/react-ui": "0.8.4-main.9be5663bfe"
61
61
  },
62
62
  "publishConfig": {
63
63
  "access": "public"
@@ -11,7 +11,6 @@ import { withLayout, withTheme } from '@dxos/react-ui/testing';
11
11
  import { withRegistry } from '@dxos/storybook-utils';
12
12
 
13
13
  import { Gameboard, type GameboardRootProps, type Move, type Player } from '../Gameboard';
14
-
15
14
  import { ChessModel } from './chess';
16
15
  import { Chessboard, type ChessboardProps } from './Chessboard';
17
16
 
@@ -66,7 +65,7 @@ const GridStory = () => {
66
65
  }, []);
67
66
 
68
67
  return (
69
- <div className='bs-full aspect-square mx-auto'>
68
+ <div className='h-full aspect-square mx-auto'>
70
69
  <div className='grid grid-cols-3 gap-2'>
71
70
  {models.map((model, i) => (
72
71
  <div key={i} className='aspect-square'>
@@ -84,7 +83,7 @@ const meta = {
84
83
  title: 'ui/react-ui-gameboard/Chessboard',
85
84
  component: Chessboard,
86
85
  render: DefaultStory,
87
- decorators: [withRegistry, withTheme, withLayout({ layout: 'column' })],
86
+ decorators: [withRegistry, withTheme(), withLayout({ layout: 'column' })],
88
87
  } satisfies Meta<typeof Chessboard>;
89
88
 
90
89
  export default meta;
@@ -109,5 +108,6 @@ export const Debug: Story = {
109
108
  };
110
109
 
111
110
  export const Grid = {
111
+ decorators: [withRegistry, withTheme(), withLayout({ layout: 'fullscreen' })],
112
112
  render: GridStory,
113
113
  };
@@ -21,12 +21,16 @@ import {
21
21
  locationToString,
22
22
  useGameboardContext,
23
23
  } from '../Gameboard';
24
-
25
24
  import { type ChessModel, type ChessPiece, ChessPieces, boardStyles, getSquareColor, locationToPos } from './chess';
26
25
 
27
26
  /** Fallback atom for when model is undefined. */
28
27
  const EMPTY_PIECES_ATOM = Atom.make<PieceMap<ChessPiece>>({});
29
28
 
29
+ /**
30
+ * Chessboard layout.
31
+ */
32
+ const CHESSBOARD_NAME = 'Chessboard';
33
+
30
34
  export type ChessboardProps = ThemedClassName<
31
35
  PropsWithChildren<{
32
36
  orientation?: Player;
@@ -37,14 +41,11 @@ export type ChessboardProps = ThemedClassName<
37
41
  }>
38
42
  >;
39
43
 
40
- /**
41
- * Chessboard layout.
42
- */
43
44
  const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
44
45
  ({ classNames, orientation, showLabels, debug, rows = 8, cols = 8 }, forwardedRef) => {
45
46
  const targetRef = useForwardedRef(forwardedRef);
46
47
  const { width, height } = useResizeDetector({ targetRef, refreshRate: 200 });
47
- const { model, promoting, onPromotion } = useGameboardContext<ChessModel>(Chessboard.displayName!);
48
+ const { model, promoting, onPromotion } = useGameboardContext<ChessModel>(CHESSBOARD_NAME);
48
49
  const pieces = useAtomValue(model?.pieces ?? EMPTY_PIECES_ATOM);
49
50
 
50
51
  // Board squares.
@@ -61,7 +62,7 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
61
62
  <div
62
63
  key={locationToString(location)}
63
64
  {...{
64
- ['data-location' as const]: locationToString(location),
65
+ 'data-location': locationToString(location),
65
66
  }}
66
67
  />
67
68
  );
@@ -103,7 +104,7 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
103
104
  }, [grid, pieces, promoting]);
104
105
 
105
106
  return (
106
- <div ref={targetRef} tabIndex={0} className={mx('relative outline-none', classNames)}>
107
+ <div ref={targetRef} tabIndex={0} className={mx('dx-expander relative outline-hidden', classNames)}>
107
108
  {/* DOM Layout. */}
108
109
  <div ref={gridRef} className='grid grid-rows-8 grid-cols-8 aspect-square select-none'>
109
110
  {layout}
@@ -153,7 +154,7 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
153
154
  },
154
155
  );
155
156
 
156
- ChessboardComponent.displayName = 'Chessboard';
157
+ ChessboardComponent.displayName = CHESSBOARD_NAME;
157
158
 
158
159
  export const Chessboard = memo(ChessboardComponent);
159
160
 
@@ -33,19 +33,13 @@ const useGameboardContext = <M extends GameboardModel<any>>(consumerName: string
33
33
 
34
34
  type GameboardRootProps<M extends GameboardModel<any>> = PropsWithChildren<{
35
35
  model?: M;
36
- moveNumber?: number;
37
36
  onDrop?: (move: Move) => boolean;
38
37
  }>;
39
38
 
40
39
  /**
41
40
  * Generic board container.
42
41
  */
43
- const GameboardRoot = <M extends GameboardModel<any>>({
44
- children,
45
- model,
46
- moveNumber,
47
- onDrop,
48
- }: GameboardRootProps<M>) => {
42
+ const GameboardRoot = <M extends GameboardModel<any>>({ children, model, onDrop }: GameboardRootProps<M>) => {
49
43
  const [dragging, setDragging] = useState(false);
50
44
  const [promoting, setPromoting] = useState<PieceRecord | undefined>();
51
45
 
@@ -113,10 +107,10 @@ const GameboardContent = forwardRef<HTMLDivElement, GameboardContentProps>(
113
107
  return (
114
108
  <div
115
109
  role='none'
116
- className={mx(grow && 'grid is-full bs-full size-container place-content-center', classNames)}
110
+ className={mx(grow && 'dx-size-container dx-expander grid place-content-center', classNames)}
117
111
  ref={forwardedRef}
118
112
  >
119
- {contain ? <div className='is-[min(100cqw,100cqh)] bs-[min(100cqw,100cqh)]'>{children}</div> : children}
113
+ {contain ? <div className='w-[min(100cqw,100cqh)] h-[min(100cqw,100cqh)]'>{children}</div> : children}
120
114
  </div>
121
115
  );
122
116
  },
@@ -26,8 +26,10 @@ export type PieceProps = ThemedClassName<{
26
26
  onClick?: () => void;
27
27
  }>;
28
28
 
29
+ const PIECE_NAME = 'Piece';
30
+
29
31
  export const Piece = memo(({ classNames, Component, piece, bounds, label, onClick }: PieceProps) => {
30
- const { model, dragging: isDragging, promoting } = useGameboardContext(Piece.displayName!);
32
+ const { model, dragging: isDragging, promoting } = useGameboardContext(PIECE_NAME);
31
33
  const promotingRef = useDynamicRef(promoting);
32
34
  const [dragging, setDragging] = useState(false);
33
35
  const [preview, setPreview] = useState<HTMLElement>();
@@ -134,4 +136,4 @@ export const Piece = memo(({ classNames, Component, piece, bounds, label, onClic
134
136
  );
135
137
  });
136
138
 
137
- Piece.displayName = 'Piece';
139
+ Piece.displayName = PIECE_NAME;
@@ -22,10 +22,12 @@ export type SquareProps = ThemedClassName<{
22
22
  label?: string;
23
23
  }>;
24
24
 
25
+ const SQUARE_NAME = 'Square';
26
+
25
27
  export const Square = memo(({ location, bounds, label, classNames }: SquareProps) => {
26
28
  const ref = useRef<HTMLDivElement>(null);
27
29
  const [state, setState] = useState<HoveredState>('idle');
28
- const { model } = useGameboardContext(Square.displayName!);
30
+ const { model } = useGameboardContext(SQUARE_NAME);
29
31
 
30
32
  useEffect(() => {
31
33
  const el = ref.current;
@@ -71,4 +73,4 @@ export const Square = memo(({ location, bounds, label, classNames }: SquareProps
71
73
  );
72
74
  });
73
75
 
74
- Square.displayName = 'Square';
76
+ Square.displayName = SQUARE_NAME;