Phone Number Field State
State for a phone number field: the selected country, the digits typed, and everything derived from them.
The digits are the single source of truth. The formatted text shown in the field is derived from them, never stored independently, which is what keeps the display and the E.164 output from drifting apart — the failure mode where a field reads +254 712 345 678 and submits 254712345678 .
Properties
Line types accepted, or empty for any. Restricting this to PhoneNumberType.SmsCapable makes the field reject a landline that is otherwise perfectly valid — which is what an SMS code flow needs, and what plain validity cannot express.
True once the user has left the field or attempted submission.
Raw digits, no separators.
The field's text and cursor.
The complete evaluated value: formatted forms, E.164, validity.
Functions
Marks the field touched, so validation messages become visible.
Applies a text edit from the field.
Changes the country, keeping the digits the user already typed.
Parses a full or partial number, adopting the country it identifies when allowCountryChange.