@bigbinary/neeto-form-frontend 4.4.27 → 4.4.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/.ready +1 -1
  2. package/dist/BuildForm.js +12 -11
  3. package/dist/BuildForm.js.map +1 -1
  4. package/dist/ExternalForm.js +4 -4
  5. package/dist/Submission.js +1 -1
  6. package/dist/UrlBuilder.js +4 -4
  7. package/dist/{buildForm-CrOWLvLE.js → buildForm-DZ6Bl-ye.js} +2 -2
  8. package/dist/{buildForm-CrOWLvLE.js.map → buildForm-DZ6Bl-ye.js.map} +1 -1
  9. package/dist/cjs/BuildForm.js +12 -11
  10. package/dist/cjs/BuildForm.js.map +1 -1
  11. package/dist/cjs/ExternalForm.js +4 -4
  12. package/dist/cjs/Submission.js +1 -1
  13. package/dist/cjs/UrlBuilder.js +4 -4
  14. package/dist/{buildForm-DfMpfuSp.js → cjs/buildForm-CC9itFZl.js} +2 -2
  15. package/dist/cjs/buildForm-CC9itFZl.js.map +1 -0
  16. package/dist/{constants-D5JlvWws.js → cjs/constants-BMSFHZ0w.js} +13 -13
  17. package/dist/cjs/constants-BMSFHZ0w.js.map +1 -0
  18. package/dist/cjs/hooks.js +4 -4
  19. package/dist/{index-Beo6ztaM.js → cjs/index-BQ76EIiQ.js} +2 -2
  20. package/dist/cjs/index-BQ76EIiQ.js.map +1 -0
  21. package/dist/cjs/index.js +6 -6
  22. package/dist/{useFormSubmission-D3O7sDHp.js → cjs/useFormSubmission-CFV6smu9.js} +2 -2
  23. package/dist/cjs/useFormSubmission-CFV6smu9.js.map +1 -0
  24. package/dist/{utils-DBhM5B2L.js → cjs/utils-BznuQ58u.js} +37 -37
  25. package/dist/cjs/utils-BznuQ58u.js.map +1 -0
  26. package/dist/cjs/v2/BuildForm.js +3236 -0
  27. package/dist/cjs/v2/BuildForm.js.map +1 -0
  28. package/dist/cjs/v2/ExternalForm.js +661 -0
  29. package/dist/cjs/v2/ExternalForm.js.map +1 -0
  30. package/dist/cjs/v2/NeetoFormProvider.js +13 -0
  31. package/dist/cjs/v2/NeetoFormProvider.js.map +1 -0
  32. package/dist/cjs/v2/Submission.js +2836 -0
  33. package/dist/cjs/v2/Submission.js.map +1 -0
  34. package/dist/cjs/v2/UrlBuilder.js +352 -0
  35. package/dist/cjs/v2/UrlBuilder.js.map +1 -0
  36. package/dist/cjs/v2/buildForm-bsda0SF2.js +38 -0
  37. package/dist/cjs/v2/buildForm-bsda0SF2.js.map +1 -0
  38. package/dist/cjs/v2/constants-8Qh_klGy.js +36 -0
  39. package/dist/cjs/v2/constants-8Qh_klGy.js.map +1 -0
  40. package/dist/cjs/v2/hooks.js +33 -0
  41. package/dist/cjs/v2/hooks.js.map +1 -0
  42. package/dist/cjs/v2/index-C1-XsBQ0.js +21 -0
  43. package/dist/cjs/v2/index-C1-XsBQ0.js.map +1 -0
  44. package/dist/cjs/v2/index.js +112 -0
  45. package/dist/cjs/v2/index.js.map +1 -0
  46. package/dist/cjs/v2/useFormApi-DD0_MxNV.js +480 -0
  47. package/dist/cjs/v2/useFormApi-DD0_MxNV.js.map +1 -0
  48. package/dist/cjs/v2/useFormSubmission-BWH7QxuC.js +24 -0
  49. package/dist/cjs/v2/useFormSubmission-BWH7QxuC.js.map +1 -0
  50. package/dist/cjs/v2/utils-DxDOZ8uO.js +2793 -0
  51. package/dist/cjs/v2/utils-DxDOZ8uO.js.map +1 -0
  52. package/dist/cjs/v2/yup-D0709IcB.js +1177 -0
  53. package/dist/cjs/v2/yup-D0709IcB.js.map +1 -0
  54. package/dist/{yup-DoKhabp1.js → cjs/yup-W5RzIslJ.js} +3 -3
  55. package/dist/cjs/yup-W5RzIslJ.js.map +1 -0
  56. package/dist/{constants-Cj0XxE8a.js → constants-BV0Ig0ag.js} +13 -13
  57. package/dist/constants-BV0Ig0ag.js.map +1 -0
  58. package/dist/hooks.js +4 -4
  59. package/dist/{index-DhtQJpD_.js → index-DE7lvoSf.js} +2 -2
  60. package/dist/{index-DhtQJpD_.js.map → index-DE7lvoSf.js.map} +1 -1
  61. package/dist/index.js +6 -6
  62. package/dist/{useFormSubmission-PLRMfzJ3.js → useFormSubmission-CBP1Vu7h.js} +2 -2
  63. package/dist/{useFormSubmission-PLRMfzJ3.js.map → useFormSubmission-CBP1Vu7h.js.map} +1 -1
  64. package/dist/{utils-BPAW-N7-.js → utils-CamvCi6R.js} +37 -37
  65. package/dist/utils-CamvCi6R.js.map +1 -0
  66. package/dist/v2/BuildForm.js +3215 -0
  67. package/dist/v2/BuildForm.js.map +1 -0
  68. package/dist/v2/ExternalForm.js +659 -0
  69. package/dist/v2/ExternalForm.js.map +1 -0
  70. package/dist/v2/NeetoFormProvider.js +11 -0
  71. package/dist/v2/NeetoFormProvider.js.map +1 -0
  72. package/dist/v2/Submission.js +2834 -0
  73. package/dist/v2/Submission.js.map +1 -0
  74. package/dist/v2/UrlBuilder.js +350 -0
  75. package/dist/v2/UrlBuilder.js.map +1 -0
  76. package/dist/v2/buildForm-CpdYPz4r.js +35 -0
  77. package/dist/v2/buildForm-CpdYPz4r.js.map +1 -0
  78. package/dist/v2/constants-C8P1Mxiw.js +33 -0
  79. package/dist/v2/constants-C8P1Mxiw.js.map +1 -0
  80. package/dist/v2/hooks.js +20 -0
  81. package/dist/v2/hooks.js.map +1 -0
  82. package/dist/v2/index-CUrkh_zd.js +18 -0
  83. package/dist/v2/index-CUrkh_zd.js.map +1 -0
  84. package/dist/v2/index.js +94 -0
  85. package/dist/v2/index.js.map +1 -0
  86. package/dist/v2/main.css +2 -0
  87. package/dist/v2/main.css.map +1 -0
  88. package/dist/v2/useFormApi-B5a0zkAT.js +463 -0
  89. package/dist/v2/useFormApi-B5a0zkAT.js.map +1 -0
  90. package/dist/v2/useFormSubmission-PDJDRUfF.js +22 -0
  91. package/dist/v2/useFormSubmission-PDJDRUfF.js.map +1 -0
  92. package/dist/v2/utils-wCXQvtSj.js +2762 -0
  93. package/dist/v2/utils-wCXQvtSj.js.map +1 -0
  94. package/dist/v2/yup-CKd8MXQx.js +1087 -0
  95. package/dist/v2/yup-CKd8MXQx.js.map +1 -0
  96. package/dist/{yup-DfQmQc3v.js → yup-DEHT0L38.js} +3 -3
  97. package/dist/{yup-DfQmQc3v.js.map → yup-DEHT0L38.js.map} +1 -1
  98. package/package.json +29 -14
  99. package/dist/buildForm-DfMpfuSp.js.map +0 -1
  100. package/dist/constants-Cj0XxE8a.js.map +0 -1
  101. package/dist/constants-D5JlvWws.js.map +0 -1
  102. package/dist/index-Beo6ztaM.js.map +0 -1
  103. package/dist/useFormSubmission-D3O7sDHp.js.map +0 -1
  104. package/dist/utils-BPAW-N7-.js.map +0 -1
  105. package/dist/utils-DBhM5B2L.js.map +0 -1
  106. package/dist/yup-DoKhabp1.js.map +0 -1
