@cyber-harbour/ui 1.0.60 → 1.0.62
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 +517 -46
- package/dist/index.d.ts +517 -46
- package/dist/index.js +244 -237
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +245 -238
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Core/Alert/Alert.tsx +11 -5
- package/src/Core/Box/Box.tsx +19 -17
- package/src/Core/Button/Button.tsx +59 -55
- package/src/Core/Checkbox/Checkbox.tsx +6 -7
- package/src/Core/ContentLoader/ContentLoader.tsx +13 -0
- package/src/Core/ContentLoader/index.ts +1 -0
- package/src/Core/Drawer/Drawer.tsx +29 -14
- package/src/Core/Flex/FlexContainer.tsx +47 -45
- package/src/Core/Flex/FlexItem.tsx +19 -26
- package/src/Core/IconComponents/FlashIcon.tsx +16 -0
- package/src/Core/IconComponents/UserInCircle.tsx +24 -0
- package/src/Core/IconComponents/index.ts +2 -0
- package/src/Core/Label/Label.tsx +31 -30
- package/src/Core/Line/Line.tsx +5 -5
- package/src/Core/LinerProgress/LinerProgress.tsx +14 -20
- package/src/Core/Switch/Switch.tsx +4 -4
- package/src/Core/Tag/Tag.tsx +40 -39
- package/src/Core/Tooltip/Tooltip.tsx +45 -41
- package/src/Core/Typography/Typography.tsx +31 -33
- package/src/Core/index.ts +1 -0
- package/src/FullscreenCard/FullscreenCard.tsx +21 -26
- package/src/Layouts/Container/Container.tsx +13 -7
- package/src/Theme/Breakpoint.tsx +50 -0
- package/src/Theme/ThemeProvider.tsx +5 -2
- package/src/Theme/{componentFabric.ts → componentFabric.tsx} +90 -36
- package/src/Theme/index.ts +1 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StyleSheetManager, ThemeProvider as ThemeProviderStyled, WebTarget } from 'styled-components';
|
|
2
2
|
import { lightTheme, darkTheme } from './themes';
|
|
3
3
|
import { GlobalStyle } from './GlobalStyle';
|
|
4
|
+
import { BreakpointProvider } from './Breakpoint';
|
|
4
5
|
|
|
5
6
|
interface ThemeProviderProps {
|
|
6
7
|
children: any;
|
|
@@ -12,8 +13,10 @@ export const ThemeProvider = ({ children, mode }: ThemeProviderProps) => {
|
|
|
12
13
|
return (
|
|
13
14
|
<StyleSheetManager shouldForwardProp={shouldForwardProp}>
|
|
14
15
|
<ThemeProviderStyled theme={mode == 'light' || mode === 'LIGHT' ? lightTheme : darkTheme}>
|
|
15
|
-
<
|
|
16
|
-
|
|
16
|
+
<BreakpointProvider>
|
|
17
|
+
<GlobalStyle />
|
|
18
|
+
{children}
|
|
19
|
+
</BreakpointProvider>
|
|
17
20
|
</ThemeProviderStyled>
|
|
18
21
|
</StyleSheetManager>
|
|
19
22
|
);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import styled, { css,
|
|
1
|
+
import styled, { css, DefaultTheme } from 'styled-components';
|
|
2
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';
|
|
3
7
|
|
|
4
8
|
type SpaceProps = {
|
|
5
9
|
m?: string | number; // margin
|
|
@@ -18,9 +22,39 @@ type SpaceProps = {
|
|
|
18
22
|
py?: string | number; // padding-top + padding-bottom
|
|
19
23
|
};
|
|
20
24
|
|
|
21
|
-
|
|
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
|
+
};
|
|
22
46
|
|
|
23
|
-
|
|
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 = {}) =>
|
|
24
58
|
css<FabricComponent>(({ theme, ...props }) => {
|
|
25
59
|
return `
|
|
26
60
|
${generatePropertySpaceStyle(theme, 'margin', props.m, ignoreStyles)}
|
|
@@ -33,7 +67,7 @@ const marginStyles = ({ ignoreStyles }: FabricComponentOptions = {}) =>
|
|
|
33
67
|
`;
|
|
34
68
|
});
|
|
35
69
|
|
|
36
|
-
const paddingStyles = ({ ignoreStyles }:
|
|
70
|
+
const paddingStyles = ({ ignoreStyles }: FabricStyledComponentOptions = {}) =>
|
|
37
71
|
css<FabricComponent>(({ theme, ...props }) => {
|
|
38
72
|
return `
|
|
39
73
|
${generatePropertySpaceStyle(theme, 'padding', props.p, ignoreStyles)}
|
|
@@ -46,21 +80,17 @@ const paddingStyles = ({ ignoreStyles }: FabricComponentOptions = {}) =>
|
|
|
46
80
|
`;
|
|
47
81
|
});
|
|
48
82
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
| 'padding-bottom'
|
|
61
|
-
| 'padding-left'
|
|
62
|
-
| 'padding-inline'
|
|
63
|
-
| 'padding-block';
|
|
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
|
+
};
|
|
64
94
|
|
|
65
95
|
export const generatePropertySpaceStyle = (
|
|
66
96
|
theme: DefaultTheme,
|
|
@@ -78,28 +108,52 @@ export const generatePropertySpaceStyle = (
|
|
|
78
108
|
return '';
|
|
79
109
|
};
|
|
80
110
|
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+
});
|
|
83
149
|
};
|
|
84
150
|
|
|
85
|
-
export const
|
|
151
|
+
export const createStyledComponent = <T extends object = StyledFabricComponent>(
|
|
86
152
|
component: React.ComponentType<T>,
|
|
87
|
-
options?:
|
|
153
|
+
options?: FabricStyledComponentOptions
|
|
88
154
|
) => {
|
|
89
|
-
return styled(component)<T
|
|
155
|
+
return styled(component)<StyledFabricComponent<T>>`
|
|
90
156
|
${marginStyles(options)}
|
|
91
157
|
${paddingStyles(options)}
|
|
92
158
|
`;
|
|
93
159
|
};
|
|
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
|
-
};
|
package/src/Theme/index.ts
CHANGED