@carbon/react 1.52.0-rc.0 → 1.53.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1791 -1450
- package/es/components/Accordion/AccordionItem.js +1 -1
- package/es/components/CodeSnippet/CodeSnippet.js +2 -2
- 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/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 +1 -1
- 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/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/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 +0 -1
- package/lib/internal/Selection.js +14 -20
- package/package.json +8 -8
|
@@ -0,0 +1,101 @@
|
|
|
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, { MouseEventHandler } from 'react';
|
|
9
|
+
import { PolymorphicProps } from '../../types/common';
|
|
10
|
+
import { SIZES } from './Tag';
|
|
11
|
+
declare const TYPES: {
|
|
12
|
+
red: string;
|
|
13
|
+
magenta: string;
|
|
14
|
+
purple: string;
|
|
15
|
+
blue: string;
|
|
16
|
+
cyan: string;
|
|
17
|
+
teal: string;
|
|
18
|
+
green: string;
|
|
19
|
+
gray: string;
|
|
20
|
+
'cool-gray': string;
|
|
21
|
+
'warm-gray': string;
|
|
22
|
+
};
|
|
23
|
+
export interface OperationalTagBaseProps {
|
|
24
|
+
/**
|
|
25
|
+
* Provide content to be rendered inside of a `OperationalTag`
|
|
26
|
+
*/
|
|
27
|
+
children?: React.ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* Provide a custom className that is applied to the containing <span>
|
|
30
|
+
*/
|
|
31
|
+
className?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Specify if the `OperationalTag` is disabled
|
|
34
|
+
*/
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Specify the id for the OperationalTag.
|
|
38
|
+
*/
|
|
39
|
+
id?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Optional prop to render a custom icon.
|
|
42
|
+
* Can be a React component class
|
|
43
|
+
*/
|
|
44
|
+
renderIcon?: React.ElementType;
|
|
45
|
+
onClick?: MouseEventHandler;
|
|
46
|
+
/**
|
|
47
|
+
* Specify the size of the Tag. Currently supports either `sm`,
|
|
48
|
+
* `md` (default) or `lg` sizes.
|
|
49
|
+
*/
|
|
50
|
+
size?: keyof typeof SIZES;
|
|
51
|
+
/**
|
|
52
|
+
* **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
|
|
53
|
+
*/
|
|
54
|
+
slug?: ReactNodeLike;
|
|
55
|
+
/**
|
|
56
|
+
* Specify the type of the `Tag`
|
|
57
|
+
*/
|
|
58
|
+
type?: keyof typeof TYPES;
|
|
59
|
+
}
|
|
60
|
+
export type OperationalTagProps<T extends React.ElementType> = PolymorphicProps<T, OperationalTagBaseProps>;
|
|
61
|
+
declare const OperationalTag: {
|
|
62
|
+
<T extends React.ElementType<any>>({ children, className, disabled, id, renderIcon, slug, size, type, ...other }: OperationalTagProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
63
|
+
propTypes: {
|
|
64
|
+
/**
|
|
65
|
+
* Provide content to be rendered inside of a `OperationalTag`
|
|
66
|
+
*/
|
|
67
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
68
|
+
/**
|
|
69
|
+
* Provide a custom className that is applied to the containing <span>
|
|
70
|
+
*/
|
|
71
|
+
className: PropTypes.Requireable<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Specify if the `OperationalTag` is disabled
|
|
74
|
+
*/
|
|
75
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
76
|
+
/**
|
|
77
|
+
* Specify the id for the tag.
|
|
78
|
+
*/
|
|
79
|
+
id: PropTypes.Requireable<string>;
|
|
80
|
+
/**
|
|
81
|
+
* Optional prop to render a custom icon.
|
|
82
|
+
* Can be a React component class
|
|
83
|
+
*/
|
|
84
|
+
renderIcon: PropTypes.Requireable<object>;
|
|
85
|
+
/**
|
|
86
|
+
* Specify the size of the Tag. Currently supports either `sm`,
|
|
87
|
+
* `md` (default) or `lg` sizes.
|
|
88
|
+
*/
|
|
89
|
+
size: PropTypes.Requireable<string>;
|
|
90
|
+
/**
|
|
91
|
+
* **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
|
|
92
|
+
*/
|
|
93
|
+
slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
94
|
+
/**
|
|
95
|
+
* Specify the type of the `Tag`
|
|
96
|
+
*/
|
|
97
|
+
type: PropTypes.Requireable<string>;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
export declare const types: string[];
|
|
101
|
+
export default OperationalTag;
|
|
@@ -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
|
*/
|
|
@@ -17,6 +17,7 @@ var iconsReact = require('@carbon/icons-react');
|
|
|
17
17
|
var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
|
|
18
18
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
19
19
|
require('../Text/index.js');
|
|
20
|
+
var deprecate = require('../../prop-types/deprecate.js');
|
|
20
21
|
var Text = require('../Text/Text.js');
|
|
21
22
|
|
|
22
23
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -41,6 +42,11 @@ const TYPES = {
|
|
|
41
42
|
'high-contrast': 'High-Contrast',
|
|
42
43
|
outline: 'Outline'
|
|
43
44
|
};
|
|
45
|
+
const SIZES = {
|
|
46
|
+
sm: 'sm',
|
|
47
|
+
md: 'md',
|
|
48
|
+
lg: 'lg'
|
|
49
|
+
};
|
|
44
50
|
const Tag = _ref => {
|
|
45
51
|
let {
|
|
46
52
|
children,
|
|
@@ -48,10 +54,13 @@ const Tag = _ref => {
|
|
|
48
54
|
id,
|
|
49
55
|
type,
|
|
50
56
|
filter,
|
|
57
|
+
// remove filter in next major release - V12
|
|
51
58
|
renderIcon: CustomIconElement,
|
|
52
59
|
title = 'Clear filter',
|
|
60
|
+
// remove title in next major release - V12
|
|
53
61
|
disabled,
|
|
54
62
|
onClose,
|
|
63
|
+
// remove onClose in next major release - V12
|
|
55
64
|
size,
|
|
56
65
|
as: BaseComponent,
|
|
57
66
|
slug,
|
|
@@ -59,6 +68,8 @@ const Tag = _ref => {
|
|
|
59
68
|
} = _ref;
|
|
60
69
|
const prefix = usePrefix.usePrefix();
|
|
61
70
|
const tagId = id || `tag-${getInstanceId()}`;
|
|
71
|
+
const conditions = [`${prefix}--tag--selectable`, `${prefix}--tag--filter`, `${prefix}--tag--operational`];
|
|
72
|
+
const isInteractiveTag = conditions.some(el => className?.includes(el));
|
|
62
73
|
const tagClasses = cx__default["default"](`${prefix}--tag`, className, {
|
|
63
74
|
[`${prefix}--tag--disabled`]: disabled,
|
|
64
75
|
[`${prefix}--tag--filter`]: filter,
|
|
@@ -66,7 +77,7 @@ const Tag = _ref => {
|
|
|
66
77
|
// TODO: V12 - Remove this class
|
|
67
78
|
[`${prefix}--layout--size-${size}`]: size,
|
|
68
79
|
[`${prefix}--tag--${type}`]: type,
|
|
69
|
-
[`${prefix}--tag--interactive`]: other.onClick && !
|
|
80
|
+
[`${prefix}--tag--interactive`]: other.onClick && !isInteractiveTag
|
|
70
81
|
});
|
|
71
82
|
const typeText = type !== undefined && type in Object.keys(TYPES) ? TYPES[type] : '';
|
|
72
83
|
const handleClose = event => {
|
|
@@ -78,7 +89,7 @@ const Tag = _ref => {
|
|
|
78
89
|
|
|
79
90
|
// Slug is always size `md` and `inline`
|
|
80
91
|
let normalizedSlug;
|
|
81
|
-
if (slug && slug['type']?.displayName === 'Slug') {
|
|
92
|
+
if (slug && slug['type']?.displayName === 'Slug' && !isInteractiveTag) {
|
|
82
93
|
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
83
94
|
size: 'sm',
|
|
84
95
|
kind: 'inline'
|
|
@@ -89,7 +100,7 @@ const Tag = _ref => {
|
|
|
89
100
|
return /*#__PURE__*/React__default["default"].createElement(ComponentTag, _rollupPluginBabelHelpers["extends"]({
|
|
90
101
|
className: tagClasses,
|
|
91
102
|
id: tagId
|
|
92
|
-
}, other), CustomIconElement ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
103
|
+
}, other), CustomIconElement && size !== 'sm' ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
93
104
|
className: `${prefix}--tag__custom-icon`
|
|
94
105
|
}, /*#__PURE__*/React__default["default"].createElement(CustomIconElement, null)) : '', /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
95
106
|
className: `${prefix}--tag__label`,
|
|
@@ -103,16 +114,14 @@ const Tag = _ref => {
|
|
|
103
114
|
title: title
|
|
104
115
|
}, _Close || (_Close = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null))));
|
|
105
116
|
}
|
|
106
|
-
const ComponentTag = BaseComponent ?? (other.onClick ? 'button' : 'div');
|
|
117
|
+
const ComponentTag = BaseComponent ?? (other.onClick || className?.includes(`${prefix}--tag--operational`) ? 'button' : 'div');
|
|
107
118
|
return /*#__PURE__*/React__default["default"].createElement(ComponentTag, _rollupPluginBabelHelpers["extends"]({
|
|
108
|
-
disabled:
|
|
119
|
+
disabled: disabled,
|
|
109
120
|
className: tagClasses,
|
|
110
121
|
id: tagId
|
|
111
|
-
}, other), CustomIconElement ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
122
|
+
}, other), CustomIconElement && size !== 'sm' ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
112
123
|
className: `${prefix}--tag__custom-icon`
|
|
113
|
-
}, /*#__PURE__*/React__default["default"].createElement(CustomIconElement, null)) : '', /*#__PURE__*/React__default["default"].createElement(Text.Text,
|
|
114
|
-
title: typeof children === 'string' ? children : undefined
|
|
115
|
-
}, children !== null && children !== undefined ? children : typeText), normalizedSlug);
|
|
124
|
+
}, /*#__PURE__*/React__default["default"].createElement(CustomIconElement, null)) : '', /*#__PURE__*/React__default["default"].createElement(Text.Text, null, children !== null && children !== undefined ? children : typeText), normalizedSlug);
|
|
116
125
|
};
|
|
117
126
|
Tag.propTypes = {
|
|
118
127
|
/**
|
|
@@ -135,7 +144,7 @@ Tag.propTypes = {
|
|
|
135
144
|
/**
|
|
136
145
|
* Determine if `Tag` is a filter/chip
|
|
137
146
|
*/
|
|
138
|
-
filter: PropTypes__default["default"].bool,
|
|
147
|
+
filter: deprecate["default"](PropTypes__default["default"].bool, 'This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
|
|
139
148
|
/**
|
|
140
149
|
* Specify the id for the tag.
|
|
141
150
|
*/
|
|
@@ -143,17 +152,17 @@ Tag.propTypes = {
|
|
|
143
152
|
/**
|
|
144
153
|
* Click handler for filter tag close button.
|
|
145
154
|
*/
|
|
146
|
-
onClose: PropTypes__default["default"].func,
|
|
155
|
+
onClose: deprecate["default"](PropTypes__default["default"].func, 'This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
|
|
147
156
|
/**
|
|
148
157
|
* Optional prop to render a custom icon.
|
|
149
158
|
* Can be a React component class
|
|
150
159
|
*/
|
|
151
160
|
renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
|
|
152
161
|
/**
|
|
153
|
-
* Specify the size of the Tag. Currently supports either `sm
|
|
154
|
-
*
|
|
162
|
+
* Specify the size of the Tag. Currently supports either `sm`,
|
|
163
|
+
* `md` (default) or `lg` sizes.
|
|
155
164
|
*/
|
|
156
|
-
size: PropTypes__default["default"].oneOf(
|
|
165
|
+
size: PropTypes__default["default"].oneOf(Object.keys(SIZES)),
|
|
157
166
|
/**
|
|
158
167
|
* **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
|
|
159
168
|
*/
|
|
@@ -161,13 +170,13 @@ Tag.propTypes = {
|
|
|
161
170
|
/**
|
|
162
171
|
* Text to show on clear filters
|
|
163
172
|
*/
|
|
164
|
-
title: PropTypes__default["default"].string,
|
|
173
|
+
title: deprecate["default"](PropTypes__default["default"].string, 'This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
|
|
165
174
|
/**
|
|
166
175
|
* Specify the type of the `Tag`
|
|
167
176
|
*/
|
|
168
177
|
type: PropTypes__default["default"].oneOf(Object.keys(TYPES))
|
|
169
178
|
};
|
|
170
|
-
const types = Object.keys(TYPES);
|
|
171
179
|
|
|
180
|
+
exports.SIZES = SIZES;
|
|
181
|
+
exports.TYPES = TYPES;
|
|
172
182
|
exports["default"] = Tag;
|
|
173
|
-
exports.types = types;
|
|
@@ -75,6 +75,7 @@ function Toggle(_ref) {
|
|
|
75
75
|
const switchClasses = cx__default["default"](`${prefix}--toggle__switch`, {
|
|
76
76
|
[`${prefix}--toggle__switch--checked`]: checked
|
|
77
77
|
});
|
|
78
|
+
const labelId = `${id}_label`;
|
|
78
79
|
return (
|
|
79
80
|
/*#__PURE__*/
|
|
80
81
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
@@ -98,10 +99,11 @@ function Toggle(_ref) {
|
|
|
98
99
|
role: "switch",
|
|
99
100
|
type: "button",
|
|
100
101
|
"aria-checked": checked,
|
|
101
|
-
"aria-labelledby":
|
|
102
|
+
"aria-labelledby": ariaLabelledby ?? labelId,
|
|
102
103
|
disabled: disabled,
|
|
103
104
|
onClick: handleClick
|
|
104
105
|
})), /*#__PURE__*/React__default["default"].createElement(LabelComponent, {
|
|
106
|
+
id: labelId,
|
|
105
107
|
htmlFor: ariaLabelledby ? undefined : id,
|
|
106
108
|
className: `${prefix}--toggle__label`
|
|
107
109
|
}, labelText && /*#__PURE__*/React__default["default"].createElement(Text.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
|
/**
|
|
@@ -102,6 +102,9 @@ function Toggletip(_ref2) {
|
|
|
102
102
|
},
|
|
103
103
|
contentProps: {
|
|
104
104
|
id
|
|
105
|
+
},
|
|
106
|
+
onClick: {
|
|
107
|
+
onClick: actions.toggle
|
|
105
108
|
}
|
|
106
109
|
};
|
|
107
110
|
const onKeyDown = event => {
|
|
@@ -189,16 +192,24 @@ function ToggletipButton(_ref3) {
|
|
|
189
192
|
let {
|
|
190
193
|
children,
|
|
191
194
|
className: customClassName,
|
|
192
|
-
label = 'Show information'
|
|
195
|
+
label = 'Show information',
|
|
196
|
+
as: BaseComponent,
|
|
197
|
+
...rest
|
|
193
198
|
} = _ref3;
|
|
194
199
|
const toggletip = useToggletip();
|
|
195
200
|
const prefix = usePrefix.usePrefix();
|
|
196
201
|
const className = cx__default["default"](`${prefix}--toggletip-button`, customClassName);
|
|
202
|
+
const ComponentToggle = BaseComponent ?? 'button';
|
|
203
|
+
if (ComponentToggle !== 'button') {
|
|
204
|
+
return /*#__PURE__*/React__default["default"].createElement(ComponentToggle, _rollupPluginBabelHelpers["extends"]({}, toggletip?.onClick, {
|
|
205
|
+
className: className
|
|
206
|
+
}, rest), children);
|
|
207
|
+
}
|
|
197
208
|
return /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({}, toggletip?.buttonProps, {
|
|
198
209
|
"aria-label": label,
|
|
199
210
|
type: "button",
|
|
200
211
|
className: className
|
|
201
|
-
}), children);
|
|
212
|
+
}, rest), children);
|
|
202
213
|
}
|
|
203
214
|
ToggletipButton.propTypes = {
|
|
204
215
|
/**
|
|
@@ -59,6 +59,9 @@ const DefinitionTooltip = _ref => {
|
|
|
59
59
|
onMouseEnter: () => {
|
|
60
60
|
openOnHover ? setOpen(true) : null;
|
|
61
61
|
},
|
|
62
|
+
onFocus: () => {
|
|
63
|
+
setOpen(true);
|
|
64
|
+
},
|
|
62
65
|
open: isOpen
|
|
63
66
|
}, /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
64
67
|
className: cx__default["default"](`${prefix}--definition-term`, triggerClassName),
|
package/lib/feature-flags.js
CHANGED
|
@@ -33,5 +33,6 @@ FeatureFlags__namespace.merge({
|
|
|
33
33
|
'enable-css-custom-properties': true,
|
|
34
34
|
'enable-css-grid': true,
|
|
35
35
|
'enable-v11-release': true,
|
|
36
|
-
'enable-experimental-tile-contrast': false
|
|
36
|
+
'enable-experimental-tile-contrast': false,
|
|
37
|
+
'enable-v12-tile-radio-icons': false
|
|
37
38
|
});
|
package/lib/index.js
CHANGED
|
@@ -347,7 +347,6 @@ exports.Tabs = Tabs.Tabs;
|
|
|
347
347
|
exports.TabContent = TabContent["default"];
|
|
348
348
|
exports.TabsSkeleton = Tabs_Skeleton["default"];
|
|
349
349
|
exports.Tag = Tag["default"];
|
|
350
|
-
exports.types = Tag.types;
|
|
351
350
|
exports.TagSkeleton = Tag_Skeleton["default"];
|
|
352
351
|
exports.TextArea = TextArea["default"];
|
|
353
352
|
exports.TextAreaSkeleton = TextArea_Skeleton["default"];
|
|
@@ -49,7 +49,16 @@ function useSelection(_ref2) {
|
|
|
49
49
|
const savedOnChange = React.useRef(onChange);
|
|
50
50
|
const [uncontrolledItems, setUncontrolledItems] = React.useState(initialSelectedItems);
|
|
51
51
|
const isControlled = !!controlledItems;
|
|
52
|
-
const selectedItems = isControlled ? controlledItems : uncontrolledItems;
|
|
52
|
+
const [selectedItems, setSelectedItems] = React.useState(isControlled ? controlledItems : uncontrolledItems);
|
|
53
|
+
React.useEffect(() => {
|
|
54
|
+
callOnChangeHandler({
|
|
55
|
+
isControlled,
|
|
56
|
+
isMounted: isMounted.current,
|
|
57
|
+
onChangeHandlerControlled: savedOnChange.current,
|
|
58
|
+
onChangeHandlerUncontrolled: setUncontrolledItems,
|
|
59
|
+
selectedItems: selectedItems
|
|
60
|
+
});
|
|
61
|
+
}, [isControlled, isMounted, selectedItems]);
|
|
53
62
|
const onItemChange = React.useCallback(item => {
|
|
54
63
|
if (disabled) {
|
|
55
64
|
return;
|
|
@@ -60,27 +69,12 @@ function useSelection(_ref2) {
|
|
|
60
69
|
selectedIndex = index;
|
|
61
70
|
}
|
|
62
71
|
});
|
|
63
|
-
let newSelectedItems;
|
|
64
72
|
if (selectedIndex === undefined) {
|
|
65
|
-
|
|
66
|
-
callOnChangeHandler({
|
|
67
|
-
isControlled,
|
|
68
|
-
isMounted: isMounted.current,
|
|
69
|
-
onChangeHandlerControlled: savedOnChange.current,
|
|
70
|
-
onChangeHandlerUncontrolled: setUncontrolledItems,
|
|
71
|
-
selectedItems: newSelectedItems
|
|
72
|
-
});
|
|
73
|
+
setSelectedItems(selectedItems => selectedItems.concat(item));
|
|
73
74
|
return;
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
isControlled,
|
|
78
|
-
isMounted: isMounted.current,
|
|
79
|
-
onChangeHandlerControlled: savedOnChange.current,
|
|
80
|
-
onChangeHandlerUncontrolled: setUncontrolledItems,
|
|
81
|
-
selectedItems: newSelectedItems
|
|
82
|
-
});
|
|
83
|
-
}, [disabled, isControlled, selectedItems]);
|
|
76
|
+
setSelectedItems(selectedItems => removeAtIndex(selectedItems, selectedIndex));
|
|
77
|
+
}, [disabled, selectedItems]);
|
|
84
78
|
const clearSelection = React.useCallback(() => {
|
|
85
79
|
if (disabled) {
|
|
86
80
|
return;
|
|
@@ -90,7 +84,7 @@ function useSelection(_ref2) {
|
|
|
90
84
|
isMounted: isMounted.current,
|
|
91
85
|
onChangeHandlerControlled: savedOnChange.current,
|
|
92
86
|
onChangeHandlerUncontrolled: setUncontrolledItems,
|
|
93
|
-
selectedItems: []
|
|
87
|
+
selectedItems: setSelectedItems([])
|
|
94
88
|
});
|
|
95
89
|
}, [disabled, isControlled]);
|
|
96
90
|
React.useEffect(() => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.53.0-rc.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@babel/runtime": "^7.18.3",
|
|
51
|
-
"@carbon/feature-flags": "^0.
|
|
52
|
-
"@carbon/icons-react": "^11.
|
|
53
|
-
"@carbon/layout": "^11.
|
|
54
|
-
"@carbon/styles": "^1.
|
|
51
|
+
"@carbon/feature-flags": "^0.18.0-rc.0",
|
|
52
|
+
"@carbon/icons-react": "^11.38.0-rc.0",
|
|
53
|
+
"@carbon/layout": "^11.21.0-rc.0",
|
|
54
|
+
"@carbon/styles": "^1.53.0-rc.0",
|
|
55
55
|
"@ibm/telemetry-js": "^1.2.1",
|
|
56
56
|
"classnames": "2.5.1",
|
|
57
57
|
"copy-to-clipboard": "^3.3.1",
|
|
58
|
-
"downshift": "8.3.
|
|
58
|
+
"downshift": "8.3.2",
|
|
59
59
|
"flatpickr": "4.6.13",
|
|
60
60
|
"invariant": "^2.2.3",
|
|
61
61
|
"lodash.debounce": "^4.0.8",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@babel/preset-react": "^7.22.3",
|
|
80
80
|
"@babel/preset-typescript": "^7.21.5",
|
|
81
81
|
"@carbon/test-utils": "^10.30.0",
|
|
82
|
-
"@carbon/themes": "^11.
|
|
82
|
+
"@carbon/themes": "^11.33.0-rc.0",
|
|
83
83
|
"@rollup/plugin-babel": "^6.0.0",
|
|
84
84
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
85
85
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
@@ -139,5 +139,5 @@
|
|
|
139
139
|
"**/*.scss",
|
|
140
140
|
"**/*.css"
|
|
141
141
|
],
|
|
142
|
-
"gitHead": "
|
|
142
|
+
"gitHead": "fd9030978919c8d2ce0c102db94aeabf88563c34"
|
|
143
143
|
}
|