@dxos/plugin-board 0.8.4-main.1da679c → 0.8.4-main.21d9917

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.
Files changed (71) hide show
  1. package/dist/lib/browser/chunk-LBLHKX5C.mjs +36 -0
  2. package/dist/lib/browser/chunk-LBLHKX5C.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-RYF2DAG7.mjs +157 -0
  4. package/dist/lib/browser/chunk-RYF2DAG7.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +34 -57
  6. package/dist/lib/browser/index.mjs.map +4 -4
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/react-surface-E72KQ3A6.mjs +31 -0
  9. package/dist/lib/browser/react-surface-E72KQ3A6.mjs.map +7 -0
  10. package/dist/lib/browser/types/index.mjs +1 -1
  11. package/dist/lib/node-esm/chunk-UK23JIUK.mjs +159 -0
  12. package/dist/lib/node-esm/chunk-UK23JIUK.mjs.map +7 -0
  13. package/dist/lib/node-esm/chunk-VU2JDWBB.mjs +37 -0
  14. package/dist/lib/node-esm/chunk-VU2JDWBB.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +34 -57
  16. package/dist/lib/node-esm/index.mjs.map +4 -4
  17. package/dist/lib/node-esm/meta.json +1 -1
  18. package/dist/lib/node-esm/react-surface-6OXJH5X5.mjs +32 -0
  19. package/dist/lib/node-esm/react-surface-6OXJH5X5.mjs.map +7 -0
  20. package/dist/lib/node-esm/types/index.mjs +1 -1
  21. package/dist/types/src/BoardPlugin.d.ts +2 -1
  22. package/dist/types/src/BoardPlugin.d.ts.map +1 -1
  23. package/dist/types/src/capabilities/index.d.ts +1 -2
  24. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  25. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  26. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  27. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  28. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  29. package/dist/types/src/components/BoardContainer.d.ts +3 -5
  30. package/dist/types/src/components/BoardContainer.d.ts.map +1 -1
  31. package/dist/types/src/components/BoardContainer.stories.d.ts +4 -3
  32. package/dist/types/src/components/BoardContainer.stories.d.ts.map +1 -1
  33. package/dist/types/src/meta.d.ts +2 -2
  34. package/dist/types/src/meta.d.ts.map +1 -1
  35. package/dist/types/src/translations.d.ts +1 -0
  36. package/dist/types/src/translations.d.ts.map +1 -1
  37. package/dist/types/src/types/Board.d.ts +24 -66
  38. package/dist/types/src/types/Board.d.ts.map +1 -1
  39. package/dist/types/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +56 -50
  41. package/src/BoardPlugin.tsx +22 -48
  42. package/src/capabilities/index.ts +1 -4
  43. package/src/capabilities/react-surface/index.ts +7 -0
  44. package/src/capabilities/react-surface/react-surface.tsx +26 -0
  45. package/src/components/BoardContainer.stories.tsx +40 -41
  46. package/src/components/BoardContainer.tsx +109 -50
  47. package/src/meta.ts +8 -4
  48. package/src/translations.ts +1 -0
  49. package/src/types/Board.ts +6 -20
  50. package/dist/lib/browser/chunk-V67SBM4U.mjs +0 -59
  51. package/dist/lib/browser/chunk-V67SBM4U.mjs.map +0 -7
  52. package/dist/lib/browser/chunk-YYCPOFRP.mjs +0 -106
  53. package/dist/lib/browser/chunk-YYCPOFRP.mjs.map +0 -7
  54. package/dist/lib/browser/intent-resolver-AHP36LHF.mjs +0 -33
  55. package/dist/lib/browser/intent-resolver-AHP36LHF.mjs.map +0 -7
  56. package/dist/lib/browser/react-surface-NRTYEQIC.mjs +0 -30
  57. package/dist/lib/browser/react-surface-NRTYEQIC.mjs.map +0 -7
  58. package/dist/lib/node-esm/chunk-RNEIWFZQ.mjs +0 -108
  59. package/dist/lib/node-esm/chunk-RNEIWFZQ.mjs.map +0 -7
  60. package/dist/lib/node-esm/chunk-XCGDC6OV.mjs +0 -60
  61. package/dist/lib/node-esm/chunk-XCGDC6OV.mjs.map +0 -7
  62. package/dist/lib/node-esm/intent-resolver-HORX66Z6.mjs +0 -34
  63. package/dist/lib/node-esm/intent-resolver-HORX66Z6.mjs.map +0 -7
  64. package/dist/lib/node-esm/react-surface-FUC4ZBPA.mjs +0 -31
  65. package/dist/lib/node-esm/react-surface-FUC4ZBPA.mjs.map +0 -7
  66. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  67. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  68. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  69. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  70. package/src/capabilities/intent-resolver.ts +0 -34
  71. 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.1da679c",
