@cyber-harbour/ui 1.0.39 → 1.0.41

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.39",
3
+ "version": "1.0.41",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -50,6 +50,7 @@ const ButtonTextContainer = styled.div`
50
50
  text-overflow: ellipsis;
51
51
  overflow: hidden;
52
52
  white-space: nowrap;
53
+ user-select: text;
53
54
  `;
54
55
 
55
56
  const StyledIconWrapper = styled.span`
@@ -94,6 +95,7 @@ const StyledButton = styled(createComponent('button'))<{
94
95
  text-decoration: none;
95
96
  transition: all 0.2s ease;
96
97
  outline: none;
98
+ user-select: text;
97
99
 
98
100
  ${$iconPosition === 'right' ? 'flex-direction: row-reverse;' : ''}
99
101
 
@@ -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
  }