@atlaskit/modal-dialog 12.7.1 → 12.8.1

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,17 @@
1
1
  # @atlaskit/modal-dialog
2
2
 
3
+ ## 12.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#40647](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40647) [`0de92f17021`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0de92f17021) - Bump react-focus-lock to latest version
8
+
9
+ ## 12.8.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#39425](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/39425) [`f0df9a3b6e7`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f0df9a3b6e7) - [ED-19408] Add new prop to modal shouldReturnFocus - shouldReturnFocus is used to control what happens when the user exits focus lock mode. If true, focus will be returned to the element that had focus before focus lock was activated. If false, focus remains where it was when the FocusLock was deactivated
14
+
3
15
  ## 12.7.1
4
16
 
5
17
  ### Patch Changes
package/dist/cjs/hooks.js CHANGED
@@ -6,11 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.useModal = void 0;
7
7
  var _react = require("react");
8
8
  var _context = require("./internal/context");
9
- var useModal = function useModal() {
9
+ var useModal = exports.useModal = function useModal() {
10
10
  var modalContext = (0, _react.useContext)(_context.ModalContext);
11
11
  if (modalContext == null) {
12
12
  throw Error('@atlaskit/modal-dialog: Modal context unavailable – this component needs to be a child of ModalDialog.');
13
13
  }
14
14
  return modalContext;
15
- };
16
- exports.useModal = useModal;
15
+ };
@@ -135,5 +135,4 @@ var ModalDialog = function ModalDialog(props) {
135
135
  };
136
136
 
137
137
  // eslint-disable-next-line @repo/internal/react/require-jsdoc
138
- var _default = ModalDialog;
139
- exports.default = _default;
138
+ var _default = exports.default = ModalDialog;
@@ -84,5 +84,4 @@ var Positioner = function Positioner(props) {
84
84
  };
85
85
 
86
86
  // eslint-disable-next-line @repo/internal/react/require-jsdoc
87
- var _default = Positioner;
88
- exports.default = _default;
87
+ var _default = exports.default = Positioner;
@@ -120,5 +120,4 @@ var ScrollContainer = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
120
120
  }, children));
121
121
  });
122
122
  ScrollContainer.displayName = 'ScrollContainer';
123
- var _default = ScrollContainer;
124
- exports.default = _default;
123
+ var _default = exports.default = ScrollContainer;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.width = exports.verticalOffset = exports.titleIconMargin = exports.textColor = exports.padding = exports.keylineHeight = exports.keylineColor = exports.iconColor = exports.gutter = exports.borderRadius = void 0;
7
7
  var _colors = require("@atlaskit/theme/colors");
8
8
  var _constants = require("@atlaskit/theme/constants");
