@bigbinary/neeto-form-frontend 4.4.71 → 4.5.0-beta1

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 (62) hide show
  1. package/app/javascript/src/translations/en.json +4 -1
  2. package/dist/.ready +1 -1
  3. package/dist/BuildForm.js +28 -4
  4. package/dist/BuildForm.js.map +1 -1
  5. package/dist/ExternalForm.js +22 -17
  6. package/dist/ExternalForm.js.map +1 -1
  7. package/dist/Submission.js +30 -10
  8. package/dist/Submission.js.map +1 -1
  9. package/dist/UrlBuilder.js +2 -2
  10. package/dist/cjs/BuildForm.js +27 -3
  11. package/dist/cjs/BuildForm.js.map +1 -1
  12. package/dist/cjs/ExternalForm.js +21 -16
  13. package/dist/cjs/ExternalForm.js.map +1 -1
  14. package/dist/cjs/Submission.js +29 -9
  15. package/dist/cjs/Submission.js.map +1 -1
  16. package/dist/cjs/UrlBuilder.js +2 -2
  17. package/dist/cjs/index.js +4 -4
  18. package/dist/cjs/{utils-BHn1TXSC.js → utils-CMHI5Y0n.js} +56 -26
  19. package/dist/cjs/utils-CMHI5Y0n.js.map +1 -0
  20. package/dist/cjs/v2/BuildForm.js +27 -3
  21. package/dist/cjs/v2/BuildForm.js.map +1 -1
  22. package/dist/cjs/v2/ExternalForm.js +19 -13
  23. package/dist/cjs/v2/ExternalForm.js.map +1 -1
  24. package/dist/cjs/v2/Submission.js +30 -10
  25. package/dist/cjs/v2/Submission.js.map +1 -1
  26. package/dist/cjs/v2/UrlBuilder.js +3 -2
  27. package/dist/cjs/v2/UrlBuilder.js.map +1 -1
  28. package/dist/cjs/v2/index.js +2 -2
  29. package/dist/cjs/v2/{utils-7ObrGr4O.js → utils-EWbfo6xy.js} +29 -5
  30. package/dist/cjs/v2/utils-EWbfo6xy.js.map +1 -0
  31. package/dist/cjs/v2/{yup-D2FUYjqU.js → yup-IIVrobcB.js} +8 -2
  32. package/dist/cjs/v2/yup-IIVrobcB.js.map +1 -0
  33. package/dist/cjs/{yup-DD46Fc7X.js → yup--rmEVYDi.js} +8 -2
  34. package/dist/cjs/yup--rmEVYDi.js.map +1 -0
  35. package/dist/index.js +4 -4
  36. package/dist/{utils-DQC5qi6q.js → utils-BQ-x2S1l.js} +56 -26
  37. package/dist/utils-BQ-x2S1l.js.map +1 -0
  38. package/dist/v2/BuildForm.js +29 -5
  39. package/dist/v2/BuildForm.js.map +1 -1
  40. package/dist/v2/ExternalForm.js +20 -14
  41. package/dist/v2/ExternalForm.js.map +1 -1
  42. package/dist/v2/Submission.js +31 -11
  43. package/dist/v2/Submission.js.map +1 -1
  44. package/dist/v2/UrlBuilder.js +3 -2
  45. package/dist/v2/UrlBuilder.js.map +1 -1
  46. package/dist/v2/index.js +2 -2
  47. package/dist/v2/{utils-Do7H0nQ3.js → utils-BgLYgJEU.js} +29 -5
  48. package/dist/v2/utils-BgLYgJEU.js.map +1 -0
  49. package/dist/v2/{yup-BRPSFuNj.js → yup-CnlHwBP1.js} +8 -3
  50. package/dist/v2/yup-CnlHwBP1.js.map +1 -0
  51. package/dist/{yup-Ccwwlg6e.js → yup-BWdsrAJJ.js} +8 -3
  52. package/dist/yup-BWdsrAJJ.js.map +1 -0
  53. package/package.json +9 -9
  54. package/types.d.ts +5 -0
  55. package/dist/cjs/utils-BHn1TXSC.js.map +0 -1
  56. package/dist/cjs/v2/utils-7ObrGr4O.js.map +0 -1
  57. package/dist/cjs/v2/yup-D2FUYjqU.js.map +0 -1
  58. package/dist/cjs/yup-DD46Fc7X.js.map +0 -1
  59. package/dist/utils-DQC5qi6q.js.map +0 -1
  60. package/dist/v2/utils-Do7H0nQ3.js.map +0 -1
  61. package/dist/v2/yup-BRPSFuNj.js.map +0 -1
  62. package/dist/yup-Ccwwlg6e.js.map +0 -1
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import 'classnames';
11
11
  import '@bigbinary/neeto-cist';
