@manuscripts/body-editor 2.8.55 → 2.8.56

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.
@@ -61,6 +61,14 @@ const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel, onSav
61
61
  }
62
62
  }, [values]);
63
63
  const [showDeleteDialog, setShowDeleteDialog] = (0, react_1.useState)(false);
64
+ const validateReference = (values) => {
65
+ var _a;
66
+ const errors = {};
67
+ if (!((_a = values.title) === null || _a === void 0 ? void 0 : _a.trim())) {
68
+ errors.title = 'Title is required';
69
+ }
70
+ return errors;
71
+ };
64
72
  if (actionsRef && !actionsRef.current) {
65
73
  actionsRef.current = {
66
74
  reset: () => {
@@ -69,7 +77,7 @@ const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel, onSav
69
77
  },
70
78
  };
71
79
  }
72
- return (react_1.default.createElement(formik_1.Formik, { initialValues: values, onSubmit: onSave, enableReinitialize: true, innerRef: formRef }, (formik) => {
80
+ return (react_1.default.createElement(formik_1.Formik, { initialValues: values, onSubmit: onSave, enableReinitialize: true, innerRef: formRef, validate: validateReference }, (formik) => {
73
81
  return (react_1.default.createElement(ChangeHandlingForm_1.ChangeHandlingForm, { onChange: onChange },
74
82
  react_1.default.createElement(style_guide_1.Dialog, { isOpen: showDeleteDialog, category: style_guide_1.Category.confirmation, header: "Delete Reference", message: "Are you sure you want to delete this reference from the list?", actions: {
75
83
  secondary: {
@@ -93,7 +101,7 @@ const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel, onSav
93
101
  react_1.default.createElement(style_guide_1.Tooltip, { id: "delete-button-tooltip", place: "bottom" }, "Unable to delete because the item is used in the document")),
94
102
  react_1.default.createElement(style_guide_1.ButtonGroup, null,
95
103
  react_1.default.createElement(style_guide_1.SecondaryButton, { onClick: onCancel }, "Cancel"),
96
- react_1.default.createElement(style_guide_1.PrimaryButton, { type: "submit" }, "Save"))),
104
+ react_1.default.createElement(style_guide_1.PrimaryButton, { type: "submit", disabled: !formik.isValid || !formik.dirty }, "Save"))),
97
105
  react_1.default.createElement(styled_components_1.FormFields, { ref: fieldsRef },
98
106
  react_1.default.createElement(styled_components_1.FormField, null,
99
107
  react_1.default.createElement(styled_components_1.LabelContainer, null,
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MATHJAX_VERSION = exports.VERSION = void 0;
4
- exports.VERSION = '2.8.55';
4
+ exports.VERSION = '2.8.56';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -35,6 +35,14 @@ export const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel
35
35
  }
36
36
  }, [values]);
37
37
  const [showDeleteDialog, setShowDeleteDialog] = useState(false);
38
+ const validateReference = (values) => {
39
+ var _a;
40
+ const errors = {};
41
+ if (!((_a = values.title) === null || _a === void 0 ? void 0 : _a.trim())) {
42
+ errors.title = 'Title is required';
43
+ }
44
+ return errors;
45
+ };
38
46
  if (actionsRef && !actionsRef.current) {
39
47
  actionsRef.current = {
40
48
  reset: () => {
@@ -43,7 +51,7 @@ export const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel
43
51
  },
44
52
  };
45
53
  }
46
- return (React.createElement(Formik, { initialValues: values, onSubmit: onSave, enableReinitialize: true, innerRef: formRef }, (formik) => {
54
+ return (React.createElement(Formik, { initialValues: values, onSubmit: onSave, enableReinitialize: true, innerRef: formRef, validate: validateReference }, (formik) => {
47
55
  return (React.createElement(ChangeHandlingForm, { onChange: onChange },
48
56
  React.createElement(Dialog, { isOpen: showDeleteDialog, category: Category.confirmation, header: "Delete Reference", message: "Are you sure you want to delete this reference from the list?", actions: {
49
57
  secondary: {
@@ -67,7 +75,7 @@ export const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel
67
75
  React.createElement(Tooltip, { id: "delete-button-tooltip", place: "bottom" }, "Unable to delete because the item is used in the document")),
68
76
  React.createElement(ButtonGroup, null,
69
77
  React.createElement(SecondaryButton, { onClick: onCancel }, "Cancel"),
70
- React.createElement(PrimaryButton, { type: "submit" }, "Save"))),
78
+ React.createElement(PrimaryButton, { type: "submit", disabled: !formik.isValid || !formik.dirty }, "Save"))),
71
79
  React.createElement(FormFields, { ref: fieldsRef },
72
80
  React.createElement(FormField, null,
73
81
  React.createElement(LabelContainer, null,
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.8.55';
1
+ export const VERSION = '2.8.56';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.8.55";
1
+ export declare const VERSION = "2.8.56";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/body-editor",
3
3
  "description": "Prosemirror components for editing and viewing manuscripts",
4
- "version": "2.8.55",
4
+ "version": "2.8.56",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",