@dxos/plugin-board 0.8.4-main.c1de068 → 0.8.4-main.c85a9c8dae

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 (99) hide show
  1. package/dist/lib/browser/BoardContainer-QVVN3MXA.mjs +150 -0
  2. package/dist/lib/browser/BoardContainer-QVVN3MXA.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-DX5POLPL.mjs +19 -0
  4. package/dist/lib/browser/chunk-DX5POLPL.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  6. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-KO5FZQGF.mjs +34 -0
  8. package/dist/lib/browser/chunk-KO5FZQGF.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +37 -55
  10. package/dist/lib/browser/index.mjs.map +4 -4
  11. package/dist/lib/browser/meta.json +1 -1
  12. package/dist/lib/browser/react-surface-DBUDXBXD.mjs +38 -0
  13. package/dist/lib/browser/react-surface-DBUDXBXD.mjs.map +7 -0
  14. package/dist/lib/browser/types/index.mjs +4 -3
  15. package/dist/lib/node-esm/BoardContainer-U2P3DS4B.mjs +151 -0
  16. package/dist/lib/node-esm/BoardContainer-U2P3DS4B.mjs.map +7 -0
  17. package/dist/lib/node-esm/chunk-4C3UI73P.mjs +35 -0
  18. package/dist/lib/node-esm/chunk-4C3UI73P.mjs.map +7 -0
  19. package/dist/lib/node-esm/chunk-BKJL6RLQ.mjs +21 -0
  20. package/dist/lib/node-esm/chunk-BKJL6RLQ.mjs.map +7 -0
  21. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  22. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  23. package/dist/lib/node-esm/index.mjs +37 -55
  24. package/dist/lib/node-esm/index.mjs.map +4 -4
  25. package/dist/lib/node-esm/meta.json +1 -1
  26. package/dist/lib/node-esm/react-surface-SFB3GP7U.mjs +39 -0
  27. package/dist/lib/node-esm/react-surface-SFB3GP7U.mjs.map +7 -0
  28. package/dist/lib/node-esm/types/index.mjs +4 -3
  29. package/dist/types/src/BoardPlugin.d.ts +2 -1
  30. package/dist/types/src/BoardPlugin.d.ts.map +1 -1
  31. package/dist/types/src/capabilities/index.d.ts +1 -2
  32. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  33. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  34. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  35. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  36. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  37. package/dist/types/src/components/index.d.ts +0 -1
  38. package/dist/types/src/components/index.d.ts.map +1 -1
  39. package/dist/types/src/containers/BoardContainer/BoardContainer.d.ts +6 -0
  40. package/dist/types/src/containers/BoardContainer/BoardContainer.d.ts.map +1 -0
  41. package/dist/types/src/containers/BoardContainer/BoardContainer.stories.d.ts +45 -0
  42. package/dist/types/src/containers/BoardContainer/BoardContainer.stories.d.ts.map +1 -0
  43. package/dist/types/src/containers/BoardContainer/index.d.ts +3 -0
  44. package/dist/types/src/containers/BoardContainer/index.d.ts.map +1 -0
  45. package/dist/types/src/containers/index.d.ts +3 -0
  46. package/dist/types/src/containers/index.d.ts.map +1 -0
  47. package/dist/types/src/index.d.ts +1 -0
  48. package/dist/types/src/index.d.ts.map +1 -1
  49. package/dist/types/src/meta.d.ts +2 -2
  50. package/dist/types/src/meta.d.ts.map +1 -1
  51. package/dist/types/src/translations.d.ts +1 -0
  52. package/dist/types/src/translations.d.ts.map +1 -1
  53. package/dist/types/src/types/Board.d.ts +46 -0
  54. package/dist/types/src/types/Board.d.ts.map +1 -0
  55. package/dist/types/src/types/index.d.ts +1 -1
  56. package/dist/types/src/types/index.d.ts.map +1 -1
  57. package/dist/types/tsconfig.tsbuildinfo +1 -1
  58. package/package.json +57 -48
  59. package/src/BoardPlugin.tsx +23 -48
  60. package/src/capabilities/index.ts +1 -4
  61. package/src/capabilities/react-surface/index.ts +7 -0
  62. package/src/capabilities/react-surface/react-surface.tsx +27 -0
  63. package/src/components/index.ts +0 -2
  64. package/src/containers/BoardContainer/BoardContainer.stories.tsx +122 -0
  65. package/src/containers/BoardContainer/BoardContainer.tsx +155 -0
  66. package/src/containers/BoardContainer/index.ts +7 -0
  67. package/src/containers/index.ts +7 -0
  68. package/src/index.ts +1 -0
  69. package/src/meta.ts +8 -4
  70. package/src/translations.ts +1 -0
  71. package/src/types/Board.ts +33 -0
  72. package/src/types/index.ts +1 -1
  73. package/dist/lib/browser/chunk-TDV6SJ64.mjs +0 -46
  74. package/dist/lib/browser/chunk-TDV6SJ64.mjs.map +0 -7
  75. package/dist/lib/browser/intent-resolver-TDOZP647.mjs +0 -33
  76. package/dist/lib/browser/intent-resolver-TDOZP647.mjs.map +0 -7
  77. package/dist/lib/browser/react-surface-XFSXU2JJ.mjs +0 -143
  78. package/dist/lib/browser/react-surface-XFSXU2JJ.mjs.map +0 -7
  79. package/dist/lib/node-esm/chunk-K6CHLZYU.mjs +0 -48
  80. package/dist/lib/node-esm/chunk-K6CHLZYU.mjs.map +0 -7
  81. package/dist/lib/node-esm/intent-resolver-IHQWKJNT.mjs +0 -34
  82. package/dist/lib/node-esm/intent-resolver-IHQWKJNT.mjs.map +0 -7
  83. package/dist/lib/node-esm/react-surface-ZHPQBZWO.mjs +0 -144
  84. package/dist/lib/node-esm/react-surface-ZHPQBZWO.mjs.map +0 -7
  85. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  86. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  87. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  88. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  89. package/dist/types/src/components/BoardContainer.d.ts +0 -8
  90. package/dist/types/src/components/BoardContainer.d.ts.map +0 -1
  91. package/dist/types/src/components/BoardContainer.stories.d.ts +0 -8
  92. package/dist/types/src/components/BoardContainer.stories.d.ts.map +0 -1
  93. package/dist/types/src/types/schema.d.ts +0 -65
  94. package/dist/types/src/types/schema.d.ts.map +0 -1
  95. package/src/capabilities/intent-resolver.ts +0 -34
  96. package/src/capabilities/react-surface.tsx +0 -22
  97. package/src/components/BoardContainer.stories.tsx +0 -142
  98. package/src/components/BoardContainer.tsx +0 -104
  99. package/src/types/schema.ts +0 -45
