@carbon/react 1.57.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 +1106 -990
- package/es/components/Accordion/Accordion.d.ts +1 -1
- package/es/components/Accordion/index.d.ts +2 -2
- package/es/components/Button/Button.js +2 -2
- package/es/components/Button/index.d.ts +2 -1
- package/es/components/Checkbox/Checkbox.d.ts +6 -7
- package/es/components/ComboBox/ComboBox.d.ts +4 -5
- package/es/components/ComboBox/ComboBox.js +268 -261
- package/es/components/ComposedModal/ComposedModal.d.ts +1 -2
- package/es/components/DataTable/TableHeader.d.ts +4 -5
- package/es/components/DataTable/TableSlugRow.d.ts +3 -2
- package/es/components/DatePicker/DatePicker.d.ts +4 -5
- package/es/components/Dropdown/Dropdown.d.ts +6 -7
- 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/IconButton/index.d.ts +3 -4
- package/es/components/InlineLoading/index.d.ts +2 -2
- package/es/components/ListBox/next/ListBoxTrigger.js +1 -0
- package/es/components/Loading/index.d.ts +2 -2
- package/es/components/Menu/Menu.js +1 -1
- package/es/components/Menu/MenuItem.js +13 -2
- package/es/components/Modal/Modal.d.ts +8 -9
- package/es/components/Modal/index.d.ts +2 -2
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -2
- package/es/components/MultiSelect/MultiSelect.d.ts +10 -9
- package/es/components/Notification/Notification.d.ts +2 -2
- package/es/components/NumberInput/NumberInput.d.ts +12 -2
- 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/PasswordInput/index.d.ts +3 -0
- package/es/components/Popover/index.d.ts +8 -2
- package/es/components/Popover/index.js +26 -1
- 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/RadioButton/RadioButton.d.ts +3 -4
- package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +7 -8
- package/es/components/Select/Select.d.ts +1 -2
- package/es/components/Slider/Slider.d.ts +5 -5
- package/es/components/Slider/Slider.js +1 -1
- 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 +12 -12
- package/es/components/Tag/DismissibleTag.js +34 -9
- package/es/components/Tag/OperationalTag.d.ts +12 -12
- package/es/components/Tag/OperationalTag.js +45 -9
- package/es/components/Tag/SelectableTag.d.ts +12 -12
- package/es/components/Tag/SelectableTag.js +46 -10
- package/es/components/Tag/Tag.d.ts +3 -3
- package/es/components/Tag/Tag.js +31 -5
- package/es/components/TextArea/TextArea.d.ts +6 -7
- package/es/components/TextArea/index.d.ts +2 -2
- package/es/components/TextInput/PasswordInput.d.ts +5 -6
- package/es/components/TextInput/PasswordInput.js +2 -2
- package/es/components/TextInput/TextInput.d.ts +1 -2
- package/es/components/TextInput/index.d.ts +4 -2
- package/es/components/Theme/index.d.ts +1 -0
- package/es/components/Theme/index.js +8 -2
- package/es/components/Tile/Tile.d.ts +3 -4
- package/es/components/TileGroup/TileGroup.d.ts +3 -2
- package/es/components/TileGroup/index.d.ts +9 -0
- package/es/components/Toggle/Toggle.js +1 -1
- package/es/components/Tooltip/DefinitionTooltip.js +1 -1
- 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/es/index.js +4 -4
- package/es/prop-types/deprecateValuesWithin.js +35 -0
- package/lib/components/Accordion/Accordion.d.ts +1 -1
- package/lib/components/Accordion/index.d.ts +2 -2
- package/lib/components/Button/Button.js +2 -2
- package/lib/components/Button/index.d.ts +2 -1
- package/lib/components/Checkbox/Checkbox.d.ts +6 -7
- package/lib/components/ComboBox/ComboBox.d.ts +4 -5
- package/lib/components/ComboBox/ComboBox.js +267 -261
- package/lib/components/ComposedModal/ComposedModal.d.ts +1 -2
- package/lib/components/DataTable/TableHeader.d.ts +4 -5
- package/lib/components/DataTable/TableSlugRow.d.ts +3 -2
- package/lib/components/DatePicker/DatePicker.d.ts +4 -5
- package/lib/components/Dropdown/Dropdown.d.ts +6 -7
- 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/IconButton/index.d.ts +3 -4
- package/lib/components/InlineLoading/index.d.ts +2 -2
- package/lib/components/ListBox/next/ListBoxTrigger.js +1 -0
- package/lib/components/Loading/index.d.ts +2 -2
- package/lib/components/Menu/Menu.js +1 -1
- package/lib/components/Menu/MenuItem.js +13 -2
- package/lib/components/Modal/Modal.d.ts +8 -9
- package/lib/components/Modal/index.d.ts +2 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -2
- package/lib/components/MultiSelect/MultiSelect.d.ts +10 -9
- package/lib/components/Notification/Notification.d.ts +2 -2
- package/lib/components/NumberInput/NumberInput.d.ts +12 -2
- 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/PasswordInput/index.d.ts +3 -0
- package/lib/components/Popover/index.d.ts +8 -2
- package/lib/components/Popover/index.js +26 -1
- 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/RadioButton/RadioButton.d.ts +3 -4
- package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +7 -8
- package/lib/components/Select/Select.d.ts +1 -2
- package/lib/components/Slider/Slider.d.ts +5 -5
- package/lib/components/Slider/Slider.js +1 -1
- 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 +12 -12
- package/lib/components/Tag/DismissibleTag.js +33 -8
- package/lib/components/Tag/OperationalTag.d.ts +12 -12
- package/lib/components/Tag/OperationalTag.js +44 -8
- package/lib/components/Tag/SelectableTag.d.ts +12 -12
- package/lib/components/Tag/SelectableTag.js +45 -9
- package/lib/components/Tag/Tag.d.ts +3 -3
- package/lib/components/Tag/Tag.js +30 -4
- package/lib/components/TextArea/TextArea.d.ts +6 -7
- package/lib/components/TextArea/index.d.ts +2 -2
- package/lib/components/TextInput/PasswordInput.d.ts +5 -6
- package/lib/components/TextInput/PasswordInput.js +2 -2
- package/lib/components/TextInput/TextInput.d.ts +1 -2
- package/lib/components/TextInput/index.d.ts +4 -2
- package/lib/components/Theme/index.d.ts +1 -0
- package/lib/components/Theme/index.js +8 -1
- package/lib/components/Tile/Tile.d.ts +3 -4
- package/lib/components/TileGroup/TileGroup.d.ts +3 -2
- package/lib/components/TileGroup/index.d.ts +9 -0
- package/lib/components/Toggle/Toggle.js +1 -1
- package/lib/components/Tooltip/DefinitionTooltip.js +1 -1
- 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/lib/index.js +30 -29
- package/lib/prop-types/deprecateValuesWithin.js +39 -0
- package/package.json +6 -6
- package/es/components/TileGroup/index.js +0 -13
- package/lib/components/TileGroup/index.js +0 -18
|
@@ -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;
|
|
@@ -4,8 +4,8 @@
|
|
|
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
|
|
8
|
-
import React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import React, { ReactNode } from 'react';
|
|
9
9
|
import { PolymorphicProps } from '../../types/common';
|
|
10
10
|
export declare const TYPES: {
|
|
11
11
|
red: string;
|
|
@@ -64,7 +64,7 @@ export interface TagBaseProps {
|
|
|
64
64
|
/**
|
|
65
65
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
|
|
66
66
|
*/
|
|
67
|
-
slug?:
|
|
67
|
+
slug?: ReactNode;
|
|
68
68
|
/**
|
|
69
69
|
* @deprecated This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.
|
|
70
70
|
*/
|
|
@@ -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,8 +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 {
|
|
8
|
-
import React from 'react';
|
|
7
|
+
import React, { ReactNode } from 'react';
|
|
9
8
|
export interface TextAreaProps extends React.InputHTMLAttributes<HTMLTextAreaElement> {
|
|
10
9
|
/**
|
|
11
10
|
* Provide a custom className that is applied directly to the underlying
|
|
@@ -31,7 +30,7 @@ export interface TextAreaProps extends React.InputHTMLAttributes<HTMLTextAreaEle
|
|
|
31
30
|
/**
|
|
32
31
|
* Provide text that is used alongside the control label for additional help
|
|
33
32
|
*/
|
|
34
|
-
helperText?:
|
|
33
|
+
helperText?: ReactNode;
|
|
35
34
|
/**
|
|
36
35
|
* Specify whether you want the underlying label to be visually hidden
|
|
37
36
|
*/
|
|
@@ -47,12 +46,12 @@ export interface TextAreaProps extends React.InputHTMLAttributes<HTMLTextAreaEle
|
|
|
47
46
|
/**
|
|
48
47
|
* Provide the text that is displayed when the control is in an invalid state
|
|
49
48
|
*/
|
|
50
|
-
invalidText?:
|
|
49
|
+
invalidText?: ReactNode;
|
|
51
50
|
/**
|
|
52
51
|
* Provide the text that will be read by a screen reader when visiting this
|
|
53
52
|
* control
|
|
54
53
|
*/
|
|
55
|
-
labelText:
|
|
54
|
+
labelText: ReactNode;
|
|
56
55
|
/**
|
|
57
56
|
* @deprecated
|
|
58
57
|
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
@@ -93,7 +92,7 @@ export interface TextAreaProps extends React.InputHTMLAttributes<HTMLTextAreaEle
|
|
|
93
92
|
/**
|
|
94
93
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `TextArea` component
|
|
95
94
|
*/
|
|
96
|
-
slug?:
|
|
95
|
+
slug?: ReactNode;
|
|
97
96
|
/**
|
|
98
97
|
* Provide the current value of the `<textarea>`
|
|
99
98
|
*/
|
|
@@ -105,7 +104,7 @@ export interface TextAreaProps extends React.InputHTMLAttributes<HTMLTextAreaEle
|
|
|
105
104
|
/**
|
|
106
105
|
* Provide the text that is displayed when the control is in warning state
|
|
107
106
|
*/
|
|
108
|
-
warnText?:
|
|
107
|
+
warnText?: ReactNode;
|
|
109
108
|
/**
|
|
110
109
|
* Specify the method used for calculating the counter number
|
|
111
110
|
*/
|
|
@@ -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,5 +1,4 @@
|
|
|
1
|
-
import React, { InputHTMLAttributes } from 'react';
|
|
2
|
-
import { ReactNodeLike } from 'prop-types';
|
|
1
|
+
import React, { InputHTMLAttributes, ReactNode } from 'react';
|
|
3
2
|
type ExcludedAttributes = 'size';
|
|
4
3
|
export interface PasswordInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
|
|
5
4
|
/**
|
|
@@ -21,7 +20,7 @@ export interface PasswordInputProps extends Omit<InputHTMLAttributes<HTMLInputEl
|
|
|
21
20
|
/**
|
|
22
21
|
* Provide text that is used alongside the control label for additional help
|
|
23
22
|
*/
|
|
24
|
-
helperText?:
|
|
23
|
+
helperText?: ReactNode;
|
|
25
24
|
/**
|
|
26
25
|
* Specify whether or not the underlying label is visually hidden
|
|
27
26
|
*/
|
|
@@ -45,11 +44,11 @@ export interface PasswordInputProps extends Omit<InputHTMLAttributes<HTMLInputEl
|
|
|
45
44
|
/**
|
|
46
45
|
* Provide the text that is displayed when the control is in an invalid state
|
|
47
46
|
*/
|
|
48
|
-
invalidText?:
|
|
47
|
+
invalidText?: ReactNode;
|
|
49
48
|
/**
|
|
50
49
|
* Provide the text that will be read by a screen reader when visiting this control
|
|
51
50
|
*/
|
|
52
|
-
labelText:
|
|
51
|
+
labelText: ReactNode;
|
|
53
52
|
/**
|
|
54
53
|
* @deprecated The `light` prop for `PasswordInput` has been deprecated in favor of the new `Layer` component. It will be removed in the next major release.
|
|
55
54
|
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
@@ -119,7 +118,7 @@ export interface PasswordInputProps extends Omit<InputHTMLAttributes<HTMLInputEl
|
|
|
119
118
|
/**
|
|
120
119
|
* Provide the text that is displayed when the control is in warning state
|
|
121
120
|
*/
|
|
122
|
-
warnText?:
|
|
121
|
+
warnText?: ReactNode;
|
|
123
122
|
}
|
|
124
123
|
declare const PasswordInput: React.ForwardRefExoticComponent<PasswordInputProps & React.RefAttributes<unknown>>;
|
|
125
124
|
export default PasswordInput;
|
|
@@ -149,10 +149,10 @@ const PasswordInput = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
149
149
|
align = tooltipPosition;
|
|
150
150
|
}
|
|
151
151
|
if (tooltipAlignment === 'end') {
|
|
152
|
-
align = `${tooltipPosition}-
|
|
152
|
+
align = `${tooltipPosition}-end`;
|
|
153
153
|
}
|
|
154
154
|
if (tooltipAlignment === 'start') {
|
|
155
|
-
align = `${tooltipPosition}-
|
|
155
|
+
align = `${tooltipPosition}-start`;
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
if (tooltipPosition === 'right' || tooltipPosition === 'left') {
|
|
@@ -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 { ReactNodeLike } from 'prop-types';
|
|
8
7
|
import React, { ReactNode } from 'react';
|
|
9
8
|
type ExcludedAttributes = 'defaultValue' | 'id' | 'size' | 'value';
|
|
10
9
|
export interface TextInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
|
|
@@ -89,7 +88,7 @@ export interface TextInputProps extends Omit<React.InputHTMLAttributes<HTMLInput
|
|
|
89
88
|
/**
|
|
90
89
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `TextInput` component
|
|
91
90
|
*/
|
|
92
|
-
slug?:
|
|
91
|
+
slug?: ReactNode;
|
|
93
92
|
/**
|
|
94
93
|
* Specify the type of the `<input>`
|
|
95
94
|
*/
|
|
@@ -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 };
|
|
@@ -15,6 +15,7 @@ var PropTypes = require('prop-types');
|
|
|
15
15
|
var React = require('react');
|
|
16
16
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
17
17
|
var LayerContext = require('../Layer/LayerContext.js');
|
|
18
|
+
var useMatchMedia = require('../../internal/useMatchMedia.js');
|
|
18
19
|
|
|
19
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
21
|
|
|
@@ -72,8 +73,10 @@ function Theme(_ref2) {
|
|
|
72
73
|
[`${prefix}--layer-one`]: true
|
|
73
74
|
});
|
|
74
75
|
const value = React__default["default"].useMemo(() => {
|
|
76
|
+
const isDark = theme && ['g90', 'g100'].includes(theme);
|
|
75
77
|
return {
|
|
76
|
-
theme
|
|
78
|
+
theme,
|
|
79
|
+
isDark
|
|
77
80
|
};
|
|
78
81
|
}, [theme]);
|
|
79
82
|
const BaseComponentAsAny = BaseComponent;
|
|
@@ -112,8 +115,12 @@ Theme.propTypes = {
|
|
|
112
115
|
function useTheme() {
|
|
113
116
|
return React__default["default"].useContext(ThemeContext);
|
|
114
117
|
}
|
|
118
|
+
function usePrefersDarkScheme() {
|
|
119
|
+
return useMatchMedia.useMatchMedia('(prefers-color-scheme: dark)');
|
|
120
|
+
}
|
|
115
121
|
|
|
116
122
|
exports.GlobalTheme = GlobalTheme;
|
|
117
123
|
exports.Theme = Theme;
|
|
118
124
|
exports.ThemeContext = ThemeContext;
|
|
125
|
+
exports.usePrefersDarkScheme = usePrefersDarkScheme;
|
|
119
126
|
exports.useTheme = useTheme;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { type ReactNode, type MouseEvent, type KeyboardEvent, type HTMLAttributes, type ChangeEvent, type ComponentType } from 'react';
|
|
2
|
-
import { ReactNodeLike } from 'prop-types';
|
|
3
2
|
export interface TileProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
3
|
children?: ReactNode;
|
|
5
4
|
className?: string;
|
|
@@ -13,7 +12,7 @@ export interface TileProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
13
12
|
/**
|
|
14
13
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `SelectableTile` component
|
|
15
14
|
*/
|
|
16
|
-
slug?:
|
|
15
|
+
slug?: ReactNode;
|
|
17
16
|
}
|
|
18
17
|
export declare const Tile: React.ForwardRefExoticComponent<TileProps & React.RefAttributes<HTMLDivElement>>;
|
|
19
18
|
export interface ClickableTileProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
@@ -104,7 +103,7 @@ export interface SelectableTileProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
104
103
|
/**
|
|
105
104
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `SelectableTile` component
|
|
106
105
|
*/
|
|
107
|
-
slug?:
|
|
106
|
+
slug?: ReactNode;
|
|
108
107
|
/**
|
|
109
108
|
* Specify the tab index of the wrapper element
|
|
110
109
|
*/
|
|
@@ -149,7 +148,7 @@ export interface ExpandableTileProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
149
148
|
/**
|
|
150
149
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `ExpandableTile` component
|
|
151
150
|
*/
|
|
152
|
-
slug?:
|
|
151
|
+
slug?: ReactNode;
|
|
153
152
|
/**
|
|
154
153
|
* The `tabindex` attribute.
|
|
155
154
|
*/
|
|
@@ -4,14 +4,15 @@
|
|
|
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
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { ReactNode } from 'react';
|
|
8
9
|
import { ReactAttr } from '../../types/common';
|
|
9
10
|
type ExcludedAttributes = 'onChange';
|
|
10
11
|
export interface TileGroupProps extends Omit<ReactAttr<HTMLFieldSetElement>, ExcludedAttributes> {
|
|
11
12
|
/**
|
|
12
13
|
* Provide a collection of <RadioTile> components to render in the group
|
|
13
14
|
*/
|
|
14
|
-
children?:
|
|
15
|
+
children?: ReactNode;
|
|
15
16
|
/**
|
|
16
17
|
* Provide an optional className to be applied to the container node
|
|
17
18
|
*/
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
import TileGroup, { type TileGroupProps } from './TileGroup';
|
|
8
|
+
export default TileGroup;
|
|
9
|
+
export { TileGroup, type TileGroupProps };
|
|
@@ -99,7 +99,7 @@ function Toggle(_ref) {
|
|
|
99
99
|
role: "switch",
|
|
100
100
|
type: "button",
|
|
101
101
|
"aria-checked": checked,
|
|
102
|
-
"aria-labelledby": ariaLabelledby ?? labelId,
|
|
102
|
+
"aria-labelledby": ariaLabelledby ?? (labelText ? labelId : undefined),
|
|
103
103
|
disabled: disabled,
|
|
104
104
|
onClick: handleClick
|
|
105
105
|
})), /*#__PURE__*/React__default["default"].createElement(LabelComponent, {
|
|
@@ -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
|
}
|