3
+ "version": "0.8.4-main.21d9917",
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
- "@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"
42
+ "effect": "3.19.11",
43
+ "@dxos/assistant": "0.8.4-main.21d9917",
44
+ "@dxos/ai": "0.8.4-main.21d9917",
45
+ "@dxos/app-framework": "0.8.4-main.21d9917",
46
+ "@dxos/async": "0.8.4-main.21d9917",
47
+ "@dxos/blueprints": "0.8.4-main.21d9917",
48
+ "@dxos/client": "0.8.4-main.21d9917",
49
+ "@dxos/echo": "0.8.4-main.21d9917",
50
+ "@dxos/echo-react": "0.8.4-main.21d9917",
51
+ "@dxos/invariant": "0.8.4-main.21d9917",
52
+ "@dxos/log": "0.8.4-main.21d9917",
53
+ "@dxos/effect": "0.8.4-main.21d9917",
54
+ "@dxos/operation": "0.8.4-main.21d9917",
55
+ "@dxos/plugin-client": "0.8.4-main.21d9917",
56
+ "@dxos/plugin-graph": "0.8.4-main.21d9917",
57
+ "@dxos/plugin-search": "0.8.4-main.21d9917",
58
+ "@dxos/plugin-space": "0.8.4-main.21d9917",
59
+ "@dxos/random": "0.8.4-main.21d9917",
60
+ "@dxos/react-client": "0.8.4-main.21d9917",
61
+ "@dxos/react-ui": "0.8.4-main.21d9917",
62
+ "@dxos/react-ui-board": "0.8.4-main.21d9917",
63
+ "@dxos/react-ui-attention": "0.8.4-main.21d9917",
64
+ "@dxos/react-ui-form": "0.8.4-main.21d9917",
65
+ "@dxos/react-ui-stack": "0.8.4-main.21d9917",
66
+ "@dxos/react-ui-mosaic": "0.8.4-main.21d9917",
67
+ "@dxos/schema": "0.8.4-main.21d9917",
68
+ "@dxos/types": "0.8.4-main.21d9917",
69
+ "@dxos/util": "0.8.4-main.21d9917"
65
70
  },
66
71
  "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"
72
+ "@types/react": "~19.2.7",
73
+ "@types/react-dom": "~19.2.3",
74
+ "react": "~19.2.3",
75
+ "react-dom": "~19.2.3",
76
+ "vite": "7.1.9",
77
+ "@dxos/plugin-preview": "0.8.4-main.21d9917",
78
+ "@dxos/plugin-theme": "0.8.4-main.21d9917",
79
+ "@dxos/plugin-testing": "0.8.4-main.21d9917",
80
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.21d9917",
81
+ "@dxos/test-utils": "0.8.4-main.21d9917",
82
+ "@dxos/storybook-utils": "0.8.4-main.21d9917",
83
+ "@dxos/ui-theme": "0.8.4-main.21d9917"
78
84
  },
79
85
  "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"
86
+ "effect": "3.19.11",
87
+ "react": "~19.2.3",
88
+ "react-dom": "~19.2.3",
89
+ "@dxos/react-ui": "0.8.4-main.21d9917",
90
+ "@dxos/ui-theme": "0.8.4-main.21d9917"
85
91
  },
