@bigbinary/neeto-form-frontend 3.0.4 → 3.0.5
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/app/javascript/src/translations/en.json +3 -1
- package/dist/index.cjs.js +46 -22
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +43 -21
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/types.d.ts +1 -0
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"select": "Select",
|
|
26
26
|
"selectOne": "Select one",
|
|
27
27
|
"required": "Required",
|
|
28
|
+
"hideQuestion": "Hide question",
|
|
28
29
|
"invalidURL": "Invalid URL",
|
|
29
30
|
"generateLink": "Generate link",
|
|
30
31
|
"paragraphCantBeEmpty": "Paragraph can't be empty",
|
|
@@ -76,7 +77,8 @@
|
|
|
76
77
|
"formSubmitted": "Form has been submitted successfully!"
|
|
77
78
|
},
|
|
78
79
|
"callouts": {
|
|
79
|
-
"submitError": "Couldn't submit the form"
|
|
80
|
+
"submitError": "Couldn't submit the form",
|
|
81
|
+
"hiddenQuestion": "This field is hidden to the public. However you can still edit it."
|
|
80
82
|
},
|
|
81
83
|
"successPage": {
|
|
82
84
|
"title1": "Thanks for completing this form.",
|
package/dist/index.cjs.js
CHANGED
|
@@ -35,9 +35,9 @@ var Tooltip = require('@bigbinary/neetoui/Tooltip');
|
|
|
35
35
|
var Pane = require('@bigbinary/neetoui/Pane');
|
|
36
36
|
var Form$2 = require('@bigbinary/neetoui/formik/Form');
|
|
37
37
|
var Select = require('@bigbinary/neetoui/formik/Select');
|
|
38
|
+
var Switch = require('@bigbinary/neetoui/formik/Switch');
|
|
38
39
|
var Textarea = require('@bigbinary/neetoui/formik/Textarea');
|
|
39
40
|
var NeetoEditor = require('@bigbinary/neeto-editor/Editor');
|
|
40
|
-
var Switch = require('@bigbinary/neetoui/formik/Switch');
|
|
41
41
|
var Button$1 = require('@bigbinary/neetoui/Button');
|
|
42
42
|
var Accordion = require('@bigbinary/neetoui/Accordion');
|
|
43
43
|
var Input = require('@bigbinary/neetoui/formik/Input');
|
|
@@ -50,8 +50,10 @@ var Label = require('@bigbinary/neetoui/Label');
|
|
|
50
50
|
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
51
51
|
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
52
52
|
var useHotkeys = require('@bigbinary/neeto-hotkeys');
|
|
53
|
+
var Warning = require('@bigbinary/neeto-icons/Warning');
|
|
53
54
|
var Toastr = require('@bigbinary/neetoui/Toastr');
|
|
54
55
|
var Spinner$2 = require('@bigbinary/neetoui/Spinner');
|
|
56
|
+
var NeetoUICallout = require('@bigbinary/neetoui/Callout');
|
|
55
57
|
var Close = require('@bigbinary/neeto-icons/Close');
|
|
56
58
|
var Check = require('@bigbinary/neeto-icons/Check');
|
|
57
59
|
var dayjs = require('dayjs');
|
|
@@ -115,9 +117,9 @@ var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
|
|
|
115
117
|
var Pane__default = /*#__PURE__*/_interopDefaultLegacy(Pane);
|
|
116
118
|
var Form__default = /*#__PURE__*/_interopDefaultLegacy(Form$2);
|
|
117
119
|
var Select__default = /*#__PURE__*/_interopDefaultLegacy(Select);
|
|
120
|
+
var Switch__default = /*#__PURE__*/_interopDefaultLegacy(Switch);
|
|
118
121
|
var Textarea__default = /*#__PURE__*/_interopDefaultLegacy(Textarea);
|
|
119
122
|
var NeetoEditor__default = /*#__PURE__*/_interopDefaultLegacy(NeetoEditor);
|
|
120
|
-
var Switch__default = /*#__PURE__*/_interopDefaultLegacy(Switch);
|
|
121
123
|
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button$1);
|
|
122
124
|
var Accordion__default = /*#__PURE__*/_interopDefaultLegacy(Accordion);
|
|
123
125
|
var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input);
|
|
@@ -130,8 +132,10 @@ var Label__default = /*#__PURE__*/_interopDefaultLegacy(Label);
|
|
|
130
132
|
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
|
|
131
133
|
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
|
|
132
134
|
var useHotkeys__default = /*#__PURE__*/_interopDefaultLegacy(useHotkeys);
|
|
135
|
+
var Warning__default = /*#__PURE__*/_interopDefaultLegacy(Warning);
|
|
133
136
|
var Toastr__default = /*#__PURE__*/_interopDefaultLegacy(Toastr);
|
|
134
137
|
var Spinner__default = /*#__PURE__*/_interopDefaultLegacy(Spinner$2);
|
|
138
|
+
var NeetoUICallout__default = /*#__PURE__*/_interopDefaultLegacy(NeetoUICallout);
|
|
135
139
|
var Close__default = /*#__PURE__*/_interopDefaultLegacy(Close);
|
|
136
140
|
var Check__default = /*#__PURE__*/_interopDefaultLegacy(Check);
|
|
137
141
|
var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
|
|
@@ -652,7 +656,7 @@ var handleQuestionMutationSuccess = function handleQuestionMutationSuccess(_ref)
|
|
|
652
656
|
var _excluded$d = ["formId", "preview", "language"],
|
|
653
657
|
_excluded2$1 = ["formId", "language"],
|
|
654
658
|
_excluded3$1 = ["page", "pageSize"],
|
|
655
|
-
_excluded5 = ["formId", "submissionId"];
|
|
659
|
+
_excluded5 = ["formId", "submissionId", "fetchPublicSubmission"];
|
|
656
660
|
function ownKeys$y(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; }
|
|
657
661
|
function _objectSpread$y(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$y(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$y(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
658
662
|
var useForm = function useForm(_ref) {
|
|
@@ -865,11 +869,13 @@ var useDeleteForm = function useDeleteForm(options) {
|
|
|
865
869
|
var useSubmission = function useSubmission(_ref11) {
|
|
866
870
|
var formId = _ref11.formId,
|
|
867
871
|
submissionId = _ref11.submissionId,
|
|
872
|
+
_ref11$fetchPublicSub = _ref11.fetchPublicSubmission,
|
|
873
|
+
fetchPublicSubmission = _ref11$fetchPublicSub === void 0 ? true : _ref11$fetchPublicSub,
|
|
868
874
|
options = _objectWithoutProperties__default["default"](_ref11, _excluded5);
|
|
869
875
|
return reactQuery.useQuery(_objectSpread$y({
|
|
870
876
|
queryKey: [QUERY_KEYS.SUBMISSION, formId, submissionId],
|
|
871
877
|
queryFn: function queryFn() {
|
|
872
|
-
return neetoFormApi.getPublicSubmission(formId, submissionId);
|
|
878
|
+
return fetchPublicSubmission ? neetoFormApi.getPublicSubmission(formId, submissionId) : neetoFormApi.getSubmission(formId, submissionId);
|
|
873
879
|
},
|
|
874
880
|
placeholderData: reactQuery.keepPreviousData
|
|
875
881
|
}, options));
|
|
@@ -2137,7 +2143,7 @@ var RequiredSwitch = reactUtils.withT(function (_ref) {
|
|
|
2137
2143
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2138
2144
|
className: "w-full",
|
|
2139
2145
|
children: /*#__PURE__*/jsxRuntime.jsx(Switch__default["default"], {
|
|
2140
|
-
label: t("neetoForm.
|
|
2146
|
+
label: t("neetoForm.common.required"),
|
|
2141
2147
|
name: "isRequired"
|
|
2142
2148
|
})
|
|
2143
2149
|
});
|
|
@@ -2231,6 +2237,7 @@ var Form$1 = function Form(_ref) {
|
|
|
2231
2237
|
var shouldShowPlaceholder = ramda.includes(kind, QUESTIONS_WITH_PLACEHOLDERS);
|
|
2232
2238
|
var hasAdditionalData = ramda.includes(kind, QUESTIONS_WITH_ADDITIONAL_DATA);
|
|
2233
2239
|
var shouldShowFieldCode = enableFieldCode && !ramda.includes(kind, QUESTIONS_WITHOUT_FIELD_CODE);
|
|
2240
|
+
var shouldShowHideSwitch = !ramda.includes(kind, QUESTIONS_WITHOUT_FIELD_CODE);
|
|
2234
2241
|
var handleKindChange = function handleKindChange(option) {
|
|
2235
2242
|
var data = buildQuestionData(option);
|
|
2236
2243
|
updateFormState(data);
|
|
@@ -2289,10 +2296,13 @@ var Form$1 = function Form(_ref) {
|
|
|
2289
2296
|
kind: kind,
|
|
2290
2297
|
questionProps: questionProps
|
|
2291
2298
|
})]
|
|
2292
|
-
}), !isRequired && /*#__PURE__*/jsxRuntime.
|
|
2299
|
+
}), !isRequired && /*#__PURE__*/jsxRuntime.jsxs(Block, {
|
|
2293
2300
|
dataCy: "settings-card",
|
|
2294
2301
|
title: t("neetoForm.common.settings"),
|
|
2295
|
-
children: /*#__PURE__*/jsxRuntime.jsx(RequiredSwitch, {})
|
|
2302
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(RequiredSwitch, {}), shouldShowHideSwitch && /*#__PURE__*/jsxRuntime.jsx(Switch__default["default"], {
|
|
2303
|
+
label: t("neetoForm.common.hideQuestion"),
|
|
2304
|
+
name: "isHidden"
|
|
2305
|
+
})]
|
|
2296
2306
|
}), shouldShowFieldCode && /*#__PURE__*/jsxRuntime.jsx(FieldCode, {
|
|
2297
2307
|
helpDocUrl: fieldCodeHelpDocUrl
|
|
2298
2308
|
})]
|
|
@@ -5711,7 +5721,10 @@ var ExternalForm = function ExternalForm(_ref) {
|
|
|
5711
5721
|
var renderedQuestions = preview ? questions.filter(function (_ref4) {
|
|
5712
5722
|
var _destroy = _ref4._destroy;
|
|
5713
5723
|
return !_destroy;
|
|
5714
|
-
}) : questions
|
|
5724
|
+
}) : questions.filter(function (_ref5) {
|
|
5725
|
+
var isHidden = _ref5.isHidden;
|
|
5726
|
+
return !isHidden;
|
|
5727
|
+
});
|
|
5715
5728
|
if (displayThankYou && showSuccess) {
|
|
5716
5729
|
return /*#__PURE__*/jsxRuntime.jsx(Success$1, {});
|
|
5717
5730
|
}
|
|
@@ -5737,11 +5750,11 @@ var ExternalForm = function ExternalForm(_ref) {
|
|
|
5737
5750
|
toCamelCase: false
|
|
5738
5751
|
}) : {}
|
|
5739
5752
|
}),
|
|
5740
|
-
children: function children(
|
|
5741
|
-
var isSubmitting =
|
|
5742
|
-
errors =
|
|
5743
|
-
setFieldError =
|
|
5744
|
-
handleReset =
|
|
5753
|
+
children: function children(_ref6) {
|
|
5754
|
+
var isSubmitting = _ref6.isSubmitting,
|
|
5755
|
+
errors = _ref6.errors,
|
|
5756
|
+
setFieldError = _ref6.setFieldError,
|
|
5757
|
+
handleReset = _ref6.handleReset;
|
|
5745
5758
|
return /*#__PURE__*/jsxRuntime.jsxs(FormikWrap, {
|
|
5746
5759
|
dataUpdateCount: dataUpdateCount,
|
|
5747
5760
|
formId: formId,
|
|
@@ -5766,15 +5779,23 @@ var ExternalForm = function ExternalForm(_ref) {
|
|
|
5766
5779
|
}), renderedQuestions.map(function (question) {
|
|
5767
5780
|
var _question$id;
|
|
5768
5781
|
var FieldComponent = getFieldComponent(question);
|
|
5769
|
-
return /*#__PURE__*/
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5782
|
+
return /*#__PURE__*/jsxRuntime.jsxs(React__default["default"].Fragment, {
|
|
5783
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(FieldComponent, {
|
|
5784
|
+
editorProps: editorProps,
|
|
5785
|
+
editorRef: editorRef,
|
|
5786
|
+
preview: preview,
|
|
5787
|
+
question: question,
|
|
5788
|
+
customValidator: customValidator === null || customValidator === void 0 ? void 0 : customValidator(question),
|
|
5789
|
+
autoComplete: buildAutoCompleteAttribute(question.kind, autoCompleteKinds, formDomProps)
|
|
5790
|
+
}), question.isHidden && /*#__PURE__*/jsxRuntime.jsx(NeetoUICallout__default["default"], {
|
|
5791
|
+
icon: Warning__default["default"],
|
|
5792
|
+
style: "warning",
|
|
5793
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
5794
|
+
style: "body2",
|
|
5795
|
+
children: t("neetoForm.callouts.hiddenQuestion")
|
|
5796
|
+
})
|
|
5797
|
+
})]
|
|
5798
|
+
}, (_question$id = question.id) !== null && _question$id !== void 0 ? _question$id : question.nodeId);
|
|
5778
5799
|
}), showEmptyState && ramda.isEmpty(renderedQuestions) && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
5779
5800
|
className: "flex flex-col items-center justify-center gap-y-4 py-8",
|
|
5780
5801
|
children: [/*#__PURE__*/jsxRuntime.jsx(SvgNoQuestions, {}), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
@@ -8409,6 +8430,8 @@ var Submission = function Submission(_ref2) {
|
|
|
8409
8430
|
submissionId = _ref2$submissionId === void 0 ? "" : _ref2$submissionId,
|
|
8410
8431
|
_ref2$className = _ref2.className,
|
|
8411
8432
|
className = _ref2$className === void 0 ? "" : _ref2$className,
|
|
8433
|
+
_ref2$fetchPublicSubm = _ref2.fetchPublicSubmission,
|
|
8434
|
+
fetchPublicSubmission = _ref2$fetchPublicSubm === void 0 ? true : _ref2$fetchPublicSubm,
|
|
8412
8435
|
_ref2$questionLabelPr = _ref2.questionLabelProps,
|
|
8413
8436
|
questionLabelProps = _ref2$questionLabelPr === void 0 ? {} : _ref2$questionLabelPr,
|
|
8414
8437
|
_ref2$answerProps = _ref2.answerProps,
|
|
@@ -8416,6 +8439,7 @@ var Submission = function Submission(_ref2) {
|
|
|
8416
8439
|
var _useSubmission = useSubmission({
|
|
8417
8440
|
formId: formId,
|
|
8418
8441
|
submissionId: submissionId,
|
|
8442
|
+
fetchPublicSubmission: fetchPublicSubmission,
|
|
8419
8443
|
enabled: !!(formId && submissionId)
|
|
8420
8444
|
}),
|
|
8421
8445
|
_useSubmission$data = _useSubmission.data,
|