@dxos/react-ui-graph 0.8.4-main.69d29f4 → 0.8.4-main.6fa680abb7
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/README.md +5 -7
- package/dist/lib/browser/index.mjs +14 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +14 -10
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/SVG/Root.d.ts +3 -3
- package/dist/types/src/components/SVG/Root.d.ts.map +1 -1
- package/dist/types/src/util/fraction.d.ts +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -18
- package/src/components/Graph/Graph.stories.tsx +5 -5
- package/src/components/Graph/Graph.tsx +5 -5
- package/src/components/Mesh/Mesh.stories.tsx +2 -2
- package/src/components/SVG/Root.tsx +13 -6
- package/src/components/SVG/Svg.stories.tsx +2 -2
- package/src/fx/fx.stories.tsx +2 -2
- package/src/stories/hooks.stories.tsx +2 -2
- package/src/util/fraction.ts +1 -1
- package/styles/graph.css +292 -43
package/README.md
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
# react-ui-graph
|
|
2
2
|
|
|
3
|
-
A small, usually single-celled reproductive body that is resistant to adverse environmental conditions
|
|
4
|
-
and is capable of growing into a new organism, produced especially by certain fungi, algae, protozoans,
|
|
3
|
+
A small, usually single-celled reproductive body that is resistant to adverse environmental conditions
|
|
4
|
+
and is capable of growing into a new organism, produced especially by certain fungi, algae, protozoans,
|
|
5
5
|
and nonseedbearing plants such as mosses and ferns.
|
|
6
6
|
|
|
7
7
|
```tsx
|
|
8
8
|
export const Primary = () => {
|
|
9
9
|
const model = useMemo(() => new GraphBuilder(), []);
|
|
10
10
|
|
|
11
|
-
return (
|
|
11
|
+
return (
|
|
12
12
|
<SVGRoot>
|
|
13
13
|
<SVG>
|
|
14
14
|
<Markers />
|
|
15
15
|
<Grid axis />
|
|
16
|
-
<Zoom extent={[1/2, 2]}>
|
|
17
|
-
<Graph
|
|
18
|
-
model={model.graph}
|
|
19
|
-
/>
|
|
16
|
+
<Zoom extent={[1 / 2, 2]}>
|
|
17
|
+
<Graph model={model.graph} />
|
|
20
18
|
</Zoom>
|
|
21
19
|
</SVG>
|
|
22
20
|
</SVGRoot>
|
|
@@ -200,7 +200,7 @@ var FractionUtil = class _FractionUtil {
|
|
|
200
200
|
};
|
|
201
201
|
/**
|
|
202
202
|
* @param {Fraction}
|
|
203
|
-
* Convert to rounded number.
|
|
203
|
+
* Convert to rounded-sm number.
|
|
204
204
|
*/
|
|
205
205
|
static toNumber = ([n, d]) => {
|
|
206
206
|
_FractionUtil.validate([
|
|
@@ -2014,15 +2014,15 @@ var useZoom = (options = defaultZoomOptions) => {
|
|
|
2014
2014
|
|
|
2015
2015
|
// src/components/Graph/Graph.tsx
|
|
2016
2016
|
var __dxlog_file9 = "/__w/dxos/dxos/packages/ui/react-ui-graph/src/components/Graph/Graph.tsx";
|
|
2017
|
-
var GraphInner = ({ classNames, model, projector:
|
|
2017
|
+
var GraphInner = ({ classNames, model, projector: projectorProp, renderer: rendererProp, drag: drag2, arrows, onSelect, onInspect, ...props }, forwardedRef) => {
|
|
2018
2018
|
const context = useSvgContext();
|
|
2019
2019
|
const graphRef = useRef3(null);
|
|
2020
2020
|
const { projector, renderer } = useMemo3(() => {
|
|
2021
|
-
let projector2 =
|
|
2021
|
+
let projector2 = projectorProp;
|
|
2022
2022
|
if (!projector2) {
|
|
2023
2023
|
projector2 = new GraphForceProjector(context);
|
|
2024
2024
|
}
|
|
2025
|
-
let renderer2 =
|
|
2025
|
+
let renderer2 = rendererProp;
|
|
2026
2026
|
if (!renderer2) {
|
|
2027
2027
|
renderer2 = new GraphRenderer(context, graphRef, {
|
|
2028
2028
|
...props,
|
|
@@ -2041,8 +2041,8 @@ var GraphInner = ({ classNames, model, projector: _projector, renderer: _rendere
|
|
|
2041
2041
|
};
|
|
2042
2042
|
}, [
|
|
2043
2043
|
context,
|
|
2044
|
-
|
|
2045
|
-
|
|
2044
|
+
projectorProp,
|
|
2045
|
+
rendererProp,
|
|
2046
2046
|
drag2
|
|
2047
2047
|
]);
|
|
2048
2048
|
useImperativeHandle(forwardedRef, () => ({
|
|
@@ -2264,15 +2264,18 @@ import { select as select9 } from "d3";
|
|
|
2264
2264
|
import React4, { forwardRef as forwardRef2, useEffect as useEffect6, useImperativeHandle as useImperativeHandle2, useMemo as useMemo4 } from "react";
|
|
2265
2265
|
import { useResizeDetector } from "react-resize-detector";
|
|
2266
2266
|
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2267
|
-
var Root = /* @__PURE__ */ forwardRef2(({ classNames, children, ...props }, ref) => {
|
|
2267
|
+
var Root = /* @__PURE__ */ forwardRef2(({ classNames, children, scale, centered, ...props }, ref) => {
|
|
2268
2268
|
const { ref: containerRef, width = 0, height = 0 } = useResizeDetector({
|
|
2269
2269
|
refreshRate: 200
|
|
2270
2270
|
});
|
|
2271
2271
|
const context = useMemo4(() => {
|
|
2272
|
-
return new SVGContext(
|
|
2272
|
+
return new SVGContext({
|
|
2273
|
+
scale,
|
|
2274
|
+
centered
|
|
2275
|
+
});
|
|
2273
2276
|
}, [
|
|
2274
|
-
|
|
2275
|
-
|
|
2277
|
+
scale,
|
|
2278
|
+
centered
|
|
2276
2279
|
]);
|
|
2277
2280
|
useImperativeHandle2(ref, () => context, [
|
|
2278
2281
|
context
|
|
@@ -2294,6 +2297,7 @@ var Root = /* @__PURE__ */ forwardRef2(({ classNames, children, ...props }, ref)
|
|
|
2294
2297
|
return /* @__PURE__ */ React4.createElement(SVGContextProvider, {
|
|
2295
2298
|
value: context
|
|
2296
2299
|
}, /* @__PURE__ */ React4.createElement("div", {
|
|
2300
|
+
...props,
|
|
2297
2301
|
ref: containerRef,
|
|
2298
2302
|
className: mx3("grid grow overflow-hidden", classNames)
|
|
2299
2303
|
}, /* @__PURE__ */ React4.createElement("svg", {
|