@carbon/react 1.48.0 → 1.48.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.
@@ -14,7 +14,6 @@ import { IconButton } from '../IconButton/index.js';
14
14
  import Button from '../Button/Button.js';
15
15
  import '../Button/Button.Skeleton.js';
16
16
  import { Menu } from '../Menu/Menu.js';
17
- import '../Menu/MenuItem.js';
18
17
  import { useAttachedMenu } from '../../internal/useAttachedMenu.js';
19
18
  import { useId } from '../../internal/useId.js';
20
19
  import { useMergedRefs } from '../../internal/useMergedRefs.js';
@@ -56,7 +56,7 @@ const Menu = /*#__PURE__*/React__default.forwardRef(function Menu(_ref, forwardR
56
56
  dispatch: childDispatch
57
57
  };
58
58
  }, [childState, childDispatch]);
59
- const menu = useRef(null);
59
+ const menu = useRef();
60
60
  const ref = useMergedRefs([forwardRef, menu]);
61
61
  const [position, setPosition] = useState([-1, -1]);
62
62
  const focusableItems = childContext.state.items.filter(item => !item.disabled && item.ref.current);
@@ -144,14 +144,11 @@ const Menu = /*#__PURE__*/React__default.forwardRef(function Menu(_ref, forwardR
144
144
  }
145
145
  }
