@availity/feedback 6.0.7 → 6.0.11

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
@@ -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.11](https://github.com/Availity/availity-react/compare/@availity/feedback@6.0.10...@availity/feedback@6.0.11) (2021-10-08)
7
+
8
+ **Note:** Version bump only for package @availity/feedback
9
+
10
+
11
+
12
+
13
+
14
+ ## [6.0.10](https://github.com/Availity/availity-react/compare/@availity/feedback@6.0.9...@availity/feedback@6.0.10) (2021-10-06)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * improve modal use case for FeedbackForm ([66dff23](https://github.com/Availity/availity-react/commit/66dff23e8b770e4143496c2d81683c46a1fc4fb4))
20
+
21
+
22
+
23
+
24
+
25
+ ## [6.0.9](https://github.com/Availity/availity-react/compare/@availity/feedback@6.0.8...@availity/feedback@6.0.9) (2021-10-04)
26
+
27
+ **Note:** Version bump only for package @availity/feedback
28
+
29
+
30
+
31
+
32
+
33
+ ## [6.0.8](https://github.com/Availity/availity-react/compare/@availity/feedback@6.0.7...@availity/feedback@6.0.8) (2021-10-01)
34
+
35
+ **Note:** Version bump only for package @availity/feedback
36
+
37
+
38
+
39
+
40
+
6
41
  ## [6.0.7](https://github.com/Availity/availity-react/compare/@availity/feedback@6.0.6...@availity/feedback@6.0.7) (2021-09-28)
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.7",
3
+ "version": "6.0.11",
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,16 +21,15 @@
21
21
  "access": "public"
22
22
  },
23
23
  "dependencies": {
24
- "@availity/form": "^0.7.1",
25
- "@availity/hooks": "^3.0.3",
26
- "@availity/icon": "^0.8.1",
24
+ "@availity/form": "^0.7.3",
25
+ "@availity/hooks": "^3.0.4",
26
+ "@availity/icon": "^0.9.0",
27
27
  "@availity/native-form": "^3.0.0",
28
- "@availity/select": "^0.18.2",
28
+ "@availity/select": "^0.19.0",
29
29
  "prop-types": "^15.7.2"
30
30
  },
31
31
  "devDependencies": {
32
- "@availity/api-axios": "^5.5.14",
33
- "@availity/api-core": "^7.0.2",
32
+ "@availity/api-axios": "^6.0.0",
34
33
  "@availity/yup": "^3.0.11",
35
34
  "axios": "^0.21.1",
36
35
  "formik": "^2.2.8",
@@ -40,8 +39,7 @@
40
39
  "yup": "^0.30.0"
41
40
  },
42
41
  "peerDependencies": {
43
- "@availity/api-axios": ">=2.0.0",
44
- "@availity/api-core": ">=2.0.0",
42
+ "@availity/api-axios": "^6.0.0",
45
43
  "@availity/yup": "^3.0.11",
46
44
  "axios": "^0.21.1",
47
45
  "formik": "^2.0.1",
@@ -49,5 +47,5 @@
49
47
  "reactstrap": "^8.0.0 || ^7.0.0 || ^6.0.0",
50
48
  "yup": "^0.27.0"
51
49
  },
52
- "gitHead": "cbd7f7edc581a61f6cc9258f00946d3098c51eef"
50
+ "gitHead": "6c8c8d87ad71b7ae6cdae9f0af265cffc859164b"
53
51
  }
@@ -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
- style={btnStyles}
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} style={iconStyles} />
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
  );
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { Button, ModalBody, ModalHeader, ModalFooter, FormGroup } from 'reactstrap';
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 sent ? (
86
- <ModalHeader
87
- role="status"
88
- id="feedback-form-header"
89
- tabIndex="0"
90
- className="d-flex justify-content-center"
91
- {...modalHeaderProps}
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
- Thank you for your feedback.
94
- </ModalHeader>
95
- ) : (
96
- <>
97
- <ModalHeader
98
- id="feedback-form-header"
99
- role="heading"
100
- aria-level="2"
101
- className="h5"
102
- tag="div"
103
- {...modalHeaderProps}
104
- >
105
- {prompt || `Tell us what you think about ${name}`}
106
- </ModalHeader>
107
- <Form
108
- aria-label="Feedback Form"
109
- aria-describedby="feedback-form-header"
110
- role="form"
111
- onKeyDown={({ keyCode }) => keyCode === 27 && onClose()}
112
- data-testid="feedback-form"
113
- initialValues={{
114
- 'face-options': undefined,
115
- additionalFeedback: undefined,
116
- feedback: undefined,
117
- feedbackApp: undefined,
118
- smileField: undefined,
119
- }}
120
- validationSchema={yup.object().shape({
121
- feedback: yup.string().max(200, 'Feedback cannot exceed 200 characters.').required('This field is required.'),
122
- additionalFeedback: yup.string().max(200, 'Additional Feedback cannot exceed 200 characters.'),
123
- smileField: yup
124
- .object()
125
- .shape({
126
- icon: yup.string().required(),
127
- description: yup.string(),
128
- label: yup.string(),
129
- })
130
- .required('This field is required.'),
131
- feedbackApp: yup.string().isRequired(aboutOptions.length > 0, 'This field is required.'),
132
- })}
133
- {...formProps}
134
- onSubmit={(values) => sendFeedback(values)}
135
- >
136
- <ModalBody>
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
- <SelectField
156
- name="feedbackApp"
157
- id="about-options"
158
- data-testid="about-options"
159
- label={aboutLabel}
160
- options={aboutOptions}
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
- <Field
164
- type="textarea"
165
- name="feedback"
166
- label={(active && active.label) || 'Feedback? Requests? Defects?'}
167
- style={fieldStyles}
168
- rows="2"
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
- <Field
172
- type="textarea"
173
- name="additionalFeedback"
174
- label="Additional Comments... (Optional)"
175
- style={fieldStyles}
176
- rows="2"
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
- <ModalFooter>
184
- {showSupport ? (
185
- <>
186
- <span className="d-none d-md-block" style={inlineStyles}>
187
- Need Help?
188
- </span>
189
- <Button
190
- className="pl-0"
191
- onClick={() => setSupportIsActive(true)}
192
- color="link"
193
- type="button"
194
- onKeyDown={({ keyCode }) => keyCode === 13 && setSupportIsActive(true)}
195
- >
196
- Open a support ticket
197
- </Button>
198
- </>
199
- ) : null}
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
- {onClose ? (
202
- <Button onClick={onClose} color="secondary" onKeyDown={({ keyCode }) => keyCode === 13 && onClose()}>
203
- Close
204
- </Button>
205
- ) : null}
206
-
207
- <Button type="submit" color="primary" disabled={!active}>
208
- Send Feedback
209
- </Button>
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
  };
@@ -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 = ({ isOpen, toggle, zIndex, showSupport, supportZIndex, feedbackToggle, ...formOptions }) => {
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 options.map((option, i) => (
13
- <FeedbackButton
14
- autoFocus={i === 0 && autoFocusFeedbackButton}
15
- style={btnStyles}
16
- key={option.icon}
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
- ));
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 = {