@carbon/react 1.60.3 → 1.61.0-rc.1

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 (34) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +980 -1062
  2. package/es/components/ComposedModal/ComposedModal.js +4 -2
  3. package/es/components/DatePicker/DatePicker.js +6 -1
  4. package/es/components/Dropdown/Dropdown.d.ts +4 -0
  5. package/es/components/Dropdown/Dropdown.js +53 -8
  6. package/es/components/Modal/Modal.js +4 -2
  7. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +20 -14
  8. package/es/components/MultiSelect/FilterableMultiSelect.js +54 -5
  9. package/es/components/MultiSelect/MultiSelect.d.ts +7 -38
  10. package/es/components/MultiSelect/MultiSelect.js +52 -5
  11. package/es/components/MultiSelect/MultiSelectPropTypes.d.ts +19 -16
  12. package/es/components/OverflowMenu/OverflowMenu.js +0 -1
  13. package/es/components/OverflowMenu/next/index.d.ts +4 -0
  14. package/es/components/OverflowMenu/next/index.js +41 -2
  15. package/es/components/Pagination/Pagination.js +2 -2
  16. package/es/components/UIShell/HeaderContainer.d.ts +11 -9
  17. package/es/components/UIShell/HeaderContainer.js +9 -7
  18. package/lib/components/ComposedModal/ComposedModal.js +6 -4
  19. package/lib/components/DatePicker/DatePicker.js +6 -1
  20. package/lib/components/Dropdown/Dropdown.d.ts +4 -0
  21. package/lib/components/Dropdown/Dropdown.js +49 -4
  22. package/lib/components/Modal/Modal.js +6 -4
  23. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +20 -14
  24. package/lib/components/MultiSelect/FilterableMultiSelect.js +51 -2
  25. package/lib/components/MultiSelect/MultiSelect.d.ts +7 -38
  26. package/lib/components/MultiSelect/MultiSelect.js +49 -2
  27. package/lib/components/MultiSelect/MultiSelectPropTypes.d.ts +19 -16
  28. package/lib/components/OverflowMenu/OverflowMenu.js +0 -1
  29. package/lib/components/OverflowMenu/next/index.d.ts +4 -0
  30. package/lib/components/OverflowMenu/next/index.js +40 -1
  31. package/lib/components/Pagination/Pagination.js +2 -2
  32. package/lib/components/UIShell/HeaderContainer.d.ts +11 -9
  33. package/lib/components/UIShell/HeaderContainer.js +9 -7
  34. package/package.json +7 -7
@@ -34,29 +34,32 @@ export declare const sortingPropTypes: {
34
34
  */
35
35
  sortItems: PropTypes.Requireable<(...args: any[]) => any>;
36
36
  };
