@carbon/react 1.68.0-rc.0 → 1.69.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.
- package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +743 -743
- package/README.md +3 -3
- package/es/components/Accordion/AccordionItem.js +0 -1
- package/es/components/Button/Button.js +6 -0
- package/es/components/CheckboxGroup/CheckboxGroup.js +1 -2
- package/es/components/CheckboxGroup/index.d.ts +10 -0
- package/es/components/ComboBox/ComboBox.d.ts +5 -0
- package/es/components/ComboBox/ComboBox.js +139 -54
- package/es/components/ComboButton/index.js +10 -3
- package/es/components/DataTable/TableCell.d.ts +1 -4
- package/es/components/DataTable/TableCell.js +3 -2
- package/es/components/DatePicker/DatePicker.js +10 -6
- package/es/components/Disclosure/index.d.ts +18 -0
- package/es/components/Dropdown/Dropdown.js +11 -9
- package/es/components/FileUploader/FileUploader.d.ts +8 -92
- package/es/components/FileUploader/FileUploader.js +116 -137
- package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
- package/es/components/FluidComboBox/FluidComboBox.Skeleton.d.ts +15 -0
- package/es/components/FluidComboBox/FluidComboBox.Skeleton.js +1 -2
- package/es/components/FluidComboBox/FluidComboBox.d.ts +102 -0
- package/es/components/FluidComboBox/FluidComboBox.js +2 -3
- package/es/components/FluidComboBox/index.d.ts +13 -0
- package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.d.ts +19 -0
- package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.js +2 -2
- package/es/components/FluidDatePicker/FluidDatePicker.d.ts +39 -0
- package/es/components/FluidDatePicker/FluidDatePicker.js +2 -3
- package/es/components/FluidDatePicker/index.d.ts +13 -0
- package/es/components/FluidDatePickerInput/FluidDatePickerInput.d.ts +10 -0
- package/es/components/FluidDatePickerInput/FluidDatePickerInput.js +1 -2
- package/es/components/FluidDatePickerInput/index.d.ts +9 -0
- package/es/components/IdPrefix/index.d.ts +26 -0
- package/es/components/Menu/MenuItem.js +1 -4
- package/es/components/MenuButton/index.d.ts +4 -0
- package/es/components/MenuButton/index.js +19 -5
- package/es/components/MultiSelect/MultiSelect.js +11 -9
- package/es/components/OverflowMenu/next/index.d.ts +4 -0
- package/es/components/OverflowMenu/next/index.js +19 -9
- package/es/components/PaginationNav/PaginationNav.js +1 -1
- package/es/components/Popover/index.js +18 -14
- package/es/components/Portal/index.d.ts +25 -0
- package/es/components/Slider/Slider.js +2 -2
- package/es/components/Tabs/usePressable.js +2 -0
- package/es/components/Tag/DismissibleTag.js +2 -2
- package/es/components/Tag/OperationalTag.d.ts +2 -10
- package/es/components/Tag/OperationalTag.js +2 -14
- package/es/components/Tag/SelectableTag.d.ts +2 -10
- package/es/components/Tag/SelectableTag.js +2 -16
- package/es/components/Toggle/Toggle.js +2 -0
- package/es/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +49 -0
- package/es/components/ToggleSmall/index.d.ts +7 -0
- package/es/components/TreeView/TreeNode.js +4 -2
- package/es/components/TreeView/TreeView.js +4 -4
- package/es/components/UIShell/SideNavMenuItem.d.ts +4 -3
- package/es/components/UIShell/SideNavMenuItem.js +1 -4
- package/es/index.js +6 -6
- package/es/internal/useIdPrefix.d.ts +9 -0
- package/lib/components/Accordion/AccordionItem.js +0 -1
- package/lib/components/Button/Button.js +6 -0
- package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -2
- package/lib/components/CheckboxGroup/index.d.ts +10 -0
- package/lib/components/ComboBox/ComboBox.d.ts +5 -0
- package/lib/components/ComboBox/ComboBox.js +144 -59
- package/lib/components/ComboButton/index.js +12 -5
- package/lib/components/DataTable/TableCell.d.ts +1 -4
- package/lib/components/DataTable/TableCell.js +3 -2
- package/lib/components/DatePicker/DatePicker.js +9 -5
- package/lib/components/Disclosure/index.d.ts +18 -0
- package/lib/components/Dropdown/Dropdown.js +18 -16
- package/lib/components/FileUploader/FileUploader.d.ts +8 -92
- package/lib/components/FileUploader/FileUploader.js +113 -134
- package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -1
- package/lib/components/FluidComboBox/FluidComboBox.Skeleton.d.ts +15 -0
- package/lib/components/FluidComboBox/FluidComboBox.Skeleton.js +1 -2
- package/lib/components/FluidComboBox/FluidComboBox.d.ts +102 -0
- package/lib/components/FluidComboBox/FluidComboBox.js +2 -3
- package/lib/components/FluidComboBox/index.d.ts +13 -0
- package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.d.ts +19 -0
- package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.js +2 -2
- package/lib/components/FluidDatePicker/FluidDatePicker.d.ts +39 -0
- package/lib/components/FluidDatePicker/FluidDatePicker.js +3 -4
- package/lib/components/FluidDatePicker/index.d.ts +13 -0
- package/lib/components/FluidDatePickerInput/FluidDatePickerInput.d.ts +10 -0
- package/lib/components/FluidDatePickerInput/FluidDatePickerInput.js +1 -2
- package/lib/components/FluidDatePickerInput/index.d.ts +9 -0
- package/lib/components/IdPrefix/index.d.ts +26 -0
- package/lib/components/Menu/MenuItem.js +1 -4
- package/lib/components/MenuButton/index.d.ts +4 -0
- package/lib/components/MenuButton/index.js +19 -5
- package/lib/components/MultiSelect/MultiSelect.js +18 -16
- package/lib/components/OverflowMenu/next/index.d.ts +4 -0
- package/lib/components/OverflowMenu/next/index.js +21 -11
- package/lib/components/PaginationNav/PaginationNav.js +1 -1
- package/lib/components/Popover/index.js +18 -14
- package/lib/components/Portal/index.d.ts +25 -0
- package/lib/components/Slider/Slider.js +2 -2
- package/lib/components/Tabs/usePressable.js +2 -0
- package/lib/components/Tag/DismissibleTag.js +2 -2
- package/lib/components/Tag/OperationalTag.d.ts +2 -10
- package/lib/components/Tag/OperationalTag.js +2 -14
- package/lib/components/Tag/SelectableTag.d.ts +2 -10
- package/lib/components/Tag/SelectableTag.js +2 -16
- package/lib/components/Toggle/Toggle.js +2 -0
- package/lib/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +49 -0
- package/lib/components/ToggleSmall/index.d.ts +7 -0
- package/lib/components/TreeView/TreeNode.js +4 -2
- package/lib/components/TreeView/TreeView.js +4 -4
- package/lib/components/UIShell/SideNavMenuItem.d.ts +4 -3
- package/lib/components/UIShell/SideNavMenuItem.js +1 -4
- package/lib/index.js +12 -12
- package/lib/internal/useIdPrefix.d.ts +9 -0
- package/package.json +7 -7
- package/telemetry.yml +809 -809
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2022
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { DatePickerInputProps } from '../DatePickerInput';
|
|
9
|
+
declare const FluidDatePickerInput: React.ForwardRefExoticComponent<DatePickerInputProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export default FluidDatePickerInput;
|
|
@@ -22,6 +22,5 @@ const FluidDatePickerInput = /*#__PURE__*/React__default.forwardRef(function Flu
|
|
|
22
22
|
ref: ref
|
|
23
23
|
}, other)));
|
|
24
24
|
});
|
|
25
|
-
var FluidDatePickerInput$1 = FluidDatePickerInput;
|
|
26
25
|
|
|
27
|
-
export { FluidDatePickerInput
|
|
26
|
+
export { FluidDatePickerInput as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2022
|
|
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 FluidDatePickerInput from './FluidDatePickerInput';
|
|
8
|
+
export default FluidDatePickerInput;
|
|
9
|
+
export { FluidDatePickerInput };
|
|
@@ -0,0 +1,26 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
8
|
+
import { PropsWithChildren, ReactNode } from 'react';
|
|
9
|
+
type IdPrefixProps = {
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* The value used to prefix the auto-generated id placed on some DOM elements
|
|
13
|
+
*/
|
|
14
|
+
prefix?: string;
|
|
15
|
+
};
|
|
16
|
+
declare function IdPrefix({ children, prefix }: PropsWithChildren<IdPrefixProps>): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare namespace IdPrefix {
|
|
18
|
+
var propTypes: {
|
|
19
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
20
|
+
/**
|
|
21
|
+
* The value used to prefix the auto-generated id placed on some DOM elements
|
|
22
|
+
*/
|
|
23
|
+
prefix: PropTypes.Requireable<string>;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export { IdPrefix };
|
|
@@ -347,9 +347,6 @@ const MenuItemRadioGroup = /*#__PURE__*/forwardRef(function MenuItemRadioGroup(_
|
|
|
347
347
|
});
|
|
348
348
|
function handleClick(item, e) {
|
|
349
349
|
setSelection(item);
|
|
350
|
-
if (onChange) {
|
|
351
|
-
onChange(e);
|
|
352
|
-
}
|
|
353
350
|
}
|
|
354
351
|
useEffect(() => {
|
|
355
352
|
if (!context.state.hasIcons) {
|
|
@@ -374,7 +371,7 @@ const MenuItemRadioGroup = /*#__PURE__*/forwardRef(function MenuItemRadioGroup(_
|
|
|
374
371
|
"aria-checked": item === selection,
|
|
375
372
|
renderIcon: item === selection ? Checkmark : undefined,
|
|
376
373
|
onClick: e => {
|
|
377
|
-
handleClick(item
|
|
374
|
+
handleClick(item);
|
|
378
375
|
}
|
|
379
376
|
}))));
|
|
380
377
|
});
|
|
@@ -39,6 +39,10 @@ export interface MenuButtonProps extends ComponentProps<'div'> {
|
|
|
39
39
|
* Specify the tabIndex of the button.
|
|
40
40
|
*/
|
|
41
41
|
tabIndex?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
|
|
44
|
+
*/
|
|
45
|
+
menuTarget?: Element;
|
|
42
46
|
}
|
|
43
47
|
declare const MenuButton: React.ForwardRefExoticComponent<Omit<MenuButtonProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
44
48
|
export { MenuButton };
|
|
@@ -18,6 +18,7 @@ import { useAttachedMenu } from '../../internal/useAttachedMenu.js';
|
|
|
18
18
|
import { useId } from '../../internal/useId.js';
|
|
19
19
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
20
20
|
import { flip, size, useFloating, autoUpdate } from '@floating-ui/react';
|
|
21
|
+
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
21
22
|
import mergeRefs from '../../tools/mergeRefs.js';
|
|
22
23
|
|
|
23
24
|
const validButtonKinds = ['primary', 'tertiary', 'ghost'];
|
|
@@ -32,14 +33,21 @@ const MenuButton = /*#__PURE__*/forwardRef(function MenuButton(_ref, forwardRef)
|
|
|
32
33
|
size: size$1 = 'lg',
|
|
33
34
|
menuAlignment = 'bottom',
|
|
34
35
|
tabIndex = 0,
|
|
36
|
+
menuTarget,
|
|
35
37
|
...rest
|
|
36
38
|
} = _ref;
|
|
39
|
+
// feature flag utilized to separate out only the dynamic styles from @floating-ui
|
|
40
|
+
// flag is turned on when collision detection (ie. flip, hide) logic is not desired
|
|
41
|
+
const enableOnlyFloatingStyles = useFeatureFlag('enable-v12-dynamic-floating-styles');
|
|
37
42
|
const id = useId('MenuButton');
|
|
38
43
|
const prefix = usePrefix();
|
|
39
44
|
const triggerRef = useRef(null);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
let middlewares = [];
|
|
46
|
+
if (!enableOnlyFloatingStyles) {
|
|
47
|
+
middlewares = [flip({
|
|
48
|
+
crossAxis: false
|
|
49
|
+
})];
|
|
50
|
+
}
|
|
43
51
|
if (menuAlignment === 'bottom' || menuAlignment === 'top') {
|
|
44
52
|
middlewares.push(size({
|
|
45
53
|
apply(_ref2) {
|
|
@@ -121,7 +129,8 @@ const MenuButton = /*#__PURE__*/forwardRef(function MenuButton(_ref, forwardRef)
|
|
|
121
129
|
mode: "basic",
|
|
122
130
|
size: size$1,
|
|
123
131
|
open: open,
|
|
124
|
-
onClose: handleClose
|
|
132
|
+
onClose: handleClose,
|
|
133
|
+
target: menuTarget
|
|
125
134
|
}, children));
|
|
126
135
|
});
|
|
127
136
|
MenuButton.propTypes = {
|
|
@@ -160,7 +169,12 @@ MenuButton.propTypes = {
|
|
|
160
169
|
* Specify the tabIndex of the button.
|
|
161
170
|
*/
|
|
162
171
|
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
163
|
-
tabIndex: PropTypes.number
|
|
172
|
+
tabIndex: PropTypes.number,
|
|
173
|
+
/**
|
|
174
|
+
* Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
menuTarget: PropTypes.instanceOf(typeof Element !== 'undefined' ? Element : Object)
|
|
164
178
|
};
|
|
165
179
|
|
|
166
180
|
export { MenuButton };
|
|
@@ -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(
|
|
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 (
|
|
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
|
-
}, [
|
|
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`]:
|
|
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:
|
|
414
|
-
}), [
|
|
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:
|
|
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(
|
|
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
|
-
} : {}
|
|
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 (
|
|
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,
|
|
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`]:
|
|
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: !
|
|
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(
|
|
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
|
-
} : {}
|
|
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 (
|
|
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,
|
|
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`]:
|
|
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 =
|
|
209
|
-
const isAllowedTriggerComponent =
|
|
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 (
|
|
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
|
-
}),
|
|
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,
|
|
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
|
-
})), !
|
|
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:
|
|
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:
|
|
1125
|
+
tabIndex: readOnly || disabled ? undefined : 0,
|
|
1126
1126
|
"aria-valuemax": max,
|
|
1127
1127
|
"aria-valuemin": value,
|
|
1128
1128
|
"aria-valuenow": valueUpper,
|
|
@@ -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))))
|
|
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
|
|
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,
|
|
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)
|
|
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),
|
|
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
|
*/
|