@carbon/react 1.56.0-rc.1 → 1.57.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 (43) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +848 -848
  2. package/es/components/ContainedList/ContainedList.d.ts +41 -0
  3. package/es/components/ContainedList/ContainedList.js +18 -4
  4. package/es/components/ContainedList/ContainedListItem/ContainedListItem.d.ts +35 -0
  5. package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +5 -3
  6. package/es/components/DataTable/TableToolbarSearch.js +1 -1
  7. package/es/components/ExpandableSearch/ExpandableSearch.d.ts +1 -5
  8. package/es/components/ExpandableSearch/ExpandableSearch.js +4 -3
  9. package/es/components/OverflowMenu/OverflowMenu.d.ts +300 -0
  10. package/es/components/OverflowMenu/OverflowMenu.js +22 -14
  11. package/es/components/OverflowMenu/next/index.d.ts +39 -0
  12. package/es/components/OverflowMenu/next/index.js +4 -3
  13. package/es/components/RadioTile/RadioTile.d.ts +4 -0
  14. package/es/components/RadioTile/RadioTile.js +7 -1
  15. package/es/components/Slider/Slider.js +9 -5
  16. package/es/components/StructuredList/StructuredList.js +6 -2
  17. package/es/components/TextInput/PasswordInput.js +25 -7
  18. package/es/components/TileGroup/TileGroup.d.ts +8 -0
  19. package/es/components/TileGroup/TileGroup.js +7 -1
  20. package/es/index.js +1 -1
  21. package/es/internal/Selection.js +4 -1
  22. package/lib/components/ContainedList/ContainedList.d.ts +41 -0
  23. package/lib/components/ContainedList/ContainedList.js +18 -4
  24. package/lib/components/ContainedList/ContainedListItem/ContainedListItem.d.ts +35 -0
  25. package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +5 -3
  26. package/lib/components/DataTable/TableToolbarSearch.js +1 -1
  27. package/lib/components/ExpandableSearch/ExpandableSearch.d.ts +1 -5
  28. package/lib/components/ExpandableSearch/ExpandableSearch.js +4 -3
  29. package/lib/components/OverflowMenu/OverflowMenu.d.ts +300 -0
  30. package/lib/components/OverflowMenu/OverflowMenu.js +21 -13
  31. package/lib/components/OverflowMenu/next/index.d.ts +39 -0
  32. package/lib/components/OverflowMenu/next/index.js +4 -3
  33. package/lib/components/RadioTile/RadioTile.d.ts +4 -0
  34. package/lib/components/RadioTile/RadioTile.js +7 -1
  35. package/lib/components/Slider/Slider.js +9 -5
  36. package/lib/components/StructuredList/StructuredList.js +6 -2
  37. package/lib/components/TextInput/PasswordInput.js +25 -7
  38. package/lib/components/TileGroup/TileGroup.d.ts +8 -0
  39. package/lib/components/TileGroup/TileGroup.js +7 -1
  40. package/lib/index.js +2 -2
  41. package/lib/internal/Selection.js +4 -1
  42. package/package.json +8 -8
  43. package/telemetry.yml +1 -1
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022
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, { ReactNode } from 'react';
8
+ declare const variants: readonly ["on-page", "disclosed"];
9
+ type Variants = (typeof variants)[number];
10
+ interface ContainedListProps {
11
+ /**
12
+ * A slot for a possible interactive element to render.
13
+ */
14
+ action?: ReactNode;
15
+ /**
16
+ * A collection of ContainedListItems to be rendered in the ContainedList
17
+ */
18
+ children?: ReactNode;
19
+ /**
20
+ * Additional CSS class names.
21
+ */
22
+ className?: string;
23
+ /**
24
+ * Specify whether the dividing lines in between list items should be inset.
25
+ */
26
+ isInset?: boolean;
27
+ /**
28
+ * The kind of ContainedList you want to display
29
+ */
30
+ kind?: Variants;
31
+ /**
32
+ * A label describing the contained list.
33
+ */
34
+ label: string | ReactNode;
35
+ /**
36
+ * Specify the size of the contained list.
37
+ */
38
+ size?: 'sm' | 'md' | 'lg' | 'xl';
39
+ }
40
+ declare const ContainedList: React.FC<ContainedListProps>;
41
+ export default ContainedList;
@@ -37,7 +37,7 @@ function renderChildren(children) {
37
37
  }
38
38
  return children;
39
39
  }
40
- function ContainedList(_ref) {
40
+ const ContainedList = _ref => {
41
41
  let {
42
42
  action,
43
43
  children,
@@ -57,7 +57,20 @@ function ContainedList(_ref) {
57
57
  [`${prefix}--layout--size-${size}`]: size
58
58
  }, `${prefix}--contained-list--${kind}`, className);
59
59
  const filteredChildren = filterChildren(children);
60
- const isActionSearch = ['Search', 'ExpandableSearch'].includes(action?.type?.displayName);
60
+ function isSearchAction(action) {
61
+ if (! /*#__PURE__*/React__default.isValidElement(action)) {
62
+ return false;
63
+ }
64
+ const actionTypes = ['Search', 'ExpandableSearch'];
65
+ let actionType = '';
66
+ if (typeof action.type === 'string') {
67
+ actionType = action.type;
68
+ } else {
69
+ actionType = action.type.displayName || '';
70
+ }
71
+ return actionTypes.includes(actionType);
72
+ }
73
+ const isActionSearch = isSearchAction(action);
61
74
  const renderedChildren = renderChildren(children);
62
75
  return /*#__PURE__*/React__default.createElement("div", _extends({
63
76
  className: classes
@@ -86,7 +99,7 @@ function ContainedList(_ref) {
86
99
  role: "list",
87
100
  "aria-labelledby": labelId
88
101
  }, isActionSearch ? filteredChildren : renderedChildren));
89
- }
102
+ };
90
103
  ContainedList.propTypes = {
91
104
  /**
92
105
  * A slot for a possible interactive element to render.
@@ -117,5 +130,6 @@ ContainedList.propTypes = {
117
130
  */
118
131
  size: PropTypes.oneOf(['sm', 'md', 'lg', 'xl'])
119
132
  };
133
+ var ContainedList$1 = ContainedList;
120
134
 
121
- export { ContainedList as default };
135
+ export { ContainedList$1 as default };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022
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, { type ComponentType, type FunctionComponent, ReactNode } from 'react';
8
+ interface ContainedListItemProps {
9
+ /**
10
+ * A slot for a possible interactive element to render within the item.
11
+ */
12
+ action?: ReactNode;
13
+ /**
14
+ * The content of this item. Must not contain any interactive elements. Use props.action to include those.
15
+ */
16
+ children?: ReactNode;
17
+ /**
18
+ * Additional CSS class names.
19
+ */
20
+ className?: string;
21
+ /**
22
+ * Whether this item is disabled.
23
+ */
24
+ disabled?: boolean;
25
+ /**
26
+ * Provide an optional function to be called when the item is clicked.
27
+ */
28
+ onClick?: () => void;
29
+ /**
30
+ * Provide an optional icon to render in front of the item's content.
31
+ */
32
+ renderIcon?: ComponentType | FunctionComponent;
33
+ }
34
+ declare const ContainedListItem: React.FC<ContainedListItemProps>;
35
+ export default ContainedListItem;
@@ -12,7 +12,7 @@ import cx from 'classnames';
12
12
  import { LayoutConstraint } from '../../Layout/index.js';
13
13
  import { usePrefix } from '../../../internal/usePrefix.js';
14
14
 
15
- function ContainedListItem(_ref) {
15
+ const ContainedListItem = _ref => {
16
16
  let {
17
17
  action,
18
18
  children,
@@ -48,7 +48,7 @@ function ContainedListItem(_ref) {
48
48
  },
49
49
  className: `${prefix}--contained-list-item__action`
50
50
  }, action));
51
- }
51
+ };
52
52
  ContainedListItem.propTypes = {
53
53
  /**
54
54
  * A slot for a possible interactive element to render within the item.
@@ -73,7 +73,9 @@ ContainedListItem.propTypes = {
73
73
  /**
74
74
  * Provide an optional icon to render in front of the item's content.
75
75
  */
76
+ // @ts-expect-error: PropTypes are not expressive enough to cover this case
76
77
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
77
78
  };
79
+ var ContainedListItem$1 = ContainedListItem;
78
80
 
