@availity/change-password 2.1.6 → 2.3.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/CHANGELOG.md +20 -0
- package/package.json +1 -1
- package/src/ChangePasswordForm.js +46 -34
- package/types/ChangePasswordForm.d.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [2.3.0](https://github.com/Availity/availity-react/compare/@availity/change-password@2.2.0...@availity/change-password@2.3.0) (2024-12-02)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **change-password:** add initialFields prop ([ac01d42](https://github.com/Availity/availity-react/commit/ac01d42f3d589d0b2f3c5be4f8e51fe35ec36b3a))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [2.2.0](https://github.com/Availity/availity-react/compare/@availity/change-password@2.1.6...@availity/change-password@2.2.0) (2024-11-27)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **change-password:** add additionalFields prop ([e8bf057](https://github.com/Availity/availity-react/commit/e8bf057826ba2bafbca732aaabcb3ffdb965c3b1))
|
|
20
|
+
* **change-password:** add showCurrentPassword prop ([1cb9088](https://github.com/Availity/availity-react/commit/1cb9088ab92658b550bc7bc4c3be440b48e74c4f))
|
|
21
|
+
* **change-password:** allow developer to use additionalFields in resource call ([ccf00bf](https://github.com/Availity/availity-react/commit/ccf00bf410780c58d59cdad00bead1cb6f0faf28))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
5
25
|
## [2.1.6](https://github.com/Availity/availity-react/compare/@availity/change-password@2.1.5...@availity/change-password@2.1.6) (2024-11-12)
|
|
6
26
|
|
|
7
27
|
### Dependency Updates
|
package/package.json
CHANGED
|
@@ -14,9 +14,11 @@ const ChangePasswordForm = ({
|
|
|
14
14
|
onHandleSubmit,
|
|
15
15
|
onError,
|
|
16
16
|
additionalButtons,
|
|
17
|
+
additionalFields,
|
|
17
18
|
header,
|
|
18
19
|
maxLength = 30,
|
|
19
20
|
currentPasswordProps,
|
|
21
|
+
showCurrentPassword = true,
|
|
20
22
|
newPasswordProps,
|
|
21
23
|
confirmNewPasswordProps,
|
|
22
24
|
}) => {
|
|
@@ -29,6 +31,7 @@ const ChangePasswordForm = ({
|
|
|
29
31
|
setSuccess,
|
|
30
32
|
resource,
|
|
31
33
|
schema,
|
|
34
|
+
initialValues,
|
|
32
35
|
currentPasswordIconRef,
|
|
33
36
|
newPasswordIconRef,
|
|
34
37
|
confirmNewPasswordIconRef,
|
|
@@ -41,11 +44,11 @@ const ChangePasswordForm = ({
|
|
|
41
44
|
setSubmitted,
|
|
42
45
|
} = useChangePasswordContext();
|
|
43
46
|
|
|
44
|
-
const handleSubmit = async ({
|
|
47
|
+
const handleSubmit = async ({ ...formFields }) => {
|
|
45
48
|
setLoading(true);
|
|
46
49
|
setSubmitted(true);
|
|
47
50
|
try {
|
|
48
|
-
const result = await resource.changePassword({
|
|
51
|
+
const result = await resource.changePassword({ ...formFields });
|
|
49
52
|
setSuccess('Your password was successfully changed');
|
|
50
53
|
if (onHandleSubmit) {
|
|
51
54
|
await onHandleSubmit({ result, setSuccess, setError });
|
|
@@ -72,7 +75,7 @@ const ChangePasswordForm = ({
|
|
|
72
75
|
return (
|
|
73
76
|
<BlockUI blocking={loading}>
|
|
74
77
|
<Form
|
|
75
|
-
initialValues={{ currentPassword: '', newPassword: '', confirmNewPassword: '' }}
|
|
78
|
+
initialValues={{ currentPassword: '', newPassword: '', confirmNewPassword: '', ...initialValues }}
|
|
76
79
|
validationSchema={schema}
|
|
77
80
|
onSubmit={handleSubmit}
|
|
78
81
|
>
|
|
@@ -86,37 +89,42 @@ const ChangePasswordForm = ({
|
|
|
86
89
|
<Alert isOpen={!!success} color="success" toggle={_onSuccessToggle}>
|
|
87
90
|
{success}
|
|
88
91
|
</Alert>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
92
|
+
|
|
93
|
+
{
|
|
94
|
+
showCurrentPassword ? (
|
|
95
|
+
<div className="password-with-icon">
|
|
96
|
+
<Field
|
|
97
|
+
name="currentPassword"
|
|
98
|
+
data-testid="current-password-input"
|
|
99
|
+
label="Current Password"
|
|
100
|
+
maxLength={maxLength}
|
|
101
|
+
placeholder="Input your current password"
|
|
102
|
+
type={currentPasswordVisible ? 'text' : 'password'}
|
|
103
|
+
{...currentPasswordProps}
|
|
104
|
+
/>
|
|
105
|
+
<Icon
|
|
106
|
+
name={`eye${currentPasswordVisible ? '' : '-off'}`}
|
|
107
|
+
data-testid="current-password-icon"
|
|
108
|
+
id="current-password-eye"
|
|
109
|
+
role="button"
|
|
110
|
+
label="password-visibility"
|
|
111
|
+
onMouseDown={(e) => {
|
|
112
|
+
currentPasswordIconRef?.current?.focus();
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
setCurrentPasswordVisible(!currentPasswordVisible);
|
|
115
|
+
}}
|
|
116
|
+
onKeyDown={(e) => {
|
|
117
|
+
if (e.keyCode === 13 || e.keyCode === 32) {
|
|
118
|
+
setCurrentPasswordVisible(!currentPasswordVisible);
|
|
119
|
+
}
|
|
120
|
+
}}
|
|
121
|
+
tabIndex={0}
|
|
122
|
+
aria-label={currentPasswordVisible ? 'Hide Password' : 'Show Password'}
|
|
123
|
+
ref={currentPasswordIconRef}
|
|
124
|
+
/>
|
|
125
|
+
</div>
|
|
126
|
+
) : null
|
|
127
|
+
}
|
|
120
128
|
|
|
121
129
|
<div className="password-with-icon">
|
|
122
130
|
<Field
|
|
@@ -183,6 +191,7 @@ const ChangePasswordForm = ({
|
|
|
183
191
|
ref={confirmNewPasswordIconRef}
|
|
184
192
|
/>
|
|
185
193
|
</div>
|
|
194
|
+
{additionalFields}
|
|
186
195
|
</Col>
|
|
187
196
|
<Col>
|
|
188
197
|
<ChangePasswordFeedback />
|
|
@@ -208,11 +217,14 @@ ChangePasswordForm.propTypes = {
|
|
|
208
217
|
onHandleSubmit: PropTypes.func,
|
|
209
218
|
onError: PropTypes.func,
|
|
210
219
|
additionalButtons: PropTypes.node,
|
|
220
|
+
additionalFields: PropTypes.node,
|
|
211
221
|
header: PropTypes.node,
|
|
212
222
|
maxLength: PropTypes.number,
|
|
213
223
|
currentPasswordProps: PropTypes.object,
|
|
224
|
+
showCurrentPassword: PropTypes.bool,
|
|
214
225
|
newPasswordProps: PropTypes.object,
|
|
215
226
|
confirmNewPasswordProps: PropTypes.object,
|
|
227
|
+
initialValues: PropTypes.object,
|
|
216
228
|
};
|
|
217
229
|
|
|
218
230
|
export default ChangePasswordForm;
|
|
@@ -2,9 +2,12 @@ export interface ChangePasswordFormProps {
|
|
|
2
2
|
onHandleSubmit?: (arg: { result: any }) => void;
|
|
3
3
|
onError?: (arg: { error: Error }) => void;
|
|
4
4
|
additionalButtons?: React.ReactNode;
|
|
5
|
+
additionalFields?: React.ReactNode;
|
|
5
6
|
header?: React.ReactNode;
|
|
7
|
+
initialFields?: any;
|
|
6
8
|
maxLength?: number;
|
|
7
9
|
currentPasswordProps?: any;
|
|
10
|
+
showCurrentPassword?: boolean;
|
|
8
11
|
newPasswordProps?: any;
|
|
9
12
|
confirmNewPasswordProps?: any;
|
|
10
13
|
}
|