@carbon/react 1.24.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 (131) 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/ListBoxSelection.js +4 -23
  23. package/es/components/ListBox/next/ListBoxSelection.js +2 -23
  24. package/es/components/Menu/Menu.js +50 -29
  25. package/es/components/Menu/MenuItem.js +1 -0
  26. package/es/components/MenuButton/index.js +127 -0
  27. package/es/components/Modal/Modal.js +4 -3
  28. package/es/components/MultiSelect/FilterableMultiSelect.js +31 -137
  29. package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
  30. package/es/components/MultiSelect/MultiSelect.js +48 -26
  31. package/es/components/Notification/Notification.js +27 -264
  32. package/es/components/OverflowMenu/OverflowMenu.js +13 -139
  33. package/es/components/OverflowMenuItem/OverflowMenuItem.d.ts +58 -0
  34. package/es/components/OverflowMenuItem/OverflowMenuItem.js +12 -7
  35. package/es/components/OverflowMenuV2/index.js +15 -51
  36. package/es/components/Popover/index.d.ts +5 -1
  37. package/es/components/Popover/index.js +37 -9
  38. package/es/components/RadioButtonGroup/RadioButtonGroup.js +7 -4
  39. package/es/components/RadioTile/RadioTile.js +6 -6
  40. package/es/components/Select/Select.d.ts +89 -0
  41. package/es/components/SelectItem/SelectItem.d.ts +62 -0
  42. package/es/components/SelectItem/SelectItem.js +2 -4
  43. package/es/components/SelectItemGroup/SelectItemGroup.d.ts +52 -0
  44. package/es/components/SkeletonText/SkeletonText.js +1 -1
  45. package/es/components/StructuredList/StructuredList.js +10 -38
  46. package/es/components/Tabs/Tabs.js +3 -1
  47. package/es/components/TextArea/TextArea.Skeleton.d.ts +33 -0
  48. package/es/components/TextArea/TextArea.Skeleton.js +5 -5
  49. package/es/components/TextArea/TextArea.d.ts +9 -2
  50. package/es/components/TextArea/TextArea.js +31 -8
  51. package/es/components/TextArea/index.js +1 -0
  52. package/es/components/Toggle/Toggle.js +8 -19
  53. package/es/components/Tooltip/DefinitionTooltip.d.ts +52 -0
  54. package/es/components/Tooltip/DefinitionTooltip.js +2 -2
  55. package/es/components/Tooltip/Tooltip.d.ts +117 -0
  56. package/es/components/Tooltip/Tooltip.js +6 -4
  57. package/es/components/Tooltip/index.d.ts +9 -0
  58. package/es/index.d.ts +2 -0
  59. package/es/index.js +5 -3
  60. package/es/internal/ClickListener.js +1 -2
  61. package/es/internal/keyboard/match.js +1 -1
  62. package/es/internal/useAttachedMenu.js +85 -0
  63. package/es/internal/useDelayedState.d.ts +19 -0
  64. package/es/internal/useDelayedState.js +7 -3
  65. package/es/internal/useId.js +1 -1
  66. package/lib/components/CodeSnippet/CodeSnippet.js +13 -115
  67. package/lib/components/ComboBox/ComboBox.d.ts +6 -0
  68. package/lib/components/ComboBox/ComboBox.js +18 -171
  69. package/lib/components/ComboButton/index.js +174 -0
  70. package/lib/components/ComposedModal/ComposedModal.js +1 -2
  71. package/lib/components/DataTable/TableToolbar.d.ts +19 -0
  72. package/lib/components/DataTable/TableToolbar.js +1 -1
  73. package/lib/components/DataTable/TableToolbarAction.d.ts +21 -0
  74. package/lib/components/DataTable/TableToolbarContent.d.ts +21 -0
  75. package/lib/components/DataTable/TableToolbarMenu.d.ts +24 -0
  76. package/lib/components/DataTable/TableToolbarMenu.js +3 -3
  77. package/lib/components/DataTable/tools/sorting.js +2 -1
  78. package/lib/components/DataTableSkeleton/DataTableSkeleton.d.ts +107 -0
  79. package/lib/components/Dropdown/Dropdown.d.ts +6 -0
  80. package/lib/components/Dropdown/Dropdown.js +7 -144
  81. package/lib/components/FileUploader/FileUploader.js +1 -1
  82. package/lib/components/FileUploader/FileUploaderDropContainer.js +30 -18
  83. package/lib/components/FileUploader/FileUploaderItem.js +2 -1
  84. package/lib/components/FileUploader/Filename.js +8 -2
  85. package/lib/components/FluidTextArea/FluidTextArea.js +12 -1
  86. package/lib/components/IconButton/index.js +1 -0
  87. package/lib/components/ListBox/ListBoxSelection.js +4 -23
  88. package/lib/components/ListBox/next/ListBoxSelection.js +2 -23
  89. package/lib/components/Menu/Menu.js +50 -29
  90. package/lib/components/Menu/MenuItem.js +1 -0
  91. package/lib/components/MenuButton/index.js +137 -0
  92. package/lib/components/Modal/Modal.js +4 -3
  93. package/lib/components/MultiSelect/FilterableMultiSelect.js +29 -135
  94. package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
  95. package/lib/components/MultiSelect/MultiSelect.js +47 -25
  96. package/lib/components/Notification/Notification.js +27 -264
  97. package/lib/components/OverflowMenu/OverflowMenu.js +13 -139
  98. package/lib/components/OverflowMenuItem/OverflowMenuItem.d.ts +58 -0
  99. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +12 -7
  100. package/lib/components/OverflowMenuV2/index.js +13 -49
  101. package/lib/components/Popover/index.d.ts +5 -1
  102. package/lib/components/Popover/index.js +37 -9
  103. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +6 -3
  104. package/lib/components/RadioTile/RadioTile.js +6 -6
  105. package/lib/components/Select/Select.d.ts +89 -0
  106. package/lib/components/SelectItem/SelectItem.d.ts +62 -0
  107. package/lib/components/SelectItem/SelectItem.js +1 -3
  108. package/lib/components/SelectItemGroup/SelectItemGroup.d.ts +52 -0
  109. package/lib/components/SkeletonText/SkeletonText.js +1 -1
  110. package/lib/components/StructuredList/StructuredList.js +10 -38
  111. package/lib/components/Tabs/Tabs.js +3 -1
  112. package/lib/components/TextArea/TextArea.Skeleton.d.ts +33 -0
  113. package/lib/components/TextArea/TextArea.Skeleton.js +5 -5
  114. package/lib/components/TextArea/TextArea.d.ts +9 -2
  115. package/lib/components/TextArea/TextArea.js +30 -7
  116. package/lib/components/TextArea/index.js +2 -0
  117. package/lib/components/Toggle/Toggle.js +8 -19
  118. package/lib/components/Tooltip/DefinitionTooltip.d.ts +52 -0
  119. package/lib/components/Tooltip/DefinitionTooltip.js +2 -2
  120. package/lib/components/Tooltip/Tooltip.d.ts +117 -0
  121. package/lib/components/Tooltip/Tooltip.js +6 -4
  122. package/lib/components/Tooltip/index.d.ts +9 -0
  123. package/lib/index.d.ts +2 -0
  124. package/lib/index.js +50 -46
  125. package/lib/internal/ClickListener.js +1 -2
  126. package/lib/internal/keyboard/match.js +1 -1
  127. package/lib/internal/useAttachedMenu.js +89 -0
  128. package/lib/internal/useDelayedState.d.ts +19 -0
  129. package/lib/internal/useDelayedState.js +7 -3
  130. package/lib/internal/useId.js +1 -1
  131. package/package.json +3 -3
