@carbon/react 1.52.0 → 1.53.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 +1617 -1393
- package/es/components/Accordion/AccordionItem.js +1 -1
- package/es/components/CodeSnippet/CodeSnippet.js +2 -2
- package/es/components/Copy/Copy.d.ts +74 -0
- package/es/components/Copy/Copy.js +1 -1
- package/es/components/Copy/index.d.ts +9 -0
- package/es/components/CopyButton/CopyButton.d.ts +71 -0
- package/es/components/CopyButton/index.d.ts +9 -0
- package/es/components/Dropdown/Dropdown.Skeleton.d.ts +11 -0
- package/es/components/Dropdown/Dropdown.Skeleton.js +11 -6
- package/es/components/FileUploader/FileUploaderItem.d.ts +1 -1
- package/es/components/FileUploader/FileUploaderItem.js +2 -1
- package/es/components/Notification/Notification.d.ts +2 -2
- package/es/components/Notification/Notification.js +2 -1
- package/es/components/OverflowMenu/OverflowMenu.js +13 -1
- package/es/components/RadioTile/RadioTile.js +16 -3
- package/es/components/Tag/DismissibleTag.d.ts +104 -0
- package/es/components/Tag/OperationalTag.d.ts +101 -0
- package/es/components/Tag/SelectableTag.d.ts +87 -0
- package/es/components/Tag/Tag.d.ts +17 -12
- package/es/components/Tag/Tag.js +25 -17
- package/es/components/Tag/index.d.ts +0 -1
- package/es/components/Toggle/Toggle.js +3 -1
- package/es/components/Toggletip/index.d.ts +5 -3
- package/es/components/Toggletip/index.js +13 -2
- package/es/components/Tooltip/DefinitionTooltip.js +3 -0
- package/es/feature-flags.js +2 -1
- package/es/index.js +3 -3
- package/es/internal/Selection.js +15 -21
- package/lib/components/Accordion/AccordionItem.js +1 -1
- package/lib/components/CodeSnippet/CodeSnippet.js +2 -2
- package/lib/components/Copy/Copy.d.ts +74 -0
- package/lib/components/Copy/Copy.js +1 -1
- package/lib/components/Copy/index.d.ts +9 -0
- package/lib/components/CopyButton/CopyButton.d.ts +71 -0
- package/lib/components/CopyButton/index.d.ts +9 -0
- package/lib/components/Dropdown/Dropdown.Skeleton.d.ts +11 -0
- package/lib/components/Dropdown/Dropdown.Skeleton.js +11 -6
- package/lib/components/FileUploader/FileUploaderItem.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderItem.js +2 -1
- package/lib/components/Notification/Notification.d.ts +2 -2
- package/lib/components/Notification/Notification.js +2 -1
- package/lib/components/OverflowMenu/OverflowMenu.js +13 -1
- package/lib/components/RadioTile/RadioTile.js +15 -2
- package/lib/components/Tag/DismissibleTag.d.ts +104 -0
- package/lib/components/Tag/OperationalTag.d.ts +101 -0
- package/lib/components/Tag/SelectableTag.d.ts +87 -0
- package/lib/components/Tag/Tag.d.ts +17 -12
- package/lib/components/Tag/Tag.js +26 -17
- package/lib/components/Tag/index.d.ts +0 -1
- package/lib/components/Toggle/Toggle.js +3 -1
- package/lib/components/Toggletip/index.d.ts +5 -3
- package/lib/components/Toggletip/index.js +13 -2
- package/lib/components/Tooltip/DefinitionTooltip.js +3 -0
- package/lib/feature-flags.js +2 -1
- package/lib/index.js +4 -5
- package/lib/internal/Selection.js +14 -20
- package/package.json +8 -8
|
@@ -0,0 +1,87 @@
|
|
|
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 PropTypes, { ReactNodeLike } from 'prop-types';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { PolymorphicProps } from '../../types/common';
|
|
10
|
+
import { SIZES } from './Tag';
|
|
11
|
+
export interface SelectableTagBaseProps {
|
|
12
|
+
/**
|
|
13
|
+
* Provide content to be rendered inside of a `SelectableTag`
|
|
14
|
+
*/
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Provide a custom className that is applied to the containing <span>
|
|
18
|
+
*/
|
|
19
|
+
className?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Specify if the `SelectableTag` is disabled
|
|
22
|
+
*/
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Specify the id for the selectabletag.
|
|
26
|
+
*/
|
|
27
|
+
id?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Optional prop to render a custom icon.
|
|
30
|
+
* Can be a React component class
|
|
31
|
+
*/
|
|
32
|
+
renderIcon?: React.ElementType;
|
|
33
|
+
/**
|
|
34
|
+
* Specify the state of the selectable tag.
|
|
35
|
+
*/
|
|
36
|
+
selected?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Specify the size of the Tag. Currently supports either `sm`,
|
|
39
|
+
* `md` (default) or `lg` sizes.
|
|
40
|
+
*/
|
|
41
|
+
size?: keyof typeof SIZES;
|
|
42
|
+
/**
|
|
43
|
+
* **Experimental:** Provide a `Slug` component to be rendered inside the `SelectableTag` component
|
|
44
|
+
*/
|
|
45
|
+
slug?: ReactNodeLike;
|
|
46
|
+
}
|
|
47
|
+
export type SelectableTagProps<T extends React.ElementType> = PolymorphicProps<T, SelectableTagBaseProps>;
|
|
48
|
+
declare const SelectableTag: {
|
|
49
|
+
<T extends React.ElementType<any>>({ children, className, disabled, id, renderIcon, selected, slug, size, ...other }: SelectableTagProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
propTypes: {
|
|
51
|
+
/**
|
|
52
|
+
* Provide content to be rendered inside of a `SelectableTag`
|
|
53
|
+
*/
|
|
54
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
55
|
+
/**
|
|
56
|
+
* Provide a custom className that is applied to the containing <span>
|
|
57
|
+
*/
|
|
58
|
+
className: PropTypes.Requireable<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Specify if the `SelectableTag` is disabled
|
|
61
|
+
*/
|
|
62
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
63
|
+
/**
|
|
64
|
+
* Specify the id for the tag.
|
|
65
|
+
*/
|
|
66
|
+
id: PropTypes.Requireable<string>;
|
|
67
|
+
/**
|
|
68
|
+
* Optional prop to render a custom icon.
|
|
69
|
+
* Can be a React component class
|
|
70
|
+
*/
|
|
71
|
+
renderIcon: PropTypes.Requireable<object>;
|
|
72
|
+
/**
|
|
73
|
+
* Specify the state of the selectable tag.
|
|
74
|
+
*/
|
|
75
|
+
selected: PropTypes.Requireable<boolean>;
|
|
76
|
+
/**
|
|
77
|
+
* Specify the size of the Tag. Currently supports either `sm`,
|
|
78
|
+
* `md` (default) or `lg` sizes.
|
|
79
|
+
*/
|
|
80
|
+
size: PropTypes.Requireable<string>;
|
|
81
|
+
/**
|
|
82
|
+
* **Experimental:** Provide a `Slug` component to be rendered inside the `SelectableTag` component
|
|
83
|
+
*/
|
|
84
|
+
slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
export default SelectableTag;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import PropTypes, { ReactNodeLike } from 'prop-types';
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { PolymorphicProps } from '../../types/common';
|
|
10
|
-
declare const TYPES: {
|
|
10
|
+
export declare const TYPES: {
|
|
11
11
|
red: string;
|
|
12
12
|
magenta: string;
|
|
13
13
|
purple: string;
|
|
@@ -21,6 +21,11 @@ declare const TYPES: {
|
|
|
21
21
|
'high-contrast': string;
|
|
22
22
|
outline: string;
|
|
23
23
|
};
|
|
24
|
+
export declare const SIZES: {
|
|
25
|
+
sm: string;
|
|
26
|
+
md: string;
|
|
27
|
+
lg: string;
|
|
28
|
+
};
|
|
24
29
|
export interface TagBaseProps {
|
|
25
30
|
/**
|
|
26
31
|
* Provide content to be rendered inside of a `Tag`
|
|
@@ -35,7 +40,7 @@ export interface TagBaseProps {
|
|
|
35
40
|
*/
|
|
36
41
|
disabled?: boolean;
|
|
37
42
|
/**
|
|
38
|
-
*
|
|
43
|
+
* @deprecated This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.
|
|
39
44
|
*/
|
|
40
45
|
filter?: boolean;
|
|
41
46
|
/**
|
|
@@ -43,7 +48,7 @@ export interface TagBaseProps {
|
|
|
43
48
|
*/
|
|
44
49
|
id?: string;
|
|
45
50
|
/**
|
|
46
|
-
*
|
|
51
|
+
* @deprecated This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.
|
|
47
52
|
*/
|
|
48
53
|
onClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
49
54
|
/**
|
|
@@ -52,16 +57,16 @@ export interface TagBaseProps {
|
|
|
52
57
|
*/
|
|
53
58
|
renderIcon?: React.ElementType;
|
|
54
59
|
/**
|
|
55
|
-
* Specify the size of the Tag. Currently supports either `sm
|
|
56
|
-
*
|
|
60
|
+
* Specify the size of the Tag. Currently supports either `sm`,
|
|
61
|
+
* `md` (default) or `lg` sizes.
|
|
57
62
|
*/
|
|
58
|
-
size?:
|
|
63
|
+
size?: keyof typeof SIZES;
|
|
59
64
|
/**
|
|
60
65
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
|
|
61
66
|
*/
|
|
62
67
|
slug?: ReactNodeLike;
|
|
63
68
|
/**
|
|
64
|
-
*
|
|
69
|
+
* @deprecated This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.
|
|
65
70
|
*/
|
|
66
71
|
title?: string;
|
|
67
72
|
/**
|
|
@@ -93,7 +98,7 @@ declare const Tag: {
|
|
|
93
98
|
/**
|
|
94
99
|
* Determine if `Tag` is a filter/chip
|
|
95
100
|
*/
|
|
96
|
-
filter:
|
|
101
|
+
filter: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
97
102
|
/**
|
|
98
103
|
* Specify the id for the tag.
|
|
99
104
|
*/
|
|
@@ -101,15 +106,15 @@ declare const Tag: {
|
|
|
101
106
|
/**
|
|
102
107
|
* Click handler for filter tag close button.
|
|
103
108
|
*/
|
|
104
|
-
onClose:
|
|
109
|
+
onClose: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
105
110
|
/**
|
|
106
111
|
* Optional prop to render a custom icon.
|
|
107
112
|
* Can be a React component class
|
|
108
113
|
*/
|
|
109
114
|
renderIcon: PropTypes.Requireable<object>;
|
|
110
115
|
/**
|
|
111
|
-
* Specify the size of the Tag. Currently supports either `sm
|
|
112
|
-
*
|
|
116
|
+
* Specify the size of the Tag. Currently supports either `sm`,
|
|
117
|
+
* `md` (default) or `lg` sizes.
|
|
113
118
|
*/
|
|
114
119
|
size: PropTypes.Requireable<string>;
|
|
115
120
|
/**
|
|
@@ -119,7 +124,7 @@ declare const Tag: {
|
|
|
119
124
|
/**
|
|
120
125
|
* Text to show on clear filters
|
|
121
126
|
*/
|
|
122
|
-
title:
|
|
127
|
+
title: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
123
128
|
/**
|
|
124
129
|
* Specify the type of the `Tag`
|
|
125
130
|
*/
|
package/es/components/Tag/Tag.js
CHANGED
|
@@ -13,6 +13,7 @@ import { Close } from '@carbon/icons-react';
|
|
|
13
13
|
import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
15
|
import '../Text/index.js';
|
|
16
|
+
import deprecate from '../../prop-types/deprecate.js';
|
|
16
17
|
import { Text } from '../Text/Text.js';
|
|
17
18
|
|
|
18
19
|
var _Close;
|
|
@@ -31,6 +32,11 @@ const TYPES = {
|
|
|
31
32
|
'high-contrast': 'High-Contrast',
|
|
32
33
|
outline: 'Outline'
|
|
33
34
|
};
|
|
35
|
+
const SIZES = {
|
|
36
|
+
sm: 'sm',
|
|
37
|
+
md: 'md',
|
|
38
|
+
lg: 'lg'
|
|
39
|
+
};
|
|
34
40
|
const Tag = _ref => {
|
|
35
41
|
let {
|
|
36
42
|
children,
|
|
@@ -38,10 +44,13 @@ const Tag = _ref => {
|
|
|
38
44
|
id,
|
|
39
45
|
type,
|
|
40
46
|
filter,
|
|
47
|
+
// remove filter in next major release - V12
|
|
41
48
|
renderIcon: CustomIconElement,
|
|
42
49
|
title = 'Clear filter',
|
|
50
|
+
// remove title in next major release - V12
|
|
43
51
|
disabled,
|
|
44
52
|
onClose,
|
|
53
|
+
// remove onClose in next major release - V12
|
|
45
54
|
size,
|
|
46
55
|
as: BaseComponent,
|
|
47
56
|
slug,
|
|
@@ -49,6 +58,8 @@ const Tag = _ref => {
|
|
|
49
58
|
} = _ref;
|
|
50
59
|
const prefix = usePrefix();
|
|
51
60
|
const tagId = id || `tag-${getInstanceId()}`;
|
|
61
|
+
const conditions = [`${prefix}--tag--selectable`, `${prefix}--tag--filter`, `${prefix}--tag--operational`];
|
|
62
|
+
const isInteractiveTag = conditions.some(el => className?.includes(el));
|
|
52
63
|
const tagClasses = cx(`${prefix}--tag`, className, {
|
|
53
64
|
[`${prefix}--tag--disabled`]: disabled,
|
|
54
65
|
[`${prefix}--tag--filter`]: filter,
|
|
@@ -56,7 +67,7 @@ const Tag = _ref => {
|
|
|
56
67
|
// TODO: V12 - Remove this class
|
|
57
68
|
[`${prefix}--layout--size-${size}`]: size,
|
|
58
69
|
[`${prefix}--tag--${type}`]: type,
|
|
59
|
-
[`${prefix}--tag--interactive`]: other.onClick && !
|
|
70
|
+
[`${prefix}--tag--interactive`]: other.onClick && !isInteractiveTag
|
|
60
71
|
});
|
|
61
72
|
const typeText = type !== undefined && type in Object.keys(TYPES) ? TYPES[type] : '';
|
|
62
73
|
const handleClose = event => {
|
|
@@ -68,7 +79,7 @@ const Tag = _ref => {
|
|
|
68
79
|
|
|
69
80
|
// Slug is always size `md` and `inline`
|
|
70
81
|
let normalizedSlug;
|
|
71
|
-
if (slug && slug['type']?.displayName === 'Slug') {
|
|
82
|
+
if (slug && slug['type']?.displayName === 'Slug' && !isInteractiveTag) {
|
|
72
83
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
73
84
|
size: 'sm',
|
|
74
85
|
kind: 'inline'
|
|
@@ -79,7 +90,7 @@ const Tag = _ref => {
|
|
|
79
90
|
return /*#__PURE__*/React__default.createElement(ComponentTag, _extends({
|
|
80
91
|
className: tagClasses,
|
|
81
92
|
id: tagId
|
|
82
|
-
}, other), CustomIconElement ? /*#__PURE__*/React__default.createElement("div", {
|
|
93
|
+
}, other), CustomIconElement && size !== 'sm' ? /*#__PURE__*/React__default.createElement("div", {
|
|
83
94
|
className: `${prefix}--tag__custom-icon`
|
|
84
95
|
}, /*#__PURE__*/React__default.createElement(CustomIconElement, null)) : '', /*#__PURE__*/React__default.createElement(Text, {
|
|
85
96
|
className: `${prefix}--tag__label`,
|
|
@@ -93,16 +104,14 @@ const Tag = _ref => {
|
|
|
93
104
|
title: title
|
|
94
105
|
}, _Close || (_Close = /*#__PURE__*/React__default.createElement(Close, null))));
|
|
95
106
|
}
|
|
96
|
-
const ComponentTag = BaseComponent ?? (other.onClick ? 'button' : 'div');
|
|
107
|
+
const ComponentTag = BaseComponent ?? (other.onClick || className?.includes(`${prefix}--tag--operational`) ? 'button' : 'div');
|
|
97
108
|
return /*#__PURE__*/React__default.createElement(ComponentTag, _extends({
|
|
98
|
-
disabled:
|
|
109
|
+
disabled: disabled,
|
|
99
110
|
className: tagClasses,
|
|
100
111
|
id: tagId
|
|
101
|
-
}, other), CustomIconElement ? /*#__PURE__*/React__default.createElement("div", {
|
|
112
|
+
}, other), CustomIconElement && size !== 'sm' ? /*#__PURE__*/React__default.createElement("div", {
|
|
102
113
|
className: `${prefix}--tag__custom-icon`
|
|
103
|
-
}, /*#__PURE__*/React__default.createElement(CustomIconElement, null)) : '', /*#__PURE__*/React__default.createElement(Text,
|
|
104
|
-
title: typeof children === 'string' ? children : undefined
|
|
105
|
-
}, children !== null && children !== undefined ? children : typeText), normalizedSlug);
|
|
114
|
+
}, /*#__PURE__*/React__default.createElement(CustomIconElement, null)) : '', /*#__PURE__*/React__default.createElement(Text, null, children !== null && children !== undefined ? children : typeText), normalizedSlug);
|
|
106
115
|
};
|
|
107
116
|
Tag.propTypes = {
|
|
108
117
|
/**
|
|
@@ -125,7 +134,7 @@ Tag.propTypes = {
|
|
|
125
134
|
/**
|
|
126
135
|
* Determine if `Tag` is a filter/chip
|
|
127
136
|
*/
|
|
128
|
-
filter: PropTypes.bool,
|
|
137
|
+
filter: deprecate(PropTypes.bool, 'This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
|
|
129
138
|
/**
|
|
130
139
|
* Specify the id for the tag.
|
|
131
140
|
*/
|
|
@@ -133,17 +142,17 @@ Tag.propTypes = {
|
|
|
133
142
|
/**
|
|
134
143
|
* Click handler for filter tag close button.
|
|
135
144
|
*/
|
|
136
|
-
onClose: PropTypes.func,
|
|
145
|
+
onClose: deprecate(PropTypes.func, 'This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
|
|
137
146
|
/**
|
|
138
147
|
* Optional prop to render a custom icon.
|
|
139
148
|
* Can be a React component class
|
|
140
149
|
*/
|
|
141
150
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
142
151
|
/**
|
|
143
|
-
* Specify the size of the Tag. Currently supports either `sm
|
|
144
|
-
*
|
|
152
|
+
* Specify the size of the Tag. Currently supports either `sm`,
|
|
153
|
+
* `md` (default) or `lg` sizes.
|
|
145
154
|
*/
|
|
146
|
-
size: PropTypes.oneOf(
|
|
155
|
+
size: PropTypes.oneOf(Object.keys(SIZES)),
|
|
147
156
|
/**
|
|
148
157
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
|
|
149
158
|
*/
|
|
@@ -151,12 +160,11 @@ Tag.propTypes = {
|
|
|
151
160
|
/**
|
|
152
161
|
* Text to show on clear filters
|
|
153
162
|
*/
|
|
154
|
-
title: PropTypes.string,
|
|
163
|
+
title: deprecate(PropTypes.string, 'This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
|
|
155
164
|
/**
|
|
156
165
|
* Specify the type of the `Tag`
|
|
157
166
|
*/
|
|
158
167
|
type: PropTypes.oneOf(Object.keys(TYPES))
|
|
159
168
|
};
|
|
160
|
-
const types = Object.keys(TYPES);
|
|
161
169
|
|
|
162
|
-
export { Tag as default
|
|
170
|
+
export { SIZES, TYPES, Tag as default };
|
|
@@ -65,6 +65,7 @@ function Toggle(_ref) {
|
|
|
65
65
|
const switchClasses = cx(`${prefix}--toggle__switch`, {
|
|
66
66
|
[`${prefix}--toggle__switch--checked`]: checked
|
|
67
67
|
});
|
|
68
|
+
const labelId = `${id}_label`;
|
|
68
69
|
return (
|
|
69
70
|
/*#__PURE__*/
|
|
70
71
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
@@ -88,10 +89,11 @@ function Toggle(_ref) {
|
|
|
88
89
|
role: "switch",
|
|
89
90
|
type: "button",
|
|
90
91
|
"aria-checked": checked,
|
|
91
|
-
"aria-labelledby":
|
|
92
|
+
"aria-labelledby": ariaLabelledby ?? labelId,
|
|
92
93
|
disabled: disabled,
|
|
93
94
|
onClick: handleClick
|
|
94
95
|
})), /*#__PURE__*/React__default.createElement(LabelComponent, {
|
|
96
|
+
id: labelId,
|
|
95
97
|
htmlFor: ariaLabelledby ? undefined : id,
|
|
96
98
|
className: `${prefix}--toggle__label`
|
|
97
99
|
}, labelText && /*#__PURE__*/React__default.createElement(Text, {
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import { type ElementType, type ReactNode } from 'react';
|
|
8
|
+
import React, { type ElementType, type ReactNode } from 'react';
|
|
9
9
|
import { type PopoverAlignment } from '../Popover';
|
|
10
|
+
import { PolymorphicProps } from '../../types/common';
|
|
10
11
|
type ToggletipLabelProps<E extends ElementType> = {
|
|
11
12
|
as?: E | undefined;
|
|
12
13
|
children?: ReactNode;
|
|
@@ -78,16 +79,17 @@ export declare namespace Toggletip {
|
|
|
78
79
|
defaultOpen: PropTypes.Requireable<boolean>;
|
|
79
80
|
};
|
|
80
81
|
}
|
|
81
|
-
interface
|
|
82
|
+
interface ToggletipButtonBaseProps {
|
|
82
83
|
children?: ReactNode;
|
|
83
84
|
className?: string | undefined;
|
|
84
85
|
label?: string | undefined;
|
|
85
86
|
}
|
|
87
|
+
export type ToggleTipButtonProps<T extends React.ElementType> = PolymorphicProps<T, ToggletipButtonBaseProps>;
|
|
86
88
|
/**
|
|
87
89
|
* `ToggletipButton` controls the visibility of the Toggletip through mouse
|
|
88
90
|
* clicks and keyboard interactions.
|
|
89
91
|
*/
|
|
90
|
-
export declare function ToggletipButton({ children, className: customClassName, label, }:
|
|
92
|
+
export declare function ToggletipButton<T extends React.ElementType>({ children, className: customClassName, label, as: BaseComponent, ...rest }: ToggleTipButtonProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
91
93
|
export declare namespace ToggletipButton {
|
|
92
94
|
var propTypes: {
|
|
93
95
|
/**
|
|
@@ -92,6 +92,9 @@ function Toggletip(_ref2) {
|
|
|
92
92
|
},
|
|
93
93
|
contentProps: {
|
|
94
94
|
id
|
|
95
|
+
},
|
|
96
|
+
onClick: {
|
|
97
|
+
onClick: actions.toggle
|
|
95
98
|
}
|
|
96
99
|
};
|
|
97
100
|
const onKeyDown = event => {
|
|
@@ -179,16 +182,24 @@ function ToggletipButton(_ref3) {
|
|
|
179
182
|
let {
|
|
180
183
|
children,
|
|
181
184
|
className: customClassName,
|
|
182
|
-
label = 'Show information'
|
|
185
|
+
label = 'Show information',
|
|
186
|
+
as: BaseComponent,
|
|
187
|
+
...rest
|
|
183
188
|
} = _ref3;
|
|
184
189
|
const toggletip = useToggletip();
|
|
185
190
|
const prefix = usePrefix();
|
|
186
191
|
const className = cx(`${prefix}--toggletip-button`, customClassName);
|
|
192
|
+
const ComponentToggle = BaseComponent ?? 'button';
|
|
193
|
+
if (ComponentToggle !== 'button') {
|
|
194
|
+
return /*#__PURE__*/React__default.createElement(ComponentToggle, _extends({}, toggletip?.onClick, {
|
|
195
|
+
className: className
|
|
196
|
+
}, rest), children);
|
|
197
|
+
}
|
|
187
198
|
return /*#__PURE__*/React__default.createElement("button", _extends({}, toggletip?.buttonProps, {
|
|
188
199
|
"aria-label": label,
|
|
189
200
|
type: "button",
|
|
190
201
|
className: className
|
|
191
|
-
}), children);
|
|
202
|
+
}, rest), children);
|
|
192
203
|
}
|
|
193
204
|
ToggletipButton.propTypes = {
|
|
194
205
|
/**
|
|
@@ -49,6 +49,9 @@ const DefinitionTooltip = _ref => {
|
|
|
49
49
|
onMouseEnter: () => {
|
|
50
50
|
openOnHover ? setOpen(true) : null;
|
|
51
51
|
},
|
|
52
|
+
onFocus: () => {
|
|
53
|
+
setOpen(true);
|
|
54
|
+
},
|
|
52
55
|
open: isOpen
|
|
53
56
|
}, /*#__PURE__*/React__default.createElement("button", _extends({}, rest, {
|
|
54
57
|
className: cx(`${prefix}--definition-term`, triggerClassName),
|
package/es/feature-flags.js
CHANGED
package/es/index.js
CHANGED
|
@@ -25,6 +25,8 @@ export { default as ComposedModal, ModalBody } from './components/ComposedModal/
|
|
|
25
25
|
export { ModalHeader } from './components/ComposedModal/ModalHeader.js';
|
|
26
26
|
export { ModalFooter } from './components/ComposedModal/ModalFooter.js';
|
|
27
27
|
export { default as ContentSwitcher } from './components/ContentSwitcher/index.js';
|
|
28
|
+
export { default as Copy } from './components/Copy/Copy.js';
|
|
29
|
+
export { default as CopyButton } from './components/CopyButton/CopyButton.js';
|
|
28
30
|
export { default as DangerButton } from './components/DangerButton/DangerButton.js';
|
|
29
31
|
import './components/DataTable/index.js';
|
|
30
32
|
export { default as DataTableSkeleton } from './components/DataTableSkeleton/DataTableSkeleton.js';
|
|
@@ -97,7 +99,7 @@ export { default as IconSwitch } from './components/Switch/IconSwitch.js';
|
|
|
97
99
|
export { IconTab, Tab, TabList, TabPanel, TabPanels, Tabs } from './components/Tabs/Tabs.js';
|
|
98
100
|
export { default as TabContent } from './components/TabContent/TabContent.js';
|
|
99
101
|
export { default as TabsSkeleton } from './components/Tabs/Tabs.Skeleton.js';
|
|
100
|
-
export { default as Tag
|
|
102
|
+
export { default as Tag } from './components/Tag/Tag.js';
|
|
101
103
|
export { default as TagSkeleton } from './components/Tag/Tag.Skeleton.js';
|
|
102
104
|
export { default as TextArea } from './components/TextArea/TextArea.js';
|
|
103
105
|
export { default as TextAreaSkeleton } from './components/TextArea/TextArea.Skeleton.js';
|
|
@@ -169,8 +171,6 @@ export { default as CodeSnippet } from './components/CodeSnippet/CodeSnippet.js'
|
|
|
169
171
|
export { default as ContainedListItem } from './components/ContainedList/ContainedListItem/ContainedListItem.js';
|
|
170
172
|
export { default as ContainedList } from './components/ContainedList/ContainedList.js';
|
|
171
173
|
export { default as useContextMenu } from './components/ContextMenu/useContextMenu.js';
|
|
172
|
-
export { default as Copy } from './components/Copy/Copy.js';
|
|
173
|
-
export { default as CopyButton } from './components/CopyButton/CopyButton.js';
|
|
174
174
|
export { default as SliderSkeleton } from './components/Slider/Slider.Skeleton.js';
|
|
175
175
|
export { default as TextInputSkeleton } from './components/TextInput/TextInput.Skeleton.js';
|
|
176
176
|
export { default as TextInput } from './components/TextInput/TextInput.js';
|
package/es/internal/Selection.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { defineProperty as _defineProperty } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default, { useRef, useState,
|
|
9
|
+
import React__default, { useRef, useState, useEffect, useCallback } from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import isEqual from 'lodash.isequal';
|
|
12
12
|
|
|
@@ -39,7 +39,16 @@ function useSelection(_ref2) {
|
|
|
39
39
|
const savedOnChange = useRef(onChange);
|
|
40
40
|
const [uncontrolledItems, setUncontrolledItems] = useState(initialSelectedItems);
|
|
41
41
|
const isControlled = !!controlledItems;
|
|
42
|
-
const selectedItems = isControlled ? controlledItems : uncontrolledItems;
|
|
42
|
+
const [selectedItems, setSelectedItems] = useState(isControlled ? controlledItems : uncontrolledItems);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
callOnChangeHandler({
|
|
45
|
+
isControlled,
|
|
46
|
+
isMounted: isMounted.current,
|
|
47
|
+
onChangeHandlerControlled: savedOnChange.current,
|
|
48
|
+
onChangeHandlerUncontrolled: setUncontrolledItems,
|
|
49
|
+
selectedItems: selectedItems
|
|
50
|
+
});
|
|
51
|
+
}, [isControlled, isMounted, selectedItems]);
|
|
43
52
|
const onItemChange = useCallback(item => {
|
|
44
53
|
if (disabled) {
|
|
45
54
|
return;
|
|
@@ -50,27 +59,12 @@ function useSelection(_ref2) {
|
|
|
50
59
|
selectedIndex = index;
|
|
51
60
|
}
|
|
52
61
|
});
|
|
53
|
-
let newSelectedItems;
|
|
54
62
|
if (selectedIndex === undefined) {
|
|
55
|
-
|
|
56
|
-
callOnChangeHandler({
|
|
57
|
-
isControlled,
|
|
58
|
-
isMounted: isMounted.current,
|
|
59
|
-
onChangeHandlerControlled: savedOnChange.current,
|
|
60
|
-
onChangeHandlerUncontrolled: setUncontrolledItems,
|
|
61
|
-
selectedItems: newSelectedItems
|
|
62
|
-
});
|
|
63
|
+
setSelectedItems(selectedItems => selectedItems.concat(item));
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
isControlled,
|
|
68
|
-
isMounted: isMounted.current,
|
|
69
|
-
onChangeHandlerControlled: savedOnChange.current,
|
|
70
|
-
onChangeHandlerUncontrolled: setUncontrolledItems,
|
|
71
|
-
selectedItems: newSelectedItems
|
|
72
|
-
});
|
|
73
|
-
}, [disabled, isControlled, selectedItems]);
|
|
66
|
+
setSelectedItems(selectedItems => removeAtIndex(selectedItems, selectedIndex));
|
|
67
|
+
}, [disabled, selectedItems]);
|
|
74
68
|
const clearSelection = useCallback(() => {
|
|
75
69
|
if (disabled) {
|
|
76
70
|
return;
|
|
@@ -80,7 +74,7 @@ function useSelection(_ref2) {
|
|
|
80
74
|
isMounted: isMounted.current,
|
|
81
75
|
onChangeHandlerControlled: savedOnChange.current,
|
|
82
76
|
onChangeHandlerUncontrolled: setUncontrolledItems,
|
|
83
|
-
selectedItems: []
|
|
77
|
+
selectedItems: setSelectedItems([])
|
|
84
78
|
});
|
|
85
79
|
}, [disabled, isControlled]);
|
|
86
80
|
useEffect(() => {
|
|
@@ -55,7 +55,7 @@ function AccordionItem(_ref) {
|
|
|
55
55
|
const prefix = usePrefix.usePrefix();
|
|
56
56
|
const className = cx__default["default"]({
|
|
57
57
|
[`${prefix}--accordion__item`]: true,
|
|
58
|
-
[`${prefix}--accordion__item--active`]: isOpen,
|
|
58
|
+
[`${prefix}--accordion__item--active`]: isOpen && !disabled,
|
|
59
59
|
[`${prefix}--accordion__item--disabled`]: disabled,
|
|
60
60
|
[customClassName]: !!customClassName
|
|
61
61
|
});
|
|
@@ -36,7 +36,7 @@ const rowHeightInPixels = 16;
|
|
|
36
36
|
const defaultMaxCollapsedNumberOfRows = 15;
|
|
37
37
|
const defaultMaxExpandedNumberOfRows = 0;
|
|
38
38
|
const defaultMinCollapsedNumberOfRows = 3;
|
|
39
|
-
const defaultMinExpandedNumberOfRows =
|
|
39
|
+
const defaultMinExpandedNumberOfRows = 0;
|
|
40
40
|
function CodeSnippet(_ref) {
|
|
41
41
|
let {
|
|
42
42
|
align = 'bottom',
|
|
@@ -113,7 +113,7 @@ function CodeSnippet(_ref) {
|
|
|
113
113
|
if (codeContentRef?.current && type === 'multi') {
|
|
114
114
|
const {
|
|
115
115
|
height
|
|
116
|
-
} =
|
|
116
|
+
} = innerCodeRef.current.getBoundingClientRect();
|
|
117
117
|
if (maxCollapsedNumberOfRows > 0 && (maxExpandedNumberOfRows <= 0 || maxExpandedNumberOfRows > maxCollapsedNumberOfRows) && height > maxCollapsedNumberOfRows * rowHeightInPixels) {
|
|
118
118
|
setShouldShowMoreLessBtn(true);
|
|
119
119
|
} else {
|
|
@@ -0,0 +1,74 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
8
|
+
import React, { AnimationEventHandler, MouseEventHandler, PropsWithChildren } from 'react';
|
|
9
|
+
interface CopyProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
10
|
+
/**
|
|
11
|
+
* Specify how the trigger should align with the tooltip
|
|
12
|
+
*/
|
|
13
|
+
align?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
|
|
14
|
+
/**
|
|
15
|
+
* Specify an optional className to be applied to the underlying `<button>`
|
|
16
|
+
*/
|
|
17
|
+
className?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Specify the string that is displayed when the button is clicked and the
|
|
20
|
+
* content is copied
|
|
21
|
+
*/
|
|
22
|
+
feedback?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Specify the time it takes for the feedback message to timeout
|
|
25
|
+
*/
|
|
26
|
+
feedbackTimeout?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Specify an optional `onAnimationEnd` handler that is called when the underlying
|
|
29
|
+
* animation ends
|
|
30
|
+
*/
|
|
31
|
+
onAnimationEnd?: AnimationEventHandler<HTMLButtonElement>;
|
|
32
|
+
/**
|
|
33
|
+
* Specify an optional `onClick` handler that is called when the underlying
|
|
34
|
+
* `<button>` is clicked
|
|
35
|
+
*/
|
|
36
|
+
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
37
|
+
}
|
|
38
|
+
declare function Copy({ align, children, className, feedback, feedbackTimeout, onAnimationEnd, onClick, ...other }: PropsWithChildren<CopyProps>): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
declare namespace Copy {
|
|
40
|
+
var propTypes: {
|
|
41
|
+
/**
|
|
42
|
+
* Specify how the trigger should align with the tooltip
|
|
43
|
+
*/
|
|
44
|
+
align: PropTypes.Requireable<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Pass in content to be rendered in the underlying `<button>`
|
|
47
|
+
*/
|
|
48
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
49
|
+
/**
|
|
50
|
+
* Specify an optional className to be applied to the underlying `<button>`
|
|
51
|
+
*/
|
|
52
|
+
className: PropTypes.Requireable<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Specify the string that is displayed when the button is clicked and the
|
|
55
|
+
* content is copied
|
|
56
|
+
*/
|
|
57
|
+
feedback: PropTypes.Requireable<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Specify the time it takes for the feedback message to timeout
|
|
60
|
+
*/
|
|
61
|
+
feedbackTimeout: PropTypes.Requireable<number>;
|
|
62
|
+
/**
|
|
63
|
+
* Specify an optional `onAnimationEnd` handler that is called when the underlying
|
|
64
|
+
* animation ends
|
|
65
|
+
*/
|
|
66
|
+
onAnimationEnd: PropTypes.Requireable<(...args: any[]) => any>;
|
|
67
|
+
/**
|
|
68
|
+
* Specify an optional `onClick` handler that is called when the underlying
|
|
69
|
+
* `<button>` is clicked
|
|
70
|
+
*/
|
|
71
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export default Copy;
|
|
@@ -68,7 +68,7 @@ function Copy(_ref) {
|
|
|
68
68
|
onClick: events.composeEventHandlers([onClick, handleClick]),
|
|
69
69
|
onAnimationEnd: events.composeEventHandlers([onAnimationEnd, handleAnimationEnd])
|
|
70
70
|
}, other, {
|
|
71
|
-
"aria-label": !children && (animation ? feedback : other['aria-label']) ||
|
|
71
|
+
"aria-label": !children && (animation ? feedback : other['aria-label']) || undefined
|
|
72
72
|
}), children);
|
|
73
73
|
}
|
|
74
74
|
Copy.propTypes = {
|