@atlaskit/drawer 7.7.2 → 7.9.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.
@@ -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.7.2";
30
+ var packageVersion = "7.9.0";
31
31
  var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
32
32
  var createAndFireOnClick = function createAndFireOnClick(createAnalyticsEvent, trigger) {
33
33
  return createAndFireEventOnAtlaskit({
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.default = void 0;
9
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
11
12
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
13
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
14
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
@@ -29,8 +30,29 @@ var FocusLock = exports.default = /*#__PURE__*/function (_Component) {
29
30
  (0, _inherits2.default)(FocusLock, _Component);
30
31
  var _super = _createSuper(FocusLock);
31
32
  function FocusLock() {
33
+ var _this;
32
34
  (0, _classCallCheck2.default)(this, FocusLock);
33
- return _super.apply(this, arguments);
35
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
36
+ args[_key] = arguments[_key];
37
+ }
38
+ _this = _super.call.apply(_super, [this].concat(args));
39
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getFocusTarget", function () {
40
+ var shouldReturnFocus = _this.props.shouldReturnFocus;
41
+ if (typeof shouldReturnFocus === 'boolean') {
42
+ return shouldReturnFocus;
43
+ }
44
+ return false;
45
+ });
46
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDeactivation", function () {
47
+ var shouldReturnFocus = _this.props.shouldReturnFocus;
48
+ if (typeof shouldReturnFocus !== 'boolean') {
49
+ window.setTimeout(function () {
50
+ var _shouldReturnFocus$cu;
51
+ shouldReturnFocus === null || shouldReturnFocus === void 0 || (_shouldReturnFocus$cu = shouldReturnFocus.current) === null || _shouldReturnFocus$cu === void 0 || _shouldReturnFocus$cu.focus();
52
+ }, 0);
53
+ }
54
+ });
55
+ return _this;
34
56
  }
35
57
  (0, _createClass2.default)(FocusLock, [{
36
58
  key: "componentDidMount",
@@ -54,12 +76,12 @@ var FocusLock = exports.default = /*#__PURE__*/function (_Component) {
54
76
  var _this$props2 = this.props,
55
77
  isFocusLockEnabled = _this$props2.isFocusLockEnabled,
56
78
  autoFocusFirstElem = _this$props2.autoFocusFirstElem,
57
- shouldReturnFocus = _this$props2.shouldReturnFocus,
58
79
  children = _this$props2.children;
59
80
  return /*#__PURE__*/_react.default.createElement(_reactFocusLock.default, {
60
81
  disabled: !isFocusLockEnabled,
61
82
  autoFocus: !!autoFocusFirstElem,
62
- returnFocus: shouldReturnFocus
83
+ returnFocus: this.getFocusTarget(),
84
+ onDeactivation: this.onDeactivation
63
85
  }, /*#__PURE__*/_react.default.createElement(_reactScrolllock.default, null, children));
64
86
  }
65
87
  }]);
@@ -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.7.2";
11
+ const packageVersion = "7.9.0";
12
12
  const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
