@carbon/react 1.41.2 → 1.42.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 (61) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +2194 -1863
  2. package/es/components/Breadcrumb/Breadcrumb.Skeleton.d.ts +25 -0
  3. package/es/components/Breadcrumb/Breadcrumb.d.ts +24 -0
  4. package/es/components/Breadcrumb/Breadcrumb.js +1 -2
  5. package/es/components/Breadcrumb/BreadcrumbItem.d.ts +25 -0
  6. package/es/components/Breadcrumb/BreadcrumbItem.js +8 -7
  7. package/es/components/ComboBox/ComboBox.d.ts +7 -1
  8. package/es/components/ComboBox/ComboBox.js +30 -2
  9. package/es/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
  10. package/es/components/DataTable/TableBatchAction.d.ts +46 -0
  11. package/es/components/DataTable/TableBatchAction.js +1 -2
  12. package/es/components/DataTable/TableExpandRow.d.ts +2 -46
  13. package/es/components/DataTable/TableExpandRow.js +6 -2
  14. package/es/components/Dropdown/Dropdown.d.ts +1 -1
  15. package/es/components/FluidMultiSelect/FluidMultiSelect.js +72 -9
  16. package/es/components/Notification/Notification.js +48 -6
  17. package/es/components/Tabs/Tabs.js +1 -2
  18. package/es/components/TreeView/TreeNode.js +7 -4
  19. package/es/components/UIShell/HeaderMenu.js +2 -2
  20. package/es/components/UIShell/SideNav.d.ts +1 -1
  21. package/es/components/UIShell/SideNavFooter.d.ts +52 -0
  22. package/es/components/UIShell/SideNavFooter.js +0 -1
  23. package/es/components/UIShell/SideNavItem.d.ts +24 -0
  24. package/es/components/UIShell/SideNavItem.js +2 -2
  25. package/es/components/UIShell/SideNavItems.d.ts +25 -0
  26. package/es/components/UIShell/SideNavItems.js +9 -7
  27. package/es/components/UIShell/SideNavMenu.js +4 -5
  28. package/es/components/UIShell/SideNavMenuItem.d.ts +25 -0
  29. package/es/components/UIShell/SideNavMenuItem.js +1 -2
  30. package/es/index.js +1 -1
  31. package/icons/index.d.ts +7 -0
  32. package/lib/components/Breadcrumb/Breadcrumb.Skeleton.d.ts +25 -0
  33. package/lib/components/Breadcrumb/Breadcrumb.d.ts +24 -0
  34. package/lib/components/Breadcrumb/Breadcrumb.js +1 -2
  35. package/lib/components/Breadcrumb/BreadcrumbItem.d.ts +25 -0
  36. package/lib/components/Breadcrumb/BreadcrumbItem.js +8 -7
  37. package/lib/components/ComboBox/ComboBox.d.ts +7 -1
  38. package/lib/components/ComboBox/ComboBox.js +30 -2
  39. package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
  40. package/lib/components/DataTable/TableBatchAction.d.ts +46 -0
  41. package/lib/components/DataTable/TableBatchAction.js +1 -2
  42. package/lib/components/DataTable/TableExpandRow.d.ts +2 -46
  43. package/lib/components/DataTable/TableExpandRow.js +6 -2
  44. package/lib/components/Dropdown/Dropdown.d.ts +1 -1
  45. package/lib/components/FluidMultiSelect/FluidMultiSelect.js +72 -9
  46. package/lib/components/Notification/Notification.js +48 -6
  47. package/lib/components/Tabs/Tabs.js +1 -2
  48. package/lib/components/TreeView/TreeNode.js +7 -4
  49. package/lib/components/UIShell/HeaderMenu.js +2 -2
  50. package/lib/components/UIShell/SideNav.d.ts +1 -1
  51. package/lib/components/UIShell/SideNavFooter.d.ts +52 -0
  52. package/lib/components/UIShell/SideNavFooter.js +0 -1
  53. package/lib/components/UIShell/SideNavItem.d.ts +24 -0
  54. package/lib/components/UIShell/SideNavItem.js +2 -2
  55. package/lib/components/UIShell/SideNavItems.d.ts +25 -0
  56. package/lib/components/UIShell/SideNavItems.js +9 -7
  57. package/lib/components/UIShell/SideNavMenu.js +4 -5
  58. package/lib/components/UIShell/SideNavMenuItem.d.ts +25 -0
  59. package/lib/components/UIShell/SideNavMenuItem.js +1 -2
  60. package/lib/index.js +2 -2
  61. package/package.json +8 -7
