@atlaskit/modal-dialog 14.0.2 → 14.0.4

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
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/modal-dialog
2
2
 
3
+ ## 14.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#133231](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/133231)
8
+ [`82b4213bf8e20`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/82b4213bf8e20) -
9
+ Update the DOM order of the modal header when using the `hasCloseButton` prop to give maximal
10
+ information to users of assistive technology.
11
+
12
+ ## 14.0.3
13
+
14
+ ### Patch Changes
15
+
16
+ - [#126072](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/126072)
17
+ [`bb86d48c26f65`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bb86d48c26f65) -
18
+ Checks for undefined children in `ModalTransition` to prevent potential runtime errors with React
19
+ 17
20
+ - Updated dependencies
21
+
3
22
  ## 14.0.2
4
23
 
5
24
  ### Patch Changes
@@ -13,6 +13,12 @@ var _closeCross = _interopRequireDefault(require("@atlaskit/icon/core/migration/
13
13
  *
14
14
  * The close button is to be used for customized modal headers to ensure that
15
15
  * all users have an accessible and obvious way to close the modal dialog.
16
+ *
17
+ * When using this in a custom header, ensure that the close button renders
18
+ * first in the DOM to make sure that users will encounter all elements of the
19
+ * modal dialog, including everything within the modal header. This can be done
20
+ * using a `Flex` primitive as the custom header's container with a flex
21
+ * direction of `row-reverse`.
16
22
  */
17
23
  var CloseButton = exports.CloseButton = function CloseButton(_ref) {
18
24
  var label = _ref.label,
@@ -13,15 +13,10 @@ var _primitives = require("@atlaskit/primitives");
13
13
  var _closeButton = require("./close-button");
14
14
  var _hooks = require("./hooks");
15
15
  var headerStyles = null;
16
- var gridStyles = (0, _primitives.xcss)({
16
+ var flexStyles = (0, _primitives.xcss)({
17
+ flexDirection: 'row-reverse',
17
18
  width: '100%'
18
19
  });
19
- var closeContainerStyles = (0, _primitives.xcss)({
20
- gridArea: 'close'
21
- });
22
- var titleContainerStyles = (0, _primitives.xcss)({
23
- gridArea: 'title'
24
- });
25
20
  /**
26
21
  * __Modal header__
27
22
  *
@@ -50,20 +45,24 @@ var ModalHeader = function ModalHeader(props) {
50
45
  style: {
51
46
  "--_t7lu6v": (0, _runtime.ix)("calc(-1 * ".concat("var(--ds-border-width-outline, 2px)", ")"))
52
47
  }
53
- }, shouldShowCloseButton ? /*#__PURE__*/_react.default.createElement(_primitives.Grid, {
48
+ }, shouldShowCloseButton ?
49
+ /*#__PURE__*/
50
+ // The reason we are putting the close button first in the DOM and then
51
+ // reordering them is to ensure that users of assistive technology get
52
+ // all the context of a modal when initial focus is placed on the close
53
+ // button, since it's the first interactive element.
54
+ _react.default.createElement(_primitives.Flex, {
54
55
  gap: "space.200",
55
- templateAreas: ['title close'],
56
- xcss: gridStyles
56
+ justifyContent: "space-between",
57
+ xcss: flexStyles
57
58
  }, /*#__PURE__*/_react.default.createElement(_primitives.Flex, {
58
- xcss: titleContainerStyles,
59
- justifyContent: "start",
60
- alignItems: "center"
61
- }, children), /*#__PURE__*/_react.default.createElement(_primitives.Flex, {
62
- xcss: closeContainerStyles,
63
59
  justifyContent: "end"
64
60
  }, /*#__PURE__*/_react.default.createElement(_closeButton.CloseButton, {
65
61
  onClick: onClose,
66
62
  testId: modalTestId
67
- }))) : children);
63
+ })), /*#__PURE__*/_react.default.createElement(_primitives.Flex, {
64
+ justifyContent: "start",
65
+ alignItems: "center"
66
+ }, children)) : children);
68
67
  };
