@krainovsd/graph 0.11.0-beta.1 → 0.11.0-beta.2
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/lib/cjs/index.cjs +0 -2
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js +0 -1
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/link-by-pointer-getter.js +0 -1
- package/lib/esm/module/GraphCanvas/lib/utils/link-by-pointer-getter.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/package.json +10 -10
|
@@ -2,7 +2,6 @@ import { COMMON_SETTINGS } from '../../constants/common-settings.js';
|
|
|
2
2
|
import '@krainovsd/js-helpers';
|
|
3
3
|
import 'd3-array';
|
|
4
4
|
|
|
5
|
-
/* eslint-disable id-length */
|
|
6
5
|
function calculateLinkPositionByNode(link, arrowSize = 0) {
|
|
7
6
|
const source = link.source;
|
|
8
7
|
const target = link.target;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-link-position-by-node.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/calculate-link-position-by-node.ts"],"sourcesContent":["/* eslint-disable id-length */\nimport { COMMON_SETTINGS } from \"../../constants\";\nimport type { LinkInterface, NodeInterface } from \"../../types\";\n\ntype Point = {\n x: number;\n y: number;\n};\n\nexport function calculateLinkPositionByNode<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(link: LinkInterface<NodeData, LinkData>, arrowSize = 0) {\n const source = link.source;\n const target = link.target;\n\n if (typeof source != \"object\" || typeof target != \"object\") return null;\n\n const sourcePoint = getLinkPoint({\n arrowSize: 0,\n node: source,\n oppositeNode: target,\n });\n const targetPoint = getLinkPoint({\n arrowSize: arrowSize > 0 ? arrowSize * 0.85 : 0,\n node: target,\n oppositeNode: source,\n });\n\n if (!sourcePoint || !targetPoint) return null;\n\n const distance =\n targetPoint && sourcePoint\n ? Math.sqrt((targetPoint.x - sourcePoint.x) ** 2 + (targetPoint.y - sourcePoint.y) ** 2)\n : 0;\n\n return {\n x1: sourcePoint.x,\n y1: sourcePoint.y,\n x2: targetPoint.x,\n y2: targetPoint.y,\n distance,\n };\n}\n\ntype GetLinkPointProps<NodeData extends Record<string, unknown>> = {\n arrowSize: number;\n node: NodeInterface<NodeData>;\n oppositeNode: NodeInterface<NodeData>;\n};\nfunction getLinkPoint<NodeData extends Record<string, unknown>>(opts: GetLinkPointProps<NodeData>) {\n if (\n opts.node.x == undefined ||\n opts.node.y == undefined ||\n opts.oppositeNode.x == undefined ||\n opts.oppositeNode.y == undefined\n )\n return null;\n\n let nodePoint: Point;\n switch (opts.node._shape) {\n case \"circle\": {\n nodePoint = getCircleIntersection({\n x: opts.node.x,\n y: opts.node.y,\n radius:\n (opts.node._radius ?? COMMON_SETTINGS.nodeRadius) +\n (opts.node._borderWidth ? opts.node._borderWidth / 2 : 0),\n oppositeX: opts.oppositeNode.x,\n oppositeY: opts.oppositeNode.y,\n arrowSize: opts.arrowSize,\n });\n break;\n }\n case \"square\":\n case \"text\": {\n nodePoint = getRectangleIntersection({\n arrowSize: opts.arrowSize,\n x: opts.node.x,\n y: opts.node.y,\n height: (opts.node._height ?? COMMON_SETTINGS.nodeSize) + (opts.node._borderWidth ?? 0),\n width: (opts.node._width ?? COMMON_SETTINGS.nodeSize) + (opts.node._borderWidth ?? 0),\n oppositeX: opts.oppositeNode.x,\n oppositeY: opts.oppositeNode.y,\n borderRadius: opts.node._shape === \"text\" ? 0 : (opts.node._borderRadius ?? 0),\n });\n break;\n }\n default: {\n nodePoint = getCircleIntersection({\n x: opts.node.x,\n y: opts.node.y,\n radius: opts.node._radius ?? COMMON_SETTINGS.nodeRadius,\n oppositeX: opts.oppositeNode.x,\n oppositeY: opts.oppositeNode.y,\n arrowSize: opts.arrowSize,\n });\n }\n }\n\n return nodePoint;\n}\n\ntype GetCircleIntersection = {\n x: number;\n y: number;\n radius: number;\n oppositeX: number;\n oppositeY: number;\n arrowSize: number;\n};\n\nfunction getCircleIntersection(opts: GetCircleIntersection): Point {\n const dx = opts.oppositeX - opts.x;\n const dy = opts.oppositeY - opts.y;\n const dr = Math.sqrt(dx * dx + dy * dy);\n\n const radius = opts.radius + opts.arrowSize;\n\n return {\n x: opts.x + (dx * radius) / dr,\n y: opts.y + (dy * radius) / dr,\n };\n}\n\ntype GetRectangleIntersection = {\n x: number;\n y: number;\n width: number;\n height: number;\n oppositeX: number;\n oppositeY: number;\n arrowSize: number;\n borderRadius: number;\n};\n\nfunction getRectangleIntersection(opts: GetRectangleIntersection): Point {\n const halfWidth = opts.width / 2;\n const halfHeight = opts.height / 2;\n\n const dx = opts.oppositeX - opts.x;\n const dy = opts.oppositeY - opts.y;\n\n let relX: number, relY: number;\n\n if (Math.abs(dx) <= halfWidth && Math.abs(dy) <= halfHeight) {\n const distToRight = halfWidth - dx;\n const distToLeft = halfWidth + dx;\n const distToTop = halfHeight - dy;\n const distToBottom = halfHeight + dy;\n\n const minDist = Math.min(distToRight, distToLeft, distToTop, distToBottom);\n\n relX = minDist === distToRight ? halfWidth : minDist === distToLeft ? -halfWidth : dx;\n relY = minDist === distToTop ? halfHeight : minDist === distToBottom ? -halfHeight : dy;\n } else {\n const absDx = Math.abs(dx);\n const absDy = Math.abs(dy);\n\n if (halfWidth * absDy < halfHeight * absDx) {\n relX = dx > 0 ? halfWidth : -halfWidth;\n relY = (relX * dy) / dx;\n if (Math.abs(relY) > halfHeight) {\n relY = dy > 0 ? halfHeight : -halfHeight;\n relX = (relY * dx) / dy;\n }\n } else {\n relY = dy > 0 ? halfHeight : -halfHeight;\n relX = (relY * dx) / dy;\n if (Math.abs(relX) > halfWidth) {\n relX = dx > 0 ? halfWidth : -halfWidth;\n relY = (relX * dy) / dx;\n }\n }\n }\n\n if (opts.borderRadius != undefined) {\n const { x, y } = squareRadiusFix(relX, relY, halfWidth, halfHeight, opts.borderRadius);\n if (x != undefined) relX = x;\n if (y != undefined) relY = y;\n }\n\n if (opts.arrowSize > 0) {\n const edgeDist = Math.sqrt(relX * relX + relY * relY);\n const scale = (edgeDist + opts.arrowSize) / edgeDist;\n relX *= scale;\n relY *= scale;\n }\n\n return {\n x: opts.x + relX,\n y: opts.y + relY,\n };\n}\n\n// eslint-disable-next-line no-warning-comments\n// TODO: Need upgrade\nfunction squareRadiusFix(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n borderRadius: number,\n) {\n const epsilon = 1e-6;\n const absX = Math.abs(relX);\n const absY = Math.abs(relY);\n\n let side: string | null = null;\n if (absX >= halfWidth - epsilon) {\n side = relX > 0 ? \"right\" : \"left\";\n } else if (absY >= halfHeight - epsilon) {\n side = relY > 0 ? \"top\" : \"bottom\";\n }\n\n if (side) {\n const topBound = halfHeight - borderRadius;\n const bottomBound = -topBound;\n const rightBound = halfWidth - borderRadius;\n const leftBound = -rightBound;\n\n switch (side) {\n case \"right\":\n if (relY > topBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"right-top\");\n } else if (relY < bottomBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"right-bottom\");\n }\n break;\n case \"left\":\n if (relY > topBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"left-top\");\n } else if (relY < bottomBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"left-bottom\");\n }\n break;\n case \"top\":\n if (relX > rightBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"top-right\");\n } else if (relX < leftBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"top-left\");\n }\n break;\n case \"bottom\":\n if (relX > rightBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"bottom-right\");\n } else if (relX < leftBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"bottom-left\");\n }\n break;\n default:\n break;\n }\n }\n\n return { x: undefined, y: undefined };\n}\n\nfunction checkIntersection(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n r: number,\n corner: Parameters<typeof intersectWithCircle>[5],\n) {\n const intersect = intersectWithCircle(relX, relY, halfWidth, halfHeight, r, corner);\n\n return intersect ?? { x: undefined, y: undefined };\n}\n\nfunction intersectWithCircle(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n r: number,\n corner:\n | \"right-top\"\n | \"right-bottom\"\n | \"left-top\"\n | \"left-bottom\"\n | \"top-right\"\n | \"top-left\"\n | \"bottom-right\"\n | \"bottom-left\",\n) {\n switch (corner) {\n case \"top-right\":\n corner = \"right-top\";\n break;\n case \"bottom-right\":\n corner = \"right-bottom\";\n break;\n case \"top-left\":\n corner = \"left-top\";\n break;\n case \"bottom-left\":\n corner = \"left-bottom\";\n break;\n default:\n break;\n }\n\n let cx: number, cy: number;\n switch (corner) {\n case \"right-top\":\n cx = halfWidth - r;\n cy = halfHeight - r;\n break;\n case \"right-bottom\":\n cx = halfWidth - r;\n cy = -halfHeight + r;\n break;\n case \"left-top\":\n cx = -halfWidth + r;\n cy = halfHeight - r;\n break;\n case \"left-bottom\":\n cx = -halfWidth + r;\n cy = -halfHeight + r;\n break;\n default:\n return null;\n }\n\n const a = relX ** 2 + relY ** 2;\n if (a === 0) return null;\n\n const b = -2 * (relX * cx + relY * cy);\n const c = cx ** 2 + cy ** 2 - r ** 2;\n const discriminant = b ** 2 - 4 * a * c;\n\n if (discriminant < 0) return null;\n const sqrtD = Math.sqrt(discriminant);\n\n const t2 = (-b - sqrtD) / (2 * a);\n const t1 = (-b + sqrtD) / (2 * a);\n const t = t2 > 0 ? t2 : t1 > 0 ? t1 : null;\n\n if (t === null || t >= 1) return null;\n\n const x = t * relX;\n const y = t * relY;\n\n let valid = false;\n switch (corner) {\n case \"right-top\":\n valid = x >= cx && y >= cy;\n break;\n case \"right-bottom\":\n valid = x >= cx && y <= cy;\n break;\n case \"left-top\":\n valid = x <= cx && y >= cy;\n break;\n case \"left-bottom\":\n valid = x <= cx && y <= cy;\n break;\n default:\n break;\n }\n\n return valid ? { x, y } : null;\n}\n"],"names":[],"mappings":";;;;AAAA;SASgB,2BAA2B,CAGzC,IAAuC,EAAE,SAAS,GAAG,CAAC,EAAA;AACtD,IAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM;AAC1B,IAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM;IAE1B,IAAI,OAAO,MAAM,IAAI,QAAQ,IAAI,OAAO,MAAM,IAAI,QAAQ;AAAE,QAAA,OAAO,IAAI;IAEvE,MAAM,WAAW,GAAG,YAAY,CAAC;AAC/B,QAAA,SAAS,EAAE,CAAC;AACZ,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,YAAY,EAAE,MAAM;AACrB,KAAA,CAAC;IACF,MAAM,WAAW,GAAG,YAAY,CAAC;AAC/B,QAAA,SAAS,EAAE,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,CAAC;AAC/C,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,YAAY,EAAE,MAAM;AACrB,KAAA,CAAC;AAEF,IAAA,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW;AAAE,QAAA,OAAO,IAAI;AAE7C,IAAA,MAAM,QAAQ,GACZ,WAAW,IAAI;AACb,UAAE,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,KAAK,CAAC;UACrF,CAAC;IAEP,OAAO;QACL,EAAE,EAAE,WAAW,CAAC,CAAC;QACjB,EAAE,EAAE,WAAW,CAAC,CAAC;QACjB,EAAE,EAAE,WAAW,CAAC,CAAC;QACjB,EAAE,EAAE,WAAW,CAAC,CAAC;QACjB,QAAQ;KACT;AACH;AAOA,SAAS,YAAY,CAA2C,IA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GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI;AAChC;;;;"}
|
|
1
|
+
{"version":3,"file":"calculate-link-position-by-node.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/calculate-link-position-by-node.ts"],"sourcesContent":["import { COMMON_SETTINGS } from \"../../constants\";\nimport type { LinkInterface, NodeInterface } from \"../../types\";\n\ntype Point = {\n x: number;\n y: number;\n};\n\nexport function calculateLinkPositionByNode<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(link: LinkInterface<NodeData, LinkData>, arrowSize = 0) {\n const source = link.source;\n const target = link.target;\n\n if (typeof source != \"object\" || typeof target != \"object\") return null;\n\n const sourcePoint = getLinkPoint({\n arrowSize: 0,\n node: source,\n oppositeNode: target,\n });\n const targetPoint = getLinkPoint({\n arrowSize: arrowSize > 0 ? arrowSize * 0.85 : 0,\n node: target,\n oppositeNode: source,\n });\n\n if (!sourcePoint || !targetPoint) return null;\n\n const distance =\n targetPoint && sourcePoint\n ? Math.sqrt((targetPoint.x - sourcePoint.x) ** 2 + (targetPoint.y - sourcePoint.y) ** 2)\n : 0;\n\n return {\n x1: sourcePoint.x,\n y1: sourcePoint.y,\n x2: targetPoint.x,\n y2: targetPoint.y,\n distance,\n };\n}\n\ntype GetLinkPointProps<NodeData extends Record<string, unknown>> = {\n arrowSize: number;\n node: NodeInterface<NodeData>;\n oppositeNode: NodeInterface<NodeData>;\n};\nfunction getLinkPoint<NodeData extends Record<string, unknown>>(opts: GetLinkPointProps<NodeData>) {\n if (\n opts.node.x == undefined ||\n opts.node.y == undefined ||\n opts.oppositeNode.x == undefined ||\n opts.oppositeNode.y == undefined\n )\n return null;\n\n let nodePoint: Point;\n switch (opts.node._shape) {\n case \"circle\": {\n nodePoint = getCircleIntersection({\n x: opts.node.x,\n y: opts.node.y,\n radius:\n (opts.node._radius ?? COMMON_SETTINGS.nodeRadius) +\n (opts.node._borderWidth ? opts.node._borderWidth / 2 : 0),\n oppositeX: opts.oppositeNode.x,\n oppositeY: opts.oppositeNode.y,\n arrowSize: opts.arrowSize,\n });\n break;\n }\n case \"square\":\n case \"text\": {\n nodePoint = getRectangleIntersection({\n arrowSize: opts.arrowSize,\n x: opts.node.x,\n y: opts.node.y,\n height: (opts.node._height ?? COMMON_SETTINGS.nodeSize) + (opts.node._borderWidth ?? 0),\n width: (opts.node._width ?? COMMON_SETTINGS.nodeSize) + (opts.node._borderWidth ?? 0),\n oppositeX: opts.oppositeNode.x,\n oppositeY: opts.oppositeNode.y,\n borderRadius: opts.node._shape === \"text\" ? 0 : (opts.node._borderRadius ?? 0),\n });\n break;\n }\n default: {\n nodePoint = getCircleIntersection({\n x: opts.node.x,\n y: opts.node.y,\n radius: opts.node._radius ?? COMMON_SETTINGS.nodeRadius,\n oppositeX: opts.oppositeNode.x,\n oppositeY: opts.oppositeNode.y,\n arrowSize: opts.arrowSize,\n });\n }\n }\n\n return nodePoint;\n}\n\ntype GetCircleIntersection = {\n x: number;\n y: number;\n radius: number;\n oppositeX: number;\n oppositeY: number;\n arrowSize: number;\n};\n\nfunction getCircleIntersection(opts: GetCircleIntersection): Point {\n const dx = opts.oppositeX - opts.x;\n const dy = opts.oppositeY - opts.y;\n const dr = Math.sqrt(dx * dx + dy * dy);\n\n const radius = opts.radius + opts.arrowSize;\n\n return {\n x: opts.x + (dx * radius) / dr,\n y: opts.y + (dy * radius) / dr,\n };\n}\n\ntype GetRectangleIntersection = {\n x: number;\n y: number;\n width: number;\n height: number;\n oppositeX: number;\n oppositeY: number;\n arrowSize: number;\n borderRadius: number;\n};\n\nfunction getRectangleIntersection(opts: GetRectangleIntersection): Point {\n const halfWidth = opts.width / 2;\n const halfHeight = opts.height / 2;\n\n const dx = opts.oppositeX - opts.x;\n const dy = opts.oppositeY - opts.y;\n\n let relX: number, relY: number;\n\n if (Math.abs(dx) <= halfWidth && Math.abs(dy) <= halfHeight) {\n const distToRight = halfWidth - dx;\n const distToLeft = halfWidth + dx;\n const distToTop = halfHeight - dy;\n const distToBottom = halfHeight + dy;\n\n const minDist = Math.min(distToRight, distToLeft, distToTop, distToBottom);\n\n relX = minDist === distToRight ? halfWidth : minDist === distToLeft ? -halfWidth : dx;\n relY = minDist === distToTop ? halfHeight : minDist === distToBottom ? -halfHeight : dy;\n } else {\n const absDx = Math.abs(dx);\n const absDy = Math.abs(dy);\n\n if (halfWidth * absDy < halfHeight * absDx) {\n relX = dx > 0 ? halfWidth : -halfWidth;\n relY = (relX * dy) / dx;\n if (Math.abs(relY) > halfHeight) {\n relY = dy > 0 ? halfHeight : -halfHeight;\n relX = (relY * dx) / dy;\n }\n } else {\n relY = dy > 0 ? halfHeight : -halfHeight;\n relX = (relY * dx) / dy;\n if (Math.abs(relX) > halfWidth) {\n relX = dx > 0 ? halfWidth : -halfWidth;\n relY = (relX * dy) / dx;\n }\n }\n }\n\n if (opts.borderRadius != undefined) {\n const { x, y } = squareRadiusFix(relX, relY, halfWidth, halfHeight, opts.borderRadius);\n if (x != undefined) relX = x;\n if (y != undefined) relY = y;\n }\n\n if (opts.arrowSize > 0) {\n const edgeDist = Math.sqrt(relX * relX + relY * relY);\n const scale = (edgeDist + opts.arrowSize) / edgeDist;\n relX *= scale;\n relY *= scale;\n }\n\n return {\n x: opts.x + relX,\n y: opts.y + relY,\n };\n}\n\n// eslint-disable-next-line no-warning-comments\n// TODO: Need upgrade\nfunction squareRadiusFix(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n borderRadius: number,\n) {\n const epsilon = 1e-6;\n const absX = Math.abs(relX);\n const absY = Math.abs(relY);\n\n let side: string | null = null;\n if (absX >= halfWidth - epsilon) {\n side = relX > 0 ? \"right\" : \"left\";\n } else if (absY >= halfHeight - epsilon) {\n side = relY > 0 ? \"top\" : \"bottom\";\n }\n\n if (side) {\n const topBound = halfHeight - borderRadius;\n const bottomBound = -topBound;\n const rightBound = halfWidth - borderRadius;\n const leftBound = -rightBound;\n\n switch (side) {\n case \"right\":\n if (relY > topBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"right-top\");\n } else if (relY < bottomBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"right-bottom\");\n }\n break;\n case \"left\":\n if (relY > topBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"left-top\");\n } else if (relY < bottomBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"left-bottom\");\n }\n break;\n case \"top\":\n if (relX > rightBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"top-right\");\n } else if (relX < leftBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"top-left\");\n }\n break;\n case \"bottom\":\n if (relX > rightBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"bottom-right\");\n } else if (relX < leftBound) {\n return checkIntersection(relX, relY, halfWidth, halfHeight, borderRadius, \"bottom-left\");\n }\n break;\n default:\n break;\n }\n }\n\n return { x: undefined, y: undefined };\n}\n\nfunction checkIntersection(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n r: number,\n corner: Parameters<typeof intersectWithCircle>[5],\n) {\n const intersect = intersectWithCircle(relX, relY, halfWidth, halfHeight, r, corner);\n\n return intersect ?? { x: undefined, y: undefined };\n}\n\nfunction intersectWithCircle(\n relX: number,\n relY: number,\n halfWidth: number,\n halfHeight: number,\n r: number,\n corner:\n | \"right-top\"\n | \"right-bottom\"\n | \"left-top\"\n | \"left-bottom\"\n | \"top-right\"\n | \"top-left\"\n | \"bottom-right\"\n | \"bottom-left\",\n) {\n switch (corner) {\n case \"top-right\":\n corner = \"right-top\";\n break;\n case \"bottom-right\":\n corner = \"right-bottom\";\n break;\n case \"top-left\":\n corner = \"left-top\";\n break;\n case \"bottom-left\":\n corner = \"left-bottom\";\n break;\n default:\n break;\n }\n\n let cx: number, cy: number;\n switch (corner) {\n case \"right-top\":\n cx = halfWidth - r;\n cy = halfHeight - r;\n break;\n case \"right-bottom\":\n cx = halfWidth - r;\n cy = -halfHeight + r;\n break;\n case \"left-top\":\n cx = -halfWidth + r;\n cy = halfHeight - r;\n break;\n case \"left-bottom\":\n cx = -halfWidth + r;\n cy = -halfHeight + r;\n break;\n default:\n return null;\n }\n\n const a = relX ** 2 + relY ** 2;\n if (a === 0) return null;\n\n const b = -2 * (relX * cx + relY * cy);\n const c = cx ** 2 + cy ** 2 - r ** 2;\n const discriminant = b ** 2 - 4 * a * c;\n\n if (discriminant < 0) return null;\n const sqrtD = Math.sqrt(discriminant);\n\n const t2 = (-b - sqrtD) / (2 * a);\n const t1 = (-b + sqrtD) / (2 * a);\n const t = t2 > 0 ? t2 : t1 > 0 ? t1 : null;\n\n if (t === null || t >= 1) return null;\n\n const x = t * relX;\n const y = t * relY;\n\n let valid = false;\n switch (corner) {\n case \"right-top\":\n valid = x >= cx && y >= cy;\n break;\n case \"right-bottom\":\n valid = x >= cx && y <= cy;\n break;\n case \"left-top\":\n valid = x <= cx && y >= cy;\n break;\n case \"left-bottom\":\n valid = x <= cx && y <= cy;\n break;\n default:\n break;\n }\n\n return valid ? { x, y } : null;\n}\n"],"names":[],"mappings":";;;;SAQgB,2BAA2B,CAGzC,IAAuC,EAAE,SAAS,GAAG,CAAC,EAAA;AACtD,IAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM;AAC1B,IAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM;IAE1B,IAAI,OAAO,MAAM,IAAI,QAAQ,IAAI,OAAO,MAAM,IAAI,QAAQ;AAAE,QAAA,OAAO,IAAI;IAEvE,MAAM,WAAW,GAAG,YAAY,CAAC;AAC/B,QAAA,SAAS,EAAE,CAAC;AACZ,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,YAAY,EAAE,MAAM;AACrB,KAAA,CAAC;IACF,MAAM,WAAW,GAAG,YAAY,CAAC;AAC/B,QAAA,SAAS,EAAE,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,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,IAAI,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,IAAI;AAErC,IAAA,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI;AAClB,IAAA,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI;IAElB,IAAI,KAAK,GAAG,KAAK;IACjB,QAAQ,MAAM;AACZ,QAAA,KAAK,WAAW;YACd,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;AACF,QAAA,KAAK,cAAc;YACjB,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;AACF,QAAA,KAAK,UAAU;YACb,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;AACF,QAAA,KAAK,aAAa;YAChB,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;YAC1B;;AAKJ,IAAA,OAAO,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI;AAChC;;;;"}
|
|
@@ -2,7 +2,6 @@ import { isObject } from '@krainovsd/js-helpers';
|
|
|
2
2
|
import { greatest } from 'd3-array';
|
|
3
3
|
import { pointerGetter } from './pointer-getter.js';
|
|
4
4
|
|
|
5
|
-
/* eslint-disable id-length */
|
|
6
5
|
function linkByPointerGetter({ areaRect, areaTransform, mouseEvent, links, linkHoverExtraZone, }) {
|
|
7
6
|
if (!areaRect)
|
|
8
7
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-by-pointer-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/link-by-pointer-getter.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"link-by-pointer-getter.js","sources":["../../../../../../src/module/GraphCanvas/lib/utils/link-by-pointer-getter.ts"],"sourcesContent":["import { isObject } from \"@krainovsd/js-helpers\";\nimport { greatest } from \"d3-array\";\nimport type { ZoomTransform } from \"d3-zoom\";\nimport type { LinkInterface } from \"../../types\";\nimport { pointerGetter } from \"./pointer-getter\";\n\nexport type LinkByPointerGetterOptions<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n> = {\n mouseEvent: MouseEvent | TouchEvent;\n areaRect: DOMRect | undefined;\n areaTransform: ZoomTransform;\n links: LinkInterface<NodeData, LinkData>[];\n linkHoverExtraZone: number;\n};\n\nexport function linkByPointerGetter<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>({\n areaRect,\n areaTransform,\n mouseEvent,\n links,\n linkHoverExtraZone,\n}: LinkByPointerGetterOptions<NodeData, LinkData>): LinkInterface<NodeData, LinkData> | undefined {\n if (!areaRect) return undefined;\n\n const [pointerX, pointerY] = pointerGetter(mouseEvent, areaRect, areaTransform);\n\n return greatest(links, (link) => {\n if (isNearLink(pointerX, pointerY, link, linkHoverExtraZone)) return link.index;\n });\n}\n\nfunction isNearLink<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(mouseX: number, mouseY: number, link: LinkInterface<NodeData, LinkData>, threshold = 2) {\n if (!isObject(link.source) || !isObject(link.target)) return false;\n\n const x1 = link.source.x as number;\n const y1 = link.source.y as number;\n const x2 = link.target.x as number;\n const y2 = link.target.y as number;\n\n const distance = distanceToLine(mouseX, mouseY, x1, y1, x2, y2);\n\n return distance <= threshold;\n}\n\nfunction distanceToLine(x: number, y: number, x1: number, y1: number, x2: number, y2: number) {\n const A = x - x1;\n const B = y - y1;\n const C = x2 - x1;\n const D = y2 - y1;\n\n const dot = A * C + B * D;\n const lenSq = C * C + D * D;\n let param = -1;\n\n if (lenSq !== 0) {\n param = dot / lenSq;\n }\n\n let xx, yy;\n\n if (param < 0) {\n xx = x1;\n yy = y1;\n } else if (param > 1) {\n xx = x2;\n yy = y2;\n } else {\n xx = x1 + param * C;\n yy = y1 + param * D;\n }\n\n const dx = x - xx;\n const dy = y - yy;\n\n return Math.sqrt(dx * dx + dy * dy);\n}\n"],"names":[],"mappings":";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IAAA,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE;AAChB,IAAA,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE;AACjB,IAAA,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE;IAEjB,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;IACzB,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;AAC3B,IAAA,IAAI,KAAK,GAAG,EAAE;AAEd,IAAA,IAAI,KAAK,KAAK,CAAC,EAAE;AACf,QAAA,KAAK,GAAG,GAAG,GAAG,KAAK;;IAGrB,IAAI,EAAE,EAAE,EAAE;AAEV,IAAA,IAAI,KAAK,GAAG,CAAC,EAAE;QACb,EAAE,GAAG,EAAE;QACP,EAAE,GAAG,EAAE;;AACF,SAAA,IAAI,KAAK,GAAG,CAAC,EAAE;QACpB,EAAE,GAAG,EAAE;QACP,EAAE,GAAG,EAAE;;SACF;AACL,QAAA,EAAE,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC;AACnB,QAAA,EAAE,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC;;AAGrB,IAAA,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE;AACjB,IAAA,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE;AAEjB,IAAA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACrC;;;;"}
|
package/lib/index.d.ts
CHANGED
|
@@ -670,4 +670,5 @@ declare const NODE_OPTIONS_NODE_CONTROLS: GraphSettingsInputInterface<keyof Node
|
|
|
670
670
|
declare const NODE_OPTIONS_TEXT_CONTROLS: GraphSettingsInputInterface<keyof NodeOptionsTextInterface>[];
|
|
671
671
|
declare const NODE_OPTIONS_LABEL_CONTROLS: GraphSettingsInputInterface<keyof NodeOptionsLabelInterface>[];
|
|
672
672
|
|
|
673
|
-
export { COMMON_SETTINGS,
|
|
673
|
+
export { COMMON_SETTINGS, FORCE_CONTROLS, FORCE_SETTINGS, GRAPH_CONTROLS, GRAPH_SETTINGS, GraphCanvas, HIGHLIGHT_BY_LINK_FOR_ARROW_CONTROLS, HIGHLIGHT_BY_LINK_FOR_LABEL_CONTROLS, HIGHLIGHT_BY_LINK_FOR_LINK_CONTROLS, HIGHLIGHT_BY_LINK_FOR_NODE_CONTROLS, HIGHLIGHT_BY_LINK_FOR_TEXT_CONTROLS, HIGHLIGHT_BY_NODE_FOR_ARROW_CONTROLS, HIGHLIGHT_BY_NODE_FOR_LABEL_CONTROLS, HIGHLIGHT_BY_NODE_FOR_LINK_CONTROLS, HIGHLIGHT_BY_NODE_FOR_NODE_CONTROLS, HIGHLIGHT_BY_NODE_FOR_TEXT_CONTROLS, HIGHLIGHT_COMMON_CONTROLS, HIGHLIGHT_SETTINGS, LINK_OPTIONS, LINK_OPTIONS_ARROW_CONTROLS, LINK_OPTIONS_LINK_CONTROLS, LINK_OPTIONS_PARTICLE_CONTROLS, LINK_SETTINGS, LINK_SETTINGS_CONTROLS, NODE_OPTIONS, NODE_OPTIONS_LABEL_CONTROLS, NODE_OPTIONS_NODE_CONTROLS, NODE_OPTIONS_TEXT_CONTROLS, NODE_SETTINGS, NODE_SETTINGS_CONTROLS, animationByProgress, calculateLinkPositionByNode, colorGetter, colorToRgb, dragPlaceCoefficientGetter, drawText, extractRgb, fadeRgb, forceSettingsGetter, getDrawLink, getDrawNode, getParticlePosition, graphSettingsGetter, highlightSettingsGetter, isNodeVisible, isOverlapsNode, linkByPointerGetter, linkFade, linkHighlight, linkIterationExtractor, linkOptionsGetter, linkSettingsGetter, listenersGetter, nodeByPointerGetter, nodeFade, nodeHighlight, nodeIdGetter, nodeIterationExtractor, nodeOptionsGetter, nodeRadiusGetter, nodeSettingsGetter, nodeSizeGetter, nodeTextSizeGetter, pointerGetter, rgbAnimationByProgress };
|
|
674
|
+
export type { CachedNodeTextInterface, CachedTextNodeParametersInterface, CachedTextNodeParametersMap, DragEventInterface, ForceSettingsInterface, GraphCanvasInterface, GraphCanvasSimulation, GraphSettingsInputInterface, GraphSettingsInterface, HighlighCommonSettingsInterface, HighlightByLinkForArrowSettingsInterface, HighlightByLinkForLabelSettingsInterface, HighlightByLinkForLinkSettingsInterface, HighlightByLinkForNodeSettingsInterface, HighlightByLinkForTextSettingsInterface, HighlightByNodeForArrowSettingsInterface, HighlightByNodeForLabelSettingsInterface, HighlightByNodeForLinkSettingsInterface, HighlightByNodeForNodeSettingsInterface, HighlightByNodeForTextSettingsInterface, HighlightSettingsInterface, LinkByPointerGetterOptions, LinkInterface, LinkIterationPropsInterface, LinkIterationPropsNoThisInterface, LinkOptionsArrowInterface, LinkOptionsInterface, LinkOptionsLinkInterface, LinkOptionsParticleInterface, LinkParticle, LinkSettingsInterface, ListenersInterface, NodeByPointerGetterOptions, NodeInterface, NodeIterationPropsInterface, NodeIterationPropsNoThisInterface, NodeOptionsInterface, NodeOptionsLabelInterface, NodeOptionsNodeInterface, NodeOptionsTextInterface, NodeRadiusGetterOptions, NodeSettingsInterface, NodeShape, NodeSizeGetterOptions, RGB, TextStyleEnum, ZoomEventInterface };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krainovsd/graph",
|
|
3
|
-
"version": "0.11.0-beta.
|
|
3
|
+
"version": "0.11.0-beta.2",
|
|
4
4
|
"description": "Krainov graph",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "KrainovSD <denislosev48@gmail.com>",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"clear": "rm -rf ./lib",
|
|
33
33
|
"build-dev": "vite build",
|
|
34
34
|
"build": "npm run clear && npm run build:types && npm run build:js",
|
|
35
|
-
"build-singleton": "
|
|
35
|
+
"build-singleton": "npm run clear && rollup --config rollup-singleton.config.ts --configPlugin @rollup/plugin-typescript --no-stdin --environment BUILD:production,NODE_ENV:production",
|
|
36
36
|
"build:js": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript --no-stdin --environment BUILD:production,NODE_ENV:production",
|
|
37
37
|
"build:types": "tspc -p tsconfig.build.json",
|
|
38
38
|
"lint": "eslint . -c ./eslint.config.js --color --max-warnings 0",
|
|
@@ -43,24 +43,24 @@
|
|
|
43
43
|
"type-debug": "tsc --showConfig > typescript-config.json"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@krainovsd/presets": "0.
|
|
47
|
-
"eslint": "9.21.0",
|
|
48
|
-
"prettier": "3.5.2",
|
|
46
|
+
"@krainovsd/presets": "0.3.6",
|
|
49
47
|
"rollup": "4.34.9",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
48
|
+
"prettier": "3.6.1",
|
|
49
|
+
"eslint": "9.29.0",
|
|
50
|
+
"typescript": "5.8.3",
|
|
51
|
+
"typescript-transform-paths": "3.5.5",
|
|
52
52
|
"ts-patch": "3.3.0",
|
|
53
|
-
"@types/node": "22.8
|
|
53
|
+
"@types/node": "22.13.8",
|
|
54
54
|
"@types/d3-selection": "3.0.11",
|
|
55
55
|
"@types/d3-drag": "3.0.7",
|
|
56
56
|
"@types/d3-array": "3.2.1",
|
|
57
|
-
"vite": "6.
|
|
57
|
+
"vite": "6.2.1",
|
|
58
58
|
"@types/lodash": "4.17.14",
|
|
59
59
|
"@sveltejs/vite-plugin-svelte": "5.0.3",
|
|
60
60
|
"svelte": "5.23.2"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@krainovsd/js-helpers": "0.
|
|
63
|
+
"@krainovsd/js-helpers": "^0.14.6",
|
|
64
64
|
"@types/d3-zoom": "3.0.8",
|
|
65
65
|
"@types/d3-force": "3.0.10",
|
|
66
66
|
"@types/d3-drag": "3.0.7",
|