9
- var width = {
9
+ var width = exports.width = {
10
10
  values: ['small', 'medium', 'large', 'x-large'],
11
11
  widths: {
12
12
  small: 400,
@@ -16,26 +16,16 @@ var width = {
16
16
  },
17
17
  defaultValue: 'medium'
18
18
  };
19
- exports.width = width;
20
- var gutter = 60;
21
- exports.gutter = gutter;
19
+ var gutter = exports.gutter = 60;
22
20
  var gridSize = (0, _constants.gridSize)();
23
- var borderRadius = (0, _constants.borderRadius)();
24
- exports.borderRadius = borderRadius;
25
- var verticalOffset = gridSize * 2;
26
- exports.verticalOffset = verticalOffset;
27
- var padding = gridSize * 3;
28
- exports.padding = padding;
29
- var titleIconMargin = gridSize;
30
- exports.titleIconMargin = titleIconMargin;
31
- var keylineHeight = 2;
32
- exports.keylineHeight = keylineHeight;
33
- var keylineColor = "var(--ds-border, ".concat(_colors.N30, ")");
34
- exports.keylineColor = keylineColor;
35
- var textColor = "var(--ds-text, ".concat(_colors.N900, ")");
36
- exports.textColor = textColor;
37
- var iconColor = {
21
+ var borderRadius = exports.borderRadius = (0, _constants.borderRadius)();
22
+ var verticalOffset = exports.verticalOffset = gridSize * 2;
23
+ var padding = exports.padding = gridSize * 3;
24
+ var titleIconMargin = exports.titleIconMargin = gridSize;
25
+ var keylineHeight = exports.keylineHeight = 2;
26
+ var keylineColor = exports.keylineColor = "var(--ds-border, ".concat(_colors.N30, ")");
27
+ var textColor = exports.textColor = "var(--ds-text, ".concat(_colors.N900, ")");
28
+ var iconColor = exports.iconColor = {
38
29
  danger: "var(--ds-icon-danger, ".concat(_colors.R400, ")"),
39
30
  warning: "var(--ds-icon-warning, #D97008)"
40
- };
41
- exports.iconColor = iconColor;
31
+ };
@@ -6,7 +6,5 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ScrollContext = exports.ModalContext = void 0;
7
7
  var _react = require("react");
8
8
  /* eslint-disable @repo/internal/react/require-jsdoc */
9
- var ModalContext = /*#__PURE__*/(0, _react.createContext)(null);
10
- exports.ModalContext = ModalContext;
11
- var ScrollContext = /*#__PURE__*/(0, _react.createContext)(null);
12
- exports.ScrollContext = ScrollContext;
9
+ var ModalContext = exports.ModalContext = /*#__PURE__*/(0, _react.createContext)(null);
10
+ var ScrollContext = exports.ScrollContext = /*#__PURE__*/(0, _react.createContext)(null);
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.dialogWidth = exports.dialogHeight = void 0;
7
7
  var _constants = require("./constants");
8
- var dialogWidth = function dialogWidth(input) {
8
+ var dialogWidth = exports.dialogWidth = function dialogWidth(input) {
9
9
  if (!input) {
10
10
  return 'auto';
11
11
  }
@@ -16,11 +16,9 @@ var dialogWidth = function dialogWidth(input) {
16
16
  }
17
17
  return typeof input === 'number' ? "".concat(input, "px") : input;
18
18
  };
19
- exports.dialogWidth = dialogWidth;
20
- var dialogHeight = function dialogHeight(input) {
19
+ var dialogHeight = exports.dialogHeight = function dialogHeight(input) {
21
20
  if (!input) {
22
21
  return 'auto';
23
22
  }
24
23
  return typeof input === 'number' ? "".concat(input, "px") : input;
25
- };
26
- exports.dialogHeight = dialogHeight;
24
+ };
@@ -63,5 +63,4 @@ var ModalBody = function ModalBody(props) {
63
63
  "data-testid": testId
64
64
  }, children)));
65
65
  };
66
- var _default = ModalBody;
67
- exports.default = _default;
66
+ var _default = exports.default = ModalBody;
@@ -40,5 +40,4 @@ var ModalFooter = function ModalFooter(props) {
40
40
  "data-testid": testId
41
41
  }, children);
42
42
  };
43
- var _default = ModalFooter;
44
- exports.default = _default;
43
+ var _default = exports.default = ModalFooter;
@@ -41,5 +41,4 @@ var ModalHeader = function ModalHeader(props) {
41
41
  "data-testid": testId
42
42
  }, children);
43
43
  };
44
- var _default = ModalHeader;
45
- exports.default = _default;
44
+ var _default = exports.default = ModalHeader;
@@ -114,5 +114,4 @@ var ModalTitle = function ModalTitle(props) {
114
114
  "data-testid": testId && "".concat(testId, "-text")
115
115
  }, children));
116
116
  };
117
- var _default = ModalTitle;
118
- exports.default = _default;
117
+ var _default = exports.default = ModalTitle;
@@ -21,5 +21,4 @@ var ModalTransition = function ModalTransition(props) {
21
21
  appear: true
22
22
  }, props.children);
23
23
  };