86
92
  "publishConfig": {
87
93
  "access": "public"
@@ -2,57 +2,31 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
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';
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 { IntentResolver, ReactSurface } from './capabilities';
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
- 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
- };
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
+ },
28
+ }),
29
+ Common.Plugin.addSchemaModule({ schema: [Board.Board] }),
30
+ Common.Plugin.addSurfaceModule({ activate: ReactSurface }),
31
+ Plugin.make,
32
+ );
@@ -2,7 +2,4 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { lazy } from '@dxos/app-framework';
6
-
7
- export const IntentResolver = lazy(() => import('./intent-resolver'));
8
- export const ReactSurface = lazy(() => import('./react-surface'));
5
+ export * from './react-surface';
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capability } from '@dxos/app-framework';
6
+
7
+ export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -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
+ );
@@ -2,25 +2,20 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
5
  import { type StoryObj } from '@storybook/react-vite';
6
+ import * as Effect from 'effect/Effect';
8
7
  import React, { useEffect, useState } from 'react';
9
8
 
10
- import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
11
9
  import { withPluginManager } from '@dxos/app-framework/testing';
12
10
  import { Obj } from '@dxos/echo';
13
11
  import { ClientPlugin } from '@dxos/plugin-client';
14
12
  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';
13
+ import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
18
14
  import { faker } from '@dxos/random';
19
15
  import { Filter, Ref, useQuery, useSpaces } from '@dxos/react-client/echo';
16
+ import { withTheme } from '@dxos/react-ui/testing';
20
17
  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';
18
+ import { Organization, Person } from '@dxos/types';
24
19
 
25
20
  import { translations } from '../translations';
26
21
  import { Board } from '../types';
@@ -40,19 +35,19 @@ const createBoard = () =>
40
35
  });
41
36
 
42
37
  const createOrg = () =>
43
- Obj.make(DataType.Organization, {
38
+ Obj.make(Organization.Organization, {
44
39
  name: faker.commerce.productName(),
45
40
  description: faker.lorem.paragraph(),
46
41
  image: faker.image.url(),
47
42
  website: faker.internet.url(),
48
43
  // TODO(burdon): Fix.
49
- // status: faker.helpers.arrayElement(DataType.OrganizationStatusOptions).id,
44
+ // status: faker.helpers.arrayElement(Organization.StatusOptions).id,
50
45
  });
51
46
 
52
47
  const DefaultStory = () => {
53
48
  const spaces = useSpaces();
54
49
  const space = spaces[spaces.length - 1];
55
- const boards = useQuery(space, Filter.type(Board.Board));
50
+ const boards = useQuery(space?.db, Filter.type(Board.Board));
56
51
  const [board, setBoard] = useState<Board.Board>();
57
52
 
58
53
  useEffect(() => {
@@ -66,7 +61,7 @@ const DefaultStory = () => {
66
61
  return null;
67
62
  }
68
63
 
69
- return <BoardContainer role='board' board={board} />;
64
+ return <BoardContainer role='board' subject={board} />;
70
65
  };
71
66
 
72
67
  //
@@ -76,43 +71,47 @@ const DefaultStory = () => {
76
71
  const meta = {
77
72
  title: 'plugins/plugin-board/Board',
78
73
  render: DefaultStory,
79
- parameters: { translations: [...translations, ...stackTranslations] },
80
74
  decorators: [
81
- withLayout({ fullscreen: true }),
75
+ withTheme,
82
76
  withPluginManager({
83
77
  plugins: [
84
- ThemePlugin({ tx: defaultTx }),
78
+ ...corePlugins(),
85
79
  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
- },
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
+ }),
107
104
  }),
108
- StorybookLayoutPlugin(),
105
+
106
+ StorybookPlugin({}),
109
107
  PreviewPlugin(),
110
- SpacePlugin(),
111
- IntentPlugin(),
112
- SettingsPlugin(),
113
108
  ],
114
109
  }),
115
110
  ],
111
+ parameters: {
112
+ layout: 'fullscreen',
113
+ translations: [...translations, ...stackTranslations],
114
+ },
116
115
  };
