@availity/mui-feedback 0.1.26 → 0.1.28

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,23 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.1.28](https://github.com/Availity/element/compare/@availity/mui-feedback@0.1.27...@availity/mui-feedback@0.1.28) (2024-05-15)
6
+
7
+ ### Dependency Updates
8
+
9
+ * `mui-form-utils` updated to version `0.1.27`
10
+ * `mui-textfield` updated to version `0.1.27`
11
+ ## [0.1.27](https://github.com/Availity/element/compare/@availity/mui-feedback@0.1.26...@availity/mui-feedback@0.1.27) (2024-04-19)
12
+
13
+ ### Dependency Updates
14
+
15
+ * `mui-button` updated to version `0.1.26`
16
+ * `mui-form-utils` updated to version `0.1.26`
17
+ * `mui-icon` updated to version `0.1.26`
18
+ * `mui-popover` updated to version `0.1.26`
19
+ * `mui-textfield` updated to version `0.1.26`
20
+ * `mui-toggle-button` updated to version `0.1.26`
21
+ * `mui-typography` updated to version `0.1.26`
5
22
  ## [0.1.26](https://github.com/Availity/element/compare/@availity/mui-feedback@0.1.25...@availity/mui-feedback@0.1.26) (2024-04-15)
6
23
 
7
24
  ### Dependency Updates
@@ -0,0 +1,9 @@
1
+ interface FeedbackProps {
2
+ analytics?: {
3
+ info: (entries: any) => any;
4
+ };
5
+ appName: string;
6
+ }
7
+ declare const Feedback: ({ analytics, appName }: FeedbackProps) => JSX.Element;
8
+
9
+ export { Feedback, type FeedbackProps };
package/dist/index.d.ts CHANGED
@@ -6,4 +6,4 @@ interface FeedbackProps {
6
6
  }
7
7
  declare const Feedback: ({ analytics, appName }: FeedbackProps) => JSX.Element;
8
8
 
9
- export { Feedback, FeedbackProps };
9
+ export { Feedback, type FeedbackProps };
package/dist/index.js CHANGED
@@ -1,10 +1,39 @@
1
1
  "use strict";
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
9
  var __getProtoOf = Object.getPrototypeOf;
7
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
8
37
  var __export = (target, all) => {
9
38
  for (var name in all)
10
39
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -18,10 +47,34 @@ var __copyProps = (to, from, except, desc) => {
18
47
  return to;
19
48
  };
20
49
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
+ // If the importer is in node compatibility mode or this is not an ESM
51
+ // file that has been converted to a CommonJS file using a Babel-
52
+ // compatible transform (i.e. "__esModule" has not been set), then set
53
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
54
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
55
  mod
23
56
  ));
24
57
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
+ var __async = (__this, __arguments, generator) => {
59
+ return new Promise((resolve, reject) => {
60
+ var fulfilled = (value) => {
61
+ try {
62
+ step(generator.next(value));
63
+ } catch (e) {
64
+ reject(e);
65
+ }
66
+ };
67
+ var rejected = (value) => {
68
+ try {
69
+ step(generator.throw(value));
70
+ } catch (e) {
71
+ reject(e);
72
+ }
73
+ };
74
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
75
+ step((generator = generator.apply(__this, __arguments)).next());
76
+ });
77
+ };
25
78
 
26
79
  // src/index.ts
27
80
  var src_exports = {};
@@ -52,17 +105,10 @@ var import_react_hook_form = require("react-hook-form");
52
105
  var import_jsx_runtime = require("react/jsx-runtime");
53
106
  var SmileButtons = (0, import_styles.styled)(import_mui_toggle_button.ToggleButtonGroup, { name: "AvFeedbackContainer", slot: "SmileButtons" })({});
54
107
  var FormActions = (0, import_styles.styled)(import_Grid.default, { name: "AvFeedbackContainer", slot: "FormActions" })({});
