@dxos/plugin-board 0.8.4-main.ae835ea → 0.8.4-main.bc674ce
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/chunk-2XGWSTZV.mjs +159 -0
- package/dist/lib/browser/chunk-2XGWSTZV.mjs.map +7 -0
- package/dist/lib/browser/chunk-7VKDDGS7.mjs +36 -0
- package/dist/lib/browser/chunk-7VKDDGS7.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +34 -56
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-BEYXCLXI.mjs +31 -0
- package/dist/lib/browser/react-surface-BEYXCLXI.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/chunk-JKPYRS2Z.mjs +161 -0
- package/dist/lib/node-esm/chunk-JKPYRS2Z.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UGVRNKWV.mjs +37 -0
- package/dist/lib/node-esm/chunk-UGVRNKWV.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +34 -56
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-ZFKFUBJM.mjs +32 -0
- package/dist/lib/node-esm/react-surface-ZFKFUBJM.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/BoardPlugin.d.ts +2 -1
- package/dist/types/src/BoardPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/BoardContainer.d.ts +3 -5
- package/dist/types/src/components/BoardContainer.d.ts.map +1 -1
- package/dist/types/src/components/BoardContainer.stories.d.ts +3 -3
- package/dist/types/src/components/BoardContainer.stories.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Board.d.ts +25 -67
- package/dist/types/src/types/Board.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +55 -49
- package/src/BoardPlugin.tsx +21 -46
- package/src/capabilities/index.ts +1 -4
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +26 -0
- package/src/components/BoardContainer.stories.tsx +33 -37
- package/src/components/BoardContainer.tsx +35 -32
- package/src/meta.ts +2 -2
- package/src/translations.ts +1 -0
- package/src/types/Board.ts +4 -18
- package/dist/lib/browser/chunk-6IYOP7JD.mjs +0 -64
- package/dist/lib/browser/chunk-6IYOP7JD.mjs.map +0 -7
- package/dist/lib/browser/chunk-IDV4P2SK.mjs +0 -143
- package/dist/lib/browser/chunk-IDV4P2SK.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-MGJCQT3N.mjs +0 -33
- package/dist/lib/browser/intent-resolver-MGJCQT3N.mjs.map +0 -7
- package/dist/lib/browser/react-surface-EACRLTVO.mjs +0 -30
- package/dist/lib/browser/react-surface-EACRLTVO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WFLKZNL3.mjs +0 -65
- package/dist/lib/node-esm/chunk-WFLKZNL3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZNNC2VAL.mjs +0 -145
- package/dist/lib/node-esm/chunk-ZNNC2VAL.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-TV2AARM7.mjs +0 -34
- package/dist/lib/node-esm/intent-resolver-TV2AARM7.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-PEYOXLWP.mjs +0 -31
- package/dist/lib/node-esm/react-surface-PEYOXLWP.mjs.map +0 -7
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -34
- package/src/capabilities/react-surface.tsx +0 -22
package/package.json
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-board",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.bc674ce",
|
|
4
4
|
"description": "Surface plugin for card baords",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
13
|
"sideEffects": true,
|
|
10
14
|
"type": "module",
|
|
11
15
|
"exports": {
|
|
12
16
|
".": {
|
|
13
|
-
"source": "./src/index.ts",
|
|
14
|
-
"types": "./dist/types/src/index.d.ts",
|
|
15
17
|
"browser": "./dist/lib/browser/index.mjs",
|
|
16
|
-
"node": "./dist/lib/node-esm/index.mjs"
|
|
18
|
+
"node": "./dist/lib/node-esm/index.mjs",
|
|
19
|
+
"source": "./src/index.ts",
|
|
20
|
+
"types": "./dist/types/src/index.d.ts"
|
|
17
21
|
},
|
|
18
22
|
"./types": {
|
|
19
|
-
"source": "./src/types/index.ts",
|
|
20
|
-
"types": "./dist/types/src/types/index.d.ts",
|
|
21
23
|
"browser": "./dist/lib/browser/types/index.mjs",
|
|
22
|
-
"node": "./dist/lib/node-esm/types/index.mjs"
|
|
24
|
+
"node": "./dist/lib/node-esm/types/index.mjs",
|
|
25
|
+
"source": "./src/types/index.ts",
|
|
26
|
+
"types": "./dist/types/src/types/index.d.ts"
|
|
23
27
|
}
|
|
24
28
|
},
|
|
25
29
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -35,53 +39,55 @@
|
|
|
35
39
|
"src"
|
|
36
40
|
],
|
|
37
41
|
"dependencies": {
|
|
38
|
-
"
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/plugin-
|
|
53
|
-
"@dxos/plugin-
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/random": "0.8.4-main.
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/react-
|
|
58
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
59
|
-
"@dxos/react-ui-
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/react-ui-
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/
|
|
42
|
+
"effect": "3.19.11",
|
|
43
|
+
"@dxos/ai": "0.8.4-main.bc674ce",
|
|
44
|
+
"@dxos/app-framework": "0.8.4-main.bc674ce",
|
|
45
|
+
"@dxos/async": "0.8.4-main.bc674ce",
|
|
46
|
+
"@dxos/assistant": "0.8.4-main.bc674ce",
|
|
47
|
+
"@dxos/blueprints": "0.8.4-main.bc674ce",
|
|
48
|
+
"@dxos/client": "0.8.4-main.bc674ce",
|
|
49
|
+
"@dxos/echo": "0.8.4-main.bc674ce",
|
|
50
|
+
"@dxos/effect": "0.8.4-main.bc674ce",
|
|
51
|
+
"@dxos/echo-react": "0.8.4-main.bc674ce",
|
|
52
|
+
"@dxos/invariant": "0.8.4-main.bc674ce",
|
|
53
|
+
"@dxos/log": "0.8.4-main.bc674ce",
|
|
54
|
+
"@dxos/operation": "0.8.4-main.bc674ce",
|
|
55
|
+
"@dxos/plugin-search": "0.8.4-main.bc674ce",
|
|
56
|
+
"@dxos/plugin-space": "0.8.4-main.bc674ce",
|
|
57
|
+
"@dxos/plugin-client": "0.8.4-main.bc674ce",
|
|
58
|
+
"@dxos/react-client": "0.8.4-main.bc674ce",
|
|
59
|
+
"@dxos/random": "0.8.4-main.bc674ce",
|
|
60
|
+
"@dxos/react-ui": "0.8.4-main.bc674ce",
|
|
61
|
+
"@dxos/react-ui-board": "0.8.4-main.bc674ce",
|
|
62
|
+
"@dxos/react-ui-attention": "0.8.4-main.bc674ce",
|
|
63
|
+
"@dxos/react-ui-form": "0.8.4-main.bc674ce",
|
|
64
|
+
"@dxos/plugin-graph": "0.8.4-main.bc674ce",
|
|
65
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.bc674ce",
|
|
66
|
+
"@dxos/schema": "0.8.4-main.bc674ce",
|
|
67
|
+
"@dxos/react-ui-stack": "0.8.4-main.bc674ce",
|
|
68
|
+
"@dxos/types": "0.8.4-main.bc674ce",
|
|
69
|
+
"@dxos/util": "0.8.4-main.bc674ce"
|
|
65
70
|
},
|
|
66
71
|
"devDependencies": {
|
|
67
|
-
"@types/react": "~19.2.
|
|
68
|
-
"@types/react-dom": "~19.2.
|
|
69
|
-
"react": "~19.2.
|
|
70
|
-
"react-dom": "~19.2.
|
|
72
|
+
"@types/react": "~19.2.7",
|
|
73
|
+
"@types/react-dom": "~19.2.3",
|
|
74
|
+
"react": "~19.2.3",
|
|
75
|
+
"react-dom": "~19.2.3",
|
|
71
76
|
"vite": "7.1.9",
|
|
72
|
-
"@dxos/plugin-
|
|
73
|
-
"@dxos/plugin-
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/react-ui-
|
|
76
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
77
|
-
"@dxos/
|
|
77
|
+
"@dxos/plugin-testing": "0.8.4-main.bc674ce",
|
|
78
|
+
"@dxos/plugin-preview": "0.8.4-main.bc674ce",
|
|
79
|
+
"@dxos/plugin-theme": "0.8.4-main.bc674ce",
|
|
80
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.bc674ce",
|
|
81
|
+
"@dxos/storybook-utils": "0.8.4-main.bc674ce",
|
|
82
|
+
"@dxos/ui-theme": "0.8.4-main.bc674ce",
|
|
83
|
+
"@dxos/test-utils": "0.8.4-main.bc674ce"
|
|
78
84
|
},
|
|
79
85
|
"peerDependencies": {
|
|
80
|
-
"effect": "
|
|
81
|
-
"react": "
|
|
82
|
-
"react-dom": "
|
|
83
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
84
|
-
"@dxos/
|
|
86
|
+
"effect": "3.19.11",
|
|
87
|
+
"react": "~19.2.3",
|
|
88
|
+
"react-dom": "~19.2.3",
|
|
89
|
+
"@dxos/react-ui": "0.8.4-main.bc674ce",
|
|
90
|
+
"@dxos/ui-theme": "0.8.4-main.bc674ce"
|
|
85
91
|
},
|
|
86
92
|
"publishConfig": {
|
|
87
93
|
"access": "public"
|
package/src/BoardPlugin.tsx
CHANGED
|
@@ -2,56 +2,31 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Common, Plugin } from '@dxos/app-framework';
|
|
8
|
+
import { type CreateObject } from '@dxos/plugin-space/types';
|
|
9
9
|
import { translations as boardTranslations } from '@dxos/react-ui-board';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { ReactSurface } from './capabilities';
|
|
12
12
|
import { meta } from './meta';
|
|
13
13
|
import { translations } from './translations';
|
|
14
14
|
import { Board } from './types';
|
|
15
15
|
|
|
16
|
-
export const BoardPlugin =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
id: Board.Board.typename,
|
|
29
|
-
metadata: {
|
|
30
|
-
icon: 'ph--squares-four--regular',
|
|
31
|
-
iconHue: 'green',
|
|
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,
|
|
16
|
+
export const BoardPlugin = Plugin.define(meta).pipe(
|
|
17
|
+
Common.Plugin.addTranslationsModule({ translations: [...translations, ...boardTranslations] }),
|
|
18
|
+
Common.Plugin.addMetadataModule({
|
|
19
|
+
metadata: {
|
|
20
|
+
id: Board.Board.typename,
|
|
21
|
+
metadata: {
|
|
22
|
+
icon: 'ph--squares-four--regular',
|
|
23
|
+
iconHue: 'green',
|
|
24
|
+
createObject: ((props) => Effect.sync(() => Board.makeBoard(props))) satisfies CreateObject,
|
|
25
|
+
addToCollectionOnCreate: true,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
56
28
|
}),
|
|
57
|
-
])
|
|
29
|
+
Common.Plugin.addSchemaModule({ schema: [Board.Board] }),
|
|
30
|
+
Common.Plugin.addSurfaceModule({ activate: ReactSurface }),
|
|
31
|
+
Plugin.make,
|
|
32
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { Capability, Common } from '@dxos/app-framework';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
|
|
11
|
+
import { BoardContainer } from '../../components';
|
|
12
|
+
import { meta } from '../../meta';
|
|
13
|
+
import { Board } from '../../types';
|
|
14
|
+
|
|
15
|
+
export default Capability.makeModule(() =>
|
|
16
|
+
Effect.succeed(
|
|
17
|
+
Capability.contributes(Common.Capability.ReactSurface, [
|
|
18
|
+
Common.createSurface({
|
|
19
|
+
id: meta.id,
|
|
20
|
+
role: ['article', 'section'],
|
|
21
|
+
filter: (data): data is { subject: Board.Board } => Obj.instanceOf(Board.Board, data.subject),
|
|
22
|
+
component: ({ role, data }) => <BoardContainer role={role} subject={data.subject} />,
|
|
23
|
+
}),
|
|
24
|
+
]),
|
|
25
|
+
),
|
|
26
|
+
);
|
|
@@ -3,22 +3,19 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
6
7
|
import React, { useEffect, useState } from 'react';
|
|
7
8
|
|
|
8
|
-
import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
|
|
9
9
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
10
|
import { Obj } from '@dxos/echo';
|
|
11
11
|
import { ClientPlugin } from '@dxos/plugin-client';
|
|
12
12
|
import { PreviewPlugin } from '@dxos/plugin-preview';
|
|
13
|
-
import {
|
|
14
|
-
import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
|
|
15
|
-
import { ThemePlugin } from '@dxos/plugin-theme';
|
|
13
|
+
import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
|
|
16
14
|
import { faker } from '@dxos/random';
|
|
17
15
|
import { Filter, Ref, useQuery, useSpaces } from '@dxos/react-client/echo';
|
|
18
16
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
19
17
|
import { translations as stackTranslations } from '@dxos/react-ui-stack';
|
|
20
|
-
import {
|
|
21
|
-
import { DataType } from '@dxos/schema';
|
|
18
|
+
import { Organization, Person } from '@dxos/types';
|
|
22
19
|
|
|
23
20
|
import { translations } from '../translations';
|
|
24
21
|
import { Board } from '../types';
|
|
@@ -38,19 +35,19 @@ const createBoard = () =>
|
|
|
38
35
|
});
|
|
39
36
|
|
|
40
37
|
const createOrg = () =>
|
|
41
|
-
Obj.make(
|
|
38
|
+
Obj.make(Organization.Organization, {
|
|
42
39
|
name: faker.commerce.productName(),
|
|
43
40
|
description: faker.lorem.paragraph(),
|
|
44
41
|
image: faker.image.url(),
|
|
45
42
|
website: faker.internet.url(),
|
|
46
43
|
// TODO(burdon): Fix.
|
|
47
|
-
// status: faker.helpers.arrayElement(
|
|
44
|
+
// status: faker.helpers.arrayElement(Organization.StatusOptions).id,
|
|
48
45
|
});
|
|
49
46
|
|
|
50
47
|
const DefaultStory = () => {
|
|
51
48
|
const spaces = useSpaces();
|
|
52
49
|
const space = spaces[spaces.length - 1];
|
|
53
|
-
const boards = useQuery(space, Filter.type(Board.Board));
|
|
50
|
+
const boards = useQuery(space?.db, Filter.type(Board.Board));
|
|
54
51
|
const [board, setBoard] = useState<Board.Board>();
|
|
55
52
|
|
|
56
53
|
useEffect(() => {
|
|
@@ -64,7 +61,7 @@ const DefaultStory = () => {
|
|
|
64
61
|
return null;
|
|
65
62
|
}
|
|
66
63
|
|
|
67
|
-
return <BoardContainer role='board'
|
|
64
|
+
return <BoardContainer role='board' subject={board} />;
|
|
68
65
|
};
|
|
69
66
|
|
|
70
67
|
//
|
|
@@ -78,37 +75,36 @@ const meta = {
|
|
|
78
75
|
withTheme,
|
|
79
76
|
withPluginManager({
|
|
80
77
|
plugins: [
|
|
78
|
+
...corePlugins(),
|
|
81
79
|
ClientPlugin({
|
|
82
|
-
types: [
|
|
83
|
-
onClientInitialized:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
80
|
+
types: [Organization.Organization, Person.Person, Board.Board],
|
|
81
|
+
onClientInitialized: ({ client }) =>
|
|
82
|
+
Effect.gen(function* () {
|
|
83
|
+
yield* Effect.promise(() => client.halo.createIdentity());
|
|
84
|
+
const space = yield* Effect.promise(() => client.spaces.create());
|
|
85
|
+
yield* Effect.promise(() => space.waitUntilReady());
|
|
86
|
+
const board = space.db.add(createBoard());
|
|
87
|
+
|
|
88
|
+
Obj.change(board, (b) => {
|
|
89
|
+
// Add some sample items
|
|
90
|
+
Array.from({ length: 10 }).map(() => {
|
|
91
|
+
const org = createOrg();
|
|
92
|
+
space.db.add(org);
|
|
93
|
+
b.items.push(Ref.make(org));
|
|
94
|
+
b.layout.cells[org.id] = {
|
|
95
|
+
x: Math.floor(Math.random() * 5) - 2,
|
|
96
|
+
y: Math.floor(Math.random() * 5) - 2,
|
|
97
|
+
width: 1,
|
|
98
|
+
height: 1,
|
|
99
|
+
};
|
|
100
|
+
return org;
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}),
|
|
103
104
|
}),
|
|
104
|
-
SpacePlugin({}),
|
|
105
|
-
IntentPlugin(),
|
|
106
|
-
SettingsPlugin(),
|
|
107
105
|
|
|
108
|
-
|
|
109
|
-
ThemePlugin({ tx: defaultTx }),
|
|
106
|
+
StorybookPlugin({}),
|
|
110
107
|
PreviewPlugin(),
|
|
111
|
-
StorybookLayoutPlugin({}),
|
|
112
108
|
],
|
|
113
109
|
}),
|
|
114
110
|
],
|
|
@@ -4,17 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Surface } from '@dxos/app-framework';
|
|
8
|
-
import { getSpace } from '@dxos/client/echo';
|
|
7
|
+
import { Surface, type SurfaceComponentProps } from '@dxos/app-framework/react';
|
|
9
8
|
import { Filter, Obj, Ref } from '@dxos/echo';
|
|
9
|
+
import { useObject, useObjects } from '@dxos/echo-react';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
11
|
import { useQuery } from '@dxos/react-client/echo';
|
|
12
|
-
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
13
|
-
import { useSignalsMemo } from '@dxos/react-ui';
|
|
14
12
|
import { useAttention } from '@dxos/react-ui-attention';
|
|
15
13
|
import { Board, type BoardController, type BoardRootProps, type Position } from '@dxos/react-ui-board';
|
|
16
14
|
import { ObjectPicker, type ObjectPickerContentProps } from '@dxos/react-ui-form';
|
|
17
|
-
import {
|
|
15
|
+
import { Layout } from '@dxos/react-ui-mosaic';
|
|
18
16
|
import { isNonNullable } from '@dxos/util';
|
|
19
17
|
|
|
20
18
|
import { type Board as BoardType } from '../types';
|
|
@@ -25,22 +23,21 @@ type PickerState = {
|
|
|
25
23
|
position: Position;
|
|
26
24
|
};
|
|
27
25
|
|
|
28
|
-
export type BoardContainerProps =
|
|
29
|
-
role?: string;
|
|
30
|
-
board: BoardType.Board;
|
|
31
|
-
};
|
|
26
|
+
export type BoardContainerProps = SurfaceComponentProps<BoardType.Board>;
|
|
32
27
|
|
|
33
|
-
export const BoardContainer = ({ board }: BoardContainerProps) => {
|
|
28
|
+
export const BoardContainer = ({ role, subject: board }: BoardContainerProps) => {
|
|
34
29
|
const controller = useRef<BoardController>(null);
|
|
35
|
-
const
|
|
30
|
+
const [boardItems] = useObject(board, 'items');
|
|
31
|
+
const items = useObjects(boardItems ?? []);
|
|
36
32
|
const addTriggerRef = useRef<HTMLButtonElement | null>(null);
|
|
37
33
|
const [pickerState, setPickerState] = useState<PickerState | null>(null);
|
|
38
|
-
const attendableId =
|
|
34
|
+
const attendableId = Obj.getDXN(board).toString();
|
|
39
35
|
const { hasAttention } = useAttention(attendableId);
|
|
40
36
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
37
|
+
const db = Obj.getDatabase(board);
|
|
38
|
+
// TODO(burdon): Use search.
|
|
39
|
+
const objects = useQuery(db, Filter.everything());
|
|
40
|
+
const options = useMemo<ObjectPickerContentProps['options']>(
|
|
44
41
|
() =>
|
|
45
42
|
objects
|
|
46
43
|
.filter((obj) => obj.id !== board.id)
|
|
@@ -50,18 +47,19 @@ export const BoardContainer = ({ board }: BoardContainerProps) => {
|
|
|
50
47
|
return {
|
|
51
48
|
id: obj.id,
|
|
52
49
|
label,
|
|
53
|
-
|
|
50
|
+
hue: 'neutral' as const,
|
|
54
51
|
};
|
|
55
52
|
}
|
|
56
53
|
})
|
|
57
|
-
.filter(isNonNullable)
|
|
54
|
+
.filter(isNonNullable)
|
|
55
|
+
.sort(({ label: a }, { label: b }) => a.toLocaleLowerCase().localeCompare(b.toLocaleLowerCase())),
|
|
58
56
|
[objects],
|
|
59
57
|
);
|
|
60
58
|
|
|
61
59
|
const handleAdd = useCallback<NonNullable<BoardRootProps['onAdd']>>(
|
|
62
60
|
async (anchor, position = DEFAULT_POSITION) => {
|
|
63
|
-
const
|
|
64
|
-
invariant(
|
|
61
|
+
const db = Obj.getDatabase(board);
|
|
62
|
+
invariant(db);
|
|
65
63
|
addTriggerRef.current = anchor;
|
|
66
64
|
setPickerState({
|
|
67
65
|
position,
|
|
@@ -75,10 +73,12 @@ export const BoardContainer = ({ board }: BoardContainerProps) => {
|
|
|
75
73
|
(id) => {
|
|
76
74
|
// TODO(burdon): Impl. DXN.equals and pass in DXN from `id`.
|
|
77
75
|
const idx = board.items.findIndex((ref) => ref.dxn.asEchoDXN()?.echoId === id);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
Obj.change(board, (b) => {
|
|
77
|
+
if (idx !== -1) {
|
|
78
|
+
b.items.splice(idx, 1);
|
|
79
|
+
}
|
|
80
|
+
delete b.layout.cells[id];
|
|
81
|
+
});
|
|
82
82
|
},
|
|
83
83
|
[board],
|
|
84
84
|
);
|
|
@@ -86,7 +86,9 @@ export const BoardContainer = ({ board }: BoardContainerProps) => {
|
|
|
86
86
|
const handleMove = useCallback<NonNullable<BoardRootProps['onMove']>>(
|
|
87
87
|
(id, position) => {
|
|
88
88
|
const layout = board.layout.cells[id];
|
|
89
|
-
board
|
|
89
|
+
Obj.change(board, (b) => {
|
|
90
|
+
b.layout.cells[id] = { ...layout, ...position };
|
|
91
|
+
});
|
|
90
92
|
},
|
|
91
93
|
[board],
|
|
92
94
|
);
|
|
@@ -99,15 +101,17 @@ export const BoardContainer = ({ board }: BoardContainerProps) => {
|
|
|
99
101
|
|
|
100
102
|
// Find the selected object by id from the space.
|
|
101
103
|
const selectedObject = objects.find((obj) => obj.id === id);
|
|
102
|
-
if (!selectedObject) {
|
|
104
|
+
if (!Obj.isObject(selectedObject)) {
|
|
103
105
|
return;
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
// Create a reference to the selected object and add it to the board.
|
|
107
|
-
|
|
109
|
+
Obj.change(board, (b) => {
|
|
110
|
+
b.items.push(Ref.make(selectedObject));
|
|
108
111
|
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
// Set the layout position for the new item.
|
|
113
|
+
b.layout.cells[selectedObject.id.toString()] = pickerState.position;
|
|
114
|
+
});
|
|
111
115
|
|
|
112
116
|
// Close the picker.
|
|
113
117
|
setPickerState(null);
|
|
@@ -123,7 +127,7 @@ export const BoardContainer = ({ board }: BoardContainerProps) => {
|
|
|
123
127
|
setPickerState(nextOpen ? { position: DEFAULT_POSITION } : null);
|
|
124
128
|
}}
|
|
125
129
|
>
|
|
126
|
-
<
|
|
130
|
+
<Layout.Main role={role} toolbar>
|
|
127
131
|
<Board.Toolbar disabled={!hasAttention} />
|
|
128
132
|
<Board.Container>
|
|
129
133
|
<Board.Viewport classNames='border-none'>
|
|
@@ -131,14 +135,13 @@ export const BoardContainer = ({ board }: BoardContainerProps) => {
|
|
|
131
135
|
<Board.Content>
|
|
132
136
|
{items?.map((item, index) => (
|
|
133
137
|
<Board.Cell item={item} key={index} layout={board.layout?.cells[item.id] ?? { x: 0, y: 0 }}>
|
|
134
|
-
<Surface role='card--
|
|
138
|
+
<Surface role='card--content' data={{ subject: item }} limit={1} />
|
|
135
139
|
</Board.Cell>
|
|
136
140
|
))}
|
|
137
141
|
</Board.Content>
|
|
138
142
|
</Board.Viewport>
|
|
139
143
|
</Board.Container>
|
|
140
|
-
</
|
|
141
|
-
{/* TODO(burdon): Currently clipped by sidebar. */}
|
|
144
|
+
</Layout.Main>
|
|
142
145
|
<ObjectPicker.Content options={options} onSelect={handleSelect} classNames='popover-card-width' />
|
|
143
146
|
<ObjectPicker.VirtualTrigger virtualRef={addTriggerRef} />
|
|
144
147
|
</ObjectPicker.Root>
|
package/src/meta.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
|
-
export const meta:
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
9
|
id: 'dxos.org/plugin/board',
|
|
10
10
|
name: 'Board',
|
|
11
11
|
description: trim`
|
package/src/translations.ts
CHANGED
package/src/types/Board.ts
CHANGED
|
@@ -5,20 +5,18 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
7
|
import { Obj, Type } from '@dxos/echo';
|
|
8
|
-
import {
|
|
8
|
+
import { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';
|
|
9
9
|
import { BoardLayout, defaultLayout } from '@dxos/react-ui-board';
|
|
10
10
|
|
|
11
|
-
import { meta } from '../meta';
|
|
12
|
-
|
|
13
11
|
/**
|
|
14
12
|
* Board and layout.
|
|
15
13
|
*/
|
|
16
14
|
export const Board = Schema.Struct({
|
|
17
15
|
name: Schema.String.pipe(Schema.optional),
|
|
18
|
-
items: Type.Ref(Type.
|
|
19
|
-
layout: BoardLayout.pipe(
|
|
16
|
+
items: Type.Ref(Type.Obj).pipe(Schema.Array, FormInputAnnotation.set(false)),
|
|
17
|
+
layout: BoardLayout.pipe(FormInputAnnotation.set(false)),
|
|
20
18
|
}).pipe(
|
|
21
|
-
Type.
|
|
19
|
+
Type.object({
|
|
22
20
|
typename: 'dxos.org/type/Board',
|
|
23
21
|
version: '0.1.0',
|
|
24
22
|
}),
|
|
@@ -33,15 +31,3 @@ export const makeBoard = (props: Partial<Obj.MakeProps<typeof Board>> = {}) =>
|
|
|
33
31
|
layout: defaultLayout,
|
|
34
32
|
...props,
|
|
35
33
|
});
|
|
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
|
-
}) {}
|