@carbon/react 1.57.0-rc.0 → 1.58.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 (126) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1022 -1028
  2. package/es/components/Button/Button.js +2 -2
  3. package/es/components/Checkbox/Checkbox.d.ts +6 -7
  4. package/es/components/ComboBox/ComboBox.d.ts +4 -5
  5. package/es/components/ComboBox/ComboBox.js +268 -260
  6. package/es/components/ComposedModal/ComposedModal.d.ts +1 -2
  7. package/es/components/ContainedList/ContainedList.d.ts +7 -3
  8. package/es/components/ContainedList/ContainedList.js +3 -2
  9. package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +1 -2
  10. package/es/components/ContainedList/ContainedListItem/index.d.ts +9 -0
  11. package/es/components/ContainedList/index.d.ts +11 -0
  12. package/es/components/ContainedList/index.js +13 -0
  13. package/es/components/DataTable/TableHeader.d.ts +4 -5
  14. package/es/components/DataTable/TableSlugRow.d.ts +3 -2
  15. package/es/components/DataTable/stories/examples/TableToolbarFilter.d.ts +51 -0
  16. package/es/components/DatePicker/DatePicker.d.ts +9 -9
  17. package/es/components/DatePicker/plugins/rangePlugin.js +5 -6
  18. package/es/components/Dialog/index.d.ts +31 -0
  19. package/es/components/Dropdown/Dropdown.d.ts +5 -6
  20. package/es/components/IconButton/index.d.ts +3 -4
  21. package/es/components/ListBox/next/ListBoxTrigger.js +5 -3
  22. package/es/components/Menu/Menu.js +1 -1
  23. package/es/components/Menu/MenuItem.js +13 -2
  24. package/es/components/Modal/Modal.d.ts +8 -9
  25. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +176 -0
  26. package/es/components/MultiSelect/FilterableMultiSelect.js +388 -313
  27. package/es/components/MultiSelect/MultiSelect.d.ts +10 -9
  28. package/es/components/MultiSelect/MultiSelect.js +1 -2
  29. package/es/components/MultiSelect/MultiSelectPropTypes.d.ts +62 -0
  30. package/es/components/MultiSelect/index.d.ts +10 -0
  31. package/es/components/MultiSelect/index.js +2 -0
  32. package/es/components/Notification/Notification.d.ts +2 -2
  33. package/es/components/NumberInput/NumberInput.d.ts +1 -2
  34. package/es/components/Pagination/Pagination.js +9 -9
  35. package/es/components/PasswordInput/index.d.ts +3 -0
  36. package/es/components/Popover/index.d.ts +8 -2
  37. package/es/components/Popover/index.js +26 -1
  38. package/es/components/RadioButton/RadioButton.d.ts +7 -4
  39. package/es/components/RadioButton/RadioButton.js +7 -1
  40. package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +11 -8
  41. package/es/components/RadioButtonGroup/RadioButtonGroup.js +7 -1
  42. package/es/components/Select/Select.d.ts +1 -2
  43. package/es/components/Slider/Slider.d.ts +5 -5
  44. package/es/components/Slider/Slider.js +1 -1
  45. package/es/components/Tag/DismissibleTag.d.ts +3 -3
  46. package/es/components/Tag/OperationalTag.d.ts +3 -3
  47. package/es/components/Tag/SelectableTag.d.ts +3 -3
  48. package/es/components/Tag/Tag.d.ts +3 -3
  49. package/es/components/TextArea/TextArea.d.ts +6 -7
  50. package/es/components/TextInput/PasswordInput.d.ts +5 -6
  51. package/es/components/TextInput/PasswordInput.js +2 -2
  52. package/es/components/TextInput/TextInput.d.ts +1 -2
  53. package/es/components/Theme/index.d.ts +1 -0
  54. package/es/components/Theme/index.js +8 -2
  55. package/es/components/Tile/Tile.d.ts +3 -4
  56. package/es/components/TileGroup/TileGroup.d.ts +3 -2
  57. package/es/components/TileGroup/index.d.ts +9 -0
  58. package/es/components/TimePicker/TimePicker.js +1 -1
  59. package/es/components/Toggle/Toggle.js +1 -1
  60. package/es/components/Tooltip/DefinitionTooltip.js +1 -1
  61. package/es/index.js +7 -5
  62. package/es/prop-types/deprecateValuesWithin.js +35 -0
  63. package/lib/components/Button/Button.js +2 -2
  64. package/lib/components/Checkbox/Checkbox.d.ts +6 -7
  65. package/lib/components/ComboBox/ComboBox.d.ts +4 -5
  66. package/lib/components/ComboBox/ComboBox.js +267 -260
  67. package/lib/components/ComposedModal/ComposedModal.d.ts +1 -2
  68. package/lib/components/ContainedList/ContainedList.d.ts +7 -3
  69. package/lib/components/ContainedList/ContainedList.js +3 -2
  70. package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +1 -2
  71. package/lib/components/ContainedList/ContainedListItem/index.d.ts +9 -0
  72. package/lib/components/ContainedList/index.d.ts +11 -0
  73. package/lib/components/ContainedList/index.js +19 -0
  74. package/lib/components/DataTable/TableHeader.d.ts +4 -5
  75. package/lib/components/DataTable/TableSlugRow.d.ts +3 -2
  76. package/lib/components/DataTable/stories/examples/TableToolbarFilter.d.ts +51 -0
  77. package/lib/components/DatePicker/DatePicker.d.ts +9 -9
  78. package/lib/components/DatePicker/plugins/rangePlugin.js +5 -6
  79. package/lib/components/Dialog/index.d.ts +31 -0
  80. package/lib/components/Dropdown/Dropdown.d.ts +5 -6
  81. package/lib/components/IconButton/index.d.ts +3 -4
  82. package/lib/components/ListBox/next/ListBoxTrigger.js +5 -3
  83. package/lib/components/Menu/Menu.js +1 -1
  84. package/lib/components/Menu/MenuItem.js +13 -2
  85. package/lib/components/Modal/Modal.d.ts +8 -9
  86. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +176 -0
  87. package/lib/components/MultiSelect/FilterableMultiSelect.js +387 -312
  88. package/lib/components/MultiSelect/MultiSelect.d.ts +10 -9
  89. package/lib/components/MultiSelect/MultiSelect.js +1 -2
  90. package/lib/components/MultiSelect/MultiSelectPropTypes.d.ts +62 -0
  91. package/lib/components/MultiSelect/index.d.ts +10 -0
  92. package/lib/components/MultiSelect/index.js +2 -0
  93. package/lib/components/Notification/Notification.d.ts +2 -2
  94. package/lib/components/NumberInput/NumberInput.d.ts +1 -2
  95. package/lib/components/Pagination/Pagination.js +9 -9
  96. package/lib/components/PasswordInput/index.d.ts +3 -0
  97. package/lib/components/Popover/index.d.ts +8 -2
  98. package/lib/components/Popover/index.js +26 -1
  99. package/lib/components/RadioButton/RadioButton.d.ts +7 -4
  100. package/lib/components/RadioButton/RadioButton.js +7 -1
  101. package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +11 -8
  102. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +7 -1
  103. package/lib/components/Select/Select.d.ts +1 -2
  104. package/lib/components/Slider/Slider.d.ts +5 -5
  105. package/lib/components/Slider/Slider.js +1 -1
  106. package/lib/components/Tag/DismissibleTag.d.ts +3 -3
  107. package/lib/components/Tag/OperationalTag.d.ts +3 -3
  108. package/lib/components/Tag/SelectableTag.d.ts +3 -3
  109. package/lib/components/Tag/Tag.d.ts +3 -3
  110. package/lib/components/TextArea/TextArea.d.ts +6 -7
  111. package/lib/components/TextInput/PasswordInput.d.ts +5 -6
  112. package/lib/components/TextInput/PasswordInput.js +2 -2
  113. package/lib/components/TextInput/TextInput.d.ts +1 -2
  114. package/lib/components/Theme/index.d.ts +1 -0
  115. package/lib/components/Theme/index.js +8 -1
  116. package/lib/components/Tile/Tile.d.ts +3 -4
  117. package/lib/components/TileGroup/TileGroup.d.ts +3 -2
  118. package/lib/components/TileGroup/index.d.ts +9 -0
  119. package/lib/components/TimePicker/TimePicker.js +1 -1
  120. package/lib/components/Toggle/Toggle.js +1 -1
  121. package/lib/components/Tooltip/DefinitionTooltip.js +1 -1
  122. package/lib/index.js +34 -31
  123. package/lib/prop-types/deprecateValuesWithin.js +39 -0
  124. package/package.json +8 -8
  125. package/es/components/TileGroup/index.js +0 -13
  126. package/lib/components/TileGroup/index.js +0 -18
