@bigbinary/neeto-form-frontend 1.2.55 → 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/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as React$2 from 'react';
2
2
  import React__default, { useState, useRef, useEffect, useContext, useLayoutEffect as useLayoutEffect$1, forwardRef, useImperativeHandle, Fragment, useReducer, useCallback as useCallback$1, useMemo as useMemo$1, createContext, createElement } from 'react';
3
3
  import { useFormikContext, useField, FieldArray, Form as Form$1, Formik, Field, FastField } from 'formik';
4
- import { noop as noop$4, findBy, slugify, filterBy, isNotEmpty, truncate, humanize, removeBy, isPresent as isPresent$1, isNotPresent, findById, notEqualsDeep } from '@bigbinary/neeto-cist';
5
- import { withEventTargetValue, showThumbsUpToastr, getQueryParams, dateFormat } from '@bigbinary/neeto-commons-frontend/utils';
4
+ import { noop as noop$4, findBy, slugify, toLabelAndValue, filterBy, isNotEmpty, truncate, humanize, removeBy, isPresent as isPresent$1, isNotPresent, findById, notEqualsDeep } from '@bigbinary/neeto-cist';
5
+ import { showThumbsUpToastr, withEventTargetValue, getQueryParams, dateFormat } from '@bigbinary/neeto-commons-frontend/utils';
6
6
  import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
7
- import { Tooltip, Dropdown as Dropdown$2, Alert, Typography, Button as Button$1, Label, Checkbox as Checkbox$1, Toastr, MultiEmailInput, DatePicker, Input as Input$2, Radio as Radio$1, Select, Textarea as Textarea$1, Spinner as Spinner$2 } from '@bigbinary/neetoui';
8
- import { assoc, mergeLeft, prop, isEmpty, path, values, compose as compose$1, trim, useWith, split, either, isNil, equals, difference, reject, pluck, keys, pick, omit, isNotNil, insert, not, pipe as pipe$1, toLower, map, includes, identity, times, clamp as clamp$2, filter as filter$1 } from 'ramda';
7
+ import { Tooltip, Dropdown as Dropdown$2, Alert, Typography, Button as Button$1, Label, Checkbox as Checkbox$1, Toastr, MultiEmailInput, DatePicker, Input as Input$2, Radio as Radio$1, Select as Select$1, Textarea as Textarea$1, Spinner as Spinner$2 } from '@bigbinary/neetoui';
8
+ import { assoc, mergeLeft, prop, isEmpty, path, range, values, compose as compose$1, trim, useWith, split, either, isNil, equals, difference, reject, pluck, keys, pick, omit, isNotNil, insert, not, pipe as pipe$1, toLower, map, includes, identity, clamp as clamp$2, filter as filter$1 } from 'ramda';
9
9
  import { useQuery, useQueryClient, useMutation } from 'react-query';
10
10
  import i18next, { t as t$4 } from 'i18next';
11
11
  import { Input, Email as Email$2, Phone as Phone$2, Globe, Up, Down, MenuHorizontal, Delete, Plus, NeetoInvisible, Checkbox as Checkbox$2, Radio, Dropdown as Dropdown$3, Rating as Rating$4, Smiley, Calendar, Upload, Check, Close, FileGeneric } from '@bigbinary/neeto-icons';
@@ -13,13 +13,13 @@ import { DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE } from '@bigbinary/neeto-commons-
13
13
  import { useMutationWithInvalidation, withImmutableActions, withT, useDebounce } from '@bigbinary/neeto-commons-frontend/react-utils';
14
14
  import axios from 'axios';
15
15
  import ReactDOM, { unstable_batchedUpdates, flushSync as flushSync$1 } from 'react-dom';
16
- import { Input as Input$1, Textarea, Checkbox, ActionBlock } from '@bigbinary/neetoui/formik';
16
+ import { Input as Input$1, Textarea, Checkbox, Select, ActionBlock } from '@bigbinary/neetoui/formik';
17
17
  import { useTranslation, Trans } from 'react-i18next';
