@bigbinary/neeto-form-frontend 4.4.6 → 4.4.7

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 (58) hide show
  1. package/README.md +4 -1
  2. package/app/javascript/src/translations/en.json +10 -1
  3. package/package.json +1 -5
  4. package/types.d.ts +1 -0
  5. package/dist/BuildForm.js +0 -3035
  6. package/dist/BuildForm.js.map +0 -1
  7. package/dist/ExternalForm.js +0 -639
  8. package/dist/ExternalForm.js.map +0 -1
  9. package/dist/NeetoFormProvider.js +0 -11
  10. package/dist/NeetoFormProvider.js.map +0 -1
  11. package/dist/Submission.js +0 -2832
  12. package/dist/Submission.js.map +0 -1
  13. package/dist/UrlBuilder.js +0 -309
  14. package/dist/UrlBuilder.js.map +0 -1
  15. package/dist/buildForm-CgofRtEN.js +0 -38
  16. package/dist/buildForm-CgofRtEN.js.map +0 -1
  17. package/dist/buildForm-D-epUrZG.js +0 -35
  18. package/dist/buildForm-D-epUrZG.js.map +0 -1
  19. package/dist/cjs/BuildForm.js +0 -3056
  20. package/dist/cjs/BuildForm.js.map +0 -1
  21. package/dist/cjs/ExternalForm.js +0 -641
  22. package/dist/cjs/ExternalForm.js.map +0 -1
  23. package/dist/cjs/NeetoFormProvider.js +0 -13
  24. package/dist/cjs/NeetoFormProvider.js.map +0 -1
  25. package/dist/cjs/Submission.js +0 -2834
  26. package/dist/cjs/Submission.js.map +0 -1
  27. package/dist/cjs/UrlBuilder.js +0 -311
  28. package/dist/cjs/UrlBuilder.js.map +0 -1
  29. package/dist/cjs/hooks.js +0 -33
  30. package/dist/cjs/hooks.js.map +0 -1
  31. package/dist/cjs/index.js +0 -112
  32. package/dist/cjs/index.js.map +0 -1
  33. package/dist/constants-BNfHPNOx.js +0 -493
  34. package/dist/constants-BNfHPNOx.js.map +0 -1
  35. package/dist/constants-CfUZ9B6N.js +0 -512
  36. package/dist/constants-CfUZ9B6N.js.map +0 -1
  37. package/dist/hooks.js +0 -20
  38. package/dist/hooks.js.map +0 -1
  39. package/dist/index-0m1EzLFY.js +0 -51
  40. package/dist/index-0m1EzLFY.js.map +0 -1
  41. package/dist/index-y4GiXx7o.js +0 -43
  42. package/dist/index-y4GiXx7o.js.map +0 -1
  43. package/dist/index.js +0 -94
  44. package/dist/index.js.map +0 -1
  45. package/dist/main.css +0 -2
  46. package/dist/main.css.map +0 -1
  47. package/dist/useFormSubmission-Cx63P761.js +0 -22
  48. package/dist/useFormSubmission-Cx63P761.js.map +0 -1
  49. package/dist/useFormSubmission-DyS5Dm1q.js +0 -24
  50. package/dist/useFormSubmission-DyS5Dm1q.js.map +0 -1
  51. package/dist/utils-C9nDMm4c.js +0 -2652
  52. package/dist/utils-C9nDMm4c.js.map +0 -1
  53. package/dist/utils-DEBFghm4.js +0 -2683
  54. package/dist/utils-DEBFghm4.js.map +0 -1
  55. package/dist/yup-CMEoabdy.js +0 -1076
  56. package/dist/yup-CMEoabdy.js.map +0 -1
  57. package/dist/yup-Dx1WK2_p.js +0 -995
  58. package/dist/yup-Dx1WK2_p.js.map +0 -1