@@ -4,8 +4,7 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import PropTypes from 'prop-types';
8
- import { MouseEventHandler, PropsWithChildren } from 'react';
7
+ import React, { MouseEventHandler, PropsWithChildren } from 'react';
9
8
  import { TableRowProps } from './TableRow';
10
9
  interface TableExpandRowProps extends PropsWithChildren<TableRowProps> {
11
10
  /**
@@ -41,48 +40,5 @@ interface TableExpandRowProps extends PropsWithChildren<TableRowProps> {
41
40
  */
42
41
  onExpand: MouseEventHandler<HTMLButtonElement>;
43
42
  }
44
- declare const TableExpandRow: {
45
- ({ ["aria-controls"]: ariaControls, ["aria-label"]: ariaLabel, ariaLabel: deprecatedAriaLabel, className: rowClassName, children, isExpanded, onExpand, expandIconDescription, isSelected, expandHeader, ...rest }: TableExpandRowProps): JSX.Element;
46
- propTypes: {
47
- /**
48
- * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
49
- * TODO: make this required in v12
50
- */
51
- "aria-controls": PropTypes.Requireable<string>;
52
- /**
53
- * Specify the string read by a voice reader when the expand trigger is
54
- * focused
55
- */
56
- "aria-label": PropTypes.Requireable<string>;
57
- /**
58
- * Deprecated, please use `aria-label` instead.
59
- * Specify the string read by a voice reader when the expand trigger is
60
- * focused
61
- */
62
- ariaLabel: PropTypes.Requireable<string>;
63
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
64
- className: PropTypes.Requireable<string>;
65
- /**
66
- * The id of the matching th node in the table head. Addresses a11y concerns outlined here: https://www.ibm.com/able/guidelines/ci162/info_and_relationships.html and https://www.w3.org/TR/WCAG20-TECHS/H43
67
- */
68
- expandHeader: PropTypes.Requireable<string>;
69
- /**
70
- * The description of the chevron right icon, to be put in its SVG `<title>` element.
71
- */
72
- expandIconDescription: PropTypes.Requireable<string>;
73
- /**
74
- * Specify whether this row is expanded or not. This helps coordinate data
75
- * attributes so that `TableExpandRow` and `TableExpandedRow` work together
76
- */
77
- isExpanded: PropTypes.Validator<boolean>;
78
- /**
79
- * Specify if the row is selected
80
- */
81
- isSelected: PropTypes.Requireable<boolean>;
82
- /**
83
- * Hook for when a listener initiates a request to expand the given row
84
- */
85
- onExpand: PropTypes.Validator<(...args: any[]) => any>;
86
- };
87
- };
43
+ declare const TableExpandRow: React.ForwardRefExoticComponent<TableExpandRowProps & React.RefAttributes<HTMLTableCellElement>>;
88
44
  export default TableExpandRow;
@@ -23,7 +23,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
23
23
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
24
24
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
25
25
 
26
- const TableExpandRow = _ref => {
26
+ const TableExpandRow = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
27
27
  let {
28
28
  ['aria-controls']: ariaControls,
29
29
  ['aria-label']: ariaLabel,
@@ -45,6 +45,7 @@ const TableExpandRow = _ref => {
45
45
  }, rowClassName);
46
46
  const previousValue = isExpanded ? 'collapsed' : undefined;
47
47
  return /*#__PURE__*/React__default["default"].createElement("tr", _rollupPluginBabelHelpers["extends"]({}, rest, {
48
+ ref: ref,
48
49
  className: className,
49
50
  "data-parent-row": true
50
51
  }), /*#__PURE__*/React__default["default"].createElement(TableCell["default"], {
@@ -63,17 +64,19 @@ const TableExpandRow = _ref => {
63
64
  className: `${prefix}--table-expand__svg`,
64
65
  "aria-label": expandIconDescription
65
66
  }))), children);
