Select Git revision
-
Nico Vermaas authoredNico Vermaas authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
TextInput.tsx 1.46 KiB
import { Dispatch, ReactNode, SetStateAction } from "react";
import { BaseInput } from "./utils/baseComponents.tsx";
type TextInputProps = {
isRequired?: boolean;
label?: string;
endContent?: ReactNode; // such as units (as text element e.g. <span>)
isClearable?: boolean;
value: string;
onValueChange?: Dispatch<SetStateAction<string>>;
isInvalid?: boolean;
errorMessage?: string;
isDisabled?: boolean;
isReadOnly?: boolean;
maxLength?: number;
type?:
| "text"
| "search"
| "url"
| "tel"
| "email"
| "password"
| (string & NonNullable<unknown>);
inputMode?:
| "none"
| "text"
| "tel"
| "url"
| "email"
| "numeric"
| "decimal"
| "search";
};
const TextInput = ({
isRequired = false,
label = "",
endContent,
isClearable = false,
value,
onValueChange,
isInvalid = false,
errorMessage = "",
isDisabled = false,
isReadOnly = false,
maxLength,
type = "text",
inputMode = "text",
}: TextInputProps) => {
return (
<BaseInput
isRequired={isRequired}
label={label}
endContent={endContent}
placeholder=" "
isClearable={isClearable}
value={value}
onValueChange={onValueChange}
isInvalid={isInvalid}
errorMessage={errorMessage}
isDisabled={isDisabled}
isReadOnly={isReadOnly}
maxLength={maxLength}
type={type}
inputMode={inputMode}
/>
);
};
export default TextInput;
export type { TextInputProps };