@bigbinary/neeto-form-frontend 4.4.6 → 4.4.7

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 (58) hide show
  1. package/README.md +4 -1
  2. package/app/javascript/src/translations/en.json +10 -1
  3. package/package.json +1 -5
  4. package/types.d.ts +1 -0
  5. package/dist/BuildForm.js +0 -3035
  6. package/dist/BuildForm.js.map +0 -1
  7. package/dist/ExternalForm.js +0 -639
  8. package/dist/ExternalForm.js.map +0 -1
  9. package/dist/NeetoFormProvider.js +0 -11
  10. package/dist/NeetoFormProvider.js.map +0 -1
  11. package/dist/Submission.js +0 -2832
  12. package/dist/Submission.js.map +0 -1
  13. package/dist/UrlBuilder.js +0 -309
  14. package/dist/UrlBuilder.js.map +0 -1
  15. package/dist/buildForm-CgofRtEN.js +0 -38
  16. package/dist/buildForm-CgofRtEN.js.map +0 -1
  17. package/dist/buildForm-D-epUrZG.js +0 -35
  18. package/dist/buildForm-D-epUrZG.js.map +0 -1
  19. package/dist/cjs/BuildForm.js +0 -3056
  20. package/dist/cjs/BuildForm.js.map +0 -1
  21. package/dist/cjs/ExternalForm.js +0 -641
  22. package/dist/cjs/ExternalForm.js.map +0 -1
  23. package/dist/cjs/NeetoFormProvider.js +0 -13
  24. package/dist/cjs/NeetoFormProvider.js.map +0 -1
  25. package/dist/cjs/Submission.js +0 -2834
  26. package/dist/cjs/Submission.js.map +0 -1
  27. package/dist/cjs/UrlBuilder.js +0 -311
  28. package/dist/cjs/UrlBuilder.js.map +0 -1
  29. package/dist/cjs/hooks.js +0 -33
  30. package/dist/cjs/hooks.js.map +0 -1
  31. package/dist/cjs/index.js +0 -112
  32. package/dist/cjs/index.js.map +0 -1
  33. package/dist/constants-BNfHPNOx.js +0 -493
  34. package/dist/constants-BNfHPNOx.js.map +0 -1
  35. package/dist/constants-CfUZ9B6N.js +0 -512
  36. package/dist/constants-CfUZ9B6N.js.map +0 -1
  37. package/dist/hooks.js +0 -20
  38. package/dist/hooks.js.map +0 -1
  39. package/dist/index-0m1EzLFY.js +0 -51
  40. package/dist/index-0m1EzLFY.js.map +0 -1
  41. package/dist/index-y4GiXx7o.js +0 -43
  42. package/dist/index-y4GiXx7o.js.map +0 -1
  43. package/dist/index.js +0 -94
  44. package/dist/index.js.map +0 -1
  45. package/dist/main.css +0 -2
  46. package/dist/main.css.map +0 -1
  47. package/dist/useFormSubmission-Cx63P761.js +0 -22
  48. package/dist/useFormSubmission-Cx63P761.js.map +0 -1
  49. package/dist/useFormSubmission-DyS5Dm1q.js +0 -24
  50. package/dist/useFormSubmission-DyS5Dm1q.js.map +0 -1
  51. package/dist/utils-C9nDMm4c.js +0 -2652
  52. package/dist/utils-C9nDMm4c.js.map +0 -1
  53. package/dist/utils-DEBFghm4.js +0 -2683
  54. package/dist/utils-DEBFghm4.js.map +0 -1
  55. package/dist/yup-CMEoabdy.js +0 -1076
  56. package/dist/yup-CMEoabdy.js.map +0 -1
  57. package/dist/yup-Dx1WK2_p.js +0 -995
  58. package/dist/yup-Dx1WK2_p.js.map +0 -1
