import React from "react"; import type { PhoneFieldEditKind, PhoneFieldHistorySnapshot, PhoneFieldInputSelection } from "./history.js"; import type { PhoneFieldCountry, PhoneFieldCountryCode, PhoneFieldState, PhoneFieldValue } from "./types.js"; export type PhoneFieldCountryGroup = { readonly id: "preferred" | "all"; readonly items: readonly PhoneFieldCountry[]; }; /** Stable while the user types, so the country picker does not re-render per keystroke. */ export type PhoneFieldCountryContextValue = { selectedCountry: PhoneFieldCountry; availableCountries: readonly PhoneFieldCountry[]; /** Present only when `preferredCountries` pins countries to the top. */ groups: readonly PhoneFieldCountryGroup[] | null; locale: string; disabled: boolean; readOnly: boolean; setCountry: (country: PhoneFieldCountry) => void; /** O(1) lookup in the available countries. */ getCountry: (iso2: string) => PhoneFieldCountry | undefined; }; export type PhoneFieldInputContextValue = { value: PhoneFieldValue; state: PhoneFieldState; /** id of the phone input, used by Label. */ controlId: string; setControlId: (id: string | undefined) => void; descriptionId: string | undefined; setDescriptionId: (id: string | undefined) => void; errorId: string | undefined; setErrorId: (id: string | undefined) => void; markTouched: () => void; setNumber: (number: string, editKind?: PhoneFieldEditKind) => boolean; accepts: (number: string) => boolean; rememberSelection: (selection: PhoneFieldInputSelection) => void; breakHistoryGroup: () => void; undo: () => PhoneFieldHistorySnapshot | undefined; redo: () => PhoneFieldHistorySnapshot | undefined; }; export type PhoneFieldCountryLabels = { /** Search placeholder and accessible name. @default "Search country" */ search?: string; /** Shown when the search has no matches. @default "No countries found" */ empty?: React.ReactNode; }; export declare const PhoneFieldCountryLabelsContext: React.Context; export declare const PhoneFieldCountryContext: React.Context; export declare const PhoneFieldInputContext: React.Context; export declare function usePhoneFieldCountryContext(part?: string): PhoneFieldCountryContextValue; export declare function usePhoneFieldInputContext(part?: string): PhoneFieldInputContextValue; /** Everything a custom part needs: the value, field state, countries, and setters. */ export type UsePhoneFieldReturnValue = { value: PhoneFieldValue; state: PhoneFieldState; country: PhoneFieldCountry; countries: readonly PhoneFieldCountry[]; /** Select a country by ISO2 code. Unknown or unavailable codes are ignored. */ setCountry: (country: PhoneFieldCountryCode | (string & {})) => void; /** Replace the number as if the user typed it. National or `+` international text. */ setNumber: (number: string) => void; }; /** * Read and drive the nearest `PhoneField.Root` from a custom part, such as a * native `