@xsolla/xui-input-password 0.99.0 → 0.100.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.
Files changed (2) hide show
  1. package/README.md +219 -24
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,44 +1,239 @@
1
- # @xsolla/xui-input-password
1
+ ---
2
+ title: Input Password
3
+ subtitle: A password input with visibility toggle.
4
+ description: A cross-platform React password input component with show/hide toggle, validation, and clear button.
5
+ ---
2
6
 
3
- Password input with visibility toggle, clear button, and validation check support.
7
+ # Input Password
8
+
9
+ A cross-platform React password input component with visibility toggle, validation checkmark, and clear functionality.
4
10
 
5
11
  ## Installation
6
12
 
7
13
  ```bash
14
+ npm install @xsolla/xui-input-password
15
+ # or
8
16
  yarn add @xsolla/xui-input-password
9
17
  ```
10
18
 
11
- ## Usage
19
+ ## Demo
20
+
21
+ ### Basic Password Input
12
22
 
13
23
  ```tsx
24
+ import * as React from 'react';
25
+ import { InputPassword } from '@xsolla/xui-input-password';
26
+
27
+ export default function BasicPassword() {
28
+ const [password, setPassword] = React.useState('');
29
+
30
+ return (
31
+ <InputPassword
32
+ value={password}
33
+ onChange={(e) => setPassword(e.target.value)}
34
+ placeholder="Enter password"
35
+ />
36
+ );
37
+ }
38
+ ```
39
+
40
+ ### With Visibility Toggle
41
+
42
+ ```tsx
43
+ import * as React from 'react';
44
+ import { InputPassword } from '@xsolla/xui-input-password';
45
+
46
+ export default function VisibilityToggle() {
47
+ const [password, setPassword] = React.useState('');
48
+
49
+ return (
50
+ <InputPassword
51
+ value={password}
52
+ onChange={(e) => setPassword(e.target.value)}
53
+ extraSee={true}
54
+ placeholder="Enter password"
55
+ />
56
+ );
57
+ }
58
+ ```
59
+
60
+ ### With Validation
61
+
62
+ ```tsx
63
+ import * as React from 'react';
64
+ import { InputPassword } from '@xsolla/xui-input-password';
65
+
66
+ export default function PasswordValidation() {
67
+ const [password, setPassword] = React.useState('');
68
+
69
+ return (
70
+ <InputPassword
71
+ value={password}
72
+ onChange={(e) => setPassword(e.target.value)}
73
+ extraSee={true}
74
+ extraCheckup={(pass) => pass.length >= 8}
75
+ label="Password"
76
+ helperText="At least 8 characters"
77
+ placeholder="Enter password"
78
+ />
79
+ );
80
+ }
81
+ ```
82
+
83
+ ### With Error State
84
+
85
+ ```tsx
86
+ import * as React from 'react';
87
+ import { InputPassword } from '@xsolla/xui-input-password';
88
+
89
+ export default function PasswordError() {
90
+ const [password, setPassword] = React.useState('');
91
+
92
+ return (
93
+ <InputPassword
94
+ value={password}
95
+ onChange={(e) => setPassword(e.target.value)}
96
+ extraSee={true}
97
+ error={password.length > 0 && password.length < 8}
98
+ errorMessage="Password must be at least 8 characters"
99
+ label="Password"
100
+ placeholder="Enter password"
101
+ />
102
+ );
103
+ }
104
+ ```
105
+
106
+ ## Anatomy
107
+
108
+ ```jsx
14
109
  import { InputPassword } from '@xsolla/xui-input-password';
15
110
 
16
111
  <InputPassword
17
- label="Password"
18
- placeholder="Enter password"
19
- extraSee
20
- extraClear
21
- value={value}
22
- onChange={(e) => setValue(e.target.value)}
23
- errorMessage="Password is too short"
112
+ value={password} // Controlled value
113
+ onChange={handleChange} // Change handler (event)
114
+ onChangeText={handleText} // Change handler (string)
115
+ extraSee={true} // Show visibility toggle
116
+ extraClear={true} // Show clear button
117
+ extraCheckup={validateFn} // Validation function
118
+ label="Label" // Label above input
119
+ helperText="Help text" // Helper text below
120
+ error={boolean} // Error state
121
+ errorMessage="Error" // Error message
122
+ size="md" // Size variant
123
+ disabled={false} // Disabled state
24
124
  />
25
125
  ```
26
126
 
