@bigbinary/neeto-form-frontend 4.4.8 → 4.4.9

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.
Files changed (90) hide show
  1. package/app/javascript/src/translations/ar.json +10 -1
  2. package/app/javascript/src/translations/bg.json +10 -1
  3. package/app/javascript/src/translations/ca.json +10 -1
  4. package/app/javascript/src/translations/cs.json +10 -1
  5. package/app/javascript/src/translations/da.json +10 -1
  6. package/app/javascript/src/translations/de.json +10 -1
  7. package/app/javascript/src/translations/es-MX.json +10 -1
  8. package/app/javascript/src/translations/es.json +10 -1
  9. package/app/javascript/src/translations/et.json +10 -1
  10. package/app/javascript/src/translations/fi.json +10 -1
  11. package/app/javascript/src/translations/fil.json +10 -1
  12. package/app/javascript/src/translations/fr.json +10 -1
  13. package/app/javascript/src/translations/he.json +10 -1
  14. package/app/javascript/src/translations/hi.json +10 -1
  15. package/app/javascript/src/translations/hr.json +10 -1
  16. package/app/javascript/src/translations/hu.json +10 -1
  17. package/app/javascript/src/translations/id.json +10 -1
  18. package/app/javascript/src/translations/it.json +10 -1
  19. package/app/javascript/src/translations/ja.json +10 -1
  20. package/app/javascript/src/translations/ko.json +10 -1
  21. package/app/javascript/src/translations/nl.json +10 -1
  22. package/app/javascript/src/translations/pl.json +10 -1
  23. package/app/javascript/src/translations/pt-BR.json +10 -1
  24. package/app/javascript/src/translations/pt.json +10 -1
  25. package/app/javascript/src/translations/ro.json +10 -1
  26. package/app/javascript/src/translations/ru.json +10 -1
  27. package/app/javascript/src/translations/sk.json +10 -1
  28. package/app/javascript/src/translations/sl.json +10 -1
  29. package/app/javascript/src/translations/sv.json +10 -1
  30. package/app/javascript/src/translations/th.json +10 -1
  31. package/app/javascript/src/translations/tr.json +10 -1
  32. package/app/javascript/src/translations/uk.json +10 -1
  33. package/app/javascript/src/translations/vi.json +10 -1
  34. package/app/javascript/src/translations/zh-CN.json +10 -1
  35. package/app/javascript/src/translations/zh-TW.json +10 -1
  36. package/package.json +1 -1
  37. package/dist/BuildForm.js +0 -3077
  38. package/dist/BuildForm.js.map +0 -1
  39. package/dist/ExternalForm.js +0 -647
  40. package/dist/ExternalForm.js.map +0 -1
  41. package/dist/NeetoFormProvider.js +0 -11
  42. package/dist/NeetoFormProvider.js.map +0 -1
  43. package/dist/Submission.js +0 -2832
  44. package/dist/Submission.js.map +0 -1
  45. package/dist/UrlBuilder.js +0 -317
  46. package/dist/UrlBuilder.js.map +0 -1
  47. package/dist/buildForm-CrOWLvLE.js +0 -35
  48. package/dist/buildForm-CrOWLvLE.js.map +0 -1
  49. package/dist/buildForm-DfMpfuSp.js +0 -38
  50. package/dist/buildForm-DfMpfuSp.js.map +0 -1
  51. package/dist/cjs/BuildForm.js +0 -3098
  52. package/dist/cjs/BuildForm.js.map +0 -1
  53. package/dist/cjs/ExternalForm.js +0 -649
  54. package/dist/cjs/ExternalForm.js.map +0 -1
  55. package/dist/cjs/NeetoFormProvider.js +0 -13
  56. package/dist/cjs/NeetoFormProvider.js.map +0 -1
  57. package/dist/cjs/Submission.js +0 -2834
  58. package/dist/cjs/Submission.js.map +0 -1
  59. package/dist/cjs/UrlBuilder.js +0 -319
  60. package/dist/cjs/UrlBuilder.js.map +0 -1
  61. package/dist/cjs/hooks.js +0 -33
  62. package/dist/cjs/hooks.js.map +0 -1
  63. package/dist/cjs/index.js +0 -113
  64. package/dist/cjs/index.js.map +0 -1
  65. package/dist/constants-Cj0XxE8a.js +0 -494
  66. package/dist/constants-Cj0XxE8a.js.map +0 -1
  67. package/dist/constants-D5JlvWws.js +0 -513
  68. package/dist/constants-D5JlvWws.js.map +0 -1
  69. package/dist/hooks.js +0 -20
  70. package/dist/hooks.js.map +0 -1
  71. package/dist/index-Beo6ztaM.js +0 -51
  72. package/dist/index-Beo6ztaM.js.map +0 -1
  73. package/dist/index-DhtQJpD_.js +0 -43
  74. package/dist/index-DhtQJpD_.js.map +0 -1
  75. package/dist/index.js +0 -95
  76. package/dist/index.js.map +0 -1
  77. package/dist/main.css +0 -2
  78. package/dist/main.css.map +0 -1
  79. package/dist/useFormSubmission-D3O7sDHp.js +0 -24
  80. package/dist/useFormSubmission-D3O7sDHp.js.map +0 -1
  81. package/dist/useFormSubmission-PLRMfzJ3.js +0 -22
  82. package/dist/useFormSubmission-PLRMfzJ3.js.map +0 -1
  83. package/dist/utils-CI844li1.js +0 -2718
  84. package/dist/utils-CI844li1.js.map +0 -1
  85. package/dist/utils-baAzU7l8.js +0 -2749
  86. package/dist/utils-baAzU7l8.js.map +0 -1
  87. package/dist/yup-CSYHMEsr.js +0 -1014
  88. package/dist/yup-CSYHMEsr.js.map +0 -1
  89. package/dist/yup-DMlViLLB.js +0 -1097
  90. package/dist/yup-DMlViLLB.js.map +0 -1
