@carbon/react 1.89.0 → 1.90.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 +877 -877
- package/README.md +2 -2
- package/es/components/AILabel/index.js +8 -6
- package/es/components/Breadcrumb/BreadcrumbItem.js +2 -0
- package/es/components/Button/Button.js +3 -0
- package/es/components/ChatButton/ChatButton.js +1 -0
- package/es/components/CheckboxGroup/CheckboxGroup.js +21 -2
- package/es/components/ComboBox/ComboBox.js +17 -1
- package/es/components/ComboButton/index.js +1 -0
- package/es/components/ComposedModal/ComposedModal.js +18 -4
- package/es/components/DataTable/DataTable.d.ts +3 -8
- package/es/components/DataTable/DataTable.js +14 -0
- package/es/components/DataTable/Table.js +3 -3
- package/es/components/DataTable/TableExpandHeader.js +5 -1
- package/es/components/DataTable/TableExpandRow.d.ts +33 -5
- package/es/components/DataTable/TableExpandRow.js +5 -2
- package/es/components/DataTable/TableHeader.d.ts +1 -2
- package/es/components/DataTable/TableHeader.js +3 -2
- package/es/components/DataTable/TableRow.d.ts +3 -6
- package/es/components/DataTable/TableRow.js +40 -22
- package/es/components/DataTable/TableSlugRow.js +1 -0
- package/es/components/DataTable/TableToolbarMenu.js +3 -0
- package/es/components/DataTable/state/sorting.d.ts +57 -14
- package/es/components/DataTable/state/sorting.js +42 -50
- package/es/components/DataTable/tools/sorting.js +5 -0
- package/es/components/DatePicker/DatePicker.js +14 -3
- package/es/components/DatePickerInput/DatePickerInput.js +6 -0
- package/es/components/Dialog/Dialog.js +10 -2
- package/es/components/Dropdown/Dropdown.js +16 -4
- package/es/components/ErrorBoundary/ErrorBoundaryContext.js +1 -0
- package/es/components/FileUploader/FileUploader.js +9 -2
- package/es/components/FileUploader/FileUploaderButton.js +1 -1
- package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
- package/es/components/FileUploader/FileUploaderItem.js +3 -0
- package/es/components/FluidMultiSelect/FluidMultiSelect.js +2 -0
- package/es/components/FluidNumberInput/FluidNumberInput.js +3 -2
- package/es/components/FluidSearch/FluidSearch.js +3 -2
- package/es/components/FluidSelect/FluidSelect.js +3 -2
- package/es/components/FluidTextInput/FluidTextInput.js +3 -2
- package/es/components/FluidTimePicker/FluidTimePicker.js +11 -4
- package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +3 -2
- package/es/components/Grid/CSSGrid.js +5 -0
- package/es/components/Grid/Column.js +3 -0
- package/es/components/Grid/ColumnHang.js +1 -0
- package/es/components/Grid/FlexGrid.js +1 -0
- package/es/components/Grid/Row.js +1 -0
- package/es/components/Heading/index.js +3 -1
- package/es/components/IconButton/index.js +4 -2
- package/es/components/IconIndicator/index.js +4 -2
- package/es/components/InlineCheckbox/InlineCheckbox.js +3 -2
- package/es/components/Layout/index.js +6 -4
- package/es/components/LayoutDirection/LayoutDirection.js +2 -0
- package/es/components/Link/Link.js +3 -0
- package/es/components/ListBox/ListBoxMenuItem.js +4 -1
- package/es/components/ListBox/next/ListBoxTrigger.js +3 -2
- package/es/components/Menu/Menu.js +6 -9
- package/es/components/Menu/MenuContext.js +1 -0
- package/es/components/Menu/MenuItem.js +5 -13
- package/es/components/MenuButton/index.js +7 -2
- package/es/components/Modal/Modal.js +15 -6
- package/es/components/ModalWrapper/ModalWrapper.js +2 -0
- package/es/components/MultiSelect/FilterableMultiSelect.js +24 -5
- package/es/components/MultiSelect/MultiSelect.js +21 -5
- package/es/components/Notification/Notification.js +1 -1
- package/es/components/NumberInput/NumberInput.js +18 -7
- package/es/components/OverflowMenu/OverflowMenu.js +2 -0
- package/es/components/OverflowMenu/next/index.js +3 -2
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +2 -0
- package/es/components/PageHeader/PageHeader.d.ts +3 -3
- package/es/components/PageHeader/PageHeader.js +22 -8
- package/es/components/Pagination/Pagination.js +6 -2
- package/es/components/PaginationNav/PaginationNav.js +2 -5
- package/es/components/Popover/index.js +20 -6
- package/es/components/ProgressBar/ProgressBar.js +4 -2
- package/es/components/RadioTile/RadioTile.js +2 -2
- package/es/components/Search/Search.js +2 -2
- package/es/components/Select/Select.js +2 -3
- package/es/components/ShapeIndicator/index.js +4 -2
- package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.d.ts +4 -4
- package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.js +1 -2
- package/es/components/SkeletonText/SkeletonText.js +0 -2
- package/es/components/Slider/Slider.js +11 -16
- package/es/components/Stack/HStack.js +1 -0
- package/es/components/Stack/Stack.js +6 -9
- package/es/components/Stack/VStack.js +1 -0
- package/es/components/StructuredList/StructuredList.js +3 -0
- package/es/components/Switch/Switch.js +1 -1
- package/es/components/Tabs/Tabs.js +28 -17
- package/es/components/Tag/DismissibleTag.d.ts +5 -0
- package/es/components/Tag/DismissibleTag.js +8 -1
- package/es/components/Tag/OperationalTag.js +2 -0
- package/es/components/Tag/SelectableTag.js +2 -0
- package/es/components/Tag/Tag.js +4 -0
- package/es/components/Tag/isEllipsisActive.js +1 -0
- package/es/components/Text/Text.js +1 -0
- package/es/components/TextInput/ControlledPasswordInput.js +2 -4
- package/es/components/TextInput/PasswordInput.js +7 -2
- package/es/components/TextInput/TextInput.js +4 -2
- package/es/components/Theme/index.js +8 -3
- package/es/components/Tile/Tile.js +14 -17
- package/es/components/TimePicker/TimePicker.js +1 -0
- package/es/components/Toggle/Toggle.js +1 -1
- package/es/components/Toggletip/index.js +23 -8
- package/es/components/Tooltip/DefinitionTooltip.js +1 -0
- package/es/components/Tooltip/Tooltip.js +30 -23
- package/es/components/TreeView/TreeNode.d.ts +28 -0
- package/es/components/TreeView/TreeNode.js +19 -10
- package/es/components/TreeView/TreeView.js +7 -0
- package/es/components/UIShell/HeaderContainer.js +3 -1
- package/es/components/UIShell/HeaderGlobalAction.js +2 -2
- package/es/components/UIShell/HeaderMenu.js +3 -3
- package/es/components/UIShell/HeaderPanel.js +2 -2
- package/es/components/UIShell/Link.js +2 -0
- package/es/components/UIShell/SideNavItems.js +1 -0
- package/es/components/UIShell/SideNavMenu.js +2 -2
- package/es/components/UIShell/SideNavMenuItem.js +1 -1
- package/es/components/UIShell/SideNavSwitcher.js +1 -1
- package/es/components/UIShell/Switcher.js +2 -1
- package/es/components/UIShell/SwitcherItem.js +4 -2
- package/es/internal/FloatingMenu.js +7 -1
- package/es/internal/Selection.js +12 -3
- package/es/internal/useMergedRefs.js +1 -0
- package/es/internal/useNoInteractiveChildren.js +4 -0
- package/es/internal/useOutsideClick.js +1 -0
- package/es/internal/useOverflowItems.js +6 -0
- package/es/internal/useResizeObserver.js +4 -0
- package/es/internal/useSavedCallback.js +1 -0
- package/es/internal/warning.js +1 -0
- package/es/prop-types/isRequiredOneOf.js +4 -1
- package/es/tools/events.js +3 -1
- package/es/tools/wrapComponent.js +1 -0
- package/lib/components/AILabel/index.js +8 -6
- package/lib/components/Breadcrumb/BreadcrumbItem.js +2 -0
- package/lib/components/Button/Button.js +3 -0
- package/lib/components/ChatButton/ChatButton.js +1 -0
- package/lib/components/CheckboxGroup/CheckboxGroup.js +20 -1
- package/lib/components/ComboBox/ComboBox.js +17 -1
- package/lib/components/ComboButton/index.js +1 -0
- package/lib/components/ComposedModal/ComposedModal.js +18 -4
- package/lib/components/DataTable/DataTable.d.ts +3 -8
- package/lib/components/DataTable/DataTable.js +14 -0
- package/lib/components/DataTable/Table.js +3 -3
- package/lib/components/DataTable/TableExpandHeader.js +5 -1
- package/lib/components/DataTable/TableExpandRow.d.ts +33 -5
- package/lib/components/DataTable/TableExpandRow.js +5 -2
- package/lib/components/DataTable/TableHeader.d.ts +1 -2
- package/lib/components/DataTable/TableHeader.js +3 -2
- package/lib/components/DataTable/TableRow.d.ts +3 -6
- package/lib/components/DataTable/TableRow.js +39 -21
- package/lib/components/DataTable/TableSlugRow.js +1 -0
- package/lib/components/DataTable/TableToolbarMenu.js +3 -0
- package/lib/components/DataTable/state/sorting.d.ts +57 -14
- package/lib/components/DataTable/state/sorting.js +41 -50
- package/lib/components/DataTable/tools/sorting.js +5 -0
- package/lib/components/DatePicker/DatePicker.js +14 -3
- package/lib/components/DatePickerInput/DatePickerInput.js +6 -0
- package/lib/components/Dialog/Dialog.js +10 -2
- package/lib/components/Dropdown/Dropdown.js +16 -4
- package/lib/components/ErrorBoundary/ErrorBoundaryContext.js +1 -0
- package/lib/components/FileUploader/FileUploader.js +9 -2
- package/lib/components/FileUploader/FileUploaderButton.js +1 -1
- package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -1
- package/lib/components/FileUploader/FileUploaderItem.js +3 -0
- package/lib/components/FluidMultiSelect/FluidMultiSelect.js +2 -0
- package/lib/components/FluidNumberInput/FluidNumberInput.js +3 -2
- package/lib/components/FluidSearch/FluidSearch.js +3 -2
- package/lib/components/FluidSelect/FluidSelect.js +3 -2
- package/lib/components/FluidTextInput/FluidTextInput.js +3 -2
- package/lib/components/FluidTimePicker/FluidTimePicker.js +11 -4
- package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +3 -2
- package/lib/components/Grid/CSSGrid.js +5 -0
- package/lib/components/Grid/Column.js +3 -0
- package/lib/components/Grid/ColumnHang.js +1 -0
- package/lib/components/Grid/FlexGrid.js +1 -0
- package/lib/components/Grid/Row.js +1 -0
- package/lib/components/Heading/index.js +3 -1
- package/lib/components/IconButton/index.js +4 -2
- package/lib/components/IconIndicator/index.js +4 -2
- package/lib/components/InlineCheckbox/InlineCheckbox.js +3 -2
- package/lib/components/Layout/index.js +6 -4
- package/lib/components/LayoutDirection/LayoutDirection.js +2 -0
- package/lib/components/Link/Link.js +3 -0
- package/lib/components/ListBox/ListBoxMenuItem.js +4 -1
- package/lib/components/ListBox/next/ListBoxTrigger.js +3 -2
- package/lib/components/Menu/Menu.js +6 -9
- package/lib/components/Menu/MenuContext.js +1 -0
- package/lib/components/Menu/MenuItem.js +5 -13
- package/lib/components/MenuButton/index.js +7 -2
- package/lib/components/Modal/Modal.js +15 -6
- package/lib/components/ModalWrapper/ModalWrapper.js +2 -0
- package/lib/components/MultiSelect/FilterableMultiSelect.js +24 -5
- package/lib/components/MultiSelect/MultiSelect.js +21 -5
- package/lib/components/Notification/Notification.js +1 -1
- package/lib/components/NumberInput/NumberInput.js +17 -6
- package/lib/components/OverflowMenu/OverflowMenu.js +2 -0
- package/lib/components/OverflowMenu/next/index.js +3 -2
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +2 -0
- package/lib/components/PageHeader/PageHeader.d.ts +3 -3
- package/lib/components/PageHeader/PageHeader.js +22 -8
- package/lib/components/Pagination/Pagination.js +6 -2
- package/lib/components/PaginationNav/PaginationNav.js +2 -5
- package/lib/components/Popover/index.js +20 -6
- package/lib/components/ProgressBar/ProgressBar.js +4 -2
- package/lib/components/RadioTile/RadioTile.js +2 -2
- package/lib/components/Search/Search.js +2 -2
- package/lib/components/Select/Select.js +2 -3
- package/lib/components/ShapeIndicator/index.js +4 -2
- package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.d.ts +4 -4
- package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.js +1 -2
- package/lib/components/SkeletonText/SkeletonText.js +0 -2
- package/lib/components/Slider/Slider.js +11 -16
- package/lib/components/Stack/HStack.js +1 -0
- package/lib/components/Stack/Stack.js +6 -9
- package/lib/components/Stack/VStack.js +1 -0
- package/lib/components/StructuredList/StructuredList.js +3 -0
- package/lib/components/Switch/Switch.js +1 -1
- package/lib/components/Tabs/Tabs.js +28 -17
- package/lib/components/Tag/DismissibleTag.d.ts +5 -0
- package/lib/components/Tag/DismissibleTag.js +8 -1
- package/lib/components/Tag/OperationalTag.js +2 -0
- package/lib/components/Tag/SelectableTag.js +2 -0
- package/lib/components/Tag/Tag.js +4 -0
- package/lib/components/Tag/isEllipsisActive.js +1 -0
- package/lib/components/Text/Text.js +1 -0
- package/lib/components/TextInput/ControlledPasswordInput.js +2 -4
- package/lib/components/TextInput/PasswordInput.js +7 -2
- package/lib/components/TextInput/TextInput.js +4 -2
- package/lib/components/Theme/index.js +8 -3
- package/lib/components/Tile/Tile.js +14 -17
- package/lib/components/TimePicker/TimePicker.js +1 -0
- package/lib/components/Toggle/Toggle.js +1 -1
- package/lib/components/Toggletip/index.js +22 -7
- package/lib/components/Tooltip/DefinitionTooltip.js +1 -0
- package/lib/components/Tooltip/Tooltip.js +30 -23
- package/lib/components/TreeView/TreeNode.d.ts +28 -0
- package/lib/components/TreeView/TreeNode.js +19 -10
- package/lib/components/TreeView/TreeView.js +7 -0
- package/lib/components/UIShell/HeaderContainer.js +3 -1
- package/lib/components/UIShell/HeaderGlobalAction.js +2 -2
- package/lib/components/UIShell/HeaderMenu.js +3 -3
- package/lib/components/UIShell/HeaderPanel.js +2 -2
- package/lib/components/UIShell/Link.js +2 -0
- package/lib/components/UIShell/SideNavItems.js +1 -0
- package/lib/components/UIShell/SideNavMenu.js +2 -2
- package/lib/components/UIShell/SideNavMenuItem.js +1 -1
- package/lib/components/UIShell/SideNavSwitcher.js +1 -1
- package/lib/components/UIShell/Switcher.js +2 -1
- package/lib/components/UIShell/SwitcherItem.js +4 -2
- package/lib/internal/FloatingMenu.js +7 -1
- package/lib/internal/Selection.js +12 -3
- package/lib/internal/useMergedRefs.js +1 -0
- package/lib/internal/useNoInteractiveChildren.js +4 -0
- package/lib/internal/useOutsideClick.js +1 -0
- package/lib/internal/useOverflowItems.js +6 -0
- package/lib/internal/useResizeObserver.js +4 -0
- package/lib/internal/useSavedCallback.js +1 -0
- package/lib/internal/warning.js +1 -0
- package/lib/prop-types/isRequiredOneOf.js +4 -1
- package/lib/tools/events.js +3 -1
- package/lib/tools/wrapComponent.js +1 -0
- package/package.json +11 -11
- package/telemetry.yml +14 -0
|
@@ -30,7 +30,6 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu({
|
|
|
30
30
|
containerRef,
|
|
31
31
|
label,
|
|
32
32
|
menuAlignment,
|
|
33
|
-
mode,
|
|
34
33
|
onClose,
|
|
35
34
|
onOpen,
|
|
36
35
|
open,
|
|
@@ -120,6 +119,8 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu({
|
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
function focusItem(e) {
|
|
122
|
+
const validItems = focusableItems?.filter(item => item?.ref?.current);
|
|
123
|
+
if (!validItems?.length) return;
|
|
123
124
|
const currentItem = focusableItems.findIndex(item => item.ref?.current?.contains(document.activeElement));
|
|
124
125
|
let indexToFocus = currentItem;
|
|
125
126
|
|
|
@@ -136,14 +137,14 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu({
|
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
if (indexToFocus < 0) {
|
|
139
|
-
indexToFocus =
|
|
140
|
+
indexToFocus = validItems.length - 1;
|
|
140
141
|
}
|
|
141
|
-
if (indexToFocus >=
|
|
142
|
+
if (indexToFocus >= validItems.length) {
|
|
142
143
|
indexToFocus = 0;
|
|
143
144
|
}
|
|
144
145
|
if (indexToFocus !== currentItem) {
|
|
145
|
-
const nodeToFocus =
|
|
146
|
-
nodeToFocus
|
|
146
|
+
const nodeToFocus = validItems[indexToFocus];
|
|
147
|
+
nodeToFocus?.ref?.current?.focus();
|
|
147
148
|
e?.preventDefault();
|
|
148
149
|
}
|
|
149
150
|
}
|
|
@@ -306,7 +307,6 @@ Menu.propTypes = {
|
|
|
306
307
|
/**
|
|
307
308
|
* A label describing the Menu.
|
|
308
309
|
*/
|
|
309
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
310
310
|
label: PropTypes.string,
|
|
311
311
|
/**
|
|
312
312
|
* Specify how the menu should align with the button element
|
|
@@ -342,17 +342,14 @@ Menu.propTypes = {
|
|
|
342
342
|
/**
|
|
343
343
|
* Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
|
|
344
344
|
*/
|
|
345
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
346
345
|
target: PropTypes.object,
|
|
347
346
|
/**
|
|
348
347
|
* Specify the x position of the Menu. Either pass a single number or an array with two numbers describing your activator's boundaries ([x1, x2])
|
|
349
348
|
*/
|
|
350
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
351
349
|
x: PropTypes.oneOfType([PropTypes.number, PropTypes.arrayOf(PropTypes.number)]),
|
|
352
350
|
/**
|
|
353
351
|
* Specify the y position of the Menu. Either pass a single number or an array with two numbers describing your activator's boundaries ([y1, y2])
|
|
354
352
|
*/
|
|
355
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
356
353
|
y: PropTypes.oneOfType([PropTypes.number, PropTypes.arrayOf(PropTypes.number)])
|
|
357
354
|
};
|
|
358
355
|
|
|
@@ -46,6 +46,7 @@ function menuReducer(state, action) {
|
|
|
46
46
|
const MenuContext = /*#__PURE__*/React.createContext({
|
|
47
47
|
state: menuDefaultState,
|
|
48
48
|
// 'dispatch' is populated by the root menu
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
49
50
|
dispatch: _ => {}
|
|
50
51
|
});
|
|
51
52
|
|
|
@@ -152,7 +152,7 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem({
|
|
|
152
152
|
}, [direction]);
|
|
153
153
|
React.useEffect(() => {
|
|
154
154
|
if (IconElement && !context.state.hasIcons) {
|
|
155
|
-
// @ts-
|
|
155
|
+
// @ts-expect-error - TODO: Should we be passing payload?
|
|
156
156
|
context.dispatch({
|
|
157
157
|
type: 'enableIcons'
|
|
158
158
|
});
|
|
@@ -227,17 +227,14 @@ MenuItem.propTypes = {
|
|
|
227
227
|
/**
|
|
228
228
|
* Provide an optional function to be called when the MenuItem is clicked.
|
|
229
229
|
*/
|
|
230
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
231
230
|
onClick: PropTypes.func,
|
|
232
231
|
/**
|
|
233
232
|
* A component used to render an icon.
|
|
234
233
|
*/
|
|
235
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
236
234
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
237
235
|
/**
|
|
238
236
|
* Provide a shortcut for the action of this MenuItem. Note that the component will only render it as a hint but not actually register the shortcut.
|
|
239
237
|
*/
|
|
240
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
241
238
|
shortcut: PropTypes.string
|
|
242
239
|
};
|
|
243
240
|
const MenuItemSelectable = /*#__PURE__*/React.forwardRef(function MenuItemSelectable({
|
|
@@ -255,12 +252,12 @@ const MenuItemSelectable = /*#__PURE__*/React.forwardRef(function MenuItemSelect
|
|
|
255
252
|
onChange,
|
|
256
253
|
defaultValue: defaultSelected ?? false
|
|
257
254
|
});
|
|
258
|
-
function handleClick(
|
|
255
|
+
function handleClick() {
|
|
259
256
|
setChecked(!checked);
|
|
260
257
|
}
|
|
261
258
|
React.useEffect(() => {
|
|
262
259
|
if (!context.state.hasSelectableItems) {
|
|
263
|
-
// @ts-
|
|
260
|
+
// @ts-expect-error - TODO: Should we be passing payload?
|
|
264
261
|
context.dispatch({
|
|
265
262
|
type: 'enableSelectableItems'
|
|
266
263
|
});
|
|
@@ -284,7 +281,6 @@ MenuItemSelectable.propTypes = {
|
|
|
284
281
|
/**
|
|
285
282
|
* Specify whether the option should be selected by default.
|
|
286
283
|
*/
|
|
287
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
288
284
|
defaultSelected: PropTypes.bool,
|
|
289
285
|
/**
|
|
290
286
|
* A required label titling this option.
|
|
@@ -293,12 +289,10 @@ MenuItemSelectable.propTypes = {
|
|
|
293
289
|
/**
|
|
294
290
|
* Provide an optional function to be called when the selection state changes.
|
|
295
291
|
*/
|
|
296
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
297
292
|
onChange: PropTypes.func,
|
|
298
293
|
/**
|
|
299
294
|
* Pass a bool to props.selected to control the state of this option.
|
|
300
295
|
*/
|
|
301
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
302
296
|
selected: PropTypes.bool
|
|
303
297
|
};
|
|
304
298
|
const MenuItemGroup = /*#__PURE__*/React.forwardRef(function MenuItemGroup({
|
|
@@ -350,12 +344,13 @@ const MenuItemRadioGroup = /*#__PURE__*/React.forwardRef(function MenuItemRadioG
|
|
|
350
344
|
onChange,
|
|
351
345
|
defaultValue: defaultSelectedItem ?? {}
|
|
352
346
|
});
|
|
347
|
+
//eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
353
348
|
function handleClick(item, e) {
|
|
354
349
|
setSelection(item);
|
|
355
350
|
}
|
|
356
351
|
React.useEffect(() => {
|
|
357
352
|
if (!context.state.hasSelectableItems) {
|
|
358
|
-
// @ts-
|
|
353
|
+
// @ts-expect-error - TODO: Should we be passing payload?
|
|
359
354
|
context.dispatch({
|
|
360
355
|
type: 'enableSelectableItems'
|
|
361
356
|
});
|
|
@@ -391,12 +386,10 @@ MenuItemRadioGroup.propTypes = {
|
|
|
391
386
|
/**
|
|
392
387
|
* Provide a function to convert an item to the string that will be rendered. Defaults to item.toString().
|
|
393
388
|
*/
|
|
394
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
395
389
|
itemToString: PropTypes.func,
|
|
396
390
|
/**
|
|
397
391
|
* Provide the options for this radio group. Can be of any type, as long as you provide an appropriate props.itemToString function.
|
|
398
392
|
*/
|
|
399
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
400
393
|
items: PropTypes.array,
|
|
401
394
|
/**
|
|
402
395
|
* A required label titling this radio group.
|
|
@@ -405,7 +398,6 @@ MenuItemRadioGroup.propTypes = {
|
|
|
405
398
|
/**
|
|
406
399
|
* Provide an optional function to be called when the selection changes.
|
|
407
400
|
*/
|
|
408
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
409
401
|
onChange: PropTypes.func,
|
|
410
402
|
/**
|
|
411
403
|
* Provide props.selectedItem to control the state of this radio group. Must match the type of props.items.
|
|
@@ -25,7 +25,8 @@ var mergeRefs = require('../../tools/mergeRefs.js');
|
|
|
25
25
|
|
|
26
26
|
const validButtonKinds = ['primary', 'tertiary', 'ghost'];
|
|
27
27
|
const defaultButtonKind = 'primary';
|
|
28
|
-
|
|
28
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
29
|
+
const MenuButton = /*#__PURE__*/React.forwardRef(({
|
|
29
30
|
children,
|
|
30
31
|
className,
|
|
31
32
|
disabled,
|
|
@@ -36,13 +37,14 @@ const MenuButton = /*#__PURE__*/React.forwardRef(function MenuButton({
|
|
|
36
37
|
tabIndex = 0,
|
|
37
38
|
menuTarget,
|
|
38
39
|
...rest
|
|
39
|
-
}, forwardRef) {
|
|
40
|
+
}, forwardRef) => {
|
|
40
41
|
// feature flag utilized to separate out only the dynamic styles from @floating-ui
|
|
41
42
|
// flag is turned on when collision detection (ie. flip, hide) logic is not desired
|
|
42
43
|
const enableOnlyFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles');
|
|
43
44
|
const id = useId.useId('MenuButton');
|
|
44
45
|
const prefix = usePrefix.usePrefix();
|
|
45
46
|
const triggerRef = React.useRef(null);
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
46
48
|
let middlewares = [];
|
|
47
49
|
if (!enableOnlyFloatingStyles) {
|
|
48
50
|
middlewares = [react.flip({
|
|
@@ -161,6 +163,7 @@ MenuButton.propTypes = {
|
|
|
161
163
|
/**
|
|
162
164
|
* Specify the type of button to be used as the base for the trigger button.
|
|
163
165
|
*/
|
|
166
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
164
167
|
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
165
168
|
kind: PropTypes.oneOf(validButtonKinds),
|
|
166
169
|
/**
|
|
@@ -174,11 +177,13 @@ MenuButton.propTypes = {
|
|
|
174
177
|
/**
|
|
175
178
|
* Specify the size of the button and menu.
|
|
176
179
|
*/
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
177
181
|
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
178
182
|
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
179
183
|
/**
|
|
180
184
|
* Specify the tabIndex of the button.
|
|
181
185
|
*/
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
182
187
|
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
183
188
|
tabIndex: PropTypes.number,
|
|
184
189
|
/**
|
|
@@ -42,7 +42,7 @@ var debounce = require('../../node_modules/es-toolkit/dist/compat/function/debou
|
|
|
42
42
|
var Text = require('../Text/Text.js');
|
|
43
43
|
|
|
44
44
|
const ModalSizes = ['xs', 'sm', 'md', 'lg'];
|
|
45
|
-
const invalidOutsideClickMessage = '
|
|
45
|
+
const invalidOutsideClickMessage = '`<Modal>` prop `preventCloseOnClickOutside` should not be `false` when ' + '`passiveModal` is `false`. Transactional, non-passive Modals should ' + 'not be dissmissable by clicking outside. ' + 'See: https://carbondesignsystem.com/components/modal/usage/#transactional-modal';
|
|
46
46
|
const Modal = /*#__PURE__*/React.forwardRef(function Modal({
|
|
47
47
|
'aria-label': ariaLabelProp,
|
|
48
48
|
children,
|
|
@@ -68,7 +68,7 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal({
|
|
|
68
68
|
size,
|
|
69
69
|
hasScrollingContent = false,
|
|
70
70
|
closeButtonLabel = 'Close',
|
|
71
|
-
preventCloseOnClickOutside
|
|
71
|
+
preventCloseOnClickOutside,
|
|
72
72
|
isFullWidth,
|
|
73
73
|
launcherButtonRef,
|
|
74
74
|
loadingStatus = 'inactive',
|
|
@@ -100,9 +100,7 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal({
|
|
|
100
100
|
const focusTrapWithoutSentinels = index.useFeatureFlag('enable-experimental-focus-wrap-without-sentinels');
|
|
101
101
|
const enableDialogElement = index.useFeatureFlag('enable-dialog-element');
|
|
102
102
|
process.env.NODE_ENV !== "production" ? warning.warning(!(focusTrapWithoutSentinels && enableDialogElement), '`<Modal>` detected both `focusTrapWithoutSentinels` and ' + '`enableDialogElement` feature flags are enabled. The native dialog ' + 'element handles focus, so `enableDialogElement` must be off for ' + '`focusTrapWithoutSentinels` to have any effect.') : void 0;
|
|
103
|
-
|
|
104
|
-
console.error(invalidOutsideClickMessage);
|
|
105
|
-
}
|
|
103
|
+
process.env.NODE_ENV !== "production" ? warning.warning(!(!passiveModal && preventCloseOnClickOutside === false), invalidOutsideClickMessage) : void 0;
|
|
106
104
|
function isCloseButton(element) {
|
|
107
105
|
return !onSecondarySubmit && element === secondaryButton.current || element.classList.contains(modalCloseButtonClass);
|
|
108
106
|
}
|
|
@@ -129,7 +127,15 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal({
|
|
|
129
127
|
target
|
|
130
128
|
} = evt;
|
|
131
129
|
evt.stopPropagation();
|
|
132
|
-
|
|
130
|
+
const shouldCloseOnOutsideClick =
|
|
131
|
+
// Passive modals can close on clicks outside the modal when
|
|
132
|
+
// preventCloseOnClickOutside is undefined or explicitly set to false.
|
|
133
|
+
passiveModal && !preventCloseOnClickOutside ||
|
|
134
|
+
// Non-passive modals have to explicitly opt-in for close on outside
|
|
135
|
+
// behavior by explicitly setting preventCloseOnClickOutside to false,
|
|
136
|
+
// rather than just leaving it undefined.
|
|
137
|
+
!passiveModal && preventCloseOnClickOutside === false;
|
|
138
|
+
if (shouldCloseOnOutsideClick && target instanceof Node && !wrapFocus.elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target)) {
|
|
133
139
|
onRequestClose(evt);
|
|
134
140
|
}
|
|
135
141
|
}
|
|
@@ -171,6 +177,8 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal({
|
|
|
171
177
|
}
|
|
172
178
|
const lastContent = modalContent.children[modalContent.children.length - 1];
|
|
173
179
|
const gradientSpacing = modalContent.scrollHeight - lastContent.offsetTop - lastContent.clientHeight;
|
|
180
|
+
|
|
181
|
+
// eslint-disable-next-line prefer-const -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
174
182
|
for (let elem of modalContent.children) {
|
|
175
183
|
if (elem.contains(currentActiveNode)) {
|
|
176
184
|
const spaceBelow = modalContent.clientHeight - elem.offsetTop + modalContent.scrollTop - elem.clientHeight;
|
|
@@ -233,6 +241,7 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal({
|
|
|
233
241
|
return () => {
|
|
234
242
|
document.removeEventListener('keydown', handleEscapeKey, true);
|
|
235
243
|
};
|
|
244
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
236
245
|
}, [open]);
|
|
237
246
|
React.useEffect(() => {
|
|
238
247
|
return () => {
|
|
@@ -21,6 +21,7 @@ var keys = require('../../internal/keyboard/keys.js');
|
|
|
21
21
|
var match = require('../../internal/keyboard/match.js');
|
|
22
22
|
|
|
23
23
|
let didWarnAboutDeprecation = false;
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
24
25
|
process.env.NODE_ENV !== 'production';
|
|
25
26
|
class ModalWrapper extends React.Component {
|
|
26
27
|
constructor(...args) {
|
|
@@ -57,6 +58,7 @@ class ModalWrapper extends React.Component {
|
|
|
57
58
|
handleSubmit?.(evt);
|
|
58
59
|
});
|
|
59
60
|
}
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
60
62
|
if(isDev) {
|
|
61
63
|
process.env.NODE_ENV !== "production" ? warning.warning(didWarnAboutDeprecation, '`<ModalWrapper>` has been deprecated in favor of `<ComposedModal/>` and will be removed in the next major version, `@carbon/react@v2.x`') : void 0;
|
|
62
64
|
didWarnAboutDeprecation = true;
|
|
@@ -113,6 +113,7 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
113
113
|
isFluid
|
|
114
114
|
} = React.useContext(FormContext.FormContext);
|
|
115
115
|
const isFirstRender = React.useRef(true);
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
116
117
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
117
118
|
const [isOpen, setIsOpen] = React.useState(!!open);
|
|
118
119
|
const [prevOpen, setPrevOpen] = React.useState(!!open);
|
|
@@ -123,7 +124,10 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
123
124
|
itemToString: itemToString$1,
|
|
124
125
|
inputValue
|
|
125
126
|
}), [items, inputValue, itemToString$1, filterItems]);
|
|
126
|
-
const nonSelectAllItems = React.useMemo(
|
|
127
|
+
const nonSelectAllItems = React.useMemo(
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
129
|
+
() => filteredItems.filter(item => !item.isSelectAll), [filteredItems]);
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
127
131
|
const selectAll = filteredItems.some(item => item.isSelectAll);
|
|
128
132
|
const {
|
|
129
133
|
selectedItems: controlledSelectedItems,
|
|
@@ -139,7 +143,9 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
139
143
|
filteredItems
|
|
140
144
|
});
|
|
141
145
|
const selectAllStatus = React.useMemo(() => {
|
|
142
|
-
const selectable = nonSelectAllItems.filter(
|
|
146
|
+
const selectable = nonSelectAllItems.filter(
|
|
147
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
148
|
+
item => !item.disabled);
|
|
143
149
|
const nonSelectedCount = selectable.filter(item => !controlledSelectedItems.some(sel => isEqual(sel, item))).length;
|
|
144
150
|
const totalCount = selectable.length;
|
|
145
151
|
return {
|
|
@@ -148,6 +154,7 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
148
154
|
};
|
|
149
155
|
}, [controlledSelectedItems, nonSelectAllItems]);
|
|
150
156
|
const handleSelectAllClick = React.useCallback(() => {
|
|
157
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
151
158
|
const selectable = nonSelectAllItems.filter(i => !i.disabled);
|
|
152
159
|
const {
|
|
153
160
|
checked,
|
|
@@ -164,6 +171,7 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
164
171
|
const toSelect = selectable.filter(e => !controlledSelectedItems.some(sel => isEqual(sel, e)));
|
|
165
172
|
toggleAll([...controlledSelectedItems, ...toSelect]);
|
|
166
173
|
}
|
|
174
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
167
175
|
}, [nonSelectAllItems, selectAllStatus, controlledSelectedItems, toggleAll]);
|
|
168
176
|
const {
|
|
169
177
|
refs,
|
|
@@ -214,11 +222,14 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
214
222
|
|
|
215
223
|
// memoize sorted items to reduce unnecessary expensive sort on rerender
|
|
216
224
|
const sortedItems = React.useMemo(() => {
|
|
217
|
-
// eslint-disable-next-line @typescript-eslint/no-
|
|
225
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
218
226
|
const selectAllItem = items.find(item => item.isSelectAll);
|
|
219
|
-
const selectableRealItems = nonSelectAllItems.filter(
|
|
227
|
+
const selectableRealItems = nonSelectAllItems.filter(
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
229
|
+
item => !item.disabled);
|
|
220
230
|
|
|
221
231
|
// Sort only non-select-all items, select-all item must stay at the top
|
|
232
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
222
233
|
const sortedReal = sortItems(nonSelectAllItems, {
|
|
223
234
|
selectedItems: {
|
|
224
235
|
top: controlledSelectedItems,
|
|
@@ -235,6 +246,7 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
235
246
|
return [selectAllItem, ...sortedReal];
|
|
236
247
|
}
|
|
237
248
|
return sortedReal;
|
|
249
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
238
250
|
}, [items, inputValue, controlledSelectedItems, topItems, selectionFeedback, itemToString$1, compareItems, locale, sortItems, nonSelectAllItems]);
|
|
239
251
|
const inline = type === 'inline';
|
|
240
252
|
const showWarning = !invalid && warn;
|
|
@@ -318,6 +330,7 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
318
330
|
return () => {
|
|
319
331
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
320
332
|
};
|
|
333
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
321
334
|
}, [isOpen, inputFocused]);
|
|
322
335
|
const {
|
|
323
336
|
getToggleButtonProps,
|
|
@@ -340,7 +353,9 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
340
353
|
inputId,
|
|
341
354
|
inputValue,
|
|
342
355
|
stateReducer,
|
|
356
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
343
357
|
isItemDisabled(item, _index) {
|
|
358
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
344
359
|
return item?.disabled;
|
|
345
360
|
}
|
|
346
361
|
});
|
|
@@ -511,7 +526,9 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
511
526
|
}) : null;
|
|
512
527
|
|
|
513
528
|
// exclude the select-all item from the count
|
|
514
|
-
const selectedItemsLength = controlledSelectedItems.filter(
|
|
529
|
+
const selectedItemsLength = controlledSelectedItems.filter(
|
|
530
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
531
|
+
item => !item.isSelectAll).length;
|
|
515
532
|
const className = cx(`${prefix}--multi-select`, `${prefix}--combo-box`, `${prefix}--multi-select--filterable`, {
|
|
516
533
|
[`${prefix}--multi-select--invalid`]: invalid,
|
|
517
534
|
[`${prefix}--multi-select--invalid--focused`]: invalid && inputFocused,
|
|
@@ -692,6 +709,7 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
692
709
|
}, normalizedDecorator) : '', /*#__PURE__*/React.createElement(index$1.default.Menu, menuProps, isOpen ? sortedItems.map((item, index) => {
|
|
693
710
|
let isChecked;
|
|
694
711
|
let isIndeterminate = false;
|
|
712
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
695
713
|
if (item.isSelectAll) {
|
|
696
714
|
isChecked = selectAllStatus.checked;
|
|
697
715
|
isIndeterminate = selectAllStatus.indeterminate;
|
|
@@ -789,6 +807,7 @@ FilterableMultiSelect.propTypes = {
|
|
|
789
807
|
* change, and in some cases they can not be shimmed by Carbon to shield you
|
|
790
808
|
* from potentially breaking changes.
|
|
791
809
|
*/
|
|
810
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
792
811
|
// @ts-ignore
|
|
793
812
|
downshiftProps: PropTypes.shape(Downshift.propTypes),
|
|
794
813
|
/**
|
|
@@ -113,12 +113,15 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
113
113
|
return true; // Return true if item is not an object with undefined values
|
|
114
114
|
});
|
|
115
115
|
}, [items]);
|
|
116
|
+
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
116
118
|
const selectAll = filteredItems.some(item => item.isSelectAll);
|
|
117
119
|
const prefix = usePrefix.usePrefix();
|
|
118
120
|
const {
|
|
119
121
|
isFluid
|
|
120
122
|
} = React.useContext(FormContext.FormContext);
|
|
121
123
|
const multiSelectInstanceId = useId.useId();
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
122
125
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
123
126
|
const [inputFocused, setInputFocused] = React.useState(false);
|
|
124
127
|
const [isOpen, setIsOpen] = React.useState(open || false);
|
|
@@ -187,13 +190,15 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
187
190
|
stateReducer,
|
|
188
191
|
isOpen,
|
|
189
192
|
itemToString: filteredItems => {
|
|
190
|
-
return Array.isArray(filteredItems) && filteredItems.map(
|
|
193
|
+
return Array.isArray(filteredItems) && filteredItems.map(item => {
|
|
191
194
|
return itemToString(item);
|
|
192
195
|
}).join(', ') || '';
|
|
193
196
|
},
|
|
194
197
|
selectedItem: controlledSelectedItems,
|
|
195
198
|
items: filteredItems,
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
196
200
|
isItemDisabled(item, _index) {
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
197
202
|
return item?.disabled;
|
|
198
203
|
},
|
|
199
204
|
...downshiftProps
|
|
@@ -388,6 +393,7 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
388
393
|
[`${prefix}--list-box__field--wrapper--input-focused`]: inputFocused
|
|
389
394
|
});
|
|
390
395
|
const handleFocus = evt => {
|
|
396
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
391
397
|
evt.target.classList.contains(`${prefix}--tag__close-icon`) ? setIsFocused(false) : setIsFocused(evt.type === 'focus' ? true : false);
|
|
392
398
|
};
|
|
393
399
|
const readOnlyEventHandlers = readOnly ? {
|
|
@@ -415,7 +421,9 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
415
421
|
size: 'mini'
|
|
416
422
|
}) : null;
|
|
417
423
|
const itemsSelectedText = selectedItems.length > 0 && selectedItems.map(item => item?.text);
|
|
418
|
-
const selectedItemsLength = selectAll ?
|
|
424
|
+
const selectedItemsLength = selectAll ?
|
|
425
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
426
|
+
selectedItems.filter(item => !item.isSelectAll).length : selectedItems.length;
|
|
419
427
|
|
|
420
428
|
// Memoize the value of getMenuProps to avoid an infinite loop
|
|
421
429
|
const menuProps = React.useMemo(() => getMenuProps({
|
|
@@ -434,7 +442,9 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
434
442
|
nonSelectAllSelectedCount,
|
|
435
443
|
totalSelectableCount
|
|
436
444
|
};
|
|
437
|
-
},
|
|
445
|
+
},
|
|
446
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
447
|
+
[selectedItems, filteredItems]);
|
|
438
448
|
return /*#__PURE__*/React.createElement("div", {
|
|
439
449
|
className: wrapperClasses
|
|
440
450
|
}, /*#__PURE__*/React.createElement("label", _rollupPluginBabelHelpers.extends({
|
|
@@ -486,14 +496,20 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
486
496
|
translateWithId: translateWithId
|
|
487
497
|
})), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React.createElement("div", {
|
|
488
498
|
className: `${prefix}--list-box__inner-wrapper--decorator`
|
|
489
|
-
}, normalizedDecorator) : ''), /*#__PURE__*/React.createElement(index$2.default.Menu, menuProps, isOpen &&
|
|
499
|
+
}, normalizedDecorator) : ''), /*#__PURE__*/React.createElement(index$2.default.Menu, menuProps, isOpen &&
|
|
500
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
501
|
+
sortItems(filteredItems, sortOptions).map((item, index) => {
|
|
490
502
|
const {
|
|
491
503
|
hasIndividualSelections,
|
|
492
504
|
nonSelectAllSelectedCount,
|
|
493
505
|
totalSelectableCount
|
|
494
506
|
} = getSelectionStats(selectedItems, filteredItems);
|
|
507
|
+
|
|
508
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
495
509
|
const isChecked = item.isSelectAll ? nonSelectAllSelectedCount === totalSelectableCount && totalSelectableCount > 0 : selectedItems.some(selected => isEqual(selected, item));
|
|
496
|
-
const isIndeterminate =
|
|
510
|
+
const isIndeterminate =
|
|
511
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
512
|
+
item.isSelectAll && hasIndividualSelections && nonSelectAllSelectedCount < totalSelectableCount;
|
|
497
513
|
const itemProps = getItemProps({
|
|
498
514
|
item,
|
|
499
515
|
// we don't want Downshift to set aria-selected for us
|
|
@@ -110,7 +110,6 @@ function NotificationButton({
|
|
|
110
110
|
[`${prefix}--${notificationType}-notification__close-icon`]: notificationType
|
|
111
111
|
});
|
|
112
112
|
return /*#__PURE__*/React.createElement("button", _rollupPluginBabelHelpers.extends({}, rest, {
|
|
113
|
-
// eslint-disable-next-line react/button-has-type
|
|
114
113
|
type: type,
|
|
115
114
|
"aria-label": deprecatedAriaLabel || ariaLabel,
|
|
116
115
|
title: deprecatedAriaLabel || ariaLabel,
|
|
@@ -810,6 +809,7 @@ Callout.propTypes = {
|
|
|
810
809
|
/**
|
|
811
810
|
* @deprecated Use `CalloutProps` instead.
|
|
812
811
|
*/
|
|
812
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
813
813
|
|
|
814
814
|
let didWarnAboutDeprecation = false;
|
|
815
815
|
const StaticNotification = props => {
|
|
@@ -43,7 +43,8 @@ const defaultTranslations = {
|
|
|
43
43
|
[translationIds['increment.number']]: 'Increment number',
|
|
44
44
|
[translationIds['decrement.number']]: 'Decrement number'
|
|
45
45
|
};
|
|
46
|
-
|
|
46
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
47
|
+
const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
47
48
|
const {
|
|
48
49
|
allowEmpty = false,
|
|
49
50
|
className: customClassName,
|
|
@@ -103,6 +104,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
|
|
|
103
104
|
}
|
|
104
105
|
return 0;
|
|
105
106
|
});
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
106
108
|
const [prevControlledValue, setPrevControlledValue] = React.useState(controlledValue);
|
|
107
109
|
const numberParser = React.useMemo(() => new utilities.NumberParser(locale, formatOptions), [locale, formatOptions]);
|
|
108
110
|
/**
|
|
@@ -175,11 +177,16 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
|
|
|
175
177
|
[`${prefix}--number__invalid`]: normalizedProps.invalid || normalizedProps.warn,
|
|
176
178
|
[`${prefix}--number__invalid--warning`]: normalizedProps.warn
|
|
177
179
|
});
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
React.useEffect(() => {
|
|
181
|
+
if (type === 'number' && controlledValue !== undefined) {
|
|
182
|
+
if (allowEmpty && controlledValue === '') {
|
|
183
|
+
setValue('');
|
|
184
|
+
} else {
|
|
185
|
+
setValue(controlledValue);
|
|
186
|
+
}
|
|
187
|
+
setPrevControlledValue(controlledValue);
|
|
188
|
+
}
|
|
189
|
+
}, [controlledValue, type, allowEmpty]);
|
|
183
190
|
let ariaDescribedBy = undefined;
|
|
184
191
|
if (normalizedProps.invalid) {
|
|
185
192
|
ariaDescribedBy = normalizedProps.invalidId;
|
|
@@ -230,6 +237,8 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
|
|
|
230
237
|
[`${prefix}--number-input--fluid--focus`]: isFluid && isFocused,
|
|
231
238
|
[`${prefix}--number-input--fluid--disabled`]: isFluid && disabled
|
|
232
239
|
});
|
|
240
|
+
|
|
241
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
233
242
|
const Icon = normalizedProps.icon;
|
|
234
243
|
const getDecimalPlaces = num => {
|
|
235
244
|
const parts = num.toString().split('.');
|
|
@@ -339,7 +348,9 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
|
|
|
339
348
|
onKeyUp: onKeyUp,
|
|
340
349
|
onKeyDown: e => {
|
|
341
350
|
if (type === 'text') {
|
|
351
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
342
352
|
match.match(e, keys.ArrowUp) && handleStep(e, 'up');
|
|
353
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
343
354
|
match.match(e, keys.ArrowDown) && handleStep(e, 'down');
|
|
344
355
|
}
|
|
345
356
|
if (rest?.onKeyDown) {
|
|
@@ -70,6 +70,7 @@ const getMenuOffset = (menuBody, direction, trigger, flip) => {
|
|
|
70
70
|
if (process.env.NODE_ENV !== 'production') {
|
|
71
71
|
!(triggerButtonPositionProp && triggerButtonPositionFactor) ? process.env.NODE_ENV !== "production" ? invariant(false, '[OverflowMenu] wrong floating menu direction: `%s`', direction) : invariant(false) : void 0;
|
|
72
72
|
}
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
73
74
|
const {
|
|
74
75
|
offsetWidth: menuWidth,
|
|
75
76
|
offsetHeight: menuHeight
|
|
@@ -92,6 +93,7 @@ const getMenuOffset = (menuBody, direction, trigger, flip) => {
|
|
|
92
93
|
};
|
|
93
94
|
}
|
|
94
95
|
};
|
|
96
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
95
97
|
const OverflowMenu = /*#__PURE__*/React.forwardRef(({
|
|
96
98
|
align,
|
|
97
99
|
['aria-label']: ariaLabel = null,
|
|
@@ -25,7 +25,8 @@ var deprecateValuesWithin = require('../../../prop-types/deprecateValuesWithin.j
|
|
|
25
25
|
var mapPopoverAlign = require('../../../tools/mapPopoverAlign.js');
|
|
26
26
|
|
|
27
27
|
const defaultSize = 'md';
|
|
28
|
-
|
|
28
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
29
|
+
const OverflowMenu = /*#__PURE__*/React.forwardRef(({
|
|
29
30
|
autoAlign = false,
|
|
30
31
|
children,
|
|
31
32
|
className,
|
|
@@ -36,7 +37,7 @@ const OverflowMenu = /*#__PURE__*/React.forwardRef(function OverflowMenu({
|
|
|
36
37
|
tooltipAlignment,
|
|
37
38
|
menuTarget,
|
|
38
39
|
...rest
|
|
39
|
-
}, forwardRef) {
|
|
40
|
+
}, forwardRef) => {
|
|
40
41
|
const enableFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
|
|
41
42
|
const {
|
|
42
43
|
refs,
|
|
@@ -93,12 +93,14 @@ const OverflowMenuItem = frFn((props, ref) => {
|
|
|
93
93
|
// ref as any: the type of `ref` is `ForwardedRef<HTMLButtonElement>` in `Button` component
|
|
94
94
|
// but `OverflowMenuItem` can be rendered as `a` tag as well, which is `HTMLAnchorElement`
|
|
95
95
|
// so we have to use `any` here
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
96
97
|
,
|
|
97
98
|
ref: ref,
|
|
98
99
|
tabIndex: -1
|
|
99
100
|
// itemText as any: itemText may be a ReactNode, but `title` only accepts string
|
|
100
101
|
// to avoid compatibility issue, we use `any` here. Consider to enforce `itemText` to be `string?`
|
|
101
102
|
// in the next major release
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
102
104
|
,
|
|
103
105
|
title: requireTitle ? title || itemText : undefined
|
|
104
106
|
}, rest), OverflowMenuItemContent));
|
|
@@ -26,7 +26,7 @@ interface PageHeaderBreadcrumbBarProps {
|
|
|
26
26
|
/**
|
|
27
27
|
* `true` by default to render BreadcrumbBar bottom border.
|
|
28
28
|
*/
|
|
29
|
-
border?:
|
|
29
|
+
border?: boolean;
|
|
30
30
|
children?: React.ReactNode;
|
|
31
31
|
className?: string;
|
|
32
32
|
/**
|
|
@@ -40,7 +40,7 @@ interface PageHeaderBreadcrumbBarProps {
|
|
|
40
40
|
/**
|
|
41
41
|
* `true` to set content actions flush against page actions
|
|
42
42
|
*/
|
|
43
|
-
contentActionsFlush?:
|
|
43
|
+
contentActionsFlush?: boolean;
|
|
44
44
|
/**
|
|
45
45
|
* The PageHeaderContent's page actions
|
|
46
46
|
*/
|
|
@@ -48,7 +48,7 @@ interface PageHeaderBreadcrumbBarProps {
|
|
|
48
48
|
/**
|
|
49
49
|
* `true` to set page actions flush with page
|
|
50
50
|
*/
|
|
51
|
-
pageActionsFlush?:
|
|
51
|
+
pageActionsFlush?: boolean;
|
|
52
52
|
}
|
|
53
53
|
declare const PageHeaderBreadcrumbBar: React.ForwardRefExoticComponent<PageHeaderBreadcrumbBarProps & React.RefAttributes<HTMLDivElement>>;
|
|
54
54
|
/**
|