mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 07:25:35 +00:00
refactor: use tabs instead of spaces
This commit is contained in:
@@ -4,46 +4,46 @@ import FormFieldError from '~/components/common/form/_form_field_error';
|
||||
import Input from '~/components/common/form/_input';
|
||||
|
||||
interface InputProps
|
||||
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> {
|
||||
label: string;
|
||||
name: string;
|
||||
value?: string;
|
||||
errors?: string[];
|
||||
onChange?: (name: string, value: string) => void;
|
||||
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> {
|
||||
label: string;
|
||||
name: string;
|
||||
value?: string;
|
||||
errors?: string[];
|
||||
onChange?: (name: string, value: string) => void;
|
||||
}
|
||||
|
||||
export default function TextBox({
|
||||
name,
|
||||
label,
|
||||
value = '',
|
||||
errors = [],
|
||||
onChange,
|
||||
required = false,
|
||||
...props
|
||||
name,
|
||||
label,
|
||||
value = '',
|
||||
errors = [],
|
||||
onChange,
|
||||
required = false,
|
||||
...props
|
||||
}: InputProps): JSX.Element {
|
||||
const [inputValue, setInputValue] = useState<string>(value);
|
||||
const [inputValue, setInputValue] = useState<string>(value);
|
||||
|
||||
function _onChange({ target }: ChangeEvent<HTMLInputElement>) {
|
||||
setInputValue(target.value);
|
||||
if (onChange) {
|
||||
onChange(target.name, target.value);
|
||||
}
|
||||
}
|
||||
function _onChange({ target }: ChangeEvent<HTMLInputElement>) {
|
||||
setInputValue(target.value);
|
||||
if (onChange) {
|
||||
onChange(target.name, target.value);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<FormField required={required}>
|
||||
<label htmlFor={name} title={label}>
|
||||
{label}
|
||||
</label>
|
||||
<Input
|
||||
{...props}
|
||||
name={name}
|
||||
onChange={_onChange}
|
||||
value={inputValue}
|
||||
placeholder={props.placeholder ?? 'Type something...'}
|
||||
/>
|
||||
{errors.length > 0 &&
|
||||
errors.map((error) => <FormFieldError>{error}</FormFieldError>)}
|
||||
</FormField>
|
||||
);
|
||||
return (
|
||||
<FormField required={required}>
|
||||
<label htmlFor={name} title={label}>
|
||||
{label}
|
||||
</label>
|
||||
<Input
|
||||
{...props}
|
||||
name={name}
|
||||
onChange={_onChange}
|
||||
value={inputValue}
|
||||
placeholder={props.placeholder ?? 'Type something...'}
|
||||
/>
|
||||
{errors.length > 0 &&
|
||||
errors.map((error) => <FormFieldError>{error}</FormFieldError>)}
|
||||
</FormField>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user