@carbon/react 1.100.0-rc.0 → 1.101.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +933 -933
- package/es/components/AILabel/index.d.ts +1 -1
- package/es/components/AILabel/index.js +1 -12
- package/es/components/Checkbox/Checkbox.js +5 -3
- package/es/components/CheckboxGroup/CheckboxGroup.js +4 -3
- package/es/components/CodeSnippet/CodeSnippet.d.ts +1 -1
- package/es/components/ComboBox/ComboBox.d.ts +3 -4
- package/es/components/ComboBox/ComboBox.js +20 -18
- package/es/components/ComboButton/index.d.ts +1 -1
- package/es/components/ComboButton/index.js +3 -2
- package/es/components/ComposedModal/ComposedModal.js +17 -22
- package/es/components/ComposedModal/ModalHeader.d.ts +2 -2
- package/es/components/ComposedModal/ModalHeader.js +1 -1
- package/es/components/Copy/Copy.d.ts +1 -1
- package/es/components/CopyButton/CopyButton.d.ts +1 -1
- package/es/components/DataTable/DataTable.d.ts +2 -0
- package/es/components/DataTable/DataTable.js +6 -5
- package/es/components/DataTable/Table.d.ts +1 -1
- package/es/components/DataTable/Table.js +10 -4
- package/es/components/DataTable/state/sorting.d.ts +4 -2
- package/es/components/Dropdown/Dropdown.d.ts +3 -4
- package/es/components/Dropdown/Dropdown.js +16 -13
- package/es/components/FileUploader/FileUploaderItem.d.ts +1 -1
- package/es/components/FileUploader/FileUploaderItem.js +3 -2
- package/es/components/FluidComboBox/FluidComboBox.d.ts +2 -7
- package/es/components/FluidComboBox/FluidComboBox.js +1 -2
- package/es/components/FluidDropdown/FluidDropdown.d.ts +1 -6
- package/es/components/FluidDropdown/FluidDropdown.js +1 -2
- package/es/components/FluidMultiSelect/FluidMultiSelect.d.ts +1 -6
- package/es/components/FluidMultiSelect/FluidMultiSelect.js +1 -2
- package/es/components/InlineLoading/InlineLoading.js +5 -11
- package/es/components/Menu/Menu.js +8 -4
- package/es/components/Menu/MenuItem.d.ts +5 -1
- package/es/components/Menu/MenuItem.js +11 -1
- package/es/components/MenuButton/index.d.ts +1 -1
- package/es/components/MenuButton/index.js +3 -2
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +7 -5
- package/es/components/MultiSelect/MultiSelect.d.ts +3 -4
- package/es/components/MultiSelect/MultiSelect.js +10 -13
- package/es/components/Notification/Notification.js +5 -3
- package/es/components/NumberInput/NumberInput.d.ts +1 -1
- package/es/components/NumberInput/NumberInput.js +5 -4
- package/es/components/OverflowMenu/OverflowMenu.d.ts +1 -0
- package/es/components/OverflowMenu/OverflowMenu.js +8 -4
- package/es/components/PageHeader/PageHeader.d.ts +1 -1
- package/es/components/PageHeader/PageHeader.js +5 -5
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +4 -3
- package/es/components/Select/Select.js +2 -1
- package/es/components/StructuredList/StructuredList.d.ts +1 -1
- package/es/components/StructuredList/StructuredList.js +2 -4
- package/es/components/Tabs/Tabs.d.ts +2 -2
- package/es/components/Tabs/Tabs.js +20 -26
- package/es/components/Tag/DismissibleTag.js +3 -2
- package/es/components/Tag/OperationalTag.js +3 -2
- package/es/components/Tag/SelectableTag.js +3 -2
- package/es/components/Tag/Tag.js +3 -2
- package/es/components/TextArea/TextArea.d.ts +1 -1
- package/es/components/TextArea/TextArea.js +7 -8
- package/es/components/TextInput/ControlledPasswordInput.js +7 -6
- package/es/components/TextInput/PasswordInput.js +5 -6
- package/es/components/TextInput/TextInput.js +4 -4
- package/es/components/Tile/Tile.d.ts +1 -1
- package/es/components/Tile/Tile.js +37 -69
- package/es/components/TimePicker/TimePicker.js +2 -2
- package/es/components/Tooltip/DefinitionTooltip.d.ts +1 -1
- package/es/components/Tooltip/DefinitionTooltip.js +3 -2
- package/es/components/UIShell/SideNav.d.ts +0 -1
- package/es/components/UIShell/SideNav.js +12 -3
- package/es/internal/useId.js +3 -4
- package/es/internal/usePresence.js +3 -2
- package/es/internal/useResizeObserver.d.ts +1 -1
- package/es/internal/useResizeObserver.js +5 -7
- package/es/tools/events.d.ts +1 -1
- package/lib/components/AILabel/index.d.ts +1 -1
- package/lib/components/AILabel/index.js +1 -12
- package/lib/components/Checkbox/Checkbox.js +5 -3
- package/lib/components/CheckboxGroup/CheckboxGroup.js +4 -3
- package/lib/components/CodeSnippet/CodeSnippet.d.ts +1 -1
- package/lib/components/ComboBox/ComboBox.d.ts +3 -4
- package/lib/components/ComboBox/ComboBox.js +20 -18
- package/lib/components/ComboButton/index.d.ts +1 -1
- package/lib/components/ComboButton/index.js +2 -1
- package/lib/components/ComposedModal/ComposedModal.js +16 -21
- package/lib/components/ComposedModal/ModalHeader.d.ts +2 -2
- package/lib/components/ComposedModal/ModalHeader.js +1 -1
- package/lib/components/Copy/Copy.d.ts +1 -1
- package/lib/components/CopyButton/CopyButton.d.ts +1 -1
- package/lib/components/DataTable/DataTable.d.ts +2 -0
- package/lib/components/DataTable/DataTable.js +6 -5
- package/lib/components/DataTable/Table.d.ts +1 -1
- package/lib/components/DataTable/Table.js +10 -4
- package/lib/components/DataTable/state/sorting.d.ts +4 -2
- package/lib/components/Dropdown/Dropdown.d.ts +3 -4
- package/lib/components/Dropdown/Dropdown.js +16 -13
- package/lib/components/FileUploader/FileUploaderItem.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderItem.js +2 -1
- package/lib/components/FluidComboBox/FluidComboBox.d.ts +2 -7
- package/lib/components/FluidComboBox/FluidComboBox.js +1 -2
- package/lib/components/FluidDropdown/FluidDropdown.d.ts +1 -6
- package/lib/components/FluidDropdown/FluidDropdown.js +1 -2
- package/lib/components/FluidMultiSelect/FluidMultiSelect.d.ts +1 -6
- package/lib/components/FluidMultiSelect/FluidMultiSelect.js +1 -2
- package/lib/components/InlineLoading/InlineLoading.js +5 -11
- package/lib/components/Menu/Menu.js +7 -3
- package/lib/components/Menu/MenuItem.d.ts +5 -1
- package/lib/components/Menu/MenuItem.js +11 -1
- package/lib/components/MenuButton/index.d.ts +1 -1
- package/lib/components/MenuButton/index.js +2 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +6 -4
- package/lib/components/MultiSelect/MultiSelect.d.ts +3 -4
- package/lib/components/MultiSelect/MultiSelect.js +9 -12
- package/lib/components/Notification/Notification.js +5 -3
- package/lib/components/NumberInput/NumberInput.d.ts +1 -1
- package/lib/components/NumberInput/NumberInput.js +5 -4
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +1 -0
- package/lib/components/OverflowMenu/OverflowMenu.js +7 -3
- package/lib/components/PageHeader/PageHeader.d.ts +1 -1
- package/lib/components/PageHeader/PageHeader.js +4 -4
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +4 -3
- package/lib/components/Select/Select.js +2 -1
- package/lib/components/StructuredList/StructuredList.d.ts +1 -1
- package/lib/components/StructuredList/StructuredList.js +2 -4
- package/lib/components/Tabs/Tabs.d.ts +2 -2
- package/lib/components/Tabs/Tabs.js +15 -21
- package/lib/components/Tag/DismissibleTag.js +2 -1
- package/lib/components/Tag/OperationalTag.js +2 -1
- package/lib/components/Tag/SelectableTag.js +2 -1
- package/lib/components/Tag/Tag.js +2 -1
- package/lib/components/TextArea/TextArea.d.ts +1 -1
- package/lib/components/TextArea/TextArea.js +7 -8
- package/lib/components/TextInput/ControlledPasswordInput.js +7 -6
- package/lib/components/TextInput/PasswordInput.js +5 -6
- package/lib/components/TextInput/TextInput.js +4 -4
- package/lib/components/Tile/Tile.d.ts +1 -1
- package/lib/components/Tile/Tile.js +35 -67
- package/lib/components/TimePicker/TimePicker.js +2 -2
- package/lib/components/Tooltip/DefinitionTooltip.d.ts +1 -1
- package/lib/components/Tooltip/DefinitionTooltip.js +3 -2
- package/lib/components/UIShell/SideNav.d.ts +0 -1
- package/lib/components/UIShell/SideNav.js +11 -2
- package/lib/internal/useId.js +2 -3
- package/lib/internal/usePresence.js +2 -1
- package/lib/internal/useResizeObserver.d.ts +1 -1
- package/lib/internal/useResizeObserver.js +4 -6
- package/lib/tools/events.d.ts +1 -1
- package/package.json +8 -8
|
@@ -10,14 +10,13 @@ import { Close, ChevronLeft, ChevronRight } from '@carbon/icons-react';
|
|
|
10
10
|
import { breakpoints } from '@carbon/layout';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import PropTypes from 'prop-types';
|
|
13
|
-
import React, { forwardRef, createContext, useRef, useState, useMemo, isValidElement, useCallback, useEffect } from 'react';
|
|
13
|
+
import React, { forwardRef, createContext, useRef, useState, useMemo, isValidElement, Children, cloneElement, useCallback, useEffect } from 'react';
|
|
14
14
|
import '../Grid/FlexGrid.js';
|
|
15
15
|
import { Grid as GridAsGridComponent } from '../Grid/Grid.js';
|
|
16
16
|
import '../Grid/Row.js';
|
|
17
17
|
import '../Grid/Column.js';
|
|
18
18
|
import '../Grid/ColumnHang.js';
|
|
19
19
|
import '../Grid/GridContext.js';
|
|
20
|
-
import { isElement } from 'react-is';
|
|
21
20
|
import '../Tooltip/DefinitionTooltip.js';
|
|
22
21
|
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
23
22
|
import { useControllableState } from '../../internal/useControllableState.js';
|
|
@@ -34,6 +33,7 @@ import { useMatchMedia } from '../../internal/useMatchMedia.js';
|
|
|
34
33
|
import { Text } from '../Text/Text.js';
|
|
35
34
|
import '../Text/TextDirection.js';
|
|
36
35
|
import { BadgeIndicator } from '../BadgeIndicator/index.js';
|
|
36
|
+
import { isComponentElement } from '../../internal/utils.js';
|
|
37
37
|
import { debounce } from '../../node_modules/es-toolkit/dist/compat/function/debounce.js';
|
|
38
38
|
|
|
39
39
|
var _ChevronLeft, _ChevronRight, _BadgeIndicator;
|
|
@@ -269,14 +269,7 @@ function TabList({
|
|
|
269
269
|
const nextButton = useRef(null);
|
|
270
270
|
const [isScrollable, setIsScrollable] = useState(false);
|
|
271
271
|
const [scrollLeft, setScrollLeft] = useState(0);
|
|
272
|
-
|
|
273
|
-
if (contained) {
|
|
274
|
-
hasSecondaryLabelTabs = React.Children.toArray(children).some(child => {
|
|
275
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
276
|
-
const _child = child;
|
|
277
|
-
return /*#__PURE__*/React.isValidElement(child) && !!_child.props.secondaryLabel;
|
|
278
|
-
});
|
|
279
|
-
}
|
|
272
|
+
const hasSecondaryLabelTabs = contained && Children.toArray(children).some(child => isComponentElement(child, Tab) && typeof child.props.secondaryLabel !== 'undefined');
|
|
280
273
|
const isLg = useMatchMedia(lgMediaQuery);
|
|
281
274
|
const distributeWidth = fullWidth && contained && isLg && React.Children.toArray(children).length < 9;
|
|
282
275
|
const className = cx(`${prefix}--tabs`, {
|
|
@@ -487,17 +480,16 @@ function TabList({
|
|
|
487
480
|
onScroll: debouncedOnScroll,
|
|
488
481
|
onKeyDown: onKeyDown,
|
|
489
482
|
onBlur: handleBlur
|
|
490
|
-
}),
|
|
491
|
-
return !
|
|
483
|
+
}), Children.map(children, (child, index) => {
|
|
484
|
+
return ! /*#__PURE__*/isValidElement(child) ? null : /*#__PURE__*/React.createElement(TabContext.Provider, {
|
|
492
485
|
value: {
|
|
493
486
|
index,
|
|
494
487
|
hasSecondaryLabel: hasSecondaryLabelTabs,
|
|
495
488
|
contained
|
|
496
489
|
}
|
|
497
|
-
}, /*#__PURE__*/
|
|
498
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
499
|
-
child, {
|
|
490
|
+
}, /*#__PURE__*/cloneElement(child, {
|
|
500
491
|
ref: node => {
|
|
492
|
+
if (!node) return;
|
|
501
493
|
tabs.current[index] = node;
|
|
502
494
|
}
|
|
503
495
|
}));
|
|
@@ -641,8 +633,7 @@ function TabListVertical({
|
|
|
641
633
|
if (containerTop && containerHeight) {
|
|
642
634
|
// scrolls so selected tab is in view
|
|
643
635
|
if (selectedPositionTop - halfTabHeight < containerTop || selectedPositionTop - containerTop + verticalTabHeight + halfTabHeight > containerHeight) {
|
|
644
|
-
|
|
645
|
-
ref.current && ref.current.scrollTo({
|
|
636
|
+
ref.current?.scrollTo({
|
|
646
637
|
top: (selectedIndex - 1) * verticalTabHeight,
|
|
647
638
|
behavior: 'smooth'
|
|
648
639
|
});
|
|
@@ -690,16 +681,15 @@ function TabListVertical({
|
|
|
690
681
|
className: `${prefix}--tab--list`,
|
|
691
682
|
onKeyDown: onKeyDown,
|
|
692
683
|
onBlur: handleBlur
|
|
693
|
-
}),
|
|
694
|
-
return !
|
|
684
|
+
}), Children.map(children, (child, index) => {
|
|
685
|
+
return ! /*#__PURE__*/isValidElement(child) ? null : /*#__PURE__*/React.createElement(TabContext.Provider, {
|
|
695
686
|
value: {
|
|
696
687
|
index,
|
|
697
688
|
hasSecondaryLabel: false
|
|
698
689
|
}
|
|
699
|
-
}, /*#__PURE__*/
|
|
700
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
701
|
-
child, {
|
|
690
|
+
}, /*#__PURE__*/cloneElement(child, {
|
|
702
691
|
ref: node => {
|
|
692
|
+
if (!node) return;
|
|
703
693
|
tabs.current[index] = node;
|
|
704
694
|
}
|
|
705
695
|
}));
|
|
@@ -1045,7 +1035,11 @@ const IconTab = /*#__PURE__*/React.forwardRef(({
|
|
|
1045
1035
|
const value = useMemo(() => ({
|
|
1046
1036
|
badgeIndicator
|
|
1047
1037
|
}), [badgeIndicator]);
|
|
1048
|
-
const hasSize20 = /*#__PURE__*/isValidElement(children) &&
|
|
1038
|
+
const hasSize20 = /*#__PURE__*/isValidElement(children) &&
|
|
1039
|
+
// TODO: The interface allows `size` to be a string. Should this case be
|
|
1040
|
+
// handled here, or should the prop type be restricted to `number`
|
|
1041
|
+
// instead?
|
|
1042
|
+
children.props.size === 20;
|
|
1049
1043
|
const classNames = cx(`${prefix}--tabs__nav-item--icon-only`, customClassName, {
|
|
1050
1044
|
[`${prefix}--tabs__nav-item--icon-only__20`]: hasSize20
|
|
1051
1045
|
});
|
|
@@ -1176,10 +1170,10 @@ function TabPanels({
|
|
|
1176
1170
|
});
|
|
1177
1171
|
}
|
|
1178
1172
|
});
|
|
1179
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
1180
|
-
return !
|
|
1173
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, Children.map(children, (child, index) => {
|
|
1174
|
+
return ! /*#__PURE__*/isValidElement(child) ? null : /*#__PURE__*/React.createElement(TabPanelContext.Provider, {
|
|
1181
1175
|
value: index
|
|
1182
|
-
}, /*#__PURE__*/
|
|
1176
|
+
}, /*#__PURE__*/cloneElement(child, {
|
|
1183
1177
|
ref: element => {
|
|
1184
1178
|
refs.current[index] = element;
|
|
1185
1179
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React, { forwardRef, useRef, useState,
|
|
10
|
+
import React, { forwardRef, useRef, useState, cloneElement } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { useId } from '../../internal/useId.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
@@ -22,6 +22,7 @@ import { isEllipsisActive } from './isEllipsisActive.js';
|
|
|
22
22
|
import { mergeRefs } from '../../tools/mergeRefs.js';
|
|
23
23
|
import { AILabel } from '../AILabel/index.js';
|
|
24
24
|
import { isComponentElement } from '../../internal/utils.js';
|
|
25
|
+
import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
|
|
25
26
|
|
|
26
27
|
var _Close;
|
|
27
28
|
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
@@ -48,7 +49,7 @@ const DismissibleTag = /*#__PURE__*/forwardRef(({
|
|
|
48
49
|
const tagId = id || `tag-${useId()}`;
|
|
49
50
|
const tagClasses = cx(`${prefix}--tag--filter`, className);
|
|
50
51
|
const [isEllipsisApplied, setIsEllipsisApplied] = useState(false);
|
|
51
|
-
|
|
52
|
+
useIsomorphicEffect(() => {
|
|
52
53
|
const newElement = tagLabelRef.current?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
53
54
|
setIsEllipsisApplied(isEllipsisActive(newElement));
|
|
54
55
|
}, [prefix, tagLabelRef]);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React, { forwardRef, useRef, useState
|
|
10
|
+
import React, { forwardRef, useRef, useState } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { useId } from '../../internal/useId.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
@@ -18,6 +18,7 @@ import { Text } from '../Text/Text.js';
|
|
|
18
18
|
import '../Text/TextDirection.js';
|
|
19
19
|
import { isEllipsisActive } from './isEllipsisActive.js';
|
|
20
20
|
import { mergeRefs } from '../../tools/mergeRefs.js';
|
|
21
|
+
import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
|
|
21
22
|
|
|
22
23
|
const TYPES = {
|
|
23
24
|
red: 'Red',
|
|
@@ -48,7 +49,7 @@ const OperationalTag = /*#__PURE__*/forwardRef(({
|
|
|
48
49
|
const tagId = id || `tag-${useId()}`;
|
|
49
50
|
const tagClasses = cx(`${prefix}--tag--operational`, className);
|
|
50
51
|
const [isEllipsisApplied, setIsEllipsisApplied] = useState(false);
|
|
51
|
-
|
|
52
|
+
useIsomorphicEffect(() => {
|
|
52
53
|
const newElement = tagRef.current?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
53
54
|
setIsEllipsisApplied(isEllipsisActive(newElement));
|
|
54
55
|
}, [prefix, tagRef]);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React, { forwardRef, useRef, useState
|
|
10
|
+
import React, { forwardRef, useRef, useState } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { useId } from '../../internal/useId.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
@@ -19,6 +19,7 @@ import '../Text/TextDirection.js';
|
|
|
19
19
|
import { isEllipsisActive } from './isEllipsisActive.js';
|
|
20
20
|
import { mergeRefs } from '../../tools/mergeRefs.js';
|
|
21
21
|
import { useControllableState } from '../../internal/useControllableState.js';
|
|
22
|
+
import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
|
|
22
23
|
|
|
23
24
|
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
24
25
|
const SelectableTag = /*#__PURE__*/forwardRef(({
|
|
@@ -47,7 +48,7 @@ const SelectableTag = /*#__PURE__*/forwardRef(({
|
|
|
47
48
|
[`${prefix}--tag--selectable-selected`]: selectedTag
|
|
48
49
|
});
|
|
49
50
|
const [isEllipsisApplied, setIsEllipsisApplied] = useState(false);
|
|
50
|
-
|
|
51
|
+
useIsomorphicEffect(() => {
|
|
51
52
|
const newElement = tagRef.current?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
52
53
|
setIsEllipsisApplied(isEllipsisActive(newElement));
|
|
53
54
|
}, [prefix, tagRef]);
|
package/es/components/Tag/Tag.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React, { useRef, useState,
|
|
10
|
+
import React, { useRef, useState, cloneElement } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { Close } from '@carbon/icons-react';
|
|
13
13
|
import { useId } from '../../internal/useId.js';
|
|
@@ -21,6 +21,7 @@ import { isEllipsisActive } from './isEllipsisActive.js';
|
|
|
21
21
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
22
22
|
import { AILabel } from '../AILabel/index.js';
|
|
23
23
|
import { isComponentElement } from '../../internal/utils.js';
|
|
24
|
+
import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
|
|
24
25
|
|
|
25
26
|
var _Close;
|
|
26
27
|
const TYPES = {
|
|
@@ -76,7 +77,7 @@ const TagBase = /*#__PURE__*/React.forwardRef(({
|
|
|
76
77
|
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
77
78
|
const tagId = id || `tag-${useId()}`;
|
|
78
79
|
const [isEllipsisApplied, setIsEllipsisApplied] = useState(false);
|
|
79
|
-
|
|
80
|
+
useIsomorphicEffect(() => {
|
|
80
81
|
const newElement = tagRef.current?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
81
82
|
setIsEllipsisApplied(isEllipsisActive(newElement));
|
|
82
83
|
}, [prefix, tagRef]);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React, { type ReactNode } from 'react';
|
|
8
|
-
export interface TextAreaProps extends React.
|
|
8
|
+
export interface TextAreaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
9
9
|
/**
|
|
10
10
|
* Provide a custom className that is applied directly to the underlying
|
|
11
11
|
* `<textarea>` node
|
|
@@ -144,9 +144,7 @@ const TextArea = frFn((props, forwardRef) => {
|
|
|
144
144
|
setTimeout(() => {
|
|
145
145
|
setTextCount(0);
|
|
146
146
|
}, 0);
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
if (enableCounter && typeof maxCount !== 'undefined' && textareaRef.current !== null) {
|
|
147
|
+
} else if (enableCounter && typeof maxCount !== 'undefined' && textareaRef.current !== null) {
|
|
150
148
|
const matchedWords = evt.target?.value?.match(/\p{L}+/gu);
|
|
151
149
|
if (matchedWords && matchedWords.length <= maxCount) {
|
|
152
150
|
textareaRef.current.removeAttribute('maxLength');
|
|
@@ -195,24 +193,25 @@ const TextArea = frFn((props, forwardRef) => {
|
|
|
195
193
|
const helperTextClasses = cx(`${prefix}--form__helper-text`, {
|
|
196
194
|
[`${prefix}--form__helper-text--disabled`]: disabled
|
|
197
195
|
});
|
|
198
|
-
const label = labelText
|
|
196
|
+
const label = typeof labelText !== 'undefined' && labelText !== null && /*#__PURE__*/React.createElement(Text, {
|
|
199
197
|
as: "label",
|
|
200
198
|
htmlFor: id,
|
|
201
199
|
className: labelClasses
|
|
202
|
-
}, labelText)
|
|
200
|
+
}, labelText);
|
|
203
201
|
const counter = enableCounter && maxCount && (counterMode === 'character' || counterMode === 'word') ? /*#__PURE__*/React.createElement(Text, {
|
|
204
202
|
as: "div",
|
|
205
203
|
className: counterClasses,
|
|
206
204
|
"aria-hidden": "true"
|
|
207
205
|
}, `${textCount}/${maxCount}`) : null;
|
|
208
206
|
const counterDescriptionId = enableCounter && maxCount ? `${id}-counter-desc` : undefined;
|
|
209
|
-
const
|
|
210
|
-
const
|
|
207
|
+
const hasHelper = typeof helperText !== 'undefined' && helperText !== null;
|
|
208
|
+
const helperId = !hasHelper ? undefined : `text-area-helper-text-${textAreaInstanceId}`;
|
|
209
|
+
const helper = hasHelper && /*#__PURE__*/React.createElement(Text, {
|
|
211
210
|
as: "div",
|
|
212
211
|
id: helperId,
|
|
213
212
|
className: helperTextClasses,
|
|
214
213
|
ref: helperTextRef
|
|
215
|
-
}, helperText)
|
|
214
|
+
}, helperText);
|
|
216
215
|
const errorId = id + '-error-msg';
|
|
217
216
|
const error = invalid ? /*#__PURE__*/React.createElement(Text, {
|
|
218
217
|
as: "div",
|
|
@@ -71,10 +71,10 @@ const ControlledPasswordInput = /*#__PURE__*/forwardRef(({
|
|
|
71
71
|
const helperTextClasses = cx(`${prefix}--form__helper-text`, {
|
|
72
72
|
[`${prefix}--form__helper-text--disabled`]: disabled
|
|
73
73
|
});
|
|
74
|
-
const label = labelText
|
|
74
|
+
const label = typeof labelText !== 'undefined' && labelText !== null && /*#__PURE__*/React.createElement("label", {
|
|
75
75
|
htmlFor: id,
|
|
76
76
|
className: labelClasses
|
|
77
|
-
}, labelText)
|
|
77
|
+
}, labelText);
|
|
78
78
|
const error = invalid ? /*#__PURE__*/React.createElement("div", {
|
|
79
79
|
className: `${prefix}--form-requirement`,
|
|
80
80
|
id: errorId
|
|
@@ -89,12 +89,13 @@ const ControlledPasswordInput = /*#__PURE__*/forwardRef(({
|
|
|
89
89
|
[`${prefix}--tooltip--${tooltipPosition}`]: tooltipPosition,
|
|
90
90
|
[`${prefix}--tooltip--align-${tooltipAlignment}`]: tooltipAlignment
|
|
91
91
|
});
|
|
92
|
-
const
|
|
92
|
+
const hasHelper = typeof helperText !== 'undefined' && helperText !== null;
|
|
93
|
+
const helperId = !hasHelper ? undefined : `controlled-password-helper-text-${controlledPasswordInstanceId}`;
|
|
93
94
|
const input = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("input", _extends({}, getTextInputProps({
|
|
94
95
|
invalid,
|
|
95
96
|
sharedTextInputProps,
|
|
96
97
|
invalidId: errorId,
|
|
97
|
-
hasHelper: !error &&
|
|
98
|
+
hasHelper: !error && hasHelper,
|
|
98
99
|
helperId
|
|
99
100
|
}), {
|
|
100
101
|
"data-toggle-password-visibility": type === 'password'
|
|
@@ -105,10 +106,10 @@ const ControlledPasswordInput = /*#__PURE__*/forwardRef(({
|
|
|
105
106
|
}, /*#__PURE__*/React.createElement("span", {
|
|
106
107
|
className: `${prefix}--assistive-text`
|
|
107
108
|
}, passwordIsVisible ? hidePasswordLabel : showPasswordLabel), passwordVisibilityIcon));
|
|
108
|
-
const helper =
|
|
109
|
+
const helper = hasHelper && /*#__PURE__*/React.createElement("div", {
|
|
109
110
|
id: helperId,
|
|
110
111
|
className: helperTextClasses
|
|
111
|
-
}, helperText)
|
|
112
|
+
}, helperText);
|
|
112
113
|
return /*#__PURE__*/React.createElement("div", {
|
|
113
114
|
className: `${prefix}--form-item ${prefix}--text-input-wrapper ${prefix}--password-input-wrapper`
|
|
114
115
|
}, label, /*#__PURE__*/React.createElement("div", {
|
|
@@ -61,8 +61,7 @@ const PasswordInput = /*#__PURE__*/forwardRef(({
|
|
|
61
61
|
} = useContext(FormContext);
|
|
62
62
|
const handleTogglePasswordVisibility = event => {
|
|
63
63
|
setInputType(inputType === 'password' ? 'text' : 'password');
|
|
64
|
-
|
|
65
|
-
onTogglePasswordVisibility && onTogglePasswordVisibility(event);
|
|
64
|
+
onTogglePasswordVisibility?.(event);
|
|
66
65
|
};
|
|
67
66
|
const textInputClasses = cx(`${prefix}--text-input`, `${prefix}--password-input`, className, {
|
|
68
67
|
[`${prefix}--text-input--light`]: light,
|
|
@@ -117,14 +116,14 @@ const PasswordInput = /*#__PURE__*/forwardRef(({
|
|
|
117
116
|
[`${prefix}--text-input__invalid-icon`]: normalizedProps.invalid || normalizedProps.warn,
|
|
118
117
|
[`${prefix}--text-input__invalid-icon--warning`]: normalizedProps.warn
|
|
119
118
|
});
|
|
120
|
-
const label = labelText
|
|
119
|
+
const label = typeof labelText !== 'undefined' && labelText !== null && /*#__PURE__*/React.createElement("label", {
|
|
121
120
|
htmlFor: id,
|
|
122
121
|
className: labelClasses
|
|
123
|
-
}, labelText)
|
|
124
|
-
const helper = helperText
|
|
122
|
+
}, labelText);
|
|
123
|
+
const helper = typeof helperText !== 'undefined' && helperText !== null && /*#__PURE__*/React.createElement("div", {
|
|
125
124
|
id: normalizedProps.helperId,
|
|
126
125
|
className: helperTextClasses
|
|
127
|
-
}, helperText)
|
|
126
|
+
}, helperText);
|
|
128
127
|
const passwordIsVisible = inputType === 'text';
|
|
129
128
|
const passwordVisibilityIcon = passwordIsVisible ? /*#__PURE__*/React.createElement(ViewOff, {
|
|
130
129
|
className: `${prefix}--icon-visibility-off`
|
|
@@ -141,19 +141,19 @@ const TextInput = /*#__PURE__*/forwardRef(({
|
|
|
141
141
|
as: "div",
|
|
142
142
|
className: counterClasses
|
|
143
143
|
}, `${textCount}/${maxCount}`) : null;
|
|
144
|
-
const label = labelText
|
|
144
|
+
const label = typeof labelText !== 'undefined' && labelText !== null && /*#__PURE__*/React.createElement(Text, {
|
|
145
145
|
as: "label",
|
|
146
146
|
htmlFor: id,
|
|
147
147
|
className: labelClasses
|
|
148
|
-
}, labelText)
|
|
148
|
+
}, labelText);
|
|
149
149
|
const labelWrapper = /*#__PURE__*/React.createElement("div", {
|
|
150
150
|
className: `${prefix}--text-input__label-wrapper`
|
|
151
151
|
}, label, counter);
|
|
152
|
-
const helper = helperText
|
|
152
|
+
const helper = typeof helperText !== 'undefined' && helperText !== null && /*#__PURE__*/React.createElement(Text, {
|
|
153
153
|
as: "div",
|
|
154
154
|
id: normalizedProps.helperId,
|
|
155
155
|
className: helperTextClasses
|
|
156
|
-
}, helperText)
|
|
156
|
+
}, helperText);
|
|
157
157
|
const input = /*#__PURE__*/React.createElement("input", getTextInputProps({
|
|
158
158
|
sharedTextInputProps,
|
|
159
159
|
invalid: normalizedProps.invalid,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React, { useState, useEffect, useCallback, useRef, cloneElement } from 'react';
|
|
9
|
+
import React, { forwardRef, useState, useEffect, useCallback, useRef, cloneElement, Children } from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { AiLabel, CheckboxCheckedFilled, Checkbox, ChevronDown, ArrowRight, Error } from '@carbon/icons-react';
|
|
@@ -363,7 +363,7 @@ SelectableTile.propTypes = {
|
|
|
363
363
|
*/
|
|
364
364
|
value: deprecate(PropTypes.oneOfType([PropTypes.string, PropTypes.number]), 'The `value` property is no longer used. It will be removed in the next major release.`')
|
|
365
365
|
};
|
|
366
|
-
const ExpandableTile = /*#__PURE__*/
|
|
366
|
+
const ExpandableTile = /*#__PURE__*/forwardRef(({
|
|
367
367
|
tabIndex = 0,
|
|
368
368
|
className,
|
|
369
369
|
children,
|
|
@@ -382,11 +382,8 @@ const ExpandableTile = /*#__PURE__*/React.forwardRef(({
|
|
|
382
382
|
hasRoundedCorners,
|
|
383
383
|
...rest
|
|
384
384
|
}, forwardRef) => {
|
|
385
|
-
const [
|
|
386
|
-
const [
|
|
387
|
-
const [prevExpanded, setPrevExpanded] = useState(expanded);
|
|
388
|
-
const [prevTileMaxHeight, setPrevTileMaxHeight] = useState(tileMaxHeight);
|
|
389
|
-
const [prevTilePadding, setPrevTilePadding] = useState(tilePadding);
|
|
385
|
+
const [measuredAboveHeight, setMeasuredAboveHeight] = useState(0);
|
|
386
|
+
const [measuredPadding, setMeasuredPadding] = useState(0);
|
|
390
387
|
const [isExpanded, setIsExpanded] = useState(expanded);
|
|
391
388
|
const [interactive, setInteractive] = useState(true);
|
|
392
389
|
const aboveTheFold = useRef(null);
|
|
@@ -396,105 +393,74 @@ const ExpandableTile = /*#__PURE__*/React.forwardRef(({
|
|
|
396
393
|
const tile = useRef(null);
|
|
397
394
|
const ref = useMergedRefs([forwardRef, tile]);
|
|
398
395
|
const prefix = usePrefix();
|
|
399
|
-
|
|
396
|
+
useEffect(() => {
|
|
400
397
|
setIsExpanded(expanded);
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
setPrevTileMaxHeight(tileMaxHeight);
|
|
407
|
-
}
|
|
408
|
-
if (tilePadding !== prevTilePadding) {
|
|
409
|
-
setIsTilePadding(tilePadding);
|
|
410
|
-
setPrevTilePadding(tilePadding);
|
|
411
|
-
}
|
|
412
|
-
function setMaxHeight() {
|
|
413
|
-
if (isExpanded && tileContent.current) {
|
|
414
|
-
setIsTileMaxHeight(tileContent.current.getBoundingClientRect()?.height);
|
|
415
|
-
}
|
|
416
|
-
if (aboveTheFold.current) {
|
|
417
|
-
setIsTileMaxHeight(aboveTheFold.current.getBoundingClientRect().height);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
function handleClick(evt) {
|
|
421
|
-
evt?.persist?.();
|
|
422
|
-
setIsExpanded(!isExpanded);
|
|
423
|
-
setMaxHeight();
|
|
424
|
-
}
|
|
425
|
-
function handleKeyUp(evt) {
|
|
398
|
+
}, [expanded]);
|
|
399
|
+
const handleClick = () => {
|
|
400
|
+
setIsExpanded(prev => !prev);
|
|
401
|
+
};
|
|
402
|
+
const handleKeyUp = evt => {
|
|
426
403
|
if (evt.target !== tile.current && evt.target !== chevronInteractiveRef.current) {
|
|
427
404
|
if (matches(evt, [Enter, Space])) {
|
|
428
405
|
evt.preventDefault();
|
|
429
406
|
}
|
|
430
407
|
}
|
|
431
|
-
}
|
|
432
|
-
function getChildren() {
|
|
433
|
-
return React.Children.toArray(children);
|
|
434
|
-
}
|
|
408
|
+
};
|
|
435
409
|
const classNames = cx(`${prefix}--tile`, `${prefix}--tile--expandable`, {
|
|
436
410
|
[`${prefix}--tile--is-expanded`]: isExpanded,
|
|
437
411
|
[`${prefix}--tile--light`]: light
|
|
438
412
|
}, className);
|
|
439
|
-
const interactiveClassNames = cx(
|
|
440
|
-
[`${prefix}--tile--is-expanded`]: isExpanded,
|
|
441
|
-
[`${prefix}--tile--light`]: light,
|
|
413
|
+
const interactiveClassNames = cx(classNames, `${prefix}--tile--expandable--interactive`, {
|
|
442
414
|
[`${prefix}--tile--slug`]: slug,
|
|
443
415
|
[`${prefix}--tile--slug-rounded`]: slug && hasRoundedCorners,
|
|
444
416
|
[`${prefix}--tile--decorator`]: decorator,
|
|
445
417
|
[`${prefix}--tile--decorator-rounded`]: decorator && hasRoundedCorners
|
|
446
|
-
}
|
|
418
|
+
});
|
|
447
419
|
const chevronInteractiveClassNames = cx(`${prefix}--tile__chevron`, `${prefix}--tile__chevron--interactive`);
|
|
448
|
-
const childrenAsArray =
|
|
420
|
+
const childrenAsArray = Children.toArray(children);
|
|
449
421
|
useIsomorphicEffect(() => {
|
|
450
422
|
if (!tile.current || !aboveTheFold.current) {
|
|
451
423
|
return;
|
|
452
424
|
}
|
|
453
|
-
const
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
} = node.getBoundingClientRect();
|
|
460
|
-
const paddingTop = parseInt(getStyle.getPropertyValue('padding-top'), 10);
|
|
461
|
-
const paddingBottom = parseInt(getStyle.getPropertyValue('padding-bottom'), 10);
|
|
462
|
-
setIsTileMaxHeight(height);
|
|
463
|
-
setIsTilePadding(paddingTop + paddingBottom);
|
|
464
|
-
}, [isTileMaxHeight]);
|
|
425
|
+
const style = window.getComputedStyle(tile.current);
|
|
426
|
+
const paddingTop = parseInt(style.getPropertyValue('padding-top'), 10) || 0;
|
|
427
|
+
const paddingBottom = parseInt(style.getPropertyValue('padding-bottom'), 10) || 0;
|
|
428
|
+
setMeasuredPadding(paddingTop + paddingBottom);
|
|
429
|
+
setMeasuredAboveHeight(aboveTheFold.current.scrollHeight);
|
|
430
|
+
}, []);
|
|
465
431
|
useIsomorphicEffect(() => {
|
|
466
432
|
if (!aboveTheFold.current || !belowTheFold.current) {
|
|
467
433
|
return;
|
|
468
434
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
if (!getInteractiveContent(belowTheFold.current) && !getRoleContent(belowTheFold.current) && !getInteractiveContent(aboveTheFold.current) && !getRoleContent(aboveTheFold.current) && !(slug || decorator)) {
|
|
473
|
-
setInteractive(false);
|
|
474
|
-
}
|
|
475
|
-
}, [slug, decorator]);
|
|
435
|
+
const hasInteractive = Boolean(getInteractiveContent(aboveTheFold.current)) || Boolean(getRoleContent(aboveTheFold.current)) || Boolean(getInteractiveContent(belowTheFold.current)) || Boolean(getRoleContent(belowTheFold.current)) || Boolean(slug || decorator);
|
|
436
|
+
setInteractive(hasInteractive);
|
|
437
|
+
}, [slug, decorator, children]);
|
|
476
438
|
useIsomorphicEffect(() => {
|
|
477
439
|
if (!tile.current) {
|
|
478
440
|
return;
|
|
479
441
|
}
|
|
480
442
|
if (isExpanded) {
|
|
481
443
|
tile.current.style.maxHeight = '';
|
|
482
|
-
|
|
483
|
-
tile.current.style.maxHeight = isTileMaxHeight + isTilePadding + 'px';
|
|
444
|
+
return;
|
|
484
445
|
}
|
|
485
|
-
|
|
446
|
+
const measured = measuredAboveHeight || aboveTheFold.current?.scrollHeight || 0;
|
|
447
|
+
const baseHeight = tileMaxHeight > 0 ? tileMaxHeight : measured;
|
|
448
|
+
const pad = tilePadding > 0 ? tilePadding : measuredPadding;
|
|
449
|
+
tile.current.style.maxHeight = `${baseHeight + pad}px`;
|
|
450
|
+
}, [isExpanded, tileMaxHeight, tilePadding, measuredAboveHeight, measuredPadding]);
|
|
486
451
|
useEffect(() => {
|
|
487
452
|
if (!aboveTheFold.current) {
|
|
488
453
|
return;
|
|
489
454
|
}
|
|
490
|
-
const resizeObserver = new ResizeObserver(
|
|
491
|
-
|
|
492
|
-
|
|
455
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
456
|
+
if (aboveTheFold.current) {
|
|
457
|
+
setMeasuredAboveHeight(aboveTheFold.current.scrollHeight);
|
|
458
|
+
}
|
|
493
459
|
});
|
|
494
460
|
resizeObserver.observe(aboveTheFold.current);
|
|
495
461
|
return () => resizeObserver.disconnect();
|
|
496
|
-
}, [
|
|
497
|
-
const belowTheFoldId = useId('expandable-tile-interactive');
|
|
462
|
+
}, []);
|
|
463
|
+
const belowTheFoldId = useId(interactive ? 'expandable-tile-interactive' : 'expandable-tile');
|
|
498
464
|
|
|
499
465
|
// AILabel is always size `xs`
|
|
500
466
|
const candidate = slug ?? decorator;
|
|
@@ -529,6 +495,7 @@ const ExpandableTile = /*#__PURE__*/React.forwardRef(({
|
|
|
529
495
|
type: "button",
|
|
530
496
|
ref: ref,
|
|
531
497
|
className: classNames,
|
|
498
|
+
"aria-controls": belowTheFoldId,
|
|
532
499
|
"aria-expanded": isExpanded,
|
|
533
500
|
title: isExpanded ? tileExpandedIconText : tileCollapsedIconText
|
|
534
501
|
}, rest, {
|
|
@@ -544,6 +511,7 @@ const ExpandableTile = /*#__PURE__*/React.forwardRef(({
|
|
|
544
511
|
className: `${prefix}--tile__chevron`
|
|
545
512
|
}, /*#__PURE__*/React.createElement("span", null, isExpanded ? tileExpandedLabel : tileCollapsedLabel), _ChevronDown2 || (_ChevronDown2 = /*#__PURE__*/React.createElement(ChevronDown, null))), /*#__PURE__*/React.createElement("div", {
|
|
546
513
|
ref: belowTheFold,
|
|
514
|
+
id: belowTheFoldId,
|
|
547
515
|
className: `${prefix}--tile-content`
|
|
548
516
|
}, childrenAsArray[1])));
|
|
549
517
|
});
|
|
@@ -98,10 +98,10 @@ const TimePicker = frFn((props, ref) => {
|
|
|
98
98
|
[`${prefix}--visually-hidden`]: hideLabel,
|
|
99
99
|
[`${prefix}--label--disabled`]: disabled
|
|
100
100
|
});
|
|
101
|
-
const label = labelText
|
|
101
|
+
const label = typeof labelText !== 'undefined' && labelText !== null && /*#__PURE__*/React.createElement("label", {
|
|
102
102
|
htmlFor: id,
|
|
103
103
|
className: labelClasses
|
|
104
|
-
}, labelText)
|
|
104
|
+
}, labelText);
|
|
105
105
|
function getInternalPickerSelects() {
|
|
106
106
|
const readOnlyEventHandlers = {
|
|
107
107
|
onMouseDown: evt => {
|
|
@@ -48,8 +48,9 @@ const DefinitionTooltip = ({
|
|
|
48
48
|
setOpen(false);
|
|
49
49
|
},
|
|
50
50
|
onMouseEnter: () => {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
if (openOnHover) {
|
|
52
|
+
setOpen(true);
|
|
53
|
+
}
|
|
53
54
|
},
|
|
54
55
|
onFocus: () => {
|
|
55
56
|
setOpen(true);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React, { forwardRef, useRef, isValidElement, createContext } from 'react';
|
|
9
|
+
import React, { forwardRef, useRef, isValidElement, useEffect, createContext } from 'react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
12
|
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
@@ -157,6 +157,16 @@ const SideNav = frFn((props, ref) => {
|
|
|
157
157
|
});
|
|
158
158
|
const lgMediaQuery = `(min-width: ${breakpoints.lg.width})`;
|
|
159
159
|
const isLg = useMatchMedia(lgMediaQuery);
|
|
160
|
+
const inertEnabled = !isRail ? !(expanded || isLg) : false;
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
const node = sideNavRef.current;
|
|
163
|
+
if (!node) return;
|
|
164
|
+
if (inertEnabled) {
|
|
165
|
+
node.setAttribute('inert', '');
|
|
166
|
+
} else {
|
|
167
|
+
node.removeAttribute('inert');
|
|
168
|
+
}
|
|
169
|
+
}, [inertEnabled]);
|
|
160
170
|
return /*#__PURE__*/React.createElement(SideNavContext.Provider, {
|
|
161
171
|
value: {
|
|
162
172
|
isRail
|
|
@@ -170,8 +180,7 @@ const SideNav = frFn((props, ref) => {
|
|
|
170
180
|
}), /*#__PURE__*/React.createElement("nav", _extends({
|
|
171
181
|
tabIndex: -1,
|
|
172
182
|
ref: navRef,
|
|
173
|
-
className: `${prefix}--side-nav__navigation ${className}
|
|
174
|
-
inert: !isRail ? !(expanded || isLg) : undefined
|
|
183
|
+
className: `${prefix}--side-nav__navigation ${className}`
|
|
175
184
|
}, accessibilityLabel, eventHandlers, other), childrenToRender));
|
|
176
185
|
});
|
|
177
186
|
SideNav.displayName = 'SideNav';
|