carbon-react 104.36.0 → 104.38.1

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.
@@ -1,6 +1,6 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
- import React, { useState } from "react";
3
+ import React, { useState, useCallback } from "react";
4
4
  import PropTypes from "prop-types";
5
5
  import propTypes from "@styled-system/prop-types";
6
6
  import Icon from "../icon";
@@ -102,6 +102,12 @@ const Button = ({
102
102
  paddingX = 3;
103
103
  }
104
104
 
105
+ const setRefs = useCallback(reference => {
106
+ setInternalRef(reference);
107
+ if (!forwardRef) return;
108
+ if (typeof forwardRef === "object") forwardRef.current = reference;
109
+ if (typeof forwardRef === "function") forwardRef(reference);
110
+ }, [forwardRef]);
105
111
  return /*#__PURE__*/React.createElement(StyledButton, _extends({
106
112
  "aria-label": !children && iconType ? ariaLabel || iconType : undefined,
107
113
  as: !disabled && href ? "a" : "button",
@@ -123,14 +129,7 @@ const Button = ({
123
129
  }, tagComponent("button", rest), rest, href && {
124
130
  href
125
131
  }, {
126
- ref: reference => {
127
- if (reference) {
128
- setInternalRef(reference);
129
- if (!forwardRef) return;
130
- if (typeof forwardRef === "object") forwardRef.current = reference;
131
- if (typeof forwardRef === "function") forwardRef(reference);
132
- }
133
- }
132
+ ref: setRefs
134
133
  }), renderChildren({
135
134
  iconType,
136
135
  iconPosition,
@@ -1,7 +1,6 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import PropTypes from "prop-types";
3
3
  import StyledIcon from "../icon/icon.style";
4
- import baseTheme from "../../style/themes/base";
5
4
  import { StyledHeadingTitle } from "../heading/heading.style";
6
5
  export const StyledConfirmButtons = styled.div`
7
6
  margin-top: 48px;
@@ -22,12 +21,12 @@ export const StyledConfirmHeading = styled.div`
22
21
  ${({
23
22
  type
24
23
  }) => type === "warning" && css`
25
- color: ${baseTheme.colors.warning};
24
+ color: var(--colorsSemanticCaution500);
26
25
  `}
27
26
  ${({
28
27
  type
29
28
  }) => type === "error" && css`
30
- color: ${baseTheme.colors.error};
29
+ color: var(--colorsSemanticNegative500);
31
30
  `}
32
31
  }
33
32
  `;
@@ -6,9 +6,7 @@ const StyledHr = styled.hr`
6
6
  width: inherit;
7
7
  border: 0;
8
8
  height: 1px;
9
- background: ${({
10
- theme
11
- }) => theme.hr.background};
9
+ background: var(--colorsUtilityMajor100);
12
10
  `;
13
11
  StyledHr.defaultProps = {
14
12
  theme: baseTheme
@@ -1,6 +1,6 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
- import React, { useState } from "react";
3
+ import React, { useState, useCallback } from "react";
4
4
  import PropTypes from "prop-types";
5
5
  import styledSystemPropTypes from "@styled-system/prop-types";
6
6
  import Events from "../../__internal__/utils/helpers/events";
@@ -32,18 +32,17 @@ const IconButton = /*#__PURE__*/React.forwardRef(({
32
32
  onAction(e);
33
33
  };
34
34
 
35
+ const setRefs = useCallback(reference => {
36
+ setInternalRef(reference);
37
+ if (!ref) return;
38
+ if (typeof ref === "object") ref.current = reference;
39
+ if (typeof ref === "function") ref(reference);
40
+ }, [ref]);
35
41
  return /*#__PURE__*/React.createElement(StyledIconButton, _extends({}, rest, {
36
42
  "aria-label": ariaLabel,
37
43
  onKeyDown: onKeyDown,
38
44
  onClick: handleOnAction,
39
- ref: reference => {
40
- if (reference) {
41
- setInternalRef(reference);
42
- if (!ref) return;
43
- if (typeof ref === "object") ref.current = reference;
44
- if (typeof ref === "function") ref(reference);
45
- }
46
- },
45
+ ref: setRefs,
47
46
  disabled: disabled
48
47
  }, marginProps), /*#__PURE__*/React.createElement(TooltipProvider, {
49
48
  disabled: disabled,
@@ -165,7 +165,7 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
165
165
 
166
166
  isClickTriggeredBySelect.current = false;
167
167
  }, [isOpen]);
168
- const mapValuesToPills = useCallback(() => {
168
+ const mapValuesToPills = useMemo(() => {
169
169
  const canDelete = !disabled && !readOnly;
170
170
 
171
171
  if (!selectedValue.length) {
@@ -384,7 +384,7 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
384
384
  disabled,
385
385
  readOnly,
386
386
  placeholder: placeholderOverride,
387
- leftChildren: mapValuesToPills(),
387
+ leftChildren: mapValuesToPills,
388
388
  inputRef: assignInput,
389
389
  formattedValue: textValue,
390
390
  selectedValue,
@@ -1,17 +1,11 @@
1
1
  import styled from "styled-components";
2
2
  import { StyledAccordionContentContainer, StyledAccordionContent } from "../../../accordion/accordion.style";
3
- import baseTheme from "../../../../style/themes/base";
4
3
  const StyledContentContainer = styled(StyledAccordionContentContainer)`
5
- background-color: ${({
6
- theme
7
- }) => theme.tileSelect.hoverBackground};
4
+ background-color: var(--colorsActionMinor050);
8
5
  `;
9
6
  const StyledContent = styled(StyledAccordionContent)`
10
7
  padding: 24px;
11
8
  position: relative;
12
9
  z-index: 200;
13
10
  `;
14
- StyledContentContainer.defaultProps = {
15
- theme: baseTheme
16
- };
17
11
  export { StyledContentContainer, StyledContent };
@@ -121,6 +121,12 @@ const Button = ({
121
121
  paddingX = 3;
122
122
  }
123
123
 
124
+ const setRefs = (0, _react.useCallback)(reference => {
125
+ setInternalRef(reference);
126
+ if (!forwardRef) return;
127
+ if (typeof forwardRef === "object") forwardRef.current = reference;
128
+ if (typeof forwardRef === "function") forwardRef(reference);
129
+ }, [forwardRef]);
124
130
  return /*#__PURE__*/_react.default.createElement(_button.default, _extends({
125
131
  "aria-label": !children && iconType ? ariaLabel || iconType : undefined,
126
132
  as: !disabled && href ? "a" : "button",
@@ -142,14 +148,7 @@ const Button = ({
142
148
  }, (0, _tags.default)("button", rest), rest, href && {
143
149
  href
144
150
  }, {
145
- ref: reference => {
146
- if (reference) {
147
- setInternalRef(reference);
148
- if (!forwardRef) return;
149
- if (typeof forwardRef === "object") forwardRef.current = reference;
150
- if (typeof forwardRef === "function") forwardRef(reference);
151
- }
152
- }
151
+ ref: setRefs
153
152
  }), renderChildren({
154
153
  iconType,
155
154
  iconPosition,
@@ -11,8 +11,6 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  var _icon = _interopRequireDefault(require("../icon/icon.style"));
13
13
 
14
- var _base = _interopRequireDefault(require("../../style/themes/base"));
15
-
16
14
  var _heading = require("../heading/heading.style");
17
15
 
18
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -41,12 +39,12 @@ const StyledConfirmHeading = _styledComponents.default.div`
41
39
  ${({
42
40
  type
43
41
  }) => type === "warning" && (0, _styledComponents.css)`
44
- color: ${_base.default.colors.warning};
42
+ color: var(--colorsSemanticCaution500);
45
43
  `}
46
44
  ${({
47
45
  type
48
46
  }) => type === "error" && (0, _styledComponents.css)`
49
- color: ${_base.default.colors.error};
47
+ color: var(--colorsSemanticNegative500);
50
48
  `}
51
49
  }
52
50
  `;
@@ -18,9 +18,7 @@ const StyledHr = _styledComponents.default.hr`
18
18
  width: inherit;
19
19
  border: 0;
20
20
  height: 1px;
21
- background: ${({
22
- theme
23
- }) => theme.hr.background};
21
+ background: var(--colorsUtilityMajor100);
24
22
  `;
25
23
  StyledHr.defaultProps = {
26
24
  theme: _base.default
@@ -54,18 +54,17 @@ const IconButton = /*#__PURE__*/_react.default.forwardRef(({
54
54
  onAction(e);
55
55
  };
56
56
 
57
+ const setRefs = (0, _react.useCallback)(reference => {
58
+ setInternalRef(reference);
59
+ if (!ref) return;
60
+ if (typeof ref === "object") ref.current = reference;
61
+ if (typeof ref === "function") ref(reference);
62
+ }, [ref]);
57
63
  return /*#__PURE__*/_react.default.createElement(_iconButton.default, _extends({}, rest, {
58
64
  "aria-label": ariaLabel,
59
65
  onKeyDown: onKeyDown,
60
66
  onClick: handleOnAction,
61
- ref: reference => {
62
- if (reference) {
63
- setInternalRef(reference);
64
- if (!ref) return;
65
- if (typeof ref === "object") ref.current = reference;
66
- if (typeof ref === "function") ref(reference);
67
- }
68
- },
67
+ ref: setRefs,
69
68
  disabled: disabled
70
69
  }, marginProps), /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
71
70
  disabled: disabled,
@@ -191,7 +191,7 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
191
191
 
192
192
  isClickTriggeredBySelect.current = false;
193
193
  }, [isOpen]);
194
- const mapValuesToPills = (0, _react.useCallback)(() => {
194
+ const mapValuesToPills = (0, _react.useMemo)(() => {
195
195
  const canDelete = !disabled && !readOnly;
196
196
 
197
197
  if (!selectedValue.length) {
@@ -411,7 +411,7 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
411
411
  disabled,
412
412
  readOnly,
413
413
  placeholder: placeholderOverride,
414
- leftChildren: mapValuesToPills(),
414
+ leftChildren: mapValuesToPills,
415
415
  inputRef: assignInput,
416
416
  formattedValue: textValue,
417
417
  selectedValue,
@@ -9,14 +9,10 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
9
 
10
10
  var _accordion = require("../../../accordion/accordion.style");
11
11
 
12
- var _base = _interopRequireDefault(require("../../../../style/themes/base"));
13
-
14
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
13
 
16
14
  const StyledContentContainer = (0, _styledComponents.default)(_accordion.StyledAccordionContentContainer)`
17
- background-color: ${({
18
- theme
19
- }) => theme.tileSelect.hoverBackground};
15
+ background-color: var(--colorsActionMinor050);
20
16
  `;
21
17
  exports.StyledContentContainer = StyledContentContainer;
22
18
  const StyledContent = (0, _styledComponents.default)(_accordion.StyledAccordionContent)`
@@ -24,7 +20,4 @@ const StyledContent = (0, _styledComponents.default)(_accordion.StyledAccordionC
24
20
  position: relative;
25
21
  z-index: 200;
26
22
  `;
27
- exports.StyledContent = StyledContent;
28
- StyledContentContainer.defaultProps = {
29
- theme: _base.default
30
- };
23
+ exports.StyledContent = StyledContent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "104.36.0",
3
+ "version": "104.38.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {