@carbon/react 1.58.0 → 1.59.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1255 -1097
  2. package/es/components/Accordion/Accordion.Skeleton.d.ts +6 -1
  3. package/es/components/Accordion/Accordion.Skeleton.js +3 -1
  4. package/es/components/Accordion/Accordion.d.ts +11 -1
  5. package/es/components/Accordion/Accordion.js +8 -1
  6. package/es/components/CheckboxGroup/CheckboxGroup.js +7 -0
  7. package/es/components/ComboButton/index.d.ts +2 -1
  8. package/es/components/ComboButton/index.js +51 -31
  9. package/es/components/ContainedList/index.js +4 -0
  10. package/es/components/ListBox/ListBoxMenuItem.js +1 -1
  11. package/es/components/RadioTile/RadioTile.d.ts +9 -0
  12. package/es/components/RadioTile/RadioTile.js +24 -3
  13. package/es/components/Tag/DismissibleTag.js +7 -9
  14. package/es/components/Tag/OperationalTag.js +9 -10
  15. package/es/components/Tag/SelectableTag.js +9 -10
  16. package/es/components/Tag/Tag.d.ts +4 -60
  17. package/es/components/Tag/Tag.js +14 -14
  18. package/es/components/Tag/isEllipsisActive.d.ts +7 -0
  19. package/es/components/Tag/isEllipsisActive.js +15 -0
  20. package/es/components/Tooltip/Tooltip.js +42 -22
  21. package/es/components/UIShell/Content.d.ts +3 -3
  22. package/es/components/UIShell/SwitcherItem.d.ts +5 -1
  23. package/es/components/UIShell/SwitcherItem.js +7 -1
  24. package/lib/components/Accordion/Accordion.Skeleton.d.ts +6 -1
  25. package/lib/components/Accordion/Accordion.Skeleton.js +3 -1
  26. package/lib/components/Accordion/Accordion.d.ts +11 -1
  27. package/lib/components/Accordion/Accordion.js +8 -1
  28. package/lib/components/CheckboxGroup/CheckboxGroup.js +7 -0
  29. package/lib/components/ComboButton/index.d.ts +2 -1
  30. package/lib/components/ComboButton/index.js +45 -25
  31. package/lib/components/ContainedList/index.js +4 -0
  32. package/lib/components/ListBox/ListBoxMenuItem.js +1 -1
  33. package/lib/components/RadioTile/RadioTile.d.ts +9 -0
  34. package/lib/components/RadioTile/RadioTile.js +24 -3
  35. package/lib/components/Tag/DismissibleTag.js +6 -8
  36. package/lib/components/Tag/OperationalTag.js +8 -9
  37. package/lib/components/Tag/SelectableTag.js +8 -9
  38. package/lib/components/Tag/Tag.d.ts +4 -60
  39. package/lib/components/Tag/Tag.js +13 -13
  40. package/lib/components/Tag/isEllipsisActive.d.ts +7 -0
  41. package/lib/components/Tag/isEllipsisActive.js +19 -0
  42. package/lib/components/Tooltip/Tooltip.js +42 -22
  43. package/lib/components/UIShell/Content.d.ts +3 -3
  44. package/lib/components/UIShell/SwitcherItem.d.ts +5 -1
  45. package/lib/components/UIShell/SwitcherItem.js +7 -1
  46. package/package.json +3 -3
@@ -4,7 +4,6 @@
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 PropTypes from 'prop-types';
8
7
  import React, { ReactNode } from 'react';
9
8
  import { PolymorphicProps } from '../../types/common';
