@carbon/react 1.65.0 → 1.66.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 (110) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +927 -927
  2. package/es/components/AILabel/index.d.ts +37 -0
  3. package/es/components/AILabel/index.js +38 -14
  4. package/es/components/Accordion/Accordion.d.ts +5 -1
  5. package/es/components/Breadcrumb/BreadcrumbItem.js +1 -1
  6. package/es/components/Button/Button.d.ts +2 -1
  7. package/es/components/Button/Button.js +14 -3
  8. package/es/components/ChatButton/ChatButton.Skeleton.d.ts +31 -0
  9. package/es/components/ChatButton/ChatButton.Skeleton.js +1 -2
  10. package/es/components/ChatButton/ChatButton.d.ts +46 -0
  11. package/es/components/ChatButton/ChatButton.js +3 -3
  12. package/es/components/ChatButton/index.d.ts +12 -0
  13. package/es/components/Checkbox/index.js +10 -0
  14. package/es/components/CodeSnippet/CodeSnippet.d.ts +9 -1
  15. package/es/components/CodeSnippet/CodeSnippet.js +7 -0
  16. package/es/components/ComboBox/ComboBox.js +38 -19
  17. package/es/components/ComboButton/index.js +8 -3
  18. package/es/components/ComposedModal/index.d.ts +2 -0
  19. package/es/components/Copy/Copy.d.ts +9 -1
  20. package/es/components/Copy/Copy.js +6 -0
  21. package/es/components/CopyButton/CopyButton.d.ts +9 -1
  22. package/es/components/CopyButton/CopyButton.js +6 -0
  23. package/es/components/DataTable/TableSlugRow.d.ts +1 -0
  24. package/es/components/DataTable/TableSlugRow.js +1 -0
  25. package/es/components/Dropdown/Dropdown.js +1 -1
  26. package/es/components/FluidTextArea/FluidTextArea.Skeleton.d.ts +20 -0
  27. package/es/components/FluidTextArea/FluidTextArea.Skeleton.js +3 -20
  28. package/es/components/FluidTextArea/FluidTextArea.d.ts +96 -0
  29. package/es/components/FluidTextArea/FluidTextArea.js +2 -2
  30. package/es/components/FluidTextArea/index.d.ts +12 -0
  31. package/es/components/Grid/Column.js +3 -3
  32. package/es/components/IconButton/index.d.ts +4 -0
  33. package/es/components/IconButton/index.js +6 -0
  34. package/es/components/ListBox/ListBoxMenuItem.d.ts +10 -1
  35. package/es/components/ListBox/next/ListBoxSelection.d.ts +106 -0
  36. package/es/components/ListBox/next/ListBoxSelection.js +12 -16
  37. package/es/components/ListBox/next/ListBoxTrigger.d.ts +31 -0
  38. package/es/components/ListBox/next/ListBoxTrigger.js +2 -4
  39. package/es/components/ListBox/next/index.d.ts +8 -0
  40. package/es/components/Menu/Menu.js +2 -1
  41. package/es/components/MultiSelect/FilterableMultiSelect.js +14 -15
  42. package/es/components/MultiSelect/MultiSelect.js +65 -49
  43. package/es/components/MultiSelect/tools/sorting.js +5 -8
  44. package/es/components/OverflowMenu/OverflowMenu.js +1 -1
  45. package/es/components/OverflowMenu/next/index.js +3 -1
  46. package/es/components/Popover/index.js +22 -5
  47. package/es/components/Tag/DismissibleTag.d.ts +9 -1
  48. package/es/components/Tag/DismissibleTag.js +7 -3
  49. package/es/components/Tag/Tag.js +2 -2
  50. package/es/components/Toggletip/index.js +2 -1
  51. package/es/components/TreeView/TreeNode.js +41 -33
  52. package/es/components/TreeView/TreeView.d.ts +5 -3
  53. package/es/index.js +4 -4
  54. package/es/internal/Selection.js +30 -18
  55. package/es/internal/useMergedRefs.d.ts +1 -1
  56. package/lib/components/AILabel/index.d.ts +37 -0
  57. package/lib/components/AILabel/index.js +38 -14
  58. package/lib/components/Accordion/Accordion.d.ts +5 -1
  59. package/lib/components/Breadcrumb/BreadcrumbItem.js +1 -1
  60. package/lib/components/Button/Button.d.ts +2 -1
  61. package/lib/components/Button/Button.js +13 -2
  62. package/lib/components/ChatButton/ChatButton.Skeleton.d.ts +31 -0
  63. package/lib/components/ChatButton/ChatButton.Skeleton.js +1 -2
  64. package/lib/components/ChatButton/ChatButton.d.ts +46 -0
  65. package/lib/components/ChatButton/ChatButton.js +4 -4
  66. package/lib/components/ChatButton/index.d.ts +12 -0
  67. package/lib/components/Checkbox/index.js +19 -0
  68. package/lib/components/CodeSnippet/CodeSnippet.d.ts +9 -1
  69. package/lib/components/CodeSnippet/CodeSnippet.js +7 -0
  70. package/lib/components/ComboBox/ComboBox.js +38 -19
  71. package/lib/components/ComboButton/index.js +8 -3
  72. package/lib/components/ComposedModal/index.d.ts +2 -0
  73. package/lib/components/Copy/Copy.d.ts +9 -1
  74. package/lib/components/Copy/Copy.js +6 -0
  75. package/lib/components/CopyButton/CopyButton.d.ts +9 -1
  76. package/lib/components/CopyButton/CopyButton.js +6 -0
  77. package/lib/components/DataTable/TableSlugRow.d.ts +1 -0
  78. package/lib/components/DataTable/TableSlugRow.js +1 -0
  79. package/lib/components/Dropdown/Dropdown.js +1 -1
  80. package/lib/components/FluidTextArea/FluidTextArea.Skeleton.d.ts +20 -0
  81. package/lib/components/FluidTextArea/FluidTextArea.Skeleton.js +3 -22
  82. package/lib/components/FluidTextArea/FluidTextArea.d.ts +96 -0
  83. package/lib/components/FluidTextArea/FluidTextArea.js +2 -2
  84. package/lib/components/FluidTextArea/index.d.ts +12 -0
  85. package/lib/components/Grid/Column.js +3 -3
  86. package/lib/components/IconButton/index.d.ts +4 -0
  87. package/lib/components/IconButton/index.js +6 -0
  88. package/lib/components/ListBox/ListBoxMenuItem.d.ts +10 -1
  89. package/lib/components/ListBox/next/ListBoxSelection.d.ts +106 -0
  90. package/lib/components/ListBox/next/ListBoxSelection.js +11 -16
  91. package/lib/components/ListBox/next/ListBoxTrigger.d.ts +31 -0
  92. package/lib/components/ListBox/next/ListBoxTrigger.js +2 -4
  93. package/lib/components/ListBox/next/index.d.ts +8 -0
  94. package/lib/components/Menu/Menu.js +2 -1
  95. package/lib/components/MultiSelect/FilterableMultiSelect.js +14 -15
  96. package/lib/components/MultiSelect/MultiSelect.js +64 -48
  97. package/lib/components/MultiSelect/tools/sorting.js +5 -8
  98. package/lib/components/OverflowMenu/OverflowMenu.js +1 -1
  99. package/lib/components/OverflowMenu/next/index.js +3 -1
  100. package/lib/components/Popover/index.js +22 -5
  101. package/lib/components/Tag/DismissibleTag.d.ts +9 -1
  102. package/lib/components/Tag/DismissibleTag.js +7 -3
  103. package/lib/components/Tag/Tag.js +2 -2
  104. package/lib/components/Toggletip/index.js +2 -1
  105. package/lib/components/TreeView/TreeNode.js +41 -33
  106. package/lib/components/TreeView/TreeView.d.ts +5 -3
  107. package/lib/index.js +8 -8
  108. package/lib/internal/Selection.js +30 -18
  109. package/lib/internal/useMergedRefs.d.ts +1 -1
  110. package/package.json +25 -22