24
- var _default = ModalTransition;
25
- exports.default = _default;
24
+ var _default = exports.default = ModalTransition;
@@ -58,6 +58,8 @@ var ModalWrapper = function ModalWrapper(props) {
58
58
  shouldCloseOnOverlayClick = _props$shouldCloseOnO === void 0 ? true : _props$shouldCloseOnO,
59
59
  _props$shouldScrollIn = props.shouldScrollInViewport,
60
60
  shouldScrollInViewport = _props$shouldScrollIn === void 0 ? false : _props$shouldScrollIn,
61
+ _props$shouldReturnFo = props.shouldReturnFocus,
62
+ shouldReturnFocus = _props$shouldReturnFo === void 0 ? true : _props$shouldReturnFo,
61
63
  stackIndexOverride = props.stackIndex,
62
64
  _props$onClose = props.onClose,
63
65
  onClose = _props$onClose === void 0 ? _noop.default : _props$onClose,
@@ -84,7 +86,7 @@ var ModalWrapper = function ModalWrapper(props) {
84
86
  action: 'closed',
85
87
  componentName: 'modalDialog',
86
88
  packageName: "@atlaskit/modal-dialog",
87
- packageVersion: "12.7.1"
89
+ packageVersion: "12.8.1"
88
90
  });
89
91
  var onBlanketClicked = (0, _react.useCallback)(function (e) {
90
92
  if (shouldCloseOnOverlayClick) {
@@ -118,10 +120,9 @@ var ModalWrapper = function ModalWrapper(props) {
118
120
  }), (0, _react2.jsx)(_reactFocusLock.default, {
119
121
  autoFocus: autoFocusLock,
120
122
  disabled: !isForeground,
121
- returnFocus: true,
123
+ returnFocus: shouldReturnFocus,
122
124
  whiteList: whiteListElements
123
125
  }, (0, _react2.jsx)(_reactScrolllock.default, null), shouldScrollInViewport ? (0, _react2.jsx)(_reactScrolllock.TouchScrollable, null, modalDialogWithBlanket) : modalDialogWithBlanket));
124
126
  })));
125
127
  };
126
- var _default = ModalWrapper;
127
- exports.default = _default;
128
+ var _default = exports.default = ModalWrapper;
@@ -45,6 +45,7 @@ const ModalWrapper = props => {
45
45
  shouldCloseOnEscapePress = true,
46
46
  shouldCloseOnOverlayClick = true,
47
47
  shouldScrollInViewport = false,
48
+ shouldReturnFocus = true,
48
49
  stackIndex: stackIndexOverride,
49
50
  onClose = noop,
50
51
  onStackChange = noop,
@@ -70,7 +71,7 @@ const ModalWrapper = props => {
70
71
  action: 'closed',
71
72
  componentName: 'modalDialog',
72
73
  packageName: "@atlaskit/modal-dialog",
73
- packageVersion: "12.7.1"
74
+ packageVersion: "12.8.1"
74
75
  });
75
76
  const onBlanketClicked = useCallback(e => {
76
77
  if (shouldCloseOnOverlayClick) {
@@ -103,7 +104,7 @@ const ModalWrapper = props => {
103
104
  }), jsx(FocusLock, {
104
105
  autoFocus: autoFocusLock,
105
106
  disabled: !isForeground,
106
- returnFocus: true,
107
+ returnFocus: shouldReturnFocus,
107
108
  whiteList: whiteListElements
108
109
  }, jsx(ScrollLock, null), shouldScrollInViewport ? jsx(TouchScrollable, null, modalDialogWithBlanket) : modalDialogWithBlanket)))));
109
110
  };
