@cyber-harbour/ui 1.0.44 → 1.0.46

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.
@@ -1,29 +1,77 @@
1
- import { GraphData, NodeObject } from 'react-force-graph-2d';
1
+ export interface Graph2DRef {
2
+ /**
3
+ * Масштабирует график так, чтобы все узлы были видны
4
+ * @param duration Длительность анимации масштабирования в миллисекундах
5
+ * @param padding Отступ от краев в пикселях
6
+ */
7
+ zoomToFit: (duration?: number, padding?: number) => void;
8
+
9
+ /**
10
+ * Добавляет новые узлы и связи на график
11
+ * @param newNodes Массив новых узлов для добавления
12
+ * @param newLinks Массив новых связей для добавления
13
+ * @param options Опции для настройки поведения при добавлении
14
+ * - smoothAppearance: если true, существующие узлы не будут двигаться,
15
+ * а новые появятся плавно рядом со связанными узлами
16
+ * - transitionDuration: длительность анимации появления новых узлов в миллисекундах
17
+ */
18
+ addNodes: (
19
+ newNodes: NodeObject[],
20
+ newLinks?: LinkObject[],
21
+ options?: {
22
+ smoothAppearance?: boolean;
23
+ transitionDuration?: number;
24
+ }
25
+ ) => void;
26
+
27
+ /**
28
+ * Удаляет узлы и связанные с ними связи из графа
29
+ * @param nodeIds Массив идентификаторов узлов для удаления
30
+ */
31
+ removeNodes: (nodeIds: (string | number)[]) => void;
32
+ }
2
33
 
3
34
  export interface Graph2DProps {
4
- graphData?: GraphData;
5
- linkSource?: string;
6
- linkTarget?: string;
35
+ graphData: GraphData;
7
36
  loading?: boolean;
8
37
 
9
38
  // Container layout
10
- width?: number;
11
- height?: number;
12
-
13
- //custom node rendering
14
- config?: {
15
- fontSize: number;
16
- maxZoom: number;
17
- nodeSizeBase: number;
18
- nodeAreaFactor: number;
19
- textPaddingFactor: number;
20
- gridSpacing: number;
21
- dotSize: number;
22
- };
39
+ width: number;
40
+ height: number;
41
+
42
+ // Button controls
43
+ buttons?: NodeButton[];
44
+
45
+ // Event handlers
23
46
  onNodeClick?: (node: NodeObject) => void;
24
- onLinkClick?: (link: NodeObject) => void;
25
- onNodeHover?: (node: NodeObject | null) => void;
26
- onLinkHover?: (link: NodeObject | null) => void;
27
47
  onBackgroundClick?: () => void;
28
- onClickLoadNodes?: (node: NodeObject) => void;
48
+ onNodeHover?: (node: NodeObject | null) => void;
49
+ }
50
+
51
+ export interface NodeButton {
52
+ img: string;
53
+ hoverImg: string;
54
+ onClick: (node: NodeObject) => void;
29
55
  }
56
+
57
+ export type GraphData<NodeType = {}, LinkType = {}> = {
58
+ nodes: NodeObject<NodeType>[];
59
+ links: LinkObject<NodeType, LinkType>[];
60
+ };
61
+
62
+ export type NodeObject<NodeType = {}> = NodeType & {
63
+ id?: string | number;
64
+ x?: number;
65
+ y?: number;
66
+ vx?: number;
67
+ vy?: number;
68
+ fx?: number;
69
+ fy?: number;
70
+ [others: string]: any;
71
+ };
72
+
73
+ export type LinkObject<NodeType = {}, LinkType = {}> = LinkType & {
74
+ source: string | number | NodeObject<NodeType>;
75
+ target: string | number | NodeObject<NodeType>;
76
+ [others: string]: any;
77
+ };
@@ -579,6 +579,7 @@ export const darkThemePx: Theme = {
579
579
  borderRadius: 0,
580
580
  iconSize: 14,
581
581
  height: 'auto',
582
+ lineHeight: 16,
582
583
  },
583
584
  small: {
584
585
  fontSize: 14,
@@ -587,6 +588,7 @@ export const darkThemePx: Theme = {
587
588
  borderRadius: 5,
588
589
  iconSize: 14,
589
590
  height: 40,
591
+ lineHeight: 16,
590
592
  },
591
593
  medium: {
592
594
  fontSize: 16,
@@ -595,6 +597,7 @@ export const darkThemePx: Theme = {
595
597
  borderRadius: 5,
596
598
  iconSize: 16,
597
599
  height: 40,
600
+ lineHeight: 18,
598
601
  },
599
602
  },
600
603
  outlined: {
@@ -680,6 +683,7 @@ export const darkThemePx: Theme = {
680
683
  graph2D: {
681
684
  ring: {
682
685
  highlightFill: 'rgba(0, 90, 255, 0.3)',
686
+ selectionFill: 'rgba(0, 90, 255, 0.5)',
683
687
  },
684
688
  button: {
685
689
  stroke: '#1A1A1A',
@@ -578,6 +578,7 @@ export const lightThemePx: Theme = {
578
578
  borderRadius: 0,
579
579
  iconSize: 14,
580
580
  height: 'auto',
581
+ lineHeight: 16,
581
582
  },
582
583
  small: {
583
584
  fontSize: 14,
@@ -586,6 +587,7 @@ export const lightThemePx: Theme = {
586
587
  borderRadius: 5,
587
588
  iconSize: 14,
588
589
  height: 40,
590
+ lineHeight: 16,
589
591
  },
590
592
  medium: {
591
593
  fontSize: 16,
@@ -594,6 +596,7 @@ export const lightThemePx: Theme = {
594
596
  borderRadius: 5,
595
597
  iconSize: 16,
596
598
  height: 40,
599
+ lineHeight: 18,
597
600
  },
598
601
  },
599
602
  outlined: {
@@ -679,6 +682,7 @@ export const lightThemePx: Theme = {
679
682
  graph2D: {
680
683
  ring: {
681
684
  highlightFill: 'rgba(255, 165, 0, 0.3)',
685
+ selectionFill: 'rgba(0, 66, 236, 0.3)',
682
686
  },
683
687
  button: {
684
688
  stroke: '#e5e5e5',
@@ -54,6 +54,7 @@ export type InputSizeStyle = {
54
54
  borderRadius: number | string;
55
55
  iconSize: number | string;
56
56
  height: number | string;
57
+ lineHeight: number;
57
58
  };
58
59
 
59
60
  // Тип для палітри
@@ -211,6 +212,7 @@ export type Theme = {
211
212
  graph2D: {
212
213
  ring: {
213
214
  highlightFill: string;
215
+ selectionFill: string;
214
216
  };
215
217
  button: {
216
218
  stroke: string;
@@ -73,6 +73,16 @@ export const pxToRem = (pxValue: number | string, baseSize: number = 16): string
73
73
  return `${remValue}rem`;
74
74
  };
75
75
 
76
+ export const remToPx = (remValue: number | string, baseSize: number = 16): number => {
77
+ // If remValue is a string with 'rem' suffix, extract the numeric value
78
+ const numericValue = typeof remValue === 'string' ? parseFloat(remValue.replace('rem', '')) : remValue;
79
+ if (isNaN(numericValue)) {
80
+ return 0;
81
+ }
82
+
83
+ return numericValue * baseSize;
84
+ };
85
+
76
86
  const IGNORE_CONVERT_KEYS: Record<string, string[] | boolean> = {
77
87
  contextMenu: ['padding'],
78
88
  baseSize: true,
Binary file
Binary file
Binary file
Binary file