From cc2276a7078659f1eb65294eccc934d91687c6c4 Mon Sep 17 00:00:00 2001 From: ttaerrim Date: Thu, 7 Dec 2023 14:29:10 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20props=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=EC=9D=84=20=EC=A7=81=EC=A0=91=20=EC=84=A0=EC=96=B8?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EA=B3=A0=20InputHTMLAttributes?= =?UTF-8?q?=20=ED=83=80=EC=9E=85=20=EC=82=AC=EC=9A=A9=20=EB=B0=8F=20rest?= =?UTF-8?q?=20=EB=B0=A9=EC=8B=9D=EC=9D=98=20props=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/frontend/src/components/Input/index.tsx | 47 ++++----------------- 1 file changed, 9 insertions(+), 38 deletions(-) diff --git a/app/frontend/src/components/Input/index.tsx b/app/frontend/src/components/Input/index.tsx index 9ca4f41ef..999426ff6 100644 --- a/app/frontend/src/components/Input/index.tsx +++ b/app/frontend/src/components/Input/index.tsx @@ -1,39 +1,16 @@ import * as styles from './index.css'; import { FieldLabel } from '../FieldLabel'; -type InputProps = { +type InputProps = React.InputHTMLAttributes & { label?: string; - placeholder?: string; errorMessage?: string; - type?: React.HTMLInputTypeAttribute; - disabled?: boolean; - maxLength?: number; - min?: number | string; - max?: number; - required?: boolean; - defaultValue?: string; - value?: string | number; - onChange?: React.ChangeEventHandler; - onClick?: React.MouseEventHandler; - list?: string; }; -export function Input({ - label = '', - type = 'input', - placeholder = '', - errorMessage = '', - disabled = false, - maxLength, - min, - max, - required = false, - defaultValue = '', - value, - onChange, - onClick, - list, -}: InputProps) { +export function Input(props: InputProps) { + const { label = '', errorMessage = '', ...rest } = props; + + const { value, maxLength, disabled, required } = rest; + return (
{maxLength && ( - {value ? value.toString().length : 0}/{maxLength} + {value?.toString()?.length || 0}/{maxLength} )}
)} {!disabled && errorMessage && (

{errorMessage}

From 699d24f0b5939867f68a8e12b6d76ca77c99b52e Mon Sep 17 00:00:00 2001 From: ttaerrim Date: Thu, 7 Dec 2023 14:39:21 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20props=EB=A5=BC=20?= =?UTF-8?q?=EC=9B=90=EB=9E=98=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8D=98=20?= =?UTF-8?q?=EB=B0=A9=EC=8B=9D=EC=9C=BC=EB=A1=9C=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/frontend/src/components/Input/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/frontend/src/components/Input/index.tsx b/app/frontend/src/components/Input/index.tsx index 999426ff6..7d7e6170b 100644 --- a/app/frontend/src/components/Input/index.tsx +++ b/app/frontend/src/components/Input/index.tsx @@ -6,9 +6,7 @@ type InputProps = React.InputHTMLAttributes & { errorMessage?: string; }; -export function Input(props: InputProps) { - const { label = '', errorMessage = '', ...rest } = props; - +export function Input({ label = '', errorMessage = '', ...rest }: InputProps) { const { value, maxLength, disabled, required } = rest; return (