@carbon/react 1.33.0-rc.0 → 1.33.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/es/components/DataTableSkeleton/DataTableSkeleton.d.ts +17 -16
- package/es/components/Tag/Tag.js +9 -2
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/UIShell/HeaderMenuButton.d.ts +4 -0
- package/es/components/UIShell/HeaderMenuButton.js +4 -0
- package/es/components/UIShell/HeaderPanel.js +1 -1
- package/es/components/UIShell/Switcher.js +17 -6
- package/lib/components/DataTableSkeleton/DataTableSkeleton.d.ts +17 -16
- package/lib/components/Tag/Tag.js +9 -2
- package/lib/components/TextArea/TextArea.js +1 -1
- package/lib/components/UIShell/HeaderMenuButton.d.ts +4 -0
- package/lib/components/UIShell/HeaderMenuButton.js +4 -0
- package/lib/components/UIShell/HeaderPanel.js +1 -1
- package/lib/components/UIShell/Switcher.js +17 -6
- package/package.json +6 -6
|
@@ -5,46 +5,47 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
|
|
8
|
+
import { TableHTMLAttributes } from 'react';
|
|
9
|
+
export interface DataTableSkeletonHeader {
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Optionally specify header label
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
+
header?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optionally specify header key
|
|
16
|
+
*/
|
|
17
|
+
key?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface DataTableSkeletonProps extends TableHTMLAttributes<HTMLTableElement> {
|
|
13
20
|
/**
|
|
14
21
|
* Specify the number of columns that you want to render in the skeleton state
|
|
15
22
|
*/
|
|
16
|
-
columnCount
|
|
23
|
+
columnCount?: number;
|
|
17
24
|
/**
|
|
18
25
|
* Optionally specify whether you want the Skeleton to be rendered as a
|
|
19
26
|
* compact DataTable
|
|
20
27
|
*/
|
|
21
|
-
compact
|
|
28
|
+
compact?: boolean;
|
|
22
29
|
/**
|
|
23
30
|
* Optionally specify the displayed headers
|
|
24
31
|
*/
|
|
25
|
-
headers?: [
|
|
26
|
-
header: string;
|
|
27
|
-
key: string;
|
|
28
|
-
}] | {
|
|
29
|
-
header: string;
|
|
30
|
-
key: string;
|
|
31
|
-
};
|
|
32
|
+
headers?: DataTableSkeletonHeader[];
|
|
32
33
|
/**
|
|
33
34
|
* Specify the number of rows that you want to render in the skeleton state
|
|
34
35
|
*/
|
|
35
|
-
rowCount
|
|
36
|
+
rowCount?: number;
|
|
36
37
|
/**
|
|
37
38
|
* Specify if the table header should be rendered as part of the skeleton.
|
|
38
39
|
*/
|
|
39
|
-
showHeader
|
|
40
|
+
showHeader?: boolean;
|
|
40
41
|
/**
|
|
41
42
|
* Specify if the table toolbar should be rendered as part of the skeleton.
|
|
42
43
|
*/
|
|
43
|
-
showToolbar
|
|
44
|
+
showToolbar?: boolean;
|
|
44
45
|
/**
|
|
45
46
|
* Optionally specify whether you want the DataTable to be zebra striped
|
|
46
47
|
*/
|
|
47
|
-
zebra
|
|
48
|
+
zebra?: boolean;
|
|
48
49
|
}
|
|
49
50
|
declare const DataTableSkeleton: {
|
|
50
51
|
({ headers, rowCount, columnCount, zebra, compact, className, showHeader, showToolbar, ...rest }: {
|
package/es/components/Tag/Tag.js
CHANGED
|
@@ -41,6 +41,7 @@ const Tag = _ref => {
|
|
|
41
41
|
disabled,
|
|
42
42
|
onClose,
|
|
43
43
|
size,
|
|
44
|
+
as: BaseComponent,
|
|
44
45
|
...other
|
|
45
46
|
} = _ref;
|
|
46
47
|
const prefix = usePrefix();
|
|
@@ -61,7 +62,8 @@ const Tag = _ref => {
|
|
|
61
62
|
}
|
|
62
63
|
};
|
|
63
64
|
if (filter) {
|
|
64
|
-
|
|
65
|
+
const ComponentTag = BaseComponent ?? 'div';
|
|
66
|
+
return /*#__PURE__*/React__default.createElement(ComponentTag, _extends({
|
|
65
67
|
className: tagClasses,
|
|
66
68
|
id: tagId
|
|
67
69
|
}, other), /*#__PURE__*/React__default.createElement("span", {
|
|
@@ -76,7 +78,7 @@ const Tag = _ref => {
|
|
|
76
78
|
title: title
|
|
77
79
|
}, _Close || (_Close = /*#__PURE__*/React__default.createElement(Close, null))));
|
|
78
80
|
}
|
|
79
|
-
const ComponentTag = other.onClick ? 'button' : 'div';
|
|
81
|
+
const ComponentTag = BaseComponent ?? (other.onClick ? 'button' : 'div');
|
|
80
82
|
return /*#__PURE__*/React__default.createElement(ComponentTag, _extends({
|
|
81
83
|
disabled: ComponentTag === 'button' ? disabled : null,
|
|
82
84
|
className: tagClasses,
|
|
@@ -88,6 +90,11 @@ const Tag = _ref => {
|
|
|
88
90
|
}, children !== null && children !== undefined ? children : TYPES[type]));
|
|
89
91
|
};
|
|
90
92
|
Tag.propTypes = {
|
|
93
|
+
/**
|
|
94
|
+
* Provide an alternative tag or component to use instead of the default
|
|
95
|
+
* wrapping element
|
|
96
|
+
*/
|
|
97
|
+
as: PropTypes.elementType,
|
|
91
98
|
/**
|
|
92
99
|
* Provide content to be rendered inside of a <Tag>
|
|
93
100
|
*/
|
|
@@ -61,7 +61,7 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
|
|
|
61
61
|
if (!other.disabled && onChange) {
|
|
62
62
|
// delay textCount assignation to give the textarea element value time to catch up if is a controlled input
|
|
63
63
|
setTimeout(() => {
|
|
64
|
-
setTextCount(evt.target
|
|
64
|
+
setTextCount(evt.target?.value?.length);
|
|
65
65
|
}, 0);
|
|
66
66
|
onChange(evt);
|
|
67
67
|
}
|
|
@@ -28,6 +28,10 @@ declare namespace HeaderMenuButton {
|
|
|
28
28
|
* Specify whether the menu button is "active".
|
|
29
29
|
*/
|
|
30
30
|
isActive: PropTypes.Requireable<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Specify whether the menu button is collapsible.
|
|
33
|
+
*/
|
|
34
|
+
isCollapsible: PropTypes.Requireable<boolean>;
|
|
31
35
|
/**
|
|
32
36
|
* Optionally provide an onClick handler that is called when the underlying
|
|
33
37
|
* button fires it's onclick event
|
|
@@ -64,6 +64,10 @@ HeaderMenuButton.propTypes = {
|
|
|
64
64
|
* Specify whether the menu button is "active".
|
|
65
65
|
*/
|
|
66
66
|
isActive: PropTypes.bool,
|
|
67
|
+
/**
|
|
68
|
+
* Specify whether the menu button is collapsible.
|
|
69
|
+
*/
|
|
70
|
+
isCollapsible: PropTypes.bool,
|
|
67
71
|
/**
|
|
68
72
|
* Optionally provide an onClick handler that is called when the underlying
|
|
69
73
|
* button fires it's onclick event
|
|
@@ -39,7 +39,7 @@ const HeaderPanel = /*#__PURE__*/React__default.forwardRef(function HeaderPanel(
|
|
|
39
39
|
const eventHandlers = {};
|
|
40
40
|
if (addFocusListeners) {
|
|
41
41
|
eventHandlers.onBlur = event => {
|
|
42
|
-
if (!event.currentTarget.contains(event.relatedTarget) && !lastClickedElement
|
|
42
|
+
if (!event.currentTarget.contains(event.relatedTarget) && !lastClickedElement?.classList?.contains('cds--switcher__item-link')) {
|
|
43
43
|
setExpandedState(false);
|
|
44
44
|
setLastClickedElement(null);
|
|
45
45
|
if (expanded) {
|
|
@@ -57,12 +57,23 @@ const Switcher = /*#__PURE__*/React__default.forwardRef(function Switcher(props,
|
|
|
57
57
|
const switcherItem = switcherRef.current.children[nextValidIndex].children[0];
|
|
58
58
|
switcherItem?.focus();
|
|
59
59
|
};
|
|
60
|
-
const childrenWithProps = React__default.Children.toArray(children).map((child, index) =>
|
|
61
|
-
handleSwitcherItemFocus
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
const childrenWithProps = React__default.Children.toArray(children).map((child, index) => {
|
|
61
|
+
// handleSwitcherItemFocus should only be passed down if the child is a SwitcherItem
|
|
62
|
+
// SwitcherDivider, for example, does not accept a handleSwitcherItemFocus prop
|
|
63
|
+
if (child.type?.displayName === 'SwitcherItem') {
|
|
64
|
+
return /*#__PURE__*/React__default.cloneElement(child, {
|
|
65
|
+
handleSwitcherItemFocus,
|
|
66
|
+
index,
|
|
67
|
+
key: index,
|
|
68
|
+
expanded
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return /*#__PURE__*/React__default.cloneElement(child, {
|
|
72
|
+
index,
|
|
73
|
+
key: index,
|
|
74
|
+
expanded
|
|
75
|
+
});
|
|
76
|
+
});
|
|
66
77
|
return /*#__PURE__*/React__default.createElement("ul", _extends({
|
|
67
78
|
ref: ref,
|
|
68
79
|
className: className
|
|
@@ -5,46 +5,47 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
|
|
8
|
+
import { TableHTMLAttributes } from 'react';
|
|
9
|
+
export interface DataTableSkeletonHeader {
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Optionally specify header label
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
+
header?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optionally specify header key
|
|
16
|
+
*/
|
|
17
|
+
key?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface DataTableSkeletonProps extends TableHTMLAttributes<HTMLTableElement> {
|
|
13
20
|
/**
|
|
14
21
|
* Specify the number of columns that you want to render in the skeleton state
|
|
15
22
|
*/
|
|
16
|
-
columnCount
|
|
23
|
+
columnCount?: number;
|
|
17
24
|
/**
|
|
18
25
|
* Optionally specify whether you want the Skeleton to be rendered as a
|
|
19
26
|
* compact DataTable
|
|
20
27
|
*/
|
|
21
|
-
compact
|
|
28
|
+
compact?: boolean;
|
|
22
29
|
/**
|
|
23
30
|
* Optionally specify the displayed headers
|
|
24
31
|
*/
|
|
25
|
-
headers?: [
|
|
26
|
-
header: string;
|
|
27
|
-
key: string;
|
|
28
|
-
}] | {
|
|
29
|
-
header: string;
|
|
30
|
-
key: string;
|
|
31
|
-
};
|
|
32
|
+
headers?: DataTableSkeletonHeader[];
|
|
32
33
|
/**
|
|
33
34
|
* Specify the number of rows that you want to render in the skeleton state
|
|
34
35
|
*/
|
|
35
|
-
rowCount
|
|
36
|
+
rowCount?: number;
|
|
36
37
|
/**
|
|
37
38
|
* Specify if the table header should be rendered as part of the skeleton.
|
|
38
39
|
*/
|
|
39
|
-
showHeader
|
|
40
|
+
showHeader?: boolean;
|
|
40
41
|
/**
|
|
41
42
|
* Specify if the table toolbar should be rendered as part of the skeleton.
|
|
42
43
|
*/
|
|
43
|
-
showToolbar
|
|
44
|
+
showToolbar?: boolean;
|
|
44
45
|
/**
|
|
45
46
|
* Optionally specify whether you want the DataTable to be zebra striped
|
|
46
47
|
*/
|
|
47
|
-
zebra
|
|
48
|
+
zebra?: boolean;
|
|
48
49
|
}
|
|
49
50
|
declare const DataTableSkeleton: {
|
|
50
51
|
({ headers, rowCount, columnCount, zebra, compact, className, showHeader, showToolbar, ...rest }: {
|
|
@@ -51,6 +51,7 @@ const Tag = _ref => {
|
|
|
51
51
|
disabled,
|
|
52
52
|
onClose,
|
|
53
53
|
size,
|
|
54
|
+
as: BaseComponent,
|
|
54
55
|
...other
|
|
55
56
|
} = _ref;
|
|
56
57
|
const prefix = usePrefix.usePrefix();
|
|
@@ -71,7 +72,8 @@ const Tag = _ref => {
|
|
|
71
72
|
}
|
|
72
73
|
};
|
|
73
74
|
if (filter) {
|
|
74
|
-
|
|
75
|
+
const ComponentTag = BaseComponent ?? 'div';
|
|
76
|
+
return /*#__PURE__*/React__default["default"].createElement(ComponentTag, _rollupPluginBabelHelpers["extends"]({
|
|
75
77
|
className: tagClasses,
|
|
76
78
|
id: tagId
|
|
77
79
|
}, other), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
@@ -86,7 +88,7 @@ const Tag = _ref => {
|
|
|
86
88
|
title: title
|
|
87
89
|
}, _Close || (_Close = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null))));
|
|
88
90
|
}
|
|
89
|
-
const ComponentTag = other.onClick ? 'button' : 'div';
|
|
91
|
+
const ComponentTag = BaseComponent ?? (other.onClick ? 'button' : 'div');
|
|
90
92
|
return /*#__PURE__*/React__default["default"].createElement(ComponentTag, _rollupPluginBabelHelpers["extends"]({
|
|
91
93
|
disabled: ComponentTag === 'button' ? disabled : null,
|
|
92
94
|
className: tagClasses,
|
|
@@ -98,6 +100,11 @@ const Tag = _ref => {
|
|
|
98
100
|
}, children !== null && children !== undefined ? children : TYPES[type]));
|
|
99
101
|
};
|
|
100
102
|
Tag.propTypes = {
|
|
103
|
+
/**
|
|
104
|
+
* Provide an alternative tag or component to use instead of the default
|
|
105
|
+
* wrapping element
|
|
106
|
+
*/
|
|
107
|
+
as: PropTypes__default["default"].elementType,
|
|
101
108
|
/**
|
|
102
109
|
* Provide content to be rendered inside of a <Tag>
|
|
103
110
|
*/
|
|
@@ -71,7 +71,7 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
71
71
|
if (!other.disabled && onChange) {
|
|
72
72
|
// delay textCount assignation to give the textarea element value time to catch up if is a controlled input
|
|
73
73
|
setTimeout(() => {
|
|
74
|
-
setTextCount(evt.target
|
|
74
|
+
setTextCount(evt.target?.value?.length);
|
|
75
75
|
}, 0);
|
|
76
76
|
onChange(evt);
|
|
77
77
|
}
|
|
@@ -28,6 +28,10 @@ declare namespace HeaderMenuButton {
|
|
|
28
28
|
* Specify whether the menu button is "active".
|
|
29
29
|
*/
|
|
30
30
|
isActive: PropTypes.Requireable<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Specify whether the menu button is collapsible.
|
|
33
|
+
*/
|
|
34
|
+
isCollapsible: PropTypes.Requireable<boolean>;
|
|
31
35
|
/**
|
|
32
36
|
* Optionally provide an onClick handler that is called when the underlying
|
|
33
37
|
* button fires it's onclick event
|
|
@@ -74,6 +74,10 @@ HeaderMenuButton.propTypes = {
|
|
|
74
74
|
* Specify whether the menu button is "active".
|
|
75
75
|
*/
|
|
76
76
|
isActive: PropTypes__default["default"].bool,
|
|
77
|
+
/**
|
|
78
|
+
* Specify whether the menu button is collapsible.
|
|
79
|
+
*/
|
|
80
|
+
isCollapsible: PropTypes__default["default"].bool,
|
|
77
81
|
/**
|
|
78
82
|
* Optionally provide an onClick handler that is called when the underlying
|
|
79
83
|
* button fires it's onclick event
|
|
@@ -49,7 +49,7 @@ const HeaderPanel = /*#__PURE__*/React__default["default"].forwardRef(function H
|
|
|
49
49
|
const eventHandlers = {};
|
|
50
50
|
if (addFocusListeners) {
|
|
51
51
|
eventHandlers.onBlur = event => {
|
|
52
|
-
if (!event.currentTarget.contains(event.relatedTarget) && !lastClickedElement
|
|
52
|
+
if (!event.currentTarget.contains(event.relatedTarget) && !lastClickedElement?.classList?.contains('cds--switcher__item-link')) {
|
|
53
53
|
setExpandedState(false);
|
|
54
54
|
setLastClickedElement(null);
|
|
55
55
|
if (expanded) {
|
|
@@ -67,12 +67,23 @@ const Switcher = /*#__PURE__*/React__default["default"].forwardRef(function Swit
|
|
|
67
67
|
const switcherItem = switcherRef.current.children[nextValidIndex].children[0];
|
|
68
68
|
switcherItem?.focus();
|
|
69
69
|
};
|
|
70
|
-
const childrenWithProps = React__default["default"].Children.toArray(children).map((child, index) =>
|
|
71
|
-
handleSwitcherItemFocus
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
const childrenWithProps = React__default["default"].Children.toArray(children).map((child, index) => {
|
|
71
|
+
// handleSwitcherItemFocus should only be passed down if the child is a SwitcherItem
|
|
72
|
+
// SwitcherDivider, for example, does not accept a handleSwitcherItemFocus prop
|
|
73
|
+
if (child.type?.displayName === 'SwitcherItem') {
|
|
74
|
+
return /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
75
|
+
handleSwitcherItemFocus,
|
|
76
|
+
index,
|
|
77
|
+
key: index,
|
|
78
|
+
expanded
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
82
|
+
index,
|
|
83
|
+
key: index,
|
|
84
|
+
expanded
|
|
85
|
+
});
|
|
86
|
+
});
|
|
76
87
|
return /*#__PURE__*/React__default["default"].createElement("ul", _rollupPluginBabelHelpers["extends"]({
|
|
77
88
|
ref: ref,
|
|
78
89
|
className: className
|
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.33.0
|
|
4
|
+
"version": "1.33.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.18.3",
|
|
47
47
|
"@carbon/feature-flags": "^0.15.0",
|
|
48
|
-
"@carbon/icons-react": "^11.22.0
|
|
49
|
-
"@carbon/layout": "^11.16.0
|
|
50
|
-
"@carbon/styles": "^1.33.0
|
|
48
|
+
"@carbon/icons-react": "^11.22.0",
|
|
49
|
+
"@carbon/layout": "^11.16.0",
|
|
50
|
+
"@carbon/styles": "^1.33.0",
|
|
51
51
|
"@carbon/telemetry": "0.1.0",
|
|
52
52
|
"classnames": "2.3.2",
|
|
53
53
|
"copy-to-clipboard": "^3.3.1",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@babel/preset-react": "^7.22.3",
|
|
76
76
|
"@babel/preset-typescript": "^7.21.5",
|
|
77
77
|
"@carbon/test-utils": "^10.30.0",
|
|
78
|
-
"@carbon/themes": "^11.21.0
|
|
78
|
+
"@carbon/themes": "^11.21.0",
|
|
79
79
|
"@rollup/plugin-babel": "^6.0.0",
|
|
80
80
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
81
81
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
@@ -137,5 +137,5 @@
|
|
|
137
137
|
"**/*.scss",
|
|
138
138
|
"**/*.css"
|
|
139
139
|
],
|
|
140
|
-
"gitHead": "
|
|
140
|
+
"gitHead": "3a58934eed5588f5e8ee1facbb09584a41adc089"
|
|
141
141
|
}
|