@carbon/react 1.41.2 → 1.42.0-rc.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 (53) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +682 -614
  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/Tabs/Tabs.js +1 -2
  16. package/es/components/TreeView/TreeNode.js +7 -4
  17. package/es/components/UIShell/HeaderMenu.js +2 -2
  18. package/es/components/UIShell/SideNav.d.ts +1 -1
  19. package/es/components/UIShell/SideNavFooter.d.ts +52 -0
  20. package/es/components/UIShell/SideNavFooter.js +0 -1
  21. package/es/components/UIShell/SideNavItem.d.ts +24 -0
  22. package/es/components/UIShell/SideNavItem.js +2 -2
  23. package/es/components/UIShell/SideNavMenu.js +4 -5
  24. package/es/components/UIShell/SideNavMenuItem.d.ts +25 -0
  25. package/es/components/UIShell/SideNavMenuItem.js +1 -2
  26. package/es/index.js +1 -1
  27. package/icons/index.d.ts +7 -0
  28. package/lib/components/Breadcrumb/Breadcrumb.Skeleton.d.ts +25 -0
  29. package/lib/components/Breadcrumb/Breadcrumb.d.ts +24 -0
  30. package/lib/components/Breadcrumb/Breadcrumb.js +1 -2
  31. package/lib/components/Breadcrumb/BreadcrumbItem.d.ts +25 -0
  32. package/lib/components/Breadcrumb/BreadcrumbItem.js +8 -7
  33. package/lib/components/ComboBox/ComboBox.d.ts +7 -1
  34. package/lib/components/ComboBox/ComboBox.js +30 -2
  35. package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
  36. package/lib/components/DataTable/TableBatchAction.d.ts +46 -0
  37. package/lib/components/DataTable/TableBatchAction.js +1 -2
  38. package/lib/components/DataTable/TableExpandRow.d.ts +2 -46
  39. package/lib/components/DataTable/TableExpandRow.js +6 -2
  40. package/lib/components/Dropdown/Dropdown.d.ts +1 -1
  41. package/lib/components/Tabs/Tabs.js +1 -2
  42. package/lib/components/TreeView/TreeNode.js +7 -4
  43. package/lib/components/UIShell/HeaderMenu.js +2 -2
  44. package/lib/components/UIShell/SideNav.d.ts +1 -1
  45. package/lib/components/UIShell/SideNavFooter.d.ts +52 -0
  46. package/lib/components/UIShell/SideNavFooter.js +0 -1
  47. package/lib/components/UIShell/SideNavItem.d.ts +24 -0
  48. package/lib/components/UIShell/SideNavItem.js +2 -2
  49. package/lib/components/UIShell/SideNavMenu.js +4 -5
  50. package/lib/components/UIShell/SideNavMenuItem.d.ts +25 -0
  51. package/lib/components/UIShell/SideNavMenuItem.js +1 -2
  52. package/lib/index.js +2 -2
  53. package/package.json +8 -7
@@ -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 PropTypes from 'prop-types';
8
+ import React from 'react';
9
+ export interface BreadcrumbSkeletonProps extends React.HTMLAttributes<HTMLDivElement> {
10
+ /**
11
+ * Specify an optional className to add.
12
+ */
13
+ className?: string;
14
+ }
15
+ declare function BreadcrumbSkeleton({ className, ...rest }: BreadcrumbSkeletonProps): JSX.Element;
16
+ declare namespace BreadcrumbSkeleton {
17
+ var propTypes: {
18
+ /**
19
+ * Specify an optional className to add.
20
+ */
21
+ className: PropTypes.Requireable<string>;
22
+ };
23
+ }
24
+ export default BreadcrumbSkeleton;
25
+ export { BreadcrumbSkeleton };
@@ -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
+ import { ForwardRefReturn } from '../../types/common';
9
+ export interface BreadcrumbProps extends React.HTMLAttributes<HTMLElement> {
10
+ /**
11
+ * Specify the label for the breadcrumb container
12
+ */
13
+ 'aria-label'?: string;
14
+ /**
15
+ * Specify an optional className to be applied to the container node
16
+ */
17
+ className?: string;
18
+ /**
19
+ * Optional prop to omit the trailing slash for the breadcrumbs
20
+ */
21
+ noTrailingSlash?: boolean;
22
+ }
23
+ declare const Breadcrumb: ForwardRefReturn<HTMLElement, BreadcrumbProps>;
24
+ export default Breadcrumb;
@@ -51,6 +51,5 @@ Breadcrumb.propTypes = {
51
51
  */
52
52
  noTrailingSlash: PropTypes.bool
53
53
  };