37
- export interface ItemBase {
38
- disabled?: boolean;
37
+ interface DownshiftTypedProps<ItemType> {
38
+ itemToString?(item: ItemType): string;
39
39
  }
40
- export interface SortingPropTypes<Item extends ItemBase> {
40
+ interface SharedOptions {
41
+ locale: string;
42
+ }
43
+ export interface SortItemsOptions<ItemType> extends SharedOptions, DownshiftTypedProps<ItemType> {
44
+ compareItems(item1: ItemType, item2: ItemType, options: SharedOptions): number;
45
+ selectedItems: ItemType[];
46
+ }
47
+ export interface MultiSelectSortingProps<ItemType> {
41
48
  /**
42
- * Provide a compare function that is used
43
- * to determine the ordering of options.
49
+ * Provide a compare function that is used to determine the ordering of
50
+ * options. See 'sortItems' for more control.
44
51
  */
45
- compareItems(itemA: string, itemB: string, ctx: {
46
- locale: string;
47
- }): number;
52
+ compareItems?(item1: ItemType, item2: ItemType, options: SharedOptions): number;
48
53
  /**
49
54
  * Provide a method that sorts all options in the control. Overriding this
50
55
  * prop means that you also have to handle the sort logic for selected versus
51
56
  * un-selected items. If you just want to control ordering, consider the
52
57
  * `compareItems` prop instead.
58
+ *
59
+ * The return value should be a number whose sign indicates the relative order
60
+ * of the two elements: negative if a is less than b, positive if a is greater
61
+ * than b, and zero if they are equal.
53
62
  */
54
- sortItems(items: Item[], state: {
55
- selectedItems: Item[];
56
- itemToString(item: Item): string;
57
- compareItems(itemA: string, itemB: string, ctx: {
58
- locale: string;
59
- }): number;
60
- locale: string;
61
- }): Item[];
63
+ sortItems?(items: ReadonlyArray<ItemType>, options: SortItemsOptions<ItemType>): ItemType[];
62
64
  }
65
+ export {};
@@ -127,7 +127,6 @@ class OverflowMenu extends React__default.Component {
127
127
  this.setState({
128
128
  click: true
129
129
  });
130
- evt.stopPropagation();
131
130
  if (!this._menuBody || !this._menuBody.contains(evt.target)) {
132
131
  this.setState({
133
132
  open: !this.state.open
@@ -6,6 +6,10 @@
6
6
  */
7
7
  import React, { type ComponentType, type FunctionComponent } from 'react';
8
8
  interface OverflowMenuProps {
9
+ /**
10
+ * **Experimental**: Will attempt to automatically align the floating element to avoid collisions with the viewport and being clipped by ancestor elements.
11
+ */
12
+ autoAlign?: boolean;
9
13
  /**
10
14
  * A collection of MenuItems to be rendered within this OverflowMenu.
11
15
  */
@@ -6,13 +6,15 @@
6
6
  */
7
7
 
8
8
  import { extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { useRef } from 'react';
9
+ import React__default, { useRef, useEffect } from 'react';
10
10
  import PropTypes from 'prop-types';
11
11
  import cx from 'classnames';
12
12
  import { OverflowMenuVertical } from '@carbon/icons-react';
13
+ import { useFloating, flip, autoUpdate } from '@floating-ui/react';
13
14
  import { IconButton } from '../../IconButton/index.js';
14
15
  import { Menu } from '../../Menu/Menu.js';
15
16
  import '../../Menu/MenuItem.js';
17
+ import mergeRefs from '../../../tools/mergeRefs.js';
16
18
  import { useId } from '../../../internal/useId.js';
17
19
  import { usePrefix } from '../../../internal/usePrefix.js';
18
20
  import { useAttachedMenu } from '../../../internal/useAttachedMenu.js';
@@ -20,6 +22,7 @@ import { useAttachedMenu } from '../../../internal/useAttachedMenu.js';
20
22
  const defaultSize = 'md';
21
23
  const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMenu(_ref, forwardRef) {
22
24
  let {
25
+ autoAlign = false,
23
26
  children,
24
27
  className,
25
28
  label = 'Options',
@@ -29,6 +32,26 @@ const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMen
29
32
  tooltipAlignment,
30
33
  ...rest
31
34
  } = _ref;
35
+ const {
36
+ refs,
37
+ floatingStyles,
38
+ placement,
39
+ middlewareData
40
+ } = useFloating(autoAlign ? {
41
+ placement: menuAlignment,
42
+ // The floating element is positioned relative to its nearest
43
+ // containing block (usually the viewport). It will in many cases also
44
+ // “break” the floating element out of a clipping ancestor.
45
+ // https://floating-ui.com/docs/misc#clipping
46
+ strategy: 'fixed',
47
+ // Middleware order matters, arrow should be last
48
+ middleware: [flip({
49
+ fallbackAxisSideDirection: 'start',
50
+ fallbackPlacements: ['top-start', 'top-end', 'bottom-start', 'bottom-end']
51
+ })],
52
+ whileElementsMounted: autoUpdate
53
+ } : {} // When autoAlign is turned off, floating-ui will not be used
54
+ );
32
55
  const id = useId('overflowmenu');
33
56
  const prefix = usePrefix();
34
57
  const triggerRef = useRef(null);
@@ -40,6 +63,15 @@ const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMen
40
63
  handleMousedown,
41
64
  handleClose
42
65
  } = useAttachedMenu(triggerRef);
66
+ useEffect(() => {
67
+ if (autoAlign) {
68
+ Object.keys(floatingStyles).forEach(style => {
69
+ if (refs.floating.current) {
70
+ refs.floating.current.style[style] = floatingStyles[style];
71
+ }
72
+ });
73
+ }
74
+ }, [floatingStyles, autoAlign, refs.floating, open, placement, middlewareData]);
43
75
  function handleTriggerClick() {
44
76
  if (triggerRef.current) {
45
77
  hookOnClick();
@@ -50,6 +82,7 @@ const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMen
50
82
  const triggerClasses = cx(`${prefix}--overflow-menu`, {
51
83
  [`${prefix}--overflow-menu--open`]: open
52
84
  }, size !== defaultSize && `${prefix}--overflow-menu--${size}`);
85
+ const floatingRef = mergeRefs(triggerRef, refs.setReference);
53
86
  return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
54
87
  className: containerClasses,
55
88
  "aria-owns": open ? id : undefined,
@@ -61,17 +94,19 @@ const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMen
61
94
  className: triggerClasses,
62
95
  onClick: handleTriggerClick,
63
96
  onMouseDown: handleMousedown,
64
- ref: triggerRef,
97
+ ref: floatingRef,
65
98
  label: label,
66
99
  align: tooltipAlignment
67
100
  }, /*#__PURE__*/React__default.createElement(IconElement, {
68
101
  className: `${prefix}--overflow-menu__icon`
69
102
  })), /*#__PURE__*/React__default.createElement(Menu, {
70
103
  containerRef: triggerRef,
104
+ ref: refs.setFloating,
71
105
  menuAlignment: menuAlignment,
72
106
  className: menuClasses,
73
107
  id: id,
74
108
  size: size,
109
+ legacyAutoalign: !autoAlign,
75
110
  open: open,
76
111
  onClose: handleClose,
77
112
  x: x,
@@ -80,6 +115,10 @@ const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMen
80
115
  }, children));
81
116
  });
82
117
  OverflowMenu.propTypes = {
118
+ /**
119
+ * **Experimental**: Will attempt to automatically align the floating element to avoid collisions with the viewport and being clipped by ancestor elements.
120
+ */
121
+ autoAlign: PropTypes.bool,
83
122
  /**
84
123
  * A collection of MenuItems to be rendered within this OverflowMenu.
85
124
  */
@@ -93,7 +93,7 @@ const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_r
93
93
  [`${prefix}--pagination--${size}`]: size,
94
94
  [customClassName]: !!customClassName
95
95
  });
96
- const totalPages = totalItems ? Math.max(Math.ceil(totalItems / pageSize), 1) : NaN;
96
+ const totalPages = totalItems ? Math.max(Math.ceil(totalItems / pageSize), 1) : 1;
97
97
  const backButtonDisabled = disabled || page === 1;
98
98
  const backButtonClasses = cx({
99
99
  [`${prefix}--pagination__button`]: true,
@@ -218,7 +218,7 @@ const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_r
218
218
  text: String(sizeObj.text)
219
219
  }))), /*#__PURE__*/React__default.createElement("span", {
220
220
  className: `${prefix}--pagination__text ${prefix}--pagination__items-count`
221
- }, pagesUnknown || !totalItems ? itemText(pageSize * (page - 1) + 1, page * pageSize) : itemRangeText(Math.min(pageSize * (page - 1) + 1, totalItems), Math.min(page * pageSize, totalItems), totalItems))), /*#__PURE__*/React__default.createElement("div", {
221
+ }, pagesUnknown || !totalItems ? totalItems === 0 ? itemRangeText(0, 0, 0) : itemText(pageSize * (page - 1) + 1, page * pageSize) : itemRangeText(Math.min(pageSize * (page - 1) + 1, totalItems), Math.min(page * pageSize, totalItems), totalItems))), /*#__PURE__*/React__default.createElement("div", {
222
222
  className: `${prefix}--pagination__right`
223
223
  }, pagesUnknown ? /*#__PURE__*/React__default.createElement("span", {
224
224
  className: `${prefix}--pagination__text ${prefix}--pagination__page-text ${prefix}--pagination__unknown-pages-text`
@@ -6,15 +6,17 @@
6
6
  */
7
7
  import PropTypes from 'prop-types';
8
8
  import React from 'react';
9
- interface HeaderContainerRenderProps {
9
+ export interface HeaderContainerRenderProps {
10
10
  isSideNavExpanded: boolean;
11
11
  onClickSideNavExpand: () => void;
12
12
  }
13
- export interface HeaderContainerProps {
13
+ export type HeaderContainerProps<P extends HeaderContainerRenderProps> = {
14
14
  isSideNavExpanded?: boolean;
15
- render: React.ComponentType<HeaderContainerRenderProps>;
16
- }
17
- declare function HeaderContainer({ render: Children, isSideNavExpanded, }: HeaderContainerProps): import("react/jsx-runtime").JSX.Element;
15
+ render: React.ComponentType<P>;
16
+ } & {
17
+ [K in keyof Omit<P, keyof HeaderContainerRenderProps>]: P[K];
18
+ };
19
+ declare function HeaderContainer<P extends HeaderContainerRenderProps>({ render: Children, isSideNavExpanded, ...rest }: HeaderContainerProps<P>): import("react/jsx-runtime").JSX.Element;
18
20
  declare namespace HeaderContainer {
19
21
  var propTypes: {
20
22
  /**
@@ -22,10 +24,10 @@ declare namespace HeaderContainer {
22
24
  */
23
25
  isSideNavExpanded: PropTypes.Requireable<boolean>;
24
26
  /**
25
- * A function or component that is passed an object parameter with two
26
- * properties: `isSideNavExpanded` and `onClickSideNavExpand`. The function or
27
- * component can then use those properties to within the components it
28
- * returns, such as with the HeaderMenuButton and SideNav components.
27
+ * A function or a component that is invoked with `isSideNavExpanded` and `onClickSideNavExpand`.
28
+ * The function or component can then use those properties to within the components it
29
+ * returns, such as with the HeaderMenuButton and SideNav components. Additional props will also be passed
30
+ * into this component for convenience.
29
31
  */
30
32
  render: PropTypes.Validator<NonNullable<PropTypes.ReactComponentLike>>;
31
33
  };
@@ -5,6 +5,7 @@
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';
8
9
  import PropTypes from 'prop-types';
9
10
  import React__default, { useState, useCallback } from 'react';
10
11
  import { useWindowEvent } from '../../internal/useEvent.js';
@@ -14,7 +15,8 @@ import { Escape } from '../../internal/keyboard/keys.js';
14
15
  function HeaderContainer(_ref) {
15
16
  let {
16
17
  render: Children,
17
- isSideNavExpanded = false
18
+ isSideNavExpanded = false,
19
+ ...rest
18
20
  } = _ref;
19
21
  //state for expandable sidenav
20
22
  const [isSideNavExpandedState, setIsSideNavExpandedState] = useState(isSideNavExpanded);
@@ -26,10 +28,10 @@ function HeaderContainer(_ref) {
26
28
  const handleHeaderMenuButtonClick = useCallback(() => {
27
29
  setIsSideNavExpandedState(prevIsSideNavExpanded => !prevIsSideNavExpanded);
28
30
  }, [setIsSideNavExpandedState]);
29
- return /*#__PURE__*/React__default.createElement(Children, {
31
+ return /*#__PURE__*/React__default.createElement(Children, _extends({}, rest, {
30
32
  isSideNavExpanded: isSideNavExpandedState,
31
33
  onClickSideNavExpand: handleHeaderMenuButtonClick
32
- });
34
+ }));
33
35
  }
34
36
  HeaderContainer.propTypes = {
35
37
  /**
@@ -37,10 +39,10 @@ HeaderContainer.propTypes = {
37
39
  */
38
40
  isSideNavExpanded: PropTypes.bool,
39
41
  /**
40
- * A function or component that is passed an object parameter with two
41
- * properties: `isSideNavExpanded` and `onClickSideNavExpand`. The function or
42
- * component can then use those properties to within the components it
43
- * returns, such as with the HeaderMenuButton and SideNav components.
42
+ * A function or a component that is invoked with `isSideNavExpanded` and `onClickSideNavExpand`.
43
+ * The function or component can then use those properties to within the components it
44
+ * returns, such as with the HeaderMenuButton and SideNav components. Additional props will also be passed
45
+ * into this component for convenience.
44
46
  */
45
47
  render: PropTypes.elementType.isRequired
46
48
  };
@@ -13,6 +13,7 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
13
13
  var React = require('react');
14
14
  var reactIs = require('react-is');
15
15
  var PropTypes = require('prop-types');
16
+ var index = require('../Layer/index.js');
16
17
  var ModalHeader = require('./ModalHeader.js');
17
18
  var ModalFooter = require('./ModalFooter.js');
18
19
  var debounce = require('lodash.debounce');
@@ -23,7 +24,7 @@ var toggleClass = require('../../tools/toggleClass.js');
23
24
  var requiredIfGivenPropIsTruthy = require('../../prop-types/requiredIfGivenPropIsTruthy.js');
24
25
  var wrapFocus = require('../../internal/wrapFocus.js');
25
26
  var usePrefix = require('../../internal/usePrefix.js');
26
- var index = require('../FeatureFlags/index.js');
27
+ var index$1 = require('../FeatureFlags/index.js');
27
28
  var match = require('../../internal/keyboard/match.js');
28
29
  var keys = require('../../internal/keyboard/keys.js');
29
30
 
@@ -70,7 +71,7 @@ const ModalBody = /*#__PURE__*/React__default["default"].forwardRef(function Mod
70
71
  tabIndex: 0,
71
72
  role: 'region'
72
73
  } : {};
73
- return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
74
+ return /*#__PURE__*/React__default["default"].createElement(index.Layer, _rollupPluginBabelHelpers["extends"]({
74
75
  className: contentClass
75
76
  }, hasScrollingContentProps, rest, {
76
77
  ref: mergeRefs["default"](contentRef, ref)
@@ -126,7 +127,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
126
127
  const button = React.useRef(null);
127
128
  const startSentinel = React.useRef(null);
128
129
  const endSentinel = React.useRef(null);
129
- const focusTrapWithoutSentinels = index.useFeatureFlag('enable-experimental-focus-wrap-without-sentinels');
130
+ const focusTrapWithoutSentinels = index$1.useFeatureFlag('enable-experimental-focus-wrap-without-sentinels');
130
131
 
131
132
  // Keep track of modal open/close state
132
133
  // and propagate it to the document.body
@@ -260,7 +261,8 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
260
261
  size: 'sm'
261
262
  });
262
263
  }
263
- return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
264
+ return /*#__PURE__*/React__default["default"].createElement(index.Layer, _rollupPluginBabelHelpers["extends"]({}, rest, {
265
+ level: 0,
264
266
  role: "presentation",
265
267
  ref: ref,
266
268
  "aria-hidden": !open,
@@ -188,6 +188,8 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
188
188
 
189
189
  // fix datepicker deleting the selectedDate when the calendar closes
190
190
  const onCalendarClose = (selectedDates, dateStr) => {
191
+ endInputField?.current?.focus();
192
+ calendarRef?.current?.calendarContainer?.classList.remove('open');
191
193
  setTimeout(() => {
192
194
  if (lastStartValue.current && selectedDates[0] && !startInputField.current.value) {
193
195
  startInputField.current.value = lastStartValue.current;
@@ -367,9 +369,12 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
367
369
  calendarRef.current = calendar;
368
370
  function handleArrowDown(event) {
369
371
  if (match.match(event, keys.Escape)) {
370
- calendar.calendarContainer.classList.remove('open');
372
+ calendar?.calendarContainer?.classList.remove('open');
371
373
  }
372
374
  if (match.match(event, keys.ArrowDown)) {
375
+ if (event.target == endInputField.current) {
376
+ calendar?.calendarContainer?.classList.add('open');
377
+ }
373
378
  const {
374
379
  calendarContainer,
375
380
  selectedDateElem: fpSelectedDateElem,
@@ -23,6 +23,10 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
23
23
  * Specify a label to be read by screen readers on the container note.
24
24
  */
25
25
  ariaLabel?: string;
26
+ /**
27
+ * **Experimental**: Will attempt to automatically align the floating element to avoid collisions with the viewport and being clipped by ancestor elements.
28
+ */
29
+ autoAlign?: boolean;
26
30
  /**
27
31
  * Specify the direction of the dropdown. Can be either top or bottom.
28
32
  */
@@ -22,6 +22,7 @@ var usePrefix = require('../../internal/usePrefix.js');
22
22
  require('../FluidForm/FluidForm.js');
23
23
  var FormContext = require('../FluidForm/FormContext.js');
24
24
  var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
25
+ var react = require('@floating-ui/react');
25
26
  var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
26
27
 
27
28
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -53,6 +54,7 @@ const defaultItemToString = item => {
53
54
  };
54
55
  const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
55
56
  let {
57
+ autoAlign = false,
56
58
  className: containerClassName,
57
59
  disabled = false,
58
60
  direction = 'bottom',
@@ -83,6 +85,40 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
83
85
  slug,
84
86
  ...other
85
87
  } = _ref;
88
+ const {
89
+ refs,
90
+ floatingStyles
91
+ } = react.useFloating(autoAlign ? {
92
+ placement: direction,
93
+ // The floating element is positioned relative to its nearest
94
+ // containing block (usually the viewport). It will in many cases also
95
+ // “break” the floating element out of a clipping ancestor.
96
+ // https://floating-ui.com/docs/misc#clipping
97
+ strategy: 'fixed',
98
+ // Middleware order matters, arrow should be last
99
+ middleware: [react.size({
100
+ apply(_ref2) {
101
+ let {
102
+ rects,
103
+ elements
104
+ } = _ref2;
105
+ Object.assign(elements.floating.style, {
106
+ width: `${rects.reference.width}px`
107
+ });
108
+ }
109
+ }), react.flip()],
110
+ whileElementsMounted: react.autoUpdate
111
+ } : {} // When autoAlign is turned off, floating-ui will not be used
112
+ );
113
+ React.useEffect(() => {
114
+ if (autoAlign) {
115
+ Object.keys(floatingStyles).forEach(style => {
116
+ if (refs.floating.current) {
117
+ refs.floating.current.style[style] = floatingStyles[style];
118
+ }
119
+ });
120
+ }
121
+ }, [floatingStyles, autoAlign, refs.floating]);
86
122
  const prefix = usePrefix.usePrefix();
87
123
  const {
88
124
  isFluid
@@ -157,7 +193,8 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
157
193
  [`${prefix}--dropdown--light`]: light,
158
194
  [`${prefix}--dropdown--readonly`]: readOnly,
159
195
  [`${prefix}--dropdown--${size}`]: size,
160
- [`${prefix}--list-box--up`]: direction === 'top'
196
+ [`${prefix}--list-box--up`]: direction === 'top',
197
+ [`${prefix}--dropdown--autoalign`]: autoAlign
161
198
  });
162
199
  const titleClasses = cx__default["default"](`${prefix}--label`, {
163
200
  [`${prefix}--label--disabled`]: disabled,
@@ -184,10 +221,10 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
184
221
  id: helperId,
185
222
  className: helperClasses
186
223
  }, helperText) : null;
187
- function onSelectedItemChange(_ref2) {
224
+ function onSelectedItemChange(_ref3) {
188
225
  let {
189
226
  selectedItem
190
- } = _ref2;
227
+ } = _ref3;
191
228
  if (onChange) {
192
229
  onChange({
193
230
  selectedItem: selectedItem ?? null
@@ -237,6 +274,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
237
274
  }
238
275
  };
239
276
  const menuProps = getMenuProps();
277
+ const menuRef = mergeRefs["default"](menuProps.ref, refs.setFloating);
240
278
 
241
279
  // Slug is always size `mini`
242
280
  let normalizedSlug;
@@ -261,6 +299,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
261
299
  warnText: warnText,
262
300
  light: light,
263
301
  isOpen: isOpen,
302
+ ref: refs.setReference,
264
303
  id: id
265
304
  }, invalid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
266
305
  className: `${prefix}--list-box__invalid-icon`
@@ -283,7 +322,9 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
283
322
  }, selectedItem ? renderSelectedItem ? renderSelectedItem(selectedItem) : itemToString(selectedItem) : label), /*#__PURE__*/React__default["default"].createElement(index["default"].MenuIcon, {
284
323
  isOpen: isOpen,
285
324
  translateWithId: translateWithId
286
- })), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen && items.map((item, index$1) => {
325
+ })), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, _rollupPluginBabelHelpers["extends"]({}, menuProps, {
326
+ ref: menuRef
327
+ }), isOpen && items.map((item, index$1) => {
287
328
  const isObject = item !== null && typeof item === 'object';
288
329
  const itemProps = getItemProps({
289
330
  item,
@@ -318,6 +359,10 @@ Dropdown.propTypes = {
318
359
  * Specify a label to be read by screen readers on the container note.
319
360
  */
320
361
  ariaLabel: deprecate["default"](PropTypes__default["default"].string, 'This prop syntax has been deprecated. Please use the new `aria-label`.'),
362
+ /**
363
+ * **Experimental**: Will attempt to automatically align the floating element to avoid collisions with the viewport and being clipped by ancestor elements.
364
+ */
365
+ autoAlign: PropTypes__default["default"].bool,
321
366
  /**
322
367
  * Provide a custom className to be applied on the cds--dropdown node
323
368
  */
@@ -19,13 +19,14 @@ var Button = require('../Button/Button.js');
19
19
  require('../Button/Button.Skeleton.js');
20
20
  var ButtonSet = require('../ButtonSet/ButtonSet.js');
21
21
  var InlineLoading = require('../InlineLoading/InlineLoading.js');
22
+ var index$1 = require('../Layer/index.js');
22
23
  var requiredIfGivenPropIsTruthy = require('../../prop-types/requiredIfGivenPropIsTruthy.js');
23
24
  var wrapFocus = require('../../internal/wrapFocus.js');
24
25
  var debounce = require('lodash.debounce');
25
26
  var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
26
27
  var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
27
28
  var usePrefix = require('../../internal/usePrefix.js');
28
- var index$1 = require('../IconButton/index.js');
29
+ var index$2 = require('../IconButton/index.js');
29
30
  var noopFn = require('../../internal/noopFn.js');
30
31
  require('../Text/index.js');
31
32
  var index = require('../FeatureFlags/index.js');
@@ -246,7 +247,7 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
246
247
  }
247
248
  const modalButton = /*#__PURE__*/React__default["default"].createElement("div", {
248
249
  className: `${prefix}--modal-close-button`
249
- }, /*#__PURE__*/React__default["default"].createElement(index$1.IconButton, {
250
+ }, /*#__PURE__*/React__default["default"].createElement(index$2.IconButton, {
250
251
  className: modalCloseButtonClass,
251
252
  label: closeButtonLabel,
252
253
  onClick: onRequestClose,
@@ -277,7 +278,7 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
277
278
  as: "h3",
278
279
  id: modalHeadingId,
279
280
  className: `${prefix}--modal-header__heading`
280
- }, modalHeading), normalizedSlug, !passiveModal && modalButton), /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
281
+ }, modalHeading), normalizedSlug, !passiveModal && modalButton), /*#__PURE__*/React__default["default"].createElement(index$1.Layer, _rollupPluginBabelHelpers["extends"]({
281
282
  ref: contentRef,
282
283
  id: modalBodyId,
283
284
  className: contentClasses
@@ -312,7 +313,8 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
312
313
  className: `${prefix}--inline-loading--btn`,
313
314
  onSuccess: onLoadingSuccess
314
315
  }))));
315
- return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
316
+ return /*#__PURE__*/React__default["default"].createElement(index$1.Layer, _rollupPluginBabelHelpers["extends"]({}, rest, {
317
+ level: 0,
316
318
  onKeyDown: handleKeyDown,
317
319
  onMouseDown: handleMousedown,
318
320
  onBlur: !focusTrapWithoutSentinels ? handleBlur : () => {},
@@ -6,8 +6,8 @@
6
6
  */
7
7
  import { type UseComboboxProps, type UseMultipleSelectionProps } from 'downshift';
8
8
  import { ReactNode, FunctionComponent, ReactElement } from 'react';
9
- import { type ItemBase, type SortingPropTypes } from './MultiSelectPropTypes';
10
- export interface FilterableMultiSelectProps<Item extends ItemBase> extends SortingPropTypes<Item> {
9
+ import { type MultiSelectSortingProps } from './MultiSelectPropTypes';
10
+ export interface FilterableMultiSelectProps<ItemType> extends MultiSelectSortingProps<ItemType> {
11
11
  /**
12
12
  * Specify a label to be read by screen readers on the container node
13
13
  * @deprecated
@@ -15,6 +15,12 @@ export interface FilterableMultiSelectProps<Item extends ItemBase> extends Sorti
15
15
  'aria-label'?: string;
16
16
  /** @deprecated */
17
17
  ariaLabel?: string;
18
+ /**
19
+ * **Experimental**: Will attempt to automatically align the floating
20
+ * element to avoid collisions with the viewport and being clipped by
21
+ * ancestor elements.
22
+ */
23
+ autoAlign?: boolean;
18
24
  className?: string;
19
25
  /**
20
26
  * Specify the text that should be read for screen readers that describes total items selected
@@ -35,14 +41,14 @@ export interface FilterableMultiSelectProps<Item extends ItemBase> extends Sorti
35
41
  /**
36
42
  * Additional props passed to Downshift
37
43
  */
38
- downshiftProps?: UseMultipleSelectionProps<Item>;
44
+ downshiftProps?: UseMultipleSelectionProps<ItemType>;
39
45
  /**
40
46
  * Default sorter is assigned if not provided.
41
47
  */
42
- filterItems(items: readonly Item[], extra: {
48
+ filterItems(items: readonly ItemType[], extra: {
43
49
  inputValue: string | null;
44
- itemToString: NonNullable<UseMultipleSelectionProps<Item>['itemToString']>;
45
- }): Item[];
50
+ itemToString: NonNullable<UseMultipleSelectionProps<ItemType>['itemToString']>;
51
+ }): ItemType[];
46
52
  /**
47
53
  * Specify whether the title text should be hidden or not
48
54
  */
@@ -60,7 +66,7 @@ export interface FilterableMultiSelectProps<Item extends ItemBase> extends Sorti
60
66
  * Allow users to pass in arbitrary items from their collection that are
61
67
  * pre-selected
62
68
  */
63
- initialSelectedItems?: Item[];
69
+ initialSelectedItems?: ItemType[];
64
70
  /**
65
71
  * Is the current selection invalid?
66
72
  */
@@ -73,7 +79,7 @@ export interface FilterableMultiSelectProps<Item extends ItemBase> extends Sorti
73
79
  * Function to render items as custom components instead of strings.
74
80
  * Defaults to null and is overridden by a getter
75
81
  */
76
- itemToElement?: FunctionComponent<Item>;
82
+ itemToElement?: FunctionComponent<ItemType>;
77
83
  /**
78
84
  * Helper function passed to downshift that allows the library to render
79
85
  * a given item to a string label.
@@ -81,12 +87,12 @@ export interface FilterableMultiSelectProps<Item extends ItemBase> extends Sorti
81
87
  * By default, it extracts the `label` field from a given item
82
88
  * to serve as the item label in the list.
83
89
  */
84
- itemToString?(item: Item | null): string;
90
+ itemToString?(item: ItemType | null): string;
85
91
  /**
86
92
  * We try to stay as generic as possible here to allow individuals to pass
87
93
  * in a collection of whatever kind of data structure they prefer
88
94
  */
89
- items: Item[];
95
+ items: ItemType[];
90
96
  /**
91
97
  * @deprecated `true` to use the light version.
92
98
  */
@@ -102,13 +108,13 @@ export interface FilterableMultiSelectProps<Item extends ItemBase> extends Sorti
102
108
  * consuming component what kind of internal state changes are occurring.
103
109
  */
104
110
  onChange?(changes: {
105
- selectedItems: Item[];
111
+ selectedItems: ItemType[];
106
112
  }): void;
107
113
  /**
108
114
  * A utility for this controlled component
109
115
  * to communicate to the currently typed input.
110
116
  */
111
- onInputValueChange?: UseComboboxProps<Item>['onInputValueChange'];
117
+ onInputValueChange?: UseComboboxProps<ItemType>['onInputValueChange'];
112
118
  /**
113
119
  * `onMenuChange` is a utility for this controlled component to communicate to a
114
120
  * consuming component that the menu was opened(`true`)/closed(`false`).
@@ -133,7 +139,7 @@ export interface FilterableMultiSelectProps<Item extends ItemBase> extends Sorti
133
139
  /**
134
140
  * For full control of the selected items
135
141
  */
136
- selectedItems?: Item[];
142
+ selectedItems?: ItemType[];
137
143
  /**
138
144
  * Specify the size of the ListBox.
139
145
  * Currently, supports either `sm`, `md` or `lg` as an option.
@@ -167,7 +173,7 @@ export interface FilterableMultiSelectProps<Item extends ItemBase> extends Sorti
167
173
  warnText?: ReactNode;
168
174
  }
169
175
  declare const FilterableMultiSelect: {
170
- <Item extends ItemBase>(props: FilterableMultiSelectProps<Item>): ReactElement;
176
+ <ItemType>(props: FilterableMultiSelectProps<ItemType>): ReactElement;
171
177
  propTypes?: any;
172
178
  contextTypes?: any;
173
179
  defaultProps?: any;