@atlaskit/drawer 9.2.6 → 9.3.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/compiled/package.json +17 -0
  3. package/dist/cjs/compiled/blanket.compiled.css +1 -0
  4. package/dist/cjs/compiled/blanket.js +54 -0
  5. package/dist/cjs/compiled/constants.js +12 -0
  6. package/dist/cjs/compiled/drawer-panel/drawer-close-button.js +44 -0
  7. package/dist/cjs/compiled/drawer-panel/drawer-content.compiled.css +6 -0
  8. package/dist/cjs/compiled/drawer-panel/drawer-content.js +72 -0
  9. package/dist/cjs/compiled/drawer-panel/drawer-panel.compiled.css +15 -0
  10. package/dist/cjs/compiled/drawer-panel/drawer-panel.js +112 -0
  11. package/dist/cjs/compiled/drawer-panel/drawer-sidebar.compiled.css +10 -0
  12. package/dist/cjs/compiled/drawer-panel/drawer-sidebar.js +33 -0
  13. package/dist/cjs/compiled/drawer-panel/focus-lock.js +44 -0
  14. package/dist/cjs/compiled/drawer.js +138 -0
  15. package/dist/cjs/compiled/types.js +5 -0
  16. package/dist/cjs/components/index.js +3 -3
  17. package/dist/cjs/components/primitives/drawer-wrapper.js +5 -4
  18. package/dist/cjs/context.js +26 -0
  19. package/dist/cjs/entry-points/compiled.js +33 -0
  20. package/dist/es2019/compiled/blanket.compiled.css +1 -0
  21. package/dist/es2019/compiled/blanket.js +47 -0
  22. package/dist/es2019/compiled/constants.js +4 -0
  23. package/dist/es2019/compiled/drawer-panel/drawer-close-button.js +34 -0
  24. package/dist/es2019/compiled/drawer-panel/drawer-content.compiled.css +6 -0
  25. package/dist/es2019/compiled/drawer-panel/drawer-content.js +59 -0
  26. package/dist/es2019/compiled/drawer-panel/drawer-panel.compiled.css +15 -0
  27. package/dist/es2019/compiled/drawer-panel/drawer-panel.js +102 -0
  28. package/dist/es2019/compiled/drawer-panel/drawer-sidebar.compiled.css +10 -0
  29. package/dist/es2019/compiled/drawer-panel/drawer-sidebar.js +25 -0
  30. package/dist/es2019/compiled/drawer-panel/focus-lock.js +35 -0
  31. package/dist/es2019/compiled/drawer.js +118 -0
  32. package/dist/es2019/compiled/types.js +1 -0
  33. package/dist/es2019/components/index.js +3 -3
  34. package/dist/es2019/components/primitives/drawer-wrapper.js +1 -1
  35. package/dist/es2019/context.js +17 -0
  36. package/dist/es2019/entry-points/compiled.js +4 -0
  37. package/dist/esm/compiled/blanket.compiled.css +1 -0
  38. package/dist/esm/compiled/blanket.js +47 -0
  39. package/dist/esm/compiled/constants.js +6 -0
  40. package/dist/esm/compiled/drawer-panel/drawer-close-button.js +37 -0
  41. package/dist/esm/compiled/drawer-panel/drawer-content.compiled.css +6 -0
  42. package/dist/esm/compiled/drawer-panel/drawer-content.js +62 -0
  43. package/dist/esm/compiled/drawer-panel/drawer-panel.compiled.css +15 -0
  44. package/dist/esm/compiled/drawer-panel/drawer-panel.js +102 -0
  45. package/dist/esm/compiled/drawer-panel/drawer-sidebar.compiled.css +10 -0
  46. package/dist/esm/compiled/drawer-panel/drawer-sidebar.js +24 -0
  47. package/dist/esm/compiled/drawer-panel/focus-lock.js +37 -0
  48. package/dist/esm/compiled/drawer.js +127 -0
  49. package/dist/esm/compiled/types.js +1 -0
  50. package/dist/esm/components/index.js +3 -3
  51. package/dist/esm/components/primitives/drawer-wrapper.js +3 -4
  52. package/dist/esm/context.js +19 -0
  53. package/dist/esm/entry-points/compiled.js +4 -0
  54. package/dist/types/compiled/blanket.d.ts +15 -0
  55. package/dist/types/compiled/constants.d.ts +3 -0
  56. package/dist/types/compiled/drawer-panel/drawer-close-button.d.ts +8 -0
  57. package/dist/types/compiled/drawer-panel/drawer-content.d.ts +12 -0
  58. package/dist/types/compiled/drawer-panel/drawer-panel.d.ts +10 -0
  59. package/dist/types/compiled/drawer-panel/drawer-sidebar.d.ts +12 -0
  60. package/dist/types/compiled/drawer-panel/focus-lock.d.ts +9 -0
  61. package/dist/types/compiled/drawer.d.ts +12 -0
  62. package/dist/types/compiled/types.d.ts +124 -0
  63. package/dist/types/context.d.ts +12 -0
  64. package/dist/types/entry-points/compiled.d.ts +5 -0
  65. package/dist/types-ts4.5/compiled/blanket.d.ts +15 -0
  66. package/dist/types-ts4.5/compiled/constants.d.ts +3 -0
  67. package/dist/types-ts4.5/compiled/drawer-panel/drawer-close-button.d.ts +8 -0
  68. package/dist/types-ts4.5/compiled/drawer-panel/drawer-content.d.ts +12 -0
  69. package/dist/types-ts4.5/compiled/drawer-panel/drawer-panel.d.ts +10 -0
  70. package/dist/types-ts4.5/compiled/drawer-panel/drawer-sidebar.d.ts +12 -0
  71. package/dist/types-ts4.5/compiled/drawer-panel/focus-lock.d.ts +9 -0
  72. package/dist/types-ts4.5/compiled/drawer.d.ts +12 -0
  73. package/dist/types-ts4.5/compiled/types.d.ts +124 -0
  74. package/dist/types-ts4.5/context.d.ts +12 -0
  75. package/dist/types-ts4.5/entry-points/compiled.d.ts +5 -0
  76. package/package.json +7 -4
  77. /package/dist/cjs/{components/primitives/hooks → hooks}/use-prevent-programmatic-scroll.js +0 -0
  78. /package/dist/es2019/{components/primitives/hooks → hooks}/use-prevent-programmatic-scroll.js +0 -0
  79. /package/dist/esm/{components/primitives/hooks → hooks}/use-prevent-programmatic-scroll.js +0 -0
  80. /package/dist/types/{components/primitives/hooks → hooks}/use-prevent-programmatic-scroll.d.ts +0 -0
  81. /package/dist/types-ts4.5/{components/primitives/hooks → hooks}/use-prevent-programmatic-scroll.d.ts +0 -0
