@cyber-harbour/ui 1.0.50 → 1.0.52

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.
@@ -31,6 +31,44 @@ export interface Graph2DRef {
31
31
  removeNodes: (nodeIds: (string | number)[]) => void;
32
32
  }
33
33
 
34
+ /**
35
+ * Интерфейс для внутреннего состояния компонента Graph2D
36
+ */
37
+ export interface GraphState {
38
+ /** Трансформация графа (позиционирование и масштаб) */
39
+ transform: { x: number; y: number; k: number };
40
+ /** Флаг режима панорамирования */
41
+ isPanning: boolean;
42
+ /** Узел, над которым находится курсор */
43
+ hoveredNode: NodeObject | null;
44
+ /** Связь, над которой находится курсор */
45
+ hoveredLink: LinkObject | null;
46
+ /** Узел, который в данный момент перетаскивается */
47
+ draggedNode: NodeObject | null;
48
+ /** Выбранный узел */
49
+ selectedNode: NodeObject | null;
50
+ /** Индекс кнопки, над которой находится курсор */
51
+ hoveredButtonIndex: number | null;
52
+ /** Набор узлов, которые должны быть подсвечены */
53
+ highlightNodes: Set<NodeObject>;
54
+ /** Набор связей, которые должны быть подсвечены */
55
+ highlightLinks: Set<any>;
56
+ /** Последняя позиция курсора */
57
+ lastMousePos: { x: number; y: number };
58
+ /** Флаг необходимости остановки распространения события */
59
+ mustBeStoppedPropagation: boolean;
60
+ /** Последний узел, над которым был курсор */
61
+ lastHoveredNode: NodeObject | null;
62
+ /** Кэшированная ссылка на последний узел, над которым был курсор (для избежания лишних вычислений) */
63
+ lastHoveredNodeRef: NodeObject | null;
64
+ /** Начальная позиция курсора при начале перетаскивания */
65
+ mouseStartPos: { x: number; y: number } | null;
66
+ /** Флаг режима перетаскивания */
67
+ isDragging: boolean;
68
+ width: number;
69
+ height: number;
70
+ }
71
+
34
72
  export interface Graph2DProps {
35
73
  graphData: GraphData;
36
74
  loading?: boolean;
@@ -46,6 +84,8 @@ export interface Graph2DProps {
46
84
  onNodeClick?: (node: NodeObject) => void;
47
85
  onBackgroundClick?: () => void;
48
86
  onNodeHover?: (node: NodeObject | null) => void;
87
+ onLinkHover?: (link: LinkObject | null) => void;
88
+ onLinkClick?: (link: LinkObject) => void;
49
89
  }
50
90
 
51
91
  export interface NodeButton {
@@ -1,7 +1,7 @@
1
1
  import styled, { css, IStyledComponent, DefaultTheme, WebTarget } from 'styled-components';
2
2
  import { pxToRem } from './utils';
3
3
 
4
- type MarginProps = {
4
+ type SpaceProps = {
5
5
  m?: string | number; // margin
6
6
  mt?: string | number; // margin-top
7
7
  mr?: string | number; // margin-right
@@ -18,7 +18,7 @@ type MarginProps = {
18
18
  py?: string | number; // padding-top + padding-bottom
19
19
  };
20
20
 
21
- export type FabricComponent<T = object> = T & MarginProps;
21
+ export type FabricComponent<T = object> = T & SpaceProps;
22
22
 
23
23
  const marginStyles = ({ ignoreStyles }: FabricComponentOptions = {}) =>
24
24
  css<FabricComponent>(({ theme, ...props }) => {
@@ -91,3 +91,15 @@ export const createComponent = <T extends object = {}>(
91
91
  ${paddingStyles(options)}
92
92
  `;
93
93
  };
94
+
95
+ export const destructSpaceProps = <T extends FabricComponent>(props: T): SpaceProps => {
96
+ const rest: SpaceProps = {};
97
+ ['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'p', 'pt', 'pr', 'pb', 'pl', 'px', 'py'].forEach((key) => {
98
+ if (key in props) {
99
+ rest[key as keyof SpaceProps] = props[key as keyof SpaceProps];
100
+ delete props[key as keyof SpaceProps];
101
+ }
102
+ });
103
+
104
+ return rest;
105
+ };
@@ -758,6 +758,24 @@ export const darkThemePx: Theme = {
758
758
  background: '#FFFBE0',
759
759
  },
760
760
  },
761
+ label: {
762
+ sizes: {
763
+ small: {
764
+ fontSize: 14,
765
+ gap: 10,
766
+ marginBottom: 20,
767
+ helpText: { fontSize: 12, marginTop: 5 },
768
+ },
769
+ medium: {
770
+ fontSize: 16,
771
+ gap: 10,
772
+ marginBottom: 25,
773
+ helpText: { fontSize: 14, marginTop: 5 },
774
+ },
775
+ },
776
+ color: '#ffffff',
777
+ helpTextColor: '#535353',
778
+ },
761
779
  };
762
780
 
763
781
  export const darkTheme = convertPaletteToRem(darkThemePx, darkThemePx.baseSize) as DefaultTheme;
@@ -757,6 +757,24 @@ export const lightThemePx: Theme = {
757
757
  background: '#FFFBE0',
758
758
  },
759
759
  },
760
+ label: {
761
+ sizes: {
762
+ small: {
763
+ fontSize: 14,
764
+ gap: 10,
765
+ marginBottom: 20,
766
+ helpText: { fontSize: 12, marginTop: 5 },
767
+ },
768
+ medium: {
769
+ fontSize: 16,
770
+ gap: 10,
771
+ marginBottom: 25,
772
+ helpText: { fontSize: 14, marginTop: 5 },
773
+ },
774
+ },
775
+ color: '#101010',
776
+ helpTextColor: '#99989C',
777
+ },
760
778
  };
761
779
 
762
780
  export const lightTheme = convertPaletteToRem(lightThemePx, lightThemePx.baseSize) as DefaultTheme;
@@ -22,6 +22,14 @@ export type TagColor =
22
22
  | 'orange'
23
23
  | string;
24
24
 
25
+ export type LabelSize = 'small' | 'medium';
26
+ export type LabelSizeStyle = {
27
+ fontSize: number | string;
28
+ gap: number | string;
29
+ marginBottom: number | string;
30
+ helpText: { fontSize: number | string; marginTop: number | string };
31
+ };
32
+
25
33
  // Типи для spacing та breakpoints
26
34
  export type Breakpoint = 'xs' | 's' | 'm' | 'l' | 'xl';
27
35
 
@@ -274,6 +282,11 @@ export type Theme = {
274
282
  background: string;
275
283
  };
276
284
  };
285
+ label: {
286
+ sizes: Record<LabelSize, LabelSizeStyle>;
287
+ color: string;
288
+ helpTextColor: string;
289
+ };
277
290
  };
278
291
 
279
292
  //TODO check and refactoring
@@ -88,6 +88,27 @@ const IGNORE_CONVERT_KEYS: Record<string, string[] | boolean> = {
88
88
  baseSize: true,
89
89
  };
90
90
 
91
+ /**
92
+ * Converts a prop value to rem units if needed
93
+ *
94
+ * @param value - The pixel value to convert. Can be a number or a string with 'px' suffix
95
+ * @param baseSize - Base font size in pixels. Default is 16px (browser default)
96
+ * @returns The value in rem units as a string (e.g., "1.25rem")
97
+ */
98
+ export const propToRem = (value: number | string, baseSize: number = 16): string => {
99
+ if (typeof value === 'string' && value.trim().endsWith('%')) return value; // Return percentage values as-is
100
+ const numericValue = typeof value === 'string' ? parseFloat(value) : value;
101
+
102
+ // Handle invalid values
103
+ if (isNaN(numericValue)) {
104
+ return `${value}`;
105
+ }
106
+
107
+ // Convert to rem and round to 4 decimal places for precision
108
+ const remValue = (numericValue / baseSize).toFixed(4).replace(/\.?0+$/, '');
109
+
110
+ return `${remValue}rem`;
111
+ };
91
112
  /**
92
113
  * Recursively converts all pixel values in an object to rem units
93
114
  *