@bigbinary/neeto-form-frontend 1.2.8 → 1.2.10

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,10 +1,10 @@
1
1
  import * as React$2 from 'react';
2
2
  import React__default, { useLayoutEffect, useEffect, useMemo as useMemo$1, useContext, useReducer, useRef, useState, memo, forwardRef, Fragment } from 'react';
3
3
  import { useField, useFormikContext, FieldArray, Form as Form$1, Formik, Field, FastField } from 'formik';
4
- import { noop as noop$3, findBy, removeBy, isPresent, findById } from '@bigbinary/neeto-cist';
4
+ import { noop as noop$3, slugify, findBy, removeBy, isPresent, findById, notEqualsDeep } from '@bigbinary/neeto-cist';
5
5
  import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
6
6
  import { Typography, Dropdown as Dropdown$2, Tooltip, Button as Button$1, Label, Alert, Toastr, MultiEmailInput, DatePicker, Checkbox as Checkbox$2, Radio, Select, Textarea as Textarea$1, Input as Input$2, Spinner as Spinner$2 } from '@bigbinary/neetoui';
7
- import { assoc, prop, isEmpty, path, reject, omit, insert, compose as compose$1, trim, either, isNil, values as values$1, equals, not, pluck, times } from 'ramda';
7
+ import { assoc, prop, isEmpty, path, reject, omit, insert, compose as compose$1, trim, either, isNil, values as values$1, equals, not, pluck, times, pick } from 'ramda';
8
8
  import { useQuery, useQueryClient, useMutation } from 'react-query';
9
9
  import i18next, { t as t$1 } from 'i18next';
10
10
  import { Input, Email as Email$2, Phone as Phone$2, Up, Down, MenuHorizontal, Delete, Plus, NeetoInvisible, MultipleChoice as MultipleChoice$2, ListDot, Dropdown as Dropdown$3, Rating as Rating$4, Smiley, Checkbox as Checkbox$1, Calendar, Check, Close } from '@bigbinary/neeto-icons';
@@ -190,15 +190,15 @@ function _objectWithoutProperties(source, excluded) {
190
190
  return target;
191
191
  }
192
192
 
193
- var _excluded$e = ["size"],
194
- _excluded2$3 = ["size"],
193
+ var _excluded$f = ["size"],
194
+ _excluded2$2 = ["size"],
195
195
  _excluded3$2 = ["size"],
196
196
  _excluded4$1 = ["size"],
197
197
  _excluded5 = ["size"];
