@synerise/ds-modal 0.17.0 → 0.17.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.17.2](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@0.17.1...@synerise/ds-modal@0.17.2) (2023-08-25)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **modal:** handle footer property with null ([c8f9040](https://github.com/synerise/synerise-design/commit/c8f90400160ee51576fa0e1f1b76653be0ab1ca5))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.17.1](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@0.17.0...@synerise/ds-modal@0.17.1) (2023-08-22)
18
+
19
+ **Note:** Version bump only for package @synerise/ds-modal
20
+
21
+
22
+
23
+
24
+
6
25
  # [0.17.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@0.16.18...@synerise/ds-modal@0.17.0) (2023-08-20)
7
26
 
8
27
 
package/README.md CHANGED
@@ -48,7 +48,7 @@ Some features of the Modal component have been deprecated. Please refer to the [
48
48
  | afterClose | Specify a function that will be called when modal is closed completely. | function | - |
49
49
  | centered | Centered Modal | Boolean | `false` |
50
50
  | width | Width of the modal dialog | string / number | 520 |
51
- | footer | Footer content, set as `footer={null}` when you don't need default buttons | string / ReactNode | OK and Cancel buttons |
51
+ | footer | Footer content, set as `footer={null}` when you don't need default buttons | ReactNode | OK and Cancel buttons |
52
52
  | okText | Text of the OK button | string / ReactNode | `OK` |
53
53
  | okType | Button `type` of the OK button | string | `primary` |
54
54
  | cancelText | Text of the Cancel button | string / ReactNode | `Cancel` |
package/dist/Modal.js CHANGED
@@ -25,8 +25,6 @@ export var buildModalFooter = function buildModalFooter(props) {
25
25
  return /*#__PURE__*/React.createElement(ModalFooter, props);
26
26
  };
27
27
  export var Modal = function Modal(props) {
28
- var _antModalProps$footer;
29
-
30
28
  var texts = props.texts,
31
29
  _props$bodyBackground = props.bodyBackground,
32
30
  bodyBackground = _props$bodyBackground === void 0 ? 'white' : _props$bodyBackground,
@@ -49,7 +47,7 @@ export var Modal = function Modal(props) {
49
47
  width: size && mapSizeToWidth[size],
50
48
  closable: false,
51
49
  title: (title || description || blank) && /*#__PURE__*/React.createElement(ModalTitle, props),
52
- footer: (_antModalProps$footer = antModalProps.footer) != null ? _antModalProps$footer : /*#__PURE__*/React.createElement(ModalFooter, props)
50
+ footer: antModalProps.footer !== null ? antModalProps.footer || /*#__PURE__*/React.createElement(ModalFooter, props) : null
53
51
  }));
54
52
  };
55
53
  Modal.info = AntModal.info;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { default, buildModalFooter } from './Modal';
2
2
  export { ModalTitle } from './Elements/ModalTitle';
3
3
  export { ModalFooter } from './Elements/ModalFooter';
4
- export type { TitleContainer } from './Elements/ModalTitle';
4
+ export { TitleContainer } from './Elements/ModalTitle';
5
5
  export type { Props, ModalProps } from './Modal.types';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { default, buildModalFooter } from './Modal';
2
2
  export { ModalTitle } from './Elements/ModalTitle';
3
- export { ModalFooter } from './Elements/ModalFooter';
3
+ export { ModalFooter } from './Elements/ModalFooter';
4
+ export { TitleContainer } from './Elements/ModalTitle';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-modal",
3
- "version": "0.17.0",
3
+ "version": "0.17.2",
4
4
  "description": "Modal UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -45,5 +45,5 @@
45
45
  "devDependencies": {
46
46
  "@synerise/ds-utils": "^0.19.0"
47
47
  },
48
- "gitHead": "0795eb5071d9160e429731ba8f8807c1ae509085"
48
+ "gitHead": "9d424b025fe368bbf3beccea2102f000f4d7e82c"
49
49
  }
