@retikz/core 0.0.1-rc.0 → 0.0.1-rc.2
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/dist/es/components/Scope.d.ts +2 -2
- package/dist/es/components/Scope.js +8 -6
- package/dist/es/components/TikZ.js +2 -2
- package/dist/es/components/draw/Draw.d.ts +11 -3
- package/dist/es/components/draw/Draw.js +31 -6
- package/dist/es/components/draw/InnerDraw.d.ts +7 -3
- package/dist/es/components/draw/InnerDraw.js +25 -20
- package/dist/es/components/draw/arrow/circle.d.ts +7 -0
- package/dist/es/components/draw/arrow/circle.js +20 -0
- package/dist/es/components/draw/arrow/index.d.ts +1 -1
- package/dist/es/components/draw/arrow/index.js +3 -0
- package/dist/es/components/draw/common.js +1 -1
- package/dist/es/components/draw/index.js +4 -0
- package/dist/es/components/draw/segment/Segment.js +5 -5
- package/dist/es/components/draw/segment/index.d.ts +0 -4
- package/dist/es/components/draw/segment/index.js +4 -4
- package/dist/es/components/draw/segment/useArrow.js +2 -2
- package/dist/es/components/draw/segment/useConvertWay.d.ts +1 -1
- package/dist/es/components/draw/segment/useConvertWay.js +28 -13
- package/dist/es/components/draw/types.d.ts +1 -1
- package/dist/es/components/node/InnerNode.d.ts +2 -2
- package/dist/es/components/node/InnerNode.js +6 -6
- package/dist/es/components/node/Node.d.ts +42 -3
- package/dist/es/components/node/Node.js +7 -6
- package/dist/es/components/node/_hooks/useNodeConfig.d.ts +1 -1
- package/dist/es/components/node/_hooks/useNodeContent.js +6 -3
- package/dist/es/components/node/_hooks/useNodeShape.js +2 -2
- package/dist/es/components/{pathNode → path-node}/PathNode.d.ts +11 -2
- package/dist/es/components/{pathNode → path-node}/PathNode.js +6 -6
- package/dist/es/container/Group.d.ts +2 -2
- package/dist/es/container/Group.js +5 -4
- package/dist/es/container/Surface.d.ts +4 -2
- package/dist/es/container/Surface.js +7 -7
- package/dist/es/elements/Path.d.ts +2 -2
- package/dist/es/elements/Path.js +5 -4
- package/dist/es/elements/Rect.d.ts +3 -5
- package/dist/es/elements/Rect.js +6 -5
- package/dist/es/elements/Text.d.ts +2 -3
- package/dist/es/elements/Text.js +7 -7
- package/dist/es/hooks/useForceUpdate.d.ts +1 -1
- package/dist/es/index.d.ts +4 -4
- package/dist/es/index.js +1 -1
- package/dist/es/model/equation/line.js +1 -0
- package/dist/es/test.d.ts +1 -0
- package/dist/es/types/svg/stroke.d.ts +2 -2
- package/dist/es/utils/style/stroke.d.ts +4 -3
- package/dist/es/utils/style/stroke.js +4 -2
- package/dist/lib/components/Scope.cjs +7 -5
- package/dist/lib/components/Scope.d.ts +2 -2
- package/dist/lib/components/TikZ.cjs +2 -2
- package/dist/lib/components/draw/Draw.cjs +31 -6
- package/dist/lib/components/draw/Draw.d.ts +11 -3
- package/dist/lib/components/draw/InnerDraw.cjs +26 -21
- package/dist/lib/components/draw/InnerDraw.d.ts +7 -3
- package/dist/lib/components/draw/arrow/circle.cjs +20 -0
- package/dist/lib/components/draw/arrow/circle.d.ts +7 -0
- package/dist/lib/components/draw/arrow/index.cjs +3 -0
- package/dist/lib/components/draw/arrow/index.d.ts +1 -1
- package/dist/lib/components/draw/common.cjs +1 -1
- package/dist/lib/components/draw/index.cjs +4 -0
- package/dist/lib/components/draw/segment/Segment.cjs +7 -7
- package/dist/lib/components/draw/segment/index.cjs +6 -6
- package/dist/lib/components/draw/segment/index.d.ts +0 -4
- package/dist/lib/components/draw/segment/useArrow.cjs +4 -4
- package/dist/lib/components/draw/segment/useConvertWay.cjs +32 -17
- package/dist/lib/components/draw/segment/useConvertWay.d.ts +1 -1
- package/dist/lib/components/draw/types.d.ts +1 -1
- package/dist/lib/components/node/InnerNode.cjs +15 -15
- package/dist/lib/components/node/InnerNode.d.ts +2 -2
- package/dist/lib/components/node/Node.cjs +12 -11
- package/dist/lib/components/node/Node.d.ts +42 -3
- package/dist/lib/components/node/_hooks/useNodeConfig.cjs +2 -2
- package/dist/lib/components/node/_hooks/useNodeConfig.d.ts +1 -1
- package/dist/lib/components/node/_hooks/useNodeContent.cjs +9 -6
- package/dist/lib/components/node/_hooks/useNodeShape.cjs +4 -4
- package/dist/lib/components/{pathNode → path-node}/PathNode.cjs +12 -12
- package/dist/lib/components/{pathNode → path-node}/PathNode.d.ts +11 -2
- package/dist/lib/components/{pathNode → path-node}/useAnchor.cjs +4 -4
- package/dist/lib/container/Group.cjs +5 -4
- package/dist/lib/container/Group.d.ts +2 -2
- package/dist/lib/container/Surface.cjs +8 -8
- package/dist/lib/container/Surface.d.ts +4 -2
- package/dist/lib/elements/Path.cjs +5 -4
- package/dist/lib/elements/Path.d.ts +2 -2
- package/dist/lib/elements/Rect.cjs +6 -5
- package/dist/lib/elements/Rect.d.ts +3 -5
- package/dist/lib/elements/Text.cjs +8 -8
- package/dist/lib/elements/Text.d.ts +2 -3
- package/dist/lib/hooks/context/useCalculate.cjs +3 -3
- package/dist/lib/hooks/context/useNodes.cjs +3 -3
- package/dist/lib/hooks/context/usePath.cjs +3 -3
- package/dist/lib/hooks/context/useScope.cjs +3 -3
- package/dist/lib/hooks/useForceUpdate.cjs +2 -2
- package/dist/lib/hooks/useForceUpdate.d.ts +1 -1
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/model/equation/line.cjs +1 -0
- package/dist/lib/test.d.ts +1 -0
- package/dist/lib/types/svg/stroke.d.ts +2 -2
- package/dist/lib/utils/style/stroke.cjs +4 -2
- package/dist/lib/utils/style/stroke.d.ts +4 -3
- package/package.json +16 -15
- package/dist/es/_virtual/jsx-runtime.js +0 -5
- package/dist/es/_virtual/jsx-runtime2.js +0 -4
- package/dist/es/_virtual/react-jsx-runtime.development.js +0 -4
- package/dist/es/_virtual/react-jsx-runtime.production.js +0 -4
- package/dist/es/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.development.js +0 -20
- package/dist/es/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.production.js +0 -41
- package/dist/es/node_modules/.pnpm/react@19.0.0/node_modules/react/jsx-runtime.js +0 -17
- package/dist/lib/_virtual/jsx-runtime.cjs +0 -5
- package/dist/lib/_virtual/jsx-runtime2.cjs +0 -4
- package/dist/lib/_virtual/react-jsx-runtime.development.cjs +0 -4
- package/dist/lib/_virtual/react-jsx-runtime.production.cjs +0 -4
- package/dist/lib/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.development.cjs +0 -20
- package/dist/lib/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.production.cjs +0 -41
- package/dist/lib/node_modules/.pnpm/react@19.0.0/node_modules/react/jsx-runtime.cjs +0 -17
- /package/dist/es/components/{pathNode → path-node}/index.d.ts +0 -0
- /package/dist/es/components/{pathNode → path-node}/index.js +0 -0
- /package/dist/es/components/{pathNode → path-node}/useAnchor.d.ts +0 -0
- /package/dist/es/components/{pathNode → path-node}/useAnchor.js +0 -0
- /package/dist/lib/components/{pathNode → path-node}/index.cjs +0 -0
- /package/dist/lib/components/{pathNode → path-node}/index.d.ts +0 -0
- /package/dist/lib/components/{pathNode → path-node}/useAnchor.d.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const jsxRuntime = require("
|
|
4
|
-
const
|
|
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,
|
|
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 =
|
|
16
|
+
const id = react.useId();
|
|
17
17
|
const realName = name ?? id;
|
|
18
18
|
const { precision } = useCalculate.default();
|
|
19
|
-
const posRadio =
|
|
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 =
|
|
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] =
|
|
37
|
+
const [adjustOffset, setAdjustOffset] = react.useState(DescartesPoint.default.plus(anchorPosition, offset));
|
|
38
38
|
const { getModel } = useNodes.default();
|
|
39
|
-
const rotate =
|
|
39
|
+
const rotate = react.useMemo(() => {
|
|
40
40
|
if (!sloped) return 0;
|
|
41
41
|
return anchorAngle * (180 / Math.PI);
|
|
42
42
|
}, [sloped, anchorAngle]);
|
|
43
|
-
|
|
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.
|
|
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:
|
|
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
|
|
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 =
|
|
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
|
-
|
|
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
|
|
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("
|
|
4
|
-
const
|
|
5
|
-
|
|
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 {
|
|
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:
|
|
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("
|
|
4
|
-
const
|
|
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 =
|
|
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.
|
|
18
|
-
title ? /* @__PURE__ */ jsxRuntime.
|
|
19
|
-
desc ? /* @__PURE__ */ jsxRuntime.
|
|
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
|
|
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:
|
|
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("
|
|
4
|
-
const
|
|
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.
|
|
12
|
-
};
|
|
12
|
+
return /* @__PURE__ */ jsxRuntime.jsx("path", { ref, ...defaultProps, ...otherProps });
|
|
13
|
+
});
|
|
13
14
|
exports.default = Path;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SVGProps } from 'react';
|
|
2
2
|
export type PathProps = {} & SVGProps<SVGPathElement>;
|
|
3
|
-
declare const Path:
|
|
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("
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
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 {
|
|
2
|
-
export type RectProps =
|
|
3
|
-
|
|
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,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const jsxRuntime = require("
|
|
4
|
-
const
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const react = require("react");
|
|
5
5
|
const string = require("../utils/string.cjs");
|
|
6
|
-
const Text = (props) => {
|
|
7
|
-
const { children,
|
|
8
|
-
const dominantBaseline =
|
|
6
|
+
const Text = react.forwardRef((props, ref) => {
|
|
7
|
+
const { children, align, verticalAlign, fontSize, fill, ...otherProps } = props;
|
|
8
|
+
const dominantBaseline = react.useMemo(() => {
|
|
9
9
|
switch (verticalAlign) {
|
|
10
10
|
case "top":
|
|
11
11
|
return "text-top";
|
|
@@ -26,10 +26,10 @@ const Text = (props) => {
|
|
|
26
26
|
};
|
|
27
27
|
const parseChildren = (children2) => {
|
|
28
28
|
if (typeof children2 === "string") {
|
|
29
|
-
return string.textWrapParse(children2).map((child, index) => /* @__PURE__ */ jsxRuntime.
|
|
29
|
+
return string.textWrapParse(children2).map((child, index) => /* @__PURE__ */ jsxRuntime.jsx("tspan", { children: child }, index));
|
|
30
30
|
}
|
|
31
31
|
return children2;
|
|
32
32
|
};
|
|
33
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
34
|
-
};
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsx("text", { ref, ...textProps, children: parseChildren(children) });
|
|
34
|
+
});
|
|
35
35
|
exports.default = Text;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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:
|
|
17
|
+
declare const Text: import('react').ForwardRefExoticComponent<Omit<PropsWithChildren<TextProps>, "ref"> & import('react').RefAttributes<SVGTextElement>>;
|
|
19
18
|
export default Text;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const
|
|
4
|
-
const CalculateContext =
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const CalculateContext = react.createContext({ precision: 2 });
|
|
5
5
|
const useCalculate = () => {
|
|
6
|
-
return
|
|
6
|
+
return react.useContext(CalculateContext);
|
|
7
7
|
};
|
|
8
8
|
exports.CalculateContext = CalculateContext;
|
|
9
9
|
exports.default = useCalculate;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const
|
|
3
|
+
const react = require("react");
|
|
4
4
|
const node = require("../../model/component/node.cjs");
|
|
5
|
-
const NodesContext =
|
|
5
|
+
const NodesContext = react.createContext(/* @__PURE__ */ new Map());
|
|
6
6
|
const useNodes = () => {
|
|
7
|
-
const nodes =
|
|
7
|
+
const nodes = react.useContext(NodesContext);
|
|
8
8
|
return {
|
|
9
9
|
subscribeModel: (name, listener) => {
|
|
10
10
|
const model = nodes.get(name);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const
|
|
4
|
-
const PathContext =
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const PathContext = react.createContext(null);
|
|
5
5
|
const usePath = () => {
|
|
6
|
-
const pathModel =
|
|
6
|
+
const pathModel = react.useContext(PathContext);
|
|
7
7
|
if (!pathModel) throw new Error("usePath must be used within a PathProvider");
|
|
8
8
|
return {
|
|
9
9
|
model: pathModel,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const
|
|
4
|
-
const ScopeContext =
|
|
5
|
-
const useScope = () =>
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const ScopeContext = react.createContext({});
|
|
5
|
+
const useScope = () => react.useContext(ScopeContext);
|
|
6
6
|
exports.ScopeContext = ScopeContext;
|
|
7
7
|
exports.default = useScope;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const
|
|
3
|
+
const react = require("react");
|
|
4
4
|
const useForceUpdate = () => {
|
|
5
|
-
const [_, forceUpdate] =
|
|
5
|
+
const [_, forceUpdate] = react.useReducer(() => ({}), {});
|
|
6
6
|
return forceUpdate;
|
|
7
7
|
};
|
|
8
8
|
exports.default = useForceUpdate;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const useForceUpdate: () => import('react').
|
|
1
|
+
declare const useForceUpdate: () => import('react').DispatchWithoutAction;
|
|
2
2
|
export default useForceUpdate;
|
package/dist/lib/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const Draw = require("./components/draw/Draw.cjs");
|
|
4
4
|
const Node = require("./components/node/Node.cjs");
|
|
5
|
-
const PathNode = require("./components/
|
|
5
|
+
const PathNode = require("./components/path-node/PathNode.cjs");
|
|
6
6
|
const Scope = require("./components/Scope.cjs");
|
|
7
7
|
const TikZ = require("./components/TikZ.cjs");
|
|
8
8
|
exports.Draw = Draw.default;
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { default as Draw } from './components/draw
|
|
2
|
-
export type { DrawProps } from './components/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/
|
|
6
|
-
export type { PathNodeProps } from './components/
|
|
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';
|
|
@@ -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?:
|
|
7
|
+
strokeLinejoin?: 'round' | 'inherit' | 'bevel' | 'miter';
|
|
8
8
|
strokeMiterlimit?: number;
|
|
9
9
|
strokeOpacity?: number;
|
|
10
10
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const convertStrokeType = (strokeType,
|
|
3
|
+
const convertStrokeType = (strokeType, oriStrokeWidth = 1) => {
|
|
4
|
+
const strokeWidth = Number(oriStrokeWidth);
|
|
4
5
|
switch (strokeType) {
|
|
5
6
|
case "solid":
|
|
6
7
|
return {};
|
|
@@ -30,7 +31,8 @@ const convertStrokeType = (strokeType, strokeWidth = 1) => {
|
|
|
30
31
|
return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 6} 1 ${strokeWidth * 6} 1 ${strokeWidth * 6}` };
|
|
31
32
|
}
|
|
32
33
|
};
|
|
33
|
-
const convertStrokeShortcut = (shortcutProps,
|
|
34
|
+
const convertStrokeShortcut = (shortcutProps, oriStrokeWidth = 1) => {
|
|
35
|
+
const strokeWidth = Number(oriStrokeWidth);
|
|
34
36
|
return convertStrokeType(
|
|
35
37
|
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",
|
|
36
38
|
strokeWidth || 1
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StrokeProps } from '../../types/svg/stroke';
|
|
2
|
-
export
|
|
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,
|
|
19
|
-
export declare const convertStrokeShortcut: (shortcutProps: StrokeShortcutProps,
|
|
19
|
+
export declare const convertStrokeType: (strokeType: StrokeType, oriStrokeWidth?: string | number) => Partial<StrokeProps>;
|
|
20
|
+
export declare const convertStrokeShortcut: (shortcutProps: StrokeShortcutProps, oriStrokeWidth?: string | number) => Partial<StrokeProps>;
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retikz/core",
|
|
3
|
-
"version": "0.0.1-rc.
|
|
3
|
+
"version": "0.0.1-rc.2",
|
|
4
4
|
"description": "atomic drawing library implemented using react and d3, inspired by tikz",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"homepage": "https://pionpill.github.io/retikz.doc/",
|
|
6
7
|
"keywords": [
|
|
7
8
|
"react",
|
|
8
9
|
"tikz",
|
|
@@ -10,7 +11,7 @@
|
|
|
10
11
|
],
|
|
11
12
|
"license": "MIT",
|
|
12
13
|
"repository": "https://github.com/Pionpill/retikz",
|
|
13
|
-
"main": "dist/lib/index.
|
|
14
|
+
"main": "dist/lib/index.cjs",
|
|
14
15
|
"module": "dist/es/index.js",
|
|
15
16
|
"types": "dist/lib/index.d.ts",
|
|
16
17
|
"publishConfig": {
|
|
@@ -21,29 +22,23 @@
|
|
|
21
22
|
"README.md",
|
|
22
23
|
"dist/**/*"
|
|
23
24
|
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
"dev": "vite",
|
|
26
|
-
"build": "vite build",
|
|
27
|
-
"lint": "eslint .",
|
|
28
|
-
"preview": "vite preview"
|
|
29
|
-
},
|
|
30
25
|
"peerDependencies": {
|
|
31
|
-
"react": ">=
|
|
32
|
-
"react-dom": ">=
|
|
26
|
+
"react": ">=18",
|
|
27
|
+
"react-dom": ">=18"
|
|
33
28
|
},
|
|
34
29
|
"dependencies": {
|
|
35
30
|
"d3-color": "^3.1.0",
|
|
36
31
|
"d3-shape": "^3.2.0",
|
|
37
|
-
"react": "
|
|
38
|
-
"react-dom": "
|
|
32
|
+
"react": "~18.3",
|
|
33
|
+
"react-dom": "~18.3"
|
|
39
34
|
},
|
|
40
35
|
"devDependencies": {
|
|
41
36
|
"@eslint/js": "^9.15.0",
|
|
42
37
|
"@types/d3-color": "^3.1.3",
|
|
43
38
|
"@types/d3-shape": "^3.1.6",
|
|
44
39
|
"@types/node": "^22.10.7",
|
|
45
|
-
"@types/react": "
|
|
46
|
-
"@types/react-dom": "
|
|
40
|
+
"@types/react": "~18.3",
|
|
41
|
+
"@types/react-dom": "~18.3",
|
|
47
42
|
"@vitejs/plugin-react": "^4.3.4",
|
|
48
43
|
"eslint": "^9.15.0",
|
|
49
44
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
@@ -53,5 +48,11 @@
|
|
|
53
48
|
"typescript-eslint": "^8.15.0",
|
|
54
49
|
"vite": "^6.0.1",
|
|
55
50
|
"vite-plugin-dts": "^4.5.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"dev": "vite",
|
|
54
|
+
"build": "vite build",
|
|
55
|
+
"lint": "eslint .",
|
|
56
|
+
"preview": "vite preview"
|
|
56
57
|
}
|
|
57
|
-
}
|
|
58
|
+
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { __exports as reactJsxRuntime_development } from "../../../../../../_virtual/react-jsx-runtime.development.js";
|
|
2
|
-
import require$$0 from "react";
|
|
3
|
-
/**
|
|
4
|
-
* @license React
|
|
5
|
-
* react-jsx-runtime.development.js
|
|
6
|
-
*
|
|
7
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the MIT license found in the
|
|
10
|
-
* LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/
|
|
12
|
-
var hasRequiredReactJsxRuntime_development;
|
|
13
|
-
function requireReactJsxRuntime_development() {
|
|
14
|
-
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
15
|
-
hasRequiredReactJsxRuntime_development = 1;
|
|
16
|
-
return reactJsxRuntime_development;
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
requireReactJsxRuntime_development as __require
|
|
20
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { __exports as reactJsxRuntime_production } from "../../../../../../_virtual/react-jsx-runtime.production.js";
|
|
2
|
-
/**
|
|
3
|
-
* @license React
|
|
4
|
-
* react-jsx-runtime.production.js
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
7
|
-
*
|
|
8
|
-
* This source code is licensed under the MIT license found in the
|
|
9
|
-
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/
|
|
11
|
-
var hasRequiredReactJsxRuntime_production;
|
|
12
|
-
function requireReactJsxRuntime_production() {
|
|
13
|
-
if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
|
|
14
|
-
hasRequiredReactJsxRuntime_production = 1;
|
|
15
|
-
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
16
|
-
function jsxProd(type, config, maybeKey) {
|
|
17
|
-
var key = null;
|
|
18
|
-
void 0 !== maybeKey && (key = "" + maybeKey);
|
|
19
|
-
void 0 !== config.key && (key = "" + config.key);
|
|
20
|
-
if ("key" in config) {
|
|
21
|
-
maybeKey = {};
|
|
22
|
-
for (var propName in config)
|
|
23
|
-
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
24
|
-
} else maybeKey = config;
|
|
25
|
-
config = maybeKey.ref;
|
|
26
|
-
return {
|
|
27
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
28
|
-
type,
|
|
29
|
-
key,
|
|
30
|
-
ref: void 0 !== config ? config : null,
|
|
31
|
-
props: maybeKey
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
35
|
-
reactJsxRuntime_production.jsx = jsxProd;
|
|
36
|
-
reactJsxRuntime_production.jsxs = jsxProd;
|
|
37
|
-
return reactJsxRuntime_production;
|
|
38
|
-
}
|
|
39
|
-
export {
|
|
40
|
-
requireReactJsxRuntime_production as __require
|
|
41
|
-
};
|