@bigbinary/neeto-form-frontend 3.10.26 → 3.11.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.
Files changed (57) hide show
  1. package/app/javascript/src/translations/en.json +6 -1
  2. package/dist/BuildForm.js +197 -67
  3. package/dist/BuildForm.js.map +1 -1
  4. package/dist/ExternalForm.js +6 -15
  5. package/dist/ExternalForm.js.map +1 -1
  6. package/dist/Submission.js +45 -12
  7. package/dist/Submission.js.map +1 -1
  8. package/dist/UrlBuilder.js +16 -5
  9. package/dist/UrlBuilder.js.map +1 -1
  10. package/dist/{buildForm-D5-1L1Je.js → buildForm-CuAJYr6B.js} +4 -3
  11. package/dist/buildForm-CuAJYr6B.js.map +1 -0
  12. package/dist/{buildForm-ZqO8kJoo.js → buildForm-nKLcTFON.js} +4 -3
  13. package/dist/buildForm-nKLcTFON.js.map +1 -0
  14. package/dist/cjs/BuildForm.js +252 -122
  15. package/dist/cjs/BuildForm.js.map +1 -1
  16. package/dist/cjs/ExternalForm.js +19 -28
  17. package/dist/cjs/ExternalForm.js.map +1 -1
  18. package/dist/cjs/Submission.js +44 -11
  19. package/dist/cjs/Submission.js.map +1 -1
  20. package/dist/cjs/UrlBuilder.js +17 -6
  21. package/dist/cjs/UrlBuilder.js.map +1 -1
  22. package/dist/cjs/hooks.js +9 -9
  23. package/dist/cjs/index.js +13 -13
  24. package/dist/{constants-DWy8qlgB.js → constants-CIKOBOUZ.js} +131 -129
  25. package/dist/constants-CIKOBOUZ.js.map +1 -0
  26. package/dist/{useFormApi-JO7ZX1kT.js → constants-CkGU4abB.js} +31 -1
  27. package/dist/constants-CkGU4abB.js.map +1 -0
  28. package/dist/{constants-C0I-orlh.js → constants-DdGn1rF4.js} +91 -90
  29. package/dist/constants-DdGn1rF4.js.map +1 -0
  30. package/dist/{useFormApi-Bp5eA5dg.js → constants-LQk7jxH9.js} +30 -2
  31. package/dist/constants-LQk7jxH9.js.map +1 -0
  32. package/dist/hooks.js +4 -4
  33. package/dist/{index-BL5SirYx.js → index-OmmVAj8-.js} +6 -2
  34. package/dist/index-OmmVAj8-.js.map +1 -0
  35. package/dist/{index-2caW4Cx0.js → index-qEhecRV2.js} +6 -1
  36. package/dist/index-qEhecRV2.js.map +1 -0
  37. package/dist/index.js +8 -8
  38. package/dist/{useFormSubmission-w1MbJv37.js → useFormSubmission-Cab-hFHR.js} +3 -3
  39. package/dist/{useFormSubmission-w1MbJv37.js.map → useFormSubmission-Cab-hFHR.js.map} +1 -1
  40. package/dist/{useFormSubmission-Bf6ryXlB.js → useFormSubmission-CqQgBLsl.js} +2 -2
  41. package/dist/{useFormSubmission-Bf6ryXlB.js.map → useFormSubmission-CqQgBLsl.js.map} +1 -1
  42. package/dist/{utils-DYmocaoL.js → utils-BGQM3KyH.js} +90 -43
  43. package/dist/utils-BGQM3KyH.js.map +1 -0
  44. package/dist/{utils-Dq-MY0vG.js → utils-DNSCC4Jb.js} +96 -49
  45. package/dist/utils-DNSCC4Jb.js.map +1 -0
  46. package/package.json +3 -3
  47. package/types.d.ts +3 -1
  48. package/dist/buildForm-D5-1L1Je.js.map +0 -1
  49. package/dist/buildForm-ZqO8kJoo.js.map +0 -1
  50. package/dist/constants-C0I-orlh.js.map +0 -1
  51. package/dist/constants-DWy8qlgB.js.map +0 -1
  52. package/dist/index-2caW4Cx0.js.map +0 -1
  53. package/dist/index-BL5SirYx.js.map +0 -1
  54. package/dist/useFormApi-Bp5eA5dg.js.map +0 -1
  55. package/dist/useFormApi-JO7ZX1kT.js.map +0 -1
  56. package/dist/utils-DYmocaoL.js.map +0 -1
  57. package/dist/utils-Dq-MY0vG.js.map +0 -1
@@ -9,9 +9,9 @@ var neetoCist = require('@bigbinary/neeto-cist');
9
9
  var utils = require('@bigbinary/neeto-commons-frontend/utils');
10
10
  var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
11
11
  var ramda = require('ramda');
12
- var useFormApi = require('../useFormApi-JO7ZX1kT.js');
13
- var constants$1 = require('../constants-CN0KQk0z.js');
14
- var constants = require('../constants-DWy8qlgB.js');
12
+ var constants = require('../constants-CkGU4abB.js');
13
+ var constants$2 = require('../constants-CN0KQk0z.js');
14
+ var constants$1 = require('../constants-CIKOBOUZ.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');
@@ -19,16 +19,16 @@ var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
19
19
  var HelpPopover = require('@bigbinary/neeto-molecules/HelpPopover');
20
20
  var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
21
21
  var reactI18next = require('react-i18next');
22
- var buildForm = require('../buildForm-ZqO8kJoo.js');
22
+ var buildForm = require('../buildForm-nKLcTFON.js');
23
23
  var shallow = require('zustand/shallow');
24
24
  var Alert = require('@bigbinary/neetoui/Alert');
25
- var index = require('../index-2caW4Cx0.js');
26
25
  var jsxRuntime = require('react/jsx-runtime');
27
26
  var Typography = require('@bigbinary/neetoui/Typography');
28
27
  var Modal = require('@bigbinary/neetoui/Modal');
29
28
  var MoreDropdown = require('@bigbinary/neeto-molecules/MoreDropdown');
30
29
  var Dropdown = require('@bigbinary/neetoui/Dropdown');
31
30
  var Tooltip = require('@bigbinary/neetoui/Tooltip');
31
+ var index = require('../index-qEhecRV2.js');
32
32
  var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
33
33
  var i18next = require('i18next');
34
34
  var uuid = require('uuid');
