@cyber-harbour/ui 1.0.40 → 1.0.42

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": "@cyber-harbour/ui",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,24 @@
1
+ import { SVGProps } from 'react';
2
+
3
+ interface CloseCircleIconProps extends SVGProps<SVGSVGElement> {
4
+ fill?: string;
5
+ }
6
+
7
+ export const CloseCircleIcon = ({ fill = 'currentColor', ...props }: CloseCircleIconProps) => {
8
+ return (
9
+ <svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
10
+ <path
11
+ d="M7.99992 15.1654C4.04659 15.1654 0.833252 11.952 0.833252 7.9987C0.833252 4.04536 4.04659 0.832031 7.99992 0.832031C11.9533 0.832031 15.1666 4.04536 15.1666 7.9987C15.1666 11.952 11.9533 15.1654 7.99992 15.1654ZM7.99992 1.83203C4.59992 1.83203 1.83325 4.5987 1.83325 7.9987C1.83325 11.3987 4.59992 14.1654 7.99992 14.1654C11.3999 14.1654 14.1666 11.3987 14.1666 7.9987C14.1666 4.5987 11.3999 1.83203 7.99992 1.83203Z"
12
+ fill={fill}
13
+ />
14
+ <path
15
+ d="M6.11332 10.3849C5.98666 10.3849 5.85999 10.3383 5.75999 10.2383C5.56666 10.0449 5.56666 9.72495 5.75999 9.53161L9.53332 5.75828C9.72666 5.56495 10.0467 5.56495 10.24 5.75828C10.4333 5.95161 10.4333 6.27161 10.24 6.46495L6.46666 10.2383C6.37332 10.3383 6.23999 10.3849 6.11332 10.3849Z"
16
+ fill={fill}
17
+ />
18
+ <path
19
+ d="M9.88666 10.3849C9.75999 10.3849 9.63332 10.3383 9.53332 10.2383L5.75999 6.46495C5.56666 6.27161 5.56666 5.95161 5.75999 5.75828C5.95332 5.56495 6.27332 5.56495 6.46666 5.75828L10.24 9.53161C10.4333 9.72495 10.4333 10.0449 10.24 10.2383C10.14 10.3383 10.0133 10.3849 9.88666 10.3849Z"
20
+ fill={fill}
21
+ />
22
+ </svg>
23
+ );
24
+ };
@@ -6,6 +6,7 @@ export { BugReportIcon } from './BugReportIcon';
6
6
  export { CalendarIcon } from './CalendarIcon';
7
7
  export { ChevronLeftIcon } from './ChevronLeftIcon';
8
8
  export { ChevronRightIcon } from './ChevronRightIcon';
9
+ export { CloseCircleIcon } from './CloseCircleIcon';
9
10
  export { ClosedLockIcon } from './ClosedLockIcon';
10
11
  export { DataSetsIcon } from './DataSetsIcon';
11
12
  export { DeepSearchIcon } from './DeepSearchIcon';
@@ -43,6 +43,7 @@ export const Graph2D = ({
43
43
  onLinkHover,
44
44
  onLinkClick,
45
45
  onBackgroundClick,
46
+ onClickLoadNodes,
46
47
  }: Graph2DProps) => {
47
48
  const theme = useTheme();
48
49
 
@@ -53,7 +54,6 @@ export const Graph2D = ({
53
54
  const [selectedNode, setSelectedNode] = useState<any>(null);
54
55
  const [unVisibleNodes, setUnVisibleNodes] = useState(new Set<string>());
55
56
  const [hiddenNodes, setHiddenNodes] = useState(new Set<string>());
56
- const [collapsedNodes, setCollapsedNodes] = useState(new Set<string>());
57
57
  // Стани для відстеження наведення на кнопки
58
58
  const [hoverTopButton, setHoverTopButton] = useState(false);
59
59
  const [hoverBottomButton, setHoverBottomButton] = useState(false);
@@ -142,14 +142,26 @@ export const Graph2D = ({
142
142
  }
143
143
  tickTimerRef.current = setTimeout(() => {
144
144
  //force tick check
145
- fgRef.current.zoomToFit(0, 20);
146
- setIsRendering(false);
145
+ if (fgRef.current) {
146
+ fgRef.current.zoomToFit(0, 20);
147
+ setIsRendering(false);
148
+ }
147
149
  }, 1500);
148
150
  }
149
151
  }
150
152
  }
151
153
  };
152
154
 
155
+ useEffect(() => {
156
+ const timeoutRef = tickTimerRef.current;
157
+
158
+ return () => {
159
+ if (timeoutRef) {
160
+ clearTimeout(timeoutRef);
161
+ }
162
+ };
163
+ }, []);
164
+
153
165
  // Створення взаємозв'язків між вузлами