@@ -1,649 +0,0 @@
1
- 'use strict';
2
-
3
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
- var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
5
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
6
- var _regeneratorRuntime = require('@babel/runtime/regenerator');
7
- var React = require('react');
8
- var reactQuery = require('@tanstack/react-query');
9
- var classnames = require('classnames');
10
- var formik = require('formik');
11
- var i18next = require('i18next');
12
- var neetoCist = require('@bigbinary/neeto-cist');
13
- var useHotkeys = require('@bigbinary/neeto-hotkeys');
14
- var Warning = require('@bigbinary/neeto-icons/Warning');
15
- var Typography = require('@bigbinary/neetoui/Typography');
16
- var Button$1 = require('@bigbinary/neetoui/Button');
17
- var Spinner$2 = require('@bigbinary/neetoui/Spinner');
18
- var NeetoUICallout = require('@bigbinary/neetoui/Callout');
19
- var NoData = require('@bigbinary/neetoui/NoData');
20
- var ramda = require('ramda');
21
- var reactI18next = require('react-i18next');
22
- var constants = require('../constants-D5JlvWws.js');
23
- var Close = require('@bigbinary/neeto-icons/Close');
24
- var index$1 = require('../index-Beo6ztaM.js');
25
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
26
- var Check = require('@bigbinary/neeto-icons/Check');
27
- var jsxRuntime = require('react/jsx-runtime');
28
- var yup = require('../yup-DMlViLLB.js');
29
- var utils = require('../utils-baAzU7l8.js');
30
- var utils$1 = require('@bigbinary/neeto-commons-frontend/utils');
31
- var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
32
- var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
33
- require('@babel/runtime/helpers/toConsumableArray');
34
- require('@bigbinary/neeto-commons-frontend/constants');
35
- require('axios');
36
- require('@babel/runtime/helpers/typeof');
37
- require('@bigbinary/neeto-editor/utils');
38
- require('dompurify');
39
- require('@bigbinary/neeto-icons/Plus');
40
- require('yup');
41
- require('libphonenumber-js');
42
- require('@bigbinary/neeto-editor/EditorContent');
43
- require('@bigbinary/neetoui/MultiEmailInput');
44
- require('@bigbinary/neeto-molecules/PhoneNumber');
45
- require('@babel/runtime/helpers/toArray');
46
- require('@bigbinary/neetoui/Select');
47
- require('@bigbinary/neetoui/Input');
48
- require('@bigbinary/neeto-icons/Refresh');
49
- require('@bigbinary/neeto-commons-frontend/initializers');
50
- require('react-google-recaptcha');
51
- require('@bigbinary/neetoui/Checkbox');
52
- require('@bigbinary/neetoui/DatePicker');
53
- require('@bigbinary/neetoui/Toastr');
54
- require('@bigbinary/neeto-icons/CheckCircle');
55
- require('@bigbinary/neeto-molecules/FileUpload');
56
- require('@bigbinary/neetoui/Label');
57
- require('@bigbinary/neetoui/Radio');
58
- require('@bigbinary/neeto-icons/Image');
59
- require('@bigbinary/neeto-editor/Editor');
60
- require('@bigbinary/neeto-icons/Info');
61
- require('@bigbinary/neetoui/Textarea');
62
- require('@bigbinary/neetoui/Tag');
63
-
64
- var Spinner = function Spinner(_ref) {
65
- var _ref$size = _ref.size,
66
- size = _ref$size === void 0 ? 24 : _ref$size;
67
- return /*#__PURE__*/jsxRuntime.jsx("div", {
68
- className: "neeto-form-engine-spinner",
69
- children: /*#__PURE__*/jsxRuntime.jsx("svg", {
70
- fill: "none",
71
- height: size,
72
- viewBox: "0 0 25 24",
73
- width: size,
74
- xmlns: "http://www.w3.org/2000/svg",
75
- children: /*#__PURE__*/jsxRuntime.jsx("path", {
76
- d: "M12.5 5.00098V8.75M17.4401 7.04867L14.9888 9.5M19.5008 11.9994H15.5M17.4401 16.9372L14.9888 14.4859M12.5023 18.9979V15M7.5516 16.9372L10.4888 14M5.50391 11.9994H9.5M7.5516 7.04867L10.0029 9.5",
77
- stroke: "#87929D",
78
- strokeLinecap: "round",
79
- strokeLinejoin: "round",
80
- strokeWidth: "1.5"
81
- })
82
- })
83
- });
84
- };
85
- var Spinner$1 = /*#__PURE__*/React.memo(Spinner);
86
-
87
- var _excluded = ["label", "loading", "success", "className"];
88
- function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
89
- function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
90
- var Button = function Button(_ref) {
91
- var label = _ref.label,
92
- _ref$loading = _ref.loading,
93
- loading = _ref$loading === void 0 ? false : _ref$loading,
94
- _ref$success = _ref.success,
95
- success = _ref$success === void 0 ? false : _ref$success,
96
- _ref$className = _ref.className,
97
- className = _ref$className === void 0 ? "" : _ref$className,
98
- otherProps = _objectWithoutProperties(_ref, _excluded);
99
- return /*#__PURE__*/jsxRuntime.jsxs("button", _objectSpread$2(_objectSpread$2({
100
- className: classnames("neeto-form-engine-button", className)
101
- }, otherProps), {}, {
102
- children: [loading && /*#__PURE__*/jsxRuntime.jsx(ButtonLoader, {}), success && /*#__PURE__*/jsxRuntime.jsx(Success$2, {}), label]
103
- }));
104
- };
105
- var ButtonLoader = function ButtonLoader() {
106
- return /*#__PURE__*/jsxRuntime.jsx("div", {
107
- className: "neeto-form-engine-button__loader",
108
- children: /*#__PURE__*/jsxRuntime.jsx(Spinner$1, {})
109
- });
110
- };
111
- var Success$2 = function Success() {
112
- return /*#__PURE__*/jsxRuntime.jsx("div", {
113
- className: "neeto-form-engine-button__success",
114
- children: /*#__PURE__*/jsxRuntime.jsx(Check, {})
115
- });
116
- };
117
-
118
- var Callout = function Callout(_ref) {
119
- var _ref$style = _ref.style,
120
- style = _ref$style === void 0 ? yup.CALLOUT_STYLES.ERROR : _ref$style,
121
- _ref$position = _ref.position,
122
- position = _ref$position === void 0 ? yup.CALLOUT_POSITIONS.ABSOLUTE : _ref$position,
123
- _ref$callout = _ref.callout,
124
- callout = _ref$callout === void 0 ? {} : _ref$callout,
125
- children = _ref.children,
126
- className = _ref.className,
127
- onClose = _ref.onClose;
128
- var isVisible = callout.isVisible,
129
- title = callout.title,
130
- message = callout.message,
131
- primaryButton = callout.primaryButton,
132
- secondaryButton = callout.secondaryButton;
133
- if (!isVisible) return null;
134
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
135
- className: classnames("neeto-form-engine-callout", _defineProperty({
136
- "neeto-form-engine-callout--error": style === yup.CALLOUT_STYLES.ERROR,
137
- "neeto-form-engine-callout--info": style === yup.CALLOUT_STYLES.INFO,
138
- "neeto-form-engine-callout--static": position === yup.CALLOUT_POSITIONS.STATIC,
139
- "neeto-form-engine-callout--absolute": position === yup.CALLOUT_POSITIONS.ABSOLUTE
140
- }, className, className)),
141
- children: [neetoCist.isPresent(onClose) && /*#__PURE__*/jsxRuntime.jsx("button", {
142
- className: "neeto-form-engine-callout__close",
143
- onClick: onClose,
144
- children: /*#__PURE__*/jsxRuntime.jsx(Close, {
145
- size: 16
146
- })
147
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
148
- className: "neeto-form-engine-callout__content",
149
- children: [ramda.not(index$1.isBlank(title)) && /*#__PURE__*/jsxRuntime.jsx("h5", {
150
- children: title
151
- }), /*#__PURE__*/jsxRuntime.jsx("p", {
152
- children: message
153
- })]
154
- }), primaryButton && /*#__PURE__*/jsxRuntime.jsx(Button, {
155
- label: primaryButton.label,
156
- size: "small",
157
- onClick: primaryButton.onClick
158
- }), secondaryButton && /*#__PURE__*/jsxRuntime.jsx(Button, {
159
- label: secondaryButton.label,
160
- size: "small",
161
- onClick: secondaryButton.onClick
162
- }), children]
163
- });
164
- };
165
-
166
- function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
167
- function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
168
- var withI18nInstance = function withI18nInstance(Component, i18n) {
169
- var I18nWrapper = function I18nWrapper(props) {
170
- return /*#__PURE__*/jsxRuntime.jsx(reactI18next.I18nextProvider, {
171
- i18n: i18n,
172
- children: /*#__PURE__*/jsxRuntime.jsx(Component, _objectSpread$1({}, props))
173
- });
174
- };
175
- I18nWrapper.displayName = "I18nWrapper(".concat(index$1.getComponentDisplayName(Component), ")");
176
- return I18nWrapper;
177
- };
178
-
179
- var useIsMounted = function useIsMounted() {
180
- var isMounted = React.useRef(true);
181
- React.useEffect(function () {
182
- return function () {
183
- isMounted.current = false;
184
- };
185
- }, []);
186
- return function () {
187
- return isMounted.current;
188
- };
189
- };
190
-
191
- var Success = reactUtils.withT(function (_ref) {
192
- var t = _ref.t;
193
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
194
- className: "neeto-form-nano-external-form-thank-you flex h-full w-full flex-col items-center justify-center space-y-3 py-20",
195
- children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
196
- style: "h1",
197
- children: "\uD83C\uDF89"
198
- }), /*#__PURE__*/jsxRuntime.jsx(Typography, {
199
- className: "text-center",
200
- style: "h2",
201
- children: t("neetoForm.successPage.title1")
202
- }), /*#__PURE__*/jsxRuntime.jsx(Typography, {
203
- className: "text-center",
204
- style: "body2",
205
- children: t("neetoForm.successPage.title2")
206
- })]
207
- });
208
- });
209
- var Success$1 = /*#__PURE__*/React.memo(Success);
210
-
211
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
212
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
213
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
214
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
215
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
216
- var ExternalForm = function ExternalForm(_ref) {
217
- var _path, _formikInnerRef$curre;
218
- var _ref$size = _ref.size,
219
- size = _ref$size === void 0 ? "medium" : _ref$size,
220
- _ref$preview = _ref.preview,
221
- preview = _ref$preview === void 0 ? false : _ref$preview,
222
- formId = _ref.formId,
223
- submissionId = _ref.submissionId,
224
- customSubmitHandler = _ref.customSubmitHandler,
225
- onBeforeSubmit = _ref.onBeforeSubmit,
226
- onSubmitSuccess = _ref.onSubmitSuccess,
227
- _ref$showTitle = _ref.showTitle,
228
- showTitle = _ref$showTitle === void 0 ? true : _ref$showTitle,
229
- formTitle = _ref.formTitle,
230
- submitButtonProps = _ref.submitButtonProps,
231
- cancelButtonProps = _ref.cancelButtonProps,
232
- resetButtonProps = _ref.resetButtonProps,
233
- _ref$displayThankYou = _ref.displayThankYou,
234
- displayThankYou = _ref$displayThankYou === void 0 ? true : _ref$displayThankYou,
235
- _ref$showEmptyState = _ref.showEmptyState,
236
- showEmptyState = _ref$showEmptyState === void 0 ? true : _ref$showEmptyState,
237
- className = _ref.className,
238
- _ref$preserveValues = _ref.preserveValues,
239
- preserveValues = _ref$preserveValues === void 0 ? false : _ref$preserveValues,
240
- _ref$clearValuesOnRes = _ref.clearValuesOnReset,
241
- clearValuesOnReset = _ref$clearValuesOnRes === void 0 ? false : _ref$clearValuesOnRes,
242
- _ref$clearValuesOnSub = _ref.clearValuesOnSubmit,
243
- clearValuesOnSubmit = _ref$clearValuesOnSub === void 0 ? false : _ref$clearValuesOnSub,
244
- _ref$initialValues = _ref.initialValues,
245
- initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
246
- onChange = _ref.onChange,
247
- formDomProps = _ref.formDomProps,
248
- _ref$editorProps = _ref.editorProps,
249
- editorProps = _ref$editorProps === void 0 ? {} : _ref$editorProps,
250
- customValidator = _ref.customValidator,
251
- _ref$autoCompleteKind = _ref.autoCompleteKinds,
252
- autoCompleteKinds = _ref$autoCompleteKind === void 0 ? [] : _ref$autoCompleteKind,
253
- _ref$enablePreFilling = _ref.enablePreFilling,
254
- enablePreFilling = _ref$enablePreFilling === void 0 ? false : _ref$enablePreFilling,
255
- _ref$language = _ref.language,
256
- language = _ref$language === void 0 ? i18next.resolvedLanguage : _ref$language,
257
- _ref$remainingSlotsCo = _ref.remainingSlotsCount,
258
- remainingSlotsCount = _ref$remainingSlotsCo === void 0 ? null : _ref$remainingSlotsCo;
259
- var _useState = React.useState(false),
260
- _useState2 = _slicedToArray(_useState, 2),
261
- isSubmitted = _useState2[0],
262
- setIsSubmitted = _useState2[1];
263
- var _useState3 = React.useState(false),
264
- _useState4 = _slicedToArray(_useState3, 2),
265
- showSuccess = _useState4[0],
266
- setShowSuccess = _useState4[1];
267
- var _useState5 = React.useState(utils.getWithExpiry("".concat(formId, "/values"))),
268
- _useState6 = _slicedToArray(_useState5, 2),
269
- localValues = _useState6[0],
270
- setLocalValues = _useState6[1];
271
- var isMounted = useIsMounted();
272
- var _useState7 = React.useState(null),
273
- _useState8 = _slicedToArray(_useState7, 2),
274
- error = _useState8[0],
275
- setError = _useState8[1];
276
- var formRef = React.useRef();
277
- var formikInnerRef = React.useRef();
278
- var editorRef = React.useRef();
279
- var captchaRef = React.useRef(null);
280
- var queryClient = reactQuery.useQueryClient();
281
- var _usePublicForm = constants.usePublicForm({
282
- formId: formId,
283
- language: language,
284
- preview: preview,
285
- enabled: !preview
286
- }),
287
- _usePublicForm$data = _usePublicForm.data,
288
- form = _usePublicForm$data === void 0 ? {
289
- title: "",
290
- questions: [],
291
- isQuestionsLoading: true
292
- } : _usePublicForm$data,
293
- isLoading = _usePublicForm.isLoading;
294
- var title = form.title,
295
- _form$questions = form.questions,
296
- questions = _form$questions === void 0 ? [] : _form$questions;
297
- var formUuid = (_path = ramda.path([0, "formId"], questions)) !== null && _path !== void 0 ? _path : formId;
298
- React.useEffect(function () {
299
- if (ramda.equals(language, utils.clientI18nInstance.resolvedLanguage)) return;
300
- utils.clientI18nInstance.changeLanguage(language);
301
- }, [language]);
302
- React.useEffect(function () {
303
- if (!preserveValues) utils.clearEmailVerificationDetails(formUuid);
304
- }, []);
305
- var _useTranslation = reactI18next.useTranslation(),
306
- t = _useTranslation.t;
307
- React.useEffect(function () {
308
- setLocalValues(utils.getWithExpiry("".concat(formId, "/values")));
309
- }, [formId]);
310
- var _useCreateSubmission = constants.useCreateSubmission({
311
- enabled: !submissionId
312
- }),
313
- createSubmission = _useCreateSubmission.mutateAsync;
314
- var _useUpdateSubmission = constants.useUpdateSubmission({
315
- enabled: !!submissionId
316
- }),
317
- updateSubmission = _useUpdateSubmission.mutateAsync;
318
- var _useSubmission = constants.useSubmission({
319
- formId: formId,
320
- submissionId: submissionId,
321
- placeholderData: submissionId ? {
322
- responses: [],
323
- isLoading: true
324
- } : {},
325
- enabled: !!submissionId
326
- }),
327
- submission = _useSubmission.data;
328
- var clearLocalFormValues = function clearLocalFormValues() {
329
- return utils.clearLocalStorageValues("".concat(formId, "/values"));
330
- };
331
- var onSubmit = /*#__PURE__*/function () {
332
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, _ref2) {
333
- var setSubmitting, responses, newResponses, data;
334
- return _regeneratorRuntime.wrap(function _callee$(_context) {
335
- while (1) switch (_context.prev = _context.next) {
336
- case 0:
337
- setSubmitting = _ref2.setSubmitting;
338
- setError(null);
339
- responses = utils.generateFormResponse(values, questions);
340
- _context.prev = 3;
341
- if (!preview) {
342
- _context.next = 9;
343
- break;
344
- }
345
- _context.next = 7;
346
- return new Promise(function (resolve) {
347
- return setTimeout(function () {
348
- resolve();
349
- setIsSubmitted(true);
350
- setTimeout(function () {
351
- return setShowSuccess(true);
352
- }, 1000);
353
- }, 1500);
354
- });
355
- case 7:
356
- _context.next = 34;
357
- break;
358
- case 9:
359
- if (!onBeforeSubmit) {
360
- _context.next = 14;
361
- break;
362
- }
363
- _context.next = 12;
364
- return onBeforeSubmit(responses, values);
365
- case 12:
366
- newResponses = _context.sent;
367
- if (newResponses) {
368
- responses = newResponses;
369
- }
370
- case 14:
371
- if (!customSubmitHandler) {
372
- _context.next = 21;
373
- break;
374
- }
375
- _context.next = 17;
376
- return customSubmitHandler({
377
- responses: responses,
378
- values: values
379
- }, clearLocalFormValues);
380
- case 17:
381
- data = _context.sent;
382
- queryClient.invalidateQueries({
383
- queryKey: [constants.QUERY_KEYS.SUBMISSION, formId, submissionId]
384
- });
385
- _context.next = 30;
386
- break;
387
- case 21:
388
- if (!submissionId) {
389
- _context.next = 27;
390
- break;
391
- }
392
- _context.next = 24;
393
- return updateSubmission({
394
- formId: formId,
395
- values: {
396
- neetoFormResponse: {
397
- submissionId: submissionId,
398
- responses: responses
399
- }
400
- }
401
- });
402
- case 24:
403
- data = _context.sent;
404
- _context.next = 30;
405
- break;
406
- case 27:
407
- _context.next = 29;
408
- return createSubmission({
409
- formId: formId,
410
- values: {
411
- neetoFormResponse: {
412
- responses: responses
413
- }
414
- }
415
- });
416
- case 29:
417
- data = _context.sent;
418
- case 30:
419
- clearValuesOnSubmit && clearLocalFormValues();
420
- setTimeout(function () {
421
- return utils.clearEmailVerificationDetails(formUuid);
422
- }, 1000);
423
- onSubmitSuccess === null || onSubmitSuccess === void 0 || onSubmitSuccess({
424
- values: values,
425
- responses: responses,
426
- data: data
427
- }, clearLocalFormValues);
428
- if (isMounted()) {
429
- setIsSubmitted(true);
430
- setTimeout(function () {
431
- return setShowSuccess(true);
432
- }, 1000);
433
- }
434
- case 34:
435
- _context.next = 39;
436
- break;
437
- case 36:
438
- _context.prev = 36;
439
- _context.t0 = _context["catch"](3);
440
- setError(index$1.parseServerError(_context.t0));
441
- case 39:
442
- _context.prev = 39;
443
- if (isMounted()) {
444
- setSubmitting(false);
445
- }
446
- return _context.finish(39);
447
- case 42:
448
- case "end":
449
- return _context.stop();
450
- }
451
- }, _callee, null, [[3, 36, 39, 42]]);
452
- }));
453
- return function onSubmit(_x, _x2) {
454
- return _ref3.apply(this, arguments);
455
- };
456
- }();
457
- var _onReset = function onReset(e, handleReset) {
458
- var _editorRef$current, _captchaRef$current, _formDomProps$onReset;
459
- if (clearValuesOnReset) {
460
- utils.clearLocalStorageValues("".concat(formId, "/values"));
461
- setLocalValues(utils.generateInitValues({
462
- questions: questions
463
- }));
464
- submissionId && queryClient.setQueryData([constants.QUERY_KEYS.SUBMISSION, formId, submissionId], {
465
- responses: []
466
- });
467
- }
468
- editorRef === null || editorRef === void 0 || (_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 || (_editorRef$current = _editorRef$current.editor) === null || _editorRef$current === void 0 || (_editorRef$current = _editorRef$current.commands) === null || _editorRef$current === void 0 || _editorRef$current.setContent("");
469
- (_captchaRef$current = captchaRef.current) === null || _captchaRef$current === void 0 || _captchaRef$current.reset();
470
- handleReset(e);
471
- formDomProps === null || formDomProps === void 0 || (_formDomProps$onReset = formDomProps.onReset) === null || _formDomProps$onReset === void 0 || _formDomProps$onReset.call(formDomProps, e);
472
- utils.clearEmailVerificationDetails(formUuid);
473
- };
474
- var handleScrollToError = function handleScrollToError(errors) {
475
- if (!formRef.current) return;
476
- var errorKeys = Object.keys(errors);
477
- if (ramda.isEmpty(errorKeys)) return;
478
- var _iterator = _createForOfIteratorHelper(formRef.current),
479
- _step;
480
- try {
481
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
482
- var formElement = _step.value;
483
- if (errorKeys.includes(formElement.name)) {
484
- formElement.scrollIntoView({
485
- behavior: "smooth",
486
- block: "center"
487
- });
488
- break;
489
- }
490
- }
491
- } catch (err) {
492
- _iterator.e(err);
493
- } finally {
494
- _iterator.f();
495
- }
496
- };
497
- var _queryClient$getQuery = queryClient.getQueryState([constants.QUERY_KEYS.QUESTIONS, formId, language]),
498
- dataUpdateCount = _queryClient$getQuery.dataUpdateCount;
499
- var keyPressRef = useHotkeys("command+enter", ((_formikInnerRef$curre = formikInnerRef.current) === null || _formikInnerRef$curre === void 0 ? void 0 : _formikInnerRef$curre.handleSubmit) || neetoCist.noop, {
500
- mode: "scoped"
501
- });
502
- if (isLoading || form.isQuestionsLoading || !!submissionId && submission !== null && submission !== void 0 && submission.isLoading) {
503
- return /*#__PURE__*/jsxRuntime.jsx("div", {
504
- className: "loader flex h-full w-full items-center justify-center",
505
- children: /*#__PURE__*/jsxRuntime.jsx(PageLoader, {})
506
- });
507
- }
508
- var displayTitle = formTitle || title;
509
- var renderedQuestions = preview ? questions : neetoCist.removeBy({
510
- isHidden: true
511
- }, questions);
512
- if (displayThankYou && showSuccess) {
513
- return /*#__PURE__*/jsxRuntime.jsx(Success$1, {});
514
- }
515
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
516
- className: classnames("neeto-form-nano-external-form", {
517
- "neeto-form-nano-external-form--size-large": size === "large",
518
- "neeto-form-nano-external-form--size-medium": size === "medium"
519
- }),
520
- children: [showTitle && displayTitle && /*#__PURE__*/jsxRuntime.jsx("div", {
521
- className: "neeto-form-nano-external-form-header py-6",
522
- children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
523
- className: "neeto-ui-text-gray-800 neeto-form-nano-external-form-title",
524
- style: "h4",
525
- weight: "semibold",
526
- children: displayTitle
527
- })
528
- }), /*#__PURE__*/jsxRuntime.jsx(formik.Formik, {
529
- onSubmit: onSubmit,
530
- enableReinitialize: true,
531
- innerRef: formikInnerRef,
532
- initialValues: utils.generateInitValues({
533
- questions: questions,
534
- initialValues: submission === null || submission === void 0 ? void 0 : submission.responses,
535
- localValues: preserveValues ? localValues : initialValues,
536
- fieldCodes: enablePreFilling ? utils$1.getQueryParams({
537
- toCamelCase: false
538
- }) : {},
539
- remainingSlotsCount: remainingSlotsCount
540
- }),
541
- children: function children(_ref4) {
542
- var isSubmitting = _ref4.isSubmitting,
543
- errors = _ref4.errors,
544
- setFieldError = _ref4.setFieldError,
545
- handleReset = _ref4.handleReset;
546
- return /*#__PURE__*/jsxRuntime.jsxs(utils.FormikWrap, {
547
- dataUpdateCount: dataUpdateCount,
548
- formId: formId,
549
- preserveValues: preserveValues,
550
- onError: handleScrollToError,
551
- onValuesChange: onChange,
552
- children: [/*#__PURE__*/jsxRuntime.jsxs(formik.Form, _objectSpread(_objectSpread({
553
- noValidate: true,
554
- ref: utils.mergeRefs(formRef, keyPressRef),
555
- className: classnames("neeto-form-engine-form relative", _defineProperty({
556
- "space-y-6": size === "large",
557
- "space-y-4": size === "medium"
558
- }, className, className)),
559
- onChange: function onChange(event) {
560
- if (ramda.isEmpty(errors)) return;
561
- setFieldError(event.target.name, "");
562
- }
563
- }, formDomProps), {}, {
564
- onReset: function onReset(e) {
565
- return _onReset(e, handleReset);
566
- },
567
- children: [(submission === null || submission === void 0 ? void 0 : submission.isLoading) && /*#__PURE__*/jsxRuntime.jsx("div", {
568
- className: "neeto-ui-bg-gray-100 absolute bottom-0 start-0 end-0 top-0 flex items-center justify-center opacity-75",
569
- children: /*#__PURE__*/jsxRuntime.jsx(Spinner$2, {})
570
- }), renderedQuestions.map(function (question, index) {
571
- var _question$id;
572
- var FieldComponent = utils.getFieldComponent(question);
573
- var isLastFewElements = index >= renderedQuestions.length - yup.LAST_ELEMENTS_THRESHOLD;
574
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
575
- className: "w-full flex flex-col gap-2",
576
- children: [/*#__PURE__*/jsxRuntime.jsx(FieldComponent, _objectSpread(_objectSpread({}, _objectSpread({
577
- captchaRef: captchaRef,
578
- editorProps: editorProps,
579
- editorRef: editorRef,
580
- isLastFewElements: isLastFewElements,
581
- preview: preview,
582
- question: question
583
- }, question.kind === yup.QUESTION_KIND.SPOT.value && typeof remainingSlotsCount === "number" && {
584
- remainingSlotsCount: remainingSlotsCount
585
- })), {}, {
586
- customValidator: customValidator === null || customValidator === void 0 ? void 0 : customValidator(question),
587
- autoComplete: utils.buildAutoCompleteAttribute(question.kind, autoCompleteKinds, formDomProps)
588
- })), question.isHidden && /*#__PURE__*/jsxRuntime.jsx(NeetoUICallout, {
589
- "data-testid": "hidden-question-callout",
590
- icon: Warning,
591
- style: "warning",
592
- children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
593
- style: "body2",
594
- children: t("neetoForm.callouts.hiddenQuestion")
595
- })
596
- }), preview && question.isResponseVisibleOnlyToHost && /*#__PURE__*/jsxRuntime.jsx(NeetoUICallout, {
597
- "data-testid": "response-visible-only-to-host-callout",
598
- icon: Warning,
599
- style: "warning",
600
- children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
601
- style: "body2",
602
- children: t("neetoForm.callouts.responseVisibleOnlyToHost")
603
- })
604
- })]
605
- }, (_question$id = question.id) !== null && _question$id !== void 0 ? _question$id : question.nodeId);
606
- }), showEmptyState && ramda.isEmpty(renderedQuestions) && /*#__PURE__*/jsxRuntime.jsx("div", {
607
- className: "flex w-full grow items-center justify-center py-8",
608
- children: /*#__PURE__*/jsxRuntime.jsx(NoData, {
609
- className: "min-h-80",
610
- title: t("neetoForm.questions.common.noData")
611
- })
612
- }), !ramda.isEmpty(renderedQuestions) && /*#__PURE__*/jsxRuntime.jsxs("div", {
613
- className: "neeto-form-nano-form-footer mt-8 flex items-center justify-between",
614
- children: [cancelButtonProps && /*#__PURE__*/jsxRuntime.jsx(Button$1, _objectSpread({
615
- label: t("neetoForm.common.cancel"),
616
- style: "secondary"
617
- }, cancelButtonProps)), /*#__PURE__*/jsxRuntime.jsx("div", {
618
- className: "flex gap-x-2",
619
- children: utils.renderButtonsInOrder([/*#__PURE__*/jsxRuntime.jsx(Button$1, _objectSpread({
620
- disabled: isSubmitting || isSubmitted,
621
- label: t("neetoForm.common.submit"),
622
- loading: isSubmitting,
623
- type: "submit"
624
- }, submitButtonProps), "submit"), /*#__PURE__*/jsxRuntime.jsx(Button$1, _objectSpread({
625
- label: t("neetoForm.common.reset"),
626
- style: "secondary",
627
- type: "reset"
628
- }, resetButtonProps), "reset")], neetoCist.isPresent(cancelButtonProps))
629
- })]
630
- })]
631
- })), !customSubmitHandler && /*#__PURE__*/jsxRuntime.jsx(Callout, {
632
- callout: {
633
- isVisible: neetoCist.isPresent(error),
634
- title: t("neetoForm.callouts.submitError"),
635
- message: error
636
- },
637
- onClose: function onClose() {
638
- return setError(null);
639
- }
640
- })]
641
- });
642
- }
643
- })]
644
- });
645
- };
646
- var index = withI18nInstance(ExternalForm, utils.clientI18nInstance);
647
-
648
- module.exports = index;
649
- //# sourceMappingURL=ExternalForm.js.map