@bigbinary/neeto-form-frontend 1.2.56 → 1.3.1
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 +4 -2
- package/dist/index.cjs.js +202 -148
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +208 -154
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/types.d.ts +3 -2
package/dist/index.cjs.js
CHANGED
|
@@ -20,8 +20,9 @@ var formik$1 = require('@bigbinary/neetoui/formik');
|
|
|
20
20
|
var reactI18next = require('react-i18next');
|
|
21
21
|
var zustand = require('zustand');
|
|
22
22
|
var classnames = require('classnames');
|
|
23
|
-
var yup = require('yup');
|
|
24
23
|
var neetoEditor = require('@bigbinary/neeto-editor');
|
|
24
|
+
var shallow = require('zustand/shallow');
|
|
25
|
+
var yup = require('yup');
|
|
25
26
|
var useHotkeys = require('@bigbinary/neeto-hotkeys');
|
|
26
27
|
var dayjs = require('dayjs');
|
|
27
28
|
var PhoneNumber$1 = require('@bigbinary/neeto-molecules/PhoneNumber');
|
|
@@ -807,6 +808,7 @@ var QUESTIONS_INITIAL_VALUE = {
|
|
|
807
808
|
};
|
|
808
809
|
var RESERVED_FIELD_CODES = ["month", "date", "time"];
|
|
809
810
|
var SELECTABLE_KINDS = ["radio", "checkbox", "dropdown"];
|
|
811
|
+
var RICH_TEXT_QUESTIONS = ["paragraph", "termsandcondition"];
|
|
810
812
|
|
|
811
813
|
function _arrayWithHoles$3(arr) {
|
|
812
814
|
if (Array.isArray(arr)) return arr;
|
|
@@ -9842,6 +9844,28 @@ var formHelpers = {
|
|
|
9842
9844
|
pushToList: pushToList
|
|
9843
9845
|
};
|
|
9844
9846
|
|
|
9847
|
+
var isBlank = ramda.compose(ramda.isEmpty, ramda.trim);
|
|
9848
|
+
var parseServerError = function parseServerError(error) {
|
|
9849
|
+
var _error$notice;
|
|
9850
|
+
return (_error$notice = error.notice) !== null && _error$notice !== void 0 ? _error$notice : i18next.t("neetoForm.common.somethingWentWrong");
|
|
9851
|
+
};
|
|
9852
|
+
var isEmptyValues = function isEmptyValues(obj) {
|
|
9853
|
+
return ramda.either(ramda.isNil, ramda.isEmpty)(obj) ? true : ramda.values(obj).every(function (value) {
|
|
9854
|
+
if (ramda.isEmpty(value)) {
|
|
9855
|
+
return true;
|
|
9856
|
+
} else if (Array.isArray(value)) {
|
|
9857
|
+
return ramda.equals([false, false, false], value);
|
|
9858
|
+
}
|
|
9859
|
+
return !value;
|
|
9860
|
+
});
|
|
9861
|
+
};
|
|
9862
|
+
|
|
9863
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
9864
|
+
var dotPath = ramda.useWith(ramda.path, [ramda.split(".")]);
|
|
9865
|
+
var isFunction$1 = function isFunction(obj) {
|
|
9866
|
+
return typeof obj === "function";
|
|
9867
|
+
};
|
|
9868
|
+
|
|
9845
9869
|
/** @type {import("neetocommons/react-utils").ZustandStoreHook} */
|
|
9846
9870
|
var useBuildFormStore = zustand.create(reactUtils.withImmutableActions(function (set) {
|
|
9847
9871
|
return {
|
|
@@ -9856,10 +9880,11 @@ var useBuildFormStore = zustand.create(reactUtils.withImmutableActions(function
|
|
|
9856
9880
|
selectedLanguage: i18next__default["default"].resolvedLanguage,
|
|
9857
9881
|
formId: null,
|
|
9858
9882
|
enabled: false,
|
|
9859
|
-
title: ""
|
|
9883
|
+
title: "",
|
|
9884
|
+
richTextFieldsToReset: []
|
|
9860
9885
|
},
|
|
9861
|
-
setFormData: function setFormData(
|
|
9862
|
-
return set(ramda.
|
|
9886
|
+
setFormData: function setFormData(arg) {
|
|
9887
|
+
return set(ramda.modify("formState", isFunction$1(arg) ? arg : ramda.mergeLeft(arg)));
|
|
9863
9888
|
}
|
|
9864
9889
|
};
|
|
9865
9890
|
}));
|
|
@@ -10077,7 +10102,8 @@ var Accordion = function Accordion(_ref) {
|
|
|
10077
10102
|
showAddQuestionDivider = _ref.showAddQuestionDivider,
|
|
10078
10103
|
isDeletable = _ref.isDeletable,
|
|
10079
10104
|
kindUniqueOn = _ref.kindUniqueOn,
|
|
10080
|
-
disabledAddButtonTooltipProps = _ref.disabledAddButtonTooltipProps
|
|
10105
|
+
disabledAddButtonTooltipProps = _ref.disabledAddButtonTooltipProps,
|
|
10106
|
+
dragHandleProps = _ref.dragHandleProps;
|
|
10081
10107
|
var _useState = React$2.useState(false),
|
|
10082
10108
|
_useState2 = _slicedToArray$3(_useState, 2),
|
|
10083
10109
|
isAddQuestionOpen = _useState2[0],
|
|
@@ -10091,14 +10117,14 @@ var Accordion = function Accordion(_ref) {
|
|
|
10091
10117
|
className: classnames__default["default"]("neeto-form-engine-question-accordion relative", {
|
|
10092
10118
|
"pr-4 md:pr-8": showAddQuestionDivider
|
|
10093
10119
|
})
|
|
10094
|
-
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
10120
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", _extends$8({
|
|
10095
10121
|
"data-cy": "neeto-form-engine-question-accordion-header",
|
|
10096
10122
|
className: classnames__default["default"]({
|
|
10097
10123
|
"neeto-form-engine-question-accordion__header flex h-10 cursor-pointer select-none items-center justify-between px-3 py-2": true,
|
|
10098
10124
|
"neeto-ui-text-gray-700 border": !isExpanded,
|
|
10099
10125
|
"neeto-ui-bg-gray-800 neeto-ui-text-white rounded-b-none": isExpanded
|
|
10100
10126
|
})
|
|
10101
|
-
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
10127
|
+
}, dragHandleProps), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
10102
10128
|
className: "neeto-form-engine-question-accordion__header-left flex items-center overflow-hidden"
|
|
10103
10129
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
10104
10130
|
className: "flex w-8 items-center"
|
|
@@ -10302,6 +10328,39 @@ var Condition$1 = function Condition(_ref) {
|
|
|
10302
10328
|
})));
|
|
10303
10329
|
};
|
|
10304
10330
|
|
|
10331
|
+
var getActiveQuestionKindDetails = function getActiveQuestionKindDetails(_ref) {
|
|
10332
|
+
var allQuestionKinds = _ref.allQuestionKinds,
|
|
10333
|
+
item = _ref.item;
|
|
10334
|
+
var kind = item.kind,
|
|
10335
|
+
label = item.label;
|
|
10336
|
+
var _findBy = neetoCist.findBy({
|
|
10337
|
+
type: kind
|
|
10338
|
+
}, allQuestionKinds),
|
|
10339
|
+
FieldComponent = _findBy.component,
|
|
10340
|
+
FieldIcon = _findBy.icon,
|
|
10341
|
+
isSingular = _findBy.isSingular;
|
|
10342
|
+
return {
|
|
10343
|
+
kind: kind,
|
|
10344
|
+
label: label,
|
|
10345
|
+
FieldComponent: FieldComponent,
|
|
10346
|
+
FieldIcon: FieldIcon,
|
|
10347
|
+
isSingular: isSingular
|
|
10348
|
+
};
|
|
10349
|
+
};
|
|
10350
|
+
var generateArray = function generateArray(start, end) {
|
|
10351
|
+
return ramda.range(start, end + 1);
|
|
10352
|
+
};
|
|
10353
|
+
|
|
10354
|
+
var validateEditorContent = function validateEditorContent(editorRef) {
|
|
10355
|
+
return function () {
|
|
10356
|
+
var _editorRef$current;
|
|
10357
|
+
return (_editorRef$current = editorRef.current) !== null && _editorRef$current !== void 0 && (_editorRef$current = _editorRef$current.editor) !== null && _editorRef$current !== void 0 && _editorRef$current.isEmpty ? i18next.t("neetoForm.common.thisFieldIsRequired") : "";
|
|
10358
|
+
};
|
|
10359
|
+
};
|
|
10360
|
+
var generateRatingOptions = function generateRatingOptions(range) {
|
|
10361
|
+
return generateArray.apply(void 0, _toConsumableArray$1(range)).map(neetoCist.toLabelAndValue);
|
|
10362
|
+
};
|
|
10363
|
+
|
|
10305
10364
|
var _FILE_TYPES_MAP;
|
|
10306
10365
|
var FILE_TYPES = {
|
|
10307
10366
|
DOCUMENTS: "documents",
|
|
@@ -10318,6 +10377,8 @@ var STAR_RATING_ICONS_MAP = {
|
|
|
10318
10377
|
trophy: MemoizedTrophy,
|
|
10319
10378
|
zap: MemoizedZap
|
|
10320
10379
|
};
|
|
10380
|
+
var STAR_RATING_MAX_VALUE_OPTIONS = generateRatingOptions([3, 10]);
|
|
10381
|
+
var STAR_RATING_MIN_VALUE_OPTIONS = generateRatingOptions([0, 1]);
|
|
10321
10382
|
var FILE_TYPES_MAP = (_FILE_TYPES_MAP = {}, _defineProperty$6(_FILE_TYPES_MAP, FILE_TYPES.DOCUMENTS, ["pdf", "doc", "docx", "xls", "xlsx", "csv", "txt", "rtf", "html", "zip", "md"]), _defineProperty$6(_FILE_TYPES_MAP, FILE_TYPES.IMAGES, ["jpg", "jpeg", "png", "gif"]), _defineProperty$6(_FILE_TYPES_MAP, FILE_TYPES.AUDIO_VIDEO, ["mp3", "wma", "mpg", "flv", "avi"]), _FILE_TYPES_MAP);
|
|
10322
10383
|
var DEFAULT_ALLOWED_FILE_TYPES = ramda.values(FILE_TYPES_MAP).flat().join(", ");
|
|
10323
10384
|
var FILE_GROUPS = [{
|
|
@@ -10330,8 +10391,6 @@ var FILE_GROUPS = [{
|
|
|
10330
10391
|
label: i18next.t("neetoForm.fileTypes.audioVideo"),
|
|
10331
10392
|
name: FILE_TYPES.AUDIO_VIDEO
|
|
10332
10393
|
}];
|
|
10333
|
-
var STAR_RATING_MIN_COUNT = 0;
|
|
10334
|
-
var STAR_RATING_MAX_COUNT = 10;
|
|
10335
10394
|
|
|
10336
10395
|
var Dropdown$1 = function Dropdown(_ref) {
|
|
10337
10396
|
var item = _ref.item,
|
|
@@ -10459,25 +10518,6 @@ var Email$1 = reactUtils.withT(function (_ref) {
|
|
|
10459
10518
|
}));
|
|
10460
10519
|
});
|
|
10461
10520
|
|
|
10462
|
-
var isBlank = ramda.compose(ramda.isEmpty, ramda.trim);
|
|
10463
|
-
var parseServerError = function parseServerError(error) {
|
|
10464
|
-
var _error$notice;
|
|
10465
|
-
return (_error$notice = error.notice) !== null && _error$notice !== void 0 ? _error$notice : i18next.t("neetoForm.common.somethingWentWrong");
|
|
10466
|
-
};
|
|
10467
|
-
var isEmptyValues = function isEmptyValues(obj) {
|
|
10468
|
-
return ramda.either(ramda.isNil, ramda.isEmpty)(obj) ? true : ramda.values(obj).every(function (value) {
|
|
10469
|
-
if (ramda.isEmpty(value)) {
|
|
10470
|
-
return true;
|
|
10471
|
-
} else if (Array.isArray(value)) {
|
|
10472
|
-
return ramda.equals([false, false, false], value);
|
|
10473
|
-
}
|
|
10474
|
-
return !value;
|
|
10475
|
-
});
|
|
10476
|
-
};
|
|
10477
|
-
|
|
10478
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
10479
|
-
var dotPath = ramda.useWith(ramda.path, [ramda.split(".")]);
|
|
10480
|
-
|
|
10481
10521
|
var FileGroup = function FileGroup(_ref) {
|
|
10482
10522
|
var name = _ref.name,
|
|
10483
10523
|
label = _ref.label,
|
|
@@ -10982,32 +11022,6 @@ var SingleChoice$1 = function SingleChoice(_ref) {
|
|
|
10982
11022
|
}));
|
|
10983
11023
|
};
|
|
10984
11024
|
|
|
10985
|
-
var validateEditorContent = function validateEditorContent(editorRef) {
|
|
10986
|
-
return function () {
|
|
10987
|
-
var _editorRef$current;
|
|
10988
|
-
return (_editorRef$current = editorRef.current) !== null && _editorRef$current !== void 0 && (_editorRef$current = _editorRef$current.editor) !== null && _editorRef$current !== void 0 && _editorRef$current.isEmpty ? i18next.t("neetoForm.common.thisFieldIsRequired") : "";
|
|
10989
|
-
};
|
|
10990
|
-
};
|
|
10991
|
-
var validateStarRatingCount = function validateStarRatingCount(value) {
|
|
10992
|
-
try {
|
|
10993
|
-
var schema = yup__namespace.number().integer().transform(function (value) {
|
|
10994
|
-
return isNaN(value) ? null : value;
|
|
10995
|
-
}).min(STAR_RATING_MIN_COUNT, i18next.t("neetoForm.error.minCount", {
|
|
10996
|
-
field: i18next.t("neetoForm.common.count"),
|
|
10997
|
-
value: STAR_RATING_MIN_COUNT
|
|
10998
|
-
})).max(STAR_RATING_MAX_COUNT, i18next.t("neetoForm.error.maxCount", {
|
|
10999
|
-
field: i18next.t("neetoForm.common.count"),
|
|
11000
|
-
value: STAR_RATING_MAX_COUNT
|
|
11001
|
-
})).nullable().required(i18next.t("neetoForm.common.fieldReq", {
|
|
11002
|
-
field: i18next.t("neetoForm.common.count")
|
|
11003
|
-
}));
|
|
11004
|
-
schema.validateSync(value);
|
|
11005
|
-
return undefined;
|
|
11006
|
-
} catch (error) {
|
|
11007
|
-
return error.message;
|
|
11008
|
-
}
|
|
11009
|
-
};
|
|
11010
|
-
|
|
11011
11025
|
var StarRating$3 = function StarRating(_ref) {
|
|
11012
11026
|
var name = _ref.name,
|
|
11013
11027
|
isRequired = _ref.isRequired,
|
|
@@ -11015,21 +11029,13 @@ var StarRating$3 = function StarRating(_ref) {
|
|
|
11015
11029
|
enableFieldCode = _ref.enableFieldCode;
|
|
11016
11030
|
var _useTranslation = reactI18next.useTranslation(),
|
|
11017
11031
|
t = _useTranslation.t;
|
|
11018
|
-
var
|
|
11032
|
+
var _useFormikContext = formik.useFormikContext(),
|
|
11033
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
11034
|
+
var _useField = formik.useField("".concat(name, ".iconType")),
|
|
11019
11035
|
_useField2 = _slicedToArray$3(_useField, 3),
|
|
11020
|
-
|
|
11036
|
+
iconType = _useField2[0].value;
|
|
11021
11037
|
_useField2[1];
|
|
11022
|
-
var
|
|
11023
|
-
var _useField3 = formik.useField({
|
|
11024
|
-
name: "".concat(name, ".count"),
|
|
11025
|
-
validate: validateStarRatingCount
|
|
11026
|
-
}),
|
|
11027
|
-
_useField4 = _slicedToArray$3(_useField3, 3),
|
|
11028
|
-
countField = _useField4[0],
|
|
11029
|
-
_useField4$ = _useField4[1],
|
|
11030
|
-
countTouched = _useField4$.touched,
|
|
11031
|
-
countError = _useField4$.error,
|
|
11032
|
-
setCount = _useField4[2].setValue;
|
|
11038
|
+
var setIconType = _useField2[2].setValue;
|
|
11033
11039
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11034
11040
|
className: "space-y-4"
|
|
11035
11041
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -11040,22 +11046,31 @@ var StarRating$3 = function StarRating(_ref) {
|
|
|
11040
11046
|
label: t("neetoForm.questions.common.questionFields.field.question"),
|
|
11041
11047
|
name: "".concat(name, ".label"),
|
|
11042
11048
|
rows: 1
|
|
11043
|
-
})), /*#__PURE__*/React__default["default"].createElement(
|
|
11044
|
-
|
|
11045
|
-
},
|
|
11046
|
-
|
|
11047
|
-
label: t("neetoForm.common.
|
|
11048
|
-
|
|
11049
|
-
|
|
11050
|
-
|
|
11051
|
-
|
|
11052
|
-
|
|
11049
|
+
})), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11050
|
+
className: "flex space-x-4"
|
|
11051
|
+
}, /*#__PURE__*/React__default["default"].createElement(formik$1.Select, {
|
|
11052
|
+
className: "w-1/2",
|
|
11053
|
+
label: t("neetoForm.common.start"),
|
|
11054
|
+
name: "".concat(name, ".minValue"),
|
|
11055
|
+
options: STAR_RATING_MIN_VALUE_OPTIONS,
|
|
11056
|
+
onChange: function onChange(option) {
|
|
11057
|
+
return setFieldValue("".concat(name, ".minValue"), option === null || option === void 0 ? void 0 : option.value);
|
|
11058
|
+
}
|
|
11059
|
+
}), /*#__PURE__*/React__default["default"].createElement(formik$1.Select, {
|
|
11060
|
+
className: "w-1/2",
|
|
11061
|
+
label: t("neetoForm.common.end"),
|
|
11062
|
+
name: "".concat(name, ".maxValue"),
|
|
11063
|
+
options: STAR_RATING_MAX_VALUE_OPTIONS,
|
|
11064
|
+
onChange: function onChange(option) {
|
|
11065
|
+
return setFieldValue("".concat(name, ".maxValue"), option === null || option === void 0 ? void 0 : option.value);
|
|
11066
|
+
}
|
|
11067
|
+
})), /*#__PURE__*/React__default["default"].createElement(neetoui.Label, null, t("neetoForm.common.shape")), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11053
11068
|
className: "flex gap-2"
|
|
11054
11069
|
}, Object.entries(STAR_RATING_ICONS_MAP).map(function (_ref2) {
|
|
11055
11070
|
var _ref3 = _slicedToArray$3(_ref2, 2),
|
|
11056
11071
|
name = _ref3[0],
|
|
11057
|
-
|
|
11058
|
-
var isActive = name ===
|
|
11072
|
+
IconType = _ref3[1];
|
|
11073
|
+
var isActive = name === iconType;
|
|
11059
11074
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11060
11075
|
key: name,
|
|
11061
11076
|
className: classnames__default["default"]("flex h-10 w-10 items-center justify-center gap-2", "neeto-ui-border-gray-800 neeto-ui-rounded-full cursor-pointer border", "transition-all duration-300 ease-in-out", {
|
|
@@ -11063,9 +11078,9 @@ var StarRating$3 = function StarRating(_ref) {
|
|
|
11063
11078
|
"neeto-ui-text-white neeto-ui-bg-gray-800": isActive
|
|
11064
11079
|
}),
|
|
11065
11080
|
onClick: function onClick() {
|
|
11066
|
-
return
|
|
11081
|
+
return setIconType(name);
|
|
11067
11082
|
}
|
|
11068
|
-
}, /*#__PURE__*/React__default["default"].createElement(
|
|
11083
|
+
}, /*#__PURE__*/React__default["default"].createElement(IconType, null));
|
|
11069
11084
|
})), !isRequired && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11070
11085
|
className: "w-full"
|
|
11071
11086
|
}, /*#__PURE__*/React__default["default"].createElement(formik$1.Checkbox, {
|
|
@@ -11077,18 +11092,42 @@ var StarRating$3 = function StarRating(_ref) {
|
|
|
11077
11092
|
}));
|
|
11078
11093
|
};
|
|
11079
11094
|
|
|
11080
|
-
var useUpdateEditorContent = function useUpdateEditorContent(
|
|
11095
|
+
var useUpdateEditorContent = function useUpdateEditorContent(_ref) {
|
|
11096
|
+
var editorRef = _ref.editorRef,
|
|
11097
|
+
fieldName = _ref.fieldName,
|
|
11098
|
+
value = _ref.value,
|
|
11099
|
+
initialValue = _ref.initialValue,
|
|
11100
|
+
fieldCode = _ref.fieldCode;
|
|
11081
11101
|
var initialStateRef = React$2.useRef({
|
|
11082
11102
|
language: "",
|
|
11083
11103
|
value: null
|
|
11084
11104
|
});
|
|
11085
|
-
var
|
|
11086
|
-
|
|
11087
|
-
|
|
11105
|
+
var _useBuildFormStore = useBuildFormStore(function (store) {
|
|
11106
|
+
return {
|
|
11107
|
+
setFormData: store["setFormData"]
|
|
11108
|
+
};
|
|
11109
|
+
}, shallow.shallow),
|
|
11110
|
+
setFormData = _useBuildFormStore.setFormData;
|
|
11111
|
+
var _useBuildFormStore2 = useBuildFormStore(function (store) {
|
|
11112
|
+
var _store$formState, _store$formState2;
|
|
11113
|
+
return {
|
|
11114
|
+
formId: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["formId"],
|
|
11115
|
+
selectedLanguage: (_store$formState2 = store["formState"]) === null || _store$formState2 === void 0 ? void 0 : _store$formState2["selectedLanguage"]
|
|
11116
|
+
};
|
|
11117
|
+
}, shallow.shallow),
|
|
11118
|
+
formId = _useBuildFormStore2.formId,
|
|
11119
|
+
language = _useBuildFormStore2.selectedLanguage;
|
|
11120
|
+
var shouldReset = useBuildFormStore(function (store) {
|
|
11121
|
+
return store.formState.richTextFieldsToReset.includes(fieldCode);
|
|
11122
|
+
});
|
|
11088
11123
|
var setEditorContent = function setEditorContent(content) {
|
|
11089
11124
|
var _editorRef$current$ed;
|
|
11090
11125
|
return (_editorRef$current$ed = editorRef.current.editor) === null || _editorRef$current$ed === void 0 || (_editorRef$current$ed = _editorRef$current$ed.commands) === null || _editorRef$current$ed === void 0 ? void 0 : _editorRef$current$ed.setContent(content);
|
|
11091
11126
|
};
|
|
11127
|
+
if (shouldReset) {
|
|
11128
|
+
setEditorContent(initialValue);
|
|
11129
|
+
setFormData(ramda.modify("richTextFieldsToReset", ramda.without([fieldCode])));
|
|
11130
|
+
}
|
|
11092
11131
|
React$2.useEffect(function () {
|
|
11093
11132
|
if (initialStateRef.current["language"] !== language) {
|
|
11094
11133
|
initialStateRef.current["language"] = language;
|
|
@@ -11115,11 +11154,13 @@ var useUpdateEditorContent = function useUpdateEditorContent(editorRef, fieldNam
|
|
|
11115
11154
|
|
|
11116
11155
|
var Terms$1 = function Terms(_ref) {
|
|
11117
11156
|
var name = _ref.name,
|
|
11157
|
+
item = _ref.item,
|
|
11118
11158
|
isLabelDisabled = _ref.isLabelDisabled;
|
|
11119
11159
|
var editorRef = React$2.useRef({
|
|
11120
11160
|
editor: {}
|
|
11121
11161
|
});
|
|
11122
11162
|
var fieldName = "".concat(name, ".label");
|
|
11163
|
+
var fieldCode = item.fieldCode;
|
|
11123
11164
|
var _useField = formik.useField({
|
|
11124
11165
|
name: fieldName,
|
|
11125
11166
|
validate: validateEditorContent(editorRef)
|
|
@@ -11129,10 +11170,17 @@ var Terms$1 = function Terms(_ref) {
|
|
|
11129
11170
|
_useField2$ = _useField2[1],
|
|
11130
11171
|
touched = _useField2$.touched,
|
|
11131
11172
|
error = _useField2$.error,
|
|
11173
|
+
initialValue = _useField2$.initialValue,
|
|
11132
11174
|
_useField2$2 = _useField2[2],
|
|
11133
11175
|
setTouched = _useField2$2.setTouched,
|
|
11134
11176
|
setValue = _useField2$2.setValue;
|
|
11135
|
-
useUpdateEditorContent(
|
|
11177
|
+
useUpdateEditorContent({
|
|
11178
|
+
editorRef: editorRef,
|
|
11179
|
+
fieldName: fieldName,
|
|
11180
|
+
value: value,
|
|
11181
|
+
initialValue: initialValue,
|
|
11182
|
+
fieldCode: fieldCode
|
|
11183
|
+
});
|
|
11136
11184
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11137
11185
|
className: "w-full cursor-auto"
|
|
11138
11186
|
}, /*#__PURE__*/React__default["default"].createElement(neetoEditor.Editor, {
|
|
@@ -11174,11 +11222,13 @@ var Fields = {
|
|
|
11174
11222
|
|
|
11175
11223
|
var Editor = function Editor(_ref) {
|
|
11176
11224
|
var name = _ref.name,
|
|
11225
|
+
item = _ref.item,
|
|
11177
11226
|
isLabelDisabled = _ref.isLabelDisabled;
|
|
11178
11227
|
var editorRef = React$2.useRef({
|
|
11179
11228
|
editor: {}
|
|
11180
11229
|
});
|
|
11181
11230
|
var fieldName = "".concat(name, ".label");
|
|
11231
|
+
var fieldCode = item.fieldCode;
|
|
11182
11232
|
var _useField = formik.useField({
|
|
11183
11233
|
name: fieldName,
|
|
11184
11234
|
validate: validateEditorContent(editorRef)
|
|
@@ -11188,10 +11238,17 @@ var Editor = function Editor(_ref) {
|
|
|
11188
11238
|
_useField2$ = _useField2[1],
|
|
11189
11239
|
touched = _useField2$.touched,
|
|
11190
11240
|
error = _useField2$.error,
|
|
11241
|
+
initialValue = _useField2$.initialValue,
|
|
11191
11242
|
_useField2$2 = _useField2[2],
|
|
11192
11243
|
setTouched = _useField2$2.setTouched,
|
|
11193
11244
|
setValue = _useField2$2.setValue;
|
|
11194
|
-
useUpdateEditorContent(
|
|
11245
|
+
useUpdateEditorContent({
|
|
11246
|
+
editorRef: editorRef,
|
|
11247
|
+
fieldName: fieldName,
|
|
11248
|
+
value: value,
|
|
11249
|
+
initialValue: initialValue,
|
|
11250
|
+
fieldCode: fieldCode
|
|
11251
|
+
});
|
|
11195
11252
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11196
11253
|
className: "w-full cursor-auto"
|
|
11197
11254
|
}, /*#__PURE__*/React__default["default"].createElement(neetoEditor.Editor, {
|
|
@@ -11372,8 +11429,9 @@ var QUESTION_KINDS = [{
|
|
|
11372
11429
|
defaults: {
|
|
11373
11430
|
label: "",
|
|
11374
11431
|
isRequired: true,
|
|
11375
|
-
|
|
11376
|
-
|
|
11432
|
+
minValue: 1,
|
|
11433
|
+
maxValue: 5,
|
|
11434
|
+
iconType: "star"
|
|
11377
11435
|
}
|
|
11378
11436
|
}, {
|
|
11379
11437
|
type: "rating",
|
|
@@ -11457,7 +11515,8 @@ var FormField = function FormField(props) {
|
|
|
11457
11515
|
allQuestionKinds = props.allQuestionKinds,
|
|
11458
11516
|
getActiveKindDetails = props.getActiveKindDetails,
|
|
11459
11517
|
kindUniqueOn = props.kindUniqueOn,
|
|
11460
|
-
disabledAddButtonTooltipProps = props.disabledAddButtonTooltipProps
|
|
11518
|
+
disabledAddButtonTooltipProps = props.disabledAddButtonTooltipProps,
|
|
11519
|
+
dragHandleProps = props.dragHandleProps;
|
|
11461
11520
|
var _getActiveKindDetails = getActiveKindDetails({
|
|
11462
11521
|
allQuestionKinds: allQuestionKinds,
|
|
11463
11522
|
item: item
|
|
@@ -11469,6 +11528,7 @@ var FormField = function FormField(props) {
|
|
|
11469
11528
|
isSingular = _getActiveKindDetails.isSingular;
|
|
11470
11529
|
return /*#__PURE__*/React__default["default"].createElement(Accordion, {
|
|
11471
11530
|
disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
|
|
11531
|
+
dragHandleProps: dragHandleProps,
|
|
11472
11532
|
isDeletable: isDeletable,
|
|
11473
11533
|
isExpanded: isExpanded,
|
|
11474
11534
|
kindUniqueOn: kindUniqueOn,
|
|
@@ -11517,11 +11577,12 @@ var Question = function Question(_ref) {
|
|
|
11517
11577
|
var draggableProps = _ref3.draggableProps,
|
|
11518
11578
|
dragHandleProps = _ref3.dragHandleProps,
|
|
11519
11579
|
innerRef = _ref3.innerRef;
|
|
11520
|
-
return /*#__PURE__*/React__default["default"].createElement("div", _extends$8({}, draggableProps,
|
|
11580
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _extends$8({}, draggableProps, {
|
|
11521
11581
|
ref: innerRef
|
|
11522
11582
|
}), /*#__PURE__*/React__default["default"].createElement(FormField, _extends$8({
|
|
11523
11583
|
allQuestionKinds: allQuestionKinds,
|
|
11524
11584
|
disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
|
|
11585
|
+
dragHandleProps: dragHandleProps,
|
|
11525
11586
|
getActiveKindDetails: getActiveKindDetails,
|
|
11526
11587
|
kindUniqueOn: kindUniqueOn,
|
|
11527
11588
|
isDeletable: isDeletable(item),
|
|
@@ -11912,6 +11973,15 @@ var Form = function Form(_ref) {
|
|
|
11912
11973
|
if (neetoCist.isNotEmpty(questionLabel)) return neetoCist.truncate(questionLabel, 40);
|
|
11913
11974
|
return neetoCist.humanize(questionKind);
|
|
11914
11975
|
};
|
|
11976
|
+
var richTextQuestions = neetoCist.filterBy({
|
|
11977
|
+
kind: ramda.includes(ramda.__, RICH_TEXT_QUESTIONS)
|
|
11978
|
+
}, questions);
|
|
11979
|
+
var resetFormData = function resetFormData() {
|
|
11980
|
+
resetForm();
|
|
11981
|
+
setFormData({
|
|
11982
|
+
richTextFieldsToReset: ramda.pluck("fieldCode", richTextQuestions)
|
|
11983
|
+
});
|
|
11984
|
+
};
|
|
11915
11985
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Alert, {
|
|
11916
11986
|
isOpen: ramda.isNotNil(deleteQuestionIndex),
|
|
11917
11987
|
submitButtonLabel: t("neetoForm.common.delete"),
|
|
@@ -12001,36 +12071,14 @@ var Form = function Form(_ref) {
|
|
|
12001
12071
|
}))), showActionBlock && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
12002
12072
|
className: "neeto-ui-border-gray-300 flex-shrink-0 border-t py-4"
|
|
12003
12073
|
}, /*#__PURE__*/React__default["default"].createElement(formik$1.ActionBlock, {
|
|
12004
|
-
|
|
12074
|
+
submitButtonProps: submitButtonProps,
|
|
12005
12075
|
cancelButtonProps: _objectSpread$h({
|
|
12006
|
-
label: t("neetoForm.common.reset")
|
|
12007
|
-
|
|
12008
|
-
|
|
12009
|
-
disabled: isSubmitting || !dirty
|
|
12010
|
-
}, submitButtonProps)
|
|
12076
|
+
label: t("neetoForm.common.reset"),
|
|
12077
|
+
onClick: resetFormData
|
|
12078
|
+
}, cancelButtonProps)
|
|
12011
12079
|
}))));
|
|
12012
12080
|
};
|
|
12013
12081
|
|
|
12014
|
-
var getActiveQuestionKindDetails = function getActiveQuestionKindDetails(_ref) {
|
|
12015
|
-
var allQuestionKinds = _ref.allQuestionKinds,
|
|
12016
|
-
item = _ref.item;
|
|
12017
|
-
var kind = item.kind,
|
|
12018
|
-
label = item.label;
|
|
12019
|
-
var _findBy = neetoCist.findBy({
|
|
12020
|
-
type: kind
|
|
12021
|
-
}, allQuestionKinds),
|
|
12022
|
-
FieldComponent = _findBy.component,
|
|
12023
|
-
FieldIcon = _findBy.icon,
|
|
12024
|
-
isSingular = _findBy.isSingular;
|
|
12025
|
-
return {
|
|
12026
|
-
kind: kind,
|
|
12027
|
-
label: label,
|
|
12028
|
-
FieldComponent: FieldComponent,
|
|
12029
|
-
FieldIcon: FieldIcon,
|
|
12030
|
-
isSingular: isSingular
|
|
12031
|
-
};
|
|
12032
|
-
};
|
|
12033
|
-
|
|
12034
12082
|
/* eslint-disable @bigbinary/neeto/file-name-and-export-name-standards */
|
|
12035
12083
|
var requiredLabelValidation = function requiredLabelValidation(schema, field) {
|
|
12036
12084
|
return schema.trim().required(i18next__default["default"].t("neetoForm.common.fieldReq", {
|
|
@@ -16187,13 +16235,13 @@ var getMultipleOptionsFromURL = function getMultipleOptionsFromURL(_ref2) {
|
|
|
16187
16235
|
});
|
|
16188
16236
|
};
|
|
16189
16237
|
var getStarRatingFromUrl = function getStarRatingFromUrl(_ref3) {
|
|
16190
|
-
var
|
|
16238
|
+
var minValue = _ref3.minValue,
|
|
16239
|
+
maxValue = _ref3.maxValue,
|
|
16191
16240
|
fieldCodes = _ref3.fieldCodes,
|
|
16192
16241
|
fieldCode = _ref3.fieldCode;
|
|
16193
16242
|
var fieldCodeValue = fieldCodes[fieldCode];
|
|
16194
16243
|
var rating = parseInt(fieldCodeValue);
|
|
16195
|
-
|
|
16196
|
-
return "".concat(rating >= starCount ? starCount : rating, " / ").concat(starCount);
|
|
16244
|
+
return ramda.isNil(rating) || isNaN(rating) ? "" : ramda.clamp(minValue, maxValue, rating);
|
|
16197
16245
|
};
|
|
16198
16246
|
var getAdditionalGuestsFromUrl = function getAdditionalGuestsFromUrl(_ref4) {
|
|
16199
16247
|
var fieldCodes = _ref4.fieldCodes,
|
|
@@ -16250,7 +16298,8 @@ var generateInitValues = function generateInitValues(_ref7) {
|
|
|
16250
16298
|
kind = question.kind,
|
|
16251
16299
|
optionsAttributes = question.optionsAttributes,
|
|
16252
16300
|
fieldCode = question.fieldCode,
|
|
16253
|
-
|
|
16301
|
+
minValue = question.minValue,
|
|
16302
|
+
maxValue = question.maxValue;
|
|
16254
16303
|
switch (kind) {
|
|
16255
16304
|
case QUESTION_KIND.CONDITION.value:
|
|
16256
16305
|
{
|
|
@@ -16338,7 +16387,8 @@ var generateInitValues = function generateInitValues(_ref7) {
|
|
|
16338
16387
|
{
|
|
16339
16388
|
var _valuesMap$id$value4, _valuesMap7;
|
|
16340
16389
|
initValues[id] = (_valuesMap$id$value4 = (_valuesMap7 = valuesMap) === null || _valuesMap7 === void 0 || (_valuesMap7 = _valuesMap7[id]) === null || _valuesMap7 === void 0 ? void 0 : _valuesMap7.value) !== null && _valuesMap$id$value4 !== void 0 ? _valuesMap$id$value4 : getStarRatingFromUrl({
|
|
16341
|
-
|
|
16390
|
+
minValue: minValue,
|
|
16391
|
+
maxValue: maxValue,
|
|
16342
16392
|
fieldCodes: fieldCodes,
|
|
16343
16393
|
fieldCode: fieldCode
|
|
16344
16394
|
});
|
|
@@ -16463,6 +16513,10 @@ var renderButtonsInOrder = function renderButtonsInOrder(buttonsArray, shouldRev
|
|
|
16463
16513
|
var orderedButtons = shouldReverse ? buttonsArray.reverse() : buttonsArray;
|
|
16464
16514
|
return ramda.map(ramda.identity, orderedButtons);
|
|
16465
16515
|
};
|
|
16516
|
+
var getSelectedRating = function getSelectedRating(value) {
|
|
16517
|
+
var parsedValue = parseInt(value);
|
|
16518
|
+
return isNaN(parsedValue) ? -1 : parsedValue;
|
|
16519
|
+
};
|
|
16466
16520
|
|
|
16467
16521
|
var _excluded$3 = ["value"];
|
|
16468
16522
|
function ownKeys$8(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; }
|
|
@@ -26950,20 +27004,19 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
26950
27004
|
}));
|
|
26951
27005
|
};
|
|
26952
27006
|
|
|
26953
|
-
var _excluded$1 = ["value", "
|
|
27007
|
+
var _excluded$1 = ["value", "iconType", "label", "rating"];
|
|
26954
27008
|
var RatingButton = function RatingButton(_ref) {
|
|
26955
27009
|
var _ref$value = _ref.value,
|
|
26956
|
-
value = _ref$value === void 0 ?
|
|
26957
|
-
|
|
27010
|
+
value = _ref$value === void 0 ? 0 : _ref$value,
|
|
27011
|
+
iconType = _ref.iconType,
|
|
26958
27012
|
label = _ref.label,
|
|
26959
27013
|
rating = _ref.rating,
|
|
26960
|
-
count = _ref.count,
|
|
26961
27014
|
otherProps = _objectWithoutProperties$1(_ref, _excluded$1);
|
|
26962
27015
|
var handleClick = function handleClick(e) {
|
|
26963
27016
|
return e.currentTarget.nextElementSibling.click();
|
|
26964
27017
|
};
|
|
26965
|
-
var Icon = ICONS_MAP[
|
|
26966
|
-
var selectedRating =
|
|
27018
|
+
var Icon = ICONS_MAP[iconType];
|
|
27019
|
+
var selectedRating = getSelectedRating(value);
|
|
26967
27020
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
26968
27021
|
className: classnames__default["default"]({
|
|
26969
27022
|
active: rating === value
|
|
@@ -26973,24 +27026,24 @@ var RatingButton = function RatingButton(_ref) {
|
|
|
26973
27026
|
}, /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
26974
27027
|
size: 24,
|
|
26975
27028
|
className: classnames__default["default"]("neeto-form-engine-star-rating__icon", {
|
|
26976
|
-
"neeto-form-engine-star-rating__icon--active": rating <=
|
|
27029
|
+
"neeto-form-engine-star-rating__icon--active": rating <= selectedRating
|
|
26977
27030
|
})
|
|
26978
27031
|
}), /*#__PURE__*/React__default["default"].createElement("label", {
|
|
26979
27032
|
className: "neeto-form-engine-label"
|
|
26980
27033
|
}, label)), /*#__PURE__*/React__default["default"].createElement("input", _extends$8({
|
|
26981
27034
|
hidden: true,
|
|
26982
|
-
checked:
|
|
27035
|
+
checked: ramda.equals(rating, value),
|
|
26983
27036
|
type: "radio",
|
|
26984
|
-
value:
|
|
27037
|
+
value: rating
|
|
26985
27038
|
}, otherProps)));
|
|
26986
27039
|
};
|
|
26987
27040
|
var RatingButton$1 = /*#__PURE__*/React__default["default"].memo(RatingButton);
|
|
26988
27041
|
|
|
26989
|
-
var _excluded = ["label", "
|
|
27042
|
+
var _excluded = ["label", "minValue", "maxValue", "error"];
|
|
26990
27043
|
var StarRating = function StarRating(_ref) {
|
|
26991
27044
|
var label = _ref.label,
|
|
26992
|
-
|
|
26993
|
-
|
|
27045
|
+
minValue = _ref.minValue,
|
|
27046
|
+
maxValue = _ref.maxValue,
|
|
26994
27047
|
error = _ref.error,
|
|
26995
27048
|
props = _objectWithoutProperties$1(_ref, _excluded);
|
|
26996
27049
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -27001,15 +27054,13 @@ var StarRating = function StarRating(_ref) {
|
|
|
27001
27054
|
className: "neeto-form-engine-label"
|
|
27002
27055
|
}, label)), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
27003
27056
|
className: "neeto-form-engine-star-rating__row"
|
|
27004
|
-
},
|
|
27057
|
+
}, generateArray(minValue, maxValue).map(function (index) {
|
|
27005
27058
|
return /*#__PURE__*/React__default["default"].createElement(RatingButton$1, _extends$8({
|
|
27006
|
-
count: count,
|
|
27007
|
-
shape: shape,
|
|
27008
27059
|
key: index,
|
|
27009
|
-
label: index
|
|
27010
|
-
rating: index
|
|
27060
|
+
label: index,
|
|
27061
|
+
rating: index
|
|
27011
27062
|
}, props));
|
|
27012
|
-
}
|
|
27063
|
+
})), !!error && typeof error === "string" && /*#__PURE__*/React__default["default"].createElement("p", {
|
|
27013
27064
|
className: "neeto-form-engine-input__error",
|
|
27014
27065
|
"data-cy": "neeto-form-engine-star-rating-error"
|
|
27015
27066
|
}, error));
|
|
@@ -27022,10 +27073,10 @@ var StarRatingField = function StarRatingField(_ref) {
|
|
|
27022
27073
|
var name = question.id,
|
|
27023
27074
|
kind = question.kind,
|
|
27024
27075
|
isRequired = question.isRequired,
|
|
27025
|
-
|
|
27026
|
-
|
|
27076
|
+
minValue = question.minValue,
|
|
27077
|
+
maxValue = question.maxValue,
|
|
27078
|
+
iconType = question.iconType;
|
|
27027
27079
|
var label = fieldWithFallback(question, "label");
|
|
27028
|
-
var sanitizedCount = ramda.clamp(0, 10, parseInt(count)) || 0;
|
|
27029
27080
|
return /*#__PURE__*/React__default["default"].createElement(formik.Field, {
|
|
27030
27081
|
name: name,
|
|
27031
27082
|
validate: validateFieldValue({
|
|
@@ -27038,9 +27089,10 @@ var StarRatingField = function StarRatingField(_ref) {
|
|
|
27038
27089
|
var meta = _ref2.meta,
|
|
27039
27090
|
field = _ref2.field;
|
|
27040
27091
|
return /*#__PURE__*/React__default["default"].createElement(StarRating$1, _extends$8({
|
|
27092
|
+
iconType: iconType,
|
|
27093
|
+
maxValue: maxValue,
|
|
27094
|
+
minValue: minValue,
|
|
27041
27095
|
name: name,
|
|
27042
|
-
shape: shape,
|
|
27043
|
-
count: sanitizedCount,
|
|
27044
27096
|
error: meta.touched ? meta.error : "",
|
|
27045
27097
|
label: getLabel(label, isRequired)
|
|
27046
27098
|
}, field));
|
|
@@ -27056,7 +27108,7 @@ var TermsField = function TermsField(_ref) {
|
|
|
27056
27108
|
kind = question.kind,
|
|
27057
27109
|
isRequired = question.isRequired,
|
|
27058
27110
|
nodeId = question.nodeId;
|
|
27059
|
-
var label = fieldWithFallback(question, "label");
|
|
27111
|
+
var label = fieldWithFallback(question, "label", true);
|
|
27060
27112
|
return /*#__PURE__*/React__default["default"].createElement(formik.Field, {
|
|
27061
27113
|
name: name || nodeId,
|
|
27062
27114
|
validate: validateFieldValue({
|
|
@@ -27142,14 +27194,16 @@ var _QUESTION_TO_COMPONEN;
|
|
|
27142
27194
|
var QUESTION_TO_COMPONENT_MAP = (_QUESTION_TO_COMPONEN = {}, _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.TEXT.value, TextField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.NAME.value, NameField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.EMAIL.value, EmailField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.INTEGER.value, TextField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.DECIMAL.value, TextField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.PHONE.value, PhoneNumberField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.QUESTION.value, TextField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.TEXTAREA.value, TextField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.CHECKBOX.value, OptionsField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.RADIO.value, OptionsField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.DROPDOWN.value, OptionsField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.RATING.value, RatingField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.PARAGRAPH.value, function (_ref) {
|
|
27143
27195
|
var question = _ref.question;
|
|
27144
27196
|
return /*#__PURE__*/React__default["default"].createElement(neetoEditor.EditorContent, {
|
|
27145
|
-
content:
|
|
27197
|
+
content: fieldWithFallback(question, "label", true)
|
|
27146
27198
|
});
|
|
27147
27199
|
}), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.TERMS.value, TermsField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.DATE.value, DateField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.STAR_RATING.value, StarRatingField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.ADDITIONAL_GUESTS.value, MultipleEmailInput), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.RICH_TEXT.value, RichTextEditor), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.CONDITION.value, ConditionField), _defineProperty$6(_QUESTION_TO_COMPONEN, QUESTION_KIND.FILE_UPLOAD.value, FileUploadField), _QUESTION_TO_COMPONEN);
|
|
27148
27200
|
|
|
27149
27201
|
var fieldWithFallback = function fieldWithFallback(question, fieldName) {
|
|
27202
|
+
var hasRichContent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
27150
27203
|
var fallback = question["".concat(fieldName, "Fallback")];
|
|
27151
27204
|
var field = question[fieldName];
|
|
27152
|
-
|
|
27205
|
+
var isFieldEmpty = hasRichContent ? neetoEditor.isEditorEmpty(field) : ramda.isEmpty(field);
|
|
27206
|
+
return isFieldEmpty && ramda.isNotNil(fallback) ? fallback : field;
|
|
27153
27207
|
};
|
|
27154
27208
|
var getFieldComponent = function getFieldComponent(_ref) {
|
|
27155
27209
|
var kind = _ref.kind;
|