React Hookers - v6.3.0
    Preparing search index...

    Interface FormattedInputHandler<V, S>

    A handler that updates state when various input events occur.

    interface FormattedInputHandler<
        V,
        S extends FormattedInputState<V> = FormattedInputState<V>,
    > {
        getInitialState(value: V): S;
        getSelectedText(state: S): string;
        onBlur(state: S): void;
        onChange(
            state: S,
            nextFormattedValue: string,
            nextSelectionStart: number,
            nextSelectionEnd: number,
        ): void;
        onFocus(state: S): void;
        onSelect(
            state: S,
            nextSelectionStart: number,
            nextSelectionEnd: number,
        ): void;
    }

    Type Parameters

    Implemented by

    Index

    Methods

    • Returns an initial mutable state of a formatted input that corresponds to a value.

      Parameters

      Returns S

    • Returns the selected text. Called when text is copied or cut from a formatted input.

      By default, a substring of formatted value is used.

      Parameters

      • state: S

        The current state of an input.

      Returns string

      A selected text.

    • Updates the state when input is blurred. No-op by default.

      Parameters

      • state: S

        The current state of an input.

      Returns void

    • Updates the state after a user has changed a formatted value.

      Parameters

      • state: S

        The state of an input before the formatted value change.

      • nextFormattedValue: string

        The new formatted value.

      • nextSelectionStart: number

        The new start of the text selection.

      • nextSelectionEnd: number

        The new end of the text selection.

      Returns void

      A new mutable state of a formatted input.

    • Updates the state when an input is focused. No-op by default.

      Parameters

      • state: S

        The current state of an input.

      Returns void

    • Updates the state after the text selection is changed.

      By default, state is updated with the new selection range.

      Parameters

      • state: S

        The state of an input before the selection change.

      • nextSelectionStart: number

        The new start of the text selection.

      • nextSelectionEnd: number

        The new end of the text selection.

      Returns void