18
18
  import { create as create$1 } from 'zustand';
19
19
  import classnames from 'classnames';
20
+ import { Editor as Editor$1, isEditorEmpty, EditorContent } from '@bigbinary/neeto-editor';
20
21
  import * as yup from 'yup';
21
22
  import { object, array, string } from 'yup';
22
- import { Editor as Editor$1, isEditorEmpty, EditorContent } from '@bigbinary/neeto-editor';
23
23
  import useHotkeys from '@bigbinary/neeto-hotkeys';
24
24
  import dayjs from 'dayjs';
25
25
  import { validation, PhoneNumberInput, PhoneNumber as PhoneNumber$1 } from '@bigbinary/neeto-molecules/PhoneNumber';
@@ -10039,7 +10039,8 @@ var Accordion = function Accordion(_ref) {
10039
10039
  showAddQuestionDivider = _ref.showAddQuestionDivider,
10040
10040
  isDeletable = _ref.isDeletable,
10041
10041
  kindUniqueOn = _ref.kindUniqueOn,
10042
- disabledAddButtonTooltipProps = _ref.disabledAddButtonTooltipProps;
10042
+ disabledAddButtonTooltipProps = _ref.disabledAddButtonTooltipProps,
10043
+ dragHandleProps = _ref.dragHandleProps;
10043
10044
  var _useState = useState(false),
10044
10045
  _useState2 = _slicedToArray$3(_useState, 2),
10045
10046
  isAddQuestionOpen = _useState2[0],
@@ -10053,14 +10054,14 @@ var Accordion = function Accordion(_ref) {
10053
10054
  className: classnames("neeto-form-engine-question-accordion relative", {
10054
10055
  "pr-4 md:pr-8": showAddQuestionDivider
10055
10056
  })
10056
- }, /*#__PURE__*/React__default.createElement("div", {
10057
+ }, /*#__PURE__*/React__default.createElement("div", _extends$8({
10057
10058
  "data-cy": "neeto-form-engine-question-accordion-header",
10058
10059
  className: classnames({
10059
10060
  "neeto-form-engine-question-accordion__header flex h-10 cursor-pointer select-none items-center justify-between px-3 py-2": true,
10060
10061
  "neeto-ui-text-gray-700 border": !isExpanded,
10061
10062
  "neeto-ui-bg-gray-800 neeto-ui-text-white rounded-b-none": isExpanded
10062
10063
  })
10063
- }, /*#__PURE__*/React__default.createElement("div", {
10064
+ }, dragHandleProps), /*#__PURE__*/React__default.createElement("div", {
10064
10065
  className: "neeto-form-engine-question-accordion__header-left flex items-center overflow-hidden"
10065
10066
  }, /*#__PURE__*/React__default.createElement("div", {
10066
10067
  className: "flex w-8 items-center"
@@ -10264,6 +10265,39 @@ var Condition$1 = function Condition(_ref) {
10264
10265
  })));
10265
10266
  };
10266
10267
 
10268
+ var getActiveQuestionKindDetails = function getActiveQuestionKindDetails(_ref) {
10269
+ var allQuestionKinds = _ref.allQuestionKinds,
10270
+ item = _ref.item;
10271
+ var kind = item.kind,
10272
+ label = item.label;
10273
+ var _findBy = findBy({
10274
+ type: kind
10275
+ }, allQuestionKinds),
10276
+ FieldComponent = _findBy.component,
10277
+ FieldIcon = _findBy.icon,
10278
+ isSingular = _findBy.isSingular;
10279
+ return {
10280
+ kind: kind,
10281
+ label: label,
10282
+ FieldComponent: FieldComponent,
10283
+ FieldIcon: FieldIcon,
10284
+ isSingular: isSingular
10285
+ };
10286
+ };
10287
+ var generateArray = function generateArray(start, end) {
10288
+ return range(start, end + 1);
10289
+ };
10290
+
10291
+ var validateEditorContent = function validateEditorContent(editorRef) {
10292
+ return function () {
10293
+ var _editorRef$current;
10294
+ return (_editorRef$current = editorRef.current) !== null && _editorRef$current !== void 0 && (_editorRef$current = _editorRef$current.editor) !== null && _editorRef$current !== void 0 && _editorRef$current.isEmpty ? t$4("neetoForm.common.thisFieldIsRequired") : "";
10295
+ };
10296
+ };
10297
+ var generateRatingOptions = function generateRatingOptions(range) {
10298
+ return generateArray.apply(void 0, _toConsumableArray$1(range)).map(toLabelAndValue);
10299
+ };
10300
+
10267
10301
  var _FILE_TYPES_MAP;
10268
10302
  var FILE_TYPES = {
10269
10303
  DOCUMENTS: "documents",
@@ -10280,6 +10314,8 @@ var STAR_RATING_ICONS_MAP = {
10280
10314
  trophy: MemoizedTrophy,
10281
10315
  zap: MemoizedZap
10282
10316
  };
10317
+ var STAR_RATING_MAX_VALUE_OPTIONS = generateRatingOptions([3, 10]);
10318
+ var STAR_RATING_MIN_VALUE_OPTIONS = generateRatingOptions([0, 1]);
10283
10319
  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);
10284
10320
  var DEFAULT_ALLOWED_FILE_TYPES = values(FILE_TYPES_MAP).flat().join(", ");
10285
10321
  var FILE_GROUPS = [{
@@ -10292,8 +10328,6 @@ var FILE_GROUPS = [{
10292
10328
  label: t$4("neetoForm.fileTypes.audioVideo"),
10293
10329
  name: FILE_TYPES.AUDIO_VIDEO
10294
10330
  }];
10295
- var STAR_RATING_MIN_COUNT = 0;
10296
- var STAR_RATING_MAX_COUNT = 10;
10297
10331
 
10298
10332
  var Dropdown$1 = function Dropdown(_ref) {
10299
10333
  var item = _ref.item,
@@ -10944,32 +10978,6 @@ var SingleChoice$1 = function SingleChoice(_ref) {
10944
10978
  }));
10945
10979
  };
10946
10980
 
10947
- var validateEditorContent = function validateEditorContent(editorRef) {
10948
- return function () {
10949
- var _editorRef$current;
10950
- return (_editorRef$current = editorRef.current) !== null && _editorRef$current !== void 0 && (_editorRef$current = _editorRef$current.editor) !== null && _editorRef$current !== void 0 && _editorRef$current.isEmpty ? t$4("neetoForm.common.thisFieldIsRequired") : "";
10951
- };
10952
- };
10953
- var validateStarRatingCount = function validateStarRatingCount(value) {
10954
- try {
10955
- var schema = yup.number().integer().transform(function (value) {
10956
- return isNaN(value) ? null : value;
10957
- }).min(STAR_RATING_MIN_COUNT, t$4("neetoForm.error.minCount", {
10958
- field: t$4("neetoForm.common.count"),
10959
- value: STAR_RATING_MIN_COUNT
10960
- })).max(STAR_RATING_MAX_COUNT, t$4("neetoForm.error.maxCount", {
10961
- field: t$4("neetoForm.common.count"),
10962
- value: STAR_RATING_MAX_COUNT
10963
- })).nullable().required(t$4("neetoForm.common.fieldReq", {
10964
- field: t$4("neetoForm.common.count")
10965
- }));
10966
- schema.validateSync(value);
10967
- return undefined;
10968
- } catch (error) {
10969
- return error.message;
10970
- }
10971
- };
10972
-
10973
10981
  var StarRating$3 = function StarRating(_ref) {
10974
10982
  var name = _ref.name,
10975
10983
  isRequired = _ref.isRequired,
@@ -10977,21 +10985,13 @@ var StarRating$3 = function StarRating(_ref) {
10977
10985
  enableFieldCode = _ref.enableFieldCode;
10978
10986
  var _useTranslation = useTranslation(),
10979
10987
  t = _useTranslation.t;
10980
- var _useField = useField("".concat(name, ".shape")),
10988
+ var _useFormikContext = useFormikContext(),
10989
+ setFieldValue = _useFormikContext.setFieldValue;
10990
+ var _useField = useField("".concat(name, ".iconType")),
10981
10991
  _useField2 = _slicedToArray$3(_useField, 3),
10982
- shape = _useField2[0].value;
10992
+ iconType = _useField2[0].value;
10983
10993
  _useField2[1];
10984
- var setShape = _useField2[2].setValue;
10985
- var _useField3 = useField({
10986
- name: "".concat(name, ".count"),
10987
- validate: validateStarRatingCount
10988
- }),
10989
- _useField4 = _slicedToArray$3(_useField3, 3),
10990
- countField = _useField4[0],
10991
- _useField4$ = _useField4[1],
10992
- countTouched = _useField4$.touched,
10993
- countError = _useField4$.error,
10994
- setCount = _useField4[2].setValue;
10994
+ var setIconType = _useField2[2].setValue;
10995
10995
  return /*#__PURE__*/React__default.createElement("div", {
10996
10996
  className: "space-y-4"
10997
10997
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -11002,22 +11002,31 @@ var StarRating$3 = function StarRating(_ref) {
11002
11002
  label: t("neetoForm.questions.common.questionFields.field.question"),
11003
11003
  name: "".concat(name, ".label"),
11004
11004
  rows: 1
11005
- })), /*#__PURE__*/React__default.createElement(InputWithMaxLength, _extends$8({
11006
- required: true
11007
- }, countField, {
11008
- error: countTouched ? countError : "",
11009
- label: t("neetoForm.common.count"),
11010
- max: STAR_RATING_MAX_COUNT,
11011
- min: STAR_RATING_MIN_COUNT,
11012
- type: "number",
11013
- onChange: withEventTargetValue(setCount)
11014
- })), /*#__PURE__*/React__default.createElement(Label, null, t("neetoForm.common.icon")), /*#__PURE__*/React__default.createElement("div", {
11005
+ })), /*#__PURE__*/React__default.createElement("div", {
11006
+ className: "flex space-x-4"
11007
+ }, /*#__PURE__*/React__default.createElement(Select, {
11008
+ className: "w-1/2",
11009
+ label: t("neetoForm.common.start"),
11010
+ name: "".concat(name, ".minValue"),
11011
+ options: STAR_RATING_MIN_VALUE_OPTIONS,
11012
+ onChange: function onChange(option) {
11013
+ return setFieldValue("".concat(name, ".minValue"), option === null || option === void 0 ? void 0 : option.value);
11014
+ }
11015
+ }), /*#__PURE__*/React__default.createElement(Select, {
11016
+ className: "w-1/2",
11017
+ label: t("neetoForm.common.end"),
11018
+ name: "".concat(name, ".maxValue"),
11019
+ options: STAR_RATING_MAX_VALUE_OPTIONS,
11020
+ onChange: function onChange(option) {
11021
+ return setFieldValue("".concat(name, ".maxValue"), option === null || option === void 0 ? void 0 : option.value);
11022
+ }
11023
+ })), /*#__PURE__*/React__default.createElement(Label, null, t("neetoForm.common.shape")), /*#__PURE__*/React__default.createElement("div", {
11015
11024
  className: "flex gap-2"
11016
11025
  }, Object.entries(STAR_RATING_ICONS_MAP).map(function (_ref2) {
11017
11026
  var _ref3 = _slicedToArray$3(_ref2, 2),
11018
11027
  name = _ref3[0],
11019
- Shape = _ref3[1];
11020
- var isActive = name === shape;
11028
+ IconType = _ref3[1];
11029
+ var isActive = name === iconType;
11021
11030
  return /*#__PURE__*/React__default.createElement("div", {
11022
11031
  key: name,
11023
11032
  className: classnames("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", {
@@ -11025,9 +11034,9 @@ var StarRating$3 = function StarRating(_ref) {
11025
11034
  "neeto-ui-text-white neeto-ui-bg-gray-800": isActive
11026
11035
  }),
11027
11036
  onClick: function onClick() {
11028
- return setShape(name);
11037
+ return setIconType(name);
11029
11038
  }
11030
- }, /*#__PURE__*/React__default.createElement(Shape, null));
11039
+ }, /*#__PURE__*/React__default.createElement(IconType, null));
11031
11040
  })), !isRequired && /*#__PURE__*/React__default.createElement("div", {
11032
11041
  className: "w-full"
11033
11042
  }, /*#__PURE__*/React__default.createElement(Checkbox, {
@@ -11088,19 +11097,30 @@ var Terms$1 = function Terms(_ref) {
11088
11097
  }),
11089
11098
  _useField2 = _slicedToArray$3(_useField, 3),
11090
11099
  value = _useField2[0].value,
11091
- error = _useField2[1].error,
11092
- setValue = _useField2[2].setValue;
11100
+ _useField2$ = _useField2[1],
11101
+ touched = _useField2$.touched,
11102
+ error = _useField2$.error,
11103
+ _useField2$2 = _useField2[2],
11104
+ setTouched = _useField2$2.setTouched,
11105
+ setValue = _useField2$2.setValue;
11093
11106
  useUpdateEditorContent(editorRef, fieldName, value);
11094
11107
  return /*#__PURE__*/React__default.createElement("div", {
11095
11108
  className: "w-full cursor-auto"
11096
11109
  }, /*#__PURE__*/React__default.createElement(Editor$1, {
11097
- error: error,
11110
+ className: "px-2 pb-2",
11111
+ contentClassName: "border-none",
11098
11112
  disabled: isLabelDisabled,
11113
+ error: touched ? error : "",
11114
+ errorWrapperClassName: "border-none",
11099
11115
  id: "editor",
11100
11116
  initialValue: value,
11101
11117
  key: fieldName,
11118
+ menuClassName: "border-none",
11102
11119
  name: fieldName,
11103
11120
  ref: editorRef,
11121
+ onBlur: function onBlur() {
11122
+ return setTouched(true);
11123
+ },
11104
11124
  onChange: setValue
11105
11125
  }));
11106
11126
  };
@@ -11323,8 +11343,9 @@ var QUESTION_KINDS = [{
11323
11343
  defaults: {
11324
11344
  label: "",
11325
11345
  isRequired: true,
11326
- count: 5,
11327
- shape: "star"
11346
+ minValue: 1,
11347
+ maxValue: 5,
11348
+ iconType: "star"
11328
11349
  }
11329
11350
  }, {
11330
11351
  type: "rating",
@@ -11408,7 +11429,8 @@ var FormField = function FormField(props) {
11408
11429
  allQuestionKinds = props.allQuestionKinds,
11409
11430
  getActiveKindDetails = props.getActiveKindDetails,
11410
11431
  kindUniqueOn = props.kindUniqueOn,
11411
- disabledAddButtonTooltipProps = props.disabledAddButtonTooltipProps;
11432
+ disabledAddButtonTooltipProps = props.disabledAddButtonTooltipProps,
11433
+ dragHandleProps = props.dragHandleProps;
11412
11434
  var _getActiveKindDetails = getActiveKindDetails({
11413
11435
  allQuestionKinds: allQuestionKinds,
11414
11436
  item: item
@@ -11420,6 +11442,7 @@ var FormField = function FormField(props) {
11420
11442
  isSingular = _getActiveKindDetails.isSingular;
11421
11443
  return /*#__PURE__*/React__default.createElement(Accordion, {
11422
11444
  disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
11445
+ dragHandleProps: dragHandleProps,
11423
11446
  isDeletable: isDeletable,
11424
11447
  isExpanded: isExpanded,
11425
11448
  kindUniqueOn: kindUniqueOn,
@@ -11468,11 +11491,12 @@ var Question = function Question(_ref) {
11468
11491
  var draggableProps = _ref3.draggableProps,
11469
11492
  dragHandleProps = _ref3.dragHandleProps,
11470
11493
  innerRef = _ref3.innerRef;
11471
- return /*#__PURE__*/React__default.createElement("div", _extends$8({}, draggableProps, dragHandleProps, {
11494
+ return /*#__PURE__*/React__default.createElement("div", _extends$8({}, draggableProps, {
11472
11495
  ref: innerRef
11473
11496
  }), /*#__PURE__*/React__default.createElement(FormField, _extends$8({
11474
11497
  allQuestionKinds: allQuestionKinds,
11475
11498
  disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
11499
+ dragHandleProps: dragHandleProps,
11476
11500
  getActiveKindDetails: getActiveKindDetails,
11477
11501
  kindUniqueOn: kindUniqueOn,
11478
11502
  isDeletable: isDeletable(item),
@@ -11962,26 +11986,6 @@ var Form = function Form(_ref) {
11962
11986
  }))));
11963
11987
  };
11964
11988
 
11965
- var getActiveQuestionKindDetails = function getActiveQuestionKindDetails(_ref) {
11966
- var allQuestionKinds = _ref.allQuestionKinds,
11967
- item = _ref.item;
11968
- var kind = item.kind,
11969
- label = item.label;
11970
- var _findBy = findBy({
11971
- type: kind
11972
- }, allQuestionKinds),
11973
- FieldComponent = _findBy.component,
11974
- FieldIcon = _findBy.icon,
11975
- isSingular = _findBy.isSingular;
11976
- return {
11977
- kind: kind,
11978
- label: label,
11979
- FieldComponent: FieldComponent,
11980
- FieldIcon: FieldIcon,
11981
- isSingular: isSingular
11982
- };
11983
- };
11984
-
11985
11989
  /* eslint-disable @bigbinary/neeto/file-name-and-export-name-standards */
11986
11990
  var requiredLabelValidation = function requiredLabelValidation(schema, field) {
11987
11991
  return schema.trim().required(i18next.t("neetoForm.common.fieldReq", {
@@ -16138,13 +16142,13 @@ var getMultipleOptionsFromURL = function getMultipleOptionsFromURL(_ref2) {
16138
16142
  });
16139
16143
  };
16140
16144
  var getStarRatingFromUrl = function getStarRatingFromUrl(_ref3) {
16141
- var starCount = _ref3.starCount,
16145
+ var minValue = _ref3.minValue,
16146
+ maxValue = _ref3.maxValue,
16142
16147
  fieldCodes = _ref3.fieldCodes,
16143
16148
  fieldCode = _ref3.fieldCode;
16144
16149
  var fieldCodeValue = fieldCodes[fieldCode];
16145
16150
  var rating = parseInt(fieldCodeValue);
16146
- if (!rating || rating < 0) return "";
16147
- return "".concat(rating >= starCount ? starCount : rating, " / ").concat(starCount);
16151
+ return isNil(rating) || isNaN(rating) ? "" : clamp$2(minValue, maxValue, rating);
16148
16152
  };
16149
16153
  var getAdditionalGuestsFromUrl = function getAdditionalGuestsFromUrl(_ref4) {
16150
16154
  var fieldCodes = _ref4.fieldCodes,
@@ -16201,7 +16205,8 @@ var generateInitValues = function generateInitValues(_ref7) {
16201
16205
  kind = question.kind,
16202
16206
  optionsAttributes = question.optionsAttributes,
16203
16207
  fieldCode = question.fieldCode,
16204
- count = question.count;
16208
+ minValue = question.minValue,
16209
+ maxValue = question.maxValue;
16205
16210
  switch (kind) {
16206
16211
  case QUESTION_KIND.CONDITION.value:
16207
16212
  {
@@ -16289,7 +16294,8 @@ var generateInitValues = function generateInitValues(_ref7) {
16289
16294
  {
16290
16295
  var _valuesMap$id$value4, _valuesMap7;
16291
16296
  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({
16292
- starCount: count,
16297
+ minValue: minValue,
16298
+ maxValue: maxValue,
16293
16299
  fieldCodes: fieldCodes,
16294
16300
  fieldCode: fieldCode
16295
16301
  });
@@ -16414,6 +16420,10 @@ var renderButtonsInOrder = function renderButtonsInOrder(buttonsArray, shouldRev
16414
16420
  var orderedButtons = shouldReverse ? buttonsArray.reverse() : buttonsArray;
16415
16421
  return map(identity, orderedButtons);
16416
16422
  };
16423
+ var getSelectedRating = function getSelectedRating(value) {
16424
+ var parsedValue = parseInt(value);
16425
+ return isNaN(parsedValue) ? -1 : parsedValue;
16426
+ };
16417
16427
 
16418
16428
  var _excluded$3 = ["value"];
16419
16429
  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; }
@@ -26681,7 +26691,7 @@ var OptionsField = function OptionsField(_ref) {
26681
26691
  options = _question$optionsAttr === void 0 ? [] : _question$optionsAttr;
26682
26692
  var isDropdown = kind === QUESTION_KIND.DROPDOWN.value;
26683
26693
  var label = fieldWithFallback(question, "label");
26684
- var Component = isDropdown ? Select : Choices$1;
26694
+ var Component = isDropdown ? Select$1 : Choices$1;
26685
26695
  var transformedOptions = isDropdown ? options.map(function (option) {
26686
26696
  return {
26687
26697
  label: fieldWithFallback(option, "label"),
@@ -26901,20 +26911,19 @@ var RichTextEditor = function RichTextEditor(_ref) {
26901
26911
  }));
26902
26912
  };
26903
26913
 
26904
- var _excluded$1 = ["value", "shape", "label", "rating", "count"];
26914
+ var _excluded$1 = ["value", "iconType", "label", "rating"];
26905
26915
  var RatingButton = function RatingButton(_ref) {
26906
26916
  var _ref$value = _ref.value,
26907
- value = _ref$value === void 0 ? "0" : _ref$value,
26908
- shape = _ref.shape,
26917
+ value = _ref$value === void 0 ? 0 : _ref$value,
26918
+ iconType = _ref.iconType,
26909
26919
  label = _ref.label,
26910
26920
  rating = _ref.rating,
26911
- count = _ref.count,
26912
26921
  otherProps = _objectWithoutProperties$1(_ref, _excluded$1);
26913
26922
  var handleClick = function handleClick(e) {
26914
26923
  return e.currentTarget.nextElementSibling.click();
26915
26924
  };
26916
- var Icon = ICONS_MAP[shape];
26917
- var selectedRating = value ? String(value).split(" / ")[0] : 0;
26925
+ var Icon = ICONS_MAP[iconType];
26926
+ var selectedRating = getSelectedRating(value);
26918
26927
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("button", {
26919
26928
  className: classnames({
26920
26929
  active: rating === value
@@ -26924,24 +26933,24 @@ var RatingButton = function RatingButton(_ref) {
26924
26933
  }, /*#__PURE__*/React__default.createElement(Icon, {
26925
26934
  size: 24,
26926
26935
  className: classnames("neeto-form-engine-star-rating__icon", {
26927
- "neeto-form-engine-star-rating__icon--active": rating <= Number(selectedRating)
26936
+ "neeto-form-engine-star-rating__icon--active": rating <= selectedRating
26928
26937
  })
26929
26938
  }), /*#__PURE__*/React__default.createElement("label", {
26930
26939
  className: "neeto-form-engine-label"
26931
26940
  }, label)), /*#__PURE__*/React__default.createElement("input", _extends$8({
26932
26941
  hidden: true,
26933
- checked: "".concat(rating, " / ").concat(count) === value,
26942
+ checked: equals(rating, value),
26934
26943
  type: "radio",
26935
- value: "".concat(rating, " / ").concat(count)
26944
+ value: rating
26936
26945
  }, otherProps)));
26937
26946
  };
26938
26947
  var RatingButton$1 = /*#__PURE__*/React__default.memo(RatingButton);
26939
26948
 
26940
- var _excluded = ["label", "count", "shape", "error"];
26949
+ var _excluded = ["label", "minValue", "maxValue", "error"];
26941
26950
  var StarRating = function StarRating(_ref) {
26942
26951
  var label = _ref.label,
26943
- count = _ref.count,
26944
- shape = _ref.shape,
26952
+ minValue = _ref.minValue,
26953
+ maxValue = _ref.maxValue,
26945
26954
  error = _ref.error,
26946
26955
  props = _objectWithoutProperties$1(_ref, _excluded);
26947
26956
  return /*#__PURE__*/React__default.createElement("div", {
@@ -26952,15 +26961,13 @@ var StarRating = function StarRating(_ref) {
26952
26961
  className: "neeto-form-engine-label"
26953
26962
  }, label)), /*#__PURE__*/React__default.createElement("div", {
26954
26963
  className: "neeto-form-engine-star-rating__row"
26955
- }, times(function (index) {
26964
+ }, generateArray(minValue, maxValue).map(function (index) {
26956
26965
  return /*#__PURE__*/React__default.createElement(RatingButton$1, _extends$8({
26957
- count: count,
26958
- shape: shape,
26959
26966
  key: index,
26960
- label: index + 1,
26961
- rating: index + 1
26967
+ label: index,
26968
+ rating: index
26962
26969
  }, props));
26963
- }, count)), !!error && typeof error === "string" && /*#__PURE__*/React__default.createElement("p", {
26970
+ })), !!error && typeof error === "string" && /*#__PURE__*/React__default.createElement("p", {
26964
26971
  className: "neeto-form-engine-input__error",
26965
26972
  "data-cy": "neeto-form-engine-star-rating-error"
26966
26973
  }, error));
@@ -26973,10 +26980,10 @@ var StarRatingField = function StarRatingField(_ref) {
26973
26980
  var name = question.id,
26974
26981
  kind = question.kind,
26975
26982
  isRequired = question.isRequired,
26976
- count = question.count,
26977
- shape = question.shape;
26983
+ minValue = question.minValue,
26984
+ maxValue = question.maxValue,
26985
+ iconType = question.iconType;
26978
26986
  var label = fieldWithFallback(question, "label");
26979
- var sanitizedCount = clamp$2(0, 10, parseInt(count)) || 0;
26980
26987
  return /*#__PURE__*/React__default.createElement(Field, {
26981
26988
  name: name,
26982
26989
  validate: validateFieldValue({
@@ -26989,9 +26996,10 @@ var StarRatingField = function StarRatingField(_ref) {
26989
26996
  var meta = _ref2.meta,
26990
26997
  field = _ref2.field;
26991
26998
  return /*#__PURE__*/React__default.createElement(StarRating$1, _extends$8({
26999
+ iconType: iconType,
27000
+ maxValue: maxValue,
27001
+ minValue: minValue,
26992
27002
  name: name,
26993
- shape: shape,
26994
- count: sanitizedCount,
26995
27003
  error: meta.touched ? meta.error : "",
26996
27004
  label: getLabel(label, isRequired)
26997
27005
  }, field));