146
146
  function handleBlur(e) {
147
- if (open && onClose && isRoot && !menu.current?.contains(e.relatedTarget)) {
147
+ if (open && onClose && isRoot && !menu.current.contains(e.relatedTarget)) {
148
148
  handleClose(e);
149
149
  }
150
150
  }
151
151
  function fitValue(range, axis) {
152
- if (!menu.current) {
153
- return;
154
- }
155
152
  const {
156
153
  width,
157
154
  height
@@ -190,38 +187,18 @@ const Menu = /*#__PURE__*/React__default.forwardRef(function Menu(_ref, forwardR
190
187
  reversedAnchor - size >= 0 ? reversedAnchor - size + offset : false,
191
188
  // align at max (second fallback)
192
189
  max - spacing - size];
193
-
194
- // Previous array `options`, has at least one item that is a number (the last one - second fallback).
195
- // That guarantees that the return of `find()` will always be a number
196
- // and we can safely add the numeric casting `as number`.
197
190
  const bestOption = options.find(option => option !== false);
198
191
  return bestOption >= spacing ? bestOption : spacing;
199
192
  }
200
- function notEmpty(value) {
201
- return value !== null && value !== undefined;
202
- }
203
- function getPosition(x) {
204
- if (Array.isArray(x)) {
205
- // has to be of length 2
206
- const filtered = x.filter(notEmpty);
207
- if (filtered.length === 2) {
208
- return filtered;
209
- } else {
210
- return;
211
- }
212
- } else {
213
- return [x, x];
214
- }
215
- }
216
193
  function calculatePosition() {
217
- const ranges = {
218
- x: getPosition(x),
219
- y: getPosition(y)
220
- };
221
- if (!ranges.x || !ranges.y) {
222
- return [-1, -1];
194
+ if (menu.current) {
195
+ const ranges = {
196
+ x: typeof x === 'object' && x.length === 2 ? x : [x, x],
197
+ y: typeof y === 'object' && y.length === 2 ? y : [y, y]
198
+ };
199
+ return [fitValue(ranges.x, 'x'), fitValue(ranges.y, 'y')];
223
200
  }
224
- return [fitValue(ranges.x, 'x') ?? -1, fitValue(ranges.y, 'y') ?? -1];
201
+ return [-1, -1];
225
202
  }
226
203
  useEffect(() => {
227
204
  if (open && focusableItems.length > 0) {
@@ -235,7 +212,7 @@ const Menu = /*#__PURE__*/React__default.forwardRef(function Menu(_ref, forwardR
235
212
  } else {
236
213
  // reset position when menu is closed in order for the --shown
237
214
  // modifier to be applied correctly
238
- setPosition([-1, -1]);
215
+ setPosition(-1, -1);
239
216
  }
240
217
  // eslint-disable-next-line react-hooks/exhaustive-deps
241
218
  }, [open]);
@@ -39,7 +39,7 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref,
39
39
  } = _ref;
40
40
  const prefix = usePrefix();
41
41
  const context = useContext(MenuContext);
42
- const menuItem = useRef(null);
42
+ const menuItem = useRef();
43
43
  const ref = useMergedRefs([forwardRef, menuItem]);
44
44
  const [boundaries, setBoundaries] = useState({
45
45
  x: -1,
@@ -61,9 +61,6 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref,
61
61
  });
62
62
  }
63
63
  function openSubmenu() {
64
- if (!menuItem.current) {
65
- return;
66
- }
67
64
  const {
68
65
  x,
69
66
  y,
@@ -108,11 +105,9 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref,
108
105
  }, hoverIntentDelay);
109
106
  }
110
107
  function handleMouseLeave() {
111
- if (hoverIntentTimeout.current) {
112
- clearTimeout(hoverIntentTimeout.current);
113
- closeSubmenu();
114
- menuItem.current?.focus();
115
- }
108
+ clearTimeout(hoverIntentTimeout.current);
109
+ closeSubmenu();
110
+ menuItem.current.focus();
116
111
  }
117
112
  function handleKeyDown(e) {
118
113
  if (hasChildren && match(e, ArrowRight)) {
@@ -162,13 +157,13 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref,
162
157
  }, rest, {
163
158
  ref: ref,
164
159
  className: classNames,
165
- tabIndex: -1,
166
- "aria-disabled": isDisabled,
167
- "aria-haspopup": hasChildren || undefined,
168
- "aria-expanded": hasChildren ? submenuOpen : undefined,
160
+ tabIndex: "-1",
161
+ "aria-disabled": isDisabled || null,
162
+ "aria-haspopup": hasChildren || null,
163
+ "aria-expanded": hasChildren ? submenuOpen : null,
169
164
  onClick: handleClick,
170
- onMouseEnter: hasChildren ? handleMouseEnter : undefined,
171
- onMouseLeave: hasChildren ? handleMouseLeave : undefined,
165
+ onMouseEnter: hasChildren ? handleMouseEnter : null,
166
+ onMouseLeave: hasChildren ? handleMouseLeave : null,
172
167
  onKeyDown: handleKeyDown
173
168
  }), /*#__PURE__*/React__default.createElement("div", {
174
169
  className: `${prefix}--menu-item__icon`
@@ -185,7 +180,7 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref,
185
180
  open: submenuOpen,
186
181
  onClose: () => {
187
182
  closeSubmenu();
188
- menuItem.current?.focus();
183
+ menuItem.current.focus();
189
184
  },
190
185
  x: boundaries.x,
191
186
  y: boundaries.y
@@ -365,7 +360,7 @@ const MenuItemRadioGroup = /*#__PURE__*/React__default.forwardRef(function MenuI
365
360
  }, /*#__PURE__*/React__default.createElement("ul", _extends({}, rest, {
366
361
  role: "group",
367
362
  "aria-label": label
368
- }), items?.map((item, i) => /*#__PURE__*/React__default.createElement(MenuItem, {
363
+ }), items.map((item, i) => /*#__PURE__*/React__default.createElement(MenuItem, {
369
364
  key: i,
370
365
  label: itemToString(item),
371
366
  role: "menuitemradio",
@@ -13,7 +13,6 @@ import { ChevronDown } from '@carbon/icons-react';
13
13
  import Button from '../Button/Button.js';
14
14
  import '../Button/Button.Skeleton.js';
15
15
  import { Menu } from '../Menu/Menu.js';
16
- import '../Menu/MenuItem.js';
17
16
  import { useAttachedMenu } from '../../internal/useAttachedMenu.js';
18
17
  import { useId } from '../../internal/useId.js';
19
18
  import { useMergedRefs } from '../../internal/useMergedRefs.js';
@@ -12,7 +12,6 @@ import cx from 'classnames';
12
12
  import { OverflowMenuVertical } from '@carbon/icons-react';
13
13
  import { IconButton } from '../../IconButton/index.js';
14
14
  import { Menu } from '../../Menu/Menu.js';
15
- import '../../Menu/MenuItem.js';
16
15
  import { useId } from '../../../internal/useId.js';
17
16
  import { usePrefix } from '../../../internal/usePrefix.js';
18
17
  import { useAttachedMenu } from '../../../internal/useAttachedMenu.js';
package/es/index.js CHANGED
@@ -60,8 +60,6 @@ export { default as InlineLoading } from './components/InlineLoading/InlineLoadi
60
60
  export { default as Link } from './components/Link/Link.js';
61
61
  export { default as ListItem } from './components/ListItem/ListItem.js';
62
62
  export { default as Loading } from './components/Loading/Loading.js';
63
- export { Menu } from './components/Menu/Menu.js';
64
- export { MenuItem, MenuItemDivider, MenuItemGroup, MenuItemRadioGroup, MenuItemSelectable } from './components/Menu/MenuItem.js';
65
63
  export { MenuButton } from './components/MenuButton/index.js';
66
64
  export { default as Modal } from './components/Modal/Modal.js';
67
65
  export { default as ModalWrapper } from './components/ModalWrapper/ModalWrapper.js';
@@ -214,6 +212,8 @@ export { default as TableToolbarContent } from './components/DataTable/TableTool
214
212
  export { default as TableToolbarSearch } from './components/DataTable/TableToolbarSearch.js';
215
213
  export { default as TableToolbarMenu } from './components/DataTable/TableToolbarMenu.js';
216
214
  export { default as FilterableMultiSelect } from './components/MultiSelect/FilterableMultiSelect.js';
215
+ export { Menu } from './components/Menu/Menu.js';
216
+ export { MenuItem, MenuItemDivider, MenuItemGroup, MenuItemRadioGroup, MenuItemSelectable } from './components/Menu/MenuItem.js';
217
217
  export { default as MultiSelect } from './components/MultiSelect/MultiSelect.js';
218
218
  export { default as Pagination } from './components/Pagination/Pagination.js';
219
219
  export { default as PaginationNav } from './components/PaginationNav/PaginationNav.js';
@@ -18,7 +18,6 @@ var index = require('../IconButton/index.js');
18
18
  var Button = require('../Button/Button.js');
19
19
  require('../Button/Button.Skeleton.js');
20
20
  var Menu = require('../Menu/Menu.js');
21
- require('../Menu/MenuItem.js');
22
21
  var useAttachedMenu = require('../../internal/useAttachedMenu.js');
23
22
  var useId = require('../../internal/useId.js');
24
23
  var useMergedRefs = require('../../internal/useMergedRefs.js');
@@ -66,7 +66,7 @@ const Menu = /*#__PURE__*/React__default["default"].forwardRef(function Menu(_re
66
66
  dispatch: childDispatch
67
67
  };
68
68
  }, [childState, childDispatch]);
69
- const menu = React.useRef(null);
69
+ const menu = React.useRef();
70
70
  const ref = useMergedRefs.useMergedRefs([forwardRef, menu]);
71
71
  const [position, setPosition] = React.useState([-1, -1]);
72
72
  const focusableItems = childContext.state.items.filter(item => !item.disabled && item.ref.current);
@@ -154,14 +154,11 @@ const Menu = /*#__PURE__*/React__default["default"].forwardRef(function Menu(_re
154
154
  }
155
155
  }
156
156
  function handleBlur(e) {
157
- if (open && onClose && isRoot && !menu.current?.contains(e.relatedTarget)) {
157
+ if (open && onClose && isRoot && !menu.current.contains(e.relatedTarget)) {
158
158
  handleClose(e);
159
159
  }
160
160
  }
161
161
  function fitValue(range, axis) {
162
- if (!menu.current) {
163
- return;
164
- }
165
162
  const {
166
163
  width,
167
164
  height
@@ -200,38 +197,18 @@ const Menu = /*#__PURE__*/React__default["default"].forwardRef(function Menu(_re
200
197
  reversedAnchor - size >= 0 ? reversedAnchor - size + offset : false,
201
198
  // align at max (second fallback)
202
199
  max - spacing - size];
203
-
204
- // Previous array `options`, has at least one item that is a number (the last one - second fallback).
205
- // That guarantees that the return of `find()` will always be a number
206
- // and we can safely add the numeric casting `as number`.
207
200
  const bestOption = options.find(option => option !== false);
208
201
  return bestOption >= spacing ? bestOption : spacing;
209
202
  }
210
- function notEmpty(value) {
211
- return value !== null && value !== undefined;
212
- }
213
- function getPosition(x) {
214
- if (Array.isArray(x)) {
215
- // has to be of length 2
216
- const filtered = x.filter(notEmpty);
217
- if (filtered.length === 2) {
218
- return filtered;
219
- } else {
220
- return;
221
- }
222
- } else {
223
- return [x, x];
224
- }
225
- }
226
203
  function calculatePosition() {
227
- const ranges = {
228
- x: getPosition(x),
229
- y: getPosition(y)
230
- };
231
- if (!ranges.x || !ranges.y) {
232
- return [-1, -1];
204
+ if (menu.current) {
205
+ const ranges = {
206
+ x: typeof x === 'object' && x.length === 2 ? x : [x, x],
207
+ y: typeof y === 'object' && y.length === 2 ? y : [y, y]
208
+ };
209
+ return [fitValue(ranges.x, 'x'), fitValue(ranges.y, 'y')];
233
210
  }
234
- return [fitValue(ranges.x, 'x') ?? -1, fitValue(ranges.y, 'y') ?? -1];
211
+ return [-1, -1];
235
212
  }
236
213
  React.useEffect(() => {
237
214
  if (open && focusableItems.length > 0) {
@@ -245,7 +222,7 @@ const Menu = /*#__PURE__*/React__default["default"].forwardRef(function Menu(_re
245
222
  } else {
246
223
  // reset position when menu is closed in order for the --shown
247
224
  // modifier to be applied correctly
248
- setPosition([-1, -1]);
225
+ setPosition(-1, -1);
249
226
  }
250
227
  // eslint-disable-next-line react-hooks/exhaustive-deps
251
228
  }, [open]);
@@ -49,7 +49,7 @@ const MenuItem = /*#__PURE__*/React__default["default"].forwardRef(function Menu
49
49
  } = _ref;
50
50
  const prefix = usePrefix.usePrefix();
51
51
  const context = React.useContext(MenuContext.MenuContext);
52
- const menuItem = React.useRef(null);
52
+ const menuItem = React.useRef();
53
53
  const ref = useMergedRefs.useMergedRefs([forwardRef, menuItem]);
54
54
  const [boundaries, setBoundaries] = React.useState({
55
55
  x: -1,
@@ -71,9 +71,6 @@ const MenuItem = /*#__PURE__*/React__default["default"].forwardRef(function Menu
71
71
  });
72
72
  }
73
73
  function openSubmenu() {
74
- if (!menuItem.current) {
75
- return;
76
- }
77
74
  const {
78
75
  x,
79
76
  y,
@@ -118,11 +115,9 @@ const MenuItem = /*#__PURE__*/React__default["default"].forwardRef(function Menu
118
115
  }, hoverIntentDelay);
119
116
  }
120
117
  function handleMouseLeave() {
121
- if (hoverIntentTimeout.current) {
122
- clearTimeout(hoverIntentTimeout.current);
123
- closeSubmenu();
124
- menuItem.current?.focus();
125
- }
118
+ clearTimeout(hoverIntentTimeout.current);
119
+ closeSubmenu();
120
+ menuItem.current.focus();
126
121
  }
127
122
  function handleKeyDown(e) {
128
123
  if (hasChildren && match.match(e, keys.ArrowRight)) {
@@ -172,13 +167,13 @@ const MenuItem = /*#__PURE__*/React__default["default"].forwardRef(function Menu
172
167
  }, rest, {
173
168
  ref: ref,
174
169
  className: classNames,
175
- tabIndex: -1,
176
- "aria-disabled": isDisabled,
177
- "aria-haspopup": hasChildren || undefined,
178
- "aria-expanded": hasChildren ? submenuOpen : undefined,
170
+ tabIndex: "-1",
171
+ "aria-disabled": isDisabled || null,
172
+ "aria-haspopup": hasChildren || null,
173
+ "aria-expanded": hasChildren ? submenuOpen : null,
179
174
  onClick: handleClick,
180
- onMouseEnter: hasChildren ? handleMouseEnter : undefined,
181
- onMouseLeave: hasChildren ? handleMouseLeave : undefined,
175
+ onMouseEnter: hasChildren ? handleMouseEnter : null,
176
+ onMouseLeave: hasChildren ? handleMouseLeave : null,
182
177
  onKeyDown: handleKeyDown
183
178
  }), /*#__PURE__*/React__default["default"].createElement("div", {
184
179
  className: `${prefix}--menu-item__icon`
@@ -195,7 +190,7 @@ const MenuItem = /*#__PURE__*/React__default["default"].forwardRef(function Menu
195
190
  open: submenuOpen,
196
191
  onClose: () => {
197
192
  closeSubmenu();
198
- menuItem.current?.focus();
193
+ menuItem.current.focus();
199
194
  },
200
195
  x: boundaries.x,
201
196
  y: boundaries.y
@@ -375,7 +370,7 @@ const MenuItemRadioGroup = /*#__PURE__*/React__default["default"].forwardRef(fun
375
370
  }, /*#__PURE__*/React__default["default"].createElement("ul", _rollupPluginBabelHelpers["extends"]({}, rest, {
376
371
  role: "group",
377
372
  "aria-label": label
378
- }), items?.map((item, i) => /*#__PURE__*/React__default["default"].createElement(MenuItem, {
373
+ }), items.map((item, i) => /*#__PURE__*/React__default["default"].createElement(MenuItem, {
379
374
  key: i,
380
375
  label: itemToString(item),
381
376
  role: "menuitemradio",
@@ -17,7 +17,6 @@ var iconsReact = require('@carbon/icons-react');
17
17
  var Button = require('../Button/Button.js');
18
18
  require('../Button/Button.Skeleton.js');
19
19
  var Menu = require('../Menu/Menu.js');
20
- require('../Menu/MenuItem.js');
21
20
  var useAttachedMenu = require('../../internal/useAttachedMenu.js');
22
21
  var useId = require('../../internal/useId.js');
23
22
  var useMergedRefs = require('../../internal/useMergedRefs.js');
@@ -16,7 +16,6 @@ var cx = require('classnames');
16
16
  var iconsReact = require('@carbon/icons-react');
17
17
  var index = require('../../IconButton/index.js');
18
18
  var Menu = require('../../Menu/Menu.js');
19
- require('../../Menu/MenuItem.js');
20
19
  var useId = require('../../../internal/useId.js');
21
20
  var usePrefix = require('../../../internal/usePrefix.js');
22
21
  var useAttachedMenu = require('../../../internal/useAttachedMenu.js');
package/lib/index.js CHANGED
@@ -64,8 +64,6 @@ var InlineLoading = require('./components/InlineLoading/InlineLoading.js');
64
64
  var Link = require('./components/Link/Link.js');
65
65
  var ListItem = require('./components/ListItem/ListItem.js');
66
66
  var Loading = require('./components/Loading/Loading.js');
67
- var Menu = require('./components/Menu/Menu.js');
68
- var MenuItem = require('./components/Menu/MenuItem.js');
69
67
  var index$8 = require('./components/MenuButton/index.js');
70
68
  var Modal = require('./components/Modal/Modal.js');
71
69
  var ModalWrapper = require('./components/ModalWrapper/ModalWrapper.js');
@@ -218,6 +216,8 @@ var TableToolbarContent = require('./components/DataTable/TableToolbarContent.js
218
216
  var TableToolbarSearch = require('./components/DataTable/TableToolbarSearch.js');
219
217
  var TableToolbarMenu = require('./components/DataTable/TableToolbarMenu.js');
220
218
  var FilterableMultiSelect = require('./components/MultiSelect/FilterableMultiSelect.js');
219
+ var Menu = require('./components/Menu/Menu.js');
220
+ var MenuItem = require('./components/Menu/MenuItem.js');
221
221
  var MultiSelect = require('./components/MultiSelect/MultiSelect.js');
222
222
  var Pagination$1 = require('./components/Pagination/Pagination.js');
223
223
  var PaginationNav = require('./components/PaginationNav/PaginationNav.js');
@@ -287,12 +287,6 @@ exports.InlineLoading = InlineLoading["default"];
287
287
  exports.Link = Link["default"];
288
288
  exports.ListItem = ListItem["default"];
289
289
  exports.Loading = Loading["default"];
290
- exports.Menu = Menu.Menu;
291
- exports.MenuItem = MenuItem.MenuItem;
292
- exports.MenuItemDivider = MenuItem.MenuItemDivider;
293
- exports.MenuItemGroup = MenuItem.MenuItemGroup;
294
- exports.MenuItemRadioGroup = MenuItem.MenuItemRadioGroup;
295
- exports.MenuItemSelectable = MenuItem.MenuItemSelectable;
296
290
  exports.MenuButton = index$8.MenuButton;
297
291
  exports.Modal = Modal["default"];
298
292
  exports.ModalWrapper = ModalWrapper["default"];
@@ -481,6 +475,12 @@ exports.TableToolbarContent = TableToolbarContent["default"];
481
475
  exports.TableToolbarSearch = TableToolbarSearch["default"];
482
476
  exports.TableToolbarMenu = TableToolbarMenu["default"];
483
477
  exports.FilterableMultiSelect = FilterableMultiSelect["default"];
478
+ exports.Menu = Menu.Menu;
479
+ exports.MenuItem = MenuItem.MenuItem;
480
+ exports.MenuItemDivider = MenuItem.MenuItemDivider;
481
+ exports.MenuItemGroup = MenuItem.MenuItemGroup;
482
+ exports.MenuItemRadioGroup = MenuItem.MenuItemRadioGroup;
483
+ exports.MenuItemSelectable = MenuItem.MenuItemSelectable;
484
484
  exports.MultiSelect = MultiSelect["default"];
485
485
  exports.Pagination = Pagination$1["default"];
486
486
  exports.PaginationNav = PaginationNav["default"];
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.48.0",
4
+ "version": "1.48.1",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -49,9 +49,9 @@
49
49
  "dependencies": {
50
50
  "@babel/runtime": "^7.18.3",
51
51
  "@carbon/feature-flags": "^0.16.0",
52
- "@carbon/icons-react": "^11.34.0",
52
+ "@carbon/icons-react": "^11.34.1",
53
53
  "@carbon/layout": "^11.20.0",
54
- "@carbon/styles": "^1.48.0",
54
+ "@carbon/styles": "^1.48.1",
55
55
  "@ibm/telemetry-js": "^1.1.0",
56
56
  "classnames": "2.5.1",
57
57
  "copy-to-clipboard": "^3.3.1",
@@ -79,7 +79,7 @@
79
79
  "@babel/preset-react": "^7.22.3",
80
80
  "@babel/preset-typescript": "^7.21.5",
81
81
  "@carbon/test-utils": "^10.30.0",
82
- "@carbon/themes": "^11.29.0",
82
+ "@carbon/themes": "^11.29.1",
83
83
  "@rollup/plugin-babel": "^6.0.0",
84
84
  "@rollup/plugin-commonjs": "^25.0.0",
85
85
  "@rollup/plugin-node-resolve": "^15.0.0",
@@ -139,5 +139,5 @@
139
139
  "**/*.scss",
140
140
  "**/*.css"
141
141
  ],
142
- "gitHead": "6d133d4f920b7c01f6ea2221938a339c14a85b42"
142
+ "gitHead": "68c58d98fe0c287eb4456c8b5153f6cb7b58c5bf"
143
143
  }
@@ -1,59 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2023
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
- import React from 'react';
8
- interface MenuProps extends React.HTMLAttributes<HTMLUListElement> {
9
- /**
10
- * A collection of MenuItems to be rendered within this Menu.
11
- */
12
- children?: React.ReactNode;
13
- /**
14
- * Additional CSS class names.
15
- */
16
- className?: string;
17
- /**
18
- * A label describing the Menu.
19
- */
20
- label?: string;
21
- /**
22
- * The mode of this menu. Defaults to full.
23
- * `full` supports nesting and selectable menu items, but no icons.
24
- * `basic` supports icons but no nesting or selectable menu items.
25
- *
26
- * **This prop is not intended for use and will be set by the respective implementation (like useContextMenu, MenuButton, and ComboButton).**
27
- */
28
- mode?: 'full' | 'basic';
29
- /**
30
- * Provide an optional function to be called when the Menu should be closed.
31
- */
32
- onClose?: () => void;
33
- /**
34
- * Provide an optional function to be called when the Menu is opened.
35
- */
36
- onOpen?: () => void;
37
- /**
38
- * Whether the Menu is open or not.
39
- */
40
- open?: boolean;
41
- /**
42
- * Specify the size of the Menu.
43
- */
44
- size?: 'xs' | 'sm' | 'md' | 'lg';
45
- /**
46
- * Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
47
- */
48
- target?: any;
49
- /**
50
- * Specify the x position of the Menu. Either pass a single number or an array with two numbers describing your activator's boundaries ([x1, x2])
51
- */
52
- x?: number | (number | null | undefined)[];
53
- /**
54
- * Specify the y position of the Menu. Either pass a single number or an array with two numbers describing your activator's boundaries ([y1, y2])
55
- */
56
- y?: number | (number | null | undefined)[];
57
- }
58
- declare const Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<HTMLUListElement>>;
59
- export { Menu };
@@ -1,32 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2023
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
- import React from 'react';
8
- type ActionType = {
9
- type: 'enableIcons' | 'registerItem';
10
- payload: any;
11
- };
12
- type StateType = {
13
- isRoot: boolean;
14
- mode: 'full' | 'basic';
15
- hasIcons: boolean;
16
- size: 'xs' | 'sm' | 'md' | 'lg' | null;
17
- items: any[];
18
- requestCloseRoot: (e: Pick<React.KeyboardEvent<HTMLUListElement>, 'type'>) => void;
19
- };
20
- declare function menuReducer(state: StateType, action: ActionType): {
21
- hasIcons: boolean;
22
- isRoot: boolean;
23
- mode: "full" | "basic";
24
- size: "sm" | "md" | "lg" | "xs" | null;
25
- items: any[];
26
- requestCloseRoot: (e: Pick<React.KeyboardEvent<HTMLUListElement>, "type">) => void;
27
- };
28
- declare const MenuContext: React.Context<{
29
- state: StateType;
30
- dispatch: React.Dispatch<any>;
31
- }>;
32
- export { MenuContext, menuReducer };
@@ -1,119 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2023
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
- import React from 'react';
8
- interface MenuItemProps extends React.LiHTMLAttributes<HTMLLIElement> {
9
- /**
10
- * Optionally provide another Menu to create a submenu. props.children can't be used to specify the content of the MenuItem itself. Use props.label instead.
11
- */
12
- children?: React.ReactNode;
13
- /**
14
- * Additional CSS class names.
15
- */
16
- className?: string;
17
- /**
18
- * Specify whether the MenuItem is disabled or not.
19
- */
20
- disabled?: boolean;
21
- /**
22
- * Specify the kind of the MenuItem.
23
- */
24
- kind?: 'default' | 'danger';
25
- /**
26
- * A required label titling the MenuItem. Will be rendered as its text content.
27
- */
28
- label: string;
29
- /**
30
- * Provide an optional function to be called when the MenuItem is clicked.
31
- */
32
- onClick?: (event: React.KeyboardEvent<HTMLLIElement> | React.MouseEvent<HTMLLIElement>) => void;
33
- /**
34
- * Only applicable if the parent menu is in `basic` mode. Sets the menu item's icon.
35
- */
36
- renderIcon?: any;
37
- /**
38
- * Provide a shortcut for the action of this MenuItem. Note that the component will only render it as a hint but not actually register the shortcut.
39
- */
40
- shortcut?: string;
41
- }
42
- declare const MenuItem: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<HTMLLIElement>>;
43
- interface MenuItemSelectableProps {
44
- /**
45
- * Additional CSS class names.
46
- */
47
- className?: string;
48
- /**
49
- * Specify whether the option should be selected by default.
50
- */
51
- defaultSelected?: boolean;
52
- /**
53
- * A required label titling this option.
54
- */
55
- label: string;
56
- /**
57
- * Provide an optional function to be called when the selection state changes.
58
- */
59
- onChange?: React.ChangeEventHandler<HTMLLIElement>;
60
- /**
61
- * Pass a bool to props.selected to control the state of this option.
62
- */
63
- selected?: boolean;
64
- }
65
- declare const MenuItemSelectable: React.ForwardRefExoticComponent<MenuItemSelectableProps & React.RefAttributes<HTMLLIElement>>;
66
- interface MenuItemGroupProps {
67
- /**
68
- * A collection of MenuItems to be rendered within this group.
69
- */
70
- children?: React.ReactNode;
71
- /**
72
- * Additional CSS class names.
73
- */
74
- className?: string;
75
- /**
76
- * A required label titling this group.
77
- */
78
- label: string;
79
- }
80
- declare const MenuItemGroup: React.ForwardRefExoticComponent<MenuItemGroupProps & React.RefAttributes<HTMLLIElement>>;
81
- interface MenuItemRadioGroupProps {
82
- /**
83
- * Additional CSS class names.
84
- */
85
- className?: string;
86
- /**
87
- * Specify the default selected item. Must match the type of props.items.
88
- */
89
- defaultSelectedItem?: any;
90
- /**
91
- * Provide a function to convert an item to the string that will be rendered. Defaults to item.toString().
92
- */
93
- itemToString?: (item: any) => string;
94
- /**
95
- * Provide the options for this radio group. Can be of any type, as long as you provide an appropriate props.itemToString function.
96
- */
97
- items?: any[];
98
- /**
99
- * A required label titling this radio group.
100
- */
101
- label: string;
102
- /**
103
- * Provide an optional function to be called when the selection changes.
104
- */
105
- onChange?: React.ChangeEventHandler<HTMLLIElement>;
106
- /**
107
- * Provide props.selectedItem to control the state of this radio group. Must match the type of props.items.
108
- */
109
- selectedItem?: any;
110
- }
111
- declare const MenuItemRadioGroup: React.ForwardRefExoticComponent<MenuItemRadioGroupProps & React.RefAttributes<HTMLLIElement>>;
112
- interface MenuItemDividerProps {
113
- /**
114
- * Additional CSS class names.
115
- */
116
- className?: string;
117
- }
118
- declare const MenuItemDivider: React.ForwardRefExoticComponent<MenuItemDividerProps & React.RefAttributes<HTMLLIElement>>;
119
- export { MenuItem, MenuItemSelectable, MenuItemGroup, MenuItemRadioGroup, MenuItemDivider, };