198
198
  var Star = function Star(props) {
199
199
  var _props$size = props.size,
200
200
  size = _props$size === void 0 ? 20 : _props$size,
201
- other = _objectWithoutProperties(props, _excluded$e);
201
+ other = _objectWithoutProperties(props, _excluded$f);
202
202
  return /*#__PURE__*/React__default.createElement("svg", _extends$6({
203
203
  fill: "none",
204
204
  height: size,
@@ -216,7 +216,7 @@ var Star = function Star(props) {
216
216
  var Heart = function Heart(props) {
217
217
  var _props$size2 = props.size,
218
218
  size = _props$size2 === void 0 ? 20 : _props$size2,
219
- other = _objectWithoutProperties(props, _excluded2$3);
219
+ other = _objectWithoutProperties(props, _excluded2$2);
220
220
  return /*#__PURE__*/React__default.createElement("svg", _extends$6({
221
221
  fill: "none",
222
222
  height: size,
@@ -540,14 +540,14 @@ var neetoFormApi = {
540
540
  updatePublicSubmission: updatePublicSubmission
541
541
  };
542
542
 
543
- var _excluded$d = ["formId", "preview"],
543
+ var _excluded$e = ["formId", "preview"],
544
544
  _excluded3$1 = ["formId", "submissionId"];
545
545
  function ownKeys$c(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
546
546
  function _objectSpread$b(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$c(Object(source), !0).forEach(function (key) { _defineProperty$6(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$c(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
547
547
  var useForm = function useForm(_ref) {
548
548
  var formId = _ref.formId,
549
549
  preview = _ref.preview,
550
- options = _objectWithoutProperties(_ref, _excluded$d);
550
+ options = _objectWithoutProperties(_ref, _excluded$e);
551
551
  return useQuery([QUERY_KEYS.QUESTIONS, preview ? "preview/".concat(formId) : formId], function () {
552
552
  return neetoFormApi.getPublicQuestions(formId);
553
553
  }, _objectSpread$b({
@@ -1790,8 +1790,8 @@ reactIs_production_min.typeOf=y;
1790
1790
 
1791
1791
  var reactIsExports = reactIs.exports;
1792
1792
 
1793
- var _excluded$c = ["getDisplayName", "methodName", "renderCountProp", "shouldHandleStateChanges", "storeKey", "withRef", "forwardRef", "context"],
1794
- _excluded2$2 = ["reactReduxForwardedRef"];
1793
+ var _excluded$d = ["getDisplayName", "methodName", "renderCountProp", "shouldHandleStateChanges", "storeKey", "withRef", "forwardRef", "context"],
1794
+ _excluded2$1 = ["reactReduxForwardedRef"];
1795
1795
 
1796
1796
  var EMPTY_ARRAY = [];
1797
1797
  var NO_SUBSCRIPTION_ARRAY = [null, null];
@@ -1940,7 +1940,7 @@ _ref) {
1940
1940
  forwardRef = _ref2$forwardRef === void 0 ? false : _ref2$forwardRef,
1941
1941
  _ref2$context = _ref2.context,
1942
1942
  context = _ref2$context === void 0 ? ReactReduxContext : _ref2$context,
1943
- connectOptions = _objectWithoutPropertiesLoose(_ref2, _excluded$c);
1943
+ connectOptions = _objectWithoutPropertiesLoose(_ref2, _excluded$d);
1944
1944
 
1945
1945
  var Context = context;
1946
1946
  return function wrapWithConnect(WrappedComponent) {
@@ -1978,7 +1978,7 @@ _ref) {
1978
1978
  // and values needed to control behavior (forwarded refs, alternate context instances).
1979
1979
  // To maintain the wrapperProps object reference, memoize this destructuring.
1980
1980
  var reactReduxForwardedRef = props.reactReduxForwardedRef,
1981
- wrapperProps = _objectWithoutPropertiesLoose(props, _excluded2$2);
1981
+ wrapperProps = _objectWithoutPropertiesLoose(props, _excluded2$1);
1982
1982
 
1983
1983
  return [props.context, reactReduxForwardedRef, wrapperProps];
1984
1984
  }, [props]),
@@ -2299,7 +2299,7 @@ function whenMergePropsIsOmitted(mergeProps) {
2299
2299
  }
2300
2300
  var defaultMergePropsFactories = [whenMergePropsIsFunction, whenMergePropsIsOmitted];
2301
2301
 
2302
- var _excluded$b = ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"];
2302
+ var _excluded$c = ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"];
2303
2303
  function impureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch) {
2304
2304
  return function impureFinalPropsSelector(state, ownProps) {
2305
2305
  return mergeProps(mapStateToProps(state, ownProps), mapDispatchToProps(dispatch, ownProps), ownProps);
@@ -2372,7 +2372,7 @@ function finalPropsSelectorFactory(dispatch, _ref2) {
2372
2372
  var initMapStateToProps = _ref2.initMapStateToProps,
2373
2373
  initMapDispatchToProps = _ref2.initMapDispatchToProps,
2374
2374
  initMergeProps = _ref2.initMergeProps,
2375
- options = _objectWithoutPropertiesLoose(_ref2, _excluded$b);
2375
+ options = _objectWithoutPropertiesLoose(_ref2, _excluded$c);
2376
2376
 
2377
2377
  var mapStateToProps = initMapStateToProps(dispatch, options);
2378
2378
  var mapDispatchToProps = initMapDispatchToProps(dispatch, options);
@@ -2382,7 +2382,7 @@ function finalPropsSelectorFactory(dispatch, _ref2) {
2382
2382
  return selectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options);
2383
2383
  }
2384
2384
 
2385
- var _excluded$a = ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"];
2385
+ var _excluded$b = ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"];
2386
2386
  /*
2387
2387
  connect is a facade over connectAdvanced. It turns its args into a compatible
2388
2388
  selectorFactory, which has the signature:
@@ -2446,7 +2446,7 @@ function createConnect(_temp) {
2446
2446
  areStatePropsEqual = _ref3$areStatePropsEq === void 0 ? shallowEqual : _ref3$areStatePropsEq,
2447
2447
  _ref3$areMergedPropsE = _ref3.areMergedPropsEqual,
2448
2448
  areMergedPropsEqual = _ref3$areMergedPropsE === void 0 ? shallowEqual : _ref3$areMergedPropsE,
2449
- extraOptions = _objectWithoutPropertiesLoose(_ref3, _excluded$a);
2449
+ extraOptions = _objectWithoutPropertiesLoose(_ref3, _excluded$b);
2450
2450
 
2451
2451
  var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps');
2452
2452
  var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps');
@@ -10896,21 +10896,22 @@ var ListItem = function ListItem(_ref) {
10896
10896
  label = _ref.label,
10897
10897
  onClick = _ref.onClick;
10898
10898
  return /*#__PURE__*/React__default.createElement("li", {
10899
+ onClick: onClick,
10899
10900
  className: "flex items-center gap-x-2",
10900
- onClick: onClick
10901
+ "data-cy": "neeto-form-engine-".concat(slugify(label))
10901
10902
  }, Icon && /*#__PURE__*/React__default.createElement(Icon, null), /*#__PURE__*/React__default.createElement(Typography, {
10902
10903
  style: "body2"
10903
10904
  }, label));
10904
10905
  };
10905
10906
 
10906
- var _excluded$9 = ["size", "color"],
10907
- _excluded2$1 = ["size", "color"],
10907
+ var _excluded$a = ["size", "color"],
10908
+ _excluded2 = ["size", "color"],
10908
10909
  _excluded3 = ["size", "color"],
10909
10910
  _excluded4 = ["size", "color"];
10910
10911
  var BadSmiley = function BadSmiley(props) {
10911
10912
  var size = props.size,
10912
10913
  color = props.color,
10913
- other = _objectWithoutProperties(props, _excluded$9);
10914
+ other = _objectWithoutProperties(props, _excluded$a);
10914
10915
  return /*#__PURE__*/React__default.createElement("svg", _extends$6({
10915
10916
  fill: "none",
10916
10917
  height: size,
@@ -10932,7 +10933,7 @@ BadSmiley.defaultProps = {
10932
10933
  var OkaySmiley = function OkaySmiley(props) {
10933
10934
  var size = props.size,
10934
10935
  color = props.color,
10935
- other = _objectWithoutProperties(props, _excluded2$1);
10936
+ other = _objectWithoutProperties(props, _excluded2);
10936
10937
  return /*#__PURE__*/React__default.createElement("svg", _extends$6({
10937
10938
  fill: "none",
10938
10939
  height: size,
@@ -11124,10 +11125,10 @@ var Accordion = function Accordion(_ref) {
11124
11125
  }));
11125
11126
  };
11126
11127
 
11127
- var _excluded$8 = ["maxLength"];
11128
+ var _excluded$9 = ["maxLength"];
11128
11129
  var InputWithMaxLength = function InputWithMaxLength(_ref) {
11129
11130
  var maxLength = _ref.maxLength,
11130
- props = _objectWithoutProperties(_ref, _excluded$8);
11131
+ props = _objectWithoutProperties(_ref, _excluded$9);
11131
11132
  var _useField = useField(props),
11132
11133
  _useField2 = _slicedToArray$1(_useField, 3),
11133
11134
  value = _useField2[0].value,
@@ -11143,10 +11144,10 @@ var InputWithMaxLength = function InputWithMaxLength(_ref) {
11143
11144
  }));
11144
11145
  };
11145
11146
 
11146
- var _excluded$7 = ["maxLength"];
11147
+ var _excluded$8 = ["maxLength"];
11147
11148
  var TextAreaWithMaxLength = function TextAreaWithMaxLength(_ref) {
11148
11149
  var maxLength = _ref.maxLength,
11149
- props = _objectWithoutProperties(_ref, _excluded$7);
11150
+ props = _objectWithoutProperties(_ref, _excluded$8);
11150
11151
  var _useField = useField(props),
11151
11152
  _useField2 = _slicedToArray$1(_useField, 3),
11152
11153
  value = _useField2[0].value,
@@ -11821,10 +11822,14 @@ var Editor = function Editor(_ref) {
11821
11822
  return /*#__PURE__*/React__default.createElement("div", {
11822
11823
  className: "w-full cursor-auto"
11823
11824
  }, /*#__PURE__*/React__default.createElement(Editor$1, {
11824
- disabled: isLabelDisabled,
11825
11825
  error: error,
11826
+ className: "px-2 pb-2",
11827
+ contentClassName: "border-none",
11828
+ disabled: isLabelDisabled,
11829
+ errorWrapperClassName: "border-none",
11826
11830
  id: "editor",
11827
11831
  initialValue: value,
11832
+ menuClassName: "border-none",
11828
11833
  name: fieldName,
11829
11834
  ref: editorRef,
11830
11835
  onChange: function onChange(text) {
@@ -12365,7 +12370,7 @@ var List = function List(_ref) {
12365
12370
  })))));
12366
12371
  };
12367
12372
 
12368
- var _excluded$6 = ["questionKinds", "showAddQuestionDivider", "onValueChange", "showActionBlock", "formId", "isDeletable", "isRequiredField", "submitButtonProps", "cancelButtonProps", "isKindAlreadyActive", "getActiveKindDetails", "kindUniqueOn", "isDisabledFieldLabel", "disabledAddButtonTooltipProps"];
12373
+ var _excluded$7 = ["questionKinds", "showAddQuestionDivider", "onValueChange", "showActionBlock", "formId", "isDeletable", "isRequiredField", "submitButtonProps", "cancelButtonProps", "isKindAlreadyActive", "getActiveKindDetails", "kindUniqueOn", "isDisabledFieldLabel", "disabledAddButtonTooltipProps"];
12369
12374
  function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12370
12375
  function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty$6(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12371
12376
  var Form = function Form(_ref) {
@@ -12384,7 +12389,7 @@ var Form = function Form(_ref) {
12384
12389
  kindUniqueOn = _ref.kindUniqueOn,
12385
12390
  isDisabledFieldLabel = _ref.isDisabledFieldLabel,
12386
12391
  disabledAddButtonTooltipProps = _ref.disabledAddButtonTooltipProps,
12387
- formDomProps = _objectWithoutProperties(_ref, _excluded$6);
12392
+ formDomProps = _objectWithoutProperties(_ref, _excluded$7);
12388
12393
  var _useTranslation = useTranslation(),
12389
12394
  t = _useTranslation.t;
12390
12395
  var _useState = useState({}),
@@ -13149,7 +13154,7 @@ var Spinner = function Spinner(_ref) {
13149
13154
  };
13150
13155
  var Spinner$1 = /*#__PURE__*/React__default.memo(Spinner);
13151
13156
 
13152
- var _excluded$5 = ["label", "loading", "success", "className"];
13157
+ var _excluded$6 = ["label", "loading", "success", "className"];
13153
13158
  var Button = function Button(_ref) {
13154
13159
  var label = _ref.label,
13155
13160
  _ref$loading = _ref.loading,
@@ -13158,7 +13163,7 @@ var Button = function Button(_ref) {
13158
13163
  success = _ref$success === void 0 ? false : _ref$success,
13159
13164
  _ref$className = _ref.className,
13160
13165
  className = _ref$className === void 0 ? "" : _ref$className,
13161
- otherProps = _objectWithoutProperties(_ref, _excluded$5);
13166
+ otherProps = _objectWithoutProperties(_ref, _excluded$6);
13162
13167
  return /*#__PURE__*/React__default.createElement("button", _extends$6({
13163
13168
  className: classnames("neeto-form-engine-button", className)
13164
13169
  }, otherProps), loading && /*#__PURE__*/React__default.createElement(ButtonLoader, null), success && /*#__PURE__*/React__default.createElement(Success$2, null), label);
@@ -13378,12 +13383,10 @@ var validateStarRatingField = function validateStarRatingField(_ref5) {
13378
13383
  return schema.trim();
13379
13384
  };
13380
13385
  var validateTermsField = function validateTermsField() {
13381
- var schema = yup["boolean"]().oneOf([true], t$1("neetoForm.common.mustAcceptTermsAndConditions"));
13382
- return schema;
13386
+ return yup["boolean"]().oneOf([true], t$1("neetoForm.common.mustAcceptTermsAndConditions"));
13383
13387
  };
13384
13388
  var validateConditionField = function validateConditionField() {
13385
- var schema = yup["boolean"]().oneOf([true], t$1("neetoForm.common.mustAcceptCondition"));
13386
- return schema;
13389
+ return yup["boolean"]().oneOf([true], t$1("neetoForm.common.mustAcceptCondition"));
13387
13390
  };
13388
13391
  var validateDateField = function validateDateField(_ref6) {
13389
13392
  var label = _ref6.label,
@@ -13415,53 +13418,49 @@ var validateRichTextField = function validateRichTextField(_ref8) {
13415
13418
  }
13416
13419
  return schema.trim();
13417
13420
  };
13418
- var fieldKindValidatorMap = (_fieldKindValidatorMa = {}, _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.EMAIL.value, validateTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.PHONE.value, validateTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.TEXT.value, validateTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.NAME.value, validateTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.QUESTION.value, validateTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.TEXTAREA.value, validateTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.DROPDOWN.value, validateSingleChoiceField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.RADIO.value, validateSingleChoiceField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.CHECKBOX.value, validateMultiChoiceField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.RATING.value, validateRatingField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.TERMS.value, validateTermsField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.DATE.value, validateDateField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.STAR_RATING.value, validateStarRatingField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.ADDITIONAL_GUESTS.value, validateMultiEmailField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.RICH_TEXT.value, validateRichTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.CONDITION.value, validateConditionField), _fieldKindValidatorMa);
13421
+ var fieldKindValidatorMap = (_fieldKindValidatorMa = {}, _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.EMAIL.value, validateTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.PHONE.value, validateTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.TEXT.value, validateTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.NAME.value, validateTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.QUESTION.value, validateTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.TEXTAREA.value, validateTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.DECIMAL.value, validateTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.INTEGER.value, validateTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.DROPDOWN.value, validateSingleChoiceField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.RADIO.value, validateSingleChoiceField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.CHECKBOX.value, validateMultiChoiceField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.RATING.value, validateRatingField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.TERMS.value, validateTermsField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.DATE.value, validateDateField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.STAR_RATING.value, validateStarRatingField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.ADDITIONAL_GUESTS.value, validateMultiEmailField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.RICH_TEXT.value, validateRichTextField), _defineProperty$6(_fieldKindValidatorMa, QUESTION_KIND.CONDITION.value, validateConditionField), _fieldKindValidatorMa);
13419
13422
  var validateFieldValue = function validateFieldValue(_ref9) {
13420
13423
  var kind = _ref9.kind,
13421
13424
  label = _ref9.label,
13422
13425
  isRequired = _ref9.isRequired,
13423
13426
  customValidator = _ref9.customValidator;
13424
- return (
13425
- // eslint-disable-next-line consistent-return
13426
- function (value) {
13427
- if (kind in fieldKindValidatorMap) {
13428
- var validator = fieldKindValidatorMap[kind];
13429
- var schema = customValidator || validator({
13430
- kind: kind,
13431
- label: label,
13432
- isRequired: isRequired
13433
- });
13427
+ return function (value) {
13428
+ if (!(kind in fieldKindValidatorMap)) return;
13429
+ var validator = fieldKindValidatorMap[kind];
13430
+ var schema = customValidator || validator({
13431
+ kind: kind,
13432
+ label: label,
13433
+ isRequired: isRequired
13434
+ });
13434
13435
 
13435
- // eslint-disable-next-line no-async-promise-executor
13436
- return new Promise( /*#__PURE__*/function () {
13437
- var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve) {
13438
- return _regeneratorRuntime.wrap(function _callee$(_context) {
13439
- while (1) switch (_context.prev = _context.next) {
13440
- case 0:
13441
- _context.prev = 0;
13442
- _context.next = 3;
13443
- return schema.validate(value);
13444
- case 3:
13445
- resolve(undefined);
13446
- _context.next = 9;
13447
- break;
13448
- case 6:
13449
- _context.prev = 6;
13450
- _context.t0 = _context["catch"](0);
13451
- resolve(_context.t0.message);
13452
- case 9:
13453
- case "end":
13454
- return _context.stop();
13455
- }
13456
- }, _callee, null, [[0, 6]]);
13457
- }));
13458
- return function (_x) {
13459
- return _ref10.apply(this, arguments);
13460
- };
13461
- }());
13462
- }
13463
- }
13464
- );
13436
+ // eslint-disable-next-line consistent-return, no-async-promise-executor
13437
+ return new Promise( /*#__PURE__*/function () {
13438
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve) {
13439
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
13440
+ while (1) switch (_context.prev = _context.next) {
13441
+ case 0:
13442
+ _context.prev = 0;
13443
+ _context.next = 3;
13444
+ return schema.validate(value);
13445
+ case 3:
13446
+ resolve(undefined);
13447
+ _context.next = 9;
13448
+ break;
13449
+ case 6:
13450
+ _context.prev = 6;
13451
+ _context.t0 = _context["catch"](0);
13452
+ resolve(_context.t0.message);
13453
+ case 9:
13454
+ case "end":
13455
+ return _context.stop();
13456
+ }
13457
+ }, _callee, null, [[0, 6]]);
13458
+ }));
13459
+ return function (_x) {
13460
+ return _ref10.apply(this, arguments);
13461
+ };
13462
+ }());
13463
+ };
13465
13464
  };
13466
13465
 
13467
13466
  var MultipleEmailInput = function MultipleEmailInput(_ref) {
@@ -13518,30 +13517,31 @@ var MultipleEmailInput = function MultipleEmailInput(_ref) {
13518
13517
  })));
13519
13518
  };
13520
13519
 
13521
- var _excluded$4 = ["name", "label", "error", "value"];
13520
+ var _excluded$5 = ["name", "label", "error", "value"];
13522
13521
  var Condition = function Condition(_ref, ref) {
13523
13522
  var name = _ref.name,
13524
13523
  label = _ref.label,
13525
13524
  error = _ref.error,
13526
13525
  value = _ref.value,
13527
- otherProps = _objectWithoutProperties(_ref, _excluded$4);
13526
+ otherProps = _objectWithoutProperties(_ref, _excluded$5);
13528
13527
  return /*#__PURE__*/React__default.createElement("div", {
13529
13528
  className: "neeto-form-engine-terms"
13530
13529
  }, /*#__PURE__*/React__default.createElement("div", {
13531
13530
  className: "neeto-form-engine-choice"
13532
13531
  }, /*#__PURE__*/React__default.createElement("input", _extends$6({
13532
+ name: name,
13533
+ ref: ref,
13534
+ value: value,
13533
13535
  required: true,
13534
13536
  "aria-invalid": !!error,
13535
13537
  id: "condition-".concat(name),
13536
- name: name,
13537
- ref: ref,
13538
- type: "checkbox",
13539
- value: value
13538
+ type: "checkbox"
13540
13539
  }, otherProps)), /*#__PURE__*/React__default.createElement("label", {
13541
13540
  className: "neeto-form-engine-label font-normal",
13542
13541
  htmlFor: "condition-".concat(name)
13543
13542
  }, label)), !!error && typeof error === "string" && /*#__PURE__*/React__default.createElement("p", {
13544
- className: "neeto-form-engine-input__error"
13543
+ className: "neeto-form-engine-input__error",
13544
+ "data-cy": "neeto-form-engine-condition-error"
13545
13545
  }, error));
13546
13546
  };
13547
13547
  var Condition$1 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(Condition));
@@ -16783,7 +16783,7 @@ var ConditionField = function ConditionField(_ref) {
16783
16783
  });
16784
16784
  };
16785
16785
 
16786
- var _excluded$3 = ["value"];
16786
+ var _excluded$4 = ["value"];
16787
16787
  dayjs.extend(weekOfYear);
16788
16788
  dayjs.extend(weekday);
16789
16789
  dayjs.extend(localeData);
@@ -16827,7 +16827,7 @@ var DateField = function DateField(_ref) {
16827
16827
  var meta = _ref2.meta,
16828
16828
  _ref2$field = _ref2.field,
16829
16829
  value = _ref2$field.value,
16830
- field = _objectWithoutProperties(_ref2$field, _excluded$3),
16830
+ field = _objectWithoutProperties(_ref2$field, _excluded$4),
16831
16831
  form = _ref2.form;
16832
16832
  return /*#__PURE__*/React__default.createElement(DatePicker, _extends$6({
16833
16833
  dateFormat: "MMM D, YYYY",
@@ -16874,16 +16874,17 @@ var Choices = function Choices(_ref) {
16874
16874
  active: false
16875
16875
  })
16876
16876
  }, /*#__PURE__*/React__default.createElement(Component, {
16877
+ onChange: onChange,
16878
+ type: type,
16877
16879
  id: option.id,
16878
16880
  label: option.label,
16879
16881
  name: isCheckBox ? "".concat(name, ".").concat(index) : name,
16880
- type: type,
16881
16882
  value: option.id,
16882
- checked: isCheckBox ? (_value$index = value === null || value === void 0 ? void 0 : value[index]) !== null && _value$index !== void 0 ? _value$index : false : value === option.id,
16883
- onChange: onChange
16883
+ checked: isCheckBox ? (_value$index = value === null || value === void 0 ? void 0 : value[index]) !== null && _value$index !== void 0 ? _value$index : false : value === option.id
16884
16884
  }));
16885
16885
  })), !!error && typeof error === "string" && /*#__PURE__*/React__default.createElement("p", {
16886
- className: "neeto-form-engine-input__error"
16886
+ className: "neeto-form-engine-input__error",
16887
+ "data-cy": "neeto-form-engine-".concat(type, "-error")
16887
16888
  }, error));
16888
16889
  };
16889
16890
  var Choices$1 = /*#__PURE__*/React__default.memo(Choices);
@@ -16978,7 +16979,7 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
16978
16979
  });
16979
16980
  };
16980
16981
 
16981
- var _excluded$2 = ["name", "label", "error", "lowestRatingLabel", "averageRatingLabel", "highestRatingLabel", "value"];
16982
+ var _excluded$3 = ["name", "label", "error", "lowestRatingLabel", "averageRatingLabel", "highestRatingLabel", "value"];
16982
16983
  var Rating = function Rating(_ref) {
16983
16984
  var name = _ref.name,
16984
16985
  label = _ref.label,
@@ -16987,7 +16988,7 @@ var Rating = function Rating(_ref) {
16987
16988
  averageRatingLabel = _ref.averageRatingLabel,
16988
16989
  highestRatingLabel = _ref.highestRatingLabel,
16989
16990
  value = _ref.value,
16990
- other = _objectWithoutProperties(_ref, _excluded$2);
16991
+ other = _objectWithoutProperties(_ref, _excluded$3);
16991
16992
  var handleClick = function handleClick(e) {
16992
16993
  return e.currentTarget.nextElementSibling.click();
16993
16994
  };
@@ -17008,9 +17009,9 @@ var Rating = function Rating(_ref) {
17008
17009
  }, /*#__PURE__*/React__default.createElement(Icon, null), /*#__PURE__*/React__default.createElement("label", {
17009
17010
  className: "neeto-form-engine-label"
17010
17011
  }, labels[index])), /*#__PURE__*/React__default.createElement("input", _extends$6({
17012
+ name: name,
17011
17013
  hidden: true,
17012
17014
  checked: rating === value,
17013
- name: name,
17014
17015
  type: "radio",
17015
17016
  value: rating
17016
17017
  }, other)));
@@ -17023,7 +17024,8 @@ var Rating = function Rating(_ref) {
17023
17024
  }, label), /*#__PURE__*/React__default.createElement("div", {
17024
17025
  className: "neeto-form-engine-rating__row"
17025
17026
  }, render()), !!error && typeof error === "string" && /*#__PURE__*/React__default.createElement("p", {
17026
- className: "neeto-form-engine-input__error"
17027
+ className: "neeto-form-engine-input__error",
17028
+ "data-cy": "neeto-form-engine-rating-error"
17027
17029
  }, error));
17028
17030
  };
17029
17031
  var Rating$1 = /*#__PURE__*/React__default.memo(Rating);
@@ -17062,8 +17064,11 @@ var RatingField = function RatingField(_ref) {
17062
17064
  var RichTextEditor = function RichTextEditor(_ref) {
17063
17065
  var editorRef = _ref.editorRef,
17064
17066
  question = _ref.question,
17067
+ preview = _ref.preview,
17065
17068
  _ref$editorProps = _ref.editorProps,
17066
17069
  editorProps = _ref$editorProps === void 0 ? {} : _ref$editorProps;
17070
+ var _useFormikContext = useFormikContext(),
17071
+ errors = _useFormikContext.errors;
17067
17072
  var name = question.id,
17068
17073
  kind = question.kind,
17069
17074
  label = question.label,
@@ -17077,18 +17082,18 @@ var RichTextEditor = function RichTextEditor(_ref) {
17077
17082
  className: "neeto-form-engine-input__label-wrapper"
17078
17083
  }, label && /*#__PURE__*/React__default.createElement("label", {
17079
17084
  className: "neeto-form-engine-label"
17080
- }, getLabel$1(label, isRequired))), /*#__PURE__*/React__default.createElement(FastField, {
17085
+ }, getLabel$1(label, isRequired))), /*#__PURE__*/React__default.createElement(FastField, _extends$6({
17081
17086
  debouncedPlaceholder: debouncedPlaceholder,
17087
+ error: errors[name],
17082
17088
  name: name || nodeId,
17083
17089
  validate: validateFieldValue({
17084
17090
  kind: kind,
17085
17091
  label: label,
17086
17092
  isRequired: isRequired
17087
- }),
17088
- shouldUpdate: function shouldUpdate(nextProps, prevProps) {
17089
- return nextProps.debouncedPlaceholder !== prevProps.debouncedPlaceholder;
17090
- }
17091
- }, function (_ref2) {
17093
+ })
17094
+ }, preview && {
17095
+ shouldUpdate: isPropsUnequal(["debouncedPlaceholder", "error"])
17096
+ }), function (_ref2) {
17092
17097
  var field = _ref2.field,
17093
17098
  form = _ref2.form,
17094
17099
  meta = _ref2.meta;
@@ -17110,8 +17115,7 @@ var RichTextEditor = function RichTextEditor(_ref) {
17110
17115
  }));
