@carbon/react 1.102.0-rc.0 → 1.102.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 +953 -953
- package/es/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
- package/es/components/CheckboxGroup/CheckboxGroup.js +2 -2
- package/es/components/ComboBox/ComboBox.js +1 -2
- package/es/components/ContentSwitcher/ContentSwitcher.js +3 -2
- package/es/components/DataTable/TableExpandRow.js +2 -2
- package/es/components/DataTable/tools/normalize.js +2 -1
- package/es/components/DatePicker/DatePicker.js +3 -2
- package/es/components/Dropdown/Dropdown.js +1 -3
- package/es/components/ProgressIndicator/ProgressIndicator.js +3 -3
- package/es/components/Slider/Slider.d.ts +1 -1
- package/es/components/Slider/Slider.js +2 -8
- package/es/components/TileGroup/TileGroup.d.ts +1 -1
- package/es/components/TileGroup/TileGroup.js +2 -1
- package/es/components/UIShell/HeaderPanel.js +3 -2
- package/es/components/UIShell/Switcher.js +5 -4
- package/es/internal/useOverflowItems.d.ts +1 -5
- package/es/internal/useOverflowItems.js +6 -27
- package/lib/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
- package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/lib/components/ComboBox/ComboBox.js +1 -2
- package/lib/components/ContentSwitcher/ContentSwitcher.js +2 -1
- package/lib/components/DataTable/TableExpandRow.js +1 -1
- package/lib/components/DataTable/tools/normalize.js +2 -1
- package/lib/components/DatePicker/DatePicker.js +3 -2
- package/lib/components/Dropdown/Dropdown.js +1 -3
- package/lib/components/ProgressIndicator/ProgressIndicator.js +3 -3
- package/lib/components/Slider/Slider.d.ts +1 -1
- package/lib/components/Slider/Slider.js +2 -8
- package/lib/components/TileGroup/TileGroup.d.ts +1 -1
- package/lib/components/TileGroup/TileGroup.js +2 -1
- package/lib/components/UIShell/HeaderPanel.js +2 -1
- package/lib/components/UIShell/Switcher.js +4 -3
- package/lib/internal/useOverflowItems.d.ts +1 -5
- package/lib/internal/useOverflowItems.js +6 -27
- package/package.json +6 -6
|
@@ -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, { Children,
|
|
10
|
+
import React, { Children, cloneElement } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { deprecate } from '../../prop-types/deprecate.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
@@ -61,7 +61,7 @@ const CheckboxGroup = ({
|
|
|
61
61
|
kind: 'default'
|
|
62
62
|
}) : candidate;
|
|
63
63
|
const clonedChildren = Children.map(children, child => {
|
|
64
|
-
if (
|
|
64
|
+
if (isComponentElement(child, Checkbox)) {
|
|
65
65
|
const childProps = {
|
|
66
66
|
...(typeof invalid !== 'undefined' && typeof child.props.invalid === 'undefined' ? {
|
|
67
67
|
invalid
|
|
@@ -500,8 +500,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
500
500
|
onHighlightedIndexChange: ({
|
|
501
501
|
highlightedIndex
|
|
502
502
|
}) => {
|
|
503
|
-
|
|
504
|
-
if (highlightedIndex > -1 && typeof window !== undefined) {
|
|
503
|
+
if (highlightedIndex > -1) {
|
|
505
504
|
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
506
505
|
const highlightedItem = itemArray[highlightedIndex];
|
|
507
506
|
if (highlightedItem) {
|
|
@@ -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, { useContext, useState, useRef, Children, useEffect,
|
|
10
|
+
import React, { useContext, useState, useRef, Children, useEffect, cloneElement, isValidElement } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { deprecate } from '../../prop-types/deprecate.js';
|
|
13
13
|
import { LayoutConstraint } from '../Layout/index.js';
|
|
@@ -16,6 +16,7 @@ import { ArrowRight, ArrowLeft, Enter, Space } from '../../internal/keyboard/key
|
|
|
16
16
|
import { matches } from '../../internal/keyboard/match.js';
|
|
17
17
|
import { getNextIndex } from '../../internal/keyboard/navigation.js';
|
|
18
18
|
import { PrefixContext } from '../../internal/usePrefix.js';
|
|
19
|
+
import { isComponentElement } from '../../internal/utils.js';
|
|
19
20
|
import '../Switch/Switch.js';
|
|
20
21
|
import IconSwitch from '../Switch/IconSwitch.js';
|
|
21
22
|
|
|
@@ -81,7 +82,7 @@ const ContentSwitcher = ({
|
|
|
81
82
|
}
|
|
82
83
|
};
|
|
83
84
|
const isIconOnly = Children.map(children, child => {
|
|
84
|
-
return
|
|
85
|
+
return isComponentElement(child, IconSwitch);
|
|
85
86
|
})?.every(val => val === true);
|
|
86
87
|
const classes = cx(`${prefix}--content-switcher`, className, {
|
|
87
88
|
[`${prefix}--content-switcher--light`]: light,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
|
-
import React, { forwardRef, Children
|
|
11
|
+
import React, { forwardRef, Children } from 'react';
|
|
12
12
|
import { ChevronRight } from '@carbon/icons-react';
|
|
13
13
|
import TableCell from './TableCell.js';
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
@@ -50,7 +50,7 @@ const TableExpandRow = /*#__PURE__*/forwardRef(({
|
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
const normalizedChildren = Children.toArray(children).map(child => {
|
|
53
|
-
if (
|
|
53
|
+
if (!isComponentElement(child, TableSlugRow) && !isComponentElement(child, TableDecoratorRow)) {
|
|
54
54
|
return child;
|
|
55
55
|
}
|
|
56
56
|
});
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { AILabel } from '../../AILabel/index.js';
|
|
9
|
+
import { isComponentElement } from '../../../internal/utils.js';
|
|
9
10
|
import { getCellId } from './cells.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -60,7 +61,7 @@ const normalize = (rows, headers, prevState = {}) => {
|
|
|
60
61
|
isEditing: false,
|
|
61
62
|
isValid: true,
|
|
62
63
|
errors: null,
|
|
63
|
-
hasAILabelHeader: !!(slug || decorator
|
|
64
|
+
hasAILabelHeader: !!(slug || isComponentElement(decorator, AILabel)),
|
|
64
65
|
info: {
|
|
65
66
|
header: key
|
|
66
67
|
}
|
|
@@ -18,6 +18,7 @@ import { rangePlugin } from './plugins/rangePlugin.js';
|
|
|
18
18
|
import { deprecate } from '../../prop-types/deprecate.js';
|
|
19
19
|
import { Escape, Tab, Enter } from '../../internal/keyboard/keys.js';
|
|
20
20
|
import { match } from '../../internal/keyboard/match.js';
|
|
21
|
+
import { isComponentElement } from '../../internal/utils.js';
|
|
21
22
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
22
23
|
import { useSavedCallback } from '../../internal/useSavedCallback.js';
|
|
23
24
|
import '../FluidForm/FluidForm.js';
|
|
@@ -242,7 +243,7 @@ const DatePicker = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
242
243
|
const childrenWithProps = React.Children.toArray(children).map(
|
|
243
244
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
244
245
|
(child, index) => {
|
|
245
|
-
if (index === 0 && child
|
|
246
|
+
if (index === 0 && isComponentElement(child, DatePickerInput)) {
|
|
246
247
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
247
248
|
datePickerType,
|
|
248
249
|
ref: startInputField,
|
|
@@ -251,7 +252,7 @@ const DatePicker = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
251
252
|
warn: effectiveWarn
|
|
252
253
|
});
|
|
253
254
|
}
|
|
254
|
-
if (index === 1 && child
|
|
255
|
+
if (index === 1 && isComponentElement(child, DatePickerInput)) {
|
|
255
256
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
256
257
|
datePickerType,
|
|
257
258
|
ref: endInputField,
|
|
@@ -172,9 +172,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
172
172
|
const {
|
|
173
173
|
highlightedIndex
|
|
174
174
|
} = changes;
|
|
175
|
-
if (highlightedIndex !== undefined && highlightedIndex > -1
|
|
176
|
-
// eslint-disable-next-line valid-typeof , no-constant-binary-expression -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
177
|
-
typeof window !== undefined) {
|
|
175
|
+
if (highlightedIndex !== undefined && highlightedIndex > -1) {
|
|
178
176
|
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
179
177
|
const highlightedItem = itemArray[highlightedIndex];
|
|
180
178
|
if (highlightedItem) {
|
|
@@ -180,7 +180,7 @@ function ProgressStep({
|
|
|
180
180
|
}),
|
|
181
181
|
disabled: disabled,
|
|
182
182
|
"aria-disabled": disabled,
|
|
183
|
-
tabIndex:
|
|
183
|
+
tabIndex: disabled ? -1 : 0,
|
|
184
184
|
onClick: !current ? onClick : undefined,
|
|
185
185
|
onKeyDown: handleKeyDown,
|
|
186
186
|
title: label
|
|
@@ -193,10 +193,10 @@ function ProgressStep({
|
|
|
193
193
|
}), /*#__PURE__*/React.createElement("div", {
|
|
194
194
|
className: `${prefix}--progress-text`
|
|
195
195
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
196
|
-
as: "
|
|
196
|
+
as: "span",
|
|
197
197
|
className: `${prefix}--progress-label`
|
|
198
198
|
}, label), secondaryLabel !== null && secondaryLabel !== undefined ? /*#__PURE__*/React.createElement(Text, {
|
|
199
|
-
as: "
|
|
199
|
+
as: "span",
|
|
200
200
|
className: `${prefix}--progress-optional`
|
|
201
201
|
}, secondaryLabel) : null), /*#__PURE__*/React.createElement("span", {
|
|
202
202
|
className: `${prefix}--assistive-text`
|
|
@@ -994,14 +994,8 @@ const Slider = props => {
|
|
|
994
994
|
delete other.onRelease;
|
|
995
995
|
delete other.invalid;
|
|
996
996
|
delete other.unstable_valueUpper;
|
|
997
|
-
const showWarning = normalizedProps.warn ||
|
|
998
|
-
|
|
999
|
-
// eslint-disable-next-line valid-typeof , no-constant-binary-expression -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
1000
|
-
typeof correctedValue !== null && correctedPosition === HandlePosition.LOWER && isValid;
|
|
1001
|
-
const showWarningUpper = normalizedUpperProps.warn ||
|
|
1002
|
-
// TODO: https://github.com/carbon-design-system/carbon/issues/18991#issuecomment-2795709637
|
|
1003
|
-
// eslint-disable-next-line valid-typeof, no-constant-binary-expression -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
1004
|
-
typeof correctedValue !== null && correctedPosition === (twoHandles ? HandlePosition.UPPER : HandlePosition.LOWER) && (twoHandles ? isValidUpper : isValid);
|
|
997
|
+
const showWarning = normalizedProps.warn || correctedPosition === HandlePosition.LOWER && isValid;
|
|
998
|
+
const showWarningUpper = normalizedUpperProps.warn || correctedPosition === (twoHandles ? HandlePosition.UPPER : HandlePosition.LOWER) && (twoHandles ? isValidUpper : isValid);
|
|
1005
999
|
return /*#__PURE__*/React.createElement(PrefixContext.Consumer, null, prefix => {
|
|
1006
1000
|
const labelId = `${id}-label`;
|
|
1007
1001
|
const labelClasses = cx(`${prefix}--label`, {
|
|
@@ -9,6 +9,7 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
|
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
10
|
import React, { useState, useEffect, Children, isValidElement, cloneElement } from 'react';
|
|
11
11
|
import RadioTile from '../RadioTile/RadioTile.js';
|
|
12
|
+
import { isComponentElement } from '../../internal/utils.js';
|
|
12
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
14
|
import { noopFn } from '../../internal/noopFn.js';
|
|
14
15
|
|
|
@@ -42,7 +43,7 @@ const TileGroup = ({
|
|
|
42
43
|
if (! /*#__PURE__*/isValidElement(child)) return child;
|
|
43
44
|
|
|
44
45
|
// If a `RadioTile` is found, return it with necessary props,
|
|
45
|
-
if (
|
|
46
|
+
if (isComponentElement(child, RadioTile)) {
|
|
46
47
|
const {
|
|
47
48
|
value,
|
|
48
49
|
...otherProps
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
|
-
import React, { useRef, useState
|
|
11
|
+
import React, { useRef, useState } from 'react';
|
|
12
|
+
import { isComponentElement } from '../../internal/utils.js';
|
|
12
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
14
|
import { Escape } from '../../internal/keyboard/keys.js';
|
|
14
15
|
import { match } from '../../internal/keyboard/match.js';
|
|
@@ -64,7 +65,7 @@ const HeaderPanel = /*#__PURE__*/React.forwardRef(({
|
|
|
64
65
|
} = event;
|
|
65
66
|
if (!(target instanceof Element)) return;
|
|
66
67
|
setLastClickedElement(target);
|
|
67
|
-
const isChildASwitcher =
|
|
68
|
+
const isChildASwitcher = isComponentElement(children, Switcher);
|
|
68
69
|
if (isChildASwitcher && !target.closest(`.${prefix}--header-panel--expanded`) && !target.closest(`.${prefix}--header__action`) && !headerPanelReference?.current?.classList.contains(`${prefix}--switcher`) && expanded) {
|
|
69
70
|
setExpandedState(false);
|
|
70
71
|
onHeaderPanelFocus();
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React, { forwardRef, useRef, Children,
|
|
9
|
+
import React, { forwardRef, useRef, Children, cloneElement } from 'react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
12
12
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
13
|
+
import { isComponentElement } from '../../internal/utils.js';
|
|
13
14
|
import PropTypes from 'prop-types';
|
|
14
15
|
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
15
16
|
import SwitcherItem from './SwitcherItem.js';
|
|
@@ -38,7 +39,7 @@ const Switcher = /*#__PURE__*/forwardRef((props, forwardRef) => {
|
|
|
38
39
|
direction
|
|
39
40
|
}) => {
|
|
40
41
|
const enabledIndices = Children.toArray(children).reduce((acc, child, i) => {
|
|
41
|
-
if (
|
|
42
|
+
if (isComponentElement(child, SwitcherItem) && Object.keys(child.props).length) {
|
|
42
43
|
acc.push(i);
|
|
43
44
|
}
|
|
44
45
|
return acc;
|
|
@@ -66,7 +67,7 @@ const Switcher = /*#__PURE__*/forwardRef((props, forwardRef) => {
|
|
|
66
67
|
}
|
|
67
68
|
};
|
|
68
69
|
const childrenWithProps = Children.toArray(children).map((child, index) => {
|
|
69
|
-
if (
|
|
70
|
+
if (isComponentElement(child, SwitcherItem)) {
|
|
70
71
|
return /*#__PURE__*/cloneElement(child, {
|
|
71
72
|
handleSwitcherItemFocus,
|
|
72
73
|
index,
|
|
@@ -74,7 +75,7 @@ const Switcher = /*#__PURE__*/forwardRef((props, forwardRef) => {
|
|
|
74
75
|
expanded
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
|
-
if (
|
|
78
|
+
if (isComponentElement(child, SwitcherDivider)) {
|
|
78
79
|
return /*#__PURE__*/cloneElement(child, {
|
|
79
80
|
key: index
|
|
80
81
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2025,
|
|
2
|
+
* Copyright IBM Corp. 2025, 2026
|
|
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.
|
|
@@ -18,10 +18,6 @@ type Item = {
|
|
|
18
18
|
* @returns Object with `visibleItems` (items to display), `hiddenItems` (items that don't fit), and `itemRefHandler` (function to attach refs to items for width measurement).
|
|
19
19
|
*/
|
|
20
20
|
declare const useOverflowItems: <T extends Item>(items: T[] | ReactNode, containerRef: RefObject<HTMLDivElement>, offsetRef?: RefObject<HTMLDivElement>, maxItems?: number, onChange?: (hiddenItems: T[]) => void) => {
|
|
21
|
-
visibleItems: T[];
|
|
22
|
-
hiddenItems: T[];
|
|
23
|
-
itemRefHandler: () => void;
|
|
24
|
-
} | {
|
|
25
21
|
visibleItems: T[];
|
|
26
22
|
itemRefHandler: (id: string, node: HTMLDivElement | null) => () => void;
|
|
27
23
|
hiddenItems: T[];
|
|
@@ -18,17 +18,10 @@ import { usePreviousValue } from './usePreviousValue.js';
|
|
|
18
18
|
* @param onChange - Optional callback called when hidden items change. Receives array of currently hidden items.
|
|
19
19
|
* @returns Object with `visibleItems` (items to display), `hiddenItems` (items that don't fit), and `itemRefHandler` (function to attach refs to items for width measurement).
|
|
20
20
|
*/
|
|
21
|
-
|
|
22
21
|
const useOverflowItems = (items, containerRef, offsetRef, maxItems, onChange) => {
|
|
23
22
|
const itemsRef = useRef(null);
|
|
24
23
|
const [maxWidth, setMaxWidth] = useState(0);
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
visibleItems: [],
|
|
28
|
-
hiddenItems: [],
|
|
29
|
-
itemRefHandler: () => {}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
24
|
+
const overflowItems = useMemo(() => Array.isArray(items) ? items : [], [items]);
|
|
32
25
|
const handleResize = () => {
|
|
33
26
|
if (containerRef.current) {
|
|
34
27
|
const offset = offsetRef?.current?.offsetWidth || 0;
|
|
@@ -36,7 +29,6 @@ const useOverflowItems = (items, containerRef, offsetRef, maxItems, onChange) =>
|
|
|
36
29
|
setMaxWidth(newMax);
|
|
37
30
|
}
|
|
38
31
|
};
|
|
39
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
40
32
|
useResizeObserver({
|
|
41
33
|
ref: containerRef,
|
|
42
34
|
onResize: handleResize
|
|
@@ -59,16 +51,13 @@ const useOverflowItems = (items, containerRef, offsetRef, maxItems, onChange) =>
|
|
|
59
51
|
};
|
|
60
52
|
};
|
|
61
53
|
const getVisibleItems = () => {
|
|
62
|
-
if (!items || Array.isArray(items) === false) {
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
54
|
if (!containerRef) {
|
|
66
|
-
return
|
|
55
|
+
return overflowItems;
|
|
67
56
|
}
|
|
68
57
|
const map = getMap();
|
|
69
58
|
let maxReached = false;
|
|
70
59
|
let accumulatedWidth = 0;
|
|
71
|
-
const visibleItems =
|
|
60
|
+
const visibleItems = overflowItems.slice(0, maxItems).reduce((prev, cur) => {
|
|
72
61
|
if (maxReached) {
|
|
73
62
|
return prev;
|
|
74
63
|
}
|
|
@@ -86,30 +75,20 @@ const useOverflowItems = (items, containerRef, offsetRef, maxItems, onChange) =>
|
|
|
86
75
|
};
|
|
87
76
|
|
|
88
77
|
// Memoize visible items calculation to avoid recalculating on every render
|
|
89
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
90
78
|
const visibleItems = useMemo(() => {
|
|
91
|
-
if (!Array.isArray(items)) {
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
79
|
return getVisibleItems();
|
|
95
80
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
96
|
-
}, [
|
|
81
|
+
}, [overflowItems, maxWidth, maxItems]);
|
|
97
82
|
|
|
98
83
|
// Memoize hidden items calculation
|
|
99
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
100
84
|
const hiddenItems = useMemo(() => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
return items.slice(visibleItems.length);
|
|
105
|
-
}, [items, visibleItems]);
|
|
85
|
+
return overflowItems.slice(visibleItems.length);
|
|
86
|
+
}, [overflowItems, visibleItems]);
|
|
106
87
|
|
|
107
88
|
// Use previous value to compare and only call onChange when needed
|
|
108
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
109
89
|
const previousHiddenItems = usePreviousValue(hiddenItems);
|
|
110
90
|
|
|
111
91
|
// Only call onChange if hidden items actually changed
|
|
112
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
113
92
|
useEffect(() => {
|
|
114
93
|
}, [hiddenItems, previousHiddenItems, onChange]);
|
|
115
94
|
return {
|
|
@@ -65,7 +65,7 @@ const CheckboxGroup = ({
|
|
|
65
65
|
kind: 'default'
|
|
66
66
|
}) : candidate;
|
|
67
67
|
const clonedChildren = React.Children.map(children, child => {
|
|
68
|
-
if (
|
|
68
|
+
if (utils.isComponentElement(child, Checkbox.default)) {
|
|
69
69
|
const childProps = {
|
|
70
70
|
...(typeof invalid !== 'undefined' && typeof child.props.invalid === 'undefined' ? {
|
|
71
71
|
invalid
|
|
@@ -504,8 +504,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
504
504
|
onHighlightedIndexChange: ({
|
|
505
505
|
highlightedIndex
|
|
506
506
|
}) => {
|
|
507
|
-
|
|
508
|
-
if (highlightedIndex > -1 && typeof window !== undefined) {
|
|
507
|
+
if (highlightedIndex > -1) {
|
|
509
508
|
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
510
509
|
const highlightedItem = itemArray[highlightedIndex];
|
|
511
510
|
if (highlightedItem) {
|
|
@@ -18,6 +18,7 @@ var keys = require('../../internal/keyboard/keys.js');
|
|
|
18
18
|
var match = require('../../internal/keyboard/match.js');
|
|
19
19
|
var navigation = require('../../internal/keyboard/navigation.js');
|
|
20
20
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
21
|
+
var utils = require('../../internal/utils.js');
|
|
21
22
|
require('../Switch/Switch.js');
|
|
22
23
|
var IconSwitch = require('../Switch/IconSwitch.js');
|
|
23
24
|
|
|
@@ -83,7 +84,7 @@ const ContentSwitcher = ({
|
|
|
83
84
|
}
|
|
84
85
|
};
|
|
85
86
|
const isIconOnly = React.Children.map(children, child => {
|
|
86
|
-
return
|
|
87
|
+
return utils.isComponentElement(child, IconSwitch.default);
|
|
87
88
|
})?.every(val => val === true);
|
|
88
89
|
const classes = cx(`${prefix}--content-switcher`, className, {
|
|
89
90
|
[`${prefix}--content-switcher--light`]: light,
|
|
@@ -54,7 +54,7 @@ const TableExpandRow = /*#__PURE__*/React.forwardRef(({
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
const normalizedChildren = React.Children.toArray(children).map(child => {
|
|
57
|
-
if (
|
|
57
|
+
if (!utils.isComponentElement(child, TableSlugRow.default) && !utils.isComponentElement(child, TableDecoratorRow.default)) {
|
|
58
58
|
return child;
|
|
59
59
|
}
|
|
60
60
|
});
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
12
|
var index = require('../../AILabel/index.js');
|
|
13
|
+
var utils = require('../../../internal/utils.js');
|
|
13
14
|
var cells = require('./cells.js');
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -64,7 +65,7 @@ const normalize = (rows, headers, prevState = {}) => {
|
|
|
64
65
|
isEditing: false,
|
|
65
66
|
isValid: true,
|
|
66
67
|
errors: null,
|
|
67
|
-
hasAILabelHeader: !!(slug || decorator
|
|
68
|
+
hasAILabelHeader: !!(slug || utils.isComponentElement(decorator, index.AILabel)),
|
|
68
69
|
info: {
|
|
69
70
|
header: key
|
|
70
71
|
}
|
|
@@ -22,6 +22,7 @@ var rangePlugin = require('./plugins/rangePlugin.js');
|
|
|
22
22
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
23
23
|
var keys = require('../../internal/keyboard/keys.js');
|
|
24
24
|
var match = require('../../internal/keyboard/match.js');
|
|
25
|
+
var utils = require('../../internal/utils.js');
|
|
25
26
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
26
27
|
var useSavedCallback = require('../../internal/useSavedCallback.js');
|
|
27
28
|
require('../FluidForm/FluidForm.js');
|
|
@@ -246,7 +247,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
246
247
|
const childrenWithProps = React.Children.toArray(children).map(
|
|
247
248
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
248
249
|
(child, index) => {
|
|
249
|
-
if (index === 0 && child
|
|
250
|
+
if (index === 0 && utils.isComponentElement(child, DatePickerInput.default)) {
|
|
250
251
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
251
252
|
datePickerType,
|
|
252
253
|
ref: startInputField,
|
|
@@ -255,7 +256,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
255
256
|
warn: effectiveWarn
|
|
256
257
|
});
|
|
257
258
|
}
|
|
258
|
-
if (index === 1 && child
|
|
259
|
+
if (index === 1 && utils.isComponentElement(child, DatePickerInput.default)) {
|
|
259
260
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
260
261
|
datePickerType,
|
|
261
262
|
ref: endInputField,
|
|
@@ -176,9 +176,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
176
176
|
const {
|
|
177
177
|
highlightedIndex
|
|
178
178
|
} = changes;
|
|
179
|
-
if (highlightedIndex !== undefined && highlightedIndex > -1
|
|
180
|
-
// eslint-disable-next-line valid-typeof , no-constant-binary-expression -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
181
|
-
typeof window !== undefined) {
|
|
179
|
+
if (highlightedIndex !== undefined && highlightedIndex > -1) {
|
|
182
180
|
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
183
181
|
const highlightedItem = itemArray[highlightedIndex];
|
|
184
182
|
if (highlightedItem) {
|
|
@@ -182,7 +182,7 @@ function ProgressStep({
|
|
|
182
182
|
}),
|
|
183
183
|
disabled: disabled,
|
|
184
184
|
"aria-disabled": disabled,
|
|
185
|
-
tabIndex:
|
|
185
|
+
tabIndex: disabled ? -1 : 0,
|
|
186
186
|
onClick: !current ? onClick : undefined,
|
|
187
187
|
onKeyDown: handleKeyDown,
|
|
188
188
|
title: label
|
|
@@ -195,10 +195,10 @@ function ProgressStep({
|
|
|
195
195
|
}), /*#__PURE__*/React.createElement("div", {
|
|
196
196
|
className: `${prefix}--progress-text`
|
|
197
197
|
}, /*#__PURE__*/React.createElement(Text.Text, {
|
|
198
|
-
as: "
|
|
198
|
+
as: "span",
|
|
199
199
|
className: `${prefix}--progress-label`
|
|
200
200
|
}, label), secondaryLabel !== null && secondaryLabel !== undefined ? /*#__PURE__*/React.createElement(Text.Text, {
|
|
201
|
-
as: "
|
|
201
|
+
as: "span",
|
|
202
202
|
className: `${prefix}--progress-optional`
|
|
203
203
|
}, secondaryLabel) : null), /*#__PURE__*/React.createElement("span", {
|
|
204
204
|
className: `${prefix}--assistive-text`
|
|
@@ -998,14 +998,8 @@ const Slider = props => {
|
|
|
998
998
|
delete other.onRelease;
|
|
999
999
|
delete other.invalid;
|
|
1000
1000
|
delete other.unstable_valueUpper;
|
|
1001
|
-
const showWarning = normalizedProps.warn ||
|
|
1002
|
-
|
|
1003
|
-
// eslint-disable-next-line valid-typeof , no-constant-binary-expression -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
1004
|
-
typeof correctedValue !== null && correctedPosition === HandlePosition.LOWER && isValid;
|
|
1005
|
-
const showWarningUpper = normalizedUpperProps.warn ||
|
|
1006
|
-
// TODO: https://github.com/carbon-design-system/carbon/issues/18991#issuecomment-2795709637
|
|
1007
|
-
// eslint-disable-next-line valid-typeof, no-constant-binary-expression -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
1008
|
-
typeof correctedValue !== null && correctedPosition === (twoHandles ? HandlePosition.UPPER : HandlePosition.LOWER) && (twoHandles ? isValidUpper : isValid);
|
|
1001
|
+
const showWarning = normalizedProps.warn || correctedPosition === HandlePosition.LOWER && isValid;
|
|
1002
|
+
const showWarningUpper = normalizedUpperProps.warn || correctedPosition === (twoHandles ? HandlePosition.UPPER : HandlePosition.LOWER) && (twoHandles ? isValidUpper : isValid);
|
|
1009
1003
|
return /*#__PURE__*/React.createElement(usePrefix.PrefixContext.Consumer, null, prefix => {
|
|
1010
1004
|
const labelId = `${id}-label`;
|
|
1011
1005
|
const labelClasses = cx(`${prefix}--label`, {
|
|
@@ -11,6 +11,7 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
|
|
|
11
11
|
var PropTypes = require('prop-types');
|
|
12
12
|
var React = require('react');
|
|
13
13
|
var RadioTile = require('../RadioTile/RadioTile.js');
|
|
14
|
+
var utils = require('../../internal/utils.js');
|
|
14
15
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
15
16
|
var noopFn = require('../../internal/noopFn.js');
|
|
16
17
|
|
|
@@ -44,7 +45,7 @@ const TileGroup = ({
|
|
|
44
45
|
if (! /*#__PURE__*/React.isValidElement(child)) return child;
|
|
45
46
|
|
|
46
47
|
// If a `RadioTile` is found, return it with necessary props,
|
|
47
|
-
if (
|
|
48
|
+
if (utils.isComponentElement(child, RadioTile.default)) {
|
|
48
49
|
const {
|
|
49
50
|
value,
|
|
50
51
|
...otherProps
|
|
@@ -13,6 +13,7 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
|
|
|
13
13
|
var cx = require('classnames');
|
|
14
14
|
var PropTypes = require('prop-types');
|
|
15
15
|
var React = require('react');
|
|
16
|
+
var utils = require('../../internal/utils.js');
|
|
16
17
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
17
18
|
var keys = require('../../internal/keyboard/keys.js');
|
|
18
19
|
var match = require('../../internal/keyboard/match.js');
|
|
@@ -68,7 +69,7 @@ const HeaderPanel = /*#__PURE__*/React.forwardRef(({
|
|
|
68
69
|
} = event;
|
|
69
70
|
if (!(target instanceof Element)) return;
|
|
70
71
|
setLastClickedElement(target);
|
|
71
|
-
const isChildASwitcher =
|
|
72
|
+
const isChildASwitcher = utils.isComponentElement(children, Switcher.default);
|
|
72
73
|
if (isChildASwitcher && !target.closest(`.${prefix}--header-panel--expanded`) && !target.closest(`.${prefix}--header__action`) && !headerPanelReference?.current?.classList.contains(`${prefix}--switcher`) && expanded) {
|
|
73
74
|
setExpandedState(false);
|
|
74
75
|
onHeaderPanelFocus();
|
|
@@ -14,6 +14,7 @@ var React = require('react');
|
|
|
14
14
|
var cx = require('classnames');
|
|
15
15
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
16
16
|
var useMergedRefs = require('../../internal/useMergedRefs.js');
|
|
17
|
+
var utils = require('../../internal/utils.js');
|
|
17
18
|
var PropTypes = require('prop-types');
|
|
18
19
|
var AriaPropTypes = require('../../prop-types/AriaPropTypes.js');
|
|
19
20
|
var SwitcherItem = require('./SwitcherItem.js');
|
|
@@ -42,7 +43,7 @@ const Switcher = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
|
42
43
|
direction
|
|
43
44
|
}) => {
|
|
44
45
|
const enabledIndices = React.Children.toArray(children).reduce((acc, child, i) => {
|
|
45
|
-
if (
|
|
46
|
+
if (utils.isComponentElement(child, SwitcherItem.default) && Object.keys(child.props).length) {
|
|
46
47
|
acc.push(i);
|
|
47
48
|
}
|
|
48
49
|
return acc;
|
|
@@ -70,7 +71,7 @@ const Switcher = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
|
70
71
|
}
|
|
71
72
|
};
|
|
72
73
|
const childrenWithProps = React.Children.toArray(children).map((child, index) => {
|
|
73
|
-
if (
|
|
74
|
+
if (utils.isComponentElement(child, SwitcherItem.default)) {
|
|
74
75
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
75
76
|
handleSwitcherItemFocus,
|
|
76
77
|
index,
|
|
@@ -78,7 +79,7 @@ const Switcher = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
|
78
79
|
expanded
|
|
79
80
|
});
|
|
80
81
|
}
|
|
81
|
-
if (
|
|
82
|
+
if (utils.isComponentElement(child, SwitcherDivider.default)) {
|
|
82
83
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
83
84
|
key: index
|
|
84
85
|
});
|