@@ -15,6 +15,7 @@ var cx = require('classnames');
15
15
  var debounce = require('lodash.debounce');
16
16
  var PropTypes = require('prop-types');
17
17
  var React = require('react');
18
+ require('../Tooltip/DefinitionTooltip.js');
18
19
  var Tooltip = require('../Tooltip/Tooltip.js');
19
20
  var useControllableState = require('../../internal/useControllableState.js');
20
21
  var useEffectOnce = require('../../internal/useEffectOnce.js');
@@ -24,6 +25,7 @@ var useMergedRefs = require('../../internal/useMergedRefs.js');
24
25
  var useNoInteractiveChildren = require('../../internal/useNoInteractiveChildren.js');
25
26
  var usePrefix = require('../../internal/usePrefix.js');
26
27
  var usePressable = require('./usePressable.js');
28
+ var deprecate = require('../../prop-types/deprecate.js');
27
29
  var match = require('../../internal/keyboard/match.js');
28
30
  var keys = require('../../internal/keyboard/keys.js');
29
31
 
@@ -388,7 +390,7 @@ TabList.propTypes = {
388
390
  /**
389
391
  * Specify whether or not to use the light component variant
390
392
  */
391
- light: PropTypes__default["default"].bool,
393
+ light: deprecate["default"](PropTypes__default["default"].bool, 'The `light` prop for `TabList` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
392
394
 
393
395
  /**
394
396
  * Provide the props that describe the right overflow button
@@ -0,0 +1,33 @@
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
+ export interface TextAreaSkeletonProps extends React.InputHTMLAttributes<HTMLDivElement> {
10
+ /**
11
+ * Specify an optional className to add to the form item wrapper.
12
+ */
13
+ className?: string;
14
+ /**
15
+ * Specify whether the label should be hidden, or not
16
+ */
17
+ hideLabel?: boolean;
18
+ }
19
+ declare const TextAreaSkeleton: {
20
+ (props: TextAreaSkeletonProps): JSX.Element;
21
+ propTypes: {
22
+ /**
23
+ * Specify an optional className to add to the form item wrapper.
24
+ */
25
+ className: PropTypes.Requireable<string>;
26
+ /**
27
+ * Specify whether the label should be hidden, or not
28
+ */
29
+ hideLabel: PropTypes.Requireable<boolean>;
30
+ };
31
+ };
32
+ export default TextAreaSkeleton;
33
+ export { TextAreaSkeleton };
@@ -21,12 +21,12 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
21
21
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
22
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
23
23
 
24
- var _excluded = ["hideLabel", "className"];
24
+ var _excluded = ["className", "hideLabel"];
25
25
 
26
- var TextAreaSkeleton = function TextAreaSkeleton(_ref) {
27
- var hideLabel = _ref.hideLabel,
28
- className = _ref.className,
29
- rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
26
+ var TextAreaSkeleton = function TextAreaSkeleton(props) {
27
+ var className = props.className,
28
+ hideLabel = props.hideLabel,
29
+ rest = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
30
30
 
31
31
  var prefix = usePrefix.usePrefix();
32
32
  return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
@@ -6,8 +6,7 @@
6
6
  */
7
7
  import { ReactNodeLike } from 'prop-types';
8
8
  import React from 'react';
9
- type ExcludedAttributes = '';
10
- export interface TextAreaProps extends Omit<React.InputHTMLAttributes<HTMLTextAreaElement>, ExcludedAttributes> {
9
+ export interface TextAreaProps extends React.InputHTMLAttributes<HTMLTextAreaElement> {
11
10
  /**
12
11
  * Provide a custom className that is applied directly to the underlying
13
12
  * `<textarea>` node
@@ -90,6 +89,14 @@ export interface TextAreaProps extends Omit<React.InputHTMLAttributes<HTMLTextAr
90
89
  * Provide the current value of the `<textarea>`
91
90
  */
92
91
  value?: string | number;
92
+ /**
93
+ * Specify whether the control is currently in warning state
94
+ */
95
+ warn?: boolean;
96
+ /**
97
+ * Provide the text that is displayed when the control is in warning state
98
+ */
99
+ warnText?: ReactNodeLike;
93
100
  }
94
101
  declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<unknown>>;
95
102
  export default TextArea;
@@ -29,9 +29,9 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
29
29
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
30
30
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
31
31
 
32
- var _excluded = ["className", "id", "labelText", "hideLabel", "onChange", "onClick", "invalid", "invalidText", "helperText", "light", "placeholder", "enableCounter", "maxCount"];
32
+ var _excluded = ["className", "id", "labelText", "hideLabel", "onChange", "onClick", "invalid", "invalidText", "helperText", "light", "placeholder", "enableCounter", "maxCount", "warn", "warnText"];
33
33
  var TextArea = /*#__PURE__*/React__default["default"].forwardRef(function (props, forwardRef) {
34
- var _classNames, _classNames4;
34
+ var _classNames, _classNames4, _classNames5;
35
35
 
36
36
  var className = props.className,
37
37
  id = props.id,
@@ -46,6 +46,9 @@ var TextArea = /*#__PURE__*/React__default["default"].forwardRef(function (props
46
46
  placeholder = props.placeholder,
47
47
  enableCounter = props.enableCounter,
48
48
  maxCount = props.maxCount,
49
+ _props$warn = props.warn,
50
+ warn = _props$warn === void 0 ? false : _props$warn,
51
+ warnText = props.warnText,
49
52
  other = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
50
53
 
51
54
  var prefix = usePrefix.usePrefix();
@@ -107,7 +110,13 @@ var TextArea = /*#__PURE__*/React__default["default"].forwardRef(function (props
107
110
  }, invalidText, isFluid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
108
111
  className: "".concat(prefix, "--text-area__invalid-icon")
109
112
  })) : null;
110
- var textareaClasses = cx__default["default"]("".concat(prefix, "--text-area"), [enabled ? null : className], (_classNames4 = {}, _rollupPluginBabelHelpers.defineProperty(_classNames4, "".concat(prefix, "--text-area--light"), light), _rollupPluginBabelHelpers.defineProperty(_classNames4, "".concat(prefix, "--text-area--invalid"), invalid), _classNames4));
113
+ var warning = warn ? /*#__PURE__*/React__default["default"].createElement("div", {
114
+ role: "alert",
115
+ className: "".concat(prefix, "--form-requirement")
116
+ }, warnText, isFluid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
117
+ className: "".concat(prefix, "--text-area__invalid-icon ").concat(prefix, "--text-area__invalid-icon--warning")
118
+ })) : null;
119
+ var textareaClasses = cx__default["default"]("".concat(prefix, "--text-area"), [enabled ? null : className], (_classNames4 = {}, _rollupPluginBabelHelpers.defineProperty(_classNames4, "".concat(prefix, "--text-area--light"), light), _rollupPluginBabelHelpers.defineProperty(_classNames4, "".concat(prefix, "--text-area--invalid"), invalid), _rollupPluginBabelHelpers.defineProperty(_classNames4, "".concat(prefix, "--text-area--warn"), warn), _classNames4));
111
120
  var textareaRef = React.useRef(null);
112
121
  var ref = useMergedRefs.useMergedRefs([forwardRef, textareaRef]);
113
122
  useIsomorphicEffect["default"](function () {
@@ -132,16 +141,18 @@ var TextArea = /*#__PURE__*/React__default["default"].forwardRef(function (props
132
141
  }, /*#__PURE__*/React__default["default"].createElement("div", {
133
142
  className: "".concat(prefix, "--text-area__label-wrapper")
134
143
  }, label, counter), /*#__PURE__*/React__default["default"].createElement("div", {
135
- className: cx__default["default"]("".concat(prefix, "--text-area__wrapper"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--text-area__wrapper--readonly"), other.readOnly)),
144
+ className: cx__default["default"]("".concat(prefix, "--text-area__wrapper"), (_classNames5 = {}, _rollupPluginBabelHelpers.defineProperty(_classNames5, "".concat(prefix, "--text-area__wrapper--readonly"), other.readOnly), _rollupPluginBabelHelpers.defineProperty(_classNames5, "".concat(prefix, "--text-area__wrapper--warn"), warn), _classNames5)),
136
145
  "data-invalid": invalid || null
137
146
  }, invalid && !isFluid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
138
147
  className: "".concat(prefix, "--text-area__invalid-icon")
148
+ }), warn && !invalid && !isFluid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
149
+ className: "".concat(prefix, "--text-area__invalid-icon ").concat(prefix, "--text-area__invalid-icon--warning")
139
150
  }), input, /*#__PURE__*/React__default["default"].createElement("span", {
140
151
  className: "".concat(prefix, "--text-area__counter-alert"),
141
152
  role: "alert"
142
153
  }, ariaAnnouncement), isFluid && /*#__PURE__*/React__default["default"].createElement("hr", {
143
154
  className: "".concat(prefix, "--text-area__divider")
144
- }), isFluid && invalid ? error : null), invalid && !isFluid ? error : helper);
155
+ }), isFluid && invalid ? error : null, isFluid && warn && !invalid ? warning : null), !invalid && !warn && !isFluid ? helper : null, invalid && !isFluid ? error : null, warn && !invalid && !isFluid ? warning : null);
145
156
  });
