@dxos/react-ui-graph 0.8.4-main.74a063c4e0 → 0.8.4-main.765dc60934
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/LICENSE +102 -5
- package/dist/lib/browser/{chunk-LKC455GK.mjs → chunk-EASNZZ7B.mjs} +1 -1
- package/dist/lib/browser/{chunk-LKC455GK.mjs.map → chunk-EASNZZ7B.mjs.map} +2 -2
- package/dist/lib/browser/index.mjs +92 -117
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/node-esm/{chunk-JE4KZCUF.mjs → chunk-JSE2X4ML.mjs} +1 -1
- package/dist/lib/node-esm/{chunk-JE4KZCUF.mjs.map → chunk-JSE2X4ML.mjs.map} +2 -2
- package/dist/lib/node-esm/index.mjs +92 -117
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +1 -1
- package/dist/lib/node-esm/testing/index.mjs.map +2 -2
- package/dist/types/src/components/Graph/Graph.d.ts.map +1 -1
- package/dist/types/src/components/Graph/Graph.stories.d.ts +3 -3
- package/dist/types/src/components/Graph/Graph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Mesh/Mesh.d.ts.map +1 -1
- package/dist/types/src/components/Mesh/Mesh.stories.d.ts.map +1 -1
- package/dist/types/src/components/SVG/Grid.d.ts.map +1 -1
- package/dist/types/src/components/SVG/Markers.d.ts.map +1 -1
- package/dist/types/src/components/SVG/Root.d.ts +5 -1
- package/dist/types/src/components/SVG/Root.d.ts.map +1 -1
- package/dist/types/src/components/SVG/Svg.stories.d.ts.map +1 -1
- package/dist/types/src/fx/fx.stories.d.ts.map +1 -1
- package/dist/types/src/fx/pulsar.d.ts.map +1 -1
- package/dist/types/src/graph/markers.d.ts.map +1 -1
- package/dist/types/src/graph/projector/graph-drag.d.ts.map +1 -1
- package/dist/types/src/graph/projector/graph-force-projector.d.ts.map +1 -1
- package/dist/types/src/graph/projector/graph-forces.d.ts.map +1 -1
- package/dist/types/src/graph/projector/graph-hierarchical-projector.d.ts.map +1 -1
- package/dist/types/src/graph/projector/graph-projector.d.ts.map +1 -1
- package/dist/types/src/graph/projector/graph-radial-projector.d.ts.map +1 -1
- package/dist/types/src/graph/projector/graph-relational-projector.d.ts.map +1 -1
- package/dist/types/src/graph/projector/projector.d.ts.map +1 -1
- package/dist/types/src/graph/renderer/bullets.d.ts.map +1 -1
- package/dist/types/src/graph/renderer/graph-renderer.d.ts.map +1 -1
- package/dist/types/src/graph/renderer/renderer.d.ts +6 -1
- package/dist/types/src/graph/renderer/renderer.d.ts.map +1 -1
- package/dist/types/src/hooks/useGrid.d.ts.map +1 -1
- package/dist/types/src/hooks/useStateRef.d.ts.map +1 -1
- package/dist/types/src/hooks/useSvgContext.d.ts.map +1 -1
- package/dist/types/src/hooks/useZoom.d.ts.map +1 -1
- package/dist/types/src/stories/hooks.stories.d.ts.map +1 -1
- package/dist/types/src/testing/data.d.ts +1 -1
- package/dist/types/src/testing/data.d.ts.map +1 -1
- package/dist/types/src/testing/hooks.d.ts.map +1 -1
- package/dist/types/src/testing/model.d.ts.map +1 -1
- package/dist/types/src/util/events.d.ts.map +1 -1
- package/dist/types/src/util/fraction.d.ts.map +1 -1
- package/dist/types/src/util/points.d.ts.map +1 -1
- package/dist/types/src/util/scale.d.ts.map +1 -1
- package/dist/types/src/util/screen.d.ts.map +1 -1
- package/dist/types/src/util/vector.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -26
- package/src/components/Graph/Graph.stories.tsx +15 -17
- package/src/components/Graph/Graph.tsx +10 -13
- package/src/components/Mesh/Mesh.stories.tsx +6 -4
- package/src/components/Mesh/Mesh.tsx +43 -35
- package/src/components/SVG/Root.tsx +28 -3
- package/src/graph/renderer/graph-renderer.ts +13 -4
- package/src/graph/renderer/renderer.ts +6 -4
- package/src/stories/hooks.stories.tsx +6 -1
- package/styles/graph.css +1 -1
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2022 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useStateRef.ts"],
|
|
4
4
|
"sourcesContent": ["//\n// Copyright 2021 DXOS.org\n//\n\nimport { type Dispatch, type RefObject, type SetStateAction, useEffect, useRef, useState } from 'react';\n\n/**\n * Extension of useState to return an up-to-date reference.\n * E.g., to use in callbacks where the state value is stale.\n * @param initialValue\n *\n * @deprecated This function has been deprecated.\n */\n// TODO(burdon): Remove.\nexport const useStateRef = <V>(\n initialValue?: V | (() => V),\n): [V | undefined, Dispatch<SetStateAction<V | undefined>>, RefObject<V | undefined>] => {\n const [value, setValue] = useState<V | undefined>(initialValue);\n const ref = useRef<V>(null);\n useEffect(() => {\n ref.current = value;\n }, [initialValue, value]);\n\n return [value, setValue, ref];\n};\n\n/**\n * Extension of useRef that contains computed values based on dependencies.\n * E.g., to use in callbacks where the state value is stale.\n * @param initialValue\n * @param deps\n */\n// TODO(burdon): Remove.\nexport const useDynamicRef = <V>(initialValue: () => V, deps: any[]): RefObject<V> => {\n const [, setValue] = useState<V>(initialValue);\n const ref = useRef<V>(initialValue());\n useEffect(() => {\n ref.current = initialValue();\n // Must update state to trigger render cycle.\n setValue(ref.current);\n }, deps);\n\n return ref;\n};\n\n/**\n * State setters to force repaint.\n * @param deps\n */\nexport const useTimestamp = (deps?: any[]): [number, () => void, number?] => {\n const [{ timestamp, previous }, setTimestamp] = useState<{\n timestamp: number;\n previous?: number;\n }>({ timestamp: Date.now() });\n useEffect(() => {\n setTimestamp({ timestamp: Date.now(), previous: timestamp });\n }, deps ?? []);\n\n return [timestamp, () => setTimestamp({ timestamp: Date.now(), previous: timestamp }), previous];\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,SAA6DA,WAAWC,QAAQC,gBAAgB;AAUzF,IAAMC,cAAc,CACzBC,iBAAAA;AAEA,QAAM,CAACC,OAAOC,QAAAA,
|
|
6
|
-
"names": ["useEffect", "useRef", "useState", "useStateRef", "initialValue", "value", "setValue", "
|
|
5
|
+
"mappings": ";AAIA,SAA6DA,WAAWC,QAAQC,gBAAgB;AAUzF,IAAMC,cAAc,CACzBC,iBAAAA;AAEA,QAAM,CAACC,OAAOC,QAAAA,IAAYJ,SAAwBE,YAAAA;AAClD,QAAMG,MAAMN,OAAU,IAAA;AACtBD,YAAU,MAAA;AACRO,QAAIC,UAAUH;EAChB,GAAG;IAACD;IAAcC;GAAM;AAExB,SAAO;IAACA;IAAOC;IAAUC;;AAC3B;AASO,IAAME,gBAAgB,CAAIL,cAAuBM,SAAAA;AACtD,QAAM,CAAA,EAAGJ,QAAAA,IAAYJ,SAAYE,YAAAA;AACjC,QAAMG,MAAMN,OAAUG,aAAAA,CAAAA;AACtBJ,YAAU,MAAA;AACRO,QAAIC,UAAUJ,aAAAA;AAEdE,aAASC,IAAIC,OAAO;EACtB,GAAGE,IAAAA;AAEH,SAAOH;AACT;AAMO,IAAMI,eAAe,CAACD,SAAAA;AAC3B,QAAM,CAAC,EAAEE,WAAWC,SAAQ,GAAIC,YAAAA,IAAgBZ,SAG7C;IAAEU,WAAWG,KAAKC,IAAG;EAAG,CAAA;AAC3BhB,YAAU,MAAA;AACRc,iBAAa;MAAEF,WAAWG,KAAKC,IAAG;MAAIH,UAAUD;IAAU,CAAA;EAC5D,GAAGF,QAAQ,CAAA,CAAE;AAEb,SAAO;IAACE;IAAW,MAAME,aAAa;MAAEF,WAAWG,KAAKC,IAAG;MAAIH,UAAUD;IAAU,CAAA;IAAIC;;AACzF;",
|
|
6
|
+
"names": ["useEffect", "useRef", "useState", "useStateRef", "initialValue", "value", "setValue", "ref", "current", "useDynamicRef", "deps", "useTimestamp", "timestamp", "previous", "setTimestamp", "Date", "now"]
|
|
7
7
|
}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
useDynamicRef,
|
|
3
3
|
useStateRef,
|
|
4
4
|
useTimestamp
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-EASNZZ7B.mjs";
|
|
6
6
|
|
|
7
7
|
// src/components/Graph/Graph.tsx
|
|
8
8
|
import React, { forwardRef, useEffect as useEffect3, useImperativeHandle, useMemo as useMemo3, useRef as useRef3 } from "react";
|
|
@@ -145,15 +145,7 @@ var createGraphDrag = (context, projector, options = defaultDragOptions) => {
|
|
|
145
145
|
import { invariant } from "@dxos/invariant";
|
|
146
146
|
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-graph/src/graph/types.ts";
|
|
147
147
|
var defaultIdAccessor = (node) => {
|
|
148
|
-
invariant(node.id, void 0, {
|
|
149
|
-
F: __dxlog_file,
|
|
150
|
-
L: 18,
|
|
151
|
-
S: void 0,
|
|
152
|
-
A: [
|
|
153
|
-
"node.id",
|
|
154
|
-
""
|
|
155
|
-
]
|
|
156
|
-
});
|
|
148
|
+
invariant(node.id, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 10, S: void 0, A: ["node.id", ""] });
|
|
157
149
|
return node.id;
|
|
158
150
|
};
|
|
159
151
|
var emptyGraph = {
|
|
@@ -292,15 +284,7 @@ var FractionUtil = class _FractionUtil {
|
|
|
292
284
|
* @param n
|
|
293
285
|
*/
|
|
294
286
|
static factors = (n) => {
|
|
295
|
-
invariant2(Number.isFinite(n), `Invalid number: ${n}`, {
|
|
296
|
-
F: __dxlog_file2,
|
|
297
|
-
L: 113,
|
|
298
|
-
S: this,
|
|
299
|
-
A: [
|
|
300
|
-
"Number.isFinite(n)",
|
|
301
|
-
"`Invalid number: ${n}`"
|
|
302
|
-
]
|
|
303
|
-
});
|
|
287
|
+
invariant2(Number.isFinite(n), `Invalid number: ${n}`, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 113, S: this, A: ["Number.isFinite(n)", "`Invalid number: ${n}`"] });
|
|
304
288
|
const factors = [
|
|
305
289
|
1
|
|
306
290
|
];
|
|
@@ -941,12 +925,7 @@ var GraphForceProjector = class extends GraphProjector {
|
|
|
941
925
|
nodes: graph?.nodes.length,
|
|
942
926
|
edges: graph?.edges.length
|
|
943
927
|
}
|
|
944
|
-
}, {
|
|
945
|
-
F: __dxlog_file3,
|
|
946
|
-
L: 226,
|
|
947
|
-
S: this,
|
|
948
|
-
C: (f, a) => f(...a)
|
|
949
|
-
});
|
|
928
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 89, S: this });
|
|
950
929
|
this._simulation.stop();
|
|
951
930
|
this.mergeData(graph);
|
|
952
931
|
this.updateLayout();
|
|
@@ -996,12 +975,7 @@ var GraphForceProjector = class extends GraphProjector {
|
|
|
996
975
|
updateForces(forces) {
|
|
997
976
|
log("updateForces", {
|
|
998
977
|
forces
|
|
999
|
-
}, {
|
|
1000
|
-
F: __dxlog_file3,
|
|
1001
|
-
L: 287,
|
|
1002
|
-
S: this,
|
|
1003
|
-
C: (f, a) => f(...a)
|
|
1004
|
-
});
|
|
978
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 148, S: this });
|
|
1005
979
|
this._simulation.nodes(this.layout.graph.nodes).force("link", maybeForce(forces?.link, (config) => {
|
|
1006
980
|
const force = forceLink().id((d) => d.id).links(this.layout.graph.edges.filter((edge) => edge.linkForce));
|
|
1007
981
|
if (config.distance != null) {
|
|
@@ -1082,12 +1056,7 @@ var GraphRadialProjector = class extends GraphProjector {
|
|
|
1082
1056
|
nodes: graph?.nodes.length,
|
|
1083
1057
|
edges: graph?.edges.length
|
|
1084
1058
|
}
|
|
1085
|
-
}, {
|
|
1086
|
-
F: __dxlog_file4,
|
|
1087
|
-
L: 31,
|
|
1088
|
-
S: this,
|
|
1089
|
-
C: (f, a) => f(...a)
|
|
1090
|
-
});
|
|
1059
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 13, S: this });
|
|
1091
1060
|
this.mergeData(graph);
|
|
1092
1061
|
this.doRadialLayout();
|
|
1093
1062
|
}
|
|
@@ -1192,12 +1161,7 @@ var GraphHierarchicalProjector = class extends GraphRadialProjector {
|
|
|
1192
1161
|
edges: graph?.edges.length
|
|
1193
1162
|
},
|
|
1194
1163
|
selection: this.selection?.getSelectedIds()
|
|
1195
|
-
}, {
|
|
1196
|
-
F: __dxlog_file5,
|
|
1197
|
-
L: 23,
|
|
1198
|
-
S: this,
|
|
1199
|
-
C: (f, a) => f(...a)
|
|
1200
|
-
});
|
|
1164
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 8, S: this });
|
|
1201
1165
|
this.mergeData(graph);
|
|
1202
1166
|
const selected = this.selection?.getSelectedIds()[0];
|
|
1203
1167
|
if (selected) {
|
|
@@ -1255,12 +1219,7 @@ var GraphRelationalProjector = class extends GraphRadialProjector {
|
|
|
1255
1219
|
edges: graph?.edges.length
|
|
1256
1220
|
},
|
|
1257
1221
|
selection: this.selection?.getSelectedIds()
|
|
1258
|
-
}, {
|
|
1259
|
-
F: __dxlog_file6,
|
|
1260
|
-
L: 23,
|
|
1261
|
-
S: this,
|
|
1262
|
-
C: (f, a) => f(...a)
|
|
1263
|
-
});
|
|
1222
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 8, S: this });
|
|
1264
1223
|
this.mergeData(graph);
|
|
1265
1224
|
const selected = this.selection?.getSelectedIds()[0];
|
|
1266
1225
|
if (selected) {
|
|
@@ -1369,8 +1328,6 @@ var createBullets = (group, nodeId, options = {}) => {
|
|
|
1369
1328
|
};
|
|
1370
1329
|
|
|
1371
1330
|
// src/graph/renderer/renderer.ts
|
|
1372
|
-
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1373
|
-
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-graph/src/graph/renderer/renderer.ts";
|
|
1374
1331
|
var Renderer = class {
|
|
1375
1332
|
_context;
|
|
1376
1333
|
_root;
|
|
@@ -1385,16 +1342,12 @@ var Renderer = class {
|
|
|
1385
1342
|
get context() {
|
|
1386
1343
|
return this._context;
|
|
1387
1344
|
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Returns the SVG group root if mounted.
|
|
1347
|
+
* The ref may be null between mount/unmount cycles or before the SVG container has sized.
|
|
1348
|
+
* Callers should treat null as "skip this render" rather than as an error.
|
|
1349
|
+
*/
|
|
1388
1350
|
get root() {
|
|
1389
|
-
invariant3(this._root.current, "SVG root is not initialized", {
|
|
1390
|
-
F: __dxlog_file7,
|
|
1391
|
-
L: 40,
|
|
1392
|
-
S: this,
|
|
1393
|
-
A: [
|
|
1394
|
-
"this._root.current",
|
|
1395
|
-
"'SVG root is not initialized'"
|
|
1396
|
-
]
|
|
1397
|
-
});
|
|
1398
1351
|
return this._root.current;
|
|
1399
1352
|
}
|
|
1400
1353
|
get options() {
|
|
@@ -1403,16 +1356,14 @@ var Renderer = class {
|
|
|
1403
1356
|
};
|
|
1404
1357
|
|
|
1405
1358
|
// src/graph/renderer/graph-renderer.ts
|
|
1406
|
-
var
|
|
1359
|
+
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-graph/src/graph/renderer/graph-renderer.ts";
|
|
1407
1360
|
var createLine2 = line2();
|
|
1408
1361
|
var GraphRenderer = class extends Renderer {
|
|
1409
1362
|
render(layout) {
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
C: (f, a) => f(...a)
|
|
1415
|
-
});
|
|
1363
|
+
if (!this.root) {
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
1366
|
+
log5("render", layout, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 24, S: this });
|
|
1416
1367
|
const root = select4(this.root);
|
|
1417
1368
|
if (layout.guides) {
|
|
1418
1369
|
root.selectAll("g.dx-guides").data([
|
|
@@ -1489,6 +1440,9 @@ var GraphRenderer = class extends Renderer {
|
|
|
1489
1440
|
* @param node
|
|
1490
1441
|
*/
|
|
1491
1442
|
fireBullet(node) {
|
|
1443
|
+
if (!this.root) {
|
|
1444
|
+
return;
|
|
1445
|
+
}
|
|
1492
1446
|
select4(this.root).selectAll("g.dx-edges").selectAll("path").call(createBullets(this.root, node.id));
|
|
1493
1447
|
}
|
|
1494
1448
|
};
|
|
@@ -1519,14 +1473,14 @@ var createNode = (group, options) => {
|
|
|
1519
1473
|
circle.on("pointerenter", function() {
|
|
1520
1474
|
select4(this.closest("g.dx-node")).raise();
|
|
1521
1475
|
if (options.labels) {
|
|
1522
|
-
select4(this.parentElement).classed("dx-active", true).classed("dx-highlight", true);
|
|
1476
|
+
select4(this.parentElement).classed("dx-node-active", true).classed("dx-highlight", true);
|
|
1523
1477
|
}
|
|
1524
1478
|
});
|
|
1525
1479
|
group.on("pointerleave", function() {
|
|
1526
1480
|
if (options.labels) {
|
|
1527
|
-
select4(this).classed("dx-active", false);
|
|
1481
|
+
select4(this).classed("dx-node-active", false);
|
|
1528
1482
|
setTimeout(() => {
|
|
1529
|
-
if (!select4(this).classed("dx-active")) {
|
|
1483
|
+
if (!select4(this).classed("dx-node-active")) {
|
|
1530
1484
|
select4(this).classed("dx-highlight", false);
|
|
1531
1485
|
}
|
|
1532
1486
|
}, 300);
|
|
@@ -1555,12 +1509,7 @@ var updateNode2 = (group, options) => {
|
|
|
1555
1509
|
} catch (error) {
|
|
1556
1510
|
log5.error("updateNode", {
|
|
1557
1511
|
error: error?.message
|
|
1558
|
-
}, {
|
|
1559
|
-
F: __dxlog_file8,
|
|
1560
|
-
L: 304,
|
|
1561
|
-
S: void 0,
|
|
1562
|
-
C: (f, a) => f(...a)
|
|
1563
|
-
});
|
|
1512
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 202, S: void 0 });
|
|
1564
1513
|
}
|
|
1565
1514
|
}
|
|
1566
1515
|
const groupOrTransition = options.transition ? group.transition(options.transition()) : group;
|
|
@@ -1611,12 +1560,7 @@ var updateEdge = (group, options, nodeGroup) => {
|
|
|
1611
1560
|
} catch (error) {
|
|
1612
1561
|
log5.error("updateEdge", {
|
|
1613
1562
|
error: error?.message
|
|
1614
|
-
}, {
|
|
1615
|
-
F: __dxlog_file8,
|
|
1616
|
-
L: 416,
|
|
1617
|
-
S: void 0,
|
|
1618
|
-
C: (f, a) => f(...a)
|
|
1619
|
-
});
|
|
1563
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 268, S: void 0 });
|
|
1620
1564
|
}
|
|
1621
1565
|
const groupOrTransition = options.transition ? group.transition(options.transition()) : group;
|
|
1622
1566
|
groupOrTransition.selectAll("path").attr("d", function() {
|
|
@@ -2013,7 +1957,7 @@ var useZoom = (options = defaultZoomOptions) => {
|
|
|
2013
1957
|
};
|
|
2014
1958
|
|
|
2015
1959
|
// src/components/Graph/Graph.tsx
|
|
2016
|
-
var
|
|
1960
|
+
var __dxlog_file8 = "/__w/dxos/dxos/packages/ui/react-ui-graph/src/components/Graph/Graph.tsx";
|
|
2017
1961
|
var GraphInner = ({ classNames, model, projector: projectorProp, renderer: rendererProp, drag: drag2, arrows, onSelect, onInspect, ...props }, forwardedRef) => {
|
|
2018
1962
|
const context = useSvgContext();
|
|
2019
1963
|
const graphRef = useRef3(null);
|
|
@@ -2031,8 +1975,8 @@ var GraphInner = ({ classNames, model, projector: projectorProp, renderer: rende
|
|
|
2031
1975
|
arrows: {
|
|
2032
1976
|
end: arrows
|
|
2033
1977
|
},
|
|
2034
|
-
onNodeClick: onSelect
|
|
2035
|
-
onNodePointerEnter: onInspect
|
|
1978
|
+
onNodeClick: onSelect,
|
|
1979
|
+
onNodePointerEnter: onInspect
|
|
2036
1980
|
});
|
|
2037
1981
|
}
|
|
2038
1982
|
return {
|
|
@@ -2062,22 +2006,20 @@ var GraphInner = ({ classNames, model, projector: projectorProp, renderer: rende
|
|
|
2062
2006
|
]);
|
|
2063
2007
|
useEffect3(() => {
|
|
2064
2008
|
projector.updateData(model?.graph);
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
F:
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
}
|
|
2080
|
-
}));
|
|
2009
|
+
return combine(
|
|
2010
|
+
// Subscribe to model changes if reactive model.
|
|
2011
|
+
model ? model.subscribe(() => {
|
|
2012
|
+
projector.updateData(model?.graph);
|
|
2013
|
+
}) : void 0,
|
|
2014
|
+
projector.updated.on(({ layout }) => {
|
|
2015
|
+
try {
|
|
2016
|
+
renderer.render(layout);
|
|
2017
|
+
} catch (error) {
|
|
2018
|
+
log6.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 67, S: void 0 });
|
|
2019
|
+
void projector.stop();
|
|
2020
|
+
}
|
|
2021
|
+
})
|
|
2022
|
+
);
|
|
2081
2023
|
}, [
|
|
2082
2024
|
model,
|
|
2083
2025
|
projector,
|
|
@@ -2105,21 +2047,27 @@ import { feature, mesh } from "topojson-client";
|
|
|
2105
2047
|
var Mesh = ({ radius = 16, value = 0.5 }) => {
|
|
2106
2048
|
const { svg, size } = useSvgContext();
|
|
2107
2049
|
useEffect4(() => {
|
|
2108
|
-
if (size) {
|
|
2109
|
-
|
|
2110
|
-
const projection = hexProjection(radius);
|
|
2111
|
-
const path = geoPath().projection(projection);
|
|
2112
|
-
select7(svg).append("g").attr("class", "hexagon").selectAll("path").data(topology.objects.hexagons.geometries).enter().append("path").attr("d", (d) => path(feature(topology, d))).attr("class", (d) => d.properties?.fill ? "fill" : null);
|
|
2113
|
-
select7(svg).append("path").datum(mesh(topology, topology.objects.hexagons)).attr("class", "mesh").attr("d", path);
|
|
2114
|
-
const redraw = (border) => {
|
|
2115
|
-
border.attr("d", path(mesh(topology, topology.objects.hexagons, (a, b) => a.properties.fill !== b.properties.fill)));
|
|
2116
|
-
};
|
|
2117
|
-
select7(svg).append("path").attr("class", "border").call(redraw);
|
|
2050
|
+
if (!size) {
|
|
2051
|
+
return;
|
|
2118
2052
|
}
|
|
2053
|
+
const topology = hexTopology(size, radius, value);
|
|
2054
|
+
const projection = hexProjection(radius);
|
|
2055
|
+
const path = geoPath().projection(projection);
|
|
2056
|
+
const root = select7(svg).selectAll("g.dx-mesh-root").data([
|
|
2057
|
+
null
|
|
2058
|
+
]).join("g").classed("dx-mesh-root", true);
|
|
2059
|
+
root.selectAll("*").remove();
|
|
2060
|
+
root.append("g").attr("class", "hexagon").selectAll("path").data(topology.objects.hexagons.geometries).enter().append("path").attr("d", (d) => path(feature(topology, d))).attr("class", (d) => d.properties?.fill ? "fill" : null);
|
|
2061
|
+
root.append("path").datum(mesh(topology, topology.objects.hexagons)).attr("class", "mesh").attr("d", path);
|
|
2062
|
+
const redraw = (border) => {
|
|
2063
|
+
border.attr("d", path(mesh(topology, topology.objects.hexagons, (a, b) => a.properties.fill !== b.properties.fill)));
|
|
2064
|
+
};
|
|
2065
|
+
root.append("path").attr("class", "border").call(redraw);
|
|
2119
2066
|
}, [
|
|
2120
2067
|
svg,
|
|
2121
2068
|
size,
|
|
2122
|
-
value
|
|
2069
|
+
value,
|
|
2070
|
+
radius
|
|
2123
2071
|
]);
|
|
2124
2072
|
return null;
|
|
2125
2073
|
};
|
|
@@ -2261,13 +2209,40 @@ var Markers = ({ arrowSize, className }) => {
|
|
|
2261
2209
|
|
|
2262
2210
|
// src/components/SVG/Root.tsx
|
|
2263
2211
|
import { select as select9 } from "d3";
|
|
2264
|
-
import React4, { forwardRef as forwardRef2, useEffect as useEffect6, useImperativeHandle as useImperativeHandle2, useMemo as useMemo4 } from "react";
|
|
2265
|
-
import { useResizeDetector } from "react-resize-detector";
|
|
2212
|
+
import React4, { forwardRef as forwardRef2, useEffect as useEffect6, useImperativeHandle as useImperativeHandle2, useMemo as useMemo4, useState } from "react";
|
|
2266
2213
|
import { composableProps, mx as mx3 } from "@dxos/ui-theme";
|
|
2267
2214
|
var Root = /* @__PURE__ */ forwardRef2(({ children, scale, centered, ...props }, ref) => {
|
|
2268
|
-
const
|
|
2269
|
-
|
|
2215
|
+
const [container, setContainer] = useState(null);
|
|
2216
|
+
const [size, setSize] = useState({
|
|
2217
|
+
width: 0,
|
|
2218
|
+
height: 0
|
|
2270
2219
|
});
|
|
2220
|
+
useEffect6(() => {
|
|
2221
|
+
if (!container) {
|
|
2222
|
+
return;
|
|
2223
|
+
}
|
|
2224
|
+
const rect = container.getBoundingClientRect();
|
|
2225
|
+
setSize({
|
|
2226
|
+
width: rect.width,
|
|
2227
|
+
height: rect.height
|
|
2228
|
+
});
|
|
2229
|
+
const observer = new ResizeObserver((entries) => {
|
|
2230
|
+
const entry = entries[0];
|
|
2231
|
+
if (!entry) {
|
|
2232
|
+
return;
|
|
2233
|
+
}
|
|
2234
|
+
const { width: width2, height: height2 } = entry.contentRect;
|
|
2235
|
+
setSize((prev) => prev.width === width2 && prev.height === height2 ? prev : {
|
|
2236
|
+
width: width2,
|
|
2237
|
+
height: height2
|
|
2238
|
+
});
|
|
2239
|
+
});
|
|
2240
|
+
observer.observe(container);
|
|
2241
|
+
return () => observer.disconnect();
|
|
2242
|
+
}, [
|
|
2243
|
+
container
|
|
2244
|
+
]);
|
|
2245
|
+
const { width, height } = size;
|
|
2271
2246
|
const context = useMemo4(() => {
|
|
2272
2247
|
return new SVGContext({
|
|
2273
2248
|
scale,
|
|
@@ -2300,7 +2275,7 @@ var Root = /* @__PURE__ */ forwardRef2(({ children, scale, centered, ...props },
|
|
|
2300
2275
|
...composableProps(props, {
|
|
2301
2276
|
classNames: "dx-expander"
|
|
2302
2277
|
}),
|
|
2303
|
-
ref:
|
|
2278
|
+
ref: setContainer
|
|
2304
2279
|
}, /* @__PURE__ */ React4.createElement("svg", {
|
|
2305
2280
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2306
2281
|
ref: context.ref,
|