@atlaskit/drawer 7.14.3 → 8.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 +9 -0
- package/dist/cjs/components/index.js +56 -71
- package/dist/cjs/components/primitives/focus-lock.js +1 -1
- package/dist/es2019/components/index.js +49 -68
- package/dist/esm/components/index.js +55 -70
- package/dist/types/components/index.d.ts +2 -17
- package/dist/types/components/types.d.ts +2 -3
- package/dist/types-ts4.5/components/index.d.ts +2 -17
- package/dist/types-ts4.5/components/types.d.ts +2 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/drawer
|
|
2
2
|
|
|
3
|
+
## 8.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#140090](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/140090)
|
|
8
|
+
[`89833597971da`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/89833597971da) -
|
|
9
|
+
Refactor of analytics handling to remove usages of legacy AnalyticsContext. Removed
|
|
10
|
+
WithAnalyticsEventsProps from type.
|
|
11
|
+
|
|
3
12
|
## 7.14.3
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default = exports.
|
|
8
|
+
exports.default = exports.Drawer = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _exenv = require("exenv");
|
|
11
11
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
@@ -15,44 +15,24 @@ var _portal = _interopRequireDefault(require("@atlaskit/portal"));
|
|
|
15
15
|
var _blanket = _interopRequireDefault(require("./blanket"));
|
|
16
16
|
var _primitives = _interopRequireDefault(require("./primitives"));
|
|
17
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
18
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
19
|
/* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
|
|
20
20
|
|
|
21
|
-
var packageName = "@atlaskit/drawer";
|
|
22
|
-
var packageVersion = "7.14.3";
|
|
23
|
-
var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
|
|
24
|
-
var createAndFireOnClick = function createAndFireOnClick(createAnalyticsEvent, trigger) {
|
|
25
|
-
return createAndFireEventOnAtlaskit({
|
|
26
|
-
action: 'dismissed',
|
|
27
|
-
actionSubject: 'drawer',
|
|
28
|
-
attributes: {
|
|
29
|
-
componentName: 'drawer',
|
|
30
|
-
packageName: packageName,
|
|
31
|
-
packageVersion: packageVersion,
|
|
32
|
-
trigger: trigger
|
|
33
|
-
}
|
|
34
|
-
})(createAnalyticsEvent);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
21
|
// escape close manager for layering
|
|
38
22
|
var EscapeCloseManager = function EscapeCloseManager(_ref) {
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
handleClose(event, _analyticsEvent);
|
|
45
|
-
}
|
|
46
|
-
}, [handleClose, createAnalyticsEvent]);
|
|
23
|
+
var onClose = _ref.onClose;
|
|
24
|
+
// wrap so that we can cast the event to a React.KeyboardEvent
|
|
25
|
+
var handleClose = (0, _react.useCallback)(function (evt) {
|
|
26
|
+
onClose && onClose(evt);
|
|
27
|
+
}, [onClose]);
|
|
47
28
|
(0, _layering.useCloseOnEscapePress)({
|
|
48
|
-
onClose:
|
|
29
|
+
onClose: handleClose
|
|
49
30
|
});
|
|
50
|
-
// only create a dummy component for using ths hook in class component
|
|
51
31
|
return /*#__PURE__*/_react.default.createElement("span", null);
|
|
52
32
|
};
|
|
53
33
|
|
|
54
34
|
/**
|
|
55
|
-
*
|
|
35
|
+
* __Drawer__
|
|
56
36
|
*
|
|
57
37
|
* A drawer is a panel that slides in from the left side of the screen.
|
|
58
38
|
*
|
|
@@ -60,7 +40,7 @@ var EscapeCloseManager = function EscapeCloseManager(_ref) {
|
|
|
60
40
|
* - [Code](https://atlassian.design/components/drawer/code)
|
|
61
41
|
* - [Usage](https://atlassian.design/components/drawer/usage)
|
|
62
42
|
*/
|
|
63
|
-
var
|
|
43
|
+
var Drawer = exports.Drawer = function Drawer(_ref2) {
|
|
64
44
|
var _ref2$width = _ref2.width,
|
|
65
45
|
width = _ref2$width === void 0 ? 'narrow' : _ref2$width,
|
|
66
46
|
isOpen = _ref2.isOpen,
|
|
@@ -71,7 +51,6 @@ var DrawerBase = exports.DrawerBase = function DrawerBase(_ref2) {
|
|
|
71
51
|
_ref2$autoFocusFirstE = _ref2.autoFocusFirstElem,
|
|
72
52
|
autoFocusFirstElem = _ref2$autoFocusFirstE === void 0 ? true : _ref2$autoFocusFirstE,
|
|
73
53
|
onKeyDown = _ref2.onKeyDown,
|
|
74
|
-
createAnalyticsEvent = _ref2.createAnalyticsEvent,
|
|
75
54
|
onClose = _ref2.onClose,
|
|
76
55
|
testId = _ref2.testId,
|
|
77
56
|
children = _ref2.children,
|
|
@@ -88,37 +67,59 @@ var DrawerBase = exports.DrawerBase = function DrawerBase(_ref2) {
|
|
|
88
67
|
titleId = _ref2.titleId,
|
|
89
68
|
enterFrom = _ref2.enterFrom;
|
|
90
69
|
var body = _exenv.canUseDOM ? document.querySelector('body') : undefined;
|
|
91
|
-
var handleClose = (0,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
70
|
+
var handleClose = (0, _analyticsNext.usePlatformLeafEventHandler)({
|
|
71
|
+
fn: function fn(evt, analyticsEvent) {
|
|
72
|
+
return onClose && onClose(evt, analyticsEvent);
|
|
73
|
+
},
|
|
74
|
+
action: 'dismissed',
|
|
75
|
+
componentName: 'drawer',
|
|
76
|
+
packageName: "@atlaskit/drawer",
|
|
77
|
+
packageVersion: "8.0.0",
|
|
78
|
+
analyticsData: {
|
|
79
|
+
trigger: 'escKey'
|
|
95
80
|
}
|
|
96
|
-
}
|
|
97
|
-
(0, _react.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (onKeyDown) {
|
|
106
|
-
onKeyDown(event);
|
|
81
|
+
});
|
|
82
|
+
var handleKeyDown = (0, _react.useCallback)(function (evt) {
|
|
83
|
+
onKeyDown && onKeyDown(evt);
|
|
84
|
+
if (!(0, _platformFeatureFlags.fg)('platform.design-system-team.inline-message-layering_wfp1p')) {
|
|
85
|
+
// when feature flag on, we will use the EscapeCloseManager instead
|
|
86
|
+
if (evt.key === 'Escape' && isOpen && onClose) {
|
|
87
|
+
handleClose(evt);
|
|
107
88
|
}
|
|
108
|
-
}
|
|
89
|
+
}
|
|
90
|
+
}, [handleClose, isOpen, onClose, onKeyDown]);
|
|
91
|
+
(0, _react.useEffect)(function () {
|
|
109
92
|
if (isOpen) {
|
|
110
93
|
window.addEventListener('keydown', handleKeyDown);
|
|
111
94
|
}
|
|
112
95
|
return function () {
|
|
113
96
|
window.removeEventListener('keydown', handleKeyDown);
|
|
114
97
|
};
|
|
115
|
-
}, [
|
|
116
|
-
var handleBlanketClick =
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
98
|
+
}, [handleKeyDown, isOpen]);
|
|
99
|
+
var handleBlanketClick = (0, _analyticsNext.usePlatformLeafEventHandler)({
|
|
100
|
+
fn: function fn(evt, analyticsEvent) {
|
|
101
|
+
return onClose && onClose(evt, analyticsEvent);
|
|
102
|
+
},
|
|
103
|
+
action: 'dismissed',
|
|
104
|
+
componentName: 'drawer',
|
|
105
|
+
packageName: "@atlaskit/drawer",
|
|
106
|
+
packageVersion: "8.0.0",
|
|
107
|
+
analyticsData: {
|
|
108
|
+
trigger: 'blanket'
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
var handleBackButtonClick = (0, _analyticsNext.usePlatformLeafEventHandler)({
|
|
112
|
+
fn: function fn(evt, analyticsEvent) {
|
|
113
|
+
return onClose && onClose(evt, analyticsEvent);
|
|
114
|
+
},
|
|
115
|
+
action: 'dismissed',
|
|
116
|
+
componentName: 'drawer',
|
|
117
|
+
packageName: "@atlaskit/drawer",
|
|
118
|
+
packageVersion: "8.0.0",
|
|
119
|
+
analyticsData: {
|
|
120
|
+
trigger: 'backButton'
|
|
121
|
+
}
|
|
122
|
+
});
|
|
122
123
|
if (!body) {
|
|
123
124
|
return null;
|
|
124
125
|
}
|
|
@@ -151,23 +152,7 @@ var DrawerBase = exports.DrawerBase = function DrawerBase(_ref2) {
|
|
|
151
152
|
}, isOpen && (0, _platformFeatureFlags.fg)('platform.design-system-team.inline-message-layering_wfp1p') ? /*#__PURE__*/_react.default.createElement(_layering.UNSAFE_LAYERING, {
|
|
152
153
|
isDisabled: false
|
|
153
154
|
}, children, /*#__PURE__*/_react.default.createElement(EscapeCloseManager, {
|
|
154
|
-
|
|
155
|
-
handleClose: handleClose
|
|
155
|
+
onClose: handleClose
|
|
156
156
|
})) : children));
|
|
157
157
|
};
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* __Drawer__
|
|
161
|
-
*
|
|
162
|
-
* A drawer is a panel that slides in from the left side of the screen.
|
|
163
|
-
*
|
|
164
|
-
* - [Examples](https://atlassian.design/components/drawer/examples)
|
|
165
|
-
* - [Code](https://atlassian.design/components/drawer/code)
|
|
166
|
-
* - [Usage](https://atlassian.design/components/drawer/usage)
|
|
167
|
-
*/
|
|
168
|
-
var Drawer = (0, _analyticsNext.withAnalyticsContext)({
|
|
169
|
-
componentName: 'drawer',
|
|
170
|
-
packageName: packageName,
|
|
171
|
-
packageVersion: packageVersion
|
|
172
|
-
})((0, _analyticsNext.withAnalyticsEvents)()(DrawerBase));
|
|
173
158
|
var _default = exports.default = Drawer;
|
|
@@ -11,7 +11,7 @@ var _reactFocusLock = _interopRequireDefault(require("react-focus-lock"));
|
|
|
11
11
|
var _reactScrolllock = _interopRequireDefault(require("react-scrolllock"));
|
|
12
12
|
var _tinyInvariant = _interopRequireDefault(require("tiny-invariant"));
|
|
13
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
15
|
/**
|
|
16
16
|
* __Focus lock__
|
|
17
17
|
*
|
|
@@ -1,46 +1,28 @@
|
|
|
1
1
|
/* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
|
|
2
2
|
import React, { useCallback, useEffect } from 'react';
|
|
3
3
|
import { canUseDOM } from 'exenv';
|
|
4
|
-
import {
|
|
4
|
+
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
5
5
|
import { UNSAFE_LAYERING, useCloseOnEscapePress } from '@atlaskit/layering';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import Portal from '@atlaskit/portal';
|
|
8
8
|
import Blanket from './blanket';
|
|
9
9
|
import DrawerPrimitive from './primitives';
|
|
10
|
-
const packageName = "@atlaskit/drawer";
|
|
11
|
-
const packageVersion = "7.14.3";
|
|
12
|
-
const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
13
|
-
const createAndFireOnClick = (createAnalyticsEvent, trigger) => createAndFireEventOnAtlaskit({
|
|
14
|
-
action: 'dismissed',
|
|
15
|
-
actionSubject: 'drawer',
|
|
16
|
-
attributes: {
|
|
17
|
-
componentName: 'drawer',
|
|
18
|
-
packageName,
|
|
19
|
-
packageVersion,
|
|
20
|
-
trigger
|
|
21
|
-
}
|
|
22
|
-
})(createAnalyticsEvent);
|
|
23
|
-
|
|
24
10
|
// escape close manager for layering
|
|
25
11
|
const EscapeCloseManager = ({
|
|
26
|
-
|
|
27
|
-
handleClose
|
|
12
|
+
onClose
|
|
28
13
|
}) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
}, [handleClose, createAnalyticsEvent]);
|
|
14
|
+
// wrap so that we can cast the event to a React.KeyboardEvent
|
|
15
|
+
const handleClose = useCallback(evt => {
|
|
16
|
+
onClose && onClose(evt);
|
|
17
|
+
}, [onClose]);
|
|
35
18
|
useCloseOnEscapePress({
|
|
36
|
-
onClose:
|
|
19
|
+
onClose: handleClose
|
|
37
20
|
});
|
|
38
|
-
// only create a dummy component for using ths hook in class component
|
|
39
21
|
return /*#__PURE__*/React.createElement("span", null);
|
|
40
22
|
};
|
|
41
23
|
|
|
42
24
|
/**
|
|
43
|
-
*
|
|
25
|
+
* __Drawer__
|
|
44
26
|
*
|
|
45
27
|
* A drawer is a panel that slides in from the left side of the screen.
|
|
46
28
|
*
|
|
@@ -48,14 +30,13 @@ const EscapeCloseManager = ({
|
|
|
48
30
|
* - [Code](https://atlassian.design/components/drawer/code)
|
|
49
31
|
* - [Usage](https://atlassian.design/components/drawer/usage)
|
|
50
32
|
*/
|
|
51
|
-
export const
|
|
33
|
+
export const Drawer = ({
|
|
52
34
|
width = 'narrow',
|
|
53
35
|
isOpen,
|
|
54
36
|
isFocusLockEnabled = true,
|
|
55
37
|
shouldReturnFocus = true,
|
|
56
38
|
autoFocusFirstElem = true,
|
|
57
39
|
onKeyDown,
|
|
58
|
-
createAnalyticsEvent,
|
|
59
40
|
onClose,
|
|
60
41
|
testId,
|
|
61
42
|
children,
|
|
@@ -73,37 +54,53 @@ export const DrawerBase = ({
|
|
|
73
54
|
enterFrom
|
|
74
55
|
}) => {
|
|
75
56
|
const body = canUseDOM ? document.querySelector('body') : undefined;
|
|
76
|
-
const handleClose =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
57
|
+
const handleClose = usePlatformLeafEventHandler({
|
|
58
|
+
fn: (evt, analyticsEvent) => onClose && onClose(evt, analyticsEvent),
|
|
59
|
+
action: 'dismissed',
|
|
60
|
+
componentName: 'drawer',
|
|
61
|
+
packageName: "@atlaskit/drawer",
|
|
62
|
+
packageVersion: "8.0.0",
|
|
63
|
+
analyticsData: {
|
|
64
|
+
trigger: 'escKey'
|
|
80
65
|
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
if (onKeyDown) {
|
|
91
|
-
onKeyDown(event);
|
|
66
|
+
});
|
|
67
|
+
const handleKeyDown = useCallback(evt => {
|
|
68
|
+
onKeyDown && onKeyDown(evt);
|
|
69
|
+
if (!fg('platform.design-system-team.inline-message-layering_wfp1p')) {
|
|
70
|
+
// when feature flag on, we will use the EscapeCloseManager instead
|
|
71
|
+
if (evt.key === 'Escape' && isOpen && onClose) {
|
|
72
|
+
handleClose(evt);
|
|
92
73
|
}
|
|
93
|
-
}
|
|
74
|
+
}
|
|
75
|
+
}, [handleClose, isOpen, onClose, onKeyDown]);
|
|
76
|
+
useEffect(() => {
|
|
94
77
|
if (isOpen) {
|
|
95
78
|
window.addEventListener('keydown', handleKeyDown);
|
|
96
79
|
}
|
|
97
80
|
return () => {
|
|
98
81
|
window.removeEventListener('keydown', handleKeyDown);
|
|
99
82
|
};
|
|
100
|
-
}, [
|
|
101
|
-
const handleBlanketClick =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
83
|
+
}, [handleKeyDown, isOpen]);
|
|
84
|
+
const handleBlanketClick = usePlatformLeafEventHandler({
|
|
85
|
+
fn: (evt, analyticsEvent) => onClose && onClose(evt, analyticsEvent),
|
|
86
|
+
action: 'dismissed',
|
|
87
|
+
componentName: 'drawer',
|
|
88
|
+
packageName: "@atlaskit/drawer",
|
|
89
|
+
packageVersion: "8.0.0",
|
|
90
|
+
analyticsData: {
|
|
91
|
+
trigger: 'blanket'
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const handleBackButtonClick = usePlatformLeafEventHandler({
|
|
95
|
+
fn: (evt, analyticsEvent) => onClose && onClose(evt, analyticsEvent),
|
|
96
|
+
action: 'dismissed',
|
|
97
|
+
componentName: 'drawer',
|
|
98
|
+
packageName: "@atlaskit/drawer",
|
|
99
|
+
packageVersion: "8.0.0",
|
|
100
|
+
analyticsData: {
|
|
101
|
+
trigger: 'backButton'
|
|
102
|
+
}
|
|
103
|
+
});
|
|
107
104
|
if (!body) {
|
|
108
105
|
return null;
|
|
109
106
|
}
|
|
@@ -136,23 +133,7 @@ export const DrawerBase = ({
|
|
|
136
133
|
}, isOpen && fg('platform.design-system-team.inline-message-layering_wfp1p') ? /*#__PURE__*/React.createElement(UNSAFE_LAYERING, {
|
|
137
134
|
isDisabled: false
|
|
138
135
|
}, children, /*#__PURE__*/React.createElement(EscapeCloseManager, {
|
|
139
|
-
|
|
140
|
-
handleClose: handleClose
|
|
136
|
+
onClose: handleClose
|
|
141
137
|
})) : children));
|
|
142
138
|
};
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* __Drawer__
|
|
146
|
-
*
|
|
147
|
-
* A drawer is a panel that slides in from the left side of the screen.
|
|
148
|
-
*
|
|
149
|
-
* - [Examples](https://atlassian.design/components/drawer/examples)
|
|
150
|
-
* - [Code](https://atlassian.design/components/drawer/code)
|
|
151
|
-
* - [Usage](https://atlassian.design/components/drawer/usage)
|
|
152
|
-
*/
|
|
153
|
-
const Drawer = withAnalyticsContext({
|
|
154
|
-
componentName: 'drawer',
|
|
155
|
-
packageName,
|
|
156
|
-
packageVersion
|
|
157
|
-
})(withAnalyticsEvents()(DrawerBase));
|
|
158
139
|
export default Drawer;
|
|
@@ -1,47 +1,27 @@
|
|
|
1
1
|
/* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
|
|
2
2
|
import React, { useCallback, useEffect } from 'react';
|
|
3
3
|
import { canUseDOM } from 'exenv';
|
|
4
|
-
import {
|
|
4
|
+
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
5
5
|
import { UNSAFE_LAYERING, useCloseOnEscapePress } from '@atlaskit/layering';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import Portal from '@atlaskit/portal';
|
|
8
8
|
import Blanket from './blanket';
|
|
9
9
|
import DrawerPrimitive from './primitives';
|
|
10
|
-
var packageName = "@atlaskit/drawer";
|
|
11
|
-
var packageVersion = "7.14.3";
|
|
12
|
-
var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
13
|
-
var createAndFireOnClick = function createAndFireOnClick(createAnalyticsEvent, trigger) {
|
|
14
|
-
return createAndFireEventOnAtlaskit({
|
|
15
|
-
action: 'dismissed',
|
|
16
|
-
actionSubject: 'drawer',
|
|
17
|
-
attributes: {
|
|
18
|
-
componentName: 'drawer',
|
|
19
|
-
packageName: packageName,
|
|
20
|
-
packageVersion: packageVersion,
|
|
21
|
-
trigger: trigger
|
|
22
|
-
}
|
|
23
|
-
})(createAnalyticsEvent);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
10
|
// escape close manager for layering
|
|
27
11
|
var EscapeCloseManager = function EscapeCloseManager(_ref) {
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
handleClose(event, _analyticsEvent);
|
|
34
|
-
}
|
|
35
|
-
}, [handleClose, createAnalyticsEvent]);
|
|
12
|
+
var onClose = _ref.onClose;
|
|
13
|
+
// wrap so that we can cast the event to a React.KeyboardEvent
|
|
14
|
+
var handleClose = useCallback(function (evt) {
|
|
15
|
+
onClose && onClose(evt);
|
|
16
|
+
}, [onClose]);
|
|
36
17
|
useCloseOnEscapePress({
|
|
37
|
-
onClose:
|
|
18
|
+
onClose: handleClose
|
|
38
19
|
});
|
|
39
|
-
// only create a dummy component for using ths hook in class component
|
|
40
20
|
return /*#__PURE__*/React.createElement("span", null);
|
|
41
21
|
};
|
|
42
22
|
|
|
43
23
|
/**
|
|
44
|
-
*
|
|
24
|
+
* __Drawer__
|
|
45
25
|
*
|
|
46
26
|
* A drawer is a panel that slides in from the left side of the screen.
|
|
47
27
|
*
|
|
@@ -49,7 +29,7 @@ var EscapeCloseManager = function EscapeCloseManager(_ref) {
|
|
|
49
29
|
* - [Code](https://atlassian.design/components/drawer/code)
|
|
50
30
|
* - [Usage](https://atlassian.design/components/drawer/usage)
|
|
51
31
|
*/
|
|
52
|
-
export var
|
|
32
|
+
export var Drawer = function Drawer(_ref2) {
|
|
53
33
|
var _ref2$width = _ref2.width,
|
|
54
34
|
width = _ref2$width === void 0 ? 'narrow' : _ref2$width,
|
|
55
35
|
isOpen = _ref2.isOpen,
|
|
@@ -60,7 +40,6 @@ export var DrawerBase = function DrawerBase(_ref2) {
|
|
|
60
40
|
_ref2$autoFocusFirstE = _ref2.autoFocusFirstElem,
|
|
61
41
|
autoFocusFirstElem = _ref2$autoFocusFirstE === void 0 ? true : _ref2$autoFocusFirstE,
|
|
62
42
|
onKeyDown = _ref2.onKeyDown,
|
|
63
|
-
createAnalyticsEvent = _ref2.createAnalyticsEvent,
|
|
64
43
|
onClose = _ref2.onClose,
|
|
65
44
|
testId = _ref2.testId,
|
|
66
45
|
children = _ref2.children,
|
|
@@ -77,37 +56,59 @@ export var DrawerBase = function DrawerBase(_ref2) {
|
|
|
77
56
|
titleId = _ref2.titleId,
|
|
78
57
|
enterFrom = _ref2.enterFrom;
|
|
79
58
|
var body = canUseDOM ? document.querySelector('body') : undefined;
|
|
80
|
-
var handleClose =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
59
|
+
var handleClose = usePlatformLeafEventHandler({
|
|
60
|
+
fn: function fn(evt, analyticsEvent) {
|
|
61
|
+
return onClose && onClose(evt, analyticsEvent);
|
|
62
|
+
},
|
|
63
|
+
action: 'dismissed',
|
|
64
|
+
componentName: 'drawer',
|
|
65
|
+
packageName: "@atlaskit/drawer",
|
|
66
|
+
packageVersion: "8.0.0",
|
|
67
|
+
analyticsData: {
|
|
68
|
+
trigger: 'escKey'
|
|
84
69
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (onKeyDown) {
|
|
95
|
-
onKeyDown(event);
|
|
70
|
+
});
|
|
71
|
+
var handleKeyDown = useCallback(function (evt) {
|
|
72
|
+
onKeyDown && onKeyDown(evt);
|
|
73
|
+
if (!fg('platform.design-system-team.inline-message-layering_wfp1p')) {
|
|
74
|
+
// when feature flag on, we will use the EscapeCloseManager instead
|
|
75
|
+
if (evt.key === 'Escape' && isOpen && onClose) {
|
|
76
|
+
handleClose(evt);
|
|
96
77
|
}
|
|
97
|
-
}
|
|
78
|
+
}
|
|
79
|
+
}, [handleClose, isOpen, onClose, onKeyDown]);
|
|
80
|
+
useEffect(function () {
|
|
98
81
|
if (isOpen) {
|
|
99
82
|
window.addEventListener('keydown', handleKeyDown);
|
|
100
83
|
}
|
|
101
84
|
return function () {
|
|
102
85
|
window.removeEventListener('keydown', handleKeyDown);
|
|
103
86
|
};
|
|
104
|
-
}, [
|
|
105
|
-
var handleBlanketClick =
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
87
|
+
}, [handleKeyDown, isOpen]);
|
|
88
|
+
var handleBlanketClick = usePlatformLeafEventHandler({
|
|
89
|
+
fn: function fn(evt, analyticsEvent) {
|
|
90
|
+
return onClose && onClose(evt, analyticsEvent);
|
|
91
|
+
},
|
|
92
|
+
action: 'dismissed',
|
|
93
|
+
componentName: 'drawer',
|
|
94
|
+
packageName: "@atlaskit/drawer",
|
|
95
|
+
packageVersion: "8.0.0",
|
|
96
|
+
analyticsData: {
|
|
97
|
+
trigger: 'blanket'
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
var handleBackButtonClick = usePlatformLeafEventHandler({
|
|
101
|
+
fn: function fn(evt, analyticsEvent) {
|
|
102
|
+
return onClose && onClose(evt, analyticsEvent);
|
|
103
|
+
},
|
|
104
|
+
action: 'dismissed',
|
|
105
|
+
componentName: 'drawer',
|
|
106
|
+
packageName: "@atlaskit/drawer",
|
|
107
|
+
packageVersion: "8.0.0",
|
|
108
|
+
analyticsData: {
|
|
109
|
+
trigger: 'backButton'
|
|
110
|
+
}
|
|
111
|
+
});
|
|
111
112
|
if (!body) {
|
|
112
113
|
return null;
|
|
113
114
|
}
|
|
@@ -140,23 +141,7 @@ export var DrawerBase = function DrawerBase(_ref2) {
|
|
|
140
141
|
}, isOpen && fg('platform.design-system-team.inline-message-layering_wfp1p') ? /*#__PURE__*/React.createElement(UNSAFE_LAYERING, {
|
|
141
142
|
isDisabled: false
|
|
142
143
|
}, children, /*#__PURE__*/React.createElement(EscapeCloseManager, {
|
|
143
|
-
|
|
144
|
-
handleClose: handleClose
|
|
144
|
+
onClose: handleClose
|
|
145
145
|
})) : children));
|
|
146
146
|
};
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* __Drawer__
|
|
150
|
-
*
|
|
151
|
-
* A drawer is a panel that slides in from the left side of the screen.
|
|
152
|
-
*
|
|
153
|
-
* - [Examples](https://atlassian.design/components/drawer/examples)
|
|
154
|
-
* - [Code](https://atlassian.design/components/drawer/code)
|
|
155
|
-
* - [Usage](https://atlassian.design/components/drawer/usage)
|
|
156
|
-
*/
|
|
157
|
-
var Drawer = withAnalyticsContext({
|
|
158
|
-
componentName: 'drawer',
|
|
159
|
-
packageName: packageName,
|
|
160
|
-
packageVersion: packageVersion
|
|
161
|
-
})(withAnalyticsEvents()(DrawerBase));
|
|
162
147
|
export default Drawer;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { type DrawerProps } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* __Drawer base__
|
|
5
|
-
*
|
|
6
|
-
* A drawer is a panel that slides in from the left side of the screen.
|
|
7
|
-
*
|
|
8
|
-
* - [Examples](https://atlassian.design/components/drawer/examples)
|
|
9
|
-
* - [Code](https://atlassian.design/components/drawer/code)
|
|
10
|
-
* - [Usage](https://atlassian.design/components/drawer/usage)
|
|
11
|
-
*/
|
|
12
|
-
export declare const DrawerBase: ({ width, isOpen, isFocusLockEnabled, shouldReturnFocus, autoFocusFirstElem, onKeyDown, createAnalyticsEvent, onClose, testId, children, icon, closeLabel, scrollContentLabel, shouldUnmountOnExit, onCloseComplete, onOpenComplete, overrides, zIndex, label, titleId, enterFrom, }: DrawerProps) => JSX.Element | null;
|
|
13
3
|
/**
|
|
14
4
|
* __Drawer__
|
|
15
5
|
*
|
|
@@ -19,10 +9,5 @@ export declare const DrawerBase: ({ width, isOpen, isFocusLockEnabled, shouldRet
|
|
|
19
9
|
* - [Code](https://atlassian.design/components/drawer/code)
|
|
20
10
|
* - [Usage](https://atlassian.design/components/drawer/usage)
|
|
21
11
|
*/
|
|
22
|
-
declare const Drawer:
|
|
23
|
-
onKeyDown?: ((event: React.SyntheticEvent<Element, Event>) => void) | undefined;
|
|
24
|
-
onClose?: ((event: React.SyntheticEvent<HTMLElement, Event>, analyticsEvent: any) => void) | undefined;
|
|
25
|
-
isOpen: boolean;
|
|
26
|
-
zIndex?: number | "unset" | undefined;
|
|
27
|
-
}, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "onKeyDown" | "key" | "onClose" | "zIndex" | "isOpen" | "analyticsContext" | keyof import("./types").BaseProps | keyof import("./types").FocusLockSettings | keyof import("./types").DrawerLabel> & React.RefAttributes<any>>;
|
|
12
|
+
export declare const Drawer: ({ width, isOpen, isFocusLockEnabled, shouldReturnFocus, autoFocusFirstElem, onKeyDown, onClose, testId, children, icon, closeLabel, scrollContentLabel, shouldUnmountOnExit, onCloseComplete, onOpenComplete, overrides, zIndex, label, titleId, enterFrom, }: DrawerProps) => JSX.Element | null;
|
|
28
13
|
export default Drawer;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type ComponentType, type ReactElement, type ReactNode, type RefObject, type SyntheticEvent } from 'react';
|
|
2
2
|
import { type CSSObject } from '@emotion/react';
|
|
3
|
-
import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
4
3
|
import { type Direction } from '@atlaskit/motion';
|
|
5
4
|
export type Widths = {
|
|
6
5
|
extended: {
|
|
@@ -129,7 +128,7 @@ export interface DrawerPrimitiveProps extends BaseProps, FocusLockSettings, Draw
|
|
|
129
128
|
in: boolean;
|
|
130
129
|
onClose: (event: SyntheticEvent<HTMLElement>) => void;
|
|
131
130
|
}
|
|
132
|
-
export type DrawerProps = BaseProps & FocusLockSettings &
|
|
131
|
+
export type DrawerProps = BaseProps & FocusLockSettings & DrawerLabel & {
|
|
133
132
|
/**
|
|
134
133
|
* Callback function called while the drawer is displayed and `keydown` event is triggered.
|
|
135
134
|
*/
|
|
@@ -137,7 +136,7 @@ export type DrawerProps = BaseProps & FocusLockSettings & WithAnalyticsEventsPro
|
|
|
137
136
|
/**
|
|
138
137
|
* Callback function called when the drawer is closed.
|
|
139
138
|
*/
|
|
140
|
-
onClose?: (event: SyntheticEvent<HTMLElement>, analyticsEvent
|
|
139
|
+
onClose?: (event: SyntheticEvent<HTMLElement>, analyticsEvent?: any) => void;
|
|
141
140
|
/**
|
|
142
141
|
* Controls if the drawer is open or closed.
|
|
143
142
|
*/
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { type DrawerProps } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* __Drawer base__
|
|
5
|
-
*
|
|
6
|
-
* A drawer is a panel that slides in from the left side of the screen.
|
|
7
|
-
*
|
|
8
|
-
* - [Examples](https://atlassian.design/components/drawer/examples)
|
|
9
|
-
* - [Code](https://atlassian.design/components/drawer/code)
|
|
10
|
-
* - [Usage](https://atlassian.design/components/drawer/usage)
|
|
11
|
-
*/
|
|
12
|
-
export declare const DrawerBase: ({ width, isOpen, isFocusLockEnabled, shouldReturnFocus, autoFocusFirstElem, onKeyDown, createAnalyticsEvent, onClose, testId, children, icon, closeLabel, scrollContentLabel, shouldUnmountOnExit, onCloseComplete, onOpenComplete, overrides, zIndex, label, titleId, enterFrom, }: DrawerProps) => JSX.Element | null;
|
|
13
3
|
/**
|
|
14
4
|
* __Drawer__
|
|
15
5
|
*
|
|
@@ -19,10 +9,5 @@ export declare const DrawerBase: ({ width, isOpen, isFocusLockEnabled, shouldRet
|
|
|
19
9
|
* - [Code](https://atlassian.design/components/drawer/code)
|
|
20
10
|
* - [Usage](https://atlassian.design/components/drawer/usage)
|
|
21
11
|
*/
|
|
22
|
-
declare const Drawer:
|
|
23
|
-
onKeyDown?: ((event: React.SyntheticEvent<Element, Event>) => void) | undefined;
|
|
24
|
-
onClose?: ((event: React.SyntheticEvent<HTMLElement, Event>, analyticsEvent: any) => void) | undefined;
|
|
25
|
-
isOpen: boolean;
|
|
26
|
-
zIndex?: number | "unset" | undefined;
|
|
27
|
-
}, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "onKeyDown" | "key" | "onClose" | "zIndex" | "isOpen" | "analyticsContext" | keyof import("./types").BaseProps | keyof import("./types").FocusLockSettings | keyof import("./types").DrawerLabel> & React.RefAttributes<any>>;
|
|
12
|
+
export declare const Drawer: ({ width, isOpen, isFocusLockEnabled, shouldReturnFocus, autoFocusFirstElem, onKeyDown, onClose, testId, children, icon, closeLabel, scrollContentLabel, shouldUnmountOnExit, onCloseComplete, onOpenComplete, overrides, zIndex, label, titleId, enterFrom, }: DrawerProps) => JSX.Element | null;
|
|
28
13
|
export default Drawer;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type ComponentType, type ReactElement, type ReactNode, type RefObject, type SyntheticEvent } from 'react';
|
|
2
2
|
import { type CSSObject } from '@emotion/react';
|
|
3
|
-
import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
4
3
|
import { type Direction } from '@atlaskit/motion';
|
|
5
4
|
export type Widths = {
|
|
6
5
|
extended: {
|
|
@@ -129,7 +128,7 @@ export interface DrawerPrimitiveProps extends BaseProps, FocusLockSettings, Draw
|
|
|
129
128
|
in: boolean;
|
|
130
129
|
onClose: (event: SyntheticEvent<HTMLElement>) => void;
|
|
131
130
|
}
|
|
132
|
-
export type DrawerProps = BaseProps & FocusLockSettings &
|
|
131
|
+
export type DrawerProps = BaseProps & FocusLockSettings & DrawerLabel & {
|
|
133
132
|
/**
|
|
134
133
|
* Callback function called while the drawer is displayed and `keydown` event is triggered.
|
|
135
134
|
*/
|
|
@@ -137,7 +136,7 @@ export type DrawerProps = BaseProps & FocusLockSettings & WithAnalyticsEventsPro
|
|
|
137
136
|
/**
|
|
138
137
|
* Callback function called when the drawer is closed.
|
|
139
138
|
*/
|
|
140
|
-
onClose?: (event: SyntheticEvent<HTMLElement>, analyticsEvent
|
|
139
|
+
onClose?: (event: SyntheticEvent<HTMLElement>, analyticsEvent?: any) => void;
|
|
141
140
|
/**
|
|
142
141
|
* Controls if the drawer is open or closed.
|
|
143
142
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/drawer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "A drawer is a panel that slides in from the left side of the screen.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@atlaskit/analytics-next": "^10.1.0",
|
|
40
40
|
"@atlaskit/blanket": "^13.3.0",
|
|
41
41
|
"@atlaskit/button": "^20.1.0",
|
|
42
|
-
"@atlaskit/icon": "^22.
|
|
42
|
+
"@atlaskit/icon": "^22.17.0",
|
|
43
43
|
"@atlaskit/layering": "^0.4.0",
|
|
44
44
|
"@atlaskit/motion": "^1.9.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|