mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-25 22:37:18 +10:00
final form update: type is nowadays inside input props
This commit is contained in:
parent
35039f5643
commit
494ad56147
6 changed files with 24 additions and 23 deletions
|
|
@ -47,7 +47,7 @@ class FieldDateInputComponent extends Component {
|
|||
[css.pickerError]: hasError,
|
||||
});
|
||||
|
||||
const { onBlur, onFocus, ...restOfInput } = input;
|
||||
const { onBlur, onFocus, type, ...restOfInput } = input;
|
||||
const inputProps = {
|
||||
onBlur: input.onBlur,
|
||||
onFocus: input.onFocus,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ import DateRangeController from './DateRangeController';
|
|||
|
||||
const component = props => {
|
||||
const { input, controllerRef, ...rest } = props;
|
||||
return <DateRangeController ref={controllerRef} {...input} {...rest} />;
|
||||
const { type, ...restOfInput } = input;
|
||||
return <DateRangeController ref={controllerRef} {...restOfInput} {...rest} />;
|
||||
};
|
||||
|
||||
const FieldDateRangeController = props => {
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ class FieldDateRangeInputComponent extends Component {
|
|||
) : null;
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { onBlur, onFocus, ...restOfInput } = input;
|
||||
const { onBlur, onFocus, type, ...restOfInput } = input;
|
||||
const inputProps = {
|
||||
unitType,
|
||||
onBlur: this.handleBlur,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ class FieldTextInputComponent extends Component {
|
|||
customErrorText,
|
||||
id,
|
||||
label,
|
||||
type,
|
||||
input,
|
||||
meta,
|
||||
onUnmount,
|
||||
|
|
@ -33,7 +32,7 @@ class FieldTextInputComponent extends Component {
|
|||
}
|
||||
|
||||
const { valid, invalid, touched, error } = meta;
|
||||
const isTextarea = type === 'textarea';
|
||||
const isTextarea = input.type === 'textarea';
|
||||
|
||||
const errorText = customErrorText || error;
|
||||
|
||||
|
|
@ -43,6 +42,8 @@ class FieldTextInputComponent extends Component {
|
|||
|
||||
const fieldMeta = { touched: hasError, error: errorText };
|
||||
|
||||
// Textarea doesn't need type.
|
||||
const { type, ...inputWithoutType } = input;
|
||||
// Uncontrolled input uses defaultValue instead of value.
|
||||
const { value: defaultValue, ...inputWithoutValue } = input;
|
||||
// Use inputRef if it is passed as prop.
|
||||
|
|
@ -57,7 +58,15 @@ class FieldTextInputComponent extends Component {
|
|||
});
|
||||
const maxLength = CONTENT_MAX_LENGTH;
|
||||
const inputProps = isTextarea
|
||||
? { className: inputClasses, id, rows: 1, maxLength, ...refMaybe, ...input, ...rest }
|
||||
? {
|
||||
className: inputClasses,
|
||||
id,
|
||||
rows: 1,
|
||||
maxLength,
|
||||
...refMaybe,
|
||||
...inputWithoutType,
|
||||
...rest,
|
||||
}
|
||||
: isUncontrolled
|
||||
? {
|
||||
className: inputClasses,
|
||||
|
|
@ -109,9 +118,6 @@ FieldTextInputComponent.propTypes = {
|
|||
id: string,
|
||||
label: string,
|
||||
|
||||
// Either 'textarea' or something that is passed to the input element
|
||||
type: string.isRequired,
|
||||
|
||||
// Uncontrolled input uses defaultValue prop, but doesn't pass value from form to the field.
|
||||
// https://reactjs.org/docs/uncontrolled-components.html#default-values
|
||||
isUncontrolled: bool,
|
||||
|
|
@ -121,6 +127,8 @@ FieldTextInputComponent.propTypes = {
|
|||
// Generated by final-form's Field component
|
||||
input: shape({
|
||||
onChange: func.isRequired,
|
||||
// Either 'textarea' or something that is passed to the input element
|
||||
type: string.isRequired,
|
||||
}).isRequired,
|
||||
meta: object.isRequired,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -159,8 +159,8 @@ export class EditListingPhotosFormComponent extends Component {
|
|||
disabled={imageUploadRequested}
|
||||
>
|
||||
{fieldprops => {
|
||||
const { accept, input, label, type, disabled } = fieldprops;
|
||||
const { name } = input;
|
||||
const { accept, input, label, disabled } = fieldprops;
|
||||
const { name, type } = input;
|
||||
const onChange = e => {
|
||||
const file = e.target.files[0];
|
||||
form.change(`addImage`, file);
|
||||
|
|
@ -185,10 +185,10 @@ export class EditListingPhotosFormComponent extends Component {
|
|||
|
||||
<Field
|
||||
component={props => {
|
||||
const { input, type, meta } = props;
|
||||
const { input, meta } = props;
|
||||
return (
|
||||
<div className={css.imageRequiredWrapper}>
|
||||
<input {...input} type={type} />
|
||||
<input {...input} />
|
||||
<ValidationError fieldMeta={meta} />
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -198,16 +198,8 @@ class ProfileSettingsFormComponent extends Component {
|
|||
disabled={uploadInProgress}
|
||||
>
|
||||
{fieldProps => {
|
||||
const {
|
||||
accept,
|
||||
id,
|
||||
input,
|
||||
label,
|
||||
type,
|
||||
disabled,
|
||||
uploadImageError,
|
||||
} = fieldProps;
|
||||
const { name } = input;
|
||||
const { accept, id, input, label, disabled, uploadImageError } = fieldProps;
|
||||
const { name, type } = input;
|
||||
const onChange = e => {
|
||||
const file = e.target.files[0];
|
||||
form.change(`profileImage`, file);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue