@carbon/react 1.68.0 → 1.69.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 (94) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +871 -871
  2. package/README.md +3 -3
  3. package/es/components/Accordion/AccordionItem.js +0 -1
  4. package/es/components/Button/Button.js +6 -0
  5. package/es/components/Checkbox/Checkbox.js +1 -1
  6. package/es/components/CheckboxGroup/CheckboxGroup.js +1 -2
  7. package/es/components/CheckboxGroup/index.d.ts +10 -0
  8. package/es/components/ComboBox/ComboBox.js +13 -18
  9. package/es/components/ComboButton/index.js +10 -3
  10. package/es/components/DataTable/TableCell.d.ts +1 -4
  11. package/es/components/DataTable/TableCell.js +3 -2
  12. package/es/components/Disclosure/index.d.ts +18 -0
  13. package/es/components/Dropdown/Dropdown.js +11 -9
  14. package/es/components/FileUploader/FileUploader.d.ts +8 -92
  15. package/es/components/FileUploader/FileUploader.js +116 -137
  16. package/es/components/Grid/CSSGrid.js +8 -1
  17. package/es/components/Grid/Grid.js +4 -0
  18. package/es/components/IdPrefix/index.d.ts +26 -0
  19. package/es/components/ListBox/next/ListBoxSelection.d.ts +9 -1
  20. package/es/components/ListBox/next/ListBoxSelection.js +12 -5
  21. package/es/components/Menu/MenuItem.js +1 -4
  22. package/es/components/MenuButton/index.d.ts +4 -0
  23. package/es/components/MenuButton/index.js +19 -5
  24. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +4 -0
  25. package/es/components/MultiSelect/FilterableMultiSelect.js +32 -6
  26. package/es/components/MultiSelect/MultiSelect.js +11 -9
  27. package/es/components/OverflowMenu/next/index.d.ts +4 -0
  28. package/es/components/OverflowMenu/next/index.js +19 -9
  29. package/es/components/PaginationNav/PaginationNav.js +1 -1
  30. package/es/components/Popover/index.js +18 -14
  31. package/es/components/Portal/index.d.ts +25 -0
  32. package/es/components/Slider/Slider.js +2 -2
  33. package/es/components/Tabs/Tabs.js +46 -20
  34. package/es/components/Tag/DismissibleTag.js +2 -2
  35. package/es/components/Tag/OperationalTag.d.ts +2 -10
  36. package/es/components/Tag/OperationalTag.js +2 -14
  37. package/es/components/Tag/SelectableTag.d.ts +18 -10
  38. package/es/components/Tag/SelectableTag.js +22 -28
  39. package/es/components/Toggle/Toggle.js +2 -0
  40. package/es/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +49 -0
  41. package/es/components/ToggleSmall/index.d.ts +7 -0
  42. package/es/components/TreeView/TreeNode.js +4 -2
  43. package/es/components/TreeView/TreeView.js +4 -4
  44. package/es/components/UIShell/SideNavMenuItem.d.ts +4 -3
  45. package/es/components/UIShell/SideNavMenuItem.js +1 -4
  46. package/es/index.js +1 -1
  47. package/es/internal/useIdPrefix.d.ts +9 -0
  48. package/lib/components/Accordion/AccordionItem.js +0 -1
  49. package/lib/components/Button/Button.js +6 -0
  50. package/lib/components/Checkbox/Checkbox.js +1 -1
  51. package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -2
  52. package/lib/components/CheckboxGroup/index.d.ts +10 -0
  53. package/lib/components/ComboBox/ComboBox.js +18 -23
  54. package/lib/components/ComboButton/index.js +12 -5
  55. package/lib/components/DataTable/TableCell.d.ts +1 -4
  56. package/lib/components/DataTable/TableCell.js +3 -2
  57. package/lib/components/Disclosure/index.d.ts +18 -0
  58. package/lib/components/Dropdown/Dropdown.js +18 -16
  59. package/lib/components/FileUploader/FileUploader.d.ts +8 -92
  60. package/lib/components/FileUploader/FileUploader.js +113 -134
  61. package/lib/components/Grid/CSSGrid.js +8 -1
  62. package/lib/components/Grid/Grid.js +4 -0
  63. package/lib/components/IdPrefix/index.d.ts +26 -0
  64. package/lib/components/ListBox/next/ListBoxSelection.d.ts +9 -1
  65. package/lib/components/ListBox/next/ListBoxSelection.js +12 -5
  66. package/lib/components/Menu/MenuItem.js +1 -4
  67. package/lib/components/MenuButton/index.d.ts +4 -0
  68. package/lib/components/MenuButton/index.js +19 -5
  69. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +4 -0
  70. package/lib/components/MultiSelect/FilterableMultiSelect.js +32 -6
  71. package/lib/components/MultiSelect/MultiSelect.js +18 -16
  72. package/lib/components/OverflowMenu/next/index.d.ts +4 -0
  73. package/lib/components/OverflowMenu/next/index.js +21 -11
  74. package/lib/components/PaginationNav/PaginationNav.js +1 -1
  75. package/lib/components/Popover/index.js +18 -14
  76. package/lib/components/Portal/index.d.ts +25 -0
  77. package/lib/components/Slider/Slider.js +2 -2
  78. package/lib/components/Tabs/Tabs.js +46 -20
  79. package/lib/components/Tag/DismissibleTag.js +2 -2
  80. package/lib/components/Tag/OperationalTag.d.ts +2 -10
  81. package/lib/components/Tag/OperationalTag.js +2 -14
  82. package/lib/components/Tag/SelectableTag.d.ts +18 -10
  83. package/lib/components/Tag/SelectableTag.js +22 -28
  84. package/lib/components/Toggle/Toggle.js +2 -0
  85. package/lib/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +49 -0
  86. package/lib/components/ToggleSmall/index.d.ts +7 -0
  87. package/lib/components/TreeView/TreeNode.js +4 -2
  88. package/lib/components/TreeView/TreeView.js +4 -4
  89. package/lib/components/UIShell/SideNavMenuItem.d.ts +4 -3
  90. package/lib/components/UIShell/SideNavMenuItem.js +1 -4
  91. package/lib/index.js +2 -2
  92. package/lib/internal/useIdPrefix.d.ts +9 -0
  93. package/package.json +10 -9
  94. package/telemetry.yml +809 -809
