@bigbinary/neeto-form-frontend 4.1.9 → 4.2.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.
Files changed (44) hide show
  1. package/app/javascript/src/translations/en.json +5 -1
  2. package/dist/BuildForm.js +103 -60
  3. package/dist/BuildForm.js.map +1 -1
  4. package/dist/ExternalForm.js +5 -4
  5. package/dist/ExternalForm.js.map +1 -1
  6. package/dist/Submission.js +2 -2
  7. package/dist/Submission.js.map +1 -1
  8. package/dist/UrlBuilder.js +3 -2
  9. package/dist/UrlBuilder.js.map +1 -1
  10. package/dist/{buildForm-BwhLCvEE.js → buildForm-CooylMLL.js} +3 -2
  11. package/dist/buildForm-CooylMLL.js.map +1 -0
  12. package/dist/{buildForm-CsVQHcC7.js → buildForm-DcE5kFvR.js} +3 -2
  13. package/dist/buildForm-DcE5kFvR.js.map +1 -0
  14. package/dist/cjs/BuildForm.js +103 -60
  15. package/dist/cjs/BuildForm.js.map +1 -1
  16. package/dist/cjs/ExternalForm.js +5 -4
  17. package/dist/cjs/ExternalForm.js.map +1 -1
  18. package/dist/cjs/Submission.js +2 -2
  19. package/dist/cjs/Submission.js.map +1 -1
  20. package/dist/cjs/UrlBuilder.js +3 -2
  21. package/dist/cjs/UrlBuilder.js.map +1 -1
  22. package/dist/cjs/hooks.js +1 -1
  23. package/dist/cjs/index.js +5 -3
  24. package/dist/cjs/index.js.map +1 -1
  25. package/dist/{constants-DXeRH2r2.js → constants-BjWWA3Oq.js} +11 -2
  26. package/dist/constants-BjWWA3Oq.js.map +1 -0
  27. package/dist/{constants-D0zli_cv.js → constants-QPLZ_r-D.js} +10 -3
  28. package/dist/constants-QPLZ_r-D.js.map +1 -0
  29. package/dist/hooks.js +1 -1
  30. package/dist/index.js +5 -3
  31. package/dist/index.js.map +1 -1
  32. package/dist/main.css +1 -1
  33. package/dist/main.css.map +1 -1
  34. package/dist/{utils-C-ermU02.js → utils-BwFLBXs2.js} +114 -39
  35. package/dist/utils-BwFLBXs2.js.map +1 -0
  36. package/dist/{utils-CdeIdZRi.js → utils-GRfGBny0.js} +114 -39
  37. package/dist/utils-GRfGBny0.js.map +1 -0
  38. package/package.json +17 -17
  39. package/dist/buildForm-BwhLCvEE.js.map +0 -1
  40. package/dist/buildForm-CsVQHcC7.js.map +0 -1
  41. package/dist/constants-D0zli_cv.js.map +0 -1
  42. package/dist/constants-DXeRH2r2.js.map +0 -1
  43. package/dist/utils-C-ermU02.js.map +0 -1
  44. package/dist/utils-CdeIdZRi.js.map +0 -1
@@ -24,7 +24,7 @@ var yup = require('yup');
24
24
  var i18next = require('i18next');
25
25
  var jsxRuntime = require('react/jsx-runtime');
26
26
  var _toArray = require('@babel/runtime/helpers/toArray');
27
- var constants = require('./constants-DXeRH2r2.js');
27
+ var constants = require('./constants-BjWWA3Oq.js');
28
28
  var classnames = require('classnames');
29
29
  var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
30
30
  var Refresh = require('@bigbinary/neeto-icons/Refresh');
@@ -44,6 +44,7 @@ var FileUpload = require('@bigbinary/neeto-molecules/FileUpload');
44
44
  var Label = require('@bigbinary/neetoui/Label');
45
45
  var Select = require('@bigbinary/neetoui/Select');
