@atlaskit/drawer 7.10.0 → 7.11.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 +697 -691
- package/dist/cjs/components/blanket.js +11 -8
- package/dist/cjs/components/index.js +4 -2
- package/dist/cjs/components/primitives/content.js +37 -14
- package/dist/cjs/components/primitives/drawer-wrapper.js +6 -2
- package/dist/cjs/components/primitives/index.js +7 -2
- package/dist/es2019/components/blanket.js +3 -1
- package/dist/es2019/components/index.js +4 -2
- package/dist/es2019/components/primitives/content.js +32 -11
- package/dist/es2019/components/primitives/drawer-wrapper.js +6 -2
- package/dist/es2019/components/primitives/index.js +7 -2
- package/dist/esm/components/blanket.js +11 -8
- package/dist/esm/components/index.js +4 -2
- package/dist/esm/components/primitives/content.js +36 -13
- package/dist/esm/components/primitives/drawer-wrapper.js +6 -2
- package/dist/esm/components/primitives/index.js +7 -2
- package/dist/types/components/index.d.ts +2 -2
- package/dist/types/components/primitives/content.d.ts +1 -1
- package/dist/types/components/primitives/index.d.ts +1 -1
- package/dist/types/components/types.d.ts +8 -0
- package/dist/types-ts4.5/components/index.d.ts +2 -2
- package/dist/types-ts4.5/components/primitives/content.d.ts +1 -1
- package/dist/types-ts4.5/components/primitives/index.d.ts +1 -1
- package/dist/types-ts4.5/components/types.d.ts +8 -0
- package/package.json +2 -4
|
@@ -42,14 +42,17 @@ var Blanket = function Blanket(_ref) {
|
|
|
42
42
|
animationTimingFunction: _constants.animationTimingFunction
|
|
43
43
|
}, function (_ref2) {
|
|
44
44
|
var className = _ref2.className;
|
|
45
|
-
return (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
return (
|
|
46
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
47
|
+
(0, _react2.jsx)("div", {
|
|
48
|
+
css: blanketStyles,
|
|
49
|
+
className: className
|
|
50
|
+
}, (0, _react2.jsx)(_blanket.default, {
|
|
51
|
+
isTinted: true,
|
|
52
|
+
onBlanketClicked: onBlanketClicked,
|
|
53
|
+
testId: testId && testId
|
|
54
|
+
}))
|
|
55
|
+
);
|
|
53
56
|
}));
|
|
54
57
|
};
|
|
55
58
|
var _default = exports.default = Blanket;
|
|
@@ -27,7 +27,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
27
27
|
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); }; }
|
|
28
28
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
|
|
29
29
|
var packageName = "@atlaskit/drawer";
|
|
30
|
-
var packageVersion = "7.
|
|
30
|
+
var packageVersion = "7.11.0";
|
|
31
31
|
var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
|
|
32
32
|
var createAndFireOnClick = function createAndFireOnClick(createAnalyticsEvent, trigger) {
|
|
33
33
|
return createAndFireEventOnAtlaskit({
|
|
@@ -120,6 +120,7 @@ var DrawerBase = exports.DrawerBase = /*#__PURE__*/function (_Component) {
|
|
|
120
120
|
children = _this$props3.children,
|
|
121
121
|
icon = _this$props3.icon,
|
|
122
122
|
closeLabel = _this$props3.closeLabel,
|
|
123
|
+
scrollContentLabel = _this$props3.scrollContentLabel,
|
|
123
124
|
width = _this$props3.width,
|
|
124
125
|
shouldUnmountOnExit = _this$props3.shouldUnmountOnExit,
|
|
125
126
|
onCloseComplete = _this$props3.onCloseComplete,
|
|
@@ -155,7 +156,8 @@ var DrawerBase = exports.DrawerBase = /*#__PURE__*/function (_Component) {
|
|
|
155
156
|
overrides: overrides,
|
|
156
157
|
autoFocusFirstElem: autoFocusFirstElem,
|
|
157
158
|
isFocusLockEnabled: isFocusLockEnabled,
|
|
158
|
-
shouldReturnFocus: shouldReturnFocus
|
|
159
|
+
shouldReturnFocus: shouldReturnFocus,
|
|
160
|
+
scrollContentLabel: scrollContentLabel
|
|
159
161
|
}, children));
|
|
160
162
|
}
|
|
161
163
|
}]);
|
|
@@ -6,9 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
-
var _react = require("
|
|
11
|
-
var
|
|
11
|
+
var _react = require("react");
|
|
12
|
+
var _react2 = require("@emotion/react");
|
|
13
|
+
var _excluded = ["cssFn", "scrollContentLabel"];
|
|
12
14
|
/** @jsx jsx */
|
|
13
15
|
var defaultStyles = {
|
|
14
16
|
flex: 1,
|
|
@@ -20,20 +22,41 @@ var contentCSS = function contentCSS() {
|
|
|
20
22
|
};
|
|
21
23
|
var Content = function Content(_ref) {
|
|
22
24
|
var cssFn = _ref.cssFn,
|
|
25
|
+
_ref$scrollContentLab = _ref.scrollContentLabel,
|
|
26
|
+
scrollContentLabel = _ref$scrollContentLab === void 0 ? 'Scrollable content' : _ref$scrollContentLab,
|
|
23
27
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
var _useState = (0, _react.useState)(false),
|
|
29
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
30
|
+
showContentFocus = _useState2[0],
|
|
31
|
+
setContentFocus = _useState2[1];
|
|
32
|
+
var scrollableRef = (0, _react.useRef)(null);
|
|
33
|
+
(0, _react.useEffect)(function () {
|
|
34
|
+
var setLazyContentFocus = function setLazyContentFocus() {
|
|
35
|
+
var target = scrollableRef.current;
|
|
36
|
+
target && setContentFocus(target.scrollHeight > target.clientHeight);
|
|
37
|
+
};
|
|
38
|
+
setLazyContentFocus();
|
|
39
|
+
}, []);
|
|
31
40
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
/**
|
|
42
|
+
* I noticed the implementation at @atlaskit/checkbox would send the props to cssFn rather
|
|
43
|
+
* than the defaultStyles as the overrides guide suggests. I went with what the overrides
|
|
44
|
+
* guide suggested as it made more sense as a transformer of the current styles rather than
|
|
45
|
+
* a complete override with no chance of partially changing styles.
|
|
46
|
+
*/
|
|
47
|
+
return (0, _react2.jsx)("div", (0, _extends2.default)({
|
|
48
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
49
|
+
css: (0, _react2.css)(cssFn(defaultStyles)),
|
|
50
|
+
ref: scrollableRef
|
|
51
|
+
// tabindex is allowed here so that keyboard users can scroll content
|
|
52
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
53
|
+
,
|
|
54
|
+
tabIndex: showContentFocus ? 0 : undefined,
|
|
55
|
+
role: showContentFocus ? 'region' : undefined,
|
|
56
|
+
"aria-label": showContentFocus ? scrollContentLabel : undefined,
|
|
57
|
+
"data-testId": "drawer-contents"
|
|
58
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
59
|
+
}, props));
|
|
37
60
|
};
|
|
38
61
|
var _default = exports.default = {
|
|
39
62
|
component: Content,
|
|
@@ -67,8 +67,12 @@ var DrawerWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, scrollRe
|
|
|
67
67
|
var ref = (0, _useCallbackRef.useMergeRefs)([drawerRef, assignSecondChildRef]);
|
|
68
68
|
(0, _usePreventProgrammaticScroll.default)();
|
|
69
69
|
return (0, _react2.jsx)("div", {
|
|
70
|
-
css: wrapperStyles
|
|
71
|
-
style
|
|
70
|
+
css: wrapperStyles
|
|
71
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
72
|
+
,
|
|
73
|
+
style: wrapperWidth[width]
|
|
74
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
75
|
+
,
|
|
72
76
|
className: className,
|
|
73
77
|
"data-testid": testId,
|
|
74
78
|
ref: ref,
|
|
@@ -58,6 +58,7 @@ var DrawerPrimitive = function DrawerPrimitive(_ref2) {
|
|
|
58
58
|
Icon = _ref2.icon,
|
|
59
59
|
_ref2$closeLabel = _ref2.closeLabel,
|
|
60
60
|
closeLabel = _ref2$closeLabel === void 0 ? 'Close drawer' : _ref2$closeLabel,
|
|
61
|
+
scrollContentLabel = _ref2.scrollContentLabel,
|
|
61
62
|
onClose = _ref2.onClose,
|
|
62
63
|
onCloseComplete = _ref2.onCloseComplete,
|
|
63
64
|
onOpenComplete = _ref2.onOpenComplete,
|
|
@@ -99,7 +100,9 @@ var DrawerPrimitive = function DrawerPrimitive(_ref2) {
|
|
|
99
100
|
autoFocusFirstElem: autoFocusFirstElem,
|
|
100
101
|
isFocusLockEnabled: isFocusLockEnabled,
|
|
101
102
|
shouldReturnFocus: shouldReturnFocus
|
|
102
|
-
}, (0, _react2.jsx)(_drawerWrapper.default
|
|
103
|
+
}, (0, _react2.jsx)(_drawerWrapper.default
|
|
104
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
105
|
+
, {
|
|
103
106
|
className: className,
|
|
104
107
|
width: width,
|
|
105
108
|
testId: testId,
|
|
@@ -117,7 +120,9 @@ var DrawerPrimitive = function DrawerPrimitive(_ref2) {
|
|
|
117
120
|
label: closeLabel,
|
|
118
121
|
shape: "circle",
|
|
119
122
|
appearance: "subtle"
|
|
120
|
-
})), (0, _react2.jsx)(Content,
|
|
123
|
+
})), (0, _react2.jsx)(Content, (0, _extends2.default)({
|
|
124
|
+
scrollContentLabel: scrollContentLabel
|
|
125
|
+
}, contentOverrides), children)));
|
|
121
126
|
}));
|
|
122
127
|
};
|
|
123
128
|
|
|
@@ -35,7 +35,9 @@ const Blanket = ({
|
|
|
35
35
|
animationTimingFunction: animationTimingFunction
|
|
36
36
|
}, ({
|
|
37
37
|
className
|
|
38
|
-
}) =>
|
|
38
|
+
}) =>
|
|
39
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
40
|
+
jsx("div", {
|
|
39
41
|
css: blanketStyles,
|
|
40
42
|
className: className
|
|
41
43
|
}, jsx(AkBlanket, {
|
|
@@ -8,7 +8,7 @@ import { defaultFocusLockSettings } from '../constants';
|
|
|
8
8
|
import Blanket from './blanket';
|
|
9
9
|
import DrawerPrimitive from './primitives';
|
|
10
10
|
const packageName = "@atlaskit/drawer";
|
|
11
|
-
const packageVersion = "7.
|
|
11
|
+
const packageVersion = "7.11.0";
|
|
12
12
|
const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
13
13
|
const createAndFireOnClick = (createAnalyticsEvent, trigger) => createAndFireEventOnAtlaskit({
|
|
14
14
|
action: 'dismissed',
|
|
@@ -89,6 +89,7 @@ export class DrawerBase extends Component {
|
|
|
89
89
|
children,
|
|
90
90
|
icon,
|
|
91
91
|
closeLabel,
|
|
92
|
+
scrollContentLabel,
|
|
92
93
|
width,
|
|
93
94
|
shouldUnmountOnExit,
|
|
94
95
|
onCloseComplete,
|
|
@@ -124,7 +125,8 @@ export class DrawerBase extends Component {
|
|
|
124
125
|
overrides: overrides,
|
|
125
126
|
autoFocusFirstElem: autoFocusFirstElem,
|
|
126
127
|
isFocusLockEnabled: isFocusLockEnabled,
|
|
127
|
-
shouldReturnFocus: shouldReturnFocus
|
|
128
|
+
shouldReturnFocus: shouldReturnFocus,
|
|
129
|
+
scrollContentLabel: scrollContentLabel
|
|
128
130
|
}, children));
|
|
129
131
|
}
|
|
130
132
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
5
|
import { css, jsx } from '@emotion/react';
|
|
5
6
|
const defaultStyles = {
|
|
6
7
|
flex: 1,
|
|
@@ -10,19 +11,39 @@ const defaultStyles = {
|
|
|
10
11
|
const contentCSS = () => defaultStyles;
|
|
11
12
|
const Content = ({
|
|
12
13
|
cssFn,
|
|
14
|
+
scrollContentLabel = 'Scrollable content',
|
|
13
15
|
...props
|
|
14
|
-
}) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
}) => {
|
|
17
|
+
const [showContentFocus, setContentFocus] = useState(false);
|
|
18
|
+
const scrollableRef = useRef(null);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const setLazyContentFocus = () => {
|
|
21
|
+
const target = scrollableRef.current;
|
|
22
|
+
target && setContentFocus(target.scrollHeight > target.clientHeight);
|
|
23
|
+
};
|
|
24
|
+
setLazyContentFocus();
|
|
25
|
+
}, []);
|
|
21
26
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
/**
|
|
28
|
+
* I noticed the implementation at @atlaskit/checkbox would send the props to cssFn rather
|
|
29
|
+
* than the defaultStyles as the overrides guide suggests. I went with what the overrides
|
|
30
|
+
* guide suggested as it made more sense as a transformer of the current styles rather than
|
|
31
|
+
* a complete override with no chance of partially changing styles.
|
|
32
|
+
*/
|
|
33
|
+
return jsx("div", _extends({
|
|
34
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
35
|
+
css: css(cssFn(defaultStyles)),
|
|
36
|
+
ref: scrollableRef
|
|
37
|
+
// tabindex is allowed here so that keyboard users can scroll content
|
|
38
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
39
|
+
,
|
|
40
|
+
tabIndex: showContentFocus ? 0 : undefined,
|
|
41
|
+
role: showContentFocus ? 'region' : undefined,
|
|
42
|
+
"aria-label": showContentFocus ? scrollContentLabel : undefined,
|
|
43
|
+
"data-testId": "drawer-contents"
|
|
44
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
45
|
+
}, props));
|
|
46
|
+
};
|
|
26
47
|
export default {
|
|
27
48
|
component: Content,
|
|
28
49
|
cssFn: contentCSS
|
|
@@ -62,8 +62,12 @@ const DrawerWrapper = /*#__PURE__*/forwardRef(({
|
|
|
62
62
|
const ref = useMergeRefs([drawerRef, assignSecondChildRef]);
|
|
63
63
|
usePreventProgrammaticScroll();
|
|
64
64
|
return jsx("div", {
|
|
65
|
-
css: wrapperStyles
|
|
66
|
-
style
|
|
65
|
+
css: wrapperStyles
|
|
66
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
67
|
+
,
|
|
68
|
+
style: wrapperWidth[width]
|
|
69
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
70
|
+
,
|
|
67
71
|
className: className,
|
|
68
72
|
"data-testid": testId,
|
|
69
73
|
ref: ref,
|
|
@@ -51,6 +51,7 @@ const DrawerPrimitive = ({
|
|
|
51
51
|
children,
|
|
52
52
|
icon: Icon,
|
|
53
53
|
closeLabel = 'Close drawer',
|
|
54
|
+
scrollContentLabel,
|
|
54
55
|
onClose,
|
|
55
56
|
onCloseComplete,
|
|
56
57
|
onOpenComplete,
|
|
@@ -95,7 +96,9 @@ const DrawerPrimitive = ({
|
|
|
95
96
|
autoFocusFirstElem: autoFocusFirstElem,
|
|
96
97
|
isFocusLockEnabled: isFocusLockEnabled,
|
|
97
98
|
shouldReturnFocus: shouldReturnFocus
|
|
98
|
-
}, jsx(DrawerWrapper
|
|
99
|
+
}, jsx(DrawerWrapper
|
|
100
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
101
|
+
, {
|
|
99
102
|
className: className,
|
|
100
103
|
width: width,
|
|
101
104
|
testId: testId,
|
|
@@ -111,7 +114,9 @@ const DrawerPrimitive = ({
|
|
|
111
114
|
label: closeLabel,
|
|
112
115
|
shape: "circle",
|
|
113
116
|
appearance: "subtle"
|
|
114
|
-
})), jsx(Content,
|
|
117
|
+
})), jsx(Content, _extends({
|
|
118
|
+
scrollContentLabel: scrollContentLabel
|
|
119
|
+
}, contentOverrides), children)))));
|
|
115
120
|
};
|
|
116
121
|
|
|
117
122
|
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
@@ -34,14 +34,17 @@ var Blanket = function Blanket(_ref) {
|
|
|
34
34
|
animationTimingFunction: animationTimingFunction
|
|
35
35
|
}, function (_ref2) {
|
|
36
36
|
var className = _ref2.className;
|
|
37
|
-
return
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
return (
|
|
38
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
39
|
+
jsx("div", {
|
|
40
|
+
css: blanketStyles,
|
|
41
|
+
className: className
|
|
42
|
+
}, jsx(AkBlanket, {
|
|
43
|
+
isTinted: true,
|
|
44
|
+
onBlanketClicked: onBlanketClicked,
|
|
45
|
+
testId: testId && testId
|
|
46
|
+
}))
|
|
47
|
+
);
|
|
45
48
|
}));
|
|
46
49
|
};
|
|
47
50
|
export default Blanket;
|
|
@@ -18,7 +18,7 @@ import { defaultFocusLockSettings } from '../constants';
|
|
|
18
18
|
import Blanket from './blanket';
|
|
19
19
|
import DrawerPrimitive from './primitives';
|
|
20
20
|
var packageName = "@atlaskit/drawer";
|
|
21
|
-
var packageVersion = "7.
|
|
21
|
+
var packageVersion = "7.11.0";
|
|
22
22
|
var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
23
23
|
var createAndFireOnClick = function createAndFireOnClick(createAnalyticsEvent, trigger) {
|
|
24
24
|
return createAndFireEventOnAtlaskit({
|
|
@@ -111,6 +111,7 @@ export var DrawerBase = /*#__PURE__*/function (_Component) {
|
|
|
111
111
|
children = _this$props3.children,
|
|
112
112
|
icon = _this$props3.icon,
|
|
113
113
|
closeLabel = _this$props3.closeLabel,
|
|
114
|
+
scrollContentLabel = _this$props3.scrollContentLabel,
|
|
114
115
|
width = _this$props3.width,
|
|
115
116
|
shouldUnmountOnExit = _this$props3.shouldUnmountOnExit,
|
|
116
117
|
onCloseComplete = _this$props3.onCloseComplete,
|
|
@@ -146,7 +147,8 @@ export var DrawerBase = /*#__PURE__*/function (_Component) {
|
|
|
146
147
|
overrides: overrides,
|
|
147
148
|
autoFocusFirstElem: autoFocusFirstElem,
|
|
148
149
|
isFocusLockEnabled: isFocusLockEnabled,
|
|
149
|
-
shouldReturnFocus: shouldReturnFocus
|
|
150
|
+
shouldReturnFocus: shouldReturnFocus,
|
|
151
|
+
scrollContentLabel: scrollContentLabel
|
|
150
152
|
}, children));
|
|
151
153
|
}
|
|
152
154
|
}]);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["cssFn"];
|
|
4
|
+
var _excluded = ["cssFn", "scrollContentLabel"];
|
|
4
5
|
/** @jsx jsx */
|
|
5
6
|
|
|
7
|
+
import { useEffect, useRef, useState } from 'react';
|
|
6
8
|
import { css, jsx } from '@emotion/react';
|
|
7
9
|
var defaultStyles = {
|
|
8
10
|
flex: 1,
|
|
@@ -14,20 +16,41 @@ var contentCSS = function contentCSS() {
|
|
|
14
16
|
};
|
|
15
17
|
var Content = function Content(_ref) {
|
|
16
18
|
var cssFn = _ref.cssFn,
|
|
19
|
+
_ref$scrollContentLab = _ref.scrollContentLabel,
|
|
20
|
+
scrollContentLabel = _ref$scrollContentLab === void 0 ? 'Scrollable content' : _ref$scrollContentLab,
|
|
17
21
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
var _useState = useState(false),
|
|
23
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
+
showContentFocus = _useState2[0],
|
|
25
|
+
setContentFocus = _useState2[1];
|
|
26
|
+
var scrollableRef = useRef(null);
|
|
27
|
+
useEffect(function () {
|
|
28
|
+
var setLazyContentFocus = function setLazyContentFocus() {
|
|
29
|
+
var target = scrollableRef.current;
|
|
30
|
+
target && setContentFocus(target.scrollHeight > target.clientHeight);
|
|
31
|
+
};
|
|
32
|
+
setLazyContentFocus();
|
|
33
|
+
}, []);
|
|
25
34
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
/**
|
|
36
|
+
* I noticed the implementation at @atlaskit/checkbox would send the props to cssFn rather
|
|
37
|
+
* than the defaultStyles as the overrides guide suggests. I went with what the overrides
|
|
38
|
+
* guide suggested as it made more sense as a transformer of the current styles rather than
|
|
39
|
+
* a complete override with no chance of partially changing styles.
|
|
40
|
+
*/
|
|
41
|
+
return jsx("div", _extends({
|
|
42
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
43
|
+
css: css(cssFn(defaultStyles)),
|
|
44
|
+
ref: scrollableRef
|
|
45
|
+
// tabindex is allowed here so that keyboard users can scroll content
|
|
46
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
47
|
+
,
|
|
48
|
+
tabIndex: showContentFocus ? 0 : undefined,
|
|
49
|
+
role: showContentFocus ? 'region' : undefined,
|
|
50
|
+
"aria-label": showContentFocus ? scrollContentLabel : undefined,
|
|
51
|
+
"data-testId": "drawer-contents"
|
|
52
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
53
|
+
}, props));
|
|
31
54
|
};
|
|
32
55
|
export default {
|
|
33
56
|
component: Content,
|
|
@@ -60,8 +60,12 @@ var DrawerWrapper = /*#__PURE__*/forwardRef(function (_ref, scrollRef) {
|
|
|
60
60
|
var ref = useMergeRefs([drawerRef, assignSecondChildRef]);
|
|
61
61
|
usePreventProgrammaticScroll();
|
|
62
62
|
return jsx("div", {
|
|
63
|
-
css: wrapperStyles
|
|
64
|
-
style
|
|
63
|
+
css: wrapperStyles
|
|
64
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
65
|
+
,
|
|
66
|
+
style: wrapperWidth[width]
|
|
67
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
68
|
+
,
|
|
65
69
|
className: className,
|
|
66
70
|
"data-testid": testId,
|
|
67
71
|
ref: ref,
|
|
@@ -53,6 +53,7 @@ var DrawerPrimitive = function DrawerPrimitive(_ref2) {
|
|
|
53
53
|
Icon = _ref2.icon,
|
|
54
54
|
_ref2$closeLabel = _ref2.closeLabel,
|
|
55
55
|
closeLabel = _ref2$closeLabel === void 0 ? 'Close drawer' : _ref2$closeLabel,
|
|
56
|
+
scrollContentLabel = _ref2.scrollContentLabel,
|
|
56
57
|
onClose = _ref2.onClose,
|
|
57
58
|
onCloseComplete = _ref2.onCloseComplete,
|
|
58
59
|
onOpenComplete = _ref2.onOpenComplete,
|
|
@@ -94,7 +95,9 @@ var DrawerPrimitive = function DrawerPrimitive(_ref2) {
|
|
|
94
95
|
autoFocusFirstElem: autoFocusFirstElem,
|
|
95
96
|
isFocusLockEnabled: isFocusLockEnabled,
|
|
96
97
|
shouldReturnFocus: shouldReturnFocus
|
|
97
|
-
}, jsx(DrawerWrapper
|
|
98
|
+
}, jsx(DrawerWrapper
|
|
99
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
100
|
+
, {
|
|
98
101
|
className: className,
|
|
99
102
|
width: width,
|
|
100
103
|
testId: testId,
|
|
@@ -112,7 +115,9 @@ var DrawerPrimitive = function DrawerPrimitive(_ref2) {
|
|
|
112
115
|
label: closeLabel,
|
|
113
116
|
shape: "circle",
|
|
114
117
|
appearance: "subtle"
|
|
115
|
-
})), jsx(Content,
|
|
118
|
+
})), jsx(Content, _extends({
|
|
119
|
+
scrollContentLabel: scrollContentLabel
|
|
120
|
+
}, contentOverrides), children)));
|
|
116
121
|
}));
|
|
117
122
|
};
|
|
118
123
|
|
|
@@ -22,10 +22,10 @@ export declare class DrawerBase extends Component<DrawerProps, {
|
|
|
22
22
|
handleKeyDown: (event: KeyboardEvent) => void;
|
|
23
23
|
render(): JSX.Element | null;
|
|
24
24
|
}
|
|
25
|
-
declare const _default: React.ForwardRefExoticComponent<Pick<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "children" | "onKeyDown" | "onClose" | "testId" | "icon" | "closeLabel" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen" | keyof import("./types").DrawerLabel> & Partial<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "width" | keyof import("./types").FocusLockSettings>> & Partial<Pick<{
|
|
25
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "scrollContentLabel" | "children" | "onKeyDown" | "onClose" | "testId" | "icon" | "closeLabel" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen" | keyof import("./types").DrawerLabel> & Partial<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "width" | keyof import("./types").FocusLockSettings>> & Partial<Pick<{
|
|
26
26
|
autoFocusFirstElem?: boolean | (() => HTMLElement | null) | undefined;
|
|
27
27
|
isFocusLockEnabled?: boolean | undefined;
|
|
28
28
|
shouldReturnFocus?: boolean | React.RefObject<HTMLElement> | undefined;
|
|
29
29
|
width: DrawerWidth;
|
|
30
|
-
}, never>> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "width" | "children" | "onKeyDown" | "key" | "onClose" | "testId" | "icon" | "closeLabel" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen" | "analyticsContext" | keyof import("./types").FocusLockSettings | keyof import("./types").DrawerLabel> & React.RefAttributes<any>>;
|
|
30
|
+
}, never>> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "scrollContentLabel" | "width" | "children" | "onKeyDown" | "key" | "onClose" | "testId" | "icon" | "closeLabel" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen" | "analyticsContext" | keyof import("./types").FocusLockSettings | keyof import("./types").DrawerLabel> & React.RefAttributes<any>>;
|
|
31
31
|
export default _default;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { type CSSObject, jsx } from '@emotion/react';
|
|
3
3
|
import { type ContentProps } from '../types';
|
|
4
4
|
declare const _default: {
|
|
5
|
-
component: ({ cssFn, ...props }: ContentProps) => jsx.JSX.Element;
|
|
5
|
+
component: ({ cssFn, scrollContentLabel, ...props }: ContentProps) => jsx.JSX.Element;
|
|
6
6
|
cssFn: () => CSSObject;
|
|
7
7
|
};
|
|
8
8
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { jsx } from '@emotion/react';
|
|
3
3
|
import { type DrawerPrimitiveProps } from '../types';
|
|
4
|
-
declare const DrawerPrimitive: ({ children, icon: Icon, closeLabel, onClose, onCloseComplete, onOpenComplete, overrides, testId, in: isOpen, shouldReturnFocus, autoFocusFirstElem, isFocusLockEnabled, width, label, titleId, }: DrawerPrimitiveProps) => jsx.JSX.Element;
|
|
4
|
+
declare const DrawerPrimitive: ({ children, icon: Icon, closeLabel, scrollContentLabel, onClose, onCloseComplete, onOpenComplete, overrides, testId, in: isOpen, shouldReturnFocus, autoFocusFirstElem, isFocusLockEnabled, width, label, titleId, }: DrawerPrimitiveProps) => jsx.JSX.Element;
|
|
5
5
|
export default DrawerPrimitive;
|
|
@@ -36,6 +36,10 @@ export interface BaseProps {
|
|
|
36
36
|
* This is the accessible name for the close/back control of the drawer. The default is "Close drawer".
|
|
37
37
|
*/
|
|
38
38
|
closeLabel?: string;
|
|
39
|
+
/**
|
|
40
|
+
* When the content is scrollable, this is the accessible name for the the drawer region. The default is "Scrollable content".
|
|
41
|
+
*/
|
|
42
|
+
scrollContentLabel?: ContentProps['scrollContentLabel'];
|
|
39
43
|
/**
|
|
40
44
|
* Sets the width of the drawer.
|
|
41
45
|
*/
|
|
@@ -110,6 +114,10 @@ export interface ContentProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
110
114
|
* @deprecated Please avoid using this prop as we intend to remove the prop completely in a future release. See DSP-2673 for more information.
|
|
111
115
|
*/
|
|
112
116
|
cssFn: (defaultStyles: CSSObject) => CSSObject;
|
|
117
|
+
/**
|
|
118
|
+
* When the content is scrollable, this is the accessible name for the the drawer region. The default is "Scrollable content".
|
|
119
|
+
*/
|
|
120
|
+
scrollContentLabel?: string;
|
|
113
121
|
}
|
|
114
122
|
export type ContentCSSProps = Omit<ContentProps, 'cssFn'>;
|
|
115
123
|
export interface DrawerPrimitiveProps extends BaseProps, FocusLockSettings, DrawerLabel {
|
|
@@ -22,10 +22,10 @@ export declare class DrawerBase extends Component<DrawerProps, {
|
|
|
22
22
|
handleKeyDown: (event: KeyboardEvent) => void;
|
|
23
23
|
render(): JSX.Element | null;
|
|
24
24
|
}
|
|
25
|
-
declare const _default: React.ForwardRefExoticComponent<Pick<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "children" | "onKeyDown" | "onClose" | "testId" | "icon" | "closeLabel" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen" | keyof import("./types").DrawerLabel> & Partial<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "width" | keyof import("./types").FocusLockSettings>> & Partial<Pick<{
|
|
25
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "scrollContentLabel" | "children" | "onKeyDown" | "onClose" | "testId" | "icon" | "closeLabel" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen" | keyof import("./types").DrawerLabel> & Partial<Pick<Omit<DrawerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "width" | keyof import("./types").FocusLockSettings>> & Partial<Pick<{
|
|
26
26
|
autoFocusFirstElem?: boolean | (() => HTMLElement | null) | undefined;
|
|
27
27
|
isFocusLockEnabled?: boolean | undefined;
|
|
28
28
|
shouldReturnFocus?: boolean | React.RefObject<HTMLElement> | undefined;
|
|
29
29
|
width: DrawerWidth;
|
|
30
|
-
}, never>> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "width" | "children" | "onKeyDown" | "key" | "onClose" | "testId" | "icon" | "closeLabel" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen" | "analyticsContext" | keyof import("./types").FocusLockSettings | keyof import("./types").DrawerLabel> & React.RefAttributes<any>>;
|
|
30
|
+
}, never>> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "scrollContentLabel" | "width" | "children" | "onKeyDown" | "key" | "onClose" | "testId" | "icon" | "closeLabel" | "onOpenComplete" | "onCloseComplete" | "shouldUnmountOnExit" | "overrides" | "zIndex" | "isOpen" | "analyticsContext" | keyof import("./types").FocusLockSettings | keyof import("./types").DrawerLabel> & React.RefAttributes<any>>;
|
|
31
31
|
export default _default;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { type CSSObject, jsx } from '@emotion/react';
|
|
3
3
|
import { type ContentProps } from '../types';
|
|
4
4
|
declare const _default: {
|
|
5
|
-
component: ({ cssFn, ...props }: ContentProps) => jsx.JSX.Element;
|
|
5
|
+
component: ({ cssFn, scrollContentLabel, ...props }: ContentProps) => jsx.JSX.Element;
|
|
6
6
|
cssFn: () => CSSObject;
|
|
7
7
|
};
|
|
8
8
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { jsx } from '@emotion/react';
|
|
3
3
|
import { type DrawerPrimitiveProps } from '../types';
|
|
4
|
-
declare const DrawerPrimitive: ({ children, icon: Icon, closeLabel, onClose, onCloseComplete, onOpenComplete, overrides, testId, in: isOpen, shouldReturnFocus, autoFocusFirstElem, isFocusLockEnabled, width, label, titleId, }: DrawerPrimitiveProps) => jsx.JSX.Element;
|
|
4
|
+
declare const DrawerPrimitive: ({ children, icon: Icon, closeLabel, scrollContentLabel, onClose, onCloseComplete, onOpenComplete, overrides, testId, in: isOpen, shouldReturnFocus, autoFocusFirstElem, isFocusLockEnabled, width, label, titleId, }: DrawerPrimitiveProps) => jsx.JSX.Element;
|
|
5
5
|
export default DrawerPrimitive;
|
|
@@ -36,6 +36,10 @@ export interface BaseProps {
|
|
|
36
36
|
* This is the accessible name for the close/back control of the drawer. The default is "Close drawer".
|
|
37
37
|
*/
|
|
38
38
|
closeLabel?: string;
|
|
39
|
+
/**
|
|
40
|
+
* When the content is scrollable, this is the accessible name for the the drawer region. The default is "Scrollable content".
|
|
41
|
+
*/
|
|
42
|
+
scrollContentLabel?: ContentProps['scrollContentLabel'];
|
|
39
43
|
/**
|
|
40
44
|
* Sets the width of the drawer.
|
|
41
45
|
*/
|
|
@@ -110,6 +114,10 @@ export interface ContentProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
110
114
|
* @deprecated Please avoid using this prop as we intend to remove the prop completely in a future release. See DSP-2673 for more information.
|
|
111
115
|
*/
|
|
112
116
|
cssFn: (defaultStyles: CSSObject) => CSSObject;
|
|
117
|
+
/**
|
|
118
|
+
* When the content is scrollable, this is the accessible name for the the drawer region. The default is "Scrollable content".
|
|
119
|
+
*/
|
|
120
|
+
scrollContentLabel?: string;
|
|
113
121
|
}
|
|
114
122
|
export type ContentCSSProps = Omit<ContentProps, 'cssFn'>;
|
|
115
123
|
export interface DrawerPrimitiveProps extends BaseProps, FocusLockSettings, DrawerLabel {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/drawer",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.11.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/"
|
|
@@ -67,7 +67,6 @@
|
|
|
67
67
|
"@atlaskit/ds-lib": "^2.3.0",
|
|
68
68
|
"@atlaskit/ssr": "*",
|
|
69
69
|
"@atlaskit/visual-regression": "*",
|
|
70
|
-
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
71
70
|
"@testing-library/react": "^12.1.5",
|
|
72
71
|
"@testing-library/user-event": "^14.4.3",
|
|
73
72
|
"@types/exenv": "^1.2.0",
|
|
@@ -98,6 +97,5 @@
|
|
|
98
97
|
"primitives"
|
|
99
98
|
]
|
|
100
99
|
}
|
|
101
|
-
}
|
|
102
|
-
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|
|
100
|
+
}
|
|
103
101
|
}
|