@dxos/plugin-board 0.8.4-main.f9ba587 → 0.8.4-main.fd6878d
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/{react-surface-SHXN2B3I.mjs → chunk-2AR36W5A.mjs} +42 -48
- package/dist/lib/browser/chunk-2AR36W5A.mjs.map +7 -0
- package/dist/lib/browser/chunk-V67SBM4U.mjs +59 -0
- package/dist/lib/browser/chunk-V67SBM4U.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +17 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-TDOZP647.mjs → intent-resolver-6NM32ZSV.mjs} +5 -5
- package/dist/lib/browser/{intent-resolver-TDOZP647.mjs.map → intent-resolver-6NM32ZSV.mjs.map} +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-S7H45RGL.mjs +30 -0
- package/dist/lib/browser/react-surface-S7H45RGL.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +3 -3
- package/dist/lib/node-esm/{react-surface-DGFWUKUE.mjs → chunk-AWGKINO6.mjs} +42 -47
- package/dist/lib/node-esm/chunk-AWGKINO6.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XCGDC6OV.mjs +60 -0
- package/dist/lib/node-esm/chunk-XCGDC6OV.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +17 -10
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-IHQWKJNT.mjs → intent-resolver-5DQ5PPTT.mjs} +5 -5
- package/dist/lib/node-esm/{intent-resolver-IHQWKJNT.mjs.map → intent-resolver-5DQ5PPTT.mjs.map} +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-UGBLNFXL.mjs +31 -0
- package/dist/lib/node-esm/react-surface-UGBLNFXL.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +3 -3
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/BoardContainer.d.ts +3 -3
- package/dist/types/src/components/BoardContainer.d.ts.map +1 -1
- package/dist/types/src/components/BoardContainer.stories.d.ts +8 -0
- package/dist/types/src/components/BoardContainer.stories.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Board.d.ts +88 -0
- package/dist/types/src/types/Board.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +39 -37
- package/src/BoardPlugin.tsx +1 -1
- package/src/capabilities/react-surface.tsx +1 -1
- package/src/components/BoardContainer.stories.tsx +143 -0
- package/src/components/BoardContainer.tsx +38 -28
- package/src/index.ts +2 -0
- package/src/translations.ts +2 -0
- package/src/types/Board.ts +47 -0
- package/src/types/index.ts +1 -1
- package/dist/lib/browser/chunk-TDV6SJ64.mjs +0 -46
- package/dist/lib/browser/chunk-TDV6SJ64.mjs.map +0 -7
- package/dist/lib/browser/react-surface-SHXN2B3I.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-K6CHLZYU.mjs +0 -48
- package/dist/lib/node-esm/chunk-K6CHLZYU.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-DGFWUKUE.mjs.map +0 -7
- package/dist/types/src/types/schema.d.ts +0 -65
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/types/schema.ts +0 -45
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-board",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.fd6878d",
|
|
4
4
|
"description": "Surface plugin for card baords",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -10,21 +10,23 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"source": "./src/index.ts",
|
|
13
14
|
"types": "./dist/types/src/index.d.ts",
|
|
14
15
|
"browser": "./dist/lib/browser/index.mjs",
|
|
15
16
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
16
17
|
},
|
|
17
18
|
"./types": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"source": "./src/types/index.ts",
|
|
20
|
+
"types": "./dist/types/src/types/index.d.ts",
|
|
21
|
+
"browser": "./dist/lib/browser/types/index.mjs",
|
|
22
|
+
"node": "./dist/lib/node-esm/types/index.mjs"
|
|
21
23
|
}
|
|
22
24
|
},
|
|
23
25
|
"types": "dist/types/src/index.d.ts",
|
|
24
26
|
"typesVersions": {
|
|
25
27
|
"*": {
|
|
26
28
|
"types": [
|
|
27
|
-
"dist/types/src/types.d.ts"
|
|
29
|
+
"dist/types/src/types/index.d.ts"
|
|
28
30
|
]
|
|
29
31
|
}
|
|
30
32
|
},
|
|
@@ -36,30 +38,30 @@
|
|
|
36
38
|
"@preact-signals/safe-react": "^0.9.0",
|
|
37
39
|
"@preact/signals-core": "^1.9.0",
|
|
38
40
|
"@preact/signals-react": "^3.2.0",
|
|
39
|
-
"effect": "3.
|
|
40
|
-
"@dxos/ai": "0.8.4-main.
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/echo": "0.8.4-main.
|
|
46
|
-
"@dxos/echo-schema": "0.8.4-main.
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/invariant": "0.8.4-main.
|
|
50
|
-
"@dxos/log": "0.8.4-main.
|
|
51
|
-
"@dxos/plugin-client": "0.8.4-main.
|
|
52
|
-
"@dxos/plugin-graph": "0.8.4-main.
|
|
53
|
-
"@dxos/plugin-
|
|
54
|
-
"@dxos/plugin-
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
58
|
-
"@dxos/react-ui-board": "0.8.4-main.
|
|
59
|
-
"@dxos/react-ui-form": "0.8.4-main.
|
|
60
|
-
"@dxos/react-ui-stack": "0.8.4-main.
|
|
61
|
-
"@dxos/schema": "0.8.4-main.
|
|
62
|
-
"@dxos/util": "0.8.4-main.
|
|
41
|
+
"effect": "3.17.7",
|
|
42
|
+
"@dxos/ai": "0.8.4-main.fd6878d",
|
|
43
|
+
"@dxos/app-framework": "0.8.4-main.fd6878d",
|
|
44
|
+
"@dxos/assistant": "0.8.4-main.fd6878d",
|
|
45
|
+
"@dxos/async": "0.8.4-main.fd6878d",
|
|
46
|
+
"@dxos/blueprints": "0.8.4-main.fd6878d",
|
|
47
|
+
"@dxos/echo": "0.8.4-main.fd6878d",
|
|
48
|
+
"@dxos/echo-schema": "0.8.4-main.fd6878d",
|
|
49
|
+
"@dxos/client": "0.8.4-main.fd6878d",
|
|
50
|
+
"@dxos/effect": "0.8.4-main.fd6878d",
|
|
51
|
+
"@dxos/invariant": "0.8.4-main.fd6878d",
|
|
52
|
+
"@dxos/log": "0.8.4-main.fd6878d",
|
|
53
|
+
"@dxos/plugin-client": "0.8.4-main.fd6878d",
|
|
54
|
+
"@dxos/plugin-graph": "0.8.4-main.fd6878d",
|
|
55
|
+
"@dxos/plugin-space": "0.8.4-main.fd6878d",
|
|
56
|
+
"@dxos/plugin-search": "0.8.4-main.fd6878d",
|
|
57
|
+
"@dxos/react-client": "0.8.4-main.fd6878d",
|
|
58
|
+
"@dxos/random": "0.8.4-main.fd6878d",
|
|
59
|
+
"@dxos/react-ui": "0.8.4-main.fd6878d",
|
|
60
|
+
"@dxos/react-ui-board": "0.8.4-main.fd6878d",
|
|
61
|
+
"@dxos/react-ui-form": "0.8.4-main.fd6878d",
|
|
62
|
+
"@dxos/react-ui-stack": "0.8.4-main.fd6878d",
|
|
63
|
+
"@dxos/schema": "0.8.4-main.fd6878d",
|
|
64
|
+
"@dxos/util": "0.8.4-main.fd6878d"
|
|
63
65
|
},
|
|
64
66
|
"devDependencies": {
|
|
65
67
|
"@types/react": "~18.2.0",
|
|
@@ -67,19 +69,19 @@
|
|
|
67
69
|
"react": "~18.2.0",
|
|
68
70
|
"react-dom": "~18.2.0",
|
|
69
71
|
"vite": "5.4.7",
|
|
70
|
-
"@dxos/plugin-preview": "0.8.4-main.
|
|
71
|
-
"@dxos/plugin-theme": "0.8.4-main.
|
|
72
|
-
"@dxos/react-ui-
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/test-utils": "0.8.4-main.
|
|
72
|
+
"@dxos/plugin-preview": "0.8.4-main.fd6878d",
|
|
73
|
+
"@dxos/plugin-theme": "0.8.4-main.fd6878d",
|
|
74
|
+
"@dxos/react-ui-theme": "0.8.4-main.fd6878d",
|
|
75
|
+
"@dxos/storybook-utils": "0.8.4-main.fd6878d",
|
|
76
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.fd6878d",
|
|
77
|
+
"@dxos/test-utils": "0.8.4-main.fd6878d"
|
|
76
78
|
},
|
|
77
79
|
"peerDependencies": {
|
|
78
80
|
"effect": "^3.13.3",
|
|
79
81
|
"react": "~18.2.0",
|
|
80
82
|
"react-dom": "~18.2.0",
|
|
81
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
82
|
-
"@dxos/react-ui
|
|
83
|
+
"@dxos/react-ui-theme": "0.8.4-main.fd6878d",
|
|
84
|
+
"@dxos/react-ui": "0.8.4-main.fd6878d"
|
|
83
85
|
},
|
|
84
86
|
"publishConfig": {
|
|
85
87
|
"access": "public"
|
package/src/BoardPlugin.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Capabilities, contributes, createIntent, defineModule, definePlugin
|
|
5
|
+
import { Capabilities, Events, contributes, createIntent, defineModule, definePlugin } from '@dxos/app-framework';
|
|
6
6
|
import { ClientEvents } from '@dxos/plugin-client';
|
|
7
7
|
import { SpaceCapabilities } from '@dxos/plugin-space';
|
|
8
8
|
import { defineObjectForm } from '@dxos/plugin-space/types';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Capabilities, type PluginContext, contributes, createSurface } from '@dxos/app-framework';
|
|
8
8
|
import { Obj } from '@dxos/echo';
|
|
9
9
|
|
|
10
10
|
import { BoardContainer } from '../components';
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
|
+
import React, { useEffect, useState } from 'react';
|
|
9
|
+
|
|
10
|
+
import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
|
|
11
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
+
import { Obj } from '@dxos/echo';
|
|
13
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
14
|
+
import { PreviewPlugin } from '@dxos/plugin-preview';
|
|
15
|
+
import { SpacePlugin } from '@dxos/plugin-space';
|
|
16
|
+
import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
|
|
17
|
+
import { ThemePlugin } from '@dxos/plugin-theme';
|
|
18
|
+
import { faker } from '@dxos/random';
|
|
19
|
+
import { type Client, useClient } from '@dxos/react-client';
|
|
20
|
+
import { Filter, Ref, type Space, useQuery, useSpaces } from '@dxos/react-client/echo';
|
|
21
|
+
import { translations as stackTranslations } from '@dxos/react-ui-stack';
|
|
22
|
+
import { defaultTx } from '@dxos/react-ui-theme';
|
|
23
|
+
import { DataType } from '@dxos/schema';
|
|
24
|
+
import { withLayout } from '@dxos/storybook-utils';
|
|
25
|
+
|
|
26
|
+
import { translations } from '../translations';
|
|
27
|
+
import { Board } from '../types';
|
|
28
|
+
|
|
29
|
+
import { BoardContainer } from './BoardContainer';
|
|
30
|
+
|
|
31
|
+
faker.seed(0);
|
|
32
|
+
|
|
33
|
+
//
|
|
34
|
+
// Initialization utilities
|
|
35
|
+
//
|
|
36
|
+
|
|
37
|
+
const initializeBoard = async ({ space, client }: { space: Space; client: Client }) => {
|
|
38
|
+
// Create a new board
|
|
39
|
+
const board = Obj.make(Board.Board, {
|
|
40
|
+
name: 'Test Board',
|
|
41
|
+
items: [],
|
|
42
|
+
layout: {
|
|
43
|
+
size: { width: 7, height: 5 },
|
|
44
|
+
cells: {},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return { board };
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//
|
|
52
|
+
// Story components
|
|
53
|
+
//
|
|
54
|
+
|
|
55
|
+
const rollOrg = () =>
|
|
56
|
+
({
|
|
57
|
+
name: faker.commerce.productName(),
|
|
58
|
+
description: faker.lorem.paragraph(),
|
|
59
|
+
image: faker.image.url(),
|
|
60
|
+
website: faker.internet.url(),
|
|
61
|
+
status: faker.helpers.arrayElement(DataType.OrganizationStatusOptions).id,
|
|
62
|
+
// TODO(thure): Why is this so difficult to type?
|
|
63
|
+
}) as unknown as DataType.Organization;
|
|
64
|
+
|
|
65
|
+
const StorybookBoard = () => {
|
|
66
|
+
const _client = useClient();
|
|
67
|
+
const spaces = useSpaces();
|
|
68
|
+
const space = spaces[spaces.length - 1];
|
|
69
|
+
const boards = useQuery(space, Filter.type(Board.Board));
|
|
70
|
+
const [board, setBoard] = useState<Board.Board>();
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (boards.length && !board) {
|
|
74
|
+
const board = boards[0];
|
|
75
|
+
setBoard(board);
|
|
76
|
+
}
|
|
77
|
+
}, [boards]);
|
|
78
|
+
|
|
79
|
+
if (!board) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return <BoardContainer role='board' board={board} />;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
type StoryProps = {};
|
|
87
|
+
|
|
88
|
+
//
|
|
89
|
+
// Story definitions
|
|
90
|
+
//
|
|
91
|
+
|
|
92
|
+
const meta: Meta<StoryProps> = {
|
|
93
|
+
title: 'plugins/plugin-board/Board',
|
|
94
|
+
component: StorybookBoard,
|
|
95
|
+
render: () => <StorybookBoard />,
|
|
96
|
+
parameters: { translations: [...translations, ...stackTranslations] },
|
|
97
|
+
decorators: [
|
|
98
|
+
withLayout({ fullscreen: true }),
|
|
99
|
+
withPluginManager({
|
|
100
|
+
plugins: [
|
|
101
|
+
ThemePlugin({ tx: defaultTx }),
|
|
102
|
+
ClientPlugin({
|
|
103
|
+
types: [DataType.Organization, DataType.Person, Board.Board],
|
|
104
|
+
onClientInitialized: async ({ client }) => {
|
|
105
|
+
await client.halo.createIdentity();
|
|
106
|
+
const space = await client.spaces.create();
|
|
107
|
+
await space.waitUntilReady();
|
|
108
|
+
const { board } = await initializeBoard({
|
|
109
|
+
space,
|
|
110
|
+
client,
|
|
111
|
+
});
|
|
112
|
+
space.db.add(board);
|
|
113
|
+
|
|
114
|
+
// Add some sample items
|
|
115
|
+
Array.from({ length: 10 }).map(() => {
|
|
116
|
+
const org = Obj.make(DataType.Organization, rollOrg());
|
|
117
|
+
space.db.add(org);
|
|
118
|
+
board.items.push(Ref.make(org));
|
|
119
|
+
board.layout.cells[org.id] = {
|
|
120
|
+
x: Math.floor(Math.random() * 5) - 2,
|
|
121
|
+
y: Math.floor(Math.random() * 5) - 2,
|
|
122
|
+
width: 1,
|
|
123
|
+
height: 1,
|
|
124
|
+
};
|
|
125
|
+
return org;
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
StorybookLayoutPlugin(),
|
|
130
|
+
PreviewPlugin(),
|
|
131
|
+
SpacePlugin(),
|
|
132
|
+
IntentPlugin(),
|
|
133
|
+
SettingsPlugin(),
|
|
134
|
+
],
|
|
135
|
+
}),
|
|
136
|
+
],
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export default meta;
|
|
140
|
+
|
|
141
|
+
type Story = StoryObj<StoryProps>;
|
|
142
|
+
|
|
143
|
+
export const Default: Story = {};
|
|
@@ -5,21 +5,25 @@
|
|
|
5
5
|
import { effect } from '@preact/signals-react';
|
|
6
6
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
7
7
|
|
|
8
|
+
import { Surface, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
9
|
import { getSpace } from '@dxos/client/echo';
|
|
9
|
-
import { Obj, Ref, Type } from '@dxos/echo';
|
|
10
|
+
import { type Obj, Ref, type Type } from '@dxos/echo';
|
|
10
11
|
import { invariant } from '@dxos/invariant';
|
|
11
|
-
import {
|
|
12
|
+
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
13
|
+
import { Board, type BoardController, type BoardRootProps } from '@dxos/react-ui-board';
|
|
12
14
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
13
15
|
import { isNonNullable } from '@dxos/util';
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
// TODO(thure): There is debate about having to rename either the type or the React component. A best practice should be chosen and either Board or Kanban (or both) should be refactored to apply it.
|
|
18
|
+
import { type Board as BoardType } from '../types';
|
|
16
19
|
|
|
17
20
|
export type BoardContainerProps = {
|
|
18
|
-
role
|
|
19
|
-
board:
|
|
21
|
+
role?: string;
|
|
22
|
+
board: BoardType.Board;
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
export const BoardContainer = ({ role, board }: BoardContainerProps) => {
|
|
26
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
23
27
|
const controller = useRef<BoardController>(null);
|
|
24
28
|
|
|
25
29
|
// TODO(burdon): Create effect utility for reactive arrays.
|
|
@@ -38,16 +42,22 @@ export const BoardContainer = ({ role, board }: BoardContainerProps) => {
|
|
|
38
42
|
}, [board.items]);
|
|
39
43
|
|
|
40
44
|
const handleAdd = useCallback<NonNullable<BoardRootProps['onAdd']>>(
|
|
41
|
-
(position = { x: 0, y: 0 }) => {
|
|
45
|
+
async (position = { x: 0, y: 0 }) => {
|
|
42
46
|
const space = getSpace(board);
|
|
43
47
|
invariant(space);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
await dispatch(
|
|
49
|
+
createIntent(SpaceAction.OpenCreateObject, {
|
|
50
|
+
target: space,
|
|
51
|
+
navigable: false,
|
|
52
|
+
onCreateObject: (object: Obj.Any) => {
|
|
53
|
+
board.items.push(Ref.make(object));
|
|
54
|
+
board.layout.cells[object.id] = { ...position, width: 1, height: 1 };
|
|
55
|
+
controller.current?.center(position);
|
|
56
|
+
},
|
|
57
|
+
}),
|
|
58
|
+
);
|
|
49
59
|
},
|
|
50
|
-
[board, controller],
|
|
60
|
+
[board, controller, dispatch],
|
|
51
61
|
);
|
|
52
62
|
|
|
53
63
|
// TODO(burdon): Use intents so can be undone.
|
|
@@ -73,22 +83,22 @@ export const BoardContainer = ({ role, board }: BoardContainerProps) => {
|
|
|
73
83
|
);
|
|
74
84
|
|
|
75
85
|
return (
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
</
|
|
90
|
-
</
|
|
86
|
+
<Board.Root ref={controller} layout={board.layout} onAdd={handleAdd} onDelete={handleDelete} onMove={handleMove}>
|
|
87
|
+
<StackItem.Content toolbar classNames='overflow-hidden'>
|
|
88
|
+
<Board.Toolbar />
|
|
89
|
+
<Board.Container>
|
|
90
|
+
<Board.Viewport classNames='border-none'>
|
|
91
|
+
<Board.Backdrop />
|
|
92
|
+
<Board.Content>
|
|
93
|
+
{items?.map((item, index) => (
|
|
94
|
+
<Board.Cell item={item} key={index} layout={board.layout?.cells[item.id] ?? { x: 0, y: 0 }}>
|
|
95
|
+
<Surface role='card--extrinsic' data={{ subject: item }} limit={1} />
|
|
96
|
+
</Board.Cell>
|
|
97
|
+
))}
|
|
98
|
+
</Board.Content>
|
|
99
|
+
</Board.Viewport>
|
|
100
|
+
</Board.Container>
|
|
91
101
|
</StackItem.Content>
|
|
92
|
-
</
|
|
102
|
+
</Board.Root>
|
|
93
103
|
);
|
|
94
104
|
};
|
package/src/index.ts
CHANGED
package/src/translations.ts
CHANGED
|
@@ -16,6 +16,8 @@ export const translations = [
|
|
|
16
16
|
'typename label_one': 'Board',
|
|
17
17
|
'typename label_other': 'Boards',
|
|
18
18
|
'object name placeholder': 'New board',
|
|
19
|
+
'rename object label': 'Rename board',
|
|
20
|
+
'delete object label': 'Delete board',
|
|
19
21
|
},
|
|
20
22
|
[meta.id]: {
|
|
21
23
|
'plugin name': 'Board',
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { Obj, Type } from '@dxos/echo';
|
|
8
|
+
import { LabelAnnotation } from '@dxos/echo-schema';
|
|
9
|
+
import { BoardLayout, defaultLayout } from '@dxos/react-ui-board';
|
|
10
|
+
|
|
11
|
+
import { meta } from '../meta';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Board and layout.
|
|
15
|
+
*/
|
|
16
|
+
export const Board = Schema.Struct({
|
|
17
|
+
name: Schema.optional(Schema.String),
|
|
18
|
+
items: Schema.mutable(Schema.Array(Type.Ref(Type.Expando))),
|
|
19
|
+
layout: Schema.mutable(BoardLayout),
|
|
20
|
+
}).pipe(
|
|
21
|
+
Type.Obj({
|
|
22
|
+
typename: 'dxos.org/type/Board',
|
|
23
|
+
version: '0.1.0',
|
|
24
|
+
}),
|
|
25
|
+
LabelAnnotation.set(['name']),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export interface Board extends Schema.Schema.Type<typeof Board> {}
|
|
29
|
+
|
|
30
|
+
export const makeBoard = (props: Partial<Obj.MakeProps<typeof Board>> = {}) =>
|
|
31
|
+
Obj.make(Board, {
|
|
32
|
+
items: [],
|
|
33
|
+
layout: defaultLayout,
|
|
34
|
+
...props,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create board.
|
|
39
|
+
*/
|
|
40
|
+
export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {
|
|
41
|
+
input: Schema.Struct({
|
|
42
|
+
name: Schema.optional(Schema.String),
|
|
43
|
+
}),
|
|
44
|
+
output: Schema.Struct({
|
|
45
|
+
object: Board,
|
|
46
|
+
}),
|
|
47
|
+
}) {}
|
package/src/types/index.ts
CHANGED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// src/types/schema.ts
|
|
2
|
-
import { Schema } from "effect";
|
|
3
|
-
import { Type } from "@dxos/echo";
|
|
4
|
-
import { LabelAnnotation } from "@dxos/echo-schema";
|
|
5
|
-
import { BoardLayout } from "@dxos/react-ui-board";
|
|
6
|
-
|
|
7
|
-
// src/meta.ts
|
|
8
|
-
var meta = {
|
|
9
|
-
id: "dxos.org/plugin/board",
|
|
10
|
-
name: "Board",
|
|
11
|
-
description: "A spatial, infinite canvas app combining notes, media, and whiteboarding in a tactile, visual interface.",
|
|
12
|
-
icon: "ph--squares-four--regular",
|
|
13
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-board",
|
|
14
|
-
screenshots: []
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// src/types/schema.ts
|
|
18
|
-
(function(Board2) {
|
|
19
|
-
Board2.Board = Schema.Struct({
|
|
20
|
-
name: Schema.optional(Schema.String),
|
|
21
|
-
items: Schema.mutable(Schema.Array(Type.Ref(Type.Expando))),
|
|
22
|
-
layout: Schema.mutable(BoardLayout)
|
|
23
|
-
}).pipe(Type.Obj({
|
|
24
|
-
typename: "dxos.org/type/Board",
|
|
25
|
-
version: "0.1.0"
|
|
26
|
-
}), LabelAnnotation.set([
|
|
27
|
-
"name"
|
|
28
|
-
]));
|
|
29
|
-
class Create extends Schema.TaggedClass()(`${meta.id}/action/create`, {
|
|
30
|
-
input: Schema.Struct({
|
|
31
|
-
name: Schema.optional(Schema.String)
|
|
32
|
-
}),
|
|
33
|
-
output: Schema.Struct({
|
|
34
|
-
object: Board2.Board
|
|
35
|
-
})
|
|
36
|
-
}) {
|
|
37
|
-
}
|
|
38
|
-
Board2.Create = Create;
|
|
39
|
-
})(Board || (Board = {}));
|
|
40
|
-
var Board;
|
|
41
|
-
|
|
42
|
-
export {
|
|
43
|
-
meta,
|
|
44
|
-
Board
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=chunk-TDV6SJ64.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/schema.ts", "../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { Type } from '@dxos/echo';\nimport { LabelAnnotation } from '@dxos/echo-schema';\nimport { BoardLayout } from '@dxos/react-ui-board';\n\nimport { meta } from '../meta';\n\nexport namespace Board {\n //\n // Types\n //\n\n // TODO(burdon): View?\n export const Board = Schema.Struct({\n name: Schema.optional(Schema.String),\n items: Schema.mutable(Schema.Array(Type.Ref(Type.Expando))),\n layout: Schema.mutable(BoardLayout),\n }).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Board',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n );\n\n export interface Board extends Schema.Schema.Type<typeof Board> {}\n\n //\n // Actions\n //\n\n export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {\n input: Schema.Struct({\n name: Schema.optional(Schema.String),\n }),\n output: Schema.Struct({\n object: Board,\n }),\n }) {}\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/board',\n name: 'Board',\n description:\n 'A spatial, infinite canvas app combining notes, media, and whiteboarding in a tactile, visual interface.',\n icon: 'ph--squares-four--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-board',\n screenshots: [],\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,cAAc;AAEvB,SAASC,YAAY;AACrB,SAASC,uBAAuB;AAChC,SAASC,mBAAmB;;;ACFrB,IAAMC,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aACE;EACFC,MAAM;EACNC,QAAQ;EACRC,aAAa,CAAA;AACf;;;UDFiBC,QAAAA;SAMFA,QAAQC,OAAOC,OAAO;IACjCC,MAAMF,OAAOG,SAASH,OAAOI,MAAM;IACnCC,OAAOL,OAAOM,QAAQN,OAAOO,MAAMC,KAAKC,IAAID,KAAKE,OAAO,CAAA,CAAA;IACxDC,QAAQX,OAAOM,QAAQM,WAAAA;EACzB,CAAA,EAAGC,KACDL,KAAKM,IAAI;IACPC,UAAU;IACVC,SAAS;EACX,CAAA,GACAC,gBAAgBC,IAAI;IAAC;GAAO,CAAA;EASvB,MAAMC,eAAenB,OAAOoB,YAAW,EAAW,GAAGC,KAAKC,EAAE,kBAAkB;IACnFC,OAAOvB,OAAOC,OAAO;MACnBC,MAAMF,OAAOG,SAASH,OAAOI,MAAM;IACrC,CAAA;IACAoB,QAAQxB,OAAOC,OAAO;MACpBwB,QAAM1B,OAAEA;IACV,CAAA;EACF,CAAA,EAAA;EAAI;SAPSoB,SAAAA;AAQf,GAhCiBpB,UAAAA,QAAAA,CAAAA,EAAAA;;",
|
|
6
|
-
"names": ["Schema", "Type", "LabelAnnotation", "BoardLayout", "meta", "id", "name", "description", "icon", "source", "screenshots", "Board", "Schema", "Struct", "name", "optional", "String", "items", "mutable", "Array", "Type", "Ref", "Expando", "layout", "BoardLayout", "pipe", "Obj", "typename", "version", "LabelAnnotation", "set", "Create", "TaggedClass", "meta", "id", "input", "output", "object"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/react-surface.tsx", "../../../src/components/BoardContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { contributes, Capabilities, type PluginContext, createSurface } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\n\nimport { BoardContainer } from '../components';\nimport { meta } from '../meta';\nimport { Board } from '../types';\n\nexport default (context: PluginContext) =>\n contributes(Capabilities.ReactSurface, [\n createSurface({\n id: meta.id,\n role: ['article', 'section'],\n filter: (data): data is { subject: Board.Board } => Obj.instanceOf(Board.Board, data.subject),\n component: ({ data, role }) => <BoardContainer board={data.subject} role={role} />,\n }),\n ]);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { effect } from '@preact/signals-react';\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { getSpace } from '@dxos/client/echo';\nimport { Obj, Ref, Type } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\nimport { Board as BoardComponent, type BoardController, type BoardRootProps } from '@dxos/react-ui-board';\nimport { StackItem } from '@dxos/react-ui-stack';\nimport { isNonNullable } from '@dxos/util';\n\nimport { type Board } from '../types';\n\nexport type BoardContainerProps = {\n role: string;\n board: Board.Board;\n};\n\nexport const BoardContainer = ({ role, board }: BoardContainerProps) => {\n const controller = useRef<BoardController>(null);\n\n // TODO(burdon): Create effect utility for reactive arrays.\n const [items, setItems] = useState<Type.Expando[]>([]);\n useEffect(() => {\n let t: NodeJS.Timeout;\n effect(() => {\n const refs = [...board.items];\n t = setTimeout(async () => {\n const items = await Ref.Array.loadAll(refs);\n setItems(items.filter(isNonNullable));\n });\n });\n\n return () => clearTimeout(t);\n }, [board.items]);\n\n const handleAdd = useCallback<NonNullable<BoardRootProps['onAdd']>>(\n (position = { x: 0, y: 0 }) => {\n const space = getSpace(board);\n invariant(space);\n // TODO(burdon): Create from menu/intent?\n const obj = space.db.add(Obj.make(Type.Expando, {}));\n board.items.push(Ref.make(obj));\n board.layout.cells[obj.id] = { ...position, width: 1, height: 1 };\n controller.current?.center(position);\n },\n [board, controller],\n );\n\n // TODO(burdon): Use intents so can be undone.\n const handleDelete = useCallback<NonNullable<BoardRootProps['onDelete']>>(\n (id) => {\n // TODO(burdon): Impl. DXN.equals and pass in DXN from `id`.\n const idx = board.items.findIndex((ref) => ref.dxn.asEchoDXN()?.echoId === id);\n if (idx !== -1) {\n board.items.splice(idx, 1);\n }\n delete board.layout.cells[id];\n setItems((items) => items.filter((item) => item.id !== id));\n },\n [board],\n );\n\n const handleMove = useCallback<NonNullable<BoardRootProps['onMove']>>(\n (id, position) => {\n const layout = board.layout.cells[id];\n board.layout.cells[id] = { ...layout, ...position };\n },\n [board],\n );\n\n return (\n <BoardComponent.Root\n ref={controller}\n layout={board.layout}\n onAdd={handleAdd}\n onDelete={handleDelete}\n onMove={handleMove}\n >\n <StackItem.Content role={role} toolbar>\n <BoardComponent.Controls />\n <BoardComponent.Container>\n <BoardComponent.Viewport classNames='border-none'>\n <BoardComponent.Background />\n <BoardComponent.Content items={items} getTitle={(item) => Obj.getLabel(item) ?? item.id} />\n </BoardComponent.Viewport>\n </BoardComponent.Container>\n </StackItem.Content>\n </BoardComponent.Root>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;AAIA,OAAOA,YAAW;AAElB,SAASC,aAAaC,cAAkCC,qBAAqB;AAC7E,SAASC,OAAAA,YAAW;;;;ACHpB,SAASC,cAAc;AACvB,OAAOC,SAASC,a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|
|
6
|
-
"names": ["React", "contributes", "Capabilities", "createSurface", "Obj", "effect", "React", "useCallback", "useEffect", "useRef", "useState", "getSpace", "Obj", "Ref", "Type", "invariant", "Board", "BoardComponent", "StackItem", "isNonNullable", "BoardContainer", "role", "board", "controller", "items", "setItems", "t", "refs", "setTimeout", "Array", "loadAll", "filter", "clearTimeout", "handleAdd", "position", "x", "y", "space", "obj", "db", "add", "make", "Expando", "push", "layout", "cells", "id", "width", "height", "current", "center", "handleDelete", "idx", "findIndex", "ref", "dxn", "asEchoDXN", "echoId", "splice", "item", "handleMove", "Root", "onAdd", "onDelete", "onMove", "Content", "toolbar", "Controls", "Container", "Viewport", "classNames", "Background", "getTitle", "getLabel", "context", "contributes", "Capabilities", "ReactSurface", "createSurface", "id", "meta", "role", "filter", "data", "Obj", "instanceOf", "Board", "subject", "component", "React", "BoardContainer", "board"]
|
|
7
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/types/schema.ts
|
|
4
|
-
import { Schema } from "effect";
|
|
5
|
-
import { Type } from "@dxos/echo";
|
|
6
|
-
import { LabelAnnotation } from "@dxos/echo-schema";
|
|
7
|
-
import { BoardLayout } from "@dxos/react-ui-board";
|
|
8
|
-
|
|
9
|
-
// src/meta.ts
|
|
10
|
-
var meta = {
|
|
11
|
-
id: "dxos.org/plugin/board",
|
|
12
|
-
name: "Board",
|
|
13
|
-
description: "A spatial, infinite canvas app combining notes, media, and whiteboarding in a tactile, visual interface.",
|
|
14
|
-
icon: "ph--squares-four--regular",
|
|
15
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-board",
|
|
16
|
-
screenshots: []
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// src/types/schema.ts
|
|
20
|
-
(function(Board2) {
|
|
21
|
-
Board2.Board = Schema.Struct({
|
|
22
|
-
name: Schema.optional(Schema.String),
|
|
23
|
-
items: Schema.mutable(Schema.Array(Type.Ref(Type.Expando))),
|
|
24
|
-
layout: Schema.mutable(BoardLayout)
|
|
25
|
-
}).pipe(Type.Obj({
|
|
26
|
-
typename: "dxos.org/type/Board",
|
|
27
|
-
version: "0.1.0"
|
|
28
|
-
}), LabelAnnotation.set([
|
|
29
|
-
"name"
|
|
30
|
-
]));
|
|
31
|
-
class Create extends Schema.TaggedClass()(`${meta.id}/action/create`, {
|
|
32
|
-
input: Schema.Struct({
|
|
33
|
-
name: Schema.optional(Schema.String)
|
|
34
|
-
}),
|
|
35
|
-
output: Schema.Struct({
|
|
36
|
-
object: Board2.Board
|
|
37
|
-
})
|
|
38
|
-
}) {
|
|
39
|
-
}
|
|
40
|
-
Board2.Create = Create;
|
|
41
|
-
})(Board || (Board = {}));
|
|
42
|
-
var Board;
|
|
43
|
-
|
|
44
|
-
export {
|
|
45
|
-
meta,
|
|
46
|
-
Board
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=chunk-K6CHLZYU.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/schema.ts", "../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { Type } from '@dxos/echo';\nimport { LabelAnnotation } from '@dxos/echo-schema';\nimport { BoardLayout } from '@dxos/react-ui-board';\n\nimport { meta } from '../meta';\n\nexport namespace Board {\n //\n // Types\n //\n\n // TODO(burdon): View?\n export const Board = Schema.Struct({\n name: Schema.optional(Schema.String),\n items: Schema.mutable(Schema.Array(Type.Ref(Type.Expando))),\n layout: Schema.mutable(BoardLayout),\n }).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Board',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n );\n\n export interface Board extends Schema.Schema.Type<typeof Board> {}\n\n //\n // Actions\n //\n\n export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {\n input: Schema.Struct({\n name: Schema.optional(Schema.String),\n }),\n output: Schema.Struct({\n object: Board,\n }),\n }) {}\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/board',\n name: 'Board',\n description:\n 'A spatial, infinite canvas app combining notes, media, and whiteboarding in a tactile, visual interface.',\n icon: 'ph--squares-four--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-board',\n screenshots: [],\n};\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,cAAc;AAEvB,SAASC,YAAY;AACrB,SAASC,uBAAuB;AAChC,SAASC,mBAAmB;;;ACFrB,IAAMC,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aACE;EACFC,MAAM;EACNC,QAAQ;EACRC,aAAa,CAAA;AACf;;;UDFiBC,QAAAA;SAMFA,QAAQC,OAAOC,OAAO;IACjCC,MAAMF,OAAOG,SAASH,OAAOI,MAAM;IACnCC,OAAOL,OAAOM,QAAQN,OAAOO,MAAMC,KAAKC,IAAID,KAAKE,OAAO,CAAA,CAAA;IACxDC,QAAQX,OAAOM,QAAQM,WAAAA;EACzB,CAAA,EAAGC,KACDL,KAAKM,IAAI;IACPC,UAAU;IACVC,SAAS;EACX,CAAA,GACAC,gBAAgBC,IAAI;IAAC;GAAO,CAAA;EASvB,MAAMC,eAAenB,OAAOoB,YAAW,EAAW,GAAGC,KAAKC,EAAE,kBAAkB;IACnFC,OAAOvB,OAAOC,OAAO;MACnBC,MAAMF,OAAOG,SAASH,OAAOI,MAAM;IACrC,CAAA;IACAoB,QAAQxB,OAAOC,OAAO;MACpBwB,QAAM1B,OAAEA;IACV,CAAA;EACF,CAAA,EAAA;EAAI;SAPSoB,SAAAA;AAQf,GAhCiBpB,UAAAA,QAAAA,CAAAA,EAAAA;;",
|
|
6
|
-
"names": ["Schema", "Type", "LabelAnnotation", "BoardLayout", "meta", "id", "name", "description", "icon", "source", "screenshots", "Board", "Schema", "Struct", "name", "optional", "String", "items", "mutable", "Array", "Type", "Ref", "Expando", "layout", "BoardLayout", "pipe", "Obj", "typename", "version", "LabelAnnotation", "set", "Create", "TaggedClass", "meta", "id", "input", "output", "object"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/react-surface.tsx", "../../../src/components/BoardContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { contributes, Capabilities, type PluginContext, createSurface } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\n\nimport { BoardContainer } from '../components';\nimport { meta } from '../meta';\nimport { Board } from '../types';\n\nexport default (context: PluginContext) =>\n contributes(Capabilities.ReactSurface, [\n createSurface({\n id: meta.id,\n role: ['article', 'section'],\n filter: (data): data is { subject: Board.Board } => Obj.instanceOf(Board.Board, data.subject),\n component: ({ data, role }) => <BoardContainer board={data.subject} role={role} />,\n }),\n ]);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { effect } from '@preact/signals-react';\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { getSpace } from '@dxos/client/echo';\nimport { Obj, Ref, Type } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\nimport { Board as BoardComponent, type BoardController, type BoardRootProps } from '@dxos/react-ui-board';\nimport { StackItem } from '@dxos/react-ui-stack';\nimport { isNonNullable } from '@dxos/util';\n\nimport { type Board } from '../types';\n\nexport type BoardContainerProps = {\n role: string;\n board: Board.Board;\n};\n\nexport const BoardContainer = ({ role, board }: BoardContainerProps) => {\n const controller = useRef<BoardController>(null);\n\n // TODO(burdon): Create effect utility for reactive arrays.\n const [items, setItems] = useState<Type.Expando[]>([]);\n useEffect(() => {\n let t: NodeJS.Timeout;\n effect(() => {\n const refs = [...board.items];\n t = setTimeout(async () => {\n const items = await Ref.Array.loadAll(refs);\n setItems(items.filter(isNonNullable));\n });\n });\n\n return () => clearTimeout(t);\n }, [board.items]);\n\n const handleAdd = useCallback<NonNullable<BoardRootProps['onAdd']>>(\n (position = { x: 0, y: 0 }) => {\n const space = getSpace(board);\n invariant(space);\n // TODO(burdon): Create from menu/intent?\n const obj = space.db.add(Obj.make(Type.Expando, {}));\n board.items.push(Ref.make(obj));\n board.layout.cells[obj.id] = { ...position, width: 1, height: 1 };\n controller.current?.center(position);\n },\n [board, controller],\n );\n\n // TODO(burdon): Use intents so can be undone.\n const handleDelete = useCallback<NonNullable<BoardRootProps['onDelete']>>(\n (id) => {\n // TODO(burdon): Impl. DXN.equals and pass in DXN from `id`.\n const idx = board.items.findIndex((ref) => ref.dxn.asEchoDXN()?.echoId === id);\n if (idx !== -1) {\n board.items.splice(idx, 1);\n }\n delete board.layout.cells[id];\n setItems((items) => items.filter((item) => item.id !== id));\n },\n [board],\n );\n\n const handleMove = useCallback<NonNullable<BoardRootProps['onMove']>>(\n (id, position) => {\n const layout = board.layout.cells[id];\n board.layout.cells[id] = { ...layout, ...position };\n },\n [board],\n );\n\n return (\n <BoardComponent.Root\n ref={controller}\n layout={board.layout}\n onAdd={handleAdd}\n onDelete={handleDelete}\n onMove={handleMove}\n >\n <StackItem.Content role={role} toolbar>\n <BoardComponent.Controls />\n <BoardComponent.Container>\n <BoardComponent.Viewport classNames='border-none'>\n <BoardComponent.Background />\n <BoardComponent.Content items={items} getTitle={(item) => Obj.getLabel(item) ?? item.id} />\n </BoardComponent.Viewport>\n </BoardComponent.Container>\n </StackItem.Content>\n </BoardComponent.Root>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAIA,OAAOA,YAAW;AAElB,SAASC,aAAaC,cAAkCC,qBAAqB;AAC7E,SAASC,OAAAA,YAAW;;;;ACHpB,SAASC,cAAc;AACvB,OAAOC,SAASC,aAAaC,WAAWC,QAAQC,gBAAgB;AAEhE,SAAS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face", "Obj", "effect", "React", "useCallback", "useEffect", "useRef", "useState", "getSpace", "Obj", "Ref", "Type", "invariant", "Board", "BoardComponent", "StackItem", "isNonNullable", "BoardContainer", "role", "board", "controller", "items", "setItems", "t", "refs", "setTimeout", "Array", "loadAll", "filter", "clearTimeout", "handleAdd", "position", "x", "y", "space", "obj", "db", "add", "make", "Expando", "push", "layout", "cells", "id", "width", "height", "current", "center", "handleDelete", "idx", "findIndex", "ref", "dxn", "asEchoDXN", "echoId", "splice", "item", "handleMove", "Root", "onAdd", "onDelete", "onMove", "Content", "toolbar", "Controls", "Container", "Viewport", "classNames", "Background", "getTitle", "getLabel", "context", "contributes", "Capabilities", "ReactSurface", "createSurface", "id", "meta", "role", "filter", "data", "Obj", "instanceOf", "Board", "subject", "component", "React", "BoardContainer", "board"]
|
|
7
|
-
}
|