117
116
 
118
117
  export default meta;
@@ -2,48 +2,70 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React, { useCallback, useRef } from 'react';
5
+ import React, { useCallback, useMemo, useRef, useState } from 'react';
6
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';
7
+ import { Surface, type SurfaceComponentProps } from '@dxos/app-framework/react';
8
+ import { Filter, Obj, Ref } from '@dxos/echo';
9
+ import { useObject, useObjects } from '@dxos/echo-react';
10
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';
11
+ import { useQuery } from '@dxos/react-client/echo';
12
+ import { useAttention } from '@dxos/react-ui-attention';
13
+ import { Board, type BoardController, type BoardRootProps, type Position } from '@dxos/react-ui-board';
14
+ import { ObjectPicker, type ObjectPickerContentProps } from '@dxos/react-ui-form';
15
+ import { Layout } from '@dxos/react-ui-mosaic';
15
16
  import { isNonNullable } from '@dxos/util';
16
17
 
17
18
  import { type Board as BoardType } from '../types';
18
19
 
19
- export type BoardContainerProps = {
20
- role?: string;
21
- board: BoardType.Board;
20
+ const DEFAULT_POSITION = { x: 0, y: 0 } satisfies Position;
21
+
22
+ type PickerState = {
23
+ position: Position;
22
24
  };
23
25
 
24
- export const BoardContainer = ({ board }: BoardContainerProps) => {
25
- const { dispatchPromise: dispatch } = useIntentDispatcher();
26
+ export type BoardContainerProps = SurfaceComponentProps<BoardType.Board>;
27
+
28
+ export const BoardContainer = ({ role, subject: board }: BoardContainerProps) => {
26
29
  const controller = useRef<BoardController>(null);
27
- const items = useSignalsMemo(() => board.items.map((ref) => ref.target).filter(isNonNullable), [board]);
30
+ const [boardItems] = useObject(board, 'items');
31
+ const items = useObjects(boardItems ?? []);
32
+ const addTriggerRef = useRef<HTMLButtonElement | null>(null);
33
+ const [pickerState, setPickerState] = useState<PickerState | null>(null);
34
+ const attendableId = Obj.getDXN(board).toString();
35
+ const { hasAttention } = useAttention(attendableId);
36
+
37
+ const db = Obj.getDatabase(board);
38
+ // TODO(burdon): Use search.
39
+ const objects = useQuery(db, Filter.everything());
40
+ const options = useMemo<ObjectPickerContentProps['options']>(
41
+ () =>
42
+ objects
43
+ .filter((obj) => obj.id !== board.id)
44
+ .map((obj) => {
45
+ const label = Obj.getLabel(obj);
46
+ if (label) {
47
+ return {
48
+ id: obj.id,
49
+ label,
50
+ hue: 'neutral' as const,
51
+ };
52
+ }
53
+ })
54
+ .filter(isNonNullable)
55
+ .sort(({ label: a }, { label: b }) => a.toLocaleLowerCase().localeCompare(b.toLocaleLowerCase())),
56
+ [objects],
57
+ );
28
58
 
29
59
  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
- );
60
+ async (anchor, position = DEFAULT_POSITION) => {
61
+ const db = Obj.getDatabase(board);
62
+ invariant(db);
63
+ addTriggerRef.current = anchor;
64
+ setPickerState({
65
+ position,
66
+ });
45
67
  },
46
- [board, controller, dispatch],
68
+ [board],
47
69
  );
48
70
 
49
71
  // TODO(burdon): Use intents so can be undone.
@@ -51,10 +73,12 @@ export const BoardContainer = ({ board }: BoardContainerProps) => {
51
73
  (id) => {
52
74
  // TODO(burdon): Impl. DXN.equals and pass in DXN from `id`.
53
75
  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];
76
+ Obj.change(board, (b) => {
77
+ if (idx !== -1) {
78
+ b.items.splice(idx, 1);
79
+ }
80
+ delete b.layout.cells[id];
81
+ });
58
82
  },
59
83
  [board],
60
84
  );
