Home > mui-country-code-selector > CCSelectorState
This API is provided as an alpha preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Represents a common state between the autocomplete component for selecting the country code and the phone number input component, which together form a complete phone number input component.
Signature:
interface CCSelectorState
Property |
Modifiers |
Type |
Description |
---|---|---|---|
(state: Partial<CCSelectorState>) => void |
(ALPHA) Applies the state changes to outside variables using the changeHandler function (controlled mode) or the reference to the phone number input DOM element. Parameters:
| ||
((event: { target: { value: string; }; }) => void) | undefined |
(ALPHA) An external change handler function to which the current phone number value is forwarded every time the value changes. | ||
() => void |
(ALPHA) The cleanup function which is executed when the component unmounts. Removes the reset event listener added to the form DOM element. Is returned by the | ||
boolean |
(ALPHA) The state variable | ||
() => void |
(ALPHA) Clears the errorMsg state variable. | ||
readonly CountryType[] |
(ALPHA) The calling codes and names of the countries of the world. | ||
string |
(ALPHA) The digits of the detected country code. | ||
CountryType | null |
(ALPHA) The | ||
string |
(ALPHA) A default phone number value. Used when the component is used as an uncontrolled component. | ||
() => void |
(ALPHA) Displays the error message for the time of the delay. | ||
((error: string) => void) | undefined |
(ALPHA) An external error handler function to which the error message is forwarded. | ||
string | null |
(ALPHA) Error message to be shown to the user. | ||
number |
(ALPHA) Time of the message delay in seconds. | ||
NodeJS.Timeout | null |
(ALPHA) | ||
HTMLElement | undefined | null |
(ALPHA) A form DOM element that is parent of the phone number input component. | ||
(_event: unknown, value: CountryType | null, reason: AutocompleteChangeReason, details?: AutocompleteChangeDetails<CountryType> | undefined) => void |
(ALPHA) A handler function for the Parameters:
| ||
(event: { target: { value: string; }; }) => void |
(ALPHA) A handler function for the phone number input’s change events. Takes care of detecting the country code from the input and setting the Parameters:
| ||
(value: string | null | undefined) => void |
(ALPHA) Handles changes to the value prop. This should be called from a useEffect hook in the component’s body. When the component is used as a controlled component the value of the phone number input element can be set (is controlled) from the outside. If the value is changed directly (in contrast to changing it in the onChange() handler function), this change must be handled using the handlePhoneNumberChange() function so that the change is also taken into account in the country code selector’s value. Parameters:
| ||
(errorMsgDelay?: number, errorHandler?: ((error: string) => void) | undefined, changeHandler?: ((event: { target: { value: string; }; }) => void) | undefined) => () => void |
(ALPHA) Initializes the component and returns a cleanup function. This, or the individual setter and cleanup functions, must be called in a Parameters:
| ||
(ALPHA) The start and end indices of the selected text within the phone number input. React keeps track of the cursor position and selection of the controlled input elements. In some situations, however, React doesn’t know where to place the cursor. For example, when an input does not get accepted by the onChange handler and the value is not changed, React places the cursor at the end of the value string. Only remedy to this seems to be to keep track of the cursor position internally, within the application. | |||
HTMLInputElement | undefined | null |
(ALPHA) The phone number input DOM element. | ||
number |
(ALPHA) An index indicating where the local part of the phone number starts. | ||
string |
(ALPHA) The whole phone number including the country code as a string. This is the value of the phone number input element. | ||
() => void |
(ALPHA) Places the cursor (more specifically the start and end indices of the text selection) within the phone number input element according to the | ||
PossibleCountries | null |
(ALPHA) Data on country codes that are possible based on the | ||
(handler: ((event: { target: { value: string; }; }) => void) | undefined) => void |
(ALPHA) Sets a change handler function that is run with the current phone number value every time the value changes. This is used e.g., in the composite selector components ( | ||
(seconds: number) => void |
(ALPHA) Sets the error message delay (how long the message is shown). Takes the delay in seconds as parameter. | ||
(inputSelection: InputSelection) => void |
(ALPHA) Sets the | ||
(inputElement: HTMLInputElement | undefined | null) => void |
(ALPHA) Sets the | ||
(element: HTMLInputElement | null, inputRef?: MutableRefObject<HTMLInputElement | null> | RefCallback<HTMLInputElement | null>, defaultValue?: string) => void |
(ALPHA) Sets references to the phone number input DOM element. Adds also some event handlers and initializes the phone number input with the default value when used as an uncontrolled component. Parameters:
| ||
string |
(ALPHA) The digits of the phone number that are significant in terms of the country code. Contains only the digits without visual separator characters or the plus sign. | ||
() => void |
(ALPHA) Toggles the |