@cyber-harbour/ui 1.0.19 → 1.0.21
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 +89 -5
- package/dist/index.d.ts +89 -5
- package/dist/index.js +170 -71
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +170 -71
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
- package/src/Core/ContextMenu/ContextMenu.tsx +131 -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/IconComponents/Plus.tsx +20 -0
- package/src/Core/IconComponents/index.ts +1 -0
- package/src/Core/Select/Select.tsx +116 -0
- package/src/Core/Select/index.ts +1 -0
- package/src/Core/index.ts +2 -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/Layouts/PageLayout/PageLayout.tsx +5 -1
- package/src/Theme/GlobalStyle.tsx +3 -0
- package/src/Theme/theme.ts +71 -0
- package/src/Theme/types.ts +22 -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
|
+
}
|
|
@@ -12,7 +12,7 @@ export const PageLayout = ({ children, header, sidebar }: PageLayoutProps) => {
|
|
|
12
12
|
<StyledContainer $withHeader={!!header} $withSidebar={!!sidebar}>
|
|
13
13
|
{header}
|
|
14
14
|
{sidebar}
|
|
15
|
-
<
|
|
15
|
+
<StyledMain>{children}</StyledMain>
|
|
16
16
|
</StyledContainer>
|
|
17
17
|
);
|
|
18
18
|
};
|
|
@@ -53,3 +53,7 @@ export const StyledContainer = styled.div<StyledContainerProps>(
|
|
|
53
53
|
}
|
|
54
54
|
`
|
|
55
55
|
);
|
|
56
|
+
|
|
57
|
+
const StyledMain = styled.main`
|
|
58
|
+
min-width: 0;
|
|
59
|
+
`;
|
package/src/Theme/theme.ts
CHANGED
|
@@ -476,8 +476,79 @@ 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: '#FAFAFA',
|
|
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
|
+
},
|
|
519
|
+
// Компонент Select
|
|
520
|
+
select: {
|
|
521
|
+
item: {
|
|
522
|
+
default: {
|
|
523
|
+
background: 'transparent',
|
|
524
|
+
text: '#101010',
|
|
525
|
+
border: ' none',
|
|
526
|
+
boxShadow: 'none',
|
|
527
|
+
},
|
|
528
|
+
hover: {
|
|
529
|
+
background: '#E5ECFD',
|
|
530
|
+
text: '#101010',
|
|
531
|
+
border: ' none',
|
|
532
|
+
boxShadow: 'none',
|
|
533
|
+
},
|
|
534
|
+
active: {
|
|
535
|
+
background: '#E8EAEE',
|
|
536
|
+
text: '#101010',
|
|
537
|
+
border: ' none',
|
|
538
|
+
boxShadow: 'none',
|
|
539
|
+
},
|
|
540
|
+
disabled: {
|
|
541
|
+
background: '#FAFAFA',
|
|
542
|
+
text: '#99989C',
|
|
543
|
+
border: ' none',
|
|
544
|
+
boxShadow: 'none',
|
|
545
|
+
},
|
|
546
|
+
},
|
|
547
|
+
},
|
|
479
548
|
};
|
|
480
549
|
|
|
481
550
|
// Конвертуємо всі розміри з px в rem
|
|
482
551
|
export const lightTheme = convertPaletteToRem(lightThemePx) as DefaultTheme;
|
|
483
552
|
export const darkTheme = convertPaletteToRem(lightThemePx) as DefaultTheme;
|
|
553
|
+
|
|
554
|
+
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,26 @@ 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
|
+
};
|
|
150
|
+
//Select
|
|
151
|
+
select: {
|
|
152
|
+
item: Record<ButtonState, ButtonElementStyle>;
|
|
153
|
+
};
|
|
132
154
|
};
|
|
133
155
|
|
|
134
156
|
//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