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