@carbon/react 1.47.0 → 1.48.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.
Files changed (76) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +914 -839
  2. package/es/components/Button/Button.d.ts +1 -3
  3. package/es/components/Button/Button.js +9 -3
  4. package/es/components/ComboButton/index.js +1 -0
  5. package/es/components/ComposedModal/ModalHeader.js +10 -4
  6. package/es/components/DangerButton/DangerButton.js +2 -2
  7. package/es/components/DataTable/TableExpandHeader.d.ts +1 -1
  8. package/es/components/DataTable/TableExpandRow.d.ts +1 -1
  9. package/es/components/DataTable/TableExpandRow.js +0 -1
  10. package/es/components/DataTable/TableHeader.d.ts +10 -1
  11. package/es/components/DataTable/index.d.ts +3 -2
  12. package/es/components/DatePicker/DatePicker.js +3 -2
  13. package/es/components/Dropdown/Dropdown.d.ts +3 -2
  14. package/es/components/Dropdown/index.d.ts +2 -2
  15. package/es/components/ExpandableSearch/ExpandableSearch.js +6 -3
  16. package/es/components/IconButton/index.d.ts +70 -0
  17. package/es/components/IconButton/index.js +6 -5
  18. package/es/components/ListBox/ListBoxMenuIcon.d.ts +3 -6
  19. package/es/components/ListBox/ListBoxMenuIcon.js +4 -8
  20. package/es/components/ListBox/index.d.ts +1 -0
  21. package/es/components/Menu/Menu.d.ts +59 -0
  22. package/es/components/Menu/Menu.js +33 -10
  23. package/es/components/Menu/MenuContext.d.ts +32 -0
  24. package/es/components/Menu/MenuItem.d.ts +119 -0
  25. package/es/components/Menu/MenuItem.js +17 -12
  26. package/es/components/Menu/index.d.ts +9 -0
  27. package/es/components/MenuButton/index.js +1 -0
  28. package/es/components/Modal/Modal.d.ts +1 -1
  29. package/es/components/Modal/Modal.js +10 -6
  30. package/es/components/OverflowMenu/next/index.js +1 -0
  31. package/es/components/Slug/index.js +5 -1
  32. package/es/components/Tooltip/Tooltip.js +1 -9
  33. package/es/components/TreeView/TreeNode.js +11 -3
  34. package/es/components/TreeView/TreeView.js +1 -1
  35. package/es/components/UIShell/HeaderMenu.js +1 -1
  36. package/es/components/UIShell/SwitcherItem.d.ts +4 -0
  37. package/es/components/UIShell/SwitcherItem.js +4 -0
  38. package/es/index.js +3 -3
  39. package/lib/components/Button/Button.d.ts +1 -3
  40. package/lib/components/Button/Button.js +9 -3
  41. package/lib/components/ComboButton/index.js +1 -0
  42. package/lib/components/ComposedModal/ModalHeader.js +10 -4
  43. package/lib/components/DangerButton/DangerButton.js +2 -2
  44. package/lib/components/DataTable/TableExpandHeader.d.ts +1 -1
  45. package/lib/components/DataTable/TableExpandRow.d.ts +1 -1
  46. package/lib/components/DataTable/TableExpandRow.js +0 -1
  47. package/lib/components/DataTable/TableHeader.d.ts +10 -1
  48. package/lib/components/DataTable/index.d.ts +3 -2
  49. package/lib/components/DatePicker/DatePicker.js +3 -2
  50. package/lib/components/Dropdown/Dropdown.d.ts +3 -2
  51. package/lib/components/Dropdown/index.d.ts +2 -2
  52. package/lib/components/ExpandableSearch/ExpandableSearch.js +5 -2
  53. package/lib/components/IconButton/index.d.ts +70 -0
  54. package/lib/components/IconButton/index.js +6 -4
  55. package/lib/components/ListBox/ListBoxMenuIcon.d.ts +3 -6
  56. package/lib/components/ListBox/ListBoxMenuIcon.js +3 -8
  57. package/lib/components/ListBox/index.d.ts +1 -0
  58. package/lib/components/Menu/Menu.d.ts +59 -0
  59. package/lib/components/Menu/Menu.js +33 -10
  60. package/lib/components/Menu/MenuContext.d.ts +32 -0
  61. package/lib/components/Menu/MenuItem.d.ts +119 -0
  62. package/lib/components/Menu/MenuItem.js +17 -12
  63. package/lib/components/Menu/index.d.ts +9 -0
  64. package/lib/components/MenuButton/index.js +1 -0
  65. package/lib/components/Modal/Modal.d.ts +1 -1
  66. package/lib/components/Modal/Modal.js +10 -6
  67. package/lib/components/OverflowMenu/next/index.js +1 -0
  68. package/lib/components/Slug/index.js +5 -1
  69. package/lib/components/Tooltip/Tooltip.js +0 -8
  70. package/lib/components/TreeView/TreeNode.js +11 -3
  71. package/lib/components/TreeView/TreeView.js +1 -1
  72. package/lib/components/UIShell/HeaderMenu.js +1 -1
  73. package/lib/components/UIShell/SwitcherItem.d.ts +4 -0
  74. package/lib/components/UIShell/SwitcherItem.js +4 -0
  75. package/lib/index.js +9 -8
  76. package/package.json +7 -7
