@retikz/core 0.0.1-rc.0 → 0.0.1-rc.1

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.
Files changed (107) hide show
  1. package/dist/es/components/Scope.d.ts +2 -2
  2. package/dist/es/components/Scope.js +6 -5
  3. package/dist/es/components/TikZ.js +2 -2
  4. package/dist/es/components/draw/Draw.d.ts +11 -3
  5. package/dist/es/components/draw/Draw.js +31 -6
  6. package/dist/es/components/draw/InnerDraw.d.ts +7 -3
  7. package/dist/es/components/draw/InnerDraw.js +25 -20
  8. package/dist/es/components/draw/index.js +4 -0
  9. package/dist/es/components/draw/segment/Segment.js +5 -5
  10. package/dist/es/components/draw/segment/index.d.ts +0 -4
  11. package/dist/es/components/draw/segment/index.js +4 -4
  12. package/dist/es/components/draw/segment/useArrow.js +2 -2
  13. package/dist/es/components/draw/segment/useConvertWay.js +10 -6
  14. package/dist/es/components/node/InnerNode.d.ts +2 -2
  15. package/dist/es/components/node/InnerNode.js +6 -6
  16. package/dist/es/components/node/Node.d.ts +42 -3
  17. package/dist/es/components/node/Node.js +7 -6
  18. package/dist/es/components/node/_hooks/useNodeConfig.d.ts +1 -1
  19. package/dist/es/components/node/_hooks/useNodeContent.js +6 -3
  20. package/dist/es/components/node/_hooks/useNodeShape.js +2 -2
  21. package/dist/es/components/{pathNode → path-node}/PathNode.d.ts +11 -2
  22. package/dist/es/components/{pathNode → path-node}/PathNode.js +6 -6
  23. package/dist/es/container/Group.d.ts +2 -2
  24. package/dist/es/container/Group.js +5 -4
  25. package/dist/es/container/Surface.d.ts +4 -2
  26. package/dist/es/container/Surface.js +7 -7
  27. package/dist/es/elements/Path.d.ts +2 -2
  28. package/dist/es/elements/Path.js +5 -4
  29. package/dist/es/elements/Rect.d.ts +3 -5
  30. package/dist/es/elements/Rect.js +6 -5
  31. package/dist/es/elements/Text.d.ts +2 -3
  32. package/dist/es/elements/Text.js +7 -7
  33. package/dist/es/hooks/useForceUpdate.d.ts +1 -1
  34. package/dist/es/index.d.ts +4 -4
  35. package/dist/es/index.js +1 -1
  36. package/dist/es/test.d.ts +1 -0
  37. package/dist/es/types/svg/stroke.d.ts +2 -2
  38. package/dist/es/utils/style/stroke.d.ts +4 -3
  39. package/dist/es/utils/style/stroke.js +4 -2
  40. package/dist/lib/components/Scope.cjs +6 -5
  41. package/dist/lib/components/Scope.d.ts +2 -2
  42. package/dist/lib/components/TikZ.cjs +2 -2
  43. package/dist/lib/components/draw/Draw.cjs +31 -6
  44. package/dist/lib/components/draw/Draw.d.ts +11 -3
  45. package/dist/lib/components/draw/InnerDraw.cjs +26 -21
  46. package/dist/lib/components/draw/InnerDraw.d.ts +7 -3
  47. package/dist/lib/components/draw/index.cjs +4 -0
  48. package/dist/lib/components/draw/segment/Segment.cjs +7 -7
  49. package/dist/lib/components/draw/segment/index.cjs +6 -6
  50. package/dist/lib/components/draw/segment/index.d.ts +0 -4
  51. package/dist/lib/components/draw/segment/useArrow.cjs +4 -4
  52. package/dist/lib/components/draw/segment/useConvertWay.cjs +14 -10
  53. package/dist/lib/components/node/InnerNode.cjs +15 -15
  54. package/dist/lib/components/node/InnerNode.d.ts +2 -2
  55. package/dist/lib/components/node/Node.cjs +12 -11
  56. package/dist/lib/components/node/Node.d.ts +42 -3
  57. package/dist/lib/components/node/_hooks/useNodeConfig.cjs +2 -2
  58. package/dist/lib/components/node/_hooks/useNodeConfig.d.ts +1 -1
  59. package/dist/lib/components/node/_hooks/useNodeContent.cjs +9 -6
  60. package/dist/lib/components/node/_hooks/useNodeShape.cjs +4 -4
  61. package/dist/lib/components/{pathNode → path-node}/PathNode.cjs +12 -12
  62. package/dist/lib/components/{pathNode → path-node}/PathNode.d.ts +11 -2
  63. package/dist/lib/components/{pathNode → path-node}/useAnchor.cjs +4 -4
  64. package/dist/lib/container/Group.cjs +5 -4
  65. package/dist/lib/container/Group.d.ts +2 -2
  66. package/dist/lib/container/Surface.cjs +8 -8
  67. package/dist/lib/container/Surface.d.ts +4 -2
  68. package/dist/lib/elements/Path.cjs +5 -4
  69. package/dist/lib/elements/Path.d.ts +2 -2
  70. package/dist/lib/elements/Rect.cjs +6 -5
  71. package/dist/lib/elements/Rect.d.ts +3 -5
  72. package/dist/lib/elements/Text.cjs +8 -8
  73. package/dist/lib/elements/Text.d.ts +2 -3
  74. package/dist/lib/hooks/context/useCalculate.cjs +3 -3
  75. package/dist/lib/hooks/context/useNodes.cjs +3 -3
  76. package/dist/lib/hooks/context/usePath.cjs +3 -3
  77. package/dist/lib/hooks/context/useScope.cjs +3 -3
  78. package/dist/lib/hooks/useForceUpdate.cjs +2 -2
  79. package/dist/lib/hooks/useForceUpdate.d.ts +1 -1
  80. package/dist/lib/index.cjs +1 -1
  81. package/dist/lib/index.d.ts +4 -4
  82. package/dist/lib/test.d.ts +1 -0
  83. package/dist/lib/types/svg/stroke.d.ts +2 -2
  84. package/dist/lib/utils/style/stroke.cjs +4 -2
  85. package/dist/lib/utils/style/stroke.d.ts +4 -3
  86. package/package.json +9 -8
  87. package/dist/es/_virtual/jsx-runtime.js +0 -5
  88. package/dist/es/_virtual/jsx-runtime2.js +0 -4
  89. package/dist/es/_virtual/react-jsx-runtime.development.js +0 -4
  90. package/dist/es/_virtual/react-jsx-runtime.production.js +0 -4
  91. package/dist/es/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.development.js +0 -20
  92. package/dist/es/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.production.js +0 -41
  93. package/dist/es/node_modules/.pnpm/react@19.0.0/node_modules/react/jsx-runtime.js +0 -17
  94. package/dist/lib/_virtual/jsx-runtime.cjs +0 -5
  95. package/dist/lib/_virtual/jsx-runtime2.cjs +0 -4
  96. package/dist/lib/_virtual/react-jsx-runtime.development.cjs +0 -4
  97. package/dist/lib/_virtual/react-jsx-runtime.production.cjs +0 -4
  98. package/dist/lib/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.development.cjs +0 -20
  99. package/dist/lib/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.production.cjs +0 -41
  100. package/dist/lib/node_modules/.pnpm/react@19.0.0/node_modules/react/jsx-runtime.cjs +0 -17
  101. /package/dist/es/components/{pathNode → path-node}/index.d.ts +0 -0
  102. /package/dist/es/components/{pathNode → path-node}/index.js +0 -0
  103. /package/dist/es/components/{pathNode → path-node}/useAnchor.d.ts +0 -0
  104. /package/dist/es/components/{pathNode → path-node}/useAnchor.js +0 -0
  105. /package/dist/lib/components/{pathNode → path-node}/index.cjs +0 -0
  106. /package/dist/lib/components/{pathNode → path-node}/index.d.ts +0 -0
  107. /package/dist/lib/components/{pathNode → path-node}/useAnchor.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const require$$0 = require("react");