27
- ## Props
127
+ ## Examples
128
+
129
+ ### Full Featured Password
130
+
131
+ ```tsx
132
+ import * as React from 'react';
133
+ import { InputPassword } from '@xsolla/xui-input-password';
134
+
135
+ export default function FullPassword() {
136
+ const [password, setPassword] = React.useState('');
137
+ const [error, setError] = React.useState('');
138
+
139
+ const validatePassword = (pass: string) => {
140
+ if (pass.length < 8) return false;
141
+ if (!/[A-Z]/.test(pass)) return false;
142
+ if (!/[0-9]/.test(pass)) return false;
143
+ return true;
144
+ };
145
+
146
+ const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
147
+ const value = e.target.value;
148
+ setPassword(value);
149
+ if (value && !validatePassword(value)) {
150
+ setError('Password must be 8+ chars with uppercase and number');
151
+ } else {
152
+ setError('');
153
+ }
154
+ };
155
+
156
+ return (
157
+ <InputPassword
158
+ value={password}
159
+ onChange={handleChange}
160
+ extraSee={true}
161
+ extraClear={true}
162
+ extraCheckup={validatePassword}
163
+ onRemove={() => setPassword('')}
164
+ label="Password"
165
+ helperText="8+ characters, uppercase, and number required"
166
+ error={!!error}
167
+ errorMessage={error}
168
+ placeholder="Create a strong password"
169
+ />
170
+ );
171
+ }
172
+ ```
173
+
174
+ ### Password Sizes
175
+
176
+ ```tsx
177
+ import * as React from 'react';
178
+ import { InputPassword } from '@xsolla/xui-input-password';
179
+
180
+ export default function PasswordSizes() {
181
+ return (
182
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
183
+ <InputPassword size="xs" placeholder="Extra Small" extraSee />
184
+ <InputPassword size="sm" placeholder="Small" extraSee />
185
+ <InputPassword size="md" placeholder="Medium" extraSee />
186
+ <InputPassword size="lg" placeholder="Large" extraSee />
187
+ <InputPassword size="xl" placeholder="Extra Large" extraSee />
188
+ </div>
189
+ );
190
+ }
191
+ ```
192
+
193
+ ## API Reference
28
194
 
29
195
  ### InputPassword
30
196
 
197
+ **InputPassword Props:**
198
+
31
199
  | Prop | Type | Default | Description |
32
- |------|------|---------|-------------|
33
- | `value` | `string` | | Controlled value |
34
- | `placeholder` | `string` | | Placeholder text |
35
- | `onChange` | `(e: ChangeEvent) => void` | | Change handler |
36
- | `onChangeText` | `(text: string) => void` | | Alternative change handler receiving the string value |
37
- | `size` | `'xl' \| 'lg' \| 'md' \| 'sm' \| 'xs'` | `'md'` | Input size |
38
- | `disabled` | `boolean` | `false` | Disables the input |
39
- | `label` | `string` | | Label displayed above the input |
40
- | `helperText` | `string` | | Helper text below the input (hidden when `errorMessage` is set) |
41
- | `errorMessage` | `string` | | Error text displayed below; also sets invalid state |
42
- | `error` | `boolean` | | Sets invalid state without a message |
43
- | `extraSee` | `boolean` | `false` | Shows a visibility toggle button |
44
- | `extraClear` | `boolean` | `false` | Shows a clear button when the field has a value |
200
+ | :--- | :--- | :------ | :---------- |
201
+ | value | `string` | - | Controlled input value. |
202
+ | onChange | `(e: ChangeEvent) => void` | - | Change event handler. |
203
+ | onChangeText | `(text: string) => void` | - | Text change handler. |
204
+ | extraSee | `boolean` | `false` | Show visibility toggle button. |
205
+ | extraClear | `boolean` | `false` | Show clear button. |
206
+ | extraCheckup | `(pass: string) => boolean` | - | Validation function. |
207
+ | initialVisible | `boolean` | `false` | Initial password visibility. |
208
+ | size | `"xl" \| "lg" \| "md" \| "sm" \| "xs"` | `"md"` | Component size. |
209
+ | label | `string` | - | Label above input. |
210
+ | helperText | `string` | - | Helper text below input. |
211
+ | error | `boolean` | `false` | Error state. |
212
+ | errorMessage | `string` | - | Error message. |
213
+ | disabled | `boolean` | `false` | Disabled state. |
214
+ | placeholder | `string` | - | Placeholder text. |
215
+ | name | `string` | - | Input name attribute. |
216
+ | onRemove | `() => void` | - | Clear button handler. |
217
+ | aria-label | `string` | - | Accessible label. |
218
+ | testID | `string` | - | Test identifier. |
219
+
220
+ ## Behavior
221
+
222
+ - **Visibility Toggle**: The eye icon reflects the current state of the password:
223
+ - Open eye (👁️) = Password is currently **visible** (type="text")
224
+ - Closed eye (🙈) = Password is currently **hidden** (type="password")
225
+ - This follows modern design system conventions (Material, Apple, Atlassian, Polaris)
226
+ - Checkmark appears when `extraCheckup` returns true
227
+ - Clear button appears when input has value and `extraClear` is true
228
+ - Error state shows red border and error message
229
+
230
+ ## Accessibility
231
+
232
+ - Uses `type="password"` or `type="text"` based on visibility
233
+ - Visibility toggle button has appropriate `aria-label`:
234
+ - "Show password" when password is hidden
235
+ - "Hide password" when password is visible
236
+ - Toggle button uses `aria-pressed` to indicate current state
237
+ - Error messages linked via `aria-describedby` for screen reader context
238
+ - Labels properly linked via `aria-labelledby` when provided
239
+ - Error messages use `role="alert"` for immediate announcement
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-input-password",
3
- "version": "0.99.0",
3
+ "version": "0.100.0",
4
4
  "main": "./web/index.js",
5
5
  "module": "./web/index.mjs",
6
6
  "types": "./web/index.d.ts",
@@ -13,9 +13,9 @@
13
13
  "test:coverage": "vitest run --coverage"
14
14
  },
15
15
  "dependencies": {
16
- "@xsolla/xui-core": "0.99.0",
17
- "@xsolla/xui-icons": "0.99.0",
18
- "@xsolla/xui-primitives-core": "0.99.0"
16
+ "@xsolla/xui-core": "0.100.0",
17
+ "@xsolla/xui-icons": "0.100.0",
18
+ "@xsolla/xui-primitives-core": "0.100.0"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "react": ">=16.8.0",