54
- var Breadcrumb$1 = Breadcrumb;
55
54
 
56
- export { Breadcrumb$1 as default };
55
+ export { Breadcrumb as default };
@@ -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, { AriaAttributes } from 'react';
8
+ import { ForwardRefReturn } from '../../types/common';
9
+ export interface BreadcrumbItemProps extends React.HTMLAttributes<HTMLLIElement> {
10
+ 'aria-current'?: AriaAttributes['aria-current'];
11
+ /**
12
+ * Specify an optional className to be applied to the container node
13
+ */
14
+ className?: string;
15
+ /**
16
+ * Optional string representing the link location for the BreadcrumbItem
17
+ */
18
+ href?: string;
19
+ /**
20
+ * Provide if this breadcrumb item represents the current page
21
+ */
22
+ isCurrentPage?: boolean;
23
+ }
24
+ declare const BreadcrumbItem: ForwardRefReturn<HTMLLIElement, BreadcrumbItemProps>;
25
+ export default BreadcrumbItem;
@@ -19,7 +19,7 @@ const BreadcrumbItem = /*#__PURE__*/React__default.forwardRef(function Breadcrum
19
19
  let {
20
20
  'aria-current': ariaCurrent,
21
21
  children,
22
- className: customClassName,
22
+ className: customClassName = '',
23
23
  href,
24
24
  isCurrentPage,
25
25
  ...rest
@@ -32,13 +32,14 @@ const BreadcrumbItem = /*#__PURE__*/React__default.forwardRef(function Breadcrum
32
32
  [`${prefix}--breadcrumb-item--current`]: isCurrentPage && ariaCurrent !== 'page',
33
33
  [customClassName]: !!customClassName
34
34
  });
35
- if (children.type && children.type.displayName !== undefined && children.type.displayName.includes('OverflowMenu')) {
35
+ const child = children;
36
+ if (child.type && child.type.displayName !== undefined && child.type.displayName.includes('OverflowMenu')) {
36
37
  const horizontalOverflowIcon = /*#__PURE__*/React__default.createElement(OverflowMenuHorizontal, {
37
38
  className: `${prefix}--overflow-menu__icon`
38
39
  });
39
40
  return /*#__PURE__*/React__default.createElement("li", _extends({
40
41
  className: className
41
- }, rest), /*#__PURE__*/React__default.cloneElement(children, {
42
+ }, rest), /*#__PURE__*/React__default.cloneElement(child, {
42
43
  menuOptionsClass: `${prefix}--breadcrumb-menu-options`,
43
44
  menuOffset: {
44
45
  top: 10,
@@ -61,13 +62,14 @@ const BreadcrumbItem = /*#__PURE__*/React__default.forwardRef(function Breadcrum
61
62
  return /*#__PURE__*/React__default.createElement("li", _extends({
62
63
  className: className,
63
64
  ref: ref
64
- }, rest), /*#__PURE__*/React__default.cloneElement(children, {
65
+ }, rest), /*#__PURE__*/React__default.cloneElement(child, {
65
66
  'aria-current': ariaCurrent,
66
- className: cx(`${prefix}--link`, children.props.className)
67
+ className: cx(`${prefix}--link`, child.props.className)
67
68
  }));
68
69
  });
69
70
  BreadcrumbItem.displayName = 'BreadcrumbItem';
70
71
  BreadcrumbItem.propTypes = {
72
+ // @ts-expect-error - v12 TODO: BREAKING: This should match AriaAttributes['aria-current']
71
73
  'aria-current': PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
72
74
  /**
73
75
  * Pass in content that will be inside of the BreadcrumbItem
@@ -86,6 +88,5 @@ BreadcrumbItem.propTypes = {
86
88
  */
87
89
  isCurrentPage: PropTypes.bool
88
90
  };
89
- var BreadcrumbItem$1 = BreadcrumbItem;
90
91
 
91
- export { BreadcrumbItem$1 as default };
92
+ export { BreadcrumbItem as default };
@@ -9,10 +9,16 @@ import { type ComponentProps, type ReactNode, type ComponentType, type ReactElem
9
9
  import { ListBoxSize } from '../ListBox';
10
10
  type ExcludedAttributes = 'id' | 'onChange' | 'onClick' | 'type' | 'size';
11
11
  interface OnChangeData<ItemType> {
12
- selectedItem: ItemType | null;
12
+ selectedItem: ItemType | null | undefined;
13
+ inputValue?: string | null;
13
14
  }
14
15
  type ItemToStringHandler<ItemType> = (item: ItemType | null) => string;
15
16
  export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
17
+ /**
18
+ * Specify whether or not the ComboBox should allow a value that is
19
+ * not in the list to be entered in the input
20
+ */
21
+ allowCustomValue?: boolean;
16
22
  /**
17
23
  * Specify a label to be read by screen readers on the container node
18
24
  * 'aria-label' of the ListBox component.
@@ -32,7 +32,8 @@ const {
32
32
  keyDownEscape,
33
33
  clickButton,
34
34
  blurButton,
35
- changeInput
35
+ changeInput,
36
+ blurInput
36
37
  } = Downshift.stateChangeTypes;
37
38
  const defaultItemToString = item => {
38
39
  if (typeof item === 'string') {
@@ -110,6 +111,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
110
111
  translateWithId,
111
112
  warn,
112
113
  warnText,
114
+ allowCustomValue = false,
113
115
  ...rest
114
116
  } = props;
115
117
  const prefix = usePrefix();
@@ -204,6 +206,17 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
204
206
  case changeInput:
205
207
  updateHighlightedIndex(getHighlightedIndex(changes));
206
208
  break;
209
+ case blurInput:
210
+ if (allowCustomValue) {
211
+ setInputValue(inputValue);
212
+ if (onChange) {
213
+ onChange({
214
+ selectedItem,
215
+ inputValue
216
+ });
217
+ }
218
+ }
219
+ break;
207
220
  }
208
221
  };
209
222
  const handleToggleClick = isOpen => event => {
@@ -302,8 +315,18 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
302
315
  if (match(event, Space)) {
303
316
  event.stopPropagation();
304
317
  }
305
- if (match(event, Enter) && !inputValue) {
318
+ if (match(event, Enter) && (!inputValue || allowCustomValue)) {
306
319
  toggleMenu();
320
+
321
+ // Since `onChange` does not normally fire when the menu is closed, we should
322
+ // manually fire it when `allowCustomValue` is provided, the menu is closing,
323
+ // and there is a value.
324
+ if (allowCustomValue && isOpen && inputValue) {
325
+ onChange({
326
+ selectedItem,
327
+ inputValue
328
+ });
329
+ }
307
330
  }
308
331
  if (match(event, Escape) && inputValue) {
309
332
  if (event.target === textInput.current && isOpen) {
@@ -411,6 +434,11 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
411
434
  });
412
435
  ComboBox.displayName = 'ComboBox';
413
436
  ComboBox.propTypes = {
437
+ /**
438
+ * Specify whether or not the ComboBox should allow a value that is
439
+ * not in the list to be entered in the input
440
+ */
441
+ allowCustomValue: PropTypes.bool,
414
442
  /**
415
443
  * 'aria-label' of the ListBox component.
416
444
  * Specify a label to be read by screen readers on the container node
@@ -40,7 +40,7 @@ export interface ContentSwitcherProps extends Omit<HTMLAttributes<HTMLElement>,
40
40
  /**
41
41
  * Choose whether or not to automatically change selection on focus
42
42
  */
43
- selectionMode: 'automatic' | 'manual';
43
+ selectionMode?: 'automatic' | 'manual';
44
44
  /**
45
45
  * Specify the size of the Content Switcher. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
46
46
  */
@@ -0,0 +1,46 @@
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 PropTypes from 'prop-types';
8
+ import React from 'react';
9
+ export interface TableBatchActionProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
10
+ /**
11
+ * Specify if the button is an icon-only button
12
+ */
13
+ hasIconOnly?: boolean;
14
+ /**
15
+ * If specifying the `renderIcon` prop, provide a description for that icon that can
16
+ * be read by screen readers
17
+ */
18
+ iconDescription?: string;
19
+ /**
20
+ * Optional function to render your own icon in the underlying button
21
+ */
22
+ renderIcon?: React.ElementType;
23
+ }
24
+ declare const TableBatchAction: {
25
+ ({ renderIcon, iconDescription, ...props }: {
26
+ [x: string]: any;
27
+ renderIcon?: import("@carbon/icons-react/lib/CarbonIcon").CarbonIconType | undefined;
28
+ iconDescription?: string | undefined;
29
+ }): JSX.Element;
30
+ propTypes: {
31
+ /**
32
+ * Specify if the button is an icon-only button
33
+ */
34
+ hasIconOnly: PropTypes.Requireable<boolean>;
35
+ /**
36
+ * If specifying the `renderIcon` prop, provide a description for that icon that can
37
+ * be read by screen readers
38
+ */
39
+ iconDescription: (props: any) => Error | undefined;
40
+ /**
41
+ * Optional function to render your own icon in the underlying button
42
+ */
43
+ renderIcon: PropTypes.Requireable<object>;
44
+ };
45
+ };
46
+ export default TableBatchAction;
@@ -43,6 +43,5 @@ TableBatchAction.propTypes = {
43
43
  */
44
44
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
45
45
  };
46
- var TableBatchAction$1 = TableBatchAction;
47
46
 
48
- export { TableBatchAction$1 as default };
47
+ export { TableBatchAction as default };
@@ -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;
@@ -13,7 +13,7 @@ import { ChevronRight } from '@carbon/icons-react';
13
13
  import TableCell from './TableCell.js';
14
14
  import { usePrefix } from '../../internal/usePrefix.js';
15
15
 
16
- const TableExpandRow = _ref => {
16
+ const TableExpandRow = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
17
17
  let {
18
18
  ['aria-controls']: ariaControls,
19
19
  ['aria-label']: ariaLabel,
@@ -35,6 +35,7 @@ const TableExpandRow = _ref => {
35
35
  }, rowClassName);
36
36
  const previousValue = isExpanded ? 'collapsed' : undefined;
37
37
  return /*#__PURE__*/React__default.createElement("tr", _extends({}, rest, {
38
+ ref: ref,
38
39
  className: className,
39
40
  "data-parent-row": true
40
41
  }), /*#__PURE__*/React__default.createElement(TableCell, {
@@ -53,17 +54,19 @@ const TableExpandRow = _ref => {
53
54
  className: `${prefix}--table-expand__svg`,
54
55
  "aria-label": expandIconDescription
55
56
  }))), children);
56
- };
57
+ });
57
58
  TableExpandRow.propTypes = {
58
59
  /**
59
60
  * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
60
61
  * TODO: make this required in v12
61
62
  */
63
+ /**@ts-ignore*/
62
64
  ['aria-controls']: PropTypes.string,
63
65
  /**
64
66
  * Specify the string read by a voice reader when the expand trigger is
65
67
  * focused
66
68
  */
69
+ /**@ts-ignore*/
67
70
  ['aria-label']: PropTypes.string,
68
71
  /**
69
72
  * Deprecated, please use `aria-label` instead.
@@ -95,5 +98,6 @@ TableExpandRow.propTypes = {
95
98
  */
96
99
  onExpand: PropTypes.func.isRequired
97
100
  };
101
+ TableExpandRow.displayName = 'TableExpandRow';
98
102
 
99
103
  export { TableExpandRow as default };
@@ -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
  */
@@ -587,8 +587,7 @@ const Tab = /*#__PURE__*/forwardRef(function Tab(_ref5, forwardRef) {
587
587
  }, /*#__PURE__*/React__default.createElement(Icon, {
588
588
  size: 16
589
589
  })), /*#__PURE__*/React__default.createElement(Text, {
590
- className: `${prefix}--tabs__nav-item-label`,
591
- title: children
590
+ className: `${prefix}--tabs__nav-item-label`
592
591
  }, children), /*#__PURE__*/React__default.createElement("div", {
593
592
  className: cx(`${prefix}--tabs__nav-item--icon`, {
594
593
  [`${prefix}--visually-hidden`]: !hasIcon
@@ -15,7 +15,7 @@ import { usePrefix } from '../../internal/usePrefix.js';
15
15
  import { matches, match } from '../../internal/keyboard/match.js';
16
16
  import { ArrowLeft, ArrowRight, Enter, Space } from '../../internal/keyboard/keys.js';
17
17
 
18
- function TreeNode(_ref) {
18
+ const TreeNode = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
19
19
  let {
20
20
  active,
21
21
  children,
@@ -220,7 +220,8 @@ function TreeNode(_ref) {
220
220
  /*#__PURE__*/
221
221
  // eslint-disable-next-line jsx-a11y/role-supports-aria-props
222
222
  React__default.createElement("li", _extends({}, treeNodeProps, {
223
- "aria-expanded": !!expanded
223
+ "aria-expanded": !!expanded,
224
+ ref: ref
224
225
  }), /*#__PURE__*/React__default.createElement("div", {
225
226
  className: `${prefix}--tree-node__label`,
226
227
  ref: currentNodeLabel
@@ -239,7 +240,7 @@ function TreeNode(_ref) {
239
240
  className: `${prefix}--tree-node__children`
240
241
  }, nodesWithProps))
241
242
  );
242
- }
243
+ });
243
244
  TreeNode.propTypes = {
244
245
  /**
245
246
  * The value of the active node in the tree
@@ -299,5 +300,7 @@ TreeNode.propTypes = {
299
300
  */
300
301
  value: PropTypes.string
301
302
  };
303
+ TreeNode.displayName = 'TreeNode';
304
+ var TreeNode$1 = TreeNode;
302
305
 
303
- export { TreeNode as default };
306
+ export { TreeNode$1 as default };
@@ -148,7 +148,7 @@ class HeaderMenu extends React__default.Component {
148
148
  onKeyDown,
149
149
  ...rest
150
150
  } = this.props;
151
- const hasActiveChildren = React__default.Children.toArray(children).some(child => child.props.isActive || child.props.isCurrentPage);
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));
152
152
  const accessibilityLabel = {
153
153
  'aria-label': ariaLabel,
154
154
  'aria-labelledby': ariaLabelledBy
@@ -163,7 +163,7 @@ class HeaderMenu extends React__default.Component {
163
163
  [`${prefix}--header__menu-title`]: true,
164
164
  // We set the current class only if `isActive` is passed in and we do
165
165
  // not have an `aria-current="page"` set for the breadcrumb item
166
- [`${prefix}--header__menu-item--current`]: isActivePage || hasActiveChildren && !this.state.expanded
166
+ [`${prefix}--header__menu-item--current`]: isActivePage || hasActiveDescendant(children) && !this.state.expanded
167
167
  });
168
168
 
169
169
  // 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;
@@ -12,7 +12,6 @@ import PropTypes from 'prop-types';
12
12
  import { usePrefix } from '../../internal/usePrefix.js';
13
13
 
14
14
  var _Close, _ChevronRight;
15
-
16
15
  /**
17
16
  * SideNavFooter is used for rendering the button at the bottom of the side
18
17
  * 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;
@@ -10,7 +10,7 @@ import PropTypes from 'prop-types';
10
10
  import React__default from 'react';
11
11
  import { usePrefix } from '../../internal/usePrefix.js';
12
12
 
13
- function SideNavItem(_ref) {
13
+ const SideNavItem = _ref => {
14
14
  let {
15
15
  className: customClassName,
16
16
  children,
@@ -25,7 +25,7 @@ function SideNavItem(_ref) {
25
25
  return /*#__PURE__*/React__default.createElement("li", {
26
26
  className: className
27
27
  }, children);
28
- }
28
+ };
29
29
  SideNavItem.propTypes = {
30
30
  /**
31
31
  * Provide a single icon as the child to `SideNavItem` to render in the
@@ -34,7 +34,7 @@ const SideNavMenu = /*#__PURE__*/React__default.forwardRef(function SideNavMenu(
34
34
  const [prevExpanded, setPrevExpanded] = useState(defaultExpanded);
35
35
  const className = cx({
36
36
  [`${prefix}--side-nav__item`]: true,
37
- [`${prefix}--side-nav__item--active`]: isActive || hasActiveChild(children) && !isExpanded,
37
+ [`${prefix}--side-nav__item--active`]: isActive || hasActiveDescendant(children) && !isExpanded,
38
38
  [`${prefix}--side-nav__item--icon`]: IconElement,
39
39
  [`${prefix}--side-nav__item--large`]: large,
40
40
  [customClassName]: !!customClassName
@@ -66,8 +66,7 @@ const SideNavMenu = /*#__PURE__*/React__default.forwardRef(function SideNavMenu(
66
66
  type: "button",
67
67
  tabIndex: tabIndex === undefined ? !isSideNavExpanded && !isRail ? -1 : 0 : tabIndex
68
68
  }, IconElement && /*#__PURE__*/React__default.createElement(SideNavIcon, null, /*#__PURE__*/React__default.createElement(IconElement, null)), /*#__PURE__*/React__default.createElement("span", {
69
- className: `${prefix}--side-nav__submenu-title`,
70
- title: title
69
+ className: `${prefix}--side-nav__submenu-title`
71
70
  }, title), /*#__PURE__*/React__default.createElement(SideNavIcon, {
72
71
  className: `${prefix}--side-nav__submenu-chevron`,
73
72
  small: true
@@ -127,7 +126,7 @@ SideNavMenu.propTypes = {
127
126
  Defining the children parameter with the type ReactNode | ReactNode[]. This allows for various possibilities:
128
127
  a single element, an array of elements, or null or undefined.
129
128
  **/
130
- function hasActiveChild(children) {
129
+ function hasActiveDescendant(children) {
131
130
  if (Array.isArray(children)) {
132
131
  return children.some(child => {
133
132
  if (! /*#__PURE__*/React__default.isValidElement(child)) {
@@ -138,7 +137,7 @@ function hasActiveChild(children) {
138
137
  safety when accessing their props.
139
138
  **/
140
139
  const props = child.props;
141
- if (props.isActive === true || props['aria-current']) {
140
+ if (props.isActive === true || props['aria-current'] || props.children instanceof Array && hasActiveDescendant(props.children)) {
142
141
  return true;
143
142
  }
144
143
  return false;