13
13
  const createAndFireOnClick = (createAnalyticsEvent, trigger) => createAndFireEventOnAtlaskit({
14
14
  action: 'dismissed',
@@ -7,6 +7,29 @@ import { defaultFocusLockSettings } from '../../constants';
7
7
  // Thin wrapper over react-focus-lock. This wrapper only exists to ensure API compatibility.
8
8
  // This component should be deleted during https://ecosystem.atlassian.net/browse/AK-5658
9
9
  export default class FocusLock extends Component {
10
+ constructor(...args) {
11
+ super(...args);
12
+ _defineProperty(this, "getFocusTarget", () => {
13
+ const {
14
+ shouldReturnFocus
15
+ } = this.props;
16
+ if (typeof shouldReturnFocus === 'boolean') {
17
+ return shouldReturnFocus;
18
+ }
19
+ return false;
20
+ });
21
+ _defineProperty(this, "onDeactivation", () => {
22
+ const {
23
+ shouldReturnFocus
24
+ } = this.props;
25
+ if (typeof shouldReturnFocus !== 'boolean') {
26
+ window.setTimeout(() => {
27
+ var _shouldReturnFocus$cu;
28
+ shouldReturnFocus === null || shouldReturnFocus === void 0 ? void 0 : (_shouldReturnFocus$cu = shouldReturnFocus.current) === null || _shouldReturnFocus$cu === void 0 ? void 0 : _shouldReturnFocus$cu.focus();
29
+ }, 0);
30
+ }
31
+ });
32
+ }
10
33
  componentDidMount() {
11
34
  const {
12
35
  isFocusLockEnabled,
@@ -26,13 +49,13 @@ export default class FocusLock extends Component {
26
49
  const {
27
50
  isFocusLockEnabled,
28
51
  autoFocusFirstElem,
29
- shouldReturnFocus,
30
52
  children
31
53
  } = this.props;
32
54
  return /*#__PURE__*/React.createElement(ReactFocusLock, {
33
55
  disabled: !isFocusLockEnabled,
34
56
  autoFocus: !!autoFocusFirstElem,
35
- returnFocus: shouldReturnFocus
57
+ returnFocus: this.getFocusTarget(),
58
+ onDeactivation: this.onDeactivation
36
59
  }, /*#__PURE__*/React.createElement(ScrollLock, null, children));
37
60
  }
38
61
  }
@@ -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.7.2";
21
+ var packageVersion = "7.9.0";
22
22
  var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
23
23
  var createAndFireOnClick = function createAndFireOnClick(createAnalyticsEvent, trigger) {
24
24
  return createAndFireEventOnAtlaskit({
@@ -1,5 +1,6 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
3
4
  import _inherits from "@babel/runtime/helpers/inherits";
4
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
@@ -19,8 +20,29 @@ var FocusLock = /*#__PURE__*/function (_Component) {
19
20
  _inherits(FocusLock, _Component);
20
21
  var _super = _createSuper(FocusLock);
21
22
  function FocusLock() {
23
+ var _this;
22
24
  _classCallCheck(this, FocusLock);
23
- return _super.apply(this, arguments);
25
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
26
+ args[_key] = arguments[_key];
27
+ }
28
+ _this = _super.call.apply(_super, [this].concat(args));
29
+ _defineProperty(_assertThisInitialized(_this), "getFocusTarget", function () {
30
+ var shouldReturnFocus = _this.props.shouldReturnFocus;
31
+ if (typeof shouldReturnFocus === 'boolean') {
32
+ return shouldReturnFocus;
33
+ }
34
+ return false;
35
+ });
36
+ _defineProperty(_assertThisInitialized(_this), "onDeactivation", function () {
37
+ var shouldReturnFocus = _this.props.shouldReturnFocus;
38
+ if (typeof shouldReturnFocus !== 'boolean') {
39
+ window.setTimeout(function () {
40
+ var _shouldReturnFocus$cu;
41
+ shouldReturnFocus === null || shouldReturnFocus === void 0 || (_shouldReturnFocus$cu = shouldReturnFocus.current) === null || _shouldReturnFocus$cu === void 0 || _shouldReturnFocus$cu.focus();
42
+ }, 0);
43
+ }
44
+ });
45
+ return _this;
24
46
  }
25
47
  _createClass(FocusLock, [{
26
48
  key: "componentDidMount",
@@ -44,12 +66,12 @@ var FocusLock = /*#__PURE__*/function (_Component) {
44
66
  var _this$props2 = this.props,
45
67
  isFocusLockEnabled = _this$props2.isFocusLockEnabled,
46
68
  autoFocusFirstElem = _this$props2.autoFocusFirstElem,
47
- shouldReturnFocus = _this$props2.shouldReturnFocus,
48
69
  children = _this$props2.children;
49
70
  return /*#__PURE__*/React.createElement(ReactFocusLock, {
50
71
  disabled: !isFocusLockEnabled,
51
72
  autoFocus: !!autoFocusFirstElem,
52
- returnFocus: shouldReturnFocus
73
+ returnFocus: this.getFocusTarget(),
74
+ onDeactivation: this.onDeactivation
53
75
  }, /*#__PURE__*/React.createElement(ScrollLock, null, children));
54
76
  }
55
77
  }]);
@@ -6,7 +6,7 @@ export declare class DrawerBase extends Component<DrawerProps, {
6
6
  static defaultProps: {
7
7
  autoFocusFirstElem?: boolean | (() => HTMLElement | null) | undefined;
8
8
  isFocusLockEnabled?: boolean | undefined;
9
- shouldReturnFocus?: boolean | undefined;
9
+ shouldReturnFocus?: boolean | React.RefObject<HTMLElement> | undefined;
10
10
  width: DrawerWidth;
11
11
  };
12
12
  state: {
@@ -25,7 +25,7 @@ export declare class DrawerBase extends Component<DrawerProps, {
25
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<{
26
26
  autoFocusFirstElem?: boolean | (() => HTMLElement | null) | undefined;
27
27
  isFocusLockEnabled?: boolean | undefined;
28
- shouldReturnFocus?: boolean | undefined;
28
+ shouldReturnFocus?: boolean | React.RefObject<HTMLElement> | undefined;
29
29
  width: DrawerWidth;
30
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>>;
31
31
  export default _default;
@@ -1,11 +1,13 @@
1
- import { Component } from 'react';
2
- import { FocusLockProps } from '../types';
1
+ import React, { Component } from 'react';
2
+ import { type FocusLockProps } from '../types';
3
3
  export default class FocusLock extends Component<FocusLockProps> {
4
4
  static defaultProps: {
5
5
  autoFocusFirstElem?: boolean | (() => HTMLElement | null) | undefined;
6
6
  isFocusLockEnabled?: boolean | undefined;
7
- shouldReturnFocus?: boolean | undefined;
7
+ shouldReturnFocus?: boolean | React.RefObject<HTMLElement> | undefined;
8
8
  };
9
9
  componentDidMount(): void;
10
+ getFocusTarget: () => boolean;
11
+ onDeactivation: () => void;
10
12
  render(): JSX.Element;
11
13
  }
@@ -1,6 +1,6 @@
1
- import { ComponentType, ReactElement, ReactNode, SyntheticEvent } from 'react';
2
- import { CSSObject } from '@emotion/react';
3
- import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
1
+ import { type ComponentType, type ReactElement, type ReactNode, type RefObject, type SyntheticEvent } from 'react';
2
+ import { type CSSObject } from '@emotion/react';
3
+ import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
4
4
  export type Widths = {
5
5
  extended: {
6
6
  width: string;
@@ -146,9 +146,11 @@ export interface FocusLockSettings {
146
146
  */
147
147
  isFocusLockEnabled?: boolean;
148
148
  /**
149
- * Controls whether to return the focus to the previous active element on closing the drawer. Set to `true` by default. Changing this is not recommended as returning focus is required for accessibility.
149
+ * ReturnFocus controls what happens when the user exits focus lock mode.
150
+ * If true, focus returns to the trigger element . If false, focus remains where it was when the FocusLock was deactivated.
151
+ * If ref is passed, focus returns to that specific ref element.
150
152
  */
151
- shouldReturnFocus?: boolean;
153
+ shouldReturnFocus?: boolean | RefObject<HTMLElement>;
152
154
  }
153
155
  export interface FocusLockProps extends FocusLockSettings {
154
156
  /**
@@ -6,7 +6,7 @@ export declare class DrawerBase extends Component<DrawerProps, {
6
6
  static defaultProps: {
7
7
  autoFocusFirstElem?: boolean | (() => HTMLElement | null) | undefined;
8
8
  isFocusLockEnabled?: boolean | undefined;
9
- shouldReturnFocus?: boolean | undefined;
9
+ shouldReturnFocus?: boolean | React.RefObject<HTMLElement> | undefined;
10
10
  width: DrawerWidth;
11
11
  };
12
12
  state: {
@@ -25,7 +25,7 @@ export declare class DrawerBase extends Component<DrawerProps, {
25
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<{
26
26
  autoFocusFirstElem?: boolean | (() => HTMLElement | null) | undefined;
27
27
  isFocusLockEnabled?: boolean | undefined;
28
- shouldReturnFocus?: boolean | undefined;
28
+ shouldReturnFocus?: boolean | React.RefObject<HTMLElement> | undefined;
29
29
  width: DrawerWidth;
30
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>>;
31
31
  export default _default;
@@ -1,11 +1,13 @@
1
- import { Component } from 'react';
2
- import { FocusLockProps } from '../types';
1
+ import React, { Component } from 'react';
2
+ import { type FocusLockProps } from '../types';
3
3
  export default class FocusLock extends Component<FocusLockProps> {
4
4
  static defaultProps: {
5
5
  autoFocusFirstElem?: boolean | (() => HTMLElement | null) | undefined;
6
6
  isFocusLockEnabled?: boolean | undefined;
7
- shouldReturnFocus?: boolean | undefined;
7
+ shouldReturnFocus?: boolean | React.RefObject<HTMLElement> | undefined;
8
8
  };
9
9
  componentDidMount(): void;
10
+ getFocusTarget: () => boolean;
11
+ onDeactivation: () => void;
10
12
  render(): JSX.Element;
11
13
  }
@@ -1,6 +1,6 @@
1
- import { ComponentType, ReactElement, ReactNode, SyntheticEvent } from 'react';
2
- import { CSSObject } from '@emotion/react';
3
- import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
1
+ import { type ComponentType, type ReactElement, type ReactNode, type RefObject, type SyntheticEvent } from 'react';
2
+ import { type CSSObject } from '@emotion/react';
3
+ import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
4
4
  export type Widths = {
5
5
  extended: {
6
6
  width: string;
@@ -146,9 +146,11 @@ export interface FocusLockSettings {
146
146
  */
147
147
  isFocusLockEnabled?: boolean;
148
148
  /**
149
- * Controls whether to return the focus to the previous active element on closing the drawer. Set to `true` by default. Changing this is not recommended as returning focus is required for accessibility.
149
+ * ReturnFocus controls what happens when the user exits focus lock mode.
150
+ * If true, focus returns to the trigger element . If false, focus remains where it was when the FocusLock was deactivated.
151
+ * If ref is passed, focus returns to that specific ref element.
150
152
  */
151
- shouldReturnFocus?: boolean;
153
+ shouldReturnFocus?: boolean | RefObject<HTMLElement>;
152
154
  }
153
155
  export interface FocusLockProps extends FocusLockSettings {
154
156
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/drawer",
3
- "version": "7.7.2",
3
+ "version": "7.9.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/"
@@ -36,16 +36,17 @@
36
36
  "website": {
37
37
  "name": "Drawer",
38
38
  "category": "Components"
39
- }
39
+ },
40
+ "runReact18": true
40
41
  },
41
42
  "dependencies": {
42
43
  "@atlaskit/analytics-next": "^9.3.0",
43
44
  "@atlaskit/blanket": "^13.1.0",
44
- "@atlaskit/icon": "^22.1.0",
45
- "@atlaskit/motion": "^1.5.0",
46
- "@atlaskit/portal": "^4.4.0",
47
- "@atlaskit/theme": "^12.7.0",
48
- "@atlaskit/tokens": "^1.43.0",
45
+ "@atlaskit/icon": "^22.3.0",
46
+ "@atlaskit/motion": "^1.6.0",
47
+ "@atlaskit/portal": "^4.5.0",
48
+ "@atlaskit/theme": "^12.8.0",
49
+ "@atlaskit/tokens": "^1.49.0",
49
50
  "@babel/runtime": "^7.0.0",
50
51
  "@emotion/react": "^11.7.1",
51
52
  "bind-event-listener": "^3.0.0",
@@ -56,7 +57,7 @@
56
57
  "use-callback-ref": "^1.2.3"
57
58
  },
58
59
  "peerDependencies": {
59
- "react": "^16.8.0"
60
+ "react": "^16.8.0 || ^17.0.0 || ~18.2.0"
60
61
  },
61
62
  "devDependencies": {
62
63
  "@af/accessibility-testing": "*",