79
- export { ContainedListItem as default };
81
+ export { ContainedListItem$1 as default };
@@ -98,7 +98,7 @@ const TableToolbarSearch = _ref => {
98
98
  disabled: disabled,
99
99
  className: searchClasses,
100
100
  value: value,
101
- id: typeof id !== 'undefined' ? id : uniqueId.toString(),
101
+ id: typeof id !== 'undefined' ? id : `table-toolbar-search-${uniqueId.toString()}`,
102
102
  labelText: labelText || t('carbon.table.toolbar.search.label'),
103
103
  placeholder: placeholder || t('carbon.table.toolbar.search.placeholder'),
104
104
  onChange: onChange,
@@ -6,9 +6,5 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import { type SearchProps } from '../Search';
9
- declare function ExpandableSearch({ onBlur, onChange, onExpand, onKeyDown, defaultValue, isExpanded, ...props }: SearchProps): import("react/jsx-runtime").JSX.Element;
10
- declare namespace ExpandableSearch {
11
- var propTypes: React.WeakValidationMap<SearchProps & React.RefAttributes<HTMLInputElement>> | undefined;
12
- var displayName: string;
13
- }
9
+ declare const ExpandableSearch: React.ForwardRefExoticComponent<SearchProps & React.RefAttributes<HTMLInputElement>>;
14
10
  export default ExpandableSearch;
@@ -12,10 +12,11 @@ import Search from '../Search/Search.js';
12
12
  import '../Search/Search.Skeleton.js';
13
13
  import { usePrefix } from '../../internal/usePrefix.js';
14
14
  import { composeEventHandlers } from '../../tools/events.js';
15
+ import mergeRefs from '../../tools/mergeRefs.js';
15
16
  import { match } from '../../internal/keyboard/match.js';
16
17
  import { Escape } from '../../internal/keyboard/keys.js';
17
18
 
18
- function ExpandableSearch(_ref) {
19
+ const ExpandableSearch = /*#__PURE__*/React__default.forwardRef(function ExpandableSearch(_ref, forwardedRef) {
19
20
  let {
20
21
  onBlur,
21
22
  onChange,
@@ -61,14 +62,14 @@ function ExpandableSearch(_ref) {
61
62
  return /*#__PURE__*/React__default.createElement(Search, _extends({}, props, {
62
63
  defaultValue: defaultValue,
63
64
  isExpanded: expanded,
64
- ref: searchRef,
65
+ ref: mergeRefs(searchRef, forwardedRef),
65
66
  className: classes,
66
67
  onBlur: composeEventHandlers([onBlur, handleBlur]),
67
68
  onChange: composeEventHandlers([onChange, handleChange]),
68
69
  onExpand: composeEventHandlers([onExpand, handleExpand]),
69
70
  onKeyDown: composeEventHandlers([onKeyDown, handleKeyDown])
70
71
  }));
71
- }
72
+ });
72
73
  ExpandableSearch.propTypes = Search.propTypes;
73
74
  ExpandableSearch.displayName = 'ExpandableSearch';
74
75
 
@@ -0,0 +1,300 @@
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
+ /**
10
+ * @param {Element} menuBody The menu body with the menu arrow.
11
+ * @param {string} direction The floating menu direction.
12
+ * @returns {FloatingMenu~offset} The adjustment of the floating menu position, upon the position of the menu arrow.
13
+ * @private
14
+ */
15
+ export declare const getMenuOffset: (menuBody: any, direction: any, trigger: any, flip: any) => {
16
+ left: number;
17
+ top: number;
18
+ } | undefined;
19
+ interface Offset {
20
+ top: number;
21
+ left: number;
22
+ }
23
+ interface OverflowMenuProps {
24
+ /**
25
+ * Specify a label to be read by screen readers on the container node
26
+ */
27
+ ['aria-label']: string;
28
+ /**
29
+ * Deprecated, please use `aria-label` instead.
30
+ * Specify a label to be read by screen readers on the container note.
31
+ * @deprecated
32
+ * */
33
+ ariaLabel: string;
34
+ /**
35
+ * The child nodes.
36
+ * */
37
+ children: React.ReactNode;
38
+ /**
39
+ * The CSS class names.
40
+ * */
41
+ className?: string;
42
+ /**
43
+ * The menu direction.
44
+ */
45
+ direction?: string;
46
+ /**
47
+ * `true` if the menu alignment should be flipped.
48
+ */
49
+ flipped?: boolean;
50
+ /**
51
+ * Enable or disable focus trap behavior
52
+ */
53
+ focusTrap?: boolean;
54
+ /**
55
+ * The CSS class for the icon.
56
+ */
57
+ iconClass?: string;
58
+ /**
59
+ * The element ID.
60
+ */
61
+ id?: string;
62
+ /**
63
+ * The icon description.
64
+ */
65
+ iconDescription?: string;
66
+ /**
67
+ * `true` to use the light version. For use on $ui-01 backgrounds only.
68
+ * Don't use this to make OverflowMenu background color same as container background color.
69
+ */
70
+ light?: boolean;
71
+ /**
72
+ * The adjustment in position applied to the floating menu.
73
+ */
74
+ menuOffset?: Offset | (() => void);
75
+ /**
76
+ * The adjustment in position applied to the floating menu.
77
+ */
78
+ menuOffsetFlip?: Offset | (() => void);
79
+ /**
80
+ * The class to apply to the menu options
81
+ */
82
+ menuOptionsClass?: string;
83
+ /**
84
+ * The event handler for the `click` event.
85
+ */
86
+ onClick?: (evt?: any) => void;
87
+ /**
88
+ * Function called when menu is closed
89
+ */
90
+ onClose?: () => void;
91
+ /**
92
+ * Function called when menu is opened
93
+ */
94
+ onOpen?: () => void;
95
+ /**
96
+ * `true` if the menu should be open.
97
+ */
98
+ open?: boolean;
99
+ /**
100
+ * Function called to override icon rendering.
101
+ */
102
+ renderIcon?: React.ElementType;
103
+ /**
104
+ * Specify a CSS selector that matches the DOM element that should
105
+ * be focused when the OverflowMenu opens
106
+ */
107
+ selectorPrimaryFocus?: string;
108
+ /**
109
+ * Specify the size of the OverflowMenu. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
110
+ */
111
+ size?: 'sm' | 'md' | 'lg';
112
+ /**
113
+ * The ref to the HTML element that should receive focus when the OverflowMenu opens
114
+ */
115
+ innerRef?: React.Ref<any>;
116
+ }
117
+ interface OverflowMenuState {
118
+ open: boolean;
119
+ prevOpen?: boolean;
120
+ hasMountedTrigger: boolean;
121
+ click: boolean;
122
+ }
123
+ interface ReleaseHandle {
124
+ release: () => null;
125
+ }
126
+ declare class OverflowMenu extends React.Component<OverflowMenuProps, OverflowMenuState> {
127
+ state: OverflowMenuState;
128
+ instanceId: number;
129
+ static propTypes: {
130
+ /**
131
+ * Specify a label to be read by screen readers on the container node
132
+ */
133
+ "aria-label": PropTypes.Requireable<string>;
134
+ /**
135
+ * Deprecated, please use `aria-label` instead.
136
+ * Specify a label to be read by screen readers on the container note.
137
+ */
138
+ ariaLabel: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
139
+ /**
140
+ * The child nodes.
141
+ */
142
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
143
+ /**
144
+ * The CSS class names.
145
+ */
146
+ className: PropTypes.Requireable<string>;
147
+ /**
148
+ * The menu direction.
149
+ */
150
+ direction: PropTypes.Requireable<string>;
151
+ /**
152
+ * `true` if the menu alignment should be flipped.
153
+ */
154
+ flipped: PropTypes.Requireable<boolean>;
155
+ /**
156
+ * Enable or disable focus trap behavior
157
+ */
158
+ focusTrap: PropTypes.Requireable<boolean>;
159
+ /**
160
+ * The CSS class for the icon.
161
+ */
162
+ iconClass: PropTypes.Requireable<string>;
163
+ /**
164
+ * The icon description.
165
+ */
166
+ iconDescription: PropTypes.Requireable<string>;
167
+ /**
168
+ * The element ID.
169
+ */
170
+ id: PropTypes.Requireable<string>;
171
+ /**
172
+ * `true` to use the light version. For use on $ui-01 backgrounds only.
173
+ * Don't use this to make OverflowMenu background color same as container background color.
174
+ */
175
+ light: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
176
+ /**
177
+ * The adjustment in position applied to the floating menu.
178
+ */
179
+ menuOffset: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | PropTypes.InferProps<{
180
+ top: PropTypes.Requireable<number>;
181
+ left: PropTypes.Requireable<number>;
182
+ }> | null | undefined>>;
183
+ /**
184
+ * The adjustment in position applied to the floating menu.
185
+ */
186
+ menuOffsetFlip: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | PropTypes.InferProps<{
187
+ top: PropTypes.Requireable<number>;
188
+ left: PropTypes.Requireable<number>;
189
+ }> | null | undefined>>;
190
+ /**
191
+ * The class to apply to the menu options
192
+ */
193
+ menuOptionsClass: PropTypes.Requireable<string>;
194
+ /**
195
+ * The event handler for the `click` event.
196
+ */
197
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
198
+ /**
199
+ * Function called when menu is closed
200
+ */
201
+ onClose: PropTypes.Requireable<(...args: any[]) => any>;
202
+ /**
203
+ * The event handler for the `focus` event.
204
+ */
205
+ onFocus: PropTypes.Requireable<(...args: any[]) => any>;
206
+ /**
207
+ * The event handler for the `keydown` event.
208
+ */
209
+ onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
210
+ /**
211
+ * Function called when menu is opened
212
+ */
213
+ onOpen: PropTypes.Requireable<(...args: any[]) => any>;
214
+ /**
215
+ * `true` if the menu should be open.
216
+ */
217
+ open: PropTypes.Requireable<boolean>;
218
+ /**
219
+ * Function called to override icon rendering.
220
+ */
221
+ renderIcon: PropTypes.Requireable<object>;
222
+ /**
223
+ * Specify a CSS selector that matches the DOM element that should
224
+ * be focused when the OverflowMenu opens
225
+ */
226
+ selectorPrimaryFocus: PropTypes.Requireable<string>;
227
+ /**
228
+ * Specify the size of the OverflowMenu. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
229
+ */
230
+ size: PropTypes.Requireable<string>;
231
+ };
232
+ static contextType: React.Context<string>;
233
+ /**
234
+ * The handle of `onfocusin` or `focus` event handler.
235
+ * @private
236
+ */
237
+ _hFocusIn: ReleaseHandle | null;
238
+ /**
239
+ * The timeout handle for handling `blur` event.
240
+ * @private
241
+ */
242
+ _hBlurTimeout: any;
243
+ /**
244
+ * The element ref of the tooltip's trigger button.
245
+ * @type {React.RefObject<Element>}
246
+ * @private
247
+ */
248
+ _triggerRef: React.RefObject<unknown>;
249
+ componentDidUpdate(_: any, prevState: any): void;
250
+ componentDidMount(): void;
251
+ static getDerivedStateFromProps({ open }: {
252
+ open: any;
253
+ }, state: any): {
254
+ open: any;
255
+ prevOpen: any;
256
+ } | null;
257
+ componentWillUnmount(): void;
258
+ handleClick: (evt: any) => void;
259
+ closeMenuAndFocus: () => void;
260
+ closeMenuOnEscape: () => void;
261
+ handleKeyPress: (evt: any) => void;
262
+ handleClickOutside: (evt: any) => void;
263
+ closeMenu: (onCloseMenu?: any) => void;
264
+ focusMenuEl: () => void;
265
+ /**
266
+ * Focuses the next enabled overflow menu item given the currently focused
267
+ * item index and direction to move
268
+ * @param {object} params
269
+ * @param {number} params.currentIndex - the index of the currently focused
270
+ * overflow menu item in the list of overflow menu items
271
+ * @param {number} params.direction - number denoting the direction to move
272
+ * focus (1 for forwards, -1 for backwards)
273
+ */
274
+ handleOverflowMenuItemFocus: ({ currentIndex, direction }: {
275
+ currentIndex: any;
276
+ direction: any;
277
+ }) => void;
278
+ /**
279
+ * Handles the floating menu being unmounted or non-floating menu being
280
+ * mounted or unmounted.
281
+ * @param {Element} menuBody The DOM element of the menu body.
282
+ * @private
283
+ */
284
+ _menuBody: HTMLElement | null;
285
+ _bindMenuBody: (menuBody: HTMLElement | null) => void;
286
+ /**
287
+ * Handles the floating menu being placed.
288
+ * @param {Element} menuBody The DOM element of the menu body.
289
+ * @private
290
+ */
291
+ _handlePlace: (menuBody: any) => void;
292
+ /**
293
+ * @returns {Element} The DOM element where the floating menu is placed in.
294
+ */
295
+ _getTarget: () => Element;
296
+ render(): import("react/jsx-runtime").JSX.Element;
297
+ }
298
+ export { OverflowMenu };
299
+ declare const _default: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<unknown>>;
300
+ export default _default;
@@ -8,7 +8,7 @@
8
8
  import { defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import invariant from 'invariant';
10
10
  import PropTypes from 'prop-types';
11
- import React__default, { Component } from 'react';
11
+ import React__default from 'react';
12
12
  import cx from 'classnames';
13
13
  import ClickListener from '../../internal/ClickListener.js';
14
14
  import FloatingMenu, { DIRECTION_TOP, DIRECTION_BOTTOM } from '../../internal/FloatingMenu.js';
@@ -93,10 +93,16 @@ const getMenuOffset = (menuBody, direction, trigger, flip) => {
93
93
  }
94
94
  }
95
95
  };
96
- class OverflowMenu extends Component {
96
+ class OverflowMenu extends React__default.Component {
97
97
  constructor() {
98
98
  super(...arguments);
99
- _defineProperty(this, "state", {});
99
+ _defineProperty(this, "state", {
100
+ open: false,
101
+ // Set a default value for 'open'
102
+ hasMountedTrigger: false,
103
+ // Set a default value for 'hasMountedTrigger'
104
+ click: false // Set a default value for 'click'
105
+ });
100
106
  _defineProperty(this, "instanceId", getInstanceId());
101
107
  /**
102
108
  * The handle of `onfocusin` or `focus` event handler.
@@ -130,8 +136,8 @@ class OverflowMenu extends Component {
130
136
  }
131
137
  });
132
138
  _defineProperty(this, "closeMenuAndFocus", () => {
133
- let wasClicked = this.state.click;
134
- let wasOpen = this.state.open;
139
+ const wasClicked = this.state.click;
140
+ const wasOpen = this.state.open;
135
141
  this.closeMenu(() => {
136
142
  if (wasOpen && !wasClicked) {
137
143
  this.focusMenuEl();
@@ -139,7 +145,7 @@ class OverflowMenu extends Component {
139
145
  });
140
146
  });
141
147
  _defineProperty(this, "closeMenuOnEscape", () => {
142
- let wasOpen = this.state.open;
148
+ const wasOpen = this.state.open;
143
149
  this.closeMenu(() => {
144
150
  if (wasOpen) {
145
151
  this.focusMenuEl();
@@ -201,7 +207,7 @@ class OverflowMenu extends Component {
201
207
  direction
202
208
  } = _ref;
203
209
  const enabledIndices = React__default.Children.toArray(this.props.children).reduce((acc, curr, i) => {
204
- if (!curr.props.disabled) {
210
+ if ( /*#__PURE__*/React__default.isValidElement(curr) && !curr.props.disabled) {
205
211
  acc.push(i);
206
212
  }
207
213
  return acc;
@@ -226,6 +232,7 @@ class OverflowMenu extends Component {
226
232
  * @param {Element} menuBody The DOM element of the menu body.
227
233
  * @private
228
234
  */
235
+ _defineProperty(this, "_menuBody", null);
229
236
  _defineProperty(this, "_bindMenuBody", menuBody => {
230
237
  if (!menuBody) {
231
238
  this._menuBody = menuBody;
@@ -268,7 +275,7 @@ class OverflowMenu extends Component {
268
275
  const {
269
276
  current: triggerEl
270
277
  } = this._triggerRef;
271
- return triggerEl && triggerEl.closest('[data-floating-menu-container]') || document.body;
278
+ return triggerEl instanceof Element && triggerEl.closest('[data-floating-menu-container]') || document.body;
272
279
  });
273
280
  }
274
281
  componentDidUpdate(_, prevState) {
@@ -349,18 +356,19 @@ class OverflowMenu extends Component {
349
356
  [`${prefix}--overflow-menu-options--${size}`]: size
350
357
  });
351
358
  const overflowMenuIconClasses = cx(`${prefix}--overflow-menu__icon`, iconClass);
352
- const childrenWithProps = React__default.Children.toArray(children).map((child, index) => /*#__PURE__*/React__default.cloneElement(child, {
353
- closeMenu: child?.props?.closeMenu || this.closeMenuAndFocus,
359
+ const childrenWithProps = React__default.Children.toArray(children).map((child, index) => /*#__PURE__*/React__default.isValidElement(child) ? /*#__PURE__*/React__default.cloneElement(child, {
360
+ // @ts-expect-error: PropTypes are not expressive enough to cover this case
361
+ closeMenu: child.props.closeMenu || this.closeMenuAndFocus,
354
362
  handleOverflowMenuItemFocus: this.handleOverflowMenuItemFocus,
355
363
  ref: e => {
356
364
  this[`overflowMenuItem${index}`] = e;
357
365
  },
358
366
  index
359
- }));
367
+ }) : null);
360
368
  const menuBodyId = `overflow-menu-${this.instanceId}__menu-body`;
361
369
  const menuBody = /*#__PURE__*/React__default.createElement("ul", {
362
370
  className: overflowMenuOptionsClasses,
363
- tabIndex: "-1",
371
+ tabIndex: -1,
364
372
  role: "menu",
365
373
  "aria-label": ariaLabel || deprecatedAriaLabel,
366
374
  onKeyDown: this.handleKeyPress,
@@ -387,12 +395,12 @@ class OverflowMenu extends Component {
387
395
  onClickOutside: this.handleClickOutside
388
396
  }, /*#__PURE__*/React__default.createElement("span", {
389
397
  className: `${prefix}--overflow-menu__wrapper`,
390
- "aria-owns": open ? menuBodyId : null
398
+ "aria-owns": open ? menuBodyId : undefined
391
399
  }, /*#__PURE__*/React__default.createElement(IconButton, _extends({}, other, {
392
400
  type: "button",
393
401
  "aria-haspopup": true,
394
402
  "aria-expanded": open,
395
- "aria-controls": open ? menuBodyId : null,
403
+ "aria-controls": open ? menuBodyId : undefined,
396
404
  className: overflowMenuClasses,
397
405
  onClick: this.handleClick,
398
406
  id: id,
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 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, { type ComponentType, type FunctionComponent } from 'react';
8
+ interface OverflowMenuProps {
9
+ /**
10
+ * A collection of MenuItems to be rendered within this OverflowMenu.
11
+ */
12
+ children?: React.ReactNode;
13
+ /**
14
+ * Additional CSS class names for the trigger button.
15
+ */
16
+ className?: string;
17
+ /**
18
+ * A label describing the options available. Is used in the trigger tooltip and as the menu's accessible label.
19
+ */
20
+ label?: string;
21
+ /**
22
+ * Experimental property. Specify how the menu should align with the button element
23
+ */
24
+ menuAlignment?: 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end';
25
+ /**
26
+ * Optionally provide a custom icon to be rendered on the trigger button.
27
+ */
28
+ renderIcon?: ComponentType | FunctionComponent;
29
+ /**
30
+ * Specify the size of the menu, from a list of available sizes.
31
+ */
32
+ size?: 'sm' | 'md' | 'lg';
33
+ /**
34
+ * Specify how the trigger tooltip should be aligned.
35
+ */
36
+ tooltipAlignment?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
37
+ }
38
+ declare const OverflowMenu: React.ForwardRefExoticComponent<OverflowMenuProps & React.RefAttributes<HTMLDivElement>>;
39
+ export { OverflowMenu };
@@ -52,10 +52,10 @@ const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMen
52
52
  }, size !== defaultSize && `${prefix}--overflow-menu--${size}`);
53
53
  return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
54
54
  className: containerClasses,
55
- "aria-owns": open ? id : null,
55
+ "aria-owns": open ? id : undefined,
56
56
  ref: forwardRef
57
57
  }), /*#__PURE__*/React__default.createElement(IconButton, {
58
- "aria-controls": open ? id : null,
58
+ "aria-controls": open ? id : undefined,
59
59
  "aria-haspopup": true,
60
60
  "aria-expanded": open,
61
61
  className: triggerClasses,
@@ -97,8 +97,9 @@ OverflowMenu.propTypes = {
97
97
  */
98
98
  menuAlignment: PropTypes.oneOf(['top-start', 'top-end', 'bottom-start', 'bottom-end']),
99
99
  /**
100
- * Otionally provide a custom icon to be rendered on the trigger button.
100
+ * Optionally provide a custom icon to be rendered on the trigger button.
101
101
  */
102
+ // @ts-expect-error: PropTypes are not expressive enough to cover this case
102
103
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
103
104
  /**
104
105
  * Specify the size of the menu, from a list of available sizes.