@dxos/plugin-board 0.8.4-main.1da679c
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-V67SBM4U.mjs +59 -0
- package/dist/lib/browser/chunk-V67SBM4U.mjs.map +7 -0
- package/dist/lib/browser/chunk-YYCPOFRP.mjs +106 -0
- package/dist/lib/browser/chunk-YYCPOFRP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +91 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/intent-resolver-AHP36LHF.mjs +33 -0
- package/dist/lib/browser/intent-resolver-AHP36LHF.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/react-surface-NRTYEQIC.mjs +30 -0
- package/dist/lib/browser/react-surface-NRTYEQIC.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-RNEIWFZQ.mjs +108 -0
- package/dist/lib/node-esm/chunk-RNEIWFZQ.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 +92 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/intent-resolver-HORX66Z6.mjs +34 -0
- package/dist/lib/node-esm/intent-resolver-HORX66Z6.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/react-surface-FUC4ZBPA.mjs +31 -0
- package/dist/lib/node-esm/react-surface-FUC4ZBPA.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 +44 -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 +5 -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/Board.d.ts +88 -0
- package/dist/types/src/types/Board.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/tsconfig.tsbuildinfo +1 -0
- package/package.json +89 -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 +122 -0
- package/src/components/BoardContainer.tsx +89 -0
- package/src/components/index.ts +5 -0
- package/src/index.ts +9 -0
- package/src/meta.ts +15 -0
- package/src/translations.ts +27 -0
- package/src/types/Board.ts +47 -0
- package/src/types/index.ts +5 -0
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dxos/plugin-board",
|
|
3
|
+
"version": "0.8.4-main.1da679c",
|
|
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
|
+
"source": "./src/index.ts",
|
|
14
|
+
"types": "./dist/types/src/index.d.ts",
|
|
15
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
16
|
+
"node": "./dist/lib/node-esm/index.mjs"
|
|
17
|
+
},
|
|
18
|
+
"./types": {
|
|
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"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"types": "dist/types/src/index.d.ts",
|
|
26
|
+
"typesVersions": {
|
|
27
|
+
"*": {
|
|
28
|
+
"types": [
|
|
29
|
+
"dist/types/src/types/index.d.ts"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"src"
|
|
36
|
+
],
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@preact-signals/safe-react": "^0.9.0",
|
|
39
|
+
"@preact/signals-core": "^1.9.0",
|
|
40
|
+
"@preact/signals-react": "^3.2.0",
|
|
41
|
+
"effect": "3.17.7",
|
|
42
|
+
"@dxos/app-framework": "0.8.4-main.1da679c",
|
|
43
|
+
"@dxos/assistant": "0.8.4-main.1da679c",
|
|
44
|
+
"@dxos/async": "0.8.4-main.1da679c",
|
|
45
|
+
"@dxos/blueprints": "0.8.4-main.1da679c",
|
|
46
|
+
"@dxos/ai": "0.8.4-main.1da679c",
|
|
47
|
+
"@dxos/echo": "0.8.4-main.1da679c",
|
|
48
|
+
"@dxos/echo-schema": "0.8.4-main.1da679c",
|
|
49
|
+
"@dxos/effect": "0.8.4-main.1da679c",
|
|
50
|
+
"@dxos/invariant": "0.8.4-main.1da679c",
|
|
51
|
+
"@dxos/client": "0.8.4-main.1da679c",
|
|
52
|
+
"@dxos/log": "0.8.4-main.1da679c",
|
|
53
|
+
"@dxos/plugin-client": "0.8.4-main.1da679c",
|
|
54
|
+
"@dxos/plugin-search": "0.8.4-main.1da679c",
|
|
55
|
+
"@dxos/plugin-graph": "0.8.4-main.1da679c",
|
|
56
|
+
"@dxos/plugin-space": "0.8.4-main.1da679c",
|
|
57
|
+
"@dxos/random": "0.8.4-main.1da679c",
|
|
58
|
+
"@dxos/react-ui": "0.8.4-main.1da679c",
|
|
59
|
+
"@dxos/react-ui-board": "0.8.4-main.1da679c",
|
|
60
|
+
"@dxos/react-ui-form": "0.8.4-main.1da679c",
|
|
61
|
+
"@dxos/react-ui-stack": "0.8.4-main.1da679c",
|
|
62
|
+
"@dxos/schema": "0.8.4-main.1da679c",
|
|
63
|
+
"@dxos/react-client": "0.8.4-main.1da679c",
|
|
64
|
+
"@dxos/util": "0.8.4-main.1da679c"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@types/react": "~18.2.0",
|
|
68
|
+
"@types/react-dom": "~18.2.0",
|
|
69
|
+
"react": "~18.2.0",
|
|
70
|
+
"react-dom": "~18.2.0",
|
|
71
|
+
"vite": "7.1.1",
|
|
72
|
+
"@dxos/plugin-preview": "0.8.4-main.1da679c",
|
|
73
|
+
"@dxos/plugin-theme": "0.8.4-main.1da679c",
|
|
74
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.1da679c",
|
|
75
|
+
"@dxos/react-ui-theme": "0.8.4-main.1da679c",
|
|
76
|
+
"@dxos/test-utils": "0.8.4-main.1da679c",
|
|
77
|
+
"@dxos/storybook-utils": "0.8.4-main.1da679c"
|
|
78
|
+
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"effect": "^3.13.3",
|
|
81
|
+
"react": "~18.2.0",
|
|
82
|
+
"react-dom": "~18.2.0",
|
|
83
|
+
"@dxos/react-ui-theme": "0.8.4-main.1da679c",
|
|
84
|
+
"@dxos/react-ui": "0.8.4-main.1da679c"
|
|
85
|
+
},
|
|
86
|
+
"publishConfig": {
|
|
87
|
+
"access": "public"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Capabilities, Events, contributes, createIntent, defineModule, definePlugin } 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 { Capabilities, type PluginContext, contributes, 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,122 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { 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 { Filter, Ref, useQuery, useSpaces } from '@dxos/react-client/echo';
|
|
20
|
+
import { translations as stackTranslations } from '@dxos/react-ui-stack';
|
|
21
|
+
import { defaultTx } from '@dxos/react-ui-theme';
|
|
22
|
+
import { DataType } from '@dxos/schema';
|
|
23
|
+
import { withLayout } from '@dxos/storybook-utils';
|
|
24
|
+
|
|
25
|
+
import { translations } from '../translations';
|
|
26
|
+
import { Board } from '../types';
|
|
27
|
+
|
|
28
|
+
import { BoardContainer } from './BoardContainer';
|
|
29
|
+
|
|
30
|
+
faker.seed(0);
|
|
31
|
+
|
|
32
|
+
const createBoard = () =>
|
|
33
|
+
Obj.make(Board.Board, {
|
|
34
|
+
name: 'Test Board',
|
|
35
|
+
items: [],
|
|
36
|
+
layout: {
|
|
37
|
+
size: { width: 7, height: 5 },
|
|
38
|
+
cells: {},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const createOrg = () =>
|
|
43
|
+
Obj.make(DataType.Organization, {
|
|
44
|
+
name: faker.commerce.productName(),
|
|
45
|
+
description: faker.lorem.paragraph(),
|
|
46
|
+
image: faker.image.url(),
|
|
47
|
+
website: faker.internet.url(),
|
|
48
|
+
// TODO(burdon): Fix.
|
|
49
|
+
// status: faker.helpers.arrayElement(DataType.OrganizationStatusOptions).id,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const DefaultStory = () => {
|
|
53
|
+
const spaces = useSpaces();
|
|
54
|
+
const space = spaces[spaces.length - 1];
|
|
55
|
+
const boards = useQuery(space, Filter.type(Board.Board));
|
|
56
|
+
const [board, setBoard] = useState<Board.Board>();
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (boards.length && !board) {
|
|
60
|
+
const board = boards[0];
|
|
61
|
+
setBoard(board);
|
|
62
|
+
}
|
|
63
|
+
}, [boards]);
|
|
64
|
+
|
|
65
|
+
if (!board) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return <BoardContainer role='board' board={board} />;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
//
|
|
73
|
+
// Story definitions
|
|
74
|
+
//
|
|
75
|
+
|
|
76
|
+
const meta = {
|
|
77
|
+
title: 'plugins/plugin-board/Board',
|
|
78
|
+
render: DefaultStory,
|
|
79
|
+
parameters: { translations: [...translations, ...stackTranslations] },
|
|
80
|
+
decorators: [
|
|
81
|
+
withLayout({ fullscreen: true }),
|
|
82
|
+
withPluginManager({
|
|
83
|
+
plugins: [
|
|
84
|
+
ThemePlugin({ tx: defaultTx }),
|
|
85
|
+
ClientPlugin({
|
|
86
|
+
types: [DataType.Organization, DataType.Person, Board.Board],
|
|
87
|
+
onClientInitialized: async ({ client }) => {
|
|
88
|
+
await client.halo.createIdentity();
|
|
89
|
+
const space = await client.spaces.create();
|
|
90
|
+
await space.waitUntilReady();
|
|
91
|
+
const board = space.db.add(createBoard());
|
|
92
|
+
|
|
93
|
+
// Add some sample items
|
|
94
|
+
Array.from({ length: 10 }).map(() => {
|
|
95
|
+
const org = createOrg();
|
|
96
|
+
space.db.add(org);
|
|
97
|
+
board.items.push(Ref.make(org));
|
|
98
|
+
board.layout.cells[org.id] = {
|
|
99
|
+
x: Math.floor(Math.random() * 5) - 2,
|
|
100
|
+
y: Math.floor(Math.random() * 5) - 2,
|
|
101
|
+
width: 1,
|
|
102
|
+
height: 1,
|
|
103
|
+
};
|
|
104
|
+
return org;
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
}),
|
|
108
|
+
StorybookLayoutPlugin(),
|
|
109
|
+
PreviewPlugin(),
|
|
110
|
+
SpacePlugin(),
|
|
111
|
+
IntentPlugin(),
|
|
112
|
+
SettingsPlugin(),
|
|
113
|
+
],
|
|
114
|
+
}),
|
|
115
|
+
],
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export default meta;
|
|
119
|
+
|
|
120
|
+
type Story = StoryObj<typeof meta>;
|
|
121
|
+
|
|
122
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback, useRef } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Surface, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
+
import { getSpace } from '@dxos/client/echo';
|
|
9
|
+
import { type Obj, Ref } from '@dxos/echo';
|
|
10
|
+
import { invariant } from '@dxos/invariant';
|
|
11
|
+
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
12
|
+
import { useSignalsMemo } from '@dxos/react-ui';
|
|
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
|
+
import { type Board as BoardType } from '../types';
|
|
18
|
+
|
|
19
|
+
export type BoardContainerProps = {
|
|
20
|
+
role?: string;
|
|
21
|
+
board: BoardType.Board;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const BoardContainer = ({ board }: BoardContainerProps) => {
|
|
25
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
26
|
+
const controller = useRef<BoardController>(null);
|
|
27
|
+
const items = useSignalsMemo(() => board.items.map((ref) => ref.target).filter(isNonNullable), [board]);
|
|
28
|
+
|
|
29
|
+
const handleAdd = useCallback<NonNullable<BoardRootProps['onAdd']>>(
|
|
30
|
+
async (position = { x: 0, y: 0 }) => {
|
|
31
|
+
const space = getSpace(board);
|
|
32
|
+
invariant(space);
|
|
33
|
+
await dispatch(
|
|
34
|
+
createIntent(SpaceAction.OpenCreateObject, {
|
|
35
|
+
target: space,
|
|
36
|
+
navigable: false,
|
|
37
|
+
onCreateObject: (object: Obj.Any) => {
|
|
38
|
+
board.items.push(Ref.make(object));
|
|
39
|
+
console.log(board.items.length);
|
|
40
|
+
board.layout.cells[object.id] = { ...position, width: 1, height: 1 };
|
|
41
|
+
controller.current?.center(position);
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
[board, controller, dispatch],
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// TODO(burdon): Use intents so can be undone.
|
|
50
|
+
const handleDelete = useCallback<NonNullable<BoardRootProps['onDelete']>>(
|
|
51
|
+
(id) => {
|
|
52
|
+
// TODO(burdon): Impl. DXN.equals and pass in DXN from `id`.
|
|
53
|
+
const idx = board.items.findIndex((ref) => ref.dxn.asEchoDXN()?.echoId === id);
|
|
54
|
+
if (idx !== -1) {
|
|
55
|
+
board.items.splice(idx, 1);
|
|
56
|
+
}
|
|
57
|
+
delete board.layout.cells[id];
|
|
58
|
+
},
|
|
59
|
+
[board],
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const handleMove = useCallback<NonNullable<BoardRootProps['onMove']>>(
|
|
63
|
+
(id, position) => {
|
|
64
|
+
const layout = board.layout.cells[id];
|
|
65
|
+
board.layout.cells[id] = { ...layout, ...position };
|
|
66
|
+
},
|
|
67
|
+
[board],
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<Board.Root ref={controller} layout={board.layout} onAdd={handleAdd} onDelete={handleDelete} onMove={handleMove}>
|
|
72
|
+
<StackItem.Content toolbar classNames='overflow-hidden'>
|
|
73
|
+
<Board.Toolbar />
|
|
74
|
+
<Board.Container>
|
|
75
|
+
<Board.Viewport classNames='border-none'>
|
|
76
|
+
<Board.Backdrop />
|
|
77
|
+
<Board.Content>
|
|
78
|
+
{items?.map((item, index) => (
|
|
79
|
+
<Board.Cell item={item} key={index} layout={board.layout?.cells[item.id] ?? { x: 0, y: 0 }}>
|
|
80
|
+
<Surface role='card--extrinsic' data={{ subject: item }} limit={1} />
|
|
81
|
+
</Board.Cell>
|
|
82
|
+
))}
|
|
83
|
+
</Board.Content>
|
|
84
|
+
</Board.Viewport>
|
|
85
|
+
</Board.Container>
|
|
86
|
+
</StackItem.Content>
|
|
87
|
+
</Board.Root>
|
|
88
|
+
);
|
|
89
|
+
};
|
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,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
|
+
}) {}
|