@carbon/react 1.77.0-rc.0 → 1.78.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 +945 -858
- package/es/components/Accordion/AccordionItem.js +1 -1
- package/es/components/BadgeIndicator/index.d.ts +23 -0
- package/es/components/BadgeIndicator/index.js +45 -0
- package/es/components/Breadcrumb/Breadcrumb.d.ts +5 -0
- package/es/components/Breadcrumb/Breadcrumb.js +8 -2
- package/es/components/Button/Button.d.ts +9 -0
- package/es/components/Button/Button.js +13 -0
- package/es/components/ComboBox/ComboBox.js +13 -9
- package/es/components/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.js +3 -2
- package/es/components/FileUploader/FileUploader.js +1 -1
- package/es/components/FileUploader/FileUploaderItem.js +1 -1
- package/es/components/IconButton/index.d.ts +7 -1
- package/es/components/IconButton/index.js +18 -2
- package/es/components/IconIndicator/index.d.ts +1 -1
- package/es/components/InlineLoading/InlineLoading.js +2 -5
- package/es/components/Menu/MenuItem.js +1 -1
- package/es/components/Modal/Modal.d.ts +3 -3
- package/es/components/Modal/Modal.js +9 -3
- package/es/components/Modal/next/index.d.ts +1 -5
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +11 -3
- package/es/components/MultiSelect/MultiSelect.js +3 -2
- package/es/components/MultiSelect/MultiSelectPropTypes.d.ts +5 -2
- package/es/components/MultiSelect/tools/sorting.js +8 -7
- package/es/components/Notification/Notification.js +1 -1
- package/es/components/NumberInput/NumberInput.js +12 -12
- package/es/components/OverflowMenu/OverflowMenu.d.ts +8 -20
- package/es/components/OverflowMenu/OverflowMenu.js +7 -9
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +1 -1
- package/es/components/Pagination/Pagination.js +2 -2
- package/es/components/ProgressIndicator/ProgressIndicator.js +1 -1
- package/es/components/RadioTile/RadioTile.js +1 -1
- package/es/components/Select/Select.js +11 -2
- package/es/components/ShapeIndicator/index.d.ts +29 -0
- package/es/components/ShapeIndicator/index.js +92 -0
- package/es/components/Tabs/Tabs.d.ts +6 -4
- package/es/components/Tabs/Tabs.js +27 -8
- package/es/components/Tag/OperationalTag.d.ts +1 -36
- package/es/components/Tag/OperationalTag.js +7 -5
- package/es/components/Text/Text.d.ts +11 -9
- package/es/components/Text/Text.js +6 -6
- package/es/components/Text/TextDirection.d.ts +7 -9
- package/es/components/Text/TextDirection.js +5 -2
- package/es/components/Text/TextDirectionContext.d.ts +14 -0
- package/es/components/Text/TextDirectionContext.js +6 -2
- package/es/components/Text/createTextComponent.d.ts +5 -5
- package/es/components/Text/createTextComponent.js +5 -4
- package/es/components/Text/index.d.ts +6 -7
- package/es/components/Text/index.js +3 -2
- package/es/components/Tile/Tile.d.ts +6 -0
- package/es/components/Tile/Tile.js +5 -9
- package/es/components/Toggletip/index.d.ts +3 -2
- package/es/components/Tooltip/DefinitionTooltip.d.ts +4 -0
- package/es/components/Tooltip/DefinitionTooltip.js +7 -1
- package/es/components/Tooltip/Tooltip.d.ts +5 -66
- package/es/components/Tooltip/Tooltip.js +26 -26
- package/es/components/UIShell/HeaderGlobalAction.d.ts +9 -0
- package/es/components/UIShell/HeaderGlobalAction.js +16 -1
- package/es/index.d.ts +4 -1
- package/es/index.js +2 -1
- package/es/internal/FloatingMenu.d.ts +83 -0
- package/es/internal/FloatingMenu.js +216 -408
- package/es/internal/wrapFocus.js +1 -1
- package/lib/components/Accordion/AccordionItem.js +1 -1
- package/lib/components/BadgeIndicator/index.d.ts +23 -0
- package/lib/components/BadgeIndicator/index.js +56 -0
- package/lib/components/Breadcrumb/Breadcrumb.d.ts +5 -0
- package/lib/components/Breadcrumb/Breadcrumb.js +8 -2
- package/lib/components/Button/Button.d.ts +9 -0
- package/lib/components/Button/Button.js +13 -0
- package/lib/components/ComboBox/ComboBox.js +13 -9
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.js +2 -1
- package/lib/components/FileUploader/FileUploader.js +1 -1
- package/lib/components/FileUploader/FileUploaderItem.js +1 -1
- package/lib/components/IconButton/index.d.ts +7 -1
- package/lib/components/IconButton/index.js +18 -2
- package/lib/components/IconIndicator/index.d.ts +1 -1
- package/lib/components/InlineLoading/InlineLoading.js +2 -5
- package/lib/components/Menu/MenuItem.js +1 -1
- package/lib/components/Modal/Modal.d.ts +3 -3
- package/lib/components/Modal/Modal.js +9 -3
- package/lib/components/Modal/next/index.d.ts +1 -5
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +10 -2
- package/lib/components/MultiSelect/MultiSelect.js +2 -1
- package/lib/components/MultiSelect/MultiSelectPropTypes.d.ts +5 -2
- package/lib/components/MultiSelect/tools/sorting.js +8 -7
- package/lib/components/Notification/Notification.js +1 -1
- package/lib/components/NumberInput/NumberInput.js +12 -12
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +8 -20
- package/lib/components/OverflowMenu/OverflowMenu.js +7 -9
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +1 -1
- package/lib/components/Pagination/Pagination.js +3 -2
- package/lib/components/ProgressIndicator/ProgressIndicator.js +1 -1
- package/lib/components/RadioTile/RadioTile.js +1 -1
- package/lib/components/Select/Select.js +11 -2
- package/lib/components/ShapeIndicator/index.d.ts +29 -0
- package/lib/components/ShapeIndicator/index.js +104 -0
- package/lib/components/Tabs/Tabs.d.ts +6 -4
- package/lib/components/Tabs/Tabs.js +42 -23
- package/lib/components/Tag/OperationalTag.d.ts +1 -36
- package/lib/components/Tag/OperationalTag.js +6 -4
- package/lib/components/Text/Text.d.ts +11 -9
- package/lib/components/Text/Text.js +5 -5
- package/lib/components/Text/TextDirection.d.ts +7 -9
- package/lib/components/Text/TextDirection.js +5 -2
- package/lib/components/Text/TextDirectionContext.d.ts +14 -0
- package/lib/components/Text/TextDirectionContext.js +6 -2
- package/lib/components/Text/createTextComponent.d.ts +5 -5
- package/lib/components/Text/createTextComponent.js +5 -4
- package/lib/components/Text/index.d.ts +6 -7
- package/lib/components/Text/index.js +4 -3
- package/lib/components/Tile/Tile.d.ts +6 -0
- package/lib/components/Tile/Tile.js +5 -9
- package/lib/components/Toggletip/index.d.ts +3 -2
- package/lib/components/Tooltip/DefinitionTooltip.d.ts +4 -0
- package/lib/components/Tooltip/DefinitionTooltip.js +7 -1
- package/lib/components/Tooltip/Tooltip.d.ts +5 -66
- package/lib/components/Tooltip/Tooltip.js +26 -26
- package/lib/components/UIShell/HeaderGlobalAction.d.ts +9 -0
- package/lib/components/UIShell/HeaderGlobalAction.js +16 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.js +42 -40
- package/lib/internal/FloatingMenu.d.ts +83 -0
- package/lib/internal/FloatingMenu.js +216 -409
- package/lib/internal/wrapFocus.js +1 -1
- package/package.json +7 -7
- package/scss/components/badge-indicator/_badge-indicator.scss +9 -0
- package/scss/components/badge-indicator/_index.scss +9 -0
- package/es/tools/array.js +0 -29
- package/lib/tools/array.js +0 -33
|
@@ -1,25 +1,13 @@
|
|
|
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 { type MenuDirection, type MenuOffset } from '../../internal/FloatingMenu';
|
|
7
8
|
import React, { ComponentType } from 'react';
|
|
8
9
|
import PropTypes from 'prop-types';
|
|
9
|
-
|
|
10
|
-
* @param {Element} menuBody The menu body with the menu arrow.
|
|
11
|
-
* @param {string} direction The floating menu direction.
|
|
12
|
-
* @returns {FloatingMenu~offset} The adjustment of the floating menu position, upon the position of the menu arrow.
|
|
13
|
-
* @private
|
|
14
|
-
*/
|
|
15
|
-
export declare const getMenuOffset: (menuBody: any, direction: any, trigger: any, flip: any) => {
|
|
16
|
-
left: number;
|
|
17
|
-
top: number;
|
|
18
|
-
} | undefined;
|
|
19
|
-
interface Offset {
|
|
20
|
-
top?: number | null | undefined;
|
|
21
|
-
left?: number | null | undefined;
|
|
22
|
-
}
|
|
10
|
+
export declare const getMenuOffset: MenuOffset;
|
|
23
11
|
type IconProps = {
|
|
24
12
|
className?: string;
|
|
25
13
|
'aria-label'?: string;
|
|
@@ -46,7 +34,7 @@ export interface OverflowMenuProps {
|
|
|
46
34
|
/**
|
|
47
35
|
* The menu direction.
|
|
48
36
|
*/
|
|
49
|
-
direction?:
|
|
37
|
+
direction?: MenuDirection;
|
|
50
38
|
/**
|
|
51
39
|
* `true` if the menu alignment should be flipped.
|
|
52
40
|
*/
|
|
@@ -75,11 +63,11 @@ export interface OverflowMenuProps {
|
|
|
75
63
|
/**
|
|
76
64
|
* The adjustment in position applied to the floating menu.
|
|
77
65
|
*/
|
|
78
|
-
menuOffset?:
|
|
66
|
+
menuOffset?: MenuOffset;
|
|
79
67
|
/**
|
|
80
68
|
* The adjustment in position applied to the floating menu.
|
|
81
69
|
*/
|
|
82
|
-
menuOffsetFlip?:
|
|
70
|
+
menuOffsetFlip?: MenuOffset;
|
|
83
71
|
/**
|
|
84
72
|
* The class to apply to the menu options
|
|
85
73
|
*/
|
|
@@ -246,10 +234,10 @@ declare class OverflowMenu extends React.Component<OverflowMenuProps, OverflowMe
|
|
|
246
234
|
_hBlurTimeout: any;
|
|
247
235
|
/**
|
|
248
236
|
* The element ref of the tooltip's trigger button.
|
|
249
|
-
* @type {React.RefObject<
|
|
237
|
+
* @type {React.RefObject<HTMLElement>}
|
|
250
238
|
* @private
|
|
251
239
|
*/
|
|
252
|
-
_triggerRef: React.RefObject<
|
|
240
|
+
_triggerRef: React.RefObject<HTMLElement>;
|
|
253
241
|
componentDidUpdate(_: any, prevState: any): void;
|
|
254
242
|
componentDidMount(): void;
|
|
255
243
|
static getDerivedStateFromProps({ open }: {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import FloatingMenu,
|
|
9
|
+
import { FloatingMenu, DIRECTION_TOP, DIRECTION_BOTTOM } from '../../internal/FloatingMenu.js';
|
|
10
10
|
import React__default from 'react';
|
|
11
11
|
import ClickListener from '../../internal/ClickListener.js';
|
|
12
12
|
import { IconButton } from '../IconButton/index.js';
|
|
@@ -53,13 +53,6 @@ const triggerButtonPositionFactors = {
|
|
|
53
53
|
[DIRECTION_TOP]: -2,
|
|
54
54
|
[DIRECTION_BOTTOM]: -1
|
|
55
55
|
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @param {Element} menuBody The menu body with the menu arrow.
|
|
59
|
-
* @param {string} direction The floating menu direction.
|
|
60
|
-
* @returns {FloatingMenu~offset} The adjustment of the floating menu position, upon the position of the menu arrow.
|
|
61
|
-
* @private
|
|
62
|
-
*/
|
|
63
56
|
const getMenuOffset = (menuBody, direction, trigger, flip) => {
|
|
64
57
|
const triggerButtonPositionProp = triggerButtonPositionProps[direction];
|
|
65
58
|
const triggerButtonPositionFactor = triggerButtonPositionFactors[direction];
|
|
@@ -81,6 +74,11 @@ const getMenuOffset = (menuBody, direction, trigger, flip) => {
|
|
|
81
74
|
top: 0
|
|
82
75
|
};
|
|
83
76
|
}
|
|
77
|
+
default:
|
|
78
|
+
return {
|
|
79
|
+
left: 0,
|
|
80
|
+
top: 0
|
|
81
|
+
};
|
|
84
82
|
}
|
|
85
83
|
};
|
|
86
84
|
class OverflowMenu extends React__default.Component {
|
|
@@ -106,7 +104,7 @@ class OverflowMenu extends React__default.Component {
|
|
|
106
104
|
_defineProperty(this, "_hBlurTimeout", void 0);
|
|
107
105
|
/**
|
|
108
106
|
* The element ref of the tooltip's trigger button.
|
|
109
|
-
* @type {React.RefObject<
|
|
107
|
+
* @type {React.RefObject<HTMLElement>}
|
|
110
108
|
* @private
|
|
111
109
|
*/
|
|
112
110
|
_defineProperty(this, "_triggerRef", /*#__PURE__*/React__default.createRef());
|
|
@@ -12,8 +12,8 @@ import React__default from 'react';
|
|
|
12
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
13
|
import { warning } from '../../internal/warning.js';
|
|
14
14
|
import '../Text/index.js';
|
|
15
|
-
import { Text } from '../Text/Text.js';
|
|
16
15
|
import { match } from '../../internal/keyboard/match.js';
|
|
16
|
+
import { Text } from '../Text/Text.js';
|
|
17
17
|
import { ArrowDown, ArrowUp } from '../../internal/keyboard/keys.js';
|
|
18
18
|
|
|
19
19
|
const OverflowMenuItem = /*#__PURE__*/React__default.forwardRef(function OverflowMenuItem(_ref, ref) {
|
|
@@ -13,10 +13,10 @@ import React__default, { useRef, useState } from 'react';
|
|
|
13
13
|
import Select from '../Select/Select.js';
|
|
14
14
|
import '../Select/Select.Skeleton.js';
|
|
15
15
|
import SelectItem from '../SelectItem/SelectItem.js';
|
|
16
|
-
import { equals } from '../../tools/array.js';
|
|
17
16
|
import { useFallbackId } from '../../internal/useId.js';
|
|
18
17
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
19
18
|
import { IconButton } from '../IconButton/index.js';
|
|
19
|
+
import isEqual from 'react-fast-compare';
|
|
20
20
|
|
|
21
21
|
var _CaretLeft, _CaretRight;
|
|
22
22
|
function mapPageSizesToObject(sizes) {
|
|
@@ -117,7 +117,7 @@ const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_r
|
|
|
117
117
|
setPageSize(getPageSize(pageSizes, controlledPageSize));
|
|
118
118
|
setPrevControlledPageSize(controlledPageSize);
|
|
119
119
|
}
|
|
120
|
-
if (!
|
|
120
|
+
if (!isEqual(controlledPageSizes, prevPageSizes)) {
|
|
121
121
|
const pageSizes = mapPageSizesToObject(controlledPageSizes);
|
|
122
122
|
const hasPageSize = pageSizes.find(size => {
|
|
123
123
|
return size.value === pageSize;
|
|
@@ -12,8 +12,8 @@ import React__default, { useState } from 'react';
|
|
|
12
12
|
import { Warning, Incomplete, CheckmarkOutline, CircleDash } from '@carbon/icons-react';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
14
|
import '../Text/index.js';
|
|
15
|
-
import { Text } from '../Text/Text.js';
|
|
16
15
|
import { matches } from '../../internal/keyboard/match.js';
|
|
16
|
+
import { Text } from '../Text/Text.js';
|
|
17
17
|
import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
18
18
|
|
|
19
19
|
const defaultTranslations = {
|
|
@@ -16,8 +16,8 @@ import deprecate from '../../prop-types/deprecate.js';
|
|
|
16
16
|
import { noopFn } from '../../internal/noopFn.js';
|
|
17
17
|
import '../Text/index.js';
|
|
18
18
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
19
|
-
import { Text } from '../Text/Text.js';
|
|
20
19
|
import { matches } from '../../internal/keyboard/match.js';
|
|
20
|
+
import { Text } from '../Text/Text.js';
|
|
21
21
|
import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
22
22
|
|
|
23
23
|
var _RadioButtonChecked, _RadioButton, _CheckmarkFilled;
|
|
@@ -49,8 +49,16 @@ const Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref)
|
|
|
49
49
|
isFluid
|
|
50
50
|
} = useContext(FormContext);
|
|
51
51
|
const [isFocused, setIsFocused] = useState(false);
|
|
52
|
-
const [title, setTitle] = useState('');
|
|
53
52
|
const selectInstanceId = useId();
|
|
53
|
+
// Convert children to an array of valid elements once using type narrowing
|
|
54
|
+
const validChildren = React__default.Children.toArray(children).filter(child => /*#__PURE__*/React__default.isValidElement(child));
|
|
55
|
+
|
|
56
|
+
// Find the default option based on the specified defaultValue
|
|
57
|
+
const defaultOption = validChildren.find(child => child.props?.value === other?.defaultValue);
|
|
58
|
+
|
|
59
|
+
// Use the default option's text if available; otherwise, fallback to the first option's text
|
|
60
|
+
const initialTitle = defaultOption?.props?.text || validChildren[0]?.props?.text || '';
|
|
61
|
+
const [title, setTitle] = useState(initialTitle);
|
|
54
62
|
const selectClasses = cx({
|
|
55
63
|
[`${prefix}--select`]: true,
|
|
56
64
|
[`${prefix}--select--inline`]: inline,
|
|
@@ -105,7 +113,8 @@ const Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref)
|
|
|
105
113
|
setIsFocused(evt.type === 'focus' ? true : false);
|
|
106
114
|
};
|
|
107
115
|
const handleChange = evt => {
|
|
108
|
-
|
|
116
|
+
const selectedOption = evt?.target?.options[evt.target.selectedIndex];
|
|
117
|
+
setTitle(selectedOption?.text);
|
|
109
118
|
};
|
|
110
119
|
const readOnlyEventHandlers = {
|
|
111
120
|
onMouseDown: evt => {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2025, 2025
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
export declare const ShapeIndicatorKinds: string[];
|
|
9
|
+
export type ShapeIndicatorKind = (typeof ShapeIndicatorKinds)[number];
|
|
10
|
+
export interface ShapeIndicatorProps {
|
|
11
|
+
/**
|
|
12
|
+
* Specify an optional className to add.
|
|
13
|
+
*/
|
|
14
|
+
className?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Specify the kind of shape to be used
|
|
17
|
+
*/
|
|
18
|
+
kind: ShapeIndicatorKind;
|
|
19
|
+
/**
|
|
20
|
+
* Label next to the shape
|
|
21
|
+
*/
|
|
22
|
+
label: string;
|
|
23
|
+
/**
|
|
24
|
+
* Specify the text size of the Shape Indicator. Defaults to 12.
|
|
25
|
+
*/
|
|
26
|
+
textSize?: 12 | 14;
|
|
27
|
+
}
|
|
28
|
+
export declare const ShapeIndicator: React.ForwardRefExoticComponent<ShapeIndicatorProps & React.RefAttributes<HTMLDivElement>>;
|
|
29
|
+
export default ShapeIndicator;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import React__default from 'react';
|
|
11
|
+
import cx from 'classnames';
|
|
12
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
|
+
import { Critical, CriticalSeverity, Caution, DiamondFill, LowSeverity, CircleFill, CircleStroke } from '@carbon/icons-react';
|
|
14
|
+
|
|
15
|
+
var _path;
|
|
16
|
+
const ShapeIndicatorKinds = ['failed', 'critical', 'high', 'medium', 'low', 'cautious', 'undefined', 'stable', 'informative', 'incomplete', 'draft'];
|
|
17
|
+
|
|
18
|
+
// TODO: update to import '@carbon/icons-react'
|
|
19
|
+
const incompleteIcon = props => /*#__PURE__*/React__default.createElement("svg", _extends({
|
|
20
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
21
|
+
width: 16,
|
|
22
|
+
height: 16,
|
|
23
|
+
fill: "none",
|
|
24
|
+
"aria-hidden": "true"
|
|
25
|
+
}, props), /*#__PURE__*/React__default.createElement("path", {
|
|
26
|
+
fill: "#fff",
|
|
27
|
+
fillOpacity: 0.01,
|
|
28
|
+
d: "M0 0h16v16H0z",
|
|
29
|
+
style: {
|
|
30
|
+
mixBlendMode: 'multiply'
|
|
31
|
+
}
|
|
32
|
+
}), _path || (_path = /*#__PURE__*/React__default.createElement("path", {
|
|
33
|
+
fill: "#161616",
|
|
34
|
+
d: "M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2Zm0 2a4.004 4.004 0 0 1 4 4H4a4.004 4.004 0 0 1 4-4Z"
|
|
35
|
+
})));
|
|
36
|
+
const shapeTypes = {
|
|
37
|
+
failed: Critical,
|
|
38
|
+
critical: CriticalSeverity,
|
|
39
|
+
high: Caution,
|
|
40
|
+
medium: DiamondFill,
|
|
41
|
+
low: LowSeverity,
|
|
42
|
+
cautious: Caution,
|
|
43
|
+
undefined: DiamondFill,
|
|
44
|
+
stable: CircleFill,
|
|
45
|
+
informative: LowSeverity,
|
|
46
|
+
incomplete: incompleteIcon,
|
|
47
|
+
draft: CircleStroke
|
|
48
|
+
};
|
|
49
|
+
const ShapeIndicator = /*#__PURE__*/React__default.forwardRef(function ShapeIndicatorContent(_ref, ref) {
|
|
50
|
+
let {
|
|
51
|
+
className: customClassName,
|
|
52
|
+
kind,
|
|
53
|
+
label,
|
|
54
|
+
textSize = 12,
|
|
55
|
+
...rest
|
|
56
|
+
} = _ref;
|
|
57
|
+
const prefix = usePrefix();
|
|
58
|
+
const classNames = cx(`${prefix}--shape-indicator`, customClassName, {
|
|
59
|
+
[`${prefix}--shape-indicator--14`]: textSize == 14
|
|
60
|
+
});
|
|
61
|
+
const ShapeForKind = shapeTypes[kind];
|
|
62
|
+
if (!ShapeForKind) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
66
|
+
className: classNames,
|
|
67
|
+
ref: ref
|
|
68
|
+
}, /*#__PURE__*/React__default.createElement(ShapeForKind, {
|
|
69
|
+
size: 16,
|
|
70
|
+
className: `${prefix}--shape-indicator--${kind}`
|
|
71
|
+
}), label);
|
|
72
|
+
});
|
|
73
|
+
ShapeIndicator.propTypes = {
|
|
74
|
+
/**
|
|
75
|
+
* Specify an optional className to add.
|
|
76
|
+
*/
|
|
77
|
+
className: PropTypes.string,
|
|
78
|
+
/**
|
|
79
|
+
* Specify the kind of the Shape Indicator
|
|
80
|
+
*/
|
|
81
|
+
kind: PropTypes.oneOf(ShapeIndicatorKinds).isRequired,
|
|
82
|
+
/**
|
|
83
|
+
* Label next to the shape.
|
|
84
|
+
*/
|
|
85
|
+
label: PropTypes.string.isRequired,
|
|
86
|
+
/**
|
|
87
|
+
* Specify the text size of the Shape Indicator. Defaults to 12.
|
|
88
|
+
*/
|
|
89
|
+
textSize: PropTypes.oneOf([12, 14])
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export { ShapeIndicator, ShapeIndicatorKinds, ShapeIndicator as default };
|
|
@@ -353,10 +353,11 @@ export interface TabProps extends HTMLAttributes<HTMLElement> {
|
|
|
353
353
|
secondaryLabel?: string;
|
|
354
354
|
}
|
|
355
355
|
declare const Tab: React.ForwardRefExoticComponent<TabProps & React.RefAttributes<HTMLElement>>;
|
|
356
|
-
/**
|
|
357
|
-
* IconTab
|
|
358
|
-
*/
|
|
359
356
|
export interface IconTabProps extends DivAttributes {
|
|
357
|
+
/**
|
|
358
|
+
* **Experimental**: Display an empty dot badge on the Tab.
|
|
359
|
+
*/
|
|
360
|
+
badgeIndicator?: boolean;
|
|
360
361
|
/**
|
|
361
362
|
* Provide an icon to be rendered inside `IconTab` as the visual label for Tab.
|
|
362
363
|
*/
|
|
@@ -377,7 +378,8 @@ export interface IconTabProps extends DivAttributes {
|
|
|
377
378
|
* Provide the label to be rendered inside the Tooltip. The label will use
|
|
378
379
|
* `aria-labelledby` and will fully describe the child node that is provided.
|
|
379
380
|
* This means that if you have text in the child node it will not be
|
|
380
|
-
* announced to the screen reader.
|
|
381
|
+
* announced to the screen reader. If using the badgeIndicator then provide a
|
|
382
|
+
* label with describing that there is a new notification.
|
|
381
383
|
*/
|
|
382
384
|
label: ReactNode;
|
|
383
385
|
/**
|
|
@@ -10,7 +10,7 @@ import { ChevronLeft, ChevronRight, Close } 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__default, { useState, useRef, useCallback, useEffect, forwardRef } from 'react';
|
|
13
|
+
import React__default, { useState, useRef, useCallback, useEffect, forwardRef, createContext, useMemo } from 'react';
|
|
14
14
|
import '../Grid/FlexGrid.js';
|
|
15
15
|
import { Grid as GridAsGridComponent } from '../Grid/Grid.js';
|
|
16
16
|
import '../Grid/Row.js';
|
|
@@ -32,12 +32,13 @@ import deprecate from '../../prop-types/deprecate.js';
|
|
|
32
32
|
import { useEvent } from '../../internal/useEvent.js';
|
|
33
33
|
import { useMatchMedia } from '../../internal/useMatchMedia.js';
|
|
34
34
|
import '../Text/index.js';
|
|
35
|
+
import { BadgeIndicator } from '../BadgeIndicator/index.js';
|
|
35
36
|
import { debounce } from '../../node_modules/es-toolkit/dist/compat/function/debounce.mjs.js';
|
|
36
|
-
import { Text } from '../Text/Text.js';
|
|
37
37
|
import { matches, match } from '../../internal/keyboard/match.js';
|
|
38
|
+
import { Text } from '../Text/Text.js';
|
|
38
39
|
import { ArrowRight, ArrowLeft, Home, End, ArrowDown, ArrowUp, Delete } from '../../internal/keyboard/keys.js';
|
|
39
40
|
|
|
40
|
-
var _ChevronLeft, _ChevronRight;
|
|
41
|
+
var _ChevronLeft, _ChevronRight, _BadgeIndicator;
|
|
41
42
|
const verticalTabHeight = 64;
|
|
42
43
|
|
|
43
44
|
// Used to manage the overall state of the Tabs
|
|
@@ -798,6 +799,9 @@ const Tab = /*#__PURE__*/forwardRef(function Tab(_ref10, forwardRef) {
|
|
|
798
799
|
hasSecondaryLabel,
|
|
799
800
|
contained
|
|
800
801
|
} = React__default.useContext(TabContext);
|
|
802
|
+
const {
|
|
803
|
+
badgeIndicator
|
|
804
|
+
} = React__default.useContext(IconTabContext) || {};
|
|
801
805
|
const dismissIconRef = useRef(null);
|
|
802
806
|
const tabRef = useRef(null);
|
|
803
807
|
const ref = useMergedRefs([forwardRef, tabRef]);
|
|
@@ -975,7 +979,7 @@ const Tab = /*#__PURE__*/forwardRef(function Tab(_ref10, forwardRef) {
|
|
|
975
979
|
as: "div",
|
|
976
980
|
className: `${prefix}--tabs__nav-item-secondary-label`,
|
|
977
981
|
title: secondaryLabel
|
|
978
|
-
}, secondaryLabel)), DismissIcon);
|
|
982
|
+
}, secondaryLabel), !disabled && badgeIndicator && (_BadgeIndicator || (_BadgeIndicator = /*#__PURE__*/React__default.createElement(BadgeIndicator, null)))), DismissIcon);
|
|
979
983
|
});
|
|
980
984
|
Tab.propTypes = {
|
|
981
985
|
/**
|
|
@@ -1026,8 +1030,10 @@ Tab.propTypes = {
|
|
|
1026
1030
|
* IconTab
|
|
1027
1031
|
*/
|
|
1028
1032
|
|
|
1033
|
+
const IconTabContext = /*#__PURE__*/createContext(false);
|
|
1029
1034
|
const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(_ref11, ref) {
|
|
1030
1035
|
let {
|
|
1036
|
+
badgeIndicator,
|
|
1031
1037
|
children,
|
|
1032
1038
|
className: customClassName,
|
|
1033
1039
|
defaultOpen = false,
|
|
@@ -1037,8 +1043,16 @@ const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(_ref11,
|
|
|
1037
1043
|
...rest
|
|
1038
1044
|
} = _ref11;
|
|
1039
1045
|
const prefix = usePrefix();
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1046
|
+
const value = useMemo(() => ({
|
|
1047
|
+
badgeIndicator
|
|
1048
|
+
}), [badgeIndicator]);
|
|
1049
|
+
const hasSize20 = /*#__PURE__*/React__default.isValidElement(children) && children.props?.size === 20;
|
|
1050
|
+
const classNames = cx(`${prefix}--tabs__nav-item--icon-only`, customClassName, {
|
|
1051
|
+
[`${prefix}--tabs__nav-item--icon-only__20`]: hasSize20
|
|
1052
|
+
});
|
|
1053
|
+
return /*#__PURE__*/React__default.createElement(IconTabContext.Provider, {
|
|
1054
|
+
value: value
|
|
1055
|
+
}, /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
1042
1056
|
align: "bottom",
|
|
1043
1057
|
defaultOpen: defaultOpen,
|
|
1044
1058
|
className: `${prefix}--icon-tooltip`,
|
|
@@ -1048,9 +1062,13 @@ const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(_ref11,
|
|
|
1048
1062
|
}, /*#__PURE__*/React__default.createElement(Tab, _extends({
|
|
1049
1063
|
className: classNames,
|
|
1050
1064
|
ref: ref
|
|
1051
|
-
}, rest), children));
|
|
1065
|
+
}, rest), children)));
|
|
1052
1066
|
});
|
|
1053
1067
|
IconTab.propTypes = {
|
|
1068
|
+
/**
|
|
1069
|
+
* **Experimental**: Display an empty dot badge on the Tab.
|
|
1070
|
+
*/
|
|
1071
|
+
badgeIndicator: PropTypes.bool,
|
|
1054
1072
|
/**
|
|
1055
1073
|
* Provide an icon to be rendered inside `IconTab` as the visual label for Tab.
|
|
1056
1074
|
*/
|
|
@@ -1071,7 +1089,8 @@ IconTab.propTypes = {
|
|
|
1071
1089
|
* Provide the label to be rendered inside the Tooltip. The label will use
|
|
1072
1090
|
* `aria-labelledby` and will fully describe the child node that is provided.
|
|
1073
1091
|
* This means that if you have text in the child node it will not be
|
|
1074
|
-
* announced to the screen reader.
|
|
1092
|
+
* announced to the screen reader. If using the badgeIndicator then provide a
|
|
1093
|
+
* label with describing that there is a new notification.
|
|
1075
1094
|
*/
|
|
1076
1095
|
label: PropTypes.node.isRequired,
|
|
1077
1096
|
/**
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
8
7
|
import React, { MouseEventHandler } from 'react';
|
|
9
8
|
import { PolymorphicProps } from '../../types/common';
|
|
10
9
|
import { SIZES } from './Tag';
|
|
@@ -54,40 +53,6 @@ export interface OperationalTagBaseProps {
|
|
|
54
53
|
type?: keyof typeof TYPES;
|
|
55
54
|
}
|
|
56
55
|
export type OperationalTagProps<T extends React.ElementType> = PolymorphicProps<T, OperationalTagBaseProps>;
|
|
57
|
-
declare const OperationalTag:
|
|
58
|
-
<T extends React.ElementType>({ className, disabled, id, renderIcon, size, text, type, ...other }: OperationalTagProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
59
|
-
propTypes: {
|
|
60
|
-
/**
|
|
61
|
-
* Provide a custom className that is applied to the containing <span>
|
|
62
|
-
*/
|
|
63
|
-
className: PropTypes.Requireable<string>;
|
|
64
|
-
/**
|
|
65
|
-
* Specify if the `OperationalTag` is disabled
|
|
66
|
-
*/
|
|
67
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
68
|
-
/**
|
|
69
|
-
* Specify the id for the tag.
|
|
70
|
-
*/
|
|
71
|
-
id: PropTypes.Requireable<string>;
|
|
72
|
-
/**
|
|
73
|
-
* Optional prop to render a custom icon.
|
|
74
|
-
* Can be a React component class
|
|
75
|
-
*/
|
|
76
|
-
renderIcon: PropTypes.Requireable<object>;
|
|
77
|
-
/**
|
|
78
|
-
* Specify the size of the Tag. Currently supports either `sm`,
|
|
79
|
-
* `md` (default) or `lg` sizes.
|
|
80
|
-
*/
|
|
81
|
-
size: PropTypes.Requireable<string>;
|
|
82
|
-
/**
|
|
83
|
-
* Provide text to be rendered inside of a the tag.
|
|
84
|
-
*/
|
|
85
|
-
text: PropTypes.Requireable<string>;
|
|
86
|
-
/**
|
|
87
|
-
* Specify the type of the `Tag`
|
|
88
|
-
*/
|
|
89
|
-
type: PropTypes.Requireable<string>;
|
|
90
|
-
};
|
|
91
|
-
};
|
|
56
|
+
declare const OperationalTag: React.ForwardRefExoticComponent<Omit<OperationalTagProps<React.ElementType<any, keyof React.JSX.IntrinsicElements>>, "ref"> & React.RefAttributes<HTMLLIElement>>;
|
|
92
57
|
export declare const types: string[];
|
|
93
58
|
export default OperationalTag;
|
|
@@ -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__default, { useRef, useState, useLayoutEffect } from 'react';
|
|
10
|
+
import React__default, { forwardRef, useRef, useState, useLayoutEffect } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { useId } from '../../internal/useId.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
@@ -16,6 +16,7 @@ import '../Tooltip/DefinitionTooltip.js';
|
|
|
16
16
|
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
17
17
|
import '../Text/index.js';
|
|
18
18
|
import { isEllipsisActive } from './isEllipsisActive.js';
|
|
19
|
+
import mergeRefs from '../../tools/mergeRefs.js';
|
|
19
20
|
import { Text } from '../Text/Text.js';
|
|
20
21
|
|
|
21
22
|
const TYPES = {
|
|
@@ -30,7 +31,7 @@ const TYPES = {
|
|
|
30
31
|
'cool-gray': 'Cool-Gray',
|
|
31
32
|
'warm-gray': 'Warm-Gray'
|
|
32
33
|
};
|
|
33
|
-
const OperationalTag = _ref => {
|
|
34
|
+
const OperationalTag = /*#__PURE__*/forwardRef((_ref, forwardRef) => {
|
|
34
35
|
let {
|
|
35
36
|
className,
|
|
36
37
|
disabled,
|
|
@@ -51,6 +52,7 @@ const OperationalTag = _ref => {
|
|
|
51
52
|
setIsEllipsisApplied(isEllipsisActive(newElement));
|
|
52
53
|
}, [prefix, tagRef]);
|
|
53
54
|
const tooltipClasses = cx(`${prefix}--icon-tooltip`, `${prefix}--tag-label-tooltip`);
|
|
55
|
+
const combinedRef = mergeRefs(tagRef, forwardRef);
|
|
54
56
|
if (isEllipsisApplied) {
|
|
55
57
|
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
56
58
|
label: text,
|
|
@@ -60,7 +62,7 @@ const OperationalTag = _ref => {
|
|
|
60
62
|
onMouseEnter: () => false,
|
|
61
63
|
closeOnActivation: true
|
|
62
64
|
}, /*#__PURE__*/React__default.createElement(Tag, _extends({
|
|
63
|
-
ref:
|
|
65
|
+
ref: combinedRef,
|
|
64
66
|
type: type,
|
|
65
67
|
size: size,
|
|
66
68
|
renderIcon: renderIcon,
|
|
@@ -73,7 +75,7 @@ const OperationalTag = _ref => {
|
|
|
73
75
|
}, text)));
|
|
74
76
|
}
|
|
75
77
|
return /*#__PURE__*/React__default.createElement(Tag, _extends({
|
|
76
|
-
ref:
|
|
78
|
+
ref: combinedRef,
|
|
77
79
|
type: type,
|
|
78
80
|
size: size,
|
|
79
81
|
renderIcon: renderIcon,
|
|
@@ -84,7 +86,7 @@ const OperationalTag = _ref => {
|
|
|
84
86
|
title: text,
|
|
85
87
|
className: `${prefix}--tag__label`
|
|
86
88
|
}, text));
|
|
87
|
-
};
|
|
89
|
+
});
|
|
88
90
|
OperationalTag.propTypes = {
|
|
89
91
|
/**
|
|
90
92
|
* Provide a custom className that is applied to the containing <span>
|
|
@@ -1,17 +1,19 @@
|
|
|
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
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { type ElementType, type ReactElement, type ReactNode } from 'react';
|
|
8
|
+
import { PolymorphicComponentPropWithRef, PolymorphicRef } from '../../internal/PolymorphicProps';
|
|
9
|
+
import { type TextDir } from '.';
|
|
10
10
|
export interface TextBaseProps {
|
|
11
|
-
dir?: TextDir
|
|
11
|
+
dir?: TextDir;
|
|
12
12
|
children?: ReactNode;
|
|
13
13
|
}
|
|
14
|
-
export type TextProps<T extends
|
|
15
|
-
type TextComponent = <T extends
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
export type TextProps<T extends ElementType> = PolymorphicComponentPropWithRef<T, TextBaseProps>;
|
|
15
|
+
type TextComponent = <T extends ElementType = 'span'>(props: TextProps<T> & {
|
|
16
|
+
ref?: PolymorphicRef<T>;
|
|
17
|
+
}) => ReactElement | null;
|
|
18
|
+
export declare const Text: TextComponent;
|
|
19
|
+
export {};
|
|
@@ -7,17 +7,17 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React__default, { useContext } from 'react';
|
|
10
|
+
import React__default, { forwardRef, useContext, Children } from 'react';
|
|
11
|
+
import './index.js';
|
|
11
12
|
import { TextDirectionContext } from './TextDirectionContext.js';
|
|
12
13
|
|
|
13
|
-
const Text = /*#__PURE__*/
|
|
14
|
+
const Text = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
14
15
|
let {
|
|
15
16
|
as,
|
|
16
17
|
children,
|
|
17
18
|
dir = 'auto',
|
|
18
19
|
...rest
|
|
19
20
|
} = _ref;
|
|
20
|
-
// TODO: Update with context typing once its been converted to TS
|
|
21
21
|
const context = useContext(TextDirectionContext);
|
|
22
22
|
const textProps = {};
|
|
23
23
|
const BaseComponent = as ?? 'span';
|
|
@@ -69,11 +69,11 @@ Text.propTypes = {
|
|
|
69
69
|
*/
|
|
70
70
|
dir: PropTypes.oneOf(['ltr', 'rtl', 'auto'])
|
|
71
71
|
};
|
|
72
|
-
|
|
72
|
+
const getTextFromChildren = children => {
|
|
73
73
|
if (typeof children === 'string') {
|
|
74
74
|
return children;
|
|
75
75
|
}
|
|
76
|
-
const text =
|
|
76
|
+
const text = Children.map(children, child => {
|
|
77
77
|
if (typeof child === 'string') {
|
|
78
78
|
return child;
|
|
79
79
|
}
|
|
@@ -85,6 +85,6 @@ function getTextFromChildren(children) {
|
|
|
85
85
|
return text[0];
|
|
86
86
|
}
|
|
87
87
|
return text;
|
|
88
|
-
}
|
|
88
|
+
};
|
|
89
89
|
|
|
90
90
|
export { Text };
|
|
@@ -1,21 +1,20 @@
|
|
|
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
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { ReactNode } from 'react';
|
|
9
|
-
|
|
10
|
-
export type GetTextDirection = (text: string | string[] | undefined) => TextDir;
|
|
9
|
+
import { type GetTextDirection, type TextDir } from '.';
|
|
11
10
|
export interface TextDirectionProps {
|
|
12
|
-
children: ReactNode
|
|
11
|
+
children: ReactNode;
|
|
13
12
|
dir?: TextDir;
|
|
14
13
|
getTextDirection?: GetTextDirection;
|
|
15
14
|
}
|
|
16
|
-
declare
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
export declare const TextDirection: {
|
|
16
|
+
({ children, dir, getTextDirection, }: TextDirectionProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
propTypes: {
|
|
19
18
|
/**
|
|
20
19
|
* Provide children to be rendered inside of this component
|
|
21
20
|
*/
|
|
@@ -31,5 +30,4 @@ declare namespace TextDirection {
|
|
|
31
30
|
*/
|
|
32
31
|
getTextDirection: PropTypes.Requireable<(...args: any[]) => any>;
|
|
33
32
|
};
|
|
34
|
-
}
|
|
35
|
-
export { TextDirection };
|
|
33
|
+
};
|