@@ -12,6 +12,7 @@ import cx from 'classnames';
12
12
  import { LayoutConstraint } from '../Layout/index.js';
13
13
  import { useId } from '../../internal/useId.js';
14
14
  import { usePrefix } from '../../internal/usePrefix.js';
15
+ import ContainedListItem from './ContainedListItem/ContainedListItem.js';
15
16
 
16
17
  const variants = ['on-page', 'disclosed'];
17
18
  function filterChildren(children) {
@@ -130,6 +131,6 @@ ContainedList.propTypes = {
130
131
  */
131
132
  size: PropTypes.oneOf(['sm', 'md', 'lg', 'xl'])
132
133
  };
133
- var ContainedList$1 = ContainedList;
134
+ ContainedList.ContainedListItem = ContainedListItem;
134
135
 
135
- export { ContainedList$1 as default };
136
+ export { ContainedList as default };
@@ -76,6 +76,5 @@ ContainedListItem.propTypes = {
76
76
  // @ts-expect-error: PropTypes are not expressive enough to cover this case
77
77
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
78
78
  };
79
- var ContainedListItem$1 = ContainedListItem;
80
79
 
81
- export { ContainedListItem$1 as default };
80
+ export { ContainedListItem as default };
@@ -0,0 +1,9 @@
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 ContainedListItem from './ContainedListItem';
8
+ export default ContainedListItem;
9
+ export { ContainedListItem };
@@ -0,0 +1,11 @@
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 ContainedList from './ContainedList';
8
+ import ContainedListItem from './ContainedListItem';
9
+ export { ContainedListItem };
10
+ export default ContainedList;
11
+ export { ContainedList };
@@ -0,0 +1,13 @@
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
+
8
+ import ContainedList from './ContainedList.js';
9
+ export { default as ContainedList, default } from './ContainedList.js';
10
+ import ContainedListItem from './ContainedListItem/ContainedListItem.js';
11
+ export { default as ContainedListItem } from './ContainedListItem/ContainedListItem.js';
12
+
13
+ ContainedList.ContainedListItem = ContainedListItem;
@@ -4,14 +4,13 @@
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 { ReactNodeLike } from 'prop-types';
8
- import React, { type MouseEventHandler } from 'react';
7
+ import React, { type MouseEventHandler, ReactNode } from 'react';
9
8
  import { sortStates } from './state/sorting';
10
9
  import { ReactAttr } from '../../types/common';
11
10
  import { DataTableSortState } from './state/sortStates';
12
11
  export type TableHeaderTranslationKey = 'carbon.table.header.icon.description';
13
12
  export interface TableHeaderTranslationArgs {
14
- header: React.ReactNode;
13
+ header: ReactNode;
15
14
  isSortHeader?: boolean;
16
15
  sortDirection?: DataTableSortState;
17
16
  sortStates: typeof sortStates;
@@ -20,7 +19,7 @@ interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonEl
20
19
  /**
21
20
  * Pass in children that will be embedded in the table header label
22
21
  */
23
- children?: React.ReactNode;
22
+ children?: ReactNode;
24
23
  /**
25
24
  * Specify an optional className to be applied to the container node
26
25
  */
@@ -56,7 +55,7 @@ interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonEl
56
55
  /**
57
56
  * **Experimental**: Provide a `Slug` component to be rendered inside the `TableSlugRow` component
58
57
  */
59
- slug?: ReactNodeLike;
58
+ slug?: ReactNode;
60
59
  /**
61
60
  * Specify which direction we are currently sorting by, should be one of DESC,
62
61
  * NONE, or ASC.
@@ -4,7 +4,8 @@
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, { ReactNodeLike } from 'prop-types';
7
+ import PropTypes from 'prop-types';
8
+ import { ReactNode } from 'react';
8
9
  export interface TableSlugRowProps {
9
10
  /**
10
11
  * The CSS class names of the cell that wraps the underlying input control
@@ -13,7 +14,7 @@ export interface TableSlugRowProps {
13
14
  /**
14
15
  * Provide a `Slug` component to be rendered inside the `TableSlugRow` component
15
16
  */
16
- slug?: ReactNodeLike;
17
+ slug?: ReactNode;
17
18
  }
18
19
  declare const TableSlugRow: {
19
20
  ({ className, slug }: TableSlugRowProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,51 @@
1
+ import { ChangeEvent } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ export type PopoverAlignment = 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-end' | 'left-start' | 'right-end' | 'right-start';
4
+ interface TableToolbarFilterProps {
5
+ /**
6
+ * Specify how the popover should align with the trigger element
7
+ */
8
+ align?: PopoverAlignment;
9
+ /**
10
+ * Provide an optional class name for the toolbar filter
11
+ */
12
+ className?: string;
13
+ /**
14
+ * Provide an optional hook that is called each time the input is updated
15
+ */
16
+ onChange?: (event: '' | ChangeEvent<HTMLInputElement>, value?: string) => void;
17
+ /**
18
+ * Provide an function that is called when the apply button is clicked
19
+ */
20
+ onApplyFilter?: (selectedCheckboxes: Array<string>) => void;
21
+ /**
22
+ * Provide an function that is called when the reset button is clicked
23
+ */
24
+ onResetFilter?: () => void;
25
+ }
26
+ declare const TableToolbarFilter: {
27
+ ({ align, onApplyFilter, onResetFilter, className, ...rest }: TableToolbarFilterProps): import("react/jsx-runtime").JSX.Element;
28
+ propTypes: {
29
+ /**
30
+ * Specify how the popover should align with the trigger element
31
+ */
32
+ align: PropTypes.Requireable<string>;
33
+ /**
34
+ * Provide an optional class name for the search container
35
+ */
36
+ className: PropTypes.Requireable<string>;
37
+ /**
38
+ * Provide an function that is called when the apply button is clicked
39
+ */
40
+ onApplyFilter: PropTypes.Requireable<(...args: any[]) => any>;
41
+ /**
42
+ * Provide an optional hook that is called each time the input is updated
43
+ */
44
+ onChange: PropTypes.Requireable<(...args: any[]) => any>;
45
+ /**
46
+ * Provide an function that is called when the reset button is clicked
47
+ */
48
+ onResetFilter: PropTypes.Requireable<(...args: any[]) => any>;
49
+ };
50
+ };
51
+ export default TableToolbarFilter;
@@ -4,9 +4,9 @@
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 { ReactNodeLike } from 'prop-types';
8
- import React from 'react';
7
+ import React, { ReactNode } from 'react';
9
8
  import flatpickr from 'flatpickr';
9
+ import { DateLimit, DateOption } from 'flatpickr/dist/types/options';
10
10
  export type DatePickerTypes = 'simple' | 'single' | 'range';
11
11
  export type CalRef = {
12
12
  inline: boolean;
@@ -33,7 +33,7 @@ interface DatePickerProps {
33
33
  /**
34
34
  * The child nodes.
35
35
  */
36
- children: React.ReactNode | object;
36
+ children: ReactNode | object;
37
37
  /**
38
38
  * The CSS class names.
39
39
  */
@@ -57,11 +57,11 @@ interface DatePickerProps {
57
57
  /**
58
58
  * The flatpickr `disable` option that allows a user to disable certain dates.
59
59
  */
60
- disable?: string[];
60
+ disable?: DateLimit<DateOption>[];
61
61
  /**
62
62
  * The flatpickr `enable` option that allows a user to enable certain dates.
63
63
  */
64
- enable?: string[];
64
+ enable?: DateLimit<DateOption>[];
65
65
  /**
66
66
  * The flatpickr `inline` option.
67
67
  */
@@ -73,7 +73,7 @@ interface DatePickerProps {
73
73
  /**
74
74
  * Provide the text that is displayed when the control is in error state (Fluid Only)
75
75
  */
76
- invalidText?: ReactNodeLike;
76
+ invalidText?: ReactNode;
77
77
  /**
78
78
  * `true` to use the light version.
79
79
  */
@@ -85,11 +85,11 @@ interface DatePickerProps {
85
85
  /**
86
86
  * The maximum date that a user can pick to.
87
87
  */
88
- maxDate?: string | number;
88
+ maxDate?: DateOption;
89
89
  /**
90
90
  * The minimum date that a user can start picking from.
91
91
  */
92
- minDate?: string | number;
92
+ minDate?: DateOption;
93
93
  /**
94
94
  * The `change` event handler.
95
95
  */
@@ -128,7 +128,7 @@ interface DatePickerProps {
128
128
  /**
129
129
  * Provide the text that is displayed when the control is in warning state (Fluid only)
130
130
  */
131
- warnText?: ReactNodeLike;
131
+ warnText?: ReactNode;
132
132
  }
133
133
  declare const DatePicker: React.ForwardRefExoticComponent<DatePickerProps & React.RefAttributes<HTMLDivElement>>;
134
134
  export default DatePicker;
@@ -27,14 +27,13 @@ var carbonFlatpickrRangePlugin = (config => {
27
27
  // where Flatpickr's range plugin takes care of fixing the first `<input>`
28
28
  if (!triggerChange) {
29
29
  const {
30
- _input: inputFrom
30
+ _input: inputDates
31
31
  } = fp;
32
- const {
33
- input: inputTo
34
- } = config;
35
- [inputFrom, inputTo].forEach((input, i) => {
32
+ const inputDatesArray = inputDates.value.split(' ');
33
+ fp.close();
34
+ [inputDatesArray[0], inputDatesArray[2]].forEach((input, i) => {
36
35
  if (input) {
37
- input.value = !dates[i] ? '' : fp.formatDate(new Date(dates[i]), fp.config.dateFormat);
36
+ input = !dates[i] ? '' : fp.formatDate(new Date(dates[i]), fp.config.dateFormat);
38
37
  }
39
38
  });
40
39
  }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright IBM Corp. 2014, 2024
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 'wicg-inert';
8
+ import React from 'react';
9
+ import { ReactAttr } from '../../types/common';
10
+ export interface DialogProps extends ReactAttr<HTMLDialogElement> {
11
+ /**
12
+ * Provide the contents of the Dialog
13
+ */
14
+ children?: React.ReactNode;
15
+ /**
16
+ * Specifies whether the dialog is modal or non-modal
17
+ */
18
+ modal?: boolean;
19
+ /**
20
+ * Specify a handler for closing Dialog.
21
+ * The handler should care of closing Dialog, e.g. changing `open` prop.
22
+ */
23
+ onRequestClose?: React.ReactEventHandler<HTMLElement>;
24
+ /**
25
+ * Specify whether the Dialog is currently open
26
+ */
27
+ open?: boolean;
28
+ }
29
+ declare const Dialog: React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<unknown>>;
30
+ export { Dialog };
31
+ export default Dialog;
@@ -6,7 +6,6 @@
6
6
  */
7
7
  import React, { ReactNode } from 'react';
8
8
  import { UseSelectProps } from 'downshift';
9
- import { ReactNodeLike } from 'prop-types';
10
9
  import { type ListBoxMenuIconTranslationKey, ListBoxSize, ListBoxType } from '../ListBox';
11
10
  import { ReactAttr } from '../../types/common';
12
11
  type ExcludedAttributes = 'id' | 'onChange';
@@ -40,7 +39,7 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
40
39
  * Provide helper text that is used alongside the control label for
41
40
  * additional help
42
41
  */
43
- helperText?: React.ReactNode;
42
+ helperText?: ReactNode;
44
43
  /**
45
44
  * Specify whether the title text should be hidden or not
46
45
  */
@@ -61,7 +60,7 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
61
60
  /**
62
61
  * Message which is displayed if the value is invalid.
63
62
  */
64
- invalidText?: React.ReactNode;
63
+ invalidText?: ReactNode;
65
64
  /**
66
65
  * Function to render items as custom components instead of strings.
67
66
  * Defaults to null and is overridden by a getter
@@ -114,12 +113,12 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
114
113
  /**
115
114
  * **Experimental**: Provide a `Slug` component to be rendered inside the `Dropdown` component
116
115
  */
117
- slug?: ReactNodeLike;
116
+ slug?: ReactNode;
118
117
  /**
119
118
  * Provide the title text that will be read by a screen reader when
120
119
  * visiting this control
121
120
  */
122
- titleText?: React.ReactNode;
121
+ titleText?: ReactNode;
123
122
  /**
124
123
  * Callback function for translating ListBoxMenuIcon SVG title
125
124
  */
@@ -135,7 +134,7 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
135
134
  /**
136
135
  * Provide the text that is displayed when the control is in warning state
137
136
  */
138
- warnText?: React.ReactNode;
137
+ warnText?: ReactNode;
139
138
  }
140
139
  export type DropdownTranslationKey = ListBoxMenuIconTranslationKey;
141
140
  type DropdownComponentProps<ItemType> = React.PropsWithoutRef<React.PropsWithChildren<DropdownProps<ItemType>> & React.RefAttributes<HTMLButtonElement>>;
@@ -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 { ReactNodeLike } from 'prop-types';
8
- import React from 'react';
7
+ import React, { ReactNode } from 'react';
9
8
  import { ButtonSize } from '../Button';
10
9
  export declare const IconButtonKinds: readonly ["primary", "secondary", "ghost", "tertiary"];
11
10
  export type IconButtonKind = (typeof IconButtonKinds)[number];
@@ -17,7 +16,7 @@ interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>
17
16
  /**
18
17
  * Provide an icon or asset to be rendered inside of the IconButton
19
18
  */
20
- children?: React.ReactNode;
19
+ children?: ReactNode;
21
20
  /**
22
21
  * Specify an optional className to be added to your Button
23
22
  */
@@ -52,7 +51,7 @@ interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>
52
51
  * This means that if you have text in the child node it will not be
53
52
  * announced to the screen reader.
54
53
  */
55
- label: ReactNodeLike;
54
+ label: ReactNode;
56
55
  /**
57
56
  * Specify the duration in milliseconds to delay before hiding the tooltip
58
57
  */
@@ -27,7 +27,8 @@ const defaultTranslateWithId = id => defaultTranslations[id];
27
27
  * `ListBoxTrigger` is used to orient the icon up or down depending on the
28
28
  * state of the menu for a given `ListBox`
29
29
  */
30
- const ListBoxTrigger = _ref => {
30
+
31
+ const ListBoxTrigger = /*#__PURE__*/React__default.forwardRef(function ListBoxTrigger(_ref, ref) {
31
32
  let {
32
33
  isOpen,
33
34
  translateWithId: t = defaultTranslateWithId,
@@ -44,9 +45,10 @@ const ListBoxTrigger = _ref => {
44
45
  title: description,
45
46
  className: className,
46
47
  type: "button",
47
- tabIndex: "-1"
48
+ tabIndex: "-1",
49
+ ref: ref
48
50
  }), _ChevronDown || (_ChevronDown = /*#__PURE__*/React__default.createElement(ChevronDown, null)));
49
- };
51
+ });
50
52
  ListBoxTrigger.propTypes = {
51
53
  /**
52
54
  * Specify whether the menu is currently open, which will influence the
@@ -130,7 +130,7 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, forwardRef) {
130
130
  }
131
131
  }
132
132
  function focusItem(e) {
133
- const currentItem = focusableItems.findIndex(item => item.ref.current.contains(document.activeElement));
133
+ const currentItem = focusableItems.findIndex(item => item.ref?.current?.contains(document.activeElement));
134
134
  let indexToFocus = currentItem;
135
135
 
136
136
  // if currentItem is -1, no menu item is focused yet.
@@ -24,6 +24,7 @@ import { ArrowRight, Enter, Space } from '../../internal/keyboard/keys.js';
24
24
 
25
25
  var _CaretLeft, _CaretRight;
26
26
  const hoverIntentDelay = 150; // in ms
27
+ const leaveIntentDelay = 300; // in ms
27
28
 
28
29
  const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
29
30
  let {
@@ -49,6 +50,7 @@ const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
49
50
  const hasChildren = Boolean(children);
50
51
  const [submenuOpen, setSubmenuOpen] = useState(false);
51
52
  const hoverIntentTimeout = useRef(null);
53
+ const leaveIntentTimeout = useRef(null);
52
54
  const isDisabled = disabled && !hasChildren;
53
55
  const isDanger = kind === 'danger' && !hasChildren;
54
56
  function registerItem() {
@@ -103,6 +105,11 @@ const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
103
105
  }
104
106
  }
105
107
  function handleMouseEnter() {
108
+ if (leaveIntentTimeout.current) {
109
+ // When mouse reenters before closing keep sub menu open
110
+ clearTimeout(leaveIntentTimeout.current);
111
+ leaveIntentTimeout.current = null;
112
+ }
106
113
  hoverIntentTimeout.current = setTimeout(() => {
107
114
  openSubmenu();
108
115
  }, hoverIntentDelay);
@@ -110,8 +117,12 @@ const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
110
117
  function handleMouseLeave() {
111
118
  if (hoverIntentTimeout.current) {
112
119
  clearTimeout(hoverIntentTimeout.current);
113
- closeSubmenu();
114
- menuItem.current?.focus();
120
+ // Avoid closing the sub menu as soon as mouse leaves
121
+ // prevents accidental closure due to scroll bar
122
+ leaveIntentTimeout.current = setTimeout(() => {
123
+ closeSubmenu();
124
+ menuItem.current?.focus();
125
+ }, leaveIntentDelay);
115
126
  }
116
127
  }
117
128
  function handleKeyDown(e) {
@@ -4,14 +4,13 @@
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 { ReactNodeLike } from 'prop-types';
8
- import React from 'react';
7
+ import React, { ReactNode } from 'react';
9
8
  import { ReactAttr } from '../../types/common';
10
9
  import { InlineLoadingStatus } from '../InlineLoading/InlineLoading';
11
10
  export declare const ModalSizes: readonly ["xs", "sm", "md", "lg"];
12
11
  export type ModalSize = (typeof ModalSizes)[number];
13
12
  export interface ModalSecondaryButton {
14
- buttonText?: string | React.ReactNode;
13
+ buttonText?: string | ReactNode;
15
14
  onClick?: React.MouseEventHandler<HTMLButtonElement>;
16
15
  }
17
16
  export interface ModalProps extends ReactAttr<HTMLDivElement> {
@@ -27,7 +26,7 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
27
26
  /**
28
27
  * Provide the contents of your Modal
29
28
  */
30
- children?: React.ReactNode;
29
+ children?: ReactNode;
31
30
  /**
32
31
  * Specify an optional className to be applied to the modal root node
33
32
  */
@@ -75,11 +74,11 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
75
74
  /**
76
75
  * Specify the content of the modal header title.
77
76
  */
78
- modalHeading?: React.ReactNode;
77
+ modalHeading?: ReactNode;
79
78
  /**
80
79
  * Specify the content of the modal header label.
81
80
  */
82
- modalLabel?: React.ReactNode;
81
+ modalLabel?: ReactNode;
83
82
  /**
84
83
  * Specify a handler for keypresses.
85
84
  * @deprecated this property is unused
@@ -124,11 +123,11 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
124
123
  /**
125
124
  * Specify the text for the primary button
126
125
  */
127
- primaryButtonText?: React.ReactNode;
126
+ primaryButtonText?: ReactNode;
128
127
  /**
129
128
  * Specify the text for the secondary button
130
129
  */
131
- secondaryButtonText?: React.ReactNode;
130
+ secondaryButtonText?: ReactNode;
132
131
  /**
133
132
  * Specify an array of config objects for secondary buttons
134
133
  */
@@ -154,7 +153,7 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
154
153
  /**
155
154
  * **Experimental**: Provide a `Slug` component to be rendered inside the `Modal` component
156
155
  */
157
- slug?: ReactNodeLike;
156
+ slug?: ReactNode;
158
157
  }
159
158
  declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<HTMLDivElement>>;
160
159
  export default Modal;