@carbon/react 1.58.0-rc.0 → 1.58.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 +1114 -957
- package/es/components/Accordion/Accordion.d.ts +1 -1
- package/es/components/Accordion/index.d.ts +2 -2
- package/es/components/Button/index.d.ts +2 -1
- package/es/components/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/Dropdown/index.d.ts +2 -2
- package/es/components/FormLabel/index.d.ts +2 -2
- package/es/components/Grid/Column.d.ts +2 -2
- package/es/components/Grid/GridTypes.d.ts +1 -2
- package/es/components/Grid/index.d.ts +3 -1
- package/es/components/InlineLoading/index.d.ts +2 -2
- package/es/components/Loading/index.d.ts +2 -2
- package/es/components/Modal/index.d.ts +2 -2
- package/es/components/NumberInput/NumberInput.d.ts +11 -0
- package/es/components/NumberInput/NumberInput.js +2 -2
- package/es/components/NumberInput/index.d.ts +1 -1
- package/es/components/OverflowMenu/OverflowMenu.d.ts +10 -6
- package/es/components/OverflowMenu/index.d.ts +13 -0
- package/es/components/ProgressBar/ProgressBar.d.ts +1 -1
- package/es/components/ProgressBar/index.d.ts +2 -2
- package/es/components/ProgressIndicator/ProgressIndicator.d.ts +2 -2
- package/es/components/ProgressIndicator/index.d.ts +2 -0
- package/es/components/StructuredList/index.d.ts +2 -0
- package/es/components/Switch/Switch.d.ts +1 -1
- package/es/components/Switch/index.d.ts +2 -2
- package/es/components/Tab/index.d.ts +2 -1
- package/es/components/Tag/DismissibleTag.d.ts +9 -9
- package/es/components/Tag/DismissibleTag.js +34 -9
- package/es/components/Tag/OperationalTag.d.ts +9 -9
- package/es/components/Tag/OperationalTag.js +45 -9
- package/es/components/Tag/SelectableTag.d.ts +9 -9
- package/es/components/Tag/SelectableTag.js +46 -10
- package/es/components/Tag/Tag.js +31 -5
- package/es/components/TextArea/index.d.ts +2 -2
- package/es/components/TextInput/index.d.ts +4 -2
- package/es/components/TileGroup/index.d.ts +2 -2
- package/es/components/Tooltip/Tooltip.js +16 -5
- package/es/components/Tooltip/index.d.ts +2 -2
- package/es/components/UnorderedList/UnorderedList.d.ts +1 -1
- package/es/components/UnorderedList/index.d.ts +1 -0
- package/lib/components/Accordion/Accordion.d.ts +1 -1
- package/lib/components/Accordion/index.d.ts +2 -2
- package/lib/components/Button/index.d.ts +2 -1
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Dropdown/index.d.ts +2 -2
- package/lib/components/FormLabel/index.d.ts +2 -2
- package/lib/components/Grid/Column.d.ts +2 -2
- package/lib/components/Grid/GridTypes.d.ts +1 -2
- package/lib/components/Grid/index.d.ts +3 -1
- package/lib/components/InlineLoading/index.d.ts +2 -2
- package/lib/components/Loading/index.d.ts +2 -2
- package/lib/components/Modal/index.d.ts +2 -2
- package/lib/components/NumberInput/NumberInput.d.ts +11 -0
- package/lib/components/NumberInput/NumberInput.js +2 -2
- package/lib/components/NumberInput/index.d.ts +1 -1
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +10 -6
- package/lib/components/OverflowMenu/index.d.ts +13 -0
- package/lib/components/ProgressBar/ProgressBar.d.ts +1 -1
- package/lib/components/ProgressBar/index.d.ts +2 -2
- package/lib/components/ProgressIndicator/ProgressIndicator.d.ts +2 -2
- package/lib/components/ProgressIndicator/index.d.ts +2 -0
- package/lib/components/StructuredList/index.d.ts +2 -0
- package/lib/components/Switch/Switch.d.ts +1 -1
- package/lib/components/Switch/index.d.ts +2 -2
- package/lib/components/Tab/index.d.ts +2 -1
- package/lib/components/Tag/DismissibleTag.d.ts +9 -9
- package/lib/components/Tag/DismissibleTag.js +33 -8
- package/lib/components/Tag/OperationalTag.d.ts +9 -9
- package/lib/components/Tag/OperationalTag.js +44 -8
- package/lib/components/Tag/SelectableTag.d.ts +9 -9
- package/lib/components/Tag/SelectableTag.js +45 -9
- package/lib/components/Tag/Tag.js +30 -4
- package/lib/components/TextArea/index.d.ts +2 -2
- package/lib/components/TextInput/index.d.ts +4 -2
- package/lib/components/TileGroup/index.d.ts +2 -2
- package/lib/components/Tooltip/Tooltip.js +16 -5
- package/lib/components/Tooltip/index.d.ts +2 -2
- package/lib/components/UnorderedList/UnorderedList.d.ts +1 -1
- package/lib/components/UnorderedList/index.d.ts +1 -0
- package/package.json +5 -5
|
@@ -4,7 +4,7 @@
|
|
|
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 Switch from './Switch';
|
|
7
|
+
import Switch, { type SwitchProps } from './Switch';
|
|
8
8
|
import IconSwitch from './IconSwitch';
|
|
9
9
|
export default Switch;
|
|
10
|
-
export { Switch, IconSwitch };
|
|
10
|
+
export { Switch, IconSwitch, type SwitchProps };
|
|
@@ -9,10 +9,6 @@ import React, { ReactNode } from 'react';
|
|
|
9
9
|
import { PolymorphicProps } from '../../types/common';
|
|
10
10
|
import { SIZES, TYPES } from './Tag';
|
|
11
11
|
export interface DismissibleTagBaseProps {
|
|
12
|
-
/**
|
|
13
|
-
* Provide content to be rendered inside of a `DismissibleTag`
|
|
14
|
-
*/
|
|
15
|
-
children?: React.ReactNode;
|
|
16
12
|
/**
|
|
17
13
|
* Provide a custom className that is applied to the containing <span>
|
|
18
14
|
*/
|
|
@@ -43,6 +39,10 @@ export interface DismissibleTagBaseProps {
|
|
|
43
39
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `DismissibleTag` component
|
|
44
40
|
*/
|
|
45
41
|
slug?: ReactNode;
|
|
42
|
+
/**
|
|
43
|
+
* Provide text to be rendered inside of a the tag.
|
|
44
|
+
*/
|
|
45
|
+
text?: string;
|
|
46
46
|
/**
|
|
47
47
|
* Text to show on clear filters
|
|
48
48
|
*/
|
|
@@ -54,12 +54,8 @@ export interface DismissibleTagBaseProps {
|
|
|
54
54
|
}
|
|
55
55
|
export type DismissibleTagProps<T extends React.ElementType> = PolymorphicProps<T, DismissibleTagBaseProps>;
|
|
56
56
|
declare const DismissibleTag: {
|
|
57
|
-
<T extends React.ElementType<any>>({
|
|
57
|
+
<T extends React.ElementType<any>>({ className, disabled, id, renderIcon, title, onClose, slug, size, text, type, ...other }: DismissibleTagProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
58
58
|
propTypes: {
|
|
59
|
-
/**
|
|
60
|
-
* Provide content to be rendered inside of a `DismissibleTag`
|
|
61
|
-
*/
|
|
62
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
63
59
|
/**
|
|
64
60
|
* Provide a custom className that is applied to the containing <span>
|
|
65
61
|
*/
|
|
@@ -90,6 +86,10 @@ declare const DismissibleTag: {
|
|
|
90
86
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `DismissibleTag` component
|
|
91
87
|
*/
|
|
92
88
|
slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
89
|
+
/**
|
|
90
|
+
* Provide text to be rendered inside of a the tag.
|
|
91
|
+
*/
|
|
92
|
+
text: PropTypes.Requireable<string>;
|
|
93
93
|
/**
|
|
94
94
|
* Text to show on clear filters
|
|
95
95
|
*/
|
|
@@ -17,6 +17,10 @@ var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
|
|
|
17
17
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
18
18
|
var Tag = require('./Tag.js');
|
|
19
19
|
var iconsReact = require('@carbon/icons-react');
|
|
20
|
+
require('../Tooltip/DefinitionTooltip.js');
|
|
21
|
+
var Tooltip = require('../Tooltip/Tooltip.js');
|
|
22
|
+
require('../Text/index.js');
|
|
23
|
+
var Text = require('../Text/Text.js');
|
|
20
24
|
|
|
21
25
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
26
|
|
|
@@ -28,21 +32,31 @@ var _Close;
|
|
|
28
32
|
const getInstanceId = setupGetInstanceId["default"]();
|
|
29
33
|
const DismissibleTag = _ref => {
|
|
30
34
|
let {
|
|
31
|
-
children,
|
|
32
35
|
className,
|
|
33
36
|
disabled,
|
|
34
37
|
id,
|
|
35
38
|
renderIcon,
|
|
36
|
-
title = '
|
|
39
|
+
title = 'Dismiss',
|
|
37
40
|
onClose,
|
|
38
41
|
slug,
|
|
39
42
|
size,
|
|
43
|
+
text,
|
|
40
44
|
type,
|
|
41
45
|
...other
|
|
42
46
|
} = _ref;
|
|
43
47
|
const prefix = usePrefix.usePrefix();
|
|
44
48
|
const tagId = id || `tag-${getInstanceId()}`;
|
|
45
49
|
const tagClasses = cx__default["default"](`${prefix}--tag--filter`, className);
|
|
50
|
+
const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
|
|
51
|
+
const isEllipsisActive = element => {
|
|
52
|
+
setIsEllipsisApplied(element.offsetWidth < element.scrollWidth);
|
|
53
|
+
return element.offsetWidth < element.scrollWidth;
|
|
54
|
+
};
|
|
55
|
+
React.useLayoutEffect(() => {
|
|
56
|
+
const elementTagId = document.querySelector(`#${tagId}`);
|
|
57
|
+
const newElement = elementTagId?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
58
|
+
isEllipsisActive(newElement);
|
|
59
|
+
}, [prefix, tagId]);
|
|
46
60
|
const handleClose = event => {
|
|
47
61
|
if (onClose) {
|
|
48
62
|
event.stopPropagation();
|
|
@@ -56,6 +70,7 @@ const DismissibleTag = _ref => {
|
|
|
56
70
|
kind: 'inline'
|
|
57
71
|
});
|
|
58
72
|
}
|
|
73
|
+
const tooltipClasses = cx__default["default"](`${prefix}--icon-tooltip`, `${prefix}--tag-label-tooltip`);
|
|
59
74
|
|
|
60
75
|
// Removing onClick from the spread operator
|
|
61
76
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -63,6 +78,7 @@ const DismissibleTag = _ref => {
|
|
|
63
78
|
onClick,
|
|
64
79
|
...otherProps
|
|
65
80
|
} = other;
|
|
81
|
+
const dismissLabel = `Dismiss "${text}"`;
|
|
66
82
|
return /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
|
|
67
83
|
type: type,
|
|
68
84
|
size: size,
|
|
@@ -72,20 +88,25 @@ const DismissibleTag = _ref => {
|
|
|
72
88
|
id: tagId
|
|
73
89
|
}, otherProps), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
74
90
|
className: `${prefix}--interactive--tag-children`
|
|
75
|
-
},
|
|
91
|
+
}, /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
92
|
+
title: text,
|
|
93
|
+
className: `${prefix}--tag__label`
|
|
94
|
+
}, text), /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
|
|
95
|
+
label: isEllipsisApplied ? dismissLabel : title,
|
|
96
|
+
align: "bottom",
|
|
97
|
+
className: tooltipClasses,
|
|
98
|
+
leaveDelayMs: 0,
|
|
99
|
+
closeOnActivation: true
|
|
100
|
+
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
76
101
|
type: "button",
|
|
77
102
|
className: `${prefix}--tag__close-icon`,
|
|
78
103
|
onClick: handleClose,
|
|
79
104
|
disabled: disabled,
|
|
80
105
|
"aria-label": title,
|
|
81
106
|
title: title
|
|
82
|
-
}, _Close || (_Close = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null)))));
|
|
107
|
+
}, _Close || (_Close = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null)))), normalizedSlug));
|
|
83
108
|
};
|
|
84
109
|
DismissibleTag.propTypes = {
|
|
85
|
-
/**
|
|
86
|
-
* Provide content to be rendered inside of a `DismissibleTag`
|
|
87
|
-
*/
|
|
88
|
-
children: PropTypes__default["default"].node,
|
|
89
110
|
/**
|
|
90
111
|
* Provide a custom className that is applied to the containing <span>
|
|
91
112
|
*/
|
|
@@ -116,6 +137,10 @@ DismissibleTag.propTypes = {
|
|
|
116
137
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `DismissibleTag` component
|
|
117
138
|
*/
|
|
118
139
|
slug: PropTypes__default["default"].node,
|
|
140
|
+
/**
|
|
141
|
+
* Provide text to be rendered inside of a the tag.
|
|
142
|
+
*/
|
|
143
|
+
text: PropTypes__default["default"].string,
|
|
119
144
|
/**
|
|
120
145
|
* Text to show on clear filters
|
|
121
146
|
*/
|
|
@@ -21,10 +21,6 @@ declare const TYPES: {
|
|
|
21
21
|
'warm-gray': string;
|
|
22
22
|
};
|
|
23
23
|
export interface OperationalTagBaseProps {
|
|
24
|
-
/**
|
|
25
|
-
* Provide content to be rendered inside of a `OperationalTag`
|
|
26
|
-
*/
|
|
27
|
-
children?: React.ReactNode;
|
|
28
24
|
/**
|
|
29
25
|
* Provide a custom className that is applied to the containing <span>
|
|
30
26
|
*/
|
|
@@ -52,6 +48,10 @@ export interface OperationalTagBaseProps {
|
|
|
52
48
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
|
|
53
49
|
*/
|
|
54
50
|
slug?: ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* Provide text to be rendered inside of a the tag.
|
|
53
|
+
*/
|
|
54
|
+
text?: string;
|
|
55
55
|
/**
|
|
56
56
|
* Specify the type of the `Tag`
|
|
57
57
|
*/
|
|
@@ -59,12 +59,8 @@ export interface OperationalTagBaseProps {
|
|
|
59
59
|
}
|
|
60
60
|
export type OperationalTagProps<T extends React.ElementType> = PolymorphicProps<T, OperationalTagBaseProps>;
|
|
61
61
|
declare const OperationalTag: {
|
|
62
|
-
<T extends React.ElementType<any>>({
|
|
62
|
+
<T extends React.ElementType<any>>({ className, disabled, id, renderIcon, slug, size, text, type, ...other }: OperationalTagProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
63
63
|
propTypes: {
|
|
64
|
-
/**
|
|
65
|
-
* Provide content to be rendered inside of a `OperationalTag`
|
|
66
|
-
*/
|
|
67
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
68
64
|
/**
|
|
69
65
|
* Provide a custom className that is applied to the containing <span>
|
|
70
66
|
*/
|
|
@@ -91,6 +87,10 @@ declare const OperationalTag: {
|
|
|
91
87
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
|
|
92
88
|
*/
|
|
93
89
|
slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
90
|
+
/**
|
|
91
|
+
* Provide text to be rendered inside of a the tag.
|
|
92
|
+
*/
|
|
93
|
+
text: PropTypes.Requireable<string>;
|
|
94
94
|
/**
|
|
95
95
|
* Specify the type of the `Tag`
|
|
96
96
|
*/
|
|
@@ -16,6 +16,10 @@ var cx = require('classnames');
|
|
|
16
16
|
var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
|
|
17
17
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
18
18
|
var Tag = require('./Tag.js');
|
|
19
|
+
require('../Tooltip/DefinitionTooltip.js');
|
|
20
|
+
var Tooltip = require('../Tooltip/Tooltip.js');
|
|
21
|
+
require('../Text/index.js');
|
|
22
|
+
var Text = require('../Text/Text.js');
|
|
19
23
|
|
|
20
24
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
25
|
|
|
@@ -38,19 +42,29 @@ const TYPES = {
|
|
|
38
42
|
};
|
|
39
43
|
const OperationalTag = _ref => {
|
|
40
44
|
let {
|
|
41
|
-
children,
|
|
42
45
|
className,
|
|
43
46
|
disabled,
|
|
44
47
|
id,
|
|
45
48
|
renderIcon,
|
|
46
49
|
slug,
|
|
47
50
|
size,
|
|
51
|
+
text,
|
|
48
52
|
type = 'gray',
|
|
49
53
|
...other
|
|
50
54
|
} = _ref;
|
|
51
55
|
const prefix = usePrefix.usePrefix();
|
|
52
56
|
const tagId = id || `tag-${getInstanceId()}`;
|
|
53
57
|
const tagClasses = cx__default["default"](`${prefix}--tag--operational`, className);
|
|
58
|
+
const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
|
|
59
|
+
const isEllipsisActive = element => {
|
|
60
|
+
setIsEllipsisApplied(element.offsetWidth < element.scrollWidth);
|
|
61
|
+
return element.offsetWidth < element.scrollWidth;
|
|
62
|
+
};
|
|
63
|
+
React.useLayoutEffect(() => {
|
|
64
|
+
const elementTagId = document.querySelector(`#${tagId}`);
|
|
65
|
+
const newElement = elementTagId?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
66
|
+
isEllipsisActive(newElement);
|
|
67
|
+
}, [prefix, tagId]);
|
|
54
68
|
let normalizedSlug;
|
|
55
69
|
if (slug && slug['type']?.displayName === 'Slug') {
|
|
56
70
|
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
@@ -58,6 +72,27 @@ const OperationalTag = _ref => {
|
|
|
58
72
|
kind: 'inline'
|
|
59
73
|
});
|
|
60
74
|
}
|
|
75
|
+
const tooltipClasses = cx__default["default"](`${prefix}--icon-tooltip`, `${prefix}--tag-label-tooltip`);
|
|
76
|
+
if (isEllipsisApplied) {
|
|
77
|
+
return /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
|
|
78
|
+
label: text,
|
|
79
|
+
align: "bottom",
|
|
80
|
+
className: tooltipClasses,
|
|
81
|
+
leaveDelayMs: 0,
|
|
82
|
+
onMouseEnter: false,
|
|
83
|
+
closeOnActivation: true
|
|
84
|
+
}, /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
|
|
85
|
+
type: type,
|
|
86
|
+
size: size,
|
|
87
|
+
renderIcon: renderIcon,
|
|
88
|
+
disabled: disabled,
|
|
89
|
+
className: tagClasses,
|
|
90
|
+
id: tagId
|
|
91
|
+
}, other), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
92
|
+
title: text,
|
|
93
|
+
className: `${prefix}--tag__label`
|
|
94
|
+
}, text), normalizedSlug));
|
|
95
|
+
}
|
|
61
96
|
return /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
|
|
62
97
|
type: type,
|
|
63
98
|
size: size,
|
|
@@ -65,15 +100,12 @@ const OperationalTag = _ref => {
|
|
|
65
100
|
disabled: disabled,
|
|
66
101
|
className: tagClasses,
|
|
67
102
|
id: tagId
|
|
68
|
-
}, other), /*#__PURE__*/React__default["default"].createElement(
|
|
69
|
-
|
|
70
|
-
|
|
103
|
+
}, other), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
104
|
+
title: text,
|
|
105
|
+
className: `${prefix}--tag__label`
|
|
106
|
+
}, text));
|
|
71
107
|
};
|
|
72
108
|
OperationalTag.propTypes = {
|
|
73
|
-
/**
|
|
74
|
-
* Provide content to be rendered inside of a `OperationalTag`
|
|
75
|
-
*/
|
|
76
|
-
children: PropTypes__default["default"].node,
|
|
77
109
|
/**
|
|
78
110
|
* Provide a custom className that is applied to the containing <span>
|
|
79
111
|
*/
|
|
@@ -100,6 +132,10 @@ OperationalTag.propTypes = {
|
|
|
100
132
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
|
|
101
133
|
*/
|
|
102
134
|
slug: PropTypes__default["default"].node,
|
|
135
|
+
/**
|
|
136
|
+
* Provide text to be rendered inside of a the tag.
|
|
137
|
+
*/
|
|
138
|
+
text: PropTypes__default["default"].string,
|
|
103
139
|
/**
|
|
104
140
|
* Specify the type of the `Tag`
|
|
105
141
|
*/
|
|
@@ -9,10 +9,6 @@ import React, { ReactNode } from 'react';
|
|
|
9
9
|
import { PolymorphicProps } from '../../types/common';
|
|
10
10
|
import { SIZES } from './Tag';
|
|
11
11
|
export interface SelectableTagBaseProps {
|
|
12
|
-
/**
|
|
13
|
-
* Provide content to be rendered inside of a `SelectableTag`
|
|
14
|
-
*/
|
|
15
|
-
children?: React.ReactNode;
|
|
16
12
|
/**
|
|
17
13
|
* Provide a custom className that is applied to the containing <span>
|
|
18
14
|
*/
|
|
@@ -43,15 +39,15 @@ export interface SelectableTagBaseProps {
|
|
|
43
39
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `SelectableTag` component
|
|
44
40
|
*/
|
|
45
41
|
slug?: ReactNode;
|
|
42
|
+
/**
|
|
43
|
+
* Provide text to be rendered inside of a the tag.
|
|
44
|
+
*/
|
|
45
|
+
text?: string;
|
|
46
46
|
}
|
|
47
47
|
export type SelectableTagProps<T extends React.ElementType> = PolymorphicProps<T, SelectableTagBaseProps>;
|
|
48
48
|
declare const SelectableTag: {
|
|
49
|
-
<T extends React.ElementType<any>>({
|
|
49
|
+
<T extends React.ElementType<any>>({ className, disabled, id, renderIcon, selected, slug, size, text, ...other }: SelectableTagProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
50
50
|
propTypes: {
|
|
51
|
-
/**
|
|
52
|
-
* Provide content to be rendered inside of a `SelectableTag`
|
|
53
|
-
*/
|
|
54
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
55
51
|
/**
|
|
56
52
|
* Provide a custom className that is applied to the containing <span>
|
|
57
53
|
*/
|
|
@@ -82,6 +78,10 @@ declare const SelectableTag: {
|
|
|
82
78
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `SelectableTag` component
|
|
83
79
|
*/
|
|
84
80
|
slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
81
|
+
/**
|
|
82
|
+
* Provide text to be rendered inside of a the tag.
|
|
83
|
+
*/
|
|
84
|
+
text: PropTypes.Requireable<string>;
|
|
85
85
|
};
|
|
86
86
|
};
|
|
87
87
|
export default SelectableTag;
|
|
@@ -16,6 +16,10 @@ var cx = require('classnames');
|
|
|
16
16
|
var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
|
|
17
17
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
18
18
|
var Tag = require('./Tag.js');
|
|
19
|
+
require('../Tooltip/DefinitionTooltip.js');
|
|
20
|
+
var Tooltip = require('../Tooltip/Tooltip.js');
|
|
21
|
+
require('../Text/index.js');
|
|
22
|
+
var Text = require('../Text/Text.js');
|
|
19
23
|
|
|
20
24
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
25
|
|
|
@@ -26,7 +30,6 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
26
30
|
const getInstanceId = setupGetInstanceId["default"]();
|
|
27
31
|
const SelectableTag = _ref => {
|
|
28
32
|
let {
|
|
29
|
-
children,
|
|
30
33
|
className,
|
|
31
34
|
disabled,
|
|
32
35
|
id,
|
|
@@ -34,6 +37,7 @@ const SelectableTag = _ref => {
|
|
|
34
37
|
selected = false,
|
|
35
38
|
slug,
|
|
36
39
|
size,
|
|
40
|
+
text,
|
|
37
41
|
...other
|
|
38
42
|
} = _ref;
|
|
39
43
|
const prefix = usePrefix.usePrefix();
|
|
@@ -42,6 +46,16 @@ const SelectableTag = _ref => {
|
|
|
42
46
|
const tagClasses = cx__default["default"](`${prefix}--tag--selectable`, className, {
|
|
43
47
|
[`${prefix}--tag--selectable-selected`]: selectedTag
|
|
44
48
|
});
|
|
49
|
+
const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
|
|
50
|
+
const isEllipsisActive = element => {
|
|
51
|
+
setIsEllipsisApplied(element.offsetWidth < element.scrollWidth);
|
|
52
|
+
return element.offsetWidth < element.scrollWidth;
|
|
53
|
+
};
|
|
54
|
+
React.useLayoutEffect(() => {
|
|
55
|
+
const elementTagId = document.querySelector(`#${tagId}`);
|
|
56
|
+
const newElement = elementTagId?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
57
|
+
isEllipsisActive(newElement);
|
|
58
|
+
}, [prefix, tagId]);
|
|
45
59
|
let normalizedSlug;
|
|
46
60
|
if (slug && slug['type']?.displayName === 'Slug') {
|
|
47
61
|
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
@@ -49,6 +63,7 @@ const SelectableTag = _ref => {
|
|
|
49
63
|
kind: 'inline'
|
|
50
64
|
});
|
|
51
65
|
}
|
|
66
|
+
const tooltipClasses = cx__default["default"](`${prefix}--icon-tooltip`, `${prefix}--tag-label-tooltip`);
|
|
52
67
|
|
|
53
68
|
// Removing onClick from the spread operator
|
|
54
69
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -56,6 +71,26 @@ const SelectableTag = _ref => {
|
|
|
56
71
|
onClick,
|
|
57
72
|
...otherProps
|
|
58
73
|
} = other;
|
|
74
|
+
if (isEllipsisApplied) {
|
|
75
|
+
return /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
|
|
76
|
+
label: text,
|
|
77
|
+
align: "bottom",
|
|
78
|
+
className: tooltipClasses,
|
|
79
|
+
leaveDelayMs: 0,
|
|
80
|
+
onMouseEnter: false
|
|
81
|
+
}, /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
|
|
82
|
+
slug: slug,
|
|
83
|
+
size: size,
|
|
84
|
+
renderIcon: renderIcon,
|
|
85
|
+
disabled: disabled,
|
|
86
|
+
className: tagClasses,
|
|
87
|
+
id: tagId,
|
|
88
|
+
onClick: () => setSelectedTag(!selectedTag)
|
|
89
|
+
}, otherProps), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
90
|
+
title: text,
|
|
91
|
+
className: `${prefix}--tag__label`
|
|
92
|
+
}, text), normalizedSlug));
|
|
93
|
+
}
|
|
59
94
|
return /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
|
|
60
95
|
slug: slug,
|
|
61
96
|
size: size,
|
|
@@ -64,15 +99,12 @@ const SelectableTag = _ref => {
|
|
|
64
99
|
className: tagClasses,
|
|
65
100
|
id: tagId,
|
|
66
101
|
onClick: () => setSelectedTag(!selectedTag)
|
|
67
|
-
}, otherProps), /*#__PURE__*/React__default["default"].createElement(
|
|
68
|
-
|
|
69
|
-
|
|
102
|
+
}, otherProps), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
103
|
+
title: text,
|
|
104
|
+
className: `${prefix}--tag__label`
|
|
105
|
+
}, text));
|
|
70
106
|
};
|
|
71
107
|
SelectableTag.propTypes = {
|
|
72
|
-
/**
|
|
73
|
-
* Provide content to be rendered inside of a `SelectableTag`
|
|
74
|
-
*/
|
|
75
|
-
children: PropTypes__default["default"].node,
|
|
76
108
|
/**
|
|
77
109
|
* Provide a custom className that is applied to the containing <span>
|
|
78
110
|
*/
|
|
@@ -102,7 +134,11 @@ SelectableTag.propTypes = {
|
|
|
102
134
|
/**
|
|
103
135
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `SelectableTag` component
|
|
104
136
|
*/
|
|
105
|
-
slug: PropTypes__default["default"].node
|
|
137
|
+
slug: PropTypes__default["default"].node,
|
|
138
|
+
/**
|
|
139
|
+
* Provide text to be rendered inside of a the tag.
|
|
140
|
+
*/
|
|
141
|
+
text: PropTypes__default["default"].string
|
|
106
142
|
};
|
|
107
143
|
|
|
108
144
|
exports["default"] = SelectableTag;
|
|
@@ -18,6 +18,8 @@ var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
|
|
|
18
18
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
19
19
|
require('../Text/index.js');
|
|
20
20
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
21
|
+
var DefinitionTooltip = require('../Tooltip/DefinitionTooltip.js');
|
|
22
|
+
require('../Tooltip/Tooltip.js');
|
|
21
23
|
var Text = require('../Text/Text.js');
|
|
22
24
|
|
|
23
25
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -68,6 +70,16 @@ const Tag = _ref => {
|
|
|
68
70
|
} = _ref;
|
|
69
71
|
const prefix = usePrefix.usePrefix();
|
|
70
72
|
const tagId = id || `tag-${getInstanceId()}`;
|
|
73
|
+
const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
|
|
74
|
+
const isEllipsisActive = element => {
|
|
75
|
+
setIsEllipsisApplied(element.offsetWidth < element.scrollWidth);
|
|
76
|
+
return element.offsetWidth < element.scrollWidth;
|
|
77
|
+
};
|
|
78
|
+
React.useLayoutEffect(() => {
|
|
79
|
+
const elementTagId = document.querySelector(`#${tagId}`);
|
|
80
|
+
const newElement = elementTagId?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
81
|
+
isEllipsisActive(newElement);
|
|
82
|
+
}, [prefix, tagId]);
|
|
71
83
|
const conditions = [`${prefix}--tag--selectable`, `${prefix}--tag--filter`, `${prefix}--tag--operational`];
|
|
72
84
|
const isInteractiveTag = conditions.some(el => className?.includes(el));
|
|
73
85
|
const tagClasses = cx__default["default"](`${prefix}--tag`, className, {
|
|
@@ -77,7 +89,7 @@ const Tag = _ref => {
|
|
|
77
89
|
// TODO: V12 - Remove this class
|
|
78
90
|
[`${prefix}--layout--size-${size}`]: size,
|
|
79
91
|
[`${prefix}--tag--${type}`]: type,
|
|
80
|
-
[`${prefix}--tag--interactive`]: other.onClick && !isInteractiveTag
|
|
92
|
+
[`${prefix}--tag--interactive`]: other.onClick && !isInteractiveTag && isEllipsisApplied
|
|
81
93
|
});
|
|
82
94
|
const typeText = type !== undefined && type in Object.keys(TYPES) ? TYPES[type] : '';
|
|
83
95
|
const handleClose = event => {
|
|
@@ -103,8 +115,8 @@ const Tag = _ref => {
|
|
|
103
115
|
}, other), CustomIconElement && size !== 'sm' ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
104
116
|
className: `${prefix}--tag__custom-icon`
|
|
105
117
|
}, /*#__PURE__*/React__default["default"].createElement(CustomIconElement, null)) : '', /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
106
|
-
|
|
107
|
-
|
|
118
|
+
title: typeof children === 'string' ? children : undefined,
|
|
119
|
+
className: `${prefix}--tag__label`
|
|
108
120
|
}, children !== null && children !== undefined ? children : typeText), normalizedSlug, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
109
121
|
type: "button",
|
|
110
122
|
className: `${prefix}--tag__close-icon`,
|
|
@@ -115,13 +127,27 @@ const Tag = _ref => {
|
|
|
115
127
|
}, _Close || (_Close = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null))));
|
|
116
128
|
}
|
|
117
129
|
const ComponentTag = BaseComponent ?? (other.onClick || className?.includes(`${prefix}--tag--operational`) ? 'button' : 'div');
|
|
130
|
+
const labelClasses = cx__default["default"]({
|
|
131
|
+
[`${prefix}--tag__label`]: !isInteractiveTag,
|
|
132
|
+
[`${prefix}--tag--${type}`]: type && !isInteractiveTag
|
|
133
|
+
});
|
|
118
134
|
return /*#__PURE__*/React__default["default"].createElement(ComponentTag, _rollupPluginBabelHelpers["extends"]({
|
|
119
135
|
disabled: disabled,
|
|
120
136
|
className: tagClasses,
|
|
121
137
|
id: tagId
|
|
122
138
|
}, other), CustomIconElement && size !== 'sm' ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
123
139
|
className: `${prefix}--tag__custom-icon`
|
|
124
|
-
}, /*#__PURE__*/React__default["default"].createElement(CustomIconElement, null)) : '', /*#__PURE__*/React__default["default"].createElement(
|
|
140
|
+
}, /*#__PURE__*/React__default["default"].createElement(CustomIconElement, null)) : '', isEllipsisApplied && !isInteractiveTag ? /*#__PURE__*/React__default["default"].createElement(DefinitionTooltip.DefinitionTooltip, {
|
|
141
|
+
openOnHover: false,
|
|
142
|
+
definition: children !== null && children !== undefined ? children : typeText,
|
|
143
|
+
className: `${prefix}--definition--tooltip--tag`
|
|
144
|
+
}, /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
145
|
+
title: children !== null && children !== undefined ? children : typeText,
|
|
146
|
+
className: labelClasses
|
|
147
|
+
}, children !== null && children !== undefined ? children : typeText)) : /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
148
|
+
title: children !== null && children !== undefined ? children : typeText,
|
|
149
|
+
className: labelClasses
|
|
150
|
+
}, children !== null && children !== undefined ? children : typeText), normalizedSlug);
|
|
125
151
|
};
|
|
126
152
|
Tag.propTypes = {
|
|
127
153
|
/**
|
|
@@ -4,7 +4,7 @@
|
|
|
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 TextArea from './TextArea';
|
|
7
|
+
import TextArea, { type TextAreaProps } from './TextArea';
|
|
8
8
|
export { default as TextAreaSkeleton } from './TextArea.Skeleton';
|
|
9
9
|
export default TextArea;
|
|
10
|
-
export { TextArea };
|
|
10
|
+
export { TextArea, type TextAreaProps };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import TextInput from './TextInput';
|
|
1
|
+
import TextInput, { type TextInputProps } from './TextInput';
|
|
2
|
+
import { type TextInputSkeletonProps } from './TextInput.Skeleton';
|
|
2
3
|
export { default as TextInputSkeleton } from './TextInput.Skeleton';
|
|
3
4
|
export default TextInput;
|
|
4
|
-
export {
|
|
5
|
+
export { type TextInputSkeletonProps };
|
|
6
|
+
export { TextInput, type TextInputProps };
|
|
@@ -4,6 +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 TileGroup from './TileGroup';
|
|
7
|
+
import TileGroup, { type TileGroupProps } from './TileGroup';
|
|
8
8
|
export default TileGroup;
|
|
9
|
-
export { TileGroup };
|
|
9
|
+
export { TileGroup, type TileGroupProps };
|
|
@@ -47,18 +47,22 @@ function Tooltip(_ref) {
|
|
|
47
47
|
const tooltipRef = React.useRef(null);
|
|
48
48
|
const [open, setOpen] = useDelayedState.useDelayedState(defaultOpen);
|
|
49
49
|
const [isDragging, setIsDragging] = React.useState(false);
|
|
50
|
+
const [focusByMouse, setFocusByMouse] = React.useState(false);
|
|
50
51
|
const [isPointerIntersecting, setIsPointerIntersecting] = React.useState(false);
|
|
51
52
|
const id = useId.useId('tooltip');
|
|
52
53
|
const prefix = usePrefix.usePrefix();
|
|
53
54
|
const child = React__default["default"].Children.only(children);
|
|
54
55
|
const triggerProps = {
|
|
55
|
-
onFocus: () => setOpen(true),
|
|
56
|
-
onBlur: () =>
|
|
56
|
+
onFocus: () => !focusByMouse && setOpen(true),
|
|
57
|
+
onBlur: () => {
|
|
58
|
+
setOpen(false);
|
|
59
|
+
setFocusByMouse(false);
|
|
60
|
+
},
|
|
57
61
|
onClick: () => closeOnActivation && setOpen(false),
|
|
58
62
|
// This should be placed on the trigger in case the element is disabled
|
|
59
63
|
onMouseEnter,
|
|
60
64
|
onMouseLeave,
|
|
61
|
-
onMouseDown
|
|
65
|
+
onMouseDown,
|
|
62
66
|
onMouseMove: onMouseMove,
|
|
63
67
|
onTouchStart: onDragStart
|
|
64
68
|
};
|
|
@@ -90,8 +94,15 @@ function Tooltip(_ref) {
|
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
function onMouseEnter() {
|
|
93
|
-
|
|
94
|
-
|
|
97
|
+
// Interactive Tags should not support onMouseEnter
|
|
98
|
+
if (!rest?.onMouseEnter?.()) {
|
|
99
|
+
setIsPointerIntersecting(true);
|
|
100
|
+
setOpen(true, enterDelayMs);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function onMouseDown() {
|
|
104
|
+
setFocusByMouse(true);
|
|
105
|
+
onDragStart();
|
|
95
106
|
}
|
|
96
107
|
function onMouseLeave() {
|
|
97
108
|
setIsPointerIntersecting(false);
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { DefinitionTooltip } from './DefinitionTooltip';
|
|
8
|
-
import { Tooltip } from './Tooltip';
|
|
9
|
-
export { DefinitionTooltip, Tooltip };
|
|
8
|
+
import { Tooltip, type TooltipProps } from './Tooltip';
|
|
9
|
+
export { DefinitionTooltip, Tooltip, type TooltipProps };
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { type ComponentProps } from 'react';
|
|
9
|
-
interface UnorderedListProps extends ComponentProps<'ul'> {
|
|
9
|
+
export interface UnorderedListProps extends ComponentProps<'ul'> {
|
|
10
10
|
nested?: boolean | undefined;
|
|
11
11
|
isExpressive?: boolean | undefined;
|
|
12
12
|
}
|