@@ -27,6 +27,7 @@ import '../Checkbox/Checkbox.Skeleton.js';
27
27
  import { noopFn } from '../../internal/noopFn.js';
28
28
  import { useFloating, flip, size, autoUpdate } from '@floating-ui/react';
29
29
  import { hide } from '../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js';
30
+ import { useFeatureFlag } from '../FeatureFlags/index.js';
30
31
  import { match } from '../../internal/keyboard/match.js';
31
32
  import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
32
33
  import { Delete, Escape, Space, ArrowDown, Enter } from '../../internal/keyboard/keys.js';
@@ -125,11 +126,12 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
125
126
  const [prevOpenProp, setPrevOpenProp] = useState(open);
126
127
  const [topItems, setTopItems] = useState([]);
127
128
  const [itemsCleared, setItemsCleared] = useState(false);
129
+ const enableFloatingStyles = useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
128
130
  const {
129
131
  refs,
130
132
  floatingStyles,
131
133
  middlewareData
132
- } = useFloating(autoAlign ? {
134
+ } = useFloating(enableFloatingStyles ? {
133
135
  placement: direction,
134
136
  // The floating element is positioned relative to its nearest
135
137
  // containing block (usually the viewport). It will in many cases also
@@ -137,7 +139,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
137
139
  // https://floating-ui.com/docs/misc#clipping
138
140
  strategy: 'fixed',
139
141
  // Middleware order matters, arrow should be last
140
- middleware: [flip({
142
+ middleware: [autoAlign && flip({
141
143
  crossAxis: false
142
144
  }), size({
143
145
  apply(_ref2) {
@@ -149,11 +151,11 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
149
151
  width: `${rects.reference.width}px`
150
152
  });
151
153
  }
152
- }), hide()],
154
+ }), autoAlign && hide()],
153
155
  whileElementsMounted: autoUpdate
154
156
  } : {});
155
157
  useLayoutEffect(() => {
156
- if (autoAlign) {
158
+ if (enableFloatingStyles) {
157
159
  const updatedFloatingStyles = {
158
160
  ...floatingStyles,
159
161
  visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
@@ -164,7 +166,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
164
166
  }
165
167
  });
166
168
  }
167
- }, [autoAlign, floatingStyles, refs.floating, middlewareData, open]);
169
+ }, [enableFloatingStyles, floatingStyles, refs.floating, middlewareData, open]);
168
170
  const {
169
171
  selectedItems: controlledSelectedItems,
170
172
  onItemChange,
@@ -279,7 +281,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
279
281
  [`${prefix}--multi-select--selected`]: selectedItems && selectedItems.length > 0,
280
282
  [`${prefix}--list-box--up`]: direction === 'top',
281
283
  [`${prefix}--multi-select--readonly`]: readOnly,
282
- [`${prefix}--autoalign`]: autoAlign,
284
+ [`${prefix}--autoalign`]: enableFloatingStyles,
283
285
  [`${prefix}--multi-select--selectall`]: selectAll
284
286
  });
285
287
 
@@ -410,8 +412,8 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
410
412
 
411
413
  // Memoize the value of getMenuProps to avoid an infinite loop