10
9
  export declare const TYPES: {
@@ -40,7 +39,7 @@ export interface TagBaseProps {
40
39
  */
41
40
  disabled?: boolean;
42
41
  /**
43
- * @deprecated This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.
42
+ * @deprecated The `filter` prop has been deprecated and will be removed in the next major version. Use DismissibleTag instead.
44
43
  */
45
44
  filter?: boolean;
46
45
  /**
@@ -48,7 +47,7 @@ export interface TagBaseProps {
48
47
  */
49
48
  id?: string;
50
49
  /**
51
- * @deprecated This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.
50
+ * @deprecated The `onClose` prop has been deprecated and will be removed in the next major version. Use DismissibleTag instead.
52
51
  */
53
52
  onClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;
54
53
  /**
@@ -66,7 +65,7 @@ export interface TagBaseProps {
66
65
  */
67
66
  slug?: ReactNode;
68
67
  /**
69
- * @deprecated This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.
68
+ * @deprecated The `title` prop has been deprecated and will be removed in the next major version. Use DismissibleTag instead.
70
69
  */
71
70
  title?: string;
72
71
  /**
@@ -75,61 +74,6 @@ export interface TagBaseProps {
75
74
  type?: keyof typeof TYPES;
76
75
  }
77
76
  export type TagProps<T extends React.ElementType> = PolymorphicProps<T, TagBaseProps>;
78
- declare const Tag: {
79
- <T extends React.ElementType<any>>({ children, className, id, type, filter, renderIcon: CustomIconElement, title, disabled, onClose, size, as: BaseComponent, slug, ...other }: TagProps<T>): import("react/jsx-runtime").JSX.Element;
80
- propTypes: {
81
- /**
82
- * Provide an alternative tag or component to use instead of the default
83
- * wrapping element
84
- */
85
- as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
86
- /**
87
- * Provide content to be rendered inside of a `Tag`
88
- */
89
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
90
- /**
91
- * Provide a custom className that is applied to the containing <span>
92
- */
93
- className: PropTypes.Requireable<string>;
94
- /**
95
- * Specify if the `Tag` is disabled
96
- */
97
- disabled: PropTypes.Requireable<boolean>;
98
- /**
99
- * Determine if `Tag` is a filter/chip
100
- */
101
- filter: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
102
- /**
103
- * Specify the id for the tag.
104
- */
105
- id: PropTypes.Requireable<string>;
106
- /**
107
- * Click handler for filter tag close button.
108
- */
109
- onClose: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
110
- /**
111
- * Optional prop to render a custom icon.
112
- * Can be a React component class
113
- */
114
- renderIcon: PropTypes.Requireable<object>;
115
- /**
116
- * Specify the size of the Tag. Currently supports either `sm`,
117
- * `md` (default) or `lg` sizes.
118
- */
119
- size: PropTypes.Requireable<string>;
120
- /**
121
- * **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
122
- */
123
- slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
124
- /**
125
- * Text to show on clear filters
126
- */
127
- title: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
128
- /**
129
- * Specify the type of the `Tag`
130
- */
131
- type: PropTypes.Requireable<string>;
132
- };
133
- };
77
+ declare const Tag: React.ForwardRefExoticComponent<Omit<TagProps<React.ElementType<any>>, "ref"> & React.RefAttributes<HTMLElement | undefined>>;
134
78
  export declare const types: string[];
135
79
  export default Tag;
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import PropTypes from 'prop-types';
10
- import React__default, { useState, useLayoutEffect } from 'react';
10
+ import React__default, { useRef, useState, useLayoutEffect } from 'react';
11
11
  import cx from 'classnames';
12
12
  import { Close } from '@carbon/icons-react';
13
13
  import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
@@ -16,6 +16,8 @@ import '../Text/index.js';
16
16
  import deprecate from '../../prop-types/deprecate.js';
17
17
  import { DefinitionTooltip } from '../Tooltip/DefinitionTooltip.js';
18
18
  import '../Tooltip/Tooltip.js';
19
+ import { isEllipsisActive } from './isEllipsisActive.js';
20
+ import { useMergeRefs } from '@floating-ui/react';
19
21
  import { Text } from '../Text/Text.js';
20
22
 
21
23
  var _Close;
@@ -39,7 +41,7 @@ const SIZES = {
39
41
  md: 'md',
40
42
  lg: 'lg'
41
43
  };