69
68
  var _default = exports.default = ModalHeader;
@@ -17,8 +17,10 @@ var _exitingPersistence = _interopRequireDefault(require("@atlaskit/motion/exiti
17
17
  * - [Usage](https://atlassian.design/components/modal-dialog/usage)
18
18
  */
19
19
  var ModalTransition = function ModalTransition(props) {
20
+ var _props$children;
20
21
  return /*#__PURE__*/_react.default.createElement(_exitingPersistence.default, {
21
22
  appear: true
22
- }, props.children);
23
+ }, //Checking if children are undefined to prevent potential runtime errors in React 17
24
+ (_props$children = props.children) !== null && _props$children !== void 0 ? _props$children : null);
23
25
  };
24
26
  var _default = exports.default = ModalTransition;
@@ -87,7 +87,7 @@ var ModalWrapper = function ModalWrapper(props) {
87
87
  action: 'closed',
88
88
  componentName: 'modalDialog',
89
89
  packageName: "@atlaskit/modal-dialog",
90
- packageVersion: "14.0.2"
90
+ packageVersion: "14.0.4"
91
91
  });
92
92
  var onBlanketClicked = (0, _react.useCallback)(function (e) {
93
93
  if (shouldCloseOnOverlayClick) {
@@ -6,6 +6,12 @@ import CrossIcon from '@atlaskit/icon/core/migration/close--cross';
6
6
  *
7
7
  * The close button is to be used for customized modal headers to ensure that
8
8
  * all users have an accessible and obvious way to close the modal dialog.
9
+ *
10
+ * When using this in a custom header, ensure that the close button renders
11
+ * first in the DOM to make sure that users will encounter all elements of the
12
+ * modal dialog, including everything within the modal header. This can be done
13
+ * using a `Flex` primitive as the custom header's container with a flex
14
+ * direction of `row-reverse`.
9
15
  */
10
16
  export const CloseButton = ({
11
17
  label,
@@ -2,19 +2,14 @@
2
2
  import "./modal-header.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
5
- import { Flex, Grid, xcss } from '@atlaskit/primitives';
5
+ import { Flex, xcss } from '@atlaskit/primitives';
6
6
  import { CloseButton } from './close-button';
7
7
  import { useModal } from './hooks';
8
8
  const headerStyles = null;
9
- const gridStyles = xcss({
9
+ const flexStyles = xcss({
10
+ flexDirection: 'row-reverse',
10
11
  width: '100%'
11
12
  });
12
- const closeContainerStyles = xcss({
13
- gridArea: 'close'
14
- });
15
- const titleContainerStyles = xcss({
16
- gridArea: 'title'
17
- });
18
13
  /**
19
14
  * __Modal header__
20
15
  *
@@ -42,20 +37,24 @@ const ModalHeader = props => {
42
37
  return /*#__PURE__*/React.createElement("div", {
43
38
  "data-testid": testId,
44
39
  className: ax(["_18zr1ejb _1e0c1txw _kqswh2mm _4cvr1h6o _1bah1yb4 _6rth1ezb _85i5pxbi _1q511ejb"])
45
- }, shouldShowCloseButton ? /*#__PURE__*/React.createElement(Grid, {
40
+ }, shouldShowCloseButton ?
41
+ /*#__PURE__*/
42
+ // The reason we are putting the close button first in the DOM and then
43
+ // reordering them is to ensure that users of assistive technology get
44
+ // all the context of a modal when initial focus is placed on the close
45
+ // button, since it's the first interactive element.
46
+ React.createElement(Flex, {
46
47
  gap: "space.200",
47
- templateAreas: ['title close'],
48
- xcss: gridStyles
48
+ justifyContent: "space-between",
49
+ xcss: flexStyles
49
50
  }, /*#__PURE__*/React.createElement(Flex, {
50
- xcss: titleContainerStyles,
51
- justifyContent: "start",
52
- alignItems: "center"
53
- }, children), /*#__PURE__*/React.createElement(Flex, {
54
- xcss: closeContainerStyles,
55
51
  justifyContent: "end"
56
52
  }, /*#__PURE__*/React.createElement(CloseButton, {
57
53
  onClick: onClose,
58
54
  testId: modalTestId
59
- }))) : children);
55
+ })), /*#__PURE__*/React.createElement(Flex, {
56
+ justifyContent: "start",
57
+ alignItems: "center"
58
+ }, children)) : children);
60
59
  };
61
60
  export default ModalHeader;
@@ -11,8 +11,10 @@ import ExitingPersistence from '@atlaskit/motion/exiting-persistence';
11
11
  * - [Usage](https://atlassian.design/components/modal-dialog/usage)
12
12
  */
13
13
  const ModalTransition = props => {
14
+ var _props$children;
14
15
  return /*#__PURE__*/React.createElement(ExitingPersistence, {
15
16
  appear: true
16
- }, props.children);
17
+ }, //Checking if children are undefined to prevent potential runtime errors in React 17
18
+ (_props$children = props.children) !== null && _props$children !== void 0 ? _props$children : null);
17
19
  };
18
20
  export default ModalTransition;
@@ -73,7 +73,7 @@ const ModalWrapper = props => {
73
73
  action: 'closed',
74
74
  componentName: 'modalDialog',
75
75
  packageName: "@atlaskit/modal-dialog",
76
- packageVersion: "14.0.2"
76
+ packageVersion: "14.0.4"
77
77
  });
