office-ui-fabric-react
Version: 
Reusable React components for building experiences for Office 365.
81 lines (80 loc) • 2.73 kB
TypeScript
/// <reference types="react" />
import { ITextField, ITextFieldProps } from './TextField.types';
import { BaseComponent } from '../../Utilities';
export interface ITextFieldState {
    value?: string | undefined;
    /** Is true when the control has focus. */
    isFocused?: boolean;
    /**
     * The validation error message.
     *
     * - If there is no validation error or we have not validated the input value, errorMessage is an empty string.
     * - If we have done the validation and there is validation error, errorMessage is the validation error message.
     */
    errorMessage?: string;
}
export declare class TextField extends BaseComponent<ITextFieldProps, ITextFieldState> implements ITextField {
    static defaultProps: ITextFieldProps;
    private _id;
    private _descriptionId;
    private _delayedValidate;
    private _isMounted;
    private _lastValidation;
    private _latestValue;
    private _latestValidateValue;
    private _isDescriptionAvailable;
    private _textElement;
    constructor(props: ITextFieldProps);
    /**
     * Gets the current value of the text field.
     */
    readonly value: string | undefined;
    componentDidMount(): void;
    componentWillReceiveProps(newProps: ITextFieldProps): void;
    componentWillUnmount(): void;
    render(): JSX.Element;
    /**
     * Sets focus on the text field
     */
    focus(): void;
    /**
     * Selects the text field
     */
    select(): void;
    /**
     * Sets the selection start of the text field to a specified value
     */
    setSelectionStart(value: number): void;
    /**
     * Sets the selection end of the text field to a specified value
     */
    setSelectionEnd(value: number): void;
    /**
     * Gets the selection start of the text field
     */
    readonly selectionStart: number;
    /**
     * Gets the selection end of the text field
     */
    readonly selectionEnd: number;
    /**
     * Sets the start and end positions of a selection in a text field.
     * @param start Index of the start of the selection.
     * @param end Index of the end of the selection.
     */
    setSelectionRange(start: number, end: number): void;
    private _onFocus(ev);
    private _onBlur(ev);
    private _onRenderLabel(props);
    private _onRenderAddon(props);
    private _onRenderPrefix(props);
    private _onRenderSuffix(props);
    private _getTextElementClassName();
    private readonly _errorMessage;
    private _renderTextArea();
    private _renderInput();
    private _onInputChange(event);
    private _validate(value);
    private _notifyAfterValidate(value, errorMessage);
    private _adjustInputHeight();
}