@carbon/react 1.24.0-rc.0 → 1.25.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 (151) hide show
  1. package/es/components/CodeSnippet/CodeSnippet.js +13 -115
  2. package/es/components/ComboBox/ComboBox.d.ts +6 -0
  3. package/es/components/ComboBox/ComboBox.js +19 -172
  4. package/es/components/ComboButton/index.js +164 -0
  5. package/es/components/ComposedModal/ComposedModal.js +1 -2
  6. package/es/components/DataTable/TableToolbar.d.ts +19 -0
  7. package/es/components/DataTable/TableToolbar.js +1 -1
  8. package/es/components/DataTable/TableToolbarAction.d.ts +21 -0
  9. package/es/components/DataTable/TableToolbarContent.d.ts +21 -0
  10. package/es/components/DataTable/TableToolbarMenu.d.ts +24 -0
  11. package/es/components/DataTable/TableToolbarMenu.js +3 -3
  12. package/es/components/DataTable/tools/sorting.js +2 -1
  13. package/es/components/DataTableSkeleton/DataTableSkeleton.d.ts +107 -0
  14. package/es/components/Dropdown/Dropdown.d.ts +6 -0
  15. package/es/components/Dropdown/Dropdown.js +8 -145
  16. package/es/components/FileUploader/FileUploader.js +1 -1
  17. package/es/components/FileUploader/FileUploaderDropContainer.js +30 -18
  18. package/es/components/FileUploader/FileUploaderItem.js +2 -1
  19. package/es/components/FileUploader/Filename.js +8 -2
  20. package/es/components/FluidTextArea/FluidTextArea.js +12 -1
  21. package/es/components/IconButton/index.js +1 -0
  22. package/es/components/ListBox/ListBoxMenuItem.d.ts +2 -2
  23. package/es/components/ListBox/ListBoxSelection.js +4 -23
  24. package/es/components/ListBox/next/ListBoxSelection.js +2 -23
  25. package/es/components/Menu/Menu.js +50 -33
  26. package/es/components/Menu/MenuContext.js +3 -6
  27. package/es/components/Menu/MenuItem.js +1 -0
  28. package/es/components/MenuButton/index.js +127 -0
  29. package/es/components/Modal/Modal.js +4 -3
  30. package/es/components/MultiSelect/FilterableMultiSelect.js +31 -137
  31. package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
  32. package/es/components/MultiSelect/MultiSelect.js +48 -26
  33. package/es/components/Notification/Notification.js +27 -264
  34. package/es/components/OverflowMenu/OverflowMenu.js +13 -139
  35. package/es/components/OverflowMenuItem/OverflowMenuItem.d.ts +58 -0
  36. package/es/components/OverflowMenuItem/OverflowMenuItem.js +12 -7
  37. package/es/components/OverflowMenuV2/index.js +15 -51
  38. package/es/components/Popover/index.d.ts +55 -0
  39. package/es/components/Popover/index.js +61 -29
  40. package/es/components/RadioButtonGroup/RadioButtonGroup.js +7 -4
  41. package/es/components/RadioTile/RadioTile.js +6 -6
  42. package/es/components/Select/Select.d.ts +89 -0
  43. package/es/components/SelectItem/SelectItem.d.ts +62 -0
  44. package/es/components/SelectItem/SelectItem.js +2 -4
  45. package/es/components/SelectItemGroup/SelectItemGroup.d.ts +52 -0
  46. package/es/components/SkeletonText/SkeletonText.js +1 -1
  47. package/es/components/Slider/Slider.Skeleton.d.ts +2 -2
  48. package/es/components/Slider/Slider.d.ts +355 -0
  49. package/es/components/Slider/Slider.js +63 -35
  50. package/es/components/StructuredList/StructuredList.js +10 -38
  51. package/es/components/Tabs/Tabs.js +3 -1
  52. package/es/components/TextArea/TextArea.Skeleton.d.ts +33 -0
  53. package/es/components/TextArea/TextArea.Skeleton.js +5 -5
  54. package/es/components/TextArea/TextArea.d.ts +9 -2
  55. package/es/components/TextArea/TextArea.js +31 -8
  56. package/es/components/TextArea/index.js +1 -0
  57. package/es/components/TextInput/TextInput.d.ts +106 -0
  58. package/es/components/TextInput/TextInput.js +3 -2
  59. package/es/components/Toggle/Toggle.js +8 -19
  60. package/es/components/Tooltip/DefinitionTooltip.d.ts +52 -0
  61. package/es/components/Tooltip/DefinitionTooltip.js +2 -2
  62. package/es/components/Tooltip/Tooltip.d.ts +117 -0
  63. package/es/components/Tooltip/Tooltip.js +6 -4
  64. package/es/components/Tooltip/index.d.ts +9 -0
  65. package/es/index.d.ts +2 -0
  66. package/es/index.js +5 -3
  67. package/es/internal/ClickListener.js +1 -2
  68. package/es/internal/keyboard/match.js +1 -1
  69. package/es/internal/useAttachedMenu.js +85 -0
  70. package/es/internal/useDelayedState.d.ts +19 -0
  71. package/es/internal/useDelayedState.js +7 -3
  72. package/es/internal/useId.js +1 -1
  73. package/es/internal/useMergedRefs.d.ts +13 -0
  74. package/es/internal/useMergedRefs.js +2 -5
  75. package/es/internal/useNormalizedInputProps.js +1 -0
  76. package/lib/components/CodeSnippet/CodeSnippet.js +13 -115
  77. package/lib/components/ComboBox/ComboBox.d.ts +6 -0
  78. package/lib/components/ComboBox/ComboBox.js +18 -171
  79. package/lib/components/ComboButton/index.js +174 -0
  80. package/lib/components/ComposedModal/ComposedModal.js +1 -2
  81. package/lib/components/DataTable/TableToolbar.d.ts +19 -0
  82. package/lib/components/DataTable/TableToolbar.js +1 -1
  83. package/lib/components/DataTable/TableToolbarAction.d.ts +21 -0
  84. package/lib/components/DataTable/TableToolbarContent.d.ts +21 -0
  85. package/lib/components/DataTable/TableToolbarMenu.d.ts +24 -0
  86. package/lib/components/DataTable/TableToolbarMenu.js +3 -3
  87. package/lib/components/DataTable/tools/sorting.js +2 -1
  88. package/lib/components/DataTableSkeleton/DataTableSkeleton.d.ts +107 -0
  89. package/lib/components/Dropdown/Dropdown.d.ts +6 -0
  90. package/lib/components/Dropdown/Dropdown.js +7 -144
  91. package/lib/components/FileUploader/FileUploader.js +1 -1
  92. package/lib/components/FileUploader/FileUploaderDropContainer.js +30 -18
  93. package/lib/components/FileUploader/FileUploaderItem.js +2 -1
  94. package/lib/components/FileUploader/Filename.js +8 -2
  95. package/lib/components/FluidTextArea/FluidTextArea.js +12 -1
  96. package/lib/components/IconButton/index.js +1 -0
  97. package/lib/components/ListBox/ListBoxMenuItem.d.ts +2 -2
  98. package/lib/components/ListBox/ListBoxSelection.js +4 -23
  99. package/lib/components/ListBox/next/ListBoxSelection.js +2 -23
  100. package/lib/components/Menu/Menu.js +50 -33
  101. package/lib/components/Menu/MenuContext.js +3 -6
  102. package/lib/components/Menu/MenuItem.js +1 -0
  103. package/lib/components/MenuButton/index.js +137 -0
  104. package/lib/components/Modal/Modal.js +4 -3
  105. package/lib/components/MultiSelect/FilterableMultiSelect.js +29 -135
  106. package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
  107. package/lib/components/MultiSelect/MultiSelect.js +47 -25
  108. package/lib/components/Notification/Notification.js +27 -264
  109. package/lib/components/OverflowMenu/OverflowMenu.js +13 -139
  110. package/lib/components/OverflowMenuItem/OverflowMenuItem.d.ts +58 -0
  111. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +12 -7
  112. package/lib/components/OverflowMenuV2/index.js +13 -49
  113. package/lib/components/Popover/index.d.ts +55 -0
  114. package/lib/components/Popover/index.js +61 -29
  115. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +6 -3
  116. package/lib/components/RadioTile/RadioTile.js +6 -6
  117. package/lib/components/Select/Select.d.ts +89 -0
  118. package/lib/components/SelectItem/SelectItem.d.ts +62 -0
  119. package/lib/components/SelectItem/SelectItem.js +1 -3
  120. package/lib/components/SelectItemGroup/SelectItemGroup.d.ts +52 -0
  121. package/lib/components/SkeletonText/SkeletonText.js +1 -1
  122. package/lib/components/Slider/Slider.Skeleton.d.ts +2 -2
  123. package/lib/components/Slider/Slider.d.ts +355 -0
  124. package/lib/components/Slider/Slider.js +62 -34
  125. package/lib/components/StructuredList/StructuredList.js +10 -38
  126. package/lib/components/Tabs/Tabs.js +3 -1
  127. package/lib/components/TextArea/TextArea.Skeleton.d.ts +33 -0
  128. package/lib/components/TextArea/TextArea.Skeleton.js +5 -5
  129. package/lib/components/TextArea/TextArea.d.ts +9 -2
  130. package/lib/components/TextArea/TextArea.js +30 -7
  131. package/lib/components/TextArea/index.js +2 -0
  132. package/lib/components/TextInput/TextInput.d.ts +106 -0
  133. package/lib/components/TextInput/TextInput.js +3 -2
  134. package/lib/components/Toggle/Toggle.js +8 -19
  135. package/lib/components/Tooltip/DefinitionTooltip.d.ts +52 -0
  136. package/lib/components/Tooltip/DefinitionTooltip.js +2 -2
  137. package/lib/components/Tooltip/Tooltip.d.ts +117 -0
  138. package/lib/components/Tooltip/Tooltip.js +6 -4
  139. package/lib/components/Tooltip/index.d.ts +9 -0
  140. package/lib/index.d.ts +2 -0
  141. package/lib/index.js +50 -46
  142. package/lib/internal/ClickListener.js +1 -2
  143. package/lib/internal/keyboard/match.js +1 -1
  144. package/lib/internal/useAttachedMenu.js +89 -0
  145. package/lib/internal/useDelayedState.d.ts +19 -0
  146. package/lib/internal/useDelayedState.js +7 -3
  147. package/lib/internal/useId.js +1 -1
  148. package/lib/internal/useMergedRefs.d.ts +13 -0
  149. package/lib/internal/useMergedRefs.js +2 -5
  150. package/lib/internal/useNormalizedInputProps.js +1 -0
  151. package/package.json +10 -10
