@availity/change-password 2.1.6 → 2.2.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 CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ # [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)
6
+
7
+
8
+ ### Features
9
+
10
+ * **change-password:** add additionalFields prop ([e8bf057](https://github.com/Availity/availity-react/commit/e8bf057826ba2bafbca732aaabcb3ffdb965c3b1))
11
+ * **change-password:** add showCurrentPassword prop ([1cb9088](https://github.com/Availity/availity-react/commit/1cb9088ab92658b550bc7bc4c3be440b48e74c4f))
12
+ * **change-password:** allow developer to use additionalFields in resource call ([ccf00bf](https://github.com/Availity/availity-react/commit/ccf00bf410780c58d59cdad00bead1cb6f0faf28))
13
+
14
+
15
+
5
16
  ## [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
17
 
7
18
  ### Dependency Updates
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/change-password",
3
- "version": "2.1.6",
3
+ "version": "2.2.0",
4
4
  "description": "Easy to use change-password components",
5
5
  "keywords": [
6
6
  "react",
@@ -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
  }) => {
@@ -41,11 +43,11 @@ const ChangePasswordForm = ({
41
43
  setSubmitted,
42
44
  } = useChangePasswordContext();
43
45
 
44
- const handleSubmit = async ({ currentPassword, newPassword }) => {
46
+ const handleSubmit = async ({ ...formFields }) => {
45
47
  setLoading(true);
46
48
  setSubmitted(true);
47
49
  try {
48
- const result = await resource.changePassword({ currentPassword, newPassword });
50
+ const result = await resource.changePassword({ ...formFields });
49
51
  setSuccess('Your password was successfully changed');
50
52
  if (onHandleSubmit) {
51
53
  await onHandleSubmit({ result, setSuccess, setError });
@@ -86,37 +88,42 @@ const ChangePasswordForm = ({
86
88
  <Alert isOpen={!!success} color="success" toggle={_onSuccessToggle}>
87
89
  {success}
88
90
  </Alert>
89
- <div className="password-with-icon">
90
- <Field
91
- name="currentPassword"
92
- data-testid="current-password-input"
93
- label="Current Password"
94
- maxLength={maxLength}
95
- placeholder="Input your current password"
96
- type={currentPasswordVisible ? 'text' : 'password'}
97
- {...currentPasswordProps}
98
- />
99
- <Icon
100
- name={`eye${currentPasswordVisible ? '' : '-off'}`}
101
- data-testid="current-password-icon"
102
- id="current-password-eye"
103
- role="button"
104
- label="password-visibility"
105
- onMouseDown={(e) => {
106
- currentPasswordIconRef?.current?.focus();
107
- e.preventDefault();
108
- setCurrentPasswordVisible(!currentPasswordVisible);
109
- }}
110
- onKeyDown={(e) => {
111
- if (e.keyCode === 13 || e.keyCode === 32) {
112
- setCurrentPasswordVisible(!currentPasswordVisible);
113
- }
114
- }}
115
- tabIndex={0}
116
- aria-label={currentPasswordVisible ? 'Hide Password' : 'Show Password'}
117
- ref={currentPasswordIconRef}
118
- />
119
- </div>
91
+
92
+ {
93
+ showCurrentPassword ? (
94
+ <div className="password-with-icon">
95
+ <Field
96
+ name="currentPassword"
97
+ data-testid="current-password-input"
98
+ label="Current Password"
99
+ maxLength={maxLength}
100
+ placeholder="Input your current password"
101
+ type={currentPasswordVisible ? 'text' : 'password'}
102
+ {...currentPasswordProps}
103
+ />
104
+ <Icon
105
+ name={`eye${currentPasswordVisible ? '' : '-off'}`}
106
+ data-testid="current-password-icon"
107
+ id="current-password-eye"
108
+ role="button"
109
+ label="password-visibility"
110
+ onMouseDown={(e) => {
111
+ currentPasswordIconRef?.current?.focus();
112
+ e.preventDefault();
113
+ setCurrentPasswordVisible(!currentPasswordVisible);
114
+ }}
115
+ onKeyDown={(e) => {
116
+ if (e.keyCode === 13 || e.keyCode === 32) {
117
+ setCurrentPasswordVisible(!currentPasswordVisible);
118
+ }
119
+ }}
120
+ tabIndex={0}
121
+ aria-label={currentPasswordVisible ? 'Hide Password' : 'Show Password'}
122
+ ref={currentPasswordIconRef}
123
+ />
124
+ </div>
125
+ ) : null
126
+ }
120
127
 
121
128
  <div className="password-with-icon">
122
129
  <Field
@@ -183,6 +190,7 @@ const ChangePasswordForm = ({
183
190
  ref={confirmNewPasswordIconRef}
184
191
  />
185
192
  </div>
193
+ {additionalFields}
186
194
  </Col>
187
195
  <Col>
188
196
  <ChangePasswordFeedback />
@@ -208,9 +216,11 @@ ChangePasswordForm.propTypes = {
208
216
  onHandleSubmit: PropTypes.func,
209
217
  onError: PropTypes.func,
210
218
  additionalButtons: PropTypes.node,
219
+ additionalFields: PropTypes.node,
211
220
  header: PropTypes.node,
212
221
  maxLength: PropTypes.number,
213
222
  currentPasswordProps: PropTypes.object,
223
+ showCurrentPassword: PropTypes.bool,
214
224
  newPasswordProps: PropTypes.object,
215
225
  confirmNewPasswordProps: PropTypes.object,
216
226
  };
@@ -2,9 +2,11 @@ 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;
6
7
  maxLength?: number;
7
8
  currentPasswordProps?: any;
9
+ showCurrentPassword?: boolean;
8
10
  newPasswordProps?: any;
9
11
  confirmNewPasswordProps?: any;
10
12
  }