@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
package/es/index.js CHANGED
@@ -159,6 +159,8 @@ export { default as SideNavMenuItem } from './components/UIShell/SideNavMenuItem
159
159
  export { default as SideNavSwitcher } from './components/UIShell/SideNavSwitcher.js';
160
160
  export { default as UnorderedList } from './components/UnorderedList/UnorderedList.js';
161
161
  export { FeatureFlags as unstable_FeatureFlags, useFeatureFlag as unstable_useFeatureFlag, useFeatureFlags as unstable_useFeatureFlags } from './components/FeatureFlags/index.js';
162
+ export { default as unstable__FluidTextArea } from './components/FluidTextArea/FluidTextArea.js';
163
+ export { default as unstable__FluidTextAreaSkeleton } from './components/FluidTextArea/FluidTextArea.Skeleton.js';
162
164
  export { Heading, Section } from './components/Heading/index.js';
163
165
  export { IconButton, IconButtonKinds } from './components/IconButton/index.js';
164
166
  export { Layer, useLayer } from './components/Layer/index.js';
@@ -167,6 +169,8 @@ export { OverflowMenuV2 as unstable_OverflowMenuV2 } from './components/Overflow
167
169
  export { Popover, PopoverContent } from './components/Popover/index.js';
168
170
  export { default as ProgressBar } from './components/ProgressBar/ProgressBar.js';
169
171
  export { AILabel, AILabelActions, AILabelContent, AILabel as unstable__Slug, AILabelActions as unstable__SlugActions, AILabelContent as unstable__SlugContent } from './components/AILabel/index.js';
172
+ export { default as unstable__ChatButton } from './components/ChatButton/ChatButton.js';
173
+ export { default as unstable__ChatButtonSkeleton } from './components/ChatButton/ChatButton.Skeleton.js';
170
174
  export { default as AISkeletonPlaceholder, default as unstable__AiSkeletonPlaceholder } from './components/AISkeleton/AISkeletonPlaceholder.js';
171
175
  export { default as AISkeletonIcon, default as unstable__AiSkeletonIcon } from './components/AISkeleton/AISkeletonIcon.js';
172
176
  export { default as AISkeletonText, default as unstable__AiSkeletonText } from './components/AISkeleton/AISkeletonText.js';
@@ -178,8 +182,6 @@ export { PrefixContext, usePrefix } from './internal/usePrefix.js';
178
182
  export { useIdPrefix } from './internal/useIdPrefix.js';
179
183
  export { default as unstable__FluidDatePickerSkeleton } from './components/FluidDatePicker/FluidDatePicker.Skeleton.js';
180
184
  export { default as unstable__FluidSearchSkeleton } from './components/FluidSearch/FluidSearch.Skeleton.js';
181
- export { default as unstable__FluidTextArea } from './components/FluidTextArea/FluidTextArea.js';
182
- export { default as unstable__FluidTextAreaSkeleton } from './components/FluidTextArea/FluidTextArea.Skeleton.js';
183
185
  export { default as unstable__FluidTextInput } from './components/FluidTextInput/FluidTextInput.js';
184
186
  export { default as unstable__FluidTextInputSkeleton } from './components/FluidTextInput/FluidTextInput.Skeleton.js';
185
187
  export { default as unstable_PageSelector } from './components/Pagination/experimental/PageSelector.js';
@@ -206,8 +208,6 @@ export { default as unstable__FluidTimePickerSkeleton } from './components/Fluid
206
208
  export { default as unstable__FluidTimePickerSelect } from './components/FluidTimePickerSelect/FluidTimePickerSelect.js';
207
209
  export { LayoutDirection as unstable_LayoutDirection } from './components/LayoutDirection/LayoutDirection.js';
208
210
  export { useLayoutDirection as unstable_useLayoutDirection } from './components/LayoutDirection/useLayoutDirection.js';
209
- export { default as unstable__ChatButton } from './components/ChatButton/ChatButton.js';
210
- export { default as unstable__ChatButtonSkeleton } from './components/ChatButton/ChatButton.Skeleton.js';
211
211
  export { Text as unstable_Text } from './components/Text/Text.js';
212
212
  export { TextDirection as unstable_TextDirection } from './components/Text/TextDirection.js';
213
213
  export { default as CheckboxGroup } from './components/CheckboxGroup/CheckboxGroup.js';
