@dxos/react-ui-mosaic 0.4.6 → 0.4.7-main.06facb4

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,5 +4,4 @@ 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: {};
8
7
  //# 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":";;;;;AA2CA,wBA4BE;AAIF,eAAO,MAAM,IAAI,IAAK,CAAC"}
1
+ {"version":3,"file":"Echo.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Demo/Echo.stories.tsx"],"names":[],"mappings":";;;;;AAyCA,wBA4BE"}
@@ -3,19 +3,10 @@ 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;
10
6
  decorators: (import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-bf5e6555").R> | import("@storybook/react").Decorator)[];
11
7
  parameters: {
12
8
  layout: string;
13
9
  };
14
10
  };
15
11
  export default _default;
16
- export declare const Graph: {
17
- args: {
18
- debug: boolean;
19
- };
20
- };
21
12
  //# 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;;;;;YAiBqB,MAAM;eAAS,OAAO;;;;;;;AAH/D,wBAeE;AAEF,eAAO,MAAM,KAAK;;;;CAEjB,CAAC"}
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,4 +1,4 @@
1
- import { type Graph } from '@dxos/app-graph';
1
+ import { 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,9 +7,4 @@ 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;
15
10
  //# 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,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"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-mosaic",
3
- "version": "0.4.6",
3
+ "version": "0.4.7-main.06facb4",
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.6",
29
- "@dxos/invariant": "0.4.6",
30
- "@dxos/keys": "0.4.6",
31
- "@dxos/react-ui-theme": "0.4.6",
32
- "@dxos/react-ui": "0.4.6",
33
- "@dxos/react-ui-card": "0.4.6",
34
- "@dxos/react-ui-types": "0.4.6",
35
- "@dxos/util": "0.4.6"
28
+ "@dxos/debug": "0.4.7-main.06facb4",
29
+ "@dxos/invariant": "0.4.7-main.06facb4",
30
+ "@dxos/keys": "0.4.7-main.06facb4",
31
+ "@dxos/react-ui-card": "0.4.7-main.06facb4",
32
+ "@dxos/react-ui-theme": "0.4.7-main.06facb4",
33
+ "@dxos/react-ui": "0.4.7-main.06facb4",
34
+ "@dxos/react-ui-types": "0.4.7-main.06facb4",
35
+ "@dxos/util": "0.4.7-main.06facb4"
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.6",
50
- "@dxos/echo-schema": "0.4.6",
51
- "@dxos/random": "0.4.6",
52
- "@dxos/react-client": "0.4.6",
53
- "@dxos/gem-core": "0.4.6",
54
- "@dxos/storybook-utils": "0.4.6"
49
+ "@dxos/app-graph": "0.4.7-main.06facb4",
50
+ "@dxos/echo-schema": "0.4.7-main.06facb4",
51
+ "@dxos/gem-core": "0.4.7-main.06facb4",
52
+ "@dxos/random": "0.4.7-main.06facb4",
53
+ "@dxos/storybook-utils": "0.4.7-main.06facb4",
54
+ "@dxos/react-client": "0.4.7-main.06facb4"
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,9 +30,7 @@ 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'>
34
- <GraphTree id='graph' debug={debug} />
35
- </div>
33
+ <div className='flex shrink-0 w-[280px] overflow-hidden'>{/* <GraphTree id='graph' debug={debug} /> */}</div>
36
34
  <div className='flex grow overflow-hidden'>
37
35
  <EchoKanban id='projects' spaceKey={spaceKey} generator={generator} debug={debug} />
38
36
  </div>
@@ -73,4 +71,4 @@ export default {
73
71
 
74
72
  // TODO(wittjosiah): This currently has a bug where empty over events are fired when dragging from tree onto kanban.
75
73
  // The bug didn't exist before the cleanup refactor so seems likely it's a side effect of that.
76
- export const ECHO = {};
74
+ // 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,13 +4,12 @@
4
4
 
5
5
  import React, { useCallback, useState } from 'react';
6
6
 
7
- import { type Graph, GraphBuilder } from '@dxos/app-graph';
8
- import { buildGraph } from '@dxos/app-graph/testing';
7
+ import { Graph } from '@dxos/app-graph';
9
8
  import { faker } from '@dxos/random';
10
9
  import { arrayMove } from '@dxos/util';
11
10
 
12
11
  import { Tree, type TreeData, type TreeProps } from './Tree';
13
- import { type MosaicDropEvent, type MosaicMoveEvent, Path, type MosaicOperation } from '../../mosaic';
12
+ import { type MosaicDropEvent, type MosaicMoveEvent, Path } from '../../mosaic';
14
13
  import { TestObjectGenerator } from '../../testing';
15
14
 
16
15
  export type DemoTreeProps = TreeProps & {
@@ -80,57 +79,64 @@ export const DemoTree = ({ id = 'tree', initialItems, types, debug }: DemoTreePr
80
79
  };
81
80
 
82
81
  export const createGraph = () => {
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) => ({
82
+ const graph = new Graph();
83
+ graph.addNodes({
84
+ id: 'root',
85
+ nodes: [Array(2)].map((_, i) => ({
89
86
  id: faker.string.hexadecimal({ length: 4 }).slice(2).toUpperCase(),
90
87
  label: faker.lorem.words(2),
91
88
  description: faker.lorem.sentence(),
92
- properties: { index: `a${j}` },
93
- children: [...Array(2)].map((_, k) => ({
89
+ properties: { index: `a${i}` },
90
+ children: [...Array(2)].map((_, j) => ({
94
91
  id: faker.string.hexadecimal({ length: 4 }).slice(2).toUpperCase(),
95
92
  label: faker.lorem.words(2),
96
93
  description: faker.lorem.sentence(),
97
- properties: { index: `a${k}` },
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
+ })),
98
101
  })),
99
102
  })),
100
- }));
103
+ });
101
104
 
102
- return buildGraph(new GraphBuilder().build(), 'tree', content);
105
+ return graph;
103
106
  };
104
107
 
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
- };
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.
130
110
 
131
- const handleOver = (): MosaicOperation => 'transfer';
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
+ // };
132
136
 
133
- return (
134
- <Tree id={id} items={graph.root.children as TreeData[]} onDrop={handleDrop} onOver={handleOver} debug={debug} />
135
- );
136
- };
137
+ // const handleOver = (): MosaicOperation => 'transfer';
138
+
139
+ // return (
140
+ // <Tree id={id} items={graph.root.children as TreeData[]} onDrop={handleDrop} onOver={handleOver} debug={debug} />
141
+ // );
142
+ // };