@@ -11,13 +11,14 @@ var _react2 = require("@emotion/react");
11
11
  var _useCallbackRef = require("use-callback-ref");
12
12
  var _colors = require("@atlaskit/theme/colors");
13
13
  var _tokens = require("@atlaskit/tokens");
14
- var _usePreventProgrammaticScroll = _interopRequireDefault(require("./hooks/use-prevent-programmatic-scroll"));
15
- var _css;
14
+ var _usePreventProgrammaticScroll = _interopRequireDefault(require("../../hooks/use-prevent-programmatic-scroll"));
16
15
  /**
17
16
  * @jsxRuntime classic
18
17
  * @jsx jsx
19
18
  */
19
+
20
20
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
21
+
21
22
  var wrapperWidth = exports.wrapperWidth = {
22
23
  full: {
23
24
  width: '100vw'
@@ -35,13 +36,13 @@ var wrapperWidth = exports.wrapperWidth = {
35
36
  width: 600
36
37
  }
37
38
  };
38
- var wrapperStyles = (0, _react2.css)((_css = {
39
+ var wrapperStyles = (0, _react2.css)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({
39
40
  display: 'flex',
40
41
  height: '100vh',
41
42
  position: 'fixed',
42
43
  zIndex: 500,
43
44
  backgroundColor: "var(--ds-surface-overlay, ".concat(_colors.N0, ")")
44
- }, (0, _defineProperty2.default)(_css, _tokens.CURRENT_SURFACE_CSS_VAR, "var(--ds-surface-overlay, ".concat(_colors.N0, ")")), (0, _defineProperty2.default)(_css, "insetBlockStart", 0), (0, _defineProperty2.default)(_css, "insetInlineStart", 0), (0, _defineProperty2.default)(_css, "overflow", 'hidden'), _css));
45
+ }, _tokens.CURRENT_SURFACE_CSS_VAR, "var(--ds-surface-overlay, ".concat(_colors.N0, ")")), "insetBlockStart", 0), "insetInlineStart", 0), "overflow", 'hidden'));
45
46
  /**
46
47
  * A wrapper that controls the styling of the drawer with a few hacks with refs to get our Touch±Scroll locks working.
47
48
  */
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useOnClose = exports.useEnsureIsInsideDrawer = exports.OnCloseContext = exports.EnsureIsInsideDrawerContext = void 0;
8
+ var _react = require("react");
9
+ var _tinyInvariant = _interopRequireDefault(require("tiny-invariant"));
10
+ /**
11
+ * Context used to share the `onClose` prop value with sub-components.
12
+ */
13
+ var OnCloseContext = exports.OnCloseContext = /*#__PURE__*/(0, _react.createContext)(undefined);
14
+ var useOnClose = exports.useOnClose = function useOnClose() {
15
+ return (0, _react.useContext)(OnCloseContext);
16
+ };
17
+
18
+ /**
19
+ * Used to ensure Drawer sub-components are used within a Drawer component,
20
+ * and provide a useful error message if not.
21
+ */
22
+ var EnsureIsInsideDrawerContext = exports.EnsureIsInsideDrawerContext = /*#__PURE__*/(0, _react.createContext)(false);
23
+ var useEnsureIsInsideDrawer = exports.useEnsureIsInsideDrawer = function useEnsureIsInsideDrawer() {
24
+ var context = (0, _react.useContext)(EnsureIsInsideDrawerContext);
25
+ (0, _tinyInvariant.default)(context, 'Drawer sub-components must be used within a Drawer component.');
26
+ };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Drawer", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _drawer.Drawer;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "DrawerCloseButton", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _drawerCloseButton.DrawerCloseButton;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "DrawerContent", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _drawerContent.DrawerContent;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "DrawerSidebar", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _drawerSidebar.DrawerSidebar;
28
+ }
29
+ });
30
+ var _drawer = require("../compiled/drawer");
31
+ var _drawerContent = require("../compiled/drawer-panel/drawer-content");
32
+ var _drawerSidebar = require("../compiled/drawer-panel/drawer-sidebar");
33
+ var _drawerCloseButton = require("../compiled/drawer-panel/drawer-close-button");
@@ -0,0 +1 @@
1
+ ._kqswh2mm{position:relative}
@@ -0,0 +1,47 @@
1
+ /* blanket.tsx generated by @compiled/babel-plugin v0.35.0 */
2
+ import "./blanket.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React from 'react';
5
+ import AkBlanket from '@atlaskit/blanket';
6
+ import { ExitingPersistence, FadeIn } from '@atlaskit/motion';
7
+ import { animationTimingFunction, transitionDurationMs } from '../constants';
8
+ const styles = {
9
+ blanket: "_kqswh2mm"
10
+ };
11
+
12
+ /**
13
+ * A wrapper around `@atlaskit/blanket` that adds a fade in/out transition.
14
+ */
15
+ const Blanket = ({
16
+ isOpen,
17
+ onBlanketClicked,
18
+ testId
19
+ }) => {
20
+ return /*#__PURE__*/React.createElement(ExitingPersistence, {
21
+ appear: true
22
+ }, isOpen && /*#__PURE__*/React.createElement(FadeIn
23
+ /**
24
+ * We double the duration because the fade in keyframes have
25
+ * `opacity: 1` at `50%`.
26
+ *
27
+ * The fade out animation uses half the passed duration so it evens out.
28
+ */, {
29
+ duration: transitionDurationMs * 2
30
+ /**
31
+ * We don't expose this on `FadeIn` but it does get passed down.
32
+ * TODO: figure out how we want to handle this...
33
+ */
34
+ // @ts-ignore
35
+ ,
36
+ animationTimingFunction: animationTimingFunction
37
+ }, ({
38
+ className
39
+ }) => /*#__PURE__*/React.createElement("div", {
40
+ className: ax([styles.blanket, className])
41
+ }, /*#__PURE__*/React.createElement(AkBlanket, {
42
+ isTinted: true,
43
+ onBlanketClicked: onBlanketClicked,
44
+ testId: testId && testId
45
+ }))));
46
+ };
47
+ export default Blanket;
@@ -0,0 +1,4 @@
1
+ import { easeOut } from '@atlaskit/motion/curves';
2
+ export const transitionDuration = '0.22s';
3
+ export const transitionDurationMs = 220;
4
+ export const animationTimingFunction = () => easeOut;
@@ -0,0 +1,34 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import { IconButton } from '@atlaskit/button/new';
4
+ import ArrowLeft from '@atlaskit/icon/core/migration/arrow-left';
5
+ import ArrowLeftOld from '@atlaskit/icon/glyph/arrow-left';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
7
+ import { useEnsureIsInsideDrawer, useOnClose } from '../../context';
8
+ /**
9
+ * __Drawer close button
10
+ *
11
+ * A button that closes the drawer.
12
+ */
13
+ export const DrawerCloseButton = ({
14
+ icon: Icon,
15
+ label = 'Close drawer',
16
+ testId = 'DrawerCloseButton'
17
+ }) => {
18
+ useEnsureIsInsideDrawer();
19
+ const onClose = useOnClose();
20
+ return /*#__PURE__*/React.createElement(IconButton, {
21
+ onClick: onClose,
22
+ testId: testId,
23
+ icon: Icon ? iconProps => /*#__PURE__*/React.createElement(Icon, _extends({}, iconProps, {
24
+ size: "large"
25
+ }, fg('platform-visual-refresh-icon-ads-migration') ? {
26
+ LEGACY_size: 'large'
27
+ } : {})) : fg('platform-visual-refresh-icon-ads-migration') ? ArrowLeft :
28
+ // eslint-disable-next-line @atlaskit/design-system/no-legacy-icons
29
+ ArrowLeftOld,
30
+ label: label,
31
+ shape: "circle",
32
+ appearance: "subtle"
33
+ });
34
+ };
@@ -0,0 +1,6 @@
1
+ ._16jlkb7n{flex-grow:1}
2
+ ._18m91wug{overflow-y:auto}
3
+ ._19pk1ejb{margin-top:var(--ds-space-300,24px)}
4
+ ._1o9zkb7n{flex-shrink:1}
5
+ ._1reo1wug{overflow-x:auto}
6
+ ._i0dlf1ug{flex-basis:0%}
@@ -0,0 +1,59 @@
1
+ /* drawer-content.tsx generated by @compiled/babel-plugin v0.35.0 */
2
+ import "./drawer-content.compiled.css";
3
+ import * as React from 'react';
4
+ import { ax, ix } from "@compiled/react/runtime";
5
+ import { forwardRef, useEffect, useRef, useState } from 'react';
6
+ import ScrollLock from 'react-scrolllock';
7
+ import { mergeRefs } from 'use-callback-ref';
8
+ import { useEnsureIsInsideDrawer } from '../../context';
9
+ import usePreventProgrammaticScroll from '../../hooks/use-prevent-programmatic-scroll';
10
+ const styles = {
11
+ default: "_16jlkb7n _1o9zkb7n _i0dlf1ug _1reo1wug _18m91wug _19pk1ejb"
12
+ };
13
+ const DrawerContentBase = /*#__PURE__*/forwardRef(({
14
+ children,
15
+ scrollContentLabel = 'Scrollable content',
16
+ xcss
17
+ }, scrollableRef) => {
18
+ const [showContentFocus, setContentFocus] = useState(false);
19
+ const ref = useRef(null);
20
+ useEffect(() => {
21
+ const setLazyContentFocus = () => {
22
+ const target = ref.current;
23
+ target && setContentFocus(target.scrollHeight > target.clientHeight);
24
+ };
25
+ setLazyContentFocus();
26
+ }, []);
27
+ return /*#__PURE__*/React.createElement("div", {
28
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
29
+ className: ax([styles.default, xcss]),
30
+ ref: mergeRefs([ref, scrollableRef])
31
+ // tabindex is allowed here so that keyboard users can scroll content
32
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
33
+ ,
34
+ tabIndex: showContentFocus ? 0 : undefined,
35
+ role: showContentFocus ? 'region' : undefined,
36
+ "aria-label": showContentFocus ? scrollContentLabel : undefined,
37
+ "data-testid": "drawer-contents"
38
+ }, children);
39
+ });
40
+
41
+ /**
42
+ * __Drawer content__
43
+ *
44
+ * The main content section of the drawer panel.
45
+ */
46
+ export const DrawerContent = ({
47
+ children,
48
+ scrollContentLabel,
49
+ xcss
50
+ }) => {
51
+ useEnsureIsInsideDrawer();
52
+ usePreventProgrammaticScroll();
53
+ return /*#__PURE__*/React.createElement(ScrollLock, null, /*#__PURE__*/React.createElement(DrawerContentBase, {
54
+ scrollContentLabel: scrollContentLabel
55
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
56
+ ,
57
+ xcss: xcss
58
+ }, children));
59
+ };
@@ -0,0 +1,15 @@
1
+ ._152tze3t{inset-block-start:var(--ds-space-0,0)}
2
+ ._18m915vq{overflow-y:hidden}
3
+ ._1bsb1gwv{width:360px}
4
+ ._1bsb1mwr{width:95vw}
5
+ ._1bsb1ogm{width:600px}
6
+ ._1bsb1y37{width:5in}
7
+ ._1bsbauwl{width:100vw}
8
+ ._1e02ze3t{inset-inline-start:var(--ds-space-0,0)}
9
+ ._1e0c1txw{display:flex}
10
+ ._1pbybfng{z-index:500}
11
+ ._1q1l1bhr{--ds-elevation-surface-current:var(--ds-surface-overlay,#fff)}
12
+ ._1reo15vq{overflow-x:hidden}
13
+ ._4t3i1kxc{height:100vh}
14
+ ._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
15
+ ._kqsw1n9t{position:fixed}
@@ -0,0 +1,102 @@
1
+ /* drawer-panel.tsx generated by @compiled/babel-plugin v0.35.0 */
2
+ import "./drawer-panel.compiled.css";
3
+ import * as React from 'react';
4
+ import { ax, ix } from "@compiled/react/runtime";
5
+ import { useCallback, useRef } from 'react';
6
+ import { ExitingPersistence, SlideIn, useExitingPersistence } from '@atlaskit/motion';
7
+ import { CURRENT_SURFACE_CSS_VAR } from '@atlaskit/tokens';
8
+ import { animationTimingFunction, transitionDurationMs } from '../../constants';
9
+ import { EnsureIsInsideDrawerContext, OnCloseContext } from '../../context';
10
+ import FocusLock from './focus-lock';
11
+ const styles = {
12
+ root: "_1reo15vq _18m915vq _1e0c1txw _4t3i1kxc _kqsw1n9t _1pbybfng _bfhk1bhr _1q1l1bhr _152tze3t _1e02ze3t",
13
+ full: "_1bsbauwl",
14
+ extended: "_1bsb1mwr",
15
+ narrow: "_1bsb1gwv",
16
+ medium: "_1bsb1y37",
17
+ wide: "_1bsb1ogm"
18
+ };
19
+
20
+ /**
21
+ * This wrapper is used to specify separate durations for enter and exit.
22
+ */
23
+ const CustomSlideIn = ({
24
+ children,
25
+ onFinish,
26
+ enterFrom
27
+ }) => {
28
+ const {
29
+ isExiting
30
+ } = useExitingPersistence();
31
+
32
+ /**
33
+ * The actual duration should be the same for both enter and exit,
34
+ * but motion halves the passed duration for exit animations,
35
+ * so we double it when exiting.
36
+ */
37
+ const duration = isExiting ? transitionDurationMs * 2 : transitionDurationMs;
38
+ return /*#__PURE__*/React.createElement(SlideIn, {
39
+ animationTimingFunction: animationTimingFunction,
40
+ duration: duration,
41
+ enterFrom: enterFrom,
42
+ exitTo: enterFrom,
43
+ fade: "none",
44
+ onFinish: onFinish
45
+ }, children);
46
+ };
47
+
48
+ /**
49
+ * __Drawer panel__
50
+ */
51
+ export const DrawerPanel = ({
52
+ children,
53
+ onClose,
54
+ onCloseComplete,
55
+ onOpenComplete,
56
+ testId,
57
+ isOpen,
58
+ shouldReturnFocus,
59
+ autoFocusFirstElem,
60
+ isFocusLockEnabled,
61
+ width = 'narrow',
62
+ label,
63
+ titleId,
64
+ enterFrom = 'left'
65
+ }) => {
66
+ /**
67
+ * A ref to point to our wrapper, passed to `onCloseComplete` and `onOpenComplete` callbacks.
68
+ */
69
+ const drawerRef = useRef(null);
70
+ const onFinish = useCallback(state => {
71
+ if (state === 'entering') {
72
+ onOpenComplete === null || onOpenComplete === void 0 ? void 0 : onOpenComplete(drawerRef.current);
73
+ } else if (state === 'exiting') {
74
+ onCloseComplete === null || onCloseComplete === void 0 ? void 0 : onCloseComplete(drawerRef.current);
75
+ }
76
+ }, [onCloseComplete, onOpenComplete]);
77
+ return /*#__PURE__*/React.createElement(ExitingPersistence, {
78
+ appear: true
79
+ }, isOpen && /*#__PURE__*/React.createElement(CustomSlideIn, {
80
+ onFinish: onFinish,
81
+ enterFrom: enterFrom
82
+ }, ({
83
+ className
84
+ }) => /*#__PURE__*/React.createElement(FocusLock, {
85
+ autoFocusFirstElem: autoFocusFirstElem,
86
+ isFocusLockEnabled: isFocusLockEnabled,
87
+ shouldReturnFocus: shouldReturnFocus
88
+ }, /*#__PURE__*/React.createElement("div", {
89
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
90
+ className: ax([styles.root, styles[width], className]),
91
+ "data-testid": testId,
92
+ ref: drawerRef,
93
+ "aria-modal": true,
94
+ role: "dialog",
95
+ "aria-label": label,
96
+ "aria-labelledby": titleId
97
+ }, /*#__PURE__*/React.createElement(EnsureIsInsideDrawerContext.Provider, {
98
+ value: true
99
+ }, /*#__PURE__*/React.createElement(OnCloseContext.Provider, {
100
+ value: onClose
101
+ }, children))))));
102
+ };
@@ -0,0 +1,10 @@
1
+ ._1bsbxncg{width:var(--ds-space-800,4pc)}
2
+ ._1e0c1txw{display:flex}
3
+ ._1o9zidpf{flex-shrink:0}
4
+ ._2lx21bp4{flex-direction:column}
5
+ ._4cvr1h6o{align-items:center}
6
+ ._4t3i1kxc{height:100vh}
7
+ ._ca0q1ejb{padding-top:var(--ds-space-300,24px)}
8
+ ._n3tdpxbi{padding-bottom:var(--ds-space-200,1pc)}
9
+ ._syaz1gjq{color:var(--ds-text-subtle,#44546f)}
10
+ ._vchhusvi{box-sizing:border-box}
@@ -0,0 +1,25 @@
1
+ /* drawer-sidebar.tsx generated by @compiled/babel-plugin v0.35.0 */
2
+ import "./drawer-sidebar.compiled.css";
3
+ import * as React from 'react';
4
+ import { ax, ix } from "@compiled/react/runtime";
5
+ import { useEnsureIsInsideDrawer } from '../../context';
6
+ const styles = {
7
+ default: "_4cvr1h6o _vchhusvi _syaz1gjq _1e0c1txw _1o9zidpf _2lx21bp4 _4t3i1kxc _n3tdpxbi _ca0q1ejb _1bsbxncg"
8
+ };
9
+
10
+ /**
11
+ * __Drawer sidebar__
12
+ *
13
+ * The sidebar of the drawer panel.
14
+ */
15
+ export const DrawerSidebar = ({
16
+ children,
17
+ xcss
18
+ }) => {
19
+ useEnsureIsInsideDrawer();
20
+ return /*#__PURE__*/React.createElement("div", {
21
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
22
+ className: ax([styles.default, xcss]),
23
+ "data-testid": "drawer-sidebar"
24
+ }, children);
25
+ };
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import ReactFocusLock from 'react-focus-lock';
3
+ /**
4
+ * __Focus lock__
5
+ *
6
+ * Thin wrapper around react-focus-lock.
7
+ */
8
+ const FocusLock = ({
9
+ isFocusLockEnabled = true,
10
+ autoFocusFirstElem = true,
11
+ shouldReturnFocus = true,
12
+ children
13
+ }) => {
14
+ const getFocusTarget = () => {
15
+ if (typeof shouldReturnFocus === 'boolean') {
16
+ return shouldReturnFocus;
17
+ }
18
+ return false;
19
+ };
20
+ const onDeactivation = () => {
21
+ if (typeof shouldReturnFocus !== 'boolean') {
22
+ window.setTimeout(() => {
23
+ var _shouldReturnFocus$cu;
24
+ shouldReturnFocus === null || shouldReturnFocus === void 0 ? void 0 : (_shouldReturnFocus$cu = shouldReturnFocus.current) === null || _shouldReturnFocus$cu === void 0 ? void 0 : _shouldReturnFocus$cu.focus();
25
+ }, 0);
26
+ }
27
+ };
28
+ return /*#__PURE__*/React.createElement(ReactFocusLock, {
29
+ disabled: !isFocusLockEnabled,
30
+ autoFocus: autoFocusFirstElem,
31
+ returnFocus: getFocusTarget(),
32
+ onDeactivation: onDeactivation
33
+ }, children);
34
+ };
35
+ export default FocusLock;
@@ -0,0 +1,118 @@
1
+ /* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
2
+ import React, { useCallback, useEffect } from 'react';
3
+ import { canUseDOM } from 'exenv';
4
+ import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
5
+ import { Layering, useCloseOnEscapePress } from '@atlaskit/layering';
6
+ import Portal from '@atlaskit/portal';
7
+ import Blanket from './blanket';
8
+ import { DrawerPanel } from './drawer-panel/drawer-panel';
9
+ // escape close manager for layering
10
+ const EscapeCloseManager = ({
11
+ onClose
12
+ }) => {
13
+ // wrap so that we can cast the event to a React.KeyboardEvent
14
+ const handleClose = useCallback(evt => {
15
+ onClose && onClose(evt);
16
+ }, [onClose]);
17
+ useCloseOnEscapePress({
18
+ onClose: handleClose
19
+ });
20
+ return /*#__PURE__*/React.createElement("span", null);
21
+ };
22
+
23
+ /**
24
+ * __Drawer__
25
+ *
26
+ * A drawer is a panel that slides in from the left side of the screen.
27
+ *
28
+ * - [Examples](https://atlassian.design/components/drawer/examples)
29
+ * - [Code](https://atlassian.design/components/drawer/code)
30
+ * - [Usage](https://atlassian.design/components/drawer/usage)
31
+ */
32
+ export const Drawer = ({
33
+ width = 'narrow',
34
+ isOpen,
35
+ isFocusLockEnabled = true,
36
+ shouldReturnFocus = true,
37
+ autoFocusFirstElem = true,
38
+ onKeyDown,
39
+ testId,
40
+ children,
41
+ onClose,
42
+ onCloseComplete,
43
+ onOpenComplete,
44
+ zIndex = 'unset',
45
+ label,
46
+ titleId,
47
+ enterFrom
48
+ }) => {
49
+ const handleClose = usePlatformLeafEventHandler({
50
+ fn: (evt, analyticsEvent) => onClose === null || onClose === void 0 ? void 0 : onClose(evt, analyticsEvent),
51
+ action: 'dismissed',
52
+ componentName: 'drawer',
53
+ packageName: "@atlaskit/drawer",
54
+ packageVersion: "9.3.0",
55
+ analyticsData: {
56
+ trigger: 'escKey'
57
+ }
58
+ });
59
+ const handleKeyDown = useCallback(evt => {
60
+ onKeyDown && onKeyDown(evt);
61
+ }, [onKeyDown]);
62
+ useEffect(() => {
63
+ if (isOpen) {
64
+ window.addEventListener('keydown', handleKeyDown);
65
+ }
66
+ return () => {
67
+ window.removeEventListener('keydown', handleKeyDown);
68
+ };
69
+ }, [handleKeyDown, isOpen]);
70
+ const handleBlanketClick = usePlatformLeafEventHandler({
71
+ fn: (evt, analyticsEvent) => onClose === null || onClose === void 0 ? void 0 : onClose(evt, analyticsEvent),
72
+ action: 'dismissed',
73
+ componentName: 'drawer',
74
+ packageName: "@atlaskit/drawer",
75
+ packageVersion: "9.3.0",
76
+ analyticsData: {
77
+ trigger: 'blanket'
78
+ }
79
+ });
80
+ const handleBackButtonClick = usePlatformLeafEventHandler({
81
+ fn: (evt, analyticsEvent) => onClose === null || onClose === void 0 ? void 0 : onClose(evt, analyticsEvent),
82
+ action: 'dismissed',
83
+ componentName: 'drawer',
84
+ packageName: "@atlaskit/drawer",
85
+ packageVersion: "9.3.0",
86
+ analyticsData: {
87
+ trigger: 'backButton'
88
+ }
89
+ });
90
+ const body = canUseDOM ? document.querySelector('body') : undefined;
91
+ if (!body) {
92
+ return null;
93
+ }
94
+ return /*#__PURE__*/React.createElement(Portal, {
95
+ zIndex: zIndex
96
+ }, /*#__PURE__*/React.createElement(Blanket, {
97
+ isOpen: isOpen,
98
+ onBlanketClicked: handleBlanketClick,
99
+ testId: testId && `${testId}--blanket`
100
+ }), /*#__PURE__*/React.createElement(DrawerPanel, {
101
+ testId: testId,
102
+ isOpen: isOpen,
103
+ onClose: handleBackButtonClick,
104
+ onCloseComplete: onCloseComplete,
105
+ onOpenComplete: onOpenComplete,
106
+ width: width,
107
+ enterFrom: enterFrom,
108
+ label: label,
109
+ titleId: titleId,
110
+ autoFocusFirstElem: autoFocusFirstElem,
111
+ isFocusLockEnabled: isFocusLockEnabled,
112
+ shouldReturnFocus: shouldReturnFocus
113
+ }, isOpen ? /*#__PURE__*/React.createElement(Layering, {
114
+ isDisabled: false
115
+ }, children, /*#__PURE__*/React.createElement(EscapeCloseManager, {
116
+ onClose: handleClose
117
+ })) : children));
118
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -57,7 +57,7 @@ export const Drawer = ({
57
57
  action: 'dismissed',
58
58
  componentName: 'drawer',
59
59
  packageName: "@atlaskit/drawer",
60
- packageVersion: "9.2.6",
60
+ packageVersion: "9.3.0",
61
61
  analyticsData: {
62
62
  trigger: 'escKey'
63
63
  }
@@ -78,7 +78,7 @@ export const Drawer = ({
78
78
  action: 'dismissed',
79
79
  componentName: 'drawer',
80
80
  packageName: "@atlaskit/drawer",
81
- packageVersion: "9.2.6",
81
+ packageVersion: "9.3.0",
82
82
  analyticsData: {
83
83
  trigger: 'blanket'
84
84
  }
@@ -88,7 +88,7 @@ export const Drawer = ({
88
88
  action: 'dismissed',
89
89
  componentName: 'drawer',
90
90
  packageName: "@atlaskit/drawer",
91
- packageVersion: "9.2.6",
91
+ packageVersion: "9.3.0",
92
92
  analyticsData: {
93
93
  trigger: 'backButton'
94
94
  }
@@ -9,7 +9,7 @@ import { css, jsx } from '@emotion/react';
9
9
  import { useMergeRefs } from 'use-callback-ref';
10
10
  import { N0 } from '@atlaskit/theme/colors';
11
11
  import { CURRENT_SURFACE_CSS_VAR } from '@atlaskit/tokens';
12
- import usePreventProgrammaticScroll from './hooks/use-prevent-programmatic-scroll';
12
+ import usePreventProgrammaticScroll from '../../hooks/use-prevent-programmatic-scroll';
13
13
  export const wrapperWidth = {
14
14
  full: {
15
15
  width: '100vw'
@@ -0,0 +1,17 @@
1
+ import { createContext, useContext } from 'react';
2
+ import invariant from 'tiny-invariant';
3
+ /**
4
+ * Context used to share the `onClose` prop value with sub-components.
5
+ */
6
+ export const OnCloseContext = /*#__PURE__*/createContext(undefined);
7
+ export const useOnClose = () => useContext(OnCloseContext);
8
+
9
+ /**
10
+ * Used to ensure Drawer sub-components are used within a Drawer component,
11
+ * and provide a useful error message if not.
12
+ */
13
+ export const EnsureIsInsideDrawerContext = /*#__PURE__*/createContext(false);
14
+ export const useEnsureIsInsideDrawer = () => {
15
+ const context = useContext(EnsureIsInsideDrawerContext);
16
+ invariant(context, 'Drawer sub-components must be used within a Drawer component.');
17
+ };
@@ -0,0 +1,4 @@
1
+ export { Drawer } from '../compiled/drawer';
2
+ export { DrawerContent } from '../compiled/drawer-panel/drawer-content';
3
+ export { DrawerSidebar } from '../compiled/drawer-panel/drawer-sidebar';
4
+ export { DrawerCloseButton } from '../compiled/drawer-panel/drawer-close-button';
@@ -0,0 +1 @@
1
+ ._kqswh2mm{position:relative}