@atlaskit/dropdown-menu 11.3.0 → 11.4.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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @atlaskit/dropdown-menu
2
2
 
3
+ ## 11.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`00fc216bd94`](https://bitbucket.org/atlassian/atlassian-frontend/commits/00fc216bd94) - Updates `@emotion/core` to `@emotion/react`; v10 to v11. There is no expected behavior change.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
13
+ ## 11.3.2
14
+
15
+ ### Patch Changes
16
+
17
+ - [`8d4228767b0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8d4228767b0) - Upgrade Typescript from `4.2.4` to `4.3.5`.
18
+
19
+ ## 11.3.1
20
+
21
+ ### Patch Changes
22
+
23
+ - [`61d8af6f398`](https://bitbucket.org/atlassian/atlassian-frontend/commits/61d8af6f398) - Adjusted the fallback placements for dropdown-menu to reduce how frequently the menu jumps while scrolling
24
+
3
25
  ## 11.3.0
4
26
 
5
27
  ### Minor Changes
@@ -17,7 +17,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
17
17
 
18
18
  var _react = require("react");
19
19
 
20
- var _core = require("@emotion/core");
20
+ var _react2 = require("@emotion/react");
21
21
 
22
22
  var _bindEventListener = require("bind-event-listener");
23
23
 
@@ -56,14 +56,38 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
56
56
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
57
57
 
58
58
  var gridSize = (0, _constants.gridSize)();
59
- var spinnerContainerStyles = (0, _core.css)({
59
+ var spinnerContainerStyles = (0, _react2.css)({
60
60
  display: 'flex',
61
61
  minWidth: "".concat(gridSize * 20, "px"),
62
62
  padding: "".concat(gridSize * 2.5, "px"),
63
63
  justifyContent: 'center'
64
64
  });
65
65
  var MAX_HEIGHT = "calc(100vh - ".concat(gridSize * 2, "px)");
66
- var fallbackPlacements = ['bottom', 'bottom-end', 'right-start', 'left-start', 'auto'];
66
+ var opposites = {
67
+ top: 'bottom',
68
+ bottom: 'top',
69
+ left: 'right',
70
+ right: 'left',
71
+ start: 'end',
72
+ auto: 'auto',
73
+ end: 'start'
74
+ };
75
+
76
+ var getFallbackPlacements = function getFallbackPlacements(placement) {
77
+ var placementPieces = placement.split('-');
78
+ var mainAxis = placementPieces[0]; // Left, right and auto placements can rely on standard popper sliding behaviour
79
+
80
+ if (!['top', 'bottom'].includes(mainAxis)) {
81
+ return undefined;
82
+ } // Top and bottom placements need to flip to the right/left to ensure
83
+ // long lists don't extend off the screen
84
+ else if (placementPieces.length === 2 && ['start', 'end'].includes(placementPieces[1])) {
85
+ var crossAxis = placementPieces[1];
86
+ return ["".concat(mainAxis), "".concat(mainAxis, "-").concat(opposites[crossAxis]), "".concat(opposites[mainAxis], "-").concat(crossAxis), "".concat(opposites[mainAxis]), "".concat(opposites[mainAxis], "-").concat(opposites[crossAxis]), 'auto'];
87
+ } else {
88
+ return ["".concat(mainAxis, "-start"), "".concat(mainAxis, "-end"), "".concat(opposites[mainAxis]), "".concat(opposites[mainAxis], "-start"), "".concat(opposites[mainAxis], "-end"), "auto"];
89
+ }
90
+ };
67
91
  /**
68
92
  * __Dropdown menu__
69
93
  *
@@ -74,6 +98,7 @@ var fallbackPlacements = ['bottom', 'bottom-end', 'right-start', 'left-start', '
74
98
  * - [Usage](https://atlassian.design/components/dropdown-menu/usage)
75
99
  */
76
100
 
101
+
77
102
  var DropdownMenu = function DropdownMenu(props) {
78
103
  var _props$defaultOpen = props.defaultOpen,
79
104
  defaultOpen = _props$defaultOpen === void 0 ? false : _props$defaultOpen,
@@ -108,6 +133,9 @@ var DropdownMenu = function DropdownMenu(props) {
108
133
  isTriggeredUsingKeyboard = _useState2[0],
109
134
  setTriggeredUsingKeyboard = _useState2[1];
110
135
 
136
+ var fallbackPlacements = (0, _react.useMemo)(function () {
137
+ return getFallbackPlacements(placement);
138
+ }, [placement]);
111
139
  var handleTriggerClicked = (0, _react.useCallback)( // TODO: event is an `any` and is being cast incorrectly
112
140
  // This means that the public type for `onOpenChange` is incorrect
113
141
  // current: (event: React.MouseEvent | React.KeyboardEvent) => void;
@@ -172,7 +200,7 @@ var DropdownMenu = function DropdownMenu(props) {
172
200
  });
173
201
  }, [isFocused, isLocalOpen, handleTriggerClicked]);
174
202
  var id = (0, _useGeneratedId.default)();
175
- return (0, _core.jsx)(_selectionStore.default, null, (0, _core.jsx)(_popup.default, {
203
+ return (0, _react2.jsx)(_selectionStore.default, null, (0, _react2.jsx)(_popup.default, {
176
204
  id: isLocalOpen ? id : undefined,
177
205
  shouldFlip: shouldFlip,
178
206
  isOpen: isLocalOpen,
@@ -194,15 +222,15 @@ var DropdownMenu = function DropdownMenu(props) {
194
222
  }));
195
223
  }
196
224
 
197
- return (0, _core.jsx)(_standardButton.default, (0, _extends2.default)({}, bindFocus, {
225
+ return (0, _react2.jsx)(_standardButton.default, (0, _extends2.default)({}, bindFocus, {
198
226
  ref: triggerProps.ref,
199
227
  "aria-controls": triggerProps['aria-controls'],
200
228
  "aria-expanded": triggerProps['aria-expanded'],
201
229
  "aria-haspopup": triggerProps['aria-haspopup'],
202
230
  isSelected: isLocalOpen,
203
- iconAfter: (0, _core.jsx)(_chevronDown.default, {
231
+ iconAfter: (0, _react2.jsx)(_chevronDown.default, {
204
232
  size: "medium",
205
- label: "expand"
233
+ label: ""
206
234
  }),
207
235
  onClick: handleTriggerClicked,
208
236
  testId: testId && "".concat(testId, "--trigger")
@@ -210,16 +238,16 @@ var DropdownMenu = function DropdownMenu(props) {
210
238
  },
211
239
  content: function content(_ref) {
212
240
  var setInitialFocusRef = _ref.setInitialFocusRef;
213
- return (0, _core.jsx)(_focusManager.default, null, (0, _core.jsx)(_menuWrapper.default, {
241
+ return (0, _react2.jsx)(_focusManager.default, null, (0, _react2.jsx)(_menuWrapper.default, {
214
242
  maxHeight: MAX_HEIGHT,
215
243
  maxWidth: 800,
216
244
  onClose: handleOnClose,
217
245
  setInitialFocusRef: isTriggeredUsingKeyboard || autoFocus ? setInitialFocusRef : undefined
218
- }, isLoading ? (0, _core.jsx)("div", {
246
+ }, isLoading ? (0, _react2.jsx)("div", {
219
247
  css: spinnerContainerStyles
220
- }, (0, _core.jsx)(_spinner.default, {
248
+ }, (0, _react2.jsx)(_spinner.default, {
221
249
  size: "small"
222
- }), (0, _core.jsx)(_visuallyHidden.default, {
250
+ }), (0, _react2.jsx)(_visuallyHidden.default, {
223
251
  role: "status"
224
252
  }, statusLabel)) : children));
225
253
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "11.3.0",
3
+ "version": "11.4.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
 
3
3
  /** @jsx jsx */
4
- import { useCallback, useEffect, useState } from 'react';
5
- import { css, jsx } from '@emotion/core';
4
+ import { useCallback, useEffect, useMemo, useState } from 'react';
5
+ import { css, jsx } from '@emotion/react';
6
6
  import { bind } from 'bind-event-listener';
7
7
  import Button from '@atlaskit/button/standard-button';
8
8
  import { KEY_DOWN } from '@atlaskit/ds-lib/keycodes';
@@ -26,7 +26,31 @@ const spinnerContainerStyles = css({
26
26
  justifyContent: 'center'
27
27
  });
28
28
  const MAX_HEIGHT = `calc(100vh - ${gridSize * 2}px)`;
29
- const fallbackPlacements = ['bottom', 'bottom-end', 'right-start', 'left-start', 'auto'];
29
+ const opposites = {
30
+ top: 'bottom',
31
+ bottom: 'top',
32
+ left: 'right',
33
+ right: 'left',
34
+ start: 'end',
35
+ auto: 'auto',
36
+ end: 'start'
37
+ };
38
+
39
+ const getFallbackPlacements = placement => {
40
+ const placementPieces = placement.split('-');
41
+ const mainAxis = placementPieces[0]; // Left, right and auto placements can rely on standard popper sliding behaviour
42
+
43
+ if (!['top', 'bottom'].includes(mainAxis)) {
44
+ return undefined;
45
+ } // Top and bottom placements need to flip to the right/left to ensure
46
+ // long lists don't extend off the screen
47
+ else if (placementPieces.length === 2 && ['start', 'end'].includes(placementPieces[1])) {
48
+ const crossAxis = placementPieces[1];
49
+ return [`${mainAxis}`, `${mainAxis}-${opposites[crossAxis]}`, `${opposites[mainAxis]}-${crossAxis}`, `${opposites[mainAxis]}`, `${opposites[mainAxis]}-${opposites[crossAxis]}`, 'auto'];
50
+ } else {
51
+ return [`${mainAxis}-start`, `${mainAxis}-end`, `${opposites[mainAxis]}`, `${opposites[mainAxis]}-start`, `${opposites[mainAxis]}-end`, `auto`];
52
+ }
53
+ };
30
54
  /**
31
55
  * __Dropdown menu__
32
56
  *
@@ -37,6 +61,7 @@ const fallbackPlacements = ['bottom', 'bottom-end', 'right-start', 'left-start',
37
61
  * - [Usage](https://atlassian.design/components/dropdown-menu/usage)
38
62
  */
39
63
 
64
+
40
65
  const DropdownMenu = props => {
41
66
  const {
42
67
  defaultOpen = false,
@@ -54,6 +79,7 @@ const DropdownMenu = props => {
54
79
  } = props;
55
80
  const [isLocalOpen, setLocalIsOpen] = useControlledState(isOpen, () => defaultOpen);
56
81
  const [isTriggeredUsingKeyboard, setTriggeredUsingKeyboard] = useState(false);
82
+ const fallbackPlacements = useMemo(() => getFallbackPlacements(placement), [placement]);
57
83
  const handleTriggerClicked = useCallback( // TODO: event is an `any` and is being cast incorrectly
58
84
  // This means that the public type for `onOpenChange` is incorrect
59
85
  // current: (event: React.MouseEvent | React.KeyboardEvent) => void;
@@ -152,7 +178,7 @@ const DropdownMenu = props => {
152
178
  isSelected: isLocalOpen,
153
179
  iconAfter: jsx(ExpandIcon, {
154
180
  size: "medium",
155
- label: "expand"
181
+ label: ""
156
182
  }),
157
183
  onClick: handleTriggerClicked,
158
184
  testId: testId && `${testId}--trigger`
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "11.3.0",
3
+ "version": "11.4.0",
4
4
  "sideEffects": false
5
5
  }
@@ -9,8 +9,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
9
9
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
10
 
11
11
  /** @jsx jsx */
12
- import { useCallback, useEffect, useState } from 'react';
13
- import { css, jsx } from '@emotion/core';
12
+ import { useCallback, useEffect, useMemo, useState } from 'react';
13
+ import { css, jsx } from '@emotion/react';
14
14
  import { bind } from 'bind-event-listener';
15
15
  import Button from '@atlaskit/button/standard-button';
16
16
  import { KEY_DOWN } from '@atlaskit/ds-lib/keycodes';
@@ -34,7 +34,31 @@ var spinnerContainerStyles = css({
34
34
  justifyContent: 'center'
35
35
  });
36
36
  var MAX_HEIGHT = "calc(100vh - ".concat(gridSize * 2, "px)");
37
- var fallbackPlacements = ['bottom', 'bottom-end', 'right-start', 'left-start', 'auto'];
37
+ var opposites = {
38
+ top: 'bottom',
39
+ bottom: 'top',
40
+ left: 'right',
41
+ right: 'left',
42
+ start: 'end',
43
+ auto: 'auto',
44
+ end: 'start'
45
+ };
46
+
47
+ var getFallbackPlacements = function getFallbackPlacements(placement) {
48
+ var placementPieces = placement.split('-');
49
+ var mainAxis = placementPieces[0]; // Left, right and auto placements can rely on standard popper sliding behaviour
50
+
51
+ if (!['top', 'bottom'].includes(mainAxis)) {
52
+ return undefined;
53
+ } // Top and bottom placements need to flip to the right/left to ensure
54
+ // long lists don't extend off the screen
55
+ else if (placementPieces.length === 2 && ['start', 'end'].includes(placementPieces[1])) {
56
+ var crossAxis = placementPieces[1];
57
+ return ["".concat(mainAxis), "".concat(mainAxis, "-").concat(opposites[crossAxis]), "".concat(opposites[mainAxis], "-").concat(crossAxis), "".concat(opposites[mainAxis]), "".concat(opposites[mainAxis], "-").concat(opposites[crossAxis]), 'auto'];
58
+ } else {
59
+ return ["".concat(mainAxis, "-start"), "".concat(mainAxis, "-end"), "".concat(opposites[mainAxis]), "".concat(opposites[mainAxis], "-start"), "".concat(opposites[mainAxis], "-end"), "auto"];
60
+ }
61
+ };
38
62
  /**
39
63
  * __Dropdown menu__
40
64
  *
@@ -45,6 +69,7 @@ var fallbackPlacements = ['bottom', 'bottom-end', 'right-start', 'left-start', '
45
69
  * - [Usage](https://atlassian.design/components/dropdown-menu/usage)
46
70
  */
47
71
 
72
+
48
73
  var DropdownMenu = function DropdownMenu(props) {
49
74
  var _props$defaultOpen = props.defaultOpen,
50
75
  defaultOpen = _props$defaultOpen === void 0 ? false : _props$defaultOpen,
@@ -79,6 +104,9 @@ var DropdownMenu = function DropdownMenu(props) {
79
104
  isTriggeredUsingKeyboard = _useState2[0],
80
105
  setTriggeredUsingKeyboard = _useState2[1];
81
106
 
107
+ var fallbackPlacements = useMemo(function () {
108
+ return getFallbackPlacements(placement);
109
+ }, [placement]);
82
110
  var handleTriggerClicked = useCallback( // TODO: event is an `any` and is being cast incorrectly
83
111
  // This means that the public type for `onOpenChange` is incorrect
84
112
  // current: (event: React.MouseEvent | React.KeyboardEvent) => void;
@@ -174,7 +202,7 @@ var DropdownMenu = function DropdownMenu(props) {
174
202
  isSelected: isLocalOpen,
175
203
  iconAfter: jsx(ExpandIcon, {
176
204
  size: "medium",
177
- label: "expand"
205
+ label: ""
178
206
  }),
179
207
  onClick: handleTriggerClicked,
180
208
  testId: testId && "".concat(testId, "--trigger")
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "11.3.0",
3
+ "version": "11.4.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { jsx } from '@emotion/react';
2
2
  import type { DropdownMenuProps } from './types';
3
3
  /**
4
4
  * __Dropdown menu__
@@ -9,5 +9,5 @@ import type { DropdownMenuProps } from './types';
9
9
  * - [Code](https://atlassian.design/components/dropdown-menu/code)
10
10
  * - [Usage](https://atlassian.design/components/dropdown-menu/usage)
11
11
  */
12
- declare const DropdownMenu: (props: DropdownMenuProps) => JSX.Element;
12
+ declare const DropdownMenu: (props: DropdownMenuProps) => jsx.JSX.Element;
13
13
  export default DropdownMenu;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "11.3.0",
3
+ "version": "11.4.0",
4
4
  "description": "A dropdown menu displays a list of actions or options to a user.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,11 +30,11 @@
30
30
  "@atlaskit/menu": "^1.3.0",
31
31
  "@atlaskit/popup": "^1.4.0",
32
32
  "@atlaskit/spinner": "^15.0.0",
33
- "@atlaskit/theme": "^12.1.0",
33
+ "@atlaskit/theme": "^12.2.0",
34
34
  "@atlaskit/tokens": "^0.10.0",
35
- "@atlaskit/visually-hidden": "^1.0.0",
35
+ "@atlaskit/visually-hidden": "^1.1.0",
36
36
  "@babel/runtime": "^7.0.0",
37
- "@emotion/core": "^10.0.9",
37
+ "@emotion/react": "^11.7.1",
38
38
  "bind-event-listener": "^2.1.1"
39
39
  },
40
40
  "peerDependencies": {
@@ -44,9 +44,9 @@
44
44
  "devDependencies": {
45
45
  "@atlaskit/avatar": "^21.0.0",
46
46
  "@atlaskit/docs": "*",
47
- "@atlaskit/lozenge": "11.1.11",
48
- "@atlaskit/modal-dialog": "^12.2.0",
49
- "@atlaskit/section-message": "^6.1.0",
47
+ "@atlaskit/lozenge": "11.2.0",
48
+ "@atlaskit/modal-dialog": "^12.3.0",
49
+ "@atlaskit/section-message": "^6.2.0",
50
50
  "@atlaskit/ssr": "*",
51
51
  "@atlaskit/tooltip": "^17.5.0",
52
52
  "@atlaskit/visual-regression": "*",
@@ -60,7 +60,7 @@
60
60
  "react-dom": "^16.8.0",
61
61
  "storybook-addon-performance": "^0.16.0",
62
62
  "tiny-invariant": "^1.2.0",
63
- "typescript": "4.2.4"
63
+ "typescript": "4.3.5"
64
64
  },
65
65
  "keywords": [
66
66
  "atlaskit",