@atlaskit/dropdown-menu 11.5.2 → 11.5.4
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 +13 -0
- package/dist/cjs/dropdown-menu.js +7 -20
- package/dist/cjs/internal/components/menu-wrapper.js +55 -20
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/dropdown-menu.js +8 -18
- package/dist/es2019/internal/components/menu-wrapper.js +44 -7
- package/dist/es2019/version.json +1 -1
- package/dist/esm/dropdown-menu.js +8 -19
- package/dist/esm/internal/components/menu-wrapper.js +51 -12
- package/dist/esm/version.json +1 -1
- package/dist/types/internal/components/menu-wrapper.d.ts +2 -2
- package/dist/types/types.d.ts +3 -0
- package/package.json +8 -14
- package/report.api.md +78 -296
- package/dist/types-ts4.0/checkbox/dropdown-item-checkbox-group.d.ts +0 -16
- package/dist/types-ts4.0/checkbox/dropdown-item-checkbox.d.ts +0 -13
- package/dist/types-ts4.0/dropdown-menu-item-group.d.ts +0 -11
- package/dist/types-ts4.0/dropdown-menu-item.d.ts +0 -13
- package/dist/types-ts4.0/dropdown-menu.d.ts +0 -13
- package/dist/types-ts4.0/index.d.ts +0 -8
- package/dist/types-ts4.0/internal/components/focus-manager.d.ts +0 -19
- package/dist/types-ts4.0/internal/components/menu-wrapper.d.ts +0 -11
- package/dist/types-ts4.0/internal/context/checkbox-group-context.d.ts +0 -5
- package/dist/types-ts4.0/internal/context/selection-store.d.ts +0 -27
- package/dist/types-ts4.0/internal/hooks/use-checkbox-state.d.ts +0 -17
- package/dist/types-ts4.0/internal/hooks/use-radio-state.d.ts +0 -12
- package/dist/types-ts4.0/internal/hooks/use-register-item-with-focus-manager.d.ts +0 -4
- package/dist/types-ts4.0/internal/utils/get-icon-colors.d.ts +0 -8
- package/dist/types-ts4.0/internal/utils/handle-focus.d.ts +0 -2
- package/dist/types-ts4.0/internal/utils/is-checkbox-item.d.ts +0 -1
- package/dist/types-ts4.0/internal/utils/is-radio-item.d.ts +0 -1
- package/dist/types-ts4.0/internal/utils/is-voice-over-supported.d.ts +0 -2
- package/dist/types-ts4.0/internal/utils/reset-options-in-group.d.ts +0 -4
- package/dist/types-ts4.0/internal/utils/use-generated-id.d.ts +0 -5
- package/dist/types-ts4.0/radio/dropdown-item-radio-group.d.ts +0 -25
- package/dist/types-ts4.0/radio/dropdown-item-radio.d.ts +0 -13
- package/dist/types-ts4.0/types.d.ts +0 -289
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/dropdown-menu
|
|
2
2
|
|
|
3
|
+
## 11.5.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a5fa14318a8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a5fa14318a8) - Improve examples and visual regression test coverage.
|
|
8
|
+
|
|
9
|
+
## 11.5.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`625585b8db6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/625585b8db6) - Bug fix to re-position the menu after change in loading state.
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 11.5.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -35,12 +35,8 @@ var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-
|
|
|
35
35
|
|
|
36
36
|
var _popup = _interopRequireDefault(require("@atlaskit/popup"));
|
|
37
37
|
|
|
38
|
-
var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
|
|
39
|
-
|
|
40
38
|
var _constants = require("@atlaskit/theme/constants");
|
|
41
39
|
|
|
42
|
-
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
43
|
-
|
|
44
40
|
var _focusManager = _interopRequireDefault(require("./internal/components/focus-manager"));
|
|
45
41
|
|
|
46
42
|
var _menuWrapper = _interopRequireDefault(require("./internal/components/menu-wrapper"));
|
|
@@ -56,12 +52,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
56
52
|
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
53
|
|
|
58
54
|
var gridSize = (0, _constants.gridSize)();
|
|
59
|
-
var spinnerContainerStyles = (0, _react2.css)({
|
|
60
|
-
display: 'flex',
|
|
61
|
-
minWidth: "".concat(gridSize * 20, "px"),
|
|
62
|
-
padding: "".concat(gridSize * 2.5, "px"),
|
|
63
|
-
justifyContent: 'center'
|
|
64
|
-
});
|
|
65
55
|
var MAX_HEIGHT = "calc(100vh - ".concat(gridSize * 2, "px)");
|
|
66
56
|
var opposites = {
|
|
67
57
|
top: 'bottom',
|
|
@@ -116,8 +106,7 @@ var DropdownMenu = function DropdownMenu(props) {
|
|
|
116
106
|
_props$autoFocus = props.autoFocus,
|
|
117
107
|
autoFocus = _props$autoFocus === void 0 ? false : _props$autoFocus,
|
|
118
108
|
testId = props.testId,
|
|
119
|
-
|
|
120
|
-
statusLabel = _props$statusLabel === void 0 ? 'Loading' : _props$statusLabel,
|
|
109
|
+
statusLabel = props.statusLabel,
|
|
121
110
|
_props$zIndex = props.zIndex,
|
|
122
111
|
zIndex = _props$zIndex === void 0 ? _constants.layers.modal() : _props$zIndex;
|
|
123
112
|
|
|
@@ -237,19 +226,17 @@ var DropdownMenu = function DropdownMenu(props) {
|
|
|
237
226
|
}), _trigger);
|
|
238
227
|
},
|
|
239
228
|
content: function content(_ref) {
|
|
240
|
-
var setInitialFocusRef = _ref.setInitialFocusRef
|
|
229
|
+
var setInitialFocusRef = _ref.setInitialFocusRef,
|
|
230
|
+
update = _ref.update;
|
|
241
231
|
return (0, _react2.jsx)(_focusManager.default, null, (0, _react2.jsx)(_menuWrapper.default, {
|
|
242
232
|
maxHeight: MAX_HEIGHT,
|
|
243
233
|
maxWidth: 800,
|
|
244
234
|
onClose: handleOnClose,
|
|
235
|
+
onUpdate: update,
|
|
236
|
+
isLoading: isLoading,
|
|
237
|
+
statusLabel: statusLabel,
|
|
245
238
|
setInitialFocusRef: isTriggeredUsingKeyboard || autoFocus ? setInitialFocusRef : undefined
|
|
246
|
-
},
|
|
247
|
-
css: spinnerContainerStyles
|
|
248
|
-
}, (0, _react2.jsx)(_spinner.default, {
|
|
249
|
-
size: "small"
|
|
250
|
-
}), (0, _react2.jsx)(_visuallyHidden.default, {
|
|
251
|
-
role: "status"
|
|
252
|
-
}, statusLabel)) : children));
|
|
239
|
+
}, children));
|
|
253
240
|
}
|
|
254
241
|
}));
|
|
255
242
|
};
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
@@ -13,22 +11,44 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
13
11
|
|
|
14
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
13
|
|
|
16
|
-
var _react =
|
|
14
|
+
var _react = require("react");
|
|
15
|
+
|
|
16
|
+
var _react2 = require("@emotion/react");
|
|
17
17
|
|
|
18
18
|
var _menuGroup = _interopRequireDefault(require("@atlaskit/menu/menu-group"));
|
|
19
19
|
|
|
20
|
+
var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
|
|
21
|
+
|
|
22
|
+
var _constants = require("@atlaskit/theme/constants");
|
|
23
|
+
|
|
24
|
+
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
25
|
+
|
|
20
26
|
var _focusManager = require("../components/focus-manager");
|
|
21
27
|
|
|
22
28
|
var _isCheckboxItem = _interopRequireDefault(require("../utils/is-checkbox-item"));
|
|
23
29
|
|
|
24
30
|
var _isRadioItem = _interopRequireDefault(require("../utils/is-radio-item"));
|
|
25
31
|
|
|
26
|
-
var _excluded = ["onClose", "setInitialFocusRef"];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
var _excluded = ["onClose", "onUpdate", "isLoading", "statusLabel", "setInitialFocusRef", "children"];
|
|
33
|
+
var gridSize = (0, _constants.gridSize)();
|
|
34
|
+
var spinnerContainerStyles = (0, _react2.css)({
|
|
35
|
+
display: 'flex',
|
|
36
|
+
minWidth: "".concat(gridSize * 20, "px"),
|
|
37
|
+
padding: "".concat(gridSize * 2.5, "px"),
|
|
38
|
+
justifyContent: 'center'
|
|
39
|
+
});
|
|
31
40
|
|
|
41
|
+
var LoadingIndicator = function LoadingIndicator(_ref) {
|
|
42
|
+
var _ref$statusLabel = _ref.statusLabel,
|
|
43
|
+
statusLabel = _ref$statusLabel === void 0 ? 'Loading' : _ref$statusLabel;
|
|
44
|
+
return (0, _react2.jsx)("div", {
|
|
45
|
+
css: spinnerContainerStyles
|
|
46
|
+
}, (0, _react2.jsx)(_spinner.default, {
|
|
47
|
+
size: "small"
|
|
48
|
+
}), (0, _react2.jsx)(_visuallyHidden.default, {
|
|
49
|
+
role: "status"
|
|
50
|
+
}, statusLabel));
|
|
51
|
+
};
|
|
32
52
|
/**
|
|
33
53
|
*
|
|
34
54
|
* MenuWrapper wraps all the menu items.
|
|
@@ -36,10 +56,16 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
36
56
|
* if a CheckboxItem or RadioItem is clicked.
|
|
37
57
|
* It also sets focus to the first menu item when opened.
|
|
38
58
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
var MenuWrapper = function MenuWrapper(_ref2) {
|
|
62
|
+
var onClose = _ref2.onClose,
|
|
63
|
+
onUpdate = _ref2.onUpdate,
|
|
64
|
+
isLoading = _ref2.isLoading,
|
|
65
|
+
statusLabel = _ref2.statusLabel,
|
|
66
|
+
setInitialFocusRef = _ref2.setInitialFocusRef,
|
|
67
|
+
children = _ref2.children,
|
|
68
|
+
props = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
|
|
43
69
|
|
|
44
70
|
var _useContext = (0, _react.useContext)(_focusManager.FocusManagerContext),
|
|
45
71
|
menuItemRefs = _useContext.menuItemRefs;
|
|
@@ -56,14 +82,23 @@ var MenuWrapper = function MenuWrapper(_ref) {
|
|
|
56
82
|
if (isTargetMenuItemOrDecendant && onClose) {
|
|
57
83
|
onClose(e);
|
|
58
84
|
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
},
|
|
85
|
+
}; // Using useEffect here causes a flicker.
|
|
86
|
+
// useLayoutEffect ensures that the update and render happen in the same
|
|
87
|
+
// rAF tick.
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
(0, _react.useLayoutEffect)(function () {
|
|
91
|
+
onUpdate();
|
|
92
|
+
}, [isLoading, onUpdate]);
|
|
93
|
+
setInitialFocusRef && setInitialFocusRef(menuItemRefs[0]);
|
|
94
|
+
return (// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
95
|
+
(0, _react2.jsx)(_menuGroup.default, (0, _extends2.default)({
|
|
96
|
+
role: "menu",
|
|
97
|
+
onClick: closeOnMenuItemClick
|
|
98
|
+
}, props), isLoading ? (0, _react2.jsx)(LoadingIndicator, {
|
|
99
|
+
statusLabel: statusLabel
|
|
100
|
+
}) : children)
|
|
101
|
+
);
|
|
67
102
|
};
|
|
68
103
|
|
|
69
104
|
var _default = MenuWrapper;
|
package/dist/cjs/version.json
CHANGED
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { 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';
|
|
@@ -11,20 +11,12 @@ import useControlledState from '@atlaskit/ds-lib/use-controlled';
|
|
|
11
11
|
import useFocus from '@atlaskit/ds-lib/use-focus-event';
|
|
12
12
|
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
13
13
|
import Popup from '@atlaskit/popup';
|
|
14
|
-
import Spinner from '@atlaskit/spinner';
|
|
15
14
|
import { gridSize as gridSizeFn, layers } from '@atlaskit/theme/constants';
|
|
16
|
-
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
17
15
|
import FocusManager from './internal/components/focus-manager';
|
|
18
16
|
import MenuWrapper from './internal/components/menu-wrapper';
|
|
19
17
|
import SelectionStore from './internal/context/selection-store';
|
|
20
18
|
import useGeneratedId from './internal/utils/use-generated-id';
|
|
21
19
|
const gridSize = gridSizeFn();
|
|
22
|
-
const spinnerContainerStyles = css({
|
|
23
|
-
display: 'flex',
|
|
24
|
-
minWidth: `${gridSize * 20}px`,
|
|
25
|
-
padding: `${gridSize * 2.5}px`,
|
|
26
|
-
justifyContent: 'center'
|
|
27
|
-
});
|
|
28
20
|
const MAX_HEIGHT = `calc(100vh - ${gridSize * 2}px)`;
|
|
29
21
|
const opposites = {
|
|
30
22
|
top: 'bottom',
|
|
@@ -74,7 +66,7 @@ const DropdownMenu = props => {
|
|
|
74
66
|
isLoading = false,
|
|
75
67
|
autoFocus = false,
|
|
76
68
|
testId,
|
|
77
|
-
statusLabel
|
|
69
|
+
statusLabel,
|
|
78
70
|
zIndex = layers.modal()
|
|
79
71
|
} = props;
|
|
80
72
|
const [isLocalOpen, setLocalIsOpen] = useControlledState(isOpen, () => defaultOpen);
|
|
@@ -185,19 +177,17 @@ const DropdownMenu = props => {
|
|
|
185
177
|
}), trigger);
|
|
186
178
|
},
|
|
187
179
|
content: ({
|
|
188
|
-
setInitialFocusRef
|
|
180
|
+
setInitialFocusRef,
|
|
181
|
+
update
|
|
189
182
|
}) => jsx(FocusManager, null, jsx(MenuWrapper, {
|
|
190
183
|
maxHeight: MAX_HEIGHT,
|
|
191
184
|
maxWidth: 800,
|
|
192
185
|
onClose: handleOnClose,
|
|
186
|
+
onUpdate: update,
|
|
187
|
+
isLoading: isLoading,
|
|
188
|
+
statusLabel: statusLabel,
|
|
193
189
|
setInitialFocusRef: isTriggeredUsingKeyboard || autoFocus ? setInitialFocusRef : undefined
|
|
194
|
-
},
|
|
195
|
-
css: spinnerContainerStyles
|
|
196
|
-
}, jsx(Spinner, {
|
|
197
|
-
size: "small"
|
|
198
|
-
}), jsx(VisuallyHidden, {
|
|
199
|
-
role: "status"
|
|
200
|
-
}, statusLabel)) : children))
|
|
190
|
+
}, children))
|
|
201
191
|
}));
|
|
202
192
|
};
|
|
203
193
|
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { useContext, useLayoutEffect } from 'react';
|
|
5
|
+
import { css, jsx } from '@emotion/react';
|
|
3
6
|
import MenuGroup from '@atlaskit/menu/menu-group';
|
|
7
|
+
import Spinner from '@atlaskit/spinner';
|
|
8
|
+
import { gridSize as gridSizeFn } from '@atlaskit/theme/constants';
|
|
9
|
+
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
4
10
|
import { FocusManagerContext } from '../components/focus-manager';
|
|
5
11
|
import isCheckboxItem from '../utils/is-checkbox-item';
|
|
6
12
|
import isRadioItem from '../utils/is-radio-item';
|
|
13
|
+
const gridSize = gridSizeFn();
|
|
14
|
+
const spinnerContainerStyles = css({
|
|
15
|
+
display: 'flex',
|
|
16
|
+
minWidth: `${gridSize * 20}px`,
|
|
17
|
+
padding: `${gridSize * 2.5}px`,
|
|
18
|
+
justifyContent: 'center'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const LoadingIndicator = ({
|
|
22
|
+
statusLabel = 'Loading'
|
|
23
|
+
}) => jsx("div", {
|
|
24
|
+
css: spinnerContainerStyles
|
|
25
|
+
}, jsx(Spinner, {
|
|
26
|
+
size: "small"
|
|
27
|
+
}), jsx(VisuallyHidden, {
|
|
28
|
+
role: "status"
|
|
29
|
+
}, statusLabel));
|
|
7
30
|
/**
|
|
8
31
|
*
|
|
9
32
|
* MenuWrapper wraps all the menu items.
|
|
@@ -12,9 +35,14 @@ import isRadioItem from '../utils/is-radio-item';
|
|
|
12
35
|
* It also sets focus to the first menu item when opened.
|
|
13
36
|
*/
|
|
14
37
|
|
|
38
|
+
|
|
15
39
|
const MenuWrapper = ({
|
|
16
40
|
onClose,
|
|
41
|
+
onUpdate,
|
|
42
|
+
isLoading,
|
|
43
|
+
statusLabel,
|
|
17
44
|
setInitialFocusRef,
|
|
45
|
+
children,
|
|
18
46
|
...props
|
|
19
47
|
}) => {
|
|
20
48
|
const {
|
|
@@ -33,14 +61,23 @@ const MenuWrapper = ({
|
|
|
33
61
|
if (isTargetMenuItemOrDecendant && onClose) {
|
|
34
62
|
onClose(e);
|
|
35
63
|
}
|
|
36
|
-
};
|
|
64
|
+
}; // Using useEffect here causes a flicker.
|
|
65
|
+
// useLayoutEffect ensures that the update and render happen in the same
|
|
66
|
+
// rAF tick.
|
|
37
67
|
|
|
38
|
-
setInitialFocusRef && setInitialFocusRef(menuItemRefs[0]); // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
39
68
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
69
|
+
useLayoutEffect(() => {
|
|
70
|
+
onUpdate();
|
|
71
|
+
}, [isLoading, onUpdate]);
|
|
72
|
+
setInitialFocusRef && setInitialFocusRef(menuItemRefs[0]);
|
|
73
|
+
return (// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
74
|
+
jsx(MenuGroup, _extends({
|
|
75
|
+
role: "menu",
|
|
76
|
+
onClick: closeOnMenuItemClick
|
|
77
|
+
}, props), isLoading ? jsx(LoadingIndicator, {
|
|
78
|
+
statusLabel: statusLabel
|
|
79
|
+
}) : children)
|
|
80
|
+
);
|
|
44
81
|
};
|
|
45
82
|
|
|
46
83
|
export default MenuWrapper;
|
package/dist/es2019/version.json
CHANGED
|
@@ -10,7 +10,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
10
10
|
|
|
11
11
|
/** @jsx jsx */
|
|
12
12
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
13
|
-
import {
|
|
13
|
+
import { 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';
|
|
@@ -19,20 +19,12 @@ import useControlledState from '@atlaskit/ds-lib/use-controlled';
|
|
|
19
19
|
import useFocus from '@atlaskit/ds-lib/use-focus-event';
|
|
20
20
|
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
21
21
|
import Popup from '@atlaskit/popup';
|
|
22
|
-
import Spinner from '@atlaskit/spinner';
|
|
23
22
|
import { gridSize as gridSizeFn, layers } from '@atlaskit/theme/constants';
|
|
24
|
-
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
25
23
|
import FocusManager from './internal/components/focus-manager';
|
|
26
24
|
import MenuWrapper from './internal/components/menu-wrapper';
|
|
27
25
|
import SelectionStore from './internal/context/selection-store';
|
|
28
26
|
import useGeneratedId from './internal/utils/use-generated-id';
|
|
29
27
|
var gridSize = gridSizeFn();
|
|
30
|
-
var spinnerContainerStyles = css({
|
|
31
|
-
display: 'flex',
|
|
32
|
-
minWidth: "".concat(gridSize * 20, "px"),
|
|
33
|
-
padding: "".concat(gridSize * 2.5, "px"),
|
|
34
|
-
justifyContent: 'center'
|
|
35
|
-
});
|
|
36
28
|
var MAX_HEIGHT = "calc(100vh - ".concat(gridSize * 2, "px)");
|
|
37
29
|
var opposites = {
|
|
38
30
|
top: 'bottom',
|
|
@@ -87,8 +79,7 @@ var DropdownMenu = function DropdownMenu(props) {
|
|
|
87
79
|
_props$autoFocus = props.autoFocus,
|
|
88
80
|
autoFocus = _props$autoFocus === void 0 ? false : _props$autoFocus,
|
|
89
81
|
testId = props.testId,
|
|
90
|
-
|
|
91
|
-
statusLabel = _props$statusLabel === void 0 ? 'Loading' : _props$statusLabel,
|
|
82
|
+
statusLabel = props.statusLabel,
|
|
92
83
|
_props$zIndex = props.zIndex,
|
|
93
84
|
zIndex = _props$zIndex === void 0 ? layers.modal() : _props$zIndex;
|
|
94
85
|
|
|
@@ -209,19 +200,17 @@ var DropdownMenu = function DropdownMenu(props) {
|
|
|
209
200
|
}), _trigger);
|
|
210
201
|
},
|
|
211
202
|
content: function content(_ref) {
|
|
212
|
-
var setInitialFocusRef = _ref.setInitialFocusRef
|
|
203
|
+
var setInitialFocusRef = _ref.setInitialFocusRef,
|
|
204
|
+
update = _ref.update;
|
|
213
205
|
return jsx(FocusManager, null, jsx(MenuWrapper, {
|
|
214
206
|
maxHeight: MAX_HEIGHT,
|
|
215
207
|
maxWidth: 800,
|
|
216
208
|
onClose: handleOnClose,
|
|
209
|
+
onUpdate: update,
|
|
210
|
+
isLoading: isLoading,
|
|
211
|
+
statusLabel: statusLabel,
|
|
217
212
|
setInitialFocusRef: isTriggeredUsingKeyboard || autoFocus ? setInitialFocusRef : undefined
|
|
218
|
-
},
|
|
219
|
-
css: spinnerContainerStyles
|
|
220
|
-
}, jsx(Spinner, {
|
|
221
|
-
size: "small"
|
|
222
|
-
}), jsx(VisuallyHidden, {
|
|
223
|
-
role: "status"
|
|
224
|
-
}, statusLabel)) : children));
|
|
213
|
+
}, children));
|
|
225
214
|
}
|
|
226
215
|
}));
|
|
227
216
|
};
|
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["onClose", "setInitialFocusRef"];
|
|
4
|
-
|
|
3
|
+
var _excluded = ["onClose", "onUpdate", "isLoading", "statusLabel", "setInitialFocusRef", "children"];
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
6
|
+
import { useContext, useLayoutEffect } from 'react';
|
|
7
|
+
import { css, jsx } from '@emotion/react';
|
|
5
8
|
import MenuGroup from '@atlaskit/menu/menu-group';
|
|
9
|
+
import Spinner from '@atlaskit/spinner';
|
|
10
|
+
import { gridSize as gridSizeFn } from '@atlaskit/theme/constants';
|
|
11
|
+
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
6
12
|
import { FocusManagerContext } from '../components/focus-manager';
|
|
7
13
|
import isCheckboxItem from '../utils/is-checkbox-item';
|
|
8
14
|
import isRadioItem from '../utils/is-radio-item';
|
|
15
|
+
var gridSize = gridSizeFn();
|
|
16
|
+
var spinnerContainerStyles = css({
|
|
17
|
+
display: 'flex',
|
|
18
|
+
minWidth: "".concat(gridSize * 20, "px"),
|
|
19
|
+
padding: "".concat(gridSize * 2.5, "px"),
|
|
20
|
+
justifyContent: 'center'
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
var LoadingIndicator = function LoadingIndicator(_ref) {
|
|
24
|
+
var _ref$statusLabel = _ref.statusLabel,
|
|
25
|
+
statusLabel = _ref$statusLabel === void 0 ? 'Loading' : _ref$statusLabel;
|
|
26
|
+
return jsx("div", {
|
|
27
|
+
css: spinnerContainerStyles
|
|
28
|
+
}, jsx(Spinner, {
|
|
29
|
+
size: "small"
|
|
30
|
+
}), jsx(VisuallyHidden, {
|
|
31
|
+
role: "status"
|
|
32
|
+
}, statusLabel));
|
|
33
|
+
};
|
|
9
34
|
/**
|
|
10
35
|
*
|
|
11
36
|
* MenuWrapper wraps all the menu items.
|
|
@@ -14,10 +39,15 @@ import isRadioItem from '../utils/is-radio-item';
|
|
|
14
39
|
* It also sets focus to the first menu item when opened.
|
|
15
40
|
*/
|
|
16
41
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
42
|
+
|
|
43
|
+
var MenuWrapper = function MenuWrapper(_ref2) {
|
|
44
|
+
var onClose = _ref2.onClose,
|
|
45
|
+
onUpdate = _ref2.onUpdate,
|
|
46
|
+
isLoading = _ref2.isLoading,
|
|
47
|
+
statusLabel = _ref2.statusLabel,
|
|
48
|
+
setInitialFocusRef = _ref2.setInitialFocusRef,
|
|
49
|
+
children = _ref2.children,
|
|
50
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
21
51
|
|
|
22
52
|
var _useContext = useContext(FocusManagerContext),
|
|
23
53
|
menuItemRefs = _useContext.menuItemRefs;
|
|
@@ -34,14 +64,23 @@ var MenuWrapper = function MenuWrapper(_ref) {
|
|
|
34
64
|
if (isTargetMenuItemOrDecendant && onClose) {
|
|
35
65
|
onClose(e);
|
|
36
66
|
}
|
|
37
|
-
};
|
|
67
|
+
}; // Using useEffect here causes a flicker.
|
|
68
|
+
// useLayoutEffect ensures that the update and render happen in the same
|
|
69
|
+
// rAF tick.
|
|
38
70
|
|
|
39
|
-
setInitialFocusRef && setInitialFocusRef(menuItemRefs[0]); // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
40
71
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
72
|
+
useLayoutEffect(function () {
|
|
73
|
+
onUpdate();
|
|
74
|
+
}, [isLoading, onUpdate]);
|
|
75
|
+
setInitialFocusRef && setInitialFocusRef(menuItemRefs[0]);
|
|
76
|
+
return (// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
77
|
+
jsx(MenuGroup, _extends({
|
|
78
|
+
role: "menu",
|
|
79
|
+
onClick: closeOnMenuItemClick
|
|
80
|
+
}, props), isLoading ? jsx(LoadingIndicator, {
|
|
81
|
+
statusLabel: statusLabel
|
|
82
|
+
}) : children)
|
|
83
|
+
);
|
|
45
84
|
};
|
|
46
85
|
|
|
47
86
|
export default MenuWrapper;
|
package/dist/esm/version.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
2
|
import { MenuWrapperProps } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -7,5 +7,5 @@ import { MenuWrapperProps } from '../../types';
|
|
|
7
7
|
* if a CheckboxItem or RadioItem is clicked.
|
|
8
8
|
* It also sets focus to the first menu item when opened.
|
|
9
9
|
*/
|
|
10
|
-
declare const MenuWrapper: ({ onClose, setInitialFocusRef, ...props }: MenuWrapperProps) => JSX.Element;
|
|
10
|
+
declare const MenuWrapper: ({ onClose, onUpdate, isLoading, statusLabel, setInitialFocusRef, children, ...props }: MenuWrapperProps) => jsx.JSX.Element;
|
|
11
11
|
export default MenuWrapper;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -46,6 +46,9 @@ export interface OnOpenChangeArgs {
|
|
|
46
46
|
export interface MenuWrapperProps extends MenuGroupProps {
|
|
47
47
|
setInitialFocusRef?: ContentProps['setInitialFocusRef'];
|
|
48
48
|
onClose?: ContentProps['onClose'];
|
|
49
|
+
onUpdate: ContentProps['update'];
|
|
50
|
+
isLoading?: DropdownMenuProps['isLoading'];
|
|
51
|
+
statusLabel?: DropdownMenuProps['statusLabel'];
|
|
49
52
|
}
|
|
50
53
|
export interface DropdownMenuGroupProps extends SectionProps {
|
|
51
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/dropdown-menu",
|
|
3
|
-
"version": "11.5.
|
|
3
|
+
"version": "11.5.4",
|
|
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/"
|
|
@@ -12,19 +12,11 @@
|
|
|
12
12
|
"module": "dist/esm/index.js",
|
|
13
13
|
"module:es2019": "dist/es2019/index.js",
|
|
14
14
|
"types": "dist/types/index.d.ts",
|
|
15
|
-
"typesVersions": {
|
|
16
|
-
">=4.0 <4.5": {
|
|
17
|
-
"*": [
|
|
18
|
-
"dist/types-ts4.0/*",
|
|
19
|
-
"dist/types-ts4.0/index.d.ts"
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
15
|
"sideEffects": false,
|
|
24
16
|
"atlaskit:src": "src/index.tsx",
|
|
25
17
|
"atlassian": {
|
|
26
|
-
"disableProductCI": true,
|
|
27
18
|
"team": "Design System Team",
|
|
19
|
+
"disableProductCI": true,
|
|
28
20
|
"releaseModel": "scheduled",
|
|
29
21
|
"website": {
|
|
30
22
|
"name": "Dropdown menu",
|
|
@@ -32,13 +24,13 @@
|
|
|
32
24
|
}
|
|
33
25
|
},
|
|
34
26
|
"dependencies": {
|
|
35
|
-
"@atlaskit/button": "^16.
|
|
27
|
+
"@atlaskit/button": "^16.4.0",
|
|
36
28
|
"@atlaskit/codemod-utils": "^4.1.0",
|
|
37
29
|
"@atlaskit/ds-lib": "^2.1.0",
|
|
38
30
|
"@atlaskit/icon": "^21.11.0",
|
|
39
|
-
"@atlaskit/menu": "^1.
|
|
31
|
+
"@atlaskit/menu": "^1.4.0",
|
|
40
32
|
"@atlaskit/popup": "^1.5.0",
|
|
41
|
-
"@atlaskit/spinner": "^15.
|
|
33
|
+
"@atlaskit/spinner": "^15.2.0",
|
|
42
34
|
"@atlaskit/theme": "^12.2.0",
|
|
43
35
|
"@atlaskit/tokens": "^0.10.0",
|
|
44
36
|
"@atlaskit/visually-hidden": "^1.1.0",
|
|
@@ -53,7 +45,9 @@
|
|
|
53
45
|
"devDependencies": {
|
|
54
46
|
"@atlaskit/avatar": "^21.1.0",
|
|
55
47
|
"@atlaskit/docs": "*",
|
|
56
|
-
"@atlaskit/
|
|
48
|
+
"@atlaskit/ds-explorations": "^1.0.0",
|
|
49
|
+
"@atlaskit/heading": "^0.1.18",
|
|
50
|
+
"@atlaskit/lozenge": "11.3.0",
|
|
57
51
|
"@atlaskit/modal-dialog": "^12.4.0",
|
|
58
52
|
"@atlaskit/section-message": "^6.3.0",
|
|
59
53
|
"@atlaskit/ssr": "*",
|