@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
- 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,7 +1,8 @@
1
- import { j as jsxRuntimeExports } from "../_virtual/jsx-runtime.js";
2
- const Group = (props) => {
3
- return /* @__PURE__ */ jsxRuntimeExports.jsx("g", { ...props });
4
- };
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ const Group = forwardRef((props, ref) => {
4
+ return /* @__PURE__ */ jsx("g", { ref, ...props });
5
+ });
5
6
  export {
6
7
  Group as default
7
8
  };
@@ -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,6 +1,6 @@
1
- import { j as jsxRuntimeExports } from "../_virtual/jsx-runtime.js";
2
- import { useMemo } from "react";
3
- const Surface = (props) => {
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useMemo } from "react";
3
+ const Surface = forwardRef((props, ref) => {
4
4
  const { title, desc, viewBox, children, width, height, ...otherProps } = props;
5
5
  const svgViewBox = useMemo(() => {
6
6
  if (!(viewBox == null ? void 0 : viewBox.x) && !(viewBox == null ? void 0 : viewBox.y)) {
@@ -12,12 +12,12 @@ const Surface = (props) => {
12
12
  const viewHeight = (viewBox == null ? void 0 : viewBox.height) || height;
13
13
  return viewWidth === void 0 || viewHeight === void 0 ? [viewX, viewY].join(" ") : [viewX, viewY, viewWidth, viewHeight].join(" ");
14
14
  }, [width, height, viewBox]);
15
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { viewBox: svgViewBox, width, height, ...otherProps, children: [
16
- title ? /* @__PURE__ */ jsxRuntimeExports.jsx("title", { children: title }) : null,
17
- desc ? /* @__PURE__ */ jsxRuntimeExports.jsx("desc", { children: desc }) : null,
15
+ return /* @__PURE__ */ jsxs("svg", { ref, viewBox: svgViewBox, width, height, ...otherProps, children: [
16
+ title ? /* @__PURE__ */ jsx("title", { children: title }) : null,
17
+ desc ? /* @__PURE__ */ jsx("desc", { children: desc }) : null,
18
18
  children
19
19
  ] });
20
- };
20
+ });
21
21
  export {
22
22
  Surface as default
23
23
  };
@@ -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,13 +1,14 @@
1
- import { j as jsxRuntimeExports } from "../_virtual/jsx-runtime.js";
2
- const Path = (props) => {
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ const Path = forwardRef((props, ref) => {
3
4
  const { fill: propFill, strokeWidth: propStrokeWidth, stroke: propStroke, ...otherProps } = props;
4
5
  const defaultProps = {
5
6
  fill: propFill || "transparent",
6
7
  strokeWidth: propStrokeWidth ?? 1,
7
8
  stroke: propStroke || "currentColor"
8
9
  };
9
- return /* @__PURE__ */ jsxRuntimeExports.jsx("path", { ...defaultProps, ...otherProps });
10
- };
10
+ return /* @__PURE__ */ jsx("path", { ref, ...defaultProps, ...otherProps });
11
+ });
11
12
  export {
12
13
  Path as default
13
14
  };
@@ -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;
@@ -1,8 +1,9 @@
1
- import { j as jsxRuntimeExports } from "../_virtual/jsx-runtime.js";
2
- const Rect = (props) => {
3
- const { ref, ...otherProps } = props;
4
- return /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { ref, ...otherProps });
5
- };
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ const Rect = forwardRef((props, ref) => {
4
+ const { ...otherProps } = props;
5
+ return /* @__PURE__ */ jsx("rect", { ref, ...otherProps });
6
+ });
6
7
  export {
7
8
  Rect as default
8
9
  };
@@ -1,4 +1,4 @@
1
- import { FC, PropsWithChildren, Ref, SVGProps } from 'react';
1
+ import { PropsWithChildren, SVGProps } from 'react';
2
2
  import { FontProps } from '../types/svg/font';
3
3
  type TextVerticalAlign = 'top' | 'center' | 'bottom';
4
4
  export type DominantBaseline = 'auto' | 'text-bottom' | 'alphabetic' | 'ideographic' | 'middle' | 'central' | 'mathematical' | 'hanging' | 'text-top';
@@ -9,11 +9,10 @@ export type TextProps = {
9
9
  verticalAlign?: TextVerticalAlign | DominantBaseline;
10
10
  fontSize?: SVGProps<SVGTextElement>['fontSize'];
11
11
  fill?: SVGProps<SVGTextElement>['fill'];
12
- ref?: Ref<SVGTextElement>;
13
12
  } & FontProps & SVGProps<SVGTextElement>;
14
13
  /**
15
14
  * 文本节点
16
15
  * @tikz node
17
16
  */
18
- declare const Text: FC<PropsWithChildren<TextProps>>;
17
+ declare const Text: import('react').ForwardRefExoticComponent<Omit<PropsWithChildren<TextProps>, "ref"> & import('react').RefAttributes<SVGTextElement>>;
19
18
  export default Text;
@@ -1,8 +1,8 @@
1
- import { j as jsxRuntimeExports } from "../_virtual/jsx-runtime.js";
2
- import { useMemo } from "react";
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useMemo } from "react";
3
3
  import { textWrapParse } from "../utils/string.js";
4
- const Text = (props) => {
5
- const { children, ref, align, verticalAlign, fontSize, fill, ...otherProps } = props;
4
+ const Text = forwardRef((props, ref) => {
5
+ const { children, align, verticalAlign, fontSize, fill, ...otherProps } = props;
6
6
  const dominantBaseline = useMemo(() => {
7
7
  switch (verticalAlign) {
8
8
  case "top":
@@ -24,12 +24,12 @@ const Text = (props) => {
24
24
  };
25
25
  const parseChildren = (children2) => {
26
26
  if (typeof children2 === "string") {
27
- return textWrapParse(children2).map((child, index) => /* @__PURE__ */ jsxRuntimeExports.jsx("tspan", { children: child }, index));
27
+ return textWrapParse(children2).map((child, index) => /* @__PURE__ */ jsx("tspan", { children: child }, index));
28
28
  }
29
29
  return children2;
30
30
  };
31
- return /* @__PURE__ */ jsxRuntimeExports.jsx("text", { ref, ...textProps, children: parseChildren(children) });
32
- };
31
+ return /* @__PURE__ */ jsx("text", { ref, ...textProps, children: parseChildren(children) });
32
+ });
33
33
  export {
34
34
  Text as default
35
35
  };
@@ -1,2 +1,2 @@
1
- declare const useForceUpdate: () => import('react').ActionDispatch<[]>;
1
+ declare const useForceUpdate: () => import('react').DispatchWithoutAction;
2
2
  export default useForceUpdate;
@@ -1,9 +1,9 @@
1
- export { default as Draw } from './components/draw/Draw';
2
- export type { DrawProps } from './components/draw/Draw';
1
+ export { default as Draw } from './components/draw';
2
+ export type { DrawProps } from './components/draw';
3
3
  export { default as Node } from './components/node';
4
4
  export type { NodeProps } from './components/node';
5
- export { default as PathNode } from './components/pathNode';
6
- export type { PathNodeProps } from './components/pathNode';
5
+ export { default as PathNode } from './components/path-node';
6
+ export type { PathNodeProps } from './components/path-node';
7
7
  export { default as Scope } from './components/Scope';
8
8
  export type { ScopeProps } from './components/Scope';
9
9
  export { default as TikZ } from './components/TikZ';
package/dist/es/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { default as default2 } from "./components/draw/Draw.js";
2
2
  import { default as default3 } from "./components/node/Node.js";
3
- import { default as default4 } from "./components/pathNode/PathNode.js";
3
+ import { default as default4 } from "./components/path-node/PathNode.js";
4
4
  import { default as default5 } from "./components/Scope.js";
5
5
  import { default as default6 } from "./components/TikZ.js";
6
6
  export {
@@ -0,0 +1 @@
1
+ export {};
@@ -1,10 +1,10 @@
1
1
  export type StrokeProps = {
2
2
  stroke?: string;
3
- strokeWidth?: number;
3
+ strokeWidth?: number | string;
4
4
  strokeDasharray?: string;
5
5
  strokeDashoffset?: string;
6
6
  strokeLinecap?: 'butt' | 'round' | 'square' | 'inherit';
7
- strokeLinejoin?: "round" | "inherit" | "bevel" | "miter";
7
+ strokeLinejoin?: 'round' | 'inherit' | 'bevel' | 'miter';
8
8
  strokeMiterlimit?: number;
9
9
  strokeOpacity?: number;
10
10
  };
@@ -1,5 +1,6 @@
1
1
  import { StrokeProps } from '../../types/svg/stroke';
2
- export type StrokeType = 'solid' | 'dashed' | 'denselyDashed' | 'looselyDashed' | 'dotted' | 'denselyDotted' | 'looselyDotted' | 'dashDot' | 'denselyDashDot' | 'looselyDashDot' | 'dashDashDot' | 'denselyDashDashDot' | 'looselyDashDashDot';
2
+ export declare const strokeTypes: readonly ["solid", "dashed", "denselyDashed", "looselyDashed", "dotted", "denselyDotted", "looselyDotted", "dashDot", "denselyDashDot", "looselyDashDot", "dashDashDot", "denselyDashDashDot", "looselyDashDashDot"];
3
+ export type StrokeType = typeof strokeTypes[number];
3
4
  export type StrokeShortcutProps = {
4
5
  dashed?: boolean;
5
6
  denselyDashed?: boolean;
@@ -15,5 +16,5 @@ export type StrokeShortcutProps = {
15
16
  looselyDashDashDot?: boolean;
16
17
  };
17
18
  /** 将 StrokeType 转换为 svg 原生的属性 */
18
- export declare const convertStrokeType: (strokeType: StrokeType, strokeWidth?: number) => Partial<StrokeProps>;
19
- export declare const convertStrokeShortcut: (shortcutProps: StrokeShortcutProps, strokeWidth?: number) => Partial<StrokeProps>;
19
+ export declare const convertStrokeType: (strokeType: StrokeType, oriStrokeWidth?: string | number) => Partial<StrokeProps>;
20
+ export declare const convertStrokeShortcut: (shortcutProps: StrokeShortcutProps, oriStrokeWidth?: string | number) => Partial<StrokeProps>;
@@ -1,4 +1,5 @@
1
- const convertStrokeType = (strokeType, strokeWidth = 1) => {
1
+ const convertStrokeType = (strokeType, oriStrokeWidth = 1) => {
2
+ const strokeWidth = Number(oriStrokeWidth);
2
3
  switch (strokeType) {
3
4
  case "solid":
4
5
  return {};
@@ -28,7 +29,8 @@ const convertStrokeType = (strokeType, strokeWidth = 1) => {
28
29
  return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 6} 1 ${strokeWidth * 6} 1 ${strokeWidth * 6}` };
29
30
  }
30
31
  };
31
- const convertStrokeShortcut = (shortcutProps, strokeWidth = 1) => {
32
+ const convertStrokeShortcut = (shortcutProps, oriStrokeWidth = 1) => {
33
+ const strokeWidth = Number(oriStrokeWidth);
32
34
  return convertStrokeType(
33
35
  shortcutProps.dashed ? "dashed" : shortcutProps.denselyDashed ? "denselyDashed" : shortcutProps.looselyDashed ? "looselyDashed" : shortcutProps.dotted ? "dotted" : shortcutProps.denselyDotted ? "denselyDotted" : shortcutProps.looselyDotted ? "looselyDotted" : shortcutProps.dashDot ? "dashDot" : shortcutProps.denselyDashDot ? "denselyDashDot" : shortcutProps.looselyDashDot ? "looselyDashDot" : shortcutProps.dashDashDot ? "dashDashDot" : shortcutProps.denselyDashDashDot ? "denselyDashDashDot" : shortcutProps.looselyDashDashDot ? "looselyDashDashDot" : "solid",
34
36
  strokeWidth || 1
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const jsxRuntime = require("../_virtual/jsx-runtime.cjs");
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
4
5
  const useScope = require("../hooks/context/useScope.cjs");
5
6
  const Group = require("../container/Group.cjs");
6
- const Scope = (props) => {
7
- const { children, ref, ...resProps } = props;
8
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useScope.ScopeContext, { value: resProps, children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(Group.default, { ref, children }) });
9
- };
7
+ const Scope = react.forwardRef((props, ref) => {
8
+ const { children, ...resProps } = props;
9
+ return /* @__PURE__ */ jsxRuntime.jsx(useScope.ScopeContext.Provider, { value: resProps, children: /* @__PURE__ */ jsxRuntime.jsx(Group.default, { ref, children }) });
10
+ });
10
11
  exports.default = Scope;
@@ -1,6 +1,6 @@
1
- import { FC, PropsWithChildren } from 'react';
1
+ import { PropsWithChildren } from 'react';
2
2
  import { ScopeProps as ScopeContextProps } from '../hooks/context/useScope';
3
3
  import { GroupProps } from '../container/Group';
4
4
  export type ScopeProps = ScopeContextProps & Omit<GroupProps, 'offset'>;
5
- declare const Scope: FC<PropsWithChildren<ScopeProps>>;
5
+ declare const Scope: import('react').ForwardRefExoticComponent<Omit<PropsWithChildren<ScopeProps>, "ref"> & import('react').RefAttributes<SVGGElement>>;
6
6
  export default Scope;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const jsxRuntime = require("../_virtual/jsx-runtime.cjs");
3
+ const jsxRuntime = require("react/jsx-runtime");
4
4
  const Surface = require("../container/Surface.cjs");
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");
8
8
  const TikZ = (props) => {
9
9
  const { precision = 2, offset, node, draw, ...resProps } = props;
10
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useNodes.NodesContext, { value: /* @__PURE__ */ new Map(), children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useCalculate.CalculateContext, { value: { precision }, children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useScope.ScopeContext, { value: { offset, node, draw }, children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(Surface.default, { ...resProps }) }) }) });
10
+ return /* @__PURE__ */ jsxRuntime.jsx(useNodes.NodesContext.Provider, { value: /* @__PURE__ */ new Map(), children: /* @__PURE__ */ jsxRuntime.jsx(useCalculate.CalculateContext.Provider, { value: { precision }, children: /* @__PURE__ */ jsxRuntime.jsx(useScope.ScopeContext.Provider, { value: { offset, node, draw }, children: /* @__PURE__ */ jsxRuntime.jsx(Surface.default, { ...resProps }) }) }) });
11
11
  };
12
12
  exports.default = TikZ;
@@ -1,24 +1,49 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const jsxRuntime = require("../../_virtual/jsx-runtime.cjs");
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
4
5
  const useScope = require("../../hooks/context/useScope.cjs");
5
6
  const DescartesPoint = require("../../model/geometry/point/DescartesPoint.cjs");
6
7
  const stroke = require("../../utils/style/stroke.cjs");
7
8
  const InnerDraw = require("./InnerDraw.cjs");
8
- const Draw = (props) => {
9
+ const Draw = react.forwardRef((props, ref) => {
9
10
  const { draw: scopeProps } = useScope.default();
10
11
  const realProps = { ...scopeProps, ...props };
11
- const { offset, color, stroke: stroke$1, strokeWidth, startArrow, startArrows, endArrow, endArrows, ...drawProps } = realProps;
12
+ const { offset, color, stroke: stroke$1, strokeWidth, startArrow, startArrows, endArrow, endArrows, ...resProps } = realProps;
12
13
  const realStroke = stroke$1 || color;
13
14
  const realStartArrow = typeof startArrow === "string" ? { type: startArrow } : startArrow;
14
15
  const realStartArrows = typeof startArrows === "string" ? { type: startArrows } : startArrows;
15
16
  const realEndArrow = typeof endArrow === "string" ? { type: endArrow } : endArrow;
16
17
  const realEndArrows = typeof endArrows === "string" ? { type: endArrows } : endArrows;
17
18
  const convertOffset = offset ? DescartesPoint.default.formatPosition(offset) : [0, 0];
18
- const getStrokeTypes = () => drawProps.strokeType ? stroke.convertStrokeType(drawProps.strokeType, strokeWidth || 1) : stroke.convertStrokeShortcut(drawProps, strokeWidth || 1);
19
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
19
+ const getStrokeTypes = () => resProps.strokeType ? stroke.convertStrokeType(resProps.strokeType, strokeWidth ?? 1) : stroke.convertStrokeShortcut(resProps, strokeWidth ?? 1);
20
+ const drawProps = react.useMemo(() => {
21
+ const props2 = { ...resProps };
22
+ [
23
+ "solid",
24
+ "dashed",
25
+ "denselyDashed",
26
+ "looselyDashed",
27
+ "dotted",
28
+ "denselyDotted",
29
+ "looselyDotted",
30
+ "dashDot",
31
+ "denselyDashDot",
32
+ "looselyDashDot",
33
+ "dashDashDot",
34
+ "denselyDashDashDot",
35
+ "looselyDashDashDot"
36
+ ].forEach((key) => {
37
+ if (key in props2) {
38
+ delete props2[key];
39
+ }
40
+ });
41
+ return props2;
42
+ }, [props]);
43
+ return /* @__PURE__ */ jsxRuntime.jsx(
20
44
  InnerDraw.default,
21
45
  {
46
+ ref,
22
47
  ...getStrokeTypes(),
23
48
  offset: convertOffset,
24
49
  stroke: realStroke,
@@ -30,5 +55,5 @@ const Draw = (props) => {
30
55
  ...drawProps
31
56
  }
32
57
  );
33
- };
58
+ });
34
59
  exports.default = Draw;
@@ -1,10 +1,9 @@
1
- import { FC, ReactElement, Ref } from 'react';
1
+ import { ReactElement } from 'react';
2
2
  import { PointPosition } from '../../types/coordinate';
3
3
  import { StrokeProps } from '../../types/svg/stroke';
4
4
  import { StrokeShortcutProps, StrokeType } from '../../utils/style/stroke';
5
5
  import { ArrowProps, DrawWayType } from './types';
6
6
  export type DrawProps = {
7
- ref?: Ref<SVGPathElement>;
8
7
  way: DrawWayType[];
9
8
  /** 位置偏移 */
10
9
  offset?: PointPosition;
@@ -14,5 +13,14 @@ export type DrawProps = {
14
13
  strokeType?: StrokeType;
15
14
  children?: ReactElement | ReactElement[] | null;
16
15
  } & StrokeProps & StrokeShortcutProps & ArrowProps;
17
- declare const Draw: FC<DrawProps>;
16
+ declare const Draw: import('react').ForwardRefExoticComponent<{
17
+ way: DrawWayType[];
18
+ /** 位置偏移 */
19
+ offset?: PointPosition;
20
+ /** 同 stroke */
21
+ color?: string;
22
+ /** 线段样式快捷属性 */
23
+ strokeType?: StrokeType;
24
+ children?: ReactElement | ReactElement[] | null;
25
+ } & StrokeProps & StrokeShortcutProps & ArrowProps & import('react').RefAttributes<SVGPathElement>>;
18
26
  export default Draw;
@@ -1,15 +1,15 @@
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 usePath = require("../../hooks/context/usePath.cjs");
7
7
  const path = require("../../model/component/path.cjs");
8
8
  const common = require("./common.cjs");
9
9
  const index = require("./segment/index.cjs");
10
- const InnerDraw = (props) => {
11
- const { way, ref, offset, startArrow, startArrows, endArrow, endArrows, children, ...strokeProps } = props;
12
- const waySegments = require$$0.useMemo(() => {
10
+ const InnerDraw = react.forwardRef((props, ref) => {
11
+ const { way, offset, startArrow, startArrows, endArrow, endArrows, children, ...strokeProps } = props;
12
+ const waySegments = react.useMemo(() => {
13
13
  let preNodeType = "coordinate";
14
14
  const waySegments2 = [];
15
15
  let waySegment = [];
@@ -28,20 +28,25 @@ const InnerDraw = (props) => {
28
28
  }
29
29
  return waySegments2;
30
30
  }, [way]);
31
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(usePath.PathContext, { value: new path.default(new Array(waySegments.length).fill([]), strokeProps.strokeWidth || 1, false), children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(Group.default, { ref, transform: `translate(${offset[0]}, ${offset[1]})`, children: [
32
- waySegments.map((segment, index$1) => /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
33
- index.default,
34
- {
35
- index: index$1,
36
- isLastSegment: index$1 === waySegments.length - 1,
37
- way: segment,
38
- ...strokeProps,
39
- endArrow: index$1 === waySegments.length - 1 ? endArrow || endArrows : endArrows,
40
- startArrow: index$1 === waySegments.length - 1 ? startArrow || startArrows : startArrows
41
- },
42
- JSON.stringify(segment)
43
- )),
44
- children
45
- ] }) });
46
- };
31
+ return /* @__PURE__ */ jsxRuntime.jsx(
32
+ usePath.PathContext.Provider,
33
+ {
34
+ value: new path.default(new Array(waySegments.length).fill([]), Number(strokeProps.strokeWidth) || 1, false),
35
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Group.default, { ref, transform: `translate(${offset[0]}, ${offset[1]})`, children: [
36
+ waySegments.map((segment, index$1) => /* @__PURE__ */ jsxRuntime.jsx(
37
+ index.default,
38
+ {
39
+ index: index$1,
40
+ way: segment,
41
+ ...strokeProps,
42
+ endArrow: index$1 === waySegments.length - 1 ? endArrow || endArrows : endArrows,
43
+ startArrow: index$1 === waySegments.length - 1 ? startArrow || startArrows : startArrows
44
+ },
45
+ JSON.stringify(segment)
46
+ )),
47
+ children
48
+ ] })
49
+ }
50
+ );
51
+ });
47
52
  exports.default = InnerDraw;
@@ -1,13 +1,17 @@
1
- import { FC, ReactNode, Ref } 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 { ArrowConfig, ArrowProps, DrawWayType } from './types';
5
5
  export type InnerDrawProps = {
6
- ref?: Ref<SVGPathElement>;
7
6
  /** 位置偏移 */
8
7
  offset: Position;
9
8
  way: DrawWayType[];
10
9
  children?: ReactNode;
11
10
  } & StrokeProps & ArrowProps<ArrowConfig>;
12
- declare const InnerDraw: FC<InnerDrawProps>;
11
+ declare const InnerDraw: import('react').ForwardRefExoticComponent<{
12
+ /** 位置偏移 */
13
+ offset: Position;
14
+ way: DrawWayType[];
15
+ children?: ReactNode;
16
+ } & StrokeProps & ArrowProps<ArrowConfig> & import('react').RefAttributes<SVGPathElement>>;
13
17
  export default InnerDraw;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const Draw = require("./Draw.cjs");
4
+ exports.default = Draw.default;
@@ -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 Path = require("../../../elements/Path.cjs");
6
6
  const Group = require("../../../container/Group.cjs");
7
7
  const useArrow = require("./useArrow.cjs");
@@ -10,7 +10,7 @@ const InnerDrawSegment = (props) => {
10
10
  const { way, startArrow, endArrow, ...strokeProps } = props;
11
11
  const pickedArrowStrokeProps = {
12
12
  stroke: strokeProps.stroke,
13
- strokeWidth: strokeProps.strokeWidth,
13
+ strokeWidth: Number(strokeProps.strokeWidth),
14
14
  strokeOpacity: strokeProps.strokeOpacity
15
15
  };
16
16
  const startArrowPath = useArrow.default(
@@ -21,7 +21,7 @@ const InnerDrawSegment = (props) => {
21
21
  { position: way[way.length - 1], nearPosition: way[way.length - 2], arrowType: "end" },
22
22
  endArrow ? { ...pickedArrowStrokeProps, ...endArrow } : void 0
23
23
  );
24
- const d = require$$0.useMemo(() => {
24
+ const d = react.useMemo(() => {
25
25
  const realWay = [...way];
26
26
  if (startArrowPath) {
27
27
  realWay[0] = startArrowPath.linkPoint;
@@ -32,10 +32,10 @@ const InnerDrawSegment = (props) => {
32
32
  const straightLine = line.default().x((d2) => d2[0]).y((d2) => d2[1]);
33
33
  return straightLine(realWay);
34
34
  }, [way]);
35
- return endArrowPath || startArrowPath ? /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(Group.default, { children: [
36
- /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(Path.default, { d: d ?? "", ...strokeProps }),
35
+ return endArrowPath || startArrowPath ? /* @__PURE__ */ jsxRuntime.jsxs(Group.default, { children: [
36
+ /* @__PURE__ */ jsxRuntime.jsx(Path.default, { d: d ?? "", ...strokeProps }),
37
37
  startArrowPath ? startArrowPath.arrowPath : null,
38
38
  endArrowPath ? endArrowPath.arrowPath : null
39
- ] }) : /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(Path.default, { d: d ?? "", ...strokeProps });
39
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(Path.default, { d: d ?? "", ...strokeProps });
40
40
  };
41
41
  exports.default = InnerDrawSegment;
@@ -1,18 +1,18 @@
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 node = require("../../../model/component/node.cjs");
6
6
  const stroke = require("../../../utils/style/stroke.cjs");
7
7
  const Segment = require("./Segment.cjs");
8
8
  const useConvertWay = require("./useConvertWay.cjs");
9
9
  const usePath = require("../../../hooks/context/usePath.cjs");
10
10
  const DrawSegment = (props) => {
11
- const { way, index, color, startArrow, endArrow, isLastSegment, ...resProps } = props;
11
+ const { way, index, startArrow, endArrow, ...resProps } = props;
12
12
  const { strokeType = "solid", strokeWidth = 1, ...strokeProps } = resProps;
13
13
  const [convertedWay, nodesInit] = useConvertWay.default(way);
14
14
  const { model, updateModel } = usePath.default();
15
- const pointWay = require$$0.useMemo(() => {
15
+ const pointWay = react.useMemo(() => {
16
16
  const realWay = convertedWay.map((wayPoint, index2) => {
17
17
  if (wayPoint instanceof node.default) {
18
18
  const neighborPoint = index2 === 0 ? convertedWay[1] : convertedWay[index2 - 1];
@@ -20,13 +20,13 @@ const DrawSegment = (props) => {
20
20
  }
21
21
  return wayPoint;
22
22
  });
23
- const newWay = [...model == null ? void 0 : model.ways];
23
+ const newWay = [...model.ways];
24
24
  newWay[index] = realWay;
25
25
  updateModel({ ways: newWay, init: nodesInit });
26
26
  return realWay;
27
27
  }, [convertedWay]);
28
28
  if (!nodesInit) return null;
29
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
29
+ return /* @__PURE__ */ jsxRuntime.jsx(
30
30
  Segment.default,
31
31
  {
32
32
  way: pointWay,
@@ -1,14 +1,10 @@
1
1
  import { FC } from 'react';
2
2
  import { StrokeProps } from '../../../types/svg/stroke';
3
- import { TikZKey } from '../../../types/tikz';
4
3
  import { ArrowConfig, DrawWaySegmentType } from '../types';
5
4
  export type DrawSegmentProps = {
6
5
  /** 路径,首位可以是 Node,其他必须是坐标 */
7
6
  way: DrawWaySegmentType;
8
7
  index: number;
9
- isLastSegment: boolean;
10
- /** 线段颜色 */
11
- color?: TikZKey;
12
8
  /** 线段样式 */
13
9
  strokeType?: 'solid' | 'dashed' | 'dotted';
14
10
  startArrow?: ArrowConfig;
@@ -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 index = require("../arrow/index.cjs");
7
7
  const Path = require("../../../elements/Path.cjs");
@@ -9,7 +9,7 @@ const line = require("../../../model/equation/line.cjs");
9
9
  const math = require("../../../utils/math.cjs");
10
10
  const useArrow = (linkConfig, arrowConfig) => {
11
11
  const { precision } = useCalculate.default();
12
- return require$$0.useMemo(() => {
12
+ return react.useMemo(() => {
13
13
  if (!arrowConfig) return null;
14
14
  const { position, nearPosition } = linkConfig;
15
15
  const { type, stroke, linkType = "end", round, strokeLinejoin, strokeWidth, ...strokeProps } = arrowConfig;
@@ -33,7 +33,7 @@ const useArrow = (linkConfig, arrowConfig) => {
33
33
  )}) rotate(${math.convertPrecision(degree * (180 / Math.PI), precision)})`;
34
34
  return {
35
35
  linkPoint,
36
- arrowPath: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
36
+ arrowPath: /* @__PURE__ */ jsxRuntime.jsx(
37
37
  Path.default,
38
38
  {
39
39
  d,