12
12
  import '@bigbinary/neetoui/Spinner';
13
13
  import 'ramda';
14
- import './yup-Ccwwlg6e.js';
14
+ import './yup-BWdsrAJJ.js';
15
15
  import 'i18next';
16
16
  import '@babel/runtime/helpers/defineProperty';
17
17
  import '@babel/runtime/helpers/objectWithoutProperties';
@@ -69,7 +69,9 @@ import '@bigbinary/neetoui/Pane';
69
69
  import '@bigbinary/neetoui/formik/ActionBlock';
70
70
  import '@bigbinary/neetoui/formik/Form';
71
71
  import 'formik';
72
+ import '@bigbinary/neeto-icons/Info';
72
73
  import '@bigbinary/neetoui/Accordion';
74
+ import '@bigbinary/neetoui/Callout';
73
75
  import '@bigbinary/neetoui/formik/Select';
74
76
  import '@bigbinary/neetoui/formik/Switch';
75
77
  import '@bigbinary/neetoui/formik/Textarea';
@@ -95,9 +97,8 @@ import '@bigbinary/neeto-molecules/HelpPopover';
95
97
  import '@bigbinary/neeto-hotkeys';
96
98
  import '@bigbinary/neeto-icons/Warning';
97
99
  import '@bigbinary/neeto-molecules/PageLoader';
98
- import '@bigbinary/neetoui/Callout';
99
100
  import '@bigbinary/neeto-icons/Check';
100
- import './utils-DQC5qi6q.js';
101
+ import './utils-BQ-x2S1l.js';
101
102
  import 'libphonenumber-js';
102
103
  import '@bigbinary/neeto-editor-frontend/EditorContent';
103
104
  import '@bigbinary/neetoui/MultiEmailInput';
@@ -116,7 +117,6 @@ import '@bigbinary/neeto-icons/CheckCircle';
116
117
  import '@bigbinary/neeto-molecules/FileUpload';
117
118
  import '@bigbinary/neetoui/Radio';
118
119
  import '@bigbinary/neeto-icons/Image';
119
- import '@bigbinary/neeto-icons/Info';
120
120
  import '@bigbinary/neetoui/Textarea';
121
121
  import '@honeybadger-io/js';
122
122
  import '@bigbinary/neeto-molecules/CopyToClipboardButton';
@@ -20,7 +20,7 @@ import { isEditorEmpty } from '@bigbinary/neeto-editor-frontend/utils';
20
20
  import { validation, PhoneNumberInput } from '@bigbinary/neeto-molecules/PhoneNumber';
21
21
  import { p as parseTime } from './date-D1QLSrIi.js';
22
22
  import i18next from 'i18next';
