@bigbinary/neeto-form-frontend 4.4.5 → 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 +11 -15
  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-Bdc3ubm4.js +0 -38
  16. package/dist/buildForm-Bdc3ubm4.js.map +0 -1
  17. package/dist/buildForm-CkVmGF-A.js +0 -35
  18. package/dist/buildForm-CkVmGF-A.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-30230o5k.js +0 -496
  34. package/dist/constants-30230o5k.js.map +0 -1
  35. package/dist/constants-DNNZYQ9X.js +0 -515
  36. package/dist/constants-DNNZYQ9X.js.map +0 -1
  37. package/dist/hooks.js +0 -20
  38. package/dist/hooks.js.map +0 -1
  39. package/dist/index-BfavwyMH.js +0 -43
  40. package/dist/index-BfavwyMH.js.map +0 -1
  41. package/dist/index-Dz5Yvk3n.js +0 -51
  42. package/dist/index-Dz5Yvk3n.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-CdKlP6De.js +0 -24
  48. package/dist/useFormSubmission-CdKlP6De.js.map +0 -1
  49. package/dist/useFormSubmission-zyh3tA0H.js +0 -22
  50. package/dist/useFormSubmission-zyh3tA0H.js.map +0 -1
  51. package/dist/utils-BRC5Gg_A.js +0 -2641
  52. package/dist/utils-BRC5Gg_A.js.map +0 -1
  53. package/dist/utils-DklENIyr.js +0 -2610
  54. package/dist/utils-DklENIyr.js.map +0 -1
  55. package/dist/yup-B3B89G9K.js +0 -1074
  56. package/dist/yup-B3B89G9K.js.map +0 -1
  57. package/dist/yup-DL9p9dFl.js +0 -994
  58. package/dist/yup-DL9p9dFl.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-DNNZYQ9X.js');