78
78
  const onBlanketClicked = useCallback(e => {
79
79
  if (shouldCloseOnOverlayClick) {
@@ -6,6 +6,12 @@ import CrossIcon from '@atlaskit/icon/core/migration/close--cross';
6
6
  *
7
7
  * The close button is to be used for customized modal headers to ensure that
8
8
  * all users have an accessible and obvious way to close the modal dialog.
9
+ *
10
+ * When using this in a custom header, ensure that the close button renders
11
+ * first in the DOM to make sure that users will encounter all elements of the
12
+ * modal dialog, including everything within the modal header. This can be done
13
+ * using a `Flex` primitive as the custom header's container with a flex
14
+ * direction of `row-reverse`.
9
15
  */
10
16
  export var CloseButton = function CloseButton(_ref) {
11
17
  var label = _ref.label,
@@ -2,19 +2,14 @@
2
2
  import "./modal-header.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
5
- import { Flex, Grid, xcss } from '@atlaskit/primitives';
5
+ import { Flex, xcss } from '@atlaskit/primitives';
6
6
  import { CloseButton } from './close-button';
7
7
  import { useModal } from './hooks';
8
8
  var headerStyles = null;
9
- var gridStyles = xcss({
9
+ var flexStyles = xcss({
10
+ flexDirection: 'row-reverse',
10
11
  width: '100%'
11
12
  });
12
- var closeContainerStyles = xcss({
13
- gridArea: 'close'
14
- });
15
- var titleContainerStyles = xcss({
16
- gridArea: 'title'
17
- });
18
13
  /**
19
14
  * __Modal header__
20
15
  *
@@ -43,20 +38,24 @@ var ModalHeader = function ModalHeader(props) {
43
38
  style: {
44
39
  "--_t7lu6v": ix("calc(-1 * ".concat("var(--ds-border-width-outline, 2px)", ")"))
45
40
  }
46
- }, shouldShowCloseButton ? /*#__PURE__*/React.createElement(Grid, {
41
+ }, shouldShowCloseButton ?
42
+ /*#__PURE__*/
43
+ // The reason we are putting the close button first in the DOM and then
44
+ // reordering them is to ensure that users of assistive technology get
45
+ // all the context of a modal when initial focus is placed on the close
46
+ // button, since it's the first interactive element.
47
+ React.createElement(Flex, {
47
48
  gap: "space.200",
48
- templateAreas: ['title close'],
49
- xcss: gridStyles
49
+ justifyContent: "space-between",
50
+ xcss: flexStyles
50
51
  }, /*#__PURE__*/React.createElement(Flex, {
51
- xcss: titleContainerStyles,
52
- justifyContent: "start",
53
- alignItems: "center"
54
- }, children), /*#__PURE__*/React.createElement(Flex, {
55
- xcss: closeContainerStyles,
56
52
  justifyContent: "end"
57
53
  }, /*#__PURE__*/React.createElement(CloseButton, {
58
54
  onClick: onClose,
59
55
  testId: modalTestId
60
- }))) : children);
56
+ })), /*#__PURE__*/React.createElement(Flex, {
57
+ justifyContent: "start",
58
+ alignItems: "center"
59
+ }, children)) : children);
61
60
  };
