@cyber-harbour/ui 1.0.37 → 1.0.39

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.37",
3
+ "version": "1.0.39",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import { CSSProperties, ReactNode } from 'react';
1
+ import { CSSProperties, forwardRef } from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
4
  export type FlexDirection = 'row' | 'column' | 'row-reverse' | 'column-reverse';
@@ -22,20 +22,23 @@ export interface FlexContainerProps {
22
22
  as?: any; // TODO: fix type to styled component or intrinsic element
23
23
  }
24
24
 
25
- export const FlexContainer = ({
26
- children,
27
- direction = 'row',
28
- wrap = 'nowrap',
29
- justify = 'flex-start',
30
- align = 'stretch',
31
- alignContent,
32
- gap,
33
- rowGap,
34
- columnGap,
35
- className,
36
- style,
37
- as = 'div',
38
- }: FlexContainerProps) => {
25
+ export const FlexContainer: any = forwardRef<HTMLElement, FlexContainerProps>(function FlexContainer(
26
+ {
27
+ children,
28
+ direction = 'row',
29
+ wrap = 'nowrap',
30
+ justify = 'flex-start',
31
+ align = 'stretch',
32
+ alignContent,
33
+ gap,
34
+ rowGap,
35
+ columnGap,
36
+ className,
37
+ style,
38
+ as = 'div',
39
+ },
40
+ ref
41
+ ) {
39
42
  return (
40
43
  <StyledFlexContainer
41
44
  as={as}
@@ -49,11 +52,12 @@ export const FlexContainer = ({
49
52
  $columnGap={columnGap}
50
53
  className={className}
51
54
  style={style}
55
+ ref={ref}
52
56
  >
53
57
  {children}
54
58
  </StyledFlexContainer>
55
59
  );
56
- };
60
+ });
57
61
 
58
62
  interface StyledFlexContainerProps {
59
63
  $direction: FlexDirection;
@@ -1,6 +1,6 @@
1
1
  import ForceGraph2D, { ForceGraphMethods, LinkObject, NodeObject } from 'react-force-graph-2d';
2
2
  import { Graph2DProps } from './types';
3
- import { useEffect, useRef, useState, useCallback, useLayoutEffect } from 'react';
3
+ import { useEffect, useRef, useState, useCallback } from 'react';
4
4
  import { forceCollide } from 'd3-force';
5
5
  import { styled, useTheme } from 'styled-components';
6
6
  import eyeLightIcon from './eye_light.png';
@@ -11,16 +11,16 @@ import GraphLoader from './GraphLoader';
11
11
 
12
12
  // Створюємо та налаштовуємо об'єкти зображень
13
13
  const imgEyeLightIcon = new Image();
14
- imgEyeLightIcon.src = eyeLightIcon;
14
+ imgEyeLightIcon.src = eyeLightIcon.replace('./', '/');
15
15
 
16
16
  const imgEyeLightHoverIcon = new Image();
17
- imgEyeLightHoverIcon.src = eyeLightHoverIcon;
17
+ imgEyeLightHoverIcon.src = eyeLightHoverIcon.replace('./', '/');
18
18
 
19
19
  const imgGroupLightIcon = new Image();
20
- imgGroupLightIcon.src = groupLightIcon;
20
+ imgGroupLightIcon.src = groupLightIcon.replace('./', '/');
21
21
 
22
22
  const imgGroupLightHoverIcon = new Image();
23
- imgGroupLightHoverIcon.src = groupLightHoverIcon;
23
+ imgGroupLightHoverIcon.src = groupLightHoverIcon.replace('./', '/');
24
24
 
25
25
  export const Graph2D = ({
26
26
  graphData,
@@ -126,32 +126,29 @@ export const Graph2D = ({
126
126
  setHighlightLinks(newHighlightLinks);
127
127
  };
128
128
 
129
- const handleEngineTick = useCallback(() => {
130
- if (isRendering)
131
- if (
132
- graphData &&
133
- fgRef.current &&
134
- fgRef.current.tick &&
135
- graphData.nodes.length > 0 &&
136
- graphData.nodes.length <= fgRef.current.tick
137
- ) {
138
- if (tickTimerRef.current) {
139
- clearTimeout(tickTimerRef.current);
140
- }
141
- fgRef.current.zoomToFit(0, 20);
142
- setIsRendering(false);
143
- } else {
144
- fgRef.current.tick = fgRef.current.tick ? (fgRef.current.tick = fgRef.current.tick + 1) : 1;
145
- if (tickTimerRef.current) {
146
- clearTimeout(tickTimerRef.current);
147
- }
148
- tickTimerRef.current = setTimeout(() => {
149
- //force tick check
129
+ const handleEngineTick = () => {
130
+ if (isRendering) {
131
+ if (fgRef.current && graphData) {
132
+ if (fgRef.current.tick && graphData.nodes.length > 0 && graphData.nodes.length <= fgRef.current.tick) {
133
+ if (tickTimerRef.current) {
134
+ clearTimeout(tickTimerRef.current);
135
+ }
150
136
  fgRef.current.zoomToFit(0, 20);
151
137
  setIsRendering(false);
152
- }, 1500);
138
+ } else {
139
+ fgRef.current.tick = fgRef.current.tick ? (fgRef.current.tick = fgRef.current.tick + 1) : 1;
140
+ if (tickTimerRef.current) {
141
+ clearTimeout(tickTimerRef.current);
142
+ }
143
+ tickTimerRef.current = setTimeout(() => {
144
+ //force tick check
145
+ fgRef.current.zoomToFit(0, 20);
146
+ setIsRendering(false);
147
+ }, 1500);
148
+ }
153
149
  }
154
- }, [graphData]);
150
+ }
151
+ };
155
152
 
156
153
  // Створення взаємозв'язків між вузлами
157
154
  useEffect(() => {
@@ -274,9 +271,9 @@ export const Graph2D = ({
274
271
  const iconSize = buttonRadius * 0.3; // Розмір іконки відносно радіуса кнопки (зменшено вдвічі)
275
272
 
276
273
  // Вибір іконки в залежності від стану наведення для верхньої кнопки (сховати)
277
- const groupIcon = hoverTopButton ? imgGroupLightHoverIcon : imgGroupLightIcon;
274
+ const groupIcon = hoverBottomButton ? imgGroupLightHoverIcon : imgGroupLightIcon;
278
275
  // Додаємо іконку ока для кнопки "згорнути дочірні вузли"
279
- const eyeIcon = hoverBottomButton ? imgEyeLightHoverIcon : imgEyeLightIcon;
276
+ const eyeIcon = hoverTopButton ? imgEyeLightHoverIcon : imgEyeLightIcon;
280
277
 
281
278
  const renderEyeIcon = () => {
282
279
  try {
@@ -308,17 +305,17 @@ export const Graph2D = ({
308
305
  }
309
306
  };
310
307
  // Використовуємо безпосередньо зображення, якщо воно вже завантажене
311
- if (eyeIcon.complete) {
308
+ if (groupIcon.complete) {
312
309
  // Розміщуємо іконку в центрі нижньої половини кнопки
313
310
 
314
311
  renderGroupIcon();
315
312
  } else {
316
313
  // Якщо зображення ще не завантажене, додаємо обробник завершення завантаження
317
- eyeIcon.onload = () => {
314
+ groupIcon.onload = () => {
318
315
  renderGroupIcon();
319
316
  };
320
317
 
321
- eyeIcon.onerror = () => {
318
+ groupIcon.onerror = () => {
322
319
  console.warn('Error loading eye icon image');
323
320
  };
324
321
  }
@@ -560,7 +557,7 @@ export const Graph2D = ({
560
557
  };
561
558
 
562
559
  const renderGrid = (ctx: CanvasRenderingContext2D, globalScale: number) => {
563
- if (isRendering) return; // Не малюємо сітку під час рендерингу
560
+ if (isRendering || loading) return; // Не малюємо сітку під час рендерингу
564
561
  // This will be called before each rendering frame
565
562
  ctx.getTransform();
566
563
  ctx.save();
@@ -14,7 +14,7 @@ export const darkThemePx: Theme = {
14
14
  baseSize: 14, // Базовий розмір шрифту для конвертації px в rem
15
15
  // Секція кольорів з теми
16
16
  colors: {
17
- background: '#0A0A0A',
17
+ background: '#0F1317',
18
18
  backgroundBase: '#000000',
19
19
  primary: {
20
20
  main: '#158EFF',
@@ -318,7 +318,7 @@ export const darkThemePx: Theme = {
318
318
  boxShadow: 'none',
319
319
  filledIcon: {
320
320
  background: '#158EFF',
321
- color: '#0A0A0A',
321
+ color: '#0F1317',
322
322
  },
323
323
  },
324
324
  active: {
@@ -328,7 +328,7 @@ export const darkThemePx: Theme = {
328
328
  boxShadow: 'none',
329
329
  filledIcon: {
330
330
  background: '#158EFF',
331
- color: '#0A0A0A',
331
+ color: '#0F1317',
332
332
  },
333
333
  },
334
334
  disabled: {
@@ -423,7 +423,7 @@ export const darkThemePx: Theme = {
423
423
 
424
424
  // Компонент Sidebar
425
425
  sidebar: {
426
- background: '#0A0A0A',
426
+ background: '#0F1317',
427
427
  border: '#1E2226',
428
428
  width: 224,
429
429
  collapsedWidth: 65,
@@ -674,7 +674,7 @@ export const darkThemePx: Theme = {
674
674
  style: 'solid',
675
675
  color: '#1E2226',
676
676
  },
677
- background: '#0A0A0A',
677
+ background: '#0F1317',
678
678
  },
679
679
  // Graph2D
680
680
  graph2D: {
@@ -698,8 +698,8 @@ export const lightThemePx: Theme = {
698
698
  },
699
699
  },
700
700
  contentLoader: {
701
- foreground: '#535353',
702
- background: '#99989C',
701
+ foreground: '#E2E2E2E2',
702
+ background: '#F3F3F3',
703
703
  },
704
704
  };
705
705