mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
fix input props passthrough
This commit is contained in:
parent
1ea70be80c
commit
f02467f83c
@ -10,9 +10,16 @@ const DefaultInput = (props: InputProps) => (
|
|||||||
<input className={styles.input} id={props.name} {...props} />
|
<input className={styles.input} id={props.name} {...props} />
|
||||||
)
|
)
|
||||||
|
|
||||||
export default function InputElement(props: InputProps): ReactElement {
|
export default function InputElement({
|
||||||
const { type, options, name, prefix, postfix, small, field } = props
|
type,
|
||||||
|
options,
|
||||||
|
name,
|
||||||
|
prefix,
|
||||||
|
postfix,
|
||||||
|
small,
|
||||||
|
field,
|
||||||
|
...props
|
||||||
|
}: InputProps): ReactElement {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'select':
|
case 'select':
|
||||||
return (
|
return (
|
||||||
@ -35,7 +42,9 @@ export default function InputElement(props: InputProps): ReactElement {
|
|||||||
</select>
|
</select>
|
||||||
)
|
)
|
||||||
case 'textarea':
|
case 'textarea':
|
||||||
return <textarea id={name} className={styles.input} {...props} />
|
return (
|
||||||
|
<textarea name={name} id={name} className={styles.input} {...props} />
|
||||||
|
)
|
||||||
case 'radio':
|
case 'radio':
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
return (
|
return (
|
||||||
@ -47,6 +56,7 @@ export default function InputElement(props: InputProps): ReactElement {
|
|||||||
className={styles.radio}
|
className={styles.radio}
|
||||||
id={slugify(option)}
|
id={slugify(option)}
|
||||||
type={type}
|
type={type}
|
||||||
|
name={name}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
<label className={styles.radioLabel} htmlFor={slugify(option)}>
|
<label className={styles.radioLabel} htmlFor={slugify(option)}>
|
||||||
@ -57,20 +67,20 @@ export default function InputElement(props: InputProps): ReactElement {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
case 'files':
|
case 'files':
|
||||||
return <FilesInput {...props} />
|
return <FilesInput name={name} {...field} {...props} />
|
||||||
case 'price':
|
case 'price':
|
||||||
return <Price {...props} />
|
return <Price name={name} {...field} {...props} />
|
||||||
case 'terms':
|
case 'terms':
|
||||||
return <Terms {...props} />
|
return <Terms name={name} options={options} {...field} {...props} />
|
||||||
default:
|
default:
|
||||||
return prefix || postfix ? (
|
return prefix || postfix ? (
|
||||||
<div className={`${prefix ? styles.prefixGroup : styles.postfixGroup}`}>
|
<div className={`${prefix ? styles.prefixGroup : styles.postfixGroup}`}>
|
||||||
{prefix && <div className={styles.prefix}>{prefix}</div>}
|
{prefix && <div className={styles.prefix}>{prefix}</div>}
|
||||||
<DefaultInput type={type || 'text'} {...props} />
|
<DefaultInput name={name} type={type || 'text'} {...props} />
|
||||||
{postfix && <div className={styles.postfix}>{postfix}</div>}
|
{postfix && <div className={styles.postfix}>{postfix}</div>}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<DefaultInput type={type || 'text'} {...props} />
|
<DefaultInput name={name} type={type || 'text'} {...props} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,15 @@ export interface InputProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Input(props: Partial<InputProps>): ReactElement {
|
export default function Input(props: Partial<InputProps>): ReactElement {
|
||||||
const { required, name, label, help, additionalComponent, field } = props
|
const {
|
||||||
|
required,
|
||||||
|
name,
|
||||||
|
label,
|
||||||
|
help,
|
||||||
|
additionalComponent,
|
||||||
|
small,
|
||||||
|
field
|
||||||
|
} = props
|
||||||
|
|
||||||
const hasError =
|
const hasError =
|
||||||
props.form &&
|
props.form &&
|
||||||
@ -62,7 +70,7 @@ export default function Input(props: Partial<InputProps>): ReactElement {
|
|||||||
<Label htmlFor={name} required={required}>
|
<Label htmlFor={name} required={required}>
|
||||||
{label}
|
{label}
|
||||||
</Label>
|
</Label>
|
||||||
<InputElement {...field} {...props} />
|
<InputElement small={small} {...field} {...props} />
|
||||||
|
|
||||||
{field && (
|
{field && (
|
||||||
<div className={styles.error}>
|
<div className={styles.error}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user