@bigbinary/neeto-form-frontend 3.9.1 → 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 +148 -85
- package/dist/BuildForm.js.map +1 -1
- package/dist/ExternalForm.js +6 -6
- package/dist/Submission.js +2 -2
- package/dist/Submission.js.map +1 -1
- package/dist/UrlBuilder.js +6 -6
- package/dist/{buildForm-b8eb931e.js → buildForm-CthgTgsm.js} +3 -7
- package/dist/{buildForm-b8eb931e.js.map → buildForm-CthgTgsm.js.map} +1 -1
- package/dist/{buildForm-dfd708c6.js → buildForm-GdQQ62ve.js} +2 -2
- package/dist/{buildForm-dfd708c6.js.map → buildForm-GdQQ62ve.js.map} +1 -1
- package/dist/cjs/BuildForm.js +276 -251
- package/dist/cjs/BuildForm.js.map +1 -1
- package/dist/cjs/ExternalForm.js +39 -60
- package/dist/cjs/ExternalForm.js.map +1 -1
- package/dist/cjs/Submission.js +11 -20
- package/dist/cjs/Submission.js.map +1 -1
- package/dist/cjs/UrlBuilder.js +15 -25
- package/dist/cjs/UrlBuilder.js.map +1 -1
- package/dist/cjs/hooks.js +4 -6
- package/dist/cjs/hooks.js.map +1 -1
- package/dist/cjs/index.js +8 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/{constants-9538731d.js → constants-CEOQLu3J.js} +7 -3
- package/dist/constants-CEOQLu3J.js.map +1 -0
- package/dist/{constants-4d9fc943.js → constants-D-XSuLo2.js} +10 -15
- package/dist/{constants-4d9fc943.js.map → constants-D-XSuLo2.js.map} +1 -1
- package/dist/{constants-771cca31.js → constants-DXZnQ_E9.js} +16 -17
- package/dist/constants-DXZnQ_E9.js.map +1 -0
- package/dist/{constants-75b78b3a.js → constants-DlRX5mcQ.js} +1 -1
- package/dist/{constants-75b78b3a.js.map → constants-DlRX5mcQ.js.map} +1 -1
- package/dist/hooks.js +4 -4
- package/dist/{index-b6bb805c.js → index-2caW4Cx0.js} +1 -1
- package/dist/{index-b6bb805c.js.map → index-2caW4Cx0.js.map} +1 -1
- package/dist/{index-2664c3e7.js → index-BL5SirYx.js} +1 -1
- package/dist/{index-2664c3e7.js.map → index-BL5SirYx.js.map} +1 -1
- package/dist/index.js +8 -8
- package/dist/{useFormApi-dee63a95.js → useFormApi-BS-TCKwR.js} +2 -2
- package/dist/{useFormApi-dee63a95.js.map → useFormApi-BS-TCKwR.js.map} +1 -1
- package/dist/{useFormApi-24e05ed2.js → useFormApi-DAiOGCeD.js} +34 -43
- package/dist/useFormApi-DAiOGCeD.js.map +1 -0
- package/dist/{useFormSubmission-c4e42402.js → useFormSubmission-B2aaxL1m.js} +2 -2
- package/dist/{useFormSubmission-c4e42402.js.map → useFormSubmission-B2aaxL1m.js.map} +1 -1
- package/dist/{useFormSubmission-8b23d7aa.js → useFormSubmission-DeaBHZs7.js} +2 -2
- package/dist/{useFormSubmission-8b23d7aa.js.map → useFormSubmission-DeaBHZs7.js.map} +1 -1
- package/dist/{utils-58566755.js → utils-BwrOrhV5.js} +5 -5
- package/dist/{utils-58566755.js.map → utils-BwrOrhV5.js.map} +1 -1
- package/dist/{utils-d5895099.js → utils-DgV43Oko.js} +70 -95
- package/dist/{utils-d5895099.js.map → utils-DgV43Oko.js.map} +1 -1
- package/package.json +19 -18
- package/types.d.ts +6 -0
- package/dist/constants-771cca31.js.map +0 -1
- package/dist/constants-9538731d.js.map +0 -1
- package/dist/useFormApi-24e05ed2.js.map +0 -1
package/dist/BuildForm.js
CHANGED
|
@@ -3,29 +3,29 @@ import { useState, useRef, useEffect, createElement } from 'react';
|
|
|
3
3
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import { useFormikContext, useField, FieldArray, Form as Form$3, Formik } from 'formik';
|
|
6
|
-
import { isPresent, truncate, findBy, isNotPresent, slugify,
|
|
7
|
-
import { showThumbsUpToastr, hyphenize } from '@bigbinary/neeto-commons-frontend/utils';
|
|
6
|
+
import { isPresent, truncate, findBy, isNotPresent, slugify, hyphenate, noop, nullSafe, filterBy, removeBy } from '@bigbinary/neeto-cist';
|
|
7
|
+
import { showThumbsUpToastr, withEventTargetValue, hyphenize } from '@bigbinary/neeto-commons-frontend/utils';
|
|
8
8
|
import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
|
|
9
|
-
import { equals, includes, __, reduce, assoc, path, when, isEmpty, reject, keys, pick, omit,
|
|
10
|
-
import {
|
|
11
|
-
import { Q as QUESTION_KIND } from './constants-
|
|
12
|
-
import { I as INDEPENDENT_LABELS_MAP, R as RICH_TEXT_QUESTIONS, A as AUTO_GENERATED_KINDS, a as IMMUTABLE_KINDS, h as htmlToPlainText, i as isElementOverflowing, D as Drag,
|
|
9
|
+
import { equals, includes, __, reduce, assoc, path, when, isEmpty, reject, keys, pick, omit, modify, without, mergeLeft, isNil, pipe, filter, isNotNil, uniq, join, pluck, map, test, difference, prop, split, last, concat, F } from 'ramda';
|
|
10
|
+
import { h as useDeleteQuestion, i as useFetchQuestions, j as useCreateQuestion, k as useUpdateQuestion, l as useReorderQuestions, Q as QUERY_KEYS } from './useFormApi-BS-TCKwR.js';
|
|
11
|
+
import { Q as QUESTION_KIND } from './constants-DlRX5mcQ.js';
|
|
12
|
+
import { I as INDEPENDENT_LABELS_MAP, R as RICH_TEXT_QUESTIONS, A as AUTO_GENERATED_KINDS, a as IMMUTABLE_KINDS, h as htmlToPlainText, i as isElementOverflowing, D as Drag, b as QUESTION_TYPES, S as SELECTABLE_KINDS, N as NON_BASIC_LATIN_CHARACTERS_REGEX, c as RESERVED_FIELD_CODES, F as FIELD_CODES_REJECT_CHARS_REGEX, Q as QUESTIONS_WITHOUT_FIELD_CODE, d as NON_HIDEABLE_FIELDS, C as CAPTCHA_TYPES, e as FILE_TYPES_MAP, f as FILE_GROUPS, M as MINIMUM_OPTIONS, j as RATING_OPTIONS, k as STAR_RATING_MIN_VALUE_OPTIONS, l as STAR_RATING_MAX_VALUE_OPTIONS, m as STAR_RATING_ICONS_MAP, n as QUESTION_ACTIONS, o as QUESTION_KINDS, p as getActiveQuestionKindDetails, q as DEFAULT_AVAILABLE_LANGUAGES, r as QUESTIONS_INITIAL_VALUE, s as MANDATORY_KINDS } from './constants-CEOQLu3J.js';
|
|
13
13
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
14
14
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
15
15
|
import { Droppable, Draggable, DragDropContext } from '@hello-pangea/dnd';
|
|
16
16
|
import { isMetaKeyPressed, withT, useStateWithDependency, useOnClickOutside } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
17
|
+
import HelpPopover from '@bigbinary/neeto-molecules/HelpPopover';
|
|
17
18
|
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
|
|
18
19
|
import { useTranslation, Trans } from 'react-i18next';
|
|
19
|
-
import { a as useBuildFormStore } from './buildForm-
|
|
20
|
+
import { a as useBuildFormStore } from './buildForm-GdQQ62ve.js';
|
|
20
21
|
import { shallow } from 'zustand/shallow';
|
|
21
22
|
import Alert from '@bigbinary/neetoui/Alert';
|
|
22
|
-
import { f as fieldWithFallback, i as isFunction } from './index-
|
|
23
|
+
import { f as fieldWithFallback, i as isFunction } from './index-BL5SirYx.js';
|
|
23
24
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
24
25
|
import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
|
|
25
26
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
26
27
|
import Dropdown from '@bigbinary/neetoui/Dropdown';
|
|
27
28
|
import Tooltip from '@bigbinary/neetoui/Tooltip';
|
|
28
|
-
import HelpPopover from '@bigbinary/neeto-molecules/HelpPopover';
|
|
29
29
|
import { t } from 'i18next';
|
|
30
30
|
import Plus from '@bigbinary/neeto-icons/Plus';
|
|
31
31
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
@@ -443,18 +443,43 @@ function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var t
|
|
|
443
443
|
var isChoiceQuestion = function isChoiceQuestion(question) {
|
|
444
444
|
return includes(question === null || question === void 0 ? void 0 : question.kind, SELECTABLE_KINDS);
|
|
445
445
|
};
|
|
446
|
-
var
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
446
|
+
var underscoredWithoutSpecialCharacters = function underscoredWithoutSpecialCharacters(string) {
|
|
447
|
+
return string.toLowerCase().replace(/[\s-]/g, "_").replace(/[\W]/gi, "").replace(/_+/g, "_").replace(/^_+|_+$/, "");
|
|
448
|
+
};
|
|
449
|
+
var addSuffixForReservedFieldCode = function addSuffixForReservedFieldCode(fieldCode) {
|
|
450
|
+
return RESERVED_FIELD_CODES.includes(fieldCode) ? "".concat(fieldCode, "_field") : fieldCode;
|
|
451
|
+
};
|
|
452
|
+
var getUniqueNumbersFromExistingFieldCodes = function getUniqueNumbersFromExistingFieldCodes(prefix, questions) {
|
|
453
|
+
return questions.filter(function (question) {
|
|
454
|
+
return question.fieldCode.startsWith(prefix);
|
|
455
|
+
}).map(function (question) {
|
|
456
|
+
return parseInt(question.fieldCode.replace(prefix, "")) || 0;
|
|
457
|
+
});
|
|
458
|
+
};
|
|
459
|
+
var generateFieldCodePrefix = function generateFieldCodePrefix(label, kind) {
|
|
460
|
+
var prefix;
|
|
461
|
+
if (NON_BASIC_LATIN_CHARACTERS_REGEX.test(label) || isEmpty(label)) {
|
|
462
|
+
prefix = kind;
|
|
463
|
+
} else {
|
|
464
|
+
var sanitizedLabel = underscoredWithoutSpecialCharacters(label).slice(0, 30);
|
|
465
|
+
prefix = isEmpty(sanitizedLabel) ? kind : sanitizedLabel;
|
|
466
|
+
}
|
|
467
|
+
return addSuffixForReservedFieldCode(prefix) || "";
|
|
468
|
+
};
|
|
469
|
+
var generateUniqueFieldCode = function generateUniqueFieldCode(_ref) {
|
|
470
|
+
var questions = _ref.questions,
|
|
471
|
+
_ref$label = _ref.label,
|
|
472
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
473
|
+
_ref$kind = _ref.kind,
|
|
474
|
+
kind = _ref$kind === void 0 ? "" : _ref$kind;
|
|
475
|
+
var prefix = generateFieldCodePrefix(label, kind);
|
|
476
|
+
var uniqueNumber = Math.max.apply(Math, [0].concat(_toConsumableArray(getUniqueNumbersFromExistingFieldCodes(prefix, questions))));
|
|
451
477
|
var candidateFieldCode = "";
|
|
452
|
-
var prefix = RESERVED_FIELD_CODES.includes(type) ? "".concat(type, "_field") : type;
|
|
453
478
|
|
|
454
479
|
//We need to continue this while loop until we can generate a unique fieldCode
|
|
455
480
|
// eslint-disable-next-line no-constant-condition
|
|
456
481
|
while (true) {
|
|
457
|
-
candidateFieldCode = "".concat(prefix).concat(uniqueNumber
|
|
482
|
+
candidateFieldCode = "".concat(prefix).concat(uniqueNumber === 0 ? "" : uniqueNumber);
|
|
458
483
|
if (!findBy({
|
|
459
484
|
fieldCode: candidateFieldCode
|
|
460
485
|
}, questions)) break;
|
|
@@ -462,18 +487,18 @@ var generateUniqueFieldCode = function generateUniqueFieldCode(type, questions)
|
|
|
462
487
|
}
|
|
463
488
|
return candidateFieldCode;
|
|
464
489
|
};
|
|
465
|
-
var isQuestionKindAlreadyActive = function isQuestionKindAlreadyActive(
|
|
466
|
-
var activeQuestions =
|
|
467
|
-
kind =
|
|
490
|
+
var isQuestionKindAlreadyActive = function isQuestionKindAlreadyActive(_ref2) {
|
|
491
|
+
var activeQuestions = _ref2.activeQuestions,
|
|
492
|
+
kind = _ref2.kind;
|
|
468
493
|
return activeQuestions.some(function (activeQuestion) {
|
|
469
494
|
return activeQuestion.kind === kind.type && activeQuestion._destroy !== true;
|
|
470
495
|
});
|
|
471
496
|
};
|
|
472
|
-
var handleFieldDragEnd = function handleFieldDragEnd(
|
|
473
|
-
var items =
|
|
474
|
-
setValue =
|
|
475
|
-
source =
|
|
476
|
-
destination =
|
|
497
|
+
var handleFieldDragEnd = function handleFieldDragEnd(_ref3) {
|
|
498
|
+
var items = _ref3.items,
|
|
499
|
+
setValue = _ref3.setValue,
|
|
500
|
+
source = _ref3.source,
|
|
501
|
+
destination = _ref3.destination;
|
|
477
502
|
if (!(destination && items instanceof Array)) return;
|
|
478
503
|
var nextItems = _toConsumableArray(items);
|
|
479
504
|
arrayHelpers.moveItem(nextItems, source.index, destination.index);
|
|
@@ -484,32 +509,36 @@ var handleFieldDragEnd = function handleFieldDragEnd(_ref2) {
|
|
|
484
509
|
});
|
|
485
510
|
setValue("questions", orderedItems);
|
|
486
511
|
};
|
|
487
|
-
var createFieldData = function createFieldData(
|
|
488
|
-
var
|
|
489
|
-
defaults =
|
|
490
|
-
type =
|
|
491
|
-
metadata =
|
|
492
|
-
|
|
493
|
-
isRequired =
|
|
494
|
-
questions =
|
|
512
|
+
var createFieldData = function createFieldData(_ref4) {
|
|
513
|
+
var _ref4$kind = _ref4.kind,
|
|
514
|
+
defaults = _ref4$kind.defaults,
|
|
515
|
+
type = _ref4$kind.type,
|
|
516
|
+
metadata = _ref4$kind.metadata,
|
|
517
|
+
_ref4$isRequired = _ref4.isRequired,
|
|
518
|
+
isRequired = _ref4$isRequired === void 0 ? undefined : _ref4$isRequired,
|
|
519
|
+
questions = _ref4.questions;
|
|
495
520
|
return _objectSpread$e(_objectSpread$e({}, defaults), {}, {
|
|
496
521
|
metadata: metadata,
|
|
497
522
|
isRequired: isRequired,
|
|
498
523
|
kind: type,
|
|
499
524
|
nodeId: v4(),
|
|
500
|
-
fieldCode: generateUniqueFieldCode(
|
|
525
|
+
fieldCode: generateUniqueFieldCode({
|
|
526
|
+
questions: questions,
|
|
527
|
+
kind: type,
|
|
528
|
+
label: defaults["label"]
|
|
529
|
+
})
|
|
501
530
|
});
|
|
502
531
|
};
|
|
503
|
-
var duplicateFieldData = function duplicateFieldData(
|
|
504
|
-
var item =
|
|
505
|
-
questionKinds =
|
|
506
|
-
questions =
|
|
507
|
-
var questionKind = findBy({
|
|
508
|
-
type: item.kind
|
|
509
|
-
}, questionKinds);
|
|
532
|
+
var duplicateFieldData = function duplicateFieldData(_ref5) {
|
|
533
|
+
var item = _ref5.item,
|
|
534
|
+
questionKinds = _ref5.questionKinds,
|
|
535
|
+
questions = _ref5.questions;
|
|
510
536
|
var isRequired = item.isRequired,
|
|
511
537
|
kind = item.kind,
|
|
512
538
|
optionsAttributes = item.optionsAttributes;
|
|
539
|
+
var questionKind = findBy({
|
|
540
|
+
type: kind
|
|
541
|
+
}, questionKinds);
|
|
513
542
|
var label = fieldWithFallback(item, "label");
|
|
514
543
|
var defaultAttributeNames = keys(questionKind.defaults || {});
|
|
515
544
|
var defaultAttributes = pick(defaultAttributeNames, item);
|
|
@@ -522,15 +551,19 @@ var duplicateFieldData = function duplicateFieldData(_ref4) {
|
|
|
522
551
|
label: newQuestionLabel,
|
|
523
552
|
optionsAttributes: optionsAttributes && optionsAttributes.map(omit(["id"])),
|
|
524
553
|
nodeId: v4(),
|
|
525
|
-
fieldCode: generateUniqueFieldCode(
|
|
554
|
+
fieldCode: generateUniqueFieldCode({
|
|
555
|
+
questions: questions,
|
|
556
|
+
kind: kind,
|
|
557
|
+
label: newQuestionLabel
|
|
558
|
+
}),
|
|
526
559
|
displayOrder: item.displayOrder + 1
|
|
527
560
|
});
|
|
528
561
|
};
|
|
529
|
-
var getAvailableQuestionKinds = function getAvailableQuestionKinds(
|
|
530
|
-
var allQuestionKinds =
|
|
531
|
-
|
|
532
|
-
activeQuestions =
|
|
533
|
-
isKindAlreadyActive =
|
|
562
|
+
var getAvailableQuestionKinds = function getAvailableQuestionKinds(_ref6) {
|
|
563
|
+
var allQuestionKinds = _ref6.allQuestionKinds,
|
|
564
|
+
_ref6$activeQuestions = _ref6.activeQuestions,
|
|
565
|
+
activeQuestions = _ref6$activeQuestions === void 0 ? [] : _ref6$activeQuestions,
|
|
566
|
+
isKindAlreadyActive = _ref6.isKindAlreadyActive;
|
|
534
567
|
if (isEmpty(activeQuestions)) return allQuestionKinds;
|
|
535
568
|
return reject(function (kind) {
|
|
536
569
|
var isSingularKind = kind.isSingular;
|
|
@@ -593,6 +626,7 @@ var INITIAL_VALUES = {
|
|
|
593
626
|
label: "",
|
|
594
627
|
fieldCode: ""
|
|
595
628
|
};
|
|
629
|
+
var VALID_FIELD_CODE_REGEX = /^[a-z0-9]+(_[a-z0-9]+)*$/;
|
|
596
630
|
|
|
597
631
|
var _excluded$8 = ["label", "name"];
|
|
598
632
|
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; }
|
|
@@ -803,6 +837,7 @@ var FieldCode = function FieldCode() {
|
|
|
803
837
|
required: true,
|
|
804
838
|
label: t("neetoForm.questions.common.questionFields.field.fieldCode"),
|
|
805
839
|
name: "fieldCode",
|
|
840
|
+
rejectCharsRegex: FIELD_CODES_REJECT_CHARS_REGEX,
|
|
806
841
|
helpText: helpDocUrl && /*#__PURE__*/jsx(Trans, {
|
|
807
842
|
i18nKey: "neetoForm.questions.common.questionFields.field.fieldCodeHelpDescription",
|
|
808
843
|
components: {
|
|
@@ -837,7 +872,8 @@ var Form$1 = function Form(_ref) {
|
|
|
837
872
|
values = _useFormikContext.values,
|
|
838
873
|
setValues = _useFormikContext.setValues,
|
|
839
874
|
setErrors = _useFormikContext.setErrors,
|
|
840
|
-
setTouched = _useFormikContext.setTouched
|
|
875
|
+
setTouched = _useFormikContext.setTouched,
|
|
876
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
841
877
|
var hideQuestionHelpDoc = useBuildFormStore(path(["formState", "helpDocUrls", "hideQuestion"]));
|
|
842
878
|
var _useBuildFormStore = useBuildFormStore(function (store) {
|
|
843
879
|
var _store$formState, _store$formState2;
|
|
@@ -896,6 +932,16 @@ var Form$1 = function Form(_ref) {
|
|
|
896
932
|
setErrors({});
|
|
897
933
|
setTouched({});
|
|
898
934
|
};
|
|
935
|
+
var handleLabelChange = function handleLabelChange(label) {
|
|
936
|
+
setFieldValue("label", label);
|
|
937
|
+
if (isEdit) return;
|
|
938
|
+
var uniqueFieldCode = generateUniqueFieldCode({
|
|
939
|
+
questions: questions,
|
|
940
|
+
label: label,
|
|
941
|
+
kind: kind
|
|
942
|
+
});
|
|
943
|
+
setFieldValue("fieldCode", uniqueFieldCode);
|
|
944
|
+
};
|
|
899
945
|
return /*#__PURE__*/jsx(Pane.Body, {
|
|
900
946
|
children: /*#__PURE__*/jsxs("div", {
|
|
901
947
|
className: "w-full space-y-4",
|
|
@@ -920,7 +966,8 @@ var Form$1 = function Form(_ref) {
|
|
|
920
966
|
disabled: isLabelDisabled,
|
|
921
967
|
name: "label",
|
|
922
968
|
placeholder: DEFAULT_PLACEHOLDERS[kind],
|
|
923
|
-
label: t("neetoForm.questions.common.questionFields.field.question")
|
|
969
|
+
label: t("neetoForm.questions.common.questionFields.field.question"),
|
|
970
|
+
onChange: withEventTargetValue(handleLabelChange)
|
|
924
971
|
}), shouldShowPlaceholder && /*#__PURE__*/jsx(FormikAdaptiveInput, {
|
|
925
972
|
name: "placeholder",
|
|
926
973
|
label: t("neetoForm.questions.common.questionFields.field.placeholder")
|
|
@@ -950,38 +997,48 @@ var requiredLabelValidation = function requiredLabelValidation(schema, field) {
|
|
|
950
997
|
field: field
|
|
951
998
|
}));
|
|
952
999
|
};
|
|
1000
|
+
var fieldCodeValidation = function fieldCodeValidation(schema, field) {
|
|
1001
|
+
return schema.trim().required(t("neetoForm.common.fieldReq", {
|
|
1002
|
+
field: field
|
|
1003
|
+
})).matches(VALID_FIELD_CODE_REGEX, t("neetoForm.error.invalidField", {
|
|
1004
|
+
label: field
|
|
1005
|
+
}));
|
|
1006
|
+
};
|
|
953
1007
|
var richTextFieldMissingErrorMessage = function richTextFieldMissingErrorMessage(kind) {
|
|
954
1008
|
var field = equals(kind, QUESTION_TYPES.PARAGRAPH) ? t("neetoForm.fields.def") : t("neetoForm.fields.tcf");
|
|
955
1009
|
return t("neetoForm.error.fieldCantBeEmpty", {
|
|
956
1010
|
field: field
|
|
957
1011
|
});
|
|
958
1012
|
};
|
|
959
|
-
var formValidationSchema =
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
1013
|
+
var formValidationSchema = function formValidationSchema() {
|
|
1014
|
+
var enableFieldCode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1015
|
+
return yup.object().shape({
|
|
1016
|
+
kind: yup.string().trim().required(t("neetoForm.common.fieldReq", {
|
|
1017
|
+
field: t("neetoForm.questions.common.questionFields.field.questionType")
|
|
1018
|
+
})),
|
|
1019
|
+
label: yup.string().when("kind", function (kind, schema) {
|
|
1020
|
+
return includes(kind, RICH_TEXT_QUESTIONS) ? schema.test(richTextFieldMissingErrorMessage(kind), function (value) {
|
|
1021
|
+
return !isEditorEmpty(value);
|
|
1022
|
+
}) : requiredLabelValidation(schema, t("neetoForm.questions.common.questionFields.field.question"));
|
|
1023
|
+
}),
|
|
1024
|
+
fieldCode: yup.string().trim().notOneOf(RESERVED_FIELD_CODES, t("neetoForm.error.invalidFieldCode")).when("kind", function (kind, schema) {
|
|
1025
|
+
return enableFieldCode && !includes(kind, QUESTIONS_WITHOUT_FIELD_CODE) ? fieldCodeValidation(schema, t("neetoForm.questions.common.questionFields.field.fieldCode")) : schema.notRequired();
|
|
1026
|
+
}),
|
|
1027
|
+
optionsAttributes: yup.array().when("_destroy", {
|
|
1028
|
+
is: true,
|
|
1029
|
+
otherwise: function otherwise(schema) {
|
|
1030
|
+
return schema.when("kind", function (kind, schema) {
|
|
1031
|
+
return includes(kind, SELECTABLE_KINDS) ? schema.of(yup.object().shape({
|
|
1032
|
+
label: requiredLabelValidation(yup.string(), t("neetoForm.questions.common.questionFields.field.option"))
|
|
1033
|
+
})) : schema.notRequired();
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
}),
|
|
1037
|
+
highestRatingLabel: yup.string().nullable(),
|
|
1038
|
+
averageRatingLabel: yup.string().nullable(),
|
|
1039
|
+
lowestRatingLabel: yup.string().nullable()
|
|
1040
|
+
});
|
|
1041
|
+
};
|
|
985
1042
|
|
|
986
1043
|
var _excluded$6 = ["question", "onClose", "questions", "handleSelect", "buildRequestArgs", "isOpen"];
|
|
987
1044
|
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; }
|
|
@@ -1041,7 +1098,7 @@ var Add = function Add(_ref) {
|
|
|
1041
1098
|
}), /*#__PURE__*/jsx(Form$2, {
|
|
1042
1099
|
formikProps: {
|
|
1043
1100
|
initialValues: INITIAL_VALUES,
|
|
1044
|
-
validationSchema: formValidationSchema,
|
|
1101
|
+
validationSchema: formValidationSchema(props["enableFieldCode"]),
|
|
1045
1102
|
onSubmit: handleSubmit
|
|
1046
1103
|
},
|
|
1047
1104
|
children: /*#__PURE__*/jsxs(Fragment, {
|
|
@@ -1111,7 +1168,7 @@ var Edit = function Edit(_ref) {
|
|
|
1111
1168
|
}), /*#__PURE__*/jsx(Form$2, {
|
|
1112
1169
|
formikProps: {
|
|
1113
1170
|
initialValues: question,
|
|
1114
|
-
validationSchema: formValidationSchema,
|
|
1171
|
+
validationSchema: formValidationSchema(props["enableFieldCode"]),
|
|
1115
1172
|
onSubmit: handleSubmit
|
|
1116
1173
|
},
|
|
1117
1174
|
children: /*#__PURE__*/jsxs(Fragment, {
|
|
@@ -2004,7 +2061,7 @@ var AddQuestion = function AddQuestion(_ref) {
|
|
|
2004
2061
|
}));
|
|
2005
2062
|
};
|
|
2006
2063
|
|
|
2007
|
-
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"];
|
|
2064
|
+
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"];
|
|
2008
2065
|
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; }
|
|
2009
2066
|
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; }
|
|
2010
2067
|
var Form = function Form(_ref) {
|
|
@@ -2035,6 +2092,7 @@ var Form = function Form(_ref) {
|
|
|
2035
2092
|
enableDomainBlacklisting = _ref.enableDomainBlacklisting,
|
|
2036
2093
|
enableDomainWhitelisting = _ref.enableDomainWhitelisting,
|
|
2037
2094
|
helpDocUrls = _ref.helpDocUrls,
|
|
2095
|
+
questionsHelpProps = _ref.questionsHelpProps,
|
|
2038
2096
|
formDomProps = _objectWithoutProperties(_ref, _excluded);
|
|
2039
2097
|
var containerRef = useRef();
|
|
2040
2098
|
var _useTranslation = useTranslation(),
|
|
@@ -2165,7 +2223,7 @@ var Form = function Form(_ref) {
|
|
|
2165
2223
|
return setIsDeleteAlertOpen(false);
|
|
2166
2224
|
}
|
|
2167
2225
|
}), /*#__PURE__*/jsxs(Form$3, _objectSpread$1(_objectSpread$1({
|
|
2168
|
-
className: "
|
|
2226
|
+
className: "neeto-form-nano-form-wrapper flex h-full flex-col"
|
|
2169
2227
|
}, formDomProps), {}, {
|
|
2170
2228
|
noValidate: true,
|
|
2171
2229
|
children: [formTitle && /*#__PURE__*/jsx(Overview, {
|
|
@@ -2176,7 +2234,7 @@ var Form = function Form(_ref) {
|
|
|
2176
2234
|
title: formTitle,
|
|
2177
2235
|
onLanguageChange: handleLanguageChange
|
|
2178
2236
|
}), /*#__PURE__*/jsx("div", {
|
|
2179
|
-
className: "
|
|
2237
|
+
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",
|
|
2180
2238
|
children: hasActiveQuestions ? /*#__PURE__*/jsxs("div", {
|
|
2181
2239
|
className: "space-y-6",
|
|
2182
2240
|
ref: containerRef,
|
|
@@ -2202,13 +2260,15 @@ var Form = function Form(_ref) {
|
|
|
2202
2260
|
onEdit: handleEdit,
|
|
2203
2261
|
onSelect: handleSelect
|
|
2204
2262
|
})
|
|
2205
|
-
}), /*#__PURE__*/
|
|
2206
|
-
className: "w-full
|
|
2207
|
-
children: /*#__PURE__*/jsx(AddQuestion, {
|
|
2263
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
2264
|
+
className: "mb-8 flex w-full items-center gap-x-1",
|
|
2265
|
+
children: [/*#__PURE__*/jsx(AddQuestion, {
|
|
2208
2266
|
disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
|
|
2209
2267
|
isDisabled: isEmpty(availableQuestionKinds),
|
|
2210
2268
|
onAdd: handleAdd
|
|
2211
|
-
})
|
|
2269
|
+
}), isPresent(questionsHelpProps) && /*#__PURE__*/jsx("span", {
|
|
2270
|
+
children: /*#__PURE__*/jsx(HelpPopover, _objectSpread$1({}, questionsHelpProps))
|
|
2271
|
+
})]
|
|
2212
2272
|
})]
|
|
2213
2273
|
}) : /*#__PURE__*/jsx(AddFirstQuestion, {
|
|
2214
2274
|
disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
|
|
@@ -2216,7 +2276,7 @@ var Form = function Form(_ref) {
|
|
|
2216
2276
|
onAdd: handleAdd
|
|
2217
2277
|
})
|
|
2218
2278
|
}), (showActionBlock || dirty) && /*#__PURE__*/jsx("div", {
|
|
2219
|
-
className: "
|
|
2279
|
+
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",
|
|
2220
2280
|
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
2221
2281
|
submitButtonProps: submitButtonProps,
|
|
2222
2282
|
isSubmitting: isReordering,
|
|
@@ -2296,7 +2356,9 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
2296
2356
|
_ref$enableDomainWhit = _ref.enableDomainWhitelisting,
|
|
2297
2357
|
enableDomainWhitelisting = _ref$enableDomainWhit === void 0 ? true : _ref$enableDomainWhit,
|
|
2298
2358
|
helpDocUrls = _ref.helpDocUrls,
|
|
2299
|
-
className = _ref.className
|
|
2359
|
+
className = _ref.className,
|
|
2360
|
+
_ref$questionsHelpPro = _ref.questionsHelpProps,
|
|
2361
|
+
questionsHelpProps = _ref$questionsHelpPro === void 0 ? {} : _ref$questionsHelpPro;
|
|
2300
2362
|
var queryClient = useQueryClient();
|
|
2301
2363
|
var _useReorderQuestions = useReorderQuestions(id, {
|
|
2302
2364
|
onSuccess: showThumbsUpToastr
|
|
@@ -2394,6 +2456,7 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
2394
2456
|
kindUniqueOn: kindUniqueOn,
|
|
2395
2457
|
onLanguageChange: onLanguageChange,
|
|
2396
2458
|
onValueChange: onValueChange,
|
|
2459
|
+
questionsHelpProps: questionsHelpProps,
|
|
2397
2460
|
savedTitle: savedTitle,
|
|
2398
2461
|
selectedLanguage: selectedLanguage,
|
|
2399
2462
|
showActionBlock: showActionBlock,
|