@canmingir/link 1.2.59 → 1.2.61

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canmingir/link",
3
- "version": "1.2.59",
3
+ "version": "1.2.61",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "bin": {
@@ -40,7 +40,7 @@ export default function NavList({ data, depth, slotProps }) {
40
40
  open={openMenu}
41
41
  onMouseEnter={handleOpenMenu}
42
42
  onMouseLeave={handleCloseMenu}
43
- title={data.title}
43
+ title={data.compactTitle ?? data.title}
44
44
  path={data.path}
45
45
  icon={data.icon}
46
46
  info={data.info}
@@ -55,6 +55,7 @@ export const MenuConfigSchema = Joi.object({
55
55
  .items(
56
56
  Joi.object({
57
57
  title: Joi.string().required(),
58
+ compactTitle: Joi.string().optional(),
58
59
  icon: Joi.string().required(),
59
60
  path: Joi.string().required(),
60
61
  external: Joi.boolean().optional().default(false),
@@ -26,6 +26,8 @@ const DynamicConnector = ({
26
26
  labelPosition = 0.5,
27
27
  labelOffsetX = 0,
28
28
  labelOffsetY = -10,
29
+ startGap = 8,
30
+ endGap = 10,
29
31
  }) => {
30
32
  const uniqueId = useId();
31
33
  const [dims, setDims] = useState(null);
@@ -53,32 +55,38 @@ const DynamicConnector = ({
53
55
  let parentPoint;
54
56
  let childPoints = [];
55
57
 
58
+ const headRoom = showArrow ? arrowSize * strokeWidth * 0.5 : 0;
59
+ const tailInset = startGap;
60
+ const headInset = endGap + headRoom;
61
+
56
62
  if (isHorizontal) {
57
63
  parentPoint = {
58
- x: (pRect.right - cRect.left) / scaleX,
64
+ x: (pRect.right - cRect.left) / scaleX + tailInset,
59
65
  y: (pRect.top + pRect.height / 2 - cRect.top) / scaleY,
60
66
  };
61
67
 
62
68
  childPoints = childEls.map((el) => {
63
69
  if (!el) return { x: parentPoint.x + 100, y: parentPoint.y };
64
70
  const r = el.getBoundingClientRect();
71
+ const x = (r.left - cRect.left) / scaleX - headInset;
65
72
  return {
66
- x: (r.left - cRect.left) / scaleX,
73
+ x: Math.max(x, parentPoint.x),
67
74
  y: (r.top + r.height / 2 - cRect.top) / scaleY,
68
75
  };
69
76
  });
70
77
  } else {
71
78
  parentPoint = {
72
79
  x: (pRect.left + pRect.width / 2 - cRect.left) / scaleX,
73
- y: (pRect.bottom - cRect.top) / scaleY,
80
+ y: (pRect.bottom - cRect.top) / scaleY + tailInset,
74
81
  };
75
82
 
76
83
  childPoints = childEls.map((el) => {
77
84
  if (!el) return { x: parentPoint.x, y: parentPoint.y + 100 };
78
85
  const r = el.getBoundingClientRect();
86
+ const y = (r.top - cRect.top) / scaleY - headInset;
79
87
  return {
80
88
  x: (r.left + r.width / 2 - cRect.left) / scaleX,
81
- y: (r.top - cRect.top) / scaleY,
89
+ y: Math.max(y, parentPoint.y),
82
90
  };
83
91
  });
84
92
  }
@@ -95,7 +103,18 @@ const DynamicConnector = ({
95
103
  childEls.forEach((el) => el && ro.observe(el));
96
104
 
97
105
  return () => ro.disconnect();
98
- }, [containerEl, parentEl, childEls, tick, isHorizontal]);
106
+ }, [
107
+ containerEl,
108
+ parentEl,
109
+ childEls,
110
+ tick,
111
+ isHorizontal,
112
+ showArrow,
113
+ arrowSize,
114
+ strokeWidth,
115
+ startGap,
116
+ endGap,
117
+ ]);
99
118
 
100
119
  const ids = useMemo(
101
120
  () => ({
@@ -189,15 +208,18 @@ const DynamicConnector = ({
189
208
  <marker
190
209
  id={ids.arrow}
191
210
  viewBox="0 0 10 10"
192
- refX="9"
211
+ refX="10"
193
212
  refY="5"
194
213
  markerWidth={arrowSize}
195
214
  markerHeight={arrowSize}
196
215
  orient="auto-start-reverse"
197
216
  >
198
217
  <path
199
- d="M 0 0 L 10 5 L 0 10 z"
218
+ d="M 0.5 1 L 10 5 L 0.5 9 Z"
200
219
  fill={gradient ? `url(#${ids.gradient})` : stroke}
220
+ stroke={gradient ? `url(#${ids.gradient})` : stroke}
221
+ strokeWidth="1"
222
+ strokeLinejoin="round"
201
223
  />
202
224
  </marker>
203
225
  )}
@@ -209,15 +231,6 @@ const DynamicConnector = ({
209
231
  const pathD = getPath(points.parent, child);
210
232
  const pathStroke = gradient ? `url(#${ids.gradient})` : stroke;
211
233
 
212
- const labelX =
213
- points.parent.x +
214
- (child.x - points.parent.x) * labelPosition +
215
- labelOffsetX;
216
- const labelY =
217
- points.parent.y +
218
- (child.y - points.parent.y) * labelPosition +
219
- labelOffsetY;
220
-
221
234
  return (
222
235
  <g key={i}>
223
236
  <path
@@ -226,7 +239,7 @@ const DynamicConnector = ({
226
239
  stroke={pathStroke}
227
240
  strokeWidth={strokeWidth}
228
241
  strokeDasharray={animated ? "8,4" : dashArray}
229
- strokeLinecap="round"
242
+ strokeLinecap={dashArray || animated ? "round" : "butt"}
230
243
  strokeLinejoin="round"
231
244
  markerEnd={showArrow ? `url(#${ids.arrow})` : undefined}
232
245
  style={{
@@ -258,24 +271,25 @@ const DynamicConnector = ({
258
271
  }}
259
272
  />
260
273
 
261
- {points.children.map((child, i) => {
262
- const dotFill = gradient ? gradient.to : effectiveDotColor;
263
-
264
- return (
265
- <circle
266
- key={i}
267
- cx={child.x}
268
- cy={child.y}
269
- r={dotRadius}
270
- fill={dotFill}
271
- stroke="#fff"
272
- strokeWidth={1.5}
273
- style={{
274
- filter: "drop-shadow(0 1px 2px rgba(0,0,0,0.15))",
275
- }}
276
- />
277
- );
278
- })}
274
+ {!showArrow &&
275
+ points.children.map((child, i) => {
276
+ const dotFill = gradient ? gradient.to : effectiveDotColor;
277
+
278
+ return (
279
+ <circle
280
+ key={i}
281
+ cx={child.x}
282
+ cy={child.y}
283
+ r={dotRadius}
284
+ fill={dotFill}
285
+ stroke="#fff"
286
+ strokeWidth={1.5}
287
+ style={{
288
+ filter: "drop-shadow(0 1px 2px rgba(0,0,0,0.15))",
289
+ }}
290
+ />
291
+ );
292
+ })}
279
293
  </>
280
294
  )}
281
295
  </svg>
@@ -1,3 +1,5 @@
1
+ import React, { useEffect, useLayoutEffect, useRef, useState } from "react";
2
+
1
3
  import { Box } from "@mui/material";
2
4
  import DefaultNodeCard from "./DefaultCard";
3
5
  import DraggableNode from "./DraggableNode";
@@ -7,8 +9,6 @@ import { getContentParts } from "../utils/flowUtils";
7
9
  import { toPxNumber } from "../styles";
8
10
  import { useNodeStyle } from "../hooks/useNodeStyle";
9
11
 
10
- import React, { useEffect, useLayoutEffect, useRef, useState } from "react";
11
-
12
12
  const FlowNodeView = ({
13
13
  node,
14
14
  type,
@@ -59,6 +59,8 @@ const FlowNodeView = ({
59
59
  gradient = baseStyle.gradient ?? null,
60
60
  curvature = baseStyle.curvature ?? 0.5,
61
61
  connectorType = baseStyle.connectorType ?? "curved",
62
+ startGap = baseStyle.startGap ?? 8,
63
+ endGap = baseStyle.endGap ?? 10,
62
64
  selectionColor = baseStyle.selectionColor ?? "#64748b",
63
65
  } = nodeStyle;
64
66
 
@@ -76,6 +78,8 @@ const FlowNodeView = ({
76
78
  gradient: edgeStyle.gradient ?? gradient,
77
79
  curvature: edgeStyle.curvature ?? curvature,
78
80
  connectorType: edgeStyle.connectorType ?? connectorType,
81
+ startGap: edgeStyle.startGap ?? startGap,
82
+ endGap: edgeStyle.endGap ?? endGap,
79
83
  };
80
84
 
81
85
  const isHorizontal = direction === "horizontal";
@@ -241,6 +245,9 @@ const FlowNodeView = ({
241
245
  connectorType:
242
246
  childSpecificStyle.connectorType ??
243
247
  childEdgeProps.connectorType,
248
+ startGap:
249
+ childSpecificStyle.startGap ?? childEdgeProps.startGap,
250
+ endGap: childSpecificStyle.endGap ?? childEdgeProps.endGap,
244
251
  label: childSpecificStyle.label,
245
252
  labelStyle: childSpecificStyle.labelStyle,
246
253
  labelPosition: childSpecificStyle.labelPosition,
@@ -278,6 +285,8 @@ const FlowNodeView = ({
278
285
  gradient={childEdgeProps.gradient}
279
286
  curvature={childEdgeProps.curvature}
280
287
  connectorType={childEdgeProps.connectorType}
288
+ startGap={childEdgeProps.startGap}
289
+ endGap={childEdgeProps.endGap}
281
290
  label={childEdgeProps.label}
282
291
  labelStyle={childEdgeProps.labelStyle}
283
292
  labelPosition={childEdgeProps.labelPosition}