@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.
- package/dist/lib/browser/BoardContainer-QVVN3MXA.mjs +150 -0
- package/dist/lib/browser/BoardContainer-QVVN3MXA.mjs.map +7 -0
- package/dist/lib/browser/chunk-DX5POLPL.mjs +19 -0
- package/dist/lib/browser/chunk-DX5POLPL.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/chunk-KO5FZQGF.mjs +34 -0
- package/dist/lib/browser/chunk-KO5FZQGF.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +37 -55
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-DBUDXBXD.mjs +38 -0
- package/dist/lib/browser/react-surface-DBUDXBXD.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -3
- package/dist/lib/node-esm/BoardContainer-U2P3DS4B.mjs +151 -0
- package/dist/lib/node-esm/BoardContainer-U2P3DS4B.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4C3UI73P.mjs +35 -0
- package/dist/lib/node-esm/chunk-4C3UI73P.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-BKJL6RLQ.mjs +21 -0
- package/dist/lib/node-esm/chunk-BKJL6RLQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +37 -55
- 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-SFB3GP7U.mjs +39 -0
- package/dist/lib/node-esm/react-surface-SFB3GP7U.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +4 -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 +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/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 +45 -0
- package/dist/types/src/containers/BoardContainer/BoardContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/BoardContainer/index.d.ts +3 -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 +1 -0
- 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 +57 -48
- package/src/BoardPlugin.tsx +23 -48
- package/src/capabilities/index.ts +1 -4
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +27 -0
- package/src/components/index.ts +0 -2
- package/src/containers/BoardContainer/BoardContainer.stories.tsx +122 -0
- package/src/containers/BoardContainer/BoardContainer.tsx +155 -0
- package/src/containers/BoardContainer/index.ts +7 -0
- package/src/containers/index.ts +7 -0
- package/src/index.ts +1 -0
- package/src/meta.ts +8 -4
- package/src/translations.ts +1 -0
- package/src/types/Board.ts +33 -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-XFSXU2JJ.mjs +0 -143
- package/dist/lib/browser/react-surface-XFSXU2JJ.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-ZHPQBZWO.mjs +0 -144
- package/dist/lib/node-esm/react-surface-ZHPQBZWO.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/dist/types/src/components/BoardContainer.d.ts +0 -8
- package/dist/types/src/components/BoardContainer.d.ts.map +0 -1
- package/dist/types/src/components/BoardContainer.stories.d.ts +0 -8
- package/dist/types/src/components/BoardContainer.stories.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/capabilities/react-surface.tsx +0 -22
- package/src/components/BoardContainer.stories.tsx +0 -142
- package/src/components/BoardContainer.tsx +0 -104
- package/src/types/schema.ts +0 -45
|
@@ -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,143 +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 } 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 { createIntent, Surface, useIntentDispatcher } from "@dxos/app-framework";
|
|
16
|
-
import { getSpace } from "@dxos/client/echo";
|
|
17
|
-
import { Ref } from "@dxos/echo";
|
|
18
|
-
import { invariant } from "@dxos/invariant";
|
|
19
|
-
import { SpaceAction } from "@dxos/plugin-space/types";
|
|
20
|
-
import { Board as Board2 } from "@dxos/react-ui-board";
|
|
21
|
-
import { StackItem } from "@dxos/react-ui-stack";
|
|
22
|
-
import { isNonNullable } from "@dxos/util";
|
|
23
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-board/src/components/BoardContainer.tsx";
|
|
24
|
-
var BoardContainer = ({ role, board }) => {
|
|
25
|
-
var _effect = _useSignals();
|
|
26
|
-
try {
|
|
27
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
28
|
-
const controller = useRef(null);
|
|
29
|
-
const [items, setItems] = useState([]);
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
let t;
|
|
32
|
-
effect(() => {
|
|
33
|
-
const refs = [
|
|
34
|
-
...board.items
|
|
35
|
-
];
|
|
36
|
-
t = setTimeout(async () => {
|
|
37
|
-
const items2 = await Ref.Array.loadAll(refs);
|
|
38
|
-
setItems(items2.filter(isNonNullable));
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
return () => clearTimeout(t);
|
|
42
|
-
}, [
|
|
43
|
-
board.items
|
|
44
|
-
]);
|
|
45
|
-
const handleAdd = useCallback(async (position = {
|
|
46
|
-
x: 0,
|
|
47
|
-
y: 0
|
|
48
|
-
}) => {
|
|
49
|
-
const space = getSpace(board);
|
|
50
|
-
invariant(space, void 0, {
|
|
51
|
-
F: __dxlog_file,
|
|
52
|
-
L: 47,
|
|
53
|
-
S: void 0,
|
|
54
|
-
A: [
|
|
55
|
-
"space",
|
|
56
|
-
""
|
|
57
|
-
]
|
|
58
|
-
});
|
|
59
|
-
await dispatch(createIntent(SpaceAction.OpenCreateObject, {
|
|
60
|
-
target: space,
|
|
61
|
-
navigable: false,
|
|
62
|
-
onCreateObject: (object) => {
|
|
63
|
-
board.items.push(Ref.make(object));
|
|
64
|
-
board.layout.cells[object.id] = {
|
|
65
|
-
...position,
|
|
66
|
-
width: 1,
|
|
67
|
-
height: 1
|
|
68
|
-
};
|
|
69
|
-
controller.current?.center(position);
|
|
70
|
-
}
|
|
71
|
-
}));
|
|
72
|
-
}, [
|
|
73
|
-
board,
|
|
74
|
-
controller,
|
|
75
|
-
dispatch
|
|
76
|
-
]);
|
|
77
|
-
const handleDelete = useCallback((id) => {
|
|
78
|
-
const idx = board.items.findIndex((ref) => ref.dxn.asEchoDXN()?.echoId === id);
|
|
79
|
-
if (idx !== -1) {
|
|
80
|
-
board.items.splice(idx, 1);
|
|
81
|
-
}
|
|
82
|
-
delete board.layout.cells[id];
|
|
83
|
-
setItems((items2) => items2.filter((item) => item.id !== id));
|
|
84
|
-
}, [
|
|
85
|
-
board
|
|
86
|
-
]);
|
|
87
|
-
const handleMove = useCallback((id, position) => {
|
|
88
|
-
const layout = board.layout.cells[id];
|
|
89
|
-
board.layout.cells[id] = {
|
|
90
|
-
...layout,
|
|
91
|
-
...position
|
|
92
|
-
};
|
|
93
|
-
}, [
|
|
94
|
-
board
|
|
95
|
-
]);
|
|
96
|
-
return /* @__PURE__ */ React.createElement(Board2.Root, {
|
|
97
|
-
ref: controller,
|
|
98
|
-
layout: board.layout,
|
|
99
|
-
onAdd: handleAdd,
|
|
100
|
-
onDelete: handleDelete,
|
|
101
|
-
onMove: handleMove
|
|
102
|
-
}, /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
103
|
-
toolbar: true
|
|
104
|
-
}, /* @__PURE__ */ React.createElement(Board2.Controls, null), /* @__PURE__ */ React.createElement(Board2.Container, null, /* @__PURE__ */ React.createElement(Board2.Viewport, {
|
|
105
|
-
classNames: "border-none"
|
|
106
|
-
}, /* @__PURE__ */ React.createElement(Board2.Backdrop, null), /* @__PURE__ */ React.createElement(Board2.Content, null, items?.map((item, index) => /* @__PURE__ */ React.createElement(Board2.Cell, {
|
|
107
|
-
item,
|
|
108
|
-
key: index,
|
|
109
|
-
layout: board.layout?.cells[item.id] ?? {
|
|
110
|
-
x: 0,
|
|
111
|
-
y: 0
|
|
112
|
-
}
|
|
113
|
-
}, /* @__PURE__ */ React.createElement(Surface, {
|
|
114
|
-
role: "card--extrinsic",
|
|
115
|
-
data: {
|
|
116
|
-
subject: item
|
|
117
|
-
},
|
|
118
|
-
limit: 1
|
|
119
|
-
}))))))));
|
|
120
|
-
} finally {
|
|
121
|
-
_effect.f();
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// src/capabilities/react-surface.tsx
|
|
126
|
-
var react_surface_default = (context) => contributes(Capabilities.ReactSurface, [
|
|
127
|
-
createSurface({
|
|
128
|
-
id: meta.id,
|
|
129
|
-
role: [
|
|
130
|
-
"article",
|
|
131
|
-
"section"
|
|
132
|
-
],
|
|
133
|
-
filter: (data) => Obj.instanceOf(Board.Board, data.subject),
|
|
134
|
-
component: ({ data, role }) => /* @__PURE__ */ React2.createElement(BoardContainer, {
|
|
135
|
-
board: data.subject,
|
|
136
|
-
role
|
|
137
|
-
})
|
|
138
|
-
})
|
|
139
|
-
]);
|
|
140
|
-
export {
|
|
141
|
-
react_surface_default as default
|
|
142
|
-
};
|
|
143
|
-
//# sourceMappingURL=react-surface-XFSXU2JJ.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 { createIntent, Surface, useIntentDispatcher } from '@dxos/app-framework';\nimport { getSpace } from '@dxos/client/echo';\nimport { type Obj, Ref, type Type } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceAction } from '@dxos/plugin-space/types';\nimport { Board, type BoardController, type BoardRootProps } from '@dxos/react-ui-board';\nimport { StackItem } from '@dxos/react-ui-stack';\nimport { isNonNullable } from '@dxos/util';\n\n// 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.\nimport { type Board as BoardType } from '../types';\n\nexport type BoardContainerProps = {\n role: string;\n board: BoardType.Board;\n};\n\nexport const BoardContainer = ({ role, board }: BoardContainerProps) => {\n const { dispatchPromise: dispatch } = useIntentDispatcher();\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 async (position = { x: 0, y: 0 }) => {\n const space = getSpace(board);\n invariant(space);\n await dispatch(\n createIntent(SpaceAction.OpenCreateObject, {\n target: space,\n navigable: false,\n onCreateObject: (object: Obj.Any) => {\n board.items.push(Ref.make(object));\n board.layout.cells[object.id] = { ...position, width: 1, height: 1 };\n controller.current?.center(position);\n },\n }),\n );\n },\n [board, controller, dispatch],\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 <Board.Root ref={controller} layout={board.layout} onAdd={handleAdd} onDelete={handleDelete} onMove={handleMove}>\n <StackItem.Content toolbar>\n <Board.Controls />\n <Board.Container>\n <Board.Viewport classNames='border-none'>\n <Board.Backdrop />\n <Board.Content>\n {items?.map((item, index) => (\n <Board.Cell item={item} key={index} layout={board.layout?.cells[item.id] ?? { x: 0, y: 0 }}>\n <Surface role='card--extrinsic' data={{ subject: item }} limit={1} />\n </Board.Cell>\n ))}\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A,cAAC3D,OAAM4D,MAAI;MAACf;MAAYgB,KAAKF;MAAO7B,QAAQzB,MAAMyB,QAAQC,MAAMc,KAAKb,EAAE,KAAK;QAAEZ,GAAG;QAAGC,GAAG;MAAE;OACvF,sBAAA,cAAC3B,SAAAA;MAAQU,MAAK;MAAkB0D,MAAM;QAAEC,SAASlB;MAAK;MAAGmB,OAAO;;;;;AASlF;;;AD1FA,IAAA,wBAAe,CAACC,YACdC,YAAYC,aAAaC,cAAc;EACrCC,cAAc;IACZC,IAAIC,KAAKD;IACTE,MAAM;MAAC;MAAW;;IAClBC,QAAQ,CAACC,SAA2CC,IAAIC,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", "createIntent", "Surface", "useIntentDispatcher", "getSpace", "Ref", "invariant", "SpaceAction", "Board", "StackItem", "isNonNullable", "BoardContainer", "role", "board", "dispatchPromise", "dispatch", "controller", "items", "setItems", "t", "refs", "setTimeout", "Array", "loadAll", "filter", "clearTimeout", "handleAdd", "position", "x", "y", "space", "OpenCreateObject", "target", "navigable", "onCreateObject", "object", "push", "make", "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", "Backdrop", "map", "index", "Cell", "key", "data", "subject", "limit", "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,144 +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 } 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 { createIntent, Surface, useIntentDispatcher } from "@dxos/app-framework";
|
|
17
|
-
import { getSpace } from "@dxos/client/echo";
|
|
18
|
-
import { Ref } from "@dxos/echo";
|
|
19
|
-
import { invariant } from "@dxos/invariant";
|
|
20
|
-
import { SpaceAction } from "@dxos/plugin-space/types";
|
|
21
|
-
import { Board as Board2 } from "@dxos/react-ui-board";
|
|
22
|
-
import { StackItem } from "@dxos/react-ui-stack";
|
|
23
|
-
import { isNonNullable } from "@dxos/util";
|
|
24
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-board/src/components/BoardContainer.tsx";
|
|
25
|
-
var BoardContainer = ({ role, board }) => {
|
|
26
|
-
var _effect = _useSignals();
|
|
27
|
-
try {
|
|
28
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
29
|
-
const controller = useRef(null);
|
|
30
|
-
const [items, setItems] = useState([]);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
let t;
|
|
33
|
-
effect(() => {
|
|
34
|
-
const refs = [
|
|
35
|
-
...board.items
|
|
36
|
-
];
|
|
37
|
-
t = setTimeout(async () => {
|
|
38
|
-
const items2 = await Ref.Array.loadAll(refs);
|
|
39
|
-
setItems(items2.filter(isNonNullable));
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
return () => clearTimeout(t);
|
|
43
|
-
}, [
|
|
44
|
-
board.items
|
|
45
|
-
]);
|
|
46
|
-
const handleAdd = useCallback(async (position = {
|
|
47
|
-
x: 0,
|
|
48
|
-
y: 0
|
|
49
|
-
}) => {
|
|
50
|
-
const space = getSpace(board);
|
|
51
|
-
invariant(space, void 0, {
|
|
52
|
-
F: __dxlog_file,
|
|
53
|
-
L: 47,
|
|
54
|
-
S: void 0,
|
|
55
|
-
A: [
|
|
56
|
-
"space",
|
|
57
|
-
""
|
|
58
|
-
]
|
|
59
|
-
});
|
|
60
|
-
await dispatch(createIntent(SpaceAction.OpenCreateObject, {
|
|
61
|
-
target: space,
|
|
62
|
-
navigable: false,
|
|
63
|
-
onCreateObject: (object) => {
|
|
64
|
-
board.items.push(Ref.make(object));
|
|
65
|
-
board.layout.cells[object.id] = {
|
|
66
|
-
...position,
|
|
67
|
-
width: 1,
|
|
68
|
-
height: 1
|
|
69
|
-
};
|
|
70
|
-
controller.current?.center(position);
|
|
71
|
-
}
|
|
72
|
-
}));
|
|
73
|
-
}, [
|
|
74
|
-
board,
|
|
75
|
-
controller,
|
|
76
|
-
dispatch
|
|
77
|
-
]);
|
|
78
|
-
const handleDelete = useCallback((id) => {
|
|
79
|
-
const idx = board.items.findIndex((ref) => ref.dxn.asEchoDXN()?.echoId === id);
|
|
80
|
-
if (idx !== -1) {
|
|
81
|
-
board.items.splice(idx, 1);
|
|
82
|
-
}
|
|
83
|
-
delete board.layout.cells[id];
|
|
84
|
-
setItems((items2) => items2.filter((item) => item.id !== id));
|
|
85
|
-
}, [
|
|
86
|
-
board
|
|
87
|
-
]);
|
|
88
|
-
const handleMove = useCallback((id, position) => {
|
|
89
|
-
const layout = board.layout.cells[id];
|
|
90
|
-
board.layout.cells[id] = {
|
|
91
|
-
...layout,
|
|
92
|
-
...position
|
|
93
|
-
};
|
|
94
|
-
}, [
|
|
95
|
-
board
|
|
96
|
-
]);
|
|
97
|
-
return /* @__PURE__ */ React.createElement(Board2.Root, {
|
|
98
|
-
ref: controller,
|
|
99
|
-
layout: board.layout,
|
|
100
|
-
onAdd: handleAdd,
|
|
101
|
-
onDelete: handleDelete,
|
|
102
|
-
onMove: handleMove
|
|
103
|
-
}, /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
104
|
-
toolbar: true
|
|
105
|
-
}, /* @__PURE__ */ React.createElement(Board2.Controls, null), /* @__PURE__ */ React.createElement(Board2.Container, null, /* @__PURE__ */ React.createElement(Board2.Viewport, {
|
|
106
|
-
classNames: "border-none"
|
|
107
|
-
}, /* @__PURE__ */ React.createElement(Board2.Backdrop, null), /* @__PURE__ */ React.createElement(Board2.Content, null, items?.map((item, index) => /* @__PURE__ */ React.createElement(Board2.Cell, {
|
|
108
|
-
item,
|
|
109
|
-
key: index,
|
|
110
|
-
layout: board.layout?.cells[item.id] ?? {
|
|
111
|
-
x: 0,
|
|
112
|
-
y: 0
|
|
113
|
-
}
|
|
114
|
-
}, /* @__PURE__ */ React.createElement(Surface, {
|
|
115
|
-
role: "card--extrinsic",
|
|
116
|
-
data: {
|
|
117
|
-
subject: item
|
|
118
|
-
},
|
|
119
|
-
limit: 1
|
|
120
|
-
}))))))));
|
|
121
|
-
} finally {
|
|
122
|
-
_effect.f();
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// src/capabilities/react-surface.tsx
|
|
127
|
-
var react_surface_default = (context) => contributes(Capabilities.ReactSurface, [
|
|
128
|
-
createSurface({
|
|
129
|
-
id: meta.id,
|
|
130
|
-
role: [
|
|
131
|
-
"article",
|
|
132
|
-
"section"
|
|
133
|
-
],
|
|
134
|
-
filter: (data) => Obj.instanceOf(Board.Board, data.subject),
|
|
135
|
-
component: ({ data, role }) => /* @__PURE__ */ React2.createElement(BoardContainer, {
|
|
136
|
-
board: data.subject,
|
|
137
|
-
role
|
|
138
|
-
})
|
|
139
|
-
})
|
|
140
|
-
]);
|
|
141
|
-
export {
|
|
142
|
-
react_surface_default as default
|
|
143
|
-
};
|
|
144
|
-
//# sourceMappingURL=react-surface-ZHPQBZWO.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 { createIntent, Surface, useIntentDispatcher } from '@dxos/app-framework';\nimport { getSpace } from '@dxos/client/echo';\nimport { type Obj, Ref, type Type } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceAction } from '@dxos/plugin-space/types';\nimport { Board, type BoardController, type BoardRootProps } from '@dxos/react-ui-board';\nimport { StackItem } from '@dxos/react-ui-stack';\nimport { isNonNullable } from '@dxos/util';\n\n// 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.\nimport { type Board as BoardType } from '../types';\n\nexport type BoardContainerProps = {\n role: string;\n board: BoardType.Board;\n};\n\nexport const BoardContainer = ({ role, board }: BoardContainerProps) => {\n const { dispatchPromise: dispatch } = useIntentDispatcher();\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 async (position = { x: 0, y: 0 }) => {\n const space = getSpace(board);\n invariant(space);\n await dispatch(\n createIntent(SpaceAction.OpenCreateObject, {\n target: space,\n navigable: false,\n onCreateObject: (object: Obj.Any) => {\n board.items.push(Ref.make(object));\n board.layout.cells[object.id] = { ...position, width: 1, height: 1 };\n controller.current?.center(position);\n },\n }),\n );\n },\n [board, controller, dispatch],\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 <Board.Root ref={controller} layout={board.layout} onAdd={handleAdd} onDelete={handleDelete} onMove={handleMove}>\n <StackItem.Content toolbar>\n <Board.Controls />\n <Board.Container>\n <Board.Viewport classNames='border-none'>\n <Board.Backdrop />\n <Board.Content>\n {items?.map((item, index) => (\n <Board.Cell item={item} key={index} layout={board.layout?.cells[item.id] ?? { x: 0, y: 0 }}>\n <Surface role='card--extrinsic' data={{ subject: item }} limit={1} />\n </Board.Cell>\n ))}\n </Board.Content>\n </Board.Viewport>\n </Board.Container>\n </StackItem.Content>\n </Board.Root>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAIA,OAAOA,YAAW;AAElB,SAASC,aAAaC,cAAkCC,qBAAqB;AAC7E,SAASC,WAAW;;;;ACHpB,SAASC,cAAc;AACvB,OAAOC,SAASC,aAAaC,WAAWC,QAAQC,gBAAgB;AAEhE,SAASC,cAAcC,SAASC,2BAA2B;AAC3D,SAASC,gBAAgB;AACzB,SAAmBC,WAAsB;AACzC,SAASC,iBAAiB;AAC1B,SAASC,mBAAmB;AAC5B,SAASC,SAAAA,cAAwD;AACjE,SAASC,iBAAiB;AAC1B,SAASC,qBAAqB;;AAUvB,IAAMC,iBAAiB,CAAC,EAAEC,MAAMC,MAAK,MAAuB;;;AACjE,UAAM,EAAEC,iBAAiBC,SAAQ,IAAKZ,oBAAAA;AACtC,UAAMa,aAAajB,OAAwB,IAAA;AAG3C,UAAM,CAACkB,OAAOC,QAAAA,IAAYlB,SAAyB,CAAA,CAAE;AACrDF,cAAU,MAAA;AACR,UAAIqB;AACJxB,aAAO,MAAA;AACL,cAAMyB,OAAO;aAAIP,MAAMI;;AACvBE,YAAIE,WAAW,YAAA;AACb,gBAAMJ,SAAQ,MAAMZ,IAAIiB,MAAMC,QAAQH,IAAAA;AACtCF,mBAASD,OAAMO,OAAOd,aAAAA,CAAAA;QACxB,CAAA;MACF,CAAA;AAEA,aAAO,MAAMe,aAAaN,CAAAA;IAC5B,GAAG;MAACN,MAAMI;KAAM;AAEhB,UAAMS,YAAY7B,YAChB,OAAO8B,WAAW;MAAEC,GAAG;MAAGC,GAAG;IAAE,MAAC;AAC9B,YAAMC,QAAQ1B,SAASS,KAAAA;AACvBP,gBAAUwB,OAAAA,QAAAA;;;;;;;;;AACV,YAAMf,SACJd,a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D,OAAMyD,UAAQ,IAAA,GACf,sBAAA,cAACzD,OAAMmD,SAAO,MACX1C,OAAOiD,IAAI,CAACb,MAAMc,UACjB,sBAAA,cAAC3D,OAAM4D,MAAI;MAACf;MAAYgB,KAAKF;MAAO7B,QAAQzB,MAAMyB,QAAQC,MAAMc,KAAKb,EAAE,KAAK;QAAEZ,GAAG;QAAGC,GAAG;MAAE;OACvF,sBAAA,cAAC3B,SAAAA;MAAQU,MAAK;MAAkB0D,MAAM;QAAEC,SAASlB;MAAK;MAAGmB,OAAO;;;;;AASlF;;;AD1FA,IAAA,wBAAe,CAACC,YACdC,YAAYC,aAAaC,cAAc;EACrCC,cAAc;IACZC,IAAIC,KAAKD;IACTE,MAAM;MAAC;MAAW;;IAClBC,QAAQ,CAACC,SAA2CC,IAAIC,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", "createIntent", "Surface", "useIntentDispatcher", "getSpace", "Ref", "invariant", "SpaceAction", "Board", "StackItem", "isNonNullable", "BoardContainer", "role", "board", "dispatchPromise", "dispatch", "controller", "items", "setItems", "t", "refs", "setTimeout", "Array", "loadAll", "filter", "clearTimeout", "handleAdd", "position", "x", "y", "space", "OpenCreateObject", "target", "navigable", "onCreateObject", "object", "push", "make", "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", "Backdrop", "map", "index", "Cell", "key", "data", "subject", "limit", "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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-surface.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/react-surface.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAe,YAAY,EAAE,KAAK,aAAa,EAAiB,MAAM,qBAAqB,CAAC;yBAOnF,SAAS,aAAa;AAAtC,wBAQK"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type Board as BoardType } from '../types';
|
|
3
|
-
export type BoardContainerProps = {
|
|
4
|
-
role: string;
|
|
5
|
-
board: BoardType.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;AAYxE,OAAO,EAAE,KAAK,KAAK,IAAI,SAAS,EAAE,MAAM,UAAU,CAAC;AAEnD,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,iBAAiB,mBAAmB,sBA+ElE,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import '@dxos-theme';
|
|
2
|
-
import { type StoryObj, type Meta } from '@storybook/react-vite';
|
|
3
|
-
type StoryProps = {};
|
|
4
|
-
declare const meta: Meta<StoryProps>;
|
|
5
|
-
export default meta;
|
|
6
|
-
type Story = StoryObj<StoryProps>;
|
|
7
|
-
export declare const Default: Story;
|
|
8
|
-
//# sourceMappingURL=BoardContainer.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BoardContainer.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/BoardContainer.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AA8EjE,KAAK,UAAU,GAAG,EAAE,CAAC;AAMrB,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAAU,CA6C1B,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AAElC,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC"}
|