@atlaskit/dropdown-menu 11.5.1 → 11.5.3
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/dist/types-ts4.0/internal/components/menu-wrapper.d.ts +2 -2
- package/dist/types-ts4.0/types.d.ts +3 -0
- package/package.json +15 -12
- package/report.api.md +79 -294
- package/dist/cjs/visual-regression/index.js +0 -93
- package/dist/es2019/visual-regression/index.js +0 -30
- package/dist/esm/visual-regression/index.js +0 -86
- package/dist/types/visual-regression/index.d.ts +0 -1
- package/dist/types-ts4.0/visual-regression/index.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/dropdown-menu
|
|
2
2
|
|
|
3
|
+
## 11.5.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`625585b8db6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/625585b8db6) - Bug fix to re-position the menu after change in loading state.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 11.5.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`bc989043572`](https://bitbucket.org/atlassian/atlassian-frontend/commits/bc989043572) - Internal changes to apply spacing tokens. This should be a no-op change.
|
|
15
|
+
|
|
3
16
|
## 11.5.1
|
|
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
|
}
|
|
@@ -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;
|
|
@@ -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.3",
|
|
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/"
|
|
@@ -15,13 +15,15 @@
|
|
|
15
15
|
"typesVersions": {
|
|
16
16
|
">=4.0 <4.5": {
|
|
17
17
|
"*": [
|
|
18
|
-
"dist/types-ts4.0/*"
|
|
18
|
+
"dist/types-ts4.0/*",
|
|
19
|
+
"dist/types-ts4.0/index.d.ts"
|
|
19
20
|
]
|
|
20
21
|
}
|
|
21
22
|
},
|
|
22
23
|
"sideEffects": false,
|
|
23
24
|
"atlaskit:src": "src/index.tsx",
|
|
24
25
|
"atlassian": {
|
|
26
|
+
"disableProductCI": true,
|
|
25
27
|
"team": "Design System Team",
|
|
26
28
|
"releaseModel": "scheduled",
|
|
27
29
|
"website": {
|
|
@@ -30,13 +32,13 @@
|
|
|
30
32
|
}
|
|
31
33
|
},
|
|
32
34
|
"dependencies": {
|
|
33
|
-
"@atlaskit/button": "^16.
|
|
35
|
+
"@atlaskit/button": "^16.4.0",
|
|
34
36
|
"@atlaskit/codemod-utils": "^4.1.0",
|
|
35
37
|
"@atlaskit/ds-lib": "^2.1.0",
|
|
36
|
-
"@atlaskit/icon": "^21.
|
|
37
|
-
"@atlaskit/menu": "^1.
|
|
38
|
-
"@atlaskit/popup": "^1.
|
|
39
|
-
"@atlaskit/spinner": "^15.
|
|
38
|
+
"@atlaskit/icon": "^21.11.0",
|
|
39
|
+
"@atlaskit/menu": "^1.4.0",
|
|
40
|
+
"@atlaskit/popup": "^1.5.0",
|
|
41
|
+
"@atlaskit/spinner": "^15.2.0",
|
|
40
42
|
"@atlaskit/theme": "^12.2.0",
|
|
41
43
|
"@atlaskit/tokens": "^0.10.0",
|
|
42
44
|
"@atlaskit/visually-hidden": "^1.1.0",
|
|
@@ -49,13 +51,13 @@
|
|
|
49
51
|
"react-dom": "^16.8.0"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
|
-
"@atlaskit/avatar": "^21.
|
|
54
|
+
"@atlaskit/avatar": "^21.1.0",
|
|
53
55
|
"@atlaskit/docs": "*",
|
|
54
|
-
"@atlaskit/lozenge": "11.
|
|
55
|
-
"@atlaskit/modal-dialog": "^12.
|
|
56
|
-
"@atlaskit/section-message": "^6.
|
|
56
|
+
"@atlaskit/lozenge": "11.3.0",
|
|
57
|
+
"@atlaskit/modal-dialog": "^12.4.0",
|
|
58
|
+
"@atlaskit/section-message": "^6.3.0",
|
|
57
59
|
"@atlaskit/ssr": "*",
|
|
58
|
-
"@atlaskit/tooltip": "^17.
|
|
60
|
+
"@atlaskit/tooltip": "^17.6.0",
|
|
59
61
|
"@atlaskit/visual-regression": "*",
|
|
60
62
|
"@atlaskit/webdriver-runner": "*",
|
|
61
63
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
@@ -82,6 +84,7 @@
|
|
|
82
84
|
"dom-events": "use-bind-event-listener",
|
|
83
85
|
"ui-components": "lite-mode",
|
|
84
86
|
"design-system": "v1",
|
|
87
|
+
"design-tokens": "spacing",
|
|
85
88
|
"styling": [
|
|
86
89
|
"static",
|
|
87
90
|
"emotion"
|
package/report.api.md
CHANGED
|
@@ -2,11 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
4
|
|
|
5
|
+
<!--
|
|
6
|
+
Generated API Report version: 2.0
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
[Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
|
|
10
|
+
|
|
5
11
|
```ts
|
|
6
12
|
/// <reference types="react" />
|
|
7
13
|
|
|
8
14
|
import type { CustomItemProps } from '@atlaskit/menu/types';
|
|
9
15
|
import { default as DropdownItemGroup } from '@atlaskit/menu/section';
|
|
16
|
+
import { jsx } from '@emotion/react';
|
|
10
17
|
import { KeyboardEvent as KeyboardEvent_2 } from 'react';
|
|
11
18
|
import { MouseEvent as MouseEvent_2 } from 'react';
|
|
12
19
|
import { ReactElement } from 'react';
|
|
@@ -16,363 +23,141 @@ import type { SectionProps } from '@atlaskit/menu';
|
|
|
16
23
|
import type { SectionProps as SectionProps_2 } from '@atlaskit/menu/types';
|
|
17
24
|
import type { TriggerProps } from '@atlaskit/popup/types';
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
triggerRef: Ref<HTMLElement>;
|
|
24
|
-
/**
|
|
25
|
-
* Makes the trigger appear selected.
|
|
26
|
-
*/
|
|
26
|
+
// @public (undocumented)
|
|
27
|
+
export interface CustomTriggerProps<
|
|
28
|
+
TriggerElement extends HTMLElement = HTMLElement
|
|
29
|
+
> extends Omit<TriggerProps, 'ref'> {
|
|
27
30
|
isSelected?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Event that is triggered when the element is clicked.
|
|
30
|
-
*/
|
|
31
31
|
onClick?: (e: MouseEvent_2 | KeyboardEvent_2) => void;
|
|
32
|
-
/**
|
|
33
|
-
* A `testId` prop is provided for specified elements, which is a unique
|
|
34
|
-
* string that appears as a data attribute `data-testid` in the rendered code,
|
|
35
|
-
* serving as a hook for automated tests.
|
|
36
|
-
*
|
|
37
|
-
* As dropdown-menu is composed of different components, we passed down the testId to the sub component you want to test:
|
|
38
|
-
* - `testId--trigger` to get the menu trigger.
|
|
39
|
-
* - `testId--content` to get the dropdown content trigger.
|
|
40
|
-
*/
|
|
41
32
|
testId?: string;
|
|
33
|
+
triggerRef: Ref<TriggerElement>;
|
|
42
34
|
}
|
|
43
35
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*
|
|
47
|
-
* A dropdown item populates the dropdown menu with items. Every item should be inside a dropdown item group.
|
|
48
|
-
*
|
|
49
|
-
* - [Examples](https://atlassian.design/components/dropdown-item/examples)
|
|
50
|
-
* - [Code](https://atlassian.design/components/dropdown-item/code)
|
|
51
|
-
* - [Usage](https://atlassian.design/components/dropdown-item/usage)
|
|
52
|
-
*/
|
|
53
|
-
export declare const DropdownItem: (props: DropdownItemProps) => JSX.Element;
|
|
36
|
+
// @public
|
|
37
|
+
export const DropdownItem: (props: DropdownItemProps) => JSX.Element;
|
|
54
38
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*
|
|
58
|
-
* A dropdown item checkbox creates groups that have multiple selections.
|
|
59
|
-
*
|
|
60
|
-
* - [Examples](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/examples)
|
|
61
|
-
* - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/code)
|
|
62
|
-
* - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/usage)
|
|
63
|
-
*/
|
|
64
|
-
export declare const DropdownItemCheckbox: (
|
|
39
|
+
// @public
|
|
40
|
+
export const DropdownItemCheckbox: (
|
|
65
41
|
props: DropdownItemCheckboxProps,
|
|
66
42
|
) => JSX.Element;
|
|
67
43
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
*
|
|
71
|
-
* A wrapping element for dropdown menu checkbox items.
|
|
72
|
-
*
|
|
73
|
-
*/
|
|
74
|
-
export declare const DropdownItemCheckboxGroup: (
|
|
44
|
+
// @public
|
|
45
|
+
export const DropdownItemCheckboxGroup: (
|
|
75
46
|
props: DropdownItemCheckboxGroupProps,
|
|
76
47
|
) => JSX.Element;
|
|
77
48
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
* Unique identifier for the checkbox group.
|
|
81
|
-
*/
|
|
49
|
+
// @public (undocumented)
|
|
50
|
+
interface DropdownItemCheckboxGroupProps extends SectionProps {
|
|
82
51
|
id: string;
|
|
83
52
|
}
|
|
84
53
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
* Primary content for the item.
|
|
88
|
-
*/
|
|
54
|
+
// @public (undocumented)
|
|
55
|
+
interface DropdownItemCheckboxProps {
|
|
89
56
|
children: React.ReactNode;
|
|
90
|
-
|
|
91
|
-
* Description of the item.
|
|
92
|
-
* This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
|
|
93
|
-
*/
|
|
57
|
+
defaultSelected?: boolean;
|
|
94
58
|
description?: string | JSX.Element;
|
|
95
|
-
|
|
96
|
-
* Makes the checkbox appear disabled as well as removing interactivity.
|
|
97
|
-
*/
|
|
59
|
+
id: string;
|
|
98
60
|
isDisabled?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* When `true` the title of the item will wrap multiple lines if it's long enough.
|
|
101
|
-
*/
|
|
102
|
-
shouldTitleWrap?: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* When `true` the description of the item will wrap multiple lines if it's long enough.
|
|
105
|
-
*/
|
|
106
|
-
shouldDescriptionWrap?: boolean;
|
|
107
|
-
/**
|
|
108
|
-
* Event that is triggered when the checkbox is clicked.
|
|
109
|
-
*/
|
|
110
|
-
onClick?: (e: MouseEvent_2 | KeyboardEvent_2) => void;
|
|
111
|
-
/**
|
|
112
|
-
* Sets whether the checkbox is checked or unchecked.
|
|
113
|
-
*/
|
|
114
61
|
isSelected?: boolean;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
defaultSelected?: boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Unique id of a checkbox
|
|
121
|
-
*/
|
|
122
|
-
id: string;
|
|
123
|
-
/**
|
|
124
|
-
* Adds a title attribute to the root item element.
|
|
125
|
-
*/
|
|
126
|
-
title?: string;
|
|
127
|
-
/**
|
|
128
|
-
* A `testId` prop is provided for specified elements,
|
|
129
|
-
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
130
|
-
* serving as a hook for automated tests.
|
|
131
|
-
*/
|
|
62
|
+
onClick?: (e: MouseEvent_2 | KeyboardEvent_2) => void;
|
|
63
|
+
shouldDescriptionWrap?: boolean;
|
|
64
|
+
shouldTitleWrap?: boolean;
|
|
132
65
|
testId?: string;
|
|
66
|
+
title?: string;
|
|
133
67
|
}
|
|
134
68
|
|
|
135
69
|
export { DropdownItemGroup };
|
|
136
70
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
* Primary content for the item.
|
|
140
|
-
*/
|
|
71
|
+
// @public (undocumented)
|
|
72
|
+
export interface DropdownItemProps {
|
|
141
73
|
children: React.ReactNode;
|
|
142
|
-
/**
|
|
143
|
-
* Custom component to render as an item.
|
|
144
|
-
*/
|
|
145
74
|
component?: CustomItemProps['component'];
|
|
146
|
-
/**
|
|
147
|
-
* Description of the item.
|
|
148
|
-
* This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
|
|
149
|
-
*/
|
|
150
75
|
description?: string | JSX.Element;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
76
|
+
elemAfter?: React.ReactNode;
|
|
77
|
+
elemBefore?: React.ReactNode;
|
|
78
|
+
href?: string;
|
|
154
79
|
isDisabled?: boolean;
|
|
155
|
-
/**
|
|
156
|
-
* When `true` the title of the item will wrap multiple lines if it's long enough.
|
|
157
|
-
*/
|
|
158
|
-
shouldTitleWrap?: boolean;
|
|
159
|
-
/**
|
|
160
|
-
* When `true` the description of the item will wrap multiple lines if it's long enough.
|
|
161
|
-
*/
|
|
162
|
-
shouldDescriptionWrap?: boolean;
|
|
163
|
-
/**
|
|
164
|
-
* Event that is triggered when the element is clicked.
|
|
165
|
-
*/
|
|
166
|
-
onClick?: (e: MouseEvent_2 | KeyboardEvent_2) => void;
|
|
167
|
-
/**
|
|
168
|
-
* Makes the element appear selected.
|
|
169
|
-
*/
|
|
170
80
|
isSelected?: boolean;
|
|
171
|
-
|
|
172
|
-
* Link to another page.
|
|
173
|
-
*/
|
|
174
|
-
href?: string;
|
|
175
|
-
/**
|
|
176
|
-
* Where to display the linked URL,
|
|
177
|
-
* see [anchor information](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) on mdn for more information.
|
|
178
|
-
*/
|
|
179
|
-
target?: string;
|
|
180
|
-
/**
|
|
181
|
-
* Adds a title attribute to the root item element.
|
|
182
|
-
*/
|
|
183
|
-
title?: string;
|
|
184
|
-
/**
|
|
185
|
-
* Element to render before the item text.
|
|
186
|
-
* Generally should be an [icon](https://atlaskit.atlassian.com/packages/design-system/icon) component.
|
|
187
|
-
*/
|
|
188
|
-
elemBefore?: React.ReactNode;
|
|
189
|
-
/**
|
|
190
|
-
* Element to render after the item text.
|
|
191
|
-
* Generally should be an [icon](https://atlaskit.atlassian.com/packages/design-system/icon) component.
|
|
192
|
-
*/
|
|
193
|
-
elemAfter?: React.ReactNode;
|
|
194
|
-
/**
|
|
195
|
-
* The relationship of the linked URL as space-separated link types.
|
|
196
|
-
* Generally you'll want to set this to "noopener noreferrer" when `target` is "_blank".
|
|
197
|
-
*/
|
|
81
|
+
onClick?: (e: MouseEvent_2 | KeyboardEvent_2) => void;
|
|
198
82
|
rel?: string;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
* serving as a hook for automated tests.
|
|
203
|
-
*/
|
|
83
|
+
shouldDescriptionWrap?: boolean;
|
|
84
|
+
shouldTitleWrap?: boolean;
|
|
85
|
+
target?: string;
|
|
204
86
|
testId?: string;
|
|
87
|
+
title?: string;
|
|
205
88
|
}
|
|
206
89
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
*
|
|
210
|
-
* A dropdown item radio displays groups that have a single selection.
|
|
211
|
-
*
|
|
212
|
-
* - [Examples](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/examples)
|
|
213
|
-
* - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/code)
|
|
214
|
-
* - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/usage)
|
|
215
|
-
*/
|
|
216
|
-
export declare const DropdownItemRadio: (
|
|
217
|
-
props: DropdownItemRadioProps,
|
|
218
|
-
) => JSX.Element;
|
|
90
|
+
// @public
|
|
91
|
+
export const DropdownItemRadio: (props: DropdownItemRadioProps) => JSX.Element;
|
|
219
92
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
* Store which manages the selection state for each DropdownItemRadio
|
|
223
|
-
* across mount and unmounts.
|
|
224
|
-
*
|
|
225
|
-
*/
|
|
226
|
-
export declare const DropdownItemRadioGroup: (
|
|
93
|
+
// @public
|
|
94
|
+
export const DropdownItemRadioGroup: (
|
|
227
95
|
props: DropdownItemRadioGroupProps,
|
|
228
96
|
) => JSX.Element;
|
|
229
97
|
|
|
230
|
-
|
|
98
|
+
// @public (undocumented)
|
|
99
|
+
interface DropdownItemRadioGroupProps extends SectionProps {
|
|
100
|
+
// (undocumented)
|
|
231
101
|
id: string;
|
|
232
102
|
}
|
|
233
103
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
* Primary content for the item.
|
|
237
|
-
*/
|
|
104
|
+
// @public (undocumented)
|
|
105
|
+
interface DropdownItemRadioProps {
|
|
238
106
|
children: React.ReactNode;
|
|
239
|
-
|
|
240
|
-
* Description of the item.
|
|
241
|
-
* This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
|
|
242
|
-
*/
|
|
107
|
+
defaultSelected?: boolean;
|
|
243
108
|
description?: string | JSX.Element;
|
|
244
|
-
|
|
245
|
-
* Makes the checkbox appear disabled as well as removing interactivity.
|
|
246
|
-
*/
|
|
109
|
+
id: string;
|
|
247
110
|
isDisabled?: boolean;
|
|
248
|
-
/**
|
|
249
|
-
* When `true` the title of the item will wrap multiple lines if it's long enough.
|
|
250
|
-
*/
|
|
251
|
-
shouldTitleWrap?: boolean;
|
|
252
|
-
/**
|
|
253
|
-
* When `true` the description of the item will wrap multiple lines if it's long enough.
|
|
254
|
-
*/
|
|
255
|
-
shouldDescriptionWrap?: boolean;
|
|
256
|
-
/**
|
|
257
|
-
* Event that is triggered when the checkbox is clicked.
|
|
258
|
-
*/
|
|
259
|
-
onClick?: (e: MouseEvent_2 | KeyboardEvent_2) => void;
|
|
260
|
-
/**
|
|
261
|
-
* Sets whether the checkbox is checked or unchecked.
|
|
262
|
-
*/
|
|
263
111
|
isSelected?: boolean;
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
defaultSelected?: boolean;
|
|
268
|
-
/**
|
|
269
|
-
* Unique id of a checkbox
|
|
270
|
-
*/
|
|
271
|
-
id: string;
|
|
272
|
-
/**
|
|
273
|
-
* Adds a title attribute to the root item element.
|
|
274
|
-
*/
|
|
275
|
-
title?: string;
|
|
276
|
-
/**
|
|
277
|
-
* A `testId` prop is provided for specified elements,
|
|
278
|
-
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
279
|
-
* serving as a hook for automated tests.
|
|
280
|
-
*/
|
|
112
|
+
onClick?: (e: MouseEvent_2 | KeyboardEvent_2) => void;
|
|
113
|
+
shouldDescriptionWrap?: boolean;
|
|
114
|
+
shouldTitleWrap?: boolean;
|
|
281
115
|
testId?: string;
|
|
116
|
+
title?: string;
|
|
282
117
|
}
|
|
283
118
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
*
|
|
289
|
-
* - [Examples](https://atlassian.design/components/dropdown-menu/examples)
|
|
290
|
-
* - [Code](https://atlassian.design/components/dropdown-menu/code)
|
|
291
|
-
* - [Usage](https://atlassian.design/components/dropdown-menu/usage)
|
|
292
|
-
*/
|
|
293
|
-
declare const DropdownMenu: (props: DropdownMenuProps) => JSX.Element;
|
|
119
|
+
// @public
|
|
120
|
+
const DropdownMenu: <T extends HTMLElement = HTMLElement>(
|
|
121
|
+
props: DropdownMenuProps<T>,
|
|
122
|
+
) => jsx.JSX.Element;
|
|
294
123
|
export default DropdownMenu;
|
|
295
124
|
|
|
296
|
-
|
|
125
|
+
// @public (undocumented)
|
|
126
|
+
export interface DropdownMenuGroupProps extends SectionProps_2 {}
|
|
297
127
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
* Tall menu has no scroll until the height exceeds the height of the viewport.
|
|
303
|
-
*/
|
|
128
|
+
// @public (undocumented)
|
|
129
|
+
export interface DropdownMenuProps<
|
|
130
|
+
TriggerElement extends HTMLElement = HTMLElement
|
|
131
|
+
> {
|
|
304
132
|
appearance?: 'default' | 'tall';
|
|
305
|
-
/**
|
|
306
|
-
* Controls if the first menu item receives focus when menu is opened. Note that the menu has a focus lock
|
|
307
|
-
* which traps the focus within the menu. Also, the first item gets fouced automatically
|
|
308
|
-
* if the menu is triggered using the keyboard.
|
|
309
|
-
*
|
|
310
|
-
*/
|
|
311
133
|
autoFocus?: boolean;
|
|
312
|
-
/**
|
|
313
|
-
* Content that will be rendered inside the layer element. Should typically be
|
|
314
|
-
* `DropdownItemGroup` or `DropdownItem`, or checkbox / radio variants of those.
|
|
315
|
-
*/
|
|
316
134
|
children?: ReactNode;
|
|
317
|
-
|
|
318
|
-
* If true, a Spinner is rendered instead of the items
|
|
319
|
-
*/
|
|
135
|
+
defaultOpen?: boolean;
|
|
320
136
|
isLoading?: boolean;
|
|
321
|
-
/**
|
|
322
|
-
* Text to be used as status for assistive technologies. Defaults to "Loading".
|
|
323
|
-
*/
|
|
324
|
-
statusLabel?: string;
|
|
325
|
-
/**
|
|
326
|
-
* Controls the open state of the dropdown.
|
|
327
|
-
*/
|
|
328
137
|
isOpen?: boolean;
|
|
329
|
-
|
|
330
|
-
* Position of the menu.
|
|
331
|
-
*/
|
|
138
|
+
onOpenChange?: (args: OnOpenChangeArgs) => void;
|
|
332
139
|
placement?: Placement;
|
|
333
|
-
/**
|
|
334
|
-
* Allows the dropdown menu to be placed on the opposite side of its trigger if it does not
|
|
335
|
-
* fit in the viewport.
|
|
336
|
-
*/
|
|
337
140
|
shouldFlip?: boolean;
|
|
338
|
-
|
|
339
|
-
* Content which will trigger the dropdown menu to open and close. Use with `triggerType`
|
|
340
|
-
* to easily get a button trigger.
|
|
341
|
-
*/
|
|
342
|
-
trigger?: string | ((triggerButtonProps: CustomTriggerProps) => ReactElement);
|
|
343
|
-
/**
|
|
344
|
-
* A `testId` prop is provided for specified elements, which is a unique
|
|
345
|
-
* string that appears as a data attribute `data-testid` in the rendered code,
|
|
346
|
-
* serving as a hook for automated tests.
|
|
347
|
-
*
|
|
348
|
-
* As dropdown-menu is composed of different components, we passed down the testId to the sub component you want to test:
|
|
349
|
-
* - `testId--trigger` to get the menu trigger.
|
|
350
|
-
* - `testId--content` to get the dropdown content trigger.
|
|
351
|
-
*/
|
|
141
|
+
statusLabel?: string;
|
|
352
142
|
testId?: string;
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Called when the menu should be open/closed. Receives an object with `isOpen` state.
|
|
360
|
-
*/
|
|
361
|
-
onOpenChange?: (args: OnOpenChangeArgs) => void;
|
|
362
|
-
/**
|
|
363
|
-
* Z-index that the popup should be displayed in.
|
|
364
|
-
* This is passed to the portal component.
|
|
365
|
-
* Defaults to `layers.modal()` from `@atlaskit/theme` which is 510.
|
|
366
|
-
*/
|
|
143
|
+
trigger?:
|
|
144
|
+
| string
|
|
145
|
+
| ((
|
|
146
|
+
triggerButtonProps: CustomTriggerProps<TriggerElement>,
|
|
147
|
+
) => ReactElement);
|
|
367
148
|
zIndex?: number;
|
|
368
149
|
}
|
|
369
150
|
|
|
370
|
-
|
|
151
|
+
// @public (undocumented)
|
|
152
|
+
export interface OnOpenChangeArgs {
|
|
153
|
+
// (undocumented)
|
|
154
|
+
event: MouseEvent_2 | KeyboardEvent_2;
|
|
155
|
+
// (undocumented)
|
|
371
156
|
isOpen: boolean;
|
|
372
|
-
event?: MouseEvent_2 | KeyboardEvent_2;
|
|
373
157
|
}
|
|
374
158
|
|
|
375
|
-
|
|
159
|
+
// @public (undocumented)
|
|
160
|
+
type Placement =
|
|
376
161
|
| 'auto-start'
|
|
377
162
|
| 'auto'
|
|
378
163
|
| 'auto-end'
|
|
@@ -389,5 +174,5 @@ declare type Placement =
|
|
|
389
174
|
| 'left'
|
|
390
175
|
| 'left-start';
|
|
391
176
|
|
|
392
|
-
|
|
177
|
+
// (No @packageDocumentation comment for this package)
|
|
393
178
|
```
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6
|
-
|
|
7
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
-
|
|
9
|
-
var _helper = require("@atlaskit/visual-regression/helper");
|
|
10
|
-
|
|
11
|
-
var dropdownTrigger = '[data-testid="dropdown--trigger"]';
|
|
12
|
-
var dropdownContent = '[data-testid="dropdown--content"]';
|
|
13
|
-
describe('Snapshot Test', function () {
|
|
14
|
-
it('it should match visual snapshot for dropdown', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
15
|
-
var url, _global, page, dropdownImage;
|
|
16
|
-
|
|
17
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
18
|
-
while (1) {
|
|
19
|
-
switch (_context.prev = _context.next) {
|
|
20
|
-
case 0:
|
|
21
|
-
url = (0, _helper.getExampleUrl)('design-system', 'dropdown-menu', 'default-dropdown-menu', global.__BASEURL__);
|
|
22
|
-
_global = global, page = _global.page;
|
|
23
|
-
_context.next = 4;
|
|
24
|
-
return (0, _helper.loadPage)(page, url);
|
|
25
|
-
|
|
26
|
-
case 4:
|
|
27
|
-
_context.next = 6;
|
|
28
|
-
return page.waitForSelector(dropdownContent);
|
|
29
|
-
|
|
30
|
-
case 6:
|
|
31
|
-
_context.next = 8;
|
|
32
|
-
return page.screenshot();
|
|
33
|
-
|
|
34
|
-
case 8:
|
|
35
|
-
dropdownImage = _context.sent;
|
|
36
|
-
expect(dropdownImage).toMatchProdImageSnapshot();
|
|
37
|
-
|
|
38
|
-
case 10:
|
|
39
|
-
case "end":
|
|
40
|
-
return _context.stop();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}, _callee);
|
|
44
|
-
})));
|
|
45
|
-
it('should accept custom zIndex', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
46
|
-
var url, _global2, page, button, popupImage;
|
|
47
|
-
|
|
48
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
49
|
-
while (1) {
|
|
50
|
-
switch (_context2.prev = _context2.next) {
|
|
51
|
-
case 0:
|
|
52
|
-
url = (0, _helper.getExampleUrl)('design-system', 'dropdown-menu', 'setting-z-index', global.__BASEURL__);
|
|
53
|
-
_global2 = global, page = _global2.page;
|
|
54
|
-
button = "[data-testid='popup--trigger']";
|
|
55
|
-
_context2.next = 5;
|
|
56
|
-
return (0, _helper.loadPage)(page, url);
|
|
57
|
-
|
|
58
|
-
case 5:
|
|
59
|
-
_context2.next = 7;
|
|
60
|
-
return page.waitForSelector(button);
|
|
61
|
-
|
|
62
|
-
case 7:
|
|
63
|
-
_context2.next = 9;
|
|
64
|
-
return page.click(button);
|
|
65
|
-
|
|
66
|
-
case 9:
|
|
67
|
-
_context2.next = 11;
|
|
68
|
-
return page.waitForSelector(dropdownTrigger);
|
|
69
|
-
|
|
70
|
-
case 11:
|
|
71
|
-
_context2.next = 13;
|
|
72
|
-
return page.click(dropdownTrigger);
|
|
73
|
-
|
|
74
|
-
case 13:
|
|
75
|
-
_context2.next = 15;
|
|
76
|
-
return page.waitForSelector(dropdownContent);
|
|
77
|
-
|
|
78
|
-
case 15:
|
|
79
|
-
_context2.next = 17;
|
|
80
|
-
return page.screenshot();
|
|
81
|
-
|
|
82
|
-
case 17:
|
|
83
|
-
popupImage = _context2.sent;
|
|
84
|
-
expect(popupImage).toMatchProdImageSnapshot();
|
|
85
|
-
|
|
86
|
-
case 19:
|
|
87
|
-
case "end":
|
|
88
|
-
return _context2.stop();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}, _callee2);
|
|
92
|
-
})));
|
|
93
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { getExampleUrl, loadPage } from '@atlaskit/visual-regression/helper';
|
|
2
|
-
const dropdownTrigger = '[data-testid="dropdown--trigger"]';
|
|
3
|
-
const dropdownContent = '[data-testid="dropdown--content"]';
|
|
4
|
-
describe('Snapshot Test', () => {
|
|
5
|
-
it('it should match visual snapshot for dropdown', async () => {
|
|
6
|
-
const url = getExampleUrl('design-system', 'dropdown-menu', 'default-dropdown-menu', global.__BASEURL__);
|
|
7
|
-
const {
|
|
8
|
-
page
|
|
9
|
-
} = global;
|
|
10
|
-
await loadPage(page, url);
|
|
11
|
-
await page.waitForSelector(dropdownContent);
|
|
12
|
-
const dropdownImage = await page.screenshot();
|
|
13
|
-
expect(dropdownImage).toMatchProdImageSnapshot();
|
|
14
|
-
});
|
|
15
|
-
it('should accept custom zIndex', async () => {
|
|
16
|
-
const url = getExampleUrl('design-system', 'dropdown-menu', 'setting-z-index', global.__BASEURL__);
|
|
17
|
-
const {
|
|
18
|
-
page
|
|
19
|
-
} = global;
|
|
20
|
-
const button = "[data-testid='popup--trigger']";
|
|
21
|
-
await loadPage(page, url);
|
|
22
|
-
await page.waitForSelector(button);
|
|
23
|
-
await page.click(button);
|
|
24
|
-
await page.waitForSelector(dropdownTrigger);
|
|
25
|
-
await page.click(dropdownTrigger);
|
|
26
|
-
await page.waitForSelector(dropdownContent);
|
|
27
|
-
const popupImage = await page.screenshot();
|
|
28
|
-
expect(popupImage).toMatchProdImageSnapshot();
|
|
29
|
-
});
|
|
30
|
-
});
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import { getExampleUrl, loadPage } from '@atlaskit/visual-regression/helper';
|
|
4
|
-
var dropdownTrigger = '[data-testid="dropdown--trigger"]';
|
|
5
|
-
var dropdownContent = '[data-testid="dropdown--content"]';
|
|
6
|
-
describe('Snapshot Test', function () {
|
|
7
|
-
it('it should match visual snapshot for dropdown', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
8
|
-
var url, _global, page, dropdownImage;
|
|
9
|
-
|
|
10
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
11
|
-
while (1) {
|
|
12
|
-
switch (_context.prev = _context.next) {
|
|
13
|
-
case 0:
|
|
14
|
-
url = getExampleUrl('design-system', 'dropdown-menu', 'default-dropdown-menu', global.__BASEURL__);
|
|
15
|
-
_global = global, page = _global.page;
|
|
16
|
-
_context.next = 4;
|
|
17
|
-
return loadPage(page, url);
|
|
18
|
-
|
|
19
|
-
case 4:
|
|
20
|
-
_context.next = 6;
|
|
21
|
-
return page.waitForSelector(dropdownContent);
|
|
22
|
-
|
|
23
|
-
case 6:
|
|
24
|
-
_context.next = 8;
|
|
25
|
-
return page.screenshot();
|
|
26
|
-
|
|
27
|
-
case 8:
|
|
28
|
-
dropdownImage = _context.sent;
|
|
29
|
-
expect(dropdownImage).toMatchProdImageSnapshot();
|
|
30
|
-
|
|
31
|
-
case 10:
|
|
32
|
-
case "end":
|
|
33
|
-
return _context.stop();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}, _callee);
|
|
37
|
-
})));
|
|
38
|
-
it('should accept custom zIndex', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
39
|
-
var url, _global2, page, button, popupImage;
|
|
40
|
-
|
|
41
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
42
|
-
while (1) {
|
|
43
|
-
switch (_context2.prev = _context2.next) {
|
|
44
|
-
case 0:
|
|
45
|
-
url = getExampleUrl('design-system', 'dropdown-menu', 'setting-z-index', global.__BASEURL__);
|
|
46
|
-
_global2 = global, page = _global2.page;
|
|
47
|
-
button = "[data-testid='popup--trigger']";
|
|
48
|
-
_context2.next = 5;
|
|
49
|
-
return loadPage(page, url);
|
|
50
|
-
|
|
51
|
-
case 5:
|
|
52
|
-
_context2.next = 7;
|
|
53
|
-
return page.waitForSelector(button);
|
|
54
|
-
|
|
55
|
-
case 7:
|
|
56
|
-
_context2.next = 9;
|
|
57
|
-
return page.click(button);
|
|
58
|
-
|
|
59
|
-
case 9:
|
|
60
|
-
_context2.next = 11;
|
|
61
|
-
return page.waitForSelector(dropdownTrigger);
|
|
62
|
-
|
|
63
|
-
case 11:
|
|
64
|
-
_context2.next = 13;
|
|
65
|
-
return page.click(dropdownTrigger);
|
|
66
|
-
|
|
67
|
-
case 13:
|
|
68
|
-
_context2.next = 15;
|
|
69
|
-
return page.waitForSelector(dropdownContent);
|
|
70
|
-
|
|
71
|
-
case 15:
|
|
72
|
-
_context2.next = 17;
|
|
73
|
-
return page.screenshot();
|
|
74
|
-
|
|
75
|
-
case 17:
|
|
76
|
-
popupImage = _context2.sent;
|
|
77
|
-
expect(popupImage).toMatchProdImageSnapshot();
|
|
78
|
-
|
|
79
|
-
case 19:
|
|
80
|
-
case "end":
|
|
81
|
-
return _context2.stop();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}, _callee2);
|
|
85
|
-
})));
|
|
86
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|