@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.
Files changed (233) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -0
  3. package/dist/es/_virtual/jsx-runtime.js +5 -0
  4. package/dist/es/_virtual/jsx-runtime2.js +4 -0
  5. package/dist/es/_virtual/react-jsx-runtime.development.js +4 -0
  6. package/dist/es/_virtual/react-jsx-runtime.production.js +4 -0
  7. package/dist/es/components/Scope.d.ts +6 -0
  8. package/dist/es/components/Scope.js +10 -0
  9. package/dist/es/components/TikZ.d.ts +9 -0
  10. package/dist/es/components/TikZ.js +12 -0
  11. package/dist/es/components/draw/Draw.d.ts +18 -0
  12. package/dist/es/components/draw/Draw.js +34 -0
  13. package/dist/es/components/draw/InnerDraw.d.ts +13 -0
  14. package/dist/es/components/draw/InnerDraw.js +47 -0
  15. package/dist/es/components/draw/arrow/index.d.ts +9 -0
  16. package/dist/es/components/draw/arrow/index.js +10 -0
  17. package/dist/es/components/draw/arrow/stealth.d.ts +7 -0
  18. package/dist/es/components/draw/arrow/stealth.js +29 -0
  19. package/dist/es/components/draw/arrow/types.d.ts +21 -0
  20. package/dist/es/components/draw/common.d.ts +4 -0
  21. package/dist/es/components/draw/common.js +12 -0
  22. package/dist/es/components/draw/index.d.ts +3 -0
  23. package/dist/es/components/draw/segment/Segment.d.ts +12 -0
  24. package/dist/es/components/draw/segment/Segment.js +41 -0
  25. package/dist/es/components/draw/segment/index.d.ts +19 -0
  26. package/dist/es/components/draw/segment/index.js +41 -0
  27. package/dist/es/components/draw/segment/useArrow.d.ts +12 -0
  28. package/dist/es/components/draw/segment/useArrow.js +52 -0
  29. package/dist/es/components/draw/segment/useConvertWay.d.ts +14 -0
  30. package/dist/es/components/draw/segment/useConvertWay.js +95 -0
  31. package/dist/es/components/draw/types.d.ts +29 -0
  32. package/dist/es/components/node/InnerNode.d.ts +33 -0
  33. package/dist/es/components/node/InnerNode.js +88 -0
  34. package/dist/es/components/node/Node.d.ts +54 -0
  35. package/dist/es/components/node/Node.js +87 -0
  36. package/dist/es/components/node/_hooks/useNodeConfig.d.ts +3 -0
  37. package/dist/es/components/node/_hooks/useNodeConfig.js +13 -0
  38. package/dist/es/components/node/_hooks/useNodeContent.d.ts +4 -0
  39. package/dist/es/components/node/_hooks/useNodeContent.js +27 -0
  40. package/dist/es/components/node/_hooks/useNodeShape.d.ts +4 -0
  41. package/dist/es/components/node/_hooks/useNodeShape.js +34 -0
  42. package/dist/es/components/node/index.d.ts +3 -0
  43. package/dist/es/components/node/index.js +4 -0
  44. package/dist/es/components/pathNode/PathNode.d.ts +39 -0
  45. package/dist/es/components/pathNode/PathNode.js +76 -0
  46. package/dist/es/components/pathNode/index.d.ts +3 -0
  47. package/dist/es/components/pathNode/index.js +4 -0
  48. package/dist/es/components/pathNode/useAnchor.d.ts +6 -0
  49. package/dist/es/components/pathNode/useAnchor.js +49 -0
  50. package/dist/es/container/Group.d.ts +6 -0
  51. package/dist/es/container/Group.js +7 -0
  52. package/dist/es/container/Surface.d.ts +17 -0
  53. package/dist/es/container/Surface.js +23 -0
  54. package/dist/es/elements/Path.d.ts +4 -0
  55. package/dist/es/elements/Path.js +13 -0
  56. package/dist/es/elements/Rect.d.ts +6 -0
  57. package/dist/es/elements/Rect.js +8 -0
  58. package/dist/es/elements/Text.d.ts +19 -0
  59. package/dist/es/elements/Text.js +35 -0
  60. package/dist/es/hooks/context/useCalculate.d.ts +7 -0
  61. package/dist/es/hooks/context/useCalculate.js +9 -0
  62. package/dist/es/hooks/context/useNodes.d.ts +9 -0
  63. package/dist/es/hooks/context/useNodes.js +33 -0
  64. package/dist/es/hooks/context/usePath.d.ts +13 -0
  65. package/dist/es/hooks/context/usePath.js +20 -0
  66. package/dist/es/hooks/context/useScope.d.ts +11 -0
  67. package/dist/es/hooks/context/useScope.js +7 -0
  68. package/dist/es/hooks/useForceUpdate.d.ts +2 -0
  69. package/dist/es/hooks/useForceUpdate.js +8 -0
  70. package/dist/es/index.d.ts +10 -0
  71. package/dist/es/index.js +12 -0
  72. package/dist/es/model/component/node.d.ts +45 -0
  73. package/dist/es/model/component/node.js +164 -0
  74. package/dist/es/model/component/path.d.ts +19 -0
  75. package/dist/es/model/component/path.js +47 -0
  76. package/dist/es/model/equation/line.d.ts +21 -0
  77. package/dist/es/model/equation/line.js +75 -0
  78. package/dist/es/model/geometry/point/DescartesPoint.d.ts +21 -0
  79. package/dist/es/model/geometry/point/DescartesPoint.js +50 -0
  80. package/dist/es/model/geometry/point/PolarPoint.d.ts +14 -0
  81. package/dist/es/model/geometry/point/PolarPoint.js +27 -0
  82. package/dist/es/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.js +338 -0
  83. package/dist/es/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.js +13 -0
  84. package/dist/es/node_modules/.pnpm/d3-path@3.1.0/node_modules/d3-path/src/path.js +88 -0
  85. package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/array.js +6 -0
  86. package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/constant.js +8 -0
  87. package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/linear.js +39 -0
  88. package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.js +41 -0
  89. package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/path.js +19 -0
  90. package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/point.js +10 -0
  91. package/dist/es/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.development.js +20 -0
  92. package/dist/es/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.production.js +41 -0
  93. package/dist/es/node_modules/.pnpm/react@19.0.0/node_modules/react/jsx-runtime.js +17 -0
  94. package/dist/es/types/coordinate/descartes.d.ts +23 -0
  95. package/dist/es/types/coordinate/index.d.ts +5 -0
  96. package/dist/es/types/coordinate/polar.d.ts +5 -0
  97. package/dist/es/types/distance/index.d.ts +8 -0
  98. package/dist/es/types/distance/sep.d.ts +9 -0
  99. package/dist/es/types/shape/index.d.ts +8 -0
  100. package/dist/es/types/shape/index.js +9 -0
  101. package/dist/es/types/shape/rect.d.ts +25 -0
  102. package/dist/es/types/shape/rect.js +30 -0
  103. package/dist/es/types/svg/font.d.ts +10 -0
  104. package/dist/es/types/svg/stroke.d.ts +10 -0
  105. package/dist/es/types/tikz/index.d.ts +6 -0
  106. package/dist/es/utils/compare.d.ts +4 -0
  107. package/dist/es/utils/compare.js +20 -0
  108. package/dist/es/utils/css.d.ts +6 -0
  109. package/dist/es/utils/css.js +26 -0
  110. package/dist/es/utils/math.d.ts +9 -0
  111. package/dist/es/utils/math.js +26 -0
  112. package/dist/es/utils/string.d.ts +7 -0
  113. package/dist/es/utils/string.js +7 -0
  114. package/dist/es/utils/style/font.d.ts +17 -0
  115. package/dist/es/utils/style/font.js +34 -0
  116. package/dist/es/utils/style/stroke.d.ts +19 -0
  117. package/dist/es/utils/style/stroke.js +40 -0
  118. package/dist/lib/_virtual/jsx-runtime.cjs +5 -0
  119. package/dist/lib/_virtual/jsx-runtime2.cjs +4 -0
  120. package/dist/lib/_virtual/react-jsx-runtime.development.cjs +4 -0
  121. package/dist/lib/_virtual/react-jsx-runtime.production.cjs +4 -0
  122. package/dist/lib/components/Scope.cjs +10 -0
  123. package/dist/lib/components/Scope.d.ts +6 -0
  124. package/dist/lib/components/TikZ.cjs +12 -0
  125. package/dist/lib/components/TikZ.d.ts +9 -0
  126. package/dist/lib/components/draw/Draw.cjs +34 -0
  127. package/dist/lib/components/draw/Draw.d.ts +18 -0
  128. package/dist/lib/components/draw/InnerDraw.cjs +47 -0
  129. package/dist/lib/components/draw/InnerDraw.d.ts +13 -0
  130. package/dist/lib/components/draw/arrow/index.cjs +10 -0
  131. package/dist/lib/components/draw/arrow/index.d.ts +9 -0
  132. package/dist/lib/components/draw/arrow/stealth.cjs +29 -0
  133. package/dist/lib/components/draw/arrow/stealth.d.ts +7 -0
  134. package/dist/lib/components/draw/arrow/types.d.ts +21 -0
  135. package/dist/lib/components/draw/common.cjs +12 -0
  136. package/dist/lib/components/draw/common.d.ts +4 -0
  137. package/dist/lib/components/draw/index.d.ts +3 -0
  138. package/dist/lib/components/draw/segment/Segment.cjs +41 -0
  139. package/dist/lib/components/draw/segment/Segment.d.ts +12 -0
  140. package/dist/lib/components/draw/segment/index.cjs +41 -0
  141. package/dist/lib/components/draw/segment/index.d.ts +19 -0
  142. package/dist/lib/components/draw/segment/useArrow.cjs +52 -0
  143. package/dist/lib/components/draw/segment/useArrow.d.ts +12 -0
  144. package/dist/lib/components/draw/segment/useConvertWay.cjs +95 -0
  145. package/dist/lib/components/draw/segment/useConvertWay.d.ts +14 -0
  146. package/dist/lib/components/draw/types.d.ts +29 -0
  147. package/dist/lib/components/node/InnerNode.cjs +88 -0
  148. package/dist/lib/components/node/InnerNode.d.ts +33 -0
  149. package/dist/lib/components/node/Node.cjs +87 -0
  150. package/dist/lib/components/node/Node.d.ts +54 -0
  151. package/dist/lib/components/node/_hooks/useNodeConfig.cjs +13 -0
  152. package/dist/lib/components/node/_hooks/useNodeConfig.d.ts +3 -0
  153. package/dist/lib/components/node/_hooks/useNodeContent.cjs +27 -0
  154. package/dist/lib/components/node/_hooks/useNodeContent.d.ts +4 -0
  155. package/dist/lib/components/node/_hooks/useNodeShape.cjs +34 -0
  156. package/dist/lib/components/node/_hooks/useNodeShape.d.ts +4 -0
  157. package/dist/lib/components/node/index.cjs +4 -0
  158. package/dist/lib/components/node/index.d.ts +3 -0
  159. package/dist/lib/components/pathNode/PathNode.cjs +76 -0
  160. package/dist/lib/components/pathNode/PathNode.d.ts +39 -0
  161. package/dist/lib/components/pathNode/index.cjs +4 -0
  162. package/dist/lib/components/pathNode/index.d.ts +3 -0
  163. package/dist/lib/components/pathNode/useAnchor.cjs +49 -0
  164. package/dist/lib/components/pathNode/useAnchor.d.ts +6 -0
  165. package/dist/lib/container/Group.cjs +7 -0
  166. package/dist/lib/container/Group.d.ts +6 -0
  167. package/dist/lib/container/Surface.cjs +23 -0
  168. package/dist/lib/container/Surface.d.ts +17 -0
  169. package/dist/lib/elements/Path.cjs +13 -0
  170. package/dist/lib/elements/Path.d.ts +4 -0
  171. package/dist/lib/elements/Rect.cjs +8 -0
  172. package/dist/lib/elements/Rect.d.ts +6 -0
  173. package/dist/lib/elements/Text.cjs +35 -0
  174. package/dist/lib/elements/Text.d.ts +19 -0
  175. package/dist/lib/hooks/context/useCalculate.cjs +9 -0
  176. package/dist/lib/hooks/context/useCalculate.d.ts +7 -0
  177. package/dist/lib/hooks/context/useNodes.cjs +33 -0
  178. package/dist/lib/hooks/context/useNodes.d.ts +9 -0
  179. package/dist/lib/hooks/context/usePath.cjs +20 -0
  180. package/dist/lib/hooks/context/usePath.d.ts +13 -0
  181. package/dist/lib/hooks/context/useScope.cjs +7 -0
  182. package/dist/lib/hooks/context/useScope.d.ts +11 -0
  183. package/dist/lib/hooks/useForceUpdate.cjs +8 -0
  184. package/dist/lib/hooks/useForceUpdate.d.ts +2 -0
  185. package/dist/lib/index.cjs +12 -0
  186. package/dist/lib/index.d.ts +10 -0
  187. package/dist/lib/model/component/node.cjs +164 -0
  188. package/dist/lib/model/component/node.d.ts +45 -0
  189. package/dist/lib/model/component/path.cjs +47 -0
  190. package/dist/lib/model/component/path.d.ts +19 -0
  191. package/dist/lib/model/equation/line.cjs +75 -0
  192. package/dist/lib/model/equation/line.d.ts +21 -0
  193. package/dist/lib/model/geometry/point/DescartesPoint.cjs +50 -0
  194. package/dist/lib/model/geometry/point/DescartesPoint.d.ts +21 -0
  195. package/dist/lib/model/geometry/point/PolarPoint.cjs +27 -0
  196. package/dist/lib/model/geometry/point/PolarPoint.d.ts +14 -0
  197. package/dist/lib/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.cjs +338 -0
  198. package/dist/lib/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.cjs +13 -0
  199. package/dist/lib/node_modules/.pnpm/d3-path@3.1.0/node_modules/d3-path/src/path.cjs +88 -0
  200. package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/array.cjs +6 -0
  201. package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/constant.cjs +8 -0
  202. package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/linear.cjs +39 -0
  203. package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.cjs +41 -0
  204. package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/path.cjs +19 -0
  205. package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/point.cjs +10 -0
  206. package/dist/lib/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.development.cjs +20 -0
  207. package/dist/lib/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.production.cjs +41 -0
  208. package/dist/lib/node_modules/.pnpm/react@19.0.0/node_modules/react/jsx-runtime.cjs +17 -0
  209. package/dist/lib/types/coordinate/descartes.d.ts +23 -0
  210. package/dist/lib/types/coordinate/index.d.ts +5 -0
  211. package/dist/lib/types/coordinate/polar.d.ts +5 -0
  212. package/dist/lib/types/distance/index.d.ts +8 -0
  213. package/dist/lib/types/distance/sep.d.ts +9 -0
  214. package/dist/lib/types/shape/index.cjs +9 -0
  215. package/dist/lib/types/shape/index.d.ts +8 -0
  216. package/dist/lib/types/shape/rect.cjs +30 -0
  217. package/dist/lib/types/shape/rect.d.ts +25 -0
  218. package/dist/lib/types/svg/font.d.ts +10 -0
  219. package/dist/lib/types/svg/stroke.d.ts +10 -0
  220. package/dist/lib/types/tikz/index.d.ts +6 -0
  221. package/dist/lib/utils/compare.cjs +20 -0
  222. package/dist/lib/utils/compare.d.ts +4 -0
  223. package/dist/lib/utils/css.cjs +26 -0
  224. package/dist/lib/utils/css.d.ts +6 -0
  225. package/dist/lib/utils/math.cjs +26 -0
  226. package/dist/lib/utils/math.d.ts +9 -0
  227. package/dist/lib/utils/string.cjs +7 -0
  228. package/dist/lib/utils/string.d.ts +7 -0
  229. package/dist/lib/utils/style/font.cjs +34 -0
  230. package/dist/lib/utils/style/font.d.ts +17 -0
  231. package/dist/lib/utils/style/stroke.cjs +40 -0
  232. package/dist/lib/utils/style/stroke.d.ts +19 -0
  233. package/package.json +57 -0
