2021-01-27 06:12:32 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import {
|
|
|
|
|
Field,
|
|
|
|
|
WrappedFieldMetaProps,
|
|
|
|
|
WrappedFieldInputProps,
|
|
|
|
|
} from "redux-form";
|
2023-01-23 03:50:47 +00:00
|
|
|
import { TextInput, InputType } from "design-system-old";
|
2022-10-05 11:06:49 +00:00
|
|
|
|
2021-01-27 06:12:32 +00:00
|
|
|
import { Intent } from "constants/DefaultTheme";
|
2023-01-23 03:50:47 +00:00
|
|
|
import { FieldError } from "design-system-old";
|
2021-01-27 06:12:32 +00:00
|
|
|
|
|
|
|
|
const renderComponent = (
|
|
|
|
|
componentProps: FormTextFieldProps & {
|
|
|
|
|
meta: Partial<WrappedFieldMetaProps>;
|
|
|
|
|
input: Partial<WrappedFieldInputProps>;
|
|
|
|
|
},
|
|
|
|
|
) => {
|
|
|
|
|
const showError = componentProps.meta.touched && !componentProps.meta.active;
|
|
|
|
|
|
|
|
|
|
return (
|
2021-04-28 10:28:39 +00:00
|
|
|
<>
|
2022-08-22 05:09:39 +00:00
|
|
|
<TextInput {...componentProps} {...componentProps.input} fill />
|
2022-02-11 18:08:46 +00:00
|
|
|
{!componentProps.hideErrorMessage &&
|
|
|
|
|
showError &&
|
|
|
|
|
componentProps.meta.error && (
|
feat: import changes batch 2 (#15722)
* Remove treedropdown from ads
* Change Treedropdown imports
* Remove Notification Banner, change imports
* Remove Toggle from ads
* Change toggle imports
* explicitly declare function argument types
* Remove Menu from ads
* Change menu imports
* Remove Spinner from ads
* Change spinner imports
* Remove Radio, import changes
* test: updated flaky test under default meta (#15707)
* updated flaky test
* Updated tests
* updated tests
* updated the tests
* updated tests
* Update constants.ts
* add more typecasting
* Remove ListSegmentHeader, import changes
* Remove TagInputComponent, import changes
* Remove Switch, import changes
* Remove SearchInput, change imports
* Rename TagInputComponent to TagInput
* Remove ProgressiveImage, import changes
* import changes for SearchVariant
* Remove menu divider, import changes
* Remove TableDropdown, import changes
* Remove Switcher
* Remove StatusBar, import changes
* Remove showcase carousel
* Remove RectangularSwitcher, import change
* Add types to TableDropdown's args
* Remove MultiSwitch, import change
* Remove GifPlayerComponent, import change
* Remove DraggableList, import change
* Remove DisplayImageUpload, import change
* Remove DatePickerComponent, import change
* Remove CopyToClipBoard, import change
* Remove ColorSelector, import change
* Remove TabItemBackgroundFill, NumberedStep, ColorPickerComponent
* GifPlayerComponent -> GifPlayer
* change named import
* Remove FormFieldError, change imports
* Update to new version of Tree Dropdown
* Fix issue with ads/index.ts
* Test file fix
* Fix issue with merge?!?!??
* update design system to 1.0.18
* Bump ds version
* bump ds version
* bump ds version
Co-authored-by: NandanAnantharamu <67676905+NandanAnantharamu@users.noreply.github.com>
Co-authored-by: Albin <albin@appsmith.com>
2022-09-02 08:38:17 +00:00
|
|
|
<FieldError error={showError && componentProps.meta.error} />
|
2022-02-11 18:08:46 +00:00
|
|
|
)}
|
2021-04-28 10:28:39 +00:00
|
|
|
</>
|
2021-01-27 06:12:32 +00:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2021-09-12 16:36:43 +00:00
|
|
|
export type FormTextFieldProps = {
|
2021-01-27 06:12:32 +00:00
|
|
|
name: string;
|
|
|
|
|
placeholder: string;
|
|
|
|
|
type?: InputType;
|
|
|
|
|
label?: string;
|
|
|
|
|
intent?: Intent;
|
|
|
|
|
disabled?: boolean;
|
|
|
|
|
autoFocus?: boolean;
|
2021-05-20 12:03:08 +00:00
|
|
|
hideErrorMessage?: boolean;
|
2021-01-27 06:12:32 +00:00
|
|
|
};
|
|
|
|
|
|
2022-10-05 11:06:49 +00:00
|
|
|
function ReduxFormTextField(props: FormTextFieldProps) {
|
2021-04-28 10:28:39 +00:00
|
|
|
return <Field component={renderComponent} {...props} asyncControl />;
|
|
|
|
|
}
|
2021-01-27 06:12:32 +00:00
|
|
|
|
2022-10-05 11:06:49 +00:00
|
|
|
export default ReduxFormTextField;
|