3
+ const react = require("react");
4
4
  const useNodes = require("../../../hooks/context/useNodes.cjs");
5
5
  const useForceUpdate = require("../../../hooks/useForceUpdate.cjs");
6
6
  const DescartesPoint = require("../../../model/geometry/point/DescartesPoint.cjs");
@@ -8,7 +8,7 @@ const PolarPoint = require("../../../model/geometry/point/PolarPoint.cjs");
8
8
  const common = require("../common.cjs");
9
9
  const formatPointPosition = (point) => {
10
10
  if (Array.isArray(point)) return point;
11
- if (point.hasOwnProperty("x") && point.hasOwnProperty("y")) {
11
+ if ("x" in point && "y" in point) {
12
12
  const p = point;
13
13
  return [p.x, p.y];
14
14
  }
@@ -20,13 +20,13 @@ const getVerticalPoint = (point1, point2, type) => {
20
20
  return type === "-|" ? [p2[0], p1[1]] : [p1[0], p2[1]];
21
21
  };
22
22
  const convertOffsetAndMovePoint = (point) => {
23
- const filterPoint = point.replace(/[+()\[\]\s]/g, "");
23
+ const filterPoint = point.replace(/[+()[\]\s]/g, "");
24
24
  return filterPoint.split(",").map((item) => parseFloat(item));
25
25
  };
26
26
  const useConvertWay = (way) => {
27
27
  const { getModel, subscribeModel } = useNodes.default();
28
28
  const forceUpdate = useForceUpdate.default();
29
- const nodeUpdateCount = require$$0.useRef(0);
29
+ const nodeUpdateCount = react.useRef(0);
30
30
  let cursor = [0, 0];
31
31
  const tryGetModel = (name) => {
32
32
  const model = getModel(name);
@@ -38,15 +38,16 @@ const useConvertWay = (way) => {
38
38
  };
39
39
  const subscribeCbs = [];
40
40
  let allNodeInit = true;
41
- const result = require$$0.useMemo(
41
+ const result = react.useMemo(
42
42
  () => way.map((item, index) => {
43
43
  const type = common.getDrawPointType(item);
44
44
  switch (type) {
45
- case "coordinate":
45
+ case "coordinate": {
46
46
  const corPosition = formatPointPosition(item);
47
47
  cursor = corPosition;
48
48
  return corPosition;
49
- case "node":
49
+ }
50
+ case "node": {
50
51
  if (![0, way.length - 1].includes(index)) {
51
52
  throw new Error(
52
53
  "Node can only be the first or last point on DrawSegment component, this may be a retikz bug, please report it."
@@ -61,7 +62,8 @@ const useConvertWay = (way) => {
61
62
  if (cb) subscribeCbs.push(cb);
62
63
  cursor = nodeModel.center;
63
64
  return nodeModel;
64
- case "vertical":
65
+ }
66
+ case "vertical": {
65
67
  if ([0, way.length - 1].includes(index)) {
66
68
  throw new Error("Vertical point can not be the first point on path.");
67
69
  }
@@ -75,17 +77,19 @@ const useConvertWay = (way) => {
75
77
  const verPosition = getVerticalPoint(beforePosition, afterPosition, item);
76
78
  cursor = verPosition;
77
79
  return cursor;
78
- default:
80
+ }
81
+ default: {
79
82
  if (index === 0) throw new Error("offset/move point can not be the first point on path.");
80
83
  const convertedPos = convertOffsetAndMovePoint(item);
81
84
  const curPos = DescartesPoint.default.plus(convertedPos, cursor);
82
85
  if (type === "move") cursor = curPos;
83
86
  return curPos;
87
+ }
84
88
  }
85
89
  }),
86
90
  [way, nodeUpdateCount.current]
87
91
  );
88
- require$$0.useLayoutEffect(() => () => {
92
+ react.useLayoutEffect(() => () => {
89
93
  subscribeCbs.forEach((cb) => cb && cb());
90
94
  });
91
95
  return [result, allNodeInit];
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const jsxRuntime = require("../../_virtual/jsx-runtime.cjs");
4
- const require$$0 = require("react");
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
5
5
  const Group = require("../../container/Group.cjs");
6
6
  const useNodeShape = require("./_hooks/useNodeShape.cjs");
7
7
  const useNodeContent = require("./_hooks/useNodeContent.cjs");
@@ -10,11 +10,11 @@ const css = require("../../utils/css.cjs");
10
10
  const useNodes = require("../../hooks/context/useNodes.cjs");
11
11
  const useCalculate = require("../../hooks/context/useCalculate.cjs");
12
12
  const math = require("../../utils/math.cjs");
13
- const InnerNode = (props) => {
14
- const { name, ref, position, width, height, innerSep, outerSep, rotate } = props;
15
- const nodeRef = require$$0.useRef(null);
16
- const shapeRef = require$$0.useRef(null);
17
- const contentRef = require$$0.useRef(null);
13
+ const InnerNode = react.forwardRef((props, ref) => {
14
+ const { name, position, width, height, innerSep, outerSep, rotate } = props;
15
+ const nodeRef = react.useRef(null);
16
+ const shapeRef = react.useRef(null);
17
+ const contentRef = react.useRef(null);
18
18
  const { getModel, updateModel, deleteModel } = useNodes.default();
19
19
  const { precision } = useCalculate.default();
20
20
  const nodeConfig = useNodeConfig.default();
@@ -23,7 +23,7 @@ const InnerNode = (props) => {
23
23
  updateModel(name, nodeConfig.current, false);
24
24
  }
25
25
  const groupElement = ref && "current" in ref ? ref.current : nodeRef.current;
26
- require$$0.useLayoutEffect(() => {
26
+ react.useLayoutEffect(() => {
27
27
  const contentElement = contentRef.current;
28
28
  if (!contentElement) return;
29
29
  const { width: elementWidth, height: elementHeight } = contentElement.getBoundingClientRect();
@@ -40,13 +40,13 @@ const InnerNode = (props) => {
40
40
  bottom: css.convertCssToPx(sep.bottom, { remPx, emPx, parentPx: height2 })
41
41
  };
42
42
  };
43
- require$$0.useLayoutEffect(() => {
43
+ react.useLayoutEffect(() => {
44
44
  nodeConfig.current.innerSep = getSep(innerSep);
45
45
  }, [innerSep]);
46
- require$$0.useLayoutEffect(() => {
46
+ react.useLayoutEffect(() => {
47
47
  nodeConfig.current.outerSep = getSep(outerSep);
48
48
  }, [outerSep]);
49
- require$$0.useLayoutEffect(() => {
49
+ react.useLayoutEffect(() => {
50
50
  var _a, _b, _c, _d;
51
51
  const {
52
52
  contentSize: [width2, height2],
@@ -61,10 +61,10 @@ const InnerNode = (props) => {
61
61
  const realHeight = height2 + innerSep2.top + innerSep2.bottom;
62
62
  (_d = shapeRef.current) == null ? void 0 : _d.setAttribute("height", math.convertPrecision(realHeight, precision).toString());
63
63
  }, [nodeConfig.current.position, nodeConfig.current.contentSize, nodeConfig.current.innerSep]);
64
- require$$0.useLayoutEffect(() => {
64
+ react.useLayoutEffect(() => {
65
65
  if (name) updateModel(name, nodeConfig.current);
66
66
  });
67
- require$$0.useLayoutEffect(
67
+ react.useLayoutEffect(
68
68
  () => () => {
69
69
  if (name) {
70
70
  deleteModel(name);
@@ -72,7 +72,7 @@ const InnerNode = (props) => {
72
72
  },
73
73
  [name]
74
74
  );
75
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(
75
+ return /* @__PURE__ */ jsxRuntime.jsxs(
76
76
  Group.default,
77
77
  {
78
78
  ref: ref || nodeRef,
@@ -84,5 +84,5 @@ const InnerNode = (props) => {
84
84
  ]
85
85
  }
86
86
  );
87
- };
87
+ });
88
88
  exports.default = InnerNode;
@@ -1,4 +1,4 @@
1
- import { FC, ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { Position } from '../../types/coordinate/descartes';
3
3
  import { StrokeProps } from '../../types/svg/stroke';
4
4
  import { TikZProps } from '../../types/tikz';
@@ -29,5 +29,5 @@ export type InnerNodeProps = {
29
29
  outerSep: DirectionDistance<number | string>;
30
30
  rotate?: number;
31
31
  } & TikZProps & ContentProps & ShapeProps;
32
- declare const InnerNode: FC<InnerNodeProps>;
32
+ declare const InnerNode: import('react').ForwardRefExoticComponent<Omit<InnerNodeProps, "ref"> & import('react').RefAttributes<SVGGElement>>;
33
33
  export default InnerNode;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const jsxRuntime = require("../../_virtual/jsx-runtime.cjs");
4
- const require$$0 = require("react");
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
5
5
  const InnerNode = require("./InnerNode.cjs");
6
6
  const css = require("../../utils/css.cjs");
7
7
  const stroke = require("../../utils/style/stroke.cjs");
@@ -9,7 +9,7 @@ const font = require("../../utils/style/font.cjs");
9
9
  const DescartesPoint = require("../../model/geometry/point/DescartesPoint.cjs");
10
10
  const useScope = require("../../hooks/context/useScope.cjs");
11
11
  const color = require("../../node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.cjs");
12
- const Node = (props) => {
12
+ const Node = react.forwardRef((props, ref) => {
13
13
  const { offset: scopeOffset, node } = useScope.default();
14
14
  const nodeScopeProps = { offset: scopeOffset, ...node };
15
15
  const realProps = {
@@ -19,13 +19,13 @@ const Node = (props) => {
19
19
  };
20
20
  const { shape = "rectangle", width, height, position, offset, innerSep, outerSep, ...res1Props } = realProps;
21
21
  const { r, rx, ry, fill, fillOpacity, stroke: stroke$1 = "transparent", strokeWidth = 1, strokeType, ...res2Props } = res1Props;
22
- const { color: color$1 = "currentColor", size, fontSize, fontStyle, fontFamily, style, ...otherProps } = res2Props;
23
- const realPosition = require$$0.useMemo(() => {
22
+ const { color: color$1 = "currentColor", size, fontSize, style, ...otherProps } = res2Props;
23
+ const realPosition = react.useMemo(() => {
24
24
  const formatPosition = position ? DescartesPoint.default.formatPosition(position) : [0, 0];
25
25
  const formatOffset = offset ? DescartesPoint.default.formatPosition(offset) : [0, 0];
26
26
  return [formatPosition[0] + formatOffset[0], formatPosition[1] + formatOffset[1]];
27
27
  }, [position]);
28
- const realColor = require$$0.useMemo(() => {
28
+ const realColor = react.useMemo(() => {
29
29
  if (color$1 === "auto" && fill && fill !== "currentColor") {
30
30
  const fillColor = color.default(fill);
31
31
  if (!fillColor) return color$1 || "currentColor";
@@ -55,15 +55,16 @@ const Node = (props) => {
55
55
  };
56
56
  };
57
57
  const getFontStyle = () => font.convertFontStyle(style);
58
- const adjustFontSize = require$$0.useMemo(() => font.convertFontSize(size || fontSize), [size, fontSize]);
59
- const adjustedInnerSep = require$$0.useMemo(
58
+ const adjustFontSize = react.useMemo(() => font.convertFontSize(size || fontSize), [size, fontSize]);
59
+ const adjustedInnerSep = react.useMemo(
60
60
  () => getSep(innerSep, css.convertCssToPx(adjustFontSize) / 3 || "0.3333em"),
61
61
  [innerSep]
62
62
  );
63
- const adjustedOuterSep = require$$0.useMemo(() => getSep(outerSep, 0), [outerSep]);
64
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
63
+ const adjustedOuterSep = react.useMemo(() => getSep(outerSep, 0), [outerSep]);
64
+ return /* @__PURE__ */ jsxRuntime.jsx(
65
65
  InnerNode.default,
66
66
  {
67
+ ref,
67
68
  width: css.convertCssToPx(width),
68
69
  height: css.convertCssToPx(height),
69
70
  shape,
@@ -83,5 +84,5 @@ const Node = (props) => {
83
84
  ...otherProps
84
85
  }
85
86
  );
86
- };
87
+ });
87
88
  exports.default = Node;
@@ -1,4 +1,4 @@
1
- import { FC, ReactNode, Ref } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { NodeShape } from './InnerNode';
3
3
  import { CssDistanceType } from '../../types/distance';
4
4
  import { SepProps } from '../../types/distance/sep';
@@ -10,7 +10,6 @@ import { TikZFontSize } from '../../utils/style/font';
10
10
  import { FontProps } from '../../types/svg/font';
11
11
  export type NodeProps = {
12
12
  name?: TikZKey;
13
- ref?: Ref<SVGGElement>;
14
13
  /** 位置 */
15
14
  position?: PointPosition;
16
15
  /** 位置偏移 */
@@ -50,5 +49,45 @@ export type NodeProps = {
50
49
  /** 样式 */
51
50
  style?: 'bold' | 'italic' | 'serif' | 'sans-serif';
52
51
  } & Partial<FontProps> & Partial<StrokeProps> & StrokeShortcutProps;
53
- declare const Node: FC<NodeProps>;
52
+ declare const Node: import('react').ForwardRefExoticComponent<{
53
+ name?: TikZKey;
54
+ /** 位置 */
55
+ position?: PointPosition;
56
+ /** 位置偏移 */
57
+ offset?: PointPosition;
58
+ /** 内容宽度 */
59
+ width?: CssDistanceType;
60
+ /** 内容高度 */
61
+ height?: CssDistanceType;
62
+ /** 内容(文本)颜色 */
63
+ color?: "currentColor" | "auto" | string;
64
+ /** 内容(文本)透明度 */
65
+ opacity?: number;
66
+ /** 内容(文本)字体大小 */
67
+ size?: string | TikZFontSize | number;
68
+ /** 内容 */
69
+ children?: ReactNode;
70
+ /** 边框形状 */
71
+ shape?: NodeShape;
72
+ /** 边框圆角 */
73
+ r?: CssDistanceType;
74
+ /** 边框圆角-x */
75
+ rx?: CssDistanceType;
76
+ /** 边框圆角-y */
77
+ ry?: CssDistanceType;
78
+ /** 背景填充色,默认为 auto */
79
+ fill?: string | "auto";
80
+ /** 背景填充色透明度 */
81
+ fillOpacity?: number;
82
+ /** 边框样式 */
83
+ strokeType?: StrokeType;
84
+ /** 内边距 */
85
+ innerSep?: CssDistanceType | SepProps;
86
+ /** 外边距 */
87
+ outerSep?: CssDistanceType | SepProps;
88
+ /** 旋转 */
89
+ rotate?: number;
90
+ /** 样式 */
91
+ style?: "bold" | "italic" | "serif" | "sans-serif";
92
+ } & Partial<FontProps> & Partial<StrokeProps> & StrokeShortcutProps & import('react').RefAttributes<SVGGElement>>;
54
93
  export default Node;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const require$$0 = require("react");
3
+ const react = require("react");
4
4
  const useNodeConfig = () => {
5
- const configRef = require$$0.useRef({
5
+ const configRef = react.useRef({
6
6
  position: [0, 0],
7
7
  contentSize: [0, 0],
8
8
  innerSep: { left: 0, right: 0, top: 0, bottom: 0 },
@@ -1,3 +1,3 @@
1
1
  import { NodeConfig } from '../../../model/component/node';
2
- declare const useNodeConfig: () => import('react').RefObject<NodeConfig>;
2
+ declare const useNodeConfig: () => import('react').MutableRefObject<NodeConfig>;
3
3
  export default useNodeConfig;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const jsxRuntime = require("../../../_virtual/jsx-runtime.cjs");
4
- const require$$0 = require("react");
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
5
5
  const Text = require("../../../elements/Text.cjs");
6
6
  const useNodeContent = (props, ref) => {
7
7
  const { color, size, opacity, fontWeight, fontStyle, fontFamily, fontStretch, children } = props;
8
- const isTextNode = children !== null && !require$$0.isValidElement(children);
9
- return require$$0.useMemo(
10
- () => isTextNode ? /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
8
+ const isTextNode = children !== null && !react.isValidElement(children);
9
+ return react.useMemo(
10
+ () => isTextNode ? /* @__PURE__ */ jsxRuntime.jsx(
11
11
  Text.default,
12
12
  {
13
13
  fill: color,
@@ -20,7 +20,10 @@ const useNodeContent = (props, ref) => {
20
20
  ref,
21
21
  children
22
22
  }
23
- ) : require$$0.isValidElement(children) ? require$$0.cloneElement(children, { ref }) : children,
23
+ ) : react.isValidElement(children) ? (
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
+ react.cloneElement(children, { ref })
26
+ ) : children,
24
27
  isTextNode ? [color, size, children] : [children]
25
28
  );
26
29
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const jsxRuntime = require("../../../_virtual/jsx-runtime.cjs");
4
- const require$$0 = require("react");
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
5
5
  const Rect = require("../../../elements/Rect.cjs");
6
6
  const getShapeProps = (nodeProps) => {
7
7
  const { rx, ry, fill, fillOpacity, stroke, strokeWidth, strokeOpacity } = nodeProps;
@@ -23,12 +23,12 @@ const getShapeProps = (nodeProps) => {
23
23
  };
24
24
  const useNodeShape = (props, ref) => {
25
25
  const shapeProps = getShapeProps(props);
26
- const Shape = require$$0.useMemo(() => {
26
+ const Shape = react.useMemo(() => {
27
27
  switch (props.shape) {
28
28
  case "rectangle":
29
29
  return Rect.default;
30
30
  }
31
31
  }, [props.shape, ...Object.values(shapeProps)]);
32
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(Shape, { ref, ...shapeProps });
32
+ return /* @__PURE__ */ jsxRuntime.jsx(Shape, { ref, ...shapeProps });
33
33
  };
34
34
  exports.default = useNodeShape;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const jsxRuntime = require("../../_virtual/jsx-runtime.cjs");
4
- const require$$0 = require("react");
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
5
5
  const useCalculate = require("../../hooks/context/useCalculate.cjs");
6
6
  const useNodes = require("../../hooks/context/useNodes.cjs");
7
7
  const useScope = require("../../hooks/context/useScope.cjs");
@@ -10,13 +10,13 @@ const css = require("../../utils/css.cjs");
10
10
  const math = require("../../utils/math.cjs");
11
11
  const Node = require("../node/Node.cjs");
12
12
  const useAnchor = require("./useAnchor.cjs");
13
- const PathNode = (props) => {
14
- const { segmentIndex = -1, offset = [0, 0], anchor, ref, left, right, above, below, name, ...resProps } = props;
13
+ const PathNode = react.forwardRef((props, ref) => {
14
+ const { segmentIndex = -1, offset = [0, 0], anchor, left, right, above, below, name, ...resProps } = props;
15
15
  const { pos, veryNearStart, veryNearEnd, start, nearStart, midway, nearEnd, end, sloped, ...nodeProps } = resProps;
16
- const id = require$$0.useId();
16
+ const id = react.useId();
17
17
  const realName = name ?? id;
18
18
  const { precision } = useCalculate.default();
19
- const posRadio = require$$0.useMemo(() => {
19
+ const posRadio = react.useMemo(() => {
20
20
  if (pos !== void 0) return pos;
21
21
  if (start) return 0;
22
22
  if (veryNearStart) return 0.125;
@@ -26,7 +26,7 @@ const PathNode = (props) => {
26
26
  if (veryNearEnd) return 0.875;
27
27
  return 1;
28
28
  }, [pos, veryNearStart, veryNearEnd, start, nearStart, midway, nearEnd, end]);
29
- const directionPos = require$$0.useMemo(() => {
29
+ const directionPos = react.useMemo(() => {
30
30
  if (left) return { direction: "left", distance: typeof left === "boolean" ? 0 : css.convertCssToPx(left) };
31
31
  if (right) return { direction: "right", distance: typeof right === "boolean" ? 0 : css.convertCssToPx(right) };
32
32
  if (above) return { direction: "top", distance: typeof above === "boolean" ? 0 : css.convertCssToPx(above) };
@@ -34,13 +34,13 @@ const PathNode = (props) => {
34
34
  return { direction: anchor ?? "center", distance: 0 };
35
35
  }, [anchor, left, right, above, below]);
36
36
  const { position: anchorPosition, angle: anchorAngle } = useAnchor.default(posRadio, segmentIndex);
37
- const [adjustOffset, setAdjustOffset] = require$$0.useState(DescartesPoint.default.plus(anchorPosition, offset));
37
+ const [adjustOffset, setAdjustOffset] = react.useState(DescartesPoint.default.plus(anchorPosition, offset));
38
38
  const { getModel } = useNodes.default();
39
- const rotate = require$$0.useMemo(() => {
39
+ const rotate = react.useMemo(() => {
40
40
  if (!sloped) return 0;
41
41
  return anchorAngle * (180 / Math.PI);
42
42
  }, [sloped, anchorAngle]);
43
- require$$0.useLayoutEffect(() => {
43
+ react.useLayoutEffect(() => {
44
44
  const model = getModel(realName);
45
45
  if (!model || !model.init) return;
46
46
  const { direction, distance } = directionPos;
@@ -62,7 +62,7 @@ const PathNode = (props) => {
62
62
  setAdjustOffset(DescartesPoint.default.plus(anchorPosition, directionPosition, offset));
63
63
  }, [anchorPosition, directionPos]);
64
64
  const scope = useScope.default();
65
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useScope.ScopeContext, { value: { ...scope, offset: [0, 0] }, children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
65
+ return /* @__PURE__ */ jsxRuntime.jsx(useScope.ScopeContext.Provider, { value: { ...scope, offset: [0, 0] }, children: /* @__PURE__ */ jsxRuntime.jsx(
66
66
  Node.default,
67
67
  {
68
68
  name: realName,
@@ -72,5 +72,5 @@ const PathNode = (props) => {
72
72
  ...nodeProps
73
73
  }
74
74
  ) });
75
- };
75
+ });
76
76
  exports.default = PathNode;
@@ -1,4 +1,3 @@
1
- import { FC } from 'react';
2
1
  import { Direction } from '../../types/coordinate';
3
2
  import { Position } from '../../types/coordinate/descartes';
4
3
  import { NodeProps } from '../node/Node';
@@ -35,5 +34,15 @@ export type PathNodeProps = {
35
34
  /** 跟随箭头位置 */
36
35
  sloped?: boolean;
37
36
  } & PathNodePositionProps & PosShortcutProps & Omit<NodeProps, 'position'>;
38
- declare const PathNode: FC<PathNodeProps>;
37
+ declare const PathNode: import('react').ForwardRefExoticComponent<{
38
+ segmentIndex?: number;
39
+ /** path 片段的下标 */
40
+ pos?: number;
41
+ /** 相对于路径的位置 */
42
+ anchor?: Direction | "center";
43
+ /** 偏移位置 */
44
+ offset?: Position;
45
+ /** 跟随箭头位置 */
46
+ sloped?: boolean;
47
+ } & PathNodePositionProps & PosShortcutProps & Omit<NodeProps, "position"> & import('react').RefAttributes<SVGGElement>>;
39
48
  export default PathNode;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const require$$0 = require("react");
3
+ const react = require("react");
4
4
  const useCalculate = require("../../hooks/context/useCalculate.cjs");
5
5
  const usePath = require("../../hooks/context/usePath.cjs");
6
6
  const useForceUpdate = require("../../hooks/useForceUpdate.cjs");
7
7
  const line = require("../../model/equation/line.cjs");
8
8
  const math = require("../../utils/math.cjs");
9
9
  const useAnchor = (pos, segmentIndex) => {
10
- const pathUpdateCount = require$$0.useRef(0);
10
+ const pathUpdateCount = react.useRef(0);
11
11
  const forceUpdate = useForceUpdate.default();
12
12
  const { model, subscribeModel } = usePath.default();
13
13
  const { precision } = useCalculate.default();
@@ -16,12 +16,12 @@ const useAnchor = (pos, segmentIndex) => {
16
16
  pathUpdateCount.current += 1;
17
17
  queueMicrotask(forceUpdate);
18
18
  });
19
- require$$0.useLayoutEffect(() => () => {
19
+ react.useLayoutEffect(() => () => {
20
20
  subscribeCb == null ? void 0 : subscribeCb();
21
21
  });
22
22
  const adjustIndex = segmentIndex >= 0 ? segmentIndex : model.ways.length + segmentIndex;
23
23
  if (!math.between(adjustIndex, [0, model.ways.length - 1], true)) throw new Error("segmentIndex is out of range");
24
- return require$$0.useMemo(() => {
24
+ return react.useMemo(() => {
25
25
  if (!model.init)
26
26
  return {
27
27
  position: [Number.MAX_SAFE_INTEGER / 2, Number.MAX_SAFE_INTEGER / 2],
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const jsxRuntime = require("../_virtual/jsx-runtime.cjs");
4
- const Group = (props) => {
5
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("g", { ...props });
6
- };
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
5
+ const Group = react.forwardRef((props, ref) => {
6
+ return /* @__PURE__ */ jsxRuntime.jsx("g", { ref, ...props });
7
+ });
7
8
  exports.default = Group;
@@ -1,6 +1,6 @@
1
- import { FC, PropsWithChildren, Ref, SVGProps } from 'react';
1
+ import { PropsWithChildren, Ref, SVGProps } from 'react';
2
2
  export type GroupProps = {
3
3
  ref?: Ref<SVGGElement>;
4
4
  } & SVGProps<SVGGElement>;
5
- declare const Group: FC<PropsWithChildren<GroupProps>>;
5
+ declare const Group: import('react').ForwardRefExoticComponent<Omit<PropsWithChildren<SVGProps<SVGGElement>>, "ref"> & import('react').RefAttributes<SVGGElement>>;
6
6
  export default Group;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const jsxRuntime = require("../_virtual/jsx-runtime.cjs");
4
- const require$$0 = require("react");
5
- const Surface = (props) => {
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
5
+ const Surface = react.forwardRef((props, ref) => {
6
6
  const { title, desc, viewBox, children, width, height, ...otherProps } = props;
7
- const svgViewBox = require$$0.useMemo(() => {
7
+ const svgViewBox = react.useMemo(() => {
8
8
  if (!(viewBox == null ? void 0 : viewBox.x) && !(viewBox == null ? void 0 : viewBox.y)) {
9
9
  return void 0;
10
10
  }
@@ -14,10 +14,10 @@ const Surface = (props) => {
14
14
  const viewHeight = (viewBox == null ? void 0 : viewBox.height) || height;
15
15
  return viewWidth === void 0 || viewHeight === void 0 ? [viewX, viewY].join(" ") : [viewX, viewY, viewWidth, viewHeight].join(" ");
16
16
  }, [width, height, viewBox]);
17
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("svg", { viewBox: svgViewBox, width, height, ...otherProps, children: [
18
- title ? /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("title", { children: title }) : null,
19
- desc ? /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("desc", { children: desc }) : null,
17
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { ref, viewBox: svgViewBox, width, height, ...otherProps, children: [
18
+ title ? /* @__PURE__ */ jsxRuntime.jsx("title", { children: title }) : null,
19
+ desc ? /* @__PURE__ */ jsxRuntime.jsx("desc", { children: desc }) : null,
20
20
  children
21
21
  ] });
22
- };
22
+ });
23
23
  exports.default = Surface;
@@ -1,4 +1,4 @@
1
- import { CSSProperties, FC, PropsWithChildren } from 'react';
1
+ import { CSSProperties } from 'react';
2
2
  export type SurfaceProps = {
3
3
  title?: string;
4
4
  desc?: string;
@@ -13,5 +13,7 @@ export type SurfaceProps = {
13
13
  className?: string;
14
14
  style?: CSSProperties;
15
15
  };
16
- declare const Surface: FC<PropsWithChildren<SurfaceProps>>;
16
+ declare const Surface: import('react').ForwardRefExoticComponent<SurfaceProps & {
17
+ children?: import('react').ReactNode | undefined;
18
+ } & import('react').RefAttributes<SVGSVGElement>>;
17
19
  export default Surface;
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const jsxRuntime = require("../_virtual/jsx-runtime.cjs");
4
- const Path = (props) => {
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
5
+ const Path = react.forwardRef((props, ref) => {
5
6
  const { fill: propFill, strokeWidth: propStrokeWidth, stroke: propStroke, ...otherProps } = props;
6
7
  const defaultProps = {
7
8
  fill: propFill || "transparent",
8
9
  strokeWidth: propStrokeWidth ?? 1,
9
10
  stroke: propStroke || "currentColor"
10
11
  };
11
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("path", { ...defaultProps, ...otherProps });
12
- };
12
+ return /* @__PURE__ */ jsxRuntime.jsx("path", { ref, ...defaultProps, ...otherProps });
13
+ });
13
14
  exports.default = Path;
@@ -1,4 +1,4 @@
1
- import { FC, SVGProps } from 'react';
1
+ import { SVGProps } from 'react';
2
2
  export type PathProps = {} & SVGProps<SVGPathElement>;
3
- declare const Path: FC<PathProps>;
3
+ declare const Path: import('react').ForwardRefExoticComponent<Omit<SVGProps<SVGPathElement>, "ref"> & import('react').RefAttributes<SVGPathElement>>;
4
4
  export default Path;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const jsxRuntime = require("../_virtual/jsx-runtime.cjs");
4
- const Rect = (props) => {
5
- const { ref, ...otherProps } = props;
6
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("rect", { ref, ...otherProps });
7
- };
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
5
+ const Rect = react.forwardRef((props, ref) => {
6
+ const { ...otherProps } = props;
7
+ return /* @__PURE__ */ jsxRuntime.jsx("rect", { ref, ...otherProps });
8
+ });
8
9
  exports.default = Rect;
@@ -1,6 +1,4 @@
1
- import { FC, PropsWithChildren, Ref, SVGProps } from 'react';
2
- export type RectProps = {
3
- ref?: Ref<SVGRectElement>;
4
- } & SVGProps<SVGRectElement>;
5
- declare const Rect: FC<PropsWithChildren<RectProps>>;
1
+ import { PropsWithChildren, SVGProps } from 'react';
2
+ export type RectProps = SVGProps<SVGRectElement>;
3
+ declare const Rect: import('react').ForwardRefExoticComponent<Omit<PropsWithChildren<RectProps>, "ref"> & import('react').RefAttributes<SVGRectElement>>;
6
4
  export default Rect;