@carbon/react 1.80.1 → 1.81.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 +785 -785
- package/es/components/Accordion/AccordionItem.d.ts +2 -2
- package/es/components/AspectRatio/AspectRatio.d.ts +2 -2
- package/es/components/Button/Button.js +3 -0
- package/es/components/Button/ButtonBase.d.ts +2 -2
- package/es/components/ChatButton/ChatButton.js +5 -3
- package/es/components/CodeSnippet/CodeSnippet.js +2 -0
- package/es/components/ComboBox/ComboBox.d.ts +1 -1
- package/es/components/ComboBox/ComboBox.js +52 -30
- package/es/components/ComposedModal/ComposedModal.d.ts +1 -1
- package/es/components/ComposedModal/ComposedModal.js +1 -2
- package/es/components/ComposedModal/ModalFooter.js +0 -1
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +0 -1
- package/es/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
- package/es/components/ContextMenu/useContextMenu.d.ts +1 -1
- package/es/components/DataTable/DataTable.d.ts +5 -5
- package/es/components/DataTable/DataTable.js +1 -1
- package/es/components/DataTable/TableActionList.d.ts +1 -1
- package/es/components/DataTable/TableCell.js +28 -4
- package/es/components/DataTable/TableExpandHeader.d.ts +1 -1
- package/es/components/DataTable/TableHead.d.ts +1 -1
- package/es/components/DataTable/TableToolbarContent.d.ts +1 -1
- package/es/components/DataTable/TableToolbarSearch.d.ts +1 -1
- package/es/components/DataTable/tools/cells.d.ts +13 -0
- package/es/components/DataTable/tools/cells.js +3 -6
- package/es/components/DataTable/tools/filter.d.ts +26 -0
- package/es/components/DataTable/tools/filter.js +8 -17
- package/es/components/DatePicker/DatePicker.js +1 -1
- package/es/components/DatePickerInput/DatePickerInput.d.ts +2 -2
- package/es/components/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.js +6 -6
- package/es/components/FeatureFlags/index.d.ts +1 -1
- package/es/components/FileUploader/FileUploader.d.ts +6 -1
- package/es/components/FileUploader/FileUploader.js +3 -1
- package/es/components/FileUploader/FileUploaderButton.d.ts +1 -1
- package/es/components/FileUploader/FileUploaderDropContainer.d.ts +1 -1
- package/es/components/FluidDatePickerInput/FluidDatePickerInput.d.ts +1 -1
- package/es/components/FluidDatePickerInput/FluidDatePickerInput.js +5 -6
- package/es/components/FluidMultiSelect/FluidFilterableMultiSelect.d.ts +3 -3
- package/es/components/FluidMultiSelect/FluidMultiSelect.d.ts +2 -2
- package/es/components/FluidMultiSelect/FluidMultiSelect.js +6 -4
- package/es/components/FluidNumberInput/FluidNumberInput.Skeleton.js +40 -0
- package/es/components/FluidNumberInput/FluidNumberInput.js +123 -0
- package/es/components/FluidTextInput/FluidTextInput.js +2 -2
- package/es/components/Grid/Column.js +1 -1
- package/es/components/Grid/GridTypes.d.ts +6 -1
- package/es/components/Layer/LayerLevel.d.ts +3 -3
- package/es/components/Layer/LayerLevel.js +4 -3
- package/es/components/Layer/index.d.ts +4 -2
- package/es/components/Layer/index.js +3 -2
- package/es/components/Link/Link.js +3 -1
- package/es/components/Menu/Menu.d.ts +1 -1
- package/es/components/Menu/Menu.js +4 -14
- package/es/components/Menu/MenuContext.d.ts +1 -1
- package/es/components/Menu/MenuItem.js +15 -4
- package/es/components/Modal/Modal.js +5 -2
- package/es/components/ModalWrapper/ModalWrapper.d.ts +2 -2
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +3 -3
- package/es/components/MultiSelect/FilterableMultiSelect.js +4 -3
- package/es/components/MultiSelect/MultiSelect.d.ts +2 -6
- package/es/components/MultiSelect/MultiSelect.js +22 -4
- package/es/components/MultiSelect/index.d.ts +2 -4
- package/es/components/NumberInput/NumberInput.js +2 -1
- package/es/components/OverflowMenu/OverflowMenu.d.ts +7 -1
- package/es/components/OverflowMenu/OverflowMenu.js +69 -17
- package/es/components/OverflowMenu/index.d.ts +2 -4
- package/es/components/OverflowMenu/index.js +10 -6
- package/es/components/OverflowMenu/next/index.js +0 -1
- package/es/components/OverflowMenuItem/OverflowMenuItem.d.ts +4 -0
- package/es/components/PageHeader/PageHeader.d.ts +9 -2
- package/es/components/PageHeader/PageHeader.js +16 -4
- package/es/components/PageHeader/index.d.ts +2 -2
- package/es/components/PageHeader/index.js +1 -1
- package/es/components/PaginationNav/PaginationNav.d.ts +1 -1
- package/es/components/PaginationNav/PaginationNav.js +2 -1
- package/es/components/Popover/index.d.ts +3 -2
- package/es/components/Popover/index.js +10 -5
- package/es/components/Portal/index.d.ts +1 -1
- package/es/components/Search/Search.js +0 -1
- package/es/components/SkeletonText/SkeletonText.js +3 -1
- package/es/components/Slider/Slider.d.ts +3 -13
- package/es/components/Slider/Slider.js +2 -14
- package/es/components/Tabs/Tabs.d.ts +2 -2
- package/es/components/Tabs/Tabs.js +8 -6
- package/es/components/Tabs/usePressable.js +1 -1
- package/es/components/Tag/Tag.js +9 -2
- package/es/components/Text/Text.js +3 -2
- package/es/components/TextInput/ControlledPasswordInput.d.ts +1 -1
- package/es/components/TextInput/ControlledPasswordInput.js +0 -6
- package/es/components/TextInput/TextInput.d.ts +1 -1
- package/es/components/TextInput/TextInput.js +0 -4
- package/es/components/TextInput/index.d.ts +6 -0
- package/es/components/TextInput/index.js +0 -8
- package/es/components/Tile/Tile.js +0 -1
- package/es/components/Toggle/Toggle.d.ts +1 -1
- package/es/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +9 -14
- package/es/components/ToggleSmall/ToggleSmall.Skeleton.js +37 -41
- package/es/components/Toggletip/index.js +11 -8
- package/es/components/Tooltip/Tooltip.d.ts +1 -1
- package/es/components/TreeView/TreeView.d.ts +1 -1
- package/es/components/UIShell/Content.d.ts +14 -1
- package/es/components/UIShell/HeaderGlobalBar.d.ts +1 -1
- package/es/components/UIShell/HeaderMenu.d.ts +2 -99
- package/es/components/UIShell/HeaderMenu.js +10 -3
- package/es/components/UIShell/HeaderMenuButton.d.ts +1 -98
- package/es/components/UIShell/HeaderMenuItem.d.ts +3 -4
- package/es/components/UIShell/HeaderMenuItem.js +3 -3
- package/es/components/UIShell/HeaderName.js +1 -1
- package/es/components/UIShell/HeaderNavigation.d.ts +0 -97
- package/es/components/UIShell/Link.d.ts +8 -8
- package/es/components/UIShell/Link.js +8 -5
- package/es/components/UIShell/SideNav.d.ts +3 -3
- package/es/components/UIShell/SideNav.js +1 -1
- package/es/components/UIShell/SideNavHeader.js +0 -1
- package/es/components/UIShell/SideNavLink.d.ts +3 -4
- package/es/components/UIShell/SideNavLink.js +8 -3
- package/es/components/UIShell/SideNavMenu.js +0 -1
- package/es/components/UIShell/SideNavMenuItem.d.ts +1 -49
- package/es/components/UIShell/SideNavMenuItem.js +1 -1
- package/es/components/UIShell/SideNavSwitcher.js +0 -1
- package/es/components/UIShell/SwitcherItem.d.ts +2 -2
- package/es/components/UIShell/SwitcherItem.js +1 -1
- package/es/index.d.ts +2 -2
- package/es/index.js +7 -7
- package/es/internal/FloatingMenu.js +2 -1
- package/es/internal/clamp.d.ts +10 -0
- package/es/internal/clamp.js +13 -0
- package/es/internal/useEvent.d.ts +9 -0
- package/es/internal/useEvent.js +8 -49
- package/es/internal/useId.js +1 -1
- package/es/internal/useMatchMedia.d.ts +7 -2
- package/es/internal/useMatchMedia.js +9 -10
- package/es/internal/useNoInteractiveChildren.js +4 -2
- package/es/internal/useOutsideClick.d.ts +1 -1
- package/es/prop-types/AriaPropTypes.js +1 -1
- package/es/prop-types/isRequiredOneOf.d.ts +16 -0
- package/es/prop-types/isRequiredOneOf.js +11 -9
- package/es/tools/setupGetInstanceId.d.ts +12 -0
- package/es/tools/setupGetInstanceId.js +7 -8
- package/es/tools/toggleClass.d.ts +14 -0
- package/es/tools/toggleClass.js +9 -10
- package/es/tools/wrapComponent.d.ts +1 -1
- package/es/types/common.d.ts +1 -6
- package/lib/components/Accordion/AccordionItem.d.ts +2 -2
- package/lib/components/AspectRatio/AspectRatio.d.ts +2 -2
- package/lib/components/Button/Button.js +3 -0
- package/lib/components/Button/ButtonBase.d.ts +2 -2
- package/lib/components/ChatButton/ChatButton.js +5 -3
- package/lib/components/CodeSnippet/CodeSnippet.js +2 -0
- package/lib/components/ComboBox/ComboBox.d.ts +1 -1
- package/lib/components/ComboBox/ComboBox.js +52 -30
- package/lib/components/ComposedModal/ComposedModal.d.ts +1 -1
- package/lib/components/ComposedModal/ComposedModal.js +2 -3
- package/lib/components/ComposedModal/ModalFooter.js +0 -1
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +0 -1
- package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
- package/lib/components/ContextMenu/useContextMenu.d.ts +1 -1
- package/lib/components/DataTable/DataTable.d.ts +5 -5
- package/lib/components/DataTable/DataTable.js +1 -1
- package/lib/components/DataTable/TableActionList.d.ts +1 -1
- package/lib/components/DataTable/TableCell.js +28 -3
- package/lib/components/DataTable/TableExpandHeader.d.ts +1 -1
- package/lib/components/DataTable/TableHead.d.ts +1 -1
- package/lib/components/DataTable/TableToolbarContent.d.ts +1 -1
- package/lib/components/DataTable/TableToolbarSearch.d.ts +1 -1
- package/lib/components/DataTable/tools/cells.d.ts +13 -0
- package/lib/components/DataTable/tools/cells.js +3 -6
- package/lib/components/DataTable/tools/filter.d.ts +26 -0
- package/lib/components/DataTable/tools/filter.js +8 -17
- package/lib/components/DatePicker/DatePicker.js +1 -1
- package/lib/components/DatePickerInput/DatePickerInput.d.ts +2 -2
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.js +6 -6
- package/lib/components/FeatureFlags/index.d.ts +1 -1
- package/lib/components/FileUploader/FileUploader.d.ts +6 -1
- package/lib/components/FileUploader/FileUploader.js +3 -1
- package/lib/components/FileUploader/FileUploaderButton.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +1 -1
- package/lib/components/FluidDatePickerInput/FluidDatePickerInput.d.ts +1 -1
- package/lib/components/FluidDatePickerInput/FluidDatePickerInput.js +4 -5
- package/lib/components/FluidMultiSelect/FluidFilterableMultiSelect.d.ts +3 -3
- package/lib/components/FluidMultiSelect/FluidMultiSelect.d.ts +2 -2
- package/lib/components/FluidMultiSelect/FluidMultiSelect.js +7 -5
- package/lib/components/FluidNumberInput/FluidNumberInput.Skeleton.js +50 -0
- package/lib/components/FluidNumberInput/FluidNumberInput.js +133 -0
- package/lib/components/FluidTextInput/FluidTextInput.js +2 -2
- package/lib/components/Grid/Column.js +1 -1
- package/lib/components/Grid/GridTypes.d.ts +6 -1
- package/lib/components/Layer/LayerLevel.d.ts +3 -3
- package/lib/components/Layer/LayerLevel.js +4 -2
- package/lib/components/Layer/index.d.ts +4 -2
- package/lib/components/Layer/index.js +2 -1
- package/lib/components/Link/Link.js +3 -1
- package/lib/components/Menu/Menu.d.ts +1 -1
- package/lib/components/Menu/Menu.js +4 -14
- package/lib/components/Menu/MenuContext.d.ts +1 -1
- package/lib/components/Menu/MenuItem.js +15 -4
- package/lib/components/Modal/Modal.js +6 -3
- package/lib/components/ModalWrapper/ModalWrapper.d.ts +2 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +3 -3
- package/lib/components/MultiSelect/FilterableMultiSelect.js +3 -2
- package/lib/components/MultiSelect/MultiSelect.d.ts +2 -6
- package/lib/components/MultiSelect/MultiSelect.js +21 -3
- package/lib/components/MultiSelect/index.d.ts +2 -4
- package/lib/components/NumberInput/NumberInput.js +2 -1
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +7 -1
- package/lib/components/OverflowMenu/OverflowMenu.js +69 -17
- package/lib/components/OverflowMenu/index.d.ts +2 -4
- package/lib/components/OverflowMenu/index.js +9 -5
- package/lib/components/OverflowMenu/next/index.js +0 -1
- package/lib/components/OverflowMenuItem/OverflowMenuItem.d.ts +4 -0
- package/lib/components/PageHeader/PageHeader.d.ts +9 -2
- package/lib/components/PageHeader/PageHeader.js +17 -3
- package/lib/components/PageHeader/index.d.ts +2 -2
- package/lib/components/PageHeader/index.js +2 -0
- package/lib/components/PaginationNav/PaginationNav.d.ts +1 -1
- package/lib/components/PaginationNav/PaginationNav.js +2 -1
- package/lib/components/Popover/index.d.ts +3 -2
- package/lib/components/Popover/index.js +10 -5
- package/lib/components/Portal/index.d.ts +1 -1
- package/lib/components/Search/Search.js +0 -1
- package/lib/components/SkeletonText/SkeletonText.js +3 -1
- package/lib/components/Slider/Slider.d.ts +3 -13
- package/lib/components/Slider/Slider.js +2 -14
- package/lib/components/Tabs/Tabs.d.ts +2 -2
- package/lib/components/Tabs/Tabs.js +7 -5
- package/lib/components/Tabs/usePressable.js +1 -1
- package/lib/components/Tag/Tag.js +9 -2
- package/lib/components/Text/Text.js +2 -1
- package/lib/components/TextInput/ControlledPasswordInput.d.ts +1 -1
- package/lib/components/TextInput/ControlledPasswordInput.js +0 -6
- package/lib/components/TextInput/TextInput.d.ts +1 -1
- package/lib/components/TextInput/TextInput.js +0 -4
- package/lib/components/TextInput/index.d.ts +6 -0
- package/lib/components/TextInput/index.js +1 -7
- package/lib/components/Tile/Tile.js +0 -1
- package/lib/components/Toggle/Toggle.d.ts +1 -1
- package/lib/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +9 -14
- package/lib/components/ToggleSmall/ToggleSmall.Skeleton.js +34 -39
- package/lib/components/Toggletip/index.js +11 -8
- package/lib/components/Tooltip/Tooltip.d.ts +1 -1
- package/lib/components/TreeView/TreeView.d.ts +1 -1
- package/lib/components/UIShell/Content.d.ts +14 -1
- package/lib/components/UIShell/HeaderGlobalBar.d.ts +1 -1
- package/lib/components/UIShell/HeaderMenu.d.ts +2 -99
- package/lib/components/UIShell/HeaderMenu.js +10 -3
- package/lib/components/UIShell/HeaderMenuButton.d.ts +1 -98
- package/lib/components/UIShell/HeaderMenuItem.d.ts +3 -4
- package/lib/components/UIShell/HeaderMenuItem.js +3 -3
- package/lib/components/UIShell/HeaderName.js +1 -1
- package/lib/components/UIShell/HeaderNavigation.d.ts +0 -97
- package/lib/components/UIShell/Link.d.ts +8 -8
- package/lib/components/UIShell/Link.js +7 -5
- package/lib/components/UIShell/SideNav.d.ts +3 -3
- package/lib/components/UIShell/SideNav.js +1 -1
- package/lib/components/UIShell/SideNavHeader.js +0 -1
- package/lib/components/UIShell/SideNavLink.d.ts +3 -4
- package/lib/components/UIShell/SideNavLink.js +8 -3
- package/lib/components/UIShell/SideNavMenu.js +0 -1
- package/lib/components/UIShell/SideNavMenuItem.d.ts +1 -49
- package/lib/components/UIShell/SideNavMenuItem.js +1 -1
- package/lib/components/UIShell/SideNavSwitcher.js +0 -1
- package/lib/components/UIShell/SwitcherItem.d.ts +2 -2
- package/lib/components/UIShell/SwitcherItem.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +13 -11
- package/lib/internal/FloatingMenu.js +2 -1
- package/lib/internal/clamp.d.ts +10 -0
- package/lib/internal/clamp.js +17 -0
- package/lib/internal/useEvent.d.ts +9 -0
- package/lib/internal/useEvent.js +8 -49
- package/lib/internal/useId.js +1 -1
- package/lib/internal/useMatchMedia.d.ts +7 -2
- package/lib/internal/useMatchMedia.js +9 -10
- package/lib/internal/useNoInteractiveChildren.js +4 -2
- package/lib/internal/useOutsideClick.d.ts +1 -1
- package/lib/prop-types/AriaPropTypes.js +1 -1
- package/lib/prop-types/isRequiredOneOf.d.ts +16 -0
- package/lib/prop-types/isRequiredOneOf.js +11 -9
- package/lib/tools/setupGetInstanceId.d.ts +12 -0
- package/lib/tools/setupGetInstanceId.js +7 -8
- package/lib/tools/toggleClass.d.ts +14 -0
- package/lib/tools/toggleClass.js +9 -10
- package/lib/tools/wrapComponent.d.ts +1 -1
- package/lib/types/common.d.ts +1 -6
- package/package.json +15 -15
- package/telemetry.yml +11 -12
- package/es/components/MultiSelect/index.js +0 -13
- package/es/internal/ClickListener.d.ts +0 -13
- package/es/internal/ClickListener.js +0 -47
- package/lib/components/MultiSelect/index.js +0 -19
- package/lib/internal/ClickListener.d.ts +0 -13
- package/lib/internal/ClickListener.js +0 -51
|
@@ -11,7 +11,7 @@ import cx from 'classnames';
|
|
|
11
11
|
import { useSelect } from 'downshift';
|
|
12
12
|
import isEqual from 'react-fast-compare';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
|
-
import React__default, { useMemo, useContext, useState, useLayoutEffect, isValidElement } from 'react';
|
|
14
|
+
import React__default, { useMemo, useContext, useState, useLayoutEffect, isValidElement, useCallback } from 'react';
|
|
15
15
|
import ListBox from '../ListBox/index.js';
|
|
16
16
|
import { sortingPropTypes } from './MultiSelectPropTypes.js';
|
|
17
17
|
import { defaultSortItems, defaultCompareItems } from './tools/sorting.js';
|
|
@@ -424,7 +424,20 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
424
424
|
const menuProps = useMemo(() => getMenuProps({
|
|
425
425
|
ref: enableFloatingStyles ? refs.setFloating : null
|
|
426
426
|
}), [enableFloatingStyles, getMenuProps, refs.setFloating]);
|
|
427
|
-
const
|
|
427
|
+
const allLabelProps = getLabelProps();
|
|
428
|
+
const labelProps = /*#__PURE__*/isValidElement(titleText) ? {
|
|
429
|
+
id: allLabelProps.id
|
|
430
|
+
} : allLabelProps;
|
|
431
|
+
const getSelectionStats = useCallback((selectedItems, filteredItems) => {
|
|
432
|
+
const hasIndividualSelections = selectedItems.some(selected => !selected.isSelectAll);
|
|
433
|
+
const nonSelectAllSelectedCount = selectedItems.filter(selected => !selected.isSelectAll).length;
|
|
434
|
+
const totalSelectableCount = filteredItems.filter(item => !item.isSelectAll && !item.disabled).length;
|
|
435
|
+
return {
|
|
436
|
+
hasIndividualSelections,
|
|
437
|
+
nonSelectAllSelectedCount,
|
|
438
|
+
totalSelectableCount
|
|
439
|
+
};
|
|
440
|
+
}, [selectedItems, filteredItems]);
|
|
428
441
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
429
442
|
className: wrapperClasses
|
|
430
443
|
}, /*#__PURE__*/React__default.createElement("label", _extends({
|
|
@@ -478,7 +491,12 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
478
491
|
className: `${prefix}--list-box__inner-wrapper--decorator`
|
|
479
492
|
}, normalizedDecorator) : ''), /*#__PURE__*/React__default.createElement(ListBox.Menu, menuProps, isOpen && sortItems(filteredItems, sortOptions).map((item, index) => {
|
|
480
493
|
const isChecked = selectedItems.filter(selected => isEqual(selected, item)).length > 0;
|
|
481
|
-
const
|
|
494
|
+
const {
|
|
495
|
+
hasIndividualSelections,
|
|
496
|
+
nonSelectAllSelectedCount,
|
|
497
|
+
totalSelectableCount
|
|
498
|
+
} = getSelectionStats(selectedItems, filteredItems);
|
|
499
|
+
const isIndeterminate = item['isSelectAll'] && hasIndividualSelections && nonSelectAllSelectedCount < totalSelectableCount;
|
|
482
500
|
const itemProps = getItemProps({
|
|
483
501
|
item,
|
|
484
502
|
// we don't want Downshift to set aria-selected for us
|
|
@@ -701,4 +719,4 @@ MultiSelect.propTypes = {
|
|
|
701
719
|
warnText: PropTypes.node
|
|
702
720
|
};
|
|
703
721
|
|
|
704
|
-
export { MultiSelect
|
|
722
|
+
export { MultiSelect };
|
|
@@ -4,7 +4,5 @@
|
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
export { FilterableMultiSelect, MultiSelect };
|
|
10
|
-
export default MultiSelect;
|
|
7
|
+
export * from './FilterableMultiSelect';
|
|
8
|
+
export * from './MultiSelect';
|
|
@@ -17,6 +17,7 @@ import deprecate from '../../prop-types/deprecate.js';
|
|
|
17
17
|
import '../FluidForm/FluidForm.js';
|
|
18
18
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
19
19
|
import '../Text/index.js';
|
|
20
|
+
import { clamp } from '../../internal/clamp.js';
|
|
20
21
|
import { Text } from '../Text/Text.js';
|
|
21
22
|
|
|
22
23
|
var _Subtract, _Add;
|
|
@@ -173,7 +174,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
173
174
|
const rawValue = direction === 'up' ? currentValue + step : currentValue - step;
|
|
174
175
|
const precision = Math.max(getDecimalPlaces(currentValue), getDecimalPlaces(step));
|
|
175
176
|
const floatValue = parseFloat(rawValue.toFixed(precision));
|
|
176
|
-
const newValue =
|
|
177
|
+
const newValue = clamp(floatValue, min ?? -Infinity, max ?? Infinity);
|
|
177
178
|
const state = {
|
|
178
179
|
value: allowEmpty && inputRef.current.value === '' && step === 0 ? '' : newValue,
|
|
179
180
|
direction
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, { type ElementType, type ReactNode, type Ref } from 'react';
|
|
8
8
|
import { type MenuDirection, type MenuOffset } from '../../internal/FloatingMenu';
|
|
9
|
+
import { PopoverAlignment } from '../Popover';
|
|
9
10
|
/**
|
|
10
11
|
* Calculates the offset for the floating menu.
|
|
11
12
|
*
|
|
@@ -16,6 +17,10 @@ import { type MenuDirection, type MenuOffset } from '../../internal/FloatingMenu
|
|
|
16
17
|
*/
|
|
17
18
|
export declare const getMenuOffset: MenuOffset;
|
|
18
19
|
export interface OverflowMenuProps {
|
|
20
|
+
/**
|
|
21
|
+
* Specify how the trigger tooltip should be aligned.
|
|
22
|
+
*/
|
|
23
|
+
align?: PopoverAlignment;
|
|
19
24
|
/**
|
|
20
25
|
* Specify a label to be read by screen readers on the container node
|
|
21
26
|
*/
|
|
@@ -105,7 +110,8 @@ export interface OverflowMenuProps {
|
|
|
105
110
|
*/
|
|
106
111
|
size?: 'sm' | 'md' | 'lg';
|
|
107
112
|
/**
|
|
108
|
-
* The ref to the
|
|
113
|
+
* The ref to the overflow menu's trigger button element.
|
|
114
|
+
* @deprecated Use the standard React `ref` prop instead.
|
|
109
115
|
*/
|
|
110
116
|
innerRef?: Ref<any>;
|
|
111
117
|
}
|
|
@@ -11,7 +11,6 @@ import { OverflowMenuVertical } from '@carbon/icons-react';
|
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import invariant from 'invariant';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
|
-
import { ClickListener } from '../../internal/ClickListener.js';
|
|
15
14
|
import { DIRECTION_TOP, DIRECTION_BOTTOM, FloatingMenu } from '../../internal/FloatingMenu.js';
|
|
16
15
|
import { ArrowUp, ArrowRight, ArrowDown, ArrowLeft, Escape } from '../../internal/keyboard/keys.js';
|
|
17
16
|
import { matches } from '../../internal/keyboard/match.js';
|
|
@@ -19,8 +18,10 @@ import { noopFn } from '../../internal/noopFn.js';
|
|
|
19
18
|
import { PrefixContext } from '../../internal/usePrefix.js';
|
|
20
19
|
import deprecate from '../../prop-types/deprecate.js';
|
|
21
20
|
import mergeRefs from '../../tools/mergeRefs.js';
|
|
22
|
-
import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
|
|
21
|
+
import { setupGetInstanceId } from '../../tools/setupGetInstanceId.js';
|
|
23
22
|
import { IconButton } from '../IconButton/index.js';
|
|
23
|
+
import { useOutsideClick } from '../../internal/useOutsideClick.js';
|
|
24
|
+
import deprecateValuesWithin from '../../prop-types/deprecateValuesWithin.js';
|
|
24
25
|
|
|
25
26
|
const getInstanceId = setupGetInstanceId();
|
|
26
27
|
const on = function (target) {
|
|
@@ -89,8 +90,25 @@ const getMenuOffset = (menuBody, direction, trigger, flip) => {
|
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
92
|
};
|
|
93
|
+
|
|
94
|
+
// TODO: Replace this code when align mapping is consolidated.
|
|
95
|
+
// https://github.com/carbon-design-system/carbon/pull/19081
|
|
96
|
+
const propMappingFunction = deprecatedValue => {
|
|
97
|
+
const mapping = {
|
|
98
|
+
'top-left': 'top-start',
|
|
99
|
+
'top-right': 'top-end',
|
|
100
|
+
'bottom-left': 'bottom-start',
|
|
101
|
+
'bottom-right': 'bottom-end',
|
|
102
|
+
'left-bottom': 'left-end',
|
|
103
|
+
'left-top': 'left-start',
|
|
104
|
+
'right-bottom': 'right-end',
|
|
105
|
+
'right-top': 'right-start'
|
|
106
|
+
};
|
|
107
|
+
return mapping[deprecatedValue];
|
|
108
|
+
};
|
|
92
109
|
const OverflowMenu = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
93
110
|
let {
|
|
111
|
+
align,
|
|
94
112
|
['aria-label']: ariaLabel = null,
|
|
95
113
|
ariaLabel: deprecatedAriaLabel,
|
|
96
114
|
children,
|
|
@@ -112,6 +130,7 @@ const OverflowMenu = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
112
130
|
renderIcon: IconElement = OverflowMenuVertical,
|
|
113
131
|
selectorPrimaryFocus = '[data-floating-menu-primary-focus]',
|
|
114
132
|
size = 'md',
|
|
133
|
+
innerRef,
|
|
115
134
|
...other
|
|
116
135
|
} = _ref;
|
|
117
136
|
const prefix = useContext(PrefixContext);
|
|
@@ -127,6 +146,7 @@ const OverflowMenu = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
127
146
|
const prevOpenState = useRef(open);
|
|
128
147
|
/** The element ref of the tooltip's trigger button. */
|
|
129
148
|
const triggerRef = useRef(null);
|
|
149
|
+
const wrapperRef = useRef(null);
|
|
130
150
|
|
|
131
151
|
// Sync open prop changes.
|
|
132
152
|
useEffect(() => {
|
|
@@ -150,6 +170,14 @@ const OverflowMenu = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
150
170
|
}
|
|
151
171
|
prevOpenState.current = open;
|
|
152
172
|
}, [open, onClose]);
|
|
173
|
+
useOutsideClick(wrapperRef, _ref2 => {
|
|
174
|
+
let {
|
|
175
|
+
target
|
|
176
|
+
} = _ref2;
|
|
177
|
+
if (open && (!menuBodyRef.current || target instanceof Node && !menuBodyRef.current.contains(target))) {
|
|
178
|
+
closeMenu();
|
|
179
|
+
}
|
|
180
|
+
});
|
|
153
181
|
const focusMenuEl = useCallback(() => {
|
|
154
182
|
if (triggerRef.current) {
|
|
155
183
|
triggerRef.current.focus();
|
|
@@ -200,23 +228,18 @@ const OverflowMenu = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
200
228
|
evt.stopPropagation();
|
|
201
229
|
}
|
|
202
230
|
};
|
|
203
|
-
const handleClickOutside = evt => {
|
|
204
|
-
if (open && (!menuBodyRef.current || evt.target instanceof Node && !menuBodyRef.current.contains(evt.target))) {
|
|
205
|
-
closeMenu();
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
231
|
|
|
209
232
|
/**
|
|
210
233
|
* Focuses the next enabled overflow menu item given the currently focused
|
|
211
234
|
* item index and direction to move.
|
|
212
235
|
*/
|
|
213
|
-
const handleOverflowMenuItemFocus =
|
|
236
|
+
const handleOverflowMenuItemFocus = _ref3 => {
|
|
214
237
|
let {
|
|
215
|
-
currentIndex,
|
|
238
|
+
currentIndex = 0,
|
|
216
239
|
direction
|
|
217
|
-
} =
|
|
240
|
+
} = _ref3;
|
|
218
241
|
const enabledIndices = Children.toArray(children).reduce((acc, curr, i) => {
|
|
219
|
-
if (/*#__PURE__*/isValidElement(curr) && !curr.props.disabled) {
|
|
242
|
+
if (/*#__PURE__*/React__default.isValidElement(curr) && !curr.props.disabled) {
|
|
220
243
|
acc.push(i);
|
|
221
244
|
}
|
|
222
245
|
return acc;
|
|
@@ -314,12 +337,13 @@ const OverflowMenu = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
314
337
|
}, /*#__PURE__*/cloneElement(menuBody, {
|
|
315
338
|
'data-floating-menu-direction': direction
|
|
316
339
|
}));
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}, /*#__PURE__*/React__default.createElement("span", {
|
|
340
|
+
const combinedRef = innerRef ? mergeRefs(triggerRef, innerRef, ref) : mergeRefs(triggerRef, ref);
|
|
341
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
|
|
320
342
|
className: `${prefix}--overflow-menu__wrapper`,
|
|
321
|
-
"aria-owns": open ? menuBodyId : undefined
|
|
343
|
+
"aria-owns": open ? menuBodyId : undefined,
|
|
344
|
+
ref: wrapperRef
|
|
322
345
|
}, /*#__PURE__*/React__default.createElement(IconButton, _extends({}, other, {
|
|
346
|
+
align: align,
|
|
323
347
|
type: "button",
|
|
324
348
|
"aria-haspopup": true,
|
|
325
349
|
"aria-expanded": open,
|
|
@@ -327,7 +351,7 @@ const OverflowMenu = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
327
351
|
className: overflowMenuClasses,
|
|
328
352
|
onClick: handleClick,
|
|
329
353
|
id: id,
|
|
330
|
-
ref:
|
|
354
|
+
ref: combinedRef,
|
|
331
355
|
size: size,
|
|
332
356
|
label: iconDescription,
|
|
333
357
|
kind: "ghost"
|
|
@@ -337,6 +361,35 @@ const OverflowMenu = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
337
361
|
})), open && hasMountedTrigger && wrappedMenuBody));
|
|
338
362
|
});
|
|
339
363
|
OverflowMenu.propTypes = {
|
|
364
|
+
/**
|
|
365
|
+
* Specify how the trigger should align with the tooltip
|
|
366
|
+
*/
|
|
367
|
+
align: deprecateValuesWithin(PropTypes.oneOf(['top', 'top-left',
|
|
368
|
+
// deprecated use top-start instead
|
|
369
|
+
'top-right',
|
|
370
|
+
// deprecated use top-end instead
|
|
371
|
+
|
|
372
|
+
'bottom', 'bottom-left',
|
|
373
|
+
// deprecated use bottom-start instead
|
|
374
|
+
'bottom-right',
|
|
375
|
+
// deprecated use bottom-end instead
|
|
376
|
+
|
|
377
|
+
'left', 'left-bottom',
|
|
378
|
+
// deprecated use left-end instead
|
|
379
|
+
'left-top',
|
|
380
|
+
// deprecated use left-start instead
|
|
381
|
+
|
|
382
|
+
'right', 'right-bottom',
|
|
383
|
+
// deprecated use right-end instead
|
|
384
|
+
'right-top',
|
|
385
|
+
// deprecated use right-start instead
|
|
386
|
+
|
|
387
|
+
// new values to match floating-ui
|
|
388
|
+
'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
|
|
389
|
+
//allowed prop values
|
|
390
|
+
['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'],
|
|
391
|
+
//optional mapper function
|
|
392
|
+
propMappingFunction),
|
|
340
393
|
/**
|
|
341
394
|
* Specify a label to be read by screen readers on the container node
|
|
342
395
|
*/
|
|
@@ -428,7 +481,6 @@ OverflowMenu.propTypes = {
|
|
|
428
481
|
/**
|
|
429
482
|
* A component used to render an icon.
|
|
430
483
|
*/
|
|
431
|
-
// @ts-expect-error: PropTypes are not expressive enough to cover this case
|
|
432
484
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
433
485
|
/**
|
|
434
486
|
* Specify a CSS selector that matches the DOM element that should
|
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
+
import React from 'react';
|
|
7
8
|
import { type OverflowMenuProps } from './OverflowMenu';
|
|
8
|
-
declare const OverflowMenu:
|
|
9
|
-
(props: OverflowMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
displayName: string;
|
|
11
|
-
};
|
|
9
|
+
declare const OverflowMenu: React.ForwardRefExoticComponent<OverflowMenuProps & React.RefAttributes<HTMLDivElement>>;
|
|
12
10
|
export default OverflowMenu;
|
|
13
11
|
export { OverflowMenu, type OverflowMenuProps };
|
|
@@ -5,17 +5,21 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import React__default, { forwardRef } from 'react';
|
|
9
10
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
10
11
|
import { OverflowMenu as OverflowMenu$2 } from './next/index.js';
|
|
11
12
|
import { OverflowMenu as OverflowMenu$1 } from './OverflowMenu.js';
|
|
12
|
-
import { createClassWrapper } from '../../internal/createClassWrapper.js';
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
const OverflowMenu = props => {
|
|
14
|
+
const OverflowMenu = /*#__PURE__*/forwardRef((props, ref) => {
|
|
16
15
|
const enableV12OverflowMenu = useFeatureFlag('enable-v12-overflowmenu');
|
|
17
|
-
return enableV12OverflowMenu ? /*#__PURE__*/React__default.createElement(OverflowMenu$2,
|
|
18
|
-
|
|
16
|
+
return enableV12OverflowMenu ? /*#__PURE__*/React__default.createElement(OverflowMenu$2, _extends({}, props, {
|
|
17
|
+
ref: ref
|
|
18
|
+
})) : /*#__PURE__*/React__default.createElement(OverflowMenu$1, _extends({}, props, {
|
|
19
|
+
ref: ref
|
|
20
|
+
}));
|
|
21
|
+
});
|
|
19
22
|
OverflowMenu.displayName = 'OverflowMenu';
|
|
23
|
+
OverflowMenu.propTypes = OverflowMenu$1.propTypes;
|
|
20
24
|
|
|
21
25
|
export { OverflowMenu, OverflowMenu as default };
|
|
@@ -167,7 +167,6 @@ OverflowMenu.propTypes = {
|
|
|
167
167
|
/**
|
|
168
168
|
* A component used to render an icon.
|
|
169
169
|
*/
|
|
170
|
-
// @ts-expect-error: PropTypes are not expressive enough to cover this case
|
|
171
170
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
172
171
|
/**
|
|
173
172
|
* Specify the size of the menu, from a list of available sizes.
|
|
@@ -40,6 +40,10 @@ export interface OverflowMenuItemProps extends React.HTMLAttributes<HTMLElement>
|
|
|
40
40
|
* `true` to make this menu item a danger button.
|
|
41
41
|
*/
|
|
42
42
|
isDelete?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* accepts a ref to the button element
|
|
45
|
+
*/
|
|
46
|
+
ref?: (element: HTMLElement) => void;
|
|
43
47
|
/**
|
|
44
48
|
* `true` to require the title attribute.
|
|
45
49
|
*/
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React, { type ComponentType, type FunctionComponent } from 'react';
|
|
8
|
+
import { Tabs as BaseTabs } from '../Tabs/Tabs';
|
|
8
9
|
/**
|
|
9
10
|
* ----------
|
|
10
11
|
* PageHeader
|
|
@@ -87,6 +88,11 @@ interface PageHeaderTabBarProps {
|
|
|
87
88
|
className?: string;
|
|
88
89
|
}
|
|
89
90
|
declare const PageHeaderTabBar: React.ForwardRefExoticComponent<PageHeaderTabBarProps & React.RefAttributes<HTMLDivElement>>;
|
|
91
|
+
interface PageHeaderTabsProps extends React.ComponentProps<typeof BaseTabs> {
|
|
92
|
+
children?: React.ReactNode;
|
|
93
|
+
className?: string;
|
|
94
|
+
}
|
|
95
|
+
declare const PageHeaderTabs: React.ForwardRefExoticComponent<PageHeaderTabsProps & React.RefAttributes<HTMLDivElement>>;
|
|
90
96
|
/**
|
|
91
97
|
* -------
|
|
92
98
|
* Exports
|
|
@@ -97,5 +103,6 @@ declare const BreadcrumbBar: React.ForwardRefExoticComponent<PageHeaderBreadcrum
|
|
|
97
103
|
declare const Content: React.ForwardRefExoticComponent<PageHeaderContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
98
104
|
declare const HeroImage: React.ForwardRefExoticComponent<PageHeaderHeroImageProps & React.RefAttributes<HTMLDivElement>>;
|
|
99
105
|
declare const TabBar: React.ForwardRefExoticComponent<PageHeaderTabBarProps & React.RefAttributes<HTMLDivElement>>;
|
|
100
|
-
|
|
101
|
-
export
|
|
106
|
+
declare const Tabs: React.ForwardRefExoticComponent<PageHeaderTabsProps & React.RefAttributes<HTMLDivElement>>;
|
|
107
|
+
export { PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderHeroImage, PageHeaderTabBar, PageHeaderTabs, Root, BreadcrumbBar, Content, HeroImage, TabBar, Tabs, };
|
|
108
|
+
export type { PageHeaderProps, PageHeaderBreadcrumbBarProps, PageHeaderContentProps, PageHeaderHeroImageProps, PageHeaderTabBarProps, PageHeaderTabsProps, };
|
|
@@ -16,9 +16,10 @@ import '../Text/index.js';
|
|
|
16
16
|
import { DefinitionTooltip } from '../Tooltip/DefinitionTooltip.js';
|
|
17
17
|
import '../Tooltip/Tooltip.js';
|
|
18
18
|
import AspectRatio from '../AspectRatio/AspectRatio.js';
|
|
19
|
+
import { Tabs as Tabs$1 } from '../Tabs/Tabs.js';
|
|
19
20
|
import { Text } from '../Text/Text.js';
|
|
20
21
|
|
|
21
|
-
var _p, _p2
|
|
22
|
+
var _p, _p2;
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* ----------
|
|
@@ -143,7 +144,7 @@ PageHeaderContent.propTypes = {
|
|
|
143
144
|
/**
|
|
144
145
|
* Provide an optional icon to render in front of the PageHeaderContent's title.
|
|
145
146
|
*/
|
|
146
|
-
|
|
147
|
+
|
|
147
148
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
148
149
|
/**
|
|
149
150
|
* The PageHeaderContent's title
|
|
@@ -218,9 +219,18 @@ const PageHeaderTabBar = /*#__PURE__*/React__default.forwardRef(function PageHea
|
|
|
218
219
|
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
219
220
|
className: classNames,
|
|
220
221
|
ref: ref
|
|
221
|
-
}, other),
|
|
222
|
+
}, other), children);
|
|
222
223
|
});
|
|
223
224
|
PageHeaderTabBar.displayName = 'PageHeaderTabBar';
|
|
225
|
+
const PageHeaderTabs = /*#__PURE__*/React__default.forwardRef(function PageHeaderTabs(_ref6, ref) {
|
|
226
|
+
let {
|
|
227
|
+
className,
|
|
228
|
+
children,
|
|
229
|
+
...other
|
|
230
|
+
} = _ref6;
|
|
231
|
+
return /*#__PURE__*/React__default.createElement(Tabs$1, other, children);
|
|
232
|
+
});
|
|
233
|
+
PageHeaderTabs.displayName = 'PageHeaderTabs';
|
|
224
234
|
|
|
225
235
|
/**
|
|
226
236
|
* -------
|
|
@@ -237,5 +247,7 @@ const HeroImage = PageHeaderHeroImage;
|
|
|
237
247
|
HeroImage.displayName = 'PageHeaderHeroImage';
|
|
238
248
|
const TabBar = PageHeaderTabBar;
|
|
239
249
|
TabBar.displayName = 'PageHeaderTabBar';
|
|
250
|
+
const Tabs = PageHeaderTabs;
|
|
251
|
+
Tabs.displayName = 'PageHeader.Tabs';
|
|
240
252
|
|
|
241
|
-
export { BreadcrumbBar, Content, HeroImage, PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderHeroImage, PageHeaderTabBar, Root, TabBar };
|
|
253
|
+
export { BreadcrumbBar, Content, HeroImage, PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderHeroImage, PageHeaderTabBar, PageHeaderTabs, Root, TabBar, Tabs };
|
|
@@ -4,5 +4,5 @@
|
|
|
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
|
-
export { PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderTabBar, PageHeaderHeroImage, Root, BreadcrumbBar, Content, TabBar, HeroImage, } from './PageHeader';
|
|
8
|
-
export type { PageHeaderProps, PageHeaderBreadcrumbBarProps, PageHeaderContentProps, PageHeaderTabBarProps, PageHeaderHeroImageProps, } from './PageHeader';
|
|
7
|
+
export { PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderTabBar, PageHeaderHeroImage, PageHeaderTabs, Root, BreadcrumbBar, Content, TabBar, HeroImage, Tabs, } from './PageHeader';
|
|
8
|
+
export type { PageHeaderProps, PageHeaderBreadcrumbBarProps, PageHeaderContentProps, PageHeaderTabBarProps, PageHeaderHeroImageProps, PageHeaderTabsProps, } from './PageHeader';
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export { BreadcrumbBar, Content, HeroImage, PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderHeroImage, PageHeaderTabBar, Root, TabBar } from './PageHeader.js';
|
|
8
|
+
export { BreadcrumbBar, Content, HeroImage, PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderHeroImage, PageHeaderTabBar, PageHeaderTabs, Root, TabBar, Tabs } from './PageHeader.js';
|
|
@@ -14,6 +14,7 @@ import { IconButton } from '../IconButton/index.js';
|
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
15
|
import { breakpoints } from '@carbon/layout';
|
|
16
16
|
import { useMatchMedia } from '../../internal/useMatchMedia.js';
|
|
17
|
+
import { clamp } from '../../internal/clamp.js';
|
|
17
18
|
|
|
18
19
|
var _CaretRight, _CaretLeft, _option;
|
|
19
20
|
const translationIds = {
|
|
@@ -189,7 +190,7 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
189
190
|
numberOfPages = itemsShown === 4 ? itemsShown : 5;
|
|
190
191
|
break;
|
|
191
192
|
case 'sm':
|
|
192
|
-
numberOfPages =
|
|
193
|
+
numberOfPages = clamp(itemsShown, 4, 7);
|
|
193
194
|
break;
|
|
194
195
|
default:
|
|
195
196
|
numberOfPages = 4;
|
|
@@ -1,10 +1,11 @@
|
|
|
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
|
|
7
|
+
import { WeakValidationMap } from 'prop-types';
|
|
8
|
+
import React from 'react';
|
|
8
9
|
import { type Boundary } from '@floating-ui/react';
|
|
9
10
|
import { PolymorphicComponentPropWithRef } from '../../internal/PolymorphicProps';
|
|
10
11
|
export interface PopoverContext {
|
|
@@ -46,7 +46,9 @@ const propMappingFunction = deprecatedValue => {
|
|
|
46
46
|
};
|
|
47
47
|
return mapping[deprecatedValue];
|
|
48
48
|
};
|
|
49
|
-
const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFunction(_ref,
|
|
49
|
+
const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFunction(_ref,
|
|
50
|
+
//this is a workaround, have to come back and fix this.
|
|
51
|
+
forwardRef) {
|
|
50
52
|
let {
|
|
51
53
|
isTabTip,
|
|
52
54
|
align: initialAlign = isTabTip ? 'bottom-start' : 'bottom',
|
|
@@ -76,8 +78,11 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
|
|
|
76
78
|
onRequestClose?.();
|
|
77
79
|
}
|
|
78
80
|
});
|
|
79
|
-
useWindowEvent('click',
|
|
80
|
-
|
|
81
|
+
useWindowEvent('click', _ref2 => {
|
|
82
|
+
let {
|
|
83
|
+
target
|
|
84
|
+
} = _ref2;
|
|
85
|
+
if (open && target instanceof Node && !popover.current?.contains(target)) {
|
|
81
86
|
onRequestClose?.();
|
|
82
87
|
}
|
|
83
88
|
});
|
|
@@ -351,12 +356,12 @@ Popover.propTypes = {
|
|
|
351
356
|
open: PropTypes.bool.isRequired
|
|
352
357
|
};
|
|
353
358
|
function PopoverContentRenderFunction(// eslint-disable-next-line react/prop-types
|
|
354
|
-
|
|
359
|
+
_ref3, forwardRef) {
|
|
355
360
|
let {
|
|
356
361
|
className,
|
|
357
362
|
children,
|
|
358
363
|
...rest
|
|
359
|
-
} =
|
|
364
|
+
} = _ref3;
|
|
360
365
|
const prefix = usePrefix();
|
|
361
366
|
const {
|
|
362
367
|
setFloating,
|
|
@@ -13,7 +13,7 @@ export interface PortalProps {
|
|
|
13
13
|
/**
|
|
14
14
|
* Provide a ref for a container node to render the portal
|
|
15
15
|
*/
|
|
16
|
-
container?: React.RefObject<HTMLElement>;
|
|
16
|
+
container?: React.RefObject<HTMLElement | null>;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Helper component for rendering content within a portal. By default, the
|
|
@@ -222,7 +222,6 @@ Search.propTypes = {
|
|
|
222
222
|
/**
|
|
223
223
|
* A component used to render an icon.
|
|
224
224
|
*/
|
|
225
|
-
// @ts-expect-error: PropTypes are not expressive enough to cover this case
|
|
226
225
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
227
226
|
/**
|
|
228
227
|
* Specify the role for the underlying `<input>`, defaults to `searchbox`
|
|
@@ -59,7 +59,9 @@ const SkeletonText = _ref => {
|
|
|
59
59
|
lines.push(/*#__PURE__*/React__default.createElement("p", _extends({
|
|
60
60
|
className: skeletonTextClasses,
|
|
61
61
|
key: i,
|
|
62
|
-
ref: el =>
|
|
62
|
+
ref: el => {
|
|
63
|
+
refs.current = [...refs.current, el];
|
|
64
|
+
}
|
|
63
65
|
}, rest)));
|
|
64
66
|
}
|
|
65
67
|
if (lineCountNumber !== 1) {
|
|
@@ -319,9 +319,9 @@ declare class Slider extends PureComponent<SliderProps> {
|
|
|
319
319
|
correctedPosition: null;
|
|
320
320
|
isRtl: boolean;
|
|
321
321
|
};
|
|
322
|
-
thumbRef: React.RefObject<HTMLDivElement>;
|
|
323
|
-
thumbRefUpper: React.RefObject<HTMLDivElement>;
|
|
324
|
-
filledTrackRef: React.RefObject<HTMLDivElement>;
|
|
322
|
+
thumbRef: React.RefObject<HTMLDivElement | null>;
|
|
323
|
+
thumbRefUpper: React.RefObject<HTMLDivElement | null>;
|
|
324
|
+
filledTrackRef: React.RefObject<HTMLDivElement | null>;
|
|
325
325
|
element: HTMLDivElement | null;
|
|
326
326
|
inputId: string;
|
|
327
327
|
track: HTMLDivElement | null | undefined;
|
|
@@ -339,16 +339,6 @@ declare class Slider extends PureComponent<SliderProps> {
|
|
|
339
339
|
* should be called.
|
|
340
340
|
*/
|
|
341
341
|
componentDidUpdate(prevProps: any, prevState: any): void;
|
|
342
|
-
/**
|
|
343
|
-
* Synonymous to ECMA2017+ `Math.clamp`.
|
|
344
|
-
*
|
|
345
|
-
* @param {number} val
|
|
346
|
-
* @param {number} min
|
|
347
|
-
* @param {number} max
|
|
348
|
-
*
|
|
349
|
-
* @returns `val` if `max>=val>=min`; `min` if `val<min`; `max` if `val>max`.
|
|
350
|
-
*/
|
|
351
|
-
clamp(val: any, min: any, max: any): number;
|
|
352
342
|
/**
|
|
353
343
|
* Rounds a given value to the nearest step defined by the slider's `step`
|
|
354
344
|
* prop.
|
|
@@ -19,6 +19,7 @@ import '../Text/index.js';
|
|
|
19
19
|
import '../Tooltip/DefinitionTooltip.js';
|
|
20
20
|
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
21
21
|
import { LowerHandle, LowerHandleFocus, UpperHandle, UpperHandleFocus } from './SliderHandles.js';
|
|
22
|
+
import { clamp } from '../../internal/clamp.js';
|
|
22
23
|
import { throttle } from '../../node_modules/es-toolkit/dist/compat/function/throttle.mjs.js';
|
|
23
24
|
import { Text } from '../Text/Text.js';
|
|
24
25
|
|
|
@@ -564,7 +565,7 @@ class Slider extends PureComponent {
|
|
|
564
565
|
range
|
|
565
566
|
});
|
|
566
567
|
/** `leftPercentRaw` clamped between 0 and 1. */
|
|
567
|
-
const leftPercent =
|
|
568
|
+
const leftPercent = clamp(leftPercentRaw, 0, 1);
|
|
568
569
|
if (useRawValue) {
|
|
569
570
|
return {
|
|
570
571
|
value,
|
|
@@ -855,19 +856,6 @@ class Slider extends PureComponent {
|
|
|
855
856
|
}
|
|
856
857
|
}
|
|
857
858
|
|
|
858
|
-
/**
|
|
859
|
-
* Synonymous to ECMA2017+ `Math.clamp`.
|
|
860
|
-
*
|
|
861
|
-
* @param {number} val
|
|
862
|
-
* @param {number} min
|
|
863
|
-
* @param {number} max
|
|
864
|
-
*
|
|
865
|
-
* @returns `val` if `max>=val>=min`; `min` if `val<min`; `max` if `val>max`.
|
|
866
|
-
*/
|
|
867
|
-
clamp(val, min, max) {
|
|
868
|
-
return Math.max(min, Math.min(val, max));
|
|
869
|
-
}
|
|
870
|
-
|
|
871
859
|
/**
|
|
872
860
|
* Rounds a given value to the nearest step defined by the slider's `step`
|
|
873
861
|
* prop.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import React, { type ReactNode, type MouseEvent, type KeyboardEvent, type HTMLAttributes, type ComponentType, type
|
|
8
|
+
import React, { type ReactNode, type MouseEvent, type KeyboardEvent, type HTMLAttributes, type ComponentType, type HTMLElementType } from 'react';
|
|
9
9
|
type DivAttributes = HTMLAttributes<HTMLDivElement>;
|
|
10
10
|
/**
|
|
11
11
|
* Tabs
|
|
@@ -312,7 +312,7 @@ export interface TabProps extends HTMLAttributes<HTMLElement> {
|
|
|
312
312
|
/**
|
|
313
313
|
* Provide a custom element to render instead of the default button
|
|
314
314
|
*/
|
|
315
|
-
as?:
|
|
315
|
+
as?: HTMLElementType | ComponentType;
|
|
316
316
|
/**
|
|
317
317
|
* Provide child elements to be rendered inside `Tab`.
|
|
318
318
|
*/
|