@atlaskit/drawer 7.14.2 → 7.14.3
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 +8 -0
- package/dist/cjs/components/index.js +99 -139
- package/dist/cjs/components/primitives/focus-lock.js +43 -72
- package/dist/es2019/components/index.js +93 -118
- package/dist/es2019/components/primitives/focus-lock.js +37 -52
- package/dist/esm/components/index.js +97 -140
- package/dist/esm/components/primitives/focus-lock.js +44 -74
- package/dist/types/components/index.d.ts +18 -30
- package/dist/types/components/primitives/focus-lock.d.ts +9 -12
- package/dist/types/components/types.d.ts +1 -1
- package/dist/types-ts4.5/components/index.d.ts +18 -30
- package/dist/types-ts4.5/components/primitives/focus-lock.d.ts +9 -12
- package/dist/types-ts4.5/components/types.d.ts +1 -1
- package/package.json +5 -9
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
1
|
/* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
|
|
3
|
-
import React, {
|
|
2
|
+
import React, { useCallback, useEffect } from 'react';
|
|
4
3
|
import { canUseDOM } from 'exenv';
|
|
5
4
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
6
5
|
import { UNSAFE_LAYERING, useCloseOnEscapePress } from '@atlaskit/layering';
|
|
7
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import Portal from '@atlaskit/portal';
|
|
9
|
-
import { defaultFocusLockSettings } from '../constants';
|
|
10
8
|
import Blanket from './blanket';
|
|
11
9
|
import DrawerPrimitive from './primitives';
|
|
12
10
|
const packageName = "@atlaskit/drawer";
|
|
13
|
-
const packageVersion = "7.14.
|
|
11
|
+
const packageVersion = "7.14.3";
|
|
14
12
|
const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
15
13
|
const createAndFireOnClick = (createAnalyticsEvent, trigger) => createAndFireEventOnAtlaskit({
|
|
16
14
|
action: 'dismissed',
|
|
@@ -40,127 +38,108 @@ const EscapeCloseManager = ({
|
|
|
40
38
|
// only create a dummy component for using ths hook in class component
|
|
41
39
|
return /*#__PURE__*/React.createElement("span", null);
|
|
42
40
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* __Drawer base__
|
|
44
|
+
*
|
|
45
|
+
* A drawer is a panel that slides in from the left side of the screen.
|
|
46
|
+
*
|
|
47
|
+
* - [Examples](https://atlassian.design/components/drawer/examples)
|
|
48
|
+
* - [Code](https://atlassian.design/components/drawer/code)
|
|
49
|
+
* - [Usage](https://atlassian.design/components/drawer/usage)
|
|
50
|
+
*/
|
|
51
|
+
export const DrawerBase = ({
|
|
52
|
+
width = 'narrow',
|
|
53
|
+
isOpen,
|
|
54
|
+
isFocusLockEnabled = true,
|
|
55
|
+
shouldReturnFocus = true,
|
|
56
|
+
autoFocusFirstElem = true,
|
|
57
|
+
onKeyDown,
|
|
58
|
+
createAnalyticsEvent,
|
|
59
|
+
onClose,
|
|
60
|
+
testId,
|
|
61
|
+
children,
|
|
62
|
+
icon,
|
|
63
|
+
closeLabel,
|
|
64
|
+
scrollContentLabel,
|
|
65
|
+
shouldUnmountOnExit,
|
|
66
|
+
onCloseComplete,
|
|
67
|
+
onOpenComplete,
|
|
68
|
+
// eslint-disable-next-line @repo/internal/react/consistent-props-definitions
|
|
69
|
+
overrides,
|
|
70
|
+
zIndex = 'unset',
|
|
71
|
+
label,
|
|
72
|
+
titleId,
|
|
73
|
+
enterFrom
|
|
74
|
+
}) => {
|
|
75
|
+
const body = canUseDOM ? document.querySelector('body') : undefined;
|
|
76
|
+
const handleClose = useCallback((event, trigger) => {
|
|
77
|
+
const analyticsEvent = createAnalyticsEvent && createAndFireOnClick(createAnalyticsEvent, trigger);
|
|
78
|
+
if (onClose) {
|
|
79
|
+
onClose(event, analyticsEvent);
|
|
80
|
+
}
|
|
81
|
+
}, [createAnalyticsEvent, onClose]);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
const handleKeyDown = event => {
|
|
71
84
|
if (!fg('platform.design-system-team.inline-message-layering_wfp1p')) {
|
|
72
85
|
// when feature flag on, we will use the EscapeCloseManager instead
|
|
73
86
|
if (event.key === 'Escape' && isOpen) {
|
|
74
|
-
|
|
87
|
+
handleClose(event, 'escKey');
|
|
75
88
|
}
|
|
76
89
|
}
|
|
77
90
|
if (onKeyDown) {
|
|
78
91
|
onKeyDown(event);
|
|
79
92
|
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
componentDidMount() {
|
|
83
|
-
const {
|
|
84
|
-
isOpen
|
|
85
|
-
} = this.props;
|
|
93
|
+
};
|
|
86
94
|
if (isOpen) {
|
|
87
|
-
window.addEventListener('keydown',
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
componentWillUnmount() {
|
|
91
|
-
window.removeEventListener('keydown', this.handleKeyDown);
|
|
92
|
-
}
|
|
93
|
-
componentDidUpdate(prevProps) {
|
|
94
|
-
const {
|
|
95
|
-
isOpen
|
|
96
|
-
} = this.props;
|
|
97
|
-
if (isOpen !== prevProps.isOpen) {
|
|
98
|
-
if (isOpen) {
|
|
99
|
-
window.addEventListener('keydown', this.handleKeyDown);
|
|
100
|
-
} else {
|
|
101
|
-
window.removeEventListener('keydown', this.handleKeyDown);
|
|
102
|
-
}
|
|
95
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
103
96
|
}
|
|
97
|
+
return () => {
|
|
98
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
99
|
+
};
|
|
100
|
+
}, [handleClose, isOpen, onKeyDown]);
|
|
101
|
+
const handleBlanketClick = event => {
|
|
102
|
+
handleClose(event, 'blanket');
|
|
103
|
+
};
|
|
104
|
+
const handleBackButtonClick = event => {
|
|
105
|
+
handleClose(event, 'backButton');
|
|
106
|
+
};
|
|
107
|
+
if (!body) {
|
|
108
|
+
return null;
|
|
104
109
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
icon: icon,
|
|
139
|
-
closeLabel: closeLabel,
|
|
140
|
-
in: isOpen,
|
|
141
|
-
onClose: this.handleBackButtonClick,
|
|
142
|
-
onCloseComplete: onCloseComplete,
|
|
143
|
-
onOpenComplete: onOpenComplete,
|
|
144
|
-
width: width,
|
|
145
|
-
enterFrom: enterFrom,
|
|
146
|
-
label: label,
|
|
147
|
-
titleId: titleId,
|
|
148
|
-
shouldUnmountOnExit: shouldUnmountOnExit
|
|
149
|
-
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
150
|
-
,
|
|
151
|
-
overrides: overrides,
|
|
152
|
-
autoFocusFirstElem: autoFocusFirstElem,
|
|
153
|
-
isFocusLockEnabled: isFocusLockEnabled,
|
|
154
|
-
shouldReturnFocus: shouldReturnFocus,
|
|
155
|
-
scrollContentLabel: scrollContentLabel
|
|
156
|
-
}, shouldHaveLayeringEnabled ? /*#__PURE__*/React.createElement(UNSAFE_LAYERING, {
|
|
157
|
-
isDisabled: false
|
|
158
|
-
}, children, /*#__PURE__*/React.createElement(EscapeCloseManager, {
|
|
159
|
-
createAnalyticsEvent: this.props.createAnalyticsEvent,
|
|
160
|
-
handleClose: this.handleClose
|
|
161
|
-
})) : children));
|
|
162
|
-
}
|
|
163
|
-
}
|
|
110
|
+
return /*#__PURE__*/React.createElement(Portal, {
|
|
111
|
+
zIndex: zIndex
|
|
112
|
+
}, /*#__PURE__*/React.createElement(Blanket, {
|
|
113
|
+
isOpen: isOpen,
|
|
114
|
+
onBlanketClicked: handleBlanketClick,
|
|
115
|
+
testId: testId && `${testId}--blanket`
|
|
116
|
+
}), /*#__PURE__*/React.createElement(DrawerPrimitive, {
|
|
117
|
+
testId: testId,
|
|
118
|
+
icon: icon,
|
|
119
|
+
closeLabel: closeLabel,
|
|
120
|
+
in: isOpen,
|
|
121
|
+
onClose: handleBackButtonClick,
|
|
122
|
+
onCloseComplete: onCloseComplete,
|
|
123
|
+
onOpenComplete: onOpenComplete,
|
|
124
|
+
width: width,
|
|
125
|
+
enterFrom: enterFrom,
|
|
126
|
+
label: label,
|
|
127
|
+
titleId: titleId,
|
|
128
|
+
shouldUnmountOnExit: shouldUnmountOnExit
|
|
129
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
130
|
+
,
|
|
131
|
+
overrides: overrides,
|
|
132
|
+
autoFocusFirstElem: autoFocusFirstElem,
|
|
133
|
+
isFocusLockEnabled: isFocusLockEnabled,
|
|
134
|
+
shouldReturnFocus: shouldReturnFocus,
|
|
135
|
+
scrollContentLabel: scrollContentLabel
|
|
136
|
+
}, isOpen && fg('platform.design-system-team.inline-message-layering_wfp1p') ? /*#__PURE__*/React.createElement(UNSAFE_LAYERING, {
|
|
137
|
+
isDisabled: false
|
|
138
|
+
}, children, /*#__PURE__*/React.createElement(EscapeCloseManager, {
|
|
139
|
+
createAnalyticsEvent: createAnalyticsEvent,
|
|
140
|
+
handleClose: handleClose
|
|
141
|
+
})) : children));
|
|
142
|
+
};
|
|
164
143
|
|
|
165
144
|
/**
|
|
166
145
|
* __Drawer__
|
|
@@ -171,10 +150,6 @@ export class DrawerBase extends Component {
|
|
|
171
150
|
* - [Code](https://atlassian.design/components/drawer/code)
|
|
172
151
|
* - [Usage](https://atlassian.design/components/drawer/usage)
|
|
173
152
|
*/
|
|
174
|
-
_defineProperty(DrawerBase, "defaultProps", {
|
|
175
|
-
width: 'narrow',
|
|
176
|
-
...defaultFocusLockSettings
|
|
177
|
-
});
|
|
178
153
|
const Drawer = withAnalyticsContext({
|
|
179
154
|
componentName: 'drawer',
|
|
180
155
|
packageName,
|
|
@@ -1,40 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { Component } from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
3
2
|
import ReactFocusLock from 'react-focus-lock';
|
|
4
3
|
import ScrollLock from 'react-scrolllock';
|
|
5
4
|
import invariant from 'tiny-invariant';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return false;
|
|
20
|
-
});
|
|
21
|
-
_defineProperty(this, "onDeactivation", () => {
|
|
22
|
-
const {
|
|
23
|
-
shouldReturnFocus
|
|
24
|
-
} = this.props;
|
|
25
|
-
if (typeof shouldReturnFocus !== 'boolean') {
|
|
26
|
-
window.setTimeout(() => {
|
|
27
|
-
var _shouldReturnFocus$cu;
|
|
28
|
-
shouldReturnFocus === null || shouldReturnFocus === void 0 ? void 0 : (_shouldReturnFocus$cu = shouldReturnFocus.current) === null || _shouldReturnFocus$cu === void 0 ? void 0 : _shouldReturnFocus$cu.focus();
|
|
29
|
-
}, 0);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
componentDidMount() {
|
|
34
|
-
const {
|
|
35
|
-
isFocusLockEnabled,
|
|
36
|
-
autoFocusFirstElem
|
|
37
|
-
} = this.props;
|
|
5
|
+
/**
|
|
6
|
+
* __Focus lock__
|
|
7
|
+
*
|
|
8
|
+
* Thin wrapper over react-focus-lock. This wrapper only exists to ensure API compatibility.
|
|
9
|
+
* This component should be deleted during https://ecosystem.atlassian.net/browse/AK-5658
|
|
10
|
+
*/
|
|
11
|
+
const FocusLock = ({
|
|
12
|
+
isFocusLockEnabled = true,
|
|
13
|
+
autoFocusFirstElem = true,
|
|
14
|
+
shouldReturnFocus = true,
|
|
15
|
+
children
|
|
16
|
+
}) => {
|
|
17
|
+
useEffect(() => {
|
|
38
18
|
if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && !process.env.CI) {
|
|
39
19
|
invariant(typeof autoFocusFirstElem === 'boolean', '@atlaskit/drawer: Passing a function as autoFocus is deprecated. Instead call focus on the element ref or use the autofocus property.');
|
|
40
20
|
}
|
|
@@ -44,21 +24,26 @@ export default class FocusLock extends Component {
|
|
|
44
24
|
elem.focus();
|
|
45
25
|
}
|
|
46
26
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
27
|
+
}, [autoFocusFirstElem, isFocusLockEnabled]);
|
|
28
|
+
const getFocusTarget = () => {
|
|
29
|
+
if (typeof shouldReturnFocus === 'boolean') {
|
|
30
|
+
return shouldReturnFocus;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
const onDeactivation = () => {
|
|
35
|
+
if (typeof shouldReturnFocus !== 'boolean') {
|
|
36
|
+
window.setTimeout(() => {
|
|
37
|
+
var _shouldReturnFocus$cu;
|
|
38
|
+
shouldReturnFocus === null || shouldReturnFocus === void 0 ? void 0 : (_shouldReturnFocus$cu = shouldReturnFocus.current) === null || _shouldReturnFocus$cu === void 0 ? void 0 : _shouldReturnFocus$cu.focus();
|
|
39
|
+
}, 0);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return /*#__PURE__*/React.createElement(ReactFocusLock, {
|
|
43
|
+
disabled: !isFocusLockEnabled,
|
|
44
|
+
autoFocus: !!autoFocusFirstElem,
|
|
45
|
+
returnFocus: getFocusTarget(),
|
|
46
|
+
onDeactivation: onDeactivation
|
|
47
|
+
}, /*#__PURE__*/React.createElement(ScrollLock, null, children));
|
|
48
|
+
};
|
|
49
|
+
export default FocusLock;
|
|
@@ -1,26 +1,14 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
12
1
|
/* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
|
|
13
|
-
import React, {
|
|
2
|
+
import React, { useCallback, useEffect } from 'react';
|
|
14
3
|
import { canUseDOM } from 'exenv';
|
|
15
4
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
16
5
|
import { UNSAFE_LAYERING, useCloseOnEscapePress } from '@atlaskit/layering';
|
|
17
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
7
|
import Portal from '@atlaskit/portal';
|
|
19
|
-
import { defaultFocusLockSettings } from '../constants';
|
|
20
8
|
import Blanket from './blanket';
|
|
21
9
|
import DrawerPrimitive from './primitives';
|
|
22
10
|
var packageName = "@atlaskit/drawer";
|
|
23
|
-
var packageVersion = "7.14.
|
|
11
|
+
var packageVersion = "7.14.3";
|
|
24
12
|
var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
25
13
|
var createAndFireOnClick = function createAndFireOnClick(createAnalyticsEvent, trigger) {
|
|
26
14
|
return createAndFireEventOnAtlaskit({
|
|
@@ -51,139 +39,111 @@ var EscapeCloseManager = function EscapeCloseManager(_ref) {
|
|
|
51
39
|
// only create a dummy component for using ths hook in class component
|
|
52
40
|
return /*#__PURE__*/React.createElement("span", null);
|
|
53
41
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* __Drawer base__
|
|
45
|
+
*
|
|
46
|
+
* A drawer is a panel that slides in from the left side of the screen.
|
|
47
|
+
*
|
|
48
|
+
* - [Examples](https://atlassian.design/components/drawer/examples)
|
|
49
|
+
* - [Code](https://atlassian.design/components/drawer/code)
|
|
50
|
+
* - [Usage](https://atlassian.design/components/drawer/usage)
|
|
51
|
+
*/
|
|
52
|
+
export var DrawerBase = function DrawerBase(_ref2) {
|
|
53
|
+
var _ref2$width = _ref2.width,
|
|
54
|
+
width = _ref2$width === void 0 ? 'narrow' : _ref2$width,
|
|
55
|
+
isOpen = _ref2.isOpen,
|
|
56
|
+
_ref2$isFocusLockEnab = _ref2.isFocusLockEnabled,
|
|
57
|
+
isFocusLockEnabled = _ref2$isFocusLockEnab === void 0 ? true : _ref2$isFocusLockEnab,
|
|
58
|
+
_ref2$shouldReturnFoc = _ref2.shouldReturnFocus,
|
|
59
|
+
shouldReturnFocus = _ref2$shouldReturnFoc === void 0 ? true : _ref2$shouldReturnFoc,
|
|
60
|
+
_ref2$autoFocusFirstE = _ref2.autoFocusFirstElem,
|
|
61
|
+
autoFocusFirstElem = _ref2$autoFocusFirstE === void 0 ? true : _ref2$autoFocusFirstE,
|
|
62
|
+
onKeyDown = _ref2.onKeyDown,
|
|
63
|
+
createAnalyticsEvent = _ref2.createAnalyticsEvent,
|
|
64
|
+
onClose = _ref2.onClose,
|
|
65
|
+
testId = _ref2.testId,
|
|
66
|
+
children = _ref2.children,
|
|
67
|
+
icon = _ref2.icon,
|
|
68
|
+
closeLabel = _ref2.closeLabel,
|
|
69
|
+
scrollContentLabel = _ref2.scrollContentLabel,
|
|
70
|
+
shouldUnmountOnExit = _ref2.shouldUnmountOnExit,
|
|
71
|
+
onCloseComplete = _ref2.onCloseComplete,
|
|
72
|
+
onOpenComplete = _ref2.onOpenComplete,
|
|
73
|
+
overrides = _ref2.overrides,
|
|
74
|
+
_ref2$zIndex = _ref2.zIndex,
|
|
75
|
+
zIndex = _ref2$zIndex === void 0 ? 'unset' : _ref2$zIndex,
|
|
76
|
+
label = _ref2.label,
|
|
77
|
+
titleId = _ref2.titleId,
|
|
78
|
+
enterFrom = _ref2.enterFrom;
|
|
79
|
+
var body = canUseDOM ? document.querySelector('body') : undefined;
|
|
80
|
+
var handleClose = useCallback(function (event, trigger) {
|
|
81
|
+
var analyticsEvent = createAnalyticsEvent && createAndFireOnClick(createAnalyticsEvent, trigger);
|
|
82
|
+
if (onClose) {
|
|
83
|
+
onClose(event, analyticsEvent);
|
|
62
84
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
_defineProperty(_assertThisInitialized(_this), "body", canUseDOM ? document.querySelector('body') : undefined);
|
|
68
|
-
_defineProperty(_assertThisInitialized(_this), "handleBlanketClick", function (event) {
|
|
69
|
-
_this.handleClose(event, 'blanket');
|
|
70
|
-
});
|
|
71
|
-
_defineProperty(_assertThisInitialized(_this), "handleBackButtonClick", function (event) {
|
|
72
|
-
_this.handleClose(event, 'backButton');
|
|
73
|
-
});
|
|
74
|
-
_defineProperty(_assertThisInitialized(_this), "handleClose", function (event, trigger) {
|
|
75
|
-
var _this$props = _this.props,
|
|
76
|
-
createAnalyticsEvent = _this$props.createAnalyticsEvent,
|
|
77
|
-
onClose = _this$props.onClose;
|
|
78
|
-
var analyticsEvent = createAnalyticsEvent && createAndFireOnClick(createAnalyticsEvent, trigger);
|
|
79
|
-
if (onClose) {
|
|
80
|
-
onClose(event, analyticsEvent);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
_defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) {
|
|
84
|
-
var _this$props2 = _this.props,
|
|
85
|
-
isOpen = _this$props2.isOpen,
|
|
86
|
-
onKeyDown = _this$props2.onKeyDown;
|
|
85
|
+
}, [createAnalyticsEvent, onClose]);
|
|
86
|
+
useEffect(function () {
|
|
87
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
87
88
|
if (!fg('platform.design-system-team.inline-message-layering_wfp1p')) {
|
|
88
89
|
// when feature flag on, we will use the EscapeCloseManager instead
|
|
89
90
|
if (event.key === 'Escape' && isOpen) {
|
|
90
|
-
|
|
91
|
+
handleClose(event, 'escKey');
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
if (onKeyDown) {
|
|
94
95
|
onKeyDown(event);
|
|
95
96
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
_createClass(DrawerBase, [{
|
|
100
|
-
key: "componentDidMount",
|
|
101
|
-
value: function componentDidMount() {
|
|
102
|
-
var isOpen = this.props.isOpen;
|
|
103
|
-
if (isOpen) {
|
|
104
|
-
window.addEventListener('keydown', this.handleKeyDown);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}, {
|
|
108
|
-
key: "componentWillUnmount",
|
|
109
|
-
value: function componentWillUnmount() {
|
|
110
|
-
window.removeEventListener('keydown', this.handleKeyDown);
|
|
111
|
-
}
|
|
112
|
-
}, {
|
|
113
|
-
key: "componentDidUpdate",
|
|
114
|
-
value: function componentDidUpdate(prevProps) {
|
|
115
|
-
var isOpen = this.props.isOpen;
|
|
116
|
-
if (isOpen !== prevProps.isOpen) {
|
|
117
|
-
if (isOpen) {
|
|
118
|
-
window.addEventListener('keydown', this.handleKeyDown);
|
|
119
|
-
} else {
|
|
120
|
-
window.removeEventListener('keydown', this.handleKeyDown);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}, {
|
|
125
|
-
key: "render",
|
|
126
|
-
value: function render() {
|
|
127
|
-
if (!this.body) {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
var _this$props3 = this.props,
|
|
131
|
-
testId = _this$props3.testId,
|
|
132
|
-
isOpen = _this$props3.isOpen,
|
|
133
|
-
children = _this$props3.children,
|
|
134
|
-
icon = _this$props3.icon,
|
|
135
|
-
closeLabel = _this$props3.closeLabel,
|
|
136
|
-
scrollContentLabel = _this$props3.scrollContentLabel,
|
|
137
|
-
width = _this$props3.width,
|
|
138
|
-
shouldUnmountOnExit = _this$props3.shouldUnmountOnExit,
|
|
139
|
-
onCloseComplete = _this$props3.onCloseComplete,
|
|
140
|
-
onOpenComplete = _this$props3.onOpenComplete,
|
|
141
|
-
autoFocusFirstElem = _this$props3.autoFocusFirstElem,
|
|
142
|
-
isFocusLockEnabled = _this$props3.isFocusLockEnabled,
|
|
143
|
-
shouldReturnFocus = _this$props3.shouldReturnFocus,
|
|
144
|
-
overrides = _this$props3.overrides,
|
|
145
|
-
_this$props3$zIndex = _this$props3.zIndex,
|
|
146
|
-
zIndex = _this$props3$zIndex === void 0 ? 'unset' : _this$props3$zIndex,
|
|
147
|
-
label = _this$props3.label,
|
|
148
|
-
titleId = _this$props3.titleId,
|
|
149
|
-
enterFrom = _this$props3.enterFrom;
|
|
150
|
-
var shouldHaveLayeringEnabled = fg('platform.design-system-team.inline-message-layering_wfp1p') && isOpen;
|
|
151
|
-
return /*#__PURE__*/React.createElement(Portal, {
|
|
152
|
-
zIndex: zIndex
|
|
153
|
-
}, /*#__PURE__*/React.createElement(Blanket, {
|
|
154
|
-
isOpen: isOpen,
|
|
155
|
-
onBlanketClicked: this.handleBlanketClick,
|
|
156
|
-
testId: testId && "".concat(testId, "--blanket")
|
|
157
|
-
}), /*#__PURE__*/React.createElement(DrawerPrimitive, {
|
|
158
|
-
testId: testId,
|
|
159
|
-
icon: icon,
|
|
160
|
-
closeLabel: closeLabel,
|
|
161
|
-
in: isOpen,
|
|
162
|
-
onClose: this.handleBackButtonClick,
|
|
163
|
-
onCloseComplete: onCloseComplete,
|
|
164
|
-
onOpenComplete: onOpenComplete,
|
|
165
|
-
width: width,
|
|
166
|
-
enterFrom: enterFrom,
|
|
167
|
-
label: label,
|
|
168
|
-
titleId: titleId,
|
|
169
|
-
shouldUnmountOnExit: shouldUnmountOnExit
|
|
170
|
-
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
171
|
-
,
|
|
172
|
-
overrides: overrides,
|
|
173
|
-
autoFocusFirstElem: autoFocusFirstElem,
|
|
174
|
-
isFocusLockEnabled: isFocusLockEnabled,
|
|
175
|
-
shouldReturnFocus: shouldReturnFocus,
|
|
176
|
-
scrollContentLabel: scrollContentLabel
|
|
177
|
-
}, shouldHaveLayeringEnabled ? /*#__PURE__*/React.createElement(UNSAFE_LAYERING, {
|
|
178
|
-
isDisabled: false
|
|
179
|
-
}, children, /*#__PURE__*/React.createElement(EscapeCloseManager, {
|
|
180
|
-
createAnalyticsEvent: this.props.createAnalyticsEvent,
|
|
181
|
-
handleClose: this.handleClose
|
|
182
|
-
})) : children));
|
|
97
|
+
};
|
|
98
|
+
if (isOpen) {
|
|
99
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
183
100
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
101
|
+
return function () {
|
|
102
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
103
|
+
};
|
|
104
|
+
}, [handleClose, isOpen, onKeyDown]);
|
|
105
|
+
var handleBlanketClick = function handleBlanketClick(event) {
|
|
106
|
+
handleClose(event, 'blanket');
|
|
107
|
+
};
|
|
108
|
+
var handleBackButtonClick = function handleBackButtonClick(event) {
|
|
109
|
+
handleClose(event, 'backButton');
|
|
110
|
+
};
|
|
111
|
+
if (!body) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
return /*#__PURE__*/React.createElement(Portal, {
|
|
115
|
+
zIndex: zIndex
|
|
116
|
+
}, /*#__PURE__*/React.createElement(Blanket, {
|
|
117
|
+
isOpen: isOpen,
|
|
118
|
+
onBlanketClicked: handleBlanketClick,
|
|
119
|
+
testId: testId && "".concat(testId, "--blanket")
|
|
120
|
+
}), /*#__PURE__*/React.createElement(DrawerPrimitive, {
|
|
121
|
+
testId: testId,
|
|
122
|
+
icon: icon,
|
|
123
|
+
closeLabel: closeLabel,
|
|
124
|
+
in: isOpen,
|
|
125
|
+
onClose: handleBackButtonClick,
|
|
126
|
+
onCloseComplete: onCloseComplete,
|
|
127
|
+
onOpenComplete: onOpenComplete,
|
|
128
|
+
width: width,
|
|
129
|
+
enterFrom: enterFrom,
|
|
130
|
+
label: label,
|
|
131
|
+
titleId: titleId,
|
|
132
|
+
shouldUnmountOnExit: shouldUnmountOnExit
|
|
133
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
134
|
+
,
|
|
135
|
+
overrides: overrides,
|
|
136
|
+
autoFocusFirstElem: autoFocusFirstElem,
|
|
137
|
+
isFocusLockEnabled: isFocusLockEnabled,
|
|
138
|
+
shouldReturnFocus: shouldReturnFocus,
|
|
139
|
+
scrollContentLabel: scrollContentLabel
|
|
140
|
+
}, isOpen && fg('platform.design-system-team.inline-message-layering_wfp1p') ? /*#__PURE__*/React.createElement(UNSAFE_LAYERING, {
|
|
141
|
+
isDisabled: false
|
|
142
|
+
}, children, /*#__PURE__*/React.createElement(EscapeCloseManager, {
|
|
143
|
+
createAnalyticsEvent: createAnalyticsEvent,
|
|
144
|
+
handleClose: handleClose
|
|
145
|
+
})) : children));
|
|
146
|
+
};
|
|
187
147
|
|
|
188
148
|
/**
|
|
189
149
|
* __Drawer__
|
|
@@ -194,9 +154,6 @@ export var DrawerBase = /*#__PURE__*/function (_Component) {
|
|
|
194
154
|
* - [Code](https://atlassian.design/components/drawer/code)
|
|
195
155
|
* - [Usage](https://atlassian.design/components/drawer/usage)
|
|
196
156
|
*/
|
|
197
|
-
_defineProperty(DrawerBase, "defaultProps", _objectSpread({
|
|
198
|
-
width: 'narrow'
|
|
199
|
-
}, defaultFocusLockSettings));
|
|
200
157
|
var Drawer = withAnalyticsContext({
|
|
201
158
|
componentName: 'drawer',
|
|
202
159
|
packageName: packageName,
|