@retikz/core 0.0.1-rc.3 → 0.1.0-alpha.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 -21
- package/dist/es/compile/compile.d.ts +27 -0
- package/dist/es/compile/compile.d.ts.map +1 -0
- package/dist/es/compile/compile.js +43 -0
- package/dist/es/compile/index.d.ts +8 -0
- package/dist/es/compile/index.d.ts.map +1 -0
- package/dist/es/compile/node.d.ts +51 -0
- package/dist/es/compile/node.d.ts.map +1 -0
- package/dist/es/compile/node.js +100 -0
- package/dist/es/compile/path.d.ts +19 -0
- package/dist/es/compile/path.d.ts.map +1 -0
- package/dist/es/compile/path.js +55 -0
- package/dist/es/compile/position.d.ts +9 -0
- package/dist/es/compile/position.d.ts.map +1 -0
- package/dist/es/compile/position.js +24 -0
- package/dist/es/compile/precision.d.ts +5 -0
- package/dist/es/compile/precision.d.ts.map +1 -0
- package/dist/es/compile/precision.js +8 -0
- package/dist/es/compile/text-metrics.d.ts +32 -0
- package/dist/es/compile/text-metrics.d.ts.map +1 -0
- package/dist/es/compile/text-metrics.js +8 -0
- package/dist/es/compile/view-box.d.ts +8 -0
- package/dist/es/compile/view-box.d.ts.map +1 -0
- package/dist/es/compile/view-box.js +31 -0
- package/dist/es/geometry/index.d.ts +4 -0
- package/dist/es/geometry/index.d.ts.map +1 -0
- package/dist/es/geometry/point.d.ts +25 -0
- package/dist/es/geometry/point.d.ts.map +1 -0
- package/dist/es/geometry/point.js +34 -0
- package/dist/es/geometry/polar.d.ts +44 -0
- package/dist/es/geometry/polar.d.ts.map +1 -0
- package/dist/es/geometry/polar.js +45 -0
- package/dist/es/geometry/rect.d.ts +59 -0
- package/dist/es/geometry/rect.d.ts.map +1 -0
- package/dist/es/geometry/rect.js +120 -0
- package/dist/es/index.d.ts +18 -10
- package/dist/es/index.d.ts.map +1 -0
- package/dist/es/index.js +14 -12
- package/dist/es/ir/index.d.ts +5 -0
- package/dist/es/ir/index.d.ts.map +1 -0
- package/dist/es/ir/node.d.ts +41 -0
- package/dist/es/ir/node.d.ts.map +1 -0
- package/dist/es/ir/node.js +19 -0
- package/dist/es/ir/path/index.d.ts +4 -0
- package/dist/es/ir/path/index.d.ts.map +1 -0
- package/dist/es/ir/path/path.d.ts +63 -0
- package/dist/es/ir/path/path.d.ts.map +1 -0
- package/dist/es/ir/path/path.js +12 -0
- package/dist/es/ir/path/step.d.ts +62 -0
- package/dist/es/ir/path/step.d.ts.map +1 -0
- package/dist/es/ir/path/step.js +16 -0
- package/dist/es/ir/path/target.d.ts +5 -0
- package/dist/es/ir/path/target.d.ts.map +1 -0
- package/dist/es/ir/path/target.js +11 -0
- package/dist/es/ir/position/index.d.ts +3 -0
- package/dist/es/ir/position/index.d.ts.map +1 -0
- package/dist/es/ir/position/polar-position.d.ts +9 -0
- package/dist/es/ir/position/polar-position.d.ts.map +1 -0
- package/dist/es/ir/position/polar-position.js +18 -0
- package/dist/es/ir/position/position.d.ts +5 -0
- package/dist/es/ir/position/position.d.ts.map +1 -0
- package/dist/es/ir/position/position.js +5 -0
- package/dist/es/ir/scene.d.ts +262 -0
- package/dist/es/ir/scene.d.ts.map +1 -0
- package/dist/es/ir/scene.js +14 -0
- package/dist/es/parsers/index.d.ts +2 -0
- package/dist/es/parsers/index.d.ts.map +1 -0
- package/dist/es/parsers/parseWay.d.ts +25 -0
- package/dist/es/parsers/parseWay.d.ts.map +1 -0
- package/dist/es/parsers/parseWay.js +30 -0
- package/dist/es/primitive/group.d.ts +11 -0
- package/dist/es/primitive/group.d.ts.map +1 -0
- package/dist/es/primitive/index.d.ts +7 -0
- package/dist/es/primitive/index.d.ts.map +1 -0
- package/dist/es/primitive/path.d.ts +22 -0
- package/dist/es/primitive/path.d.ts.map +1 -0
- package/dist/es/primitive/rect.d.ts +28 -0
- package/dist/es/primitive/rect.d.ts.map +1 -0
- package/dist/es/primitive/scene.d.ts +20 -0
- package/dist/es/primitive/scene.d.ts.map +1 -0
- package/dist/es/primitive/text.d.ts +32 -0
- package/dist/es/primitive/text.d.ts.map +1 -0
- package/dist/es/primitive/view-box.d.ts +12 -0
- package/dist/es/primitive/view-box.d.ts.map +1 -0
- package/dist/lib/compile/compile.cjs +43 -0
- package/dist/lib/compile/compile.d.ts +27 -0
- package/dist/lib/compile/compile.d.ts.map +1 -0
- package/dist/lib/compile/index.d.ts +8 -0
- package/dist/lib/compile/index.d.ts.map +1 -0
- package/dist/lib/compile/node.cjs +102 -0
- package/dist/lib/compile/node.d.ts +51 -0
- package/dist/lib/compile/node.d.ts.map +1 -0
- package/dist/lib/compile/path.cjs +55 -0
- package/dist/lib/compile/path.d.ts +19 -0
- package/dist/lib/compile/path.d.ts.map +1 -0
- package/dist/lib/compile/position.cjs +24 -0
- package/dist/lib/compile/position.d.ts +9 -0
- package/dist/lib/compile/position.d.ts.map +1 -0
- package/dist/lib/compile/precision.cjs +8 -0
- package/dist/lib/compile/precision.d.ts +5 -0
- package/dist/lib/compile/precision.d.ts.map +1 -0
- package/dist/lib/compile/text-metrics.cjs +8 -0
- package/dist/lib/compile/text-metrics.d.ts +32 -0
- package/dist/lib/compile/text-metrics.d.ts.map +1 -0
- package/dist/lib/compile/view-box.cjs +31 -0
- package/dist/lib/compile/view-box.d.ts +8 -0
- package/dist/lib/compile/view-box.d.ts.map +1 -0
- package/dist/lib/geometry/index.d.ts +4 -0
- package/dist/lib/geometry/index.d.ts.map +1 -0
- package/dist/lib/geometry/point.cjs +34 -0
- package/dist/lib/geometry/point.d.ts +25 -0
- package/dist/lib/geometry/point.d.ts.map +1 -0
- package/dist/lib/geometry/polar.cjs +45 -0
- package/dist/lib/geometry/polar.d.ts +44 -0
- package/dist/lib/geometry/polar.d.ts.map +1 -0
- package/dist/lib/geometry/rect.cjs +121 -0
- package/dist/lib/geometry/rect.d.ts +59 -0
- package/dist/lib/geometry/rect.d.ts.map +1 -0
- package/dist/lib/index.cjs +31 -11
- package/dist/lib/index.d.ts +18 -10
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/ir/index.d.ts +5 -0
- package/dist/lib/ir/index.d.ts.map +1 -0
- package/dist/lib/ir/node.cjs +19 -0
- package/dist/lib/ir/node.d.ts +41 -0
- package/dist/lib/ir/node.d.ts.map +1 -0
- package/dist/lib/ir/path/index.d.ts +4 -0
- package/dist/lib/ir/path/index.d.ts.map +1 -0
- package/dist/lib/ir/path/path.cjs +12 -0
- package/dist/lib/ir/path/path.d.ts +63 -0
- package/dist/lib/ir/path/path.d.ts.map +1 -0
- package/dist/lib/ir/path/step.cjs +18 -0
- package/dist/lib/ir/path/step.d.ts +62 -0
- package/dist/lib/ir/path/step.d.ts.map +1 -0
- package/dist/lib/ir/path/target.cjs +11 -0
- package/dist/lib/ir/path/target.d.ts +5 -0
- package/dist/lib/ir/path/target.d.ts.map +1 -0
- package/dist/lib/ir/position/index.d.ts +3 -0
- package/dist/lib/ir/position/index.d.ts.map +1 -0
- package/dist/lib/ir/position/polar-position.cjs +18 -0
- package/dist/lib/ir/position/polar-position.d.ts +9 -0
- package/dist/lib/ir/position/polar-position.d.ts.map +1 -0
- package/dist/lib/ir/position/position.cjs +5 -0
- package/dist/lib/ir/position/position.d.ts +5 -0
- package/dist/lib/ir/position/position.d.ts.map +1 -0
- package/dist/lib/ir/scene.cjs +16 -0
- package/dist/lib/ir/scene.d.ts +262 -0
- package/dist/lib/ir/scene.d.ts.map +1 -0
- package/dist/lib/parsers/index.d.ts +2 -0
- package/dist/lib/parsers/index.d.ts.map +1 -0
- package/dist/lib/parsers/parseWay.cjs +30 -0
- package/dist/lib/parsers/parseWay.d.ts +25 -0
- package/dist/lib/parsers/parseWay.d.ts.map +1 -0
- package/dist/lib/primitive/group.d.ts +11 -0
- package/dist/lib/primitive/group.d.ts.map +1 -0
- package/dist/lib/primitive/index.d.ts +7 -0
- package/dist/lib/primitive/index.d.ts.map +1 -0
- package/dist/lib/primitive/path.d.ts +22 -0
- package/dist/lib/primitive/path.d.ts.map +1 -0
- package/dist/lib/primitive/rect.d.ts +28 -0
- package/dist/lib/primitive/rect.d.ts.map +1 -0
- package/dist/lib/primitive/scene.d.ts +20 -0
- package/dist/lib/primitive/scene.d.ts.map +1 -0
- package/dist/lib/primitive/text.d.ts +32 -0
- package/dist/lib/primitive/text.d.ts.map +1 -0
- package/dist/lib/primitive/view-box.d.ts +12 -0
- package/dist/lib/primitive/view-box.d.ts.map +1 -0
- package/package.json +26 -34
- package/README.md +0 -2
- package/dist/es/components/Scope.d.ts +0 -6
- package/dist/es/components/Scope.js +0 -12
- package/dist/es/components/TikZ.d.ts +0 -9
- package/dist/es/components/TikZ.js +0 -12
- package/dist/es/components/draw/Draw.d.ts +0 -26
- package/dist/es/components/draw/Draw.js +0 -59
- package/dist/es/components/draw/InnerDraw.d.ts +0 -17
- package/dist/es/components/draw/InnerDraw.js +0 -52
- package/dist/es/components/draw/arrow/circle.d.ts +0 -7
- package/dist/es/components/draw/arrow/circle.js +0 -20
- package/dist/es/components/draw/arrow/index.d.ts +0 -9
- package/dist/es/components/draw/arrow/index.js +0 -13
- package/dist/es/components/draw/arrow/stealth.d.ts +0 -7
- package/dist/es/components/draw/arrow/stealth.js +0 -29
- package/dist/es/components/draw/arrow/types.d.ts +0 -21
- package/dist/es/components/draw/common.d.ts +0 -4
- package/dist/es/components/draw/common.js +0 -12
- package/dist/es/components/draw/index.d.ts +0 -3
- package/dist/es/components/draw/index.js +0 -4
- package/dist/es/components/draw/segment/Segment.d.ts +0 -12
- package/dist/es/components/draw/segment/Segment.js +0 -41
- package/dist/es/components/draw/segment/index.d.ts +0 -15
- package/dist/es/components/draw/segment/index.js +0 -41
- package/dist/es/components/draw/segment/useArrow.d.ts +0 -12
- package/dist/es/components/draw/segment/useArrow.js +0 -52
- package/dist/es/components/draw/segment/useConvertWay.d.ts +0 -14
- package/dist/es/components/draw/segment/useConvertWay.js +0 -117
- package/dist/es/components/draw/types.d.ts +0 -29
- package/dist/es/components/node/InnerNode.d.ts +0 -33
- package/dist/es/components/node/InnerNode.js +0 -88
- package/dist/es/components/node/Node.d.ts +0 -93
- package/dist/es/components/node/Node.js +0 -88
- package/dist/es/components/node/_hooks/useNodeConfig.d.ts +0 -3
- package/dist/es/components/node/_hooks/useNodeConfig.js +0 -13
- package/dist/es/components/node/_hooks/useNodeContent.d.ts +0 -4
- package/dist/es/components/node/_hooks/useNodeContent.js +0 -30
- package/dist/es/components/node/_hooks/useNodeShape.d.ts +0 -4
- package/dist/es/components/node/_hooks/useNodeShape.js +0 -34
- package/dist/es/components/node/index.d.ts +0 -3
- package/dist/es/components/node/index.js +0 -4
- package/dist/es/components/path-node/PathNode.d.ts +0 -48
- package/dist/es/components/path-node/PathNode.js +0 -76
- package/dist/es/components/path-node/index.d.ts +0 -3
- package/dist/es/components/path-node/index.js +0 -4
- package/dist/es/components/path-node/useAnchor.d.ts +0 -6
- package/dist/es/components/path-node/useAnchor.js +0 -49
- package/dist/es/container/Group.d.ts +0 -6
- package/dist/es/container/Group.js +0 -8
- package/dist/es/container/Surface.d.ts +0 -19
- package/dist/es/container/Surface.js +0 -23
- package/dist/es/elements/Path.d.ts +0 -4
- package/dist/es/elements/Path.js +0 -14
- package/dist/es/elements/Rect.d.ts +0 -4
- package/dist/es/elements/Rect.js +0 -9
- package/dist/es/elements/Text.d.ts +0 -18
- package/dist/es/elements/Text.js +0 -35
- package/dist/es/hooks/context/useCalculate.d.ts +0 -7
- package/dist/es/hooks/context/useCalculate.js +0 -9
- package/dist/es/hooks/context/useNodes.d.ts +0 -9
- package/dist/es/hooks/context/useNodes.js +0 -33
- package/dist/es/hooks/context/usePath.d.ts +0 -13
- package/dist/es/hooks/context/usePath.js +0 -20
- package/dist/es/hooks/context/useScope.d.ts +0 -11
- package/dist/es/hooks/context/useScope.js +0 -7
- package/dist/es/hooks/useForceUpdate.d.ts +0 -2
- package/dist/es/hooks/useForceUpdate.js +0 -8
- package/dist/es/model/component/node.d.ts +0 -45
- package/dist/es/model/component/node.js +0 -164
- package/dist/es/model/component/path.d.ts +0 -19
- package/dist/es/model/component/path.js +0 -47
- package/dist/es/model/equation/line.d.ts +0 -21
- package/dist/es/model/equation/line.js +0 -76
- package/dist/es/model/geometry/point/DescartesPoint.d.ts +0 -21
- package/dist/es/model/geometry/point/DescartesPoint.js +0 -50
- package/dist/es/model/geometry/point/PolarPoint.d.ts +0 -14
- package/dist/es/model/geometry/point/PolarPoint.js +0 -27
- package/dist/es/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.js +0 -338
- package/dist/es/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.js +0 -13
- package/dist/es/node_modules/.pnpm/d3-path@3.1.0/node_modules/d3-path/src/path.js +0 -88
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/array.js +0 -6
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/constant.js +0 -8
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/linear.js +0 -39
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.js +0 -41
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/path.js +0 -19
- package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/point.js +0 -10
- package/dist/es/test.d.ts +0 -3
- package/dist/es/types/coordinate/descartes.d.ts +0 -23
- package/dist/es/types/coordinate/index.d.ts +0 -5
- package/dist/es/types/coordinate/polar.d.ts +0 -5
- package/dist/es/types/distance/index.d.ts +0 -8
- package/dist/es/types/distance/sep.d.ts +0 -9
- package/dist/es/types/shape/index.d.ts +0 -8
- package/dist/es/types/shape/index.js +0 -9
- package/dist/es/types/shape/rect.d.ts +0 -25
- package/dist/es/types/shape/rect.js +0 -30
- package/dist/es/types/svg/font.d.ts +0 -10
- package/dist/es/types/svg/stroke.d.ts +0 -10
- package/dist/es/types/tikz/index.d.ts +0 -6
- package/dist/es/utils/compare.d.ts +0 -4
- package/dist/es/utils/compare.js +0 -20
- package/dist/es/utils/css.d.ts +0 -6
- package/dist/es/utils/css.js +0 -26
- package/dist/es/utils/math.d.ts +0 -9
- package/dist/es/utils/math.js +0 -26
- package/dist/es/utils/string.d.ts +0 -7
- package/dist/es/utils/string.js +0 -7
- package/dist/es/utils/style/font.d.ts +0 -17
- package/dist/es/utils/style/font.js +0 -34
- package/dist/es/utils/style/stroke.d.ts +0 -20
- package/dist/es/utils/style/stroke.js +0 -42
- package/dist/lib/components/Scope.cjs +0 -12
- package/dist/lib/components/Scope.d.ts +0 -6
- package/dist/lib/components/TikZ.cjs +0 -12
- package/dist/lib/components/TikZ.d.ts +0 -9
- package/dist/lib/components/draw/Draw.cjs +0 -59
- package/dist/lib/components/draw/Draw.d.ts +0 -26
- package/dist/lib/components/draw/InnerDraw.cjs +0 -52
- package/dist/lib/components/draw/InnerDraw.d.ts +0 -17
- package/dist/lib/components/draw/arrow/circle.cjs +0 -20
- package/dist/lib/components/draw/arrow/circle.d.ts +0 -7
- package/dist/lib/components/draw/arrow/index.cjs +0 -13
- package/dist/lib/components/draw/arrow/index.d.ts +0 -9
- package/dist/lib/components/draw/arrow/stealth.cjs +0 -29
- package/dist/lib/components/draw/arrow/stealth.d.ts +0 -7
- package/dist/lib/components/draw/arrow/types.d.ts +0 -21
- package/dist/lib/components/draw/common.cjs +0 -12
- package/dist/lib/components/draw/common.d.ts +0 -4
- package/dist/lib/components/draw/index.cjs +0 -4
- package/dist/lib/components/draw/index.d.ts +0 -3
- package/dist/lib/components/draw/segment/Segment.cjs +0 -41
- package/dist/lib/components/draw/segment/Segment.d.ts +0 -12
- package/dist/lib/components/draw/segment/index.cjs +0 -41
- package/dist/lib/components/draw/segment/index.d.ts +0 -15
- package/dist/lib/components/draw/segment/useArrow.cjs +0 -52
- package/dist/lib/components/draw/segment/useArrow.d.ts +0 -12
- package/dist/lib/components/draw/segment/useConvertWay.cjs +0 -117
- package/dist/lib/components/draw/segment/useConvertWay.d.ts +0 -14
- package/dist/lib/components/draw/types.d.ts +0 -29
- package/dist/lib/components/node/InnerNode.cjs +0 -88
- package/dist/lib/components/node/InnerNode.d.ts +0 -33
- package/dist/lib/components/node/Node.cjs +0 -88
- package/dist/lib/components/node/Node.d.ts +0 -93
- package/dist/lib/components/node/_hooks/useNodeConfig.cjs +0 -13
- package/dist/lib/components/node/_hooks/useNodeConfig.d.ts +0 -3
- package/dist/lib/components/node/_hooks/useNodeContent.cjs +0 -30
- package/dist/lib/components/node/_hooks/useNodeContent.d.ts +0 -4
- package/dist/lib/components/node/_hooks/useNodeShape.cjs +0 -34
- package/dist/lib/components/node/_hooks/useNodeShape.d.ts +0 -4
- package/dist/lib/components/node/index.cjs +0 -4
- package/dist/lib/components/node/index.d.ts +0 -3
- package/dist/lib/components/path-node/PathNode.cjs +0 -76
- package/dist/lib/components/path-node/PathNode.d.ts +0 -48
- package/dist/lib/components/path-node/index.cjs +0 -4
- package/dist/lib/components/path-node/index.d.ts +0 -3
- package/dist/lib/components/path-node/useAnchor.cjs +0 -49
- package/dist/lib/components/path-node/useAnchor.d.ts +0 -6
- package/dist/lib/container/Group.cjs +0 -8
- package/dist/lib/container/Group.d.ts +0 -6
- package/dist/lib/container/Surface.cjs +0 -23
- package/dist/lib/container/Surface.d.ts +0 -19
- package/dist/lib/elements/Path.cjs +0 -14
- package/dist/lib/elements/Path.d.ts +0 -4
- package/dist/lib/elements/Rect.cjs +0 -9
- package/dist/lib/elements/Rect.d.ts +0 -4
- package/dist/lib/elements/Text.cjs +0 -35
- package/dist/lib/elements/Text.d.ts +0 -18
- package/dist/lib/hooks/context/useCalculate.cjs +0 -9
- package/dist/lib/hooks/context/useCalculate.d.ts +0 -7
- package/dist/lib/hooks/context/useNodes.cjs +0 -33
- package/dist/lib/hooks/context/useNodes.d.ts +0 -9
- package/dist/lib/hooks/context/usePath.cjs +0 -20
- package/dist/lib/hooks/context/usePath.d.ts +0 -13
- package/dist/lib/hooks/context/useScope.cjs +0 -7
- package/dist/lib/hooks/context/useScope.d.ts +0 -11
- package/dist/lib/hooks/useForceUpdate.cjs +0 -8
- package/dist/lib/hooks/useForceUpdate.d.ts +0 -2
- package/dist/lib/model/component/node.cjs +0 -164
- package/dist/lib/model/component/node.d.ts +0 -45
- package/dist/lib/model/component/path.cjs +0 -47
- package/dist/lib/model/component/path.d.ts +0 -19
- package/dist/lib/model/equation/line.cjs +0 -76
- package/dist/lib/model/equation/line.d.ts +0 -21
- package/dist/lib/model/geometry/point/DescartesPoint.cjs +0 -50
- package/dist/lib/model/geometry/point/DescartesPoint.d.ts +0 -21
- package/dist/lib/model/geometry/point/PolarPoint.cjs +0 -27
- package/dist/lib/model/geometry/point/PolarPoint.d.ts +0 -14
- package/dist/lib/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.cjs +0 -338
- package/dist/lib/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.cjs +0 -13
- package/dist/lib/node_modules/.pnpm/d3-path@3.1.0/node_modules/d3-path/src/path.cjs +0 -88
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/array.cjs +0 -6
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/constant.cjs +0 -8
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/linear.cjs +0 -39
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.cjs +0 -41
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/path.cjs +0 -19
- package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/point.cjs +0 -10
- package/dist/lib/test.d.ts +0 -3
- package/dist/lib/types/coordinate/descartes.d.ts +0 -23
- package/dist/lib/types/coordinate/index.d.ts +0 -5
- package/dist/lib/types/coordinate/polar.d.ts +0 -5
- package/dist/lib/types/distance/index.d.ts +0 -8
- package/dist/lib/types/distance/sep.d.ts +0 -9
- package/dist/lib/types/shape/index.cjs +0 -9
- package/dist/lib/types/shape/index.d.ts +0 -8
- package/dist/lib/types/shape/rect.cjs +0 -30
- package/dist/lib/types/shape/rect.d.ts +0 -25
- package/dist/lib/types/svg/font.d.ts +0 -10
- package/dist/lib/types/svg/stroke.d.ts +0 -10
- package/dist/lib/types/tikz/index.d.ts +0 -6
- package/dist/lib/utils/compare.cjs +0 -20
- package/dist/lib/utils/compare.d.ts +0 -4
- package/dist/lib/utils/css.cjs +0 -26
- package/dist/lib/utils/css.d.ts +0 -6
- package/dist/lib/utils/math.cjs +0 -26
- package/dist/lib/utils/math.d.ts +0 -9
- package/dist/lib/utils/string.cjs +0 -7
- package/dist/lib/utils/string.d.ts +0 -7
- package/dist/lib/utils/style/font.cjs +0 -34
- package/dist/lib/utils/style/font.d.ts +0 -17
- package/dist/lib/utils/style/stroke.cjs +0 -42
- package/dist/lib/utils/style/stroke.d.ts +0 -20
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { Position } from '../../types/coordinate/descartes';
|
|
3
|
-
import { StrokeProps } from '../../types/svg/stroke';
|
|
4
|
-
import { TikZProps } from '../../types/tikz';
|
|
5
|
-
import { DirectionDistance } from '../../types/distance';
|
|
6
|
-
import { FontProps } from '../../types/svg/font';
|
|
7
|
-
/** 节点外边框形状 */
|
|
8
|
-
export type NodeShape = 'rectangle';
|
|
9
|
-
/** 外层形状相关属性 */
|
|
10
|
-
export type ShapeProps = {
|
|
11
|
-
shape: NodeShape;
|
|
12
|
-
rx?: number | string;
|
|
13
|
-
ry?: number | string;
|
|
14
|
-
fill?: string;
|
|
15
|
-
fillOpacity?: number;
|
|
16
|
-
} & StrokeProps;
|
|
17
|
-
/** 内容相关属性 */
|
|
18
|
-
export type ContentProps = {
|
|
19
|
-
color: string;
|
|
20
|
-
opacity?: number;
|
|
21
|
-
children?: ReactNode;
|
|
22
|
-
size?: string | number;
|
|
23
|
-
} & FontProps;
|
|
24
|
-
export type InnerNodeProps = {
|
|
25
|
-
position: Position;
|
|
26
|
-
width?: number;
|
|
27
|
-
height?: number;
|
|
28
|
-
innerSep: DirectionDistance<number | string>;
|
|
29
|
-
outerSep: DirectionDistance<number | string>;
|
|
30
|
-
rotate?: number;
|
|
31
|
-
} & TikZProps & ContentProps & ShapeProps;
|
|
32
|
-
declare const InnerNode: import('react').ForwardRefExoticComponent<Omit<InnerNodeProps, "ref"> & import('react').RefAttributes<SVGGElement>>;
|
|
33
|
-
export default InnerNode;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useRef, useLayoutEffect } from "react";
|
|
3
|
-
import Group from "../../container/Group.js";
|
|
4
|
-
import useNodeShape from "./_hooks/useNodeShape.js";
|
|
5
|
-
import useNodeContent from "./_hooks/useNodeContent.js";
|
|
6
|
-
import useNodeConfig from "./_hooks/useNodeConfig.js";
|
|
7
|
-
import { convertCssToPx } from "../../utils/css.js";
|
|
8
|
-
import useNodes from "../../hooks/context/useNodes.js";
|
|
9
|
-
import useCalculate from "../../hooks/context/useCalculate.js";
|
|
10
|
-
import { convertPrecision } from "../../utils/math.js";
|
|
11
|
-
const InnerNode = forwardRef((props, ref) => {
|
|
12
|
-
const { name, position, width, height, innerSep, outerSep, rotate } = props;
|
|
13
|
-
const nodeRef = useRef(null);
|
|
14
|
-
const shapeRef = useRef(null);
|
|
15
|
-
const contentRef = useRef(null);
|
|
16
|
-
const { getModel, updateModel, deleteModel } = useNodes();
|
|
17
|
-
const { precision } = useCalculate();
|
|
18
|
-
const nodeConfig = useNodeConfig();
|
|
19
|
-
nodeConfig.current.position = position;
|
|
20
|
-
if (name && !getModel(name)) {
|
|
21
|
-
updateModel(name, nodeConfig.current, false);
|
|
22
|
-
}
|
|
23
|
-
const groupElement = ref && "current" in ref ? ref.current : nodeRef.current;
|
|
24
|
-
useLayoutEffect(() => {
|
|
25
|
-
const contentElement = contentRef.current;
|
|
26
|
-
if (!contentElement) return;
|
|
27
|
-
const { width: elementWidth, height: elementHeight } = contentElement.getBoundingClientRect();
|
|
28
|
-
nodeConfig.current.contentSize = [Math.max(elementWidth, width || 0), Math.max(elementHeight, height || 0)];
|
|
29
|
-
});
|
|
30
|
-
const getSep = (sep) => {
|
|
31
|
-
const { width: width2 = 100, height: height2 = 100 } = (groupElement == null ? void 0 : groupElement.getBoundingClientRect()) || {};
|
|
32
|
-
const remPx = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
33
|
-
const emPx = groupElement ? parseFloat(getComputedStyle(groupElement).fontSize) : remPx;
|
|
34
|
-
return {
|
|
35
|
-
left: convertCssToPx(sep.left, { remPx, emPx, parentPx: width2 }),
|
|
36
|
-
right: convertCssToPx(sep.right, { remPx, emPx, parentPx: width2 }),
|
|
37
|
-
top: convertCssToPx(sep.top, { remPx, emPx, parentPx: height2 }),
|
|
38
|
-
bottom: convertCssToPx(sep.bottom, { remPx, emPx, parentPx: height2 })
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
useLayoutEffect(() => {
|
|
42
|
-
nodeConfig.current.innerSep = getSep(innerSep);
|
|
43
|
-
}, [innerSep]);
|
|
44
|
-
useLayoutEffect(() => {
|
|
45
|
-
nodeConfig.current.outerSep = getSep(outerSep);
|
|
46
|
-
}, [outerSep]);
|
|
47
|
-
useLayoutEffect(() => {
|
|
48
|
-
var _a, _b, _c, _d;
|
|
49
|
-
const {
|
|
50
|
-
contentSize: [width2, height2],
|
|
51
|
-
innerSep: innerSep2
|
|
52
|
-
} = nodeConfig.current;
|
|
53
|
-
const realX = -width2 / 2 - innerSep2.left;
|
|
54
|
-
(_a = shapeRef.current) == null ? void 0 : _a.setAttribute("x", convertPrecision(realX, precision).toString());
|
|
55
|
-
const realY = -height2 / 2 - innerSep2.top;
|
|
56
|
-
(_b = shapeRef.current) == null ? void 0 : _b.setAttribute("y", convertPrecision(realY, precision).toString());
|
|
57
|
-
const realWidth = width2 + innerSep2.left + innerSep2.right;
|
|
58
|
-
(_c = shapeRef.current) == null ? void 0 : _c.setAttribute("width", convertPrecision(realWidth, precision).toString());
|
|
59
|
-
const realHeight = height2 + innerSep2.top + innerSep2.bottom;
|
|
60
|
-
(_d = shapeRef.current) == null ? void 0 : _d.setAttribute("height", convertPrecision(realHeight, precision).toString());
|
|
61
|
-
}, [nodeConfig.current.position, nodeConfig.current.contentSize, nodeConfig.current.innerSep]);
|
|
62
|
-
useLayoutEffect(() => {
|
|
63
|
-
if (name) updateModel(name, nodeConfig.current);
|
|
64
|
-
});
|
|
65
|
-
useLayoutEffect(
|
|
66
|
-
() => () => {
|
|
67
|
-
if (name) {
|
|
68
|
-
deleteModel(name);
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
[name]
|
|
72
|
-
);
|
|
73
|
-
return /* @__PURE__ */ jsxs(
|
|
74
|
-
Group,
|
|
75
|
-
{
|
|
76
|
-
ref: ref || nodeRef,
|
|
77
|
-
id: name,
|
|
78
|
-
transform: `translate(${position[0]}, ${position[1]}) ${rotate ? `rotate(${rotate})` : ""}`,
|
|
79
|
-
children: [
|
|
80
|
-
useNodeShape(props, shapeRef),
|
|
81
|
-
useNodeContent(props, contentRef)
|
|
82
|
-
]
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
export {
|
|
87
|
-
InnerNode as default
|
|
88
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { ReactNode } 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
|
-
/** 位置 */
|
|
14
|
-
position?: PointPosition;
|
|
15
|
-
/** 位置偏移 */
|
|
16
|
-
offset?: PointPosition;
|
|
17
|
-
/** 内容宽度 */
|
|
18
|
-
width?: CssDistanceType;
|
|
19
|
-
/** 内容高度 */
|
|
20
|
-
height?: CssDistanceType;
|
|
21
|
-
/** 内容(文本)颜色 */
|
|
22
|
-
color?: 'currentColor' | 'auto' | string;
|
|
23
|
-
/** 内容(文本)透明度 */
|
|
24
|
-
opacity?: number;
|
|
25
|
-
/** 内容(文本)字体大小 */
|
|
26
|
-
size?: string | TikZFontSize | number;
|
|
27
|
-
/** 内容 */
|
|
28
|
-
children?: ReactNode;
|
|
29
|
-
/** 边框形状 */
|
|
30
|
-
shape?: NodeShape;
|
|
31
|
-
/** 边框圆角 */
|
|
32
|
-
r?: CssDistanceType;
|
|
33
|
-
/** 边框圆角-x */
|
|
34
|
-
rx?: CssDistanceType;
|
|
35
|
-
/** 边框圆角-y */
|
|
36
|
-
ry?: CssDistanceType;
|
|
37
|
-
/** 背景填充色,默认为 auto */
|
|
38
|
-
fill?: string | 'auto';
|
|
39
|
-
/** 背景填充色透明度 */
|
|
40
|
-
fillOpacity?: number;
|
|
41
|
-
/** 边框样式 */
|
|
42
|
-
strokeType?: StrokeType;
|
|
43
|
-
/** 内边距 */
|
|
44
|
-
innerSep?: CssDistanceType | SepProps;
|
|
45
|
-
/** 外边距 */
|
|
46
|
-
outerSep?: CssDistanceType | SepProps;
|
|
47
|
-
/** 旋转 */
|
|
48
|
-
rotate?: number;
|
|
49
|
-
/** 样式 */
|
|
50
|
-
style?: 'bold' | 'italic' | 'serif' | 'sans-serif';
|
|
51
|
-
} & Partial<FontProps> & Partial<StrokeProps> & StrokeShortcutProps;
|
|
52
|
-
declare const Node: import('react').ForwardRefExoticComponent<{
|
|
53
|
-
name?: TikZKey;
|
|
54
|
-
/** 位置 */
|
|
55
|
-
position?: PointPosition;
|
|
56
|
-
/** 位置偏移 */
|
|
57
|
-
offset?: PointPosition;
|
|
58
|
-
/** 内容宽度 */
|
|
59
|
-
width?: CssDistanceType;
|
|
60
|
-
/** 内容高度 */
|
|
61
|
-
height?: CssDistanceType;
|
|
62
|
-
/** 内容(文本)颜色 */
|
|
63
|
-
color?: "currentColor" | "auto" | string;
|
|
64
|
-
/** 内容(文本)透明度 */
|
|
65
|
-
opacity?: number;
|
|
66
|
-
/** 内容(文本)字体大小 */
|
|
67
|
-
size?: string | TikZFontSize | number;
|
|
68
|
-
/** 内容 */
|
|
69
|
-
children?: ReactNode;
|
|
70
|
-
/** 边框形状 */
|
|
71
|
-
shape?: NodeShape;
|
|
72
|
-
/** 边框圆角 */
|
|
73
|
-
r?: CssDistanceType;
|
|
74
|
-
/** 边框圆角-x */
|
|
75
|
-
rx?: CssDistanceType;
|
|
76
|
-
/** 边框圆角-y */
|
|
77
|
-
ry?: CssDistanceType;
|
|
78
|
-
/** 背景填充色,默认为 auto */
|
|
79
|
-
fill?: string | "auto";
|
|
80
|
-
/** 背景填充色透明度 */
|
|
81
|
-
fillOpacity?: number;
|
|
82
|
-
/** 边框样式 */
|
|
83
|
-
strokeType?: StrokeType;
|
|
84
|
-
/** 内边距 */
|
|
85
|
-
innerSep?: CssDistanceType | SepProps;
|
|
86
|
-
/** 外边距 */
|
|
87
|
-
outerSep?: CssDistanceType | SepProps;
|
|
88
|
-
/** 旋转 */
|
|
89
|
-
rotate?: number;
|
|
90
|
-
/** 样式 */
|
|
91
|
-
style?: "bold" | "italic" | "serif" | "sans-serif";
|
|
92
|
-
} & Partial<FontProps> & Partial<StrokeProps> & StrokeShortcutProps & import('react').RefAttributes<SVGGElement>>;
|
|
93
|
-
export default Node;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useMemo } from "react";
|
|
3
|
-
import InnerNode from "./InnerNode.js";
|
|
4
|
-
import { convertCssToPx } from "../../utils/css.js";
|
|
5
|
-
import { convertStrokeType, convertStrokeShortcut } from "../../utils/style/stroke.js";
|
|
6
|
-
import { convertFontSize, convertFontStyle } from "../../utils/style/font.js";
|
|
7
|
-
import DescartesPoint from "../../model/geometry/point/DescartesPoint.js";
|
|
8
|
-
import useScope from "../../hooks/context/useScope.js";
|
|
9
|
-
import color, { hsl } from "../../node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.js";
|
|
10
|
-
const Node = forwardRef((props, ref) => {
|
|
11
|
-
const { offset: scopeOffset, node } = useScope();
|
|
12
|
-
const nodeScopeProps = { offset: scopeOffset, ...node };
|
|
13
|
-
const realProps = {
|
|
14
|
-
...nodeScopeProps,
|
|
15
|
-
...props,
|
|
16
|
-
offset: DescartesPoint.plus(scopeOffset || [0, 0], props.offset || [0, 0])
|
|
17
|
-
};
|
|
18
|
-
const { shape = "rectangle", width, height, position, offset, innerSep, outerSep, ...res1Props } = realProps;
|
|
19
|
-
const { r, rx, ry, fill, fillOpacity, stroke = "transparent", strokeWidth = 1, strokeType, ...res2Props } = res1Props;
|
|
20
|
-
const { color: color$1 = "currentColor", size, fontSize, style, ...otherProps } = res2Props;
|
|
21
|
-
const realPosition = useMemo(() => {
|
|
22
|
-
const formatPosition = position ? DescartesPoint.formatPosition(position) : [0, 0];
|
|
23
|
-
const formatOffset = offset ? DescartesPoint.formatPosition(offset) : [0, 0];
|
|
24
|
-
return [formatPosition[0] + formatOffset[0], formatPosition[1] + formatOffset[1]];
|
|
25
|
-
}, [position]);
|
|
26
|
-
const realColor = useMemo(() => {
|
|
27
|
-
if (color$1 === "auto" && fill && fill !== "currentColor") {
|
|
28
|
-
const fillColor = color(fill);
|
|
29
|
-
if (!fillColor) return color$1 || "currentColor";
|
|
30
|
-
fillColor.opacity = fillOpacity || 1;
|
|
31
|
-
const lightness = hsl(fillColor).l;
|
|
32
|
-
return lightness < 0.5 ? "white" : "black";
|
|
33
|
-
}
|
|
34
|
-
return color$1 || "currentColor";
|
|
35
|
-
}, [color$1, fill, fillOpacity]);
|
|
36
|
-
const realRx = rx || r;
|
|
37
|
-
const realRy = ry || r;
|
|
38
|
-
const getStrokeAttributes = () => strokeType ? convertStrokeType(strokeType, strokeWidth) : convertStrokeShortcut(otherProps, strokeWidth);
|
|
39
|
-
const getSep = (sep, defaultVal) => {
|
|
40
|
-
if (typeof sep !== "object") {
|
|
41
|
-
return {
|
|
42
|
-
left: sep ?? defaultVal,
|
|
43
|
-
right: sep ?? defaultVal,
|
|
44
|
-
top: sep ?? defaultVal,
|
|
45
|
-
bottom: sep ?? defaultVal
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
left: sep.left ?? sep.x ?? defaultVal,
|
|
50
|
-
right: sep.right ?? sep.x ?? defaultVal,
|
|
51
|
-
top: sep.top ?? sep.y ?? defaultVal,
|
|
52
|
-
bottom: sep.bottom ?? sep.y ?? defaultVal
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
const getFontStyle = () => convertFontStyle(style);
|
|
56
|
-
const adjustFontSize = useMemo(() => convertFontSize(size || fontSize), [size, fontSize]);
|
|
57
|
-
const adjustedInnerSep = useMemo(
|
|
58
|
-
() => getSep(innerSep, convertCssToPx(adjustFontSize) / 3 || "0.3333em"),
|
|
59
|
-
[innerSep]
|
|
60
|
-
);
|
|
61
|
-
const adjustedOuterSep = useMemo(() => getSep(outerSep, 0), [outerSep]);
|
|
62
|
-
return /* @__PURE__ */ jsx(
|
|
63
|
-
InnerNode,
|
|
64
|
-
{
|
|
65
|
-
ref,
|
|
66
|
-
width: convertCssToPx(width),
|
|
67
|
-
height: convertCssToPx(height),
|
|
68
|
-
shape,
|
|
69
|
-
position: realPosition,
|
|
70
|
-
color: realColor,
|
|
71
|
-
fill: fill || "transparent",
|
|
72
|
-
fillOpacity,
|
|
73
|
-
rx: realRx,
|
|
74
|
-
ry: realRy,
|
|
75
|
-
stroke,
|
|
76
|
-
strokeWidth,
|
|
77
|
-
innerSep: adjustedInnerSep,
|
|
78
|
-
outerSep: adjustedOuterSep,
|
|
79
|
-
size: adjustFontSize,
|
|
80
|
-
...getFontStyle(),
|
|
81
|
-
...getStrokeAttributes(),
|
|
82
|
-
...otherProps
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
export {
|
|
87
|
-
Node as default
|
|
88
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { useRef } from "react";
|
|
2
|
-
const useNodeConfig = () => {
|
|
3
|
-
const configRef = useRef({
|
|
4
|
-
position: [0, 0],
|
|
5
|
-
contentSize: [0, 0],
|
|
6
|
-
innerSep: { left: 0, right: 0, top: 0, bottom: 0 },
|
|
7
|
-
outerSep: { left: 0, right: 0, top: 0, bottom: 0 }
|
|
8
|
-
});
|
|
9
|
-
return configRef;
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
useNodeConfig as default
|
|
13
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { isValidElement, useMemo, cloneElement } from "react";
|
|
3
|
-
import Text from "../../../elements/Text.js";
|
|
4
|
-
const useNodeContent = (props, ref) => {
|
|
5
|
-
const { color, size, opacity, fontWeight, fontStyle, fontFamily, fontStretch, children } = props;
|
|
6
|
-
const isTextNode = children !== null && !isValidElement(children);
|
|
7
|
-
return useMemo(
|
|
8
|
-
() => isTextNode ? /* @__PURE__ */ jsx(
|
|
9
|
-
Text,
|
|
10
|
-
{
|
|
11
|
-
fill: color,
|
|
12
|
-
fontSize: size,
|
|
13
|
-
fillOpacity: opacity,
|
|
14
|
-
fontWeight,
|
|
15
|
-
fontStyle,
|
|
16
|
-
fontFamily,
|
|
17
|
-
fontStretch,
|
|
18
|
-
ref,
|
|
19
|
-
children
|
|
20
|
-
}
|
|
21
|
-
) : isValidElement(children) ? (
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
-
cloneElement(children, { ref })
|
|
24
|
-
) : children,
|
|
25
|
-
isTextNode ? [color, size, children] : [children]
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
export {
|
|
29
|
-
useNodeContent as default
|
|
30
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import Rect from "../../../elements/Rect.js";
|
|
4
|
-
const getShapeProps = (nodeProps) => {
|
|
5
|
-
const { rx, ry, fill, fillOpacity, stroke, strokeWidth, strokeOpacity } = nodeProps;
|
|
6
|
-
const { strokeDasharray, strokeDashoffset, strokeLinecap, strokeLinejoin, strokeMiterlimit } = nodeProps;
|
|
7
|
-
return {
|
|
8
|
-
rx,
|
|
9
|
-
ry,
|
|
10
|
-
fill,
|
|
11
|
-
fillOpacity,
|
|
12
|
-
stroke,
|
|
13
|
-
strokeWidth,
|
|
14
|
-
strokeOpacity,
|
|
15
|
-
strokeDasharray,
|
|
16
|
-
strokeDashoffset,
|
|
17
|
-
strokeLinecap,
|
|
18
|
-
strokeLinejoin,
|
|
19
|
-
strokeMiterlimit
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
const useNodeShape = (props, ref) => {
|
|
23
|
-
const shapeProps = getShapeProps(props);
|
|
24
|
-
const Shape = useMemo(() => {
|
|
25
|
-
switch (props.shape) {
|
|
26
|
-
case "rectangle":
|
|
27
|
-
return Rect;
|
|
28
|
-
}
|
|
29
|
-
}, [props.shape, ...Object.values(shapeProps)]);
|
|
30
|
-
return /* @__PURE__ */ jsx(Shape, { ref, ...shapeProps });
|
|
31
|
-
};
|
|
32
|
-
export {
|
|
33
|
-
useNodeShape as default
|
|
34
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Direction } from '../../types/coordinate';
|
|
2
|
-
import { Position } from '../../types/coordinate/descartes';
|
|
3
|
-
import { NodeProps } from '../node/Node';
|
|
4
|
-
type PathNodePositionProps = {
|
|
5
|
-
left?: boolean | number | string;
|
|
6
|
-
right?: boolean | number | string;
|
|
7
|
-
above?: boolean | number | string;
|
|
8
|
-
below?: boolean | number | string;
|
|
9
|
-
};
|
|
10
|
-
type PosShortcutProps = {
|
|
11
|
-
/** pos: 0 */
|
|
12
|
-
start?: boolean;
|
|
13
|
-
/** pos: 0.125 */
|
|
14
|
-
veryNearStart?: boolean;
|
|
15
|
-
/** pos: 0.25 */
|
|
16
|
-
nearStart?: boolean;
|
|
17
|
-
/** pos: 0.5 */
|
|
18
|
-
midway?: boolean;
|
|
19
|
-
/** pos: 0.75 */
|
|
20
|
-
nearEnd?: boolean;
|
|
21
|
-
/** pos: 0.875 */
|
|
22
|
-
veryNearEnd?: boolean;
|
|
23
|
-
/** pos: 1 */
|
|
24
|
-
end?: boolean;
|
|
25
|
-
};
|
|
26
|
-
export type PathNodeProps = {
|
|
27
|
-
segmentIndex?: number;
|
|
28
|
-
/** path 片段的下标 */
|
|
29
|
-
pos?: number;
|
|
30
|
-
/** 相对于路径的位置 */
|
|
31
|
-
anchor?: Direction | 'center';
|
|
32
|
-
/** 偏移位置 */
|
|
33
|
-
offset?: Position;
|
|
34
|
-
/** 跟随箭头位置 */
|
|
35
|
-
sloped?: boolean;
|
|
36
|
-
} & PathNodePositionProps & PosShortcutProps & Omit<NodeProps, 'position'>;
|
|
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>>;
|
|
48
|
-
export default PathNode;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useId, useMemo, useState, useLayoutEffect } from "react";
|
|
3
|
-
import useCalculate from "../../hooks/context/useCalculate.js";
|
|
4
|
-
import useNodes from "../../hooks/context/useNodes.js";
|
|
5
|
-
import useScope, { ScopeContext } from "../../hooks/context/useScope.js";
|
|
6
|
-
import DescartesPoint from "../../model/geometry/point/DescartesPoint.js";
|
|
7
|
-
import { convertCssToPx } from "../../utils/css.js";
|
|
8
|
-
import { convertPrecision } from "../../utils/math.js";
|
|
9
|
-
import Node from "../node/Node.js";
|
|
10
|
-
import useAnchor from "./useAnchor.js";
|
|
11
|
-
const PathNode = forwardRef((props, ref) => {
|
|
12
|
-
const { segmentIndex = -1, offset = [0, 0], anchor, left, right, above, below, name, ...resProps } = props;
|
|
13
|
-
const { pos, veryNearStart, veryNearEnd, start, nearStart, midway, nearEnd, end, sloped, ...nodeProps } = resProps;
|
|
14
|
-
const id = useId();
|
|
15
|
-
const realName = name ?? id;
|
|
16
|
-
const { precision } = useCalculate();
|
|
17
|
-
const posRadio = useMemo(() => {
|
|
18
|
-
if (pos !== void 0) return pos;
|
|
19
|
-
if (start) return 0;
|
|
20
|
-
if (veryNearStart) return 0.125;
|
|
21
|
-
if (nearStart) return 0.25;
|
|
22
|
-
if (midway) return 0.5;
|
|
23
|
-
if (nearEnd) return 0.75;
|
|
24
|
-
if (veryNearEnd) return 0.875;
|
|
25
|
-
return 1;
|
|
26
|
-
}, [pos, veryNearStart, veryNearEnd, start, nearStart, midway, nearEnd, end]);
|
|
27
|
-
const directionPos = useMemo(() => {
|
|
28
|
-
if (left) return { direction: "left", distance: typeof left === "boolean" ? 0 : convertCssToPx(left) };
|
|
29
|
-
if (right) return { direction: "right", distance: typeof right === "boolean" ? 0 : convertCssToPx(right) };
|
|
30
|
-
if (above) return { direction: "top", distance: typeof above === "boolean" ? 0 : convertCssToPx(above) };
|
|
31
|
-
if (below) return { direction: "bottom", distance: typeof below === "boolean" ? 0 : convertCssToPx(below) };
|
|
32
|
-
return { direction: anchor ?? "center", distance: 0 };
|
|
33
|
-
}, [anchor, left, right, above, below]);
|
|
34
|
-
const { position: anchorPosition, angle: anchorAngle } = useAnchor(posRadio, segmentIndex);
|
|
35
|
-
const [adjustOffset, setAdjustOffset] = useState(DescartesPoint.plus(anchorPosition, offset));
|
|
36
|
-
const { getModel } = useNodes();
|
|
37
|
-
const rotate = useMemo(() => {
|
|
38
|
-
if (!sloped) return 0;
|
|
39
|
-
return anchorAngle * (180 / Math.PI);
|
|
40
|
-
}, [sloped, anchorAngle]);
|
|
41
|
-
useLayoutEffect(() => {
|
|
42
|
-
const model = getModel(realName);
|
|
43
|
-
if (!model || !model.init) return;
|
|
44
|
-
const { direction, distance } = directionPos;
|
|
45
|
-
let directionPosition = [0, 0];
|
|
46
|
-
switch (direction) {
|
|
47
|
-
case "left":
|
|
48
|
-
directionPosition = [-(model == null ? void 0 : model.getOuterDistance("left")) - distance, 0];
|
|
49
|
-
break;
|
|
50
|
-
case "right":
|
|
51
|
-
directionPosition = [(model == null ? void 0 : model.getOuterDistance("right")) + distance, 0];
|
|
52
|
-
break;
|
|
53
|
-
case "top":
|
|
54
|
-
directionPosition = [0, -(model == null ? void 0 : model.getOuterDistance("top")) - distance];
|
|
55
|
-
break;
|
|
56
|
-
case "bottom":
|
|
57
|
-
directionPosition = [0, (model == null ? void 0 : model.getOuterDistance("bottom")) + distance];
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
setAdjustOffset(DescartesPoint.plus(anchorPosition, directionPosition, offset));
|
|
61
|
-
}, [anchorPosition, directionPos]);
|
|
62
|
-
const scope = useScope();
|
|
63
|
-
return /* @__PURE__ */ jsx(ScopeContext.Provider, { value: { ...scope, offset: [0, 0] }, children: /* @__PURE__ */ jsx(
|
|
64
|
-
Node,
|
|
65
|
-
{
|
|
66
|
-
name: realName,
|
|
67
|
-
position: convertPrecision(adjustOffset, precision),
|
|
68
|
-
ref,
|
|
69
|
-
rotate,
|
|
70
|
-
...nodeProps
|
|
71
|
-
}
|
|
72
|
-
) });
|
|
73
|
-
});
|
|
74
|
-
export {
|
|
75
|
-
PathNode as default
|
|
76
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { useRef, useLayoutEffect, useMemo } from "react";
|
|
2
|
-
import useCalculate from "../../hooks/context/useCalculate.js";
|
|
3
|
-
import usePath from "../../hooks/context/usePath.js";
|
|
4
|
-
import useForceUpdate from "../../hooks/useForceUpdate.js";
|
|
5
|
-
import Line from "../../model/equation/line.js";
|
|
6
|
-
import { between, convertPrecision } from "../../utils/math.js";
|
|
7
|
-
const useAnchor = (pos, segmentIndex) => {
|
|
8
|
-
const pathUpdateCount = useRef(0);
|
|
9
|
-
const forceUpdate = useForceUpdate();
|
|
10
|
-
const { model, subscribeModel } = usePath();
|
|
11
|
-
const { precision } = useCalculate();
|
|
12
|
-
const subscribeCb = subscribeModel((model2) => {
|
|
13
|
-
if (!(model2 == null ? void 0 : model2.init)) return;
|
|
14
|
-
pathUpdateCount.current += 1;
|
|
15
|
-
queueMicrotask(forceUpdate);
|
|
16
|
-
});
|
|
17
|
-
useLayoutEffect(() => () => {
|
|
18
|
-
subscribeCb == null ? void 0 : subscribeCb();
|
|
19
|
-
});
|
|
20
|
-
const adjustIndex = segmentIndex >= 0 ? segmentIndex : model.ways.length + segmentIndex;
|
|
21
|
-
if (!between(adjustIndex, [0, model.ways.length - 1], true)) throw new Error("segmentIndex is out of range");
|
|
22
|
-
return useMemo(() => {
|
|
23
|
-
if (!model.init)
|
|
24
|
-
return {
|
|
25
|
-
position: [Number.MAX_SAFE_INTEGER / 2, Number.MAX_SAFE_INTEGER / 2],
|
|
26
|
-
angle: 0
|
|
27
|
-
};
|
|
28
|
-
const way = model.ways[adjustIndex];
|
|
29
|
-
const waySegments = way.length - 1;
|
|
30
|
-
const segmentPercent = 1 / waySegments;
|
|
31
|
-
let segmentSum = 0;
|
|
32
|
-
let index = 0;
|
|
33
|
-
while (pos >= segmentSum) {
|
|
34
|
-
segmentSum += segmentPercent;
|
|
35
|
-
index++;
|
|
36
|
-
}
|
|
37
|
-
const startPoint = way[index - 1];
|
|
38
|
-
const endPoint = way[index];
|
|
39
|
-
const percent = pos % segmentPercent / segmentPercent;
|
|
40
|
-
const position = index === way.length ? startPoint : Line.getPositionByPercent(startPoint, endPoint, percent);
|
|
41
|
-
return {
|
|
42
|
-
position: convertPrecision(position, precision),
|
|
43
|
-
angle: index === way.length ? Line.getDegree(way[way.length - 2], way[way.length - 1]) : Line.getDegree(startPoint, endPoint)
|
|
44
|
-
};
|
|
45
|
-
}, [pos, segmentIndex, pathUpdateCount.current]);
|
|
46
|
-
};
|
|
47
|
-
export {
|
|
48
|
-
useAnchor as default
|
|
49
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren, Ref, SVGProps } from 'react';
|
|
2
|
-
export type GroupProps = {
|
|
3
|
-
ref?: Ref<SVGGElement>;
|
|
4
|
-
} & SVGProps<SVGGElement>;
|
|
5
|
-
declare const Group: import('react').ForwardRefExoticComponent<Omit<PropsWithChildren<SVGProps<SVGGElement>>, "ref"> & import('react').RefAttributes<SVGGElement>>;
|
|
6
|
-
export default Group;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { CSSProperties } 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: import('react').ForwardRefExoticComponent<SurfaceProps & {
|
|
17
|
-
children?: import('react').ReactNode | undefined;
|
|
18
|
-
} & import('react').RefAttributes<SVGSVGElement>>;
|
|
19
|
-
export default Surface;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useMemo } from "react";
|
|
3
|
-
const Surface = forwardRef((props, ref) => {
|
|
4
|
-
const { title, desc, viewBox, children, width, height, ...otherProps } = props;
|
|
5
|
-
const svgViewBox = useMemo(() => {
|
|
6
|
-
if (!(viewBox == null ? void 0 : viewBox.x) && !(viewBox == null ? void 0 : viewBox.y)) {
|
|
7
|
-
return void 0;
|
|
8
|
-
}
|
|
9
|
-
const viewX = (viewBox == null ? void 0 : viewBox.x) || 0;
|
|
10
|
-
const viewY = (viewBox == null ? void 0 : viewBox.y) || 0;
|
|
11
|
-
const viewWidth = (viewBox == null ? void 0 : viewBox.width) || width;
|
|
12
|
-
const viewHeight = (viewBox == null ? void 0 : viewBox.height) || height;
|
|
13
|
-
return viewWidth === void 0 || viewHeight === void 0 ? [viewX, viewY].join(" ") : [viewX, viewY, viewWidth, viewHeight].join(" ");
|
|
14
|
-
}, [width, height, viewBox]);
|
|
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
|
-
children
|
|
19
|
-
] });
|
|
20
|
-
});
|
|
21
|
-
export {
|
|
22
|
-
Surface as default
|
|
23
|
-
};
|