@bigbinary/neeto-form-frontend 1.2.56 → 1.3.0
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 +108 -111
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +114 -117
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/types.d.ts +3 -2
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"phoneNumberValidation": "phone number starting with country code",
|
|
31
31
|
"yes": "Yes",
|
|
32
32
|
"count": "Count",
|
|
33
|
-
"
|
|
33
|
+
"shape": "Shape",
|
|
34
34
|
"good": "Good",
|
|
35
35
|
"okay": "Okay",
|
|
36
36
|
"bad": "Bad",
|
|
@@ -40,7 +40,9 @@
|
|
|
40
40
|
"hobbies": "Hobbies",
|
|
41
41
|
"country": "Country",
|
|
42
42
|
"addGuests": "Add guests",
|
|
43
|
-
"addGuestsHelper": "Enter emails separated by comma."
|
|
43
|
+
"addGuestsHelper": "Enter emails separated by comma.",
|
|
44
|
+
"start": "Start",
|
|
45
|
+
"end": "End"
|
|
44
46
|
},
|
|
45
47
|
"fields": {
|
|
46
48
|
"mcf": "Multiple choice",
|
package/dist/index.cjs.js
CHANGED
|
@@ -20,8 +20,8 @@ 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 yup = require('yup');
|
|
25
25
|
var useHotkeys = require('@bigbinary/neeto-hotkeys');
|
|
26
26
|
var dayjs = require('dayjs');
|
|
27
27
|
var PhoneNumber$1 = require('@bigbinary/neeto-molecules/PhoneNumber');
|
|
@@ -10077,7 +10077,8 @@ var Accordion = function Accordion(_ref) {
|
|
|
10077
10077
|
showAddQuestionDivider = _ref.showAddQuestionDivider,
|
|
10078
10078
|
isDeletable = _ref.isDeletable,
|
|
10079
10079
|
kindUniqueOn = _ref.kindUniqueOn,
|
|
10080
|
-
disabledAddButtonTooltipProps = _ref.disabledAddButtonTooltipProps
|
|
10080
|
+
disabledAddButtonTooltipProps = _ref.disabledAddButtonTooltipProps,
|
|
10081
|
+
dragHandleProps = _ref.dragHandleProps;
|
|
10081
10082
|
var _useState = React$2.useState(false),
|
|
10082
10083
|
_useState2 = _slicedToArray$3(_useState, 2),
|
|
10083
10084
|
isAddQuestionOpen = _useState2[0],
|
|
@@ -10091,14 +10092,14 @@ var Accordion = function Accordion(_ref) {
|
|
|
10091
10092
|
className: classnames__default["default"]("neeto-form-engine-question-accordion relative", {
|
|
10092
10093
|
"pr-4 md:pr-8": showAddQuestionDivider
|
|
10093
10094
|
})
|
|
10094
|
-
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
10095
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", _extends$8({
|
|
10095
10096
|
"data-cy": "neeto-form-engine-question-accordion-header",
|
|
10096
10097
|
className: classnames__default["default"]({
|
|
10097
10098
|
"neeto-form-engine-question-accordion__header flex h-10 cursor-pointer select-none items-center justify-between px-3 py-2": true,
|
|
10098
10099
|
"neeto-ui-text-gray-700 border": !isExpanded,
|
|
10099
10100
|
"neeto-ui-bg-gray-800 neeto-ui-text-white rounded-b-none": isExpanded
|
|
10100
10101
|
})
|
|
10101
|
-
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
10102
|
+
}, dragHandleProps), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
10102
10103
|
className: "neeto-form-engine-question-accordion__header-left flex items-center overflow-hidden"
|
|
10103
10104
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
10104
10105
|
className: "flex w-8 items-center"
|
|
@@ -10302,6 +10303,39 @@ var Condition$1 = function Condition(_ref) {
|
|
|
10302
10303
|
})));
|
|
10303
10304
|
};
|
|
10304
10305
|
|
|
10306
|
+
var getActiveQuestionKindDetails = function getActiveQuestionKindDetails(_ref) {
|
|
10307
|
+
var allQuestionKinds = _ref.allQuestionKinds,
|
|
10308
|
+
item = _ref.item;
|
|
10309
|
+
var kind = item.kind,
|
|
10310
|
+
label = item.label;
|
|
10311
|
+
var _findBy = neetoCist.findBy({
|
|
10312
|
+
type: kind
|
|
10313
|
+
}, allQuestionKinds),
|
|
10314
|
+
FieldComponent = _findBy.component,
|
|
10315
|
+
FieldIcon = _findBy.icon,
|
|
10316
|
+
isSingular = _findBy.isSingular;
|
|
10317
|
+
return {
|
|
10318
|
+
kind: kind,
|
|
10319
|
+
label: label,
|
|
10320
|
+
FieldComponent: FieldComponent,
|
|
10321
|
+
FieldIcon: FieldIcon,
|
|
10322
|
+
isSingular: isSingular
|
|
10323
|
+
};
|
|
10324
|
+
};
|
|
10325
|
+
var generateArray = function generateArray(start, end) {
|
|
10326
|
+
return ramda.range(start, end + 1);
|
|
10327
|
+
};
|
|
10328
|
+
|
|
10329
|
+
var validateEditorContent = function validateEditorContent(editorRef) {
|
|
10330
|
+
return function () {
|
|
10331
|
+
var _editorRef$current;
|
|
10332
|
+
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") : "";
|
|
10333
|
+
};
|
|
10334
|
+
};
|
|
10335
|
+
var generateRatingOptions = function generateRatingOptions(range) {
|
|
10336
|
+
return generateArray.apply(void 0, _toConsumableArray$1(range)).map(neetoCist.toLabelAndValue);
|
|
10337
|
+
};
|
|
10338
|
+
|
|
10305
10339
|
var _FILE_TYPES_MAP;
|
|
10306
10340
|
var FILE_TYPES = {
|
|
10307
10341
|
DOCUMENTS: "documents",
|
|
@@ -10318,6 +10352,8 @@ var STAR_RATING_ICONS_MAP = {
|
|
|
10318
10352
|
trophy: MemoizedTrophy,
|
|
10319
10353
|
zap: MemoizedZap
|
|
10320
10354
|
};
|
|
10355
|
+
var STAR_RATING_MAX_VALUE_OPTIONS = generateRatingOptions([3, 10]);
|
|
10356
|
+
var STAR_RATING_MIN_VALUE_OPTIONS = generateRatingOptions([0, 1]);
|
|
10321
10357
|
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
10358
|
var DEFAULT_ALLOWED_FILE_TYPES = ramda.values(FILE_TYPES_MAP).flat().join(", ");
|
|
10323
10359
|
var FILE_GROUPS = [{
|
|
@@ -10330,8 +10366,6 @@ var FILE_GROUPS = [{
|
|
|
10330
10366
|
label: i18next.t("neetoForm.fileTypes.audioVideo"),
|
|
10331
10367
|
name: FILE_TYPES.AUDIO_VIDEO
|
|
10332
10368
|
}];
|
|
10333
|
-
var STAR_RATING_MIN_COUNT = 0;
|
|
10334
|
-
var STAR_RATING_MAX_COUNT = 10;
|
|
10335
10369
|
|
|
10336
10370
|
var Dropdown$1 = function Dropdown(_ref) {
|
|
10337
10371
|
var item = _ref.item,
|
|
@@ -10982,32 +11016,6 @@ var SingleChoice$1 = function SingleChoice(_ref) {
|
|
|
10982
11016
|
}));
|
|
10983
11017
|
};
|
|
10984
11018
|
|
|
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
11019
|
var StarRating$3 = function StarRating(_ref) {
|
|
11012
11020
|
var name = _ref.name,
|
|
11013
11021
|
isRequired = _ref.isRequired,
|
|
@@ -11015,21 +11023,13 @@ var StarRating$3 = function StarRating(_ref) {
|
|
|
11015
11023
|
enableFieldCode = _ref.enableFieldCode;
|
|
11016
11024
|
var _useTranslation = reactI18next.useTranslation(),
|
|
11017
11025
|
t = _useTranslation.t;
|
|
11018
|
-
var
|
|
11026
|
+
var _useFormikContext = formik.useFormikContext(),
|
|
11027
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
11028
|
+
var _useField = formik.useField("".concat(name, ".iconType")),
|
|
11019
11029
|
_useField2 = _slicedToArray$3(_useField, 3),
|
|
11020
|
-
|
|
11030
|
+
iconType = _useField2[0].value;
|
|
11021
11031
|
_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;
|
|
11032
|
+
var setIconType = _useField2[2].setValue;
|
|
11033
11033
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11034
11034
|
className: "space-y-4"
|
|
11035
11035
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -11040,22 +11040,31 @@ var StarRating$3 = function StarRating(_ref) {
|
|
|
11040
11040
|
label: t("neetoForm.questions.common.questionFields.field.question"),
|
|
11041
11041
|
name: "".concat(name, ".label"),
|
|
11042
11042
|
rows: 1
|
|
11043
|
-
})), /*#__PURE__*/React__default["default"].createElement(
|
|
11044
|
-
|
|
11045
|
-
},
|
|
11046
|
-
|
|
11047
|
-
label: t("neetoForm.common.
|
|
11048
|
-
|
|
11049
|
-
|
|
11050
|
-
|
|
11051
|
-
|
|
11052
|
-
|
|
11043
|
+
})), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11044
|
+
className: "flex space-x-4"
|
|
11045
|
+
}, /*#__PURE__*/React__default["default"].createElement(formik$1.Select, {
|
|
11046
|
+
className: "w-1/2",
|
|
11047
|
+
label: t("neetoForm.common.start"),
|
|
11048
|
+
name: "".concat(name, ".minValue"),
|
|
11049
|
+
options: STAR_RATING_MIN_VALUE_OPTIONS,
|
|
11050
|
+
onChange: function onChange(option) {
|
|
11051
|
+
return setFieldValue("".concat(name, ".minValue"), option === null || option === void 0 ? void 0 : option.value);
|
|
11052
|
+
}
|
|
11053
|
+
}), /*#__PURE__*/React__default["default"].createElement(formik$1.Select, {
|
|
11054
|
+
className: "w-1/2",
|
|
11055
|
+
label: t("neetoForm.common.end"),
|
|
11056
|
+
name: "".concat(name, ".maxValue"),
|
|
11057
|
+
options: STAR_RATING_MAX_VALUE_OPTIONS,
|
|
11058
|
+
onChange: function onChange(option) {
|
|
11059
|
+
return setFieldValue("".concat(name, ".maxValue"), option === null || option === void 0 ? void 0 : option.value);
|
|
11060
|
+
}
|
|
11061
|
+
})), /*#__PURE__*/React__default["default"].createElement(neetoui.Label, null, t("neetoForm.common.shape")), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11053
11062
|
className: "flex gap-2"
|
|
11054
11063
|
}, Object.entries(STAR_RATING_ICONS_MAP).map(function (_ref2) {
|
|
11055
11064
|
var _ref3 = _slicedToArray$3(_ref2, 2),
|
|
11056
11065
|
name = _ref3[0],
|
|
11057
|
-
|
|
11058
|
-
var isActive = name ===
|
|
11066
|
+
IconType = _ref3[1];
|
|
11067
|
+
var isActive = name === iconType;
|
|
11059
11068
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11060
11069
|
key: name,
|
|
11061
11070
|
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 +11072,9 @@ var StarRating$3 = function StarRating(_ref) {
|
|
|
11063
11072
|
"neeto-ui-text-white neeto-ui-bg-gray-800": isActive
|
|
11064
11073
|
}),
|
|
11065
11074
|
onClick: function onClick() {
|
|
11066
|
-
return
|
|
11075
|
+
return setIconType(name);
|
|
11067
11076
|
}
|
|
11068
|
-
}, /*#__PURE__*/React__default["default"].createElement(
|
|
11077
|
+
}, /*#__PURE__*/React__default["default"].createElement(IconType, null));
|
|
11069
11078
|
})), !isRequired && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
11070
11079
|
className: "w-full"
|
|
11071
11080
|
}, /*#__PURE__*/React__default["default"].createElement(formik$1.Checkbox, {
|
|
@@ -11372,8 +11381,9 @@ var QUESTION_KINDS = [{
|
|
|
11372
11381
|
defaults: {
|
|
11373
11382
|
label: "",
|
|
11374
11383
|
isRequired: true,
|
|
11375
|
-
|
|
11376
|
-
|
|
11384
|
+
minValue: 1,
|
|
11385
|
+
maxValue: 5,
|
|
11386
|
+
iconType: "star"
|
|
11377
11387
|
}
|
|
11378
11388
|
}, {
|
|
11379
11389
|
type: "rating",
|
|
@@ -11457,7 +11467,8 @@ var FormField = function FormField(props) {
|
|
|
11457
11467
|
allQuestionKinds = props.allQuestionKinds,
|
|
11458
11468
|
getActiveKindDetails = props.getActiveKindDetails,
|
|
11459
11469
|
kindUniqueOn = props.kindUniqueOn,
|
|
11460
|
-
disabledAddButtonTooltipProps = props.disabledAddButtonTooltipProps
|
|
11470
|
+
disabledAddButtonTooltipProps = props.disabledAddButtonTooltipProps,
|
|
11471
|
+
dragHandleProps = props.dragHandleProps;
|
|
11461
11472
|
var _getActiveKindDetails = getActiveKindDetails({
|
|
11462
11473
|
allQuestionKinds: allQuestionKinds,
|
|
11463
11474
|
item: item
|
|
@@ -11469,6 +11480,7 @@ var FormField = function FormField(props) {
|
|
|
11469
11480
|
isSingular = _getActiveKindDetails.isSingular;
|
|
11470
11481
|
return /*#__PURE__*/React__default["default"].createElement(Accordion, {
|
|
11471
11482
|
disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
|
|
11483
|
+
dragHandleProps: dragHandleProps,
|
|
11472
11484
|
isDeletable: isDeletable,
|
|
11473
11485
|
isExpanded: isExpanded,
|
|
11474
11486
|
kindUniqueOn: kindUniqueOn,
|
|
@@ -11517,11 +11529,12 @@ var Question = function Question(_ref) {
|
|
|
11517
11529
|
var draggableProps = _ref3.draggableProps,
|
|
11518
11530
|
dragHandleProps = _ref3.dragHandleProps,
|
|
11519
11531
|
innerRef = _ref3.innerRef;
|
|
11520
|
-
return /*#__PURE__*/React__default["default"].createElement("div", _extends$8({}, draggableProps,
|
|
11532
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _extends$8({}, draggableProps, {
|
|
11521
11533
|
ref: innerRef
|
|
11522
11534
|
}), /*#__PURE__*/React__default["default"].createElement(FormField, _extends$8({
|
|
11523
11535
|
allQuestionKinds: allQuestionKinds,
|
|
11524
11536
|
disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
|
|
11537
|
+
dragHandleProps: dragHandleProps,
|
|
11525
11538
|
getActiveKindDetails: getActiveKindDetails,
|
|
11526
11539
|
kindUniqueOn: kindUniqueOn,
|
|
11527
11540
|
isDeletable: isDeletable(item),
|
|
@@ -12011,26 +12024,6 @@ var Form = function Form(_ref) {
|
|
|
12011
12024
|
}))));
|
|
12012
12025
|
};
|
|
12013
12026
|
|
|
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
12027
|
/* eslint-disable @bigbinary/neeto/file-name-and-export-name-standards */
|
|
12035
12028
|
var requiredLabelValidation = function requiredLabelValidation(schema, field) {
|
|
12036
12029
|
return schema.trim().required(i18next__default["default"].t("neetoForm.common.fieldReq", {
|
|
@@ -16187,13 +16180,13 @@ var getMultipleOptionsFromURL = function getMultipleOptionsFromURL(_ref2) {
|
|
|
16187
16180
|
});
|
|
16188
16181
|
};
|
|
16189
16182
|
var getStarRatingFromUrl = function getStarRatingFromUrl(_ref3) {
|
|
16190
|
-
var
|
|
16183
|
+
var minValue = _ref3.minValue,
|
|
16184
|
+
maxValue = _ref3.maxValue,
|
|
16191
16185
|
fieldCodes = _ref3.fieldCodes,
|
|
16192
16186
|
fieldCode = _ref3.fieldCode;
|
|
16193
16187
|
var fieldCodeValue = fieldCodes[fieldCode];
|
|
16194
16188
|
var rating = parseInt(fieldCodeValue);
|
|
16195
|
-
|
|
16196
|
-
return "".concat(rating >= starCount ? starCount : rating, " / ").concat(starCount);
|
|
16189
|
+
return ramda.isNil(rating) || isNaN(rating) ? "" : ramda.clamp(minValue, maxValue, rating);
|
|
16197
16190
|
};
|
|
16198
16191
|
var getAdditionalGuestsFromUrl = function getAdditionalGuestsFromUrl(_ref4) {
|
|
16199
16192
|
var fieldCodes = _ref4.fieldCodes,
|
|
@@ -16250,7 +16243,8 @@ var generateInitValues = function generateInitValues(_ref7) {
|
|
|
16250
16243
|
kind = question.kind,
|
|
16251
16244
|
optionsAttributes = question.optionsAttributes,
|
|
16252
16245
|
fieldCode = question.fieldCode,
|
|
16253
|
-
|
|
16246
|
+
minValue = question.minValue,
|
|
16247
|
+
maxValue = question.maxValue;
|
|
16254
16248
|
switch (kind) {
|
|
16255
16249
|
case QUESTION_KIND.CONDITION.value:
|
|
16256
16250
|
{
|
|
@@ -16338,7 +16332,8 @@ var generateInitValues = function generateInitValues(_ref7) {
|
|
|
16338
16332
|
{
|
|
16339
16333
|
var _valuesMap$id$value4, _valuesMap7;
|
|
16340
16334
|
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
|
-
|
|
16335
|
+
minValue: minValue,
|
|
16336
|
+
maxValue: maxValue,
|
|
16342
16337
|
fieldCodes: fieldCodes,
|
|
16343
16338
|
fieldCode: fieldCode
|
|
16344
16339
|
});
|
|
@@ -16463,6 +16458,10 @@ var renderButtonsInOrder = function renderButtonsInOrder(buttonsArray, shouldRev
|
|
|
16463
16458
|
var orderedButtons = shouldReverse ? buttonsArray.reverse() : buttonsArray;
|
|
16464
16459
|
return ramda.map(ramda.identity, orderedButtons);
|
|
16465
16460
|
};
|
|
16461
|
+
var getSelectedRating = function getSelectedRating(value) {
|
|
16462
|
+
var parsedValue = parseInt(value);
|
|
16463
|
+
return isNaN(parsedValue) ? -1 : parsedValue;
|
|
16464
|
+
};
|
|
16466
16465
|
|
|
16467
16466
|
var _excluded$3 = ["value"];
|
|
16468
16467
|
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 +26949,19 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
26950
26949
|
}));
|
|
26951
26950
|
};
|
|
26952
26951
|
|
|
26953
|
-
var _excluded$1 = ["value", "
|
|
26952
|
+
var _excluded$1 = ["value", "iconType", "label", "rating"];
|
|
26954
26953
|
var RatingButton = function RatingButton(_ref) {
|
|
26955
26954
|
var _ref$value = _ref.value,
|
|
26956
|
-
value = _ref$value === void 0 ?
|
|
26957
|
-
|
|
26955
|
+
value = _ref$value === void 0 ? 0 : _ref$value,
|
|
26956
|
+
iconType = _ref.iconType,
|
|
26958
26957
|
label = _ref.label,
|
|
26959
26958
|
rating = _ref.rating,
|
|
26960
|
-
count = _ref.count,
|
|
26961
26959
|
otherProps = _objectWithoutProperties$1(_ref, _excluded$1);
|
|
26962
26960
|
var handleClick = function handleClick(e) {
|
|
26963
26961
|
return e.currentTarget.nextElementSibling.click();
|
|
26964
26962
|
};
|
|
26965
|
-
var Icon = ICONS_MAP[
|
|
26966
|
-
var selectedRating =
|
|
26963
|
+
var Icon = ICONS_MAP[iconType];
|
|
26964
|
+
var selectedRating = getSelectedRating(value);
|
|
26967
26965
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
26968
26966
|
className: classnames__default["default"]({
|
|
26969
26967
|
active: rating === value
|
|
@@ -26973,24 +26971,24 @@ var RatingButton = function RatingButton(_ref) {
|
|
|
26973
26971
|
}, /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
26974
26972
|
size: 24,
|
|
26975
26973
|
className: classnames__default["default"]("neeto-form-engine-star-rating__icon", {
|
|
26976
|
-
"neeto-form-engine-star-rating__icon--active": rating <=
|
|
26974
|
+
"neeto-form-engine-star-rating__icon--active": rating <= selectedRating
|
|
26977
26975
|
})
|
|
26978
26976
|
}), /*#__PURE__*/React__default["default"].createElement("label", {
|
|
26979
26977
|
className: "neeto-form-engine-label"
|
|
26980
26978
|
}, label)), /*#__PURE__*/React__default["default"].createElement("input", _extends$8({
|
|
26981
26979
|
hidden: true,
|
|
26982
|
-
checked:
|
|
26980
|
+
checked: ramda.equals(rating, value),
|
|
26983
26981
|
type: "radio",
|
|
26984
|
-
value:
|
|
26982
|
+
value: rating
|
|
26985
26983
|
}, otherProps)));
|
|
26986
26984
|
};
|
|
26987
26985
|
var RatingButton$1 = /*#__PURE__*/React__default["default"].memo(RatingButton);
|
|
26988
26986
|
|
|
26989
|
-
var _excluded = ["label", "
|
|
26987
|
+
var _excluded = ["label", "minValue", "maxValue", "error"];
|
|
26990
26988
|
var StarRating = function StarRating(_ref) {
|
|
26991
26989
|
var label = _ref.label,
|
|
26992
|
-
|
|
26993
|
-
|
|
26990
|
+
minValue = _ref.minValue,
|
|
26991
|
+
maxValue = _ref.maxValue,
|
|
26994
26992
|
error = _ref.error,
|
|
26995
26993
|
props = _objectWithoutProperties$1(_ref, _excluded);
|
|
26996
26994
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -27001,15 +26999,13 @@ var StarRating = function StarRating(_ref) {
|
|
|
27001
26999
|
className: "neeto-form-engine-label"
|
|
27002
27000
|
}, label)), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
27003
27001
|
className: "neeto-form-engine-star-rating__row"
|
|
27004
|
-
},
|
|
27002
|
+
}, generateArray(minValue, maxValue).map(function (index) {
|
|
27005
27003
|
return /*#__PURE__*/React__default["default"].createElement(RatingButton$1, _extends$8({
|
|
27006
|
-
count: count,
|
|
27007
|
-
shape: shape,
|
|
27008
27004
|
key: index,
|
|
27009
|
-
label: index
|
|
27010
|
-
rating: index
|
|
27005
|
+
label: index,
|
|
27006
|
+
rating: index
|
|
27011
27007
|
}, props));
|
|
27012
|
-
}
|
|
27008
|
+
})), !!error && typeof error === "string" && /*#__PURE__*/React__default["default"].createElement("p", {
|
|
27013
27009
|
className: "neeto-form-engine-input__error",
|
|
27014
27010
|
"data-cy": "neeto-form-engine-star-rating-error"
|
|
27015
27011
|
}, error));
|
|
@@ -27022,10 +27018,10 @@ var StarRatingField = function StarRatingField(_ref) {
|
|
|
27022
27018
|
var name = question.id,
|
|
27023
27019
|
kind = question.kind,
|
|
27024
27020
|
isRequired = question.isRequired,
|
|
27025
|
-
|
|
27026
|
-
|
|
27021
|
+
minValue = question.minValue,
|
|
27022
|
+
maxValue = question.maxValue,
|
|
27023
|
+
iconType = question.iconType;
|
|
27027
27024
|
var label = fieldWithFallback(question, "label");
|
|
27028
|
-
var sanitizedCount = ramda.clamp(0, 10, parseInt(count)) || 0;
|
|
27029
27025
|
return /*#__PURE__*/React__default["default"].createElement(formik.Field, {
|
|
27030
27026
|
name: name,
|
|
27031
27027
|
validate: validateFieldValue({
|
|
@@ -27038,9 +27034,10 @@ var StarRatingField = function StarRatingField(_ref) {
|
|
|
27038
27034
|
var meta = _ref2.meta,
|
|
27039
27035
|
field = _ref2.field;
|
|
27040
27036
|
return /*#__PURE__*/React__default["default"].createElement(StarRating$1, _extends$8({
|
|
27037
|
+
iconType: iconType,
|
|
27038
|
+
maxValue: maxValue,
|
|
27039
|
+
minValue: minValue,
|
|
27041
27040
|
name: name,
|
|
27042
|
-
shape: shape,
|
|
27043
|
-
count: sanitizedCount,
|
|
27044
27041
|
error: meta.touched ? meta.error : "",
|
|
27045
27042
|
label: getLabel(label, isRequired)
|
|
27046
27043
|
}, field));
|