@bigbinary/neeto-form-frontend 3.3.2 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/javascript/src/translations/en.json +4 -4
- package/dist/BuildForm.js +2378 -0
- package/dist/BuildForm.js.map +1 -0
- package/dist/ExternalForm.js +658 -0
- package/dist/ExternalForm.js.map +1 -0
- package/dist/NeetoFormProvider.js +11 -0
- package/dist/NeetoFormProvider.js.map +1 -0
- package/dist/Submission.js +2700 -0
- package/dist/Submission.js.map +1 -0
- package/dist/UrlBuilder.js +297 -0
- package/dist/UrlBuilder.js.map +1 -0
- package/dist/buildForm-4a5a5251.js +35 -0
- package/dist/buildForm-4a5a5251.js.map +1 -0
- package/dist/buildForm-77b32f08.js +42 -0
- package/dist/buildForm-77b32f08.js.map +1 -0
- package/dist/cjs/BuildForm.js +2437 -0
- package/dist/cjs/BuildForm.js.map +1 -0
- package/dist/cjs/ExternalForm.js +699 -0
- package/dist/cjs/ExternalForm.js.map +1 -0
- package/dist/cjs/NeetoFormProvider.js +13 -0
- package/dist/cjs/NeetoFormProvider.js.map +1 -0
- package/dist/cjs/Submission.js +2711 -0
- package/dist/cjs/Submission.js.map +1 -0
- package/dist/cjs/UrlBuilder.js +309 -0
- package/dist/cjs/UrlBuilder.js.map +1 -0
- package/dist/cjs/hooks.js +34 -0
- package/dist/cjs/hooks.js.map +1 -0
- package/dist/cjs/index.js +116 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/constants-25c02c05.js +486 -0
- package/dist/constants-25c02c05.js.map +1 -0
- package/dist/constants-8afd221a.js +455 -0
- package/dist/constants-8afd221a.js.map +1 -0
- package/dist/constants-9310a7c2.js +342 -0
- package/dist/constants-9310a7c2.js.map +1 -0
- package/dist/constants-f0f38e6f.js +378 -0
- package/dist/constants-f0f38e6f.js.map +1 -0
- package/dist/hooks.js +20 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index-2664c3e7.js +39 -0
- package/dist/index-2664c3e7.js.map +1 -0
- package/dist/index-b6bb805c.js +46 -0
- package/dist/index-b6bb805c.js.map +1 -0
- package/dist/index.js +95 -9325
- package/dist/index.js.map +1 -1
- package/dist/main.css +12 -1
- package/dist/main.css.map +1 -1
- package/dist/useFormApi-ca36173e.js +492 -0
- package/dist/useFormApi-ca36173e.js.map +1 -0
- package/dist/useFormApi-d733cb8d.js +467 -0
- package/dist/useFormApi-d733cb8d.js.map +1 -0
- package/dist/useFormSubmission-866195bb.js +24 -0
- package/dist/useFormSubmission-866195bb.js.map +1 -0
- package/dist/useFormSubmission-f8866b84.js +22 -0
- package/dist/useFormSubmission-f8866b84.js.map +1 -0
- package/dist/utils-1ab9e83f.js +2158 -0
- package/dist/utils-1ab9e83f.js.map +1 -0
- package/dist/utils-38cc949e.js +2222 -0
- package/dist/utils-38cc949e.js.map +1 -0
- package/package.json +19 -7
- package/dist/index.cjs.js +0 -9424
- package/dist/index.cjs.js.map +0 -1
|
@@ -0,0 +1,2378 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import { useState, createElement, useRef, useEffect } from 'react';
|
|
3
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import { useFormikContext, useField, FieldArray, Form as Form$3, Formik } from 'formik';
|
|
6
|
+
import { isPresent, truncate, findBy, slugify, filterBy, hyphenate, noop, nullSafe, removeBy } from '@bigbinary/neeto-cist';
|
|
7
|
+
import { showThumbsUpToastr, hyphenize } from '@bigbinary/neeto-commons-frontend/utils';
|
|
8
|
+
import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
|
|
9
|
+
import { equals, includes, __, reduce, assoc, when, isEmpty, reject, keys, pick, omit, pluck, modify, without, path, mergeLeft, isNil, pipe, filter, isNotNil, uniq, join, map, test, difference, prop, split, last, concat } from 'ramda';
|
|
10
|
+
import { e as useDeleteQuestion, f as useFetchQuestions, g as useCreateQuestion, h as useUpdateQuestion, i as useReorderQuestions, Q as QUERY_KEYS } from './useFormApi-d733cb8d.js';
|
|
11
|
+
import { Q as QUESTION_KIND } from './constants-9310a7c2.js';
|
|
12
|
+
import { I as INDEPENDENT_LABELS_MAP, R as RICH_TEXT_QUESTIONS, h as htmlToPlainText, D as Drag, S as SELECTABLE_KINDS, a as RESERVED_FIELD_CODES, Q as QUESTION_TYPES, b as QUESTIONS_WITHOUT_FIELD_CODE, C as CAPTCHA_TYPES, F as FILE_TYPES_MAP, c as FILE_GROUPS, M as MINIMUM_OPTIONS, d as RATING_OPTIONS, e as STAR_RATING_MIN_VALUE_OPTIONS, f as STAR_RATING_MAX_VALUE_OPTIONS, g as STAR_RATING_ICONS_MAP, i as QUESTION_ACTIONS, j as QUESTION_KINDS, k as getActiveQuestionKindDetails, l as DEFAULT_AVAILABLE_LANGUAGES, m as QUESTIONS_INITIAL_VALUE, n as MANDATORY_KINDS } from './constants-8afd221a.js';
|
|
13
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
14
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
15
|
+
import { Droppable, Draggable, DragDropContext } from '@hello-pangea/dnd';
|
|
16
|
+
import { isMetaKeyPressed, withT, useStateWithDependency, useOnClickOutside } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
17
|
+
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
|
|
18
|
+
import { useTranslation, Trans } from 'react-i18next';
|
|
19
|
+
import { a as useBuildFormStore } from './buildForm-4a5a5251.js';
|
|
20
|
+
import { shallow } from 'zustand/shallow';
|
|
21
|
+
import Alert from '@bigbinary/neetoui/Alert';
|
|
22
|
+
import { f as fieldWithFallback, i as isFunction } from './index-2664c3e7.js';
|
|
23
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
24
|
+
import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
|
|
25
|
+
import Typography from '@bigbinary/neetoui/Typography';
|
|
26
|
+
import Dropdown from '@bigbinary/neetoui/Dropdown';
|
|
27
|
+
import Tooltip from '@bigbinary/neetoui/Tooltip';
|
|
28
|
+
import { t } from 'i18next';
|
|
29
|
+
import Plus from '@bigbinary/neeto-icons/Plus';
|
|
30
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
31
|
+
import NoData from '@bigbinary/neetoui/NoData';
|
|
32
|
+
import Pane from '@bigbinary/neetoui/Pane';
|
|
33
|
+
import Form$2 from '@bigbinary/neetoui/formik/Form';
|
|
34
|
+
import Select from '@bigbinary/neetoui/formik/Select';
|
|
35
|
+
import Switch from '@bigbinary/neetoui/formik/Switch';
|
|
36
|
+
import Textarea from '@bigbinary/neetoui/formik/Textarea';
|
|
37
|
+
import NeetoEditor from '@bigbinary/neeto-editor/Editor';
|
|
38
|
+
import Button from '@bigbinary/neetoui/Button';
|
|
39
|
+
import Accordion from '@bigbinary/neetoui/Accordion';
|
|
40
|
+
import Input from '@bigbinary/neetoui/formik/Input';
|
|
41
|
+
import { isEditorEmpty } from '@bigbinary/neeto-editor/utils';
|
|
42
|
+
import * as yup from 'yup';
|
|
43
|
+
import Radio from '@bigbinary/neetoui/formik/Radio';
|
|
44
|
+
import HelpPopover from '@bigbinary/neeto-molecules/HelpPopover';
|
|
45
|
+
import Label from '@bigbinary/neetoui/Label';
|
|
46
|
+
import CreatableSelect from 'react-select/creatable';
|
|
47
|
+
import _toArray from '@babel/runtime/helpers/toArray';
|
|
48
|
+
import Close from '@bigbinary/neeto-icons/Close';
|
|
49
|
+
import Tag from '@bigbinary/neetoui/Tag';
|
|
50
|
+
import { components } from 'react-select';
|
|
51
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
52
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
53
|
+
import Checkbox$1 from '@bigbinary/neetoui/formik/Checkbox';
|
|
54
|
+
import Checkbox from '@bigbinary/neetoui/Checkbox';
|
|
55
|
+
import Delete from '@bigbinary/neeto-icons/Delete';
|
|
56
|
+
import '@bigbinary/neeto-commons-frontend/constants';
|
|
57
|
+
import 'axios';
|
|
58
|
+
import 'dompurify';
|
|
59
|
+
import 'zustand';
|
|
60
|
+
import '@babel/runtime/helpers/typeof';
|
|
61
|
+
|
|
62
|
+
var DeleteAlert = function DeleteAlert(_ref) {
|
|
63
|
+
var selectedQuestion = _ref.selectedQuestion,
|
|
64
|
+
isOpen = _ref.isOpen,
|
|
65
|
+
onClose = _ref.onClose,
|
|
66
|
+
languagesCount = _ref.languagesCount,
|
|
67
|
+
handleSelect = _ref.handleSelect;
|
|
68
|
+
var _useTranslation = useTranslation(),
|
|
69
|
+
t = _useTranslation.t;
|
|
70
|
+
var _useBuildFormStore = useBuildFormStore(function (store) {
|
|
71
|
+
var _store$formState;
|
|
72
|
+
return {
|
|
73
|
+
selectedLanguage: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["selectedLanguage"]
|
|
74
|
+
};
|
|
75
|
+
}, shallow),
|
|
76
|
+
selectedLanguage = _useBuildFormStore.selectedLanguage;
|
|
77
|
+
var renderQuestionLabel = function renderQuestionLabel() {
|
|
78
|
+
var questionKind = selectedQuestion.kind;
|
|
79
|
+
var independentLabel = INDEPENDENT_LABELS_MAP[questionKind];
|
|
80
|
+
if (isPresent(independentLabel)) return independentLabel;
|
|
81
|
+
var questionLabel = fieldWithFallback(selectedQuestion, "label");
|
|
82
|
+
return truncate(questionLabel, 40);
|
|
83
|
+
};
|
|
84
|
+
var _useDeleteQuestion = useDeleteQuestion(selectedQuestion === null || selectedQuestion === void 0 ? void 0 : selectedQuestion.formId, selectedLanguage, {
|
|
85
|
+
onSuccess: function onSuccess() {
|
|
86
|
+
showThumbsUpToastr();
|
|
87
|
+
onClose();
|
|
88
|
+
}
|
|
89
|
+
}),
|
|
90
|
+
deleteQuestion = _useDeleteQuestion.mutate,
|
|
91
|
+
isDeleting = _useDeleteQuestion.isPending;
|
|
92
|
+
var selectNextQuestion = function selectNextQuestion(questions) {
|
|
93
|
+
var selectedQuestionIndex = selectedQuestion.displayOrder;
|
|
94
|
+
var wasLastQuestion = equals(selectedQuestionIndex, questions.length);
|
|
95
|
+
var newDisplayOrder = wasLastQuestion ? selectedQuestionIndex - 1 : selectedQuestionIndex;
|
|
96
|
+
var newQuestion = findBy({
|
|
97
|
+
displayOrder: newDisplayOrder
|
|
98
|
+
}, questions);
|
|
99
|
+
handleSelect(newQuestion);
|
|
100
|
+
};
|
|
101
|
+
var handleSubmit = function handleSubmit() {
|
|
102
|
+
deleteQuestion(selectedQuestion.id, {
|
|
103
|
+
onSuccess: function onSuccess(_ref2) {
|
|
104
|
+
var questions = _ref2.questions;
|
|
105
|
+
return selectNextQuestion(questions);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
return /*#__PURE__*/jsx(Alert, {
|
|
110
|
+
isOpen: isOpen,
|
|
111
|
+
onClose: onClose,
|
|
112
|
+
isSubmitting: isDeleting,
|
|
113
|
+
submitButtonLabel: t("neetoForm.common.delete"),
|
|
114
|
+
title: t("neetoForm.questions.deleteAlert.title"),
|
|
115
|
+
message: isPresent(selectedQuestion) && /*#__PURE__*/jsx(Trans, {
|
|
116
|
+
i18nKey: "neetoForm.questions.deleteAlert.message",
|
|
117
|
+
values: {
|
|
118
|
+
count: languagesCount,
|
|
119
|
+
label: renderQuestionLabel()
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
onSubmit: handleSubmit
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
var ChangeLanguageDropdown = function ChangeLanguageDropdown(_ref) {
|
|
127
|
+
var _findBy;
|
|
128
|
+
var currentLanguage = _ref.currentLanguage,
|
|
129
|
+
languages = _ref.languages,
|
|
130
|
+
onChange = _ref.onChange;
|
|
131
|
+
var _useState = useState(false),
|
|
132
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
133
|
+
isUnsavedChangesAlertOpen = _useState2[0],
|
|
134
|
+
setIsUnsavedChangesAlertOpen = _useState2[1];
|
|
135
|
+
var _useState3 = useState(currentLanguage),
|
|
136
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
137
|
+
selectedLanguage = _useState4[0],
|
|
138
|
+
setSelectedLanguage = _useState4[1];
|
|
139
|
+
var _useTranslation = useTranslation(),
|
|
140
|
+
t = _useTranslation.t;
|
|
141
|
+
var _useFormikContext = useFormikContext(),
|
|
142
|
+
dirty = _useFormikContext.dirty;
|
|
143
|
+
var languageChangeHandler = function languageChangeHandler(code) {
|
|
144
|
+
if (!dirty) {
|
|
145
|
+
onChange(code);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
setSelectedLanguage(code);
|
|
149
|
+
setIsUnsavedChangesAlertOpen(true);
|
|
150
|
+
};
|
|
151
|
+
var selectedLanguageName = (_findBy = findBy({
|
|
152
|
+
code: currentLanguage
|
|
153
|
+
}, languages)) === null || _findBy === void 0 ? void 0 : _findBy.name;
|
|
154
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
155
|
+
children: [/*#__PURE__*/jsx(Tooltip, {
|
|
156
|
+
content: t("neetoForm.questions.changeLanguage"),
|
|
157
|
+
children: /*#__PURE__*/jsx("div", {
|
|
158
|
+
children: /*#__PURE__*/jsx(Dropdown, {
|
|
159
|
+
buttonStyle: "secondary",
|
|
160
|
+
label: selectedLanguageName,
|
|
161
|
+
children: /*#__PURE__*/jsx(Dropdown.Menu, {
|
|
162
|
+
children: languages.map(function (_ref2) {
|
|
163
|
+
var code = _ref2.code,
|
|
164
|
+
name = _ref2.name;
|
|
165
|
+
return /*#__PURE__*/jsx(Dropdown.MenuItem.Button, {
|
|
166
|
+
isActive: currentLanguage === code,
|
|
167
|
+
onClick: function onClick() {
|
|
168
|
+
return languageChangeHandler(code);
|
|
169
|
+
},
|
|
170
|
+
children: name
|
|
171
|
+
}, code);
|
|
172
|
+
})
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
}), /*#__PURE__*/jsx(Alert, {
|
|
177
|
+
isOpen: isUnsavedChangesAlertOpen,
|
|
178
|
+
message: t("neetoForm.questions.unsavedChangesAlert.message"),
|
|
179
|
+
submitButtonLabel: t("neetoForm.questions.unsavedChangesAlert.discard"),
|
|
180
|
+
title: t("neetoForm.questions.unsavedChangesAlert.title"),
|
|
181
|
+
onClose: function onClose() {
|
|
182
|
+
return setIsUnsavedChangesAlertOpen(false);
|
|
183
|
+
},
|
|
184
|
+
onSubmit: function onSubmit() {
|
|
185
|
+
onChange(selectedLanguage);
|
|
186
|
+
setIsUnsavedChangesAlertOpen(false);
|
|
187
|
+
}
|
|
188
|
+
})]
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
var Overview = function Overview(_ref) {
|
|
193
|
+
var title = _ref.title,
|
|
194
|
+
description = _ref.description,
|
|
195
|
+
availableLanguages = _ref.availableLanguages,
|
|
196
|
+
selectedLanguage = _ref.selectedLanguage,
|
|
197
|
+
onLanguageChange = _ref.onLanguageChange,
|
|
198
|
+
additionalActionOptions = _ref.additionalActionOptions;
|
|
199
|
+
return /*#__PURE__*/jsxs("div", {
|
|
200
|
+
className: "neeto-form-nano-form-wrapper__overview mb-4 w-full flex-shrink-0 space-y-4 px-6 pt-6",
|
|
201
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
202
|
+
className: "flex items-center justify-between",
|
|
203
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
204
|
+
"data-cy": "neeto-form-engine-overview-title",
|
|
205
|
+
lineHeight: "neeto-ui-leading-normal",
|
|
206
|
+
style: "h2",
|
|
207
|
+
weight: "neeto-ui-font-semibold",
|
|
208
|
+
children: title
|
|
209
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
210
|
+
className: "flex flex-shrink-0 items-center justify-between space-x-1",
|
|
211
|
+
children: [availableLanguages.length > 1 && /*#__PURE__*/jsx(ChangeLanguageDropdown, {
|
|
212
|
+
currentLanguage: selectedLanguage,
|
|
213
|
+
languages: availableLanguages,
|
|
214
|
+
onChange: onLanguageChange
|
|
215
|
+
}), isPresent(additionalActionOptions) && /*#__PURE__*/jsx(MoreDropdown, {
|
|
216
|
+
dropdownButtonProps: {
|
|
217
|
+
isRounded: true,
|
|
218
|
+
style: "tertiary"
|
|
219
|
+
},
|
|
220
|
+
dropdownProps: {
|
|
221
|
+
strategy: "fixed",
|
|
222
|
+
position: "bottom-start"
|
|
223
|
+
},
|
|
224
|
+
menuItems: additionalActionOptions
|
|
225
|
+
})]
|
|
226
|
+
})]
|
|
227
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
228
|
+
"data-cy": "neeto-form-engine-overview-description",
|
|
229
|
+
style: "body2",
|
|
230
|
+
children: description
|
|
231
|
+
})]
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
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; }
|
|
236
|
+
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), !0).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; }
|
|
237
|
+
var validateEditorContent = function validateEditorContent(editorRef) {
|
|
238
|
+
return function () {
|
|
239
|
+
var _editorRef$current;
|
|
240
|
+
return (_editorRef$current = editorRef.current) !== null && _editorRef$current !== void 0 && (_editorRef$current = _editorRef$current.editor) !== null && _editorRef$current !== void 0 && _editorRef$current.isEmpty ? t("neetoForm.common.thisFieldIsRequired") : "";
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
var buildReorderPayload = function buildReorderPayload(questions) {
|
|
244
|
+
return reduce(function (acc, _ref) {
|
|
245
|
+
var id = _ref.id,
|
|
246
|
+
displayOrder = _ref.displayOrder;
|
|
247
|
+
return assoc(id, displayOrder, acc);
|
|
248
|
+
}, {}, questions);
|
|
249
|
+
};
|
|
250
|
+
var isRichTextQuestion = includes(__, RICH_TEXT_QUESTIONS);
|
|
251
|
+
var buildAddQuestionButtonProps = function buildAddQuestionButtonProps(onAdd, isDisabled, tooltipProps) {
|
|
252
|
+
return _objectSpread$g({
|
|
253
|
+
"data-cy": "neeto-form-engine-add-question-button",
|
|
254
|
+
disabled: isDisabled,
|
|
255
|
+
label: t("neetoForm.questions.common.primaryPanel.addQuestion"),
|
|
256
|
+
icon: Plus,
|
|
257
|
+
iconPosition: "left",
|
|
258
|
+
style: "link",
|
|
259
|
+
onClick: onAdd
|
|
260
|
+
}, isDisabled && {
|
|
261
|
+
tooltipProps: tooltipProps
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
var buildDisabledAddButtonTooltipProps = function buildDisabledAddButtonTooltipProps(isDisabled) {
|
|
265
|
+
var disabledAddButtonTooltipProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
266
|
+
return _objectSpread$g({
|
|
267
|
+
disabled: !isDisabled,
|
|
268
|
+
position: "top",
|
|
269
|
+
content: t("neetoForm.questions.common.primaryPanel.noQuestionLeft")
|
|
270
|
+
}, disabledAddButtonTooltipProps);
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
var Card = function Card(_ref) {
|
|
274
|
+
var _ref$question = _ref.question,
|
|
275
|
+
question = _ref$question === void 0 ? {} : _ref$question,
|
|
276
|
+
allQuestionKinds = _ref.allQuestionKinds,
|
|
277
|
+
getActiveKindDetails = _ref.getActiveKindDetails,
|
|
278
|
+
isActive = _ref.isActive,
|
|
279
|
+
onSelect = _ref.onSelect,
|
|
280
|
+
onEdit = _ref.onEdit,
|
|
281
|
+
onClone = _ref.onClone,
|
|
282
|
+
onDelete = _ref.onDelete;
|
|
283
|
+
var _useTranslation = useTranslation(),
|
|
284
|
+
t = _useTranslation.t;
|
|
285
|
+
var _getActiveKindDetails = getActiveKindDetails({
|
|
286
|
+
allQuestionKinds: allQuestionKinds,
|
|
287
|
+
item: question
|
|
288
|
+
}),
|
|
289
|
+
kind = _getActiveKindDetails.kind,
|
|
290
|
+
isSingular = _getActiveKindDetails.isSingular;
|
|
291
|
+
var label = fieldWithFallback(question, "label");
|
|
292
|
+
var questionLabel = isRichTextQuestion(kind) ? htmlToPlainText(label) : label;
|
|
293
|
+
return /*#__PURE__*/jsxs("div", {
|
|
294
|
+
"data-cy": "neeto-form-engine-".concat(slugify(questionLabel)),
|
|
295
|
+
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 border p-2", {
|
|
296
|
+
"neeto-ui-border-primary-500 neeto-form-nano-form__card--active": isActive
|
|
297
|
+
}),
|
|
298
|
+
onClick: function onClick() {
|
|
299
|
+
return onSelect(question);
|
|
300
|
+
},
|
|
301
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
302
|
+
className: "flex min-w-0 flex-grow items-center gap-1",
|
|
303
|
+
children: [/*#__PURE__*/jsx(Drag, {
|
|
304
|
+
className: "neeto-ui-text-gray-600 flex-shrink-0"
|
|
305
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
306
|
+
className: "line-clamp-2 min-w-0 flex-grow truncate break-words",
|
|
307
|
+
lineHeight: "snug",
|
|
308
|
+
style: "body2",
|
|
309
|
+
weight: "medium",
|
|
310
|
+
children: questionLabel
|
|
311
|
+
})]
|
|
312
|
+
}), /*#__PURE__*/jsx(MoreDropdown, {
|
|
313
|
+
dropdownButtonProps: {
|
|
314
|
+
className: "shrink-0"
|
|
315
|
+
},
|
|
316
|
+
dropdownProps: {
|
|
317
|
+
strategy: "fixed"
|
|
318
|
+
},
|
|
319
|
+
menuItems: [{
|
|
320
|
+
"data-cy": "edit-question",
|
|
321
|
+
key: "edit",
|
|
322
|
+
label: t("neetoForm.common.edit"),
|
|
323
|
+
onClick: onEdit
|
|
324
|
+
}, {
|
|
325
|
+
"data-cy": "clone-question",
|
|
326
|
+
key: "clone",
|
|
327
|
+
label: t("neetoForm.common.clone"),
|
|
328
|
+
isVisible: !isSingular && isFunction(onClone),
|
|
329
|
+
onClick: onClone
|
|
330
|
+
}, {
|
|
331
|
+
"data-cy": "delete-question",
|
|
332
|
+
key: "delete",
|
|
333
|
+
label: t("neetoForm.common.delete"),
|
|
334
|
+
isVisible: isFunction(onDelete),
|
|
335
|
+
onClick: onDelete
|
|
336
|
+
}]
|
|
337
|
+
})]
|
|
338
|
+
});
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
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; }
|
|
342
|
+
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), !0).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; }
|
|
343
|
+
var Questions = function Questions(_ref) {
|
|
344
|
+
var questions = _ref.questions,
|
|
345
|
+
isDeletable = _ref.isDeletable,
|
|
346
|
+
allQuestionKinds = _ref.allQuestionKinds,
|
|
347
|
+
getActiveKindDetails = _ref.getActiveKindDetails,
|
|
348
|
+
selectedQuestion = _ref.selectedQuestion,
|
|
349
|
+
onEdit = _ref.onEdit,
|
|
350
|
+
onClone = _ref.onClone,
|
|
351
|
+
onDelete = _ref.onDelete,
|
|
352
|
+
onSelect = _ref.onSelect;
|
|
353
|
+
return /*#__PURE__*/jsx(Droppable, {
|
|
354
|
+
droppableId: "droppable",
|
|
355
|
+
children: function children(_ref2) {
|
|
356
|
+
var droppableProps = _ref2.droppableProps,
|
|
357
|
+
placeholder = _ref2.placeholder,
|
|
358
|
+
innerRef = _ref2.innerRef;
|
|
359
|
+
return /*#__PURE__*/jsxs("div", _objectSpread$f(_objectSpread$f({}, droppableProps), {}, {
|
|
360
|
+
className: "space-y-2",
|
|
361
|
+
ref: innerRef,
|
|
362
|
+
children: [questions.map(function (question, index) {
|
|
363
|
+
var _question$id, _question$id2;
|
|
364
|
+
return /*#__PURE__*/createElement(Draggable, {
|
|
365
|
+
index: index,
|
|
366
|
+
draggableId: "question-".concat((_question$id = question.id) !== null && _question$id !== void 0 ? _question$id : question.nodeId),
|
|
367
|
+
key: "question-".concat((_question$id2 = question.id) !== null && _question$id2 !== void 0 ? _question$id2 : question.nodeId)
|
|
368
|
+
}, function (_ref3) {
|
|
369
|
+
var draggableProps = _ref3.draggableProps,
|
|
370
|
+
dragHandleProps = _ref3.dragHandleProps,
|
|
371
|
+
innerRef = _ref3.innerRef;
|
|
372
|
+
return /*#__PURE__*/jsx("div", _objectSpread$f(_objectSpread$f(_objectSpread$f({}, draggableProps), dragHandleProps), {}, {
|
|
373
|
+
ref: innerRef,
|
|
374
|
+
children: /*#__PURE__*/jsx(Card, {
|
|
375
|
+
allQuestionKinds: allQuestionKinds,
|
|
376
|
+
getActiveKindDetails: getActiveKindDetails,
|
|
377
|
+
onClone: onClone,
|
|
378
|
+
onEdit: onEdit,
|
|
379
|
+
onSelect: onSelect,
|
|
380
|
+
question: question,
|
|
381
|
+
isActive: equals(selectedQuestion, question),
|
|
382
|
+
onDelete: isDeletable(question) && onDelete
|
|
383
|
+
})
|
|
384
|
+
}));
|
|
385
|
+
});
|
|
386
|
+
}), placeholder]
|
|
387
|
+
}));
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
393
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
394
|
+
// generators (like Math.random()).
|
|
395
|
+
let getRandomValues;
|
|
396
|
+
const rnds8 = new Uint8Array(16);
|
|
397
|
+
function rng() {
|
|
398
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
399
|
+
if (!getRandomValues) {
|
|
400
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
401
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
402
|
+
|
|
403
|
+
if (!getRandomValues) {
|
|
404
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return getRandomValues(rnds8);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
413
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
414
|
+
*/
|
|
415
|
+
|
|
416
|
+
const byteToHex = [];
|
|
417
|
+
|
|
418
|
+
for (let i = 0; i < 256; ++i) {
|
|
419
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function unsafeStringify(arr, offset = 0) {
|
|
423
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
424
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
425
|
+
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
429
|
+
var native = {
|
|
430
|
+
randomUUID
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
function v4(options, buf, offset) {
|
|
434
|
+
if (native.randomUUID && !buf && !options) {
|
|
435
|
+
return native.randomUUID();
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
options = options || {};
|
|
439
|
+
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
440
|
+
|
|
441
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
442
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
443
|
+
|
|
444
|
+
if (buf) {
|
|
445
|
+
offset = offset || 0;
|
|
446
|
+
|
|
447
|
+
for (let i = 0; i < 16; ++i) {
|
|
448
|
+
buf[offset + i] = rnds[i];
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return buf;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
return unsafeStringify(rnds);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
var moveItem = function moveItem(arr, sourceIndex, destinationIndex) {
|
|
458
|
+
if (sourceIndex === destinationIndex) return arr;
|
|
459
|
+
if (arr instanceof Array && arr[sourceIndex] !== undefined) {
|
|
460
|
+
var removedItem = arr.splice(sourceIndex, 1)[0];
|
|
461
|
+
arr.splice(destinationIndex, 0, removedItem);
|
|
462
|
+
}
|
|
463
|
+
return arr;
|
|
464
|
+
};
|
|
465
|
+
var arrayHelpers = {
|
|
466
|
+
moveItem: moveItem
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
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; }
|
|
470
|
+
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), !0).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; }
|
|
471
|
+
var isChoiceQuestion = function isChoiceQuestion(question) {
|
|
472
|
+
return includes(question === null || question === void 0 ? void 0 : question.kind, SELECTABLE_KINDS);
|
|
473
|
+
};
|
|
474
|
+
var generateUniqueFieldCode = function generateUniqueFieldCode(type, questions) {
|
|
475
|
+
var fieldCodes = pluck("fieldCode", filterBy({
|
|
476
|
+
kind: type
|
|
477
|
+
}, questions));
|
|
478
|
+
var uniqueNumber = fieldCodes.length;
|
|
479
|
+
var candidateFieldCode = "";
|
|
480
|
+
var prefix = RESERVED_FIELD_CODES.includes(type) ? "".concat(type, "_field") : type;
|
|
481
|
+
|
|
482
|
+
//We need to continue this while loop until we can generate a unique fieldCode
|
|
483
|
+
// eslint-disable-next-line no-constant-condition
|
|
484
|
+
while (true) {
|
|
485
|
+
candidateFieldCode = "".concat(prefix).concat(uniqueNumber || "");
|
|
486
|
+
if (!findBy({
|
|
487
|
+
fieldCode: candidateFieldCode
|
|
488
|
+
}, questions)) break;
|
|
489
|
+
uniqueNumber += 1;
|
|
490
|
+
}
|
|
491
|
+
return candidateFieldCode;
|
|
492
|
+
};
|
|
493
|
+
var isQuestionKindAlreadyActive = function isQuestionKindAlreadyActive(_ref) {
|
|
494
|
+
var activeQuestions = _ref.activeQuestions,
|
|
495
|
+
kind = _ref.kind;
|
|
496
|
+
return activeQuestions.some(function (activeQuestion) {
|
|
497
|
+
return activeQuestion.kind === kind.type && activeQuestion._destroy !== true;
|
|
498
|
+
});
|
|
499
|
+
};
|
|
500
|
+
var handleFieldDragEnd = function handleFieldDragEnd(_ref2) {
|
|
501
|
+
var items = _ref2.items,
|
|
502
|
+
setValue = _ref2.setValue,
|
|
503
|
+
source = _ref2.source,
|
|
504
|
+
destination = _ref2.destination;
|
|
505
|
+
if (!(destination && items instanceof Array)) return;
|
|
506
|
+
var nextItems = _toConsumableArray(items);
|
|
507
|
+
arrayHelpers.moveItem(nextItems, source.index, destination.index);
|
|
508
|
+
var orderedItems = nextItems.map(function (item, index) {
|
|
509
|
+
return _objectSpread$e(_objectSpread$e({}, item), {}, {
|
|
510
|
+
displayOrder: index
|
|
511
|
+
});
|
|
512
|
+
});
|
|
513
|
+
setValue("questions", orderedItems);
|
|
514
|
+
};
|
|
515
|
+
var createFieldData = function createFieldData(_ref3) {
|
|
516
|
+
var _ref3$kind = _ref3.kind,
|
|
517
|
+
defaults = _ref3$kind.defaults,
|
|
518
|
+
type = _ref3$kind.type,
|
|
519
|
+
metadata = _ref3$kind.metadata,
|
|
520
|
+
_ref3$isRequired = _ref3.isRequired,
|
|
521
|
+
isRequired = _ref3$isRequired === void 0 ? undefined : _ref3$isRequired,
|
|
522
|
+
questions = _ref3.questions;
|
|
523
|
+
return _objectSpread$e(_objectSpread$e({}, defaults), {}, {
|
|
524
|
+
metadata: metadata,
|
|
525
|
+
isRequired: isRequired,
|
|
526
|
+
kind: type,
|
|
527
|
+
nodeId: v4(),
|
|
528
|
+
fieldCode: generateUniqueFieldCode(type, questions)
|
|
529
|
+
});
|
|
530
|
+
};
|
|
531
|
+
var duplicateFieldData = function duplicateFieldData(_ref4) {
|
|
532
|
+
var item = _ref4.item,
|
|
533
|
+
questionKinds = _ref4.questionKinds,
|
|
534
|
+
questions = _ref4.questions;
|
|
535
|
+
var questionKind = findBy({
|
|
536
|
+
type: item.kind
|
|
537
|
+
}, questionKinds);
|
|
538
|
+
var isRequired = item.isRequired,
|
|
539
|
+
kind = item.kind,
|
|
540
|
+
optionsAttributes = item.optionsAttributes;
|
|
541
|
+
var label = fieldWithFallback(item, "label");
|
|
542
|
+
var defaultAttributeNames = keys(questionKind.defaults || {});
|
|
543
|
+
var defaultAttributes = pick(defaultAttributeNames, item);
|
|
544
|
+
var newQuestionLabel = isRichTextQuestion(kind) ? label : t("neetoForm.common.clonedElementLabel", {
|
|
545
|
+
label: label
|
|
546
|
+
});
|
|
547
|
+
return _objectSpread$e(_objectSpread$e({}, defaultAttributes), {}, {
|
|
548
|
+
isRequired: isRequired,
|
|
549
|
+
kind: kind,
|
|
550
|
+
label: newQuestionLabel,
|
|
551
|
+
optionsAttributes: optionsAttributes && optionsAttributes.map(omit(["id"])),
|
|
552
|
+
nodeId: v4(),
|
|
553
|
+
fieldCode: generateUniqueFieldCode(item.kind, questions),
|
|
554
|
+
displayOrder: item.displayOrder + 1
|
|
555
|
+
});
|
|
556
|
+
};
|
|
557
|
+
var getAvailableQuestionKinds = function getAvailableQuestionKinds(_ref5) {
|
|
558
|
+
var allQuestionKinds = _ref5.allQuestionKinds,
|
|
559
|
+
_ref5$activeQuestions = _ref5.activeQuestions,
|
|
560
|
+
activeQuestions = _ref5$activeQuestions === void 0 ? [] : _ref5$activeQuestions,
|
|
561
|
+
isKindAlreadyActive = _ref5.isKindAlreadyActive;
|
|
562
|
+
if (isEmpty(activeQuestions)) return allQuestionKinds;
|
|
563
|
+
return reject(function (kind) {
|
|
564
|
+
var isSingularKind = kind.isSingular;
|
|
565
|
+
return isSingularKind && isKindAlreadyActive({
|
|
566
|
+
activeQuestions: activeQuestions,
|
|
567
|
+
kind: kind
|
|
568
|
+
});
|
|
569
|
+
}, allQuestionKinds);
|
|
570
|
+
};
|
|
571
|
+
var formatQuestionAttributesForClone = when(isChoiceQuestion, assoc("isCloning", true));
|
|
572
|
+
|
|
573
|
+
var AddFirstQuestion = function AddFirstQuestion(_ref) {
|
|
574
|
+
var onAdd = _ref.onAdd,
|
|
575
|
+
isDisabled = _ref.isDisabled,
|
|
576
|
+
disabledAddButtonTooltipProps = _ref.disabledAddButtonTooltipProps;
|
|
577
|
+
var _useTranslation = useTranslation(),
|
|
578
|
+
t = _useTranslation.t;
|
|
579
|
+
var tooltipProps = buildDisabledAddButtonTooltipProps(isDisabled, disabledAddButtonTooltipProps);
|
|
580
|
+
return /*#__PURE__*/jsx("div", {
|
|
581
|
+
className: "flex h-full flex-col items-center justify-center py-8",
|
|
582
|
+
children: /*#__PURE__*/jsx(NoData, {
|
|
583
|
+
showTooltipWhenButtonDisabled: true,
|
|
584
|
+
className: "min-h-80",
|
|
585
|
+
title: t("neetoForm.questions.common.noData"),
|
|
586
|
+
primaryButtonProps: buildAddQuestionButtonProps(onAdd, isDisabled, tooltipProps)
|
|
587
|
+
})
|
|
588
|
+
});
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
var NAME = QUESTION_TYPES.NAME,
|
|
592
|
+
PHONE = QUESTION_TYPES.PHONE,
|
|
593
|
+
EMAIL$1 = QUESTION_TYPES.EMAIL,
|
|
594
|
+
ADDITIONAL_GUESTS = QUESTION_TYPES.ADDITIONAL_GUESTS,
|
|
595
|
+
TEXT = QUESTION_TYPES.TEXT,
|
|
596
|
+
TEXTAREA = QUESTION_TYPES.TEXTAREA,
|
|
597
|
+
RICH_TEXT = QUESTION_TYPES.RICH_TEXT,
|
|
598
|
+
INTEGER = QUESTION_TYPES.INTEGER,
|
|
599
|
+
DECIMAL = QUESTION_TYPES.DECIMAL,
|
|
600
|
+
STAR_RATING$1 = QUESTION_TYPES.STAR_RATING,
|
|
601
|
+
RATING$1 = QUESTION_TYPES.RATING,
|
|
602
|
+
DATE = QUESTION_TYPES.DATE,
|
|
603
|
+
FILE_UPLOAD$1 = QUESTION_TYPES.FILE_UPLOAD,
|
|
604
|
+
CAPTCHA$1 = QUESTION_TYPES.CAPTCHA;
|
|
605
|
+
var QUESTIONS_WITH_ADDITIONAL_DATA = [].concat(_toConsumableArray(SELECTABLE_KINDS), [STAR_RATING$1, RATING$1, FILE_UPLOAD$1, CAPTCHA$1, EMAIL$1]);
|
|
606
|
+
var QUESTIONS_WITH_PLACEHOLDERS = [NAME, PHONE, EMAIL$1, ADDITIONAL_GUESTS, TEXT, TEXTAREA, RICH_TEXT, INTEGER, DECIMAL, DATE];
|
|
607
|
+
var DEFAULT_PLACEHOLDERS = {
|
|
608
|
+
CHECKBOX: t("neetoForm.questions.common.questionFields.field.labelExample", {
|
|
609
|
+
what: t("neetoForm.common.hobbies")
|
|
610
|
+
}),
|
|
611
|
+
RADIO: t("neetoForm.questions.common.questionFields.field.labelExample", {
|
|
612
|
+
what: t("neetoForm.common.country")
|
|
613
|
+
}),
|
|
614
|
+
DROPDOWN: t("neetoForm.questions.common.questionFields.field.labelExample", {
|
|
615
|
+
what: t("neetoForm.common.company")
|
|
616
|
+
})
|
|
617
|
+
};
|
|
618
|
+
var INITIAL_VALUES = {
|
|
619
|
+
kind: "",
|
|
620
|
+
label: "",
|
|
621
|
+
fieldCode: ""
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
var _excluded$8 = ["label", "name"];
|
|
625
|
+
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; }
|
|
626
|
+
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), !0).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; }
|
|
627
|
+
var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
|
|
628
|
+
var label = _ref.label,
|
|
629
|
+
name = _ref.name,
|
|
630
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$8);
|
|
631
|
+
var _useFormikContext = useFormikContext(),
|
|
632
|
+
dirty = _useFormikContext.dirty,
|
|
633
|
+
isValid = _useFormikContext.isValid,
|
|
634
|
+
submitForm = _useFormikContext.submitForm;
|
|
635
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
636
|
+
if (event.key !== "Enter" || event.shiftKey) return;
|
|
637
|
+
event.preventDefault();
|
|
638
|
+
if (isMetaKeyPressed(event)) return;
|
|
639
|
+
dirty && isValid && submitForm();
|
|
640
|
+
};
|
|
641
|
+
var handleFocus = function handleFocus(element) {
|
|
642
|
+
var end = element.value.length;
|
|
643
|
+
element.setSelectionRange(end, end);
|
|
644
|
+
};
|
|
645
|
+
return /*#__PURE__*/jsx(Textarea, _objectSpread$d({
|
|
646
|
+
label: label,
|
|
647
|
+
name: name,
|
|
648
|
+
className: "neeto-form-nano-adaptive-input",
|
|
649
|
+
resize: "none",
|
|
650
|
+
size: "small",
|
|
651
|
+
onFocus: function onFocus(_ref2) {
|
|
652
|
+
var target = _ref2.target;
|
|
653
|
+
return handleFocus(target);
|
|
654
|
+
},
|
|
655
|
+
onKeyDown: handleKeyDown
|
|
656
|
+
}, otherProps));
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
var Block = function Block(_ref) {
|
|
660
|
+
var title = _ref.title,
|
|
661
|
+
children = _ref.children,
|
|
662
|
+
dataCy = _ref.dataCy;
|
|
663
|
+
return /*#__PURE__*/jsxs("div", {
|
|
664
|
+
className: "mt-4 space-y-4",
|
|
665
|
+
"data-cy": dataCy,
|
|
666
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
667
|
+
className: "flex items-center justify-between",
|
|
668
|
+
"data-cy": "properties-header",
|
|
669
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
670
|
+
lineHeight: "normal",
|
|
671
|
+
style: "body1",
|
|
672
|
+
weight: "semibold",
|
|
673
|
+
children: title
|
|
674
|
+
})
|
|
675
|
+
}), /*#__PURE__*/jsx("div", {
|
|
676
|
+
className: "space-y-4",
|
|
677
|
+
children: children
|
|
678
|
+
})]
|
|
679
|
+
});
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
var useUpdateEditorContent = function useUpdateEditorContent(_ref) {
|
|
683
|
+
var editorRef = _ref.editorRef,
|
|
684
|
+
fieldName = _ref.fieldName,
|
|
685
|
+
value = _ref.value,
|
|
686
|
+
initialValue = _ref.initialValue,
|
|
687
|
+
fieldCode = _ref.fieldCode;
|
|
688
|
+
var initialStateRef = useRef({
|
|
689
|
+
language: "",
|
|
690
|
+
value: null
|
|
691
|
+
});
|
|
692
|
+
var _useBuildFormStore = useBuildFormStore(function (store) {
|
|
693
|
+
return {
|
|
694
|
+
setFormData: store["setFormData"]
|
|
695
|
+
};
|
|
696
|
+
}, shallow),
|
|
697
|
+
setFormData = _useBuildFormStore.setFormData;
|
|
698
|
+
var _useBuildFormStore2 = useBuildFormStore(function (store) {
|
|
699
|
+
var _store$formState, _store$formState2;
|
|
700
|
+
return {
|
|
701
|
+
formId: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["formId"],
|
|
702
|
+
selectedLanguage: (_store$formState2 = store["formState"]) === null || _store$formState2 === void 0 ? void 0 : _store$formState2["selectedLanguage"]
|
|
703
|
+
};
|
|
704
|
+
}, shallow),
|
|
705
|
+
formId = _useBuildFormStore2.formId,
|
|
706
|
+
language = _useBuildFormStore2.selectedLanguage;
|
|
707
|
+
var shouldReset = useBuildFormStore(function (store) {
|
|
708
|
+
return store.formState.richTextFieldsToReset.includes(fieldCode);
|
|
709
|
+
});
|
|
710
|
+
var setEditorContent = function setEditorContent(content) {
|
|
711
|
+
var _editorRef$current$ed;
|
|
712
|
+
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);
|
|
713
|
+
};
|
|
714
|
+
if (shouldReset) {
|
|
715
|
+
setEditorContent(initialValue);
|
|
716
|
+
setFormData(modify("richTextFieldsToReset", without([fieldCode])));
|
|
717
|
+
}
|
|
718
|
+
var _useFetchQuestions = useFetchQuestions({
|
|
719
|
+
formId: formId,
|
|
720
|
+
language: language
|
|
721
|
+
}),
|
|
722
|
+
data = _useFetchQuestions.data;
|
|
723
|
+
useEffect(function () {
|
|
724
|
+
if (!data) return;
|
|
725
|
+
var pathArray = fieldName.split(".").map(function (part) {
|
|
726
|
+
var parsedPart = parseInt(part);
|
|
727
|
+
return isNaN(parsedPart) ? part : parsedPart;
|
|
728
|
+
});
|
|
729
|
+
setEditorContent(path(pathArray, data));
|
|
730
|
+
}, [data]);
|
|
731
|
+
useEffect(function () {
|
|
732
|
+
if (initialStateRef.current["language"] !== language) {
|
|
733
|
+
initialStateRef.current["language"] = language;
|
|
734
|
+
initialStateRef.current["value"] = null;
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
if (initialStateRef.current["value"] === null && value !== null) {
|
|
738
|
+
setEditorContent(value);
|
|
739
|
+
initialStateRef.current["value"] = value;
|
|
740
|
+
}
|
|
741
|
+
}, [language, value]);
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
var Editor = function Editor() {
|
|
745
|
+
var editorRef = useRef({
|
|
746
|
+
editor: {}
|
|
747
|
+
});
|
|
748
|
+
var _useFormikContext = useFormikContext(),
|
|
749
|
+
fieldCode = _useFormikContext.values.fieldCode;
|
|
750
|
+
var fieldName = "label";
|
|
751
|
+
var _useField = useField({
|
|
752
|
+
name: fieldName,
|
|
753
|
+
validate: validateEditorContent(editorRef)
|
|
754
|
+
}),
|
|
755
|
+
_useField2 = _slicedToArray(_useField, 3),
|
|
756
|
+
value = _useField2[0].value,
|
|
757
|
+
_useField2$ = _useField2[1],
|
|
758
|
+
touched = _useField2$.touched,
|
|
759
|
+
error = _useField2$.error,
|
|
760
|
+
initialValue = _useField2$.initialValue,
|
|
761
|
+
_useField2$2 = _useField2[2],
|
|
762
|
+
setTouched = _useField2$2.setTouched,
|
|
763
|
+
setValue = _useField2$2.setValue;
|
|
764
|
+
useUpdateEditorContent({
|
|
765
|
+
editorRef: editorRef,
|
|
766
|
+
fieldName: fieldName,
|
|
767
|
+
value: value,
|
|
768
|
+
initialValue: initialValue,
|
|
769
|
+
fieldCode: fieldCode
|
|
770
|
+
});
|
|
771
|
+
return /*#__PURE__*/jsx("div", {
|
|
772
|
+
className: "w-full cursor-auto",
|
|
773
|
+
children: /*#__PURE__*/jsx(NeetoEditor, {
|
|
774
|
+
required: true,
|
|
775
|
+
error: touched ? error : "",
|
|
776
|
+
id: "editor",
|
|
777
|
+
initialValue: value,
|
|
778
|
+
name: fieldName,
|
|
779
|
+
ref: editorRef,
|
|
780
|
+
onBlur: function onBlur() {
|
|
781
|
+
return setTouched(true);
|
|
782
|
+
},
|
|
783
|
+
onChange: setValue
|
|
784
|
+
})
|
|
785
|
+
});
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
var RequiredSwitch = withT(function (_ref) {
|
|
789
|
+
var t = _ref.t;
|
|
790
|
+
return /*#__PURE__*/jsx("div", {
|
|
791
|
+
className: "w-full",
|
|
792
|
+
children: /*#__PURE__*/jsx(Switch, {
|
|
793
|
+
label: t("neetoForm.common.required"),
|
|
794
|
+
name: "isRequired"
|
|
795
|
+
})
|
|
796
|
+
});
|
|
797
|
+
});
|
|
798
|
+
|
|
799
|
+
var _excluded$7 = ["maxLength"];
|
|
800
|
+
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; }
|
|
801
|
+
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), !0).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; }
|
|
802
|
+
var InputWithMaxLength = function InputWithMaxLength(_ref) {
|
|
803
|
+
var maxLength = _ref.maxLength,
|
|
804
|
+
props = _objectWithoutProperties(_ref, _excluded$7);
|
|
805
|
+
var _useField = useField(props),
|
|
806
|
+
_useField2 = _slicedToArray(_useField, 3),
|
|
807
|
+
value = _useField2[0].value,
|
|
808
|
+
setValue = _useField2[2].setValue;
|
|
809
|
+
useEffect(function () {
|
|
810
|
+
if (value && value.length > maxLength) {
|
|
811
|
+
setValue(value.substring(0, maxLength));
|
|
812
|
+
}
|
|
813
|
+
}, [value, maxLength, setValue]);
|
|
814
|
+
var shouldShowMaxLength = value && value.length > maxLength - 10;
|
|
815
|
+
return /*#__PURE__*/jsx(Input, _objectSpread$c(_objectSpread$c({}, props), shouldShowMaxLength && {
|
|
816
|
+
maxLength: maxLength
|
|
817
|
+
}));
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
var FieldCode = withT(function (_ref) {
|
|
821
|
+
var helpDocUrl = _ref.helpDocUrl,
|
|
822
|
+
t = _ref.t;
|
|
823
|
+
return /*#__PURE__*/jsx(Accordion, {
|
|
824
|
+
className: "neeto-form-nano-advanced-properties-accordion",
|
|
825
|
+
"data-cy": "advanced-properties-card",
|
|
826
|
+
children: /*#__PURE__*/jsx(Accordion.Item, {
|
|
827
|
+
title: t("neetoForm.common.advancedProperties"),
|
|
828
|
+
children: /*#__PURE__*/jsx(InputWithMaxLength, {
|
|
829
|
+
required: true,
|
|
830
|
+
label: t("neetoForm.questions.common.questionFields.field.fieldCode"),
|
|
831
|
+
name: "fieldCode",
|
|
832
|
+
helpText: helpDocUrl && /*#__PURE__*/jsx(Trans, {
|
|
833
|
+
i18nKey: "neetoForm.questions.common.questionFields.field.fieldCodeHelpDescription",
|
|
834
|
+
components: {
|
|
835
|
+
Link: /*#__PURE__*/jsx(Button, {
|
|
836
|
+
className: "text-xs",
|
|
837
|
+
href: helpDocUrl,
|
|
838
|
+
style: "link",
|
|
839
|
+
target: "_blank"
|
|
840
|
+
})
|
|
841
|
+
}
|
|
842
|
+
})
|
|
843
|
+
})
|
|
844
|
+
})
|
|
845
|
+
});
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
var Form$1 = function Form(_ref) {
|
|
849
|
+
var questions = _ref.questions,
|
|
850
|
+
initialFocusRef = _ref.initialFocusRef,
|
|
851
|
+
isRequiredField = _ref.isRequiredField,
|
|
852
|
+
isDisabledFieldLabel = _ref.isDisabledFieldLabel,
|
|
853
|
+
enableFieldCode = _ref.enableFieldCode,
|
|
854
|
+
allQuestionKinds = _ref.allQuestionKinds,
|
|
855
|
+
availableQuestionKinds = _ref.availableQuestionKinds,
|
|
856
|
+
getActiveKindDetails = _ref.getActiveKindDetails,
|
|
857
|
+
additionalQuestionKindPattern = _ref.additionalQuestionKindPattern,
|
|
858
|
+
fieldCodeHelpDocUrl = _ref.fieldCodeHelpDocUrl,
|
|
859
|
+
enableDomainRestriction = _ref.enableDomainRestriction,
|
|
860
|
+
domainRestrictionHelpDocUrl = _ref.domainRestrictionHelpDocUrl,
|
|
861
|
+
_ref$isEdit = _ref.isEdit,
|
|
862
|
+
isEdit = _ref$isEdit === void 0 ? false : _ref$isEdit;
|
|
863
|
+
var _useTranslation = useTranslation(),
|
|
864
|
+
t = _useTranslation.t;
|
|
865
|
+
var _useFormikContext = useFormikContext(),
|
|
866
|
+
values = _useFormikContext.values,
|
|
867
|
+
setValues = _useFormikContext.setValues,
|
|
868
|
+
setErrors = _useFormikContext.setErrors,
|
|
869
|
+
setTouched = _useFormikContext.setTouched;
|
|
870
|
+
var kind = values.kind;
|
|
871
|
+
var questionKinds = isEdit ? allQuestionKinds : availableQuestionKinds;
|
|
872
|
+
var questionKindUniquenessPattern = mergeLeft(isEdit && additionalQuestionKindPattern ? additionalQuestionKindPattern(values) : {}, {
|
|
873
|
+
type: kind
|
|
874
|
+
});
|
|
875
|
+
var _useStateWithDependen = useStateWithDependency(getQuestionKind(questionKinds, questionKindUniquenessPattern), [kind]),
|
|
876
|
+
_useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 1),
|
|
877
|
+
questionKind = _useStateWithDependen2[0];
|
|
878
|
+
var _ref2 = questionKind ? getActiveKindDetails({
|
|
879
|
+
allQuestionKinds: allQuestionKinds,
|
|
880
|
+
item: questionKind
|
|
881
|
+
}) : {},
|
|
882
|
+
_ref2$questionProps = _ref2.questionProps,
|
|
883
|
+
questionProps = _ref2$questionProps === void 0 ? {} : _ref2$questionProps;
|
|
884
|
+
var isRequired = questionKind && isRequiredField(questionKind);
|
|
885
|
+
var isLabelDisabled = questionKind && isDisabledFieldLabel(questionKind);
|
|
886
|
+
var shouldShowPlaceholder = includes(kind, QUESTIONS_WITH_PLACEHOLDERS);
|
|
887
|
+
var hasAdditionalData = includes(kind, QUESTIONS_WITH_ADDITIONAL_DATA);
|
|
888
|
+
var shouldShowFieldCode = enableFieldCode && !includes(kind, QUESTIONS_WITHOUT_FIELD_CODE);
|
|
889
|
+
var shouldShowHideSwitch = !includes(kind, QUESTIONS_WITHOUT_FIELD_CODE);
|
|
890
|
+
var handleKindChange = function handleKindChange(option) {
|
|
891
|
+
var data = buildQuestionData(option);
|
|
892
|
+
updateFormState(data);
|
|
893
|
+
};
|
|
894
|
+
var buildQuestionData = function buildQuestionData(option) {
|
|
895
|
+
if (isNil(option)) {
|
|
896
|
+
return INITIAL_VALUES;
|
|
897
|
+
}
|
|
898
|
+
var label = option.label,
|
|
899
|
+
value = option.value;
|
|
900
|
+
var kind = extractKindFromOption(value);
|
|
901
|
+
var questionKind = getQuestionKind(availableQuestionKinds, {
|
|
902
|
+
type: kind,
|
|
903
|
+
label: label
|
|
904
|
+
});
|
|
905
|
+
return createFieldData({
|
|
906
|
+
kind: questionKind,
|
|
907
|
+
isRequired: isRequired,
|
|
908
|
+
questions: questions
|
|
909
|
+
});
|
|
910
|
+
};
|
|
911
|
+
var updateFormState = function updateFormState(data) {
|
|
912
|
+
setValues(data);
|
|
913
|
+
setErrors({});
|
|
914
|
+
setTouched({});
|
|
915
|
+
};
|
|
916
|
+
return /*#__PURE__*/jsx(Pane.Body, {
|
|
917
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
918
|
+
className: "w-full space-y-4",
|
|
919
|
+
children: [/*#__PURE__*/jsx(Select, {
|
|
920
|
+
isClearable: true,
|
|
921
|
+
isSearchable: true,
|
|
922
|
+
defaultValue: buildDefaultValueForKind(questionKind),
|
|
923
|
+
innerRef: initialFocusRef,
|
|
924
|
+
isDisabled: isEdit,
|
|
925
|
+
name: "kind",
|
|
926
|
+
options: buildKindOptions(questionKinds),
|
|
927
|
+
label: t("neetoForm.questions.common.questionFields.field.questionType"),
|
|
928
|
+
onChange: handleKindChange
|
|
929
|
+
}), isRichTextQuestion(kind) ? /*#__PURE__*/jsx(Editor, {
|
|
930
|
+
isLabelDisabled: isLabelDisabled
|
|
931
|
+
}) : /*#__PURE__*/jsxs("div", {
|
|
932
|
+
className: "space-y-6",
|
|
933
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
934
|
+
className: "space-y-4",
|
|
935
|
+
children: [/*#__PURE__*/jsx(FormikAdaptiveInput, {
|
|
936
|
+
required: true,
|
|
937
|
+
disabled: isLabelDisabled,
|
|
938
|
+
name: "label",
|
|
939
|
+
placeholder: DEFAULT_PLACEHOLDERS[kind],
|
|
940
|
+
label: t("neetoForm.questions.common.questionFields.field.question")
|
|
941
|
+
}), shouldShowPlaceholder && /*#__PURE__*/jsx(FormikAdaptiveInput, {
|
|
942
|
+
name: "placeholder",
|
|
943
|
+
label: t("neetoForm.questions.common.questionFields.field.placeholder")
|
|
944
|
+
}), hasAdditionalData && renderAdditionalData({
|
|
945
|
+
kind: kind,
|
|
946
|
+
questionProps: questionProps,
|
|
947
|
+
domainRestrictionHelpDocUrl: domainRestrictionHelpDocUrl,
|
|
948
|
+
enableDomainRestriction: enableDomainRestriction
|
|
949
|
+
})]
|
|
950
|
+
}), !isRequired && /*#__PURE__*/jsxs(Block, {
|
|
951
|
+
dataCy: "settings-card",
|
|
952
|
+
title: t("neetoForm.common.settings"),
|
|
953
|
+
children: [/*#__PURE__*/jsx(RequiredSwitch, {}), shouldShowHideSwitch && /*#__PURE__*/jsx(Switch, {
|
|
954
|
+
label: t("neetoForm.common.hideQuestion"),
|
|
955
|
+
name: "isHidden"
|
|
956
|
+
})]
|
|
957
|
+
}), shouldShowFieldCode && /*#__PURE__*/jsx(FieldCode, {
|
|
958
|
+
helpDocUrl: fieldCodeHelpDocUrl
|
|
959
|
+
})]
|
|
960
|
+
})]
|
|
961
|
+
})
|
|
962
|
+
});
|
|
963
|
+
};
|
|
964
|
+
|
|
965
|
+
/* eslint-disable @bigbinary/neeto/file-name-and-export-name-standards */
|
|
966
|
+
var requiredLabelValidation = function requiredLabelValidation(schema, field) {
|
|
967
|
+
return schema.trim().required(t("neetoForm.common.fieldReq", {
|
|
968
|
+
field: field
|
|
969
|
+
}));
|
|
970
|
+
};
|
|
971
|
+
var richTextFieldMissingErrorMessage = function richTextFieldMissingErrorMessage(kind) {
|
|
972
|
+
var field = equals(kind, QUESTION_TYPES.PARAGRAPH) ? t("neetoForm.fields.def") : t("neetoForm.fields.tcf");
|
|
973
|
+
return t("neetoForm.error.fieldCantBeEmpty", {
|
|
974
|
+
field: field
|
|
975
|
+
});
|
|
976
|
+
};
|
|
977
|
+
var formValidationSchema = yup.object().shape({
|
|
978
|
+
kind: yup.string().trim().required(t("neetoForm.common.fieldReq", {
|
|
979
|
+
field: t("neetoForm.questions.common.questionFields.field.questionType")
|
|
980
|
+
})),
|
|
981
|
+
label: yup.string().when("kind", function (kind, schema) {
|
|
982
|
+
return includes(kind, RICH_TEXT_QUESTIONS) ? schema.test("required", richTextFieldMissingErrorMessage(kind), function (value) {
|
|
983
|
+
return !isEditorEmpty(value);
|
|
984
|
+
}) : requiredLabelValidation(schema, t("neetoForm.questions.common.questionFields.field.question"));
|
|
985
|
+
}),
|
|
986
|
+
fieldCode: yup.string().trim().notOneOf(RESERVED_FIELD_CODES, t("neetoForm.error.invalidFieldCode")).when("kind", function (kind, schema) {
|
|
987
|
+
return includes(kind, QUESTIONS_WITHOUT_FIELD_CODE) ? schema.notRequired() : requiredLabelValidation(schema, t("neetoForm.questions.common.questionFields.field.fieldCode"));
|
|
988
|
+
}),
|
|
989
|
+
optionsAttributes: yup.array().when("_destroy", {
|
|
990
|
+
is: true,
|
|
991
|
+
otherwise: function otherwise(schema) {
|
|
992
|
+
return schema.when("kind", function (kind, schema) {
|
|
993
|
+
return includes(kind, SELECTABLE_KINDS) ? schema.of(yup.object().shape({
|
|
994
|
+
label: requiredLabelValidation(yup.string(), t("neetoForm.questions.common.questionFields.field.option"))
|
|
995
|
+
})) : schema.notRequired();
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
}),
|
|
999
|
+
highestRatingLabel: yup.string().nullable(),
|
|
1000
|
+
averageRatingLabel: yup.string().nullable(),
|
|
1001
|
+
lowestRatingLabel: yup.string().nullable()
|
|
1002
|
+
});
|
|
1003
|
+
|
|
1004
|
+
var _excluded$6 = ["question", "onClose", "questions", "handleSelect", "buildRequestArgs", "isOpen", "fieldCodeHelpDocUrl", "domainRestrictionHelpDocUrl"];
|
|
1005
|
+
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; }
|
|
1006
|
+
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), !0).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; }
|
|
1007
|
+
var Add = function Add(_ref) {
|
|
1008
|
+
var question = _ref.question,
|
|
1009
|
+
onClose = _ref.onClose,
|
|
1010
|
+
questions = _ref.questions,
|
|
1011
|
+
handleSelect = _ref.handleSelect,
|
|
1012
|
+
buildRequestArgs = _ref.buildRequestArgs,
|
|
1013
|
+
isOpen = _ref.isOpen,
|
|
1014
|
+
fieldCodeHelpDocUrl = _ref.fieldCodeHelpDocUrl,
|
|
1015
|
+
domainRestrictionHelpDocUrl = _ref.domainRestrictionHelpDocUrl,
|
|
1016
|
+
props = _objectWithoutProperties(_ref, _excluded$6);
|
|
1017
|
+
var _useBuildFormStore = useBuildFormStore(function (store) {
|
|
1018
|
+
var _store$formState, _store$formState2;
|
|
1019
|
+
return {
|
|
1020
|
+
formId: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["formId"],
|
|
1021
|
+
selectedLanguage: (_store$formState2 = store["formState"]) === null || _store$formState2 === void 0 ? void 0 : _store$formState2["selectedLanguage"]
|
|
1022
|
+
};
|
|
1023
|
+
}, shallow),
|
|
1024
|
+
formId = _useBuildFormStore.formId,
|
|
1025
|
+
language = _useBuildFormStore.selectedLanguage;
|
|
1026
|
+
var _useTranslation = useTranslation(),
|
|
1027
|
+
t = _useTranslation.t;
|
|
1028
|
+
var _useCreateQuestion = useCreateQuestion(formId, language, {
|
|
1029
|
+
onSuccess: function onSuccess() {
|
|
1030
|
+
showThumbsUpToastr();
|
|
1031
|
+
onClose();
|
|
1032
|
+
}
|
|
1033
|
+
}),
|
|
1034
|
+
createQuestion = _useCreateQuestion.mutate,
|
|
1035
|
+
isCreating = _useCreateQuestion.isPending;
|
|
1036
|
+
var handleSubmit = function handleSubmit(values) {
|
|
1037
|
+
if (isCreating || !isOpen) return;
|
|
1038
|
+
var displayOrder = question ? question.displayOrder + 1 : questions.length;
|
|
1039
|
+
createQuestion(_objectSpread$b({
|
|
1040
|
+
language: language,
|
|
1041
|
+
neetoFormQuestion: mergeLeft({
|
|
1042
|
+
displayOrder: displayOrder
|
|
1043
|
+
}, values)
|
|
1044
|
+
}, buildRequestArgs), {
|
|
1045
|
+
onSuccess: function onSuccess(_ref2) {
|
|
1046
|
+
var questions = _ref2.questions;
|
|
1047
|
+
var newQuestion = findBy({
|
|
1048
|
+
displayOrder: displayOrder
|
|
1049
|
+
}, questions);
|
|
1050
|
+
handleSelect(newQuestion);
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
};
|
|
1054
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
1055
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
1056
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
1057
|
+
"data-cy": "add-question-pane-header",
|
|
1058
|
+
style: "h2",
|
|
1059
|
+
children: t("neetoForm.questions.common.primaryPanel.addQuestion")
|
|
1060
|
+
})
|
|
1061
|
+
}), /*#__PURE__*/jsx(Form$2, {
|
|
1062
|
+
formikProps: {
|
|
1063
|
+
initialValues: INITIAL_VALUES,
|
|
1064
|
+
validationSchema: formValidationSchema,
|
|
1065
|
+
onSubmit: handleSubmit
|
|
1066
|
+
},
|
|
1067
|
+
children: /*#__PURE__*/jsxs(Fragment, {
|
|
1068
|
+
children: [/*#__PURE__*/jsx(Form$1, _objectSpread$b({}, _objectSpread$b(_objectSpread$b({}, props), {}, {
|
|
1069
|
+
domainRestrictionHelpDocUrl: domainRestrictionHelpDocUrl,
|
|
1070
|
+
fieldCodeHelpDocUrl: fieldCodeHelpDocUrl,
|
|
1071
|
+
question: question,
|
|
1072
|
+
questions: questions
|
|
1073
|
+
}))), /*#__PURE__*/jsx(Pane.Footer, {
|
|
1074
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
1075
|
+
cancelButtonProps: {
|
|
1076
|
+
onClick: onClose
|
|
1077
|
+
},
|
|
1078
|
+
isSubmitting: isCreating
|
|
1079
|
+
})
|
|
1080
|
+
})]
|
|
1081
|
+
})
|
|
1082
|
+
})]
|
|
1083
|
+
});
|
|
1084
|
+
};
|
|
1085
|
+
|
|
1086
|
+
var _excluded$5 = ["question", "isOpen", "onClose", "fieldCodeHelpDocUrl", "domainRestrictionHelpDocUrl"];
|
|
1087
|
+
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; }
|
|
1088
|
+
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), !0).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; }
|
|
1089
|
+
var Edit = function Edit(_ref) {
|
|
1090
|
+
var question = _ref.question,
|
|
1091
|
+
isOpen = _ref.isOpen,
|
|
1092
|
+
onClose = _ref.onClose,
|
|
1093
|
+
fieldCodeHelpDocUrl = _ref.fieldCodeHelpDocUrl,
|
|
1094
|
+
domainRestrictionHelpDocUrl = _ref.domainRestrictionHelpDocUrl,
|
|
1095
|
+
props = _objectWithoutProperties(_ref, _excluded$5);
|
|
1096
|
+
var _useTranslation = useTranslation(),
|
|
1097
|
+
t = _useTranslation.t;
|
|
1098
|
+
var _useBuildFormStore = useBuildFormStore(function (store) {
|
|
1099
|
+
var _store$formState;
|
|
1100
|
+
return {
|
|
1101
|
+
selectedLanguage: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["selectedLanguage"]
|
|
1102
|
+
};
|
|
1103
|
+
}, shallow),
|
|
1104
|
+
language = _useBuildFormStore.selectedLanguage;
|
|
1105
|
+
var _useUpdateQuestion = useUpdateQuestion(question === null || question === void 0 ? void 0 : question.formId, language),
|
|
1106
|
+
updateQuestion = _useUpdateQuestion.mutate,
|
|
1107
|
+
isUpdating = _useUpdateQuestion.isPending;
|
|
1108
|
+
var handleSubmit = function handleSubmit(values, _ref2) {
|
|
1109
|
+
var setSubmitting = _ref2.setSubmitting;
|
|
1110
|
+
if (isUpdating || !isOpen) return;
|
|
1111
|
+
var payload = {
|
|
1112
|
+
language: language,
|
|
1113
|
+
neetoFormQuestion: values
|
|
1114
|
+
};
|
|
1115
|
+
updateQuestion({
|
|
1116
|
+
questionId: question.id,
|
|
1117
|
+
payload: payload
|
|
1118
|
+
}, {
|
|
1119
|
+
onSuccess: function onSuccess() {
|
|
1120
|
+
showThumbsUpToastr();
|
|
1121
|
+
onClose();
|
|
1122
|
+
},
|
|
1123
|
+
onSettled: function onSettled() {
|
|
1124
|
+
return setSubmitting(false);
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
};
|
|
1128
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
1129
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
1130
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
1131
|
+
"data-cy": "edit-question-pane-header",
|
|
1132
|
+
style: "h2",
|
|
1133
|
+
children: t("neetoForm.questions.common.editQuestion")
|
|
1134
|
+
})
|
|
1135
|
+
}), /*#__PURE__*/jsx(Form$2, {
|
|
1136
|
+
formikProps: {
|
|
1137
|
+
initialValues: question,
|
|
1138
|
+
validationSchema: formValidationSchema,
|
|
1139
|
+
onSubmit: handleSubmit
|
|
1140
|
+
},
|
|
1141
|
+
children: /*#__PURE__*/jsxs(Fragment, {
|
|
1142
|
+
children: [/*#__PURE__*/jsx(Form$1, _objectSpread$a(_objectSpread$a({}, _objectSpread$a({
|
|
1143
|
+
domainRestrictionHelpDocUrl: domainRestrictionHelpDocUrl,
|
|
1144
|
+
fieldCodeHelpDocUrl: fieldCodeHelpDocUrl,
|
|
1145
|
+
question: question
|
|
1146
|
+
}, props)), {}, {
|
|
1147
|
+
isEdit: true
|
|
1148
|
+
})), /*#__PURE__*/jsx(Pane.Footer, {
|
|
1149
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
1150
|
+
cancelButtonProps: {
|
|
1151
|
+
onClick: onClose
|
|
1152
|
+
},
|
|
1153
|
+
isSubmitting: isUpdating
|
|
1154
|
+
})
|
|
1155
|
+
})]
|
|
1156
|
+
})
|
|
1157
|
+
})]
|
|
1158
|
+
});
|
|
1159
|
+
};
|
|
1160
|
+
|
|
1161
|
+
var Captcha = withT(function (_ref) {
|
|
1162
|
+
var t = _ref.t;
|
|
1163
|
+
return /*#__PURE__*/jsxs(Radio, {
|
|
1164
|
+
label: t("neetoForm.common.captchaType"),
|
|
1165
|
+
labelProps: {
|
|
1166
|
+
required: true
|
|
1167
|
+
},
|
|
1168
|
+
name: "variant",
|
|
1169
|
+
children: [/*#__PURE__*/jsx(Radio.Item, {
|
|
1170
|
+
label: t("neetoForm.common.reCaptchaV2"),
|
|
1171
|
+
value: CAPTCHA_TYPES.RECAPTCHA_V2
|
|
1172
|
+
}), /*#__PURE__*/jsx(Radio.Item, {
|
|
1173
|
+
label: t("neetoForm.common.mathCaptcha"),
|
|
1174
|
+
value: CAPTCHA_TYPES.MATH_CAPTCHA
|
|
1175
|
+
})]
|
|
1176
|
+
});
|
|
1177
|
+
});
|
|
1178
|
+
|
|
1179
|
+
var _excluded$4 = ["name", "title", "className"];
|
|
1180
|
+
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; }
|
|
1181
|
+
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), !0).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; }
|
|
1182
|
+
var SwitchBlock = function SwitchBlock(_ref) {
|
|
1183
|
+
var name = _ref.name,
|
|
1184
|
+
title = _ref.title,
|
|
1185
|
+
_ref$className = _ref.className,
|
|
1186
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
1187
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$4);
|
|
1188
|
+
return /*#__PURE__*/jsxs(Label, {
|
|
1189
|
+
className: classnames("flex items-center justify-start gap-2 ", className),
|
|
1190
|
+
"data-cy": "neeto-form-engine-".concat(hyphenate(title), "-toggle-label"),
|
|
1191
|
+
children: [/*#__PURE__*/jsx(Switch, _objectSpread$9(_objectSpread$9({}, _objectSpread$9(_objectSpread$9({}, otherProps), {}, {
|
|
1192
|
+
name: name
|
|
1193
|
+
})), {}, {
|
|
1194
|
+
"data-cy": "neeto-form-engine-".concat(hyphenate(title), "-switch")
|
|
1195
|
+
})), /*#__PURE__*/jsx(Typography, {
|
|
1196
|
+
component: "span",
|
|
1197
|
+
style: "body1",
|
|
1198
|
+
children: title
|
|
1199
|
+
})]
|
|
1200
|
+
});
|
|
1201
|
+
};
|
|
1202
|
+
|
|
1203
|
+
var _excluded$3 = ["children"];
|
|
1204
|
+
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; }
|
|
1205
|
+
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), !0).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; }
|
|
1206
|
+
var STYLES = {
|
|
1207
|
+
border: {
|
|
1208
|
+
"default": "1px solid rgb(var(--neeto-ui-gray-400))",
|
|
1209
|
+
error: "1px solid rgb(var(--neeto-ui-error-800)) !important"
|
|
1210
|
+
},
|
|
1211
|
+
color: {
|
|
1212
|
+
"default": "rgb(var(--neeto-ui-gray-800))",
|
|
1213
|
+
error: "rgb(var(--neeto-ui-error-800)) !important"
|
|
1214
|
+
}
|
|
1215
|
+
};
|
|
1216
|
+
var MultiValueRemove = function MultiValueRemove(props) {
|
|
1217
|
+
return /*#__PURE__*/jsx(components.MultiValueRemove, _objectSpread$8(_objectSpread$8({}, props), {}, {
|
|
1218
|
+
innerProps: _objectSpread$8(_objectSpread$8({}, props.innerProps), {}, _defineProperty({}, "data-cy", "".concat(hyphenize(props.data.label), "-remove-icon"))),
|
|
1219
|
+
children: /*#__PURE__*/jsx(Close, {
|
|
1220
|
+
size: 16
|
|
1221
|
+
})
|
|
1222
|
+
}));
|
|
1223
|
+
};
|
|
1224
|
+
var ValueContainer = function ValueContainer(_ref) {
|
|
1225
|
+
var children = _ref.children,
|
|
1226
|
+
props = _objectWithoutProperties(_ref, _excluded$3);
|
|
1227
|
+
var _useTranslation = useTranslation(),
|
|
1228
|
+
t = _useTranslation.t;
|
|
1229
|
+
var getValue = props.getValue,
|
|
1230
|
+
_props$selectProps = props.selectProps,
|
|
1231
|
+
isFocused = _props$selectProps.isFocused,
|
|
1232
|
+
visibleDomainsCount = _props$selectProps.visibleDomainsCount;
|
|
1233
|
+
var value = getValue();
|
|
1234
|
+
var _children = _toArray(children),
|
|
1235
|
+
firstChild = _children[0],
|
|
1236
|
+
rest = _children.slice(1);
|
|
1237
|
+
var shouldCollapse = !isFocused && value.length > visibleDomainsCount;
|
|
1238
|
+
return /*#__PURE__*/jsxs(components.ValueContainer, _objectSpread$8(_objectSpread$8({}, props), {}, {
|
|
1239
|
+
innerProps: _objectSpread$8(_objectSpread$8({}, props.innerProps), {}, _defineProperty({}, "data-cy", "multi-domain-input-container")),
|
|
1240
|
+
children: [shouldCollapse ? firstChild.slice(0, visibleDomainsCount) : firstChild, shouldCollapse && /*#__PURE__*/jsx(Tag, {
|
|
1241
|
+
style: "secondary",
|
|
1242
|
+
label: t("neetoForm.common.remainingItemsCount", {
|
|
1243
|
+
count: value.length - visibleDomainsCount
|
|
1244
|
+
})
|
|
1245
|
+
}), rest]
|
|
1246
|
+
}));
|
|
1247
|
+
};
|
|
1248
|
+
var ClearIndicator = function ClearIndicator(props) {
|
|
1249
|
+
return /*#__PURE__*/jsx(components.ClearIndicator, _objectSpread$8(_objectSpread$8({}, props), {}, {
|
|
1250
|
+
innerProps: _objectSpread$8(_objectSpread$8({}, props.innerProps), {}, _defineProperty({}, "data-cy", "clear-all-button")),
|
|
1251
|
+
children: /*#__PURE__*/jsx(Close, {
|
|
1252
|
+
className: "cursor-pointer",
|
|
1253
|
+
size: 16
|
|
1254
|
+
})
|
|
1255
|
+
}));
|
|
1256
|
+
};
|
|
1257
|
+
var ERROR_MESSAGE_DELIMITER = ". ";
|
|
1258
|
+
var DELIMITER_KEYS = ["Enter", "Tab", ",", " "];
|
|
1259
|
+
var DOMAIN_SEPARATION_REGEX = /[^\s,]+/g;
|
|
1260
|
+
var FLEXIBLE_DOMAIN_REGEX = /^[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/;
|
|
1261
|
+
var VALID_DOMAIN_REGEX = /^(?:[a-zA-Z0-9-]{1,63}\.)+[a-zA-Z0-9-]{2,63}$/;
|
|
1262
|
+
var DOMAIN_VALIDATION_SCHEMA = yup.string().required(t("neetoForm.error.requiredField", {
|
|
1263
|
+
label: t("neetoForm.common.domain")
|
|
1264
|
+
})).test("verify domains", t("neetoForm.error.invalidDomain"), function (domain) {
|
|
1265
|
+
return VALID_DOMAIN_REGEX.test(domain);
|
|
1266
|
+
});
|
|
1267
|
+
var CUSTOM_STYLES = {
|
|
1268
|
+
input: assoc("overflow", "hidden"),
|
|
1269
|
+
multiValue: function multiValue(styles, _ref2) {
|
|
1270
|
+
var valid = _ref2.data.valid;
|
|
1271
|
+
return _objectSpread$8(_objectSpread$8({}, styles), {}, {
|
|
1272
|
+
border: valid ? STYLES.border["default"] : STYLES.border.error,
|
|
1273
|
+
color: valid ? STYLES.color["default"] : STYLES.color.error
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
var CUSTOM_COMPONENTS = {
|
|
1278
|
+
DropdownIndicator: null,
|
|
1279
|
+
MultiValueRemove: MultiValueRemove,
|
|
1280
|
+
ValueContainer: ValueContainer,
|
|
1281
|
+
ClearIndicator: ClearIndicator
|
|
1282
|
+
};
|
|
1283
|
+
|
|
1284
|
+
var removeDuplicateErrorMessages = pipe(filter(isNotNil), uniq, join(ERROR_MESSAGE_DELIMITER));
|
|
1285
|
+
var formatDomainInputOptions = function formatDomainInputOptions(domain) {
|
|
1286
|
+
var isValid;
|
|
1287
|
+
try {
|
|
1288
|
+
DOMAIN_VALIDATION_SCHEMA.validateSync(domain);
|
|
1289
|
+
isValid = true;
|
|
1290
|
+
} catch (_unused) {
|
|
1291
|
+
isValid = false;
|
|
1292
|
+
}
|
|
1293
|
+
return {
|
|
1294
|
+
label: domain,
|
|
1295
|
+
value: domain,
|
|
1296
|
+
valid: isValid
|
|
1297
|
+
};
|
|
1298
|
+
};
|
|
1299
|
+
var pruneDuplicates = pipe(pluck("value"), uniq, map(formatDomainInputOptions));
|
|
1300
|
+
var getValidDomains = function getValidDomains(domains) {
|
|
1301
|
+
return domains.filter(function (domain) {
|
|
1302
|
+
return domain === null || domain === void 0 ? void 0 : domain.valid;
|
|
1303
|
+
});
|
|
1304
|
+
};
|
|
1305
|
+
var getValidDomainsCount = function getValidDomainsCount(domains) {
|
|
1306
|
+
return getValidDomains(domains).length;
|
|
1307
|
+
};
|
|
1308
|
+
var formatErrorMessage = function formatErrorMessage(error) {
|
|
1309
|
+
if (typeof error === "string") return error;
|
|
1310
|
+
return removeDuplicateErrorMessages(error);
|
|
1311
|
+
};
|
|
1312
|
+
|
|
1313
|
+
var _excluded$2 = ["label", "value", "onChange", "error", "onBlur"];
|
|
1314
|
+
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; }
|
|
1315
|
+
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), !0).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; }
|
|
1316
|
+
var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
1317
|
+
var _ref$label = _ref.label,
|
|
1318
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
1319
|
+
_ref$value = _ref.value,
|
|
1320
|
+
value = _ref$value === void 0 ? [] : _ref$value,
|
|
1321
|
+
_ref$onChange = _ref.onChange,
|
|
1322
|
+
onChange = _ref$onChange === void 0 ? noop : _ref$onChange,
|
|
1323
|
+
_ref$error = _ref.error,
|
|
1324
|
+
error = _ref$error === void 0 ? "" : _ref$error,
|
|
1325
|
+
_ref$onBlur = _ref.onBlur,
|
|
1326
|
+
onBlur = _ref$onBlur === void 0 ? noop : _ref$onBlur,
|
|
1327
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$2);
|
|
1328
|
+
var _useState = useState(""),
|
|
1329
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1330
|
+
inputValue = _useState2[0],
|
|
1331
|
+
setInputValue = _useState2[1];
|
|
1332
|
+
var _useState3 = useState(false),
|
|
1333
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1334
|
+
isFocused = _useState4[0],
|
|
1335
|
+
setIsFocused = _useState4[1];
|
|
1336
|
+
var _useTranslation = useTranslation(),
|
|
1337
|
+
t = _useTranslation.t;
|
|
1338
|
+
var handleFilterDomains = function handleFilterDomains() {
|
|
1339
|
+
return onChange(getValidDomains(value));
|
|
1340
|
+
};
|
|
1341
|
+
var handleDomainChange = function handleDomainChange() {
|
|
1342
|
+
var inputValues = inputValue.match(DOMAIN_SEPARATION_REGEX) || [];
|
|
1343
|
+
var domainMatches = filter(test(FLEXIBLE_DOMAIN_REGEX), inputValues);
|
|
1344
|
+
var domains = domainMatches.map(formatDomainInputOptions);
|
|
1345
|
+
onChange(pruneDuplicates([].concat(_toConsumableArray(value), _toConsumableArray(domains))));
|
|
1346
|
+
setInputValue("");
|
|
1347
|
+
};
|
|
1348
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
1349
|
+
if (!inputValue) return;
|
|
1350
|
+
if (includes(event.key, DELIMITER_KEYS)) {
|
|
1351
|
+
handleDomainChange();
|
|
1352
|
+
event.preventDefault();
|
|
1353
|
+
event.stopPropagation();
|
|
1354
|
+
}
|
|
1355
|
+
};
|
|
1356
|
+
var onCreateOption = function onCreateOption(input) {
|
|
1357
|
+
var domain = formatDomainInputOptions(input);
|
|
1358
|
+
onChange(pruneDuplicates([].concat(_toConsumableArray(value), [domain])));
|
|
1359
|
+
};
|
|
1360
|
+
var handleBlur = function handleBlur(event) {
|
|
1361
|
+
inputValue ? handleDomainChange() : onBlur(event);
|
|
1362
|
+
setIsFocused(false);
|
|
1363
|
+
};
|
|
1364
|
+
var isFilterDomainsLinkVisible = value.length > getValidDomainsCount(value);
|
|
1365
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1366
|
+
className: "neeto-ui-input__wrapper neeto-ui-email-input__wrapper",
|
|
1367
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
1368
|
+
className: "neeto-ui-email-input__label-wrapper",
|
|
1369
|
+
children: /*#__PURE__*/jsx(Label, {
|
|
1370
|
+
className: "neeto-ui-email-input__label",
|
|
1371
|
+
"data-cy": "".concat(hyphenize(label), "-input-label"),
|
|
1372
|
+
children: label
|
|
1373
|
+
})
|
|
1374
|
+
}), /*#__PURE__*/jsx(CreatableSelect, _objectSpread$7({
|
|
1375
|
+
isMulti: true,
|
|
1376
|
+
required: true,
|
|
1377
|
+
classNamePrefix: "neeto-ui-react-select",
|
|
1378
|
+
components: CUSTOM_COMPONENTS,
|
|
1379
|
+
menuIsOpen: false,
|
|
1380
|
+
visibleDomainsCount: 3,
|
|
1381
|
+
className: classnames("neeto-ui-react-select__container neeto-ui-react-select__container--medium neeto-ui-email-input__select", {
|
|
1382
|
+
"neeto-ui-react-select__container--error": !!error
|
|
1383
|
+
}),
|
|
1384
|
+
styles: _objectSpread$7(_objectSpread$7({}, CUSTOM_STYLES), {}, {
|
|
1385
|
+
control: mergeLeft({
|
|
1386
|
+
maxHeight: "200px",
|
|
1387
|
+
overflowY: "auto"
|
|
1388
|
+
})
|
|
1389
|
+
}),
|
|
1390
|
+
onBlur: handleBlur,
|
|
1391
|
+
onFocus: function onFocus() {
|
|
1392
|
+
return setIsFocused(true);
|
|
1393
|
+
},
|
|
1394
|
+
onInputChange: setInputValue,
|
|
1395
|
+
onKeyDown: handleKeyDown
|
|
1396
|
+
}, _objectSpread$7({
|
|
1397
|
+
inputValue: inputValue,
|
|
1398
|
+
isFocused: isFocused,
|
|
1399
|
+
onChange: onChange,
|
|
1400
|
+
onCreateOption: onCreateOption,
|
|
1401
|
+
value: value
|
|
1402
|
+
}, otherProps))), !!error && /*#__PURE__*/jsxs("p", {
|
|
1403
|
+
className: "neeto-ui-input__error",
|
|
1404
|
+
"data-cy": "".concat(hyphenize(label), "-input-error"),
|
|
1405
|
+
children: [formatErrorMessage(error), isFilterDomainsLinkVisible && /*#__PURE__*/jsxs("span", {
|
|
1406
|
+
className: "neeto-ui-font-semibold cursor-pointer",
|
|
1407
|
+
onClick: handleFilterDomains,
|
|
1408
|
+
children: [ERROR_MESSAGE_DELIMITER, t("neetoForm.domainRestriction.removeInvalidDomains")]
|
|
1409
|
+
})]
|
|
1410
|
+
}), /*#__PURE__*/jsx("p", {
|
|
1411
|
+
className: "neeto-ui-input__help-text",
|
|
1412
|
+
"data-cy": "".concat(hyphenize(label), "-input-help"),
|
|
1413
|
+
children: t("neetoForm.domainRestriction.helpText")
|
|
1414
|
+
})]
|
|
1415
|
+
});
|
|
1416
|
+
};
|
|
1417
|
+
|
|
1418
|
+
var validateDomains = function validateDomains(value) {
|
|
1419
|
+
var schema = yup.array().of(yup.string().test("verify domains", t("neetoForm.error.invalidDomain"), function (domain) {
|
|
1420
|
+
return VALID_DOMAIN_REGEX.test(domain);
|
|
1421
|
+
})).ensure().compact().min(1, t("neetoForm.error.minOneEntity", {
|
|
1422
|
+
entity: t("neetoForm.common.domain")
|
|
1423
|
+
}));
|
|
1424
|
+
|
|
1425
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
1426
|
+
return new Promise( /*#__PURE__*/function () {
|
|
1427
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve) {
|
|
1428
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1429
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1430
|
+
case 0:
|
|
1431
|
+
_context.prev = 0;
|
|
1432
|
+
_context.next = 3;
|
|
1433
|
+
return schema.validate(value);
|
|
1434
|
+
case 3:
|
|
1435
|
+
resolve(undefined);
|
|
1436
|
+
_context.next = 9;
|
|
1437
|
+
break;
|
|
1438
|
+
case 6:
|
|
1439
|
+
_context.prev = 6;
|
|
1440
|
+
_context.t0 = _context["catch"](0);
|
|
1441
|
+
resolve(_context.t0.message);
|
|
1442
|
+
case 9:
|
|
1443
|
+
case "end":
|
|
1444
|
+
return _context.stop();
|
|
1445
|
+
}
|
|
1446
|
+
}, _callee, null, [[0, 6]]);
|
|
1447
|
+
}));
|
|
1448
|
+
return function (_x) {
|
|
1449
|
+
return _ref.apply(this, arguments);
|
|
1450
|
+
};
|
|
1451
|
+
}());
|
|
1452
|
+
};
|
|
1453
|
+
|
|
1454
|
+
var RestrictedDomains = function RestrictedDomains() {
|
|
1455
|
+
var _useField = useField({
|
|
1456
|
+
name: "restrictedDomains",
|
|
1457
|
+
validate: validateDomains
|
|
1458
|
+
}),
|
|
1459
|
+
_useField2 = _slicedToArray(_useField, 3),
|
|
1460
|
+
_useField2$0$value = _useField2[0].value,
|
|
1461
|
+
domains = _useField2$0$value === void 0 ? [] : _useField2$0$value,
|
|
1462
|
+
meta = _useField2[1],
|
|
1463
|
+
_useField2$ = _useField2[2],
|
|
1464
|
+
setValue = _useField2$.setValue,
|
|
1465
|
+
setTouched = _useField2$.setTouched;
|
|
1466
|
+
var _useTranslation = useTranslation(),
|
|
1467
|
+
t = _useTranslation.t;
|
|
1468
|
+
var formattedDomains = map(formatDomainInputOptions, domains);
|
|
1469
|
+
return /*#__PURE__*/jsx("div", {
|
|
1470
|
+
className: "mb-4",
|
|
1471
|
+
children: /*#__PURE__*/jsx(MultiDomainInput, {
|
|
1472
|
+
error: meta.touched ? meta.error : "",
|
|
1473
|
+
label: t("neetoForm.domainRestriction.description"),
|
|
1474
|
+
name: "restrictedDomains",
|
|
1475
|
+
value: formattedDomains,
|
|
1476
|
+
onBlur: function onBlur() {
|
|
1477
|
+
return setTouched(true);
|
|
1478
|
+
},
|
|
1479
|
+
onChange: function onChange(value) {
|
|
1480
|
+
return setValue(nullSafe(pluck)("value", value));
|
|
1481
|
+
}
|
|
1482
|
+
})
|
|
1483
|
+
});
|
|
1484
|
+
};
|
|
1485
|
+
|
|
1486
|
+
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; }
|
|
1487
|
+
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), !0).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; }
|
|
1488
|
+
var Email = function Email(_ref) {
|
|
1489
|
+
var _ref$domainRestrictio = _ref.domainRestrictionHelpDocUrl,
|
|
1490
|
+
domainRestrictionHelpDocUrl = _ref$domainRestrictio === void 0 ? "" : _ref$domainRestrictio;
|
|
1491
|
+
var _useFormikContext = useFormikContext(),
|
|
1492
|
+
_useFormikContext$val = _useFormikContext.values.isDomainRestrictionEnabled,
|
|
1493
|
+
isDomainRestrictionEnabled = _useFormikContext$val === void 0 ? false : _useFormikContext$val;
|
|
1494
|
+
var _useTranslation = useTranslation(),
|
|
1495
|
+
t = _useTranslation.t;
|
|
1496
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1497
|
+
className: "flex flex-col space-y-4",
|
|
1498
|
+
children: [/*#__PURE__*/jsx(SwitchBlock, {
|
|
1499
|
+
className: "mt-4",
|
|
1500
|
+
name: "isDomainRestrictionEnabled",
|
|
1501
|
+
title: /*#__PURE__*/jsxs("div", {
|
|
1502
|
+
className: "flex gap-2",
|
|
1503
|
+
children: [t("neetoForm.domainRestriction.label"), /*#__PURE__*/jsx(HelpPopover, _objectSpread$6({
|
|
1504
|
+
description: t("neetoForm.domainRestriction.popoverDescription"),
|
|
1505
|
+
popoverProps: {
|
|
1506
|
+
position: "top"
|
|
1507
|
+
}
|
|
1508
|
+
}, domainRestrictionHelpDocUrl && {
|
|
1509
|
+
helpLinkProps: {
|
|
1510
|
+
href: domainRestrictionHelpDocUrl
|
|
1511
|
+
}
|
|
1512
|
+
}))]
|
|
1513
|
+
})
|
|
1514
|
+
}), isDomainRestrictionEnabled && /*#__PURE__*/jsx(RestrictedDomains, {})]
|
|
1515
|
+
});
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1518
|
+
var FileGroup = function FileGroup(_ref) {
|
|
1519
|
+
var name = _ref.name,
|
|
1520
|
+
label = _ref.label,
|
|
1521
|
+
checked = _ref.checked,
|
|
1522
|
+
handleAllowedFileTypesChange = _ref.handleAllowedFileTypesChange;
|
|
1523
|
+
return /*#__PURE__*/jsx(Checkbox, {
|
|
1524
|
+
checked: checked,
|
|
1525
|
+
label: label,
|
|
1526
|
+
name: name,
|
|
1527
|
+
"data-cy": "neeto-form-engine-file-type-".concat(name),
|
|
1528
|
+
id: name,
|
|
1529
|
+
onChange: handleAllowedFileTypesChange
|
|
1530
|
+
});
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
|
+
var buildFileTypesList = function buildFileTypesList(fileTypes) {
|
|
1534
|
+
return (fileTypes !== null && fileTypes !== void 0 ? fileTypes : "").split(", ");
|
|
1535
|
+
};
|
|
1536
|
+
var getAllowedFileTypes = function getAllowedFileTypes(_ref) {
|
|
1537
|
+
var type = _ref.type,
|
|
1538
|
+
isChecked = _ref.isChecked,
|
|
1539
|
+
allowedFileTypes = _ref.allowedFileTypes;
|
|
1540
|
+
var fileTypes = buildFileTypesList(allowedFileTypes);
|
|
1541
|
+
if (isChecked) {
|
|
1542
|
+
var fileTypesSet = new Set([].concat(_toConsumableArray(FILE_TYPES_MAP[type]), _toConsumableArray(fileTypes)));
|
|
1543
|
+
return Array.from(fileTypesSet).join(", ");
|
|
1544
|
+
}
|
|
1545
|
+
var newFileTypes = difference(fileTypes, FILE_TYPES_MAP[type]);
|
|
1546
|
+
return newFileTypes.join(", ");
|
|
1547
|
+
};
|
|
1548
|
+
var isFileTypeEnabled = function isFileTypeEnabled(type, allowedFileTypes) {
|
|
1549
|
+
var fileTypes = buildFileTypesList(allowedFileTypes);
|
|
1550
|
+
return isEmpty(difference(FILE_TYPES_MAP[type], fileTypes));
|
|
1551
|
+
};
|
|
1552
|
+
|
|
1553
|
+
var FileUpload = function FileUpload() {
|
|
1554
|
+
var _useTranslation = useTranslation(),
|
|
1555
|
+
t = _useTranslation.t;
|
|
1556
|
+
var _useFormikContext = useFormikContext(),
|
|
1557
|
+
values = _useFormikContext.values,
|
|
1558
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
1559
|
+
var allowedFileTypes = prop("allowedFileTypes", values);
|
|
1560
|
+
var handleAllowedFileTypesChange = function handleAllowedFileTypesChange(_ref) {
|
|
1561
|
+
var _ref$target = _ref.target,
|
|
1562
|
+
fileType = _ref$target.name,
|
|
1563
|
+
checked = _ref$target.checked;
|
|
1564
|
+
return setFieldValue("allowedFileTypes", getAllowedFileTypes({
|
|
1565
|
+
type: fileType,
|
|
1566
|
+
isChecked: checked,
|
|
1567
|
+
allowedFileTypes: allowedFileTypes
|
|
1568
|
+
}));
|
|
1569
|
+
};
|
|
1570
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
1571
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
1572
|
+
className: "w-full",
|
|
1573
|
+
children: /*#__PURE__*/jsx(Checkbox$1, {
|
|
1574
|
+
id: "multipleFilesAllowed",
|
|
1575
|
+
label: t("neetoForm.fileUpload.enableMultipleFilesUpload"),
|
|
1576
|
+
name: "multipleFilesAllowed"
|
|
1577
|
+
})
|
|
1578
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
1579
|
+
className: "flex flex-col space-y-3",
|
|
1580
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
1581
|
+
style: "body1",
|
|
1582
|
+
weight: "semibold",
|
|
1583
|
+
children: t("neetoForm.fileUpload.fileTypes")
|
|
1584
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1585
|
+
className: "flex space-x-4",
|
|
1586
|
+
children: FILE_GROUPS.map(function (_ref2) {
|
|
1587
|
+
var name = _ref2.name,
|
|
1588
|
+
label = _ref2.label;
|
|
1589
|
+
return /*#__PURE__*/createElement(FileGroup, {
|
|
1590
|
+
handleAllowedFileTypesChange: handleAllowedFileTypesChange,
|
|
1591
|
+
label: label,
|
|
1592
|
+
name: name,
|
|
1593
|
+
checked: isFileTypeEnabled(name, allowedFileTypes),
|
|
1594
|
+
key: name
|
|
1595
|
+
});
|
|
1596
|
+
})
|
|
1597
|
+
})]
|
|
1598
|
+
})]
|
|
1599
|
+
});
|
|
1600
|
+
};
|
|
1601
|
+
|
|
1602
|
+
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; }
|
|
1603
|
+
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), !0).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; }
|
|
1604
|
+
var defaultConfig = {
|
|
1605
|
+
strict: true,
|
|
1606
|
+
matchKey: "value"
|
|
1607
|
+
};
|
|
1608
|
+
var findOptionByValue = function findOptionByValue(value) {
|
|
1609
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1610
|
+
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1611
|
+
var configObject = _objectSpread$5(_objectSpread$5({}, defaultConfig), config);
|
|
1612
|
+
var matchKey = configObject.matchKey,
|
|
1613
|
+
strict = configObject.strict;
|
|
1614
|
+
return options.find(function (option) {
|
|
1615
|
+
return (
|
|
1616
|
+
// eslint-disable-next-line eqeqeq
|
|
1617
|
+
strict ? option[matchKey] === value : option[matchKey] == value
|
|
1618
|
+
);
|
|
1619
|
+
});
|
|
1620
|
+
};
|
|
1621
|
+
var filterOptionsByValues = function filterOptionsByValues() {
|
|
1622
|
+
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1623
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1624
|
+
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1625
|
+
var configObject = _objectSpread$5(_objectSpread$5({}, defaultConfig), config);
|
|
1626
|
+
var matchKey = configObject.matchKey,
|
|
1627
|
+
strict = configObject.strict;
|
|
1628
|
+
return options.filter(function (option) {
|
|
1629
|
+
return values.some(function (value) {
|
|
1630
|
+
return (
|
|
1631
|
+
// eslint-disable-next-line eqeqeq
|
|
1632
|
+
strict ? option[matchKey] === value : option[matchKey] == value
|
|
1633
|
+
);
|
|
1634
|
+
});
|
|
1635
|
+
});
|
|
1636
|
+
};
|
|
1637
|
+
var destroyFromList = function destroyFromList(items, index) {
|
|
1638
|
+
var itemToRemove = items[index];
|
|
1639
|
+
if (itemToRemove) {
|
|
1640
|
+
var nextItems = _toConsumableArray(items);
|
|
1641
|
+
nextItems.splice(index, 1);
|
|
1642
|
+
if (itemToRemove.id) {
|
|
1643
|
+
nextItems.push(_objectSpread$5(_objectSpread$5({}, itemToRemove), {}, {
|
|
1644
|
+
_destroy: true
|
|
1645
|
+
}));
|
|
1646
|
+
}
|
|
1647
|
+
return nextItems;
|
|
1648
|
+
}
|
|
1649
|
+
return items;
|
|
1650
|
+
};
|
|
1651
|
+
var insertToList = function insertToList(items, item, index) {
|
|
1652
|
+
var nextItems = _toConsumableArray(items !== null && items !== void 0 ? items : []);
|
|
1653
|
+
nextItems.splice(index, 0, item);
|
|
1654
|
+
return nextItems;
|
|
1655
|
+
};
|
|
1656
|
+
var pushToList = function pushToList(items, item) {
|
|
1657
|
+
var nextItems = _toConsumableArray(items !== null && items !== void 0 ? items : []);
|
|
1658
|
+
nextItems.push(item);
|
|
1659
|
+
return nextItems;
|
|
1660
|
+
};
|
|
1661
|
+
var formHelpers = {
|
|
1662
|
+
findOptionByValue: findOptionByValue,
|
|
1663
|
+
filterOptionsByValues: filterOptionsByValues,
|
|
1664
|
+
destroyFromList: destroyFromList,
|
|
1665
|
+
insertToList: insertToList,
|
|
1666
|
+
pushToList: pushToList
|
|
1667
|
+
};
|
|
1668
|
+
|
|
1669
|
+
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; }
|
|
1670
|
+
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), !0).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; }
|
|
1671
|
+
var Options = function Options(_ref) {
|
|
1672
|
+
var questionProps = _ref.questionProps;
|
|
1673
|
+
var _useTranslation = useTranslation(),
|
|
1674
|
+
t = _useTranslation.t;
|
|
1675
|
+
var _useBuildFormStore = useBuildFormStore(function (store) {
|
|
1676
|
+
var _store$formState;
|
|
1677
|
+
return {
|
|
1678
|
+
selectedLanguage: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["selectedLanguage"]
|
|
1679
|
+
};
|
|
1680
|
+
}, shallow),
|
|
1681
|
+
selectedLanguage = _useBuildFormStore.selectedLanguage;
|
|
1682
|
+
var _useField = useField("optionsAttributes"),
|
|
1683
|
+
_useField2 = _slicedToArray(_useField, 3),
|
|
1684
|
+
optionsAttributes = _useField2[0].value;
|
|
1685
|
+
_useField2[1];
|
|
1686
|
+
var setOptionsAttributes = _useField2[2].setValue;
|
|
1687
|
+
var _ref2 = questionProps || {},
|
|
1688
|
+
_ref2$optionLabelProp = _ref2.optionLabelProps,
|
|
1689
|
+
optionLabelProps = _ref2$optionLabelProp === void 0 ? {} : _ref2$optionLabelProp,
|
|
1690
|
+
_ref2$freezeOptions = _ref2.freezeOptions,
|
|
1691
|
+
freezeOptions = _ref2$freezeOptions === void 0 ? false : _ref2$freezeOptions,
|
|
1692
|
+
_ref2$disableAddOptio = _ref2.disableAddOption,
|
|
1693
|
+
disableAddOption = _ref2$disableAddOptio === void 0 ? false : _ref2$disableAddOptio,
|
|
1694
|
+
_ref2$disableRemoveOp = _ref2.disableRemoveOption,
|
|
1695
|
+
disableRemoveOption = _ref2$disableRemoveOp === void 0 ? false : _ref2$disableRemoveOp;
|
|
1696
|
+
var handleRemoveOption = function handleRemoveOption(index) {
|
|
1697
|
+
var nextOptions = formHelpers.destroyFromList(optionsAttributes, index);
|
|
1698
|
+
setOptionsAttributes(nextOptions);
|
|
1699
|
+
};
|
|
1700
|
+
var isManageOptionDisabled = isFunction(freezeOptions) ? freezeOptions(selectedLanguage) : freezeOptions;
|
|
1701
|
+
var isAddOptionDisabled = disableAddOption || isManageOptionDisabled;
|
|
1702
|
+
var isRemoveOptionDisabled = disableRemoveOption || isManageOptionDisabled;
|
|
1703
|
+
return /*#__PURE__*/jsx("div", {
|
|
1704
|
+
className: "w-full",
|
|
1705
|
+
children: /*#__PURE__*/jsx(FieldArray, {
|
|
1706
|
+
name: "optionsAttributes",
|
|
1707
|
+
children: function children(_ref3) {
|
|
1708
|
+
var handlePush = _ref3.handlePush;
|
|
1709
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
1710
|
+
children: [/*#__PURE__*/jsx(Label, _objectSpread$4(_objectSpread$4({
|
|
1711
|
+
className: "mb-1 block"
|
|
1712
|
+
}, optionLabelProps), {}, {
|
|
1713
|
+
children: t("neetoForm.questions.common.questionFields.field.options")
|
|
1714
|
+
})), /*#__PURE__*/jsx("div", {
|
|
1715
|
+
className: "flex w-2/3 flex-col space-y-2",
|
|
1716
|
+
children: optionsAttributes === null || optionsAttributes === void 0 ? void 0 : optionsAttributes.map(function (option, index) {
|
|
1717
|
+
var _option$id;
|
|
1718
|
+
return !option._destroy && /*#__PURE__*/jsxs("div", {
|
|
1719
|
+
className: "flex items-start gap-1",
|
|
1720
|
+
"data-cy": "neeto-form-engine-option-".concat(index),
|
|
1721
|
+
children: [/*#__PURE__*/jsx(InputWithMaxLength, {
|
|
1722
|
+
required: true,
|
|
1723
|
+
disabled: isManageOptionDisabled,
|
|
1724
|
+
name: "optionsAttributes.".concat(index, ".label"),
|
|
1725
|
+
placeholder: t("neetoForm.questions.common.questionFields.field.numberedOption", {
|
|
1726
|
+
number: index + 1
|
|
1727
|
+
})
|
|
1728
|
+
}), !isRemoveOptionDisabled && /*#__PURE__*/jsx(Button, {
|
|
1729
|
+
"data-cy": "neeto-form-engine-delete-option-button",
|
|
1730
|
+
icon: Delete,
|
|
1731
|
+
size: "small",
|
|
1732
|
+
style: "text",
|
|
1733
|
+
className: classnames({
|
|
1734
|
+
invisible: index < MINIMUM_OPTIONS
|
|
1735
|
+
}),
|
|
1736
|
+
tooltipProps: {
|
|
1737
|
+
position: "top",
|
|
1738
|
+
content: t("neetoForm.common.delete")
|
|
1739
|
+
},
|
|
1740
|
+
onClick: function onClick() {
|
|
1741
|
+
return handleRemoveOption(index);
|
|
1742
|
+
}
|
|
1743
|
+
})]
|
|
1744
|
+
}, "question-option-".concat((_option$id = option.id) !== null && _option$id !== void 0 ? _option$id : index));
|
|
1745
|
+
})
|
|
1746
|
+
}), !isAddOptionDisabled && /*#__PURE__*/jsx("div", {
|
|
1747
|
+
className: "mt-3 w-full",
|
|
1748
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
1749
|
+
"data-cy": "neeto-form-engine-add-option-button",
|
|
1750
|
+
icon: Plus,
|
|
1751
|
+
iconPosition: "left",
|
|
1752
|
+
size: "small",
|
|
1753
|
+
style: "text",
|
|
1754
|
+
label: t("neetoForm.questions.common.questionFields.field.addOption"),
|
|
1755
|
+
onClick: handlePush({
|
|
1756
|
+
label: ""
|
|
1757
|
+
})
|
|
1758
|
+
})
|
|
1759
|
+
})]
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
})
|
|
1763
|
+
});
|
|
1764
|
+
};
|
|
1765
|
+
|
|
1766
|
+
var RatingItem = function RatingItem(_ref) {
|
|
1767
|
+
var children = _ref.children;
|
|
1768
|
+
return /*#__PURE__*/jsx("div", {
|
|
1769
|
+
className: "flex w-16 flex-col items-center gap-3",
|
|
1770
|
+
children: children
|
|
1771
|
+
});
|
|
1772
|
+
};
|
|
1773
|
+
var Rating = function Rating() {
|
|
1774
|
+
return /*#__PURE__*/jsx("div", {
|
|
1775
|
+
className: "flex flex-col",
|
|
1776
|
+
children: /*#__PURE__*/jsx("div", {
|
|
1777
|
+
className: "w-full",
|
|
1778
|
+
children: /*#__PURE__*/jsx("div", {
|
|
1779
|
+
className: "flex gap-6",
|
|
1780
|
+
children: RATING_OPTIONS.map(function (_ref2) {
|
|
1781
|
+
var Icon = _ref2.icon,
|
|
1782
|
+
name = _ref2.name,
|
|
1783
|
+
color = _ref2.color;
|
|
1784
|
+
return /*#__PURE__*/jsxs(RatingItem, {
|
|
1785
|
+
children: [/*#__PURE__*/jsx(Icon, {
|
|
1786
|
+
color: color,
|
|
1787
|
+
size: 48
|
|
1788
|
+
}), /*#__PURE__*/jsx(InputWithMaxLength, {
|
|
1789
|
+
name: name,
|
|
1790
|
+
"data-cy": "neeto-form-engine-".concat(hyphenate(name))
|
|
1791
|
+
})]
|
|
1792
|
+
}, name);
|
|
1793
|
+
})
|
|
1794
|
+
})
|
|
1795
|
+
})
|
|
1796
|
+
});
|
|
1797
|
+
};
|
|
1798
|
+
|
|
1799
|
+
var StarRating = function StarRating() {
|
|
1800
|
+
var _useTranslation = useTranslation(),
|
|
1801
|
+
t = _useTranslation.t;
|
|
1802
|
+
var _useFormikContext = useFormikContext(),
|
|
1803
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
1804
|
+
var _useField = useField("iconType"),
|
|
1805
|
+
_useField2 = _slicedToArray(_useField, 3),
|
|
1806
|
+
iconType = _useField2[0].value;
|
|
1807
|
+
_useField2[1];
|
|
1808
|
+
var setIconType = _useField2[2].setValue;
|
|
1809
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
1810
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
1811
|
+
className: "flex space-x-4",
|
|
1812
|
+
children: [/*#__PURE__*/jsx(Select, {
|
|
1813
|
+
className: "w-1/2",
|
|
1814
|
+
"data-cy": "neeto-form-engine-star-rating-min-value",
|
|
1815
|
+
label: t("neetoForm.common.start"),
|
|
1816
|
+
name: "minValue",
|
|
1817
|
+
options: STAR_RATING_MIN_VALUE_OPTIONS,
|
|
1818
|
+
onChange: function onChange(option) {
|
|
1819
|
+
return setFieldValue("minValue", option === null || option === void 0 ? void 0 : option.value);
|
|
1820
|
+
}
|
|
1821
|
+
}), /*#__PURE__*/jsx(Select, {
|
|
1822
|
+
className: "w-1/2",
|
|
1823
|
+
"data-cy": "neeto-form-engine-star-rating-max-value",
|
|
1824
|
+
label: t("neetoForm.common.end"),
|
|
1825
|
+
name: "maxValue",
|
|
1826
|
+
options: STAR_RATING_MAX_VALUE_OPTIONS,
|
|
1827
|
+
onChange: function onChange(option) {
|
|
1828
|
+
return setFieldValue("maxValue", option === null || option === void 0 ? void 0 : option.value);
|
|
1829
|
+
}
|
|
1830
|
+
})]
|
|
1831
|
+
}), /*#__PURE__*/jsx(Label, {
|
|
1832
|
+
children: t("neetoForm.common.shape")
|
|
1833
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1834
|
+
className: "flex gap-2",
|
|
1835
|
+
children: Object.entries(STAR_RATING_ICONS_MAP).map(function (_ref) {
|
|
1836
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
1837
|
+
name = _ref2[0],
|
|
1838
|
+
IconType = _ref2[1];
|
|
1839
|
+
var isActive = name === iconType;
|
|
1840
|
+
return /*#__PURE__*/jsx("div", {
|
|
1841
|
+
"data-cy": "neeto-form-engine-rating-icon-".concat(name),
|
|
1842
|
+
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", {
|
|
1843
|
+
"neeto-ui-text-gray-800 neeto-ui-bg-gray-200": !isActive,
|
|
1844
|
+
"neeto-ui-text-white neeto-ui-bg-gray-800": isActive
|
|
1845
|
+
}),
|
|
1846
|
+
onClick: function onClick() {
|
|
1847
|
+
return setIconType(name);
|
|
1848
|
+
},
|
|
1849
|
+
children: /*#__PURE__*/jsx(IconType, {})
|
|
1850
|
+
}, name);
|
|
1851
|
+
})
|
|
1852
|
+
})]
|
|
1853
|
+
});
|
|
1854
|
+
};
|
|
1855
|
+
|
|
1856
|
+
var CHECKBOX = QUESTION_TYPES.CHECKBOX,
|
|
1857
|
+
RADIO = QUESTION_TYPES.RADIO,
|
|
1858
|
+
DROPDOWN = QUESTION_TYPES.DROPDOWN,
|
|
1859
|
+
STAR_RATING = QUESTION_TYPES.STAR_RATING,
|
|
1860
|
+
RATING = QUESTION_TYPES.RATING,
|
|
1861
|
+
FILE_UPLOAD = QUESTION_TYPES.FILE_UPLOAD,
|
|
1862
|
+
CAPTCHA = QUESTION_TYPES.CAPTCHA,
|
|
1863
|
+
EMAIL = QUESTION_TYPES.EMAIL;
|
|
1864
|
+
var transformValueForOption = function transformValueForOption(_ref) {
|
|
1865
|
+
var label = _ref.label,
|
|
1866
|
+
type = _ref.type;
|
|
1867
|
+
return "".concat(slugify(label), "-").concat(type);
|
|
1868
|
+
};
|
|
1869
|
+
var renderAdditionalData = function renderAdditionalData(_ref2) {
|
|
1870
|
+
var kind = _ref2.kind,
|
|
1871
|
+
questionProps = _ref2.questionProps,
|
|
1872
|
+
domainRestrictionHelpDocUrl = _ref2.domainRestrictionHelpDocUrl,
|
|
1873
|
+
enableDomainRestriction = _ref2.enableDomainRestriction;
|
|
1874
|
+
switch (kind) {
|
|
1875
|
+
case CHECKBOX:
|
|
1876
|
+
case RADIO:
|
|
1877
|
+
case DROPDOWN:
|
|
1878
|
+
return /*#__PURE__*/jsx(Options, {
|
|
1879
|
+
questionProps: questionProps
|
|
1880
|
+
});
|
|
1881
|
+
case RATING:
|
|
1882
|
+
return /*#__PURE__*/jsx(Rating, {});
|
|
1883
|
+
case STAR_RATING:
|
|
1884
|
+
return /*#__PURE__*/jsx(StarRating, {});
|
|
1885
|
+
case FILE_UPLOAD:
|
|
1886
|
+
return /*#__PURE__*/jsx(FileUpload, {});
|
|
1887
|
+
case CAPTCHA:
|
|
1888
|
+
return /*#__PURE__*/jsx(Captcha, {});
|
|
1889
|
+
case EMAIL:
|
|
1890
|
+
return enableDomainRestriction ? /*#__PURE__*/jsx(Email, {
|
|
1891
|
+
domainRestrictionHelpDocUrl: domainRestrictionHelpDocUrl
|
|
1892
|
+
}) : null;
|
|
1893
|
+
default:
|
|
1894
|
+
return null;
|
|
1895
|
+
}
|
|
1896
|
+
};
|
|
1897
|
+
var resolveActionComponent = function resolveActionComponent(action) {
|
|
1898
|
+
return equals(action, QUESTION_ACTIONS.ADD) ? Add : Edit;
|
|
1899
|
+
};
|
|
1900
|
+
var getQuestionKind = function getQuestionKind(questionKinds, pattern) {
|
|
1901
|
+
var questionKind = findBy(pattern, questionKinds);
|
|
1902
|
+
return questionKind ? assoc("kind", questionKind.type, questionKind) : null;
|
|
1903
|
+
};
|
|
1904
|
+
var buildKindOptions = function buildKindOptions(kinds) {
|
|
1905
|
+
return kinds.map(function (_ref3) {
|
|
1906
|
+
var label = _ref3.label,
|
|
1907
|
+
type = _ref3.type;
|
|
1908
|
+
return {
|
|
1909
|
+
label: label,
|
|
1910
|
+
value: transformValueForOption({
|
|
1911
|
+
label: label,
|
|
1912
|
+
type: type
|
|
1913
|
+
})
|
|
1914
|
+
};
|
|
1915
|
+
});
|
|
1916
|
+
};
|
|
1917
|
+
var extractKindFromOption = pipe(split("-"), last);
|
|
1918
|
+
var buildDefaultValueForKind = function buildDefaultValueForKind(questionKind) {
|
|
1919
|
+
return isPresent(questionKind) ? {
|
|
1920
|
+
value: transformValueForOption(questionKind)
|
|
1921
|
+
} : undefined;
|
|
1922
|
+
};
|
|
1923
|
+
|
|
1924
|
+
var _excluded$1 = ["isOpen", "onClose", "action", "question", "availableQuestionKinds", "fieldCodeHelpDocUrl", "domainRestrictionHelpDocUrl"];
|
|
1925
|
+
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; }
|
|
1926
|
+
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), !0).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; }
|
|
1927
|
+
var ManageQuestionPane = function ManageQuestionPane(_ref) {
|
|
1928
|
+
var isOpen = _ref.isOpen,
|
|
1929
|
+
onClose = _ref.onClose,
|
|
1930
|
+
action = _ref.action,
|
|
1931
|
+
question = _ref.question,
|
|
1932
|
+
availableQuestionKinds = _ref.availableQuestionKinds,
|
|
1933
|
+
fieldCodeHelpDocUrl = _ref.fieldCodeHelpDocUrl,
|
|
1934
|
+
domainRestrictionHelpDocUrl = _ref.domainRestrictionHelpDocUrl,
|
|
1935
|
+
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
1936
|
+
var initialFocusRef = useRef(null);
|
|
1937
|
+
var Component = resolveActionComponent(action);
|
|
1938
|
+
return /*#__PURE__*/jsx(Pane, {
|
|
1939
|
+
initialFocusRef: initialFocusRef,
|
|
1940
|
+
isOpen: isOpen,
|
|
1941
|
+
onClose: onClose,
|
|
1942
|
+
children: /*#__PURE__*/jsx(Component, _objectSpread$3({}, _objectSpread$3({
|
|
1943
|
+
availableQuestionKinds: availableQuestionKinds,
|
|
1944
|
+
domainRestrictionHelpDocUrl: domainRestrictionHelpDocUrl,
|
|
1945
|
+
fieldCodeHelpDocUrl: fieldCodeHelpDocUrl,
|
|
1946
|
+
initialFocusRef: initialFocusRef,
|
|
1947
|
+
isOpen: isOpen,
|
|
1948
|
+
onClose: onClose,
|
|
1949
|
+
question: question
|
|
1950
|
+
}, props)))
|
|
1951
|
+
});
|
|
1952
|
+
};
|
|
1953
|
+
|
|
1954
|
+
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; }
|
|
1955
|
+
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), !0).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; }
|
|
1956
|
+
var AddQuestion = function AddQuestion(_ref) {
|
|
1957
|
+
var onAdd = _ref.onAdd,
|
|
1958
|
+
disabledAddButtonTooltipProps = _ref.disabledAddButtonTooltipProps,
|
|
1959
|
+
isDisabled = _ref.isDisabled;
|
|
1960
|
+
var tooltipProps = buildDisabledAddButtonTooltipProps(isDisabled, disabledAddButtonTooltipProps);
|
|
1961
|
+
return /*#__PURE__*/jsx(Tooltip, _objectSpread$2(_objectSpread$2({}, isDisabled && tooltipProps), {}, {
|
|
1962
|
+
children: /*#__PURE__*/jsx("span", {
|
|
1963
|
+
children: /*#__PURE__*/jsx(Button, _objectSpread$2({}, buildAddQuestionButtonProps(onAdd, isDisabled)))
|
|
1964
|
+
})
|
|
1965
|
+
}));
|
|
1966
|
+
};
|
|
1967
|
+
|
|
1968
|
+
var _excluded = ["questionKinds", "onValueChange", "formId", "isDeletable", "isRequiredField", "submitButtonProps", "cancelButtonProps", "isKindAlreadyActive", "getActiveKindDetails", "isDisabledFieldLabel", "disabledAddButtonTooltipProps", "enableFieldCode", "isFormEnabled", "savedTitle", "formTitle", "formDescription", "selectedLanguage", "availableLanguages", "onLanguageChange", "additionalActionOptions", "isReordering", "additionalQuestionKindPattern", "showActionBlock", "buildRequestArgs", "fieldCodeHelpDocUrl", "enableDomainRestriction", "domainRestrictionHelpDocUrl"];
|
|
1969
|
+
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; }
|
|
1970
|
+
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), !0).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; }
|
|
1971
|
+
var Form = function Form(_ref) {
|
|
1972
|
+
var questionKinds = _ref.questionKinds,
|
|
1973
|
+
onValueChange = _ref.onValueChange,
|
|
1974
|
+
formId = _ref.formId,
|
|
1975
|
+
isDeletable = _ref.isDeletable,
|
|
1976
|
+
isRequiredField = _ref.isRequiredField,
|
|
1977
|
+
submitButtonProps = _ref.submitButtonProps,
|
|
1978
|
+
cancelButtonProps = _ref.cancelButtonProps,
|
|
1979
|
+
isKindAlreadyActive = _ref.isKindAlreadyActive,
|
|
1980
|
+
getActiveKindDetails = _ref.getActiveKindDetails,
|
|
1981
|
+
isDisabledFieldLabel = _ref.isDisabledFieldLabel,
|
|
1982
|
+
disabledAddButtonTooltipProps = _ref.disabledAddButtonTooltipProps,
|
|
1983
|
+
enableFieldCode = _ref.enableFieldCode,
|
|
1984
|
+
isFormEnabled = _ref.isFormEnabled,
|
|
1985
|
+
savedTitle = _ref.savedTitle,
|
|
1986
|
+
formTitle = _ref.formTitle,
|
|
1987
|
+
formDescription = _ref.formDescription,
|
|
1988
|
+
selectedLanguage = _ref.selectedLanguage,
|
|
1989
|
+
availableLanguages = _ref.availableLanguages,
|
|
1990
|
+
onLanguageChange = _ref.onLanguageChange,
|
|
1991
|
+
additionalActionOptions = _ref.additionalActionOptions,
|
|
1992
|
+
isReordering = _ref.isReordering,
|
|
1993
|
+
additionalQuestionKindPattern = _ref.additionalQuestionKindPattern,
|
|
1994
|
+
showActionBlock = _ref.showActionBlock,
|
|
1995
|
+
buildRequestArgs = _ref.buildRequestArgs,
|
|
1996
|
+
fieldCodeHelpDocUrl = _ref.fieldCodeHelpDocUrl,
|
|
1997
|
+
enableDomainRestriction = _ref.enableDomainRestriction,
|
|
1998
|
+
domainRestrictionHelpDocUrl = _ref.domainRestrictionHelpDocUrl,
|
|
1999
|
+
formDomProps = _objectWithoutProperties(_ref, _excluded);
|
|
2000
|
+
var containerRef = useRef();
|
|
2001
|
+
var _useTranslation = useTranslation(),
|
|
2002
|
+
t = _useTranslation.t;
|
|
2003
|
+
var formikContext = useFormikContext();
|
|
2004
|
+
var _useState = useState(null),
|
|
2005
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2006
|
+
selectedQuestion = _useState2[0],
|
|
2007
|
+
setSelectedQuestion = _useState2[1];
|
|
2008
|
+
var _useState3 = useState(""),
|
|
2009
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2010
|
+
selectedAction = _useState4[0],
|
|
2011
|
+
setSelectedAction = _useState4[1];
|
|
2012
|
+
var _useState5 = useState(false),
|
|
2013
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
2014
|
+
isDeleteAlertOpen = _useState6[0],
|
|
2015
|
+
setIsDeleteAlertOpen = _useState6[1];
|
|
2016
|
+
var _useState7 = useState(false),
|
|
2017
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
2018
|
+
isManageQuestionPaneOpen = _useState8[0],
|
|
2019
|
+
setIsManageQuestionPaneOpen = _useState8[1];
|
|
2020
|
+
var values = formikContext.values,
|
|
2021
|
+
setFieldValue = formikContext.setFieldValue,
|
|
2022
|
+
dirty = formikContext.dirty,
|
|
2023
|
+
isSubmitting = formikContext.isSubmitting,
|
|
2024
|
+
isValid = formikContext.isValid,
|
|
2025
|
+
errors = formikContext.errors,
|
|
2026
|
+
submitForm = formikContext.submitForm,
|
|
2027
|
+
resetForm = formikContext.resetForm;
|
|
2028
|
+
var setFormData = useBuildFormStore(prop("setFormData"));
|
|
2029
|
+
var _useCreateQuestion = useCreateQuestion(formId, selectedLanguage, {
|
|
2030
|
+
onSuccess: showThumbsUpToastr
|
|
2031
|
+
}),
|
|
2032
|
+
createQuestion = _useCreateQuestion.mutate;
|
|
2033
|
+
useEffect(function () {
|
|
2034
|
+
setFormData({
|
|
2035
|
+
formId: formId,
|
|
2036
|
+
enabled: isFormEnabled,
|
|
2037
|
+
title: savedTitle,
|
|
2038
|
+
values: values,
|
|
2039
|
+
dirty: dirty,
|
|
2040
|
+
isSubmitting: isSubmitting,
|
|
2041
|
+
isValid: isValid,
|
|
2042
|
+
errors: errors,
|
|
2043
|
+
submitForm: submitForm,
|
|
2044
|
+
resetForm: resetForm,
|
|
2045
|
+
selectedLanguage: selectedLanguage
|
|
2046
|
+
});
|
|
2047
|
+
}, [formId, isFormEnabled, savedTitle, setFormData, values, dirty, isSubmitting, isValid, errors, submitForm, resetForm, selectedLanguage]);
|
|
2048
|
+
var questions = values.questions;
|
|
2049
|
+
var handleSelect = function handleSelect(question) {
|
|
2050
|
+
setSelectedQuestion(question);
|
|
2051
|
+
};
|
|
2052
|
+
var handleAdd = function handleAdd() {
|
|
2053
|
+
setSelectedAction(QUESTION_ACTIONS.ADD);
|
|
2054
|
+
setIsManageQuestionPaneOpen(true);
|
|
2055
|
+
};
|
|
2056
|
+
var handleEdit = function handleEdit() {
|
|
2057
|
+
setSelectedAction(QUESTION_ACTIONS.EDIT);
|
|
2058
|
+
setIsManageQuestionPaneOpen(true);
|
|
2059
|
+
};
|
|
2060
|
+
var handleClone = function handleClone() {
|
|
2061
|
+
var values = duplicateFieldData({
|
|
2062
|
+
item: selectedQuestion,
|
|
2063
|
+
questionKinds: availableQuestionKinds,
|
|
2064
|
+
questions: questions
|
|
2065
|
+
});
|
|
2066
|
+
var displayOrder = selectedQuestion.displayOrder + 1;
|
|
2067
|
+
var attributes = mergeLeft({
|
|
2068
|
+
displayOrder: displayOrder
|
|
2069
|
+
}, values);
|
|
2070
|
+
var payload = _objectSpread$1({
|
|
2071
|
+
language: selectedLanguage,
|
|
2072
|
+
neetoFormQuestion: formatQuestionAttributesForClone(attributes)
|
|
2073
|
+
}, buildRequestArgs);
|
|
2074
|
+
createQuestion(payload, {
|
|
2075
|
+
onSuccess: function onSuccess(_ref2) {
|
|
2076
|
+
var questions = _ref2.questions;
|
|
2077
|
+
var newQuestion = findBy({
|
|
2078
|
+
displayOrder: displayOrder
|
|
2079
|
+
}, questions);
|
|
2080
|
+
handleSelect(newQuestion);
|
|
2081
|
+
}
|
|
2082
|
+
});
|
|
2083
|
+
};
|
|
2084
|
+
var handleDelete = function handleDelete() {
|
|
2085
|
+
setIsDeleteAlertOpen(true);
|
|
2086
|
+
};
|
|
2087
|
+
useOnClickOutside(containerRef, function () {
|
|
2088
|
+
return handleSelect(null);
|
|
2089
|
+
}, {
|
|
2090
|
+
enabled: !(isDeleteAlertOpen || isManageQuestionPaneOpen)
|
|
2091
|
+
});
|
|
2092
|
+
useEffect(function () {
|
|
2093
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(questions);
|
|
2094
|
+
}, [questions]);
|
|
2095
|
+
var availableQuestionKinds = getAvailableQuestionKinds({
|
|
2096
|
+
allQuestionKinds: questionKinds,
|
|
2097
|
+
activeQuestions: questions,
|
|
2098
|
+
isKindAlreadyActive: isKindAlreadyActive
|
|
2099
|
+
});
|
|
2100
|
+
var hasActiveQuestions = questions && questions.length && questions.some(function (question) {
|
|
2101
|
+
return question._destroy !== true;
|
|
2102
|
+
});
|
|
2103
|
+
var handleLanguageChange = function handleLanguageChange(code) {
|
|
2104
|
+
resetForm();
|
|
2105
|
+
onLanguageChange(code);
|
|
2106
|
+
};
|
|
2107
|
+
var richTextQuestions = filterBy({
|
|
2108
|
+
kind: includes(__, RICH_TEXT_QUESTIONS)
|
|
2109
|
+
}, questions);
|
|
2110
|
+
var resetFormData = function resetFormData() {
|
|
2111
|
+
resetForm();
|
|
2112
|
+
setFormData({
|
|
2113
|
+
richTextFieldsToReset: pluck("fieldCode", richTextQuestions)
|
|
2114
|
+
});
|
|
2115
|
+
};
|
|
2116
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
2117
|
+
children: [/*#__PURE__*/jsx(DeleteAlert, {
|
|
2118
|
+
handleSelect: handleSelect,
|
|
2119
|
+
selectedQuestion: selectedQuestion,
|
|
2120
|
+
isOpen: isDeleteAlertOpen,
|
|
2121
|
+
languagesCount: availableLanguages.length,
|
|
2122
|
+
onClose: function onClose() {
|
|
2123
|
+
return setIsDeleteAlertOpen(false);
|
|
2124
|
+
}
|
|
2125
|
+
}), /*#__PURE__*/jsxs(Form$3, _objectSpread$1(_objectSpread$1({
|
|
2126
|
+
className: "neeto-form-nano-form-wrapper flex h-full flex-col"
|
|
2127
|
+
}, formDomProps), {}, {
|
|
2128
|
+
noValidate: true,
|
|
2129
|
+
children: [formTitle && /*#__PURE__*/jsx(Overview, {
|
|
2130
|
+
additionalActionOptions: additionalActionOptions,
|
|
2131
|
+
availableLanguages: availableLanguages,
|
|
2132
|
+
selectedLanguage: selectedLanguage,
|
|
2133
|
+
description: formDescription,
|
|
2134
|
+
title: formTitle,
|
|
2135
|
+
onLanguageChange: handleLanguageChange
|
|
2136
|
+
}), /*#__PURE__*/jsx("div", {
|
|
2137
|
+
className: "neeto-form-nano-form-wrapper__body min-h-0 w-full flex-grow space-y-6 overflow-y-auto px-6 pb-6",
|
|
2138
|
+
children: hasActiveQuestions ? /*#__PURE__*/jsxs("div", {
|
|
2139
|
+
className: "space-y-6",
|
|
2140
|
+
ref: containerRef,
|
|
2141
|
+
children: [/*#__PURE__*/jsx(DragDropContext, {
|
|
2142
|
+
onDragEnd: function onDragEnd(_ref3) {
|
|
2143
|
+
var source = _ref3.source,
|
|
2144
|
+
destination = _ref3.destination;
|
|
2145
|
+
return handleFieldDragEnd({
|
|
2146
|
+
source: source,
|
|
2147
|
+
destination: destination,
|
|
2148
|
+
items: questions,
|
|
2149
|
+
setValue: setFieldValue
|
|
2150
|
+
});
|
|
2151
|
+
},
|
|
2152
|
+
children: /*#__PURE__*/jsx(Questions, {
|
|
2153
|
+
getActiveKindDetails: getActiveKindDetails,
|
|
2154
|
+
isDeletable: isDeletable,
|
|
2155
|
+
questions: questions,
|
|
2156
|
+
selectedQuestion: selectedQuestion,
|
|
2157
|
+
allQuestionKinds: questionKinds,
|
|
2158
|
+
onClone: handleClone,
|
|
2159
|
+
onDelete: handleDelete,
|
|
2160
|
+
onEdit: handleEdit,
|
|
2161
|
+
onSelect: handleSelect
|
|
2162
|
+
})
|
|
2163
|
+
}), /*#__PURE__*/jsx("div", {
|
|
2164
|
+
className: "mb-8 w-full",
|
|
2165
|
+
children: /*#__PURE__*/jsx(AddQuestion, {
|
|
2166
|
+
disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
|
|
2167
|
+
isDisabled: isEmpty(availableQuestionKinds),
|
|
2168
|
+
onAdd: handleAdd
|
|
2169
|
+
})
|
|
2170
|
+
})]
|
|
2171
|
+
}) : /*#__PURE__*/jsx(AddFirstQuestion, {
|
|
2172
|
+
disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
|
|
2173
|
+
isDisabled: isEmpty(availableQuestionKinds),
|
|
2174
|
+
onAdd: handleAdd
|
|
2175
|
+
})
|
|
2176
|
+
}), (showActionBlock || dirty) && /*#__PURE__*/jsx("div", {
|
|
2177
|
+
className: "neeto-ui-border-gray-300 neeto-form-nano-form-wrapper__footer neeto-ui-bg-white sticky bottom-0 flex flex-shrink-0 justify-end border-t px-6 py-4",
|
|
2178
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
2179
|
+
submitButtonProps: submitButtonProps,
|
|
2180
|
+
isSubmitting: isReordering,
|
|
2181
|
+
cancelButtonProps: _objectSpread$1({
|
|
2182
|
+
label: t("neetoForm.common.reset"),
|
|
2183
|
+
onClick: resetFormData
|
|
2184
|
+
}, cancelButtonProps)
|
|
2185
|
+
})
|
|
2186
|
+
}), /*#__PURE__*/jsx(ManageQuestionPane, {
|
|
2187
|
+
additionalQuestionKindPattern: additionalQuestionKindPattern,
|
|
2188
|
+
availableQuestionKinds: availableQuestionKinds,
|
|
2189
|
+
buildRequestArgs: buildRequestArgs,
|
|
2190
|
+
domainRestrictionHelpDocUrl: domainRestrictionHelpDocUrl,
|
|
2191
|
+
enableDomainRestriction: enableDomainRestriction,
|
|
2192
|
+
enableFieldCode: enableFieldCode,
|
|
2193
|
+
fieldCodeHelpDocUrl: fieldCodeHelpDocUrl,
|
|
2194
|
+
getActiveKindDetails: getActiveKindDetails,
|
|
2195
|
+
handleSelect: handleSelect,
|
|
2196
|
+
isDisabledFieldLabel: isDisabledFieldLabel,
|
|
2197
|
+
isRequiredField: isRequiredField,
|
|
2198
|
+
questions: questions,
|
|
2199
|
+
action: selectedAction,
|
|
2200
|
+
allQuestionKinds: questionKinds,
|
|
2201
|
+
isOpen: isManageQuestionPaneOpen,
|
|
2202
|
+
question: selectedQuestion,
|
|
2203
|
+
onClose: function onClose() {
|
|
2204
|
+
return setIsManageQuestionPaneOpen(false);
|
|
2205
|
+
}
|
|
2206
|
+
})]
|
|
2207
|
+
}))]
|
|
2208
|
+
});
|
|
2209
|
+
};
|
|
2210
|
+
|
|
2211
|
+
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; }
|
|
2212
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).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; }
|
|
2213
|
+
var BuildForm = function BuildForm(_ref) {
|
|
2214
|
+
var id = _ref.id,
|
|
2215
|
+
onUpdate = _ref.onUpdate,
|
|
2216
|
+
buildRequestArgs = _ref.buildRequestArgs,
|
|
2217
|
+
_ref$nonRemovableFiel = _ref.nonRemovableFields,
|
|
2218
|
+
nonRemovableFields = _ref$nonRemovableFiel === void 0 ? [] : _ref$nonRemovableFiel,
|
|
2219
|
+
_ref$requiredFields = _ref.requiredFields,
|
|
2220
|
+
requiredFields = _ref$requiredFields === void 0 ? [] : _ref$requiredFields,
|
|
2221
|
+
formDomProps = _ref.formDomProps,
|
|
2222
|
+
_ref$showActionBlock = _ref.showActionBlock,
|
|
2223
|
+
showActionBlock = _ref$showActionBlock === void 0 ? false : _ref$showActionBlock,
|
|
2224
|
+
submitButtonProps = _ref.submitButtonProps,
|
|
2225
|
+
cancelButtonProps = _ref.cancelButtonProps,
|
|
2226
|
+
questionKinds = _ref.questionKinds,
|
|
2227
|
+
_ref$isKindAlreadyAct = _ref.isKindAlreadyActive,
|
|
2228
|
+
isKindAlreadyActive = _ref$isKindAlreadyAct === void 0 ? isQuestionKindAlreadyActive : _ref$isKindAlreadyAct,
|
|
2229
|
+
_ref$getActiveKindDet = _ref.getActiveKindDetails,
|
|
2230
|
+
getActiveKindDetails = _ref$getActiveKindDet === void 0 ? getActiveQuestionKindDetails : _ref$getActiveKindDet,
|
|
2231
|
+
isQuestionDeletable = _ref.isQuestionDeletable,
|
|
2232
|
+
isFieldRequired = _ref.isFieldRequired,
|
|
2233
|
+
isFieldLabelDisabled = _ref.isFieldLabelDisabled,
|
|
2234
|
+
_ref$showLoader = _ref.showLoader,
|
|
2235
|
+
showLoader = _ref$showLoader === void 0 ? false : _ref$showLoader,
|
|
2236
|
+
_ref$kindUniqueOn = _ref.kindUniqueOn,
|
|
2237
|
+
kindUniqueOn = _ref$kindUniqueOn === void 0 ? ["type"] : _ref$kindUniqueOn,
|
|
2238
|
+
_ref$allowAdditionalG = _ref.allowAdditionalGuests,
|
|
2239
|
+
allowAdditionalGuests = _ref$allowAdditionalG === void 0 ? false : _ref$allowAdditionalG,
|
|
2240
|
+
disabledAddButtonTooltipProps = _ref.disabledAddButtonTooltipProps,
|
|
2241
|
+
_ref$enableFieldCode = _ref.enableFieldCode,
|
|
2242
|
+
enableFieldCode = _ref$enableFieldCode === void 0 ? false : _ref$enableFieldCode,
|
|
2243
|
+
_ref$availableLanguag = _ref.availableLanguages,
|
|
2244
|
+
availableLanguages = _ref$availableLanguag === void 0 ? DEFAULT_AVAILABLE_LANGUAGES : _ref$availableLanguag,
|
|
2245
|
+
formDescription = _ref.formDescription,
|
|
2246
|
+
_ref$formTitle = _ref.formTitle,
|
|
2247
|
+
formTitle = _ref$formTitle === void 0 ? "" : _ref$formTitle,
|
|
2248
|
+
_ref$selectedLanguage = _ref.selectedLanguage,
|
|
2249
|
+
selectedLanguage = _ref$selectedLanguage === void 0 ? "en" : _ref$selectedLanguage,
|
|
2250
|
+
_ref$onLanguageChange = _ref.onLanguageChange,
|
|
2251
|
+
onLanguageChange = _ref$onLanguageChange === void 0 ? noop : _ref$onLanguageChange,
|
|
2252
|
+
_ref$additionalAction = _ref.additionalActionOptions,
|
|
2253
|
+
additionalActionOptions = _ref$additionalAction === void 0 ? [] : _ref$additionalAction,
|
|
2254
|
+
additionalQuestionKindPattern = _ref.additionalQuestionKindPattern,
|
|
2255
|
+
fieldCodeHelpDocUrl = _ref.fieldCodeHelpDocUrl,
|
|
2256
|
+
_ref$enableDomainRest = _ref.enableDomainRestriction,
|
|
2257
|
+
enableDomainRestriction = _ref$enableDomainRest === void 0 ? true : _ref$enableDomainRest,
|
|
2258
|
+
domainRestrictionHelpDocUrl = _ref.domainRestrictionHelpDocUrl,
|
|
2259
|
+
className = _ref.className;
|
|
2260
|
+
var queryClient = useQueryClient();
|
|
2261
|
+
var _useReorderQuestions = useReorderQuestions(id, {
|
|
2262
|
+
onSuccess: showThumbsUpToastr
|
|
2263
|
+
}),
|
|
2264
|
+
reorderQuestions = _useReorderQuestions.mutate,
|
|
2265
|
+
isReordering = _useReorderQuestions.isPending;
|
|
2266
|
+
var _useFetchQuestions = useFetchQuestions({
|
|
2267
|
+
formId: id,
|
|
2268
|
+
language: selectedLanguage
|
|
2269
|
+
}),
|
|
2270
|
+
data = _useFetchQuestions.data,
|
|
2271
|
+
isLoading = _useFetchQuestions.isLoading,
|
|
2272
|
+
isQuestionsPending = _useFetchQuestions.isPending;
|
|
2273
|
+
var _ref2 = data || QUESTIONS_INITIAL_VALUE,
|
|
2274
|
+
isFormEnabled = _ref2.enabled,
|
|
2275
|
+
savedTitle = _ref2.title,
|
|
2276
|
+
questions = _ref2.questions,
|
|
2277
|
+
isQuestionsLoading = _ref2.isQuestionsLoading;
|
|
2278
|
+
useEffect(function () {
|
|
2279
|
+
if (data) {
|
|
2280
|
+
onUpdate === null || onUpdate === void 0 || onUpdate(data);
|
|
2281
|
+
}
|
|
2282
|
+
}, [data]);
|
|
2283
|
+
if (isLoading || showLoader && isQuestionsLoading && !isQuestionsPending) {
|
|
2284
|
+
return /*#__PURE__*/jsx("div", {
|
|
2285
|
+
className: "flex h-full w-full items-center justify-center py-6",
|
|
2286
|
+
children: /*#__PURE__*/jsx(PageLoader, {})
|
|
2287
|
+
});
|
|
2288
|
+
}
|
|
2289
|
+
var handleSubmit = function handleSubmit(_ref3, _ref4) {
|
|
2290
|
+
var questions = _ref3.questions;
|
|
2291
|
+
var setSubmitting = _ref4.setSubmitting;
|
|
2292
|
+
var payload = {
|
|
2293
|
+
neetoFormQuestions: {
|
|
2294
|
+
questions: buildReorderPayload(questions)
|
|
2295
|
+
}
|
|
2296
|
+
};
|
|
2297
|
+
reorderQuestions(payload, {
|
|
2298
|
+
onSettled: function onSettled() {
|
|
2299
|
+
return setSubmitting(false);
|
|
2300
|
+
}
|
|
2301
|
+
});
|
|
2302
|
+
};
|
|
2303
|
+
var onValueChange = function onValueChange(questions) {
|
|
2304
|
+
var _queryClient$getQuery = queryClient.getQueryState([QUERY_KEYS.QUESTIONS, id, selectedLanguage]),
|
|
2305
|
+
dataUpdateCount = _queryClient$getQuery.dataUpdateCount;
|
|
2306
|
+
if (dataUpdateCount > 0) {
|
|
2307
|
+
queryClient.setQueryData([QUERY_KEYS.QUESTIONS, "preview/".concat(id), selectedLanguage], assoc("questions", questions));
|
|
2308
|
+
}
|
|
2309
|
+
};
|
|
2310
|
+
var isDeletable = isQuestionDeletable !== null && isQuestionDeletable !== void 0 ? isQuestionDeletable : function (question) {
|
|
2311
|
+
return !nonRemovableFields.includes(question.kind);
|
|
2312
|
+
};
|
|
2313
|
+
var isRequiredField = isFieldRequired !== null && isFieldRequired !== void 0 ? isFieldRequired : function (_ref5) {
|
|
2314
|
+
var kind = _ref5.kind;
|
|
2315
|
+
return concat(MANDATORY_KINDS, requiredFields).includes(kind);
|
|
2316
|
+
};
|
|
2317
|
+
var isDisabledFieldLabel = isFieldLabelDisabled !== null && isFieldLabelDisabled !== void 0 ? isFieldLabelDisabled : function () {
|
|
2318
|
+
return false;
|
|
2319
|
+
};
|
|
2320
|
+
var defaultQuestionKinds = allowAdditionalGuests ? QUESTION_KINDS : removeBy({
|
|
2321
|
+
type: QUESTION_KIND.ADDITIONAL_GUESTS.value
|
|
2322
|
+
}, QUESTION_KINDS);
|
|
2323
|
+
return /*#__PURE__*/jsxs("div", {
|
|
2324
|
+
className: classnames("neeto-form-nano-form-outer-wrapper relative", className),
|
|
2325
|
+
children: [/*#__PURE__*/jsx(Formik, {
|
|
2326
|
+
enableReinitialize: true,
|
|
2327
|
+
initialValues: {
|
|
2328
|
+
questions: questions
|
|
2329
|
+
},
|
|
2330
|
+
onSubmit: handleSubmit,
|
|
2331
|
+
children: function children(_ref6) {
|
|
2332
|
+
var errors = _ref6.errors,
|
|
2333
|
+
setFieldError = _ref6.setFieldError;
|
|
2334
|
+
return /*#__PURE__*/jsx(Form, _objectSpread(_objectSpread({}, _objectSpread(_objectSpread({}, formDomProps), {}, {
|
|
2335
|
+
additionalActionOptions: additionalActionOptions,
|
|
2336
|
+
additionalQuestionKindPattern: additionalQuestionKindPattern,
|
|
2337
|
+
availableLanguages: availableLanguages,
|
|
2338
|
+
buildRequestArgs: buildRequestArgs,
|
|
2339
|
+
cancelButtonProps: cancelButtonProps,
|
|
2340
|
+
disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
|
|
2341
|
+
domainRestrictionHelpDocUrl: domainRestrictionHelpDocUrl,
|
|
2342
|
+
enableDomainRestriction: enableDomainRestriction,
|
|
2343
|
+
enableFieldCode: enableFieldCode,
|
|
2344
|
+
fieldCodeHelpDocUrl: fieldCodeHelpDocUrl,
|
|
2345
|
+
formDescription: formDescription,
|
|
2346
|
+
formTitle: formTitle,
|
|
2347
|
+
getActiveKindDetails: getActiveKindDetails,
|
|
2348
|
+
isDeletable: isDeletable,
|
|
2349
|
+
isDisabledFieldLabel: isDisabledFieldLabel,
|
|
2350
|
+
isFormEnabled: isFormEnabled,
|
|
2351
|
+
isKindAlreadyActive: isKindAlreadyActive,
|
|
2352
|
+
isReordering: isReordering,
|
|
2353
|
+
isRequiredField: isRequiredField,
|
|
2354
|
+
kindUniqueOn: kindUniqueOn,
|
|
2355
|
+
onLanguageChange: onLanguageChange,
|
|
2356
|
+
onValueChange: onValueChange,
|
|
2357
|
+
savedTitle: savedTitle,
|
|
2358
|
+
selectedLanguage: selectedLanguage,
|
|
2359
|
+
showActionBlock: showActionBlock,
|
|
2360
|
+
submitButtonProps: submitButtonProps
|
|
2361
|
+
})), {}, {
|
|
2362
|
+
formId: id,
|
|
2363
|
+
questionKinds: isNil(questionKinds) ? defaultQuestionKinds : questionKinds,
|
|
2364
|
+
onChange: function onChange(event) {
|
|
2365
|
+
if (isEmpty(errors)) return;
|
|
2366
|
+
setFieldError(event.target.name);
|
|
2367
|
+
}
|
|
2368
|
+
}));
|
|
2369
|
+
}
|
|
2370
|
+
}), isQuestionsLoading && !isQuestionsPending && /*#__PURE__*/jsx("div", {
|
|
2371
|
+
className: "neeto-ui-bg-white absolute inset-0 flex items-center justify-center",
|
|
2372
|
+
children: /*#__PURE__*/jsx(PageLoader, {})
|
|
2373
|
+
})]
|
|
2374
|
+
});
|
|
2375
|
+
};
|
|
2376
|
+
|
|
2377
|
+
export { BuildForm as default };
|
|
2378
|
+
//# sourceMappingURL=BuildForm.js.map
|