@@ -1,2683 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var formik = require('formik');
5
- var neetoCist = require('@bigbinary/neeto-cist');
6
- var index = require('./index-0m1EzLFY.js');
7
- var utils = require('@bigbinary/neeto-commons-frontend/utils');
8
- var libphonenumberJs = require('libphonenumber-js');
9
- var ramda = require('ramda');
10
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
11
- var EditorContent = require('@bigbinary/neeto-editor/EditorContent');
12
- var constants = require('./constants-CfUZ9B6N.js');
13
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
14
- var Plus = require('@bigbinary/neeto-icons/Plus');
15
- var Button = require('@bigbinary/neetoui/Button');
16
- var NeetoUIMultiEmailInput = require('@bigbinary/neetoui/MultiEmailInput');
17
- var reactI18next = require('react-i18next');
18
- var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
19
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
20
- var _regeneratorRuntime = require('@babel/runtime/regenerator');
21
- var utils$1 = require('@bigbinary/neeto-editor/utils');
22
- var PhoneNumber = require('@bigbinary/neeto-molecules/PhoneNumber');
23
- var i18next = require('i18next');
24
- var jsxRuntime = require('react/jsx-runtime');
25
- var yup = require('./yup-CMEoabdy.js');
26
- var _toArray = require('@babel/runtime/helpers/toArray');
27
- var yup$1 = require('yup');
28
- var classnames = require('classnames');
29
- var Select = require('@bigbinary/neetoui/Select');
30
- var Input = require('@bigbinary/neetoui/Input');
31
- var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
32
- var Refresh = require('@bigbinary/neeto-icons/Refresh');
33
- var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
34
- var initializers = require('@bigbinary/neeto-commons-frontend/initializers');
35
- var ReCAPTCHA = require('react-google-recaptcha');
36
- var Checkbox = require('@bigbinary/neetoui/Checkbox');
37
- var DatePicker = require('@bigbinary/neetoui/DatePicker');
38
- var Toastr = require('@bigbinary/neetoui/Toastr');
39
- var reactQuery = require('@tanstack/react-query');
40
- var axios = require('axios');
41
- var CheckCircle = require('@bigbinary/neeto-icons/CheckCircle');
42
- var Spinner = require('@bigbinary/neetoui/Spinner');
43
- var NeetoUICallout = require('@bigbinary/neetoui/Callout');
44
- var FileUpload = require('@bigbinary/neeto-molecules/FileUpload');
45
- var Label = require('@bigbinary/neetoui/Label');
46
- var Radio = require('@bigbinary/neetoui/Radio');
47
- var Image = require('@bigbinary/neeto-icons/Image');
48
- var NeetoEditor = require('@bigbinary/neeto-editor/Editor');
49
- var Textarea = require('@bigbinary/neetoui/Textarea');
50
-
51
- function _interopNamespaceDefault(e) {
52
- var n = Object.create(null);
53
- if (e) {
54
- Object.keys(e).forEach(function (k) {
55
- if (k !== 'default') {
56
- var d = Object.getOwnPropertyDescriptor(e, k);
57
- Object.defineProperty(n, k, d.get ? d : {
58
- enumerable: true,
59
- get: function () { return e[k]; }
60
- });
61
- }
62
- });
63
- }
64
- n.default = e;
65
- return Object.freeze(n);
66
- }
67
-
68
- var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup$1);
69
-
70
- var clientI18nInstance = i18next.cloneInstance();
71
-
72
- var clearLocalStorageValues = function clearLocalStorageValues(key) {
73
- try {
74
- localStorage.removeItem(key);
75
- } catch (error) {
76
- // eslint-disable-next-line no-console
77
- console.error(error);
78
- }
79
- };
80
- var setWithExpiry = function setWithExpiry(key, value) {
81
- var expireInDays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
82
- var expiryDate = utils.dayjs().add(expireInDays, "day").toDate();
83
- var item = {
84
- value: value,
85
- localStorageExpiry: expiryDate.getTime()
86
- };
87
- try {
88
- localStorage.setItem(key, JSON.stringify(item));
89
- } catch (error) {
90
- // eslint-disable-next-line no-console
91
- console.error(error);
92
- }
93
- };
94
- var getWithExpiry = function getWithExpiry(key) {
95
- try {
96
- var itemStr = localStorage.getItem(key);
97
- if (!itemStr) {
98
- return null;
99
- }
100
- var item = JSON.parse(itemStr);
101
- var now = new Date();
102
- if (now.getTime() > item.localStorageExpiry) {
103
- localStorage.removeItem(key);
104
- return null;
105
- }
106
- return item.value;
107
- } catch (error) {
108
- // eslint-disable-next-line no-console
109
- console.error(error);
110
- return null;
111
- }
112
- };
113
-
114
- var FormikWrap = function FormikWrap(_ref) {
115
- var onError = _ref.onError,
116
- children = _ref.children,
117
- formId = _ref.formId,
118
- preserveValues = _ref.preserveValues,
119
- onValuesChange = _ref.onValuesChange,
120
- dataUpdateCount = _ref.dataUpdateCount;
121
- var _useFormikContext = formik.useFormikContext(),
122
- errors = _useFormikContext.errors,
123
- touched = _useFormikContext.touched,
124
- isValid = _useFormikContext.isValid,
125
- isSubmitting = _useFormikContext.isSubmitting,
126
- values = _useFormikContext.values,
127
- validateForm = _useFormikContext.validateForm;
128
- var revalidate = function revalidate() {
129
- return neetoCist.isPresent(errors) && validateForm();
130
- };
131
- React.useEffect(function () {
132
- revalidate();
133
- }, [clientI18nInstance.language, dataUpdateCount]);
134
- var syncValuesWithLocalStorage = function syncValuesWithLocalStorage() {
135
- return preserveValues && !index.isEmptyValues(values) && setWithExpiry("".concat(formId, "/values"), values);
136
- };
137
- React.useEffect(function () {
138
- syncValuesWithLocalStorage();
139
- onValuesChange && onValuesChange(values);
140
- }, [values, formId, preserveValues]);
141
- React.useEffect(function () {
142
- if (isSubmitting || isValid) return;
143
-
144
- // include only touched fields
145
- var touchedErrors = Object.keys(errors).filter(function (key) {
146
- return touched[key];
147
- }).reduce(function (obj, key) {
148
- obj[key] = errors[key];
149
- return obj;
150
- }, {});
151
- if (index.isFunction(onError)) onError(touchedErrors);
152
- }, [isValid, isSubmitting]);
153
- return children;
154
- };
155
-
156
- var RESEND_DELAY = 120;
157
- var ONE_SECOND = 1000;
158
- var EMAIL_VERIFICATION_FIELD_NAME_PREFIX = "verificationCode";
159
- var EMAIL_VERIFICATION_PREFIX = "neeto_form_nano_email_verification_details_";
160
- var EMAIL_VERIFICATION_KEYS = {
161
- EMAIL: "email",
162
- TOKEN: "token",
163
- VERIFIED: "verified",
164
- CODE: "code",
165
- CODE_SENT_AT: "code-sent-at"
166
- };
167
- var CALLOUT_STYLES = {
168
- WARNING: "warning",
169
- ERROR: "danger"
170
- };
171
- var DEFAULT_CALLOUT_DETAILS = {
172
- message: "",
173
- style: ""
174
- };
175
-
176
- var getEmailVerificationKey = function getEmailVerificationKey(formId) {
177
- return "".concat(EMAIL_VERIFICATION_PREFIX, "-").concat(formId);
178
- };
179
- var getEmailVerificationDetails = function getEmailVerificationDetails(formId) {
180
- return utils.getFromLocalStorage(getEmailVerificationKey(formId)) || {};
181
- };
182
- var buildVerificationFieldName = function buildVerificationFieldName(questionId) {
183
- return "".concat(EMAIL_VERIFICATION_FIELD_NAME_PREFIX, "-").concat(questionId);
184
- };
185
- var getLastVerificationCodeSentAt = function getLastVerificationCodeSentAt(formId, questionId) {
186
- var codeSentAt = getEmailVerificationDetail(formId, questionId, EMAIL_VERIFICATION_KEYS.CODE_SENT_AT);
187
- return Number(codeSentAt) || 0;
188
- };
189
- var storeLastVerificationCodeSentAt = function storeLastVerificationCodeSentAt(formId, questionId) {
190
- var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
191
- return setEmailVerificationDetail(formId, questionId, _defineProperty({}, EMAIL_VERIFICATION_KEYS.CODE_SENT_AT, Date.now() - offset));
192
- };
193
- var getRemainingTime = function getRemainingTime(formId, questionId) {
194
- var elapsedTime = Math.floor((Date.now() - getLastVerificationCodeSentAt(formId, questionId)) / ONE_SECOND);
195
- return ramda.max(RESEND_DELAY - elapsedTime, 0);
196
- };
197
- var getEmailVerificationDetail = function getEmailVerificationDetail(formId, questionId) {
198
- var _questionDetails$keys;
199
- var allDetails = getEmailVerificationDetails(formId);
200
- var questionDetails = allDetails[questionId] || {};
201
- for (var _len = arguments.length, keys = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
202
- keys[_key - 2] = arguments[_key];
203
- }
204
- return keys.length === 1 ? (_questionDetails$keys = questionDetails[keys[0]]) !== null && _questionDetails$keys !== void 0 ? _questionDetails$keys : "" : ramda.pick(keys, allDetails);
205
- };
206
- var setEmailVerificationDetail = function setEmailVerificationDetail(formId, questionId, data) {
207
- var storageKey = getEmailVerificationKey(formId);
208
- var allDetails = getEmailVerificationDetails(formId);
209
- allDetails[questionId] = ramda.mergeRight(allDetails[questionId] || {}, data);
210
- utils.setToLocalStorage(storageKey, allDetails);
211
- };
212
- var removeEmailVerificationDetail = function removeEmailVerificationDetail(formId, questionId) {
213
- var storageKey = getEmailVerificationKey(formId);
214
- var allDetails = getEmailVerificationDetails(formId);
215
- for (var _len2 = arguments.length, keys = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
216
- keys[_key2 - 2] = arguments[_key2];
217
- }
218
- allDetails[questionId] = ramda.omit(keys, allDetails[questionId]);
219
- if (ramda.isEmpty(allDetails[questionId])) delete allDetails[questionId];
220
- ramda.isEmpty(allDetails) ? utils.removeFromLocalStorage(storageKey) : utils.setToLocalStorage(storageKey, allDetails);
221
- };
222
- var clearEmailVerificationDetails = function clearEmailVerificationDetails(formId) {
223
- utils.removeFromLocalStorage(getEmailVerificationKey(formId));
224
- };
225
-
226
- var t$1 = clientI18nInstance.t;
227
- var getInvalidFieldError = function getInvalidFieldError(label) {
228
- return t$1("neetoForm.error.invalidField", {
229
- label: label
230
- });
231
- };
232
- var getRequiredFieldError = function getRequiredFieldError(label) {
233
- return t$1("neetoForm.error.requiredField", {
234
- label: label
235
- });
236
- };
237
- var getSelectMinError = function getSelectMinError() {
238
- var entity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : t$1("neetoForm.common.option");
239
- return t$1("neetoForm.error.minOneEntity", {
240
- entity: entity
241
- });
242
- };
243
- var getInvalidTypeError = function getInvalidTypeError(label, type) {
244
- return t$1("neetoForm.error.invalidType", {
245
- label: label,
246
- type: type
247
- });
248
- };
249
-
250
- function ownKeys$i(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; }
251
- function _objectSpread$i(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$i(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$i(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
252
- var resolveQueryParamValue = ramda.when(ramda.is(Array), ramda.last);
253
- var toEmailValues = function toEmailValues() {
254
- var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
255
- return values.map(function (value) {
256
- return {
257
- label: value,
258
- value: value,
259
- valid: true
260
- };
261
- });
262
- };
263
- var getPhoneNumberFromUrl = function getPhoneNumberFromUrl(fieldCodes, fieldCode) {
264
- var _resolveQueryParamVal;
265
- var countryCode = resolveQueryParamValue(fieldCodes["".concat(fieldCode, ".country")]);
266
- var phoneNumber = resolveQueryParamValue(fieldCodes["".concat(fieldCode, ".number")]);
267
- var phoneNumberWithCountryCode = (_resolveQueryParamVal = resolveQueryParamValue(fieldCodes[fieldCode])) === null || _resolveQueryParamVal === void 0 ? void 0 : _resolveQueryParamVal.replace(yup.PARENTHESES_REGEX, "");
268
- if (phoneNumberWithCountryCode) return phoneNumberWithCountryCode;
269
- if (!countryCode || !phoneNumber) return undefined;
270
- var formattedValue = getPhoneData(phoneNumber, countryCode);
271
- if (!formattedValue) return undefined;
272
- return formattedValue.formatInternational();
273
- };
274
- var getOptionFromURL = function getOptionFromURL(_ref) {
275
- var _findBy;
276
- var optionsAttributes = _ref.optionsAttributes,
277
- fieldCodes = _ref.fieldCodes,
278
- fieldCode = _ref.fieldCode;
279
- var preFillOption = resolveQueryParamValue(fieldCodes[fieldCode]);
280
- return (_findBy = neetoCist.findBy({
281
- label: preFillOption
282
- }, optionsAttributes)) === null || _findBy === void 0 ? void 0 : _findBy.id;
283
- };
284
- var getMultipleOptionsFromURL = function getMultipleOptionsFromURL(_ref2) {
285
- var optionsAttributes = _ref2.optionsAttributes,
286
- fieldCodes = _ref2.fieldCodes,
287
- fieldCode = _ref2.fieldCode;
288
- var fieldCodeValue = resolveQueryParamValue(fieldCodes[fieldCode]);
289
- if (!fieldCodeValue) return new Array(optionsAttributes.length).fill(false);
290
- var allOptions = fieldCodeValue.split(",").map(ramda.trim);
291
- return optionsAttributes.map(function (option) {
292
- return allOptions.includes(option.label);
293
- });
294
- };
295
- var getStarRatingOrOpinionScaleFromUrl = function getStarRatingOrOpinionScaleFromUrl(_ref3) {
296
- var minValue = _ref3.minValue,
297
- maxValue = _ref3.maxValue,
298
- fieldCodes = _ref3.fieldCodes,
299
- fieldCode = _ref3.fieldCode;
300
- var fieldCodeValue = resolveQueryParamValue(fieldCodes[fieldCode]);
301
- var rating = parseInt(fieldCodeValue);
302
- return ramda.isNil(rating) || isNaN(rating) ? "" : ramda.clamp(minValue, maxValue, rating);
303
- };
304
- var getAdditionalGuestsFromUrl = function getAdditionalGuestsFromUrl(_ref4) {
305
- var fieldCodes = _ref4.fieldCodes,
306
- fieldCode = _ref4.fieldCode;
307
- var fieldCodeValue = resolveQueryParamValue(fieldCodes[fieldCode]);
308
- var allEmails = fieldCodeValue === null || fieldCodeValue === void 0 ? void 0 : fieldCodeValue.split(",");
309
- if (!allEmails) return [];
310
- return allEmails.map(function (email) {
311
- return {
312
- label: email.trim(),
313
- value: email.trim(),
314
- valid: yup.EMAIL_REGEX.test(email.trim())
315
- };
316
- });
317
- };
318
- var getRatingFromUrl = function getRatingFromUrl(_ref5) {
319
- var fieldCodes = _ref5.fieldCodes,
320
- fieldCode = _ref5.fieldCode;
321
- var fieldCodeValue = resolveQueryParamValue(fieldCodes[fieldCode]);
322
- var allowedValues = Object.values(yup.RATING_VALUES).map(ramda.prop("value"));
323
- return allowedValues.includes(fieldCodeValue) ? fieldCodeValue : "";
324
- };
325
- var getNumberFromUrl = function getNumberFromUrl(_ref6) {
326
- var fieldCodes = _ref6.fieldCodes,
327
- fieldCode = _ref6.fieldCode,
328
- kind = _ref6.kind;
329
- var fieldCodeValue = resolveQueryParamValue(fieldCodes[fieldCode]);
330
- var parsedValue = kind === yup.QUESTION_KIND.INTEGER.value ? parseInt(fieldCodeValue) : parseFloat(fieldCodeValue);
331
- return parsedValue || "";
332
- };
333
- var getNameFromUrl = function getNameFromUrl(_ref7, fieldCodes) {
334
- var isSplitMode = _ref7.isSplitMode,
335
- fieldCode = _ref7.fieldCode;
336
- var fullName = resolveQueryParamValue(fieldCodes[fieldCode]) || "";
337
- if (!isSplitMode) return {
338
- fullName: fullName
339
- };
340
- var firstName = resolveQueryParamValue(fieldCodes["".concat(fieldCode, ".first_name")]) || "";
341
- var lastName = resolveQueryParamValue(fieldCodes["".concat(fieldCode, ".last_name")]) || "";
342
- if (neetoCist.isPresent(firstName) || neetoCist.isPresent(lastName)) {
343
- return {
344
- firstName: firstName,
345
- lastName: lastName
346
- };
347
- }
348
- if (neetoCist.isPresent(fullName)) {
349
- var _fullName$trim$split = fullName.trim().split(/\s+/),
350
- _fullName$trim$split2 = _toArray(_fullName$trim$split),
351
- computedFirstName = _fullName$trim$split2[0],
352
- remainingParts = _fullName$trim$split2.slice(1);
353
- return {
354
- firstName: computedFirstName,
355
- lastName: remainingParts.join(" ")
356
- };
357
- }
358
- return {
359
- firstName: firstName,
360
- lastName: lastName
361
- };
362
- };
363
- var buildEmailVerificationEntries = function buildEmailVerificationEntries() {
364
- var questions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
365
- var emailQuestionsRequiringVerification = neetoCist.filterBy({
366
- kind: constants.QUESTION_TYPES.EMAIL,
367
- isVerificationEnabled: true
368
- }, questions);
369
- var fieldNames = ramda.map(function (_ref8) {
370
- var id = _ref8.id;
371
- return buildVerificationFieldName(id);
372
- }, emailQuestionsRequiringVerification);
373
- return ramda.zipObj(fieldNames, Array(fieldNames.length).fill(""));
374
- };
375
- var getLabel = function getLabel(label, isRequired) {
376
- return isRequired ? "".concat(label, "*") : label;
377
- };
378
- var generateInitValues = function generateInitValues(_ref9) {
379
- var questions = _ref9.questions,
380
- _ref9$initialValues = _ref9.initialValues,
381
- initialValues = _ref9$initialValues === void 0 ? [] : _ref9$initialValues,
382
- _ref9$localValues = _ref9.localValues,
383
- localValues = _ref9$localValues === void 0 ? {} : _ref9$localValues,
384
- _ref9$fieldCodes = _ref9.fieldCodes,
385
- fieldCodes = _ref9$fieldCodes === void 0 ? {} : _ref9$fieldCodes;
386
- var initValues = {};
387
- var valuesMap = {};
388
- if (initialValues) {
389
- valuesMap = initialValues.reduce(function (acc, answer) {
390
- return _objectSpread$i(_objectSpread$i({}, acc), {}, _defineProperty({}, answer.questionId, {
391
- value: answer.value,
392
- optionIds: answer.optionIds
393
- }));
394
- }, {});
395
- }
396
- questions.forEach(function (question) {
397
- var id = question.id,
398
- kind = question.kind,
399
- optionsAttributes = question.optionsAttributes,
400
- fieldCode = question.fieldCode,
401
- minValue = question.minValue,
402
- maxValue = question.maxValue,
403
- fields = question.fields;
404
- switch (kind) {
405
- case yup.QUESTION_KIND.CONDITION.value:
406
- {
407
- var _valuesMap$id$value, _valuesMap;
408
- initValues[id] = (_valuesMap$id$value = (_valuesMap = valuesMap) === null || _valuesMap === void 0 || (_valuesMap = _valuesMap[id]) === null || _valuesMap === void 0 ? void 0 : _valuesMap.value) !== null && _valuesMap$id$value !== void 0 ? _valuesMap$id$value : false;
409
- return;
410
- }
411
- case yup.QUESTION_KIND.ADDITIONAL_GUESTS.value:
412
- {
413
- var _valuesMap2;
414
- var emailsFromSubmission = toEmailValues((_valuesMap2 = valuesMap) === null || _valuesMap2 === void 0 || (_valuesMap2 = _valuesMap2[id]) === null || _valuesMap2 === void 0 ? void 0 : _valuesMap2.value);
415
- initValues[id] = neetoCist.isNotEmpty(emailsFromSubmission) ? emailsFromSubmission : getAdditionalGuestsFromUrl({
416
- fieldCodes: fieldCodes,
417
- fieldCode: fieldCode
418
- });
419
- return;
420
- }
421
- case yup.QUESTION_KIND.CHECKBOX.value:
422
- {
423
- var _valuesMap$id;
424
- initValues[id] = (_valuesMap$id = valuesMap[id]) !== null && _valuesMap$id !== void 0 && (_valuesMap$id = _valuesMap$id.optionIds) !== null && _valuesMap$id !== void 0 && _valuesMap$id.length ? optionsAttributes.map(function (option) {
425
- var _valuesMap$id2;
426
- return (_valuesMap$id2 = valuesMap[id]) === null || _valuesMap$id2 === void 0 || (_valuesMap$id2 = _valuesMap$id2.optionIds) === null || _valuesMap$id2 === void 0 ? void 0 : _valuesMap$id2.includes(option.id);
427
- }) : getMultipleOptionsFromURL({
428
- optionsAttributes: optionsAttributes,
429
- fieldCodes: fieldCodes,
430
- fieldCode: fieldCode
431
- });
432
- return;
433
- }
434
- case yup.QUESTION_KIND.RADIO.value:
435
- case yup.QUESTION_KIND.DROPDOWN.value:
436
- {
437
- var _optionsAttributes$fi;
438
- initValues[id] = ((_optionsAttributes$fi = optionsAttributes.find(function (option) {
439
- var _valuesMap$id3;
440
- return (_valuesMap$id3 = valuesMap[id]) === null || _valuesMap$id3 === void 0 || (_valuesMap$id3 = _valuesMap$id3.optionIds) === null || _valuesMap$id3 === void 0 ? void 0 : _valuesMap$id3.includes(option.id);
441
- })) === null || _optionsAttributes$fi === void 0 ? void 0 : _optionsAttributes$fi.id) || getOptionFromURL({
442
- optionsAttributes: optionsAttributes,
443
- fieldCodes: fieldCodes,
444
- fieldCode: fieldCode
445
- });
446
- return;
447
- }
448
- case yup.QUESTION_KIND.INTEGER.value:
449
- case yup.QUESTION_KIND.DECIMAL.value:
450
- {
451
- var _valuesMap3;
452
- initValues[id] = ((_valuesMap3 = valuesMap) === null || _valuesMap3 === void 0 || (_valuesMap3 = _valuesMap3[id]) === null || _valuesMap3 === void 0 ? void 0 : _valuesMap3.value) || getNumberFromUrl({
453
- fieldCodes: fieldCodes,
454
- fieldCode: fieldCode,
455
- kind: kind
456
- });
457
- return;
458
- }
459
- case yup.QUESTION_KIND.RATING.value:
460
- {
461
- var _valuesMap4;
462
- initValues[id] = ((_valuesMap4 = valuesMap) === null || _valuesMap4 === void 0 || (_valuesMap4 = _valuesMap4[id]) === null || _valuesMap4 === void 0 ? void 0 : _valuesMap4.value) || getRatingFromUrl({
463
- fieldCodes: fieldCodes,
464
- fieldCode: fieldCode
465
- });
466
- return;
467
- }
468
- case yup.QUESTION_KIND.TERMS.value:
469
- {
470
- initValues[id] = false;
471
- return;
472
- }
473
- case yup.QUESTION_KIND.FILE_UPLOAD.value:
474
- {
475
- var _valuesMap$id$value2, _valuesMap5;
476
- initValues[id] = {
477
- files: (_valuesMap$id$value2 = (_valuesMap5 = valuesMap) === null || _valuesMap5 === void 0 || (_valuesMap5 = _valuesMap5[id]) === null || _valuesMap5 === void 0 ? void 0 : _valuesMap5.value) !== null && _valuesMap$id$value2 !== void 0 ? _valuesMap$id$value2 : []
478
- };
479
- return;
480
- }
481
- case yup.QUESTION_KIND.PHONE.value:
482
- case yup.QUESTION_KIND.SMS_REMINDER.value:
483
- {
484
- var _valuesMap$id$value3, _valuesMap6;
485
- initValues[id] = (_valuesMap$id$value3 = (_valuesMap6 = valuesMap) === null || _valuesMap6 === void 0 || (_valuesMap6 = _valuesMap6[id]) === null || _valuesMap6 === void 0 ? void 0 : _valuesMap6.value) !== null && _valuesMap$id$value3 !== void 0 ? _valuesMap$id$value3 : getPhoneNumberFromUrl(fieldCodes, fieldCode);
486
- return;
487
- }
488
- case yup.QUESTION_KIND.STAR_RATING.value:
489
- case yup.QUESTION_KIND.OPINION_SCALE.value:
490
- {
491
- var _valuesMap$id$value4, _valuesMap7;
492
- initValues[id] = (_valuesMap$id$value4 = (_valuesMap7 = valuesMap) === null || _valuesMap7 === void 0 || (_valuesMap7 = _valuesMap7[id]) === null || _valuesMap7 === void 0 ? void 0 : _valuesMap7.value) !== null && _valuesMap$id$value4 !== void 0 ? _valuesMap$id$value4 : getStarRatingOrOpinionScaleFromUrl({
493
- minValue: minValue,
494
- maxValue: maxValue,
495
- fieldCodes: fieldCodes,
496
- fieldCode: fieldCode
497
- });
498
- return;
499
- }
500
- case yup.QUESTION_KIND.NAME.value:
501
- {
502
- var _valuesMap$id$value5, _valuesMap8;
503
- initValues[id] = (_valuesMap$id$value5 = (_valuesMap8 = valuesMap) === null || _valuesMap8 === void 0 || (_valuesMap8 = _valuesMap8[id]) === null || _valuesMap8 === void 0 ? void 0 : _valuesMap8.value) !== null && _valuesMap$id$value5 !== void 0 ? _valuesMap$id$value5 : getNameFromUrl(question, fieldCodes);
504
- return;
505
- }
506
- case yup.QUESTION_KIND.ADDRESS.value:
507
- {
508
- var _valuesMap$id$value6, _valuesMap9;
509
- initValues[id] = (_valuesMap$id$value6 = (_valuesMap9 = valuesMap) === null || _valuesMap9 === void 0 || (_valuesMap9 = _valuesMap9[id]) === null || _valuesMap9 === void 0 ? void 0 : _valuesMap9.value) !== null && _valuesMap$id$value6 !== void 0 ? _valuesMap$id$value6 : fields.reduce(function (values, field) {
510
- values[field.id] = "";
511
- return values;
512
- }, {});
513
- return;
514
- }
515
- default:
516
- {
517
- var _valuesMap$id$value7, _valuesMap10;
518
- initValues[id] = (_valuesMap$id$value7 = (_valuesMap10 = valuesMap) === null || _valuesMap10 === void 0 || (_valuesMap10 = _valuesMap10[id]) === null || _valuesMap10 === void 0 ? void 0 : _valuesMap10.value) !== null && _valuesMap$id$value7 !== void 0 ? _valuesMap$id$value7 : resolveQueryParamValue(fieldCodes[fieldCode] || "");
519
- return;
520
- }
521
- }
522
- });
523
- var formInitialValues = !index.isEmptyValues(localValues) ? localValues : initValues;
524
- return ramda.mergeLeft(formInitialValues, buildEmailVerificationEntries(questions));
525
- };
526
- var generateFormResponse = function generateFormResponse(response, questions) {
527
- var formResponse = [];
528
- questions.forEach(function (question) {
529
- var id = question.id,
530
- kind = question.kind,
531
- optionsAttributes = question.optionsAttributes;
532
- if (!yup.SCHEMA_LESS_QUESTION_KINDS.includes(kind)) {
533
- var responseValue = response[id];
534
- if (kind === yup.QUESTION_KIND.RADIO.value || kind === yup.QUESTION_KIND.DROPDOWN.value) {
535
- var option = neetoCist.findById(responseValue, optionsAttributes);
536
- if (option) {
537
- formResponse.push({
538
- questionId: id,
539
- questionOptionId: option.id,
540
- value: option.label,
541
- kind: kind
542
- });
543
- }
544
- } else if (kind === yup.QUESTION_KIND.CHECKBOX.value) {
545
- responseValue.forEach(function (isChecked, index) {
546
- if (!isChecked) return;
547
- var option = optionsAttributes[index];
548
- formResponse.push({
549
- questionId: id,
550
- questionOptionId: option.id,
551
- value: option.label,
552
- kind: kind
553
- });
554
- });
555
- } else if (isPhoneNumberField(kind)) {
556
- formResponse.push({
557
- questionId: id,
558
- value: responseValue ? libphonenumberJs.parsePhoneNumber(responseValue).formatInternational() : "",
559
- kind: kind
560
- });
561
- } else if (kind === yup.QUESTION_KIND.ADDITIONAL_GUESTS.value) {
562
- formResponse.push({
563
- questionId: id,
564
- value: responseValue ? ramda.pluck("value", responseValue) : null,
565
- kind: kind
566
- });
567
- } else if (kind === yup.QUESTION_KIND.RICH_TEXT.value) {
568
- formResponse.push({
569
- questionId: id,
570
- value: utils$1.isEditorEmpty(responseValue) ? null : responseValue,
571
- kind: kind
572
- });
573
- } else if (kind === yup.QUESTION_KIND.FILE_UPLOAD.value) {
574
- formResponse.push({
575
- questionId: id,
576
- files: neetoCist.isPresent(responseValue) ? responseValue.files : null,
577
- kind: kind
578
- });
579
- } else if (kind === yup.QUESTION_KIND.DATE.value) {
580
- formResponse.push({
581
- questionId: id,
582
- value: utils.dayjs(responseValue).isValid() ?
583
- // YYYY-MM-DD format is not supported by dateFormat.
584
- // eslint-disable-next-line @bigbinary/neeto/use-standard-date-time-formats
585
- utils.dayjs(responseValue).format("YYYY-MM-DD") : "",
586
- kind: kind
587
- });
588
- } else formResponse.push({
589
- questionId: id,
590
- value: responseValue,
591
- kind: kind
592
- });
593
- }
594
- });
595
- return formResponse;
596
- };
597
- var mergeRefs = function mergeRefs() {
598
- for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
599
- refs[_key] = arguments[_key];
600
- }
601
- return function (node) {
602
- return refs.forEach(function (ref) {
603
- return typeof ref === "function" ? ref(node) : ref.current = node;
604
- });
605
- };
606
- };
607
- var getError = function getError(meta) {
608
- if (meta.error && meta.touched) {
609
- return typeof meta.error === "string" ? meta.error : "";
610
- }
611
- return "";
612
- };
613
- var buildAutoCompleteAttribute = function buildAutoCompleteAttribute(kind, autoCompleteKinds, formDomProps) {
614
- return (formDomProps === null || formDomProps === void 0 ? void 0 : formDomProps.autoComplete) === "off" && ramda.includes(kind, autoCompleteKinds) ? "on" : undefined;
615
- };
616
- var renderButtonsInOrder = function renderButtonsInOrder(buttonsArray, shouldReverse) {
617
- var orderedButtons = shouldReverse ? buttonsArray.reverse() : buttonsArray;
618
- return ramda.map(ramda.identity, orderedButtons);
619
- };
620
- var getSelectedRating = function getSelectedRating(value) {
621
- var parsedValue = parseInt(value);
622
- return isNaN(parsedValue) ? -1 : parsedValue;
623
- };
624
- var isPhoneNumberField = ramda.includes(ramda.__, [yup.QUESTION_KIND.PHONE.value, yup.QUESTION_KIND.SMS_REMINDER.value]);
625
-
626
- var _excluded$4 = ["kind", "customValidator"];
627
- var _fieldKindValidatorMa;
628
- function ownKeys$h(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; }
629
- function _objectSpread$h(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$h(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$h(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
630
- var t = clientI18nInstance.t;
631
- var isValidDate = function isValidDate(date) {
632
- return date && utils.dayjs(date).isValid();
633
- };
634
- var extractEmailDomain = function extractEmailDomain(email) {
635
- return email === null || email === void 0 ? void 0 : email.split("@")[1];
636
- };
637
- var isEmailFromWhitelistedDomain = function isEmailFromWhitelistedDomain(email, whitelistedDomains) {
638
- if (ramda.isEmpty(whitelistedDomains)) return true;
639
- var domain = extractEmailDomain(email);
640
- return ramda.includes(domain, whitelistedDomains);
641
- };
642
- var isEmailFromBlacklistedDomain = function isEmailFromBlacklistedDomain(email, blacklistedDomains) {
643
- var domain = extractEmailDomain(email);
644
- return ramda.includes(domain, blacklistedDomains);
645
- };
646
- var validateTextField = function validateTextField(_ref) {
647
- var kind = _ref.kind,
648
- label = _ref.label,
649
- isRequired = _ref.isRequired;
650
- var schema = yup__namespace.string().typeError(getInvalidTypeError(label, "string"));
651
- if (isPhoneNumberField(kind)) {
652
- schema = PhoneNumber.validation(getInvalidFieldError(t("neetoForm.common.phoneNumberValidation")));
653
- }
654
- if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
655
- return schema.trim();
656
- };
657
- var validateEmailField = function validateEmailField(_ref2) {
658
- var label = _ref2.label,
659
- isRequired = _ref2.isRequired,
660
- whitelistedDomains = _ref2.whitelistedDomains,
661
- blacklistedDomains = _ref2.blacklistedDomains;
662
- var schema = yup__namespace.string().typeError(getInvalidTypeError(label, "string")).email(getInvalidFieldError("Email")).test("verify domain", function (_ref3) {
663
- var value = _ref3.value;
664
- return t("neetoForm.error.emailFromRestrictedDomain", {
665
- domain: extractEmailDomain(value)
666
- });
667
- }, function (value) {
668
- return neetoCist.isNotPresent(value) || isEmailFromWhitelistedDomain(value, whitelistedDomains) && !isEmailFromBlacklistedDomain(value, blacklistedDomains);
669
- });
670
- if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
671
- return schema.trim();
672
- };
673
- var validateNameField = function validateNameField(_ref4) {
674
- var label = _ref4.label,
675
- isRequired = _ref4.isRequired;
676
- var schema = yup__namespace.string().typeError(getInvalidTypeError(label, "string"));
677
- if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
678
- return schema.trim();
679
- };
680
- var validateSingleChoiceField = function validateSingleChoiceField(_ref5) {
681
- var label = _ref5.label,
682
- isRequired = _ref5.isRequired;
683
- var schema = yup__namespace.string().typeError(getInvalidTypeError(label, "string"));
684
- if (isRequired) schema = schema.required(getSelectMinError());
685
- return schema.trim();
686
- };
687
- var validateMultiChoiceField = function validateMultiChoiceField(_ref6) {
688
- var isRequired = _ref6.isRequired;
689
- var schema = yup__namespace.array().of(yup__namespace["boolean"]());
690
- if (isRequired) schema = schema.compact().min(1, getSelectMinError());
691
- return schema;
692
- };
693
- var validateRatingField = function validateRatingField(_ref7) {
694
- var label = _ref7.label,
695
- isRequired = _ref7.isRequired;
696
- var schema = yup__namespace.string().typeError(getInvalidTypeError(label, "string"));
697
- if (isRequired) schema = schema.required(getSelectMinError());
698
- return schema.trim();
699
- };
700
- var validateStarRatingField = function validateStarRatingField(_ref8) {
701
- var label = _ref8.label,
702
- isRequired = _ref8.isRequired;
703
- var schema = yup__namespace.string().typeError(getInvalidTypeError(label, "string"));
704
- if (isRequired) {
705
- schema = schema.required(getSelectMinError(t("neetoForm.common.rating")));
706
- }
707
- return schema.trim();
708
- };
709
- var validateOpinionScaleField = function validateOpinionScaleField(_ref9) {
710
- var label = _ref9.label,
711
- isRequired = _ref9.isRequired;
712
- var schema = yup__namespace.string().typeError(getInvalidTypeError(label, "string"));
713
- if (isRequired) {
714
- schema = schema.required(getSelectMinError(t("neetoForm.common.selection")));
715
- }
716
- return schema.trim();
717
- };
718
- var validateTermsField = function validateTermsField(_ref10) {
719
- var _ref10$isRequired = _ref10.isRequired,
720
- isRequired = _ref10$isRequired === void 0 ? true : _ref10$isRequired;
721
- return isRequired ? yup__namespace["boolean"]().oneOf([true], t("neetoForm.common.mustAcceptTermsAndConditions")) : yup__namespace["boolean"]().notRequired();
722
- };
723
- var validateConditionField = function validateConditionField(_ref11) {
724
- var _ref11$isRequired = _ref11.isRequired,
725
- isRequired = _ref11$isRequired === void 0 ? true : _ref11$isRequired;
726
- return isRequired ? yup__namespace["boolean"]().oneOf([true], t("neetoForm.common.mustAcceptCondition")) : yup__namespace["boolean"]().notRequired();
727
- };
728
- var validateDateField = function validateDateField(_ref12) {
729
- var label = _ref12.label,
730
- isRequired = _ref12.isRequired;
731
- var schema = yup__namespace.string().test("is valid date", getInvalidTypeError(label, "date"), function (value) {
732
- return neetoCist.isNotPresent(value) || isValidDate(value);
733
- });
734
- if (isRequired) {
735
- schema = schema.required(getRequiredFieldError(label));
736
- }
737
- return schema;
738
- };
739
- var validateMultiEmailField = function validateMultiEmailField(_ref13) {
740
- var isRequired = _ref13.isRequired;
741
- var schema = yup__namespace.array().of(yup__namespace.object().shape({
742
- value: yup__namespace.string().email(getInvalidFieldError("Email")).trim()
743
- })).nullable();
744
- if (isRequired) {
745
- schema = schema.compact().min(1, getSelectMinError(t("neetoForm.common.email")));
746
- }
747
- return schema;
748
- };
749
- var validateAddressField = function validateAddressField(_ref14) {
750
- var label = _ref14.label,
751
- isRequired = _ref14.isRequired;
752
- var schema = yup__namespace.string().typeError(getInvalidTypeError(label, "string"));
753
- if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
754
- return schema.trim();
755
- };
756
- var editorHasValue = function editorHasValue(content) {
757
- return !utils$1.isEditorEmpty(content);
758
- };
759
- var validateRichTextField = function validateRichTextField(_ref15) {
760
- var isRequired = _ref15.isRequired;
761
- var schema = yup__namespace.string();
762
- if (isRequired) {
763
- schema = schema.test("required", getRequiredFieldError("content"), editorHasValue);
764
- }
765
- return schema.trim();
766
- };
767
- var validateFileUploadField = function validateFileUploadField(_ref16) {
768
- var isRequired = _ref16.isRequired,
769
- multipleFilesAllowed = _ref16.multipleFilesAllowed;
770
- var files_schema = yup__namespace.array();
771
- if (isRequired) {
772
- files_schema = files_schema.of(yup__namespace.object().shape({
773
- name: yup__namespace.string(),
774
- signedId: yup__namespace.string().required(t("neetoForm.fileUpload.validations.waitForUpload")),
775
- url: yup__namespace.string().required(t("neetoForm.fileUpload.validations.waitForUpload"))
776
- })).unique("name", t("neetoForm.fileUpload.validations.removeDuplicates")).min(1, multipleFilesAllowed ? t("neetoForm.fileUpload.validations.atLeastOneFileRequired") : t("neetoForm.fileUpload.validations.fileIsRequired"));
777
- }
778
- return yup__namespace.object().shape({
779
- files: files_schema
780
- });
781
- };
782
- var validateCaptchaField = function validateCaptchaField(_ref17) {
783
- var variant = _ref17.variant;
784
- return variant === constants.CAPTCHA_TYPES.MATH_CAPTCHA ? yup__namespace.mixed().test("verification failed", t("neetoForm.error.captchaVerificationFailed"), function (value) {
785
- return neetoCist.isNotPresent(value) || value;
786
- }).transform(function (value) {
787
- return value === "" ? null : value;
788
- }).required(t("neetoForm.error.incompleteCaptcha")) : yup__namespace.string().trim().required(t("neetoForm.error.incompleteCaptcha"));
789
- };
790
- var fieldKindValidatorMap = (_fieldKindValidatorMa = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_fieldKindValidatorMa, yup.QUESTION_KIND.EMAIL.value, validateEmailField), yup.QUESTION_KIND.NAME.value, validateNameField), yup.QUESTION_KIND.PHONE.value, validateTextField), yup.QUESTION_KIND.TEXT.value, validateTextField), yup.QUESTION_KIND.QUESTION.value, validateTextField), yup.QUESTION_KIND.TEXTAREA.value, validateTextField), yup.QUESTION_KIND.DECIMAL.value, validateTextField), yup.QUESTION_KIND.INTEGER.value, validateTextField), yup.QUESTION_KIND.DROPDOWN.value, validateSingleChoiceField), yup.QUESTION_KIND.RADIO.value, validateSingleChoiceField), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_fieldKindValidatorMa, yup.QUESTION_KIND.CHECKBOX.value, validateMultiChoiceField), yup.QUESTION_KIND.RATING.value, validateRatingField), yup.QUESTION_KIND.TERMS.value, validateTermsField), yup.QUESTION_KIND.DATE.value, validateDateField), yup.QUESTION_KIND.STAR_RATING.value, validateStarRatingField), yup.QUESTION_KIND.OPINION_SCALE.value, validateOpinionScaleField), yup.QUESTION_KIND.ADDITIONAL_GUESTS.value, validateMultiEmailField), yup.QUESTION_KIND.RICH_TEXT.value, validateRichTextField), yup.QUESTION_KIND.CONDITION.value, validateConditionField), yup.QUESTION_KIND.FILE_UPLOAD.value, validateFileUploadField), _defineProperty(_defineProperty(_defineProperty(_fieldKindValidatorMa, yup.QUESTION_KIND.CAPTCHA.value, validateCaptchaField), yup.QUESTION_KIND.SMS_REMINDER.value, validateTextField), yup.QUESTION_KIND.ADDRESS.value, validateAddressField));
791
- var validateFieldValue = function validateFieldValue(_ref18) {
792
- var kind = _ref18.kind,
793
- customValidator = _ref18.customValidator,
794
- otherProps = _objectWithoutProperties(_ref18, _excluded$4);
795
- return function (value) {
796
- if (!(kind in fieldKindValidatorMap)) return;
797
- var validator = fieldKindValidatorMap[kind];
798
- var schema = customValidator || validator(_objectSpread$h({
799
- kind: kind
800
- }, otherProps));
801
-
802
- // eslint-disable-next-line consistent-return, no-async-promise-executor
803
- return new Promise(/*#__PURE__*/function () {
804
- var _ref19 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve) {
805
- return _regeneratorRuntime.wrap(function _callee$(_context) {
806
- while (1) switch (_context.prev = _context.next) {
807
- case 0:
808
- _context.prev = 0;
809
- _context.next = 3;
810
- return schema.validate(value);
811
- case 3:
812
- resolve(undefined);
813
- _context.next = 9;
814
- break;
815
- case 6:
816
- _context.prev = 6;
817
- _context.t0 = _context["catch"](0);
818
- resolve(_context.t0.message);
819
- case 9:
820
- case "end":
821
- return _context.stop();
822
- }
823
- }, _callee, null, [[0, 6]]);
824
- }));
825
- return function (_x) {
826
- return _ref19.apply(this, arguments);
827
- };
828
- }());
829
- };
830
- };
831
- var validateVerificationCode = function validateVerificationCode(context) {
832
- return function (value) {
833
- var entity = t("neetoForm.emailVerification.verificationCode");
834
- var schema = yup__namespace.string().trim().when("$isVerificationEnabled", {
835
- is: true,
836
- then: function then(schema) {
837
- return schema.when("$isRequired", {
838
- is: true,
839
- then: function then(s) {
840
- return s.required(getRequiredFieldError(entity));
841
- }
842
- }).when("$email", function (email, s) {
843
- if (email !== null && email !== void 0 && email.trim()) {
844
- return s.required(getRequiredFieldError(entity));
845
- }
846
- return s;
847
- }).test("is-6-digit-number", t("neetoForm.error.mustBeASixDigitNumber", {
848
- entity: entity
849
- }), function (value) {
850
- return neetoCist.isNotPresent(value) || yup.SIX_DIGIT_NUMBER_REGEX.test(value);
851
- }).test("verify code", t("neetoForm.error.emailNotVerified"), function () {
852
- var _this$options;
853
- return this === null || this === void 0 || (_this$options = this.options) === null || _this$options === void 0 || (_this$options = _this$options.context) === null || _this$options === void 0 ? void 0 : _this$options.isCodeVerified;
854
- });
855
- }
856
- });
857
-
858
- // eslint-disable-next-line no-async-promise-executor
859
- return new Promise(/*#__PURE__*/function () {
860
- var _ref20 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve) {
861
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
862
- while (1) switch (_context2.prev = _context2.next) {
863
- case 0:
864
- _context2.prev = 0;
865
- _context2.next = 3;
866
- return schema.validate(value, {
867
- context: context
868
- });
869
- case 3:
870
- resolve(undefined);
871
- _context2.next = 9;
872
- break;
873
- case 6:
874
- _context2.prev = 6;
875
- _context2.t0 = _context2["catch"](0);
876
- resolve(_context2.t0.message);
877
- case 9:
878
- case "end":
879
- return _context2.stop();
880
- }
881
- }, _callee2, null, [[0, 6]]);
882
- }));
883
- return function (_x2) {
884
- return _ref20.apply(this, arguments);
885
- };
886
- }());
887
- };
888
- };
889
-
890
- var MultipleEmailInput = function MultipleEmailInput(_ref) {
891
- var question = _ref.question,
892
- customValidator = _ref.customValidator;
893
- var name = question.id,
894
- kind = question.kind,
895
- isRequired = question.isRequired,
896
- nodeId = question.nodeId,
897
- isReadOnly = question.isReadOnly;
898
- var label = index.fieldWithFallback(question, "label");
899
- var _useFormikContext = formik.useFormikContext(),
900
- submitCount = _useFormikContext.submitCount;
901
- var _useTranslation = reactI18next.useTranslation(),
902
- t = _useTranslation.t;
903
- var _useField = formik.useField({
904
- name: name || nodeId,
905
- validate: validateFieldValue({
906
- kind: kind,
907
- label: label,
908
- isRequired: isRequired,
909
- customValidator: customValidator
910
- })
911
- }),
912
- _useField2 = _slicedToArray(_useField, 3),
913
- field = _useField2[0],
914
- meta = _useField2[1],
915
- _useField2$ = _useField2[2],
916
- setValue = _useField2$.setValue,
917
- setTouched = _useField2$.setTouched;
918
- var _useState = React.useState(neetoCist.isPresent(field.value)),
919
- _useState2 = _slicedToArray(_useState, 2),
920
- isInputVisible = _useState2[0],
921
- setIsInputVisible = _useState2[1];
922
- return /*#__PURE__*/jsxRuntime.jsx("div", {
923
- className: "neeto-form-engine-input__wrapper",
924
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
925
- className: "neeto-ui-w-full",
926
- children: isInputVisible ? /*#__PURE__*/jsxRuntime.jsx(NeetoUIMultiEmailInput, {
927
- isRequired: isRequired,
928
- label: label,
929
- disabled: isReadOnly,
930
- error: meta.touched ? meta.error : "",
931
- helpText: t("neetoForm.common.addGuestsHelper"),
932
- name: field.name,
933
- placeholder: index.fieldWithFallback(question, "placeholder"),
934
- value: field.value,
935
- onBlur: function onBlur() {
936
- return setTouched(true);
937
- },
938
- onChange: setValue
939
- }) : /*#__PURE__*/jsxRuntime.jsxs("div", {
940
- className: "flex flex-col gap-2 items-end",
941
- children: [/*#__PURE__*/jsxRuntime.jsx(Button, _defineProperty(_defineProperty(_defineProperty({
942
- label: label,
943
- "data-testid": "add-guest-button",
944
- disabled: isReadOnly,
945
- icon: Plus,
946
- iconPosition: "left"
947
- }, "label", t("neetoForm.common.addGuests")), "style", "link"), "onClick", function onClick() {
948
- return setIsInputVisible(true);
949
- })), (meta === null || meta === void 0 ? void 0 : meta.error) && submitCount > 0 && /*#__PURE__*/jsxRuntime.jsx("span", {
950
- className: "neeto-ui-text-error-500",
951
- children: meta.error
952
- })]
953
- })
954
- })
955
- });
956
- };
957
-
958
- function ownKeys$g(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; }
959
- function _objectSpread$g(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$g(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$g(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
960
- var AddressField = function AddressField(_ref) {
961
- var question = _ref.question,
962
- customValidator = _ref.customValidator;
963
- var name = question.id,
964
- kind = question.kind,
965
- isAddressRequired = question.isRequired,
966
- isReadOnly = question.isReadOnly,
967
- _question$fields = question.fields,
968
- fields = _question$fields === void 0 ? [] : _question$fields;
969
- var label = index.fieldWithFallback(question, "label");
970
- var transformedFields = fields.map(function (field) {
971
- return _objectSpread$g(_objectSpread$g({}, field), {}, {
972
- label: index.fieldWithFallback(field, "label")
973
- });
974
- });
975
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
976
- className: "neeto-form-engine-address-wrapper",
977
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
978
- className: "neeto-form-engine-input__label-wrapper",
979
- children: label && /*#__PURE__*/jsxRuntime.jsx("label", {
980
- className: "neeto-form-engine-label",
981
- "data-testid": "".concat(neetoCist.hyphenate(label), "-input-label"),
982
- children: label
983
- })
984
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
985
- className: "neeto-form-engine-address pb-1",
986
- children: getVisibleOptions(transformedFields).map(function (_ref2) {
987
- var id = _ref2.id,
988
- label = _ref2.label,
989
- width = _ref2.width,
990
- fieldType = _ref2.fieldType,
991
- properties = _ref2.properties,
992
- isRequired = _ref2.isRequired;
993
- return /*#__PURE__*/jsxRuntime.jsx("div", {
994
- "data-testid": "neeto-form-engine-address-fields",
995
- className: classnames("neeto-form-engine-address__field", {
996
- "neeto-form-engine-address__field--width-full": width === yup.ADDRESS_FIELD_WIDTHS.FULL,
997
- "neeto-form-engine-address__field--width-half": width === yup.ADDRESS_FIELD_WIDTHS.HALF,
998
- "neeto-form-engine-address__field--width-one-forth": width === yup.ADDRESS_FIELD_WIDTHS.ONE_FOURTH,
999
- "neeto-form-engine-address__field--width-three-forth": width === yup.ADDRESS_FIELD_WIDTHS.THREE_FOURTH
1000
- }),
1001
- children: /*#__PURE__*/jsxRuntime.jsx(formik.Field, {
1002
- name: "".concat(name, ".").concat(id),
1003
- validate: isAddressRequired ? validateFieldValue({
1004
- kind: kind,
1005
- label: label,
1006
- isRequired: isRequired,
1007
- customValidator: customValidator
1008
- }) : neetoCist.noop,
1009
- children: function children(_ref3) {
1010
- var _properties$options;
1011
- var field = _ref3.field,
1012
- meta = _ref3.meta,
1013
- form = _ref3.form;
1014
- return fieldType === yup.ADDRESS_FIELD_TYPES.SELECT ? /*#__PURE__*/jsxRuntime.jsx(Select, _objectSpread$g(_objectSpread$g({
1015
- label: label,
1016
- size: "large"
1017
- }, field), {}, {
1018
- error: meta.touched && meta.error,
1019
- isDisabled: isReadOnly,
1020
- menuPosition: "absolute",
1021
- required: isRequired,
1022
- value: neetoCist.toLabelAndValue(field.value),
1023
- options: properties === null || properties === void 0 || (_properties$options = properties.options) === null || _properties$options === void 0 ? void 0 : _properties$options.map(function (_ref4) {
1024
- var label = _ref4.label;
1025
- return neetoCist.toLabelAndValue(label);
1026
- }),
1027
- onChange: function onChange(_ref5) {
1028
- var value = _ref5.value;
1029
- return !isReadOnly && form.setFieldValue("".concat(name, ".").concat(id), value);
1030
- }
1031
- })) : /*#__PURE__*/jsxRuntime.jsx(Input, _objectSpread$g(_objectSpread$g({}, _objectSpread$g(_objectSpread$g({}, field), {}, {
1032
- label: label
1033
- })), {}, {
1034
- disabled: isReadOnly,
1035
- error: meta.touched && meta.error,
1036
- required: isRequired
1037
- }));
1038
- }
1039
- })
1040
- }, id);
1041
- })
1042
- })]
1043
- });
1044
- };
1045
-
1046
- var CaptchaField = function CaptchaField(_ref) {
1047
- var question = _ref.question,
1048
- preview = _ref.preview,
1049
- customValidator = _ref.customValidator,
1050
- captchaRef = _ref.captchaRef;
1051
- var name = question.id,
1052
- kind = question.kind,
1053
- isRequired = question.isRequired,
1054
- variant = question.variant,
1055
- nodeId = question.nodeId;
1056
- var label = index.fieldWithFallback(question, "label");
1057
- var _useField = formik.useField({
1058
- name: name || nodeId,
1059
- validate: validateFieldValue({
1060
- kind: kind,
1061
- label: label,
1062
- isRequired: isRequired,
1063
- customValidator: customValidator,
1064
- variant: variant
1065
- })
1066
- }),
1067
- _useField2 = _slicedToArray(_useField, 3);
1068
- _useField2[0];
1069
- var _useField2$ = _useField2[1],
1070
- touched = _useField2$.touched,
1071
- error = _useField2$.error,
1072
- _useField2$2 = _useField2[2],
1073
- setValue = _useField2$2.setValue,
1074
- setTouched = _useField2$2.setTouched;
1075
- var handleVerifyCaptcha = function handleVerifyCaptcha(response) {
1076
- setTouched(true);
1077
- setValue(response);
1078
- };
1079
- var Component = CAPTCHA_COMPONENT_MAP[variant];
1080
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
1081
- className: "neeto-form-engine-input__wrapper",
1082
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
1083
- className: "neeto-form-engine-input__label-wrapper",
1084
- children: label && /*#__PURE__*/jsxRuntime.jsx("label", {
1085
- className: "neeto-form-engine-label",
1086
- children: getLabel(label, isRequired)
1087
- })
1088
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
1089
- className: classnames({
1090
- "pointer-events-none": preview
1091
- }),
1092
- children: /*#__PURE__*/jsxRuntime.jsx(Component, {
1093
- captchaRef: captchaRef,
1094
- handleVerifyCaptcha: handleVerifyCaptcha,
1095
- handleBlur: function handleBlur() {
1096
- return setTouched(true);
1097
- }
1098
- })
1099
- }), touched && error && /*#__PURE__*/jsxRuntime.jsx("p", {
1100
- className: "neeto-form-engine-input__error",
1101
- "data-testid": "neeto-form-engine-captcha-error",
1102
- children: error
1103
- })]
1104
- });
1105
- };
1106
-
1107
- var MATH_OPERATORS = {
1108
- PLUS: "+",
1109
- MINUS: "-"
1110
- };
1111
-
1112
- var generateRandomOperation = function generateRandomOperation() {
1113
- var firstNumber = neetoCist.getRandomInt(1, 50);
1114
- var secondNumber = neetoCist.getRandomInt(1, 50);
1115
- var operator = neetoCist.randomPick.apply(void 0, _toConsumableArray(ramda.values(MATH_OPERATORS)));
1116
- return {
1117
- firstNumber: firstNumber,
1118
- secondNumber: secondNumber,
1119
- operator: operator
1120
- };
1121
- };
1122
-
1123
- var MathCaptcha = function MathCaptcha(_ref) {
1124
- var captchaRef = _ref.captchaRef,
1125
- handleVerifyCaptcha = _ref.handleVerifyCaptcha,
1126
- handleBlur = _ref.handleBlur;
1127
- var _useState = React.useState(generateRandomOperation()),
1128
- _useState2 = _slicedToArray(_useState, 2),
1129
- operation = _useState2[0],
1130
- setOperation = _useState2[1];
1131
- var _useState3 = React.useState(""),
1132
- _useState4 = _slicedToArray(_useState3, 2),
1133
- userInput = _useState4[0],
1134
- setUserInput = _useState4[1];
1135
- var firstNumber = operation.firstNumber,
1136
- secondNumber = operation.secondNumber,
1137
- operator = operation.operator;
1138
- var resetCaptcha = function resetCaptcha() {
1139
- setOperation(generateRandomOperation());
1140
- setUserInput("");
1141
- };
1142
- React.useImperativeHandle(captchaRef, function () {
1143
- return {
1144
- reset: resetCaptcha
1145
- };
1146
- });
1147
- var calculateResult = function calculateResult() {
1148
- switch (operator) {
1149
- case MATH_OPERATORS.PLUS:
1150
- return firstNumber + secondNumber;
1151
- case MATH_OPERATORS.MINUS:
1152
- return firstNumber - secondNumber;
1153
- default:
1154
- return null;
1155
- }
1156
- };
1157
- var verifyCaptcha = function verifyCaptcha() {
1158
- var result = calculateResult();
1159
- if (result === null) return;
1160
- handleVerifyCaptcha(result === Number(userInput));
1161
- };
1162
- reactUtils.useUpdateEffect(function () {
1163
- verifyCaptcha();
1164
- }, [userInput]);
1165
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
1166
- className: "neeto-form-nano-math-captcha",
1167
- "data-testid": "math-captcha",
1168
- ref: captchaRef,
1169
- children: [/*#__PURE__*/jsxRuntime.jsx("button", {
1170
- className: "neeto-form-nano-math-captcha__button",
1171
- type: "button",
1172
- onClick: resetCaptcha,
1173
- children: /*#__PURE__*/jsxRuntime.jsx(Refresh, {})
1174
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1175
- className: "neeto-form-nano-math-captcha__equation",
1176
- children: [/*#__PURE__*/jsxRuntime.jsx("span", {
1177
- "data-testid": "first-number",
1178
- children: firstNumber
1179
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
1180
- "data-testid": "operator",
1181
- children: operator
1182
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
1183
- "data-testid": "second-number",
1184
- children: secondNumber
1185
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
1186
- children: "="
1187
- })]
1188
- }), /*#__PURE__*/jsxRuntime.jsx(Input, {
1189
- required: true,
1190
- className: "neeto-form-nano-math-captcha__input",
1191
- "data-testid": "math-captcha-input",
1192
- value: userInput,
1193
- onBlur: handleBlur,
1194
- onChange: utils.withEventTargetValue(setUserInput)
1195
- })]
1196
- });
1197
- };
1198
-
1199
- var Recaptcha = function Recaptcha(_ref) {
1200
- var captchaRef = _ref.captchaRef,
1201
- handleVerifyCaptcha = _ref.handleVerifyCaptcha;
1202
- var verifyRecaptcha = function verifyRecaptcha(response) {
1203
- if (response === null) {
1204
- return;
1205
- }
1206
- handleVerifyCaptcha(response);
1207
- };
1208
- var expiredRecaptcha = function expiredRecaptcha() {
1209
- var _captchaRef$current;
1210
- captchaRef === null || captchaRef === void 0 || (_captchaRef$current = captchaRef.current) === null || _captchaRef$current === void 0 || _captchaRef$current.reset();
1211
- handleVerifyCaptcha("");
1212
- };
1213
- return /*#__PURE__*/jsxRuntime.jsx(ReCAPTCHA, {
1214
- hl: clientI18nInstance.language,
1215
- ref: captchaRef,
1216
- sitekey: initializers.globalProps.formNanoRecaptchaV2SiteKey,
1217
- onChange: verifyRecaptcha,
1218
- onErrored: neetoCist.noop,
1219
- onExpired: expiredRecaptcha
1220
- }, clientI18nInstance.language);
1221
- };
1222
-
1223
- function ownKeys$f(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; }
1224
- function _objectSpread$f(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$f(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$f(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1225
- var ConditionField = function ConditionField(_ref) {
1226
- var question = _ref.question,
1227
- customValidator = _ref.customValidator;
1228
- var name = question.id,
1229
- kind = question.kind,
1230
- isRequired = question.isRequired,
1231
- nodeId = question.nodeId;
1232
- var label = index.fieldWithFallback(question, "label");
1233
- return /*#__PURE__*/jsxRuntime.jsx(formik.Field, {
1234
- name: name || nodeId,
1235
- validate: validateFieldValue({
1236
- kind: kind,
1237
- label: label,
1238
- isRequired: isRequired,
1239
- customValidator: customValidator
1240
- }),
1241
- children: function children(_ref2) {
1242
- var meta = _ref2.meta,
1243
- field = _ref2.field;
1244
- return /*#__PURE__*/jsxRuntime.jsx(Checkbox, _objectSpread$f(_objectSpread$f({}, _objectSpread$f(_objectSpread$f({}, field), {}, {
1245
- label: label,
1246
- name: name
1247
- })), {}, {
1248
- checked: field.value,
1249
- error: meta.touched ? meta.error : "",
1250
- required: isRequired
1251
- }));
1252
- }
1253
- });
1254
- };
1255
-
1256
- var _excluded$3 = ["value"];
1257
- function ownKeys$e(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; }
1258
- function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$e(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$e(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1259
- var DateField = function DateField(_ref) {
1260
- var question = _ref.question,
1261
- customValidator = _ref.customValidator;
1262
- var name = question.id,
1263
- kind = question.kind,
1264
- isRequired = question.isRequired,
1265
- nodeId = question.nodeId,
1266
- isReadOnly = question.isReadOnly;
1267
- var label = index.fieldWithFallback(question, "label");
1268
- var _QUESTION_KIND$kind$t = yup.QUESTION_KIND[kind.toUpperCase()].type,
1269
- type = _QUESTION_KIND$kind$t === void 0 ? "date" : _QUESTION_KIND$kind$t;
1270
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
1271
- className: "neeto-form-engine-input__wrapper",
1272
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
1273
- className: "neeto-form-engine-input__label-wrapper",
1274
- children: label && /*#__PURE__*/jsxRuntime.jsx("label", {
1275
- className: "neeto-form-engine-label",
1276
- "data-testid": "".concat(neetoCist.hyphenate(label), "-input-label"),
1277
- children: getLabel(label, isRequired)
1278
- })
1279
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
1280
- className: "neeto-form-engine-date-picker",
1281
- children: /*#__PURE__*/jsxRuntime.jsx(formik.Field, {
1282
- name: name || nodeId,
1283
- validate: validateFieldValue({
1284
- kind: kind,
1285
- label: label,
1286
- isRequired: isRequired,
1287
- customValidator: customValidator
1288
- }),
1289
- children: function children(_ref2) {
1290
- var meta = _ref2.meta,
1291
- _ref2$field = _ref2.field,
1292
- value = _ref2$field.value,
1293
- field = _objectWithoutProperties(_ref2$field, _excluded$3),
1294
- form = _ref2.form;
1295
- return /*#__PURE__*/jsxRuntime.jsx(DatePicker, _objectSpread$e(_objectSpread$e({}, _objectSpread$e(_objectSpread$e({}, field), {}, {
1296
- type: type
1297
- })), {}, {
1298
- "data-testid": "".concat(neetoCist.hyphenate(label), "-input-field"),
1299
- dateFormat: "MMM D, YYYY",
1300
- disabled: isReadOnly,
1301
- error: meta.touched ? meta.error : "",
1302
- placeholder: index.fieldWithFallback(question, "placeholder"),
1303
- popupClassName: "neeto-form-engine-date-picker-popup",
1304
- required: isRequired,
1305
- size: "small",
1306
- value: getValidDate(value),
1307
- onCalendarChange: function onCalendarChange(date) {
1308
- if (date) {
1309
- form.setFieldValue(name, date.toISOString());
1310
- }
1311
- },
1312
- onChange: function onChange(date) {
1313
- form.setFieldValue(name, date ? date.toISOString() : "");
1314
- }
1315
- }));
1316
- }
1317
- })
1318
- })]
1319
- });
1320
- };
1321
-
1322
- var create = function create(_ref) {
1323
- var formId = _ref.formId,
1324
- questionId = _ref.questionId,
1325
- payload = _ref.payload;
1326
- return axios.post(utils.buildUrl(constants.EMAIL_VERIFICATIONS_CREATE_URL, {
1327
- formId: formId,
1328
- questionId: questionId
1329
- }), payload, {
1330
- showToastr: false
1331
- });
1332
- };
1333
- var verify = function verify(_ref2) {
1334
- var formId = _ref2.formId,
1335
- questionId = _ref2.questionId,
1336
- payload = _ref2.payload;
1337
- return axios.post(utils.buildUrl(constants.EMAIL_VERIFICATIONS_VERIFY_URL, {
1338
- formId: formId,
1339
- questionId: questionId
1340
- }), payload, {
1341
- showToastr: false
1342
- });
1343
- };
1344
- var emailVerificationsApi = {
1345
- create: create,
1346
- verify: verify
1347
- };
1348
-
1349
- function ownKeys$d(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; }
1350
- function _objectSpread$d(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$d(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$d(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1351
- var getMutationCallbacks = function getMutationCallbacks(options) {
1352
- return {
1353
- onSuccess: function onSuccess() {
1354
- var _options$onSuccess;
1355
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1356
- args[_key] = arguments[_key];
1357
- }
1358
- return (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call.apply(_options$onSuccess, [options].concat(args));
1359
- },
1360
- onError: function onError() {
1361
- var _options$onError;
1362
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1363
- args[_key2] = arguments[_key2];
1364
- }
1365
- return (_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call.apply(_options$onError, [options].concat(args));
1366
- }
1367
- };
1368
- };
1369
- var useSendEmailVerificationCode = function useSendEmailVerificationCode(formId, questionId) {
1370
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1371
- return reactQuery.useMutation(_objectSpread$d(_objectSpread$d({
1372
- mutationFn: function mutationFn(payload) {
1373
- return emailVerificationsApi.create({
1374
- formId: formId,
1375
- questionId: questionId,
1376
- payload: payload
1377
- });
1378
- }
1379
- }, options), getMutationCallbacks(options)));
1380
- };
1381
- var useVerifyEmailVerificationCode = function useVerifyEmailVerificationCode(formId, questionId) {
1382
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1383
- return reactQuery.useMutation(_objectSpread$d(_objectSpread$d({
1384
- mutationFn: function mutationFn(payload) {
1385
- return emailVerificationsApi.verify({
1386
- formId: formId,
1387
- questionId: questionId,
1388
- payload: payload
1389
- });
1390
- }
1391
- }, options), getMutationCallbacks(options)));
1392
- };
1393
-
1394
- var SendCodeButton = function SendCodeButton(_ref) {
1395
- var isCodeVerified = _ref.isCodeVerified,
1396
- isSendingVerificationCode = _ref.isSendingVerificationCode,
1397
- handleClick = _ref.handleClick,
1398
- isDisabled = _ref.isDisabled;
1399
- var _useTranslation = reactI18next.useTranslation(),
1400
- t = _useTranslation.t;
1401
- if (isCodeVerified) {
1402
- return /*#__PURE__*/jsxRuntime.jsx(CheckCircle, {});
1403
- }
1404
- return /*#__PURE__*/jsxRuntime.jsx(Button, {
1405
- "data-testid": "send-code-button",
1406
- disabled: isDisabled,
1407
- size: "small",
1408
- style: "secondary",
1409
- onClick: handleClick,
1410
- children: isSendingVerificationCode ? /*#__PURE__*/jsxRuntime.jsx(Spinner, {
1411
- size: "16"
1412
- }) : t("neetoForm.emailVerification.sendCode")
1413
- });
1414
- };
1415
-
1416
- var ResendVerificationCode = function ResendVerificationCode(_ref) {
1417
- var formId = _ref.formId,
1418
- questionId = _ref.questionId,
1419
- sendVerificationCode = _ref.sendVerificationCode,
1420
- isResendDisabled = _ref.isResendDisabled;
1421
- var _useState = React.useState(getRemainingTime(formId, questionId)),
1422
- _useState2 = _slicedToArray(_useState, 2),
1423
- secondsLeft = _useState2[0],
1424
- setSecondsLeft = _useState2[1];
1425
- var _useTranslation = reactI18next.useTranslation(),
1426
- t = _useTranslation.t;
1427
- React.useEffect(function () {
1428
- if (secondsLeft <= 0) return undefined;
1429
- var interval = setTimeout(function () {
1430
- setSecondsLeft(ramda.pipe(ramda.dec, ramda.max(0)));
1431
- }, ONE_SECOND);
1432
- return function () {
1433
- return clearTimeout(interval);
1434
- };
1435
- }, [secondsLeft]);
1436
- var handleResendClick = function handleResendClick() {
1437
- if (secondsLeft !== 0) return;
1438
- sendVerificationCode();
1439
- setSecondsLeft(RESEND_DELAY);
1440
- storeLastVerificationCodeSentAt(formId, questionId);
1441
- };
1442
- return /*#__PURE__*/jsxRuntime.jsx("p", {
1443
- children: !isResendDisabled && secondsLeft > 0 ? t("neetoForm.emailVerification.resendInSeconds", {
1444
- secondsLeft: secondsLeft
1445
- }) : /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
1446
- i18nKey: "neetoForm.emailVerification.resendCode",
1447
- components: {
1448
- button: /*#__PURE__*/jsxRuntime.jsx(Button, {
1449
- "data-testid": "otp-resend-button",
1450
- disabled: isResendDisabled,
1451
- size: "small",
1452
- style: "link",
1453
- onClick: handleResendClick
1454
- })
1455
- }
1456
- })
1457
- });
1458
- };
1459
-
1460
- function ownKeys$c(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; }
1461
- function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$c(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$c(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1462
- var VerifyCode = function VerifyCode(_ref) {
1463
- var formId = _ref.formId,
1464
- questionId = _ref.questionId,
1465
- email = _ref.email,
1466
- emailVerificationToken = _ref.emailVerificationToken,
1467
- isCodeVerified = _ref.isCodeVerified,
1468
- setIsCodeVerified = _ref.setIsCodeVerified,
1469
- handleResponseError = _ref.handleResponseError,
1470
- hasSentVerificationCode = _ref.hasSentVerificationCode,
1471
- calloutDetails = _ref.calloutDetails,
1472
- handleSendVerificationCode = _ref.handleSendVerificationCode,
1473
- isRequired = _ref.isRequired,
1474
- isVerificationEnabled = _ref.isVerificationEnabled;
1475
- var _useTranslation = reactI18next.useTranslation(),
1476
- t = _useTranslation.t;
1477
- var verificationFieldName = buildVerificationFieldName(questionId);
1478
- var _useField = formik.useField({
1479
- name: verificationFieldName,
1480
- validate: validateVerificationCode({
1481
- isVerificationEnabled: isVerificationEnabled,
1482
- isRequired: isRequired,
1483
- email: email,
1484
- isCodeVerified: isCodeVerified
1485
- })
1486
- }),
1487
- _useField2 = _slicedToArray(_useField, 3),
1488
- field = _useField2[0],
1489
- _useField2$ = _useField2[1],
1490
- touched = _useField2$.touched,
1491
- error = _useField2$.error,
1492
- _useField2$2 = _useField2[2],
1493
- setValue = _useField2$2.setValue,
1494
- setTouched = _useField2$2.setTouched;
1495
- var code = field.value;
1496
- var _useState = React.useState(code),
1497
- _useState2 = _slicedToArray(_useState, 2),
1498
- previousCode = _useState2[0],
1499
- setPreviousCode = _useState2[1];
1500
- var _useVerifyEmailVerifi = useVerifyEmailVerificationCode(formId, questionId, {
1501
- onSuccess: function onSuccess(_, _ref2) {
1502
- var emailVerifications = _ref2.emailVerifications;
1503
- setIsCodeVerified(true);
1504
- setPreviousCode(emailVerifications.otp);
1505
- setEmailVerificationDetail(formId, questionId, _defineProperty(_defineProperty(_defineProperty({}, EMAIL_VERIFICATION_KEYS.EMAIL, emailVerifications.email), EMAIL_VERIFICATION_KEYS.CODE, emailVerifications.otp), EMAIL_VERIFICATION_KEYS.VERIFIED, true));
1506
- },
1507
- onError: handleResponseError
1508
- }),
1509
- verifyCode = _useVerifyEmailVerifi.mutate,
1510
- isVerifyingCode = _useVerifyEmailVerifi.isPending;
1511
- var hasError = neetoCist.isPresent(error);
1512
- React.useEffect(function () {
1513
- var handleVerifyCode = function handleVerifyCode() {
1514
- if (ramda.equals(code, previousCode) || hasError || (code === null || code === void 0 ? void 0 : code.length) !== 6) {
1515
- return;
1516
- }
1517
- verifyCode({
1518
- emailVerifications: {
1519
- email: email,
1520
- token: emailVerificationToken,
1521
- otp: code
1522
- }
1523
- });
1524
- };
1525
- handleVerifyCode();
1526
- }, [code, hasError]);
1527
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1528
- children: [/*#__PURE__*/jsxRuntime.jsx(Input, _objectSpread$c(_objectSpread$c({}, _objectSpread$c({}, field)), {}, {
1529
- "data-testid": "otp-input-field",
1530
- disabled: isVerifyingCode,
1531
- error: touched ? error : "",
1532
- loading: isVerifyingCode,
1533
- name: verificationFieldName,
1534
- placeholder: t("neetoForm.emailVerification.verificationCode"),
1535
- size: "small",
1536
- onBlur: function onBlur() {
1537
- return setTouched(true);
1538
- },
1539
- onChange: utils.withEventTargetValue(setValue)
1540
- })), hasSentVerificationCode && /*#__PURE__*/jsxRuntime.jsx(ResendVerificationCode, {
1541
- formId: formId,
1542
- questionId: questionId,
1543
- isResendDisabled: calloutDetails.style === CALLOUT_STYLES.ERROR,
1544
- sendVerificationCode: handleSendVerificationCode
1545
- }), calloutDetails.message && /*#__PURE__*/jsxRuntime.jsx(NeetoUICallout, {
1546
- style: calloutDetails.style,
1547
- children: calloutDetails.message
1548
- })]
1549
- });
1550
- };
1551
-
1552
- function ownKeys$b(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; }
1553
- function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1554
- var EmailField = function EmailField(_ref) {
1555
- var question = _ref.question,
1556
- customValidator = _ref.customValidator,
1557
- autoComplete = _ref.autoComplete,
1558
- isFormPreview = _ref.preview,
1559
- isUrlBuilderPreview = _ref.isUrlBuilderPreview;
1560
- var questionId = question.id,
1561
- kind = question.kind,
1562
- isRequired = question.isRequired,
1563
- isReadOnly = question.isReadOnly,
1564
- isDomainWhitelistingEnabled = question.isDomainWhitelistingEnabled,
1565
- whitelistedDomains = question.whitelistedDomains,
1566
- isDomainBlacklistingEnabled = question.isDomainBlacklistingEnabled,
1567
- blacklistedDomains = question.blacklistedDomains,
1568
- isVerificationEnabled = question.isVerificationEnabled,
1569
- nodeId = question.nodeId,
1570
- formId = question.formId;
1571
- var label = index.fieldWithFallback(question, "label");
1572
- var _useState = React.useState(DEFAULT_CALLOUT_DETAILS),
1573
- _useState2 = _slicedToArray(_useState, 2),
1574
- calloutDetails = _useState2[0],
1575
- setCalloutDetails = _useState2[1];
1576
- var type = yup.QUESTION_KIND[kind.toUpperCase()].type;
1577
- var _useState3 = React.useState(getLastVerificationCodeSentAt(questionId) > 0),
1578
- _useState4 = _slicedToArray(_useState3, 2),
1579
- hasSentVerificationCode = _useState4[0],
1580
- setHasSentVerificationCode = _useState4[1];
1581
- var verificationStatus = getEmailVerificationDetail(formId, questionId, EMAIL_VERIFICATION_KEYS.VERIFIED);
1582
- var _useStateWithDependen = reactUtils.useStateWithDependency(verificationStatus, [verificationStatus]),
1583
- _useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
1584
- isCodeVerified = _useStateWithDependen2[0],
1585
- setIsCodeVerified = _useStateWithDependen2[1];
1586
- var _useField = formik.useField({
1587
- name: questionId || nodeId,
1588
- validate: validateFieldValue({
1589
- kind: kind,
1590
- label: label,
1591
- isRequired: isRequired,
1592
- customValidator: customValidator,
1593
- whitelistedDomains: isDomainWhitelistingEnabled ? whitelistedDomains : [],
1594
- blacklistedDomains: isDomainBlacklistingEnabled ? blacklistedDomains : []
1595
- })
1596
- }),
1597
- _useField2 = _slicedToArray(_useField, 3),
1598
- field = _useField2[0],
1599
- _useField2$ = _useField2[1],
1600
- touched = _useField2$.touched,
1601
- error = _useField2$.error,
1602
- _useField2$2 = _useField2[2],
1603
- setValue = _useField2$2.setValue,
1604
- setTouched = _useField2$2.setTouched;
1605
- var _useFormikContext = formik.useFormikContext(),
1606
- setFieldValue = _useFormikContext.setFieldValue;
1607
- var email = field.value;
1608
- var emailVerificationToken = getEmailVerificationDetail(formId, questionId, EMAIL_VERIFICATION_KEYS.TOKEN);
1609
- var handleResponseError = function handleResponseError(error) {
1610
- var _error$response;
1611
- var message = error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.data) === null || _error$response === void 0 ? void 0 : _error$response.error;
1612
- if ((error === null || error === void 0 ? void 0 : error.status) === 429) {
1613
- setCalloutDetails({
1614
- message: message,
1615
- style: CALLOUT_STYLES.ERROR
1616
- });
1617
- storeLastVerificationCodeSentAt(formId, questionId, RESEND_DELAY * ONE_SECOND);
1618
- } else {
1619
- Toastr.error(message);
1620
- }
1621
- };
1622
-
1623
- // TODO backend validation
1624
- var _useSendEmailVerifica = useSendEmailVerificationCode(formId, questionId, {
1625
- onSuccess: function onSuccess(_ref2) {
1626
- var token = _ref2.token,
1627
- message = _ref2.message;
1628
- setHasSentVerificationCode(true);
1629
- storeLastVerificationCodeSentAt(formId, questionId);
1630
- if (!emailVerificationToken) {
1631
- setEmailVerificationDetail(formId, questionId, _defineProperty({}, EMAIL_VERIFICATION_KEYS.TOKEN, token));
1632
- }
1633
- if (message) {
1634
- setCalloutDetails({
1635
- message: message,
1636
- style: CALLOUT_STYLES.WARNING
1637
- });
1638
- }
1639
- },
1640
- onError: handleResponseError
1641
- }),
1642
- sendVerificationCode = _useSendEmailVerifica.mutate,
1643
- isSendingVerificationCode = _useSendEmailVerifica.isPending;
1644
- var resetVerifiedData = function resetVerifiedData(email) {
1645
- var verifiedEmail = getEmailVerificationDetail(formId, questionId, EMAIL_VERIFICATION_KEYS.EMAIL);
1646
- if (email !== verifiedEmail) {
1647
- removeEmailVerificationDetail(formId, questionId, ramda.values(ramda.omit(["TOKEN"], EMAIL_VERIFICATION_KEYS)));
1648
- setIsCodeVerified(false);
1649
- setFieldValue(buildVerificationFieldName(questionId), "");
1650
- setHasSentVerificationCode(false);
1651
- setCalloutDetails(DEFAULT_CALLOUT_DETAILS);
1652
- }
1653
- };
1654
- var handleFieldChange = utils.withEventTargetValue(setValue);
1655
- var handleSendVerificationCode = function handleSendVerificationCode() {
1656
- return sendVerificationCode({
1657
- emailVerifications: {
1658
- email: email,
1659
- token: emailVerificationToken
1660
- }
1661
- });
1662
- };
1663
- var shouldShowVerifyButton = isVerificationEnabled && !isUrlBuilderPreview && (isFormPreview || neetoCist.isPresent(email) && neetoCist.isNotPresent(error));
1664
- var shouldShowVerificationCodeInput = shouldShowVerifyButton && !isFormPreview && !isCodeVerified;
1665
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
1666
- className: "flex-col space-y-2",
1667
- children: [/*#__PURE__*/jsxRuntime.jsx(Input, _objectSpread$b(_objectSpread$b({}, _objectSpread$b(_objectSpread$b({
1668
- type: type
1669
- }, field), {}, {
1670
- autoComplete: autoComplete,
1671
- label: label
1672
- }, shouldShowVerifyButton && {
1673
- suffix: /*#__PURE__*/jsxRuntime.jsx(SendCodeButton, {
1674
- isCodeVerified: isCodeVerified,
1675
- isSendingVerificationCode: isSendingVerificationCode,
1676
- handleClick: isFormPreview ? neetoCist.noop : handleSendVerificationCode,
1677
- isDisabled: isCodeVerified || hasSentVerificationCode
1678
- })
1679
- })), {}, {
1680
- disabled: isReadOnly,
1681
- error: touched && !isCodeVerified ? error : "",
1682
- name: kind,
1683
- placeholder: index.fieldWithFallback(question, "placeholder"),
1684
- required: isRequired,
1685
- onBlur: function onBlur() {
1686
- return setTouched(true);
1687
- },
1688
- onBlurCapture: utils.withEventTargetValue(resetVerifiedData),
1689
- onChange: handleFieldChange
1690
- })), shouldShowVerificationCodeInput && /*#__PURE__*/jsxRuntime.jsx(VerifyCode, {
1691
- calloutDetails: calloutDetails,
1692
- email: email,
1693
- emailVerificationToken: emailVerificationToken,
1694
- formId: formId,
1695
- handleResponseError: handleResponseError,
1696
- handleSendVerificationCode: handleSendVerificationCode,
1697
- hasSentVerificationCode: hasSentVerificationCode,
1698
- isCodeVerified: isCodeVerified,
1699
- isRequired: isRequired,
1700
- isVerificationEnabled: isVerificationEnabled,
1701
- questionId: questionId,
1702
- setIsCodeVerified: setIsCodeVerified
1703
- })]
1704
- });
1705
- };
1706
-
1707
- var FileUploadField = function FileUploadField(_ref) {
1708
- var question = _ref.question,
1709
- _ref$preview = _ref.preview,
1710
- preview = _ref$preview === void 0 ? false : _ref$preview,
1711
- customValidator = _ref.customValidator;
1712
- var name = question.id,
1713
- kind = question.kind,
1714
- isRequired = question.isRequired,
1715
- nodeId = question.nodeId,
1716
- allowedFileTypes = question.allowedFileTypes,
1717
- multipleFilesAllowed = question.multipleFilesAllowed,
1718
- maxFileSize = question.maxFileSize;
1719
- var label = index.fieldWithFallback(question, "label");
1720
- var _useField = formik.useField({
1721
- name: name || nodeId,
1722
- validate: validateFieldValue({
1723
- kind: kind,
1724
- label: label,
1725
- isRequired: isRequired,
1726
- customValidator: customValidator,
1727
- multipleFilesAllowed: multipleFilesAllowed
1728
- })
1729
- }),
1730
- _useField2 = _slicedToArray(_useField, 3);
1731
- _useField2[0];
1732
- var _useField2$ = _useField2[1],
1733
- value = _useField2$.value,
1734
- touched = _useField2$.touched,
1735
- error = _useField2$.error,
1736
- _useField2$2 = _useField2[2],
1737
- setValue = _useField2$2.setValue,
1738
- setError = _useField2$2.setError,
1739
- setTouched = _useField2$2.setTouched;
1740
- var errorToDisplay = touched && error ? error : "";
1741
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
1742
- className: "neeto-form-engine-input__wrapper",
1743
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
1744
- className: "neeto-form-engine-input__label-wrapper",
1745
- children: /*#__PURE__*/jsxRuntime.jsx(Label, {
1746
- className: "neeto-form-engine-label",
1747
- required: isRequired,
1748
- children: label
1749
- })
1750
- }), /*#__PURE__*/jsxRuntime.jsx(FileUpload.FileUpload, {
1751
- allowedFileTypes: allowedFileTypes,
1752
- maxFileSize: maxFileSize,
1753
- multipleFilesAllowed: multipleFilesAllowed,
1754
- setError: setError,
1755
- setTouched: setTouched,
1756
- error: errorToDisplay,
1757
- files: value === null || value === void 0 ? void 0 : value.files,
1758
- isPreview: preview,
1759
- onChange: function onChange(files) {
1760
- return setValue({
1761
- files: files
1762
- });
1763
- }
1764
- })]
1765
- });
1766
- };
1767
-
1768
- function ownKeys$a(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; }
1769
- function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1770
- var Field = function Field(_ref) {
1771
- var question = _ref.question,
1772
- name = _ref.name,
1773
- labelField = _ref.labelField,
1774
- placeholderField = _ref.placeholderField,
1775
- customValidator = _ref.customValidator,
1776
- autoComplete = _ref.autoComplete;
1777
- var kind = question.kind,
1778
- isRequired = question.isRequired,
1779
- nodeId = question.nodeId,
1780
- isReadOnly = question.isReadOnly;
1781
- var label = index.fieldWithFallback(question, labelField);
1782
- var type = yup.QUESTION_KIND.NAME.type;
1783
- var _useField = formik.useField({
1784
- name: name || nodeId,
1785
- validate: validateFieldValue({
1786
- kind: kind,
1787
- label: label,
1788
- isRequired: isRequired,
1789
- customValidator: customValidator
1790
- })
1791
- }),
1792
- _useField2 = _slicedToArray(_useField, 3),
1793
- field = _useField2[0],
1794
- _useField2$ = _useField2[1],
1795
- touched = _useField2$.touched,
1796
- error = _useField2$.error,
1797
- _useField2$2 = _useField2[2],
1798
- setValue = _useField2$2.setValue,
1799
- setTouched = _useField2$2.setTouched;
1800
- return /*#__PURE__*/jsxRuntime.jsx(Input, _objectSpread$a(_objectSpread$a({}, _objectSpread$a(_objectSpread$a({
1801
- type: type
1802
- }, field), {}, {
1803
- autoComplete: autoComplete,
1804
- label: label,
1805
- name: name
1806
- })), {}, {
1807
- disabled: isReadOnly,
1808
- error: touched ? error : "",
1809
- placeholder: index.fieldWithFallback(question, placeholderField),
1810
- required: isRequired,
1811
- onBlur: function onBlur() {
1812
- return setTouched(true);
1813
- },
1814
- onChange: utils.withEventTargetValue(setValue)
1815
- }));
1816
- };
1817
-
1818
- function ownKeys$9(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; }
1819
- function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1820
- var NameField = function NameField(props) {
1821
- var _props$question = props.question,
1822
- id = _props$question.id,
1823
- isSplitMode = _props$question.isSplitMode;
1824
- if (isSplitMode) {
1825
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
1826
- className: "flex w-full justify-between space-x-4",
1827
- children: [/*#__PURE__*/jsxRuntime.jsx(Field, _objectSpread$9(_objectSpread$9({}, props), {}, {
1828
- labelField: yup.LABEL_FIELDS.FIRST_NAME,
1829
- name: "".concat(id, ".firstName"),
1830
- placeholderField: "firstNamePlaceholder"
1831
- })), /*#__PURE__*/jsxRuntime.jsx(Field, _objectSpread$9(_objectSpread$9({}, props), {}, {
1832
- labelField: yup.LABEL_FIELDS.LAST_NAME,
1833
- name: "".concat(id, ".lastName"),
1834
- placeholderField: "lastNamePlaceholder"
1835
- }))]
1836
- });
1837
- }
1838
- return /*#__PURE__*/jsxRuntime.jsx(Field, _objectSpread$9(_objectSpread$9({}, props), {}, {
1839
- labelField: yup.LABEL_FIELDS.FULL_NAME,
1840
- name: "".concat(id, ".fullName"),
1841
- placeholderField: "fullNamePlaceholder"
1842
- }));
1843
- };
1844
-
1845
- var OpinionScaleField = function OpinionScaleField(_ref) {
1846
- var question = _ref.question,
1847
- customValidator = _ref.customValidator;
1848
- var name = question.id,
1849
- kind = question.kind,
1850
- isRequired = question.isRequired,
1851
- minValue = question.minValue,
1852
- maxValue = question.maxValue,
1853
- isReadOnly = question.isReadOnly,
1854
- hasOpinionLabels = question.hasOpinionLabels;
1855
- var label = index.fieldWithFallback(question, "label");
1856
- var leftOpinionLabel = index.fieldWithFallback(question, "leftOpinionLabel");
1857
- var rightOpinionLabel = index.fieldWithFallback(question, "rightOpinionLabel");
1858
- var _useField = formik.useField({
1859
- name: name,
1860
- validate: validateFieldValue({
1861
- kind: kind,
1862
- label: label,
1863
- isRequired: isRequired,
1864
- customValidator: customValidator
1865
- })
1866
- }),
1867
- _useField2 = _slicedToArray(_useField, 3),
1868
- field = _useField2[0],
1869
- _useField2$ = _useField2[1],
1870
- error = _useField2$.error,
1871
- touched = _useField2$.touched,
1872
- setValue = _useField2[2].setValue;
1873
- var handleClick = function handleClick(event, index) {
1874
- if (index !== parseInt(field.value)) return;
1875
- event.preventDefault();
1876
- setValue("");
1877
- };
1878
- var opinionScaleOptions = yup.generateArray(minValue, maxValue);
1879
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
1880
- className: "neeto-form-engine-input__wrapper neeto-form-engine-opinion-scale",
1881
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
1882
- className: "neeto-form-engine-input__label-wrapper",
1883
- children: /*#__PURE__*/jsxRuntime.jsx("label", {
1884
- className: "neeto-form-engine-label",
1885
- "data-testid": "opinion-scale-input-label",
1886
- children: getLabel(label, isRequired)
1887
- })
1888
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
1889
- className: "neeto-form-nano-opinion-scale",
1890
- "data-testid": "form-opinion-scale",
1891
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
1892
- className: "neeto-form-nano-opinion-scale__group",
1893
- children: [hasOpinionLabels && /*#__PURE__*/jsxRuntime.jsx("div", {
1894
- className: "neeto-form-nano-opinion-scale__labels-wrap neeto-form-nano-opinion-scale__labels-wrap-mobile",
1895
- children: /*#__PURE__*/jsxRuntime.jsx("label", {
1896
- className: "neeto-form-nano-opinion-scale__label",
1897
- "data-testid": "opinion-scale-left-label",
1898
- children: leftOpinionLabel
1899
- })
1900
- }), /*#__PURE__*/jsxRuntime.jsx("ul", {
1901
- className: "neeto-form-nano-opinion-scale__list",
1902
- "data-testid": "opinion-scale-list",
1903
- children: opinionScaleOptions.map(function (step) {
1904
- return /*#__PURE__*/jsxRuntime.jsx("li", {
1905
- className: "neeto-form-nano-opinion-scale__item",
1906
- "data-testid": "opinion-scale-list-item",
1907
- children: /*#__PURE__*/jsxRuntime.jsxs("label", {
1908
- className: "neeto-form-nano-opinion-scale__item-label",
1909
- "data-testid": "opinion-scale-label",
1910
- onClick: function onClick(event) {
1911
- return handleClick(event, step);
1912
- },
1913
- children: [/*#__PURE__*/jsxRuntime.jsx(formik.Field, {
1914
- name: name,
1915
- checked: parseInt(field.value) === step,
1916
- className: "neeto-form-nano-sr-only neeto-form-nano-opinion-scale__item-input",
1917
- "data-testid": "opinion-scale-input-".concat(step),
1918
- disabled: isReadOnly,
1919
- type: "radio",
1920
- value: step
1921
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
1922
- className: "neeto-form-nano-opinion-scale__item-highlight",
1923
- "data-testid": "opinion-scale-item-".concat(step),
1924
- children: step
1925
- })]
1926
- })
1927
- }, step);
1928
- })
1929
- }), hasOpinionLabels && /*#__PURE__*/jsxRuntime.jsxs("div", {
1930
- className: "neeto-form-nano-opinion-scale__labels-wrap",
1931
- children: [/*#__PURE__*/jsxRuntime.jsx("label", {
1932
- className: "neeto-form-nano-opinion-scale__label neeto-form-nano-opinion-scale__label--start",
1933
- "data-testid": "opinion-scale-left-label",
1934
- children: leftOpinionLabel
1935
- }), /*#__PURE__*/jsxRuntime.jsx("label", {
1936
- className: "neeto-form-nano-opinion-scale__label neeto-form-nano-opinion-scale__label--end",
1937
- "data-testid": "opinion-scale-right-label",
1938
- children: rightOpinionLabel
1939
- })]
1940
- })]
1941
- })
1942
- }), touched && error && /*#__PURE__*/jsxRuntime.jsx("p", {
1943
- className: "neeto-form-engine-input__error",
1944
- "data-testid": "neeto-form-engine-opinion-scale-error",
1945
- children: error
1946
- })]
1947
- });
1948
- };
1949
-
1950
- var ChoiceImage = function ChoiceImage(_ref) {
1951
- var src = _ref.src,
1952
- alt = _ref.alt,
1953
- height = _ref.height,
1954
- shouldFitImages = _ref.shouldFitImages;
1955
- var _useState = React.useState(false),
1956
- _useState2 = _slicedToArray(_useState, 2),
1957
- hasError = _useState2[0],
1958
- setHasError = _useState2[1];
1959
- var _useState3 = React.useState(true),
1960
- _useState4 = _slicedToArray(_useState3, 2),
1961
- isLoading = _useState4[0],
1962
- setIsLoading = _useState4[1];
1963
- var handleLoad = function handleLoad() {
1964
- return setIsLoading(false);
1965
- };
1966
- var handleError = function handleError() {
1967
- setHasError(true);
1968
- setIsLoading(false);
1969
- };
1970
- if (hasError || !src) {
1971
- return /*#__PURE__*/jsxRuntime.jsx("div", {
1972
- className: "neeto-form-engine-choice__image-placeholder neeto-ui-bg-gray-100",
1973
- style: {
1974
- height: height
1975
- },
1976
- children: /*#__PURE__*/jsxRuntime.jsx(Image, {
1977
- size: 32
1978
- })
1979
- });
1980
- }
1981
- return /*#__PURE__*/jsxRuntime.jsx("div", {
1982
- style: {
1983
- height: height
1984
- },
1985
- className: classnames("neeto-form-engine-choice__image-wrapper", {
1986
- "neeto-form-engine-choice__image-wrapper--loading": isLoading
1987
- }),
1988
- children: /*#__PURE__*/jsxRuntime.jsx("img", {
1989
- alt: alt,
1990
- src: src,
1991
- draggable: false,
1992
- className: classnames("neeto-form-engine-choice__image", {
1993
- "neeto-form-engine-choice__image--fit": shouldFitImages
1994
- }),
1995
- onError: handleError,
1996
- onLoad: handleLoad
1997
- })
1998
- });
1999
- };
2000
-
2001
- var Choices = function Choices(_ref) {
2002
- var label = _ref.label,
2003
- options = _ref.options,
2004
- type = _ref.type,
2005
- name = _ref.name,
2006
- value = _ref.value,
2007
- onChange = _ref.onChange,
2008
- onValueChange = _ref.onValueChange,
2009
- error = _ref.error,
2010
- disabled = _ref.isDisabled,
2011
- _ref$isPictureChoice = _ref.isPictureChoice,
2012
- isPictureChoice = _ref$isPictureChoice === void 0 ? yup.DEFAULT_CHOICE_QUESTION_ATTRIBUTES.isPictureChoice : _ref$isPictureChoice,
2013
- _ref$imageHeight = _ref.imageHeight,
2014
- imageHeight = _ref$imageHeight === void 0 ? yup.DEFAULT_CHOICE_QUESTION_ATTRIBUTES.imageHeight : _ref$imageHeight,
2015
- _ref$shouldFitImages = _ref.shouldFitImages,
2016
- shouldFitImages = _ref$shouldFitImages === void 0 ? yup.DEFAULT_CHOICE_QUESTION_ATTRIBUTES.shouldFitImages : _ref$shouldFitImages;
2017
- var isCheckBox = type === "checkbox";
2018
- var ChoiceWrapper = isCheckBox ? "div" : Radio;
2019
- var Component = isCheckBox ? Checkbox : Radio.Item;
2020
- var handleChoiceValueChange = function handleChoiceValueChange(updatedValue) {
2021
- if (typeof onValueChange === "function") {
2022
- onValueChange(updatedValue);
2023
- return;
2024
- }
2025
- onChange({
2026
- target: {
2027
- name: name,
2028
- value: updatedValue
2029
- }
2030
- });
2031
- };
2032
- var shouldDeselectOption = function shouldDeselectOption(optionId) {
2033
- return !isCheckBox && !disabled && value === optionId;
2034
- };
2035
- var handleChoiceClick = function handleChoiceClick(event, optionId) {
2036
- if (!shouldDeselectOption(optionId)) return;
2037
- event.preventDefault();
2038
- handleChoiceValueChange("");
2039
- };
2040
- var handleChoiceKeyDown = function handleChoiceKeyDown(event, optionId) {
2041
- if (!shouldDeselectOption(optionId)) return;
2042
- if (!yup.RADIO_DESELECT_KEYS.includes(event.key)) return;
2043
- event.preventDefault();
2044
- handleChoiceValueChange("");
2045
- };
2046
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
2047
- className: "neeto-form-engine-choices__wrapper",
2048
- "data-testid": "".concat(neetoCist.hyphenate(label), "-select-container-wrapper"),
2049
- children: [/*#__PURE__*/jsxRuntime.jsx("label", {
2050
- className: "neeto-form-engine-label",
2051
- "data-testid": "".concat(neetoCist.hyphenate(label), "-input-label"),
2052
- children: label
2053
- }), /*#__PURE__*/jsxRuntime.jsx(ChoiceWrapper, {
2054
- stacked: !isCheckBox,
2055
- className: classnames("neeto-form-engine-choices", {
2056
- "neeto-form-engine-choices--picture": isPictureChoice
2057
- }),
2058
- children: options.map(function (option, index) {
2059
- var _value$index, _option$image;
2060
- var isChecked = isCheckBox ? (_value$index = value === null || value === void 0 ? void 0 : value[index]) !== null && _value$index !== void 0 ? _value$index : false : value === option.id;
2061
- return /*#__PURE__*/jsxRuntime.jsxs("label", {
2062
- htmlFor: option.id,
2063
- className: classnames("neeto-form-engine-choice", {
2064
- "neeto-form-engine-choice--picture": isPictureChoice,
2065
- "neeto-form-engine-choice--selected": isChecked,
2066
- "cursor-not-allowed": disabled
2067
- }),
2068
- onClick: function onClick(event) {
2069
- return handleChoiceClick(event, option.id);
2070
- },
2071
- children: [isPictureChoice && /*#__PURE__*/jsxRuntime.jsx(ChoiceImage, {
2072
- shouldFitImages: shouldFitImages,
2073
- alt: option.label,
2074
- height: imageHeight,
2075
- src: (_option$image = option.image) === null || _option$image === void 0 ? void 0 : _option$image.url
2076
- }), /*#__PURE__*/jsxRuntime.jsx(Component, {
2077
- disabled: disabled,
2078
- onChange: onChange,
2079
- type: type,
2080
- checked: isChecked,
2081
- className: classnames({
2082
- "cursor-not-allowed": disabled
2083
- }),
2084
- id: option.id,
2085
- label: option.label,
2086
- name: isCheckBox ? "".concat(name, ".").concat(index) : name,
2087
- value: option.id,
2088
- labelProps: {
2089
- className: classnames({
2090
- "cursor-not-allowed": disabled
2091
- })
2092
- },
2093
- onKeyDown: function onKeyDown(event) {
2094
- return handleChoiceKeyDown(event, option.id);
2095
- }
2096
- })]
2097
- }, option.id);
2098
- })
2099
- }), !!error && typeof error === "string" && /*#__PURE__*/jsxRuntime.jsx("p", {
2100
- className: "neeto-form-engine-input__error",
2101
- "data-testid": "neeto-form-engine-".concat(type, "-error"),
2102
- children: error
2103
- })]
2104
- });
2105
- };
2106
- var Choices$1 = /*#__PURE__*/React.memo(Choices);
2107
-
2108
- function ownKeys$8(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; }
2109
- function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2110
- var OptionsField = function OptionsField(_ref) {
2111
- var question = _ref.question,
2112
- customValidator = _ref.customValidator,
2113
- isLastFewElements = _ref.isLastFewElements;
2114
- var _useFormikContext = formik.useFormikContext(),
2115
- setFieldTouched = _useFormikContext.setFieldTouched,
2116
- setFieldValue = _useFormikContext.setFieldValue,
2117
- validateField = _useFormikContext.validateField;
2118
- var name = question.id,
2119
- kind = question.kind,
2120
- isRequired = question.isRequired,
2121
- isReadOnly = question.isReadOnly,
2122
- isPictureChoiceFromQuestion = question.isPictureChoice,
2123
- imageHeight = question.imageHeight,
2124
- shouldFitImages = question.shouldFitImages,
2125
- _question$optionsAttr = question.optionsAttributes,
2126
- options = _question$optionsAttr === void 0 ? [] : _question$optionsAttr;
2127
- var isPictureChoice = isPictureChoiceFromQuestion;
2128
- var isDropdown = kind === yup.QUESTION_KIND.DROPDOWN.value;
2129
- var label = index.fieldWithFallback(question, "label");
2130
- var Component = isDropdown ? Select : Choices$1;
2131
- var transformedOptions = isDropdown ? options.map(function (option) {
2132
- return {
2133
- label: index.fieldWithFallback(option, "label"),
2134
- position: option.position,
2135
- value: option.id
2136
- };
2137
- }) : options.map(function (option) {
2138
- return _objectSpread$8(_objectSpread$8({}, option), {}, {
2139
- label: index.fieldWithFallback(option, "label")
2140
- });
2141
- });
2142
- var handleSelect = function handleSelect(option) {
2143
- setFieldValue(name, option === null || option === void 0 ? void 0 : option.value, false);
2144
- setFieldTouched(name, true, false);
2145
- setTimeout(function () {
2146
- return validateField(name);
2147
- });
2148
- };
2149
- var handleValueChange = function handleValueChange(updatedValue) {
2150
- setFieldValue(name, updatedValue, false);
2151
- setFieldTouched(name, true, false);
2152
- setTimeout(function () {
2153
- return validateField(name);
2154
- });
2155
- };
2156
- var customFilter = function customFilter(option, inputValue) {
2157
- if (!option) return false;
2158
- return containsIgnoreCase(option.label, inputValue);
2159
- };
2160
- return /*#__PURE__*/jsxRuntime.jsx(formik.Field, {
2161
- name: name,
2162
- validate: validateFieldValue({
2163
- kind: kind,
2164
- label: label,
2165
- isRequired: isRequired,
2166
- customValidator: customValidator
2167
- }),
2168
- children: function children(_ref2) {
2169
- var meta = _ref2.meta,
2170
- field = _ref2.field;
2171
- var onChange = field.onChange,
2172
- value = field.value;
2173
- return /*#__PURE__*/jsxRuntime.jsx(Component, _objectSpread$8(_objectSpread$8({
2174
- error: getError(meta),
2175
- isDisabled: isReadOnly,
2176
- label: getLabel(label, isRequired),
2177
- options: transformedOptions,
2178
- strategy: "fixed",
2179
- type: kind
2180
- }, _objectSpread$8(_objectSpread$8({
2181
- isRequired: isRequired,
2182
- name: name
2183
- }, isDropdown && {
2184
- filterOption: customFilter
2185
- }), !isDropdown && {
2186
- imageHeight: imageHeight,
2187
- isPictureChoice: isPictureChoice,
2188
- shouldFitImages: shouldFitImages
2189
- })), {}, {
2190
- value: isDropdown ? neetoCist.findBy({
2191
- value: value
2192
- }, transformedOptions) || null : value,
2193
- onChange: isDropdown ? handleSelect : onChange,
2194
- onValueChange: !isDropdown ? handleValueChange : undefined
2195
- }, isDropdown && {
2196
- isClearable: true,
2197
- menuPlacement: isLastFewElements ? "top" : "auto",
2198
- menuPortalTarget: document.body,
2199
- menuPosition: "fixed"
2200
- }));
2201
- }
2202
- });
2203
- };
2204
-
2205
- var PhoneNumberField = function PhoneNumberField(_ref) {
2206
- var _getPhoneData;
2207
- var question = _ref.question,
2208
- autoComplete = _ref.autoComplete,
2209
- isLastFewElements = _ref.isLastFewElements;
2210
- var name = question.id,
2211
- kind = question.kind,
2212
- isRequired = question.isRequired,
2213
- nodeId = question.nodeId,
2214
- isReadOnly = question.isReadOnly;
2215
- var label = index.fieldWithFallback(question, "label");
2216
- var _useField = formik.useField({
2217
- name: name || nodeId,
2218
- validate: validateFieldValue({
2219
- kind: kind,
2220
- label: label,
2221
- isRequired: isRequired
2222
- })
2223
- }),
2224
- _useField2 = _slicedToArray(_useField, 3),
2225
- value = _useField2[0].value,
2226
- _useField2$ = _useField2[1],
2227
- touched = _useField2$.touched,
2228
- error = _useField2$.error,
2229
- _useField2$2 = _useField2[2],
2230
- setValue = _useField2$2.setValue,
2231
- setTouched = _useField2$2.setTouched;
2232
- return /*#__PURE__*/jsxRuntime.jsx(PhoneNumber.PhoneNumberInput, {
2233
- autoComplete: autoComplete,
2234
- label: label,
2235
- value: value,
2236
- className: "neeto-form-engine-input__wrapper items-stretch",
2237
- disabled: isReadOnly,
2238
- error: touched ? error : "",
2239
- initialCountryCode: (_getPhoneData = getPhoneData(value)) === null || _getPhoneData === void 0 ? void 0 : _getPhoneData.country,
2240
- placeholder: index.fieldWithFallback(question, "placeholder"),
2241
- required: isRequired,
2242
- selectProps: {
2243
- isDisabled: isReadOnly,
2244
- menuPlacement: isLastFewElements ? "top" : "auto",
2245
- menuPortalTarget: document.body,
2246
- menuPosition: "fixed"
2247
- },
2248
- onBlur: function onBlur() {
2249
- return setTouched(true);
2250
- },
2251
- onChange: setValue
2252
- });
2253
- };
2254
-
2255
- var _excluded$2 = ["name", "label", "error", "lowestRatingLabel", "averageRatingLabel", "highestRatingLabel", "value", "disabled"];
2256
- function ownKeys$7(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; }
2257
- function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2258
- var Rating = function Rating(_ref) {
2259
- var name = _ref.name,
2260
- label = _ref.label,
2261
- error = _ref.error,
2262
- lowestRatingLabel = _ref.lowestRatingLabel,
2263
- averageRatingLabel = _ref.averageRatingLabel,
2264
- highestRatingLabel = _ref.highestRatingLabel,
2265
- value = _ref.value,
2266
- disabled = _ref.disabled,
2267
- other = _objectWithoutProperties(_ref, _excluded$2);
2268
- var handleClick = function handleClick(e) {
2269
- return e.currentTarget.nextElementSibling.click();
2270
- };
2271
- var render = function render() {
2272
- var labels = [highestRatingLabel, averageRatingLabel, lowestRatingLabel];
2273
- return yup.RATING_OPTIONS.map(function (_ref2, index) {
2274
- var Icon = _ref2.icon,
2275
- modifier = _ref2.modifier,
2276
- rating = _ref2.value;
2277
- return /*#__PURE__*/jsxRuntime.jsxs(React.Fragment, {
2278
- children: [/*#__PURE__*/jsxRuntime.jsxs("button", {
2279
- disabled: disabled,
2280
- type: "button",
2281
- className: classnames("neeto-form-engine-rating__item neeto-form-engine-rating__item--".concat(modifier), {
2282
- active: rating === value
2283
- }),
2284
- onClick: handleClick,
2285
- children: [/*#__PURE__*/jsxRuntime.jsx(Icon, {}), /*#__PURE__*/jsxRuntime.jsx("label", {
2286
- className: "neeto-form-engine-label",
2287
- children: labels[index]
2288
- })]
2289
- }), /*#__PURE__*/jsxRuntime.jsx("input", _objectSpread$7({
2290
- name: name,
2291
- hidden: true,
2292
- checked: rating === value,
2293
- type: "radio",
2294
- value: rating
2295
- }, other))]
2296
- }, rating);
2297
- });
2298
- };
2299
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
2300
- className: "neeto-form-engine-rating",
2301
- children: [/*#__PURE__*/jsxRuntime.jsx("label", {
2302
- className: "neeto-form-engine-label",
2303
- "data-testid": "rating-input-label",
2304
- children: label
2305
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
2306
- className: "neeto-form-engine-rating__row",
2307
- "data-testid": "rating-input-field",
2308
- children: render()
2309
- }), !!error && typeof error === "string" && /*#__PURE__*/jsxRuntime.jsx("p", {
2310
- className: "neeto-form-engine-input__error",
2311
- "data-testid": "neeto-form-engine-rating-error",
2312
- children: error
2313
- })]
2314
- });
2315
- };
2316
- var Rating$1 = /*#__PURE__*/React.memo(Rating);
2317
-
2318
- function ownKeys$6(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; }
2319
- function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2320
- var RatingField = function RatingField(_ref) {
2321
- var question = _ref.question,
2322
- customValidator = _ref.customValidator;
2323
- var name = question.id,
2324
- kind = question.kind,
2325
- isRequired = question.isRequired,
2326
- isReadOnly = question.isReadOnly;
2327
- var label = index.fieldWithFallback(question, "label");
2328
- return /*#__PURE__*/jsxRuntime.jsx(formik.Field, {
2329
- name: name,
2330
- validate: validateFieldValue({
2331
- kind: kind,
2332
- label: label,
2333
- isRequired: isRequired,
2334
- customValidator: customValidator
2335
- }),
2336
- children: function children(_ref2) {
2337
- var meta = _ref2.meta,
2338
- field = _ref2.field;
2339
- return /*#__PURE__*/jsxRuntime.jsx(Rating$1, _objectSpread$6(_objectSpread$6({}, field), {}, {
2340
- disabled: isReadOnly,
2341
- error: meta.touched ? meta.error : "",
2342
- label: getLabel(label, isRequired),
2343
- averageRatingLabel: index.fieldWithFallback(question, "averageRatingLabel") || yup.RATING_VALUES.AVERAGE.label,
2344
- highestRatingLabel: index.fieldWithFallback(question, "highestRatingLabel") || yup.RATING_VALUES.GOOD.label,
2345
- lowestRatingLabel: index.fieldWithFallback(question, "lowestRatingLabel") || yup.RATING_VALUES.BAD.label
2346
- }));
2347
- }
2348
- });
2349
- };
2350
-
2351
- function ownKeys$5(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; }
2352
- function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2353
- var RichTextEditor = function RichTextEditor(_ref) {
2354
- var editorRef = _ref.editorRef,
2355
- question = _ref.question,
2356
- _ref$editorProps = _ref.editorProps,
2357
- editorProps = _ref$editorProps === void 0 ? {} : _ref$editorProps;
2358
- var _useFormikContext = formik.useFormikContext(),
2359
- errors = _useFormikContext.errors,
2360
- touched = _useFormikContext.touched;
2361
- var name = question.id,
2362
- kind = question.kind,
2363
- isRequired = question.isRequired,
2364
- nodeId = question.nodeId,
2365
- isReadOnly = question.isReadOnly;
2366
- var label = index.fieldWithFallback(question, "label");
2367
- var debouncedPlaceholder = reactUtils.useDebounce(index.fieldWithFallback(question, "placeholder"), 300);
2368
- React.useEffect(function () {
2369
- var _editorRef$current, _editorRef$current$se;
2370
- 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$se = _editorRef$current.setEditable) === null || _editorRef$current$se === void 0 || _editorRef$current$se.call(_editorRef$current, !isReadOnly);
2371
- }, [editorRef === null || editorRef === void 0 ? void 0 : editorRef.current, isReadOnly]);
2372
- var propsToCompare = ["debouncedPlaceholder", "error", "touched", "isReadOnly"];
2373
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
2374
- className: "neeto-form-engine-input__wrapper",
2375
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
2376
- className: "neeto-form-engine-input__label-wrapper",
2377
- children: label && /*#__PURE__*/jsxRuntime.jsx("label", {
2378
- className: "neeto-form-engine-label",
2379
- "data-testid": "".concat(neetoCist.hyphenate(label), "-input-label"),
2380
- children: getLabel(label, isRequired)
2381
- })
2382
- }), /*#__PURE__*/jsxRuntime.jsx(formik.FastField, {
2383
- debouncedPlaceholder: debouncedPlaceholder,
2384
- isReadOnly: isReadOnly,
2385
- error: errors[name],
2386
- name: name || nodeId,
2387
- shouldUpdate: isPropsUnequal(propsToCompare),
2388
- touched: touched[name],
2389
- validate: validateFieldValue({
2390
- kind: kind,
2391
- label: label,
2392
- isRequired: isRequired
2393
- }),
2394
- children: function children(_ref2) {
2395
- var field = _ref2.field,
2396
- form = _ref2.form,
2397
- meta = _ref2.meta;
2398
- return /*#__PURE__*/jsxRuntime.jsx(NeetoEditor, _objectSpread$5({
2399
- editable: isReadOnly,
2400
- error: meta.touched ? meta.error : "",
2401
- initialValue: field.value,
2402
- menuType: isReadOnly ? "bubble" : "fixed",
2403
- placeholder: debouncedPlaceholder,
2404
- ref: editorRef,
2405
- addons: isReadOnly ? [] : ["attachments", "block-quote", "code-block", "image-upload"],
2406
- className: classnames("neeto-form-engine-rich-text-input", {
2407
- "cursor-not-allowed border": isReadOnly
2408
- }),
2409
- onBlur: function onBlur() {
2410
- return form.setFieldTouched(name, true);
2411
- },
2412
- onChange: function onChange(value) {
2413
- return form.setFieldValue(name, value);
2414
- }
2415
- }, editorProps), debouncedPlaceholder);
2416
- }
2417
- })]
2418
- });
2419
- };
2420
-
2421
- var _excluded$1 = ["value", "iconType", "label", "rating"];
2422
- function ownKeys$4(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; }
2423
- function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2424
- var RatingButton = function RatingButton(_ref) {
2425
- var _ref$value = _ref.value,
2426
- value = _ref$value === void 0 ? 0 : _ref$value,
2427
- iconType = _ref.iconType,
2428
- label = _ref.label,
2429
- rating = _ref.rating,
2430
- otherProps = _objectWithoutProperties(_ref, _excluded$1);
2431
- var handleClick = function handleClick(e) {
2432
- return e.currentTarget.nextElementSibling.click();
2433
- };
2434
- var Icon = yup.ICONS_MAP[iconType];
2435
- var selectedRating = getSelectedRating(value);
2436
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
2437
- children: [/*#__PURE__*/jsxRuntime.jsxs("button", {
2438
- className: classnames({
2439
- active: rating === value
2440
- }),
2441
- disabled: otherProps === null || otherProps === void 0 ? void 0 : otherProps.disabled,
2442
- type: "button",
2443
- onClick: handleClick,
2444
- children: [/*#__PURE__*/jsxRuntime.jsx(Icon, {
2445
- size: 24,
2446
- className: classnames("neeto-form-engine-star-rating__icon", {
2447
- "neeto-form-engine-star-rating__icon--active": rating <= selectedRating
2448
- })
2449
- }), /*#__PURE__*/jsxRuntime.jsx("label", {
2450
- className: "neeto-form-engine-label",
2451
- children: label
2452
- })]
2453
- }), /*#__PURE__*/jsxRuntime.jsx("input", _objectSpread$4({
2454
- hidden: true,
2455
- checked: ramda.equals(rating, value),
2456
- type: "radio",
2457
- value: rating
2458
- }, otherProps))]
2459
- });
2460
- };
2461
- var RatingButton$1 = /*#__PURE__*/React.memo(RatingButton);
2462
-
2463
- var _excluded = ["label", "minValue", "maxValue", "error"];
2464
- function ownKeys$3(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; }
2465
- function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2466
- var StarRating = function StarRating(_ref) {
2467
- var label = _ref.label,
2468
- minValue = _ref.minValue,
2469
- maxValue = _ref.maxValue,
2470
- error = _ref.error,
2471
- props = _objectWithoutProperties(_ref, _excluded);
2472
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
2473
- className: "neeto-form-engine-input__wrapper neeto-form-engine-star-rating",
2474
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
2475
- className: "neeto-form-engine-input__label-wrapper",
2476
- children: /*#__PURE__*/jsxRuntime.jsx("label", {
2477
- className: "neeto-form-engine-label",
2478
- "data-testid": "star-rating-input-label",
2479
- children: label
2480
- })
2481
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
2482
- className: "neeto-form-engine-star-rating__row",
2483
- "data-testid": "star-rating-input-field",
2484
- children: yup.generateArray(minValue, maxValue).map(function (index) {
2485
- return /*#__PURE__*/jsxRuntime.jsx(RatingButton$1, _objectSpread$3({
2486
- label: index,
2487
- rating: index
2488
- }, props), index);
2489
- })
2490
- }), !!error && typeof error === "string" && /*#__PURE__*/jsxRuntime.jsx("p", {
2491
- className: "neeto-form-engine-input__error",
2492
- "data-testid": "neeto-form-engine-star-rating-error",
2493
- children: error
2494
- })]
2495
- });
2496
- };
2497
- var StarRating$1 = /*#__PURE__*/React.memo(StarRating);
2498
-
2499
- 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; }
2500
- 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; }
2501
- var StarRatingField = function StarRatingField(_ref) {
2502
- var question = _ref.question,
2503
- customValidator = _ref.customValidator;
2504
- var name = question.id,
2505
- kind = question.kind,
2506
- isRequired = question.isRequired,
2507
- minValue = question.minValue,
2508
- maxValue = question.maxValue,
2509
- iconType = question.iconType,
2510
- isReadOnly = question.isReadOnly;
2511
- var label = index.fieldWithFallback(question, "label");
2512
- return /*#__PURE__*/jsxRuntime.jsx(formik.Field, {
2513
- name: name,
2514
- validate: validateFieldValue({
2515
- kind: kind,
2516
- label: label,
2517
- isRequired: isRequired,
2518
- customValidator: customValidator
2519
- }),
2520
- children: function children(_ref2) {
2521
- var meta = _ref2.meta,
2522
- field = _ref2.field;
2523
- return /*#__PURE__*/jsxRuntime.jsx(StarRating$1, _objectSpread$2({
2524
- iconType: iconType,
2525
- maxValue: maxValue,
2526
- minValue: minValue,
2527
- name: name,
2528
- disabled: isReadOnly,
2529
- error: meta.touched ? meta.error : "",
2530
- label: getLabel(label, isRequired)
2531
- }, field));
2532
- }
2533
- });
2534
- };
2535
-
2536
- 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; }
2537
- 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; }
2538
- var TermsField = function TermsField(_ref) {
2539
- var question = _ref.question,
2540
- customValidator = _ref.customValidator;
2541
- var name = question.id,
2542
- kind = question.kind,
2543
- isRequired = question.isRequired,
2544
- nodeId = question.nodeId;
2545
- var label = index.fieldWithFallback(question, "label", true);
2546
- return /*#__PURE__*/jsxRuntime.jsx(formik.Field, {
2547
- name: name || nodeId,
2548
- validate: validateFieldValue({
2549
- kind: kind,
2550
- label: label,
2551
- isRequired: isRequired,
2552
- customValidator: customValidator
2553
- }),
2554
- children: function children(_ref2) {
2555
- var meta = _ref2.meta,
2556
- field = _ref2.field;
2557
- return /*#__PURE__*/jsxRuntime.jsx("div", {
2558
- className: "neeto-form-engine-terms",
2559
- children: /*#__PURE__*/jsxRuntime.jsx(Checkbox, _objectSpread$1(_objectSpread$1({}, _objectSpread$1(_objectSpread$1({}, field), {}, {
2560
- name: name
2561
- })), {}, {
2562
- checked: field.value,
2563
- error: meta.touched ? meta.error : "",
2564
- children: /*#__PURE__*/jsxRuntime.jsx(EditorContent, {
2565
- content: label
2566
- })
2567
- }))
2568
- });
2569
- }
2570
- });
2571
- };
2572
-
2573
- 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; }
2574
- 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; }
2575
- var TextField = function TextField(_ref) {
2576
- var _otherProps$onChange;
2577
- var question = _ref.question,
2578
- customValidator = _ref.customValidator,
2579
- autoComplete = _ref.autoComplete;
2580
- var name = question.id,
2581
- kind = question.kind,
2582
- isRequired = question.isRequired,
2583
- isReadOnly = question.isReadOnly,
2584
- nodeId = question.nodeId;
2585
- var label = index.fieldWithFallback(question, "label");
2586
- var _QUESTION_KIND$kind$t = yup.QUESTION_KIND[kind.toUpperCase()],
2587
- _QUESTION_KIND$kind$t2 = _QUESTION_KIND$kind$t.type,
2588
- type = _QUESTION_KIND$kind$t2 === void 0 ? "text" : _QUESTION_KIND$kind$t2,
2589
- onKeyDown = _QUESTION_KIND$kind$t.onKeyDown,
2590
- otherProps = _QUESTION_KIND$kind$t.otherProps;
2591
- var Component = kind === yup.QUESTION_KIND.TEXTAREA.value ? Textarea : Input;
2592
- var _useField = formik.useField({
2593
- name: name || nodeId,
2594
- validate: validateFieldValue({
2595
- kind: kind,
2596
- label: label,
2597
- isRequired: isRequired,
2598
- customValidator: customValidator
2599
- })
2600
- }),
2601
- _useField2 = _slicedToArray(_useField, 3),
2602
- field = _useField2[0],
2603
- _useField2$ = _useField2[1],
2604
- touched = _useField2$.touched,
2605
- error = _useField2$.error,
2606
- _useField2$2 = _useField2[2],
2607
- setValue = _useField2$2.setValue,
2608
- setTouched = _useField2$2.setTouched;
2609
- var handleFieldChange = utils.withEventTargetValue(setValue);
2610
- return /*#__PURE__*/jsxRuntime.jsx(Component, _objectSpread(_objectSpread({}, _objectSpread(_objectSpread({
2611
- type: type
2612
- }, field), {}, {
2613
- autoComplete: autoComplete,
2614
- label: label,
2615
- onKeyDown: onKeyDown
2616
- })), {}, {
2617
- disabled: isReadOnly,
2618
- error: touched ? error : "",
2619
- name: neetoCist.slugify(label),
2620
- placeholder: index.fieldWithFallback(question, "placeholder"),
2621
- required: isRequired,
2622
- onBlur: function onBlur() {
2623
- return setTouched(true);
2624
- },
2625
- onChange: (_otherProps$onChange = otherProps === null || otherProps === void 0 ? void 0 : otherProps.onChange(handleFieldChange)) !== null && _otherProps$onChange !== void 0 ? _otherProps$onChange : handleFieldChange
2626
- }));
2627
- };
2628
-
2629
- var _QUESTION_TO_COMPONEN;
2630
- var QUESTION_TO_COMPONENT_MAP = (_QUESTION_TO_COMPONEN = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_QUESTION_TO_COMPONEN, yup.QUESTION_KIND.TEXT.value, TextField), yup.QUESTION_KIND.NAME.value, NameField), yup.QUESTION_KIND.EMAIL.value, EmailField), yup.QUESTION_KIND.INTEGER.value, TextField), yup.QUESTION_KIND.DECIMAL.value, TextField), yup.QUESTION_KIND.PHONE.value, PhoneNumberField), yup.QUESTION_KIND.QUESTION.value, TextField), yup.QUESTION_KIND.TEXTAREA.value, TextField), yup.QUESTION_KIND.CHECKBOX.value, OptionsField), yup.QUESTION_KIND.RADIO.value, OptionsField), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_QUESTION_TO_COMPONEN, yup.QUESTION_KIND.DROPDOWN.value, OptionsField), yup.QUESTION_KIND.RATING.value, RatingField), yup.QUESTION_KIND.PARAGRAPH.value, function (_ref) {
2631
- var question = _ref.question;
2632
- return /*#__PURE__*/jsxRuntime.jsx(EditorContent, {
2633
- content: index.fieldWithFallback(question, "label", true)
2634
- });
2635
- }), yup.QUESTION_KIND.TERMS.value, TermsField), yup.QUESTION_KIND.DATE.value, DateField), yup.QUESTION_KIND.STAR_RATING.value, StarRatingField), yup.QUESTION_KIND.OPINION_SCALE.value, OpinionScaleField), yup.QUESTION_KIND.ADDITIONAL_GUESTS.value, MultipleEmailInput), yup.QUESTION_KIND.RICH_TEXT.value, RichTextEditor), yup.QUESTION_KIND.CONDITION.value, ConditionField), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_QUESTION_TO_COMPONEN, yup.QUESTION_KIND.FILE_UPLOAD.value, FileUploadField), yup.QUESTION_KIND.CAPTCHA.value, CaptchaField), yup.QUESTION_KIND.SMS_REMINDER.value, PhoneNumberField), yup.QUESTION_KIND.ADDRESS.value, AddressField));
2636
- var CAPTCHA_COMPONENT_MAP = _defineProperty(_defineProperty({}, constants.CAPTCHA_TYPES.RECAPTCHA_V2, Recaptcha), constants.CAPTCHA_TYPES.MATH_CAPTCHA, MathCaptcha);
2637
-
2638
- var getFieldComponent = function getFieldComponent(_ref) {
2639
- var kind = _ref.kind;
2640
- if (kind in QUESTION_TO_COMPONENT_MAP) return QUESTION_TO_COMPONENT_MAP[kind];
2641
- return function () {
2642
- return null;
2643
- };
2644
- };
2645
- var isPropsUnequal = function isPropsUnequal(props) {
2646
- return function (nextProps, prevProps) {
2647
- return neetoCist.notEqualsDeep(ramda.pick(props, nextProps), ramda.pick(props, prevProps));
2648
- };
2649
- };
2650
- var getValidDate = function getValidDate(date) {
2651
- if (!date) return "";
2652
- return utils.dayjs(date).isValid() ? utils.dayjs(date) : "";
2653
- };
2654
- var getPhoneData = function getPhoneData(value, countryCode) {
2655
- try {
2656
- return libphonenumberJs.parsePhoneNumber(value, countryCode);
2657
- } catch (_unused) {
2658
- return undefined;
2659
- }
2660
- };
2661
- var containsIgnoreCase = function containsIgnoreCase(string, substring) {
2662
- return string.toLowerCase().includes(substring.toLowerCase());
2663
- };
2664
- var getVisibleOptions = function getVisibleOptions(options) {
2665
- return Array.isArray(options) ? options.filter(function (option) {
2666
- return !option.deleted;
2667
- }).sort(function (a, b) {
2668
- return a.position - b.position;
2669
- }) : [];
2670
- };
2671
-
2672
- exports.FormikWrap = FormikWrap;
2673
- exports.buildAutoCompleteAttribute = buildAutoCompleteAttribute;
2674
- exports.clearEmailVerificationDetails = clearEmailVerificationDetails;
2675
- exports.clearLocalStorageValues = clearLocalStorageValues;
2676
- exports.clientI18nInstance = clientI18nInstance;
2677
- exports.generateFormResponse = generateFormResponse;
2678
- exports.generateInitValues = generateInitValues;
2679
- exports.getFieldComponent = getFieldComponent;
2680
- exports.getWithExpiry = getWithExpiry;
2681
- exports.mergeRefs = mergeRefs;
2682
- exports.renderButtonsInOrder = renderButtonsInOrder;
2683
- //# sourceMappingURL=utils-DEBFghm4.js.map