@cyber-harbour/ui 1.0.19 → 1.0.20
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/dist/index.d.mts +64 -3
- package/dist/index.d.ts +64 -3
- package/dist/index.js +111 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +126 -71
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
- package/src/Core/ContextMenu/ContextMenu.tsx +122 -0
- package/src/Core/ContextMenu/ContextMenuDelimiter.tsx +13 -0
- package/src/Core/ContextMenu/index.ts +3 -0
- package/src/Core/ContextMenu/useContextMenuControl.ts +21 -0
- package/src/Core/index.ts +1 -0
- package/src/Graph2D/Graph2D.tsx +186 -0
- package/src/Graph2D/index.ts +2 -0
- package/src/Graph2D/json_test.json +3685 -0
- package/src/Graph2D/types.ts +22 -0
- package/src/Theme/GlobalStyle.tsx +3 -0
- package/src/Theme/theme.ts +42 -0
- package/src/Theme/types.ts +18 -0
- package/src/Theme/utils.ts +15 -3
- package/src/index.ts +1 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GraphData } from 'react-force-graph-2d';
|
|
2
|
+
|
|
3
|
+
export interface Graph2DProps {
|
|
4
|
+
graphData?: GraphData;
|
|
5
|
+
linkSource?: string;
|
|
6
|
+
linkTarget?: string;
|
|
7
|
+
|
|
8
|
+
// Container layout
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
|
|
12
|
+
//custom node rendering
|
|
13
|
+
config?: {
|
|
14
|
+
nodeSizeFactor: number;
|
|
15
|
+
fontSize: number;
|
|
16
|
+
nodeSizeBase: number;
|
|
17
|
+
textPaddingFactor: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
onNodeClick?: (node: any) => void;
|
|
21
|
+
onLinkClick?: (link: any) => void;
|
|
22
|
+
}
|
package/src/Theme/theme.ts
CHANGED
|
@@ -476,8 +476,50 @@ export const lightThemePx: Theme = {
|
|
|
476
476
|
margin: '8px 0',
|
|
477
477
|
},
|
|
478
478
|
},
|
|
479
|
+
contextMenu: {
|
|
480
|
+
button: {
|
|
481
|
+
default: {
|
|
482
|
+
background: 'transparent',
|
|
483
|
+
text: '#101010',
|
|
484
|
+
border: ' #EBEBEB',
|
|
485
|
+
boxShadow: 'none',
|
|
486
|
+
},
|
|
487
|
+
hover: {
|
|
488
|
+
background: 'transparent',
|
|
489
|
+
text: '#0042EC',
|
|
490
|
+
border: ' #EBEBEB',
|
|
491
|
+
boxShadow: 'none',
|
|
492
|
+
},
|
|
493
|
+
active: {
|
|
494
|
+
background: 'transparent',
|
|
495
|
+
text: '#0042EC',
|
|
496
|
+
border: ' #EBEBEB',
|
|
497
|
+
boxShadow: 'none',
|
|
498
|
+
},
|
|
499
|
+
disabled: {
|
|
500
|
+
background: '#EBEBEB',
|
|
501
|
+
text: '#99989C',
|
|
502
|
+
border: ' #EBEBEB',
|
|
503
|
+
boxShadow: 'none',
|
|
504
|
+
},
|
|
505
|
+
},
|
|
506
|
+
delimeter: {
|
|
507
|
+
color: '#EBEBEB',
|
|
508
|
+
thickness: 1,
|
|
509
|
+
marginInline: 12,
|
|
510
|
+
marginBlock: 3,
|
|
511
|
+
style: 'solid',
|
|
512
|
+
},
|
|
513
|
+
shadow: '0px 4px 16px rgba(0, 0, 0, 0.1), 0px 2px 4px rgba(0, 0, 0, 0.06)',
|
|
514
|
+
padding: 5,
|
|
515
|
+
icon: {
|
|
516
|
+
size: 7,
|
|
517
|
+
},
|
|
518
|
+
},
|
|
479
519
|
};
|
|
480
520
|
|
|
481
521
|
// Конвертуємо всі розміри з px в rem
|
|
482
522
|
export const lightTheme = convertPaletteToRem(lightThemePx) as DefaultTheme;
|
|
483
523
|
export const darkTheme = convertPaletteToRem(lightThemePx) as DefaultTheme;
|
|
524
|
+
|
|
525
|
+
console.log('Light theme:', lightTheme.contextMenu);
|
package/src/Theme/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CSSProperties } from 'styled-components';
|
|
2
|
+
|
|
1
3
|
// Типи для компонентної палітри
|
|
2
4
|
export type ButtonVariant = 'fill' | 'outlined' | 'empty';
|
|
3
5
|
export type ButtonColor = 'default' | 'primary' | 'secondary' | 'error';
|
|
@@ -129,6 +131,22 @@ export type Theme = {
|
|
|
129
131
|
margin: string;
|
|
130
132
|
};
|
|
131
133
|
};
|
|
134
|
+
//ContextMenu
|
|
135
|
+
contextMenu: {
|
|
136
|
+
button: Record<ButtonState, ButtonElementStyle>;
|
|
137
|
+
padding: number;
|
|
138
|
+
delimeter: {
|
|
139
|
+
style: CSSProperties['borderStyle'];
|
|
140
|
+
color: string;
|
|
141
|
+
thickness: number;
|
|
142
|
+
marginInline: number | string;
|
|
143
|
+
marginBlock: number | string;
|
|
144
|
+
};
|
|
145
|
+
shadow: string;
|
|
146
|
+
icon: {
|
|
147
|
+
size: number | string;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
132
150
|
};
|
|
133
151
|
|
|
134
152
|
//TODO check and refactoring
|
package/src/Theme/utils.ts
CHANGED
|
@@ -64,6 +64,10 @@ export const pxToRem = (pxValue: number | string, baseSize: number = 16): string
|
|
|
64
64
|
return `${remValue}rem`;
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
+
const IGNORE_CONVERT_KEYS: Record<string, string[]> = {
|
|
68
|
+
contextMenu: ['padding'],
|
|
69
|
+
};
|
|
70
|
+
|
|
67
71
|
/**
|
|
68
72
|
* Recursively converts all pixel values in an object to rem units
|
|
69
73
|
*
|
|
@@ -71,13 +75,17 @@ export const pxToRem = (pxValue: number | string, baseSize: number = 16): string
|
|
|
71
75
|
* @param baseSize - Base font size in pixels. Default is 16px
|
|
72
76
|
* @returns A new object with pixel values converted to rem
|
|
73
77
|
*/
|
|
74
|
-
export const convertPaletteToRem = (
|
|
78
|
+
export const convertPaletteToRem = (
|
|
79
|
+
obj: Record<string, any>,
|
|
80
|
+
baseSize: number = 14,
|
|
81
|
+
parentKey?: string
|
|
82
|
+
): Record<string, any> => {
|
|
75
83
|
const result: Record<string, any> = {};
|
|
76
84
|
|
|
77
85
|
Object.entries(obj).forEach(([key, value]) => {
|
|
78
86
|
// If the value is an object and not null, recursively convert its properties
|
|
79
87
|
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
80
|
-
result[key] = convertPaletteToRem(value, baseSize);
|
|
88
|
+
result[key] = convertPaletteToRem(value, baseSize, key);
|
|
81
89
|
}
|
|
82
90
|
// If value is a string and contains 'px', convert it to rem
|
|
83
91
|
else if (typeof value === 'string' && value.includes('px')) {
|
|
@@ -90,7 +98,11 @@ export const convertPaletteToRem = (obj: Record<string, any>, baseSize: number =
|
|
|
90
98
|
key.toLowerCase().includes(prop.toLowerCase())
|
|
91
99
|
)
|
|
92
100
|
) {
|
|
93
|
-
|
|
101
|
+
if (!(parentKey && IGNORE_CONVERT_KEYS[parentKey]?.includes(key))) {
|
|
102
|
+
result[key] = pxToRem(value, baseSize);
|
|
103
|
+
} else {
|
|
104
|
+
result[key] = value; // Keep original value if it's in the ignore list
|
|
105
|
+
}
|
|
94
106
|
}
|
|
95
107
|
// Keep other values unchanged
|
|
96
108
|
else {
|
package/src/index.ts
CHANGED