carbon-react 119.3.0 → 119.3.2
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/esm/components/button/button.component.js +8 -6
- package/esm/components/flat-table/flat-table.component.js +2 -2
- package/esm/components/flat-table/flat-table.style.js +0 -3
- package/lib/components/button/button.component.js +8 -6
- package/lib/components/flat-table/flat-table.component.js +2 -2
- package/lib/components/flat-table/flat-table.style.js +0 -3
- package/package.json +3 -3
|
@@ -36,13 +36,14 @@ function renderChildren(_ref) {
|
|
|
36
36
|
bg: "transparent",
|
|
37
37
|
bgSize: "extra-small"
|
|
38
38
|
};
|
|
39
|
-
|
|
39
|
+
const isValidChildren = children !== undefined && children !== false;
|
|
40
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, iconType && iconPosition === "before" && isValidChildren && /*#__PURE__*/React.createElement(Icon, _extends({
|
|
40
41
|
type: iconType
|
|
41
|
-
}, iconProps)),
|
|
42
|
+
}, iconProps)), isValidChildren && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", {
|
|
42
43
|
"data-element": "main-text"
|
|
43
44
|
}, children), size === "large" && /*#__PURE__*/React.createElement(StyledButtonSubtext, {
|
|
44
45
|
"data-element": "subtext"
|
|
45
|
-
}, subtext)), iconType && !
|
|
46
|
+
}, subtext)), iconType && !isValidChildren && /*#__PURE__*/React.createElement(TooltipProvider, {
|
|
46
47
|
disabled: disabled,
|
|
47
48
|
focusable: false,
|
|
48
49
|
target: tooltipTarget
|
|
@@ -90,7 +91,7 @@ const Button = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
90
91
|
const size = sizeContext || sizeProp;
|
|
91
92
|
const iconPosition = iconPositionContext || iconPositionProp;
|
|
92
93
|
const fullWidth = fullWidthContext || fullWidthProp;
|
|
93
|
-
|
|
94
|
+
!(children !== undefined || !!iconType) ? process.env.NODE_ENV !== "production" ? invariant(false, "Either prop `iconType` must be defined or this node must have children.") : invariant(false) : void 0;
|
|
94
95
|
if (subtext) {
|
|
95
96
|
!(size === "large") ? process.env.NODE_ENV !== "production" ? invariant(false, "subtext prop has no effect unless the button is large.") : invariant(false) : void 0;
|
|
96
97
|
}
|
|
@@ -128,8 +129,9 @@ const Button = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
128
129
|
if (typeof activeRef === "object") activeRef.current = reference;
|
|
129
130
|
if (typeof activeRef === "function") activeRef(reference);
|
|
130
131
|
}, [ref, forwardRef]);
|
|
132
|
+
const isValidChildren = children !== undefined && children !== false;
|
|
131
133
|
return /*#__PURE__*/React.createElement(StyledButton, _extends({
|
|
132
|
-
"aria-label": !
|
|
134
|
+
"aria-label": !isValidChildren && iconType ? ariaLabel || iconType : ariaLabel,
|
|
133
135
|
as: !disabled && href ? "a" : "button",
|
|
134
136
|
onKeyDown: href ? handleLinkKeyDown : undefined,
|
|
135
137
|
draggable: false,
|
|
@@ -143,7 +145,7 @@ const Button = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
143
145
|
px: px ?? paddingX,
|
|
144
146
|
m: m,
|
|
145
147
|
noWrap: noWrap,
|
|
146
|
-
iconOnly:
|
|
148
|
+
iconOnly: !isValidChildren && !!iconType,
|
|
147
149
|
iconPosition: iconPosition,
|
|
148
150
|
target: target,
|
|
149
151
|
rel: rel,
|
|
@@ -175,9 +175,9 @@ const FlatTable = _ref => {
|
|
|
175
175
|
setSelectedId,
|
|
176
176
|
selectedId
|
|
177
177
|
}
|
|
178
|
-
}, children)), footer && /*#__PURE__*/React.createElement(StyledFlatTableFooter, {
|
|
178
|
+
}, children))), footer && /*#__PURE__*/React.createElement(StyledFlatTableFooter, {
|
|
179
179
|
hasStickyFooter: hasStickyFooter
|
|
180
|
-
}, footer))
|
|
180
|
+
}, footer));
|
|
181
181
|
});
|
|
182
182
|
};
|
|
183
183
|
FlatTable.propTypes = {
|
|
@@ -45,13 +45,14 @@ function renderChildren(_ref) {
|
|
|
45
45
|
bg: "transparent",
|
|
46
46
|
bgSize: "extra-small"
|
|
47
47
|
};
|
|
48
|
-
|
|
48
|
+
const isValidChildren = children !== undefined && children !== false;
|
|
49
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, iconType && iconPosition === "before" && isValidChildren && /*#__PURE__*/_react.default.createElement(_icon.default, _extends({
|
|
49
50
|
type: iconType
|
|
50
|
-
}, iconProps)),
|
|
51
|
+
}, iconProps)), isValidChildren && /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement("span", {
|
|
51
52
|
"data-element": "main-text"
|
|
52
53
|
}, children), size === "large" && /*#__PURE__*/_react.default.createElement(_button.StyledButtonSubtext, {
|
|
53
54
|
"data-element": "subtext"
|
|
54
|
-
}, subtext)), iconType && !
|
|
55
|
+
}, subtext)), iconType && !isValidChildren && /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
|
|
55
56
|
disabled: disabled,
|
|
56
57
|
focusable: false,
|
|
57
58
|
target: tooltipTarget
|
|
@@ -99,7 +100,7 @@ const Button = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
99
100
|
const size = sizeContext || sizeProp;
|
|
100
101
|
const iconPosition = iconPositionContext || iconPositionProp;
|
|
101
102
|
const fullWidth = fullWidthContext || fullWidthProp;
|
|
102
|
-
|
|
103
|
+
!(children !== undefined || !!iconType) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "Either prop `iconType` must be defined or this node must have children.") : (0, _invariant.default)(false) : void 0;
|
|
103
104
|
if (subtext) {
|
|
104
105
|
!(size === "large") ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "subtext prop has no effect unless the button is large.") : (0, _invariant.default)(false) : void 0;
|
|
105
106
|
}
|
|
@@ -137,8 +138,9 @@ const Button = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
137
138
|
if (typeof activeRef === "object") activeRef.current = reference;
|
|
138
139
|
if (typeof activeRef === "function") activeRef(reference);
|
|
139
140
|
}, [ref, forwardRef]);
|
|
141
|
+
const isValidChildren = children !== undefined && children !== false;
|
|
140
142
|
return /*#__PURE__*/_react.default.createElement(_button.default, _extends({
|
|
141
|
-
"aria-label": !
|
|
143
|
+
"aria-label": !isValidChildren && iconType ? ariaLabel || iconType : ariaLabel,
|
|
142
144
|
as: !disabled && href ? "a" : "button",
|
|
143
145
|
onKeyDown: href ? handleLinkKeyDown : undefined,
|
|
144
146
|
draggable: false,
|
|
@@ -152,7 +154,7 @@ const Button = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
152
154
|
px: px ?? paddingX,
|
|
153
155
|
m: m,
|
|
154
156
|
noWrap: noWrap,
|
|
155
|
-
iconOnly:
|
|
157
|
+
iconOnly: !isValidChildren && !!iconType,
|
|
156
158
|
iconPosition: iconPosition,
|
|
157
159
|
target: target,
|
|
158
160
|
rel: rel,
|
|
@@ -185,9 +185,9 @@ const FlatTable = _ref => {
|
|
|
185
185
|
setSelectedId,
|
|
186
186
|
selectedId
|
|
187
187
|
}
|
|
188
|
-
}, children)), footer && /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTableFooter, {
|
|
188
|
+
}, children))), footer && /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTableFooter, {
|
|
189
189
|
hasStickyFooter: hasStickyFooter
|
|
190
|
-
}, footer))
|
|
190
|
+
}, footer));
|
|
191
191
|
});
|
|
192
192
|
};
|
|
193
193
|
FlatTable.propTypes = {
|
|
@@ -22,9 +22,6 @@ const HEADER_OVERLAY_INCREMENT = 3;
|
|
|
22
22
|
const STICKY_FOOTER_OVERLAY_INCREMENT = 1;
|
|
23
23
|
const ROW_HEADER_OVERLAY_INCREMENT = 5;
|
|
24
24
|
const StyledTableContainer = _styledComponents.default.div`
|
|
25
|
-
display: grid;
|
|
26
|
-
grid-auto-rows: min-content;
|
|
27
|
-
|
|
28
25
|
${_ref => {
|
|
29
26
|
let {
|
|
30
27
|
width,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "119.3.
|
|
3
|
+
"version": "119.3.2",
|
|
4
4
|
"description": "A library of reusable React components for easily building user interfaces.",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"test": "jest --config=./jest.config.json",
|
|
15
15
|
"test-update": "jest --config=./jest.config.json --updateSnapshot",
|
|
16
16
|
"cypress:react": "npx cypress open --component --browser chrome",
|
|
17
|
-
"format": "prettier --write './src/**/*.{js,jsx,ts,tsx}'",
|
|
18
|
-
"lint": "eslint ./src",
|
|
17
|
+
"format": "prettier --write './{src,cypress}/**/*.{js,jsx,ts,tsx}'",
|
|
18
|
+
"lint": "eslint ./src ./cypress",
|
|
19
19
|
"build": "node ./scripts/build.js",
|
|
20
20
|
"copy-files": "node ./scripts/copy-files.js",
|
|
21
21
|
"precompile": "npm run type-check && npm run clean-lib && npm run build && npm run build:types && npm run copy-files",
|