import React from 'react'; import { extractStringLabel, type SafeOmit, type SafePick } from '@shoptet/utils'; import type { FieldProps } from '../../Field/Field'; import { Field } from '../../Field/Field'; import type { FieldHelperTextProps } from '../../Field/FieldHelperText'; import type { FieldLabelProps } from '../../Field/FieldLabel'; import { InputLoader } from '../../Inputs/InputLoader'; import type { TextInputProps } from '../../Inputs/TextInput/TextInput'; import { TextInput } from '../../Inputs/TextInput/TextInput'; import type { LabelAfterProps } from '../../LabelAfter/LabelAfter'; /** @inheritdoc */ export interface TextFieldProps extends SafePick, SafePick, SafeOmit, SafePick { /** * Label for the input element. */ label: string; /** * Visually hide the label. */ labelHidden?: FieldLabelProps['visuallyHidden']; /** * Addon to the right of the input. * * **INTERNAL USE ONLY:** It is unsafe to rely on this prop, as it may change or be removed in the future. * @internal */ UNSAFE_addon?: React.ReactNode; /** * Label displayed after the input element. */ labelAfter?: LabelAfterProps['label']; /** * Display loading indicator. */ loading?: boolean; } export const TextField: React.FC = React.forwardRef( function TextField( { UNSAFE_addon: addon, tooltip, required, label, labelHidden, labelAfter, loading, error, warning, hint, width, disabled, readOnly, justify, ...inputProps }: TextFieldProps, ref ) { return ( {label}
{labelAfter && {labelAfter}}
{addon}
); } );