@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/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, {
@@ -11334,8 +11343,9 @@ var QUESTION_KINDS = [{
11334
11343
  defaults: {
11335
11344
  label: "",
11336
11345
  isRequired: true,
11337
- count: 5,
11338
- shape: "star"
11346
+ minValue: 1,
11347
+ maxValue: 5,
11348
+ iconType: "star"
11339
11349
  }
11340
11350
  }, {
11341
11351
  type: "rating",
@@ -11419,7 +11429,8 @@ var FormField = function FormField(props) {
11419
11429
  allQuestionKinds = props.allQuestionKinds,
11420
11430
  getActiveKindDetails = props.getActiveKindDetails,
11421
11431
  kindUniqueOn = props.kindUniqueOn,
11422
- disabledAddButtonTooltipProps = props.disabledAddButtonTooltipProps;
11432
+ disabledAddButtonTooltipProps = props.disabledAddButtonTooltipProps,
11433
+ dragHandleProps = props.dragHandleProps;
11423
11434
  var _getActiveKindDetails = getActiveKindDetails({
11424
11435
  allQuestionKinds: allQuestionKinds,
11425
11436
  item: item
@@ -11431,6 +11442,7 @@ var FormField = function FormField(props) {
11431
11442
  isSingular = _getActiveKindDetails.isSingular;
11432
11443
  return /*#__PURE__*/React__default.createElement(Accordion, {
11433
11444
  disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
11445
+ dragHandleProps: dragHandleProps,
11434
11446
  isDeletable: isDeletable,
11435
11447
  isExpanded: isExpanded,
11436
11448
  kindUniqueOn: kindUniqueOn,
@@ -11479,11 +11491,12 @@ var Question = function Question(_ref) {
11479
11491
  var draggableProps = _ref3.draggableProps,
11480
11492
  dragHandleProps = _ref3.dragHandleProps,
11481
11493
  innerRef = _ref3.innerRef;
11482
- return /*#__PURE__*/React__default.createElement("div", _extends$8({}, draggableProps, dragHandleProps, {
11494
+ return /*#__PURE__*/React__default.createElement("div", _extends$8({}, draggableProps, {
11483
11495
  ref: innerRef
11484
11496
  }), /*#__PURE__*/React__default.createElement(FormField, _extends$8({
11485
11497
  allQuestionKinds: allQuestionKinds,
11486
11498
  disabledAddButtonTooltipProps: disabledAddButtonTooltipProps,
11499
+ dragHandleProps: dragHandleProps,
11487
11500
  getActiveKindDetails: getActiveKindDetails,
11488
11501
  kindUniqueOn: kindUniqueOn,
11489
11502
  isDeletable: isDeletable(item),
@@ -11973,26 +11986,6 @@ var Form = function Form(_ref) {
11973
11986
  }))));
11974
11987
  };
11975
11988
 
11976
- var getActiveQuestionKindDetails = function getActiveQuestionKindDetails(_ref) {
11977
- var allQuestionKinds = _ref.allQuestionKinds,
11978
- item = _ref.item;
11979
- var kind = item.kind,
11980
- label = item.label;
11981
- var _findBy = findBy({
11982
- type: kind
11983
- }, allQuestionKinds),
11984
- FieldComponent = _findBy.component,
11985
- FieldIcon = _findBy.icon,
11986
- isSingular = _findBy.isSingular;
11987
- return {
11988
- kind: kind,
11989
- label: label,
11990
- FieldComponent: FieldComponent,
11991
- FieldIcon: FieldIcon,
11992
- isSingular: isSingular
11993
- };
11994
- };
11995
-
11996
11989
  /* eslint-disable @bigbinary/neeto/file-name-and-export-name-standards */
11997
11990
  var requiredLabelValidation = function requiredLabelValidation(schema, field) {
11998
11991
  return schema.trim().required(i18next.t("neetoForm.common.fieldReq", {
@@ -16149,13 +16142,13 @@ var getMultipleOptionsFromURL = function getMultipleOptionsFromURL(_ref2) {
16149
16142
  });
16150
16143
  };
16151
16144
  var getStarRatingFromUrl = function getStarRatingFromUrl(_ref3) {
16152
- var starCount = _ref3.starCount,
16145
+ var minValue = _ref3.minValue,
16146
+ maxValue = _ref3.maxValue,
16153
16147
  fieldCodes = _ref3.fieldCodes,
16154
16148
  fieldCode = _ref3.fieldCode;
16155
16149
  var fieldCodeValue = fieldCodes[fieldCode];
16156
16150
  var rating = parseInt(fieldCodeValue);
16157
- if (!rating || rating < 0) return "";
16158
- return "".concat(rating >= starCount ? starCount : rating, " / ").concat(starCount);
16151
+ return isNil(rating) || isNaN(rating) ? "" : clamp$2(minValue, maxValue, rating);
16159
16152
  };
16160
16153
  var getAdditionalGuestsFromUrl = function getAdditionalGuestsFromUrl(_ref4) {
16161
16154
  var fieldCodes = _ref4.fieldCodes,
@@ -16212,7 +16205,8 @@ var generateInitValues = function generateInitValues(_ref7) {
16212
16205
  kind = question.kind,
16213
16206
  optionsAttributes = question.optionsAttributes,
16214
16207
  fieldCode = question.fieldCode,
16215
- count = question.count;
16208
+ minValue = question.minValue,
16209
+ maxValue = question.maxValue;
16216
16210
  switch (kind) {
16217
16211
  case QUESTION_KIND.CONDITION.value:
16218
16212
  {
@@ -16300,7 +16294,8 @@ var generateInitValues = function generateInitValues(_ref7) {
16300
16294
  {
16301
16295
  var _valuesMap$id$value4, _valuesMap7;
16302
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({
16303
- starCount: count,
16297
+ minValue: minValue,
16298
+ maxValue: maxValue,
16304
16299
  fieldCodes: fieldCodes,
16305
16300
  fieldCode: fieldCode
16306
16301
  });
@@ -16425,6 +16420,10 @@ var renderButtonsInOrder = function renderButtonsInOrder(buttonsArray, shouldRev
16425
16420
  var orderedButtons = shouldReverse ? buttonsArray.reverse() : buttonsArray;
16426
16421
  return map(identity, orderedButtons);
16427
16422
  };
16423
+ var getSelectedRating = function getSelectedRating(value) {
16424
+ var parsedValue = parseInt(value);
16425
+ return isNaN(parsedValue) ? -1 : parsedValue;
16426
+ };
16428
16427
 
16429
16428
  var _excluded$3 = ["value"];
16430
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; }
@@ -26692,7 +26691,7 @@ var OptionsField = function OptionsField(_ref) {
26692
26691
  options = _question$optionsAttr === void 0 ? [] : _question$optionsAttr;
26693
26692
  var isDropdown = kind === QUESTION_KIND.DROPDOWN.value;
26694
26693
  var label = fieldWithFallback(question, "label");
26695
- var Component = isDropdown ? Select : Choices$1;
26694
+ var Component = isDropdown ? Select$1 : Choices$1;
26696
26695
  var transformedOptions = isDropdown ? options.map(function (option) {
26697
26696
  return {
26698
26697
  label: fieldWithFallback(option, "label"),
@@ -26912,20 +26911,19 @@ var RichTextEditor = function RichTextEditor(_ref) {
26912
26911
  }));
26913
26912
  };
26914
26913
 
26915
- var _excluded$1 = ["value", "shape", "label", "rating", "count"];
26914
+ var _excluded$1 = ["value", "iconType", "label", "rating"];
26916
26915
  var RatingButton = function RatingButton(_ref) {
26917
26916
  var _ref$value = _ref.value,
26918
- value = _ref$value === void 0 ? "0" : _ref$value,
26919
- shape = _ref.shape,
26917
+ value = _ref$value === void 0 ? 0 : _ref$value,
26918
+ iconType = _ref.iconType,
26920
26919
  label = _ref.label,
26921
26920
  rating = _ref.rating,
26922
- count = _ref.count,
26923
26921
  otherProps = _objectWithoutProperties$1(_ref, _excluded$1);
26924
26922
  var handleClick = function handleClick(e) {
26925
26923
  return e.currentTarget.nextElementSibling.click();
26926
26924
  };
26927
- var Icon = ICONS_MAP[shape];
26928
- var selectedRating = value ? String(value).split(" / ")[0] : 0;
26925
+ var Icon = ICONS_MAP[iconType];
26926
+ var selectedRating = getSelectedRating(value);
26929
26927
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("button", {
26930
26928
  className: classnames({
26931
26929
  active: rating === value
@@ -26935,24 +26933,24 @@ var RatingButton = function RatingButton(_ref) {
26935
26933
  }, /*#__PURE__*/React__default.createElement(Icon, {
26936
26934
  size: 24,
26937
26935
  className: classnames("neeto-form-engine-star-rating__icon", {
26938
- "neeto-form-engine-star-rating__icon--active": rating <= Number(selectedRating)
26936
+ "neeto-form-engine-star-rating__icon--active": rating <= selectedRating
26939
26937
  })
26940
26938
  }), /*#__PURE__*/React__default.createElement("label", {
26941
26939
  className: "neeto-form-engine-label"
26942
26940
  }, label)), /*#__PURE__*/React__default.createElement("input", _extends$8({
26943
26941
  hidden: true,
26944
- checked: "".concat(rating, " / ").concat(count) === value,
26942
+ checked: equals(rating, value),
26945
26943
  type: "radio",
26946
- value: "".concat(rating, " / ").concat(count)
26944
+ value: rating
26947
26945
  }, otherProps)));
26948
26946
  };
26949
26947
  var RatingButton$1 = /*#__PURE__*/React__default.memo(RatingButton);
26950
26948
 
26951
- var _excluded = ["label", "count", "shape", "error"];
26949
+ var _excluded = ["label", "minValue", "maxValue", "error"];
26952
26950
  var StarRating = function StarRating(_ref) {
26953
26951
  var label = _ref.label,
26954
- count = _ref.count,
26955
- shape = _ref.shape,
26952
+ minValue = _ref.minValue,
26953
+ maxValue = _ref.maxValue,
26956
26954
  error = _ref.error,
26957
26955
  props = _objectWithoutProperties$1(_ref, _excluded);
26958
26956
  return /*#__PURE__*/React__default.createElement("div", {
@@ -26963,15 +26961,13 @@ var StarRating = function StarRating(_ref) {
26963
26961
  className: "neeto-form-engine-label"
26964
26962
  }, label)), /*#__PURE__*/React__default.createElement("div", {
26965
26963
  className: "neeto-form-engine-star-rating__row"
26966
- }, times(function (index) {
26964
+ }, generateArray(minValue, maxValue).map(function (index) {
26967
26965
  return /*#__PURE__*/React__default.createElement(RatingButton$1, _extends$8({
26968
- count: count,
26969
- shape: shape,
26970
26966
  key: index,
26971
- label: index + 1,
26972
- rating: index + 1
26967
+ label: index,
26968
+ rating: index
26973
26969
  }, props));
26974
- }, count)), !!error && typeof error === "string" && /*#__PURE__*/React__default.createElement("p", {
26970
+ })), !!error && typeof error === "string" && /*#__PURE__*/React__default.createElement("p", {
26975
26971
  className: "neeto-form-engine-input__error",
26976
26972
  "data-cy": "neeto-form-engine-star-rating-error"
26977
26973
  }, error));
@@ -26984,10 +26980,10 @@ var StarRatingField = function StarRatingField(_ref) {
26984
26980
  var name = question.id,
26985
26981
  kind = question.kind,
26986
26982
  isRequired = question.isRequired,
26987
- count = question.count,
26988
- shape = question.shape;
26983
+ minValue = question.minValue,
26984
+ maxValue = question.maxValue,
26985
+ iconType = question.iconType;
26989
26986
  var label = fieldWithFallback(question, "label");
26990
- var sanitizedCount = clamp$2(0, 10, parseInt(count)) || 0;
26991
26987
  return /*#__PURE__*/React__default.createElement(Field, {
26992
26988
  name: name,
26993
26989
  validate: validateFieldValue({
@@ -27000,9 +26996,10 @@ var StarRatingField = function StarRatingField(_ref) {
27000
26996
  var meta = _ref2.meta,
27001
26997
  field = _ref2.field;
27002
26998
  return /*#__PURE__*/React__default.createElement(StarRating$1, _extends$8({
26999
+ iconType: iconType,
27000
+ maxValue: maxValue,
27001
+ minValue: minValue,
27003
27002
  name: name,
27004
- shape: shape,
27005
- count: sanitizedCount,
27006
27003
  error: meta.touched ? meta.error : "",
27007
27004
  label: getLabel(label, isRequired)
27008
27005
  }, field));