@bigbinary/neeto-molecules 1.0.77 → 1.0.78

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.
@@ -51,20 +51,20 @@ var INITIAL_FORM_VALUES = {
51
51
  subject: "",
52
52
  message: ""
53
53
  };
54
- var EMAIL_FORM_VALIDATION_SCHEMA = yup__namespace.object().shape({
54
+ var EMAIL_FORM_VALIDATION_SCHEMA = yup__namespace.object({
55
55
  subject: yup__namespace.string().required(i18next.t("neetoMolecules.emailForm.errors.subjectRequired")),
56
56
  message: yup__namespace.string().test("message", i18next.t("neetoMolecules.emailForm.errors.messageRequired"), function (value) {
57
57
  return !neetoEditor.isEditorEmpty(value);
58
58
  })
59
59
  });
60
- var SEND_TO_FIELD_VALIDATION = yup__namespace.object().shape({
60
+ var SEND_TO_FIELD_VALIDATION = yup__namespace.object({
61
61
  sendTo: yup__namespace.array().min(1, i18next.t("neetoMolecules.emailForm.errors.required", {
62
62
  entity: i18next.t("neetoMolecules.emailForm.fields.sendToEmailAddress")
63
63
  })).test("all-emails-valid", i18next.t("neetoMolecules.emailForm.errors.invalidEmailAddress"), function (emails) {
64
64
  return emails === null || emails === void 0 ? void 0 : emails.every(ramda.prop("valid"));
65
65
  }).nullable()
66
66
  });
67
- var REPLY_TO_FIELD_VALIDATION = yup__namespace.object().shape({
67
+ var REPLY_TO_FIELD_VALIDATION = yup__namespace.object({
68
68
  replyTo: yup__namespace.string().nullable().email(i18next.t("neetoMolecules.emailForm.errors.invalidEmailAddress")).required(i18next.t("neetoMolecules.emailForm.errors.required", {
69
69
  entity: i18next.t("neetoMolecules.emailForm.fields.replyToEmailAddress")
70
70
  }))
@@ -2508,7 +2508,7 @@ var getValidationSchema = function getValidationSchema(_ref2) {
2508
2508
  var schema = EMAIL_FORM_VALIDATION_SCHEMA.clone();
2509
2509
  if (showSendToField) schema = schema.concat(SEND_TO_FIELD_VALIDATION);
2510
2510
  if (showReplyToField) schema = schema.concat(REPLY_TO_FIELD_VALIDATION);
2511
- return schema.concat(customValidations);
2511
+ return schema.shape(customValidations);
2512
2512
  };
2513
2513
 
2514
2514
  var SendToField = function SendToField() {
@@ -2517,11 +2517,12 @@ var SendToField = function SendToField() {
2517
2517
  var _useFormikContext = formik.useFormikContext(),
2518
2518
  setFieldValue = _useFormikContext.setFieldValue,
2519
2519
  values = _useFormikContext.values;
2520
+ var sendToFieldRef = React.useRef();
2520
2521
  var showCopyEmailFieldValue = values.showCopyEmails,
2521
2522
  existingSendToEmails = values.sendTo;
2522
2523
  var handleCSVFile = /*#__PURE__*/function () {
2523
2524
  var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(files) {
2524
- var setNotifyEmails;
2525
+ var _sendToFieldRef$curre, setNotifyEmails;
2525
2526
  return regenerator.wrap(function _callee$(_context) {
2526
2527
  while (1) switch (_context.prev = _context.next) {
2527
2528
  case 0:
@@ -2532,17 +2533,18 @@ var SendToField = function SendToField() {
2532
2533
  _context.next = 4;
2533
2534
  return parseCsvEmails(files[0], setNotifyEmails);
2534
2535
  case 4:
2535
- _context.next = 9;
2536
+ (_sendToFieldRef$curre = sendToFieldRef.current) === null || _sendToFieldRef$curre === void 0 ? void 0 : _sendToFieldRef$curre.focus();
2537
+ _context.next = 10;
2536
2538
  break;
2537
- case 6:
2538
- _context.prev = 6;
2539
+ case 7:
2540
+ _context.prev = 7;
2539
2541
  _context.t0 = _context["catch"](0);
2540
2542
  neetoui.Toastr.error(_context.t0);
2541
- case 9:
2543
+ case 10:
2542
2544
  case "end":
2543
2545
  return _context.stop();
2544
2546
  }
2545
- }, _callee, null, [[0, 6]]);
2547
+ }, _callee, null, [[0, 7]]);
2546
2548
  }));
2547
2549
  return function handleCSVFile(_x) {
2548
2550
  return _ref.apply(this, arguments);
@@ -2565,6 +2567,7 @@ var SendToField = function SendToField() {
2565
2567
  id: "sendTo",
2566
2568
  label: "",
2567
2569
  name: "sendTo",
2570
+ ref: sendToFieldRef,
2568
2571
  placeholder: t("neetoMolecules.emailForm.placeholders.commaSeparatedEmails"),
2569
2572
  suffix: /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
2570
2573
  "data-cy": "cc-bcc-button",
@@ -2696,7 +2699,9 @@ var EmailForm = function EmailForm(_ref) {
2696
2699
  _ref$replyToOptions = _ref.replyToOptions,
2697
2700
  replyToOptions = _ref$replyToOptions === void 0 ? [] : _ref$replyToOptions,
2698
2701
  _ref$isUpdating = _ref.isUpdating,
2699
- isUpdating = _ref$isUpdating === void 0 ? false : _ref$isUpdating;
2702
+ isUpdating = _ref$isUpdating === void 0 ? false : _ref$isUpdating,
2703
+ _ref$showFields = _ref.showFields,
2704
+ showFields = _ref$showFields === void 0 ? true : _ref$showFields;
2700
2705
  var _useTranslation = reactI18next.useTranslation(),
2701
2706
  t = _useTranslation.t;
2702
2707
  var _useContext = React.useContext(EmailFormContext),
@@ -2708,7 +2713,7 @@ var EmailForm = function EmailForm(_ref) {
2708
2713
  return /*#__PURE__*/React__default["default"].createElement("div", {
2709
2714
  className: "flex flex-1 flex-col items-start gap-2",
2710
2715
  "data-testid": "email-form"
2711
- }, /*#__PURE__*/React__default["default"].createElement("div", {
2716
+ }, showFields && /*#__PURE__*/React__default["default"].createElement("div", {
2712
2717
  className: "flex items-stretch gap-8"
2713
2718
  }, /*#__PURE__*/React__default["default"].createElement("div", {
2714
2719
  className: "flex flex-col items-start justify-start gap-6"
@@ -2819,7 +2824,7 @@ var EmailFormProvider = function EmailFormProvider(_ref) {
2819
2824
  children = _ref.children,
2820
2825
  formikProps = _ref.formikProps,
2821
2826
  _ref$validationSchema = _ref.validationSchema,
2822
- customValidations = _ref$validationSchema === void 0 ? yup__namespace.object({}) : _ref$validationSchema,
2827
+ customValidations = _ref$validationSchema === void 0 ? {} : _ref$validationSchema,
2823
2828
  _ref$showSendToField = _ref.showSendToField,
2824
2829
  showSendToField = _ref$showSendToField === void 0 ? false : _ref$showSendToField,
2825
2830
  _ref$showReplyToField = _ref.showReplyToField,