@@ -1,96 +0,0 @@
1
- import React from 'react';
2
- import { screen } from '@testing-library/react';
3
- import userEvent from '@testing-library/user-event';
4
- import { renderWithProvider } from '@synerise/ds-utils/dist/testing';
5
- import Button from '@synerise/ds-button';
6
- import { ModalFooter } from './ModalFooter';
7
- describe('ModalFooter', function () {
8
- var onOkMock = jest.fn();
9
- var onCancelMock = jest.fn();
10
-
11
- var CustomButtonMock = function CustomButtonMock(_ref) {
12
- var children = _ref.children,
13
- onClick = _ref.onClick,
14
- disabled = _ref.disabled;
15
- return /*#__PURE__*/React.createElement(Button, {
16
- onClick: onClick,
17
- disabled: disabled
18
- }, "Custom ", children);
19
- };
20
-
21
- beforeEach(function () {
22
- jest.clearAllMocks();
23
- });
24
- it('renders default cancel and apply buttons', function () {
25
- renderWithProvider( /*#__PURE__*/React.createElement(ModalFooter, {
26
- onCancel: onCancelMock,
27
- onOk: onOkMock
28
- }));
29
- var cancelButton = screen.getByText('Cancel');
30
- var okButton = screen.getByText('Apply');
31
- expect(cancelButton).toBeInTheDocument();
32
- expect(okButton).toBeInTheDocument();
33
- });
34
- it('renders custom cancel and apply buttons', function () {
35
- var customTexts = {
36
- cancelButton: 'Custom Cancel',
37
- okButton: 'Custom Apply'
38
- };
39
- renderWithProvider( /*#__PURE__*/React.createElement(ModalFooter, {
40
- onCancel: onCancelMock,
41
- onOk: onOkMock,
42
- texts: customTexts
43
- }));
44
- var cancelButton = screen.getByText('Custom Cancel');
45
- var okButton = screen.getByText('Custom Apply');
46
- expect(cancelButton).toBeInTheDocument();
47
- expect(okButton).toBeInTheDocument();
48
- });
49
- it('calls onOk and onCancel callbacks when buttons are clicked', function () {
50
- renderWithProvider( /*#__PURE__*/React.createElement(ModalFooter, {
51
- onCancel: onCancelMock,
52
- onOk: onOkMock
53
- }));
54
- var cancelButton = screen.getByText('Cancel');
55
- var okButton = screen.getByText('Apply');
56
- userEvent.click(cancelButton);
57
- expect(onCancelMock).toBeCalledTimes(1);
58
- userEvent.click(okButton);
59
- expect(onOkMock).toBeCalledTimes(1);
60
- });
61
- it('renders prefix, infix and suffix elements in the footer', function () {
62
- var prefixNode = /*#__PURE__*/React.createElement("div", {
63
- "data-testid": "prefix"
64
- }, "Prefix Node");
65
- var infixNode = /*#__PURE__*/React.createElement("div", {
66
- "data-testid": "infix"
67
- }, "Infix Node");
68
- var suffixNode = /*#__PURE__*/React.createElement("div", {
69
- "data-testid": "suffix"
70
- }, "Suffix Node");
71
- renderWithProvider( /*#__PURE__*/React.createElement(ModalFooter, {
72
- onCancel: onCancelMock,
73
- onOk: onOkMock,
74
- prefix: prefixNode,
75
- suffix: suffixNode,
76
- infix: infixNode
77
- }));
78
- var prefixElement = screen.getByTestId('prefix');
79
- var infixElement = screen.getByTestId('infix');
80
- var suffixElement = screen.getByTestId('suffix');
81
- expect(prefixElement).toBeInTheDocument();
82
- expect(infixElement).toBeInTheDocument();
83
- expect(suffixElement).toBeInTheDocument();
84
- });
85
- it('renders custom DSButton component for cancel and apply buttons', function () {
86
- renderWithProvider( /*#__PURE__*/React.createElement(ModalFooter, {
87
- onCancel: onCancelMock,
88
- onOk: onOkMock,
89
- CustomFooterButton: CustomButtonMock
90
- }));
91
- var cancelButton = screen.getByText('Custom Cancel');
92
- var okButton = screen.getByText('Custom Apply');
93
- expect(cancelButton).toHaveTextContent('Custom Cancel');
94
- expect(okButton).toHaveTextContent('Custom Apply');
95
- });
96
- });
@@ -1,84 +0,0 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import { renderWithProvider } from '@synerise/ds-utils/dist/testing';
4
- import userEvent from '@testing-library/user-event';
5
- import { ModalTitle } from './ModalTitle';
6
- describe('ModalTitle', function () {
7
- var onCancelMock = jest.fn();
8
- var title = 'Test Title';
9
- var description = 'Test Description';
10
- beforeEach(function () {
11
- jest.clearAllMocks();
12
- });
13
- it('should render title and description when props are provided', function () {
14
- renderWithProvider( /*#__PURE__*/React.createElement(ModalTitle, {
15
- title: title,
16
- description: description
17
- }));
18
- var titleElement = screen.getByText(title);
19
- var descriptionElement = screen.getByText(description);
20
- expect(titleElement).toBeInTheDocument();
21
- expect(descriptionElement).toBeInTheDocument();
22
- });
23
- it('should render close button when blank is true and onCancel is provided', function () {
24
- renderWithProvider( /*#__PURE__*/React.createElement(ModalTitle, {
25
- blank: true,
26
- onCancel: onCancelMock
27
- }));
28
- var closeButton = screen.getByTestId('modal-close');
29
- expect(closeButton).toBeInTheDocument();
30
- });
31
- it('should call onCancel when the close button is clicked', function () {
32
- renderWithProvider( /*#__PURE__*/React.createElement(ModalTitle, {
33
- blank: true,
34
- onCancel: onCancelMock
35
- }));
36
- var closeButton = screen.getByTestId('modal-close');
37
- userEvent.click(closeButton);
38
- expect(onCancelMock).toHaveBeenCalled();
39
- });
40
- it('should not render close button when blank is true but onCancel is not provided', function () {
41
- render( /*#__PURE__*/React.createElement(ModalTitle, {
42
- blank: true
43
- }));
44
- var closeButton = screen.queryByTestId('modal-close');
45
- expect(closeButton).not.toBeInTheDocument();
46
- });
47
- it('should render headerActions when provided', function () {
48
- // eslint-disable-next-line react/button-has-type
49
- var headerActions = /*#__PURE__*/React.createElement("button", {
50
- onClick: jest.fn()
51
- }, "Test Action");
52
- renderWithProvider( /*#__PURE__*/React.createElement(ModalTitle, {
53
- title: title,
54
- headerActions: headerActions
55
- }));
56
- var headerActionsElement = screen.getByText('Test Action');
57
- expect(headerActionsElement).toBeInTheDocument();
58
- });
59
- it('should not render headerActions when not provided', function () {
60
- renderWithProvider( /*#__PURE__*/React.createElement(ModalTitle, {
61
- title: title
62
- }));
63
- var headerActionsElement = screen.queryByText('Test Action');
64
- expect(headerActionsElement).not.toBeInTheDocument();
65
- });
66
- it('should render custom title container style when provided', function () {
67
- var customStyle = {
68
- backgroundColor: 'red'
69
- };
70
- renderWithProvider( /*#__PURE__*/React.createElement(ModalTitle, {
71
- title: title,
72
- titleContainerStyle: customStyle
73
- }));
74
- var titleContainer = screen.getByTestId('modal-title');
75
- expect(titleContainer).toHaveStyle(customStyle);
76
- });
77
- it('should not render description when description prop is not provided', function () {
78
- renderWithProvider( /*#__PURE__*/React.createElement(ModalTitle, {
79
- title: "Test Title"
80
- }));
81
- var descriptionElement = screen.queryByText('Test Description');
82
- expect(descriptionElement).not.toBeInTheDocument();
83
- });
84
- });
@@ -1,75 +0,0 @@
1
- import React from 'react';
2
- import { screen } from '@testing-library/react';
3
- import { renderWithProvider } from '@synerise/ds-utils/dist/testing';
4
- import Modal from './Modal';
5
- describe('Modal', function () {
6
- var titleMock = 'Test Title';
7
- var descriptionMock = 'Test Description';
8
- beforeEach(function () {
9
- jest.clearAllMocks();
10
- });
11
- it('should not render modal if there is no visible prop or visible is false', function () {
12
- renderWithProvider( /*#__PURE__*/React.createElement(Modal, {
13
- title: titleMock,
14
- description: descriptionMock
15
- }));
16
- var modalDialog = screen.queryByRole('document');
17
- expect(modalDialog).not.toBeInTheDocument();
18
- });
19
- it('should render title, description, and blank correctly', function () {
20
- renderWithProvider( /*#__PURE__*/React.createElement(Modal, {
21
- title: titleMock,
22
- description: descriptionMock,
23
- visible: true
24
- }));
25
- var titleElement = screen.getByText(titleMock);
26
- var descriptionElement = screen.getByText(descriptionMock);
27
- expect(titleElement).toBeInTheDocument();
28
- expect(descriptionElement).toBeInTheDocument();
29
- });
30
- it('should not render title and description when blank, title and description is false', function () {
31
- renderWithProvider( /*#__PURE__*/React.createElement(Modal, {
32
- visible: true
33
- }));
34
- var titleElement = screen.queryByText(titleMock);
35
- var descriptionElement = screen.queryByText(descriptionMock);
36
- var closeButton = screen.queryByTestId('modal-close');
37
- expect(titleElement).not.toBeInTheDocument();
38
- expect(descriptionElement).not.toBeInTheDocument();
39
- expect(closeButton).not.toBeInTheDocument();
40
- });
41
- it('should render headerActions when provided', function () {
42
- // eslint-disable-next-line react/button-has-type
43
- var headerActions = /*#__PURE__*/React.createElement("button", {
44
- onClick: jest.fn()
45
- }, "Test Action");
46
- renderWithProvider( /*#__PURE__*/React.createElement(Modal, {
47
- title: titleMock,
48
- headerActions: headerActions,
49
- visible: true
50
- }));
51
- var headerActionsElement = screen.getByText('Test Action');
52
- expect(headerActionsElement).toBeInTheDocument();
53
- });
54
- it('should render custom size correctly', function () {
55
- renderWithProvider( /*#__PURE__*/React.createElement(Modal, {
56
- title: "Test Title",
57
- size: "medium",
58
- visible: true
59
- }));
60
- var modalDialog = screen.getByRole('document');
61
- expect(modalDialog).toHaveStyle({
62
- width: '792px'
63
- });
64
- });
65
- it('should show custom footer if its in props', function () {
66
- renderWithProvider( /*#__PURE__*/React.createElement(Modal, {
67
- footer: /*#__PURE__*/React.createElement("div", null, "Custom Footer"),
68
- visible: true
69
- }));
70
- var customFooter = screen.getByText('Custom Footer');
71
- var defaultFooter = screen.queryByTestId('modal-footer');
72
- expect(customFooter).toBeInTheDocument();
73
- expect(defaultFooter).not.toBeInTheDocument();
74
- });
75
- });