@atlaskit/drawer 7.1.7 → 7.1.10
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 +18 -0
- package/constants/package.json +1 -0
- package/dist/cjs/components/blanket.js +54 -0
- package/dist/cjs/components/index.js +6 -30
- package/dist/cjs/components/primitives/index.js +88 -92
- package/dist/cjs/constants.js +12 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/blanket.js +41 -0
- package/dist/es2019/components/index.js +7 -27
- package/dist/es2019/components/primitives/index.js +80 -48
- package/dist/es2019/constants.js +4 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/blanket.js +41 -0
- package/dist/esm/components/index.js +7 -28
- package/dist/esm/components/primitives/index.js +88 -89
- package/dist/esm/constants.js +6 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/components/blanket.d.ts +10 -0
- package/dist/types/components/index.d.ts +2 -2
- package/dist/types/components/primitives/index.d.ts +3 -4
- package/dist/types/components/types.d.ts +8 -5
- package/dist/types/constants.d.ts +2 -1
- package/package.json +7 -5
- package/dist/cjs/components/transitions.js +0 -185
- package/dist/es2019/components/transitions.js +0 -118
- package/dist/esm/components/transitions.js +0 -161
- package/dist/types/components/transitions.d.ts +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/drawer
|
|
2
2
|
|
|
3
|
+
## 7.1.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 7.1.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`45e0af67ad3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/45e0af67ad3) - Internal change to make styles statically analyzable
|
|
14
|
+
|
|
15
|
+
## 7.1.8
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`cb2392f6d33`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cb2392f6d33) - Upgrade to TypeScript 4.2.4
|
|
20
|
+
|
|
3
21
|
## 7.1.7
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/constants/package.json
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _blanket = _interopRequireDefault(require("@atlaskit/blanket"));
|
|
13
|
+
|
|
14
|
+
var _motion = require("@atlaskit/motion");
|
|
15
|
+
|
|
16
|
+
var _constants = require("../constants");
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A wrapper around `@atlaskit/blanket` that adds a fade in/out transition.
|
|
20
|
+
*/
|
|
21
|
+
var Blanket = function Blanket(_ref) {
|
|
22
|
+
var isOpen = _ref.isOpen,
|
|
23
|
+
onBlanketClicked = _ref.onBlanketClicked;
|
|
24
|
+
return /*#__PURE__*/_react.default.createElement(_motion.ExitingPersistence, {
|
|
25
|
+
appear: true
|
|
26
|
+
}, isOpen && /*#__PURE__*/_react.default.createElement(_motion.FadeIn
|
|
27
|
+
/**
|
|
28
|
+
* We double the duration because the fade in keyframes have
|
|
29
|
+
* `opacity: 1` at `50%`.
|
|
30
|
+
*
|
|
31
|
+
* The fade out animation uses half the passed duration so it evens out.
|
|
32
|
+
*/
|
|
33
|
+
, {
|
|
34
|
+
duration: _constants.transitionDurationMs * 2
|
|
35
|
+
/**
|
|
36
|
+
* We don't expose this on `FadeIn` but it does get passed down.
|
|
37
|
+
* TODO: figure out how we want to handle this...
|
|
38
|
+
*/
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
,
|
|
41
|
+
animationTimingFunction: _constants.animationTimingFunction
|
|
42
|
+
}, function (_ref2) {
|
|
43
|
+
var className = _ref2.className;
|
|
44
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
45
|
+
className: className
|
|
46
|
+
}, /*#__PURE__*/_react.default.createElement(_blanket.default, {
|
|
47
|
+
isTinted: true,
|
|
48
|
+
onBlanketClicked: onBlanketClicked
|
|
49
|
+
}));
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var _default = Blanket;
|
|
54
|
+
exports.default = _default;
|
|
@@ -27,22 +27,16 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
27
27
|
|
|
28
28
|
var _exenv = require("exenv");
|
|
29
29
|
|
|
30
|
-
var _reactTransitionGroup = require("react-transition-group");
|
|
31
|
-
|
|
32
30
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
33
31
|
|
|
34
|
-
var _blanket = _interopRequireDefault(require("@atlaskit/blanket"));
|
|
35
|
-
|
|
36
32
|
var _portal = _interopRequireDefault(require("@atlaskit/portal"));
|
|
37
33
|
|
|
38
|
-
var
|
|
34
|
+
var _blanket = _interopRequireDefault(require("./blanket"));
|
|
39
35
|
|
|
40
36
|
var _focusLock = _interopRequireDefault(require("./focus-lock"));
|
|
41
37
|
|
|
42
38
|
var _primitives = _interopRequireDefault(require("./primitives"));
|
|
43
39
|
|
|
44
|
-
var _transitions = require("./transitions");
|
|
45
|
-
|
|
46
40
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
47
41
|
|
|
48
42
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -52,13 +46,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
52
46
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
53
47
|
|
|
54
48
|
var packageName = "@atlaskit/drawer";
|
|
55
|
-
var packageVersion = "7.1.
|
|
56
|
-
|
|
57
|
-
var OnlyChild = function OnlyChild(_ref) {
|
|
58
|
-
var children = _ref.children;
|
|
59
|
-
return _react.Children.toArray(children)[0] || null;
|
|
60
|
-
};
|
|
61
|
-
|
|
49
|
+
var packageVersion = "7.1.10";
|
|
62
50
|
var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
|
|
63
51
|
|
|
64
52
|
var createAndFireOnClick = function createAndFireOnClick(createAnalyticsEvent, trigger) {
|
|
@@ -172,24 +160,12 @@ var DrawerBase = /*#__PURE__*/function (_Component) {
|
|
|
172
160
|
isFocusLockEnabled = _this$props3.isFocusLockEnabled,
|
|
173
161
|
shouldReturnFocus = _this$props3.shouldReturnFocus,
|
|
174
162
|
overrides = _this$props3.overrides;
|
|
175
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
176
|
-
in: isOpen,
|
|
177
|
-
timeout: {
|
|
178
|
-
enter: 0,
|
|
179
|
-
exit: _constants.transitionDurationMs
|
|
180
|
-
},
|
|
181
|
-
mountOnEnter: true,
|
|
182
|
-
unmountOnExit: true
|
|
183
|
-
}, /*#__PURE__*/_react.default.createElement(_portal.default, {
|
|
163
|
+
return /*#__PURE__*/_react.default.createElement(_portal.default, {
|
|
184
164
|
zIndex: "unset"
|
|
185
|
-
}, /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.TransitionGroup, {
|
|
186
|
-
component: OnlyChild
|
|
187
|
-
}, /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_transitions.Fade, {
|
|
188
|
-
in: isOpen
|
|
189
165
|
}, /*#__PURE__*/_react.default.createElement(_blanket.default, {
|
|
190
|
-
|
|
166
|
+
isOpen: isOpen,
|
|
191
167
|
onBlanketClicked: this.handleBlanketClick
|
|
192
|
-
})
|
|
168
|
+
}), /*#__PURE__*/_react.default.createElement(_focusLock.default, {
|
|
193
169
|
autoFocusFirstElem: autoFocusFirstElem,
|
|
194
170
|
isFocusLockEnabled: isFocusLockEnabled,
|
|
195
171
|
shouldReturnFocus: shouldReturnFocus
|
|
@@ -203,7 +179,7 @@ var DrawerBase = /*#__PURE__*/function (_Component) {
|
|
|
203
179
|
width: width,
|
|
204
180
|
shouldUnmountOnExit: shouldUnmountOnExit,
|
|
205
181
|
overrides: overrides
|
|
206
|
-
}, children)))
|
|
182
|
+
}, children)));
|
|
207
183
|
}
|
|
208
184
|
}]);
|
|
209
185
|
return DrawerBase;
|
|
@@ -7,20 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
-
|
|
16
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
-
|
|
18
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
-
|
|
20
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
21
|
-
|
|
22
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
25
11
|
|
|
26
12
|
var _react = require("react");
|
|
@@ -29,11 +15,13 @@ var _core = require("@emotion/core");
|
|
|
29
15
|
|
|
30
16
|
var _arrowLeft = _interopRequireDefault(require("@atlaskit/icon/glyph/arrow-left"));
|
|
31
17
|
|
|
18
|
+
var _motion = require("@atlaskit/motion");
|
|
19
|
+
|
|
32
20
|
var _colors = require("@atlaskit/theme/colors");
|
|
33
21
|
|
|
34
22
|
var _constants = require("@atlaskit/theme/constants");
|
|
35
23
|
|
|
36
|
-
var
|
|
24
|
+
var _constants2 = require("../../constants");
|
|
37
25
|
|
|
38
26
|
var _utils = require("../utils");
|
|
39
27
|
|
|
@@ -43,19 +31,9 @@ var _iconButton = _interopRequireDefault(require("./icon-button"));
|
|
|
43
31
|
|
|
44
32
|
var _sidebar = _interopRequireDefault(require("./sidebar"));
|
|
45
33
|
|
|
46
|
-
var _excluded = ["
|
|
47
|
-
_excluded2 = ["
|
|
48
|
-
_excluded3 = ["component"]
|
|
49
|
-
_excluded4 = ["component"];
|
|
50
|
-
|
|
51
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
52
|
-
|
|
53
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
54
|
-
|
|
55
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
56
|
-
|
|
57
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
58
|
-
|
|
34
|
+
var _excluded = ["children", "icon", "onClose", "onCloseComplete", "onOpenComplete", "overrides", "testId", "in"],
|
|
35
|
+
_excluded2 = ["component"],
|
|
36
|
+
_excluded3 = ["component"];
|
|
59
37
|
// Misc.
|
|
60
38
|
// ------------------------------
|
|
61
39
|
var widths = {
|
|
@@ -75,74 +53,92 @@ var wrapperStyles = (0, _core.css)({
|
|
|
75
53
|
backgroundColor: "var(--ds-surface-overlay, ".concat(_colors.N0, ")"),
|
|
76
54
|
overflow: 'hidden'
|
|
77
55
|
});
|
|
78
|
-
|
|
79
|
-
var Wrapper = function Wrapper(_ref) {
|
|
80
|
-
var _ref$width = _ref.width,
|
|
81
|
-
width = _ref$width === void 0 ? 'narrow' : _ref$width,
|
|
82
|
-
shouldUnmountOnExit = _ref.shouldUnmountOnExit,
|
|
83
|
-
style = _ref.style,
|
|
84
|
-
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
85
|
-
return (0, _core.jsx)("div", (0, _extends2.default)({
|
|
86
|
-
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
87
|
-
width: widths[width]
|
|
88
|
-
}),
|
|
89
|
-
css: wrapperStyles
|
|
90
|
-
}, props));
|
|
91
|
-
};
|
|
92
|
-
|
|
93
56
|
var defaults = {
|
|
94
57
|
Sidebar: _sidebar.default,
|
|
95
58
|
Content: _content.default
|
|
96
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* This wrapper is used to specify separate durations for enter and exit.
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
var CustomSlideIn = function CustomSlideIn(_ref) {
|
|
65
|
+
var children = _ref.children,
|
|
66
|
+
onFinish = _ref.onFinish;
|
|
67
|
+
|
|
68
|
+
var _useExitingPersistenc = (0, _motion.useExitingPersistence)(),
|
|
69
|
+
isExiting = _useExitingPersistenc.isExiting;
|
|
70
|
+
/**
|
|
71
|
+
* The actual duration should be the same for both enter and exit,
|
|
72
|
+
* but motion halves the passed duration for exit animations,
|
|
73
|
+
* so we double it when exiting.
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
var duration = isExiting ? _constants2.transitionDurationMs * 2 : _constants2.transitionDurationMs;
|
|
78
|
+
return (0, _core.jsx)(_motion.SlideIn, {
|
|
79
|
+
animationTimingFunction: _constants2.animationTimingFunction,
|
|
80
|
+
duration: duration,
|
|
81
|
+
enterFrom: "left",
|
|
82
|
+
exitTo: "left",
|
|
83
|
+
fade: "none",
|
|
84
|
+
onFinish: onFinish
|
|
85
|
+
}, children);
|
|
86
|
+
};
|
|
97
87
|
|
|
98
|
-
var DrawerPrimitive =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
(0,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
sideBarOverrides = (0, _objectWithoutProperties2.default)(_getOverrides, _excluded3);
|
|
125
|
-
|
|
126
|
-
var _getOverrides2 = getOverrides('Content'),
|
|
127
|
-
Content = _getOverrides2.component,
|
|
128
|
-
contentOverrides = (0, _objectWithoutProperties2.default)(_getOverrides2, _excluded4);
|
|
129
|
-
|
|
130
|
-
return (0, _core.jsx)(_transitions.Slide, (0, _extends2.default)({
|
|
131
|
-
component: Wrapper,
|
|
132
|
-
onExited: onCloseComplete,
|
|
133
|
-
onEntered: onOpenComplete,
|
|
134
|
-
"data-testid": testId
|
|
135
|
-
}, props), (0, _core.jsx)(Sidebar, sideBarOverrides, (0, _core.jsx)(_iconButton.default, {
|
|
136
|
-
onClick: onClose,
|
|
137
|
-
testId: testId && 'DrawerPrimitiveSidebarCloseButton'
|
|
138
|
-
}, Icon ? (0, _core.jsx)(Icon, {
|
|
139
|
-
size: "large"
|
|
140
|
-
}) : (0, _core.jsx)(_arrowLeft.default, {
|
|
141
|
-
label: "Close drawer"
|
|
142
|
-
}))), (0, _core.jsx)(Content, contentOverrides, children));
|
|
88
|
+
var DrawerPrimitive = function DrawerPrimitive(_ref2) {
|
|
89
|
+
var children = _ref2.children,
|
|
90
|
+
Icon = _ref2.icon,
|
|
91
|
+
onClose = _ref2.onClose,
|
|
92
|
+
onCloseComplete = _ref2.onCloseComplete,
|
|
93
|
+
onOpenComplete = _ref2.onOpenComplete,
|
|
94
|
+
overrides = _ref2.overrides,
|
|
95
|
+
testId = _ref2.testId,
|
|
96
|
+
isOpen = _ref2.in,
|
|
97
|
+
props = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
|
|
98
|
+
var getOverrides = (0, _utils.createExtender)(defaults, overrides);
|
|
99
|
+
|
|
100
|
+
var _getOverrides = getOverrides('Sidebar'),
|
|
101
|
+
Sidebar = _getOverrides.component,
|
|
102
|
+
sideBarOverrides = (0, _objectWithoutProperties2.default)(_getOverrides, _excluded2);
|
|
103
|
+
|
|
104
|
+
var _getOverrides2 = getOverrides('Content'),
|
|
105
|
+
Content = _getOverrides2.component,
|
|
106
|
+
contentOverrides = (0, _objectWithoutProperties2.default)(_getOverrides2, _excluded3);
|
|
107
|
+
|
|
108
|
+
var ref = (0, _react.useRef)(null);
|
|
109
|
+
var onFinish = (0, _react.useCallback)(function (state) {
|
|
110
|
+
if (state === 'entering') {
|
|
111
|
+
onOpenComplete === null || onOpenComplete === void 0 ? void 0 : onOpenComplete(ref.current);
|
|
112
|
+
} else if (state === 'exiting') {
|
|
113
|
+
onCloseComplete === null || onCloseComplete === void 0 ? void 0 : onCloseComplete(ref.current);
|
|
143
114
|
}
|
|
144
|
-
}]);
|
|
145
|
-
return
|
|
146
|
-
|
|
115
|
+
}, [onCloseComplete, onOpenComplete]);
|
|
116
|
+
return (0, _core.jsx)(_motion.ExitingPersistence, {
|
|
117
|
+
appear: true
|
|
118
|
+
}, isOpen && (0, _core.jsx)(CustomSlideIn, {
|
|
119
|
+
onFinish: onFinish
|
|
120
|
+
}, function (_ref3) {
|
|
121
|
+
var _props$width;
|
|
122
|
+
|
|
123
|
+
var className = _ref3.className;
|
|
124
|
+
return (0, _core.jsx)("div", {
|
|
125
|
+
className: className,
|
|
126
|
+
css: wrapperStyles,
|
|
127
|
+
style: {
|
|
128
|
+
width: widths[(_props$width = props.width) !== null && _props$width !== void 0 ? _props$width : 'narrow']
|
|
129
|
+
},
|
|
130
|
+
"data-testid": testId,
|
|
131
|
+
ref: ref
|
|
132
|
+
}, (0, _core.jsx)(Sidebar, sideBarOverrides, (0, _core.jsx)(_iconButton.default, {
|
|
133
|
+
onClick: onClose,
|
|
134
|
+
testId: testId && 'DrawerPrimitiveSidebarCloseButton'
|
|
135
|
+
}, Icon ? (0, _core.jsx)(Icon, {
|
|
136
|
+
size: "large"
|
|
137
|
+
}) : (0, _core.jsx)(_arrowLeft.default, {
|
|
138
|
+
label: "Close drawer"
|
|
139
|
+
}))), (0, _core.jsx)(Content, contentOverrides, children));
|
|
140
|
+
}));
|
|
141
|
+
};
|
|
147
142
|
|
|
148
|
-
|
|
143
|
+
var _default = DrawerPrimitive;
|
|
144
|
+
exports.default = _default;
|
package/dist/cjs/constants.js
CHANGED
|
@@ -3,12 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.widths = exports.transitionTimingFunction = exports.transitionDurationMs = exports.transitionDuration = void 0;
|
|
6
|
+
exports.widths = exports.transitionTimingFunction = exports.transitionDurationMs = exports.transitionDuration = exports.animationTimingFunction = void 0;
|
|
7
|
+
|
|
8
|
+
var _curves = require("@atlaskit/motion/curves");
|
|
9
|
+
|
|
7
10
|
var transitionDuration = '0.22s';
|
|
8
11
|
exports.transitionDuration = transitionDuration;
|
|
9
12
|
var transitionDurationMs = 220;
|
|
10
13
|
exports.transitionDurationMs = transitionDurationMs;
|
|
11
|
-
var transitionTimingFunction =
|
|
14
|
+
var transitionTimingFunction = _curves.easeOut;
|
|
12
15
|
exports.transitionTimingFunction = transitionTimingFunction;
|
|
13
16
|
var widths = ['narrow', 'medium', 'wide', 'extended', 'full'];
|
|
14
|
-
exports.widths = widths;
|
|
17
|
+
exports.widths = widths;
|
|
18
|
+
|
|
19
|
+
var animationTimingFunction = function animationTimingFunction() {
|
|
20
|
+
return _curves.easeOut;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.animationTimingFunction = animationTimingFunction;
|
package/dist/cjs/version.json
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import AkBlanket from '@atlaskit/blanket';
|
|
3
|
+
import { ExitingPersistence, FadeIn } from '@atlaskit/motion';
|
|
4
|
+
import { animationTimingFunction, transitionDurationMs } from '../constants';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A wrapper around `@atlaskit/blanket` that adds a fade in/out transition.
|
|
8
|
+
*/
|
|
9
|
+
const Blanket = ({
|
|
10
|
+
isOpen,
|
|
11
|
+
onBlanketClicked
|
|
12
|
+
}) => {
|
|
13
|
+
return /*#__PURE__*/React.createElement(ExitingPersistence, {
|
|
14
|
+
appear: true
|
|
15
|
+
}, isOpen && /*#__PURE__*/React.createElement(FadeIn
|
|
16
|
+
/**
|
|
17
|
+
* We double the duration because the fade in keyframes have
|
|
18
|
+
* `opacity: 1` at `50%`.
|
|
19
|
+
*
|
|
20
|
+
* The fade out animation uses half the passed duration so it evens out.
|
|
21
|
+
*/
|
|
22
|
+
, {
|
|
23
|
+
duration: transitionDurationMs * 2
|
|
24
|
+
/**
|
|
25
|
+
* We don't expose this on `FadeIn` but it does get passed down.
|
|
26
|
+
* TODO: figure out how we want to handle this...
|
|
27
|
+
*/
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
,
|
|
30
|
+
animationTimingFunction: animationTimingFunction
|
|
31
|
+
}, ({
|
|
32
|
+
className
|
|
33
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
className: className
|
|
35
|
+
}, /*#__PURE__*/React.createElement(AkBlanket, {
|
|
36
|
+
isTinted: true,
|
|
37
|
+
onBlanketClicked: onBlanketClicked
|
|
38
|
+
}))));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default Blanket;
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
3
|
import { canUseDOM } from 'exenv';
|
|
4
|
-
import { Transition, TransitionGroup } from 'react-transition-group';
|
|
5
4
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
6
|
-
import Blanket from '@atlaskit/blanket';
|
|
7
5
|
import Portal from '@atlaskit/portal';
|
|
8
|
-
import
|
|
6
|
+
import Blanket from './blanket';
|
|
9
7
|
import FocusLock from './focus-lock';
|
|
10
8
|
import DrawerPrimitive from './primitives';
|
|
11
|
-
import { Fade } from './transitions';
|
|
12
9
|
const packageName = "@atlaskit/drawer";
|
|
13
|
-
const packageVersion = "7.1.
|
|
14
|
-
|
|
15
|
-
const OnlyChild = ({
|
|
16
|
-
children
|
|
17
|
-
}) => Children.toArray(children)[0] || null;
|
|
18
|
-
|
|
10
|
+
const packageVersion = "7.1.10";
|
|
19
11
|
const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
20
12
|
|
|
21
13
|
const createAndFireOnClick = (createAnalyticsEvent, trigger) => createAndFireEventOnAtlaskit({
|
|
@@ -122,24 +114,12 @@ export class DrawerBase extends Component {
|
|
|
122
114
|
shouldReturnFocus,
|
|
123
115
|
overrides
|
|
124
116
|
} = this.props;
|
|
125
|
-
return /*#__PURE__*/React.createElement(
|
|
126
|
-
in: isOpen,
|
|
127
|
-
timeout: {
|
|
128
|
-
enter: 0,
|
|
129
|
-
exit: transitionDurationMs
|
|
130
|
-
},
|
|
131
|
-
mountOnEnter: true,
|
|
132
|
-
unmountOnExit: true
|
|
133
|
-
}, /*#__PURE__*/React.createElement(Portal, {
|
|
117
|
+
return /*#__PURE__*/React.createElement(Portal, {
|
|
134
118
|
zIndex: "unset"
|
|
135
|
-
}, /*#__PURE__*/React.createElement(TransitionGroup, {
|
|
136
|
-
component: OnlyChild
|
|
137
|
-
}, /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Fade, {
|
|
138
|
-
in: isOpen
|
|
139
119
|
}, /*#__PURE__*/React.createElement(Blanket, {
|
|
140
|
-
|
|
120
|
+
isOpen: isOpen,
|
|
141
121
|
onBlanketClicked: this.handleBlanketClick
|
|
142
|
-
})
|
|
122
|
+
}), /*#__PURE__*/React.createElement(FocusLock, {
|
|
143
123
|
autoFocusFirstElem: autoFocusFirstElem,
|
|
144
124
|
isFocusLockEnabled: isFocusLockEnabled,
|
|
145
125
|
shouldReturnFocus: shouldReturnFocus
|
|
@@ -153,7 +133,7 @@ export class DrawerBase extends Component {
|
|
|
153
133
|
width: width,
|
|
154
134
|
shouldUnmountOnExit: shouldUnmountOnExit,
|
|
155
135
|
overrides: overrides
|
|
156
|
-
}, children)))
|
|
136
|
+
}, children)));
|
|
157
137
|
}
|
|
158
138
|
|
|
159
139
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
1
|
/** @jsx jsx */
|
|
4
|
-
import {
|
|
2
|
+
import { useCallback, useRef } from 'react';
|
|
5
3
|
import { css, jsx } from '@emotion/core';
|
|
6
4
|
import ArrowLeft from '@atlaskit/icon/glyph/arrow-left';
|
|
5
|
+
import { ExitingPersistence, SlideIn, useExitingPersistence } from '@atlaskit/motion';
|
|
7
6
|
import { N0 } from '@atlaskit/theme/colors';
|
|
8
7
|
import { gridSize, layers } from '@atlaskit/theme/constants';
|
|
9
|
-
import {
|
|
8
|
+
import { animationTimingFunction, transitionDurationMs } from '../../constants';
|
|
10
9
|
import { createExtender } from '../utils';
|
|
11
10
|
import ContentOverrides from './content';
|
|
12
11
|
import IconButton from './icon-button';
|
|
@@ -30,52 +29,84 @@ const wrapperStyles = css({
|
|
|
30
29
|
backgroundColor: `var(--ds-surface-overlay, ${N0})`,
|
|
31
30
|
overflow: 'hidden'
|
|
32
31
|
});
|
|
33
|
-
|
|
34
|
-
const Wrapper = ({
|
|
35
|
-
width = 'narrow',
|
|
36
|
-
shouldUnmountOnExit,
|
|
37
|
-
style,
|
|
38
|
-
...props
|
|
39
|
-
}) => {
|
|
40
|
-
return jsx("div", _extends({
|
|
41
|
-
style: { ...style,
|
|
42
|
-
width: widths[width]
|
|
43
|
-
},
|
|
44
|
-
css: wrapperStyles
|
|
45
|
-
}, props));
|
|
46
|
-
};
|
|
47
|
-
|
|
48
32
|
const defaults = {
|
|
49
33
|
Sidebar: SidebarOverrides,
|
|
50
34
|
Content: ContentOverrides
|
|
51
35
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
36
|
+
/**
|
|
37
|
+
* This wrapper is used to specify separate durations for enter and exit.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
const CustomSlideIn = ({
|
|
41
|
+
children,
|
|
42
|
+
onFinish
|
|
43
|
+
}) => {
|
|
44
|
+
const {
|
|
45
|
+
isExiting
|
|
46
|
+
} = useExitingPersistence();
|
|
47
|
+
/**
|
|
48
|
+
* The actual duration should be the same for both enter and exit,
|
|
49
|
+
* but motion halves the passed duration for exit animations,
|
|
50
|
+
* so we double it when exiting.
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
const duration = isExiting ? transitionDurationMs * 2 : transitionDurationMs;
|
|
54
|
+
return jsx(SlideIn, {
|
|
55
|
+
animationTimingFunction: animationTimingFunction,
|
|
56
|
+
duration: duration,
|
|
57
|
+
enterFrom: "left",
|
|
58
|
+
exitTo: "left",
|
|
59
|
+
fade: "none",
|
|
60
|
+
onFinish: onFinish
|
|
61
|
+
}, children);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const DrawerPrimitive = ({
|
|
65
|
+
children,
|
|
66
|
+
icon: Icon,
|
|
67
|
+
onClose,
|
|
68
|
+
onCloseComplete,
|
|
69
|
+
onOpenComplete,
|
|
70
|
+
overrides,
|
|
71
|
+
testId,
|
|
72
|
+
in: isOpen,
|
|
73
|
+
...props
|
|
74
|
+
}) => {
|
|
75
|
+
const getOverrides = createExtender(defaults, overrides);
|
|
76
|
+
const {
|
|
77
|
+
component: Sidebar,
|
|
78
|
+
...sideBarOverrides
|
|
79
|
+
} = getOverrides('Sidebar');
|
|
80
|
+
const {
|
|
81
|
+
component: Content,
|
|
82
|
+
...contentOverrides
|
|
83
|
+
} = getOverrides('Content');
|
|
84
|
+
const ref = useRef(null);
|
|
85
|
+
const onFinish = useCallback(state => {
|
|
86
|
+
if (state === 'entering') {
|
|
87
|
+
onOpenComplete === null || onOpenComplete === void 0 ? void 0 : onOpenComplete(ref.current);
|
|
88
|
+
} else if (state === 'exiting') {
|
|
89
|
+
onCloseComplete === null || onCloseComplete === void 0 ? void 0 : onCloseComplete(ref.current);
|
|
90
|
+
}
|
|
91
|
+
}, [onCloseComplete, onOpenComplete]);
|
|
92
|
+
return jsx(ExitingPersistence, {
|
|
93
|
+
appear: true
|
|
94
|
+
}, isOpen && jsx(CustomSlideIn, {
|
|
95
|
+
onFinish: onFinish
|
|
96
|
+
}, ({
|
|
97
|
+
className
|
|
98
|
+
}) => {
|
|
99
|
+
var _props$width;
|
|
100
|
+
|
|
101
|
+
return jsx("div", {
|
|
102
|
+
className: className,
|
|
103
|
+
css: wrapperStyles,
|
|
104
|
+
style: {
|
|
105
|
+
width: widths[(_props$width = props.width) !== null && _props$width !== void 0 ? _props$width : 'narrow']
|
|
106
|
+
},
|
|
107
|
+
"data-testid": testId,
|
|
108
|
+
ref: ref
|
|
109
|
+
}, jsx(Sidebar, sideBarOverrides, jsx(IconButton, {
|
|
79
110
|
onClick: onClose,
|
|
80
111
|
testId: testId && 'DrawerPrimitiveSidebarCloseButton'
|
|
81
112
|
}, Icon ? jsx(Icon, {
|
|
@@ -83,6 +114,7 @@ export default class DrawerPrimitive extends Component {
|
|
|
83
114
|
}) : jsx(ArrowLeft, {
|
|
84
115
|
label: "Close drawer"
|
|
85
116
|
}))), jsx(Content, contentOverrides, children));
|
|
86
|
-
}
|
|
117
|
+
}));
|
|
118
|
+
};
|
|
87
119
|
|
|
88
|
-
|
|
120
|
+
export default DrawerPrimitive;
|