@dxos/plugin-board 0.8.4-main.f9ba587 → 0.8.4-main.fcfe5033a5
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-FL67SBF5.mjs +39 -0
- package/dist/lib/browser/chunk-FL67SBF5.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +70 -62
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +3 -3
- package/dist/lib/node-esm/chunk-5GGKJL4Z.mjs +40 -0
- package/dist/lib/node-esm/chunk-5GGKJL4Z.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +70 -62
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +3 -3
- 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 +2 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/BoardContainer/BoardContainer.d.ts +6 -0
- package/dist/types/src/containers/BoardContainer/BoardContainer.d.ts.map +1 -0
- package/dist/types/src/containers/BoardContainer/BoardContainer.stories.d.ts +47 -0
- package/dist/types/src/containers/BoardContainer/BoardContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/BoardContainer/index.d.ts +2 -0
- package/dist/types/src/containers/BoardContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.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 +12 -8
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Board.d.ts +46 -0
- package/dist/types/src/types/Board.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +66 -50
- package/src/BoardPlugin.tsx +38 -50
- package/src/capabilities/index.ts +2 -3
- package/src/capabilities/react-surface.tsx +23 -14
- package/src/components/index.ts +0 -2
- package/src/containers/BoardContainer/BoardContainer.stories.tsx +122 -0
- package/src/containers/BoardContainer/BoardContainer.tsx +154 -0
- package/src/containers/BoardContainer/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/index.ts +1 -0
- package/src/meta.ts +9 -5
- package/src/translations.ts +12 -8
- package/src/types/Board.ts +37 -0
- package/src/types/index.ts +1 -1
- package/dist/lib/browser/chunk-TDV6SJ64.mjs +0 -46
- package/dist/lib/browser/chunk-TDV6SJ64.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-TDOZP647.mjs +0 -33
- package/dist/lib/browser/intent-resolver-TDOZP647.mjs.map +0 -7
- package/dist/lib/browser/react-surface-SHXN2B3I.mjs +0 -125
- package/dist/lib/browser/react-surface-SHXN2B3I.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-K6CHLZYU.mjs +0 -48
- package/dist/lib/node-esm/chunk-K6CHLZYU.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-IHQWKJNT.mjs +0 -34
- package/dist/lib/node-esm/intent-resolver-IHQWKJNT.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-DGFWUKUE.mjs +0 -126
- package/dist/lib/node-esm/react-surface-DGFWUKUE.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/components/BoardContainer.d.ts +0 -8
- package/dist/types/src/components/BoardContainer.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -65
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -34
- package/src/components/BoardContainer.tsx +0 -94
- package/src/types/schema.ts +0 -45
package/src/translations.ts
CHANGED
|
@@ -4,21 +4,25 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
|
-
import { meta } from '
|
|
8
|
-
import { Board } from '
|
|
7
|
+
import { meta } from '#meta';
|
|
8
|
+
import { Board } from '#types';
|
|
9
9
|
|
|
10
10
|
export const translations = [
|
|
11
11
|
{
|
|
12
12
|
'en-US': {
|
|
13
13
|
[Board.Board.typename]: {
|
|
14
|
-
'typename
|
|
15
|
-
'typename
|
|
16
|
-
'typename
|
|
17
|
-
'typename
|
|
18
|
-
'object
|
|
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
|
+
'add-object.label': 'Add board',
|
|
20
|
+
'rename-object.label': 'Rename board',
|
|
21
|
+
'delete-object.label': 'Delete board',
|
|
22
|
+
'object-deleted.label': 'Board deleted',
|
|
19
23
|
},
|
|
20
24
|
[meta.id]: {
|
|
21
|
-
'plugin
|
|
25
|
+
'plugin.name': 'Board',
|
|
22
26
|
},
|
|
23
27
|
},
|
|
24
28
|
},
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { Annotation, Obj, Ref, Type } from '@dxos/echo';
|
|
8
|
+
import { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';
|
|
9
|
+
import { BoardLayout, defaultLayout } from '@dxos/react-ui-board';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Board and layout.
|
|
13
|
+
*/
|
|
14
|
+
export const Board = Schema.Struct({
|
|
15
|
+
name: Schema.String.pipe(Schema.optional),
|
|
16
|
+
items: Ref.Ref(Obj.Unknown).pipe(Schema.Array, FormInputAnnotation.set(false)),
|
|
17
|
+
layout: BoardLayout.pipe(FormInputAnnotation.set(false)),
|
|
18
|
+
}).pipe(
|
|
19
|
+
Type.object({
|
|
20
|
+
typename: 'org.dxos.type.board',
|
|
21
|
+
version: '0.1.0',
|
|
22
|
+
}),
|
|
23
|
+
LabelAnnotation.set(['name']),
|
|
24
|
+
Annotation.IconAnnotation.set({
|
|
25
|
+
icon: 'ph--squares-four--regular',
|
|
26
|
+
hue: 'green',
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export interface Board extends Schema.Schema.Type<typeof Board> {}
|
|
31
|
+
|
|
32
|
+
export const makeBoard = (props: Partial<Obj.MakeProps<typeof Board>> = {}) =>
|
|
33
|
+
Obj.make(Board, {
|
|
34
|
+
items: [],
|
|
35
|
+
layout: defaultLayout,
|
|
36
|
+
...props,
|
|
37
|
+
});
|
package/src/types/index.ts
CHANGED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// src/types/schema.ts
|
|
2
|
-
import { Schema } from "effect";
|
|
3
|
-
import { Type } from "@dxos/echo";
|
|
4
|
-
import { LabelAnnotation } from "@dxos/echo-schema";
|
|
5
|
-
import { BoardLayout } from "@dxos/react-ui-board";
|
|
6
|
-
|
|
7
|
-
// src/meta.ts
|
|
8
|
-
var meta = {
|
|
9
|
-
id: "dxos.org/plugin/board",
|
|
10
|
-
name: "Board",
|
|
11
|
-
description: "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
|
-
};
|
|
16
|
-
|
|
17
|
-
// src/types/schema.ts
|
|
18
|
-
(function(Board2) {
|
|
19
|
-
Board2.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(Type.Obj({
|
|
24
|
-
typename: "dxos.org/type/Board",
|
|
25
|
-
version: "0.1.0"
|
|
26
|
-
}), LabelAnnotation.set([
|
|
27
|
-
"name"
|
|
28
|
-
]));
|
|
29
|
-
class Create extends Schema.TaggedClass()(`${meta.id}/action/create`, {
|
|
30
|
-
input: Schema.Struct({
|
|
31
|
-
name: Schema.optional(Schema.String)
|
|
32
|
-
}),
|
|
33
|
-
output: Schema.Struct({
|
|
34
|
-
object: Board2.Board
|
|
35
|
-
})
|
|
36
|
-
}) {
|
|
37
|
-
}
|
|
38
|
-
Board2.Create = Create;
|
|
39
|
-
})(Board || (Board = {}));
|
|
40
|
-
var Board;
|
|
41
|
-
|
|
42
|
-
export {
|
|
43
|
-
meta,
|
|
44
|
-
Board
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=chunk-TDV6SJ64.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/schema.ts", "../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { Type } from '@dxos/echo';\nimport { LabelAnnotation } from '@dxos/echo-schema';\nimport { BoardLayout } from '@dxos/react-ui-board';\n\nimport { meta } from '../meta';\n\nexport namespace Board {\n //\n // Types\n //\n\n // TODO(burdon): View?\n export const Board = Schema.Struct({\n name: Schema.optional(Schema.String),\n items: Schema.mutable(Schema.Array(Type.Ref(Type.Expando))),\n layout: Schema.mutable(BoardLayout),\n }).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Board',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n );\n\n export interface Board extends Schema.Schema.Type<typeof Board> {}\n\n //\n // Actions\n //\n\n export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {\n input: Schema.Struct({\n name: Schema.optional(Schema.String),\n }),\n output: Schema.Struct({\n object: Board,\n }),\n }) {}\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/board',\n name: 'Board',\n description:\n 'A spatial, infinite canvas app combining notes, media, and whiteboarding in a tactile, visual interface.',\n icon: 'ph--squares-four--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-board',\n screenshots: [],\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,cAAc;AAEvB,SAASC,YAAY;AACrB,SAASC,uBAAuB;AAChC,SAASC,mBAAmB;;;ACFrB,IAAMC,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aACE;EACFC,MAAM;EACNC,QAAQ;EACRC,aAAa,CAAA;AACf;;;UDFiBC,QAAAA;SAMFA,QAAQC,OAAOC,OAAO;IACjCC,MAAMF,OAAOG,SAASH,OAAOI,MAAM;IACnCC,OAAOL,OAAOM,QAAQN,OAAOO,MAAMC,KAAKC,IAAID,KAAKE,OAAO,CAAA,CAAA;IACxDC,QAAQX,OAAOM,QAAQM,WAAAA;EACzB,CAAA,EAAGC,KACDL,KAAKM,IAAI;IACPC,UAAU;IACVC,SAAS;EACX,CAAA,GACAC,gBAAgBC,IAAI;IAAC;GAAO,CAAA;EASvB,MAAMC,eAAenB,OAAOoB,YAAW,EAAW,GAAGC,KAAKC,EAAE,kBAAkB;IACnFC,OAAOvB,OAAOC,OAAO;MACnBC,MAAMF,OAAOG,SAASH,OAAOI,MAAM;IACrC,CAAA;IACAoB,QAAQxB,OAAOC,OAAO;MACpBwB,QAAM1B,OAAEA;IACV,CAAA;EACF,CAAA,EAAA;EAAI;SAPSoB,SAAAA;AAQf,GAhCiBpB,UAAAA,QAAAA,CAAAA,EAAAA;;",
|
|
6
|
-
"names": ["Schema", "Type", "LabelAnnotation", "BoardLayout", "meta", "id", "name", "description", "icon", "source", "screenshots", "Board", "Schema", "Struct", "name", "optional", "String", "items", "mutable", "Array", "Type", "Ref", "Expando", "layout", "BoardLayout", "pipe", "Obj", "typename", "version", "LabelAnnotation", "set", "Create", "TaggedClass", "meta", "id", "input", "output", "object"]
|
|
7
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Board
|
|
3
|
-
} from "./chunk-TDV6SJ64.mjs";
|
|
4
|
-
|
|
5
|
-
// src/capabilities/intent-resolver.ts
|
|
6
|
-
import { Capabilities, contributes, createResolver } from "@dxos/app-framework";
|
|
7
|
-
import { Obj } from "@dxos/echo";
|
|
8
|
-
var intent_resolver_default = () => [
|
|
9
|
-
contributes(Capabilities.IntentResolver, createResolver({
|
|
10
|
-
intent: Board.Create,
|
|
11
|
-
resolve: ({ name }) => {
|
|
12
|
-
return {
|
|
13
|
-
data: {
|
|
14
|
-
object: Obj.make(Board.Board, {
|
|
15
|
-
name,
|
|
16
|
-
items: [],
|
|
17
|
-
layout: {
|
|
18
|
-
size: {
|
|
19
|
-
width: 5,
|
|
20
|
-
height: 5
|
|
21
|
-
},
|
|
22
|
-
cells: {}
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}))
|
|
29
|
-
];
|
|
30
|
-
export {
|
|
31
|
-
intent_resolver_default as default
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=intent-resolver-TDOZP647.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/intent-resolver.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, contributes, createResolver } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\n\nimport { Board } from '../types';\n\nexport default () => [\n contributes(\n Capabilities.IntentResolver,\n createResolver({\n intent: Board.Create,\n resolve: ({ name }) => {\n return {\n data: {\n object: Obj.make(Board.Board, {\n name,\n items: [],\n layout: {\n size: {\n width: 5,\n height: 5,\n },\n cells: {},\n },\n }),\n },\n };\n },\n }),\n ),\n];\n"],
|
|
5
|
-
"mappings": ";;;;;AAIA,SAASA,cAAcC,aAAaC,sBAAsB;AAC1D,SAASC,WAAW;AAIpB,IAAA,0BAAe,MAAM;EACnBC,YACEC,aAAaC,gBACbC,eAAe;IACbC,QAAQC,MAAMC;IACdC,SAAS,CAAC,EAAEC,KAAI,MAAE;AAChB,aAAO;QACLC,MAAM;UACJC,QAAQC,IAAIC,KAAKP,MAAMA,OAAO;YAC5BG;YACAK,OAAO,CAAA;YACPC,QAAQ;cACNC,MAAM;gBACJC,OAAO;gBACPC,QAAQ;cACV;cACAC,OAAO,CAAC;YACV;UACF,CAAA;QACF;MACF;IACF;EACF,CAAA,CAAA;;",
|
|
6
|
-
"names": ["Capabilities", "contributes", "createResolver", "Obj", "contributes", "Capabilities", "IntentResolver", "createResolver", "intent", "Board", "Create", "resolve", "name", "data", "object", "Obj", "make", "items", "layout", "size", "width", "height", "cells"]
|
|
7
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Board,
|
|
3
|
-
meta
|
|
4
|
-
} from "./chunk-TDV6SJ64.mjs";
|
|
5
|
-
|
|
6
|
-
// src/capabilities/react-surface.tsx
|
|
7
|
-
import React2 from "react";
|
|
8
|
-
import { contributes, Capabilities, createSurface } from "@dxos/app-framework";
|
|
9
|
-
import { Obj as Obj2 } from "@dxos/echo";
|
|
10
|
-
|
|
11
|
-
// src/components/BoardContainer.tsx
|
|
12
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
13
|
-
import { effect } from "@preact/signals-react";
|
|
14
|
-
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
15
|
-
import { getSpace } from "@dxos/client/echo";
|
|
16
|
-
import { Obj, Ref, Type } from "@dxos/echo";
|
|
17
|
-
import { invariant } from "@dxos/invariant";
|
|
18
|
-
import { Board as BoardComponent } from "@dxos/react-ui-board";
|
|
19
|
-
import { StackItem } from "@dxos/react-ui-stack";
|
|
20
|
-
import { isNonNullable } from "@dxos/util";
|
|
21
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-board/src/components/BoardContainer.tsx";
|
|
22
|
-
var BoardContainer = ({ role, board }) => {
|
|
23
|
-
var _effect = _useSignals();
|
|
24
|
-
try {
|
|
25
|
-
const controller = useRef(null);
|
|
26
|
-
const [items, setItems] = useState([]);
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
let t;
|
|
29
|
-
effect(() => {
|
|
30
|
-
const refs = [
|
|
31
|
-
...board.items
|
|
32
|
-
];
|
|
33
|
-
t = setTimeout(async () => {
|
|
34
|
-
const items2 = await Ref.Array.loadAll(refs);
|
|
35
|
-
setItems(items2.filter(isNonNullable));
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
return () => clearTimeout(t);
|
|
39
|
-
}, [
|
|
40
|
-
board.items
|
|
41
|
-
]);
|
|
42
|
-
const handleAdd = useCallback((position = {
|
|
43
|
-
x: 0,
|
|
44
|
-
y: 0
|
|
45
|
-
}) => {
|
|
46
|
-
const space = getSpace(board);
|
|
47
|
-
invariant(space, void 0, {
|
|
48
|
-
F: __dxlog_file,
|
|
49
|
-
L: 43,
|
|
50
|
-
S: void 0,
|
|
51
|
-
A: [
|
|
52
|
-
"space",
|
|
53
|
-
""
|
|
54
|
-
]
|
|
55
|
-
});
|
|
56
|
-
const obj = space.db.add(Obj.make(Type.Expando, {}));
|
|
57
|
-
board.items.push(Ref.make(obj));
|
|
58
|
-
board.layout.cells[obj.id] = {
|
|
59
|
-
...position,
|
|
60
|
-
width: 1,
|
|
61
|
-
height: 1
|
|
62
|
-
};
|
|
63
|
-
controller.current?.center(position);
|
|
64
|
-
}, [
|
|
65
|
-
board,
|
|
66
|
-
controller
|
|
67
|
-
]);
|
|
68
|
-
const handleDelete = useCallback((id) => {
|
|
69
|
-
const idx = board.items.findIndex((ref) => ref.dxn.asEchoDXN()?.echoId === id);
|
|
70
|
-
if (idx !== -1) {
|
|
71
|
-
board.items.splice(idx, 1);
|
|
72
|
-
}
|
|
73
|
-
delete board.layout.cells[id];
|
|
74
|
-
setItems((items2) => items2.filter((item) => item.id !== id));
|
|
75
|
-
}, [
|
|
76
|
-
board
|
|
77
|
-
]);
|
|
78
|
-
const handleMove = useCallback((id, position) => {
|
|
79
|
-
const layout = board.layout.cells[id];
|
|
80
|
-
board.layout.cells[id] = {
|
|
81
|
-
...layout,
|
|
82
|
-
...position
|
|
83
|
-
};
|
|
84
|
-
}, [
|
|
85
|
-
board
|
|
86
|
-
]);
|
|
87
|
-
return /* @__PURE__ */ React.createElement(BoardComponent.Root, {
|
|
88
|
-
ref: controller,
|
|
89
|
-
layout: board.layout,
|
|
90
|
-
onAdd: handleAdd,
|
|
91
|
-
onDelete: handleDelete,
|
|
92
|
-
onMove: handleMove
|
|
93
|
-
}, /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
94
|
-
role,
|
|
95
|
-
toolbar: true
|
|
96
|
-
}, /* @__PURE__ */ React.createElement(BoardComponent.Controls, null), /* @__PURE__ */ React.createElement(BoardComponent.Container, null, /* @__PURE__ */ React.createElement(BoardComponent.Viewport, {
|
|
97
|
-
classNames: "border-none"
|
|
98
|
-
}, /* @__PURE__ */ React.createElement(BoardComponent.Background, null), /* @__PURE__ */ React.createElement(BoardComponent.Content, {
|
|
99
|
-
items,
|
|
100
|
-
getTitle: (item) => Obj.getLabel(item) ?? item.id
|
|
101
|
-
})))));
|
|
102
|
-
} finally {
|
|
103
|
-
_effect.f();
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
// src/capabilities/react-surface.tsx
|
|
108
|
-
var react_surface_default = (context) => contributes(Capabilities.ReactSurface, [
|
|
109
|
-
createSurface({
|
|
110
|
-
id: meta.id,
|
|
111
|
-
role: [
|
|
112
|
-
"article",
|
|
113
|
-
"section"
|
|
114
|
-
],
|
|
115
|
-
filter: (data) => Obj2.instanceOf(Board.Board, data.subject),
|
|
116
|
-
component: ({ data, role }) => /* @__PURE__ */ React2.createElement(BoardContainer, {
|
|
117
|
-
board: data.subject,
|
|
118
|
-
role
|
|
119
|
-
})
|
|
120
|
-
})
|
|
121
|
-
]);
|
|
122
|
-
export {
|
|
123
|
-
react_surface_default as default
|
|
124
|
-
};
|
|
125
|
-
//# sourceMappingURL=react-surface-SHXN2B3I.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/react-surface.tsx", "../../../src/components/BoardContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { contributes, Capabilities, type PluginContext, createSurface } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\n\nimport { BoardContainer } from '../components';\nimport { meta } from '../meta';\nimport { Board } from '../types';\n\nexport default (context: PluginContext) =>\n contributes(Capabilities.ReactSurface, [\n createSurface({\n id: meta.id,\n role: ['article', 'section'],\n filter: (data): data is { subject: Board.Board } => Obj.instanceOf(Board.Board, data.subject),\n component: ({ data, role }) => <BoardContainer board={data.subject} role={role} />,\n }),\n ]);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { effect } from '@preact/signals-react';\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { getSpace } from '@dxos/client/echo';\nimport { Obj, Ref, Type } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\nimport { Board as BoardComponent, type BoardController, type BoardRootProps } from '@dxos/react-ui-board';\nimport { StackItem } from '@dxos/react-ui-stack';\nimport { isNonNullable } from '@dxos/util';\n\nimport { type Board } from '../types';\n\nexport type BoardContainerProps = {\n role: string;\n board: Board.Board;\n};\n\nexport const BoardContainer = ({ role, board }: BoardContainerProps) => {\n const controller = useRef<BoardController>(null);\n\n // TODO(burdon): Create effect utility for reactive arrays.\n const [items, setItems] = useState<Type.Expando[]>([]);\n useEffect(() => {\n let t: NodeJS.Timeout;\n effect(() => {\n const refs = [...board.items];\n t = setTimeout(async () => {\n const items = await Ref.Array.loadAll(refs);\n setItems(items.filter(isNonNullable));\n });\n });\n\n return () => clearTimeout(t);\n }, [board.items]);\n\n const handleAdd = useCallback<NonNullable<BoardRootProps['onAdd']>>(\n (position = { x: 0, y: 0 }) => {\n const space = getSpace(board);\n invariant(space);\n // TODO(burdon): Create from menu/intent?\n const obj = space.db.add(Obj.make(Type.Expando, {}));\n board.items.push(Ref.make(obj));\n board.layout.cells[obj.id] = { ...position, width: 1, height: 1 };\n controller.current?.center(position);\n },\n [board, controller],\n );\n\n // TODO(burdon): Use intents so can be undone.\n const handleDelete = useCallback<NonNullable<BoardRootProps['onDelete']>>(\n (id) => {\n // TODO(burdon): Impl. DXN.equals and pass in DXN from `id`.\n const idx = board.items.findIndex((ref) => ref.dxn.asEchoDXN()?.echoId === id);\n if (idx !== -1) {\n board.items.splice(idx, 1);\n }\n delete board.layout.cells[id];\n setItems((items) => items.filter((item) => item.id !== id));\n },\n [board],\n );\n\n const handleMove = useCallback<NonNullable<BoardRootProps['onMove']>>(\n (id, position) => {\n const layout = board.layout.cells[id];\n board.layout.cells[id] = { ...layout, ...position };\n },\n [board],\n );\n\n return (\n <BoardComponent.Root\n ref={controller}\n layout={board.layout}\n onAdd={handleAdd}\n onDelete={handleDelete}\n onMove={handleMove}\n >\n <StackItem.Content role={role} toolbar>\n <BoardComponent.Controls />\n <BoardComponent.Container>\n <BoardComponent.Viewport classNames='border-none'>\n <BoardComponent.Background />\n <BoardComponent.Content items={items} getTitle={(item) => Obj.getLabel(item) ?? item.id} />\n </BoardComponent.Viewport>\n </BoardComponent.Container>\n </StackItem.Content>\n </BoardComponent.Root>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;AAIA,OAAOA,YAAW;AAElB,SAASC,aAAaC,cAAkCC,qBAAqB;AAC7E,SAASC,OAAAA,YAAW;;;;ACHpB,SAASC,cAAc;AACvB,OAAOC,SAASC,aAAaC,WAAWC,QAAQC,gBAAgB;AAEhE,SAASC,gBAAgB;AACzB,SAASC,KAAKC,KAAKC,YAAY;AAC/B,SAASC,iBAAiB;AAC1B,SAASC,SAASC,sBAAiE;AACnF,SAASC,iBAAiB;AAC1B,SAASC,qBAAqB;;AASvB,IAAMC,iBAAiB,CAAC,EAAEC,MAAMC,MAAK,MAAuB;;;AACjE,UAAMC,aAAad,OAAwB,IAAA;AAG3C,UAAM,CAACe,OAAOC,QAAAA,IAAYf,SAAyB,CAAA,CAAE;AACrDF,cAAU,MAAA;AACR,UAAIkB;AACJrB,aAAO,MAAA;AACL,cAAMsB,OAAO;aAAIL,MAAME;;AACvBE,YAAIE,WAAW,YAAA;AACb,gBAAMJ,SAAQ,MAAMX,IAAIgB,MAAMC,QAAQH,IAAAA;AACtCF,mBAASD,OAAMO,OAAOZ,aAAAA,CAAAA;QACxB,CAAA;MACF,CAAA;AAEA,aAAO,MAAMa,aAAaN,CAAAA;IAC5B,GAAG;MAACJ,MAAME;KAAM;AAEhB,UAAMS,YAAY1B,YAChB,CAAC2B,WAAW;MAAEC,GAAG;MAAGC,GAAG;IAAE,MAAC;AACxB,YAAMC,QAAQ1B,SAASW,KAAAA;AACvBP,gBAAUsB,OAAAA,QAAAA;;;;;;;;;AAEV,YAAMC,MAAMD,MAAME,GAAGC,IAAI5B,IAAI6B,KAAK3B,KAAK4B,SAAS,CAAC,CAAA,CAAA;AACjDpB,YAAME,MAAMmB,KAAK9B,IAAI4B,KAAKH,GAAAA,CAAAA;AAC1BhB,YAAMsB,OAAOC,MAAMP,IAAIQ,EAAE,IAAI;QAAE,GAAGZ;QAAUa,OAAO;QAAGC,QAAQ;MAAE;AAChEzB,iBAAW0B,SAASC,OAAOhB,QAAAA;IAC7B,GACA;MAACZ;MAAOC;KAAW;AAIrB,UAAM4B,eAAe5C,YACnB,CAACuC,OAAAA;AAEC,YAAMM,MAAM9B,MAAME,MAAM6B,UAAU,CAACC,QAAQA,IAAIC,IAAIC,UAAS,GAAIC,WAAWX,EAAAA;AAC3E,UAAIM,QAAQ,IAAI;AACd9B,cAAME,MAAMkC,OAAON,KAAK,CAAA;MAC1B;AACA,aAAO9B,MAAMsB,OAAOC,MAAMC,EAAAA;AAC1BrB,eAAS,CAACD,WAAUA,OAAMO,OAAO,CAAC4B,SAASA,KAAKb,OAAOA,EAAAA,CAAAA;IACzD,GACA;MAACxB;KAAM;AAGT,UAAMsC,aAAarD,YACjB,CAACuC,IAAIZ,aAAAA;AACH,YAAMU,SAAStB,MAAMsB,OAAOC,MAAMC,EAAAA;AAClCxB,YAAMsB,OAAOC,MAAMC,EAAAA,IAAM;QAAE,GAAGF;QAAQ,GAAGV;MAAS;IACpD,GACA;MAACZ;KAAM;AAGT,WACE,sBAAA,cAACL,eAAe4C,MAAI;MAClBP,KAAK/B;MACLqB,QAAQtB,MAAMsB;MACdkB,OAAO7B;MACP8B,UAAUZ;MACVa,QAAQJ;OAER,sBAAA,cAAC1C,UAAU+C,SAAO;MAAC5C;MAAY6C,SAAAA;OAC7B,sBAAA,cAACjD,eAAekD,UAAQ,IAAA,GACxB,sBAAA,cAAClD,eAAemD,WAAS,MACvB,sBAAA,cAACnD,eAAeoD,UAAQ;MAACC,YAAW;OAClC,sBAAA,cAACrD,eAAesD,YAAU,IAAA,GAC1B,sBAAA,cAACtD,eAAegD,SAAO;MAACzC;MAAcgD,UAAU,CAACb,SAAS/C,IAAI6D,SAASd,IAAAA,KAASA,KAAKb;;;;;AAMjG;;;ADhFA,IAAA,wBAAe,CAAC4B,YACdC,YAAYC,aAAaC,cAAc;EACrCC,cAAc;IACZC,IAAIC,KAAKD;IACTE,MAAM;MAAC;MAAW;;IAClBC,QAAQ,CAACC,SAA2CC,KAAIC,WAAWC,MAAMA,OAAOH,KAAKI,OAAO;IAC5FC,WAAW,CAAC,EAAEL,MAAMF,KAAI,MAAO,gBAAAQ,OAAA,cAACC,gBAAAA;MAAeC,OAAOR,KAAKI;MAASN;;EACtE,CAAA;CACD;",
|
|
6
|
-
"names": ["React", "contributes", "Capabilities", "createSurface", "Obj", "effect", "React", "useCallback", "useEffect", "useRef", "useState", "getSpace", "Obj", "Ref", "Type", "invariant", "Board", "BoardComponent", "StackItem", "isNonNullable", "BoardContainer", "role", "board", "controller", "items", "setItems", "t", "refs", "setTimeout", "Array", "loadAll", "filter", "clearTimeout", "handleAdd", "position", "x", "y", "space", "obj", "db", "add", "make", "Expando", "push", "layout", "cells", "id", "width", "height", "current", "center", "handleDelete", "idx", "findIndex", "ref", "dxn", "asEchoDXN", "echoId", "splice", "item", "handleMove", "Root", "onAdd", "onDelete", "onMove", "Content", "toolbar", "Controls", "Container", "Viewport", "classNames", "Background", "getTitle", "getLabel", "context", "contributes", "Capabilities", "ReactSurface", "createSurface", "id", "meta", "role", "filter", "data", "Obj", "instanceOf", "Board", "subject", "component", "React", "BoardContainer", "board"]
|
|
7
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/types/schema.ts
|
|
4
|
-
import { Schema } from "effect";
|
|
5
|
-
import { Type } from "@dxos/echo";
|
|
6
|
-
import { LabelAnnotation } from "@dxos/echo-schema";
|
|
7
|
-
import { BoardLayout } from "@dxos/react-ui-board";
|
|
8
|
-
|
|
9
|
-
// src/meta.ts
|
|
10
|
-
var meta = {
|
|
11
|
-
id: "dxos.org/plugin/board",
|
|
12
|
-
name: "Board",
|
|
13
|
-
description: "A spatial, infinite canvas app combining notes, media, and whiteboarding in a tactile, visual interface.",
|
|
14
|
-
icon: "ph--squares-four--regular",
|
|
15
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-board",
|
|
16
|
-
screenshots: []
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// src/types/schema.ts
|
|
20
|
-
(function(Board2) {
|
|
21
|
-
Board2.Board = Schema.Struct({
|
|
22
|
-
name: Schema.optional(Schema.String),
|
|
23
|
-
items: Schema.mutable(Schema.Array(Type.Ref(Type.Expando))),
|
|
24
|
-
layout: Schema.mutable(BoardLayout)
|
|
25
|
-
}).pipe(Type.Obj({
|
|
26
|
-
typename: "dxos.org/type/Board",
|
|
27
|
-
version: "0.1.0"
|
|
28
|
-
}), LabelAnnotation.set([
|
|
29
|
-
"name"
|
|
30
|
-
]));
|
|
31
|
-
class Create extends Schema.TaggedClass()(`${meta.id}/action/create`, {
|
|
32
|
-
input: Schema.Struct({
|
|
33
|
-
name: Schema.optional(Schema.String)
|
|
34
|
-
}),
|
|
35
|
-
output: Schema.Struct({
|
|
36
|
-
object: Board2.Board
|
|
37
|
-
})
|
|
38
|
-
}) {
|
|
39
|
-
}
|
|
40
|
-
Board2.Create = Create;
|
|
41
|
-
})(Board || (Board = {}));
|
|
42
|
-
var Board;
|
|
43
|
-
|
|
44
|
-
export {
|
|
45
|
-
meta,
|
|
46
|
-
Board
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=chunk-K6CHLZYU.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/schema.ts", "../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { Type } from '@dxos/echo';\nimport { LabelAnnotation } from '@dxos/echo-schema';\nimport { BoardLayout } from '@dxos/react-ui-board';\n\nimport { meta } from '../meta';\n\nexport namespace Board {\n //\n // Types\n //\n\n // TODO(burdon): View?\n export const Board = Schema.Struct({\n name: Schema.optional(Schema.String),\n items: Schema.mutable(Schema.Array(Type.Ref(Type.Expando))),\n layout: Schema.mutable(BoardLayout),\n }).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Board',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n );\n\n export interface Board extends Schema.Schema.Type<typeof Board> {}\n\n //\n // Actions\n //\n\n export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {\n input: Schema.Struct({\n name: Schema.optional(Schema.String),\n }),\n output: Schema.Struct({\n object: Board,\n }),\n }) {}\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/board',\n name: 'Board',\n description:\n 'A spatial, infinite canvas app combining notes, media, and whiteboarding in a tactile, visual interface.',\n icon: 'ph--squares-four--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-board',\n screenshots: [],\n};\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,cAAc;AAEvB,SAASC,YAAY;AACrB,SAASC,uBAAuB;AAChC,SAASC,mBAAmB;;;ACFrB,IAAMC,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aACE;EACFC,MAAM;EACNC,QAAQ;EACRC,aAAa,CAAA;AACf;;;UDFiBC,QAAAA;SAMFA,QAAQC,OAAOC,OAAO;IACjCC,MAAMF,OAAOG,SAASH,OAAOI,MAAM;IACnCC,OAAOL,OAAOM,QAAQN,OAAOO,MAAMC,KAAKC,IAAID,KAAKE,OAAO,CAAA,CAAA;IACxDC,QAAQX,OAAOM,QAAQM,WAAAA;EACzB,CAAA,EAAGC,KACDL,KAAKM,IAAI;IACPC,UAAU;IACVC,SAAS;EACX,CAAA,GACAC,gBAAgBC,IAAI;IAAC;GAAO,CAAA;EASvB,MAAMC,eAAenB,OAAOoB,YAAW,EAAW,GAAGC,KAAKC,EAAE,kBAAkB;IACnFC,OAAOvB,OAAOC,OAAO;MACnBC,MAAMF,OAAOG,SAASH,OAAOI,MAAM;IACrC,CAAA;IACAoB,QAAQxB,OAAOC,OAAO;MACpBwB,QAAM1B,OAAEA;IACV,CAAA;EACF,CAAA,EAAA;EAAI;SAPSoB,SAAAA;AAQf,GAhCiBpB,UAAAA,QAAAA,CAAAA,EAAAA;;",
|
|
6
|
-
"names": ["Schema", "Type", "LabelAnnotation", "BoardLayout", "meta", "id", "name", "description", "icon", "source", "screenshots", "Board", "Schema", "Struct", "name", "optional", "String", "items", "mutable", "Array", "Type", "Ref", "Expando", "layout", "BoardLayout", "pipe", "Obj", "typename", "version", "LabelAnnotation", "set", "Create", "TaggedClass", "meta", "id", "input", "output", "object"]
|
|
7
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
Board
|
|
4
|
-
} from "./chunk-K6CHLZYU.mjs";
|
|
5
|
-
|
|
6
|
-
// src/capabilities/intent-resolver.ts
|
|
7
|
-
import { Capabilities, contributes, createResolver } from "@dxos/app-framework";
|
|
8
|
-
import { Obj } from "@dxos/echo";
|
|
9
|
-
var intent_resolver_default = () => [
|
|
10
|
-
contributes(Capabilities.IntentResolver, createResolver({
|
|
11
|
-
intent: Board.Create,
|
|
12
|
-
resolve: ({ name }) => {
|
|
13
|
-
return {
|
|
14
|
-
data: {
|
|
15
|
-
object: Obj.make(Board.Board, {
|
|
16
|
-
name,
|
|
17
|
-
items: [],
|
|
18
|
-
layout: {
|
|
19
|
-
size: {
|
|
20
|
-
width: 5,
|
|
21
|
-
height: 5
|
|
22
|
-
},
|
|
23
|
-
cells: {}
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
}))
|
|
30
|
-
];
|
|
31
|
-
export {
|
|
32
|
-
intent_resolver_default as default
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=intent-resolver-IHQWKJNT.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/intent-resolver.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, contributes, createResolver } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\n\nimport { Board } from '../types';\n\nexport default () => [\n contributes(\n Capabilities.IntentResolver,\n createResolver({\n intent: Board.Create,\n resolve: ({ name }) => {\n return {\n data: {\n object: Obj.make(Board.Board, {\n name,\n items: [],\n layout: {\n size: {\n width: 5,\n height: 5,\n },\n cells: {},\n },\n }),\n },\n };\n },\n }),\n ),\n];\n"],
|
|
5
|
-
"mappings": ";;;;;;AAIA,SAASA,cAAcC,aAAaC,sBAAsB;AAC1D,SAASC,WAAW;AAIpB,IAAA,0BAAe,MAAM;EACnBC,YACEC,aAAaC,gBACbC,eAAe;IACbC,QAAQC,MAAMC;IACdC,SAAS,CAAC,EAAEC,KAAI,MAAE;AAChB,aAAO;QACLC,MAAM;UACJC,QAAQC,IAAIC,KAAKP,MAAMA,OAAO;YAC5BG;YACAK,OAAO,CAAA;YACPC,QAAQ;cACNC,MAAM;gBACJC,OAAO;gBACPC,QAAQ;cACV;cACAC,OAAO,CAAC;YACV;UACF,CAAA;QACF;MACF;IACF;EACF,CAAA,CAAA;;",
|
|
6
|
-
"names": ["Capabilities", "contributes", "createResolver", "Obj", "contributes", "Capabilities", "IntentResolver", "createResolver", "intent", "Board", "Create", "resolve", "name", "data", "object", "Obj", "make", "items", "layout", "size", "width", "height", "cells"]
|
|
7
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
Board,
|
|
4
|
-
meta
|
|
5
|
-
} from "./chunk-K6CHLZYU.mjs";
|
|
6
|
-
|
|
7
|
-
// src/capabilities/react-surface.tsx
|
|
8
|
-
import React2 from "react";
|
|
9
|
-
import { contributes, Capabilities, createSurface } from "@dxos/app-framework";
|
|
10
|
-
import { Obj as Obj2 } from "@dxos/echo";
|
|
11
|
-
|
|
12
|
-
// src/components/BoardContainer.tsx
|
|
13
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
14
|
-
import { effect } from "@preact/signals-react";
|
|
15
|
-
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
16
|
-
import { getSpace } from "@dxos/client/echo";
|
|
17
|
-
import { Obj, Ref, Type } from "@dxos/echo";
|
|
18
|
-
import { invariant } from "@dxos/invariant";
|
|
19
|
-
import { Board as BoardComponent } from "@dxos/react-ui-board";
|
|
20
|
-
import { StackItem } from "@dxos/react-ui-stack";
|
|
21
|
-
import { isNonNullable } from "@dxos/util";
|
|
22
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-board/src/components/BoardContainer.tsx";
|
|
23
|
-
var BoardContainer = ({ role, board }) => {
|
|
24
|
-
var _effect = _useSignals();
|
|
25
|
-
try {
|
|
26
|
-
const controller = useRef(null);
|
|
27
|
-
const [items, setItems] = useState([]);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
let t;
|
|
30
|
-
effect(() => {
|
|
31
|
-
const refs = [
|
|
32
|
-
...board.items
|
|
33
|
-
];
|
|
34
|
-
t = setTimeout(async () => {
|
|
35
|
-
const items2 = await Ref.Array.loadAll(refs);
|
|
36
|
-
setItems(items2.filter(isNonNullable));
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
return () => clearTimeout(t);
|
|
40
|
-
}, [
|
|
41
|
-
board.items
|
|
42
|
-
]);
|
|
43
|
-
const handleAdd = useCallback((position = {
|
|
44
|
-
x: 0,
|
|
45
|
-
y: 0
|
|
46
|
-
}) => {
|
|
47
|
-
const space = getSpace(board);
|
|
48
|
-
invariant(space, void 0, {
|
|
49
|
-
F: __dxlog_file,
|
|
50
|
-
L: 43,
|
|
51
|
-
S: void 0,
|
|
52
|
-
A: [
|
|
53
|
-
"space",
|
|
54
|
-
""
|
|
55
|
-
]
|
|
56
|
-
});
|
|
57
|
-
const obj = space.db.add(Obj.make(Type.Expando, {}));
|
|
58
|
-
board.items.push(Ref.make(obj));
|
|
59
|
-
board.layout.cells[obj.id] = {
|
|
60
|
-
...position,
|
|
61
|
-
width: 1,
|
|
62
|
-
height: 1
|
|
63
|
-
};
|
|
64
|
-
controller.current?.center(position);
|
|
65
|
-
}, [
|
|
66
|
-
board,
|
|
67
|
-
controller
|
|
68
|
-
]);
|
|
69
|
-
const handleDelete = useCallback((id) => {
|
|
70
|
-
const idx = board.items.findIndex((ref) => ref.dxn.asEchoDXN()?.echoId === id);
|
|
71
|
-
if (idx !== -1) {
|
|
72
|
-
board.items.splice(idx, 1);
|
|
73
|
-
}
|
|
74
|
-
delete board.layout.cells[id];
|
|
75
|
-
setItems((items2) => items2.filter((item) => item.id !== id));
|
|
76
|
-
}, [
|
|
77
|
-
board
|
|
78
|
-
]);
|
|
79
|
-
const handleMove = useCallback((id, position) => {
|
|
80
|
-
const layout = board.layout.cells[id];
|
|
81
|
-
board.layout.cells[id] = {
|
|
82
|
-
...layout,
|
|
83
|
-
...position
|
|
84
|
-
};
|
|
85
|
-
}, [
|
|
86
|
-
board
|
|
87
|
-
]);
|
|
88
|
-
return /* @__PURE__ */ React.createElement(BoardComponent.Root, {
|
|
89
|
-
ref: controller,
|
|
90
|
-
layout: board.layout,
|
|
91
|
-
onAdd: handleAdd,
|
|
92
|
-
onDelete: handleDelete,
|
|
93
|
-
onMove: handleMove
|
|
94
|
-
}, /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
95
|
-
role,
|
|
96
|
-
toolbar: true
|
|
97
|
-
}, /* @__PURE__ */ React.createElement(BoardComponent.Controls, null), /* @__PURE__ */ React.createElement(BoardComponent.Container, null, /* @__PURE__ */ React.createElement(BoardComponent.Viewport, {
|
|
98
|
-
classNames: "border-none"
|
|
99
|
-
}, /* @__PURE__ */ React.createElement(BoardComponent.Background, null), /* @__PURE__ */ React.createElement(BoardComponent.Content, {
|
|
100
|
-
items,
|
|
101
|
-
getTitle: (item) => Obj.getLabel(item) ?? item.id
|
|
102
|
-
})))));
|
|
103
|
-
} finally {
|
|
104
|
-
_effect.f();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// src/capabilities/react-surface.tsx
|
|
109
|
-
var react_surface_default = (context) => contributes(Capabilities.ReactSurface, [
|
|
110
|
-
createSurface({
|
|
111
|
-
id: meta.id,
|
|
112
|
-
role: [
|
|
113
|
-
"article",
|
|
114
|
-
"section"
|
|
115
|
-
],
|
|
116
|
-
filter: (data) => Obj2.instanceOf(Board.Board, data.subject),
|
|
117
|
-
component: ({ data, role }) => /* @__PURE__ */ React2.createElement(BoardContainer, {
|
|
118
|
-
board: data.subject,
|
|
119
|
-
role
|
|
120
|
-
})
|
|
121
|
-
})
|
|
122
|
-
]);
|
|
123
|
-
export {
|
|
124
|
-
react_surface_default as default
|
|
125
|
-
};
|
|
126
|
-
//# sourceMappingURL=react-surface-DGFWUKUE.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/react-surface.tsx", "../../../src/components/BoardContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { contributes, Capabilities, type PluginContext, createSurface } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\n\nimport { BoardContainer } from '../components';\nimport { meta } from '../meta';\nimport { Board } from '../types';\n\nexport default (context: PluginContext) =>\n contributes(Capabilities.ReactSurface, [\n createSurface({\n id: meta.id,\n role: ['article', 'section'],\n filter: (data): data is { subject: Board.Board } => Obj.instanceOf(Board.Board, data.subject),\n component: ({ data, role }) => <BoardContainer board={data.subject} role={role} />,\n }),\n ]);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { effect } from '@preact/signals-react';\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { getSpace } from '@dxos/client/echo';\nimport { Obj, Ref, Type } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\nimport { Board as BoardComponent, type BoardController, type BoardRootProps } from '@dxos/react-ui-board';\nimport { StackItem } from '@dxos/react-ui-stack';\nimport { isNonNullable } from '@dxos/util';\n\nimport { type Board } from '../types';\n\nexport type BoardContainerProps = {\n role: string;\n board: Board.Board;\n};\n\nexport const BoardContainer = ({ role, board }: BoardContainerProps) => {\n const controller = useRef<BoardController>(null);\n\n // TODO(burdon): Create effect utility for reactive arrays.\n const [items, setItems] = useState<Type.Expando[]>([]);\n useEffect(() => {\n let t: NodeJS.Timeout;\n effect(() => {\n const refs = [...board.items];\n t = setTimeout(async () => {\n const items = await Ref.Array.loadAll(refs);\n setItems(items.filter(isNonNullable));\n });\n });\n\n return () => clearTimeout(t);\n }, [board.items]);\n\n const handleAdd = useCallback<NonNullable<BoardRootProps['onAdd']>>(\n (position = { x: 0, y: 0 }) => {\n const space = getSpace(board);\n invariant(space);\n // TODO(burdon): Create from menu/intent?\n const obj = space.db.add(Obj.make(Type.Expando, {}));\n board.items.push(Ref.make(obj));\n board.layout.cells[obj.id] = { ...position, width: 1, height: 1 };\n controller.current?.center(position);\n },\n [board, controller],\n );\n\n // TODO(burdon): Use intents so can be undone.\n const handleDelete = useCallback<NonNullable<BoardRootProps['onDelete']>>(\n (id) => {\n // TODO(burdon): Impl. DXN.equals and pass in DXN from `id`.\n const idx = board.items.findIndex((ref) => ref.dxn.asEchoDXN()?.echoId === id);\n if (idx !== -1) {\n board.items.splice(idx, 1);\n }\n delete board.layout.cells[id];\n setItems((items) => items.filter((item) => item.id !== id));\n },\n [board],\n );\n\n const handleMove = useCallback<NonNullable<BoardRootProps['onMove']>>(\n (id, position) => {\n const layout = board.layout.cells[id];\n board.layout.cells[id] = { ...layout, ...position };\n },\n [board],\n );\n\n return (\n <BoardComponent.Root\n ref={controller}\n layout={board.layout}\n onAdd={handleAdd}\n onDelete={handleDelete}\n onMove={handleMove}\n >\n <StackItem.Content role={role} toolbar>\n <BoardComponent.Controls />\n <BoardComponent.Container>\n <BoardComponent.Viewport classNames='border-none'>\n <BoardComponent.Background />\n <BoardComponent.Content items={items} getTitle={(item) => Obj.getLabel(item) ?? item.id} />\n </BoardComponent.Viewport>\n </BoardComponent.Container>\n </StackItem.Content>\n </BoardComponent.Root>\n );\n};\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["React", "contributes", "Capabilities", "createSurface", "Obj", "effect", "React", "useCallback", "useEffect", "useRef", "useState", "getSpace", "Obj", "Ref", "Type", "invariant", "Board", "BoardComponent", "StackItem", "isNonNullable", "BoardContainer", "role", "board", "controller", "items", "setItems", "t", "refs", "setTimeout", "Array", "loadAll", "filter", "clearTimeout", "handleAdd", "position", "x", "y", "space", "obj", "db", "add", "make", "Expando", "push", "layout", "cells", "id", "width", "height", "current", "center", "handleDelete", "idx", "findIndex", "ref", "dxn", "asEchoDXN", "echoId", "splice", "item", "handleMove", "Root", "onAdd", "onDelete", "onMove", "Content", "toolbar", "Controls", "Container", "Viewport", "classNames", "Background", "getTitle", "getLabel", "context", "contributes", "Capabilities", "ReactSurface", "createSurface", "id", "meta", "role", "filter", "data", "Obj", "instanceOf", "Board", "subject", "component", "React", "BoardContainer", "board"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"intent-resolver.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/intent-resolver.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAA+B,MAAM,qBAAqB,CAAC;;AAKhF,wBAwBE"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type Board } from '../types';
|
|
3
|
-
export type BoardContainerProps = {
|
|
4
|
-
role: string;
|
|
5
|
-
board: Board.Board;
|
|
6
|
-
};
|
|
7
|
-
export declare const BoardContainer: ({ role, board }: BoardContainerProps) => React.JSX.Element;
|
|
8
|
-
//# sourceMappingURL=BoardContainer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BoardContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/BoardContainer.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAmD,MAAM,OAAO,CAAC;AASxE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,iBAAiB,mBAAmB,sBAwElE,CAAC"}
|