46
46
  var Radio = require('@bigbinary/neetoui/Radio');
47
+ var Image = require('@bigbinary/neeto-icons/Image');
47
48
  var NeetoEditor = require('@bigbinary/neeto-editor/Editor');
48
49
  var Textarea = require('@bigbinary/neetoui/Textarea');
49
50
 
@@ -932,7 +933,7 @@ var MultipleEmailInput = function MultipleEmailInput(_ref) {
932
933
  className: "flex flex-col gap-2 items-end",
933
934
  children: [/*#__PURE__*/jsxRuntime.jsx(Button, _defineProperty(_defineProperty(_defineProperty({
934
935
  label: label,
935
- "data-cy": "add-guest-button",
936
+ "data-testid": "add-guest-button",
936
937
  disabled: isReadOnly,
937
938
  icon: Plus,
938
939
  iconPosition: "left"
@@ -1002,7 +1003,7 @@ var CaptchaField = function CaptchaField(_ref) {
1002
1003
  })
1003
1004
  }), touched && error && /*#__PURE__*/jsxRuntime.jsx("p", {
1004
1005
  className: "neeto-form-engine-input__error",
1005
- "data-cy": "neeto-form-engine-captcha-error",
1006
+ "data-testid": "neeto-form-engine-captcha-error",
1006
1007
  children: error
1007
1008
  })]
1008
1009
  });
@@ -1068,7 +1069,7 @@ var MathCaptcha = function MathCaptcha(_ref) {
1068
1069
  }, [userInput]);
1069
1070
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
1070
1071
  className: "neeto-form-nano-math-captcha",
1071
- "data-cy": "math-captcha",
1072
+ "data-testid": "math-captcha",
1072
1073
  ref: captchaRef,
