@bigbinary/neeto-form-frontend 4.3.0 → 4.4.0
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 +39 -3
- package/dist/BuildForm.js +480 -86
- package/dist/BuildForm.js.map +1 -1
- package/dist/ExternalForm.js +7 -7
- package/dist/Submission.js +32 -1
- package/dist/Submission.js.map +1 -1
- package/dist/UrlBuilder.js +8 -8
- package/dist/UrlBuilder.js.map +1 -1
- package/dist/{buildForm-vzjjarhs.js → buildForm-Bdc3ubm4.js} +2 -2
- package/dist/{buildForm-vzjjarhs.js.map → buildForm-Bdc3ubm4.js.map} +1 -1
- package/dist/{buildForm-DA1LRDwr.js → buildForm-CkVmGF-A.js} +2 -2
- package/dist/{buildForm-DA1LRDwr.js.map → buildForm-CkVmGF-A.js.map} +1 -1
- package/dist/cjs/BuildForm.js +552 -158
- package/dist/cjs/BuildForm.js.map +1 -1
- package/dist/cjs/ExternalForm.js +21 -21
- package/dist/cjs/ExternalForm.js.map +1 -1
- package/dist/cjs/Submission.js +32 -1
- package/dist/cjs/Submission.js.map +1 -1
- package/dist/cjs/UrlBuilder.js +19 -19
- package/dist/cjs/UrlBuilder.js.map +1 -1
- package/dist/cjs/hooks.js +4 -4
- package/dist/cjs/index.js +11 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/{constants-B_OEW8Yc.js → constants-30230o5k.js} +3 -2
- package/dist/constants-30230o5k.js.map +1 -0
- package/dist/{constants-DcN-Mvx7.js → constants-DNNZYQ9X.js} +3 -2
- package/dist/constants-DNNZYQ9X.js.map +1 -0
- package/dist/hooks.js +4 -4
- package/dist/{index-DGvqFcqA.js → index-BfavwyMH.js} +2 -2
- package/dist/{index-DGvqFcqA.js.map → index-BfavwyMH.js.map} +1 -1
- package/dist/{index-BQf-XQOv.js → index-Dz5Yvk3n.js} +2 -2
- package/dist/{index-BQf-XQOv.js.map → index-Dz5Yvk3n.js.map} +1 -1
- package/dist/index.js +11 -10
- package/dist/index.js.map +1 -1
- package/dist/main.css +1 -1
- package/dist/main.css.map +1 -1
- package/dist/{useFormSubmission-C7RL4Doz.js → useFormSubmission-CdKlP6De.js} +2 -2
- package/dist/{useFormSubmission-C7RL4Doz.js.map → useFormSubmission-CdKlP6De.js.map} +1 -1
- package/dist/{useFormSubmission-CzjIcsVB.js → useFormSubmission-zyh3tA0H.js} +2 -2
- package/dist/{useFormSubmission-CzjIcsVB.js.map → useFormSubmission-zyh3tA0H.js.map} +1 -1
- package/dist/{utils-BgH6USlj.js → utils-CDyve_0y.js} +147 -61
- package/dist/utils-CDyve_0y.js.map +1 -0
- package/dist/{utils-CjySOwOO.js → utils-DfujkkDT.js} +198 -112
- package/dist/utils-DfujkkDT.js.map +1 -0
- package/dist/{constants-BEKfDeAd.js → yup-DcJey7xZ.js} +99 -4
- package/dist/yup-DcJey7xZ.js.map +1 -0
- package/dist/{constants-Dcy0vCkf.js → yup-SHH_PrTm.js} +92 -6
- package/dist/yup-SHH_PrTm.js.map +1 -0
- package/package.json +3 -1
- package/dist/constants-BEKfDeAd.js.map +0 -1
- package/dist/constants-B_OEW8Yc.js.map +0 -1
- package/dist/constants-DcN-Mvx7.js.map +0 -1
- package/dist/constants-Dcy0vCkf.js.map +0 -1
- package/dist/utils-BgH6USlj.js.map +0 -1
- package/dist/utils-CjySOwOO.js.map +0 -1
package/dist/cjs/BuildForm.js
CHANGED
|
@@ -5,14 +5,14 @@ var classnames = require('classnames');
|
|
|
5
5
|
var neetoCist = require('@bigbinary/neeto-cist');
|
|
6
6
|
var Spinner = require('@bigbinary/neetoui/Spinner');
|
|
7
7
|
var ramda = require('ramda');
|
|
8
|
-
var constants = require('../constants-
|
|
9
|
-
var
|
|
8
|
+
var constants = require('../constants-DNNZYQ9X.js');
|
|
9
|
+
var yup = require('../yup-DcJey7xZ.js');
|
|
10
10
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
11
11
|
var React = require('react');
|
|
12
12
|
var dnd = require('@hello-pangea/dnd');
|
|
13
13
|
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
14
14
|
var utils = require('@bigbinary/neeto-commons-frontend/utils');
|
|
15
|
-
var buildForm = require('../buildForm-
|
|
15
|
+
var buildForm = require('../buildForm-Bdc3ubm4.js');
|
|
16
16
|
var shallow = require('zustand/shallow');
|
|
17
17
|
var Alert = require('@bigbinary/neetoui/Alert');
|
|
18
18
|
var reactI18next = require('react-i18next');
|
|
@@ -23,13 +23,13 @@ var MoreDropdown = require('@bigbinary/neeto-molecules/MoreDropdown');
|
|
|
23
23
|
var Dropdown = require('@bigbinary/neetoui/Dropdown');
|
|
24
24
|
var Tooltip = require('@bigbinary/neetoui/Tooltip');
|
|
25
25
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
26
|
-
var index = require('../index-
|
|
26
|
+
var index = require('../index-Dz5Yvk3n.js');
|
|
27
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
27
28
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
28
29
|
var i18next = require('i18next');
|
|
29
30
|
var uuid = require('uuid');
|
|
30
31
|
var NoData = require('@bigbinary/neetoui/NoData');
|
|
31
32
|
var Button = require('@bigbinary/neetoui/Button');
|
|
32
|
-
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
33
33
|
var Pane = require('@bigbinary/neetoui/Pane');
|
|
34
34
|
var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
|
|
35
35
|
var Form$2 = require('@bigbinary/neetoui/formik/Form');
|
|
@@ -41,7 +41,9 @@ var Textarea = require('@bigbinary/neetoui/formik/Textarea');
|
|
|
41
41
|
var NeetoEditor = require('@bigbinary/neeto-editor/Editor');
|
|
42
42
|
var Input = require('@bigbinary/neetoui/formik/Input');
|
|
43
43
|
var utils$1 = require('@bigbinary/neeto-editor/utils');
|
|
44
|
-
var yup = require('yup');
|
|
44
|
+
var yup$1 = require('yup');
|
|
45
|
+
var OptionFields = require('@bigbinary/neeto-molecules/OptionFields');
|
|
46
|
+
var framerMotion = require('framer-motion');
|
|
45
47
|
var Radio = require('@bigbinary/neetoui/formik/Radio');
|
|
46
48
|
var Label = require('@bigbinary/neetoui/Label');
|
|
47
49
|
var CreatableSelect = require('react-select/creatable');
|
|
@@ -53,7 +55,6 @@ var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
|
53
55
|
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
54
56
|
var Checkbox$1 = require('@bigbinary/neetoui/formik/Checkbox');
|
|
55
57
|
var Checkbox = require('@bigbinary/neetoui/Checkbox');
|
|
56
|
-
var OptionFields = require('@bigbinary/neeto-molecules/OptionFields');
|
|
57
58
|
var Slider = require('@bigbinary/neetoui/Slider');
|
|
58
59
|
var HelpPopover = require('@bigbinary/neeto-molecules/HelpPopover');
|
|
59
60
|
require('@bigbinary/neeto-commons-frontend/constants');
|
|
@@ -80,7 +81,7 @@ function _interopNamespaceDefault(e) {
|
|
|
80
81
|
return Object.freeze(n);
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
|
|
84
|
+
var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup$1);
|
|
84
85
|
|
|
85
86
|
var DeleteAlert = function DeleteAlert(_ref) {
|
|
86
87
|
var selectedQuestion = _ref.selectedQuestion,
|
|
@@ -101,9 +102,9 @@ var DeleteAlert = function DeleteAlert(_ref) {
|
|
|
101
102
|
onMutateSuccess = _useBuildFormStore.onMutateSuccess;
|
|
102
103
|
var renderQuestionLabel = function renderQuestionLabel() {
|
|
103
104
|
var questionKind = selectedQuestion.kind;
|
|
104
|
-
var independentLabel =
|
|
105
|
+
var independentLabel = yup.INDEPENDENT_LABELS_MAP[questionKind];
|
|
105
106
|
if (neetoCist.isPresent(independentLabel)) return independentLabel;
|
|
106
|
-
var questionLabel =
|
|
107
|
+
var questionLabel = yup.buildDisplayLabel(selectedQuestion);
|
|
107
108
|
return neetoCist.truncate(questionLabel, 40);
|
|
108
109
|
};
|
|
109
110
|
var _useDeleteQuestion = constants.useDeleteQuestion(selectedQuestion === null || selectedQuestion === void 0 ? void 0 : selectedQuestion.formId, selectedLanguage, {
|
|
@@ -112,7 +113,7 @@ var DeleteAlert = function DeleteAlert(_ref) {
|
|
|
112
113
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
113
114
|
args[_key] = arguments[_key];
|
|
114
115
|
}
|
|
115
|
-
onMutateSuccess === null || onMutateSuccess === void 0 || onMutateSuccess.apply(void 0, [
|
|
116
|
+
onMutateSuccess === null || onMutateSuccess === void 0 || onMutateSuccess.apply(void 0, [yup.QUESTION_ACTIONS.DELETE].concat(args));
|
|
116
117
|
onClose();
|
|
117
118
|
}
|
|
118
119
|
}),
|
|
@@ -283,11 +284,11 @@ var Card = function Card(_ref) {
|
|
|
283
284
|
item: question
|
|
284
285
|
}),
|
|
285
286
|
isSingular = _getActiveKindDetails.isSingular;
|
|
286
|
-
var questionLabel =
|
|
287
|
+
var questionLabel = yup.buildDisplayLabel(question);
|
|
287
288
|
React.useEffect(function () {
|
|
288
289
|
var element = questionLabelRef.current;
|
|
289
290
|
if (neetoCist.isNotPresent(element)) return;
|
|
290
|
-
setIsTooltipEnabled(
|
|
291
|
+
setIsTooltipEnabled(yup.isElementOverflowing(element));
|
|
291
292
|
}, [questionLabel]);
|
|
292
293
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
293
294
|
"data-testid": "neeto-form-engine-".concat(neetoCist.slugify(questionLabel)),
|
|
@@ -299,7 +300,7 @@ var Card = function Card(_ref) {
|
|
|
299
300
|
},
|
|
300
301
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
301
302
|
className: "flex min-w-0 grow items-center gap-1",
|
|
302
|
-
children: [canManageQuestions && /*#__PURE__*/jsxRuntime.jsx(
|
|
303
|
+
children: [canManageQuestions && /*#__PURE__*/jsxRuntime.jsx(yup.Drag, {
|
|
303
304
|
className: "neeto-ui-text-gray-600 shrink-0"
|
|
304
305
|
}), /*#__PURE__*/jsxRuntime.jsx(Tooltip, {
|
|
305
306
|
content: questionLabel,
|
|
@@ -346,8 +347,8 @@ var Card = function Card(_ref) {
|
|
|
346
347
|
});
|
|
347
348
|
};
|
|
348
349
|
|
|
349
|
-
function ownKeys$
|
|
350
|
-
function _objectSpread$
|
|
350
|
+
function ownKeys$i(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
351
|
+
function _objectSpread$i(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$i(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$i(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
351
352
|
var Questions = function Questions(_ref) {
|
|
352
353
|
var questions = _ref.questions,
|
|
353
354
|
isDeletable = _ref.isDeletable,
|
|
@@ -366,7 +367,7 @@ var Questions = function Questions(_ref) {
|
|
|
366
367
|
var droppableProps = _ref2.droppableProps,
|
|
367
368
|
placeholder = _ref2.placeholder,
|
|
368
369
|
innerRef = _ref2.innerRef;
|
|
369
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread$
|
|
370
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread$i(_objectSpread$i({}, droppableProps), {}, {
|
|
370
371
|
className: "space-y-2",
|
|
371
372
|
ref: innerRef,
|
|
372
373
|
children: [questions.map(function (question, index) {
|
|
@@ -380,7 +381,7 @@ var Questions = function Questions(_ref) {
|
|
|
380
381
|
var draggableProps = _ref3.draggableProps,
|
|
381
382
|
dragHandleProps = _ref3.dragHandleProps,
|
|
382
383
|
innerRef = _ref3.innerRef;
|
|
383
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread$
|
|
384
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread$i(_objectSpread$i(_objectSpread$i({}, draggableProps), dragHandleProps), {}, {
|
|
384
385
|
ref: innerRef,
|
|
385
386
|
children: /*#__PURE__*/jsxRuntime.jsx(Card, {
|
|
386
387
|
allQuestionKinds: allQuestionKinds,
|
|
@@ -413,16 +414,20 @@ var arrayHelpers = {
|
|
|
413
414
|
moveItem: moveItem
|
|
414
415
|
};
|
|
415
416
|
|
|
416
|
-
|
|
417
|
-
function
|
|
417
|
+
var _excluded$b = ["fields"];
|
|
418
|
+
function ownKeys$h(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
419
|
+
function _objectSpread$h(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$h(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$h(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
418
420
|
var isChoiceQuestion = function isChoiceQuestion(question) {
|
|
419
|
-
return ramda.includes(question === null || question === void 0 ? void 0 : question.kind,
|
|
421
|
+
return ramda.includes(question === null || question === void 0 ? void 0 : question.kind, yup.SELECTABLE_KINDS);
|
|
422
|
+
};
|
|
423
|
+
var isAddressQuestion = function isAddressQuestion(question) {
|
|
424
|
+
return (question === null || question === void 0 ? void 0 : question.kind) === constants.QUESTION_TYPES.ADDRESS;
|
|
420
425
|
};
|
|
421
426
|
var underscoredWithoutSpecialCharacters = function underscoredWithoutSpecialCharacters(string) {
|
|
422
427
|
return string.toLowerCase().replace(/[\s-]/g, "_").replace(/[\W]/gi, "").replace(/_+/g, "_").replace(/^_+|_+$/, "");
|
|
423
428
|
};
|
|
424
429
|
var addSuffixForReservedFieldCode = function addSuffixForReservedFieldCode(fieldCode) {
|
|
425
|
-
return
|
|
430
|
+
return yup.RESERVED_FIELD_CODES.includes(fieldCode) ? "".concat(fieldCode, "_field") : fieldCode;
|
|
426
431
|
};
|
|
427
432
|
var getUniqueNumbersFromExistingFieldCodes = function getUniqueNumbersFromExistingFieldCodes(prefix, questions) {
|
|
428
433
|
return questions.filter(function (question) {
|
|
@@ -433,7 +438,7 @@ var getUniqueNumbersFromExistingFieldCodes = function getUniqueNumbersFromExisti
|
|
|
433
438
|
};
|
|
434
439
|
var generateFieldCodePrefix = function generateFieldCodePrefix(label, kind) {
|
|
435
440
|
var prefix;
|
|
436
|
-
if (index.isNameQuestion(kind) ||
|
|
441
|
+
if (index.isNameQuestion(kind) || yup.NON_BASIC_LATIN_CHARACTERS_REGEX.test(label) || ramda.isEmpty(label)) {
|
|
437
442
|
prefix = kind;
|
|
438
443
|
} else {
|
|
439
444
|
var sanitizedLabel = underscoredWithoutSpecialCharacters(label).slice(0, 30);
|
|
@@ -441,18 +446,15 @@ var generateFieldCodePrefix = function generateFieldCodePrefix(label, kind) {
|
|
|
441
446
|
}
|
|
442
447
|
return addSuffixForReservedFieldCode(prefix) || "";
|
|
443
448
|
};
|
|
444
|
-
var renameKey = ramda.curry(function (oldKey, newKey, obj) {
|
|
445
|
-
return ramda.assoc(newKey, ramda.prop(oldKey, obj), ramda.dissoc(oldKey, obj));
|
|
446
|
-
});
|
|
447
449
|
var modifyDefaultValues = function modifyDefaultValues(_ref) {
|
|
448
450
|
var values = _ref.values,
|
|
449
451
|
kind = _ref.kind,
|
|
450
452
|
selectedLanguage = _ref.selectedLanguage,
|
|
451
453
|
isUsingDefaultQuestionKinds = _ref.isUsingDefaultQuestionKinds;
|
|
452
454
|
if (index.isNameQuestion(kind)) {
|
|
453
|
-
return renameKey(
|
|
455
|
+
return yup.renameKey(yup.LABEL_FIELDS.DEFAULT, yup.LABEL_FIELDS.FULL_NAME, values);
|
|
454
456
|
}
|
|
455
|
-
if (!ramda.includes(kind,
|
|
457
|
+
if (!ramda.includes(kind, yup.SELECTABLE_KINDS) || yup.isDefaultLanguage(selectedLanguage) || !isUsingDefaultQuestionKinds) {
|
|
456
458
|
return values;
|
|
457
459
|
}
|
|
458
460
|
return ramda.evolve({
|
|
@@ -496,7 +498,7 @@ var handleFieldDragEnd = function handleFieldDragEnd(_ref4) {
|
|
|
496
498
|
var nextItems = _toConsumableArray(items);
|
|
497
499
|
arrayHelpers.moveItem(nextItems, source.index, destination.index);
|
|
498
500
|
var orderedItems = nextItems.map(function (item, index) {
|
|
499
|
-
return _objectSpread$
|
|
501
|
+
return _objectSpread$h(_objectSpread$h({}, item), {}, {
|
|
500
502
|
displayOrder: index
|
|
501
503
|
});
|
|
502
504
|
});
|
|
@@ -518,7 +520,7 @@ var createFieldData = function createFieldData(_ref5) {
|
|
|
518
520
|
selectedLanguage: selectedLanguage,
|
|
519
521
|
isUsingDefaultQuestionKinds: isUsingDefaultQuestionKinds
|
|
520
522
|
});
|
|
521
|
-
return _objectSpread$
|
|
523
|
+
return _objectSpread$h(_objectSpread$h({}, modifiedDefaultValues), {}, {
|
|
522
524
|
metadata: metadata,
|
|
523
525
|
isRequired: isRequired,
|
|
524
526
|
kind: type,
|
|
@@ -542,15 +544,18 @@ var duplicateFieldData = function duplicateFieldData(_ref6) {
|
|
|
542
544
|
}, questionKinds);
|
|
543
545
|
var label = index.fieldWithFallback(item, "label");
|
|
544
546
|
var defaultAttributeNames = ramda.keys(questionKind.defaults || {});
|
|
545
|
-
var
|
|
546
|
-
|
|
547
|
+
var _pick = ramda.pick(defaultAttributeNames, item),
|
|
548
|
+
fields = _pick.fields,
|
|
549
|
+
defaultAttributes = _objectWithoutProperties(_pick, _excluded$b);
|
|
550
|
+
var newQuestionLabel = yup.isRichTextQuestion(kind) ? label : i18next.t("neetoForm.common.clonedElementLabel", {
|
|
547
551
|
label: label
|
|
548
552
|
});
|
|
549
|
-
return _objectSpread$
|
|
553
|
+
return _objectSpread$h(_objectSpread$h({}, defaultAttributes), {}, {
|
|
550
554
|
isRequired: isRequired,
|
|
551
555
|
kind: kind,
|
|
552
556
|
label: newQuestionLabel,
|
|
553
557
|
optionsAttributes: optionsAttributes && optionsAttributes.map(ramda.omit(["id"])),
|
|
558
|
+
fieldsAttributes: fields && fields.map(ramda.omit(["id"])),
|
|
554
559
|
nodeId: uuid.v4(),
|
|
555
560
|
fieldCode: generateUniqueFieldCode({
|
|
556
561
|
questions: questions,
|
|
@@ -568,13 +573,15 @@ var getAvailableQuestionKinds = function getAvailableQuestionKinds(_ref7) {
|
|
|
568
573
|
if (ramda.isEmpty(activeQuestions)) return allQuestionKinds;
|
|
569
574
|
return ramda.reject(function (kind) {
|
|
570
575
|
var isSingularKind = kind.isSingular;
|
|
571
|
-
return
|
|
576
|
+
return yup.isAutoGeneratedQuestion(kind.type) || isSingularKind && isKindAlreadyActive({
|
|
572
577
|
activeQuestions: activeQuestions,
|
|
573
578
|
kind: kind
|
|
574
579
|
});
|
|
575
580
|
}, allQuestionKinds);
|
|
576
581
|
};
|
|
577
|
-
var formatQuestionAttributesForClone = ramda.when(
|
|
582
|
+
var formatQuestionAttributesForClone = ramda.when(function (question) {
|
|
583
|
+
return isChoiceQuestion(question) || isAddressQuestion(question);
|
|
584
|
+
}, ramda.assoc("isCloning", true));
|
|
578
585
|
|
|
579
586
|
var HelpText = reactUtils.withT(function (_ref) {
|
|
580
587
|
var t = _ref.t,
|
|
@@ -605,7 +612,7 @@ var AddFirstQuestion = function AddFirstQuestion(_ref) {
|
|
|
605
612
|
helpText: neetoCist.isPresent(href) ? /*#__PURE__*/jsxRuntime.jsx(HelpText, {
|
|
606
613
|
href: href
|
|
607
614
|
}) : null,
|
|
608
|
-
primaryButtonProps:
|
|
615
|
+
primaryButtonProps: yup.buildAddQuestionButtonProps(onAdd, isDisabled),
|
|
609
616
|
title: t("neetoForm.questions.common.noData")
|
|
610
617
|
})
|
|
611
618
|
});
|
|
@@ -626,8 +633,9 @@ var NAME = constants.QUESTION_TYPES.NAME,
|
|
|
626
633
|
DATE = constants.QUESTION_TYPES.DATE,
|
|
627
634
|
FILE_UPLOAD$1 = constants.QUESTION_TYPES.FILE_UPLOAD,
|
|
628
635
|
CAPTCHA$1 = constants.QUESTION_TYPES.CAPTCHA,
|
|
629
|
-
SMS_REMINDER = constants.QUESTION_TYPES.SMS_REMINDER
|
|
630
|
-
|
|
636
|
+
SMS_REMINDER = constants.QUESTION_TYPES.SMS_REMINDER,
|
|
637
|
+
ADDRESS$1 = constants.QUESTION_TYPES.ADDRESS;
|
|
638
|
+
var QUESTIONS_WITH_ADDITIONAL_DATA = [].concat(_toConsumableArray(yup.SELECTABLE_KINDS), [STAR_RATING$1, OPINION_SCALE$1, RATING$1, FILE_UPLOAD$1, CAPTCHA$1, EMAIL$1, ADDRESS$1]);
|
|
631
639
|
var QUESTIONS_WITH_PLACEHOLDERS = [NAME, PHONE, EMAIL$1, ADDITIONAL_GUESTS, TEXT, TEXTAREA, RICH_TEXT, INTEGER, DECIMAL, DATE, SMS_REMINDER];
|
|
632
640
|
var DEFAULT_PLACEHOLDERS = {
|
|
633
641
|
CHECKBOX: i18next.t("neetoForm.questions.common.questionFields.field.labelExample", {
|
|
@@ -647,18 +655,19 @@ var INITIAL_VALUES = {
|
|
|
647
655
|
isSplitMode: false
|
|
648
656
|
};
|
|
649
657
|
var VALID_FIELD_CODE_REGEX = /^[a-z0-9]+(_[a-z0-9]+)*$/;
|
|
658
|
+
var DRAFT_ID_PREFIX = "draft-";
|
|
650
659
|
|
|
651
660
|
var useHelpDoc = function useHelpDoc(key) {
|
|
652
661
|
return buildForm.useBuildFormStore(ramda.path(["formState", "helpDocUrls", key]));
|
|
653
662
|
};
|
|
654
663
|
|
|
655
|
-
var _excluded$
|
|
656
|
-
function ownKeys$
|
|
657
|
-
function _objectSpread$
|
|
664
|
+
var _excluded$a = ["label", "name"];
|
|
665
|
+
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; }
|
|
666
|
+
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; }
|
|
658
667
|
var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
|
|
659
668
|
var label = _ref.label,
|
|
660
669
|
name = _ref.name,
|
|
661
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
670
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$a);
|
|
662
671
|
var _useFormikContext = formik.useFormikContext(),
|
|
663
672
|
dirty = _useFormikContext.dirty,
|
|
664
673
|
isValid = _useFormikContext.isValid,
|
|
@@ -673,7 +682,7 @@ var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
|
|
|
673
682
|
var end = element.value.length;
|
|
674
683
|
element.setSelectionRange(end, end);
|
|
675
684
|
};
|
|
676
|
-
return /*#__PURE__*/jsxRuntime.jsx(Textarea, _objectSpread$
|
|
685
|
+
return /*#__PURE__*/jsxRuntime.jsx(Textarea, _objectSpread$g({
|
|
677
686
|
label: label,
|
|
678
687
|
name: name,
|
|
679
688
|
className: "neeto-form-nano-adaptive-input",
|
|
@@ -687,8 +696,8 @@ var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
|
|
|
687
696
|
}, otherProps));
|
|
688
697
|
};
|
|
689
698
|
|
|
690
|
-
function ownKeys$
|
|
691
|
-
function _objectSpread$
|
|
699
|
+
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; }
|
|
700
|
+
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; }
|
|
692
701
|
var LabelWithPlaceholder = function LabelWithPlaceholder(_ref) {
|
|
693
702
|
var kind = _ref.kind,
|
|
694
703
|
isLabelDisabled = _ref.isLabelDisabled,
|
|
@@ -702,14 +711,14 @@ var LabelWithPlaceholder = function LabelWithPlaceholder(_ref) {
|
|
|
702
711
|
var shouldShowPlaceholder = ramda.includes(kind, QUESTIONS_WITH_PLACEHOLDERS);
|
|
703
712
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
704
713
|
className: "space-y-4",
|
|
705
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(FormikAdaptiveInput, _objectSpread$
|
|
714
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(FormikAdaptiveInput, _objectSpread$f({
|
|
706
715
|
required: true,
|
|
707
716
|
disabled: isLabelDisabled,
|
|
708
717
|
label: t("neetoForm.questions.common.questionFields.field.question"),
|
|
709
718
|
name: "label",
|
|
710
719
|
placeholder: DEFAULT_PLACEHOLDERS[kind],
|
|
711
720
|
onChange: utils.withEventTargetValue(handleLabelChange)
|
|
712
|
-
}, labelProps)), shouldShowPlaceholder && /*#__PURE__*/jsxRuntime.jsx(FormikAdaptiveInput, _objectSpread$
|
|
721
|
+
}, labelProps)), shouldShowPlaceholder && /*#__PURE__*/jsxRuntime.jsx(FormikAdaptiveInput, _objectSpread$f({
|
|
713
722
|
className: "neeto-form-nano-placeholder-input neeto-form-nano-placeholder-input-".concat(kind),
|
|
714
723
|
name: "placeholder",
|
|
715
724
|
label: t("neetoForm.questions.common.questionFields.field.placeholder")
|
|
@@ -717,8 +726,8 @@ var LabelWithPlaceholder = function LabelWithPlaceholder(_ref) {
|
|
|
717
726
|
});
|
|
718
727
|
};
|
|
719
728
|
|
|
720
|
-
function ownKeys$
|
|
721
|
-
function _objectSpread$
|
|
729
|
+
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; }
|
|
730
|
+
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; }
|
|
722
731
|
var Name = function Name(_ref) {
|
|
723
732
|
var isLabelDisabled = _ref.isLabelDisabled,
|
|
724
733
|
_handleLabelChange = _ref.handleLabelChange;
|
|
@@ -738,40 +747,40 @@ var Name = function Name(_ref) {
|
|
|
738
747
|
label: t("neetoForm.common.splitAsFirstAndLastNames"),
|
|
739
748
|
name: "isSplitMode"
|
|
740
749
|
}), isSplitMode && !usesCustomSubmissionComponent ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
741
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, _objectSpread$
|
|
750
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, _objectSpread$e(_objectSpread$e({}, commonProps), {}, {
|
|
742
751
|
handleLabelChange: function handleLabelChange(value) {
|
|
743
|
-
return _handleLabelChange(value,
|
|
752
|
+
return _handleLabelChange(value, yup.LABEL_FIELDS.FIRST_NAME);
|
|
744
753
|
},
|
|
745
754
|
labelProps: {
|
|
746
755
|
label: t("neetoForm.questions.common.questionFields.field.firstNameQuestion"),
|
|
747
|
-
name:
|
|
756
|
+
name: yup.LABEL_FIELDS.FIRST_NAME
|
|
748
757
|
},
|
|
749
758
|
placeholderProps: {
|
|
750
759
|
label: t("neetoForm.questions.common.questionFields.field.firstNamePlaceholder"),
|
|
751
760
|
name: "firstNamePlaceholder"
|
|
752
761
|
}
|
|
753
|
-
})), /*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, _objectSpread$
|
|
762
|
+
})), /*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, _objectSpread$e(_objectSpread$e({}, commonProps), {}, {
|
|
754
763
|
handleLabelChange: function handleLabelChange(value) {
|
|
755
|
-
return _handleLabelChange(value,
|
|
764
|
+
return _handleLabelChange(value, yup.LABEL_FIELDS.LAST_NAME);
|
|
756
765
|
},
|
|
757
766
|
labelProps: {
|
|
758
767
|
label: t("neetoForm.questions.common.questionFields.field.lastNameQuestion"),
|
|
759
|
-
name:
|
|
768
|
+
name: yup.LABEL_FIELDS.LAST_NAME
|
|
760
769
|
},
|
|
761
770
|
placeholderProps: {
|
|
762
771
|
label: t("neetoForm.questions.common.questionFields.field.lastNamePlaceholder"),
|
|
763
772
|
name: "lastNamePlaceholder"
|
|
764
773
|
}
|
|
765
774
|
}))]
|
|
766
|
-
}) : /*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, _objectSpread$
|
|
775
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, _objectSpread$e(_objectSpread$e({}, commonProps), {}, {
|
|
767
776
|
labelProps: {
|
|
768
|
-
name:
|
|
777
|
+
name: yup.LABEL_FIELDS.FULL_NAME
|
|
769
778
|
},
|
|
770
779
|
placeholderProps: {
|
|
771
780
|
name: "fullNamePlaceholder"
|
|
772
781
|
},
|
|
773
782
|
handleLabelChange: function handleLabelChange(value) {
|
|
774
|
-
return _handleLabelChange(value,
|
|
783
|
+
return _handleLabelChange(value, yup.LABEL_FIELDS.FULL_NAME);
|
|
775
784
|
}
|
|
776
785
|
}))]
|
|
777
786
|
});
|
|
@@ -887,7 +896,7 @@ var Editor = function Editor() {
|
|
|
887
896
|
var fieldName = "label";
|
|
888
897
|
var _useField = formik.useField({
|
|
889
898
|
name: fieldName,
|
|
890
|
-
validate:
|
|
899
|
+
validate: yup.validateEditorContent(editorRef)
|
|
891
900
|
}),
|
|
892
901
|
_useField2 = _slicedToArray(_useField, 3),
|
|
893
902
|
value = _useField2[0].value,
|
|
@@ -930,12 +939,12 @@ var RequiredSwitch = reactUtils.withT(function (_ref) {
|
|
|
930
939
|
});
|
|
931
940
|
});
|
|
932
941
|
|
|
933
|
-
var _excluded$
|
|
934
|
-
function ownKeys$
|
|
935
|
-
function _objectSpread$
|
|
942
|
+
var _excluded$9 = ["maxLength"];
|
|
943
|
+
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; }
|
|
944
|
+
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; }
|
|
936
945
|
var InputWithMaxLength = function InputWithMaxLength(_ref) {
|
|
937
946
|
var maxLength = _ref.maxLength,
|
|
938
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
947
|
+
props = _objectWithoutProperties(_ref, _excluded$9);
|
|
939
948
|
var _useField = formik.useField(props),
|
|
940
949
|
_useField2 = _slicedToArray(_useField, 3),
|
|
941
950
|
value = _useField2[0].value,
|
|
@@ -946,7 +955,7 @@ var InputWithMaxLength = function InputWithMaxLength(_ref) {
|
|
|
946
955
|
}
|
|
947
956
|
}, [value, maxLength, setValue]);
|
|
948
957
|
var shouldShowMaxLength = value && value.length > maxLength - 10;
|
|
949
|
-
return /*#__PURE__*/jsxRuntime.jsx(Input, _objectSpread$
|
|
958
|
+
return /*#__PURE__*/jsxRuntime.jsx(Input, _objectSpread$d(_objectSpread$d({}, props), shouldShowMaxLength && {
|
|
950
959
|
maxLength: maxLength
|
|
951
960
|
}));
|
|
952
961
|
};
|
|
@@ -959,7 +968,7 @@ var FieldCode = function FieldCode() {
|
|
|
959
968
|
required: true,
|
|
960
969
|
label: t("neetoForm.questions.common.questionFields.field.fieldCode"),
|
|
961
970
|
name: "fieldCode",
|
|
962
|
-
rejectCharsRegex:
|
|
971
|
+
rejectCharsRegex: yup.FIELD_CODES_REJECT_CHARS_REGEX,
|
|
963
972
|
helpText: helpDocUrl && /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
964
973
|
i18nKey: "neetoForm.questions.common.questionFields.field.fieldCodeHelpDescription",
|
|
965
974
|
components: {
|
|
@@ -1039,11 +1048,11 @@ var Form$1 = function Form(_ref) {
|
|
|
1039
1048
|
}, [submitCount]);
|
|
1040
1049
|
var isRequired = questionKind && isRequiredField(questionKind);
|
|
1041
1050
|
var isLabelDisabled = questionKind && isDisabledFieldLabel(questionKind);
|
|
1042
|
-
var isImmutable = questionKind &&
|
|
1043
|
-
var shouldShowFieldCode = isFieldCodeEnabled && !ramda.includes(kind,
|
|
1044
|
-
var shouldShowHideSwitch = isFieldCodeEnabled && !usesCustomSubmissionComponent && !ramda.includes(kind,
|
|
1045
|
-
var canRestrictResponseVisibilityToHost = restrictResponseVisibilityToHost && !ramda.includes(kind,
|
|
1046
|
-
var canMarkResponsesAsReadOnly = markResponsesAsReadOnly && !ramda.includes(kind,
|
|
1051
|
+
var isImmutable = questionKind && yup.isImmutableField(questionKind);
|
|
1052
|
+
var shouldShowFieldCode = isFieldCodeEnabled && !ramda.includes(kind, yup.QUESTIONS_WITHOUT_FIELD_CODE);
|
|
1053
|
+
var shouldShowHideSwitch = isFieldCodeEnabled && !usesCustomSubmissionComponent && !ramda.includes(kind, yup.NON_HIDEABLE_FIELDS);
|
|
1054
|
+
var canRestrictResponseVisibilityToHost = restrictResponseVisibilityToHost && !ramda.includes(kind, yup.NON_HIDEABLE_FIELDS);
|
|
1055
|
+
var canMarkResponsesAsReadOnly = markResponsesAsReadOnly && !ramda.includes(kind, yup.NON_READ_ONLY_FIELDS);
|
|
1047
1056
|
var isBasicSettingsVisible = !isRequired && (!isImmutable || shouldShowHideSwitch);
|
|
1048
1057
|
var isSettingsBlockVisible = isBasicSettingsVisible || canMarkResponsesAsReadOnly;
|
|
1049
1058
|
var handleKindChange = function handleKindChange(option) {
|
|
@@ -1075,7 +1084,7 @@ var Form$1 = function Form(_ref) {
|
|
|
1075
1084
|
setTouched({});
|
|
1076
1085
|
};
|
|
1077
1086
|
var handleLabelChange = function handleLabelChange(label) {
|
|
1078
|
-
var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
1087
|
+
var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : yup.LABEL_FIELDS.DEFAULT;
|
|
1079
1088
|
setFieldValue(name, label);
|
|
1080
1089
|
if (isEdit) return;
|
|
1081
1090
|
var uniqueFieldCode = generateUniqueFieldCode({
|
|
@@ -1098,7 +1107,7 @@ var Form$1 = function Form(_ref) {
|
|
|
1098
1107
|
options: buildKindOptions(questionKinds),
|
|
1099
1108
|
label: t("neetoForm.questions.common.questionFields.field.questionType"),
|
|
1100
1109
|
onChange: handleKindChange
|
|
1101
|
-
}),
|
|
1110
|
+
}), yup.isRichTextQuestion(kind) ? /*#__PURE__*/jsxRuntime.jsx(Editor, {
|
|
1102
1111
|
isLabelDisabled: isLabelDisabled
|
|
1103
1112
|
}) : /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1104
1113
|
className: "space-y-6",
|
|
@@ -1111,7 +1120,7 @@ var Form$1 = function Form(_ref) {
|
|
|
1111
1120
|
dataTestid: "settings-card",
|
|
1112
1121
|
title: t("neetoForm.common.settings"),
|
|
1113
1122
|
children: [isBasicSettingsVisible && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1114
|
-
children: [!isImmutable && /*#__PURE__*/jsxRuntime.jsx(RequiredSwitch, {}), shouldShowHideSwitch && /*#__PURE__*/jsxRuntime.jsx(Switch, {
|
|
1123
|
+
children: [!isImmutable && kind !== constants.QUESTION_TYPES.ADDRESS && /*#__PURE__*/jsxRuntime.jsx(RequiredSwitch, {}), shouldShowHideSwitch && /*#__PURE__*/jsxRuntime.jsx(Switch, {
|
|
1115
1124
|
label: t("neetoForm.common.hideQuestion"),
|
|
1116
1125
|
name: "isHidden",
|
|
1117
1126
|
labelProps: hideSwitchLabelProps(hideQuestionHelpDocUrl)
|
|
@@ -1166,7 +1175,7 @@ var buildLabelValidationSchema = function buildLabelValidationSchema(kind, schem
|
|
|
1166
1175
|
if (index.isNameQuestion(kind)) {
|
|
1167
1176
|
return schema.notRequired();
|
|
1168
1177
|
}
|
|
1169
|
-
return ramda.includes(kind,
|
|
1178
|
+
return ramda.includes(kind, yup.RICH_TEXT_QUESTIONS) ? schema.test("required", richTextFieldMissingErrorMessage(kind), function (value) {
|
|
1170
1179
|
return !utils$1.isEditorEmpty(value);
|
|
1171
1180
|
}) : requiredLabelValidation(schema, i18next.t("neetoForm.questions.common.questionFields.field.question"));
|
|
1172
1181
|
};
|
|
@@ -1178,8 +1187,8 @@ var buildNameLabelValidationSchema = function buildNameLabelValidationSchema(que
|
|
|
1178
1187
|
var buildOpinionScaleLabelValidationSchema = function buildOpinionScaleLabelValidationSchema(label) {
|
|
1179
1188
|
return stringSchema.when("hasOpinionLabels", {
|
|
1180
1189
|
is: true,
|
|
1181
|
-
then: requiredLabelValidation(stringSchema, label).max(
|
|
1182
|
-
value:
|
|
1190
|
+
then: requiredLabelValidation(stringSchema, label).max(yup.OPINION_LABEL_MAX_LENGTH, i18next.t("neetoForm.error.mustBeOrLessThanOrEqualTo", {
|
|
1191
|
+
value: yup.OPINION_LABEL_MAX_LENGTH
|
|
1183
1192
|
})),
|
|
1184
1193
|
otherwise: stringSchema.notRequired()
|
|
1185
1194
|
});
|
|
@@ -1195,17 +1204,25 @@ var formValidationSchema = function formValidationSchema(question) {
|
|
|
1195
1204
|
fullNameLabel: buildNameLabelValidationSchema(question, stringSchema, true),
|
|
1196
1205
|
firstNameLabel: buildNameLabelValidationSchema(question, stringSchema),
|
|
1197
1206
|
lastNameLabel: buildNameLabelValidationSchema(question, stringSchema),
|
|
1198
|
-
fieldCode: yup__namespace.string().trim().notOneOf(
|
|
1199
|
-
return isFieldCodeEnabled && !ramda.includes(kind,
|
|
1207
|
+
fieldCode: yup__namespace.string().trim().notOneOf(yup.RESERVED_FIELD_CODES, i18next.t("neetoForm.error.invalidFieldCode")).when("kind", function (kind, schema) {
|
|
1208
|
+
return isFieldCodeEnabled && !ramda.includes(kind, yup.QUESTIONS_WITHOUT_FIELD_CODE) ? fieldCodeValidation(schema, i18next.t("neetoForm.questions.common.questionFields.field.fieldCode")) : schema.notRequired();
|
|
1200
1209
|
}),
|
|
1201
1210
|
optionsAttributes: yup__namespace.array().when("kind", function (kind, schema) {
|
|
1202
|
-
return ramda.includes(kind,
|
|
1211
|
+
return ramda.includes(kind, yup.SELECTABLE_KINDS) ? schema.of(yup__namespace.object().shape({
|
|
1203
1212
|
label: yup__namespace.string().when("_destroy", {
|
|
1204
1213
|
is: true,
|
|
1205
1214
|
otherwise: requiredLabelValidation(yup__namespace.string(), i18next.t("neetoForm.questions.common.questionFields.field.option"))
|
|
1206
1215
|
})
|
|
1207
1216
|
})) : schema.notRequired();
|
|
1208
1217
|
}),
|
|
1218
|
+
fields: yup__namespace.array().when("kind", function (kind, schema) {
|
|
1219
|
+
return kind === constants.QUESTION_TYPES.ADDRESS ? schema.of(yup__namespace.object().shape({
|
|
1220
|
+
label: yup__namespace.string().when("_destroy", {
|
|
1221
|
+
is: true,
|
|
1222
|
+
otherwise: yup__namespace.string().trim().required(i18next.t("neetoForm.error.allFieldsRequired"))
|
|
1223
|
+
})
|
|
1224
|
+
})) : schema.notRequired();
|
|
1225
|
+
}),
|
|
1209
1226
|
highestRatingLabel: yup__namespace.string().nullable(),
|
|
1210
1227
|
averageRatingLabel: yup__namespace.string().nullable(),
|
|
1211
1228
|
lowestRatingLabel: yup__namespace.string().nullable(),
|
|
@@ -1214,16 +1231,16 @@ var formValidationSchema = function formValidationSchema(question) {
|
|
|
1214
1231
|
});
|
|
1215
1232
|
};
|
|
1216
1233
|
|
|
1217
|
-
var _excluded$
|
|
1218
|
-
function ownKeys$
|
|
1219
|
-
function _objectSpread$
|
|
1234
|
+
var _excluded$8 = ["question", "onClose", "questions", "handleSelect", "isOpen"];
|
|
1235
|
+
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; }
|
|
1236
|
+
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; }
|
|
1220
1237
|
var Add = function Add(_ref) {
|
|
1221
1238
|
var question = _ref.question,
|
|
1222
1239
|
onClose = _ref.onClose,
|
|
1223
1240
|
questions = _ref.questions,
|
|
1224
1241
|
handleSelect = _ref.handleSelect,
|
|
1225
1242
|
isOpen = _ref.isOpen,
|
|
1226
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
1243
|
+
props = _objectWithoutProperties(_ref, _excluded$8);
|
|
1227
1244
|
var _useBuildFormStore = buildForm.useBuildFormStore(function (store) {
|
|
1228
1245
|
var _store$formState, _store$formState2, _store$formState3;
|
|
1229
1246
|
return {
|
|
@@ -1243,7 +1260,7 @@ var Add = function Add(_ref) {
|
|
|
1243
1260
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1244
1261
|
args[_key] = arguments[_key];
|
|
1245
1262
|
}
|
|
1246
|
-
onMutateSuccess === null || onMutateSuccess === void 0 || onMutateSuccess.apply(void 0, [
|
|
1263
|
+
onMutateSuccess === null || onMutateSuccess === void 0 || onMutateSuccess.apply(void 0, [yup.QUESTION_ACTIONS.ADD].concat(args));
|
|
1247
1264
|
utils.showThumbsUpToastr();
|
|
1248
1265
|
onClose();
|
|
1249
1266
|
}
|
|
@@ -1257,7 +1274,7 @@ var Add = function Add(_ref) {
|
|
|
1257
1274
|
language: language,
|
|
1258
1275
|
neetoFormQuestion: ramda.mergeLeft({
|
|
1259
1276
|
displayOrder: displayOrder
|
|
1260
|
-
}, values)
|
|
1277
|
+
}, transformValues(values))
|
|
1261
1278
|
}, {
|
|
1262
1279
|
onSuccess: function onSuccess(_ref2) {
|
|
1263
1280
|
var questions = _ref2.questions;
|
|
@@ -1282,7 +1299,7 @@ var Add = function Add(_ref) {
|
|
|
1282
1299
|
onSubmit: handleSubmit
|
|
1283
1300
|
},
|
|
1284
1301
|
children: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1285
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Form$1, _objectSpread$
|
|
1302
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Form$1, _objectSpread$c({}, _objectSpread$c(_objectSpread$c({}, props), {}, {
|
|
1286
1303
|
question: question,
|
|
1287
1304
|
questions: questions
|
|
1288
1305
|
}))), /*#__PURE__*/jsxRuntime.jsx(Pane.Footer, {
|
|
@@ -1298,14 +1315,14 @@ var Add = function Add(_ref) {
|
|
|
1298
1315
|
});
|
|
1299
1316
|
};
|
|
1300
1317
|
|
|
1301
|
-
var _excluded$
|
|
1302
|
-
function ownKeys$
|
|
1303
|
-
function _objectSpread$
|
|
1318
|
+
var _excluded$7 = ["question", "isOpen", "onClose"];
|
|
1319
|
+
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; }
|
|
1320
|
+
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; }
|
|
1304
1321
|
var Edit = function Edit(_ref) {
|
|
1305
1322
|
var question = _ref.question,
|
|
1306
1323
|
isOpen = _ref.isOpen,
|
|
1307
1324
|
onClose = _ref.onClose,
|
|
1308
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
1325
|
+
props = _objectWithoutProperties(_ref, _excluded$7);
|
|
1309
1326
|
var _useTranslation = reactI18next.useTranslation(),
|
|
1310
1327
|
t = _useTranslation.t;
|
|
1311
1328
|
var _useBuildFormStore = buildForm.useBuildFormStore(function (store) {
|
|
@@ -1326,7 +1343,7 @@ var Edit = function Edit(_ref) {
|
|
|
1326
1343
|
if (isUpdating || !isOpen) return;
|
|
1327
1344
|
var payload = {
|
|
1328
1345
|
language: language,
|
|
1329
|
-
neetoFormQuestion: values
|
|
1346
|
+
neetoFormQuestion: transformValues(values)
|
|
1330
1347
|
};
|
|
1331
1348
|
updateQuestion({
|
|
1332
1349
|
questionId: question.id,
|
|
@@ -1336,7 +1353,7 @@ var Edit = function Edit(_ref) {
|
|
|
1336
1353
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1337
1354
|
args[_key] = arguments[_key];
|
|
1338
1355
|
}
|
|
1339
|
-
onMutateSuccess === null || onMutateSuccess === void 0 || onMutateSuccess.apply(void 0, [
|
|
1356
|
+
onMutateSuccess === null || onMutateSuccess === void 0 || onMutateSuccess.apply(void 0, [yup.QUESTION_ACTIONS.EDIT].concat(args));
|
|
1340
1357
|
utils.showThumbsUpToastr();
|
|
1341
1358
|
onClose();
|
|
1342
1359
|
},
|
|
@@ -1359,7 +1376,7 @@ var Edit = function Edit(_ref) {
|
|
|
1359
1376
|
onSubmit: handleSubmit
|
|
1360
1377
|
},
|
|
1361
1378
|
children: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1362
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Form$1, _objectSpread$
|
|
1379
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Form$1, _objectSpread$b(_objectSpread$b({}, _objectSpread$b({
|
|
1363
1380
|
question: question
|
|
1364
1381
|
}, props)), {}, {
|
|
1365
1382
|
isEdit: true
|
|
@@ -1376,6 +1393,359 @@ var Edit = function Edit(_ref) {
|
|
|
1376
1393
|
});
|
|
1377
1394
|
};
|
|
1378
1395
|
|
|
1396
|
+
var VARIANTS = {
|
|
1397
|
+
hidden: {
|
|
1398
|
+
opacity: 0,
|
|
1399
|
+
height: 0,
|
|
1400
|
+
overflow: "hidden"
|
|
1401
|
+
},
|
|
1402
|
+
visible: {
|
|
1403
|
+
opacity: 1,
|
|
1404
|
+
height: "auto"
|
|
1405
|
+
}
|
|
1406
|
+
};
|
|
1407
|
+
|
|
1408
|
+
var _excluded$6 = ["open", "className", "children"];
|
|
1409
|
+
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; }
|
|
1410
|
+
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; }
|
|
1411
|
+
var Collapsible = function Collapsible(_ref) {
|
|
1412
|
+
var open = _ref.open,
|
|
1413
|
+
_ref$className = _ref.className,
|
|
1414
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
1415
|
+
children = _ref.children,
|
|
1416
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$6);
|
|
1417
|
+
return /*#__PURE__*/jsxRuntime.jsx(framerMotion.AnimatePresence, {
|
|
1418
|
+
children: open && /*#__PURE__*/jsxRuntime.jsx(framerMotion.motion.div, _objectSpread$a(_objectSpread$a({
|
|
1419
|
+
animate: "visible",
|
|
1420
|
+
exit: "hidden",
|
|
1421
|
+
initial: "hidden",
|
|
1422
|
+
transition: {
|
|
1423
|
+
duration: 0.3
|
|
1424
|
+
},
|
|
1425
|
+
variants: VARIANTS
|
|
1426
|
+
}, otherProps), {}, {
|
|
1427
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1428
|
+
className: className,
|
|
1429
|
+
children: children
|
|
1430
|
+
})
|
|
1431
|
+
}))
|
|
1432
|
+
});
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1435
|
+
var ADDRESS_FIELD_WIDTH_OPTIONS = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, yup.ADDRESS_FIELD_WIDTHS.FULL, {
|
|
1436
|
+
label: i18next.t("neetoForm.questions.address.widths.full"),
|
|
1437
|
+
value: yup.ADDRESS_FIELD_WIDTHS.FULL
|
|
1438
|
+
}), yup.ADDRESS_FIELD_WIDTHS.HALF, {
|
|
1439
|
+
label: i18next.t("neetoForm.questions.address.widths.half"),
|
|
1440
|
+
value: yup.ADDRESS_FIELD_WIDTHS.HALF
|
|
1441
|
+
}), yup.ADDRESS_FIELD_WIDTHS.ONE_FOURTH, {
|
|
1442
|
+
label: i18next.t("neetoForm.questions.address.widths.oneFourth"),
|
|
1443
|
+
value: yup.ADDRESS_FIELD_WIDTHS.ONE_FOURTH
|
|
1444
|
+
}), yup.ADDRESS_FIELD_WIDTHS.THREE_FOURTH, {
|
|
1445
|
+
label: i18next.t("neetoForm.questions.address.widths.threeFourth"),
|
|
1446
|
+
value: yup.ADDRESS_FIELD_WIDTHS.THREE_FOURTH
|
|
1447
|
+
});
|
|
1448
|
+
var ADDRESS_FIELD_TYPE_OPTIONS = _defineProperty(_defineProperty({}, yup.ADDRESS_FIELD_TYPES.INPUT, {
|
|
1449
|
+
label: i18next.t("neetoForm.questions.address.types.textInput"),
|
|
1450
|
+
value: yup.ADDRESS_FIELD_TYPES.INPUT
|
|
1451
|
+
}), yup.ADDRESS_FIELD_TYPES.SELECT, {
|
|
1452
|
+
label: i18next.t("neetoForm.questions.address.types.dropdown"),
|
|
1453
|
+
value: yup.ADDRESS_FIELD_TYPES.SELECT
|
|
1454
|
+
});
|
|
1455
|
+
var ADDRESS_FIELD_FORM_VALIDATION_SCHEMA = yup__namespace.object().shape({
|
|
1456
|
+
label: yup__namespace.string().trim().required(i18next.t("neetoForm.error.requiredField", {
|
|
1457
|
+
label: i18next.t("neetoForm.questions.common.questionFields.field.label")
|
|
1458
|
+
})),
|
|
1459
|
+
width: yup__namespace.object().nullable().required(i18next.t("neetoForm.error.requiredField", {
|
|
1460
|
+
label: i18next.t("neetoForm.questions.address.width")
|
|
1461
|
+
})),
|
|
1462
|
+
fieldType: yup__namespace.object().nullable().required(i18next.t("neetoForm.error.requiredField", {
|
|
1463
|
+
label: i18next.t("neetoForm.questions.address.type")
|
|
1464
|
+
})),
|
|
1465
|
+
properties: yup__namespace.object().shape({
|
|
1466
|
+
options: yup__namespace.array().of(yup__namespace.object().shape({
|
|
1467
|
+
label: yup__namespace.string().required(i18next.t("neetoForm.error.requiredField", {
|
|
1468
|
+
label: i18next.t("neetoForm.common.option")
|
|
1469
|
+
}))
|
|
1470
|
+
})).unique("label", i18next.t("neetoForm.error.removeDuplicates"))
|
|
1471
|
+
})
|
|
1472
|
+
});
|
|
1473
|
+
var ERROR_MESSAGE_DELIMITER$1 = ". ";
|
|
1474
|
+
|
|
1475
|
+
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; }
|
|
1476
|
+
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; }
|
|
1477
|
+
var removeDuplicateErrorMessages$1 = ramda.pipe(ramda.filter(ramda.isNotNil), ramda.map(ramda.values), ramda.uniq, ramda.join(ERROR_MESSAGE_DELIMITER$1));
|
|
1478
|
+
var getAddressModalInitialValues = function getAddressModalInitialValues(field) {
|
|
1479
|
+
return field ? _objectSpread$9(_objectSpread$9({}, field), {}, {
|
|
1480
|
+
width: ADDRESS_FIELD_WIDTH_OPTIONS[field.width],
|
|
1481
|
+
fieldType: ADDRESS_FIELD_TYPE_OPTIONS[field.fieldType]
|
|
1482
|
+
}) : {
|
|
1483
|
+
label: "",
|
|
1484
|
+
isRequired: false,
|
|
1485
|
+
width: ADDRESS_FIELD_WIDTH_OPTIONS[yup.ADDRESS_FIELD_WIDTHS.FULL],
|
|
1486
|
+
fieldType: ADDRESS_FIELD_TYPE_OPTIONS[yup.ADDRESS_FIELD_TYPES.INPUT]
|
|
1487
|
+
};
|
|
1488
|
+
};
|
|
1489
|
+
var sanitizeAddressField = function sanitizeAddressField(field, isSelectField, defaultOptions) {
|
|
1490
|
+
var hasOptions = ramda.pathSatisfies(neetoCist.isPresent, ["properties", "options"], field);
|
|
1491
|
+
if (isSelectField && !hasOptions) {
|
|
1492
|
+
return ramda.assocPath(["properties", "options"], defaultOptions, field);
|
|
1493
|
+
}
|
|
1494
|
+
if (!isSelectField && hasOptions) {
|
|
1495
|
+
return ramda.dissoc("properties", field);
|
|
1496
|
+
}
|
|
1497
|
+
return field;
|
|
1498
|
+
};
|
|
1499
|
+
var formatErrorMessage$1 = function formatErrorMessage(error) {
|
|
1500
|
+
if (typeof error === "string") return error;
|
|
1501
|
+
return removeDuplicateErrorMessages$1(error);
|
|
1502
|
+
};
|
|
1503
|
+
|
|
1504
|
+
var _excluded$5 = ["width", "fieldType"];
|
|
1505
|
+
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; }
|
|
1506
|
+
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; }
|
|
1507
|
+
var ManagePane = function ManagePane(_ref) {
|
|
1508
|
+
var isOpen = _ref.isOpen,
|
|
1509
|
+
selectedFieldId = _ref.selectedFieldId,
|
|
1510
|
+
onClose = _ref.onClose,
|
|
1511
|
+
title = _ref.title,
|
|
1512
|
+
fields = _ref.fields,
|
|
1513
|
+
initialFocusRef = _ref.initialFocusRef;
|
|
1514
|
+
var _useField = formik.useField("fields"),
|
|
1515
|
+
_useField2 = _slicedToArray(_useField, 3),
|
|
1516
|
+
allFields = _useField2[0].value,
|
|
1517
|
+
setValue = _useField2[2].setValue;
|
|
1518
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
1519
|
+
t = _useTranslation.t;
|
|
1520
|
+
var defaultOptions = yup.generateDefaultOptions(yup.MINIMUM_ADDRESS_FIELDS);
|
|
1521
|
+
var editingField = neetoCist.findById(selectedFieldId, fields);
|
|
1522
|
+
var initialValues = getAddressModalInitialValues(editingField);
|
|
1523
|
+
var handleSubmit = function handleSubmit(_ref2) {
|
|
1524
|
+
var width = _ref2.width,
|
|
1525
|
+
fieldType = _ref2.fieldType,
|
|
1526
|
+
field = _objectWithoutProperties(_ref2, _excluded$5);
|
|
1527
|
+
var deletedFields = yup.getDeletedRecords(allFields);
|
|
1528
|
+
var isSelectField = fieldType.value === yup.ADDRESS_FIELD_TYPES.SELECT;
|
|
1529
|
+
var sanitizedField = sanitizeAddressField(field, isSelectField, defaultOptions);
|
|
1530
|
+
if (ramda.isNil(selectedFieldId)) {
|
|
1531
|
+
var position = fields.length;
|
|
1532
|
+
var id = "draft-".concat(yup.randomId());
|
|
1533
|
+
var newField = _objectSpread$8(_objectSpread$8({
|
|
1534
|
+
id: id
|
|
1535
|
+
}, sanitizedField), {}, {
|
|
1536
|
+
altId: "alt-".concat(yup.randomId()),
|
|
1537
|
+
position: position,
|
|
1538
|
+
width: width.value,
|
|
1539
|
+
fieldType: fieldType.value
|
|
1540
|
+
});
|
|
1541
|
+
var nextFields = ramda.append(newField, fields);
|
|
1542
|
+
setValue([].concat(_toConsumableArray(nextFields), _toConsumableArray(deletedFields)));
|
|
1543
|
+
} else {
|
|
1544
|
+
var selectedFieldIndex = neetoCist.findIndexById(selectedFieldId, fields);
|
|
1545
|
+
setValue(ramda.assoc(selectedFieldIndex, _objectSpread$8(_objectSpread$8({}, sanitizedField), {}, {
|
|
1546
|
+
width: width.value,
|
|
1547
|
+
fieldType: fieldType.value
|
|
1548
|
+
}), [].concat(_toConsumableArray(fields), _toConsumableArray(deletedFields))));
|
|
1549
|
+
}
|
|
1550
|
+
onClose();
|
|
1551
|
+
};
|
|
1552
|
+
var handleFieldTypeChange = function handleFieldTypeChange(setFieldValue, values) {
|
|
1553
|
+
return function (fieldType) {
|
|
1554
|
+
var _values$properties;
|
|
1555
|
+
setFieldValue("fieldType", fieldType);
|
|
1556
|
+
if (fieldType.value === yup.ADDRESS_FIELD_TYPES.SELECT && neetoCist.isNotPresent((_values$properties = values.properties) === null || _values$properties === void 0 ? void 0 : _values$properties.options)) {
|
|
1557
|
+
setFieldValue("properties.options", defaultOptions);
|
|
1558
|
+
}
|
|
1559
|
+
};
|
|
1560
|
+
};
|
|
1561
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Pane, {
|
|
1562
|
+
initialFocusRef: initialFocusRef,
|
|
1563
|
+
isOpen: isOpen,
|
|
1564
|
+
onClose: onClose,
|
|
1565
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Pane.Header, {
|
|
1566
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
1567
|
+
"data-testid": "add-address-field-title",
|
|
1568
|
+
style: "h2",
|
|
1569
|
+
weight: "semibold",
|
|
1570
|
+
children: title
|
|
1571
|
+
})
|
|
1572
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Form$2, {
|
|
1573
|
+
formikProps: {
|
|
1574
|
+
initialValues: initialValues,
|
|
1575
|
+
validationSchema: ADDRESS_FIELD_FORM_VALIDATION_SCHEMA,
|
|
1576
|
+
onSubmit: handleSubmit
|
|
1577
|
+
},
|
|
1578
|
+
children: function children(_ref3) {
|
|
1579
|
+
var _values$fieldType;
|
|
1580
|
+
var values = _ref3.values,
|
|
1581
|
+
setFieldValue = _ref3.setFieldValue;
|
|
1582
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1583
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Pane.Body, {
|
|
1584
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1585
|
+
className: "w-full space-y-6",
|
|
1586
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
1587
|
+
name: "label",
|
|
1588
|
+
ref: initialFocusRef,
|
|
1589
|
+
label: t("neetoForm.questions.common.questionFields.field.label"),
|
|
1590
|
+
placeholder: t("neetoForm.questions.address.fieldLabelPlaceholder")
|
|
1591
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1592
|
+
className: "grid grid-cols-2 gap-6",
|
|
1593
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Select, {
|
|
1594
|
+
label: t("neetoForm.questions.address.width"),
|
|
1595
|
+
name: "width",
|
|
1596
|
+
options: Object.values(ADDRESS_FIELD_WIDTH_OPTIONS)
|
|
1597
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Select, {
|
|
1598
|
+
label: t("neetoForm.questions.address.type"),
|
|
1599
|
+
name: "fieldType",
|
|
1600
|
+
options: Object.values(ADDRESS_FIELD_TYPE_OPTIONS),
|
|
1601
|
+
onChange: handleFieldTypeChange(setFieldValue, values)
|
|
1602
|
+
})]
|
|
1603
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Collapsible, {
|
|
1604
|
+
open: (values === null || values === void 0 || (_values$fieldType = values.fieldType) === null || _values$fieldType === void 0 ? void 0 : _values$fieldType.value) === yup.ADDRESS_FIELD_TYPES.SELECT,
|
|
1605
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1606
|
+
className: "flex flex-col",
|
|
1607
|
+
children: /*#__PURE__*/jsxRuntime.jsx(OptionFields, {
|
|
1608
|
+
draggable: true,
|
|
1609
|
+
minOptions: yup.MINIMUM_ADDRESS_FIELDS,
|
|
1610
|
+
name: "properties.options"
|
|
1611
|
+
})
|
|
1612
|
+
})
|
|
1613
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1614
|
+
className: "flex items-center gap-4",
|
|
1615
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Switch, {
|
|
1616
|
+
label: t("neetoForm.common.required"),
|
|
1617
|
+
name: "isRequired"
|
|
1618
|
+
})
|
|
1619
|
+
})]
|
|
1620
|
+
})
|
|
1621
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Pane.Footer, {
|
|
1622
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1623
|
+
className: "flex items-center gap-2",
|
|
1624
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock, {
|
|
1625
|
+
className: "flex gap-x-2",
|
|
1626
|
+
cancelButtonProps: {
|
|
1627
|
+
type: "reset",
|
|
1628
|
+
onClick: onClose,
|
|
1629
|
+
disabled: false
|
|
1630
|
+
},
|
|
1631
|
+
submitButtonProps: {
|
|
1632
|
+
label: t("neetoForm.common.saveChanges")
|
|
1633
|
+
}
|
|
1634
|
+
})
|
|
1635
|
+
})
|
|
1636
|
+
})]
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1639
|
+
})]
|
|
1640
|
+
});
|
|
1641
|
+
};
|
|
1642
|
+
|
|
1643
|
+
var Address = function Address() {
|
|
1644
|
+
var _findById;
|
|
1645
|
+
var _useState = React.useState(false),
|
|
1646
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1647
|
+
isAddressFieldPaneOpen = _useState2[0],
|
|
1648
|
+
setIsAddressFieldPaneOpen = _useState2[1];
|
|
1649
|
+
var _useState3 = React.useState(false),
|
|
1650
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1651
|
+
isDeleteAddressFieldAlertOpen = _useState4[0],
|
|
1652
|
+
setIsDeleteAddressFieldAlertOpen = _useState4[1];
|
|
1653
|
+
var _useState5 = React.useState(null),
|
|
1654
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1655
|
+
selectedFieldId = _useState6[0],
|
|
1656
|
+
setSelectedFieldId = _useState6[1];
|
|
1657
|
+
var initialFocusRef = React.useRef(null);
|
|
1658
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
1659
|
+
t = _useTranslation.t;
|
|
1660
|
+
var _useBuildFormStore = buildForm.useBuildFormStore(function (store) {
|
|
1661
|
+
var _store$formState;
|
|
1662
|
+
return {
|
|
1663
|
+
selectedLanguage: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["selectedLanguage"]
|
|
1664
|
+
};
|
|
1665
|
+
}, shallow.shallow),
|
|
1666
|
+
selectedLanguage = _useBuildFormStore.selectedLanguage;
|
|
1667
|
+
var name = "fields";
|
|
1668
|
+
var _useField = formik.useField(name),
|
|
1669
|
+
_useField2 = _slicedToArray(_useField, 3),
|
|
1670
|
+
fields = _useField2[0].value,
|
|
1671
|
+
_useField2$ = _useField2[1],
|
|
1672
|
+
error = _useField2$.error,
|
|
1673
|
+
touched = _useField2$.touched,
|
|
1674
|
+
setFields = _useField2[2].setValue;
|
|
1675
|
+
var handleDelete = function handleDelete() {
|
|
1676
|
+
var deletedFields = yup.getDeletedRecords(fields);
|
|
1677
|
+
var nextFields = yup.getActiveRecords(fields);
|
|
1678
|
+
var selectedFieldIndex = neetoCist.findIndexById(selectedFieldId, nextFields);
|
|
1679
|
+
nextFields = ramda.assocPath([selectedFieldIndex, "deleted"], true, nextFields);
|
|
1680
|
+
setFields([].concat(_toConsumableArray(nextFields), _toConsumableArray(deletedFields)));
|
|
1681
|
+
};
|
|
1682
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1683
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Block, {
|
|
1684
|
+
dataTestid: "address-fields-block",
|
|
1685
|
+
title: t("neetoForm.questions.address.fields"),
|
|
1686
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1687
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(OptionFields, {
|
|
1688
|
+
name: name,
|
|
1689
|
+
draggable: true,
|
|
1690
|
+
shouldDestroy: true,
|
|
1691
|
+
editable: false,
|
|
1692
|
+
isNewItemsPrefilled: yup.isDefaultLanguage(selectedLanguage),
|
|
1693
|
+
itemLabel: t("neetoForm.common.field"),
|
|
1694
|
+
minOptions: yup.MINIMUM_ADDRESS_FIELDS,
|
|
1695
|
+
shouldResetEmptyOptionOnBlur: false,
|
|
1696
|
+
buttonProps: {
|
|
1697
|
+
label: t("neetoForm.questions.address.addField"),
|
|
1698
|
+
onClick: function onClick() {
|
|
1699
|
+
return setIsAddressFieldPaneOpen(true);
|
|
1700
|
+
}
|
|
1701
|
+
},
|
|
1702
|
+
onDelete: function onDelete(id) {
|
|
1703
|
+
setSelectedFieldId(id);
|
|
1704
|
+
setIsDeleteAddressFieldAlertOpen(true);
|
|
1705
|
+
},
|
|
1706
|
+
onEdit: function onEdit(id) {
|
|
1707
|
+
setSelectedFieldId(id);
|
|
1708
|
+
setIsAddressFieldPaneOpen(true);
|
|
1709
|
+
}
|
|
1710
|
+
}), touched && error && /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
1711
|
+
className: "neeto-form-engine-input__error",
|
|
1712
|
+
"data-testid": "neeto-form-engine-address-fields-error",
|
|
1713
|
+
children: formatErrorMessage$1(error)
|
|
1714
|
+
})]
|
|
1715
|
+
})
|
|
1716
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ManagePane, {
|
|
1717
|
+
initialFocusRef: initialFocusRef,
|
|
1718
|
+
selectedFieldId: selectedFieldId,
|
|
1719
|
+
fields: yup.getActiveRecords(fields),
|
|
1720
|
+
isOpen: isAddressFieldPaneOpen,
|
|
1721
|
+
title: ramda.isNotNil(selectedFieldId) ? t("neetoForm.questions.address.editField") : t("neetoForm.questions.address.addField"),
|
|
1722
|
+
onClose: function onClose() {
|
|
1723
|
+
setIsAddressFieldPaneOpen(false);
|
|
1724
|
+
setSelectedFieldId(null);
|
|
1725
|
+
}
|
|
1726
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Alert, {
|
|
1727
|
+
isOpen: isDeleteAddressFieldAlertOpen,
|
|
1728
|
+
submitButtonLabel: t("neetoForm.common.delete"),
|
|
1729
|
+
title: t("neetoForm.questions.address.deleteAlert.title"),
|
|
1730
|
+
message: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
1731
|
+
i18nKey: "neetoForm.questions.address.deleteAlert.message",
|
|
1732
|
+
values: {
|
|
1733
|
+
label: (_findById = neetoCist.findById(selectedFieldId, fields)) === null || _findById === void 0 ? void 0 : _findById.label
|
|
1734
|
+
}
|
|
1735
|
+
}),
|
|
1736
|
+
onClose: function onClose() {
|
|
1737
|
+
setIsDeleteAddressFieldAlertOpen(false);
|
|
1738
|
+
setSelectedFieldId(null);
|
|
1739
|
+
},
|
|
1740
|
+
onSubmit: function onSubmit() {
|
|
1741
|
+
setIsDeleteAddressFieldAlertOpen(false);
|
|
1742
|
+
handleDelete();
|
|
1743
|
+
setSelectedFieldId(null);
|
|
1744
|
+
}
|
|
1745
|
+
})]
|
|
1746
|
+
});
|
|
1747
|
+
};
|
|
1748
|
+
|
|
1379
1749
|
var Captcha = reactUtils.withT(function (_ref) {
|
|
1380
1750
|
var t = _ref.t;
|
|
1381
1751
|
return /*#__PURE__*/jsxRuntime.jsxs(Radio, {
|
|
@@ -1394,19 +1764,19 @@ var Captcha = reactUtils.withT(function (_ref) {
|
|
|
1394
1764
|
});
|
|
1395
1765
|
});
|
|
1396
1766
|
|
|
1397
|
-
var _excluded$
|
|
1398
|
-
function ownKeys$
|
|
1399
|
-
function _objectSpread$
|
|
1767
|
+
var _excluded$4 = ["name", "title", "className"];
|
|
1768
|
+
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; }
|
|
1769
|
+
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; }
|
|
1400
1770
|
var SwitchBlock = function SwitchBlock(_ref) {
|
|
1401
1771
|
var name = _ref.name,
|
|
1402
1772
|
title = _ref.title,
|
|
1403
1773
|
_ref$className = _ref.className,
|
|
1404
1774
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
1405
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
1775
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$4);
|
|
1406
1776
|
return /*#__PURE__*/jsxRuntime.jsxs(Label, {
|
|
1407
1777
|
className: classnames("flex items-center justify-start gap-2 ", className),
|
|
1408
1778
|
"data-testid": "neeto-form-engine-".concat(neetoCist.hyphenate(title && name), "-toggle-label"),
|
|
1409
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Switch, _objectSpread$
|
|
1779
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Switch, _objectSpread$7(_objectSpread$7({}, _objectSpread$7(_objectSpread$7({}, otherProps), {}, {
|
|
1410
1780
|
name: name
|
|
1411
1781
|
})), {}, {
|
|
1412
1782
|
"data-testid": "neeto-form-engine-".concat(neetoCist.hyphenate(title && name), "-switch")
|
|
@@ -1435,9 +1805,9 @@ var EMAIL_VERIFICATION_TRANSLATIONS = {
|
|
|
1435
1805
|
popoverDescription: i18next.t("neetoForm.emailVerification.popoverDescription")
|
|
1436
1806
|
};
|
|
1437
1807
|
|
|
1438
|
-
var _excluded$
|
|
1439
|
-
function ownKeys$
|
|
1440
|
-
function _objectSpread$
|
|
1808
|
+
var _excluded$3 = ["children"];
|
|
1809
|
+
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; }
|
|
1810
|
+
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; }
|
|
1441
1811
|
var STYLES = {
|
|
1442
1812
|
border: {
|
|
1443
1813
|
"default": "1px solid rgb(var(--neeto-ui-gray-400))",
|
|
@@ -1449,8 +1819,8 @@ var STYLES = {
|
|
|
1449
1819
|
}
|
|
1450
1820
|
};
|
|
1451
1821
|
var MultiValueRemove = function MultiValueRemove(props) {
|
|
1452
|
-
return /*#__PURE__*/jsxRuntime.jsx(reactSelect.components.MultiValueRemove, _objectSpread$
|
|
1453
|
-
innerProps: _objectSpread$
|
|
1822
|
+
return /*#__PURE__*/jsxRuntime.jsx(reactSelect.components.MultiValueRemove, _objectSpread$6(_objectSpread$6({}, props), {}, {
|
|
1823
|
+
innerProps: _objectSpread$6(_objectSpread$6({}, props.innerProps), {}, _defineProperty({}, "data-testid", "".concat(utils.hyphenize(props.data.label), "-remove-icon"))),
|
|
1454
1824
|
children: /*#__PURE__*/jsxRuntime.jsx(Close, {
|
|
1455
1825
|
size: 16
|
|
1456
1826
|
})
|
|
@@ -1458,7 +1828,7 @@ var MultiValueRemove = function MultiValueRemove(props) {
|
|
|
1458
1828
|
};
|
|
1459
1829
|
var ValueContainer = function ValueContainer(_ref) {
|
|
1460
1830
|
var children = _ref.children,
|
|
1461
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
1831
|
+
props = _objectWithoutProperties(_ref, _excluded$3);
|
|
1462
1832
|
var _useTranslation = reactI18next.useTranslation(),
|
|
1463
1833
|
t = _useTranslation.t;
|
|
1464
1834
|
var getValue = props.getValue,
|
|
@@ -1470,8 +1840,8 @@ var ValueContainer = function ValueContainer(_ref) {
|
|
|
1470
1840
|
firstChild = _children[0],
|
|
1471
1841
|
rest = _children.slice(1);
|
|
1472
1842
|
var shouldCollapse = !isFocused && value.length > visibleDomainsCount;
|
|
1473
|
-
return /*#__PURE__*/jsxRuntime.jsxs(reactSelect.components.ValueContainer, _objectSpread$
|
|
1474
|
-
innerProps: _objectSpread$
|
|
1843
|
+
return /*#__PURE__*/jsxRuntime.jsxs(reactSelect.components.ValueContainer, _objectSpread$6(_objectSpread$6({}, props), {}, {
|
|
1844
|
+
innerProps: _objectSpread$6(_objectSpread$6({}, props.innerProps), {}, _defineProperty({}, "data-testid", "multi-domain-input-container")),
|
|
1475
1845
|
children: [shouldCollapse ? firstChild.slice(0, visibleDomainsCount) : firstChild, shouldCollapse && /*#__PURE__*/jsxRuntime.jsx(Tag, {
|
|
1476
1846
|
style: "secondary",
|
|
1477
1847
|
label: t("neetoForm.common.remainingItemsCount", {
|
|
@@ -1481,8 +1851,8 @@ var ValueContainer = function ValueContainer(_ref) {
|
|
|
1481
1851
|
}));
|
|
1482
1852
|
};
|
|
1483
1853
|
var ClearIndicator = function ClearIndicator(props) {
|
|
1484
|
-
return /*#__PURE__*/jsxRuntime.jsx(reactSelect.components.ClearIndicator, _objectSpread$
|
|
1485
|
-
innerProps: _objectSpread$
|
|
1854
|
+
return /*#__PURE__*/jsxRuntime.jsx(reactSelect.components.ClearIndicator, _objectSpread$6(_objectSpread$6({}, props), {}, {
|
|
1855
|
+
innerProps: _objectSpread$6(_objectSpread$6({}, props.innerProps), {}, _defineProperty({}, "data-testid", "clear-all-button")),
|
|
1486
1856
|
children: /*#__PURE__*/jsxRuntime.jsx(Close, {
|
|
1487
1857
|
className: "cursor-pointer",
|
|
1488
1858
|
size: 16
|
|
@@ -1503,7 +1873,7 @@ var CUSTOM_STYLES = {
|
|
|
1503
1873
|
input: ramda.assoc("overflow", "hidden"),
|
|
1504
1874
|
multiValue: function multiValue(styles, _ref2) {
|
|
1505
1875
|
var valid = _ref2.data.valid;
|
|
1506
|
-
return _objectSpread$
|
|
1876
|
+
return _objectSpread$6(_objectSpread$6({}, styles), {}, {
|
|
1507
1877
|
border: valid ? STYLES.border["default"] : STYLES.border.error,
|
|
1508
1878
|
color: valid ? STYLES.color["default"] : STYLES.color.error
|
|
1509
1879
|
});
|
|
@@ -1545,9 +1915,9 @@ var formatErrorMessage = function formatErrorMessage(error) {
|
|
|
1545
1915
|
return removeDuplicateErrorMessages(error);
|
|
1546
1916
|
};
|
|
1547
1917
|
|
|
1548
|
-
var _excluded$
|
|
1549
|
-
function ownKeys$
|
|
1550
|
-
function _objectSpread$
|
|
1918
|
+
var _excluded$2 = ["label", "value", "onChange", "error", "onBlur"];
|
|
1919
|
+
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; }
|
|
1920
|
+
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; }
|
|
1551
1921
|
var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
1552
1922
|
var _ref$label = _ref.label,
|
|
1553
1923
|
label = _ref$label === void 0 ? "" : _ref$label,
|
|
@@ -1559,7 +1929,7 @@ var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
|
1559
1929
|
error = _ref$error === void 0 ? "" : _ref$error,
|
|
1560
1930
|
_ref$onBlur = _ref.onBlur,
|
|
1561
1931
|
onBlur = _ref$onBlur === void 0 ? neetoCist.noop : _ref$onBlur,
|
|
1562
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
1932
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$2);
|
|
1563
1933
|
var _useState = React.useState(""),
|
|
1564
1934
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1565
1935
|
inputValue = _useState2[0],
|
|
@@ -1606,7 +1976,7 @@ var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
|
1606
1976
|
"data-testid": "".concat(utils.hyphenize(label), "-input-label"),
|
|
1607
1977
|
children: label
|
|
1608
1978
|
})
|
|
1609
|
-
}), /*#__PURE__*/jsxRuntime.jsx(CreatableSelect, _objectSpread$
|
|
1979
|
+
}), /*#__PURE__*/jsxRuntime.jsx(CreatableSelect, _objectSpread$5({
|
|
1610
1980
|
isMulti: true,
|
|
1611
1981
|
required: true,
|
|
1612
1982
|
classNamePrefix: "neeto-ui-react-select",
|
|
@@ -1616,7 +1986,7 @@ var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
|
1616
1986
|
className: classnames("neeto-ui-react-select__container neeto-ui-react-select__container--medium neeto-ui-email-input__select", {
|
|
1617
1987
|
"neeto-ui-react-select__container--error": !!error
|
|
1618
1988
|
}),
|
|
1619
|
-
styles: _objectSpread$
|
|
1989
|
+
styles: _objectSpread$5(_objectSpread$5({}, CUSTOM_STYLES), {}, {
|
|
1620
1990
|
control: ramda.mergeLeft({
|
|
1621
1991
|
maxHeight: "200px",
|
|
1622
1992
|
overflowY: "auto"
|
|
@@ -1628,7 +1998,7 @@ var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
|
1628
1998
|
},
|
|
1629
1999
|
onInputChange: setInputValue,
|
|
1630
2000
|
onKeyDown: handleKeyDown
|
|
1631
|
-
}, _objectSpread$
|
|
2001
|
+
}, _objectSpread$5({
|
|
1632
2002
|
inputValue: inputValue,
|
|
1633
2003
|
isFocused: isFocused,
|
|
1634
2004
|
onChange: onChange,
|
|
@@ -1650,8 +2020,8 @@ var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
|
1650
2020
|
});
|
|
1651
2021
|
};
|
|
1652
2022
|
|
|
1653
|
-
function ownKeys$
|
|
1654
|
-
function _objectSpread$
|
|
2023
|
+
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; }
|
|
2024
|
+
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; }
|
|
1655
2025
|
var validateDomains = function validateDomains(value) {
|
|
1656
2026
|
var schema = yup__namespace.array().of(yup__namespace.string().test("verify domains", i18next.t("neetoForm.error.invalidDomain"), function (domain) {
|
|
1657
2027
|
return VALID_DOMAIN_REGEX.test(domain);
|
|
@@ -1691,7 +2061,7 @@ var buildHelpPopoverLabelProps = function buildHelpPopoverLabelProps(popoverDesc
|
|
|
1691
2061
|
return {
|
|
1692
2062
|
helpIconProps: {
|
|
1693
2063
|
"data-testid": "help-popover-button",
|
|
1694
|
-
popoverProps: _objectSpread$
|
|
2064
|
+
popoverProps: _objectSpread$4({
|
|
1695
2065
|
description: popoverDescription
|
|
1696
2066
|
}, helpLink && {
|
|
1697
2067
|
helpLinkProps: {
|
|
@@ -1830,15 +2200,15 @@ var getAllowedFileTypes = function getAllowedFileTypes(_ref) {
|
|
|
1830
2200
|
allowedFileTypes = _ref.allowedFileTypes;
|
|
1831
2201
|
var fileTypes = buildFileTypesList(allowedFileTypes);
|
|
1832
2202
|
if (isChecked) {
|
|
1833
|
-
var fileTypesSet = new Set([].concat(_toConsumableArray(
|
|
2203
|
+
var fileTypesSet = new Set([].concat(_toConsumableArray(yup.FILE_TYPES_MAP[type]), _toConsumableArray(fileTypes)));
|
|
1834
2204
|
return Array.from(fileTypesSet).join(", ");
|
|
1835
2205
|
}
|
|
1836
|
-
var newFileTypes = ramda.difference(fileTypes,
|
|
2206
|
+
var newFileTypes = ramda.difference(fileTypes, yup.FILE_TYPES_MAP[type]);
|
|
1837
2207
|
return newFileTypes.join(", ");
|
|
1838
2208
|
};
|
|
1839
2209
|
var isFileTypeEnabled = function isFileTypeEnabled(type, allowedFileTypes) {
|
|
1840
2210
|
var fileTypes = buildFileTypesList(allowedFileTypes);
|
|
1841
|
-
return ramda.isEmpty(ramda.difference(
|
|
2211
|
+
return ramda.isEmpty(ramda.difference(yup.FILE_TYPES_MAP[type], fileTypes));
|
|
1842
2212
|
};
|
|
1843
2213
|
|
|
1844
2214
|
var FileUpload = function FileUpload() {
|
|
@@ -1874,7 +2244,7 @@ var FileUpload = function FileUpload() {
|
|
|
1874
2244
|
children: t("neetoForm.fileUpload.fileTypes")
|
|
1875
2245
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1876
2246
|
className: "flex space-x-4",
|
|
1877
|
-
children:
|
|
2247
|
+
children: yup.FILE_GROUPS.map(function (_ref2) {
|
|
1878
2248
|
var name = _ref2.name,
|
|
1879
2249
|
label = _ref2.label;
|
|
1880
2250
|
return /*#__PURE__*/React.createElement(FileGroup, {
|
|
@@ -1905,7 +2275,7 @@ var OpinionScale = function OpinionScale() {
|
|
|
1905
2275
|
"data-testid": "neeto-form-engine-opinion-scale-min-value",
|
|
1906
2276
|
label: t("neetoForm.common.start"),
|
|
1907
2277
|
name: "minValue",
|
|
1908
|
-
options:
|
|
2278
|
+
options: yup.OPINION_SCALE_MIN_VALUE_OPTIONS,
|
|
1909
2279
|
onChange: function onChange(option) {
|
|
1910
2280
|
return setFieldValue("minValue", option === null || option === void 0 ? void 0 : option.value);
|
|
1911
2281
|
}
|
|
@@ -1914,7 +2284,7 @@ var OpinionScale = function OpinionScale() {
|
|
|
1914
2284
|
"data-testid": "neeto-form-engine-opinion-scale-max-value",
|
|
1915
2285
|
label: t("neetoForm.common.end"),
|
|
1916
2286
|
name: "maxValue",
|
|
1917
|
-
options:
|
|
2287
|
+
options: yup.OPINION_SCALE_MAX_VALUE_OPTIONS,
|
|
1918
2288
|
onChange: function onChange(option) {
|
|
1919
2289
|
return setFieldValue("maxValue", option === null || option === void 0 ? void 0 : option.value);
|
|
1920
2290
|
}
|
|
@@ -1929,21 +2299,21 @@ var OpinionScale = function OpinionScale() {
|
|
|
1929
2299
|
className: "w-1/2",
|
|
1930
2300
|
"data-testid": "neeto-form-engine-opinion-scale-left-label",
|
|
1931
2301
|
label: t("neetoForm.questions.opinionScale.leftLabel"),
|
|
1932
|
-
maxLength:
|
|
2302
|
+
maxLength: yup.OPINION_LABEL_MAX_LENGTH,
|
|
1933
2303
|
name: "leftOpinionLabel"
|
|
1934
2304
|
}), /*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
1935
2305
|
className: "w-1/2",
|
|
1936
2306
|
"data-testid": "neeto-form-engine-opinion-scale-right-label",
|
|
1937
2307
|
label: t("neetoForm.questions.opinionScale.rightLabel"),
|
|
1938
|
-
maxLength:
|
|
2308
|
+
maxLength: yup.OPINION_LABEL_MAX_LENGTH,
|
|
1939
2309
|
name: "rightOpinionLabel"
|
|
1940
2310
|
})]
|
|
1941
2311
|
})]
|
|
1942
2312
|
});
|
|
1943
2313
|
};
|
|
1944
2314
|
|
|
1945
|
-
function ownKeys$
|
|
1946
|
-
function _objectSpread$
|
|
2315
|
+
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; }
|
|
2316
|
+
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; }
|
|
1947
2317
|
var Options = function Options(_ref) {
|
|
1948
2318
|
var questionProps = _ref.questionProps;
|
|
1949
2319
|
var _useTranslation = reactI18next.useTranslation(),
|
|
@@ -1980,15 +2350,15 @@ var Options = function Options(_ref) {
|
|
|
1980
2350
|
var isAddOptionDisabled = disableAddOption || isManageOptionDisabled;
|
|
1981
2351
|
var isRemoveOptionDisabled = disableRemoveOption || isManageOptionDisabled;
|
|
1982
2352
|
var isDropdown = values.kind === constants.QUESTION_TYPES.DROPDOWN;
|
|
1983
|
-
var isPictureChoice = isPictureChoiceEnabled && !isDropdown && (values.isPictureChoice ||
|
|
1984
|
-
var imageHeight = values.imageHeight ||
|
|
2353
|
+
var isPictureChoice = isPictureChoiceEnabled && !isDropdown && (values.isPictureChoice || yup.DEFAULT_CHOICE_QUESTION_ATTRIBUTES.isPictureChoice);
|
|
2354
|
+
var imageHeight = values.imageHeight || yup.DEFAULT_CHOICE_QUESTION_ATTRIBUTES.imageHeight;
|
|
1985
2355
|
var handleImageHeightChange = function handleImageHeightChange(value) {
|
|
1986
2356
|
setFieldValue("imageHeight", value);
|
|
1987
2357
|
};
|
|
1988
2358
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1989
2359
|
className: "w-full space-y-4",
|
|
1990
2360
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1991
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Label, _objectSpread$
|
|
2361
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label, _objectSpread$3(_objectSpread$3({
|
|
1992
2362
|
className: "mb-2 block"
|
|
1993
2363
|
}, optionLabelProps), {}, {
|
|
1994
2364
|
children: t("neetoForm.questions.common.questionFields.field.options")
|
|
@@ -2012,8 +2382,8 @@ var Options = function Options(_ref) {
|
|
|
2012
2382
|
draggable: !isManageOptionDisabled,
|
|
2013
2383
|
isAddOptionEnabled: !isAddOptionDisabled,
|
|
2014
2384
|
isDeleteOptionEnabled: !isRemoveOptionDisabled,
|
|
2015
|
-
isNewItemsPrefilled:
|
|
2016
|
-
minOptions:
|
|
2385
|
+
isNewItemsPrefilled: yup.isDefaultLanguage(selectedLanguage),
|
|
2386
|
+
minOptions: yup.MINIMUM_OPTIONS,
|
|
2017
2387
|
shouldResetEmptyOptionOnBlur: false,
|
|
2018
2388
|
onChange: setOptionsAttributes
|
|
2019
2389
|
})
|
|
@@ -2043,8 +2413,8 @@ var Options = function Options(_ref) {
|
|
|
2043
2413
|
weight: "medium",
|
|
2044
2414
|
children: t("neetoForm.questions.common.questionFields.field.imageHeight")
|
|
2045
2415
|
}), /*#__PURE__*/jsxRuntime.jsx(Slider, {
|
|
2046
|
-
max:
|
|
2047
|
-
min:
|
|
2416
|
+
max: yup.IMAGE_HEIGHT_SLIDER_DEFAULTS.max,
|
|
2417
|
+
min: yup.IMAGE_HEIGHT_SLIDER_DEFAULTS.min,
|
|
2048
2418
|
value: imageHeight,
|
|
2049
2419
|
onChange: handleImageHeightChange
|
|
2050
2420
|
})]
|
|
@@ -2068,7 +2438,7 @@ var Rating = function Rating() {
|
|
|
2068
2438
|
className: "w-full",
|
|
2069
2439
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2070
2440
|
className: "flex gap-6",
|
|
2071
|
-
children:
|
|
2441
|
+
children: yup.RATING_OPTIONS$1.map(function (_ref2) {
|
|
2072
2442
|
var Icon = _ref2.icon,
|
|
2073
2443
|
name = _ref2.name,
|
|
2074
2444
|
color = _ref2.color;
|
|
@@ -2105,7 +2475,7 @@ var StarRating = function StarRating() {
|
|
|
2105
2475
|
"data-testid": "neeto-form-engine-star-rating-min-value",
|
|
2106
2476
|
label: t("neetoForm.common.start"),
|
|
2107
2477
|
name: "minValue",
|
|
2108
|
-
options:
|
|
2478
|
+
options: yup.STAR_RATING_MIN_VALUE_OPTIONS,
|
|
2109
2479
|
onChange: function onChange(option) {
|
|
2110
2480
|
return setFieldValue("minValue", option === null || option === void 0 ? void 0 : option.value);
|
|
2111
2481
|
}
|
|
@@ -2114,7 +2484,7 @@ var StarRating = function StarRating() {
|
|
|
2114
2484
|
"data-testid": "neeto-form-engine-star-rating-max-value",
|
|
2115
2485
|
label: t("neetoForm.common.end"),
|
|
2116
2486
|
name: "maxValue",
|
|
2117
|
-
options:
|
|
2487
|
+
options: yup.STAR_RATING_MAX_VALUE_OPTIONS,
|
|
2118
2488
|
onChange: function onChange(option) {
|
|
2119
2489
|
return setFieldValue("maxValue", option === null || option === void 0 ? void 0 : option.value);
|
|
2120
2490
|
}
|
|
@@ -2123,7 +2493,7 @@ var StarRating = function StarRating() {
|
|
|
2123
2493
|
children: t("neetoForm.common.shape")
|
|
2124
2494
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2125
2495
|
className: "flex gap-2",
|
|
2126
|
-
children: Object.entries(
|
|
2496
|
+
children: Object.entries(yup.STAR_RATING_ICONS_MAP).map(function (_ref) {
|
|
2127
2497
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
2128
2498
|
name = _ref2[0],
|
|
2129
2499
|
IconType = _ref2[1];
|
|
@@ -2144,6 +2514,9 @@ var StarRating = function StarRating() {
|
|
|
2144
2514
|
});
|
|
2145
2515
|
};
|
|
2146
2516
|
|
|
2517
|
+
var _excluded$1 = ["fields"];
|
|
2518
|
+
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; }
|
|
2519
|
+
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; }
|
|
2147
2520
|
var CHECKBOX = constants.QUESTION_TYPES.CHECKBOX,
|
|
2148
2521
|
RADIO = constants.QUESTION_TYPES.RADIO,
|
|
2149
2522
|
DROPDOWN = constants.QUESTION_TYPES.DROPDOWN,
|
|
@@ -2152,12 +2525,16 @@ var CHECKBOX = constants.QUESTION_TYPES.CHECKBOX,
|
|
|
2152
2525
|
RATING = constants.QUESTION_TYPES.RATING,
|
|
2153
2526
|
FILE_UPLOAD = constants.QUESTION_TYPES.FILE_UPLOAD,
|
|
2154
2527
|
CAPTCHA = constants.QUESTION_TYPES.CAPTCHA,
|
|
2155
|
-
EMAIL = constants.QUESTION_TYPES.EMAIL
|
|
2528
|
+
EMAIL = constants.QUESTION_TYPES.EMAIL,
|
|
2529
|
+
ADDRESS = constants.QUESTION_TYPES.ADDRESS;
|
|
2156
2530
|
var transformValueForOption = function transformValueForOption(_ref) {
|
|
2157
2531
|
var label = _ref.label,
|
|
2158
2532
|
type = _ref.type;
|
|
2159
2533
|
return "".concat(neetoCist.slugify(label), "-").concat(type);
|
|
2160
2534
|
};
|
|
2535
|
+
var omitDraftId = neetoCist.modifyBy({
|
|
2536
|
+
id: ramda.startsWith(DRAFT_ID_PREFIX)
|
|
2537
|
+
}, ramda.omit(["id"]));
|
|
2161
2538
|
var renderAdditionalData = function renderAdditionalData(_ref2) {
|
|
2162
2539
|
var kind = _ref2.kind,
|
|
2163
2540
|
questionProps = _ref2.questionProps,
|
|
@@ -2179,6 +2556,8 @@ var renderAdditionalData = function renderAdditionalData(_ref2) {
|
|
|
2179
2556
|
return /*#__PURE__*/jsxRuntime.jsx(FileUpload, {});
|
|
2180
2557
|
case CAPTCHA:
|
|
2181
2558
|
return /*#__PURE__*/jsxRuntime.jsx(Captcha, {});
|
|
2559
|
+
case ADDRESS:
|
|
2560
|
+
return /*#__PURE__*/jsxRuntime.jsx(Address, {});
|
|
2182
2561
|
case EMAIL:
|
|
2183
2562
|
return !usesCustomSubmissionComponent && /*#__PURE__*/jsxRuntime.jsx(Email, {
|
|
2184
2563
|
usesCustomSubmissionComponent: usesCustomSubmissionComponent
|
|
@@ -2188,7 +2567,7 @@ var renderAdditionalData = function renderAdditionalData(_ref2) {
|
|
|
2188
2567
|
}
|
|
2189
2568
|
};
|
|
2190
2569
|
var resolveActionComponent = function resolveActionComponent(action) {
|
|
2191
|
-
return ramda.equals(action,
|
|
2570
|
+
return ramda.equals(action, yup.QUESTION_ACTIONS.ADD) ? Add : Edit;
|
|
2192
2571
|
};
|
|
2193
2572
|
var getQuestionKind = function getQuestionKind(questionKinds, pattern) {
|
|
2194
2573
|
var questionKind = neetoCist.findBy(pattern, questionKinds);
|
|
@@ -2255,6 +2634,21 @@ var readOnlySwitchLabelProps = function readOnlySwitchLabelProps(helpUrl) {
|
|
|
2255
2634
|
}
|
|
2256
2635
|
};
|
|
2257
2636
|
};
|
|
2637
|
+
var transformValues = function transformValues(values) {
|
|
2638
|
+
switch (values.kind) {
|
|
2639
|
+
case constants.QUESTION_TYPES.ADDRESS:
|
|
2640
|
+
{
|
|
2641
|
+
var _values$fields = values.fields,
|
|
2642
|
+
fields = _values$fields === void 0 ? [] : _values$fields,
|
|
2643
|
+
rest = _objectWithoutProperties(values, _excluded$1);
|
|
2644
|
+
return _objectSpread$2(_objectSpread$2({}, rest), {}, {
|
|
2645
|
+
fieldsAttributes: ramda.map(yup.renameKey("deleted", "_destroy"), omitDraftId(fields))
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
default:
|
|
2649
|
+
return values;
|
|
2650
|
+
}
|
|
2651
|
+
};
|
|
2258
2652
|
|
|
2259
2653
|
var _excluded = ["isOpen", "onClose", "action", "question", "availableQuestionKinds"];
|
|
2260
2654
|
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; }
|
|
@@ -2289,10 +2683,10 @@ var AddQuestion = function AddQuestion(_ref) {
|
|
|
2289
2683
|
disabledAddButtonHelpPopoverProps = _ref.disabledAddButtonHelpPopoverProps,
|
|
2290
2684
|
isDisabled = _ref.isDisabled,
|
|
2291
2685
|
addQuestionHelpProps = _ref.addQuestionHelpProps;
|
|
2292
|
-
var helpPopoverProps = isDisabled ?
|
|
2686
|
+
var helpPopoverProps = isDisabled ? yup.buildDisabledAddButtonHelpPopoverProps(disabledAddButtonHelpPopoverProps) : {};
|
|
2293
2687
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2294
2688
|
className: "mb-8 flex w-full items-center gap-x-1",
|
|
2295
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Button, _objectSpread({},
|
|
2689
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button, _objectSpread({}, yup.buildAddQuestionButtonProps(onAdd, isDisabled))), isDisabled && /*#__PURE__*/jsxRuntime.jsx(HelpPopover, _objectSpread({}, helpPopoverProps)), neetoCist.isPresent(addQuestionHelpProps) && !isDisabled && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
2296
2690
|
children: /*#__PURE__*/jsxRuntime.jsx(HelpPopover, _objectSpread({}, addQuestionHelpProps))
|
|
2297
2691
|
})]
|
|
2298
2692
|
});
|
|
@@ -2358,7 +2752,7 @@ var Form = function Form(_ref) {
|
|
|
2358
2752
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2359
2753
|
args[_key] = arguments[_key];
|
|
2360
2754
|
}
|
|
2361
|
-
onMutateSuccess === null || onMutateSuccess === void 0 || onMutateSuccess.apply(void 0, [
|
|
2755
|
+
onMutateSuccess === null || onMutateSuccess === void 0 || onMutateSuccess.apply(void 0, [yup.QUESTION_ACTIONS.CLONE].concat(args));
|
|
2362
2756
|
utils.showThumbsUpToastr();
|
|
2363
2757
|
}
|
|
2364
2758
|
}),
|
|
@@ -2368,7 +2762,7 @@ var Form = function Form(_ref) {
|
|
|
2368
2762
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2369
2763
|
args[_key2] = arguments[_key2];
|
|
2370
2764
|
}
|
|
2371
|
-
onMutateSuccess === null || onMutateSuccess === void 0 || onMutateSuccess.apply(void 0, [
|
|
2765
|
+
onMutateSuccess === null || onMutateSuccess === void 0 || onMutateSuccess.apply(void 0, [yup.QUESTION_ACTIONS.REORDER].concat(args));
|
|
2372
2766
|
setFormData({
|
|
2373
2767
|
isReorderingQuestions: false
|
|
2374
2768
|
});
|
|
@@ -2379,7 +2773,7 @@ var Form = function Form(_ref) {
|
|
|
2379
2773
|
var handleReorder = function handleReorder(questions) {
|
|
2380
2774
|
var payload = {
|
|
2381
2775
|
neetoFormQuestions: {
|
|
2382
|
-
questions:
|
|
2776
|
+
questions: yup.buildReorderPayload(questions)
|
|
2383
2777
|
},
|
|
2384
2778
|
language: selectedLanguage
|
|
2385
2779
|
};
|
|
@@ -2408,11 +2802,11 @@ var Form = function Form(_ref) {
|
|
|
2408
2802
|
setSelectedQuestion(question);
|
|
2409
2803
|
};
|
|
2410
2804
|
var handleAdd = function handleAdd() {
|
|
2411
|
-
setSelectedAction(
|
|
2805
|
+
setSelectedAction(yup.QUESTION_ACTIONS.ADD);
|
|
2412
2806
|
setIsManageQuestionPaneOpen(true);
|
|
2413
2807
|
};
|
|
2414
2808
|
var handleEdit = function handleEdit() {
|
|
2415
|
-
setSelectedAction(
|
|
2809
|
+
setSelectedAction(yup.QUESTION_ACTIONS.EDIT);
|
|
2416
2810
|
setIsManageQuestionPaneOpen(true);
|
|
2417
2811
|
};
|
|
2418
2812
|
var handleClone = function handleClone() {
|
|
@@ -2552,7 +2946,7 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
2552
2946
|
_ref$isKindAlreadyAct = _ref.isKindAlreadyActive,
|
|
2553
2947
|
isKindAlreadyActive = _ref$isKindAlreadyAct === void 0 ? isQuestionKindAlreadyActive : _ref$isKindAlreadyAct,
|
|
2554
2948
|
_ref$getActiveKindDet = _ref.getActiveKindDetails,
|
|
2555
|
-
getActiveKindDetails = _ref$getActiveKindDet === void 0 ?
|
|
2949
|
+
getActiveKindDetails = _ref$getActiveKindDet === void 0 ? yup.getActiveQuestionKindDetails : _ref$getActiveKindDet,
|
|
2556
2950
|
kindUniqueOn = _ref.kindUniqueOn,
|
|
2557
2951
|
_ref$isQuestionDeleta = _ref.isQuestionDeletable,
|
|
2558
2952
|
isQuestionDeletable = _ref$isQuestionDeleta === void 0 ? ramda.T : _ref$isQuestionDeleta,
|
|
@@ -2563,7 +2957,7 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
2563
2957
|
formTitle = _ref$formTitle === void 0 ? "" : _ref$formTitle,
|
|
2564
2958
|
formDescription = _ref.formDescription,
|
|
2565
2959
|
_ref$availableLanguag = _ref.availableLanguages,
|
|
2566
|
-
availableLanguages = _ref$availableLanguag === void 0 ?
|
|
2960
|
+
availableLanguages = _ref$availableLanguag === void 0 ? yup.DEFAULT_AVAILABLE_LANGUAGES : _ref$availableLanguag,
|
|
2567
2961
|
_ref$selectedLanguage = _ref.selectedLanguage,
|
|
2568
2962
|
selectedLanguage = _ref$selectedLanguage === void 0 ? "en" : _ref$selectedLanguage,
|
|
2569
2963
|
_ref$onLanguageChange = _ref.onLanguageChange,
|
|
@@ -2577,7 +2971,7 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
2577
2971
|
_ref$allowAdditionalG = _ref.allowAdditionalGuests,
|
|
2578
2972
|
allowAdditionalGuests = _ref$allowAdditionalG === void 0 ? false : _ref$allowAdditionalG,
|
|
2579
2973
|
_ref$advancedFeatures = _ref.advancedFeatures,
|
|
2580
|
-
advancedFeatures = _ref$advancedFeatures === void 0 ?
|
|
2974
|
+
advancedFeatures = _ref$advancedFeatures === void 0 ? yup.DEFAULT_ADVANCED_FEATURES : _ref$advancedFeatures,
|
|
2581
2975
|
helpDocUrls = _ref.helpDocUrls,
|
|
2582
2976
|
className = _ref.className,
|
|
2583
2977
|
_ref$usesCustomSubmis = _ref.usesCustomSubmissionComponent,
|
|
@@ -2597,7 +2991,7 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
2597
2991
|
data = _useForm.data,
|
|
2598
2992
|
isLoading = _useForm.isLoading,
|
|
2599
2993
|
isQuestionsPending = _useForm.isPending;
|
|
2600
|
-
var _ref2 = data ||
|
|
2994
|
+
var _ref2 = data || yup.QUESTIONS_INITIAL_VALUE,
|
|
2601
2995
|
isFormEnabled = _ref2.enabled,
|
|
2602
2996
|
savedTitle = _ref2.title,
|
|
2603
2997
|
questionsFromCache = _ref2.questions,
|
|
@@ -2615,13 +3009,13 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
2615
3009
|
queryClient.setQueryData([constants.QUERY_KEYS.QUESTIONS, "preview/".concat(id), selectedLanguage], ramda.assoc("questions", questions));
|
|
2616
3010
|
}
|
|
2617
3011
|
};
|
|
2618
|
-
var isRequiredField = ramda.either(
|
|
3012
|
+
var isRequiredField = ramda.either(yup.isMandatoryField, isFieldRequired);
|
|
2619
3013
|
var isDisabledFieldLabel = function isDisabledFieldLabel(field) {
|
|
2620
|
-
return
|
|
3014
|
+
return yup.isImmutableField(field) || (isFieldLabelDisabled !== null && isFieldLabelDisabled !== void 0 ? isFieldLabelDisabled : ramda.F)(field);
|
|
2621
3015
|
};
|
|
2622
|
-
var defaultQuestionKinds = allowAdditionalGuests ?
|
|
2623
|
-
type:
|
|
2624
|
-
},
|
|
3016
|
+
var defaultQuestionKinds = allowAdditionalGuests ? yup.QUESTION_KINDS : neetoCist.removeBy({
|
|
3017
|
+
type: yup.QUESTION_KIND.ADDITIONAL_GUESTS.value
|
|
3018
|
+
}, yup.QUESTION_KINDS);
|
|
2625
3019
|
var isUsingDefaultQuestionKinds = ramda.isNil(questionKinds);
|
|
2626
3020
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2627
3021
|
className: classnames("neeto-form-nano-form-outer-wrapper relative", className),
|