23
- import { Q as QUESTION_KIND, S as SCHEMA_LESS_QUESTION_KINDS, A as ADDRESS_FIELD_TYPES, c as SPOT_QUESTION_DEFAULT_VALUE, Y as YES_NO_VALUES, P as PARENTHESES_REGEX, R as RATING_VALUES, E as EMAIL_REGEX, I as INTEGER_REGEX, D as DECIMAL_REGEX, d as SIX_DIGIT_NUMBER_REGEX, e as ADDRESS_FIELD_WIDTHS, f as LABEL_FIELDS, g as generateArray, h as DEFAULT_CHOICE_QUESTION_ATTRIBUTES, i as RADIO_DESELECT_KEYS, j as RATING_OPTIONS, k as ICONS_MAP, l as YES_NO_DISPLAY_ICONS_MAP } from './yup-Ccwwlg6e.js';
23
+ import { Q as QUESTION_KIND, S as SCHEMA_LESS_QUESTION_KINDS, A as ADDRESS_FIELD_TYPES, c as SPOT_QUESTION_DEFAULT_VALUE, Y as YES_NO_VALUES, P as PARENTHESES_REGEX, R as RATING_VALUES, E as EMAIL_REGEX, I as INTEGER_REGEX, D as DECIMAL_REGEX, d as SIX_DIGIT_NUMBER_REGEX, e as ADDRESS_FIELD_WIDTHS, f as LABEL_FIELDS, g as generateArray, h as DEFAULT_CHOICE_QUESTION_ATTRIBUTES, i as RADIO_DESELECT_KEYS, W as WHATSAPP_CONSENT_FIELD, j as RATING_OPTIONS, k as ICONS_MAP, l as YES_NO_DISPLAY_ICONS_MAP } from './yup-BWdsrAJJ.js';
24
24
  import _toArray from '@babel/runtime/helpers/toArray';
25
25
  import * as yup from 'yup';
26
26
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -39,7 +39,7 @@ import { useMutation } from '@tanstack/react-query';
39
39
  import axios from 'axios';
40
40
  import CheckCircle from '@bigbinary/neeto-icons/CheckCircle';
41
41
  import Spinner from '@bigbinary/neetoui/Spinner';
42
- import NeetoUICallout from '@bigbinary/neetoui/Callout';
42
+ import Callout from '@bigbinary/neetoui/Callout';
43
43
  import { FileUpload } from '@bigbinary/neeto-molecules/FileUpload';
44
44
  import Label from '@bigbinary/neetoui/Label';
45
45
  import Checkbox from '@bigbinary/neetoui/Checkbox';
@@ -1658,7 +1658,7 @@ var VerifyCode = function VerifyCode(_ref) {
1658
1658
  questionId: questionId,
1659
1659
  isResendDisabled: calloutDetails.style === CALLOUT_STYLES.ERROR,
1660
1660
  sendVerificationCode: handleSendVerificationCode
1661
- }), calloutDetails.message && /*#__PURE__*/jsx(NeetoUICallout, {
1661
+ }), calloutDetails.message && /*#__PURE__*/jsx(Callout, {
1662
1662
  style: calloutDetails.style,
1663
1663
  children: calloutDetails.message
1664
1664
  })]
@@ -2347,11 +2347,35 @@ var OptionsField = function OptionsField(_ref) {
2347
2347
  });
2348
2348
  };
2349
2349
 