@@ -0,0 +1,3215 @@
1
+ import { Alert, Dialog, Typography, Tooltip, DropdownMenu, Button, Empty, Switch as Switch$1, Sheet, Accordion, Label, Badge, Checkbox, Slider, Spinner } from '@bigbinary/neeto-atoms';
2
+ import { useQueryClient } from '@tanstack/react-query';
3
+ import classnames from 'classnames';
4
+ import { isPresent, truncate, findBy, isNotPresent, slugify, existsBy, findById, findIndexById, hyphenate, noop, nullSafe, modifyBy, removeBy } from '@bigbinary/neeto-cist';
5
+ import { equals, path, when, assoc, includes, isEmpty, reject, keys, pick, omit, evolve, map, mergeLeft, isNil, pipe, filter, isNotNil, values, uniq, join, pathSatisfies, assocPath, dissoc, append, pluck, test, paths, difference, prop, startsWith, split, last, either, F, T } from 'ramda';
6
+ import { j as useDeleteQuestion, b as useForm, k as useCreateQuestion, l as useUpdateQuestion, m as useReorderQuestions, Q as QUERY_KEYS } from './useFormApi-B5a0zkAT.js';
7
+ import { n as QUESTION_ACTIONS, o as INDEPENDENT_LABELS_MAP, q as buildDisplayLabel, r as isElementOverflowing, c as isFunction, s as SELECTABLE_KINDS, t as isAutoGeneratedQuestion, g as fieldWithFallback, u as isRichTextQuestion, v as SPOT_QUESTION_FIELD_CODE, w as isNameQuestion, N as NON_BASIC_LATIN_CHARACTERS_REGEX, x as RESERVED_FIELD_CODES, y as renameKey, j as LABEL_FIELDS, z as isDefaultLanguage, B as buildAddQuestionButtonProps, F as validateEditorContent, G as FIELD_CODES_REJECT_CHARS_REGEX, M as MIN_WORDS_SWITCH_LABEL_PROPS, H as MIN_WORDS, J as isImmutableField, a as QUESTIONS_WITHOUT_FIELD_CODE, K as NON_HIDEABLE_FIELDS, O as NON_READ_ONLY_FIELDS, T as OPINION_LABEL_MAX_LENGTH, U as RICH_TEXT_QUESTIONS, h as ADDRESS_FIELD_WIDTHS, A as ADDRESS_FIELD_TYPES, V as generateDefaultOptions, W as MINIMUM_ADDRESS_FIELDS, X as getDeletedRecords, Y as randomId, Z as getActiveRecords, _ as FILE_TYPES_MAP, $ as FILE_GROUPS, a0 as OPINION_SCALE_MIN_VALUE_OPTIONS, a1 as OPINION_SCALE_MAX_VALUE_OPTIONS, D as DEFAULT_CHOICE_QUESTION_ATTRIBUTES, a2 as MINIMUM_OPTIONS, a3 as IMAGE_HEIGHT_SLIDER_DEFAULTS, a4 as RATING_OPTIONS, a5 as STAR_RATING_MIN_VALUE_OPTIONS, a6 as STAR_RATING_MAX_VALUE_OPTIONS, a7 as STAR_RATING_ICONS_MAP, a8 as buildDisabledAddButtonHelpPopoverProps, a9 as buildReorderPayload, aa as QUESTIONS_INITIAL_VALUE, ab as isMandatoryField, ac as QUESTION_KINDS, Q as QUESTION_KIND, ad as getActiveQuestionKindDetails, ae as DEFAULT_AVAILABLE_LANGUAGES, af as DEFAULT_ADVANCED_FEATURES } from './yup-CKd8MXQx.js';
8
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
9
+ import { useState, useRef, useEffect, createElement } from 'react';
10
+ import { Droppable, Draggable, DragDropContext } from '@hello-pangea/dnd';
11
+ import { withT, isMetaKeyPressed, useStateWithDependency, useFuncDebounce, useOnClickOutside } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
12
+ import { showThumbsUpToastr, withEventTargetValue, hyphenize } from '@bigbinary/neeto-commons-frontend/v2/utils';
13
+ import { a as useBuildFormStore } from './buildForm-CpdYPz4r.js';
14
+ import { Q as QUESTION_TYPES, C as CAPTCHA_TYPES } from './constants-C8P1Mxiw.js';
15
+ import { shallow } from 'zustand/shallow';
16
+ import { useTranslation, Trans } from 'react-i18next';
17
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
18
+ import MoreDropdown from '@bigbinary/neeto-molecules/v2/MoreDropdown';
19
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
20
+ import Equals from '@bigbinary/neeto-icons/Equals';
21
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
22
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
23
+ import { t } from 'i18next';
24
+ import { v4 } from 'uuid';
25
+ import { Textarea as Textarea$1, Switch, Input, Select, Form as Form$2, ActionBlock, RadioGroup, Checkbox as Checkbox$1 } from '@bigbinary/neeto-atoms/formik';
26
+ import { useFormikContext, useField } from 'formik';
27
+ import NeetoEditor from '@bigbinary/neeto-editor/v2/Editor';
28
+ import { isEditorEmpty } from '@bigbinary/neeto-editor/v2/utils';
29
+ import * as yup from 'yup';
30
+ import OptionFields from '@bigbinary/neeto-molecules/v2/OptionFields';
31
+ import { AnimatePresence, motion } from 'framer-motion';
32
+ import CreatableSelect from 'react-select/creatable';
33
+ import _toArray from '@babel/runtime/helpers/toArray';
34
+ import Close from '@bigbinary/neeto-icons/Close';
35
+ import { components } from 'react-select';
36
+ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
37
+ import _regeneratorRuntime from '@babel/runtime/regenerator';
38
+ import HelpPopover from '@bigbinary/neeto-molecules/v2/HelpPopover';
39
+ import '@bigbinary/neeto-commons-frontend/constants';
40
+ import '@bigbinary/neeto-commons-frontend/react-utils';
41
+ import 'axios';
42
+ import '@bigbinary/neeto-commons-frontend/utils';
43
+ import '@bigbinary/neeto-icons/Address';
44
+ import '@bigbinary/neeto-icons/Calendar';
45
+ import '@bigbinary/neeto-icons/Captcha';
46
+ import '@bigbinary/neeto-icons/Checkbox';
47
+ import '@bigbinary/neeto-icons/DropdownClosed';
48
+ import '@bigbinary/neeto-icons/Email';
49
+ import '@bigbinary/neeto-icons/FileUpload';
50
+ import '@bigbinary/neeto-icons/Group';
51
+ import '@bigbinary/neeto-icons/Hash';
52
+ import '@bigbinary/neeto-icons/Header';
53
+ import '@bigbinary/neeto-icons/Location';
54
+ import '@bigbinary/neeto-icons/LongText';
55
+ import '@bigbinary/neeto-icons/MessageSquare';
56
+ import '@bigbinary/neeto-icons/NeetoInvisible';
57
+ import '@bigbinary/neeto-icons/PhoneRing';
58
+ import '@bigbinary/neeto-icons/Radio';
59
+ import '@bigbinary/neeto-icons/Rating';
60
+ import '@bigbinary/neeto-icons/Scale';
61
+ import '@bigbinary/neeto-icons/Sms';
62
+ import '@bigbinary/neeto-icons/Terms';
63
+ import '@bigbinary/neeto-icons/TextLines';
64
+ import '@bigbinary/neeto-icons/UserRoundedRect';
65
+ import 'dompurify';
66
+ import '@babel/runtime/helpers/typeof';
67
+ import '@bigbinary/neeto-icons/Plus';
68
+ import 'zustand';
69
+ import './index-CUrkh_zd.js';
70
+ import '@bigbinary/neeto-editor/utils';
71
+
72
+ var DeleteAlert = function DeleteAlert(_ref) {
73
+ var selectedQuestion = _ref.selectedQuestion,
74
+ isOpen = _ref.isOpen,
75
+ onClose = _ref.onClose,
76
+ languagesCount = _ref.languagesCount,
77
+ handleSelect = _ref.handleSelect;
78
+ var _useTranslation = useTranslation(),
79
+ t = _useTranslation.t;
80
+ var _useBuildFormStore = useBuildFormStore(function (store) {
81
+ var _store$formState, _store$formState2;
82
+ return {
83
+ selectedLanguage: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["selectedLanguage"],
84
+ onMutateSuccess: (_store$formState2 = store["formState"]) === null || _store$formState2 === void 0 ? void 0 : _store$formState2["onMutateSuccess"]
85
+ };
86
+ }, shallow),
87
+ selectedLanguage = _useBuildFormStore.selectedLanguage,
88
+ onMutateSuccess = _useBuildFormStore.onMutateSuccess;
89
+ var renderQuestionLabel = function renderQuestionLabel() {
90
+ var questionKind = selectedQuestion.kind;
91
+ var independentLabel = INDEPENDENT_LABELS_MAP[questionKind];
92
+ if (isPresent(independentLabel)) return independentLabel;
93
+ var questionLabel = buildDisplayLabel(selectedQuestion);
94
+ return truncate(questionLabel, 40);
95
+ };
96
+ var _useDeleteQuestion = useDeleteQuestion(selectedQuestion === null || selectedQuestion === void 0 ? void 0 : selectedQuestion.formId, selectedLanguage, {
97
+ onSuccess: function onSuccess() {
98
+ showThumbsUpToastr();
99
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
100
+ args[_key] = arguments[_key];
101
+ }
102
+ onMutateSuccess === null || onMutateSuccess === void 0 || onMutateSuccess.apply(void 0, [QUESTION_ACTIONS.DELETE].concat(args));
103
+ onClose();
104
+ }
105
+ }),
106
+ deleteQuestion = _useDeleteQuestion.mutate,
107
+ isDeleting = _useDeleteQuestion.isPending;
108
+ var selectNextQuestion = function selectNextQuestion(questions) {
109
+ var selectedQuestionIndex = selectedQuestion.displayOrder;
110
+ var wasLastQuestion = equals(selectedQuestionIndex, questions.length);
111
+ var newDisplayOrder = wasLastQuestion ? selectedQuestionIndex - 1 : selectedQuestionIndex;
112
+ var newQuestion = findBy({
113
+ displayOrder: newDisplayOrder
114
+ }, questions);
115
+ handleSelect(newQuestion);
116
+ };
117
+ var handleSubmit = function handleSubmit() {
118
+ deleteQuestion(selectedQuestion.id, {
119
+ onSuccess: function onSuccess(_ref2) {
120
+ var questions = _ref2.questions;
121
+ return selectNextQuestion(questions);
122
+ }
123
+ });
124
+ };
125
+ return /*#__PURE__*/jsx(Alert, {
126
+ isOpen: isOpen,
127
+ onClose: onClose,
128
+ isSubmitting: isDeleting,
129
+ submitButtonLabel: t("neetoForm.common.delete"),
130
+ title: t("neetoForm.questions.deleteAlert.title"),
131
+ message: isPresent(selectedQuestion) && /*#__PURE__*/jsx(Trans, {
132
+ i18nKey: "neetoForm.questions.deleteAlert.message",
133
+ values: {
134
+ count: languagesCount,
135
+ label: renderQuestionLabel()
136
+ }
137
+ }),
138
+ onSubmit: handleSubmit
139
+ });
140
+ };
141
+
142
+ var DeleteSmsReminderModal = function DeleteSmsReminderModal(_ref) {
143
+ var isOpen = _ref.isOpen,
144
+ onClose = _ref.onClose,
145
+ _ref$hostSpecificData = _ref.hostSpecificData,
146
+ hostSpecificData = _ref$hostSpecificData === void 0 ? {} : _ref$hostSpecificData;
147
+ return /*#__PURE__*/jsxs(Dialog, {
148
+ isOpen: isOpen,
149
+ onClose: onClose,
150
+ children: [/*#__PURE__*/jsx(Dialog.Header, {
151
+ children: /*#__PURE__*/jsx(Dialog.Title, {
152
+ children: /*#__PURE__*/jsx(Typography, {
153
+ "data-testid": "delete-sms-reminder-modal-header",
154
+ variant: "h2",
155
+ weight: "medium",
156
+ children: path(["smsReminder", "deleteModal", "title"], hostSpecificData)
157
+ })
158
+ })
159
+ }), /*#__PURE__*/jsx(Dialog.Body, {
160
+ children: /*#__PURE__*/jsx(Typography, {
161
+ "data-testid": "delete-sms-reminder-modal-description",
162
+ variant: "body2",
163
+ children: path(["smsReminder", "deleteModal", "description"], hostSpecificData)
164
+ })
165
+ })]
166
+ });
167
+ };
168
+
169
+ var DeleteSpotModal = function DeleteSpotModal(_ref) {
170
+ var isOpen = _ref.isOpen,
171
+ onClose = _ref.onClose,
172
+ _ref$hostSpecificData = _ref.hostSpecificData,
173
+ hostSpecificData = _ref$hostSpecificData === void 0 ? {} : _ref$hostSpecificData;
174
+ var title = path(["spot", "deleteModal", "title"], hostSpecificData);
175
+ var description = path(["spot", "deleteModal", "description"], hostSpecificData);
176
+ return /*#__PURE__*/jsxs(Dialog, {
177
+ isOpen: isOpen,
178
+ onClose: onClose,
179
+ children: [/*#__PURE__*/jsx(Dialog.Header, {
180
+ children: /*#__PURE__*/jsx(Dialog.Title, {
181
+ "data-testid": "delete-spot-modal-header",
182
+ children: title
183
+ })
184
+ }), /*#__PURE__*/jsx(Dialog.Body, {
185
+ children: /*#__PURE__*/jsx(Typography, {
186
+ "data-testid": "delete-spot-modal-description",
187
+ variant: "body2",
188
+ children: description
189
+ })
190
+ })]
191
+ });
192
+ };
193
+
194
+ var ChangeLanguageDropdown = function ChangeLanguageDropdown(_ref) {
195
+ var _findBy;
196
+ var availableLanguages = _ref.availableLanguages;
197
+ var _useTranslation = useTranslation(),
198
+ t = _useTranslation.t;
199
+ var _useBuildFormStore = useBuildFormStore(function (store) {
200
+ var _store$formState, _store$formState2, _store$formState3;
201
+ return {
202
+ selectedLanguage: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["selectedLanguage"],
203
+ onLanguageChange: (_store$formState2 = store["formState"]) === null || _store$formState2 === void 0 ? void 0 : _store$formState2["onLanguageChange"],
204
+ isReorderingQuestions: (_store$formState3 = store["formState"]) === null || _store$formState3 === void 0 ? void 0 : _store$formState3["isReorderingQuestions"]
205
+ };
206
+ }, shallow),
207
+ selectedLanguage = _useBuildFormStore.selectedLanguage,
208
+ onLanguageChange = _useBuildFormStore.onLanguageChange,
209
+ isReorderingQuestions = _useBuildFormStore.isReorderingQuestions;
210
+ var selectedLanguageName = (_findBy = findBy({
211
+ code: selectedLanguage
212
+ }, availableLanguages)) === null || _findBy === void 0 ? void 0 : _findBy.name;
213
+ return /*#__PURE__*/jsx(Tooltip, {
214
+ content: t("neetoForm.questions.changeLanguage"),
215
+ children: /*#__PURE__*/jsx("div", {
216
+ children: /*#__PURE__*/jsx(DropdownMenu, {
217
+ buttonProps: {
218
+ variant: "outline"
219
+ },
220
+ disabled: isReorderingQuestions,
221
+ label: selectedLanguageName,
222
+ children: /*#__PURE__*/jsx(DropdownMenu.Menu, {
223
+ children: availableLanguages.map(function (_ref2) {
224
+ var code = _ref2.code,
225
+ name = _ref2.name;
226
+ return /*#__PURE__*/jsx(DropdownMenu.MenuItem, {
227
+ isActive: selectedLanguage === code,
228
+ onClick: function onClick() {
229
+ return onLanguageChange(code);
230
+ },
231
+ children: name
232
+ }, code);
233
+ })
234
+ })
235
+ })
236
+ })
237
+ });
238
+ };
239
+
240
+ var Overview = function Overview(_ref) {
241
+ var title = _ref.title,
242
+ description = _ref.description,
243
+ availableLanguages = _ref.availableLanguages,
244
+ additionalActionOptions = _ref.additionalActionOptions;
245
+ return /*#__PURE__*/jsxs("div", {
246
+ className: "neeto-form-nano-form-wrapper__overview mb-4 w-full shrink-0 space-y-4 pt-6",
247
+ children: [/*#__PURE__*/jsxs("div", {
248
+ className: "flex items-center justify-between",
249
+ children: [/*#__PURE__*/jsx(Typography, {
250
+ "data-testid": "neeto-form-engine-overview-title",
251
+ lineHeight: "leading-normal",
252
+ variant: "h2",
253
+ weight: "semibold",
254
+ children: title
255
+ }), /*#__PURE__*/jsxs("div", {
256
+ className: "flex shrink-0 items-center justify-between space-x-1",
257
+ children: [availableLanguages.length > 1 && /*#__PURE__*/jsx(ChangeLanguageDropdown, {
258
+ availableLanguages: availableLanguages
259
+ }), isPresent(additionalActionOptions) && /*#__PURE__*/jsx(MoreDropdown, {
260
+ dropdownButtonProps: {
261
+ isRounded: true,
262
+ style: "tertiary"
263
+ },
264
+ dropdownProps: {
265
+ strategy: "fixed",
266
+ position: "bottom-start"
267
+ },
268
+ menuItems: additionalActionOptions
269
+ })]
270
+ })]
271
+ }), /*#__PURE__*/jsx(Typography, {
272
+ "data-testid": "neeto-form-engine-overview-description",
273
+ variant: "body2",
274
+ children: description
275
+ })]
276
+ });
277
+ };
278
+
279
+ var Card = function Card(_ref) {
280
+ var _ref$question = _ref.question,
281
+ question = _ref$question === void 0 ? {} : _ref$question,
282
+ allQuestionKinds = _ref.allQuestionKinds,
283
+ getActiveKindDetails = _ref.getActiveKindDetails,
284
+ isActive = _ref.isActive,
285
+ onSelect = _ref.onSelect,
286
+ onEdit = _ref.onEdit,
287
+ onClone = _ref.onClone,
288
+ onDelete = _ref.onDelete,
289
+ canManageQuestions = _ref.canManageQuestions,
290
+ _ref$extraMenuItems = _ref.extraMenuItems,
291
+ extraMenuItems = _ref$extraMenuItems === void 0 ? [] : _ref$extraMenuItems;
292
+ var _useState = useState(false),
293
+ _useState2 = _slicedToArray(_useState, 2),
294
+ isTooltipEnabled = _useState2[0],
295
+ setIsTooltipEnabled = _useState2[1];
296
+ var questionLabelRef = useRef(null);
297
+ var _useTranslation = useTranslation(),
298
+ t = _useTranslation.t;
299
+ var _getActiveKindDetails = getActiveKindDetails({
300
+ allQuestionKinds: allQuestionKinds,
301
+ item: question
302
+ }),
303
+ isSingular = _getActiveKindDetails.isSingular,
304
+ KindIcon = _getActiveKindDetails.icon;
305
+ var questionLabel = buildDisplayLabel(question);
306
+ useEffect(function () {
307
+ var element = questionLabelRef.current;
308
+ if (isNotPresent(element)) return;
309
+ setIsTooltipEnabled(isElementOverflowing(element));
310
+ }, [questionLabel]);
311
+ return /*#__PURE__*/jsxs("div", {
312
+ "data-testid": "neeto-form-engine-".concat(slugify(questionLabel)),
313
+ className: classnames("neeto-ui-rounded neeto-ui-border-gray-300 neeto-ui-bg-white neeto-form-nano-form__card flex h-10 w-full items-center justify-between gap-2 overflow-hidden border p-2", {
314
+ "border-primary-500 neeto-form-nano-form__card--active": isActive
315
+ }),
316
+ onClick: function onClick() {
317
+ return onSelect(question);
318
+ },
319
+ children: [/*#__PURE__*/jsxs("div", {
320
+ className: "flex min-w-0 grow items-center gap-2",
321
+ children: [KindIcon && /*#__PURE__*/jsx(KindIcon, {
322
+ className: "neeto-ui-text-gray-600 shrink-0",
323
+ "data-testid": "question-card-kind-icon",
324
+ size: 16
325
+ }), /*#__PURE__*/jsx(Tooltip, {
326
+ content: questionLabel,
327
+ disabled: !isTooltipEnabled,
328
+ position: "top",
329
+ children: /*#__PURE__*/jsx(Typography, {
330
+ className: "min-w-0 grow truncate",
331
+ "data-testid": "".concat(slugify(questionLabel), "-question-card-label"),
332
+ lineHeight: "snug",
333
+ ref: questionLabelRef,
334
+ variant: "body2",
335
+ weight: "medium",
336
+ children: questionLabel
337
+ })
338
+ })]
339
+ }), canManageQuestions && /*#__PURE__*/jsx(MoreDropdown, {
340
+ dropdownButtonProps: {
341
+ className: "shrink-0"
342
+ },
343
+ dropdownProps: {
344
+ strategy: "fixed"
345
+ },
346
+ menuItems: [{
347
+ "data-testid": "edit-question",
348
+ key: "edit",
349
+ label: t("neetoForm.common.edit"),
350
+ onClick: onEdit
351
+ }, {
352
+ "data-testid": "clone-question",
353
+ key: "clone",
354
+ label: t("neetoForm.common.clone"),
355
+ isVisible: !isSingular && isFunction(onClone),
356
+ onClick: onClone
357
+ }].concat(_toConsumableArray(extraMenuItems), [{
358
+ "data-testid": "delete-question",
359
+ key: "delete",
360
+ label: t("neetoForm.common.delete"),
361
+ isVisible: isFunction(onDelete),
362
+ onClick: function onClick() {
363
+ return onDelete(question);
364
+ }
365
+ }])
366
+ })]
367
+ });
368
+ };
369
+
370
+ function ownKeys$j(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; }
371
+ function _objectSpread$j(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$j(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$j(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
372
+ var Questions = function Questions(_ref) {
373
+ var questions = _ref.questions,
374
+ isDeletable = _ref.isDeletable,
375
+ allQuestionKinds = _ref.allQuestionKinds,
376
+ getActiveKindDetails = _ref.getActiveKindDetails,
377
+ getQuestionMenuExtras = _ref.getQuestionMenuExtras,
378
+ selectedQuestion = _ref.selectedQuestion,
379
+ onEdit = _ref.onEdit,
380
+ onClone = _ref.onClone,
381
+ onDelete = _ref.onDelete,
382
+ onSelect = _ref.onSelect,
383
+ canManageQuestions = _ref.canManageQuestions;
384
+ return /*#__PURE__*/jsx(Droppable, {
385
+ droppableId: "droppable",
386
+ isDropDisabled: !canManageQuestions,
387
+ children: function children(_ref2) {
388
+ var droppableProps = _ref2.droppableProps,
389
+ placeholder = _ref2.placeholder,
390
+ innerRef = _ref2.innerRef;
391
+ return /*#__PURE__*/jsxs("div", _objectSpread$j(_objectSpread$j({}, droppableProps), {}, {
392
+ className: "space-y-2",
393
+ ref: innerRef,
394
+ children: [questions.map(function (question, index) {
395
+ var _question$id, _question$id2;
396
+ return /*#__PURE__*/createElement(Draggable, {
397
+ index: index,
398
+ draggableId: "question-".concat((_question$id = question.id) !== null && _question$id !== void 0 ? _question$id : question.nodeId),
399
+ isDragDisabled: !canManageQuestions,
400
+ key: "question-".concat((_question$id2 = question.id) !== null && _question$id2 !== void 0 ? _question$id2 : question.nodeId)
401
+ }, function (_ref3) {
402
+ var _getQuestionMenuExtra;
403
+ var draggableProps = _ref3.draggableProps,
404
+ dragHandleProps = _ref3.dragHandleProps,
405
+ innerRef = _ref3.innerRef;
406
+ return /*#__PURE__*/jsxs("div", _objectSpread$j(_objectSpread$j({}, draggableProps), {}, {
407
+ className: "flex items-center gap-1",
408
+ ref: innerRef,
409
+ children: [canManageQuestions && /*#__PURE__*/jsx("span", _objectSpread$j(_objectSpread$j({}, dragHandleProps), {}, {
410
+ className: "neeto-ui-text-gray-400 hover:neeto-ui-text-gray-500 shrink-0 cursor-grab transition-all duration-300 ease-in-out",
411
+ "data-testid": "question-card-drag-handle",
412
+ children: /*#__PURE__*/jsx(Equals, {
413
+ size: 16
414
+ })
415
+ })), /*#__PURE__*/jsx("div", {
416
+ className: "min-w-0 grow",
417
+ children: /*#__PURE__*/jsx(Card, {
418
+ allQuestionKinds: allQuestionKinds,
419
+ canManageQuestions: canManageQuestions,
420
+ getActiveKindDetails: getActiveKindDetails,
421
+ onClone: onClone,
422
+ onEdit: onEdit,
423
+ onSelect: onSelect,
424
+ question: question,
425
+ extraMenuItems: (_getQuestionMenuExtra = getQuestionMenuExtras === null || getQuestionMenuExtras === void 0 ? void 0 : getQuestionMenuExtras(question)) !== null && _getQuestionMenuExtra !== void 0 ? _getQuestionMenuExtra : [],
426
+ isActive: equals(selectedQuestion, question),
427
+ onDelete: isDeletable(question) && onDelete
428
+ })
429
+ })]
430
+ }));
431
+ });
432
+ }), placeholder]
433
+ }));
434
+ }
435
+ });
436
+ };
437
+
438
+ var moveItem = function moveItem(arr, sourceIndex, destinationIndex) {
439
+ if (sourceIndex === destinationIndex) return arr;
440
+ if (arr instanceof Array && arr[sourceIndex] !== undefined) {
441
+ var removedItem = arr.splice(sourceIndex, 1)[0];
442
+ arr.splice(destinationIndex, 0, removedItem);
443
+ }
444
+ return arr;
445
+ };
446
+ var arrayHelpers = {
447
+ moveItem: moveItem
448
+ };
449
+
450
+ var _excluded$b = ["fields"];
451
+ 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; }
452
+ 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; }
453
+ var isChoiceQuestion = function isChoiceQuestion(question) {
454
+ return includes(question === null || question === void 0 ? void 0 : question.kind, SELECTABLE_KINDS);
455
+ };
456
+ var isAddressQuestion = function isAddressQuestion(question) {
457
+ return (question === null || question === void 0 ? void 0 : question.kind) === QUESTION_TYPES.ADDRESS;
458
+ };
459
+ var underscoredWithoutSpecialCharacters = function underscoredWithoutSpecialCharacters(string) {
460
+ return string.toLowerCase().replace(/[\s-]/g, "_").replace(/[\W]/gi, "").replace(/_+/g, "_").replace(/^_+|_+$/, "");
461
+ };
462
+ var addSuffixForReservedFieldCode = function addSuffixForReservedFieldCode(fieldCode) {
463
+ return RESERVED_FIELD_CODES.includes(fieldCode) ? "".concat(fieldCode, "_field") : fieldCode;
464
+ };
465
+ var getUniqueNumbersFromExistingFieldCodes = function getUniqueNumbersFromExistingFieldCodes(prefix, questions) {
466
+ return questions.filter(function (question) {
467
+ return question.fieldCode.startsWith(prefix);
468
+ }).map(function (question) {
469
+ return parseInt(question.fieldCode.replace(prefix, "")) || 0;
470
+ });
471
+ };
472
+ var generateFieldCodePrefix = function generateFieldCodePrefix(label, kind) {
473
+ if (kind === QUESTION_TYPES.SPOT) {
474
+ return SPOT_QUESTION_FIELD_CODE;
475
+ }
476
+ var prefix;
477
+ if (isNameQuestion(kind) || NON_BASIC_LATIN_CHARACTERS_REGEX.test(label) || isEmpty(label)) {
478
+ prefix = kind;
479
+ } else {
480
+ var sanitizedLabel = underscoredWithoutSpecialCharacters(label).slice(0, 30);
481
+ prefix = isEmpty(sanitizedLabel) ? kind : sanitizedLabel;
482
+ }
483
+ return addSuffixForReservedFieldCode(prefix) || "";
484
+ };
485
+ var modifyDefaultValues = function modifyDefaultValues(_ref) {
486
+ var values = _ref.values,
487
+ kind = _ref.kind,
488
+ selectedLanguage = _ref.selectedLanguage,
489
+ isUsingDefaultQuestionKinds = _ref.isUsingDefaultQuestionKinds;
490
+ if (isNameQuestion(kind)) {
491
+ return renameKey(LABEL_FIELDS.DEFAULT, LABEL_FIELDS.FULL_NAME, values);
492
+ }
493
+ if (!includes(kind, SELECTABLE_KINDS) || isDefaultLanguage(selectedLanguage) || !isUsingDefaultQuestionKinds) {
494
+ return values;
495
+ }
496
+ return evolve({
497
+ optionsAttributes: map(assoc("label", ""))
498
+ }, values);
499
+ };
500
+ var generateUniqueFieldCode = function generateUniqueFieldCode(_ref2) {
501
+ var questions = _ref2.questions,
502
+ _ref2$label = _ref2.label,
503
+ label = _ref2$label === void 0 ? "" : _ref2$label,
504
+ _ref2$kind = _ref2.kind,
505
+ kind = _ref2$kind === void 0 ? "" : _ref2$kind;
506
+ var prefix = generateFieldCodePrefix(label, kind);
507
+ var uniqueNumber = Math.max.apply(Math, [0].concat(_toConsumableArray(getUniqueNumbersFromExistingFieldCodes(prefix, questions))));
508
+ var candidateFieldCode = "";
509
+
510
+ //We need to continue this while loop until we can generate a unique fieldCode
511
+
512
+ while (true) {
513
+ candidateFieldCode = "".concat(prefix).concat(uniqueNumber === 0 ? "" : uniqueNumber);
514
+ if (!findBy({
515
+ fieldCode: candidateFieldCode
516
+ }, questions)) break;
517
+ uniqueNumber += 1;
518
+ }
519
+ return candidateFieldCode;
520
+ };
521
+ var isQuestionKindAlreadyActive = function isQuestionKindAlreadyActive(_ref3) {
522
+ var activeQuestions = _ref3.activeQuestions,
523
+ kind = _ref3.kind;
524
+ return existsBy({
525
+ kind: kind.type
526
+ }, activeQuestions);
527
+ };
528
+ var handleFieldDragEnd = function handleFieldDragEnd(_ref4) {
529
+ var items = _ref4.items,
530
+ setValue = _ref4.setValue,
531
+ source = _ref4.source,
532
+ destination = _ref4.destination;
533
+ if (!(destination && items instanceof Array)) return;
534
+ var nextItems = _toConsumableArray(items);
535
+ arrayHelpers.moveItem(nextItems, source.index, destination.index);
536
+ var orderedItems = nextItems.map(function (item, index) {
537
+ return _objectSpread$i(_objectSpread$i({}, item), {}, {
538
+ displayOrder: index
539
+ });
540
+ });
541
+ setValue(orderedItems);
542
+ };
543
+ var createFieldData = function createFieldData(_ref5) {
544
+ var _ref5$kind = _ref5.kind,
545
+ defaults = _ref5$kind.defaults,
546
+ type = _ref5$kind.type,
547
+ metadata = _ref5$kind.metadata,
548
+ _ref5$isRequired = _ref5.isRequired,
549
+ isRequired = _ref5$isRequired === void 0 ? undefined : _ref5$isRequired,
550
+ questions = _ref5.questions,
551
+ selectedLanguage = _ref5.selectedLanguage,
552
+ isUsingDefaultQuestionKinds = _ref5.isUsingDefaultQuestionKinds;
553
+ var modifiedDefaultValues = modifyDefaultValues({
554
+ values: defaults,
555
+ kind: type,
556
+ selectedLanguage: selectedLanguage,
557
+ isUsingDefaultQuestionKinds: isUsingDefaultQuestionKinds
558
+ });
559
+ return _objectSpread$i(_objectSpread$i(_objectSpread$i({}, modifiedDefaultValues), {}, {
560
+ metadata: metadata
561
+ }, typeof isRequired === "boolean" && {
562
+ isRequired: isRequired
563
+ }), {}, {
564
+ kind: type,
565
+ nodeId: v4(),
566
+ fieldCode: generateUniqueFieldCode({
567
+ questions: questions,
568
+ kind: type,
569
+ label: defaults["label"]
570
+ })
571
+ });
572
+ };
573
+ var duplicateFieldData = function duplicateFieldData(_ref6) {
574
+ var item = _ref6.item,
575
+ questionKinds = _ref6.questionKinds,
576
+ questions = _ref6.questions;
577
+ var isRequired = item.isRequired,
578
+ kind = item.kind,
579
+ optionsAttributes = item.optionsAttributes;
580
+ var questionKind = findBy({
581
+ type: kind
582
+ }, questionKinds);
583
+ var label = fieldWithFallback(item, "label");
584
+ var defaultAttributeNames = keys(questionKind.defaults || {});
585
+ var _pick = pick(defaultAttributeNames, item),
586
+ fields = _pick.fields,
587
+ defaultAttributes = _objectWithoutProperties(_pick, _excluded$b);
588
+ var newQuestionLabel = isRichTextQuestion(kind) ? label : t("neetoForm.common.clonedElementLabel", {
589
+ label: label
590
+ });
591
+ return _objectSpread$i(_objectSpread$i({}, defaultAttributes), {}, {
592
+ isRequired: isRequired,
593
+ kind: kind,
594
+ label: newQuestionLabel,
595
+ optionsAttributes: optionsAttributes && optionsAttributes.map(omit(["id"])),
596
+ fieldsAttributes: fields && fields.map(omit(["id"])),
597
+ nodeId: v4(),
598
+ fieldCode: generateUniqueFieldCode({
599
+ questions: questions,
600
+ kind: kind,
601
+ label: newQuestionLabel
602
+ }),
603
+ displayOrder: item.displayOrder + 1
604
+ });
605
+ };
606
+ var getAvailableQuestionKinds = function getAvailableQuestionKinds(_ref7) {
607
+ var allQuestionKinds = _ref7.allQuestionKinds,
608
+ _ref7$activeQuestions = _ref7.activeQuestions,
609
+ activeQuestions = _ref7$activeQuestions === void 0 ? [] : _ref7$activeQuestions,
610
+ isKindAlreadyActive = _ref7.isKindAlreadyActive;
611
+ if (isEmpty(activeQuestions)) return allQuestionKinds;
612
+ return reject(function (kind) {
613
+ var isSingularKind = kind.isSingular;
614
+ return isAutoGeneratedQuestion(kind.type) || isSingularKind && isKindAlreadyActive({
615
+ activeQuestions: activeQuestions,
616
+ kind: kind
617
+ });
618
+ }, allQuestionKinds);
619
+ };
620
+ var formatQuestionAttributesForClone = when(function (question) {
621
+ return isChoiceQuestion(question) || isAddressQuestion(question);
622
+ }, assoc("isCloning", true));
623
+
624
+ var HelpText = withT(function (_ref) {
625
+ var t = _ref.t,
626
+ href = _ref.href;
627
+ return /*#__PURE__*/jsxs(Fragment, {
628
+ children: [t("neetoForm.questions.common.helpText.learnAbout"), " ", /*#__PURE__*/jsx(Button, {
629
+ href: href,
630
+ label: t("neetoForm.questions.common.helpText.howToAddNewQuestions"),
631
+ target: "_blank",
632
+ variant: "link"
633
+ })]
634
+ });
635
+ });
636
+
637
+ var AddFirstQuestion = function AddFirstQuestion(_ref) {
638
+ var onAdd = _ref.onAdd,
639
+ isDisabled = _ref.isDisabled,
640
+ disabledAddButtonHelpPopoverProps = _ref.disabledAddButtonHelpPopoverProps;
641
+ var _useTranslation = useTranslation(),
642
+ t = _useTranslation.t;
643
+ var _disabledAddButtonHel = disabledAddButtonHelpPopoverProps.helpLinkProps,
644
+ _disabledAddButtonHel2 = _disabledAddButtonHel === void 0 ? {} : _disabledAddButtonHel,
645
+ href = _disabledAddButtonHel2.href;
646
+ return /*#__PURE__*/jsx("div", {
647
+ className: "flex h-full flex-col items-center justify-center py-8",
648
+ children: /*#__PURE__*/jsx(Empty, {
649
+ className: "min-h-80",
650
+ helpText: isPresent(href) ? /*#__PURE__*/jsx(HelpText, {
651
+ href: href
652
+ }) : null,
653
+ primaryButtonProps: buildAddQuestionButtonProps(onAdd, isDisabled),
654
+ title: t("neetoForm.questions.common.noData")
655
+ })
656
+ });
657
+ };
658
+
659
+ var NAME = QUESTION_TYPES.NAME,
660
+ PHONE = QUESTION_TYPES.PHONE,
661
+ EMAIL$1 = QUESTION_TYPES.EMAIL,
662
+ ADDITIONAL_GUESTS = QUESTION_TYPES.ADDITIONAL_GUESTS,
663
+ TEXT = QUESTION_TYPES.TEXT,
664
+ TEXTAREA = QUESTION_TYPES.TEXTAREA,
665
+ RICH_TEXT = QUESTION_TYPES.RICH_TEXT,
666
+ INTEGER = QUESTION_TYPES.INTEGER,
667
+ DECIMAL = QUESTION_TYPES.DECIMAL,
668
+ STAR_RATING$1 = QUESTION_TYPES.STAR_RATING,
669
+ OPINION_SCALE$1 = QUESTION_TYPES.OPINION_SCALE,
670
+ RATING$1 = QUESTION_TYPES.RATING,
671
+ DATE = QUESTION_TYPES.DATE,
672
+ FILE_UPLOAD$1 = QUESTION_TYPES.FILE_UPLOAD,
673
+ CAPTCHA$1 = QUESTION_TYPES.CAPTCHA,
674
+ SMS_REMINDER = QUESTION_TYPES.SMS_REMINDER,
675
+ ADDRESS$1 = QUESTION_TYPES.ADDRESS;
676
+ var QUESTIONS_WITH_ADDITIONAL_DATA = [].concat(_toConsumableArray(SELECTABLE_KINDS), [STAR_RATING$1, OPINION_SCALE$1, RATING$1, FILE_UPLOAD$1, CAPTCHA$1, EMAIL$1, ADDRESS$1]);
677
+ var QUESTIONS_WITH_PLACEHOLDERS = [NAME, PHONE, EMAIL$1, ADDITIONAL_GUESTS, TEXT, TEXTAREA, RICH_TEXT, INTEGER, DECIMAL, DATE, SMS_REMINDER];
678
+ var DEFAULT_PLACEHOLDERS = {
679
+ CHECKBOX: t("neetoForm.questions.common.questionFields.field.labelExample", {
680
+ what: t("neetoForm.common.hobbies")
681
+ }),
682
+ RADIO: t("neetoForm.questions.common.questionFields.field.labelExample", {
683
+ what: t("neetoForm.common.country")
684
+ }),
685
+ DROPDOWN: t("neetoForm.questions.common.questionFields.field.labelExample", {
686
+ what: t("neetoForm.common.company")
687
+ })
688
+ };
689
+ var INITIAL_VALUES = {
690
+ kind: "",
691
+ label: "",
692
+ fieldCode: "",
693
+ isSplitMode: false,
694
+ minWords: null,
695
+ isMinWordsEnabled: false
696
+ };
697
+ var VALID_FIELD_CODE_REGEX = /^[a-z0-9]+(_[a-z0-9]+)*$/;
698
+ var DRAFT_ID_PREFIX = "draft-";
699
+
700
+ var useHelpDoc = function useHelpDoc(key) {
701
+ return useBuildFormStore(path(["formState", "helpDocUrls", key]));
702
+ };
703
+
704
+ var KindOption = function KindOption(_ref) {
705
+ var label = _ref.label,
706
+ description = _ref.description,
707
+ Icon = _ref.icon;
708
+ return /*#__PURE__*/jsxs("div", {
709
+ className: "flex items-start gap-2",
710
+ children: [Icon && /*#__PURE__*/jsx(Icon, {
711
+ className: "neeto-ui-text-gray-700 mt-0.5 shrink-0",
712
+ "data-testid": "kind-option-icon",
713
+ size: 16
714
+ }), /*#__PURE__*/jsxs("div", {
715
+ className: "flex min-w-0 flex-col",
716
+ children: [/*#__PURE__*/jsx(Typography, {
717
+ variant: "body2",
718
+ children: label
719
+ }), description && /*#__PURE__*/jsx(Typography, {
720
+ className: "text-muted-foreground mt-0.5",
721
+ "data-testid": "kind-option-description",
722
+ variant: "body3",
723
+ children: description
724
+ })]
725
+ })]
726
+ });
727
+ };
728
+
729
+ var _excluded$a = ["label", "name"];
730
+ 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; }
731
+ 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; }
732
+ var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
733
+ var label = _ref.label,
734
+ name = _ref.name,
735
+ otherProps = _objectWithoutProperties(_ref, _excluded$a);
736
+ var _useFormikContext = useFormikContext(),
737
+ dirty = _useFormikContext.dirty,
738
+ isValid = _useFormikContext.isValid,
739
+ submitForm = _useFormikContext.submitForm;
740
+ var handleKeyDown = function handleKeyDown(event) {
741
+ if (event.key !== "Enter" || event.shiftKey) return;
742
+ event.preventDefault();
743
+ if (isMetaKeyPressed(event)) return;
744
+ dirty && isValid && submitForm();
745
+ };
746
+ var handleFocus = function handleFocus(element) {
747
+ var end = element.value.length;
748
+ element.setSelectionRange(end, end);
749
+ };
750
+ return /*#__PURE__*/jsx(Textarea$1, _objectSpread$h({
751
+ label: label,
752
+ name: name,
753
+ className: "neeto-form-nano-adaptive-input",
754
+ resize: "none",
755
+ size: "small",
756
+ onFocus: function onFocus(_ref2) {
757
+ var target = _ref2.target;
758
+ return handleFocus(target);
759
+ },
760
+ onKeyDown: handleKeyDown
761
+ }, otherProps));
762
+ };
763
+
764
+ 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; }
765
+ 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; }
766
+ var LabelWithPlaceholder = function LabelWithPlaceholder(_ref) {
767
+ var kind = _ref.kind,
768
+ isLabelDisabled = _ref.isLabelDisabled,
769
+ handleLabelChange = _ref.handleLabelChange,
770
+ _ref$labelProps = _ref.labelProps,
771
+ labelProps = _ref$labelProps === void 0 ? {} : _ref$labelProps,
772
+ _ref$placeholderProps = _ref.placeholderProps,
773
+ placeholderProps = _ref$placeholderProps === void 0 ? {} : _ref$placeholderProps;
774
+ var _useTranslation = useTranslation(),
775
+ t = _useTranslation.t;
776
+ var shouldShowPlaceholder = includes(kind, QUESTIONS_WITH_PLACEHOLDERS);
777
+ return /*#__PURE__*/jsxs("div", {
778
+ className: "space-y-4",
779
+ children: [/*#__PURE__*/jsx(FormikAdaptiveInput, _objectSpread$g({
780
+ required: true,
781
+ disabled: isLabelDisabled,
782
+ label: t("neetoForm.questions.common.questionFields.field.question"),
783
+ name: "label",
784
+ placeholder: DEFAULT_PLACEHOLDERS[kind],
785
+ onChange: withEventTargetValue(handleLabelChange)
786
+ }, labelProps)), shouldShowPlaceholder && /*#__PURE__*/jsx(FormikAdaptiveInput, _objectSpread$g({
787
+ className: "neeto-form-nano-placeholder-input neeto-form-nano-placeholder-input-".concat(kind),
788
+ name: "placeholder",
789
+ label: t("neetoForm.questions.common.questionFields.field.placeholder")
790
+ }, placeholderProps))]
791
+ });
792
+ };
793
+
794
+ 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; }
795
+ 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; }
796
+ var Name = function Name(_ref) {
797
+ var isLabelDisabled = _ref.isLabelDisabled,
798
+ _handleLabelChange = _ref.handleLabelChange;
799
+ var _useFormikContext = useFormikContext(),
800
+ _useFormikContext$val = _useFormikContext.values.isSplitMode,
801
+ isSplitMode = _useFormikContext$val === void 0 ? false : _useFormikContext$val;
802
+ var _useTranslation = useTranslation(),
803
+ t = _useTranslation.t;
804
+ var usesCustomSubmissionComponent = useBuildFormStore(path(["formState", "usesCustomSubmissionComponent"]));
805
+ var commonProps = {
806
+ kind: QUESTION_TYPES.NAME,
807
+ isLabelDisabled: isLabelDisabled
808
+ };
809
+ return /*#__PURE__*/jsxs("div", {
810
+ className: "space-y-4",
811
+ children: [!usesCustomSubmissionComponent && /*#__PURE__*/jsx(Switch, {
812
+ label: t("neetoForm.common.splitAsFirstAndLastNames"),
813
+ name: "isSplitMode"
814
+ }), isSplitMode && !usesCustomSubmissionComponent ? /*#__PURE__*/jsxs(Fragment, {
815
+ children: [/*#__PURE__*/jsx(LabelWithPlaceholder, _objectSpread$f(_objectSpread$f({}, commonProps), {}, {
816
+ handleLabelChange: function handleLabelChange(value) {
817
+ return _handleLabelChange(value, LABEL_FIELDS.FIRST_NAME);
818
+ },
819
+ labelProps: {
820
+ label: t("neetoForm.questions.common.questionFields.field.firstNameQuestion"),
821
+ name: LABEL_FIELDS.FIRST_NAME
822
+ },
823
+ placeholderProps: {
824
+ label: t("neetoForm.questions.common.questionFields.field.firstNamePlaceholder"),
825
+ name: "firstNamePlaceholder"
826
+ }
827
+ })), /*#__PURE__*/jsx(LabelWithPlaceholder, _objectSpread$f(_objectSpread$f({}, commonProps), {}, {
828
+ handleLabelChange: function handleLabelChange(value) {
829
+ return _handleLabelChange(value, LABEL_FIELDS.LAST_NAME);
830
+ },
831
+ labelProps: {
832
+ label: t("neetoForm.questions.common.questionFields.field.lastNameQuestion"),
833
+ name: LABEL_FIELDS.LAST_NAME
834
+ },
835
+ placeholderProps: {
836
+ label: t("neetoForm.questions.common.questionFields.field.lastNamePlaceholder"),
837
+ name: "lastNamePlaceholder"
838
+ }
839
+ }))]
840
+ }) : /*#__PURE__*/jsx(LabelWithPlaceholder, _objectSpread$f(_objectSpread$f({}, commonProps), {}, {
841
+ labelProps: {
842
+ name: LABEL_FIELDS.FULL_NAME
843
+ },
844
+ placeholderProps: {
845
+ name: "fullNamePlaceholder"
846
+ },
847
+ handleLabelChange: function handleLabelChange(value) {
848
+ return _handleLabelChange(value, LABEL_FIELDS.FULL_NAME);
849
+ }
850
+ }))]
851
+ });
852
+ };
853
+
854
+ var Properties = function Properties(_ref) {
855
+ var kind = _ref.kind,
856
+ isLabelDisabled = _ref.isLabelDisabled,
857
+ handleLabelChange = _ref.handleLabelChange,
858
+ questionProps = _ref.questionProps;
859
+ var _useBuildFormStore = useBuildFormStore(function (store) {
860
+ var _store$formState;
861
+ return {
862
+ usesCustomSubmissionComponent: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["usesCustomSubmissionComponent"]
863
+ };
864
+ }, shallow),
865
+ usesCustomSubmissionComponent = _useBuildFormStore.usesCustomSubmissionComponent;
866
+ var hasAdditionalData = includes(kind, QUESTIONS_WITH_ADDITIONAL_DATA);
867
+ if (isNameQuestion(kind)) {
868
+ return /*#__PURE__*/jsx(Name, {
869
+ handleLabelChange: handleLabelChange,
870
+ isLabelDisabled: isLabelDisabled
871
+ });
872
+ }
873
+ return /*#__PURE__*/jsxs("div", {
874
+ className: "space-y-4",
875
+ children: [/*#__PURE__*/jsx(LabelWithPlaceholder, {
876
+ handleLabelChange: handleLabelChange,
877
+ isLabelDisabled: isLabelDisabled,
878
+ kind: kind
879
+ }), hasAdditionalData && renderAdditionalData({
880
+ kind: kind,
881
+ questionProps: questionProps,
882
+ usesCustomSubmissionComponent: usesCustomSubmissionComponent
883
+ })]
884
+ });
885
+ };
886
+
887
+ var useUpdateEditorContent = function useUpdateEditorContent(_ref) {
888
+ var editorRef = _ref.editorRef,
889
+ fieldName = _ref.fieldName,
890
+ value = _ref.value;
891
+ var initialStateRef = useRef({
892
+ language: "",
893
+ value: null
894
+ });
895
+ var _useBuildFormStore = useBuildFormStore(function (store) {
896
+ var _store$formState, _store$formState2;
897
+ return {
898
+ formId: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["formId"],
899
+ selectedLanguage: (_store$formState2 = store["formState"]) === null || _store$formState2 === void 0 ? void 0 : _store$formState2["selectedLanguage"]
900
+ };
901
+ }, shallow),
902
+ formId = _useBuildFormStore.formId,
903
+ language = _useBuildFormStore.selectedLanguage;
904
+ var setEditorContent = function setEditorContent(content) {
905
+ var _editorRef$current$ed;
906
+ return (_editorRef$current$ed = editorRef.current.editor) === null || _editorRef$current$ed === void 0 || (_editorRef$current$ed = _editorRef$current$ed.commands) === null || _editorRef$current$ed === void 0 ? void 0 : _editorRef$current$ed.setContent(content);
907
+ };
908
+ var _useForm = useForm({
909
+ formId: formId,
910
+ language: language
911
+ }),
912
+ data = _useForm.data;
913
+ useEffect(function () {
914
+ if (!data) return;
915
+ var pathArray = fieldName.split(".").map(function (part) {
916
+ var parsedPart = parseInt(part);
917
+ return isNaN(parsedPart) ? part : parsedPart;
918
+ });
919
+ setEditorContent(path(pathArray, data));
920
+ }, [data]);
921
+ useEffect(function () {
922
+ if (initialStateRef.current["language"] !== language) {
923
+ initialStateRef.current["language"] = language;
924
+ initialStateRef.current["value"] = null;
925
+ return;
926
+ }
927
+ if (initialStateRef.current["value"] === null && value !== null) {
928
+ setEditorContent(value);
929
+ initialStateRef.current["value"] = value;
930
+ }
931
+ }, [language, value]);
932
+ };
933
+
934
+ var Editor = function Editor() {
935
+ var editorRef = useRef({
936
+ editor: {}
937
+ });
938
+ var fieldName = "label";
939
+ var _useField = useField({
940
+ name: fieldName,
941
+ validate: validateEditorContent(editorRef)
942
+ }),
943
+ _useField2 = _slicedToArray(_useField, 3),
944
+ value = _useField2[0].value,
945
+ _useField2$ = _useField2[1],
946
+ touched = _useField2$.touched,
947
+ error = _useField2$.error,
948
+ _useField2$2 = _useField2[2],
949
+ setTouched = _useField2$2.setTouched,
950
+ setValue = _useField2$2.setValue;
951
+ useUpdateEditorContent({
952
+ editorRef: editorRef,
953
+ fieldName: fieldName,
954
+ value: value
955
+ });
956
+ return /*#__PURE__*/jsx("div", {
957
+ className: "w-full cursor-auto",
958
+ children: /*#__PURE__*/jsx(NeetoEditor, {
959
+ required: true,
960
+ error: touched ? error : "",
961
+ id: "editor",
962
+ initialValue: value,
963
+ name: fieldName,
964
+ ref: editorRef,
965
+ onBlur: function onBlur() {
966
+ return setTouched(true);
967
+ },
968
+ onChange: setValue
969
+ })
970
+ });
971
+ };
972
+
973
+ var RequiredSwitch = withT(function (_ref) {
974
+ var t = _ref.t;
975
+ return /*#__PURE__*/jsx("div", {
976
+ className: "w-full",
977
+ children: /*#__PURE__*/jsx(Switch, {
978
+ label: t("neetoForm.common.required"),
979
+ name: "isRequired"
980
+ })
981
+ });
982
+ });
983
+
984
+ var _excluded$9 = ["maxLength"];
985
+ 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; }
986
+ 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; }
987
+ var InputWithMaxLength = function InputWithMaxLength(_ref) {
988
+ var maxLength = _ref.maxLength,
989
+ props = _objectWithoutProperties(_ref, _excluded$9);
990
+ var _useField = useField(props),
991
+ _useField2 = _slicedToArray(_useField, 3),
992
+ value = _useField2[0].value,
993
+ setValue = _useField2[2].setValue;
994
+ useEffect(function () {
995
+ if (value && value.length > maxLength) {
996
+ setValue(value.substring(0, maxLength));
997
+ }
998
+ }, [value, maxLength, setValue]);
999
+ var shouldShowMaxLength = value && value.length > maxLength - 10;
1000
+ return /*#__PURE__*/jsx(Input, _objectSpread$e(_objectSpread$e({}, props), shouldShowMaxLength && {
1001
+ maxLength: maxLength
1002
+ }));
1003
+ };
1004
+
1005
+ var FieldCode = function FieldCode() {
1006
+ var helpDocUrl = useHelpDoc("fieldCode");
1007
+ var _useTranslation = useTranslation(),
1008
+ t = _useTranslation.t;
1009
+ return /*#__PURE__*/jsx(InputWithMaxLength, {
1010
+ required: true,
1011
+ label: t("neetoForm.questions.common.questionFields.field.fieldCode"),
1012
+ name: "fieldCode",
1013
+ rejectCharsRegex: FIELD_CODES_REJECT_CHARS_REGEX,
1014
+ helpText: helpDocUrl && /*#__PURE__*/jsx(Trans, {
1015
+ i18nKey: "neetoForm.questions.common.questionFields.field.fieldCodeHelpDescription",
1016
+ components: {
1017
+ Link: /*#__PURE__*/jsx(Button, {
1018
+ className: "text-xs",
1019
+ href: helpDocUrl,
1020
+ target: "_blank",
1021
+ variant: "link"
1022
+ })
1023
+ }
1024
+ })
1025
+ });
1026
+ };
1027
+
1028
+ var Textarea = function Textarea() {
1029
+ var _useTranslation = useTranslation(),
1030
+ t = _useTranslation.t;
1031
+ var _useField = useField("minWords"),
1032
+ _useField2 = _slicedToArray(_useField, 3),
1033
+ setMinWords = _useField2[2].setValue;
1034
+ var _useField3 = useField("isMinWordsEnabled"),
1035
+ _useField4 = _slicedToArray(_useField3, 3),
1036
+ isMinWordsEnabled = _useField4[0].value,
1037
+ setIsMinWordsEnabled = _useField4[2].setValue;
1038
+ var handleToggleChange = function handleToggleChange() {
1039
+ var isEnabled = !isMinWordsEnabled;
1040
+ setIsMinWordsEnabled(isEnabled);
1041
+ setMinWords(isEnabled ? MIN_WORDS.DEFAULT : null);
1042
+ };
1043
+ return /*#__PURE__*/jsxs("div", {
1044
+ className: "flex flex-col gap-2",
1045
+ children: [/*#__PURE__*/jsx(Switch$1, {
1046
+ checked: isMinWordsEnabled,
1047
+ label: t("neetoForm.questions.textarea.minimumWords"),
1048
+ labelProps: MIN_WORDS_SWITCH_LABEL_PROPS,
1049
+ onCheckedChange: handleToggleChange
1050
+ }), isMinWordsEnabled && /*#__PURE__*/jsx(Input, {
1051
+ className: "w-42 ms-14",
1052
+ max: MIN_WORDS.MAX,
1053
+ min: MIN_WORDS.MIN,
1054
+ name: "minWords",
1055
+ type: "number"
1056
+ })]
1057
+ });
1058
+ };
1059
+
1060
+ 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; }
1061
+ 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; }
1062
+ var Form$1 = function Form(_ref) {
1063
+ var questions = _ref.questions,
1064
+ initialFocusRef = _ref.initialFocusRef,
1065
+ isRequiredField = _ref.isRequiredField,
1066
+ isDisabledFieldLabel = _ref.isDisabledFieldLabel,
1067
+ allQuestionKinds = _ref.allQuestionKinds,
1068
+ availableQuestionKinds = _ref.availableQuestionKinds,
1069
+ getActiveKindDetails = _ref.getActiveKindDetails,
1070
+ kindUniqueOn = _ref.kindUniqueOn,
1071
+ _ref$isEdit = _ref.isEdit,
1072
+ isEdit = _ref$isEdit === void 0 ? false : _ref$isEdit;
1073
+ var _useState = useState(false),
1074
+ _useState2 = _slicedToArray(_useState, 2),
1075
+ isFieldCodeInvalid = _useState2[0],
1076
+ setIsFieldCodeInvalid = _useState2[1];
1077
+ var _useTranslation = useTranslation(),
1078
+ t = _useTranslation.t;
1079
+ var _useFormikContext = useFormikContext(),
1080
+ values = _useFormikContext.values,
1081
+ setValues = _useFormikContext.setValues,
1082
+ setErrors = _useFormikContext.setErrors,
1083
+ setTouched = _useFormikContext.setTouched,
1084
+ setFieldValue = _useFormikContext.setFieldValue,
1085
+ errors = _useFormikContext.errors,
1086
+ submitCount = _useFormikContext.submitCount;
1087
+ var hideQuestionHelpDocUrl = useHelpDoc("hideQuestion");
1088
+ var readOnlyHelpDocUrl = useHelpDoc("readOnly");
1089
+ var responseVisibleOnlyToHostHelpDocUrl = useHelpDoc("responseVisibleOnlyToHost");
1090
+ var _useBuildFormStore = useBuildFormStore(function (store) {
1091
+ var _store$formState, _store$formState2, _store$formState3, _store$formState4;
1092
+ return {
1093
+ advancedFeatures: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["advancedFeatures"],
1094
+ selectedLanguage: (_store$formState2 = store["formState"]) === null || _store$formState2 === void 0 ? void 0 : _store$formState2["selectedLanguage"],
1095
+ isUsingDefaultQuestionKinds: (_store$formState3 = store["formState"]) === null || _store$formState3 === void 0 ? void 0 : _store$formState3["isUsingDefaultQuestionKinds"],
1096
+ usesCustomSubmissionComponent: (_store$formState4 = store["formState"]) === null || _store$formState4 === void 0 ? void 0 : _store$formState4["usesCustomSubmissionComponent"]
1097
+ };
1098
+ }, shallow),
1099
+ advancedFeatures = _useBuildFormStore.advancedFeatures,
1100
+ selectedLanguage = _useBuildFormStore.selectedLanguage,
1101
+ isUsingDefaultQuestionKinds = _useBuildFormStore.isUsingDefaultQuestionKinds,
1102
+ usesCustomSubmissionComponent = _useBuildFormStore.usesCustomSubmissionComponent;
1103
+ var isFieldCodeEnabled = advancedFeatures.fieldCode,
1104
+ markResponsesAsReadOnly = advancedFeatures.markResponsesAsReadOnly,
1105
+ restrictResponseVisibilityToHost = advancedFeatures.restrictResponseVisibilityToHost,
1106
+ enforceMinWordsInMultiLineTexts = advancedFeatures.enforceMinWordsInMultiLineTexts;
1107
+ var kind = values.kind;
1108
+ var questionKinds = isEdit ? allQuestionKinds : availableQuestionKinds;
1109
+ var questionKindUniquenessPattern = mergeLeft(isEdit && kindUniqueOn ? kindUniqueOn(values) : {}, {
1110
+ type: kind
1111
+ });
1112
+ var _useStateWithDependen = useStateWithDependency(getQuestionKind(questionKinds, questionKindUniquenessPattern), [kind]),
1113
+ _useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 1),
1114
+ questionKind = _useStateWithDependen2[0];
1115
+ var _ref2 = questionKind ? getActiveKindDetails({
1116
+ allQuestionKinds: allQuestionKinds,
1117
+ item: questionKind
1118
+ }) : {},
1119
+ _ref2$questionProps = _ref2.questionProps,
1120
+ questionProps = _ref2$questionProps === void 0 ? {} : _ref2$questionProps;
1121
+ useEffect(function () {
1122
+ if (submitCount > 0 && isPresent(errors === null || errors === void 0 ? void 0 : errors.fieldCode)) {
1123
+ setIsFieldCodeInvalid(true);
1124
+ }
1125
+ }, [submitCount]);
1126
+ var isRequired = questionKind && isRequiredField(questionKind);
1127
+ var isLabelDisabled = questionKind && isDisabledFieldLabel(questionKind);
1128
+ var isImmutable = questionKind && isImmutableField(questionKind);
1129
+ var shouldShowFieldCode = isFieldCodeEnabled && !includes(kind, QUESTIONS_WITHOUT_FIELD_CODE);
1130
+ var shouldShowHideSwitch = isFieldCodeEnabled && !usesCustomSubmissionComponent && !includes(kind, NON_HIDEABLE_FIELDS);
1131
+ var canRestrictResponseVisibilityToHost = restrictResponseVisibilityToHost && !includes(kind, NON_HIDEABLE_FIELDS);
1132
+ var canMarkResponsesAsReadOnly = markResponsesAsReadOnly && !includes(kind, NON_READ_ONLY_FIELDS);
1133
+ var isTextarea = kind === QUESTION_TYPES.TEXTAREA;
1134
+ var isBasicSettingsVisible = !isRequired && (!isImmutable || shouldShowHideSwitch);
1135
+ var shouldShowRequiredSwitch = isBasicSettingsVisible && !isImmutable && !includes(kind, [QUESTION_TYPES.PARAGRAPH, QUESTION_TYPES.ADDRESS, QUESTION_TYPES.SPOT]);
1136
+ var isSettingsBlockVisible = kind !== QUESTION_TYPES.SPOT && (isBasicSettingsVisible || canMarkResponsesAsReadOnly || isTextarea);
1137
+ var handleKindChange = function handleKindChange(option) {
1138
+ var data = buildQuestionData(option);
1139
+ updateFormState(data);
1140
+ };
1141
+ var buildQuestionData = function buildQuestionData(option) {
1142
+ if (isNil(option)) {
1143
+ return INITIAL_VALUES;
1144
+ }
1145
+ var label = option.label,
1146
+ value = option.value;
1147
+ var kind = extractKindFromOption(value);
1148
+ var questionKind = getQuestionKind(availableQuestionKinds, {
1149
+ type: kind,
1150
+ label: label
1151
+ });
1152
+ return createFieldData({
1153
+ kind: questionKind,
1154
+ isRequired: isRequired,
1155
+ questions: questions,
1156
+ selectedLanguage: selectedLanguage,
1157
+ isUsingDefaultQuestionKinds: isUsingDefaultQuestionKinds
1158
+ });
1159
+ };
1160
+ var updateFormState = function updateFormState(data) {
1161
+ setValues(data);
1162
+ setErrors({});
1163
+ setTouched({});
1164
+ };
1165
+ var handleLabelChange = function handleLabelChange(label) {
1166
+ var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : LABEL_FIELDS.DEFAULT;
1167
+ setFieldValue(name, label);
1168
+ if (isEdit) return;
1169
+ var uniqueFieldCode = generateUniqueFieldCode({
1170
+ questions: questions,
1171
+ label: label,
1172
+ kind: kind
1173
+ });
1174
+ setFieldValue("fieldCode", uniqueFieldCode);
1175
+ };
1176
+ return /*#__PURE__*/jsx(Sheet.Body, {
1177
+ children: /*#__PURE__*/jsxs("div", {
1178
+ className: "w-full space-y-4",
1179
+ children: [/*#__PURE__*/jsx(Select, {
1180
+ isClearable: true,
1181
+ isSearchable: true,
1182
+ defaultValue: buildDefaultValueForKind(questionKind),
1183
+ filterOption: filterKindOption,
1184
+ innerRef: initialFocusRef,
1185
+ isDisabled: isEdit,
1186
+ name: "kind",
1187
+ options: buildKindOptions(questionKinds),
1188
+ formatOptionLabel: function formatOptionLabel(option, _ref3) {
1189
+ var context = _ref3.context;
1190
+ return context === "menu" ? /*#__PURE__*/jsx(KindOption, _objectSpread$d({}, option)) : option.label;
1191
+ },
1192
+ label: t("neetoForm.questions.common.questionFields.field.questionType"),
1193
+ onChange: handleKindChange
1194
+ }), isRichTextQuestion(kind) ? /*#__PURE__*/jsxs(Fragment, {
1195
+ children: [/*#__PURE__*/jsx(Editor, {
1196
+ isLabelDisabled: isLabelDisabled
1197
+ }), shouldShowRequiredSwitch && /*#__PURE__*/jsx(RequiredSwitch, {})]
1198
+ }) : /*#__PURE__*/jsxs("div", {
1199
+ className: "space-y-4",
1200
+ children: [/*#__PURE__*/jsx(Properties, {
1201
+ handleLabelChange: handleLabelChange,
1202
+ isLabelDisabled: isLabelDisabled,
1203
+ kind: kind,
1204
+ questionProps: questionProps
1205
+ }), isSettingsBlockVisible && /*#__PURE__*/jsxs("div", {
1206
+ className: "space-y-4",
1207
+ "data-testid": "settings-card",
1208
+ children: [isBasicSettingsVisible && /*#__PURE__*/jsxs(Fragment, {
1209
+ children: [shouldShowRequiredSwitch && /*#__PURE__*/jsx(RequiredSwitch, {}), shouldShowHideSwitch && /*#__PURE__*/jsx(Switch, {
1210
+ label: t("neetoForm.common.hideQuestion"),
1211
+ name: "isHidden",
1212
+ labelProps: hideSwitchLabelProps(hideQuestionHelpDocUrl)
1213
+ }), canRestrictResponseVisibilityToHost && /*#__PURE__*/jsx(Switch, {
1214
+ label: t("neetoForm.common.responseVisibleOnlyToHost"),
1215
+ name: "isResponseVisibleOnlyToHost",
1216
+ labelProps: responseVisibleOnlyToHostSwitchLabelProps(responseVisibleOnlyToHostHelpDocUrl)
1217
+ })]
1218
+ }), canMarkResponsesAsReadOnly && /*#__PURE__*/jsx(Switch, {
1219
+ label: t("neetoForm.common.readOnly"),
1220
+ labelProps: readOnlySwitchLabelProps(readOnlyHelpDocUrl),
1221
+ name: "isReadOnly"
1222
+ }), isTextarea && enforceMinWordsInMultiLineTexts && /*#__PURE__*/jsx(Textarea, {})]
1223
+ }), shouldShowFieldCode && /*#__PURE__*/jsx(Accordion, {
1224
+ className: "neeto-form-nano-advanced-properties-accordion",
1225
+ "data-testid": "advanced-properties-card",
1226
+ defaultActiveKey: isFieldCodeInvalid ? 0 : null // This is to open the accordion when field code is invalid
1227
+ ,
1228
+ children: /*#__PURE__*/jsx(Accordion.Item, {
1229
+ title: t("neetoForm.common.advancedProperties"),
1230
+ children: /*#__PURE__*/jsx("div", {
1231
+ className: "flex flex-col space-y-4",
1232
+ children: shouldShowFieldCode && /*#__PURE__*/jsx(FieldCode, {})
1233
+ })
1234
+ })
1235
+ })]
1236
+ })]
1237
+ })
1238
+ });
1239
+ };
1240
+
1241
+ var requiredLabelValidation = function requiredLabelValidation(schema, field) {
1242
+ return schema.trim().required(t("neetoForm.common.fieldReq", {
1243
+ field: field
1244
+ }));
1245
+ };
1246
+ var fieldCodeValidation = function fieldCodeValidation(schema, field) {
1247
+ return schema.trim().required(t("neetoForm.common.fieldReq", {
1248
+ field: field
1249
+ })).matches(VALID_FIELD_CODE_REGEX, t("neetoForm.error.invalidField", {
1250
+ label: field
1251
+ }));
1252
+ };
1253
+ var richTextFieldMissingErrorMessage = function richTextFieldMissingErrorMessage(kind) {
1254
+ var field = equals(kind, QUESTION_TYPES.PARAGRAPH) ? t("neetoForm.fields.def") : t("neetoForm.fields.tcf");
1255
+ return t("neetoForm.error.fieldCantBeEmpty", {
1256
+ field: field
1257
+ });
1258
+ };
1259
+ var buildLabelValidationSchema = function buildLabelValidationSchema(kind, schema) {
1260
+ if (isNameQuestion(kind)) {
1261
+ return schema.notRequired();
1262
+ }
1263
+ return includes(kind, RICH_TEXT_QUESTIONS) ? schema.test("required", richTextFieldMissingErrorMessage(kind), function (value) {
1264
+ return !isEditorEmpty(value);
1265
+ }) : requiredLabelValidation(schema, t("neetoForm.questions.common.questionFields.field.question"));
1266
+ };
1267
+ var buildNameLabelValidationSchema = function buildNameLabelValidationSchema(question, schema) {
1268
+ var isFullName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1269
+ var isRequired = isFullName ? !question.isSplitMode : question.isSplitMode;
1270
+ return isNameQuestion(question.kind) && isRequired ? requiredLabelValidation(schema, t("neetoForm.questions.common.questionFields.field.question")) : schema.notRequired();
1271
+ };
1272
+ var buildOpinionScaleLabelValidationSchema = function buildOpinionScaleLabelValidationSchema(label) {
1273
+ return stringSchema.when("hasOpinionLabels", {
1274
+ is: true,
1275
+ then: requiredLabelValidation(stringSchema, label).max(OPINION_LABEL_MAX_LENGTH, t("neetoForm.error.mustBeOrLessThanOrEqualTo", {
1276
+ value: OPINION_LABEL_MAX_LENGTH
1277
+ })),
1278
+ otherwise: stringSchema.notRequired()
1279
+ });
1280
+ };
1281
+ var stringSchema = yup.string();
1282
+ var formValidationSchema = function formValidationSchema(question) {
1283
+ var isFieldCodeEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1284
+ return yup.object().shape({
1285
+ kind: yup.string().trim().required(t("neetoForm.common.fieldReq", {
1286
+ field: t("neetoForm.questions.common.questionFields.field.questionType")
1287
+ })),
1288
+ label: yup.string().when("kind", buildLabelValidationSchema),
1289
+ fullNameLabel: buildNameLabelValidationSchema(question, stringSchema, true),
1290
+ firstNameLabel: buildNameLabelValidationSchema(question, stringSchema),
1291
+ lastNameLabel: buildNameLabelValidationSchema(question, stringSchema),
1292
+ fieldCode: yup.string().trim().notOneOf(RESERVED_FIELD_CODES, t("neetoForm.error.invalidFieldCode")).when("kind", function (kind, schema) {
1293
+ return isFieldCodeEnabled && !includes(kind, QUESTIONS_WITHOUT_FIELD_CODE) ? fieldCodeValidation(schema, t("neetoForm.questions.common.questionFields.field.fieldCode")) : schema.notRequired();
1294
+ }),
1295
+ optionsAttributes: yup.array().when("kind", function (kind, schema) {
1296
+ return includes(kind, SELECTABLE_KINDS) ? schema.of(yup.object().shape({
1297
+ label: yup.string().when("_destroy", {
1298
+ is: true,
1299
+ otherwise: requiredLabelValidation(yup.string(), t("neetoForm.questions.common.questionFields.field.option"))
1300
+ })
1301
+ })) : schema.notRequired();
1302
+ }),
1303
+ fields: yup.array().when("kind", function (kind, schema) {
1304
+ return kind === QUESTION_TYPES.ADDRESS ? schema.of(yup.object().shape({
1305
+ label: yup.string().when("_destroy", {
1306
+ is: true,
1307
+ otherwise: yup.string().trim().required(t("neetoForm.error.allFieldsRequired"))
1308
+ })
1309
+ })) : schema.notRequired();
1310
+ }),
1311
+ minWords: yup.number().nullable().when(["kind", "isMinWordsEnabled"], function (kind, isMinWordsEnabled, schema) {
1312
+ if (kind !== QUESTION_TYPES.TEXTAREA) return schema.notRequired();
1313
+ if (!isMinWordsEnabled) return schema.notRequired();
1314
+ return schema.typeError(t("neetoForm.questions.textarea.minimumWordsMinError")).required(t("neetoForm.questions.textarea.minimumWordsMinError")).min(MIN_WORDS.MIN, t("neetoForm.questions.textarea.minimumWordsMinError")).max(MIN_WORDS.MAX, t("neetoForm.questions.textarea.minimumWordsMaxError"));
1315
+ }),
1316
+ highestRatingLabel: yup.string().nullable(),
1317
+ averageRatingLabel: yup.string().nullable(),
1318
+ lowestRatingLabel: yup.string().nullable(),
1319
+ leftOpinionLabel: buildOpinionScaleLabelValidationSchema(t("neetoForm.questions.opinionScale.leftLabel")),
1320
+ rightOpinionLabel: buildOpinionScaleLabelValidationSchema(t("neetoForm.questions.opinionScale.rightLabel"))
1321
+ });
1322
+ };
1323
+
1324
+ var _excluded$8 = ["question", "onClose", "questions", "handleSelect", "isOpen"];
1325
+ 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; }
1326
+ 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; }
1327
+ var Add = function Add(_ref) {
1328
+ var question = _ref.question,
1329
+ onClose = _ref.onClose,
1330
+ questions = _ref.questions,
1331
+ handleSelect = _ref.handleSelect,
1332
+ isOpen = _ref.isOpen,
1333
+ props = _objectWithoutProperties(_ref, _excluded$8);
1334
+ var _useBuildFormStore = useBuildFormStore(function (store) {
1335
+ var _store$formState, _store$formState2, _store$formState3;
1336
+ return {
1337
+ formId: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["formId"],
1338
+ selectedLanguage: (_store$formState2 = store["formState"]) === null || _store$formState2 === void 0 ? void 0 : _store$formState2["selectedLanguage"],
1339
+ onMutateSuccess: (_store$formState3 = store["formState"]) === null || _store$formState3 === void 0 ? void 0 : _store$formState3["onMutateSuccess"]
1340
+ };
1341
+ }, shallow),
1342
+ formId = _useBuildFormStore.formId,
1343
+ language = _useBuildFormStore.selectedLanguage,
1344
+ onMutateSuccess = _useBuildFormStore.onMutateSuccess;
1345
+ var isFieldCodeEnabled = useBuildFormStore(path(["advancedFeatures", "fieldCode"]));
1346
+ var _useTranslation = useTranslation(),
1347
+ t = _useTranslation.t;
1348
+ var _useCreateQuestion = useCreateQuestion(formId, language, {
1349
+ onSuccess: function onSuccess() {
1350
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1351
+ args[_key] = arguments[_key];
1352
+ }
1353
+ onMutateSuccess === null || onMutateSuccess === void 0 || onMutateSuccess.apply(void 0, [QUESTION_ACTIONS.ADD].concat(args));
1354
+ showThumbsUpToastr();
1355
+ onClose();
1356
+ }
1357
+ }),
1358
+ createQuestion = _useCreateQuestion.mutate,
1359
+ isCreating = _useCreateQuestion.isPending;
1360
+ var handleSubmit = function handleSubmit(values) {
1361
+ if (isCreating || !isOpen) return;
1362
+ var displayOrder = question ? question.displayOrder + 1 : questions.length;
1363
+ createQuestion({
1364
+ language: language,
1365
+ neetoFormQuestion: mergeLeft({
1366
+ displayOrder: displayOrder
1367
+ }, transformValues(values))
1368
+ }, {
1369
+ onSuccess: function onSuccess(_ref2) {
1370
+ var questions = _ref2.questions;
1371
+ var newQuestion = findBy({
1372
+ displayOrder: displayOrder
1373
+ }, questions);
1374
+ handleSelect(newQuestion);
1375
+ }
1376
+ });
1377
+ };
1378
+ return /*#__PURE__*/jsxs(Fragment, {
1379
+ children: [/*#__PURE__*/jsx(Sheet.Header, {
1380
+ children: /*#__PURE__*/jsx(Sheet.Title, {
1381
+ "data-testid": "add-question-pane-header",
1382
+ children: t("neetoForm.questions.common.primaryPanel.addQuestion")
1383
+ })
1384
+ }), /*#__PURE__*/jsx(Form$2, {
1385
+ formikProps: {
1386
+ initialValues: INITIAL_VALUES,
1387
+ validationSchema: formValidationSchema(INITIAL_VALUES, isFieldCodeEnabled),
1388
+ onSubmit: handleSubmit
1389
+ },
1390
+ children: /*#__PURE__*/jsxs(Fragment, {
1391
+ children: [/*#__PURE__*/jsx(Form$1, _objectSpread$c({}, _objectSpread$c(_objectSpread$c({}, props), {}, {
1392
+ question: question,
1393
+ questions: questions
1394
+ }))), /*#__PURE__*/jsx(Sheet.Footer, {
1395
+ children: /*#__PURE__*/jsx(ActionBlock, {
1396
+ cancelButtonProps: {
1397
+ onClick: onClose
1398
+ },
1399
+ isSubmitting: isCreating
1400
+ })
1401
+ })]
1402
+ })
1403
+ })]
1404
+ });
1405
+ };
1406
+
1407
+ var _excluded$7 = ["question", "isOpen", "onClose"];
1408
+ 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; }
1409
+ 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; }
1410
+ var Edit = function Edit(_ref) {
1411
+ var question = _ref.question,
1412
+ isOpen = _ref.isOpen,
1413
+ onClose = _ref.onClose,
1414
+ props = _objectWithoutProperties(_ref, _excluded$7);
1415
+ var _useTranslation = useTranslation(),
1416
+ t = _useTranslation.t;
1417
+ var _useBuildFormStore = useBuildFormStore(function (store) {
1418
+ var _store$formState, _store$formState2;
1419
+ return {
1420
+ selectedLanguage: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["selectedLanguage"],
1421
+ onMutateSuccess: (_store$formState2 = store["formState"]) === null || _store$formState2 === void 0 ? void 0 : _store$formState2["onMutateSuccess"]
1422
+ };
1423
+ }, shallow),
1424
+ language = _useBuildFormStore.selectedLanguage,
1425
+ onMutateSuccess = _useBuildFormStore.onMutateSuccess;
1426
+ var isFieldCodeEnabled = useBuildFormStore(path(["advancedFeatures", "fieldCode"]));
1427
+ var _useUpdateQuestion = useUpdateQuestion(question === null || question === void 0 ? void 0 : question.formId, language),
1428
+ updateQuestion = _useUpdateQuestion.mutate,
1429
+ isUpdating = _useUpdateQuestion.isPending;
1430
+ var handleSubmit = function handleSubmit(values, _ref2) {
1431
+ var setSubmitting = _ref2.setSubmitting;
1432
+ if (isUpdating || !isOpen) return;
1433
+ var payload = {
1434
+ language: language,
1435
+ neetoFormQuestion: transformValues(values)
1436
+ };
1437
+ updateQuestion({
1438
+ questionId: question.id,
1439
+ payload: payload
1440
+ }, {
1441
+ onSuccess: function onSuccess() {
1442
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1443
+ args[_key] = arguments[_key];
1444
+ }
1445
+ onMutateSuccess === null || onMutateSuccess === void 0 || onMutateSuccess.apply(void 0, [QUESTION_ACTIONS.EDIT].concat(args));
1446
+ showThumbsUpToastr();
1447
+ onClose();
1448
+ },
1449
+ onSettled: function onSettled() {
1450
+ return setSubmitting(false);
1451
+ }
1452
+ });
1453
+ };
1454
+ return /*#__PURE__*/jsxs(Fragment, {
1455
+ children: [/*#__PURE__*/jsx(Sheet.Header, {
1456
+ children: /*#__PURE__*/jsx(Sheet.Title, {
1457
+ asChild: true,
1458
+ children: /*#__PURE__*/jsx(Typography, {
1459
+ "data-testid": "edit-question-pane-header",
1460
+ variant: "h2",
1461
+ children: t("neetoForm.questions.common.editQuestion")
1462
+ })
1463
+ })
1464
+ }), /*#__PURE__*/jsx(Form$2, {
1465
+ formikProps: {
1466
+ initialValues: _objectSpread$b(_objectSpread$b({}, question), {}, {
1467
+ isMinWordsEnabled: isPresent(question.minWords)
1468
+ }),
1469
+ validationSchema: formValidationSchema(question, isFieldCodeEnabled),
1470
+ onSubmit: handleSubmit
1471
+ },
1472
+ children: /*#__PURE__*/jsxs(Fragment, {
1473
+ children: [/*#__PURE__*/jsx(Sheet.Body, {
1474
+ children: /*#__PURE__*/jsx(Form$1, _objectSpread$b(_objectSpread$b({}, _objectSpread$b({
1475
+ question: question
1476
+ }, props)), {}, {
1477
+ isEdit: true
1478
+ }))
1479
+ }), /*#__PURE__*/jsx(Sheet.Footer, {
1480
+ children: /*#__PURE__*/jsx(ActionBlock, {
1481
+ cancelButtonProps: {
1482
+ onClick: onClose
1483
+ },
1484
+ isSubmitting: isUpdating
1485
+ })
1486
+ })]
1487
+ })
1488
+ })]
1489
+ });
1490
+ };
1491
+
1492
+ var Block = function Block(_ref) {
1493
+ var title = _ref.title,
1494
+ children = _ref.children,
1495
+ dataTestid = _ref.dataTestid;
1496
+ return /*#__PURE__*/jsxs("div", {
1497
+ className: "mt-4 space-y-3",
1498
+ "data-testid": dataTestid,
1499
+ children: [/*#__PURE__*/jsx("div", {
1500
+ className: "flex items-center justify-between",
1501
+ "data-testid": "properties-header",
1502
+ children: /*#__PURE__*/jsx(Typography, {
1503
+ variant: "body1",
1504
+ weight: "semibold",
1505
+ children: title
1506
+ })
1507
+ }), /*#__PURE__*/jsx("div", {
1508
+ className: "space-y-4",
1509
+ children: children
1510
+ })]
1511
+ });
1512
+ };
1513
+
1514
+ var VARIANTS = {
1515
+ hidden: {
1516
+ opacity: 0,
1517
+ height: 0,
1518
+ overflow: "hidden"
1519
+ },
1520
+ visible: {
1521
+ opacity: 1,
1522
+ height: "auto"
1523
+ }
1524
+ };
1525
+
1526
+ var _excluded$6 = ["open", "className", "children"];
1527
+ 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; }
1528
+ 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; }
1529
+ var Collapsible = function Collapsible(_ref) {
1530
+ var open = _ref.open,
1531
+ _ref$className = _ref.className,
1532
+ className = _ref$className === void 0 ? "" : _ref$className,
1533
+ children = _ref.children,
1534
+ otherProps = _objectWithoutProperties(_ref, _excluded$6);
1535
+ return /*#__PURE__*/jsx(AnimatePresence, {
1536
+ children: open && /*#__PURE__*/jsx(motion.div, _objectSpread$a(_objectSpread$a({
1537
+ animate: "visible",
1538
+ exit: "hidden",
1539
+ initial: "hidden",
1540
+ transition: {
1541
+ duration: 0.3
1542
+ },
1543
+ variants: VARIANTS
1544
+ }, otherProps), {}, {
1545
+ children: /*#__PURE__*/jsx("div", {
1546
+ className: className,
1547
+ children: children
1548
+ })
1549
+ }))
1550
+ });
1551
+ };
1552
+
1553
+ var ADDRESS_FIELD_WIDTH_OPTIONS = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ADDRESS_FIELD_WIDTHS.FULL, {
1554
+ label: t("neetoForm.questions.address.widths.full"),
1555
+ value: ADDRESS_FIELD_WIDTHS.FULL
1556
+ }), ADDRESS_FIELD_WIDTHS.HALF, {
1557
+ label: t("neetoForm.questions.address.widths.half"),
1558
+ value: ADDRESS_FIELD_WIDTHS.HALF
1559
+ }), ADDRESS_FIELD_WIDTHS.ONE_FOURTH, {
1560
+ label: t("neetoForm.questions.address.widths.oneFourth"),
1561
+ value: ADDRESS_FIELD_WIDTHS.ONE_FOURTH
1562
+ }), ADDRESS_FIELD_WIDTHS.THREE_FOURTH, {
1563
+ label: t("neetoForm.questions.address.widths.threeFourth"),
1564
+ value: ADDRESS_FIELD_WIDTHS.THREE_FOURTH
1565
+ });
1566
+ var ADDRESS_FIELD_TYPE_OPTIONS = _defineProperty(_defineProperty({}, ADDRESS_FIELD_TYPES.INPUT, {
1567
+ label: t("neetoForm.questions.address.types.textInput"),
1568
+ value: ADDRESS_FIELD_TYPES.INPUT
1569
+ }), ADDRESS_FIELD_TYPES.SELECT, {
1570
+ label: t("neetoForm.questions.address.types.dropdown"),
1571
+ value: ADDRESS_FIELD_TYPES.SELECT
1572
+ });
1573
+ var ADDRESS_FIELD_FORM_VALIDATION_SCHEMA = yup.object().shape({
1574
+ label: yup.string().trim().required(t("neetoForm.error.requiredField", {
1575
+ label: t("neetoForm.questions.common.questionFields.field.label")
1576
+ })),
1577
+ width: yup.object().nullable().required(t("neetoForm.error.requiredField", {
1578
+ label: t("neetoForm.questions.address.width")
1579
+ })),
1580
+ fieldType: yup.object().nullable().required(t("neetoForm.error.requiredField", {
1581
+ label: t("neetoForm.questions.address.type")
1582
+ })),
1583
+ properties: yup.object().shape({
1584
+ options: yup.array().of(yup.object().shape({
1585
+ label: yup.string().required(t("neetoForm.error.requiredField", {
1586
+ label: t("neetoForm.common.option")
1587
+ }))
1588
+ })).unique("label", t("neetoForm.error.removeDuplicates"))
1589
+ })
1590
+ });
1591
+ var ERROR_MESSAGE_DELIMITER$1 = ". ";
1592
+
1593
+ 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; }
1594
+ 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; }
1595
+ var removeDuplicateErrorMessages$1 = pipe(filter(isNotNil), map(values), uniq, join(ERROR_MESSAGE_DELIMITER$1));
1596
+ var getAddressModalInitialValues = function getAddressModalInitialValues(field) {
1597
+ return field ? _objectSpread$9(_objectSpread$9({}, field), {}, {
1598
+ width: ADDRESS_FIELD_WIDTH_OPTIONS[field.width],
1599
+ fieldType: ADDRESS_FIELD_TYPE_OPTIONS[field.fieldType]
1600
+ }) : {
1601
+ label: "",
1602
+ isRequired: false,
1603
+ width: ADDRESS_FIELD_WIDTH_OPTIONS[ADDRESS_FIELD_WIDTHS.FULL],
1604
+ fieldType: ADDRESS_FIELD_TYPE_OPTIONS[ADDRESS_FIELD_TYPES.INPUT]
1605
+ };
1606
+ };
1607
+ var sanitizeAddressField = function sanitizeAddressField(field, isSelectField, defaultOptions) {
1608
+ var hasOptions = pathSatisfies(isPresent, ["properties", "options"], field);
1609
+ if (isSelectField && !hasOptions) {
1610
+ return assocPath(["properties", "options"], defaultOptions, field);
1611
+ }
1612
+ if (!isSelectField && hasOptions) {
1613
+ return dissoc("properties", field);
1614
+ }
1615
+ return field;
1616
+ };
1617
+ var formatErrorMessage$1 = function formatErrorMessage(error) {
1618
+ if (typeof error === "string") return error;
1619
+ return removeDuplicateErrorMessages$1(error);
1620
+ };
1621
+
1622
+ var _excluded$5 = ["width", "fieldType"];
1623
+ 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; }
1624
+ 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; }
1625
+ var ManagePane = function ManagePane(_ref) {
1626
+ var isOpen = _ref.isOpen,
1627
+ selectedFieldId = _ref.selectedFieldId,
1628
+ onClose = _ref.onClose,
1629
+ title = _ref.title,
1630
+ fields = _ref.fields,
1631
+ initialFocusRef = _ref.initialFocusRef;
1632
+ var _useField = useField("fields"),
1633
+ _useField2 = _slicedToArray(_useField, 3),
1634
+ allFields = _useField2[0].value,
1635
+ setValue = _useField2[2].setValue;
1636
+ var _useTranslation = useTranslation(),
1637
+ t = _useTranslation.t;
1638
+ var defaultOptions = generateDefaultOptions(MINIMUM_ADDRESS_FIELDS);
1639
+ var editingField = findById(selectedFieldId, fields);
1640
+ var initialValues = getAddressModalInitialValues(editingField);
1641
+ var handleSubmit = function handleSubmit(_ref2) {
1642
+ var width = _ref2.width,
1643
+ fieldType = _ref2.fieldType,
1644
+ field = _objectWithoutProperties(_ref2, _excluded$5);
1645
+ var deletedFields = getDeletedRecords(allFields);
1646
+ var isSelectField = fieldType.value === ADDRESS_FIELD_TYPES.SELECT;
1647
+ var sanitizedField = sanitizeAddressField(field, isSelectField, defaultOptions);
1648
+ if (isNil(selectedFieldId)) {
1649
+ var position = fields.length;
1650
+ var id = "draft-".concat(randomId());
1651
+ var newField = _objectSpread$8(_objectSpread$8({
1652
+ id: id
1653
+ }, sanitizedField), {}, {
1654
+ altId: "alt-".concat(randomId()),
1655
+ position: position,
1656
+ width: width.value,
1657
+ fieldType: fieldType.value
1658
+ });
1659
+ var nextFields = append(newField, fields);
1660
+ setValue([].concat(_toConsumableArray(nextFields), _toConsumableArray(deletedFields)));
1661
+ } else {
1662
+ var selectedFieldIndex = findIndexById(selectedFieldId, fields);
1663
+ setValue(assoc(selectedFieldIndex, _objectSpread$8(_objectSpread$8({}, sanitizedField), {}, {
1664
+ width: width.value,
1665
+ fieldType: fieldType.value
1666
+ }), [].concat(_toConsumableArray(fields), _toConsumableArray(deletedFields))));
1667
+ }
1668
+ onClose();
1669
+ };
1670
+ var handleFieldTypeChange = function handleFieldTypeChange(setFieldValue, values) {
1671
+ return function (fieldType) {
1672
+ var _values$properties;
1673
+ setFieldValue("fieldType", fieldType);
1674
+ if (fieldType.value === ADDRESS_FIELD_TYPES.SELECT && isNotPresent((_values$properties = values.properties) === null || _values$properties === void 0 ? void 0 : _values$properties.options)) {
1675
+ setFieldValue("properties.options", defaultOptions);
1676
+ }
1677
+ };
1678
+ };
1679
+ return /*#__PURE__*/jsxs(Sheet, {
1680
+ initialFocusRef: initialFocusRef,
1681
+ isOpen: isOpen,
1682
+ onClose: onClose,
1683
+ children: [/*#__PURE__*/jsx(Sheet.Header, {
1684
+ children: /*#__PURE__*/jsx(Sheet.Title, {
1685
+ children: /*#__PURE__*/jsx(Typography, {
1686
+ "data-testid": "add-address-field-title",
1687
+ variant: "h2",
1688
+ weight: "semibold",
1689
+ children: title
1690
+ })
1691
+ })
1692
+ }), /*#__PURE__*/jsx(Form$2, {
1693
+ formikProps: {
1694
+ initialValues: initialValues,
1695
+ validationSchema: ADDRESS_FIELD_FORM_VALIDATION_SCHEMA,
1696
+ onSubmit: handleSubmit
1697
+ },
1698
+ children: function children(_ref3) {
1699
+ var _values$fieldType;
1700
+ var values = _ref3.values,
1701
+ setFieldValue = _ref3.setFieldValue;
1702
+ return /*#__PURE__*/jsxs(Fragment, {
1703
+ children: [/*#__PURE__*/jsx(Sheet.Body, {
1704
+ children: /*#__PURE__*/jsxs("div", {
1705
+ className: "w-full space-y-6",
1706
+ children: [/*#__PURE__*/jsx(Input, {
1707
+ name: "label",
1708
+ ref: initialFocusRef,
1709
+ label: t("neetoForm.questions.common.questionFields.field.label"),
1710
+ placeholder: t("neetoForm.questions.address.fieldLabelPlaceholder")
1711
+ }), /*#__PURE__*/jsxs("div", {
1712
+ className: "grid grid-cols-2 gap-6",
1713
+ children: [/*#__PURE__*/jsx(Select, {
1714
+ label: t("neetoForm.questions.address.width"),
1715
+ name: "width",
1716
+ options: Object.values(ADDRESS_FIELD_WIDTH_OPTIONS)
1717
+ }), /*#__PURE__*/jsx(Select, {
1718
+ label: t("neetoForm.questions.address.type"),
1719
+ name: "fieldType",
1720
+ options: Object.values(ADDRESS_FIELD_TYPE_OPTIONS),
1721
+ onChange: handleFieldTypeChange(setFieldValue, values)
1722
+ })]
1723
+ }), /*#__PURE__*/jsx(Collapsible, {
1724
+ open: (values === null || values === void 0 || (_values$fieldType = values.fieldType) === null || _values$fieldType === void 0 ? void 0 : _values$fieldType.value) === ADDRESS_FIELD_TYPES.SELECT,
1725
+ children: /*#__PURE__*/jsx("div", {
1726
+ className: "flex flex-col",
1727
+ children: /*#__PURE__*/jsx(OptionFields, {
1728
+ draggable: true,
1729
+ minOptions: MINIMUM_ADDRESS_FIELDS,
1730
+ name: "properties.options"
1731
+ })
1732
+ })
1733
+ }), /*#__PURE__*/jsx("div", {
1734
+ className: "flex items-center gap-4",
1735
+ children: /*#__PURE__*/jsx(Switch, {
1736
+ label: t("neetoForm.common.required"),
1737
+ name: "isRequired"
1738
+ })
1739
+ })]
1740
+ })
1741
+ }), /*#__PURE__*/jsx(Sheet.Footer, {
1742
+ children: /*#__PURE__*/jsx("div", {
1743
+ className: "flex items-center gap-2",
1744
+ children: /*#__PURE__*/jsx(ActionBlock, {
1745
+ className: "flex gap-x-2",
1746
+ cancelButtonProps: {
1747
+ type: "reset",
1748
+ onClick: onClose,
1749
+ disabled: false
1750
+ },
1751
+ submitButtonProps: {
1752
+ label: t("neetoForm.common.saveChanges")
1753
+ }
1754
+ })
1755
+ })
1756
+ })]
1757
+ });
1758
+ }
1759
+ })]
1760
+ });
1761
+ };
1762
+
1763
+ var Address = function Address() {
1764
+ var _findById;
1765
+ var _useState = useState(false),
1766
+ _useState2 = _slicedToArray(_useState, 2),
1767
+ isAddressFieldPaneOpen = _useState2[0],
1768
+ setIsAddressFieldPaneOpen = _useState2[1];
1769
+ var _useState3 = useState(false),
1770
+ _useState4 = _slicedToArray(_useState3, 2),
1771
+ isDeleteAddressFieldAlertOpen = _useState4[0],
1772
+ setIsDeleteAddressFieldAlertOpen = _useState4[1];
1773
+ var _useState5 = useState(null),
1774
+ _useState6 = _slicedToArray(_useState5, 2),
1775
+ selectedFieldId = _useState6[0],
1776
+ setSelectedFieldId = _useState6[1];
1777
+ var initialFocusRef = useRef(null);
1778
+ var _useTranslation = useTranslation(),
1779
+ t = _useTranslation.t;
1780
+ var _useBuildFormStore = useBuildFormStore(function (store) {
1781
+ var _store$formState;
1782
+ return {
1783
+ selectedLanguage: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["selectedLanguage"]
1784
+ };
1785
+ }, shallow),
1786
+ selectedLanguage = _useBuildFormStore.selectedLanguage;
1787
+ var name = "fields";
1788
+ var _useField = useField(name),
1789
+ _useField2 = _slicedToArray(_useField, 3),
1790
+ fields = _useField2[0].value,
1791
+ _useField2$ = _useField2[1],
1792
+ error = _useField2$.error,
1793
+ touched = _useField2$.touched,
1794
+ setFields = _useField2[2].setValue;
1795
+ var handleDelete = function handleDelete() {
1796
+ var deletedFields = getDeletedRecords(fields);
1797
+ var nextFields = getActiveRecords(fields);
1798
+ var selectedFieldIndex = findIndexById(selectedFieldId, nextFields);
1799
+ nextFields = assocPath([selectedFieldIndex, "deleted"], true, nextFields);
1800
+ setFields([].concat(_toConsumableArray(nextFields), _toConsumableArray(deletedFields)));
1801
+ };
1802
+ return /*#__PURE__*/jsxs(Fragment, {
1803
+ children: [/*#__PURE__*/jsx(Block, {
1804
+ dataTestid: "address-fields-block",
1805
+ title: t("neetoForm.questions.address.fields"),
1806
+ children: /*#__PURE__*/jsxs("div", {
1807
+ children: [/*#__PURE__*/jsx(OptionFields, {
1808
+ name: name,
1809
+ draggable: true,
1810
+ shouldDestroy: true,
1811
+ editable: false,
1812
+ isNewItemsPrefilled: isDefaultLanguage(selectedLanguage),
1813
+ itemLabel: t("neetoForm.common.field"),
1814
+ minOptions: MINIMUM_ADDRESS_FIELDS,
1815
+ shouldResetEmptyOptionOnBlur: false,
1816
+ buttonProps: {
1817
+ label: t("neetoForm.questions.address.addField"),
1818
+ onClick: function onClick() {
1819
+ return setIsAddressFieldPaneOpen(true);
1820
+ }
1821
+ },
1822
+ onDelete: function onDelete(id) {
1823
+ setSelectedFieldId(id);
1824
+ setIsDeleteAddressFieldAlertOpen(true);
1825
+ },
1826
+ onEdit: function onEdit(id) {
1827
+ setSelectedFieldId(id);
1828
+ setIsAddressFieldPaneOpen(true);
1829
+ }
1830
+ }), touched && error && /*#__PURE__*/jsx("p", {
1831
+ className: "neeto-form-engine-input__error",
1832
+ "data-testid": "neeto-form-engine-address-fields-error",
1833
+ children: formatErrorMessage$1(error)
1834
+ })]
1835
+ })
1836
+ }), /*#__PURE__*/jsx(ManagePane, {
1837
+ initialFocusRef: initialFocusRef,
1838
+ selectedFieldId: selectedFieldId,
1839
+ fields: getActiveRecords(fields),
1840
+ isOpen: isAddressFieldPaneOpen,
1841
+ title: isNotNil(selectedFieldId) ? t("neetoForm.questions.address.editField") : t("neetoForm.questions.address.addField"),
1842
+ onClose: function onClose() {
1843
+ setIsAddressFieldPaneOpen(false);
1844
+ setSelectedFieldId(null);
1845
+ }
1846
+ }), /*#__PURE__*/jsx(Alert, {
1847
+ isOpen: isDeleteAddressFieldAlertOpen,
1848
+ submitButtonLabel: t("neetoForm.common.delete"),
1849
+ title: t("neetoForm.questions.address.deleteAlert.title"),
1850
+ message: /*#__PURE__*/jsx(Trans, {
1851
+ i18nKey: "neetoForm.questions.address.deleteAlert.message",
1852
+ values: {
1853
+ label: (_findById = findById(selectedFieldId, fields)) === null || _findById === void 0 ? void 0 : _findById.label
1854
+ }
1855
+ }),
1856
+ onClose: function onClose() {
1857
+ setIsDeleteAddressFieldAlertOpen(false);
1858
+ setSelectedFieldId(null);
1859
+ },
1860
+ onSubmit: function onSubmit() {
1861
+ setIsDeleteAddressFieldAlertOpen(false);
1862
+ handleDelete();
1863
+ setSelectedFieldId(null);
1864
+ }
1865
+ })]
1866
+ });
1867
+ };
1868
+
1869
+ var Captcha = withT(function (_ref) {
1870
+ var t = _ref.t;
1871
+ return /*#__PURE__*/jsxs(RadioGroup, {
1872
+ label: t("neetoForm.common.captchaType"),
1873
+ labelProps: {
1874
+ required: true
1875
+ },
1876
+ name: "variant",
1877
+ children: [/*#__PURE__*/jsx(RadioGroup.Item, {
1878
+ label: t("neetoForm.common.reCaptchaV2"),
1879
+ value: CAPTCHA_TYPES.RECAPTCHA_V2
1880
+ }), /*#__PURE__*/jsx(RadioGroup.Item, {
1881
+ label: t("neetoForm.common.mathCaptcha"),
1882
+ value: CAPTCHA_TYPES.MATH_CAPTCHA
1883
+ })]
1884
+ });
1885
+ });
1886
+
1887
+ var _excluded$4 = ["name", "title", "className"];
1888
+ 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; }
1889
+ 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; }
1890
+ var SwitchBlock = function SwitchBlock(_ref) {
1891
+ var name = _ref.name,
1892
+ title = _ref.title,
1893
+ _ref$className = _ref.className,
1894
+ className = _ref$className === void 0 ? "" : _ref$className,
1895
+ otherProps = _objectWithoutProperties(_ref, _excluded$4);
1896
+ return /*#__PURE__*/jsxs(Label, {
1897
+ className: classnames("flex items-center justify-start gap-2 ", className),
1898
+ "data-testid": "neeto-form-engine-".concat(hyphenate(title && name), "-toggle-label"),
1899
+ children: [/*#__PURE__*/jsx(Switch, _objectSpread$7(_objectSpread$7({}, _objectSpread$7(_objectSpread$7({}, otherProps), {}, {
1900
+ name: name
1901
+ })), {}, {
1902
+ "data-testid": "neeto-form-engine-".concat(hyphenate(title && name), "-switch")
1903
+ })), /*#__PURE__*/jsx(Typography, {
1904
+ as: "span",
1905
+ variant: "body1",
1906
+ children: title
1907
+ })]
1908
+ });
1909
+ };
1910
+
1911
+ var DOMAIN_RESTRICTION_TRANSLATIONS = {
1912
+ whitelistedDomains: {
1913
+ title: t("neetoForm.domainRestriction.whitelistedDomains.label"),
1914
+ description: t("neetoForm.domainRestriction.whitelistedDomains.description"),
1915
+ popoverDescription: t("neetoForm.domainRestriction.whitelistedDomains.popoverDescription")
1916
+ },
1917
+ blacklistedDomains: {
1918
+ title: t("neetoForm.domainRestriction.blacklistedDomains.label"),
1919
+ description: t("neetoForm.domainRestriction.blacklistedDomains.description"),
1920
+ popoverDescription: t("neetoForm.domainRestriction.blacklistedDomains.popoverDescription")
1921
+ }
1922
+ };
1923
+ var EMAIL_VERIFICATION_TRANSLATIONS = {
1924
+ title: t("neetoForm.emailVerification.label"),
1925
+ popoverDescription: t("neetoForm.emailVerification.popoverDescription")
1926
+ };
1927
+
1928
+ var _excluded$3 = ["children"];
1929
+ 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; }
1930
+ 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; }
1931
+ var STYLES = {
1932
+ border: {
1933
+ "default": "1px solid rgb(var(--neeto-ui-gray-400))",
1934
+ error: "1px solid rgb(var(--neeto-ui-error-800)) !important"
1935
+ },
1936
+ color: {
1937
+ "default": "rgb(var(--neeto-ui-gray-800))",
1938
+ error: "rgb(var(--neeto-ui-error-800)) !important"
1939
+ }
1940
+ };
1941
+ var MultiValueRemove = function MultiValueRemove(props) {
1942
+ return /*#__PURE__*/jsx(components.MultiValueRemove, _objectSpread$6(_objectSpread$6({}, props), {}, {
1943
+ innerProps: _objectSpread$6(_objectSpread$6({}, props.innerProps), {}, _defineProperty({}, "data-testid", "".concat(hyphenize(props.data.label), "-remove-icon"))),
1944
+ children: /*#__PURE__*/jsx(Close, {
1945
+ size: 16
1946
+ })
1947
+ }));
1948
+ };
1949
+ var ValueContainer = function ValueContainer(_ref) {
1950
+ var children = _ref.children,
1951
+ props = _objectWithoutProperties(_ref, _excluded$3);
1952
+ var _useTranslation = useTranslation(),
1953
+ t = _useTranslation.t;
1954
+ var getValue = props.getValue,
1955
+ _props$selectProps = props.selectProps,
1956
+ isFocused = _props$selectProps.isFocused,
1957
+ visibleDomainsCount = _props$selectProps.visibleDomainsCount;
1958
+ var value = getValue();
1959
+ var _children = _toArray(children),
1960
+ firstChild = _children[0],
1961
+ rest = _children.slice(1);
1962
+ var shouldCollapse = !isFocused && value.length > visibleDomainsCount;
1963
+ return /*#__PURE__*/jsxs(components.ValueContainer, _objectSpread$6(_objectSpread$6({}, props), {}, {
1964
+ innerProps: _objectSpread$6(_objectSpread$6({}, props.innerProps), {}, _defineProperty({}, "data-testid", "multi-domain-input-container")),
1965
+ children: [shouldCollapse ? firstChild.slice(0, visibleDomainsCount) : firstChild, shouldCollapse && /*#__PURE__*/jsx(Badge, {
1966
+ variant: "secondary",
1967
+ label: t("neetoForm.common.remainingItemsCount", {
1968
+ count: value.length - visibleDomainsCount
1969
+ })
1970
+ }), rest]
1971
+ }));
1972
+ };
1973
+ var ClearIndicator = function ClearIndicator(props) {
1974
+ return /*#__PURE__*/jsx(components.ClearIndicator, _objectSpread$6(_objectSpread$6({}, props), {}, {
1975
+ innerProps: _objectSpread$6(_objectSpread$6({}, props.innerProps), {}, _defineProperty({}, "data-testid", "clear-all-button")),
1976
+ children: /*#__PURE__*/jsx(Close, {
1977
+ className: "cursor-pointer",
1978
+ size: 16
1979
+ })
1980
+ }));
1981
+ };
1982
+ var ERROR_MESSAGE_DELIMITER = ". ";
1983
+ var DELIMITER_KEYS = ["Enter", "Tab", ",", " "];
1984
+ var DOMAIN_SEPARATION_REGEX = /[^\s,]+/g;
1985
+ var FLEXIBLE_DOMAIN_REGEX = /^[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/;
1986
+ var VALID_DOMAIN_REGEX = /^(?:[a-zA-Z0-9-]{1,63}\.)+[a-zA-Z0-9-]{2,63}$/;
1987
+ var DOMAIN_VALIDATION_SCHEMA = yup.string().required(t("neetoForm.error.requiredField", {
1988
+ label: t("neetoForm.common.domain")
1989
+ })).test("verify domains", t("neetoForm.error.invalidDomain"), function (domain) {
1990
+ return VALID_DOMAIN_REGEX.test(domain);
1991
+ });
1992
+ var CUSTOM_STYLES = {
1993
+ input: assoc("overflow", "hidden"),
1994
+ multiValue: function multiValue(styles, _ref2) {
1995
+ var valid = _ref2.data.valid;
1996
+ return _objectSpread$6(_objectSpread$6({}, styles), {}, {
1997
+ border: valid ? STYLES.border["default"] : STYLES.border.error,
1998
+ color: valid ? STYLES.color["default"] : STYLES.color.error
1999
+ });
2000
+ }
2001
+ };
2002
+ var CUSTOM_COMPONENTS = {
2003
+ DropdownIndicator: null,
2004
+ MultiValueRemove: MultiValueRemove,
2005
+ ValueContainer: ValueContainer,
2006
+ ClearIndicator: ClearIndicator
2007
+ };
2008
+
2009
+ var removeDuplicateErrorMessages = pipe(filter(isNotNil), uniq, join(ERROR_MESSAGE_DELIMITER));
2010
+ var formatDomainInputOptions = function formatDomainInputOptions(domain) {
2011
+ var isValid;
2012
+ try {
2013
+ DOMAIN_VALIDATION_SCHEMA.validateSync(domain);
2014
+ isValid = true;
2015
+ } catch (_unused) {
2016
+ isValid = false;
2017
+ }
2018
+ return {
2019
+ label: domain,
2020
+ value: domain,
2021
+ valid: isValid
2022
+ };
2023
+ };
2024
+ var pruneDuplicates = pipe(pluck("value"), uniq, map(formatDomainInputOptions));
2025
+ var getValidDomains = function getValidDomains(domains) {
2026
+ return domains.filter(function (domain) {
2027
+ return domain === null || domain === void 0 ? void 0 : domain.valid;
2028
+ });
2029
+ };
2030
+ var getValidDomainsCount = function getValidDomainsCount(domains) {
2031
+ return getValidDomains(domains).length;
2032
+ };
2033
+ var formatErrorMessage = function formatErrorMessage(error) {
2034
+ if (typeof error === "string") return error;
2035
+ return removeDuplicateErrorMessages(error);
2036
+ };
2037
+
2038
+ var _excluded$2 = ["label", "value", "onChange", "error", "onBlur"];
2039
+ 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; }
2040
+ 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; }
2041
+ var MultiDomainInput = function MultiDomainInput(_ref) {
2042
+ var _ref$label = _ref.label,
2043
+ label = _ref$label === void 0 ? "" : _ref$label,
2044
+ _ref$value = _ref.value,
2045
+ value = _ref$value === void 0 ? [] : _ref$value,
2046
+ _ref$onChange = _ref.onChange,
2047
+ onChange = _ref$onChange === void 0 ? noop : _ref$onChange,
2048
+ _ref$error = _ref.error,
2049
+ error = _ref$error === void 0 ? "" : _ref$error,
2050
+ _ref$onBlur = _ref.onBlur,
2051
+ onBlur = _ref$onBlur === void 0 ? noop : _ref$onBlur,
2052
+ otherProps = _objectWithoutProperties(_ref, _excluded$2);
2053
+ var _useState = useState(""),
2054
+ _useState2 = _slicedToArray(_useState, 2),
2055
+ inputValue = _useState2[0],
2056
+ setInputValue = _useState2[1];
2057
+ var _useState3 = useState(false),
2058
+ _useState4 = _slicedToArray(_useState3, 2),
2059
+ isFocused = _useState4[0],
2060
+ setIsFocused = _useState4[1];
2061
+ var _useTranslation = useTranslation(),
2062
+ t = _useTranslation.t;
2063
+ var handleFilterDomains = function handleFilterDomains() {
2064
+ return onChange(getValidDomains(value));
2065
+ };
2066
+ var handleDomainChange = function handleDomainChange() {
2067
+ var inputValues = inputValue.match(DOMAIN_SEPARATION_REGEX) || [];
2068
+ var domainMatches = filter(test(FLEXIBLE_DOMAIN_REGEX), inputValues);
2069
+ var domains = domainMatches.map(formatDomainInputOptions);
2070
+ onChange(pruneDuplicates([].concat(_toConsumableArray(value), _toConsumableArray(domains))));
2071
+ setInputValue("");
2072
+ };
2073
+ var handleKeyDown = function handleKeyDown(event) {
2074
+ if (!inputValue) return;
2075
+ if (includes(event.key, DELIMITER_KEYS)) {
2076
+ handleDomainChange();
2077
+ event.preventDefault();
2078
+ event.stopPropagation();
2079
+ }
2080
+ };
2081
+ var onCreateOption = function onCreateOption(input) {
2082
+ var domain = formatDomainInputOptions(input);
2083
+ onChange(pruneDuplicates([].concat(_toConsumableArray(value), [domain])));
2084
+ };
2085
+ var handleBlur = function handleBlur(event) {
2086
+ inputValue ? handleDomainChange() : onBlur(event);
2087
+ setIsFocused(false);
2088
+ };
2089
+ var isFilterDomainsLinkVisible = value.length > getValidDomainsCount(value);
2090
+ return /*#__PURE__*/jsxs("div", {
2091
+ className: "input__wrapper email-input__wrapper",
2092
+ children: [/*#__PURE__*/jsx("div", {
2093
+ className: "email-input__label-wrapper",
2094
+ children: /*#__PURE__*/jsx(Label, {
2095
+ className: "email-input__label",
2096
+ "data-testid": "".concat(hyphenize(label), "-input-label"),
2097
+ children: label
2098
+ })
2099
+ }), /*#__PURE__*/jsx(CreatableSelect, _objectSpread$5({
2100
+ isMulti: true,
2101
+ required: true,
2102
+ classNamePrefix: "neeto-ui-react-select",
2103
+ components: CUSTOM_COMPONENTS,
2104
+ menuIsOpen: false,
2105
+ visibleDomainsCount: 3,
2106
+ className: classnames("react-select__container react-select__container--medium email-input__select", {
2107
+ "react-select__container--error": !!error
2108
+ }),
2109
+ styles: _objectSpread$5(_objectSpread$5({}, CUSTOM_STYLES), {}, {
2110
+ control: mergeLeft({
2111
+ maxHeight: "200px",
2112
+ overflowY: "auto"
2113
+ })
2114
+ }),
2115
+ onBlur: handleBlur,
2116
+ onFocus: function onFocus() {
2117
+ return setIsFocused(true);
2118
+ },
2119
+ onInputChange: setInputValue,
2120
+ onKeyDown: handleKeyDown
2121
+ }, _objectSpread$5({
2122
+ inputValue: inputValue,
2123
+ isFocused: isFocused,
2124
+ onChange: onChange,
2125
+ onCreateOption: onCreateOption,
2126
+ value: value
2127
+ }, otherProps))), !!error && /*#__PURE__*/jsxs("p", {
2128
+ className: "input__error",
2129
+ "data-testid": "".concat(hyphenize(label), "-input-error"),
2130
+ children: [formatErrorMessage(error), isFilterDomainsLinkVisible && /*#__PURE__*/jsxs("span", {
2131
+ className: "font-semibold cursor-pointer",
2132
+ onClick: handleFilterDomains,
2133
+ children: [ERROR_MESSAGE_DELIMITER, t("neetoForm.domainRestriction.removeInvalidDomains")]
2134
+ })]
2135
+ }), /*#__PURE__*/jsx("p", {
2136
+ className: "input__help-text",
2137
+ "data-testid": "".concat(hyphenize(label), "-input-help"),
2138
+ children: t("neetoForm.domainRestriction.helpText")
2139
+ })]
2140
+ });
2141
+ };
2142
+
2143
+ 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; }
2144
+ 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; }
2145
+ var validateDomains = function validateDomains(value) {
2146
+ var schema = yup.array().of(yup.string().test("verify domains", t("neetoForm.error.invalidDomain"), function (domain) {
2147
+ return VALID_DOMAIN_REGEX.test(domain);
2148
+ })).ensure().compact().min(1, t("neetoForm.error.minOneEntity", {
2149
+ entity: t("neetoForm.common.domain")
2150
+ }));
2151
+
2152
+ // eslint-disable-next-line no-async-promise-executor
2153
+ return new Promise(/*#__PURE__*/function () {
2154
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve) {
2155
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
2156
+ while (1) switch (_context.prev = _context.next) {
2157
+ case 0:
2158
+ _context.prev = 0;
2159
+ _context.next = 3;
2160
+ return schema.validate(value);
2161
+ case 3:
2162
+ resolve(undefined);
2163
+ _context.next = 9;
2164
+ break;
2165
+ case 6:
2166
+ _context.prev = 6;
2167
+ _context.t0 = _context["catch"](0);
2168
+ resolve(_context.t0.message);
2169
+ case 9:
2170
+ case "end":
2171
+ return _context.stop();
2172
+ }
2173
+ }, _callee, null, [[0, 6]]);
2174
+ }));
2175
+ return function (_x) {
2176
+ return _ref.apply(this, arguments);
2177
+ };
2178
+ }());
2179
+ };
2180
+ var buildHelpPopoverLabelProps = function buildHelpPopoverLabelProps(popoverDescription, helpLink) {
2181
+ return {
2182
+ helpIconProps: {
2183
+ "data-testid": "help-popover-button",
2184
+ popoverProps: _objectSpread$4({
2185
+ description: popoverDescription
2186
+ }, helpLink && {
2187
+ helpLinkProps: {
2188
+ href: helpLink,
2189
+ label: t("neetoForm.common.viewHelpArticle")
2190
+ }
2191
+ })
2192
+ }
2193
+ };
2194
+ };
2195
+
2196
+ var EmailDomains = function EmailDomains(_ref) {
2197
+ var name = _ref.name,
2198
+ label = _ref.label;
2199
+ var _useTranslation = useTranslation(),
2200
+ t = _useTranslation.t;
2201
+ var _useField = useField({
2202
+ name: name,
2203
+ validate: validateDomains
2204
+ }),
2205
+ _useField2 = _slicedToArray(_useField, 3),
2206
+ _useField2$0$value = _useField2[0].value,
2207
+ domains = _useField2$0$value === void 0 ? [] : _useField2$0$value,
2208
+ meta = _useField2[1],
2209
+ _useField2$ = _useField2[2],
2210
+ setValue = _useField2$.setValue,
2211
+ setTouched = _useField2$.setTouched;
2212
+ var formattedDomains = map(formatDomainInputOptions, domains);
2213
+ return /*#__PURE__*/jsx("div", {
2214
+ className: "mb-4",
2215
+ children: /*#__PURE__*/jsx(MultiDomainInput, {
2216
+ label: label,
2217
+ name: name,
2218
+ error: meta.touched ? meta.error : "",
2219
+ placeholder: t("neetoForm.domainRestriction.placeholder"),
2220
+ value: formattedDomains,
2221
+ onBlur: function onBlur() {
2222
+ return setTouched(true);
2223
+ },
2224
+ onChange: function onChange(value) {
2225
+ return setValue(nullSafe(pluck)("value", value));
2226
+ }
2227
+ })
2228
+ });
2229
+ };
2230
+
2231
+ var RestrictDomainsBlock = function RestrictDomainsBlock(_ref) {
2232
+ var switchName = _ref.switchName,
2233
+ domainName = _ref.domainName,
2234
+ isDomainRestrictionEnabled = _ref.isDomainRestrictionEnabled;
2235
+ var _useBuildFormStore = useBuildFormStore(paths([["formState", "helpDocUrls", domainName], ["formState", "hostSpecificData", domainName]])),
2236
+ _useBuildFormStore2 = _slicedToArray(_useBuildFormStore, 2),
2237
+ helpLink = _useBuildFormStore2[0],
2238
+ hostSpecificTranslations = _useBuildFormStore2[1];
2239
+ var _mergeLeft = mergeLeft(hostSpecificTranslations, DOMAIN_RESTRICTION_TRANSLATIONS[domainName]),
2240
+ title = _mergeLeft.title,
2241
+ description = _mergeLeft.description,
2242
+ popoverDescription = _mergeLeft.popoverDescription;
2243
+ return /*#__PURE__*/jsxs("div", {
2244
+ className: "flex flex-col space-y-4",
2245
+ "data-testid": "".concat(hyphenate(switchName), "-container"),
2246
+ children: [/*#__PURE__*/jsx(SwitchBlock, {
2247
+ label: title,
2248
+ labelProps: buildHelpPopoverLabelProps(popoverDescription, helpLink),
2249
+ name: switchName
2250
+ }), isDomainRestrictionEnabled && /*#__PURE__*/jsx(EmailDomains, {
2251
+ label: description,
2252
+ name: domainName
2253
+ })]
2254
+ });
2255
+ };
2256
+
2257
+ var VerifyEmails = function VerifyEmails() {
2258
+ var _useBuildFormStore = useBuildFormStore(paths([["formState", "helpDocUrls", "emailVerification"], ["formState", "hostSpecificData", "emailVerification"]])),
2259
+ _useBuildFormStore2 = _slicedToArray(_useBuildFormStore, 2),
2260
+ helpLink = _useBuildFormStore2[0],
2261
+ hostSpecificTranslations = _useBuildFormStore2[1];
2262
+ var _mergeLeft = mergeLeft(hostSpecificTranslations, EMAIL_VERIFICATION_TRANSLATIONS),
2263
+ title = _mergeLeft.title,
2264
+ popoverDescription = _mergeLeft.popoverDescription;
2265
+ return /*#__PURE__*/jsx("div", {
2266
+ "data-testid": "email-verification-switch-container",
2267
+ children: /*#__PURE__*/jsx(Switch, {
2268
+ label: title,
2269
+ labelProps: buildHelpPopoverLabelProps(popoverDescription, helpLink),
2270
+ name: "isVerificationEnabled"
2271
+ })
2272
+ });
2273
+ };
2274
+
2275
+ var Email = function Email(_ref) {
2276
+ var usesCustomSubmissionComponent = _ref.usesCustomSubmissionComponent;
2277
+ var _useFormikContext = useFormikContext(),
2278
+ _useFormikContext$val = _useFormikContext.values,
2279
+ _useFormikContext$val2 = _useFormikContext$val.isDomainWhitelistingEnabled,
2280
+ isDomainWhitelistingEnabled = _useFormikContext$val2 === void 0 ? false : _useFormikContext$val2,
2281
+ _useFormikContext$val3 = _useFormikContext$val.isDomainBlacklistingEnabled,
2282
+ isDomainBlacklistingEnabled = _useFormikContext$val3 === void 0 ? false : _useFormikContext$val3;
2283
+ return /*#__PURE__*/jsx("div", {
2284
+ className: "flex flex-col space-y-4",
2285
+ children: !usesCustomSubmissionComponent && /*#__PURE__*/jsxs(Fragment, {
2286
+ children: [/*#__PURE__*/jsx(RestrictDomainsBlock, {
2287
+ domainName: "whitelistedDomains",
2288
+ isDomainRestrictionEnabled: isDomainWhitelistingEnabled,
2289
+ switchName: "isDomainWhitelistingEnabled"
2290
+ }), /*#__PURE__*/jsx(RestrictDomainsBlock, {
2291
+ domainName: "blacklistedDomains",
2292
+ isDomainRestrictionEnabled: isDomainBlacklistingEnabled,
2293
+ switchName: "isDomainBlacklistingEnabled"
2294
+ }), /*#__PURE__*/jsx(VerifyEmails, {})]
2295
+ })
2296
+ });
2297
+ };
2298
+
2299
+ var FileGroup = function FileGroup(_ref) {
2300
+ var name = _ref.name,
2301
+ label = _ref.label,
2302
+ checked = _ref.checked,
2303
+ handleAllowedFileTypesChange = _ref.handleAllowedFileTypesChange;
2304
+ return /*#__PURE__*/jsx(Checkbox, {
2305
+ checked: checked,
2306
+ label: label,
2307
+ name: name,
2308
+ "data-testid": "neeto-form-engine-file-type-".concat(name),
2309
+ id: name,
2310
+ onCheckedChange: handleAllowedFileTypesChange
2311
+ });
2312
+ };
2313
+
2314
+ var buildFileTypesList = function buildFileTypesList(fileTypes) {
2315
+ return (fileTypes !== null && fileTypes !== void 0 ? fileTypes : "").split(", ");
2316
+ };
2317
+ var getAllowedFileTypes = function getAllowedFileTypes(_ref) {
2318
+ var type = _ref.type,
2319
+ isChecked = _ref.isChecked,
2320
+ allowedFileTypes = _ref.allowedFileTypes;
2321
+ var fileTypes = buildFileTypesList(allowedFileTypes);
2322
+ if (isChecked) {
2323
+ var fileTypesSet = new Set([].concat(_toConsumableArray(FILE_TYPES_MAP[type]), _toConsumableArray(fileTypes)));
2324
+ return Array.from(fileTypesSet).join(", ");
2325
+ }
2326
+ var newFileTypes = difference(fileTypes, FILE_TYPES_MAP[type]);
2327
+ return newFileTypes.join(", ");
2328
+ };
2329
+ var isFileTypeEnabled = function isFileTypeEnabled(type, allowedFileTypes) {
2330
+ var fileTypes = buildFileTypesList(allowedFileTypes);
2331
+ return isEmpty(difference(FILE_TYPES_MAP[type], fileTypes));
2332
+ };
2333
+
2334
+ var FileUpload = function FileUpload() {
2335
+ var _useTranslation = useTranslation(),
2336
+ t = _useTranslation.t;
2337
+ var _useFormikContext = useFormikContext(),
2338
+ values = _useFormikContext.values,
2339
+ setFieldValue = _useFormikContext.setFieldValue;
2340
+ var allowedFileTypes = prop("allowedFileTypes", values);
2341
+ var handleAllowedFileTypesChange = function handleAllowedFileTypesChange(_ref) {
2342
+ var _ref$target = _ref.target,
2343
+ fileType = _ref$target.name,
2344
+ checked = _ref$target.checked;
2345
+ return setFieldValue("allowedFileTypes", getAllowedFileTypes({
2346
+ type: fileType,
2347
+ isChecked: checked,
2348
+ allowedFileTypes: allowedFileTypes
2349
+ }));
2350
+ };
2351
+ return /*#__PURE__*/jsxs(Fragment, {
2352
+ children: [/*#__PURE__*/jsx("div", {
2353
+ className: "w-full",
2354
+ children: /*#__PURE__*/jsx(Checkbox$1, {
2355
+ id: "multipleFilesAllowed",
2356
+ label: t("neetoForm.fileUpload.enableMultipleFilesUpload"),
2357
+ name: "multipleFilesAllowed"
2358
+ })
2359
+ }), /*#__PURE__*/jsxs("div", {
2360
+ className: "flex flex-col space-y-3",
2361
+ children: [/*#__PURE__*/jsx(Typography, {
2362
+ variant: "body1",
2363
+ weight: "semibold",
2364
+ children: t("neetoForm.fileUpload.fileTypes")
2365
+ }), /*#__PURE__*/jsx("div", {
2366
+ className: "flex space-x-4",
2367
+ children: FILE_GROUPS.map(function (_ref2) {
2368
+ var name = _ref2.name,
2369
+ label = _ref2.label;
2370
+ return /*#__PURE__*/createElement(FileGroup, {
2371
+ handleAllowedFileTypesChange: handleAllowedFileTypesChange,
2372
+ label: label,
2373
+ name: name,
2374
+ checked: isFileTypeEnabled(name, allowedFileTypes),
2375
+ key: name
2376
+ });
2377
+ })
2378
+ })]
2379
+ })]
2380
+ });
2381
+ };
2382
+
2383
+ var OpinionScale = function OpinionScale() {
2384
+ var _useTranslation = useTranslation(),
2385
+ t = _useTranslation.t;
2386
+ var _useFormikContext = useFormikContext(),
2387
+ setFieldValue = _useFormikContext.setFieldValue,
2388
+ _useFormikContext$val = _useFormikContext.values.hasOpinionLabels,
2389
+ hasOpinionLabels = _useFormikContext$val === void 0 ? false : _useFormikContext$val;
2390
+ return /*#__PURE__*/jsxs(Fragment, {
2391
+ children: [/*#__PURE__*/jsxs("div", {
2392
+ className: "flex space-x-4",
2393
+ children: [/*#__PURE__*/jsx(Select, {
2394
+ className: "w-1/2",
2395
+ "data-testid": "neeto-form-engine-opinion-scale-min-value",
2396
+ label: t("neetoForm.common.start"),
2397
+ name: "minValue",
2398
+ options: OPINION_SCALE_MIN_VALUE_OPTIONS,
2399
+ onChange: function onChange(option) {
2400
+ return setFieldValue("minValue", option === null || option === void 0 ? void 0 : option.value);
2401
+ }
2402
+ }), /*#__PURE__*/jsx(Select, {
2403
+ className: "w-1/2",
2404
+ "data-testid": "neeto-form-engine-opinion-scale-max-value",
2405
+ label: t("neetoForm.common.end"),
2406
+ name: "maxValue",
2407
+ options: OPINION_SCALE_MAX_VALUE_OPTIONS,
2408
+ onChange: function onChange(option) {
2409
+ return setFieldValue("maxValue", option === null || option === void 0 ? void 0 : option.value);
2410
+ }
2411
+ })]
2412
+ }), /*#__PURE__*/jsx(Switch, {
2413
+ "data-testid": "neeto-form-engine-opinion-scale-show-labels-switch",
2414
+ label: t("neetoForm.questions.opinionScale.showLabels"),
2415
+ name: "hasOpinionLabels"
2416
+ }), hasOpinionLabels && /*#__PURE__*/jsxs("div", {
2417
+ className: "flex space-x-4",
2418
+ children: [/*#__PURE__*/jsx(Input, {
2419
+ className: "w-1/2",
2420
+ "data-testid": "neeto-form-engine-opinion-scale-left-label",
2421
+ label: t("neetoForm.questions.opinionScale.leftLabel"),
2422
+ maxLength: OPINION_LABEL_MAX_LENGTH,
2423
+ name: "leftOpinionLabel"
2424
+ }), /*#__PURE__*/jsx(Input, {
2425
+ className: "w-1/2",
2426
+ "data-testid": "neeto-form-engine-opinion-scale-right-label",
2427
+ label: t("neetoForm.questions.opinionScale.rightLabel"),
2428
+ maxLength: OPINION_LABEL_MAX_LENGTH,
2429
+ name: "rightOpinionLabel"
2430
+ })]
2431
+ })]
2432
+ });
2433
+ };
2434
+
2435
+ 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; }
2436
+ 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; }
2437
+ var Options = function Options(_ref) {
2438
+ var questionProps = _ref.questionProps;
2439
+ var _useTranslation = useTranslation(),
2440
+ t = _useTranslation.t;
2441
+ var _useBuildFormStore = useBuildFormStore(function (store) {
2442
+ var _store$formState, _store$formState2;
2443
+ return {
2444
+ selectedLanguage: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["selectedLanguage"],
2445
+ isPictureChoiceEnabled: (_store$formState2 = store["formState"]) === null || _store$formState2 === void 0 ? void 0 : _store$formState2["isPictureChoiceEnabled"]
2446
+ };
2447
+ }, shallow),
2448
+ selectedLanguage = _useBuildFormStore.selectedLanguage,
2449
+ isPictureChoiceEnabled = _useBuildFormStore.isPictureChoiceEnabled;
2450
+ var bulkAddHelpDocUrl = useHelpDoc("bulkAddOptions");
2451
+ var _useFormikContext = useFormikContext(),
2452
+ values = _useFormikContext.values,
2453
+ setFieldValue = _useFormikContext.setFieldValue;
2454
+ var name = "optionsAttributes";
2455
+ var _useField = useField(name),
2456
+ _useField2 = _slicedToArray(_useField, 3);
2457
+ _useField2[0];
2458
+ _useField2[1];
2459
+ var setOptionsAttributes = _useField2[2].setValue;
2460
+ var _ref2 = questionProps || {},
2461
+ _ref2$optionLabelProp = _ref2.optionLabelProps,
2462
+ optionLabelProps = _ref2$optionLabelProp === void 0 ? {} : _ref2$optionLabelProp,
2463
+ _ref2$freezeOptions = _ref2.freezeOptions,
2464
+ freezeOptions = _ref2$freezeOptions === void 0 ? false : _ref2$freezeOptions,
2465
+ _ref2$disableAddOptio = _ref2.disableAddOption,
2466
+ disableAddOption = _ref2$disableAddOptio === void 0 ? false : _ref2$disableAddOptio,
2467
+ _ref2$disableRemoveOp = _ref2.disableRemoveOption,
2468
+ disableRemoveOption = _ref2$disableRemoveOp === void 0 ? false : _ref2$disableRemoveOp;
2469
+ var isManageOptionDisabled = isFunction(freezeOptions) ? freezeOptions(selectedLanguage) : freezeOptions;
2470
+ var isAddOptionDisabled = disableAddOption || isManageOptionDisabled;
2471
+ var isRemoveOptionDisabled = disableRemoveOption || isManageOptionDisabled;
2472
+ var isDropdown = values.kind === QUESTION_TYPES.DROPDOWN;
2473
+ var isPictureChoice = isPictureChoiceEnabled && !isDropdown && (values.isPictureChoice || DEFAULT_CHOICE_QUESTION_ATTRIBUTES.isPictureChoice);
2474
+ var imageHeight = values.imageHeight || DEFAULT_CHOICE_QUESTION_ATTRIBUTES.imageHeight;
2475
+ var handleImageHeightChange = function handleImageHeightChange(value) {
2476
+ setFieldValue("imageHeight", value);
2477
+ };
2478
+ return /*#__PURE__*/jsxs("div", {
2479
+ className: "w-full space-y-4",
2480
+ children: [/*#__PURE__*/jsxs("div", {
2481
+ children: [/*#__PURE__*/jsx(Label, _objectSpread$3(_objectSpread$3({
2482
+ className: "mb-2 block"
2483
+ }, optionLabelProps), {}, {
2484
+ children: t("neetoForm.questions.common.questionFields.field.options")
2485
+ })), /*#__PURE__*/jsx("div", {
2486
+ className: classnames(["neeto-form-engine-fields-wrapper", {
2487
+ "neeto-form-engine-fields-wrapper--fit-image": values.shouldFitImages
2488
+ }]),
2489
+ style: {
2490
+ "--neeto-form-engine-picture-choice-image-height": "".concat(values.imageHeight, "px")
2491
+ },
2492
+ children: /*#__PURE__*/jsx(OptionFields, {
2493
+ isPictureChoice: isPictureChoice,
2494
+ name: name,
2495
+ shouldDestroy: true,
2496
+ bulkActionProps: {
2497
+ enabled: true,
2498
+ bulkAddHelpDocUrl: bulkAddHelpDocUrl
2499
+ },
2500
+ destroyFlagName: "_destroy",
2501
+ disabled: isManageOptionDisabled,
2502
+ draggable: !isManageOptionDisabled,
2503
+ isAddOptionEnabled: !isAddOptionDisabled,
2504
+ isDeleteOptionEnabled: !isRemoveOptionDisabled,
2505
+ isNewItemsPrefilled: isDefaultLanguage(selectedLanguage),
2506
+ minOptions: MINIMUM_OPTIONS,
2507
+ shouldResetEmptyOptionOnBlur: false,
2508
+ onChange: setOptionsAttributes
2509
+ })
2510
+ })]
2511
+ }), !isDropdown && isPictureChoiceEnabled && /*#__PURE__*/jsxs("div", {
2512
+ className: "space-y-4",
2513
+ children: [/*#__PURE__*/jsx(Switch, {
2514
+ name: "isPictureChoice",
2515
+ label: t("neetoForm.questions.common.questionFields.field.addPicturesToOptions")
2516
+ }), isPictureChoice && /*#__PURE__*/jsxs(Fragment, {
2517
+ children: [/*#__PURE__*/jsx(Switch, {
2518
+ name: "shouldFitImages",
2519
+ label: t("neetoForm.questions.common.questionFields.field.fitImages"),
2520
+ labelProps: {
2521
+ helpIconProps: {
2522
+ "data-testid": "fit-images-help-popover-button",
2523
+ popoverProps: {
2524
+ position: "top",
2525
+ description: t("neetoForm.questions.common.questionFields.field.fitImagesHelpDescription")
2526
+ }
2527
+ }
2528
+ }
2529
+ }), /*#__PURE__*/jsxs("div", {
2530
+ className: "mt-4",
2531
+ children: [/*#__PURE__*/jsx(Typography, {
2532
+ variant: "body2",
2533
+ weight: "medium",
2534
+ children: t("neetoForm.questions.common.questionFields.field.imageHeight")
2535
+ }), /*#__PURE__*/jsx(Slider, {
2536
+ max: IMAGE_HEIGHT_SLIDER_DEFAULTS.max,
2537
+ min: IMAGE_HEIGHT_SLIDER_DEFAULTS.min,
2538
+ value: imageHeight,
2539
+ onValueChange: handleImageHeightChange
2540
+ })]
2541
+ })]
2542
+ })]
2543
+ })]
2544
+ });
2545
+ };
2546
+
2547
+ var RatingItem = function RatingItem(_ref) {
2548
+ var children = _ref.children;
2549
+ return /*#__PURE__*/jsx("div", {
2550
+ className: "flex w-16 flex-col items-center gap-3",
2551
+ children: children
2552
+ });
2553
+ };
2554
+ var Rating = function Rating() {
2555
+ return /*#__PURE__*/jsx("div", {
2556
+ className: "flex flex-col",
2557
+ children: /*#__PURE__*/jsx("div", {
2558
+ className: "w-full",
2559
+ children: /*#__PURE__*/jsx("div", {
2560
+ className: "flex gap-6",
2561
+ children: RATING_OPTIONS.map(function (_ref2) {
2562
+ var Icon = _ref2.icon,
2563
+ name = _ref2.name,
2564
+ color = _ref2.color;
2565
+ return /*#__PURE__*/jsxs(RatingItem, {
2566
+ children: [/*#__PURE__*/jsx(Icon, {
2567
+ color: color,
2568
+ size: 48
2569
+ }), /*#__PURE__*/jsx(InputWithMaxLength, {
2570
+ name: name,
2571
+ "data-testid": "neeto-form-engine-".concat(hyphenate(name))
2572
+ })]
2573
+ }, name);
2574
+ })
2575
+ })
2576
+ })
2577
+ });
2578
+ };
2579
+
2580
+ var StarRating = function StarRating() {
2581
+ var _useTranslation = useTranslation(),
2582
+ t = _useTranslation.t;
2583
+ var _useFormikContext = useFormikContext(),
2584
+ setFieldValue = _useFormikContext.setFieldValue;
2585
+ var _useField = useField("iconType"),
2586
+ _useField2 = _slicedToArray(_useField, 3),
2587
+ iconType = _useField2[0].value;
2588
+ _useField2[1];
2589
+ var setIconType = _useField2[2].setValue;
2590
+ return /*#__PURE__*/jsxs(Fragment, {
2591
+ children: [/*#__PURE__*/jsxs("div", {
2592
+ className: "flex space-x-4",
2593
+ children: [/*#__PURE__*/jsx(Select, {
2594
+ className: "w-1/2",
2595
+ "data-testid": "neeto-form-engine-star-rating-min-value",
2596
+ label: t("neetoForm.common.start"),
2597
+ name: "minValue",
2598
+ options: STAR_RATING_MIN_VALUE_OPTIONS,
2599
+ onChange: function onChange(option) {
2600
+ return setFieldValue("minValue", option === null || option === void 0 ? void 0 : option.value);
2601
+ }
2602
+ }), /*#__PURE__*/jsx(Select, {
2603
+ className: "w-1/2",
2604
+ "data-testid": "neeto-form-engine-star-rating-max-value",
2605
+ label: t("neetoForm.common.end"),
2606
+ name: "maxValue",
2607
+ options: STAR_RATING_MAX_VALUE_OPTIONS,
2608
+ onChange: function onChange(option) {
2609
+ return setFieldValue("maxValue", option === null || option === void 0 ? void 0 : option.value);
2610
+ }
2611
+ })]
2612
+ }), /*#__PURE__*/jsx(Label, {
2613
+ children: t("neetoForm.common.shape")
2614
+ }), /*#__PURE__*/jsx("div", {
2615
+ className: "flex gap-2",
2616
+ children: Object.entries(STAR_RATING_ICONS_MAP).map(function (_ref) {
2617
+ var _ref2 = _slicedToArray(_ref, 2),
2618
+ name = _ref2[0],
2619
+ IconType = _ref2[1];
2620
+ var isActive = name === iconType;
2621
+ return /*#__PURE__*/jsx("div", {
2622
+ "data-testid": "neeto-form-engine-star-rating-icon-".concat(name),
2623
+ className: classnames("flex h-10 w-10 items-center justify-center gap-2", "neeto-ui-border-gray-800 neeto-ui-rounded-full cursor-pointer border", "transition-all duration-300 ease-in-out", {
2624
+ "text-foreground neeto-ui-bg-gray-200": !isActive,
2625
+ "neeto-ui-text-white neeto-ui-bg-gray-800": isActive
2626
+ }),
2627
+ onClick: function onClick() {
2628
+ return setIconType(name);
2629
+ },
2630
+ children: /*#__PURE__*/jsx(IconType, {})
2631
+ }, name);
2632
+ })
2633
+ })]
2634
+ });
2635
+ };
2636
+
2637
+ var _excluded$1 = ["minWords"],
2638
+ _excluded2 = ["fields"];
2639
+ 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; }
2640
+ 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; }
2641
+ var CHECKBOX = QUESTION_TYPES.CHECKBOX,
2642
+ RADIO = QUESTION_TYPES.RADIO,
2643
+ DROPDOWN = QUESTION_TYPES.DROPDOWN,
2644
+ STAR_RATING = QUESTION_TYPES.STAR_RATING,
2645
+ OPINION_SCALE = QUESTION_TYPES.OPINION_SCALE,
2646
+ RATING = QUESTION_TYPES.RATING,
2647
+ FILE_UPLOAD = QUESTION_TYPES.FILE_UPLOAD,
2648
+ CAPTCHA = QUESTION_TYPES.CAPTCHA,
2649
+ EMAIL = QUESTION_TYPES.EMAIL,
2650
+ ADDRESS = QUESTION_TYPES.ADDRESS;
2651
+ var transformValueForOption = function transformValueForOption(_ref) {
2652
+ var label = _ref.label,
2653
+ type = _ref.type;
2654
+ return "".concat(slugify(label), "-").concat(type);
2655
+ };
2656
+ var omitDraftId = modifyBy({
2657
+ id: startsWith(DRAFT_ID_PREFIX)
2658
+ }, omit(["id"]));
2659
+ var renderAdditionalData = function renderAdditionalData(_ref2) {
2660
+ var kind = _ref2.kind,
2661
+ questionProps = _ref2.questionProps,
2662
+ usesCustomSubmissionComponent = _ref2.usesCustomSubmissionComponent;
2663
+ switch (kind) {
2664
+ case CHECKBOX:
2665
+ case RADIO:
2666
+ case DROPDOWN:
2667
+ return /*#__PURE__*/jsx(Options, {
2668
+ questionProps: questionProps
2669
+ });
2670
+ case RATING:
2671
+ return /*#__PURE__*/jsx(Rating, {});
2672
+ case STAR_RATING:
2673
+ return /*#__PURE__*/jsx(StarRating, {});
2674
+ case OPINION_SCALE:
2675
+ return /*#__PURE__*/jsx(OpinionScale, {});
2676
+ case FILE_UPLOAD:
2677
+ return /*#__PURE__*/jsx(FileUpload, {});
2678
+ case CAPTCHA:
2679
+ return /*#__PURE__*/jsx(Captcha, {});
2680
+ case ADDRESS:
2681
+ return /*#__PURE__*/jsx(Address, {});
2682
+ case EMAIL:
2683
+ return !usesCustomSubmissionComponent && /*#__PURE__*/jsx(Email, {
2684
+ usesCustomSubmissionComponent: usesCustomSubmissionComponent
2685
+ });
2686
+ default:
2687
+ return null;
2688
+ }
2689
+ };
2690
+ var resolveActionComponent = function resolveActionComponent(action) {
2691
+ return equals(action, QUESTION_ACTIONS.ADD) ? Add : Edit;
2692
+ };
2693
+ var getQuestionKind = function getQuestionKind(questionKinds, pattern) {
2694
+ var questionKind = findBy(pattern, questionKinds);
2695
+ return questionKind ? assoc("kind", questionKind.type, questionKind) : null;
2696
+ };
2697
+ var buildKindOptions = function buildKindOptions(kinds) {
2698
+ return kinds.map(function (_ref3) {
2699
+ var label = _ref3.label,
2700
+ type = _ref3.type,
2701
+ icon = _ref3.icon,
2702
+ description = _ref3.description,
2703
+ searchTerms = _ref3.searchTerms;
2704
+ return {
2705
+ label: label,
2706
+ value: transformValueForOption({
2707
+ label: label,
2708
+ type: type
2709
+ }),
2710
+ icon: icon,
2711
+ description: description,
2712
+ searchTerms: searchTerms
2713
+ };
2714
+ });
2715
+ };
2716
+ var filterKindOption = function filterKindOption(option, rawInput) {
2717
+ var _option$data$searchTe, _option$data;
2718
+ var query = rawInput === null || rawInput === void 0 ? void 0 : rawInput.trim().toLowerCase();
2719
+ if (!query) return true;
2720
+ var searchTerms = (_option$data$searchTe = (_option$data = option.data) === null || _option$data === void 0 ? void 0 : _option$data.searchTerms) !== null && _option$data$searchTe !== void 0 ? _option$data$searchTe : [];
2721
+ return searchTerms.some(function (term) {
2722
+ return term.includes(query);
2723
+ });
2724
+ };
2725
+ var extractKindFromOption = pipe(split("-"), last);
2726
+ var buildDefaultValueForKind = function buildDefaultValueForKind(questionKind) {
2727
+ return isPresent(questionKind) ? {
2728
+ value: transformValueForOption(questionKind)
2729
+ } : undefined;
2730
+ };
2731
+ var hideSwitchLabelProps = function hideSwitchLabelProps(helpUrl) {
2732
+ return helpUrl ? {
2733
+ helpIconProps: {
2734
+ "data-testid": "help-popover-button",
2735
+ popoverProps: {
2736
+ description: t("neetoForm.questions.common.questionFields.field.hideQuestionHelpDescription"),
2737
+ helpLinkProps: {
2738
+ href: helpUrl,
2739
+ label: t("neetoForm.common.viewHelpArticle")
2740
+ }
2741
+ }
2742
+ }
2743
+ } : undefined;
2744
+ };
2745
+ var responseVisibleOnlyToHostSwitchLabelProps = function responseVisibleOnlyToHostSwitchLabelProps(helpUrl) {
2746
+ return {
2747
+ helpIconProps: {
2748
+ "data-testid": "help-popover-button",
2749
+ popoverProps: {
2750
+ description: t("neetoForm.questions.common.questionFields.field.responseVisibleOnlyToHostHelpDescription"),
2751
+ helpLinkProps: {
2752
+ href: helpUrl,
2753
+ label: t("neetoForm.common.viewHelpArticle")
2754
+ }
2755
+ }
2756
+ }
2757
+ };
2758
+ };
2759
+ var readOnlySwitchLabelProps = function readOnlySwitchLabelProps(helpUrl) {
2760
+ return {
2761
+ helpIconProps: {
2762
+ "data-testid": "help-popover-button",
2763
+ popoverProps: {
2764
+ description: t("neetoForm.questions.common.questionFields.field.readOnlyHelpDescription"),
2765
+ helpLinkProps: helpUrl ? {
2766
+ href: helpUrl,
2767
+ label: t("neetoForm.common.viewHelpArticle")
2768
+ } : undefined
2769
+ }
2770
+ }
2771
+ };
2772
+ };
2773
+ var transformValues = function transformValues(_ref4) {
2774
+ var minWords = _ref4.minWords,
2775
+ values = _objectWithoutProperties(_ref4, _excluded$1);
2776
+ var rest = omit(["isMinWordsEnabled"], values);
2777
+ switch (rest.kind) {
2778
+ case QUESTION_TYPES.TEXTAREA:
2779
+ return _objectSpread$2(_objectSpread$2({}, rest), {}, {
2780
+ minWords: minWords !== null && minWords !== void 0 ? minWords : ""
2781
+ });
2782
+ case QUESTION_TYPES.ADDRESS:
2783
+ {
2784
+ var _rest$fields = rest.fields,
2785
+ fields = _rest$fields === void 0 ? [] : _rest$fields,
2786
+ addressRest = _objectWithoutProperties(rest, _excluded2);
2787
+ return _objectSpread$2(_objectSpread$2({}, addressRest), {}, {
2788
+ fieldsAttributes: map(renameKey("deleted", "_destroy"), omitDraftId(fields))
2789
+ });
2790
+ }
2791
+ default:
2792
+ return rest;
2793
+ }
2794
+ };
2795
+
2796
+ var _excluded = ["isOpen", "onClose", "action", "question", "availableQuestionKinds"];
2797
+ 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; }
2798
+ 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; }
2799
+ var ManageQuestionPane = function ManageQuestionPane(_ref) {
2800
+ var isOpen = _ref.isOpen,
2801
+ onClose = _ref.onClose,
2802
+ action = _ref.action,
2803
+ question = _ref.question,
2804
+ availableQuestionKinds = _ref.availableQuestionKinds,
2805
+ props = _objectWithoutProperties(_ref, _excluded);
2806
+ var initialFocusRef = useRef(null);
2807
+ var Component = resolveActionComponent(action);
2808
+ return /*#__PURE__*/jsx(Sheet, {
2809
+ initialFocusRef: initialFocusRef,
2810
+ isOpen: isOpen,
2811
+ onClose: onClose,
2812
+ children: /*#__PURE__*/jsx(Component, _objectSpread$1({}, _objectSpread$1({
2813
+ availableQuestionKinds: availableQuestionKinds,
2814
+ initialFocusRef: initialFocusRef,
2815
+ isOpen: isOpen,
2816
+ onClose: onClose,
2817
+ question: question
2818
+ }, props)))
2819
+ });
2820
+ };
2821
+
2822
+ 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; }
2823
+ 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; }
2824
+ var AddQuestion = function AddQuestion(_ref) {
2825
+ var onAdd = _ref.onAdd,
2826
+ disabledAddButtonHelpPopoverProps = _ref.disabledAddButtonHelpPopoverProps,
2827
+ isDisabled = _ref.isDisabled,
2828
+ addQuestionHelpProps = _ref.addQuestionHelpProps;
2829
+ var helpPopoverProps = isDisabled ? buildDisabledAddButtonHelpPopoverProps(disabledAddButtonHelpPopoverProps) : {};
2830
+ return /*#__PURE__*/jsxs("div", {
2831
+ className: "mb-8 flex w-full items-center gap-x-1",
2832
+ children: [/*#__PURE__*/jsx(Button, _objectSpread({}, buildAddQuestionButtonProps(onAdd, isDisabled))), isDisabled && /*#__PURE__*/jsx(HelpPopover, _objectSpread({}, helpPopoverProps)), isPresent(addQuestionHelpProps) && !isDisabled && /*#__PURE__*/jsx("span", {
2833
+ children: /*#__PURE__*/jsx(HelpPopover, _objectSpread({}, addQuestionHelpProps))
2834
+ })]
2835
+ });
2836
+ };
2837
+
2838
+ var Form = function Form(_ref) {
2839
+ var questionKinds = _ref.questionKinds,
2840
+ onValueChange = _ref.onValueChange,
2841
+ formId = _ref.formId,
2842
+ isDeletable = _ref.isDeletable,
2843
+ isRequiredField = _ref.isRequiredField,
2844
+ isKindAlreadyActive = _ref.isKindAlreadyActive,
2845
+ getActiveKindDetails = _ref.getActiveKindDetails,
2846
+ isDisabledFieldLabel = _ref.isDisabledFieldLabel,
2847
+ disabledAddButtonHelpPopoverProps = _ref.disabledAddButtonHelpPopoverProps,
2848
+ isFormEnabled = _ref.isFormEnabled,
2849
+ canManageQuestions = _ref.canManageQuestions,
2850
+ savedTitle = _ref.savedTitle,
2851
+ formTitle = _ref.formTitle,
2852
+ formDescription = _ref.formDescription,
2853
+ selectedLanguage = _ref.selectedLanguage,
2854
+ availableLanguages = _ref.availableLanguages,
2855
+ onLanguageChange = _ref.onLanguageChange,
2856
+ additionalActionOptions = _ref.additionalActionOptions,
2857
+ kindUniqueOn = _ref.kindUniqueOn,
2858
+ helpDocUrls = _ref.helpDocUrls,
2859
+ hostSpecificData = _ref.hostSpecificData,
2860
+ addQuestionHelpProps = _ref.addQuestionHelpProps,
2861
+ isUsingDefaultQuestionKinds = _ref.isUsingDefaultQuestionKinds,
2862
+ usesCustomSubmissionComponent = _ref.usesCustomSubmissionComponent,
2863
+ questionsFromCache = _ref.questionsFromCache,
2864
+ onMutateSuccess = _ref.onMutateSuccess,
2865
+ advancedFeatures = _ref.advancedFeatures,
2866
+ isPictureChoiceEnabled = _ref.isPictureChoiceEnabled,
2867
+ getQuestionMenuExtras = _ref.getQuestionMenuExtras;
2868
+ var containerRef = useRef();
2869
+ var _useStateWithDependen = useStateWithDependency(questionsFromCache),
2870
+ _useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
2871
+ questions = _useStateWithDependen2[0],
2872
+ setQuestions = _useStateWithDependen2[1];
2873
+ var _useState = useState({}),
2874
+ _useState2 = _slicedToArray(_useState, 2),
2875
+ selectedQuestion = _useState2[0],
2876
+ setSelectedQuestion = _useState2[1];
2877
+ var _useState3 = useState(""),
2878
+ _useState4 = _slicedToArray(_useState3, 2),
2879
+ selectedAction = _useState4[0],
2880
+ setSelectedAction = _useState4[1];
2881
+ var _useState5 = useState(false),
2882
+ _useState6 = _slicedToArray(_useState5, 2),
2883
+ isDeleteAlertOpen = _useState6[0],
2884
+ setIsDeleteAlertOpen = _useState6[1];
2885
+ var _useState7 = useState(false),
2886
+ _useState8 = _slicedToArray(_useState7, 2),
2887
+ isDeleteSmsReminderModalOpen = _useState8[0],
2888
+ setIsDeleteSmsReminderModalOpen = _useState8[1];
2889
+ var _useState9 = useState(false),
2890
+ _useState0 = _slicedToArray(_useState9, 2),
2891
+ isDeleteSpotModalOpen = _useState0[0],
2892
+ setIsDeleteSpotModalOpen = _useState0[1];
2893
+ var _useState1 = useState(false),
2894
+ _useState10 = _slicedToArray(_useState1, 2),
2895
+ isManageQuestionPaneOpen = _useState10[0],
2896
+ setIsManageQuestionPaneOpen = _useState10[1];
2897
+ var setFormData = useBuildFormStore(prop("setFormData"));
2898
+ var _useCreateQuestion = useCreateQuestion(formId, selectedLanguage, {
2899
+ onSuccess: function onSuccess() {
2900
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2901
+ args[_key] = arguments[_key];
2902
+ }
2903
+ onMutateSuccess === null || onMutateSuccess === void 0 || onMutateSuccess.apply(void 0, [QUESTION_ACTIONS.CLONE].concat(args));
2904
+ showThumbsUpToastr();
2905
+ }
2906
+ }),
2907
+ createQuestion = _useCreateQuestion.mutate;
2908
+ var _useReorderQuestions = useReorderQuestions(formId, selectedLanguage, {
2909
+ onSuccess: function onSuccess() {
2910
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2911
+ args[_key2] = arguments[_key2];
2912
+ }
2913
+ onMutateSuccess === null || onMutateSuccess === void 0 || onMutateSuccess.apply(void 0, [QUESTION_ACTIONS.REORDER].concat(args));
2914
+ setFormData({
2915
+ isReorderingQuestions: false
2916
+ });
2917
+ }
2918
+ }),
2919
+ reorderQuestions = _useReorderQuestions.mutate;
2920
+ var debouncedReorderQuestions = useFuncDebounce(reorderQuestions, 1000);
2921
+ var handleReorder = function handleReorder(questions) {
2922
+ var payload = {
2923
+ neetoFormQuestions: {
2924
+ questions: buildReorderPayload(questions)
2925
+ },
2926
+ language: selectedLanguage
2927
+ };
2928
+ setFormData({
2929
+ isReorderingQuestions: true
2930
+ });
2931
+ debouncedReorderQuestions(payload);
2932
+ };
2933
+ useEffect(function () {
2934
+ setFormData({
2935
+ formId: formId,
2936
+ enabled: isFormEnabled,
2937
+ title: savedTitle,
2938
+ selectedLanguage: selectedLanguage,
2939
+ helpDocUrls: helpDocUrls,
2940
+ isUsingDefaultQuestionKinds: isUsingDefaultQuestionKinds,
2941
+ usesCustomSubmissionComponent: usesCustomSubmissionComponent,
2942
+ hostSpecificData: hostSpecificData,
2943
+ onMutateSuccess: onMutateSuccess,
2944
+ advancedFeatures: advancedFeatures,
2945
+ onLanguageChange: onLanguageChange,
2946
+ isPictureChoiceEnabled: isPictureChoiceEnabled
2947
+ });
2948
+ }, [formId, isFormEnabled, savedTitle, setFormData, selectedLanguage, helpDocUrls, isUsingDefaultQuestionKinds, usesCustomSubmissionComponent, hostSpecificData, onMutateSuccess, advancedFeatures, onLanguageChange, isPictureChoiceEnabled]);
2949
+ var handleSelect = function handleSelect(question) {
2950
+ setSelectedQuestion(question);
2951
+ };
2952
+ var handleAdd = function handleAdd() {
2953
+ setSelectedAction(QUESTION_ACTIONS.ADD);
2954
+ setIsManageQuestionPaneOpen(true);
2955
+ };
2956
+ var handleEdit = function handleEdit() {
2957
+ setSelectedAction(QUESTION_ACTIONS.EDIT);
2958
+ setIsManageQuestionPaneOpen(true);
2959
+ };
2960
+ var handleClone = function handleClone() {
2961
+ var values = duplicateFieldData({
2962
+ item: selectedQuestion,
2963
+ questionKinds: availableQuestionKinds,
2964
+ questions: questions
2965
+ });
2966
+ var displayOrder = selectedQuestion.displayOrder + 1;
2967
+ var attributes = mergeLeft({
2968
+ displayOrder: displayOrder
2969
+ }, values);
2970
+ var payload = {
2971
+ language: selectedLanguage,
2972
+ neetoFormQuestion: formatQuestionAttributesForClone(attributes)
2973
+ };
2974
+ createQuestion(payload, {
2975
+ onSuccess: function onSuccess(_ref2) {
2976
+ var questions = _ref2.questions;
2977
+ var newQuestion = findBy({
2978
+ displayOrder: displayOrder
2979
+ }, questions);
2980
+ handleSelect(newQuestion);
2981
+ }
2982
+ });
2983
+ };
2984
+ var handleDelete = function handleDelete(question) {
2985
+ if (question.kind === QUESTION_TYPES.SMS_REMINDER) {
2986
+ setIsDeleteSmsReminderModalOpen(true);
2987
+ } else if (question.kind === QUESTION_TYPES.SPOT) {
2988
+ setIsDeleteSpotModalOpen(true);
2989
+ } else {
2990
+ setIsDeleteAlertOpen(true);
2991
+ }
2992
+ };
2993
+ useOnClickOutside(containerRef, function () {
2994
+ return handleSelect({});
2995
+ }, {
2996
+ enabled: !(isDeleteAlertOpen || isManageQuestionPaneOpen || isDeleteSmsReminderModalOpen || isDeleteSpotModalOpen)
2997
+ });
2998
+ useEffect(function () {
2999
+ onValueChange === null || onValueChange === void 0 || onValueChange(questions);
3000
+ }, [questions]);
3001
+ var availableQuestionKinds = getAvailableQuestionKinds({
3002
+ allQuestionKinds: questionKinds,
3003
+ activeQuestions: questions,
3004
+ isKindAlreadyActive: isKindAlreadyActive
3005
+ });
3006
+ return /*#__PURE__*/jsxs(Fragment, {
3007
+ children: [/*#__PURE__*/jsx(DeleteAlert, {
3008
+ handleSelect: handleSelect,
3009
+ selectedQuestion: selectedQuestion,
3010
+ isOpen: isDeleteAlertOpen,
3011
+ languagesCount: availableLanguages.length,
3012
+ onClose: function onClose() {
3013
+ return setIsDeleteAlertOpen(false);
3014
+ }
3015
+ }), /*#__PURE__*/jsx(DeleteSmsReminderModal, {
3016
+ hostSpecificData: hostSpecificData,
3017
+ isOpen: isDeleteSmsReminderModalOpen,
3018
+ onClose: function onClose() {
3019
+ return setIsDeleteSmsReminderModalOpen(false);
3020
+ }
3021
+ }), /*#__PURE__*/jsx(DeleteSpotModal, {
3022
+ hostSpecificData: hostSpecificData,
3023
+ isOpen: isDeleteSpotModalOpen,
3024
+ onClose: function onClose() {
3025
+ return setIsDeleteSpotModalOpen(false);
3026
+ }
3027
+ }), /*#__PURE__*/jsxs("div", {
3028
+ className: "neeto-form-nano-form-wrapper flex h-full flex-col",
3029
+ children: [formTitle && /*#__PURE__*/jsx(Overview, {
3030
+ additionalActionOptions: additionalActionOptions,
3031
+ availableLanguages: availableLanguages,
3032
+ description: formDescription,
3033
+ title: formTitle
3034
+ }), /*#__PURE__*/jsx("div", {
3035
+ className: "neeto-form-nano-form-wrapper__body min-h-0 w-full grow space-y-6 overflow-y-auto pb-6",
3036
+ children: isPresent(questions) ? /*#__PURE__*/jsxs("div", {
3037
+ className: "space-y-6",
3038
+ ref: containerRef,
3039
+ children: [/*#__PURE__*/jsx(DragDropContext, {
3040
+ onDragEnd: function onDragEnd(_ref3) {
3041
+ var source = _ref3.source,
3042
+ destination = _ref3.destination;
3043
+ return handleFieldDragEnd({
3044
+ source: source,
3045
+ destination: destination,
3046
+ items: questions,
3047
+ setValue: function setValue(orderedQuestions) {
3048
+ setQuestions(orderedQuestions);
3049
+ handleReorder(orderedQuestions);
3050
+ }
3051
+ });
3052
+ },
3053
+ children: /*#__PURE__*/jsx(Questions, {
3054
+ canManageQuestions: canManageQuestions,
3055
+ getActiveKindDetails: getActiveKindDetails,
3056
+ getQuestionMenuExtras: getQuestionMenuExtras,
3057
+ isDeletable: isDeletable,
3058
+ questions: questions,
3059
+ selectedQuestion: selectedQuestion,
3060
+ allQuestionKinds: questionKinds,
3061
+ onClone: handleClone,
3062
+ onDelete: handleDelete,
3063
+ onEdit: handleEdit,
3064
+ onSelect: handleSelect
3065
+ })
3066
+ }), canManageQuestions && /*#__PURE__*/jsx("div", {
3067
+ className: "mb-8 flex w-full items-center gap-x-1",
3068
+ children: /*#__PURE__*/jsx(AddQuestion, {
3069
+ addQuestionHelpProps: addQuestionHelpProps,
3070
+ disabledAddButtonHelpPopoverProps: disabledAddButtonHelpPopoverProps,
3071
+ isDisabled: isEmpty(availableQuestionKinds),
3072
+ onAdd: handleAdd
3073
+ })
3074
+ })]
3075
+ }) : /*#__PURE__*/jsx(AddFirstQuestion, {
3076
+ disabledAddButtonHelpPopoverProps: disabledAddButtonHelpPopoverProps,
3077
+ isDisabled: isEmpty(availableQuestionKinds) || !canManageQuestions,
3078
+ onAdd: handleAdd
3079
+ })
3080
+ }), /*#__PURE__*/jsx(ManageQuestionPane, {
3081
+ availableQuestionKinds: availableQuestionKinds,
3082
+ getActiveKindDetails: getActiveKindDetails,
3083
+ handleSelect: handleSelect,
3084
+ isDisabledFieldLabel: isDisabledFieldLabel,
3085
+ isRequiredField: isRequiredField,
3086
+ kindUniqueOn: kindUniqueOn,
3087
+ questions: questions,
3088
+ action: selectedAction,
3089
+ allQuestionKinds: questionKinds,
3090
+ isOpen: isManageQuestionPaneOpen,
3091
+ question: selectedQuestion,
3092
+ onClose: function onClose() {
3093
+ return setIsManageQuestionPaneOpen(false);
3094
+ }
3095
+ })]
3096
+ })]
3097
+ });
3098
+ };
3099
+
3100
+ var BuildForm = function BuildForm(_ref) {
3101
+ var id = _ref.id,
3102
+ questionKinds = _ref.questionKinds,
3103
+ _ref$isKindAlreadyAct = _ref.isKindAlreadyActive,
3104
+ isKindAlreadyActive = _ref$isKindAlreadyAct === void 0 ? isQuestionKindAlreadyActive : _ref$isKindAlreadyAct,
3105
+ _ref$getActiveKindDet = _ref.getActiveKindDetails,
3106
+ getActiveKindDetails = _ref$getActiveKindDet === void 0 ? getActiveQuestionKindDetails : _ref$getActiveKindDet,
3107
+ kindUniqueOn = _ref.kindUniqueOn,
3108
+ _ref$isQuestionDeleta = _ref.isQuestionDeletable,
3109
+ isQuestionDeletable = _ref$isQuestionDeleta === void 0 ? T : _ref$isQuestionDeleta,
3110
+ _ref$isFieldRequired = _ref.isFieldRequired,
3111
+ isFieldRequired = _ref$isFieldRequired === void 0 ? F : _ref$isFieldRequired,
3112
+ isFieldLabelDisabled = _ref.isFieldLabelDisabled,
3113
+ _ref$formTitle = _ref.formTitle,
3114
+ formTitle = _ref$formTitle === void 0 ? "" : _ref$formTitle,
3115
+ formDescription = _ref.formDescription,
3116
+ _ref$availableLanguag = _ref.availableLanguages,
3117
+ availableLanguages = _ref$availableLanguag === void 0 ? DEFAULT_AVAILABLE_LANGUAGES : _ref$availableLanguag,
3118
+ _ref$selectedLanguage = _ref.selectedLanguage,
3119
+ selectedLanguage = _ref$selectedLanguage === void 0 ? "en" : _ref$selectedLanguage,
3120
+ _ref$onLanguageChange = _ref.onLanguageChange,
3121
+ onLanguageChange = _ref$onLanguageChange === void 0 ? noop : _ref$onLanguageChange,
3122
+ _ref$addQuestionHelpP = _ref.addQuestionHelpProps,
3123
+ addQuestionHelpProps = _ref$addQuestionHelpP === void 0 ? {} : _ref$addQuestionHelpP,
3124
+ _ref$disabledAddButto = _ref.disabledAddButtonHelpPopoverProps,
3125
+ disabledAddButtonHelpPopoverProps = _ref$disabledAddButto === void 0 ? {} : _ref$disabledAddButto,
3126
+ _ref$additionalAction = _ref.additionalActionOptions,
3127
+ additionalActionOptions = _ref$additionalAction === void 0 ? [] : _ref$additionalAction,
3128
+ _ref$allowAdditionalG = _ref.allowAdditionalGuests,
3129
+ allowAdditionalGuests = _ref$allowAdditionalG === void 0 ? false : _ref$allowAdditionalG,
3130
+ _ref$advancedFeatures = _ref.advancedFeatures,
3131
+ advancedFeatures = _ref$advancedFeatures === void 0 ? DEFAULT_ADVANCED_FEATURES : _ref$advancedFeatures,
3132
+ helpDocUrls = _ref.helpDocUrls,
3133
+ className = _ref.className,
3134
+ _ref$usesCustomSubmis = _ref.usesCustomSubmissionComponent,
3135
+ usesCustomSubmissionComponent = _ref$usesCustomSubmis === void 0 ? false : _ref$usesCustomSubmis,
3136
+ _ref$onMutateSuccess = _ref.onMutateSuccess,
3137
+ onMutateSuccess = _ref$onMutateSuccess === void 0 ? noop : _ref$onMutateSuccess,
3138
+ hostSpecificData = _ref.hostSpecificData,
3139
+ _ref$canManageQuestio = _ref.canManageQuestions,
3140
+ canManageQuestions = _ref$canManageQuestio === void 0 ? false : _ref$canManageQuestio,
3141
+ _ref$isPictureChoiceE = _ref.isPictureChoiceEnabled,
3142
+ isPictureChoiceEnabled = _ref$isPictureChoiceE === void 0 ? false : _ref$isPictureChoiceE,
3143
+ getQuestionMenuExtras = _ref.getQuestionMenuExtras;
3144
+ var queryClient = useQueryClient();
3145
+ var _useForm = useForm({
3146
+ formId: id,
3147
+ language: selectedLanguage
3148
+ }),
3149
+ data = _useForm.data,
3150
+ isLoading = _useForm.isLoading,
3151
+ isQuestionsPending = _useForm.isPending;
3152
+ var _ref2 = data || QUESTIONS_INITIAL_VALUE,
3153
+ isFormEnabled = _ref2.enabled,
3154
+ savedTitle = _ref2.title,
3155
+ questionsFromCache = _ref2.questions,
3156
+ isQuestionsLoading = _ref2.isQuestionsLoading;
3157
+ if (isLoading || isQuestionsLoading && !isQuestionsPending) {
3158
+ return /*#__PURE__*/jsx("div", {
3159
+ className: "flex h-full w-full items-center justify-center py-6",
3160
+ children: /*#__PURE__*/jsx(Spinner, {})
3161
+ });
3162
+ }
3163
+ var onValueChange = function onValueChange(questions) {
3164
+ var _queryClient$getQuery = queryClient.getQueryState([QUERY_KEYS.QUESTIONS, id, selectedLanguage]),
3165
+ dataUpdateCount = _queryClient$getQuery.dataUpdateCount;
3166
+ if (dataUpdateCount > 0) {
3167
+ queryClient.setQueryData([QUERY_KEYS.QUESTIONS, "preview/".concat(id), selectedLanguage], assoc("questions", questions));
3168
+ }
3169
+ };
3170
+ var isRequiredField = either(isMandatoryField, isFieldRequired);
3171
+ var isDisabledFieldLabel = function isDisabledFieldLabel(field) {
3172
+ return isImmutableField(field) || (isFieldLabelDisabled !== null && isFieldLabelDisabled !== void 0 ? isFieldLabelDisabled : F)(field);
3173
+ };
3174
+ var defaultQuestionKinds = allowAdditionalGuests ? QUESTION_KINDS : removeBy({
3175
+ type: QUESTION_KIND.ADDITIONAL_GUESTS.value
3176
+ }, QUESTION_KINDS);
3177
+ var isUsingDefaultQuestionKinds = isNil(questionKinds);
3178
+ return /*#__PURE__*/jsx("div", {
3179
+ className: classnames("neeto-form-nano-form-outer-wrapper relative", className),
3180
+ children: /*#__PURE__*/jsx(Form, {
3181
+ addQuestionHelpProps: addQuestionHelpProps,
3182
+ additionalActionOptions: additionalActionOptions,
3183
+ advancedFeatures: advancedFeatures,
3184
+ availableLanguages: availableLanguages,
3185
+ canManageQuestions: canManageQuestions,
3186
+ disabledAddButtonHelpPopoverProps: disabledAddButtonHelpPopoverProps,
3187
+ formDescription: formDescription,
3188
+ formTitle: formTitle,
3189
+ getActiveKindDetails: getActiveKindDetails,
3190
+ getQuestionMenuExtras: getQuestionMenuExtras,
3191
+ helpDocUrls: helpDocUrls,
3192
+ hostSpecificData: hostSpecificData,
3193
+ isDisabledFieldLabel: isDisabledFieldLabel,
3194
+ isFormEnabled: isFormEnabled,
3195
+ isKindAlreadyActive: isKindAlreadyActive,
3196
+ isPictureChoiceEnabled: isPictureChoiceEnabled,
3197
+ isRequiredField: isRequiredField,
3198
+ isUsingDefaultQuestionKinds: isUsingDefaultQuestionKinds,
3199
+ kindUniqueOn: kindUniqueOn,
3200
+ onLanguageChange: onLanguageChange,
3201
+ onMutateSuccess: onMutateSuccess,
3202
+ onValueChange: onValueChange,
3203
+ questionsFromCache: questionsFromCache,
3204
+ savedTitle: savedTitle,
3205
+ selectedLanguage: selectedLanguage,
3206
+ usesCustomSubmissionComponent: usesCustomSubmissionComponent,
3207
+ formId: id,
3208
+ isDeletable: isQuestionDeletable,
3209
+ questionKinds: isUsingDefaultQuestionKinds ? defaultQuestionKinds : questionKinds
3210
+ })
3211
+ });
3212
+ };
3213
+
3214
+ export { BuildForm as default };
3215
+ //# sourceMappingURL=BuildForm.js.map