@liguelead/design-system 0.0.11 → 0.0.12
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/components/Checkbox/Checkbox.styles.ts +21 -12
- package/components/Checkbox/Checkbox.tsx +10 -9
- package/components/Checkbox/Checkbox.types.ts +4 -2
- package/components/InputOpt/InputOpt.styles.ts +15 -10
- package/components/InputOpt/InputOpt.tsx +20 -5
- package/components/InputOpt/InputOpt.types.ts +2 -1
- package/components/RequiredAsterisk/RequiredAsterisk.style.ts +6 -0
- package/components/RequiredAsterisk/RequiredAsterisk.tsx +7 -0
- package/components/RequiredAsterisk/index.ts +1 -0
- package/components/Select/Select.states.tsx +10 -7
- package/components/Select/Select.styles.ts +5 -3
- package/components/Select/Select.tsx +9 -2
- package/components/Select/Select.types.ts +3 -1
- package/components/TextField/TextField.states.tsx +3 -2
- package/components/TextField/TextField.styles.ts +5 -7
- package/components/TextField/TextField.tsx +5 -4
- package/components/TextField/TextField.types.ts +1 -0
- package/package.json +1 -1
|
@@ -2,7 +2,8 @@ import {
|
|
|
2
2
|
spacing,
|
|
3
3
|
fontSize,
|
|
4
4
|
fontWeight,
|
|
5
|
-
radius
|
|
5
|
+
radius,
|
|
6
|
+
shadow
|
|
6
7
|
} from '@liguelead/foundation'
|
|
7
8
|
import { parseColor } from '../../utils'
|
|
8
9
|
import styled, { css } from 'styled-components'
|
|
@@ -32,8 +33,9 @@ export const CheckboxWrapper = styled.label`
|
|
|
32
33
|
export const CustomCheckbox = styled.span<{
|
|
33
34
|
checked: boolean
|
|
34
35
|
disabled?: boolean
|
|
36
|
+
error?: boolean
|
|
35
37
|
}>`
|
|
36
|
-
${({ checked, theme, disabled }) => css`
|
|
38
|
+
${({ checked, theme, disabled, error }) => css`
|
|
37
39
|
width: ${spacing.spacing16}px;
|
|
38
40
|
height: ${spacing.spacing16}px;
|
|
39
41
|
border: 1px solid ${checked
|
|
@@ -52,11 +54,17 @@ export const CustomCheckbox = styled.span<{
|
|
|
52
54
|
overflow: hidden;
|
|
53
55
|
|
|
54
56
|
${disabled &&
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
css`
|
|
58
|
+
background-color: transparent;
|
|
59
|
+
border-color: ${parseColor(theme.colors.neutral400)}70;
|
|
60
|
+
cursor: not-allowed;
|
|
61
|
+
`}
|
|
62
|
+
|
|
63
|
+
${error &&
|
|
64
|
+
css`
|
|
65
|
+
border-color: ${parseColor(theme.colors.danger200)};
|
|
66
|
+
box-shadow: ${shadow.errorShadow};
|
|
67
|
+
`}
|
|
60
68
|
|
|
61
69
|
&::after {
|
|
62
70
|
content: '';
|
|
@@ -98,18 +106,19 @@ export const Label = styled.span<{ disabled?: boolean }>`
|
|
|
98
106
|
|
|
99
107
|
color: ${({ theme, disabled }) =>
|
|
100
108
|
disabled
|
|
101
|
-
? `${parseColor(theme.colors.
|
|
102
|
-
: parseColor(theme.colors.
|
|
109
|
+
? `${parseColor(theme.colors.textDark)}70`
|
|
110
|
+
: parseColor(theme.colors.textDark)};
|
|
103
111
|
`
|
|
104
112
|
|
|
105
|
-
export const CustomLabel = styled(Text)<{ disabled?: boolean }>`
|
|
113
|
+
export const CustomLabel = styled(Text)<{ disabled?: boolean; error?: boolean }>`
|
|
106
114
|
font-size: ${fontSize.fontSize12}px;
|
|
107
115
|
font-weight: ${fontWeight.fontWeight400};
|
|
108
116
|
line-height: 8px;
|
|
109
117
|
|
|
110
|
-
color: ${({ theme, disabled }) =>
|
|
118
|
+
color: ${({ theme, disabled, error }) =>
|
|
111
119
|
disabled
|
|
112
120
|
? `${parseColor(theme.colors.textMedium)}70`
|
|
121
|
+
: error
|
|
122
|
+
? parseColor(theme.colors.danger200)
|
|
113
123
|
: parseColor(theme.colors.textMedium)};
|
|
114
|
-
|
|
115
124
|
`
|
|
@@ -21,6 +21,8 @@ const Checkbox: React.FC<CheckboxProps> = ({
|
|
|
21
21
|
disabled = false,
|
|
22
22
|
register,
|
|
23
23
|
className,
|
|
24
|
+
error,
|
|
25
|
+
children,
|
|
24
26
|
description,
|
|
25
27
|
...rest
|
|
26
28
|
}) => {
|
|
@@ -64,8 +66,8 @@ const Checkbox: React.FC<CheckboxProps> = ({
|
|
|
64
66
|
<CustomCheckbox
|
|
65
67
|
checked={internalChecked}
|
|
66
68
|
disabled={disabled}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
error={!!error}
|
|
70
|
+
onClick={handleRipple}>
|
|
69
71
|
{ripples.map(ripple => (
|
|
70
72
|
<RippleContainer
|
|
71
73
|
key={ripple.id}
|
|
@@ -82,13 +84,12 @@ const Checkbox: React.FC<CheckboxProps> = ({
|
|
|
82
84
|
))}
|
|
83
85
|
</CustomCheckbox>
|
|
84
86
|
<div>
|
|
85
|
-
{label
|
|
86
|
-
|
|
87
|
-
disabled={disabled}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
</CustomLabel>
|
|
87
|
+
{label ? <Label disabled={disabled}>{label}</Label> : children}
|
|
88
|
+
{(description || error) && (
|
|
89
|
+
<CustomLabel disabled={disabled} weight="fontWeight400">
|
|
90
|
+
{error?.message || description}
|
|
91
|
+
</CustomLabel>
|
|
92
|
+
)}
|
|
92
93
|
</div>
|
|
93
94
|
</CheckboxWrapper>
|
|
94
95
|
)
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { UseFormRegisterReturn } from 'react-hook-form'
|
|
1
|
+
import { FieldValues, UseFormRegisterReturn } from 'react-hook-form'
|
|
2
2
|
|
|
3
|
-
export interface CheckboxProps {
|
|
3
|
+
export interface CheckboxProps<TFieldValues extends FieldValues = FieldValues> {
|
|
4
4
|
label?: string
|
|
5
5
|
checked?: boolean
|
|
6
|
+
error?: TFieldValues
|
|
6
7
|
description?: string
|
|
8
|
+
children?: React.ReactNode
|
|
7
9
|
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
|
|
8
10
|
disabled?: boolean
|
|
9
11
|
register?: UseFormRegisterReturn<string>
|
|
@@ -2,16 +2,22 @@ import styled, { css } from 'styled-components'
|
|
|
2
2
|
import { spacing, fontSize, fontWeight, shadow, lineHeight } from '@liguelead/foundation'
|
|
3
3
|
import { parseColor } from '../../utils'
|
|
4
4
|
|
|
5
|
-
export const OptWrapper = styled.div`
|
|
6
|
-
display: flex;
|
|
7
|
-
gap: ${spacing.spacing16}px;
|
|
8
|
-
`
|
|
9
|
-
|
|
10
5
|
interface OptBoxProps {
|
|
11
6
|
$disabled?: boolean;
|
|
12
7
|
$error?: boolean;
|
|
13
8
|
}
|
|
14
9
|
|
|
10
|
+
export const OptWrapper = styled.div`
|
|
11
|
+
display: flex;
|
|
12
|
+
gap: ${spacing.spacing8}px;
|
|
13
|
+
`
|
|
14
|
+
|
|
15
|
+
export const OptContainer = styled.div`
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
gap: ${spacing.spacing4}px;
|
|
19
|
+
`
|
|
20
|
+
|
|
15
21
|
export const OptBox = styled.input<OptBoxProps>`
|
|
16
22
|
width: ${spacing.spacing36}px;
|
|
17
23
|
height: ${spacing.spacing36}px;
|
|
@@ -36,7 +42,7 @@ export const OptBox = styled.input<OptBoxProps>`
|
|
|
36
42
|
$error
|
|
37
43
|
? css`
|
|
38
44
|
border-color: ${parseColor(theme.colors.danger200)};
|
|
39
|
-
box-shadow:
|
|
45
|
+
box-shadow: ${shadow.errorShadow};
|
|
40
46
|
`
|
|
41
47
|
: css`
|
|
42
48
|
border-color: ${parseColor(theme.colors.neutral700)};
|
|
@@ -55,9 +61,9 @@ export const OptBox = styled.input<OptBoxProps>`
|
|
|
55
61
|
`
|
|
56
62
|
|
|
57
63
|
export const OtpSeparator = styled.span`
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
width: 14px;
|
|
65
|
+
border: 1px solid ${({ theme }) => parseColor(theme.colors.neutral700)};
|
|
66
|
+
border-radius: 8px;
|
|
61
67
|
`
|
|
62
68
|
|
|
63
69
|
export const OtpSeparatorContainer = styled.div`
|
|
@@ -67,7 +73,6 @@ export const OtpSeparatorContainer = styled.div`
|
|
|
67
73
|
|
|
68
74
|
export const OptHelperText = styled.span<{ $error?: boolean }>`
|
|
69
75
|
display: block;
|
|
70
|
-
margin-top: ${spacing.spacing8}px;
|
|
71
76
|
font-size: ${fontSize.fontSize12}px;
|
|
72
77
|
line-height: ${lineHeight.lineHeight16}px;
|
|
73
78
|
color: ${({ theme, $error }) =>
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
OtpSeparator,
|
|
7
7
|
OptHelperText,
|
|
8
8
|
OtpSeparatorContainer,
|
|
9
|
+
OptContainer,
|
|
9
10
|
} from './InputOpt.styles'
|
|
10
11
|
|
|
11
12
|
import {
|
|
@@ -17,6 +18,9 @@ import {
|
|
|
17
18
|
focusFirstEmpty
|
|
18
19
|
} from './utils'
|
|
19
20
|
|
|
21
|
+
import Text from '../Text'
|
|
22
|
+
import RequiredAsterisk from '../RequiredAsterisk'
|
|
23
|
+
|
|
20
24
|
const InputOpt: React.FC<InputOptProps> = ({
|
|
21
25
|
length = 6,
|
|
22
26
|
value,
|
|
@@ -25,7 +29,8 @@ const InputOpt: React.FC<InputOptProps> = ({
|
|
|
25
29
|
autoFocus = true,
|
|
26
30
|
disabled = false,
|
|
27
31
|
placeholderChar = '',
|
|
28
|
-
|
|
32
|
+
label,
|
|
33
|
+
requiredSymbol = false,
|
|
29
34
|
className,
|
|
30
35
|
inputMode = 'numeric',
|
|
31
36
|
helperText,
|
|
@@ -105,9 +110,19 @@ const InputOpt: React.FC<InputOptProps> = ({
|
|
|
105
110
|
}
|
|
106
111
|
|
|
107
112
|
return (
|
|
108
|
-
|
|
113
|
+
<OptContainer
|
|
114
|
+
className={`${className || ''} ${error ? 'error' : ''}`.trim()}
|
|
115
|
+
>
|
|
116
|
+
{label && (
|
|
117
|
+
<Text
|
|
118
|
+
size="body02"
|
|
119
|
+
tag='label'
|
|
120
|
+
weight='fontWeight500'
|
|
121
|
+
>
|
|
122
|
+
{label} {requiredSymbol && <RequiredAsterisk/> }
|
|
123
|
+
</Text>
|
|
124
|
+
)}
|
|
109
125
|
<OptWrapper
|
|
110
|
-
className={`${className || ''} ${error ? 'error' : ''}`.trim()}
|
|
111
126
|
aria-disabled={disabled}
|
|
112
127
|
aria-invalid={!!error}
|
|
113
128
|
role="group"
|
|
@@ -134,7 +149,7 @@ const InputOpt: React.FC<InputOptProps> = ({
|
|
|
134
149
|
/>
|
|
135
150
|
{(i + 1) % 2 === 0 && i < length - 1 && (
|
|
136
151
|
<OtpSeparatorContainer>
|
|
137
|
-
<OtpSeparator
|
|
152
|
+
<OtpSeparator/>
|
|
138
153
|
</OtpSeparatorContainer>
|
|
139
154
|
)}
|
|
140
155
|
</React.Fragment>
|
|
@@ -146,7 +161,7 @@ const InputOpt: React.FC<InputOptProps> = ({
|
|
|
146
161
|
{helperText}
|
|
147
162
|
</OptHelperText>
|
|
148
163
|
)}
|
|
149
|
-
|
|
164
|
+
</OptContainer>
|
|
150
165
|
)
|
|
151
166
|
}
|
|
152
167
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./RequiredAsterisk";
|
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
import { parseColor } from '../../utils'
|
|
2
2
|
import { useTheme } from 'styled-components'
|
|
3
3
|
import { TextFieldStates } from './Select.types'
|
|
4
|
+
import { shadow } from '@liguelead/foundation'
|
|
4
5
|
|
|
5
6
|
export const SelectStates = (state: keyof TextFieldStates) => {
|
|
6
7
|
const theme = useTheme()
|
|
7
8
|
const states: TextFieldStates = {
|
|
8
9
|
error: {
|
|
9
10
|
input: `
|
|
10
|
-
border: 1px solid ${parseColor(theme.colors.
|
|
11
|
+
border: 1px solid ${parseColor(theme.colors.danger200)};
|
|
11
12
|
color: ${parseColor(theme.colors.textDark)};
|
|
12
13
|
&:focus {
|
|
13
|
-
border-color: ${parseColor(theme.colors.
|
|
14
|
+
border-color: ${parseColor(theme.colors.danger200)};
|
|
15
|
+
box-shadow: ${shadow.errorShadow};
|
|
14
16
|
}
|
|
15
17
|
`,
|
|
16
|
-
label: `color: ${parseColor(theme.colors.
|
|
17
|
-
helperText: `color: ${parseColor(theme.colors.
|
|
18
|
+
label: `color: ${parseColor(theme.colors.textDark)};`,
|
|
19
|
+
helperText: `color: ${parseColor(theme.colors.danger200)};`
|
|
18
20
|
},
|
|
19
21
|
default: {
|
|
20
22
|
input: `
|
|
21
|
-
border: 1px solid ${parseColor(theme.colors.
|
|
23
|
+
border: 1px solid ${parseColor(theme.colors.neutral400)};
|
|
22
24
|
color: ${parseColor(theme.colors.textDark)};
|
|
23
25
|
&:focus {
|
|
24
|
-
border-color: ${parseColor(theme.colors.
|
|
26
|
+
border-color: ${parseColor(theme.colors.neutral700)};
|
|
27
|
+
box-shadow: ${shadow.focusShadow};
|
|
25
28
|
}
|
|
26
29
|
`,
|
|
27
30
|
label: `color: ${parseColor(theme.colors.textDark)};`,
|
|
@@ -32,7 +35,7 @@ export const SelectStates = (state: keyof TextFieldStates) => {
|
|
|
32
35
|
border: 1px solid ${parseColor(theme.colors.neutral400)};
|
|
33
36
|
color: ${parseColor(theme.colors.neutral600)};
|
|
34
37
|
`,
|
|
35
|
-
label: `color: ${parseColor(theme.colors.
|
|
38
|
+
label: `color: ${parseColor(theme.colors.textDark)};`,
|
|
36
39
|
helperText: `color: ${parseColor(theme.colors.textMedium)};`
|
|
37
40
|
}
|
|
38
41
|
}
|
|
@@ -22,14 +22,13 @@ export const InputWrapper = styled.div`
|
|
|
22
22
|
|
|
23
23
|
export const Label = styled.label`
|
|
24
24
|
display: block;
|
|
25
|
-
font-weight: ${fontWeight.
|
|
26
|
-
margin-bottom: ${spacing.spacing4}px;
|
|
25
|
+
font-weight: ${fontWeight.fontWeight500};
|
|
27
26
|
font-size: ${fontSize.fontSize14}px;
|
|
28
27
|
`
|
|
29
28
|
|
|
30
29
|
export const HelperText = styled.span<{ error?: boolean }>`
|
|
31
30
|
font-size: ${fontSize.fontSize12}px;
|
|
32
|
-
line-height: ${lineHeight.
|
|
31
|
+
line-height: ${lineHeight.lineHeight16}px;
|
|
33
32
|
`
|
|
34
33
|
|
|
35
34
|
export const IconWrapper = styled.div<{
|
|
@@ -145,6 +144,9 @@ export const BorderWrapper = styled.div`
|
|
|
145
144
|
export const Wrapper = styled.div<StyledInputProps>`
|
|
146
145
|
position: relative;
|
|
147
146
|
width: 100%;
|
|
147
|
+
display: flex;
|
|
148
|
+
flex-direction: column;
|
|
149
|
+
gap: ${spacing.spacing4}px;
|
|
148
150
|
cursor: pointer;
|
|
149
151
|
${({ $themefication, size }) => `
|
|
150
152
|
${StyledInput} {
|
|
@@ -15,6 +15,7 @@ import { SelectStates } from './Select.states'
|
|
|
15
15
|
import { textFieldSizes } from './Select.sizes'
|
|
16
16
|
import { SelectProps, StateInterface } from './Select.types'
|
|
17
17
|
import getState from '../TextField/utils/getState'
|
|
18
|
+
import RequiredAsterisk from '../RequiredAsterisk'
|
|
18
19
|
|
|
19
20
|
const Select = forwardRef<HTMLInputElement, SelectProps>(
|
|
20
21
|
(
|
|
@@ -26,8 +27,10 @@ const Select = forwardRef<HTMLInputElement, SelectProps>(
|
|
|
26
27
|
leftIcon,
|
|
27
28
|
size = 'md',
|
|
28
29
|
options,
|
|
30
|
+
placeholder,
|
|
29
31
|
className,
|
|
30
32
|
disabled = false,
|
|
33
|
+
requiredSymbol = false,
|
|
31
34
|
handleLeftIcon,
|
|
32
35
|
register
|
|
33
36
|
},
|
|
@@ -60,10 +63,12 @@ const Select = forwardRef<HTMLInputElement, SelectProps>(
|
|
|
60
63
|
<Wrapper
|
|
61
64
|
className={className}
|
|
62
65
|
size={textFieldSize}
|
|
63
|
-
$themefication={textFieldState}
|
|
66
|
+
$themefication={textFieldState}
|
|
67
|
+
>
|
|
64
68
|
<input
|
|
65
69
|
type="hidden"
|
|
66
70
|
value={selectValue}
|
|
71
|
+
placeholder={placeholder}
|
|
67
72
|
ref={instance => {
|
|
68
73
|
if (typeof ref === 'function') {
|
|
69
74
|
ref(instance)
|
|
@@ -75,7 +80,9 @@ const Select = forwardRef<HTMLInputElement, SelectProps>(
|
|
|
75
80
|
onChange={register?.onChange}
|
|
76
81
|
onBlur={register?.onBlur}
|
|
77
82
|
/>
|
|
78
|
-
<Label>
|
|
83
|
+
<Label>
|
|
84
|
+
{label} {requiredSymbol && <RequiredAsterisk />}
|
|
85
|
+
</Label>
|
|
79
86
|
{disabled ? (
|
|
80
87
|
<InputWrapper className="is-disabled">
|
|
81
88
|
{leftIcon && (
|
|
@@ -4,6 +4,8 @@ export interface SelectProps<TFieldValues extends FieldValues = FieldValues> {
|
|
|
4
4
|
disabled?: boolean
|
|
5
5
|
error?: TFieldValues
|
|
6
6
|
label?: string
|
|
7
|
+
placeholder?: string
|
|
8
|
+
requiredSymbol? :boolean
|
|
7
9
|
options: Array<{ label: string; value: string }>
|
|
8
10
|
value?: string
|
|
9
11
|
defaultValue?: string
|
|
@@ -17,7 +19,7 @@ export interface SelectProps<TFieldValues extends FieldValues = FieldValues> {
|
|
|
17
19
|
|
|
18
20
|
export interface StateInterface {
|
|
19
21
|
input: string
|
|
20
|
-
label
|
|
22
|
+
label?: string
|
|
21
23
|
helperText: string
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -25,8 +25,8 @@ export const TextFieldStates = (state: keyof TextFieldStates) => {
|
|
|
25
25
|
box-shadow: ${shadow.errorShadow};
|
|
26
26
|
}
|
|
27
27
|
`,
|
|
28
|
-
label: `color: ${parseColor(theme.colors.
|
|
29
|
-
helperText: `color: ${parseColor(theme.colors.
|
|
28
|
+
label: `color: ${parseColor(theme.colors.textDark)};`,
|
|
29
|
+
helperText: `color: ${parseColor(theme.colors.danger200)};`,
|
|
30
30
|
},
|
|
31
31
|
default: {
|
|
32
32
|
input: `
|
|
@@ -46,6 +46,7 @@ export const TextFieldStates = (state: keyof TextFieldStates) => {
|
|
|
46
46
|
box-shadow: 0 1px 2px 0 #0000000D;
|
|
47
47
|
opacity: 0.5;
|
|
48
48
|
`,
|
|
49
|
+
label: `color: ${parseColor(theme.colors.textDark)};`,
|
|
49
50
|
helperText: `color: ${parseColor(theme.colors.neutral500)};`,
|
|
50
51
|
}
|
|
51
52
|
}
|
|
@@ -21,8 +21,7 @@ export const InputWrapper = styled.div`
|
|
|
21
21
|
|
|
22
22
|
export const Label = styled.label`
|
|
23
23
|
display: block;
|
|
24
|
-
font-weight: ${fontWeight.
|
|
25
|
-
margin-bottom: ${spacing.spacing4}px;
|
|
24
|
+
font-weight: ${fontWeight.fontWeight500};
|
|
26
25
|
font-size: ${fontSize.fontSize14}px;
|
|
27
26
|
`
|
|
28
27
|
|
|
@@ -65,6 +64,9 @@ export const StyledInput = styled.input.withConfig({
|
|
|
65
64
|
export const Wrapper = styled.div<StyledInputProps>`
|
|
66
65
|
position: relative;
|
|
67
66
|
width: 100%;
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
gap: ${spacing.spacing4}px;
|
|
68
70
|
${({ $themefication, size }) => `
|
|
69
71
|
${StyledInput} {
|
|
70
72
|
${$themefication.input}
|
|
@@ -75,11 +77,7 @@ export const Wrapper = styled.div<StyledInputProps>`
|
|
|
75
77
|
${size.label}
|
|
76
78
|
}
|
|
77
79
|
${HelperText} {
|
|
78
|
-
${$themefication.
|
|
80
|
+
${$themefication.helperText}
|
|
79
81
|
}
|
|
80
82
|
`}
|
|
81
83
|
`
|
|
82
|
-
|
|
83
|
-
export const RequiredAsterisk = styled.span`
|
|
84
|
-
color: ${({ theme }) => parseColor(theme.colors.primary)};
|
|
85
|
-
`
|
|
@@ -2,17 +2,17 @@ import React, { forwardRef, useState } from 'react'
|
|
|
2
2
|
import { TextFieldProps } from './TextField.types'
|
|
3
3
|
import { StateInterface, TextFieldStates } from './TextField.states'
|
|
4
4
|
import {
|
|
5
|
-
Label,
|
|
6
5
|
HelperText,
|
|
7
6
|
IconWrapper,
|
|
8
7
|
InputWrapper,
|
|
8
|
+
Label,
|
|
9
9
|
StyledInput,
|
|
10
|
-
Wrapper
|
|
11
|
-
RequiredAsterisk
|
|
10
|
+
Wrapper
|
|
12
11
|
} from './TextField.styles'
|
|
13
12
|
import { textFieldSizes } from './TextField.sizes'
|
|
14
13
|
import { Eye, EyeClosed } from '@phosphor-icons/react'
|
|
15
14
|
import getState from './utils/getState'
|
|
15
|
+
import RequiredAsterisk from '../RequiredAsterisk'
|
|
16
16
|
|
|
17
17
|
const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
|
|
18
18
|
(
|
|
@@ -31,6 +31,7 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
31
31
|
type = 'text',
|
|
32
32
|
value,
|
|
33
33
|
register,
|
|
34
|
+
requiredSymbol = false,
|
|
34
35
|
placeholder,
|
|
35
36
|
...props
|
|
36
37
|
},
|
|
@@ -72,7 +73,7 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
72
73
|
$themefication={textFieldState}
|
|
73
74
|
>
|
|
74
75
|
<Label>
|
|
75
|
-
{label} {
|
|
76
|
+
{label} {requiredSymbol && <RequiredAsterisk />}
|
|
76
77
|
</Label>
|
|
77
78
|
<InputWrapper>
|
|
78
79
|
{leftIcon && (
|
|
@@ -17,6 +17,7 @@ export interface TextFieldProps<TFieldValues extends FieldValues = FieldValues>
|
|
|
17
17
|
leftIcon?: React.ReactNode
|
|
18
18
|
rightIcon?: React.ReactNode
|
|
19
19
|
error?: TFieldValues
|
|
20
|
+
requiredSymbol?: boolean
|
|
20
21
|
type?: 'text' | 'password' | 'email' | 'number'
|
|
21
22
|
register?: UseFormRegisterReturn<string>
|
|
22
23
|
}
|