@dxos/react-ui-mosaic 0.4.7-main.d28a540 → 0.4.7-main.e015b9e

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.
@@ -4,4 +4,5 @@ declare const _default: {
4
4
  decorators: (import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-bf5e6555").R> | import("@storybook/react").Decorator)[];
5
5
  };
6
6
  export default _default;
7
+ export declare const ECHO: {};
7
8
  //# sourceMappingURL=Echo.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Echo.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Demo/Echo.stories.tsx"],"names":[],"mappings":";;;;;AAyCA,wBA4BE"}
1
+ {"version":3,"file":"Echo.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Demo/Echo.stories.tsx"],"names":[],"mappings":";;;;;AA2CA,wBA4BE;AAIF,eAAO,MAAM,IAAI,IAAK,CAAC"}
@@ -3,10 +3,19 @@ import '@dxosTheme';
3
3
  declare const _default: {
4
4
  title: string;
5
5
  component: ({ id, Component, onOver, onDrop, items, debug }: import("./Tree").TreeProps<import("./Tree").TreeData>) => JSX.Element;
6
+ render: ({ id, debug }: {
7
+ id: string;
8
+ debug: boolean;
9
+ }) => JSX.Element;
6
10
  decorators: (import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-bf5e6555").R> | import("@storybook/react").Decorator)[];
7
11
  parameters: {
8
12
  layout: string;
9
13
  };
10
14
  };
11
15
  export default _default;
16
+ export declare const Graph: {
17
+ args: {
18
+ debug: boolean;
19
+ };
20
+ };
12
21
  //# sourceMappingURL=Graph.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Graph.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Tree/Graph.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,YAAY,CAAC;;;;;;;;;AAcpB,wBAeE"}
1
+ {"version":3,"file":"Graph.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Tree/Graph.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,YAAY,CAAC;;;;;YAiBqB,MAAM;eAAS,OAAO;;;;;;;AAH/D,wBAeE;AAEF,eAAO,MAAM,KAAK;;;;CAEjB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Graph } from '@dxos/app-graph';
1
+ import { type Graph } from '@dxos/app-graph';
2
2
  import { type TreeData, type TreeProps } from './Tree';
3
3
  export type DemoTreeProps = TreeProps & {
4
4
  initialItems?: TreeData[];
@@ -7,4 +7,9 @@ export type DemoTreeProps = TreeProps & {
7
7
  };
8
8
  export declare const DemoTree: ({ id, initialItems, types, debug }: DemoTreeProps) => JSX.Element;
9
9
  export declare const createGraph: () => Graph;
10
+ export declare const GraphTree: ({ id, graph, debug }: {
11
+ id: string;
12
+ graph?: Graph | undefined;
13
+ debug: boolean;
14
+ }) => JSX.Element;
10
15
  //# sourceMappingURL=testing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../../src/views/Tree/testing.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAIxC,OAAO,EAAQ,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAI7D,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG;IACtC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,QAAQ,uCAAiD,aAAa,gBA0DlF,CAAC;AAEF,eAAO,MAAM,WAAW,aAyBvB,CAAC"}
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../../src/views/Tree/testing.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,KAAK,EAAgB,MAAM,iBAAiB,CAAC;AAK3D,OAAO,EAAQ,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAI7D,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG;IACtC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,QAAQ,uCAAiD,aAAa,gBA0DlF,CAAC;AAEF,eAAO,MAAM,WAAW,aAqBvB,CAAC;AAEF,eAAO,MAAM,SAAS;QAAgD,MAAM;;WAAwB,OAAO;iBA+B1G,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-mosaic",
3
- "version": "0.4.7-main.d28a540",
3
+ "version": "0.4.7-main.e015b9e",
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",
@@ -25,14 +25,14 @@
25
25
  "lodash.defaultsdeep": "^4.6.1",
26
26
  "lodash.pick": "^4.4.0",
27
27
  "react-resize-detector": "^7.1.2",
28
- "@dxos/debug": "0.4.7-main.d28a540",
29
- "@dxos/invariant": "0.4.7-main.d28a540",
30
- "@dxos/react-ui": "0.4.7-main.d28a540",
31
- "@dxos/keys": "0.4.7-main.d28a540",
32
- "@dxos/react-ui-card": "0.4.7-main.d28a540",
33
- "@dxos/react-ui-theme": "0.4.7-main.d28a540",
34
- "@dxos/util": "0.4.7-main.d28a540",
35
- "@dxos/react-ui-types": "0.4.7-main.d28a540"
28
+ "@dxos/debug": "0.4.7-main.e015b9e",
29
+ "@dxos/keys": "0.4.7-main.e015b9e",
30
+ "@dxos/invariant": "0.4.7-main.e015b9e",
31
+ "@dxos/react-ui-card": "0.4.7-main.e015b9e",
32
+ "@dxos/react-ui": "0.4.7-main.e015b9e",
33
+ "@dxos/react-ui-theme": "0.4.7-main.e015b9e",
34
+ "@dxos/react-ui-types": "0.4.7-main.e015b9e",
35
+ "@dxos/util": "0.4.7-main.e015b9e"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@phosphor-icons/react": "^2.0.5",
@@ -46,12 +46,12 @@
46
46
  "react-dom": "^18.2.0",
47
47
  "vite": "^5.1.3",
48
48
  "vite-plugin-turbosnap": "^1.0.2",
49
- "@dxos/app-graph": "0.4.7-main.d28a540",
50
- "@dxos/echo-schema": "0.4.7-main.d28a540",
51
- "@dxos/random": "0.4.7-main.d28a540",
52
- "@dxos/gem-core": "0.4.7-main.d28a540",
53
- "@dxos/react-client": "0.4.7-main.d28a540",
54
- "@dxos/storybook-utils": "0.4.7-main.d28a540"
49
+ "@dxos/app-graph": "0.4.7-main.e015b9e",
50
+ "@dxos/gem-core": "0.4.7-main.e015b9e",
51
+ "@dxos/echo-schema": "0.4.7-main.e015b9e",
52
+ "@dxos/random": "0.4.7-main.e015b9e",
53
+ "@dxos/react-client": "0.4.7-main.e015b9e",
54
+ "@dxos/storybook-utils": "0.4.7-main.e015b9e"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@phosphor-icons/react": "^2.0.5",
@@ -13,7 +13,7 @@ import { withTheme } from '@dxos/storybook-utils';
13
13
  import { Mosaic } from '../../mosaic';
14
14
  import { FullscreenDecorator, TestObjectGenerator, range, Status, Priority } from '../../testing';
15
15
  import { EchoKanban } from '../Kanban/testing';
16
- // import { GraphTree } from '../Tree/testing';
16
+ import { GraphTree } from '../Tree/testing';
17
17
 
18
18
  faker.seed(3);
19
19
  const debug = true;
@@ -30,7 +30,9 @@ const Story: FC<{ spaceKey: PublicKey }> = ({ spaceKey }) => {
30
30
  <Mosaic.Root debug={debug}>
31
31
  <Mosaic.DragOverlay />
32
32
  <div className='flex grow overflow-hidden'>
33
- <div className='flex shrink-0 w-[280px] overflow-hidden'>{/* <GraphTree id='graph' debug={debug} /> */}</div>
33
+ <div className='flex shrink-0 w-[280px] overflow-hidden'>
34
+ <GraphTree id='graph' debug={debug} />
35
+ </div>
34
36
  <div className='flex grow overflow-hidden'>
35
37
  <EchoKanban id='projects' spaceKey={spaceKey} generator={generator} debug={debug} />
36
38
  </div>
@@ -71,4 +73,4 @@ export default {
71
73
 
72
74
  // TODO(wittjosiah): This currently has a bug where empty over events are fired when dragging from tree onto kanban.
73
75
  // The bug didn't exist before the cleanup refactor so seems likely it's a side effect of that.
74
- // export const ECHO = {};
76
+ export const ECHO = {};
@@ -4,14 +4,14 @@
4
4
 
5
5
  import '@dxosTheme';
6
6
 
7
- // import React from 'react';
7
+ import React from 'react';
8
8
 
9
9
  import { faker } from '@dxos/random';
10
10
  import { withTheme } from '@dxos/storybook-utils';
11
11
 
12
12
  import { Tree } from './Tree';
13
- // import { GraphTree } from './testing';
14
- // import { Mosaic } from '../../mosaic';
13
+ import { GraphTree } from './testing';
14
+ import { Mosaic } from '../../mosaic';
15
15
  import { FullscreenDecorator } from '../../testing';
16
16
 
17
17
  faker.seed(3);
@@ -19,20 +19,20 @@ faker.seed(3);
19
19
  export default {
20
20
  title: 'react-ui-mosaic/Tree',
21
21
  component: Tree,
22
- // render: ({ id = 'tree', debug }: { id: string; debug: boolean }) => {
23
- // return (
24
- // <Mosaic.Root debug={debug}>
25
- // <Mosaic.DragOverlay />
26
- // <GraphTree id={id} debug={debug} />
27
- // </Mosaic.Root>
28
- // );
29
- // },
22
+ render: ({ id = 'tree', debug }: { id: string; debug: boolean }) => {
23
+ return (
24
+ <Mosaic.Root debug={debug}>
25
+ <Mosaic.DragOverlay />
26
+ <GraphTree id={id} debug={debug} />
27
+ </Mosaic.Root>
28
+ );
29
+ },
30
30
  decorators: [withTheme, FullscreenDecorator()],
31
31
  parameters: {
32
32
  layout: 'fullscreen',
33
33
  },
34
34
  };
35
35
 
36
- // export const Graph = {
37
- // args: { debug: true },
38
- // };
36
+ export const Graph = {
37
+ args: { debug: true },
38
+ };
@@ -4,12 +4,13 @@
4
4
 
5
5
  import React, { useCallback, useState } from 'react';
6
6
 
7
- import { Graph } from '@dxos/app-graph';
7
+ import { type Graph, GraphBuilder } from '@dxos/app-graph';
8
+ import { buildGraph } from '@dxos/app-graph/testing';
8
9
  import { faker } from '@dxos/random';
9
10
  import { arrayMove } from '@dxos/util';
10
11
 
11
12
  import { Tree, type TreeData, type TreeProps } from './Tree';
12
- import { type MosaicDropEvent, type MosaicMoveEvent, Path } from '../../mosaic';
13
+ import { type MosaicDropEvent, type MosaicMoveEvent, Path, type MosaicOperation } from '../../mosaic';
13
14
  import { TestObjectGenerator } from '../../testing';
14
15
 
15
16
  export type DemoTreeProps = TreeProps & {
@@ -79,64 +80,57 @@ export const DemoTree = ({ id = 'tree', initialItems, types, debug }: DemoTreePr
79
80
  };
80
81
 
81
82
  export const createGraph = () => {
82
- const graph = new Graph();
83
- graph.addNodes({
84
- id: 'root',
85
- nodes: [Array(2)].map((_, i) => ({
83
+ const content = [...Array(2)].map((_, i) => ({
84
+ id: faker.string.hexadecimal({ length: 4 }).slice(2).toUpperCase(),
85
+ label: faker.lorem.words(2),
86
+ description: faker.lorem.sentence(),
87
+ properties: { index: `a${i}` },
88
+ children: [...Array(2)].map((_, j) => ({
86
89
  id: faker.string.hexadecimal({ length: 4 }).slice(2).toUpperCase(),
87
90
  label: faker.lorem.words(2),
88
91
  description: faker.lorem.sentence(),
89
- properties: { index: `a${i}` },
90
- children: [...Array(2)].map((_, j) => ({
92
+ properties: { index: `a${j}` },
93
+ children: [...Array(2)].map((_, k) => ({
91
94
  id: faker.string.hexadecimal({ length: 4 }).slice(2).toUpperCase(),
92
95
  label: faker.lorem.words(2),
93
96
  description: faker.lorem.sentence(),
94
- properties: { index: `a${j}` },
95
- children: [...Array(2)].map((_, k) => ({
96
- id: faker.string.hexadecimal({ length: 4 }).slice(2).toUpperCase(),
97
- label: faker.lorem.words(2),
98
- description: faker.lorem.sentence(),
99
- properties: { index: `a${k}` },
100
- })),
97
+ properties: { index: `a${k}` },
101
98
  })),
102
99
  })),
103
- });
100
+ }));
104
101
 
105
- return graph;
102
+ return buildGraph(new GraphBuilder().build(), 'tree', content);
106
103
  };
107
104
 
108
- // TODO(wittjosiah): This needs to be updated for the new graph api.
109
- // Left it for now because the tree needs to be re-implemented flat.
110
-
111
- // export const GraphTree = ({ id, graph = createGraph(), debug }: { id: string; graph?: Graph; debug: boolean }) => {
112
- // const handleDrop = ({ operation, active, over }: MosaicDropEvent<number>) => {
113
- // // Moving within the tree.
114
- // if (Path.hasDescendent(id, active.path) && Path.hasDescendent(id, over.path)) {
115
- // const activeNode = graph.findNode(active.item.id);
116
- // const overNode = graph.findNode(over.item.id);
117
- // const activeParent = activeNode?.parent;
118
- // const overParent = overNode?.parent;
119
- // if (
120
- // activeNode &&
121
- // overNode &&
122
- // activeParent &&
123
- // overParent &&
124
- // activeParent.id === overParent.id &&
125
- // activeNode.id !== overNode.id &&
126
- // operation === 'rearrange'
127
- // ) {
128
- // // This is a rearrange operation
129
- // console.warn('[react-ui-mosaic]', 'Tree', 'rearrange', 'needs implementation');
130
- // } else if (activeNode && activeParent && overParent && operation === 'transfer') {
131
- // activeParent.removeNode(active.item.id);
132
- // overNode.addNode('tree', { ...activeNode });
133
- // }
134
- // }
135
- // };
105
+ export const GraphTree = ({ id, graph = createGraph(), debug }: { id: string; graph?: Graph; debug: boolean }) => {
106
+ const handleDrop = ({ operation, active, over }: MosaicDropEvent<number>) => {
107
+ // Moving within the tree.
108
+ if (Path.hasDescendent(id, active.path) && Path.hasDescendent(id, over.path)) {
109
+ const activeNode = graph.findNode(active.item.id);
110
+ const overNode = graph.findNode(over.item.id);
111
+ const activeParent = activeNode?.parent;
112
+ const overParent = overNode?.parent;
113
+ if (
114
+ activeNode &&
115
+ overNode &&
116
+ activeParent &&
117
+ overParent &&
118
+ activeParent.id === overParent.id &&
119
+ activeNode.id !== overNode.id &&
120
+ operation === 'rearrange'
121
+ ) {
122
+ // This is a rearrange operation
123
+ console.warn('[react-ui-mosaic]', 'Tree', 'rearrange', 'needs implementation');
124
+ } else if (activeNode && activeParent && overParent && operation === 'transfer') {
125
+ activeParent.removeNode(active.item.id);
126
+ overNode.addNode('tree', { ...activeNode });
127
+ }
128
+ }
129
+ };
136
130
 
137
- // const handleOver = (): MosaicOperation => 'transfer';
131
+ const handleOver = (): MosaicOperation => 'transfer';
138
132
 
139
- // return (
140
- // <Tree id={id} items={graph.root.children as TreeData[]} onDrop={handleDrop} onOver={handleOver} debug={debug} />
141
- // );
142
- // };
133
+ return (
134
+ <Tree id={id} items={graph.root.children as TreeData[]} onDrop={handleDrop} onOver={handleOver} debug={debug} />
135
+ );
136
+ };