@@ -0,0 +1,119 @@
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, };
@@ -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();
42
+ const menuItem = useRef(null);
43
43
  const ref = useMergedRefs([forwardRef, menuItem]);
44
44
  const [boundaries, setBoundaries] = useState({
45
45
  x: -1,
@@ -61,6 +61,9 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref,
61
61
  });
62
62
  }
63
63
  function openSubmenu() {
64
+ if (!menuItem.current) {
65
+ return;
66
+ }
64
67
  const {
65
68
  x,
66
69
  y,
@@ -105,9 +108,11 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref,
105
108
  }, hoverIntentDelay);
106
109
  }
107
110
  function handleMouseLeave() {
108
- clearTimeout(hoverIntentTimeout.current);
109
- closeSubmenu();
110
- menuItem.current.focus();
111
+ if (hoverIntentTimeout.current) {
112
+ clearTimeout(hoverIntentTimeout.current);
113
+ closeSubmenu();
114
+ menuItem.current?.focus();
115
+ }
111
116
  }
112
117
  function handleKeyDown(e) {
113
118
  if (hasChildren && match(e, ArrowRight)) {
@@ -157,13 +162,13 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref,
157
162
  }, rest, {
158
163
  ref: ref,
159
164
  className: classNames,
160
- tabIndex: "-1",
161
- "aria-disabled": isDisabled || null,
162
- "aria-haspopup": hasChildren || null,
163
- "aria-expanded": hasChildren ? submenuOpen : null,
165
+ tabIndex: -1,
166
+ "aria-disabled": isDisabled,
167
+ "aria-haspopup": hasChildren || undefined,
168
+ "aria-expanded": hasChildren ? submenuOpen : undefined,
164
169
  onClick: handleClick,
165
- onMouseEnter: hasChildren ? handleMouseEnter : null,
166
- onMouseLeave: hasChildren ? handleMouseLeave : null,
170
+ onMouseEnter: hasChildren ? handleMouseEnter : undefined,
171
+ onMouseLeave: hasChildren ? handleMouseLeave : undefined,
167
172
  onKeyDown: handleKeyDown
168
173
  }), /*#__PURE__*/React__default.createElement("div", {
169
174
  className: `${prefix}--menu-item__icon`
@@ -180,7 +185,7 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref,
180
185
  open: submenuOpen,
181
186
  onClose: () => {
182
187
  closeSubmenu();
183
- menuItem.current.focus();
188
+ menuItem.current?.focus();
184
189
  },
185
190
  x: boundaries.x,
186
191
  y: boundaries.y
@@ -360,7 +365,7 @@ const MenuItemRadioGroup = /*#__PURE__*/React__default.forwardRef(function MenuI
360
365
  }, /*#__PURE__*/React__default.createElement("ul", _extends({}, rest, {
361
366
  role: "group",
362
367
  "aria-label": label
363
- }), items.map((item, i) => /*#__PURE__*/React__default.createElement(MenuItem, {
368
+ }), items?.map((item, i) => /*#__PURE__*/React__default.createElement(MenuItem, {
364
369
  key: i,
365
370
  label: itemToString(item),
366
371
  role: "menuitemradio",
@@ -0,0 +1,9 @@
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 { Menu } from './Menu';
8
+ import { MenuItem, MenuItemDivider, MenuItemGroup, MenuItemRadioGroup, MenuItemSelectable } from './MenuItem';
9
+ export { Menu, MenuItem, MenuItemDivider, MenuItemGroup, MenuItemRadioGroup, MenuItemSelectable, };
@@ -13,6 +13,7 @@ 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';
16
17
  import { useAttachedMenu } from '../../internal/useAttachedMenu.js';
17
18
  import { useId } from '../../internal/useId.js';
18
19
  import { useMergedRefs } from '../../internal/useMergedRefs.js';
@@ -11,7 +11,7 @@ import { InlineLoadingStatus } from '../InlineLoading/InlineLoading';
11
11
  export declare const ModalSizes: readonly ["xs", "sm", "md", "lg"];
12
12
  export type ModalSize = (typeof ModalSizes)[number];
13
13
  export interface ModalSecondaryButton {
14
- buttonText?: string;
14
+ buttonText?: string | React.ReactNode;
15
15
  onClick?: React.MouseEventHandler<HTMLButtonElement>;
16
16
  }
17
17
  export interface ModalProps extends ReactAttr<HTMLDivElement> {
@@ -19,6 +19,7 @@ import requiredIfGivenPropIsTruthy from '../../prop-types/requiredIfGivenPropIsT
19
19
  import wrapFocus, { elementOrParentIsFloatingMenu } from '../../internal/wrapFocus.js';
20
20
  import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
21
21
  import { usePrefix } from '../../internal/usePrefix.js';
22
+ import { IconButton } from '../IconButton/index.js';
22
23
  import { noopFn } from '../../internal/noopFn.js';
23
24
  import '../Text/index.js';
24
25
  import { Text } from '../Text/Text.js';
@@ -51,7 +52,7 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
51
52
  shouldSubmitOnEnter,
52
53
  size,
53
54
  hasScrollingContent = false,
54
- closeButtonLabel,
55
+ closeButtonLabel = 'Close',
55
56
  preventCloseOnClickOutside = false,
56
57
  isFullWidth,
57
58
  launcherButtonRef,
@@ -201,19 +202,22 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
201
202
  size: 'lg'
202
203
  });
203
204
  }
204
- const modalButton = /*#__PURE__*/React__default.createElement("button", {
205
+ const modalButton = /*#__PURE__*/React__default.createElement("div", {
206
+ className: `${prefix}--modal-close-button`
207
+ }, /*#__PURE__*/React__default.createElement(IconButton, {
205
208
  className: modalCloseButtonClass,
206
- type: "button",
209
+ label: closeButtonLabel,
207
210
  onClick: onRequestClose,
208
- title: ariaLabel,
209
- "aria-label": closeButtonLabel ? closeButtonLabel : 'close',
211
+ title: closeButtonLabel,
212
+ "aria-label": closeButtonLabel,
213
+ align: "left",
210
214
  ref: button
211
215
  }, /*#__PURE__*/React__default.createElement(Close, {
212
216
  size: 20,
213
217
  "aria-hidden": "true",
214
218
  tabIndex: "-1",
215
219
  className: `${modalCloseButtonClass}__icon`
216
- }));
220
+ })));
217
221
  const modalBody = /*#__PURE__*/React__default.createElement("div", _extends({
218
222
  ref: innerModal,
219
223
  role: "dialog"
@@ -12,6 +12,7 @@ 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';
15
16
  import { useId } from '../../../internal/useId.js';
16
17
  import { usePrefix } from '../../../internal/usePrefix.js';
17
18
  import { useAttachedMenu } from '../../../internal/useAttachedMenu.js';
@@ -22,14 +22,17 @@ const SlugContent = /*#__PURE__*/React__default.forwardRef(function SlugContent(
22
22
  className
23
23
  } = _ref;
24
24
  const prefix = usePrefix();
25
+ const hasSlugActions = React__default.Children.toArray(children).some(child => child.type?.displayName === 'SlugActions');
25
26
  const slugContentClasses = cx(className, {
26
- [`${prefix}--slug-content`]: true
27
+ [`${prefix}--slug-content`]: true,
28
+ [`${prefix}--slug-content--with-actions`]: hasSlugActions
27
29
  });
28
30
  return /*#__PURE__*/React__default.createElement(ToggletipContent, {
29
31
  className: slugContentClasses,
30
32
  ref: ref
31
33
  }, children);
32
34
  });
35
+ SlugContent.displayName = 'SlugContent';
33
36
  SlugContent.propTypes = {
34
37
  /**
35
38
  * Specify the content you want rendered inside the slug ToggleTip
@@ -54,6 +57,7 @@ const SlugActions = /*#__PURE__*/React__default.forwardRef(function SlugActions(
54
57
  ref: ref
55
58
  }, children);
56
59
  });
60
+ SlugActions.displayName = 'SlugActions';
57
61
  SlugActions.propTypes = {
58
62
  /**
59
63
  * Specify the content you want rendered inside the slug callout toolbar
@@ -12,7 +12,7 @@ import React__default, { useRef, useState, useCallback, useEffect } from 'react'
12
12
  import { Popover, PopoverContent } from '../Popover/index.js';
13
13
  import { useDelayedState } from '../../internal/useDelayedState.js';
14
14
  import { useId } from '../../internal/useId.js';
15
- import { useNoInteractiveChildren, getInteractiveContent } from '../../internal/useNoInteractiveChildren.js';
15
+ import { useNoInteractiveChildren } from '../../internal/useNoInteractiveChildren.js';
16
16
  import { usePrefix } from '../../internal/usePrefix.js';
17
17
  import { match } from '../../internal/keyboard/match.js';
18
18
  import { Escape, Enter, Space } from '../../internal/keyboard/keys.js';
@@ -110,14 +110,6 @@ function Tooltip(_ref) {
110
110
  }
111
111
  }, [isPointerIntersecting, leaveDelayMs, setOpen]);
112
112
  useNoInteractiveChildren(tooltipRef, 'The Tooltip component must have no interactive content rendered by the' + '`label` or `description` prop');
113
- useEffect(() => {
114
- if (containerRef !== null && containerRef.current) {
115
- const interactiveContent = getInteractiveContent(containerRef.current);
116
- if (!interactiveContent) {
117
- setOpen(false);
118
- }
119
- }
120
- });
121
113
  useEffect(() => {
122
114
  if (isDragging) {
123
115
  // Register drag stop handlers.
@@ -22,6 +22,7 @@ const TreeNode = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
22
22
  className,
23
23
  depth,
24
24
  disabled,
25
+ id: nodeId,
25
26
  isExpanded,
26
27
  label,
27
28
  onNodeFocusEvent,
@@ -35,7 +36,7 @@ const TreeNode = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
35
36
  } = _ref;
36
37
  const {
37
38
  current: id
38
- } = useRef(rest.id || uniqueId());
39
+ } = useRef(nodeId || uniqueId());
39
40
  const [expanded, setExpanded] = useState(isExpanded);
40
41
  const currentNode = useRef(null);
41
42
  const currentNodeLabel = useRef(null);
@@ -246,7 +247,8 @@ const TreeNode = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
246
247
  });
247
248
  TreeNode.propTypes = {
248
249
  /**
249
- * The value of the active node in the tree
250
+ * **Note:** this is controlled by the parent TreeView component, do not set manually.
251
+ * The ID of the active node in the tree
250
252
  */
251
253
  active: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
252
254
  /**
@@ -258,13 +260,18 @@ TreeNode.propTypes = {
258
260
  */
259
261
  className: PropTypes.string,
260
262
  /**
261
- * TreeNode depth to determine spacing, automatically calculated by default
263
+ * * **Note:** this is controlled by the parent TreeView component, do not set manually.
264
+ * TreeNode depth to determine spacing
262
265
  */
263
266
  depth: PropTypes.number,
264
267
  /**
265
268
  * Specify if the TreeNode is disabled
266
269
  */
267
270
  disabled: PropTypes.bool,
271
+ /**
272
+ * Specify the TreeNode's ID. Must be unique in the DOM and is used for props.active and props.selected
273
+ */
274
+ id: PropTypes.string,
268
275
  /**
269
276
  * Specify if the TreeNode is expanded (only applicable to parent nodes)
270
277
  */
@@ -295,6 +302,7 @@ TreeNode.propTypes = {
295
302
  */
296
303
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
297
304
  /**
305
+ * **Note:** this is controlled by the parent TreeView component, do not set manually.
298
306
  * Array containing all selected node IDs in the tree
299
307
  */
300
308
  selected: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
@@ -192,7 +192,7 @@ function TreeView(_ref) {
192
192
  }
193
193
  TreeView.propTypes = {
194
194
  /**
195
- * Mark the active node in the tree, represented by its value
195
+ * Mark the active node in the tree, represented by its ID
196
196
  */
197
197
  active: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
198
198
  /**
@@ -148,7 +148,7 @@ class HeaderMenu extends React__default.Component {
148
148
  onKeyDown,
149
149
  ...rest
150
150
  } = this.props;
151
- const hasActiveDescendant = childrenArg => React__default.Children.toArray(childrenArg).some(child => child.props.isActive || child.props.isCurrentPage || child.props.children instanceof Array && hasActiveDescendant(child.props.children));
151
+ const hasActiveDescendant = childrenArg => React__default.Children.toArray(childrenArg).some(child => child.props && (child.props.isActive || child.props.isCurrentPage || child.props.children instanceof Array && hasActiveDescendant(child.props.children)));
152
152
  const accessibilityLabel = {
153
153
  'aria-label': ariaLabel,
154
154
  'aria-labelledby': ariaLabelledBy
@@ -23,6 +23,10 @@ interface BaseSwitcherItemProps {
23
23
  * event handlers
24
24
  */
25
25
  onKeyDown?: (event: KeyboardEvent) => void;
26
+ /**
27
+ * event handlers
28
+ */
29
+ onClick?: (event: MouseEvent) => void;
26
30
  /**
27
31
  * Specify the tab index of the Link
28
32
  */
@@ -88,6 +88,10 @@ SwitcherItem.propTypes = {
88
88
  * Specify the index of the SwitcherItem
89
89
  */
90
90
  index: PropTypes.number,
91
+ /**
92
+ * event handlers
93
+ */
94
+ onClick: PropTypes.func,
91
95
  /**
92
96
  * event handlers
93
97
  */
package/es/index.js CHANGED
@@ -60,6 +60,8 @@ 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';
63
65
  export { MenuButton } from './components/MenuButton/index.js';
64
66
  export { default as Modal } from './components/Modal/Modal.js';
65
67
  export { default as ModalWrapper } from './components/ModalWrapper/ModalWrapper.js';
@@ -139,7 +141,7 @@ export { default as SideNavSwitcher } from './components/UIShell/SideNavSwitcher
139
141
  export { default as UnorderedList } from './components/UnorderedList/UnorderedList.js';
140
142
  export { FeatureFlags as unstable_FeatureFlags, useFeatureFlag as unstable_useFeatureFlag, useFeatureFlags as unstable_useFeatureFlags } from './components/FeatureFlags/index.js';
141
143
  export { Heading, Section } from './components/Heading/index.js';
142
- export { IconButton } from './components/IconButton/index.js';
144
+ export { IconButton, IconButtonKinds } from './components/IconButton/index.js';
143
145
  export { Layer, useLayer } from './components/Layer/index.js';
144
146
  export { Layout as unstable_Layout } from './components/Layout/index.js';
145
147
  export { OverflowMenuV2 as unstable_OverflowMenuV2 } from './components/OverflowMenuV2/index.js';
@@ -212,8 +214,6 @@ export { default as TableToolbarContent } from './components/DataTable/TableTool
212
214
  export { default as TableToolbarSearch } from './components/DataTable/TableToolbarSearch.js';
213
215
  export { default as TableToolbarMenu } from './components/DataTable/TableToolbarMenu.js';
214
216
  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';
@@ -65,8 +65,6 @@ interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonElement>
65
65
  tooltipPosition?: ButtonTooltipPosition;
66
66
  }
67
67
  export type ButtonProps<T extends React.ElementType> = PolymorphicProps<T, ButtonBaseProps>;
68
- export interface ButtonComponent {
69
- <T extends React.ElementType>(props: ButtonProps<T>, context?: any): React.ReactElement<any, any> | null;
70
- }
68
+ export type ButtonComponent = <T extends React.ElementType>(props: ButtonProps<T>, context?: any) => React.ReactElement<any, any> | null;
71
69
  declare const _default: ButtonComponent;
72
70
  export default _default;
@@ -28,6 +28,12 @@ const ButtonKinds = ['primary', 'secondary', 'danger', 'ghost', 'danger--primary
28
28
  const ButtonSizes = ['sm', 'md', 'lg', 'xl', '2xl'];
29
29
  const ButtonTooltipAlignments = ['start', 'center', 'end'];
30
30
  const ButtonTooltipPositions = ['top', 'right', 'bottom', 'left'];
31
+ function isIconOnlyButton(hasIconOnly, _kind) {
32
+ if (hasIconOnly === true) {
33
+ return true;
34
+ }
35
+ return false;
36
+ }
31
37
  const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button(_ref, ref) {
32
38
  let {
33
39
  as,
@@ -60,7 +66,6 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button
60
66
  // Prevent clicks on the tooltip from triggering the button click event
61
67
  if (evt.target === tooltipRef.current) {
62
68
  evt.preventDefault();
63
- return;
64
69
  }
65
70
  };
66
71
  const buttonClasses = cx__default["default"](className, {
@@ -123,7 +128,7 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button
123
128
  component = 'a';
124
129
  otherProps = anchorProps;
125
130
  }
126
- if (!hasIconOnly) {
131
+ if (!isIconOnlyButton(hasIconOnly)) {
127
132
  return /*#__PURE__*/React__default["default"].createElement(component, {
128
133
  onMouseEnter,
129
134
  onMouseLeave,
@@ -161,7 +166,7 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button
161
166
  onFocus: onFocus,
162
167
  onBlur: onBlur,
163
168
  onClick: events.composeEventHandlers([onClick, handleClick])
164
- }, rest, commonProps, otherProps), iconOnlyImage ? iconOnlyImage : children);
169
+ }, rest, commonProps, otherProps), iconOnlyImage ?? children);
165
170
  }
166
171
  });
167
172
  Button.displayName = 'Button';
@@ -216,6 +221,7 @@ Button.propTypes = {
216
221
  /**
217
222
  * Specify the kind of Button you want to create
218
223
  */
224
+ // TODO: this should be either ButtonKinds or IconButtonKinds based on the value of "hasIconOnly"
219
225
  kind: PropTypes__default["default"].oneOf(ButtonKinds),
220
226
  /**
221
227
  * Provide an optional function to be called when the button element
@@ -18,6 +18,7 @@ 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');
21
22
  var useAttachedMenu = require('../../internal/useAttachedMenu.js');
22
23
  var useId = require('../../internal/useId.js');
23
24
  var useMergedRefs = require('../../internal/useMergedRefs.js');
@@ -15,6 +15,7 @@ var PropTypes = require('prop-types');
15
15
  var cx = require('classnames');
16
16
  var iconsReact = require('@carbon/icons-react');
17
17
  var usePrefix = require('../../internal/usePrefix.js');
18
+ var index = require('../IconButton/index.js');
18
19
 
19
20
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
21
 
@@ -55,16 +56,21 @@ const ModalHeader = /*#__PURE__*/React__default["default"].forwardRef(function M
55
56
  className: labelClass
56
57
  }, label), title && /*#__PURE__*/React__default["default"].createElement("h3", {
57
58
  className: titleClass
58
- }, title), children, /*#__PURE__*/React__default["default"].createElement("button", {
59
- onClick: handleCloseButtonClick,
59
+ }, title), children, /*#__PURE__*/React__default["default"].createElement("div", {
60
+ className: `${prefix}--modal-close-button`
61
+ }, /*#__PURE__*/React__default["default"].createElement(index.IconButton, {
60
62
  className: closeClass,
63
+ label: iconDescription,
64
+ onClick: handleCloseButtonClick,
61
65
  title: iconDescription,
62
66
  "aria-label": iconDescription,
63
- type: "button"
67
+ align: "left"
64
68
  }, /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, {
65
69
  size: 20,
70
+ "aria-hidden": "true",
71
+ tabIndex: "-1",
66
72
  className: closeIconClass
67
- })));
73
+ }))));
68
74
  });
