@xsolla/xui-input-phone 0.148.0 → 0.148.2

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.
Files changed (2) hide show
  1. package/README.md +212 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,212 @@
1
+ # Input Phone
2
+
3
+ A cross-platform React phone number input component with integrated country selector. Features a searchable country dropdown with flags and dial codes.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @xsolla/xui-input-phone
9
+ # or
10
+ yarn add @xsolla/xui-input-phone
11
+ ```
12
+
13
+ ## Demo
14
+
15
+ ### Basic Phone Input
16
+
17
+ ```tsx
18
+ import * as React from 'react';
19
+ import { InputPhone } from '@xsolla/xui-input-phone';
20
+
21
+ export default function BasicPhoneInput() {
22
+ const [phone, setPhone] = React.useState('');
23
+
24
+ return (
25
+ <InputPhone
26
+ value={phone}
27
+ onChange={(e) => setPhone(e.target.value)}
28
+ placeholder="+1 (000) 000-0000"
29
+ />
30
+ );
31
+ }
32
+ ```
33
+
34
+ ### With Country Selection
35
+
36
+ ```tsx
37
+ import * as React from 'react';
38
+ import { InputPhone, Country } from '@xsolla/xui-input-phone';
39
+
40
+ export default function CountryPhoneInput() {
41
+ const [phone, setPhone] = React.useState('');
42
+ const [country, setCountry] = React.useState<Country | undefined>();
43
+
44
+ return (
45
+ <InputPhone
46
+ value={phone}
47
+ onChange={(e) => setPhone(e.target.value)}
48
+ selectedCountry={country}
49
+ onCountryChange={setCountry}
50
+ />
51
+ );
52
+ }
53
+ ```
54
+
55
+ ### With Validation
56
+
57
+ ```tsx
58
+ import * as React from 'react';
59
+ import { InputPhone } from '@xsolla/xui-input-phone';
60
+
61
+ export default function ValidatedPhoneInput() {
62
+ const [phone, setPhone] = React.useState('');
63
+ const isValid = phone.length >= 10;
64
+
65
+ return (
66
+ <InputPhone
67
+ value={phone}
68
+ onChange={(e) => setPhone(e.target.value)}
69
+ checked={isValid}
70
+ extraClear={true}
71
+ onRemove={() => setPhone('')}
72
+ />
73
+ );
74
+ }
75
+ ```
76
+
77
+ ## Anatomy
78
+
79
+ ```jsx
80
+ import { InputPhone } from '@xsolla/xui-input-phone';
81
+
82
+ <InputPhone
83
+ value={phoneNumber} // Phone number value
84
+ onChange={handleChange} // Change event handler
85
+ selectedCountry={country} // Currently selected country
86
+ onCountryChange={setCountry} // Country selection handler
87
+ countries={customCountries} // Custom countries array
88
+ placeholder="+1 (000) 000-0000" // Placeholder text
89
+ size="md" // Size variant
90
+ disabled={false} // Disabled state
91
+ error={false} // Error state
92
+ errorMessage="Error" // Error message
93
+ extraClear={false} // Show clear button
94
+ onRemove={handleClear} // Clear button handler
95
+ checked={false} // Show validation checkmark
96
+ />
97
+ ```
98
+
99
+ ## Examples
100
+
101
+ ### Error State
102
+
103
+ ```tsx
104
+ import * as React from 'react';
105
+ import { InputPhone } from '@xsolla/xui-input-phone';
106
+
107
+ export default function ErrorPhoneInput() {
108
+ return (
109
+ <InputPhone
110
+ value="123"
111
+ error={true}
112
+ errorMessage="Please enter a valid phone number"
113
+ />
114
+ );
115
+ }
116
+ ```
117
+
118
+ ### Phone Input Sizes
119
+
120
+ ```tsx
121
+ import * as React from 'react';
122
+ import { InputPhone } from '@xsolla/xui-input-phone';
123
+
124
+ export default function PhoneInputSizes() {
125
+ return (
126
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
127
+ <InputPhone size="xs" placeholder="Extra Small" />
128
+ <InputPhone size="sm" placeholder="Small" />
129
+ <InputPhone size="md" placeholder="Medium" />
130
+ <InputPhone size="lg" placeholder="Large" />
131
+ <InputPhone size="xl" placeholder="Extra Large" />
132
+ </div>
133
+ );
134
+ }
135
+ ```
136
+
137
+ ### Custom Countries
138
+
139
+ ```tsx
140
+ import * as React from 'react';
141
+ import { InputPhone, Country } from '@xsolla/xui-input-phone';
142
+
143
+ export default function CustomCountriesPhone() {
144
+ const [phone, setPhone] = React.useState('');
145
+
146
+ const countries: Country[] = [
147
+ { code: 'US', name: 'United States', dialCode: '+1' },
148
+ { code: 'GB', name: 'United Kingdom', dialCode: '+44' },
149
+ { code: 'DE', name: 'Germany', dialCode: '+49' },
150
+ ];
151
+
152
+ return (
153
+ <InputPhone
154
+ value={phone}
155
+ onChange={(e) => setPhone(e.target.value)}
156
+ countries={countries}
157
+ />
158
+ );
159
+ }
160
+ ```
161
+
162
+ ## API Reference
163
+
164
+ ### InputPhone
165
+
166
+ **InputPhone Props:**
167
+
168
+ | Prop | Type | Default | Description |
169
+ | :--- | :--- | :------ | :---------- |
170
+ | value | `string` | - | Phone number value. |
171
+ | onChange | `(e: ChangeEvent) => void` | - | Change event handler. |
172
+ | onChangeText | `(text: string) => void` | - | Text change handler. |
173
+ | countries | `Country[]` | All countries | Available countries for selection. |
174
+ | selectedCountry | `Country` | - | Currently selected country. |
175
+ | onCountryChange | `(country: Country) => void` | - | Country selection handler. |
176
+ | placeholder | `string` | `"+1 (000) 000-0000"` | Placeholder text. |
177
+ | size | `"xl" \| "lg" \| "md" \| "sm" \| "xs"` | `"md"` | Component size. |
178
+ | disabled | `boolean` | `false` | Disabled state. |
179
+ | error | `boolean` | `false` | Error state. |
180
+ | errorMessage | `string` | - | Error message text. |
181
+ | extraClear | `boolean` | `false` | Show clear button. |
182
+ | onRemove | `() => void` | - | Clear button handler. |
183
+ | checked | `boolean` | `false` | Show validation checkmark. |
184
+ | checkedIcon | `ReactNode` | Check icon | Custom checkmark icon. |
185
+ | testID | `string` | - | Test identifier. |
186
+
187
+ **Country Interface:**
188
+
189
+ ```typescript
190
+ interface Country {
191
+ code: string; // ISO 3166-1 alpha-2 (e.g., "US")
192
+ name: string; // Country name
193
+ dialCode: string; // International dial code (e.g., "+1")
194
+ flag?: ReactNode; // Optional flag icon
195
+ }
196
+ ```
197
+
198
+ ## Keyboard Navigation
199
+
200
+ | Key | Action |
201
+ | :-- | :----- |
202
+ | Arrow Down | Open dropdown / Next country |
203
+ | Arrow Up | Previous country |
204
+ | Enter | Select country / Open dropdown |
205
+ | Escape | Close dropdown |
206
+
207
+ ## Accessibility
208
+
209
+ - Country selector uses `role="combobox"`
210
+ - Country list uses `role="listbox"` with `role="option"` items
211
+ - Searchable dropdown with `aria-controls` linking
212
+ - Phone input uses `type="tel"` and `inputMode="tel"`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-input-phone",
3
- "version": "0.148.0",
3
+ "version": "0.148.2",
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.148.0",
17
- "@xsolla/xui-primitives-core": "0.148.0",
16
+ "@xsolla/xui-core": "0.148.2",
17
+ "@xsolla/xui-primitives-core": "0.148.2",
18
18
  "libphonenumber-js": "^1.10.56"
19
19
  },
20
20
  "peerDependencies": {