@dxos/react-ui-mosaic 0.4.10-main.fa5a270 → 0.4.10-main.fd8ea31

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.
@@ -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":"AAKA,OAAc,EAAE,KAAK,EAAE,EAAoB,MAAM,OAAO,CAAC;AAGzD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAKpD,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAA+C,MAAM,eAAe,CAAC;AAWjG,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;AAEF,eAAO,MAAM,UAAU;QAMjB,MAAM;cACA,SAAS;eACR,mBAAmB;;iBA+G/B,CAAC"}
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.fa5a270",
3
+ "version": "0.4.10-main.fd8ea31",
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,18 +24,18 @@
24
24
  "lodash.defaultsdeep": "^4.6.1",
25
25
  "lodash.pick": "^4.4.0",
26
26
  "react-resize-detector": "^7.1.2",
27
- "@dxos/invariant": "0.4.10-main.fa5a270",
28
- "@dxos/react-ui": "0.4.10-main.fa5a270",
29
- "@dxos/keys": "0.4.10-main.fa5a270",
30
- "@dxos/debug": "0.4.10-main.fa5a270",
31
- "@dxos/react-ui-theme": "0.4.10-main.fa5a270",
32
- "@dxos/react-ui-card": "0.4.10-main.fa5a270",
33
- "@dxos/util": "0.4.10-main.fa5a270",
34
- "@dxos/react-ui-types": "0.4.10-main.fa5a270",
35
- "@dxos/log": "0.4.10-main.fa5a270"
27
+ "@dxos/debug": "0.4.10-main.fd8ea31",
28
+ "@dxos/invariant": "0.4.10-main.fd8ea31",
29
+ "@dxos/keys": "0.4.10-main.fd8ea31",
30
+ "@dxos/log": "0.4.10-main.fd8ea31",
31
+ "@dxos/react-ui": "0.4.10-main.fd8ea31",
32
+ "@dxos/react-ui-card": "0.4.10-main.fd8ea31",
33
+ "@dxos/react-ui-types": "0.4.10-main.fd8ea31",
34
+ "@dxos/util": "0.4.10-main.fd8ea31",
35
+ "@dxos/react-ui-theme": "0.4.10-main.fd8ea31"
36
36
  },
37
37
  "devDependencies": {
38
- "@phosphor-icons/react": "^2.0.5",
38
+ "@phosphor-icons/react": "^2.1.5",
39
39
  "@types/d3": "^7.4.2",
40
40
  "@types/lodash.defaultsdeep": "^4.6.6",
41
41
  "@types/lodash.pick": "^4.4.7",
@@ -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.1.5",
47
+ "vite": "^5.2.9",
48
48
  "vite-plugin-turbosnap": "^1.0.2",
49
- "@dxos/app-graph": "0.4.10-main.fa5a270",
50
- "@dxos/echo-schema": "0.4.10-main.fa5a270",
51
- "@dxos/gem-core": "0.4.10-main.fa5a270",
52
- "@dxos/react-client": "0.4.10-main.fa5a270",
53
- "@dxos/storybook-utils": "0.4.10-main.fa5a270",
54
- "@dxos/random": "0.4.10-main.fa5a270"
49
+ "@dxos/echo-schema": "0.4.10-main.fd8ea31",
50
+ "@dxos/app-graph": "0.4.10-main.fd8ea31",
51
+ "@dxos/random": "0.4.10-main.fd8ea31",
52
+ "@dxos/gem-core": "0.4.10-main.fd8ea31",
53
+ "@dxos/react-client": "0.4.10-main.fd8ea31",
54
+ "@dxos/storybook-utils": "0.4.10-main.fd8ea31"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@phosphor-icons/react": "^2.0.5",
@@ -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;
@@ -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 React from 'react';
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
- type = DEFAULT_TYPE,
112
- item,
113
- Component = DefaultComponent,
114
- position,
115
- ...props
116
- }: MosaicTileProps<any>) => {
117
- const { operation } = useMosaic();
118
- const path =
119
- parentPath === item.id
120
- ? parentPath // If the path is the same as the item id, then this is the root tile.
121
- : Path.create(parentPath, item.id);
122
- const { setNodeRef, isOver } = useDroppable({
123
- id: path,
124
- data: { path, type, item, position } satisfies MosaicDraggedItem,
125
- });
126
-
127
- return (
128
- <Component
129
- ref={setNodeRef}
130
- item={item}
131
- path={path}
132
- type={type}
133
- position={position}
134
- operation={operation}
135
- isOver={isOver}
136
- {...props}
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.
@@ -4,8 +4,8 @@
4
4
 
5
5
  // TODO(burdon): Reconcile with @dxos/echo-generator.
6
6
 
7
- import { Schema } from '@dxos/client/echo';
8
- import { Expando, type TypedObject } from '@dxos/echo-schema';
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 TypedObject> = {
25
- schema?: Schema; // TODO(burdon): Support both typed and expando 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: () => new Expando(createData(), { schema }),
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
- new Schema({
62
- props: [
63
- {
64
- id: 'title',
65
- type: Schema.PropType.STRING,
66
- },
67
- {
68
- id: 'repo',
69
- type: Schema.PropType.STRING,
70
- },
71
- {
72
- id: 'status',
73
- type: Schema.PropType.STRING,
74
- },
75
- {
76
- id: 'priority',
77
- type: Schema.PropType.NUMBER,
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 { Expando } from '@dxos/react-client/echo';
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
- import { EchoKanban } from '../Kanban/testing';
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
- new Expando({
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, TestObjectGenerator, range } from '../../testing';
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
- 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
- ];
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
- // TODO(burdon): Batch API.
59
- objects.forEach((object) => space.db.add(object));
60
- }}
58
+ // // TODO(burdon): Batch API.
59
+ // objects.forEach((object) => space.db.add(object));
60
+ // }}
61
61
  component={Story}
62
62
  createSpace
63
63
  />