@dxos/react-ui-gameboard 0.8.4-main.bc674ce → 0.8.4-main.bd9b33e6c8

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.bc674ce",
3
+ "version": "0.8.4-main.bd9b33e6c8",
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.bc674ce",
38
- "@dxos/invariant": "0.8.4-main.bc674ce",
39
- "@dxos/node-std": "0.8.4-main.bc674ce",
40
- "@dxos/log": "0.8.4-main.bc674ce",
41
- "@dxos/util": "0.8.4-main.bc674ce"
37
+ "@dxos/debug": "0.8.4-main.bd9b33e6c8",
38
+ "@dxos/log": "0.8.4-main.bd9b33e6c8",
39
+ "@dxos/invariant": "0.8.4-main.bd9b33e6c8",
40
+ "@dxos/node-std": "0.8.4-main.bd9b33e6c8",
41
+ "@dxos/util": "0.8.4-main.bd9b33e6c8"
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.bc674ce",
53
- "@dxos/storybook-utils": "0.8.4-main.bc674ce",
54
- "@dxos/ui-theme": "0.8.4-main.bc674ce"
51
+ "vite": "^7.1.11",
52
+ "@dxos/react-ui": "0.8.4-main.bd9b33e6c8",
53
+ "@dxos/ui-theme": "0.8.4-main.bd9b33e6c8",
54
+ "@dxos/storybook-utils": "0.8.4-main.bd9b33e6c8"
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.bc674ce",
60
- "@dxos/ui-theme": "0.8.4-main.bc674ce"
59
+ "@dxos/react-ui": "0.8.4-main.bd9b33e6c8",
60
+ "@dxos/ui-theme": "0.8.4-main.bd9b33e6c8"
61
61
  },
62
62
  "publishConfig": {
63
63
  "access": "public"
@@ -66,7 +66,7 @@ const GridStory = () => {
66
66
  }, []);
67
67
 
68
68
  return (
69
- <div className='bs-full aspect-square mx-auto'>
69
+ <div className='h-full aspect-square mx-auto'>
70
70
  <div className='grid grid-cols-3 gap-2'>
71
71
  {models.map((model, i) => (
72
72
  <div key={i} className='aspect-square'>
@@ -84,7 +84,7 @@ const meta = {
84
84
  title: 'ui/react-ui-gameboard/Chessboard',
85
85
  component: Chessboard,
86
86
  render: DefaultStory,
87
- decorators: [withRegistry, withTheme, withLayout({ layout: 'column' })],
87
+ decorators: [withRegistry, withTheme(), withLayout({ layout: 'column' })],
88
88
  } satisfies Meta<typeof Chessboard>;
89
89
 
90
90
  export default meta;
@@ -109,5 +109,6 @@ export const Debug: Story = {
109
109
  };
110
110
 
111
111
  export const Grid = {
112
+ decorators: [withRegistry, withTheme(), withLayout({ layout: 'fullscreen' })],
112
113
  render: GridStory,
113
114
  };
@@ -27,6 +27,11 @@ import { type ChessModel, type ChessPiece, ChessPieces, boardStyles, getSquareCo
27
27
  /** Fallback atom for when model is undefined. */
28
28
  const EMPTY_PIECES_ATOM = Atom.make<PieceMap<ChessPiece>>({});
29
29
 
30
+ /**
31
+ * Chessboard layout.
32
+ */
33
+ const CHESSBOARD_NAME = 'Chessboard';
34
+
30
35
  export type ChessboardProps = ThemedClassName<
31
36
  PropsWithChildren<{
32
37
  orientation?: Player;
@@ -37,14 +42,11 @@ export type ChessboardProps = ThemedClassName<
37
42
  }>
38
43
  >;
39
44
 
40
- /**
41
- * Chessboard layout.
42
- */
43
45
  const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
44
46
  ({ classNames, orientation, showLabels, debug, rows = 8, cols = 8 }, forwardedRef) => {
45
47
  const targetRef = useForwardedRef(forwardedRef);
46
48
  const { width, height } = useResizeDetector({ targetRef, refreshRate: 200 });
47
- const { model, promoting, onPromotion } = useGameboardContext<ChessModel>(Chessboard.displayName!);
49
+ const { model, promoting, onPromotion } = useGameboardContext<ChessModel>(CHESSBOARD_NAME);
48
50
  const pieces = useAtomValue(model?.pieces ?? EMPTY_PIECES_ATOM);
49
51
 
50
52
  // Board squares.
@@ -61,7 +63,7 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
61
63
  <div
62
64
  key={locationToString(location)}
63
65
  {...{
64
- ['data-location' as const]: locationToString(location),
66
+ 'data-location': locationToString(location),
65
67
  }}
66
68
  />
67
69
  );
@@ -103,7 +105,7 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
103
105
  }, [grid, pieces, promoting]);
104
106
 
105
107
  return (
106
- <div ref={targetRef} tabIndex={0} className={mx('relative outline-none', classNames)}>
108
+ <div ref={targetRef} tabIndex={0} className={mx('dx-expander relative outline-hidden', classNames)}>
107
109
  {/* DOM Layout. */}
108
110
  <div ref={gridRef} className='grid grid-rows-8 grid-cols-8 aspect-square select-none'>
109
111
  {layout}
@@ -153,7 +155,7 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
153
155
  },
154
156
  );
155
157
 
156
- ChessboardComponent.displayName = 'Chessboard';
158
+ ChessboardComponent.displayName = CHESSBOARD_NAME;
157
159
 
158
160
  export const Chessboard = memo(ChessboardComponent);
159
161
 
@@ -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;