66
- };
67
+ });
67
68
  TableExpandRow.propTypes = {
68
69
  /**
69
70
  * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
70
71
  * TODO: make this required in v12
71
72
  */
73
+ /**@ts-ignore*/
72
74
  ['aria-controls']: PropTypes__default["default"].string,
73
75
  /**
74
76
  * Specify the string read by a voice reader when the expand trigger is
75
77
  * focused
76
78
  */
79
+ /**@ts-ignore*/
77
80
  ['aria-label']: PropTypes__default["default"].string,
78
81
  /**
79
82
  * Deprecated, please use `aria-label` instead.
@@ -105,5 +108,6 @@ TableExpandRow.propTypes = {
105
108
  */
106
109
  onExpand: PropTypes__default["default"].func.isRequired
107
110
  };
111
+ TableExpandRow.displayName = 'TableExpandRow';
108
112
 
109
113
  exports["default"] = TableExpandRow;
@@ -101,7 +101,7 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
101
101
  * An optional callback to render the currently selected item as a react element instead of only
102
102
  * as a string.
103
103
  */
104
- renderSelectedItem?(item: ItemType): string;
104
+ renderSelectedItem?(item: ItemType): React.JSXElementConstructor<ItemType> | null;
105
105
  /**
106
106
  * In the case you want to control the dropdown selection entirely.
107
107
  */