62
61
  export default ModalHeader;
@@ -11,8 +11,10 @@ import ExitingPersistence from '@atlaskit/motion/exiting-persistence';
11
11
  * - [Usage](https://atlassian.design/components/modal-dialog/usage)
12
12
  */
13
13
  var ModalTransition = function ModalTransition(props) {
14
+ var _props$children;
14
15
  return /*#__PURE__*/React.createElement(ExitingPersistence, {
15
16
  appear: true
16
- }, props.children);
17
+ }, //Checking if children are undefined to prevent potential runtime errors in React 17
18
+ (_props$children = props.children) !== null && _props$children !== void 0 ? _props$children : null);
17
19
  };
18
20
  export default ModalTransition;
@@ -77,7 +77,7 @@ var ModalWrapper = function ModalWrapper(props) {
77
77
  action: 'closed',
78
78
  componentName: 'modalDialog',
79
79
  packageName: "@atlaskit/modal-dialog",
80
- packageVersion: "14.0.2"
80
+ packageVersion: "14.0.4"
81
81
  });
82
82
  var onBlanketClicked = useCallback(function (e) {
83
83
  if (shouldCloseOnOverlayClick) {
@@ -1,13 +1,30 @@
1
1
  import React from 'react';
2
2
  import { type OnCloseHandler } from './types';
3
+ type CloseButtonProps = {
4
+ /**
5
+ * The accessible name to give to the close button.
6
+ */
7
+ label?: string;
8
+ /**
9
+ * The same close handler you give to the top-level modal component.
10
+ */
11
+ onClick: OnCloseHandler;
12
+ /**
13
+ * The prefix to use. Renders as `{testId}--close-button`.
14
+ */
15
+ testId?: string;
16
+ };
3
17
  /**
4
18
  * __Close button__
5
19
  *
6
20
  * The close button is to be used for customized modal headers to ensure that
7
21
  * all users have an accessible and obvious way to close the modal dialog.
22
+ *
23
+ * When using this in a custom header, ensure that the close button renders
24
+ * first in the DOM to make sure that users will encounter all elements of the
25
+ * modal dialog, including everything within the modal header. This can be done
26
+ * using a `Flex` primitive as the custom header's container with a flex
27
+ * direction of `row-reverse`.
8
28
  */
9
- export declare const CloseButton: ({ label, onClick, testId, }: {
10
- label?: string | undefined;
11
- onClick: OnCloseHandler;
12
- testId?: string | undefined;
13
- }) => React.JSX.Element;
29
+ export declare const CloseButton: ({ label, onClick, testId }: CloseButtonProps) => React.JSX.Element;
30
+ export {};
@@ -14,8 +14,11 @@ export type { ModalFooterProps } from './modal-footer';
14
14
  export type { ModalAttributes } from './internal/context';
15
15
  export interface ModalDialogProps {
16
16
  /**
17
- * Focus is moved to the first interactive element inside the modal dialog when `true`.
18
- * Pass an element `ref` to focus on a specific element.
17
+ * Focus is moved to the first interactive element inside the modal dialog
18
+ * when `true`. It is not recommended to set to `false` as this creates
19
+ * accessibility regressions. Pass an element `ref` to focus on a specific element.
20
+ *
21
+ * Default value is `true`.
19
22
  */
20
23
  autoFocus?: boolean | RefObject<HTMLElement | null | undefined>;
21
24
  /**
@@ -98,6 +101,7 @@ export interface ModalDialogProps {
98
101
  * If not overridden using `testId` prop in the respective components, this will set `data-testid` on these elements when defined:
99
102
  * - Modal dialog: `{testId}`
100
103
  * - Modal header: `{testId}--header`
104
+ * - Close button: `{testId}--close-button`
101
105
  * - Modal title: `{testId}--title`
102
106
  * - Modal body: `{testId}--body`
103
107
  * - Modal footer: `{testId}--footer`
@@ -1,13 +1,30 @@
1
1
  import React from 'react';
2
2
  import { type OnCloseHandler } from './types';
3
+ type CloseButtonProps = {
4
+ /**
5
+ * The accessible name to give to the close button.
6
+ */
7
+ label?: string;
8
+ /**
9
+ * The same close handler you give to the top-level modal component.
10
+ */
11
+ onClick: OnCloseHandler;
12
+ /**
13
+ * The prefix to use. Renders as `{testId}--close-button`.
14
+ */
15
+ testId?: string;
16
+ };
3
17
  /**
4
18
  * __Close button__
5
19
  *
6
20
  * The close button is to be used for customized modal headers to ensure that
7
21
  * all users have an accessible and obvious way to close the modal dialog.
22
+ *
23
+ * When using this in a custom header, ensure that the close button renders
24
+ * first in the DOM to make sure that users will encounter all elements of the
25
+ * modal dialog, including everything within the modal header. This can be done
26
+ * using a `Flex` primitive as the custom header's container with a flex
27
+ * direction of `row-reverse`.
8
28
  */
9
- export declare const CloseButton: ({ label, onClick, testId, }: {
10
- label?: string | undefined;
11
- onClick: OnCloseHandler;
12
- testId?: string | undefined;
13
- }) => React.JSX.Element;
29
+ export declare const CloseButton: ({ label, onClick, testId }: CloseButtonProps) => React.JSX.Element;
30
+ export {};
@@ -14,8 +14,11 @@ export type { ModalFooterProps } from './modal-footer';
14
14
  export type { ModalAttributes } from './internal/context';
15
15
  export interface ModalDialogProps {
16
16
  /**
17
- * Focus is moved to the first interactive element inside the modal dialog when `true`.
18
- * Pass an element `ref` to focus on a specific element.
17
+ * Focus is moved to the first interactive element inside the modal dialog
18
+ * when `true`. It is not recommended to set to `false` as this creates
19
+ * accessibility regressions. Pass an element `ref` to focus on a specific element.
20
+ *
21
+ * Default value is `true`.
19
22
  */
20
23
  autoFocus?: boolean | RefObject<HTMLElement | null | undefined>;
21
24
  /**
@@ -98,6 +101,7 @@ export interface ModalDialogProps {
98
101
  * If not overridden using `testId` prop in the respective components, this will set `data-testid` on these elements when defined:
99
102
  * - Modal dialog: `{testId}`
100
103
  * - Modal header: `{testId}--header`
104
+ * - Close button: `{testId}--close-button`
101
105
  * - Modal title: `{testId}--title`
102
106
  * - Modal body: `{testId}--body`
103
107
  * - Modal footer: `{testId}--footer`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/modal-dialog",
3
- "version": "14.0.2",
3
+ "version": "14.0.4",
4
4
  "description": "A modal dialog displays content that requires user interaction, in a layer above the page.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -70,7 +70,7 @@
70
70
  "@atlaskit/flag": "^17.1.0",
71
71
  "@atlaskit/form": "^12.0.0",
72
72
  "@atlaskit/heading": "^5.1.0",
73
- "@atlaskit/link": "^3.0.0",
73
+ "@atlaskit/link": "^3.1.0",
74
74
  "@atlaskit/popup": "^3.0.0",
75
75
  "@atlaskit/radio": "^8.0.0",
76
76
  "@atlaskit/section-message": "^8.2.0",