@carbon/react 1.92.1 → 1.93.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 +874 -838
- 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/CodeSnippet/CodeSnippet.js +9 -50
- 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 +19 -25
- package/es/components/DataTable/DataTable.d.ts +27 -16
- package/es/components/DataTable/DataTable.js +40 -39
- 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.d.ts +4 -0
- 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 +7 -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 +17 -23
- 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 +10 -9
- 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/CodeSnippet/CodeSnippet.js +8 -49
- 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 +18 -24
- package/lib/components/DataTable/DataTable.d.ts +27 -16
- package/lib/components/DataTable/DataTable.js +40 -39
- 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.d.ts +4 -0
- 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 +7 -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 +16 -22
- 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 +10 -9
- 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
|
@@ -97,15 +97,6 @@ const findHighlightedIndex = ({
|
|
|
97
97
|
}
|
|
98
98
|
return -1;
|
|
99
99
|
};
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Message ids that will be passed to translateWithId().
|
|
103
|
-
* Combination of message ids from ListBox/next/ListBoxSelection.js and
|
|
104
|
-
* ListBox/next/ListBoxTrigger.js, but we can't access those values directly
|
|
105
|
-
* because those components aren't Typescript. (If you try, TranslationKey
|
|
106
|
-
* ends up just being defined as "string".)
|
|
107
|
-
*/
|
|
108
|
-
|
|
109
100
|
const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
110
101
|
const prevInputLengthRef = React.useRef(0);
|
|
111
102
|
const inputRef = React.useRef(null);
|
|
@@ -173,7 +164,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
173
164
|
refs.floating.current.style.width = parentWidth + 'px';
|
|
174
165
|
}
|
|
175
166
|
}
|
|
176
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
167
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
177
168
|
}, [enableFloatingStyles, floatingStyles, refs.floating, parentWidth]);
|
|
178
169
|
const [inputValue, setInputValue] = React.useState(getInputValue({
|
|
179
170
|
initialSelectedItem,
|
|
@@ -203,7 +194,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
203
194
|
}
|
|
204
195
|
prevInputLengthRef.current = inputValue.length;
|
|
205
196
|
}
|
|
206
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
197
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
207
198
|
}, [typeahead, inputValue, items, itemToString, autocompleteCustomFilter]);
|
|
208
199
|
const isManualClearingRef = React.useRef(false);
|
|
209
200
|
const [isClearing, setIsClearing] = React.useState(false);
|
|
@@ -244,7 +235,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
244
235
|
}
|
|
245
236
|
prevSelectedItemProp.current = selectedItemProp;
|
|
246
237
|
}
|
|
247
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
238
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
248
239
|
}, [selectedItemProp]);
|
|
249
240
|
const filterItems = (items, itemToString, inputValue) => items.filter(item => typeahead ? autocompleteCustomFilter({
|
|
250
241
|
item: itemToString(item),
|
|
@@ -259,10 +250,10 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
259
250
|
React.useEffect(() => {
|
|
260
251
|
if (prevInputValue.current !== inputValue) {
|
|
261
252
|
prevInputValue.current = inputValue;
|
|
262
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/
|
|
253
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
263
254
|
onInputChange && onInputChange(inputValue);
|
|
264
255
|
}
|
|
265
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
256
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
266
257
|
}, [inputValue]);
|
|
267
258
|
const handleSelectionClear = () => {
|
|
268
259
|
if (textInput?.current) {
|
|
@@ -331,7 +322,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
331
322
|
const filteredList = filterItems(items, itemToString, inputValue);
|
|
332
323
|
const highlightedItem = filteredList[state.highlightedIndex];
|
|
333
324
|
|
|
334
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
325
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
335
326
|
if (highlightedItem && !highlightedItem.disabled) {
|
|
336
327
|
return {
|
|
337
328
|
...changes,
|
|
@@ -344,7 +335,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
344
335
|
if (autoIndex !== -1) {
|
|
345
336
|
const matchingItem = items[autoIndex];
|
|
346
337
|
|
|
347
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
338
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
348
339
|
if (matchingItem && !matchingItem.disabled) {
|
|
349
340
|
return {
|
|
350
341
|
...changes,
|
|
@@ -462,7 +453,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
462
453
|
const candidateIsAILabel = utils.isComponentElement(candidate, index$1.AILabel);
|
|
463
454
|
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
|
|
464
455
|
size: 'mini'
|
|
465
|
-
}) :
|
|
456
|
+
}) : candidate;
|
|
466
457
|
const {
|
|
467
458
|
// Prop getters
|
|
468
459
|
getInputProps,
|
|
@@ -498,10 +489,10 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
498
489
|
onHighlightedIndexChange: ({
|
|
499
490
|
highlightedIndex
|
|
500
491
|
}) => {
|
|
501
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion , valid-typeof , no-constant-binary-expression -- https://github.com/carbon-design-system/carbon/issues/
|
|
492
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion , valid-typeof , no-constant-binary-expression -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
502
493
|
if (highlightedIndex > -1 && typeof window !== undefined) {
|
|
503
494
|
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
504
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/
|
|
495
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
505
496
|
const highlightedItem = itemArray[highlightedIndex];
|
|
506
497
|
if (highlightedItem) {
|
|
507
498
|
highlightedItem.scrollIntoView({
|
|
@@ -514,9 +505,9 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
514
505
|
initialSelectedItem: initialSelectedItem,
|
|
515
506
|
inputId: id,
|
|
516
507
|
stateReducer,
|
|
517
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/
|
|
508
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
518
509
|
isItemDisabled(item, _index) {
|
|
519
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
510
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
520
511
|
return item?.disabled;
|
|
521
512
|
},
|
|
522
513
|
...downshiftProps,
|
|
@@ -553,7 +544,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
553
544
|
toggleMenu
|
|
554
545
|
};
|
|
555
546
|
}
|
|
556
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
547
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
557
548
|
}, [closeMenu, openMenu, reset, selectItem, setHighlightedIndex, downshiftSetInputValue, toggleMenu]);
|
|
558
549
|
const buttonProps = getToggleButtonProps({
|
|
559
550
|
disabled: disabled || readOnly,
|
|
@@ -603,7 +594,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
603
594
|
const menuProps = React.useMemo(() => getMenuProps({
|
|
604
595
|
ref: enableFloatingStyles ? refs.setFloating : null
|
|
605
596
|
}),
|
|
606
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
597
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
607
598
|
[enableFloatingStyles, deprecatedAriaLabel, ariaLabel, getMenuProps, refs.setFloating]);
|
|
608
599
|
React.useEffect(() => {
|
|
609
600
|
if (textInput.current) {
|
|
@@ -937,8 +928,7 @@ ComboBox.propTypes = {
|
|
|
937
928
|
*/
|
|
938
929
|
titleText: PropTypes.node,
|
|
939
930
|
/**
|
|
940
|
-
*
|
|
941
|
-
* and returns the localized string for the message
|
|
931
|
+
* Translates component strings using your i18n tool.
|
|
942
932
|
*/
|
|
943
933
|
translateWithId: PropTypes.func,
|
|
944
934
|
/**
|
|
@@ -9,14 +9,11 @@ import { IconButton } from '../IconButton';
|
|
|
9
9
|
import Button from '../Button';
|
|
10
10
|
import { Menu } from '../Menu';
|
|
11
11
|
import { MenuAlignment } from '../MenuButton';
|
|
12
|
-
import { TranslateWithId } from '../../types/common';
|
|
13
|
-
declare const
|
|
14
|
-
'carbon.combo-button.additional-actions':
|
|
12
|
+
import type { TranslateWithId } from '../../types/common';
|
|
13
|
+
declare const translationIds: {
|
|
14
|
+
readonly 'carbon.combo-button.additional-actions': "carbon.combo-button.additional-actions";
|
|
15
15
|
};
|
|
16
|
-
|
|
17
|
-
* Message ids that will be passed to translateWithId().
|
|
18
|
-
*/
|
|
19
|
-
export type TranslationKey = keyof typeof defaultTranslations;
|
|
16
|
+
type TranslationKey = keyof typeof translationIds;
|
|
20
17
|
interface ComboButtonProps extends TranslateWithId<TranslationKey> {
|
|
21
18
|
/**
|
|
22
19
|
* A collection of `MenuItems` to be rendered as additional actions for this `ComboButton`.
|
|
@@ -45,7 +42,7 @@ interface ComboButtonProps extends TranslateWithId<TranslationKey> {
|
|
|
45
42
|
/**
|
|
46
43
|
* Specify the size of the buttons and menu.
|
|
47
44
|
*/
|
|
48
|
-
size?: 'sm' | 'md' | 'lg';
|
|
45
|
+
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
49
46
|
/**
|
|
50
47
|
* Specify how the trigger tooltip should be aligned.
|
|
51
48
|
*/
|
|
@@ -27,17 +27,15 @@ var deprecateValuesWithin = require('../../prop-types/deprecateValuesWithin.js')
|
|
|
27
27
|
var mapPopoverAlign = require('../../tools/mapPopoverAlign.js');
|
|
28
28
|
|
|
29
29
|
var _ChevronDown;
|
|
30
|
+
const translationIds = {
|
|
31
|
+
'carbon.combo-button.additional-actions': 'carbon.combo-button.additional-actions'
|
|
32
|
+
};
|
|
30
33
|
const defaultTranslations = {
|
|
31
|
-
'carbon.combo-button.additional-actions': 'Additional actions'
|
|
34
|
+
[translationIds['carbon.combo-button.additional-actions']]: 'Additional actions'
|
|
32
35
|
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Message ids that will be passed to translateWithId().
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
function defaultTranslateWithId(messageId) {
|
|
36
|
+
const defaultTranslateWithId = messageId => {
|
|
39
37
|
return defaultTranslations[messageId];
|
|
40
|
-
}
|
|
38
|
+
};
|
|
41
39
|
const ComboButton = /*#__PURE__*/React.forwardRef(function ComboButton({
|
|
42
40
|
children,
|
|
43
41
|
className,
|
|
@@ -56,7 +54,7 @@ const ComboButton = /*#__PURE__*/React.forwardRef(function ComboButton({
|
|
|
56
54
|
const id = useId.useId('combobutton');
|
|
57
55
|
const prefix = usePrefix.usePrefix();
|
|
58
56
|
const containerRef = React.useRef(null);
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
60
58
|
let middlewares = [];
|
|
61
59
|
if (!enableOnlyFloatingStyles) {
|
|
62
60
|
middlewares = [react.flip({
|
|
@@ -188,7 +186,7 @@ ComboButton.propTypes = {
|
|
|
188
186
|
/**
|
|
189
187
|
* Specify the size of the buttons and menu.
|
|
190
188
|
*/
|
|
191
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
189
|
+
size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg']),
|
|
192
190
|
/**
|
|
193
191
|
* Specify how the trigger tooltip should be aligned.
|
|
194
192
|
*/
|
|
@@ -215,8 +213,7 @@ ComboButton.propTypes = {
|
|
|
215
213
|
// new values to match floating-ui
|
|
216
214
|
'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']), ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'], mapPopoverAlign.mapPopoverAlign),
|
|
217
215
|
/**
|
|
218
|
-
*
|
|
219
|
-
* internationalized string.
|
|
216
|
+
* Translates component strings using your i18n tool.
|
|
220
217
|
*/
|
|
221
218
|
translateWithId: PropTypes.func
|
|
222
219
|
};
|
|
@@ -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(() => {
|
|
@@ -309,7 +303,7 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
|
|
|
309
303
|
return () => {
|
|
310
304
|
document.removeEventListener('keydown', handleEscapeKey, true);
|
|
311
305
|
};
|
|
312
|
-
// 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
|
|
313
307
|
}, [open]);
|
|
314
308
|
React.useEffect(() => {
|
|
315
309
|
if (!enableDialogElement && !enablePresence && !open && launcherButtonRef) {
|
|
@@ -352,7 +346,7 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
|
|
|
352
346
|
focusButton(innerModal.current);
|
|
353
347
|
}
|
|
354
348
|
}
|
|
355
|
-
// 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
|
|
356
350
|
}, [open, selectorPrimaryFocus, isOpen]);
|
|
357
351
|
|
|
358
352
|
// AILabel is always size `sm`
|
|
@@ -360,7 +354,7 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
|
|
|
360
354
|
const candidateIsAILabel = utils.isComponentElement(candidate, index$2.AILabel);
|
|
361
355
|
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
|
|
362
356
|
size: 'sm'
|
|
363
|
-
}) :
|
|
357
|
+
}) : candidate;
|
|
364
358
|
const modalBody = enableDialogElement ? /*#__PURE__*/React.createElement(Dialog.Dialog, {
|
|
365
359
|
open: open,
|
|
366
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;
|
|
@@ -92,6 +92,7 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
|
|
|
92
92
|
isExpanded: boolean;
|
|
93
93
|
onExpand: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
94
94
|
[key: string]: unknown;
|
|
95
|
+
id: string;
|
|
95
96
|
};
|
|
96
97
|
getRowProps: (options: {
|
|
97
98
|
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
@@ -105,6 +106,7 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
|
|
|
105
106
|
key: string;
|
|
106
107
|
onExpand: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
107
108
|
[key: string]: unknown;
|
|
109
|
+
expandHeader: string;
|
|
108
110
|
};
|
|
109
111
|
getExpandedRowProps: (options: {
|
|
110
112
|
row: DataTableRow<ColTypes>;
|
|
@@ -233,7 +235,6 @@ export interface DataTableProps<RowType, ColTypes extends any[]> extends Transla
|
|
|
233
235
|
*/
|
|
234
236
|
export declare const DataTable: {
|
|
235
237
|
<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
238
|
Table: {
|
|
238
239
|
({ className, children, useZebraStyles, size, isSortable, useStaticWidth, stickyHeader, overflowMenuOnHover, experimentalAutoAlign, tabIndex, ...other }: React.PropsWithChildren<import("./Table").TableProps>): import("react/jsx-runtime").JSX.Element;
|
|
239
240
|
propTypes: {
|
|
@@ -258,7 +259,19 @@ export declare const DataTable: {
|
|
|
258
259
|
renderIcon: PropTypes.Requireable<object>;
|
|
259
260
|
};
|
|
260
261
|
};
|
|
261
|
-
TableBatchActions:
|
|
262
|
+
TableBatchActions: {
|
|
263
|
+
({ className, children, shouldShowBatchActions, totalSelected, totalCount, onCancel, onSelectAll, translateWithId: t, ...rest }: import("./TableBatchActions").TableBatchActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
264
|
+
propTypes: {
|
|
265
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
266
|
+
className: PropTypes.Requireable<string>;
|
|
267
|
+
onCancel: PropTypes.Validator<(...args: any[]) => any>;
|
|
268
|
+
onSelectAll: PropTypes.Requireable<(...args: any[]) => any>;
|
|
269
|
+
shouldShowBatchActions: PropTypes.Requireable<boolean>;
|
|
270
|
+
totalCount: PropTypes.Requireable<number>;
|
|
271
|
+
totalSelected: PropTypes.Validator<number>;
|
|
272
|
+
translateWithId: PropTypes.Requireable<(...args: any[]) => any>;
|
|
273
|
+
};
|
|
274
|
+
};
|
|
262
275
|
TableBody: {
|
|
263
276
|
({ children, className, ...rest }: import("./TableBody").TableBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
264
277
|
propTypes: {
|
|
@@ -454,9 +467,7 @@ export declare const DataTable: {
|
|
|
454
467
|
*/
|
|
455
468
|
stickyHeader: PropTypes.Requireable<boolean>;
|
|
456
469
|
/**
|
|
457
|
-
*
|
|
458
|
-
* internationalized string. See `DataTable.translationKeys` for all
|
|
459
|
-
* available message IDs.
|
|
470
|
+
* Translates component strings using your i18n tool.
|
|
460
471
|
*/
|
|
461
472
|
translateWithId: PropTypes.Requireable<(...args: any[]) => any>;
|
|
462
473
|
/**
|
|
@@ -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, {
|
|
@@ -194,9 +196,10 @@ const DataTable = props => {
|
|
|
194
196
|
...rest,
|
|
195
197
|
'aria-label': t(translationKey),
|
|
196
198
|
// Provide a string of all expanded row IDs, separated by a space.
|
|
197
|
-
'aria-controls': rowIds.map(id =>
|
|
199
|
+
'aria-controls': rowIds.map(id => `${getTablePrefix()}-expanded-row-${id}`).join(' '),
|
|
198
200
|
isExpanded,
|
|
199
|
-
onExpand: events.composeEventHandlers(handlers)
|
|
201
|
+
onExpand: events.composeEventHandlers(handlers),
|
|
202
|
+
id: `${getTablePrefix()}-expand`
|
|
200
203
|
};
|
|
201
204
|
};
|
|
202
205
|
|
|
@@ -218,7 +221,7 @@ const DataTable = props => {
|
|
|
218
221
|
onClick,
|
|
219
222
|
...rest
|
|
220
223
|
}) => {
|
|
221
|
-
const translationKey = row.isExpanded ?
|
|
224
|
+
const translationKey = row.isExpanded ? translationIds['carbon.table.row.collapse'] : translationIds['carbon.table.row.expand'];
|
|
222
225
|
return {
|
|
223
226
|
...rest,
|
|
224
227
|
key: row.id,
|
|
@@ -228,9 +231,10 @@ const DataTable = props => {
|
|
|
228
231
|
onExpand: events.composeEventHandlers([handleOnExpandRow(row.id), onClick]),
|
|
229
232
|
isExpanded: row.isExpanded,
|
|
230
233
|
'aria-label': t(translationKey),
|
|
231
|
-
'aria-controls':
|
|
234
|
+
'aria-controls': `${getTablePrefix()}-expanded-row-${row.id}`,
|
|
232
235
|
isSelected: row.isSelected,
|
|
233
|
-
disabled: row.disabled
|
|
236
|
+
disabled: row.disabled,
|
|
237
|
+
expandHeader: `${getTablePrefix()}-expand`
|
|
234
238
|
};
|
|
235
239
|
};
|
|
236
240
|
const getExpandedRowProps = ({
|
|
@@ -239,7 +243,7 @@ const DataTable = props => {
|
|
|
239
243
|
}) => {
|
|
240
244
|
return {
|
|
241
245
|
...rest,
|
|
242
|
-
id:
|
|
246
|
+
id: `${getTablePrefix()}-expanded-row-${row.id}`
|
|
243
247
|
};
|
|
244
248
|
};
|
|
245
249
|
|
|
@@ -253,7 +257,7 @@ const DataTable = props => {
|
|
|
253
257
|
} = {}) => {
|
|
254
258
|
// If we're given a row, return the selection state values for that row
|
|
255
259
|
if (row) {
|
|
256
|
-
const translationKey = row.isSelected ?
|
|
260
|
+
const translationKey = row.isSelected ? translationIds['carbon.table.row.unselect'] : translationIds['carbon.table.row.select'];
|
|
257
261
|
return {
|
|
258
262
|
...rest,
|
|
259
263
|
checked: row.isSelected,
|
|
@@ -272,7 +276,7 @@ const DataTable = props => {
|
|
|
272
276
|
const selectedRowCount = selectedRows.length;
|
|
273
277
|
const checked = rowCount > 0 && selectedRowCount === rowCount;
|
|
274
278
|
const indeterminate = rowCount > 0 && selectedRowCount > 0 && selectedRowCount !== rowCount;
|
|
275
|
-
const translationKey = checked || indeterminate ?
|
|
279
|
+
const translationKey = checked || indeterminate ? translationIds['carbon.table.all.unselect'] : translationIds['carbon.table.all.select'];
|
|
276
280
|
return {
|
|
277
281
|
...rest,
|
|
278
282
|
'aria-label': t(translationKey),
|
|
@@ -554,7 +558,6 @@ const DataTable = props => {
|
|
|
554
558
|
}
|
|
555
559
|
return null;
|
|
556
560
|
};
|
|
557
|
-
DataTable.translationKeys = Object.values(translationKeys);
|
|
558
561
|
DataTable.Table = Table.Table;
|
|
559
562
|
DataTable.TableActionList = TableActionList.default;
|
|
560
563
|
DataTable.TableBatchAction = TableBatchAction.default;
|
|
@@ -650,9 +653,7 @@ DataTable.propTypes = {
|
|
|
650
653
|
*/
|
|
651
654
|
stickyHeader: PropTypes.bool,
|
|
652
655
|
/**
|
|
653
|
-
*
|
|
654
|
-
* internationalized string. See `DataTable.translationKeys` for all
|
|
655
|
-
* available message IDs.
|
|
656
|
+
* Translates component strings using your i18n tool.
|
|
656
657
|
*/
|
|
657
658
|
translateWithId: PropTypes.func,
|
|
658
659
|
/**
|
|
@@ -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(() => {
|