@carbon/react 1.39.0 → 1.40.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.
@@ -24,6 +24,7 @@ const TableSelectAll = _ref => {
24
24
  } = _ref;
25
25
  const prefix = usePrefix();
26
26
  return /*#__PURE__*/React__default.createElement("th", {
27
+ "aria-live": "off",
27
28
  scope: "col",
28
29
  className: cx(`${prefix}--table-column-checkbox`, className)
29
30
  }, /*#__PURE__*/React__default.createElement(InlineCheckbox, {
@@ -42,7 +42,8 @@ const TableSelectRow = _ref => {
42
42
  [`${prefix}--table-column-radio`]: radio
43
43
  });
44
44
  return /*#__PURE__*/React__default.createElement("td", {
45
- className: tableSelectRowClasses
45
+ className: tableSelectRowClasses,
46
+ "aria-live": "off"
46
47
  }, /*#__PURE__*/React__default.createElement(InlineInputComponent, _extends({}, selectionInputProps, radio && {
47
48
  labelText: ariaLabel,
48
49
  hideLabel: true
@@ -28,6 +28,10 @@ export interface FileUploaderItemProps extends ReactAttr<HTMLSpanElement> {
28
28
  * Name of the uploaded file
29
29
  */
30
30
  name?: string;
31
+ /**
32
+ * Event handler that is called after files are added to the uploader
33
+ */
34
+ onAddFiles?: (event: React.ChangeEvent<HTMLInputElement>) => void;
31
35
  /**
32
36
  * Event handler that is called after removing a file from the file uploader
33
37
  * The event handler signature looks like `onDelete(evt, { uuid })`
@@ -8,10 +8,12 @@
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import cx from 'classnames';
10
10
  import PropTypes from 'prop-types';
11
- import React__default, { useRef } from 'react';
11
+ import React__default, { useState, useRef, useLayoutEffect } from 'react';
12
12
  import Filename from './Filename.js';
13
13
  import uniqueId from '../../tools/uniqueId.js';
14
14
  import { usePrefix } from '../../internal/usePrefix.js';
15
+ import '../Tooltip/DefinitionTooltip.js';
16
+ import { Tooltip } from '../Tooltip/Tooltip.js';
15
17
  import { matches } from '../../internal/keyboard/match.js';
16
18
  import { Enter, Space } from '../../internal/keyboard/keys.js';
17
19
 
@@ -28,6 +30,7 @@ function FileUploaderItem(_ref) {
28
30
  size,
29
31
  ...other
30
32
  } = _ref;
33
+ const [isEllipsisApplied, setIsEllipsisApplied] = useState(false);
31
34
  const prefix = usePrefix();
32
35
  const {
33
36
  current: id
@@ -37,13 +40,37 @@ function FileUploaderItem(_ref) {
37
40
  [`${prefix}--file__selected-file--md`]: size === 'md',
38
41
  [`${prefix}--file__selected-file--sm`]: size === 'sm'
39
42
  });
43
+ const isInvalid = invalid ? `${prefix}--file-filename-container-wrap-invalid` : `${prefix}--file-filename-container-wrap`;
44
+ const isEllipsisActive = element => {
45
+ setIsEllipsisApplied(element.offsetWidth < element.scrollWidth);
46
+ return element.offsetWidth < element.scrollWidth;
47
+ };
48
+ useLayoutEffect(() => {
49
+ const element = document.querySelector(`[title="${name}"]`);
50
+ isEllipsisActive(element);
51
+ }, [prefix, name]);
40
52
  return /*#__PURE__*/React__default.createElement("span", _extends({
41
53
  className: classes
42
- }, other), /*#__PURE__*/React__default.createElement("p", {
43
- className: `${prefix}--file-filename`,
54
+ }, other), isEllipsisApplied ? /*#__PURE__*/React__default.createElement("div", {
55
+ className: isInvalid
56
+ }, /*#__PURE__*/React__default.createElement(Tooltip, {
57
+ label: name,
58
+ align: "bottom",
59
+ className: `${prefix}--file-filename-tooltip`
60
+ }, /*#__PURE__*/React__default.createElement("button", {
61
+ className: `${prefix}--file-filename-button`,
62
+ type: "button"
63
+ }, /*#__PURE__*/React__default.createElement("p", {
64
+ title: name,
65
+ className: `${prefix}--file-filename-button`,
66
+ id: name
67
+ }, name)))) : /*#__PURE__*/React__default.createElement("p", {
44
68
  title: name,
69
+ className: `${prefix}--file-filename`,
45
70
  id: name
46
- }, name), /*#__PURE__*/React__default.createElement("span", {
71
+ }, name), /*#__PURE__*/React__default.createElement("div", {
72
+ className: `${prefix}--file-container-item`
73
+ }, /*#__PURE__*/React__default.createElement("span", {
47
74
  className: `${prefix}--file__state-container`
48
75
  }, /*#__PURE__*/React__default.createElement(Filename, {
49
76
  name: name,
@@ -68,7 +95,7 @@ function FileUploaderItem(_ref) {
68
95
  });
69
96
  }
70
97
  }
71
- })), invalid && errorSubject && /*#__PURE__*/React__default.createElement("div", {
98
+ }))), invalid && errorSubject && /*#__PURE__*/React__default.createElement("div", {
72
99
  className: `${prefix}--form-requirement`,
73
100
  role: "alert",
74
101
  id: `${name}-id-error`
@@ -28,7 +28,8 @@ function Filename(_ref) {
28
28
  return /*#__PURE__*/React__default.createElement(Loading, {
29
29
  description: iconDescription,
30
30
  small: true,
31
- withOverlay: false
31
+ withOverlay: false,
32
+ className: `${prefix}--file-loading`
32
33
  });
33
34
  case 'edit':
34
35
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, invalid && /*#__PURE__*/React__default.createElement(WarningFilled, {
@@ -125,7 +125,7 @@ const Search = /*#__PURE__*/React__default.forwardRef(function Search(_ref, forw
125
125
  className: `${prefix}--search-magnifier`,
126
126
  onClick: onExpand,
127
127
  onKeyDown: handleExpandButtonKeyDown,
128
- tabIndex: onExpand && !isExpanded ? 1 : -1,
128
+ tabIndex: onExpand && !isExpanded ? 0 : -1,
129
129
  ref: expandButtonRef,
130
130
  "aria-expanded": onExpand && isExpanded ? true : undefined,
131
131
  "aria-controls": onExpand ? uniqueId : undefined
@@ -0,0 +1,26 @@
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 { ReactNode } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ export interface SideNavLinkTextProps {
10
+ children: ReactNode;
11
+ className?: string;
12
+ }
13
+ declare function SideNavLinkText({ className: customClassName, children, ...rest }: SideNavLinkTextProps): JSX.Element;
14
+ declare namespace SideNavLinkText {
15
+ var propTypes: {
16
+ /**
17
+ * Provide the content for the link text
18
+ */
19
+ children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
20
+ /**
21
+ * Provide an optional class to be applied to the containing node
22
+ */
23
+ className: PropTypes.Requireable<string>;
24
+ };
25
+ }
26
+ export default SideNavLinkText;
@@ -7,9 +7,9 @@
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import cx from 'classnames';
10
- import PropTypes from 'prop-types';
11
10
  import React__default from 'react';
12
11
  import { usePrefix } from '../../internal/usePrefix.js';
12
+ import PropTypes from 'prop-types';
13
13
 
14
14
  function SideNavLinkText(_ref) {
15
15
  let {
@@ -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 React from 'react';
8
+ interface SideNavMenuProps {
9
+ /**
10
+ * An optional CSS class to apply to the component.
11
+ */
12
+ className?: string;
13
+ /**
14
+ * The content to render within the SideNavMenu component.
15
+ */
16
+ children?: React.ReactNode;
17
+ /**
18
+ * Specifies whether the menu should be expanded by default.
19
+ */
20
+ defaultExpanded?: boolean;
21
+ /**
22
+ * Indicates whether the SideNavMenu is active.
23
+ */
24
+ isActive?: boolean;
25
+ /**
26
+ * Specifies whether the SideNavMenu is in a large variation.
27
+ */
28
+ large?: boolean;
29
+ /**
30
+ * A custom icon to render next to the SideNavMenu title. This can be a function returning JSX or JSX itself.
31
+ */
32
+ renderIcon?: React.ComponentType;
33
+ /**
34
+ * Indicates if the side navigation container is expanded or collapsed.
35
+ */
36
+ isSideNavExpanded?: boolean;
37
+ /**
38
+ * The tabIndex for the button element.
39
+ * If not specified, the default validation will be applied.
40
+ */
41
+ tabIndex?: number;
42
+ title: string;
43
+ }
44
+ declare const SideNavMenu: React.ForwardRefExoticComponent<SideNavMenuProps & React.RefAttributes<HTMLElement>>;
45
+ export default SideNavMenu;
46
+ export { SideNavMenu };
@@ -16,8 +16,8 @@ import { match } from '../../internal/keyboard/match.js';
16
16
  import { Escape } from '../../internal/keyboard/keys.js';
17
17
 
18
18
  var _ChevronDown;
19
- const SideNavMenu = /*#__PURE__*/React__default.forwardRef(function SideNavMenu(props, ref) {
20
- const {
19
+ const SideNavMenu = /*#__PURE__*/React__default.forwardRef(function SideNavMenu(_ref, ref) {
20
+ let {
21
21
  className: customClassName,
22
22
  children,
23
23
  defaultExpanded = false,
@@ -27,7 +27,7 @@ const SideNavMenu = /*#__PURE__*/React__default.forwardRef(function SideNavMenu(
27
27
  isSideNavExpanded,
28
28
  tabIndex,
29
29
  title
30
- } = props;
30
+ } = _ref;
31
31
  const isRail = useContext(SideNavContext);
32
32
  const prefix = usePrefix();
33
33
  const [isExpanded, setIsExpanded] = useState(defaultExpanded);
@@ -111,6 +111,7 @@ SideNavMenu.propTypes = {
111
111
  /**
112
112
  * Pass in a custom icon to render next to the `SideNavMenu` title
113
113
  */
114
+ // @ts-expect-error - PropTypes are unable to cover this case.
114
115
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
115
116
  /**
116
117
  * Optional prop to specify the tabIndex of the button. If undefined, it will be applied default validation
@@ -121,29 +122,38 @@ SideNavMenu.propTypes = {
121
122
  */
122
123
  title: PropTypes.string.isRequired
123
124
  };
125
+
126
+ /**
127
+ Defining the children parameter with the type ReactNode | ReactNode[]. This allows for various possibilities:
128
+ a single element, an array of elements, or null or undefined.
129
+ **/
124
130
  function hasActiveChild(children) {
125
- // if we have children, either a single or multiple, find if it is active
126
131
  if (Array.isArray(children)) {
127
132
  return children.some(child => {
128
- if (!child.props) {
133
+ if (! /*#__PURE__*/React__default.isValidElement(child)) {
129
134
  return false;
130
135
  }
131
- if (child.props.isActive === true) {
132
- return true;
133
- }
134
- if (child.props['aria-current']) {
136
+
137
+ /** Explicitly defining the expected prop types (isActive and 'aria-current) for the children to ensure type
138
+ safety when accessing their props.
139
+ **/
140
+ const props = child.props;
141
+ if (props.isActive === true || props['aria-current']) {
135
142
  return true;
136
143
  }
137
144
  return false;
138
145
  });
139
146
  }
140
- if (children.props) {
141
- if (children.props.isActive === true || children.props['aria-current']) {
147
+
148
+ // We use React.isValidElement(child) to check if the child is a valid React element before accessing its props
149
+
150
+ if ( /*#__PURE__*/React__default.isValidElement(children)) {
151
+ const props = children.props;
152
+ if (props.isActive === true || props['aria-current']) {
142
153
  return true;
143
154
  }
144
155
  }
145
156
  return false;
146
157
  }
147
- var SideNavMenu$1 = SideNavMenu;
148
158
 
149
- export { SideNavMenu, SideNavMenu$1 as default };
159
+ export { SideNavMenu, SideNavMenu as default };
@@ -34,6 +34,7 @@ const TableSelectAll = _ref => {
34
34
  } = _ref;
35
35
  const prefix = usePrefix.usePrefix();
36
36
  return /*#__PURE__*/React__default["default"].createElement("th", {
37
+ "aria-live": "off",
37
38
  scope: "col",
38
39
  className: cx__default["default"](`${prefix}--table-column-checkbox`, className)
39
40
  }, /*#__PURE__*/React__default["default"].createElement(InlineCheckbox["default"], {
@@ -52,7 +52,8 @@ const TableSelectRow = _ref => {
52
52
  [`${prefix}--table-column-radio`]: radio
53
53
  });
54
54
  return /*#__PURE__*/React__default["default"].createElement("td", {
55
- className: tableSelectRowClasses
55
+ className: tableSelectRowClasses,
56
+ "aria-live": "off"
56
57
  }, /*#__PURE__*/React__default["default"].createElement(InlineInputComponent, _rollupPluginBabelHelpers["extends"]({}, selectionInputProps, radio && {
57
58
  labelText: ariaLabel,
58
59
  hideLabel: true
@@ -28,6 +28,10 @@ export interface FileUploaderItemProps extends ReactAttr<HTMLSpanElement> {
28
28
  * Name of the uploaded file
29
29
  */
30
30
  name?: string;
31
+ /**
32
+ * Event handler that is called after files are added to the uploader
33
+ */
34
+ onAddFiles?: (event: React.ChangeEvent<HTMLInputElement>) => void;
31
35
  /**
32
36
  * Event handler that is called after removing a file from the file uploader
33
37
  * The event handler signature looks like `onDelete(evt, { uuid })`
@@ -16,6 +16,8 @@ var React = require('react');
16
16
  var Filename = require('./Filename.js');
17
17
  var uniqueId = require('../../tools/uniqueId.js');
18
18
  var usePrefix = require('../../internal/usePrefix.js');
19
+ require('../Tooltip/DefinitionTooltip.js');
20
+ var Tooltip = require('../Tooltip/Tooltip.js');
19
21
  var match = require('../../internal/keyboard/match.js');
20
22
  var keys = require('../../internal/keyboard/keys.js');
21
23
 
@@ -38,6 +40,7 @@ function FileUploaderItem(_ref) {
38
40
  size,
39
41
  ...other
40
42
  } = _ref;
43
+ const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
41
44
  const prefix = usePrefix.usePrefix();
42
45
  const {
43
46
  current: id
@@ -47,13 +50,37 @@ function FileUploaderItem(_ref) {
47
50
  [`${prefix}--file__selected-file--md`]: size === 'md',
48
51
  [`${prefix}--file__selected-file--sm`]: size === 'sm'
49
52
  });
53
+ const isInvalid = invalid ? `${prefix}--file-filename-container-wrap-invalid` : `${prefix}--file-filename-container-wrap`;
54
+ const isEllipsisActive = element => {
55
+ setIsEllipsisApplied(element.offsetWidth < element.scrollWidth);
56
+ return element.offsetWidth < element.scrollWidth;
57
+ };
58
+ React.useLayoutEffect(() => {
59
+ const element = document.querySelector(`[title="${name}"]`);
60
+ isEllipsisActive(element);
61
+ }, [prefix, name]);
50
62
  return /*#__PURE__*/React__default["default"].createElement("span", _rollupPluginBabelHelpers["extends"]({
51
63
  className: classes
52
- }, other), /*#__PURE__*/React__default["default"].createElement("p", {
53
- className: `${prefix}--file-filename`,
64
+ }, other), isEllipsisApplied ? /*#__PURE__*/React__default["default"].createElement("div", {
65
+ className: isInvalid
66
+ }, /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
67
+ label: name,
68
+ align: "bottom",
69
+ className: `${prefix}--file-filename-tooltip`
70
+ }, /*#__PURE__*/React__default["default"].createElement("button", {
71
+ className: `${prefix}--file-filename-button`,
72
+ type: "button"
73
+ }, /*#__PURE__*/React__default["default"].createElement("p", {
74
+ title: name,
75
+ className: `${prefix}--file-filename-button`,
76
+ id: name
77
+ }, name)))) : /*#__PURE__*/React__default["default"].createElement("p", {
54
78
  title: name,
79
+ className: `${prefix}--file-filename`,
55
80
  id: name
56
- }, name), /*#__PURE__*/React__default["default"].createElement("span", {
81
+ }, name), /*#__PURE__*/React__default["default"].createElement("div", {
82
+ className: `${prefix}--file-container-item`
83
+ }, /*#__PURE__*/React__default["default"].createElement("span", {
57
84
  className: `${prefix}--file__state-container`
58
85
  }, /*#__PURE__*/React__default["default"].createElement(Filename["default"], {
59
86
  name: name,
@@ -78,7 +105,7 @@ function FileUploaderItem(_ref) {
78
105
  });
79
106
  }
80
107
  }
81
- })), invalid && errorSubject && /*#__PURE__*/React__default["default"].createElement("div", {
108
+ }))), invalid && errorSubject && /*#__PURE__*/React__default["default"].createElement("div", {
82
109
  className: `${prefix}--form-requirement`,
83
110
  role: "alert",
84
111
  id: `${name}-id-error`
@@ -37,7 +37,8 @@ function Filename(_ref) {
37
37
  return /*#__PURE__*/React__default["default"].createElement(Loading["default"], {
38
38
  description: iconDescription,
39
39
  small: true,
40
- withOverlay: false
40
+ withOverlay: false,
41
+ className: `${prefix}--file-loading`
41
42
  });
42
43
  case 'edit':
43
44
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, invalid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
@@ -135,7 +135,7 @@ const Search = /*#__PURE__*/React__default["default"].forwardRef(function Search
135
135
  className: `${prefix}--search-magnifier`,
136
136
  onClick: onExpand,
137
137
  onKeyDown: handleExpandButtonKeyDown,
138
- tabIndex: onExpand && !isExpanded ? 1 : -1,
138
+ tabIndex: onExpand && !isExpanded ? 0 : -1,
139
139
  ref: expandButtonRef,
140
140
  "aria-expanded": onExpand && isExpanded ? true : undefined,
141
141
  "aria-controls": onExpand ? uniqueId : undefined
@@ -0,0 +1,26 @@
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 { ReactNode } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ export interface SideNavLinkTextProps {
10
+ children: ReactNode;
11
+ className?: string;
12
+ }
13
+ declare function SideNavLinkText({ className: customClassName, children, ...rest }: SideNavLinkTextProps): JSX.Element;
14
+ declare namespace SideNavLinkText {
15
+ var propTypes: {
16
+ /**
17
+ * Provide the content for the link text
18
+ */
19
+ children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
20
+ /**
21
+ * Provide an optional class to be applied to the containing node
22
+ */
23
+ className: PropTypes.Requireable<string>;
24
+ };
25
+ }
26
+ export default SideNavLinkText;
@@ -11,15 +11,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
12
  var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
13
13
  var cx = require('classnames');
14
- var PropTypes = require('prop-types');
15
14
  var React = require('react');
16
15
  var usePrefix = require('../../internal/usePrefix.js');
16
+ var PropTypes = require('prop-types');
17
17
 
18
18
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
19
 
20
20
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
21
- var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
22
21
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
23
23
 
24
24
  function SideNavLinkText(_ref) {
25
25
  let {
@@ -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 React from 'react';
8
+ interface SideNavMenuProps {
9
+ /**
10
+ * An optional CSS class to apply to the component.
11
+ */
12
+ className?: string;
13
+ /**
14
+ * The content to render within the SideNavMenu component.
15
+ */
16
+ children?: React.ReactNode;
17
+ /**
18
+ * Specifies whether the menu should be expanded by default.
19
+ */
20
+ defaultExpanded?: boolean;
21
+ /**
22
+ * Indicates whether the SideNavMenu is active.
23
+ */
24
+ isActive?: boolean;
25
+ /**
26
+ * Specifies whether the SideNavMenu is in a large variation.
27
+ */
28
+ large?: boolean;
29
+ /**
30
+ * A custom icon to render next to the SideNavMenu title. This can be a function returning JSX or JSX itself.
31
+ */
32
+ renderIcon?: React.ComponentType;
33
+ /**
34
+ * Indicates if the side navigation container is expanded or collapsed.
35
+ */
36
+ isSideNavExpanded?: boolean;
37
+ /**
38
+ * The tabIndex for the button element.
39
+ * If not specified, the default validation will be applied.
40
+ */
41
+ tabIndex?: number;
42
+ title: string;
43
+ }
44
+ declare const SideNavMenu: React.ForwardRefExoticComponent<SideNavMenuProps & React.RefAttributes<HTMLElement>>;
45
+ export default SideNavMenu;
46
+ export { SideNavMenu };
@@ -26,8 +26,8 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
26
26
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
27
27
 
28
28
  var _ChevronDown;
29
- const SideNavMenu = /*#__PURE__*/React__default["default"].forwardRef(function SideNavMenu(props, ref) {
30
- const {
29
+ const SideNavMenu = /*#__PURE__*/React__default["default"].forwardRef(function SideNavMenu(_ref, ref) {
30
+ let {
31
31
  className: customClassName,
32
32
  children,
33
33
  defaultExpanded = false,
@@ -37,7 +37,7 @@ const SideNavMenu = /*#__PURE__*/React__default["default"].forwardRef(function S
37
37
  isSideNavExpanded,
38
38
  tabIndex,
39
39
  title
40
- } = props;
40
+ } = _ref;
41
41
  const isRail = React.useContext(SideNav.SideNavContext);
42
42
  const prefix = usePrefix.usePrefix();
43
43
  const [isExpanded, setIsExpanded] = React.useState(defaultExpanded);
@@ -121,6 +121,7 @@ SideNavMenu.propTypes = {
121
121
  /**
122
122
  * Pass in a custom icon to render next to the `SideNavMenu` title
123
123
  */
124
+ // @ts-expect-error - PropTypes are unable to cover this case.
124
125
  renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
125
126
  /**
126
127
  * Optional prop to specify the tabIndex of the button. If undefined, it will be applied default validation
@@ -131,30 +132,39 @@ SideNavMenu.propTypes = {
131
132
  */
132
133
  title: PropTypes__default["default"].string.isRequired
133
134
  };
135
+
136
+ /**
137
+ Defining the children parameter with the type ReactNode | ReactNode[]. This allows for various possibilities:
138
+ a single element, an array of elements, or null or undefined.
139
+ **/
134
140
  function hasActiveChild(children) {
135
- // if we have children, either a single or multiple, find if it is active
136
141
  if (Array.isArray(children)) {
137
142
  return children.some(child => {
138
- if (!child.props) {
143
+ if (! /*#__PURE__*/React__default["default"].isValidElement(child)) {
139
144
  return false;
140
145
  }
141
- if (child.props.isActive === true) {
142
- return true;
143
- }
144
- if (child.props['aria-current']) {
146
+
147
+ /** Explicitly defining the expected prop types (isActive and 'aria-current) for the children to ensure type
148
+ safety when accessing their props.
149
+ **/
150
+ const props = child.props;
151
+ if (props.isActive === true || props['aria-current']) {
145
152
  return true;
146
153
  }
147
154
  return false;
148
155
  });
149
156
  }
150
- if (children.props) {
151
- if (children.props.isActive === true || children.props['aria-current']) {
157
+
158
+ // We use React.isValidElement(child) to check if the child is a valid React element before accessing its props
159
+
160
+ if ( /*#__PURE__*/React__default["default"].isValidElement(children)) {
161
+ const props = children.props;
162
+ if (props.isActive === true || props['aria-current']) {
152
163
  return true;
153
164
  }
154
165
  }
155
166
  return false;
156
167
  }
157
- var SideNavMenu$1 = SideNavMenu;
158
168
 
159
169
  exports.SideNavMenu = SideNavMenu;
160
- exports["default"] = SideNavMenu$1;
170
+ exports["default"] = SideNavMenu;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/react",
3
3
  "description": "React components for the Carbon Design System",
4
- "version": "1.39.0",
4
+ "version": "1.40.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -49,11 +49,11 @@
49
49
  "@carbon/feature-flags": "^0.16.0",
50
50
  "@carbon/icons-react": "^11.28.0",
51
51
  "@carbon/layout": "^11.19.0",
52
- "@carbon/styles": "^1.39.0",
52
+ "@carbon/styles": "^1.40.0",
53
53
  "@carbon/telemetry": "0.1.0",
54
54
  "classnames": "2.3.2",
55
55
  "copy-to-clipboard": "^3.3.1",
56
- "downshift": "8.2.0",
56
+ "downshift": "8.2.1",
57
57
  "flatpickr": "4.6.9",
58
58
  "invariant": "^2.2.3",
59
59
  "lodash.debounce": "^4.0.8",
@@ -87,6 +87,7 @@
87
87
  "@storybook/addon-docs": "^7.1.0",
88
88
  "@storybook/addon-essentials": "^7.1.0",
89
89
  "@storybook/addon-knobs": "^7.0.2",
90
+ "@storybook/addon-links": "^7.4.5",
90
91
  "@storybook/addon-notes": "^5.3.21",
91
92
  "@storybook/addon-storysource": "^7.1.0",
92
93
  "@storybook/react": "^7.1.0",
@@ -138,5 +139,5 @@
138
139
  "**/*.scss",
139
140
  "**/*.css"
140
141
  ],
141
- "gitHead": "7c151d929564f2cf414f3a0fef4a5fc888242fae"
142
+ "gitHead": "99314f69da3f5791c3c0f46564a47ef9ee7c9e0f"
142
143
  }