@cyber-harbour/ui 1.0.60 → 1.0.61
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 +482 -44
- package/dist/index.d.ts +482 -44
- package/dist/index.js +219 -219
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +234 -234
- 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/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 +29 -36
- package/src/Core/Tooltip/Tooltip.tsx +35 -41
- package/src/Core/Typography/Typography.tsx +31 -33
- package/src/Core/index.ts +1 -0
- 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
package/package.json
CHANGED
package/src/Core/Alert/Alert.tsx
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
FabricComponent,
|
|
5
|
+
StyledFabricComponent,
|
|
6
|
+
createComponent,
|
|
7
|
+
createStyledComponent,
|
|
8
|
+
generatePropertySpaceStyle,
|
|
9
|
+
} from '../../Theme';
|
|
4
10
|
import { AlertIcon } from '../IconComponents';
|
|
5
11
|
|
|
6
12
|
type AlertProps = FabricComponent<{
|
|
@@ -9,7 +15,7 @@ type AlertProps = FabricComponent<{
|
|
|
9
15
|
}> &
|
|
10
16
|
Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
11
17
|
|
|
12
|
-
export const Alert = ({ title, note, ...props }
|
|
18
|
+
export const Alert = createComponent<AlertProps>(({ title, note, ...props }) => {
|
|
13
19
|
return (
|
|
14
20
|
<StyledContainer {...props}>
|
|
15
21
|
<IconWrapper>
|
|
@@ -21,7 +27,7 @@ export const Alert = ({ title, note, ...props }: AlertProps) => {
|
|
|
21
27
|
</div>
|
|
22
28
|
</StyledContainer>
|
|
23
29
|
);
|
|
24
|
-
};
|
|
30
|
+
});
|
|
25
31
|
|
|
26
32
|
const IconWrapper = styled.div(
|
|
27
33
|
({ theme: { alert } }) => `
|
|
@@ -60,8 +66,8 @@ const Note = styled.p(
|
|
|
60
66
|
`
|
|
61
67
|
);
|
|
62
68
|
|
|
63
|
-
const StyledContainer =
|
|
64
|
-
styled.div<
|
|
69
|
+
const StyledContainer = createStyledComponent(
|
|
70
|
+
styled.div<StyledFabricComponent>(
|
|
65
71
|
({ theme, py = theme.alert.paddingBlock, pl = theme.alert.paddingLeft, pr = theme.alert.paddingRight }) => {
|
|
66
72
|
return `
|
|
67
73
|
display: flex;
|
package/src/Core/Box/Box.tsx
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ColorVariant,
|
|
3
3
|
createComponent,
|
|
4
|
+
createStyledComponent,
|
|
4
5
|
FabricComponent,
|
|
5
6
|
generatePropertySpaceStyle,
|
|
6
7
|
resolveThemeColor,
|
|
8
|
+
StyledFabricComponent,
|
|
7
9
|
} from '../../Theme';
|
|
8
10
|
import { styled } from 'styled-components';
|
|
9
11
|
|
|
10
|
-
type BoxProps =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} & React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
|
|
17
|
-
>;
|
|
12
|
+
type BoxProps = {
|
|
13
|
+
children?: any;
|
|
14
|
+
element?: 'div' | 'section';
|
|
15
|
+
hasBorder?: boolean;
|
|
16
|
+
color?: ColorVariant | string;
|
|
17
|
+
} & React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
18
18
|
|
|
19
|
-
export const Box = (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
export const Box = createComponent<BoxProps>(
|
|
20
|
+
({ children, element = 'div', hasBorder = true, color, ...props }): any => {
|
|
21
|
+
return (
|
|
22
|
+
<StyledBox as={element} $hasBorder={hasBorder} $color={color} {...props}>
|
|
23
|
+
{children}
|
|
24
|
+
</StyledBox>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
);
|
|
26
28
|
|
|
27
29
|
type StyledProps = { $hasBorder: boolean; $color?: string };
|
|
28
30
|
|
|
29
|
-
const StyledBox =
|
|
30
|
-
styled('div')<
|
|
31
|
+
const StyledBox = createStyledComponent(
|
|
32
|
+
styled('div')<StyledFabricComponent<StyledProps>>(
|
|
31
33
|
({ theme, $hasBorder, $color, px = theme.box.padding, py = theme.box.padding }) => `
|
|
32
34
|
${generatePropertySpaceStyle(theme, 'padding-inline', px)}
|
|
33
35
|
${generatePropertySpaceStyle(theme, 'padding-block', py)}
|
|
@@ -8,11 +8,12 @@ import {
|
|
|
8
8
|
getButtonSizeStyles,
|
|
9
9
|
ButtonElementStyle,
|
|
10
10
|
createComponent,
|
|
11
|
-
FabricComponent,
|
|
12
11
|
generatePropertySpaceStyle,
|
|
12
|
+
createStyledComponent,
|
|
13
|
+
StyledFabricComponent,
|
|
13
14
|
} from '../../Theme';
|
|
14
15
|
|
|
15
|
-
type BaseButtonProps =
|
|
16
|
+
type BaseButtonProps = {
|
|
16
17
|
children?: any;
|
|
17
18
|
variant?: ButtonVariant;
|
|
18
19
|
color?: ButtonColor;
|
|
@@ -23,11 +24,10 @@ type BaseButtonProps = FabricComponent<{
|
|
|
23
24
|
icon?: any;
|
|
24
25
|
iconPosition?: 'left' | 'right';
|
|
25
26
|
iconVariant?: 'filled' | 'empty';
|
|
26
|
-
}
|
|
27
|
-
|
|
27
|
+
};
|
|
28
28
|
export type ButtonProps = (
|
|
29
|
-
| Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'>
|
|
30
|
-
| Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children'>
|
|
29
|
+
| Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children' | 'media'>
|
|
30
|
+
| Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'media'>
|
|
31
31
|
) &
|
|
32
32
|
BaseButtonProps;
|
|
33
33
|
|
|
@@ -70,21 +70,22 @@ type StyledButtonProps = {
|
|
|
70
70
|
$iconVariant: 'filled' | 'empty';
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
const
|
|
74
|
-
(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
73
|
+
const StyledButton = createStyledComponent(
|
|
74
|
+
styled.button<StyledFabricComponent<StyledButtonProps>>(
|
|
75
|
+
({
|
|
76
|
+
$variant,
|
|
77
|
+
$color,
|
|
78
|
+
$size,
|
|
79
|
+
$disabled,
|
|
80
|
+
$fullWidth,
|
|
81
|
+
$iconPosition,
|
|
82
|
+
$iconVariant,
|
|
83
|
+
theme,
|
|
84
|
+
px = $variant !== 'empty' ? theme.button.sizes[$size].paddingInline : 0,
|
|
85
|
+
py = $variant !== 'empty' ? theme.button.sizes[$size].paddingBlock : 0,
|
|
86
|
+
}) => {
|
|
87
|
+
const sizes = getButtonSizeStyles(theme, $size);
|
|
88
|
+
return `
|
|
88
89
|
${getCss(getButtonStyles(theme, $variant, $color, 'default'))}
|
|
89
90
|
font-size: ${sizes.fontSize};
|
|
90
91
|
gap: ${sizes.gap};
|
|
@@ -155,39 +156,42 @@ const Btn = styled.button<FabricComponent<StyledButtonProps>>(
|
|
|
155
156
|
: ``
|
|
156
157
|
}
|
|
157
158
|
`;
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
export const Button = createComponent<ButtonProps>(
|
|
164
|
+
({
|
|
165
|
+
children,
|
|
166
|
+
variant = 'fill',
|
|
167
|
+
color = 'primary',
|
|
168
|
+
size = 'medium',
|
|
169
|
+
disabled = false,
|
|
170
|
+
fullWidth = false,
|
|
171
|
+
className,
|
|
172
|
+
icon,
|
|
173
|
+
iconPosition = 'left',
|
|
174
|
+
iconVariant = 'empty',
|
|
175
|
+
...props
|
|
176
|
+
}) => {
|
|
177
|
+
return (
|
|
178
|
+
// @ts-ignore
|
|
179
|
+
<StyledButton
|
|
180
|
+
as={'href' in props ? 'a' : 'button'}
|
|
181
|
+
$variant={variant}
|
|
182
|
+
$color={color}
|
|
183
|
+
$size={size}
|
|
184
|
+
$disabled={disabled}
|
|
185
|
+
$fullWidth={fullWidth}
|
|
186
|
+
$iconPosition={iconPosition}
|
|
187
|
+
$iconVariant={iconVariant}
|
|
188
|
+
disabled={disabled}
|
|
189
|
+
className={className}
|
|
190
|
+
{...props}
|
|
191
|
+
>
|
|
192
|
+
{!!icon && <StyledIconWrapper>{icon}</StyledIconWrapper>}
|
|
193
|
+
{!!children && <ButtonTextContainer>{children}</ButtonTextContainer>}
|
|
194
|
+
</StyledButton>
|
|
195
|
+
);
|
|
158
196
|
}
|
|
159
197
|
);
|
|
160
|
-
const StyledButton = createComponent(Btn);
|
|
161
|
-
|
|
162
|
-
export const Button = ({
|
|
163
|
-
children,
|
|
164
|
-
variant = 'fill',
|
|
165
|
-
color = 'primary',
|
|
166
|
-
size = 'medium',
|
|
167
|
-
disabled = false,
|
|
168
|
-
fullWidth = false,
|
|
169
|
-
className,
|
|
170
|
-
icon,
|
|
171
|
-
iconPosition = 'left',
|
|
172
|
-
iconVariant = 'empty',
|
|
173
|
-
...props
|
|
174
|
-
}: ButtonProps) => {
|
|
175
|
-
return (
|
|
176
|
-
<StyledButton
|
|
177
|
-
as={'href' in props ? 'a' : 'button'}
|
|
178
|
-
$variant={variant}
|
|
179
|
-
$color={color}
|
|
180
|
-
$size={size}
|
|
181
|
-
$disabled={disabled}
|
|
182
|
-
$fullWidth={fullWidth}
|
|
183
|
-
$iconPosition={iconPosition}
|
|
184
|
-
$iconVariant={iconVariant}
|
|
185
|
-
disabled={disabled}
|
|
186
|
-
className={className}
|
|
187
|
-
{...props}
|
|
188
|
-
>
|
|
189
|
-
{!!icon && <StyledIconWrapper>{icon}</StyledIconWrapper>}
|
|
190
|
-
{!!children && <ButtonTextContainer>{children}</ButtonTextContainer>}
|
|
191
|
-
</StyledButton>
|
|
192
|
-
);
|
|
193
|
-
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
import {
|
|
3
|
+
import { createComponent, createStyledComponent, destructSpaceProps, pxToRem } from '../../Theme';
|
|
4
4
|
|
|
5
|
-
type CheckboxProps =
|
|
5
|
+
type CheckboxProps = {
|
|
6
6
|
label?: any;
|
|
7
|
-
}
|
|
8
|
-
Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type'>;
|
|
7
|
+
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type'>;
|
|
9
8
|
|
|
10
|
-
export const Checkbox = ({ label, className, disabled, ...props }
|
|
9
|
+
export const Checkbox = createComponent<CheckboxProps>(({ label, className, disabled, ...props }) => {
|
|
11
10
|
const spaceProps = destructSpaceProps(props);
|
|
12
11
|
return (
|
|
13
12
|
<StyledCheckbox className={className} $disabled={disabled} {...spaceProps}>
|
|
@@ -16,7 +15,7 @@ export const Checkbox = ({ label, className, disabled, ...props }: CheckboxProps
|
|
|
16
15
|
{!!label && <LabelText>{label}</LabelText>}
|
|
17
16
|
</StyledCheckbox>
|
|
18
17
|
);
|
|
19
|
-
};
|
|
18
|
+
});
|
|
20
19
|
|
|
21
20
|
const CustomCheckbox = styled.div(
|
|
22
21
|
({ theme }) => `
|
|
@@ -48,7 +47,7 @@ const HiddenInput = styled.input`
|
|
|
48
47
|
position: absolute;
|
|
49
48
|
`;
|
|
50
49
|
|
|
51
|
-
const StyledCheckbox =
|
|
50
|
+
const StyledCheckbox = createStyledComponent(
|
|
52
51
|
styled.label<{ $disabled?: boolean }>(({ theme, $disabled }) => {
|
|
53
52
|
return `
|
|
54
53
|
position: relative;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import ReactContentLoader, { IContentLoaderProps } from 'react-content-loader';
|
|
2
|
+
import { useTheme } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
export interface ContentLoaderProps extends Omit<IContentLoaderProps, 'backgroundColor' | 'foregroundColor'> {
|
|
5
|
+
children?: any;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const ContentLoader = (props: ContentLoaderProps) => {
|
|
9
|
+
const {
|
|
10
|
+
contentLoader: { foreground, background },
|
|
11
|
+
} = useTheme();
|
|
12
|
+
return <ReactContentLoader {...props} backgroundColor={background} foregroundColor={foreground} />;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ContentLoader';
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { createPortal } from 'react-dom';
|
|
2
2
|
import { styled } from 'styled-components';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
createComponent,
|
|
5
|
+
createStyledComponent,
|
|
6
|
+
FabricComponent,
|
|
7
|
+
generatePropertySpaceStyle,
|
|
8
|
+
propToRem,
|
|
9
|
+
pxToRem,
|
|
10
|
+
StyledFabricComponent,
|
|
11
|
+
} from '../../Theme';
|
|
4
12
|
import { useBodyScrollLock } from '../../utils';
|
|
5
13
|
import { useEffect, useRef } from 'react';
|
|
6
14
|
|
|
@@ -12,12 +20,12 @@ type DrawerProps = {
|
|
|
12
20
|
width?: string | number;
|
|
13
21
|
};
|
|
14
22
|
|
|
15
|
-
export const Drawer = (props
|
|
23
|
+
export const Drawer = createComponent<DrawerProps>((props) => {
|
|
16
24
|
useBodyScrollLock(props.isOpen);
|
|
17
25
|
|
|
18
26
|
if (!props.isOpen) return null;
|
|
19
27
|
return createPortal(<DrawerWithOutclick {...props} />, document.body);
|
|
20
|
-
};
|
|
28
|
+
});
|
|
21
29
|
|
|
22
30
|
const DrawerWithOutclick = ({ onClose, children, width, header }: DrawerProps) => {
|
|
23
31
|
const drawerRef = useRef<HTMLDivElement>(null);
|
|
@@ -45,8 +53,8 @@ type DrawerHeaderProps = FabricComponent<{
|
|
|
45
53
|
children?: any;
|
|
46
54
|
}>;
|
|
47
55
|
|
|
48
|
-
export const DrawerHeader: any =
|
|
49
|
-
styled.div
|
|
56
|
+
export const DrawerHeader: any = createStyledComponent<DrawerHeaderProps>(
|
|
57
|
+
styled.div(
|
|
50
58
|
({ theme, p = theme.drawer.padding }) => `
|
|
51
59
|
grid-area: drawer-header;
|
|
52
60
|
${generatePropertySpaceStyle(theme, 'padding', p)};
|
|
@@ -57,26 +65,33 @@ export const DrawerHeader: any = createComponent<DrawerHeaderProps>(
|
|
|
57
65
|
}
|
|
58
66
|
);
|
|
59
67
|
|
|
60
|
-
type DrawerBodyProps =
|
|
68
|
+
type DrawerBodyProps = StyledFabricComponent<{
|
|
61
69
|
children?: any;
|
|
62
70
|
}>;
|
|
63
71
|
|
|
64
|
-
export const DrawerBody: any = createComponent(
|
|
65
|
-
|
|
66
|
-
(
|
|
72
|
+
export const DrawerBody: any = createComponent<DrawerBodyProps>(
|
|
73
|
+
createStyledComponent<DrawerBodyProps>(
|
|
74
|
+
styled.div(
|
|
75
|
+
({ theme, px = theme.drawer.padding, pb = theme.drawer.padding }) => `
|
|
67
76
|
grid-area: drawer-body;
|
|
68
77
|
max-height: 100%;
|
|
69
78
|
overflow-y: auto;
|
|
70
79
|
${generatePropertySpaceStyle(theme, 'padding-inline', px)};
|
|
71
80
|
${generatePropertySpaceStyle(theme, 'padding-bottom', pb)};
|
|
72
81
|
`
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
),
|
|
83
|
+
{
|
|
84
|
+
ignoreStyles: ['padding', 'padding-bottom'],
|
|
85
|
+
}
|
|
86
|
+
)
|
|
77
87
|
);
|
|
78
88
|
|
|
79
|
-
|
|
89
|
+
type StyledDrawerProps = {
|
|
90
|
+
$header?: number;
|
|
91
|
+
$width?: string | number;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const StyledDrawer = styled.div<StyledDrawerProps>(
|
|
80
95
|
({ theme, $header, $width }) => `
|
|
81
96
|
position: fixed;
|
|
82
97
|
display: grid;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, forwardRef } from 'react';
|
|
2
|
-
import { createComponent, FabricComponent } from '../../Theme';
|
|
2
|
+
import { createComponent, createStyledComponent, FabricComponent, StyledFabricComponent } from '../../Theme';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
|
|
5
5
|
export type FlexDirection = 'row' | 'column' | 'row-reverse' | 'column-reverse';
|
|
@@ -23,46 +23,50 @@ export interface FlexContainerProps extends FabricComponent<Omit<React.HTMLAttri
|
|
|
23
23
|
as?: any; // TODO: fix type to styled component or intrinsic element
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export const FlexContainer
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
26
|
+
export const FlexContainer = createComponent<FlexContainerProps, HTMLDivElement>(
|
|
27
|
+
forwardRef<HTMLDivElement, FlexContainerProps>(
|
|
28
|
+
(
|
|
29
|
+
{
|
|
30
|
+
children,
|
|
31
|
+
direction = 'row',
|
|
32
|
+
wrap = 'nowrap',
|
|
33
|
+
justify = 'flex-start',
|
|
34
|
+
align = 'stretch',
|
|
35
|
+
alignContent,
|
|
36
|
+
gap,
|
|
37
|
+
rowGap,
|
|
38
|
+
columnGap,
|
|
39
|
+
className,
|
|
40
|
+
style,
|
|
41
|
+
as = 'div',
|
|
42
|
+
...props
|
|
43
|
+
},
|
|
44
|
+
ref
|
|
45
|
+
) => {
|
|
46
|
+
return (
|
|
47
|
+
<StyledContainer
|
|
48
|
+
as={as}
|
|
49
|
+
$direction={direction}
|
|
50
|
+
$wrap={wrap}
|
|
51
|
+
$justify={justify}
|
|
52
|
+
$align={align}
|
|
53
|
+
$alignContent={alignContent}
|
|
54
|
+
$gap={gap}
|
|
55
|
+
$rowGap={rowGap}
|
|
56
|
+
$columnGap={columnGap}
|
|
57
|
+
className={className}
|
|
58
|
+
style={style}
|
|
59
|
+
ref={ref}
|
|
60
|
+
{...props}
|
|
61
|
+
>
|
|
62
|
+
{children}
|
|
63
|
+
</StyledContainer>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
);
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
type StyledFlexContainerProps = StyledFabricComponent<{
|
|
66
70
|
$direction: FlexDirection;
|
|
67
71
|
$wrap: FlexWrap;
|
|
68
72
|
$justify: FlexJustify;
|
|
@@ -71,9 +75,9 @@ interface StyledFlexContainerProps {
|
|
|
71
75
|
$gap?: FlexGap;
|
|
72
76
|
$rowGap?: FlexGap;
|
|
73
77
|
$columnGap?: FlexGap;
|
|
74
|
-
}
|
|
78
|
+
}>;
|
|
75
79
|
|
|
76
|
-
const StyledContainer = styled.div
|
|
80
|
+
const StyledContainer = createStyledComponent<StyledFlexContainerProps>(styled.div`
|
|
77
81
|
${({ $direction, $wrap, $justify, $align, $alignContent, $gap, $rowGap, $columnGap }) => `
|
|
78
82
|
display: flex;
|
|
79
83
|
width: 100%;
|
|
@@ -87,6 +91,4 @@ const StyledContainer = styled.div<StyledFlexContainerProps>`
|
|
|
87
91
|
${$rowGap !== undefined ? `row-gap: ${typeof $rowGap === 'number' ? `${$rowGap}px` : $rowGap};` : ''}
|
|
88
92
|
${$columnGap !== undefined ? `column-gap: ${typeof $columnGap === 'number' ? `${$columnGap}px` : $columnGap};` : ''}
|
|
89
93
|
`}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const StyledFlexContainer = createComponent(StyledContainer);
|
|
94
|
+
`);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import { styled } from 'styled-components';
|
|
3
|
+
import { createComponent } from '../../Theme';
|
|
3
4
|
|
|
4
5
|
export type FlexItemGrow = number;
|
|
5
6
|
export type FlexItemShrink = number;
|
|
@@ -18,32 +19,24 @@ export interface FlexItemProps {
|
|
|
18
19
|
as?: any; //TODO: fix type to styled component or intrinsic element
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
export const FlexItem = (
|
|
22
|
-
children,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
$order={order}
|
|
40
|
-
className={className}
|
|
41
|
-
style={style}
|
|
42
|
-
>
|
|
43
|
-
{children}
|
|
44
|
-
</StyledFlexItem>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
22
|
+
export const FlexItem = createComponent<FlexItemProps>(
|
|
23
|
+
({ children, grow, shrink, basis, align, order, className, style, as = 'div' }) => {
|
|
24
|
+
return (
|
|
25
|
+
<StyledFlexItem
|
|
26
|
+
as={as}
|
|
27
|
+
$grow={grow}
|
|
28
|
+
$shrink={shrink}
|
|
29
|
+
$basis={basis}
|
|
30
|
+
$align={align}
|
|
31
|
+
$order={order}
|
|
32
|
+
className={className}
|
|
33
|
+
style={style}
|
|
34
|
+
>
|
|
35
|
+
{children}
|
|
36
|
+
</StyledFlexItem>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
);
|
|
47
40
|
|
|
48
41
|
interface StyledFlexItemProps {
|
|
49
42
|
$grow?: FlexItemGrow;
|
package/src/Core/Label/Label.tsx
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
FabricComponent,
|
|
5
|
+
LabelSize,
|
|
6
|
+
createComponent,
|
|
7
|
+
createStyledComponent,
|
|
8
|
+
generatePropertySpaceStyle,
|
|
9
|
+
propToRem,
|
|
10
|
+
} from '../../Theme';
|
|
4
11
|
|
|
5
12
|
type LabelProps = FabricComponent<{
|
|
6
13
|
label?: any;
|
|
@@ -22,40 +29,34 @@ type LabelDirection = {
|
|
|
22
29
|
direction?: Omit<React.CSSProperties['flexDirection'], 'row' | 'row-reverse'>;
|
|
23
30
|
};
|
|
24
31
|
|
|
25
|
-
export const Label = (
|
|
26
|
-
label,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
direction = 'column',
|
|
30
|
-
size = 'small',
|
|
31
|
-
errorText,
|
|
32
|
-
fullWidth,
|
|
33
|
-
...props
|
|
34
|
-
}: LabelProps) => {
|
|
35
|
-
const $isRow = direction === 'row' || direction === 'row-reverse';
|
|
36
|
-
const $width = $isRow ? (props as LabelDirectionRaw).childrenWidth || '50%' : '100%';
|
|
32
|
+
export const Label = createComponent<LabelProps>(
|
|
33
|
+
({ label, helpText, children, direction = 'column', size = 'small', errorText, fullWidth, ...props }) => {
|
|
34
|
+
const $isRow = direction === 'row' || direction === 'row-reverse';
|
|
35
|
+
const $width = $isRow ? (props as LabelDirectionRaw).childrenWidth || '50%' : '100%';
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
37
|
+
return (
|
|
38
|
+
<StyledLabel $size={size} $direction={direction} $fullWidth={fullWidth} $isRow={$isRow} {...props}>
|
|
39
|
+
{Boolean(label || helpText) && (
|
|
40
|
+
<LabelWrapper $width={$width}>
|
|
41
|
+
{!!label && <LabelText $size={size}>{label}</LabelText>}
|
|
42
|
+
{!!helpText && <HelpText $size={size}>{helpText}</HelpText>}
|
|
43
|
+
</LabelWrapper>
|
|
44
|
+
)}
|
|
45
|
+
<Wrapper $width={$width}>
|
|
46
|
+
{children}
|
|
47
|
+
{!!errorText && <ErrorText $size={size}>{errorText}</ErrorText>}
|
|
48
|
+
</Wrapper>
|
|
49
|
+
</StyledLabel>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
53
|
|
|
54
54
|
type StyledProps = {
|
|
55
55
|
$size: LabelSize;
|
|
56
56
|
$direction?: LabelDirection['direction'] | LabelDirectionRaw['direction'];
|
|
57
57
|
$fullWidth?: boolean;
|
|
58
58
|
$isRow: boolean;
|
|
59
|
+
children?: any;
|
|
59
60
|
};
|
|
60
61
|
|
|
61
62
|
type WrapperProps = { $width: number | string };
|
|
@@ -107,8 +108,8 @@ const ErrorText = styled.div<TextProps>(
|
|
|
107
108
|
`
|
|
108
109
|
);
|
|
109
110
|
|
|
110
|
-
const StyledLabel =
|
|
111
|
-
styled.label
|
|
111
|
+
const StyledLabel = createStyledComponent<FabricComponent<StyledProps>>(
|
|
112
|
+
styled.label(
|
|
112
113
|
({
|
|
113
114
|
theme,
|
|
114
115
|
$direction = 'column',
|
package/src/Core/Line/Line.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponent, FabricComponent } from '../../Theme';
|
|
1
|
+
import { createComponent, createStyledComponent, FabricComponent, StyledFabricComponent } from '../../Theme';
|
|
2
2
|
import { styled } from 'styled-components';
|
|
3
3
|
|
|
4
4
|
type LineProps = FabricComponent<
|
|
@@ -7,16 +7,16 @@ type LineProps = FabricComponent<
|
|
|
7
7
|
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'children'>
|
|
8
8
|
>;
|
|
9
9
|
|
|
10
|
-
export const Line = ({ direction = 'horizontal', ...props }
|
|
10
|
+
export const Line = createComponent<LineProps>(({ direction = 'horizontal', ...props }) => {
|
|
11
11
|
return <StyledLine {...props} $direction={direction} />;
|
|
12
|
-
};
|
|
12
|
+
});
|
|
13
13
|
|
|
14
14
|
interface StyledLineProps {
|
|
15
15
|
$direction: 'horizontal' | 'vertical';
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const StyledLine =
|
|
19
|
-
styled.div
|
|
18
|
+
const StyledLine = createStyledComponent<StyledFabricComponent<StyledLineProps>>(
|
|
19
|
+
styled.div(
|
|
20
20
|
({ theme, $direction }) => `
|
|
21
21
|
width: ${$direction === 'horizontal' ? '100%' : theme.line.size};
|
|
22
22
|
height: ${$direction === 'vertical' ? '100%' : theme.line.size};
|