@@ -64,8 +64,8 @@ function Toggle(_ref) {
64
64
 
65
65
  var isSm = size === 'sm';
66
66
  var sideLabel = hideLabel ? labelText : checked ? labelB : labelA;
67
- var renderSideLabel = !(hideLabel && ariaLabelledby);
68
- var LabelComponent = ariaLabelledby ? 'div' : 'label';
67
+ var renderSideLabel = !(hideLabel && !labelText);
68
+ var LabelComponent = labelText ? 'label' : 'div';
69
69
  var wrapperClasses = cx("".concat(prefix, "--toggle"), (_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "--toggle--disabled"), disabled), _defineProperty(_classNames, "".concat(prefix, "--toggle--readonly"), readOnly), _classNames), className);
70
70
  var labelTextClasses = cx("".concat(prefix, "--toggle__label-text"), _defineProperty({}, "".concat(prefix, "--visually-hidden"), hideLabel));
71
71
  var appearanceClasses = cx("".concat(prefix, "--toggle__appearance"), _defineProperty({}, "".concat(prefix, "--toggle__appearance--sm"), isSm));
@@ -75,7 +75,7 @@ function Toggle(_ref) {
75
75
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
76
76
  React__default.createElement("div", {
77
77
  className: wrapperClasses,
78
- onClick: ariaLabelledby ? function (e) {
78
+ onClick: !labelText ? function (e) {
79
79
  // the underlying <button> can only be activated by keyboard as it is visually hidden;
80
80
  // therefore, if this event's target is the <button>, it had to be triggered by
81
81
  // the keyboard event which already calls handleClick. if we wouldn't catch this, the
@@ -141,10 +141,7 @@ Toggle.propTypes = {
141
141
 
142
142
  /**
143
143
  * If true, the side labels (props.labelA and props.labelB) will be replaced by
144
- * props.labelText, so that the toggle doesn't render a top label. In order to fully
145
- * hide any labels, you can use props['aria-labelledby'] to refer to another element
146
- * that labels the toggle. props.labelText would no longer be required in that case
147
- * and can therefore be omitted.
144
+ * props.labelText (if passed), so that the toggle doesn't render a top label.
148
145
  */
149
146
  hideLabel: PropTypes.bool,
150
147
 
@@ -165,19 +162,11 @@ Toggle.propTypes = {
165
162
 
166
163
  /**
167
164
  * Provide the text that will be read by a screen reader when visiting this
168
- * control. This is required unless 'aria-labelledby' is provided instead
165
+ * control. This should be provided unless 'aria-labelledby' is set instead
166
+ * or you use an external <label> element with its "for" attribute set to the
167
+ * toggle's id.
169
168
  */
170
- labelText: function labelText(props) {
171
- if (!props['aria-labelledby'] && !props.labelText) {
172
- return new Error('labelText property is required if no aria-labelledby is provided.');
173
- }
174
-
175
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
176
- rest[_key - 1] = arguments[_key];
177
- }
178
-
179
- return PropTypes.node.apply(PropTypes, [props].concat(rest));
180
- },
169
+ labelText: PropTypes.string,
181
170
 
182
171
  /**
183
172
  * Provide an event listener that is called when the control is clicked
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import { PopoverAlignment } from '../Popover';
9
+ export interface DefinitionTooltipProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'id' | 'classname' | 'children' | 'type'> {
10
+ /**
11
+ * Specify how the trigger should align with the tooltip
12
+ */
13
+ align?: PopoverAlignment;
14
+ /**
15
+ * The `children` prop will be used as the value that is being defined
16
+ */
17
+ children?: React.ReactNode;
18
+ /**
19
+ * Specify an optional className to be applied to the container node
20
+ */
21
+ className?: string;
22
+ /**
23
+ * Specify whether the tooltip should be open when it first renders
24
+ */
25
+ defaultOpen?: boolean;
26
+ /**
27
+ * The `definition` prop is used as the content inside of the tooltip that
28
+ * appears when a user interacts with the element rendered by the `children`
29
+ * prop
30
+ */
31
+ definition: React.ReactNode;
32
+ /**
33
+ * Provide a value that will be assigned as the id of the tooltip
34
+ */
35
+ id?: string;
36
+ /**
37
+ * Specifies whether or not the `DefinitionTooltip` should open on hover or not
38
+ */
39
+ openOnHover?: boolean;
40
+ /**
41
+ * @deprecated [Deprecated in v11] Please use the `definition` prop instead.
42
+ *
43
+ * Provide the text that will be displayed in the tooltip when it is rendered.
44
+ */
45
+ tooltipText?: React.ReactNode;
46
+ /**
47
+ * The CSS class name of the trigger element
48
+ */
49
+ triggerClassName?: string;
50
+ }
51
+ declare const DefinitionTooltip: React.FC<DefinitionTooltipProps>;
52
+ export { DefinitionTooltip };
@@ -18,7 +18,7 @@ import { Escape } from '../../internal/keyboard/keys.js';
18
18
 
19
19
  var _excluded = ["align", "className", "children", "definition", "defaultOpen", "id", "openOnHover", "tooltipText", "triggerClassName"];
20
20
 
21
- function DefinitionTooltip(_ref) {
21
+ var DefinitionTooltip = function DefinitionTooltip(_ref) {
22
22
  var _ref$align = _ref.align,
23
23
  align = _ref$align === void 0 ? 'bottom-left' : _ref$align,
24
24
  className = _ref.className,
@@ -75,7 +75,7 @@ function DefinitionTooltip(_ref) {
75
75
  className: "".concat(prefix, "--definition-tooltip"),
76
76
  id: tooltipId
77
77
  }, tooltipText !== null && tooltipText !== void 0 ? tooltipText : definition));
78
- }
78
+ };
79
79
 
80
80
  DefinitionTooltip.propTypes = {
81
81
  /**
@@ -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 };
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
 
@@ -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
+ import { Ref, ForwardedRef } from 'react';
8
+ /**
9
+ * Combine multiple refs into a single ref. This use useful when you have two
10
+ * refs from both `React.forwardRef` and `useRef` that you would like to add to
11
+ * the same node.
12
+ */
13
+ export declare const useMergedRefs: <T>(refs: ForwardedRef<T>[]) => Ref<T>;
@@ -11,12 +11,9 @@ import { useCallback } from 'react';
11
11
  * Combine multiple refs into a single ref. This use useful when you have two
12
12
  * refs from both `React.forwardRef` and `useRef` that you would like to add to
13
13
  * the same node.
14
- *
15
- * @param {Array} refs
16
- * @returns {Function}
17
14
  */
18
15
 
19
- function useMergedRefs(refs) {
16
+ var useMergedRefs = function useMergedRefs(refs) {
20
17
  return useCallback(function (node) {
21
18
  refs.forEach(function (ref) {
22
19
  if (typeof ref === 'function') {
@@ -26,6 +23,6 @@ function useMergedRefs(refs) {
26
23
  }
27
24
  }); // eslint-disable-next-line react-hooks/exhaustive-deps
28
25
  }, refs);
29
- }
26
+ };
30
27
 
31
28
  export { useMergedRefs };
@@ -25,6 +25,7 @@ import { usePrefix } from './usePrefix.js';
25
25
  * @property {boolean} disabled - Whether the input is disabled
26
26
  * @property {boolean} invalid - Whether the input is invalid (takes precedence over warn)
27
27
  * @property {string} invalidId - The invalid message's id
28
+ * @property {string} helperId - id used for helper text
28
29
  * @property {boolean} warn - Whether the input is in warning state
29
30
  * @property {string} warnId - The warning message's id
30
31
  * @property {React.ReactNode | null} validation – React node rendering the appropriate validation message (if any)