@dxos/react-ui-mosaic 0.4.10-main.fa5a270 → 0.4.10-main.fda6f37
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/index.mjs +9 -7
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/mosaic/Container.d.ts +1 -1
- package/dist/types/src/mosaic/Container.d.ts.map +1 -1
- package/dist/types/src/mosaic/Tile.d.ts +22 -1
- package/dist/types/src/mosaic/Tile.d.ts.map +1 -1
- package/dist/types/src/testing/generator.d.ts +4 -5
- package/dist/types/src/testing/generator.d.ts.map +1 -1
- package/dist/types/src/views/Demo/Echo.stories.d.ts.map +1 -1
- package/dist/types/src/views/Kanban/testing.d.ts +0 -8
- package/dist/types/src/views/Kanban/testing.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/mosaic/Container.tsx +1 -1
- package/src/mosaic/Tile.tsx +30 -32
- package/src/testing/generator.ts +35 -28
- package/src/views/Demo/Echo.stories.tsx +5 -4
- package/src/views/Kanban/Echo.stories.tsx +23 -23
- package/src/views/Kanban/testing.tsx +149 -153
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { type FC } from 'react';
|
|
2
|
-
import { type PublicKey } from '@dxos/react-client';
|
|
3
2
|
import { type KanbanProps } from './Kanban';
|
|
4
|
-
import { TestObjectGenerator } from '../../testing';
|
|
5
3
|
export type DemoKanbanProps = Omit<KanbanProps, 'columns'> & {
|
|
6
4
|
types?: string[];
|
|
7
5
|
count?: number;
|
|
@@ -11,10 +9,4 @@ export declare const DemoKanban: FC<DemoKanbanProps>;
|
|
|
11
9
|
export declare const columnValues: {
|
|
12
10
|
[property: string]: any[];
|
|
13
11
|
};
|
|
14
|
-
export declare const EchoKanban: ({ id, spaceKey, generator, debug, }: {
|
|
15
|
-
id: string;
|
|
16
|
-
spaceKey: PublicKey;
|
|
17
|
-
generator: TestObjectGenerator;
|
|
18
|
-
debug?: boolean | undefined;
|
|
19
|
-
}) => JSX.Element;
|
|
20
12
|
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../../src/views/Kanban/testing.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../../src/views/Kanban/testing.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAE,KAAK,EAAE,EAAY,MAAM,OAAO,CAAC;AAIjD,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAavE,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG;IAC3D,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA6C1C,CAAC;AAGF,eAAO,MAAM,YAAY,EAAE;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,EAAE,CAAA;CAGrD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-mosaic",
|
|
3
|
-
"version": "0.4.10-main.
|
|
3
|
+
"version": "0.4.10-main.fda6f37",
|
|
4
4
|
"description": "An intermediate interface for drag-and-drop interactions.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"lodash.defaultsdeep": "^4.6.1",
|
|
25
25
|
"lodash.pick": "^4.4.0",
|
|
26
26
|
"react-resize-detector": "^7.1.2",
|
|
27
|
-
"@dxos/
|
|
28
|
-
"@dxos/
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/react-ui
|
|
32
|
-
"@dxos/react-ui-card": "0.4.10-main.
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/react-ui-types": "0.4.10-main.
|
|
35
|
-
"@dxos/
|
|
27
|
+
"@dxos/debug": "0.4.10-main.fda6f37",
|
|
28
|
+
"@dxos/keys": "0.4.10-main.fda6f37",
|
|
29
|
+
"@dxos/log": "0.4.10-main.fda6f37",
|
|
30
|
+
"@dxos/invariant": "0.4.10-main.fda6f37",
|
|
31
|
+
"@dxos/react-ui": "0.4.10-main.fda6f37",
|
|
32
|
+
"@dxos/react-ui-card": "0.4.10-main.fda6f37",
|
|
33
|
+
"@dxos/react-ui-theme": "0.4.10-main.fda6f37",
|
|
34
|
+
"@dxos/react-ui-types": "0.4.10-main.fda6f37",
|
|
35
|
+
"@dxos/util": "0.4.10-main.fda6f37"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@phosphor-icons/react": "^2.0.5",
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
"d3": "^7.8.5",
|
|
45
45
|
"react": "^18.2.0",
|
|
46
46
|
"react-dom": "^18.2.0",
|
|
47
|
-
"vite": "^5.
|
|
47
|
+
"vite": "^5.2.9",
|
|
48
48
|
"vite-plugin-turbosnap": "^1.0.2",
|
|
49
|
-
"@dxos/app-graph": "0.4.10-main.
|
|
50
|
-
"@dxos/echo-schema": "0.4.10-main.
|
|
51
|
-
"@dxos/gem-core": "0.4.10-main.
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/storybook-utils": "0.4.10-main.
|
|
54
|
-
"@dxos/
|
|
49
|
+
"@dxos/app-graph": "0.4.10-main.fda6f37",
|
|
50
|
+
"@dxos/echo-schema": "0.4.10-main.fda6f37",
|
|
51
|
+
"@dxos/gem-core": "0.4.10-main.fda6f37",
|
|
52
|
+
"@dxos/random": "0.4.10-main.fda6f37",
|
|
53
|
+
"@dxos/storybook-utils": "0.4.10-main.fda6f37",
|
|
54
|
+
"@dxos/react-client": "0.4.10-main.fda6f37"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@phosphor-icons/react": "^2.0.5",
|
package/src/mosaic/Container.tsx
CHANGED
|
@@ -52,7 +52,7 @@ export type MosaicDropEvent<TPosition = unknown> = MosaicMoveEvent<TPosition> &
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
export type MosaicContainerProps<TData extends MosaicDataItem = MosaicDataItem, TPosition = unknown> = ThemedClassName<
|
|
55
|
-
Omit<HTMLAttributes<HTMLElement>, 'onDrop'>
|
|
55
|
+
Omit<HTMLAttributes<HTMLElement>, 'onDrop' | 'onSelect'>
|
|
56
56
|
> &
|
|
57
57
|
PropsWithChildren<{
|
|
58
58
|
id: string;
|
package/src/mosaic/Tile.tsx
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { type DraggableAttributes, useDraggable, useDroppable } from '@dnd-kit/core';
|
|
6
6
|
import { defaultAnimateLayoutChanges, useSortable } from '@dnd-kit/sortable';
|
|
7
|
-
import
|
|
7
|
+
import { useComposedRefs } from '@radix-ui/react-compose-refs';
|
|
8
|
+
import React, { forwardRef } from 'react';
|
|
8
9
|
import type { CSSProperties, ForwardRefExoticComponent, HTMLAttributes, RefAttributes } from 'react';
|
|
9
10
|
|
|
10
11
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
@@ -106,37 +107,34 @@ export const DraggableTile = ({
|
|
|
106
107
|
/**
|
|
107
108
|
* Basic droppable mosaic tile.
|
|
108
109
|
*/
|
|
109
|
-
export const DroppableTile = (
|
|
110
|
-
path: parentPath,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
/>
|
|
138
|
-
);
|
|
139
|
-
};
|
|
110
|
+
export const DroppableTile = forwardRef<HTMLDivElement | null, MosaicTileProps<any>>(
|
|
111
|
+
({ path: parentPath, type = DEFAULT_TYPE, item, Component = DefaultComponent, position, ...props }, forwardedRef) => {
|
|
112
|
+
const { operation } = useMosaic();
|
|
113
|
+
const path =
|
|
114
|
+
parentPath === item.id
|
|
115
|
+
? parentPath // If the path is the same as the item id, then this is the root tile.
|
|
116
|
+
: Path.create(parentPath, item.id);
|
|
117
|
+
const { setNodeRef, isOver } = useDroppable({
|
|
118
|
+
id: path,
|
|
119
|
+
data: { path, type, item, position } satisfies MosaicDraggedItem,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const ref = useComposedRefs<HTMLDivElement | null>(setNodeRef, forwardedRef);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<Component
|
|
126
|
+
item={item}
|
|
127
|
+
path={path}
|
|
128
|
+
type={type}
|
|
129
|
+
position={position}
|
|
130
|
+
operation={operation}
|
|
131
|
+
isOver={isOver}
|
|
132
|
+
{...props}
|
|
133
|
+
ref={ref}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
},
|
|
137
|
+
);
|
|
140
138
|
|
|
141
139
|
/**
|
|
142
140
|
* Mosaic tile that can be sorted.
|
package/src/testing/generator.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
// TODO(burdon): Reconcile with @dxos/echo-generator.
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import type { EchoReactiveObject, S } from '@dxos/echo-schema';
|
|
8
|
+
import { create } from '@dxos/echo-schema';
|
|
9
9
|
import { faker } from '@dxos/random';
|
|
10
10
|
|
|
11
11
|
// TODO(burdon): Util.
|
|
@@ -17,12 +17,12 @@ export const range = <T>(fn: (i: number) => T | undefined, length: number): T[]
|
|
|
17
17
|
export type TestItem = { id: string; type: string } & Record<string, any>;
|
|
18
18
|
|
|
19
19
|
type ObjectDataGenerator = {
|
|
20
|
-
createSchema?: () => Schema
|
|
20
|
+
createSchema?: () => S.Schema<any>;
|
|
21
21
|
createData: () => any;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
type ObjectFactory<T extends
|
|
25
|
-
schema?: Schema
|
|
24
|
+
type ObjectFactory<T extends EchoReactiveObject<any>> = {
|
|
25
|
+
schema?: S.Schema<any>; // TODO(burdon): Support both typed and expando schema.
|
|
26
26
|
createObject: () => T;
|
|
27
27
|
};
|
|
28
28
|
|
|
@@ -32,7 +32,7 @@ const createFactory = ({ createSchema, createData }: ObjectDataGenerator) => {
|
|
|
32
32
|
const schema = createSchema?.();
|
|
33
33
|
return {
|
|
34
34
|
schema,
|
|
35
|
-
createObject: () =>
|
|
35
|
+
createObject: () => (schema ? create(schema, createData()) : create(createData())),
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
|
|
@@ -57,27 +57,34 @@ const defaultGenerators: { [type: string]: ObjectDataGenerator } = {
|
|
|
57
57
|
},
|
|
58
58
|
|
|
59
59
|
project: {
|
|
60
|
-
createSchema: () =>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
60
|
+
// createSchema: () =>
|
|
61
|
+
// return object(StoredEchoSchema, {
|
|
62
|
+
// typename: 'Project',
|
|
63
|
+
// version: '0.1.0',
|
|
64
|
+
// jsonSchema: effectToJsonSchema(
|
|
65
|
+
//
|
|
66
|
+
// ),
|
|
67
|
+
// })
|
|
68
|
+
// new Schema({
|
|
69
|
+
// props: [
|
|
70
|
+
// {
|
|
71
|
+
// id: 'title',
|
|
72
|
+
// type: Schema.PropType.STRING,
|
|
73
|
+
// },
|
|
74
|
+
// {
|
|
75
|
+
// id: 'repo',
|
|
76
|
+
// type: Schema.PropType.STRING,
|
|
77
|
+
// },
|
|
78
|
+
// {
|
|
79
|
+
// id: 'status',
|
|
80
|
+
// type: Schema.PropType.STRING,
|
|
81
|
+
// },
|
|
82
|
+
// {
|
|
83
|
+
// id: 'priority',
|
|
84
|
+
// type: Schema.PropType.NUMBER,
|
|
85
|
+
// },
|
|
86
|
+
// ],
|
|
87
|
+
// }),
|
|
81
88
|
createData: () => ({
|
|
82
89
|
title: faker.commerce.productName(),
|
|
83
90
|
repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,
|
|
@@ -102,7 +109,7 @@ export class TestObjectGenerator {
|
|
|
102
109
|
}, {});
|
|
103
110
|
}
|
|
104
111
|
|
|
105
|
-
get schema(): Schema[] {
|
|
112
|
+
get schema(): S.Schema<any>[] {
|
|
106
113
|
return Object.values(this.factories).map((f) => f.schema!);
|
|
107
114
|
}
|
|
108
115
|
|
|
@@ -6,13 +6,14 @@ import React, { type FC } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { faker } from '@dxos/random';
|
|
8
8
|
import { type PublicKey } from '@dxos/react-client';
|
|
9
|
-
import {
|
|
9
|
+
import { create } from '@dxos/react-client/echo';
|
|
10
10
|
import { ClientRepeater } from '@dxos/react-client/testing';
|
|
11
11
|
import { withTheme } from '@dxos/storybook-utils';
|
|
12
12
|
|
|
13
13
|
import { Mosaic } from '../../mosaic';
|
|
14
14
|
import { FullscreenDecorator, TestObjectGenerator, range, Status, Priority } from '../../testing';
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
// import { EchoKanban } from '../Kanban/testing';
|
|
16
17
|
// import { GraphTree } from '../Tree/testing';
|
|
17
18
|
|
|
18
19
|
faker.seed(3);
|
|
@@ -32,7 +33,7 @@ const Story: FC<{ spaceKey: PublicKey }> = ({ spaceKey }) => {
|
|
|
32
33
|
<div className='flex grow overflow-hidden'>
|
|
33
34
|
<div className='flex shrink-0 w-[280px] overflow-hidden'>{/* <GraphTree id='graph' debug={debug} /> */}</div>
|
|
34
35
|
<div className='flex grow overflow-hidden'>
|
|
35
|
-
<EchoKanban id='projects' spaceKey={spaceKey} generator={generator} debug={debug} />
|
|
36
|
+
{/* <EchoKanban id='projects' spaceKey={spaceKey} generator={generator} debug={debug} /> */}
|
|
36
37
|
</div>
|
|
37
38
|
</div>
|
|
38
39
|
</Mosaic.Root>
|
|
@@ -49,7 +50,7 @@ export default {
|
|
|
49
50
|
const objects = [
|
|
50
51
|
factory.schema,
|
|
51
52
|
...range(factory.createObject, 10),
|
|
52
|
-
|
|
53
|
+
create({
|
|
53
54
|
type: 'kanban',
|
|
54
55
|
title: 'Projects',
|
|
55
56
|
schema: factory.schema,
|
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { type PublicKey } from '@dxos/react-client';
|
|
8
|
-
import { Expando } from '@dxos/react-client/echo';
|
|
8
|
+
// import { Expando } from '@dxos/react-client/echo';
|
|
9
9
|
import { ClientRepeater } from '@dxos/react-client/testing';
|
|
10
10
|
import { withTheme } from '@dxos/storybook-utils';
|
|
11
11
|
|
|
12
12
|
import { Kanban } from './Kanban';
|
|
13
|
-
import { EchoKanban, columnValues } from './testing';
|
|
13
|
+
// import { EchoKanban, columnValues } from './testing';
|
|
14
14
|
import { Mosaic } from '../../mosaic';
|
|
15
|
-
import { FullscreenDecorator
|
|
15
|
+
import { FullscreenDecorator /* TestObjectGenerator, range */ } from '../../testing';
|
|
16
16
|
|
|
17
|
-
const generator = new TestObjectGenerator();
|
|
17
|
+
// const generator = new TestObjectGenerator();
|
|
18
18
|
|
|
19
19
|
const Story = ({
|
|
20
20
|
// TODO(wittjosiah): Can't use id because of ClientSpaceDecorator.
|
|
@@ -29,7 +29,7 @@ const Story = ({
|
|
|
29
29
|
return (
|
|
30
30
|
<Mosaic.Root debug={debug}>
|
|
31
31
|
<Mosaic.DragOverlay />
|
|
32
|
-
<EchoKanban id={basePath} spaceKey={spaceKey} generator={generator} debug={debug} />
|
|
32
|
+
{/* <EchoKanban id={basePath} spaceKey={spaceKey} generator={generator} debug={debug} /> */}
|
|
33
33
|
</Mosaic.Root>
|
|
34
34
|
);
|
|
35
35
|
};
|
|
@@ -39,25 +39,25 @@ export default {
|
|
|
39
39
|
component: Kanban,
|
|
40
40
|
render: () => (
|
|
41
41
|
<ClientRepeater
|
|
42
|
-
onCreateSpace={async (space) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
// onCreateSpace={async (space) => {
|
|
43
|
+
// const factory = generator.factories.project;
|
|
44
|
+
// const objects = [
|
|
45
|
+
// factory.schema,
|
|
46
|
+
// ...range(factory.createObject, 10),
|
|
47
|
+
// new Expando({
|
|
48
|
+
// type: 'kanban',
|
|
49
|
+
// title: 'Projects',
|
|
50
|
+
// schema: factory.schema,
|
|
51
|
+
// // TODO(burdon): Standardize with other story.
|
|
52
|
+
// columnProp: 'status',
|
|
53
|
+
// columnValues: columnValues.status,
|
|
54
|
+
// objectPosition: {}, // TODO(burdon): Make this a CRDT.
|
|
55
|
+
// }),
|
|
56
|
+
// ];
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}}
|
|
58
|
+
// // TODO(burdon): Batch API.
|
|
59
|
+
// objects.forEach((object) => space.db.add(object));
|
|
60
|
+
// }}
|
|
61
61
|
component={Story}
|
|
62
62
|
createSpace
|
|
63
63
|
/>
|