@carbon/react 1.23.0-rc.0 → 1.23.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/es/components/DataTable/tools/sorting.js +3 -0
- package/es/components/Dropdown/Dropdown.Skeleton.d.ts +15 -0
- package/es/components/Dropdown/Dropdown.Skeleton.js +1 -2
- package/es/components/Dropdown/index.js +1 -0
- package/es/components/FluidDropdown/FluidDropdown.js +1 -0
- package/es/components/Grid/CSSGrid.d.ts +9 -0
- package/es/components/Grid/CSSGrid.js +8 -5
- package/es/components/Grid/Column.d.ts +73 -0
- package/es/components/Grid/Column.js +40 -34
- package/es/components/Grid/ColumnHang.d.ts +24 -0
- package/es/components/Grid/ColumnHang.js +7 -4
- package/es/components/Grid/FlexGrid.d.ts +9 -0
- package/es/components/Grid/FlexGrid.js +6 -3
- package/es/components/Grid/Grid.d.ts +9 -0
- package/es/components/Grid/Grid.js +6 -5
- package/es/components/Grid/GridContext.d.ts +38 -0
- package/es/components/Grid/GridContext.js +6 -6
- package/es/components/Grid/GridTypes.d.ts +37 -0
- package/es/components/Grid/Row.d.ts +34 -0
- package/es/components/Grid/Row.js +4 -2
- package/es/components/Grid/index.d.ts +11 -0
- package/es/components/Heading/index.js +11 -4
- package/es/components/Menu/Menu.js +164 -216
- package/es/components/Menu/MenuContext.js +44 -0
- package/es/components/Menu/MenuItem.js +401 -23
- package/es/components/MultiSelect/MultiSelect.js +6 -0
- package/es/components/OverflowMenu/OverflowMenu.js +2 -2
- package/es/components/OverflowMenuV2/index.js +4 -14
- package/es/components/Search/Search.js +3 -3
- package/es/index.d.ts +1 -1
- package/es/index.js +7 -11
- package/es/prop-types/isRequiredOneOf.js +2 -2
- package/lib/components/DataTable/tools/sorting.js +3 -0
- package/lib/components/Dropdown/Dropdown.Skeleton.d.ts +15 -0
- package/lib/components/Dropdown/Dropdown.Skeleton.js +1 -2
- package/lib/components/Dropdown/index.js +2 -0
- package/lib/components/FluidDropdown/FluidDropdown.js +1 -0
- package/lib/components/Grid/CSSGrid.d.ts +9 -0
- package/lib/components/Grid/CSSGrid.js +8 -5
- package/lib/components/Grid/Column.d.ts +73 -0
- package/lib/components/Grid/Column.js +36 -30
- package/lib/components/Grid/ColumnHang.d.ts +24 -0
- package/lib/components/Grid/ColumnHang.js +7 -4
- package/lib/components/Grid/FlexGrid.d.ts +9 -0
- package/lib/components/Grid/FlexGrid.js +6 -3
- package/lib/components/Grid/Grid.d.ts +9 -0
- package/lib/components/Grid/Grid.js +2 -1
- package/lib/components/Grid/GridContext.d.ts +38 -0
- package/lib/components/Grid/GridContext.js +6 -6
- package/lib/components/Grid/GridTypes.d.ts +37 -0
- package/lib/components/Grid/Row.d.ts +34 -0
- package/lib/components/Grid/Row.js +4 -2
- package/lib/components/Grid/index.d.ts +11 -0
- package/lib/components/Heading/index.js +11 -4
- package/lib/components/Menu/Menu.js +163 -216
- package/lib/components/Menu/MenuContext.js +53 -0
- package/lib/components/Menu/MenuItem.js +406 -23
- package/lib/components/MultiSelect/MultiSelect.js +6 -0
- package/lib/components/OverflowMenu/OverflowMenu.js +2 -2
- package/lib/components/OverflowMenuV2/index.js +5 -15
- package/lib/components/Search/Search.js +3 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +17 -21
- package/lib/prop-types/isRequiredOneOf.js +2 -2
- package/package.json +4 -4
- package/es/components/Menu/MenuDivider.js +0 -19
- package/es/components/Menu/MenuGroup.js +0 -34
- package/es/components/Menu/MenuOption.js +0 -250
- package/es/components/Menu/MenuRadioGroup.js +0 -50
- package/es/components/Menu/MenuRadioGroupOptions.js +0 -64
- package/es/components/Menu/MenuSelectableItem.js +0 -57
- package/es/components/Menu/_utils.js +0 -177
- package/es/components/Menu/index.js +0 -25
- package/lib/components/Menu/MenuDivider.js +0 -27
- package/lib/components/Menu/MenuGroup.js +0 -43
- package/lib/components/Menu/MenuOption.js +0 -260
- package/lib/components/Menu/MenuRadioGroup.js +0 -59
- package/lib/components/Menu/MenuRadioGroupOptions.js +0 -73
- package/lib/components/Menu/MenuSelectableItem.js +0 -66
- package/lib/components/Menu/_utils.js +0 -191
- package/lib/components/Menu/index.js +0 -31
package/lib/index.js
CHANGED
|
@@ -18,6 +18,11 @@ var Dropdown = require('./components/Dropdown/Dropdown.js');
|
|
|
18
18
|
var Dropdown_Skeleton = require('./components/Dropdown/Dropdown.Skeleton.js');
|
|
19
19
|
var FluidForm = require('./components/FluidForm/FluidForm.js');
|
|
20
20
|
var FormContext = require('./components/FluidForm/FormContext.js');
|
|
21
|
+
var FlexGrid = require('./components/Grid/FlexGrid.js');
|
|
22
|
+
var Grid = require('./components/Grid/Grid.js');
|
|
23
|
+
var Row = require('./components/Grid/Row.js');
|
|
24
|
+
var Column = require('./components/Grid/Column.js');
|
|
25
|
+
var ColumnHang = require('./components/Grid/ColumnHang.js');
|
|
21
26
|
var index$4 = require('./components/IdPrefix/index.js');
|
|
22
27
|
var index$5 = require('./components/OverflowMenu/index.js');
|
|
23
28
|
var index$6 = require('./components/Slider/index.js');
|
|
@@ -49,11 +54,6 @@ var FluidTextArea = require('./components/FluidTextArea/FluidTextArea.js');
|
|
|
49
54
|
var FluidTextArea_Skeleton = require('./components/FluidTextArea/FluidTextArea.Skeleton.js');
|
|
50
55
|
var FluidTextInput = require('./components/FluidTextInput/FluidTextInput.js');
|
|
51
56
|
var FluidTextInput_Skeleton = require('./components/FluidTextInput/FluidTextInput.Skeleton.js');
|
|
52
|
-
var MenuDivider = require('./components/Menu/MenuDivider.js');
|
|
53
|
-
var MenuGroup = require('./components/Menu/MenuGroup.js');
|
|
54
|
-
var MenuItem = require('./components/Menu/MenuItem.js');
|
|
55
|
-
var MenuRadioGroup = require('./components/Menu/MenuRadioGroup.js');
|
|
56
|
-
var MenuSelectableItem = require('./components/Menu/MenuSelectableItem.js');
|
|
57
57
|
var PageSelector = require('./components/Pagination/experimental/PageSelector.js');
|
|
58
58
|
var Pagination = require('./components/Pagination/experimental/Pagination.js');
|
|
59
59
|
var AccordionItem = require('./components/Accordion/AccordionItem.js');
|
|
@@ -74,8 +74,6 @@ var FileUploaderDropContainer = require('./components/FileUploader/FileUploaderD
|
|
|
74
74
|
var FileUploaderItem = require('./components/FileUploader/FileUploaderItem.js');
|
|
75
75
|
var FormItem = require('./components/FormItem/FormItem.js');
|
|
76
76
|
var FormLabel = require('./components/FormLabel/FormLabel.js');
|
|
77
|
-
var Row = require('./components/Grid/Row.js');
|
|
78
|
-
var Column = require('./components/Grid/Column.js');
|
|
79
77
|
var InlineLoading = require('./components/InlineLoading/InlineLoading.js');
|
|
80
78
|
var Loading = require('./components/Loading/Loading.js');
|
|
81
79
|
var NumberInput_Skeleton = require('./components/NumberInput/NumberInput.Skeleton.js');
|
|
@@ -112,6 +110,7 @@ var FluidTimePickerSelect = require('./components/FluidTimePickerSelect/FluidTim
|
|
|
112
110
|
var LayoutDirection = require('./components/Layout/LayoutDirection.js');
|
|
113
111
|
var useLayoutDirection = require('./components/Layout/useLayoutDirection.js');
|
|
114
112
|
var Menu = require('./components/Menu/Menu.js');
|
|
113
|
+
var MenuItem = require('./components/Menu/MenuItem.js');
|
|
115
114
|
var Text = require('./components/Text/Text.js');
|
|
116
115
|
var TextDirection = require('./components/Text/TextDirection.js');
|
|
117
116
|
var Breadcrumb = require('./components/Breadcrumb/Breadcrumb.js');
|
|
@@ -154,9 +153,6 @@ var FileUploader = require('./components/FileUploader/FileUploader.js');
|
|
|
154
153
|
var FilterableMultiSelect = require('./components/MultiSelect/FilterableMultiSelect.js');
|
|
155
154
|
var Form = require('./components/Form/Form.js');
|
|
156
155
|
var FormGroup = require('./components/FormGroup/FormGroup.js');
|
|
157
|
-
var FlexGrid = require('./components/Grid/FlexGrid.js');
|
|
158
|
-
var Grid = require('./components/Grid/Grid.js');
|
|
159
|
-
var ColumnHang = require('./components/Grid/ColumnHang.js');
|
|
160
156
|
var Link = require('./components/Link/Link.js');
|
|
161
157
|
var ListItem = require('./components/ListItem/ListItem.js');
|
|
162
158
|
var Modal = require('./components/Modal/Modal.js');
|
|
@@ -232,6 +228,11 @@ exports.Dropdown = Dropdown["default"];
|
|
|
232
228
|
exports.DropdownSkeleton = Dropdown_Skeleton["default"];
|
|
233
229
|
exports.FluidForm = FluidForm["default"];
|
|
234
230
|
exports.FormContext = FormContext.FormContext;
|
|
231
|
+
exports.FlexGrid = FlexGrid.FlexGrid;
|
|
232
|
+
exports.Grid = Grid.Grid;
|
|
233
|
+
exports.Row = Row["default"];
|
|
234
|
+
exports.Column = Column["default"];
|
|
235
|
+
exports.ColumnHang = ColumnHang.ColumnHang;
|
|
235
236
|
exports.IdPrefix = index$4.IdPrefix;
|
|
236
237
|
exports.OverflowMenu = index$5["default"];
|
|
237
238
|
exports.Slider = index$6["default"];
|
|
@@ -276,11 +277,6 @@ exports.unstable__FluidTextArea = FluidTextArea["default"];
|
|
|
276
277
|
exports.unstable__FluidTextAreaSkeleton = FluidTextArea_Skeleton["default"];
|
|
277
278
|
exports.unstable__FluidTextInput = FluidTextInput["default"];
|
|
278
279
|
exports.unstable__FluidTextInputSkeleton = FluidTextInput_Skeleton["default"];
|
|
279
|
-
exports.unstable_MenuDivider = MenuDivider["default"];
|
|
280
|
-
exports.unstable_MenuGroup = MenuGroup["default"];
|
|
281
|
-
exports.unstable_MenuItem = MenuItem["default"];
|
|
282
|
-
exports.unstable_MenuRadioGroup = MenuRadioGroup["default"];
|
|
283
|
-
exports.unstable_MenuSelectableItem = MenuSelectableItem["default"];
|
|
284
280
|
exports.unstable_PageSelector = PageSelector["default"];
|
|
285
281
|
exports.unstable_Pagination = Pagination["default"];
|
|
286
282
|
exports.AccordionItem = AccordionItem["default"];
|
|
@@ -301,8 +297,6 @@ exports.FileUploaderDropContainer = FileUploaderDropContainer["default"];
|
|
|
301
297
|
exports.FileUploaderItem = FileUploaderItem["default"];
|
|
302
298
|
exports.FormItem = FormItem["default"];
|
|
303
299
|
exports.FormLabel = FormLabel["default"];
|
|
304
|
-
exports.Row = Row["default"];
|
|
305
|
-
exports.Column = Column["default"];
|
|
306
300
|
exports.InlineLoading = InlineLoading["default"];
|
|
307
301
|
exports.Loading = Loading["default"];
|
|
308
302
|
exports.NumberInputSkeleton = NumberInput_Skeleton["default"];
|
|
@@ -338,7 +332,12 @@ exports.unstable__FluidTimePickerSkeleton = FluidTimePicker_Skeleton["default"];
|
|
|
338
332
|
exports.unstable__FluidTimePickerSelect = FluidTimePickerSelect["default"];
|
|
339
333
|
exports.unstable_LayoutDirection = LayoutDirection.LayoutDirection;
|
|
340
334
|
exports.unstable_useLayoutDirection = useLayoutDirection.useLayoutDirection;
|
|
341
|
-
exports.unstable_Menu = Menu
|
|
335
|
+
exports.unstable_Menu = Menu.Menu;
|
|
336
|
+
exports.unstable_MenuItem = MenuItem.MenuItem;
|
|
337
|
+
exports.unstable_MenuItemDivider = MenuItem.MenuItemDivider;
|
|
338
|
+
exports.unstable_MenuItemGroup = MenuItem.MenuItemGroup;
|
|
339
|
+
exports.unstable_MenuItemRadioGroup = MenuItem.MenuItemRadioGroup;
|
|
340
|
+
exports.unstable_MenuItemSelectable = MenuItem.MenuItemSelectable;
|
|
342
341
|
exports.unstable_Text = Text.Text;
|
|
343
342
|
exports.unstable_TextDirection = TextDirection.TextDirection;
|
|
344
343
|
exports.Breadcrumb = Breadcrumb["default"];
|
|
@@ -382,9 +381,6 @@ exports.FileUploader = FileUploader["default"];
|
|
|
382
381
|
exports.FilterableMultiSelect = FilterableMultiSelect["default"];
|
|
383
382
|
exports.Form = Form["default"];
|
|
384
383
|
exports.FormGroup = FormGroup["default"];
|
|
385
|
-
exports.FlexGrid = FlexGrid.FlexGrid;
|
|
386
|
-
exports.Grid = Grid.Grid;
|
|
387
|
-
exports.ColumnHang = ColumnHang.ColumnHang;
|
|
388
384
|
exports.Link = Link["default"];
|
|
389
385
|
exports.ListItem = ListItem["default"];
|
|
390
386
|
exports.Modal = Modal["default"];
|
|
@@ -19,8 +19,8 @@ var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.j
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* @param {
|
|
23
|
-
* @returns {
|
|
22
|
+
* @param {Object<string, Function>} propTypes The list of type checkers, keyed by prop names.
|
|
23
|
+
* @returns {Object<string, Function>}
|
|
24
24
|
* The new prop type checkers that checks if one of the given props exist,
|
|
25
25
|
* in addition to the original type checkings.
|
|
26
26
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.23.
|
|
4
|
+
"version": "1.23.1",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@babel/runtime": "^7.18.3",
|
|
46
46
|
"@carbon/feature-flags": "^0.12.0",
|
|
47
|
-
"@carbon/icons-react": "^11.16.
|
|
47
|
+
"@carbon/icons-react": "^11.16.1",
|
|
48
48
|
"@carbon/layout": "^11.11.0",
|
|
49
|
-
"@carbon/styles": "^1.23.
|
|
49
|
+
"@carbon/styles": "^1.23.1",
|
|
50
50
|
"@carbon/telemetry": "0.1.0",
|
|
51
51
|
"classnames": "2.3.2",
|
|
52
52
|
"copy-to-clipboard": "^3.3.1",
|
|
@@ -133,5 +133,5 @@
|
|
|
133
133
|
"**/*.scss",
|
|
134
134
|
"**/*.css"
|
|
135
135
|
],
|
|
136
|
-
"gitHead": "
|
|
136
|
+
"gitHead": "2f5261e26d75787ab906d678fde430dfbd394d14"
|
|
137
137
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React__default from 'react';
|
|
9
|
-
import { usePrefix } from '../../internal/usePrefix.js';
|
|
10
|
-
|
|
11
|
-
function MenuDivider() {
|
|
12
|
-
var prefix = usePrefix();
|
|
13
|
-
return /*#__PURE__*/React__default.createElement("li", {
|
|
14
|
-
role: "separator",
|
|
15
|
-
className: "".concat(prefix, "--menu-divider")
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { MenuDivider as default };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React__default from 'react';
|
|
9
|
-
import PropTypes from 'prop-types';
|
|
10
|
-
|
|
11
|
-
function MenuGroup(_ref) {
|
|
12
|
-
var label = _ref.label,
|
|
13
|
-
children = _ref.children;
|
|
14
|
-
return /*#__PURE__*/React__default.createElement("li", {
|
|
15
|
-
role: "none"
|
|
16
|
-
}, /*#__PURE__*/React__default.createElement("ul", {
|
|
17
|
-
role: "group",
|
|
18
|
-
"aria-label": label
|
|
19
|
-
}, children));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
MenuGroup.propTypes = {
|
|
23
|
-
/**
|
|
24
|
-
* Specify the children of the MenuGroup
|
|
25
|
-
*/
|
|
26
|
-
children: PropTypes.node,
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Rendered label for the MenuGroup
|
|
30
|
-
*/
|
|
31
|
-
label: PropTypes.node.isRequired
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export { MenuGroup as default };
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default, { useState, useRef, useEffect } from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import cx from 'classnames';
|
|
12
|
-
import { CaretRight } from '@carbon/icons-react';
|
|
13
|
-
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
|
-
import { getFirstSubNode, focusNode, clickedElementHasSubnodes, getParentMenu } from './_utils.js';
|
|
15
|
-
import Menu from './Menu.js';
|
|
16
|
-
import { match } from '../../internal/keyboard/match.js';
|
|
17
|
-
import { ArrowRight, Enter, Space } from '../../internal/keyboard/keys.js';
|
|
18
|
-
|
|
19
|
-
var _CaretRight;
|
|
20
|
-
|
|
21
|
-
var _excluded = ["children", "disabled", "indented", "kind", "label", "level", "onClick", "renderIcon", "shortcut"];
|
|
22
|
-
var hoverIntentDelay = 150; // in ms
|
|
23
|
-
|
|
24
|
-
function MenuOptionContent(_ref) {
|
|
25
|
-
var label = _ref.label,
|
|
26
|
-
info = _ref.info,
|
|
27
|
-
disabled = _ref.disabled,
|
|
28
|
-
Icon = _ref.icon,
|
|
29
|
-
indented = _ref.indented;
|
|
30
|
-
var prefix = usePrefix();
|
|
31
|
-
var classes = cx("".concat(prefix, "--menu-option__content"), _defineProperty({}, "".concat(prefix, "--menu-option__content--disabled"), disabled));
|
|
32
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
33
|
-
className: classes
|
|
34
|
-
}, indented && /*#__PURE__*/React__default.createElement("div", {
|
|
35
|
-
className: "".concat(prefix, "--menu-option__icon")
|
|
36
|
-
}, Icon && /*#__PURE__*/React__default.createElement(Icon, null)), /*#__PURE__*/React__default.createElement("span", {
|
|
37
|
-
className: "".concat(prefix, "--menu-option__label"),
|
|
38
|
-
title: label
|
|
39
|
-
}, label), /*#__PURE__*/React__default.createElement("div", {
|
|
40
|
-
className: "".concat(prefix, "--menu-option__info")
|
|
41
|
-
}, info));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function MenuOption(_ref2) {
|
|
45
|
-
var _classnames2;
|
|
46
|
-
|
|
47
|
-
var children = _ref2.children,
|
|
48
|
-
disabled = _ref2.disabled,
|
|
49
|
-
indented = _ref2.indented,
|
|
50
|
-
_ref2$kind = _ref2.kind,
|
|
51
|
-
kind = _ref2$kind === void 0 ? 'default' : _ref2$kind,
|
|
52
|
-
label = _ref2.label,
|
|
53
|
-
level = _ref2.level,
|
|
54
|
-
_ref2$onClick = _ref2.onClick,
|
|
55
|
-
onClick = _ref2$onClick === void 0 ? function () {} : _ref2$onClick,
|
|
56
|
-
renderIcon = _ref2.renderIcon,
|
|
57
|
-
shortcut = _ref2.shortcut,
|
|
58
|
-
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
59
|
-
|
|
60
|
-
var _useState = useState(false),
|
|
61
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
62
|
-
submenuOpen = _useState2[0],
|
|
63
|
-
setSubmenuOpen = _useState2[1];
|
|
64
|
-
|
|
65
|
-
var _useState3 = useState(false),
|
|
66
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
67
|
-
submenuOpenedByKeyboard = _useState4[0],
|
|
68
|
-
setSubmenuOpenedByKeyboard = _useState4[1];
|
|
69
|
-
|
|
70
|
-
var rootRef = useRef(null);
|
|
71
|
-
var hoverIntentTimeout = useRef(null);
|
|
72
|
-
var prefix = usePrefix();
|
|
73
|
-
var subOptions = React__default.Children.map(children, function (node) {
|
|
74
|
-
if ( /*#__PURE__*/React__default.isValidElement(node)) {
|
|
75
|
-
return /*#__PURE__*/React__default.cloneElement(node);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
function openSubmenu() {
|
|
80
|
-
var openedByKeyboard = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
81
|
-
setSubmenuOpenedByKeyboard(openedByKeyboard);
|
|
82
|
-
setSubmenuOpen(true);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function handleKeyDown(event) {
|
|
86
|
-
if (clickedElementHasSubnodes(event) && (match(event, ArrowRight) || match(event, Enter) || match(event, Space))) {
|
|
87
|
-
openSubmenu(true);
|
|
88
|
-
} else if ((match(event, Enter) || match(event, Space)) && onClick) {
|
|
89
|
-
onClick(event);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function handleMouseEnter() {
|
|
94
|
-
hoverIntentTimeout.current = setTimeout(openSubmenu, hoverIntentDelay);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function handleMouseLeave() {
|
|
98
|
-
clearTimeout(hoverIntentTimeout === null || hoverIntentTimeout === void 0 ? void 0 : hoverIntentTimeout.current);
|
|
99
|
-
setSubmenuOpen(false);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function getSubmenuPosition() {
|
|
103
|
-
var pos = [0, 0];
|
|
104
|
-
|
|
105
|
-
if (subOptions) {
|
|
106
|
-
var parentMenu = getParentMenu(rootRef === null || rootRef === void 0 ? void 0 : rootRef.current);
|
|
107
|
-
|
|
108
|
-
if (parentMenu) {
|
|
109
|
-
var _parentMenu$getBoundi = parentMenu.getBoundingClientRect(),
|
|
110
|
-
x = _parentMenu$getBoundi.x,
|
|
111
|
-
width = _parentMenu$getBoundi.width;
|
|
112
|
-
|
|
113
|
-
var _rootRef$current$getB = rootRef.current.getBoundingClientRect(),
|
|
114
|
-
y = _rootRef$current$getB.y;
|
|
115
|
-
|
|
116
|
-
pos[0] = x + width;
|
|
117
|
-
pos[1] = y;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return pos;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
useEffect(function () {
|
|
125
|
-
if (subOptions && submenuOpenedByKeyboard) {
|
|
126
|
-
var firstSubnode = getFirstSubNode(rootRef === null || rootRef === void 0 ? void 0 : rootRef.current);
|
|
127
|
-
focusNode(firstSubnode);
|
|
128
|
-
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
129
|
-
|
|
130
|
-
}, [submenuOpen]);
|
|
131
|
-
var classes = cx("".concat(prefix, "--menu-option"), (_classnames2 = {}, _defineProperty(_classnames2, "".concat(prefix, "--menu-option--disabled"), disabled), _defineProperty(_classnames2, "".concat(prefix, "--menu-option--active"), subOptions && submenuOpen), _defineProperty(_classnames2, "".concat(prefix, "--menu-option--danger"), !subOptions && kind === 'danger'), _classnames2));
|
|
132
|
-
var allowedRoles = ['menuitemradio', 'menuitemcheckbox'];
|
|
133
|
-
var role = rest.role && allowedRoles.includes(rest.role) ? rest.role : 'menuitem';
|
|
134
|
-
var submenuPosition = getSubmenuPosition();
|
|
135
|
-
return (
|
|
136
|
-
/*#__PURE__*/
|
|
137
|
-
// role is either menuitemradio, menuitemcheckbox, or menuitem which are all interactive
|
|
138
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
139
|
-
React__default.createElement("li", _extends({}, rest, {
|
|
140
|
-
ref: rootRef,
|
|
141
|
-
className: classes,
|
|
142
|
-
role: role,
|
|
143
|
-
tabIndex: -1,
|
|
144
|
-
"aria-disabled": !subOptions && disabled,
|
|
145
|
-
"aria-haspopup": subOptions ? true : null,
|
|
146
|
-
"aria-expanded": subOptions ? submenuOpen : null,
|
|
147
|
-
onKeyDown: handleKeyDown,
|
|
148
|
-
onMouseEnter: subOptions ? handleMouseEnter : null,
|
|
149
|
-
onMouseLeave: subOptions ? handleMouseLeave : null,
|
|
150
|
-
onClick: onClick
|
|
151
|
-
}), subOptions ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MenuOptionContent, {
|
|
152
|
-
label: label,
|
|
153
|
-
icon: renderIcon,
|
|
154
|
-
info: _CaretRight || (_CaretRight = /*#__PURE__*/React__default.createElement(CaretRight, null)),
|
|
155
|
-
indented: indented
|
|
156
|
-
}), /*#__PURE__*/React__default.createElement(Menu, {
|
|
157
|
-
level: level + 1,
|
|
158
|
-
open: submenuOpen,
|
|
159
|
-
onClose: function onClose() {
|
|
160
|
-
setSubmenuOpen(false);
|
|
161
|
-
},
|
|
162
|
-
x: submenuPosition[0],
|
|
163
|
-
y: submenuPosition[1]
|
|
164
|
-
}, subOptions)) : /*#__PURE__*/React__default.createElement(MenuOptionContent, {
|
|
165
|
-
label: label,
|
|
166
|
-
disabled: disabled,
|
|
167
|
-
icon: renderIcon,
|
|
168
|
-
info: shortcut,
|
|
169
|
-
indented: indented
|
|
170
|
-
}))
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
MenuOptionContent.propTypes = {
|
|
175
|
-
/**
|
|
176
|
-
* Whether this option is disabled
|
|
177
|
-
*/
|
|
178
|
-
disabled: PropTypes.bool,
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Icon that is displayed in front of the option
|
|
182
|
-
*/
|
|
183
|
-
icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Whether the content should be indented
|
|
187
|
-
*/
|
|
188
|
-
indented: PropTypes.bool,
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Additional information such as shortcut or caret
|
|
192
|
-
*/
|
|
193
|
-
info: PropTypes.node,
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Rendered label for the MenuOptionContent
|
|
197
|
-
*/
|
|
198
|
-
label: PropTypes.node.isRequired
|
|
199
|
-
};
|
|
200
|
-
MenuOption.propTypes = {
|
|
201
|
-
/**
|
|
202
|
-
* Specify the children of the MenuOption
|
|
203
|
-
*/
|
|
204
|
-
children: PropTypes.node,
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Specify whether this MenuOption is disabled
|
|
208
|
-
*/
|
|
209
|
-
disabled: PropTypes.bool,
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Whether the content should be indented (for example because it's in a group with options that have icons).
|
|
213
|
-
* Is automatically set by Menu
|
|
214
|
-
*/
|
|
215
|
-
indented: PropTypes.bool,
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Optional prop to specify the kind of the MenuOption
|
|
219
|
-
*/
|
|
220
|
-
kind: PropTypes.oneOf(['default', 'danger']),
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Rendered label for the MenuOption
|
|
224
|
-
*/
|
|
225
|
-
label: PropTypes.node.isRequired,
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Which nested level this option is located in.
|
|
229
|
-
* Is automatically set by Menu
|
|
230
|
-
*/
|
|
231
|
-
level: PropTypes.number,
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* The onClick handler
|
|
235
|
-
*/
|
|
236
|
-
onClick: PropTypes.func,
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Rendered icon for the MenuOption.
|
|
240
|
-
* Can be a React component class
|
|
241
|
-
*/
|
|
242
|
-
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Rendered shortcut for the MenuOption
|
|
246
|
-
*/
|
|
247
|
-
shortcut: PropTypes.node
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
export { MenuOption as default };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React__default from 'react';
|
|
9
|
-
import PropTypes from 'prop-types';
|
|
10
|
-
import MenuGroup from './MenuGroup.js';
|
|
11
|
-
import MenuRadioGroupOptions from './MenuRadioGroupOptions.js';
|
|
12
|
-
|
|
13
|
-
function MenuRadioGroup(_ref) {
|
|
14
|
-
var items = _ref.items,
|
|
15
|
-
initialSelectedItem = _ref.initialSelectedItem,
|
|
16
|
-
label = _ref.label,
|
|
17
|
-
_ref$onChange = _ref.onChange,
|
|
18
|
-
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange;
|
|
19
|
-
return /*#__PURE__*/React__default.createElement(MenuGroup, {
|
|
20
|
-
label: label
|
|
21
|
-
}, /*#__PURE__*/React__default.createElement(MenuRadioGroupOptions, {
|
|
22
|
-
items: items,
|
|
23
|
-
initialSelectedItem: initialSelectedItem,
|
|
24
|
-
onChange: onChange
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
MenuRadioGroup.propTypes = {
|
|
29
|
-
/**
|
|
30
|
-
* Whether the option should be checked by default
|
|
31
|
-
*/
|
|
32
|
-
initialSelectedItem: PropTypes.string,
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Array of the radio options
|
|
36
|
-
*/
|
|
37
|
-
items: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The radio group label
|
|
41
|
-
*/
|
|
42
|
-
label: PropTypes.string.isRequired,
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Callback function when selection the has been changed
|
|
46
|
-
*/
|
|
47
|
-
onChange: PropTypes.func
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export { MenuRadioGroup as default };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default, { useState } from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import { Checkmark } from '@carbon/icons-react';
|
|
12
|
-
import MenuOption from './MenuOption.js';
|
|
13
|
-
|
|
14
|
-
function MenuRadioGroupOptions(_ref) {
|
|
15
|
-
var items = _ref.items,
|
|
16
|
-
initialSelectedItem = _ref.initialSelectedItem,
|
|
17
|
-
_ref$onChange = _ref.onChange,
|
|
18
|
-
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange;
|
|
19
|
-
|
|
20
|
-
var _useState = useState(initialSelectedItem),
|
|
21
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
-
selected = _useState2[0],
|
|
23
|
-
setSelected = _useState2[1];
|
|
24
|
-
|
|
25
|
-
function handleClick(option) {
|
|
26
|
-
setSelected(option);
|
|
27
|
-
onChange(option);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var options = items.map(function (option, i) {
|
|
31
|
-
var isSelected = selected === option;
|
|
32
|
-
return /*#__PURE__*/React__default.createElement(MenuOption, {
|
|
33
|
-
key: i,
|
|
34
|
-
role: "menuitemradio",
|
|
35
|
-
"aria-checked": isSelected,
|
|
36
|
-
renderIcon: isSelected ? Checkmark : null,
|
|
37
|
-
label: option,
|
|
38
|
-
indented: true,
|
|
39
|
-
onClick: function onClick() {
|
|
40
|
-
handleClick(option);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
return options;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
MenuRadioGroupOptions.propTypes = {
|
|
48
|
-
/**
|
|
49
|
-
* Whether the option should be checked by default
|
|
50
|
-
*/
|
|
51
|
-
initialSelectedItem: PropTypes.string,
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Array of the radio options
|
|
55
|
-
*/
|
|
56
|
-
items: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Callback function when selection the has been changed
|
|
60
|
-
*/
|
|
61
|
-
onChange: PropTypes.func
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export { MenuRadioGroupOptions as default };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default, { useState } from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import { Checkmark } from '@carbon/icons-react';
|
|
12
|
-
import MenuOption from './MenuOption.js';
|
|
13
|
-
|
|
14
|
-
function MenuSelectableItem(_ref) {
|
|
15
|
-
var label = _ref.label,
|
|
16
|
-
initialChecked = _ref.initialChecked,
|
|
17
|
-
_ref$onChange = _ref.onChange,
|
|
18
|
-
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange;
|
|
19
|
-
|
|
20
|
-
var _useState = useState(initialChecked),
|
|
21
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
-
checked = _useState2[0],
|
|
23
|
-
setChecked = _useState2[1];
|
|
24
|
-
|
|
25
|
-
function handleClick() {
|
|
26
|
-
setChecked(!checked);
|
|
27
|
-
onChange(!checked);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return /*#__PURE__*/React__default.createElement(MenuOption, {
|
|
31
|
-
role: "menuitemcheckbox",
|
|
32
|
-
"aria-checked": checked,
|
|
33
|
-
renderIcon: checked ? Checkmark : null,
|
|
34
|
-
label: label,
|
|
35
|
-
indented: true,
|
|
36
|
-
onClick: handleClick
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
MenuSelectableItem.propTypes = {
|
|
41
|
-
/**
|
|
42
|
-
* Whether the option should be checked by default
|
|
43
|
-
*/
|
|
44
|
-
initialChecked: PropTypes.bool,
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Rendered label for the MenuOptionContent
|
|
48
|
-
*/
|
|
49
|
-
label: PropTypes.node.isRequired,
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Callback function when selection the has been changed
|
|
53
|
-
*/
|
|
54
|
-
onChange: PropTypes.func
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export { MenuSelectableItem as default };
|