@cyber-harbour/ui 1.0.50 → 1.0.52
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 +98 -4
- package/dist/index.d.ts +98 -4
- package/dist/index.js +275 -193
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +274 -192
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Core/Checkbox/Checkbox.tsx +74 -0
- package/src/Core/Checkbox/index.ts +1 -0
- package/src/Core/Label/Label.tsx +122 -0
- package/src/Core/Label/index.ts +1 -0
- package/src/Core/index.ts +2 -0
- package/src/Graph2D/Graph2D.tsx +692 -512
- package/src/Graph2D/types.ts +40 -0
- package/src/Theme/componentFabric.ts +14 -2
- package/src/Theme/themes/dark.ts +18 -0
- package/src/Theme/themes/light.ts +18 -0
- package/src/Theme/types.ts +13 -0
- package/src/Theme/utils.ts +21 -0
package/package.json
CHANGED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { FabricComponent, createComponent, destructSpaceProps, pxToRem } from '../../Theme';
|
|
4
|
+
|
|
5
|
+
type CheckboxProps = FabricComponent<{
|
|
6
|
+
label?: any;
|
|
7
|
+
}> &
|
|
8
|
+
Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type'>;
|
|
9
|
+
|
|
10
|
+
export const Checkbox = ({ label, className, disabled, ...props }: CheckboxProps) => {
|
|
11
|
+
const spaceProps = destructSpaceProps(props);
|
|
12
|
+
return (
|
|
13
|
+
<StyledCheckbox className={className} $disabled={disabled} {...spaceProps}>
|
|
14
|
+
<HiddenInput type="checkbox" disabled={disabled} {...props} />
|
|
15
|
+
<CustomCheckbox />
|
|
16
|
+
{!!label && <LabelText>{label}</LabelText>}
|
|
17
|
+
</StyledCheckbox>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const CustomCheckbox = styled.div(
|
|
22
|
+
({ theme }) => `
|
|
23
|
+
width: ${pxToRem(15)};
|
|
24
|
+
height: ${pxToRem(15)};
|
|
25
|
+
border-radius: ${pxToRem(2)};
|
|
26
|
+
border: 1px solid ${theme.colors.stroke.main};
|
|
27
|
+
background-color: ${theme.colors.background};
|
|
28
|
+
transition: all 0.2s ease;
|
|
29
|
+
`
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const LabelText = styled.span(
|
|
33
|
+
({ theme }) => `
|
|
34
|
+
margin-left: ${pxToRem(5)};
|
|
35
|
+
font-size: ${theme.typography.variants.h3.fontSize};
|
|
36
|
+
color: ${theme.colors.text.main};
|
|
37
|
+
`
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const HiddenInput = styled.input`
|
|
41
|
+
border: 0;
|
|
42
|
+
clip: rect(0 0 0 0);
|
|
43
|
+
height: 1px;
|
|
44
|
+
width: 1px;
|
|
45
|
+
margin: -1px;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
padding: 0;
|
|
48
|
+
position: absolute;
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
const StyledCheckbox = createComponent(
|
|
52
|
+
styled.label<{ $disabled?: boolean }>(({ theme, $disabled }) => {
|
|
53
|
+
return `
|
|
54
|
+
position: relative;
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
cursor: ${$disabled ? 'not-allowed' : 'pointer'};
|
|
58
|
+
|
|
59
|
+
&:hover {
|
|
60
|
+
${HiddenInput}:not(:disabled) + ${CustomCheckbox} {
|
|
61
|
+
border-color: ${theme.colors.primary.main};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
${HiddenInput}:checked + ${CustomCheckbox} {
|
|
66
|
+
background-color: ${theme.colors.primary.main};
|
|
67
|
+
border-color: ${theme.colors.primary.main};
|
|
68
|
+
}
|
|
69
|
+
${HiddenInput}:disabled + ${CustomCheckbox} {
|
|
70
|
+
background-color: ${theme.colors.disable};
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
})
|
|
74
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Checkbox';
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { FabricComponent, LabelSize, createComponent, generatePropertySpaceStyle, propToRem } from '../../Theme';
|
|
4
|
+
|
|
5
|
+
type LabelProps = FabricComponent<{
|
|
6
|
+
label?: any;
|
|
7
|
+
helpText?: any;
|
|
8
|
+
errorText?: string;
|
|
9
|
+
size?: LabelSize;
|
|
10
|
+
children: any;
|
|
11
|
+
}> &
|
|
12
|
+
Omit<React.LabelHTMLAttributes<HTMLLabelElement>, 'children'> &
|
|
13
|
+
(LabelDirection | LabelDirectionRaw);
|
|
14
|
+
|
|
15
|
+
type LabelDirectionRaw = {
|
|
16
|
+
direction?: 'row' | 'row-reverse';
|
|
17
|
+
childrenWidth?: number | string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type LabelDirection = {
|
|
21
|
+
direction?: Omit<React.CSSProperties['flexDirection'], 'row' | 'row-reverse'>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Label = ({
|
|
25
|
+
label,
|
|
26
|
+
helpText,
|
|
27
|
+
children,
|
|
28
|
+
direction = 'column',
|
|
29
|
+
size = 'small',
|
|
30
|
+
errorText,
|
|
31
|
+
...props
|
|
32
|
+
}: LabelProps) => {
|
|
33
|
+
const $width =
|
|
34
|
+
direction === 'row' || direction === 'row-reverse' ? (props as LabelDirectionRaw).childrenWidth || '50%' : '100%';
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<StyledLabel $size={size} $direction={direction} {...props}>
|
|
38
|
+
<LabelWrapper $width={$width} $size={size}>
|
|
39
|
+
{!!label && <LabelText $size={size}>{label}</LabelText>}
|
|
40
|
+
{!!helpText && <HelpText $size={size}>{helpText}</HelpText>}
|
|
41
|
+
</LabelWrapper>
|
|
42
|
+
<Wrapper $size={size} $width={$width}>
|
|
43
|
+
{children}
|
|
44
|
+
{!!errorText && <ErrorText $size={size}>{errorText}</ErrorText>}
|
|
45
|
+
</Wrapper>
|
|
46
|
+
</StyledLabel>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
type StyledProps = {
|
|
51
|
+
$size: LabelSize;
|
|
52
|
+
$direction?: LabelDirection['direction'] | LabelDirectionRaw['direction'];
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const Wrapper = styled.div<StyledProps & { $width: number | string }>(
|
|
56
|
+
({ theme, $width }) => `
|
|
57
|
+
flex-basis: 100%;
|
|
58
|
+
@media (min-width: ${theme.breakpoints.m}px) {
|
|
59
|
+
flex-basis: ${propToRem($width, theme.baseSize)};
|
|
60
|
+
}
|
|
61
|
+
`
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const LabelWrapper = styled(Wrapper)<StyledProps>`
|
|
65
|
+
align-self: flex-start;
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
const LabelText = styled.div<StyledProps>(
|
|
69
|
+
({ theme, $size }) => `
|
|
70
|
+
line-height: 1.2;
|
|
71
|
+
font-weight: 500;
|
|
72
|
+
font-size: ${theme.label.sizes[$size].fontSize};
|
|
73
|
+
color: ${theme.label.color};
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
:hover {
|
|
76
|
+
color: ${theme.colors.primary.main};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
`
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const HelpText = styled.div<StyledProps>(
|
|
83
|
+
({ theme, $size }) => `
|
|
84
|
+
margin-top: ${theme.label.sizes[$size].helpText.marginTop};
|
|
85
|
+
word-break: break-word;
|
|
86
|
+
line-height: 1.2;
|
|
87
|
+
font-size: ${theme.label.sizes[$size].helpText.fontSize};
|
|
88
|
+
color: ${theme.label.helpTextColor};
|
|
89
|
+
`
|
|
90
|
+
);
|
|
91
|
+
const ErrorText = styled.div<StyledProps>(
|
|
92
|
+
({ theme, $size }) => `
|
|
93
|
+
margin-top: ${theme.label.sizes[$size].helpText.marginTop};
|
|
94
|
+
word-break: break-word;
|
|
95
|
+
line-height: 1.2;
|
|
96
|
+
font-size: ${theme.label.sizes[$size].helpText.fontSize};
|
|
97
|
+
color: ${theme.colors.error};
|
|
98
|
+
`
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const StyledLabel = createComponent(
|
|
102
|
+
styled.label<FabricComponent<StyledProps>>(
|
|
103
|
+
({ theme, $direction = 'column', $size, mb = theme.label.sizes[$size].marginBottom }) => {
|
|
104
|
+
return `
|
|
105
|
+
display: flex;
|
|
106
|
+
align-items: center;
|
|
107
|
+
justify-content: space-between;
|
|
108
|
+
width: 100%;
|
|
109
|
+
min-width: 0;
|
|
110
|
+
flex-direction: column;
|
|
111
|
+
|
|
112
|
+
@media (min-width: ${theme.breakpoints.m}px) {
|
|
113
|
+
flex-direction: ${$direction};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
gap: ${theme.label.sizes[$size].gap};
|
|
117
|
+
${generatePropertySpaceStyle(theme, 'margin-bottom', mb)};
|
|
118
|
+
`;
|
|
119
|
+
}
|
|
120
|
+
),
|
|
121
|
+
{ ignoreStyles: ['margin-bottom'] }
|
|
122
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Label';
|