@carbon/react 1.58.0 → 1.59.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 +1255 -1097
- package/es/components/Accordion/Accordion.Skeleton.d.ts +6 -1
- package/es/components/Accordion/Accordion.Skeleton.js +3 -1
- package/es/components/Accordion/Accordion.d.ts +11 -1
- package/es/components/Accordion/Accordion.js +8 -1
- package/es/components/CheckboxGroup/CheckboxGroup.js +7 -0
- package/es/components/ComboButton/index.d.ts +2 -1
- package/es/components/ComboButton/index.js +51 -31
- package/es/components/ContainedList/index.js +4 -0
- package/es/components/ListBox/ListBoxMenuItem.js +1 -1
- package/es/components/RadioTile/RadioTile.d.ts +9 -0
- package/es/components/RadioTile/RadioTile.js +24 -3
- package/es/components/Tag/DismissibleTag.js +7 -9
- package/es/components/Tag/OperationalTag.js +9 -10
- package/es/components/Tag/SelectableTag.js +9 -10
- package/es/components/Tag/Tag.d.ts +4 -60
- package/es/components/Tag/Tag.js +14 -14
- package/es/components/Tag/isEllipsisActive.d.ts +7 -0
- package/es/components/Tag/isEllipsisActive.js +15 -0
- package/es/components/Tooltip/Tooltip.js +42 -22
- package/es/components/UIShell/Content.d.ts +3 -3
- package/es/components/UIShell/SwitcherItem.d.ts +5 -1
- package/es/components/UIShell/SwitcherItem.js +7 -1
- package/lib/components/Accordion/Accordion.Skeleton.d.ts +6 -1
- package/lib/components/Accordion/Accordion.Skeleton.js +3 -1
- package/lib/components/Accordion/Accordion.d.ts +11 -1
- package/lib/components/Accordion/Accordion.js +8 -1
- package/lib/components/CheckboxGroup/CheckboxGroup.js +7 -0
- package/lib/components/ComboButton/index.d.ts +2 -1
- package/lib/components/ComboButton/index.js +45 -25
- package/lib/components/ContainedList/index.js +4 -0
- package/lib/components/ListBox/ListBoxMenuItem.js +1 -1
- package/lib/components/RadioTile/RadioTile.d.ts +9 -0
- package/lib/components/RadioTile/RadioTile.js +24 -3
- package/lib/components/Tag/DismissibleTag.js +6 -8
- package/lib/components/Tag/OperationalTag.js +8 -9
- package/lib/components/Tag/SelectableTag.js +8 -9
- package/lib/components/Tag/Tag.d.ts +4 -60
- package/lib/components/Tag/Tag.js +13 -13
- package/lib/components/Tag/isEllipsisActive.d.ts +7 -0
- package/lib/components/Tag/isEllipsisActive.js +19 -0
- package/lib/components/Tooltip/Tooltip.js +42 -22
- package/lib/components/UIShell/Content.d.ts +3 -3
- package/lib/components/UIShell/SwitcherItem.d.ts +5 -1
- package/lib/components/UIShell/SwitcherItem.js +7 -1
- package/package.json +3 -3
|
@@ -9,10 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
|
+
var deprecateFieldOnObject = require('../../internal/deprecateFieldOnObject.js');
|
|
12
13
|
var ContainedList = require('./ContainedList.js');
|
|
13
14
|
var ContainedListItem = require('./ContainedListItem/ContainedListItem.js');
|
|
14
15
|
|
|
15
16
|
ContainedList["default"].ContainedListItem = ContainedListItem["default"];
|
|
17
|
+
if (process.env.NODE_ENV !== "production") {
|
|
18
|
+
deprecateFieldOnObject.deprecateFieldOnObject(ContainedList["default"], 'ContainedListItem', ContainedListItem["default"]);
|
|
19
|
+
}
|
|
16
20
|
|
|
17
21
|
exports.ContainedList = ContainedList["default"];
|
|
18
22
|
exports["default"] = ContainedList["default"];
|
|
@@ -22,6 +22,11 @@ export interface RadioTileProps {
|
|
|
22
22
|
* Specify whether the `RadioTile` should be disabled.
|
|
23
23
|
*/
|
|
24
24
|
disabled?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* **Experimental**: Specify if the `ExpandableTile` component should be rendered with rounded corners.
|
|
27
|
+
* Only valid when `slug` prop is present
|
|
28
|
+
*/
|
|
29
|
+
hasRoundedCorners?: boolean;
|
|
25
30
|
/**
|
|
26
31
|
* Provide a unique id for the underlying `<input>`.
|
|
27
32
|
*/
|
|
@@ -42,6 +47,10 @@ export interface RadioTileProps {
|
|
|
42
47
|
* the underlying `<input>` changes.
|
|
43
48
|
*/
|
|
44
49
|
onChange?: (value: string | number, name: string | undefined, event: React.ChangeEvent<HTMLInputElement> | React.KeyboardEvent<HTMLInputElement>) => void;
|
|
50
|
+
/**
|
|
51
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `SelectableTile` component
|
|
52
|
+
*/
|
|
53
|
+
slug?: React.ReactNode;
|
|
45
54
|
/**
|
|
46
55
|
* Specify the tab index of the underlying `<input>`.
|
|
47
56
|
*/
|
|
@@ -43,15 +43,19 @@ const RadioTile = /*#__PURE__*/React__default["default"].forwardRef(function Rad
|
|
|
43
43
|
id,
|
|
44
44
|
onChange = noopFn.noopFn,
|
|
45
45
|
tabIndex = 0,
|
|
46
|
+
hasRoundedCorners,
|
|
47
|
+
slug,
|
|
46
48
|
required,
|
|
47
49
|
...rest
|
|
48
50
|
} = _ref;
|
|
49
51
|
const prefix = usePrefix.usePrefix();
|
|
50
52
|
const inputId = useId.useFallbackId(id);
|
|
51
|
-
const className = cx__default["default"](customClassName, `${prefix}--tile`, `${prefix}--tile--selectable`, {
|
|
53
|
+
const className = cx__default["default"](customClassName, `${prefix}--tile`, `${prefix}--tile--selectable`, `${prefix}--tile--radio`, {
|
|
52
54
|
[`${prefix}--tile--is-selected`]: checked,
|
|
53
55
|
[`${prefix}--tile--light`]: light,
|
|
54
|
-
[`${prefix}--tile--disabled`]: disabled
|
|
56
|
+
[`${prefix}--tile--disabled`]: disabled,
|
|
57
|
+
[`${prefix}--tile--slug`]: slug,
|
|
58
|
+
[`${prefix}--tile--slug-rounded`]: slug && hasRoundedCorners
|
|
55
59
|
});
|
|
56
60
|
const v12TileRadioIcons = index.useFeatureFlag('enable-v12-tile-radio-icons');
|
|
57
61
|
function icon() {
|
|
@@ -74,6 +78,14 @@ const RadioTile = /*#__PURE__*/React__default["default"].forwardRef(function Rad
|
|
|
74
78
|
onChange(value, name, evt);
|
|
75
79
|
}
|
|
76
80
|
}
|
|
81
|
+
|
|
82
|
+
// Slug is always size `xs`
|
|
83
|
+
let normalizedSlug;
|
|
84
|
+
if (slug && slug['type']?.displayName === 'Slug') {
|
|
85
|
+
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
86
|
+
size: 'xs'
|
|
87
|
+
});
|
|
88
|
+
}
|
|
77
89
|
return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("input", {
|
|
78
90
|
checked: checked,
|
|
79
91
|
className: `${prefix}--tile-input`,
|
|
@@ -94,7 +106,7 @@ const RadioTile = /*#__PURE__*/React__default["default"].forwardRef(function Rad
|
|
|
94
106
|
className: `${prefix}--tile__checkmark`
|
|
95
107
|
}, icon()), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
96
108
|
className: `${prefix}--tile-content`
|
|
97
|
-
}, children)));
|
|
109
|
+
}, children), normalizedSlug));
|
|
98
110
|
});
|
|
99
111
|
RadioTile.displayName = 'RadioTile';
|
|
100
112
|
RadioTile.propTypes = {
|
|
@@ -114,6 +126,11 @@ RadioTile.propTypes = {
|
|
|
114
126
|
* Specify whether the `RadioTile` should be disabled.
|
|
115
127
|
*/
|
|
116
128
|
disabled: PropTypes__default["default"].bool,
|
|
129
|
+
/**
|
|
130
|
+
* Specify if the `ExpandableTile` component should be rendered with rounded corners.
|
|
131
|
+
* Only valid when `slug` prop is present
|
|
132
|
+
*/
|
|
133
|
+
hasRoundedCorners: PropTypes__default["default"].bool,
|
|
117
134
|
/**
|
|
118
135
|
* Provide a unique id for the underlying `<input>`.
|
|
119
136
|
*/
|
|
@@ -136,6 +153,10 @@ RadioTile.propTypes = {
|
|
|
136
153
|
* `true` to specify if the control is required.
|
|
137
154
|
*/
|
|
138
155
|
required: PropTypes__default["default"].bool,
|
|
156
|
+
/**
|
|
157
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `SelectableTile` component
|
|
158
|
+
*/
|
|
159
|
+
slug: PropTypes__default["default"].node,
|
|
139
160
|
/**
|
|
140
161
|
* Specify the tab index of the underlying `<input>`.
|
|
141
162
|
*/
|
|
@@ -20,6 +20,7 @@ var iconsReact = require('@carbon/icons-react');
|
|
|
20
20
|
require('../Tooltip/DefinitionTooltip.js');
|
|
21
21
|
var Tooltip = require('../Tooltip/Tooltip.js');
|
|
22
22
|
require('../Text/index.js');
|
|
23
|
+
var isEllipsisActive = require('./isEllipsisActive.js');
|
|
23
24
|
var Text = require('../Text/Text.js');
|
|
24
25
|
|
|
25
26
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -45,18 +46,14 @@ const DismissibleTag = _ref => {
|
|
|
45
46
|
...other
|
|
46
47
|
} = _ref;
|
|
47
48
|
const prefix = usePrefix.usePrefix();
|
|
49
|
+
const tagLabelRef = React.useRef();
|
|
48
50
|
const tagId = id || `tag-${getInstanceId()}`;
|
|
49
51
|
const tagClasses = cx__default["default"](`${prefix}--tag--filter`, className);
|
|
50
52
|
const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
|
|
51
|
-
const isEllipsisActive = element => {
|
|
52
|
-
setIsEllipsisApplied(element.offsetWidth < element.scrollWidth);
|
|
53
|
-
return element.offsetWidth < element.scrollWidth;
|
|
54
|
-
};
|
|
55
53
|
React.useLayoutEffect(() => {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}, [prefix, tagId]);
|
|
54
|
+
const newElement = tagLabelRef.current?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
55
|
+
setIsEllipsisApplied(isEllipsisActive.isEllipsisActive(newElement));
|
|
56
|
+
}, [prefix, tagLabelRef]);
|
|
60
57
|
const handleClose = event => {
|
|
61
58
|
if (onClose) {
|
|
62
59
|
event.stopPropagation();
|
|
@@ -80,6 +77,7 @@ const DismissibleTag = _ref => {
|
|
|
80
77
|
} = other;
|
|
81
78
|
const dismissLabel = `Dismiss "${text}"`;
|
|
82
79
|
return /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
|
|
80
|
+
ref: tagLabelRef,
|
|
83
81
|
type: type,
|
|
84
82
|
size: size,
|
|
85
83
|
renderIcon: renderIcon,
|
|
@@ -19,6 +19,7 @@ var Tag = require('./Tag.js');
|
|
|
19
19
|
require('../Tooltip/DefinitionTooltip.js');
|
|
20
20
|
var Tooltip = require('../Tooltip/Tooltip.js');
|
|
21
21
|
require('../Text/index.js');
|
|
22
|
+
var isEllipsisActive = require('./isEllipsisActive.js');
|
|
22
23
|
var Text = require('../Text/Text.js');
|
|
23
24
|
|
|
24
25
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -53,18 +54,14 @@ const OperationalTag = _ref => {
|
|
|
53
54
|
...other
|
|
54
55
|
} = _ref;
|
|
55
56
|
const prefix = usePrefix.usePrefix();
|
|
57
|
+
const tagRef = React.useRef();
|
|
56
58
|
const tagId = id || `tag-${getInstanceId()}`;
|
|
57
59
|
const tagClasses = cx__default["default"](`${prefix}--tag--operational`, className);
|
|
58
60
|
const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
|
|
59
|
-
const isEllipsisActive = element => {
|
|
60
|
-
setIsEllipsisApplied(element.offsetWidth < element.scrollWidth);
|
|
61
|
-
return element.offsetWidth < element.scrollWidth;
|
|
62
|
-
};
|
|
63
61
|
React.useLayoutEffect(() => {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}, [prefix, tagId]);
|
|
62
|
+
const newElement = tagRef.current?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
63
|
+
setIsEllipsisApplied(isEllipsisActive.isEllipsisActive(newElement));
|
|
64
|
+
}, [prefix, tagRef]);
|
|
68
65
|
let normalizedSlug;
|
|
69
66
|
if (slug && slug['type']?.displayName === 'Slug') {
|
|
70
67
|
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
@@ -79,9 +76,10 @@ const OperationalTag = _ref => {
|
|
|
79
76
|
align: "bottom",
|
|
80
77
|
className: tooltipClasses,
|
|
81
78
|
leaveDelayMs: 0,
|
|
82
|
-
onMouseEnter: false,
|
|
79
|
+
onMouseEnter: () => false,
|
|
83
80
|
closeOnActivation: true
|
|
84
81
|
}, /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
|
|
82
|
+
ref: tagRef,
|
|
85
83
|
type: type,
|
|
86
84
|
size: size,
|
|
87
85
|
renderIcon: renderIcon,
|
|
@@ -94,6 +92,7 @@ const OperationalTag = _ref => {
|
|
|
94
92
|
}, text), normalizedSlug));
|
|
95
93
|
}
|
|
96
94
|
return /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
|
|
95
|
+
ref: tagRef,
|
|
97
96
|
type: type,
|
|
98
97
|
size: size,
|
|
99
98
|
renderIcon: renderIcon,
|
|
@@ -19,6 +19,7 @@ var Tag = require('./Tag.js');
|
|
|
19
19
|
require('../Tooltip/DefinitionTooltip.js');
|
|
20
20
|
var Tooltip = require('../Tooltip/Tooltip.js');
|
|
21
21
|
require('../Text/index.js');
|
|
22
|
+
var isEllipsisActive = require('./isEllipsisActive.js');
|
|
22
23
|
var Text = require('../Text/Text.js');
|
|
23
24
|
|
|
24
25
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -41,21 +42,17 @@ const SelectableTag = _ref => {
|
|
|
41
42
|
...other
|
|
42
43
|
} = _ref;
|
|
43
44
|
const prefix = usePrefix.usePrefix();
|
|
45
|
+
const tagRef = React.useRef();
|
|
44
46
|
const tagId = id || `tag-${getInstanceId()}`;
|
|
45
47
|
const [selectedTag, setSelectedTag] = React.useState(selected);
|
|
46
48
|
const tagClasses = cx__default["default"](`${prefix}--tag--selectable`, className, {
|
|
47
49
|
[`${prefix}--tag--selectable-selected`]: selectedTag
|
|
48
50
|
});
|
|
49
51
|
const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
|
|
50
|
-
const isEllipsisActive = element => {
|
|
51
|
-
setIsEllipsisApplied(element.offsetWidth < element.scrollWidth);
|
|
52
|
-
return element.offsetWidth < element.scrollWidth;
|
|
53
|
-
};
|
|
54
52
|
React.useLayoutEffect(() => {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}, [prefix, tagId]);
|
|
53
|
+
const newElement = tagRef.current?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
54
|
+
setIsEllipsisApplied(isEllipsisActive.isEllipsisActive(newElement));
|
|
55
|
+
}, [prefix, tagRef]);
|
|
59
56
|
let normalizedSlug;
|
|
60
57
|
if (slug && slug['type']?.displayName === 'Slug') {
|
|
61
58
|
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
@@ -77,8 +74,9 @@ const SelectableTag = _ref => {
|
|
|
77
74
|
align: "bottom",
|
|
78
75
|
className: tooltipClasses,
|
|
79
76
|
leaveDelayMs: 0,
|
|
80
|
-
onMouseEnter: false
|
|
77
|
+
onMouseEnter: () => false
|
|
81
78
|
}, /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
|
|
79
|
+
ref: tagRef,
|
|
82
80
|
slug: slug,
|
|
83
81
|
size: size,
|
|
84
82
|
renderIcon: renderIcon,
|
|
@@ -92,6 +90,7 @@ const SelectableTag = _ref => {
|
|
|
92
90
|
}, text), normalizedSlug));
|
|
93
91
|
}
|
|
94
92
|
return /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
|
|
93
|
+
ref: tagRef,
|
|
95
94
|
slug: slug,
|
|
96
95
|
size: size,
|
|
97
96
|
renderIcon: renderIcon,
|
|
@@ -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, { ReactNode } from 'react';
|
|
9
8
|
import { PolymorphicProps } from '../../types/common';
|
|
10
9
|
export declare const TYPES: {
|
|
@@ -40,7 +39,7 @@ export interface TagBaseProps {
|
|
|
40
39
|
*/
|
|
41
40
|
disabled?: boolean;
|
|
42
41
|
/**
|
|
43
|
-
* @deprecated
|
|
42
|
+
* @deprecated The `filter` prop has been deprecated and will be removed in the next major version. Use DismissibleTag instead.
|
|
44
43
|
*/
|
|
45
44
|
filter?: boolean;
|
|
46
45
|
/**
|
|
@@ -48,7 +47,7 @@ export interface TagBaseProps {
|
|
|
48
47
|
*/
|
|
49
48
|
id?: string;
|
|
50
49
|
/**
|
|
51
|
-
* @deprecated
|
|
50
|
+
* @deprecated The `onClose` prop has been deprecated and will be removed in the next major version. Use DismissibleTag instead.
|
|
52
51
|
*/
|
|
53
52
|
onClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
54
53
|
/**
|
|
@@ -66,7 +65,7 @@ export interface TagBaseProps {
|
|
|
66
65
|
*/
|
|
67
66
|
slug?: ReactNode;
|
|
68
67
|
/**
|
|
69
|
-
* @deprecated
|
|
68
|
+
* @deprecated The `title` prop has been deprecated and will be removed in the next major version. Use DismissibleTag instead.
|
|
70
69
|
*/
|
|
71
70
|
title?: string;
|
|
72
71
|
/**
|
|
@@ -75,61 +74,6 @@ export interface TagBaseProps {
|
|
|
75
74
|
type?: keyof typeof TYPES;
|
|
76
75
|
}
|
|
77
76
|
export type TagProps<T extends React.ElementType> = PolymorphicProps<T, TagBaseProps>;
|
|
78
|
-
declare const Tag:
|
|
79
|
-
<T extends React.ElementType<any>>({ children, className, id, type, filter, renderIcon: CustomIconElement, title, disabled, onClose, size, as: BaseComponent, slug, ...other }: TagProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
80
|
-
propTypes: {
|
|
81
|
-
/**
|
|
82
|
-
* Provide an alternative tag or component to use instead of the default
|
|
83
|
-
* wrapping element
|
|
84
|
-
*/
|
|
85
|
-
as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
|
|
86
|
-
/**
|
|
87
|
-
* Provide content to be rendered inside of a `Tag`
|
|
88
|
-
*/
|
|
89
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
90
|
-
/**
|
|
91
|
-
* Provide a custom className that is applied to the containing <span>
|
|
92
|
-
*/
|
|
93
|
-
className: PropTypes.Requireable<string>;
|
|
94
|
-
/**
|
|
95
|
-
* Specify if the `Tag` is disabled
|
|
96
|
-
*/
|
|
97
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
98
|
-
/**
|
|
99
|
-
* Determine if `Tag` is a filter/chip
|
|
100
|
-
*/
|
|
101
|
-
filter: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
102
|
-
/**
|
|
103
|
-
* Specify the id for the tag.
|
|
104
|
-
*/
|
|
105
|
-
id: PropTypes.Requireable<string>;
|
|
106
|
-
/**
|
|
107
|
-
* Click handler for filter tag close button.
|
|
108
|
-
*/
|
|
109
|
-
onClose: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
110
|
-
/**
|
|
111
|
-
* Optional prop to render a custom icon.
|
|
112
|
-
* Can be a React component class
|
|
113
|
-
*/
|
|
114
|
-
renderIcon: PropTypes.Requireable<object>;
|
|
115
|
-
/**
|
|
116
|
-
* Specify the size of the Tag. Currently supports either `sm`,
|
|
117
|
-
* `md` (default) or `lg` sizes.
|
|
118
|
-
*/
|
|
119
|
-
size: PropTypes.Requireable<string>;
|
|
120
|
-
/**
|
|
121
|
-
* **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
|
|
122
|
-
*/
|
|
123
|
-
slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
124
|
-
/**
|
|
125
|
-
* Text to show on clear filters
|
|
126
|
-
*/
|
|
127
|
-
title: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
128
|
-
/**
|
|
129
|
-
* Specify the type of the `Tag`
|
|
130
|
-
*/
|
|
131
|
-
type: PropTypes.Requireable<string>;
|
|
132
|
-
};
|
|
133
|
-
};
|
|
77
|
+
declare const Tag: React.ForwardRefExoticComponent<Omit<TagProps<React.ElementType<any>>, "ref"> & React.RefAttributes<HTMLElement | undefined>>;
|
|
134
78
|
export declare const types: string[];
|
|
135
79
|
export default Tag;
|
|
@@ -20,6 +20,8 @@ require('../Text/index.js');
|
|
|
20
20
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
21
21
|
var DefinitionTooltip = require('../Tooltip/DefinitionTooltip.js');
|
|
22
22
|
require('../Tooltip/Tooltip.js');
|
|
23
|
+
var isEllipsisActive = require('./isEllipsisActive.js');
|
|
24
|
+
var react = require('@floating-ui/react');
|
|
23
25
|
var Text = require('../Text/Text.js');
|
|
24
26
|
|
|
25
27
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -49,7 +51,7 @@ const SIZES = {
|
|
|
49
51
|
md: 'md',
|
|
50
52
|
lg: 'lg'
|
|
51
53
|
};
|
|
52
|
-
const Tag = _ref
|
|
54
|
+
const Tag = /*#__PURE__*/React__default["default"].forwardRef(function Tag(_ref, forwardRef) {
|
|
53
55
|
let {
|
|
54
56
|
children,
|
|
55
57
|
className,
|
|
@@ -69,17 +71,14 @@ const Tag = _ref => {
|
|
|
69
71
|
...other
|
|
70
72
|
} = _ref;
|
|
71
73
|
const prefix = usePrefix.usePrefix();
|
|
74
|
+
const tagRef = React.useRef();
|
|
75
|
+
const ref = react.useMergeRefs([forwardRef, tagRef]);
|
|
72
76
|
const tagId = id || `tag-${getInstanceId()}`;
|
|
73
77
|
const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
|
|
74
|
-
const isEllipsisActive = element => {
|
|
75
|
-
setIsEllipsisApplied(element.offsetWidth < element.scrollWidth);
|
|
76
|
-
return element.offsetWidth < element.scrollWidth;
|
|
77
|
-
};
|
|
78
78
|
React.useLayoutEffect(() => {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}, [prefix, tagId]);
|
|
79
|
+
const newElement = tagRef.current?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
80
|
+
setIsEllipsisApplied(isEllipsisActive.isEllipsisActive(newElement));
|
|
81
|
+
}, [prefix, tagRef]);
|
|
83
82
|
const conditions = [`${prefix}--tag--selectable`, `${prefix}--tag--filter`, `${prefix}--tag--operational`];
|
|
84
83
|
const isInteractiveTag = conditions.some(el => className?.includes(el));
|
|
85
84
|
const tagClasses = cx__default["default"](`${prefix}--tag`, className, {
|
|
@@ -132,6 +131,7 @@ const Tag = _ref => {
|
|
|
132
131
|
[`${prefix}--tag--${type}`]: type && !isInteractiveTag
|
|
133
132
|
});
|
|
134
133
|
return /*#__PURE__*/React__default["default"].createElement(ComponentTag, _rollupPluginBabelHelpers["extends"]({
|
|
134
|
+
ref: ref,
|
|
135
135
|
disabled: disabled,
|
|
136
136
|
className: tagClasses,
|
|
137
137
|
id: tagId
|
|
@@ -148,7 +148,7 @@ const Tag = _ref => {
|
|
|
148
148
|
title: children !== null && children !== undefined ? children : typeText,
|
|
149
149
|
className: labelClasses
|
|
150
150
|
}, children !== null && children !== undefined ? children : typeText), normalizedSlug);
|
|
151
|
-
};
|
|
151
|
+
});
|
|
152
152
|
Tag.propTypes = {
|
|
153
153
|
/**
|
|
154
154
|
* Provide an alternative tag or component to use instead of the default
|
|
@@ -170,7 +170,7 @@ Tag.propTypes = {
|
|
|
170
170
|
/**
|
|
171
171
|
* Determine if `Tag` is a filter/chip
|
|
172
172
|
*/
|
|
173
|
-
filter: deprecate["default"](PropTypes__default["default"].bool, '
|
|
173
|
+
filter: deprecate["default"](PropTypes__default["default"].bool, 'The `filter` prop has been deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
|
|
174
174
|
/**
|
|
175
175
|
* Specify the id for the tag.
|
|
176
176
|
*/
|
|
@@ -178,7 +178,7 @@ Tag.propTypes = {
|
|
|
178
178
|
/**
|
|
179
179
|
* Click handler for filter tag close button.
|
|
180
180
|
*/
|
|
181
|
-
onClose: deprecate["default"](PropTypes__default["default"].func, '
|
|
181
|
+
onClose: deprecate["default"](PropTypes__default["default"].func, 'The `onClose` prop has been deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
|
|
182
182
|
/**
|
|
183
183
|
* Optional prop to render a custom icon.
|
|
184
184
|
* Can be a React component class
|
|
@@ -196,7 +196,7 @@ Tag.propTypes = {
|
|
|
196
196
|
/**
|
|
197
197
|
* Text to show on clear filters
|
|
198
198
|
*/
|
|
199
|
-
title: deprecate["default"](PropTypes__default["default"].string, '
|
|
199
|
+
title: deprecate["default"](PropTypes__default["default"].string, 'The `title` prop has been deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
|
|
200
200
|
/**
|
|
201
201
|
* Specify the type of the `Tag`
|
|
202
202
|
*/
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
const isEllipsisActive = element => {
|
|
13
|
+
if (element) {
|
|
14
|
+
return element?.offsetWidth < element?.scrollWidth;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.isEllipsisActive = isEllipsisActive;
|
|
@@ -18,6 +18,7 @@ var useDelayedState = require('../../internal/useDelayedState.js');
|
|
|
18
18
|
var useId = require('../../internal/useId.js');
|
|
19
19
|
var useNoInteractiveChildren = require('../../internal/useNoInteractiveChildren.js');
|
|
20
20
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
21
|
+
var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
|
|
21
22
|
var match = require('../../internal/keyboard/match.js');
|
|
22
23
|
var keys = require('../../internal/keyboard/keys.js');
|
|
23
24
|
|
|
@@ -84,7 +85,7 @@ function Tooltip(_ref) {
|
|
|
84
85
|
} else {
|
|
85
86
|
triggerProps['aria-describedby'] = id;
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
+
const onKeyDown = React.useCallback(event => {
|
|
88
89
|
if (open && match.match(event, keys.Escape)) {
|
|
89
90
|
event.stopPropagation();
|
|
90
91
|
setOpen(false);
|
|
@@ -92,10 +93,24 @@ function Tooltip(_ref) {
|
|
|
92
93
|
if (open && closeOnActivation && (match.match(event, keys.Enter) || match.match(event, keys.Space))) {
|
|
93
94
|
setOpen(false);
|
|
94
95
|
}
|
|
95
|
-
}
|
|
96
|
+
}, [closeOnActivation, open, setOpen]);
|
|
97
|
+
useIsomorphicEffect["default"](() => {
|
|
98
|
+
if (!open) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
function handleKeyDown(event) {
|
|
102
|
+
if (match.match(event, keys.Escape)) {
|
|
103
|
+
onKeyDown(event);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
107
|
+
return () => {
|
|
108
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
109
|
+
};
|
|
110
|
+
}, [open, onKeyDown]);
|
|
96
111
|
function onMouseEnter() {
|
|
97
112
|
// Interactive Tags should not support onMouseEnter
|
|
98
|
-
if (!rest?.onMouseEnter
|
|
113
|
+
if (!rest?.onMouseEnter) {
|
|
99
114
|
setIsPointerIntersecting(true);
|
|
100
115
|
setOpen(true, enterDelayMs);
|
|
101
116
|
}
|
|
@@ -143,25 +158,30 @@ function Tooltip(_ref) {
|
|
|
143
158
|
});
|
|
144
159
|
};
|
|
145
160
|
}, [isDragging, onDragStop]);
|
|
146
|
-
return
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
return (
|
|
162
|
+
/*#__PURE__*/
|
|
163
|
+
// @ts-ignore-error Popover throws a TS error everytime is imported
|
|
164
|
+
React__default["default"].createElement(index.Popover, _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
165
|
+
align: align,
|
|
166
|
+
className: cx__default["default"](`${prefix}--tooltip`, customClassName),
|
|
167
|
+
dropShadow: false,
|
|
168
|
+
highContrast: true,
|
|
169
|
+
onKeyDown: onKeyDown,
|
|
170
|
+
onMouseLeave: onMouseLeave,
|
|
171
|
+
open: open
|
|
172
|
+
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
173
|
+
className: `${prefix}--tooltip-trigger__wrapper`
|
|
174
|
+
}, child !== undefined ? /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
175
|
+
...triggerProps,
|
|
176
|
+
...getChildEventHandlers(child.props)
|
|
177
|
+
}) : null), /*#__PURE__*/React__default["default"].createElement(index.PopoverContent, {
|
|
178
|
+
"aria-hidden": open ? 'false' : 'true',
|
|
179
|
+
className: `${prefix}--tooltip-content`,
|
|
180
|
+
id: id,
|
|
181
|
+
onMouseEnter: onMouseEnter,
|
|
182
|
+
role: "tooltip"
|
|
183
|
+
}, label || description))
|
|
184
|
+
);
|
|
165
185
|
}
|
|
166
186
|
Tooltip.propTypes = {
|
|
167
187
|
/**
|
|
@@ -29,7 +29,7 @@ declare const Content: {
|
|
|
29
29
|
suppressHydrationWarning?: boolean | undefined;
|
|
30
30
|
accessKey?: string | undefined;
|
|
31
31
|
autoFocus?: boolean | undefined;
|
|
32
|
-
contentEditable?:
|
|
32
|
+
contentEditable?: (boolean | "true" | "false") | "inherit" | undefined;
|
|
33
33
|
contextMenu?: string | undefined;
|
|
34
34
|
dir?: string | undefined;
|
|
35
35
|
draggable?: (boolean | "true" | "false") | undefined;
|
|
@@ -43,7 +43,7 @@ declare const Content: {
|
|
|
43
43
|
style?: React.CSSProperties | undefined;
|
|
44
44
|
tabIndex?: number | undefined;
|
|
45
45
|
title?: string | undefined;
|
|
46
|
-
translate?: "
|
|
46
|
+
translate?: "yes" | "no" | undefined;
|
|
47
47
|
radioGroup?: string | undefined;
|
|
48
48
|
role?: React.AriaRole | undefined;
|
|
49
49
|
about?: string | undefined;
|
|
@@ -93,7 +93,7 @@ declare const Content: {
|
|
|
93
93
|
"aria-expanded"?: (boolean | "true" | "false") | undefined;
|
|
94
94
|
"aria-flowto"?: string | undefined;
|
|
95
95
|
"aria-grabbed"?: (boolean | "true" | "false") | undefined;
|
|
96
|
-
"aria-haspopup"?: boolean | "dialog" | "menu" | "
|
|
96
|
+
"aria-haspopup"?: boolean | "dialog" | "menu" | "true" | "false" | "grid" | "listbox" | "tree" | undefined;
|
|
97
97
|
"aria-hidden"?: (boolean | "true" | "false") | undefined;
|
|
98
98
|
"aria-invalid"?: boolean | "true" | "false" | "grammar" | "spelling" | undefined;
|
|
99
99
|
"aria-keyshortcuts"?: string | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { HTMLAttributeAnchorTarget } from 'react';
|
|
2
2
|
interface BaseSwitcherItemProps {
|
|
3
3
|
/**
|
|
4
4
|
* Specify the text content for the link
|
|
@@ -43,6 +43,10 @@ interface BaseSwitcherItemProps {
|
|
|
43
43
|
* Optionally provide an href for the underlying li`
|
|
44
44
|
*/
|
|
45
45
|
href?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Specify where to open the link.
|
|
48
|
+
*/
|
|
49
|
+
target?: HTMLAttributeAnchorTarget;
|
|
46
50
|
}
|
|
47
51
|
interface SwitcherItemWithAriaLabel extends BaseSwitcherItemProps {
|
|
48
52
|
'aria-label': string;
|
|
@@ -38,6 +38,7 @@ const SwitcherItem = /*#__PURE__*/React.forwardRef(function SwitcherItem(props,
|
|
|
38
38
|
handleSwitcherItemFocus,
|
|
39
39
|
onKeyDown = () => {},
|
|
40
40
|
href,
|
|
41
|
+
target,
|
|
41
42
|
...rest
|
|
42
43
|
} = props;
|
|
43
44
|
const prefix = usePrefix.usePrefix();
|
|
@@ -75,6 +76,7 @@ const SwitcherItem = /*#__PURE__*/React.forwardRef(function SwitcherItem(props,
|
|
|
75
76
|
onKeyDown(evt);
|
|
76
77
|
},
|
|
77
78
|
href: href,
|
|
79
|
+
target: target,
|
|
78
80
|
ref: forwardRef
|
|
79
81
|
}, rest, {
|
|
80
82
|
className: linkClassName,
|
|
@@ -115,7 +117,11 @@ SwitcherItem.propTypes = {
|
|
|
115
117
|
/**
|
|
116
118
|
* Specify the tab index of the Link
|
|
117
119
|
*/
|
|
118
|
-
tabIndex: PropTypes__default["default"].number
|
|
120
|
+
tabIndex: PropTypes__default["default"].number,
|
|
121
|
+
/**
|
|
122
|
+
* Specify where to open the link.
|
|
123
|
+
*/
|
|
124
|
+
target: PropTypes__default["default"].string
|
|
119
125
|
};
|
|
120
126
|
|
|
121
127
|
exports["default"] = SwitcherItem;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.59.0-rc.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@carbon/feature-flags": "^0.20.0",
|
|
52
52
|
"@carbon/icons-react": "^11.42.0",
|
|
53
53
|
"@carbon/layout": "^11.22.0",
|
|
54
|
-
"@carbon/styles": "^1.
|
|
54
|
+
"@carbon/styles": "^1.59.0-rc.0",
|
|
55
55
|
"@floating-ui/react": "^0.26.0",
|
|
56
56
|
"@ibm/telemetry-js": "^1.5.0",
|
|
57
57
|
"classnames": "2.5.1",
|
|
@@ -141,5 +141,5 @@
|
|
|
141
141
|
"**/*.scss",
|
|
142
142
|
"**/*.css"
|
|
143
143
|
],
|
|
144
|
-
"gitHead": "
|
|
144
|
+
"gitHead": "6269fa19f0ce2930b21a2fda05974a597126ec6b"
|
|
145
145
|
}
|