-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRenderInputContent.tsx
More file actions
51 lines (48 loc) · 1.27 KB
/
RenderInputContent.tsx
File metadata and controls
51 lines (48 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
import React from 'react';
import IcSmallTextdelete from '@/assets/svg/IcSmallTextdelete';
import IcLock from '@/assets/svg/IcLock';
interface RenderInputContentProps {
fieldState: string;
inputProps: React.InputHTMLAttributes<HTMLInputElement>;
value: string;
isLocked: boolean;
handleClearClick: (e: React.MouseEvent) => void;
styles: typeof import('./SignupTextField.css');
}
export function RenderInputContent({
fieldState,
inputProps,
value,
isLocked,
handleClearClick,
styles,
}: RenderInputContentProps) {
if (fieldState === 'typing' || fieldState === 'error') {
return (
<>
<input {...inputProps} />
{value && !isLocked && (
<button
type="button"
onClick={handleClearClick}
onMouseDown={(e) => e.preventDefault()}
tabIndex={-1}
className={styles.clearButton}
aria-label="입력값 삭제"
>
<IcSmallTextdelete className={styles.iconClass} />
</button>
)}
</>
);
}
if (fieldState === 'locked') {
return (
<div className={styles.inputContent}>
<input {...inputProps} />
<IcLock className={styles.lockIconClass} />
</div>
);
}
return <input {...inputProps} />;
}