@atlaskit/modal-dialog 14.18.2 → 15.0.0
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 +24 -0
- package/codemods/{not-yet-boolean-autofocus-removal.tsx → 15.0.0-boolean-autofocus-removal.tsx} +2 -2
- package/codemods/__tests__/{not-yet-boolean-autofocus-removal.tsx → next-boolean-autofocus-removal.tsx} +1 -1
- package/codemods/migrations/remove-props.tsx +1 -1
- package/dist/cjs/internal/components/modal-dialog.js +5 -8
- package/dist/cjs/internal/components/modal-wrapper.js +8 -10
- package/dist/cjs/internal/context.js +9 -3
- package/dist/cjs/internal/hooks/use-scroll.js +2 -2
- package/dist/cjs/internal/scroll-context.js +19 -0
- package/dist/es2019/internal/components/modal-dialog.js +5 -8
- package/dist/es2019/internal/components/modal-wrapper.js +5 -7
- package/dist/es2019/internal/context.js +1 -1
- package/dist/es2019/internal/hooks/use-scroll.js +1 -1
- package/dist/es2019/internal/scroll-context.js +14 -0
- package/dist/esm/internal/components/modal-dialog.js +5 -8
- package/dist/esm/internal/components/modal-wrapper.js +6 -8
- package/dist/esm/internal/context.js +1 -1
- package/dist/esm/internal/hooks/use-scroll.js +1 -1
- package/dist/esm/internal/scroll-context.js +14 -0
- package/dist/types/internal/context.d.ts +1 -1
- package/dist/types/internal/scroll-context.d.ts +11 -0
- package/dist/types/types.d.ts +1 -3
- package/dist/types-ts4.5/internal/context.d.ts +1 -1
- package/dist/types-ts4.5/internal/scroll-context.d.ts +11 -0
- package/dist/types-ts4.5/types.d.ts +1 -3
- package/package.json +15 -15
- package/offerings.json +0 -37
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @atlaskit/modal-dialog
|
|
2
2
|
|
|
3
|
+
## 15.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`babe23b40c154`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/babe23b40c154) -
|
|
8
|
+
Removes the `boolean` type for the `autoFocus` prop in the modal dialog. This improves the
|
|
9
|
+
accessibility of the modal dialog by ensuring focus always moves to the first interactive element,
|
|
10
|
+
as per the WCAG accessibility guidelines for modal dialogs.
|
|
11
|
+
|
|
12
|
+
You can run the included codemod to remove all boolean instances of `autoFocus`.
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
18
|
+
## 14.18.3
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- [`5a711f8d38b68`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5a711f8d38b68) -
|
|
23
|
+
Changed the motion uplift feature gate from `platform-dst-motion-uplift` to
|
|
24
|
+
`platform-dst-motion-uplift-modal`
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
|
|
3
27
|
## 14.18.2
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/codemods/{not-yet-boolean-autofocus-removal.tsx → 15.0.0-boolean-autofocus-removal.tsx}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { API, FileInfo, Options } from 'jscodeshift';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { removeBooleanAutoFocus } from './migrations/remove-props';
|
|
4
4
|
import { createTransformer } from './utils/create-transformer';
|
|
5
5
|
|
|
6
6
|
const transformer: (fileInfo: FileInfo, { jscodeshift }: API, options: Options) => string =
|
|
7
|
-
createTransformer('@atlaskit/modal-dialog', [
|
|
7
|
+
createTransformer('@atlaskit/modal-dialog', [removeBooleanAutoFocus]);
|
|
8
8
|
|
|
9
9
|
export default transformer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRemoveFuncIfBooleanFor } from '../utils/create-remove-func-if-boolean-for';
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const removeBooleanAutoFocus: (
|
|
4
4
|
j: import('jscodeshift/src/core').JSCodeshift,
|
|
5
5
|
source: import('jscodeshift/src/Collection').Collection<Node>,
|
|
6
6
|
) => void = createRemoveFuncIfBooleanFor('@atlaskit/modal-dialog', 'ModalDialog', 'autoFocus');
|
|
@@ -28,6 +28,7 @@ var _useOnMotionFinish3 = _interopRequireDefault(require("../hooks/use-on-motion
|
|
|
28
28
|
var _element = require("../pragmatic-drag-and-drop/disable-dragging-to-cross-origin-iframes/element");
|
|
29
29
|
var _external = require("../pragmatic-drag-and-drop/disable-dragging-to-cross-origin-iframes/external");
|
|
30
30
|
var _textSelection = require("../pragmatic-drag-and-drop/disable-dragging-to-cross-origin-iframes/text-selection");
|
|
31
|
+
var _scrollContext = require("../scroll-context");
|
|
31
32
|
var _width = require("../width");
|
|
32
33
|
var _positioner = _interopRequireDefault(require("./positioner"));
|
|
33
34
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -64,7 +65,7 @@ var ModalDialog = function ModalDialog(props) {
|
|
|
64
65
|
_props$shouldScrollIn = props.shouldScrollInViewport,
|
|
65
66
|
shouldScrollInViewport = _props$shouldScrollIn === void 0 ? false : _props$shouldScrollIn,
|
|
66
67
|
shouldCloseOnEscapePress = props.shouldCloseOnEscapePress,
|
|
67
|
-
|
|
68
|
+
autoFocus = props.autoFocus,
|
|
68
69
|
stackIndex = props.stackIndex,
|
|
69
70
|
onClose = props.onClose,
|
|
70
71
|
onCloseComplete = props.onCloseComplete,
|
|
@@ -81,10 +82,6 @@ var ModalDialog = function ModalDialog(props) {
|
|
|
81
82
|
var id = (0, _useId.useId)();
|
|
82
83
|
var titleId = "modal-dialog-title-".concat(id);
|
|
83
84
|
var defaultTestId = testId || 'modal-dialog';
|
|
84
|
-
// https://product-fabric.atlassian.net/browse/DSP-24307
|
|
85
|
-
// If flag and falsy, use true instead.
|
|
86
|
-
// When we remove boolean `autoFocus`, we won't have to worry about this
|
|
87
|
-
var autoFocus = !providedAutoFocus ? true : providedAutoFocus;
|
|
88
85
|
(0, _react.useEffect)(function () {
|
|
89
86
|
// Modal dialogs can appear on top of iframe elements that are on another domain.
|
|
90
87
|
// There is a Chrome bug where drag and drop in an element on top of a cross domain
|
|
@@ -96,7 +93,7 @@ var ModalDialog = function ModalDialog(props) {
|
|
|
96
93
|
|
|
97
94
|
return (0, _combine.combine)((0, _element.disableDraggingToCrossOriginIFramesForElement)(), (0, _textSelection.disableDraggingToCrossOriginIFramesForTextSelection)(), (0, _external.disableDraggingToCrossOriginIFramesForExternal)());
|
|
98
95
|
}, []);
|
|
99
|
-
(0, _useAutoFocus.default)(
|
|
96
|
+
(0, _useAutoFocus.default)(autoFocus,
|
|
100
97
|
// When a user supplies a ref to focus we enable this hook
|
|
101
98
|
(0, _typeof2.default)(autoFocus) === 'object');
|
|
102
99
|
var _useOnMotionFinish = (0, _useOnMotionFinish3.default)({
|
|
@@ -128,9 +125,9 @@ var ModalDialog = function ModalDialog(props) {
|
|
|
128
125
|
isFullScreen: isFullScreen
|
|
129
126
|
}, /*#__PURE__*/React.createElement(_context.ModalContext.Provider, {
|
|
130
127
|
value: modalDialogContext
|
|
131
|
-
}, /*#__PURE__*/React.createElement(
|
|
128
|
+
}, /*#__PURE__*/React.createElement(_scrollContext.ScrollContext.Provider, {
|
|
132
129
|
value: shouldScrollInViewport
|
|
133
|
-
}, !UNSAFE_shouldDisableMotionUplift && (0, _platformFeatureFlags.fg)('platform-dst-motion-uplift') ? /*#__PURE__*/React.createElement(_motion.Motion, {
|
|
130
|
+
}, !UNSAFE_shouldDisableMotionUplift && (0, _platformFeatureFlags.fg)('platform-dst-motion-uplift-modal') ? /*#__PURE__*/React.createElement(_motion.Motion, {
|
|
134
131
|
enteringAnimation: "var(--ds-modal-enter, 250ms cubic-bezier(0.4, 0, 0, 1) ScaleIn95to100)",
|
|
135
132
|
exitingAnimation: "var(--ds-modal-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) ScaleOut100to95)",
|
|
136
133
|
onFinish: onMotionFinish,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
-
var
|
|
5
|
+
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
@@ -12,6 +12,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var React = _react;
|
|
13
13
|
var _runtime = require("@compiled/react/runtime");
|
|
14
14
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
15
16
|
var _reactFocusLock = _interopRequireDefault(require("react-focus-lock"));
|
|
16
17
|
var _reactScrolllock = _interopRequireWildcard(require("react-scrolllock"));
|
|
17
18
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
@@ -27,7 +28,7 @@ var _constants = require("@atlaskit/theme/constants");
|
|
|
27
28
|
var _useModalStack = _interopRequireDefault(require("../hooks/use-modal-stack"));
|
|
28
29
|
var _usePreventProgrammaticScroll = _interopRequireDefault(require("../hooks/use-prevent-programmatic-scroll"));
|
|
29
30
|
var _modalDialog = _interopRequireDefault(require("./modal-dialog"));
|
|
30
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" !=
|
|
31
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
31
32
|
var fillScreenStyles = null;
|
|
32
33
|
var allowlistElements = function allowlistElements(element, callback) {
|
|
33
34
|
// Allow focus to reach elements outside the modal:
|
|
@@ -53,8 +54,7 @@ var allowlistElements = function allowlistElements(element, callback) {
|
|
|
53
54
|
* - [Usage](https://atlassian.design/components/modal-dialog/usage)
|
|
54
55
|
*/
|
|
55
56
|
var InternalModalWrapper = function InternalModalWrapper(props) {
|
|
56
|
-
var
|
|
57
|
-
autoFocus = _props$autoFocus === void 0 ? true : _props$autoFocus,
|
|
57
|
+
var autoFocus = props.autoFocus,
|
|
58
58
|
focusLockAllowlist = props.focusLockAllowlist,
|
|
59
59
|
_props$shouldCloseOnE = props.shouldCloseOnEscapePress,
|
|
60
60
|
shouldCloseOnEscapePress = _props$shouldCloseOnE === void 0 ? true : _props$shouldCloseOnE,
|
|
@@ -85,16 +85,14 @@ var InternalModalWrapper = function InternalModalWrapper(props) {
|
|
|
85
85
|
var stackIndex = stackIndexOverride || calculatedStackIndex;
|
|
86
86
|
var isForeground = stackIndex === 0;
|
|
87
87
|
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
// When we remove boolean `autoFocus`, we won't have to worry about this
|
|
91
|
-
var autoFocusLock = typeof autoFocus === 'boolean';
|
|
88
|
+
// If no ref is provided, autofocus on first element
|
|
89
|
+
var autoFocusLock = !((0, _typeof2.default)(autoFocus) === 'object');
|
|
92
90
|
var onCloseHandler = (0, _analyticsNext.usePlatformLeafEventHandler)({
|
|
93
91
|
fn: providedOnClose || _noop.default,
|
|
94
92
|
action: 'closed',
|
|
95
93
|
componentName: 'modalDialog',
|
|
96
94
|
packageName: "@atlaskit/modal-dialog",
|
|
97
|
-
packageVersion: "14.18.
|
|
95
|
+
packageVersion: "14.18.3"
|
|
98
96
|
});
|
|
99
97
|
var onBlanketClicked = (0, _react.useCallback)(function (e) {
|
|
100
98
|
if (shouldCloseOnOverlayClick) {
|
|
@@ -152,7 +150,7 @@ var InternalModalWrapper = function InternalModalWrapper(props) {
|
|
|
152
150
|
isDisabled: false
|
|
153
151
|
}, /*#__PURE__*/React.createElement(_portal.default, {
|
|
154
152
|
zIndex: _constants.layers.modal()
|
|
155
|
-
}, !UNSAFE_shouldDisableMotionUplift && (0, _platformFeatureFlags.fg)('platform-dst-motion-uplift') ? /*#__PURE__*/React.createElement(_motion.Motion, {
|
|
153
|
+
}, !UNSAFE_shouldDisableMotionUplift && (0, _platformFeatureFlags.fg)('platform-dst-motion-uplift-modal') ? /*#__PURE__*/React.createElement(_motion.Motion, {
|
|
156
154
|
enteringAnimation: "var(--ds-blanket-enter, 250ms cubic-bezier(0.4, 0, 0, 1) FadeIn0to100)",
|
|
157
155
|
exitingAnimation: "var(--ds-blanket-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
158
156
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -3,8 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.ModalContext = void 0;
|
|
7
|
+
Object.defineProperty(exports, "ScrollContext", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _scrollContext.ScrollContext;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
7
13
|
var _react = require("react");
|
|
14
|
+
var _scrollContext = require("./scroll-context");
|
|
8
15
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
9
|
-
var ModalContext = exports.ModalContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
10
|
-
var ScrollContext = exports.ScrollContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
16
|
+
var ModalContext = exports.ModalContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = useScroll;
|
|
7
7
|
var _react = require("react");
|
|
8
|
-
var
|
|
8
|
+
var _scrollContext = require("../scroll-context");
|
|
9
9
|
/**
|
|
10
10
|
* This returns whether or not scrolling is allowed based on the existing
|
|
11
11
|
* scrolling context.
|
|
12
12
|
*/
|
|
13
13
|
function useScroll() {
|
|
14
|
-
var shouldScrollInViewport = (0, _react.useContext)(
|
|
14
|
+
var shouldScrollInViewport = (0, _react.useContext)(_scrollContext.ScrollContext);
|
|
15
15
|
if (shouldScrollInViewport == null) {
|
|
16
16
|
throw Error('@atlaskit/modal-dialog: Scroll context unavailable – this component needs to be a child of ModalDialog.');
|
|
17
17
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ScrollContext = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
// TODO: Fill in the component {description} and ensure links point to the correct {packageName} location.
|
|
9
|
+
// Remove links that the component does not have (such as usage). If there are no links remove them all.
|
|
10
|
+
/**
|
|
11
|
+
* __Scroll context__
|
|
12
|
+
*
|
|
13
|
+
* A scroll context {description}.
|
|
14
|
+
*
|
|
15
|
+
* - [Examples](https://atlassian.design/components/{packageName}/examples)
|
|
16
|
+
* - [Code](https://atlassian.design/components/{packageName}/code)
|
|
17
|
+
* - [Usage](https://atlassian.design/components/{packageName}/usage)
|
|
18
|
+
*/
|
|
19
|
+
var ScrollContext = exports.ScrollContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
@@ -13,11 +13,12 @@ import { Motion } from '@atlaskit/motion';
|
|
|
13
13
|
import FadeIn from '@atlaskit/motion/fade-in';
|
|
14
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
15
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
16
|
-
import { ModalContext
|
|
16
|
+
import { ModalContext } from '../context';
|
|
17
17
|
import useOnMotionFinish from '../hooks/use-on-motion-finish';
|
|
18
18
|
import { disableDraggingToCrossOriginIFramesForElement } from '../pragmatic-drag-and-drop/disable-dragging-to-cross-origin-iframes/element';
|
|
19
19
|
import { disableDraggingToCrossOriginIFramesForExternal } from '../pragmatic-drag-and-drop/disable-dragging-to-cross-origin-iframes/external';
|
|
20
20
|
import { disableDraggingToCrossOriginIFramesForTextSelection } from '../pragmatic-drag-and-drop/disable-dragging-to-cross-origin-iframes/text-selection';
|
|
21
|
+
import { ScrollContext } from '../scroll-context';
|
|
21
22
|
import { width } from '../width';
|
|
22
23
|
import Positioner from './positioner';
|
|
23
24
|
const dialogWidth = input => {
|
|
@@ -52,7 +53,7 @@ const ModalDialog = props => {
|
|
|
52
53
|
width = 'medium',
|
|
53
54
|
shouldScrollInViewport = false,
|
|
54
55
|
shouldCloseOnEscapePress,
|
|
55
|
-
autoFocus
|
|
56
|
+
autoFocus,
|
|
56
57
|
stackIndex,
|
|
57
58
|
onClose,
|
|
58
59
|
onCloseComplete,
|
|
@@ -68,10 +69,6 @@ const ModalDialog = props => {
|
|
|
68
69
|
const id = useId();
|
|
69
70
|
const titleId = `modal-dialog-title-${id}`;
|
|
70
71
|
const defaultTestId = testId || 'modal-dialog';
|
|
71
|
-
// https://product-fabric.atlassian.net/browse/DSP-24307
|
|
72
|
-
// If flag and falsy, use true instead.
|
|
73
|
-
// When we remove boolean `autoFocus`, we won't have to worry about this
|
|
74
|
-
const autoFocus = !providedAutoFocus ? true : providedAutoFocus;
|
|
75
72
|
useEffect(() => {
|
|
76
73
|
// Modal dialogs can appear on top of iframe elements that are on another domain.
|
|
77
74
|
// There is a Chrome bug where drag and drop in an element on top of a cross domain
|
|
@@ -83,7 +80,7 @@ const ModalDialog = props => {
|
|
|
83
80
|
|
|
84
81
|
return combine(disableDraggingToCrossOriginIFramesForElement(), disableDraggingToCrossOriginIFramesForTextSelection(), disableDraggingToCrossOriginIFramesForExternal());
|
|
85
82
|
}, []);
|
|
86
|
-
useAutoFocus(
|
|
83
|
+
useAutoFocus(autoFocus,
|
|
87
84
|
// When a user supplies a ref to focus we enable this hook
|
|
88
85
|
typeof autoFocus === 'object');
|
|
89
86
|
const [motionRef, onMotionFinish] = useOnMotionFinish({
|
|
@@ -113,7 +110,7 @@ const ModalDialog = props => {
|
|
|
113
110
|
value: modalDialogContext
|
|
114
111
|
}, /*#__PURE__*/React.createElement(ScrollContext.Provider, {
|
|
115
112
|
value: shouldScrollInViewport
|
|
116
|
-
}, !UNSAFE_shouldDisableMotionUplift && fg('platform-dst-motion-uplift') ? /*#__PURE__*/React.createElement(Motion, {
|
|
113
|
+
}, !UNSAFE_shouldDisableMotionUplift && fg('platform-dst-motion-uplift-modal') ? /*#__PURE__*/React.createElement(Motion, {
|
|
117
114
|
enteringAnimation: "var(--ds-modal-enter, 250ms cubic-bezier(0.4, 0, 0, 1) ScaleIn95to100)",
|
|
118
115
|
exitingAnimation: "var(--ds-modal-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) ScaleOut100to95)",
|
|
119
116
|
onFinish: onMotionFinish,
|
|
@@ -45,7 +45,7 @@ const allowlistElements = (element, callback) => {
|
|
|
45
45
|
*/
|
|
46
46
|
const InternalModalWrapper = props => {
|
|
47
47
|
const {
|
|
48
|
-
autoFocus
|
|
48
|
+
autoFocus,
|
|
49
49
|
focusLockAllowlist,
|
|
50
50
|
shouldCloseOnEscapePress = true,
|
|
51
51
|
shouldCloseOnOverlayClick = true,
|
|
@@ -71,16 +71,14 @@ const InternalModalWrapper = props => {
|
|
|
71
71
|
const stackIndex = stackIndexOverride || calculatedStackIndex;
|
|
72
72
|
const isForeground = stackIndex === 0;
|
|
73
73
|
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
// When we remove boolean `autoFocus`, we won't have to worry about this
|
|
77
|
-
const autoFocusLock = typeof autoFocus === 'boolean';
|
|
74
|
+
// If no ref is provided, autofocus on first element
|
|
75
|
+
const autoFocusLock = !(typeof autoFocus === 'object');
|
|
78
76
|
const onCloseHandler = usePlatformLeafEventHandler({
|
|
79
77
|
fn: providedOnClose || noop,
|
|
80
78
|
action: 'closed',
|
|
81
79
|
componentName: 'modalDialog',
|
|
82
80
|
packageName: "@atlaskit/modal-dialog",
|
|
83
|
-
packageVersion: "14.18.
|
|
81
|
+
packageVersion: "14.18.3"
|
|
84
82
|
});
|
|
85
83
|
const onBlanketClicked = useCallback(e => {
|
|
86
84
|
if (shouldCloseOnOverlayClick) {
|
|
@@ -136,7 +134,7 @@ const InternalModalWrapper = props => {
|
|
|
136
134
|
isDisabled: false
|
|
137
135
|
}, /*#__PURE__*/React.createElement(Portal, {
|
|
138
136
|
zIndex: layers.modal()
|
|
139
|
-
}, !UNSAFE_shouldDisableMotionUplift && fg('platform-dst-motion-uplift') ? /*#__PURE__*/React.createElement(Motion, {
|
|
137
|
+
}, !UNSAFE_shouldDisableMotionUplift && fg('platform-dst-motion-uplift-modal') ? /*#__PURE__*/React.createElement(Motion, {
|
|
140
138
|
enteringAnimation: "var(--ds-blanket-enter, 250ms cubic-bezier(0.4, 0, 0, 1) FadeIn0to100)",
|
|
141
139
|
exitingAnimation: "var(--ds-blanket-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
142
140
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
3
3
|
export const ModalContext = /*#__PURE__*/createContext(null);
|
|
4
|
-
export
|
|
4
|
+
export { ScrollContext } from './scroll-context';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
// TODO: Fill in the component {description} and ensure links point to the correct {packageName} location.
|
|
4
|
+
// Remove links that the component does not have (such as usage). If there are no links remove them all.
|
|
5
|
+
/**
|
|
6
|
+
* __Scroll context__
|
|
7
|
+
*
|
|
8
|
+
* A scroll context {description}.
|
|
9
|
+
*
|
|
10
|
+
* - [Examples](https://atlassian.design/components/{packageName}/examples)
|
|
11
|
+
* - [Code](https://atlassian.design/components/{packageName}/code)
|
|
12
|
+
* - [Usage](https://atlassian.design/components/{packageName}/usage)
|
|
13
|
+
*/
|
|
14
|
+
export const ScrollContext = /*#__PURE__*/createContext(null);
|
|
@@ -15,11 +15,12 @@ import { Motion } from '@atlaskit/motion';
|
|
|
15
15
|
import FadeIn from '@atlaskit/motion/fade-in';
|
|
16
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
17
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
18
|
-
import { ModalContext
|
|
18
|
+
import { ModalContext } from '../context';
|
|
19
19
|
import useOnMotionFinish from '../hooks/use-on-motion-finish';
|
|
20
20
|
import { disableDraggingToCrossOriginIFramesForElement } from '../pragmatic-drag-and-drop/disable-dragging-to-cross-origin-iframes/element';
|
|
21
21
|
import { disableDraggingToCrossOriginIFramesForExternal } from '../pragmatic-drag-and-drop/disable-dragging-to-cross-origin-iframes/external';
|
|
22
22
|
import { disableDraggingToCrossOriginIFramesForTextSelection } from '../pragmatic-drag-and-drop/disable-dragging-to-cross-origin-iframes/text-selection';
|
|
23
|
+
import { ScrollContext } from '../scroll-context';
|
|
23
24
|
import { width } from '../width';
|
|
24
25
|
import Positioner from './positioner';
|
|
25
26
|
var dialogWidth = function dialogWidth(input) {
|
|
@@ -55,7 +56,7 @@ var ModalDialog = function ModalDialog(props) {
|
|
|
55
56
|
_props$shouldScrollIn = props.shouldScrollInViewport,
|
|
56
57
|
shouldScrollInViewport = _props$shouldScrollIn === void 0 ? false : _props$shouldScrollIn,
|
|
57
58
|
shouldCloseOnEscapePress = props.shouldCloseOnEscapePress,
|
|
58
|
-
|
|
59
|
+
autoFocus = props.autoFocus,
|
|
59
60
|
stackIndex = props.stackIndex,
|
|
60
61
|
onClose = props.onClose,
|
|
61
62
|
onCloseComplete = props.onCloseComplete,
|
|
@@ -72,10 +73,6 @@ var ModalDialog = function ModalDialog(props) {
|
|
|
72
73
|
var id = useId();
|
|
73
74
|
var titleId = "modal-dialog-title-".concat(id);
|
|
74
75
|
var defaultTestId = testId || 'modal-dialog';
|
|
75
|
-
// https://product-fabric.atlassian.net/browse/DSP-24307
|
|
76
|
-
// If flag and falsy, use true instead.
|
|
77
|
-
// When we remove boolean `autoFocus`, we won't have to worry about this
|
|
78
|
-
var autoFocus = !providedAutoFocus ? true : providedAutoFocus;
|
|
79
76
|
useEffect(function () {
|
|
80
77
|
// Modal dialogs can appear on top of iframe elements that are on another domain.
|
|
81
78
|
// There is a Chrome bug where drag and drop in an element on top of a cross domain
|
|
@@ -87,7 +84,7 @@ var ModalDialog = function ModalDialog(props) {
|
|
|
87
84
|
|
|
88
85
|
return combine(disableDraggingToCrossOriginIFramesForElement(), disableDraggingToCrossOriginIFramesForTextSelection(), disableDraggingToCrossOriginIFramesForExternal());
|
|
89
86
|
}, []);
|
|
90
|
-
useAutoFocus(
|
|
87
|
+
useAutoFocus(autoFocus,
|
|
91
88
|
// When a user supplies a ref to focus we enable this hook
|
|
92
89
|
_typeof(autoFocus) === 'object');
|
|
93
90
|
var _useOnMotionFinish = useOnMotionFinish({
|
|
@@ -121,7 +118,7 @@ var ModalDialog = function ModalDialog(props) {
|
|
|
121
118
|
value: modalDialogContext
|
|
122
119
|
}, /*#__PURE__*/React.createElement(ScrollContext.Provider, {
|
|
123
120
|
value: shouldScrollInViewport
|
|
124
|
-
}, !UNSAFE_shouldDisableMotionUplift && fg('platform-dst-motion-uplift') ? /*#__PURE__*/React.createElement(Motion, {
|
|
121
|
+
}, !UNSAFE_shouldDisableMotionUplift && fg('platform-dst-motion-uplift-modal') ? /*#__PURE__*/React.createElement(Motion, {
|
|
125
122
|
enteringAnimation: "var(--ds-modal-enter, 250ms cubic-bezier(0.4, 0, 0, 1) ScaleIn95to100)",
|
|
126
123
|
exitingAnimation: "var(--ds-modal-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) ScaleOut100to95)",
|
|
127
124
|
onFinish: onMotionFinish,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* modal-wrapper.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
3
4
|
import "./modal-wrapper.compiled.css";
|
|
4
5
|
import * as React from 'react';
|
|
5
6
|
import { ax, ix } from "@compiled/react/runtime";
|
|
@@ -44,8 +45,7 @@ var allowlistElements = function allowlistElements(element, callback) {
|
|
|
44
45
|
* - [Usage](https://atlassian.design/components/modal-dialog/usage)
|
|
45
46
|
*/
|
|
46
47
|
var InternalModalWrapper = function InternalModalWrapper(props) {
|
|
47
|
-
var
|
|
48
|
-
autoFocus = _props$autoFocus === void 0 ? true : _props$autoFocus,
|
|
48
|
+
var autoFocus = props.autoFocus,
|
|
49
49
|
focusLockAllowlist = props.focusLockAllowlist,
|
|
50
50
|
_props$shouldCloseOnE = props.shouldCloseOnEscapePress,
|
|
51
51
|
shouldCloseOnEscapePress = _props$shouldCloseOnE === void 0 ? true : _props$shouldCloseOnE,
|
|
@@ -76,16 +76,14 @@ var InternalModalWrapper = function InternalModalWrapper(props) {
|
|
|
76
76
|
var stackIndex = stackIndexOverride || calculatedStackIndex;
|
|
77
77
|
var isForeground = stackIndex === 0;
|
|
78
78
|
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
// When we remove boolean `autoFocus`, we won't have to worry about this
|
|
82
|
-
var autoFocusLock = typeof autoFocus === 'boolean';
|
|
79
|
+
// If no ref is provided, autofocus on first element
|
|
80
|
+
var autoFocusLock = !(_typeof(autoFocus) === 'object');
|
|
83
81
|
var onCloseHandler = usePlatformLeafEventHandler({
|
|
84
82
|
fn: providedOnClose || noop,
|
|
85
83
|
action: 'closed',
|
|
86
84
|
componentName: 'modalDialog',
|
|
87
85
|
packageName: "@atlaskit/modal-dialog",
|
|
88
|
-
packageVersion: "14.18.
|
|
86
|
+
packageVersion: "14.18.3"
|
|
89
87
|
});
|
|
90
88
|
var onBlanketClicked = useCallback(function (e) {
|
|
91
89
|
if (shouldCloseOnOverlayClick) {
|
|
@@ -143,7 +141,7 @@ var InternalModalWrapper = function InternalModalWrapper(props) {
|
|
|
143
141
|
isDisabled: false
|
|
144
142
|
}, /*#__PURE__*/React.createElement(Portal, {
|
|
145
143
|
zIndex: layers.modal()
|
|
146
|
-
}, !UNSAFE_shouldDisableMotionUplift && fg('platform-dst-motion-uplift') ? /*#__PURE__*/React.createElement(Motion, {
|
|
144
|
+
}, !UNSAFE_shouldDisableMotionUplift && fg('platform-dst-motion-uplift-modal') ? /*#__PURE__*/React.createElement(Motion, {
|
|
147
145
|
enteringAnimation: "var(--ds-blanket-enter, 250ms cubic-bezier(0.4, 0, 0, 1) FadeIn0to100)",
|
|
148
146
|
exitingAnimation: "var(--ds-blanket-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
149
147
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
3
3
|
export var ModalContext = /*#__PURE__*/createContext(null);
|
|
4
|
-
export
|
|
4
|
+
export { ScrollContext } from './scroll-context';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
// TODO: Fill in the component {description} and ensure links point to the correct {packageName} location.
|
|
4
|
+
// Remove links that the component does not have (such as usage). If there are no links remove them all.
|
|
5
|
+
/**
|
|
6
|
+
* __Scroll context__
|
|
7
|
+
*
|
|
8
|
+
* A scroll context {description}.
|
|
9
|
+
*
|
|
10
|
+
* - [Examples](https://atlassian.design/components/{packageName}/examples)
|
|
11
|
+
* - [Code](https://atlassian.design/components/{packageName}/code)
|
|
12
|
+
* - [Usage](https://atlassian.design/components/{packageName}/usage)
|
|
13
|
+
*/
|
|
14
|
+
export var ScrollContext = /*#__PURE__*/createContext(null);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Context } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* __Scroll context__
|
|
4
|
+
*
|
|
5
|
+
* A scroll context {description}.
|
|
6
|
+
*
|
|
7
|
+
* - [Examples](https://atlassian.design/components/{packageName}/examples)
|
|
8
|
+
* - [Code](https://atlassian.design/components/{packageName}/code)
|
|
9
|
+
* - [Usage](https://atlassian.design/components/{packageName}/usage)
|
|
10
|
+
*/
|
|
11
|
+
export declare const ScrollContext: Context<boolean | null>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -19,10 +19,8 @@ export interface ModalDialogProps {
|
|
|
19
19
|
* accessibility regressions. Pass an element `ref` to focus on a specific element.
|
|
20
20
|
*
|
|
21
21
|
* Default value is `true`.
|
|
22
|
-
*
|
|
23
|
-
* @deprecated {@link https://hello.jira.atlassian.cloud/browse/ENGHEALTH-28588 Learn more about why `false` should not be used and will be removed.}
|
|
24
22
|
*/
|
|
25
|
-
autoFocus?:
|
|
23
|
+
autoFocus?: RefObject<HTMLElement | null | undefined>;
|
|
26
24
|
/**
|
|
27
25
|
* Contents of the modal dialog.
|
|
28
26
|
*/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Context } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* __Scroll context__
|
|
4
|
+
*
|
|
5
|
+
* A scroll context {description}.
|
|
6
|
+
*
|
|
7
|
+
* - [Examples](https://atlassian.design/components/{packageName}/examples)
|
|
8
|
+
* - [Code](https://atlassian.design/components/{packageName}/code)
|
|
9
|
+
* - [Usage](https://atlassian.design/components/{packageName}/usage)
|
|
10
|
+
*/
|
|
11
|
+
export declare const ScrollContext: Context<boolean | null>;
|
|
@@ -19,10 +19,8 @@ export interface ModalDialogProps {
|
|
|
19
19
|
* accessibility regressions. Pass an element `ref` to focus on a specific element.
|
|
20
20
|
*
|
|
21
21
|
* Default value is `true`.
|
|
22
|
-
*
|
|
23
|
-
* @deprecated {@link https://hello.jira.atlassian.cloud/browse/ENGHEALTH-28588 Learn more about why `false` should not be used and will be removed.}
|
|
24
22
|
*/
|
|
25
|
-
autoFocus?:
|
|
23
|
+
autoFocus?: RefObject<HTMLElement | null | undefined>;
|
|
26
24
|
/**
|
|
27
25
|
* Contents of the modal dialog.
|
|
28
26
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/modal-dialog",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0",
|
|
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/"
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"@atlaskit/button": "^23.11.0",
|
|
40
40
|
"@atlaskit/css": "^0.19.0",
|
|
41
41
|
"@atlaskit/ds-lib": "^7.0.0",
|
|
42
|
-
"@atlaskit/icon": "^34.
|
|
42
|
+
"@atlaskit/icon": "^34.4.0",
|
|
43
43
|
"@atlaskit/layering": "^3.7.0",
|
|
44
|
-
"@atlaskit/motion": "^6.
|
|
44
|
+
"@atlaskit/motion": "^6.2.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
46
|
-
"@atlaskit/portal": "^5.
|
|
46
|
+
"@atlaskit/portal": "^5.5.0",
|
|
47
47
|
"@atlaskit/pragmatic-drag-and-drop": "^1.8.0",
|
|
48
48
|
"@atlaskit/primitives": "^19.0.0",
|
|
49
|
-
"@atlaskit/theme": "^23.
|
|
49
|
+
"@atlaskit/theme": "^23.2.0",
|
|
50
50
|
"@atlaskit/tokens": "^13.0.0",
|
|
51
51
|
"@babel/runtime": "^7.0.0",
|
|
52
52
|
"@compiled/react": "^0.20.0",
|
|
@@ -62,26 +62,26 @@
|
|
|
62
62
|
"@af/accessibility-testing": "workspace:^",
|
|
63
63
|
"@af/integration-testing": "workspace:^",
|
|
64
64
|
"@af/visual-regression": "workspace:^",
|
|
65
|
-
"@atlaskit/avatar": "^25.
|
|
65
|
+
"@atlaskit/avatar": "^25.14.0",
|
|
66
66
|
"@atlaskit/avatar-group": "^12.7.0",
|
|
67
|
-
"@atlaskit/banner": "^14.
|
|
67
|
+
"@atlaskit/banner": "^14.1.0",
|
|
68
68
|
"@atlaskit/breadcrumbs": "^16.1.0",
|
|
69
69
|
"@atlaskit/checkbox": "^17.3.0",
|
|
70
|
-
"@atlaskit/code": "^17.
|
|
71
|
-
"@atlaskit/datetime-picker": "^17.
|
|
70
|
+
"@atlaskit/code": "^17.5.0",
|
|
71
|
+
"@atlaskit/datetime-picker": "^17.8.0",
|
|
72
72
|
"@atlaskit/docs": "^11.8.0",
|
|
73
73
|
"@atlaskit/dropdown-menu": "^16.8.0",
|
|
74
|
-
"@atlaskit/flag": "^17.
|
|
74
|
+
"@atlaskit/flag": "^17.11.0",
|
|
75
75
|
"@atlaskit/form": "^15.5.0",
|
|
76
76
|
"@atlaskit/heading": "^5.4.0",
|
|
77
77
|
"@atlaskit/link": "^3.4.0",
|
|
78
|
-
"@atlaskit/popup": "^4.
|
|
79
|
-
"@atlaskit/radio": "^8.
|
|
78
|
+
"@atlaskit/popup": "^4.17.0",
|
|
79
|
+
"@atlaskit/radio": "^8.6.0",
|
|
80
80
|
"@atlaskit/section-message": "^8.12.0",
|
|
81
81
|
"@atlaskit/select": "^21.10.0",
|
|
82
|
-
"@atlaskit/spotlight": "^0.
|
|
82
|
+
"@atlaskit/spotlight": "^0.14.0",
|
|
83
83
|
"@atlaskit/textfield": "^8.3.0",
|
|
84
|
-
"@atlaskit/tooltip": "^
|
|
84
|
+
"@atlaskit/tooltip": "^22.0.0",
|
|
85
85
|
"@atlassian/feature-flags-test-utils": "^1.0.0",
|
|
86
86
|
"@atlassian/react-compiler-gating": "workspace:^",
|
|
87
87
|
"@atlassian/ssr-tests": "workspace:^",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"platform-dst-shape-theme-default": {
|
|
139
139
|
"type": "boolean"
|
|
140
140
|
},
|
|
141
|
-
"platform-dst-motion-uplift": {
|
|
141
|
+
"platform-dst-motion-uplift-modal": {
|
|
142
142
|
"type": "boolean"
|
|
143
143
|
}
|
|
144
144
|
},
|
package/offerings.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"name": "Modal",
|
|
4
|
-
"package": "@atlaskit/modal-dialog",
|
|
5
|
-
"import": {
|
|
6
|
-
"name": "Modal",
|
|
7
|
-
"package": "@atlaskit/modal-dialog",
|
|
8
|
-
"type": "default"
|
|
9
|
-
},
|
|
10
|
-
"keywords": ["modal", "dialog", "popup", "overlay", "focused", "interaction", "layer"],
|
|
11
|
-
"categories": ["overlay"],
|
|
12
|
-
"shortDescription": "A modal dialog component for important content.",
|
|
13
|
-
"status": "general-availability",
|
|
14
|
-
"accessibilityGuidelines": [
|
|
15
|
-
"Ensure modal content is announced by screen readers",
|
|
16
|
-
"Provide appropriate focus management",
|
|
17
|
-
"Use clear, descriptive modal titles",
|
|
18
|
-
"Ensure keyboard navigation and escape key support",
|
|
19
|
-
"Maintain focus within modal when open"
|
|
20
|
-
],
|
|
21
|
-
"usageGuidelines": [
|
|
22
|
-
"Use for important content that requires user attention",
|
|
23
|
-
"Keep modal content focused on a single task",
|
|
24
|
-
"Provide clear action buttons",
|
|
25
|
-
"Use appropriate modal sizes for content",
|
|
26
|
-
"Consider mobile responsiveness"
|
|
27
|
-
],
|
|
28
|
-
"contentGuidelines": [
|
|
29
|
-
"Use clear, descriptive titles",
|
|
30
|
-
"Keep content focused on a single task or message",
|
|
31
|
-
"Include clear action buttons",
|
|
32
|
-
"Use sentence case for all text",
|
|
33
|
-
"Provide clear next steps"
|
|
34
|
-
],
|
|
35
|
-
"examples": ["./examples/constellation/modal-default.tsx"]
|
|
36
|
-
}
|
|
37
|
-
]
|