@dxos/react-ui-canvas 0.10.0 → 0.11.0

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 (34) hide show
  1. package/dist/lib/index.mjs +1312 -0
  2. package/dist/lib/index.mjs.map +1 -0
  3. package/dist/types/src/components/CellGrid/input/pointer.d.ts +1 -1
  4. package/dist/types/src/components/CellGrid/input/pointer.d.ts.map +1 -1
  5. package/dist/types/src/components/CellGrid/input/wheel.d.ts +1 -1
  6. package/dist/types/src/components/CellGrid/input/wheel.d.ts.map +1 -1
  7. package/dist/types/src/components/CellGrid/state/atoms.d.ts +1 -1
  8. package/dist/types/src/components/CellGrid/state/atoms.d.ts.map +1 -1
  9. package/dist/types/src/hooks/useCanvasContext.d.ts.map +1 -1
  10. package/dist/types/src/util/index.d.ts +1 -0
  11. package/dist/types/src/util/index.d.ts.map +1 -1
  12. package/dist/types/src/util/svg-path.d.ts +4 -0
  13. package/dist/types/src/util/svg-path.d.ts.map +1 -0
  14. package/dist/types/src/util/svg.d.ts +0 -1
  15. package/dist/types/src/util/svg.d.ts.map +1 -1
  16. package/dist/types/src/util/svg.stories.d.ts.map +1 -1
  17. package/dist/types/tsconfig.tsbuildinfo +1 -1
  18. package/package.json +14 -14
  19. package/src/components/CellGrid/CellGrid.tsx +2 -2
  20. package/src/components/CellGrid/headers/Ruler.tsx +1 -1
  21. package/src/components/CellGrid/input/pointer.ts +1 -1
  22. package/src/components/CellGrid/input/wheel.ts +1 -1
  23. package/src/components/CellGrid/state/atoms.ts +1 -1
  24. package/src/hooks/{useCanvasContext.tsx → useCanvasContext.ts} +3 -0
  25. package/src/util/index.ts +1 -0
  26. package/src/util/svg-path.ts +13 -0
  27. package/src/util/svg.stories.tsx +2 -1
  28. package/src/util/svg.tsx +1 -4
  29. package/dist/lib/browser/index.mjs +0 -1451
  30. package/dist/lib/browser/index.mjs.map +0 -7
  31. package/dist/lib/browser/meta.json +0 -1
  32. package/dist/lib/node-esm/index.mjs +0 -1453
  33. package/dist/lib/node-esm/index.mjs.map +0 -7
  34. package/dist/lib/node-esm/meta.json +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-canvas",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "A canvas component.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -15,8 +15,7 @@
15
15
  ".": {
16
16
  "source": "./src/index.ts",
17
17
  "types": "./dist/types/src/index.d.ts",
18
- "browser": "./dist/lib/browser/index.mjs",
19
- "node": "./dist/lib/node-esm/index.mjs"
18
+ "import": "./dist/lib/index.mjs"
20
19
  }
21
20
  },
22
21
  "types": "dist/types/src/index.d.ts",
@@ -25,16 +24,17 @@
25
24
  "src"
26
25
  ],
