@dxos/react-ui-mosaic 0.3.3-main.97c2b9e → 0.3.3-main.ad8134b
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/types/src/testing/generator.d.ts +4 -4
- package/dist/types/src/testing/generator.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +0 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/views/Tree/testing.d.ts.map +1 -1
- package/package.json +13 -14
- package/src/testing/generator.ts +9 -9
- package/src/testing/index.ts +0 -1
- package/src/views/Tree/testing.tsx +2 -3
- package/dist/types/src/testing/next-fractional-index.d.ts +0 -5
- package/dist/types/src/testing/next-fractional-index.d.ts.map +0 -1
- package/src/testing/next-fractional-index.ts +0 -36
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Schema
|
|
1
|
+
import { Schema } from '@dxos/client/echo';
|
|
2
2
|
import { type TypedObject } from '@dxos/echo-schema';
|
|
3
3
|
export declare const range: <T>(fn: (i: number) => T | undefined, length: number) => T[];
|
|
4
4
|
export type TestItem = {
|
|
@@ -6,11 +6,11 @@ export type TestItem = {
|
|
|
6
6
|
type: string;
|
|
7
7
|
} & Record<string, any>;
|
|
8
8
|
type ObjectDataGenerator = {
|
|
9
|
-
createSchema?: () =>
|
|
9
|
+
createSchema?: () => Schema;
|
|
10
10
|
createData: () => any;
|
|
11
11
|
};
|
|
12
12
|
type ObjectFactory<T extends TypedObject> = {
|
|
13
|
-
schema?:
|
|
13
|
+
schema?: Schema;
|
|
14
14
|
createObject: () => T;
|
|
15
15
|
};
|
|
16
16
|
type ObjectFactoryMap = {
|
|
@@ -30,7 +30,7 @@ export declare class TestObjectGenerator {
|
|
|
30
30
|
types?: string[];
|
|
31
31
|
factories?: ObjectFactoryMap;
|
|
32
32
|
});
|
|
33
|
-
get schema():
|
|
33
|
+
get schema(): Schema[];
|
|
34
34
|
createObject({ types }?: {
|
|
35
35
|
types?: string[];
|
|
36
36
|
}): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../src/testing/generator.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../src/testing/generator.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG9D,eAAO,MAAM,KAAK,cAAe,MAAM,4BAA4B,MAAM,QAG9C,CAAC;AAG5B,MAAM,MAAM,QAAQ,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE1E,KAAK,mBAAmB,GAAG;IACzB,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,CAAC;CACvB,CAAC;AAEF,KAAK,aAAa,CAAC,CAAC,SAAS,WAAW,IAAI;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC,CAAC;CACvB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;CAAE,CAAC;AAW/D,eAAO,MAAM,MAAM,UAAgC,CAAC;AACpD,eAAO,MAAM,QAAQ,UAAkB,CAAC;AAExC,eAAO,MAAM,iBAAiB,EAAE;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,CAAA;CA6CpE,CAAC;AAEF;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,SAAgB,SAAS,EAAE,gBAAgB,CAAC;gBAEhC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,SAAS,CAAC,EAAE,gBAAgB,CAAA;KAAO;IASzF,IAAI,MAAM,IAAI,MAAM,EAAE,CAErB;IAED,YAAY,CAAC,EAAE,KAAK,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KAAO;IAMjD,aAAa,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CAGtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAE5B,cAAc,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../../src/views/Tree/testing.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,KAAK,EAA2B,MAAM,iBAAiB,CAAC;AAItE,OAAO,EAAQ,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAM7D,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;AAcF,eAAO,MAAM,SAAS;QAAgD,MAAM;;WAAwB,OAAO;
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../../src/views/Tree/testing.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,KAAK,EAA2B,MAAM,iBAAiB,CAAC;AAItE,OAAO,EAAQ,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAM7D,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;AAcF,eAAO,MAAM,SAAS;QAAgD,MAAM;;WAAwB,OAAO;iBAsC1G,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-mosaic",
|
|
3
|
-
"version": "0.3.3-main.
|
|
3
|
+
"version": "0.3.3-main.ad8134b",
|
|
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",
|
|
@@ -21,18 +21,17 @@
|
|
|
21
21
|
"@dnd-kit/utilities": "^3.2.0",
|
|
22
22
|
"@preact/signals-core": "^1.5.0",
|
|
23
23
|
"@radix-ui/react-compose-refs": "^1.0.0",
|
|
24
|
-
"@tldraw/indices": "2.0.0-alpha.14",
|
|
25
24
|
"deepsignal": "1.4.0-shallow.0",
|
|
26
25
|
"lodash.defaultsdeep": "^4.6.1",
|
|
27
26
|
"lodash.pick": "^4.4.0",
|
|
28
27
|
"react-resize-detector": "^7.1.2",
|
|
29
|
-
"@dxos/debug": "0.3.3-main.
|
|
30
|
-
"@dxos/invariant": "0.3.3-main.
|
|
31
|
-
"@dxos/keys": "0.3.3-main.
|
|
32
|
-
"@dxos/react-ui": "0.3.3-main.
|
|
33
|
-
"@dxos/react-ui-theme": "0.3.3-main.
|
|
34
|
-
"@dxos/react-ui-types": "0.3.3-main.
|
|
35
|
-
"@dxos/util": "0.3.3-main.
|
|
28
|
+
"@dxos/debug": "0.3.3-main.ad8134b",
|
|
29
|
+
"@dxos/invariant": "0.3.3-main.ad8134b",
|
|
30
|
+
"@dxos/keys": "0.3.3-main.ad8134b",
|
|
31
|
+
"@dxos/react-ui": "0.3.3-main.ad8134b",
|
|
32
|
+
"@dxos/react-ui-theme": "0.3.3-main.ad8134b",
|
|
33
|
+
"@dxos/react-ui-types": "0.3.3-main.ad8134b",
|
|
34
|
+
"@dxos/util": "0.3.3-main.ad8134b"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
37
|
"@faker-js/faker": "^8.0.2",
|
|
@@ -42,16 +41,16 @@
|
|
|
42
41
|
"@types/lodash.pick": "^4.4.7",
|
|
43
42
|
"@types/react": "^18.0.21",
|
|
44
43
|
"@types/react-dom": "^18.0.6",
|
|
45
|
-
"chromatic": "^
|
|
44
|
+
"chromatic": "^7.5.0",
|
|
46
45
|
"d3": "^7.4.4",
|
|
47
46
|
"react": "^18.2.0",
|
|
48
47
|
"react-dom": "^18.2.0",
|
|
49
48
|
"vite": "^4.3.9",
|
|
50
49
|
"vite-plugin-turbosnap": "^1.0.2",
|
|
51
|
-
"@dxos/app-graph": "0.3.3-main.
|
|
52
|
-
"@dxos/echo-schema": "0.3.3-main.
|
|
53
|
-
"@dxos/gem-core": "0.3.3-main.
|
|
54
|
-
"@dxos/react-client": "0.3.3-main.
|
|
50
|
+
"@dxos/app-graph": "0.3.3-main.ad8134b",
|
|
51
|
+
"@dxos/echo-schema": "0.3.3-main.ad8134b",
|
|
52
|
+
"@dxos/gem-core": "0.3.3-main.ad8134b",
|
|
53
|
+
"@dxos/react-client": "0.3.3-main.ad8134b"
|
|
55
54
|
},
|
|
56
55
|
"peerDependencies": {
|
|
57
56
|
"@phosphor-icons/react": "^2.0.5",
|
package/src/testing/generator.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { faker } from '@faker-js/faker';
|
|
10
10
|
|
|
11
|
-
import { Schema
|
|
11
|
+
import { Schema } from '@dxos/client/echo';
|
|
12
12
|
import { Expando, type TypedObject } from '@dxos/echo-schema';
|
|
13
13
|
|
|
14
14
|
// TODO(burdon): Util.
|
|
@@ -21,12 +21,12 @@ export const range = <T>(fn: (i: number) => T | undefined, length: number): T[]
|
|
|
21
21
|
export type TestItem = { id: string; type: string } & Record<string, any>;
|
|
22
22
|
|
|
23
23
|
type ObjectDataGenerator = {
|
|
24
|
-
createSchema?: () =>
|
|
24
|
+
createSchema?: () => Schema;
|
|
25
25
|
createData: () => any;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
type ObjectFactory<T extends TypedObject> = {
|
|
29
|
-
schema?:
|
|
29
|
+
schema?: Schema; // TODO(burdon): Support both typed and expando schema.
|
|
30
30
|
createObject: () => T;
|
|
31
31
|
};
|
|
32
32
|
|
|
@@ -62,23 +62,23 @@ export const defaultGenerators: { [type: string]: ObjectDataGenerator } = {
|
|
|
62
62
|
|
|
63
63
|
project: {
|
|
64
64
|
createSchema: () =>
|
|
65
|
-
new
|
|
65
|
+
new Schema({
|
|
66
66
|
props: [
|
|
67
67
|
{
|
|
68
68
|
id: 'title',
|
|
69
|
-
type:
|
|
69
|
+
type: Schema.PropType.STRING,
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
id: 'repo',
|
|
73
|
-
type:
|
|
73
|
+
type: Schema.PropType.STRING,
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
id: 'status',
|
|
77
|
-
type:
|
|
77
|
+
type: Schema.PropType.STRING,
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
id: 'priority',
|
|
81
|
-
type:
|
|
81
|
+
type: Schema.PropType.NUMBER,
|
|
82
82
|
},
|
|
83
83
|
],
|
|
84
84
|
}),
|
|
@@ -106,7 +106,7 @@ export class TestObjectGenerator {
|
|
|
106
106
|
}, {});
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
get schema():
|
|
109
|
+
get schema(): Schema[] {
|
|
110
110
|
return Object.values(this.factories).map((f) => f.schema!);
|
|
111
111
|
}
|
|
112
112
|
|
package/src/testing/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { arrayMove } from '@dxos/util';
|
|
|
11
11
|
|
|
12
12
|
import { Tree, type TreeData, type TreeProps } from './Tree';
|
|
13
13
|
import { type MosaicDropEvent, type MosaicMoveEvent, Path, type MosaicOperation } from '../../mosaic';
|
|
14
|
-
import { TestObjectGenerator
|
|
14
|
+
import { TestObjectGenerator } from '../../testing';
|
|
15
15
|
|
|
16
16
|
const fake = faker.helpers.fake;
|
|
17
17
|
|
|
@@ -134,8 +134,7 @@ export const GraphTree = ({ id, graph = createGraph(), debug }: { id: string; gr
|
|
|
134
134
|
operation === 'rearrange'
|
|
135
135
|
) {
|
|
136
136
|
// This is a rearrange operation
|
|
137
|
-
|
|
138
|
-
activeNode.properties.index = nextIndex ?? 'a0';
|
|
137
|
+
console.warn('[react-ui-mosaic]', 'Tree', 'rearrange', 'needs implementation');
|
|
139
138
|
} else if (activeNode && activeParent && overParent && operation === 'transfer') {
|
|
140
139
|
activeParent.removeNode(active.item.id);
|
|
141
140
|
overNode.addNode('tree', { ...activeNode });
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type UniqueIdentifier } from '@dnd-kit/core';
|
|
2
|
-
import { type Node } from '@dxos/app-graph';
|
|
3
|
-
export declare const nextRearrangeIndex: (nodes: Node[], activeId: UniqueIdentifier, overId?: UniqueIdentifier) => string | null;
|
|
4
|
-
export declare const nextCopyIndex: (nodes: Node[], overId?: UniqueIdentifier) => string;
|
|
5
|
-
//# sourceMappingURL=next-fractional-index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"next-fractional-index.d.ts","sourceRoot":"","sources":["../../../../src/testing/next-fractional-index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,eAAO,MAAM,kBAAkB,UAAW,IAAI,EAAE,YAAY,gBAAgB,WAAW,gBAAgB,kBAYtG,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,IAAI,EAAE,WAAW,gBAAgB,WAYrE,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type UniqueIdentifier } from '@dnd-kit/core';
|
|
6
|
-
import { getIndexAbove, getIndexBelow, getIndexBetween } from '@tldraw/indices';
|
|
7
|
-
|
|
8
|
-
import { type Node } from '@dxos/app-graph';
|
|
9
|
-
|
|
10
|
-
export const nextRearrangeIndex = (nodes: Node[], activeId: UniqueIdentifier, overId?: UniqueIdentifier) => {
|
|
11
|
-
const overOrderIndex = nodes.length > 0 ? nodes.findIndex(({ id }) => id === overId) : -1;
|
|
12
|
-
if (overOrderIndex >= 0) {
|
|
13
|
-
const activeOrderIndex = nodes.findIndex(({ id }) => id === activeId);
|
|
14
|
-
return overOrderIndex < 1
|
|
15
|
-
? getIndexBelow(nodes[overOrderIndex].properties.index)
|
|
16
|
-
: activeOrderIndex < overOrderIndex
|
|
17
|
-
? getIndexBetween(nodes[overOrderIndex].properties.index, nodes[overOrderIndex + 1]?.properties.index)
|
|
18
|
-
: getIndexBetween(nodes[overOrderIndex - 1].properties.index, nodes[overOrderIndex].properties.index);
|
|
19
|
-
} else {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const nextCopyIndex = (nodes: Node[], overId?: UniqueIdentifier) => {
|
|
25
|
-
const overOrderIndex = nodes.length > 0 ? nodes.findIndex(({ id }) => id === overId) : -1;
|
|
26
|
-
const previewOrderIndex = nodes.findIndex(({ id }) => id.startsWith('preview--'));
|
|
27
|
-
if (overOrderIndex >= 0) {
|
|
28
|
-
return overOrderIndex < 1
|
|
29
|
-
? getIndexBelow(nodes[overOrderIndex].properties.index)
|
|
30
|
-
: previewOrderIndex < overOrderIndex && previewOrderIndex >= 0
|
|
31
|
-
? getIndexBetween(nodes[overOrderIndex].properties.index, nodes[overOrderIndex + 1]?.properties.index)
|
|
32
|
-
: getIndexBetween(nodes[overOrderIndex - 1].properties.index, nodes[overOrderIndex]?.properties.index);
|
|
33
|
-
} else {
|
|
34
|
-
return nodes.length ? getIndexAbove(nodes[nodes.length - 1].properties.index) : 'a0';
|
|
35
|
-
}
|
|
36
|
-
};
|