55
- var SmileButton = ({ disabled, Icon, label, value, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
56
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_toggle_button.ToggleButton, {
57
- "aria-label": value,
58
- value,
59
- ...props,
60
- disabled,
61
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
62
- fontSize: "large"
63
- })
64
- })
65
- });
108
+ var SmileButton = (_a) => {
109
+ var _b = _a, { disabled, Icon, label, value } = _b, props = __objRest(_b, ["disabled", "Icon", "label", "value"]);
110
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_toggle_button.ToggleButton, __spreadProps(__spreadValues({ "aria-label": value, value }, props), { disabled, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { fontSize: "large" }) })) });
111
+ };
66
112
  var FeedbackForm = ({
67
113
  analytics,
68
114
  appName,
@@ -72,7 +118,7 @@ var FeedbackForm = ({
72
118
  setLoading,
73
119
  setSent
74
120
  }) => {
75
- var _a;
121
+ var _c;
76
122
  const {
77
123
  control,
78
124
  formState: { errors },
@@ -81,27 +127,27 @@ var FeedbackForm = ({
81
127
  setValue,
82
128
  watch
83
129
  } = (0, import_react_hook_form.useForm)();
84
- const onSubmit = async ({ smileField, ...values }) => {
130
+ const onSubmit = (_a) => __async(void 0, null, function* () {
131
+ var _b = _a, { smileField } = _b, values = __objRest(_b, ["smileField"]);
85
132
  setLoading(true);
86
133
  try {
87
- const response = await import_api_axios.avRegionsApi.getCurrentRegion();
88
- await analytics.info({
134
+ const response = yield import_api_axios.avRegionsApi.getCurrentRegion();
135
+ yield analytics.info(__spreadValues({
89
136
  surveyId: `${appName.replace(/\s/g, "_")}_Smile_Survey`,
90
137
  smileLocation: `${appName}`,
91
138
  smile: `icon-${smileField}`,
92
139
  url: window.location.href,
93
140
  region: response.data.regions[0] && response.data.regions[0].id,
94
141
  userAgent: window.navigator.userAgent,
95
- submitTime: new Date(),
96
- ...values
97
- });
142
+ submitTime: /* @__PURE__ */ new Date()
143
+ }, values));
98
144
  setSent(true);
99
145
  setLoading(false);
100
- } catch {
146
+ } catch (e) {
101
147
  setSent(false);
102
148
  setLoading(false);
103
149
  }
104
- };
150
+ });
105
151
  (0, import_react.useEffect)(() => {
106
152
  if (sent) {
107
153
  setTimeout(() => {
@@ -128,81 +174,66 @@ var FeedbackForm = ({
128
174
  return (option == null ? void 0 : option.label) || "What would you improve?";
129
175
  };
130
176
  if (!sent) {
131
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_Grid.default, {
132
- component: "form",
133
- container: true,
134
- justifyContent: "center",
135
- onSubmit: handleSubmit(onSubmit),
136
- "aria-label": "Feedback Form",
137
- "aria-describedby": "feedback-form-header",
138
- children: [
139
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_hook_form.Controller, {
140
- control,
141
- name: "smileField",
142
- render: ({ field }) => {
143
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SmileButtons, {
144
- children: options.map((props, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SmileButton, {
145
- autoFocus: index === 0,
146
- disabled: loading,
147
- ...props
148
- }, props.value)),
149
- ...field,
150
- "aria-labelledby": "feedback-form-header",
151
- onChange: (event, value) => {
152
- setValue(field.name, value);
177
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
178
+ import_Grid.default,
179
+ {
180
+ component: "form",
181
+ container: true,
182
+ justifyContent: "center",
183
+ onSubmit: handleSubmit(onSubmit),
184
+ "aria-label": "Feedback Form",
185
+ "aria-describedby": "feedback-form-header",
186
+ children: [
187
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
188
+ import_react_hook_form.Controller,
189
+ {
190
+ control,
191
+ name: "smileField",
192
+ render: ({ field }) => {
193
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
194
+ SmileButtons,
195
+ __spreadProps(__spreadValues({
196
+ children: options.map((props, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SmileButton, __spreadValues({ autoFocus: index === 0, disabled: loading }, props), props.value))
197
+ }, field), {
198
+ "aria-labelledby": "feedback-form-header",
199
+ onChange: (event, value) => {
200
+ setValue(field.name, value);
201
+ },
202
+ size: "medium",
203
+ exclusive: true
204
+ })
205
+ );
206
+ }
207
+ }
208
+ ),
209
+ smileFieldValue && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
210
+ import_mui_textfield.TextField,
211
+ __spreadProps(__spreadValues({}, register("feedback", {
212
+ required: "This field is required",
213
+ maxLength: { value: 200, message: "This field must not exceed 200 characters" }
214
+ })), {
215
+ fullWidth: true,
216
+ multiline: true,
217
+ minRows: 3,
218
+ maxRows: 3,
219
+ label: getFeedbackLabel(),
220
+ inputProps: { "aria-required": "true" },
221
+ InputLabelProps: {
222
+ component: import_mui_form_utils.FormLabel,
223
+ required: true
153
224
  },
154
- size: "medium",
155
- exclusive: true
156
- });
157
- }
158
- }),
159
- smileFieldValue && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_textfield.TextField, {
160
- ...register("feedback", {
161
- required: "This field is required",
162
- maxLength: { value: 200, message: "This field must not exceed 200 characters" }
163
- }),
164
- fullWidth: true,
165
- multiline: true,
166
- minRows: 3,
167
- maxRows: 3,
168
- label: getFeedbackLabel(),
169
- inputProps: { "aria-required": "true" },
170
- InputLabelProps: {
171
- component: import_mui_form_utils.FormLabel,
172
- required: true
173
- },
174
- helperText: ((_a = errors.feedback) == null ? void 0 : _a.message) || "Max 200 characters",
175
- error: !!errors.feedback,
176
- disabled: loading
177
- }),
178
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FormActions, {
179
- container: true,
180
- direction: "row",
181
- spacing: 1,
182
- children: [
183
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Grid.default, {
184
- item: true,
185
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_button.Button, {
186
- color: "secondary",
187
- disabled: loading,
188
- onClick: handleClose,
189
- children: "Cancel"
190
- })
191
- }),
192
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Grid.default, {
193
- item: true,
194
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_button.LoadingButton, {
195
- disabled: !smileFieldValue,
196
- loading,
197
- type: "submit",
198
- variant: "contained",
199
- children: "Send Feedback"
200
- })
225
+ helperText: ((_c = errors.feedback) == null ? void 0 : _c.message) || "Max 200 characters",
226
+ error: !!errors.feedback,
227
+ disabled: loading
201
228
  })
202
- ]
203
- })
204
- ]
205
- });
229
+ ),
230
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FormActions, { container: true, direction: "row", spacing: 1, children: [
231
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Grid.default, { item: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_button.Button, { color: "secondary", disabled: loading, onClick: handleClose, children: "Cancel" }) }),
232
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Grid.default, { item: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_button.LoadingButton, { disabled: !smileFieldValue, loading, type: "submit", variant: "contained", children: "Send Feedback" }) })
233
+ ] })
234
+ ]
235
+ }
236
+ );
206
237
  } else {
207
238
  return null;
208
239
  }
