@bigbinary/neeto-molecules 1.1.13 → 1.1.14

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.
@@ -1,7 +1,8 @@
1
- import React from "react";
1
+ import React, { useRef } from "react";
2
2
  import { Modal, Typography } from "@bigbinary/neetoui";
3
- import { Button, Form, Input } from "@bigbinary/neetoui/formik";
3
+ import { ActionBlock, Form, Input } from "@bigbinary/neetoui/formik";
4
4
  import { type } from "ramda";
5
+ import { useTranslation } from "react-i18next";
5
6
  import { INITIAL_VALUES } from "./constants";
6
7
  import { deletionValidationSchema } from "./utils";
7
8
  var ConfirmationModal = function ConfirmationModal(_ref) {
@@ -16,31 +17,61 @@ var ConfirmationModal = function ConfirmationModal(_ref) {
16
17
  _ref$title = _ref.title,
17
18
  title = _ref$title === void 0 ? "" : _ref$title,
18
19
  onClose = _ref.onClose,
19
- onSubmit = _ref.onSubmit;
20
+ onSubmit = _ref.onSubmit,
21
+ deleteConfirmationMessage = _ref.deleteConfirmationMessage;
22
+ var _useTranslation = useTranslation(),
23
+ t = _useTranslation.t;
20
24
  var formikProps = {
21
25
  initialValues: INITIAL_VALUES,
22
26
  validationSchema: deletionValidationSchema(confirmationText),
23
27
  onSubmit: onSubmit
24
28
  };
29
+ var deleteInputLabel = deleteConfirmationMessage || t("neetoMolecules.confirmationModal.deleteConfirmationMessage", {
30
+ value: confirmationText
31
+ });
32
+ var initialFocusRef = useRef(null);
25
33
  return /*#__PURE__*/React.createElement(Modal, {
34
+ initialFocusRef: initialFocusRef,
26
35
  isOpen: isOpen,
27
36
  onClose: onClose,
28
37
  "data-testid": "confirmation-modal"
29
38
  }, /*#__PURE__*/React.createElement(Modal.Header, null, /*#__PURE__*/React.createElement(Typography, {
39
+ "data-cy": "confirmation-modal",
30
40
  style: "h2"
31
- }, title)), /*#__PURE__*/React.createElement(Modal.Body, {
32
- className: "space-y-4"
33
- }, type(description) === "String" ? /*#__PURE__*/React.createElement(Typography, null, description) : description, /*#__PURE__*/React.createElement(Form, {
34
- className: "flex items-start space-x-1",
41
+ }, title)), /*#__PURE__*/React.createElement(Form, {
35
42
  formikProps: formikProps
36
- }, /*#__PURE__*/React.createElement(Input, {
37
- className: "flex-auto",
38
- "data-testid": "confirmation-modal-input",
39
- name: "confirmationText"
40
- }), /*#__PURE__*/React.createElement(Button, {
41
- label: buttonLabel,
42
- loading: isSubmitting,
43
- style: "danger"
44
- }))));
43
+ }, function (_ref2) {
44
+ var values = _ref2.values;
45
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Modal.Body, {
46
+ className: "space-y-4"
47
+ }, type(description) === "String" ? /*#__PURE__*/React.createElement(Typography, {
48
+ style: "body2"
49
+ }, description) : description, /*#__PURE__*/React.createElement(Input, {
50
+ "data-testid": "confirmation-modal-input",
51
+ label: deleteInputLabel,
52
+ labelProps: {
53
+ className: "block"
54
+ },
55
+ name: "confirmationText",
56
+ ref: initialFocusRef,
57
+ type: "text"
58
+ })), /*#__PURE__*/React.createElement(Modal.Footer, null, /*#__PURE__*/React.createElement(ActionBlock, {
59
+ className: "space-x-2",
60
+ cancelButtonProps: {
61
+ label: t("neetoMolecules.common.actions.cancel"),
62
+ style: "text",
63
+ onClick: onClose,
64
+ disabled: false,
65
+ type: "button"
66
+ },
67
+ submitButtonProps: {
68
+ "data-cy": "delete-continue-button",
69
+ label: buttonLabel,
70
+ loading: isSubmitting,
71
+ style: "danger",
72
+ disabled: isSubmitting || confirmationText !== values.confirmationText
73
+ }
74
+ })));
75
+ }));
45
76
  };
46
77
  export default ConfirmationModal;
@@ -1,10 +1,6 @@
1
- import { t } from "i18next";
2
1
  import * as yup from "yup";
3
2
  export var deletionValidationSchema = function deletionValidationSchema(confirmationText) {
4
- var errorMessage = t("neetoMolecules.confirmationModal.required", {
5
- confirmationText: confirmationText
6
- });
7
3
  return yup.object({
8
- confirmationText: yup.string().required(errorMessage).oneOf([confirmationText], errorMessage)
4
+ confirmationText: yup.string().required("").oneOf([confirmationText], "")
9
5
  });
10
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-molecules",
3
- "version": "1.1.13",
3
+ "version": "1.1.14",
4
4
  "description": "A package of reusable molecular components for neeto products.",
5
5
  "repository": "git@github.com:bigbinary/neeto-molecules.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",
@@ -558,7 +558,7 @@
558
558
  }
559
559
  },
560
560
  "confirmationModal": {
561
- "required": "Enter \"{{confirmationText}}\" to confirm"
561
+ "deleteConfirmationMessage": "Please type <strong>{{value}}</strong> to confirm."
562
562
  },
563
563
  "metadata": {
564
564
  "detailsTitle": "Details",
@@ -59,5 +59,6 @@ const ConfirmationModal: React.FC<{
59
59
  title?: string;
60
60
  onClose: Function;
61
61
  onSubmit: Function;
62
+ deleteConfirmationMessage?: string;
62
63
  }>;
63
64
  export default ConfirmationModal;