@bigbinary/neeto-form-frontend 2.1.1 → 2.2.0-beta2
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/index.cjs.js +179 -137
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +178 -137
- package/dist/index.js.map +1 -1
- package/dist/main.css +1 -1
- package/dist/main.css.map +1 -1
- package/package.json +7 -7
- package/types.d.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import * as React$2 from 'react';
|
|
3
3
|
import React__default, { useState, createElement, useRef, useEffect, forwardRef, useImperativeHandle, Fragment as Fragment$1, useReducer, useCallback, useMemo, createContext, useContext, useLayoutEffect } from 'react';
|
|
4
|
+
import { useQuery, useQueryClient, useMutation, keepPreviousData } from '@tanstack/react-query';
|
|
4
5
|
import classnames from 'classnames';
|
|
5
6
|
import { useFormikContext, useField, FieldArray, Form as Form$3, Formik, Field, FastField } from 'formik';
|
|
6
7
|
import { filterNonNull, noop as noop$1, findBy, toLabelAndValue, isPresent as isPresent$1, truncate, slugify, filterBy, hyphenate, removeBy, isNotPresent, isNotEmpty, findById, notEqualsDeep } from '@bigbinary/neeto-cist';
|
|
7
8
|
import { buildUrl, showThumbsUpToastr, withEventTargetValue, getQueryParams, dateFormat } from '@bigbinary/neeto-commons-frontend/utils';
|
|
8
9
|
import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
|
|
9
10
|
import { assoc, mergeLeft, compose, isEmpty, trim, useWith, path, split, isNotNil, either, isNil, values, equals, modify, prop, range, includes, __, reduce, reject, keys, pick, omit, pluck, without, difference, pipe as pipe$1, last, not, toLower, map, clamp as clamp$2, identity, filter as filter$1 } from 'ramda';
|
|
10
|
-
import { useQuery, useQueryClient, useMutation } from 'react-query';
|
|
11
11
|
import i18next, { t as t$3 } from 'i18next';
|
|
12
12
|
import _objectWithoutProperties$1 from '@babel/runtime/helpers/objectWithoutProperties';
|
|
13
13
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -34,12 +34,13 @@ import Form$2 from '@bigbinary/neetoui/formik/Form';
|
|
|
34
34
|
import Select from '@bigbinary/neetoui/formik/Select';
|
|
35
35
|
import Textarea from '@bigbinary/neetoui/formik/Textarea';
|
|
36
36
|
import Switch from '@bigbinary/neetoui/formik/Switch';
|
|
37
|
-
import { Info, Delete, Plus, Check, Close, FileGeneric } from '@bigbinary/neeto-icons';
|
|
38
37
|
import Button$1 from '@bigbinary/neetoui/Button';
|
|
38
|
+
import Accordion from '@bigbinary/neetoui/Accordion';
|
|
39
39
|
import Input from '@bigbinary/neetoui/formik/Input';
|
|
40
40
|
import * as yup from 'yup';
|
|
41
41
|
import Checkbox$1 from '@bigbinary/neetoui/formik/Checkbox';
|
|
42
42
|
import Checkbox from '@bigbinary/neetoui/Checkbox';
|
|
43
|
+
import { Delete, Plus, Check, Close, FileGeneric } from '@bigbinary/neeto-icons';
|
|
43
44
|
import Label from '@bigbinary/neetoui/Label';
|
|
44
45
|
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
45
46
|
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
@@ -553,8 +554,12 @@ var handleQuestionMutationSuccess = function handleQuestionMutationSuccess(_ref)
|
|
|
553
554
|
onSuccess = _ref.onSuccess;
|
|
554
555
|
var _args = _slicedToArray$2(args, 1),
|
|
555
556
|
data = _args[0];
|
|
556
|
-
queryClient.invalidateQueries(
|
|
557
|
-
|
|
557
|
+
queryClient.invalidateQueries({
|
|
558
|
+
queryKey: [QUERY_KEYS.QUESTIONS, formId, language]
|
|
559
|
+
});
|
|
560
|
+
queryClient.invalidateQueries({
|
|
561
|
+
queryKey: [QUERY_KEYS.QUESTIONS, "preview/".concat(formId), language]
|
|
562
|
+
});
|
|
558
563
|
queryClient.setQueryData([QUERY_KEYS.QUESTIONS, formId, language], assoc("questions", data.questions));
|
|
559
564
|
queryClient.setQueryData([QUERY_KEYS.QUESTIONS, "preview/".concat(formId), language], assoc("questions", data.questions));
|
|
560
565
|
onSuccess === null || onSuccess === void 0 || onSuccess.apply(void 0, _toConsumableArray$1(args));
|
|
@@ -573,10 +578,12 @@ var useForm = function useForm(_ref) {
|
|
|
573
578
|
_ref$language = _ref.language,
|
|
574
579
|
language = _ref$language === void 0 ? i18next.resolvedLanguage : _ref$language,
|
|
575
580
|
options = _objectWithoutProperties$1(_ref, _excluded$d);
|
|
576
|
-
return useQuery(
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
581
|
+
return useQuery(_objectSpread$z({
|
|
582
|
+
queryKey: [QUERY_KEYS.QUESTIONS, preview ? "preview/".concat(formId) : formId, language],
|
|
583
|
+
queryFn: function queryFn() {
|
|
584
|
+
return neetoFormApi.getPublicQuestions(formId, language);
|
|
585
|
+
},
|
|
586
|
+
placeholderData: keepPreviousData
|
|
580
587
|
}, options));
|
|
581
588
|
};
|
|
582
589
|
var useFetchQuestions = function useFetchQuestions(_ref2) {
|
|
@@ -584,24 +591,29 @@ var useFetchQuestions = function useFetchQuestions(_ref2) {
|
|
|
584
591
|
_ref2$language = _ref2.language,
|
|
585
592
|
language = _ref2$language === void 0 ? i18next.resolvedLanguage : _ref2$language,
|
|
586
593
|
options = _objectWithoutProperties$1(_ref2, _excluded2$1);
|
|
587
|
-
return useQuery(
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
594
|
+
return useQuery(_objectSpread$z({
|
|
595
|
+
queryKey: [QUERY_KEYS.QUESTIONS, formId, language],
|
|
596
|
+
queryFn: function queryFn() {
|
|
597
|
+
return neetoFormApi.getQuestions(formId, language);
|
|
598
|
+
},
|
|
599
|
+
placeholderData: keepPreviousData
|
|
591
600
|
}, options));
|
|
592
601
|
};
|
|
593
602
|
var useCreateForm = function useCreateForm(options) {
|
|
594
603
|
var language = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i18next.resolvedLanguage;
|
|
595
604
|
var queryClient = useQueryClient();
|
|
596
|
-
return useMutation(
|
|
605
|
+
return useMutation(_objectSpread$z(_objectSpread$z({
|
|
606
|
+
mutationFn: neetoFormApi.createForm
|
|
607
|
+
}, options), {}, {
|
|
597
608
|
onSuccess: function onSuccess(form) {
|
|
598
609
|
var _options$onSuccess;
|
|
599
|
-
queryClient.setQueryData(QUERY_KEYS.QUESTIONS, function (forms) {
|
|
610
|
+
queryClient.setQueryData([QUERY_KEYS.QUESTIONS], function (forms) {
|
|
600
611
|
return forms && [].concat(_toConsumableArray$1(forms), [form]);
|
|
601
612
|
});
|
|
602
613
|
queryClient.setQueryData([QUERY_KEYS.QUESTIONS, form.id, language], form);
|
|
603
|
-
queryClient.setQueryData([QUERY_KEYS.QUESTIONS, "preview/".concat(form.id), language], form)
|
|
604
|
-
|
|
614
|
+
queryClient.setQueryData([QUERY_KEYS.QUESTIONS, "preview/".concat(form.id), language], form), queryClient.invalidateQueries({
|
|
615
|
+
queryKey: [QUERY_KEYS.FORMS]
|
|
616
|
+
});
|
|
605
617
|
options === null || options === void 0 || (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 || _options$onSuccess.call(options, form);
|
|
606
618
|
}
|
|
607
619
|
}));
|
|
@@ -609,11 +621,13 @@ var useCreateForm = function useCreateForm(options) {
|
|
|
609
621
|
var useUpdateForm = function useUpdateForm(options) {
|
|
610
622
|
var language = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i18next.resolvedLanguage;
|
|
611
623
|
var queryClient = useQueryClient();
|
|
612
|
-
return useMutation(
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
624
|
+
return useMutation(_objectSpread$z(_objectSpread$z({
|
|
625
|
+
mutationFn: function mutationFn(_ref3) {
|
|
626
|
+
var id = _ref3.id,
|
|
627
|
+
values = _ref3.values;
|
|
628
|
+
return neetoFormApi.updateForm(id, values);
|
|
629
|
+
}
|
|
630
|
+
}, options), {}, {
|
|
617
631
|
onSuccess: function onSuccess(data, _ref4) {
|
|
618
632
|
var id = _ref4.id;
|
|
619
633
|
queryClient.setQueryData([QUERY_KEYS.QUESTIONS, id, language], assoc("title", data.title));
|
|
@@ -621,9 +635,15 @@ var useUpdateForm = function useUpdateForm(options) {
|
|
|
621
635
|
questions: data.questions,
|
|
622
636
|
title: data.title
|
|
623
637
|
}));
|
|
624
|
-
queryClient.invalidateQueries(
|
|
625
|
-
|
|
626
|
-
|
|
638
|
+
queryClient.invalidateQueries({
|
|
639
|
+
queryKey: [QUERY_KEYS.FORMS]
|
|
640
|
+
});
|
|
641
|
+
queryClient.invalidateQueries({
|
|
642
|
+
queryKey: [QUERY_KEYS.QUESTIONS, id]
|
|
643
|
+
});
|
|
644
|
+
queryClient.invalidateQueries({
|
|
645
|
+
queryKey: [QUERY_KEYS.QUESTIONS, "preview/".concat(id)]
|
|
646
|
+
});
|
|
627
647
|
options.onSuccess && options.onSuccess(data);
|
|
628
648
|
}
|
|
629
649
|
}));
|
|
@@ -631,9 +651,11 @@ var useUpdateForm = function useUpdateForm(options) {
|
|
|
631
651
|
var useCreateQuestion = function useCreateQuestion(formId, language) {
|
|
632
652
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
633
653
|
var queryClient = useQueryClient();
|
|
634
|
-
return useMutation(
|
|
635
|
-
|
|
636
|
-
|
|
654
|
+
return useMutation(_objectSpread$z(_objectSpread$z({
|
|
655
|
+
mutationFn: function mutationFn(payload) {
|
|
656
|
+
return neetoFormApi.createQuestion(formId, filterNonNull(payload));
|
|
657
|
+
}
|
|
658
|
+
}, options), {}, {
|
|
637
659
|
onSuccess: function onSuccess() {
|
|
638
660
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
639
661
|
args[_key] = arguments[_key];
|
|
@@ -651,15 +673,17 @@ var useCreateQuestion = function useCreateQuestion(formId, language) {
|
|
|
651
673
|
var useUpdateQuestion = function useUpdateQuestion(formId, language) {
|
|
652
674
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
653
675
|
var queryClient = useQueryClient();
|
|
654
|
-
return useMutation(
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
676
|
+
return useMutation(_objectSpread$z(_objectSpread$z({
|
|
677
|
+
mutationFn: function mutationFn(_ref5) {
|
|
678
|
+
var questionId = _ref5.questionId,
|
|
679
|
+
payload = _ref5.payload;
|
|
680
|
+
return neetoFormApi.updateQuestion({
|
|
681
|
+
formId: formId,
|
|
682
|
+
questionId: questionId,
|
|
683
|
+
payload: filterNonNull(payload)
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
}, options), {}, {
|
|
663
687
|
onSuccess: function onSuccess() {
|
|
664
688
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
665
689
|
args[_key2] = arguments[_key2];
|
|
@@ -677,9 +701,11 @@ var useUpdateQuestion = function useUpdateQuestion(formId, language) {
|
|
|
677
701
|
var useDeleteQuestion = function useDeleteQuestion(formId, language) {
|
|
678
702
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
679
703
|
var queryClient = useQueryClient();
|
|
680
|
-
return useMutation(
|
|
681
|
-
|
|
682
|
-
|
|
704
|
+
return useMutation(_objectSpread$z(_objectSpread$z({
|
|
705
|
+
mutationFn: function mutationFn(questionId) {
|
|
706
|
+
return neetoFormApi.deleteQuestion(formId, questionId);
|
|
707
|
+
}
|
|
708
|
+
}, options), {}, {
|
|
683
709
|
onSuccess: function onSuccess() {
|
|
684
710
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
685
711
|
args[_key3] = arguments[_key3];
|
|
@@ -697,9 +723,11 @@ var useDeleteQuestion = function useDeleteQuestion(formId, language) {
|
|
|
697
723
|
var useReorderQuestions = function useReorderQuestions(formId, language) {
|
|
698
724
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
699
725
|
var queryClient = useQueryClient();
|
|
700
|
-
return useMutation(
|
|
701
|
-
|
|
702
|
-
|
|
726
|
+
return useMutation(_objectSpread$z(_objectSpread$z({
|
|
727
|
+
mutationFn: function mutationFn(payload) {
|
|
728
|
+
return neetoFormApi.reorderQuestions(formId, filterNonNull(payload));
|
|
729
|
+
}
|
|
730
|
+
}, options), {}, {
|
|
703
731
|
onSuccess: function onSuccess() {
|
|
704
732
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
705
733
|
args[_key4] = arguments[_key4];
|
|
@@ -721,13 +749,15 @@ var useForms = function useForms() {
|
|
|
721
749
|
_ref6$pageSize = _ref6.pageSize,
|
|
722
750
|
pageSize = _ref6$pageSize === void 0 ? DEFAULT_PAGE_SIZE : _ref6$pageSize,
|
|
723
751
|
options = _objectWithoutProperties$1(_ref6, _excluded3$1);
|
|
724
|
-
return useQuery(
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
752
|
+
return useQuery(_objectSpread$z({
|
|
753
|
+
queryKey: [QUERY_KEYS.FORMS, page],
|
|
754
|
+
queryFn: function queryFn() {
|
|
755
|
+
return neetoFormApi.getForms({
|
|
756
|
+
page: page,
|
|
757
|
+
pageSize: pageSize
|
|
758
|
+
});
|
|
759
|
+
},
|
|
760
|
+
placeholderData: keepPreviousData
|
|
731
761
|
}, options));
|
|
732
762
|
};
|
|
733
763
|
var useDeleteForm = function useDeleteForm(options) {
|
|
@@ -751,19 +781,23 @@ var useSubmission = function useSubmission(_ref11) {
|
|
|
751
781
|
var formId = _ref11.formId,
|
|
752
782
|
submissionId = _ref11.submissionId,
|
|
753
783
|
options = _objectWithoutProperties$1(_ref11, _excluded5);
|
|
754
|
-
return useQuery(
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
784
|
+
return useQuery(_objectSpread$z({
|
|
785
|
+
queryKey: [QUERY_KEYS.SUBMISSION, formId, submissionId],
|
|
786
|
+
queryFn: function queryFn() {
|
|
787
|
+
return neetoFormApi.getPublicSubmission(formId, submissionId);
|
|
788
|
+
},
|
|
789
|
+
placeholderData: keepPreviousData
|
|
790
|
+
}, options));
|
|
759
791
|
};
|
|
760
792
|
var useCreateSubmission = function useCreateSubmission(options) {
|
|
761
793
|
var queryClient = useQueryClient();
|
|
762
|
-
return useMutation(
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
794
|
+
return useMutation(_objectSpread$z(_objectSpread$z({
|
|
795
|
+
mutationFn: function mutationFn(_ref12) {
|
|
796
|
+
var formId = _ref12.formId,
|
|
797
|
+
values = _ref12.values;
|
|
798
|
+
return neetoFormApi.submitPublicForm(formId, values);
|
|
799
|
+
}
|
|
800
|
+
}, options), {}, {
|
|
767
801
|
onSuccess: function onSuccess() {
|
|
768
802
|
var _data$submission, _data$submission2;
|
|
769
803
|
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
@@ -771,30 +805,42 @@ var useCreateSubmission = function useCreateSubmission(options) {
|
|
|
771
805
|
}
|
|
772
806
|
var data = args[0],
|
|
773
807
|
formId = args[1].formId;
|
|
774
|
-
queryClient.invalidateQueries(
|
|
808
|
+
queryClient.invalidateQueries({
|
|
809
|
+
queryKey: [QUERY_KEYS.SUBMISSIONS, formId]
|
|
810
|
+
});
|
|
775
811
|
queryClient.setQueryData([QUERY_KEYS.SUBMISSION, formId, data === null || data === void 0 || (_data$submission = data.submission) === null || _data$submission === void 0 ? void 0 : _data$submission.id], data === null || data === void 0 ? void 0 : data.submission);
|
|
776
|
-
queryClient.invalidateQueries(
|
|
812
|
+
queryClient.invalidateQueries({
|
|
813
|
+
queryKey: [QUERY_KEYS.SUBMISSION, formId, data === null || data === void 0 || (_data$submission2 = data.submission) === null || _data$submission2 === void 0 ? void 0 : _data$submission2.id]
|
|
814
|
+
});
|
|
777
815
|
options.onSuccess && options.onSuccess.apply(options, args);
|
|
778
816
|
}
|
|
779
817
|
}));
|
|
780
818
|
};
|
|
781
819
|
var useUpdateSubmission = function useUpdateSubmission(options) {
|
|
782
820
|
var queryClient = useQueryClient();
|
|
783
|
-
return useMutation(
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
821
|
+
return useMutation(_objectSpread$z(_objectSpread$z({
|
|
822
|
+
mutationFn: function mutationFn(_ref13) {
|
|
823
|
+
var formId = _ref13.formId,
|
|
824
|
+
submissionId = _ref13.submissionId,
|
|
825
|
+
values = _ref13.values;
|
|
826
|
+
return neetoFormApi.updatePublicSubmission(formId, submissionId, values);
|
|
827
|
+
}
|
|
828
|
+
}, options), {}, {
|
|
788
829
|
onSuccess: function onSuccess() {
|
|
789
|
-
var _data$submission3;
|
|
790
830
|
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
791
831
|
args[_key6] = arguments[_key6];
|
|
792
832
|
}
|
|
793
833
|
var data = args[0],
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
queryClient.invalidateQueries(
|
|
834
|
+
_args$ = args[1],
|
|
835
|
+
formId = _args$.formId,
|
|
836
|
+
submissionId = _args$.submissionId;
|
|
837
|
+
queryClient.invalidateQueries({
|
|
838
|
+
queryKey: [QUERY_KEYS.SUBMISSIONS, formId]
|
|
839
|
+
});
|
|
840
|
+
queryClient.setQueryData([QUERY_KEYS.SUBMISSION, formId, submissionId], data === null || data === void 0 ? void 0 : data.submission);
|
|
841
|
+
queryClient.invalidateQueries({
|
|
842
|
+
queryKey: [QUERY_KEYS.SUBMISSION, formId, submissionId]
|
|
843
|
+
});
|
|
798
844
|
options.onSuccess && options.onSuccess.apply(options, args);
|
|
799
845
|
}
|
|
800
846
|
}));
|
|
@@ -1304,7 +1350,7 @@ var DeleteAlert = function DeleteAlert(_ref) {
|
|
|
1304
1350
|
}
|
|
1305
1351
|
}),
|
|
1306
1352
|
deleteQuestion = _useDeleteQuestion.mutate,
|
|
1307
|
-
isDeleting = _useDeleteQuestion.
|
|
1353
|
+
isDeleting = _useDeleteQuestion.isPending;
|
|
1308
1354
|
var selectNextQuestion = function selectNextQuestion(questions) {
|
|
1309
1355
|
var selectedQuestionIndex = selectedQuestion.displayOrder;
|
|
1310
1356
|
var wasLastQuestion = equals(selectedQuestionIndex, questions.length);
|
|
@@ -1924,6 +1970,19 @@ var useUpdateEditorContent = function useUpdateEditorContent(_ref) {
|
|
|
1924
1970
|
setEditorContent(initialValue);
|
|
1925
1971
|
setFormData(modify("richTextFieldsToReset", without([fieldCode])));
|
|
1926
1972
|
}
|
|
1973
|
+
var _useFetchQuestions = useFetchQuestions({
|
|
1974
|
+
formId: formId,
|
|
1975
|
+
language: language
|
|
1976
|
+
}),
|
|
1977
|
+
data = _useFetchQuestions.data;
|
|
1978
|
+
useEffect(function () {
|
|
1979
|
+
if (!data) return;
|
|
1980
|
+
var pathArray = fieldName.split(".").map(function (part) {
|
|
1981
|
+
var parsedPart = parseInt(part);
|
|
1982
|
+
return isNaN(parsedPart) ? part : parsedPart;
|
|
1983
|
+
});
|
|
1984
|
+
setEditorContent(path(pathArray, data));
|
|
1985
|
+
}, [data]);
|
|
1927
1986
|
useEffect(function () {
|
|
1928
1987
|
if (initialStateRef.current["language"] !== language) {
|
|
1929
1988
|
initialStateRef.current["language"] = language;
|
|
@@ -1935,17 +1994,6 @@ var useUpdateEditorContent = function useUpdateEditorContent(_ref) {
|
|
|
1935
1994
|
initialStateRef.current["value"] = value;
|
|
1936
1995
|
}
|
|
1937
1996
|
}, [language, value]);
|
|
1938
|
-
useFetchQuestions({
|
|
1939
|
-
formId: formId,
|
|
1940
|
-
language: language,
|
|
1941
|
-
onSuccess: function onSuccess(data) {
|
|
1942
|
-
var pathArray = fieldName.split(".").map(function (part) {
|
|
1943
|
-
var parsedPart = parseInt(part);
|
|
1944
|
-
return isNaN(parsedPart) ? part : parsedPart;
|
|
1945
|
-
});
|
|
1946
|
-
setEditorContent(path(pathArray, data));
|
|
1947
|
-
}
|
|
1948
|
-
});
|
|
1949
1997
|
};
|
|
1950
1998
|
|
|
1951
1999
|
var Editor = function Editor() {
|
|
@@ -2026,31 +2074,27 @@ var InputWithMaxLength = function InputWithMaxLength(_ref) {
|
|
|
2026
2074
|
|
|
2027
2075
|
var FieldCode = withT(function (_ref) {
|
|
2028
2076
|
var t = _ref.t;
|
|
2029
|
-
return /*#__PURE__*/jsx(
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
icon: Info,
|
|
2048
|
-
className: "cursor-pointer",
|
|
2049
|
-
onClick: function onClick() {
|
|
2050
|
-
return window.open(FIELD_CODE_DOC, "_blank");
|
|
2077
|
+
return /*#__PURE__*/jsx(Accordion, {
|
|
2078
|
+
className: "neeto-form-nano-advanced-properties-accordion",
|
|
2079
|
+
"data-cy": "advanced-properties-card",
|
|
2080
|
+
children: /*#__PURE__*/jsx(Accordion.Item, {
|
|
2081
|
+
title: t("neetoForm.common.advancedProperties"),
|
|
2082
|
+
children: /*#__PURE__*/jsx(InputWithMaxLength, {
|
|
2083
|
+
required: true,
|
|
2084
|
+
label: t("neetoForm.questions.common.questionFields.field.fieldCode"),
|
|
2085
|
+
name: "fieldCode",
|
|
2086
|
+
helpText: /*#__PURE__*/jsx(Trans, {
|
|
2087
|
+
i18nKey: "neetoForm.questions.common.questionFields.field.fieldCodeHelpDescription",
|
|
2088
|
+
components: {
|
|
2089
|
+
Link: /*#__PURE__*/jsx(Button$1, {
|
|
2090
|
+
className: "text-xs",
|
|
2091
|
+
href: FIELD_CODE_DOC,
|
|
2092
|
+
style: "link",
|
|
2093
|
+
target: "_blank"
|
|
2094
|
+
})
|
|
2051
2095
|
}
|
|
2052
|
-
}
|
|
2053
|
-
}
|
|
2096
|
+
})
|
|
2097
|
+
})
|
|
2054
2098
|
})
|
|
2055
2099
|
});
|
|
2056
2100
|
});
|
|
@@ -2155,11 +2199,7 @@ var Form$1 = function Form(_ref) {
|
|
|
2155
2199
|
dataCy: "settings-card",
|
|
2156
2200
|
title: t("neetoForm.common.settings"),
|
|
2157
2201
|
children: /*#__PURE__*/jsx(RequiredSwitch, {})
|
|
2158
|
-
}), shouldShowFieldCode && /*#__PURE__*/jsx(
|
|
2159
|
-
dataCy: "advanced-properties-card",
|
|
2160
|
-
title: t("neetoForm.common.advancedProperties"),
|
|
2161
|
-
children: /*#__PURE__*/jsx(FieldCode, {})
|
|
2162
|
-
})]
|
|
2202
|
+
}), shouldShowFieldCode && /*#__PURE__*/jsx(FieldCode, {})]
|
|
2163
2203
|
})]
|
|
2164
2204
|
})
|
|
2165
2205
|
});
|
|
@@ -2233,7 +2273,7 @@ var Add = function Add(_ref) {
|
|
|
2233
2273
|
}
|
|
2234
2274
|
}),
|
|
2235
2275
|
createQuestion = _useCreateQuestion.mutate,
|
|
2236
|
-
isCreating = _useCreateQuestion.
|
|
2276
|
+
isCreating = _useCreateQuestion.isPending;
|
|
2237
2277
|
var handleSubmit = function handleSubmit(values) {
|
|
2238
2278
|
if (isCreating || !isOpen) return;
|
|
2239
2279
|
var displayOrder = question ? question.displayOrder + 1 : questions.length;
|
|
@@ -2301,7 +2341,7 @@ var Edit = function Edit(_ref) {
|
|
|
2301
2341
|
language = _useBuildFormStore.selectedLanguage;
|
|
2302
2342
|
var _useUpdateQuestion = useUpdateQuestion(question === null || question === void 0 ? void 0 : question.formId, language),
|
|
2303
2343
|
updateQuestion = _useUpdateQuestion.mutate,
|
|
2304
|
-
isUpdating = _useUpdateQuestion.
|
|
2344
|
+
isUpdating = _useUpdateQuestion.isPending;
|
|
2305
2345
|
var handleSubmit = function handleSubmit(values, _ref2) {
|
|
2306
2346
|
var setSubmitting = _ref2.setSubmitting;
|
|
2307
2347
|
if (isUpdating || !isOpen) return;
|
|
@@ -3073,13 +3113,10 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
3073
3113
|
onSuccess: showThumbsUpToastr
|
|
3074
3114
|
}),
|
|
3075
3115
|
reorderQuestions = _useReorderQuestions.mutate,
|
|
3076
|
-
isReordering = _useReorderQuestions.
|
|
3116
|
+
isReordering = _useReorderQuestions.isPending;
|
|
3077
3117
|
var _useFetchQuestions = useFetchQuestions({
|
|
3078
3118
|
formId: id,
|
|
3079
3119
|
language: selectedLanguage,
|
|
3080
|
-
onSuccess: function onSuccess(data) {
|
|
3081
|
-
return onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(data);
|
|
3082
|
-
},
|
|
3083
3120
|
placeholderData: {
|
|
3084
3121
|
isQuestionsLoading: true,
|
|
3085
3122
|
questions: [{
|
|
@@ -3093,22 +3130,27 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
3093
3130
|
}]
|
|
3094
3131
|
}
|
|
3095
3132
|
}),
|
|
3096
|
-
|
|
3097
|
-
_useFetchQuestions$da2 = _useFetchQuestions$da === void 0 ? QUESTIONS_INITIAL_VALUE : _useFetchQuestions$da,
|
|
3098
|
-
isFormEnabled = _useFetchQuestions$da2.enabled,
|
|
3099
|
-
savedTitle = _useFetchQuestions$da2.title,
|
|
3100
|
-
isQuestionsLoading = _useFetchQuestions$da2.isQuestionsLoading,
|
|
3101
|
-
questions = _useFetchQuestions$da2.questions,
|
|
3133
|
+
data = _useFetchQuestions.data,
|
|
3102
3134
|
isLoading = _useFetchQuestions.isLoading;
|
|
3135
|
+
var _ref2 = data || QUESTIONS_INITIAL_VALUE,
|
|
3136
|
+
isFormEnabled = _ref2.enabled,
|
|
3137
|
+
savedTitle = _ref2.title,
|
|
3138
|
+
questions = _ref2.questions,
|
|
3139
|
+
isQuestionsLoading = _ref2.isQuestionsLoading;
|
|
3140
|
+
useEffect(function () {
|
|
3141
|
+
if (data) {
|
|
3142
|
+
onUpdate === null || onUpdate === void 0 || onUpdate(data);
|
|
3143
|
+
}
|
|
3144
|
+
}, [data]);
|
|
3103
3145
|
if (isLoading || showLoader && isQuestionsLoading) {
|
|
3104
3146
|
return /*#__PURE__*/jsx("div", {
|
|
3105
3147
|
className: "flex h-full w-full items-center justify-center py-6",
|
|
3106
3148
|
children: /*#__PURE__*/jsx(PageLoader, {})
|
|
3107
3149
|
});
|
|
3108
3150
|
}
|
|
3109
|
-
var handleSubmit = function handleSubmit(
|
|
3110
|
-
var questions =
|
|
3111
|
-
var setSubmitting =
|
|
3151
|
+
var handleSubmit = function handleSubmit(_ref3, _ref4) {
|
|
3152
|
+
var questions = _ref3.questions;
|
|
3153
|
+
var setSubmitting = _ref4.setSubmitting;
|
|
3112
3154
|
var payload = {
|
|
3113
3155
|
neetoFormQuestions: {
|
|
3114
3156
|
questions: buildReorderPayload(questions)
|
|
@@ -3130,8 +3172,8 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
3130
3172
|
var isDeletable = isQuestionDeletable !== null && isQuestionDeletable !== void 0 ? isQuestionDeletable : function (question) {
|
|
3131
3173
|
return !nonRemovableFields.includes(question.kind);
|
|
3132
3174
|
};
|
|
3133
|
-
var isRequiredField = isFieldRequired !== null && isFieldRequired !== void 0 ? isFieldRequired : function (
|
|
3134
|
-
var kind =
|
|
3175
|
+
var isRequiredField = isFieldRequired !== null && isFieldRequired !== void 0 ? isFieldRequired : function (_ref5) {
|
|
3176
|
+
var kind = _ref5.kind;
|
|
3135
3177
|
return requiredFields.includes(kind);
|
|
3136
3178
|
};
|
|
3137
3179
|
var isDisabledFieldLabel = isFieldLabelDisabled !== null && isFieldLabelDisabled !== void 0 ? isFieldLabelDisabled : function () {
|
|
@@ -3148,9 +3190,9 @@ var BuildForm = function BuildForm(_ref) {
|
|
|
3148
3190
|
questions: questions
|
|
3149
3191
|
},
|
|
3150
3192
|
onSubmit: handleSubmit,
|
|
3151
|
-
children: function children(
|
|
3152
|
-
var errors =
|
|
3153
|
-
setFieldError =
|
|
3193
|
+
children: function children(_ref6) {
|
|
3194
|
+
var errors = _ref6.errors,
|
|
3195
|
+
setFieldError = _ref6.setFieldError;
|
|
3154
3196
|
return /*#__PURE__*/jsx(Form, _objectSpread$n(_objectSpread$n({}, _objectSpread$n(_objectSpread$n({}, formDomProps), {}, {
|
|
3155
3197
|
additionalActionOptions: additionalActionOptions,
|
|
3156
3198
|
additionalQuestionKindPattern: additionalQuestionKindPattern,
|
|
@@ -13447,6 +13489,7 @@ var Choices = function Choices(_ref) {
|
|
|
13447
13489
|
var Component = isCheckBox ? Checkbox : Radio.Item;
|
|
13448
13490
|
return /*#__PURE__*/jsxs("div", {
|
|
13449
13491
|
className: "neeto-form-engine-choices__wrapper",
|
|
13492
|
+
"data-cy": "".concat(hyphenate(label), "-select-container-wrapper"),
|
|
13450
13493
|
children: [/*#__PURE__*/jsx("label", {
|
|
13451
13494
|
className: "neeto-form-engine-label",
|
|
13452
13495
|
children: label
|
|
@@ -14160,7 +14203,9 @@ var ExternalForm = function ExternalForm(_ref) {
|
|
|
14160
14203
|
}, clearLocalFormValues);
|
|
14161
14204
|
case 17:
|
|
14162
14205
|
data = _context.sent;
|
|
14163
|
-
queryClient.invalidateQueries(
|
|
14206
|
+
queryClient.invalidateQueries({
|
|
14207
|
+
queryKey: [QUERY_KEYS.FORM, formId, submissionId]
|
|
14208
|
+
});
|
|
14164
14209
|
_context.next = 30;
|
|
14165
14210
|
break;
|
|
14166
14211
|
case 21:
|
|
@@ -14271,9 +14316,7 @@ var ExternalForm = function ExternalForm(_ref) {
|
|
|
14271
14316
|
};
|
|
14272
14317
|
var _useForm = useForm({
|
|
14273
14318
|
formId: formId,
|
|
14274
|
-
preview: preview,
|
|
14275
14319
|
language: language,
|
|
14276
|
-
onError: Toastr.error,
|
|
14277
14320
|
enabled: !preview,
|
|
14278
14321
|
placeholderData: {
|
|
14279
14322
|
isQuestionsLoading: true
|
|
@@ -17204,8 +17247,6 @@ var UrlBuilder = function UrlBuilder(_ref) {
|
|
|
17204
17247
|
};
|
|
17205
17248
|
var _useForm = useForm({
|
|
17206
17249
|
formId: formId,
|
|
17207
|
-
preview: false,
|
|
17208
|
-
onError: Toastr.error,
|
|
17209
17250
|
placeholderData: {
|
|
17210
17251
|
isQuestionsLoading: true
|
|
17211
17252
|
}
|