@@ -1,65 +0,0 @@
1
- import { Schema } from 'effect';
2
- import { Type } from '@dxos/echo';
3
- export declare namespace Board {
4
- export const Board: Type.obj<Schema.Struct<{
5
- name: Schema.optional<typeof Schema.String>;
6
- items: Schema.mutable<Schema.Array$<Type.ref<Schema.Schema<Type.Expando, {
7
- [x: string]: any;
8
- id: string;
9
- }, never>>>>;
10
- layout: Schema.mutable<Schema.Struct<{
11
- size: Schema.Struct<{
12
- width: typeof Schema.Number;
13
- height: typeof Schema.Number;
14
- }>;
15
- cells: Schema.mutable<Schema.Record$<typeof Schema.String, Schema.extend<Schema.Struct<{
16
- x: typeof Schema.Number;
17
- y: typeof Schema.Number;
18
- }>, Schema.SchemaClass<{
19
- readonly width?: number | undefined;
20
- readonly height?: number | undefined;
21
- }, {
22
- readonly width?: number | undefined;
23
- readonly height?: number | undefined;
24
- }, never>>>>;
25
- }>>;
26
- }>>;
27
- export interface Board extends Schema.Schema.Type<typeof Board> {
28
- }
29
- const Create_base: Schema.TaggedClass<Create, `${string}/action/create`, {
30
- readonly _tag: Schema.tag<`${string}/action/create`>;
31
- } & {
32
- input: Schema.Struct<{
33
- name: Schema.optional<typeof Schema.String>;
34
- }>;
35
- output: Schema.Struct<{
36
- object: Type.obj<Schema.Struct<{
37
- name: Schema.optional<typeof Schema.String>;
38
- items: Schema.mutable<Schema.Array$<Type.ref<Schema.Schema<Type.Expando, {
39
- [x: string]: any;
40
- id: string;
41
- }, never>>>>;
42
- layout: Schema.mutable<Schema.Struct<{
43
- size: Schema.Struct<{
44
- width: typeof Schema.Number;
45
- height: typeof Schema.Number;
46
- }>;
47
- cells: Schema.mutable<Schema.Record$<typeof Schema.String, Schema.extend<Schema.Struct<{
48
- x: typeof Schema.Number;
49
- y: typeof Schema.Number;
50
- }>, Schema.SchemaClass<{
51
- readonly width?: number | undefined;
52
- readonly height?: number | undefined;
53
- }, {
54
- readonly width?: number | undefined;
55
- readonly height?: number | undefined;
56
- }, never>>>>;
57
- }>>;
58
- }>>;
59
- }>;
60
- }>;
61
- export class Create extends Create_base {
62
- }
63
- export {};
64
- }
65
- //# sourceMappingURL=schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/types/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAMlC,yBAAiB,KAAK,CAAC;IAMrB,MAAM,CAAC,MAAM,KAAK;;;;;;;;;;;;;;;8BA2BuL,CAAC;+BAA6C,CAAC;;8BAAqD,CAAC;+BAA6C,CAAC;;;OAjB3V,CAAC;IAEF,MAAM,WAAW,KAAM,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,KAAK,CAAC;KAAG;;;;;;;;;;;;;;;;;;;;;;;sCAeuI,CAAC;uCAA6C,CAAC;;sCAAqD,CAAC;uCAA6C,CAAC;;;;;;IAT5V,MAAM,OAAO,MAAO,SAAQ,WAO1B;KAAG;;CACN"}
@@ -1,34 +0,0 @@
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
- ];
@@ -1,22 +0,0 @@
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
- ]);
@@ -1,142 +0,0 @@
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 = {};
@@ -1,104 +0,0 @@
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
- };
@@ -1,45 +0,0 @@
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
- }