1073
1074
  children: [/*#__PURE__*/jsxRuntime.jsx("button", {
1074
1075
  className: "neeto-form-nano-math-captcha__button",
@@ -1078,13 +1079,13 @@ var MathCaptcha = function MathCaptcha(_ref) {
1078
1079
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1079
1080
  className: "neeto-form-nano-math-captcha__equation",
1080
1081
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
1081
- "data-cy": "first-number",
1082
+ "data-testid": "first-number",
1082
1083
  children: firstNumber
1083
1084
  }), /*#__PURE__*/jsxRuntime.jsx("span", {
1084
- "data-cy": "operator",
1085
+ "data-testid": "operator",
1085
1086
  children: operator
1086
1087
  }), /*#__PURE__*/jsxRuntime.jsx("span", {
1087
- "data-cy": "second-number",
1088
+ "data-testid": "second-number",
1088
1089
  children: secondNumber
1089
1090
  }), /*#__PURE__*/jsxRuntime.jsx("span", {
1090
1091
  children: "="
@@ -1092,7 +1093,7 @@ var MathCaptcha = function MathCaptcha(_ref) {
1092
1093
  }), /*#__PURE__*/jsxRuntime.jsx(Input, {
1093
1094
  required: true,
1094
1095
  className: "neeto-form-nano-math-captcha__input",
1095
- "data-cy": "math-captcha-input",
1096
+ "data-testid": "math-captcha-input",
1096
1097
  value: userInput,
1097
1098
  onBlur: handleBlur,
1098
1099
  onChange: utils.withEventTargetValue(setUserInput)
@@ -1177,7 +1178,7 @@ var DateField = function DateField(_ref) {
1177
1178
  className: "neeto-form-engine-input__label-wrapper",
1178
1179
  children: label && /*#__PURE__*/jsxRuntime.jsx("label", {
1179
1180
  className: "neeto-form-engine-label",
1180
- "data-cy": "".concat(neetoCist.hyphenate(label), "-input-label"),
1181
+ "data-testid": "".concat(neetoCist.hyphenate(label), "-input-label"),
1181
1182
  children: getLabel(label, isRequired)
1182
1183
  })
1183
1184
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -1199,7 +1200,7 @@ var DateField = function DateField(_ref) {
1199
1200
  return /*#__PURE__*/jsxRuntime.jsx(DatePicker, _objectSpread$e(_objectSpread$e({}, _objectSpread$e(_objectSpread$e({}, field), {}, {
1200
1201
  type: type
1201
1202
  })), {}, {
1202
- "data-cy": "".concat(neetoCist.hyphenate(label), "-input-field"),
1203
+ "data-testid": "".concat(neetoCist.hyphenate(label), "-input-field"),
1203
1204
  dateFormat: "MMM D, YYYY",
1204
1205
  disabled: isReadOnly,
1205
1206
  error: meta.touched ? meta.error : "",
@@ -1306,7 +1307,7 @@ var SendCodeButton = function SendCodeButton(_ref) {
1306
1307
  return /*#__PURE__*/jsxRuntime.jsx(CheckCircle, {});
1307
1308
  }
1308
1309
  return /*#__PURE__*/jsxRuntime.jsx(Button, {
1309
- "data-cy": "send-code-button",
1310
+ "data-testid": "send-code-button",
1310
1311
  disabled: isDisabled,
1311
1312
  size: "small",
1312
1313
  style: "secondary",
@@ -1350,7 +1351,7 @@ var ResendVerificationCode = function ResendVerificationCode(_ref) {
1350
1351
  i18nKey: "neetoForm.emailVerification.resendCode",
1351
1352
  components: {
1352
1353
  button: /*#__PURE__*/jsxRuntime.jsx(Button, {
1353
- "data-cy": "otp-resend-button",
1354
+ "data-testid": "otp-resend-button",
1354
1355
  disabled: isResendDisabled,
1355
1356
  size: "small",
1356
1357
  style: "link",
@@ -1430,7 +1431,7 @@ var VerifyCode = function VerifyCode(_ref) {
1430
1431
  }, [code, hasError]);
1431
1432
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1432
1433
  children: [/*#__PURE__*/jsxRuntime.jsx(Input, _objectSpread$c(_objectSpread$c({}, _objectSpread$c({}, field)), {}, {
1433
- "data-cy": "otp-input-field",
1434
+ "data-testid": "otp-input-field",
1434
1435
  disabled: isVerifyingCode,
1435
1436
  error: touched ? error : "",
1436
1437
  loading: isVerifyingCode,
@@ -1746,6 +1747,56 @@ var NameField = function NameField(props) {
1746
1747
  }));
1747
1748
  };
1748
1749
 
1750
+ var ChoiceImage = function ChoiceImage(_ref) {
1751
+ var src = _ref.src,
1752
+ alt = _ref.alt,
1753
+ height = _ref.height,
1754
+ shouldFitImages = _ref.shouldFitImages;
1755
+ var _useState = React.useState(false),
1756
+ _useState2 = _slicedToArray(_useState, 2),
1757
+ hasError = _useState2[0],
1758
+ setHasError = _useState2[1];
1759
+ var _useState3 = React.useState(true),
1760
+ _useState4 = _slicedToArray(_useState3, 2),
1761
+ isLoading = _useState4[0],
1762
+ setIsLoading = _useState4[1];
1763
+ var handleLoad = function handleLoad() {
1764
+ return setIsLoading(false);
1765
+ };
1766
+ var handleError = function handleError() {
1767
+ setHasError(true);
1768
+ setIsLoading(false);
1769
+ };
1770
+ if (hasError || !src) {
1771
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
1772
+ className: "neeto-form-engine-choice__image-placeholder neeto-ui-bg-gray-100",
1773
+ style: {
1774
+ height: height
1775
+ },
1776
+ children: /*#__PURE__*/jsxRuntime.jsx(Image, {
1777
+ size: 32
1778
+ })
1779
+ });
1780
+ }
1781
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
1782
+ style: {
1783
+ height: height
1784
+ },
1785
+ className: classnames("neeto-form-engine-choice__image-wrapper", {
1786
+ "neeto-form-engine-choice__image-wrapper--loading": isLoading
1787
+ }),
1788
+ children: /*#__PURE__*/jsxRuntime.jsx("img", {
1789
+ alt: alt,
1790
+ src: src,
1791
+ className: classnames("neeto-form-engine-choice__image", {
1792
+ "neeto-form-engine-choice__image--fit": shouldFitImages
1793
+ }),
1794
+ onError: handleError,
1795
+ onLoad: handleLoad
1796
+ })
1797
+ });
1798
+ };
1799
+
1749
1800
  var Choices = function Choices(_ref) {
1750
1801
  var label = _ref.label,
1751
1802
  options = _ref.options,
@@ -1754,51 +1805,66 @@ var Choices = function Choices(_ref) {
1754
1805
  value = _ref.value,
1755
1806
  onChange = _ref.onChange,
1756
1807
  error = _ref.error,
1757
- disabled = _ref.isDisabled;
1808
+ disabled = _ref.isDisabled,
1809
+ _ref$isPictureChoice = _ref.isPictureChoice,
1810
+ isPictureChoice = _ref$isPictureChoice === void 0 ? constants.DEFAULT_CHOICE_QUESTION_ATTRIBUTES.isPictureChoice : _ref$isPictureChoice,
1811
+ _ref$imageHeight = _ref.imageHeight,
1812
+ imageHeight = _ref$imageHeight === void 0 ? constants.DEFAULT_CHOICE_QUESTION_ATTRIBUTES.imageHeight : _ref$imageHeight,
1813
+ _ref$shouldFitImages = _ref.shouldFitImages,
1814
+ shouldFitImages = _ref$shouldFitImages === void 0 ? constants.DEFAULT_CHOICE_QUESTION_ATTRIBUTES.shouldFitImages : _ref$shouldFitImages;
1758
1815
  var isCheckBox = type === "checkbox";
1759
1816
  var ChoiceWrapper = isCheckBox ? "div" : Radio;
1760
1817
  var Component = isCheckBox ? Checkbox : Radio.Item;
1761
1818
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
1762
1819
  className: "neeto-form-engine-choices__wrapper",
1763
- "data-cy": "".concat(neetoCist.hyphenate(label), "-select-container-wrapper"),
1820
+ "data-testid": "".concat(neetoCist.hyphenate(label), "-select-container-wrapper"),
1764
1821
  children: [/*#__PURE__*/jsxRuntime.jsx("label", {
1765
1822
  className: "neeto-form-engine-label",
1766
- "data-cy": "".concat(neetoCist.hyphenate(label), "-input-label"),
1823
+ "data-testid": "".concat(neetoCist.hyphenate(label), "-input-label"),
1767
1824
  children: label
1768
1825
  }), /*#__PURE__*/jsxRuntime.jsx(ChoiceWrapper, {
1769
- className: "neeto-form-engine-choices",
1770
1826
  stacked: !isCheckBox,
1827
+ className: classnames("neeto-form-engine-choices", {
1828
+ "neeto-form-engine-choices--picture": isPictureChoice
1829
+ }),
1771
1830
  children: options.map(function (option, index) {
1772
- var _value$index;
1773
- return /*#__PURE__*/jsxRuntime.jsx("label", {
1831
+ var _value$index, _option$image;
1832
+ var isChecked = isCheckBox ? (_value$index = value === null || value === void 0 ? void 0 : value[index]) !== null && _value$index !== void 0 ? _value$index : false : value === option.id;
1833
+ return /*#__PURE__*/jsxRuntime.jsxs("label", {
1774
1834
  htmlFor: option.id,
1775
1835
  className: classnames("neeto-form-engine-choice", {
1776
- active: false,
1836
+ "neeto-form-engine-choice--picture": isPictureChoice,
1837
+ "neeto-form-engine-choice--selected": isChecked,
1777
1838
  "cursor-not-allowed": disabled
1778
1839
  }),
1779
- children: /*#__PURE__*/jsxRuntime.jsx(Component, {
1840
+ children: [isPictureChoice && /*#__PURE__*/jsxRuntime.jsx(ChoiceImage, {
1841
+ shouldFitImages: shouldFitImages,
1842
+ alt: option.label,
1843
+ height: imageHeight,
1844
+ src: (_option$image = option.image) === null || _option$image === void 0 ? void 0 : _option$image.url
1845
+ }), /*#__PURE__*/jsxRuntime.jsx(Component, {
1780
1846
  disabled: disabled,
1781
1847
  onChange: onChange,
1782
1848
  type: type,
1849
+ checked: isChecked,
1783
1850
  className: classnames({
1784
1851
  "cursor-not-allowed": disabled
1785
1852
  }),
1786
1853
  id: option.id,
1854
+ label: option.label,
1855
+ name: isCheckBox ? "".concat(name, ".").concat(index) : name,
1856
+ value: option.id,
1787
1857
  labelProps: {
1788
1858
  className: classnames({
1789
1859
  "cursor-not-allowed": disabled
1790
1860
  })
1791
- },
1792
- label: option.label,
1793
- name: isCheckBox ? "".concat(name, ".").concat(index) : name,
1794
- value: option.id,
1795
- checked: isCheckBox ? (_value$index = value === null || value === void 0 ? void 0 : value[index]) !== null && _value$index !== void 0 ? _value$index : false : value === option.id
1796
- })
1861
+ }
1862
+ })]
1797
1863
  }, option.id);
1798
1864
  })
1799
1865
  }), !!error && typeof error === "string" && /*#__PURE__*/jsxRuntime.jsx("p", {
1800
1866
  className: "neeto-form-engine-input__error",
1801
- "data-cy": "neeto-form-engine-".concat(type, "-error"),
1867
+ "data-testid": "neeto-form-engine-".concat(type, "-error"),
1802
1868
  children: error
1803
1869
  })]
1804
1870
  });
@@ -1819,8 +1885,12 @@ var OptionsField = function OptionsField(_ref) {
1819
1885
  kind = question.kind,
1820
1886
  isRequired = question.isRequired,
1821
1887
  isReadOnly = question.isReadOnly,
1888
+ isPictureChoiceFromQuestion = question.isPictureChoice,
1889
+ imageHeight = question.imageHeight,
1890
+ shouldFitImages = question.shouldFitImages,
1822
1891
  _question$optionsAttr = question.optionsAttributes,
1823
1892
  options = _question$optionsAttr === void 0 ? [] : _question$optionsAttr;
1893
+ var isPictureChoice = isPictureChoiceFromQuestion;
1824
1894
  var isDropdown = kind === constants.QUESTION_KIND.DROPDOWN.value;
1825
1895
  var label = index.fieldWithFallback(question, "label");
1826
1896
  var Component = isDropdown ? Select : Choices$1;
@@ -1860,17 +1930,22 @@ var OptionsField = function OptionsField(_ref) {
1860
1930
  var onChange = field.onChange,
1861
1931
  value = field.value;
1862
1932
  return /*#__PURE__*/jsxRuntime.jsx(Component, _objectSpread$8(_objectSpread$8({
1863
- isRequired: isRequired,
1864
- name: name,
1865
1933
  error: getError(meta),
1866
1934
  isDisabled: isReadOnly,
1867
1935
  label: getLabel(label, isRequired),
1868
1936
  options: transformedOptions,
1869
1937
  strategy: "fixed",
1870
1938
  type: kind
1939
+ }, _objectSpread$8(_objectSpread$8({
1940
+ isRequired: isRequired,
1941
+ name: name
1871
1942
  }, isDropdown && {
1872
1943
  filterOption: customFilter
1873
- }), {}, {
1944
+ }), !isDropdown && {
1945
+ imageHeight: imageHeight,
1946
+ isPictureChoice: isPictureChoice,
1947
+ shouldFitImages: shouldFitImages
1948
+ })), {}, {
1874
1949
  value: isDropdown ? neetoCist.findBy({
1875
1950
  value: value
1876
1951
  }, transformedOptions) || null : value,
@@ -1983,15 +2058,15 @@ var Rating = function Rating(_ref) {
1983
2058
  className: "neeto-form-engine-rating",
1984
2059
  children: [/*#__PURE__*/jsxRuntime.jsx("label", {
1985
2060
  className: "neeto-form-engine-label",
1986
- "data-cy": "rating-input-label",
2061
+ "data-testid": "rating-input-label",
1987
2062
  children: label
1988
2063
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
1989
2064
  className: "neeto-form-engine-rating__row",
1990
- "data-cy": "rating-input-field",
2065
+ "data-testid": "rating-input-field",
1991
2066
  children: render()
1992
2067
  }), !!error && typeof error === "string" && /*#__PURE__*/jsxRuntime.jsx("p", {
1993
2068
  className: "neeto-form-engine-input__error",
1994
- "data-cy": "neeto-form-engine-rating-error",
2069
+ "data-testid": "neeto-form-engine-rating-error",
1995
2070
  children: error
1996
2071
  })]
1997
2072
  });
@@ -2059,7 +2134,7 @@ var RichTextEditor = function RichTextEditor(_ref) {
2059
2134
  className: "neeto-form-engine-input__label-wrapper",
2060
2135
  children: label && /*#__PURE__*/jsxRuntime.jsx("label", {
2061
2136
  className: "neeto-form-engine-label",
2062
- "data-cy": "".concat(neetoCist.hyphenate(label), "-input-label"),
2137
+ "data-testid": "".concat(neetoCist.hyphenate(label), "-input-label"),
2063
2138
  children: getLabel(label, isRequired)
2064
2139
  })
2065
2140
  }), /*#__PURE__*/jsxRuntime.jsx(formik.FastField, {
@@ -2158,12 +2233,12 @@ var StarRating = function StarRating(_ref) {
2158
2233
  className: "neeto-form-engine-input__label-wrapper",
2159
2234
  children: /*#__PURE__*/jsxRuntime.jsx("label", {
2160
2235
  className: "neeto-form-engine-label",
2161
- "data-cy": "star-rating-input-label",
2236
+ "data-testid": "star-rating-input-label",
2162
2237
  children: label
2163
2238
  })
2164
2239
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
2165
2240
  className: "neeto-form-engine-star-rating__row",
2166
- "data-cy": "star-rating-input-field",
2241
+ "data-testid": "star-rating-input-field",
2167
2242
  children: constants.generateArray(minValue, maxValue).map(function (index) {
2168
2243
  return /*#__PURE__*/jsxRuntime.jsx(RatingButton$1, _objectSpread$3({
2169
2244
  label: index,
@@ -2172,7 +2247,7 @@ var StarRating = function StarRating(_ref) {
2172
2247
  })
2173
2248
  }), !!error && typeof error === "string" && /*#__PURE__*/jsxRuntime.jsx("p", {
2174
2249
  className: "neeto-form-engine-input__error",
2175
- "data-cy": "neeto-form-engine-star-rating-error",
2250
+ "data-testid": "neeto-form-engine-star-rating-error",
2176
2251
  children: error
2177
2252
  })]
2178
2253
  });
@@ -2356,4 +2431,4 @@ exports.getFieldComponent = getFieldComponent;
2356
2431
  exports.getWithExpiry = getWithExpiry;
2357
2432
  exports.mergeRefs = mergeRefs;
2358
2433
  exports.renderButtonsInOrder = renderButtonsInOrder;
2359
- //# sourceMappingURL=utils-C-ermU02.js.map
2434
+ //# sourceMappingURL=utils-BwFLBXs2.js.map