@delightui/components 0.1.104 → 0.1.106
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 +104 -1
- package/dist/cjs/components/molecules/Modal/DemoModal.d.ts +8 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/ModalContext.d.ts +41 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/ModalContext.types.d.ts +87 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/index.d.ts +3 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/useModal.d.ts +34 -0
- package/dist/cjs/components/molecules/Modal/index.d.ts +2 -0
- package/dist/cjs/components/molecules/Popover/Popover.presenter.d.ts +26 -0
- package/dist/cjs/components/molecules/Select/Option/Option.types.d.ts +6 -0
- package/dist/cjs/components/molecules/Select/Select.Context.d.ts +1 -1
- package/dist/cjs/components/molecules/Select/Select.d.ts +5 -5
- package/dist/cjs/components/molecules/Select/Select.presenter.d.ts +1 -0
- package/dist/cjs/components/molecules/Select/Select.types.d.ts +5 -0
- package/dist/cjs/components/molecules/Select/index.d.ts +2 -9
- package/dist/cjs/components/molecules/index.d.ts +2 -0
- package/dist/cjs/components/utils/accessibilityUtils.d.ts +41 -0
- package/dist/cjs/components/utils/index.d.ts +2 -0
- package/dist/cjs/library.css +13 -0
- package/dist/cjs/library.js +2 -2
- package/dist/cjs/library.js.map +1 -1
- package/dist/esm/components/molecules/Modal/DemoModal.d.ts +8 -0
- package/dist/esm/components/molecules/Modal/ModalContext/ModalContext.d.ts +41 -0
- package/dist/esm/components/molecules/Modal/ModalContext/ModalContext.types.d.ts +87 -0
- package/dist/esm/components/molecules/Modal/ModalContext/index.d.ts +3 -0
- package/dist/esm/components/molecules/Modal/ModalContext/useModal.d.ts +34 -0
- package/dist/esm/components/molecules/Modal/index.d.ts +2 -0
- package/dist/esm/components/molecules/Popover/Popover.presenter.d.ts +26 -0
- package/dist/esm/components/molecules/Select/Option/Option.types.d.ts +6 -0
- package/dist/esm/components/molecules/Select/Select.Context.d.ts +1 -1
- package/dist/esm/components/molecules/Select/Select.d.ts +5 -5
- package/dist/esm/components/molecules/Select/Select.presenter.d.ts +1 -0
- package/dist/esm/components/molecules/Select/Select.types.d.ts +5 -0
- package/dist/esm/components/molecules/Select/index.d.ts +2 -9
- package/dist/esm/components/molecules/index.d.ts +2 -0
- package/dist/esm/components/utils/accessibilityUtils.d.ts +41 -0
- package/dist/esm/components/utils/index.d.ts +2 -0
- package/dist/esm/library.css +13 -0
- package/dist/esm/library.js +3 -3
- package/dist/esm/library.js.map +1 -1
- package/dist/index.d.ts +156 -12
- package/docs/README.md +264 -0
- package/docs/components/atoms/ActionImage.md +119 -0
- package/docs/components/atoms/Button.md +197 -0
- package/docs/components/atoms/Checkbox.md +299 -0
- package/docs/components/atoms/CheckboxItem.md +314 -0
- package/docs/components/atoms/Chip.md +380 -0
- package/docs/components/atoms/CustomToggle.md +270 -0
- package/docs/components/atoms/Icon.md +365 -0
- package/docs/components/atoms/IconButton.md +407 -0
- package/docs/components/atoms/Image.md +448 -0
- package/docs/components/atoms/Input.md +430 -0
- package/docs/components/atoms/ListItem.md +502 -0
- package/docs/components/atoms/Password.md +472 -0
- package/docs/components/atoms/RadioButton.md +614 -0
- package/docs/components/atoms/RadioButtonItem.md +588 -0
- package/docs/components/atoms/ResponsiveComponent.md +612 -0
- package/docs/components/atoms/SelectListItem.md +609 -0
- package/docs/components/atoms/Slider.md +605 -0
- package/docs/components/atoms/Spinner.md +605 -0
- package/docs/components/atoms/Text.md +463 -0
- package/docs/components/atoms/TextArea.md +670 -0
- package/docs/components/atoms/ToastNotification.md +668 -0
- package/docs/components/atoms/Toggle.md +737 -0
- package/docs/components/atoms/ToggleButton.md +751 -0
- package/docs/components/atoms/Tooltip.md +391 -0
- package/docs/components/molecules/Accordion.md +440 -0
- package/docs/components/molecules/AccordionGroup.md +547 -0
- package/docs/components/molecules/ActionCard.md +546 -0
- package/docs/components/molecules/Breadcrumb.md +403 -0
- package/docs/components/molecules/Breadcrumbs.md +485 -0
- package/docs/components/molecules/ButtonGroup.md +383 -0
- package/docs/components/molecules/Card.md +298 -0
- package/docs/components/molecules/ChipInput.md +646 -0
- package/docs/components/molecules/ContextMenu.md +768 -0
- package/docs/components/molecules/CustomTimeSelector.md +116 -0
- package/docs/components/molecules/DatePicker.md +516 -0
- package/docs/components/molecules/DateTimeSelector.md +166 -0
- package/docs/components/molecules/FormField.md +312 -0
- package/docs/components/molecules/Grid.md +577 -0
- package/docs/components/molecules/GridItem.md +834 -0
- package/docs/components/molecules/GridList.md +244 -0
- package/docs/components/molecules/List.md +485 -0
- package/docs/components/molecules/Modal.md +470 -0
- package/docs/components/molecules/ModalFooter.md +702 -0
- package/docs/components/molecules/ModalHeader.md +756 -0
- package/docs/components/molecules/ModalProvider.md +205 -0
- package/docs/components/molecules/Nav.md +530 -0
- package/docs/components/molecules/NavItem.md +572 -0
- package/docs/components/molecules/NavLink.md +499 -0
- package/docs/components/molecules/Option.md +521 -0
- package/docs/components/molecules/Pagination.md +592 -0
- package/docs/components/molecules/PaginationNumberField.md +722 -0
- package/docs/components/molecules/Popover.md +516 -0
- package/docs/components/molecules/ProgressBar.md +624 -0
- package/docs/components/molecules/RadioGroup.md +831 -0
- package/docs/components/molecules/RepeaterList.md +185 -0
- package/docs/components/molecules/Select.md +402 -0
- package/docs/components/molecules/SortableTrigger.md +82 -0
- package/docs/components/molecules/useModal.md +379 -0
- package/docs/components/organisms/Dropzone.md +346 -0
- package/docs/components/organisms/DropzoneClear.md +135 -0
- package/docs/components/organisms/DropzoneContent.md +216 -0
- package/docs/components/organisms/DropzoneFilename.md +191 -0
- package/docs/components/organisms/DropzoneSupportedFormats.md +184 -0
- package/docs/components/organisms/DropzoneTrigger.md +209 -0
- package/docs/components/organisms/Form.md +533 -0
- package/docs/components/organisms/SlideOutPanel.md +662 -0
- package/docs/components/organisms/TabContent.md +902 -0
- package/docs/components/organisms/TabItem.md +1091 -0
- package/docs/components/organisms/Table.md +611 -0
- package/docs/components/organisms/TableBody.md +679 -0
- package/docs/components/organisms/TableCell.md +482 -0
- package/docs/components/organisms/TableHeader.md +513 -0
- package/docs/components/organisms/TableHeaderCell.md +661 -0
- package/docs/components/organisms/TableRow.md +715 -0
- package/docs/components/organisms/Tabs.md +1330 -0
- package/docs/components/utils/ConditionalView.md +568 -0
- package/docs/components/utils/RenderStateView.md +726 -0
- package/docs/components/utils/WrapTextNodes.md +614 -0
- package/package.json +3 -2
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
# Password
|
|
2
|
+
|
|
3
|
+
A specialized input component designed specifically for password entry. It extends the Input component with built-in password visibility toggle functionality, providing a secure and user-friendly way to handle password inputs. The component automatically includes a show/hide password toggle icon unless explicitly disabled.
|
|
4
|
+
|
|
5
|
+
## Aliases
|
|
6
|
+
|
|
7
|
+
- Password
|
|
8
|
+
- PasswordInput
|
|
9
|
+
- SecureInput
|
|
10
|
+
|
|
11
|
+
## Props Breakdown
|
|
12
|
+
|
|
13
|
+
**Extends:** `InputHTMLAttributes<HTMLInputElement>` (via InputProps, excluding `inputType`, `trailingIcon`) + `ControlledFormComponentProps<string>`
|
|
14
|
+
|
|
15
|
+
| Prop | Type | Default | Required | Description |
|
|
16
|
+
|------|------|---------|----------|-------------|
|
|
17
|
+
| `hideTrailingIcon` | `boolean` | `false` | No | Whether to hide the password visibility toggle icon |
|
|
18
|
+
| `leadingIcon` | `ReactNode` | `undefined` | No | Icon to be displayed before the input |
|
|
19
|
+
| `component-variant` | `string` | `undefined` | No | Override styling variant |
|
|
20
|
+
| `initialValue` | `string` | `undefined` | No | The initial value for the field |
|
|
21
|
+
| `checked` | `boolean` | `undefined` | No | The initial value for the field |
|
|
22
|
+
| `value` | `string` | `undefined` | No | The current value of the form field |
|
|
23
|
+
| `onValueChange` | `(value: string) => void` | `undefined` | No | Callback function that is called when the field value changes |
|
|
24
|
+
| `disabled` | `boolean` | `false` | No | Whether the form field is disabled and cannot be interacted with |
|
|
25
|
+
| `required` | `boolean` | `false` | No | Whether the form field must have a value |
|
|
26
|
+
| `invalid` | `boolean` | `false` | No | Whether the form field's current value is invalid |
|
|
27
|
+
| `id` | `string` | `undefined` | No | Id for the form field |
|
|
28
|
+
| `placeholder` | `string` | `undefined` | No | Placeholder text for the input |
|
|
29
|
+
| `maxLength` | `number` | `undefined` | No | Maximum length of the input value |
|
|
30
|
+
| `minLength` | `number` | `undefined` | No | Minimum length of the input value |
|
|
31
|
+
| `readOnly` | `boolean` | `false` | No | Whether the input is read-only |
|
|
32
|
+
| `autoComplete` | `string` | `undefined` | No | Autocomplete attribute for the input |
|
|
33
|
+
| `autoFocus` | `boolean` | `false` | No | Whether the input should be focused on mount |
|
|
34
|
+
|
|
35
|
+
Plus all standard HTML input attributes (name, onChange, onFocus, onBlur, etc.).
|
|
36
|
+
|
|
37
|
+
## Examples
|
|
38
|
+
|
|
39
|
+
### Basic Password Input
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { Password } from '@delightui/components';
|
|
43
|
+
|
|
44
|
+
function BasicPasswordExample() {
|
|
45
|
+
const [password, setPassword] = useState('');
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Password
|
|
49
|
+
value={password}
|
|
50
|
+
onValueChange={setPassword}
|
|
51
|
+
placeholder="Enter your password"
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Form Integration
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { Form, FormField, Password, Button } from '@delightui/components';
|
|
61
|
+
|
|
62
|
+
function PasswordFormExample() {
|
|
63
|
+
const handleSubmit = (data: any) => {
|
|
64
|
+
console.log('Form submitted:', data);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<Form onSubmit={handleSubmit}>
|
|
69
|
+
<FormField
|
|
70
|
+
name="password"
|
|
71
|
+
label="Password"
|
|
72
|
+
required
|
|
73
|
+
>
|
|
74
|
+
<Password
|
|
75
|
+
placeholder="Enter your password"
|
|
76
|
+
autoComplete="current-password"
|
|
77
|
+
/>
|
|
78
|
+
</FormField>
|
|
79
|
+
|
|
80
|
+
<Button type="submit">
|
|
81
|
+
Sign In
|
|
82
|
+
</Button>
|
|
83
|
+
</Form>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Password with Leading Icon
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import { Password, Icon } from '@delightui/components';
|
|
92
|
+
|
|
93
|
+
function PasswordWithIconExample() {
|
|
94
|
+
const [password, setPassword] = useState('');
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<Password
|
|
98
|
+
value={password}
|
|
99
|
+
onValueChange={setPassword}
|
|
100
|
+
placeholder="Enter your password"
|
|
101
|
+
leadingIcon={<Icon name="InfoFilled" />}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Password without Toggle Icon
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
import { Password } from '@delightui/components';
|
|
111
|
+
|
|
112
|
+
function PasswordWithoutToggleExample() {
|
|
113
|
+
const [password, setPassword] = useState('');
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<Password
|
|
117
|
+
value={password}
|
|
118
|
+
onValueChange={setPassword}
|
|
119
|
+
placeholder="Enter your password"
|
|
120
|
+
hideTrailingIcon={true}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Registration Form with Password Confirmation
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
import { Form, FormField, Password, Button, Text } from '@delightui/components';
|
|
130
|
+
|
|
131
|
+
function RegistrationFormExample() {
|
|
132
|
+
const [formData, setFormData] = useState({
|
|
133
|
+
password: '',
|
|
134
|
+
confirmPassword: ''
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const [passwordMatch, setPasswordMatch] = useState(true);
|
|
138
|
+
|
|
139
|
+
const handlePasswordChange = (value: string) => {
|
|
140
|
+
setFormData(prev => ({ ...prev, password: value }));
|
|
141
|
+
setPasswordMatch(value === formData.confirmPassword || formData.confirmPassword === '');
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const handleConfirmPasswordChange = (value: string) => {
|
|
145
|
+
setFormData(prev => ({ ...prev, confirmPassword: value }));
|
|
146
|
+
setPasswordMatch(formData.password === value || value === '');
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const handleSubmit = (data: any) => {
|
|
150
|
+
if (passwordMatch) {
|
|
151
|
+
console.log('Registration data:', data);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<Form onSubmit={handleSubmit}>
|
|
157
|
+
<FormField
|
|
158
|
+
name="password"
|
|
159
|
+
label="Password"
|
|
160
|
+
required
|
|
161
|
+
message="Password must be at least 8 characters long"
|
|
162
|
+
>
|
|
163
|
+
<Password
|
|
164
|
+
value={formData.password}
|
|
165
|
+
onValueChange={handlePasswordChange}
|
|
166
|
+
placeholder="Enter your password"
|
|
167
|
+
minLength={8}
|
|
168
|
+
autoComplete="new-password"
|
|
169
|
+
/>
|
|
170
|
+
</FormField>
|
|
171
|
+
|
|
172
|
+
<FormField
|
|
173
|
+
name="confirmPassword"
|
|
174
|
+
label="Confirm Password"
|
|
175
|
+
required
|
|
176
|
+
invalid={!passwordMatch}
|
|
177
|
+
message={!passwordMatch ? "Passwords do not match" : undefined}
|
|
178
|
+
>
|
|
179
|
+
<Password
|
|
180
|
+
value={formData.confirmPassword}
|
|
181
|
+
onValueChange={handleConfirmPasswordChange}
|
|
182
|
+
placeholder="Confirm your password"
|
|
183
|
+
invalid={!passwordMatch}
|
|
184
|
+
autoComplete="new-password"
|
|
185
|
+
/>
|
|
186
|
+
</FormField>
|
|
187
|
+
|
|
188
|
+
{!passwordMatch && (
|
|
189
|
+
<Text color="error" size="small">
|
|
190
|
+
Passwords must match
|
|
191
|
+
</Text>
|
|
192
|
+
)}
|
|
193
|
+
|
|
194
|
+
<Button
|
|
195
|
+
type="submit"
|
|
196
|
+
disabled={!passwordMatch || !formData.password || !formData.confirmPassword}
|
|
197
|
+
>
|
|
198
|
+
Create Account
|
|
199
|
+
</Button>
|
|
200
|
+
</Form>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Password Strength Indicator
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
import { Password, Text } from '@delightui/components';
|
|
209
|
+
|
|
210
|
+
function PasswordStrengthExample() {
|
|
211
|
+
const [password, setPassword] = useState('');
|
|
212
|
+
const [strength, setStrength] = useState({ score: 0, text: 'Weak', color: 'error' });
|
|
213
|
+
|
|
214
|
+
const evaluatePasswordStrength = (pwd: string) => {
|
|
215
|
+
let score = 0;
|
|
216
|
+
|
|
217
|
+
if (pwd.length >= 8) score++;
|
|
218
|
+
if (/[a-z]/.test(pwd)) score++;
|
|
219
|
+
if (/[A-Z]/.test(pwd)) score++;
|
|
220
|
+
if (/[0-9]/.test(pwd)) score++;
|
|
221
|
+
if (/[^A-Za-z0-9]/.test(pwd)) score++;
|
|
222
|
+
|
|
223
|
+
const strength = {
|
|
224
|
+
0: { text: 'Very Weak', color: 'error' },
|
|
225
|
+
1: { text: 'Weak', color: 'error' },
|
|
226
|
+
2: { text: 'Fair', color: 'warning' },
|
|
227
|
+
3: { text: 'Good', color: 'info' },
|
|
228
|
+
4: { text: 'Strong', color: 'success' },
|
|
229
|
+
5: { text: 'Very Strong', color: 'success' }
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
return { score, ...strength[score as keyof typeof strength] };
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const handlePasswordChange = (value: string) => {
|
|
236
|
+
setPassword(value);
|
|
237
|
+
setStrength(evaluatePasswordStrength(value));
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
<div>
|
|
242
|
+
<Password
|
|
243
|
+
value={password}
|
|
244
|
+
onValueChange={handlePasswordChange}
|
|
245
|
+
placeholder="Enter a strong password"
|
|
246
|
+
/>
|
|
247
|
+
|
|
248
|
+
{password && (
|
|
249
|
+
<div style={{ marginTop: '8px' }}>
|
|
250
|
+
<div style={{
|
|
251
|
+
height: '4px',
|
|
252
|
+
backgroundColor: '#e0e0e0',
|
|
253
|
+
borderRadius: '2px',
|
|
254
|
+
overflow: 'hidden'
|
|
255
|
+
}}>
|
|
256
|
+
<div
|
|
257
|
+
style={{
|
|
258
|
+
height: '100%',
|
|
259
|
+
width: `${(strength.score / 5) * 100}%`,
|
|
260
|
+
backgroundColor:
|
|
261
|
+
strength.color === 'error' ? '#dc3545' :
|
|
262
|
+
strength.color === 'warning' ? '#ffc107' :
|
|
263
|
+
strength.color === 'info' ? '#17a2b8' :
|
|
264
|
+
'#28a745',
|
|
265
|
+
transition: 'all 0.3s ease'
|
|
266
|
+
}}
|
|
267
|
+
/>
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
<Text size="small" color={strength.color} style={{ marginTop: '4px' }}>
|
|
271
|
+
Password Strength: {strength.text}
|
|
272
|
+
</Text>
|
|
273
|
+
</div>
|
|
274
|
+
)}
|
|
275
|
+
</div>
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Disabled Password Input
|
|
281
|
+
|
|
282
|
+
```tsx
|
|
283
|
+
import { Password } from '@delightui/components';
|
|
284
|
+
|
|
285
|
+
function DisabledPasswordExample() {
|
|
286
|
+
return (
|
|
287
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
|
|
288
|
+
<Password
|
|
289
|
+
value="example-password"
|
|
290
|
+
disabled
|
|
291
|
+
placeholder="This field is disabled"
|
|
292
|
+
/>
|
|
293
|
+
|
|
294
|
+
<Password
|
|
295
|
+
value=""
|
|
296
|
+
disabled
|
|
297
|
+
placeholder="Empty disabled field"
|
|
298
|
+
/>
|
|
299
|
+
</div>
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Read-Only Password Display
|
|
305
|
+
|
|
306
|
+
```tsx
|
|
307
|
+
import { Password } from '@delightui/components';
|
|
308
|
+
|
|
309
|
+
function ReadOnlyPasswordExample() {
|
|
310
|
+
return (
|
|
311
|
+
<Password
|
|
312
|
+
value="hidden-password-value"
|
|
313
|
+
readOnly
|
|
314
|
+
placeholder="Read-only password"
|
|
315
|
+
/>
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Login Form Example
|
|
321
|
+
|
|
322
|
+
```tsx
|
|
323
|
+
import { Form, FormField, Input, Password, Button, Text } from '@delightui/components';
|
|
324
|
+
|
|
325
|
+
function LoginFormExample() {
|
|
326
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
327
|
+
const [error, setError] = useState('');
|
|
328
|
+
|
|
329
|
+
const handleSubmit = async (data: any) => {
|
|
330
|
+
setIsLoading(true);
|
|
331
|
+
setError('');
|
|
332
|
+
|
|
333
|
+
try {
|
|
334
|
+
// Simulate API call
|
|
335
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
336
|
+
console.log('Login successful:', data);
|
|
337
|
+
} catch (err) {
|
|
338
|
+
setError('Invalid username or password');
|
|
339
|
+
} finally {
|
|
340
|
+
setIsLoading(false);
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
return (
|
|
345
|
+
<Form onSubmit={handleSubmit}>
|
|
346
|
+
<FormField
|
|
347
|
+
name="username"
|
|
348
|
+
label="Username"
|
|
349
|
+
required
|
|
350
|
+
>
|
|
351
|
+
<Input
|
|
352
|
+
placeholder="Enter your username"
|
|
353
|
+
autoComplete="username"
|
|
354
|
+
/>
|
|
355
|
+
</FormField>
|
|
356
|
+
|
|
357
|
+
<FormField
|
|
358
|
+
name="password"
|
|
359
|
+
label="Password"
|
|
360
|
+
required
|
|
361
|
+
>
|
|
362
|
+
<Password
|
|
363
|
+
placeholder="Enter your password"
|
|
364
|
+
autoComplete="current-password"
|
|
365
|
+
/>
|
|
366
|
+
</FormField>
|
|
367
|
+
|
|
368
|
+
{error && (
|
|
369
|
+
<Text color="error" size="small">
|
|
370
|
+
{error}
|
|
371
|
+
</Text>
|
|
372
|
+
)}
|
|
373
|
+
|
|
374
|
+
<Button
|
|
375
|
+
type="submit"
|
|
376
|
+
loading={isLoading}
|
|
377
|
+
style={{ width: '100%' }}
|
|
378
|
+
>
|
|
379
|
+
{isLoading ? 'Signing In...' : 'Sign In'}
|
|
380
|
+
</Button>
|
|
381
|
+
</Form>
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Password Change Form
|
|
387
|
+
|
|
388
|
+
```tsx
|
|
389
|
+
import { Form, FormField, Password, Button } from '@delightui/components';
|
|
390
|
+
|
|
391
|
+
function PasswordChangeExample() {
|
|
392
|
+
const handleSubmit = (data: any) => {
|
|
393
|
+
console.log('Password change data:', data);
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
return (
|
|
397
|
+
<Form onSubmit={handleSubmit}>
|
|
398
|
+
<FormField
|
|
399
|
+
name="currentPassword"
|
|
400
|
+
label="Current Password"
|
|
401
|
+
required
|
|
402
|
+
>
|
|
403
|
+
<Password
|
|
404
|
+
placeholder="Enter your current password"
|
|
405
|
+
autoComplete="current-password"
|
|
406
|
+
/>
|
|
407
|
+
</FormField>
|
|
408
|
+
|
|
409
|
+
<FormField
|
|
410
|
+
name="newPassword"
|
|
411
|
+
label="New Password"
|
|
412
|
+
required
|
|
413
|
+
message="Must be at least 8 characters with uppercase, lowercase, and numbers"
|
|
414
|
+
>
|
|
415
|
+
<Password
|
|
416
|
+
placeholder="Enter your new password"
|
|
417
|
+
minLength={8}
|
|
418
|
+
autoComplete="new-password"
|
|
419
|
+
/>
|
|
420
|
+
</FormField>
|
|
421
|
+
|
|
422
|
+
<FormField
|
|
423
|
+
name="confirmNewPassword"
|
|
424
|
+
label="Confirm New Password"
|
|
425
|
+
required
|
|
426
|
+
>
|
|
427
|
+
<Password
|
|
428
|
+
placeholder="Confirm your new password"
|
|
429
|
+
autoComplete="new-password"
|
|
430
|
+
/>
|
|
431
|
+
</FormField>
|
|
432
|
+
|
|
433
|
+
<Button type="submit">
|
|
434
|
+
Change Password
|
|
435
|
+
</Button>
|
|
436
|
+
</Form>
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
### Custom Styled Password
|
|
442
|
+
|
|
443
|
+
```tsx
|
|
444
|
+
import { Password } from '@delightui/components';
|
|
445
|
+
|
|
446
|
+
function CustomStyledPasswordExample() {
|
|
447
|
+
const [password, setPassword] = useState('');
|
|
448
|
+
|
|
449
|
+
return (
|
|
450
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
|
|
451
|
+
<Password
|
|
452
|
+
value={password}
|
|
453
|
+
onValueChange={setPassword}
|
|
454
|
+
placeholder="Custom styled password"
|
|
455
|
+
component-variant="custom-password"
|
|
456
|
+
style={{
|
|
457
|
+
border: '2px solid #007bff',
|
|
458
|
+
borderRadius: '8px',
|
|
459
|
+
padding: '12px'
|
|
460
|
+
}}
|
|
461
|
+
/>
|
|
462
|
+
|
|
463
|
+
<Password
|
|
464
|
+
value={password}
|
|
465
|
+
onValueChange={setPassword}
|
|
466
|
+
placeholder="Another custom style"
|
|
467
|
+
className="custom-password-class"
|
|
468
|
+
/>
|
|
469
|
+
</div>
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
```
|