import React from 'react'; import PropTypes from 'prop-types'; import { ComponentProps } from '../utils/types'; /** @public */ type PhoneNumberChangeHandler = (event: React.ChangeEvent | React.KeyboardEvent | React.MouseEvent, data: { name?: string; value: string; displayValue: string; country?: string; isPossibleNumber: boolean; isValidNumber: boolean; internationalFormat: string; }) => void; /** @public */ type PhoneNumberBlurHandler = (event: React.FocusEvent, data: { name?: string; value: string; displayValue: string; country?: string; isPossibleNumber: boolean; isValidNumber: boolean; internationalFormat: string; }) => void; /** @public */ type PhoneNumberFocusHandler = (event: React.FocusEvent, data: { name?: string; value: string; displayValue: string; country?: string; isPossibleNumber: boolean; isValidNumber: boolean; internationalFormat: string; }) => void; interface PhoneNumberPropsBase { /** Append removes rounded corners and the border from the right side. */ append?: boolean; /** Include an "X" button to clear the value. */ canClear?: boolean; /** The iso2 country code to use for the phone number input. */ defaultCountry?: string; /** Set this property instead of value to make the value uncontrolled. */ defaultValue?: string; /** * The id of the description. When placed in a ControlGroup, this is automatically set to the * ControlGroup's help component. */ describedBy?: string; /** Determines whether or not the input is disabled. */ disabled?: boolean; /** * A React ref which is set to the DOM element when the component mounts, and null when it unmounts. */ elementRef?: React.Ref; /** Highlight the field as having an error. */ error?: boolean; /** When true, displays inline with a default width. */ inline?: boolean; /** An id for the text input. */ inputId?: string; /** * A React ref which is set to the text input element when the component mounts, and null when it unmounts. */ inputRef?: React.Ref; /** * The id of the label. When placed in a ControlGroup, this is automatically set to the * ControlGroup's label. */ labelledBy?: string; name?: string; /** A callback for when the input loses focus. */ onBlur?: PhoneNumberBlurHandler; /** * Called whenever the value changes. * If the value prop is set, this callback is required. */ onChange?: PhoneNumberChangeHandler; /** A callback for when the input is clicked. */ onClick?: React.MouseEventHandler; /** A callback for when the input takes focus. */ onFocus?: PhoneNumberFocusHandler; /** A callback for when the user selects text. */ onSelect?: React.ReactEventHandler; /** Prepend removes rounded borders from the left side. */ prepend?: boolean; /** * @private * Do not format the number as the user types. */ skipFormatting?: boolean; /** * A React ref which is set to the dropdown toggle when the component mounts and null when it unmounts. */ toggleRef?: React.Ref; /** * The contents of the input. Setting this value makes the input controlled. A callback is required. */ value?: string; } interface PhoneNumberPropsBaseControlled extends PhoneNumberPropsBase { defaultValue?: never; onChange: PhoneNumberChangeHandler; value?: string; } interface PhoneNumberPropsBaseUncontrolled extends PhoneNumberPropsBase { defaultValue?: string; value?: never; } type PhoneNumberProps = ComponentProps; declare function PhoneNumber({ append, canClear, defaultCountry, defaultValue, describedBy, disabled, elementRef, error, inline, inputRef, name, onBlur, onChange, onFocus, prepend, skipFormatting, toggleRef, value, ...otherProps }: PhoneNumberProps): React.JSX.Element; declare namespace PhoneNumber { var componentType: string; var propTypes: { append: PropTypes.Requireable; canClear: PropTypes.Requireable; defaultCountry: PropTypes.Requireable; defaultValue: PropTypes.Requireable; describedBy: PropTypes.Requireable; disabled: PropTypes.Requireable; elementRef: PropTypes.Requireable; error: PropTypes.Requireable; inline: PropTypes.Requireable; inputId: PropTypes.Requireable; inputRef: PropTypes.Requireable; labelledBy: PropTypes.Requireable; name: PropTypes.Requireable; onBlur: PropTypes.Requireable<(...args: any[]) => any>; onChange: PropTypes.Requireable<(...args: any[]) => any>; onClick: PropTypes.Requireable<(...args: any[]) => any>; onFocus: PropTypes.Requireable<(...args: any[]) => any>; onSelect: PropTypes.Requireable<(...args: any[]) => any>; prepend: PropTypes.Requireable; /** @private */ skipFormatting: PropTypes.Requireable; value: PropTypes.Requireable; }; } export default PhoneNumber; export { PhoneNumberBlurHandler, PhoneNumberChangeHandler, PhoneNumberFocusHandler }; export type { PhoneNumberProps, PhoneNumberPropsBase, PhoneNumberPropsBaseControlled, PhoneNumberPropsBaseUncontrolled, };