@@ -33,7 +33,9 @@ function useSelection(_ref2) {
33
33
  disabled,
34
34
  onChange,
35
35
  initialSelectedItems = [],
36
- selectedItems: controlledItems
36
+ selectedItems: controlledItems,
37
+ selectAll = false,
38
+ filteredItems = []
37
39
  } = _ref2;
38
40
  const isMounted = useRef(false);
39
41
  const savedOnChange = useRef(onChange);
@@ -44,25 +46,35 @@ function useSelection(_ref2) {
44
46
  if (disabled) {
45
47
  return;
46
48
  }
47
- let selectedIndex;
48
- selectedItems.forEach((selectedItem, index) => {
49
- if (isEqual(selectedItem, item)) {
50
- selectedIndex = index;
51
- }
52
- });
49
+ const allSelectableItems = filteredItems.filter(item => !item.disabled);
50
+ const disabledItemCount = filteredItems.filter(item => item.disabled).length;
53
51
  let newSelectedItems;
54
- if (selectedIndex === undefined) {
55
- newSelectedItems = selectedItems.concat(item);
56
- callOnChangeHandler({
57
- isControlled,
58
- isMounted: isMounted.current,
59
- onChangeHandlerControlled: savedOnChange.current,
60
- onChangeHandlerUncontrolled: setUncontrolledItems,
61
- selectedItems: newSelectedItems
52
+
53
+ //deselect all on click to All/indeterminate option
54
+ if (item && item.isSelectAll && selectedItems.length > 0) {
55
+ newSelectedItems = [];
56
+ }
57
+ //select all option
58
+ else if (item && item.isSelectAll && selectedItems.length == 0) {
59
+ newSelectedItems = allSelectableItems;
60
+ } else {
61
+ let selectedIndex;
62
+ selectedItems.forEach((selectedItem, index) => {
63
+ if (isEqual(selectedItem, item)) {
64
+ selectedIndex = index;
65
+ }
62
66
  });
63
- return;
67
+ if (selectedIndex === undefined) {
68
+ newSelectedItems = selectedItems.concat(item);
69
+ // checking if all items are selected then We should select mark the 'select All' option as well
70
+ if (selectAll && filteredItems.length - 1 === newSelectedItems.length + disabledItemCount) {
71
+ newSelectedItems = allSelectableItems;
72
+ }
73
+ } else {
74
+ newSelectedItems = removeAtIndex(selectedItems, selectedIndex);
75
+ newSelectedItems = newSelectedItems.filter(item => !item.isSelectAll);
76
+ }
64
77
  }
65
- newSelectedItems = removeAtIndex(selectedItems, selectedIndex);
66
78
  callOnChangeHandler({
67
79
  isControlled,
68
80
  isMounted: isMounted.current,
@@ -70,7 +82,7 @@ function useSelection(_ref2) {
70
82
  onChangeHandlerUncontrolled: setUncontrolledItems,
71
83
  selectedItems: newSelectedItems
72
84
  });
73
- }, [disabled, isControlled, selectedItems]);
85
+ }, [disabled, selectedItems, filteredItems, selectAll, isControlled]);
74
86
  const clearSelection = useCallback(() => {
75
87
  if (disabled) {
76
88
  return;
@@ -10,4 +10,4 @@ import { Ref, ForwardedRef } from 'react';
10
10
  * refs from both `React.forwardRef` and `useRef` that you would like to add to
11
11
  * the same node.
12
12
  */
13
- export declare const useMergedRefs: <T>(refs: ForwardedRef<T>[]) => Ref<T>;
13
+ export declare const useMergedRefs: <T extends unknown>(refs: ForwardedRef<T>[]) => Ref<T>;
@@ -0,0 +1,37 @@
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 type AILabelContentProps = React.HTMLAttributes<HTMLSpanElement>;
9
+ export declare const AILabelContent: React.ForwardRefExoticComponent<AILabelContentProps & React.RefAttributes<unknown>>;
10
+ export type AILabelActionsProps = React.HTMLAttributes<HTMLSpanElement>;
11
+ export declare const AILabelActions: React.ForwardRefExoticComponent<AILabelActionsProps & React.RefAttributes<unknown>>;
12
+ /**
13
+ * Deprecated popover alignment values.
14
+ * @deprecated Use NewPopoverAlignment instead.
15
+ */
16
+ export type DeprecatedAlignment = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'left-bottom' | 'left-top' | 'right-bottom' | 'right-top';
17
+ export type NewAlignment = 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-end' | 'left-start' | 'right-end' | 'right-start';
18
+ export type Alignment = DeprecatedAlignment | NewAlignment;
19
+ interface AILabelProps {
20
+ AILabelContent?: React.ReactNode;
21
+ aiText?: string;
22
+ aiTextLabel?: string;
23
+ textLabel?: string;
24
+ align?: Alignment;
25
+ autoAlign?: boolean;
26
+ children?: React.ReactNode;
27
+ className?: string;
28
+ kind?: 'default' | 'inline';
29
+ onRevertClick?: (evt: React.MouseEvent<HTMLButtonElement>) => void;
30
+ revertActive?: boolean;
31
+ revertLabel?: string;
32
+ size?: 'mini' | '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
33
+ 'aria-label'?: string;
34
+ slugLabel?: string;
35
+ }
36
+ export declare const AILabel: React.ForwardRefExoticComponent<AILabelProps & React.RefAttributes<HTMLDivElement>>;
37
+ export {};
@@ -12,10 +12,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
12
12
  var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
13
13
  var cx = require('classnames');
14
14
  var PropTypes = require('prop-types');
15
+ var deprecateValuesWithin = require('../../prop-types/deprecateValuesWithin.js');
15
16
  var React = require('react');
16
17
  var usePrefix = require('../../internal/usePrefix.js');
17
18
  var index = require('../Toggletip/index.js');
18
19
  var index$1 = require('../IconButton/index.js');
20
+ var createPropAdapter = require('../../tools/createPropAdapter.js');
19
21
  var iconsReact = require('@carbon/icons-react');
20
22
  var useId = require('../../internal/useId.js');
21
23
  var deprecate = require('../../prop-types/deprecate.js');
@@ -29,11 +31,15 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
29
31
  var _Undo;
30
32
  const AILabelContent = /*#__PURE__*/React__default["default"].forwardRef(function AILabelContent(_ref, ref) {
31
33
  let {
34
+ className,
32
35
  children,
33
- className
36
+ ...rest
34
37
  } = _ref;
35
38
  const prefix = usePrefix.usePrefix();
36
- const hasAILabelActions = React__default["default"].Children.toArray(children).some(child => child.type?.displayName === 'AILabelActions');
39
+ const hasAILabelActions = React__default["default"].Children.toArray(children).some(child => {
40
+ const item = child;
41
+ item.type?.displayName === 'AILabelActions';
42
+ });
37
43
  const aiLabelContentClasses = cx__default["default"](className, {
38
44
  [`${prefix}--slug-content`]: true,
39
45
  [`${prefix}--slug-content--with-actions`]: hasAILabelActions
@@ -55,16 +61,16 @@ AILabelContent.propTypes = {
55
61
  };
56
62
  const AILabelActions = /*#__PURE__*/React__default["default"].forwardRef(function AILabelActions(_ref2, ref) {
57
63
  let {
64
+ className,
58
65
  children,
59
- className
66
+ ...rest
60
67
  } = _ref2;
61
68
  const prefix = usePrefix.usePrefix();
62
69
  const aiLabelActionsClasses = cx__default["default"](className, {
63
70
  [`${prefix}--slug-actions`]: true
64
71
  });
65
72
  return /*#__PURE__*/React__default["default"].createElement(index.ToggletipActions, {
66
- className: aiLabelActionsClasses,
67
- ref: ref
73
+ className: aiLabelActionsClasses
68
74
  }, children);
69
75
  });
70
76
  AILabelActions.displayName = 'AILabelActions';
@@ -78,6 +84,15 @@ AILabelActions.propTypes = {
78
84
  */
79
85
  className: PropTypes__default["default"].string
80
86
  };
87
+
88
+ /**
89
+ * Deprecated popover alignment values.
90
+ * @deprecated Use NewPopoverAlignment instead.
91
+ */
92
+
93
+ const propMappingFunction = deprecatedValue => {
94
+ return createPropAdapter.mapPopoverAlignProp(deprecatedValue);
95
+ };
81
96
  const AILabel = /*#__PURE__*/React__default["default"].forwardRef(function AILabel(_ref3, ref) {
82
97
  let {
83
98
  aiText = 'AI',
@@ -153,23 +168,32 @@ AILabel.propTypes = {
153
168
  /**
154
169
  * Specify how the popover should align with the button
155
170
  */
156
- align: PropTypes__default["default"].oneOf(['top', 'top-left',
171
+ align: deprecateValuesWithin["default"](PropTypes__default["default"].oneOf(['top', 'top-left',
157
172
  // deprecated use top-start instead
158
- 'top-start', 'top-right',
173
+ 'top-right',
159
174
  // deprecated use top-end instead
160
- 'top-end', 'bottom', 'bottom-left',
175
+
176
+ 'bottom', 'bottom-left',
161
177
  // deprecated use bottom-start instead
162
- 'bottom-start', 'bottom-right',
178
+ 'bottom-right',
163
179
  // deprecated use bottom-end instead
164
- 'bottom-end', 'left', 'left-bottom',
180
+
181
+ 'left', 'left-bottom',
165
182
  // deprecated use left-end instead
166
- 'left-end', 'left-top',
183
+ 'left-top',
167
184
  // deprecated use left-start instead
168
- 'left-start', 'right', 'right-bottom',
185
+
186
+ 'right', 'right-bottom',
169
187
  // deprecated use right-end instead
170
- 'right-end', 'right-top',
188
+ 'right-top',
171
189
  // deprecated use right-start instead
172
- 'right-start']),
190
+
191
+ // new values to match floating-ui
192
+ 'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
193
+ //allowed prop values
194
+ ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'],
195
+ //optional mapper function
196
+ propMappingFunction),
173
197
  /**
174
198
  * Specify the text that will be provided to the aria-label of the `AILabel` button
175
199
  */
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import PropTypes from 'prop-types';
8
- import { PropsWithChildren } from 'react';
8
+ import { PropsWithChildren, ReactNode } from 'react';
9
9
  export interface AccordionProps {
10
10
  /**
11
11
  * Specify the alignment of the accordion heading
@@ -17,6 +17,10 @@ export interface AccordionProps {
17
17
  * the container node.
18
18
  */
19
19
  className?: string;
20
+ /**
21
+ * Pass in the children that will be rendered within the Accordion
22
+ */
23
+ children?: ReactNode;
20
24
  /**
21
25
  * Specify whether an individual AccordionItem
22
26
  * should be disabled.
@@ -64,7 +64,7 @@ const BreadcrumbItem = /*#__PURE__*/React__default["default"].forwardRef(functio
64
64
  ref: ref
65
65
  }, rest), href ? /*#__PURE__*/React__default["default"].createElement(Link["default"], {
66
66
  href: href,
67
- "aria-current": ariaCurrent
67
+ "aria-current": ariaCurrent || isCurrentPage
68
68
  }, children) : /*#__PURE__*/React__default["default"].createElement(Text.Text, {
69
69
  className: `${prefix}--link`
70
70
  }, children));
@@ -5,6 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
+ import { IconButtonKind } from '../IconButton';
8
9
  import { PolymorphicProps } from '../../types/common';
9
10
  export declare const ButtonKinds: readonly ["primary", "secondary", "danger", "ghost", "danger--primary", "danger--ghost", "danger--tertiary", "tertiary"];
10
11
  export type ButtonKind = (typeof ButtonKinds)[number];
@@ -43,7 +44,7 @@ export interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonEl
43
44
  /**
44
45
  * Specify the kind of Button you want to create
45
46
  */
46
- kind?: ButtonKind;
47
+ kind?: ButtonBaseProps['hasIconOnly'] extends true ? IconButtonKind : ButtonKind;
47
48
  /**
48
49
  * Optional prop to allow overriding the icon rendering.
49
50
  * Can be a React component class
@@ -150,8 +150,19 @@ Button.propTypes = {
150
150
  /**
151
151
  * Specify the kind of Button you want to create
152
152
  */
153
- // TODO: this should be either ButtonKinds or IconButtonKinds based on the value of "hasIconOnly"
154
- kind: PropTypes__default["default"].oneOf(ButtonKinds),
153
+ kind: (props, propName, componentName) => {
154
+ const {
155
+ hasIconOnly
156
+ } = props;
157
+ const validKinds = hasIconOnly ? index.IconButtonKinds : ButtonKinds;
158
+ if (props[propName] === undefined) {
159
+ return null;
160
+ }
161
+ if (!validKinds.includes(props[propName])) {
162
+ return new Error(`Invalid prop \`${propName}\` supplied to \`${componentName}\`. Expected one of ${validKinds.join(', ')}.`);
163
+ }
164
+ return null;
165
+ },
155
166
  /**
156
167
  * Provide an optional function to be called when the button element
157
168
  * loses focus
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright IBM Corp. 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 PropTypes from 'prop-types';
8
+ export interface ChatButtonSkeletonProps {
9
+ /**
10
+ * Specify an optional className to add.
11
+ */
12
+ className?: string;
13
+ /**
14
+ * Specify the size of the `ChatButtonSkeleton`, from the following list of sizes:
15
+ */
16
+ size?: 'sm' | 'md' | 'lg';
17
+ }
18
+ declare const ChatButtonSkeleton: {
19
+ ({ className, size, ...rest }: ChatButtonSkeletonProps): import("react/jsx-runtime").JSX.Element;
20
+ propTypes: {
21
+ /**
22
+ * Specify an optional className to add.
23
+ */
24
+ className: PropTypes.Requireable<string>;
25
+ /**
26
+ * Specify the size of the `ChatButtonSkeleton`, from the following list of sizes:
27
+ */
28
+ size: PropTypes.Requireable<string>;
29
+ };
30
+ };
31
+ export default ChatButtonSkeleton;
@@ -45,6 +45,5 @@ ChatButtonSkeleton.propTypes = {
45
45
  */
46
46
  size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg'])
47
47
  };
48
- var ChatButtonSkeleton$1 = ChatButtonSkeleton;
49
48
 
50
- exports["default"] = ChatButtonSkeleton$1;
49
+ exports["default"] = ChatButtonSkeleton;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Copyright IBM Corp. 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, { type ComponentType, type FunctionComponent } from 'react';
8
+ export type ChatButtonKind = 'primary' | 'secondary' | 'danger' | 'ghost' | 'tertiary';
9
+ export type ChatButtonSize = 'sm' | 'md' | 'lg';
10
+ export interface ChatButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
11
+ /**
12
+ * Provide the contents of your Select
13
+ */
14
+ children?: React.ReactNode;
15
+ /**
16
+ * Specify an optional className to be applied to the node containing the label and the select box
17
+ */
18
+ className?: string;
19
+ /**
20
+ * Specify whether the `ChatButton` should be disabled
21
+ */
22
+ disabled?: boolean;
23
+ /**
24
+ * Specify whether the `ChatButton` should be rendered as a quick action button
25
+ */
26
+ isQuickAction?: boolean;
27
+ /**
28
+ * Specify whether the quick action `ChatButton` should be rendered as selected. This disables the input
29
+ */
30
+ isSelected?: boolean;
31
+ /**
32
+ * Specify the kind of `ChatButton` you want to create
33
+ */
34
+ kind?: ChatButtonKind;
35
+ /**
36
+ * Optional prop to specify an icon to be rendered.
37
+ * Can be a React component class
38
+ */
39
+ renderIcon?: ComponentType | FunctionComponent;
40
+ /**
41
+ * Specify the size of the `ChatButton`, from the following list of sizes:
42
+ */
43
+ size?: ChatButtonSize;
44
+ }
45
+ declare const ChatButton: React.ForwardRefExoticComponent<ChatButtonProps & React.RefAttributes<HTMLButtonElement>>;
46
+ export default ChatButton;
@@ -10,8 +10,8 @@
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
12
  var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
13
- var PropTypes = require('prop-types');
14
13
  var React = require('react');
14
+ var PropTypes = require('prop-types');
15
15
  var cx = require('classnames');
16
16
  var Button = require('../Button/Button.js');
17
17
  require('../Button/Button.Skeleton.js');
@@ -19,8 +19,8 @@ var usePrefix = require('../../internal/usePrefix.js');
19
19
 
20
20
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
21
 
22
- var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
23
22
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
23
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
24
24
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
25
25
 
26
26
  const ChatButton = /*#__PURE__*/React__default["default"].forwardRef(function ChatButton(_ref, ref) {
@@ -88,12 +88,12 @@ ChatButton.propTypes = {
88
88
  * Optional prop to specify an icon to be rendered.
89
89
  * Can be a React component class
90
90
  */
91
+ // @ts-expect-error: PropTypes are not expressive enough to cover this case
91
92
  renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
92
93
  /**
93
94
  * Specify the size of the `ChatButton`, from the following list of sizes:
94
95
  */
95
96
  size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg'])
96
97
  };
97
- var ChatButton$1 = ChatButton;
98
98
 
99
- exports["default"] = ChatButton$1;
99
+ exports["default"] = ChatButton;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright IBM Corp. 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 ChatButton from './ChatButton';
8
+ import { type ChatButtonProps } from './ChatButton';
9
+ import { type ChatButtonSkeletonProps } from './ChatButton.Skeleton';
10
+ export default ChatButton;
11
+ export { ChatButton, type ChatButtonProps, type ChatButtonSkeletonProps };
12
+ export { default as ChatButtonSkeleton } from './ChatButton.Skeleton';
@@ -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
+
8
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var Checkbox = require('./Checkbox.js');
13
+ var Checkbox_Skeleton = require('./Checkbox.Skeleton.js');
14
+
15
+
16
+
17
+ exports.Checkbox = Checkbox["default"];
18
+ exports["default"] = Checkbox["default"];
19
+ exports.CheckboxSkeleton = Checkbox_Skeleton["default"];
@@ -11,6 +11,10 @@ export interface CodeSnippetProps {
11
11
  * Specify how the trigger should align with the tooltip
12
12
  */
13
13
  align?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
14
+ /**
15
+ * **Experimental**: Will attempt to automatically align the tooltip
16
+ */
17
+ autoAlign?: boolean;
14
18
  /**
15
19
  * Specify a label to be read by screen readers on the containing textbox
16
20
  * node
@@ -96,7 +100,7 @@ export interface CodeSnippetProps {
96
100
  */
97
101
  wrapText?: boolean;
98
102
  }
99
- declare function CodeSnippet({ align, className, type, children, disabled, feedback, feedbackTimeout, onClick, ['aria-label']: ariaLabel, ariaLabel: deprecatedAriaLabel, copyText, copyButtonDescription, light, showMoreText, showLessText, hideCopyButton, wrapText, maxCollapsedNumberOfRows, maxExpandedNumberOfRows, minCollapsedNumberOfRows, minExpandedNumberOfRows, ...rest }: PropsWithChildren<CodeSnippetProps>): import("react/jsx-runtime").JSX.Element;
103
+ declare function CodeSnippet({ align, autoAlign, className, type, children, disabled, feedback, feedbackTimeout, onClick, ['aria-label']: ariaLabel, ariaLabel: deprecatedAriaLabel, copyText, copyButtonDescription, light, showMoreText, showLessText, hideCopyButton, wrapText, maxCollapsedNumberOfRows, maxExpandedNumberOfRows, minCollapsedNumberOfRows, minExpandedNumberOfRows, ...rest }: PropsWithChildren<CodeSnippetProps>): import("react/jsx-runtime").JSX.Element;
100
104
  declare namespace CodeSnippet {
101
105
  var propTypes: {
102
106
  /**
@@ -114,6 +118,10 @@ declare namespace CodeSnippet {
114
118
  * node
115
119
  */
116
120
  ariaLabel: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
121
+ /**
122
+ * **Experimental**: Will attempt to automatically align the tooltip
123
+ */
124
+ autoAlign: PropTypes.Requireable<boolean>;
117
125
  /**
118
126
  * Provide the content of your CodeSnippet as a node or string
119
127
  */
@@ -40,6 +40,7 @@ const defaultMinExpandedNumberOfRows = 16;
40
40
  function CodeSnippet(_ref) {
41
41
  let {
42
42
  align = 'bottom',
43
+ autoAlign = false,
43
44
  className,
44
45
  type = 'single',
45
46
  children,
@@ -162,6 +163,7 @@ function CodeSnippet(_ref) {
162
163
  }
163
164
  return /*#__PURE__*/React__default["default"].createElement(Copy["default"], _rollupPluginBabelHelpers["extends"]({}, rest, {
164
165
  align: align,
166
+ autoAlign: autoAlign,
165
167
  onClick: handleCopyClick,
166
168
  "aria-label": deprecatedAriaLabel || ariaLabel,
167
169
  "aria-describedby": uid,
@@ -217,6 +219,7 @@ function CodeSnippet(_ref) {
217
219
  className: `${prefix}--snippet__overflow-indicator--right`
218
220
  }), !hideCopyButton && /*#__PURE__*/React__default["default"].createElement(CopyButton["default"], {
219
221
  align: align,
222
+ autoAlign: autoAlign,
220
223
  size: type === 'multi' ? 'sm' : 'md',
221
224
  disabled: disabled,
222
225
  onClick: handleCopyClick,
@@ -253,6 +256,10 @@ CodeSnippet.propTypes = {
253
256
  * node
254
257
  */
255
258
  ariaLabel: deprecate["default"](PropTypes__default["default"].string, 'This prop syntax has been deprecated. Please use the new `aria-label`.'),
259
+ /**
260
+ * **Experimental**: Will attempt to automatically align the tooltip
261
+ */
262
+ autoAlign: PropTypes__default["default"].bool,
256
263
  /**
257
264
  * Provide the content of your CodeSnippet as a node or string
258
265
  */