2021-09-21 07:55:56 +00:00
|
|
|
|
import React, {
|
|
|
|
|
|
EventHandler,
|
|
|
|
|
|
FocusEvent,
|
|
|
|
|
|
forwardRef,
|
|
|
|
|
|
Ref,
|
|
|
|
|
|
useCallback,
|
|
|
|
|
|
useMemo,
|
|
|
|
|
|
useState,
|
|
|
|
|
|
} from "react";
|
2021-02-11 12:54:00 +00:00
|
|
|
|
import { Classes, CommonComponentProps, hexToRgba } from "./common";
|
|
|
|
|
|
import styled, { withTheme } from "styled-components";
|
2020-08-14 04:58:03 +00:00
|
|
|
|
import Text, { TextType } from "./Text";
|
2020-08-28 18:51:16 +00:00
|
|
|
|
import {
|
|
|
|
|
|
ERROR_MESSAGE_NAME_EMPTY,
|
2021-03-13 14:24:45 +00:00
|
|
|
|
createMessage,
|
2021-02-11 12:54:00 +00:00
|
|
|
|
FORM_VALIDATION_INVALID_EMAIL,
|
2020-08-28 18:51:16 +00:00
|
|
|
|
} from "constants/messages";
|
|
|
|
|
|
import { isEmail } from "utils/formhelpers";
|
2021-10-04 15:34:37 +00:00
|
|
|
|
import Icon, { IconCollection, IconName, IconSize } from "./Icon";
|
2021-05-03 05:49:12 +00:00
|
|
|
|
import { AsyncControllableInput } from "@blueprintjs/core/lib/esm/components/forms/asyncControllableInput";
|
2021-09-07 13:12:04 +00:00
|
|
|
|
import _ from "lodash";
|
2021-02-03 09:22:19 +00:00
|
|
|
|
|
2020-08-28 18:51:16 +00:00
|
|
|
|
export type Validator = (
|
|
|
|
|
|
value: string,
|
|
|
|
|
|
) => {
|
|
|
|
|
|
isValid: boolean;
|
|
|
|
|
|
message: string;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export function emailValidator(email: string) {
|
2020-11-04 16:06:06 +00:00
|
|
|
|
let isValid = true;
|
|
|
|
|
|
if (email) {
|
|
|
|
|
|
isValid = isEmail(email);
|
|
|
|
|
|
}
|
2020-08-28 18:51:16 +00:00
|
|
|
|
return {
|
|
|
|
|
|
isValid: isValid,
|
2021-03-13 14:24:45 +00:00
|
|
|
|
message: !isValid ? createMessage(FORM_VALIDATION_INVALID_EMAIL) : "",
|
2020-08-28 18:51:16 +00:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function notEmptyValidator(value: string) {
|
|
|
|
|
|
const isValid = !!value;
|
|
|
|
|
|
return {
|
|
|
|
|
|
isValid: isValid,
|
2021-03-13 14:24:45 +00:00
|
|
|
|
message: !isValid ? createMessage(ERROR_MESSAGE_NAME_EMPTY) : "",
|
2020-08-28 18:51:16 +00:00
|
|
|
|
};
|
|
|
|
|
|
}
|
2020-08-10 04:54:33 +00:00
|
|
|
|
|
2020-08-14 04:58:03 +00:00
|
|
|
|
export type TextInputProps = CommonComponentProps & {
|
2021-09-13 13:26:24 +00:00
|
|
|
|
autoFocus?: boolean;
|
2020-08-10 04:54:33 +00:00
|
|
|
|
placeholder?: string;
|
2020-08-14 04:58:03 +00:00
|
|
|
|
fill?: boolean;
|
|
|
|
|
|
defaultValue?: string;
|
2021-08-20 09:55:59 +00:00
|
|
|
|
value?: string;
|
2020-08-14 04:58:03 +00:00
|
|
|
|
validator?: (value: string) => { isValid: boolean; message: string };
|
|
|
|
|
|
onChange?: (value: string) => void;
|
2020-10-12 07:15:35 +00:00
|
|
|
|
readOnly?: boolean;
|
2021-02-11 12:54:00 +00:00
|
|
|
|
dataType?: string;
|
|
|
|
|
|
theme?: any;
|
2021-10-04 15:34:37 +00:00
|
|
|
|
leftIcon?: IconName;
|
|
|
|
|
|
helperText?: string;
|
2021-08-18 11:48:24 +00:00
|
|
|
|
rightSideComponent?: React.ReactNode;
|
2021-10-04 15:34:37 +00:00
|
|
|
|
width?: string;
|
|
|
|
|
|
height?: string;
|
|
|
|
|
|
noBorder?: boolean;
|
|
|
|
|
|
noCaret?: boolean;
|
2021-09-21 07:55:56 +00:00
|
|
|
|
onBlur?: EventHandler<FocusEvent<any>>;
|
|
|
|
|
|
onFocus?: EventHandler<FocusEvent<any>>;
|
2020-08-10 04:54:33 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
2020-08-14 04:58:03 +00:00
|
|
|
|
type boxReturnType = {
|
|
|
|
|
|
bgColor: string;
|
|
|
|
|
|
color: string;
|
|
|
|
|
|
borderColor: string;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2020-09-16 11:50:47 +00:00
|
|
|
|
const boxStyles = (
|
|
|
|
|
|
props: TextInputProps,
|
|
|
|
|
|
isValid: boolean,
|
|
|
|
|
|
theme: any,
|
|
|
|
|
|
): boxReturnType => {
|
2020-09-23 14:06:50 +00:00
|
|
|
|
let bgColor = theme.colors.textInput.normal.bg;
|
|
|
|
|
|
let color = theme.colors.textInput.normal.text;
|
|
|
|
|
|
let borderColor = theme.colors.textInput.normal.border;
|
2020-08-14 04:58:03 +00:00
|
|
|
|
|
2020-10-06 06:02:43 +00:00
|
|
|
|
if (props.disabled) {
|
2020-09-23 14:06:50 +00:00
|
|
|
|
bgColor = theme.colors.textInput.disable.bg;
|
|
|
|
|
|
color = theme.colors.textInput.disable.text;
|
|
|
|
|
|
borderColor = theme.colors.textInput.disable.border;
|
2020-08-14 04:58:03 +00:00
|
|
|
|
}
|
2020-10-12 07:15:35 +00:00
|
|
|
|
if (props.readOnly) {
|
|
|
|
|
|
bgColor = theme.colors.textInput.readOnly.bg;
|
|
|
|
|
|
color = theme.colors.textInput.readOnly.text;
|
|
|
|
|
|
borderColor = theme.colors.textInput.readOnly.border;
|
|
|
|
|
|
}
|
2020-08-14 04:58:03 +00:00
|
|
|
|
if (!isValid) {
|
|
|
|
|
|
bgColor = hexToRgba(theme.colors.danger.main, 0.1);
|
|
|
|
|
|
color = theme.colors.danger.main;
|
|
|
|
|
|
borderColor = theme.colors.danger.main;
|
|
|
|
|
|
}
|
|
|
|
|
|
return { bgColor, color, borderColor };
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2021-02-03 09:22:19 +00:00
|
|
|
|
const StyledInput = styled((props) => {
|
2021-03-15 12:17:56 +00:00
|
|
|
|
// we are removing non input related props before passing them in the components
|
2021-09-07 13:12:04 +00:00
|
|
|
|
// eslint-disable @typescript-eslint/no-unused-vars
|
|
|
|
|
|
const { dataType, inputRef, ...inputProps } = props;
|
|
|
|
|
|
|
|
|
|
|
|
const omitProps = [
|
2021-10-04 15:34:37 +00:00
|
|
|
|
"hasLeftIcon",
|
2021-09-07 13:12:04 +00:00
|
|
|
|
"inputStyle",
|
|
|
|
|
|
"rightSideComponentWidth",
|
|
|
|
|
|
"theme",
|
|
|
|
|
|
"validator",
|
|
|
|
|
|
"isValid",
|
|
|
|
|
|
"cypressSelector",
|
2021-10-04 15:34:37 +00:00
|
|
|
|
"leftIcon",
|
|
|
|
|
|
"helperText",
|
|
|
|
|
|
"rightSideComponent",
|
|
|
|
|
|
"noBorder",
|
|
|
|
|
|
"isLoading",
|
|
|
|
|
|
"noCaret",
|
2021-09-22 18:48:50 +00:00
|
|
|
|
"fill",
|
2021-09-07 13:12:04 +00:00
|
|
|
|
];
|
|
|
|
|
|
|
2021-02-03 09:22:19 +00:00
|
|
|
|
return props.asyncControl ? (
|
2021-03-15 12:17:56 +00:00
|
|
|
|
<AsyncControllableInput
|
2021-09-07 13:12:04 +00:00
|
|
|
|
{..._.omit(inputProps, omitProps)}
|
|
|
|
|
|
datatype={dataType}
|
2021-04-28 10:28:39 +00:00
|
|
|
|
inputRef={inputRef}
|
2021-03-15 12:17:56 +00:00
|
|
|
|
/>
|
2021-02-03 09:22:19 +00:00
|
|
|
|
) : (
|
2021-09-07 13:12:04 +00:00
|
|
|
|
<input ref={inputRef} {..._.omit(inputProps, omitProps)} />
|
2021-02-03 09:22:19 +00:00
|
|
|
|
);
|
2021-08-18 06:05:42 +00:00
|
|
|
|
})<
|
|
|
|
|
|
TextInputProps & {
|
|
|
|
|
|
inputStyle: boxReturnType;
|
|
|
|
|
|
isValid: boolean;
|
|
|
|
|
|
rightSideComponentWidth: number;
|
2021-10-04 15:34:37 +00:00
|
|
|
|
hasLeftIcon: boolean;
|
2021-08-18 06:05:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
>`
|
2021-10-04 15:34:37 +00:00
|
|
|
|
${(props) => (props.noCaret ? "caret-color: white;" : null)}
|
|
|
|
|
|
color: ${(props) => props.inputStyle.color};
|
|
|
|
|
|
width: ${(props) =>
|
|
|
|
|
|
props.value && !props.noBorder && props.isFocused
|
|
|
|
|
|
? "calc(100% - 50px)"
|
|
|
|
|
|
: "100%"};
|
2020-08-14 04:58:03 +00:00
|
|
|
|
border-radius: 0;
|
|
|
|
|
|
outline: 0;
|
|
|
|
|
|
box-shadow: none;
|
2021-10-04 15:34:37 +00:00
|
|
|
|
border: none;
|
|
|
|
|
|
padding: 0;
|
2021-08-18 06:05:42 +00:00
|
|
|
|
padding-right: ${(props) =>
|
2021-10-04 15:34:37 +00:00
|
|
|
|
props.rightSideComponentWidth + props.theme.spaces[5]}px;
|
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
|
font-size: ${(props) => props.theme.typography.p1.fontSize}px;
|
|
|
|
|
|
font-weight: ${(props) => props.theme.typography.p1.fontWeight};
|
|
|
|
|
|
line-height: ${(props) => props.theme.typography.p1.lineHeight}px;
|
|
|
|
|
|
letter-spacing: ${(props) => props.theme.typography.p1.letterSpacing}px;
|
|
|
|
|
|
text-overflow: ellipsis;
|
2021-01-27 06:12:32 +00:00
|
|
|
|
|
2020-08-14 04:58:03 +00:00
|
|
|
|
&::placeholder {
|
2020-12-24 04:32:25 +00:00
|
|
|
|
color: ${(props) => props.theme.colors.textInput.placeholder};
|
2020-08-14 04:58:03 +00:00
|
|
|
|
}
|
2020-10-12 07:15:35 +00:00
|
|
|
|
&:disabled {
|
|
|
|
|
|
cursor: not-allowed;
|
|
|
|
|
|
}
|
2021-10-04 15:34:37 +00:00
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|
const InputWrapper = styled.div<{
|
|
|
|
|
|
value?: string;
|
|
|
|
|
|
isFocused: boolean;
|
|
|
|
|
|
fill?: number;
|
|
|
|
|
|
noBorder?: boolean;
|
|
|
|
|
|
height?: string;
|
|
|
|
|
|
width?: string;
|
|
|
|
|
|
inputStyle: boxReturnType;
|
|
|
|
|
|
isValid?: boolean;
|
|
|
|
|
|
disabled?: boolean;
|
|
|
|
|
|
}>`
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
padding: 0px ${(props) => props.theme.spaces[6]}px;
|
|
|
|
|
|
width: ${(props) =>
|
|
|
|
|
|
props.fill ? "100%" : props.width ? props.width : "260px"};
|
|
|
|
|
|
height: ${(props) => props.height || "36px"};
|
|
|
|
|
|
border: 1.2px solid ${(props) =>
|
|
|
|
|
|
props.noBorder ? "transparent" : props.inputStyle.borderColor};
|
|
|
|
|
|
background-color: ${(props) => props.inputStyle.bgColor};
|
|
|
|
|
|
color: ${(props) => props.inputStyle.color};
|
2020-12-24 04:32:25 +00:00
|
|
|
|
${(props) =>
|
2021-10-04 15:34:37 +00:00
|
|
|
|
props.isFocused && !props.noBorder
|
2020-10-12 07:15:35 +00:00
|
|
|
|
? `
|
2021-10-04 15:34:37 +00:00
|
|
|
|
border: 1.2px solid
|
2020-10-12 07:15:35 +00:00
|
|
|
|
${
|
2020-08-14 04:58:03 +00:00
|
|
|
|
props.isValid
|
|
|
|
|
|
? props.theme.colors.info.main
|
2020-10-12 07:15:35 +00:00
|
|
|
|
: props.theme.colors.danger.main
|
|
|
|
|
|
};
|
2021-10-04 15:34:37 +00:00
|
|
|
|
`
|
|
|
|
|
|
: null}
|
2020-08-14 04:58:03 +00:00
|
|
|
|
|
2020-08-31 13:04:34 +00:00
|
|
|
|
.${Classes.TEXT} {
|
2020-12-24 04:32:25 +00:00
|
|
|
|
color: ${(props) => props.theme.colors.danger.main};
|
2020-08-14 04:58:03 +00:00
|
|
|
|
}
|
2021-10-04 15:34:37 +00:00
|
|
|
|
.helper {
|
|
|
|
|
|
.${Classes.TEXT} {
|
|
|
|
|
|
color: ${(props) => props.theme.colors.textInput.helper};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
background-color: ${(props) =>
|
|
|
|
|
|
props.disabled
|
|
|
|
|
|
? props.inputStyle.bgColor
|
|
|
|
|
|
: props.theme.colors.textInput.hover.bg};
|
|
|
|
|
|
}
|
|
|
|
|
|
${(props) => (props.disabled ? "cursor: not-allowed;" : null)}
|
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|
const MsgWrapper = styled.div`
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
bottom: -20px;
|
|
|
|
|
|
left: 0px;
|
|
|
|
|
|
&.helper {
|
|
|
|
|
|
.${Classes.TEXT} {
|
|
|
|
|
|
color: ${(props) => props.theme.colors.textInput.helper};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-08-14 04:58:03 +00:00
|
|
|
|
`;
|
|
|
|
|
|
|
2021-08-18 06:05:42 +00:00
|
|
|
|
const RightSideContainer = styled.div`
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
top: 0;
|
2021-10-04 15:34:37 +00:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2021-08-18 06:05:42 +00:00
|
|
|
|
`;
|
|
|
|
|
|
|
2021-10-04 15:34:37 +00:00
|
|
|
|
const IconWrapper = styled.div`
|
|
|
|
|
|
.${Classes.ICON} {
|
|
|
|
|
|
margin-right: ${(props) => props.theme.spaces[5]}px;
|
|
|
|
|
|
}
|
2020-08-28 18:51:16 +00:00
|
|
|
|
`;
|
2020-08-14 04:58:03 +00:00
|
|
|
|
const TextInput = forwardRef(
|
|
|
|
|
|
(props: TextInputProps, ref: Ref<HTMLInputElement>) => {
|
|
|
|
|
|
const initialValidation = () => {
|
|
|
|
|
|
let validationObj = { isValid: true, message: "" };
|
|
|
|
|
|
if (props.defaultValue && props.validator) {
|
|
|
|
|
|
validationObj = props.validator(props.defaultValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
return validationObj;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const [validation, setValidation] = useState<{
|
|
|
|
|
|
isValid: boolean;
|
|
|
|
|
|
message: string;
|
|
|
|
|
|
}>(initialValidation());
|
|
|
|
|
|
|
2021-08-18 06:05:42 +00:00
|
|
|
|
const [rightSideComponentWidth, setRightSideComponentWidth] = useState(0);
|
2021-10-04 15:34:37 +00:00
|
|
|
|
const [isFocused, setIsFocused] = useState(false);
|
|
|
|
|
|
const [inputValue, setInputValue] = useState(props.defaultValue);
|
2021-08-18 06:05:42 +00:00
|
|
|
|
|
|
|
|
|
|
const setRightSideRef = useCallback((ref: HTMLDivElement) => {
|
|
|
|
|
|
if (ref) {
|
|
|
|
|
|
const { width } = ref.getBoundingClientRect();
|
|
|
|
|
|
setRightSideComponentWidth(width);
|
|
|
|
|
|
}
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
2020-09-16 11:50:47 +00:00
|
|
|
|
const inputStyle = useMemo(
|
2021-02-11 12:54:00 +00:00
|
|
|
|
() => boxStyles(props, validation.isValid, props.theme),
|
|
|
|
|
|
[props, validation.isValid, props.theme],
|
2020-09-16 11:50:47 +00:00
|
|
|
|
);
|
2020-08-14 04:58:03 +00:00
|
|
|
|
|
|
|
|
|
|
const memoizedChangeHandler = useCallback(
|
2020-12-24 04:32:25 +00:00
|
|
|
|
(el) => {
|
2020-11-04 16:06:06 +00:00
|
|
|
|
const inputValue = el.target.value.trim();
|
2021-10-04 15:34:37 +00:00
|
|
|
|
setInputValue(inputValue);
|
2020-11-04 16:06:06 +00:00
|
|
|
|
const validation = props.validator && props.validator(inputValue);
|
2020-08-28 18:51:16 +00:00
|
|
|
|
if (validation) {
|
|
|
|
|
|
props.validator && setValidation(validation);
|
|
|
|
|
|
return (
|
2020-11-04 16:06:06 +00:00
|
|
|
|
validation.isValid && props.onChange && props.onChange(inputValue)
|
2020-08-28 18:51:16 +00:00
|
|
|
|
);
|
|
|
|
|
|
} else {
|
2020-11-04 16:06:06 +00:00
|
|
|
|
return props.onChange && props.onChange(inputValue);
|
2020-08-28 18:51:16 +00:00
|
|
|
|
}
|
2020-08-14 04:58:03 +00:00
|
|
|
|
},
|
|
|
|
|
|
[props],
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2020-08-28 18:51:16 +00:00
|
|
|
|
const ErrorMessage = (
|
2021-10-04 15:34:37 +00:00
|
|
|
|
<MsgWrapper>
|
2020-08-28 18:51:16 +00:00
|
|
|
|
<Text type={TextType.P3}>{validation.message}</Text>
|
2021-10-04 15:34:37 +00:00
|
|
|
|
</MsgWrapper>
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const HelperMessage = (
|
|
|
|
|
|
<MsgWrapper className="helper">
|
|
|
|
|
|
<Text type={TextType.P3}>* {props.helperText}</Text>
|
|
|
|
|
|
</MsgWrapper>
|
2020-08-28 18:51:16 +00:00
|
|
|
|
);
|
2021-10-04 15:34:37 +00:00
|
|
|
|
const iconColor = !validation.isValid
|
|
|
|
|
|
? props.theme.colors.danger.main
|
|
|
|
|
|
: props.theme.colors.textInput.icon;
|
2020-08-14 04:58:03 +00:00
|
|
|
|
|
2021-10-04 15:34:37 +00:00
|
|
|
|
const hasLeftIcon = props.leftIcon
|
|
|
|
|
|
? IconCollection.includes(props.leftIcon)
|
|
|
|
|
|
: false;
|
2020-08-14 04:58:03 +00:00
|
|
|
|
return (
|
2021-10-04 15:34:37 +00:00
|
|
|
|
<InputWrapper
|
|
|
|
|
|
disabled={props.disabled}
|
|
|
|
|
|
fill={props.fill ? 1 : 0}
|
|
|
|
|
|
height={props.height || undefined}
|
|
|
|
|
|
inputStyle={inputStyle}
|
|
|
|
|
|
isFocused={isFocused}
|
|
|
|
|
|
isValid={validation.isValid}
|
|
|
|
|
|
noBorder={props.noBorder}
|
|
|
|
|
|
value={inputValue}
|
|
|
|
|
|
width={props.width || undefined}
|
|
|
|
|
|
>
|
|
|
|
|
|
{props.leftIcon && (
|
|
|
|
|
|
<IconWrapper className="left-icon">
|
|
|
|
|
|
<Icon
|
|
|
|
|
|
fillColor={iconColor}
|
|
|
|
|
|
name={props.leftIcon}
|
|
|
|
|
|
size={IconSize.MEDIUM}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
|
)}
|
2020-08-14 04:58:03 +00:00
|
|
|
|
<StyledInput
|
2021-09-13 13:26:24 +00:00
|
|
|
|
autoFocus={props.autoFocus}
|
2021-04-28 10:28:39 +00:00
|
|
|
|
defaultValue={props.defaultValue}
|
2020-08-14 04:58:03 +00:00
|
|
|
|
inputStyle={inputStyle}
|
|
|
|
|
|
isValid={validation.isValid}
|
2021-04-28 10:28:39 +00:00
|
|
|
|
ref={ref}
|
|
|
|
|
|
type={props.dataType || "text"}
|
2020-08-14 04:58:03 +00:00
|
|
|
|
{...props}
|
2020-10-28 05:39:28 +00:00
|
|
|
|
data-cy={props.cypressSelector}
|
2021-10-04 15:34:37 +00:00
|
|
|
|
hasLeftIcon={hasLeftIcon}
|
2021-02-03 09:22:19 +00:00
|
|
|
|
inputRef={ref}
|
2021-10-08 07:39:31 +00:00
|
|
|
|
onBlur={(e: React.FocusEvent<any>) => {
|
|
|
|
|
|
setIsFocused(false);
|
|
|
|
|
|
if (props.onBlur) props.onBlur(e);
|
|
|
|
|
|
}}
|
2021-04-28 10:28:39 +00:00
|
|
|
|
onChange={memoizedChangeHandler}
|
2021-10-08 07:39:31 +00:00
|
|
|
|
onFocus={(e: React.FocusEvent<any>) => {
|
|
|
|
|
|
setIsFocused(true);
|
|
|
|
|
|
if (props.onFocus) props.onFocus(e);
|
|
|
|
|
|
}}
|
2021-04-28 10:28:39 +00:00
|
|
|
|
placeholder={props.placeholder}
|
|
|
|
|
|
readOnly={props.readOnly}
|
2021-08-18 06:05:42 +00:00
|
|
|
|
rightSideComponentWidth={rightSideComponentWidth}
|
2020-08-14 04:58:03 +00:00
|
|
|
|
/>
|
2021-10-04 15:34:37 +00:00
|
|
|
|
{validation.isValid &&
|
|
|
|
|
|
props.helperText &&
|
|
|
|
|
|
props.helperText.length > 0 &&
|
|
|
|
|
|
HelperMessage}
|
2020-08-28 18:51:16 +00:00
|
|
|
|
{ErrorMessage}
|
2021-08-18 06:05:42 +00:00
|
|
|
|
<RightSideContainer ref={setRightSideRef}>
|
2021-08-18 11:48:24 +00:00
|
|
|
|
{props.rightSideComponent}
|
2021-08-18 06:05:42 +00:00
|
|
|
|
</RightSideContainer>
|
2020-08-14 04:58:03 +00:00
|
|
|
|
</InputWrapper>
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
TextInput.displayName = "TextInput";
|
|
|
|
|
|
|
2021-02-11 12:54:00 +00:00
|
|
|
|
export default withTheme(TextInput);
|
2021-01-27 06:12:32 +00:00
|
|
|
|
|
|
|
|
|
|
export type InputType = "text" | "password" | "number" | "email" | "tel";
|