69
75
  ModalHeader.propTypes = {
70
76
  /**
@@ -18,8 +18,8 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
18
18
 
19
19
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
20
20
 
21
- const DangerButton = props => /*#__PURE__*/React__default["default"].createElement(Button["default"], _rollupPluginBabelHelpers["extends"]({
21
+ const DangerButton = props => /*#__PURE__*/React__default["default"].createElement(Button["default"], _rollupPluginBabelHelpers["extends"]({}, props, {
22
22
  kind: "danger"
23
- }, props));
23
+ }));
24
24
 
25
25
  exports["default"] = DangerButton;
@@ -11,7 +11,7 @@ type TableExpandHeaderPropsBase = {
11
11
  /**
12
12
  * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandHeader
13
13
  */
14
- ['aria-controls']: string;
14
+ ['aria-controls']?: string;
15
15
  /**
16
16
  * @deprecated This prop has been deprecated and will be
17
17
  * removed in the next major release of Carbon. Use the
@@ -10,7 +10,7 @@ interface TableExpandRowProps extends PropsWithChildren<TableRowProps> {
10
10
  /**
11
11
  * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
12
12
  */
13
- ['aria-controls']: string;
13
+ ['aria-controls']?: string;
14
14
  /**
15
15
  * @deprecated This prop has been deprecated and will be
16
16
  * removed in the next major release of Carbon. Use the
@@ -87,7 +87,6 @@ TableExpandRow.propTypes = {
87
87
  * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
88
88
  * TODO: make this required in v12
89
89
  */
90
- /**@ts-ignore*/
91
90
  ['aria-controls']: PropTypes__default["default"].string,
92
91
  /**
93
92
  * Specify the string read by a voice reader when the expand trigger is
@@ -6,7 +6,16 @@
6
6
  */
7
7
  import { ReactNodeLike } from 'prop-types';
8
8
  import React, { type MouseEventHandler } from 'react';
9
+ import { sortStates } from './state/sorting';
9
10
  import { ReactAttr } from '../../types/common';
11
+ import { DataTableSortState } from './state/sortStates';
12
+ export type TableHeaderTranslationKey = 'carbon.table.header.icon.description';
13
+ export interface TableHeaderTranslationArgs {
14
+ header: React.ReactNode;
15
+ isSortHeader?: boolean;
16
+ sortDirection?: DataTableSortState;
17
+ sortStates: typeof sortStates;
18
+ }
10
19
  interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonElement> {
11
20
  /**
12
21
  * Pass in children that will be embedded in the table header label
@@ -58,7 +67,7 @@ interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonEl
58
67
  * choice. Translation keys are available on the `translationKeys` field for
59
68
  * this component.
60
69
  */
61
- translateWithId?: (key: string, { header, sortDirection, isSortHeader, sortStates }: {
70
+ translateWithId?: (key: TableHeaderTranslationKey, { header, sortDirection, isSortHeader, sortStates }: {
62
71
  header: any;
63
72
  sortDirection: any;
64
73
  isSortHeader: any;
@@ -16,7 +16,7 @@ import TableExpandHeader from './TableExpandHeader';
16
16
  import TableExpandRow from './TableExpandRow';
17
17
  import TableExpandedRow from './TableExpandedRow';
18
18
  import TableHead from './TableHead';
19
- import TableHeader from './TableHeader';
19
+ import TableHeader, { TableHeaderTranslationKey, TableHeaderTranslationArgs } from './TableHeader';
20
20
  import TableRow from './TableRow';
21
21
  import TableSelectAll from './TableSelectAll';
22
22
  import TableSelectRow from './TableSelectRow';
@@ -26,5 +26,6 @@ import TableToolbarAction from './TableToolbarAction';
26
26
  import TableToolbarContent from './TableToolbarContent';
27
27
  import TableToolbarSearch from './TableToolbarSearch';
28
28
  import TableToolbarMenu from './TableToolbarMenu';
29
- export { DataTable, type DataTableCell, type DataTableHeader, type DataTableProps, type DataTableRenderProps, type DataTableRow, type DataTableSize, Table, TableActionList, TableBatchAction, TableBatchActions, TableBody, TableCell, TableContainer, TableExpandHeader, TableExpandRow, TableExpandedRow, TableHead, TableHeader, TableRow, TableSelectAll, TableSelectRow, TableSlugRow, TableToolbar, TableToolbarAction, TableToolbarContent, TableToolbarSearch, TableToolbarMenu, };
29
+ import type { DataTableSortState } from './state/sortStates';
30
+ export { DataTable, type DataTableCell, type DataTableHeader, type DataTableProps, type DataTableRenderProps, type DataTableSortState, type DataTableRow, type DataTableSize, Table, TableActionList, TableBatchAction, TableBatchActions, TableBody, TableCell, TableContainer, TableExpandHeader, TableExpandRow, TableExpandedRow, TableHead, TableHeader, type TableHeaderTranslationKey, type TableHeaderTranslationArgs, TableRow, TableSelectAll, TableSelectRow, TableSlugRow, TableToolbar, TableToolbarAction, TableToolbarContent, TableToolbarSearch, TableToolbarMenu, };
30
31
  export default DataTable;