Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: input 리팩터링 #36

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mingle-ui",
"description": "mingle-design-system",
"private": false,
"version": "0.5.2",
"version": "0.5.5",
"type": "module",
"license": "MIT",
"files": [
Expand Down
6 changes: 2 additions & 4 deletions src/components/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ interface CustomInputProps<T extends FieldValues> {
formMethod: UseFormReturn<T>;
placeholder: string;
errorMessage?: string;
isRequired?: boolean;
}

type InputProps<T extends FieldValues> = Omit<InputHTMLAttributes<HTMLInputElement>, keyof CustomInputProps<T>> &
Expand All @@ -21,7 +20,6 @@ const Input = <T extends FieldValues>({
placeholder,
formMethod,
errorMessage = '',
isRequired = false,
...rest
}: InputProps<T>) => {
const {
Expand All @@ -48,7 +46,7 @@ const Input = <T extends FieldValues>({
>
<input
className='h-full w-full bg-transparent pr-3 text-base-16 text-neutral-200 outline-none placeholder:text-neutral-700'
{...register(name, { required: isRequired && errorMessage })}
{...register(name)}
id={name as string}
type={type === 'password' ? inputType : type}
placeholder={placeholder}
Expand All @@ -68,7 +66,7 @@ const Input = <T extends FieldValues>({
)}
</div>

{isRequired && errors[name] && <ErrorMessage>{errorMessage}</ErrorMessage>}
{errors[name] && <ErrorMessage>{errorMessage}</ErrorMessage>}
</>
);
};
Expand Down
3 changes: 0 additions & 3 deletions src/components/InputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ interface CustomInputProps<T extends FieldValues> {
formMethod: UseFormReturn<T>;
placeholder: string;
errorMessage?: string;
isRequired?: boolean;
}

type InputFieldProps<T extends FieldValues> = Omit<InputHTMLAttributes<HTMLInputElement>, keyof CustomInputProps<T>> &
Expand All @@ -23,7 +22,6 @@ const InputField = <T extends FieldValues>({
placeholder,
formMethod,
errorMessage,
isRequired,
...rest
}: InputFieldProps<T>) => {
return (
Expand All @@ -35,7 +33,6 @@ const InputField = <T extends FieldValues>({
type={type}
placeholder={placeholder}
errorMessage={errorMessage}
isRequired={isRequired}
{...rest}
/>
</div>
Expand Down