42
- const Tag = _ref => {
44
+ const Tag = /*#__PURE__*/React__default.forwardRef(function Tag(_ref, forwardRef) {
43
45
  let {
44
46
  children,
45
47
  className,
@@ -59,17 +61,14 @@ const Tag = _ref => {
59
61
  ...other
60
62
  } = _ref;
61
63
  const prefix = usePrefix();
64
+ const tagRef = useRef();
65
+ const ref = useMergeRefs([forwardRef, tagRef]);
62
66
  const tagId = id || `tag-${getInstanceId()}`;
63
67
  const [isEllipsisApplied, setIsEllipsisApplied] = useState(false);
64
- const isEllipsisActive = element => {
65
- setIsEllipsisApplied(element.offsetWidth < element.scrollWidth);
66
- return element.offsetWidth < element.scrollWidth;
67
- };
68
68
  useLayoutEffect(() => {
69
- const elementTagId = document.querySelector(`#${tagId}`);
70
- const newElement = elementTagId?.getElementsByClassName(`${prefix}--tag__label`)[0];
71
- isEllipsisActive(newElement);
72
- }, [prefix, tagId]);
69
+ const newElement = tagRef.current?.getElementsByClassName(`${prefix}--tag__label`)[0];
70
+ setIsEllipsisApplied(isEllipsisActive(newElement));
71
+ }, [prefix, tagRef]);
73
72
  const conditions = [`${prefix}--tag--selectable`, `${prefix}--tag--filter`, `${prefix}--tag--operational`];
74
73
  const isInteractiveTag = conditions.some(el => className?.includes(el));
75
74
  const tagClasses = cx(`${prefix}--tag`, className, {
@@ -122,6 +121,7 @@ const Tag = _ref => {
122
121
  [`${prefix}--tag--${type}`]: type && !isInteractiveTag
123
122
  });
124
123
  return /*#__PURE__*/React__default.createElement(ComponentTag, _extends({
124
+ ref: ref,
125
125
  disabled: disabled,
126
126
  className: tagClasses,
127
127
  id: tagId
@@ -138,7 +138,7 @@ const Tag = _ref => {
138
138
  title: children !== null && children !== undefined ? children : typeText,
139
139
  className: labelClasses
140
140
  }, children !== null && children !== undefined ? children : typeText), normalizedSlug);
141
- };
141
+ });
142
142
  Tag.propTypes = {
143
143
  /**
144
144
  * Provide an alternative tag or component to use instead of the default
@@ -160,7 +160,7 @@ Tag.propTypes = {
160
160
  /**
161
161
  * Determine if `Tag` is a filter/chip
162
162
  */
163
- filter: deprecate(PropTypes.bool, 'This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
163
+ filter: deprecate(PropTypes.bool, 'The `filter` prop has been deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
164
164
  /**
165
165
  * Specify the id for the tag.
166
166
  */
@@ -168,7 +168,7 @@ Tag.propTypes = {
168
168
  /**
169
169
  * Click handler for filter tag close button.
170
170
  */
171
- onClose: deprecate(PropTypes.func, 'This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
171
+ onClose: deprecate(PropTypes.func, 'The `onClose` prop has been deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
172
172
  /**
173
173
  * Optional prop to render a custom icon.
174
174
  * Can be a React component class
@@ -186,7 +186,7 @@ Tag.propTypes = {
186
186
  /**
187
187
  * Text to show on clear filters
188
188
  */
189
- title: deprecate(PropTypes.string, 'This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
189
+ title: deprecate(PropTypes.string, 'The `title` prop has been deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
190
190
  /**
191
191
  * Specify the type of the `Tag`
192
192
  */
@@ -0,0 +1,7 @@
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
+ export declare const isEllipsisActive: (element: any) => boolean;
@@ -0,0 +1,15 @@
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
+ const isEllipsisActive = element => {
9
+ if (element) {
10
+ return element?.offsetWidth < element?.scrollWidth;
11
+ }
12
+ return false;
13
+ };
14
+
15
+ export { isEllipsisActive };
@@ -14,6 +14,7 @@ import { useDelayedState } from '../../internal/useDelayedState.js';
14
14
  import { useId } from '../../internal/useId.js';
15
15
  import { useNoInteractiveChildren } from '../../internal/useNoInteractiveChildren.js';
16
16
  import { usePrefix } from '../../internal/usePrefix.js';
17
+ import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
17
18
  import { match } from '../../internal/keyboard/match.js';
18
19
  import { Escape, Enter, Space } from '../../internal/keyboard/keys.js';
19
20
 
@@ -74,7 +75,7 @@ function Tooltip(_ref) {
74
75
  } else {
75
76
  triggerProps['aria-describedby'] = id;
76
77
  }
77
- function onKeyDown(event) {
78
+ const onKeyDown = useCallback(event => {
78
79
  if (open && match(event, Escape)) {
79
80
  event.stopPropagation();
80
81
  setOpen(false);
@@ -82,10 +83,24 @@ function Tooltip(_ref) {
82
83
  if (open && closeOnActivation && (match(event, Enter) || match(event, Space))) {
83
84
  setOpen(false);
84
85
  }
85
- }
86
+ }, [closeOnActivation, open, setOpen]);
87
+ useIsomorphicEffect(() => {
88
+ if (!open) {
89
+ return undefined;
90
+ }
91
+ function handleKeyDown(event) {
92
+ if (match(event, Escape)) {
93
+ onKeyDown(event);
94
+ }
95
+ }
96
+ document.addEventListener('keydown', handleKeyDown);
97
+ return () => {
98
+ document.removeEventListener('keydown', handleKeyDown);
99
+ };
100
+ }, [open, onKeyDown]);
86
101
  function onMouseEnter() {
87
102
  // Interactive Tags should not support onMouseEnter
88
- if (!rest?.onMouseEnter?.()) {
103
+ if (!rest?.onMouseEnter) {
89
104
  setIsPointerIntersecting(true);
90
105
  setOpen(true, enterDelayMs);
91
106
  }
@@ -133,25 +148,30 @@ function Tooltip(_ref) {
133
148
  });
134
149
  };
135
150
  }, [isDragging, onDragStop]);
136
- return /*#__PURE__*/React__default.createElement(Popover, _extends({}, rest, {
137
- align: align,
138
- className: cx(`${prefix}--tooltip`, customClassName),
139
- dropShadow: false,
140
- highContrast: true,
141
- onKeyDown: onKeyDown,
142
- onMouseLeave: onMouseLeave,
143
- open: open
144
- }), /*#__PURE__*/React__default.createElement("div", {
145
- className: `${prefix}--tooltip-trigger__wrapper`
146
- }, child !== undefined ? /*#__PURE__*/React__default.cloneElement(child, {
147
- ...triggerProps,
148
- ...getChildEventHandlers(child.props)
149
- }) : null), /*#__PURE__*/React__default.createElement(PopoverContent, {
150
- "aria-hidden": open ? 'false' : 'true',
151
- className: `${prefix}--tooltip-content`,
152
- id: id,
153
- role: "tooltip"
154
- }, label || description));
151
+ return (
152
+ /*#__PURE__*/
153
+ // @ts-ignore-error Popover throws a TS error everytime is imported
154
+ React__default.createElement(Popover, _extends({}, rest, {
155
+ align: align,
156
+ className: cx(`${prefix}--tooltip`, customClassName),
157
+ dropShadow: false,
158
+ highContrast: true,
159
+ onKeyDown: onKeyDown,
160
+ onMouseLeave: onMouseLeave,
161
+ open: open
162
+ }), /*#__PURE__*/React__default.createElement("div", {
163
+ className: `${prefix}--tooltip-trigger__wrapper`
164
+ }, child !== undefined ? /*#__PURE__*/React__default.cloneElement(child, {
165
+ ...triggerProps,
166
+ ...getChildEventHandlers(child.props)
167
+ }) : null), /*#__PURE__*/React__default.createElement(PopoverContent, {
168
+ "aria-hidden": open ? 'false' : 'true',
169
+ className: `${prefix}--tooltip-content`,
170
+ id: id,
171
+ onMouseEnter: onMouseEnter,
172
+ role: "tooltip"
173
+ }, label || description))
174
+ );
155
175
  }
156
176
  Tooltip.propTypes = {
157
177
  /**
@@ -29,7 +29,7 @@ declare const Content: {
29
29
  suppressHydrationWarning?: boolean | undefined;
30
30
  accessKey?: string | undefined;
31
31
  autoFocus?: boolean | undefined;
32
- contentEditable?: "inherit" | (boolean | "true" | "false") | undefined;
32
+ contentEditable?: (boolean | "true" | "false") | "inherit" | undefined;
33
33
  contextMenu?: string | undefined;
34
34
  dir?: string | undefined;
35
35
  draggable?: (boolean | "true" | "false") | undefined;
@@ -43,7 +43,7 @@ declare const Content: {
43
43
  style?: React.CSSProperties | undefined;
44
44
  tabIndex?: number | undefined;
45
45
  title?: string | undefined;
46
- translate?: "no" | "yes" | undefined;
46
+ translate?: "yes" | "no" | undefined;
47
47
  radioGroup?: string | undefined;
48
48
  role?: React.AriaRole | undefined;
49
49
  about?: string | undefined;
@@ -93,7 +93,7 @@ declare const Content: {
93
93
  "aria-expanded"?: (boolean | "true" | "false") | undefined;
94
94
  "aria-flowto"?: string | undefined;
95
95
  "aria-grabbed"?: (boolean | "true" | "false") | undefined;
96
- "aria-haspopup"?: boolean | "dialog" | "menu" | "grid" | "listbox" | "tree" | "true" | "false" | undefined;
96
+ "aria-haspopup"?: boolean | "dialog" | "menu" | "true" | "false" | "grid" | "listbox" | "tree" | undefined;
97
97
  "aria-hidden"?: (boolean | "true" | "false") | undefined;
98
98
  "aria-invalid"?: boolean | "true" | "false" | "grammar" | "spelling" | undefined;
99
99
  "aria-keyshortcuts"?: string | undefined;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { HTMLAttributeAnchorTarget } from 'react';
2
2
  interface BaseSwitcherItemProps {
3
3
  /**
4
4
  * Specify the text content for the link
@@ -43,6 +43,10 @@ interface BaseSwitcherItemProps {
43
43
  * Optionally provide an href for the underlying li`
44
44
  */
45
45
  href?: string;
46
+ /**
47
+ * Specify where to open the link.
48
+ */
49
+ target?: HTMLAttributeAnchorTarget;
46
50
  }
47
51
  interface SwitcherItemWithAriaLabel extends BaseSwitcherItemProps {
48
52
  'aria-label': string;
@@ -28,6 +28,7 @@ const SwitcherItem = /*#__PURE__*/forwardRef(function SwitcherItem(props, forwar
28
28
  handleSwitcherItemFocus,
29
29
  onKeyDown = () => {},
30
30
  href,
31
+ target,
31
32
  ...rest
32
33
  } = props;
33
34
  const prefix = usePrefix();
@@ -65,6 +66,7 @@ const SwitcherItem = /*#__PURE__*/forwardRef(function SwitcherItem(props, forwar
65
66
  onKeyDown(evt);
66
67
  },
67
68
  href: href,
69
+ target: target,
68
70
  ref: forwardRef
69
71
  }, rest, {
70
72
  className: linkClassName,
@@ -105,7 +107,11 @@ SwitcherItem.propTypes = {
105
107
  /**
106
108
  * Specify the tab index of the Link
107
109
  */
108
- tabIndex: PropTypes.number
110
+ tabIndex: PropTypes.number,
111
+ /**
112
+ * Specify where to open the link.
113
+ */
114
+ target: PropTypes.string
109
115
  };
110
116
 
111
117
  export { SwitcherItem as default };
@@ -28,8 +28,13 @@ interface AccordionSkeletonProps {
28
28
  * `false` to not display the first item opened.
29
29
  */
30
30
  open?: boolean;
31
+ /**
32
+ * Specify if the Accordion should be an ordered list,
33
+ * default is `false`
34
+ */
35
+ ordered?: boolean;
31
36
  }
32
- declare function AccordionSkeleton({ align, className, count, isFlush, open, ...rest }: AccordionSkeletonProps): import("react/jsx-runtime").JSX.Element;
37
+ declare function AccordionSkeleton({ align, className, count, isFlush, open, ordered, ...rest }: AccordionSkeletonProps): import("react/jsx-runtime").JSX.Element;
33
38
  declare namespace AccordionSkeleton {
34
39
  var propTypes: {
35
40
  /**
@@ -31,6 +31,7 @@ function AccordionSkeleton(_ref) {
31
31
  count = 4,
32
32
  isFlush,
33
33
  open = true,
34
+ ordered = false,
34
35
  ...rest
35
36
  } = _ref;
36
37
  const prefix = usePrefix.usePrefix();
@@ -39,7 +40,8 @@ function AccordionSkeleton(_ref) {
39
40
  [`${prefix}--accordion--flush`]: isFlush && align !== 'start'
40
41
  });
41
42
  const numSkeletonItems = open ? count - 1 : count;
42
- return /*#__PURE__*/React__default["default"].createElement("ul", _rollupPluginBabelHelpers["extends"]({
43
+ const ListTag = ordered ? 'ol' : 'ul';
44
+ return /*#__PURE__*/React__default["default"].createElement(ListTag, _rollupPluginBabelHelpers["extends"]({
43
45
  className: classes
44
46
  }, rest), open && /*#__PURE__*/React__default["default"].createElement("li", {
45
47
  className: `${prefix}--accordion__item ${prefix}--accordion__item--active`
@@ -27,13 +27,18 @@ export interface AccordionProps {
27
27
  * default is `false`, does not work with `align="start"`.
28
28
  */
29
29
  isFlush?: boolean;
30
+ /**
31
+ * Specify if the Accordion should be an ordered list,
32
+ * default is `false`
33
+ */
34
+ ordered?: boolean;
30
35
  /**
31
36
  * Specify the size of the Accordion. Currently
32
37
  * supports the following: `sm`, `md`, `lg`
33
38
  */
34
39
  size?: 'sm' | 'md' | 'lg';
35
40
  }
36
- declare function Accordion({ align, children, className: customClassName, disabled, isFlush, size, ...rest }: PropsWithChildren<AccordionProps>): import("react/jsx-runtime").JSX.Element;
41
+ declare function Accordion({ align, children, className: customClassName, disabled, isFlush, ordered, size, ...rest }: PropsWithChildren<AccordionProps>): import("react/jsx-runtime").JSX.Element;
37
42
  declare namespace Accordion {
38
43
  var propTypes: {
39
44
  /**
@@ -56,6 +61,11 @@ declare namespace Accordion {
56
61
  * Specify whether Accordion text should be flush, default is false, does not work with align="start"
57
62
  */
58
63
  isFlush: PropTypes.Requireable<boolean>;
64
+ /**
65
+ * Specify if the Accordion should be an ordered list,
66
+ * default is `false`
67
+ */
68
+ ordered: PropTypes.Requireable<boolean>;
59
69
  /**
60
70
  * Specify the size of the Accordion. Currently supports the following:
61
71
  */
@@ -29,6 +29,7 @@ function Accordion(_ref) {
29
29
  className: customClassName,
30
30
  disabled = false,
31
31
  isFlush = false,
32
+ ordered = false,
32
33
  size,
33
34
  ...rest
34
35
  } = _ref;
@@ -40,9 +41,10 @@ function Accordion(_ref) {
40
41
  [`${prefix}--layout--size-${size}`]: size,
41
42
  [`${prefix}--accordion--flush`]: isFlush && align !== 'start'
42
43
  });
44
+ const ListTag = ordered ? 'ol' : 'ul';
43
45
  return /*#__PURE__*/React__default["default"].createElement(AccordionProvider.AccordionProvider, {
44
46
  disabled: disabled
45
- }, /*#__PURE__*/React__default["default"].createElement("ul", _rollupPluginBabelHelpers["extends"]({
47
+ }, /*#__PURE__*/React__default["default"].createElement(ListTag, _rollupPluginBabelHelpers["extends"]({
46
48
  className: className
47
49
  }, rest), children));
48
50
  }
@@ -67,6 +69,11 @@ Accordion.propTypes = {
67
69
  * Specify whether Accordion text should be flush, default is false, does not work with align="start"
68
70
  */
69
71
  isFlush: PropTypes__default["default"].bool,
72
+ /**
73
+ * Specify if the Accordion should be an ordered list,
74
+ * default is `false`
75
+ */
76
+ ordered: PropTypes__default["default"].bool,
70
77
  /**
71
78
  * Specify the size of the Accordion. Currently supports the following:
72
79
  */
@@ -37,6 +37,7 @@ function CheckboxGroup(_ref) {
37
37
  warn,
38
38
  warnText,
39
39
  slug,
40
+ orientation = 'vertical',
40
41
  ...rest
41
42
  } = _ref;
42
43
  const prefix = usePrefix.usePrefix();
@@ -49,6 +50,7 @@ function CheckboxGroup(_ref) {
49
50
  className: `${prefix}--form__helper-text`
50
51
  }, helperText) : null;
51
52
  const fieldsetClasses = cx__default["default"](`${prefix}--checkbox-group`, className, {
53
+ [`${prefix}--checkbox-group--${orientation}`]: orientation === 'horizontal',
52
54
  [`${prefix}--checkbox-group--readonly`]: readOnly,
53
55
  [`${prefix}--checkbox-group--invalid`]: !readOnly && invalid,
54
56
  [`${prefix}--checkbox-group--warning`]: showWarning,
@@ -68,6 +70,7 @@ function CheckboxGroup(_ref) {
68
70
  "data-invalid": invalid ? true : undefined,
69
71
  "aria-labelledby": rest['aria-labelledby'] || legendId,
70
72
  "aria-readonly": readOnly,
73
+ orientation: "vertical",
71
74
  "aria-describedby": !invalid && !warn && helper ? helperId : undefined
72
75
  }, rest), /*#__PURE__*/React__default["default"].createElement("legend", {
73
76
  className: `${prefix}--label`,
@@ -114,6 +117,10 @@ CheckboxGroup.propTypes = {
114
117
  * Provide the text to be rendered inside of the fieldset <legend>
115
118
  */
116
119
  legendText: PropTypes__default["default"].node.isRequired,
120
+ /**
121
+ * Provide the orientation for how the checkbox should be displayed
122
+ */
123
+ orientation: PropTypes__default["default"].oneOf(['horizontal', 'vertical']),
117
124
  /**
118
125
  * Whether the CheckboxGroup should be read-only
119
126
  */
@@ -8,6 +8,7 @@ import React from 'react';
8
8
  import { IconButton } from '../IconButton';
9
9
  import Button from '../Button';
10
10
  import { Menu } from '../Menu';
11
+ export type MenuAlignment = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end';
11
12
  interface ComboButtonProps {
12
13
  /**
13
14
  * A collection of `MenuItems` to be rendered as additional actions for this `ComboButton`.
@@ -28,7 +29,7 @@ interface ComboButtonProps {
28
29
  /**
29
30
  * Experimental property. Specify how the menu should align with the button element
30
31
  */
31
- menuAlignment?: React.ComponentProps<typeof Menu>['menuAlignment'];
32
+ menuAlignment?: MenuAlignment;
32
33
  /**
33
34
  * Provide an optional function to be called when the primary action element is clicked.
34
35
  */
@@ -21,8 +21,9 @@ var Menu = require('../Menu/Menu.js');
21
21
  require('../Menu/MenuItem.js');
22
22
  var useAttachedMenu = require('../../internal/useAttachedMenu.js');
23
23
  var useId = require('../../internal/useId.js');
24
- var useMergedRefs = require('../../internal/useMergedRefs.js');
25
24
  var usePrefix = require('../../internal/usePrefix.js');
25
+ var react = require('@floating-ui/react');
26
+ var mergeRefs = require('../../tools/mergeRefs.js');
26
27
 
27
28
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
28
29
 
@@ -31,7 +32,6 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
31
32
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
32
33
 
33
34
  var _ChevronDown;
34
- const spacing = 0; // top and bottom spacing between the button and the menu. in px
35
35
  const defaultTranslations = {
36
36
  'carbon.combo-button.additional-actions': 'Additional actions'
37
37
  };
@@ -54,23 +54,54 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
54
54
  const id = useId.useId('combobutton');
55
55
  const prefix = usePrefix.usePrefix();
56
56
  const containerRef = React.useRef(null);
57
- const menuRef = React.useRef(null);
58
- const ref = useMergedRefs.useMergedRefs([forwardRef, containerRef]);
59
- const [width, setWidth] = React.useState(0);
57
+ const middlewares = [react.flip({
58
+ crossAxis: false
59
+ })];
60
+ if (menuAlignment === 'bottom' || menuAlignment === 'top') {
61
+ middlewares.push(react.size({
62
+ apply(_ref2) {
63
+ let {
64
+ rects,
65
+ elements
66
+ } = _ref2;
67
+ Object.assign(elements.floating.style, {
68
+ width: `${rects.reference.width}px`
69
+ });
70
+ }
71
+ }));
72
+ }
73
+ const {
74
+ refs,
75
+ floatingStyles,
76
+ placement,
77
+ middlewareData
78
+ } = react.useFloating({
79
+ placement: menuAlignment,
80
+ // The floating element is positioned relative to its nearest
81
+ // containing block (usually the viewport). It will in many cases also
82
+ // “break” the floating element out of a clipping ancestor.
83
+ // https://floating-ui.com/docs/misc#clipping
84
+ strategy: 'fixed',
85
+ // Middleware order matters, arrow should be last
86
+ middleware: middlewares,
87
+ whileElementsMounted: react.autoUpdate
88
+ });
89
+ const ref = mergeRefs["default"](forwardRef, containerRef, refs.setReference);
60
90
  const {
61
91
  open,
62
- x,
63
- y,
64
92
  handleClick: hookOnClick,
65
93
  handleMousedown: handleTriggerMousedown,
66
94
  handleClose
67
95
  } = useAttachedMenu.useAttachedMenu(containerRef);
96
+ React.useLayoutEffect(() => {
97
+ Object.keys(floatingStyles).forEach(style => {
98
+ if (refs.floating.current) {
99
+ refs.floating.current.style[style] = floatingStyles[style];
100
+ }
101
+ });
102
+ }, [floatingStyles, refs.floating, middlewareData, placement, open]);
68
103
  function handleTriggerClick() {
69
104
  if (containerRef.current) {
70
- const {
71
- width: w
72
- } = containerRef.current.getBoundingClientRect();
73
- setWidth(w);
74
105
  hookOnClick();
75
106
  }
76
107
  }
@@ -79,15 +110,6 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
79
110
  onClick(e);
80
111
  }
81
112
  }
82
- function handleOpen() {
83
- if (menuRef.current) {
84
- menuRef.current.style.inlineSize = `${width}px`;
85
- menuRef.current.style.minInlineSize = `${width}px`;
86
- if (menuAlignment !== 'bottom' && menuAlignment !== 'top') {
87
- menuRef.current.style.inlineSize = `fit-content`;
88
- }
89
- }
90
- }
91
113
  const containerClasses = cx__default["default"](`${prefix}--combo-button__container`, `${prefix}--combo-button__container--${size}`, {
92
114
  [`${prefix}--combo-button__container--open`]: open
93
115
  }, className);
@@ -106,6 +128,7 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
106
128
  disabled: disabled,
107
129
  onClick: handlePrimaryActionClick
108
130
  }, label)), /*#__PURE__*/React__default["default"].createElement(index.IconButton, {
131
+ ref: refs.setReference,
109
132
  className: triggerClasses,
110
133
  label: t('carbon.combo-button.additional-actions'),
111
134
  size: size,
@@ -120,16 +143,13 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
120
143
  containerRef: containerRef,
121
144
  menuAlignment: menuAlignment,
122
145
  className: menuClasses,
123
- ref: menuRef,
146
+ ref: refs.setFloating,
124
147
  id: id,
125
148
  label: t('carbon.combo-button.additional-actions'),
126
149
  mode: "basic",
127
150
  size: size,
128
151
  open: open,
129
- onClose: handleClose,
130
- onOpen: handleOpen,
131
- x: x,
132
- y: [y[0] - spacing, y[1] + spacing]
152
+ onClose: handleClose
133
153
  }, children));
134
154
  });
135
155
  ComboButton.propTypes = {