@krainovsd/graph 0.9.0 → 0.10.0-rc2

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 (53) hide show
  1. package/lib/cjs/index.cjs +2672 -1803
  2. package/lib/cjs/index.cjs.map +1 -1
  3. package/lib/esm/index.js +12 -3
  4. package/lib/esm/index.js.map +1 -1
  5. package/lib/esm/lib/draw-time.js +5 -1
  6. package/lib/esm/lib/draw-time.js.map +1 -1
  7. package/lib/esm/lib/get-controls-info.js +451 -224
  8. package/lib/esm/lib/get-controls-info.js.map +1 -1
  9. package/lib/esm/module/GraphCanvas/GraphCanvas.js +44 -934
  10. package/lib/esm/module/GraphCanvas/GraphCanvas.js.map +1 -1
  11. package/lib/esm/module/GraphCanvas/constants/settings.js +70 -47
  12. package/lib/esm/module/GraphCanvas/constants/settings.js.map +1 -1
  13. package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js +12 -1
  14. package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js.map +1 -1
  15. package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js +270 -0
  16. package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js.map +1 -0
  17. package/lib/esm/module/GraphCanvas/lib/utils/drag-place-coefficient-getter.js +2 -2
  18. package/lib/esm/module/GraphCanvas/lib/utils/drag-place-coefficient-getter.js.map +1 -1
  19. package/lib/esm/module/GraphCanvas/lib/utils/get-particle-position.js +19 -4
  20. package/lib/esm/module/GraphCanvas/lib/utils/get-particle-position.js.map +1 -1
  21. package/lib/esm/module/GraphCanvas/lib/utils/is-node-visible.js +29 -4
  22. package/lib/esm/module/GraphCanvas/lib/utils/is-node-visible.js.map +1 -1
  23. package/lib/esm/module/GraphCanvas/lib/utils/is-overlaps-node.js +53 -4
  24. package/lib/esm/module/GraphCanvas/lib/utils/is-overlaps-node.js.map +1 -1
  25. package/lib/esm/module/GraphCanvas/lib/utils/link-by-pointer-getter.js +2 -2
  26. package/lib/esm/module/GraphCanvas/lib/utils/link-by-pointer-getter.js.map +1 -1
  27. package/lib/esm/module/GraphCanvas/lib/utils/node-by-pointer-getter.js +3 -13
  28. package/lib/esm/module/GraphCanvas/lib/utils/node-by-pointer-getter.js.map +1 -1
  29. package/lib/esm/module/GraphCanvas/slices/draw-links.js +207 -0
  30. package/lib/esm/module/GraphCanvas/slices/draw-links.js.map +1 -0
  31. package/lib/esm/module/GraphCanvas/slices/draw-nodes.js +367 -0
  32. package/lib/esm/module/GraphCanvas/slices/draw-nodes.js.map +1 -0
  33. package/lib/esm/module/GraphCanvas/{lib/utils → slices}/draw-text.js +30 -7
  34. package/lib/esm/module/GraphCanvas/slices/draw-text.js.map +1 -0
  35. package/lib/esm/module/GraphCanvas/slices/init-area.js +31 -0
  36. package/lib/esm/module/GraphCanvas/slices/init-area.js.map +1 -0
  37. package/lib/esm/module/GraphCanvas/slices/init-dnd.js +62 -0
  38. package/lib/esm/module/GraphCanvas/slices/init-dnd.js.map +1 -0
  39. package/lib/esm/module/GraphCanvas/slices/init-draw.js +84 -0
  40. package/lib/esm/module/GraphCanvas/slices/init-draw.js.map +1 -0
  41. package/lib/esm/module/GraphCanvas/slices/init-pointer.js +211 -0
  42. package/lib/esm/module/GraphCanvas/slices/init-pointer.js.map +1 -0
  43. package/lib/esm/module/GraphCanvas/slices/init-resize.js +28 -0
  44. package/lib/esm/module/GraphCanvas/slices/init-resize.js.map +1 -0
  45. package/lib/esm/module/GraphCanvas/slices/init-simulation.js +172 -0
  46. package/lib/esm/module/GraphCanvas/slices/init-simulation.js.map +1 -0
  47. package/lib/esm/module/GraphCanvas/slices/init-zoom.js +36 -0
  48. package/lib/esm/module/GraphCanvas/slices/init-zoom.js.map +1 -0
  49. package/lib/index.d.ts +197 -154
  50. package/package.json +1 -1
  51. package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-radius.js +0 -20
  52. package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-radius.js.map +0 -1
  53. package/lib/esm/module/GraphCanvas/lib/utils/draw-text.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draw-nodes.js","sources":["../../../../../src/module/GraphCanvas/slices/draw-nodes.ts"],"sourcesContent":["import { isNumber } from \"@krainovsd/js-helpers\";\nimport { colorToRgb, extractRgb, fadeRgb, rgbAnimationByProgress } from \"@/lib\";\nimport type { CachedTextNodeParametersInterface, NodeInterface } from \"@/types\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport {\n animationByProgress,\n isNodeVisible,\n nodeIterationExtractor,\n nodeOptionsGetter,\n nodeRadiusGetter,\n nodeSizeGetter,\n} from \"../lib\";\nimport type { GraphState, NodeOptionsInterface } from \"../types\";\nimport { drawText, getTextLines } from \"./draw-text\";\n\nexport function getDrawNode<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(nodeRenders: (() => void)[], textRenders: (() => void)[], state: GraphState<NodeData, LinkData>) {\n return function drawNode(\n this: GraphCanvas<NodeData, LinkData>,\n node: NodeInterface<NodeData>,\n index: number,\n ) {\n if (!this.context || !node.x || !node.y) return;\n\n let nodeOptions: Required<NodeOptionsInterface<NodeData, LinkData>>;\n if (this.nodeSettings.cache && this.nodeOptionsCache[node.id]) {\n nodeOptions = this.nodeOptionsCache[node.id];\n } else {\n nodeOptions = nodeIterationExtractor(\n node,\n index,\n this.nodes,\n state,\n this.nodeSettings.options ?? {},\n nodeOptionsGetter,\n );\n if (this.nodeSettings.cache) {\n this.nodeOptionsCache[node.id] = nodeOptions;\n }\n }\n\n if (nodeOptions.nodeDraw && nodeOptions.textDraw) {\n nodeRenders.push(() => {\n nodeOptions?.nodeDraw?.(node, nodeOptions, state);\n });\n\n textRenders.push(() => {\n nodeOptions?.textDraw?.(node, nodeOptions, state);\n });\n\n return;\n }\n\n let alpha = nodeOptions.alpha;\n let color = nodeOptions.color;\n let radiusInitial = nodeOptions.radius;\n let widthInitial = nodeOptions.width;\n let heightInitial = nodeOptions.height;\n let textAlpha = nodeOptions.textAlpha;\n let textSize = nodeOptions.textSize;\n let textShiftX = nodeOptions.textShiftX;\n let textShiftY = nodeOptions.textShiftY;\n let textWeight = nodeOptions.textWeight;\n let textWidth = nodeOptions.textWidth;\n let sizeCoefficient = 1;\n /** Node Highlight */\n if (this.highlightedNeighbors && this.highlightedNode) {\n /** Not highlighted */\n if (!this.highlightedNeighbors.has(node.id) && this.highlightedNode.id != node.id) {\n if (this.nodeSettings.highlightByNodeNodeFading) {\n const min =\n this.nodeSettings.highlightByNodeNodeFadingMin < alpha\n ? this.nodeSettings.highlightByNodeNodeFadingMin\n : alpha;\n alpha = animationByProgress(min, alpha - min, 1 - this.highlightProgress);\n }\n if (this.nodeSettings.highlightByNodeTextFading) {\n const min =\n this.nodeSettings.highlightByNodeTextFadingMin < textAlpha\n ? this.nodeSettings.highlightByNodeTextFadingMin\n : textAlpha;\n textAlpha = animationByProgress(min, textAlpha - min, 1 - this.highlightProgress);\n }\n if (this.nodeSettings.highlightByNodeNodeColor) {\n const colorRgb = extractRgb(colorToRgb(color));\n if (colorRgb) {\n const colorRgbFade = fadeRgb(\n colorRgb,\n this.nodeSettings.highlightByNodeNodeColorFadingMin,\n );\n const colorFadeAnimation = rgbAnimationByProgress(\n colorRgb,\n colorRgbFade,\n this.highlightProgress,\n );\n color = `rgb(${colorFadeAnimation.r}, ${colorFadeAnimation.g}, ${colorFadeAnimation.b})`;\n }\n }\n } else if (\n !this.nodeSettings.highlightByNodeOnlyRoot ||\n (this.nodeSettings.highlightByNodeOnlyRoot && this.highlightedNode.id === node.id)\n ) {\n /** Highlighted */\n\n if (this.nodeSettings.highlightByNodeNodeSizing && nodeOptions.shape === \"circle\") {\n radiusInitial = animationByProgress(\n radiusInitial,\n this.nodeSettings.highlightByNodeNodeSizingAdditional,\n this.highlightProgress,\n );\n }\n if (\n this.nodeSettings.highlightByNodeNodeSizing &&\n (nodeOptions.shape === \"square\" || nodeOptions.shape === \"text\")\n ) {\n sizeCoefficient = animationByProgress(\n sizeCoefficient,\n this.nodeSettings.highlightByNodeNodeSizingAdditionalCoefficient,\n this.highlightProgress,\n );\n\n widthInitial *= sizeCoefficient;\n heightInitial *= sizeCoefficient;\n }\n if (this.nodeSettings.highlightByNodeTextSizing) {\n textSize = animationByProgress(\n textSize,\n this.nodeSettings.highlightByNodeTextSizingAdditional,\n this.highlightProgress,\n );\n textShiftX = animationByProgress(\n textShiftX,\n this.nodeSettings.highlightByNodeTextShiftXAdditional,\n this.highlightProgress,\n );\n textShiftY = animationByProgress(\n textShiftY,\n this.nodeSettings.highlightByNodeTextShiftYAdditional,\n this.highlightProgress,\n );\n textWeight = animationByProgress(\n textWeight,\n this.nodeSettings.highlightByNodeTextWeightAdditional,\n this.highlightProgress,\n );\n textWidth = animationByProgress(\n textWidth,\n this.nodeSettings.highlightByNodeTextWidthAdditional,\n this.highlightProgress,\n );\n }\n }\n }\n /** LinkHighlight */\n if (this.highlightedNeighbors && this.highlightedLink) {\n /** Not highlighted */\n if (\n !this.highlightedNeighbors.has(node.id) &&\n this.highlightedLink.source !== node &&\n this.highlightedLink.target !== node\n ) {\n if (this.nodeSettings.highlightByLinkNodeFading) {\n const min =\n this.nodeSettings.highlightByLinkNodeFadingMin < alpha\n ? this.nodeSettings.highlightByLinkNodeFadingMin\n : alpha;\n alpha = animationByProgress(min, alpha - min, 1 - this.highlightProgress);\n }\n if (this.nodeSettings.highlightByLinkTextFading) {\n const min =\n this.nodeSettings.highlightByLinkTextFadingMin < textAlpha\n ? this.nodeSettings.highlightByLinkTextFadingMin\n : textAlpha;\n textAlpha = animationByProgress(min, textAlpha - min, 1 - this.highlightProgress);\n }\n if (this.nodeSettings.highlightByLinkNodeColor) {\n const colorRgb = extractRgb(colorToRgb(color));\n if (colorRgb) {\n const colorRgbFade = fadeRgb(\n colorRgb,\n this.nodeSettings.highlightByLinkNodeColorFadingMin,\n );\n const colorFadeAnimation = rgbAnimationByProgress(\n colorRgb,\n colorRgbFade,\n this.highlightProgress,\n );\n color = `rgb(${colorFadeAnimation.r}, ${colorFadeAnimation.g}, ${colorFadeAnimation.b})`;\n }\n }\n } else {\n /** Highlighted */\n\n if (this.nodeSettings.highlightByLinkNodeSizing && nodeOptions.shape === \"circle\") {\n radiusInitial = animationByProgress(\n radiusInitial,\n this.nodeSettings.highlightByLinkNodeSizingAdditional,\n this.highlightProgress,\n );\n }\n if (\n this.nodeSettings.highlightByLinkNodeSizing &&\n (nodeOptions.shape === \"square\" ||\n nodeOptions.shape === \"text\" ||\n nodeOptions.shape === \"icon\")\n ) {\n sizeCoefficient = animationByProgress(\n sizeCoefficient,\n this.nodeSettings.highlightByNodeNodeSizingAdditionalCoefficient,\n this.highlightProgress,\n );\n\n widthInitial *= sizeCoefficient;\n heightInitial *= sizeCoefficient;\n }\n if (this.nodeSettings.highlightByLinkTextSizing) {\n textSize = animationByProgress(\n textSize,\n this.nodeSettings.highlightByLinkTextSizingAdditional,\n this.highlightProgress,\n );\n textShiftX = animationByProgress(\n textShiftX,\n this.nodeSettings.highlightByLinkTextShiftXAdditional,\n this.highlightProgress,\n );\n textShiftY = animationByProgress(\n textShiftY,\n this.nodeSettings.highlightByLinkTextShiftYAdditional,\n this.highlightProgress,\n );\n textWeight = animationByProgress(\n textWeight,\n this.nodeSettings.highlightByLinkTextWeightAdditional,\n this.highlightProgress,\n );\n textWidth = animationByProgress(\n textWidth,\n this.nodeSettings.highlightByLinkTextWidthAdditional,\n this.highlightProgress,\n );\n }\n }\n }\n\n /** Flex radius */\n const radius =\n nodeOptions.shape === \"circle\"\n ? nodeRadiusGetter({\n radiusFlexible: this.nodeSettings.nodeRadiusFlexible,\n radiusInitial,\n radiusCoefficient: this.nodeSettings.nodeRadiusCoefficient,\n radiusFactor: this.nodeSettings.nodeRadiusFactor,\n linkCount: node.linkCount,\n })\n : radiusInitial;\n /** Flex size */\n let height: number = heightInitial;\n let width: number = widthInitial;\n if (nodeOptions.shape === \"square\") {\n const size = nodeSizeGetter({\n heightInitial,\n widthInitial,\n linkCount: node.linkCount,\n sizeCoefficient: this.nodeSettings.nodeSizeCoefficient,\n sizeFactor: this.nodeSettings.nodeSizeFactor,\n sizeFlexible: this.nodeSettings.nodeSizeFlexible,\n });\n width = size.width;\n height = size.height;\n }\n if (nodeOptions.shape === \"text\") {\n width = nodeOptions.width;\n\n const size = nodeSizeGetter({\n heightInitial,\n widthInitial: width,\n linkCount: node.linkCount,\n sizeCoefficient: this.nodeSettings.nodeSizeCoefficient,\n sizeFactor: this.nodeSettings.nodeSizeFactor,\n sizeFlexible: this.nodeSettings.nodeSizeFlexible,\n });\n\n textSize *= size.additionalSizeCoefficient;\n }\n /** Size by text in textNode */\n if (nodeOptions.shape === \"text\" && nodeOptions.text) {\n textWidth = width;\n let lines: string[];\n\n let textNodeParameters: CachedTextNodeParametersInterface;\n\n const cachedLines = this.cachedNodeText[node.id];\n const cachedTextNodeParameters = this.cachedTextNodeParameters[node.id];\n if (cachedLines != undefined && cachedTextNodeParameters != undefined) {\n lines = cachedLines;\n textNodeParameters = cachedTextNodeParameters;\n } else {\n const textInfo = getTextLines({\n context: this.context,\n text: nodeOptions.text,\n textAlign: nodeOptions.textAlign,\n textColor: nodeOptions.textColor,\n textFont: nodeOptions.textFont,\n textSize,\n maxWidth: textWidth,\n textStyle: nodeOptions.textStyle,\n textWeight,\n });\n textNodeParameters = [textInfo.currentMaxSize, textSize];\n lines = textInfo.lines;\n this.cachedNodeText[node.id] = lines;\n this.cachedTextNodeParameters[node.id] = textNodeParameters;\n }\n\n const textSizeCoefficient = textSize / textNodeParameters[1];\n const maxSize = textNodeParameters[0] * textSizeCoefficient;\n\n height =\n lines.length * textSize +\n (lines.length - 1) * nodeOptions.textGap +\n nodeOptions.textNodeYPadding;\n\n width = maxSize + nodeOptions.textNodeXPadding;\n }\n\n /** Node parameters */\n node._radius = radius;\n node._width = width;\n node._height = height;\n node._borderRadius =\n isNumber(nodeOptions.borderRadius) && nodeOptions.borderRadius > 0\n ? Math.min(nodeOptions.borderRadius, nodeOptions.width / 2, nodeOptions.height / 2)\n : 0;\n node._shape = nodeOptions.shape ?? \"circle\";\n\n /** Node Visibility */\n if (\n !isNodeVisible({\n height: this.height,\n width: this.width,\n transform: this.areaTransform,\n node,\n })\n ) {\n node._visible = false;\n\n return;\n }\n node._visible = true;\n\n /** Node draw */\n nodeRenders.push(() => {\n if (!this.context || !node.x || !node.y) return;\n\n this.context.beginPath();\n this.context.globalAlpha = alpha;\n this.context.lineWidth = nodeOptions.borderWidth;\n this.context.strokeStyle = nodeOptions.borderColor;\n this.context.fillStyle = color;\n\n switch (nodeOptions.shape) {\n case \"circle\": {\n this.context.arc(node.x, node.y, radius, 0, 2 * Math.PI);\n break;\n }\n case \"square\": {\n this.context.roundRect(\n node.x - width / 2,\n node.y - height / 2,\n width,\n height,\n node._borderRadius,\n );\n break;\n }\n case \"text\": {\n if (this.nodeSettings.textNodeDebug) {\n this.context.strokeRect(node.x - width / 2, node.y - height / 2, width, height);\n }\n\n const lines = this.cachedNodeText[node.id];\n if (nodeOptions.text && lines)\n drawText({\n id: node.id,\n cachedNodeText: this.cachedNodeText,\n context: this.context,\n text: nodeOptions.text,\n textAlign: nodeOptions.textAlign,\n textColor: nodeOptions.textColor,\n textFont: nodeOptions.textFont,\n textSize,\n x: node.x,\n y: node.y + textSize / 4 - (lines.length - 1) * (textSize / 2),\n maxWidth: textWidth,\n textStyle: nodeOptions.textStyle,\n textWeight,\n textGap: nodeOptions.textGap,\n });\n break;\n }\n default: {\n this.context.arc(node.x, node.y, radius, 0, 2 * Math.PI);\n break;\n }\n }\n\n this.context.fill();\n this.context.stroke();\n });\n\n if (nodeOptions.nodeExtraDraw) {\n nodeRenders.push(() => {\n nodeOptions?.nodeExtraDraw?.(\n node,\n {\n ...nodeOptions,\n radius,\n alpha,\n color,\n textAlpha,\n textSize,\n textShiftX,\n textShiftY,\n textWeight,\n textWidth,\n },\n state,\n );\n });\n }\n\n /** Text draw */\n if (nodeOptions.textVisible && nodeOptions.text && nodeOptions.shape !== \"text\") {\n textRenders.push(() => {\n if (nodeOptions.textDraw) {\n nodeOptions.textDraw(\n node,\n {\n ...nodeOptions,\n radius,\n alpha,\n color,\n textAlpha,\n textSize,\n textShiftX,\n textShiftY,\n textWeight,\n textWidth,\n },\n state,\n );\n\n return;\n }\n\n if (!this.context || !node.x || !node.y || !nodeOptions.text) return;\n this.context.beginPath();\n this.context.globalAlpha = textAlpha;\n\n let y = node.y + textShiftY;\n if (nodeOptions.shape === \"circle\") {\n y += radius;\n }\n if (nodeOptions.shape === \"square\") {\n y += height / 2;\n }\n\n drawText({\n id: node.id,\n cachedNodeText: this.cachedNodeText,\n context: this.context,\n text: nodeOptions.text,\n textAlign: nodeOptions.textAlign,\n textColor: nodeOptions.textColor,\n textFont: nodeOptions.textFont,\n textSize,\n x: node.x + textShiftX,\n y,\n maxWidth: textWidth,\n textStyle: nodeOptions.textStyle,\n textWeight,\n textGap: nodeOptions.textGap,\n });\n\n if (nodeOptions.textExtraDraw) {\n nodeOptions.textExtraDraw(\n node,\n {\n ...nodeOptions,\n radius,\n alpha,\n color,\n textAlpha,\n textSize,\n textShiftX,\n textShiftY,\n textWeight,\n textWidth,\n },\n state,\n );\n }\n });\n }\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;SAegB,WAAW,CAGzB,WAA2B,EAAE,WAA2B,EAAE,KAAqC,EAAA;AAC/F,IAAA,OAAO,SAAS,QAAQ,CAEtB,IAA6B,EAC7B,KAAa,EAAA;AAEb,QAAA,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAAE;AAEzC,QAAA,IAAI,WAA+D;AACnE,QAAA,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;YAC7D,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,E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AAO;AAC7B,iBAAA,CAAC;AAEF,gBAAA,IAAI,WAAW,CAAC,aAAa,EAAE;AAC7B,oBAAA,WAAW,CAAC,aAAa,CACvB,IAAI,EACJ;AACE,wBAAA,GAAG,WAAW;wBACd,MAAM;wBACN,KAAK;wBACL,KAAK;wBACL,SAAS;wBACT,QAAQ;wBACR,UAAU;wBACV,UAAU;wBACV,UAAU;wBACV,SAAS;qBACV,EACD,KAAK,CACN;;AAEL,aAAC,CAAC;;AAEN,KAAC;AACH;;;;"}
