@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
|
@@ -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,94 +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 { getSpace } from '@dxos/client/echo';
|
|
9
|
-
import { Obj, Ref, Type } from '@dxos/echo';
|
|
10
|
-
import { invariant } from '@dxos/invariant';
|
|
11
|
-
import { Board as BoardComponent, type BoardController, type BoardRootProps } from '@dxos/react-ui-board';
|
|
12
|
-
import { StackItem } from '@dxos/react-ui-stack';
|
|
13
|
-
import { isNonNullable } from '@dxos/util';
|
|
14
|
-
|
|
15
|
-
import { type Board } from '../types';
|
|
16
|
-
|
|
17
|
-
export type BoardContainerProps = {
|
|
18
|
-
role: string;
|
|
19
|
-
board: Board.Board;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const BoardContainer = ({ role, board }: BoardContainerProps) => {
|
|
23
|
-
const controller = useRef<BoardController>(null);
|
|
24
|
-
|
|
25
|
-
// TODO(burdon): Create effect utility for reactive arrays.
|
|
26
|
-
const [items, setItems] = useState<Type.Expando[]>([]);
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
let t: NodeJS.Timeout;
|
|
29
|
-
effect(() => {
|
|
30
|
-
const refs = [...board.items];
|
|
31
|
-
t = setTimeout(async () => {
|
|
32
|
-
const items = await Ref.Array.loadAll(refs);
|
|
33
|
-
setItems(items.filter(isNonNullable));
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return () => clearTimeout(t);
|
|
38
|
-
}, [board.items]);
|
|
39
|
-
|
|
40
|
-
const handleAdd = useCallback<NonNullable<BoardRootProps['onAdd']>>(
|
|
41
|
-
(position = { x: 0, y: 0 }) => {
|
|
42
|
-
const space = getSpace(board);
|
|
43
|
-
invariant(space);
|
|
44
|
-
// TODO(burdon): Create from menu/intent?
|
|
45
|
-
const obj = space.db.add(Obj.make(Type.Expando, {}));
|
|
46
|
-
board.items.push(Ref.make(obj));
|
|
47
|
-
board.layout.cells[obj.id] = { ...position, width: 1, height: 1 };
|
|
48
|
-
controller.current?.center(position);
|
|
49
|
-
},
|
|
50
|
-
[board, controller],
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
// TODO(burdon): Use intents so can be undone.
|
|
54
|
-
const handleDelete = useCallback<NonNullable<BoardRootProps['onDelete']>>(
|
|
55
|
-
(id) => {
|
|
56
|
-
// TODO(burdon): Impl. DXN.equals and pass in DXN from `id`.
|
|
57
|
-
const idx = board.items.findIndex((ref) => ref.dxn.asEchoDXN()?.echoId === id);
|
|
58
|
-
if (idx !== -1) {
|
|
59
|
-
board.items.splice(idx, 1);
|
|
60
|
-
}
|
|
61
|
-
delete board.layout.cells[id];
|
|
62
|
-
setItems((items) => items.filter((item) => item.id !== id));
|
|
63
|
-
},
|
|
64
|
-
[board],
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const handleMove = useCallback<NonNullable<BoardRootProps['onMove']>>(
|
|
68
|
-
(id, position) => {
|
|
69
|
-
const layout = board.layout.cells[id];
|
|
70
|
-
board.layout.cells[id] = { ...layout, ...position };
|
|
71
|
-
},
|
|
72
|
-
[board],
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<BoardComponent.Root
|
|
77
|
-
ref={controller}
|
|
78
|
-
layout={board.layout}
|
|
79
|
-
onAdd={handleAdd}
|
|
80
|
-
onDelete={handleDelete}
|
|
81
|
-
onMove={handleMove}
|
|
82
|
-
>
|
|
83
|
-
<StackItem.Content role={role} toolbar>
|
|
84
|
-
<BoardComponent.Controls />
|
|
85
|
-
<BoardComponent.Container>
|
|
86
|
-
<BoardComponent.Viewport classNames='border-none'>
|
|
87
|
-
<BoardComponent.Background />
|
|
88
|
-
<BoardComponent.Content items={items} getTitle={(item) => Obj.getLabel(item) ?? item.id} />
|
|
89
|
-
</BoardComponent.Viewport>
|
|
90
|
-
</BoardComponent.Container>
|
|
91
|
-
</StackItem.Content>
|
|
92
|
-
</BoardComponent.Root>
|
|
93
|
-
);
|
|
94
|
-
};
|
package/src/types/schema.ts
DELETED
|
@@ -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
|
-
}
|