146
157
  TextArea.displayName = 'TextArea';
147
158
  TextArea.propTypes = {
@@ -243,7 +254,17 @@ TextArea.propTypes = {
243
254
  /**
244
255
  * Provide the current value of the `<textarea>`
245
256
  */
246
- value: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number])
257
+ value: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number]),
258
+
259
+ /**
260
+ * Specify whether the control is currently in warning state
261
+ */
262
+ warn: PropTypes__default["default"].bool,
263
+
264
+ /**
265
+ * Provide the text that is displayed when the control is in warning state
266
+ */
267
+ warnText: PropTypes__default["default"].node
247
268
  };
248
269
  TextArea.defaultProps = {
249
270
  disabled: false,
@@ -255,7 +276,9 @@ TextArea.defaultProps = {
255
276
  invalidText: '',
256
277
  helperText: '',
257
278
  enableCounter: false,
258
- maxCount: undefined
279
+ maxCount: undefined,
280
+ warn: false,
281
+ warnText: ''
259
282
  };
260
283
  var TextArea$1 = TextArea;
261
284
 
@@ -10,8 +10,10 @@
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
12
  var TextArea = require('./TextArea.js');
13
+ var TextArea_Skeleton = require('./TextArea.Skeleton.js');
13
14
 
14
15
 
15
16
 
16
17
  exports.TextArea = TextArea["default"];
17
18
  exports["default"] = TextArea["default"];
19
+ exports.TextAreaSkeleton = TextArea_Skeleton["default"];
@@ -74,8 +74,8 @@ function Toggle(_ref) {
74
74
 
75
75
  var isSm = size === 'sm';
76
76
  var sideLabel = hideLabel ? labelText : checked ? labelB : labelA;
77
- var renderSideLabel = !(hideLabel && ariaLabelledby);
78
- var LabelComponent = ariaLabelledby ? 'div' : 'label';
77
+ var renderSideLabel = !(hideLabel && !labelText);
78
+ var LabelComponent = labelText ? 'label' : 'div';
79
79
  var wrapperClasses = cx__default["default"]("".concat(prefix, "--toggle"), (_classNames = {}, _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--toggle--disabled"), disabled), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--toggle--readonly"), readOnly), _classNames), className);
