import type { SyntheticEvent } from "react"; import React from "react"; import type { FocusEvent, StyleProp, TextInputProps, TextStyle } from "react-native"; import { TextInput } from "react-native"; import type { RegisterOptions } from "react-hook-form"; import type { IconNames } from "@jobber/design"; import type { Clearable } from "@jobber/hooks"; import type { InputFieldStyleOverride, InputFieldWrapperProps } from "../InputFieldWrapper/InputFieldWrapper"; export interface InputTextProps extends Pick { /** * Highlights the field red and shows message below (if string) to indicate an error */ readonly invalid?: boolean | string; /** * Disable the input */ readonly disabled?: boolean; /** * Makes the input read-only */ readonly readonly?: boolean; /** * Name of the input. */ readonly name?: string; /** * Hint text that goes above the value once the field is filled out */ readonly placeholder?: string; /** * Text that helps the user understand the input */ readonly assistiveText?: string; /** * Controls the visibility of the mini label that appears inside the input * when a value is entered. By default, the placeholder text moves up to * become a mini label. Set to false to disable this behavior. * * @default true */ readonly showMiniLabel?: boolean; /** * Determines what keyboard is shown */ readonly keyboard?: "default" | "numeric" | "phone-pad" | "email-address" | "numbers-and-punctuation" | "decimal-pad"; /** * Set the component to a given value */ readonly value?: string; /** * Default value for when component is uncontrolled */ readonly defaultValue?: string; /** * Automatically focus the input after it is rendered */ readonly autoFocus?: boolean; /** * Shows an error message below the field and highlight the field red when value is invalid */ readonly validations?: RegisterOptions; /** * Simplified callback that only provides the new value * @param newValue */ readonly onChangeText?: (newValue: string) => void; /** * Callback that is called when the text input's submit button is pressed * @param event */ readonly onSubmitEditing?: (event?: SyntheticEvent) => void; /** * Callback that is called when the text input is focused * @param event */ readonly onFocus?: (event?: FocusEvent) => void; /** * Callback that is called when the text input is blurred */ readonly onBlur?: (event?: FocusEvent) => void; /** * VoiceOver will read this string when a user selects the associated element */ readonly accessibilityLabel?: string; /** * An accessibility hint helps users understand what will happen when they perform an action on the * accessibility element when that result is not clear from the accessibility label */ readonly accessibilityHint?: string; /** * Turn off autocorrect */ readonly autoCorrect?: boolean; /** * Determines where to autocapitalize */ readonly autoCapitalize?: "characters" | "words" | "sentences" | "none"; /** * Determines which content to suggest on auto complete, e.g.`username`. * Default is `off` which disables auto complete * * *Android Only* * */ readonly autoComplete?: TextInputProps["autoComplete"]; /** * Determines which content to suggest on auto complete, e.g.`username`. * Default is `none` which disables auto complete * * *iOS Only* */ readonly textContentType?: TextInputProps["textContentType"]; /** * Determines if inputText will span multiple lines. * Default is `false` * * https://reactnative.dev/docs/textinput#multiline */ readonly multiline?: TextInputProps["multiline"]; /** * Symbol to display before the text input */ readonly prefix?: { icon?: IconNames; label?: string; }; /** * Symbol to display after the text input */ readonly suffix?: { icon?: IconNames; label?: string; onPress?: () => void; }; /** * transform object is used to transform the internal TextInput value * It's useful for components like InputNumber where we want to transform * the internal value to a number. * "input" is a function that transform the value to the string format that should be shown to the user * "output" is a function that transform the string representation of the value to the value that is sent to onChange and the form */ readonly transform?: { input?: (v: any) => string | undefined; output?: (v: string | undefined) => any; }; /** * Add a clear action on the input that clears the value. * * You should always use `while-editing` if you want the input to be * clearable. if the input value isn't editable (i.e. `InputDateTime`) you can * set it to `always`. */ readonly clearable?: Clearable; /** * Used to locate this view in end-to-end tests */ readonly testID?: string; /** * Use secure text entry */ readonly secureTextEntry?: boolean; /** * Determines whether spell check is used. Turn it off to hide empty autoCorrect * suggestions when autoCorrect is off. * * *iOS Only* */ readonly spellCheck?: boolean; /** * Custom styling to override default style of the input text */ readonly styleOverride?: InputTextStyleOverride; } interface InputTextStyleOverride extends InputFieldStyleOverride { inputText?: StyleProp; } export type InputTextRef = Pick; export declare const InputText: React.ForwardRefExoticComponent>; export {};