@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,9 @@
|
|
|
1
|
+
import { CssDistanceType, DirectionDistance } from '.';
|
|
2
|
+
/** 快捷属性 */
|
|
3
|
+
export type SepShortcutProps<T = CssDistanceType> = {
|
|
4
|
+
defaultVal: T;
|
|
5
|
+
x: T;
|
|
6
|
+
y: T;
|
|
7
|
+
} & DirectionDistance<T>;
|
|
8
|
+
/** 距离的全部属性 */
|
|
9
|
+
export type SepProps<T = CssDistanceType> = T | SepShortcutProps<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
var Area = /* @__PURE__ */ ((Area2) => {
|
|
4
|
+
Area2["INSIDE"] = "inside";
|
|
5
|
+
Area2["OUTSIDE"] = "outside";
|
|
6
|
+
Area2["EDGE"] = "edge";
|
|
7
|
+
return Area2;
|
|
8
|
+
})(Area || {});
|
|
9
|
+
exports.Area = Area;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
var RectVertexPoint = /* @__PURE__ */ ((RectVertexPoint2) => {
|
|
4
|
+
RectVertexPoint2["TL"] = "top_left";
|
|
5
|
+
RectVertexPoint2["TR"] = "top_right";
|
|
6
|
+
RectVertexPoint2["BL"] = "bottom_left";
|
|
7
|
+
RectVertexPoint2["BR"] = "bottom_right";
|
|
8
|
+
return RectVertexPoint2;
|
|
9
|
+
})(RectVertexPoint || {});
|
|
10
|
+
var RectMidPoint = /* @__PURE__ */ ((RectMidPoint2) => {
|
|
11
|
+
RectMidPoint2["T"] = "top_mid";
|
|
12
|
+
RectMidPoint2["B"] = "bottom_mid";
|
|
13
|
+
RectMidPoint2["L"] = "left_mid";
|
|
14
|
+
RectMidPoint2["R"] = "right_mid";
|
|
15
|
+
return RectMidPoint2;
|
|
16
|
+
})(RectMidPoint || {});
|
|
17
|
+
var RectThirdPoint = /* @__PURE__ */ ((RectThirdPoint2) => {
|
|
18
|
+
RectThirdPoint2["TL"] = "third_top_left";
|
|
19
|
+
RectThirdPoint2["TR"] = "third_top_right";
|
|
20
|
+
RectThirdPoint2["BL"] = "third_bottom_left";
|
|
21
|
+
RectThirdPoint2["BR"] = "third_bottom_right";
|
|
22
|
+
RectThirdPoint2["LT"] = "third_left_top";
|
|
23
|
+
RectThirdPoint2["LB"] = "third_left_bottom";
|
|
24
|
+
RectThirdPoint2["RT"] = "third_right_top";
|
|
25
|
+
RectThirdPoint2["RB"] = "third_right_bottom";
|
|
26
|
+
return RectThirdPoint2;
|
|
27
|
+
})(RectThirdPoint || {});
|
|
28
|
+
exports.RectMidPoint = RectMidPoint;
|
|
29
|
+
exports.RectThirdPoint = RectThirdPoint;
|
|
30
|
+
exports.RectVertexPoint = RectVertexPoint;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** 矩形四个顶点 */
|
|
2
|
+
export declare enum RectVertexPoint {
|
|
3
|
+
TL = "top_left",
|
|
4
|
+
TR = "top_right",
|
|
5
|
+
BL = "bottom_left",
|
|
6
|
+
BR = "bottom_right"
|
|
7
|
+
}
|
|
8
|
+
/** 矩形四个边的中点 */
|
|
9
|
+
export declare enum RectMidPoint {
|
|
10
|
+
T = "top_mid",
|
|
11
|
+
B = "bottom_mid",
|
|
12
|
+
L = "left_mid",
|
|
13
|
+
R = "right_mid"
|
|
14
|
+
}
|
|
15
|
+
/** 矩形四边的三等分点 */
|
|
16
|
+
export declare enum RectThirdPoint {
|
|
17
|
+
TL = "third_top_left",
|
|
18
|
+
TR = "third_top_right",
|
|
19
|
+
BL = "third_bottom_left",
|
|
20
|
+
BR = "third_bottom_right",
|
|
21
|
+
LT = "third_left_top",
|
|
22
|
+
LB = "third_left_bottom",
|
|
23
|
+
RT = "third_right_top",
|
|
24
|
+
RB = "third_right_bottom"
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type FontWeight = 'normal' | 'bold' | 'bolder' | 'lighter';
|
|
2
|
+
export type FontProps = {
|
|
3
|
+
fill?: 'currentColor' | string;
|
|
4
|
+
fillOpacity?: number;
|
|
5
|
+
fontSize?: string | number;
|
|
6
|
+
fontWeight?: FontWeight | number;
|
|
7
|
+
fontStyle?: 'normal' | 'italic' | 'oblique';
|
|
8
|
+
fontFamily?: string;
|
|
9
|
+
fontStretch?: 'normal' | 'condensed' | 'semi-condensed' | 'ultra-condensed' | 'extra-condensed' | 'expanded' | 'semi-expanded' | 'extra-expanded' | 'ultra-expanded' | 'inherit' | 'initial' | 'revert' | 'revert-layer' | 'unset' | string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type StrokeProps = {
|
|
2
|
+
stroke?: string;
|
|
3
|
+
strokeWidth?: number;
|
|
4
|
+
strokeDasharray?: string;
|
|
5
|
+
strokeDashoffset?: string;
|
|
6
|
+
strokeLinecap?: 'butt' | 'round' | 'square' | 'inherit';
|
|
7
|
+
strokeLinejoin?: "round" | "inherit" | "bevel" | "miter";
|
|
8
|
+
strokeMiterlimit?: number;
|
|
9
|
+
strokeOpacity?: number;
|
|
10
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const isSameArray = (arr1, arr2) => {
|
|
4
|
+
if (arr1.length !== arr2.length) return false;
|
|
5
|
+
const length = arr1.length;
|
|
6
|
+
for (let i = 0; i < length; i++) {
|
|
7
|
+
if (arr1[i] !== arr2[i]) return false;
|
|
8
|
+
}
|
|
9
|
+
return true;
|
|
10
|
+
};
|
|
11
|
+
const isSameObj = (obj1, obj2) => {
|
|
12
|
+
if (Object.keys(obj1).length !== Object.keys(obj2).length) return false;
|
|
13
|
+
const keys = Object.keys(obj1);
|
|
14
|
+
for (let i = 0; i < keys.length; i++) {
|
|
15
|
+
if (obj1[keys[i]] !== obj2[keys[i]]) return false;
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
};
|
|
19
|
+
exports.isSameArray = isSameArray;
|
|
20
|
+
exports.isSameObj = isSameObj;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const convertCssToPx = (dimension, sizeConfig) => {
|
|
4
|
+
if (dimension === void 0) return 0;
|
|
5
|
+
if (typeof dimension === "number") return dimension;
|
|
6
|
+
const match = dimension.match(/^(\d+(?:\.\d+)?)(px|em|rem|%)$/);
|
|
7
|
+
const { remPx: remSize = 16, emPx: emSize = 16, parentPx: elementSize = 100 } = sizeConfig || {};
|
|
8
|
+
if (match) {
|
|
9
|
+
const value = parseFloat(match[1]);
|
|
10
|
+
const unit = match[2];
|
|
11
|
+
switch (unit) {
|
|
12
|
+
case "px":
|
|
13
|
+
return value;
|
|
14
|
+
case "em":
|
|
15
|
+
return value * (emSize || remSize || 16);
|
|
16
|
+
case "rem":
|
|
17
|
+
return value * (remSize || 16);
|
|
18
|
+
case "%":
|
|
19
|
+
return elementSize ? value / 100 * elementSize : value;
|
|
20
|
+
default:
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return parseInt(dimension);
|
|
25
|
+
};
|
|
26
|
+
exports.convertCssToPx = convertCssToPx;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const between = (value, range, equal) => {
|
|
4
|
+
return equal ? value >= range[0] && value <= range[1] : value > range[0] && value < range[1];
|
|
5
|
+
};
|
|
6
|
+
const convertPrecision = (value, precision, deep = true) => {
|
|
7
|
+
if (precision === false) return value;
|
|
8
|
+
const innerConvert = (value2) => {
|
|
9
|
+
if (precision === 0) return Math.round(value2);
|
|
10
|
+
const realPrecision = 10 ** precision;
|
|
11
|
+
return Math.round(value2 * realPrecision) / realPrecision;
|
|
12
|
+
};
|
|
13
|
+
if (typeof value === "number") return innerConvert(value);
|
|
14
|
+
if (Array.isArray(value))
|
|
15
|
+
return value.map((item) => deep ? innerConvert(item) : typeof item === "number" ? innerConvert(item) : item);
|
|
16
|
+
if (typeof value === "object" && value !== null) {
|
|
17
|
+
const result = {};
|
|
18
|
+
for (const [key, item] of Object.entries(value)) {
|
|
19
|
+
result[key] = deep ? convertPrecision(item, precision) : typeof item === "number" ? innerConvert(item) : item;
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
exports.between = between;
|
|
26
|
+
exports.convertPrecision = convertPrecision;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** 判断值是否在范围内 */
|
|
2
|
+
export declare const between: (value: number, range: [number, number], equal?: boolean) => boolean;
|
|
3
|
+
/**
|
|
4
|
+
* 将数值进行精度调整(主要是为了内存优化)
|
|
5
|
+
* @value 要调整的值
|
|
6
|
+
* @precision 要调整的精度
|
|
7
|
+
* @deep 是否进行深度调整
|
|
8
|
+
* */
|
|
9
|
+
export declare const convertPrecision: <T>(value: T, precision: number | false, deep?: boolean) => T;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const TikZFontSizeMap = {
|
|
4
|
+
tiny: "5px",
|
|
5
|
+
script: "8px",
|
|
6
|
+
footnote: "10px",
|
|
7
|
+
small: "12px",
|
|
8
|
+
normal: "16px",
|
|
9
|
+
large: "18px",
|
|
10
|
+
Large: "22px",
|
|
11
|
+
LARGE: "26px",
|
|
12
|
+
huge: "30px",
|
|
13
|
+
Huge: "36px"
|
|
14
|
+
};
|
|
15
|
+
const convertFontSize = (fontSize) => {
|
|
16
|
+
return typeof fontSize === "string" && TikZFontSizeMap.hasOwnProperty(fontSize) ? TikZFontSizeMap[fontSize] : fontSize;
|
|
17
|
+
};
|
|
18
|
+
const convertFontStyle = (fontStyle) => {
|
|
19
|
+
switch (fontStyle) {
|
|
20
|
+
case "bold":
|
|
21
|
+
return { fontWeight: "bold" };
|
|
22
|
+
case "italic":
|
|
23
|
+
return { fontStyle: "italic" };
|
|
24
|
+
case "serif":
|
|
25
|
+
return { fontFamily: "serif" };
|
|
26
|
+
case "sans-serif":
|
|
27
|
+
return { fontFamily: "sans-serif" };
|
|
28
|
+
default:
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.TikZFontSizeMap = TikZFontSizeMap;
|
|
33
|
+
exports.convertFontSize = convertFontSize;
|
|
34
|
+
exports.convertFontStyle = convertFontStyle;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FontProps } from '../../types/svg/font';
|
|
2
|
+
export declare const TikZFontSizeMap: {
|
|
3
|
+
tiny: string;
|
|
4
|
+
script: string;
|
|
5
|
+
footnote: string;
|
|
6
|
+
small: string;
|
|
7
|
+
normal: string;
|
|
8
|
+
large: string;
|
|
9
|
+
Large: string;
|
|
10
|
+
LARGE: string;
|
|
11
|
+
huge: string;
|
|
12
|
+
Huge: string;
|
|
13
|
+
};
|
|
14
|
+
export type TikZFontSize = keyof typeof TikZFontSizeMap;
|
|
15
|
+
export declare const convertFontSize: (fontSize?: string | TikZFontSize | number) => string | number | undefined;
|
|
16
|
+
export type FontStyle = 'bold' | 'italic' | 'serif' | 'sans-serif';
|
|
17
|
+
export declare const convertFontStyle: (fontStyle?: FontStyle) => Partial<FontProps>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const convertStrokeType = (strokeType, strokeWidth = 1) => {
|
|
4
|
+
switch (strokeType) {
|
|
5
|
+
case "solid":
|
|
6
|
+
return {};
|
|
7
|
+
case "dashed":
|
|
8
|
+
return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 4}` };
|
|
9
|
+
case "denselyDashed":
|
|
10
|
+
return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 2}` };
|
|
11
|
+
case "looselyDashed":
|
|
12
|
+
return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 6}` };
|
|
13
|
+
case "dotted":
|
|
14
|
+
return { strokeDasharray: `1 ${strokeWidth * 4}` };
|
|
15
|
+
case "denselyDotted":
|
|
16
|
+
return { strokeDasharray: `1 ${strokeWidth * 2}` };
|
|
17
|
+
case "looselyDotted":
|
|
18
|
+
return { strokeDasharray: `1 ${strokeWidth * 6}` };
|
|
19
|
+
case "dashDot":
|
|
20
|
+
return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 4} 1 ${strokeWidth * 4}` };
|
|
21
|
+
case "denselyDashDot":
|
|
22
|
+
return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 2} 1 ${strokeWidth * 2}` };
|
|
23
|
+
case "looselyDashDot":
|
|
24
|
+
return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 6} 1 ${strokeWidth * 6}` };
|
|
25
|
+
case "dashDashDot":
|
|
26
|
+
return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 4} 1 ${strokeWidth * 4} 1 ${strokeWidth * 4}` };
|
|
27
|
+
case "denselyDashDashDot":
|
|
28
|
+
return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 2} 1 ${strokeWidth * 2} 1 ${strokeWidth * 2}` };
|
|
29
|
+
case "looselyDashDashDot":
|
|
30
|
+
return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 6} 1 ${strokeWidth * 6} 1 ${strokeWidth * 6}` };
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const convertStrokeShortcut = (shortcutProps, strokeWidth = 1) => {
|
|
34
|
+
return convertStrokeType(
|
|
35
|
+
shortcutProps.dashed ? "dashed" : shortcutProps.denselyDashed ? "denselyDashed" : shortcutProps.looselyDashed ? "looselyDashed" : shortcutProps.dotted ? "dotted" : shortcutProps.denselyDotted ? "denselyDotted" : shortcutProps.looselyDotted ? "looselyDotted" : shortcutProps.dashDot ? "dashDot" : shortcutProps.denselyDashDot ? "denselyDashDot" : shortcutProps.looselyDashDot ? "looselyDashDot" : shortcutProps.dashDashDot ? "dashDashDot" : shortcutProps.denselyDashDashDot ? "denselyDashDashDot" : shortcutProps.looselyDashDashDot ? "looselyDashDashDot" : "solid",
|
|
36
|
+
strokeWidth || 1
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
exports.convertStrokeShortcut = convertStrokeShortcut;
|
|
40
|
+
exports.convertStrokeType = convertStrokeType;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { StrokeProps } from '../../types/svg/stroke';
|
|
2
|
+
export type StrokeType = 'solid' | 'dashed' | 'denselyDashed' | 'looselyDashed' | 'dotted' | 'denselyDotted' | 'looselyDotted' | 'dashDot' | 'denselyDashDot' | 'looselyDashDot' | 'dashDashDot' | 'denselyDashDashDot' | 'looselyDashDashDot';
|
|
3
|
+
export type StrokeShortcutProps = {
|
|
4
|
+
dashed?: boolean;
|
|
5
|
+
denselyDashed?: boolean;
|
|
6
|
+
looselyDashed?: boolean;
|
|
7
|
+
dotted?: boolean;
|
|
8
|
+
denselyDotted?: boolean;
|
|
9
|
+
looselyDotted?: boolean;
|
|
10
|
+
dashDot?: boolean;
|
|
11
|
+
denselyDashDot?: boolean;
|
|
12
|
+
looselyDashDot?: boolean;
|
|
13
|
+
dashDashDot?: boolean;
|
|
14
|
+
denselyDashDashDot?: boolean;
|
|
15
|
+
looselyDashDashDot?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/** 将 StrokeType 转换为 svg 原生的属性 */
|
|
18
|
+
export declare const convertStrokeType: (strokeType: StrokeType, strokeWidth?: number) => Partial<StrokeProps>;
|
|
19
|
+
export declare const convertStrokeShortcut: (shortcutProps: StrokeShortcutProps, strokeWidth?: number) => Partial<StrokeProps>;
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@retikz/core",
|
|
3
|
+
"version": "0.0.1-rc.0",
|
|
4
|
+
"description": "atomic drawing library implemented using react and d3, inspired by tikz",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"react",
|
|
8
|
+
"tikz",
|
|
9
|
+
"chart"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": "https://github.com/Pionpill/retikz",
|
|
13
|
+
"main": "dist/lib/index.js",
|
|
14
|
+
"module": "dist/es/index.js",
|
|
15
|
+
"types": "dist/lib/index.d.ts",
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"README.md",
|
|
22
|
+
"dist/**/*"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"dev": "vite",
|
|
26
|
+
"build": "vite build",
|
|
27
|
+
"lint": "eslint .",
|
|
28
|
+
"preview": "vite preview"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": ">=19.0.0",
|
|
32
|
+
"react-dom": ">=19.0.0"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"d3-color": "^3.1.0",
|
|
36
|
+
"d3-shape": "^3.2.0",
|
|
37
|
+
"react": "^19",
|
|
38
|
+
"react-dom": "^19"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@eslint/js": "^9.15.0",
|
|
42
|
+
"@types/d3-color": "^3.1.3",
|
|
43
|
+
"@types/d3-shape": "^3.1.6",
|
|
44
|
+
"@types/node": "^22.10.7",
|
|
45
|
+
"@types/react": "^19",
|
|
46
|
+
"@types/react-dom": "^19",
|
|
47
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
48
|
+
"eslint": "^9.15.0",
|
|
49
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
50
|
+
"eslint-plugin-react-refresh": "^0.4.14",
|
|
51
|
+
"globals": "^15.12.0",
|
|
52
|
+
"typescript": "~5.6.2",
|
|
53
|
+
"typescript-eslint": "^8.15.0",
|
|
54
|
+
"vite": "^6.0.1",
|
|
55
|
+
"vite-plugin-dts": "^4.5.0"
|
|
56
|
+
}
|
|
57
|
+
}
|