@@ -48,6 +48,8 @@ var ModalWrapper = function ModalWrapper(props) {
48
48
  shouldCloseOnOverlayClick = _props$shouldCloseOnO === void 0 ? true : _props$shouldCloseOnO,
49
49
  _props$shouldScrollIn = props.shouldScrollInViewport,
50
50
  shouldScrollInViewport = _props$shouldScrollIn === void 0 ? false : _props$shouldScrollIn,
51
+ _props$shouldReturnFo = props.shouldReturnFocus,
52
+ shouldReturnFocus = _props$shouldReturnFo === void 0 ? true : _props$shouldReturnFo,
51
53
  stackIndexOverride = props.stackIndex,
52
54
  _props$onClose = props.onClose,
53
55
  onClose = _props$onClose === void 0 ? noop : _props$onClose,
@@ -74,7 +76,7 @@ var ModalWrapper = function ModalWrapper(props) {
74
76
  action: 'closed',
75
77
  componentName: 'modalDialog',
76
78
  packageName: "@atlaskit/modal-dialog",
77
- packageVersion: "12.7.1"
79
+ packageVersion: "12.8.1"
78
80
  });
79
81
  var onBlanketClicked = useCallback(function (e) {
80
82
  if (shouldCloseOnOverlayClick) {
@@ -108,7 +110,7 @@ var ModalWrapper = function ModalWrapper(props) {
108
110
  }), jsx(FocusLock, {
109
111
  autoFocus: autoFocusLock,
110
112
  disabled: !isForeground,
111
- returnFocus: true,
113
+ returnFocus: shouldReturnFocus,
112
114
  whiteList: whiteListElements
113
115
  }, jsx(ScrollLock, null), shouldScrollInViewport ? jsx(TouchScrollable, null, modalDialogWithBlanket) : modalDialogWithBlanket));
114
116
  })));
@@ -61,6 +61,12 @@ export interface ModalDialogProps {
61
61
  * Calls `onClose` when pressing escape.
62
62
  */
63
63
  shouldCloseOnEscapePress?: boolean;
64
+ /**
65
+ * ReturnFocus is used to control what happens when the user exists
66
+ * focus lock mode. If true, focus will be returned to the element that had focus before focus lock
67
+ * was activated. If false, focus remains where it was when the FocusLock was deactivated.
68
+ */
69
+ shouldReturnFocus?: boolean;
64
70
  /**
65
71
  * Will remove the blanket tinted background color.
66
72
  */
@@ -61,6 +61,12 @@ export interface ModalDialogProps {
61
61
  * Calls `onClose` when pressing escape.
62
62
  */
63
63
  shouldCloseOnEscapePress?: boolean;
64
+ /**
65
+ * ReturnFocus is used to control what happens when the user exists
66
+ * focus lock mode. If true, focus will be returned to the element that had focus before focus lock
67
+ * was activated. If false, focus remains where it was when the FocusLock was deactivated.
68
+ */
69
+ shouldReturnFocus?: boolean;
64
70
  /**
65
71
  * Will remove the blanket tinted background color.
66
72
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/modal-dialog",
3
- "version": "12.7.1",
3
+ "version": "12.8.1",
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/"
@@ -42,7 +42,7 @@
42
42
  "@emotion/react": "^11.7.1",
43
43
  "bind-event-listener": "^2.1.1",
44
44
  "raf-schd": "^4.0.3",
45
- "react-focus-lock": "^2.5.2",
45
+ "react-focus-lock": "^2.9.5",
46
46
  "react-scrolllock": "^5.0.1",
47
47
  "react-uid": "^2.2.0"
48
48
  },
package/report.api.md CHANGED
@@ -62,6 +62,7 @@ export interface ModalDialogProps {
62
62
  onStackChange?: OnStackChangeHandler;
63
63
  shouldCloseOnEscapePress?: boolean;
64
64
  shouldCloseOnOverlayClick?: boolean;
65
+ shouldReturnFocus?: boolean;
65
66
  shouldScrollInViewport?: boolean;
66
67
  stackIndex?: number;
67
68
  testId?: string;
@@ -48,6 +48,7 @@ export interface ModalDialogProps {
48
48
  onStackChange?: OnStackChangeHandler;
49
49
  shouldCloseOnEscapePress?: boolean;
50
50
  shouldCloseOnOverlayClick?: boolean;
51
+ shouldReturnFocus?: boolean;
51
52
  shouldScrollInViewport?: boolean;
52
53
  stackIndex?: number;
53
54
  testId?: string;