@bigbinary/neeto-form-frontend 3.9.2 → 3.9.3
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/dist/BuildForm.js +144 -81
- package/dist/BuildForm.js.map +1 -1
- package/dist/ExternalForm.js +2 -2
- package/dist/UrlBuilder.js +2 -2
- package/dist/cjs/BuildForm.js +141 -78
- package/dist/cjs/BuildForm.js.map +1 -1
- package/dist/cjs/ExternalForm.js +2 -2
- package/dist/cjs/UrlBuilder.js +2 -2
- package/dist/cjs/index.js +3 -3
- package/dist/{constants-pb1PsblC.js → constants-CEOQLu3J.js} +6 -2
- package/dist/constants-CEOQLu3J.js.map +1 -0
- package/dist/{constants-CAupEAeQ.js → constants-DXZnQ_E9.js} +7 -1
- package/dist/constants-DXZnQ_E9.js.map +1 -0
- package/dist/index.js +3 -3
- package/dist/{utils-BPSPfGM5.js → utils-BwrOrhV5.js} +2 -2
- package/dist/{utils-BPSPfGM5.js.map → utils-BwrOrhV5.js.map} +1 -1
- package/dist/{utils-D-ZaPjZk.js → utils-DgV43Oko.js} +2 -2
- package/dist/{utils-D-ZaPjZk.js.map → utils-DgV43Oko.js.map} +1 -1
- package/package.json +17 -16
- package/types.d.ts +6 -0
- package/dist/constants-CAupEAeQ.js.map +0 -1
- package/dist/constants-pb1PsblC.js.map +0 -1
package/dist/ExternalForm.js
CHANGED
|
@@ -27,7 +27,7 @@ import { a as isBlank, g as getComponentDisplayName, p as parseServerError } fro
|
|
|
27
27
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
28
28
|
import Check from '@bigbinary/neeto-icons/Check';
|
|
29
29
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
30
|
-
import { c as clientI18nInstance, d as getWithExpiry, g as generateInitValues, F as FormikWrap, a as getFieldComponent, b as buildAutoCompleteAttribute, r as renderButtonsInOrder, m as mergeRefs, e as generateFormResponse, f as clearLocalStorageValues } from './utils-
|
|
30
|
+
import { c as clientI18nInstance, d as getWithExpiry, g as generateInitValues, F as FormikWrap, a as getFieldComponent, b as buildAutoCompleteAttribute, r as renderButtonsInOrder, m as mergeRefs, e as generateFormResponse, f as clearLocalStorageValues } from './utils-BwrOrhV5.js';
|
|
31
31
|
import { withT } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
32
32
|
import '@babel/runtime/helpers/toConsumableArray';
|
|
33
33
|
import '@bigbinary/neeto-commons-frontend/constants';
|
|
@@ -36,7 +36,7 @@ import '@babel/runtime/helpers/typeof';
|
|
|
36
36
|
import '@bigbinary/neeto-editor/utils';
|
|
37
37
|
import 'libphonenumber-js';
|
|
38
38
|
import '@bigbinary/neeto-editor/EditorContent';
|
|
39
|
-
import './constants-
|
|
39
|
+
import './constants-CEOQLu3J.js';
|
|
40
40
|
import './constants-DlRX5mcQ.js';
|
|
41
41
|
import 'dompurify';
|
|
42
42
|
import '@bigbinary/neeto-icons/Plus';
|
package/dist/UrlBuilder.js
CHANGED
|
@@ -10,10 +10,10 @@ import Button from '@bigbinary/neetoui/Button';
|
|
|
10
10
|
import NoData from '@bigbinary/neetoui/NoData';
|
|
11
11
|
import { map, assoc, filter, pluck, isEmpty } from 'ramda';
|
|
12
12
|
import { useTranslation } from 'react-i18next';
|
|
13
|
-
import { g as generateInitValues, F as FormikWrap, a as getFieldComponent, b as buildAutoCompleteAttribute, m as mergeRefs } from './utils-
|
|
13
|
+
import { g as generateInitValues, F as FormikWrap, a as getFieldComponent, b as buildAutoCompleteAttribute, m as mergeRefs } from './utils-BwrOrhV5.js';
|
|
14
14
|
import { a as useForm } from './useFormApi-BS-TCKwR.js';
|
|
15
15
|
import { parsePhoneNumber } from 'libphonenumber-js';
|
|
16
|
-
import { Q as QUESTIONS_WITHOUT_FIELD_CODE } from './constants-
|
|
16
|
+
import { Q as QUESTIONS_WITHOUT_FIELD_CODE } from './constants-CEOQLu3J.js';
|
|
17
17
|
import { Q as QUESTION_KIND } from './constants-DlRX5mcQ.js';
|
|
18
18
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
19
19
|
import './index-BL5SirYx.js';
|
package/dist/cjs/BuildForm.js
CHANGED
|
@@ -11,11 +11,12 @@ var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
|
|
|
11
11
|
var ramda = require('ramda');
|
|
12
12
|
var useFormApi = require('../useFormApi-DAiOGCeD.js');
|
|
13
13
|
var constants$1 = require('../constants-D-XSuLo2.js');
|
|
14
|
-
var constants = require('../constants-
|
|
14
|
+
var constants = require('../constants-DXZnQ_E9.js');
|
|
15
15
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
16
16
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
17
17
|
var dnd = require('@hello-pangea/dnd');
|
|
18
18
|
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
19
|
+
var HelpPopover = require('@bigbinary/neeto-molecules/HelpPopover');
|
|
19
20
|
var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
|
|
20
21
|
var reactI18next = require('react-i18next');
|
|
21
22
|
var buildForm = require('../buildForm-CthgTgsm.js');
|
|
@@ -27,7 +28,6 @@ var MoreDropdown = require('@bigbinary/neeto-molecules/MoreDropdown');
|
|
|
27
28
|
var Typography = require('@bigbinary/neetoui/Typography');
|
|
28
29
|
var Dropdown = require('@bigbinary/neetoui/Dropdown');
|
|
29
30
|
var Tooltip = require('@bigbinary/neetoui/Tooltip');
|
|
30
|
-
var HelpPopover = require('@bigbinary/neeto-molecules/HelpPopover');
|
|
31
31
|
var i18next = require('i18next');
|
|
32
32
|
var Plus = require('@bigbinary/neeto-icons/Plus');
|
|
33
33
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
@@ -464,18 +464,43 @@ function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var t
|
|
|
464
464
|
var isChoiceQuestion = function isChoiceQuestion(question) {
|
|
465
465
|
return ramda.includes(question === null || question === void 0 ? void 0 : question.kind, constants.SELECTABLE_KINDS);
|
|
466
466
|
};
|
|
467
|
-
var
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
467
|
+
var underscoredWithoutSpecialCharacters = function underscoredWithoutSpecialCharacters(string) {
|
|
468
|
+
return string.toLowerCase().replace(/[\s-]/g, "_").replace(/[\W]/gi, "").replace(/_+/g, "_").replace(/^_+|_+$/, "");
|
|
469
|
+
};
|
|
470
|
+
var addSuffixForReservedFieldCode = function addSuffixForReservedFieldCode(fieldCode) {
|
|
471
|
+
return constants.RESERVED_FIELD_CODES.includes(fieldCode) ? "".concat(fieldCode, "_field") : fieldCode;
|
|
472
|
+
};
|
|
473
|
+
var getUniqueNumbersFromExistingFieldCodes = function getUniqueNumbersFromExistingFieldCodes(prefix, questions) {
|
|
474
|
+
return questions.filter(function (question) {
|
|
475
|
+
return question.fieldCode.startsWith(prefix);
|
|
476
|
+
}).map(function (question) {
|
|
477
|
+
return parseInt(question.fieldCode.replace(prefix, "")) || 0;
|
|
478
|
+
});
|
|
479
|
+
};
|
|
480
|
+
var generateFieldCodePrefix = function generateFieldCodePrefix(label, kind) {
|
|
481
|
+
var prefix;
|
|
482
|
+
if (constants.NON_BASIC_LATIN_CHARACTERS_REGEX.test(label) || ramda.isEmpty(label)) {
|
|
483
|
+
prefix = kind;
|
|
484
|
+
} else {
|
|
485
|
+
var sanitizedLabel = underscoredWithoutSpecialCharacters(label).slice(0, 30);
|
|
486
|
+
prefix = ramda.isEmpty(sanitizedLabel) ? kind : sanitizedLabel;
|
|
487
|
+
}
|
|
488
|
+
return addSuffixForReservedFieldCode(prefix) || "";
|
|
489
|
+
};
|
|
490
|
+
var generateUniqueFieldCode = function generateUniqueFieldCode(_ref) {
|
|
491
|
+
var questions = _ref.questions,
|
|
492
|
+
_ref$label = _ref.label,
|
|
493
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
494
|
+
_ref$kind = _ref.kind,
|
|
495
|
+
kind = _ref$kind === void 0 ? "" : _ref$kind;
|
|
496
|
+
var prefix = generateFieldCodePrefix(label, kind);
|
|
497
|
+
var uniqueNumber = Math.max.apply(Math, [0].concat(_toConsumableArray(getUniqueNumbersFromExistingFieldCodes(prefix, questions))));
|
|
472
498
|
var candidateFieldCode = "";
|
|
473
|
-
var prefix = constants.RESERVED_FIELD_CODES.includes(type) ? "".concat(type, "_field") : type;
|
|
474
499
|
|
|
475
500
|
//We need to continue this while loop until we can generate a unique fieldCode
|
|
476
501
|
// eslint-disable-next-line no-constant-condition
|
|
477
502
|
while (true) {
|
|
478
|
-
candidateFieldCode = "".concat(prefix).concat(uniqueNumber
|
|
503
|
+
candidateFieldCode = "".concat(prefix).concat(uniqueNumber === 0 ? "" : uniqueNumber);
|
|
479
504
|
if (!neetoCist.findBy({
|
|
480
505
|
fieldCode: candidateFieldCode
|
|
481
506
|
}, questions)) break;
|
|
@@ -483,18 +508,18 @@ var generateUniqueFieldCode = function generateUniqueFieldCode(type, questions)
|
|
|
483
508
|
}
|
|
484
509
|
return candidateFieldCode;
|
|
485
510
|
};
|
|
486
|
-
var isQuestionKindAlreadyActive = function isQuestionKindAlreadyActive(
|
|
487
|
-
var activeQuestions =
|
|
488
|
-
kind =
|
|
511
|
+
var isQuestionKindAlreadyActive = function isQuestionKindAlreadyActive(_ref2) {
|
|
512
|
+
var activeQuestions = _ref2.activeQuestions,
|
|
513
|
+
kind = _ref2.kind;
|
|
489
514
|
return activeQuestions.some(function (activeQuestion) {
|
|
490
515
|
return activeQuestion.kind === kind.type && activeQuestion._destroy !== true;
|
|
491
516
|
});
|
|
492
517
|
};
|
|
493
|
-
var handleFieldDragEnd = function handleFieldDragEnd(
|
|
494
|
-
var items =
|
|
495
|
-
setValue =
|
|
496
|
-
source =
|
|
497
|
-
destination =
|
|
518
|
+
var handleFieldDragEnd = function handleFieldDragEnd(_ref3) {
|
|
519
|
+
var items = _ref3.items,
|
|
520
|
+
setValue = _ref3.setValue,
|
|
521
|
+
source = _ref3.source,
|
|
522
|
+
destination = _ref3.destination;
|
|
498
523
|
if (!(destination && items instanceof Array)) return;
|
|
499
524
|
var nextItems = _toConsumableArray(items);
|
|
500
525
|
arrayHelpers.moveItem(nextItems, source.index, destination.index);
|
|
@@ -505,32 +530,36 @@ var handleFieldDragEnd = function handleFieldDragEnd(_ref2) {
|
|
|
505
530
|
});
|
|
506
531
|
setValue("questions", orderedItems);
|
|
507
532
|
};
|
|
508
|
-
var createFieldData = function createFieldData(
|
|
509
|
-
var
|
|
510
|
-
defaults =
|
|
511
|
-
type =
|
|
512
|
-
metadata =
|
|
513
|
-
|
|
514
|
-
isRequired =
|
|
515
|
-
questions =
|
|
533
|
+
var createFieldData = function createFieldData(_ref4) {
|
|
534
|
+
var _ref4$kind = _ref4.kind,
|
|
535
|
+
defaults = _ref4$kind.defaults,
|
|
536
|
+
type = _ref4$kind.type,
|
|
537
|
+
metadata = _ref4$kind.metadata,
|
|
538
|
+
_ref4$isRequired = _ref4.isRequired,
|
|
539
|
+
isRequired = _ref4$isRequired === void 0 ? undefined : _ref4$isRequired,
|
|
540
|
+
questions = _ref4.questions;
|
|
516
541
|
return _objectSpread$e(_objectSpread$e({}, defaults), {}, {
|
|
517
542
|
metadata: metadata,
|
|
518
543
|
isRequired: isRequired,
|
|
519
544
|
kind: type,
|
|
520
545
|
nodeId: uuid.v4(),
|
|
521
|
-
fieldCode: generateUniqueFieldCode(
|
|
546
|
+
fieldCode: generateUniqueFieldCode({
|
|
547
|
+
questions: questions,
|
|
548
|
+
kind: type,
|
|
549
|
+
label: defaults["label"]
|
|
550
|
+
})
|
|
522
551
|
});
|
|
523
552
|
};
|
|
524
|
-
var duplicateFieldData = function duplicateFieldData(
|
|
525
|
-
var item =
|
|
526
|
-
questionKinds =
|
|
527
|
-
questions =
|
|
528
|
-
var questionKind = neetoCist.findBy({
|
|
529
|
-
type: item.kind
|
|
530
|
-
}, questionKinds);
|
|
553
|
+
var duplicateFieldData = function duplicateFieldData(_ref5) {
|
|
554
|
+
var item = _ref5.item,
|
|
555
|
+
questionKinds = _ref5.questionKinds,
|
|
556
|
+
questions = _ref5.questions;
|
|
531
557
|
var isRequired = item.isRequired,
|
|
532
558
|
kind = item.kind,
|
|
533
559
|
optionsAttributes = item.optionsAttributes;
|
|
560
|
+
var questionKind = neetoCist.findBy({
|
|
561
|
+
type: kind
|
|
562
|
+
}, questionKinds);
|
|
534
563
|
var label = index.fieldWithFallback(item, "label");
|
|
535
564
|
var defaultAttributeNames = ramda.keys(questionKind.defaults || {});
|
|
536
565
|
var defaultAttributes = ramda.pick(defaultAttributeNames, item);
|
|
@@ -543,15 +572,19 @@ var duplicateFieldData = function duplicateFieldData(_ref4) {
|
|
|
543
572
|
label: newQuestionLabel,
|
|
544
573
|
optionsAttributes: optionsAttributes && optionsAttributes.map(ramda.omit(["id"])),
|
|
545
574
|
nodeId: uuid.v4(),
|
|
546
|
-
fieldCode: generateUniqueFieldCode(
|
|
575
|
+
fieldCode: generateUniqueFieldCode({
|
|
576
|
+
questions: questions,
|
|
577
|
+
kind: kind,
|
|
578
|
+
label: newQuestionLabel
|
|
579
|
+
}),
|
|
547
580
|
displayOrder: item.displayOrder + 1
|
|
548
581
|
});
|
|
549
582
|
};
|
|
550
|
-
var getAvailableQuestionKinds = function getAvailableQuestionKinds(
|
|
551
|
-
var allQuestionKinds =
|
|
552
|
-
|
|
553
|
-
activeQuestions =
|
|
554
|
-
isKindAlreadyActive =
|
|
583
|
+
var getAvailableQuestionKinds = function getAvailableQuestionKinds(_ref6) {
|
|
584
|
+
var allQuestionKinds = _ref6.allQuestionKinds,
|
|
585
|
+
_ref6$activeQuestions = _ref6.activeQuestions,
|
|
586
|
+
activeQuestions = _ref6$activeQuestions === void 0 ? [] : _ref6$activeQuestions,
|
|
587
|
+
isKindAlreadyActive = _ref6.isKindAlreadyActive;
|
|
555
588
|
if (ramda.isEmpty(activeQuestions)) return allQuestionKinds;
|
|
556
589
|
return ramda.reject(function (kind) {
|
|
557
590
|
var isSingularKind = kind.isSingular;
|
|
@@ -614,6 +647,7 @@ var INITIAL_VALUES = {
|
|
|
614
647
|
label: "",
|
|
615
648
|
fieldCode: ""
|
|
616
649
|
};
|
|
650
|
+
var VALID_FIELD_CODE_REGEX = /^[a-z0-9]+(_[a-z0-9]+)*$/;
|
|
617
651
|
|
|
618
652
|
var _excluded$8 = ["label", "name"];
|
|
619
653
|
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; }
|
|
@@ -824,6 +858,7 @@ var FieldCode = function FieldCode() {
|
|
|
824
858
|
required: true,
|
|
825
859
|
label: t("neetoForm.questions.common.questionFields.field.fieldCode"),
|
|
826
860
|
name: "fieldCode",
|
|
861
|
+
rejectCharsRegex: constants.FIELD_CODES_REJECT_CHARS_REGEX,
|
|
827
862
|
helpText: helpDocUrl && /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
828
863
|
i18nKey: "neetoForm.questions.common.questionFields.field.fieldCodeHelpDescription",
|
|
829
864
|
components: {
|
|
@@ -858,7 +893,8 @@ var Form$1 = function Form(_ref) {
|
|
|
858
893
|
values = _useFormikContext.values,
|
|
859
894
|
setValues = _useFormikContext.setValues,
|
|
860
895
|
setErrors = _useFormikContext.setErrors,
|
|
861
|
-
setTouched = _useFormikContext.setTouched
|
|
896
|
+
setTouched = _useFormikContext.setTouched,
|
|
897
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
862
898
|
var hideQuestionHelpDoc = buildForm.useBuildFormStore(ramda.path(["formState", "helpDocUrls", "hideQuestion"]));
|
|
863
899
|
var _useBuildFormStore = buildForm.useBuildFormStore(function (store) {
|
|
864
900
|
var _store$formState, _store$formState2;
|
|
@@ -917,6 +953,16 @@ var Form$1 = function Form(_ref) {
|
|
|
917
953
|
setErrors({});
|
|
918
954
|
setTouched({});
|
|
919
955
|
};
|
|
956
|
+
var handleLabelChange = function handleLabelChange(label) {
|
|
957
|
+
setFieldValue("label", label);
|
|
958
|
+
if (isEdit) return;
|
|
959
|
+
var uniqueFieldCode = generateUniqueFieldCode({
|
|
960
|
+
questions: questions,
|
|
961
|
+
label: label,
|
|
962
|
+
kind: kind
|
|
963
|
+
});
|
|
964
|
+
setFieldValue("fieldCode", uniqueFieldCode);
|
|
965
|
+
};
|
|
920
966
|
return /*#__PURE__*/jsxRuntime.jsx(Pane.Body, {
|
|
921
967
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
922
968
|
className: "w-full space-y-4",
|
|
@@ -941,7 +987,8 @@ var Form$1 = function Form(_ref) {
|
|
|
941
987
|
disabled: isLabelDisabled,
|
|
942
988
|
name: "label",
|
|
943
989
|
placeholder: DEFAULT_PLACEHOLDERS[kind],
|
|
944
|
-
label: t("neetoForm.questions.common.questionFields.field.question")
|
|
990
|
+
label: t("neetoForm.questions.common.questionFields.field.question"),
|
|
991
|
+
onChange: utils.withEventTargetValue(handleLabelChange)
|
|
945
992
|
}), shouldShowPlaceholder && /*#__PURE__*/jsxRuntime.jsx(FormikAdaptiveInput, {
|
|
946
993
|
name: "placeholder",
|
|
947
994
|
label: t("neetoForm.questions.common.questionFields.field.placeholder")
|
|
@@ -971,38 +1018,48 @@ var requiredLabelValidation = function requiredLabelValidation(schema, field) {
|
|
|
971
1018
|
field: field
|
|
972
1019
|
}));
|
|
973
1020
|
};
|
|
1021
|
+
var fieldCodeValidation = function fieldCodeValidation(schema, field) {
|
|
1022
|
+
return schema.trim().required(i18next.t("neetoForm.common.fieldReq", {
|
|
1023
|
+
field: field
|
|
1024
|
+
})).matches(VALID_FIELD_CODE_REGEX, i18next.t("neetoForm.error.invalidField", {
|
|
1025
|
+
label: field
|
|
1026
|
+
}));
|
|
1027
|
+
};
|
|
974
1028
|
var richTextFieldMissingErrorMessage = function richTextFieldMissingErrorMessage(kind) {
|
|
975
1029
|
var field = ramda.equals(kind, constants.QUESTION_TYPES.PARAGRAPH) ? i18next.t("neetoForm.fields.def") : i18next.t("neetoForm.fields.tcf");
|
|
976
1030
|
return i18next.t("neetoForm.error.fieldCantBeEmpty", {
|
|
977
1031
|
field: field
|
|
978
1032
|
});
|
|
979
1033
|
};
|
|
980
|
-
var formValidationSchema =
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1034
|
+
var formValidationSchema = function formValidationSchema() {
|
|
1035
|
+
var enableFieldCode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1036
|
+
return yup__namespace.object().shape({
|
|
1037
|
+
kind: yup__namespace.string().trim().required(i18next.t("neetoForm.common.fieldReq", {
|
|
1038
|
+
field: i18next.t("neetoForm.questions.common.questionFields.field.questionType")
|
|
1039
|
+
})),
|
|
1040
|
+
label: yup__namespace.string().when("kind", function (kind, schema) {
|
|
1041
|
+
return ramda.includes(kind, constants.RICH_TEXT_QUESTIONS) ? schema.test(richTextFieldMissingErrorMessage(kind), function (value) {
|
|
1042
|
+
return !utils$1.isEditorEmpty(value);
|
|
1043
|
+
}) : requiredLabelValidation(schema, i18next.t("neetoForm.questions.common.questionFields.field.question"));
|
|
1044
|
+
}),
|
|
1045
|
+
fieldCode: yup__namespace.string().trim().notOneOf(constants.RESERVED_FIELD_CODES, i18next.t("neetoForm.error.invalidFieldCode")).when("kind", function (kind, schema) {
|
|
1046
|
+
return enableFieldCode && !ramda.includes(kind, constants.QUESTIONS_WITHOUT_FIELD_CODE) ? fieldCodeValidation(schema, i18next.t("neetoForm.questions.common.questionFields.field.fieldCode")) : schema.notRequired();
|
|
1047
|
+
}),
|
|
1048
|
+
optionsAttributes: yup__namespace.array().when("_destroy", {
|
|
1049
|
+
is: true,
|
|
1050
|
+
otherwise: function otherwise(schema) {
|
|
1051
|
+
return schema.when("kind", function (kind, schema) {
|
|
1052
|
+
return ramda.includes(kind, constants.SELECTABLE_KINDS) ? schema.of(yup__namespace.object().shape({
|
|
1053
|
+
label: requiredLabelValidation(yup__namespace.string(), i18next.t("neetoForm.questions.common.questionFields.field.option"))
|
|
1054
|
+
})) : schema.notRequired();
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
}),
|
|
1058
|
+
highestRatingLabel: yup__namespace.string().nullable(),
|
|
1059
|
+
averageRatingLabel: yup__namespace.string().nullable(),
|
|
1060
|
+
lowestRatingLabel: yup__namespace.string().nullable()
|
|
1061
|
+
});
|
|
1062
|
+
};
|
|
1006
1063
|
|
|
1007
1064
|
var _excluded$6 = ["question", "onClose", "questions", "handleSelect", "buildRequestArgs", "isOpen"];
|
|
1008
1065
|
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; }
|
|
@@ -1062,7 +1119,7 @@ var Add = function Add(_ref) {
|
|
|
1062
1119
|
}), /*#__PURE__*/jsxRuntime.jsx(Form$2, {
|
|
1063
1120
|
formikProps: {
|
|
1064
1121
|
initialValues: INITIAL_VALUES,
|
|
1065
|
-
validationSchema: formValidationSchema,
|
|
1122
|
+
validationSchema: formValidationSchema(props["enableFieldCode"]),
|
|
1066
1123
|
onSubmit: handleSubmit
|
|
1067
1124
|
},
|
|
1068
1125
|
children: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
@@ -1132,7 +1189,7 @@ var Edit = function Edit(_ref) {
|
|
|
1132
1189
|
}), /*#__PURE__*/jsxRuntime.jsx(Form$2, {
|
|
1133
1190
|
formikProps: {
|
|
1134
1191
|
initialValues: question,
|
|
1135
|
-
validationSchema: formValidationSchema,
|
|
1192
|
+
validationSchema: formValidationSchema(props["enableFieldCode"]),
|
|
1136
1193
|
onSubmit: handleSubmit
|
|
1137
1194
|
},
|
|
1138
1195
|
children: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
@@ -2025,7 +2082,7 @@ var AddQuestion = function AddQuestion(_ref) {
|
|
|
2025
2082
|
}));
|
|
2026
2083
|
};
|
|
2027
2084
|
|
|
2028
|
-
var _excluded = ["questionKinds", "onValueChange", "formId", "isDeletable", "isRequiredField", "submitButtonProps", "cancelButtonProps", "isKindAlreadyActive", "getActiveKindDetails", "isDisabledFieldLabel", "disabledAddButtonTooltipProps", "enableFieldCode", "isFormEnabled", "savedTitle", "formTitle", "formDescription", "selectedLanguage", "availableLanguages", "onLanguageChange", "additionalActionOptions", "isReordering", "additionalQuestionKindPattern", "showActionBlock", "buildRequestArgs", "enableDomainBlacklisting", "enableDomainWhitelisting", "helpDocUrls"];
|
|
2085
|
+
var _excluded = ["questionKinds", "onValueChange", "formId", "isDeletable", "isRequiredField", "submitButtonProps", "cancelButtonProps", "isKindAlreadyActive", "getActiveKindDetails", "isDisabledFieldLabel", "disabledAddButtonTooltipProps", "enableFieldCode", "isFormEnabled", "savedTitle", "formTitle", "formDescription", "selectedLanguage", "availableLanguages", "onLanguageChange", "additionalActionOptions", "isReordering", "additionalQuestionKindPattern", "showActionBlock", "buildRequestArgs", "enableDomainBlacklisting", "enableDomainWhitelisting", "helpDocUrls", "questionsHelpProps"];
|
|
2029
2086
|
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; }
|
|
2030
2087
|
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2031
2088
|
var Form = function Form(_ref) {
|
|
@@ -2056,6 +2113,7 @@ var Form = function Form(_ref) {
|
|
|
2056
2113
|
enableDomainBlacklisting = _ref.enableDomainBlacklisting,
|
|
2057
2114
|
enableDomainWhitelisting = _ref.enableDomainWhitelisting,
|
|
2058
2115
|
helpDocUrls = _ref.helpDocUrls,
|
|
2116
|
+
questionsHelpProps = _ref.questionsHelpProps,
|
|
2059
2117
|
formDomProps = _objectWithoutProperties(_ref, _excluded);
|
|
2060
2118
|
var containerRef = React.useRef();
|
|
2061
2119
|
var _useTranslation = reactI18next.useTranslation(),
|
|
@@ -2186,7 +2244,7 @@ var Form = function Form(_ref) {
|
|
|
2186
2244
|
return setIsDeleteAlertOpen(false);
|
|
2187
2245
|
}
|
|
2188
2246
|
}), /*#__PURE__*/jsxRuntime.jsxs(formik.Form, _objectSpread$1(_objectSpread$1({
|
|
2189
|
-
className: "
|
|
2247
|
+
className: "neeto-form-nano-form-wrapper flex h-full flex-col"
|
|
2190
2248
|
}, formDomProps), {}, {
|
|
2191
2249
|
noValidate: true,
|
|
2192
2250
|
children: [formTitle && /*#__PURE__*/jsxRuntime.jsx(Overview, {
|
|
@@ -2197,7 +2255,7 @@ var Form = function Form(_ref) {
|
|
|
2197
2255
|
title: formTitle,
|
|
2198
2256
|
onLanguageChange: handleLanguageChange
|
|
2199
2257
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2200
|
-
className: "
|
|
2258
|
+
className: "neeto-form-nano-form-wrapper__body min-h-0 w-full flex-grow space-y-6 overflow-y-auto pb-6 md:px-6",
|
|
2201
2259
|
children: hasActiveQuestions ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2202
2260
|
className: "space-y-6",
|
|
2203
2261
|
ref: containerRef,
|
|
@@ -2223,13 +2281,15 @@ var Form = function Form(_ref) {
|
|
|
2223
2281
|
onEdit: handleEdit,
|
|
2224
2282
|
onSelect: handleSelect
|
|
2225
2283
|
})
|
|
2226
|
-
}), /*#__PURE__*/jsxRuntime.
|
|
2227
|
-
className: "w-full
|
|
2228
|
-
children: /*#__PURE__*/jsxRuntime.jsx(AddQuestion, {
|
|
2284
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2285
|
+
className: "mb-8 flex w-full items-center gap-x-1",
|
|
2286
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(AddQuestion, {
|
|
2229
2287
|
disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
|
|
2230
2288
|
isDisabled: ramda.isEmpty(availableQuestionKinds),
|
|
2231
2289
|
onAdd: handleAdd
|
|
2232
|
-
})
|
|
2290
|
+
}), neetoCist.isPresent(questionsHelpProps) && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
2291
|
+
children: /*#__PURE__*/jsxRuntime.jsx(HelpPopover, _objectSpread$1({}, questionsHelpProps))
|
|
2292
|
+
})]
|
|
2233
2293
|
})]
|
|
2234
2294
|
}) : /*#__PURE__*/jsxRuntime.jsx(AddFirstQuestion, {
|
|
2235
2295
|
disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
|
|
@@ -2237,7 +2297,7 @@ var Form = function Form(_ref) {
|
|
|
2237
2297
|
onAdd: handleAdd
|
|
2238
2298
|
})
|
|
2239
2299
|
}), (showActionBlock || dirty) && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2240
|
-
className: "
|
|
2300
|
+
className: "neeto-ui-border-gray-300 neeto-form-nano-form-wrapper__footer neeto-ui-bg-white sticky bottom-0 flex flex-shrink-0 justify-end border-t px-6 py-4",
|
|
2241
2301
|
children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock, {
|
|
2242
2302
|
submitButtonProps: submitButtonProps,
|
|
2243
2303
|
isSubmitting: isReordering,
|
|
@@ -2317,7 +2377,9 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
2317
2377
|
_ref$enableDomainWhit = _ref.enableDomainWhitelisting,
|
|
2318
2378
|
enableDomainWhitelisting = _ref$enableDomainWhit === void 0 ? true : _ref$enableDomainWhit,
|
|
2319
2379
|
helpDocUrls = _ref.helpDocUrls,
|
|
2320
|
-
className = _ref.className
|
|
2380
|
+
className = _ref.className,
|
|
2381
|
+
_ref$questionsHelpPro = _ref.questionsHelpProps,
|
|
2382
|
+
questionsHelpProps = _ref$questionsHelpPro === void 0 ? {} : _ref$questionsHelpPro;
|
|
2321
2383
|
var queryClient = reactQuery.useQueryClient();
|
|
2322
2384
|
var _useReorderQuestions = useFormApi.useReorderQuestions(id, {
|
|
2323
2385
|
onSuccess: utils.showThumbsUpToastr
|
|
@@ -2415,6 +2477,7 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
2415
2477
|
kindUniqueOn: kindUniqueOn,
|
|
2416
2478
|
onLanguageChange: onLanguageChange,
|
|
2417
2479
|
onValueChange: onValueChange,
|
|
2480
|
+
questionsHelpProps: questionsHelpProps,
|
|
2418
2481
|
savedTitle: savedTitle,
|
|
2419
2482
|
selectedLanguage: selectedLanguage,
|
|
2420
2483
|
showActionBlock: showActionBlock,
|