@@ -214,43 +245,29 @@ var import_mui_icon2 = require("@availity/mui-icon");
214
245
  var import_mui_typography = require("@availity/mui-typography");
215
246
  var import_Grid2 = __toESM(require("@mui/material/Grid"));
216
247
  var import_styles2 = require("@mui/material/styles");
217
- var import_jsx_runtime = require("react/jsx-runtime");
248
+ var import_jsx_runtime2 = require("react/jsx-runtime");
218
249
  var FeedbackHeaderContainer = (0, import_styles2.styled)(import_Grid2.default, { name: "AvFeedbackContainer", slot: "FeedbackHeaderContainer" })({});
219
250
  var FeedbackHeader = ({ appName, handleClose, loading, sent }) => {
220
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FeedbackHeaderContainer, {
221
- alignItems: "center",
222
- container: true,
223
- direction: "row",
224
- marginBottom: !sent ? "8px" : "0px",
225
- justifyContent: "space-between",
226
- flexWrap: "nowrap",
227
- id: "feedback-form-header",
228
- children: [
229
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Grid2.default, {
230
- item: true,
231
- whiteSpace: "normal",
232
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_typography.Typography, {
233
- component: "h2",
234
- variant: "h5",
235
- children: sent ? "Thank you for your feedback." : `Tell us what you think about ${appName}`
236
- })
237
- }),
238
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Grid2.default, {
239
- item: true,
240
- marginRight: "-8px",
241
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_button2.IconButton, {
242
- disabled: loading,
243
- title: "Close",
244
- onClick: handleClose,
245
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_icon2.CloseIcon, {})
246
- })
247
- })
248
- ]
249
- });
251
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
252
+ FeedbackHeaderContainer,
253
+ {
254
+ alignItems: "center",
255
+ container: true,
256
+ direction: "row",
257
+ marginBottom: !sent ? "8px" : "0px",
258
+ justifyContent: "space-between",
259
+ flexWrap: "nowrap",
260
+ id: "feedback-form-header",
261
+ children: [
262
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_Grid2.default, { item: true, whiteSpace: "normal", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_mui_typography.Typography, { component: "h2", variant: "h5", children: sent ? "Thank you for your feedback." : `Tell us what you think about ${appName}` }) }),
263
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_Grid2.default, { item: true, marginRight: "-8px", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_mui_button2.IconButton, { disabled: loading, title: "Close", onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_mui_icon2.CloseIcon, {}) }) })
264
+ ]
265
+ }
266
+ );
250
267
  };
