@carbon/react 1.90.0-rc.0 → 1.91.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +923 -964
- 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/CodeSnippet/CodeSnippet.d.ts +1 -1
- package/es/components/CodeSnippet/CodeSnippet.js +1 -1
- package/es/components/ComboBox/ComboBox.js +18 -13
- package/es/components/ComboButton/index.js +2 -1
- package/es/components/ComposedModal/ComposedModal.js +5 -2
- package/es/components/Copy/Copy.d.ts +1 -1
- package/es/components/Copy/Copy.js +1 -1
- package/es/components/CopyButton/CopyButton.d.ts +1 -1
- package/es/components/CopyButton/CopyButton.js +1 -1
- package/es/components/DataTable/DataTable.d.ts +60 -15
- package/es/components/DataTable/DataTable.js +119 -178
- package/es/components/DataTable/Table.d.ts +2 -2
- package/es/components/DataTable/Table.js +4 -4
- package/es/components/DataTable/TableExpandHeader.d.ts +1 -1
- package/es/components/DataTable/TableExpandHeader.js +6 -2
- package/es/components/DataTable/TableExpandRow.js +1 -0
- package/es/components/DataTable/TableHeader.js +2 -0
- package/es/components/DataTable/TableRow.js +5 -0
- package/es/components/DataTable/TableSlugRow.js +1 -0
- package/es/components/DataTable/TableToolbarMenu.js +3 -0
- package/es/components/DataTable/state/sorting.d.ts +3 -1
- package/es/components/DataTable/state/sorting.js +2 -0
- package/es/components/DataTable/tools/sorting.js +1 -0
- package/es/components/DatePicker/DatePicker.d.ts +0 -12
- package/es/components/DatePicker/DatePicker.js +17 -6
- package/es/components/DatePicker/plugins/rangePlugin.d.ts +19 -2
- package/es/components/DatePicker/plugins/rangePlugin.js +18 -14
- package/es/components/DatePickerInput/DatePickerInput.js +6 -0
- package/es/components/Dialog/Dialog.js +10 -2
- package/es/components/Dropdown/Dropdown.js +17 -16
- package/es/components/ErrorBoundary/ErrorBoundaryContext.js +1 -0
- package/es/components/FeatureFlags/index.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 +5 -3
- 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.d.ts +1 -1
- package/es/components/Menu/MenuItem.js +10 -18
- package/es/components/MenuButton/index.js +7 -2
- package/es/components/Modal/Modal.js +4 -1
- package/es/components/ModalWrapper/ModalWrapper.js +2 -0
- package/es/components/MultiSelect/FilterableMultiSelect.js +25 -6
- package/es/components/MultiSelect/MultiSelect.js +22 -17
- package/es/components/Notification/Notification.d.ts +6 -6
- package/es/components/Notification/Notification.js +7 -7
- package/es/components/NumberInput/NumberInput.js +7 -1
- package/es/components/OverflowMenu/OverflowMenu.js +3 -1
- package/es/components/OverflowMenu/next/index.js +4 -3
- 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 +15 -5
- package/es/components/ProgressBar/ProgressBar.js +4 -2
- package/es/components/RadioTile/RadioTile.js +2 -2
- package/es/components/Search/Search.d.ts +4 -2
- package/es/components/Search/Search.js +7 -6
- 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.d.ts +144 -188
- package/es/components/Slider/Slider.js +798 -726
- package/es/components/Slider/index.d.ts +2 -2
- 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.d.ts +4 -0
- package/es/components/Tabs/Tabs.js +28 -17
- package/es/components/Tag/DismissibleTag.js +2 -0
- 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/TextArea/TextArea.js +13 -6
- package/es/components/TextInput/ControlledPasswordInput.js +4 -6
- package/es/components/TextInput/PasswordInput.js +9 -4
- package/es/components/TextInput/TextInput.js +6 -4
- package/es/components/TextInput/util.d.ts +17 -5
- package/es/components/TextInput/util.js +2 -7
- 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 +4 -0
- package/es/components/Tooltip/DefinitionTooltip.js +1 -0
- package/es/components/Tooltip/Tooltip.js +30 -23
- package/es/components/TreeView/TreeNode.js +13 -5
- 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.d.ts +1 -1
- 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/index.d.ts +12 -13
- package/es/index.js +25 -24
- package/es/internal/FloatingMenu.js +7 -1
- package/es/internal/Selection.js +12 -3
- package/es/internal/defaultItemToString.d.ts +7 -0
- package/es/internal/defaultItemToString.js +17 -0
- package/es/internal/index.d.ts +1 -0
- 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/deprecateValuesWithin.d.ts +8 -1
- package/es/prop-types/deprecateValuesWithin.js +6 -6
- package/es/prop-types/isRequiredOneOf.js +4 -1
- package/es/prop-types/requiredIfGivenPropIsTruthy.d.ts +8 -7
- package/es/prop-types/requiredIfGivenPropIsTruthy.js +10 -10
- 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/CodeSnippet/CodeSnippet.d.ts +1 -1
- package/lib/components/CodeSnippet/CodeSnippet.js +1 -1
- package/lib/components/ComboBox/ComboBox.js +20 -15
- package/lib/components/ComboButton/index.js +2 -1
- package/lib/components/ComposedModal/ComposedModal.js +5 -2
- package/lib/components/Copy/Copy.d.ts +1 -1
- package/lib/components/Copy/Copy.js +1 -1
- package/lib/components/CopyButton/CopyButton.d.ts +1 -1
- package/lib/components/CopyButton/CopyButton.js +1 -1
- package/lib/components/DataTable/DataTable.d.ts +60 -15
- package/lib/components/DataTable/DataTable.js +119 -178
- package/lib/components/DataTable/Table.d.ts +2 -2
- package/lib/components/DataTable/Table.js +4 -4
- package/lib/components/DataTable/TableExpandHeader.d.ts +1 -1
- package/lib/components/DataTable/TableExpandHeader.js +6 -2
- package/lib/components/DataTable/TableExpandRow.js +1 -0
- package/lib/components/DataTable/TableHeader.js +2 -0
- package/lib/components/DataTable/TableRow.js +5 -0
- package/lib/components/DataTable/TableSlugRow.js +1 -0
- package/lib/components/DataTable/TableToolbarMenu.js +3 -0
- package/lib/components/DataTable/state/sorting.d.ts +3 -1
- package/lib/components/DataTable/state/sorting.js +2 -0
- package/lib/components/DataTable/tools/sorting.js +1 -0
- package/lib/components/DatePicker/DatePicker.d.ts +0 -12
- package/lib/components/DatePicker/DatePicker.js +16 -5
- package/lib/components/DatePicker/plugins/rangePlugin.d.ts +19 -2
- package/lib/components/DatePicker/plugins/rangePlugin.js +18 -16
- package/lib/components/DatePickerInput/DatePickerInput.js +6 -0
- package/lib/components/Dialog/Dialog.js +10 -2
- package/lib/components/Dropdown/Dropdown.js +19 -18
- package/lib/components/ErrorBoundary/ErrorBoundaryContext.js +1 -0
- package/lib/components/FeatureFlags/index.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 +5 -3
- 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.d.ts +1 -1
- package/lib/components/Menu/MenuItem.js +11 -19
- package/lib/components/MenuButton/index.js +7 -2
- package/lib/components/Modal/Modal.js +4 -1
- package/lib/components/ModalWrapper/ModalWrapper.js +2 -0
- package/lib/components/MultiSelect/FilterableMultiSelect.js +32 -13
- package/lib/components/MultiSelect/MultiSelect.js +23 -18
- package/lib/components/Notification/Notification.d.ts +6 -6
- package/lib/components/Notification/Notification.js +7 -7
- package/lib/components/NumberInput/NumberInput.js +7 -1
- package/lib/components/OverflowMenu/OverflowMenu.js +3 -1
- package/lib/components/OverflowMenu/next/index.js +4 -3
- 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 +15 -5
- package/lib/components/ProgressBar/ProgressBar.js +4 -2
- package/lib/components/RadioTile/RadioTile.js +2 -2
- package/lib/components/Search/Search.d.ts +4 -2
- package/lib/components/Search/Search.js +7 -6
- 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.d.ts +144 -188
- package/lib/components/Slider/Slider.js +795 -725
- package/lib/components/Slider/index.d.ts +2 -2
- 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.d.ts +4 -0
- package/lib/components/Tabs/Tabs.js +28 -17
- package/lib/components/Tag/DismissibleTag.js +2 -0
- 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/TextArea/TextArea.js +13 -6
- package/lib/components/TextInput/ControlledPasswordInput.js +3 -5
- package/lib/components/TextInput/PasswordInput.js +8 -3
- package/lib/components/TextInput/TextInput.js +5 -3
- package/lib/components/TextInput/util.d.ts +17 -5
- package/lib/components/TextInput/util.js +2 -7
- 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 +4 -0
- package/lib/components/Tooltip/DefinitionTooltip.js +1 -0
- package/lib/components/Tooltip/Tooltip.js +30 -23
- package/lib/components/TreeView/TreeNode.js +13 -5
- 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.d.ts +1 -1
- 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/index.d.ts +12 -13
- package/lib/index.js +51 -28
- package/lib/internal/FloatingMenu.js +7 -1
- package/lib/internal/Selection.js +12 -3
- package/lib/internal/defaultItemToString.d.ts +7 -0
- package/lib/internal/defaultItemToString.js +19 -0
- package/lib/internal/index.d.ts +1 -0
- 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/deprecateValuesWithin.d.ts +8 -1
- package/lib/prop-types/deprecateValuesWithin.js +6 -8
- package/lib/prop-types/isRequiredOneOf.js +4 -1
- package/lib/prop-types/requiredIfGivenPropIsTruthy.d.ts +8 -7
- package/lib/prop-types/requiredIfGivenPropIsTruthy.js +10 -12
- package/lib/tools/events.js +3 -1
- package/lib/tools/wrapComponent.js +1 -0
- package/package.json +10 -9
- package/es/components/MultiSelect/tools/itemToString.d.ts +0 -1
- package/es/components/MultiSelect/tools/itemToString.js +0 -21
- package/es/components/Slider/index.js +0 -14
- package/es/internal/createClassWrapper.js +0 -23
- package/lib/components/MultiSelect/tools/itemToString.d.ts +0 -1
- package/lib/components/MultiSelect/tools/itemToString.js +0 -23
- package/lib/components/Slider/index.js +0 -20
- package/lib/internal/createClassWrapper.js +0 -25
|
@@ -37,6 +37,7 @@ import TableToolbarAction from './TableToolbarAction.js';
|
|
|
37
37
|
import TableToolbarContent from './TableToolbarContent.js';
|
|
38
38
|
import TableToolbarSearch from './TableToolbarSearch.js';
|
|
39
39
|
import TableToolbarMenu from './TableToolbarMenu.js';
|
|
40
|
+
import { deprecate } from '../../prop-types/deprecate.js';
|
|
40
41
|
|
|
41
42
|
const getInstanceId = setupGetInstanceId();
|
|
42
43
|
const translationKeys = {
|
|
@@ -50,11 +51,8 @@ const translationKeys = {
|
|
|
50
51
|
unselectRow: 'carbon.table.row.unselect'
|
|
51
52
|
};
|
|
52
53
|
|
|
53
|
-
// TODO: All code comments in this file should be revisited for accuracy and
|
|
54
|
-
// clarity.
|
|
55
|
-
|
|
56
54
|
/**
|
|
57
|
-
* Message
|
|
55
|
+
* Message IDs that will be passed to translateWithId().
|
|
58
56
|
*/
|
|
59
57
|
|
|
60
58
|
const defaultTranslations = {
|
|
@@ -68,16 +66,26 @@ const defaultTranslations = {
|
|
|
68
66
|
[translationKeys.unselectRow]: 'Unselect row'
|
|
69
67
|
};
|
|
70
68
|
const translateWithId = id => defaultTranslations[id];
|
|
69
|
+
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
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
|
+
|
|
71
80
|
/**
|
|
72
|
-
*
|
|
73
|
-
* subset of their fields in columns, or headers. We prioritize
|
|
74
|
-
* to the state of what we're rendering, so internally we
|
|
75
|
-
* given data and then
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* and updating the state of the single entity will cascade updates to the
|
|
79
|
-
* consumer.
|
|
81
|
+
* DataTable components are used to represent a collection of resources,
|
|
82
|
+
* displaying a subset of their fields in columns, or headers. We prioritize
|
|
83
|
+
* direct updates to the state of what we're rendering, so internally we
|
|
84
|
+
* normalize the given data and then denormalize it at render time. Each part of
|
|
85
|
+
* the DataTable is accessible through look-up by ID, and updating the state of
|
|
86
|
+
* a single entity cascades updates to the consumer.
|
|
80
87
|
*/
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
81
89
|
const DataTable = props => {
|
|
82
90
|
const {
|
|
83
91
|
children,
|
|
@@ -98,24 +106,18 @@ const DataTable = props => {
|
|
|
98
106
|
const instanceId = useMemo(() => getInstanceId(), []);
|
|
99
107
|
const [state, setState] = useState(() => ({
|
|
100
108
|
...getDerivedStateFromProps(props, {}),
|
|
101
|
-
|
|
109
|
+
// Initialize to collapsed. A value of `undefined` is treated as neutral.
|
|
110
|
+
isExpandedAll: false
|
|
102
111
|
}));
|
|
103
112
|
useEffect(() => {
|
|
104
113
|
const nextRowIds = rows.map(row => row.id);
|
|
105
114
|
const nextHeaders = headers.map(header => header.key);
|
|
106
115
|
const hasRowIdsChanged = !isEqual(nextRowIds, state.rowIds);
|
|
107
|
-
const currentHeaders = Object.keys(state.cellsById).
|
|
108
|
-
const headerKey = cellId.split(':')[1];
|
|
109
|
-
if (headerKey && !acc.includes(headerKey)) {
|
|
110
|
-
acc.push(headerKey);
|
|
111
|
-
}
|
|
112
|
-
return acc;
|
|
113
|
-
}, []);
|
|
116
|
+
const currentHeaders = Array.from(new Set(Object.keys(state.cellsById).map(id => id.split(':')[1])));
|
|
114
117
|
const hasHeadersChanged = !isEqual(nextHeaders, currentHeaders);
|
|
115
118
|
const currentRows = state.rowIds.map(id => {
|
|
116
119
|
const row = state.rowsById[id];
|
|
117
120
|
return {
|
|
118
|
-
// TODO: Investigate whether it be okay to just return `row`.
|
|
119
121
|
id: row.id,
|
|
120
122
|
disabled: row.disabled,
|
|
121
123
|
isExpanded: row.isExpanded,
|
|
@@ -126,12 +128,8 @@ const DataTable = props => {
|
|
|
126
128
|
if (hasRowIdsChanged || hasHeadersChanged || hasRowsChanged) {
|
|
127
129
|
setState(prev => getDerivedStateFromProps(props, prev));
|
|
128
130
|
}
|
|
131
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
129
132
|
}, [headers, rows]);
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Get the props associated with the given header. Mostly used for adding in
|
|
133
|
-
* sorting behavior.
|
|
134
|
-
*/
|
|
135
133
|
const getHeaderProps = ({
|
|
136
134
|
header,
|
|
137
135
|
onClick,
|
|
@@ -142,33 +140,36 @@ const DataTable = props => {
|
|
|
142
140
|
sortDirection,
|
|
143
141
|
sortHeaderKey
|
|
144
142
|
} = state;
|
|
143
|
+
const {
|
|
144
|
+
key,
|
|
145
|
+
slug,
|
|
146
|
+
decorator
|
|
147
|
+
} = header;
|
|
145
148
|
return {
|
|
146
149
|
...rest,
|
|
147
|
-
key
|
|
150
|
+
key,
|
|
148
151
|
sortDirection,
|
|
149
152
|
isSortable,
|
|
150
|
-
isSortHeader: sortHeaderKey ===
|
|
151
|
-
slug
|
|
152
|
-
decorator
|
|
153
|
+
isSortHeader: sortHeaderKey === key,
|
|
154
|
+
slug,
|
|
155
|
+
decorator,
|
|
153
156
|
onClick: event => {
|
|
154
157
|
const nextSortState = getNextSortState(props, state, {
|
|
155
|
-
key
|
|
158
|
+
key
|
|
156
159
|
});
|
|
157
160
|
setState(prev => ({
|
|
158
161
|
...prev,
|
|
159
162
|
...nextSortState
|
|
160
163
|
}));
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
if (onClick) {
|
|
165
|
+
handleOnHeaderClick(onClick, {
|
|
166
|
+
sortHeaderKey: key,
|
|
167
|
+
sortDirection: nextSortState.sortDirection
|
|
168
|
+
})(event);
|
|
169
|
+
}
|
|
165
170
|
}
|
|
166
171
|
};
|
|
167
172
|
};
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Get the props associated with the given expand header.
|
|
171
|
-
*/
|
|
172
173
|
const getExpandHeaderProps = ({
|
|
173
174
|
onClick,
|
|
174
175
|
onExpand,
|
|
@@ -181,39 +182,35 @@ const DataTable = props => {
|
|
|
181
182
|
} = state;
|
|
182
183
|
const isExpanded = isExpandedAll || rowIds.every(id => rowsById[id].isExpanded);
|
|
183
184
|
const translationKey = isExpanded ? translationKeys.collapseAll : translationKeys.expandAll;
|
|
185
|
+
const handlers = [handleOnExpandAll, onExpand];
|
|
186
|
+
if (onClick) {
|
|
187
|
+
handlers.push(handleOnExpandHeaderClick(onClick, {
|
|
188
|
+
isExpanded
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
184
191
|
return {
|
|
185
192
|
...rest,
|
|
186
193
|
'aria-label': t(translationKey),
|
|
187
|
-
// Provide a string of all
|
|
194
|
+
// Provide a string of all expanded row IDs, separated by a space.
|
|
188
195
|
'aria-controls': rowIds.map(id => `expanded-row-${id}`).join(' '),
|
|
189
196
|
isExpanded,
|
|
190
|
-
|
|
191
|
-
// handler
|
|
192
|
-
onExpand: composeEventHandlers([handleOnExpandAll, onExpand,
|
|
193
|
-
// TODO: Avoid passing `false` to this function.
|
|
194
|
-
onClick && handleOnExpandHeaderClick(onClick, {
|
|
195
|
-
isExpanded
|
|
196
|
-
})])
|
|
197
|
+
onExpand: composeEventHandlers(handlers)
|
|
197
198
|
};
|
|
198
199
|
};
|
|
199
200
|
|
|
200
201
|
/**
|
|
201
|
-
*
|
|
202
|
+
* Wraps the consumer's `onClick` with sorting metadata.
|
|
202
203
|
*/
|
|
203
204
|
const handleOnHeaderClick = (onClick, sortParams) => {
|
|
204
205
|
return event => onClick(event, sortParams);
|
|
205
206
|
};
|
|
206
207
|
|
|
207
208
|
/**
|
|
208
|
-
*
|
|
209
|
+
* Wraps the consumer's `onClick` with sorting metadata.
|
|
209
210
|
*/
|
|
210
211
|
const handleOnExpandHeaderClick = (onClick, expandParams) => {
|
|
211
212
|
return event => onClick(event, expandParams);
|
|
212
213
|
};
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Get the props associated with the given row. Mostly used for expansion.
|
|
216
|
-
*/
|
|
217
214
|
const getRowProps = ({
|
|
218
215
|
row,
|
|
219
216
|
onClick,
|
|
@@ -234,10 +231,6 @@ const DataTable = props => {
|
|
|
234
231
|
disabled: row.disabled
|
|
235
232
|
};
|
|
236
233
|
};
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Get the props associated with an expanded row
|
|
240
|
-
*/
|
|
241
234
|
const getExpandedRowProps = ({
|
|
242
235
|
row,
|
|
243
236
|
...rest
|
|
@@ -249,9 +242,7 @@ const DataTable = props => {
|
|
|
249
242
|
};
|
|
250
243
|
|
|
251
244
|
/**
|
|
252
|
-
* Gets the props associated with selection for a header or a row
|
|
253
|
-
* applicable. Most often used to indicate selection status of the table or
|
|
254
|
-
* for a specific row.
|
|
245
|
+
* Gets the props associated with selection for a header or a row.
|
|
255
246
|
*/
|
|
256
247
|
const getSelectionProps = ({
|
|
257
248
|
onClick,
|
|
@@ -276,7 +267,7 @@ const DataTable = props => {
|
|
|
276
267
|
// Otherwise, we're working on `TableSelectAll` which handles toggling the
|
|
277
268
|
// selection state of all rows.
|
|
278
269
|
const rowCount = state.rowIds.length;
|
|
279
|
-
const selectedRowCount =
|
|
270
|
+
const selectedRowCount = selectedRows.length;
|
|
280
271
|
const checked = rowCount > 0 && selectedRowCount === rowCount;
|
|
281
272
|
const indeterminate = rowCount > 0 && selectedRowCount > 0 && selectedRowCount !== rowCount;
|
|
282
273
|
const translationKey = checked || indeterminate ? translationKeys.unselectAll : translationKeys.selectAll;
|
|
@@ -301,13 +292,13 @@ const DataTable = props => {
|
|
|
301
292
|
const {
|
|
302
293
|
shouldShowBatchActions
|
|
303
294
|
} = state;
|
|
304
|
-
const
|
|
295
|
+
const selectedRowCount = selectedRows.length;
|
|
305
296
|
return {
|
|
306
297
|
onSelectAll: undefined,
|
|
307
|
-
totalCount: state.rowIds.length
|
|
298
|
+
totalCount: state.rowIds.length,
|
|
308
299
|
...props,
|
|
309
|
-
shouldShowBatchActions: shouldShowBatchActions &&
|
|
310
|
-
totalSelected,
|
|
300
|
+
shouldShowBatchActions: shouldShowBatchActions && selectedRowCount > 0,
|
|
301
|
+
totalSelected: selectedRowCount,
|
|
311
302
|
onCancel: handleOnCancel
|
|
312
303
|
};
|
|
313
304
|
};
|
|
@@ -328,77 +319,49 @@ const DataTable = props => {
|
|
|
328
319
|
useStaticWidth
|
|
329
320
|
};
|
|
330
321
|
};
|
|
331
|
-
|
|
332
|
-
// TODO: `getHeaderProps` and `getRowProps` return `key` props. Would it be
|
|
333
|
-
// beneficial for this function to also return a `key` prop?
|
|
334
|
-
/**
|
|
335
|
-
* Get the props associated with the given table cell.
|
|
336
|
-
*/
|
|
337
322
|
const getCellProps = ({
|
|
338
323
|
cell: {
|
|
339
324
|
hasAILabelHeader,
|
|
340
|
-
|
|
325
|
+
id
|
|
341
326
|
},
|
|
342
327
|
...rest
|
|
343
328
|
}) => {
|
|
344
329
|
return {
|
|
345
330
|
...rest,
|
|
346
331
|
hasAILabelHeader,
|
|
347
|
-
|
|
332
|
+
key: id
|
|
348
333
|
};
|
|
349
334
|
};
|
|
350
335
|
|
|
351
336
|
/**
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
* @returns the array of rowIds that are currently selected
|
|
337
|
+
* Selected row IDs, excluding disabled rows.
|
|
355
338
|
*/
|
|
356
|
-
const
|
|
339
|
+
const selectedRows = state.rowIds.filter(id => {
|
|
357
340
|
const row = state.rowsById[id];
|
|
358
341
|
return row.isSelected && !row.disabled;
|
|
359
342
|
});
|
|
343
|
+
const filteredRowIds = typeof state.filterInputValue === 'string' ? filterRows({
|
|
344
|
+
cellsById: state.cellsById,
|
|
345
|
+
getCellId,
|
|
346
|
+
headers,
|
|
347
|
+
inputValue: state.filterInputValue,
|
|
348
|
+
rowIds: state.rowIds
|
|
349
|
+
}) : state.rowIds;
|
|
360
350
|
|
|
361
351
|
/**
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
* @returns the array of rowIds that are currently included through the filter
|
|
365
|
-
*/
|
|
366
|
-
const getFilteredRowIds = () => {
|
|
367
|
-
const filteredRowIds = typeof state.filterInputValue === 'string' ? filterRows({
|
|
368
|
-
rowIds: state.rowIds,
|
|
369
|
-
headers: headers,
|
|
370
|
-
cellsById: state.cellsById,
|
|
371
|
-
inputValue: state.filterInputValue,
|
|
372
|
-
getCellId
|
|
373
|
-
}) : state.rowIds;
|
|
374
|
-
// TODO: Use strict equality check.
|
|
375
|
-
if (filteredRowIds.length == 0) {
|
|
376
|
-
return [];
|
|
377
|
-
}
|
|
378
|
-
return filteredRowIds;
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* Helper for getting the table prefix for elements that require an
|
|
383
|
-
* `id` attribute that is unique.
|
|
352
|
+
* Generates a prefix for table related IDs.
|
|
384
353
|
*/
|
|
385
354
|
const getTablePrefix = () => `data-table-${instanceId}`;
|
|
386
355
|
|
|
387
356
|
/**
|
|
388
|
-
*
|
|
389
|
-
* setState, so use it when setting state.
|
|
390
|
-
*
|
|
391
|
-
* @returns object to put into this.setState (use spread operator)
|
|
357
|
+
* Generates a new `rowsById` object with updated selection state.
|
|
392
358
|
*/
|
|
393
|
-
const
|
|
359
|
+
const getUpdatedSelectionState = (initialState, isSelected) => {
|
|
394
360
|
const {
|
|
395
361
|
rowIds
|
|
396
362
|
} = initialState;
|
|
397
|
-
|
|
398
|
-
const isFiltered = rowIds.length != filteredRowIds.length;
|
|
363
|
+
const isFiltered = rowIds.length !== filteredRowIds.length;
|
|
399
364
|
return {
|
|
400
|
-
// TODO: Should the `reduce` be typed with `<Record<string,
|
|
401
|
-
// DataTableRow<ColTypes>>>`?
|
|
402
365
|
rowsById: rowIds.reduce((acc, id) => {
|
|
403
366
|
const row = {
|
|
404
367
|
...initialState.rowsById[id]
|
|
@@ -406,62 +369,59 @@ const DataTable = props => {
|
|
|
406
369
|
if (!row.disabled && (!isFiltered || filteredRowIds.includes(id))) {
|
|
407
370
|
row.isSelected = isSelected;
|
|
408
371
|
}
|
|
409
|
-
|
|
372
|
+
|
|
373
|
+
// Local mutation for performance with large tables
|
|
374
|
+
acc[id] = row;
|
|
410
375
|
return acc;
|
|
411
376
|
}, {})
|
|
412
377
|
};
|
|
413
378
|
};
|
|
414
379
|
|
|
415
380
|
/**
|
|
416
|
-
* Handler for
|
|
417
|
-
*
|
|
381
|
+
* Handler for `onCancel` to hide the batch action toolbar and deselect all
|
|
382
|
+
* rows.
|
|
418
383
|
*/
|
|
419
384
|
const handleOnCancel = () => {
|
|
420
385
|
setState(prev => {
|
|
421
386
|
return {
|
|
422
387
|
...prev,
|
|
423
388
|
shouldShowBatchActions: false,
|
|
424
|
-
...
|
|
389
|
+
...getUpdatedSelectionState(prev, false)
|
|
425
390
|
};
|
|
426
391
|
});
|
|
427
392
|
};
|
|
428
393
|
|
|
429
394
|
/**
|
|
430
|
-
* Handler for toggling the selection state of all rows
|
|
395
|
+
* Handler for toggling the selection state of all rows.
|
|
431
396
|
*/
|
|
432
397
|
const handleSelectAll = () => {
|
|
433
398
|
setState(prev => {
|
|
434
|
-
const filteredRowIds = getFilteredRowIds();
|
|
435
399
|
const {
|
|
436
400
|
rowsById
|
|
437
401
|
} = prev;
|
|
438
|
-
const isSelected = !
|
|
402
|
+
const isSelected = !Object.values(rowsById).filter(row => row.isSelected && !row.disabled).length;
|
|
439
403
|
return {
|
|
440
404
|
...prev,
|
|
441
405
|
shouldShowBatchActions: isSelected,
|
|
442
|
-
...
|
|
406
|
+
...getUpdatedSelectionState(prev, isSelected)
|
|
443
407
|
};
|
|
444
408
|
});
|
|
445
409
|
};
|
|
446
410
|
|
|
447
411
|
/**
|
|
448
|
-
* Handler for toggling
|
|
412
|
+
* Handler for toggling selection state of a given row.
|
|
449
413
|
*/
|
|
450
414
|
const handleOnSelectRow = rowId => () => {
|
|
451
415
|
setState(prev => {
|
|
452
416
|
const row = prev.rowsById[rowId];
|
|
453
417
|
if (radio) {
|
|
454
|
-
//
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
const [key, val] = c;
|
|
462
|
-
val.isSelected = false;
|
|
463
|
-
p[key] = val;
|
|
464
|
-
return p;
|
|
418
|
+
// Deselect all radio buttons, then toggle the target row
|
|
419
|
+
const rowsById = Object.entries(prev.rowsById).reduce((acc, [id, row]) => {
|
|
420
|
+
acc[id] = {
|
|
421
|
+
...row,
|
|
422
|
+
isSelected: false
|
|
423
|
+
};
|
|
424
|
+
return acc;
|
|
465
425
|
}, {});
|
|
466
426
|
return {
|
|
467
427
|
...prev,
|
|
@@ -469,8 +429,8 @@ const DataTable = props => {
|
|
|
469
429
|
rowsById: {
|
|
470
430
|
...rowsById,
|
|
471
431
|
[rowId]: {
|
|
472
|
-
...
|
|
473
|
-
isSelected: !
|
|
432
|
+
...rowsById[rowId],
|
|
433
|
+
isSelected: !rowsById[rowId].isSelected
|
|
474
434
|
}
|
|
475
435
|
}
|
|
476
436
|
};
|
|
@@ -480,10 +440,8 @@ const DataTable = props => {
|
|
|
480
440
|
const selectedRowsCount = !row.isSelected ? selectedRows + 1 : selectedRows - 1;
|
|
481
441
|
return {
|
|
482
442
|
...prev,
|
|
483
|
-
//
|
|
484
|
-
//
|
|
485
|
-
// have a non-zero number of selected rows that batch actions could
|
|
486
|
-
// still apply to
|
|
443
|
+
// Show batch action toolbar if selecting, or if there are other
|
|
444
|
+
// selected rows remaining.
|
|
487
445
|
shouldShowBatchActions: !row.isSelected || selectedRowsCount > 0,
|
|
488
446
|
rowsById: {
|
|
489
447
|
...prev.rowsById,
|
|
@@ -495,10 +453,6 @@ const DataTable = props => {
|
|
|
495
453
|
};
|
|
496
454
|
});
|
|
497
455
|
};
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* Handler for toggling the expansion state of a given row.
|
|
501
|
-
*/
|
|
502
456
|
const handleOnExpandRow = rowId => () => {
|
|
503
457
|
setState(prev => {
|
|
504
458
|
const row = prev.rowsById[rowId];
|
|
@@ -518,10 +472,6 @@ const DataTable = props => {
|
|
|
518
472
|
};
|
|
519
473
|
});
|
|
520
474
|
};
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* Handler for changing the expansion state of all rows.
|
|
524
|
-
*/
|
|
525
475
|
const handleOnExpandAll = () => {
|
|
526
476
|
setState(prev => {
|
|
527
477
|
const {
|
|
@@ -531,22 +481,19 @@ const DataTable = props => {
|
|
|
531
481
|
return {
|
|
532
482
|
...prev,
|
|
533
483
|
isExpandedAll: !isExpandedAll,
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
...acc,
|
|
537
|
-
[id]: {
|
|
484
|
+
rowsById: rowIds.reduce((acc, id) => {
|
|
485
|
+
acc[id] = {
|
|
538
486
|
...prev.rowsById[id],
|
|
539
487
|
isExpanded: !isExpandedAll
|
|
540
|
-
}
|
|
541
|
-
|
|
488
|
+
};
|
|
489
|
+
return acc;
|
|
490
|
+
}, {})
|
|
542
491
|
};
|
|
543
492
|
});
|
|
544
493
|
};
|
|
545
494
|
|
|
546
495
|
/**
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
* @param headerKey - The field for the header that we are sorting by.
|
|
496
|
+
* Transitions to the next sort state of the table.
|
|
550
497
|
*/
|
|
551
498
|
const handleSortBy = headerKey => () => {
|
|
552
499
|
setState(prev => {
|
|
@@ -562,37 +509,20 @@ const DataTable = props => {
|
|
|
562
509
|
};
|
|
563
510
|
|
|
564
511
|
/**
|
|
565
|
-
* Event handler for
|
|
566
|
-
* filter component.
|
|
512
|
+
* Event handler for table filter input changes.
|
|
567
513
|
*/
|
|
568
514
|
const handleOnInputValueChange = (event, defaultValue) => {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
}
|
|
575
|
-
if (defaultValue) {
|
|
576
|
-
setState(prev => ({
|
|
577
|
-
...prev,
|
|
578
|
-
filterInputValue: defaultValue
|
|
579
|
-
}));
|
|
580
|
-
}
|
|
515
|
+
const value = defaultValue || event.target?.value;
|
|
516
|
+
setState(prev => ({
|
|
517
|
+
...prev,
|
|
518
|
+
filterInputValue: value
|
|
519
|
+
}));
|
|
581
520
|
};
|
|
582
|
-
|
|
583
|
-
// TODO: Could getFilteredRowIds be used here?
|
|
584
|
-
const filteredRowIds = typeof state.filterInputValue === 'string' ? filterRows({
|
|
585
|
-
rowIds: state.rowIds,
|
|
586
|
-
headers,
|
|
587
|
-
cellsById: state.cellsById,
|
|
588
|
-
inputValue: state.filterInputValue,
|
|
589
|
-
getCellId
|
|
590
|
-
}) : state.rowIds;
|
|
591
521
|
const renderProps = {
|
|
592
522
|
// Data derived from state
|
|
593
523
|
rows: denormalize(filteredRowIds, state.rowsById, state.cellsById),
|
|
594
524
|
headers: headers,
|
|
595
|
-
selectedRows: denormalize(
|
|
525
|
+
selectedRows: denormalize(selectedRows, state.rowsById, state.cellsById),
|
|
596
526
|
// Prop accessors/getters
|
|
597
527
|
getHeaderProps,
|
|
598
528
|
getExpandHeaderProps,
|
|
@@ -646,6 +576,10 @@ DataTable.TableToolbarContent = TableToolbarContent;
|
|
|
646
576
|
DataTable.TableToolbarSearch = TableToolbarSearch;
|
|
647
577
|
DataTable.TableToolbarMenu = TableToolbarMenu;
|
|
648
578
|
DataTable.propTypes = {
|
|
579
|
+
/**
|
|
580
|
+
* Pass in the children that will be rendered within the Table
|
|
581
|
+
*/
|
|
582
|
+
children: PropTypes.node,
|
|
649
583
|
/**
|
|
650
584
|
* Experimental property. Allows table to align cell contents to the top if there is text wrapping in the content. Might have performance issues, intended for smaller tables
|
|
651
585
|
*/
|
|
@@ -681,6 +615,13 @@ DataTable.propTypes = {
|
|
|
681
615
|
* Specify whether the control should be a radio button or inline checkbox
|
|
682
616
|
*/
|
|
683
617
|
radio: PropTypes.bool,
|
|
618
|
+
/**
|
|
619
|
+
* @deprecated Use `children` instead. This prop will be removed in
|
|
620
|
+
* the next major version.
|
|
621
|
+
*
|
|
622
|
+
* https://www.patterns.dev/react/render-props-pattern/#children-as-a-function
|
|
623
|
+
*/
|
|
624
|
+
render: deprecate(PropTypes.func),
|
|
684
625
|
/**
|
|
685
626
|
* The `rows` prop is where you provide us with a list of all the rows that
|
|
686
627
|
* you want to render in the table. The only hard requirement is that this
|
|
@@ -707,13 +648,13 @@ DataTable.propTypes = {
|
|
|
707
648
|
*/
|
|
708
649
|
stickyHeader: PropTypes.bool,
|
|
709
650
|
/**
|
|
710
|
-
* Optional method that takes in a message
|
|
651
|
+
* Optional method that takes in a message ID and returns an
|
|
711
652
|
* internationalized string. See `DataTable.translationKeys` for all
|
|
712
|
-
* available message
|
|
653
|
+
* available message IDs.
|
|
713
654
|
*/
|
|
714
655
|
translateWithId: PropTypes.func,
|
|
715
656
|
/**
|
|
716
|
-
*
|
|
657
|
+
* If `true`, sets the table width to `auto` instead of `100%`.
|
|
717
658
|
*/
|
|
718
659
|
useStaticWidth: PropTypes.bool,
|
|
719
660
|
/**
|
|
@@ -26,7 +26,7 @@ export interface TableProps {
|
|
|
26
26
|
*/
|
|
27
27
|
stickyHeader?: boolean;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* If `true`, sets the table width to `auto` instead of `100%`.
|
|
30
30
|
*/
|
|
31
31
|
useStaticWidth?: boolean;
|
|
32
32
|
/**
|
|
@@ -67,7 +67,7 @@ export declare const Table: {
|
|
|
67
67
|
*/
|
|
68
68
|
stickyHeader: PropTypes.Requireable<boolean>;
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
70
|
+
* If `true`, sets the table width to `auto` instead of `100%`.
|
|
71
71
|
*/
|
|
72
72
|
useStaticWidth: PropTypes.Requireable<boolean>;
|
|
73
73
|
/**
|
|
@@ -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,
|
|
@@ -166,7 +166,7 @@ Table.propTypes = {
|
|
|
166
166
|
*/
|
|
167
167
|
stickyHeader: PropTypes.bool,
|
|
168
168
|
/**
|
|
169
|
-
*
|
|
169
|
+
* If `true`, sets the table width to `auto` instead of `100%`.
|
|
170
170
|
*/
|
|
171
171
|
useStaticWidth: PropTypes.bool,
|
|
172
172
|
/**
|
|
@@ -98,7 +98,7 @@ declare const TableExpandHeader: {
|
|
|
98
98
|
* Specify whether this row is expanded or not. This helps coordinate data
|
|
99
99
|
* attributes so that `TableExpandRow` and `TableExpandedRow` work together
|
|
100
100
|
*/
|
|
101
|
-
isExpanded:
|
|
101
|
+
isExpanded: PropTypes.Validator<boolean | null | undefined>;
|
|
102
102
|
/**
|
|
103
103
|
* Hook for when a listener initiates a request to expand the given row
|
|
104
104
|
*/
|
|
@@ -12,7 +12,7 @@ import PropTypes from 'prop-types';
|
|
|
12
12
|
import React from 'react';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
14
|
import { deprecate } from '../../prop-types/deprecate.js';
|
|
15
|
-
import requiredIfGivenPropIsTruthy from '../../prop-types/requiredIfGivenPropIsTruthy.js';
|
|
15
|
+
import { requiredIfGivenPropIsTruthy } from '../../prop-types/requiredIfGivenPropIsTruthy.js';
|
|
16
16
|
|
|
17
17
|
const TableExpandHeader = ({
|
|
18
18
|
['aria-controls']: ariaControls,
|
|
@@ -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 };
|
|
@@ -92,6 +92,7 @@ TableExpandRow.propTypes = {
|
|
|
92
92
|
* Specify the string read by a voice reader when the expand trigger is
|
|
93
93
|
* focused
|
|
94
94
|
*/
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
95
96
|
/**@ts-ignore*/
|
|
96
97
|
'aria-label': PropTypes.string,
|
|
97
98
|
/**
|
|
@@ -188,6 +188,8 @@ TableHeader.propTypes = {
|
|
|
188
188
|
*/
|
|
189
189
|
translateWithId: PropTypes.func
|
|
190
190
|
};
|
|
191
|
+
|
|
192
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
191
193
|
TableHeader.translationKeys = Object.values(translationKeys);
|
|
192
194
|
TableHeader.displayName = 'TableHeader';
|
|
193
195
|
|