2350
+ var WhatsappConsentField = function WhatsappConsentField(_ref) {
2351
+ var label = _ref.label,
2352
+ hasPhoneNumber = _ref.hasPhoneNumber;
2353
+ var _useField = useField(WHATSAPP_CONSENT_FIELD),
2354
+ _useField2 = _slicedToArray(_useField, 3),
2355
+ _useField2$0$value = _useField2[0].value,
2356
+ value = _useField2$0$value === void 0 ? false : _useField2$0$value,
2357
+ setValue = _useField2[2].setValue;
2358
+ useEffect(function () {
2359
+ if (!hasPhoneNumber && value) setValue(false);
2360
+ }, [hasPhoneNumber, value, setValue]);
2361
+ if (!hasPhoneNumber) return null;
2362
+ return /*#__PURE__*/jsx(Checkbox, {
2363
+ label: label,
2364
+ checked: value,
2365
+ "data-testid": "whatsapp-consent-checkbox",
2366
+ name: WHATSAPP_CONSENT_FIELD,
2367
+ onChange: function onChange(event) {
2368
+ return setValue(event.target.checked);
2369
+ }
2370
+ });
2371
+ };
2372
+
2350
2373
  var PhoneNumberField = function PhoneNumberField(_ref) {
2351
- var _getPhoneData;
2352
2374
  var question = _ref.question,
2353
2375
  autoComplete = _ref.autoComplete,
2354
- isLastFewElements = _ref.isLastFewElements;
2376
+ isLastFewElements = _ref.isLastFewElements,
2377
+ _ref$whatsappConsent = _ref.whatsappConsent,
2378
+ whatsappConsent = _ref$whatsappConsent === void 0 ? null : _ref$whatsappConsent;
2355
2379
  var name = question.id,
2356
2380
  kind = question.kind,
2357
2381
  isRequired = question.isRequired,
@@ -2374,26 +2398,32 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
2374
2398
  _useField2$2 = _useField2[2],
2375
2399
  setValue = _useField2$2.setValue,
2376
2400
  setTouched = _useField2$2.setTouched;
2377
- return /*#__PURE__*/jsx(PhoneNumberInput, {
2378
- autoComplete: autoComplete,
2379
- label: label,
2380
- value: value,
2381
- className: "neeto-form-engine-input__wrapper items-stretch",
2382
- disabled: isReadOnly,
2383
- error: touched ? error : "",
2384
- initialCountryCode: (_getPhoneData = getPhoneData(value)) === null || _getPhoneData === void 0 ? void 0 : _getPhoneData.country,
2385
- placeholder: fieldWithFallback(question, "placeholder"),
2386
- required: isRequired,
2387
- selectProps: {
2388
- isDisabled: isReadOnly,
2389
- menuPlacement: isLastFewElements ? "top" : "auto",
2390
- menuPortalTarget: document.body,
2391
- menuPosition: "fixed"
2392
- },
2393
- onBlur: function onBlur() {
2394
- return setTouched(true);
2395
- },
2396
- onChange: setValue
2401
+ var phoneData = getPhoneData(value);
2402
+ return /*#__PURE__*/jsxs(Fragment, {
2403
+ children: [/*#__PURE__*/jsx(PhoneNumberInput, {
2404
+ autoComplete: autoComplete,
2405
+ label: label,
2406
+ value: value,
2407
+ className: "neeto-form-engine-input__wrapper items-stretch",
2408
+ disabled: isReadOnly,
2409
+ error: touched ? error : "",
2410
+ initialCountryCode: phoneData === null || phoneData === void 0 ? void 0 : phoneData.country,
2411
+ placeholder: fieldWithFallback(question, "placeholder"),
2412
+ required: isRequired,
2413
+ selectProps: {
2414
+ isDisabled: isReadOnly,
2415
+ menuPlacement: isLastFewElements ? "top" : "auto",
2416
+ menuPortalTarget: document.body,
2417
+ menuPosition: "fixed"
2418
+ },
2419
+ onBlur: function onBlur() {
2420
+ return setTouched(true);
2421
+ },
2422
+ onChange: setValue
2423
+ }), whatsappConsent && /*#__PURE__*/jsx(WhatsappConsentField, {
2424
+ hasPhoneNumber: Boolean(phoneData === null || phoneData === void 0 ? void 0 : phoneData.number),
2425
+ label: whatsappConsent.label
2426
+ })]
2397
2427
  });
2398
2428
  };
2399
2429
 
@@ -2919,4 +2949,4 @@ var getVisibleOptions = function getVisibleOptions(options) {
2919
2949
  };
2920
2950
 
2921
2951
  export { FormikWrap as F, buildAutoCompleteAttribute as a, buildDateQueryParameters as b, generateInitValues as c, clientI18nInstance as d, getWithExpiry as e, clearEmailVerificationDetails as f, getFieldComponent as g, generateFormResponse as h, clearLocalStorageValues as i, mergeRefs as m, renderButtonsInOrder as r };
2922
- //# sourceMappingURL=utils-DQC5qi6q.js.map
2952
+ //# sourceMappingURL=utils-BQ-x2S1l.js.map