@carbon/react 1.24.0 → 1.26.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 (197) hide show
  1. package/es/components/Button/Button.js +2 -2
  2. package/es/components/CodeSnippet/CodeSnippet.js +13 -115
  3. package/es/components/ComboBox/ComboBox.d.ts +6 -0
  4. package/es/components/ComboBox/ComboBox.js +19 -172
  5. package/es/components/ComboButton/index.js +164 -0
  6. package/es/components/ComposedModal/ComposedModal.js +1 -2
  7. package/es/components/DataTable/Table.d.ts +74 -0
  8. package/es/components/DataTable/Table.js +4 -2
  9. package/es/components/DataTable/TableCell.d.ts +10 -0
  10. package/es/components/DataTable/TableContext.d.ts +13 -0
  11. package/es/components/DataTable/TableContext.js +2 -2
  12. package/es/components/DataTable/TableExpandRow.d.ts +67 -0
  13. package/es/components/DataTable/TableExpandedRow.d.ts +32 -0
  14. package/es/components/DataTable/TableHead.d.ts +10 -0
  15. package/es/components/DataTable/TableHeader.d.ts +64 -0
  16. package/es/components/DataTable/TableHeader.js +23 -28
  17. package/es/components/DataTable/TableRow.d.ts +32 -0
  18. package/es/components/DataTable/TableSelectAll.js +1 -1
  19. package/es/components/DataTable/TableSelectRow.js +1 -3
  20. package/es/components/DataTable/TableToolbar.d.ts +19 -0
  21. package/es/components/DataTable/TableToolbar.js +1 -1
  22. package/es/components/DataTable/TableToolbarAction.d.ts +21 -0
  23. package/es/components/DataTable/TableToolbarContent.d.ts +19 -0
  24. package/es/components/DataTable/TableToolbarMenu.d.ts +24 -0
  25. package/es/components/DataTable/TableToolbarMenu.js +3 -3
  26. package/es/components/DataTable/TableToolbarSearch.js +1 -0
  27. package/es/components/DataTable/tools/sorting.js +2 -1
  28. package/es/components/DataTableSkeleton/DataTableSkeleton.d.ts +107 -0
  29. package/es/components/Dropdown/Dropdown.d.ts +6 -0
  30. package/es/components/Dropdown/Dropdown.js +8 -145
  31. package/es/components/ExpandableSearch/ExpandableSearch.js +1 -0
  32. package/es/components/FileUploader/FileUploader.js +1 -1
  33. package/es/components/FileUploader/FileUploaderButton.js +2 -0
  34. package/es/components/FileUploader/FileUploaderDropContainer.js +30 -18
  35. package/es/components/FileUploader/FileUploaderItem.js +2 -1
  36. package/es/components/FileUploader/Filename.js +8 -2
  37. package/es/components/FluidTextArea/FluidTextArea.js +12 -1
  38. package/es/components/IconButton/index.js +1 -0
  39. package/es/components/InlineCheckbox/InlineCheckbox.js +7 -53
  40. package/es/components/ListBox/ListBoxSelection.js +4 -23
  41. package/es/components/ListBox/next/ListBoxSelection.js +2 -23
  42. package/es/components/Menu/Menu.js +50 -29
  43. package/es/components/Menu/MenuItem.js +1 -0
  44. package/es/components/MenuButton/index.js +127 -0
  45. package/es/components/Modal/Modal.js +4 -3
  46. package/es/components/MultiSelect/FilterableMultiSelect.js +46 -144
  47. package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
  48. package/es/components/MultiSelect/MultiSelect.js +48 -28
  49. package/es/components/Notification/Notification.js +27 -264
  50. package/es/components/NumberInput/NumberInput.js +9 -1
  51. package/es/components/OverflowMenu/OverflowMenu.js +13 -139
  52. package/es/components/OverflowMenuItem/OverflowMenuItem.d.ts +58 -0
  53. package/es/components/OverflowMenuItem/OverflowMenuItem.js +12 -7
  54. package/es/components/OverflowMenuV2/index.js +15 -51
  55. package/es/components/Popover/index.d.ts +5 -1
  56. package/es/components/Popover/index.js +37 -9
  57. package/es/components/RadioButton/RadioButton.Skeleton.d.ts +25 -0
  58. package/es/components/RadioButton/RadioButton.Skeleton.js +3 -3
  59. package/es/components/RadioButton/RadioButton.d.ts +64 -0
  60. package/es/components/RadioButton/RadioButton.js +19 -17
  61. package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +80 -0
  62. package/es/components/RadioButtonGroup/RadioButtonGroup.js +88 -26
  63. package/es/components/RadioTile/RadioTile.js +6 -6
  64. package/es/components/Search/Search.Skeleton.d.ts +36 -0
  65. package/es/components/Search/Search.js +3 -2
  66. package/es/components/Search/index.js +1 -0
  67. package/es/components/Select/Select.d.ts +89 -0
  68. package/es/components/SelectItem/SelectItem.d.ts +62 -0
  69. package/es/components/SelectItem/SelectItem.js +2 -4
  70. package/es/components/SelectItemGroup/SelectItemGroup.d.ts +52 -0
  71. package/es/components/SkeletonText/SkeletonText.js +1 -1
  72. package/es/components/StructuredList/StructuredList.js +11 -39
  73. package/es/components/Tabs/Tabs.js +29 -6
  74. package/es/components/TextArea/TextArea.Skeleton.d.ts +33 -0
  75. package/es/components/TextArea/TextArea.Skeleton.js +5 -5
  76. package/es/components/TextArea/TextArea.d.ts +9 -2
  77. package/es/components/TextArea/TextArea.js +31 -8
  78. package/es/components/TextArea/index.js +1 -0
  79. package/es/components/TextInput/TextInput.Skeleton.d.ts +33 -0
  80. package/es/components/TextInput/index.js +1 -0
  81. package/es/components/Tile/Tile.js +15 -8
  82. package/es/components/Toggle/Toggle.js +8 -19
  83. package/es/components/Tooltip/DefinitionTooltip.d.ts +52 -0
  84. package/es/components/Tooltip/DefinitionTooltip.js +2 -2
  85. package/es/components/Tooltip/Tooltip.d.ts +117 -0
  86. package/es/components/Tooltip/Tooltip.js +6 -4
  87. package/es/components/Tooltip/index.d.ts +9 -0
  88. package/es/components/UIShell/HeaderMenu.js +13 -4
  89. package/es/components/UIShell/HeaderMenuItem.js +17 -4
  90. package/es/index.d.ts +2 -0
  91. package/es/index.js +5 -3
  92. package/es/internal/ClickListener.js +1 -2
  93. package/es/internal/keyboard/match.js +1 -1
  94. package/es/internal/useAttachedMenu.js +85 -0
  95. package/es/internal/useDelayedState.d.ts +19 -0
  96. package/es/internal/useDelayedState.js +7 -3
  97. package/es/internal/useId.js +1 -1
  98. package/es/tools/wrapComponent.js +9 -0
  99. package/lib/components/Button/Button.js +2 -2
  100. package/lib/components/CodeSnippet/CodeSnippet.js +13 -115
  101. package/lib/components/ComboBox/ComboBox.d.ts +6 -0
  102. package/lib/components/ComboBox/ComboBox.js +18 -171
  103. package/lib/components/ComboButton/index.js +174 -0
  104. package/lib/components/ComposedModal/ComposedModal.js +1 -2
  105. package/lib/components/DataTable/Table.d.ts +74 -0
  106. package/lib/components/DataTable/Table.js +4 -2
  107. package/lib/components/DataTable/TableCell.d.ts +10 -0
  108. package/lib/components/DataTable/TableContext.d.ts +13 -0
  109. package/lib/components/DataTable/TableContext.js +2 -2
  110. package/lib/components/DataTable/TableExpandRow.d.ts +67 -0
  111. package/lib/components/DataTable/TableExpandedRow.d.ts +32 -0
  112. package/lib/components/DataTable/TableHead.d.ts +10 -0
  113. package/lib/components/DataTable/TableHeader.d.ts +64 -0
  114. package/lib/components/DataTable/TableHeader.js +23 -28
  115. package/lib/components/DataTable/TableRow.d.ts +32 -0
  116. package/lib/components/DataTable/TableSelectAll.js +1 -1
  117. package/lib/components/DataTable/TableSelectRow.js +1 -3
  118. package/lib/components/DataTable/TableToolbar.d.ts +19 -0
  119. package/lib/components/DataTable/TableToolbar.js +1 -1
  120. package/lib/components/DataTable/TableToolbarAction.d.ts +21 -0
  121. package/lib/components/DataTable/TableToolbarContent.d.ts +19 -0
  122. package/lib/components/DataTable/TableToolbarMenu.d.ts +24 -0
  123. package/lib/components/DataTable/TableToolbarMenu.js +3 -3
  124. package/lib/components/DataTable/TableToolbarSearch.js +1 -0
  125. package/lib/components/DataTable/tools/sorting.js +2 -1
  126. package/lib/components/DataTableSkeleton/DataTableSkeleton.d.ts +107 -0
  127. package/lib/components/Dropdown/Dropdown.d.ts +6 -0
  128. package/lib/components/Dropdown/Dropdown.js +7 -144
  129. package/lib/components/ExpandableSearch/ExpandableSearch.js +1 -0
  130. package/lib/components/FileUploader/FileUploader.js +1 -1
  131. package/lib/components/FileUploader/FileUploaderButton.js +2 -0
  132. package/lib/components/FileUploader/FileUploaderDropContainer.js +30 -18
  133. package/lib/components/FileUploader/FileUploaderItem.js +2 -1
  134. package/lib/components/FileUploader/Filename.js +8 -2
  135. package/lib/components/FluidTextArea/FluidTextArea.js +12 -1
  136. package/lib/components/IconButton/index.js +1 -0
  137. package/lib/components/InlineCheckbox/InlineCheckbox.js +7 -53
  138. package/lib/components/ListBox/ListBoxSelection.js +4 -23
  139. package/lib/components/ListBox/next/ListBoxSelection.js +2 -23
  140. package/lib/components/Menu/Menu.js +50 -29
  141. package/lib/components/Menu/MenuItem.js +1 -0
  142. package/lib/components/MenuButton/index.js +137 -0
  143. package/lib/components/Modal/Modal.js +4 -3
  144. package/lib/components/MultiSelect/FilterableMultiSelect.js +43 -141
  145. package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
  146. package/lib/components/MultiSelect/MultiSelect.js +47 -27
  147. package/lib/components/Notification/Notification.js +27 -264
  148. package/lib/components/NumberInput/NumberInput.js +9 -1
  149. package/lib/components/OverflowMenu/OverflowMenu.js +13 -139
  150. package/lib/components/OverflowMenuItem/OverflowMenuItem.d.ts +58 -0
  151. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +12 -7
  152. package/lib/components/OverflowMenuV2/index.js +13 -49
  153. package/lib/components/Popover/index.d.ts +5 -1
  154. package/lib/components/Popover/index.js +37 -9
  155. package/lib/components/RadioButton/RadioButton.Skeleton.d.ts +25 -0
  156. package/lib/components/RadioButton/RadioButton.Skeleton.js +3 -3
  157. package/lib/components/RadioButton/RadioButton.d.ts +64 -0
  158. package/lib/components/RadioButton/RadioButton.js +18 -16
  159. package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +80 -0
  160. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +86 -24
  161. package/lib/components/RadioTile/RadioTile.js +6 -6
  162. package/lib/components/Search/Search.Skeleton.d.ts +36 -0
  163. package/lib/components/Search/Search.js +3 -2
  164. package/lib/components/Search/index.js +2 -0
  165. package/lib/components/Select/Select.d.ts +89 -0
  166. package/lib/components/SelectItem/SelectItem.d.ts +62 -0
  167. package/lib/components/SelectItem/SelectItem.js +1 -3
  168. package/lib/components/SelectItemGroup/SelectItemGroup.d.ts +52 -0
  169. package/lib/components/SkeletonText/SkeletonText.js +1 -1
  170. package/lib/components/StructuredList/StructuredList.js +11 -39
  171. package/lib/components/Tabs/Tabs.js +29 -6
  172. package/lib/components/TextArea/TextArea.Skeleton.d.ts +33 -0
  173. package/lib/components/TextArea/TextArea.Skeleton.js +5 -5
  174. package/lib/components/TextArea/TextArea.d.ts +9 -2
  175. package/lib/components/TextArea/TextArea.js +30 -7
  176. package/lib/components/TextArea/index.js +2 -0
  177. package/lib/components/TextInput/TextInput.Skeleton.d.ts +33 -0
  178. package/lib/components/TextInput/index.js +2 -0
  179. package/lib/components/Tile/Tile.js +15 -8
  180. package/lib/components/Toggle/Toggle.js +8 -19
  181. package/lib/components/Tooltip/DefinitionTooltip.d.ts +52 -0
  182. package/lib/components/Tooltip/DefinitionTooltip.js +2 -2
  183. package/lib/components/Tooltip/Tooltip.d.ts +117 -0
  184. package/lib/components/Tooltip/Tooltip.js +6 -4
  185. package/lib/components/Tooltip/index.d.ts +9 -0
  186. package/lib/components/UIShell/HeaderMenu.js +13 -4
  187. package/lib/components/UIShell/HeaderMenuItem.js +17 -4
  188. package/lib/index.d.ts +2 -0
  189. package/lib/index.js +50 -46
  190. package/lib/internal/ClickListener.js +1 -2
  191. package/lib/internal/keyboard/match.js +1 -1
  192. package/lib/internal/useAttachedMenu.js +89 -0
  193. package/lib/internal/useDelayedState.d.ts +19 -0
  194. package/lib/internal/useDelayedState.js +7 -3
  195. package/lib/internal/useId.js +1 -1
  196. package/lib/tools/wrapComponent.js +9 -0
  197. package/package.json +3 -3