27
26
  "dependencies": {
27
+ "@effect-atom/atom": "^0.5.3",
28
28
  "@effect-atom/atom-react": "^0.5.0",
29
29
  "@radix-ui/react-context": "1.1.1",
30
30
  "bind-event-listener": "^3.0.0",
31
31
  "d3": "^7.9.0",
32
32
  "react-resize-detector": "^11.0.1",
33
33
  "transformation-matrix": "^2.16.1",
34
- "@dxos/invariant": "0.10.0",
35
- "@dxos/util": "0.10.0",
36
- "@dxos/log": "0.10.0",
37
- "@dxos/debug": "0.10.0"
34
+ "@dxos/debug": "0.11.0",
35
+ "@dxos/invariant": "0.11.0",
36
+ "@dxos/log": "0.11.0",
37
+ "@dxos/util": "0.11.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/d3": "^7.4.3",
@@ -43,18 +43,18 @@
43
43
  "effect": "3.21.4",
44
44
  "react": "~19.2.7",
45
45
  "react-dom": "~19.2.7",
46
- "vite": "^8.0.16",
47
- "@dxos/react-ui": "0.10.0",
48
- "@dxos/random": "0.10.0",
49
- "@dxos/storybook-utils": "0.10.0",
50
- "@dxos/ui-theme": "0.10.0"
46
+ "vite": "^8.1.4",
47
+ "@dxos/random": "0.11.0",
48
+ "@dxos/react-ui": "0.11.0",
49
+ "@dxos/storybook-utils": "0.11.0",
50
+ "@dxos/ui-theme": "0.11.0"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "effect": "3.21.4",
54
54
  "react": "~19.2.7",
55
55
  "react-dom": "~19.2.7",
56
- "@dxos/react-ui": "0.10.0",
57
- "@dxos/ui-theme": "0.10.0"
56
+ "@dxos/react-ui": "^0.11.0",
57
+ "@dxos/ui-theme": "^0.11.0"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public"
@@ -240,7 +240,7 @@ export const CellGrid = <T,>({
240
240
  }, [registry, atoms, headers]);
241
241
 
242
242
  return (
243
- <div ref={containerRef} className={mx('relative w-full h-full overflow-hidden bg-baseSurface', classNames)}>
243
+ <div ref={containerRef} className={mx('relative w-full h-full overflow-hidden dx-base-surface', classNames)}>
244
244
  {/*
245
245
  Canvases are nudged up + left 1 CSS pixel so the gridlines (drawn at the TOP
246
246
  and LEFT edges of each cell) sit on top of the frozen header dividers — the
@@ -259,7 +259,7 @@ export const CellGrid = <T,>({
259
259
  {headers.left > 0 && <TrackHeader viewport={viewportState} headers={headers} rows={rows} height={height} />}
260
260
  {headers.top > 0 && headers.left > 0 && (
261
261
  <div
262
- className='absolute top-0 left-0 border-b border-r border-neutral-200 dark:border-neutral-700 bg-baseSurface'
262
+ className='absolute top-0 left-0 border-b border-r border-neutral-200 dark:border-neutral-700 bg-base-surface'
263
263
  style={{ width: headers.left, height: headers.top }}
264
264
  />
265
265
  )}
@@ -47,7 +47,7 @@ export const Ruler = ({ viewport, headers, width, majorEvery = 4, classNames }:
47
47
  return (
48
48
  <div
49
49
  className={mx(
50
- 'absolute top-0 left-0 right-0 border-b border-neutral-200 dark:border-neutral-700 bg-baseSurface select-none overflow-hidden',
50
+ 'absolute top-0 left-0 right-0 border-b border-neutral-200 dark:border-neutral-700 bg-base-surface select-none overflow-hidden',
51
51
  classNames,
52
52
  )}
53
53
  style={{ height: headers.top }}
@@ -2,7 +2,7 @@
2
2
  // Copyright 2026 DXOS.org
3
3
  //
4
4
 
5
- import type { Registry } from '@effect-atom/atom-react';
5
+ import type { Registry } from '@effect-atom/atom';
6
6
 
7
7
  import type { CellGridAtoms } from '../state/atoms';
8
8
  import type { Cell, CellCoord, Headers, SelectionRange, Tool } from '../state/types';
@@ -2,7 +2,7 @@
2
2
  // Copyright 2026 DXOS.org
3
3
  //
4
4
 
5
- import type { Registry } from '@effect-atom/atom-react';
5
+ import type { Registry } from '@effect-atom/atom';
6
6
 
7
7
  import type { CellGridAtoms } from '../state/atoms';
8
8
  import type { Headers } from '../state/types';
@@ -2,7 +2,7 @@
2
2
  // Copyright 2026 DXOS.org
3
3
  //
4
4
 
5
- import { Atom } from '@effect-atom/atom-react';
5
+ import { Atom } from '@effect-atom/atom';
6
6
 
7
7
  import type { Cell, Selection, Tool, Viewport } from './types';
8
8
 
@@ -8,6 +8,9 @@ import { raise } from '@dxos/debug';
8
8
 
9
9
  import { type Projection, type ProjectionState } from './projection';
10
10
 
11
+ // Kept out of the canvas components: react-refresh only fast-refreshes a module whose exports are all
12
+ // components, so a context and hook exported beside one force a full page reload on every edit.
13
+
11
14
  export type CanvasContext = ProjectionState & {
12
15
  root: HTMLDivElement;
13
16
  ready: boolean;
package/src/util/index.ts CHANGED
@@ -3,4 +3,5 @@
3
3
  //
4
4
 
5
5
  export * from './svg';
6
+ export * from './svg-path';
6
7
  export * from './util';
@@ -0,0 +1,13 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { type Point } from '../types';
6
+
7
+ // Kept out of `svg.tsx`: react-refresh only fast-refreshes a module whose exports are all components,
8
+ // so a helper exported beside them forces a full page reload on every edit.
9
+
10
+ /** https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths */
11
+ export const createPath = (points: Point[], join = false) => {
12
+ return ['M', points.map(({ x, y }) => `${x},${y}`).join(' L '), join ? 'Z' : ''].join(' ');
13
+ };
@@ -7,7 +7,8 @@ import React from 'react';
7
7
 
8
8
  import { withTheme } from '@dxos/react-ui/testing';
9
9
 
10
- import { Arrow, createPath } from './svg';
10
+ import { Arrow } from './svg';
11
+ import { createPath } from './svg-path';
11
12
  import { testId } from './util';
12
13
 
13
14
  const DefaultStory = () => (
package/src/util/svg.tsx CHANGED
@@ -8,15 +8,12 @@ import { type ThemedClassName } from '@dxos/react-ui';
8
8
  import { mx } from '@dxos/ui-theme';
9
9
 
10
10
  import { type Dimension, type Point } from '../types';
11
+ import { createPath } from './svg-path';
11
12
 
12
13
  // Refs
13
14
  // - https://airbnb.io/visx/gallery
14
15
  // - https://github.com/tldraw/tldraw/blob/main/packages/editor/src/lib/primitives/Vec.ts
15
16
 
16
- export const createPath = (points: Point[], join = false) => {
17
- return ['M', points.map(({ x, y }) => `${x},${y}`).join(' L '), join ? 'Z' : ''].join(' ');
18
- };
19
-
20
17
  /**
21
18
  * https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths
22
19
  * NOTE: Leave space around shape for line width.