@carbon/react 1.92.0 → 1.93.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 +1011 -970
- package/es/components/AILabel/index.js +4 -4
- package/es/components/Breadcrumb/BreadcrumbItem.js +1 -1
- package/es/components/Button/Button.js +2 -2
- package/es/components/ChatButton/ChatButton.js +1 -1
- package/es/components/Checkbox/Checkbox.js +1 -1
- package/es/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/es/components/ComboBox/ComboBox.d.ts +3 -11
- package/es/components/ComboBox/ComboBox.js +15 -25
- package/es/components/ComboButton/index.d.ts +5 -8
- package/es/components/ComboButton/index.js +9 -12
- package/es/components/ComposedModal/ComposedModal.js +22 -36
- package/es/components/DataTable/DataTable.d.ts +25 -16
- package/es/components/DataTable/DataTable.js +33 -34
- package/es/components/DataTable/Table.js +2 -2
- package/es/components/DataTable/TableBatchActions.d.ts +49 -10
- package/es/components/DataTable/TableBatchActions.js +26 -21
- package/es/components/DataTable/TableExpandHeader.js +2 -2
- package/es/components/DataTable/TableExpandRow.js +1 -1
- package/es/components/DataTable/TableHeader.d.ts +8 -10
- package/es/components/DataTable/TableHeader.js +11 -13
- package/es/components/DataTable/TableRow.js +5 -5
- package/es/components/DataTable/TableSlugRow.js +1 -1
- package/es/components/DataTable/TableToolbarMenu.js +1 -1
- package/es/components/DataTable/TableToolbarSearch.d.ts +8 -7
- package/es/components/DataTable/TableToolbarSearch.js +11 -11
- package/es/components/DataTable/index.d.ts +2 -2
- package/es/components/DataTable/state/sorting.d.ts +2 -2
- package/es/components/DataTable/state/sorting.js +1 -1
- package/es/components/DataTable/tools/sorting.js +1 -1
- package/es/components/DatePicker/DatePicker.js +9 -9
- package/es/components/DatePickerInput/DatePickerInput.js +5 -5
- package/es/components/Dialog/Dialog.js +6 -6
- package/es/components/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.js +8 -8
- package/es/components/ErrorBoundary/ErrorBoundaryContext.js +1 -1
- package/es/components/FileUploader/FileUploader.js +4 -4
- package/es/components/FileUploader/FileUploaderButton.js +1 -1
- package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
- package/es/components/FileUploader/FileUploaderItem.js +2 -2
- package/es/components/FluidComboBox/FluidComboBox.d.ts +4 -7
- package/es/components/FluidComboBox/FluidComboBox.js +1 -1
- package/es/components/FluidDropdown/FluidDropdown.d.ts +4 -8
- package/es/components/FluidDropdown/FluidDropdown.js +1 -1
- package/es/components/FluidMultiSelect/FluidFilterableMultiSelect.d.ts +3 -7
- package/es/components/FluidMultiSelect/FluidMultiSelect.d.ts +3 -7
- package/es/components/FluidMultiSelect/FluidMultiSelect.js +3 -3
- package/es/components/FluidNumberInput/FluidNumberInput.d.ts +4 -7
- package/es/components/FluidNumberInput/FluidNumberInput.js +2 -2
- package/es/components/FluidSearch/FluidSearch.js +1 -1
- package/es/components/FluidSelect/FluidSelect.js +1 -1
- package/es/components/FluidTextInput/FluidTextInput.js +1 -1
- package/es/components/FluidTimePicker/FluidTimePicker.js +3 -3
- package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +1 -1
- package/es/components/Grid/CSSGrid.js +3 -3
- package/es/components/Grid/Column.js +2 -2
- package/es/components/Grid/ColumnHang.js +1 -1
- package/es/components/Grid/FlexGrid.js +1 -1
- package/es/components/Grid/Row.js +1 -1
- package/es/components/Heading/index.js +2 -2
- package/es/components/IconButton/index.js +2 -2
- package/es/components/IconIndicator/index.js +2 -2
- package/es/components/InlineCheckbox/InlineCheckbox.js +1 -1
- package/es/components/Layout/index.js +2 -2
- package/es/components/LayoutDirection/LayoutDirection.js +1 -1
- package/es/components/Link/Link.js +2 -2
- package/es/components/ListBox/ListBoxField.d.ts +0 -1
- package/es/components/ListBox/ListBoxMenuIcon.d.ts +8 -4
- package/es/components/ListBox/ListBoxMenuIcon.js +10 -6
- package/es/components/ListBox/ListBoxMenuItem.js +2 -2
- package/es/components/ListBox/ListBoxSelection.d.ts +3 -6
- package/es/components/ListBox/ListBoxSelection.js +5 -10
- package/es/components/ListBox/index.d.ts +5 -3
- package/es/components/ListBox/next/ListBoxSelection.d.ts +6 -13
- package/es/components/ListBox/next/ListBoxSelection.js +16 -8
- package/es/components/ListBox/next/ListBoxTrigger.d.ts +5 -10
- package/es/components/ListBox/next/ListBoxTrigger.js +6 -6
- package/es/components/Menu/MenuContext.js +1 -1
- package/es/components/Menu/MenuItem.js +1 -1
- package/es/components/MenuButton/index.js +5 -5
- package/es/components/Modal/Modal.js +20 -36
- package/es/components/ModalWrapper/ModalWrapper.js +2 -2
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +3 -12
- package/es/components/MultiSelect/FilterableMultiSelect.js +18 -27
- package/es/components/MultiSelect/MultiSelect.d.ts +2 -2
- package/es/components/MultiSelect/MultiSelect.js +12 -12
- package/es/components/Notification/Notification.js +1 -1
- package/es/components/NumberInput/NumberInput.d.ts +2 -5
- package/es/components/NumberInput/NumberInput.js +13 -18
- package/es/components/OverflowMenu/OverflowMenu.d.ts +2 -2
- package/es/components/OverflowMenu/OverflowMenu.js +4 -4
- package/es/components/OverflowMenu/next/index.d.ts +1 -1
- package/es/components/OverflowMenu/next/index.js +2 -2
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +2 -2
- package/es/components/PageHeader/PageHeader.js +12 -12
- package/es/components/Pagination/Pagination.js +3 -3
- package/es/components/PaginationNav/PaginationNav.d.ts +6 -9
- package/es/components/PaginationNav/PaginationNav.js +21 -22
- package/es/components/Popover/index.js +8 -8
- package/es/components/ProgressBar/ProgressBar.js +2 -2
- package/es/components/ProgressIndicator/ProgressIndicator.d.ts +11 -15
- package/es/components/ProgressIndicator/ProgressIndicator.js +15 -15
- package/es/components/RadioButton/RadioButton.js +1 -1
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/es/components/RadioTile/RadioTile.js +1 -1
- package/es/components/Select/Select.js +7 -5
- package/es/components/ShapeIndicator/index.js +2 -2
- package/es/components/Slider/Slider.d.ts +7 -9
- package/es/components/Slider/Slider.js +16 -20
- package/es/components/Stack/HStack.js +1 -1
- package/es/components/Stack/Stack.js +1 -1
- package/es/components/Stack/VStack.js +1 -1
- package/es/components/StructuredList/StructuredList.js +3 -3
- package/es/components/Tabs/Tabs.js +12 -12
- package/es/components/Tag/DismissibleTag.js +3 -3
- package/es/components/Tag/OperationalTag.js +2 -2
- package/es/components/Tag/SelectableTag.js +2 -2
- package/es/components/Tag/Tag.js +4 -4
- package/es/components/Tag/isEllipsisActive.js +1 -1
- package/es/components/Text/Text.js +1 -1
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/TextInput/PasswordInput.js +4 -4
- package/es/components/TextInput/TextInput.js +3 -3
- package/es/components/Theme/index.js +3 -3
- package/es/components/Tile/Tile.js +3 -3
- package/es/components/TimePicker/TimePicker.js +1 -1
- package/es/components/Toggletip/index.js +4 -4
- package/es/components/Tooltip/DefinitionTooltip.js +1 -1
- package/es/components/Tooltip/Tooltip.js +3 -3
- package/es/components/TreeView/TreeNode.js +6 -6
- package/es/components/TreeView/TreeView.js +5 -5
- package/es/components/UIShell/HeaderContainer.js +1 -1
- package/es/components/UIShell/HeaderMenu.js +1 -1
- package/es/components/UIShell/Link.js +2 -2
- package/es/components/UIShell/SideNavItems.js +1 -1
- package/es/components/UIShell/Switcher.js +1 -1
- package/es/components/UIShell/SwitcherItem.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/internal/FloatingMenu.js +4 -4
- package/es/internal/Selection.js +6 -6
- package/es/internal/useMergedRefs.js +1 -1
- package/es/internal/useNoInteractiveChildren.js +4 -4
- package/es/internal/useOutsideClick.js +1 -1
- package/es/internal/useOverflowItems.js +6 -6
- package/es/internal/useResizeObserver.js +3 -3
- package/es/internal/useSavedCallback.js +1 -1
- package/es/internal/warning.js +1 -1
- package/es/prop-types/isRequiredOneOf.js +2 -2
- package/es/tools/events.js +1 -1
- package/es/tools/wrapComponent.js +1 -1
- package/es/types/common.d.ts +6 -2
- package/lib/components/AILabel/index.js +4 -4
- package/lib/components/Breadcrumb/BreadcrumbItem.js +1 -1
- package/lib/components/Button/Button.js +2 -2
- package/lib/components/ChatButton/ChatButton.js +1 -1
- package/lib/components/Checkbox/Checkbox.js +1 -1
- package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/lib/components/ComboBox/ComboBox.d.ts +3 -11
- package/lib/components/ComboBox/ComboBox.js +15 -25
- package/lib/components/ComboButton/index.d.ts +5 -8
- package/lib/components/ComboButton/index.js +9 -12
- package/lib/components/ComposedModal/ComposedModal.js +21 -35
- package/lib/components/DataTable/DataTable.d.ts +25 -16
- package/lib/components/DataTable/DataTable.js +33 -34
- package/lib/components/DataTable/Table.js +2 -2
- package/lib/components/DataTable/TableBatchActions.d.ts +49 -10
- package/lib/components/DataTable/TableBatchActions.js +26 -21
- package/lib/components/DataTable/TableExpandHeader.js +2 -2
- package/lib/components/DataTable/TableExpandRow.js +1 -1
- package/lib/components/DataTable/TableHeader.d.ts +8 -10
- package/lib/components/DataTable/TableHeader.js +11 -13
- package/lib/components/DataTable/TableRow.js +5 -5
- package/lib/components/DataTable/TableSlugRow.js +1 -1
- package/lib/components/DataTable/TableToolbarMenu.js +1 -1
- package/lib/components/DataTable/TableToolbarSearch.d.ts +8 -7
- package/lib/components/DataTable/TableToolbarSearch.js +11 -11
- package/lib/components/DataTable/index.d.ts +2 -2
- package/lib/components/DataTable/state/sorting.d.ts +2 -2
- package/lib/components/DataTable/state/sorting.js +1 -1
- package/lib/components/DataTable/tools/sorting.js +1 -1
- package/lib/components/DatePicker/DatePicker.js +9 -9
- package/lib/components/DatePickerInput/DatePickerInput.js +5 -5
- package/lib/components/Dialog/Dialog.js +6 -6
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.js +8 -8
- package/lib/components/ErrorBoundary/ErrorBoundaryContext.js +1 -1
- package/lib/components/FileUploader/FileUploader.js +4 -4
- package/lib/components/FileUploader/FileUploaderButton.js +1 -1
- package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -1
- package/lib/components/FileUploader/FileUploaderItem.js +2 -2
- package/lib/components/FluidComboBox/FluidComboBox.d.ts +4 -7
- package/lib/components/FluidComboBox/FluidComboBox.js +1 -1
- package/lib/components/FluidDropdown/FluidDropdown.d.ts +4 -8
- package/lib/components/FluidDropdown/FluidDropdown.js +1 -1
- package/lib/components/FluidMultiSelect/FluidFilterableMultiSelect.d.ts +3 -7
- package/lib/components/FluidMultiSelect/FluidMultiSelect.d.ts +3 -7
- package/lib/components/FluidMultiSelect/FluidMultiSelect.js +3 -3
- package/lib/components/FluidNumberInput/FluidNumberInput.d.ts +4 -7
- package/lib/components/FluidNumberInput/FluidNumberInput.js +2 -2
- package/lib/components/FluidSearch/FluidSearch.js +1 -1
- package/lib/components/FluidSelect/FluidSelect.js +1 -1
- package/lib/components/FluidTextInput/FluidTextInput.js +1 -1
- package/lib/components/FluidTimePicker/FluidTimePicker.js +3 -3
- package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +1 -1
- package/lib/components/Grid/CSSGrid.js +3 -3
- package/lib/components/Grid/Column.js +2 -2
- package/lib/components/Grid/ColumnHang.js +1 -1
- package/lib/components/Grid/FlexGrid.js +1 -1
- package/lib/components/Grid/Row.js +1 -1
- package/lib/components/Heading/index.js +2 -2
- package/lib/components/IconButton/index.js +2 -2
- package/lib/components/IconIndicator/index.js +2 -2
- package/lib/components/InlineCheckbox/InlineCheckbox.js +1 -1
- package/lib/components/Layout/index.js +2 -2
- package/lib/components/LayoutDirection/LayoutDirection.js +1 -1
- package/lib/components/Link/Link.js +2 -2
- package/lib/components/ListBox/ListBoxField.d.ts +0 -1
- package/lib/components/ListBox/ListBoxMenuIcon.d.ts +8 -4
- package/lib/components/ListBox/ListBoxMenuIcon.js +10 -6
- package/lib/components/ListBox/ListBoxMenuItem.js +2 -2
- package/lib/components/ListBox/ListBoxSelection.d.ts +3 -6
- package/lib/components/ListBox/ListBoxSelection.js +4 -10
- package/lib/components/ListBox/index.d.ts +5 -3
- package/lib/components/ListBox/next/ListBoxSelection.d.ts +6 -13
- package/lib/components/ListBox/next/ListBoxSelection.js +16 -8
- package/lib/components/ListBox/next/ListBoxTrigger.d.ts +5 -10
- package/lib/components/ListBox/next/ListBoxTrigger.js +5 -6
- package/lib/components/Menu/MenuContext.js +1 -1
- package/lib/components/Menu/MenuItem.js +1 -1
- package/lib/components/MenuButton/index.js +5 -5
- package/lib/components/Modal/Modal.js +19 -35
- package/lib/components/ModalWrapper/ModalWrapper.js +2 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +3 -12
- package/lib/components/MultiSelect/FilterableMultiSelect.js +18 -27
- package/lib/components/MultiSelect/MultiSelect.d.ts +2 -2
- package/lib/components/MultiSelect/MultiSelect.js +12 -12
- package/lib/components/Notification/Notification.js +1 -1
- package/lib/components/NumberInput/NumberInput.d.ts +2 -5
- package/lib/components/NumberInput/NumberInput.js +12 -18
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +2 -2
- package/lib/components/OverflowMenu/OverflowMenu.js +4 -4
- package/lib/components/OverflowMenu/next/index.d.ts +1 -1
- package/lib/components/OverflowMenu/next/index.js +2 -2
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +2 -2
- package/lib/components/PageHeader/PageHeader.js +12 -12
- package/lib/components/Pagination/Pagination.js +3 -3
- package/lib/components/PaginationNav/PaginationNav.d.ts +6 -9
- package/lib/components/PaginationNav/PaginationNav.js +21 -22
- package/lib/components/Popover/index.js +8 -8
- package/lib/components/ProgressBar/ProgressBar.js +2 -2
- package/lib/components/ProgressIndicator/ProgressIndicator.d.ts +11 -15
- package/lib/components/ProgressIndicator/ProgressIndicator.js +15 -15
- package/lib/components/RadioButton/RadioButton.js +1 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/lib/components/RadioTile/RadioTile.js +1 -1
- package/lib/components/Select/Select.js +7 -5
- package/lib/components/ShapeIndicator/index.js +2 -2
- package/lib/components/Slider/Slider.d.ts +7 -9
- package/lib/components/Slider/Slider.js +16 -20
- package/lib/components/Stack/HStack.js +1 -1
- package/lib/components/Stack/Stack.js +1 -1
- package/lib/components/Stack/VStack.js +1 -1
- package/lib/components/StructuredList/StructuredList.js +3 -3
- package/lib/components/Tabs/Tabs.js +12 -12
- package/lib/components/Tag/DismissibleTag.js +3 -3
- package/lib/components/Tag/OperationalTag.js +2 -2
- package/lib/components/Tag/SelectableTag.js +2 -2
- package/lib/components/Tag/Tag.js +4 -4
- package/lib/components/Tag/isEllipsisActive.js +1 -1
- package/lib/components/Text/Text.js +1 -1
- package/lib/components/TextArea/TextArea.js +1 -1
- package/lib/components/TextInput/PasswordInput.js +4 -4
- package/lib/components/TextInput/TextInput.js +3 -3
- package/lib/components/Theme/index.js +3 -3
- package/lib/components/Tile/Tile.js +3 -3
- package/lib/components/TimePicker/TimePicker.js +1 -1
- package/lib/components/Toggletip/index.js +4 -4
- package/lib/components/Tooltip/DefinitionTooltip.js +1 -1
- package/lib/components/Tooltip/Tooltip.js +3 -3
- package/lib/components/TreeView/TreeNode.js +6 -6
- package/lib/components/TreeView/TreeView.js +5 -5
- package/lib/components/UIShell/HeaderContainer.js +1 -1
- package/lib/components/UIShell/HeaderMenu.js +1 -1
- package/lib/components/UIShell/Link.js +2 -2
- package/lib/components/UIShell/SideNavItems.js +1 -1
- package/lib/components/UIShell/Switcher.js +1 -1
- package/lib/components/UIShell/SwitcherItem.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/internal/FloatingMenu.js +4 -4
- package/lib/internal/Selection.js +6 -6
- package/lib/internal/useMergedRefs.js +1 -1
- package/lib/internal/useNoInteractiveChildren.js +4 -4
- package/lib/internal/useOutsideClick.js +1 -1
- package/lib/internal/useOverflowItems.js +6 -6
- package/lib/internal/useResizeObserver.js +3 -3
- package/lib/internal/useSavedCallback.js +1 -1
- package/lib/internal/warning.js +1 -1
- package/lib/prop-types/isRequiredOneOf.js +2 -2
- package/lib/tools/events.js +1 -1
- package/lib/tools/wrapComponent.js +1 -1
- package/lib/types/common.d.ts +6 -2
- package/package.json +9 -9
|
@@ -11,12 +11,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
11
11
|
|
|
12
12
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
13
|
var React = require('react');
|
|
14
|
+
var useResizeObserver = require('../../internal/useResizeObserver.js');
|
|
14
15
|
var reactIs = require('react-is');
|
|
15
16
|
var PropTypes = require('prop-types');
|
|
16
17
|
var index = require('../Layer/index.js');
|
|
17
18
|
var ModalHeader = require('./ModalHeader.js');
|
|
18
19
|
var ModalFooter = require('./ModalFooter.js');
|
|
19
|
-
var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
|
|
20
20
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
21
21
|
var cx = require('classnames');
|
|
22
22
|
var toggleClass = require('../../tools/toggleClass.js');
|
|
@@ -36,7 +36,6 @@ var react = require('@floating-ui/react');
|
|
|
36
36
|
var ComposedModalPresence = require('./ComposedModalPresence.js');
|
|
37
37
|
var useId = require('../../internal/useId.js');
|
|
38
38
|
var useComposedModalState = require('./useComposedModalState.js');
|
|
39
|
-
var debounce = require('../../node_modules/es-toolkit/dist/compat/function/debounce.js');
|
|
40
39
|
|
|
41
40
|
const ModalBody = /*#__PURE__*/React.forwardRef(function ModalBody({
|
|
42
41
|
className: customClassName,
|
|
@@ -47,28 +46,23 @@ const ModalBody = /*#__PURE__*/React.forwardRef(function ModalBody({
|
|
|
47
46
|
}, ref) {
|
|
48
47
|
const prefix = usePrefix.usePrefix();
|
|
49
48
|
const contentRef = React.useRef(null);
|
|
50
|
-
const
|
|
49
|
+
const {
|
|
50
|
+
height
|
|
51
|
+
} = useResizeObserver.useResizeObserver({
|
|
52
|
+
ref: contentRef
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* isScrollable is implicitly dependent on height, when height gets updated
|
|
57
|
+
* via `useResizeObserver`, clientHeight and scrollHeight get updated too
|
|
58
|
+
*/
|
|
59
|
+
const isScrollable = !!contentRef.current && contentRef?.current?.scrollHeight > contentRef?.current?.clientHeight;
|
|
51
60
|
const contentClass = cx({
|
|
52
61
|
[`${prefix}--modal-content`]: true,
|
|
53
62
|
[`${prefix}--modal-content--with-form`]: hasForm,
|
|
54
|
-
[`${prefix}--modal-scroll-content`]: hasScrollingContent || isScrollable
|
|
63
|
+
[`${prefix}--modal-scroll-content`]: hasScrollingContent || isScrollable,
|
|
64
|
+
[`${prefix}--modal-scroll-content--no-fade`]: height <= 300
|
|
55
65
|
}, customClassName);
|
|
56
|
-
useIsomorphicEffect.default(() => {
|
|
57
|
-
if (contentRef.current) {
|
|
58
|
-
setIsScrollable(contentRef.current.scrollHeight > contentRef.current.clientHeight);
|
|
59
|
-
}
|
|
60
|
-
function handler() {
|
|
61
|
-
if (contentRef.current) {
|
|
62
|
-
setIsScrollable(contentRef.current.scrollHeight > contentRef.current.clientHeight);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const debouncedHandler = debounce.debounce(handler, 200);
|
|
66
|
-
window.addEventListener('resize', debouncedHandler);
|
|
67
|
-
return () => {
|
|
68
|
-
debouncedHandler.cancel();
|
|
69
|
-
window.removeEventListener('resize', debouncedHandler);
|
|
70
|
-
};
|
|
71
|
-
}, []);
|
|
72
66
|
const hasScrollingContentProps = hasScrollingContent || isScrollable ? {
|
|
73
67
|
tabIndex: 0,
|
|
74
68
|
role: 'region'
|
|
@@ -173,7 +167,7 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
|
|
|
173
167
|
if (!enableDialogElement) {
|
|
174
168
|
toggleClass.toggleClass(document.body, `${prefix}--body--with-modal-open`, !!open);
|
|
175
169
|
}
|
|
176
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
170
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
177
171
|
}, [open, prefix]);
|
|
178
172
|
// Remove the document.body className on unmount
|
|
179
173
|
React.useEffect(() => {
|
|
@@ -247,17 +241,9 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
|
|
|
247
241
|
if (!modalContent || !modalContent.classList.contains(`${prefix}--modal-scroll-content`) || !currentActiveNode || !modalContent.contains(currentActiveNode)) {
|
|
248
242
|
return;
|
|
249
243
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if (elem.contains(currentActiveNode)) {
|
|
254
|
-
const spaceBelow = modalContent.clientHeight - elem.offsetTop + modalContent.scrollTop - elem.clientHeight;
|
|
255
|
-
if (spaceBelow < gradientSpacing) {
|
|
256
|
-
modalContent.scrollTop = modalContent.scrollTop + (gradientSpacing - spaceBelow);
|
|
257
|
-
}
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
244
|
+
currentActiveNode.scrollIntoView({
|
|
245
|
+
block: 'center'
|
|
246
|
+
});
|
|
261
247
|
}
|
|
262
248
|
function closeModal(evt) {
|
|
263
249
|
if (!onClose || onClose(evt) !== false) {
|
|
@@ -317,7 +303,7 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
|
|
|
317
303
|
return () => {
|
|
318
304
|
document.removeEventListener('keydown', handleEscapeKey, true);
|
|
319
305
|
};
|
|
320
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
306
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
321
307
|
}, [open]);
|
|
322
308
|
React.useEffect(() => {
|
|
323
309
|
if (!enableDialogElement && !enablePresence && !open && launcherButtonRef) {
|
|
@@ -360,7 +346,7 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
|
|
|
360
346
|
focusButton(innerModal.current);
|
|
361
347
|
}
|
|
362
348
|
}
|
|
363
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
349
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
364
350
|
}, [open, selectorPrimaryFocus, isOpen]);
|
|
365
351
|
|
|
366
352
|
// AILabel is always size `sm`
|
|
@@ -368,7 +354,7 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
|
|
|
368
354
|
const candidateIsAILabel = utils.isComponentElement(candidate, index$2.AILabel);
|
|
369
355
|
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
|
|
370
356
|
size: 'sm'
|
|
371
|
-
}) :
|
|
357
|
+
}) : candidate;
|
|
372
358
|
const modalBody = enableDialogElement ? /*#__PURE__*/React.createElement(Dialog.Dialog, {
|
|
373
359
|
open: open,
|
|
374
360
|
focusAfterCloseRef: launcherButtonRef,
|
|
@@ -8,21 +8,21 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import React, { type ChangeEvent, type MouseEvent, type ReactElement, type ReactNode } from 'react';
|
|
9
9
|
import { type SortRowFn } from './state/sorting';
|
|
10
10
|
import type { DataTableSortState } from './state/sortStates';
|
|
11
|
-
import { TranslateWithId } from '../../types/common';
|
|
12
|
-
declare const
|
|
13
|
-
readonly
|
|
14
|
-
readonly
|
|
15
|
-
readonly
|
|
16
|
-
readonly
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
19
|
-
readonly
|
|
20
|
-
readonly
|
|
11
|
+
import type { TranslateWithId } from '../../types/common';
|
|
12
|
+
declare const translationIds: {
|
|
13
|
+
readonly 'carbon.table.row.expand': "carbon.table.row.expand";
|
|
14
|
+
readonly 'carbon.table.row.collapse': "carbon.table.row.collapse";
|
|
15
|
+
readonly 'carbon.table.all.expand': "carbon.table.all.expand";
|
|
16
|
+
readonly 'carbon.table.all.collapse': "carbon.table.all.collapse";
|
|
17
|
+
readonly 'carbon.table.all.select': "carbon.table.all.select";
|
|
18
|
+
readonly 'carbon.table.all.unselect': "carbon.table.all.unselect";
|
|
19
|
+
readonly 'carbon.table.row.select': "carbon.table.row.select";
|
|
20
|
+
readonly 'carbon.table.row.unselect': "carbon.table.row.unselect";
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
23
|
* Message IDs that will be passed to translateWithId().
|
|
24
24
|
*/
|
|
25
|
-
type TranslationKey =
|
|
25
|
+
type TranslationKey = keyof typeof translationIds;
|
|
26
26
|
export type DataTableSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
27
27
|
export interface DataTableCell<T> {
|
|
28
28
|
id: string;
|
|
@@ -233,7 +233,6 @@ export interface DataTableProps<RowType, ColTypes extends any[]> extends Transla
|
|
|
233
233
|
*/
|
|
234
234
|
export declare const DataTable: {
|
|
235
235
|
<RowType, ColTypes extends any[]>(props: DataTableProps<RowType, ColTypes>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
|
|
236
|
-
translationKeys: ("carbon.table.row.expand" | "carbon.table.row.collapse" | "carbon.table.all.expand" | "carbon.table.all.collapse" | "carbon.table.all.select" | "carbon.table.all.unselect" | "carbon.table.row.select" | "carbon.table.row.unselect")[];
|
|
237
236
|
Table: {
|
|
238
237
|
({ className, children, useZebraStyles, size, isSortable, useStaticWidth, stickyHeader, overflowMenuOnHover, experimentalAutoAlign, tabIndex, ...other }: React.PropsWithChildren<import("./Table").TableProps>): import("react/jsx-runtime").JSX.Element;
|
|
239
238
|
propTypes: {
|
|
@@ -258,7 +257,19 @@ export declare const DataTable: {
|
|
|
258
257
|
renderIcon: PropTypes.Requireable<object>;
|
|
259
258
|
};
|
|
260
259
|
};
|
|
261
|
-
TableBatchActions:
|
|
260
|
+
TableBatchActions: {
|
|
261
|
+
({ className, children, shouldShowBatchActions, totalSelected, totalCount, onCancel, onSelectAll, translateWithId: t, ...rest }: import("./TableBatchActions").TableBatchActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
262
|
+
propTypes: {
|
|
263
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
264
|
+
className: PropTypes.Requireable<string>;
|
|
265
|
+
onCancel: PropTypes.Validator<(...args: any[]) => any>;
|
|
266
|
+
onSelectAll: PropTypes.Requireable<(...args: any[]) => any>;
|
|
267
|
+
shouldShowBatchActions: PropTypes.Requireable<boolean>;
|
|
268
|
+
totalCount: PropTypes.Requireable<number>;
|
|
269
|
+
totalSelected: PropTypes.Validator<number>;
|
|
270
|
+
translateWithId: PropTypes.Requireable<(...args: any[]) => any>;
|
|
271
|
+
};
|
|
272
|
+
};
|
|
262
273
|
TableBody: {
|
|
263
274
|
({ children, className, ...rest }: import("./TableBody").TableBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
264
275
|
propTypes: {
|
|
@@ -454,9 +465,7 @@ export declare const DataTable: {
|
|
|
454
465
|
*/
|
|
455
466
|
stickyHeader: PropTypes.Requireable<boolean>;
|
|
456
467
|
/**
|
|
457
|
-
*
|
|
458
|
-
* internationalized string. See `DataTable.translationKeys` for all
|
|
459
|
-
* available message IDs.
|
|
468
|
+
* Translates component strings using your i18n tool.
|
|
460
469
|
*/
|
|
461
470
|
translateWithId: PropTypes.Requireable<(...args: any[]) => any>;
|
|
462
471
|
/**
|
|
@@ -42,15 +42,15 @@ var TableToolbarMenu = require('./TableToolbarMenu.js');
|
|
|
42
42
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
43
43
|
|
|
44
44
|
const getInstanceId = setupGetInstanceId.setupGetInstanceId();
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
const translationIds = {
|
|
46
|
+
'carbon.table.row.expand': 'carbon.table.row.expand',
|
|
47
|
+
'carbon.table.row.collapse': 'carbon.table.row.collapse',
|
|
48
|
+
'carbon.table.all.expand': 'carbon.table.all.expand',
|
|
49
|
+
'carbon.table.all.collapse': 'carbon.table.all.collapse',
|
|
50
|
+
'carbon.table.all.select': 'carbon.table.all.select',
|
|
51
|
+
'carbon.table.all.unselect': 'carbon.table.all.unselect',
|
|
52
|
+
'carbon.table.row.select': 'carbon.table.row.select',
|
|
53
|
+
'carbon.table.row.unselect': 'carbon.table.row.unselect'
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
/**
|
|
@@ -58,26 +58,28 @@ const translationKeys = {
|
|
|
58
58
|
*/
|
|
59
59
|
|
|
60
60
|
const defaultTranslations = {
|
|
61
|
-
[
|
|
62
|
-
[
|
|
63
|
-
[
|
|
64
|
-
[
|
|
65
|
-
[
|
|
66
|
-
[
|
|
67
|
-
[
|
|
68
|
-
[
|
|
61
|
+
[translationIds['carbon.table.all.expand']]: 'Expand all rows',
|
|
62
|
+
[translationIds['carbon.table.all.collapse']]: 'Collapse all rows',
|
|
63
|
+
[translationIds['carbon.table.row.expand']]: 'Expand current row',
|
|
64
|
+
[translationIds['carbon.table.row.collapse']]: 'Collapse current row',
|
|
65
|
+
[translationIds['carbon.table.all.select']]: 'Select all rows',
|
|
66
|
+
[translationIds['carbon.table.all.unselect']]: 'Unselect all rows',
|
|
67
|
+
[translationIds['carbon.table.row.select']]: 'Select row',
|
|
68
|
+
[translationIds['carbon.table.row.unselect']]: 'Unselect row'
|
|
69
|
+
};
|
|
70
|
+
const defaultTranslateWithId = messageId => {
|
|
71
|
+
return defaultTranslations[messageId];
|
|
69
72
|
};
|
|
70
|
-
const translateWithId = id => defaultTranslations[id];
|
|
71
73
|
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
73
75
|
|
|
74
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
75
77
|
|
|
76
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
77
79
|
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
79
81
|
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
81
83
|
|
|
82
84
|
/**
|
|
83
85
|
* DataTable components are used to represent a collection of resources,
|
|
@@ -87,14 +89,14 @@ const translateWithId = id => defaultTranslations[id];
|
|
|
87
89
|
* the DataTable is accessible through look-up by ID, and updating the state of
|
|
88
90
|
* a single entity cascades updates to the consumer.
|
|
89
91
|
*/
|
|
90
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
91
93
|
const DataTable = props => {
|
|
92
94
|
const {
|
|
93
95
|
children,
|
|
94
96
|
filterRows = filter.defaultFilterRows,
|
|
95
97
|
headers,
|
|
96
98
|
render,
|
|
97
|
-
translateWithId: t =
|
|
99
|
+
translateWithId: t = defaultTranslateWithId,
|
|
98
100
|
size,
|
|
99
101
|
isSortable: isSortableProp,
|
|
100
102
|
useZebraStyles,
|
|
@@ -130,7 +132,7 @@ const DataTable = props => {
|
|
|
130
132
|
if (hasRowIdsChanged || hasHeadersChanged || hasRowsChanged) {
|
|
131
133
|
setState(prev => getDerivedStateFromProps.default(props, prev));
|
|
132
134
|
}
|
|
133
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
135
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
134
136
|
}, [headers, rows]);
|
|
135
137
|
const getHeaderProps = ({
|
|
136
138
|
header,
|
|
@@ -183,7 +185,7 @@ const DataTable = props => {
|
|
|
183
185
|
rowsById
|
|
184
186
|
} = state;
|
|
185
187
|
const isExpanded = isExpandedAll || rowIds.every(id => rowsById[id].isExpanded);
|
|
186
|
-
const translationKey = isExpanded ?
|
|
188
|
+
const translationKey = isExpanded ? translationIds['carbon.table.all.collapse'] : translationIds['carbon.table.all.expand'];
|
|
187
189
|
const handlers = [handleOnExpandAll, onExpand];
|
|
188
190
|
if (onClick) {
|
|
189
191
|
handlers.push(handleOnExpandHeaderClick(onClick, {
|
|
@@ -218,7 +220,7 @@ const DataTable = props => {
|
|
|
218
220
|
onClick,
|
|
219
221
|
...rest
|
|
220
222
|
}) => {
|
|
221
|
-
const translationKey = row.isExpanded ?
|
|
223
|
+
const translationKey = row.isExpanded ? translationIds['carbon.table.row.collapse'] : translationIds['carbon.table.row.expand'];
|
|
222
224
|
return {
|
|
223
225
|
...rest,
|
|
224
226
|
key: row.id,
|
|
@@ -253,7 +255,7 @@ const DataTable = props => {
|
|
|
253
255
|
} = {}) => {
|
|
254
256
|
// If we're given a row, return the selection state values for that row
|
|
255
257
|
if (row) {
|
|
256
|
-
const translationKey = row.isSelected ?
|
|
258
|
+
const translationKey = row.isSelected ? translationIds['carbon.table.row.unselect'] : translationIds['carbon.table.row.select'];
|
|
257
259
|
return {
|
|
258
260
|
...rest,
|
|
259
261
|
checked: row.isSelected,
|
|
@@ -272,7 +274,7 @@ const DataTable = props => {
|
|
|
272
274
|
const selectedRowCount = selectedRows.length;
|
|
273
275
|
const checked = rowCount > 0 && selectedRowCount === rowCount;
|
|
274
276
|
const indeterminate = rowCount > 0 && selectedRowCount > 0 && selectedRowCount !== rowCount;
|
|
275
|
-
const translationKey = checked || indeterminate ?
|
|
277
|
+
const translationKey = checked || indeterminate ? translationIds['carbon.table.all.unselect'] : translationIds['carbon.table.all.select'];
|
|
276
278
|
return {
|
|
277
279
|
...rest,
|
|
278
280
|
'aria-label': t(translationKey),
|
|
@@ -554,7 +556,6 @@ const DataTable = props => {
|
|
|
554
556
|
}
|
|
555
557
|
return null;
|
|
556
558
|
};
|
|
557
|
-
DataTable.translationKeys = Object.values(translationKeys);
|
|
558
559
|
DataTable.Table = Table.Table;
|
|
559
560
|
DataTable.TableActionList = TableActionList.default;
|
|
560
561
|
DataTable.TableBatchAction = TableBatchAction.default;
|
|
@@ -650,9 +651,7 @@ DataTable.propTypes = {
|
|
|
650
651
|
*/
|
|
651
652
|
stickyHeader: PropTypes.bool,
|
|
652
653
|
/**
|
|
653
|
-
*
|
|
654
|
-
* internationalized string. See `DataTable.translationKeys` for all
|
|
655
|
-
* available message IDs.
|
|
654
|
+
* Translates component strings using your i18n tool.
|
|
656
655
|
*/
|
|
657
656
|
translateWithId: PropTypes.func,
|
|
658
657
|
/**
|
|
@@ -76,11 +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/
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
80
80
|
alignTop ? tableRef.current?.classList.add(`${prefix}--data-table--top-aligned-body`) : tableRef.current?.classList.remove(`${prefix}--data-table--top-aligned-body`);
|
|
81
81
|
}, [prefix]);
|
|
82
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/
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
84
84
|
alignTop ? tableRef.current?.classList.add(`${prefix}--data-table--top-aligned-header`) : tableRef.current?.classList.remove(`${prefix}--data-table--top-aligned-header`);
|
|
85
85
|
}, [prefix]);
|
|
86
86
|
const setTableAlignment = React.useCallback(() => {
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
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 PropTypes from 'prop-types';
|
|
7
8
|
import React, { type MouseEventHandler } from 'react';
|
|
8
9
|
import type { TranslateWithId } from '../../types/common';
|
|
9
|
-
declare const
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
declare const translationIds: {
|
|
11
|
+
readonly 'carbon.table.batch.cancel': "carbon.table.batch.cancel";
|
|
12
|
+
readonly 'carbon.table.batch.items.selected': "carbon.table.batch.items.selected";
|
|
13
|
+
readonly 'carbon.table.batch.item.selected': "carbon.table.batch.item.selected";
|
|
14
|
+
readonly 'carbon.table.batch.selectAll': "carbon.table.batch.selectAll";
|
|
15
|
+
};
|
|
16
|
+
type TranslationKey = keyof typeof translationIds;
|
|
17
|
+
export type TableBatchActionsTranslationArgs = {
|
|
12
18
|
totalSelected?: number;
|
|
13
19
|
totalCount?: number;
|
|
14
|
-
}
|
|
15
|
-
export interface TableBatchActionsProps extends React.HTMLAttributes<HTMLDivElement>, TranslateWithId<
|
|
20
|
+
};
|
|
21
|
+
export interface TableBatchActionsProps extends React.HTMLAttributes<HTMLDivElement>, TranslateWithId<TranslationKey, TableBatchActionsTranslationArgs> {
|
|
16
22
|
/**
|
|
17
23
|
* Provide elements to be rendered inside of the component.
|
|
18
24
|
*/
|
|
@@ -44,8 +50,41 @@ export interface TableBatchActionsProps extends React.HTMLAttributes<HTMLDivElem
|
|
|
44
50
|
*/
|
|
45
51
|
totalCount?: number;
|
|
46
52
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
declare const TableBatchActions: {
|
|
54
|
+
({ className, children, shouldShowBatchActions, totalSelected, totalCount, onCancel, onSelectAll, translateWithId: t, ...rest }: TableBatchActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
propTypes: {
|
|
56
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
57
|
+
className: PropTypes.Requireable<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Hook required to listen for when the user initiates a cancel request
|
|
60
|
+
* through this component
|
|
61
|
+
*/
|
|
62
|
+
onCancel: PropTypes.Validator<(...args: any[]) => any>;
|
|
63
|
+
/**
|
|
64
|
+
* Hook to listen for when the user initiates a select all
|
|
65
|
+
* request through this component. This _only_ controls the rendering
|
|
66
|
+
* of the `Select All` button and does not include built in functionality
|
|
67
|
+
*/
|
|
68
|
+
onSelectAll: PropTypes.Requireable<(...args: any[]) => any>;
|
|
69
|
+
/**
|
|
70
|
+
* Boolean specifier for whether or not the batch action bar should be
|
|
71
|
+
* displayed
|
|
72
|
+
*/
|
|
73
|
+
shouldShowBatchActions: PropTypes.Requireable<boolean>;
|
|
74
|
+
/**
|
|
75
|
+
* Numeric representation of the total number of items in a table.
|
|
76
|
+
* This number is used in the select all button text
|
|
77
|
+
*/
|
|
78
|
+
totalCount: PropTypes.Requireable<number>;
|
|
79
|
+
/**
|
|
80
|
+
* Numeric representation of the total number of items selected in a table.
|
|
81
|
+
* This number is used to derive the selection message
|
|
82
|
+
*/
|
|
83
|
+
totalSelected: PropTypes.Validator<number>;
|
|
84
|
+
/**
|
|
85
|
+
* Translates component strings using your i18n tool.
|
|
86
|
+
*/
|
|
87
|
+
translateWithId: PropTypes.Requireable<(...args: any[]) => any>;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
51
90
|
export default TableBatchActions;
|
|
@@ -20,27 +20,35 @@ var Text = require('../Text/Text.js');
|
|
|
20
20
|
require('../Text/TextDirection.js');
|
|
21
21
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
22
22
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
'carbon.table.batch.
|
|
26
|
-
'carbon.table.batch.
|
|
27
|
-
'carbon.table.batch.
|
|
28
|
-
'carbon.table.batch.selectAll': 'Select all'
|
|
23
|
+
const translationIds = {
|
|
24
|
+
'carbon.table.batch.cancel': 'carbon.table.batch.cancel',
|
|
25
|
+
'carbon.table.batch.items.selected': 'carbon.table.batch.items.selected',
|
|
26
|
+
'carbon.table.batch.item.selected': 'carbon.table.batch.item.selected',
|
|
27
|
+
'carbon.table.batch.selectAll': 'carbon.table.batch.selectAll'
|
|
29
28
|
};
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
const defaultTranslations = {
|
|
30
|
+
[translationIds['carbon.table.batch.cancel']]: 'Cancel',
|
|
31
|
+
[translationIds['carbon.table.batch.items.selected']]: 'items selected',
|
|
32
|
+
[translationIds['carbon.table.batch.item.selected']]: 'item selected',
|
|
33
|
+
[translationIds['carbon.table.batch.selectAll']]: 'Select all'
|
|
34
|
+
};
|
|
35
|
+
const defaultTranslateWithId = (messageId, args = {
|
|
34
36
|
totalSelected: 0,
|
|
35
37
|
totalCount: 0
|
|
36
38
|
}) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const {
|
|
40
|
+
totalSelected,
|
|
41
|
+
totalCount
|
|
42
|
+
} = args;
|
|
43
|
+
switch (messageId) {
|
|
44
|
+
case translationIds['carbon.table.batch.cancel']:
|
|
45
|
+
return defaultTranslations[messageId];
|
|
46
|
+
case translationIds['carbon.table.batch.selectAll']:
|
|
47
|
+
return `${defaultTranslations[messageId]} (${totalCount})`;
|
|
48
|
+
case translationIds['carbon.table.batch.items.selected']:
|
|
49
|
+
case translationIds['carbon.table.batch.item.selected']:
|
|
50
|
+
return `${totalSelected} ${defaultTranslations[messageId]}`;
|
|
42
51
|
}
|
|
43
|
-
return `${totalSelected} ${translationKeys[id]}`;
|
|
44
52
|
};
|
|
45
53
|
const TableBatchActions = ({
|
|
46
54
|
className,
|
|
@@ -50,7 +58,7 @@ const TableBatchActions = ({
|
|
|
50
58
|
totalCount,
|
|
51
59
|
onCancel,
|
|
52
60
|
onSelectAll,
|
|
53
|
-
translateWithId: t =
|
|
61
|
+
translateWithId: t = defaultTranslateWithId,
|
|
54
62
|
...rest
|
|
55
63
|
}) => {
|
|
56
64
|
const [isScrolling, setIsScrolling] = React.useState(false);
|
|
@@ -89,7 +97,6 @@ const TableBatchActions = ({
|
|
|
89
97
|
onClick: onCancel
|
|
90
98
|
}, t('carbon.table.batch.cancel'))));
|
|
91
99
|
};
|
|
92
|
-
TableBatchActions.translationKeys = TableBatchActionsTranslationKeys;
|
|
93
100
|
TableBatchActions.propTypes = {
|
|
94
101
|
children: PropTypes.node,
|
|
95
102
|
className: PropTypes.string,
|
|
@@ -120,9 +127,7 @@ TableBatchActions.propTypes = {
|
|
|
120
127
|
*/
|
|
121
128
|
totalSelected: PropTypes.number.isRequired,
|
|
122
129
|
/**
|
|
123
|
-
*
|
|
124
|
-
* choice. Translation keys are available on the `translationKeys` field for
|
|
125
|
-
* this component.
|
|
130
|
+
* Translates component strings using your i18n tool.
|
|
126
131
|
*/
|
|
127
132
|
translateWithId: PropTypes.func
|
|
128
133
|
};
|
|
@@ -96,9 +96,9 @@ TableExpandHeader.propTypes = {
|
|
|
96
96
|
* Hook for when a listener initiates a request to expand the given row
|
|
97
97
|
*/
|
|
98
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/
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
100
100
|
), requiredIfGivenPropIsTruthy.requiredIfGivenPropIsTruthy('enableToggle', PropTypes.func
|
|
101
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
102
102
|
)])
|
|
103
103
|
};
|
|
104
104
|
|
|
@@ -96,7 +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/
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
100
100
|
/**@ts-ignore*/
|
|
101
101
|
'aria-label': PropTypes.string,
|
|
102
102
|
/**
|
|
@@ -5,21 +5,19 @@
|
|
|
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 { TranslateWithId } from '../../types/common';
|
|
8
|
+
import type { TranslateWithId } from '../../types/common';
|
|
9
9
|
import { sortStates, type DataTableSortState } from './state/sortStates';
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
declare const translationIds: {
|
|
11
|
+
readonly 'carbon.table.header.icon.description': "carbon.table.header.icon.description";
|
|
12
|
+
};
|
|
13
|
+
type TranslationKey = keyof typeof translationIds;
|
|
14
|
+
interface TableHeaderTranslationArgs {
|
|
12
15
|
header: ReactNode;
|
|
13
16
|
isSortHeader?: boolean;
|
|
14
17
|
sortDirection?: DataTableSortState;
|
|
15
18
|
sortStates: typeof sortStates;
|
|
16
19
|
}
|
|
17
|
-
export interface TableHeaderProps extends HTMLAttributes<HTMLTableCellElement & HTMLButtonElement>, TranslateWithId<
|
|
18
|
-
header: any;
|
|
19
|
-
sortDirection: any;
|
|
20
|
-
isSortHeader: any;
|
|
21
|
-
sortStates: any;
|
|
22
|
-
}> {
|
|
20
|
+
export interface TableHeaderProps extends HTMLAttributes<HTMLTableCellElement & HTMLButtonElement>, TranslateWithId<TranslationKey, TableHeaderTranslationArgs> {
|
|
23
21
|
/**
|
|
24
22
|
* Pass in children that will be embedded in the table header label
|
|
25
23
|
*/
|
|
@@ -69,7 +67,7 @@ export interface TableHeaderProps extends HTMLAttributes<HTMLTableCellElement &
|
|
|
69
67
|
* Specify which direction we are currently sorting by, should be one of DESC,
|
|
70
68
|
* NONE, or ASC.
|
|
71
69
|
*/
|
|
72
|
-
sortDirection?:
|
|
70
|
+
sortDirection?: DataTableSortState;
|
|
73
71
|
}
|
|
74
72
|
declare const TableHeader: React.ForwardRefExoticComponent<TableHeaderProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
75
73
|
export default TableHeader;
|
|
@@ -21,11 +21,14 @@ var index = require('../AILabel/index.js');
|
|
|
21
21
|
var utils = require('../../internal/utils.js');
|
|
22
22
|
|
|
23
23
|
const defaultScope = 'col';
|
|
24
|
-
const
|
|
25
|
-
|
|
24
|
+
const translationIds = {
|
|
25
|
+
'carbon.table.header.icon.description': 'carbon.table.header.icon.description'
|
|
26
26
|
};
|
|
27
|
-
const
|
|
28
|
-
|
|
27
|
+
const defaultTranslations = {
|
|
28
|
+
[translationIds['carbon.table.header.icon.description']]: 'Click to sort rows by header in ascending order'
|
|
29
|
+
};
|
|
30
|
+
const defaultTranslateWithId = (messageId, args) => {
|
|
31
|
+
if (args && messageId === translationIds['carbon.table.header.icon.description']) {
|
|
29
32
|
if (args.isSortHeader && sortStates.sortStates) {
|
|
30
33
|
// When transitioning, we know that the sequence of states is as follows:
|
|
31
34
|
// NONE -> ASC -> DESC -> NONE
|
|
@@ -39,7 +42,7 @@ const translateWithId = (key, args) => {
|
|
|
39
42
|
}
|
|
40
43
|
return `Click to sort rows by ${args.header} header in ascending order`;
|
|
41
44
|
}
|
|
42
|
-
return
|
|
45
|
+
return defaultTranslations[messageId];
|
|
43
46
|
};
|
|
44
47
|
const sortDirections = {
|
|
45
48
|
[sortStates.sortStates.NONE]: 'none',
|
|
@@ -56,7 +59,7 @@ const TableHeader = /*#__PURE__*/React.forwardRef(function TableHeader({
|
|
|
56
59
|
onClick,
|
|
57
60
|
scope = defaultScope,
|
|
58
61
|
sortDirection,
|
|
59
|
-
translateWithId: t =
|
|
62
|
+
translateWithId: t = defaultTranslateWithId,
|
|
60
63
|
slug,
|
|
61
64
|
id,
|
|
62
65
|
...rest
|
|
@@ -72,7 +75,7 @@ const TableHeader = /*#__PURE__*/React.forwardRef(function TableHeader({
|
|
|
72
75
|
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
|
|
73
76
|
size: 'mini',
|
|
74
77
|
ref: AILableRef
|
|
75
|
-
}) :
|
|
78
|
+
}) : candidate;
|
|
76
79
|
const headerLabelClassNames = cx({
|
|
77
80
|
[`${prefix}--table-header-label`]: true,
|
|
78
81
|
[`${prefix}--table-header-label--slug ${prefix}--table-header-label--ai-label`]: colHasAILabel,
|
|
@@ -186,15 +189,10 @@ TableHeader.propTypes = {
|
|
|
186
189
|
*/
|
|
187
190
|
sortDirection: PropTypes.oneOf(Object.values(sortStates.sortStates)),
|
|
188
191
|
/**
|
|
189
|
-
*
|
|
190
|
-
* choice. Translation keys are available on the `translationKeys` field for
|
|
191
|
-
* this component.
|
|
192
|
+
* Translates component strings using your i18n tool.
|
|
192
193
|
*/
|
|
193
194
|
translateWithId: PropTypes.func
|
|
194
195
|
};
|
|
195
|
-
|
|
196
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
197
|
-
TableHeader.translationKeys = Object.values(translationKeys);
|
|
198
196
|
TableHeader.displayName = 'TableHeader';
|
|
199
197
|
|
|
200
198
|
exports.default = TableHeader;
|