@@ -62,28 +86,63 @@ export const BoardContainer = ({ board }: BoardContainerProps) => {
62
86
  const handleMove = useCallback<NonNullable<BoardRootProps['onMove']>>(
63
87
  (id, position) => {
64
88
  const layout = board.layout.cells[id];
65
- board.layout.cells[id] = { ...layout, ...position };
89
+ Obj.change(board, (b) => {
90
+ b.layout.cells[id] = { ...layout, ...position };
91
+ });
66
92
  },
67
93
  [board],
68
94
  );
69
95
 
96
+ const handleSelect = useCallback<NonNullable<ObjectPickerContentProps['onSelect']>>(
97
+ (id) => {
98
+ if (!pickerState) {
99
+ return;
100
+ }
101
+
102
+ // Find the selected object by id from the space.
103
+ const selectedObject = objects.find((obj) => obj.id === id);
104
+ if (!Obj.isObject(selectedObject)) {
105
+ return;
106
+ }
107
+
108
+ // Create a reference to the selected object and add it to the board.
109
+ board.items.push(Ref.make(selectedObject));
110
+
111
+ // Set the layout position for the new item.
112
+ board.layout.cells[selectedObject.id.toString()] = pickerState.position;
113
+
114
+ // Close the picker.
115
+ setPickerState(null);
116
+ },
117
+ [pickerState, objects, board],
118
+ );
119
+
70
120
  return (
71
121
  <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>
122
+ <ObjectPicker.Root
123
+ open={!!pickerState}
124
+ onOpenChange={(nextOpen: boolean) => {
125
+ setPickerState(nextOpen ? { position: DEFAULT_POSITION } : null);
126
+ }}
127
+ >
128
+ <Layout.Main role={role} toolbar>
129
+ <Board.Toolbar disabled={!hasAttention} />
130
+ <Board.Container>
131
+ <Board.Viewport classNames='border-none'>
132
+ <Board.Backdrop />
133
+ <Board.Content>
134
+ {items?.map((item, index) => (
135
+ <Board.Cell item={item} key={index} layout={board.layout?.cells[item.id] ?? { x: 0, y: 0 }}>
136
+ <Surface role='card--content' data={{ subject: item }} limit={1} />
137
+ </Board.Cell>
138
+ ))}
139
+ </Board.Content>
140
+ </Board.Viewport>
141
+ </Board.Container>
142
+ </Layout.Main>
143
+ <ObjectPicker.Content options={options} onSelect={handleSelect} classNames='popover-card-width' />
144
+ <ObjectPicker.VirtualTrigger virtualRef={addTriggerRef} />
145
+ </ObjectPicker.Root>
87
146
  </Board.Root>
88
147
  );
89
148
  };
package/src/meta.ts CHANGED
@@ -2,14 +2,18 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type PluginMeta } from '@dxos/app-framework';
5
+ import { type Plugin } from '@dxos/app-framework';
6
+ import { trim } from '@dxos/util';
6
7
 
7
- export const meta: PluginMeta = {
8
+ export const meta: Plugin.Meta = {
8
9
  id: 'dxos.org/plugin/board',
9
10
  name: 'Board',
10
- description:
11
- 'A spatial, infinite canvas app combining notes, media, and whiteboarding in a tactile, visual interface.',
11
+ description: trim`
12
+ Infinite canvas workspace that combines sticky notes, media, and whiteboarding tools.
13
+ Arrange and connect ideas freely in a visual space perfect for brainstorming and creative collaboration.
14
+ `,
12
15
  icon: 'ph--squares-four--regular',
16
+ iconHue: 'green',
13
17
  source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-board',
14
18
  screenshots: [],
15
19
  };
@@ -18,6 +18,7 @@ export const translations = [
18
18
  'object name placeholder': 'New board',
19
19
  'rename object label': 'Rename board',
20
20
  'delete object label': 'Delete board',
21
+ 'object deleted label': 'Board deleted',
21
22
  },
22
23
  [meta.id]: {
23
24
  'plugin name': 'Board',