17111
17116
  };
17112
17117
 
17113
- var _excluded$1 = ["value", "shape", "label", "rating", "count"],
17114
- _excluded2 = ["label", "count", "shape", "error"];
17118
+ var _excluded$2 = ["value", "shape", "label", "rating", "count"];
17115
17119
  var RatingButton = function RatingButton(_ref) {
17116
17120
  var _ref$value = _ref.value,
17117
17121
  value = _ref$value === void 0 ? "0" : _ref$value,
@@ -17119,7 +17123,7 @@ var RatingButton = function RatingButton(_ref) {
17119
17123
  label = _ref.label,
17120
17124
  rating = _ref.rating,
17121
17125
  count = _ref.count,
17122
- otherProps = _objectWithoutProperties(_ref, _excluded$1);
17126
+ otherProps = _objectWithoutProperties(_ref, _excluded$2);
17123
17127
  var handleClick = function handleClick(e) {
17124
17128
  return e.currentTarget.nextElementSibling.click();
17125
17129
  };
@@ -17145,12 +17149,15 @@ var RatingButton = function RatingButton(_ref) {
17145
17149
  value: "".concat(rating, " / ").concat(count)
17146
17150
  }, otherProps)));
17147
17151
  };
17148
- var StarRating = function StarRating(_ref2) {
17149
- var label = _ref2.label,
17150
- count = _ref2.count,
17151
- shape = _ref2.shape,
17152
- error = _ref2.error,
17153
- props = _objectWithoutProperties(_ref2, _excluded2);
17152
+ var RatingButton$1 = /*#__PURE__*/React__default.memo(RatingButton);
17153
+
17154
+ var _excluded$1 = ["label", "count", "shape", "error"];
17155
+ var StarRating = function StarRating(_ref) {
17156
+ var label = _ref.label,
17157
+ count = _ref.count,
17158
+ shape = _ref.shape,
17159
+ error = _ref.error,
17160
+ props = _objectWithoutProperties(_ref, _excluded$1);
17154
17161
  return /*#__PURE__*/React__default.createElement("div", {
17155
17162
  className: "neeto-form-engine-input__wrapper neeto-form-engine-star-rating"
17156
17163
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -17160,15 +17167,16 @@ var StarRating = function StarRating(_ref2) {
17160
17167
  }, label)), /*#__PURE__*/React__default.createElement("div", {
17161
17168
  className: "neeto-form-engine-star-rating__row"
17162
17169
  }, times(function (index) {
17163
- return /*#__PURE__*/React__default.createElement(RatingButton, _extends$6({
17170
+ return /*#__PURE__*/React__default.createElement(RatingButton$1, _extends$6({
17164
17171
  count: count,
17172
+ shape: shape,
17165
17173
  key: index,
17166
17174
  label: index + 1,
17167
- rating: index + 1,
17168
- shape: shape
17175
+ rating: index + 1
17169
17176
  }, props));
17170
17177
  }, count)), !!error && typeof error === "string" && /*#__PURE__*/React__default.createElement("p", {
17171
- className: "neeto-form-engine-input__error"
17178
+ className: "neeto-form-engine-input__error",
17179
+ "data-cy": "neeto-form-engine-star-rating-error"
17172
17180
  }, error));
17173
17181
  };
17174
17182
  var StarRating$1 = /*#__PURE__*/React__default.memo(StarRating);
@@ -17215,17 +17223,18 @@ var Terms = function Terms(_ref, ref) {
17215
17223
  }, /*#__PURE__*/React__default.createElement("div", {
17216
17224
  className: "neeto-form-engine-choice"
17217
17225
  }, /*#__PURE__*/React__default.createElement("input", _extends$6({
17226
+ name: name,
17227
+ ref: ref,
17228
+ value: value,
17218
17229
  required: true,
17219
17230
  "aria-invalid": !!error,
17220
17231
  id: "terms-and-condition",
17221
- name: name,
17222
- ref: ref,
17223
- type: "checkbox",
17224
- value: value
17232
+ type: "checkbox"
17225
17233
  }, otherProps)), /*#__PURE__*/React__default.createElement(EditorContent, {
17226
17234
  content: label
17227
17235
  })), !!error && typeof error === "string" && /*#__PURE__*/React__default.createElement("p", {
17228
- className: "neeto-form-engine-input__error"
17236
+ className: "neeto-form-engine-input__error",
17237
+ "data-cy": "neeto-form-engine-terms-error"
17229
17238
  }, error));
17230
17239
  };
17231
17240
  var Terms$1 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(Terms));