412
414
  const menuProps = useMemo(() => getMenuProps({
413
- ref: autoAlign ? refs.setFloating : null
414
- }), [autoAlign, getMenuProps, refs.setFloating]);
415
+ ref: enableFloatingStyles ? refs.setFloating : null
416
+ }), [enableFloatingStyles, getMenuProps, refs.setFloating]);
415
417
  return /*#__PURE__*/React__default.createElement("div", {
416
418
  className: wrapperClasses
417
419
  }, /*#__PURE__*/React__default.createElement("label", _extends({
@@ -438,7 +440,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
438
440
  className: `${prefix}--list-box__invalid-icon ${prefix}--list-box__invalid-icon--warning`
439
441
  }), /*#__PURE__*/React__default.createElement("div", {
440
442
  className: multiSelectFieldWrapperClasses,
441
- ref: autoAlign ? refs.setReference : null
443
+ ref: enableFloatingStyles ? refs.setReference : null
442
444
  }, selectedItems.length > 0 && /*#__PURE__*/React__default.createElement(ListBox.Selection, {
443
445
  readOnly: readOnly,
444
446
  clearSelection: !disabled && !readOnly ? clearSelection : noopFn,
@@ -38,6 +38,10 @@ interface OverflowMenuProps {
38
38
  * Specify how the trigger tooltip should be aligned.
39
39
  */
40
40
  tooltipAlignment?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
41
+ /**
42
+ * Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
43
+ */
44
+ menuTarget?: Element;
41
45
  }
42
46
  declare const OverflowMenu: React.ForwardRefExoticComponent<OverflowMenuProps & React.RefAttributes<HTMLDivElement>>;
43
47
  export { OverflowMenu };
@@ -11,6 +11,7 @@ import PropTypes from 'prop-types';
11
11
  import cx from 'classnames';
12
12
  import { OverflowMenuVertical } from '@carbon/icons-react';
13
13
  import { useFloating, flip, autoUpdate } from '@floating-ui/react';
14
+ import { useFeatureFlag } from '../../FeatureFlags/index.js';
14
15
  import { IconButton } from '../../IconButton/index.js';
15
16
  import { Menu } from '../../Menu/Menu.js';
16
17
  import '../../Menu/MenuItem.js';
@@ -30,14 +31,16 @@ const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMen
30
31
  size = defaultSize,
31
32
  menuAlignment = 'bottom-start',
32
33
  tooltipAlignment,
34
+ menuTarget,
33
35
  ...rest
34
36
  } = _ref;
37
+ const enableFloatingStyles = useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
35
38
  const {
36
39
  refs,
37
40
  floatingStyles,
38
41
  placement,
39
42
  middlewareData
40
- } = useFloating(autoAlign ? {
43
+ } = useFloating(enableFloatingStyles ? {
41
44
  // Computing the position starts with initial positioning
42
45
  // via `placement`.
43
46
  placement: menuAlignment,
@@ -49,14 +52,16 @@ const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMen
49
52
  // Middleware are executed as an in-between “middle” step of the
50
53
  // initial `placement` computation and eventual return of data for
51
54
  // rendering. Each middleware is executed in order.
52
- middleware: [flip({
55
+ middleware: [autoAlign && flip({
53
56
  // An explicit array of placements to try if the initial
54
57
  // `placement` doesn’t fit on the axes in which overflow
55
58
  // is checked.
56
59
  fallbackPlacements: menuAlignment.includes('bottom') ? ['bottom-start', 'bottom-end', 'top-start', 'top-end'] : ['top-start', 'top-end', 'bottom-start', 'bottom-end']
57
60
  })],
58
61
  whileElementsMounted: autoUpdate
59
- } : {} // When autoAlign is turned off, floating-ui will not be used
62
+ } : {}
63
+ // When autoAlign is turned off & the `enable-v12-dynamic-floating-styles` feature flag is not
64
+ // enabled, floating-ui will not be used
60
65
  );
61
66
  const id = useId('overflowmenu');
62
67
  const prefix = usePrefix();
@@ -70,21 +75,21 @@ const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMen
70
75
  handleClose
71
76
  } = useAttachedMenu(triggerRef);
72
77
  useEffect(() => {
73
- if (autoAlign) {
78
+ if (enableFloatingStyles) {
74
79
  Object.keys(floatingStyles).forEach(style => {
75
80
  if (refs.floating.current) {
76
81
  refs.floating.current.style[style] = floatingStyles[style];
77
82
  }
78
83
  });
79
84
  }
80
- }, [floatingStyles, autoAlign, refs.floating, open, placement, middlewareData]);
85
+ }, [floatingStyles, enableFloatingStyles, refs.floating, open, placement, middlewareData]);
81
86
  function handleTriggerClick() {
82
87
  if (triggerRef.current) {
83
88
  hookOnClick();
84
89
  }
85
90
  }
86
91
  const containerClasses = cx(className, `${prefix}--overflow-menu__container`, {
87
- [`${prefix}--autoalign`]: autoAlign
92
+ [`${prefix}--autoalign`]: enableFloatingStyles
88
93
  });
89
94
  const menuClasses = cx(`${prefix}--overflow-menu__${menuAlignment}`);
90
95
  const triggerClasses = cx(`${prefix}--overflow-menu`, {
@@ -115,12 +120,13 @@ const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMen
115
120
  className: menuClasses,
116
121
  id: id,
117
122
  size: size,
118
- legacyAutoalign: !autoAlign,
123
+ legacyAutoalign: !enableFloatingStyles,
119
124
  open: open,
120
125
  onClose: handleClose,
121
126
  x: x,
122
127
  y: y,
123
- label: label
128
+ label: label,
129
+ target: menuTarget
124
130
  }, children));
125
131
  });
126
132
  OverflowMenu.propTypes = {
@@ -156,7 +162,11 @@ OverflowMenu.propTypes = {
156
162
  /**
157
163
  * Specify how the trigger tooltip should be aligned.
158
164
  */
159
- tooltipAlignment: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right'])
165
+ tooltipAlignment: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right']),
166
+ /**
167
+ * Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
168
+ */
169
+ menuTarget: PropTypes.instanceOf(typeof Element !== 'undefined' ? Element : Object)
160
170
  };
161
171
 
162
172
  export { OverflowMenu };
@@ -213,7 +213,7 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
213
213
  }
214
214
  function pageWouldBeHidden(page) {
215
215
  const startOffset = itemsDisplayedOnPage <= 4 && page > 1 ? 0 : 1;
216
- const wouldBeHiddenInFront = page >= startOffset && page <= cuts.front;
216
+ const wouldBeHiddenInFront = page >= startOffset && page <= cuts.front || page === 0;
217
217
  const wouldBeHiddenInBack = page >= totalItems - cuts.back - 1 && page <= totalItems - 2;
218
218
  return wouldBeHiddenInFront || wouldBeHiddenInBack;
219
219
  }
@@ -17,6 +17,7 @@ import { useWindowEvent } from '../../internal/useEvent.js';
17
17
  import { mapPopoverAlignProp } from '../../tools/createPropAdapter.js';
18
18
  import { useFloating, offset, flip, arrow, autoUpdate } from '@floating-ui/react';
19
19
  import { hide } from '../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js';
20
+ import { useFeatureFlag } from '../FeatureFlags/index.js';
20
21
 
21
22
  const PopoverContext = /*#__PURE__*/React__default.createContext({
22
23
  setFloating: {
@@ -65,6 +66,7 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
65
66
  const floating = useRef(null);
66
67
  const caretRef = useRef(null);
67
68
  const popover = useRef(null);
69
+ const enableFloatingStyles = useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
68
70
  let align = mapPopoverAlignProp(initialAlign);
69
71
 
70
72
  // If the `Popover` is the last focusable item in the tab order, it should also close when the browser window loses focus (#12922)
@@ -117,7 +119,7 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
117
119
  floatingStyles,
118
120
  placement,
119
121
  middlewareData
120
- } = useFloating(autoAlign ? {
122
+ } = useFloating(enableFloatingStyles ? {
121
123
  placement: align,
122
124
  // The floating element is positioned relative to its nearest
123
125
  // containing block (usually the viewport). It will in many cases also
@@ -125,13 +127,15 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
125
127
  // https://floating-ui.com/docs/misc#clipping
126
128
  strategy: 'fixed',
127
129
  // Middleware order matters, arrow should be last
128
- middleware: [offset(!isTabTip ? popoverDimensions?.current?.offset : 0), flip({
130
+ middleware: [offset(!isTabTip ? popoverDimensions?.current?.offset : 0), autoAlign && flip({
129
131
  fallbackAxisSideDirection: 'start'
130
132
  }), arrow({
131
133
  element: caretRef
132
- }), hide()],
134
+ }), autoAlign && hide()],
133
135
  whileElementsMounted: autoUpdate
134
- } : {} // When autoAlign is turned off, floating-ui will not be used
136
+ } : {}
137
+ // When autoAlign is turned off & the `enable-v12-dynamic-floating-styles` feature flag is not
138
+ // enabled, floating-ui will not be used
135
139
  );
136
140
  const value = useMemo(() => {
137
141
  return {
@@ -148,7 +152,7 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
148
152
  }
149
153
  }
150
154
  useEffect(() => {
151
- if (autoAlign) {
155
+ if (enableFloatingStyles) {
152
156
  const updatedFloatingStyles = {
153
157
  ...floatingStyles,
154
158
  visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
@@ -180,7 +184,7 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
180
184
  }
181
185
  }
182
186
  }
183
- }, [floatingStyles, refs.floating, autoAlign, middlewareData, placement, caret]);
187
+ }, [floatingStyles, refs.floating, enableFloatingStyles, middlewareData, placement, caret]);
184
188
  const ref = useMergedRefs([forwardRef, popover]);
185
189
  const currentAlignment = autoAlign && placement !== align ? placement : align;
186
190
  const className = cx({
@@ -189,7 +193,7 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
189
193
  [`${prefix}--popover--drop-shadow`]: dropShadow,
190
194
  [`${prefix}--popover--high-contrast`]: highContrast,
191
195
  [`${prefix}--popover--open`]: open,
192
- [`${prefix}--popover--auto-align ${prefix}--autoalign`]: autoAlign,
196
+ [`${prefix}--popover--auto-align ${prefix}--autoalign`]: enableFloatingStyles,
193
197
  [`${prefix}--popover--${currentAlignment}`]: true,
194
198
  [`${prefix}--popover--tab-tip`]: isTabTip
195
199
  }, customClassName);
@@ -205,8 +209,8 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
205
209
  * is on, even if they are a trigger element.
206
210
  */
207
211
  const isTriggerElement = item?.type === 'button';
208
- const isTriggerComponent = autoAlign && displayName && ['ToggletipButton'].includes(displayName);
209
- const isAllowedTriggerComponent = autoAlign && !['ToggletipContent', 'PopoverContent'].includes(displayName);
212
+ const isTriggerComponent = enableFloatingStyles && displayName && ['ToggletipButton'].includes(displayName);
213
+ const isAllowedTriggerComponent = enableFloatingStyles && !['ToggletipContent', 'PopoverContent'].includes(displayName);
210
214
  if ( /*#__PURE__*/React__default.isValidElement(item) && (isTriggerElement || isTriggerComponent || isAllowedTriggerComponent)) {
211
215
  const className = item?.props?.className;
212
216
  const ref = (item?.props).ref;
@@ -225,7 +229,7 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
225
229
  // For a toggletip there is a specific trigger component, ToggletipButton.
226
230
  // In either of these caes we want to set this as the reference node for floating-ui autoAlign
227
231
  // positioning.
228
- if (autoAlign && item?.type?.displayName !== 'PopoverContent' || autoAlign && item?.type?.displayName === 'ToggletipButton') {
232
+ if (enableFloatingStyles && item?.type?.displayName !== 'PopoverContent' || enableFloatingStyles && item?.type?.displayName === 'ToggletipButton') {
229
233
  // Set the reference element for floating-ui
230
234
  refs.setReference(node);
231
235
  }
@@ -248,7 +252,7 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
248
252
  }, /*#__PURE__*/React__default.createElement(BaseComponentAsAny, _extends({}, rest, {
249
253
  className: className,
250
254
  ref: ref
251
- }), autoAlign || isTabTip ? mappedChildren : children));
255
+ }), enableFloatingStyles || isTabTip ? mappedChildren : children));
252
256
  });