@@ -0,0 +1,17 @@
1
+ import { __module as jsxRuntime } from "../../../../../_virtual/jsx-runtime2.js";
2
+ import { __require as requireReactJsxRuntime_production } from "./cjs/react-jsx-runtime.production.js";
3
+ import { __require as requireReactJsxRuntime_development } from "./cjs/react-jsx-runtime.development.js";
4
+ var hasRequiredJsxRuntime;
5
+ function requireJsxRuntime() {
6
+ if (hasRequiredJsxRuntime) return jsxRuntime.exports;
7
+ hasRequiredJsxRuntime = 1;
8
+ if (true) {
9
+ jsxRuntime.exports = requireReactJsxRuntime_production();
10
+ } else {
11
+ jsxRuntime.exports = requireReactJsxRuntime_development();
12
+ }
13
+ return jsxRuntime.exports;
14
+ }
15
+ export {
16
+ requireJsxRuntime as __require
17
+ };
@@ -0,0 +1,23 @@
1
+ /** 笛卡尔象限 */
2
+ export declare enum Quadrant {
3
+ TR = "top_right",// 第一象限
4
+ TL = "top_left",// 第二象限
5
+ BL = "bottom_left",// 第三象限
6
+ BR = "bottom_right"
7
+ }
8
+ /** 笛卡尔坐标轴 */
9
+ export declare enum Axis {
10
+ X_POS = "x-positive",// 正x轴
11
+ Y_POS = "y-positive",// 正y轴
12
+ X_NEG = "x-negative",// 负x轴
13
+ Y_NEG = "y-negative"
14
+ }
15
+ /** 笛卡尔坐标系位置 */
16
+ export type DescartesLocation = Quadrant | Axis | 'center';
17
+ /** 笛卡尔坐标 */
18
+ export type Position = [number, number];
19
+ /** 笛卡尔坐标(对象形式) */
20
+ export type DescartesPosition = {
21
+ x: number;
22
+ y: number;
23
+ };
@@ -0,0 +1,5 @@
1
+ import { DescartesPosition, Position } from './descartes';
2
+ import { PolarPosition } from './polar';
3
+ /** 点坐标的多种类型 */
4
+ export type PointPosition = Position | DescartesPosition | PolarPosition;
5
+ export type Direction = 'top' | 'bottom' | 'left' | 'right';
@@ -0,0 +1,5 @@
1
+ /** 笛卡尔坐标(对象形式) */
2
+ export type PolarPosition = {
3
+ radius: number;
4
+ angle: number;
5
+ };
@@ -0,0 +1,8 @@
1
+ export type CssDistanceType = number | string | undefined;
2
+ /** 四个方向的距离 */
3
+ export type DirectionDistance<T = number> = {
4
+ left: T;
5
+ right: T;
6
+ top: T;
7
+ bottom: T;
8
+ };
@@ -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,8 @@
1
+ /** 几何体范围:内部,外部,边界线上 */
2
+ export declare enum Area {
3
+ INSIDE = "inside",
4
+ OUTSIDE = "outside",
5
+ EDGE = "edge"
6
+ }
7
+ /** 宽高 */
8
+ export type Size = [number, number];
@@ -0,0 +1,9 @@
1
+ var Area = /* @__PURE__ */ ((Area2) => {
2
+ Area2["INSIDE"] = "inside";
3
+ Area2["OUTSIDE"] = "outside";
4
+ Area2["EDGE"] = "edge";
5
+ return Area2;
6
+ })(Area || {});
7
+ export {
8
+ Area
9
+ };
@@ -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,30 @@
1
+ var RectVertexPoint = /* @__PURE__ */ ((RectVertexPoint2) => {
2
+ RectVertexPoint2["TL"] = "top_left";
3
+ RectVertexPoint2["TR"] = "top_right";
4
+ RectVertexPoint2["BL"] = "bottom_left";
5
+ RectVertexPoint2["BR"] = "bottom_right";
6
+ return RectVertexPoint2;
7
+ })(RectVertexPoint || {});
8
+ var RectMidPoint = /* @__PURE__ */ ((RectMidPoint2) => {
9
+ RectMidPoint2["T"] = "top_mid";
10
+ RectMidPoint2["B"] = "bottom_mid";
11
+ RectMidPoint2["L"] = "left_mid";
12
+ RectMidPoint2["R"] = "right_mid";
13
+ return RectMidPoint2;
14
+ })(RectMidPoint || {});
15
+ var RectThirdPoint = /* @__PURE__ */ ((RectThirdPoint2) => {
16
+ RectThirdPoint2["TL"] = "third_top_left";
17
+ RectThirdPoint2["TR"] = "third_top_right";
18
+ RectThirdPoint2["BL"] = "third_bottom_left";
19
+ RectThirdPoint2["BR"] = "third_bottom_right";
20
+ RectThirdPoint2["LT"] = "third_left_top";
21
+ RectThirdPoint2["LB"] = "third_left_bottom";
22
+ RectThirdPoint2["RT"] = "third_right_top";
23
+ RectThirdPoint2["RB"] = "third_right_bottom";
24
+ return RectThirdPoint2;
25
+ })(RectThirdPoint || {});
26
+ export {
27
+ RectMidPoint,
28
+ RectThirdPoint,
29
+ RectVertexPoint
30
+ };
@@ -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,6 @@
1
+ import { Ref } from 'react';
2
+ export type TikZKey = string;
3
+ export type TikZProps = {
4
+ name?: TikZKey;
5
+ ref?: Ref<SVGGElement>;
6
+ };
@@ -0,0 +1,4 @@
1
+ /** 判断两个数组内容是否相同 */
2
+ export declare const isSameArray: (arr1: unknown[], arr2: unknown[]) => boolean;
3
+ /** 判断两个对象是否相同 */
4
+ export declare const isSameObj: (obj1: Record<string, unknown>, obj2: Record<string, unknown>) => boolean;
@@ -0,0 +1,20 @@
1
+ const isSameArray = (arr1, arr2) => {
2
+ if (arr1.length !== arr2.length) return false;
3
+ const length = arr1.length;
4
+ for (let i = 0; i < length; i++) {
5
+ if (arr1[i] !== arr2[i]) return false;
6
+ }
7
+ return true;
8
+ };
9
+ const isSameObj = (obj1, obj2) => {
10
+ if (Object.keys(obj1).length !== Object.keys(obj2).length) return false;
11
+ const keys = Object.keys(obj1);
12
+ for (let i = 0; i < keys.length; i++) {
13
+ if (obj1[keys[i]] !== obj2[keys[i]]) return false;
14
+ }
15
+ return true;
16
+ };
17
+ export {
18
+ isSameArray,
19
+ isSameObj
20
+ };
@@ -0,0 +1,6 @@
1
+ /** 将 CSS 长度转换为像素 */
2
+ export declare const convertCssToPx: (dimension?: string | number, sizeConfig?: {
3
+ remPx?: number;
4
+ emPx?: number;
5
+ parentPx?: number;
6
+ }) => number;
@@ -0,0 +1,26 @@
1
+ const convertCssToPx = (dimension, sizeConfig) => {
2
+ if (dimension === void 0) return 0;
3
+ if (typeof dimension === "number") return dimension;
4
+ const match = dimension.match(/^(\d+(?:\.\d+)?)(px|em|rem|%)$/);
5
+ const { remPx: remSize = 16, emPx: emSize = 16, parentPx: elementSize = 100 } = sizeConfig || {};
6
+ if (match) {
7
+ const value = parseFloat(match[1]);
8
+ const unit = match[2];
9
+ switch (unit) {
10
+ case "px":
11
+ return value;
12
+ case "em":
13
+ return value * (emSize || remSize || 16);
14
+ case "rem":
15
+ return value * (remSize || 16);
16
+ case "%":
17
+ return elementSize ? value / 100 * elementSize : value;
18
+ default:
19
+ return 0;
20
+ }
21
+ }
22
+ return parseInt(dimension);
23
+ };
24
+ export {
25
+ convertCssToPx
26
+ };
@@ -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,26 @@
1
+ const between = (value, range, equal) => {
2
+ return equal ? value >= range[0] && value <= range[1] : value > range[0] && value < range[1];
3
+ };
4
+ const convertPrecision = (value, precision, deep = true) => {
5
+ if (precision === false) return value;
6
+ const innerConvert = (value2) => {
7
+ if (precision === 0) return Math.round(value2);
8
+ const realPrecision = 10 ** precision;
9
+ return Math.round(value2 * realPrecision) / realPrecision;
10
+ };
11
+ if (typeof value === "number") return innerConvert(value);
12
+ if (Array.isArray(value))
13
+ return value.map((item) => deep ? innerConvert(item) : typeof item === "number" ? innerConvert(item) : item);
14
+ if (typeof value === "object" && value !== null) {
15
+ const result = {};
16
+ for (const [key, item] of Object.entries(value)) {
17
+ result[key] = deep ? convertPrecision(item, precision) : typeof item === "number" ? innerConvert(item) : item;
18
+ }
19
+ return result;
20
+ }
21
+ return value;
22
+ };
23
+ export {
24
+ between,
25
+ convertPrecision
26
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 文本换行解析器,将文本根据特定字符分割成数组
3
+ * 默认的换行标识为:\n
4
+ * @param text 原始文本
5
+ * @param breakMark 换行标识
6
+ */
7
+ export declare const textWrapParse: (text: string, breakMark?: string) => string[];
@@ -0,0 +1,7 @@
1
+ const textWrapParse = (text, breakMark = "\\n") => {
2
+ const textArray = text.split(breakMark);
3
+ return textArray;
4
+ };
5
+ export {
6
+ textWrapParse
7
+ };
@@ -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,34 @@
1
+ const TikZFontSizeMap = {
2
+ tiny: "5px",
3
+ script: "8px",
4
+ footnote: "10px",
5
+ small: "12px",
6
+ normal: "16px",
7
+ large: "18px",
8
+ Large: "22px",
9
+ LARGE: "26px",
10
+ huge: "30px",
11
+ Huge: "36px"
12
+ };
13
+ const convertFontSize = (fontSize) => {
14
+ return typeof fontSize === "string" && TikZFontSizeMap.hasOwnProperty(fontSize) ? TikZFontSizeMap[fontSize] : fontSize;
15
+ };
16
+ const convertFontStyle = (fontStyle) => {
17
+ switch (fontStyle) {
18
+ case "bold":
19
+ return { fontWeight: "bold" };
20
+ case "italic":
21
+ return { fontStyle: "italic" };
22
+ case "serif":
23
+ return { fontFamily: "serif" };
24
+ case "sans-serif":
25
+ return { fontFamily: "sans-serif" };
26
+ default:
27
+ return {};
28
+ }
29
+ };
30
+ export {
31
+ TikZFontSizeMap,
32
+ convertFontSize,
33
+ convertFontStyle
34
+ };
@@ -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>;
@@ -0,0 +1,40 @@
1
+ const convertStrokeType = (strokeType, strokeWidth = 1) => {
2
+ switch (strokeType) {
3
+ case "solid":
4
+ return {};
5
+ case "dashed":
6
+ return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 4}` };
7
+ case "denselyDashed":
8
+ return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 2}` };
9
+ case "looselyDashed":
10
+ return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 6}` };
11
+ case "dotted":
12
+ return { strokeDasharray: `1 ${strokeWidth * 4}` };
13
+ case "denselyDotted":
14
+ return { strokeDasharray: `1 ${strokeWidth * 2}` };
15
+ case "looselyDotted":
16
+ return { strokeDasharray: `1 ${strokeWidth * 6}` };
17
+ case "dashDot":
18
+ return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 4} 1 ${strokeWidth * 4}` };
19
+ case "denselyDashDot":
20
+ return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 2} 1 ${strokeWidth * 2}` };
21
+ case "looselyDashDot":
22
+ return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 6} 1 ${strokeWidth * 6}` };
23
+ case "dashDashDot":
24
+ return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 4} 1 ${strokeWidth * 4} 1 ${strokeWidth * 4}` };
25
+ case "denselyDashDashDot":
26
+ return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 2} 1 ${strokeWidth * 2} 1 ${strokeWidth * 2}` };
27
+ case "looselyDashDashDot":
28
+ return { strokeDasharray: `${strokeWidth * 4} ${strokeWidth * 6} 1 ${strokeWidth * 6} 1 ${strokeWidth * 6}` };
29
+ }
30
+ };
31
+ const convertStrokeShortcut = (shortcutProps, strokeWidth = 1) => {
32
+ return convertStrokeType(
33
+ shortcutProps.dashed ? "dashed" : shortcutProps.denselyDashed ? "denselyDashed" : shortcutProps.looselyDashed ? "looselyDashed" : shortcutProps.dotted ? "dotted" : shortcutProps.denselyDotted ? "denselyDotted" : shortcutProps.looselyDotted ? "looselyDotted" : shortcutProps.dashDot ? "dashDot" : shortcutProps.denselyDashDot ? "denselyDashDot" : shortcutProps.looselyDashDot ? "looselyDashDot" : shortcutProps.dashDashDot ? "dashDashDot" : shortcutProps.denselyDashDashDot ? "denselyDashDashDot" : shortcutProps.looselyDashDashDot ? "looselyDashDashDot" : "solid",
34
+ strokeWidth || 1
35
+ );
36
+ };
37
+ export {
38
+ convertStrokeShortcut,
39
+ convertStrokeType
40
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("../node_modules/.pnpm/react@19.0.0/node_modules/react/jsx-runtime.cjs");
4
+ var jsxRuntimeExports = jsxRuntime.__require();
5
+ exports.jsxRuntimeExports = jsxRuntimeExports;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ var jsxRuntime = { exports: {} };
4
+ exports.__module = jsxRuntime;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ var reactJsxRuntime_development = {};
4
+ exports.__exports = reactJsxRuntime_development;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ var reactJsxRuntime_production = {};
4
+ exports.__exports = reactJsxRuntime_production;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const jsxRuntime = require("../_virtual/jsx-runtime.cjs");
4
+ const useScope = require("../hooks/context/useScope.cjs");
5
+ const Group = require("../container/Group.cjs");
6
+ const Scope = (props) => {
7
+ const { children, ref, ...resProps } = props;
8
+ return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useScope.ScopeContext, { value: resProps, children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(Group.default, { ref, children }) });
9
+ };
10
+ exports.default = Scope;
@@ -0,0 +1,6 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ import { ScopeProps as ScopeContextProps } from '../hooks/context/useScope';
3
+ import { GroupProps } from '../container/Group';
4
+ export type ScopeProps = ScopeContextProps & Omit<GroupProps, 'offset'>;
5
+ declare const Scope: FC<PropsWithChildren<ScopeProps>>;
6
+ export default Scope;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const jsxRuntime = require("../_virtual/jsx-runtime.cjs");
4
+ const Surface = require("../container/Surface.cjs");
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 TikZ = (props) => {
9
+ const { precision = 2, offset, node, draw, ...resProps } = props;
10
+ return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useNodes.NodesContext, { value: /* @__PURE__ */ new Map(), children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useCalculate.CalculateContext, { value: { precision }, children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useScope.ScopeContext, { value: { offset, node, draw }, children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(Surface.default, { ...resProps }) }) }) });
11
+ };
12
+ exports.default = TikZ;
@@ -0,0 +1,9 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { SurfaceProps } from '../container/Surface';
3
+ import { CalculateProps } from '../hooks/context/useCalculate';
4
+ import { ScopeProps } from '../hooks/context/useScope';
5
+ export type TikZProps = {
6
+ children: ReactNode;
7
+ } & Partial<CalculateProps> & ScopeProps & SurfaceProps;
8
+ declare const TikZ: FC<TikZProps>;
9
+ export default TikZ;
@@ -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 useScope = require("../../hooks/context/useScope.cjs");
5
+ const DescartesPoint = require("../../model/geometry/point/DescartesPoint.cjs");
6
+ const stroke = require("../../utils/style/stroke.cjs");
7
+ const InnerDraw = require("./InnerDraw.cjs");
8
+ const Draw = (props) => {
9
+ const { draw: scopeProps } = useScope.default();
10
+ const realProps = { ...scopeProps, ...props };
11
+ const { offset, color, stroke: stroke$1, strokeWidth, startArrow, startArrows, endArrow, endArrows, ...drawProps } = realProps;
12
+ const realStroke = stroke$1 || color;
13
+ const realStartArrow = typeof startArrow === "string" ? { type: startArrow } : startArrow;
14
+ const realStartArrows = typeof startArrows === "string" ? { type: startArrows } : startArrows;
15
+ const realEndArrow = typeof endArrow === "string" ? { type: endArrow } : endArrow;
16
+ const realEndArrows = typeof endArrows === "string" ? { type: endArrows } : endArrows;
17
+ const convertOffset = offset ? DescartesPoint.default.formatPosition(offset) : [0, 0];
18
+ const getStrokeTypes = () => drawProps.strokeType ? stroke.convertStrokeType(drawProps.strokeType, strokeWidth || 1) : stroke.convertStrokeShortcut(drawProps, strokeWidth || 1);
19
+ return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
20
+ InnerDraw.default,
21
+ {
22
+ ...getStrokeTypes(),
23
+ offset: convertOffset,
24
+ stroke: realStroke,
25
+ strokeWidth: strokeWidth || 1,
26
+ startArrow: realStartArrow,
27
+ startArrows: realStartArrows,
28
+ endArrow: realEndArrow,
29
+ endArrows: realEndArrows,
30
+ ...drawProps
31
+ }
32
+ );
33
+ };
34
+ exports.default = Draw;
@@ -0,0 +1,18 @@
1
+ import { FC, ReactElement, Ref } from 'react';
2
+ import { PointPosition } from '../../types/coordinate';
3
+ import { StrokeProps } from '../../types/svg/stroke';
4
+ import { StrokeShortcutProps, StrokeType } from '../../utils/style/stroke';
5
+ import { ArrowProps, DrawWayType } from './types';
6
+ export type DrawProps = {
7
+ ref?: Ref<SVGPathElement>;
8
+ way: DrawWayType[];
9
+ /** 位置偏移 */
10
+ offset?: PointPosition;
11
+ /** 同 stroke */
12
+ color?: string;
13
+ /** 线段样式快捷属性 */
14
+ strokeType?: StrokeType;
15
+ children?: ReactElement | ReactElement[] | null;
16
+ } & StrokeProps & StrokeShortcutProps & ArrowProps;
17
+ declare const Draw: FC<DrawProps>;
18
+ export default Draw;
@@ -0,0 +1,47 @@
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 Group = require("../../container/Group.cjs");
6
+ const usePath = require("../../hooks/context/usePath.cjs");
7
+ const path = require("../../model/component/path.cjs");
8
+ const common = require("./common.cjs");
9
+ const index = require("./segment/index.cjs");
10
+ const InnerDraw = (props) => {
11
+ const { way, ref, offset, startArrow, startArrows, endArrow, endArrows, children, ...strokeProps } = props;
12
+ const waySegments = require$$0.useMemo(() => {
13
+ let preNodeType = "coordinate";
14
+ const waySegments2 = [];
15
+ let waySegment = [];
16
+ for (let i = 0; i < way.length; i++) {
17
+ const point = way[i];
18
+ const currentNodeType = common.getDrawPointType(point);
19
+ waySegment.push(point);
20
+ if (currentNodeType === "node" && preNodeType === "node" && waySegment.length >= 2) {
21
+ waySegments2.push(waySegment);
22
+ waySegment = [waySegment[waySegment.length - 1]];
23
+ }
24
+ if (i === way.length - 1 && waySegment.length > 1) {
25
+ waySegments2.push(waySegment);
26
+ }
27
+ preNodeType = currentNodeType;
28
+ }
29
+ return waySegments2;
30
+ }, [way]);
31
+ return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(usePath.PathContext, { value: new path.default(new Array(waySegments.length).fill([]), strokeProps.strokeWidth || 1, false), children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(Group.default, { ref, transform: `translate(${offset[0]}, ${offset[1]})`, children: [
32
+ waySegments.map((segment, index$1) => /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
33
+ index.default,
34
+ {
35
+ index: index$1,
36
+ isLastSegment: index$1 === waySegments.length - 1,
37
+ way: segment,
38
+ ...strokeProps,
39
+ endArrow: index$1 === waySegments.length - 1 ? endArrow || endArrows : endArrows,
40
+ startArrow: index$1 === waySegments.length - 1 ? startArrow || startArrows : startArrows
41
+ },
42
+ JSON.stringify(segment)
43
+ )),
44
+ children
45
+ ] }) });
46
+ };
47
+ exports.default = InnerDraw;
@@ -0,0 +1,13 @@
1
+ import { FC, ReactNode, Ref } from 'react';
2
+ import { Position } from '../../types/coordinate/descartes';
3
+ import { StrokeProps } from '../../types/svg/stroke';
4
+ import { ArrowConfig, ArrowProps, DrawWayType } from './types';
5
+ export type InnerDrawProps = {
6
+ ref?: Ref<SVGPathElement>;
7
+ /** 位置偏移 */
8
+ offset: Position;
9
+ way: DrawWayType[];
10
+ children?: ReactNode;
11
+ } & StrokeProps & ArrowProps<ArrowConfig>;
12
+ declare const InnerDraw: FC<InnerDrawProps>;
13
+ export default InnerDraw;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const stealth = require("./stealth.cjs");
4
+ const getArrowPath = (type, attributes) => {
5
+ switch (type) {
6
+ case "Stealth":
7
+ return stealth.default(attributes);
8
+ }
9
+ };
10
+ exports.default = getArrowPath;
@@ -0,0 +1,9 @@
1
+ import { ArrowAttributes, ArrowPathConfig } from './types';
2
+ export type { ArrowAttributes as ArrowPositionAttributes, ArrowPathConfig };
3
+ export type ArrowType = 'Stealth';
4
+ declare const getArrowPath: (type: ArrowType, attributes: ArrowAttributes) => {
5
+ d: string;
6
+ offsetDistance: number;
7
+ insertDistance: number;
8
+ };
9
+ export default getArrowPath;