@@ -99,12 +99,12 @@ var DeleteAlert = function DeleteAlert(_ref) {
99
99
  selectedLanguage = _useBuildFormStore.selectedLanguage;
100
100
  var renderQuestionLabel = function renderQuestionLabel() {
101
101
  var questionKind = selectedQuestion.kind;
102
- var independentLabel = constants.INDEPENDENT_LABELS_MAP[questionKind];
102
+ var independentLabel = constants$1.INDEPENDENT_LABELS_MAP[questionKind];
103
103
  if (neetoCist.isPresent(independentLabel)) return independentLabel;
104
- var questionLabel = index.fieldWithFallback(selectedQuestion, "label");
104
+ var questionLabel = constants$1.buildDisplayLabel(selectedQuestion);
105
105
  return neetoCist.truncate(questionLabel, 40);
106
106
  };
107
- var _useDeleteQuestion = useFormApi.useDeleteQuestion(selectedQuestion === null || selectedQuestion === void 0 ? void 0 : selectedQuestion.formId, selectedLanguage, {
107
+ var _useDeleteQuestion = constants.useDeleteQuestion(selectedQuestion === null || selectedQuestion === void 0 ? void 0 : selectedQuestion.formId, selectedLanguage, {
108
108
  onSuccess: function onSuccess() {
109
109
  utils.showThumbsUpToastr();
110
110
  onClose();
@@ -301,14 +301,12 @@ var Card = function Card(_ref) {
301
301
  allQuestionKinds: allQuestionKinds,
302
302
  item: question
303
303
  }),
304
- kind = _getActiveKindDetails.kind,
305
304
  isSingular = _getActiveKindDetails.isSingular;
306
- var label = index.fieldWithFallback(question, "label");
307
- var questionLabel = constants.isRichTextQuestion(kind) ? constants.htmlToPlainText(label) : label;
305
+ var questionLabel = constants$1.buildDisplayLabel(question);
308
306
  React.useEffect(function () {
309
307
  var element = questionLabelRef.current;
310
308
  if (neetoCist.isNotPresent(element)) return;
311
- setIsTooltipEnabled(constants.isElementOverflowing(element));
309
+ setIsTooltipEnabled(constants$1.isElementOverflowing(element));
312
310
  }, [questionLabel]);
313
311
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
314
312
  "data-cy": "neeto-form-engine-".concat(neetoCist.slugify(questionLabel)),
@@ -320,7 +318,7 @@ var Card = function Card(_ref) {
320
318
  },
321
319
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
322
320
  className: "flex min-w-0 flex-grow items-center gap-1",
323
- children: [/*#__PURE__*/jsxRuntime.jsx(constants.Drag, {
321
+ children: [/*#__PURE__*/jsxRuntime.jsx(constants$1.Drag, {
324
322
  className: "neeto-ui-text-gray-600 flex-shrink-0"
325
323
  }), /*#__PURE__*/jsxRuntime.jsx(Tooltip, {
326
324
  content: questionLabel,
@@ -367,8 +365,8 @@ var Card = function Card(_ref) {
367
365
  });
368
366
  };
369
367
 
370
- 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; }
371
- 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; }
368
+ 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; }
369
+ 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; }
372
370
  var Questions = function Questions(_ref) {
373
371
  var questions = _ref.questions,
374
372
  isDeletable = _ref.isDeletable,
@@ -385,7 +383,7 @@ var Questions = function Questions(_ref) {
385
383
  var droppableProps = _ref2.droppableProps,
386
384
  placeholder = _ref2.placeholder,
387
385
  innerRef = _ref2.innerRef;
388
- return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread$e(_objectSpread$e({}, droppableProps), {}, {
386
+ return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread$g(_objectSpread$g({}, droppableProps), {}, {
389
387
  className: "space-y-2",
390
388
  ref: innerRef,
391
389
  children: [questions.map(function (question, index) {
@@ -398,7 +396,7 @@ var Questions = function Questions(_ref) {
398
396
  var draggableProps = _ref3.draggableProps,
399
397
  dragHandleProps = _ref3.dragHandleProps,
400
398
  innerRef = _ref3.innerRef;
401
- return /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread$e(_objectSpread$e(_objectSpread$e({}, draggableProps), dragHandleProps), {}, {
399
+ return /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread$g(_objectSpread$g(_objectSpread$g({}, draggableProps), dragHandleProps), {}, {
402
400
  ref: innerRef,
403
401
  children: /*#__PURE__*/jsxRuntime.jsx(Card, {
404
402
  allQuestionKinds: allQuestionKinds,
@@ -430,16 +428,16 @@ var arrayHelpers = {
430
428
  moveItem: moveItem
431
429
  };
432
430
 
433
- 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; }
434
- 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; }
431
+ 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; }
432
+ 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; }
435
433
  var isChoiceQuestion = function isChoiceQuestion(question) {
436
- return ramda.includes(question === null || question === void 0 ? void 0 : question.kind, constants.SELECTABLE_KINDS);
434
+ return ramda.includes(question === null || question === void 0 ? void 0 : question.kind, constants$1.SELECTABLE_KINDS);
437
435
  };
438
436
  var underscoredWithoutSpecialCharacters = function underscoredWithoutSpecialCharacters(string) {
439
437
  return string.toLowerCase().replace(/[\s-]/g, "_").replace(/[\W]/gi, "").replace(/_+/g, "_").replace(/^_+|_+$/, "");
440
438
  };
441
439
  var addSuffixForReservedFieldCode = function addSuffixForReservedFieldCode(fieldCode) {
442
- return constants.RESERVED_FIELD_CODES.includes(fieldCode) ? "".concat(fieldCode, "_field") : fieldCode;
440
+ return constants$1.RESERVED_FIELD_CODES.includes(fieldCode) ? "".concat(fieldCode, "_field") : fieldCode;
443
441
  };
444
442
  var getUniqueNumbersFromExistingFieldCodes = function getUniqueNumbersFromExistingFieldCodes(prefix, questions) {
445
443
  return questions.filter(function (question) {
@@ -450,7 +448,7 @@ var getUniqueNumbersFromExistingFieldCodes = function getUniqueNumbersFromExisti
450
448
  };
451
449
  var generateFieldCodePrefix = function generateFieldCodePrefix(label, kind) {
452
450
  var prefix;
453
- if (constants.NON_BASIC_LATIN_CHARACTERS_REGEX.test(label) || ramda.isEmpty(label)) {
451
+ if (index.isNameQuestion(kind) || constants$1.NON_BASIC_LATIN_CHARACTERS_REGEX.test(label) || ramda.isEmpty(label)) {
454
452
  prefix = kind;
455
453
  } else {
456
454
  var sanitizedLabel = underscoredWithoutSpecialCharacters(label).slice(0, 30);
@@ -458,12 +456,18 @@ var generateFieldCodePrefix = function generateFieldCodePrefix(label, kind) {
458
456
  }
459
457
  return addSuffixForReservedFieldCode(prefix) || "";
460
458
  };
459
+ var renameKey = ramda.curry(function (oldKey, newKey, obj) {
460
+ return ramda.assoc(newKey, ramda.prop(oldKey, obj), ramda.dissoc(oldKey, obj));
461
+ });
461
462
  var modifyDefaultValues = function modifyDefaultValues(_ref) {
462
463
  var values = _ref.values,
463
464
  kind = _ref.kind,
464
465
  selectedLanguage = _ref.selectedLanguage,
465
466
  isUsingDefaultQuestionKinds = _ref.isUsingDefaultQuestionKinds;
466
- if (!ramda.includes(kind, constants.SELECTABLE_KINDS) || constants.isDefaultLanguage(selectedLanguage) || !isUsingDefaultQuestionKinds) {
467
+ if (index.isNameQuestion(kind)) {
468
+ return renameKey(constants$1.LABEL_FIELDS.DEFAULT, constants$1.LABEL_FIELDS.FULL_NAME, values);
469
+ }
470
+ if (!ramda.includes(kind, constants$1.SELECTABLE_KINDS) || constants$1.isDefaultLanguage(selectedLanguage) || !isUsingDefaultQuestionKinds) {
467
471
  return values;
468
472
  }
469
473
  return ramda.evolve({
@@ -507,7 +511,7 @@ var handleFieldDragEnd = function handleFieldDragEnd(_ref4) {
507
511
  var nextItems = _toConsumableArray(items);
508
512
  arrayHelpers.moveItem(nextItems, source.index, destination.index);
509
513
  var orderedItems = nextItems.map(function (item, index) {
510
- return _objectSpread$d(_objectSpread$d({}, item), {}, {
514
+ return _objectSpread$f(_objectSpread$f({}, item), {}, {
511
515
  displayOrder: index
512
516
  });
513
517
  });
@@ -529,7 +533,7 @@ var createFieldData = function createFieldData(_ref5) {
529
533
  selectedLanguage: selectedLanguage,
530
534
  isUsingDefaultQuestionKinds: isUsingDefaultQuestionKinds
531
535
  });
532
- return _objectSpread$d(_objectSpread$d({}, modifiedDefaultValues), {}, {
536
+ return _objectSpread$f(_objectSpread$f({}, modifiedDefaultValues), {}, {
533
537
  metadata: metadata,
534
538
  isRequired: isRequired,
535
539
  kind: type,
@@ -554,10 +558,10 @@ var duplicateFieldData = function duplicateFieldData(_ref6) {
554
558
  var label = index.fieldWithFallback(item, "label");
555
559
  var defaultAttributeNames = ramda.keys(questionKind.defaults || {});
556
560
  var defaultAttributes = ramda.pick(defaultAttributeNames, item);
557
- var newQuestionLabel = constants.isRichTextQuestion(kind) ? label : i18next.t("neetoForm.common.clonedElementLabel", {
561
+ var newQuestionLabel = constants$1.isRichTextQuestion(kind) ? label : i18next.t("neetoForm.common.clonedElementLabel", {
558
562
  label: label
559
563
  });
560
- return _objectSpread$d(_objectSpread$d({}, defaultAttributes), {}, {
564
+ return _objectSpread$f(_objectSpread$f({}, defaultAttributes), {}, {
561
565
  isRequired: isRequired,
562
566
  kind: kind,
563
567
  label: newQuestionLabel,
@@ -579,7 +583,7 @@ var getAvailableQuestionKinds = function getAvailableQuestionKinds(_ref7) {
579
583
  if (ramda.isEmpty(activeQuestions)) return allQuestionKinds;
580
584
  return ramda.reject(function (kind) {
581
585
  var isSingularKind = kind.isSingular;
582
- return constants.isAutoGeneratedQuestion(kind.type) || isSingularKind && isKindAlreadyActive({
586
+ return constants$1.isAutoGeneratedQuestion(kind.type) || isSingularKind && isKindAlreadyActive({
583
587
  activeQuestions: activeQuestions,
584
588
  kind: kind
585
589
  });
@@ -593,14 +597,14 @@ var AddFirstQuestion = function AddFirstQuestion(_ref) {
593
597
  disabledAddButtonTooltipProps = _ref.disabledAddButtonTooltipProps;
594
598
  var _useTranslation = reactI18next.useTranslation(),
595
599
  t = _useTranslation.t;
596
- var tooltipProps = constants.buildDisabledAddButtonTooltipProps(isDisabled, disabledAddButtonTooltipProps);
600
+ var tooltipProps = constants$1.buildDisabledAddButtonTooltipProps(isDisabled, disabledAddButtonTooltipProps);
597
601
  return /*#__PURE__*/jsxRuntime.jsx("div", {
598
602
  className: "flex h-full flex-col items-center justify-center py-8",
599
603
  children: /*#__PURE__*/jsxRuntime.jsx(NoData, {
600
604
  showTooltipWhenButtonDisabled: true,
601
605
  className: "min-h-80",
602
606
  title: t("neetoForm.questions.common.noData"),
603
- primaryButtonProps: constants.buildAddQuestionButtonProps(onAdd, isDisabled, tooltipProps)
607
+ primaryButtonProps: constants$1.buildAddQuestionButtonProps(onAdd, isDisabled, tooltipProps)
604
608
  })
605
609
  });
606
610
  };
@@ -620,7 +624,7 @@ var NAME = constants.QUESTION_TYPES.NAME,
620
624
  FILE_UPLOAD$1 = constants.QUESTION_TYPES.FILE_UPLOAD,
621
625
  CAPTCHA$1 = constants.QUESTION_TYPES.CAPTCHA,
622
626
  SMS_REMINDER = constants.QUESTION_TYPES.SMS_REMINDER;
623
- var QUESTIONS_WITH_ADDITIONAL_DATA = [].concat(_toConsumableArray(constants.SELECTABLE_KINDS), [STAR_RATING$1, RATING$1, FILE_UPLOAD$1, CAPTCHA$1, EMAIL$1]);
627
+ var QUESTIONS_WITH_ADDITIONAL_DATA = [].concat(_toConsumableArray(constants$1.SELECTABLE_KINDS), [STAR_RATING$1, RATING$1, FILE_UPLOAD$1, CAPTCHA$1, EMAIL$1]);
624
628
  var QUESTIONS_WITH_PLACEHOLDERS = [NAME, PHONE, EMAIL$1, ADDITIONAL_GUESTS, TEXT, TEXTAREA, RICH_TEXT, INTEGER, DECIMAL, DATE, SMS_REMINDER];
625
629
  var DEFAULT_PLACEHOLDERS = {
626
630
  CHECKBOX: i18next.t("neetoForm.questions.common.questionFields.field.labelExample", {
@@ -636,13 +640,14 @@ var DEFAULT_PLACEHOLDERS = {
636
640
  var INITIAL_VALUES = {
637
641
  kind: "",
638
642
  label: "",
639
- fieldCode: ""
643
+ fieldCode: "",
644
+ isSplitMode: false
640
645
  };
641
646
  var VALID_FIELD_CODE_REGEX = /^[a-z0-9]+(_[a-z0-9]+)*$/;
642
647
 
643
648
  var _excluded$8 = ["label", "name"];
644
- 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; }
645
- 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; }
649
+ 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; }
650
+ 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; }
646
651
  var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
647
652
  var label = _ref.label,
648
653
  name = _ref.name,
@@ -661,7 +666,7 @@ var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
661
666
  var end = element.value.length;
662
667
  element.setSelectionRange(end, end);
663
668
  };
664
- return /*#__PURE__*/jsxRuntime.jsx(Textarea, _objectSpread$c({
669
+ return /*#__PURE__*/jsxRuntime.jsx(Textarea, _objectSpread$e({
665
670
  label: label,
666
671
  name: name,
667
672
  className: "neeto-form-nano-adaptive-input",
@@ -675,6 +680,132 @@ var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
675
680
  }, otherProps));
676
681
  };
677
682
 
683
+ 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; }
684
+ 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; }
685
+ var LabelWithPlaceholder = function LabelWithPlaceholder(_ref) {
686
+ var kind = _ref.kind,
687
+ isLabelDisabled = _ref.isLabelDisabled,
688
+ handleLabelChange = _ref.handleLabelChange,
689
+ _ref$labelProps = _ref.labelProps,
690
+ labelProps = _ref$labelProps === void 0 ? {} : _ref$labelProps,
691
+ _ref$placeholderProps = _ref.placeholderProps,
692
+ placeholderProps = _ref$placeholderProps === void 0 ? {} : _ref$placeholderProps;
693
+ var _useTranslation = reactI18next.useTranslation(),
694
+ t = _useTranslation.t;
695
+ var shouldShowPlaceholder = ramda.includes(kind, QUESTIONS_WITH_PLACEHOLDERS);
696
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
697
+ className: "space-y-4",
698
+ children: [/*#__PURE__*/jsxRuntime.jsx(FormikAdaptiveInput, _objectSpread$d({
699
+ required: true,
700
+ disabled: isLabelDisabled,
701
+ label: t("neetoForm.questions.common.questionFields.field.question"),
702
+ name: "label",
703
+ placeholder: DEFAULT_PLACEHOLDERS[kind],
704
+ onChange: utils.withEventTargetValue(handleLabelChange)
705
+ }, labelProps)), shouldShowPlaceholder && /*#__PURE__*/jsxRuntime.jsx(FormikAdaptiveInput, _objectSpread$d({
706
+ className: "neeto-form-nano-placeholder-input neeto-form-nano-placeholder-input-".concat(kind),
707
+ name: "placeholder",
708
+ label: t("neetoForm.questions.common.questionFields.field.placeholder")
709
+ }, placeholderProps))]
710
+ });
711
+ };
712
+
713
+ 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; }
714
+ 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; }
715
+ var Name = function Name(_ref) {
716
+ var isLabelDisabled = _ref.isLabelDisabled,
717
+ _handleLabelChange = _ref.handleLabelChange;
718
+ var _useFormikContext = formik.useFormikContext(),
719
+ _useFormikContext$val = _useFormikContext.values.isSplitMode,
720
+ isSplitMode = _useFormikContext$val === void 0 ? false : _useFormikContext$val;
721
+ var _useTranslation = reactI18next.useTranslation(),
722
+ t = _useTranslation.t;
723
+ var usesCustomSubmissionComponent = buildForm.useBuildFormStore(ramda.path(["formState", "usesCustomSubmissionComponent"]));
724
+ var commonProps = {
725
+ kind: constants.QUESTION_TYPES.NAME,
726
+ isLabelDisabled: isLabelDisabled
727
+ };
728
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
729
+ className: "space-y-4",
730
+ children: [!usesCustomSubmissionComponent && /*#__PURE__*/jsxRuntime.jsx(Switch, {
731
+ label: t("neetoForm.common.splitAsFirstAndLastNames"),
732
+ name: "isSplitMode"
733
+ }), isSplitMode && !usesCustomSubmissionComponent ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
734
+ children: [/*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, _objectSpread$c(_objectSpread$c({}, commonProps), {}, {
735
+ handleLabelChange: function handleLabelChange(value) {
736
+ return _handleLabelChange(value, constants$1.LABEL_FIELDS.FIRST_NAME);
737
+ },
738
+ labelProps: {
739
+ label: t("neetoForm.questions.common.questionFields.field.firstNameQuestion"),
740
+ name: constants$1.LABEL_FIELDS.FIRST_NAME
741
+ },
742
+ placeholderProps: {
743
+ label: t("neetoForm.questions.common.questionFields.field.firstNamePlaceholder"),
744
+ name: "firstNamePlaceholder"
745
+ }
746
+ })), /*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, _objectSpread$c(_objectSpread$c({}, commonProps), {}, {
747
+ handleLabelChange: function handleLabelChange(value) {
748
+ return _handleLabelChange(value, constants$1.LABEL_FIELDS.LAST_NAME);
749
+ },
750
+ labelProps: {
751
+ label: t("neetoForm.questions.common.questionFields.field.lastNameQuestion"),
752
+ name: constants$1.LABEL_FIELDS.LAST_NAME
753
+ },
754
+ placeholderProps: {
755
+ label: t("neetoForm.questions.common.questionFields.field.lastNamePlaceholder"),
756
+ name: "lastNamePlaceholder"
757
+ }
758
+ }))]
759
+ }) : /*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, _objectSpread$c(_objectSpread$c({}, commonProps), {}, {
760
+ labelProps: {
761
+ name: constants$1.LABEL_FIELDS.FULL_NAME
762
+ },
763
+ placeholderProps: {
764
+ name: "fullNamePlaceholder"
765
+ },
766
+ handleLabelChange: function handleLabelChange(value) {
767
+ return _handleLabelChange(value, constants$1.LABEL_FIELDS.FULL_NAME);
768
+ }
769
+ }))]
770
+ });
771
+ };
772
+
773
+ var Properties = function Properties(_ref) {
774
+ var kind = _ref.kind,
775
+ isLabelDisabled = _ref.isLabelDisabled,
776
+ handleLabelChange = _ref.handleLabelChange,
777
+ questionProps = _ref.questionProps;
778
+ var _useBuildFormStore = buildForm.useBuildFormStore(function (store) {
779
+ var _store$formState, _store$formState2;
780
+ return {
781
+ enableDomainWhitelisting: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["enableDomainWhitelisting"],
782
+ enableDomainBlacklisting: (_store$formState2 = store["formState"]) === null || _store$formState2 === void 0 ? void 0 : _store$formState2["enableDomainBlacklisting"]
783
+ };
784
+ }, shallow.shallow),
785
+ enableDomainWhitelisting = _useBuildFormStore.enableDomainWhitelisting,
786
+ enableDomainBlacklisting = _useBuildFormStore.enableDomainBlacklisting;
787
+ var hasAdditionalData = ramda.includes(kind, QUESTIONS_WITH_ADDITIONAL_DATA);
788
+ if (index.isNameQuestion(kind)) {
789
+ return /*#__PURE__*/jsxRuntime.jsx(Name, {
790
+ handleLabelChange: handleLabelChange,
791
+ isLabelDisabled: isLabelDisabled
792
+ });
793
+ }
794
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
795
+ className: "space-y-4",
796
+ children: [/*#__PURE__*/jsxRuntime.jsx(LabelWithPlaceholder, {
797
+ handleLabelChange: handleLabelChange,
798
+ isLabelDisabled: isLabelDisabled,
799
+ kind: kind
800
+ }), hasAdditionalData && renderAdditionalData({
801
+ kind: kind,
802
+ questionProps: questionProps,
803
+ enableDomainWhitelisting: enableDomainWhitelisting,
804
+ enableDomainBlacklisting: enableDomainBlacklisting
805
+ })]
806
+ });
807
+ };
808
+
678
809
  var Block = function Block(_ref) {
679
810
  var title = _ref.title,
680
811
  children = _ref.children,
@@ -734,7 +865,7 @@ var useUpdateEditorContent = function useUpdateEditorContent(_ref) {
734
865
  setEditorContent(initialValue);
735
866
  setFormData(ramda.modify("richTextFieldsToReset", ramda.without([fieldCode])));
736
867
  }
737
- var _useFetchQuestions = useFormApi.useFetchQuestions({
868
+ var _useFetchQuestions = constants.useFetchQuestions({
738
869
  formId: formId,
739
870
  language: language
740
871
  }),
@@ -769,7 +900,7 @@ var Editor = function Editor() {
769
900
  var fieldName = "label";
770
901
  var _useField = formik.useField({
771
902
  name: fieldName,
772
- validate: constants.validateEditorContent(editorRef)
903
+ validate: constants$1.validateEditorContent(editorRef)
773
904
  }),
774
905
  _useField2 = _slicedToArray(_useField, 3),
775
906
  value = _useField2[0].value,
@@ -844,7 +975,7 @@ var FieldCode = function FieldCode() {
844
975
  required: true,
845
976
  label: t("neetoForm.questions.common.questionFields.field.fieldCode"),
846
977
  name: "fieldCode",
847
- rejectCharsRegex: constants.FIELD_CODES_REJECT_CHARS_REGEX,
978
+ rejectCharsRegex: constants$1.FIELD_CODES_REJECT_CHARS_REGEX,
848
979
  helpText: helpDocUrl && /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
849
980
  i18nKey: "neetoForm.questions.common.questionFields.field.fieldCodeHelpDescription",
850
981
  components: {
@@ -882,17 +1013,13 @@ var Form$1 = function Form(_ref) {
882
1013
  var hideQuestionHelpDoc = buildForm.useBuildFormStore(ramda.path(["formState", "helpDocUrls", "hideQuestion"]));
883
1014
  var readOnlyHelpDoc = buildForm.useBuildFormStore(ramda.path(["formState", "helpDocUrls", "readOnly"]));
884
1015
  var _useBuildFormStore = buildForm.useBuildFormStore(function (store) {
885
- var _store$formState, _store$formState2, _store$formState3, _store$formState4, _store$formState5;
1016
+ var _store$formState, _store$formState2, _store$formState3;
886
1017
  return {
887
- enableDomainWhitelisting: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["enableDomainWhitelisting"],
888
- enableDomainBlacklisting: (_store$formState2 = store["formState"]) === null || _store$formState2 === void 0 ? void 0 : _store$formState2["enableDomainBlacklisting"],
889
- showReadOnlySwitch: (_store$formState3 = store["formState"]) === null || _store$formState3 === void 0 ? void 0 : _store$formState3["showReadOnlySwitch"],
890
- selectedLanguage: (_store$formState4 = store["formState"]) === null || _store$formState4 === void 0 ? void 0 : _store$formState4["selectedLanguage"],
891
- isUsingDefaultQuestionKinds: (_store$formState5 = store["formState"]) === null || _store$formState5 === void 0 ? void 0 : _store$formState5["isUsingDefaultQuestionKinds"]
1018
+ showReadOnlySwitch: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["showReadOnlySwitch"],
1019
+ selectedLanguage: (_store$formState2 = store["formState"]) === null || _store$formState2 === void 0 ? void 0 : _store$formState2["selectedLanguage"],
1020
+ isUsingDefaultQuestionKinds: (_store$formState3 = store["formState"]) === null || _store$formState3 === void 0 ? void 0 : _store$formState3["isUsingDefaultQuestionKinds"]
892
1021
  };
893
1022
  }, shallow.shallow),
894
- enableDomainWhitelisting = _useBuildFormStore.enableDomainWhitelisting,
895
- enableDomainBlacklisting = _useBuildFormStore.enableDomainBlacklisting,
896
1023
  showReadOnlySwitch = _useBuildFormStore.showReadOnlySwitch,
897
1024
  selectedLanguage = _useBuildFormStore.selectedLanguage,
898
1025
  isUsingDefaultQuestionKinds = _useBuildFormStore.isUsingDefaultQuestionKinds;
@@ -912,12 +1039,10 @@ var Form$1 = function Form(_ref) {
912
1039
  questionProps = _ref2$questionProps === void 0 ? {} : _ref2$questionProps;
913
1040
  var isRequired = questionKind && isRequiredField(questionKind);
914
1041
  var isLabelDisabled = questionKind && isDisabledFieldLabel(questionKind);
915
- var isImmutable = questionKind && constants.isImmutableField(questionKind);
916
- var shouldShowPlaceholder = ramda.includes(kind, QUESTIONS_WITH_PLACEHOLDERS);
917
- var hasAdditionalData = ramda.includes(kind, QUESTIONS_WITH_ADDITIONAL_DATA);
918
- var shouldShowFieldCode = enableFieldCode && !ramda.includes(kind, constants.QUESTIONS_WITHOUT_FIELD_CODE);
919
- var shouldShowHideSwitch = !ramda.includes(kind, constants.NON_HIDEABLE_FIELDS);
920
- var shouldShowReadOnlySwitch = showReadOnlySwitch && !ramda.includes(kind, constants.NON_READ_ONLY_FIELDS);
1042
+ var isImmutable = questionKind && constants$1.isImmutableField(questionKind);
1043
+ var shouldShowFieldCode = enableFieldCode && !ramda.includes(kind, constants$1.QUESTIONS_WITHOUT_FIELD_CODE);
1044
+ var shouldShowHideSwitch = !ramda.includes(kind, constants$1.NON_HIDEABLE_FIELDS);
1045
+ var shouldShowReadOnlySwitch = showReadOnlySwitch && !ramda.includes(kind, constants$1.NON_READ_ONLY_FIELDS);
921
1046
  var isSettingsBlockVisible = !isRequired && (!isImmutable || shouldShowHideSwitch);
922
1047
  var handleKindChange = function handleKindChange(option) {
923
1048
  var data = buildQuestionData(option);
@@ -948,7 +1073,8 @@ var Form$1 = function Form(_ref) {
948
1073
  setTouched({});
949
1074
  };
950
1075
  var handleLabelChange = function handleLabelChange(label) {
951
- setFieldValue("label", label);
1076
+ var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : constants$1.LABEL_FIELDS.DEFAULT;
1077
+ setFieldValue(name, label);
952
1078
  if (isEdit) return;
953
1079
  var uniqueFieldCode = generateUniqueFieldCode({
954
1080
  questions: questions,
@@ -970,29 +1096,15 @@ var Form$1 = function Form(_ref) {
970
1096
  options: buildKindOptions(questionKinds),
971
1097
  label: t("neetoForm.questions.common.questionFields.field.questionType"),
972
1098
  onChange: handleKindChange
973
- }), constants.isRichTextQuestion(kind) ? /*#__PURE__*/jsxRuntime.jsx(Editor, {
1099
+ }), constants$1.isRichTextQuestion(kind) ? /*#__PURE__*/jsxRuntime.jsx(Editor, {
974
1100
  isLabelDisabled: isLabelDisabled
975
1101
  }) : /*#__PURE__*/jsxRuntime.jsxs("div", {
976
1102
  className: "space-y-6",
977
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
978
- className: "space-y-4",
979
- children: [/*#__PURE__*/jsxRuntime.jsx(FormikAdaptiveInput, {
980
- required: true,
981
- disabled: isLabelDisabled,
982
- name: "label",
983
- placeholder: DEFAULT_PLACEHOLDERS[kind],
984
- label: t("neetoForm.questions.common.questionFields.field.question"),
985
- onChange: utils.withEventTargetValue(handleLabelChange)
986
- }), shouldShowPlaceholder && /*#__PURE__*/jsxRuntime.jsx(FormikAdaptiveInput, {
987
- className: "neeto-form-nano-placeholder-input neeto-form-nano-placeholder-input-".concat(kind),
988
- name: "placeholder",
989
- label: t("neetoForm.questions.common.questionFields.field.placeholder")
990
- }), hasAdditionalData && renderAdditionalData({
991
- kind: kind,
992
- questionProps: questionProps,
993
- enableDomainWhitelisting: enableDomainWhitelisting,
994
- enableDomainBlacklisting: enableDomainBlacklisting
995
- })]
1103
+ children: [/*#__PURE__*/jsxRuntime.jsx(Properties, {
1104
+ handleLabelChange: handleLabelChange,
1105
+ isLabelDisabled: isLabelDisabled,
1106
+ kind: kind,
1107
+ questionProps: questionProps
996
1108
  }), isSettingsBlockVisible && /*#__PURE__*/jsxRuntime.jsxs(Block, {
997
1109
  dataCy: "settings-card",
998
1110
  title: t("neetoForm.common.settings"),
@@ -1040,22 +1152,35 @@ var richTextFieldMissingErrorMessage = function richTextFieldMissingErrorMessage
1040
1152
  field: field
1041
1153
  });
1042
1154
  };
1043
- var formValidationSchema = function formValidationSchema() {
1044
- var enableFieldCode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1155
+ var buildLabelValidationSchema = function buildLabelValidationSchema(kind, schema) {
1156
+ if (index.isNameQuestion(kind)) {
1157
+ return schema.notRequired();
1158
+ }
1159
+ return ramda.includes(kind, constants$1.RICH_TEXT_QUESTIONS) ? schema.test("required", richTextFieldMissingErrorMessage(kind), function (value) {
1160
+ return !utils$1.isEditorEmpty(value);
1161
+ }) : requiredLabelValidation(schema, i18next.t("neetoForm.questions.common.questionFields.field.question"));
1162
+ };
1163
+ var buildNameLabelValidationSchema = function buildNameLabelValidationSchema(question, schema) {
1164
+ var isFullName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1165
+ var isRequired = isFullName ? !question.isSplitMode : question.isSplitMode;
1166
+ return index.isNameQuestion(question.kind) && isRequired ? requiredLabelValidation(schema, i18next.t("neetoForm.questions.common.questionFields.field.question")) : schema.notRequired();
1167
+ };
1168
+ var stringSchema = yup__namespace.string();
1169
+ var formValidationSchema = function formValidationSchema(question) {
1170
+ var enableFieldCode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1045
1171
  return yup__namespace.object().shape({
1046
1172
  kind: yup__namespace.string().trim().required(i18next.t("neetoForm.common.fieldReq", {
1047
1173
  field: i18next.t("neetoForm.questions.common.questionFields.field.questionType")
1048
1174
  })),
1049
- label: yup__namespace.string().when("kind", function (kind, schema) {
1050
- return ramda.includes(kind, constants.RICH_TEXT_QUESTIONS) ? schema.test("required", richTextFieldMissingErrorMessage(kind), function (value) {
1051
- return !utils$1.isEditorEmpty(value);
1052
- }) : requiredLabelValidation(schema, i18next.t("neetoForm.questions.common.questionFields.field.question"));
1053
- }),
1054
- fieldCode: yup__namespace.string().trim().notOneOf(constants.RESERVED_FIELD_CODES, i18next.t("neetoForm.error.invalidFieldCode")).when("kind", function (kind, schema) {
1055
- return enableFieldCode && !ramda.includes(kind, constants.QUESTIONS_WITHOUT_FIELD_CODE) ? fieldCodeValidation(schema, i18next.t("neetoForm.questions.common.questionFields.field.fieldCode")) : schema.notRequired();
1175
+ label: yup__namespace.string().when("kind", buildLabelValidationSchema),
1176
+ fullNameLabel: buildNameLabelValidationSchema(question, stringSchema, true),
1177
+ firstNameLabel: buildNameLabelValidationSchema(question, stringSchema),
1178
+ lastNameLabel: buildNameLabelValidationSchema(question, stringSchema),
1179
+ fieldCode: yup__namespace.string().trim().notOneOf(constants$1.RESERVED_FIELD_CODES, i18next.t("neetoForm.error.invalidFieldCode")).when("kind", function (kind, schema) {
1180
+ return enableFieldCode && !ramda.includes(kind, constants$1.QUESTIONS_WITHOUT_FIELD_CODE) ? fieldCodeValidation(schema, i18next.t("neetoForm.questions.common.questionFields.field.fieldCode")) : schema.notRequired();
1056
1181
  }),
1057
1182
  optionsAttributes: yup__namespace.array().when("kind", function (kind, schema) {
1058
- return ramda.includes(kind, constants.SELECTABLE_KINDS) ? schema.of(yup__namespace.object().shape({
1183
+ return ramda.includes(kind, constants$1.SELECTABLE_KINDS) ? schema.of(yup__namespace.object().shape({
1059
1184
  label: yup__namespace.string().when("_destroy", {
1060
1185
  is: true,
1061
1186
  otherwise: requiredLabelValidation(yup__namespace.string(), i18next.t("neetoForm.questions.common.questionFields.field.option"))
@@ -1090,7 +1215,7 @@ var Add = function Add(_ref) {
1090
1215
  language = _useBuildFormStore.selectedLanguage;
1091
1216
  var _useTranslation = reactI18next.useTranslation(),
1092
1217
  t = _useTranslation.t;
1093
- var _useCreateQuestion = useFormApi.useCreateQuestion(formId, language, {
1218
+ var _useCreateQuestion = constants.useCreateQuestion(formId, language, {
1094
1219
  onSuccess: function onSuccess() {
1095
1220
  utils.showThumbsUpToastr();
1096
1221
  onClose();
@@ -1126,7 +1251,7 @@ var Add = function Add(_ref) {
1126
1251
  }), /*#__PURE__*/jsxRuntime.jsx(Form$2, {
1127
1252
  formikProps: {
1128
1253
  initialValues: INITIAL_VALUES,
1129
- validationSchema: formValidationSchema(props["enableFieldCode"]),
1254
+ validationSchema: formValidationSchema(INITIAL_VALUES, props["enableFieldCode"]),
1130
1255
  onSubmit: handleSubmit
1131
1256
  },
1132
1257
  children: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -1163,7 +1288,7 @@ var Edit = function Edit(_ref) {
1163
1288
  };
1164
1289
  }, shallow.shallow),
1165
1290
  language = _useBuildFormStore.selectedLanguage;
1166
- var _useUpdateQuestion = useFormApi.useUpdateQuestion(question === null || question === void 0 ? void 0 : question.formId, language),
1291
+ var _useUpdateQuestion = constants.useUpdateQuestion(question === null || question === void 0 ? void 0 : question.formId, language),
1167
1292
  updateQuestion = _useUpdateQuestion.mutate,
1168
1293
  isUpdating = _useUpdateQuestion.isPending;
1169
1294
  var handleSubmit = function handleSubmit(values, _ref2) {
@@ -1196,7 +1321,7 @@ var Edit = function Edit(_ref) {
1196
1321
  }), /*#__PURE__*/jsxRuntime.jsx(Form$2, {
1197
1322
  formikProps: {
1198
1323
  initialValues: question,
1199
- validationSchema: formValidationSchema(props["enableFieldCode"]),
1324
+ validationSchema: formValidationSchema(question, props["enableFieldCode"]),
1200
1325
  onSubmit: handleSubmit
1201
1326
  },
1202
1327
  children: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -1653,15 +1778,15 @@ var getAllowedFileTypes = function getAllowedFileTypes(_ref) {
1653
1778
  allowedFileTypes = _ref.allowedFileTypes;
1654
1779
  var fileTypes = buildFileTypesList(allowedFileTypes);
1655
1780
  if (isChecked) {
1656
- var fileTypesSet = new Set([].concat(_toConsumableArray(constants.FILE_TYPES_MAP[type]), _toConsumableArray(fileTypes)));
1781
+ var fileTypesSet = new Set([].concat(_toConsumableArray(constants$1.FILE_TYPES_MAP[type]), _toConsumableArray(fileTypes)));
1657
1782
  return Array.from(fileTypesSet).join(", ");
1658
1783
  }
1659
- var newFileTypes = ramda.difference(fileTypes, constants.FILE_TYPES_MAP[type]);
1784
+ var newFileTypes = ramda.difference(fileTypes, constants$1.FILE_TYPES_MAP[type]);
1660
1785
  return newFileTypes.join(", ");
1661
1786
  };
1662
1787
  var isFileTypeEnabled = function isFileTypeEnabled(type, allowedFileTypes) {
1663
1788
  var fileTypes = buildFileTypesList(allowedFileTypes);
1664
- return ramda.isEmpty(ramda.difference(constants.FILE_TYPES_MAP[type], fileTypes));
1789
+ return ramda.isEmpty(ramda.difference(constants$1.FILE_TYPES_MAP[type], fileTypes));
1665
1790
  };
1666
1791
 
1667
1792
  var FileUpload = function FileUpload() {
@@ -1697,7 +1822,7 @@ var FileUpload = function FileUpload() {
1697
1822
  children: t("neetoForm.fileUpload.fileTypes")
1698
1823
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
1699
1824
  className: "flex space-x-4",
1700
- children: constants.FILE_GROUPS.map(function (_ref2) {
1825
+ children: constants$1.FILE_GROUPS.map(function (_ref2) {
1701
1826
  var name = _ref2.name,
1702
1827
  label = _ref2.label;
1703
1828
  return /*#__PURE__*/React.createElement(FileGroup, {
@@ -1758,8 +1883,8 @@ var Options = function Options(_ref) {
1758
1883
  draggable: !isManageOptionDisabled,
1759
1884
  isAddOptionEnabled: !isAddOptionDisabled,
1760
1885
  isDeleteOptionEnabled: !isRemoveOptionDisabled,
1761
- isNewItemsPrefilled: constants.isDefaultLanguage(selectedLanguage),
1762
- minOptions: constants.MINIMUM_OPTIONS,
1886
+ isNewItemsPrefilled: constants$1.isDefaultLanguage(selectedLanguage),
1887
+ minOptions: constants$1.MINIMUM_OPTIONS,
1763
1888
  shouldResetEmptyOptionOnBlur: false,
1764
1889
  onChange: setOptionsAttributes
1765
1890
  })]
@@ -1780,7 +1905,7 @@ var Rating = function Rating() {
1780
1905
  className: "w-full",
1781
1906
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
1782
1907
  className: "flex gap-6",
1783
- children: constants.RATING_OPTIONS.map(function (_ref2) {
1908
+ children: constants$1.RATING_OPTIONS.map(function (_ref2) {
1784
1909
  var Icon = _ref2.icon,
1785
1910
  name = _ref2.name,
1786
1911
  color = _ref2.color;
@@ -1817,7 +1942,7 @@ var StarRating = function StarRating() {
1817
1942
  "data-cy": "neeto-form-engine-star-rating-min-value",
1818
1943
  label: t("neetoForm.common.start"),
1819
1944
  name: "minValue",
1820
- options: constants.STAR_RATING_MIN_VALUE_OPTIONS,
1945
+ options: constants$1.STAR_RATING_MIN_VALUE_OPTIONS,
1821
1946
  onChange: function onChange(option) {
1822
1947
  return setFieldValue("minValue", option === null || option === void 0 ? void 0 : option.value);
1823
1948
  }
@@ -1826,7 +1951,7 @@ var StarRating = function StarRating() {
1826
1951
  "data-cy": "neeto-form-engine-star-rating-max-value",
1827
1952
  label: t("neetoForm.common.end"),
1828
1953
  name: "maxValue",
1829
- options: constants.STAR_RATING_MAX_VALUE_OPTIONS,
1954
+ options: constants$1.STAR_RATING_MAX_VALUE_OPTIONS,
1830
1955
  onChange: function onChange(option) {
1831
1956
  return setFieldValue("maxValue", option === null || option === void 0 ? void 0 : option.value);
1832
1957
  }
@@ -1835,7 +1960,7 @@ var StarRating = function StarRating() {
1835
1960
  children: t("neetoForm.common.shape")
1836
1961
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
1837
1962
  className: "flex gap-2",
1838
- children: Object.entries(constants.STAR_RATING_ICONS_MAP).map(function (_ref) {
1963
+ children: Object.entries(constants$1.STAR_RATING_ICONS_MAP).map(function (_ref) {
1839
1964
  var _ref2 = _slicedToArray(_ref, 2),
1840
1965
  name = _ref2[0],
1841
1966
  IconType = _ref2[1];
@@ -1899,7 +2024,7 @@ var renderAdditionalData = function renderAdditionalData(_ref2) {
1899
2024
  }
1900
2025
  };
1901
2026
  var resolveActionComponent = function resolveActionComponent(action) {
1902
- return ramda.equals(action, constants.QUESTION_ACTIONS.ADD) ? Add : Edit;
2027
+ return ramda.equals(action, constants$1.QUESTION_ACTIONS.ADD) ? Add : Edit;
1903
2028
  };
1904
2029
  var getQuestionKind = function getQuestionKind(questionKinds, pattern) {
1905
2030
  var questionKind = neetoCist.findBy(pattern, questionKinds);
@@ -1983,15 +2108,15 @@ var AddQuestion = function AddQuestion(_ref) {
1983
2108
  var onAdd = _ref.onAdd,
1984
2109
  disabledAddButtonTooltipProps = _ref.disabledAddButtonTooltipProps,
1985
2110
  isDisabled = _ref.isDisabled;
1986
- var tooltipProps = constants.buildDisabledAddButtonTooltipProps(isDisabled, disabledAddButtonTooltipProps);
2111
+ var tooltipProps = constants$1.buildDisabledAddButtonTooltipProps(isDisabled, disabledAddButtonTooltipProps);
1987
2112
  return /*#__PURE__*/jsxRuntime.jsx(Tooltip, _objectSpread$2(_objectSpread$2({}, tooltipProps), {}, {
1988
2113
  children: /*#__PURE__*/jsxRuntime.jsx("span", {
1989
- children: /*#__PURE__*/jsxRuntime.jsx(Button, _objectSpread$2({}, constants.buildAddQuestionButtonProps(onAdd, isDisabled)))
2114
+ children: /*#__PURE__*/jsxRuntime.jsx(Button, _objectSpread$2({}, constants$1.buildAddQuestionButtonProps(onAdd, isDisabled)))
1990
2115
  })
1991
2116
  }));
1992
2117
  };
1993
2118
 
1994
- 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", "showReadOnlySwitch", "buildRequestArgs", "enableDomainBlacklisting", "enableDomainWhitelisting", "helpDocUrls", "hostSpecificData", "questionsHelpProps", "isUsingDefaultQuestionKinds"];
2119
+ 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", "showReadOnlySwitch", "buildRequestArgs", "enableDomainBlacklisting", "enableDomainWhitelisting", "helpDocUrls", "hostSpecificData", "questionsHelpProps", "isUsingDefaultQuestionKinds", "usesCustomSubmissionComponent"];
1995
2120
  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; }
1996
2121
  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; }
1997
2122
  var Form = function Form(_ref) {
@@ -2026,6 +2151,7 @@ var Form = function Form(_ref) {
2026
2151
  hostSpecificData = _ref.hostSpecificData,
2027
2152
  questionsHelpProps = _ref.questionsHelpProps,
2028
2153
  isUsingDefaultQuestionKinds = _ref.isUsingDefaultQuestionKinds,
2154
+ usesCustomSubmissionComponent = _ref.usesCustomSubmissionComponent,
2029
2155
  formDomProps = _objectWithoutProperties(_ref, _excluded);
2030
2156
  var containerRef = React.useRef();
2031
2157
  var _useTranslation = reactI18next.useTranslation(),
@@ -2060,7 +2186,7 @@ var Form = function Form(_ref) {
2060
2186
  submitForm = formikContext.submitForm,
2061
2187
  resetForm = formikContext.resetForm;
2062
2188
  var setFormData = buildForm.useBuildFormStore(ramda.prop("setFormData"));
2063
- var _useCreateQuestion = useFormApi.useCreateQuestion(formId, selectedLanguage, {
2189
+ var _useCreateQuestion = constants.useCreateQuestion(formId, selectedLanguage, {
2064
2190
  onSuccess: utils.showThumbsUpToastr
2065
2191
  }),
2066
2192
  createQuestion = _useCreateQuestion.mutate;
@@ -2081,19 +2207,20 @@ var Form = function Form(_ref) {
2081
2207
  enableDomainBlacklisting: enableDomainBlacklisting,
2082
2208
  enableDomainWhitelisting: enableDomainWhitelisting,
2083
2209
  isUsingDefaultQuestionKinds: isUsingDefaultQuestionKinds,
2084
- showReadOnlySwitch: showReadOnlySwitch
2210
+ showReadOnlySwitch: showReadOnlySwitch,
2211
+ usesCustomSubmissionComponent: usesCustomSubmissionComponent
2085
2212
  });
2086
- }, [formId, isFormEnabled, savedTitle, setFormData, values, dirty, isSubmitting, isValid, errors, submitForm, resetForm, selectedLanguage, helpDocUrls, enableDomainBlacklisting, enableDomainWhitelisting, isUsingDefaultQuestionKinds, showReadOnlySwitch]);
2213
+ }, [formId, isFormEnabled, savedTitle, setFormData, values, dirty, isSubmitting, isValid, errors, submitForm, resetForm, selectedLanguage, helpDocUrls, enableDomainBlacklisting, enableDomainWhitelisting, isUsingDefaultQuestionKinds, showReadOnlySwitch, usesCustomSubmissionComponent]);
2087
2214
  var questions = values.questions;
2088
2215
  var handleSelect = function handleSelect(question) {
2089
2216
  setSelectedQuestion(question);
2090
2217
  };
2091
2218
  var handleAdd = function handleAdd() {
2092
- setSelectedAction(constants.QUESTION_ACTIONS.ADD);
2219
+ setSelectedAction(constants$1.QUESTION_ACTIONS.ADD);
2093
2220
  setIsManageQuestionPaneOpen(true);
2094
2221
  };
2095
2222
  var handleEdit = function handleEdit() {
2096
- setSelectedAction(constants.QUESTION_ACTIONS.EDIT);
2223
+ setSelectedAction(constants$1.QUESTION_ACTIONS.EDIT);
2097
2224
  setIsManageQuestionPaneOpen(true);
2098
2225
  };
2099
2226
  var handleClone = function handleClone() {
@@ -2148,7 +2275,7 @@ var Form = function Form(_ref) {
2148
2275
  onLanguageChange(code);
2149
2276
  };
2150
2277
  var richTextQuestions = neetoCist.filterBy({
2151
- kind: ramda.includes(ramda.__, constants.RICH_TEXT_QUESTIONS)
2278
+ kind: ramda.includes(ramda.__, constants$1.RICH_TEXT_QUESTIONS)
2152
2279
  }, questions);
2153
2280
  var resetFormData = function resetFormData() {
2154
2281
  resetForm();
@@ -2275,7 +2402,7 @@ var BuildForm = function BuildForm(_ref) {
2275
2402
  _ref$isKindAlreadyAct = _ref.isKindAlreadyActive,
2276
2403
  isKindAlreadyActive = _ref$isKindAlreadyAct === void 0 ? isQuestionKindAlreadyActive : _ref$isKindAlreadyAct,
2277
2404
  _ref$getActiveKindDet = _ref.getActiveKindDetails,
2278
- getActiveKindDetails = _ref$getActiveKindDet === void 0 ? constants.getActiveQuestionKindDetails : _ref$getActiveKindDet,
2405
+ getActiveKindDetails = _ref$getActiveKindDet === void 0 ? constants$1.getActiveQuestionKindDetails : _ref$getActiveKindDet,
2279
2406
  isQuestionDeletable = _ref.isQuestionDeletable,
2280
2407
  isFieldRequired = _ref.isFieldRequired,
2281
2408
  isFieldLabelDisabled = _ref.isFieldLabelDisabled,
@@ -2289,7 +2416,7 @@ var BuildForm = function BuildForm(_ref) {
2289
2416
  _ref$enableFieldCode = _ref.enableFieldCode,
2290
2417
  enableFieldCode = _ref$enableFieldCode === void 0 ? false : _ref$enableFieldCode,
2291
2418
  _ref$availableLanguag = _ref.availableLanguages,
2292
- availableLanguages = _ref$availableLanguag === void 0 ? constants.DEFAULT_AVAILABLE_LANGUAGES : _ref$availableLanguag,
2419
+ availableLanguages = _ref$availableLanguag === void 0 ? constants$1.DEFAULT_AVAILABLE_LANGUAGES : _ref$availableLanguag,
2293
2420
  formDescription = _ref.formDescription,
2294
2421
  _ref$formTitle = _ref.formTitle,
2295
2422
  formTitle = _ref$formTitle === void 0 ? "" : _ref$formTitle,
@@ -2311,21 +2438,23 @@ var BuildForm = function BuildForm(_ref) {
2311
2438
  _ref$hostSpecificData = _ref.hostSpecificData,
2312
2439
  hostSpecificData = _ref$hostSpecificData === void 0 ? {} : _ref$hostSpecificData,
2313
2440
  _ref$showReadOnlySwit = _ref.showReadOnlySwitch,
2314
- showReadOnlySwitch = _ref$showReadOnlySwit === void 0 ? false : _ref$showReadOnlySwit;
2441
+ showReadOnlySwitch = _ref$showReadOnlySwit === void 0 ? false : _ref$showReadOnlySwit,
2442
+ _ref$usesCustomSubmis = _ref.usesCustomSubmissionComponent,
2443
+ usesCustomSubmissionComponent = _ref$usesCustomSubmis === void 0 ? false : _ref$usesCustomSubmis;
2315
2444
  var queryClient = reactQuery.useQueryClient();
2316
- var _useReorderQuestions = useFormApi.useReorderQuestions(id, {
2445
+ var _useReorderQuestions = constants.useReorderQuestions(id, {
2317
2446
  onSuccess: utils.showThumbsUpToastr
2318
2447
  }),
2319
2448
  reorderQuestions = _useReorderQuestions.mutate,
2320
2449
  isReordering = _useReorderQuestions.isPending;
2321
- var _useFetchQuestions = useFormApi.useFetchQuestions({
2450
+ var _useFetchQuestions = constants.useFetchQuestions({
2322
2451
  formId: id,
2323
2452
  language: selectedLanguage
2324
2453
  }),
2325
2454
  data = _useFetchQuestions.data,
2326
2455
  isLoading = _useFetchQuestions.isLoading,
2327
2456
  isQuestionsPending = _useFetchQuestions.isPending;
2328
- var _ref2 = data || constants.QUESTIONS_INITIAL_VALUE,
2457
+ var _ref2 = data || constants$1.QUESTIONS_INITIAL_VALUE,
2329
2458
  isFormEnabled = _ref2.enabled,
2330
2459
  savedTitle = _ref2.title,
2331
2460
  questions = _ref2.questions,
@@ -2346,7 +2475,7 @@ var BuildForm = function BuildForm(_ref) {
2346
2475
  var setSubmitting = _ref4.setSubmitting;
2347
2476
  var payload = {
2348
2477
  neetoFormQuestions: {
2349
- questions: constants.buildReorderPayload(questions)
2478
+ questions: constants$1.buildReorderPayload(questions)
2350
2479
  }
2351
2480
  };
2352
2481
  reorderQuestions(payload, {
@@ -2356,10 +2485,10 @@ var BuildForm = function BuildForm(_ref) {
2356
2485
  });
2357
2486
  };
2358
2487
  var onValueChange = function onValueChange(questions) {
2359
- var _queryClient$getQuery = queryClient.getQueryState([useFormApi.QUERY_KEYS.QUESTIONS, id, selectedLanguage]),
2488
+ var _queryClient$getQuery = queryClient.getQueryState([constants.QUERY_KEYS.QUESTIONS, id, selectedLanguage]),
2360
2489
  dataUpdateCount = _queryClient$getQuery.dataUpdateCount;
2361
2490
  if (dataUpdateCount > 0) {
2362
- queryClient.setQueryData([useFormApi.QUERY_KEYS.QUESTIONS, "preview/".concat(id), selectedLanguage], ramda.assoc("questions", questions));
2491
+ queryClient.setQueryData([constants.QUERY_KEYS.QUESTIONS, "preview/".concat(id), selectedLanguage], ramda.assoc("questions", questions));
2363
2492
  }
2364
2493
  };
2365
2494
  var isDeletable = isQuestionDeletable !== null && isQuestionDeletable !== void 0 ? isQuestionDeletable : function (question) {
@@ -2367,14 +2496,14 @@ var BuildForm = function BuildForm(_ref) {
2367
2496
  };
2368
2497
  var isRequiredField = isFieldRequired !== null && isFieldRequired !== void 0 ? isFieldRequired : function (_ref5) {
2369
2498
  var kind = _ref5.kind;
2370
- return ramda.concat(constants.MANDATORY_KINDS, requiredFields).includes(kind);
2499
+ return ramda.concat(constants$1.MANDATORY_KINDS, requiredFields).includes(kind);
2371
2500
  };
2372
2501
  var isDisabledFieldLabel = function isDisabledFieldLabel(field) {
2373
- return constants.isImmutableField(field) || (isFieldLabelDisabled !== null && isFieldLabelDisabled !== void 0 ? isFieldLabelDisabled : ramda.F)(field);
2502
+ return constants$1.isImmutableField(field) || (isFieldLabelDisabled !== null && isFieldLabelDisabled !== void 0 ? isFieldLabelDisabled : ramda.F)(field);
2374
2503
  };
2375
- var defaultQuestionKinds = allowAdditionalGuests ? constants.QUESTION_KINDS : neetoCist.removeBy({
2376
- type: constants$1.QUESTION_KIND.ADDITIONAL_GUESTS.value
2377
- }, constants.QUESTION_KINDS);
2504
+ var defaultQuestionKinds = allowAdditionalGuests ? constants$1.QUESTION_KINDS : neetoCist.removeBy({
2505
+ type: constants$2.QUESTION_KIND.ADDITIONAL_GUESTS.value
2506
+ }, constants$1.QUESTION_KINDS);
2378
2507
  var isUsingDefaultQuestionKinds = ramda.isNil(questionKinds);
2379
2508
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
2380
2509
  className: classnames("neeto-form-nano-form-outer-wrapper relative", className),
@@ -2417,7 +2546,8 @@ var BuildForm = function BuildForm(_ref) {
2417
2546
  selectedLanguage: selectedLanguage,
2418
2547
  showActionBlock: showActionBlock,
2419
2548
  showReadOnlySwitch: showReadOnlySwitch,
2420
- submitButtonProps: submitButtonProps
2549
+ submitButtonProps: submitButtonProps,
2550
+ usesCustomSubmissionComponent: usesCustomSubmissionComponent
2421
2551
  })), {}, {
2422
2552
  formId: id,
2423
2553
  questionKinds: isUsingDefaultQuestionKinds ? defaultQuestionKinds : questionKinds,