@atlaskit/dropdown-menu 11.14.4 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/cjs/checkbox/dropdown-item-checkbox-group.js +21 -6
- package/dist/cjs/checkbox/dropdown-item-checkbox.js +27 -27
- package/dist/cjs/dropdown-menu-item-group.js +1 -2
- package/dist/cjs/dropdown-menu-item.js +51 -31
- package/dist/cjs/dropdown-menu.js +46 -43
- package/dist/cjs/internal/components/checkbox-icon.js +1 -2
- package/dist/cjs/internal/components/context.js +4 -7
- package/dist/cjs/internal/components/focus-manager.js +2 -4
- package/dist/cjs/internal/components/menu-wrapper.js +2 -3
- package/dist/cjs/internal/components/radio-icon.js +1 -2
- package/dist/cjs/internal/context/checkbox-group-context.js +1 -2
- package/dist/cjs/internal/context/selection-store.js +2 -4
- package/dist/cjs/internal/hooks/use-checkbox-state.js +1 -2
- package/dist/cjs/internal/hooks/use-radio-state.js +1 -2
- package/dist/cjs/internal/hooks/use-register-item-with-focus-manager.js +1 -2
- package/dist/cjs/internal/utils/handle-focus.js +4 -4
- package/dist/cjs/internal/utils/is-voice-over-supported.js +1 -2
- package/dist/cjs/internal/utils/reset-options-in-group.js +1 -2
- package/dist/cjs/internal/utils/use-generated-id.js +1 -2
- package/dist/cjs/radio/dropdown-item-radio-group.js +22 -8
- package/dist/cjs/radio/dropdown-item-radio.js +29 -27
- package/dist/es2019/checkbox/dropdown-item-checkbox-group.js +21 -6
- package/dist/es2019/checkbox/dropdown-item-checkbox.js +24 -22
- package/dist/es2019/dropdown-menu-item.js +49 -27
- package/dist/es2019/dropdown-menu.js +33 -31
- package/dist/es2019/radio/dropdown-item-radio-group.js +21 -6
- package/dist/es2019/radio/dropdown-item-radio.js +26 -22
- package/dist/esm/checkbox/dropdown-item-checkbox-group.js +20 -4
- package/dist/esm/checkbox/dropdown-item-checkbox.js +26 -25
- package/dist/esm/dropdown-menu-item.js +50 -29
- package/dist/esm/dropdown-menu.js +44 -40
- package/dist/esm/internal/components/menu-wrapper.js +1 -1
- package/dist/esm/internal/utils/handle-focus.js +4 -4
- package/dist/esm/radio/dropdown-item-radio-group.js +20 -4
- package/dist/esm/radio/dropdown-item-radio.js +28 -25
- package/dist/types/checkbox/dropdown-item-checkbox-group.d.ts +1 -1
- package/dist/types/checkbox/dropdown-item-checkbox.d.ts +1 -1
- package/dist/types/dropdown-menu.d.ts +1 -1
- package/dist/types/radio/dropdown-item-radio-group.d.ts +1 -1
- package/dist/types/radio/dropdown-item-radio.d.ts +1 -1
- package/package.json +11 -13
- package/report.api.md +61 -13
- package/dist/types-ts4.5/checkbox/dropdown-item-checkbox-group.d.ts +0 -16
- package/dist/types-ts4.5/checkbox/dropdown-item-checkbox.d.ts +0 -13
- package/dist/types-ts4.5/dropdown-menu-item-group.d.ts +0 -11
- package/dist/types-ts4.5/dropdown-menu-item.d.ts +0 -13
- package/dist/types-ts4.5/dropdown-menu.d.ts +0 -13
- package/dist/types-ts4.5/index.d.ts +0 -8
- package/dist/types-ts4.5/internal/components/checkbox-icon.d.ts +0 -12
- package/dist/types-ts4.5/internal/components/context.d.ts +0 -27
- package/dist/types-ts4.5/internal/components/focus-manager.d.ts +0 -21
- package/dist/types-ts4.5/internal/components/menu-wrapper.d.ts +0 -11
- package/dist/types-ts4.5/internal/components/radio-icon.d.ts +0 -12
- package/dist/types-ts4.5/internal/context/checkbox-group-context.d.ts +0 -5
- package/dist/types-ts4.5/internal/context/selection-store.d.ts +0 -27
- package/dist/types-ts4.5/internal/hooks/use-checkbox-state.d.ts +0 -17
- package/dist/types-ts4.5/internal/hooks/use-radio-state.d.ts +0 -12
- package/dist/types-ts4.5/internal/hooks/use-register-item-with-focus-manager.d.ts +0 -4
- package/dist/types-ts4.5/internal/utils/handle-focus.d.ts +0 -2
- package/dist/types-ts4.5/internal/utils/is-checkbox-item.d.ts +0 -1
- package/dist/types-ts4.5/internal/utils/is-radio-item.d.ts +0 -1
- package/dist/types-ts4.5/internal/utils/is-voice-over-supported.d.ts +0 -2
- package/dist/types-ts4.5/internal/utils/reset-options-in-group.d.ts +0 -4
- package/dist/types-ts4.5/internal/utils/use-generated-id.d.ts +0 -6
- package/dist/types-ts4.5/radio/dropdown-item-radio-group.d.ts +0 -25
- package/dist/types-ts4.5/radio/dropdown-item-radio.d.ts +0 -13
- package/dist/types-ts4.5/types.d.ts +0 -303
- package/tmp/api-report-tmp.d.ts +0 -147
|
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.PREFIX = void 0;
|
|
7
7
|
exports.default = useGeneratedId;
|
|
8
8
|
var _react = require("react");
|
|
9
|
-
var PREFIX = 'ds--dropdown--';
|
|
10
|
-
exports.PREFIX = PREFIX;
|
|
9
|
+
var PREFIX = exports.PREFIX = 'ds--dropdown--';
|
|
11
10
|
var generateRandomString = function generateRandomString() {
|
|
12
11
|
return (// This string is used only on client side usually triggered after a user interaction.
|
|
13
12
|
// Therefore, so there is no risk of mismatch
|
|
@@ -21,7 +21,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
21
21
|
* __Radio group context__
|
|
22
22
|
* Context provider that wraps each DropdownItemRadioGroup
|
|
23
23
|
*/
|
|
24
|
-
var RadioGroupContext = /*#__PURE__*/(0, _react.createContext)({
|
|
24
|
+
var RadioGroupContext = exports.RadioGroupContext = /*#__PURE__*/(0, _react.createContext)({
|
|
25
25
|
id: '',
|
|
26
26
|
radioGroupState: {},
|
|
27
27
|
selectRadioItem: _noop.default
|
|
@@ -33,10 +33,15 @@ var RadioGroupContext = /*#__PURE__*/(0, _react.createContext)({
|
|
|
33
33
|
* across mount and unmounts.
|
|
34
34
|
*
|
|
35
35
|
*/
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
id =
|
|
36
|
+
var DropdownItemRadioGroup = function DropdownItemRadioGroup(_ref) {
|
|
37
|
+
var children = _ref.children,
|
|
38
|
+
hasSeparator = _ref.hasSeparator,
|
|
39
|
+
id = _ref.id,
|
|
40
|
+
isList = _ref.isList,
|
|
41
|
+
isScrollable = _ref.isScrollable,
|
|
42
|
+
overrides = _ref.overrides,
|
|
43
|
+
testId = _ref.testId,
|
|
44
|
+
title = _ref.title;
|
|
40
45
|
var _useContext = (0, _react.useContext)(_selectionStore.SelectionStoreContext),
|
|
41
46
|
setGroupState = _useContext.setGroupState,
|
|
42
47
|
getGroupState = _useContext.getGroupState;
|
|
@@ -62,7 +67,16 @@ var DropdownItemRadioGroup = function DropdownItemRadioGroup(props) {
|
|
|
62
67
|
radioGroupState: radioGroupState,
|
|
63
68
|
selectRadioItem: selectRadioItem
|
|
64
69
|
}
|
|
65
|
-
}, /*#__PURE__*/_react.default.createElement(_section.default,
|
|
70
|
+
}, /*#__PURE__*/_react.default.createElement(_section.default, {
|
|
71
|
+
hasSeparator: hasSeparator,
|
|
72
|
+
id: id,
|
|
73
|
+
isList: isList,
|
|
74
|
+
isScrollable: isScrollable
|
|
75
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
76
|
+
,
|
|
77
|
+
overrides: overrides,
|
|
78
|
+
testId: testId,
|
|
79
|
+
title: title
|
|
80
|
+
}, children));
|
|
66
81
|
};
|
|
67
|
-
var _default = DropdownItemRadioGroup;
|
|
68
|
-
exports.default = _default;
|
|
82
|
+
var _default = exports.default = DropdownItemRadioGroup;
|
|
@@ -6,19 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
11
|
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
14
12
|
var _menu = require("@atlaskit/menu");
|
|
15
13
|
var _buttonItem = _interopRequireDefault(require("@atlaskit/menu/button-item"));
|
|
16
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
14
|
var _radioIcon = _interopRequireDefault(require("../internal/components/radio-icon"));
|
|
18
15
|
var _useRadioState3 = _interopRequireDefault(require("../internal/hooks/use-radio-state"));
|
|
19
16
|
var _useRegisterItemWithFocusManager = _interopRequireDefault(require("../internal/hooks/use-register-item-with-focus-manager"));
|
|
20
17
|
var _isVoiceOverSupported = _interopRequireDefault(require("../internal/utils/is-voice-over-supported"));
|
|
21
|
-
var _excluded = ["id", "isSelected", "defaultSelected", "onClick", "shouldTitleWrap", "shouldDescriptionWrap"];
|
|
22
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
19
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
20
|
/**
|
|
@@ -30,17 +26,21 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
30
26
|
* - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/code)
|
|
31
27
|
* - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/usage)
|
|
32
28
|
*/
|
|
33
|
-
var DropdownItemRadio = function DropdownItemRadio(
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
var DropdownItemRadio = function DropdownItemRadio(_ref) {
|
|
30
|
+
var children = _ref.children,
|
|
31
|
+
defaultSelected = _ref.defaultSelected,
|
|
32
|
+
testId = _ref.testId,
|
|
33
|
+
id = _ref.id,
|
|
34
|
+
title = _ref.title,
|
|
35
|
+
description = _ref.description,
|
|
36
|
+
isDisabled = _ref.isDisabled,
|
|
37
|
+
isSelected = _ref.isSelected,
|
|
38
|
+
_ref$onClick = _ref.onClick,
|
|
39
|
+
providedOnClick = _ref$onClick === void 0 ? _noop.default : _ref$onClick,
|
|
40
|
+
_ref$shouldDescriptio = _ref.shouldDescriptionWrap,
|
|
41
|
+
shouldDescriptionWrap = _ref$shouldDescriptio === void 0 ? true : _ref$shouldDescriptio,
|
|
42
|
+
_ref$shouldTitleWrap = _ref.shouldTitleWrap,
|
|
43
|
+
shouldTitleWrap = _ref$shouldTitleWrap === void 0 ? true : _ref$shouldTitleWrap;
|
|
44
44
|
if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && typeof isSelected !== 'undefined' && typeof defaultSelected !== 'undefined') {
|
|
45
45
|
// eslint-disable-next-line no-console
|
|
46
46
|
console.warn("[DropdownItemRadio] You've used both `defaultSelected` and `isSelected` props. This is dangerous and can lead to unexpected results. Use one or the other depending if you want to control the components state yourself.");
|
|
@@ -62,20 +62,22 @@ var DropdownItemRadio = function DropdownItemRadio(props) {
|
|
|
62
62
|
var itemRef = (0, _useRegisterItemWithFocusManager.default)();
|
|
63
63
|
return /*#__PURE__*/_react.default.createElement(_menu.SELECTION_STYLE_CONTEXT_DO_NOT_USE.Provider, {
|
|
64
64
|
value: "none"
|
|
65
|
-
}, /*#__PURE__*/_react.default.createElement(_buttonItem.default,
|
|
66
|
-
id: id,
|
|
67
|
-
onClick: onClickHandler,
|
|
68
|
-
role: (0, _isVoiceOverSupported.default)() ? 'radio' : 'menuitemradio',
|
|
65
|
+
}, /*#__PURE__*/_react.default.createElement(_buttonItem.default, {
|
|
69
66
|
"aria-checked": selected,
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
children: children,
|
|
68
|
+
description: description,
|
|
72
69
|
iconBefore: /*#__PURE__*/_react.default.createElement(_radioIcon.default, {
|
|
73
70
|
checked: selected
|
|
74
71
|
}),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
id: id,
|
|
73
|
+
isDisabled: isDisabled,
|
|
74
|
+
isSelected: selected,
|
|
75
|
+
onClick: onClickHandler,
|
|
76
|
+
ref: itemRef,
|
|
77
|
+
role: (0, _isVoiceOverSupported.default)() ? 'radio' : 'menuitemradio',
|
|
78
|
+
shouldDescriptionWrap: shouldDescriptionWrap,
|
|
79
|
+
shouldTitleWrap: shouldTitleWrap,
|
|
80
|
+
testId: testId
|
|
81
|
+
}));
|
|
79
82
|
};
|
|
80
|
-
var _default = DropdownItemRadio;
|
|
81
|
-
exports.default = _default;
|
|
83
|
+
var _default = exports.default = DropdownItemRadio;
|
|
@@ -7,13 +7,28 @@ import { CheckboxGroupContext } from '../internal/context/checkbox-group-context
|
|
|
7
7
|
* A wrapping element for dropdown menu checkbox items.
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
|
-
const DropdownItemCheckboxGroup =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const DropdownItemCheckboxGroup = ({
|
|
11
|
+
children,
|
|
12
|
+
hasSeparator,
|
|
13
|
+
id,
|
|
14
|
+
isList,
|
|
15
|
+
isScrollable,
|
|
16
|
+
overrides,
|
|
17
|
+
testId,
|
|
18
|
+
title
|
|
19
|
+
}) => {
|
|
15
20
|
return /*#__PURE__*/React.createElement(CheckboxGroupContext.Provider, {
|
|
16
21
|
value: id
|
|
17
|
-
}, /*#__PURE__*/React.createElement(Section,
|
|
22
|
+
}, /*#__PURE__*/React.createElement(Section, {
|
|
23
|
+
hasSeparator: hasSeparator,
|
|
24
|
+
id: id,
|
|
25
|
+
isList: isList,
|
|
26
|
+
isScrollable: isScrollable
|
|
27
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
28
|
+
,
|
|
29
|
+
overrides: overrides,
|
|
30
|
+
testId: testId,
|
|
31
|
+
title: title
|
|
32
|
+
}, children));
|
|
18
33
|
};
|
|
19
34
|
export default DropdownItemCheckboxGroup;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React, { useCallback } from 'react';
|
|
3
2
|
import noop from '@atlaskit/ds-lib/noop';
|
|
4
3
|
import { SELECTION_STYLE_CONTEXT_DO_NOT_USE } from '@atlaskit/menu';
|
|
5
4
|
import ButtonItem from '@atlaskit/menu/button-item';
|
|
6
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
5
|
import CheckboxIcon from '../internal/components/checkbox-icon';
|
|
8
6
|
import useCheckboxState from '../internal/hooks/use-checkbox-state';
|
|
9
7
|
import useRegisterItemWithFocusManager from '../internal/hooks/use-register-item-with-focus-manager';
|
|
@@ -16,16 +14,18 @@ import useRegisterItemWithFocusManager from '../internal/hooks/use-register-item
|
|
|
16
14
|
* - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/code)
|
|
17
15
|
* - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/usage)
|
|
18
16
|
*/
|
|
19
|
-
const DropdownItemCheckbox =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
const DropdownItemCheckbox = ({
|
|
18
|
+
children,
|
|
19
|
+
defaultSelected,
|
|
20
|
+
description,
|
|
21
|
+
id,
|
|
22
|
+
isDisabled,
|
|
23
|
+
isSelected,
|
|
24
|
+
onClick: providedOnClick = noop,
|
|
25
|
+
shouldDescriptionWrap = true,
|
|
26
|
+
shouldTitleWrap = true,
|
|
27
|
+
testId
|
|
28
|
+
}) => {
|
|
29
29
|
if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && typeof isSelected !== 'undefined' && typeof defaultSelected !== 'undefined') {
|
|
30
30
|
// eslint-disable-next-line no-console
|
|
31
31
|
console.warn("[DropdownItemCheckbox] You've used both `defaultSelected` and `isSelected` props. This is dangerous and can lead to unexpected results. Use one or the other depending if you want to control the components state yourself.");
|
|
@@ -42,19 +42,21 @@ const DropdownItemCheckbox = props => {
|
|
|
42
42
|
const itemRef = useRegisterItemWithFocusManager();
|
|
43
43
|
return /*#__PURE__*/React.createElement(SELECTION_STYLE_CONTEXT_DO_NOT_USE.Provider, {
|
|
44
44
|
value: "none"
|
|
45
|
-
}, /*#__PURE__*/React.createElement(ButtonItem,
|
|
46
|
-
id: id,
|
|
47
|
-
onClick: onClickHandler,
|
|
48
|
-
role: "menuitemcheckbox",
|
|
45
|
+
}, /*#__PURE__*/React.createElement(ButtonItem, {
|
|
49
46
|
"aria-checked": selected,
|
|
50
|
-
|
|
51
|
-
shouldDescriptionWrap: shouldDescriptionWrap,
|
|
47
|
+
description: description,
|
|
52
48
|
iconBefore: /*#__PURE__*/React.createElement(CheckboxIcon, {
|
|
53
49
|
checked: selected
|
|
54
50
|
}),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
id: id,
|
|
52
|
+
isDisabled: isDisabled,
|
|
53
|
+
isSelected: selected,
|
|
54
|
+
onClick: onClickHandler,
|
|
55
|
+
ref: itemRef,
|
|
56
|
+
role: "menuitemcheckbox",
|
|
57
|
+
shouldDescriptionWrap: shouldDescriptionWrap,
|
|
58
|
+
shouldTitleWrap: shouldTitleWrap,
|
|
59
|
+
testId: testId
|
|
60
|
+
}, children));
|
|
59
61
|
};
|
|
60
62
|
export default DropdownItemCheckbox;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React, { forwardRef } from 'react';
|
|
3
2
|
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
4
3
|
import ButtonItem from '@atlaskit/menu/button-item';
|
|
@@ -14,45 +13,68 @@ import useRegisterItemWithFocusManager from './internal/hooks/use-register-item-
|
|
|
14
13
|
* - [Code](https://atlassian.design/components/dropdown-item/code)
|
|
15
14
|
* - [Usage](https://atlassian.design/components/dropdown-item/usage)
|
|
16
15
|
*/
|
|
17
|
-
const DropdownMenuItem = /*#__PURE__*/forwardRef((
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
const DropdownMenuItem = /*#__PURE__*/forwardRef(({
|
|
17
|
+
children,
|
|
18
|
+
component,
|
|
19
|
+
description,
|
|
20
|
+
elemAfter,
|
|
21
|
+
elemBefore,
|
|
22
|
+
href,
|
|
23
|
+
isDisabled,
|
|
24
|
+
isSelected,
|
|
25
|
+
onClick,
|
|
26
|
+
rel,
|
|
27
|
+
shouldDescriptionWrap = true,
|
|
28
|
+
shouldTitleWrap = true,
|
|
29
|
+
target,
|
|
30
|
+
testId
|
|
31
|
+
}, ref) => {
|
|
27
32
|
const itemRef = useRegisterItemWithFocusManager();
|
|
28
33
|
if (component) {
|
|
29
|
-
return /*#__PURE__*/React.createElement(CustomItem,
|
|
34
|
+
return /*#__PURE__*/React.createElement(CustomItem, {
|
|
30
35
|
component: component,
|
|
31
|
-
|
|
36
|
+
description: description,
|
|
32
37
|
iconAfter: elemAfter,
|
|
38
|
+
iconBefore: elemBefore,
|
|
39
|
+
isDisabled: isDisabled,
|
|
40
|
+
isSelected: isSelected,
|
|
41
|
+
onClick: onClick,
|
|
33
42
|
ref: mergeRefs([ref, itemRef]),
|
|
43
|
+
shouldDescriptionWrap: shouldDescriptionWrap,
|
|
34
44
|
shouldTitleWrap: shouldTitleWrap,
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
} else if (
|
|
38
|
-
return /*#__PURE__*/React.createElement(LinkItem,
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
testId: testId
|
|
46
|
+
}, children);
|
|
47
|
+
} else if (href) {
|
|
48
|
+
return /*#__PURE__*/React.createElement(LinkItem, {
|
|
49
|
+
description: description,
|
|
50
|
+
href: href,
|
|
41
51
|
iconAfter: elemAfter,
|
|
42
|
-
|
|
52
|
+
iconBefore: elemBefore,
|
|
53
|
+
isDisabled: isDisabled,
|
|
54
|
+
isSelected: isSelected,
|
|
55
|
+
onClick: onClick,
|
|
43
56
|
ref: mergeRefs([ref, itemRef]),
|
|
57
|
+
rel: rel,
|
|
58
|
+
role: "menuitem",
|
|
59
|
+
shouldDescriptionWrap: shouldDescriptionWrap,
|
|
44
60
|
shouldTitleWrap: shouldTitleWrap,
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
target: target,
|
|
62
|
+
testId: testId
|
|
63
|
+
}, children);
|
|
47
64
|
} else {
|
|
48
|
-
return /*#__PURE__*/React.createElement(ButtonItem,
|
|
49
|
-
|
|
50
|
-
iconBefore: elemBefore,
|
|
65
|
+
return /*#__PURE__*/React.createElement(ButtonItem, {
|
|
66
|
+
description: description,
|
|
51
67
|
iconAfter: elemAfter,
|
|
68
|
+
iconBefore: elemBefore,
|
|
69
|
+
isDisabled: isDisabled,
|
|
70
|
+
isSelected: isSelected,
|
|
71
|
+
onClick: onClick,
|
|
52
72
|
ref: mergeRefs([ref, itemRef]),
|
|
73
|
+
role: "menuitem",
|
|
74
|
+
shouldDescriptionWrap: shouldDescriptionWrap,
|
|
53
75
|
shouldTitleWrap: shouldTitleWrap,
|
|
54
|
-
|
|
55
|
-
},
|
|
76
|
+
testId: testId
|
|
77
|
+
}, children);
|
|
56
78
|
}
|
|
57
79
|
});
|
|
58
80
|
export default DropdownMenuItem;
|
|
@@ -57,23 +57,22 @@ const getFallbackPlacements = placement => {
|
|
|
57
57
|
* - [Code](https://atlassian.design/components/dropdown-menu/code)
|
|
58
58
|
* - [Usage](https://atlassian.design/components/dropdown-menu/usage)
|
|
59
59
|
*/
|
|
60
|
-
const DropdownMenu =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
} = props;
|
|
60
|
+
const DropdownMenu = ({
|
|
61
|
+
autoFocus = false,
|
|
62
|
+
children,
|
|
63
|
+
defaultOpen = false,
|
|
64
|
+
isLoading = false,
|
|
65
|
+
isOpen,
|
|
66
|
+
onOpenChange = noop,
|
|
67
|
+
placement = 'bottom-start',
|
|
68
|
+
shouldFlip = true,
|
|
69
|
+
shouldRenderToParent = false,
|
|
70
|
+
spacing,
|
|
71
|
+
statusLabel,
|
|
72
|
+
testId,
|
|
73
|
+
trigger,
|
|
74
|
+
zIndex = layers.modal()
|
|
75
|
+
}) => {
|
|
77
76
|
const [isLocalOpen, setLocalIsOpen] = useControlledState(isOpen, () => defaultOpen);
|
|
78
77
|
const [isTriggeredUsingKeyboard, setTriggeredUsingKeyboard] = useState(false);
|
|
79
78
|
const fallbackPlacements = useMemo(() => getFallbackPlacements(placement), [placement]);
|
|
@@ -158,14 +157,17 @@ const DropdownMenu = props => {
|
|
|
158
157
|
testId: testId && `${testId}--content`,
|
|
159
158
|
shouldUseCaptureOnOutsideClick: true,
|
|
160
159
|
shouldRenderToParent: shouldRenderToParent,
|
|
161
|
-
trigger:
|
|
160
|
+
trigger: ({
|
|
161
|
+
ref,
|
|
162
|
+
'aria-controls': ariaControls,
|
|
163
|
+
'aria-expanded': ariaExpanded,
|
|
164
|
+
'aria-haspopup': ariaHasPopup
|
|
165
|
+
}) => {
|
|
162
166
|
if (typeof trigger === 'function') {
|
|
163
|
-
const {
|
|
164
|
-
ref,
|
|
165
|
-
...providedProps
|
|
166
|
-
} = triggerProps;
|
|
167
167
|
return trigger({
|
|
168
|
-
|
|
168
|
+
'aria-controls': ariaControls,
|
|
169
|
+
'aria-expanded': ariaExpanded,
|
|
170
|
+
'aria-haspopup': ariaHasPopup,
|
|
169
171
|
...bindFocus,
|
|
170
172
|
triggerRef: mergeRefs([ref, itemRef]),
|
|
171
173
|
isSelected: isLocalOpen,
|
|
@@ -180,18 +182,18 @@ const DropdownMenu = props => {
|
|
|
180
182
|
}),
|
|
181
183
|
onFocus: bindFocus.onFocus,
|
|
182
184
|
onBlur: bindFocus.onBlur,
|
|
183
|
-
ref: mergeRefs([
|
|
184
|
-
"aria-controls":
|
|
185
|
-
"aria-expanded":
|
|
186
|
-
"aria-haspopup":
|
|
185
|
+
ref: mergeRefs([ref, itemRef]),
|
|
186
|
+
"aria-controls": ariaControls,
|
|
187
|
+
"aria-expanded": ariaExpanded,
|
|
188
|
+
"aria-haspopup": ariaHasPopup,
|
|
187
189
|
isSelected: isLocalOpen,
|
|
188
190
|
onClick: handleTriggerClicked,
|
|
189
191
|
testId: testId && `${testId}--trigger`
|
|
190
192
|
}, trigger) : /*#__PURE__*/React.createElement(Button, _extends({}, bindFocus, {
|
|
191
|
-
ref: mergeRefs([
|
|
192
|
-
"aria-controls":
|
|
193
|
-
"aria-expanded":
|
|
194
|
-
"aria-haspopup":
|
|
193
|
+
ref: mergeRefs([ref, itemRef]),
|
|
194
|
+
"aria-controls": ariaControls,
|
|
195
|
+
"aria-expanded": ariaExpanded,
|
|
196
|
+
"aria-haspopup": ariaHasPopup,
|
|
195
197
|
isSelected: isLocalOpen,
|
|
196
198
|
iconAfter: /*#__PURE__*/React.createElement(ExpandIcon, {
|
|
197
199
|
size: "medium",
|
|
@@ -19,11 +19,16 @@ export const RadioGroupContext = /*#__PURE__*/createContext({
|
|
|
19
19
|
* across mount and unmounts.
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
-
const DropdownItemRadioGroup =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const DropdownItemRadioGroup = ({
|
|
23
|
+
children,
|
|
24
|
+
hasSeparator,
|
|
25
|
+
id,
|
|
26
|
+
isList,
|
|
27
|
+
isScrollable,
|
|
28
|
+
overrides,
|
|
29
|
+
testId,
|
|
30
|
+
title
|
|
31
|
+
}) => {
|
|
27
32
|
const {
|
|
28
33
|
setGroupState,
|
|
29
34
|
getGroupState
|
|
@@ -48,6 +53,16 @@ const DropdownItemRadioGroup = props => {
|
|
|
48
53
|
radioGroupState,
|
|
49
54
|
selectRadioItem
|
|
50
55
|
}
|
|
51
|
-
}, /*#__PURE__*/React.createElement(Section,
|
|
56
|
+
}, /*#__PURE__*/React.createElement(Section, {
|
|
57
|
+
hasSeparator: hasSeparator,
|
|
58
|
+
id: id,
|
|
59
|
+
isList: isList,
|
|
60
|
+
isScrollable: isScrollable
|
|
61
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
62
|
+
,
|
|
63
|
+
overrides: overrides,
|
|
64
|
+
testId: testId,
|
|
65
|
+
title: title
|
|
66
|
+
}, children));
|
|
52
67
|
};
|
|
53
68
|
export default DropdownItemRadioGroup;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React, { useCallback } from 'react';
|
|
3
2
|
import noop from '@atlaskit/ds-lib/noop';
|
|
4
3
|
import { SELECTION_STYLE_CONTEXT_DO_NOT_USE } from '@atlaskit/menu';
|
|
5
4
|
import ButtonItem from '@atlaskit/menu/button-item';
|
|
6
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
5
|
import RadioIcon from '../internal/components/radio-icon';
|
|
8
6
|
import useRadioState from '../internal/hooks/use-radio-state';
|
|
9
7
|
import useRegisterItemWithFocusManager from '../internal/hooks/use-register-item-with-focus-manager';
|
|
@@ -17,16 +15,19 @@ import isVoiceOverSupported from '../internal/utils/is-voice-over-supported';
|
|
|
17
15
|
* - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/code)
|
|
18
16
|
* - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/usage)
|
|
19
17
|
*/
|
|
20
|
-
const DropdownItemRadio =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
const DropdownItemRadio = ({
|
|
19
|
+
children,
|
|
20
|
+
defaultSelected,
|
|
21
|
+
testId,
|
|
22
|
+
id,
|
|
23
|
+
title,
|
|
24
|
+
description,
|
|
25
|
+
isDisabled,
|
|
26
|
+
isSelected,
|
|
27
|
+
onClick: providedOnClick = noop,
|
|
28
|
+
shouldDescriptionWrap = true,
|
|
29
|
+
shouldTitleWrap = true
|
|
30
|
+
}) => {
|
|
30
31
|
if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && typeof isSelected !== 'undefined' && typeof defaultSelected !== 'undefined') {
|
|
31
32
|
// eslint-disable-next-line no-console
|
|
32
33
|
console.warn("[DropdownItemRadio] You've used both `defaultSelected` and `isSelected` props. This is dangerous and can lead to unexpected results. Use one or the other depending if you want to control the components state yourself.");
|
|
@@ -43,19 +44,22 @@ const DropdownItemRadio = props => {
|
|
|
43
44
|
const itemRef = useRegisterItemWithFocusManager();
|
|
44
45
|
return /*#__PURE__*/React.createElement(SELECTION_STYLE_CONTEXT_DO_NOT_USE.Provider, {
|
|
45
46
|
value: "none"
|
|
46
|
-
}, /*#__PURE__*/React.createElement(ButtonItem,
|
|
47
|
-
id: id,
|
|
48
|
-
onClick: onClickHandler,
|
|
49
|
-
role: isVoiceOverSupported() ? 'radio' : 'menuitemradio',
|
|
47
|
+
}, /*#__PURE__*/React.createElement(ButtonItem, {
|
|
50
48
|
"aria-checked": selected,
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
children: children,
|
|
50
|
+
description: description,
|
|
53
51
|
iconBefore: /*#__PURE__*/React.createElement(RadioIcon, {
|
|
54
52
|
checked: selected
|
|
55
53
|
}),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
id: id,
|
|
55
|
+
isDisabled: isDisabled,
|
|
56
|
+
isSelected: selected,
|
|
57
|
+
onClick: onClickHandler,
|
|
58
|
+
ref: itemRef,
|
|
59
|
+
role: isVoiceOverSupported() ? 'radio' : 'menuitemradio',
|
|
60
|
+
shouldDescriptionWrap: shouldDescriptionWrap,
|
|
61
|
+
shouldTitleWrap: shouldTitleWrap,
|
|
62
|
+
testId: testId
|
|
63
|
+
}));
|
|
60
64
|
};
|
|
61
65
|
export default DropdownItemRadio;
|
|
@@ -7,11 +7,27 @@ import { CheckboxGroupContext } from '../internal/context/checkbox-group-context
|
|
|
7
7
|
* A wrapping element for dropdown menu checkbox items.
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
|
-
var DropdownItemCheckboxGroup = function DropdownItemCheckboxGroup(
|
|
11
|
-
var children =
|
|
12
|
-
|
|
10
|
+
var DropdownItemCheckboxGroup = function DropdownItemCheckboxGroup(_ref) {
|
|
11
|
+
var children = _ref.children,
|
|
12
|
+
hasSeparator = _ref.hasSeparator,
|
|
13
|
+
id = _ref.id,
|
|
14
|
+
isList = _ref.isList,
|
|
15
|
+
isScrollable = _ref.isScrollable,
|
|
16
|
+
overrides = _ref.overrides,
|
|
17
|
+
testId = _ref.testId,
|
|
18
|
+
title = _ref.title;
|
|
13
19
|
return /*#__PURE__*/React.createElement(CheckboxGroupContext.Provider, {
|
|
14
20
|
value: id
|
|
15
|
-
}, /*#__PURE__*/React.createElement(Section,
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Section, {
|
|
22
|
+
hasSeparator: hasSeparator,
|
|
23
|
+
id: id,
|
|
24
|
+
isList: isList,
|
|
25
|
+
isScrollable: isScrollable
|
|
26
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
27
|
+
,
|
|
28
|
+
overrides: overrides,
|
|
29
|
+
testId: testId,
|
|
30
|
+
title: title
|
|
31
|
+
}, children));
|
|
16
32
|
};
|
|
17
33
|
export default DropdownItemCheckboxGroup;
|