@atlaskit/drawer 7.4.7 → 7.4.8
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 +6 -0
- package/dist/cjs/components/blanket.js +3 -13
- package/dist/cjs/components/index.js +21 -60
- package/dist/cjs/components/primitives/content.js +2 -10
- package/dist/cjs/components/primitives/drawer-wrapper.js +5 -19
- package/dist/cjs/components/primitives/focus-lock.js +6 -33
- package/dist/cjs/components/primitives/hooks/use-prevent-programmatic-scroll.js +4 -12
- package/dist/cjs/components/primitives/icon-button.js +9 -11
- package/dist/cjs/components/primitives/index.js +24 -43
- package/dist/cjs/components/primitives/sidebar.js +1 -11
- package/dist/cjs/components/utils.js +4 -12
- package/dist/cjs/constants.js +0 -4
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/blanket.js +1 -4
- package/dist/es2019/components/index.js +3 -24
- package/dist/es2019/components/primitives/content.js +2 -4
- package/dist/es2019/components/primitives/drawer-wrapper.js +3 -3
- package/dist/es2019/components/primitives/focus-lock.js +2 -7
- package/dist/es2019/components/primitives/hooks/use-prevent-programmatic-scroll.js +2 -4
- package/dist/es2019/components/primitives/icon-button.js +7 -6
- package/dist/es2019/components/primitives/index.js +9 -7
- package/dist/es2019/components/primitives/sidebar.js +1 -4
- package/dist/es2019/components/utils.js +0 -5
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/blanket.js +3 -6
- package/dist/esm/components/index.js +21 -49
- package/dist/esm/components/primitives/content.js +3 -6
- package/dist/esm/components/primitives/drawer-wrapper.js +6 -11
- package/dist/esm/components/primitives/focus-lock.js +6 -22
- package/dist/esm/components/primitives/hooks/use-prevent-programmatic-scroll.js +5 -8
- package/dist/esm/components/primitives/icon-button.js +9 -8
- package/dist/esm/components/primitives/index.js +27 -31
- package/dist/esm/components/primitives/sidebar.js +2 -6
- package/dist/esm/components/utils.js +4 -10
- package/dist/esm/version.json +1 -1
- package/package.json +1 -1
|
@@ -1,61 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
-
|
|
12
9
|
var _react = require("react");
|
|
13
|
-
|
|
14
10
|
var _react2 = require("@emotion/react");
|
|
15
|
-
|
|
16
11
|
var _arrowLeft = _interopRequireDefault(require("@atlaskit/icon/glyph/arrow-left"));
|
|
17
|
-
|
|
18
12
|
var _motion = require("@atlaskit/motion");
|
|
19
|
-
|
|
20
13
|
var _constants = require("../../constants");
|
|
21
|
-
|
|
22
14
|
var _utils = require("../utils");
|
|
23
|
-
|
|
24
15
|
var _content = _interopRequireDefault(require("./content"));
|
|
25
|
-
|
|
26
16
|
var _drawerWrapper = _interopRequireDefault(require("./drawer-wrapper"));
|
|
27
|
-
|
|
28
17
|
var _focusLock = _interopRequireDefault(require("./focus-lock"));
|
|
29
|
-
|
|
30
18
|
var _iconButton = _interopRequireDefault(require("./icon-button"));
|
|
31
|
-
|
|
32
19
|
var _sidebar = _interopRequireDefault(require("./sidebar"));
|
|
33
|
-
|
|
34
20
|
var _excluded = ["component"],
|
|
35
|
-
|
|
21
|
+
_excluded2 = ["component"];
|
|
36
22
|
// Misc.
|
|
37
23
|
// ------------------------------
|
|
24
|
+
|
|
38
25
|
var defaults = {
|
|
39
26
|
Sidebar: _sidebar.default,
|
|
40
27
|
Content: _content.default
|
|
41
28
|
};
|
|
29
|
+
|
|
42
30
|
/**
|
|
43
31
|
* This wrapper is used to specify separate durations for enter and exit.
|
|
44
32
|
*/
|
|
45
|
-
|
|
46
33
|
var CustomSlideIn = function CustomSlideIn(_ref) {
|
|
47
34
|
var children = _ref.children,
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
onFinish = _ref.onFinish;
|
|
50
36
|
var _useExitingPersistenc = (0, _motion.useExitingPersistence)(),
|
|
51
|
-
|
|
37
|
+
isExiting = _useExitingPersistenc.isExiting;
|
|
38
|
+
|
|
52
39
|
/**
|
|
53
40
|
* The actual duration should be the same for both enter and exit,
|
|
54
41
|
* but motion halves the passed duration for exit animations,
|
|
55
42
|
* so we double it when exiting.
|
|
56
43
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
44
|
var duration = isExiting ? _constants.transitionDurationMs * 2 : _constants.transitionDurationMs;
|
|
60
45
|
return (0, _react2.jsx)(_motion.SlideIn, {
|
|
61
46
|
animationTimingFunction: _constants.animationTimingFunction,
|
|
@@ -66,34 +51,30 @@ var CustomSlideIn = function CustomSlideIn(_ref) {
|
|
|
66
51
|
onFinish: onFinish
|
|
67
52
|
}, children);
|
|
68
53
|
};
|
|
69
|
-
|
|
70
54
|
var DrawerPrimitive = function DrawerPrimitive(_ref2) {
|
|
71
55
|
var children = _ref2.children,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
56
|
+
Icon = _ref2.icon,
|
|
57
|
+
onClose = _ref2.onClose,
|
|
58
|
+
onCloseComplete = _ref2.onCloseComplete,
|
|
59
|
+
onOpenComplete = _ref2.onOpenComplete,
|
|
60
|
+
overrides = _ref2.overrides,
|
|
61
|
+
testId = _ref2.testId,
|
|
62
|
+
isOpen = _ref2.in,
|
|
63
|
+
shouldReturnFocus = _ref2.shouldReturnFocus,
|
|
64
|
+
autoFocusFirstElem = _ref2.autoFocusFirstElem,
|
|
65
|
+
isFocusLockEnabled = _ref2.isFocusLockEnabled,
|
|
66
|
+
width = _ref2.width;
|
|
83
67
|
var getOverrides = (0, _utils.createExtender)(defaults, overrides);
|
|
84
|
-
|
|
85
68
|
var _getOverrides = getOverrides('Sidebar'),
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
69
|
+
Sidebar = _getOverrides.component,
|
|
70
|
+
sideBarOverrides = (0, _objectWithoutProperties2.default)(_getOverrides, _excluded);
|
|
89
71
|
var _getOverrides2 = getOverrides('Content'),
|
|
90
|
-
|
|
91
|
-
|
|
72
|
+
Content = _getOverrides2.component,
|
|
73
|
+
contentOverrides = (0, _objectWithoutProperties2.default)(_getOverrides2, _excluded2);
|
|
74
|
+
|
|
92
75
|
/**
|
|
93
76
|
* A ref to point to our wrapper, passed to `onCloseComplete` and `onOpenComplete` callbacks.
|
|
94
77
|
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
78
|
var drawerRef = (0, _react.useRef)(null);
|
|
98
79
|
var onFinish = (0, _react.useCallback)(function (state) {
|
|
99
80
|
if (state === 'entering') {
|
|
@@ -126,8 +107,8 @@ var DrawerPrimitive = function DrawerPrimitive(_ref2) {
|
|
|
126
107
|
label: "Close drawer"
|
|
127
108
|
}))), (0, _react2.jsx)(Content, contentOverrides, children)));
|
|
128
109
|
}));
|
|
129
|
-
};
|
|
130
|
-
|
|
110
|
+
};
|
|
131
111
|
|
|
112
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
132
113
|
var _default = DrawerPrimitive;
|
|
133
114
|
exports.default = _default;
|
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
-
|
|
14
10
|
var _react = require("@emotion/react");
|
|
15
|
-
|
|
16
11
|
var _colors = require("@atlaskit/theme/colors");
|
|
17
|
-
|
|
18
12
|
var _constants = require("@atlaskit/theme/constants");
|
|
19
|
-
|
|
20
13
|
var _excluded = ["cssFn"];
|
|
21
14
|
var defaultStyle = {
|
|
22
15
|
alignItems: 'center',
|
|
@@ -30,20 +23,17 @@ var defaultStyle = {
|
|
|
30
23
|
paddingTop: 3 * (0, _constants.gridSize)(),
|
|
31
24
|
width: 8 * (0, _constants.gridSize)()
|
|
32
25
|
};
|
|
33
|
-
|
|
34
26
|
var sidebarCSS = function sidebarCSS() {
|
|
35
27
|
return defaultStyle;
|
|
36
28
|
};
|
|
37
|
-
|
|
38
29
|
var Sidebar = function Sidebar(_ref) {
|
|
39
30
|
var cssFn = _ref.cssFn,
|
|
40
|
-
|
|
31
|
+
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
41
32
|
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage, @repo/internal/react/no-unsafe-spread-props, @repo/internal/react/use-primitives
|
|
42
33
|
return (0, _react.jsx)("div", (0, _extends2.default)({
|
|
43
34
|
css: (0, _react.css)(cssFn(defaultStyle))
|
|
44
35
|
}, props));
|
|
45
36
|
};
|
|
46
|
-
|
|
47
37
|
var _default = {
|
|
48
38
|
component: Sidebar,
|
|
49
39
|
cssFn: sidebarCSS
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createExtender = void 0;
|
|
7
|
-
|
|
8
7
|
// eslint-disable-next-line @repo/internal/react/consistent-types-definitions
|
|
9
8
|
|
|
10
9
|
/**
|
|
@@ -12,36 +11,29 @@ exports.createExtender = void 0;
|
|
|
12
11
|
*/
|
|
13
12
|
var createExtender = function createExtender(defaults) {
|
|
14
13
|
var overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Object.create(Object.prototype);
|
|
15
|
-
|
|
16
14
|
if (!defaults) {
|
|
17
15
|
throw new Error('a default set of overrides *must* be passed in as the first argument');
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
return function getOverrides(key) {
|
|
21
18
|
var _defaults$key = defaults[key],
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
defaultCssFn = _defaults$key.cssFn,
|
|
20
|
+
defaultComponent = _defaults$key.component;
|
|
25
21
|
if (!overrides[key]) {
|
|
26
22
|
return {
|
|
27
23
|
cssFn: defaultCssFn,
|
|
28
24
|
component: defaultComponent
|
|
29
25
|
};
|
|
30
26
|
}
|
|
31
|
-
|
|
32
27
|
var _overrides$key = overrides[key],
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
customCssFn = _overrides$key.cssFn,
|
|
29
|
+
customComponent = _overrides$key.component;
|
|
36
30
|
var composedCssFn = function composedCssFn(state) {
|
|
37
31
|
return customCssFn(defaultCssFn(state), state);
|
|
38
32
|
};
|
|
39
|
-
|
|
40
33
|
return {
|
|
41
34
|
cssFn: customCssFn ? composedCssFn : defaultCssFn,
|
|
42
35
|
component: customComponent || defaultComponent
|
|
43
36
|
};
|
|
44
37
|
};
|
|
45
38
|
};
|
|
46
|
-
|
|
47
39
|
exports.createExtender = createExtender;
|
package/dist/cjs/constants.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.widths = exports.transitionTimingFunction = exports.transitionDurationMs = exports.transitionDuration = exports.defaultFocusLockSettings = exports.animationTimingFunction = void 0;
|
|
7
|
-
|
|
8
7
|
var _curves = require("@atlaskit/motion/curves");
|
|
9
|
-
|
|
10
8
|
var transitionDuration = '0.22s';
|
|
11
9
|
exports.transitionDuration = transitionDuration;
|
|
12
10
|
var transitionDurationMs = 220;
|
|
@@ -15,11 +13,9 @@ var transitionTimingFunction = _curves.easeOut;
|
|
|
15
13
|
exports.transitionTimingFunction = transitionTimingFunction;
|
|
16
14
|
var widths = ['narrow', 'medium', 'wide', 'extended', 'full'];
|
|
17
15
|
exports.widths = widths;
|
|
18
|
-
|
|
19
16
|
var animationTimingFunction = function animationTimingFunction() {
|
|
20
17
|
return _curves.easeOut;
|
|
21
18
|
};
|
|
22
|
-
|
|
23
19
|
exports.animationTimingFunction = animationTimingFunction;
|
|
24
20
|
var defaultFocusLockSettings = {
|
|
25
21
|
isFocusLockEnabled: true,
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -11,5 +10,4 @@ Object.defineProperty(exports, "default", {
|
|
|
11
10
|
return _components.default;
|
|
12
11
|
}
|
|
13
12
|
});
|
|
14
|
-
|
|
15
13
|
var _components = _interopRequireDefault(require("./components"));
|
package/dist/cjs/version.json
CHANGED
|
@@ -5,7 +5,6 @@ import AkBlanket from '@atlaskit/blanket';
|
|
|
5
5
|
import Box from '@atlaskit/ds-explorations/box';
|
|
6
6
|
import { ExitingPersistence, FadeIn } from '@atlaskit/motion';
|
|
7
7
|
import { animationTimingFunction, transitionDurationMs } from '../constants';
|
|
8
|
-
|
|
9
8
|
/**
|
|
10
9
|
* A wrapper around `@atlaskit/blanket` that adds a fade in/out transition.
|
|
11
10
|
*/
|
|
@@ -22,8 +21,7 @@ const Blanket = ({
|
|
|
22
21
|
* `opacity: 1` at `50%`.
|
|
23
22
|
*
|
|
24
23
|
* The fade out animation uses half the passed duration so it evens out.
|
|
25
|
-
|
|
26
|
-
, {
|
|
24
|
+
*/, {
|
|
27
25
|
duration: transitionDurationMs * 2
|
|
28
26
|
/**
|
|
29
27
|
* We don't expose this on `FadeIn` but it does get passed down.
|
|
@@ -43,5 +41,4 @@ const Blanket = ({
|
|
|
43
41
|
testId: testId && testId
|
|
44
42
|
}))));
|
|
45
43
|
};
|
|
46
|
-
|
|
47
44
|
export default Blanket;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
/* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
|
|
4
3
|
import React, { Component } from 'react';
|
|
5
4
|
import { canUseDOM } from 'exenv';
|
|
@@ -9,9 +8,8 @@ import { defaultFocusLockSettings } from '../constants';
|
|
|
9
8
|
import Blanket from './blanket';
|
|
10
9
|
import DrawerPrimitive from './primitives';
|
|
11
10
|
const packageName = "@atlaskit/drawer";
|
|
12
|
-
const packageVersion = "7.4.
|
|
11
|
+
const packageVersion = "7.4.8";
|
|
13
12
|
const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
14
|
-
|
|
15
13
|
const createAndFireOnClick = (createAnalyticsEvent, trigger) => createAndFireEventOnAtlaskit({
|
|
16
14
|
action: 'dismissed',
|
|
17
15
|
actionSubject: 'drawer',
|
|
@@ -22,72 +20,57 @@ const createAndFireOnClick = (createAnalyticsEvent, trigger) => createAndFireEve
|
|
|
22
20
|
trigger
|
|
23
21
|
}
|
|
24
22
|
})(createAnalyticsEvent);
|
|
25
|
-
|
|
26
23
|
export class DrawerBase extends Component {
|
|
27
24
|
constructor(...args) {
|
|
28
25
|
super(...args);
|
|
29
|
-
|
|
30
26
|
_defineProperty(this, "state", {
|
|
31
27
|
renderPortal: false
|
|
32
28
|
});
|
|
33
|
-
|
|
34
29
|
_defineProperty(this, "body", canUseDOM ? document.querySelector('body') : undefined);
|
|
35
|
-
|
|
36
30
|
_defineProperty(this, "handleBlanketClick", event => {
|
|
37
31
|
this.handleClose(event, 'blanket');
|
|
38
32
|
});
|
|
39
|
-
|
|
40
33
|
_defineProperty(this, "handleBackButtonClick", event => {
|
|
41
34
|
this.handleClose(event, 'backButton');
|
|
42
35
|
});
|
|
43
|
-
|
|
44
36
|
_defineProperty(this, "handleClose", (event, trigger) => {
|
|
45
37
|
const {
|
|
46
38
|
createAnalyticsEvent,
|
|
47
39
|
onClose
|
|
48
40
|
} = this.props;
|
|
49
41
|
const analyticsEvent = createAnalyticsEvent && createAndFireOnClick(createAnalyticsEvent, trigger);
|
|
50
|
-
|
|
51
42
|
if (onClose) {
|
|
52
43
|
onClose(event, analyticsEvent);
|
|
53
44
|
}
|
|
54
45
|
});
|
|
55
|
-
|
|
56
46
|
_defineProperty(this, "handleKeyDown", event => {
|
|
57
47
|
const {
|
|
58
48
|
isOpen,
|
|
59
49
|
onKeyDown
|
|
60
50
|
} = this.props;
|
|
61
|
-
|
|
62
51
|
if (event.key === 'Escape' && isOpen) {
|
|
63
52
|
this.handleClose(event, 'escKey');
|
|
64
53
|
}
|
|
65
|
-
|
|
66
54
|
if (onKeyDown) {
|
|
67
55
|
onKeyDown(event);
|
|
68
56
|
}
|
|
69
57
|
});
|
|
70
58
|
}
|
|
71
|
-
|
|
72
59
|
componentDidMount() {
|
|
73
60
|
const {
|
|
74
61
|
isOpen
|
|
75
62
|
} = this.props;
|
|
76
|
-
|
|
77
63
|
if (isOpen) {
|
|
78
64
|
window.addEventListener('keydown', this.handleKeyDown);
|
|
79
65
|
}
|
|
80
66
|
}
|
|
81
|
-
|
|
82
67
|
componentWillUnmount() {
|
|
83
68
|
window.removeEventListener('keydown', this.handleKeyDown);
|
|
84
69
|
}
|
|
85
|
-
|
|
86
70
|
componentDidUpdate(prevProps) {
|
|
87
71
|
const {
|
|
88
72
|
isOpen
|
|
89
73
|
} = this.props;
|
|
90
|
-
|
|
91
74
|
if (isOpen !== prevProps.isOpen) {
|
|
92
75
|
if (isOpen) {
|
|
93
76
|
window.addEventListener('keydown', this.handleKeyDown);
|
|
@@ -96,12 +79,10 @@ export class DrawerBase extends Component {
|
|
|
96
79
|
}
|
|
97
80
|
}
|
|
98
81
|
}
|
|
99
|
-
|
|
100
82
|
render() {
|
|
101
83
|
if (!this.body) {
|
|
102
84
|
return null;
|
|
103
85
|
}
|
|
104
|
-
|
|
105
86
|
const {
|
|
106
87
|
testId,
|
|
107
88
|
isOpen,
|
|
@@ -131,7 +112,8 @@ export class DrawerBase extends Component {
|
|
|
131
112
|
onCloseComplete: onCloseComplete,
|
|
132
113
|
onOpenComplete: onOpenComplete,
|
|
133
114
|
width: width,
|
|
134
|
-
shouldUnmountOnExit: shouldUnmountOnExit
|
|
115
|
+
shouldUnmountOnExit: shouldUnmountOnExit
|
|
116
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
135
117
|
,
|
|
136
118
|
overrides: overrides,
|
|
137
119
|
autoFocusFirstElem: autoFocusFirstElem,
|
|
@@ -139,14 +121,11 @@ export class DrawerBase extends Component {
|
|
|
139
121
|
shouldReturnFocus: shouldReturnFocus
|
|
140
122
|
}, children));
|
|
141
123
|
}
|
|
142
|
-
|
|
143
124
|
}
|
|
144
|
-
|
|
145
125
|
_defineProperty(DrawerBase, "defaultProps", {
|
|
146
126
|
width: 'narrow',
|
|
147
127
|
...defaultFocusLockSettings
|
|
148
128
|
});
|
|
149
|
-
|
|
150
129
|
export default withAnalyticsContext({
|
|
151
130
|
componentName: 'drawer',
|
|
152
131
|
packageName,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
3
|
+
|
|
4
4
|
import { css, jsx } from '@emotion/react';
|
|
5
5
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
6
6
|
const defaultStyles = {
|
|
@@ -8,9 +8,7 @@ const defaultStyles = {
|
|
|
8
8
|
overflow: 'auto',
|
|
9
9
|
marginTop: 3 * gridSize()
|
|
10
10
|
};
|
|
11
|
-
|
|
12
11
|
const contentCSS = () => defaultStyles;
|
|
13
|
-
|
|
14
12
|
const Content = ({
|
|
15
13
|
cssFn,
|
|
16
14
|
...props
|
|
@@ -21,11 +19,11 @@ const Content = ({
|
|
|
21
19
|
* guide suggested as it made more sense as a transformer of the current styles rather than
|
|
22
20
|
* a complete override with no chance of partially changing styles.
|
|
23
21
|
*/
|
|
22
|
+
|
|
24
23
|
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage, @repo/internal/react/no-unsafe-spread-props, @repo/internal/react/use-primitives
|
|
25
24
|
jsx("div", _extends({
|
|
26
25
|
css: css(cssFn(defaultStyles))
|
|
27
26
|
}, props));
|
|
28
|
-
|
|
29
27
|
export default {
|
|
30
28
|
component: Content,
|
|
31
29
|
cssFn: contentCSS
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
|
|
2
3
|
import { forwardRef, useCallback } from 'react';
|
|
3
4
|
import { jsx } from '@emotion/react';
|
|
4
5
|
import { useMergeRefs } from 'use-callback-ref';
|
|
@@ -27,7 +28,6 @@ const wrapperStyles = {
|
|
|
27
28
|
left: 0,
|
|
28
29
|
height: '100vh'
|
|
29
30
|
};
|
|
30
|
-
|
|
31
31
|
/**
|
|
32
32
|
* A wrapper that controls the styling of the drawer with a few hacks with refs to get our Touch±Scroll locks working.
|
|
33
33
|
*/
|
|
@@ -48,7 +48,6 @@ const DrawerWrapper = /*#__PURE__*/forwardRef(({
|
|
|
48
48
|
*/
|
|
49
49
|
const assignSecondChildRef = useCallback(node => {
|
|
50
50
|
var _node$children;
|
|
51
|
-
|
|
52
51
|
if (node !== null && node !== void 0 && (_node$children = node.children) !== null && _node$children !== void 0 && _node$children.length && typeof scrollRef === 'function') {
|
|
53
52
|
scrollRef(node.children[node.children.length - 1]);
|
|
54
53
|
}
|
|
@@ -61,7 +60,8 @@ const DrawerWrapper = /*#__PURE__*/forwardRef(({
|
|
|
61
60
|
backgroundColor: "elevation.surface.overlay",
|
|
62
61
|
overflow: "hidden",
|
|
63
62
|
layer: "blanket",
|
|
64
|
-
UNSAFE_style: {
|
|
63
|
+
UNSAFE_style: {
|
|
64
|
+
...wrapperStyles,
|
|
65
65
|
...wrapperWidth[width]
|
|
66
66
|
},
|
|
67
67
|
className: className,
|
|
@@ -12,20 +12,16 @@ export default class FocusLock extends Component {
|
|
|
12
12
|
isFocusLockEnabled,
|
|
13
13
|
autoFocusFirstElem
|
|
14
14
|
} = this.props;
|
|
15
|
-
|
|
16
15
|
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
|
|
17
16
|
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.');
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
if (typeof autoFocusFirstElem === 'function' && isFocusLockEnabled) {
|
|
21
19
|
const elem = autoFocusFirstElem();
|
|
22
|
-
|
|
23
20
|
if (elem && elem.focus) {
|
|
24
21
|
elem.focus();
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
|
-
|
|
29
25
|
render() {
|
|
30
26
|
const {
|
|
31
27
|
isFocusLockEnabled,
|
|
@@ -39,8 +35,7 @@ export default class FocusLock extends Component {
|
|
|
39
35
|
returnFocus: shouldReturnFocus
|
|
40
36
|
}, /*#__PURE__*/React.createElement(ScrollLock, null, children));
|
|
41
37
|
}
|
|
42
|
-
|
|
43
38
|
}
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
_defineProperty(FocusLock, "defaultProps", {
|
|
40
|
+
...defaultFocusLockSettings
|
|
46
41
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useLayoutEffect, useState } from 'react';
|
|
2
2
|
import { bind } from 'bind-event-listener';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* Returns how far the body is scrolled from the top of the viewport.
|
|
5
6
|
*
|
|
@@ -12,12 +13,11 @@ import { bind } from 'bind-event-listener';
|
|
|
12
13
|
*
|
|
13
14
|
* Scroll distance is the height of overflow outside the viewport.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
16
|
function getScrollDistance() {
|
|
17
17
|
var _document$documentEle, _document$body;
|
|
18
|
-
|
|
19
18
|
return window.pageYOffset || ((_document$documentEle = document.documentElement) === null || _document$documentEle === void 0 ? void 0 : _document$documentEle.scrollTop) || ((_document$body = document.body) === null || _document$body === void 0 ? void 0 : _document$body.scrollTop) || 0;
|
|
20
19
|
}
|
|
20
|
+
|
|
21
21
|
/**
|
|
22
22
|
* Prevents programmatic scrolling of the viewport with `scrollIntoView`.
|
|
23
23
|
* Should be used in conjunction with a scroll lock to prevent a user from scrolling.
|
|
@@ -26,8 +26,6 @@ function getScrollDistance() {
|
|
|
26
26
|
*
|
|
27
27
|
* @returns scroll top offset of the viewport
|
|
28
28
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
29
|
export default function usePreventProgrammaticScroll() {
|
|
32
30
|
const [scrollTopOffset, setScrollTopOffset] = useState(0);
|
|
33
31
|
useLayoutEffect(() => {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
|
|
2
3
|
import { css, jsx } from '@emotion/react';
|
|
3
4
|
import { B50, N30A } from '@atlaskit/theme/colors';
|
|
4
5
|
const iconButtonStyles = css({
|
|
5
|
-
padding: "var(--ds-
|
|
6
|
+
padding: "var(--ds-space-100, 8px)",
|
|
6
7
|
backgroundColor: 'inherit',
|
|
7
8
|
border: 'none',
|
|
8
|
-
borderRadius: "var(--ds-
|
|
9
|
+
borderRadius: "var(--ds-space-1000, 80px)",
|
|
9
10
|
color: 'inherit',
|
|
10
11
|
cursor: 'pointer',
|
|
11
12
|
lineHeight: "var(--ds-font-lineHeight-100, 1)",
|
|
@@ -16,18 +17,18 @@ const iconButtonStyles = css({
|
|
|
16
17
|
backgroundColor: `var(--ds-background-neutral-subtle-pressed, ${B50})`
|
|
17
18
|
}
|
|
18
19
|
});
|
|
19
|
-
|
|
20
20
|
const IconButton = ({
|
|
21
21
|
children,
|
|
22
22
|
onClick,
|
|
23
23
|
testId
|
|
24
|
-
}) =>
|
|
24
|
+
}) =>
|
|
25
|
+
// eslint-disable-next-line @repo/internal/react/use-primitives
|
|
25
26
|
jsx("button", {
|
|
26
27
|
type: "button",
|
|
27
28
|
css: iconButtonStyles,
|
|
28
29
|
onClick: onClick,
|
|
29
30
|
"data-testid": testId
|
|
30
|
-
}, children);
|
|
31
|
-
|
|
31
|
+
}, children);
|
|
32
32
|
|
|
33
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
33
34
|
export default IconButton;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
|
|
2
3
|
import { useCallback, useRef } from 'react';
|
|
3
4
|
import { jsx } from '@emotion/react';
|
|
4
5
|
import ArrowLeft from '@atlaskit/icon/glyph/arrow-left';
|
|
@@ -9,17 +10,19 @@ import ContentOverrides from './content';
|
|
|
9
10
|
import DrawerWrapper from './drawer-wrapper';
|
|
10
11
|
import FocusLock from './focus-lock';
|
|
11
12
|
import IconButton from './icon-button';
|
|
12
|
-
import SidebarOverrides from './sidebar';
|
|
13
|
+
import SidebarOverrides from './sidebar';
|
|
14
|
+
|
|
15
|
+
// Misc.
|
|
13
16
|
// ------------------------------
|
|
14
17
|
|
|
15
18
|
const defaults = {
|
|
16
19
|
Sidebar: SidebarOverrides,
|
|
17
20
|
Content: ContentOverrides
|
|
18
21
|
};
|
|
22
|
+
|
|
19
23
|
/**
|
|
20
24
|
* This wrapper is used to specify separate durations for enter and exit.
|
|
21
25
|
*/
|
|
22
|
-
|
|
23
26
|
const CustomSlideIn = ({
|
|
24
27
|
children,
|
|
25
28
|
onFinish
|
|
@@ -27,12 +30,12 @@ const CustomSlideIn = ({
|
|
|
27
30
|
const {
|
|
28
31
|
isExiting
|
|
29
32
|
} = useExitingPersistence();
|
|
33
|
+
|
|
30
34
|
/**
|
|
31
35
|
* The actual duration should be the same for both enter and exit,
|
|
32
36
|
* but motion halves the passed duration for exit animations,
|
|
33
37
|
* so we double it when exiting.
|
|
34
38
|
*/
|
|
35
|
-
|
|
36
39
|
const duration = isExiting ? transitionDurationMs * 2 : transitionDurationMs;
|
|
37
40
|
return jsx(SlideIn, {
|
|
38
41
|
animationTimingFunction: animationTimingFunction,
|
|
@@ -43,7 +46,6 @@ const CustomSlideIn = ({
|
|
|
43
46
|
onFinish: onFinish
|
|
44
47
|
}, children);
|
|
45
48
|
};
|
|
46
|
-
|
|
47
49
|
const DrawerPrimitive = ({
|
|
48
50
|
children,
|
|
49
51
|
icon: Icon,
|
|
@@ -67,10 +69,10 @@ const DrawerPrimitive = ({
|
|
|
67
69
|
component: Content,
|
|
68
70
|
...contentOverrides
|
|
69
71
|
} = getOverrides('Content');
|
|
72
|
+
|
|
70
73
|
/**
|
|
71
74
|
* A ref to point to our wrapper, passed to `onCloseComplete` and `onOpenComplete` callbacks.
|
|
72
75
|
*/
|
|
73
|
-
|
|
74
76
|
const drawerRef = useRef(null);
|
|
75
77
|
const onFinish = useCallback(state => {
|
|
76
78
|
if (state === 'entering') {
|
|
@@ -102,7 +104,7 @@ const DrawerPrimitive = ({
|
|
|
102
104
|
}) : jsx(ArrowLeft, {
|
|
103
105
|
label: "Close drawer"
|
|
104
106
|
}))), jsx(Content, contentOverrides, children)))));
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
+
};
|
|
107
108
|
|
|
109
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
108
110
|
export default DrawerPrimitive;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
3
|
+
|
|
4
4
|
import { css, jsx } from '@emotion/react';
|
|
5
5
|
import { N500 } from '@atlaskit/theme/colors';
|
|
6
6
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
@@ -16,9 +16,7 @@ const defaultStyle = {
|
|
|
16
16
|
paddingTop: 3 * gridSize(),
|
|
17
17
|
width: 8 * gridSize()
|
|
18
18
|
};
|
|
19
|
-
|
|
20
19
|
const sidebarCSS = () => defaultStyle;
|
|
21
|
-
|
|
22
20
|
const Sidebar = ({
|
|
23
21
|
cssFn,
|
|
24
22
|
...props
|
|
@@ -28,7 +26,6 @@ const Sidebar = ({
|
|
|
28
26
|
css: css(cssFn(defaultStyle))
|
|
29
27
|
}, props));
|
|
30
28
|
};
|
|
31
|
-
|
|
32
29
|
export default {
|
|
33
30
|
component: Sidebar,
|
|
34
31
|
cssFn: sidebarCSS
|