@dxos/react-ui-graph 0.8.4-main.bc674ce → 0.8.4-main.c351d160a8

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 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: _projector, renderer: _renderer, drag: drag2, arrows, onSelect, onInspect, ...props }, forwardedRef) => {
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 = _projector;
2021
+ let projector2 = projectorProp;
2022
2022
  if (!projector2) {
2023
2023
  projector2 = new GraphForceProjector(context);
2024
2024
  }
2025
- let renderer2 = _renderer;
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
- _projector,
2045
- _renderer,
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(props);
2272
+ return new SVGContext({
2273
+ scale,
2274
+ centered
2275
+ });
2273
2276
  }, [
2274
- props.scale,
2275
- props.centered
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", {