@bigbinary/neeto-form-frontend 4.2.11 → 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 +50 -3
- package/dist/BuildForm.js +548 -87
- 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 +9 -8
- package/dist/UrlBuilder.js.map +1 -1
- package/dist/{buildForm-CooylMLL.js → buildForm-Bdc3ubm4.js} +2 -2
- package/dist/{buildForm-CooylMLL.js.map → buildForm-Bdc3ubm4.js.map} +1 -1
- package/dist/{buildForm-DcE5kFvR.js → buildForm-CkVmGF-A.js} +2 -2
- package/dist/{buildForm-DcE5kFvR.js.map → buildForm-CkVmGF-A.js.map} +1 -1
- package/dist/cjs/BuildForm.js +614 -153
- 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 -18
- 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-51SEJjzI.js → constants-30230o5k.js} +4 -2
- package/dist/constants-30230o5k.js.map +1 -0
- package/dist/{constants-C9wKMfgo.js → constants-DNNZYQ9X.js} +4 -2
- package/dist/constants-DNNZYQ9X.js.map +1 -0
- package/dist/hooks.js +4 -4
- package/dist/{index-DnHrq-hl.js → index-BfavwyMH.js} +2 -2
- package/dist/{index-DnHrq-hl.js.map → index-BfavwyMH.js.map} +1 -1
- package/dist/{index-D4URTv1p.js → index-Dz5Yvk3n.js} +2 -2
- package/dist/{index-D4URTv1p.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-BGNEnxvm.js → useFormSubmission-CdKlP6De.js} +2 -2
- package/dist/{useFormSubmission-BGNEnxvm.js.map → useFormSubmission-CdKlP6De.js.map} +1 -1
- package/dist/{useFormSubmission-BUPnuOSG.js → useFormSubmission-zyh3tA0H.js} +2 -2
- package/dist/{useFormSubmission-BUPnuOSG.js.map → useFormSubmission-zyh3tA0H.js.map} +1 -1
- package/dist/{utils-Dn-q4QBc.js → utils-CDyve_0y.js} +274 -73
- package/dist/utils-CDyve_0y.js.map +1 -0
- package/dist/{utils-Ch7Ggngj.js → utils-DfujkkDT.js} +323 -122
- package/dist/utils-DfujkkDT.js.map +1 -0
- package/dist/{constants-BjWWA3Oq.js → yup-DcJey7xZ.js} +149 -26
- package/dist/yup-DcJey7xZ.js.map +1 -0
- package/dist/{constants-QPLZ_r-D.js → yup-SHH_PrTm.js} +139 -28
- package/dist/yup-SHH_PrTm.js.map +1 -0
- package/package.json +20 -19
- package/types.d.ts +3 -0
- package/dist/constants-51SEJjzI.js.map +0 -1
- package/dist/constants-BjWWA3Oq.js.map +0 -1
- package/dist/constants-C9wKMfgo.js.map +0 -1
- package/dist/constants-QPLZ_r-D.js.map +0 -1
- package/dist/utils-Ch7Ggngj.js.map +0 -1
- package/dist/utils-Dn-q4QBc.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
|
});
|
|
@@ -621,12 +628,14 @@ var NAME = constants.QUESTION_TYPES.NAME,
|
|
|
621
628
|
INTEGER = constants.QUESTION_TYPES.INTEGER,
|
|
622
629
|
DECIMAL = constants.QUESTION_TYPES.DECIMAL,
|
|
623
630
|
STAR_RATING$1 = constants.QUESTION_TYPES.STAR_RATING,
|
|
631
|
+
OPINION_SCALE$1 = constants.QUESTION_TYPES.OPINION_SCALE,
|
|
624
632
|
RATING$1 = constants.QUESTION_TYPES.RATING,
|
|
625
633
|
DATE = constants.QUESTION_TYPES.DATE,
|
|
626
634
|
FILE_UPLOAD$1 = constants.QUESTION_TYPES.FILE_UPLOAD,
|
|
627
635
|
CAPTCHA$1 = constants.QUESTION_TYPES.CAPTCHA,
|
|
628
|
-
SMS_REMINDER = constants.QUESTION_TYPES.SMS_REMINDER
|
|
629
|
-
|
|
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]);
|
|
630
639
|
var QUESTIONS_WITH_PLACEHOLDERS = [NAME, PHONE, EMAIL$1, ADDITIONAL_GUESTS, TEXT, TEXTAREA, RICH_TEXT, INTEGER, DECIMAL, DATE, SMS_REMINDER];
|
|
631
640
|
var DEFAULT_PLACEHOLDERS = {
|
|
632
641
|
CHECKBOX: i18next.t("neetoForm.questions.common.questionFields.field.labelExample", {
|
|
@@ -646,18 +655,19 @@ var INITIAL_VALUES = {
|
|
|
646
655
|
isSplitMode: false
|
|
647
656
|
};
|
|
648
657
|
var VALID_FIELD_CODE_REGEX = /^[a-z0-9]+(_[a-z0-9]+)*$/;
|
|
658
|
+
var DRAFT_ID_PREFIX = "draft-";
|
|
649
659
|
|
|
650
660
|
var useHelpDoc = function useHelpDoc(key) {
|
|
651
661
|
return buildForm.useBuildFormStore(ramda.path(["formState", "helpDocUrls", key]));
|
|
652
662
|
};
|
|
653
663
|
|
|
654
|
-
var _excluded$
|
|
655
|
-
function ownKeys$
|
|
656
|
-
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; }
|
|
657
667
|
var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
|
|
658
668
|
var label = _ref.label,
|
|
659
669
|
name = _ref.name,
|
|
660
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
670
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$a);
|
|
661
671
|
var _useFormikContext = formik.useFormikContext(),
|
|
662
672
|
dirty = _useFormikContext.dirty,
|
|
663
673
|
isValid = _useFormikContext.isValid,
|
|
@@ -672,7 +682,7 @@ var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
|
|
|
672
682
|
var end = element.value.length;
|
|
673
683
|
element.setSelectionRange(end, end);
|
|
674
684
|
};
|
|
675
|
-
return /*#__PURE__*/jsxRuntime.jsx(Textarea, _objectSpread$
|
|
685
|
+
return /*#__PURE__*/jsxRuntime.jsx(Textarea, _objectSpread$g({
|
|
676
686
|
label: label,
|
|
677
687
|
name: name,
|
|
678
688
|
className: "neeto-form-nano-adaptive-input",
|
|
@@ -686,8 +696,8 @@ var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
|
|
|
686
696
|
}, otherProps));
|
|
687
697
|
};
|
|
688
698
|
|
|
689
|
-
function ownKeys$
|
|
690
|
-
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; }
|
|
691
701
|
var LabelWithPlaceholder = function LabelWithPlaceholder(_ref) {
|
|
692
702
|
var kind = _ref.kind,
|
|
693
703
|
isLabelDisabled = _ref.isLabelDisabled,
|
|
@@ -701,14 +711,14 @@ var LabelWithPlaceholder = function LabelWithPlaceholder(_ref) {
|
|
|
701
711
|
var shouldShowPlaceholder = ramda.includes(kind, QUESTIONS_WITH_PLACEHOLDERS);
|
|
702
712
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
703
713
|
className: "space-y-4",
|
|
704
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(FormikAdaptiveInput, _objectSpread$
|
|
714
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(FormikAdaptiveInput, _objectSpread$f({
|
|
705
715
|
required: true,
|
|
706
716
|
disabled: isLabelDisabled,
|
|
707
717
|
label: t("neetoForm.questions.common.questionFields.field.question"),
|
|
708
718
|
name: "label",
|
|
709
719
|
placeholder: DEFAULT_PLACEHOLDERS[kind],
|
|
710
720
|
onChange: utils.withEventTargetValue(handleLabelChange)
|
|
711
|
-
}, labelProps)), shouldShowPlaceholder && /*#__PURE__*/jsxRuntime.jsx(FormikAdaptiveInput, _objectSpread$
|
|
721
|
+
}, labelProps)), shouldShowPlaceholder && /*#__PURE__*/jsxRuntime.jsx(FormikAdaptiveInput, _objectSpread$f({
|
|
712
722
|
className: "neeto-form-nano-placeholder-input neeto-form-nano-placeholder-input-".concat(kind),
|
|
713
723
|
name: "placeholder",
|
|
714
724
|
label: t("neetoForm.questions.common.questionFields.field.placeholder")
|
|
@@ -716,8 +726,8 @@ var LabelWithPlaceholder = function LabelWithPlaceholder(_ref) {
|
|
|
716
726
|
});
|
|
717
727
|
};
|
|
718
728
|
|
|
719
|
-
function ownKeys$
|
|
720
|
-
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; }
|
|
721
731
|
var Name = function Name(_ref) {
|
|
722
732
|
var isLabelDisabled = _ref.isLabelDisabled,
|
|
723
733
|
_handleLabelChange = _ref.handleLabelChange;
|
|
@@ -737,40 +747,40 @@ var Name = function Name(_ref) {
|
|
|
737
747
|
label: t("neetoForm.common.splitAsFirstAndLastNames"),
|
|
738
748
|
name: "isSplitMode"
|
|
739
749
|
}), isSplitMode && !usesCustomSubmissionComponent ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
740
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, _objectSpread$
|
|
750
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, _objectSpread$e(_objectSpread$e({}, commonProps), {}, {
|
|
741
751
|
handleLabelChange: function handleLabelChange(value) {
|
|
742
|
-
return _handleLabelChange(value,
|
|
752
|
+
return _handleLabelChange(value, yup.LABEL_FIELDS.FIRST_NAME);
|
|
743
753
|
},
|
|
744
754
|
labelProps: {
|
|
745
755
|
label: t("neetoForm.questions.common.questionFields.field.firstNameQuestion"),
|
|
746
|
-
name:
|
|
756
|
+
name: yup.LABEL_FIELDS.FIRST_NAME
|
|
747
757
|
},
|
|
748
758
|
placeholderProps: {
|
|
749
759
|
label: t("neetoForm.questions.common.questionFields.field.firstNamePlaceholder"),
|
|
750
760
|
name: "firstNamePlaceholder"
|
|
751
761
|
}
|
|
752
|
-
})), /*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, _objectSpread$
|
|
762
|
+
})), /*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, _objectSpread$e(_objectSpread$e({}, commonProps), {}, {
|
|
753
763
|
handleLabelChange: function handleLabelChange(value) {
|
|
754
|
-
return _handleLabelChange(value,
|
|
764
|
+
return _handleLabelChange(value, yup.LABEL_FIELDS.LAST_NAME);
|
|
755
765
|
},
|
|
756
766
|
labelProps: {
|
|
757
767
|
label: t("neetoForm.questions.common.questionFields.field.lastNameQuestion"),
|
|
758
|
-
name:
|
|
768
|
+
name: yup.LABEL_FIELDS.LAST_NAME
|
|
759
769
|
},
|
|
760
770
|
placeholderProps: {
|
|
761
771
|
label: t("neetoForm.questions.common.questionFields.field.lastNamePlaceholder"),
|
|
762
772
|
name: "lastNamePlaceholder"
|
|
763
773
|
}
|
|
764
774
|
}))]
|
|
765
|
-
}) : /*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, _objectSpread$
|
|
775
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, _objectSpread$e(_objectSpread$e({}, commonProps), {}, {
|
|
766
776
|
labelProps: {
|
|
767
|
-
name:
|
|
777
|
+
name: yup.LABEL_FIELDS.FULL_NAME
|
|
768
778
|
},
|
|
769
779
|
placeholderProps: {
|
|
770
780
|
name: "fullNamePlaceholder"
|
|
771
781
|
},
|
|
772
782
|
handleLabelChange: function handleLabelChange(value) {
|
|
773
|
-
return _handleLabelChange(value,
|
|
783
|
+
return _handleLabelChange(value, yup.LABEL_FIELDS.FULL_NAME);
|
|
774
784
|
}
|
|
775
785
|
}))]
|
|
776
786
|
});
|
|
@@ -886,7 +896,7 @@ var Editor = function Editor() {
|
|
|
886
896
|
var fieldName = "label";
|
|
887
897
|
var _useField = formik.useField({
|
|
888
898
|
name: fieldName,
|
|
889
|
-
validate:
|
|
899
|
+
validate: yup.validateEditorContent(editorRef)
|
|
890
900
|
}),
|
|
891
901
|
_useField2 = _slicedToArray(_useField, 3),
|
|
892
902
|
value = _useField2[0].value,
|
|
@@ -929,12 +939,12 @@ var RequiredSwitch = reactUtils.withT(function (_ref) {
|
|
|
929
939
|
});
|
|
930
940
|
});
|
|
931
941
|
|
|
932
|
-
var _excluded$
|
|
933
|
-
function ownKeys$
|
|
934
|
-
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; }
|
|
935
945
|
var InputWithMaxLength = function InputWithMaxLength(_ref) {
|
|
936
946
|
var maxLength = _ref.maxLength,
|
|
937
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
947
|
+
props = _objectWithoutProperties(_ref, _excluded$9);
|
|
938
948
|
var _useField = formik.useField(props),
|
|
939
949
|
_useField2 = _slicedToArray(_useField, 3),
|
|
940
950
|
value = _useField2[0].value,
|
|
@@ -945,7 +955,7 @@ var InputWithMaxLength = function InputWithMaxLength(_ref) {
|
|
|
945
955
|
}
|
|
946
956
|
}, [value, maxLength, setValue]);
|
|
947
957
|
var shouldShowMaxLength = value && value.length > maxLength - 10;
|
|
948
|
-
return /*#__PURE__*/jsxRuntime.jsx(Input, _objectSpread$
|
|
958
|
+
return /*#__PURE__*/jsxRuntime.jsx(Input, _objectSpread$d(_objectSpread$d({}, props), shouldShowMaxLength && {
|
|
949
959
|
maxLength: maxLength
|
|
950
960
|
}));
|
|
951
961
|
};
|
|
@@ -958,7 +968,7 @@ var FieldCode = function FieldCode() {
|
|
|
958
968
|
required: true,
|
|
959
969
|
label: t("neetoForm.questions.common.questionFields.field.fieldCode"),
|
|
960
970
|
name: "fieldCode",
|
|
961
|
-
rejectCharsRegex:
|
|
971
|
+
rejectCharsRegex: yup.FIELD_CODES_REJECT_CHARS_REGEX,
|
|
962
972
|
helpText: helpDocUrl && /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
963
973
|
i18nKey: "neetoForm.questions.common.questionFields.field.fieldCodeHelpDescription",
|
|
964
974
|
components: {
|
|
@@ -1038,11 +1048,11 @@ var Form$1 = function Form(_ref) {
|
|
|
1038
1048
|
}, [submitCount]);
|
|
1039
1049
|
var isRequired = questionKind && isRequiredField(questionKind);
|
|
1040
1050
|
var isLabelDisabled = questionKind && isDisabledFieldLabel(questionKind);
|
|
1041
|
-
var isImmutable = questionKind &&
|
|
1042
|
-
var shouldShowFieldCode = isFieldCodeEnabled && !ramda.includes(kind,
|
|
1043
|
-
var shouldShowHideSwitch = isFieldCodeEnabled && !usesCustomSubmissionComponent && !ramda.includes(kind,
|
|
1044
|
-
var canRestrictResponseVisibilityToHost = restrictResponseVisibilityToHost && !ramda.includes(kind,
|
|
1045
|
-
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);
|
|
1046
1056
|
var isBasicSettingsVisible = !isRequired && (!isImmutable || shouldShowHideSwitch);
|
|
1047
1057
|
var isSettingsBlockVisible = isBasicSettingsVisible || canMarkResponsesAsReadOnly;
|
|
1048
1058
|
var handleKindChange = function handleKindChange(option) {
|
|
@@ -1074,7 +1084,7 @@ var Form$1 = function Form(_ref) {
|
|
|
1074
1084
|
setTouched({});
|
|
1075
1085
|
};
|
|
1076
1086
|
var handleLabelChange = function handleLabelChange(label) {
|
|
1077
|
-
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;
|
|
1078
1088
|
setFieldValue(name, label);
|
|
1079
1089
|
if (isEdit) return;
|
|
1080
1090
|
var uniqueFieldCode = generateUniqueFieldCode({
|
|
@@ -1097,7 +1107,7 @@ var Form$1 = function Form(_ref) {
|
|
|
1097
1107
|
options: buildKindOptions(questionKinds),
|
|
1098
1108
|
label: t("neetoForm.questions.common.questionFields.field.questionType"),
|
|
1099
1109
|
onChange: handleKindChange
|
|
1100
|
-
}),
|
|
1110
|
+
}), yup.isRichTextQuestion(kind) ? /*#__PURE__*/jsxRuntime.jsx(Editor, {
|
|
1101
1111
|
isLabelDisabled: isLabelDisabled
|
|
1102
1112
|
}) : /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1103
1113
|
className: "space-y-6",
|
|
@@ -1110,7 +1120,7 @@ var Form$1 = function Form(_ref) {
|
|
|
1110
1120
|
dataTestid: "settings-card",
|
|
1111
1121
|
title: t("neetoForm.common.settings"),
|
|
1112
1122
|
children: [isBasicSettingsVisible && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1113
|
-
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, {
|
|
1114
1124
|
label: t("neetoForm.common.hideQuestion"),
|
|
1115
1125
|
name: "isHidden",
|
|
1116
1126
|
labelProps: hideSwitchLabelProps(hideQuestionHelpDocUrl)
|
|
@@ -1165,7 +1175,7 @@ var buildLabelValidationSchema = function buildLabelValidationSchema(kind, schem
|
|
|
1165
1175
|
if (index.isNameQuestion(kind)) {
|
|
1166
1176
|
return schema.notRequired();
|
|
1167
1177
|
}
|
|
1168
|
-
return ramda.includes(kind,
|
|
1178
|
+
return ramda.includes(kind, yup.RICH_TEXT_QUESTIONS) ? schema.test("required", richTextFieldMissingErrorMessage(kind), function (value) {
|
|
1169
1179
|
return !utils$1.isEditorEmpty(value);
|
|
1170
1180
|
}) : requiredLabelValidation(schema, i18next.t("neetoForm.questions.common.questionFields.field.question"));
|
|
1171
1181
|
};
|
|
@@ -1174,6 +1184,15 @@ var buildNameLabelValidationSchema = function buildNameLabelValidationSchema(que
|
|
|
1174
1184
|
var isRequired = isFullName ? !question.isSplitMode : question.isSplitMode;
|
|
1175
1185
|
return index.isNameQuestion(question.kind) && isRequired ? requiredLabelValidation(schema, i18next.t("neetoForm.questions.common.questionFields.field.question")) : schema.notRequired();
|
|
1176
1186
|
};
|
|
1187
|
+
var buildOpinionScaleLabelValidationSchema = function buildOpinionScaleLabelValidationSchema(label) {
|
|
1188
|
+
return stringSchema.when("hasOpinionLabels", {
|
|
1189
|
+
is: true,
|
|
1190
|
+
then: requiredLabelValidation(stringSchema, label).max(yup.OPINION_LABEL_MAX_LENGTH, i18next.t("neetoForm.error.mustBeOrLessThanOrEqualTo", {
|
|
1191
|
+
value: yup.OPINION_LABEL_MAX_LENGTH
|
|
1192
|
+
})),
|
|
1193
|
+
otherwise: stringSchema.notRequired()
|
|
1194
|
+
});
|
|
1195
|
+
};
|
|
1177
1196
|
var stringSchema = yup__namespace.string();
|
|
1178
1197
|
var formValidationSchema = function formValidationSchema(question) {
|
|
1179
1198
|
var isFieldCodeEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -1185,33 +1204,43 @@ var formValidationSchema = function formValidationSchema(question) {
|
|
|
1185
1204
|
fullNameLabel: buildNameLabelValidationSchema(question, stringSchema, true),
|
|
1186
1205
|
firstNameLabel: buildNameLabelValidationSchema(question, stringSchema),
|
|
1187
1206
|
lastNameLabel: buildNameLabelValidationSchema(question, stringSchema),
|
|
1188
|
-
fieldCode: yup__namespace.string().trim().notOneOf(
|
|
1189
|
-
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();
|
|
1190
1209
|
}),
|
|
1191
1210
|
optionsAttributes: yup__namespace.array().when("kind", function (kind, schema) {
|
|
1192
|
-
return ramda.includes(kind,
|
|
1211
|
+
return ramda.includes(kind, yup.SELECTABLE_KINDS) ? schema.of(yup__namespace.object().shape({
|
|
1193
1212
|
label: yup__namespace.string().when("_destroy", {
|
|
1194
1213
|
is: true,
|
|
1195
1214
|
otherwise: requiredLabelValidation(yup__namespace.string(), i18next.t("neetoForm.questions.common.questionFields.field.option"))
|
|
1196
1215
|
})
|
|
1197
1216
|
})) : schema.notRequired();
|
|
1198
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
|
+
}),
|
|
1199
1226
|
highestRatingLabel: yup__namespace.string().nullable(),
|
|
1200
1227
|
averageRatingLabel: yup__namespace.string().nullable(),
|
|
1201
|
-
lowestRatingLabel: yup__namespace.string().nullable()
|
|
1228
|
+
lowestRatingLabel: yup__namespace.string().nullable(),
|
|
1229
|
+
leftOpinionLabel: buildOpinionScaleLabelValidationSchema(i18next.t("neetoForm.questions.opinionScale.leftLabel")),
|
|
1230
|
+
rightOpinionLabel: buildOpinionScaleLabelValidationSchema(i18next.t("neetoForm.questions.opinionScale.rightLabel"))
|
|
1202
1231
|
});
|
|
1203
1232
|
};
|
|
1204
1233
|
|
|
1205
|
-
var _excluded$
|
|
1206
|
-
function ownKeys$
|
|
1207
|
-
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; }
|
|
1208
1237
|
var Add = function Add(_ref) {
|
|
1209
1238
|
var question = _ref.question,
|
|
1210
1239
|
onClose = _ref.onClose,
|
|
1211
1240
|
questions = _ref.questions,
|
|
1212
1241
|
handleSelect = _ref.handleSelect,
|
|
1213
1242
|
isOpen = _ref.isOpen,
|
|
1214
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
1243
|
+
props = _objectWithoutProperties(_ref, _excluded$8);
|
|
1215
1244
|
var _useBuildFormStore = buildForm.useBuildFormStore(function (store) {
|
|
1216
1245
|
var _store$formState, _store$formState2, _store$formState3;
|
|
1217
1246
|
return {
|
|
@@ -1231,7 +1260,7 @@ var Add = function Add(_ref) {
|
|
|
1231
1260
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1232
1261
|
args[_key] = arguments[_key];
|
|
1233
1262
|
}
|
|
1234
|
-
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));
|
|
1235
1264
|
utils.showThumbsUpToastr();
|
|
1236
1265
|
onClose();
|
|
1237
1266
|
}
|
|
@@ -1245,7 +1274,7 @@ var Add = function Add(_ref) {
|
|
|
1245
1274
|
language: language,
|
|
1246
1275
|
neetoFormQuestion: ramda.mergeLeft({
|
|
1247
1276
|
displayOrder: displayOrder
|
|
1248
|
-
}, values)
|
|
1277
|
+
}, transformValues(values))
|
|
1249
1278
|
}, {
|
|
1250
1279
|
onSuccess: function onSuccess(_ref2) {
|
|
1251
1280
|
var questions = _ref2.questions;
|
|
@@ -1270,7 +1299,7 @@ var Add = function Add(_ref) {
|
|
|
1270
1299
|
onSubmit: handleSubmit
|
|
1271
1300
|
},
|
|
1272
1301
|
children: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1273
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Form$1, _objectSpread$
|
|
1302
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Form$1, _objectSpread$c({}, _objectSpread$c(_objectSpread$c({}, props), {}, {
|
|
1274
1303
|
question: question,
|
|
1275
1304
|
questions: questions
|
|
1276
1305
|
}))), /*#__PURE__*/jsxRuntime.jsx(Pane.Footer, {
|
|
@@ -1286,14 +1315,14 @@ var Add = function Add(_ref) {
|
|
|
1286
1315
|
});
|
|
1287
1316
|
};
|
|
1288
1317
|
|
|
1289
|
-
var _excluded$
|
|
1290
|
-
function ownKeys$
|
|
1291
|
-
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; }
|
|
1292
1321
|
var Edit = function Edit(_ref) {
|
|
1293
1322
|
var question = _ref.question,
|
|
1294
1323
|
isOpen = _ref.isOpen,
|
|
1295
1324
|
onClose = _ref.onClose,
|
|
1296
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
1325
|
+
props = _objectWithoutProperties(_ref, _excluded$7);
|
|
1297
1326
|
var _useTranslation = reactI18next.useTranslation(),
|
|
1298
1327
|
t = _useTranslation.t;
|
|
1299
1328
|
var _useBuildFormStore = buildForm.useBuildFormStore(function (store) {
|
|
@@ -1314,7 +1343,7 @@ var Edit = function Edit(_ref) {
|
|
|
1314
1343
|
if (isUpdating || !isOpen) return;
|
|
1315
1344
|
var payload = {
|
|
1316
1345
|
language: language,
|
|
1317
|
-
neetoFormQuestion: values
|
|
1346
|
+
neetoFormQuestion: transformValues(values)
|
|
1318
1347
|
};
|
|
1319
1348
|
updateQuestion({
|
|
1320
1349
|
questionId: question.id,
|
|
@@ -1324,7 +1353,7 @@ var Edit = function Edit(_ref) {
|
|
|
1324
1353
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1325
1354
|
args[_key] = arguments[_key];
|
|
1326
1355
|
}
|
|
1327
|
-
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));
|
|
1328
1357
|
utils.showThumbsUpToastr();
|
|
1329
1358
|
onClose();
|
|
1330
1359
|
},
|
|
@@ -1347,7 +1376,7 @@ var Edit = function Edit(_ref) {
|
|
|
1347
1376
|
onSubmit: handleSubmit
|
|
1348
1377
|
},
|
|
1349
1378
|
children: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1350
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Form$1, _objectSpread$
|
|
1379
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Form$1, _objectSpread$b(_objectSpread$b({}, _objectSpread$b({
|
|
1351
1380
|
question: question
|
|
1352
1381
|
}, props)), {}, {
|
|
1353
1382
|
isEdit: true
|
|
@@ -1364,6 +1393,359 @@ var Edit = function Edit(_ref) {
|
|
|
1364
1393
|
});
|
|
1365
1394
|
};
|
|
1366
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
|
+
|
|
1367
1749
|
var Captcha = reactUtils.withT(function (_ref) {
|
|
1368
1750
|
var t = _ref.t;
|
|
1369
1751
|
return /*#__PURE__*/jsxRuntime.jsxs(Radio, {
|
|
@@ -1382,19 +1764,19 @@ var Captcha = reactUtils.withT(function (_ref) {
|
|
|
1382
1764
|
});
|
|
1383
1765
|
});
|
|
1384
1766
|
|
|
1385
|
-
var _excluded$
|
|
1386
|
-
function ownKeys$
|
|
1387
|
-
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; }
|
|
1388
1770
|
var SwitchBlock = function SwitchBlock(_ref) {
|
|
1389
1771
|
var name = _ref.name,
|
|
1390
1772
|
title = _ref.title,
|
|
1391
1773
|
_ref$className = _ref.className,
|
|
1392
1774
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
1393
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
1775
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$4);
|
|
1394
1776
|
return /*#__PURE__*/jsxRuntime.jsxs(Label, {
|
|
1395
1777
|
className: classnames("flex items-center justify-start gap-2 ", className),
|
|
1396
1778
|
"data-testid": "neeto-form-engine-".concat(neetoCist.hyphenate(title && name), "-toggle-label"),
|
|
1397
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Switch, _objectSpread$
|
|
1779
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Switch, _objectSpread$7(_objectSpread$7({}, _objectSpread$7(_objectSpread$7({}, otherProps), {}, {
|
|
1398
1780
|
name: name
|
|
1399
1781
|
})), {}, {
|
|
1400
1782
|
"data-testid": "neeto-form-engine-".concat(neetoCist.hyphenate(title && name), "-switch")
|
|
@@ -1423,9 +1805,9 @@ var EMAIL_VERIFICATION_TRANSLATIONS = {
|
|
|
1423
1805
|
popoverDescription: i18next.t("neetoForm.emailVerification.popoverDescription")
|
|
1424
1806
|
};
|
|
1425
1807
|
|
|
1426
|
-
var _excluded$
|
|
1427
|
-
function ownKeys$
|
|
1428
|
-
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; }
|
|
1429
1811
|
var STYLES = {
|
|
1430
1812
|
border: {
|
|
1431
1813
|
"default": "1px solid rgb(var(--neeto-ui-gray-400))",
|
|
@@ -1437,8 +1819,8 @@ var STYLES = {
|
|
|
1437
1819
|
}
|
|
1438
1820
|
};
|
|
1439
1821
|
var MultiValueRemove = function MultiValueRemove(props) {
|
|
1440
|
-
return /*#__PURE__*/jsxRuntime.jsx(reactSelect.components.MultiValueRemove, _objectSpread$
|
|
1441
|
-
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"))),
|
|
1442
1824
|
children: /*#__PURE__*/jsxRuntime.jsx(Close, {
|
|
1443
1825
|
size: 16
|
|
1444
1826
|
})
|
|
@@ -1446,7 +1828,7 @@ var MultiValueRemove = function MultiValueRemove(props) {
|
|
|
1446
1828
|
};
|
|
1447
1829
|
var ValueContainer = function ValueContainer(_ref) {
|
|
1448
1830
|
var children = _ref.children,
|
|
1449
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
1831
|
+
props = _objectWithoutProperties(_ref, _excluded$3);
|
|
1450
1832
|
var _useTranslation = reactI18next.useTranslation(),
|
|
1451
1833
|
t = _useTranslation.t;
|
|
1452
1834
|
var getValue = props.getValue,
|
|
@@ -1458,8 +1840,8 @@ var ValueContainer = function ValueContainer(_ref) {
|
|
|
1458
1840
|
firstChild = _children[0],
|
|
1459
1841
|
rest = _children.slice(1);
|
|
1460
1842
|
var shouldCollapse = !isFocused && value.length > visibleDomainsCount;
|
|
1461
|
-
return /*#__PURE__*/jsxRuntime.jsxs(reactSelect.components.ValueContainer, _objectSpread$
|
|
1462
|
-
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")),
|
|
1463
1845
|
children: [shouldCollapse ? firstChild.slice(0, visibleDomainsCount) : firstChild, shouldCollapse && /*#__PURE__*/jsxRuntime.jsx(Tag, {
|
|
1464
1846
|
style: "secondary",
|
|
1465
1847
|
label: t("neetoForm.common.remainingItemsCount", {
|
|
@@ -1469,8 +1851,8 @@ var ValueContainer = function ValueContainer(_ref) {
|
|
|
1469
1851
|
}));
|
|
1470
1852
|
};
|
|
1471
1853
|
var ClearIndicator = function ClearIndicator(props) {
|
|
1472
|
-
return /*#__PURE__*/jsxRuntime.jsx(reactSelect.components.ClearIndicator, _objectSpread$
|
|
1473
|
-
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")),
|
|
1474
1856
|
children: /*#__PURE__*/jsxRuntime.jsx(Close, {
|
|
1475
1857
|
className: "cursor-pointer",
|
|
1476
1858
|
size: 16
|
|
@@ -1491,7 +1873,7 @@ var CUSTOM_STYLES = {
|
|
|
1491
1873
|
input: ramda.assoc("overflow", "hidden"),
|
|
1492
1874
|
multiValue: function multiValue(styles, _ref2) {
|
|
1493
1875
|
var valid = _ref2.data.valid;
|
|
1494
|
-
return _objectSpread$
|
|
1876
|
+
return _objectSpread$6(_objectSpread$6({}, styles), {}, {
|
|
1495
1877
|
border: valid ? STYLES.border["default"] : STYLES.border.error,
|
|
1496
1878
|
color: valid ? STYLES.color["default"] : STYLES.color.error
|
|
1497
1879
|
});
|
|
@@ -1533,9 +1915,9 @@ var formatErrorMessage = function formatErrorMessage(error) {
|
|
|
1533
1915
|
return removeDuplicateErrorMessages(error);
|
|
1534
1916
|
};
|
|
1535
1917
|
|
|
1536
|
-
var _excluded$
|
|
1537
|
-
function ownKeys$
|
|
1538
|
-
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; }
|
|
1539
1921
|
var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
1540
1922
|
var _ref$label = _ref.label,
|
|
1541
1923
|
label = _ref$label === void 0 ? "" : _ref$label,
|
|
@@ -1547,7 +1929,7 @@ var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
|
1547
1929
|
error = _ref$error === void 0 ? "" : _ref$error,
|
|
1548
1930
|
_ref$onBlur = _ref.onBlur,
|
|
1549
1931
|
onBlur = _ref$onBlur === void 0 ? neetoCist.noop : _ref$onBlur,
|
|
1550
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
1932
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$2);
|
|
1551
1933
|
var _useState = React.useState(""),
|
|
1552
1934
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1553
1935
|
inputValue = _useState2[0],
|
|
@@ -1594,7 +1976,7 @@ var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
|
1594
1976
|
"data-testid": "".concat(utils.hyphenize(label), "-input-label"),
|
|
1595
1977
|
children: label
|
|
1596
1978
|
})
|
|
1597
|
-
}), /*#__PURE__*/jsxRuntime.jsx(CreatableSelect, _objectSpread$
|
|
1979
|
+
}), /*#__PURE__*/jsxRuntime.jsx(CreatableSelect, _objectSpread$5({
|
|
1598
1980
|
isMulti: true,
|
|
1599
1981
|
required: true,
|
|
1600
1982
|
classNamePrefix: "neeto-ui-react-select",
|
|
@@ -1604,7 +1986,7 @@ var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
|
1604
1986
|
className: classnames("neeto-ui-react-select__container neeto-ui-react-select__container--medium neeto-ui-email-input__select", {
|
|
1605
1987
|
"neeto-ui-react-select__container--error": !!error
|
|
1606
1988
|
}),
|
|
1607
|
-
styles: _objectSpread$
|
|
1989
|
+
styles: _objectSpread$5(_objectSpread$5({}, CUSTOM_STYLES), {}, {
|
|
1608
1990
|
control: ramda.mergeLeft({
|
|
1609
1991
|
maxHeight: "200px",
|
|
1610
1992
|
overflowY: "auto"
|
|
@@ -1616,7 +1998,7 @@ var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
|
1616
1998
|
},
|
|
1617
1999
|
onInputChange: setInputValue,
|
|
1618
2000
|
onKeyDown: handleKeyDown
|
|
1619
|
-
}, _objectSpread$
|
|
2001
|
+
}, _objectSpread$5({
|
|
1620
2002
|
inputValue: inputValue,
|
|
1621
2003
|
isFocused: isFocused,
|
|
1622
2004
|
onChange: onChange,
|
|
@@ -1638,8 +2020,8 @@ var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
|
1638
2020
|
});
|
|
1639
2021
|
};
|
|
1640
2022
|
|
|
1641
|
-
function ownKeys$
|
|
1642
|
-
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; }
|
|
1643
2025
|
var validateDomains = function validateDomains(value) {
|
|
1644
2026
|
var schema = yup__namespace.array().of(yup__namespace.string().test("verify domains", i18next.t("neetoForm.error.invalidDomain"), function (domain) {
|
|
1645
2027
|
return VALID_DOMAIN_REGEX.test(domain);
|
|
@@ -1679,7 +2061,7 @@ var buildHelpPopoverLabelProps = function buildHelpPopoverLabelProps(popoverDesc
|
|
|
1679
2061
|
return {
|
|
1680
2062
|
helpIconProps: {
|
|
1681
2063
|
"data-testid": "help-popover-button",
|
|
1682
|
-
popoverProps: _objectSpread$
|
|
2064
|
+
popoverProps: _objectSpread$4({
|
|
1683
2065
|
description: popoverDescription
|
|
1684
2066
|
}, helpLink && {
|
|
1685
2067
|
helpLinkProps: {
|
|
@@ -1818,15 +2200,15 @@ var getAllowedFileTypes = function getAllowedFileTypes(_ref) {
|
|
|
1818
2200
|
allowedFileTypes = _ref.allowedFileTypes;
|
|
1819
2201
|
var fileTypes = buildFileTypesList(allowedFileTypes);
|
|
1820
2202
|
if (isChecked) {
|
|
1821
|
-
var fileTypesSet = new Set([].concat(_toConsumableArray(
|
|
2203
|
+
var fileTypesSet = new Set([].concat(_toConsumableArray(yup.FILE_TYPES_MAP[type]), _toConsumableArray(fileTypes)));
|
|
1822
2204
|
return Array.from(fileTypesSet).join(", ");
|
|
1823
2205
|
}
|
|
1824
|
-
var newFileTypes = ramda.difference(fileTypes,
|
|
2206
|
+
var newFileTypes = ramda.difference(fileTypes, yup.FILE_TYPES_MAP[type]);
|
|
1825
2207
|
return newFileTypes.join(", ");
|
|
1826
2208
|
};
|
|
1827
2209
|
var isFileTypeEnabled = function isFileTypeEnabled(type, allowedFileTypes) {
|
|
1828
2210
|
var fileTypes = buildFileTypesList(allowedFileTypes);
|
|
1829
|
-
return ramda.isEmpty(ramda.difference(
|
|
2211
|
+
return ramda.isEmpty(ramda.difference(yup.FILE_TYPES_MAP[type], fileTypes));
|
|
1830
2212
|
};
|
|
1831
2213
|
|
|
1832
2214
|
var FileUpload = function FileUpload() {
|
|
@@ -1862,7 +2244,7 @@ var FileUpload = function FileUpload() {
|
|
|
1862
2244
|
children: t("neetoForm.fileUpload.fileTypes")
|
|
1863
2245
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1864
2246
|
className: "flex space-x-4",
|
|
1865
|
-
children:
|
|
2247
|
+
children: yup.FILE_GROUPS.map(function (_ref2) {
|
|
1866
2248
|
var name = _ref2.name,
|
|
1867
2249
|
label = _ref2.label;
|
|
1868
2250
|
return /*#__PURE__*/React.createElement(FileGroup, {
|
|
@@ -1878,8 +2260,60 @@ var FileUpload = function FileUpload() {
|
|
|
1878
2260
|
});
|
|
1879
2261
|
};
|
|
1880
2262
|
|
|
1881
|
-
|
|
1882
|
-
|
|
2263
|
+
var OpinionScale = function OpinionScale() {
|
|
2264
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
2265
|
+
t = _useTranslation.t;
|
|
2266
|
+
var _useFormikContext = formik.useFormikContext(),
|
|
2267
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
2268
|
+
_useFormikContext$val = _useFormikContext.values.hasOpinionLabels,
|
|
2269
|
+
hasOpinionLabels = _useFormikContext$val === void 0 ? false : _useFormikContext$val;
|
|
2270
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2271
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2272
|
+
className: "flex space-x-4",
|
|
2273
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Select, {
|
|
2274
|
+
className: "w-1/2",
|
|
2275
|
+
"data-testid": "neeto-form-engine-opinion-scale-min-value",
|
|
2276
|
+
label: t("neetoForm.common.start"),
|
|
2277
|
+
name: "minValue",
|
|
2278
|
+
options: yup.OPINION_SCALE_MIN_VALUE_OPTIONS,
|
|
2279
|
+
onChange: function onChange(option) {
|
|
2280
|
+
return setFieldValue("minValue", option === null || option === void 0 ? void 0 : option.value);
|
|
2281
|
+
}
|
|
2282
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Select, {
|
|
2283
|
+
className: "w-1/2",
|
|
2284
|
+
"data-testid": "neeto-form-engine-opinion-scale-max-value",
|
|
2285
|
+
label: t("neetoForm.common.end"),
|
|
2286
|
+
name: "maxValue",
|
|
2287
|
+
options: yup.OPINION_SCALE_MAX_VALUE_OPTIONS,
|
|
2288
|
+
onChange: function onChange(option) {
|
|
2289
|
+
return setFieldValue("maxValue", option === null || option === void 0 ? void 0 : option.value);
|
|
2290
|
+
}
|
|
2291
|
+
})]
|
|
2292
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Switch, {
|
|
2293
|
+
"data-testid": "neeto-form-engine-opinion-scale-show-labels-switch",
|
|
2294
|
+
label: t("neetoForm.questions.opinionScale.showLabels"),
|
|
2295
|
+
name: "hasOpinionLabels"
|
|
2296
|
+
}), hasOpinionLabels && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2297
|
+
className: "flex space-x-4",
|
|
2298
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
2299
|
+
className: "w-1/2",
|
|
2300
|
+
"data-testid": "neeto-form-engine-opinion-scale-left-label",
|
|
2301
|
+
label: t("neetoForm.questions.opinionScale.leftLabel"),
|
|
2302
|
+
maxLength: yup.OPINION_LABEL_MAX_LENGTH,
|
|
2303
|
+
name: "leftOpinionLabel"
|
|
2304
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
2305
|
+
className: "w-1/2",
|
|
2306
|
+
"data-testid": "neeto-form-engine-opinion-scale-right-label",
|
|
2307
|
+
label: t("neetoForm.questions.opinionScale.rightLabel"),
|
|
2308
|
+
maxLength: yup.OPINION_LABEL_MAX_LENGTH,
|
|
2309
|
+
name: "rightOpinionLabel"
|
|
2310
|
+
})]
|
|
2311
|
+
})]
|
|
2312
|
+
});
|
|
2313
|
+
};
|
|
2314
|
+
|
|
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; }
|
|
1883
2317
|
var Options = function Options(_ref) {
|
|
1884
2318
|
var questionProps = _ref.questionProps;
|
|
1885
2319
|
var _useTranslation = reactI18next.useTranslation(),
|
|
@@ -1916,15 +2350,15 @@ var Options = function Options(_ref) {
|
|
|
1916
2350
|
var isAddOptionDisabled = disableAddOption || isManageOptionDisabled;
|
|
1917
2351
|
var isRemoveOptionDisabled = disableRemoveOption || isManageOptionDisabled;
|
|
1918
2352
|
var isDropdown = values.kind === constants.QUESTION_TYPES.DROPDOWN;
|
|
1919
|
-
var isPictureChoice = isPictureChoiceEnabled && !isDropdown && (values.isPictureChoice ||
|
|
1920
|
-
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;
|
|
1921
2355
|
var handleImageHeightChange = function handleImageHeightChange(value) {
|
|
1922
2356
|
setFieldValue("imageHeight", value);
|
|
1923
2357
|
};
|
|
1924
2358
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1925
2359
|
className: "w-full space-y-4",
|
|
1926
2360
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1927
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Label, _objectSpread$
|
|
2361
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label, _objectSpread$3(_objectSpread$3({
|
|
1928
2362
|
className: "mb-2 block"
|
|
1929
2363
|
}, optionLabelProps), {}, {
|
|
1930
2364
|
children: t("neetoForm.questions.common.questionFields.field.options")
|
|
@@ -1948,8 +2382,8 @@ var Options = function Options(_ref) {
|
|
|
1948
2382
|
draggable: !isManageOptionDisabled,
|
|
1949
2383
|
isAddOptionEnabled: !isAddOptionDisabled,
|
|
1950
2384
|
isDeleteOptionEnabled: !isRemoveOptionDisabled,
|
|
1951
|
-
isNewItemsPrefilled:
|
|
1952
|
-
minOptions:
|
|
2385
|
+
isNewItemsPrefilled: yup.isDefaultLanguage(selectedLanguage),
|
|
2386
|
+
minOptions: yup.MINIMUM_OPTIONS,
|
|
1953
2387
|
shouldResetEmptyOptionOnBlur: false,
|
|
1954
2388
|
onChange: setOptionsAttributes
|
|
1955
2389
|
})
|
|
@@ -1979,8 +2413,8 @@ var Options = function Options(_ref) {
|
|
|
1979
2413
|
weight: "medium",
|
|
1980
2414
|
children: t("neetoForm.questions.common.questionFields.field.imageHeight")
|
|
1981
2415
|
}), /*#__PURE__*/jsxRuntime.jsx(Slider, {
|
|
1982
|
-
max:
|
|
1983
|
-
min:
|
|
2416
|
+
max: yup.IMAGE_HEIGHT_SLIDER_DEFAULTS.max,
|
|
2417
|
+
min: yup.IMAGE_HEIGHT_SLIDER_DEFAULTS.min,
|
|
1984
2418
|
value: imageHeight,
|
|
1985
2419
|
onChange: handleImageHeightChange
|
|
1986
2420
|
})]
|
|
@@ -2004,7 +2438,7 @@ var Rating = function Rating() {
|
|
|
2004
2438
|
className: "w-full",
|
|
2005
2439
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2006
2440
|
className: "flex gap-6",
|
|
2007
|
-
children:
|
|
2441
|
+
children: yup.RATING_OPTIONS$1.map(function (_ref2) {
|
|
2008
2442
|
var Icon = _ref2.icon,
|
|
2009
2443
|
name = _ref2.name,
|
|
2010
2444
|
color = _ref2.color;
|
|
@@ -2041,7 +2475,7 @@ var StarRating = function StarRating() {
|
|
|
2041
2475
|
"data-testid": "neeto-form-engine-star-rating-min-value",
|
|
2042
2476
|
label: t("neetoForm.common.start"),
|
|
2043
2477
|
name: "minValue",
|
|
2044
|
-
options:
|
|
2478
|
+
options: yup.STAR_RATING_MIN_VALUE_OPTIONS,
|
|
2045
2479
|
onChange: function onChange(option) {
|
|
2046
2480
|
return setFieldValue("minValue", option === null || option === void 0 ? void 0 : option.value);
|
|
2047
2481
|
}
|
|
@@ -2050,7 +2484,7 @@ var StarRating = function StarRating() {
|
|
|
2050
2484
|
"data-testid": "neeto-form-engine-star-rating-max-value",
|
|
2051
2485
|
label: t("neetoForm.common.end"),
|
|
2052
2486
|
name: "maxValue",
|
|
2053
|
-
options:
|
|
2487
|
+
options: yup.STAR_RATING_MAX_VALUE_OPTIONS,
|
|
2054
2488
|
onChange: function onChange(option) {
|
|
2055
2489
|
return setFieldValue("maxValue", option === null || option === void 0 ? void 0 : option.value);
|
|
2056
2490
|
}
|
|
@@ -2059,7 +2493,7 @@ var StarRating = function StarRating() {
|
|
|
2059
2493
|
children: t("neetoForm.common.shape")
|
|
2060
2494
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2061
2495
|
className: "flex gap-2",
|
|
2062
|
-
children: Object.entries(
|
|
2496
|
+
children: Object.entries(yup.STAR_RATING_ICONS_MAP).map(function (_ref) {
|
|
2063
2497
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
2064
2498
|
name = _ref2[0],
|
|
2065
2499
|
IconType = _ref2[1];
|
|
@@ -2080,19 +2514,27 @@ var StarRating = function StarRating() {
|
|
|
2080
2514
|
});
|
|
2081
2515
|
};
|
|
2082
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; }
|
|
2083
2520
|
var CHECKBOX = constants.QUESTION_TYPES.CHECKBOX,
|
|
2084
2521
|
RADIO = constants.QUESTION_TYPES.RADIO,
|
|
2085
2522
|
DROPDOWN = constants.QUESTION_TYPES.DROPDOWN,
|
|
2086
2523
|
STAR_RATING = constants.QUESTION_TYPES.STAR_RATING,
|
|
2524
|
+
OPINION_SCALE = constants.QUESTION_TYPES.OPINION_SCALE,
|
|
2087
2525
|
RATING = constants.QUESTION_TYPES.RATING,
|
|
2088
2526
|
FILE_UPLOAD = constants.QUESTION_TYPES.FILE_UPLOAD,
|
|
2089
2527
|
CAPTCHA = constants.QUESTION_TYPES.CAPTCHA,
|
|
2090
|
-
EMAIL = constants.QUESTION_TYPES.EMAIL
|
|
2528
|
+
EMAIL = constants.QUESTION_TYPES.EMAIL,
|
|
2529
|
+
ADDRESS = constants.QUESTION_TYPES.ADDRESS;
|
|
2091
2530
|
var transformValueForOption = function transformValueForOption(_ref) {
|
|
2092
2531
|
var label = _ref.label,
|
|
2093
2532
|
type = _ref.type;
|
|
2094
2533
|
return "".concat(neetoCist.slugify(label), "-").concat(type);
|
|
2095
2534
|
};
|
|
2535
|
+
var omitDraftId = neetoCist.modifyBy({
|
|
2536
|
+
id: ramda.startsWith(DRAFT_ID_PREFIX)
|
|
2537
|
+
}, ramda.omit(["id"]));
|
|
2096
2538
|
var renderAdditionalData = function renderAdditionalData(_ref2) {
|
|
2097
2539
|
var kind = _ref2.kind,
|
|
2098
2540
|
questionProps = _ref2.questionProps,
|
|
@@ -2108,10 +2550,14 @@ var renderAdditionalData = function renderAdditionalData(_ref2) {
|
|
|
2108
2550
|
return /*#__PURE__*/jsxRuntime.jsx(Rating, {});
|
|
2109
2551
|
case STAR_RATING:
|
|
2110
2552
|
return /*#__PURE__*/jsxRuntime.jsx(StarRating, {});
|
|
2553
|
+
case OPINION_SCALE:
|
|
2554
|
+
return /*#__PURE__*/jsxRuntime.jsx(OpinionScale, {});
|
|
2111
2555
|
case FILE_UPLOAD:
|
|
2112
2556
|
return /*#__PURE__*/jsxRuntime.jsx(FileUpload, {});
|
|
2113
2557
|
case CAPTCHA:
|
|
2114
2558
|
return /*#__PURE__*/jsxRuntime.jsx(Captcha, {});
|
|
2559
|
+
case ADDRESS:
|
|
2560
|
+
return /*#__PURE__*/jsxRuntime.jsx(Address, {});
|
|
2115
2561
|
case EMAIL:
|
|
2116
2562
|
return !usesCustomSubmissionComponent && /*#__PURE__*/jsxRuntime.jsx(Email, {
|
|
2117
2563
|
usesCustomSubmissionComponent: usesCustomSubmissionComponent
|
|
@@ -2121,7 +2567,7 @@ var renderAdditionalData = function renderAdditionalData(_ref2) {
|
|
|
2121
2567
|
}
|
|
2122
2568
|
};
|
|
2123
2569
|
var resolveActionComponent = function resolveActionComponent(action) {
|
|
2124
|
-
return ramda.equals(action,
|
|
2570
|
+
return ramda.equals(action, yup.QUESTION_ACTIONS.ADD) ? Add : Edit;
|
|
2125
2571
|
};
|
|
2126
2572
|
var getQuestionKind = function getQuestionKind(questionKinds, pattern) {
|
|
2127
2573
|
var questionKind = neetoCist.findBy(pattern, questionKinds);
|
|
@@ -2188,6 +2634,21 @@ var readOnlySwitchLabelProps = function readOnlySwitchLabelProps(helpUrl) {
|
|
|
2188
2634
|
}
|
|
2189
2635
|
};
|
|
2190
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
|
+
};
|
|
2191
2652
|
|
|
2192
2653
|
var _excluded = ["isOpen", "onClose", "action", "question", "availableQuestionKinds"];
|
|
2193
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; }
|
|
@@ -2222,10 +2683,10 @@ var AddQuestion = function AddQuestion(_ref) {
|
|
|
2222
2683
|
disabledAddButtonHelpPopoverProps = _ref.disabledAddButtonHelpPopoverProps,
|
|
2223
2684
|
isDisabled = _ref.isDisabled,
|
|
2224
2685
|
addQuestionHelpProps = _ref.addQuestionHelpProps;
|
|
2225
|
-
var helpPopoverProps = isDisabled ?
|
|
2686
|
+
var helpPopoverProps = isDisabled ? yup.buildDisabledAddButtonHelpPopoverProps(disabledAddButtonHelpPopoverProps) : {};
|
|
2226
2687
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2227
2688
|
className: "mb-8 flex w-full items-center gap-x-1",
|
|
2228
|
-
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", {
|
|
2229
2690
|
children: /*#__PURE__*/jsxRuntime.jsx(HelpPopover, _objectSpread({}, addQuestionHelpProps))
|
|
2230
2691
|
})]
|
|
2231
2692
|
});
|
|
@@ -2291,7 +2752,7 @@ var Form = function Form(_ref) {
|
|
|
2291
2752
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2292
2753
|
args[_key] = arguments[_key];
|
|
2293
2754
|
}
|
|
2294
|
-
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));
|
|
2295
2756
|
utils.showThumbsUpToastr();
|
|
2296
2757
|
}
|
|
2297
2758
|
}),
|
|
@@ -2301,7 +2762,7 @@ var Form = function Form(_ref) {
|
|
|
2301
2762
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2302
2763
|
args[_key2] = arguments[_key2];
|
|
2303
2764
|
}
|
|
2304
|
-
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));
|
|
2305
2766
|
setFormData({
|
|
2306
2767
|
isReorderingQuestions: false
|
|
2307
2768
|
});
|
|
@@ -2312,7 +2773,7 @@ var Form = function Form(_ref) {
|
|
|
2312
2773
|
var handleReorder = function handleReorder(questions) {
|
|
2313
2774
|
var payload = {
|
|
2314
2775
|
neetoFormQuestions: {
|
|
2315
|
-
questions:
|
|
2776
|
+
questions: yup.buildReorderPayload(questions)
|
|
2316
2777
|
},
|
|
2317
2778
|
language: selectedLanguage
|
|
2318
2779
|
};
|
|
@@ -2341,11 +2802,11 @@ var Form = function Form(_ref) {
|
|
|
2341
2802
|
setSelectedQuestion(question);
|
|
2342
2803
|
};
|
|
2343
2804
|
var handleAdd = function handleAdd() {
|
|
2344
|
-
setSelectedAction(
|
|
2805
|
+
setSelectedAction(yup.QUESTION_ACTIONS.ADD);
|
|
2345
2806
|
setIsManageQuestionPaneOpen(true);
|
|
2346
2807
|
};
|
|
2347
2808
|
var handleEdit = function handleEdit() {
|
|
2348
|
-
setSelectedAction(
|
|
2809
|
+
setSelectedAction(yup.QUESTION_ACTIONS.EDIT);
|
|
2349
2810
|
setIsManageQuestionPaneOpen(true);
|
|
2350
2811
|
};
|
|
2351
2812
|
var handleClone = function handleClone() {
|
|
@@ -2485,7 +2946,7 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
2485
2946
|
_ref$isKindAlreadyAct = _ref.isKindAlreadyActive,
|
|
2486
2947
|
isKindAlreadyActive = _ref$isKindAlreadyAct === void 0 ? isQuestionKindAlreadyActive : _ref$isKindAlreadyAct,
|
|
2487
2948
|
_ref$getActiveKindDet = _ref.getActiveKindDetails,
|
|
2488
|
-
getActiveKindDetails = _ref$getActiveKindDet === void 0 ?
|
|
2949
|
+
getActiveKindDetails = _ref$getActiveKindDet === void 0 ? yup.getActiveQuestionKindDetails : _ref$getActiveKindDet,
|
|
2489
2950
|
kindUniqueOn = _ref.kindUniqueOn,
|
|
2490
2951
|
_ref$isQuestionDeleta = _ref.isQuestionDeletable,
|
|
2491
2952
|
isQuestionDeletable = _ref$isQuestionDeleta === void 0 ? ramda.T : _ref$isQuestionDeleta,
|
|
@@ -2496,7 +2957,7 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
2496
2957
|
formTitle = _ref$formTitle === void 0 ? "" : _ref$formTitle,
|
|
2497
2958
|
formDescription = _ref.formDescription,
|
|
2498
2959
|
_ref$availableLanguag = _ref.availableLanguages,
|
|
2499
|
-
availableLanguages = _ref$availableLanguag === void 0 ?
|
|
2960
|
+
availableLanguages = _ref$availableLanguag === void 0 ? yup.DEFAULT_AVAILABLE_LANGUAGES : _ref$availableLanguag,
|
|
2500
2961
|
_ref$selectedLanguage = _ref.selectedLanguage,
|
|
2501
2962
|
selectedLanguage = _ref$selectedLanguage === void 0 ? "en" : _ref$selectedLanguage,
|
|
2502
2963
|
_ref$onLanguageChange = _ref.onLanguageChange,
|
|
@@ -2510,7 +2971,7 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
2510
2971
|
_ref$allowAdditionalG = _ref.allowAdditionalGuests,
|
|
2511
2972
|
allowAdditionalGuests = _ref$allowAdditionalG === void 0 ? false : _ref$allowAdditionalG,
|
|
2512
2973
|
_ref$advancedFeatures = _ref.advancedFeatures,
|
|
2513
|
-
advancedFeatures = _ref$advancedFeatures === void 0 ?
|
|
2974
|
+
advancedFeatures = _ref$advancedFeatures === void 0 ? yup.DEFAULT_ADVANCED_FEATURES : _ref$advancedFeatures,
|
|
2514
2975
|
helpDocUrls = _ref.helpDocUrls,
|
|
2515
2976
|
className = _ref.className,
|
|
2516
2977
|
_ref$usesCustomSubmis = _ref.usesCustomSubmissionComponent,
|
|
@@ -2530,7 +2991,7 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
2530
2991
|
data = _useForm.data,
|
|
2531
2992
|
isLoading = _useForm.isLoading,
|
|
2532
2993
|
isQuestionsPending = _useForm.isPending;
|
|
2533
|
-
var _ref2 = data ||
|
|
2994
|
+
var _ref2 = data || yup.QUESTIONS_INITIAL_VALUE,
|
|
2534
2995
|
isFormEnabled = _ref2.enabled,
|
|
2535
2996
|
savedTitle = _ref2.title,
|
|
2536
2997
|
questionsFromCache = _ref2.questions,
|
|
@@ -2548,13 +3009,13 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
2548
3009
|
queryClient.setQueryData([constants.QUERY_KEYS.QUESTIONS, "preview/".concat(id), selectedLanguage], ramda.assoc("questions", questions));
|
|
2549
3010
|
}
|
|
2550
3011
|
};
|
|
2551
|
-
var isRequiredField = ramda.either(
|
|
3012
|
+
var isRequiredField = ramda.either(yup.isMandatoryField, isFieldRequired);
|
|
2552
3013
|
var isDisabledFieldLabel = function isDisabledFieldLabel(field) {
|
|
2553
|
-
return
|
|
3014
|
+
return yup.isImmutableField(field) || (isFieldLabelDisabled !== null && isFieldLabelDisabled !== void 0 ? isFieldLabelDisabled : ramda.F)(field);
|
|
2554
3015
|
};
|
|
2555
|
-
var defaultQuestionKinds = allowAdditionalGuests ?
|
|
2556
|
-
type:
|
|
2557
|
-
},
|
|
3016
|
+
var defaultQuestionKinds = allowAdditionalGuests ? yup.QUESTION_KINDS : neetoCist.removeBy({
|
|
3017
|
+
type: yup.QUESTION_KIND.ADDITIONAL_GUESTS.value
|
|
3018
|
+
}, yup.QUESTION_KINDS);
|
|
2558
3019
|
var isUsingDefaultQuestionKinds = ramda.isNil(questionKinds);
|
|
2559
3020
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2560
3021
|
className: classnames("neeto-form-nano-form-outer-wrapper relative", className),
|