@@ -17319,6 +17328,11 @@ var getFieldComponent = function getFieldComponent(_ref) {
17319
17328
  return null;
17320
17329
  };
17321
17330
  };
17331
+ var isPropsUnequal = function isPropsUnequal(props) {
17332
+ return function (nextProps, prevProps) {
17333
+ return notEqualsDeep(pick(props, nextProps), pick(props, prevProps));
17334
+ };
17335
+ };
17322
17336
 
17323
17337
  var _path, _defs;
17324
17338
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -17648,10 +17662,10 @@ var ExternalForm = function ExternalForm(_ref) {
17648
17662
  style: "h4",
17649
17663
  weight: "semibold"
17650
17664
  }, titleProps), formTitle || title)), /*#__PURE__*/React__default.createElement(Formik, {
17665
+ onSubmit: onSubmit,
17651
17666
  enableReinitialize: true,
17652
17667
  innerRef: formikInnerRef,
17653
- initialValues: generateInitValues(questions, submission === null || submission === void 0 ? void 0 : submission.responses, preserveValues ? localValues : initialValues),
17654
- onSubmit: onSubmit
17668
+ initialValues: generateInitValues(questions, submission === null || submission === void 0 ? void 0 : submission.responses, preserveValues ? localValues : initialValues)
17655
17669
  }, function (_ref5) {
17656
17670
  var isSubmitting = _ref5.isSubmitting,
17657
17671
  errors = _ref5.errors,
@@ -17668,24 +17682,24 @@ var ExternalForm = function ExternalForm(_ref) {
17668
17682
  ref: mergeRefs(formRef, keyPressRef),
17669
17683
  className: classnames("neeto-form-engine-form relative space-y-4", _defineProperty$6({}, className, className)),
17670
17684
  onChange: function onChange(event) {
17671
- if (!isEmpty(errors)) {
17672
- setFieldError(event.target.name, "");
17673
- }
17685
+ if (isEmpty(errors)) return;
17686
+ setFieldError(event.target.name, "");
17674
17687
  }
17675
17688
  }, formDomProps, {
17676
17689
  onReset: function onReset(e) {
17677
17690
  return _onReset(e, handleReset);
17678
17691
  }
17679
17692
  }), (submission === null || submission === void 0 ? void 0 : submission.isLoading) && /*#__PURE__*/React__default.createElement("div", {
17680
- className: "neeto-ui-bg-gray-100 absolute top-0 left-0 right-0 bottom-0 flex items-center justify-center opacity-75"
17693
+ className: "neeto-ui-bg-gray-100 absolute bottom-0 left-0 right-0 top-0 flex items-center justify-center opacity-75"
17681
17694
  }, /*#__PURE__*/React__default.createElement(Spinner$2, null)), renderedQuestions.map(function (question) {
17682
17695
  var _question$id;
17683
17696
  var FieldComponent = getFieldComponent(question);
17684
17697
  return /*#__PURE__*/React__default.createElement(FieldComponent, {
17685
- customValidator: customValidator === null || customValidator === void 0 ? void 0 : customValidator(question),
17686
- editorRef: editorRef,
17687
17698
  editorProps: editorProps,
17699
+ editorRef: editorRef,
17700
+ preview: preview,
17688
17701
  question: question,
17702
+ customValidator: customValidator === null || customValidator === void 0 ? void 0 : customValidator(question),
17689
17703
  key: (_question$id = question.id) !== null && _question$id !== void 0 ? _question$id : question.nodeId,
17690
17704
  showPrefixIcon: showPrefixIcons
17691
17705
  });