@cyber-harbour/ui 1.0.31 → 1.0.32
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 +10 -4
- package/dist/index.d.ts +10 -4
- package/dist/index.js +62 -62
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -62
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Core/Input/Input.tsx +34 -35
- package/src/Theme/theme.ts +42 -0
- package/src/Theme/types.ts +3 -2
- package/src/Theme/utils.ts +16 -17
package/package.json
CHANGED
package/src/Core/Input/Input.tsx
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
import { InputSize, InputSizeStyle } from '../../Theme';
|
|
2
|
-
import { InputHTMLAttributes } from 'react';
|
|
1
|
+
import { InputSize, InputSizeStyle, InputVariant, getInputStyles } from '../../Theme';
|
|
2
|
+
import { forwardRef, InputHTMLAttributes, Ref } from 'react';
|
|
3
3
|
import { styled } from 'styled-components';
|
|
4
4
|
import { InfoCircleFilledIcon } from '../IconComponents';
|
|
5
5
|
|
|
6
|
-
type
|
|
7
|
-
$error?: boolean;
|
|
8
|
-
$sizes: InputSizeStyle;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> & {
|
|
6
|
+
export type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> & {
|
|
12
7
|
error?: boolean;
|
|
13
8
|
append?: any;
|
|
14
9
|
prepend?: any;
|
|
15
10
|
size?: InputSize;
|
|
11
|
+
variant?: InputVariant;
|
|
16
12
|
};
|
|
17
13
|
|
|
18
|
-
export const Input
|
|
14
|
+
export const Input: any = forwardRef<HTMLInputElement, InputProps>(function Input(
|
|
15
|
+
{ error, append, prepend, size = 'small', variant = 'outlined', disabled, className, ...props },
|
|
16
|
+
ref
|
|
17
|
+
) {
|
|
19
18
|
return (
|
|
20
|
-
<Group className={className} $error={error} $size={size} $disabled={!!disabled}>
|
|
19
|
+
<Group className={className} $error={error} $size={size} $variant={variant} $disabled={!!disabled}>
|
|
21
20
|
{!!prepend && prepend}
|
|
22
|
-
<InputGroup $size={size}>
|
|
23
|
-
<input {
|
|
21
|
+
<InputGroup $size={size} $variant={variant}>
|
|
22
|
+
<input ref={ref} disabled={disabled} {...props} />
|
|
24
23
|
{!!error && (
|
|
25
|
-
<IconWrapper>
|
|
24
|
+
<IconWrapper $variant={variant}>
|
|
26
25
|
<InfoCircleFilledIcon />
|
|
27
26
|
</IconWrapper>
|
|
28
27
|
)}
|
|
@@ -30,10 +29,10 @@ export const Input = ({ error, append, prepend, size = 'small', disabled, classN
|
|
|
30
29
|
{!!append && append}
|
|
31
30
|
</Group>
|
|
32
31
|
);
|
|
33
|
-
};
|
|
32
|
+
});
|
|
34
33
|
|
|
35
|
-
const InputGroup = styled.div<{ $size: InputSize }>(
|
|
36
|
-
({ theme, $size }) => `
|
|
34
|
+
const InputGroup = styled.div<{ $size: InputSize; $variant?: InputVariant }>(
|
|
35
|
+
({ theme, $size, $variant = 'outlined' }) => `
|
|
37
36
|
display: inline-flex;
|
|
38
37
|
align-items: center;
|
|
39
38
|
width: 100%;
|
|
@@ -56,7 +55,7 @@ const InputGroup = styled.div<{ $size: InputSize }>(
|
|
|
56
55
|
border: none;
|
|
57
56
|
|
|
58
57
|
&::placeholder {
|
|
59
|
-
color: ${theme.input.
|
|
58
|
+
color: ${theme.input[$variant].default.placeholder};
|
|
60
59
|
font-size: ${theme.input.sizes[$size].fontSize};
|
|
61
60
|
}
|
|
62
61
|
|
|
@@ -68,19 +67,19 @@ const InputGroup = styled.div<{ $size: InputSize }>(
|
|
|
68
67
|
`
|
|
69
68
|
);
|
|
70
69
|
|
|
71
|
-
const IconWrapper = styled.span(
|
|
72
|
-
({ theme }) => `
|
|
70
|
+
const IconWrapper = styled.span<{ $variant: InputVariant }>(
|
|
71
|
+
({ theme, $variant }) => `
|
|
73
72
|
display: inline-flex;
|
|
74
73
|
flex: 0 0 auto;
|
|
75
74
|
align-items: center;
|
|
76
|
-
color: ${theme.input.
|
|
75
|
+
color: ${theme.input[$variant].error.icon};
|
|
77
76
|
margin-right: 10px;
|
|
78
77
|
|
|
79
78
|
`
|
|
80
79
|
);
|
|
81
80
|
|
|
82
|
-
const Group = styled.div<{ $disabled: boolean; $error?: boolean; $size: InputSize }>(
|
|
83
|
-
({ theme, $disabled, $error, $size }) => `
|
|
81
|
+
const Group = styled.div<{ $disabled: boolean; $error?: boolean; $size: InputSize; $variant: InputVariant }>(
|
|
82
|
+
({ theme, $disabled, $error, $size, $variant }) => `
|
|
84
83
|
display: inline-flex;
|
|
85
84
|
align-items: center;
|
|
86
85
|
width: 100%;
|
|
@@ -93,14 +92,14 @@ const Group = styled.div<{ $disabled: boolean; $error?: boolean; $size: InputSiz
|
|
|
93
92
|
${
|
|
94
93
|
$error
|
|
95
94
|
? `
|
|
96
|
-
border-color: ${theme.input.
|
|
97
|
-
color: ${theme.input.
|
|
98
|
-
background: ${theme.input.
|
|
95
|
+
border-color: ${theme.input[$variant].error.border};
|
|
96
|
+
color: ${theme.input[$variant].error.text};
|
|
97
|
+
background: ${theme.input[$variant].error.background};
|
|
99
98
|
`
|
|
100
99
|
: `
|
|
101
|
-
border-color: ${theme.input.
|
|
102
|
-
color: ${theme.input.
|
|
103
|
-
background: ${theme.input.
|
|
100
|
+
border-color: ${theme.input[$variant].default.border};
|
|
101
|
+
color: ${theme.input[$variant].default.text};
|
|
102
|
+
background: ${theme.input[$variant].default.background};
|
|
104
103
|
`
|
|
105
104
|
}
|
|
106
105
|
|
|
@@ -109,13 +108,13 @@ const Group = styled.div<{ $disabled: boolean; $error?: boolean; $size: InputSiz
|
|
|
109
108
|
!$error &&
|
|
110
109
|
`
|
|
111
110
|
&:hover {
|
|
112
|
-
border-color: ${theme.input.
|
|
111
|
+
border-color: ${theme.input[$variant].focus.border};
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
&:focus-within {
|
|
116
|
-
border-color: ${theme.input.
|
|
117
|
-
color: ${theme.input.
|
|
118
|
-
background: ${theme.input.
|
|
115
|
+
border-color: ${theme.input[$variant].focus.border};
|
|
116
|
+
color: ${theme.input[$variant].focus.text};
|
|
117
|
+
background: ${theme.input[$variant].focus.background};
|
|
119
118
|
}
|
|
120
119
|
`
|
|
121
120
|
}
|
|
@@ -123,9 +122,9 @@ const Group = styled.div<{ $disabled: boolean; $error?: boolean; $size: InputSiz
|
|
|
123
122
|
${
|
|
124
123
|
$disabled &&
|
|
125
124
|
`
|
|
126
|
-
border-color: ${theme.input.
|
|
127
|
-
color: ${theme.input.
|
|
128
|
-
background: ${theme.input.
|
|
125
|
+
border-color: ${theme.input[$variant].disabled.border};
|
|
126
|
+
color: ${theme.input[$variant].disabled.text};
|
|
127
|
+
background: ${theme.input[$variant].disabled.background};
|
|
129
128
|
cursor: not-allowed;
|
|
130
129
|
`
|
|
131
130
|
}
|
package/src/Theme/theme.ts
CHANGED
|
@@ -601,6 +601,14 @@ export const lightThemePx: Theme = {
|
|
|
601
601
|
// Компонент Input
|
|
602
602
|
input: {
|
|
603
603
|
sizes: {
|
|
604
|
+
empty: {
|
|
605
|
+
fontSize: 14,
|
|
606
|
+
paddingInline: 0,
|
|
607
|
+
paddingBlock: 0,
|
|
608
|
+
borderRadius: 0,
|
|
609
|
+
iconSize: 14,
|
|
610
|
+
height: 'auto',
|
|
611
|
+
},
|
|
604
612
|
small: {
|
|
605
613
|
fontSize: 14,
|
|
606
614
|
paddingInline: 10,
|
|
@@ -652,6 +660,40 @@ export const lightThemePx: Theme = {
|
|
|
652
660
|
icon: '#99989C',
|
|
653
661
|
},
|
|
654
662
|
},
|
|
663
|
+
empty: {
|
|
664
|
+
default: {
|
|
665
|
+
background: 'transparent',
|
|
666
|
+
text: '#101010',
|
|
667
|
+
placeholder: '#99989C',
|
|
668
|
+
border: ' transparent',
|
|
669
|
+
boxShadow: 'none',
|
|
670
|
+
icon: '#101010',
|
|
671
|
+
},
|
|
672
|
+
focus: {
|
|
673
|
+
background: 'transparent',
|
|
674
|
+
text: '#101010',
|
|
675
|
+
placeholder: '#99989C',
|
|
676
|
+
border: ' transparent',
|
|
677
|
+
boxShadow: 'none',
|
|
678
|
+
icon: '#101010',
|
|
679
|
+
},
|
|
680
|
+
error: {
|
|
681
|
+
background: 'transparent',
|
|
682
|
+
text: '#101010',
|
|
683
|
+
placeholder: '#99989C',
|
|
684
|
+
border: ' transparent',
|
|
685
|
+
boxShadow: 'none',
|
|
686
|
+
icon: '#C93939',
|
|
687
|
+
},
|
|
688
|
+
disabled: {
|
|
689
|
+
background: '#FAFAFA',
|
|
690
|
+
text: '#99989C',
|
|
691
|
+
placeholder: '#99989C',
|
|
692
|
+
border: 'transparent',
|
|
693
|
+
boxShadow: 'none',
|
|
694
|
+
icon: '#99989C',
|
|
695
|
+
},
|
|
696
|
+
},
|
|
655
697
|
},
|
|
656
698
|
box: {
|
|
657
699
|
padding: 20,
|
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 = 'outlined';
|
|
9
|
+
export type InputVariant = 'outlined' | 'empty';
|
|
10
10
|
export type InputState = 'default' | 'focus' | 'error' | 'disabled';
|
|
11
|
-
export type InputSize = 'small' | 'medium';
|
|
11
|
+
export type InputSize = 'empty' | 'small' | 'medium';
|
|
12
12
|
|
|
13
13
|
// Типи для spacing та breakpoints
|
|
14
14
|
export type Breakpoint = 'xs' | 's' | 'm' | 'l' | 'xl';
|
|
@@ -191,6 +191,7 @@ export type Theme = {
|
|
|
191
191
|
input: {
|
|
192
192
|
sizes: Record<InputSize, InputSizeStyle>;
|
|
193
193
|
outlined: Record<InputState, InputElementStyle>;
|
|
194
|
+
empty: Record<InputState, InputElementStyle>;
|
|
194
195
|
};
|
|
195
196
|
//Box
|
|
196
197
|
box: {
|
package/src/Theme/utils.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { DefaultTheme } from 'styled-components';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Breakpoint,
|
|
4
|
+
ButtonColor,
|
|
5
|
+
ButtonSize,
|
|
6
|
+
ButtonState,
|
|
7
|
+
ButtonVariant,
|
|
8
|
+
InputSize,
|
|
9
|
+
InputState,
|
|
10
|
+
InputVariant,
|
|
11
|
+
} from './types';
|
|
3
12
|
|
|
4
13
|
/**
|
|
5
14
|
* Helper function to resolve nested color paths from theme
|
|
@@ -130,22 +139,12 @@ export const getButtonSizeStyles = (theme: DefaultTheme, size: ButtonSize) => {
|
|
|
130
139
|
return theme.button.sizes[size];
|
|
131
140
|
};
|
|
132
141
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// size: InputSize = 'medium'
|
|
140
|
-
// ) => {
|
|
141
|
-
// const variantStyles = theme.input[variant][state];
|
|
142
|
-
// const sizeStyles = theme.input.sizes[size];
|
|
143
|
-
|
|
144
|
-
// return {
|
|
145
|
-
// ...variantStyles,
|
|
146
|
-
// ...sizeStyles,
|
|
147
|
-
// };
|
|
148
|
-
// };
|
|
142
|
+
/**
|
|
143
|
+
* Функція для отримання стилів інпута за варіантом та станом
|
|
144
|
+
*/
|
|
145
|
+
export const getInputStyles = (theme: DefaultTheme, variant: InputVariant, state: InputState) => {
|
|
146
|
+
return theme.input[variant][state];
|
|
147
|
+
};
|
|
149
148
|
|
|
150
149
|
/**
|
|
151
150
|
* Функція для отримання типографічних стилів
|