154
166
  useEffect(() => {
155
167
  if (!graphData) return;
@@ -349,9 +361,7 @@ export const Graph2D = ({
349
361
  if (unvisibles.has(`${link.target.id}`)) {
350
362
  if (!hiddenNodes.has(`${link.target.id}`)) {
351
363
  unvisibles.delete(`${link.target.id}`);
352
- if (!collapsedNodes.has(`${link.target.id}`)) {
353
- showNode(unvisibles, link.target);
354
- }
364
+ showNode(unvisibles, link.target);
355
365
  }
356
366
  }
357
367
  });
@@ -373,21 +383,6 @@ export const Graph2D = ({
373
383
  setUnVisibleNodes(newUnVisibleNodes);
374
384
  };
375
385
 
376
- // Функція для обробки кліку на кнопку "згорнути дочірні вузли"
377
- const handleCollapseChildren = (node: any) => {
378
- const newCollapsedNodes = new Set(collapsedNodes);
379
- const newUnVisibleNodes = new Set(unVisibleNodes);
380
- if (newCollapsedNodes.has(node.id)) {
381
- newCollapsedNodes.delete(node.id);
382
- showNode(newUnVisibleNodes, node);
383
- } else {
384
- newCollapsedNodes.add(node.id);
385
- hideNode(newUnVisibleNodes, node);
386
- }
387
- setCollapsedNodes(newCollapsedNodes);
388
- setUnVisibleNodes(newUnVisibleNodes);
389
- };
390
-
391
386
  // Функція для визначення, чи знаходиться точка в межах сектора кола (кнопки)
392
387
  const isPointInButtonArea = useCallback(
393
388
  (
@@ -493,7 +488,7 @@ export const Graph2D = ({
493
488
  nodeScreenY = graphCenter.y + nodeY * zoom;
494
489
  }
495
490
 
496
- // Перевіряємо наведення на верхню кнопку (hide)
491
+ // Перевіряємо наведення на верхню кнопку
497
492
  const isOverTopButton = isPointInButtonArea(
498
493
  scaledMouseX,
499
494
  scaledMouseY,
@@ -504,7 +499,7 @@ export const Graph2D = ({
504
499
  Math.PI * 2
505
500
  );
506
501
 
507
- // Перевіряємо наведення на нижню кнопку (collapse)
502
+ // Перевіряємо наведення на нижню кнопку
508
503
  const isOverBottomButton = isPointInButtonArea(
509
504
  scaledMouseX,
510
505
  scaledMouseY,
@@ -620,7 +615,7 @@ export const Graph2D = ({
620
615
  // Малюємо коло
621
616
  ctx.beginPath();
622
617
  ctx.arc(x as number, y as number, radius, 0, 2 * Math.PI);
623
- ctx.fillStyle = collapsedNodes.has(node.id as string) ? `${color}50` : color; // Колір контуру з opacity для згорнутих вузлів
618
+ ctx.fillStyle = color;
624
619
 
625
620
  ctx.fill();
626
621
 
@@ -889,7 +884,7 @@ export const Graph2D = ({
889
884
  return;
890
885
  }
891
886
 
892
- // Перевіряємо клік на нижній кнопці (collapse)
887
+ // Перевіряємо клік на нижній кнопці
893
888
  if (
894
889
  isPointInButtonArea(
895
890
  scaledClickX,
@@ -901,7 +896,7 @@ export const Graph2D = ({
901
896
  Math.PI // Кінцевий кут для нижньої півсфери
902
897
  )
903
898
  ) {
904
- handleCollapseChildren(hoverNode);
899
+ onClickLoadNodes?.(hoverNode);
905
900
  event.stopPropagation();
906
901
  return;
907
902
  }
@@ -960,7 +955,6 @@ export const Graph2D = ({
960
955
  // Перевіряємо, чи вузол прихований
961
956
  if (hiddenNodes.has(link.source.id) || hiddenNodes.has(link.target.id)) return false;
962
957
  // Перевіряємо, чи вузол згорнутий
963
- if (collapsedNodes.has(link.source.id)) return false;
964
958
  if (unVisibleNodes.has(link.source.id) || unVisibleNodes.has(link.target.id)) return false;
965
959
 
966
960
  return true; // Показуємо вузол, якщо не прихований і не згорнутий
@@ -25,4 +25,5 @@ export interface Graph2DProps {
25
25
  onNodeHover?: (node: NodeObject | null) => void;
26
26
  onLinkHover?: (link: NodeObject | null) => void;
27
27
  onBackgroundClick?: () => void;
28
+ onClickLoadNodes?: (node: NodeObject) => void;
28
29
  }