@xsolla/xui-input-phone 0.174.3 → 0.176.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
# InputPhone
|
|
2
2
|
|
|
3
3
|
A cross-platform phone-number input with an integrated, searchable country selector (flags and dial codes); ships with a `usePhoneNumber` hook for formatting and country detection.
|
|
4
|
+
<!-- BEGIN:xui-mcp-instructions:input-phone -->
|
|
5
|
+
A specialised input for entering a phone number. Combines a Select (country/region picker) with a text field for the number itself. Used whenever the product requires a valid, internationally formatted phone number from the user.
|
|
6
|
+
|
|
7
|
+
### When to use
|
|
8
|
+
|
|
9
|
+
- Registration and account setup forms requiring a phone number
|
|
10
|
+
- Two-factor authentication (2FA) enrollment flows
|
|
11
|
+
- Payment and billing forms where a contact number is required
|
|
12
|
+
- Any context where the phone number must include a country code
|
|
13
|
+
|
|
14
|
+
### When not to use
|
|
15
|
+
|
|
16
|
+
When a simple freeform text field is sufficient and international formatting is not required — use a plain Input instead
|
|
17
|
+
|
|
18
|
+
When the phone number does not need country selection (e.g. a single-country product with a fixed dial code)
|
|
19
|
+
|
|
20
|
+
Do not use for non-phone numeric fields (e.g. zip codes, card numbers) — use Input with appropriatetype
|
|
21
|
+
|
|
22
|
+
### Content guidelines
|
|
23
|
+
|
|
24
|
+
Placeholder mask should show the expected format for the selected country (e.g. (000) 000-0000 for US, 00 0000 0000 for AU). Update it dynamically when the country changes.
|
|
25
|
+
|
|
26
|
+
Dial code (e.g. +1) should be displayed as a non-editable prefix, not typed by the user.
|
|
27
|
+
|
|
28
|
+
Error messages should be specific: *"Enter a valid phone number"*, not just *"Invalid input"*. If the format is wrong, indicate the expected format.
|
|
29
|
+
|
|
30
|
+
Country selector label — use the flag icon as the primary identifier; always include the country name in the dropdown list for accessibility.
|
|
31
|
+
|
|
32
|
+
### Behaviour guidelines
|
|
33
|
+
|
|
34
|
+
Auto-format the number as the user types, applying the mask for the selected country (e.g. spaces, dashes, parentheses). This reduces input errors and improves readability.
|
|
35
|
+
|
|
36
|
+
Auto-detect country from the number if the user pastes a full international number with a + prefix — update the flag and dial code accordingly.
|
|
37
|
+
|
|
38
|
+
Strip non-numeric characters on submit; store the number in E.164 format (e.g. +14155551234) regardless of display format.
|
|
39
|
+
|
|
40
|
+
Preserve the country selection when the user clears the number field with the Remove button — only the number should be cleared, not the country.
|
|
41
|
+
|
|
42
|
+
Validate on blur, not on every keystroke, to avoid showing errors before the user has finished typing.
|
|
43
|
+
|
|
44
|
+
Country list should be searchable when it contains more than ~20 entries. Prioritise common countries at the top (e.g. based on locale or previous selection).
|
|
45
|
+
|
|
46
|
+
### Accessibility
|
|
47
|
+
|
|
48
|
+
The country selector must have an accessible name (e.g. aria-label=*"Select country"*) — flag icons alone are not sufficient for screen readers.
|
|
49
|
+
|
|
50
|
+
The dial code prefix must be announced as part of the field context, either via aria-label on the input or by including it in a visible label.
|
|
51
|
+
|
|
52
|
+
The phone input should use type=*"tel"* to trigger the numeric keyboard on mobile.
|
|
53
|
+
|
|
54
|
+
The input should have autocomplete=*"tel"* to support autofill.
|
|
55
|
+
|
|
56
|
+
Error messages must be linked via aria-describedby so screen readers announce them on focus.
|
|
57
|
+
|
|
58
|
+
Ensure the country selector and number field are reachable and operable via keyboard alone.
|
|
59
|
+
<!-- END:xui-mcp-instructions:input-phone -->
|
|
4
60
|
|
|
5
61
|
## Installation
|
|
6
62
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-input-phone",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.176.0",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"test:coverage": "vitest run --coverage"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@xsolla/xui-core": "0.
|
|
17
|
-
"@xsolla/xui-primitives-core": "0.
|
|
16
|
+
"@xsolla/xui-core": "0.176.0",
|
|
17
|
+
"@xsolla/xui-primitives-core": "0.176.0",
|
|
18
18
|
"libphonenumber-js": "^1.10.56"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|