goobs-frontend
Version:
A comprehensive React-based libary for building modern web applications
61 lines • 2.96 kB
TypeScript
import { default as React } from 'react';
import { FieldStyleOverrides } from '../Shell';
export interface TextFieldProps {
/** Controlled input value; the rendered text always mirrors this prop. */
value: string;
/** Called on every edit with the plain string value — not the DOM change event. */
onChange: (value: string) => void;
onFocus?: (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
onBlur?: (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
label?: React.ReactNode;
helperText?: string;
/** Error message rendered below the input; sets aria-invalid. */
error?: string | boolean | undefined;
/**
* Marks the field required — renders the required indicator next to the label
* and sets `aria-required` on the input. Top-level ergonomic alias for
* `styles.required`; DEFAULTS from `styles?.required` when omitted, so every
* existing `styles={{ required: true }}` callsite renders identically. When
* both are set the top-level prop wins (same precedence FieldShell uses).
*/
required?: boolean;
/** Node rendered inside the field frame before the input (icon, unit prefix, …). */
startAdornment?: React.ReactNode;
/** Node rendered inside the field frame after the input. */
endAdornment?: React.ReactNode;
placeholder?: string | undefined;
/** Native input `type` (default 'text'). Ignored when `multiline` is set. */
type?: string;
/** Renders a `<textarea>` instead of a single-line input (default false). */
multiline?: boolean;
/** Minimum textarea height in rows (default 3; applied as 1.5em per row). */
minRows?: number;
/** Stable test selector — emitted as `data-field` on the wrapper. */
dataField?: string;
/** Stable test selector — emitted as `data-field-name` on the wrapper. */
dataFieldName?: string;
/**
* Forwarded to the input as `name` for native form submission, and — unless
* `dataFieldName` is set explicitly — also emitted as `data-field-name` so a
* single `name="<entityFieldKey>"` gives both native binding and the stable
* test anchor the recommender targets via `[data-field-name="<key>"]`.
*/
name?: string;
styles?: FieldStyleOverrides & {
startAdornmentOffset?: string;
endAdornmentOffset?: string;
color?: string;
background?: string;
border?: string;
};
}
/**
* Single- or multiline text input built on FieldShell, with label, helper text,
* error and required states, and optional start/end adornments. Auto-binds its
* value by `name` when rendered inside a goobs `<Form>`; otherwise it is a
* controlled input.
*/
declare const TextField: React.FC<TextFieldProps>;
export default TextField;
//# sourceMappingURL=index.d.ts.map