@cyber-harbour/ui 1.0.74 → 1.0.75
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/README.md +76 -0
- package/bin/switch-ui-lib.js +196 -0
- package/dist/index.js +90 -90
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -2
- package/.env.example +0 -0
- package/src/Core/Alert/Alert.tsx +0 -87
- package/src/Core/Alert/index.ts +0 -1
- package/src/Core/Box/Box.tsx +0 -46
- package/src/Core/Box/index.ts +0 -1
- package/src/Core/Button/Button.tsx +0 -208
- package/src/Core/Button/index.ts +0 -1
- package/src/Core/Checkbox/Checkbox.tsx +0 -73
- package/src/Core/Checkbox/index.ts +0 -1
- package/src/Core/ContentLoader/ContentLoader.tsx +0 -13
- package/src/Core/ContentLoader/index.ts +0 -1
- package/src/Core/ContextMenu/ContextMenu.tsx +0 -153
- package/src/Core/ContextMenu/ContextMenuDelimiter.tsx +0 -13
- package/src/Core/ContextMenu/index.ts +0 -3
- package/src/Core/ContextMenu/useContextMenuControl.ts +0 -21
- package/src/Core/Drawer/Drawer.tsx +0 -118
- package/src/Core/Drawer/index.ts +0 -1
- package/src/Core/EmptyData/EmptyData.tsx +0 -44
- package/src/Core/EmptyData/index.ts +0 -1
- package/src/Core/Flex/FlexContainer.tsx +0 -94
- package/src/Core/Flex/FlexItem.tsx +0 -58
- package/src/Core/Flex/index.ts +0 -4
- package/src/Core/Header/Header.tsx +0 -37
- package/src/Core/Header/HeaderDelimeter.tsx +0 -12
- package/src/Core/Header/HeaderSection.tsx +0 -37
- package/src/Core/Header/index.ts +0 -3
- package/src/Core/IconComponents/AlertIcon.tsx +0 -18
- package/src/Core/IconComponents/AndroidIcon.tsx +0 -28
- package/src/Core/IconComponents/ApiIcon.tsx +0 -26
- package/src/Core/IconComponents/ArrowCircleTopRightIcon.tsx +0 -27
- package/src/Core/IconComponents/ArrowRightIcon.tsx +0 -23
- package/src/Core/IconComponents/BallsMenu.tsx +0 -15
- package/src/Core/IconComponents/BugReportIcon.tsx +0 -16
- package/src/Core/IconComponents/BusIcon.tsx +0 -24
- package/src/Core/IconComponents/CalendarIcon.tsx +0 -26
- package/src/Core/IconComponents/CarIcon.tsx +0 -16
- package/src/Core/IconComponents/Check.tsx +0 -16
- package/src/Core/IconComponents/ChevronDown.tsx +0 -18
- package/src/Core/IconComponents/ChevronLeftIcon.tsx +0 -23
- package/src/Core/IconComponents/ChevronRightIcon.tsx +0 -23
- package/src/Core/IconComponents/ChevronUp.tsx +0 -18
- package/src/Core/IconComponents/CloseCircleIcon.tsx +0 -24
- package/src/Core/IconComponents/ClosedLockIcon.tsx +0 -22
- package/src/Core/IconComponents/Cross.tsx +0 -16
- package/src/Core/IconComponents/DataSetsIcon.tsx +0 -26
- package/src/Core/IconComponents/DeepSearchIcon.tsx +0 -16
- package/src/Core/IconComponents/DisabledVisibleIcon.tsx +0 -26
- package/src/Core/IconComponents/DocsIcon.tsx +0 -26
- package/src/Core/IconComponents/DownloadIcon.tsx +0 -26
- package/src/Core/IconComponents/EditUserIcon.tsx +0 -26
- package/src/Core/IconComponents/EnableVisibleIcon.tsx +0 -22
- package/src/Core/IconComponents/EnterArrowLeftIcon.tsx +0 -16
- package/src/Core/IconComponents/FileIcon.tsx +0 -16
- package/src/Core/IconComponents/FiltersIcon.tsx +0 -38
- package/src/Core/IconComponents/FlashIcon.tsx +0 -16
- package/src/Core/IconComponents/FolderAlertIcon.tsx +0 -32
- package/src/Core/IconComponents/FolderInfoIcon.tsx +0 -28
- package/src/Core/IconComponents/HomepageIcon.tsx +0 -16
- package/src/Core/IconComponents/InfoCircleFilled.tsx +0 -18
- package/src/Core/IconComponents/InfoCircleIcon.tsx +0 -23
- package/src/Core/IconComponents/IosIcon.tsx +0 -20
- package/src/Core/IconComponents/MapRadarIcon.tsx +0 -22
- package/src/Core/IconComponents/MaximizeIcon.tsx +0 -28
- package/src/Core/IconComponents/MicrosoftIcon.tsx +0 -28
- package/src/Core/IconComponents/MoonIcon.tsx +0 -16
- package/src/Core/IconComponents/OpenLockIcon.tsx +0 -30
- package/src/Core/IconComponents/OrganizationIcon.tsx +0 -26
- package/src/Core/IconComponents/PassportIcon.tsx +0 -796
- package/src/Core/IconComponents/PasswordFinderIcon.tsx +0 -22
- package/src/Core/IconComponents/PencilIcon.tsx +0 -16
- package/src/Core/IconComponents/PhonebookIcon.tsx +0 -22
- package/src/Core/IconComponents/PlaneIcon.tsx +0 -17
- package/src/Core/IconComponents/Plus.tsx +0 -20
- package/src/Core/IconComponents/PointIcon.tsx +0 -16
- package/src/Core/IconComponents/PrintIcon.tsx +0 -16
- package/src/Core/IconComponents/Profiler2Icon.tsx +0 -30
- package/src/Core/IconComponents/ProfilerIcon.tsx +0 -22
- package/src/Core/IconComponents/RelationIcon.tsx +0 -28
- package/src/Core/IconComponents/RelationPointsIcon.tsx +0 -36
- package/src/Core/IconComponents/RotateLeftIcon.tsx +0 -24
- package/src/Core/IconComponents/RotateRightIcon.tsx +0 -24
- package/src/Core/IconComponents/SandBoxIcon.tsx +0 -16
- package/src/Core/IconComponents/SearchIcon.tsx +0 -14
- package/src/Core/IconComponents/ShipIcon.tsx +0 -32
- package/src/Core/IconComponents/StatisticIcon.tsx +0 -26
- package/src/Core/IconComponents/SunIcon.tsx +0 -49
- package/src/Core/IconComponents/Unfold.tsx +0 -20
- package/src/Core/IconComponents/UpRightArrowCircleIcon.tsx +0 -22
- package/src/Core/IconComponents/UserInCircle.tsx +0 -24
- package/src/Core/IconComponents/Users.tsx +0 -36
- package/src/Core/IconComponents/VectorIcon.tsx +0 -17
- package/src/Core/IconComponents/WayIcon.tsx +0 -24
- package/src/Core/IconComponents/index.ts +0 -66
- package/src/Core/Input/Input.tsx +0 -245
- package/src/Core/Input/index.ts +0 -1
- package/src/Core/Label/Label.tsx +0 -139
- package/src/Core/Label/index.ts +0 -1
- package/src/Core/Line/Line.tsx +0 -26
- package/src/Core/Line/index.ts +0 -1
- package/src/Core/LinerProgress/LinerProgress.tsx +0 -47
- package/src/Core/LinerProgress/index.ts +0 -1
- package/src/Core/ListMenu/ListMenu.tsx +0 -31
- package/src/Core/ListMenu/ListMenuItem.tsx +0 -105
- package/src/Core/ListMenu/ListMenuSection.tsx +0 -54
- package/src/Core/ListMenu/index.ts +0 -3
- package/src/Core/Modal/Modal.tsx +0 -116
- package/src/Core/Modal/index.ts +0 -1
- package/src/Core/Overlay/Overlay.tsx +0 -94
- package/src/Core/Overlay/index.ts +0 -1
- package/src/Core/Pagination/Pagination.tsx +0 -139
- package/src/Core/Pagination/index.ts +0 -1
- package/src/Core/RowActionsMenu/RowActionsMenu.tsx +0 -153
- package/src/Core/RowActionsMenu/index.ts +0 -1
- package/src/Core/Select/Select.tsx +0 -197
- package/src/Core/Select/index.ts +0 -1
- package/src/Core/Sidebar/Sidebar.tsx +0 -80
- package/src/Core/Sidebar/SidebarContext.tsx +0 -13
- package/src/Core/Sidebar/SidebarDelimeter.tsx +0 -35
- package/src/Core/Sidebar/SidebarItem.tsx +0 -137
- package/src/Core/Sidebar/SidebarSection.tsx +0 -31
- package/src/Core/Sidebar/index.ts +0 -5
- package/src/Core/Switch/Switch.tsx +0 -71
- package/src/Core/Switch/index.ts +0 -1
- package/src/Core/Table/Cell.tsx +0 -42
- package/src/Core/Table/Row.tsx +0 -3
- package/src/Core/Table/Table.tsx +0 -94
- package/src/Core/Table/index.ts +0 -1
- package/src/Core/Tag/Tag.tsx +0 -144
- package/src/Core/Tag/index.ts +0 -1
- package/src/Core/Tooltip/Tooltip.tsx +0 -103
- package/src/Core/Tooltip/index.ts +0 -1
- package/src/Core/Typography/Typography.tsx +0 -70
- package/src/Core/Typography/index.ts +0 -1
- package/src/Core/index.ts +0 -27
- package/src/FullscreenCard/FullscreenCard.tsx +0 -56
- package/src/FullscreenCard/index.ts +0 -1
- package/src/Graph2D/Graph2D.tsx +0 -1837
- package/src/Graph2D/GraphLoader.tsx +0 -68
- package/src/Graph2D/icons/eye_light.png +0 -0
- package/src/Graph2D/icons/eye_light_hover.png +0 -0
- package/src/Graph2D/icons/group_light.png +0 -0
- package/src/Graph2D/icons/group_light_hover.png +0 -0
- package/src/Graph2D/index.ts +0 -2
- package/src/Graph2D/json_test.json +0 -44444
- package/src/Graph2D/types.ts +0 -122
- package/src/Layouts/Container/Container.tsx +0 -33
- package/src/Layouts/Container/index.ts +0 -1
- package/src/Layouts/PageLayout/PageLayout.tsx +0 -63
- package/src/Layouts/PageLayout/index.ts +0 -1
- package/src/Layouts/index.ts +0 -2
- package/src/Theme/Breakpoint.tsx +0 -50
- package/src/Theme/GlobalStyle.tsx +0 -18
- package/src/Theme/ThemeProvider.tsx +0 -30
- package/src/Theme/componentFabric.tsx +0 -159
- package/src/Theme/index.ts +0 -8
- package/src/Theme/styled.d.ts +0 -7
- package/src/Theme/themes/config.ts +0 -41
- package/src/Theme/themes/dark.ts +0 -1005
- package/src/Theme/themes/index.ts +0 -2
- package/src/Theme/themes/light.ts +0 -1004
- package/src/Theme/types.ts +0 -362
- package/src/Theme/useTheme.tsx +0 -7
- package/src/Theme/utils.ts +0 -205
- package/src/custom.d.ts +0 -19
- package/src/index.ts +0 -5
- package/src/utils.ts +0 -30
- package/tsconfig.paths.json +0 -5
- package/tsup.config.ts +0 -30
- package/tsup.dev.config.ts +0 -10
package/src/Graph2D/types.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
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
|
-
}
|
|
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
|
-
mouseStartPos: { x: number; y: number } | null;
|
|
62
|
-
/** Флаг режима перетаскивания */
|
|
63
|
-
isDragging: boolean;
|
|
64
|
-
width: number;
|
|
65
|
-
height: number;
|
|
66
|
-
/** Поточна анімація */
|
|
67
|
-
animation: {
|
|
68
|
-
id: number | null;
|
|
69
|
-
buttonIndex: number | null;
|
|
70
|
-
};
|
|
71
|
-
/** Кут оберту спінера */
|
|
72
|
-
spinnerAngle: number;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface Graph2DProps {
|
|
76
|
-
graphData: GraphData;
|
|
77
|
-
loading?: boolean;
|
|
78
|
-
|
|
79
|
-
// Container layout
|
|
80
|
-
width: number;
|
|
81
|
-
height: number;
|
|
82
|
-
|
|
83
|
-
// Button controls
|
|
84
|
-
buttons?: NodeButton[];
|
|
85
|
-
|
|
86
|
-
// Event handlers
|
|
87
|
-
onNodeClick?: (node: NodeObject) => void;
|
|
88
|
-
onBackgroundClick?: () => void;
|
|
89
|
-
onNodeHover?: (node: NodeObject | null) => void;
|
|
90
|
-
onLinkHover?: (link: LinkObject | null) => void;
|
|
91
|
-
onLinkClick?: (link: LinkObject) => void;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface NodeButton {
|
|
95
|
-
img: string;
|
|
96
|
-
hoverImg: string;
|
|
97
|
-
loading?: boolean;
|
|
98
|
-
getCount?: (node: NodeObject) => number;
|
|
99
|
-
onClick: (node: NodeObject) => void;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export type GraphData<NodeType = {}, LinkType = {}> = {
|
|
103
|
-
nodes: NodeObject<NodeType>[];
|
|
104
|
-
links: LinkObject<NodeType, LinkType>[];
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export type NodeObject<NodeType = {}> = NodeType & {
|
|
108
|
-
id?: string | number;
|
|
109
|
-
x?: number;
|
|
110
|
-
y?: number;
|
|
111
|
-
vx?: number;
|
|
112
|
-
vy?: number;
|
|
113
|
-
fx?: number;
|
|
114
|
-
fy?: number;
|
|
115
|
-
[others: string]: any;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export type LinkObject<NodeType = {}, LinkType = {}> = LinkType & {
|
|
119
|
-
source: string | number | NodeObject<NodeType>;
|
|
120
|
-
target: string | number | NodeObject<NodeType>;
|
|
121
|
-
[others: string]: any;
|
|
122
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createComponent,
|
|
3
|
-
createStyledComponent,
|
|
4
|
-
FabricComponent,
|
|
5
|
-
generatePropertySpaceStyle,
|
|
6
|
-
pxToRem,
|
|
7
|
-
} from '../../Theme';
|
|
8
|
-
import { styled } from 'styled-components';
|
|
9
|
-
|
|
10
|
-
type ContainerProps = {
|
|
11
|
-
children: any;
|
|
12
|
-
maxWidth?: string | number;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type StyledContainerProps = {
|
|
16
|
-
$maxWidth?: string | number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const Container = createComponent<ContainerProps>(({ maxWidth, ...props }) => {
|
|
20
|
-
return <StyledContainer {...props} $maxWidth={maxWidth} />;
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const StyledContainer = createStyledComponent<FabricComponent<StyledContainerProps>>(
|
|
24
|
-
styled.div(({ theme, $maxWidth, px = 20 }) => {
|
|
25
|
-
return `
|
|
26
|
-
${generatePropertySpaceStyle(theme, 'padding-inline', px)}
|
|
27
|
-
width: 100%;
|
|
28
|
-
min-width: 0;
|
|
29
|
-
max-width: ${typeof $maxWidth === 'number' ? pxToRem($maxWidth, theme.baseSize) : $maxWidth || '100%'};
|
|
30
|
-
`;
|
|
31
|
-
}),
|
|
32
|
-
{ ignoreStyles: ['padding-inline'] }
|
|
33
|
-
);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Container';
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { styled } from 'styled-components';
|
|
3
|
-
|
|
4
|
-
interface PageLayoutProps {
|
|
5
|
-
header?: any;
|
|
6
|
-
sidebar?: any;
|
|
7
|
-
children?: any;
|
|
8
|
-
className?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const PageLayout = ({ children, header, sidebar, className }: PageLayoutProps) => {
|
|
12
|
-
return (
|
|
13
|
-
<StyledContainer className={className} $withHeader={!!header} $withSidebar={!!sidebar}>
|
|
14
|
-
{header}
|
|
15
|
-
{sidebar}
|
|
16
|
-
<StyledMain>{children}</StyledMain>
|
|
17
|
-
</StyledContainer>
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
interface StyledContainerProps {
|
|
22
|
-
$withHeader?: boolean;
|
|
23
|
-
$withSidebar?: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const StyledContainer = styled.div<StyledContainerProps>(
|
|
27
|
-
({ $withHeader, $withSidebar }) => `
|
|
28
|
-
display: grid;
|
|
29
|
-
min-height: 100dvh;
|
|
30
|
-
position: relative;
|
|
31
|
-
grid-template-columns: ${$withSidebar ? 'auto 1fr' : '1fr'};
|
|
32
|
-
grid-template-rows: ${$withHeader ? 'auto 1fr' : '1fr'};
|
|
33
|
-
grid-template-areas: ${
|
|
34
|
-
$withHeader
|
|
35
|
-
? $withSidebar
|
|
36
|
-
? `'sidebar header' 'sidebar content'`
|
|
37
|
-
: `'header' 'content'`
|
|
38
|
-
: $withSidebar
|
|
39
|
-
? `'sidebar content'`
|
|
40
|
-
: `'content'`
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
& > header {
|
|
44
|
-
grid-area: header;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
& > aside {
|
|
48
|
-
grid-area: sidebar;
|
|
49
|
-
max-height: 100dvh;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
& > main {
|
|
53
|
-
grid-area: content;
|
|
54
|
-
}
|
|
55
|
-
`
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
const StyledMain = styled.main(
|
|
59
|
-
({ theme }) => `
|
|
60
|
-
min-width: 0;
|
|
61
|
-
background: ${theme.colors.backgroundBase};
|
|
62
|
-
`
|
|
63
|
-
);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './PageLayout';
|
package/src/Layouts/index.ts
DELETED
package/src/Theme/Breakpoint.tsx
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext, useEffect, useLayoutEffect, useMemo, useState } from 'react';
|
|
2
|
-
import { Theme } from './types';
|
|
3
|
-
import { useTheme } from 'styled-components';
|
|
4
|
-
import { breakpoints } from './themes/config';
|
|
5
|
-
|
|
6
|
-
type Breakpoint = keyof Theme['breakpoints'];
|
|
7
|
-
|
|
8
|
-
const getBreakpoint = (breakpoints: Theme['breakpoints']): Breakpoint => {
|
|
9
|
-
if (window !== undefined) {
|
|
10
|
-
const width = window.innerWidth;
|
|
11
|
-
for (const [key, value] of Object.entries(breakpoints)) {
|
|
12
|
-
if (width < value) {
|
|
13
|
-
return key as Breakpoint;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
const keys = Object.keys(breakpoints) as Breakpoint[];
|
|
18
|
-
|
|
19
|
-
return keys[keys.length - 1];
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const BreakpointContext = createContext<Breakpoint>(getBreakpoint(breakpoints));
|
|
23
|
-
|
|
24
|
-
export const BreakpointProvider = ({ children }: { children: any }) => {
|
|
25
|
-
const theme = useTheme();
|
|
26
|
-
const [breakpoint, setBreakpoint] = useState<Breakpoint>(getBreakpoint(theme.breakpoints));
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
const handleResize = () => {
|
|
30
|
-
const newBreakpoint = getBreakpoint(theme.breakpoints);
|
|
31
|
-
if (newBreakpoint !== breakpoint) {
|
|
32
|
-
setBreakpoint(newBreakpoint);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
window.addEventListener('resize', handleResize);
|
|
37
|
-
return () => {
|
|
38
|
-
window.removeEventListener('resize', handleResize);
|
|
39
|
-
};
|
|
40
|
-
}, [breakpoint]);
|
|
41
|
-
|
|
42
|
-
return <BreakpointContext.Provider value={breakpoint}>{children}</BreakpointContext.Provider>;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const useBreakpoint = () => {
|
|
46
|
-
const currentBreakpoint = useContext(BreakpointContext);
|
|
47
|
-
const theme = useTheme();
|
|
48
|
-
const breakpointsOrder = useMemo(() => Object.keys(theme.breakpoints) as Breakpoint[], [theme.breakpoints]);
|
|
49
|
-
return { currentBreakpoint, breakpointsOrder: breakpointsOrder };
|
|
50
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createGlobalStyle } from 'styled-components';
|
|
2
|
-
|
|
3
|
-
export const GlobalStyle = createGlobalStyle(
|
|
4
|
-
({ theme }) => `
|
|
5
|
-
*, *::before, *::after {
|
|
6
|
-
box-sizing: border-box;
|
|
7
|
-
margin: 0;
|
|
8
|
-
padding: 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
body, html {
|
|
12
|
-
background: ${theme.colors.backgroundBase};
|
|
13
|
-
color: ${theme.colors.text.main};
|
|
14
|
-
font-family: ${theme.typography.fontFamily};
|
|
15
|
-
font-size: ${theme.baseSize}px;
|
|
16
|
-
}
|
|
17
|
-
`
|
|
18
|
-
);
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { StyleSheetManager, ThemeProvider as ThemeProviderStyled, WebTarget } from 'styled-components';
|
|
2
|
-
import { lightTheme, darkTheme } from './themes';
|
|
3
|
-
import { GlobalStyle } from './GlobalStyle';
|
|
4
|
-
import { BreakpointProvider } from './Breakpoint';
|
|
5
|
-
|
|
6
|
-
interface ThemeProviderProps {
|
|
7
|
-
children: any;
|
|
8
|
-
mode?: 'light' | 'LIGHT' | 'dark' | 'DARK';
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type ThemeMode = 'light' | 'LIGHT' | 'dark' | 'DARK';
|
|
12
|
-
export const ThemeProvider = ({ children, mode }: ThemeProviderProps) => {
|
|
13
|
-
return (
|
|
14
|
-
<StyleSheetManager shouldForwardProp={shouldForwardProp}>
|
|
15
|
-
<ThemeProviderStyled theme={mode == 'light' || mode === 'LIGHT' ? lightTheme : darkTheme}>
|
|
16
|
-
<BreakpointProvider>
|
|
17
|
-
<GlobalStyle />
|
|
18
|
-
{children}
|
|
19
|
-
</BreakpointProvider>
|
|
20
|
-
</ThemeProviderStyled>
|
|
21
|
-
</StyleSheetManager>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
function shouldForwardProp(propName: any, target: WebTarget) {
|
|
26
|
-
if (typeof target === 'string') {
|
|
27
|
-
return !['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'p', 'pt', 'pr', 'pb', 'pl', 'px', 'py'].includes(propName);
|
|
28
|
-
}
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import styled, { css, DefaultTheme } from 'styled-components';
|
|
2
|
-
import { pxToRem } from './utils';
|
|
3
|
-
import React, { useMemo } from 'react';
|
|
4
|
-
import { useBreakpoint } from './Breakpoint';
|
|
5
|
-
import { Breakpoint } from './types';
|
|
6
|
-
import { breakpoints } from './themes/config';
|
|
7
|
-
|
|
8
|
-
type SpaceProps = {
|
|
9
|
-
m?: string | number; // margin
|
|
10
|
-
mt?: string | number; // margin-top
|
|
11
|
-
mr?: string | number; // margin-right
|
|
12
|
-
mb?: string | number; // margin-bottom
|
|
13
|
-
ml?: string | number; // margin-left
|
|
14
|
-
mx?: string | number; // margin-left + margin-right
|
|
15
|
-
my?: string | number; // margin-top + margin-bottom
|
|
16
|
-
p?: string | number; // padding
|
|
17
|
-
pt?: string | number; // padding-top
|
|
18
|
-
pr?: string | number; // padding-right
|
|
19
|
-
pb?: string | number; // padding-bottom
|
|
20
|
-
pl?: string | number; // padding-left
|
|
21
|
-
px?: string | number; // padding-left + padding-right
|
|
22
|
-
py?: string | number; // padding-top + padding-bottom
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
type GeneratedFabricMarginProperties =
|
|
26
|
-
| 'margin'
|
|
27
|
-
| 'margin-top'
|
|
28
|
-
| 'margin-right'
|
|
29
|
-
| 'margin-bottom'
|
|
30
|
-
| 'margin-left'
|
|
31
|
-
| 'margin-inline'
|
|
32
|
-
| 'margin-block'
|
|
33
|
-
| 'padding'
|
|
34
|
-
| 'padding-top'
|
|
35
|
-
| 'padding-right'
|
|
36
|
-
| 'padding-bottom'
|
|
37
|
-
| 'padding-left'
|
|
38
|
-
| 'padding-inline'
|
|
39
|
-
| 'padding-block';
|
|
40
|
-
|
|
41
|
-
type MediaProps<T = object> = {
|
|
42
|
-
media?: {
|
|
43
|
-
[key in Breakpoint]?: Partial<T>;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
type FabricStyledComponentOptions = {
|
|
48
|
-
ignoreStyles?: GeneratedFabricMarginProperties[] | undefined; // Ignore margin styles
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
type CreatedFabricComponent<T extends FabricComponent> =
|
|
52
|
-
| React.ComponentType<Omit<T, 'media'>>
|
|
53
|
-
| React.ForwardRefExoticComponent<Omit<T, 'media'>>;
|
|
54
|
-
export type FabricComponent<T = object> = T & SpaceProps & MediaProps<T>;
|
|
55
|
-
export type StyledFabricComponent<T = object> = T & SpaceProps;
|
|
56
|
-
|
|
57
|
-
const marginStyles = ({ ignoreStyles }: FabricStyledComponentOptions = {}) =>
|
|
58
|
-
css<FabricComponent>(({ theme, ...props }) => {
|
|
59
|
-
return `
|
|
60
|
-
${generatePropertySpaceStyle(theme, 'margin', props.m, ignoreStyles)}
|
|
61
|
-
${generatePropertySpaceStyle(theme, 'margin-top', props.mt, ignoreStyles)}
|
|
62
|
-
${generatePropertySpaceStyle(theme, 'margin-right', props.mr, ignoreStyles)}
|
|
63
|
-
${generatePropertySpaceStyle(theme, 'margin-bottom', props.mb, ignoreStyles)}
|
|
64
|
-
${generatePropertySpaceStyle(theme, 'margin-left', props.ml, ignoreStyles)}
|
|
65
|
-
${generatePropertySpaceStyle(theme, 'margin-inline', props.mx, ignoreStyles)}
|
|
66
|
-
${generatePropertySpaceStyle(theme, 'margin-block', props.my, ignoreStyles)}
|
|
67
|
-
`;
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const paddingStyles = ({ ignoreStyles }: FabricStyledComponentOptions = {}) =>
|
|
71
|
-
css<FabricComponent>(({ theme, ...props }) => {
|
|
72
|
-
return `
|
|
73
|
-
${generatePropertySpaceStyle(theme, 'padding', props.p, ignoreStyles)}
|
|
74
|
-
${generatePropertySpaceStyle(theme, 'padding-top', props.pt, ignoreStyles)}
|
|
75
|
-
${generatePropertySpaceStyle(theme, 'padding-right', props.pr, ignoreStyles)}
|
|
76
|
-
${generatePropertySpaceStyle(theme, 'padding-bottom', props.pb, ignoreStyles)}
|
|
77
|
-
${generatePropertySpaceStyle(theme, 'padding-left', props.pl, ignoreStyles)}
|
|
78
|
-
${generatePropertySpaceStyle(theme, 'padding-inline', props.px, ignoreStyles)}
|
|
79
|
-
${generatePropertySpaceStyle(theme, 'padding-block', props.py, ignoreStyles)}
|
|
80
|
-
`;
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
export const destructSpaceProps = <T extends FabricComponent>(props: T): SpaceProps => {
|
|
84
|
-
const rest: SpaceProps = {};
|
|
85
|
-
['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'p', 'pt', 'pr', 'pb', 'pl', 'px', 'py'].forEach((key) => {
|
|
86
|
-
if (key in props) {
|
|
87
|
-
rest[key as keyof SpaceProps] = props[key as keyof SpaceProps];
|
|
88
|
-
delete props[key as keyof SpaceProps];
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
return rest;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export const generatePropertySpaceStyle = (
|
|
96
|
-
theme: DefaultTheme,
|
|
97
|
-
property: GeneratedFabricMarginProperties,
|
|
98
|
-
value?: string | number,
|
|
99
|
-
ignoredOptions?: GeneratedFabricMarginProperties[]
|
|
100
|
-
) => {
|
|
101
|
-
if (ignoredOptions && ignoredOptions.includes(property)) {
|
|
102
|
-
return '';
|
|
103
|
-
}
|
|
104
|
-
if (value !== undefined) {
|
|
105
|
-
const t = typeof value === 'number';
|
|
106
|
-
return `${property}: ${typeof value === 'number' ? `${pxToRem(value, theme.baseSize)}` : value};`;
|
|
107
|
-
}
|
|
108
|
-
return '';
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export function getResponsiveProps<T = object>(
|
|
112
|
-
{ media, ...props }: T & MediaProps<T>,
|
|
113
|
-
currentBreakpoint: Breakpoint,
|
|
114
|
-
breakpointOrder: Breakpoint[]
|
|
115
|
-
) {
|
|
116
|
-
if (!media) {
|
|
117
|
-
return props;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Отримуємо індекс поточного breakpoint
|
|
121
|
-
const currentIndex = breakpointOrder.indexOf(currentBreakpoint);
|
|
122
|
-
|
|
123
|
-
// Створюємо результуючий об'єкт, починаючи з базових props
|
|
124
|
-
let result = { ...props };
|
|
125
|
-
|
|
126
|
-
// Застосовуємо стилі від найменшого breakpoint до поточного (mobile-first)
|
|
127
|
-
for (let i = 0; i <= currentIndex; i++) {
|
|
128
|
-
const breakpoint = breakpointOrder[i];
|
|
129
|
-
if (media[breakpoint]) {
|
|
130
|
-
result = {
|
|
131
|
-
...result,
|
|
132
|
-
...media[breakpoint],
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return result;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export const createComponent = <T extends FabricComponent, R = unknown>(Component: CreatedFabricComponent<T>) => {
|
|
141
|
-
return React.forwardRef<R, FabricComponent<T>>((props, ref) => {
|
|
142
|
-
const { currentBreakpoint, breakpointsOrder } = useBreakpoint();
|
|
143
|
-
const responsiveProps = useMemo(
|
|
144
|
-
() => getResponsiveProps<T>(props as T & MediaProps<T>, currentBreakpoint, breakpointsOrder),
|
|
145
|
-
[props, currentBreakpoint]
|
|
146
|
-
);
|
|
147
|
-
return <Component {...responsiveProps} ref={ref} />;
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export const createStyledComponent = <T extends object = StyledFabricComponent>(
|
|
152
|
-
component: React.ComponentType<T>,
|
|
153
|
-
options?: FabricStyledComponentOptions
|
|
154
|
-
) => {
|
|
155
|
-
return styled(component)<StyledFabricComponent<T>>`
|
|
156
|
-
${marginStyles(options)}
|
|
157
|
-
${paddingStyles(options)}
|
|
158
|
-
`;
|
|
159
|
-
};
|
package/src/Theme/index.ts
DELETED
package/src/Theme/styled.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// Індексні шари (z-index) для різних компонентів
|
|
2
|
-
export const zIndex = {
|
|
3
|
-
dropdown: 1000,
|
|
4
|
-
sticky: 1020,
|
|
5
|
-
fixed: 1030,
|
|
6
|
-
backdrop: 1040,
|
|
7
|
-
modal: 1050,
|
|
8
|
-
popover: 1060,
|
|
9
|
-
tooltip: 1070,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// Розміри брейкпоінтів
|
|
13
|
-
export const breakpoints = {
|
|
14
|
-
xs: 320,
|
|
15
|
-
s: 576,
|
|
16
|
-
m: 768,
|
|
17
|
-
l: 992,
|
|
18
|
-
xl: 1200,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// Типографія
|
|
22
|
-
export const typography = {
|
|
23
|
-
fontFamily:
|
|
24
|
-
'Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;',
|
|
25
|
-
lineHeight: 1.49,
|
|
26
|
-
// Розміри текстових елементів
|
|
27
|
-
variants: {
|
|
28
|
-
h1: {
|
|
29
|
-
fontSize: 22,
|
|
30
|
-
},
|
|
31
|
-
h2: {
|
|
32
|
-
fontSize: 16,
|
|
33
|
-
},
|
|
34
|
-
h3: {
|
|
35
|
-
fontSize: 14,
|
|
36
|
-
},
|
|
37
|
-
body: {
|
|
38
|
-
fontSize: 12,
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
};
|