@bigbinary/neeto-form-frontend 3.0.4 → 3.0.6
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/ar.json +34 -0
- 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 +9 -9
- package/types.d.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -32,9 +32,9 @@ import Tooltip from '@bigbinary/neetoui/Tooltip';
|
|
|
32
32
|
import Pane from '@bigbinary/neetoui/Pane';
|
|
33
33
|
import Form$2 from '@bigbinary/neetoui/formik/Form';
|
|
34
34
|
import Select from '@bigbinary/neetoui/formik/Select';
|
|
35
|
+
import Switch from '@bigbinary/neetoui/formik/Switch';
|
|
35
36
|
import Textarea from '@bigbinary/neetoui/formik/Textarea';
|
|
36
37
|
import NeetoEditor from '@bigbinary/neeto-editor/Editor';
|
|
37
|
-
import Switch from '@bigbinary/neetoui/formik/Switch';
|
|
38
38
|
import Button$1 from '@bigbinary/neetoui/Button';
|
|
39
39
|
import Accordion from '@bigbinary/neetoui/Accordion';
|
|
40
40
|
import Input from '@bigbinary/neetoui/formik/Input';
|
|
@@ -47,8 +47,10 @@ import Label from '@bigbinary/neetoui/Label';
|
|
|
47
47
|
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
48
48
|
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
49
49
|
import useHotkeys from '@bigbinary/neeto-hotkeys';
|
|
50
|
+
import Warning from '@bigbinary/neeto-icons/Warning';
|
|
50
51
|
import Toastr from '@bigbinary/neetoui/Toastr';
|
|
51
52
|
import Spinner$2 from '@bigbinary/neetoui/Spinner';
|
|
53
|
+
import NeetoUICallout from '@bigbinary/neetoui/Callout';
|
|
52
54
|
import Close from '@bigbinary/neeto-icons/Close';
|
|
53
55
|
import Check from '@bigbinary/neeto-icons/Check';
|
|
54
56
|
import dayjs from 'dayjs';
|
|
@@ -575,7 +577,7 @@ var handleQuestionMutationSuccess = function handleQuestionMutationSuccess(_ref)
|
|
|
575
577
|
var _excluded$d = ["formId", "preview", "language"],
|
|
576
578
|
_excluded2$1 = ["formId", "language"],
|
|
577
579
|
_excluded3$1 = ["page", "pageSize"],
|
|
578
|
-
_excluded5 = ["formId", "submissionId"];
|
|
580
|
+
_excluded5 = ["formId", "submissionId", "fetchPublicSubmission"];
|
|
579
581
|
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; }
|
|
580
582
|
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(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; }
|
|
581
583
|
var useForm = function useForm(_ref) {
|
|
@@ -788,11 +790,13 @@ var useDeleteForm = function useDeleteForm(options) {
|
|
|
788
790
|
var useSubmission = function useSubmission(_ref11) {
|
|
789
791
|
var formId = _ref11.formId,
|
|
790
792
|
submissionId = _ref11.submissionId,
|
|
793
|
+
_ref11$fetchPublicSub = _ref11.fetchPublicSubmission,
|
|
794
|
+
fetchPublicSubmission = _ref11$fetchPublicSub === void 0 ? true : _ref11$fetchPublicSub,
|
|
791
795
|
options = _objectWithoutProperties(_ref11, _excluded5);
|
|
792
796
|
return useQuery(_objectSpread$y({
|
|
793
797
|
queryKey: [QUERY_KEYS.SUBMISSION, formId, submissionId],
|
|
794
798
|
queryFn: function queryFn() {
|
|
795
|
-
return neetoFormApi.getPublicSubmission(formId, submissionId);
|
|
799
|
+
return fetchPublicSubmission ? neetoFormApi.getPublicSubmission(formId, submissionId) : neetoFormApi.getSubmission(formId, submissionId);
|
|
796
800
|
},
|
|
797
801
|
placeholderData: keepPreviousData
|
|
798
802
|
}, options));
|
|
@@ -2060,7 +2064,7 @@ var RequiredSwitch = withT(function (_ref) {
|
|
|
2060
2064
|
return /*#__PURE__*/jsx("div", {
|
|
2061
2065
|
className: "w-full",
|
|
2062
2066
|
children: /*#__PURE__*/jsx(Switch, {
|
|
2063
|
-
label: t("neetoForm.
|
|
2067
|
+
label: t("neetoForm.common.required"),
|
|
2064
2068
|
name: "isRequired"
|
|
2065
2069
|
})
|
|
2066
2070
|
});
|
|
@@ -2154,6 +2158,7 @@ var Form$1 = function Form(_ref) {
|
|
|
2154
2158
|
var shouldShowPlaceholder = includes(kind, QUESTIONS_WITH_PLACEHOLDERS);
|
|
2155
2159
|
var hasAdditionalData = includes(kind, QUESTIONS_WITH_ADDITIONAL_DATA);
|
|
2156
2160
|
var shouldShowFieldCode = enableFieldCode && !includes(kind, QUESTIONS_WITHOUT_FIELD_CODE);
|
|
2161
|
+
var shouldShowHideSwitch = !includes(kind, QUESTIONS_WITHOUT_FIELD_CODE);
|
|
2157
2162
|
var handleKindChange = function handleKindChange(option) {
|
|
2158
2163
|
var data = buildQuestionData(option);
|
|
2159
2164
|
updateFormState(data);
|
|
@@ -2212,10 +2217,13 @@ var Form$1 = function Form(_ref) {
|
|
|
2212
2217
|
kind: kind,
|
|
2213
2218
|
questionProps: questionProps
|
|
2214
2219
|
})]
|
|
2215
|
-
}), !isRequired && /*#__PURE__*/
|
|
2220
|
+
}), !isRequired && /*#__PURE__*/jsxs(Block, {
|
|
2216
2221
|
dataCy: "settings-card",
|
|
2217
2222
|
title: t("neetoForm.common.settings"),
|
|
2218
|
-
children: /*#__PURE__*/jsx(RequiredSwitch, {})
|
|
2223
|
+
children: [/*#__PURE__*/jsx(RequiredSwitch, {}), shouldShowHideSwitch && /*#__PURE__*/jsx(Switch, {
|
|
2224
|
+
label: t("neetoForm.common.hideQuestion"),
|
|
2225
|
+
name: "isHidden"
|
|
2226
|
+
})]
|
|
2219
2227
|
}), shouldShowFieldCode && /*#__PURE__*/jsx(FieldCode, {
|
|
2220
2228
|
helpDocUrl: fieldCodeHelpDocUrl
|
|
2221
2229
|
})]
|
|
@@ -5634,7 +5642,10 @@ var ExternalForm = function ExternalForm(_ref) {
|
|
|
5634
5642
|
var renderedQuestions = preview ? questions.filter(function (_ref4) {
|
|
5635
5643
|
var _destroy = _ref4._destroy;
|
|
5636
5644
|
return !_destroy;
|
|
5637
|
-
}) : questions
|
|
5645
|
+
}) : questions.filter(function (_ref5) {
|
|
5646
|
+
var isHidden = _ref5.isHidden;
|
|
5647
|
+
return !isHidden;
|
|
5648
|
+
});
|
|
5638
5649
|
if (displayThankYou && showSuccess) {
|
|
5639
5650
|
return /*#__PURE__*/jsx(Success$1, {});
|
|
5640
5651
|
}
|
|
@@ -5660,11 +5671,11 @@ var ExternalForm = function ExternalForm(_ref) {
|
|
|
5660
5671
|
toCamelCase: false
|
|
5661
5672
|
}) : {}
|
|
5662
5673
|
}),
|
|
5663
|
-
children: function children(
|
|
5664
|
-
var isSubmitting =
|
|
5665
|
-
errors =
|
|
5666
|
-
setFieldError =
|
|
5667
|
-
handleReset =
|
|
5674
|
+
children: function children(_ref6) {
|
|
5675
|
+
var isSubmitting = _ref6.isSubmitting,
|
|
5676
|
+
errors = _ref6.errors,
|
|
5677
|
+
setFieldError = _ref6.setFieldError,
|
|
5678
|
+
handleReset = _ref6.handleReset;
|
|
5668
5679
|
return /*#__PURE__*/jsxs(FormikWrap, {
|
|
5669
5680
|
dataUpdateCount: dataUpdateCount,
|
|
5670
5681
|
formId: formId,
|
|
@@ -5689,15 +5700,23 @@ var ExternalForm = function ExternalForm(_ref) {
|
|
|
5689
5700
|
}), renderedQuestions.map(function (question) {
|
|
5690
5701
|
var _question$id;
|
|
5691
5702
|
var FieldComponent = getFieldComponent(question);
|
|
5692
|
-
return /*#__PURE__*/
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
5703
|
+
return /*#__PURE__*/jsxs(React__default.Fragment, {
|
|
5704
|
+
children: [/*#__PURE__*/jsx(FieldComponent, {
|
|
5705
|
+
editorProps: editorProps,
|
|
5706
|
+
editorRef: editorRef,
|
|
5707
|
+
preview: preview,
|
|
5708
|
+
question: question,
|
|
5709
|
+
customValidator: customValidator === null || customValidator === void 0 ? void 0 : customValidator(question),
|
|
5710
|
+
autoComplete: buildAutoCompleteAttribute(question.kind, autoCompleteKinds, formDomProps)
|
|
5711
|
+
}), question.isHidden && /*#__PURE__*/jsx(NeetoUICallout, {
|
|
5712
|
+
icon: Warning,
|
|
5713
|
+
style: "warning",
|
|
5714
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
5715
|
+
style: "body2",
|
|
5716
|
+
children: t("neetoForm.callouts.hiddenQuestion")
|
|
5717
|
+
})
|
|
5718
|
+
})]
|
|
5719
|
+
}, (_question$id = question.id) !== null && _question$id !== void 0 ? _question$id : question.nodeId);
|
|
5701
5720
|
}), showEmptyState && isEmpty(renderedQuestions) && /*#__PURE__*/jsxs("div", {
|
|
5702
5721
|
className: "flex flex-col items-center justify-center gap-y-4 py-8",
|
|
5703
5722
|
children: [/*#__PURE__*/jsx(SvgNoQuestions, {}), /*#__PURE__*/jsx(Typography, {
|
|
@@ -8332,6 +8351,8 @@ var Submission = function Submission(_ref2) {
|
|
|
8332
8351
|
submissionId = _ref2$submissionId === void 0 ? "" : _ref2$submissionId,
|
|
8333
8352
|
_ref2$className = _ref2.className,
|
|
8334
8353
|
className = _ref2$className === void 0 ? "" : _ref2$className,
|
|
8354
|
+
_ref2$fetchPublicSubm = _ref2.fetchPublicSubmission,
|
|
8355
|
+
fetchPublicSubmission = _ref2$fetchPublicSubm === void 0 ? true : _ref2$fetchPublicSubm,
|
|
8335
8356
|
_ref2$questionLabelPr = _ref2.questionLabelProps,
|
|
8336
8357
|
questionLabelProps = _ref2$questionLabelPr === void 0 ? {} : _ref2$questionLabelPr,
|
|
8337
8358
|
_ref2$answerProps = _ref2.answerProps,
|
|
@@ -8339,6 +8360,7 @@ var Submission = function Submission(_ref2) {
|
|
|
8339
8360
|
var _useSubmission = useSubmission({
|
|
8340
8361
|
formId: formId,
|
|
8341
8362
|
submissionId: submissionId,
|
|
8363
|
+
fetchPublicSubmission: fetchPublicSubmission,
|
|
8342
8364
|
enabled: !!(formId && submissionId)
|
|
8343
8365
|
}),
|
|
8344
8366
|
_useSubmission$data = _useSubmission.data,
|