@cyber-harbour/ui 1.0.23 → 1.0.24
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 +43 -10
- package/dist/index.d.ts +43 -10
- package/dist/index.js +125 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +112 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Core/IconComponents/InfoCircleFilled.tsx +18 -0
- package/src/Core/IconComponents/index.ts +1 -0
- package/src/Core/Input/Input.tsx +133 -0
- package/src/Core/Input/index.ts +1 -0
- package/src/Core/index.ts +1 -0
- package/src/Theme/theme.ts +55 -0
- package/src/Theme/types.ts +28 -2
- package/src/Theme/utils.ts +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SVGProps } from 'react';
|
|
2
|
+
|
|
3
|
+
interface InfoCircleIconProps extends SVGProps<SVGSVGElement> {
|
|
4
|
+
fill?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const InfoCircleFilledIcon = ({ fill = 'currentColor', ...props }: InfoCircleIconProps) => {
|
|
8
|
+
return (
|
|
9
|
+
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
|
10
|
+
<path
|
|
11
|
+
fill-rule="evenodd"
|
|
12
|
+
clip-rule="evenodd"
|
|
13
|
+
d="M8 15C9.85652 15 11.637 14.2625 12.9497 12.9497C14.2625 11.637 15 9.85652 15 8C15 6.14348 14.2625 4.36301 12.9497 3.05025C11.637 1.7375 9.85652 1 8 1C6.14348 1 4.36301 1.7375 3.05025 3.05025C1.7375 4.36301 1 6.14348 1 8C1 9.85652 1.7375 11.637 3.05025 12.9497C4.36301 14.2625 6.14348 15 8 15ZM8 4C8.19891 4 8.38968 4.07902 8.53033 4.21967C8.67098 4.36032 8.75 4.55109 8.75 4.75V7.75C8.75 7.94891 8.67098 8.13968 8.53033 8.28033C8.38968 8.42098 8.19891 8.5 8 8.5C7.80109 8.5 7.61032 8.42098 7.46967 8.28033C7.32902 8.13968 7.25 7.94891 7.25 7.75V4.75C7.25 4.55109 7.32902 4.36032 7.46967 4.21967C7.61032 4.07902 7.80109 4 8 4ZM8 12C8.26522 12 8.51957 11.8946 8.70711 11.7071C8.89464 11.5196 9 11.2652 9 11C9 10.7348 8.89464 10.4804 8.70711 10.2929C8.51957 10.1054 8.26522 10 8 10C7.73478 10 7.48043 10.1054 7.29289 10.2929C7.10536 10.4804 7 10.7348 7 11C7 11.2652 7.10536 11.5196 7.29289 11.7071C7.48043 11.8946 7.73478 12 8 12Z"
|
|
14
|
+
fill={fill}
|
|
15
|
+
/>
|
|
16
|
+
</svg>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { InputSize, InputSizeStyle } from '../../Theme';
|
|
2
|
+
import { InputHTMLAttributes } from 'react';
|
|
3
|
+
import { styled } from 'styled-components';
|
|
4
|
+
import { InfoCircleFilledIcon } from '../IconComponents';
|
|
5
|
+
|
|
6
|
+
type StyledProps = {
|
|
7
|
+
$error?: boolean;
|
|
8
|
+
$sizes: InputSizeStyle;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> & {
|
|
12
|
+
error?: boolean;
|
|
13
|
+
append?: any;
|
|
14
|
+
prepend?: any;
|
|
15
|
+
size?: InputSize;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const Input = ({ error, append, prepend, size = 'small', disabled, className, ...props }: InputProps) => {
|
|
19
|
+
return (
|
|
20
|
+
<Group className={className} $error={error} $size={size} $disabled={!!disabled}>
|
|
21
|
+
{!!prepend && prepend}
|
|
22
|
+
<InputGroup $size={size}>
|
|
23
|
+
<input {...props} disabled={disabled} />
|
|
24
|
+
{!!error && (
|
|
25
|
+
<IconWrapper>
|
|
26
|
+
<InfoCircleFilledIcon />
|
|
27
|
+
</IconWrapper>
|
|
28
|
+
)}
|
|
29
|
+
</InputGroup>
|
|
30
|
+
{!!append && append}
|
|
31
|
+
</Group>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const InputGroup = styled.div<{ $size: InputSize }>(
|
|
36
|
+
({ theme, $size }) => `
|
|
37
|
+
display: inline-flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
width: 100%;
|
|
40
|
+
color: currentColor;
|
|
41
|
+
|
|
42
|
+
svg {
|
|
43
|
+
width: ${theme.input.sizes[$size].iconSize};
|
|
44
|
+
height: ${theme.input.sizes[$size].iconSize};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
& input {
|
|
48
|
+
font-size: ${theme.input.sizes[$size].fontSize};
|
|
49
|
+
color: inherit;
|
|
50
|
+
background: transparent;
|
|
51
|
+
padding-block: ${theme.input.sizes[$size].paddingBlock};
|
|
52
|
+
padding-inline: ${theme.input.sizes[$size].paddingInline};
|
|
53
|
+
position: relative;
|
|
54
|
+
width: 100%;
|
|
55
|
+
outline: none;
|
|
56
|
+
border: none;
|
|
57
|
+
|
|
58
|
+
&::placeholder {
|
|
59
|
+
color: ${theme.input.outlined.default.placeholder};
|
|
60
|
+
font-size: ${theme.input.sizes[$size].fontSize};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&:disabled {
|
|
64
|
+
cursor: not-allowed;
|
|
65
|
+
color: inherit;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
`
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const IconWrapper = styled.span(
|
|
72
|
+
({ theme }) => `
|
|
73
|
+
display: inline-flex;
|
|
74
|
+
flex: 0 0 auto;
|
|
75
|
+
align-items: center;
|
|
76
|
+
color: ${theme.input.outlined.error.icon};
|
|
77
|
+
margin-right: 10px;
|
|
78
|
+
|
|
79
|
+
`
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const Group = styled.div<{ $disabled: boolean; $error?: boolean; $size: InputSize }>(
|
|
83
|
+
({ theme, $disabled, $error, $size }) => `
|
|
84
|
+
display: inline-flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
width: 100%;
|
|
87
|
+
border: 1px solid;
|
|
88
|
+
border-radius: ${theme.input.sizes[$size].borderRadius};
|
|
89
|
+
height: ${theme.input.sizes[$size].height};
|
|
90
|
+
overflow: hidden;
|
|
91
|
+
transition: all 0.2s ease;
|
|
92
|
+
|
|
93
|
+
${
|
|
94
|
+
$error
|
|
95
|
+
? `
|
|
96
|
+
border-color: ${theme.input.outlined.error.border};
|
|
97
|
+
color: ${theme.input.outlined.error.text};
|
|
98
|
+
background: ${theme.input.outlined.error.background};
|
|
99
|
+
`
|
|
100
|
+
: `
|
|
101
|
+
border-color: ${theme.input.outlined.default.border};
|
|
102
|
+
color: ${theme.input.outlined.default.text};
|
|
103
|
+
background: ${theme.input.outlined.default.background};
|
|
104
|
+
`
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
${
|
|
108
|
+
!$disabled &&
|
|
109
|
+
!$error &&
|
|
110
|
+
`
|
|
111
|
+
&:hover {
|
|
112
|
+
border-color: ${theme.input.outlined.focus.border};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&:focus-within {
|
|
116
|
+
border-color: ${theme.input.outlined.focus.border};
|
|
117
|
+
color: ${theme.input.outlined.focus.text};
|
|
118
|
+
background: ${theme.input.outlined.focus.background};
|
|
119
|
+
}
|
|
120
|
+
`
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
${
|
|
124
|
+
$disabled &&
|
|
125
|
+
`
|
|
126
|
+
border-color: ${theme.input.outlined.disabled.border};
|
|
127
|
+
color: ${theme.input.outlined.disabled.text};
|
|
128
|
+
background: ${theme.input.outlined.disabled.background};
|
|
129
|
+
cursor: not-allowed;
|
|
130
|
+
`
|
|
131
|
+
}
|
|
132
|
+
`
|
|
133
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Input';
|
package/src/Core/index.ts
CHANGED
package/src/Theme/theme.ts
CHANGED
|
@@ -578,6 +578,61 @@ export const lightThemePx: Theme = {
|
|
|
578
578
|
size: 16,
|
|
579
579
|
},
|
|
580
580
|
},
|
|
581
|
+
// Компонент Input
|
|
582
|
+
input: {
|
|
583
|
+
sizes: {
|
|
584
|
+
small: {
|
|
585
|
+
fontSize: 14,
|
|
586
|
+
paddingInline: 10,
|
|
587
|
+
paddingBlock: 10,
|
|
588
|
+
borderRadius: 5,
|
|
589
|
+
iconSize: 14,
|
|
590
|
+
height: 40,
|
|
591
|
+
},
|
|
592
|
+
medium: {
|
|
593
|
+
fontSize: 16,
|
|
594
|
+
paddingInline: 10,
|
|
595
|
+
paddingBlock: 10,
|
|
596
|
+
borderRadius: 5,
|
|
597
|
+
iconSize: 16,
|
|
598
|
+
height: 40,
|
|
599
|
+
},
|
|
600
|
+
},
|
|
601
|
+
outlined: {
|
|
602
|
+
default: {
|
|
603
|
+
background: 'transparent',
|
|
604
|
+
text: '#101010',
|
|
605
|
+
placeholder: '#99989C',
|
|
606
|
+
border: ' #EBEBEB',
|
|
607
|
+
boxShadow: 'none',
|
|
608
|
+
icon: '#101010',
|
|
609
|
+
},
|
|
610
|
+
focus: {
|
|
611
|
+
background: 'transparent',
|
|
612
|
+
text: '#101010',
|
|
613
|
+
placeholder: '#99989C',
|
|
614
|
+
border: ' #0042EC',
|
|
615
|
+
boxShadow: 'none',
|
|
616
|
+
icon: '#101010',
|
|
617
|
+
},
|
|
618
|
+
error: {
|
|
619
|
+
background: 'transparent',
|
|
620
|
+
text: '#101010',
|
|
621
|
+
placeholder: '#99989C',
|
|
622
|
+
border: ' #C93939',
|
|
623
|
+
boxShadow: 'none',
|
|
624
|
+
icon: '#C93939',
|
|
625
|
+
},
|
|
626
|
+
disabled: {
|
|
627
|
+
background: '#FAFAFA',
|
|
628
|
+
text: '#99989C',
|
|
629
|
+
placeholder: '#99989C',
|
|
630
|
+
border: ' #EBEBEB',
|
|
631
|
+
boxShadow: 'none',
|
|
632
|
+
icon: '#99989C',
|
|
633
|
+
},
|
|
634
|
+
},
|
|
635
|
+
},
|
|
581
636
|
};
|
|
582
637
|
|
|
583
638
|
// Конвертуємо всі розміри з px в rem
|
package/src/Theme/types.ts
CHANGED
|
@@ -6,9 +6,9 @@ export type ButtonColor = 'default' | 'primary' | 'secondary' | 'error';
|
|
|
6
6
|
export type ButtonState = 'default' | 'hover' | 'active' | 'disabled';
|
|
7
7
|
export type ButtonSize = 'small' | 'medium';
|
|
8
8
|
|
|
9
|
-
export type InputVariant = '
|
|
9
|
+
export type InputVariant = 'outlined';
|
|
10
10
|
export type InputState = 'default' | 'focus' | 'error' | 'disabled';
|
|
11
|
-
export type InputSize = 'small' | 'medium'
|
|
11
|
+
export type InputSize = 'small' | 'medium';
|
|
12
12
|
|
|
13
13
|
// Типи для spacing та breakpoints
|
|
14
14
|
export type Breakpoint = 'xs' | 's' | 'm' | 'l' | 'xl';
|
|
@@ -32,6 +32,26 @@ export type ButtonSizeStyle = {
|
|
|
32
32
|
iconSize: number | string;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
// Тип для стилів елементів інпута
|
|
36
|
+
export type InputElementStyle = {
|
|
37
|
+
background: string;
|
|
38
|
+
text: string;
|
|
39
|
+
placeholder: string;
|
|
40
|
+
border: string;
|
|
41
|
+
boxShadow: string;
|
|
42
|
+
icon: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// Тип для розмірів інпута
|
|
46
|
+
export type InputSizeStyle = {
|
|
47
|
+
fontSize: number | string;
|
|
48
|
+
paddingInline: number | string;
|
|
49
|
+
paddingBlock: number | string;
|
|
50
|
+
borderRadius: number | string;
|
|
51
|
+
iconSize: number | string;
|
|
52
|
+
height: number | string;
|
|
53
|
+
};
|
|
54
|
+
|
|
35
55
|
// Тип для палітри
|
|
36
56
|
export type Theme = {
|
|
37
57
|
mode: 'light' | 'dark';
|
|
@@ -151,6 +171,7 @@ export type Theme = {
|
|
|
151
171
|
select: {
|
|
152
172
|
item: Record<ButtonState, ButtonElementStyle>;
|
|
153
173
|
};
|
|
174
|
+
// RowActionsMenu
|
|
154
175
|
rowActionsMenu: {
|
|
155
176
|
button: Record<ButtonState, ButtonElementStyle>;
|
|
156
177
|
delimiterColor: string;
|
|
@@ -158,6 +179,11 @@ export type Theme = {
|
|
|
158
179
|
size: number | string;
|
|
159
180
|
};
|
|
160
181
|
};
|
|
182
|
+
//Input
|
|
183
|
+
input: {
|
|
184
|
+
sizes: Record<InputSize, InputSizeStyle>;
|
|
185
|
+
outlined: Record<InputState, InputElementStyle>;
|
|
186
|
+
};
|
|
161
187
|
};
|
|
162
188
|
|
|
163
189
|
//TODO check and refactoring
|
package/src/Theme/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DefaultTheme } from 'styled-components';
|
|
2
|
-
import { Breakpoint, ButtonColor, ButtonSize, ButtonState, ButtonVariant } from './types';
|
|
2
|
+
import { Breakpoint, ButtonColor, ButtonSize, ButtonState, ButtonVariant, InputSize, InputState } from './types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Helper function to resolve nested color paths from theme
|