package/dist/cjs/index.js DELETED
@@ -1,112 +0,0 @@
1
- 'use strict';
2
-
3
- var BuildForm = require('./BuildForm.js');
4
- var NeetoFormProvider = require('./NeetoFormProvider.js');
5
- var ExternalForm = require('./ExternalForm.js');
6
- var Submission = require('./Submission.js');
7
- var UrlBuilder = require('./UrlBuilder.js');
8
- var constants = require('../constants-CfUZ9B6N.js');
9
- var useFormSubmission = require('../useFormSubmission-DyS5Dm1q.js');
10
- var buildForm = require('../buildForm-CgofRtEN.js');
11
- require('@tanstack/react-query');
12
- require('classnames');
13
- require('@bigbinary/neeto-cist');
14
- require('@bigbinary/neetoui/Spinner');
15
- require('ramda');
16
- require('../yup-CMEoabdy.js');
17
- require('i18next');
18
- require('react');
19
- require('@babel/runtime/helpers/defineProperty');
20
- require('@babel/runtime/helpers/objectWithoutProperties');
21
- require('react/jsx-runtime');
22
- require('@babel/runtime/helpers/toConsumableArray');
23
- require('dompurify');
24
- require('../index-0m1EzLFY.js');
25
- require('@babel/runtime/helpers/typeof');
26
- require('@bigbinary/neeto-editor/utils');
27
- require('@bigbinary/neeto-icons/Plus');
28
- require('yup');
29
- require('@babel/runtime/helpers/slicedToArray');
30
- require('@hello-pangea/dnd');
31
- require('@bigbinary/neeto-commons-frontend/react-utils');
32
- require('@bigbinary/neeto-commons-frontend/utils');
33
- require('zustand/shallow');
34
- require('@bigbinary/neetoui/Alert');
35
- require('react-i18next');
36
- require('@bigbinary/neetoui/Typography');
37
- require('@bigbinary/neetoui/Modal');
38
- require('@bigbinary/neeto-molecules/MoreDropdown');
39
- require('@bigbinary/neetoui/Dropdown');
40
- require('@bigbinary/neetoui/Tooltip');
41
- require('uuid');
42
- require('@bigbinary/neetoui/NoData');
43
- require('@bigbinary/neetoui/Button');
44
- require('@bigbinary/neetoui/Pane');
45
- require('@bigbinary/neetoui/formik/ActionBlock');
46
- require('@bigbinary/neetoui/formik/Form');
47
- require('formik');
48
- require('@bigbinary/neetoui/Accordion');
49
- require('@bigbinary/neetoui/formik/Select');
50
- require('@bigbinary/neetoui/formik/Switch');
51
- require('@bigbinary/neetoui/formik/Textarea');
52
- require('@bigbinary/neeto-editor/Editor');
53
- require('@bigbinary/neetoui/formik/Input');
54
- require('@bigbinary/neeto-molecules/OptionFields');
55
- require('framer-motion');
56
- require('@bigbinary/neetoui/formik/Radio');
57
- require('@bigbinary/neetoui/Label');
58
- require('react-select/creatable');
59
- require('@babel/runtime/helpers/toArray');
60
- require('@bigbinary/neeto-icons/Close');
61
- require('@bigbinary/neetoui/Tag');
62
- require('react-select');
63
- require('@babel/runtime/helpers/asyncToGenerator');
64
- require('@babel/runtime/regenerator');
65
- require('@bigbinary/neetoui/formik/Checkbox');
66
- require('@bigbinary/neetoui/Checkbox');
67
- require('@bigbinary/neetoui/Slider');
68
- require('@bigbinary/neeto-molecules/HelpPopover');
69
- require('@bigbinary/neeto-hotkeys');
70
- require('@bigbinary/neeto-icons/Warning');
71
- require('@bigbinary/neeto-molecules/PageLoader');
72
- require('@bigbinary/neetoui/Callout');
73
- require('@bigbinary/neeto-icons/Check');
74
- require('../utils-DEBFghm4.js');
75
- require('libphonenumber-js');
76
- require('@bigbinary/neeto-editor/EditorContent');
77
- require('@bigbinary/neetoui/MultiEmailInput');
78
- require('@bigbinary/neeto-molecules/PhoneNumber');
79
- require('@bigbinary/neetoui/Select');
80
- require('@bigbinary/neetoui/Input');
81
- require('@bigbinary/neeto-icons/Refresh');
82
- require('@bigbinary/neeto-commons-frontend/initializers');
83
- require('react-google-recaptcha');
84
- require('@bigbinary/neetoui/DatePicker');
85
- require('@bigbinary/neetoui/Toastr');
86
- require('axios');
87
- require('@bigbinary/neeto-icons/CheckCircle');
88
- require('@bigbinary/neeto-molecules/FileUpload');
89
- require('@bigbinary/neetoui/Radio');
90
- require('@bigbinary/neeto-icons/Image');
91
- require('@bigbinary/neetoui/Textarea');
92
- require('@honeybadger-io/js');
93
- require('@bigbinary/neeto-molecules/CopyToClipboardButton');
94
- require('@bigbinary/neeto-commons-frontend/constants');
95
- require('zustand');
96
-
97
-
98
-
99
- exports.BuildForm = BuildForm;
100
- exports.NeetoFormProvider = NeetoFormProvider;
101
- exports.ExternalForm = ExternalForm;
102
- exports.Submission = Submission;
103
- exports.UrlBuilder = UrlBuilder;
104
- exports.useCreateForm = constants.useCreateForm;
105
- exports.useDeleteForm = constants.useDeleteForm;
106
- exports.useForm = constants.useForm;
107
- exports.useForms = constants.useForms;
108
- exports.usePublicForm = constants.usePublicForm;
109
- exports.useUpdateForm = constants.useUpdateForm;
110
- exports.useFormSubmission = useFormSubmission.useFormSubmission;
111
- exports.useBuildFormState = buildForm.useBuildFormState;
112
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,493 +0,0 @@
1
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
2
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
- import { useQueryClient, useMutation, useQuery, keepPreviousData } from '@tanstack/react-query';
5
- import i18next from 'i18next';
6
- import { filterNonNull } from '@bigbinary/neeto-cist';
7
- import { DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE } from '@bigbinary/neeto-commons-frontend/constants';
8
- import { useMutationWithInvalidation } from '@bigbinary/neeto-commons-frontend/react-utils';
9
- import { assoc, mergeLeft, pick } from 'ramda';
10
- import axios from 'axios';
11
- import { buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
12
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
13
-
14
- var BASE_URL = "/neeto_form";
15
- var BASIC_FORM_ATTRIBUTES = ["title", "slug", "enabled", "questions"];
16
- var QUERY_KEYS = {
17
- QUESTIONS: "neetoFormQuestions",
18
- SUBMISSIONS: "neetoFormSubmissions",
19
- SUBMISSION: "neetoFormSubmission",
20
- FORMS: "neetoFormForms"};
21
- var FORMS_URL = "".concat(BASE_URL, "/api/v1/forms");
22
- var FORM_URL = "".concat(FORMS_URL, "/:formId");
23
- var QUESTIONS_URL = "".concat(FORM_URL, "/questions");
24
- var QUESTION_URL = "".concat(QUESTIONS_URL, "/:questionId");
25
- var PUBLIC_QUESTIONS_URL = "".concat(FORM_URL, "/public/questions");
26
- var REORDER_QUESTIONS_URL = "".concat(QUESTIONS_URL, "/reorder");
27
- var QUESTION_RESPONSES_URL = "".concat(FORM_URL, "/question_responses");
28
- var PUBLIC_QUESTION_RESPONSES_URL = "".concat(FORM_URL, "/public/question_responses");
29
- var SUBMISSIONS_URL = "".concat(FORM_URL, "/submissions");
30
- var SUBMISSION_URL = "".concat(SUBMISSIONS_URL, "/:submissionId");
31
- var PUBLIC_SUBMISSION_URL = "".concat(FORM_URL, "/public/submissions/:submissionId");
32
- var EMAIL_VERIFICATIONS_CREATE_URL = "".concat(FORM_URL, "/public/email_verifications");
33
- var EMAIL_VERIFICATIONS_VERIFY_URL = "".concat(FORM_URL, "/public/email_verifications/verify");
34
-
35
- var getForms = function getForms(params) {
36
- return axios.get(FORMS_URL, {
37
- params: params
38
- });
39
- };
40
- var createForm = function createForm(payload) {
41
- return axios.post(FORMS_URL, payload);
42
- };
43
- var updateForm = function updateForm(formId, payload) {
44
- return axios.patch(buildUrl(FORM_URL, {
45
- formId: formId
46
- }), payload);
47
- };
48
- var destroyForm = function destroyForm(formId) {
49
- return axios["delete"](buildUrl(FORM_URL, {
50
- formId: formId
51
- }));
52
- };
53
- var getQuestions = function getQuestions(formId) {
54
- var language = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i18next.resolvedLanguage;
55
- return axios.get(buildUrl(QUESTIONS_URL, {
56
- formId: formId
57
- }), {
58
- params: {
59
- language: language
60
- }
61
- });
62
- };
63
- var getPublicQuestions = function getPublicQuestions(formId) {
64
- var language = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i18next.resolvedLanguage;
65
- return axios.get(buildUrl(PUBLIC_QUESTIONS_URL, {
66
- formId: formId
67
- }), {
68
- params: {
69
- language: language
70
- }
71
- });
72
- };
73
- var createQuestion = function createQuestion(formId, payload) {
74
- return axios.post(buildUrl(QUESTIONS_URL, {
75
- formId: formId
76
- }), payload);
77
- };
78
- var updateQuestion = function updateQuestion(_ref) {
79
- var formId = _ref.formId,
80
- questionId = _ref.questionId,
81
- payload = _ref.payload;
82
- return axios.patch(buildUrl(QUESTION_URL, {
83
- formId: formId,
84
- questionId: questionId
85
- }), payload);
86
- };
87
- var deleteQuestion = function deleteQuestion(formId, questionId) {
88
- return axios["delete"](buildUrl(QUESTION_URL, {
89
- formId: formId,
90
- questionId: questionId
91
- }));
92
- };
93
- var reorderQuestions = function reorderQuestions(formId, payload) {
94
- return axios.post(buildUrl(REORDER_QUESTIONS_URL, {
95
- formId: formId
96
- }), payload);
97
- };
98
- var submitPublicForm = function submitPublicForm(formId, payload) {
99
- return axios.post(buildUrl(PUBLIC_QUESTION_RESPONSES_URL, {
100
- formId: formId
101
- }), payload);
102
- };
103
- var updatePublicSubmission = function updatePublicSubmission(formId, payload) {
104
- return axios.put(buildUrl(PUBLIC_QUESTION_RESPONSES_URL, {
105
- formId: formId
106
- }), payload);
107
- };
108
- var getPublicSubmission = function getPublicSubmission(formId, submissionId) {
109
- var language = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : i18next.resolvedLanguage;
110
- return axios.get(buildUrl(PUBLIC_SUBMISSION_URL, {
111
- formId: formId,
112
- submissionId: submissionId
113
- }), {
114
- params: {
115
- language: language
116
- }
117
- });
118
- };
119
- var getSubmissions = function getSubmissions(formId) {
120
- var language = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i18next.resolvedLanguage;
121
- return axios.get(buildUrl(SUBMISSIONS_URL, {
122
- formId: formId
123
- }), {
124
- params: {
125
- language: language
126
- }
127
- });
128
- };
129
- var getSubmission = function getSubmission(formId, submissionId) {
130
- var language = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : i18next.resolvedLanguage;
131
- return axios.get(buildUrl(SUBMISSION_URL, {
132
- formId: formId,
133
- submissionId: submissionId
134
- }), {
135
- params: {
136
- language: language
137
- }
138
- });
139
- };
140
- var updateSubmission = function updateSubmission(formId, payload) {
141
- return axios.put(buildUrl(QUESTION_RESPONSES_URL, {
142
- formId: formId
143
- }), payload);
144
- };
145
- var neetoFormApi = {
146
- getForms: getForms,
147
- createForm: createForm,
148
- updateForm: updateForm,
149
- destroyForm: destroyForm,
150
- getQuestions: getQuestions,
151
- getPublicQuestions: getPublicQuestions,
152
- createQuestion: createQuestion,
153
- updateQuestion: updateQuestion,
154
- deleteQuestion: deleteQuestion,
155
- reorderQuestions: reorderQuestions,
156
- submitPublicForm: submitPublicForm,
157
- getSubmissions: getSubmissions,
158
- getSubmission: getSubmission,
159
- getPublicSubmission: getPublicSubmission,
160
- updateSubmission: updateSubmission,
161
- updatePublicSubmission: updatePublicSubmission
162
- };
163
-
164
- var handleQuestionMutationSuccess = function handleQuestionMutationSuccess(_ref) {
165
- var args = _ref.args,
166
- formId = _ref.formId,
167
- language = _ref.language,
168
- queryClient = _ref.queryClient,
169
- onSuccess = _ref.onSuccess;
170
- var _args = _slicedToArray(args, 1),
171
- data = _args[0];
172
- queryClient.invalidateQueries({
173
- queryKey: [QUERY_KEYS.QUESTIONS, formId]
174
- });
175
- queryClient.invalidateQueries({
176
- queryKey: [QUERY_KEYS.QUESTIONS, "preview/".concat(formId)]
177
- });
178
- queryClient.setQueryData([QUERY_KEYS.QUESTIONS, formId, language], assoc("questions", data.questions));
179
- queryClient.setQueryData([QUERY_KEYS.QUESTIONS, "preview/".concat(formId), language], assoc("questions", data.questions));
180
- onSuccess === null || onSuccess === void 0 || onSuccess.apply(void 0, _toConsumableArray(args));
181
- };
182
-
183
- var _excluded = ["formId", "preview", "language"],
184
- _excluded2 = ["formId", "language"],
185
- _excluded3 = ["page", "pageSize"],
186
- _excluded5 = ["formId", "submissionId", "fetchPublicSubmission"];
187
- function ownKeys(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; }
188
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
189
- var usePublicForm = function usePublicForm(_ref) {
190
- var formId = _ref.formId,
191
- _ref$preview = _ref.preview,
192
- preview = _ref$preview === void 0 ? null : _ref$preview,
193
- _ref$language = _ref.language,
194
- language = _ref$language === void 0 ? i18next.resolvedLanguage : _ref$language,
195
- options = _objectWithoutProperties(_ref, _excluded);
196
- return useQuery(_objectSpread({
197
- queryKey: [QUERY_KEYS.QUESTIONS, preview ? "preview/".concat(formId) : formId, language],
198
- queryFn: function queryFn() {
199
- return neetoFormApi.getPublicQuestions(formId, language);
200
- },
201
- placeholderData: keepPreviousData
202
- }, options));
203
- };
204
- var useForm = function useForm(_ref2) {
205
- var formId = _ref2.formId,
206
- _ref2$language = _ref2.language,
207
- language = _ref2$language === void 0 ? i18next.resolvedLanguage : _ref2$language,
208
- options = _objectWithoutProperties(_ref2, _excluded2);
209
- return useQuery(_objectSpread({
210
- queryKey: [QUERY_KEYS.QUESTIONS, formId, language],
211
- queryFn: function queryFn() {
212
- return neetoFormApi.getQuestions(formId, language);
213
- },
214
- placeholderData: keepPreviousData
215
- }, options));
216
- };
217
- var useCreateForm = function useCreateForm(options) {
218
- var language = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i18next.resolvedLanguage;
219
- var queryClient = useQueryClient();
220
- return useMutation(_objectSpread(_objectSpread({
221
- mutationFn: neetoFormApi.createForm
222
- }, options), {}, {
223
- onSuccess: function onSuccess(form) {
224
- var _options$onSuccess;
225
- queryClient.setQueryData([QUERY_KEYS.QUESTIONS], function (forms) {
226
- return forms && [].concat(_toConsumableArray(forms), [form]);
227
- });
228
- queryClient.setQueryData([QUERY_KEYS.QUESTIONS, form.id, language], form);
229
- queryClient.setQueryData([QUERY_KEYS.QUESTIONS, "preview/".concat(form.id), language], form);
230
- queryClient.invalidateQueries({
231
- queryKey: [QUERY_KEYS.FORMS]
232
- });
233
- options === null || options === void 0 || (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 || _options$onSuccess.call(options, form);
234
- }
235
- }));
236
- };
237
- var useUpdateForm = function useUpdateForm(options) {
238
- var language = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i18next.resolvedLanguage;
239
- var queryClient = useQueryClient();
240
- return useMutation(_objectSpread(_objectSpread({
241
- mutationFn: function mutationFn(_ref3) {
242
- var id = _ref3.id,
243
- values = _ref3.values;
244
- return neetoFormApi.updateForm(id, values);
245
- }
246
- }, options), {}, {
247
- onSuccess: function onSuccess(data, _ref4) {
248
- var id = _ref4.id;
249
- queryClient.setQueryData([QUERY_KEYS.QUESTIONS, id, language], mergeLeft(pick(BASIC_FORM_ATTRIBUTES, data)));
250
- queryClient.setQueryData([QUERY_KEYS.QUESTIONS, "preview/".concat(id), language], mergeLeft(pick(BASIC_FORM_ATTRIBUTES, data)));
251
- queryClient.invalidateQueries({
252
- queryKey: [QUERY_KEYS.FORMS]
253
- });
254
- queryClient.invalidateQueries({
255
- queryKey: [QUERY_KEYS.QUESTIONS, id]
256
- });
257
- queryClient.invalidateQueries({
258
- queryKey: [QUERY_KEYS.QUESTIONS, "preview/".concat(id)]
259
- });
260
- options.onSuccess && options.onSuccess(data);
261
- }
262
- }));
263
- };
264
- var useCreateQuestion = function useCreateQuestion(formId, language) {
265
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
266
- var queryClient = useQueryClient();
267
- return useMutation(_objectSpread(_objectSpread({
268
- mutationFn: function mutationFn(payload) {
269
- return neetoFormApi.createQuestion(formId, filterNonNull(payload));
270
- }
271
- }, options), {}, {
272
- onSuccess: function onSuccess() {
273
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
274
- args[_key] = arguments[_key];
275
- }
276
- return handleQuestionMutationSuccess({
277
- args: args,
278
- formId: formId,
279
- language: language,
280
- queryClient: queryClient,
281
- onSuccess: options.onSuccess
282
- });
283
- }
284
- }));
285
- };
286
- var useUpdateQuestion = function useUpdateQuestion(formId, language) {
287
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
288
- var queryClient = useQueryClient();
289
- return useMutation(_objectSpread(_objectSpread({
290
- mutationFn: function mutationFn(_ref5) {
291
- var questionId = _ref5.questionId,
292
- payload = _ref5.payload;
293
- return neetoFormApi.updateQuestion({
294
- formId: formId,
295
- questionId: questionId,
296
- payload: filterNonNull(payload)
297
- });
298
- }
299
- }, options), {}, {
300
- onSuccess: function onSuccess() {
301
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
302
- args[_key2] = arguments[_key2];
303
- }
304
- return handleQuestionMutationSuccess({
305
- args: args,
306
- formId: formId,
307
- language: language,
308
- queryClient: queryClient,
309
- onSuccess: options.onSuccess
310
- });
311
- }
312
- }));
313
- };
314
- var useDeleteQuestion = function useDeleteQuestion(formId, language) {
315
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
316
- var queryClient = useQueryClient();
317
- return useMutation(_objectSpread(_objectSpread({
318
- mutationFn: function mutationFn(questionId) {
319
- return neetoFormApi.deleteQuestion(formId, questionId);
320
- }
321
- }, options), {}, {
322
- onSuccess: function onSuccess() {
323
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
324
- args[_key3] = arguments[_key3];
325
- }
326
- return handleQuestionMutationSuccess({
327
- args: args,
328
- formId: formId,
329
- language: language,
330
- queryClient: queryClient,
331
- onSuccess: options.onSuccess
332
- });
333
- }
334
- }));
335
- };
336
- var useReorderQuestions = function useReorderQuestions(formId, language) {
337
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
338
- var queryClient = useQueryClient();
339
- return useMutation(_objectSpread(_objectSpread({
340
- mutationFn: function mutationFn(payload) {
341
- return neetoFormApi.reorderQuestions(formId, filterNonNull(payload));
342
- }
343
- }, options), {}, {
344
- onSuccess: function onSuccess() {
345
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
346
- args[_key4] = arguments[_key4];
347
- }
348
- return handleQuestionMutationSuccess({
349
- args: args,
350
- formId: formId,
351
- language: language,
352
- queryClient: queryClient,
353
- onSuccess: options.onSuccess
354
- });
355
- }
356
- }));
357
- };
358
- var useForms = function useForms() {
359
- var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
360
- _ref6$page = _ref6.page,
361
- page = _ref6$page === void 0 ? DEFAULT_PAGE_INDEX : _ref6$page,
362
- _ref6$pageSize = _ref6.pageSize,
363
- pageSize = _ref6$pageSize === void 0 ? DEFAULT_PAGE_SIZE : _ref6$pageSize,
364
- options = _objectWithoutProperties(_ref6, _excluded3);
365
- return useQuery(_objectSpread({
366
- queryKey: [QUERY_KEYS.FORMS, page],
367
- queryFn: function queryFn() {
368
- return neetoFormApi.getForms({
369
- page: page,
370
- pageSize: pageSize
371
- });
372
- },
373
- placeholderData: keepPreviousData
374
- }, options));
375
- };
376
- var useDeleteForm = function useDeleteForm(options) {
377
- return useMutationWithInvalidation(function (_ref7) {
378
- var id = _ref7.id;
379
- return neetoFormApi.destroyForm(id);
380
- }, _objectSpread(_objectSpread({}, options), {}, {
381
- keysToInvalidate: [[QUERY_KEYS.FORMS], function (_, _ref8) {
382
- var id = _ref8.id;
383
- return [QUERY_KEYS.QUESTIONS, id];
384
- }, function (_, _ref9) {
385
- var id = _ref9.id;
386
- return [QUERY_KEYS.QUESTIONS, "preview/".concat(id)];
387
- }],
388
- onSuccess: function onSuccess() {
389
- options.onSuccess && options.onSuccess.apply(options, arguments);
390
- }
391
- }));
392
- };
393
- var useSubmission = function useSubmission(_ref11) {
394
- var formId = _ref11.formId,
395
- submissionId = _ref11.submissionId,
396
- _ref11$fetchPublicSub = _ref11.fetchPublicSubmission,
397
- fetchPublicSubmission = _ref11$fetchPublicSub === void 0 ? true : _ref11$fetchPublicSub,
398
- options = _objectWithoutProperties(_ref11, _excluded5);
399
- return useQuery(_objectSpread({
400
- queryKey: [QUERY_KEYS.SUBMISSION, formId, submissionId],
401
- queryFn: function queryFn() {
402
- return fetchPublicSubmission ? neetoFormApi.getPublicSubmission(formId, submissionId) : neetoFormApi.getSubmission(formId, submissionId);
403
- },
404
- placeholderData: keepPreviousData
405
- }, options));
406
- };
407
- var useCreateSubmission = function useCreateSubmission(options) {
408
- var queryClient = useQueryClient();
409
- return useMutation(_objectSpread(_objectSpread({
410
- mutationFn: function mutationFn(_ref12) {
411
- var formId = _ref12.formId,
412
- values = _ref12.values;
413
- return neetoFormApi.submitPublicForm(formId, values);
414
- }
415
- }, options), {}, {
416
- onSuccess: function onSuccess() {
417
- var _data$submission, _data$submission2;
418
- for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
419
- args[_key5] = arguments[_key5];
420
- }
421
- var data = args[0],
422
- formId = args[1].formId;
423
- queryClient.invalidateQueries({
424
- queryKey: [QUERY_KEYS.SUBMISSIONS, formId]
425
- });
426
- 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);
427
- queryClient.invalidateQueries({
428
- queryKey: [QUERY_KEYS.SUBMISSION, formId, data === null || data === void 0 || (_data$submission2 = data.submission) === null || _data$submission2 === void 0 ? void 0 : _data$submission2.id]
429
- });
430
- options.onSuccess && options.onSuccess.apply(options, args);
431
- }
432
- }));
433
- };
434
- var useUpdateSubmission = function useUpdateSubmission(options) {
435
- var queryClient = useQueryClient();
436
- return useMutation(_objectSpread(_objectSpread({
437
- mutationFn: function mutationFn(_ref13) {
438
- var formId = _ref13.formId,
439
- values = _ref13.values;
440
- return neetoFormApi.updatePublicSubmission(formId, values);
441
- }
442
- }, options), {}, {
443
- onSuccess: function onSuccess() {
444
- var _data$submission3;
445
- for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
446
- args[_key6] = arguments[_key6];
447
- }
448
- var data = args[0],
449
- formId = args[1].formId;
450
- queryClient.invalidateQueries({
451
- queryKey: [[QUERY_KEYS.SUBMISSIONS, formId]]
452
- });
453
- queryClient.setQueryData([QUERY_KEYS.SUBMISSION, formId, data === null || data === void 0 || (_data$submission3 = data.submission) === null || _data$submission3 === void 0 ? void 0 : _data$submission3.id], data === null || data === void 0 ? void 0 : data.submission);
454
- queryClient.invalidateQueries({
455
- queryKey: [[QUERY_KEYS.SUBMISSION, formId, data.submission.id]]
456
- });
457
- options.onSuccess && options.onSuccess.apply(options, args);
458
- }
459
- }));
460
- };
461
-
462
- var QUESTION_TYPES = {
463
- NAME: "name",
464
- PHONE: "phone",
465
- EMAIL: "email",
466
- ADDITIONAL_GUESTS: "additional_guests",
467
- TEXT: "text",
468
- TEXTAREA: "textarea",
469
- RICH_TEXT: "rich_text",
470
- INTEGER: "integer",
471
- DECIMAL: "decimal",
472
- PARAGRAPH: "paragraph",
473
- TERMS_AND_CONDITION: "termsandcondition",
474
- CONDITION: "condition",
475
- CHECKBOX: "checkbox",
476
- RADIO: "radio",
477
- DROPDOWN: "dropdown",
478
- STAR_RATING: "star_rating",
479
- OPINION_SCALE: "opinion_scale",
480
- RATING: "rating",
481
- DATE: "date",
482
- FILE_UPLOAD: "file_upload",
483
- CAPTCHA: "captcha",
484
- SMS_REMINDER: "sms_reminder",
485
- ADDRESS: "address"
486
- };
487
- var CAPTCHA_TYPES = {
488
- RECAPTCHA_V2: "recaptcha_v2",
489
- MATH_CAPTCHA: "math_captcha"
490
- };
491
-
492
- export { CAPTCHA_TYPES as C, EMAIL_VERIFICATIONS_CREATE_URL as E, QUESTION_TYPES as Q, useDeleteForm as a, useForm as b, useForms as c, usePublicForm as d, useUpdateForm as e, useSubmission as f, useCreateSubmission as g, useUpdateSubmission as h, QUERY_KEYS as i, EMAIL_VERIFICATIONS_VERIFY_URL as j, useDeleteQuestion as k, useCreateQuestion as l, useUpdateQuestion as m, useReorderQuestions as n, useCreateForm as u };
493
- //# sourceMappingURL=constants-BNfHPNOx.js.map