@dxos/react-ui-canvas 0.8.4-main.84f28bd → 0.8.4-main.ae835ea
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 +12 -12
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +12 -12
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Canvas/Canvas.d.ts.map +1 -1
- package/dist/types/src/components/Canvas/Canvas.stories.d.ts +12 -4
- package/dist/types/src/components/Canvas/Canvas.stories.d.ts.map +1 -1
- package/dist/types/src/components/Grid/Grid.d.ts.map +1 -1
- package/dist/types/src/components/Grid/Grid.stories.d.ts +19 -4
- package/dist/types/src/components/Grid/Grid.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/projection.d.ts +1 -1
- package/dist/types/src/hooks/projection.d.ts.map +1 -1
- package/dist/types/src/hooks/useWheel.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +1 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util/svg.stories.d.ts +12 -4
- package/dist/types/src/util/svg.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -20
- package/src/components/Canvas/Canvas.stories.tsx +10 -8
- package/src/components/Canvas/Canvas.tsx +8 -12
- package/src/components/FPS.tsx +1 -1
- package/src/components/Grid/Grid.stories.tsx +11 -9
- package/src/components/Grid/Grid.tsx +2 -2
- package/src/hooks/projection.tsx +2 -2
- package/src/hooks/useWheel.tsx +2 -1
- package/src/types.ts +1 -1
- package/src/util/svg.stories.tsx +7 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-canvas",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.ae835ea",
|
|
4
4
|
"description": "A canvas component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
+
"source": "./src/index.ts",
|
|
12
13
|
"types": "./dist/types/src/index.d.ts",
|
|
13
14
|
"browser": "./dist/lib/browser/index.mjs",
|
|
14
15
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
@@ -24,36 +25,36 @@
|
|
|
24
25
|
],
|
|
25
26
|
"dependencies": {
|
|
26
27
|
"@preact-signals/safe-react": "^0.9.0",
|
|
27
|
-
"@preact/signals-core": "^1.
|
|
28
|
+
"@preact/signals-core": "^1.12.1",
|
|
28
29
|
"@radix-ui/react-context": "1.1.1",
|
|
29
30
|
"bind-event-listener": "^3.0.0",
|
|
30
31
|
"d3": "^7.9.0",
|
|
31
32
|
"react-resize-detector": "^11.0.1",
|
|
32
33
|
"transformation-matrix": "^2.16.1",
|
|
33
|
-
"@dxos/debug": "0.8.4-main.
|
|
34
|
-
"@dxos/invariant": "0.8.4-main.
|
|
35
|
-
"@dxos/log": "0.8.4-main.
|
|
36
|
-
"@dxos/util": "0.8.4-main.
|
|
34
|
+
"@dxos/debug": "0.8.4-main.ae835ea",
|
|
35
|
+
"@dxos/invariant": "0.8.4-main.ae835ea",
|
|
36
|
+
"@dxos/log": "0.8.4-main.ae835ea",
|
|
37
|
+
"@dxos/util": "0.8.4-main.ae835ea"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@types/d3": "^7.4.3",
|
|
40
|
-
"@types/react": "~
|
|
41
|
-
"@types/react-dom": "~
|
|
42
|
-
"effect": "3.
|
|
43
|
-
"react": "~
|
|
44
|
-
"react-dom": "~
|
|
45
|
-
"vite": "
|
|
46
|
-
"@dxos/random": "0.8.4-main.
|
|
47
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
41
|
+
"@types/react": "~19.2.2",
|
|
42
|
+
"@types/react-dom": "~19.2.2",
|
|
43
|
+
"effect": "3.18.3",
|
|
44
|
+
"react": "~19.2.0",
|
|
45
|
+
"react-dom": "~19.2.0",
|
|
46
|
+
"vite": "7.1.9",
|
|
47
|
+
"@dxos/random": "0.8.4-main.ae835ea",
|
|
48
|
+
"@dxos/react-ui": "0.8.4-main.ae835ea",
|
|
49
|
+
"@dxos/react-ui-theme": "0.8.4-main.ae835ea",
|
|
50
|
+
"@dxos/storybook-utils": "0.8.4-main.ae835ea"
|
|
50
51
|
},
|
|
51
52
|
"peerDependencies": {
|
|
52
53
|
"effect": "3.13.3",
|
|
53
|
-
"react": "
|
|
54
|
-
"react-dom": "
|
|
55
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
56
|
-
"@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.ae835ea",
|
|
57
|
+
"@dxos/react-ui-theme": "0.8.4-main.ae835ea"
|
|
57
58
|
},
|
|
58
59
|
"publishConfig": {
|
|
59
60
|
"access": "public"
|
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
|
-
import {
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
11
9
|
|
|
12
|
-
import { Canvas } from './Canvas';
|
|
13
10
|
import { useCanvasContext, useWheel } from '../../hooks';
|
|
14
11
|
import { type Point } from '../../types';
|
|
15
12
|
import { testId } from '../../util';
|
|
16
13
|
import { Grid, type GridProps } from '../Grid';
|
|
17
14
|
|
|
15
|
+
import { Canvas } from './Canvas';
|
|
16
|
+
|
|
18
17
|
const size = 128;
|
|
19
18
|
|
|
20
19
|
const points: Point[] = [0, (2 * Math.PI) / 3, (2 * Math.PI * 2) / 3].map((a, i) => ({
|
|
@@ -88,16 +87,19 @@ const Item = (p: Point) => {
|
|
|
88
87
|
);
|
|
89
88
|
};
|
|
90
89
|
|
|
91
|
-
const meta
|
|
90
|
+
const meta = {
|
|
92
91
|
title: 'ui/react-ui-canvas/Canvas',
|
|
93
92
|
component: Grid,
|
|
94
93
|
render: DefaultStory,
|
|
95
|
-
decorators: [withTheme
|
|
96
|
-
|
|
94
|
+
decorators: [withTheme],
|
|
95
|
+
parameters: {
|
|
96
|
+
layout: 'fullscreen',
|
|
97
|
+
},
|
|
98
|
+
} satisfies Meta<typeof Grid>;
|
|
97
99
|
|
|
98
100
|
export default meta;
|
|
99
101
|
|
|
100
|
-
type Story = StoryObj<
|
|
102
|
+
type Story = StoryObj<typeof meta>;
|
|
101
103
|
|
|
102
104
|
export const Default: Story = {
|
|
103
105
|
args: { size: 16 },
|
|
@@ -17,7 +17,7 @@ import { useResizeDetector } from 'react-resize-detector';
|
|
|
17
17
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
18
18
|
import { mx } from '@dxos/react-ui-theme';
|
|
19
19
|
|
|
20
|
-
import {
|
|
20
|
+
import { CanvasContext, ProjectionMapper, type ProjectionState, defaultOrigin } from '../../hooks';
|
|
21
21
|
|
|
22
22
|
export interface CanvasController {
|
|
23
23
|
setProjection(projection: ProjectionState): Promise<void>;
|
|
@@ -64,17 +64,13 @@ export const Canvas = forwardRef<CanvasController, CanvasProps>(
|
|
|
64
64
|
}, [scale, offset]);
|
|
65
65
|
|
|
66
66
|
// Controller.
|
|
67
|
-
useImperativeHandle(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
[ref],
|
|
77
|
-
);
|
|
67
|
+
useImperativeHandle(forwardedRef, () => {
|
|
68
|
+
return {
|
|
69
|
+
setProjection: async (projection: ProjectionState) => {
|
|
70
|
+
setProjection(projection);
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}, [ref]);
|
|
78
74
|
|
|
79
75
|
return (
|
|
80
76
|
<CanvasContext.Provider
|
package/src/components/FPS.tsx
CHANGED
|
@@ -53,7 +53,7 @@ export const FPS = ({ classNames, width = 60, height = 30, bar = 'bg-cyan-500' }
|
|
|
53
53
|
},
|
|
54
54
|
);
|
|
55
55
|
|
|
56
|
-
const requestRef = useRef<number>();
|
|
56
|
+
const requestRef = useRef<number | null>(null);
|
|
57
57
|
const tick = () => {
|
|
58
58
|
dispatch();
|
|
59
59
|
requestRef.current = requestAnimationFrame(tick);
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useRef, useState } from 'react';
|
|
9
7
|
|
|
10
|
-
import {
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
11
9
|
|
|
12
|
-
import { GridComponent, type GridProps } from './Grid';
|
|
13
10
|
import { type ProjectionState } from '../../hooks';
|
|
14
11
|
|
|
12
|
+
import { GridComponent, type GridProps } from './Grid';
|
|
13
|
+
|
|
15
14
|
const DefaultStory = (props: GridProps) => {
|
|
16
15
|
const ref = useRef<HTMLDivElement>(null);
|
|
17
16
|
const [{ scale, offset }] = useState<ProjectionState>({ scale: 1, offset: { x: 0, y: 0 } });
|
|
@@ -23,16 +22,19 @@ const DefaultStory = (props: GridProps) => {
|
|
|
23
22
|
);
|
|
24
23
|
};
|
|
25
24
|
|
|
26
|
-
const meta
|
|
25
|
+
const meta = {
|
|
27
26
|
title: 'ui/react-ui-canvas/Grid',
|
|
28
27
|
component: GridComponent,
|
|
29
28
|
render: DefaultStory,
|
|
30
|
-
decorators: [withTheme
|
|
31
|
-
|
|
29
|
+
decorators: [withTheme],
|
|
30
|
+
parameters: {
|
|
31
|
+
layout: 'fullscreen',
|
|
32
|
+
},
|
|
33
|
+
} satisfies Meta<typeof GridComponent>;
|
|
32
34
|
|
|
33
35
|
export default meta;
|
|
34
36
|
|
|
35
|
-
type Story = StoryObj<
|
|
37
|
+
type Story = StoryObj<typeof meta>;
|
|
36
38
|
|
|
37
39
|
export const Default: Story = {
|
|
38
40
|
args: {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { forwardRef,
|
|
5
|
+
import React, { forwardRef, useId, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { type ThemedClassName, useForwardedRef } from '@dxos/react-ui';
|
|
8
8
|
import { mx } from '@dxos/react-ui-theme';
|
|
9
9
|
|
|
10
10
|
import { useCanvasContext } from '../../hooks';
|
package/src/hooks/projection.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { interpolate, interpolateObject, transition
|
|
5
|
+
import { easeSinOut, interpolate, interpolateObject, transition } from 'd3';
|
|
6
6
|
import {
|
|
7
7
|
type Matrix,
|
|
8
8
|
applyToPoints,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
translate as translateMatrix,
|
|
14
14
|
} from 'transformation-matrix';
|
|
15
15
|
|
|
16
|
-
import { type
|
|
16
|
+
import { type Dimension, type Point } from '../types';
|
|
17
17
|
|
|
18
18
|
export const defaultOrigin: Point = { x: 0, y: 0 };
|
|
19
19
|
|
package/src/hooks/useWheel.tsx
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
import { bindAll } from 'bind-event-listener';
|
|
6
6
|
import { useEffect } from 'react';
|
|
7
7
|
|
|
8
|
+
import { getRelativePoint } from '../util';
|
|
9
|
+
|
|
8
10
|
import { getZoomTransform } from './projection';
|
|
9
11
|
import { useCanvasContext } from './useCanvasContext';
|
|
10
|
-
import { getRelativePoint } from '../util';
|
|
11
12
|
|
|
12
13
|
export type WheelOptions = {
|
|
13
14
|
zoom?: boolean;
|
package/src/types.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
7
|
export const Point = Schema.Struct({ x: Schema.Number, y: Schema.Number });
|
|
8
8
|
export const Dimension = Schema.Struct({ width: Schema.Number, height: Schema.Number });
|
package/src/util/svg.stories.tsx
CHANGED
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import type { Meta } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
|
-
import { withTheme } from '@dxos/
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
11
9
|
|
|
12
10
|
import { Arrow, createPath } from './svg';
|
|
13
11
|
import { testId } from './util';
|
|
@@ -31,15 +29,17 @@ const DefaultStory = () => (
|
|
|
31
29
|
</svg>
|
|
32
30
|
);
|
|
33
31
|
|
|
34
|
-
const meta
|
|
32
|
+
const meta = {
|
|
35
33
|
title: 'ui/react-ui-canvas/svg',
|
|
36
34
|
render: DefaultStory,
|
|
37
35
|
decorators: [withTheme],
|
|
38
36
|
parameters: {
|
|
39
37
|
layout: 'centered',
|
|
40
38
|
},
|
|
41
|
-
};
|
|
39
|
+
} satisfies Meta;
|
|
42
40
|
|
|
43
41
|
export default meta;
|
|
44
42
|
|
|
45
|
-
|
|
43
|
+
type Story = StoryObj<typeof meta>;
|
|
44
|
+
|
|
45
|
+
export const Default: Story = {};
|