253
257
 
254
258
  // Note: this displayName is temporarily set so that Storybook ArgTable
@@ -259,7 +263,6 @@ if (process.env.NODE_ENV !== "production") {
259
263
  Popover.propTypes = {
260
264
  /**
261
265
  * Specify how the popover should align with the trigger element
262
-
263
266
  */
264
267
  align: deprecateValuesWithin(PropTypes.oneOf(['top', 'top-left',
265
268
  // deprecated use top-start instead
@@ -345,18 +348,19 @@ _ref2, forwardRef) {
345
348
  autoAlign
346
349
  } = React__default.useContext(PopoverContext);
347
350
  const ref = useMergedRefs([setFloating, forwardRef]);
351
+ const enableFloatingStyles = useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
348
352
  return /*#__PURE__*/React__default.createElement("span", _extends({}, rest, {
349
353
  className: `${prefix}--popover`
350
354
  }), /*#__PURE__*/React__default.createElement("span", {
351
355
  className: cx(`${prefix}--popover-content`, className),
352
356
  ref: ref
353
- }, children, autoAlign && /*#__PURE__*/React__default.createElement("span", {
357
+ }, children, enableFloatingStyles && /*#__PURE__*/React__default.createElement("span", {
354
358
  className: cx({
355
359
  [`${prefix}--popover-caret`]: true,
356
360
  [`${prefix}--popover--auto-align`]: true
357
361
  }),
358
362
  ref: caretRef
359
- })), !autoAlign && /*#__PURE__*/React__default.createElement("span", {
363
+ })), !enableFloatingStyles && /*#__PURE__*/React__default.createElement("span", {
360
364
  className: cx({
361
365
  [`${prefix}--popover-caret`]: true
362
366
  }),
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React, { ReactNode } from 'react';
8
+ interface PortalProps {
9
+ /**
10
+ * Specify the children elements to be rendered inside of the <Portal>
11
+ */
12
+ children: ReactNode;
13
+ /**
14
+ * Provide a ref for a container node to render the portal
15
+ */
16
+ container?: React.RefObject<HTMLElement>;
17
+ }
18
+ /**
19
+ * Helper component for rendering content within a portal. By default, the
20
+ * portal will render into document.body. You can customize this behavior with
21
+ * the `container` prop. Any `children` provided to this component will be
22
+ * rendered inside of the container.
23
+ */
24
+ declare function Portal({ container, children, }: PortalProps): React.ReactPortal | null;
25
+ export { Portal };
@@ -1103,7 +1103,7 @@ class Slider extends PureComponent {
1103
1103
  className: lowerThumbClasses,
1104
1104
  role: "slider",
1105
1105
  id: twoHandles ? undefined : id,
1106
- tabIndex: !readOnly ? 0 : -1,
1106
+ tabIndex: readOnly || disabled ? undefined : 0,
1107
1107
  "aria-valuetext": `${formatLabel(value, '')}`,
1108
1108
  "aria-valuemax": twoHandles ? valueUpper : max,
1109
1109
  "aria-valuemin": min,
@@ -1122,7 +1122,7 @@ class Slider extends PureComponent {
1122
1122
  }, upperThumbWrapperProps), /*#__PURE__*/React__default.createElement("div", {
1123
1123
  className: upperThumbClasses,
1124
1124
  role: "slider",
1125
- tabIndex: !readOnly ? 0 : -1,
1125
+ tabIndex: readOnly || disabled ? undefined : 0,
1126
1126
  "aria-valuemax": max,
1127
1127
  "aria-valuemin": value,
1128
1128
  "aria-valuenow": valueUpper,
@@ -322,8 +322,8 @@ function TabList(_ref4) {
322
322
  function onKeyDown(event) {
323
323
  if (matches(event, [ArrowRight, ArrowLeft, Home, End])) {
324
324
  event.preventDefault();
325
- const filtredTabs = tabs.current.filter(tab => tab !== null);
326
- const activeTabs = filtredTabs.filter(tab => !tab.disabled);
325
+ const filteredTabs = tabs.current.filter(tab => tab !== null);
326
+ const activeTabs = filteredTabs.filter(tab => !tab.disabled);
327
327
  const currentIndex = activeTabs.indexOf(tabs.current[activation === 'automatic' ? selectedIndex : activeIndex]);
328
328
  const nextIndex = tabs.current.indexOf(activeTabs[getNextIndex(event, activeTabs.length, currentIndex)]);
329
329
  if (activation === 'automatic') {
@@ -334,6 +334,18 @@ function TabList(_ref4) {
334
334
  tabs.current[nextIndex]?.focus();
335
335
  }
336
336
  }
337
+ function handleBlur(_ref5) {
338
+ let {
339
+ relatedTarget: currentActiveNode
340
+ } = _ref5;
341
+ if (ref.current?.contains(currentActiveNode)) {
342
+ return;
343
+ }
344
+ // reset active index to selected tab index for manual activation
345
+ if (activation === 'manual') {
346
+ setActiveIndex(selectedIndex);
347
+ }
348
+ }
337
349
  useEffectOnce(() => {
338
350
  const tab = tabs.current[selectedIndex];
339
351
  if (scrollIntoView && tab) {
@@ -419,10 +431,10 @@ function TabList(_ref4) {
419
431
  }
420
432
  }, [activation, activeIndex, selectedIndex, isScrollable, children]);
421
433
  usePressable(previousButton, {
422
- onPress(_ref5) {
434
+ onPress(_ref6) {
423
435
  let {
424
436
  longPress
425
- } = _ref5;
437
+ } = _ref6;
426
438
  if (!longPress && ref.current) {
427
439
  setScrollLeft(Math.max(scrollLeft - ref.current.scrollWidth / tabs.current.length * 1.5, 0));
428
440
  }
@@ -432,10 +444,10 @@ function TabList(_ref4) {
432
444
  }
433
445
  });
434
446
  usePressable(nextButton, {
435
- onPress(_ref6) {
447
+ onPress(_ref7) {
436
448
  let {
437
449
  longPress
438
- } = _ref6;
450
+ } = _ref7;
439
451
  if (!longPress && ref.current) {
440
452
  setScrollLeft(Math.min(scrollLeft + ref.current.scrollWidth / tabs.current.length * 1.5, ref.current.scrollWidth - ref.current.clientWidth));
441
453
  }
@@ -459,7 +471,8 @@ function TabList(_ref4) {
459
471
  role: "tablist",
460
472
  className: `${prefix}--tab--list`,
461
473
  onScroll: debouncedOnScroll,
462
- onKeyDown: onKeyDown
474
+ onKeyDown: onKeyDown,
475
+ onBlur: handleBlur
463
476
  }), React__default.Children.map(children, (child, index) => {
464
477
  return !isElement(child) ? null : /*#__PURE__*/React__default.createElement(TabContext.Provider, {
465
478
  value: {
@@ -544,7 +557,7 @@ TabList.propTypes = {
544
557
 
545
558
  // type TabElement = HTMLElement & { disabled?: boolean };
546
559
 
547
- function TabListVertical(_ref7) {
560
+ function TabListVertical(_ref8) {
548
561
  let {
549
562
  activation = 'automatic',
550
563
  'aria-label': label,
@@ -552,7 +565,7 @@ function TabListVertical(_ref7) {
552
565
  className: customClassName,
553
566
  scrollIntoView,
554
567
  ...rest
555
- } = _ref7;
568
+ } = _ref8;
556
569
  const {
557
570
  activeIndex,
558
571
  selectedIndex,
@@ -569,8 +582,8 @@ function TabListVertical(_ref7) {
569
582
  function onKeyDown(event) {
570
583
  if (matches(event, [ArrowDown, ArrowUp, Home, End])) {
571
584
  event.preventDefault();
572
- const filtredTabs = tabs.current.filter(tab => tab !== null);
573
- const activeTabs = filtredTabs.filter(tab => !tab.disabled);
585
+ const filteredTabs = tabs.current.filter(tab => tab !== null);
586
+ const activeTabs = filteredTabs.filter(tab => !tab.disabled);
574
587
  const currentIndex = activeTabs.indexOf(tabs.current[activation === 'automatic' ? selectedIndex : activeIndex]);
575
588
  const nextIndex = tabs.current.indexOf(activeTabs[getNextIndexVertical(event, activeTabs.length, currentIndex)]);
576
589
  if (activation === 'automatic') {
@@ -581,6 +594,18 @@ function TabListVertical(_ref7) {
581
594
  tabs.current[nextIndex]?.focus();
582
595
  }
583
596
  }
597
+ function handleBlur(_ref9) {
598
+ let {
599
+ relatedTarget: currentActiveNode
600
+ } = _ref9;
601
+ if (ref.current?.contains(currentActiveNode)) {
602
+ return;
603
+ }
604
+ // reset active index to selected tab index for manual activation
605
+ if (activation === 'manual') {
606
+ setActiveIndex(selectedIndex);
607
+ }
608
+ }
584
609
  useEffectOnce(() => {
585
610
  if (tabs.current[selectedIndex]?.disabled) {
586
611
  const activeTabs = tabs.current.filter(tab => {
@@ -647,7 +672,8 @@ function TabListVertical(_ref7) {
647
672
  ref: ref,
648
673
  role: "tablist",
649
674
  className: `${prefix}--tab--list`,
650
- onKeyDown: onKeyDown
675
+ onKeyDown: onKeyDown,
676
+ onBlur: handleBlur
651
677
  }), React__default.Children.map(children, (child, index) => {
652
678
  return !isElement(child) ? null : /*#__PURE__*/React__default.createElement(TabContext.Provider, {
653
679
  value: {
@@ -730,7 +756,7 @@ function createLongPressBehavior(ref, direction, setScrollLeft) {
730
756
  * Tab
731
757
  */
732
758
 
733
- const Tab = /*#__PURE__*/forwardRef(function Tab(_ref8, forwardRef) {
759
+ const Tab = /*#__PURE__*/forwardRef(function Tab(_ref10, forwardRef) {
734
760
  let {
735
761
  as = 'button',
736
762
  children,
@@ -741,7 +767,7 @@ const Tab = /*#__PURE__*/forwardRef(function Tab(_ref8, forwardRef) {
741
767
  secondaryLabel,
742
768
  renderIcon: Icon,
743
769
  ...rest
744
- } = _ref8;
770
+ } = _ref10;
745
771
  const prefix = usePrefix();
746
772
  const {
747
773
  selectedIndex,
@@ -983,7 +1009,7 @@ Tab.propTypes = {
983
1009
  * IconTab
984
1010
  */
985
1011
 
986
- const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(_ref9, ref) {
1012
+ const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(_ref11, ref) {
987
1013
  let {
988
1014
  children,
989
1015
  className: customClassName,
@@ -992,7 +1018,7 @@ const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(_ref9, r
992
1018
  leaveDelayMs,
993
1019
  label,
994
1020
  ...rest
995
- } = _ref9;
1021
+ } = _ref11;
996
1022
  const prefix = usePrefix();
997
1023
  const classNames = cx(`${prefix}--tabs__nav-item--icon-only`, customClassName);
998
1024
  return /*#__PURE__*/React__default.createElement(Tooltip, {
@@ -1041,12 +1067,12 @@ IconTab.propTypes = {
1041
1067
  * TabPanel
1042
1068
  */
1043
1069
 
1044
- const TabPanel = /*#__PURE__*/React__default.forwardRef(function TabPanel(_ref10, forwardRef) {
1070
+ const TabPanel = /*#__PURE__*/React__default.forwardRef(function TabPanel(_ref12, forwardRef) {
1045
1071
  let {
1046
1072
  children,
1047
1073
  className: customClassName,
1048
1074
  ...rest
1049
- } = _ref10;
1075
+ } = _ref12;
1050
1076
  const prefix = usePrefix();
1051
1077
  const panel = useRef(null);
1052
1078
  const ref = useMergedRefs([forwardRef, panel]);
@@ -1121,10 +1147,10 @@ TabPanel.propTypes = {
1121
1147
  * TabPanels
1122
1148
  */
1123
1149
 
1124
- function TabPanels(_ref11) {
1150
+ function TabPanels(_ref13) {
1125
1151
  let {
1126
1152
  children
1127
- } = _ref11;
1153
+ } = _ref13;
1128
1154
  const prefix = usePrefix();
1129
1155
  const refs = useRef([]);
1130
1156
  const hiddenStates = useRef([]);
@@ -79,7 +79,7 @@ const DismissibleTag = _ref => {
79
79
  }, /*#__PURE__*/React__default.createElement(Text, {
80
80
  title: tagTitle ? tagTitle : text,
81
81
  className: `${prefix}--tag__label`
82
- }, text), /*#__PURE__*/React__default.createElement(Tooltip, {
82
+ }, text), normalizedSlug, /*#__PURE__*/React__default.createElement(Tooltip, {
83
83
  label: isEllipsisApplied ? dismissLabel : title,
84
84
  align: "bottom",
85
85
  className: tooltipClasses,
@@ -91,7 +91,7 @@ const DismissibleTag = _ref => {
91
91
  onClick: handleClose,
92
92
  disabled: disabled,
93
93
  "aria-label": title
94
- }, _Close || (_Close = /*#__PURE__*/React__default.createElement(Close, null)))), normalizedSlug));
94
+ }, _Close || (_Close = /*#__PURE__*/React__default.createElement(Close, null))))));
95
95
  };
96
96
  DismissibleTag.propTypes = {
97
97
  /**
@@ -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 React, { MouseEventHandler, ReactNode } from 'react';
8
+ import React, { MouseEventHandler } from 'react';
9
9
  import { PolymorphicProps } from '../../types/common';
10
10
  import { SIZES } from './Tag';
11
11
  declare const TYPES: {
@@ -44,10 +44,6 @@ export interface OperationalTagBaseProps {
44
44
  * `md` (default) or `lg` sizes.
45
45
  */
46
46
  size?: keyof typeof SIZES;
47
- /**
48
- * **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
49
- */
50
- slug?: ReactNode;
51
47
  /**
52
48
  * Provide text to be rendered inside of a the tag.
53
49
  */
@@ -59,7 +55,7 @@ export interface OperationalTagBaseProps {
59
55
  }
60
56
  export type OperationalTagProps<T extends React.ElementType> = PolymorphicProps<T, OperationalTagBaseProps>;
61
57
  declare const OperationalTag: {
62
- <T extends React.ElementType<any, keyof React.JSX.IntrinsicElements>>({ className, disabled, id, renderIcon, slug, size, text, type, ...other }: OperationalTagProps<T>): import("react/jsx-runtime").JSX.Element;
58
+ <T extends React.ElementType<any, keyof React.JSX.IntrinsicElements>>({ className, disabled, id, renderIcon, size, text, type, ...other }: OperationalTagProps<T>): import("react/jsx-runtime").JSX.Element;
63
59
  propTypes: {
64
60
  /**
65
61
  * Provide a custom className that is applied to the containing <span>
@@ -83,10 +79,6 @@ declare const OperationalTag: {
83
79
  * `md` (default) or `lg` sizes.
84
80
  */
85
81
  size: PropTypes.Requireable<string>;
86
- /**
87
- * **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
88
- */
89
- slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
90
82
  /**
91
83
  * Provide text to be rendered inside of a the tag.
92
84
  */
@@ -36,7 +36,6 @@ const OperationalTag = _ref => {
36
36
  disabled,
37
37
  id,
38
38
  renderIcon,
39
- slug,
40
39
  size,
41
40
  text,
42
41
  type = 'gray',
@@ -51,13 +50,6 @@ const OperationalTag = _ref => {
51
50
  const newElement = tagRef.current?.getElementsByClassName(`${prefix}--tag__label`)[0];
52
51
  setIsEllipsisApplied(isEllipsisActive(newElement));
53
52
  }, [prefix, tagRef]);
54
- let normalizedSlug;
55
- if (slug && slug['type']?.displayName === 'AILabel') {
56
- normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
57
- size: 'sm',
58
- kind: 'inline'
59
- });
60
- }
61
53
  const tooltipClasses = cx(`${prefix}--icon-tooltip`, `${prefix}--tag-label-tooltip`);
62
54
  if (isEllipsisApplied) {
63
55
  return /*#__PURE__*/React__default.createElement(Tooltip, {
@@ -78,7 +70,7 @@ const OperationalTag = _ref => {
78
70
  }, other), /*#__PURE__*/React__default.createElement(Text, {
79
71
  title: text,
80
72
  className: `${prefix}--tag__label`
81
- }, text), normalizedSlug));
73
+ }, text)));
82
74
  }
83
75
  return /*#__PURE__*/React__default.createElement(Tag, _extends({
84
76
  ref: tagRef,
@@ -88,7 +80,7 @@ const OperationalTag = _ref => {
88
80
  disabled: disabled,
89
81
  className: tagClasses,
90
82
  id: tagId
91
- }, other), normalizedSlug, /*#__PURE__*/React__default.createElement(Text, {
83
+ }, other), /*#__PURE__*/React__default.createElement(Text, {
92
84
  title: text,
93
85
  className: `${prefix}--tag__label`
94
86
  }, text));
@@ -116,10 +108,6 @@ OperationalTag.propTypes = {
116
108
  * `md` (default) or `lg` sizes.
117
109
  */
118
110
  size: PropTypes.oneOf(Object.keys(SIZES)),
119
- /**
120
- * **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
121
- */
122
- slug: PropTypes.node,
123
111
  /**
124
112
  * Provide text to be rendered inside of a the tag.
125
113
  */