@bigbinary/neeto-molecules 1.0.78-beta → 1.0.79-beta

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/EmailForm.js CHANGED
@@ -23,20 +23,20 @@ var INITIAL_FORM_VALUES = {
23
23
  subject: "",
24
24
  message: ""
25
25
  };
26
- var EMAIL_FORM_VALIDATION_SCHEMA = yup.object().shape({
26
+ var EMAIL_FORM_VALIDATION_SCHEMA = yup.object({
27
27
  subject: yup.string().required(t("neetoMolecules.emailForm.errors.subjectRequired")),
28
28
  message: yup.string().test("message", t("neetoMolecules.emailForm.errors.messageRequired"), function (value) {
29
29
  return !isEditorEmpty(value);
30
30
  })
31
31
  });
32
- var SEND_TO_FIELD_VALIDATION = yup.object().shape({
32
+ var SEND_TO_FIELD_VALIDATION = yup.object({
33
33
  sendTo: yup.array().min(1, t("neetoMolecules.emailForm.errors.required", {
34
34
  entity: t("neetoMolecules.emailForm.fields.sendToEmailAddress")
35
35
  })).test("all-emails-valid", t("neetoMolecules.emailForm.errors.invalidEmailAddress"), function (emails) {
36
36
  return emails === null || emails === void 0 ? void 0 : emails.every(prop("valid"));
37
37
  }).nullable()
38
38
  });
39
- var REPLY_TO_FIELD_VALIDATION = yup.object().shape({
39
+ var REPLY_TO_FIELD_VALIDATION = yup.object({
40
40
  replyTo: yup.string().nullable().email(t("neetoMolecules.emailForm.errors.invalidEmailAddress")).required(t("neetoMolecules.emailForm.errors.required", {
41
41
  entity: t("neetoMolecules.emailForm.fields.replyToEmailAddress")
42
42
  }))
@@ -2480,7 +2480,7 @@ var getValidationSchema = function getValidationSchema(_ref2) {
2480
2480
  var schema = EMAIL_FORM_VALIDATION_SCHEMA.clone();
2481
2481
  if (showSendToField) schema = schema.concat(SEND_TO_FIELD_VALIDATION);
2482
2482
  if (showReplyToField) schema = schema.concat(REPLY_TO_FIELD_VALIDATION);
2483
- return schema.concat(customValidations);
2483
+ return schema.shape(customValidations);
2484
2484
  };
2485
2485
 
2486
2486
  var SendToField = function SendToField() {
@@ -2489,11 +2489,12 @@ var SendToField = function SendToField() {
2489
2489
  var _useFormikContext = useFormikContext(),
2490
2490
  setFieldValue = _useFormikContext.setFieldValue,
2491
2491
  values = _useFormikContext.values;
2492
+ var sendToFieldRef = useRef();
2492
2493
  var showCopyEmailFieldValue = values.showCopyEmails,
2493
2494
  existingSendToEmails = values.sendTo;
2494
2495
  var handleCSVFile = /*#__PURE__*/function () {
2495
2496
  var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(files) {
2496
- var setNotifyEmails;
2497
+ var _sendToFieldRef$curre, setNotifyEmails;
2497
2498
  return regenerator.wrap(function _callee$(_context) {
2498
2499
  while (1) switch (_context.prev = _context.next) {
2499
2500
  case 0:
@@ -2504,17 +2505,18 @@ var SendToField = function SendToField() {
2504
2505
  _context.next = 4;
2505
2506
  return parseCsvEmails(files[0], setNotifyEmails);
2506
2507
  case 4:
2507
- _context.next = 9;
2508
+ (_sendToFieldRef$curre = sendToFieldRef.current) === null || _sendToFieldRef$curre === void 0 ? void 0 : _sendToFieldRef$curre.focus();
2509
+ _context.next = 10;
2508
2510
  break;
2509
- case 6:
2510
- _context.prev = 6;
2511
+ case 7:
2512
+ _context.prev = 7;
2511
2513
  _context.t0 = _context["catch"](0);
2512
2514
  Toastr.error(_context.t0);
2513
- case 9:
2515
+ case 10:
2514
2516
  case "end":
2515
2517
  return _context.stop();
2516
2518
  }
2517
- }, _callee, null, [[0, 6]]);
2519
+ }, _callee, null, [[0, 7]]);
2518
2520
  }));
2519
2521
  return function handleCSVFile(_x) {
2520
2522
  return _ref.apply(this, arguments);
@@ -2537,6 +2539,7 @@ var SendToField = function SendToField() {
2537
2539
  id: "sendTo",
2538
2540
  label: "",
2539
2541
  name: "sendTo",
2542
+ ref: sendToFieldRef,
2540
2543
  placeholder: t("neetoMolecules.emailForm.placeholders.commaSeparatedEmails"),
2541
2544
  suffix: /*#__PURE__*/React.createElement(Button, {
2542
2545
  "data-cy": "cc-bcc-button",
@@ -2668,7 +2671,9 @@ var EmailForm = function EmailForm(_ref) {
2668
2671
  _ref$replyToOptions = _ref.replyToOptions,
2669
2672
  replyToOptions = _ref$replyToOptions === void 0 ? [] : _ref$replyToOptions,
2670
2673
  _ref$isUpdating = _ref.isUpdating,
2671
- isUpdating = _ref$isUpdating === void 0 ? false : _ref$isUpdating;
2674
+ isUpdating = _ref$isUpdating === void 0 ? false : _ref$isUpdating,
2675
+ _ref$showFields = _ref.showFields,
2676
+ showFields = _ref$showFields === void 0 ? true : _ref$showFields;
2672
2677
  var _useTranslation = useTranslation(),
2673
2678
  t = _useTranslation.t;
2674
2679
  var _useContext = useContext(EmailFormContext),
@@ -2680,7 +2685,7 @@ var EmailForm = function EmailForm(_ref) {
2680
2685
  return /*#__PURE__*/React.createElement("div", {
2681
2686
  className: "flex flex-1 flex-col items-start gap-2",
2682
2687
  "data-testid": "email-form"
2683
- }, /*#__PURE__*/React.createElement("div", {
2688
+ }, showFields && /*#__PURE__*/React.createElement("div", {
2684
2689
  className: "flex items-stretch gap-8"
2685
2690
  }, /*#__PURE__*/React.createElement("div", {
2686
2691
  className: "flex flex-col items-start justify-start gap-6"
@@ -2791,7 +2796,7 @@ var EmailFormProvider = function EmailFormProvider(_ref) {
2791
2796
  children = _ref.children,
2792
2797
  formikProps = _ref.formikProps,
2793
2798
  _ref$validationSchema = _ref.validationSchema,
2794
- customValidations = _ref$validationSchema === void 0 ? yup.object({}) : _ref$validationSchema,
2799
+ customValidations = _ref$validationSchema === void 0 ? {} : _ref$validationSchema,
2795
2800
  _ref$showSendToField = _ref.showSendToField,
2796
2801
  showSendToField = _ref$showSendToField === void 0 ? false : _ref$showSendToField,
2797
2802
  _ref$showReplyToField = _ref.showReplyToField,