@@ -14,19 +14,43 @@ function drawText({ context, id, textAlign, textColor, textFont, textStyle, text
14
14
  context.fillText(text, x, y);
15
15
  return;
16
16
  }
17
+ const { lines } = getTextLines({
18
+ context,
19
+ maxWidth,
20
+ text,
21
+ textAlign,
22
+ textColor,
23
+ textFont,
24
+ textSize,
25
+ textStyle,
26
+ textWeight,
27
+ });
28
+ cachedNodeText[id] = lines;
29
+ lines.forEach((line, index) => {
30
+ context.fillText(line, x, y + index * textSize + index * textGap);
31
+ });
32
+ }
33
+ function getTextLines({ context, textAlign, textColor, textFont, textStyle, textWeight, textSize, text, maxWidth, }) {
34
+ context.font = `${textStyle} normal ${textWeight} ${textSize}px ${textFont}`;
35
+ context.fillStyle = textColor;
36
+ context.textAlign = textAlign;
17
37
  const spaceWidth = context.measureText(" ").width;
18
38
  const lines = [];
19
39
  let lineWidth = 0;
20
40
  let line = "";
41
+ let currentMaxSize = 0;
21
42
  for (const word of text.split(" ")) {
22
43
  const size = context.measureText(word).width;
23
- lineWidth += size;
44
+ lineWidth += size + spaceWidth;
24
45
  if (line === "") {
25
46
  line = word;
26
47
  continue;
27
48
  }
28
49
  if (lineWidth > maxWidth) {
29
- lineWidth = 0;
50
+ const initialSize = lineWidth - size - spaceWidth;
51
+ if (initialSize > currentMaxSize)
52
+ currentMaxSize = initialSize;
53
+ lineWidth = size;
30
54
  lines.push(line);
31
55
  line = word;
32
56
  }
@@ -37,11 +61,10 @@ function drawText({ context, id, textAlign, textColor, textFont, textStyle, text
37
61
  }
38
62
  if (line !== "")
39
63
  lines.push(line);
40
- cachedNodeText[id] = lines;
41
- lines.forEach((line, index) => {
42
- context.fillText(line, x, y + index * textSize + index * textGap);
43
- });
64
+ if (lineWidth > currentMaxSize)
65
+ currentMaxSize = lineWidth;
66
+ return { lines, currentMaxSize };
44
67
  }
45
68
 
46
- export { drawText };
69
+ export { drawText, getTextLines };
47
70
  //# sourceMappingURL=draw-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draw-text.js","sources":["../../../../../src/module/GraphCanvas/slices/draw-text.ts"],"sourcesContent":["import type { CachedNodeTextInterface } from \"@/types\";\nimport type { TextStyleEnum } from \"../types\";\n\nexport type DrawTextOptions = {\n id: string | number;\n x: number;\n y: number;\n text: string;\n textSize: number;\n textStyle: TextStyleEnum;\n textWeight: number;\n textFont: string;\n textColor: string;\n textGap: number;\n textAlign: CanvasTextAlign;\n context: CanvasRenderingContext2D;\n cachedNodeText: CachedNodeTextInterface;\n maxWidth?: number;\n};\n\nconst SPACE = \" \";\n\nexport function drawText({\n context,\n id,\n textAlign,\n textColor,\n textFont,\n textStyle,\n textGap,\n textWeight,\n textSize,\n text,\n x,\n y,\n cachedNodeText,\n maxWidth,\n}: DrawTextOptions) {\n context.font = `${textStyle} normal ${textWeight} ${textSize}px ${textFont}`;\n context.fillStyle = textColor;\n context.textAlign = textAlign;\n\n if (cachedNodeText[id] != undefined) {\n cachedNodeText[id].forEach((line, index) => {\n context.fillText(line, x, y + index * textSize + index * textGap);\n });\n\n return;\n }\n\n if (maxWidth == undefined || context.measureText(text).width <= maxWidth) {\n cachedNodeText[id] = [text];\n context.fillText(text, x, y);\n\n return;\n }\n\n const { lines } = getTextLines({\n context,\n maxWidth,\n text,\n textAlign,\n textColor,\n textFont,\n textSize,\n textStyle,\n textWeight,\n });\n\n cachedNodeText[id] = lines;\n lines.forEach((line, index) => {\n context.fillText(line, x, y + index * textSize + index * textGap);\n });\n}\n\nexport type GetTextLines = {\n text: string;\n textSize: number;\n textStyle: TextStyleEnum;\n textWeight: number;\n textFont: string;\n textColor: string;\n textAlign: CanvasTextAlign;\n context: CanvasRenderingContext2D;\n maxWidth: number;\n};\nexport function getTextLines({\n context,\n textAlign,\n textColor,\n textFont,\n textStyle,\n textWeight,\n textSize,\n text,\n maxWidth,\n}: GetTextLines) {\n context.font = `${textStyle} normal ${textWeight} ${textSize}px ${textFont}`;\n context.fillStyle = textColor;\n context.textAlign = textAlign;\n\n const spaceWidth = context.measureText(\" \").width;\n const lines: string[] = [];\n let lineWidth = 0;\n let line = \"\";\n let currentMaxSize = 0;\n\n for (const word of text.split(\" \")) {\n const size = context.measureText(word).width;\n lineWidth += size + spaceWidth;\n\n if (line === \"\") {\n line = word;\n\n continue;\n }\n if (lineWidth > maxWidth) {\n const initialSize = lineWidth - size - spaceWidth;\n if (initialSize > currentMaxSize) currentMaxSize = initialSize;\n\n lineWidth = size;\n lines.push(line);\n line = word;\n } else {\n lineWidth += spaceWidth;\n line += `${SPACE}${word}`;\n }\n }\n\n if (line !== \"\") lines.push(line);\n if (lineWidth > currentMaxSize) currentMaxSize = lineWidth;\n\n return { lines, currentMaxSize };\n}\n"],"names":[],"mappings":"AAoBA,MAAM,KAAK,GAAG,GAAG;AAED,SAAA,QAAQ,CAAC,EACvB,OAAO,EACP,EAAE,EACF,SAAS,EACT,SAAS,EACT,QAAQ,EACR,SAAS,EACT,OAAO,EACP,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,CAAC,EACD,CAAC,EACD,cAAc,EACd,QAAQ,GACQ,EAAA;AAChB,IAAA,OAAO,CAAC,IAAI,GAAG,CAAA,EAAG,SAAS,CAAA,QAAA,EAAW,UAAU,CAAA,CAAA,EAAI,QAAQ,CAAA,GAAA,EAAM,QAAQ,CAAA,CAAE;AAC5E,IAAA,OAAO,CAAC,SAAS,GAAG,SAAS;AAC7B,IAAA,OAAO,CAAC,SAAS,GAAG,SAAS;AAE7B,IAAA,IAAI,cAAc,CAAC,EAA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CAAC,SAAS,GAAG,SAAS;AAC7B,IAAA,OAAO,CAAC,SAAS,GAAG,SAAS;IAE7B,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK;IACjD,MAAM,KAAK,GAAa,EAAE;IAC1B,IAAI,SAAS,GAAG,CAAC;IACjB,IAAI,IAAI,GAAG,EAAE;IACb,IAAI,cAAc,GAAG,CAAC;IAEtB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QAClC,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK;AAC5C,QAAA,SAAS,IAAI,IAAI,GAAG,UAAU;AAE9B,QAAA,IAAI,IAAI,KAAK,EAAE,EAAE;YACf,IAAI,GAAG,IAAI;YAEX;;AAEF,QAAA,IAAI,SAAS,GAAG,QAAQ,EAAE;AACxB,YAAA,MAAM,WAAW,GAAG,SAAS,GAAG,IAAI,GAAG,UAAU;YACjD,IAAI,WAAW,GAAG,cAAc;gBAAE,cAAc,GAAG,WAAW;YAE9D,SAAS,GAAG,IAAI;AAChB,YAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAChB,IAAI,GAAG,IAAI;;aACN;YACL,SAAS,IAAI,UAAU;AACvB,YAAA,IAAI,IAAI,CAAG,EAAA,KAAK,CAAG,EAAA,IAAI,EAAE;;;IAI7B,IAAI,IAAI,KAAK,EAAE;AAAE,QAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;IACjC,IAAI,SAAS,GAAG,cAAc;QAAE,cAAc,GAAG,SAAS;AAE1D,IAAA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE;AAClC;;;;"}
@@ -0,0 +1,31 @@
1
+ import { create } from 'd3-selection';
2
+
3
+ function initArea() {
4
+ if (!this.area || !this.context || !this.container) {
5
+ this.container = create("div")
6
+ .attr("style", "padding: 0 !important; width: 100%; height: 100%;")
7
+ .node();
8
+ if (!this.container)
9
+ throw new Error("couldn't create container");
10
+ this.root.appendChild(this.container);
11
+ const { width, height } = this.root.getBoundingClientRect();
12
+ this.width = width;
13
+ this.height = height;
14
+ this.area = create("canvas")
15
+ .attr("width", this.dpi * this.width)
16
+ .attr("height", this.dpi * this.height)
17
+ .attr("style", `width: 100%; height: 100%; border: none !important;`)
18
+ .node();
19
+ if (!this.area)
20
+ throw new Error("couldn't create canvas");
21
+ this.container.appendChild(this.area);
22
+ this.areaRect = this.area.getBoundingClientRect();
23
+ this.context = this.area.getContext("2d");
24
+ if (!this.context)
25
+ throw new Error("couldn't create canvas context");
26
+ this.context.scale(this.dpi, this.dpi);
27
+ }
28
+ }
29
+
30
+ export { initArea };
31
+ //# sourceMappingURL=init-area.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-area.js","sources":["../../../../../src/module/GraphCanvas/slices/init-area.ts"],"sourcesContent":["import { create as d3Create } from \"d3-selection\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\n\nexport function initArea<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.area || !this.context || !this.container) {\n this.container = d3Create(\"div\")\n .attr(\"style\", \"padding: 0 !important; width: 100%; height: 100%;\")\n .node();\n if (!this.container) throw new Error(\"couldn't create container\");\n this.root.appendChild(this.container);\n\n const { width, height } = this.root.getBoundingClientRect();\n this.width = width;\n this.height = height;\n\n this.area = d3Create(\"canvas\")\n .attr(\"width\", this.dpi * this.width)\n .attr(\"height\", this.dpi * this.height)\n .attr(\"style\", `width: 100%; height: 100%; border: none !important;`)\n .node();\n\n if (!this.area) throw new Error(\"couldn't create canvas\");\n this.container.appendChild(this.area);\n this.areaRect = this.area.getBoundingClientRect();\n\n this.context = this.area.getContext(\"2d\");\n if (!this.context) throw new Error(\"couldn't create canvas context\");\n this.context.scale(this.dpi, this.dpi);\n }\n}\n"],"names":["d3Create"],"mappings":";;SAGgB,QAAQ,GAAA;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CAAC;AACpE,QAAA,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;;AAE1C;;;;"}
@@ -0,0 +1,62 @@
1
+ import { isBoolean } from '@krainovsd/js-helpers';
2
+ import { greatest } from 'd3-array';
3
+ import { drag } from 'd3-drag';
4
+ import { select } from 'd3-selection';
5
+ import { pointerGetter } from '../lib/utils/pointer-getter.js';
6
+
7
+ function initDnd() {
8
+ if (!this.area || !this.nodes)
9
+ throw new Error("bad init data");
10
+ const dragHandler = drag()
11
+ .subject((event) => {
12
+ if (this.listeners.onDragSubject) {
13
+ return this.listeners.onDragSubject(event, this.state);
14
+ }
15
+ if (!this.areaRect)
16
+ return;
17
+ const mouseEvent = event.sourceEvent;
18
+ const [pointerX, pointerY] = pointerGetter(mouseEvent, this.areaRect, this.areaTransform);
19
+ return greatest(this.nodes, (node) => {
20
+ if (!node.x || !node.y || (isBoolean(node.drag) && !node.drag))
21
+ return undefined;
22
+ return this.graphSettings.dragPlaceCoefficient(node, pointerX, pointerY);
23
+ });
24
+ })
25
+ .on("start", (event) => {
26
+ this.listeners.onStartDragFinished?.(event, this.state);
27
+ })
28
+ .on("drag", (event) => {
29
+ if (!this.isDragging) {
30
+ this.isDragging = true;
31
+ if (this.simulation)
32
+ this.simulation.alphaTarget(0.3).restart();
33
+ }
34
+ if (!this.areaRect)
35
+ return;
36
+ const mouseEvent = event.sourceEvent;
37
+ const [pointerX, pointerY] = pointerGetter(mouseEvent, this.areaRect, this.areaTransform);
38
+ event.subject.fx = pointerX;
39
+ event.subject.fy = pointerY;
40
+ this.listeners.onMoveDragFinished?.(event, this.state);
41
+ })
42
+ .on("end", (event) => {
43
+ this.isDragging = false;
44
+ if (!event.active && this.simulation)
45
+ this.simulation.alphaTarget(0);
46
+ const sourceEvent = event.sourceEvent;
47
+ if (sourceEvent.altKey && this.areaRect) {
48
+ const [pointerX, pointerY] = pointerGetter(sourceEvent, this.areaRect, this.areaTransform);
49
+ event.subject.fx = pointerX;
50
+ event.subject.fy = pointerY;
51
+ }
52
+ else {
53
+ event.subject.fx = null;
54
+ event.subject.fy = null;
55
+ }
56
+ this.listeners.onEndDragFinished?.(event, this.state);
57
+ });
58
+ select(this.area).call(dragHandler);
59
+ }
60
+
61
+ export { initDnd };
62
+ //# sourceMappingURL=init-dnd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-dnd.js","sources":["../../../../../src/module/GraphCanvas/slices/init-dnd.ts"],"sourcesContent":["import { isBoolean } from \"@krainovsd/js-helpers\";\nimport { greatest } from \"d3-array\";\nimport { drag as d3Drag } from \"d3-drag\";\nimport { select as d3Select } from \"d3-selection\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport { pointerGetter } from \"../lib\";\nimport type { DragEventInterface } from \"../types\";\n\nexport function initDnd<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.area || !this.nodes) throw new Error(\"bad init data\");\n\n const dragHandler = d3Drag<HTMLCanvasElement, unknown>()\n .subject((event: DragEventInterface<NodeData>) => {\n if (this.listeners.onDragSubject) {\n return this.listeners.onDragSubject(event, this.state);\n }\n\n if (!this.areaRect) return;\n\n const mouseEvent = event.sourceEvent as MouseEvent | TouchEvent;\n const [pointerX, pointerY] = pointerGetter(mouseEvent, this.areaRect, this.areaTransform);\n\n return greatest(this.nodes, (node) => {\n if (!node.x || !node.y || (isBoolean(node.drag) && !node.drag)) return undefined;\n\n return this.graphSettings.dragPlaceCoefficient(node, pointerX, pointerY);\n });\n })\n .on(\"start\", (event: DragEventInterface<NodeData>) => {\n this.listeners.onStartDragFinished?.(event, this.state);\n })\n .on(\"drag\", (event: DragEventInterface<NodeData>) => {\n if (!this.isDragging) {\n this.isDragging = true;\n if (this.simulation) this.simulation.alphaTarget(0.3).restart();\n }\n\n if (!this.areaRect) return;\n const mouseEvent = event.sourceEvent as MouseEvent | TouchEvent;\n const [pointerX, pointerY] = pointerGetter(mouseEvent, this.areaRect, this.areaTransform);\n event.subject.fx = pointerX;\n event.subject.fy = pointerY;\n\n this.listeners.onMoveDragFinished?.(event, this.state);\n })\n .on(\"end\", (event: DragEventInterface<NodeData>) => {\n this.isDragging = false;\n\n if (!event.active && this.simulation) this.simulation.alphaTarget(0);\n\n const sourceEvent = event.sourceEvent as MouseEvent | TouchEvent;\n if (sourceEvent.altKey && this.areaRect) {\n const [pointerX, pointerY] = pointerGetter(sourceEvent, this.areaRect, this.areaTransform);\n event.subject.fx = pointerX;\n event.subject.fy = pointerY;\n } else {\n event.subject.fx = null;\n event.subject.fy = null;\n }\n\n this.listeners.onEndDragFinished?.(event, this.state);\n });\n\n d3Select(this.area).call(dragHandler);\n}\n"],"names":["d3Drag","d3Select"],"mappings":";;;;;;SAQgB,OAAO,GAAA;IAIrB,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC;IAE/D,MAAM,WAAW,GAAGA,IAAM;AACvB,SAAA,OAAO,CAAC,CAAC,KAAmC,KAAI;AAC/C,QAAA,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE;AAChC,YAAA,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC;;QAGxD,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE;AAEpB,QAAA,MAAM,UAAU,GAAG,KAAK,CAAC,WAAsC;AAC/D,QAAA,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC;QAEzF,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,KAAI;YACnC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KA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AAE,YAAA,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;AAEpE,QAAA,MAAM,WAAW,GAAG,KAAK,CAAC,WAAsC;QAChE,IAAI,WAAW,CAAC,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE;AACvC,YAAA,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC;AAC1F,YAAA,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,QAAQ;AAC3B,YAAA,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,QAAQ;;aACtB;AACL,YAAA,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI;AACvB,YAAA,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI;;AAGzB,QAAA,IAAI,CAAC,SAAS,CAAC,iBAAiB,GAAG,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC;AACvD,KAAC,CAAC;IAEJC,MAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;AACvC;;;;"}
@@ -0,0 +1,84 @@
1
+ import '@krainovsd/js-helpers';
2
+ import 'd3-array';
3
+ import { setDrawTime } from '../../../lib/draw-time.js';
4
+ import { getDrawLink } from './draw-links.js';
5
+ import { getDrawNode } from './draw-nodes.js';
6
+
7
+ function initDraw() {
8
+ function calculateHighlight() {
9
+ this.highlightDrawing = true;
10
+ if (!this.highlightWorking && this.highlightProgress > 0) {
11
+ const highlightDownStep = 1 / this.graphSettings.highlightDownFrames;
12
+ this.highlightProgress -= highlightDownStep;
13
+ if (!this.simulationWorking) {
14
+ return void requestAnimationFrame(() => this.draw());
15
+ }
16
+ if (!this.linkSettings.particles)
17
+ return;
18
+ }
19
+ if (this.highlightWorking && this.highlightProgress < 1) {
20
+ const highlightUpStep = 1 / this.graphSettings.highlightUpFrames;
21
+ this.highlightProgress += highlightUpStep;
22
+ if (!this.simulationWorking) {
23
+ return void requestAnimationFrame(() => this.draw());
24
+ }
25
+ if (!this.linkSettings.particles)
26
+ return;
27
+ }
28
+ if (this.linkSettings.particles && this.highlightWorking && !this.simulationWorking) {
29
+ return void requestAnimationFrame(() => this.draw());
30
+ }
31
+ if (!this.highlightWorking && this.highlightProgress <= 0) {
32
+ if (this.highlightedNeighbors || this.highlightedNode || this.highlightedLink) {
33
+ this.highlightedNeighbors = null;
34
+ this.highlightedNode = null;
35
+ this.highlightedLink = null;
36
+ this.particles = {};
37
+ if (!this.simulationWorking) {
38
+ return void requestAnimationFrame(() => this.draw());
39
+ }
40
+ }
41
+ }
42
+ this.highlightDrawing = false;
43
+ }
44
+ function draw() {
45
+ if (!this.context)
46
+ return;
47
+ const state = this.state;
48
+ if (this.listeners.onDraw) {
49
+ this.listeners.onDraw(state, (status) => {
50
+ this.highlightDrawing = status;
51
+ }, () => {
52
+ if (this.highlightedNeighbors)
53
+ this.highlightedNeighbors = null;
54
+ if (this.highlightedNode)
55
+ this.highlightedNode = null;
56
+ if (this.highlightedLink)
57
+ this.highlightedLink = null;
58
+ });
59
+ return;
60
+ }
61
+ this.context.save();
62
+ this.context.clearRect(0, 0, this.width, this.height);
63
+ this.context.translate(this.areaTransform.x, this.areaTransform.y);
64
+ this.context.scale(this.areaTransform.k, this.areaTransform.k);
65
+ const textRenders = [];
66
+ const nodeRenders = [];
67
+ this.nodes.forEach(getDrawNode(nodeRenders, textRenders, state).bind(this));
68
+ /** links */
69
+ this.links.forEach(getDrawLink(state).bind(this));
70
+ /** nodes */
71
+ nodeRenders.forEach((render) => render());
72
+ textRenders.forEach((render) => render());
73
+ this.context.restore();
74
+ this.listeners.onDrawFinished?.(state);
75
+ calculateHighlight.bind(this)();
76
+ }
77
+ if (this.graphSettings.showDrawTime) {
78
+ return setDrawTime(draw.bind(this), this.graphSettings.showDrawTimeEveryTick);
79
+ }
80
+ return draw.bind(this);
81
+ }
82
+
83
+ export { initDraw };
84
+ //# sourceMappingURL=init-draw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-draw.js","sources":["../../../../../src/module/GraphCanvas/slices/init-draw.ts"],"sourcesContent":["import { setDrawTime } from \"@/lib\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport { getDrawLink } from \"./draw-links\";\nimport { getDrawNode } from \"./draw-nodes\";\n\nexport function initDraw<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n function calculateHighlight(this: GraphCanvas<NodeData, LinkData>) {\n this.highlightDrawing = true;\n\n if (!this.highlightWorking && this.highlightProgress > 0) {\n const highlightDownStep = 1 / this.graphSettings.highlightDownFrames;\n this.highlightProgress -= highlightDownStep;\n\n if (!this.simulationWorking) {\n return void requestAnimationFrame(() => this.draw());\n }\n\n if (!this.linkSettings.particles) return;\n }\n if (this.highlightWorking && this.highlightProgress < 1) {\n const highlightUpStep = 1 / this.graphSettings.highlightUpFrames;\n this.highlightProgress += highlightUpStep;\n\n if (!this.simulationWorking) {\n return void requestAnimationFrame(() => this.draw());\n }\n\n if (!this.linkSettings.particles) return;\n }\n\n if (this.linkSettings.particles && this.highlightWorking && !this.simulationWorking) {\n return void requestAnimationFrame(() => this.draw());\n }\n\n if (!this.highlightWorking && this.highlightProgress <= 0) {\n if (this.highlightedNeighbors || this.highlightedNode || this.highlightedLink) {\n this.highlightedNeighbors = null;\n this.highlightedNode = null;\n this.highlightedLink = null;\n this.particles = {};\n\n if (!this.simulationWorking) {\n return void requestAnimationFrame(() => this.draw());\n }\n }\n }\n\n this.highlightDrawing = false;\n }\n\n function draw(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.context) return;\n const state = this.state;\n\n if (this.listeners.onDraw) {\n this.listeners.onDraw(\n state,\n (status) => {\n this.highlightDrawing = status;\n },\n () => {\n if (this.highlightedNeighbors) this.highlightedNeighbors = null;\n if (this.highlightedNode) this.highlightedNode = null;\n if (this.highlightedLink) this.highlightedLink = null;\n },\n );\n\n return;\n }\n\n this.context.save();\n this.context.clearRect(0, 0, this.width, this.height);\n this.context.translate(this.areaTransform.x, this.areaTransform.y);\n this.context.scale(this.areaTransform.k, this.areaTransform.k);\n\n const textRenders: (() => void)[] = [];\n const nodeRenders: (() => void)[] = [];\n this.nodes.forEach(getDrawNode(nodeRenders, textRenders, state).bind(this));\n\n /** links */\n this.links.forEach(getDrawLink(state).bind(this));\n\n /** nodes */\n\n nodeRenders.forEach((render) => render());\n textRenders.forEach((render) => render());\n\n this.context.restore();\n\n this.listeners.onDrawFinished?.(state);\n\n calculateHighlight.bind(this)();\n }\n\n if (this.graphSettings.showDrawTime) {\n return setDrawTime(draw.bind(this), this.graphSettings.showDrawTimeEveryTick);\n }\n\n return draw.bind(this);\n}\n"],"names":[],"mappings":";;;;;;SAKgB,QAAQ,GAAA;AAItB,IAAA,SAAS,kBAAkB,GAAA;AACzB,QAAA,IAAI,CAAC,gBAAgB,GAAG,IAAI;QAE5B,IAAI,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,iBAAiB,GAAG,CAAC,EAAE;YACxD,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,mBAAmB;AACpE,YAAA,IAAI,CAAC,iBAAiB,IAAI,iBAAiB;AAE3C,YAAA,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;gBAC3B,OAAO,KAAK,qBAAqB,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;;AAGtD,YAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS;gBAAE;;QAEpC,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,iBAAiB,GAAG,CAAC,EAAE;YACvD,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,iBAAiB;AAChE,YAAA,IAAI,CAAC,iBAAiB,IAAI,eAAe;AAEzC,YAAA,IAAI,CAAC,IAAI,CAAC,iB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AC,aAAa,CAAC,YAAY,EAAE;AACnC,QAAA,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAAC;;AAG/E,IAAA,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACxB;;;;"}
@@ -0,0 +1,211 @@
1
+ import { isObject } from 'lodash';
2
+ import { checkType } from '../../../lib/check-type.js';
3
+ import '@krainovsd/js-helpers';
4
+ import { nodeByPointerGetter } from '../lib/utils/node-by-pointer-getter.js';
5
+ import { linkByPointerGetter } from '../lib/utils/link-by-pointer-getter.js';
6
+
7
+ function initPointer() {
8
+ if (!this.area || !this.nodes)
9
+ throw new Error("bad init data");
10
+ function onHover(event) {
11
+ if (!this.area)
12
+ return;
13
+ let currentNode;
14
+ let currentLink;
15
+ const checkHighlightNode = this.nodeSettings.highlightByHoverNode && !this.isDragging;
16
+ const checkHighlightLink = this.linkSettings.highlightByHoverLink && !this.isDragging;
17
+ if (checkHighlightNode) {
18
+ currentNode = nodeByPointerGetter({
19
+ areaRect: this.areaRect,
20
+ areaTransform: this.areaTransform,
21
+ mouseEvent: event,
22
+ nodes: this.nodes,
23
+ });
24
+ }
25
+ if (currentNode) {
26
+ this.area.style.cursor = "pointer";
27
+ }
28
+ else if (checkHighlightLink) {
29
+ currentLink = linkByPointerGetter({
30
+ linkSettings: this.linkSettings,
31
+ areaRect: this.areaRect,
32
+ areaTransform: this.areaTransform,
33
+ mouseEvent: event,
34
+ links: this.links,
35
+ });
36
+ if (currentLink) {
37
+ this.area.style.cursor = "pointer";
38
+ }
39
+ else {
40
+ this.area.style.cursor = "default";
41
+ }
42
+ }
43
+ else {
44
+ this.area.style.cursor = "default";
45
+ }
46
+ if (currentNode && this.highlightedNode !== currentNode) {
47
+ this.highlightedNode = currentNode;
48
+ this.highlightedLink = null;
49
+ this.highlightedNeighbors = new Set(this.highlightedNode?.neighbors ?? []);
50
+ this.highlightWorking = true;
51
+ if (!this.simulationWorking && !this.highlightDrawing)
52
+ requestAnimationFrame(() => {
53
+ this.draw();
54
+ });
55
+ }
56
+ else if (currentLink &&
57
+ checkType(currentLink.source, isObject(currentLink.source)) &&
58
+ checkType(currentLink.target, isObject(currentLink.target)) &&
59
+ this.highlightedLink !== currentLink) {
60
+ this.highlightProgress = 0;
61
+ this.highlightedLink = currentLink;
62
+ this.highlightedNode = null;
63
+ this.highlightedNeighbors = new Set([currentLink.source.id, currentLink.target.id]);
64
+ this.highlightWorking = true;
65
+ if (!this.simulationWorking && !this.highlightDrawing)
66
+ requestAnimationFrame(() => {
67
+ this.draw();
68
+ });
69
+ }
70
+ else if (!currentNode && !currentLink && (this.highlightedNode || this.highlightedLink)) {
71
+ this.highlightWorking = false;
72
+ if (!this.simulationWorking && !this.highlightDrawing)
73
+ requestAnimationFrame(() => {
74
+ this.draw();
75
+ });
76
+ }
77
+ if (!this.listeners.onMove)
78
+ return;
79
+ if (!currentNode && !checkHighlightNode)
80
+ currentNode = nodeByPointerGetter({
81
+ areaRect: this.areaRect,
82
+ areaTransform: this.areaTransform,
83
+ mouseEvent: event,
84
+ nodes: this.nodes,
85
+ });
86
+ if (!currentNode && (!checkHighlightNode || (!checkHighlightLink && !currentLink))) {
87
+ currentLink = linkByPointerGetter({
88
+ linkSettings: this.linkSettings,
89
+ areaRect: this.areaRect,
90
+ areaTransform: this.areaTransform,
91
+ mouseEvent: event,
92
+ links: this.links,
93
+ });
94
+ }
95
+ if (!currentNode)
96
+ return void this.listeners.onMove(event, currentNode, currentLink);
97
+ }
98
+ function onWheelClick(event) {
99
+ if (this.isDragging ||
100
+ !this.listeners.onWheelClick ||
101
+ !("button" in event) ||
102
+ event.button !== 1)
103
+ return;
104
+ const currentNode = nodeByPointerGetter({
105
+ areaRect: this.areaRect,
106
+ areaTransform: this.areaTransform,
107
+ mouseEvent: event,
108
+ nodes: this.nodes,
109
+ });
110
+ if (!currentNode) {
111
+ const currentLink = linkByPointerGetter({
112
+ linkSettings: this.linkSettings,
113
+ areaRect: this.areaRect,
114
+ areaTransform: this.areaTransform,
115
+ mouseEvent: event,
116
+ links: this.links,
117
+ });
118
+ return void this.listeners.onWheelClick(event, undefined, currentLink);
119
+ }
120
+ return void this.listeners.onWheelClick(event, currentNode, undefined);
121
+ }
122
+ function onRightClick(event) {
123
+ if (!this.listeners.onContextMenu)
124
+ return;
125
+ const currentNode = nodeByPointerGetter({
126
+ areaRect: this.areaRect,
127
+ areaTransform: this.areaTransform,
128
+ mouseEvent: event,
129
+ nodes: this.nodes,
130
+ });
131
+ if (!currentNode) {
132
+ const currentLink = linkByPointerGetter({
133
+ linkSettings: this.linkSettings,
134
+ areaRect: this.areaRect,
135
+ areaTransform: this.areaTransform,
136
+ mouseEvent: event,
137
+ links: this.links,
138
+ });
139
+ return void this.listeners.onContextMenu(event, undefined, currentLink);
140
+ }
141
+ return void this.listeners.onContextMenu(event, currentNode, undefined);
142
+ }
143
+ function onDoubleClick(event) {
144
+ if (!this.listeners.onDoubleClick)
145
+ return;
146
+ const currentNode = nodeByPointerGetter({
147
+ areaRect: this.areaRect,
148
+ areaTransform: this.areaTransform,
149
+ mouseEvent: event,
150
+ nodes: this.nodes,
151
+ });
152
+ if (!currentNode) {
153
+ const currentLink = linkByPointerGetter({
154
+ linkSettings: this.linkSettings,
155
+ areaRect: this.areaRect,
156
+ areaTransform: this.areaTransform,
157
+ mouseEvent: event,
158
+ links: this.links,
159
+ });
160
+ return void this.listeners.onDoubleClick(event, undefined, currentLink);
161
+ }
162
+ return void this.listeners.onDoubleClick(event, currentNode, undefined);
163
+ }
164
+ function onClick(event) {
165
+ if (this.isDragging || !this.listeners.onClick || ("button" in event && event.button !== 0))
166
+ return;
167
+ const currentNode = nodeByPointerGetter({
168
+ areaRect: this.areaRect,
169
+ areaTransform: this.areaTransform,
170
+ mouseEvent: event,
171
+ nodes: this.nodes,
172
+ });
173
+ if (!currentNode) {
174
+ const currentLink = linkByPointerGetter({
175
+ linkSettings: this.linkSettings,
176
+ areaRect: this.areaRect,
177
+ areaTransform: this.areaTransform,
178
+ mouseEvent: event,
179
+ links: this.links,
180
+ });
181
+ return void this.listeners.onClick(event, undefined, currentLink);
182
+ }
183
+ return void this.listeners.onClick(event, currentNode, undefined);
184
+ }
185
+ /** hover */
186
+ this.area.addEventListener("mousemove", onHover.bind(this), {
187
+ signal: this.eventAbortController.signal,
188
+ });
189
+ this.area.addEventListener("touchmove", onHover.bind(this), {
190
+ signal: this.eventAbortController.signal,
191
+ });
192
+ /** dblclick */
193
+ this.area.addEventListener("dblclick", onDoubleClick.bind(this), {
194
+ signal: this.eventAbortController.signal,
195
+ });
196
+ /** wheel click */
197
+ this.area.addEventListener("mousedown", onWheelClick.bind(this), {
198
+ signal: this.eventAbortController.signal,
199
+ });
200
+ /** click */
201
+ this.area.addEventListener("click", onClick.bind(this), {
202
+ signal: this.eventAbortController.signal,
203
+ });
204
+ /** right click */
205
+ this.area.addEventListener("contextmenu", onRightClick.bind(this), {
206
+ signal: this.eventAbortController.signal,
207
+ });
208
+ }
209
+
210
+ export { initPointer };
211
+ //# sourceMappingURL=init-pointer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-pointer.js","sources":["../../../../../src/module/GraphCanvas/slices/init-pointer.ts"],"sourcesContent":["import { isObject } from \"lodash\";\nimport { checkType } from \"@/lib\";\nimport type { LinkInterface, NodeInterface } from \"@/types\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport { linkByPointerGetter, nodeByPointerGetter } from \"../lib\";\n\nexport function initPointer<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.area || !this.nodes) throw new Error(\"bad init data\");\n\n function onHover(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent | TouchEvent) {\n if (!this.area) return;\n\n let currentNode: NodeInterface<NodeData> | undefined;\n let currentLink: LinkInterface<NodeData, LinkData> | undefined;\n const checkHighlightNode = this.nodeSettings.highlightByHoverNode && !this.isDragging;\n const checkHighlightLink = this.linkSettings.highlightByHoverLink && !this.isDragging;\n\n if (checkHighlightNode) {\n currentNode = nodeByPointerGetter({\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n nodes: this.nodes,\n });\n }\n if (currentNode) {\n this.area.style.cursor = \"pointer\";\n } else if (checkHighlightLink) {\n currentLink = linkByPointerGetter({\n linkSettings: this.linkSettings,\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n links: this.links,\n });\n\n if (currentLink) {\n this.area.style.cursor = \"pointer\";\n } else {\n this.area.style.cursor = \"default\";\n }\n } else {\n this.area.style.cursor = \"default\";\n }\n if (currentNode && this.highlightedNode !== currentNode) {\n this.highlightedNode = currentNode;\n this.highlightedLink = null;\n this.highlightedNeighbors = new Set(this.highlightedNode?.neighbors ?? []);\n this.highlightWorking = true;\n\n if (!this.simulationWorking && !this.highlightDrawing)\n requestAnimationFrame(() => {\n this.draw();\n });\n } else if (\n currentLink &&\n checkType<NodeInterface<NodeData>>(currentLink.source, isObject(currentLink.source)) &&\n checkType<NodeInterface<NodeData>>(currentLink.target, isObject(currentLink.target)) &&\n this.highlightedLink !== currentLink\n ) {\n this.highlightProgress = 0;\n this.highlightedLink = currentLink;\n this.highlightedNode = null;\n this.highlightedNeighbors = new Set([currentLink.source.id, currentLink.target.id]);\n this.highlightWorking = true;\n\n if (!this.simulationWorking && !this.highlightDrawing)\n requestAnimationFrame(() => {\n this.draw();\n });\n } else if (!currentNode && !currentLink && (this.highlightedNode || this.highlightedLink)) {\n this.highlightWorking = false;\n if (!this.simulationWorking && !this.highlightDrawing)\n requestAnimationFrame(() => {\n this.draw();\n });\n }\n\n if (!this.listeners.onMove) return;\n\n if (!currentNode && !checkHighlightNode)\n currentNode = nodeByPointerGetter({\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n nodes: this.nodes,\n });\n if (!currentNode && (!checkHighlightNode || (!checkHighlightLink && !currentLink))) {\n currentLink = linkByPointerGetter({\n linkSettings: this.linkSettings,\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n links: this.links,\n });\n }\n\n if (!currentNode) return void this.listeners.onMove(event, currentNode, currentLink);\n }\n function onWheelClick(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent | TouchEvent) {\n if (\n this.isDragging ||\n !this.listeners.onWheelClick ||\n !(\"button\" in event) ||\n event.button !== 1\n )\n return;\n\n const currentNode = nodeByPointerGetter({\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n nodes: this.nodes,\n });\n\n if (!currentNode) {\n const currentLink = linkByPointerGetter({\n linkSettings: this.linkSettings,\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n links: this.links,\n });\n\n return void this.listeners.onWheelClick(event, undefined, currentLink);\n }\n\n return void this.listeners.onWheelClick(event, currentNode, undefined);\n }\n function onRightClick(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent) {\n if (!this.listeners.onContextMenu) return;\n\n const currentNode = nodeByPointerGetter({\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n nodes: this.nodes,\n });\n\n if (!currentNode) {\n const currentLink = linkByPointerGetter({\n linkSettings: this.linkSettings,\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n links: this.links,\n });\n\n return void this.listeners.onContextMenu(event, undefined, currentLink);\n }\n\n return void this.listeners.onContextMenu(event, currentNode, undefined);\n }\n function onDoubleClick(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent | TouchEvent) {\n if (!this.listeners.onDoubleClick) return;\n\n const currentNode = nodeByPointerGetter({\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n nodes: this.nodes,\n });\n if (!currentNode) {\n const currentLink = linkByPointerGetter({\n linkSettings: this.linkSettings,\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n links: this.links,\n });\n\n return void this.listeners.onDoubleClick(event, undefined, currentLink);\n }\n\n return void this.listeners.onDoubleClick(event, currentNode, undefined);\n }\n function onClick(this: GraphCanvas<NodeData, LinkData>, event: MouseEvent | TouchEvent) {\n if (this.isDragging || !this.listeners.onClick || (\"button\" in event && event.button !== 0))\n return;\n const currentNode = nodeByPointerGetter({\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n nodes: this.nodes,\n });\n if (!currentNode) {\n const currentLink = linkByPointerGetter({\n linkSettings: this.linkSettings,\n areaRect: this.areaRect,\n areaTransform: this.areaTransform,\n mouseEvent: event,\n links: this.links,\n });\n\n return void this.listeners.onClick(event, undefined, currentLink);\n }\n\n return void this.listeners.onClick(event, currentNode, undefined);\n }\n\n /** hover */\n this.area.addEventListener(\"mousemove\", onHover.bind(this), {\n signal: this.eventAbortController.signal,\n });\n this.area.addEventListener(\"touchmove\", onHover.bind(this), {\n signal: this.eventAbortController.signal,\n });\n\n /** dblclick */\n this.area.addEventListener(\"dblclick\", onDoubleClick.bind(this), {\n signal: this.eventAbortController.signal,\n });\n\n /** wheel click */\n this.area.addEventListener(\"mousedown\", onWheelClick.bind(this), {\n signal: this.eventAbortController.signal,\n });\n\n /** click */\n this.area.addEventListener(\"click\", onClick.bind(this), {\n signal: this.eventAbortController.signal,\n });\n\n /** right click */\n this.area.addEventListener(\"contextmenu\", onRightClick.bind(this), {\n signal: this.eventAbortController.signal,\n });\n}\n"],"names":[],"mappings":";;;;;;SAMgB,WAAW,GAAA;IAIzB,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC;IAE/D,SAAS,OAAO,CAAwC,KAA8B,EAAA;QACpF,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE;AAEhB,QAAA,IAAI,WAAgD;AACpD,QAAA,IAAI,WAA0D;AAC9D,QAAA,MAAM,kBAAkB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aAAa,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AACjE,QAAA,MAAM,EAAE,IAAI,CAAC,oBAAoB,CAAC,MAAM;AACzC,KAAA,CAAC;AACJ;;;;"}
@@ -0,0 +1,28 @@
1
+ function initResize() {
2
+ if (!this.area)
3
+ throw new Error("bad init data");
4
+ let initialResizeCall = true;
5
+ const abortController = this.eventAbortController;
6
+ const observer = new ResizeObserver(() => {
7
+ if (initialResizeCall) {
8
+ initialResizeCall = false;
9
+ return;
10
+ }
11
+ if (abortController.signal.aborted) {
12
+ observer.disconnect();
13
+ return;
14
+ }
15
+ requestAnimationFrame(() => {
16
+ this.updateSize();
17
+ });
18
+ });
19
+ document.addEventListener("scroll", this.updateRect.bind(this), {
20
+ capture: true,
21
+ passive: true,
22
+ signal: abortController.signal,
23
+ });
24
+ observer.observe(this.area);
25
+ }
26
+
27
+ export { initResize };
28
+ //# sourceMappingURL=init-resize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-resize.js","sources":["../../../../../src/module/GraphCanvas/slices/init-resize.ts"],"sourcesContent":["import type { GraphCanvas } from \"../GraphCanvas\";\n\nexport function initResize<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.area) throw new Error(\"bad init data\");\n\n let initialResizeCall = true;\n\n const abortController = this.eventAbortController;\n const observer = new ResizeObserver(() => {\n if (initialResizeCall) {\n initialResizeCall = false;\n\n return;\n }\n\n if (abortController.signal.aborted) {\n observer.disconnect();\n\n return;\n }\n\n requestAnimationFrame(() => {\n this.updateSize();\n });\n });\n\n document.addEventListener(\"scroll\", this.updateRect.bind(this), {\n capture: true,\n passive: true,\n signal: abortController.signal,\n });\n\n observer.observe(this.area);\n}\n"],"names":[],"mappings":"SAEgB,UAAU,GAAA;IAIxB,IAAI,CAAC,IAAI,CAAC,IAAI;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC;IAEhD,IAAI,iBAAiB,GAAG,IAAI;AAE5B,IAAA,MAAM,eAAe,GAAG,IAAI,CAAC,oBAAoB;AACjD,IAAA,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,MAAK;QACvC,IAAI,iBAAiB,EAAE;YACrB,iBAAiB,GAAG,KAAK;YAEzB;;AAGF,QAAA,IAAI,eAAe,CAAC,MAAM,CAAC,OAAO,EAAE;YAClC,QAAQ,CAAC,UAAU,EAAE;YAErB;;QAGF,qBAAqB,CAAC,MAAK;YACzB,IAAI,CAAC,UAAU,EAAE;AACnB,SAAC,CAAC;AACJ,KAAC,CAAC;AAEF,IAAA,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AAC9D,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,eAAe,CAAC,MAAM;AAC/B,KAAA,CAAC;AAEF,IAAA,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;AAC7B;;;;"}