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

    Interface FormattedInputHandler<V, S>

    A handler that updates state in response to various input events.

    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 the initial mutable state of a formatted input corresponding to the given value.

      Parameters

      Returns S

    • Returns the selected text.

      Called when text is copied or cut from a formatted input. By default, a substring of the formatted value is used.

      Parameters

      • state: S

        The current state of the input.

      Returns string

      The selected text.

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

      Parameters

      • state: S

        The current state of the input.

      Returns void

    • Updates the state after the user changes the formatted value.

      Parameters

      • state: S

        The state of the 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

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

      Parameters

      • state: S

        The current state of the input.

      Returns void

    • Updates the state after the text selection changes.

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

      Parameters

      • state: S

        The state of the 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