@atlaskit/dropdown-menu 11.2.1 → 11.3.1
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 +22 -0
- package/dist/cjs/dropdown-menu.js +33 -4
- package/dist/cjs/internal/components/menu-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/dropdown-menu.js +32 -5
- package/dist/es2019/internal/components/menu-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/dropdown-menu.js +34 -5
- package/dist/esm/internal/components/menu-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/visual-regression/index.js +1 -1
- package/dist/types/types.d.ts +1 -1
- package/package.json +4 -4
- package/report.api.md +393 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/dropdown-menu
|
|
2
2
|
|
|
3
|
+
## 11.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`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
|
|
8
|
+
|
|
9
|
+
## 11.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`01d80d395bc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/01d80d395bc) - pass event to onOpenChange consistently
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
19
|
+
## 11.2.2
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [`8a5bdb3c844`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8a5bdb3c844) - Upgrading internal dependency (bind-event-listener) for improved internal types
|
|
24
|
+
|
|
3
25
|
## 11.2.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -63,7 +63,31 @@ var spinnerContainerStyles = (0, _core.css)({
|
|
|
63
63
|
justifyContent: 'center'
|
|
64
64
|
});
|
|
65
65
|
var MAX_HEIGHT = "calc(100vh - ".concat(gridSize * 2, "px)");
|
|
66
|
-
var
|
|
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;
|
|
@@ -133,11 +161,12 @@ var DropdownMenu = function DropdownMenu(props) {
|
|
|
133
161
|
event: event
|
|
134
162
|
});
|
|
135
163
|
}, [onOpenChange, isLocalOpen, setLocalIsOpen]);
|
|
136
|
-
var handleOnClose = (0, _react.useCallback)(function () {
|
|
164
|
+
var handleOnClose = (0, _react.useCallback)(function (event) {
|
|
137
165
|
var newValue = false;
|
|
138
166
|
setLocalIsOpen(newValue);
|
|
139
167
|
onOpenChange({
|
|
140
|
-
isOpen: newValue
|
|
168
|
+
isOpen: newValue,
|
|
169
|
+
event: event
|
|
141
170
|
});
|
|
142
171
|
}, [onOpenChange, setLocalIsOpen]);
|
|
143
172
|
|
|
@@ -201,7 +230,7 @@ var DropdownMenu = function DropdownMenu(props) {
|
|
|
201
230
|
isSelected: isLocalOpen,
|
|
202
231
|
iconAfter: (0, _core.jsx)(_chevronDown.default, {
|
|
203
232
|
size: "medium",
|
|
204
|
-
label: "
|
|
233
|
+
label: ""
|
|
205
234
|
}),
|
|
206
235
|
onClick: handleTriggerClicked,
|
|
207
236
|
testId: testId && "".concat(testId, "--trigger")
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
5
5
|
import { css, jsx } from '@emotion/core';
|
|
6
6
|
import { bind } from 'bind-event-listener';
|
|
7
7
|
import Button from '@atlaskit/button/standard-button';
|
|
@@ -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
|
|
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;
|
|
@@ -81,11 +107,12 @@ const DropdownMenu = props => {
|
|
|
81
107
|
event
|
|
82
108
|
});
|
|
83
109
|
}, [onOpenChange, isLocalOpen, setLocalIsOpen]);
|
|
84
|
-
const handleOnClose = useCallback(
|
|
110
|
+
const handleOnClose = useCallback(event => {
|
|
85
111
|
const newValue = false;
|
|
86
112
|
setLocalIsOpen(newValue);
|
|
87
113
|
onOpenChange({
|
|
88
|
-
isOpen: newValue
|
|
114
|
+
isOpen: newValue,
|
|
115
|
+
event
|
|
89
116
|
});
|
|
90
117
|
}, [onOpenChange, setLocalIsOpen]);
|
|
91
118
|
const {
|
|
@@ -151,7 +178,7 @@ const DropdownMenu = props => {
|
|
|
151
178
|
isSelected: isLocalOpen,
|
|
152
179
|
iconAfter: jsx(ExpandIcon, {
|
|
153
180
|
size: "medium",
|
|
154
|
-
label: "
|
|
181
|
+
label: ""
|
|
155
182
|
}),
|
|
156
183
|
onClick: handleTriggerClicked,
|
|
157
184
|
testId: testId && `${testId}--trigger`
|
package/dist/es2019/version.json
CHANGED
|
@@ -9,7 +9,7 @@ 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';
|
|
12
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
13
13
|
import { css, jsx } from '@emotion/core';
|
|
14
14
|
import { bind } from 'bind-event-listener';
|
|
15
15
|
import Button from '@atlaskit/button/standard-button';
|
|
@@ -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
|
|
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;
|
|
@@ -104,11 +132,12 @@ var DropdownMenu = function DropdownMenu(props) {
|
|
|
104
132
|
event: event
|
|
105
133
|
});
|
|
106
134
|
}, [onOpenChange, isLocalOpen, setLocalIsOpen]);
|
|
107
|
-
var handleOnClose = useCallback(function () {
|
|
135
|
+
var handleOnClose = useCallback(function (event) {
|
|
108
136
|
var newValue = false;
|
|
109
137
|
setLocalIsOpen(newValue);
|
|
110
138
|
onOpenChange({
|
|
111
|
-
isOpen: newValue
|
|
139
|
+
isOpen: newValue,
|
|
140
|
+
event: event
|
|
112
141
|
});
|
|
113
142
|
}, [onOpenChange, setLocalIsOpen]);
|
|
114
143
|
|
|
@@ -173,7 +202,7 @@ var DropdownMenu = function DropdownMenu(props) {
|
|
|
173
202
|
isSelected: isLocalOpen,
|
|
174
203
|
iconAfter: jsx(ExpandIcon, {
|
|
175
204
|
size: "medium",
|
|
176
|
-
label: "
|
|
205
|
+
label: ""
|
|
177
206
|
}),
|
|
178
207
|
onClick: handleTriggerClicked,
|
|
179
208
|
testId: testId && "".concat(testId, "--trigger")
|
package/dist/esm/version.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
import { getExampleUrl, loadPage } from '@atlaskit/visual-regression/helper';
|
|
4
4
|
var dropdownTrigger = '[data-testid="dropdown--trigger"]';
|
|
5
5
|
var dropdownContent = '[data-testid="dropdown--content"]';
|
package/dist/types/types.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export interface CustomTriggerProps extends Omit<TriggerProps, 'ref'> {
|
|
|
41
41
|
}
|
|
42
42
|
export interface OnOpenChangeArgs {
|
|
43
43
|
isOpen: boolean;
|
|
44
|
-
event
|
|
44
|
+
event: MouseEvent | KeyboardEvent;
|
|
45
45
|
}
|
|
46
46
|
export interface MenuWrapperProps extends MenuGroupProps {
|
|
47
47
|
setInitialFocusRef?: ContentProps['setInitialFocusRef'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/dropdown-menu",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.1",
|
|
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/"
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@atlaskit/button": "^16.3.0",
|
|
27
27
|
"@atlaskit/codemod-utils": "^4.1.0",
|
|
28
|
-
"@atlaskit/ds-lib": "^2.
|
|
28
|
+
"@atlaskit/ds-lib": "^2.1.0",
|
|
29
29
|
"@atlaskit/icon": "^21.10.0",
|
|
30
30
|
"@atlaskit/menu": "^1.3.0",
|
|
31
|
-
"@atlaskit/popup": "^1.
|
|
31
|
+
"@atlaskit/popup": "^1.4.0",
|
|
32
32
|
"@atlaskit/spinner": "^15.0.0",
|
|
33
33
|
"@atlaskit/theme": "^12.1.0",
|
|
34
34
|
"@atlaskit/tokens": "^0.10.0",
|
|
35
35
|
"@atlaskit/visually-hidden": "^1.0.0",
|
|
36
36
|
"@babel/runtime": "^7.0.0",
|
|
37
37
|
"@emotion/core": "^10.0.9",
|
|
38
|
-
"bind-event-listener": "^2.1.
|
|
38
|
+
"bind-event-listener": "^2.1.1"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": "^16.8.0",
|
package/report.api.md
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
## API Report File for "@atlaskit/dropdown-menu"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
/// <reference types="react" />
|
|
7
|
+
|
|
8
|
+
import type { CustomItemProps } from '@atlaskit/menu/types';
|
|
9
|
+
import { default as DropdownItemGroup } from '@atlaskit/menu/section';
|
|
10
|
+
import { KeyboardEvent as KeyboardEvent_2 } from 'react';
|
|
11
|
+
import { MouseEvent as MouseEvent_2 } from 'react';
|
|
12
|
+
import { ReactElement } from 'react';
|
|
13
|
+
import { ReactNode } from 'react';
|
|
14
|
+
import { Ref } from 'react';
|
|
15
|
+
import type { SectionProps } from '@atlaskit/menu';
|
|
16
|
+
import type { SectionProps as SectionProps_2 } from '@atlaskit/menu/types';
|
|
17
|
+
import type { TriggerProps } from '@atlaskit/popup/types';
|
|
18
|
+
|
|
19
|
+
export declare interface CustomTriggerProps extends Omit<TriggerProps, 'ref'> {
|
|
20
|
+
/**
|
|
21
|
+
* Ref that should be applied to the trigger. This is used to calculate the menu position.
|
|
22
|
+
*/
|
|
23
|
+
triggerRef: Ref<HTMLElement>;
|
|
24
|
+
/**
|
|
25
|
+
* Makes the trigger appear selected.
|
|
26
|
+
*/
|
|
27
|
+
isSelected?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Event that is triggered when the element is clicked.
|
|
30
|
+
*/
|
|
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
|
+
testId?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* __Dropdown menu item__
|
|
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;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* __Dropdown item checkbox__
|
|
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: (
|
|
65
|
+
props: DropdownItemCheckboxProps,
|
|
66
|
+
) => JSX.Element;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* __Dropdown item checkbox group__
|
|
70
|
+
*
|
|
71
|
+
* A wrapping element for dropdown menu checkbox items.
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
export declare const DropdownItemCheckboxGroup: (
|
|
75
|
+
props: DropdownItemCheckboxGroupProps,
|
|
76
|
+
) => JSX.Element;
|
|
77
|
+
|
|
78
|
+
declare interface DropdownItemCheckboxGroupProps extends SectionProps {
|
|
79
|
+
/**
|
|
80
|
+
* Unique identifier for the checkbox group.
|
|
81
|
+
*/
|
|
82
|
+
id: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare interface DropdownItemCheckboxProps {
|
|
86
|
+
/**
|
|
87
|
+
* Primary content for the item.
|
|
88
|
+
*/
|
|
89
|
+
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
|
+
*/
|
|
94
|
+
description?: string | JSX.Element;
|
|
95
|
+
/**
|
|
96
|
+
* Makes the checkbox appear disabled as well as removing interactivity.
|
|
97
|
+
*/
|
|
98
|
+
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
|
+
isSelected?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Sets whether the checkbox begins selected.
|
|
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
|
+
*/
|
|
132
|
+
testId?: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export { DropdownItemGroup };
|
|
136
|
+
|
|
137
|
+
export declare interface DropdownItemProps {
|
|
138
|
+
/**
|
|
139
|
+
* Primary content for the item.
|
|
140
|
+
*/
|
|
141
|
+
children: React.ReactNode;
|
|
142
|
+
/**
|
|
143
|
+
* Custom component to render as an item.
|
|
144
|
+
*/
|
|
145
|
+
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
|
+
description?: string | JSX.Element;
|
|
151
|
+
/**
|
|
152
|
+
* Makes the element appear disabled as well as removing interactivity.
|
|
153
|
+
*/
|
|
154
|
+
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
|
+
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
|
+
*/
|
|
198
|
+
rel?: string;
|
|
199
|
+
/**
|
|
200
|
+
* A `testId` prop is provided for specified elements,
|
|
201
|
+
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
202
|
+
* serving as a hook for automated tests.
|
|
203
|
+
*/
|
|
204
|
+
testId?: string;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* __Dropdown item radio__
|
|
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;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* __Dropdown item radio group__
|
|
222
|
+
* Store which manages the selection state for each DropdownItemRadio
|
|
223
|
+
* across mount and unmounts.
|
|
224
|
+
*
|
|
225
|
+
*/
|
|
226
|
+
export declare const DropdownItemRadioGroup: (
|
|
227
|
+
props: DropdownItemRadioGroupProps,
|
|
228
|
+
) => JSX.Element;
|
|
229
|
+
|
|
230
|
+
declare interface DropdownItemRadioGroupProps extends SectionProps {
|
|
231
|
+
id: string;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
declare interface DropdownItemRadioProps {
|
|
235
|
+
/**
|
|
236
|
+
* Primary content for the item.
|
|
237
|
+
*/
|
|
238
|
+
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
|
+
*/
|
|
243
|
+
description?: string | JSX.Element;
|
|
244
|
+
/**
|
|
245
|
+
* Makes the checkbox appear disabled as well as removing interactivity.
|
|
246
|
+
*/
|
|
247
|
+
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
|
+
isSelected?: boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Sets whether the checkbox begins selected.
|
|
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
|
+
*/
|
|
281
|
+
testId?: string;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* __Dropdown menu__
|
|
286
|
+
*
|
|
287
|
+
* A dropdown menu displays a list of actions or options to a user.
|
|
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;
|
|
294
|
+
export default DropdownMenu;
|
|
295
|
+
|
|
296
|
+
export declare interface DropdownMenuGroupProps extends SectionProps_2 {}
|
|
297
|
+
|
|
298
|
+
export declare interface DropdownMenuProps {
|
|
299
|
+
/**
|
|
300
|
+
* Controls the appearance of the menu.
|
|
301
|
+
* Default menu has scroll after its height exceeds the pre-defined amount.
|
|
302
|
+
* Tall menu has no scroll until the height exceeds the height of the viewport.
|
|
303
|
+
*/
|
|
304
|
+
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
|
+
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
|
+
children?: ReactNode;
|
|
317
|
+
/**
|
|
318
|
+
* If true, a Spinner is rendered instead of the items
|
|
319
|
+
*/
|
|
320
|
+
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
|
+
isOpen?: boolean;
|
|
329
|
+
/**
|
|
330
|
+
* Position of the menu.
|
|
331
|
+
*/
|
|
332
|
+
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
|
+
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
|
+
*/
|
|
352
|
+
testId?: string;
|
|
353
|
+
/**
|
|
354
|
+
* Controls the initial open state of the dropdown. If provided, the component is considered to be controlled
|
|
355
|
+
* which means that the user is responsible for managing the open and close state of the menu.
|
|
356
|
+
*/
|
|
357
|
+
defaultOpen?: boolean;
|
|
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
|
+
*/
|
|
367
|
+
zIndex?: number;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export declare interface OnOpenChangeArgs {
|
|
371
|
+
isOpen: boolean;
|
|
372
|
+
event?: MouseEvent_2 | KeyboardEvent_2;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
declare type Placement =
|
|
376
|
+
| 'auto-start'
|
|
377
|
+
| 'auto'
|
|
378
|
+
| 'auto-end'
|
|
379
|
+
| 'top-start'
|
|
380
|
+
| 'top'
|
|
381
|
+
| 'top-end'
|
|
382
|
+
| 'right-start'
|
|
383
|
+
| 'right'
|
|
384
|
+
| 'right-end'
|
|
385
|
+
| 'bottom-end'
|
|
386
|
+
| 'bottom'
|
|
387
|
+
| 'bottom-start'
|
|
388
|
+
| 'left-end'
|
|
389
|
+
| 'left'
|
|
390
|
+
| 'left-start';
|
|
391
|
+
|
|
392
|
+
export {};
|
|
393
|
+
```
|