@@ -54,22 +54,39 @@ FluidMultiSelect.propTypes = {
54
54
  */
55
55
  className: PropTypes__default["default"].string,
56
56
  /**
57
- * Specify the direction of the dropdown. Can be either top or bottom.
57
+ * Specify the text that should be read for screen readers that describes total items selected
58
+ */
59
+ clearSelectionDescription: PropTypes__default["default"].string,
60
+ /**
61
+ * Specify the text that should be read for screen readers to clear selection.
62
+ */
63
+ clearSelectionText: PropTypes__default["default"].string,
64
+ /**
65
+ * Provide a compare function that is used to determine the ordering of
66
+ * options. See 'sortItems' for more control.
67
+ */
68
+ compareItems: PropTypes__default["default"].func,
69
+ /**
70
+ * Specify the direction of the multiselect dropdown. Can be either top or bottom.
58
71
  */
59
72
  direction: PropTypes__default["default"].oneOf(['top', 'bottom']),
60
73
  /**
61
74
  * Specify whether the `<input>` should be disabled
62
75
  */
63
76
  disabled: PropTypes__default["default"].bool,
77
+ /**
78
+ * Additional props passed to Downshift
79
+ */
80
+ downshiftProps: PropTypes__default["default"].object,
64
81
  /**
65
82
  * Specify a custom `id` for the `<input>`
66
83
  */
67
84
  id: PropTypes__default["default"].string.isRequired,
68
85
  /**
69
- * Allow users to pass in an arbitrary item or a string (in case their items are an array of strings)
70
- * from their collection that are pre-selected
86
+ * Allow users to pass in arbitrary items from their collection that are
87
+ * pre-selected
71
88
  */
72
- initialSelectedItem: PropTypes__default["default"].oneOfType([PropTypes__default["default"].object, PropTypes__default["default"].string, PropTypes__default["default"].number]),
89
+ initialSelectedItems: PropTypes__default["default"].array,
73
90
  /**
74
91
  * Specify if the currently selected value is invalid.
75
92
  */
@@ -107,20 +124,62 @@ FluidMultiSelect.propTypes = {
107
124
  * this field is for
108
125
  */
109
126
  label: PropTypes__default["default"].node.isRequired,
127
+ /**
128
+ * Specify the locale of the control. Used for the default `compareItems`
129
+ * used for sorting the list of items in the control.
130
+ */
131
+ locale: PropTypes__default["default"].string,
110
132
  /**
111
133
  * `onChange` is a utility for this controlled component to communicate to a
112
134
  * consuming component what kind of internal state changes are occurring.
113
135
  */
114
136
  onChange: PropTypes__default["default"].func,
115
137
  /**
116
- * An optional callback to render the currently selected item as a react element instead of only
117
- * as a string.
138
+ * **Filterable variant only** - `onInputValueChange` is a utility for this controlled component to communicate to
139
+ * the currently typed input.
118
140
  */
119
- renderSelectedItem: PropTypes__default["default"].func,
141
+ onInputValueChange: PropTypes__default["default"].func,
120
142
  /**
121
- * In the case you want to control the dropdown selection entirely.
143
+ * `onMenuChange` is a utility for this controlled component to communicate to a
144
+ * consuming component that the menu was open(`true`)/closed(`false`).
122
145
  */
123
- selectedItem: PropTypes__default["default"].oneOfType([PropTypes__default["default"].object, PropTypes__default["default"].string, PropTypes__default["default"].number]),
146
+ onMenuChange: PropTypes__default["default"].func,
147
+ /**
148
+ * Whether or not the Multiselect is readonly
149
+ */
150
+ readOnly: PropTypes__default["default"].bool,
151
+ /**
152
+ * For full control of the selected items
153
+ */
154
+ selectedItems: PropTypes__default["default"].array,
155
+ /**
156
+ * Specify feedback (mode) of the selection.
157
+ * `top`: selected item jumps to top
158
+ * `fixed`: selected item stays at it's position
159
+ * `top-after-reopen`: selected item jump to top after reopen dropdown
160
+ */
161
+ selectionFeedback: PropTypes__default["default"].oneOf(['top', 'fixed', 'top-after-reopen']),
162
+ /**
163
+ * Provide a method that sorts all options in the control. Overriding this
164
+ * prop means that you also have to handle the sort logic for selected versus
165
+ * un-selected items. If you just want to control ordering, consider the
166
+ * `compareItems` prop instead.
167
+ *
168
+ * The return value should be a number whose sign indicates the relative order
169
+ * of the two elements: negative if a is less than b, positive if a is greater
170
+ * than b, and zero if they are equal.
171
+ *
172
+ * sortItems :
173
+ * (items: Array<Item>, {
174
+ * selectedItems: Array<Item>,
175
+ * itemToString: Item => string,
176
+ * compareItems: (itemA: string, itemB: string, {
177
+ * locale: string
178
+ * }) => number,
179
+ * locale: string,
180
+ * }) => Array<Item>
181
+ */
182
+ sortItems: PropTypes__default["default"].func,
124
183
  /**
125
184
  * Provide the title text that will be read by a screen reader when
126
185
  * visiting this control
@@ -130,6 +189,10 @@ FluidMultiSelect.propTypes = {
130
189
  * Callback function for translating ListBoxMenuIcon SVG title
131
190
  */
132
191
  translateWithId: PropTypes__default["default"].func,
192
+ /**
193
+ * Specify title to show title on hover
194
+ */
195
+ useTitleInItem: PropTypes__default["default"].bool,
133
196
  /**
134
197
  * Specify whether the control is currently in warning state
135
198
  */
@@ -23,6 +23,7 @@ var useNoInteractiveChildren = require('../../internal/useNoInteractiveChildren.
23
23
  var usePrefix = require('../../internal/usePrefix.js');
24
24
  var useId = require('../../internal/useId.js');
25
25
  var noopFn = require('../../internal/noopFn.js');
26
+ var wrapFocus = require('../../internal/wrapFocus.js');
26
27
  var Text = require('../Text/Text.js');
27
28
  var match = require('../../internal/keyboard/match.js');
28
29
  var keys = require('../../internal/keyboard/keys.js');
@@ -516,12 +517,40 @@ function ActionableNotification(_ref6) {
516
517
  [`${prefix}--actionable-notification--${kind}`]: kind,
517
518
  [`${prefix}--actionable-notification--hide-close-button`]: hideCloseButton
518
519
  });
520
+ const innerModal = React.useRef(null);
521
+ const startTrap = React.useRef(null);
522
+ const endTrap = React.useRef(null);
519
523
  const ref = React.useRef(null);
520
524
  useIsomorphicEffect["default"](() => {
521
- if (ref.current && hasFocus) {
522
- ref.current.focus();
525
+ if (hasFocus) {
526
+ const button = document.querySelector('button.cds--actionable-notification__action-button');
527
+ button?.focus();
523
528
  }
524
529
  });
530
+ function handleBlur(_ref7) {
531
+ let {
532
+ target: oldActiveNode,
533
+ relatedTarget: currentActiveNode
534
+ } = _ref7;
535
+ if (isOpen && currentActiveNode && oldActiveNode) {
536
+ const {
537
+ current: bodyNode
538
+ } = innerModal;
539
+ const {
540
+ current: startTrapNode
541
+ } = startTrap;
542
+ const {
543
+ current: endTrapNode
544
+ } = endTrap;
545
+ wrapFocus["default"]({
546
+ bodyNode,
547
+ startTrapNode,
548
+ endTrapNode,
549
+ currentActiveNode,
550
+ oldActiveNode
551
+ });
552
+ }
553
+ }
525
554
  const handleClose = evt => {
526
555
  if (!onClose || onClose(evt) !== false) {
527
556
  setIsOpen(false);
@@ -539,8 +568,14 @@ function ActionableNotification(_ref6) {
539
568
  ref: ref,
540
569
  role: role,
541
570
  className: containerClassName,
542
- "aria-labelledby": title ? id : subtitleId
543
- }), /*#__PURE__*/React__default["default"].createElement("div", {
571
+ "aria-labelledby": title ? id : subtitleId,
572
+ onBlur: handleBlur
573
+ }), /*#__PURE__*/React__default["default"].createElement("span", {
574
+ ref: startTrap,
575
+ tabIndex: 0,
576
+ role: "link",
577
+ className: `${prefix}--visually-hidden`
578
+ }, "Focus sentinel"), /*#__PURE__*/React__default["default"].createElement("div", {
544
579
  className: `${prefix}--actionable-notification__details`
545
580
  }, /*#__PURE__*/React__default["default"].createElement(NotificationIcon, {
546
581
  notificationType: inline ? 'inline' : 'toast',
@@ -558,14 +593,21 @@ function ActionableNotification(_ref6) {
558
593
  as: "div",
559
594
  className: `${prefix}--actionable-notification__subtitle`,
560
595
  id: subtitleId
561
- }, subtitle), children))), actionButtonLabel && /*#__PURE__*/React__default["default"].createElement(NotificationActionButton, {
596
+ }, subtitle), children))), /*#__PURE__*/React__default["default"].createElement("div", {
597
+ ref: innerModal
598
+ }, actionButtonLabel && /*#__PURE__*/React__default["default"].createElement(NotificationActionButton, {
562
599
  onClick: onActionButtonClick,
563
600
  inline: inline
564
601
  }, actionButtonLabel), !hideCloseButton && /*#__PURE__*/React__default["default"].createElement(NotificationButton, {
565
602
  "aria-label": deprecatedAriaLabel || ariaLabel,
566
603
  notificationType: "actionable",
567
604
  onClick: handleCloseButtonClick
568
- }));
605
+ })), /*#__PURE__*/React__default["default"].createElement("span", {
606
+ ref: endTrap,
607
+ tabIndex: 0,
608
+ role: "link",
609
+ className: `${prefix}--visually-hidden`
610
+ }, "Focus sentinel"));
569
611
  }