80
80
  var labelTextClasses = cx__default["default"]("".concat(prefix, "--toggle__label-text"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--visually-hidden"), hideLabel));
81
81
  var appearanceClasses = cx__default["default"]("".concat(prefix, "--toggle__appearance"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--toggle__appearance--sm"), isSm));
@@ -85,7 +85,7 @@ function Toggle(_ref) {
85
85
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
86
86
  React__default["default"].createElement("div", {
87
87
  className: wrapperClasses,
88
- onClick: ariaLabelledby ? function (e) {
88
+ onClick: !labelText ? function (e) {
89
89
  // the underlying <button> can only be activated by keyboard as it is visually hidden;
90
90
  // therefore, if this event's target is the <button>, it had to be triggered by
91
91
  // the keyboard event which already calls handleClick. if we wouldn't catch this, the
@@ -151,10 +151,7 @@ Toggle.propTypes = {
151
151
 
152
152
  /**
153
153
  * If true, the side labels (props.labelA and props.labelB) will be replaced by
154
- * props.labelText, so that the toggle doesn't render a top label. In order to fully
155
- * hide any labels, you can use props['aria-labelledby'] to refer to another element
156
- * that labels the toggle. props.labelText would no longer be required in that case
157
- * and can therefore be omitted.
154
+ * props.labelText (if passed), so that the toggle doesn't render a top label.
158
155
  */
159
156
  hideLabel: PropTypes__default["default"].bool,
160
157
 
@@ -175,19 +172,11 @@ Toggle.propTypes = {
175
172
 
176
173
  /**
177
174
  * Provide the text that will be read by a screen reader when visiting this
178
- * control. This is required unless 'aria-labelledby' is provided instead
175
+ * control. This should be provided unless 'aria-labelledby' is set instead
176
+ * or you use an external <label> element with its "for" attribute set to the
177
+ * toggle's id.
179
178
  */
180
- labelText: function labelText(props) {
181
- if (!props['aria-labelledby'] && !props.labelText) {
182
- return new Error('labelText property is required if no aria-labelledby is provided.');
183
- }
184
-
185
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
186
- rest[_key - 1] = arguments[_key];
187
- }
188
-
189
- return PropTypes__default["default"].node.apply(PropTypes__default["default"], [props].concat(rest));
190
- },
179
+ labelText: PropTypes__default["default"].string,
191
180
 
192
181
  /**
193
182
  * 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 };
@@ -28,7 +28,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
28
28
 
29
29
  var _excluded = ["align", "className", "children", "definition", "defaultOpen", "id", "openOnHover", "tooltipText", "triggerClassName"];
30
30
 
31
- function DefinitionTooltip(_ref) {
31
+ var DefinitionTooltip = function DefinitionTooltip(_ref) {
32
32
  var _ref$align = _ref.align,
33
33
  align = _ref$align === void 0 ? 'bottom-left' : _ref$align,
34
34
  className = _ref.className,
@@ -85,7 +85,7 @@ function DefinitionTooltip(_ref) {
85
85
  className: "".concat(prefix, "--definition-tooltip"),
86
86
  id: tooltipId
87
87
  }, tooltipText !== null && tooltipText !== void 0 ? tooltipText : definition));
88
- }
88
+ };
89
89
 
90
90
  DefinitionTooltip.propTypes = {
91
91
  /**
@@ -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 };
@@ -113,10 +113,12 @@ function Tooltip(_ref) {
113
113
 
114
114
  useNoInteractiveChildren.useNoInteractiveChildren(tooltipRef, 'The Tooltip component must have no interactive content rendered by the' + '`label` or `description` prop');
115
115
  React.useEffect(function () {
116
- var interactiveContent = useNoInteractiveChildren.getInteractiveContent(containerRef.current);
116
+ if (containerRef !== null && containerRef.current) {
117
+ var interactiveContent = useNoInteractiveChildren.getInteractiveContent(containerRef.current);
117
118
 
118
- if (!interactiveContent) {
119
- setOpen(false);
119
+ if (!interactiveContent) {
120
+ setOpen(false);
121
+ }
120
122
  }
121
123
  });
122
124
  return /*#__PURE__*/React__default["default"].createElement(index.Popover, _rollupPluginBabelHelpers["extends"]({}, rest, {
@@ -128,7 +130,7 @@ function Tooltip(_ref) {
128
130
  onMouseLeave: onMouseLeave,
129
131
  open: open,
130
132
  ref: containerRef
131
- }), /*#__PURE__*/React__default["default"].cloneElement(child, _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, triggerProps), getChildEventHandlers(child.props))), /*#__PURE__*/React__default["default"].createElement(index.PopoverContent, {
133
+ }), child !== undefined ? /*#__PURE__*/React__default["default"].cloneElement(child, _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, triggerProps), getChildEventHandlers(child.props))) : null, /*#__PURE__*/React__default["default"].createElement(index.PopoverContent, {
132
134
  "aria-hidden": "true",
133
135
  className: "".concat(prefix, "--tooltip-content"),
134
136
  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/lib/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';