@retikz/core 0.0.1-rc.0
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/LICENSE +21 -0
- package/README.md +2 -0
- package/dist/es/_virtual/jsx-runtime.js +5 -0
- package/dist/es/_virtual/jsx-runtime2.js +4 -0
- package/dist/es/_virtual/react-jsx-runtime.development.js +4 -0
- package/dist/es/_virtual/react-jsx-runtime.production.js +4 -0
- package/dist/es/components/Scope.d.ts +6 -0
- package/dist/es/components/Scope.js +10 -0
- package/dist/es/components/TikZ.d.ts +9 -0
- package/dist/es/components/TikZ.js +12 -0
- package/dist/es/components/draw/Draw.d.ts +18 -0
- package/dist/es/components/draw/Draw.js +34 -0
- package/dist/es/components/draw/InnerDraw.d.ts +13 -0
- package/dist/es/components/draw/InnerDraw.js +47 -0
- package/dist/es/components/draw/arrow/index.d.ts +9 -0
- package/dist/es/components/draw/arrow/index.js +10 -0
- package/dist/es/components/draw/arrow/stealth.d.ts +7 -0
- package/dist/es/components/draw/arrow/stealth.js +29 -0
- package/dist/es/components/draw/arrow/types.d.ts +21 -0
- package/dist/es/components/draw/common.d.ts +4 -0
- package/dist/es/components/draw/common.js +12 -0
- package/dist/es/components/draw/index.d.ts +3 -0
- package/dist/es/components/draw/segment/Segment.d.ts +12 -0
- package/dist/es/components/draw/segment/Segment.js +41 -0
- package/dist/es/components/draw/segment/index.d.ts +19 -0
- package/dist/es/components/draw/segment/index.js +41 -0
- package/dist/es/components/draw/segment/useArrow.d.ts +12 -0
- package/dist/es/components/draw/segment/useArrow.js +52 -0
- package/dist/es/components/draw/segment/useConvertWay.d.ts +14 -0
- package/dist/es/components/draw/segment/useConvertWay.js +95 -0
- package/dist/es/components/draw/types.d.ts +29 -0
- package/dist/es/components/node/InnerNode.d.ts +33 -0
- package/dist/es/components/node/InnerNode.js +88 -0
- package/dist/es/components/node/Node.d.ts +54 -0
- package/dist/es/components/node/Node.js +87 -0
- package/dist/es/components/node/_hooks/useNodeConfig.d.ts +3 -0
- package/dist/es/components/node/_hooks/useNodeConfig.js +13 -0
- package/dist/es/components/node/_hooks/useNodeContent.d.ts +4 -0
- package/dist/es/components/node/_hooks/useNodeContent.js +27 -0
- package/dist/es/components/node/_hooks/useNodeShape.d.ts +4 -0
- package/dist/es/components/node/_hooks/useNodeShape.js +34 -0
- package/dist/es/components/node/index.d.ts +3 -0
- package/dist/es/components/node/index.js +4 -0
- package/dist/es/components/pathNode/PathNode.d.ts +39 -0
- package/dist/es/components/pathNode/PathNode.js +76 -0
- package/dist/es/components/pathNode/index.d.ts +3 -0
- package/dist/es/components/pathNode/index.js +4 -0
- package/dist/es/components/pathNode/useAnchor.d.ts +6 -0
- package/dist/es/components/pathNode/useAnchor.js +49 -0
- package/dist/es/container/Group.d.ts +6 -0
- package/dist/es/container/Group.js +7 -0
- package/dist/es/container/Surface.d.ts +17 -0
- package/dist/es/container/Surface.js +23 -0
- package/dist/es/elements/Path.d.ts +4 -0
- package/dist/es/elements/Path.js +13 -0
- package/dist/es/elements/Rect.d.ts +6 -0
- package/dist/es/elements/Rect.js +8 -0
- package/dist/es/elements/Text.d.ts +19 -0
- package/dist/es/elements/Text.js +35 -0
- package/dist/es/hooks/context/useCalculate.d.ts +7 -0
- package/dist/es/hooks/context/useCalculate.js +9 -0
- package/dist/es/hooks/context/useNodes.d.ts +9 -0
- package/dist/es/hooks/context/useNodes.js +33 -0
- package/dist/es/hooks/context/usePath.d.ts +13 -0
- package/dist/es/hooks/context/usePath.js +20 -0
- package/dist/es/hooks/context/useScope.d.ts +11 -0
- package/dist/es/hooks/context/useScope.js +7 -0
- package/dist/es/hooks/useForceUpdate.d.ts +2 -0
- package/dist/es/hooks/useForceUpdate.js +8 -0
- package/dist/es/index.d.ts +10 -0
- package/dist/es/index.js +12 -0
- package/dist/es/model/component/node.d.ts +45 -0
- package/dist/es/model/component/node.js +164 -0
- package/dist/es/model/component/path.d.ts +19 -0
- package/dist/es/model/component/path.js +47 -0
- package/dist/es/model/equation/line.d.ts +21 -0
- package/dist/es/model/equation/line.js +75 -0
- package/dist/es/model/geometry/point/DescartesPoint.d.ts +21 -0
- package/dist/es/model/geometry/point/DescartesPoint.js +50 -0
- package/dist/es/model/geometry/point/PolarPoint.d.ts +14 -0
- package/dist/es/model/geometry/point/PolarPoint.js +27 -0
- package/dist/es/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.js +338 -0
- package/dist/es/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.js +13 -0
- package/dist/es/node_modules/.pnpm/d3-path@3.1.0/node_modules/d3-path/src/path.js +88 -0
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/array.js +6 -0
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/constant.js +8 -0
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/linear.js +39 -0
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.js +41 -0
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/path.js +19 -0
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/point.js +10 -0
- package/dist/es/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.development.js +20 -0
- package/dist/es/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.production.js +41 -0
- package/dist/es/node_modules/.pnpm/react@19.0.0/node_modules/react/jsx-runtime.js +17 -0
- package/dist/es/types/coordinate/descartes.d.ts +23 -0
- package/dist/es/types/coordinate/index.d.ts +5 -0
- package/dist/es/types/coordinate/polar.d.ts +5 -0
- package/dist/es/types/distance/index.d.ts +8 -0
- package/dist/es/types/distance/sep.d.ts +9 -0
- package/dist/es/types/shape/index.d.ts +8 -0
- package/dist/es/types/shape/index.js +9 -0
- package/dist/es/types/shape/rect.d.ts +25 -0
- package/dist/es/types/shape/rect.js +30 -0
- package/dist/es/types/svg/font.d.ts +10 -0
- package/dist/es/types/svg/stroke.d.ts +10 -0
- package/dist/es/types/tikz/index.d.ts +6 -0
- package/dist/es/utils/compare.d.ts +4 -0
- package/dist/es/utils/compare.js +20 -0
- package/dist/es/utils/css.d.ts +6 -0
- package/dist/es/utils/css.js +26 -0
- package/dist/es/utils/math.d.ts +9 -0
- package/dist/es/utils/math.js +26 -0
- package/dist/es/utils/string.d.ts +7 -0
- package/dist/es/utils/string.js +7 -0
- package/dist/es/utils/style/font.d.ts +17 -0
- package/dist/es/utils/style/font.js +34 -0
- package/dist/es/utils/style/stroke.d.ts +19 -0
- package/dist/es/utils/style/stroke.js +40 -0
- package/dist/lib/_virtual/jsx-runtime.cjs +5 -0
- package/dist/lib/_virtual/jsx-runtime2.cjs +4 -0
- package/dist/lib/_virtual/react-jsx-runtime.development.cjs +4 -0
- package/dist/lib/_virtual/react-jsx-runtime.production.cjs +4 -0
- package/dist/lib/components/Scope.cjs +10 -0
- package/dist/lib/components/Scope.d.ts +6 -0
- package/dist/lib/components/TikZ.cjs +12 -0
- package/dist/lib/components/TikZ.d.ts +9 -0
- package/dist/lib/components/draw/Draw.cjs +34 -0
- package/dist/lib/components/draw/Draw.d.ts +18 -0
- package/dist/lib/components/draw/InnerDraw.cjs +47 -0
- package/dist/lib/components/draw/InnerDraw.d.ts +13 -0
- package/dist/lib/components/draw/arrow/index.cjs +10 -0
- package/dist/lib/components/draw/arrow/index.d.ts +9 -0
- package/dist/lib/components/draw/arrow/stealth.cjs +29 -0
- package/dist/lib/components/draw/arrow/stealth.d.ts +7 -0
- package/dist/lib/components/draw/arrow/types.d.ts +21 -0
- package/dist/lib/components/draw/common.cjs +12 -0
- package/dist/lib/components/draw/common.d.ts +4 -0
- package/dist/lib/components/draw/index.d.ts +3 -0
- package/dist/lib/components/draw/segment/Segment.cjs +41 -0
- package/dist/lib/components/draw/segment/Segment.d.ts +12 -0
- package/dist/lib/components/draw/segment/index.cjs +41 -0
- package/dist/lib/components/draw/segment/index.d.ts +19 -0
- package/dist/lib/components/draw/segment/useArrow.cjs +52 -0
- package/dist/lib/components/draw/segment/useArrow.d.ts +12 -0
- package/dist/lib/components/draw/segment/useConvertWay.cjs +95 -0
- package/dist/lib/components/draw/segment/useConvertWay.d.ts +14 -0
- package/dist/lib/components/draw/types.d.ts +29 -0
- package/dist/lib/components/node/InnerNode.cjs +88 -0
- package/dist/lib/components/node/InnerNode.d.ts +33 -0
- package/dist/lib/components/node/Node.cjs +87 -0
- package/dist/lib/components/node/Node.d.ts +54 -0
- package/dist/lib/components/node/_hooks/useNodeConfig.cjs +13 -0
- package/dist/lib/components/node/_hooks/useNodeConfig.d.ts +3 -0
- package/dist/lib/components/node/_hooks/useNodeContent.cjs +27 -0
- package/dist/lib/components/node/_hooks/useNodeContent.d.ts +4 -0
- package/dist/lib/components/node/_hooks/useNodeShape.cjs +34 -0
- package/dist/lib/components/node/_hooks/useNodeShape.d.ts +4 -0
- package/dist/lib/components/node/index.cjs +4 -0
- package/dist/lib/components/node/index.d.ts +3 -0
- package/dist/lib/components/pathNode/PathNode.cjs +76 -0
- package/dist/lib/components/pathNode/PathNode.d.ts +39 -0
- package/dist/lib/components/pathNode/index.cjs +4 -0
- package/dist/lib/components/pathNode/index.d.ts +3 -0
- package/dist/lib/components/pathNode/useAnchor.cjs +49 -0
- package/dist/lib/components/pathNode/useAnchor.d.ts +6 -0
- package/dist/lib/container/Group.cjs +7 -0
- package/dist/lib/container/Group.d.ts +6 -0
- package/dist/lib/container/Surface.cjs +23 -0
- package/dist/lib/container/Surface.d.ts +17 -0
- package/dist/lib/elements/Path.cjs +13 -0
- package/dist/lib/elements/Path.d.ts +4 -0
- package/dist/lib/elements/Rect.cjs +8 -0
- package/dist/lib/elements/Rect.d.ts +6 -0
- package/dist/lib/elements/Text.cjs +35 -0
- package/dist/lib/elements/Text.d.ts +19 -0
- package/dist/lib/hooks/context/useCalculate.cjs +9 -0
- package/dist/lib/hooks/context/useCalculate.d.ts +7 -0
- package/dist/lib/hooks/context/useNodes.cjs +33 -0
- package/dist/lib/hooks/context/useNodes.d.ts +9 -0
- package/dist/lib/hooks/context/usePath.cjs +20 -0
- package/dist/lib/hooks/context/usePath.d.ts +13 -0
- package/dist/lib/hooks/context/useScope.cjs +7 -0
- package/dist/lib/hooks/context/useScope.d.ts +11 -0
- package/dist/lib/hooks/useForceUpdate.cjs +8 -0
- package/dist/lib/hooks/useForceUpdate.d.ts +2 -0
- package/dist/lib/index.cjs +12 -0
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/model/component/node.cjs +164 -0
- package/dist/lib/model/component/node.d.ts +45 -0
- package/dist/lib/model/component/path.cjs +47 -0
- package/dist/lib/model/component/path.d.ts +19 -0
- package/dist/lib/model/equation/line.cjs +75 -0
- package/dist/lib/model/equation/line.d.ts +21 -0
- package/dist/lib/model/geometry/point/DescartesPoint.cjs +50 -0
- package/dist/lib/model/geometry/point/DescartesPoint.d.ts +21 -0
- package/dist/lib/model/geometry/point/PolarPoint.cjs +27 -0
- package/dist/lib/model/geometry/point/PolarPoint.d.ts +14 -0
- package/dist/lib/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.cjs +338 -0
- package/dist/lib/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.cjs +13 -0
- package/dist/lib/node_modules/.pnpm/d3-path@3.1.0/node_modules/d3-path/src/path.cjs +88 -0
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/array.cjs +6 -0
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/constant.cjs +8 -0
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/linear.cjs +39 -0
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.cjs +41 -0
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/path.cjs +19 -0
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/point.cjs +10 -0
- package/dist/lib/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.development.cjs +20 -0
- package/dist/lib/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.production.cjs +41 -0
- package/dist/lib/node_modules/.pnpm/react@19.0.0/node_modules/react/jsx-runtime.cjs +17 -0
- package/dist/lib/types/coordinate/descartes.d.ts +23 -0
- package/dist/lib/types/coordinate/index.d.ts +5 -0
- package/dist/lib/types/coordinate/polar.d.ts +5 -0
- package/dist/lib/types/distance/index.d.ts +8 -0
- package/dist/lib/types/distance/sep.d.ts +9 -0
- package/dist/lib/types/shape/index.cjs +9 -0
- package/dist/lib/types/shape/index.d.ts +8 -0
- package/dist/lib/types/shape/rect.cjs +30 -0
- package/dist/lib/types/shape/rect.d.ts +25 -0
- package/dist/lib/types/svg/font.d.ts +10 -0
- package/dist/lib/types/svg/stroke.d.ts +10 -0
- package/dist/lib/types/tikz/index.d.ts +6 -0
- package/dist/lib/utils/compare.cjs +20 -0
- package/dist/lib/utils/compare.d.ts +4 -0
- package/dist/lib/utils/css.cjs +26 -0
- package/dist/lib/utils/css.d.ts +6 -0
- package/dist/lib/utils/math.cjs +26 -0
- package/dist/lib/utils/math.d.ts +9 -0
- package/dist/lib/utils/string.cjs +7 -0
- package/dist/lib/utils/string.d.ts +7 -0
- package/dist/lib/utils/style/font.cjs +34 -0
- package/dist/lib/utils/style/font.d.ts +17 -0
- package/dist/lib/utils/style/stroke.cjs +40 -0
- package/dist/lib/utils/style/stroke.d.ts +19 -0
- package/package.json +57 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { FC, ReactNode, Ref } from 'react';
|
|
2
|
+
import { NodeShape } from './InnerNode';
|
|
3
|
+
import { CssDistanceType } from '../../types/distance';
|
|
4
|
+
import { SepProps } from '../../types/distance/sep';
|
|
5
|
+
import { StrokeProps } from '../../types/svg/stroke';
|
|
6
|
+
import { TikZKey } from '../../types/tikz';
|
|
7
|
+
import { StrokeShortcutProps, StrokeType } from '../../utils/style/stroke';
|
|
8
|
+
import { PointPosition } from '../../types/coordinate';
|
|
9
|
+
import { TikZFontSize } from '../../utils/style/font';
|
|
10
|
+
import { FontProps } from '../../types/svg/font';
|
|
11
|
+
export type NodeProps = {
|
|
12
|
+
name?: TikZKey;
|
|
13
|
+
ref?: Ref<SVGGElement>;
|
|
14
|
+
/** 位置 */
|
|
15
|
+
position?: PointPosition;
|
|
16
|
+
/** 位置偏移 */
|
|
17
|
+
offset?: PointPosition;
|
|
18
|
+
/** 内容宽度 */
|
|
19
|
+
width?: CssDistanceType;
|
|
20
|
+
/** 内容高度 */
|
|
21
|
+
height?: CssDistanceType;
|
|
22
|
+
/** 内容(文本)颜色 */
|
|
23
|
+
color?: 'currentColor' | 'auto' | string;
|
|
24
|
+
/** 内容(文本)透明度 */
|
|
25
|
+
opacity?: number;
|
|
26
|
+
/** 内容(文本)字体大小 */
|
|
27
|
+
size?: string | TikZFontSize | number;
|
|
28
|
+
/** 内容 */
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
/** 边框形状 */
|
|
31
|
+
shape?: NodeShape;
|
|
32
|
+
/** 边框圆角 */
|
|
33
|
+
r?: CssDistanceType;
|
|
34
|
+
/** 边框圆角-x */
|
|
35
|
+
rx?: CssDistanceType;
|
|
36
|
+
/** 边框圆角-y */
|
|
37
|
+
ry?: CssDistanceType;
|
|
38
|
+
/** 背景填充色,默认为 auto */
|
|
39
|
+
fill?: string | 'auto';
|
|
40
|
+
/** 背景填充色透明度 */
|
|
41
|
+
fillOpacity?: number;
|
|
42
|
+
/** 边框样式 */
|
|
43
|
+
strokeType?: StrokeType;
|
|
44
|
+
/** 内边距 */
|
|
45
|
+
innerSep?: CssDistanceType | SepProps;
|
|
46
|
+
/** 外边距 */
|
|
47
|
+
outerSep?: CssDistanceType | SepProps;
|
|
48
|
+
/** 旋转 */
|
|
49
|
+
rotate?: number;
|
|
50
|
+
/** 样式 */
|
|
51
|
+
style?: 'bold' | 'italic' | 'serif' | 'sans-serif';
|
|
52
|
+
} & Partial<FontProps> & Partial<StrokeProps> & StrokeShortcutProps;
|
|
53
|
+
declare const Node: FC<NodeProps>;
|
|
54
|
+
export default Node;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const require$$0 = require("react");
|
|
4
|
+
const useNodeConfig = () => {
|
|
5
|
+
const configRef = require$$0.useRef({
|
|
6
|
+
position: [0, 0],
|
|
7
|
+
contentSize: [0, 0],
|
|
8
|
+
innerSep: { left: 0, right: 0, top: 0, bottom: 0 },
|
|
9
|
+
outerSep: { left: 0, right: 0, top: 0, bottom: 0 }
|
|
10
|
+
});
|
|
11
|
+
return configRef;
|
|
12
|
+
};
|
|
13
|
+
exports.default = useNodeConfig;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
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 Text = require("../../../elements/Text.cjs");
|
|
6
|
+
const useNodeContent = (props, ref) => {
|
|
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(
|
|
11
|
+
Text.default,
|
|
12
|
+
{
|
|
13
|
+
fill: color,
|
|
14
|
+
fontSize: size,
|
|
15
|
+
fillOpacity: opacity,
|
|
16
|
+
fontWeight,
|
|
17
|
+
fontStyle,
|
|
18
|
+
fontFamily,
|
|
19
|
+
fontStretch,
|
|
20
|
+
ref,
|
|
21
|
+
children
|
|
22
|
+
}
|
|
23
|
+
) : require$$0.isValidElement(children) ? require$$0.cloneElement(children, { ref }) : children,
|
|
24
|
+
isTextNode ? [color, size, children] : [children]
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
exports.default = useNodeContent;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
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 Rect = require("../../../elements/Rect.cjs");
|
|
6
|
+
const getShapeProps = (nodeProps) => {
|
|
7
|
+
const { rx, ry, fill, fillOpacity, stroke, strokeWidth, strokeOpacity } = nodeProps;
|
|
8
|
+
const { strokeDasharray, strokeDashoffset, strokeLinecap, strokeLinejoin, strokeMiterlimit } = nodeProps;
|
|
9
|
+
return {
|
|
10
|
+
rx,
|
|
11
|
+
ry,
|
|
12
|
+
fill,
|
|
13
|
+
fillOpacity,
|
|
14
|
+
stroke,
|
|
15
|
+
strokeWidth,
|
|
16
|
+
strokeOpacity,
|
|
17
|
+
strokeDasharray,
|
|
18
|
+
strokeDashoffset,
|
|
19
|
+
strokeLinecap,
|
|
20
|
+
strokeLinejoin,
|
|
21
|
+
strokeMiterlimit
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const useNodeShape = (props, ref) => {
|
|
25
|
+
const shapeProps = getShapeProps(props);
|
|
26
|
+
const Shape = require$$0.useMemo(() => {
|
|
27
|
+
switch (props.shape) {
|
|
28
|
+
case "rectangle":
|
|
29
|
+
return Rect.default;
|
|
30
|
+
}
|
|
31
|
+
}, [props.shape, ...Object.values(shapeProps)]);
|
|
32
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(Shape, { ref, ...shapeProps });
|
|
33
|
+
};
|
|
34
|
+
exports.default = useNodeShape;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
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 useCalculate = require("../../hooks/context/useCalculate.cjs");
|
|
6
|
+
const useNodes = require("../../hooks/context/useNodes.cjs");
|
|
7
|
+
const useScope = require("../../hooks/context/useScope.cjs");
|
|
8
|
+
const DescartesPoint = require("../../model/geometry/point/DescartesPoint.cjs");
|
|
9
|
+
const css = require("../../utils/css.cjs");
|
|
10
|
+
const math = require("../../utils/math.cjs");
|
|
11
|
+
const Node = require("../node/Node.cjs");
|
|
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;
|
|
15
|
+
const { pos, veryNearStart, veryNearEnd, start, nearStart, midway, nearEnd, end, sloped, ...nodeProps } = resProps;
|
|
16
|
+
const id = require$$0.useId();
|
|
17
|
+
const realName = name ?? id;
|
|
18
|
+
const { precision } = useCalculate.default();
|
|
19
|
+
const posRadio = require$$0.useMemo(() => {
|
|
20
|
+
if (pos !== void 0) return pos;
|
|
21
|
+
if (start) return 0;
|
|
22
|
+
if (veryNearStart) return 0.125;
|
|
23
|
+
if (nearStart) return 0.25;
|
|
24
|
+
if (midway) return 0.5;
|
|
25
|
+
if (nearEnd) return 0.75;
|
|
26
|
+
if (veryNearEnd) return 0.875;
|
|
27
|
+
return 1;
|
|
28
|
+
}, [pos, veryNearStart, veryNearEnd, start, nearStart, midway, nearEnd, end]);
|
|
29
|
+
const directionPos = require$$0.useMemo(() => {
|
|
30
|
+
if (left) return { direction: "left", distance: typeof left === "boolean" ? 0 : css.convertCssToPx(left) };
|
|
31
|
+
if (right) return { direction: "right", distance: typeof right === "boolean" ? 0 : css.convertCssToPx(right) };
|
|
32
|
+
if (above) return { direction: "top", distance: typeof above === "boolean" ? 0 : css.convertCssToPx(above) };
|
|
33
|
+
if (below) return { direction: "bottom", distance: typeof below === "boolean" ? 0 : css.convertCssToPx(below) };
|
|
34
|
+
return { direction: anchor ?? "center", distance: 0 };
|
|
35
|
+
}, [anchor, left, right, above, below]);
|
|
36
|
+
const { position: anchorPosition, angle: anchorAngle } = useAnchor.default(posRadio, segmentIndex);
|
|
37
|
+
const [adjustOffset, setAdjustOffset] = require$$0.useState(DescartesPoint.default.plus(anchorPosition, offset));
|
|
38
|
+
const { getModel } = useNodes.default();
|
|
39
|
+
const rotate = require$$0.useMemo(() => {
|
|
40
|
+
if (!sloped) return 0;
|
|
41
|
+
return anchorAngle * (180 / Math.PI);
|
|
42
|
+
}, [sloped, anchorAngle]);
|
|
43
|
+
require$$0.useLayoutEffect(() => {
|
|
44
|
+
const model = getModel(realName);
|
|
45
|
+
if (!model || !model.init) return;
|
|
46
|
+
const { direction, distance } = directionPos;
|
|
47
|
+
let directionPosition = [0, 0];
|
|
48
|
+
switch (direction) {
|
|
49
|
+
case "left":
|
|
50
|
+
directionPosition = [-(model == null ? void 0 : model.getOuterDistance("left")) - distance, 0];
|
|
51
|
+
break;
|
|
52
|
+
case "right":
|
|
53
|
+
directionPosition = [(model == null ? void 0 : model.getOuterDistance("right")) + distance, 0];
|
|
54
|
+
break;
|
|
55
|
+
case "top":
|
|
56
|
+
directionPosition = [0, -(model == null ? void 0 : model.getOuterDistance("top")) - distance];
|
|
57
|
+
break;
|
|
58
|
+
case "bottom":
|
|
59
|
+
directionPosition = [0, (model == null ? void 0 : model.getOuterDistance("bottom")) + distance];
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
setAdjustOffset(DescartesPoint.default.plus(anchorPosition, directionPosition, offset));
|
|
63
|
+
}, [anchorPosition, directionPos]);
|
|
64
|
+
const scope = useScope.default();
|
|
65
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useScope.ScopeContext, { value: { ...scope, offset: [0, 0] }, children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
66
|
+
Node.default,
|
|
67
|
+
{
|
|
68
|
+
name: realName,
|
|
69
|
+
position: math.convertPrecision(adjustOffset, precision),
|
|
70
|
+
ref,
|
|
71
|
+
rotate,
|
|
72
|
+
...nodeProps
|
|
73
|
+
}
|
|
74
|
+
) });
|
|
75
|
+
};
|
|
76
|
+
exports.default = PathNode;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Direction } from '../../types/coordinate';
|
|
3
|
+
import { Position } from '../../types/coordinate/descartes';
|
|
4
|
+
import { NodeProps } from '../node/Node';
|
|
5
|
+
type PathNodePositionProps = {
|
|
6
|
+
left?: boolean | number | string;
|
|
7
|
+
right?: boolean | number | string;
|
|
8
|
+
above?: boolean | number | string;
|
|
9
|
+
below?: boolean | number | string;
|
|
10
|
+
};
|
|
11
|
+
type PosShortcutProps = {
|
|
12
|
+
/** pos: 0 */
|
|
13
|
+
start?: boolean;
|
|
14
|
+
/** pos: 0.125 */
|
|
15
|
+
veryNearStart?: boolean;
|
|
16
|
+
/** pos: 0.25 */
|
|
17
|
+
nearStart?: boolean;
|
|
18
|
+
/** pos: 0.5 */
|
|
19
|
+
midway?: boolean;
|
|
20
|
+
/** pos: 0.75 */
|
|
21
|
+
nearEnd?: boolean;
|
|
22
|
+
/** pos: 0.875 */
|
|
23
|
+
veryNearEnd?: boolean;
|
|
24
|
+
/** pos: 1 */
|
|
25
|
+
end?: boolean;
|
|
26
|
+
};
|
|
27
|
+
export type PathNodeProps = {
|
|
28
|
+
segmentIndex?: number;
|
|
29
|
+
/** path 片段的下标 */
|
|
30
|
+
pos?: number;
|
|
31
|
+
/** 相对于路径的位置 */
|
|
32
|
+
anchor?: Direction | 'center';
|
|
33
|
+
/** 偏移位置 */
|
|
34
|
+
offset?: Position;
|
|
35
|
+
/** 跟随箭头位置 */
|
|
36
|
+
sloped?: boolean;
|
|
37
|
+
} & PathNodePositionProps & PosShortcutProps & Omit<NodeProps, 'position'>;
|
|
38
|
+
declare const PathNode: FC<PathNodeProps>;
|
|
39
|
+
export default PathNode;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const require$$0 = require("react");
|
|
4
|
+
const useCalculate = require("../../hooks/context/useCalculate.cjs");
|
|
5
|
+
const usePath = require("../../hooks/context/usePath.cjs");
|
|
6
|
+
const useForceUpdate = require("../../hooks/useForceUpdate.cjs");
|
|
7
|
+
const line = require("../../model/equation/line.cjs");
|
|
8
|
+
const math = require("../../utils/math.cjs");
|
|
9
|
+
const useAnchor = (pos, segmentIndex) => {
|
|
10
|
+
const pathUpdateCount = require$$0.useRef(0);
|
|
11
|
+
const forceUpdate = useForceUpdate.default();
|
|
12
|
+
const { model, subscribeModel } = usePath.default();
|
|
13
|
+
const { precision } = useCalculate.default();
|
|
14
|
+
const subscribeCb = subscribeModel((model2) => {
|
|
15
|
+
if (!(model2 == null ? void 0 : model2.init)) return;
|
|
16
|
+
pathUpdateCount.current += 1;
|
|
17
|
+
queueMicrotask(forceUpdate);
|
|
18
|
+
});
|
|
19
|
+
require$$0.useLayoutEffect(() => () => {
|
|
20
|
+
subscribeCb == null ? void 0 : subscribeCb();
|
|
21
|
+
});
|
|
22
|
+
const adjustIndex = segmentIndex >= 0 ? segmentIndex : model.ways.length + segmentIndex;
|
|
23
|
+
if (!math.between(adjustIndex, [0, model.ways.length - 1], true)) throw new Error("segmentIndex is out of range");
|
|
24
|
+
return require$$0.useMemo(() => {
|
|
25
|
+
if (!model.init)
|
|
26
|
+
return {
|
|
27
|
+
position: [Number.MAX_SAFE_INTEGER / 2, Number.MAX_SAFE_INTEGER / 2],
|
|
28
|
+
angle: 0
|
|
29
|
+
};
|
|
30
|
+
const way = model.ways[adjustIndex];
|
|
31
|
+
const waySegments = way.length - 1;
|
|
32
|
+
const segmentPercent = 1 / waySegments;
|
|
33
|
+
let segmentSum = 0;
|
|
34
|
+
let index = 0;
|
|
35
|
+
while (pos >= segmentSum) {
|
|
36
|
+
segmentSum += segmentPercent;
|
|
37
|
+
index++;
|
|
38
|
+
}
|
|
39
|
+
const startPoint = way[index - 1];
|
|
40
|
+
const endPoint = way[index];
|
|
41
|
+
const percent = pos % segmentPercent / segmentPercent;
|
|
42
|
+
const position = index === way.length ? startPoint : line.default.getPositionByPercent(startPoint, endPoint, percent);
|
|
43
|
+
return {
|
|
44
|
+
position: math.convertPrecision(position, precision),
|
|
45
|
+
angle: index === way.length ? line.default.getDegree(way[way.length - 2], way[way.length - 1]) : line.default.getDegree(startPoint, endPoint)
|
|
46
|
+
};
|
|
47
|
+
}, [pos, segmentIndex, pathUpdateCount.current]);
|
|
48
|
+
};
|
|
49
|
+
exports.default = useAnchor;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
};
|
|
7
|
+
exports.default = Group;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
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) => {
|
|
6
|
+
const { title, desc, viewBox, children, width, height, ...otherProps } = props;
|
|
7
|
+
const svgViewBox = require$$0.useMemo(() => {
|
|
8
|
+
if (!(viewBox == null ? void 0 : viewBox.x) && !(viewBox == null ? void 0 : viewBox.y)) {
|
|
9
|
+
return void 0;
|
|
10
|
+
}
|
|
11
|
+
const viewX = (viewBox == null ? void 0 : viewBox.x) || 0;
|
|
12
|
+
const viewY = (viewBox == null ? void 0 : viewBox.y) || 0;
|
|
13
|
+
const viewWidth = (viewBox == null ? void 0 : viewBox.width) || width;
|
|
14
|
+
const viewHeight = (viewBox == null ? void 0 : viewBox.height) || height;
|
|
15
|
+
return viewWidth === void 0 || viewHeight === void 0 ? [viewX, viewY].join(" ") : [viewX, viewY, viewWidth, viewHeight].join(" ");
|
|
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,
|
|
20
|
+
children
|
|
21
|
+
] });
|
|
22
|
+
};
|
|
23
|
+
exports.default = Surface;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CSSProperties, FC, PropsWithChildren } from 'react';
|
|
2
|
+
export type SurfaceProps = {
|
|
3
|
+
title?: string;
|
|
4
|
+
desc?: string;
|
|
5
|
+
width?: string | number;
|
|
6
|
+
height?: string | number;
|
|
7
|
+
viewBox?: {
|
|
8
|
+
x?: number;
|
|
9
|
+
y?: number;
|
|
10
|
+
width?: number;
|
|
11
|
+
height?: number;
|
|
12
|
+
};
|
|
13
|
+
className?: string;
|
|
14
|
+
style?: CSSProperties;
|
|
15
|
+
};
|
|
16
|
+
declare const Surface: FC<PropsWithChildren<SurfaceProps>>;
|
|
17
|
+
export default Surface;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const jsxRuntime = require("../_virtual/jsx-runtime.cjs");
|
|
4
|
+
const Path = (props) => {
|
|
5
|
+
const { fill: propFill, strokeWidth: propStrokeWidth, stroke: propStroke, ...otherProps } = props;
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
fill: propFill || "transparent",
|
|
8
|
+
strokeWidth: propStrokeWidth ?? 1,
|
|
9
|
+
stroke: propStroke || "currentColor"
|
|
10
|
+
};
|
|
11
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("path", { ...defaultProps, ...otherProps });
|
|
12
|
+
};
|
|
13
|
+
exports.default = Path;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
};
|
|
8
|
+
exports.default = Rect;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
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 string = require("../utils/string.cjs");
|
|
6
|
+
const Text = (props) => {
|
|
7
|
+
const { children, ref, align, verticalAlign, fontSize, fill, ...otherProps } = props;
|
|
8
|
+
const dominantBaseline = require$$0.useMemo(() => {
|
|
9
|
+
switch (verticalAlign) {
|
|
10
|
+
case "top":
|
|
11
|
+
return "text-top";
|
|
12
|
+
case "bottom":
|
|
13
|
+
return "text-bottom";
|
|
14
|
+
case "center":
|
|
15
|
+
return "central";
|
|
16
|
+
default:
|
|
17
|
+
return verticalAlign;
|
|
18
|
+
}
|
|
19
|
+
}, [verticalAlign]);
|
|
20
|
+
const textProps = {
|
|
21
|
+
textAnchor: align || "middle",
|
|
22
|
+
dominantBaseline: dominantBaseline || "central",
|
|
23
|
+
fontSize: fontSize || "1em",
|
|
24
|
+
fill: fill || "currentColor",
|
|
25
|
+
...otherProps
|
|
26
|
+
};
|
|
27
|
+
const parseChildren = (children2) => {
|
|
28
|
+
if (typeof children2 === "string") {
|
|
29
|
+
return string.textWrapParse(children2).map((child, index) => /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("tspan", { children: child }, index));
|
|
30
|
+
}
|
|
31
|
+
return children2;
|
|
32
|
+
};
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("text", { ref, ...textProps, children: parseChildren(children) });
|
|
34
|
+
};
|
|
35
|
+
exports.default = Text;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FC, PropsWithChildren, Ref, SVGProps } from 'react';
|
|
2
|
+
import { FontProps } from '../types/svg/font';
|
|
3
|
+
type TextVerticalAlign = 'top' | 'center' | 'bottom';
|
|
4
|
+
export type DominantBaseline = 'auto' | 'text-bottom' | 'alphabetic' | 'ideographic' | 'middle' | 'central' | 'mathematical' | 'hanging' | 'text-top';
|
|
5
|
+
export type TextProps = {
|
|
6
|
+
x?: SVGProps<SVGTextElement>['x'];
|
|
7
|
+
y?: SVGProps<SVGTextElement>['y'];
|
|
8
|
+
align?: 'start' | 'middle' | 'end' | 'inherit';
|
|
9
|
+
verticalAlign?: TextVerticalAlign | DominantBaseline;
|
|
10
|
+
fontSize?: SVGProps<SVGTextElement>['fontSize'];
|
|
11
|
+
fill?: SVGProps<SVGTextElement>['fill'];
|
|
12
|
+
ref?: Ref<SVGTextElement>;
|
|
13
|
+
} & FontProps & SVGProps<SVGTextElement>;
|
|
14
|
+
/**
|
|
15
|
+
* 文本节点
|
|
16
|
+
* @tikz node
|
|
17
|
+
*/
|
|
18
|
+
declare const Text: FC<PropsWithChildren<TextProps>>;
|
|
19
|
+
export default Text;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const require$$0 = require("react");
|
|
4
|
+
const CalculateContext = require$$0.createContext({ precision: 2 });
|
|
5
|
+
const useCalculate = () => {
|
|
6
|
+
return require$$0.useContext(CalculateContext);
|
|
7
|
+
};
|
|
8
|
+
exports.CalculateContext = CalculateContext;
|
|
9
|
+
exports.default = useCalculate;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type CalculateProps = {
|
|
2
|
+
precision: number | false;
|
|
3
|
+
};
|
|
4
|
+
export declare const CalculateContext: import('react').Context<CalculateProps>;
|
|
5
|
+
declare const useCalculate: () => CalculateProps;
|
|
6
|
+
export declare const useCalculateValue: (value: number, deep?: boolean) => number;
|
|
7
|
+
export default useCalculate;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const require$$0 = require("react");
|
|
4
|
+
const node = require("../../model/component/node.cjs");
|
|
5
|
+
const NodesContext = require$$0.createContext(/* @__PURE__ */ new Map());
|
|
6
|
+
const useNodes = () => {
|
|
7
|
+
const nodes = require$$0.useContext(NodesContext);
|
|
8
|
+
return {
|
|
9
|
+
subscribeModel: (name, listener) => {
|
|
10
|
+
const model = nodes.get(name);
|
|
11
|
+
if (!model) return false;
|
|
12
|
+
return model.subscribe(listener);
|
|
13
|
+
},
|
|
14
|
+
getModel: (name) => nodes.get(name),
|
|
15
|
+
updateModel: (name, config, init = true) => {
|
|
16
|
+
const model = nodes.get(name);
|
|
17
|
+
if (model) {
|
|
18
|
+
model.update(config, init);
|
|
19
|
+
} else {
|
|
20
|
+
nodes.set(name, new node.default(config, init));
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
deleteModel: (name) => {
|
|
24
|
+
const model = nodes.get(name);
|
|
25
|
+
if (!model) return;
|
|
26
|
+
model.dispose();
|
|
27
|
+
model.notify();
|
|
28
|
+
nodes.delete(name);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.NodesContext = NodesContext;
|
|
33
|
+
exports.default = useNodes;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as NodeModel, NodeConfig, StateListener } from '../../model/component/node';
|
|
2
|
+
export declare const NodesContext: import('react').Context<Map<string, NodeModel>>;
|
|
3
|
+
declare const useNodes: () => {
|
|
4
|
+
subscribeModel: (name: string, listener: StateListener) => false | (() => boolean);
|
|
5
|
+
getModel: (name: string) => NodeModel | undefined;
|
|
6
|
+
updateModel: (name: string, config: NodeConfig, init?: boolean) => void;
|
|
7
|
+
deleteModel: (name: string) => void;
|
|
8
|
+
};
|
|
9
|
+
export default useNodes;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const require$$0 = require("react");
|
|
4
|
+
const PathContext = require$$0.createContext(null);
|
|
5
|
+
const usePath = () => {
|
|
6
|
+
const pathModel = require$$0.useContext(PathContext);
|
|
7
|
+
if (!pathModel) throw new Error("usePath must be used within a PathProvider");
|
|
8
|
+
return {
|
|
9
|
+
model: pathModel,
|
|
10
|
+
subscribeModel: (listener) => {
|
|
11
|
+
if (!pathModel) return;
|
|
12
|
+
return pathModel.subscribe(listener);
|
|
13
|
+
},
|
|
14
|
+
updateModel: (config) => {
|
|
15
|
+
pathModel == null ? void 0 : pathModel.update(config);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
exports.PathContext = PathContext;
|
|
20
|
+
exports.default = usePath;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as PathModel, StateListener } from '../../model/component/path';
|
|
2
|
+
import { Position } from '../../types/coordinate/descartes';
|
|
3
|
+
export declare const PathContext: import('react').Context<PathModel | null>;
|
|
4
|
+
declare const usePath: () => {
|
|
5
|
+
model: PathModel;
|
|
6
|
+
subscribeModel: (listener: StateListener) => (() => boolean) | undefined;
|
|
7
|
+
updateModel: (config: {
|
|
8
|
+
ways?: Array<Position[]>;
|
|
9
|
+
lineWidth?: number;
|
|
10
|
+
init?: boolean;
|
|
11
|
+
}) => void;
|
|
12
|
+
};
|
|
13
|
+
export default usePath;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const require$$0 = require("react");
|
|
4
|
+
const ScopeContext = require$$0.createContext({});
|
|
5
|
+
const useScope = () => require$$0.useContext(ScopeContext);
|
|
6
|
+
exports.ScopeContext = ScopeContext;
|
|
7
|
+
exports.default = useScope;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DrawProps } from '../../components/draw/Draw';
|
|
2
|
+
import { NodeProps } from '../../components/node';
|
|
3
|
+
import { Position } from '../../types/coordinate/descartes';
|
|
4
|
+
export type ScopeProps = {
|
|
5
|
+
offset?: Position;
|
|
6
|
+
node?: Omit<NodeProps, 'name' | 'ref' | 'position' | 'offset'>;
|
|
7
|
+
draw?: Omit<DrawProps, 'ref' | 'way' | 'offset'>;
|
|
8
|
+
};
|
|
9
|
+
export declare const ScopeContext: import('react').Context<ScopeProps>;
|
|
10
|
+
declare const useScope: () => ScopeProps;
|
|
11
|
+
export default useScope;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const require$$0 = require("react");
|
|
4
|
+
const useForceUpdate = () => {
|
|
5
|
+
const [_, forceUpdate] = require$$0.useReducer(() => ({}), {});
|
|
6
|
+
return forceUpdate;
|
|
7
|
+
};
|
|
8
|
+
exports.default = useForceUpdate;
|