carbon-react 119.3.1 → 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.
@@ -36,13 +36,14 @@ function renderChildren(_ref) {
36
36
  bg: "transparent",
37
37
  bgSize: "extra-small"
38
38
  };
39
- return /*#__PURE__*/React.createElement(React.Fragment, null, iconType && iconPosition === "before" && children && /*#__PURE__*/React.createElement(Icon, _extends({
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)), children && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", {
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 && !children && /*#__PURE__*/React.createElement(TooltipProvider, {
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
- !!!(children || 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
+ !(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": !children && iconType ? ariaLabel || iconType : ariaLabel,
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: !!(!children && iconType),
148
+ iconOnly: !isValidChildren && !!iconType,
147
149
  iconPosition: iconPosition,
148
150
  target: target,
149
151
  rel: rel,
@@ -45,13 +45,14 @@ function renderChildren(_ref) {
45
45
  bg: "transparent",
46
46
  bgSize: "extra-small"
47
47
  };
48
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, iconType && iconPosition === "before" && children && /*#__PURE__*/_react.default.createElement(_icon.default, _extends({
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)), children && /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement("span", {
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 && !children && /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
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
- !!!(children || 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
+ !(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": !children && iconType ? ariaLabel || iconType : ariaLabel,
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: !!(!children && iconType),
157
+ iconOnly: !isValidChildren && !!iconType,
156
158
  iconPosition: iconPosition,
157
159
  target: target,
158
160
  rel: rel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "119.3.1",
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",