@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
package/README.md
CHANGED
|
@@ -114,14 +114,14 @@ function MyComponent() {
|
|
|
114
114
|
```
|
|
115
115
|
|
|
116
116
|
For a full list of icons available, checkout our
|
|
117
|
-
[website](https://
|
|
117
|
+
[website](https://carbondesignsystem.com/elements/icons/library/).
|
|
118
118
|
|
|
119
119
|
## 📖 API Documentation
|
|
120
120
|
|
|
121
121
|
If you're looking for `@carbon/react` API documentation, check out:
|
|
122
122
|
|
|
123
123
|
- [Storybook](https://react.carbondesignsystem.com/)
|
|
124
|
-
- [Icon Library](https://
|
|
124
|
+
- [Icon Library](https://carbondesignsystem.com/elements/icons/library/)
|
|
125
125
|
|
|
126
126
|
## 🙌 Contributing
|
|
127
127
|
|
|
@@ -19,17 +19,19 @@ import { deprecate } from '../../prop-types/deprecate.js';
|
|
|
19
19
|
var _Undo;
|
|
20
20
|
const AILabelContent = /*#__PURE__*/React.forwardRef(function AILabelContent({
|
|
21
21
|
className,
|
|
22
|
-
children
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
children
|
|
23
|
+
}, ref // eslint-disable-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
24
|
+
) {
|
|
25
25
|
const prefix = usePrefix();
|
|
26
26
|
const hasAILabelActions = React.Children.toArray(children).some(child => {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
27
28
|
const item = child;
|
|
28
29
|
// TODO: Is there supposed to be a `return` here? If so, this issue would
|
|
29
30
|
// have been caught by ESLint. It's concerning that this code is 7 months
|
|
30
31
|
// old and no one has noticed any issues with it. It also makes me question
|
|
31
32
|
// whether the code is necessary.
|
|
32
33
|
// https://github.com/carbon-design-system/carbon/issues/18991
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
33
35
|
item.type === AILabelActions;
|
|
34
36
|
});
|
|
35
37
|
const aiLabelContentClasses = cx(className, {
|
|
@@ -53,9 +55,9 @@ AILabelContent.propTypes = {
|
|
|
53
55
|
};
|
|
54
56
|
const AILabelActions = /*#__PURE__*/React.forwardRef(function AILabelActions({
|
|
55
57
|
className,
|
|
56
|
-
children
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
children
|
|
59
|
+
}, ref // eslint-disable-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
60
|
+
) {
|
|
59
61
|
const prefix = usePrefix();
|
|
60
62
|
const aiLabelActionsClasses = cx(className, {
|
|
61
63
|
[`${prefix}--ai-label-actions`]: true
|
|
@@ -33,6 +33,8 @@ const BreadcrumbItem = frFn((props, ref) => {
|
|
|
33
33
|
[`${prefix}--breadcrumb-item--current`]: isCurrentPage && ariaCurrent !== 'page',
|
|
34
34
|
[customClassName]: !!customClassName
|
|
35
35
|
});
|
|
36
|
+
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
36
38
|
const child = children;
|
|
37
39
|
if (child.type && child.type.displayName !== undefined && child.type.displayName.includes('OverflowMenu')) {
|
|
38
40
|
const horizontalOverflowIcon = /*#__PURE__*/React.createElement(OverflowMenuHorizontal, {
|
|
@@ -21,6 +21,8 @@ function isIconOnlyButton(hasIconOnly, _kind) {
|
|
|
21
21
|
}
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
24
26
|
const Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
25
27
|
const {
|
|
26
28
|
as,
|
|
@@ -43,6 +45,7 @@ const Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
43
45
|
...rest
|
|
44
46
|
} = props;
|
|
45
47
|
if (ButtonImageElement && !children && !iconDescription) {
|
|
48
|
+
// eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
46
49
|
console.error('Button: renderIcon property specified without also providing an iconDescription property. ' + 'This may impact accessibility for screen reader users.');
|
|
47
50
|
}
|
|
48
51
|
const iconOnlyImage = !ButtonImageElement ? null : /*#__PURE__*/React.createElement(ButtonImageElement, null);
|
|
@@ -38,6 +38,7 @@ const ChatButton = /*#__PURE__*/React.forwardRef(function ChatButton({
|
|
|
38
38
|
} else {
|
|
39
39
|
// Check if size is valid and warn if not
|
|
40
40
|
if (size && !allowedSizes.includes(size)) {
|
|
41
|
+
// eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
41
42
|
console.error(`Invalid size "${size}" provided to ChatButton. Size must be one of: ${allowedSizes.join(', ')}. Defaulting to "lg".`);
|
|
42
43
|
size = 'lg';
|
|
43
44
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React, { cloneElement } from 'react';
|
|
10
|
+
import React, { Children, isValidElement, cloneElement } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { deprecate } from '../../prop-types/deprecate.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
@@ -15,6 +15,8 @@ import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
|
15
15
|
import { useId } from '../../internal/useId.js';
|
|
16
16
|
import { AILabel } from '../AILabel/index.js';
|
|
17
17
|
import { isComponentElement } from '../../internal/utils.js';
|
|
18
|
+
import Checkbox from '../Checkbox/Checkbox.js';
|
|
19
|
+
import '../Checkbox/Checkbox.Skeleton.js';
|
|
18
20
|
|
|
19
21
|
const CheckboxGroup = ({
|
|
20
22
|
children,
|
|
@@ -57,6 +59,23 @@ const CheckboxGroup = ({
|
|
|
57
59
|
size: 'mini',
|
|
58
60
|
kind: 'default'
|
|
59
61
|
}) : null;
|
|
62
|
+
const clonedChildren = Children.map(children, child => {
|
|
63
|
+
if (/*#__PURE__*/isValidElement(child) && child.type === Checkbox) {
|
|
64
|
+
const childProps = {
|
|
65
|
+
...(typeof invalid !== 'undefined' && typeof child.props.invalid === 'undefined' ? {
|
|
66
|
+
invalid
|
|
67
|
+
} : {}),
|
|
68
|
+
...(typeof readOnly !== 'undefined' && typeof child.props.readOnly === 'undefined' ? {
|
|
69
|
+
readOnly
|
|
70
|
+
} : {}),
|
|
71
|
+
...(typeof warn !== 'undefined' && typeof child.props.warn === 'undefined' ? {
|
|
72
|
+
warn
|
|
73
|
+
} : {})
|
|
74
|
+
};
|
|
75
|
+
return Object.keys(childProps).length ? /*#__PURE__*/cloneElement(child, childProps) : child;
|
|
76
|
+
}
|
|
77
|
+
return child;
|
|
78
|
+
});
|
|
60
79
|
return /*#__PURE__*/React.createElement("fieldset", _extends({
|
|
61
80
|
className: fieldsetClasses,
|
|
62
81
|
"data-invalid": invalid ? true : undefined,
|
|
@@ -68,7 +87,7 @@ const CheckboxGroup = ({
|
|
|
68
87
|
id: legendId || rest['aria-labelledby']
|
|
69
88
|
}, legendText, slug ? normalizedDecorator : decorator ? /*#__PURE__*/React.createElement("div", {
|
|
70
89
|
className: `${prefix}--checkbox-group-inner--decorator`
|
|
71
|
-
}, normalizedDecorator) : ''),
|
|
90
|
+
}, normalizedDecorator) : ''), clonedChildren, /*#__PURE__*/React.createElement("div", {
|
|
72
91
|
className: `${prefix}--checkbox-group__validation-msg`
|
|
73
92
|
}, !readOnly && invalid && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(WarningFilled, {
|
|
74
93
|
className: `${prefix}--checkbox__invalid-icon`
|
|
@@ -180,6 +180,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
180
180
|
refs.floating.current.style.width = parentWidth + 'px';
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
183
184
|
}, [enableFloatingStyles, floatingStyles, refs.floating, parentWidth]);
|
|
184
185
|
const [inputValue, setInputValue] = useState(getInputValue({
|
|
185
186
|
initialSelectedItem,
|
|
@@ -209,6 +210,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
209
210
|
}
|
|
210
211
|
prevInputLengthRef.current = inputValue.length;
|
|
211
212
|
}
|
|
213
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
212
214
|
}, [typeahead, inputValue, items, itemToString, autocompleteCustomFilter]);
|
|
213
215
|
const isManualClearingRef = useRef(false);
|
|
214
216
|
const [isClearing, setIsClearing] = useState(false);
|
|
@@ -249,6 +251,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
249
251
|
}
|
|
250
252
|
prevSelectedItemProp.current = selectedItemProp;
|
|
251
253
|
}
|
|
254
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
252
255
|
}, [selectedItemProp]);
|
|
253
256
|
const filterItems = (items, itemToString, inputValue) => items.filter(item => typeahead ? autocompleteCustomFilter({
|
|
254
257
|
item: itemToString(item),
|
|
@@ -263,8 +266,10 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
263
266
|
useEffect(() => {
|
|
264
267
|
if (prevInputValue.current !== inputValue) {
|
|
265
268
|
prevInputValue.current = inputValue;
|
|
269
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
266
270
|
onInputChange && onInputChange(inputValue);
|
|
267
271
|
}
|
|
272
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
268
273
|
}, [inputValue]);
|
|
269
274
|
const handleSelectionClear = () => {
|
|
270
275
|
if (textInput?.current) {
|
|
@@ -317,6 +322,8 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
317
322
|
if (state.highlightedIndex !== -1) {
|
|
318
323
|
const filteredList = filterItems(items, itemToString, inputValue);
|
|
319
324
|
const highlightedItem = filteredList[state.highlightedIndex];
|
|
325
|
+
|
|
326
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
320
327
|
if (highlightedItem && !highlightedItem.disabled) {
|
|
321
328
|
return {
|
|
322
329
|
...changes,
|
|
@@ -328,6 +335,8 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
328
335
|
const autoIndex = indexToHighlight(inputValue);
|
|
329
336
|
if (autoIndex !== -1) {
|
|
330
337
|
const matchingItem = items[autoIndex];
|
|
338
|
+
|
|
339
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
331
340
|
if (matchingItem && !matchingItem.disabled) {
|
|
332
341
|
return {
|
|
333
342
|
...changes,
|
|
@@ -480,8 +489,10 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
480
489
|
onHighlightedIndexChange: ({
|
|
481
490
|
highlightedIndex
|
|
482
491
|
}) => {
|
|
492
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion , valid-typeof , no-constant-binary-expression -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
483
493
|
if (highlightedIndex > -1 && typeof window !== undefined) {
|
|
484
494
|
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
495
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
485
496
|
const highlightedItem = itemArray[highlightedIndex];
|
|
486
497
|
if (highlightedItem) {
|
|
487
498
|
highlightedItem.scrollIntoView({
|
|
@@ -494,7 +505,9 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
494
505
|
initialSelectedItem: initialSelectedItem,
|
|
495
506
|
inputId: id,
|
|
496
507
|
stateReducer,
|
|
508
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
497
509
|
isItemDisabled(item, _index) {
|
|
510
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
498
511
|
return item?.disabled;
|
|
499
512
|
},
|
|
500
513
|
...downshiftProps,
|
|
@@ -531,6 +544,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
531
544
|
toggleMenu
|
|
532
545
|
};
|
|
533
546
|
}
|
|
547
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
534
548
|
}, [closeMenu, openMenu, reset, selectItem, setHighlightedIndex, downshiftSetInputValue, toggleMenu]);
|
|
535
549
|
const buttonProps = getToggleButtonProps({
|
|
536
550
|
disabled: disabled || readOnly,
|
|
@@ -579,7 +593,9 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
579
593
|
// Memoize the value of getMenuProps to avoid an infinite loop
|
|
580
594
|
const menuProps = useMemo(() => getMenuProps({
|
|
581
595
|
ref: enableFloatingStyles ? refs.setFloating : null
|
|
582
|
-
}),
|
|
596
|
+
}),
|
|
597
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
598
|
+
[enableFloatingStyles, deprecatedAriaLabel, ariaLabel, getMenuProps, refs.setFloating]);
|
|
583
599
|
useEffect(() => {
|
|
584
600
|
if (textInput.current) {
|
|
585
601
|
if (inputRef.current && typeaheadText) {
|
|
@@ -54,6 +54,7 @@ const ComboButton = /*#__PURE__*/React.forwardRef(function ComboButton({
|
|
|
54
54
|
const id = useId('combobutton');
|
|
55
55
|
const prefix = usePrefix();
|
|
56
56
|
const containerRef = useRef(null);
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
57
58
|
let middlewares = [];
|
|
58
59
|
if (!enableOnlyFloatingStyles) {
|
|
59
60
|
middlewares = [flip({
|
|
@@ -134,6 +134,7 @@ const ComposedModal = /*#__PURE__*/React.forwardRef(function ComposedModal({
|
|
|
134
134
|
setWasOpen(!!open);
|
|
135
135
|
toggleClass(document.body, `${prefix}--body--with-modal-open`, !!open);
|
|
136
136
|
}
|
|
137
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
137
138
|
}, [open, wasOpen, prefix]);
|
|
138
139
|
// Remove the document.body className on unmount
|
|
139
140
|
useEffect(() => {
|
|
@@ -166,9 +167,14 @@ const ComposedModal = /*#__PURE__*/React.forwardRef(function ComposedModal({
|
|
|
166
167
|
} = evt;
|
|
167
168
|
const mouseDownTarget = onMouseDownTarget.current;
|
|
168
169
|
evt.stopPropagation();
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
const shouldCloseOnOutsideClick =
|
|
171
|
+
// Passive modals can close on clicks outside the modal when
|
|
172
|
+
// preventCloseOnClickOutside is undefined or explicitly set to false.
|
|
173
|
+
isPassive && !preventCloseOnClickOutside ||
|
|
174
|
+
// Non-passive modals have to explicitly opt-in for close on outside
|
|
175
|
+
// behavior by explicitly setting preventCloseOnClickOutside to false,
|
|
176
|
+
// rather than just leaving it undefined.
|
|
177
|
+
!isPassive && preventCloseOnClickOutside === false;
|
|
172
178
|
if (shouldCloseOnOutsideClick && target instanceof Node && !elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target) && !innerModal.current.contains(mouseDownTarget)) {
|
|
173
179
|
closeModal(evt);
|
|
174
180
|
}
|
|
@@ -204,7 +210,7 @@ const ComposedModal = /*#__PURE__*/React.forwardRef(function ComposedModal({
|
|
|
204
210
|
}
|
|
205
211
|
const lastContent = modalContent.children[modalContent.children.length - 1];
|
|
206
212
|
const gradientSpacing = modalContent.scrollHeight - lastContent.offsetTop - lastContent.clientHeight;
|
|
207
|
-
for (
|
|
213
|
+
for (const elem of modalContent.children) {
|
|
208
214
|
if (elem.contains(currentActiveNode)) {
|
|
209
215
|
const spaceBelow = modalContent.clientHeight - elem.offsetTop + modalContent.scrollTop - elem.clientHeight;
|
|
210
216
|
if (spaceBelow < gradientSpacing) {
|
|
@@ -252,6 +258,12 @@ const ComposedModal = /*#__PURE__*/React.forwardRef(function ComposedModal({
|
|
|
252
258
|
return child;
|
|
253
259
|
}
|
|
254
260
|
});
|
|
261
|
+
|
|
262
|
+
// Modals without a footer are considered passive and carry limitations as
|
|
263
|
+
// outlined in the design spec.
|
|
264
|
+
const containsModalFooter = Children.toArray(childrenWithProps).some(child => isComponentElement(child, ModalFooter));
|
|
265
|
+
const isPassive = !containsModalFooter;
|
|
266
|
+
process.env.NODE_ENV !== "production" ? warning(!(!isPassive && preventCloseOnClickOutside === false), '`<ComposedModal>` prop `preventCloseOnClickOutside` should not be ' + '`false` when `<ModalFooter>` is present. Transactional, non-passive ' + 'Modals should not be dissmissable by clicking outside. ' + 'See: https://carbondesignsystem.com/components/modal/usage/#transactional-modal') : void 0;
|
|
255
267
|
useEffect(() => {
|
|
256
268
|
if (!open) return;
|
|
257
269
|
const handleEscapeKey = event => {
|
|
@@ -265,6 +277,7 @@ const ComposedModal = /*#__PURE__*/React.forwardRef(function ComposedModal({
|
|
|
265
277
|
return () => {
|
|
266
278
|
document.removeEventListener('keydown', handleEscapeKey, true);
|
|
267
279
|
};
|
|
280
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
268
281
|
}, [open]);
|
|
269
282
|
useEffect(() => {
|
|
270
283
|
if (!enableDialogElement && !open && launcherButtonRef) {
|
|
@@ -296,6 +309,7 @@ const ComposedModal = /*#__PURE__*/React.forwardRef(function ComposedModal({
|
|
|
296
309
|
focusButton(innerModal.current);
|
|
297
310
|
}
|
|
298
311
|
}
|
|
312
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
299
313
|
}, [open, selectorPrimaryFocus, isOpen]);
|
|
300
314
|
|
|
301
315
|
// AILabel is always size `sm`
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import React, { type ChangeEvent, type MouseEvent, type ReactElement, type ReactNode } from 'react';
|
|
9
|
+
import { type SortRowFn } from './state/sorting';
|
|
9
10
|
import type { DataTableSortState } from './state/sortStates';
|
|
10
11
|
import { TranslateWithId } from '../../types/common';
|
|
11
12
|
declare const translationKeys: {
|
|
@@ -181,13 +182,7 @@ export interface DataTableProps<RowType, ColTypes extends any[]> extends Transla
|
|
|
181
182
|
render?: (renderProps: DataTableRenderProps<RowType, ColTypes>) => ReactElement;
|
|
182
183
|
rows: Omit<DataTableRow<ColTypes>, 'cells'>[];
|
|
183
184
|
size?: DataTableSize;
|
|
184
|
-
sortRow?:
|
|
185
|
-
sortDirection: DataTableSortState;
|
|
186
|
-
sortStates: Record<DataTableSortState, DataTableSortState>;
|
|
187
|
-
locale: string;
|
|
188
|
-
key: string;
|
|
189
|
-
compare: (a: number | string, b: number | string, locale?: string) => number;
|
|
190
|
-
}) => number;
|
|
185
|
+
sortRow?: SortRowFn;
|
|
191
186
|
stickyHeader?: boolean;
|
|
192
187
|
useStaticWidth?: boolean;
|
|
193
188
|
useZebraStyles?: boolean;
|
|
@@ -286,7 +281,7 @@ export declare const DataTable: {
|
|
|
286
281
|
};
|
|
287
282
|
TableHead: (props: React.HTMLAttributes<"thead">) => React.ReactElement<any>;
|
|
288
283
|
TableHeader: React.ForwardRefExoticComponent<import("./TableHeader").TableHeaderProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
289
|
-
TableRow: React.ForwardRefExoticComponent<import("./TableRow").TableRowProps & React.RefAttributes<
|
|
284
|
+
TableRow: React.ForwardRefExoticComponent<import("./TableRow").TableRowProps & React.RefAttributes<HTMLTableRowElement>>;
|
|
290
285
|
TableSelectAll: {
|
|
291
286
|
({ ariaLabel: deprecatedAriaLabel, ["aria-label"]: ariaLabel, checked, id, indeterminate, name, onSelect, disabled, className, }: import("./TableSelectAll").TableSelectAllProps): import("react/jsx-runtime").JSX.Element;
|
|
292
287
|
propTypes: {
|
|
@@ -68,6 +68,17 @@ const defaultTranslations = {
|
|
|
68
68
|
[translationKeys.unselectRow]: 'Unselect row'
|
|
69
69
|
};
|
|
70
70
|
const translateWithId = id => defaultTranslations[id];
|
|
71
|
+
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
73
|
+
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
75
|
+
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
77
|
+
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
79
|
+
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
81
|
+
|
|
71
82
|
/**
|
|
72
83
|
* Data Tables are used to represent a collection of resources, displaying a
|
|
73
84
|
* subset of their fields in columns, or headers. We prioritize direct updates
|
|
@@ -78,6 +89,7 @@ const translateWithId = id => defaultTranslations[id];
|
|
|
78
89
|
* and updating the state of the single entity will cascade updates to the
|
|
79
90
|
* consumer.
|
|
80
91
|
*/
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
81
93
|
const DataTable = props => {
|
|
82
94
|
const {
|
|
83
95
|
children,
|
|
@@ -126,6 +138,7 @@ const DataTable = props => {
|
|
|
126
138
|
if (hasRowIdsChanged || hasHeadersChanged || hasRowsChanged) {
|
|
127
139
|
setState(prev => getDerivedStateFromProps(props, prev));
|
|
128
140
|
}
|
|
141
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
129
142
|
}, [headers, rows]);
|
|
130
143
|
|
|
131
144
|
/**
|
|
@@ -158,6 +171,7 @@ const DataTable = props => {
|
|
|
158
171
|
...prev,
|
|
159
172
|
...nextSortState
|
|
160
173
|
}));
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
161
175
|
onClick && handleOnHeaderClick(onClick, {
|
|
162
176
|
sortHeaderKey: header.key,
|
|
163
177
|
sortDirection: nextSortState.sortDirection
|
|
@@ -72,9 +72,11 @@ const Table = ({
|
|
|
72
72
|
[`${prefix}--data-table--visible-overflow-menu`]: !overflowMenuOnHover
|
|
73
73
|
});
|
|
74
74
|
const toggleTableBodyAlignmentClass = useCallback((alignTop = false) => {
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
75
76
|
alignTop ? tableRef.current?.classList.add(`${prefix}--data-table--top-aligned-body`) : tableRef.current?.classList.remove(`${prefix}--data-table--top-aligned-body`);
|
|
76
77
|
}, [prefix]);
|
|
77
78
|
const toggleTableHeaderAlignmentClass = useCallback((alignTop = false) => {
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
78
80
|
alignTop ? tableRef.current?.classList.add(`${prefix}--data-table--top-aligned-header`) : tableRef.current?.classList.remove(`${prefix}--data-table--top-aligned-header`);
|
|
79
81
|
}, [prefix]);
|
|
80
82
|
const setTableAlignment = useCallback(() => {
|
|
@@ -124,9 +126,7 @@ const Table = ({
|
|
|
124
126
|
setTableAlignment();
|
|
125
127
|
}, [setTableAlignment, size]);
|
|
126
128
|
const table = /*#__PURE__*/React.createElement("div", {
|
|
127
|
-
className: `${prefix}--data-table-content
|
|
128
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
129
|
-
,
|
|
129
|
+
className: `${prefix}--data-table-content`,
|
|
130
130
|
tabIndex: tabIndex ?? (isScrollable ? 0 : undefined)
|
|
131
131
|
}, /*#__PURE__*/React.createElement("table", _extends({
|
|
132
132
|
"aria-labelledby": titleId,
|
|
@@ -91,7 +91,11 @@ TableExpandHeader.propTypes = {
|
|
|
91
91
|
/**
|
|
92
92
|
* Hook for when a listener initiates a request to expand the given row
|
|
93
93
|
*/
|
|
94
|
-
onExpand: PropTypes.oneOfType([requiredIfGivenPropIsTruthy('enableExpando', PropTypes.func
|
|
94
|
+
onExpand: PropTypes.oneOfType([requiredIfGivenPropIsTruthy('enableExpando', PropTypes.func
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
96
|
+
), requiredIfGivenPropIsTruthy('enableToggle', PropTypes.func
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
98
|
+
)])
|
|
95
99
|
};
|
|
96
100
|
|
|
97
101
|
export { TableExpandHeader as default };
|
|
@@ -4,13 +4,41 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, { type MouseEventHandler, type PropsWithChildren } from 'react';
|
|
8
|
-
|
|
9
|
-
export interface
|
|
7
|
+
import React, { type HTMLAttributes, type MouseEventHandler, type PropsWithChildren } from 'react';
|
|
8
|
+
/** Props shared between `TableRow` and `TableExpandRow`. */
|
|
9
|
+
export interface TableRowExpandInteropProps {
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use `aria-label` instead.
|
|
12
|
+
*/
|
|
13
|
+
ariaLabel?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Specify the string read by a voice reader when the expand trigger is
|
|
16
|
+
* focused
|
|
17
|
+
*/
|
|
18
|
+
'aria-label'?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
|
|
21
|
+
*/
|
|
22
|
+
'aria-controls'?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Specify whether this row is expanded or not. This helps coordinate data
|
|
25
|
+
* attributes so that `TableExpandRow` and `TableExpandedRow` work together
|
|
26
|
+
*/
|
|
27
|
+
isExpanded?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Hook for when a listener initiates a request to expand the given row
|
|
30
|
+
*/
|
|
31
|
+
onExpand?: MouseEventHandler<HTMLButtonElement>;
|
|
32
|
+
/**
|
|
33
|
+
* Specify if the row is selected.
|
|
34
|
+
*/
|
|
35
|
+
isSelected?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface TableExpandRowProps extends PropsWithChildren<Omit<HTMLAttributes<HTMLTableRowElement>, 'onClick'>>, Omit<TableRowExpandInteropProps, 'aria-label' | 'onExpand'> {
|
|
10
38
|
/**
|
|
11
39
|
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
|
|
12
40
|
*/
|
|
13
|
-
|
|
41
|
+
'aria-controls'?: string;
|
|
14
42
|
/**
|
|
15
43
|
* @deprecated This prop has been deprecated and will be
|
|
16
44
|
* removed in the next major release of Carbon. Use the
|
|
@@ -21,7 +49,7 @@ export interface TableExpandRowProps extends PropsWithChildren<TableRowProps> {
|
|
|
21
49
|
* Specify the string read by a voice reader when the expand trigger is
|
|
22
50
|
* focused
|
|
23
51
|
*/
|
|
24
|
-
|
|
52
|
+
'aria-label': string;
|
|
25
53
|
/**
|
|
26
54
|
* The id of the matching th node in the table head. Addresses a11y concerns outlined here: https://www.ibm.com/able/guidelines/ci162/info_and_relationships.html and https://www.w3.org/TR/WCAG20-TECHS/H43
|
|
27
55
|
*/
|
|
@@ -17,6 +17,8 @@ import TableDecoratorRow from './TableDecoratorRow.js';
|
|
|
17
17
|
import { AILabel } from '../AILabel/index.js';
|
|
18
18
|
import { isComponentElement } from '../../internal/utils.js';
|
|
19
19
|
|
|
20
|
+
/** Props shared between `TableRow` and `TableExpandRow`. */
|
|
21
|
+
|
|
20
22
|
const TableExpandRow = /*#__PURE__*/React.forwardRef(({
|
|
21
23
|
['aria-controls']: ariaControls,
|
|
22
24
|
['aria-label']: ariaLabel,
|
|
@@ -85,13 +87,14 @@ TableExpandRow.propTypes = {
|
|
|
85
87
|
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
|
|
86
88
|
* TODO: make this required in v12
|
|
87
89
|
*/
|
|
88
|
-
|
|
90
|
+
'aria-controls': PropTypes.string,
|
|
89
91
|
/**
|
|
90
92
|
* Specify the string read by a voice reader when the expand trigger is
|
|
91
93
|
* focused
|
|
92
94
|
*/
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
93
96
|
/**@ts-ignore*/
|
|
94
|
-
|
|
97
|
+
'aria-label': PropTypes.string,
|
|
95
98
|
/**
|
|
96
99
|
* Deprecated, please use `aria-label` instead.
|
|
97
100
|
* Specify the string read by a voice reader when the expand trigger is
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React, { type HTMLAttributes, type MouseEventHandler, type ReactNode } from 'react';
|
|
8
|
-
import { sortStates } from './state/sorting';
|
|
9
8
|
import { TranslateWithId } from '../../types/common';
|
|
10
|
-
import { DataTableSortState } from './state/sortStates';
|
|
9
|
+
import { sortStates, type DataTableSortState } from './state/sortStates';
|
|
11
10
|
export type TableHeaderTranslationKey = 'carbon.table.header.icon.description';
|
|
12
11
|
export interface TableHeaderTranslationArgs {
|
|
13
12
|
header: ReactNode;
|
|
@@ -10,12 +10,11 @@ import cx from 'classnames';
|
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import React, { useRef, cloneElement } from 'react';
|
|
12
12
|
import { ArrowUp, ArrowsVertical } from '@carbon/icons-react';
|
|
13
|
-
import './state/sorting.js';
|
|
14
13
|
import { useId } from '../../internal/useId.js';
|
|
15
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
|
+
import { sortStates } from './state/sortStates.js';
|
|
16
16
|
import { AILabel } from '../AILabel/index.js';
|
|
17
17
|
import { isComponentElement } from '../../internal/utils.js';
|
|
18
|
-
import { sortStates } from './state/sortStates.js';
|
|
19
18
|
|
|
20
19
|
const defaultScope = 'col';
|
|
21
20
|
const translationKeys = {
|
|
@@ -189,6 +188,8 @@ TableHeader.propTypes = {
|
|
|
189
188
|
*/
|
|
190
189
|
translateWithId: PropTypes.func
|
|
191
190
|
};
|
|
191
|
+
|
|
192
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
192
193
|
TableHeader.translationKeys = Object.values(translationKeys);
|
|
193
194
|
TableHeader.displayName = 'TableHeader';
|
|
194
195
|
|
|
@@ -5,15 +5,12 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React, { type HTMLAttributes } from 'react';
|
|
8
|
-
|
|
8
|
+
import type { TableRowExpandInteropProps } from './TableExpandRow';
|
|
9
|
+
export interface TableRowProps extends HTMLAttributes<HTMLTableRowElement>, TableRowExpandInteropProps {
|
|
9
10
|
/**
|
|
10
11
|
* Specify an optional className to be applied to the container node
|
|
11
12
|
*/
|
|
12
13
|
className?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Specify if the row is selected
|
|
15
|
-
*/
|
|
16
|
-
isSelected?: boolean;
|
|
17
14
|
}
|
|
18
|
-
declare const TableRow: React.ForwardRefExoticComponent<TableRowProps & React.RefAttributes<
|
|
15
|
+
declare const TableRow: React.ForwardRefExoticComponent<TableRowProps & React.RefAttributes<HTMLTableRowElement>>;
|
|
19
16
|
export default TableRow;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React, { Children } from 'react';
|
|
9
|
+
import React, { forwardRef, Children } from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
@@ -15,37 +15,35 @@ import TableDecoratorRow from './TableDecoratorRow.js';
|
|
|
15
15
|
import { AILabel } from '../AILabel/index.js';
|
|
16
16
|
import { isComponentElement } from '../../internal/utils.js';
|
|
17
17
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
let rowHasAILabel;
|
|
21
|
-
if (props?.children) {
|
|
22
|
-
// TODO: Why is this loop a `map`? It's not returning anything. Ideally,
|
|
23
|
-
// it seems that it should be a `some`. Maybe I'm missing something?
|
|
24
|
-
Children.toArray(props.children).map(child => {
|
|
25
|
-
if (isComponentElement(child, TableSlugRow)) {
|
|
26
|
-
if (child.props.slug) {
|
|
27
|
-
rowHasAILabel = true;
|
|
28
|
-
}
|
|
29
|
-
} else if (isComponentElement(child, TableDecoratorRow) && isComponentElement(child.props.decorator, AILabel)) {
|
|
30
|
-
rowHasAILabel = true;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
18
|
+
const frFn = forwardRef;
|
|
19
|
+
const TableRow = frFn((props, ref) => {
|
|
34
20
|
// Remove unnecessary props if provided to this component, these are
|
|
35
21
|
// only useful in `TableExpandRow`
|
|
36
|
-
const className = cx(props.className, {
|
|
37
|
-
[`${prefix}--data-table--selected`]: props.isSelected,
|
|
38
|
-
[`${prefix}--data-table--slug-row ${prefix}--data-table--ai-label-row`]: rowHasAILabel
|
|
39
|
-
});
|
|
40
22
|
const {
|
|
41
23
|
ariaLabel,
|
|
24
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
42
25
|
'aria-label': ariaLabelAlt,
|
|
26
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
43
27
|
'aria-controls': ariaControls,
|
|
28
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
44
29
|
onExpand,
|
|
30
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
45
31
|
isExpanded,
|
|
32
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
46
33
|
isSelected,
|
|
47
34
|
...cleanProps
|
|
48
35
|
} = props;
|
|
36
|
+
const prefix = usePrefix();
|
|
37
|
+
const rowHasAILabel = Children.toArray(props.children).some(child => {
|
|
38
|
+
if (isComponentElement(child, TableSlugRow)) {
|
|
39
|
+
return !!child.props.slug;
|
|
40
|
+
}
|
|
41
|
+
return isComponentElement(child, TableDecoratorRow) && isComponentElement(child.props.decorator, AILabel);
|
|
42
|
+
});
|
|
43
|
+
const className = cx(props.className, {
|
|
44
|
+
[`${prefix}--data-table--selected`]: isSelected,
|
|
45
|
+
[`${prefix}--data-table--slug-row ${prefix}--data-table--ai-label-row`]: rowHasAILabel
|
|
46
|
+
});
|
|
49
47
|
if (className) {
|
|
50
48
|
cleanProps.className = className;
|
|
51
49
|
}
|
|
@@ -61,7 +59,27 @@ TableRow.propTypes = {
|
|
|
61
59
|
/**
|
|
62
60
|
* Specify if the row is selected
|
|
63
61
|
*/
|
|
64
|
-
isSelected: PropTypes.bool
|
|
62
|
+
isSelected: PropTypes.bool,
|
|
63
|
+
/**
|
|
64
|
+
* Non-standard alias for `aria-label`.
|
|
65
|
+
*/
|
|
66
|
+
ariaLabel: PropTypes.string,
|
|
67
|
+
/**
|
|
68
|
+
* Accessible label for the row element.
|
|
69
|
+
*/
|
|
70
|
+
'aria-label': PropTypes.string,
|
|
71
|
+
/**
|
|
72
|
+
* Associates this row with the id of the corresponding expanded row content.
|
|
73
|
+
*/
|
|
74
|
+
'aria-controls': PropTypes.string,
|
|
75
|
+
/**
|
|
76
|
+
* Handler called when the row’s expand toggle is clicked.
|
|
77
|
+
*/
|
|
78
|
+
onExpand: PropTypes.func,
|
|
79
|
+
/**
|
|
80
|
+
* Flag indicating whether the row is currently expanded.
|
|
81
|
+
*/
|
|
82
|
+
isExpanded: PropTypes.bool
|
|
65
83
|
};
|
|
66
84
|
|
|
67
85
|
export { TableRow as default };
|