@@ -0,0 +1,117 @@
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
+ import { PopoverAlignment } from '../Popover';
10
+ import { PolymorphicProps } from '../../types/common';
11
+ interface TooltipBaseProps {
12
+ /**
13
+ * Specify how the trigger should align with the tooltip
14
+ */
15
+ align?: PopoverAlignment;
16
+ /**
17
+ * Pass in the child to which the tooltip will be applied
18
+ */
19
+ children?: React.ReactElement;
20
+ /**
21
+ * Specify an optional className to be applied to the container node
22
+ */
23
+ className?: string;
24
+ /**
25
+ * Determines wether the tooltip should close when inner content is activated (click, Enter or Space)
26
+ */
27
+ closeOnActivation?: boolean;
28
+ /**
29
+ * Specify whether the tooltip should be open when it first renders
30
+ */
31
+ defaultOpen?: boolean;
32
+ /**
33
+ * Provide the description to be rendered inside of the Tooltip. The
34
+ * description will use `aria-describedby` and will describe the child node
35
+ * in addition to the text rendered inside of the child. This means that if you
36
+ * have text in the child node, that it will be announced alongside the
37
+ * description to the screen reader.
38
+ *
39
+ * Note: if label and description are both provided, label will be used and
40
+ * description will not be used
41
+ */
42
+ description?: React.ReactNode;
43
+ /**
44
+ * Specify the duration in milliseconds to delay before displaying the tooltip
45
+ */
46
+ enterDelayMs?: number;
47
+ /**
48
+ * Provide the label to be rendered inside of the Tooltip. The label will use
49
+ * `aria-labelledby` and will fully describe the child node that is provided.
50
+ * This means that if you have text in the child node, that it will not be
51
+ * announced to the screen reader.
52
+ *
53
+ * Note: if label and description are both provided, description will not be
54
+ * used
55
+ */
56
+ label?: React.ReactNode;
57
+ /**
58
+ * Specify the duration in milliseconds to delay before hiding the tooltip
59
+ */
60
+ leaveDelayMs?: number;
61
+ }
62
+ export type TooltipProps<T extends React.ElementType> = PolymorphicProps<T, TooltipBaseProps>;
63
+ declare function Tooltip<T extends React.ElementType>({ align, className: customClassName, children, label, description, enterDelayMs, leaveDelayMs, defaultOpen, closeOnActivation, ...rest }: TooltipProps<T>): JSX.Element;
64
+ declare namespace Tooltip {
65
+ var propTypes: {
66
+ /**
67
+ * Specify how the trigger should align with the tooltip
68
+ */
69
+ align: PropTypes.Requireable<string>;
70
+ /**
71
+ * Pass in the child to which the tooltip will be applied
72
+ */
73
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
74
+ /**
75
+ * Specify an optional className to be applied to the container node
76
+ */
77
+ className: PropTypes.Requireable<string>;
78
+ /**
79
+ * Determines wether the tooltip should close when inner content is activated (click, Enter or Space)
80
+ */
81
+ closeOnActivation: PropTypes.Requireable<boolean>;
82
+ /**
83
+ * Specify whether the tooltip should be open when it first renders
84
+ */
85
+ defaultOpen: PropTypes.Requireable<boolean>;
86
+ /**
87
+ * Provide the description to be rendered inside of the Tooltip. The
88
+ * description will use `aria-describedby` and will describe the child node
89
+ * in addition to the text rendered inside of the child. This means that if you
90
+ * have text in the child node, that it will be announced alongside the
91
+ * description to the screen reader.
92
+ *
93
+ * Note: if label and description are both provided, label will be used and
94
+ * description will not be used
95
+ */
96
+ description: PropTypes.Requireable<PropTypes.ReactNodeLike>;
97
+ /**
98
+ * Specify the duration in milliseconds to delay before displaying the tooltip
99
+ */
100
+ enterDelayMs: PropTypes.Requireable<number>;
101
+ /**
102
+ * Provide the label to be rendered inside of the Tooltip. The label will use
103
+ * `aria-labelledby` and will fully describe the child node that is provided.
104
+ * This means that if you have text in the child node, that it will not be
105
+ * announced to the screen reader.
106
+ *
107
+ * Note: if label and description are both provided, description will not be
108
+ * used
109
+ */
110
+ label: PropTypes.Requireable<PropTypes.ReactNodeLike>;
111
+ /**
112
+ * Specify the duration in milliseconds to delay before hiding the tooltip
113
+ */
114
+ leaveDelayMs: PropTypes.Requireable<number>;
115
+ };
116
+ }
117
+ export { Tooltip };
@@ -103,10 +103,12 @@ function Tooltip(_ref) {
103
103
 
104
104
  useNoInteractiveChildren(tooltipRef, 'The Tooltip component must have no interactive content rendered by the' + '`label` or `description` prop');
105
105
  useEffect(function () {
106
- var interactiveContent = getInteractiveContent(containerRef.current);
106
+ if (containerRef !== null && containerRef.current) {
107
+ var interactiveContent = getInteractiveContent(containerRef.current);
107
108
 
108
- if (!interactiveContent) {
109
- setOpen(false);
109
+ if (!interactiveContent) {
110
+ setOpen(false);
111
+ }
110
112
  }
111
113
  });
112
114
  return /*#__PURE__*/React__default.createElement(Popover, _extends({}, rest, {
@@ -118,7 +120,7 @@ function Tooltip(_ref) {
118
120
  onMouseLeave: onMouseLeave,
119
121
  open: open,
120
122
  ref: containerRef
121
- }), /*#__PURE__*/React__default.cloneElement(child, _objectSpread2(_objectSpread2({}, triggerProps), getChildEventHandlers(child.props))), /*#__PURE__*/React__default.createElement(PopoverContent, {
123
+ }), child !== undefined ? /*#__PURE__*/React__default.cloneElement(child, _objectSpread2(_objectSpread2({}, triggerProps), getChildEventHandlers(child.props))) : null, /*#__PURE__*/React__default.createElement(PopoverContent, {
122
124
  "aria-hidden": "true",
123
125
  className: "".concat(prefix, "--tooltip-content"),
124
126
  id: id,
@@ -0,0 +1,9 @@
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 { DefinitionTooltip } from './DefinitionTooltip';
8
+ import { Tooltip } from './Tooltip';
9
+ export { DefinitionTooltip, Tooltip };
@@ -12,10 +12,11 @@ import React__default from 'react';
12
12
  import PropTypes from 'prop-types';
13
13
  import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
14
14
  import { PrefixContext } from '../../internal/usePrefix.js';
15
+ import deprecate from '../../prop-types/deprecate.js';
15
16
  import { matches } from '../../internal/keyboard/match.js';
16
17
  import { Enter, Space, Escape } from '../../internal/keyboard/keys.js';
17
18
 
18
- var _excluded = ["isCurrentPage", "aria-label", "aria-labelledby", "className", "children", "renderMenuContent", "menuLinkName", "focusRef"];
19
+ var _excluded = ["isActive", "isCurrentPage", "aria-label", "aria-labelledby", "className", "children", "renderMenuContent", "menuLinkName", "focusRef"];
19
20
  /**
20
21
  * `HeaderMenu` is used to render submenu's in the `Header`. Most often children
21
22
  * will be a `HeaderMenuItem`. It handles certain keyboard events to help
@@ -149,6 +150,7 @@ var HeaderMenu = /*#__PURE__*/function (_React$Component) {
149
150
  var prefix = this.context;
150
151
 
151
152
  var _this$props = this.props,
153
+ isActive = _this$props.isActive,
152
154
  isCurrentPage = _this$props.isCurrentPage,
153
155
  ariaLabel = _this$props['aria-label'],
154
156
  ariaLabelledBy = _this$props['aria-labelledby'],
@@ -164,7 +166,8 @@ var HeaderMenu = /*#__PURE__*/function (_React$Component) {
164
166
  'aria-labelledby': ariaLabelledBy
165
167
  };
166
168
  var itemClassName = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--header__submenu"), true), _defineProperty(_cx, customClassName, !!customClassName), _cx));
167
- var linkClassName = cx((_cx2 = {}, _defineProperty(_cx2, "".concat(prefix, "--header__menu-item"), true), _defineProperty(_cx2, "".concat(prefix, "--header__menu-title"), true), _defineProperty(_cx2, "".concat(prefix, "--header__menu-item--current"), isCurrentPage), _cx2)); // Notes on eslint comments and based on the examples in:
169
+ var isActivePage = isActive ? isActive : isCurrentPage;
170
+ var linkClassName = cx((_cx2 = {}, _defineProperty(_cx2, "".concat(prefix, "--header__menu-item"), true), _defineProperty(_cx2, "".concat(prefix, "--header__menu-title"), true), _defineProperty(_cx2, "".concat(prefix, "--header__menu-item--current"), isActivePage), _cx2)); // Notes on eslint comments and based on the examples in:
168
171
  // https://www.w3.org/TR/wai-aria-practices/examples/menubar/menubar-1/menubar-1.html#
169
172
  // - The focus is handled by the <a> menuitem, onMouseOver is for mouse
170
173
  // users
@@ -218,9 +221,15 @@ _defineProperty(HeaderMenu, "propTypes", _objectSpread2(_objectSpread2({}, AriaL
218
221
  focusRef: PropTypes.func,
219
222
 
220
223
  /**
221
- * Applies selected styles to the item if a user sets this to true and aria-current !== 'page'.
224
+ * Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
222
225
  */
223
- isCurrentPage: PropTypes.bool,
226
+ isActive: PropTypes.bool,
227
+
228
+ /**
229
+ * Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
230
+ * @deprecated Please use `isActive` instead. This will be removed in the next major release.
231
+ */
232
+ isCurrentPage: deprecate(PropTypes.bool, 'The `isCurrentPage` prop for `HeaderMenu` has ' + 'been deprecated. Please use `isActive` instead. This will be removed in the next major release.'),
224
233
 
225
234
  /**
226
235
  * Provide a label for the link text
@@ -11,12 +11,14 @@ import React__default from 'react';
11
11
  import cx from 'classnames';
12
12
  import Link, { LinkPropTypes } from './Link.js';
13
13
  import { usePrefix } from '../../internal/usePrefix.js';
14
+ import deprecate from '../../prop-types/deprecate.js';
14
15
 
15
- var _excluded = ["className", "isCurrentPage", "aria-current", "children", "role", "tabIndex"];
16
+ var _excluded = ["className", "isActive", "isCurrentPage", "aria-current", "children", "role", "tabIndex"];
16
17
  var HeaderMenuItem = /*#__PURE__*/React__default.forwardRef(function HeaderMenuItem(_ref, ref) {
17
18
  var _cx;
18
19
 
19
20
  var className = _ref.className,
21
+ isActive = _ref.isActive,
20
22
  isCurrentPage = _ref.isCurrentPage,
21
23
  ariaCurrent = _ref['aria-current'],
22
24
  children = _ref.children,
@@ -26,7 +28,12 @@ var HeaderMenuItem = /*#__PURE__*/React__default.forwardRef(function HeaderMenuI
26
28
  rest = _objectWithoutProperties(_ref, _excluded);
27
29
 
28
30
  var prefix = usePrefix();
29
- var linkClassName = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--header__menu-item"), true), _defineProperty(_cx, "".concat(prefix, "--header__menu-item--current"), isCurrentPage && ariaCurrent !== 'page'), _cx));
31
+
32
+ if (isCurrentPage) {
33
+ isActive = isCurrentPage;
34
+ }
35
+
36
+ var linkClassName = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--header__menu-item"), true), _defineProperty(_cx, "".concat(prefix, "--header__menu-item--current"), isActive && ariaCurrent !== 'page'), _cx));
30
37
  return /*#__PURE__*/React__default.createElement("li", {
31
38
  className: className,
32
39
  role: role
@@ -53,9 +60,15 @@ HeaderMenuItem.propTypes = _objectSpread2(_objectSpread2({}, LinkPropTypes), {},
53
60
  className: PropTypes.string,
54
61
 
55
62
  /**
56
- * Applies selected styles to the item if a user sets this to true and aria-current !== 'page'.
63
+ * Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
64
+ */
65
+ isActive: PropTypes.bool,
66
+
67
+ /**
68
+ * Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
69
+ * @deprecated Please use `isActive` instead. This will be removed in the next major release.
57
70
  */
58
- isCurrentPage: PropTypes.bool,
71
+ isCurrentPage: deprecate(PropTypes.bool, 'The `isCurrentPage` prop for `HeaderMenuItem` has ' + 'been deprecated. Please use `isActive` instead. This will be removed in the next major release.'),
59
72
 
60
73
  /**
61
74
  * Optionally supply a role for the underlying `<li>` node. Useful for resetting
package/es/index.d.ts CHANGED
@@ -107,6 +107,8 @@ export * from './components/Layer';
107
107
  export { LayoutDirection as unstable_LayoutDirection, useLayoutDirection as unstable_useLayoutDirection, } from './components/Layout';
108
108
  export { Menu as unstable_Menu, MenuItem as unstable_MenuItem, MenuItemDivider as unstable_MenuItemDivider, MenuItemGroup as unstable_MenuItemGroup, MenuItemRadioGroup as unstable_MenuItemRadioGroup, MenuItemSelectable as unstable_MenuItemSelectable, } from './components/Menu';
109
109
  export { OverflowMenuV2 as unstable_OverflowMenuV2 } from './components/OverflowMenuV2';
110
+ export { ComboButton as unstable_ComboButton } from './components/ComboButton';
111
+ export { MenuButton as unstable_MenuButton } from './components/MenuButton';
110
112
  export { PageSelector as unstable_PageSelector, Pagination as unstable_Pagination, } from './components/Pagination/experimental';
111
113
  export * from './components/Popover';
112
114
  export * from './components/ProgressBar';
package/es/index.js CHANGED
@@ -37,10 +37,13 @@ export { Heading, Section } from './components/Heading/index.js';
37
37
  export { IconButton } from './components/IconButton/index.js';
38
38
  export { Layer, useLayer } from './components/Layer/index.js';
39
39
  export { OverflowMenuV2 as unstable_OverflowMenuV2 } from './components/OverflowMenuV2/index.js';
40
+ export { ComboButton as unstable_ComboButton } from './components/ComboButton/index.js';
41
+ export { MenuButton as unstable_MenuButton } from './components/MenuButton/index.js';
40
42
  export { Popover, PopoverContent } from './components/Popover/index.js';
41
43
  export { HStack, VStack } from './components/Stack/index.js';
42
- import './components/Text/index.js';
43
44
  export { DefinitionTooltip } from './components/Tooltip/DefinitionTooltip.js';
45
+ export { Tooltip } from './components/Tooltip/Tooltip.js';
46
+ import './components/Text/index.js';
44
47
  export { GlobalTheme, Theme, ThemeContext, useTheme } from './components/Theme/index.js';
45
48
  export { PrefixContext, usePrefix } from './internal/usePrefix.js';
46
49
  export { useIdPrefix } from './internal/useIdPrefix.js';
@@ -76,7 +79,6 @@ export { default as NumberInputSkeleton } from './components/NumberInput/NumberI
76
79
  export { default as ProgressIndicatorSkeleton } from './components/ProgressIndicator/ProgressIndicator.Skeleton.js';
77
80
  export { default as ExpandableSearch } from './components/ExpandableSearch/ExpandableSearch.js';
78
81
  export { default as TabsSkeleton } from './components/Tabs/Tabs.Skeleton.js';
79
- export { default as RadioTile } from './components/RadioTile/RadioTile.js';
80
82
  export { Toggle } from './components/Toggle/Toggle.js';
81
83
  export { default as TreeNode } from './components/TreeView/TreeNode.js';
82
84
  export { default as TreeView } from './components/TreeView/TreeView.js';
@@ -185,6 +187,7 @@ export { default as TextArea } from './components/TextArea/TextArea.js';
185
187
  export { default as TextInputSkeleton } from './components/TextInput/TextInput.Skeleton.js';
186
188
  export { default as TextInput } from './components/TextInput/TextInput.js';
187
189
  export { ClickableTile, ExpandableTile, SelectableTile, Tile, TileAboveTheFoldContent, TileBelowTheFoldContent } from './components/Tile/Tile.js';
190
+ export { default as RadioTile } from './components/RadioTile/RadioTile.js';
188
191
  export { default as TimePicker } from './components/TimePicker/TimePicker.js';
189
192
  export { default as UnorderedList } from './components/UnorderedList/UnorderedList.js';
190
193
  export { default as SkeletonText } from './components/SkeletonText/SkeletonText.js';
@@ -212,4 +215,3 @@ export { default as SideNavMenu } from './components/UIShell/SideNavMenu.js';
212
215
  export { default as SideNavMenuItem } from './components/UIShell/SideNavMenuItem.js';
213
216
  export { default as SideNavSwitcher } from './components/UIShell/SideNavSwitcher.js';
214
217
  export { Stack } from './components/Stack/Stack.js';
215
- export { Tooltip } from './components/Tooltip/Tooltip.js';
@@ -25,8 +25,7 @@ var ClickListener = /*#__PURE__*/function (_React$Component) {
25
25
  _classCallCheck(this, ClickListener);
26
26
 
27
27
  _this = _super.call(this, props); // We manually bind handlers in this Component, versus using class
28
- // properties, so that we can properly test the `handleRef` handler with
29
- // enzyme.
28
+ // properties, so that we can properly test the `handleRef` handler.
30
29
 
31
30
  _this.handleRef = _this.handleRef.bind(_assertThisInitialized(_this));
32
31
  _this.handleDocumentClick = _this.handleDocumentClick.bind(_assertThisInitialized(_this));
@@ -53,7 +53,7 @@ function matches(event, keysToMatch) {
53
53
  * }
54
54
  * }
55
55
  *
56
- * @param {Event|number|string} eventOrCode
56
+ * @param {React.KeyboardEvent|Event|number|string} eventOrCode
57
57
  * @param {Key} key
58
58
  * @returns {boolean}
59
59
  */
@@ -0,0 +1,85 @@
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 { slicedToArray as _slicedToArray } from '../_virtual/_rollupPluginBabelHelpers.js';
9
+ import { useState } from 'react';
10
+
11
+ /**
12
+ * @typedef {object} useAttachedMenuReturn
13
+ * @property {boolean} open Whether the menu is open or not
14
+ * @property {[number, number]} x The x position of the menu
15
+ * @property {[number, number]} y The y position of the menu
16
+ * @property {Function} handleClick A function to be called when the trigger element receives a click event
17
+ * @property {Function} handleMousedown A function to be called when the trigger element recives a mousedown event
18
+ * @property {Function} handleClose A function to be called when the menu emits onClose
19
+ */
20
+
21
+ /**
22
+ * This hook contains common code to be used when a menu should be visually attached to an anchor based on a click event.
23
+ *
24
+ * @param {Element|object} anchor The element or ref the menu should visually be attached to.
25
+ * @returns {useAttachedMenuReturn}
26
+ */
27
+
28
+ function useAttachedMenu(anchor) {
29
+ var _useState = useState(false),
30
+ _useState2 = _slicedToArray(_useState, 2),
31
+ open = _useState2[0],
32
+ setOpen = _useState2[1];
33
+
34
+ var _useState3 = useState([[-1, -1], [-1, -1]]),
35
+ _useState4 = _slicedToArray(_useState3, 2),
36
+ position = _useState4[0],
37
+ setPosition = _useState4[1];
38
+
39
+ function openMenu() {
40
+ var anchorEl = (anchor === null || anchor === void 0 ? void 0 : anchor.current) || anchor;
41
+
42
+ if (anchorEl) {
43
+ var _anchorEl$getBounding = anchorEl.getBoundingClientRect(),
44
+ left = _anchorEl$getBounding.left,
45
+ top = _anchorEl$getBounding.top,
46
+ right = _anchorEl$getBounding.right,
47
+ bottom = _anchorEl$getBounding.bottom;
48
+
49
+ setPosition([[left, right], [top, bottom]]);
50
+ }
51
+
52
+ setOpen(true);
53
+ }
54
+
55
+ function closeMenu() {
56
+ setOpen(false);
57
+ }
58
+
59
+ function handleClick() {
60
+ if (open) {
61
+ closeMenu();
62
+ } else {
63
+ openMenu();
64
+ }
65
+ }
66
+
67
+ function handleMousedown(e) {
68
+ // prevent default for mousedown on trigger element to avoid
69
+ // the "blur" event from firing on the menu as this would close
70
+ // it and immediately re-open since "click" event is fired after
71
+ // "blur" event.
72
+ e.preventDefault();
73
+ }
74
+
75
+ return {
76
+ open: open,
77
+ x: position[0],
78
+ y: position[1],
79
+ handleClick: handleClick,
80
+ handleMousedown: handleMousedown,
81
+ handleClose: closeMenu
82
+ };
83
+ }
84
+
85
+ export { useAttachedMenu };
@@ -0,0 +1,19 @@
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 { SetStateAction } from 'react';
8
+ /**
9
+ * `useDelayedState` mirrors `useState` but also allows you to add a delay to
10
+ * when your state updates. You can provide a second argument to `setState`,
11
+ * `delayMs`, which will be the time in milliseconds after which the state is
12
+ * updated.
13
+ *
14
+ * This hook will clean up pending timers in `useEffect` and will cancel any
15
+ * pending timers when a `setState` is called before the state is updated from
16
+ * a previous call
17
+ */
18
+ export type DispatchWithDelay<A> = (value: A, delayMS?: number) => void;
19
+ export declare function useDelayedState<S>(initialState: S): [S, DispatchWithDelay<SetStateAction<S>>];
@@ -29,8 +29,10 @@ function useDelayedState(initialState) {
29
29
  // always return the same reference for the `setState` updater
30
30
 
31
31
  var setStateWithDelay = useCallback(function (stateToSet) {
32
+ var _timeoutId$current;
33
+
32
34
  var delayMs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
33
- clearTimeout(timeoutId.current);
35
+ window.clearTimeout((_timeoutId$current = timeoutId.current) !== null && _timeoutId$current !== void 0 ? _timeoutId$current : undefined);
34
36
  timeoutId.current = null;
35
37
 
36
38
  if (delayMs === 0) {
@@ -38,14 +40,16 @@ function useDelayedState(initialState) {
38
40
  return;
39
41
  }
40
42
 
41
- timeoutId.current = setTimeout(function () {
43
+ timeoutId.current = window.setTimeout(function () {
42
44
  setState(stateToSet);
43
45
  timeoutId.current = null;
44
46
  }, delayMs);
45
47
  }, []);
46
48
  useEffect(function () {
47
49
  return function () {
48
- clearTimeout(timeoutId.current);
50
+ var _timeoutId$current2;
51
+
52
+ window.clearTimeout((_timeoutId$current2 = timeoutId.current) !== null && _timeoutId$current2 !== void 0 ? _timeoutId$current2 : undefined);
49
53
  };
50
54
  }, []);
51
55
  return [state, setStateWithDelay];
@@ -50,7 +50,7 @@ function useId() {
50
50
  }
51
51
  /**
52
52
  * Generate a unique id if a given `id` is not provided
53
- * @param {string} id
53
+ * @param {string|undefined} id
54
54
  * @returns {string}
55
55
  */
56
56
 
@@ -12,12 +12,21 @@ import cx from 'classnames';
12
12
  import { usePrefix } from '../internal/usePrefix.js';
13
13
 
14
14
  var _excluded = ["className"];
15
+ /**
16
+ * @param {{ name: string, type: string, className?: string | (prefix: string) => string }} props
17
+ * @returns
18
+ */
15
19
 
16
20
  var wrapComponent = function wrapComponent(_ref) {
17
21
  var name = _ref.name,
18
22
  getClassName = _ref.className,
19
23
  type = _ref.type;
20
24
 
25
+ /**
26
+ *
27
+ * @param {{ className?: string, [x: string]: any}} param0
28
+ * @returns
29
+ */
21
30
  function Component(_ref2) {
22
31
  var baseClassName = _ref2.className,
23
32
  other = _objectWithoutProperties(_ref2, _excluded);
@@ -27,7 +27,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
27
27
 
28
28
  var _excluded = ["as", "children", "className", "dangerDescription", "disabled", "hasIconOnly", "href", "iconDescription", "isExpressive", "isSelected", "kind", "onBlur", "onClick", "onFocus", "onMouseEnter", "onMouseLeave", "renderIcon", "size", "tabIndex", "tooltipAlignment", "tooltipPosition", "type"];
29
29
  var Button = /*#__PURE__*/React__default["default"].forwardRef(function Button(_ref, ref) {
30
- var _classNames;
30
+ var _classNames, _rest$ariaPressed;
31
31
 
32
32
  var as = _ref.as,
33
33
  children = _ref.children,
@@ -92,7 +92,7 @@ var Button = /*#__PURE__*/React__default["default"].forwardRef(function Button(_
92
92
  disabled: disabled,
93
93
  type: type,
94
94
  'aria-describedby': dangerButtonVariants.includes(kind) ? assistiveId : null,
95
- 'aria-pressed': hasIconOnly && kind === 'ghost' ? isSelected : null
95
+ 'aria-pressed': (_rest$ariaPressed = rest['aria-pressed']) !== null && _rest$ariaPressed !== void 0 ? _rest$ariaPressed : hasIconOnly && kind === 'ghost' ? isSelected : null
96
96
  };
97
97
  var anchorProps = {
98
98
  href: href