@@ -12,6 +12,10 @@ export interface CopyButtonProps extends ButtonProps<'button'> {
12
12
  * Specify how the trigger should align with the tooltip
13
13
  */
14
14
  align?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
15
+ /**
16
+ * **Experimental**: Will attempt to automatically align the tooltip
17
+ */
18
+ autoAlign?: boolean;
15
19
  /**
16
20
  * Specify an optional className to be applied to the underlying `<button>`
17
21
  */
@@ -36,13 +40,17 @@ export interface CopyButtonProps extends ButtonProps<'button'> {
36
40
  */
37
41
  onClick?: MouseEventHandler<HTMLButtonElement>;
38
42
  }
39
- declare function CopyButton({ align, feedback, feedbackTimeout, iconDescription, className, onClick, ...other }: CopyButtonProps): import("react/jsx-runtime").JSX.Element;
43
+ declare function CopyButton({ align, autoAlign, feedback, feedbackTimeout, iconDescription, className, onClick, ...other }: CopyButtonProps): import("react/jsx-runtime").JSX.Element;
40
44
  declare namespace CopyButton {
41
45
  var propTypes: {
42
46
  /**
43
47
  * Specify how the trigger should align with the tooltip
44
48
  */
45
49
  align: PropTypes.Requireable<string>;
50
+ /**
51
+ * **Experimental**: Will attempt to automatically align the tooltip
52
+ */
53
+ autoAlign: PropTypes.Requireable<boolean>;
46
54
  /**
47
55
  * Specify an optional className to be applied to the underlying `<button>`
48
56
  */
@@ -18,6 +18,7 @@ import { noopFn } from '../../internal/noopFn.js';
18
18
  function CopyButton(_ref) {
19
19
  let {
20
20
  align = 'bottom',
21
+ autoAlign = false,
21
22
  feedback = 'Copied!',
22
23
  feedbackTimeout = 2000,
23
24
  iconDescription = 'Copy to clipboard',
@@ -36,6 +37,7 @@ function CopyButton(_ref) {
36
37
  feedbackTimeout: feedbackTimeout,
37
38
  onClick: onClick,
38
39
  align: align,
40
+ autoAlign: autoAlign,
39
41
  className: cx(className, `${prefix}--copy-btn`),
40
42
  "aria-label": iconDescription
41
43
  }, other), /*#__PURE__*/React__default.createElement(Copy$1, {
@@ -47,6 +49,10 @@ CopyButton.propTypes = {
47
49
  * Specify how the trigger should align with the tooltip
48
50
  */
49
51
  align: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right']),
52
+ /**
53
+ * **Experimental**: Will attempt to automatically align the tooltip
54
+ */
55
+ autoAlign: PropTypes.bool,
50
56
  /**
51
57
  * Specify an optional className to be applied to the underlying `<button>`
52
58
  */
@@ -18,6 +18,7 @@ export interface TableSlugRowProps {
18
18
  }
19
19
  declare const TableSlugRow: {
20
20
  ({ className, slug }: TableSlugRowProps): import("react/jsx-runtime").JSX.Element;
21
+ displayName: string;
21
22
  propTypes: {
22
23
  /**
23
24
  * The CSS class names of the cell that wraps the underlying input control
@@ -35,6 +35,7 @@ const TableSlugRow = _ref => {
35
35
  className: TableSlugRowClasses
36
36
  }, normalizedSlug);
37
37
  };
38
+ TableSlugRow.displayName = 'TableSlugRow';
38
39
  TableSlugRow.propTypes = {
39
40
  /**
40
41
  * The CSS class names of the cell that wraps the underlying input control
@@ -185,7 +185,7 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
185
185
  [`${prefix}--dropdown--readonly`]: readOnly,
186
186
  [`${prefix}--dropdown--${size$1}`]: size$1,
187
187
  [`${prefix}--list-box--up`]: direction === 'top',
188
- [`${prefix}--dropdown--autoalign`]: autoAlign
188
+ [`${prefix}--autoalign`]: autoAlign
189
189
  });
190
190
  const titleClasses = cx(`${prefix}--label`, {
191
191
  [`${prefix}--label--disabled`]: disabled,
@@ -0,0 +1,20 @@
1
+ import PropTypes from 'prop-types';
2
+ export interface FluidTextAreaSkeletonProps {
3
+ /**
4
+ * Specify an optional className to be applied to the outer FluidForm wrapper
5
+ */
6
+ className?: string;
7
+ }
8
+ declare function FluidTextAreaSkeleton({ className, ...other }: {
9
+ [x: string]: any;
10
+ className: any;
11
+ }): void;
12
+ declare namespace FluidTextAreaSkeleton {
13
+ var propTypes: {
14
+ /**
15
+ * Specify an optional className to be applied to the outer FluidForm wrapper
16
+ */
17
+ className: PropTypes.Requireable<string>;
18
+ };
19
+ }
20
+ export default FluidTextAreaSkeleton;
@@ -5,30 +5,13 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
8
  import PropTypes from 'prop-types';
10
- import React__default from 'react';
11
- import cx from 'classnames';
9
+ import 'react';
10
+ import 'classnames';
12
11
  import { usePrefix } from '../../internal/usePrefix.js';
13
- import { FormContext } from '../FluidForm/FormContext.js';
14
12
 
15
13
  function FluidTextAreaSkeleton(_ref) {
16
- let {
17
- className,
18
- ...other
19
- } = _ref;
20
- const prefix = usePrefix();
21
- return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
22
- value: {
23
- isFluid: true
24
- }
25
- }, /*#__PURE__*/React__default.createElement("div", _extends({
26
- className: cx(`${prefix}--form-item ${prefix}--text-area--fluid__skeleton`, className)
27
- }, other), /*#__PURE__*/React__default.createElement("span", {
28
- className: `${prefix}--label ${prefix}--skeleton`
29
- }), /*#__PURE__*/React__default.createElement("div", {
30
- className: `${prefix}--skeleton ${prefix}--text-area`
31
- })));
14
+ usePrefix();
32
15
  }
33
16
  FluidTextAreaSkeleton.propTypes = {
34
17
  /**
@@ -0,0 +1,96 @@
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
+ export interface FluidTextAreaProps {
9
+ /**
10
+ * Provide a custom className that is applied directly to the underlying
11
+ * `<textarea>` node
12
+ */
13
+ className?: string;
14
+ /**
15
+ * Specify the `cols` attribute for the underlying `<textarea>` node
16
+ */
17
+ cols?: number;
18
+ /**
19
+ * Optionally provide the default value of the `<textarea>`
20
+ */
21
+ defaultValue?: string | number;
22
+ /**
23
+ * Specify whether the control is disabled
24
+ */
25
+ disabled?: boolean;
26
+ /**
27
+ * Specify whether to display the character counter
28
+ */
29
+ enableCounter?: boolean;
30
+ /**
31
+ * Provide text that is used alongside the control label for additional help
32
+ */
33
+ helperText?: React.ReactNode;
34
+ /**
35
+ * Specify whether you want the underlying label to be visually hidden
36
+ */
37
+ hideLabel?: boolean;
38
+ /**
39
+ * Provide a unique identifier for the control
40
+ */
41
+ id?: string;
42
+ /**
43
+ * Specify whether the control is currently invalid
44
+ */
45
+ invalid?: boolean;
46
+ /**
47
+ * Provide the text that is displayed when the control is in an invalid state
48
+ */
49
+ invalidText?: React.ReactNode;
50
+ /**
51
+ * Provide the text that will be read by a screen reader when visiting this
52
+ * control
53
+ */
54
+ labelText: React.ReactNode;
55
+ /**
56
+ * `true` to use the light version. For use on $ui-01 backgrounds only.
57
+ * Don't use this to make tile background color same as container background color.
58
+ */
59
+ light?: boolean;
60
+ /**
61
+ * Max character count allowed for the textarea. This is needed in order for enableCounter to display
62
+ */
63
+ maxCount?: number;
64
+ /**
65
+ * Optionally provide an `onChange` handler that is called whenever `<textarea>`
66
+ * is updated
67
+ */
68
+ onChange?: React.ChangeEventHandler<HTMLTextAreaElement>;
69
+ /**
70
+ * Optionally provide an `onClick` handler that is called whenever the
71
+ * `<textarea>` is clicked
72
+ */
73
+ onClick?: React.MouseEventHandler<HTMLTextAreaElement>;
74
+ /**
75
+ * Specify the placeholder attribute for the `<textarea>`
76
+ */
77
+ placeholder?: string;
78
+ /**
79
+ * Specify the rows attribute for the `<textarea>`
80
+ */
81
+ rows?: number;
82
+ /**
83
+ * Provide the current value of the `<textarea>`
84
+ */
85
+ value?: string | number;
86
+ /**
87
+ * Specify whether the control is currently in warning state
88
+ */
89
+ warn?: boolean;
90
+ /**
91
+ * Provide the text that is displayed when the control is in warning state
92
+ */
93
+ warnText?: React.ReactNode;
94
+ }
95
+ declare const FluidTextArea: React.FC<FluidTextAreaProps>;
96
+ export default FluidTextArea;
@@ -15,7 +15,7 @@ import deprecate from '../../prop-types/deprecate.js';
15
15
  import { usePrefix } from '../../internal/usePrefix.js';
16
16
  import { FormContext } from '../FluidForm/FormContext.js';
17
17
 
18
- function FluidTextArea(_ref) {
18
+ const FluidTextArea = _ref => {
19
19
  let {
20
20
  className,
21
21
  ...other
@@ -29,7 +29,7 @@ function FluidTextArea(_ref) {
29
29
  }, /*#__PURE__*/React__default.createElement(TextArea, _extends({
30
30
  className: classNames
31
31
  }, other)));
32
- }
32
+ };
33
33
  FluidTextArea.propTypes = {
34
34
  /**
35
35
  * Provide a custom className that is applied directly to the underlying
@@ -0,0 +1,12 @@
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 FluidTextArea from './FluidTextArea';
8
+ import { type FluidTextAreaProps } from './FluidTextArea';
9
+ import { type FluidTextAreaSkeletonProps } from './FluidTextArea.Skeleton';
10
+ export default FluidTextArea;
11
+ export { FluidTextArea, type FluidTextAreaProps, type FluidTextAreaSkeletonProps, };
12
+ export { default as FluidTextAreaSkeleton } from './FluidTextArea.Skeleton';
@@ -245,11 +245,11 @@ function getClassNameForBreakpoints(breakpoints, prefix) {
245
245
  start,
246
246
  end
247
247
  } = breakpoint;
248
- if (typeof offset === 'number' && offset > 0) {
249
- classNames.push(`${prefix}--${name}:col-start-${offset + 1}`);
248
+ if (typeof offset === 'number') {
249
+ classNames.push(`${prefix}--${name}:col-start-${offset > 0 ? offset + 1 : 'auto'}`);
250
250
  }
251
251
  if (typeof start === 'number') {
252
- classNames.push(`${prefix}--${name}:col-start-${start}`);
252
+ classNames.push(`${prefix}--${name}:col-start-${start ? start : 'auto'}`);
253
253
  }
254
254
  if (typeof end === 'number') {
255
255
  classNames.push(`${prefix}--${name}:col-end-${end}`);
@@ -13,6 +13,10 @@ interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>
13
13
  * Specify how the trigger should align with the tooltip
14
14
  */
15
15
  align?: 'top' | 'top-left' | 'top-start' | 'top-right' | 'top-end' | 'bottom' | 'bottom-left' | 'bottom-start' | 'bottom-right' | 'bottom-end' | 'left' | 'right';
16
+ /**
17
+ * **Experimental**: Will attempt to automatically align the tooltip
18
+ */
19
+ autoAlign?: boolean;
16
20
  /**
17
21
  * Provide an icon or asset to be rendered inside of the IconButton
18
22
  */
@@ -18,6 +18,7 @@ const IconButtonKinds = ['primary', 'secondary', 'ghost', 'tertiary'];
18
18
  const IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(_ref, ref) {
19
19
  let {
20
20
  align,
21
+ autoAlign = false,
21
22
  children,
22
23
  className,
23
24
  closeOnActivation = true,
@@ -38,6 +39,7 @@ const IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(_r
38
39
  });
39
40
  return /*#__PURE__*/React__default.createElement(Tooltip, {
40
41
  align: align,
42
+ autoAlign: autoAlign,
41
43
  closeOnActivation: closeOnActivation,
42
44
  className: tooltipClasses,
43
45
  defaultOpen: defaultOpen,
@@ -59,6 +61,10 @@ IconButton.propTypes = {
59
61
  * Specify how the trigger should align with the tooltip
60
62
  */
61
63
  align: PropTypes.oneOf(['top', 'top-left', 'top-start', 'top-right', 'top-end', 'bottom', 'bottom-left', 'bottom-start', 'bottom-right', 'bottom-end', 'left', 'right']),
64
+ /**
65
+ * **Experimental**: Will attempt to automatically align the tooltip
66
+ */
67
+ autoAlign: PropTypes.bool,
62
68
  /**
63
69
  * Provide an icon or asset to be rendered inside of the IconButton
64
70
  */
@@ -4,9 +4,14 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React, { ForwardedRef } from 'react';
7
+ import React, { ForwardedRef, ReactNode } from 'react';
8
8
  import { ForwardRefReturn, ReactAttr } from '../../types/common';
9
9
  export interface ListBoxMenuItemProps extends ReactAttr<HTMLLIElement> {
10
+ /**
11
+ * Specify any children nodes that should be rendered inside of the ListBox
12
+ * Menu Item
13
+ */
14
+ children?: ReactNode;
10
15
  /**
11
16
  * Specify whether the current menu item is "active".
12
17
  */
@@ -19,6 +24,10 @@ export interface ListBoxMenuItemProps extends ReactAttr<HTMLLIElement> {
19
24
  * Specify whether the item should be disabled
20
25
  */
21
26
  disabled?: boolean;
27
+ /**
28
+ * Provide an optional tooltip for the ListBoxMenuItem
29
+ */
30
+ title?: string;
22
31
  }
23
32
  export type ListBoxMenuItemForwardedRef = (ForwardedRef<HTMLLIElement> & {
24
33
  menuItemOptionRef?: React.Ref<HTMLDivElement>;
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import PropTypes from 'prop-types';
9
+ /**
10
+ * `ListBoxSelection` is used to provide controls for clearing a selection, in
11
+ * addition to conditionally rendering a badge if the control has more than one
12
+ * selection.
13
+ */
14
+ export declare const translationIds: {
15
+ readonly 'clear.all': "clear.all";
16
+ readonly 'clear.selection': "clear.selection";
17
+ };
18
+ export type TranslationKey = keyof typeof translationIds;
19
+ export interface ListBoxSelectionProps {
20
+ /**
21
+ * Specify a function to be invoked when a user interacts with the clear
22
+ * selection element.
23
+ */
24
+ clearSelection: (event: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
25
+ /**
26
+ * Specify an optional `selectionCount` value that will be used to determine
27
+ * whether the selection should display a badge or a single clear icon.
28
+ */
29
+ selectionCount?: number;
30
+ /**
31
+ * i18n hook used to provide the appropriate description for the given menu
32
+ * icon. This function takes in an id defined in `translationIds` and should
33
+ * return a string message for that given message id.
34
+ */
35
+ translateWithId?: (id: TranslationKey) => string;
36
+ /**
37
+ * Specify whether or not the clear selection element should be disabled
38
+ */
39
+ disabled?: boolean;
40
+ /**
41
+ * Specify an optional `onClearSelection` handler that is called when the underlying
42
+ * element is cleared
43
+ */
44
+ onClearSelection?: (event: React.MouseEvent<HTMLButtonElement>) => void;
45
+ /**
46
+ * Specify an optional `onClick` handler that is called when the underlying
47
+ * clear selection element is clicked
48
+ */
49
+ onClick?: React.MouseEventHandler<HTMLButtonElement>;
50
+ /**
51
+ * Specify an optional `onKeyDown` handler that is called when the underlying
52
+ * clear selection element fires a keydown event
53
+ */
54
+ onKeyDown?: React.KeyboardEventHandler<HTMLButtonElement>;
55
+ /**
56
+ * Specify an optional `onMouseUp` handler that is called when the underlying
57
+ * clear selection element fires a mouseup event
58
+ */
59
+ onMouseUp?: React.MouseEventHandler<HTMLButtonElement>;
60
+ }
61
+ declare function ListBoxSelection({ clearSelection, selectionCount, translateWithId: t, disabled, onClearSelection, ...rest }: ListBoxSelectionProps): import("react/jsx-runtime").JSX.Element;
62
+ declare namespace ListBoxSelection {
63
+ var propTypes: {
64
+ /**
65
+ * Specify a function to be invoked when a user interacts with the clear
66
+ * selection element.
67
+ */
68
+ clearSelection: PropTypes.Validator<(...args: any[]) => any>;
69
+ /**
70
+ * Specify whether or not the clear selection element should be disabled
71
+ */
72
+ disabled: PropTypes.Requireable<boolean>;
73
+ /**
74
+ * Specify an optional `onClearSelection` handler that is called when the underlying
75
+ * element is cleared
76
+ */
77
+ onClearSelection: PropTypes.Requireable<(...args: any[]) => any>;
78
+ /**
79
+ * Specify an optional `onClick` handler that is called when the underlying
80
+ * clear selection element is clicked
81
+ */
82
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
83
+ /**
84
+ * Specify an optional `onClick` handler that is called when the underlying
85
+ * clear selection element is clicked
86
+ */
87
+ onMouseUp: PropTypes.Requireable<(...args: any[]) => any>;
88
+ /**
89
+ * Specify an optional `onKeyDown` handler that is called when the underlying
90
+ * clear selection element fires a keydown event
91
+ */
92
+ onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
93
+ /**
94
+ * Specify an optional `selectionCount` value that will be used to determine
95
+ * whether the selection should display a badge or a single clear icon.
96
+ */
97
+ selectionCount: PropTypes.Requireable<number>;
98
+ /**
99
+ * i18n hook used to provide the appropriate description for the given menu
100
+ * icon. This function takes in an id defined in `translationIds` and should
101
+ * return a string message for that given message id.
102
+ */
103
+ translateWithId: PropTypes.Requireable<(...args: any[]) => any>;
104
+ };
105
+ }
106
+ export default ListBoxSelection;
@@ -13,22 +13,13 @@ import { Close } from '@carbon/icons-react';
13
13
  import { usePrefix } from '../../../internal/usePrefix.js';
14
14
 
15
15
  var _Close, _Close2;
16
-
17
- /**
18
- * `ListBoxSelection` is used to provide controls for clearing a selection, in
19
- * addition to conditionally rendering a badge if the control has more than one
20
- * selection.
21
- */
22
-
23
- const translationIds = {
24
- 'clear.all': 'clear.all',
25
- 'clear.selection': 'clear.selection'
26
- };
27
16
  const defaultTranslations = {
28
- [translationIds['clear.all']]: 'Clear all selected items',
29
- [translationIds['clear.selection']]: 'Clear selected item'
17
+ 'clear.all': 'Clear all selected items',
18
+ 'clear.selection': 'Clear selected item'
30
19
  };
31
- const defaultTranslateWithId = id => defaultTranslations[id];
20
+ function defaultTranslateWithId(id) {
21
+ return defaultTranslations[id];
22
+ }
32
23
  function ListBoxSelection(_ref) {
33
24
  let {
34
25
  clearSelection,
@@ -62,7 +53,7 @@ function ListBoxSelection(_ref) {
62
53
  className: tagClasses
63
54
  }, /*#__PURE__*/React__default.createElement("span", {
64
55
  className: `${prefix}--tag__label`,
65
- title: selectionCount
56
+ title: selectionCount?.toString()
66
57
  }, selectionCount), /*#__PURE__*/React__default.createElement("button", {
67
58
  "aria-label": description,
68
59
  className: `${prefix}--tag__close-icon`,
@@ -103,6 +94,11 @@ ListBoxSelection.propTypes = {
103
94
  * clear selection element is clicked
104
95
  */
105
96
  onClick: PropTypes.func,
97
+ /**
98
+ * Specify an optional `onClick` handler that is called when the underlying
99
+ * clear selection element is clicked
100
+ */
101
+ onMouseUp: PropTypes.func,
106
102
  /**
107
103
  * Specify an optional `onKeyDown` handler that is called when the underlying
108
104
  * clear selection element fires a keydown event
@@ -121,4 +117,4 @@ ListBoxSelection.propTypes = {
121
117
  translateWithId: PropTypes.func
122
118
  };
123
119
 
124
- export { ListBoxSelection as default, translationIds };
120
+ export { ListBoxSelection as default };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ export declare const translationIds: {
9
+ readonly 'close.menu': "close.menu";
10
+ readonly 'open.menu': "open.menu";
11
+ };
12
+ export type TranslationKey = keyof typeof translationIds;
13
+ export interface ListBoxTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
14
+ /**
15
+ * Specify whether the menu is currently open, which will influence the
16
+ * direction of the menu icon
17
+ */
18
+ isOpen: boolean;
19
+ /**
20
+ * i18n hook used to provide the appropriate description for the given menu
21
+ * icon. This function takes in an id defined in `translationIds` and should
22
+ * return a string message for that given message id.
23
+ */
24
+ translateWithId?: (id: TranslationKey) => string;
25
+ }
26
+ /**
27
+ * `ListBoxTrigger` is used to orient the icon up or down depending on the
28
+ * state of the menu for a given `ListBox`
29
+ */
30
+ declare const ListBoxTrigger: React.ForwardRefExoticComponent<ListBoxTriggerProps & React.RefAttributes<HTMLButtonElement>>;
31
+ export default ListBoxTrigger;
@@ -22,7 +22,6 @@ const defaultTranslations = {
22
22
  [translationIds['open.menu']]: 'Open'
23
23
  };
24
24
  const defaultTranslateWithId = id => defaultTranslations[id];
25
-
26
25
  /**
27
26
  * `ListBoxTrigger` is used to orient the icon up or down depending on the
28
27
  * state of the menu for a given `ListBox`
@@ -45,7 +44,7 @@ const ListBoxTrigger = /*#__PURE__*/React__default.forwardRef(function ListBoxTr
45
44
  title: description,
46
45
  className: className,
47
46
  type: "button",
48
- tabIndex: "-1",
47
+ tabIndex: -1,
49
48
  ref: ref
50
49
  }), _ChevronDown || (_ChevronDown = /*#__PURE__*/React__default.createElement(ChevronDown, null)));
51
50
  });
@@ -62,6 +61,5 @@ ListBoxTrigger.propTypes = {
62
61
  */
63
62
  translateWithId: PropTypes.func
64
63
  };
65
- var ListBoxTrigger$1 = ListBoxTrigger;
66
64
 
67
- export { ListBoxTrigger$1 as default, translationIds };
65
+ export { ListBoxTrigger as default, translationIds };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ export { default as ListBoxSelection, type ListBoxSelectionProps, } from './ListBoxSelection';
8
+ export { default as ListBoxTrigger, type ListBoxTriggerProps, } from './ListBoxTrigger';
@@ -282,7 +282,8 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, forwardRef) {
282
282
  [`${prefix}--menu--box-shadow-top`]: menuAlignment && menuAlignment.slice(0, 3) === 'top',
283
283
  [`${prefix}--menu--open`]: open,
284
284
  [`${prefix}--menu--shown`]: open && !legacyAutoalign || position[0] >= 0 && position[1] >= 0,
285
- [`${prefix}--menu--with-icons`]: childContext.state.hasIcons
285
+ [`${prefix}--menu--with-icons`]: childContext.state.hasIcons,
286
+ [`${prefix}--autoalign`]: !legacyAutoalign
286
287
  });
287
288
  const rendered = /*#__PURE__*/React__default.createElement(MenuContext.Provider, {
288
289
  value: childContext