@dxos/plugin-board 0.8.4-main.c1de068
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/LICENSE +8 -0
- package/README.md +15 -0
- package/dist/lib/browser/chunk-TDV6SJ64.mjs +46 -0
- package/dist/lib/browser/chunk-TDV6SJ64.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +86 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/intent-resolver-TDOZP647.mjs +33 -0
- package/dist/lib/browser/intent-resolver-TDOZP647.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/react-surface-XFSXU2JJ.mjs +143 -0
- package/dist/lib/browser/react-surface-XFSXU2JJ.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -0
- package/dist/lib/browser/types/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-K6CHLZYU.mjs +48 -0
- package/dist/lib/node-esm/chunk-K6CHLZYU.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +87 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/intent-resolver-IHQWKJNT.mjs +34 -0
- package/dist/lib/node-esm/intent-resolver-IHQWKJNT.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/react-surface-ZHPQBZWO.mjs +144 -0
- package/dist/lib/node-esm/react-surface-ZHPQBZWO.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +8 -0
- package/dist/lib/node-esm/types/index.mjs.map +7 -0
- package/dist/types/src/BoardPlugin.d.ts +2 -0
- package/dist/types/src/BoardPlugin.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +3 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/BoardContainer.d.ts +8 -0
- package/dist/types/src/components/BoardContainer.d.ts.map +1 -0
- 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/components/index.d.ts +2 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +3 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +19 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +65 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +87 -0
- package/src/BoardPlugin.tsx +58 -0
- package/src/capabilities/index.ts +8 -0
- package/src/capabilities/intent-resolver.ts +34 -0
- package/src/capabilities/react-surface.tsx +22 -0
- package/src/components/BoardContainer.stories.tsx +142 -0
- package/src/components/BoardContainer.tsx +104 -0
- package/src/components/index.ts +5 -0
- package/src/index.ts +7 -0
- package/src/meta.ts +15 -0
- package/src/translations.ts +27 -0
- package/src/types/index.ts +5 -0
- package/src/types/schema.ts +45 -0
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dxos/plugin-board",
|
|
3
|
+
"version": "0.8.4-main.c1de068",
|
|
4
|
+
"description": "Surface plugin for card baords",
|
|
5
|
+
"homepage": "https://dxos.org",
|
|
6
|
+
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "DXOS.org",
|
|
9
|
+
"sideEffects": true,
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/types/src/index.d.ts",
|
|
14
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
15
|
+
"node": "./dist/lib/node-esm/index.mjs"
|
|
16
|
+
},
|
|
17
|
+
"./types": {
|
|
18
|
+
"types": "./dist/types/src/types/index.d.ts",
|
|
19
|
+
"browser": "./dist/lib/browser/types/index.mjs",
|
|
20
|
+
"node": "./dist/lib/node-esm/types/index.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"types": "dist/types/src/index.d.ts",
|
|
24
|
+
"typesVersions": {
|
|
25
|
+
"*": {
|
|
26
|
+
"types": [
|
|
27
|
+
"dist/types/src/types/index.d.ts"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"src"
|
|
34
|
+
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@preact-signals/safe-react": "^0.9.0",
|
|
37
|
+
"@preact/signals-core": "^1.9.0",
|
|
38
|
+
"@preact/signals-react": "^3.2.0",
|
|
39
|
+
"effect": "3.17.0",
|
|
40
|
+
"@dxos/ai": "0.8.4-main.c1de068",
|
|
41
|
+
"@dxos/assistant": "0.8.4-main.c1de068",
|
|
42
|
+
"@dxos/app-framework": "0.8.4-main.c1de068",
|
|
43
|
+
"@dxos/async": "0.8.4-main.c1de068",
|
|
44
|
+
"@dxos/client": "0.8.4-main.c1de068",
|
|
45
|
+
"@dxos/blueprints": "0.8.4-main.c1de068",
|
|
46
|
+
"@dxos/echo": "0.8.4-main.c1de068",
|
|
47
|
+
"@dxos/effect": "0.8.4-main.c1de068",
|
|
48
|
+
"@dxos/echo-schema": "0.8.4-main.c1de068",
|
|
49
|
+
"@dxos/invariant": "0.8.4-main.c1de068",
|
|
50
|
+
"@dxos/log": "0.8.4-main.c1de068",
|
|
51
|
+
"@dxos/plugin-client": "0.8.4-main.c1de068",
|
|
52
|
+
"@dxos/plugin-graph": "0.8.4-main.c1de068",
|
|
53
|
+
"@dxos/plugin-space": "0.8.4-main.c1de068",
|
|
54
|
+
"@dxos/plugin-search": "0.8.4-main.c1de068",
|
|
55
|
+
"@dxos/random": "0.8.4-main.c1de068",
|
|
56
|
+
"@dxos/react-client": "0.8.4-main.c1de068",
|
|
57
|
+
"@dxos/react-ui": "0.8.4-main.c1de068",
|
|
58
|
+
"@dxos/react-ui-board": "0.8.4-main.c1de068",
|
|
59
|
+
"@dxos/react-ui-form": "0.8.4-main.c1de068",
|
|
60
|
+
"@dxos/react-ui-stack": "0.8.4-main.c1de068",
|
|
61
|
+
"@dxos/schema": "0.8.4-main.c1de068",
|
|
62
|
+
"@dxos/util": "0.8.4-main.c1de068"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@types/react": "~18.2.0",
|
|
66
|
+
"@types/react-dom": "~18.2.0",
|
|
67
|
+
"react": "~18.2.0",
|
|
68
|
+
"react-dom": "~18.2.0",
|
|
69
|
+
"vite": "5.4.7",
|
|
70
|
+
"@dxos/plugin-preview": "0.8.4-main.c1de068",
|
|
71
|
+
"@dxos/plugin-theme": "0.8.4-main.c1de068",
|
|
72
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.c1de068",
|
|
73
|
+
"@dxos/react-ui-theme": "0.8.4-main.c1de068",
|
|
74
|
+
"@dxos/test-utils": "0.8.4-main.c1de068",
|
|
75
|
+
"@dxos/storybook-utils": "0.8.4-main.c1de068"
|
|
76
|
+
},
|
|
77
|
+
"peerDependencies": {
|
|
78
|
+
"effect": "^3.13.3",
|
|
79
|
+
"react": "~18.2.0",
|
|
80
|
+
"react-dom": "~18.2.0",
|
|
81
|
+
"@dxos/react-ui": "0.8.4-main.c1de068",
|
|
82
|
+
"@dxos/react-ui-theme": "0.8.4-main.c1de068"
|
|
83
|
+
},
|
|
84
|
+
"publishConfig": {
|
|
85
|
+
"access": "public"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Capabilities, contributes, createIntent, defineModule, definePlugin, Events } from '@dxos/app-framework';
|
|
6
|
+
import { ClientEvents } from '@dxos/plugin-client';
|
|
7
|
+
import { SpaceCapabilities } from '@dxos/plugin-space';
|
|
8
|
+
import { defineObjectForm } from '@dxos/plugin-space/types';
|
|
9
|
+
import { translations as boardTranslations } from '@dxos/react-ui-board';
|
|
10
|
+
|
|
11
|
+
import { IntentResolver, ReactSurface } from './capabilities';
|
|
12
|
+
import { meta } from './meta';
|
|
13
|
+
import { translations } from './translations';
|
|
14
|
+
import { Board } from './types';
|
|
15
|
+
|
|
16
|
+
export const BoardPlugin = () => {
|
|
17
|
+
return definePlugin(meta, [
|
|
18
|
+
defineModule({
|
|
19
|
+
id: `${meta.id}/module/translations`,
|
|
20
|
+
activatesOn: Events.SetupTranslations,
|
|
21
|
+
activate: () => contributes(Capabilities.Translations, [...translations, ...boardTranslations]),
|
|
22
|
+
}),
|
|
23
|
+
defineModule({
|
|
24
|
+
id: `${meta.id}/module/metadata`,
|
|
25
|
+
activatesOn: Events.SetupMetadata,
|
|
26
|
+
activate: () =>
|
|
27
|
+
// TODO(burdon): "Metadata" here seems non-descriptive; is this specifically for the type? ObjectMetadata?
|
|
28
|
+
contributes(Capabilities.Metadata, {
|
|
29
|
+
id: Board.Board.typename,
|
|
30
|
+
metadata: {
|
|
31
|
+
icon: 'ph--squares-four--regular',
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
}),
|
|
35
|
+
defineModule({
|
|
36
|
+
id: `${meta.id}/module/object-form`,
|
|
37
|
+
activatesOn: ClientEvents.SetupSchema,
|
|
38
|
+
activate: () =>
|
|
39
|
+
contributes(
|
|
40
|
+
SpaceCapabilities.ObjectForm,
|
|
41
|
+
defineObjectForm({
|
|
42
|
+
objectSchema: Board.Board,
|
|
43
|
+
getIntent: () => createIntent(Board.Create),
|
|
44
|
+
}),
|
|
45
|
+
),
|
|
46
|
+
}),
|
|
47
|
+
defineModule({
|
|
48
|
+
id: `${meta.id}/module/react-surface`,
|
|
49
|
+
activatesOn: Events.SetupReactSurface,
|
|
50
|
+
activate: ReactSurface,
|
|
51
|
+
}),
|
|
52
|
+
defineModule({
|
|
53
|
+
id: `${meta.id}/module/intent-resolver`,
|
|
54
|
+
activatesOn: Events.SetupIntentResolver,
|
|
55
|
+
activate: IntentResolver,
|
|
56
|
+
}),
|
|
57
|
+
]);
|
|
58
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Capabilities, contributes, createResolver } from '@dxos/app-framework';
|
|
6
|
+
import { Obj } from '@dxos/echo';
|
|
7
|
+
|
|
8
|
+
import { Board } from '../types';
|
|
9
|
+
|
|
10
|
+
export default () => [
|
|
11
|
+
contributes(
|
|
12
|
+
Capabilities.IntentResolver,
|
|
13
|
+
createResolver({
|
|
14
|
+
intent: Board.Create,
|
|
15
|
+
resolve: ({ name }) => {
|
|
16
|
+
return {
|
|
17
|
+
data: {
|
|
18
|
+
object: Obj.make(Board.Board, {
|
|
19
|
+
name,
|
|
20
|
+
items: [],
|
|
21
|
+
layout: {
|
|
22
|
+
size: {
|
|
23
|
+
width: 5,
|
|
24
|
+
height: 5,
|
|
25
|
+
},
|
|
26
|
+
cells: {},
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
),
|
|
34
|
+
];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { contributes, Capabilities, type PluginContext, createSurface } from '@dxos/app-framework';
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
|
+
|
|
10
|
+
import { BoardContainer } from '../components';
|
|
11
|
+
import { meta } from '../meta';
|
|
12
|
+
import { Board } from '../types';
|
|
13
|
+
|
|
14
|
+
export default (context: PluginContext) =>
|
|
15
|
+
contributes(Capabilities.ReactSurface, [
|
|
16
|
+
createSurface({
|
|
17
|
+
id: meta.id,
|
|
18
|
+
role: ['article', 'section'],
|
|
19
|
+
filter: (data): data is { subject: Board.Board } => Obj.instanceOf(Board.Board, data.subject),
|
|
20
|
+
component: ({ data, role }) => <BoardContainer board={data.subject} role={role} />,
|
|
21
|
+
}),
|
|
22
|
+
]);
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type StoryObj, type Meta } 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, useSpaces, useQuery, Ref, type Space } 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 { BoardContainer } from './BoardContainer';
|
|
27
|
+
import { translations } from '../translations';
|
|
28
|
+
import { Board } from '../types';
|
|
29
|
+
|
|
30
|
+
faker.seed(0);
|
|
31
|
+
|
|
32
|
+
//
|
|
33
|
+
// Initialization utilities
|
|
34
|
+
//
|
|
35
|
+
|
|
36
|
+
const initializeBoard = async ({ space, client }: { space: Space; client: Client }) => {
|
|
37
|
+
// Create a new board
|
|
38
|
+
const board = Obj.make(Board.Board, {
|
|
39
|
+
name: 'Test Board',
|
|
40
|
+
items: [],
|
|
41
|
+
layout: {
|
|
42
|
+
size: { width: 7, height: 5 },
|
|
43
|
+
cells: {},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return { board };
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
//
|
|
51
|
+
// Story components
|
|
52
|
+
//
|
|
53
|
+
|
|
54
|
+
const rollOrg = () =>
|
|
55
|
+
({
|
|
56
|
+
name: faker.commerce.productName(),
|
|
57
|
+
description: faker.lorem.paragraph(),
|
|
58
|
+
image: faker.image.url(),
|
|
59
|
+
website: faker.internet.url(),
|
|
60
|
+
status: faker.helpers.arrayElement(DataType.OrganizationStatusOptions).id,
|
|
61
|
+
// TODO(thure): Why is this so difficult to type?
|
|
62
|
+
}) as unknown as DataType.Organization;
|
|
63
|
+
|
|
64
|
+
const StorybookBoard = () => {
|
|
65
|
+
const _client = useClient();
|
|
66
|
+
const spaces = useSpaces();
|
|
67
|
+
const space = spaces[spaces.length - 1];
|
|
68
|
+
const boards = useQuery(space, Filter.type(Board.Board));
|
|
69
|
+
const [board, setBoard] = useState<Board.Board>();
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (boards.length && !board) {
|
|
73
|
+
const board = boards[0];
|
|
74
|
+
setBoard(board);
|
|
75
|
+
}
|
|
76
|
+
}, [boards]);
|
|
77
|
+
|
|
78
|
+
if (!board) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return <BoardContainer role='board' board={board} />;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
type StoryProps = {};
|
|
86
|
+
|
|
87
|
+
//
|
|
88
|
+
// Story definitions
|
|
89
|
+
//
|
|
90
|
+
|
|
91
|
+
const meta: Meta<StoryProps> = {
|
|
92
|
+
title: 'plugins/plugin-board/Board',
|
|
93
|
+
component: StorybookBoard,
|
|
94
|
+
render: () => <StorybookBoard />,
|
|
95
|
+
parameters: { translations: [...translations, ...stackTranslations] },
|
|
96
|
+
decorators: [
|
|
97
|
+
withLayout({ fullscreen: true }),
|
|
98
|
+
withPluginManager({
|
|
99
|
+
plugins: [
|
|
100
|
+
ThemePlugin({ tx: defaultTx }),
|
|
101
|
+
ClientPlugin({
|
|
102
|
+
types: [DataType.Organization, DataType.Person, Board.Board],
|
|
103
|
+
onClientInitialized: async (_, client) => {
|
|
104
|
+
await client.halo.createIdentity();
|
|
105
|
+
const space = await client.spaces.create();
|
|
106
|
+
await space.waitUntilReady();
|
|
107
|
+
const { board } = await initializeBoard({
|
|
108
|
+
space,
|
|
109
|
+
client,
|
|
110
|
+
});
|
|
111
|
+
space.db.add(board);
|
|
112
|
+
|
|
113
|
+
// Add some sample items
|
|
114
|
+
Array.from({ length: 10 }).map((_, index) => {
|
|
115
|
+
const org = Obj.make(DataType.Organization, rollOrg());
|
|
116
|
+
space.db.add(org);
|
|
117
|
+
board.items.push(Ref.make(org));
|
|
118
|
+
board.layout.cells[org.id] = {
|
|
119
|
+
x: Math.floor(Math.random() * 5) - 2,
|
|
120
|
+
y: Math.floor(Math.random() * 5) - 2,
|
|
121
|
+
width: 1,
|
|
122
|
+
height: 1,
|
|
123
|
+
};
|
|
124
|
+
return org;
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
}),
|
|
128
|
+
StorybookLayoutPlugin(),
|
|
129
|
+
PreviewPlugin(),
|
|
130
|
+
SpacePlugin(),
|
|
131
|
+
IntentPlugin(),
|
|
132
|
+
SettingsPlugin(),
|
|
133
|
+
],
|
|
134
|
+
}),
|
|
135
|
+
],
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export default meta;
|
|
139
|
+
|
|
140
|
+
type Story = StoryObj<StoryProps>;
|
|
141
|
+
|
|
142
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { effect } from '@preact/signals-react';
|
|
6
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { createIntent, Surface, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
+
import { getSpace } from '@dxos/client/echo';
|
|
10
|
+
import { type Obj, Ref, type Type } from '@dxos/echo';
|
|
11
|
+
import { invariant } from '@dxos/invariant';
|
|
12
|
+
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
13
|
+
import { Board, type BoardController, type BoardRootProps } from '@dxos/react-ui-board';
|
|
14
|
+
import { StackItem } from '@dxos/react-ui-stack';
|
|
15
|
+
import { isNonNullable } from '@dxos/util';
|
|
16
|
+
|
|
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';
|
|
19
|
+
|
|
20
|
+
export type BoardContainerProps = {
|
|
21
|
+
role: string;
|
|
22
|
+
board: BoardType.Board;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const BoardContainer = ({ role, board }: BoardContainerProps) => {
|
|
26
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
27
|
+
const controller = useRef<BoardController>(null);
|
|
28
|
+
|
|
29
|
+
// TODO(burdon): Create effect utility for reactive arrays.
|
|
30
|
+
const [items, setItems] = useState<Type.Expando[]>([]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
let t: NodeJS.Timeout;
|
|
33
|
+
effect(() => {
|
|
34
|
+
const refs = [...board.items];
|
|
35
|
+
t = setTimeout(async () => {
|
|
36
|
+
const items = await Ref.Array.loadAll(refs);
|
|
37
|
+
setItems(items.filter(isNonNullable));
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return () => clearTimeout(t);
|
|
42
|
+
}, [board.items]);
|
|
43
|
+
|
|
44
|
+
const handleAdd = useCallback<NonNullable<BoardRootProps['onAdd']>>(
|
|
45
|
+
async (position = { x: 0, y: 0 }) => {
|
|
46
|
+
const space = getSpace(board);
|
|
47
|
+
invariant(space);
|
|
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
|
+
);
|
|
59
|
+
},
|
|
60
|
+
[board, controller, dispatch],
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
// TODO(burdon): Use intents so can be undone.
|
|
64
|
+
const handleDelete = useCallback<NonNullable<BoardRootProps['onDelete']>>(
|
|
65
|
+
(id) => {
|
|
66
|
+
// TODO(burdon): Impl. DXN.equals and pass in DXN from `id`.
|
|
67
|
+
const idx = board.items.findIndex((ref) => ref.dxn.asEchoDXN()?.echoId === id);
|
|
68
|
+
if (idx !== -1) {
|
|
69
|
+
board.items.splice(idx, 1);
|
|
70
|
+
}
|
|
71
|
+
delete board.layout.cells[id];
|
|
72
|
+
setItems((items) => items.filter((item) => item.id !== id));
|
|
73
|
+
},
|
|
74
|
+
[board],
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const handleMove = useCallback<NonNullable<BoardRootProps['onMove']>>(
|
|
78
|
+
(id, position) => {
|
|
79
|
+
const layout = board.layout.cells[id];
|
|
80
|
+
board.layout.cells[id] = { ...layout, ...position };
|
|
81
|
+
},
|
|
82
|
+
[board],
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Board.Root ref={controller} layout={board.layout} onAdd={handleAdd} onDelete={handleDelete} onMove={handleMove}>
|
|
87
|
+
<StackItem.Content toolbar>
|
|
88
|
+
<Board.Controls />
|
|
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>
|
|
101
|
+
</StackItem.Content>
|
|
102
|
+
</Board.Root>
|
|
103
|
+
);
|
|
104
|
+
};
|
package/src/index.ts
ADDED
package/src/meta.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
export const meta: PluginMeta = {
|
|
8
|
+
id: 'dxos.org/plugin/board',
|
|
9
|
+
name: 'Board',
|
|
10
|
+
description:
|
|
11
|
+
'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
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Resource } from '@dxos/react-ui';
|
|
6
|
+
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
import { Board } from './types';
|
|
9
|
+
|
|
10
|
+
export const translations = [
|
|
11
|
+
{
|
|
12
|
+
'en-US': {
|
|
13
|
+
[Board.Board.typename]: {
|
|
14
|
+
'typename label': 'Board',
|
|
15
|
+
'typename label_zero': 'Boards',
|
|
16
|
+
'typename label_one': 'Board',
|
|
17
|
+
'typename label_other': 'Boards',
|
|
18
|
+
'object name placeholder': 'New board',
|
|
19
|
+
'rename object label': 'Rename board',
|
|
20
|
+
'delete object label': 'Delete board',
|
|
21
|
+
},
|
|
22
|
+
[meta.id]: {
|
|
23
|
+
'plugin name': 'Board',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
] as const satisfies Resource[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { Type } from '@dxos/echo';
|
|
8
|
+
import { LabelAnnotation } from '@dxos/echo-schema';
|
|
9
|
+
import { BoardLayout } from '@dxos/react-ui-board';
|
|
10
|
+
|
|
11
|
+
import { meta } from '../meta';
|
|
12
|
+
|
|
13
|
+
export namespace Board {
|
|
14
|
+
//
|
|
15
|
+
// Types
|
|
16
|
+
//
|
|
17
|
+
|
|
18
|
+
// TODO(burdon): View?
|
|
19
|
+
export const 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(
|
|
24
|
+
Type.Obj({
|
|
25
|
+
typename: 'dxos.org/type/Board',
|
|
26
|
+
version: '0.1.0',
|
|
27
|
+
}),
|
|
28
|
+
LabelAnnotation.set(['name']),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export interface Board extends Schema.Schema.Type<typeof Board> {}
|
|
32
|
+
|
|
33
|
+
//
|
|
34
|
+
// Actions
|
|
35
|
+
//
|
|
36
|
+
|
|
37
|
+
export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {
|
|
38
|
+
input: Schema.Struct({
|
|
39
|
+
name: Schema.optional(Schema.String),
|
|
40
|
+
}),
|
|
41
|
+
output: Schema.Struct({
|
|
42
|
+
object: Board,
|
|
43
|
+
}),
|
|
44
|
+
}) {}
|
|
45
|
+
}
|