251
268
 
252
269
  // src/lib/Feedback.tsx
253
- var import_jsx_runtime = require("react/jsx-runtime");
270
+ var import_jsx_runtime3 = require("react/jsx-runtime");
254
271
  var FeedbackContainer = (0, import_styles3.styled)(import_Container.default, { name: "AvFeedbackContainer", slot: "root" })({});
255
272
  var GiveFeedbackButton = (0, import_styles3.styled)(import_mui_button3.Button, { name: "AvGiveFeedbackButton", slot: "root" })({});
256
273
  var Feedback = ({ analytics = import_api_axios2.avLogMessagesApi, appName }) => {
@@ -265,14 +282,11 @@ var Feedback = ({ analytics = import_api_axios2.avLogMessagesApi, appName }) =>
265
282
  setAnchorEl(null);
266
283
  };
267
284
  const open = Boolean(anchorEl);
268
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
269
- children: [
270
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GiveFeedbackButton, {
271
- onClick: handlePopoverOpen,
272
- color: "secondary",
273
- children: "Give Feedback"
274
- }),
275
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_popover.Popover, {
285
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
286
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(GiveFeedbackButton, { onClick: handlePopoverOpen, color: "secondary", children: "Give Feedback" }),
287
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
288
+ import_mui_popover.Popover,
289
+ {
276
290
  anchorEl,
277
291
  anchorOrigin: {
278
292
  vertical: "bottom",
@@ -286,15 +300,11 @@ var Feedback = ({ analytics = import_api_axios2.avLogMessagesApi, appName }) =>
286
300
  vertical: "top",
287
301
  horizontal: "right"
288
302
  },
289
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FeedbackContainer, {
290
- children: [
291
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FeedbackHeader, {
292
- appName,
293
- handleClose: handlePopoverClose,
294
- loading,
295
- sent
296
- }),
297
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FeedbackForm, {
303
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(FeedbackContainer, { children: [
304
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FeedbackHeader, { appName, handleClose: handlePopoverClose, loading, sent }),
305
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
306
+ FeedbackForm,
307
+ {
298
308
  analytics,
299
309
  appName,
300
310
  handleClose: handlePopoverClose,
@@ -302,12 +312,12 @@ var Feedback = ({ analytics = import_api_axios2.avLogMessagesApi, appName }) =>
302
312
  sent,
303
313
  setLoading,
304
314
  setSent
305
- })
306
- ]
307
- })
308
- })
309
- ]
310
- });
315
+ }
316
+ )
317
+ ] })
318
+ }
319
+ )
320
+ ] });
311
321
  };
312
322
  // Annotate the CommonJS export names for ESM import in node:
313
323
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -1,3 +1,55 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ var __async = (__this, __arguments, generator) => {
33
+ return new Promise((resolve, reject) => {
34
+ var fulfilled = (value) => {
35
+ try {
36
+ step(generator.next(value));
37
+ } catch (e) {
38
+ reject(e);
39
+ }
40
+ };
41
+ var rejected = (value) => {
42
+ try {
43
+ step(generator.throw(value));
44
+ } catch (e) {
45
+ reject(e);
46
+ }
47
+ };
48
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
+ step((generator = generator.apply(__this, __arguments)).next());
50
+ });
51
+ };
52
+
1
53
  // src/lib/Feedback.tsx
2
54
  import { useState } from "react";
3
55
  import { Popover } from "@availity/mui-popover";
@@ -20,17 +72,10 @@ import { useForm, Controller } from "react-hook-form";
20
72
  import { jsx, jsxs } from "react/jsx-runtime";
21
73
  var SmileButtons = styled(ToggleButtonGroup, { name: "AvFeedbackContainer", slot: "SmileButtons" })({});
