@availity/feedback 6.0.9 → 6.0.13
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 +35 -0
- package/package.json +4 -4
- package/src/FeedbackButton.js +3 -5
- package/src/FeedbackForm.js +167 -106
- package/src/FeedbackModal.js +13 -2
- package/src/SmileField.js +24 -21
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,41 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [6.0.13](https://github.com/Availity/availity-react/compare/@availity/feedback@6.0.12...@availity/feedback@6.0.13) (2021-10-19)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @availity/feedback
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 6.0.12 (2021-10-19)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @availity/feedback
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [6.0.11](https://github.com/Availity/availity-react/compare/@availity/feedback@6.0.10...@availity/feedback@6.0.11) (2021-10-08)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @availity/feedback
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [6.0.10](https://github.com/Availity/availity-react/compare/@availity/feedback@6.0.9...@availity/feedback@6.0.10) (2021-10-06)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
|
|
35
|
+
* improve modal use case for FeedbackForm ([66dff23](https://github.com/Availity/availity-react/commit/66dff23e8b770e4143496c2d81683c46a1fc4fb4))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
6
41
|
## [6.0.9](https://github.com/Availity/availity-react/compare/@availity/feedback@6.0.8...@availity/feedback@6.0.9) (2021-10-04)
|
|
7
42
|
|
|
8
43
|
**Note:** Version bump only for package @availity/feedback
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/feedback",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.13",
|
|
4
4
|
"author": "Evan Sharp <evan.sharp@availity.com>",
|
|
5
5
|
"description": "Availity feedback with smiley faces react component.",
|
|
6
6
|
"main": "index.js",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@availity/form": "^0.7.
|
|
24
|
+
"@availity/form": "^0.7.4",
|
|
25
25
|
"@availity/hooks": "^3.0.4",
|
|
26
26
|
"@availity/icon": "^0.9.0",
|
|
27
27
|
"@availity/native-form": "^3.0.0",
|
|
28
|
-
"@availity/select": "^0.
|
|
28
|
+
"@availity/select": "^0.20.1",
|
|
29
29
|
"prop-types": "^15.7.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"reactstrap": "^8.0.0 || ^7.0.0 || ^6.0.0",
|
|
48
48
|
"yup": "^0.27.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "b3d2b222b3aeec7005548254998a8ccda95ef514"
|
|
51
51
|
}
|
package/src/FeedbackButton.js
CHANGED
|
@@ -3,12 +3,10 @@ import { PropTypes } from 'prop-types';
|
|
|
3
3
|
import { Button } from 'reactstrap';
|
|
4
4
|
import Icon from '@availity/icon';
|
|
5
5
|
|
|
6
|
-
const btnStyles = { fontSize: '1.4em', padding: '.2em .4em' };
|
|
7
|
-
const iconStyles = { margin: '0px' };
|
|
8
|
-
|
|
9
6
|
const FeedbackButton = ({ onClick, icon, active, children, iconSize, ...rest }) => (
|
|
10
7
|
<Button
|
|
11
|
-
|
|
8
|
+
block
|
|
9
|
+
className="mt-2"
|
|
12
10
|
color={active === icon ? 'primary' : 'light'}
|
|
13
11
|
aria-pressed={active === icon}
|
|
14
12
|
onClick={() => {
|
|
@@ -17,7 +15,7 @@ const FeedbackButton = ({ onClick, icon, active, children, iconSize, ...rest })
|
|
|
17
15
|
onKeyDown={({ keyCode }) => keyCode === 13 && onClick(icon)}
|
|
18
16
|
{...rest}
|
|
19
17
|
>
|
|
20
|
-
<Icon data-testid="feedback-icon" name={icon} size={iconSize}
|
|
18
|
+
<Icon data-testid="feedback-icon" name={icon} size={iconSize} className="m-0 " />
|
|
21
19
|
<span className="sr-only">{children}</span>
|
|
22
20
|
</Button>
|
|
23
21
|
);
|
package/src/FeedbackForm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
3
|
+
import { Col, Row, Button, ModalHeader, FormGroup } from 'reactstrap';
|
|
4
4
|
import { avLogMessagesApi, avRegionsApi } from '@availity/api-axios';
|
|
5
5
|
import { Form, Field } from '@availity/form';
|
|
6
6
|
import { SelectField } from '@availity/select';
|
|
@@ -21,6 +21,9 @@ yup.addMethod(yup.string, 'isRequired', function format(isRequired, msg) {
|
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
+
// const ConditionalModalHeader = ({ condition, wrapper, children }) =>
|
|
25
|
+
// condition ? wrapper(children) : children;
|
|
26
|
+
|
|
24
27
|
const fieldStyles = { resize: 'none' };
|
|
25
28
|
const inlineStyles = { display: 'inline-block', margin: 0 };
|
|
26
29
|
|
|
@@ -82,65 +85,100 @@ const FeedbackForm = ({
|
|
|
82
85
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
83
86
|
}, [sent]);
|
|
84
87
|
|
|
85
|
-
return
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
{
|
|
88
|
+
return (
|
|
89
|
+
<Form
|
|
90
|
+
aria-label="Feedback Form"
|
|
91
|
+
aria-describedby="feedback-form-header"
|
|
92
|
+
className="container p-2"
|
|
93
|
+
role="form"
|
|
94
|
+
onKeyDown={({ keyCode }) => keyCode === 27 && onClose()}
|
|
95
|
+
data-testid="feedback-form"
|
|
96
|
+
initialValues={{
|
|
97
|
+
'face-options': undefined,
|
|
98
|
+
additionalFeedback: undefined,
|
|
99
|
+
feedback: undefined,
|
|
100
|
+
feedbackApp: undefined,
|
|
101
|
+
smileField: undefined,
|
|
102
|
+
}}
|
|
103
|
+
validationSchema={yup.object().shape({
|
|
104
|
+
feedback: yup.string().max(200, 'Feedback cannot exceed 200 characters.').required('This field is required.'),
|
|
105
|
+
additionalFeedback: yup.string().max(200, 'Additional Feedback cannot exceed 200 characters.'),
|
|
106
|
+
smileField: yup
|
|
107
|
+
.object()
|
|
108
|
+
.shape({
|
|
109
|
+
icon: yup.string().required(),
|
|
110
|
+
description: yup.string(),
|
|
111
|
+
label: yup.string(),
|
|
112
|
+
})
|
|
113
|
+
.required('This field is required.'),
|
|
114
|
+
feedbackApp: yup.string().isRequired(aboutOptions.length > 0, 'This field is required.'),
|
|
115
|
+
})}
|
|
116
|
+
{...formProps}
|
|
117
|
+
onSubmit={(values) => sendFeedback(values)}
|
|
92
118
|
>
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
119
|
+
{sent ? (
|
|
120
|
+
modalHeaderProps ? (
|
|
121
|
+
// TODO Sorry for all the ternaries here. This component badly needs to be
|
|
122
|
+
// refactored. PF-2208 was to make FeedbackForm usable outside, but to maintain
|
|
123
|
+
// the use case of it being inside a modal I needed to keep modalHeaderProps
|
|
124
|
+
// in the PropTypes. Since modalHeaderProps is being used to pass an onClose
|
|
125
|
+
// handler to the modal header, I need to still conditionally render the
|
|
126
|
+
// ModalHeader and spread the props onto it. This whole set of components
|
|
127
|
+
// need to be completely reworked to enable better composition of these
|
|
128
|
+
// components
|
|
129
|
+
<ModalHeader
|
|
130
|
+
role="status"
|
|
131
|
+
id="feedback-form-header"
|
|
132
|
+
tabIndex="0"
|
|
133
|
+
className="d-flex justify-content-center"
|
|
134
|
+
{...modalHeaderProps}
|
|
135
|
+
>
|
|
136
|
+
Thank you for your feedback.
|
|
137
|
+
</ModalHeader>
|
|
138
|
+
) : modalHeaderProps ? (
|
|
139
|
+
<ModalHeader
|
|
140
|
+
id="feedback-form-header"
|
|
141
|
+
role="heading"
|
|
142
|
+
aria-level="2"
|
|
143
|
+
className="h5 mt-n2 mx-n2"
|
|
144
|
+
tag="div"
|
|
145
|
+
{...modalHeaderProps}
|
|
146
|
+
>
|
|
147
|
+
{prompt || `Tell us what you think about ${name}`}
|
|
148
|
+
</ModalHeader>
|
|
149
|
+
) : (
|
|
150
|
+
<Row>
|
|
151
|
+
<Col className="m-2 p-3">Your feedback has been sent. Thank you!</Col>
|
|
152
|
+
</Row>
|
|
153
|
+
)
|
|
154
|
+
) : (
|
|
155
|
+
<>
|
|
156
|
+
{modalHeaderProps ? (
|
|
157
|
+
<ModalHeader
|
|
158
|
+
id="feedback-form-header"
|
|
159
|
+
role="heading"
|
|
160
|
+
aria-level="2"
|
|
161
|
+
className="h5 mt-n2 mx-n2"
|
|
162
|
+
tag="div"
|
|
163
|
+
{...modalHeaderProps}
|
|
164
|
+
>
|
|
165
|
+
{prompt || `Tell us what you think about ${name}`}
|
|
166
|
+
</ModalHeader>
|
|
167
|
+
) : (
|
|
168
|
+
<Row>
|
|
169
|
+
<div className="col h5" role="heading" aria-level="2" id="feedback-form-header">
|
|
170
|
+
{prompt || `Tell us what you think about ${name}`}
|
|
171
|
+
</div>
|
|
172
|
+
</Row>
|
|
173
|
+
)}
|
|
174
|
+
|
|
137
175
|
<FormGroup
|
|
176
|
+
row
|
|
177
|
+
data-testid="face-options"
|
|
138
178
|
size="lg"
|
|
139
179
|
id="face-options"
|
|
140
180
|
role="group"
|
|
141
181
|
aria-labelledby="feedback-form-header"
|
|
142
|
-
data-testid="face-options"
|
|
143
|
-
className="d-flex flex-row justify-content-between"
|
|
144
182
|
>
|
|
145
183
|
<SmileField
|
|
146
184
|
options={faceOptions}
|
|
@@ -149,67 +187,91 @@ const FeedbackForm = ({
|
|
|
149
187
|
autoFocusFeedbackButton={autoFocusFeedbackButton}
|
|
150
188
|
/>
|
|
151
189
|
</FormGroup>
|
|
190
|
+
|
|
152
191
|
{active ? (
|
|
153
192
|
<>
|
|
154
193
|
{aboutOptions.length > 0 && (
|
|
155
|
-
<
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
194
|
+
<Row>
|
|
195
|
+
<Col>
|
|
196
|
+
<SelectField
|
|
197
|
+
name="feedbackApp"
|
|
198
|
+
id="about-options"
|
|
199
|
+
data-testid="about-options"
|
|
200
|
+
label={aboutLabel}
|
|
201
|
+
options={aboutOptions}
|
|
202
|
+
/>
|
|
203
|
+
</Col>
|
|
204
|
+
</Row>
|
|
162
205
|
)}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
206
|
+
|
|
207
|
+
<Row>
|
|
208
|
+
<Col>
|
|
209
|
+
<Field
|
|
210
|
+
type="textarea"
|
|
211
|
+
name="feedback"
|
|
212
|
+
label={(active && active.label) || 'Feedback? Requests? Defects?'}
|
|
213
|
+
style={fieldStyles}
|
|
214
|
+
rows="2"
|
|
215
|
+
/>
|
|
216
|
+
</Col>
|
|
217
|
+
</Row>
|
|
170
218
|
{additionalComments && (
|
|
171
|
-
<
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
219
|
+
<Row>
|
|
220
|
+
<Col>
|
|
221
|
+
<Field
|
|
222
|
+
type="textarea"
|
|
223
|
+
name="additionalFeedback"
|
|
224
|
+
label="Additional Comments... (Optional)"
|
|
225
|
+
style={fieldStyles}
|
|
226
|
+
rows="2"
|
|
227
|
+
/>
|
|
228
|
+
</Col>
|
|
229
|
+
</Row>
|
|
178
230
|
)}
|
|
179
231
|
</>
|
|
180
232
|
) : null}
|
|
181
|
-
</ModalBody>
|
|
182
233
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
234
|
+
<Row className="justify-content-end">
|
|
235
|
+
{showSupport ? (
|
|
236
|
+
<Col xs="auto" className="mt-2">
|
|
237
|
+
<small className="d-none d-md-inline" style={inlineStyles}>
|
|
238
|
+
Need Help?
|
|
239
|
+
</small>
|
|
240
|
+
<Button
|
|
241
|
+
size="sm"
|
|
242
|
+
className="pl-0 ml-1 d-inline"
|
|
243
|
+
onClick={() => setSupportIsActive(true)}
|
|
244
|
+
onKeyDown={({ keyCode }) => keyCode === 13 && setSupportIsActive(true)}
|
|
245
|
+
color="link"
|
|
246
|
+
type="button"
|
|
247
|
+
>
|
|
248
|
+
Open a support ticket
|
|
249
|
+
</Button>
|
|
250
|
+
</Col>
|
|
251
|
+
) : null}
|
|
252
|
+
{onClose ? (
|
|
253
|
+
<Col xs="auto" className="mt-2">
|
|
254
|
+
<Button
|
|
255
|
+
size="sm"
|
|
256
|
+
onClick={onClose}
|
|
257
|
+
onKeyDown={({ keyCode }) => keyCode === 13 && onClose()}
|
|
258
|
+
color="secondary"
|
|
259
|
+
className=""
|
|
260
|
+
>
|
|
261
|
+
Close
|
|
262
|
+
</Button>
|
|
263
|
+
</Col>
|
|
264
|
+
) : null}
|
|
200
265
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
</ModalFooter>
|
|
211
|
-
</Form>
|
|
212
|
-
</>
|
|
266
|
+
<Col xs="auto" className="mt-2">
|
|
267
|
+
<Button size="sm" type="submit" color="primary" disabled={!active}>
|
|
268
|
+
Send Feedback
|
|
269
|
+
</Button>
|
|
270
|
+
</Col>
|
|
271
|
+
</Row>
|
|
272
|
+
</>
|
|
273
|
+
)}
|
|
274
|
+
</Form>
|
|
213
275
|
);
|
|
214
276
|
};
|
|
215
277
|
|
|
@@ -247,7 +309,6 @@ FeedbackForm.defaultProps = {
|
|
|
247
309
|
aboutOptions: [],
|
|
248
310
|
aboutLabel: 'This is about',
|
|
249
311
|
additionalComments: false,
|
|
250
|
-
modalHeaderProps: {},
|
|
251
312
|
analytics: avLogMessagesApi,
|
|
252
313
|
showSupport: false,
|
|
253
314
|
};
|
package/src/FeedbackModal.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { Modal } from 'reactstrap';
|
|
3
|
+
import { Modal, ModalHeader } from 'reactstrap';
|
|
4
4
|
import FeedbackForm from './FeedbackForm';
|
|
5
5
|
import SupportModal from './SupportModal';
|
|
6
6
|
|
|
7
|
-
const FeedbackModal = ({
|
|
7
|
+
const FeedbackModal = ({
|
|
8
|
+
isOpen,
|
|
9
|
+
toggle,
|
|
10
|
+
zIndex,
|
|
11
|
+
showSupport,
|
|
12
|
+
supportZIndex,
|
|
13
|
+
feedbackToggle,
|
|
14
|
+
modalHeaderProps = {},
|
|
15
|
+
...formOptions
|
|
16
|
+
}) => {
|
|
8
17
|
const [supportIsActive, setSupportIsActive] = React.useState(false);
|
|
9
18
|
|
|
10
19
|
return supportIsActive ? (
|
|
@@ -30,6 +39,7 @@ const FeedbackModal = ({ isOpen, toggle, zIndex, showSupport, supportZIndex, fee
|
|
|
30
39
|
onClose={toggle}
|
|
31
40
|
showSupport={showSupport}
|
|
32
41
|
setSupportIsActive={setSupportIsActive}
|
|
42
|
+
modalHeaderProps={{ toggle, ...modalHeaderProps }}
|
|
33
43
|
{...formOptions}
|
|
34
44
|
/>
|
|
35
45
|
</Modal>
|
|
@@ -43,6 +53,7 @@ FeedbackModal.propTypes = {
|
|
|
43
53
|
zIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
44
54
|
supportZIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
45
55
|
feedbackToggle: PropTypes.func,
|
|
56
|
+
modalHeaderProps: PropTypes.shape({ ...ModalHeader.propTypes }),
|
|
46
57
|
};
|
|
47
58
|
|
|
48
59
|
export default FeedbackModal;
|
package/src/SmileField.js
CHANGED
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { useField, useFormikContext } from 'formik';
|
|
4
|
+
import { Col } from 'reactstrap';
|
|
4
5
|
import FeedbackButton from './FeedbackButton';
|
|
5
6
|
|
|
6
|
-
const btnStyles = { flex: 1, margin: '0 2% 0 2%' };
|
|
7
|
-
|
|
8
7
|
const SmileField = ({ name, options, onChange, autoFocusFeedbackButton }) => {
|
|
9
8
|
const [{ value }] = useField(name);
|
|
10
9
|
const { setFieldValue } = useFormikContext();
|
|
11
10
|
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
11
|
+
return (
|
|
12
|
+
<>
|
|
13
|
+
{options.map((option, i) => (
|
|
14
|
+
<Col key={option.icon}>
|
|
15
|
+
<FeedbackButton
|
|
16
|
+
autoFocus={i === 0 && autoFocusFeedbackButton}
|
|
17
|
+
icon={option.icon}
|
|
18
|
+
iconSize="2x"
|
|
19
|
+
value={option}
|
|
20
|
+
active={value && value.icon}
|
|
21
|
+
onClick={() => {
|
|
22
|
+
setFieldValue(name, option);
|
|
23
|
+
if (onChange) {
|
|
24
|
+
onChange(option);
|
|
25
|
+
}
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
{option.description}
|
|
29
|
+
</FeedbackButton>
|
|
30
|
+
</Col>
|
|
31
|
+
))}
|
|
32
|
+
</>
|
|
33
|
+
);
|
|
31
34
|
};
|
|
32
35
|
|
|
33
36
|
SmileField.propTypes = {
|