9
- var useFormSubmission = require('../useFormSubmission-CdKlP6De.js');
10
- var buildForm = require('../buildForm-Bdc3ubm4.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-B3B89G9K.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-Dz5Yvk3n.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-BRC5Gg_A.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,496 +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 { useQuery, useQueryClient, useMutation, 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
- FORM: "neetoFormForm",
22
- FORMIK: "neetoFormFormik"
23
- };
24
- var FORMS_URL = "".concat(BASE_URL, "/api/v1/forms");
25
- var FORM_URL = "".concat(FORMS_URL, "/:formId");
26
- var QUESTIONS_URL = "".concat(FORM_URL, "/questions");
27
- var QUESTION_URL = "".concat(QUESTIONS_URL, "/:questionId");
28
- var PUBLIC_QUESTIONS_URL = "".concat(FORM_URL, "/public/questions");
29
- var REORDER_QUESTIONS_URL = "".concat(QUESTIONS_URL, "/reorder");
30
- var QUESTION_RESPONSES_URL = "".concat(FORM_URL, "/question_responses");
31
- var PUBLIC_QUESTION_RESPONSES_URL = "".concat(FORM_URL, "/public/question_responses");
32
- var SUBMISSIONS_URL = "".concat(FORM_URL, "/submissions");
33
- var SUBMISSION_URL = "".concat(SUBMISSIONS_URL, "/:submissionId");
34
- var PUBLIC_SUBMISSION_URL = "".concat(FORM_URL, "/public/submissions/:submissionId");
35
- var EMAIL_VERIFICATIONS_CREATE_URL = "".concat(FORM_URL, "/public/email_verifications");
36
- var EMAIL_VERIFICATIONS_VERIFY_URL = "".concat(FORM_URL, "/public/email_verifications/verify");
37
-
38
- var getForms = function getForms(params) {
39
- return axios.get(FORMS_URL, {
40
- params: params
41
- });
42
- };
43
- var createForm = function createForm(payload) {
44
- return axios.post(FORMS_URL, payload);
45
- };
46
- var updateForm = function updateForm(formId, payload) {
47
- return axios.patch(buildUrl(FORM_URL, {
48
- formId: formId
49
- }), payload);
50
- };
51
- var destroyForm = function destroyForm(formId) {
52
- return axios["delete"](buildUrl(FORM_URL, {
53
- formId: formId
54
- }));
55
- };
56
- var getQuestions = function getQuestions(formId) {
57
- var language = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i18next.resolvedLanguage;
58
- return axios.get(buildUrl(QUESTIONS_URL, {
59
- formId: formId
60
- }), {
61
- params: {
62
- language: language
63
- }
64
- });
65
- };
66
- var getPublicQuestions = function getPublicQuestions(formId) {
67
- var language = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i18next.resolvedLanguage;
68
- return axios.get(buildUrl(PUBLIC_QUESTIONS_URL, {
69
- formId: formId
70
- }), {
71
- params: {
72
- language: language
73
- }
74
- });
75
- };
76
- var createQuestion = function createQuestion(formId, payload) {
77
- return axios.post(buildUrl(QUESTIONS_URL, {
78
- formId: formId
79
- }), payload);
80
- };
81
- var updateQuestion = function updateQuestion(_ref) {
82
- var formId = _ref.formId,
83
- questionId = _ref.questionId,
84
- payload = _ref.payload;
85
- return axios.patch(buildUrl(QUESTION_URL, {
86
- formId: formId,
87
- questionId: questionId
88
- }), payload);
89
- };
90
- var deleteQuestion = function deleteQuestion(formId, questionId) {
91
- return axios["delete"](buildUrl(QUESTION_URL, {
92
- formId: formId,
93
- questionId: questionId
94
- }));
95
- };
96
- var reorderQuestions = function reorderQuestions(formId, payload) {
97
- return axios.post(buildUrl(REORDER_QUESTIONS_URL, {
98
- formId: formId
99
- }), payload);
100
- };
101
- var submitPublicForm = function submitPublicForm(formId, payload) {
102
- return axios.post(buildUrl(PUBLIC_QUESTION_RESPONSES_URL, {
103
- formId: formId
104
- }), payload);
105
- };
106
- var updatePublicSubmission = function updatePublicSubmission(formId, payload) {
107
- return axios.put(buildUrl(PUBLIC_QUESTION_RESPONSES_URL, {
108
- formId: formId
109
- }), payload);
110
- };
111
- var getPublicSubmission = function getPublicSubmission(formId, submissionId) {
112
- var language = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : i18next.resolvedLanguage;
113
- return axios.get(buildUrl(PUBLIC_SUBMISSION_URL, {
114
- formId: formId,
115
- submissionId: submissionId
116
- }), {
117
- params: {
118
- language: language
119
- }
120
- });
121
- };
122
- var getSubmissions = function getSubmissions(formId) {
123
- var language = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i18next.resolvedLanguage;
124
- return axios.get(buildUrl(SUBMISSIONS_URL, {
125
- formId: formId
126
- }), {
127
- params: {
128
- language: language
129
- }
130
- });
131
- };
132
- var getSubmission = function getSubmission(formId, submissionId) {
133
- var language = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : i18next.resolvedLanguage;
134
- return axios.get(buildUrl(SUBMISSION_URL, {
135
- formId: formId,
136
- submissionId: submissionId
137
- }), {
138
- params: {
139
- language: language
140
- }
141
- });
142
- };
143
- var updateSubmission = function updateSubmission(formId, payload) {
144
- return axios.put(buildUrl(QUESTION_RESPONSES_URL, {
145
- formId: formId
146
- }), payload);
147
- };
148
- var neetoFormApi = {
149
- getForms: getForms,
150
- createForm: createForm,
151
- updateForm: updateForm,
152
- destroyForm: destroyForm,
153
- getQuestions: getQuestions,
154
- getPublicQuestions: getPublicQuestions,
155
- createQuestion: createQuestion,
156
- updateQuestion: updateQuestion,
157
- deleteQuestion: deleteQuestion,
158
- reorderQuestions: reorderQuestions,
159
- submitPublicForm: submitPublicForm,
160
- getSubmissions: getSubmissions,
161
- getSubmission: getSubmission,
162
- getPublicSubmission: getPublicSubmission,
163
- updateSubmission: updateSubmission,
164
- updatePublicSubmission: updatePublicSubmission
165
- };
166
-
167
- var handleQuestionMutationSuccess = function handleQuestionMutationSuccess(_ref) {
168
- var args = _ref.args,
169
- formId = _ref.formId,
170
- language = _ref.language,
171
- queryClient = _ref.queryClient,
172
- onSuccess = _ref.onSuccess;
173
- var _args = _slicedToArray(args, 1),
174
- data = _args[0];
175
- queryClient.invalidateQueries({
176
- queryKey: [QUERY_KEYS.QUESTIONS, formId]
177
- });
178
- queryClient.invalidateQueries({
179
- queryKey: [QUERY_KEYS.QUESTIONS, "preview/".concat(formId)]
180
- });
181
- queryClient.setQueryData([QUERY_KEYS.QUESTIONS, formId, language], assoc("questions", data.questions));
182
- queryClient.setQueryData([QUERY_KEYS.QUESTIONS, "preview/".concat(formId), language], assoc("questions", data.questions));
183
- onSuccess === null || onSuccess === void 0 || onSuccess.apply(void 0, _toConsumableArray(args));
184
- };
185
-
186
- var _excluded = ["formId", "preview", "language"],
187
- _excluded2 = ["formId", "language"],
188
- _excluded3 = ["page", "pageSize"],
189
- _excluded5 = ["formId", "submissionId", "fetchPublicSubmission"];
190
- 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; }
191
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).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; }
192
- var usePublicForm = function usePublicForm(_ref) {
193
- var formId = _ref.formId,
194
- _ref$preview = _ref.preview,
195
- preview = _ref$preview === void 0 ? null : _ref$preview,
196
- _ref$language = _ref.language,
197
- language = _ref$language === void 0 ? i18next.resolvedLanguage : _ref$language,
198
- options = _objectWithoutProperties(_ref, _excluded);
199
- return useQuery(_objectSpread({
200
- queryKey: [QUERY_KEYS.QUESTIONS, preview ? "preview/".concat(formId) : formId, language],
201
- queryFn: function queryFn() {
202
- return neetoFormApi.getPublicQuestions(formId, language);
203
- },
204
- placeholderData: keepPreviousData
205
- }, options));
206
- };
207
- var useForm = function useForm(_ref2) {
208
- var formId = _ref2.formId,
209
- _ref2$language = _ref2.language,
210
- language = _ref2$language === void 0 ? i18next.resolvedLanguage : _ref2$language,
211
- options = _objectWithoutProperties(_ref2, _excluded2);
212
- return useQuery(_objectSpread({
213
- queryKey: [QUERY_KEYS.QUESTIONS, formId, language],
214
- queryFn: function queryFn() {
215
- return neetoFormApi.getQuestions(formId, language);
216
- },
217
- placeholderData: keepPreviousData
218
- }, options));
219
- };
220
- var useCreateForm = function useCreateForm(options) {
221
- var language = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i18next.resolvedLanguage;
222
- var queryClient = useQueryClient();
223
- return useMutation(_objectSpread(_objectSpread({
224
- mutationFn: neetoFormApi.createForm
225
- }, options), {}, {
226
- onSuccess: function onSuccess(form) {
227
- var _options$onSuccess;
228
- queryClient.setQueryData([QUERY_KEYS.QUESTIONS], function (forms) {
229
- return forms && [].concat(_toConsumableArray(forms), [form]);
230
- });
231
- queryClient.setQueryData([QUERY_KEYS.QUESTIONS, form.id, language], form);
232
- queryClient.setQueryData([QUERY_KEYS.QUESTIONS, "preview/".concat(form.id), language], form);
233
- queryClient.invalidateQueries({
234
- queryKey: [QUERY_KEYS.FORMS]
235
- });
236
- options === null || options === void 0 || (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 || _options$onSuccess.call(options, form);
237
- }
238
- }));
239
- };
240
- var useUpdateForm = function useUpdateForm(options) {
241
- var language = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : i18next.resolvedLanguage;
242
- var queryClient = useQueryClient();
243
- return useMutation(_objectSpread(_objectSpread({
244
- mutationFn: function mutationFn(_ref3) {
245
- var id = _ref3.id,
246
- values = _ref3.values;
247
- return neetoFormApi.updateForm(id, values);
248
- }
249
- }, options), {}, {
250
- onSuccess: function onSuccess(data, _ref4) {
251
- var id = _ref4.id;
252
- queryClient.setQueryData([QUERY_KEYS.QUESTIONS, id, language], mergeLeft(pick(BASIC_FORM_ATTRIBUTES, data)));
253
- queryClient.setQueryData([QUERY_KEYS.QUESTIONS, "preview/".concat(id), language], mergeLeft(pick(BASIC_FORM_ATTRIBUTES, data)));
254
- queryClient.invalidateQueries({
255
- queryKey: [QUERY_KEYS.FORMS]
256
- });
257
- queryClient.invalidateQueries({
258
- queryKey: [QUERY_KEYS.QUESTIONS, id]
259
- });
260
- queryClient.invalidateQueries({
261
- queryKey: [QUERY_KEYS.QUESTIONS, "preview/".concat(id)]
262
- });
263
- options.onSuccess && options.onSuccess(data);
264
- }
265
- }));
266
- };
267
- var useCreateQuestion = function useCreateQuestion(formId, language) {
268
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
269
- var queryClient = useQueryClient();
270
- return useMutation(_objectSpread(_objectSpread({
271
- mutationFn: function mutationFn(payload) {
272
- return neetoFormApi.createQuestion(formId, filterNonNull(payload));
273
- }
274
- }, options), {}, {
275
- onSuccess: function onSuccess() {
276
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
277
- args[_key] = arguments[_key];
278
- }
279
- return handleQuestionMutationSuccess({
280
- args: args,
281
- formId: formId,
282
- language: language,
283
- queryClient: queryClient,
284
- onSuccess: options.onSuccess
285
- });
286
- }
287
- }));
288
- };
289
- var useUpdateQuestion = function useUpdateQuestion(formId, language) {
290
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
291
- var queryClient = useQueryClient();
292
- return useMutation(_objectSpread(_objectSpread({
293
- mutationFn: function mutationFn(_ref5) {
294
- var questionId = _ref5.questionId,
295
- payload = _ref5.payload;
296
- return neetoFormApi.updateQuestion({
297
- formId: formId,
298
- questionId: questionId,
299
- payload: filterNonNull(payload)
300
- });
301
- }
302
- }, options), {}, {
303
- onSuccess: function onSuccess() {
304
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
305
- args[_key2] = arguments[_key2];
306
- }
307
- return handleQuestionMutationSuccess({
308
- args: args,
309
- formId: formId,
310
- language: language,
311
- queryClient: queryClient,
312
- onSuccess: options.onSuccess
313
- });
314
- }
315
- }));
316
- };
317
- var useDeleteQuestion = function useDeleteQuestion(formId, language) {
318
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
319
- var queryClient = useQueryClient();
320
- return useMutation(_objectSpread(_objectSpread({
321
- mutationFn: function mutationFn(questionId) {
322
- return neetoFormApi.deleteQuestion(formId, questionId);
323
- }
324
- }, options), {}, {
325
- onSuccess: function onSuccess() {
326
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
327
- args[_key3] = arguments[_key3];
328
- }
329
- return handleQuestionMutationSuccess({
330
- args: args,
331
- formId: formId,
332
- language: language,
333
- queryClient: queryClient,
334
- onSuccess: options.onSuccess
335
- });
336
- }
337
- }));
338
- };
339
- var useReorderQuestions = function useReorderQuestions(formId, language) {
340
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
341
- var queryClient = useQueryClient();
342
- return useMutation(_objectSpread(_objectSpread({
343
- mutationFn: function mutationFn(payload) {
344
- return neetoFormApi.reorderQuestions(formId, filterNonNull(payload));
345
- }
346
- }, options), {}, {
347
- onSuccess: function onSuccess() {
348
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
349
- args[_key4] = arguments[_key4];
350
- }
351
- return handleQuestionMutationSuccess({
352
- args: args,
353
- formId: formId,
354
- language: language,
355
- queryClient: queryClient,
356
- onSuccess: options.onSuccess
357
- });
358
- }
359
- }));
360
- };
361
- var useForms = function useForms() {
362
- var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
363
- _ref6$page = _ref6.page,
364
- page = _ref6$page === void 0 ? DEFAULT_PAGE_INDEX : _ref6$page,
365
- _ref6$pageSize = _ref6.pageSize,
366
- pageSize = _ref6$pageSize === void 0 ? DEFAULT_PAGE_SIZE : _ref6$pageSize,
367
- options = _objectWithoutProperties(_ref6, _excluded3);
368
- return useQuery(_objectSpread({
369
- queryKey: [QUERY_KEYS.FORMS, page],
370
- queryFn: function queryFn() {
371
- return neetoFormApi.getForms({
372
- page: page,
373
- pageSize: pageSize
374
- });
375
- },
376
- placeholderData: keepPreviousData
377
- }, options));
378
- };
379
- var useDeleteForm = function useDeleteForm(options) {
380
- return useMutationWithInvalidation(function (_ref7) {
381
- var id = _ref7.id;
382
- return neetoFormApi.destroyForm(id);
383
- }, _objectSpread(_objectSpread({}, options), {}, {
384
- keysToInvalidate: [[QUERY_KEYS.FORMS], function (_, _ref8) {
385
- var id = _ref8.id;
386
- return [QUERY_KEYS.QUESTIONS, id];
387
- }, function (_, _ref9) {
388
- var id = _ref9.id;
389
- return [QUERY_KEYS.QUESTIONS, "preview/".concat(id)];
390
- }],
391
- onSuccess: function onSuccess() {
392
- options.onSuccess && options.onSuccess.apply(options, arguments);
393
- }
394
- }));
395
- };
396
- var useSubmission = function useSubmission(_ref11) {
397
- var formId = _ref11.formId,
398
- submissionId = _ref11.submissionId,
399
- _ref11$fetchPublicSub = _ref11.fetchPublicSubmission,
400
- fetchPublicSubmission = _ref11$fetchPublicSub === void 0 ? true : _ref11$fetchPublicSub,
401
- options = _objectWithoutProperties(_ref11, _excluded5);
402
- return useQuery(_objectSpread({
403
- queryKey: [QUERY_KEYS.SUBMISSION, formId, submissionId],
404
- queryFn: function queryFn() {
405
- return fetchPublicSubmission ? neetoFormApi.getPublicSubmission(formId, submissionId) : neetoFormApi.getSubmission(formId, submissionId);
406
- },
407
- placeholderData: keepPreviousData
408
- }, options));
409
- };
410
- var useCreateSubmission = function useCreateSubmission(options) {
411
- var queryClient = useQueryClient();
412
- return useMutation(_objectSpread(_objectSpread({
413
- mutationFn: function mutationFn(_ref12) {
414
- var formId = _ref12.formId,
415
- values = _ref12.values;
416
- return neetoFormApi.submitPublicForm(formId, values);
417
- }
418
- }, options), {}, {
419
- onSuccess: function onSuccess() {
420
- var _data$submission, _data$submission2;
421
- for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
422
- args[_key5] = arguments[_key5];
423
- }
424
- var data = args[0],
425
- formId = args[1].formId;
426
- queryClient.invalidateQueries({
427
- queryKey: [QUERY_KEYS.SUBMISSIONS, formId]
428
- });
429
- 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);
430
- queryClient.invalidateQueries({
431
- queryKey: [QUERY_KEYS.SUBMISSION, formId, data === null || data === void 0 || (_data$submission2 = data.submission) === null || _data$submission2 === void 0 ? void 0 : _data$submission2.id]
432
- });
433
- options.onSuccess && options.onSuccess.apply(options, args);
434
- }
435
- }));
436
- };
437
- var useUpdateSubmission = function useUpdateSubmission(options) {
438
- var queryClient = useQueryClient();
439
- return useMutation(_objectSpread(_objectSpread({
440
- mutationFn: function mutationFn(_ref13) {
441
- var formId = _ref13.formId,
442
- values = _ref13.values;
443
- return neetoFormApi.updatePublicSubmission(formId, values);
444
- }
445
- }, options), {}, {
446
- onSuccess: function onSuccess() {
447
- var _data$submission3;
448
- for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
449
- args[_key6] = arguments[_key6];
450
- }
451
- var data = args[0],
452
- formId = args[1].formId;
453
- queryClient.invalidateQueries({
454
- queryKey: [[QUERY_KEYS.SUBMISSIONS, formId]]
455
- });
456
- 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);
457
- queryClient.invalidateQueries({
458
- queryKey: [[QUERY_KEYS.SUBMISSION, formId, data.submission.id]]
459
- });
460
- options.onSuccess && options.onSuccess.apply(options, args);
461
- }
462
- }));
463
- };
464
-
465
- var QUESTION_TYPES = {
466
- NAME: "name",
467
- PHONE: "phone",
468
- EMAIL: "email",
469
- ADDITIONAL_GUESTS: "additional_guests",
470
- TEXT: "text",
471
- TEXTAREA: "textarea",
472
- RICH_TEXT: "rich_text",
473
- INTEGER: "integer",
474
- DECIMAL: "decimal",
475
- PARAGRAPH: "paragraph",
476
- TERMS_AND_CONDITION: "termsandcondition",
477
- CONDITION: "condition",
478
- CHECKBOX: "checkbox",
479
- RADIO: "radio",
480
- DROPDOWN: "dropdown",
481
- STAR_RATING: "star_rating",
482
- OPINION_SCALE: "opinion_scale",
483
- RATING: "rating",
484
- DATE: "date",
485
- FILE_UPLOAD: "file_upload",
486
- CAPTCHA: "captcha",
487
- SMS_REMINDER: "sms_reminder",
488
- ADDRESS: "address"
489
- };
490
- var CAPTCHA_TYPES = {
491
- RECAPTCHA_V2: "recaptcha_v2",
492
- MATH_CAPTCHA: "math_captcha"
493
- };
494
-
495
- export { CAPTCHA_TYPES as C, EMAIL_VERIFICATIONS_CREATE_URL as E, QUESTION_TYPES as Q, useForm as a, usePublicForm as b, useCreateForm as c, useUpdateForm as d, useDeleteForm 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, useForms as u };
496
- //# sourceMappingURL=constants-30230o5k.js.map