570
612
  ActionableNotification.propTypes = {
571
613
  /**
@@ -598,8 +598,7 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(_ref5, forwardRef) {
598
598
  }, /*#__PURE__*/React__default["default"].createElement(Icon, {
599
599
  size: 16
600
600
  })), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
601
- className: `${prefix}--tabs__nav-item-label`,
602
- title: children
601
+ className: `${prefix}--tabs__nav-item-label`
603
602
  }, children), /*#__PURE__*/React__default["default"].createElement("div", {
604
603
  className: cx__default["default"](`${prefix}--tabs__nav-item--icon`, {
605
604
  [`${prefix}--visually-hidden`]: !hasIcon
@@ -25,7 +25,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
25
25
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
26
26
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
27
27
 
28
- function TreeNode(_ref) {
28
+ const TreeNode = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
29
29
  let {
30
30
  active,
31
31
  children,
@@ -230,7 +230,8 @@ function TreeNode(_ref) {
230
230
  /*#__PURE__*/
231
231
  // eslint-disable-next-line jsx-a11y/role-supports-aria-props
232
232
  React__default["default"].createElement("li", _rollupPluginBabelHelpers["extends"]({}, treeNodeProps, {
233
- "aria-expanded": !!expanded
233
+ "aria-expanded": !!expanded,
234
+ ref: ref
234
235
  }), /*#__PURE__*/React__default["default"].createElement("div", {
235
236
  className: `${prefix}--tree-node__label`,
236
237
  ref: currentNodeLabel
@@ -249,7 +250,7 @@ function TreeNode(_ref) {
249
250
  className: `${prefix}--tree-node__children`
250
251
  }, nodesWithProps))
251
252
  );
252
- }
253
+ });
253
254
  TreeNode.propTypes = {
254
255
  /**
255
256
  * The value of the active node in the tree
@@ -309,5 +310,7 @@ TreeNode.propTypes = {
309
310
  */
310
311
  value: PropTypes__default["default"].string
311
312
  };
313
+ TreeNode.displayName = 'TreeNode';
314
+ var TreeNode$1 = TreeNode;
312
315
 
313
- exports["default"] = TreeNode;
316
+ exports["default"] = TreeNode$1;
@@ -158,7 +158,7 @@ class HeaderMenu extends React__default["default"].Component {
158
158
  onKeyDown,
159
159
  ...rest
160
160
  } = this.props;
161
- const hasActiveChildren = React__default["default"].Children.toArray(children).some(child => child.props.isActive || child.props.isCurrentPage);
161
+ const hasActiveDescendant = childrenArg => React__default["default"].Children.toArray(childrenArg).some(child => child.props.isActive || child.props.isCurrentPage || child.props.children instanceof Array && hasActiveDescendant(child.props.children));
162
162
  const accessibilityLabel = {
163
163
  'aria-label': ariaLabel,
164
164
  'aria-labelledby': ariaLabelledBy
@@ -173,7 +173,7 @@ class HeaderMenu extends React__default["default"].Component {
173
173
  [`${prefix}--header__menu-title`]: true,
174
174
  // We set the current class only if `isActive` is passed in and we do
175
175
  // not have an `aria-current="page"` set for the breadcrumb item
176
- [`${prefix}--header__menu-item--current`]: isActivePage || hasActiveChildren && !this.state.expanded
176
+ [`${prefix}--header__menu-item--current`]: isActivePage || hasActiveDescendant(children) && !this.state.expanded
177
177
  });
178
178
 
179
179
  // Notes on eslint comments and based on the examples in:
@@ -25,5 +25,5 @@ interface SideNavContextData {
25
25
  isRail?: boolean | undefined;
26
26
  }
27
27
  export declare const SideNavContext: React.Context<SideNavContextData>;
28
- declare const SideNav: React.ForwardRefExoticComponent<Pick<SideNavProps, "children" | "slot" | "style" | "title" | "className" | "dir" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "onToggle" | "key" | "id" | "aria-controls" | "aria-expanded" | "onClick" | "onAnimationEnd" | "onKeyDown" | "tabIndex" | "color" | "lang" | "role" | "href" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "expanded" | "enterDelayMs" | "defaultExpanded" | "addFocusListeners" | "isChildOfHeader" | "isFixedNav" | "isRail" | "isPersistent" | "addMouseListeners" | "onOverlayClick" | "onSideNavBlur" | "inert"> & React.RefAttributes<HTMLElement>>;
28
+ declare const SideNav: React.ForwardRefExoticComponent<Pick<SideNavProps, "children" | "slot" | "style" | "title" | "className" | "dir" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "onToggle" | "key" | "id" | "aria-controls" | "aria-expanded" | "onClick" | "onAnimationEnd" | "onKeyDown" | "tabIndex" | "color" | "lang" | "role" | "href" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "expanded" | "enterDelayMs" | "defaultExpanded" | "inert" | "addFocusListeners" | "isChildOfHeader" | "isFixedNav" | "isRail" | "isPersistent" | "addMouseListeners" | "onOverlayClick" | "onSideNavBlur"> & React.RefAttributes<HTMLElement>>;
29
29
  export default SideNav;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 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
+ import PropTypes from 'prop-types';
9
+ export interface SideNavFooterProps {
10
+ /**
11
+ * Provide text to be read to screen readers and shown as a tooltip when
12
+ * interacting with the toggle button in the footer
13
+ */
14
+ assistiveText: string;
15
+ className?: string;
16
+ /**
17
+ * Specify whether the side navigation is expanded or collapsed
18
+ */
19
+ expanded: boolean;
20
+ /**
21
+ * Provide a function that is called when the toggle button is interacted
22
+ * with. Useful for controlling the expansion state of the side navigation.
23
+ */
24
+ onToggle: (event: React.MouseEvent<HTMLButtonElement>) => void;
25
+ }
26
+ /**
27
+ * SideNavFooter is used for rendering the button at the bottom of the side
28
+ * navigation that is a part of the UI Shell. It is responsible for handling the
29
+ * user interaction to expand or collapse the side navigation.
30
+ */
31
+ declare function SideNavFooter({ assistiveText, className: customClassName, expanded, onToggle, }: SideNavFooterProps): JSX.Element;
32
+ declare namespace SideNavFooter {
33
+ var displayName: string;
34
+ var propTypes: {
35
+ /**
36
+ * Provide text to be read to screen readers and shown as a tooltip when
37
+ * interacting with the toggle button in the footer
38
+ */
39
+ assistiveText: PropTypes.Requireable<string>;
40
+ className: PropTypes.Requireable<string>;
41
+ /**
42
+ * Specify whether the side navigation is expanded or collapsed
43
+ */
44
+ expanded: PropTypes.Validator<boolean>;
45
+ /**
46
+ * Provide a function that is called when the toggle button is interacted
47
+ * with. Useful for controlling the expansion state of the side navigation.
48
+ */
49
+ onToggle: PropTypes.Validator<(...args: any[]) => any>;
50
+ };
51
+ }
52
+ export default SideNavFooter;
@@ -22,7 +22,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
22
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
23
23
 
24
24
  var _Close, _ChevronRight;
25
-
26
25
  /**
27
26
  * SideNavFooter is used for rendering the button at the bottom of the side
28
27
  * navigation that is a part of the UI Shell. It is responsible for handling the
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 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 SideNavItemProps {
9
+ /**
10
+ * Provide a single icon as the child to `SideNavItem` to render in the
11
+ * container
12
+ */
13
+ children: React.ReactNode;
14
+ /**
15
+ * Provide an optional class to be applied to the containing node
16
+ */
17
+ className?: string;
18
+ /**
19
+ * Specify if this is a large variation of the SideNavItem
20
+ */
21
+ large?: boolean;
22
+ }
23
+ declare const SideNavItem: React.FC<SideNavItemProps>;
24
+ export default SideNavItem;
@@ -20,7 +20,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
20
20
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
21
21
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
22
 
23
- function SideNavItem(_ref) {
23
+ const SideNavItem = _ref => {
24
24
  let {
25
25
  className: customClassName,
26
26
  children,
@@ -35,7 +35,7 @@ function SideNavItem(_ref) {
35
35
  return /*#__PURE__*/React__default["default"].createElement("li", {
36
36
  className: className
37
37
  }, children);
38
- }
38
+ };
39
39
  SideNavItem.propTypes = {
40
40
  /**
41
41
  * Provide a single icon as the child to `SideNavItem` to render in the
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 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 SideNavItemsProps {
9
+ /**
10
+ * Provide a single icon as the child to `SideNavIcon` to render in the
11
+ * container
12
+ */
13
+ children: React.ReactNode;
14
+ /**
15
+ * Provide an optional class to be applied to the containing node
16
+ */
17
+ className?: string;
18
+ /**
19
+ * Property to indicate if the side nav container is open (or not). Use to
20
+ * keep local state and styling in step with the SideNav expansion state.
21
+ */
22
+ isSideNavExpanded?: boolean;
23
+ }
24
+ declare const SideNavItems: React.FC<SideNavItemsProps>;
25
+ export default SideNavItems;
@@ -32,11 +32,14 @@ const SideNavItems = _ref => {
32
32
  const childrenWithExpandedState = React__default["default"].Children.map(children, child => {
33
33
  if ( /*#__PURE__*/React__default["default"].isValidElement(child)) {
34
34
  // avoid spreading `isSideNavExpanded` to non-Carbon UI Shell children
35
- return /*#__PURE__*/React__default["default"].cloneElement(child, {
36
- ...(_utils.CARBON_SIDENAV_ITEMS.includes(child.type?.displayName) ? {
37
- isSideNavExpanded
38
- } : {})
39
- });
35
+ const childType = child.type;
36
+ if (childType && childType.displayName) {
37
+ return /*#__PURE__*/React__default["default"].cloneElement(child, {
38
+ ...(_utils.CARBON_SIDENAV_ITEMS.includes(childType.displayName) ? {
39
+ isSideNavExpanded
40
+ } : {})
41
+ });
42
+ }
40
43
  }
41
44
  });
42
45
  return /*#__PURE__*/React__default["default"].createElement("ul", {
@@ -60,6 +63,5 @@ SideNavItems.propTypes = {
60
63
  */
61
64
  isSideNavExpanded: PropTypes__default["default"].bool
62
65
  };
63
- var SideNavItems$1 = SideNavItems;
64
66
 
65
- exports["default"] = SideNavItems$1;
67
+ exports["default"] = SideNavItems;
@@ -44,7 +44,7 @@ const SideNavMenu = /*#__PURE__*/React__default["default"].forwardRef(function S
44
44
  const [prevExpanded, setPrevExpanded] = React.useState(defaultExpanded);
45
45
  const className = cx__default["default"]({
46
46
  [`${prefix}--side-nav__item`]: true,
47
- [`${prefix}--side-nav__item--active`]: isActive || hasActiveChild(children) && !isExpanded,
47
+ [`${prefix}--side-nav__item--active`]: isActive || hasActiveDescendant(children) && !isExpanded,
48
48
  [`${prefix}--side-nav__item--icon`]: IconElement,
49
49
  [`${prefix}--side-nav__item--large`]: large,
50
50
  [customClassName]: !!customClassName
@@ -76,8 +76,7 @@ const SideNavMenu = /*#__PURE__*/React__default["default"].forwardRef(function S
76
76
  type: "button",
77
77
  tabIndex: tabIndex === undefined ? !isSideNavExpanded && !isRail ? -1 : 0 : tabIndex
78
78
  }, IconElement && /*#__PURE__*/React__default["default"].createElement(SideNavIcon["default"], null, /*#__PURE__*/React__default["default"].createElement(IconElement, null)), /*#__PURE__*/React__default["default"].createElement("span", {
79
- className: `${prefix}--side-nav__submenu-title`,
80
- title: title
79
+ className: `${prefix}--side-nav__submenu-title`
81
80
  }, title), /*#__PURE__*/React__default["default"].createElement(SideNavIcon["default"], {
82
81
  className: `${prefix}--side-nav__submenu-chevron`,
83
82
  small: true
@@ -137,7 +136,7 @@ SideNavMenu.propTypes = {
137
136
  Defining the children parameter with the type ReactNode | ReactNode[]. This allows for various possibilities:
138
137
  a single element, an array of elements, or null or undefined.
139
138
  **/
140
- function hasActiveChild(children) {
139
+ function hasActiveDescendant(children) {
141
140
  if (Array.isArray(children)) {
142
141
  return children.some(child => {
143
142
  if (! /*#__PURE__*/React__default["default"].isValidElement(child)) {
@@ -148,7 +147,7 @@ function hasActiveChild(children) {
148
147
  safety when accessing their props.
149
148
  **/
150
149
  const props = child.props;
151
- if (props.isActive === true || props['aria-current']) {
150
+ if (props.isActive === true || props['aria-current'] || props.children instanceof Array && hasActiveDescendant(props.children)) {
152
151
  return true;
153
152
  }
154
153
  return false;