22
74
  var FormActions = styled(Grid, { name: "AvFeedbackContainer", slot: "FormActions" })({});
23
- var SmileButton = ({ disabled, Icon, label, value, ...props }) => /* @__PURE__ */ jsx("div", {
24
- children: /* @__PURE__ */ jsx(ToggleButton, {
25
- "aria-label": value,
26
- value,
27
- ...props,
28
- disabled,
29
- children: /* @__PURE__ */ jsx(Icon, {
30
- fontSize: "large"
31
- })
32
- })
33
- });
75
+ var SmileButton = (_a) => {
76
+ var _b = _a, { disabled, Icon, label, value } = _b, props = __objRest(_b, ["disabled", "Icon", "label", "value"]);
77
+ return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(ToggleButton, __spreadProps(__spreadValues({ "aria-label": value, value }, props), { disabled, children: /* @__PURE__ */ jsx(Icon, { fontSize: "large" }) })) });
78
+ };
34
79
  var FeedbackForm = ({
35
80
  analytics,
36
81
  appName,
@@ -40,7 +85,7 @@ var FeedbackForm = ({
40
85
  setLoading,
41
86
  setSent
42
87
  }) => {
43
- var _a;
88
+ var _c;
44
89
  const {
45
90
  control,
46
91
  formState: { errors },
@@ -49,27 +94,27 @@ var FeedbackForm = ({
49
94
  setValue,
50
95
  watch
51
96
  } = useForm();
52
- const onSubmit = async ({ smileField, ...values }) => {
97
+ const onSubmit = (_a) => __async(void 0, null, function* () {
98
+ var _b = _a, { smileField } = _b, values = __objRest(_b, ["smileField"]);
53
99
  setLoading(true);
54
100
  try {
55
- const response = await avRegionsApi.getCurrentRegion();
56
- await analytics.info({
101
+ const response = yield avRegionsApi.getCurrentRegion();
102
+ yield analytics.info(__spreadValues({
57
103
  surveyId: `${appName.replace(/\s/g, "_")}_Smile_Survey`,
58
104
  smileLocation: `${appName}`,
59
105
  smile: `icon-${smileField}`,
60
106
  url: window.location.href,
61
107
  region: response.data.regions[0] && response.data.regions[0].id,
62
108
  userAgent: window.navigator.userAgent,
63
- submitTime: new Date(),
64
- ...values
65
- });
109
+ submitTime: /* @__PURE__ */ new Date()
110
+ }, values));
66
111
  setSent(true);
67
112
  setLoading(false);
68
- } catch {
113
+ } catch (e) {
69
114
  setSent(false);
70
115
  setLoading(false);
71
116
  }
72
- };
117
+ });
73
118
  useEffect(() => {
74
119
  if (sent) {
75
120
  setTimeout(() => {
@@ -96,81 +141,66 @@ var FeedbackForm = ({
96
141
  return (option == null ? void 0 : option.label) || "What would you improve?";
97
142
  };
98
143
  if (!sent) {
99
- return /* @__PURE__ */ jsxs(Grid, {
100
- component: "form",
101
- container: true,
102
- justifyContent: "center",
103
- onSubmit: handleSubmit(onSubmit),
104
- "aria-label": "Feedback Form",
105
- "aria-describedby": "feedback-form-header",
106
- children: [
107
- /* @__PURE__ */ jsx(Controller, {
108
- control,
109
- name: "smileField",
110
- render: ({ field }) => {
111
- return /* @__PURE__ */ jsx(SmileButtons, {
112
- children: options.map((props, index) => /* @__PURE__ */ jsx(SmileButton, {
113
- autoFocus: index === 0,
114
- disabled: loading,
115
- ...props
116
- }, props.value)),
117
- ...field,
118
- "aria-labelledby": "feedback-form-header",
119
- onChange: (event, value) => {
120
- setValue(field.name, value);
144
+ return /* @__PURE__ */ jsxs(
145
+ Grid,
146
+ {
147
+ component: "form",
148
+ container: true,
149
+ justifyContent: "center",
150
+ onSubmit: handleSubmit(onSubmit),
151
+ "aria-label": "Feedback Form",
152
+ "aria-describedby": "feedback-form-header",
153
+ children: [
154
+ /* @__PURE__ */ jsx(
155
+ Controller,
156
+ {
157
+ control,
158
+ name: "smileField",
159
+ render: ({ field }) => {
160
+ return /* @__PURE__ */ jsx(
161
+ SmileButtons,
162
+ __spreadProps(__spreadValues({
163
+ children: options.map((props, index) => /* @__PURE__ */ jsx(SmileButton, __spreadValues({ autoFocus: index === 0, disabled: loading }, props), props.value))
164
+ }, field), {
165
+ "aria-labelledby": "feedback-form-header",
166
+ onChange: (event, value) => {
167
+ setValue(field.name, value);
168
+ },
169
+ size: "medium",
170
+ exclusive: true
171
+ })
172
+ );
173
+ }
174
+ }
175
+ ),
176
+ smileFieldValue && /* @__PURE__ */ jsx(
177
+ TextField,
178
+ __spreadProps(__spreadValues({}, register("feedback", {
179
+ required: "This field is required",
180
+ maxLength: { value: 200, message: "This field must not exceed 200 characters" }
181
+ })), {
182
+ fullWidth: true,
183
+ multiline: true,
184
+ minRows: 3,
185
+ maxRows: 3,
186
+ label: getFeedbackLabel(),
187
+ inputProps: { "aria-required": "true" },
188
+ InputLabelProps: {
189
+ component: FormLabel,
190
+ required: true
121
191
  },
122
- size: "medium",
123
- exclusive: true
124
- });
125
- }
126
- }),
127
- smileFieldValue && /* @__PURE__ */ jsx(TextField, {
128
- ...register("feedback", {
129
- required: "This field is required",
130
- maxLength: { value: 200, message: "This field must not exceed 200 characters" }
131
- }),
132
- fullWidth: true,
133
- multiline: true,
134
- minRows: 3,
135
- maxRows: 3,
136
- label: getFeedbackLabel(),
137
- inputProps: { "aria-required": "true" },
138
- InputLabelProps: {
139
- component: FormLabel,
140
- required: true
141
- },
142
- helperText: ((_a = errors.feedback) == null ? void 0 : _a.message) || "Max 200 characters",
143
- error: !!errors.feedback,
144
- disabled: loading
145
- }),
146
- /* @__PURE__ */ jsxs(FormActions, {
147
- container: true,
148
- direction: "row",
149
- spacing: 1,
150
- children: [
151
- /* @__PURE__ */ jsx(Grid, {
152
- item: true,
153
- children: /* @__PURE__ */ jsx(Button, {
154
- color: "secondary",
155
- disabled: loading,
156
- onClick: handleClose,
157
- children: "Cancel"
158
- })
159
- }),
160
- /* @__PURE__ */ jsx(Grid, {
161
- item: true,
162
- children: /* @__PURE__ */ jsx(LoadingButton, {
163
- disabled: !smileFieldValue,
164
- loading,
165
- type: "submit",
166
- variant: "contained",
167
- children: "Send Feedback"
168
- })
192
+ helperText: ((_c = errors.feedback) == null ? void 0 : _c.message) || "Max 200 characters",
193
+ error: !!errors.feedback,
194
+ disabled: loading
169
195
  })
170
- ]
171
- })
172
- ]
173
- });
196
+ ),
197
+ /* @__PURE__ */ jsxs(FormActions, { container: true, direction: "row", spacing: 1, children: [
198
+ /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(Button, { color: "secondary", disabled: loading, onClick: handleClose, children: "Cancel" }) }),
199
+ /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(LoadingButton, { disabled: !smileFieldValue, loading, type: "submit", variant: "contained", children: "Send Feedback" }) })
200
+ ] })
201
+ ]
202
+ }
203
+ );
174
204
  } else {
175
205
  return null;
176
206
  }
@@ -185,36 +215,22 @@ import { styled as styled2 } from "@mui/material/styles";
185
215
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
186
216
  var FeedbackHeaderContainer = styled2(Grid2, { name: "AvFeedbackContainer", slot: "FeedbackHeaderContainer" })({});
187
217
  var FeedbackHeader = ({ appName, handleClose, loading, sent }) => {
188
- return /* @__PURE__ */ jsxs2(FeedbackHeaderContainer, {
189
- alignItems: "center",
190
- container: true,
191
- direction: "row",
192
- marginBottom: !sent ? "8px" : "0px",
193
- justifyContent: "space-between",
194
- flexWrap: "nowrap",
195
- id: "feedback-form-header",
196
- children: [
197
- /* @__PURE__ */ jsx2(Grid2, {
198
- item: true,
199
- whiteSpace: "normal",
200
- children: /* @__PURE__ */ jsx2(Typography, {
201
- component: "h2",
202
- variant: "h5",
203
- children: sent ? "Thank you for your feedback." : `Tell us what you think about ${appName}`
204
- })
205
- }),
206
- /* @__PURE__ */ jsx2(Grid2, {
207
- item: true,
208
- marginRight: "-8px",
209
- children: /* @__PURE__ */ jsx2(IconButton, {
210
- disabled: loading,
211
- title: "Close",
212
- onClick: handleClose,
213
- children: /* @__PURE__ */ jsx2(CloseIcon, {})
214
- })
215
- })
216
- ]
217
- });
218
+ return /* @__PURE__ */ jsxs2(
219
+ FeedbackHeaderContainer,
220
+ {
221
+ alignItems: "center",
222
+ container: true,
223
+ direction: "row",
224
+ marginBottom: !sent ? "8px" : "0px",
225
+ justifyContent: "space-between",
226
+ flexWrap: "nowrap",
227
+ id: "feedback-form-header",
228
+ children: [
229
+ /* @__PURE__ */ jsx2(Grid2, { item: true, whiteSpace: "normal", children: /* @__PURE__ */ jsx2(Typography, { component: "h2", variant: "h5", children: sent ? "Thank you for your feedback." : `Tell us what you think about ${appName}` }) }),
230
+ /* @__PURE__ */ jsx2(Grid2, { item: true, marginRight: "-8px", children: /* @__PURE__ */ jsx2(IconButton, { disabled: loading, title: "Close", onClick: handleClose, children: /* @__PURE__ */ jsx2(CloseIcon, {}) }) })
231
+ ]
232
+ }
233
+ );
218
234
  };
219
235
 
220
236
  // src/lib/Feedback.tsx
@@ -233,14 +249,11 @@ var Feedback = ({ analytics = avLogMessagesApi, appName }) => {
233
249
  setAnchorEl(null);
234
250
  };
235
251
  const open = Boolean(anchorEl);
236
- return /* @__PURE__ */ jsxs3(Fragment, {
237
- children: [
238
- /* @__PURE__ */ jsx3(GiveFeedbackButton, {
239
- onClick: handlePopoverOpen,
240
- color: "secondary",
241
- children: "Give Feedback"
242
- }),
243
- /* @__PURE__ */ jsx3(Popover, {
252
+ return /* @__PURE__ */ jsxs3(Fragment, { children: [
253
+ /* @__PURE__ */ jsx3(GiveFeedbackButton, { onClick: handlePopoverOpen, color: "secondary", children: "Give Feedback" }),
254
+ /* @__PURE__ */ jsx3(
255
+ Popover,
256
+ {
244
257
  anchorEl,
245
258
  anchorOrigin: {
246
259
  vertical: "bottom",
@@ -254,15 +267,11 @@ var Feedback = ({ analytics = avLogMessagesApi, appName }) => {
254
267
  vertical: "top",
255
268
  horizontal: "right"
256
269
  },
257
- children: /* @__PURE__ */ jsxs3(FeedbackContainer, {
258
- children: [
259
- /* @__PURE__ */ jsx3(FeedbackHeader, {
260
- appName,
261
- handleClose: handlePopoverClose,
262
- loading,
263
- sent
264
- }),
265
- /* @__PURE__ */ jsx3(FeedbackForm, {
270
+ children: /* @__PURE__ */ jsxs3(FeedbackContainer, { children: [
271
+ /* @__PURE__ */ jsx3(FeedbackHeader, { appName, handleClose: handlePopoverClose, loading, sent }),
272
+ /* @__PURE__ */ jsx3(
273
+ FeedbackForm,
274
+ {
266
275
  analytics,
267
276
  appName,
268
277
  handleClose: handlePopoverClose,
@@ -270,12 +279,12 @@ var Feedback = ({ analytics = avLogMessagesApi, appName }) => {
270
279
  sent,
271
280
  setLoading,
272
281
  setSent
273
- })
274
- ]
275
- })
276
- })
277
- ]
278
- });
282
+ }
283
+ )
284
+ ] })
285
+ }
286
+ )
287
+ ] });
279
288
  };
280
289
  export {
281
290
  Feedback
package/jest.config.js CHANGED
@@ -4,4 +4,14 @@ module.exports = {
4
4
  ...global,
5
5
  displayName: 'feedback',
6
6
  coverageDirectory: '../../coverage/feedback',
7
+ /* TODO: Update to latest Jest snapshotFormat
8
+ * By default Nx has kept the older style of Jest Snapshot formats
9
+ * to prevent breaking of any existing tests with snapshots.
10
+ * It's recommend you update to the latest format.
11
+ * You can do this by removing snapshotFormat property
12
+ * and running tests with --update-snapshot flag.
13
+ * Example: From within the project directory, run "nx test --update-snapshot"
14
+ * More info: https://jestjs.io/docs/upgrading-to-jest29#snapshot-format
15
+ */
16
+ snapshotFormat: { escapeString: true, printBasicPrototype: true },
7
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/mui-feedback",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "description": "Availity MUI Feedback Component - part of the @availity/element design system",
5
5
  "keywords": [
6
6
  "react",
@@ -32,11 +32,11 @@
32
32
  "publish:canary": "yarn npm publish --access public --tag canary"
33
33
  },
34
34
  "devDependencies": {
35
- "@mui/material": "^5.11.9",
35
+ "@mui/material": "^5.15.15",
36
36
  "react": "18.2.0",
37
37
  "react-dom": "18.2.0",
38
- "tsup": "^5.12.7",
39
- "typescript": "^4.6.4"
38
+ "tsup": "^8.0.2",
39
+ "typescript": "^5.4.5"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@mui/material": "^5.11.9",
@@ -46,14 +46,14 @@
46
46
  "access": "public"
47
47
  },
48
48
  "dependencies": {
49
- "@availity/api-axios": "^8.0.6",
50
- "@availity/mui-button": "^0.6.6",
51
- "@availity/mui-form-utils": "^0.10.2",
52
- "@availity/mui-icon": "^0.8.1",
53
- "@availity/mui-popover": "^0.1.3",
54
- "@availity/mui-textfield": "^0.5.16",
55
- "@availity/mui-toggle-button": "^0.1.9",
56
- "@availity/mui-typography": "^0.1.7",
57
- "react-hook-form": "^7.48.2"
49
+ "@availity/api-axios": "^8.0.7",
50
+ "@availity/mui-button": "^0.6.7",
51
+ "@availity/mui-form-utils": "^0.11.0",
52
+ "@availity/mui-icon": "^0.8.2",
53
+ "@availity/mui-popover": "^0.1.4",
54
+ "@availity/mui-textfield": "^0.5.18",
55
+ "@availity/mui-toggle-button": "^0.1.10",
56
+ "@availity/mui-typography": "^0.1.8",
57
+ "react-hook-form": "^7.51.3"
58
58
  }
59
59
  }
package/project.json CHANGED
@@ -6,10 +6,9 @@
6
6
  "tags": [],
7
7
  "targets": {
8
8
  "lint": {
9
- "executor": "@nrwl/linter:eslint",
9
+ "executor": "@nx/eslint:lint",
10
10
  "options": {
11
11
  "eslintConfig": ".eslintrc.json",
12
- "lintFilePatterns": ["packages/feedback/**/*.{js,ts}"],
13
12
  "silent": false,
14
13
  "fix": false,
15
14
  "cache": true,
@@ -22,20 +21,20 @@
22
21
  }
23
22
  },
24
23
  "test": {
25
- "executor": "@nrwl/jest:jest",
26
- "outputs": ["coverage/feedback"],
24
+ "executor": "@nx/jest:jest",
25
+ "outputs": ["{workspaceRoot}/coverage/feedback"],
27
26
  "options": {
28
- "jestConfig": "packages/feedback/jest.config.js",
29
- "passWithNoTests": true
27
+ "jestConfig": "packages/feedback/jest.config.js"
30
28
  }
31
29
  },
32
30
  "version": {
33
31
  "executor": "@jscutlery/semver:version",
34
32
  "options": {
35
33
  "preset": "conventional",
36
- "commitMessageFormat": "chore(${projectName}): release version ${version} [skip ci]",
37
- "tagPrefix": "@availity/${projectName}@",
38
- "trackDeps": true
34
+ "commitMessageFormat": "chore({projectName}): release version ${version} [skip ci]",
35
+ "tagPrefix": "@availity/{projectName}@",
36
+ "trackDeps": true,
37
+ "skipCommitTypes": ["docs"]
39
38
  }
40
39
  }
41
40
  }