@dxos/react-ui-canvas 0.8.4-main.5acf9ea → 0.8.4-main.5ea62a8
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 +28 -15
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +28 -15
- 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 +9 -3
- 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 +16 -3
- 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/util/svg.stories.d.ts +12 -3
- package/dist/types/src/util/svg.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -15
- package/src/components/Canvas/Canvas.stories.tsx +5 -4
- package/src/components/Canvas/Canvas.tsx +1 -1
- package/src/components/Grid/Grid.stories.tsx +6 -5
- package/src/components/Grid/Grid.tsx +2 -2
- package/src/hooks/projection.tsx +2 -2
- package/src/hooks/useWheel.tsx +2 -1
- package/src/util/svg.stories.tsx +6 -4
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.5ea62a8",
|
|
4
4
|
"description": "A canvas component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -9,10 +9,10 @@
|
|
|
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
|
-
"node": "./dist/lib/node-esm/index.mjs"
|
|
15
|
-
"source": "./src/index.ts"
|
|
15
|
+
"node": "./dist/lib/node-esm/index.mjs"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -31,30 +31,30 @@
|
|
|
31
31
|
"d3": "^7.9.0",
|
|
32
32
|
"react-resize-detector": "^11.0.1",
|
|
33
33
|
"transformation-matrix": "^2.16.1",
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/util": "0.8.4-main.
|
|
34
|
+
"@dxos/invariant": "0.8.4-main.5ea62a8",
|
|
35
|
+
"@dxos/log": "0.8.4-main.5ea62a8",
|
|
36
|
+
"@dxos/debug": "0.8.4-main.5ea62a8",
|
|
37
|
+
"@dxos/util": "0.8.4-main.5ea62a8"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/d3": "^7.4.3",
|
|
41
41
|
"@types/react": "~18.2.0",
|
|
42
42
|
"@types/react-dom": "~18.2.0",
|
|
43
|
-
"effect": "3.17.
|
|
43
|
+
"effect": "3.17.7",
|
|
44
44
|
"react": "~18.2.0",
|
|
45
45
|
"react-dom": "~18.2.0",
|
|
46
|
-
"vite": "
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
50
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
46
|
+
"vite": "7.1.1",
|
|
47
|
+
"@dxos/random": "0.8.4-main.5ea62a8",
|
|
48
|
+
"@dxos/react-ui": "0.8.4-main.5ea62a8",
|
|
49
|
+
"@dxos/react-ui-theme": "0.8.4-main.5ea62a8",
|
|
50
|
+
"@dxos/storybook-utils": "0.8.4-main.5ea62a8"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"effect": "3.13.3",
|
|
54
54
|
"react": "~18.2.0",
|
|
55
55
|
"react-dom": "~18.2.0",
|
|
56
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
57
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
56
|
+
"@dxos/react-ui": "0.8.4-main.5ea62a8",
|
|
57
|
+
"@dxos/react-ui-theme": "0.8.4-main.5ea62a8"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
@@ -9,12 +9,13 @@ import React from 'react';
|
|
|
9
9
|
|
|
10
10
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
11
11
|
|
|
12
|
-
import { Canvas } from './Canvas';
|
|
13
12
|
import { useCanvasContext, useWheel } from '../../hooks';
|
|
14
13
|
import { type Point } from '../../types';
|
|
15
14
|
import { testId } from '../../util';
|
|
16
15
|
import { Grid, type GridProps } from '../Grid';
|
|
17
16
|
|
|
17
|
+
import { Canvas } from './Canvas';
|
|
18
|
+
|
|
18
19
|
const size = 128;
|
|
19
20
|
|
|
20
21
|
const points: Point[] = [0, (2 * Math.PI) / 3, (2 * Math.PI * 2) / 3].map((a, i) => ({
|
|
@@ -88,16 +89,16 @@ const Item = (p: Point) => {
|
|
|
88
89
|
);
|
|
89
90
|
};
|
|
90
91
|
|
|
91
|
-
const meta
|
|
92
|
+
const meta = {
|
|
92
93
|
title: 'ui/react-ui-canvas/Canvas',
|
|
93
94
|
component: Grid,
|
|
94
95
|
render: DefaultStory,
|
|
95
96
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
|
96
|
-
}
|
|
97
|
+
} satisfies Meta<typeof Grid>;
|
|
97
98
|
|
|
98
99
|
export default meta;
|
|
99
100
|
|
|
100
|
-
type Story = StoryObj<
|
|
101
|
+
type Story = StoryObj<typeof meta>;
|
|
101
102
|
|
|
102
103
|
export const Default: Story = {
|
|
103
104
|
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>;
|
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import type
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import React, { useRef, useState } from 'react';
|
|
9
9
|
|
|
10
10
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
11
11
|
|
|
12
|
-
import { GridComponent, type GridProps } from './Grid';
|
|
13
12
|
import { type ProjectionState } from '../../hooks';
|
|
14
13
|
|
|
14
|
+
import { GridComponent, type GridProps } from './Grid';
|
|
15
|
+
|
|
15
16
|
const DefaultStory = (props: GridProps) => {
|
|
16
17
|
const ref = useRef<HTMLDivElement>(null);
|
|
17
18
|
const [{ scale, offset }] = useState<ProjectionState>({ scale: 1, offset: { x: 0, y: 0 } });
|
|
@@ -23,16 +24,16 @@ const DefaultStory = (props: GridProps) => {
|
|
|
23
24
|
);
|
|
24
25
|
};
|
|
25
26
|
|
|
26
|
-
const meta
|
|
27
|
+
const meta = {
|
|
27
28
|
title: 'ui/react-ui-canvas/Grid',
|
|
28
29
|
component: GridComponent,
|
|
29
30
|
render: DefaultStory,
|
|
30
31
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
|
31
|
-
}
|
|
32
|
+
} satisfies Meta<typeof GridComponent>;
|
|
32
33
|
|
|
33
34
|
export default meta;
|
|
34
35
|
|
|
35
|
-
type Story = StoryObj<
|
|
36
|
+
type Story = StoryObj<typeof meta>;
|
|
36
37
|
|
|
37
38
|
export const Default: Story = {
|
|
38
39
|
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/util/svg.stories.tsx
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import type
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import React from 'react';
|
|
9
9
|
|
|
10
10
|
import { withTheme } from '@dxos/storybook-utils';
|
|
@@ -31,15 +31,17 @@ const DefaultStory = () => (
|
|
|
31
31
|
</svg>
|
|
32
32
|
);
|
|
33
33
|
|
|
34
|
-
const meta
|
|
34
|
+
const meta = {
|
|
35
35
|
title: 'ui/react-ui-canvas/svg',
|
|
36
36
|
render: DefaultStory,
|
|
37
37
|
decorators: [withTheme],
|
|
38
38
|
parameters: {
|
|
39
39
|
layout: 'centered',
|
|
40
40
|
},
|
|
41
|
-
};
|
|
41
|
+
} satisfies Meta;
|
|
42
42
|
|
|
43
43
|
export default meta;
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
type Story = StoryObj<typeof meta>;
|
|
46
|
+
|
|
47
|
+
export const Default: Story = {};
|