carbon-react 102.4.5 → 102.6.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.
@@ -13,6 +13,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
 
14
14
  var _core = require("@popperjs/core");
15
15
 
16
+ var _styledComponents = require("styled-components");
17
+
16
18
  var _useResizeObserver = _interopRequireDefault(require("../../hooks/__internal__/useResizeObserver"));
17
19
 
18
20
  var _carbonScopedTokensProvider = require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component");
@@ -32,10 +34,11 @@ const Popover = ({
32
34
  modifiers
33
35
  }) => {
34
36
  const elementDOM = (0, _react.useRef)();
37
+ const theme = (0, _react.useContext)(_styledComponents.ThemeContext);
35
38
 
36
39
  if (!elementDOM.current && !disablePortal) {
37
40
  elementDOM.current = document.createElement("div");
38
- elementDOM.current.classList.add(_carbonScopedTokensProvider.tokensClassName);
41
+ elementDOM.current.classList.add((0, _carbonScopedTokensProvider.tokensClassName)(theme === null || theme === void 0 ? void 0 : theme.name));
39
42
  document.body.appendChild(elementDOM.current);
40
43
  }
41
44
 
@@ -19,140 +19,127 @@ function makeColors(color) {
19
19
  `;
20
20
  }
21
21
 
22
- var _default = ({
23
- colors,
24
- disabled
25
- }, isDisabled, destructive) => ({
22
+ var _default = (isDisabled, destructive) => ({
26
23
  primary: `
27
- background: ${colors.primary};
24
+ background: var(--colorsActionMajor500);
28
25
  border-color: transparent;
29
- color: ${colors.white};
26
+ ${makeColors("var(--colorsActionMajorYang100)")};
30
27
  &:hover {
31
- background: ${colors.secondary};
28
+ background: var(--colorsActionMajor600);
32
29
  }
33
30
 
34
31
  ${isDisabled ? `
35
- background: ${disabled.button};
36
- color: ${disabled.text};
32
+ background: var(--colorsActionDisabled500);
33
+ ${makeColors("var(--colorsYin030)")};
37
34
  &:hover {
38
- background: ${disabled.button};
39
- border-color: ${disabled.button};
40
- color: ${disabled.text};
35
+ background: var(--colorsActionDisabled500);
41
36
  }
42
37
  ` : ""}
43
38
 
44
- ${destructive ? `background: ${colors.error};
45
- border-color: transparent;
46
- color: ${colors.white};
39
+ ${destructive ? `background: var(--colorsSemanticNegative500);
40
+ ${makeColors("var(--colorsSemanticNegativeYang100)")};
47
41
  &:hover {
48
- background: ${colors.destructive.hover};
42
+ background: var(--colorsSemanticNegative600);
49
43
  }
50
44
 
51
45
  ${isDisabled ? `
52
- background: ${disabled.button};
53
- color: ${disabled.text};
46
+ background: var(--colorsActionDisabled500);
47
+ ${makeColors("var(--colorsYin030)")};
54
48
  &:hover {
55
- background: ${disabled.button};
56
- color: ${disabled.text};
49
+ background: var(--colorsActionDisabled500);
57
50
  }
58
51
  ` : ""}` : ""}
59
52
  `,
60
53
  secondary: `
61
54
  background: transparent;
62
- border-color: ${colors.primary};
63
- color: ${colors.primary};
55
+ border-color: var(--colorsActionMajor500);
56
+ ${makeColors("var(--colorsActionMajor500)")};
64
57
  &:hover {
65
- background: ${colors.secondary};
66
- border-color: ${colors.secondary};
67
- ${makeColors(colors.white)}
58
+ background: var(--colorsActionMajor600);
59
+ border-color: var(--colorsActionMajorTransparent);
60
+ ${makeColors("var(--colorsActionMajorYang100)")};
68
61
  }
69
62
 
70
63
  ${destructive ? `
71
- border-color: ${colors.error};
72
- ${makeColors(colors.error)}
73
- &:focus {
74
- ${makeColors(colors.white)}
75
- background: ${colors.destructive.hover};
76
- }
64
+ border-color: var(--colorsSemanticNegative500);
65
+ ${makeColors("var(--colorsSemanticNegative500)")}
77
66
  &:hover {
78
- ${makeColors(colors.white)}
79
- border-color: ${colors.destructive.hover};
80
- background: ${colors.destructive.hover};
67
+ background: var(--colorsSemanticNegative600);
68
+ border-color: var(--colorsSemanticNegativeTransparent);
69
+ ${makeColors("var(--colorsSemanticNegativeYang100)")};
81
70
  }
82
71
  ` : ""}
83
72
 
84
73
  ${isDisabled ? `
85
- border-color: ${disabled.button};
86
- color: ${disabled.text};
74
+ border-color: var(--colorsActionDisabled500);
75
+ ${makeColors("var(--colorsYin030)")};
87
76
  &:hover {
88
- background: transparent
89
- border-color: ${disabled.button};
90
- ${makeColors(disabled.text)}
77
+ background: transparent;
78
+ border-color: var(--colorsActionDisabled500);
79
+ ${makeColors("var(--colorsYin030)")};
91
80
  }
92
81
  ` : ""}
93
82
  `,
94
83
  tertiary: `
95
84
  background: transparent;
96
85
  border-color: transparent;
97
- color: ${colors.primary};
86
+ ${makeColors("var(--colorsActionMajor500)")};
98
87
  &:hover {
99
- ${makeColors(colors.secondary)}
88
+ background: var(--colorsActionMajor600);
89
+ ${makeColors("var(--colorsActionMajorYang100)")};
100
90
  }
101
91
 
102
92
  ${destructive ? `
103
- ${makeColors(colors.error)}
93
+ ${makeColors("var(--colorsSemanticNegative500)")};
104
94
  &:hover {
105
- ${makeColors(colors.destructive.hover)}
95
+ background: var(--colorsSemanticNegative600);
96
+ ${makeColors("var(--colorsSemanticNegativeYang100)")};
106
97
  }
107
98
  ` : ""}
108
99
 
109
100
  ${isDisabled ? `
110
- color: ${disabled.text};
101
+ ${makeColors("var(--colorsYin030)")};
111
102
  &:hover {
112
- ${makeColors(disabled.text)}
103
+ background: var(--colorsActionMajorTransparent);
104
+ ${makeColors("var(--colorsYin030)")};
113
105
  }
114
106
  ` : ""}
115
107
  `,
116
108
  dashed: `
117
109
  background: transparent;
118
- border: 2px solid ${colors.dashedBorder}
119
- border-style: dashed;
120
- color: ${colors.dashedButtonText};
110
+ border: 2px dashed var(--colorsActionMinor500);
111
+ ${makeColors("var(--colorsActionMinor500)")};
121
112
  &:hover {
122
- background-color: ${colors.dashedHoverBackground}
113
+ background-color: var(--colorsActionMinor200);
123
114
  }
124
115
 
125
116
  ${destructive ? `
126
- ${makeColors(colors.error)}
127
- &:hover {
128
- ${makeColors(colors.destructive.hover)}
129
- }
117
+ border-color: var(--colorsSemanticNegative500);
130
118
  ` : ""}
131
119
 
132
120
  ${isDisabled ? `
133
- border-color: ${disabled.button};
134
- color: ${disabled.text};
121
+ border-color: var(--colorsActionDisabled500);
122
+ ${makeColors("var(--colorsYin030)")};
135
123
  &:hover {
136
124
  background-color: transparent;
137
- ${makeColors(disabled.text)}
138
125
  }
139
126
  ` : ""}
140
127
  `,
141
128
  darkBackground: `
142
- background: ${colors.white};
129
+ background: var(--colorsActionMajorYang100);
143
130
  border-color: transparent;
144
- color: ${colors.primary};
131
+ ${makeColors("var(--colorsActionMajor500)")};
145
132
  &:hover {
146
- background: ${colors.secondary};
147
- ${makeColors(colors.white)}
133
+ background: var(--colorsActionMajor600);
134
+ ${makeColors("var(--colorsActionMajorYang100)")}
148
135
  }
149
136
 
150
137
  ${isDisabled ? `
151
- background: ${disabled.button};
152
- color: ${disabled.text};
138
+ background: var(--colorsActionDisabled500);
139
+ ${makeColors("var(--colorsYin030)")};
153
140
  &:hover {
154
- background: ${disabled.button};
155
- ${makeColors(disabled.text)}
141
+ background: var(--colorsActionDisabled500);
142
+ ${makeColors("var(--colorsYin030)")};
156
143
  }
157
144
  ` : ""}
158
145
  `
@@ -7,8 +7,6 @@ exports.default = exports.ButtonWithForwardRef = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
- var _styledComponents = require("styled-components");
11
-
12
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
11
 
14
12
  var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
@@ -19,8 +17,6 @@ var _button = _interopRequireWildcard(require("./button.style"));
19
17
 
20
18
  var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags/tags"));
21
19
 
22
- var _base = _interopRequireDefault(require("../../style/themes/base"));
23
-
24
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
21
 
26
22
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -39,16 +35,15 @@ function renderChildren({
39
35
  disabled,
40
36
  buttonType,
41
37
  iconTooltipMessage,
42
- iconTooltipPosition,
43
- theme
38
+ iconTooltipPosition
44
39
  /* eslint-enable */
45
40
 
46
41
  }) {
47
42
  const iconColorMap = {
48
- primary: theme.colors.white,
49
- secondary: theme.colors.primary,
50
- tertiary: theme.colors.primary,
51
- darkBackground: theme.colors.primary
43
+ primary: "var(--colorsActionMajorYang100)",
44
+ secondary: "var(--colorsActionMajor500)",
45
+ tertiary: "var(--colorsActionMajor500)",
46
+ darkBackground: "var(--colorsActionMajor500)"
52
47
  };
53
48
  const iconProps = {
54
49
  "aria-hidden": true,
@@ -74,7 +69,6 @@ const renderStyledButton = buttonProps => {
74
69
  disabled,
75
70
  buttonType,
76
71
  iconType,
77
- theme,
78
72
  href,
79
73
  ref,
80
74
  m = 0,
@@ -136,8 +130,6 @@ const renderStyledButton = buttonProps => {
136
130
  };
137
131
 
138
132
  const Button = props => {
139
- const theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _base.default;
140
-
141
133
  const {
142
134
  size,
143
135
  subtext
@@ -151,8 +143,7 @@ const Button = props => {
151
143
  } = props;
152
144
  const propsWithoutAs = { ...rest,
153
145
  buttonType: buttonType || as,
154
- ref: forwardRef || linkRef,
155
- theme
146
+ ref: forwardRef || linkRef
156
147
  };
157
148
 
158
149
  if (subtext.length > 0 && size !== "large") {
@@ -51,15 +51,6 @@ const StyledButton = _styledComponents.default.button`
51
51
  ${stylingForType}
52
52
  `}
53
53
 
54
- &&& {
55
- ${({
56
- mb,
57
- theme
58
- }) => (mb || mb === 0) && (0, _styledComponents.css)`
59
- margin-bottom: ${mb * theme.spacing}px;
60
- `}
61
- }
62
-
63
54
  ${({
64
55
  fullWidth
65
56
  }) => fullWidth && (0, _styledComponents.css)`
@@ -68,12 +59,11 @@ const StyledButton = _styledComponents.default.button`
68
59
 
69
60
  ${({
70
61
  iconOnly,
71
- iconPosition,
72
- theme
62
+ iconPosition
73
63
  }) => (0, _styledComponents.css)`
74
64
  ${_icon.default} {
75
- margin-left: ${!iconOnly && iconPosition === "after" ? `${theme.spacing}px` : "0px"};
76
- margin-right: ${!iconOnly && iconPosition === "before" ? `${theme.spacing}px` : "0px"};
65
+ margin-left: ${!iconOnly && iconPosition === "after" ? "var(--spacing100)" : "0px"};
66
+ margin-right: ${!iconOnly && iconPosition === "before" ? "var(--spacing100)" : "0px"};
77
67
  margin-bottom: ${iconOnly ? "1px" : "0px"};
78
68
  height: ${additionalIconStyle};
79
69
  svg {
@@ -123,7 +113,6 @@ function stylingForType({
123
113
  iconOnly,
124
114
  disabled,
125
115
  buttonType,
126
- theme,
127
116
  size,
128
117
  destructive
129
118
  }) {
@@ -133,18 +122,18 @@ function stylingForType({
133
122
  font-weight: 600;
134
123
  text-decoration: none;
135
124
  &:focus {
136
- outline: solid 3px ${theme.colors.focus};
125
+ outline: solid 3px var(--colorsSemanticFocus500);
137
126
  }
138
127
 
139
- ${(0, _buttonTypes.default)(theme, disabled, destructive)[buttonType]};
128
+ ${(0, _buttonTypes.default)(disabled, destructive)[buttonType]};
140
129
 
141
130
  ${size === "small" && (0, _styledComponents.css)`
142
- font-size: ${theme.text.size};
131
+ font-size: var(--fontSizes100);
143
132
  min-height: 32px;
144
133
  `}
145
134
 
146
135
  ${size === "medium" && (0, _styledComponents.css)`
147
- font-size: ${theme.text.size};
136
+ font-size: var(--fontSizes100);
148
137
  min-height: 40px;
149
138
  `}
150
139
 
@@ -171,15 +160,27 @@ StyledButton.propTypes = {
171
160
  /** The text the button displays */
172
161
  children: _propTypes.default.node.isRequired,
173
162
 
163
+ /** Apply destructive style to the button */
164
+ destructive: _propTypes.default.bool,
165
+
174
166
  /** Apply disabled state to the button */
175
167
  disabled: _propTypes.default.bool,
176
168
 
169
+ /** Apply fullWidth style to the button */
170
+ fullWidth: _propTypes.default.bool,
171
+
172
+ /** Apply iconOnly to display button with the icon only */
173
+ iconOnly: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string]),
174
+
177
175
  /** Defines an Icon position within the button */
178
176
  iconPosition: _propTypes.default.oneOf([..._button.BUTTON_ICON_POSITIONS, ""]),
179
177
 
180
178
  /** Defines an Icon type within the button (see Icon for options) */
181
179
  iconType: _propTypes.default.oneOf([..._iconConfig.ICONS, ""]),
182
180
 
181
+ /** If provided, the text inside a button will not wrap */
182
+ noWrap: _propTypes.default.bool,
183
+
183
184
  /** Assigns a size to the button */
184
185
  size: _propTypes.default.oneOf(_button.BUTTON_SIZES),
185
186
 
@@ -77,6 +77,9 @@ const StyledIcon = _styledComponents.default.span`
77
77
  if (disabled) {
78
78
  finalColor = theme.icon.disabled;
79
79
  finalHoverColor = theme.icon.disabled;
80
+ } else if (typeof color === "string" && color.startsWith("var")) {
81
+ finalColor = color;
82
+ finalHoverColor = (0, _polished.shade)(0.2, theme.compatibility[color.replace("var(--", "").replace(")", "")]);
80
83
  } else if (color) {
81
84
  const {
82
85
  color: renderedColor
@@ -9,11 +9,9 @@ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _row = require("../row");
13
-
14
12
  var _label = _interopRequireDefault(require("../../__internal__/label"));
15
13
 
16
- var _inlineInputs = _interopRequireDefault(require("./inline-inputs.style"));
14
+ var _inlineInputs = _interopRequireWildcard(require("./inline-inputs.style"));
17
15
 
18
16
  var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
19
17
 
@@ -23,9 +21,7 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
23
21
 
24
22
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
23
 
26
- 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); }
27
-
28
- const columnWrapper = children => {
24
+ const columnWrapper = (children, gutter) => {
29
25
  let inputs = children;
30
26
 
31
27
  if (!Array.isArray(inputs)) {
@@ -36,8 +32,10 @@ const columnWrapper = children => {
36
32
  // Input is never going to be re-ordered so we don't require a defined key
37
33
 
38
34
  /* eslint-disable react/no-array-index-key */
39
- return /*#__PURE__*/_react.default.createElement(_row.Column, {
40
- key: index
35
+ return /*#__PURE__*/_react.default.createElement(_inlineInputs.StyledInlineInput, {
36
+ key: index,
37
+ gutter: gutter,
38
+ "data-element": "inline-input"
41
39
  }, input);
42
40
  });
43
41
  };
@@ -53,14 +51,6 @@ const InlineInputs = props => {
53
51
  labelWidth
54
52
  } = props;
55
53
  const labelId = (0, _react.useRef)((0, _guid.default)());
56
- const widthProps = {
57
- inputWidth
58
- };
59
-
60
- if (labelWidth) {
61
- widthProps.labelWidth = labelWidth;
62
- widthProps.inputWidth = inputWidth || 100 - labelWidth;
63
- }
64
54
 
65
55
  function renderLabel() {
66
56
  if (!label) return null;
@@ -78,13 +68,16 @@ const InlineInputs = props => {
78
68
  }));
79
69
  }
80
70
 
81
- return /*#__PURE__*/_react.default.createElement(_inlineInputs.default, _extends({
71
+ return /*#__PURE__*/_react.default.createElement(_inlineInputs.default, {
82
72
  gutter: gutter,
83
73
  "data-component": "inline-inputs",
84
- className: className
85
- }, widthProps), renderLabel(), /*#__PURE__*/_react.default.createElement(_row.Row, {
86
- gutter: gutter
87
- }, columnWrapper(renderChildren())));
74
+ className: className,
75
+ labelWidth: labelWidth
76
+ }, renderLabel(), /*#__PURE__*/_react.default.createElement(_inlineInputs.StyledContentContainer, {
77
+ gutter: gutter,
78
+ "data-element": "inline-inputs-container",
79
+ inputWidth: inputWidth
80
+ }, columnWrapper(renderChildren(), gutter)));
88
81
  }; // Assign props over for demo site
89
82
 
90
83
 
@@ -3,14 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.StyledInlineInput = exports.StyledContentContainer = void 0;
7
7
 
8
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
9
 
10
- var _row = _interopRequireDefault(require("../row/row.style"));
11
-
12
- var _column = _interopRequireDefault(require("../row/column/column.style"));
13
-
14
10
  var _inputPresentation = _interopRequireDefault(require("../../__internal__/input/input-presentation.style"));
15
11
 
16
12
  var _label = require("../../__internal__/label/label.style");
@@ -33,20 +29,46 @@ const spacings = {
33
29
  large: 32,
34
30
  "extra-large": 40
35
31
  };
36
- const StyledInlineInputs = _styledComponents.default.div`
37
- display: flex;
38
- align-items: center;
32
+ const StyledInlineInput = _styledComponents.default.div`
33
+ flex: 1;
39
34
 
40
35
  ${({
36
+ gutter
37
+ }) => (0, _styledComponents.css)`
38
+ margin-bottom: 0;
39
+ padding-left: ${spacings[gutter]}px;
40
+ `}
41
+ `;
42
+ exports.StyledInlineInput = StyledInlineInput;
43
+ const StyledContentContainer = _styledComponents.default.div`
44
+ display: flex;
45
+ flex: ${({
41
46
  inputWidth
42
- }) => inputWidth && `
43
- flex: 0 0 ${inputWidth}%;
44
- `}
47
+ }) => inputWidth ? `0 0 ${inputWidth}%` : 1};
48
+
49
+ ${({
50
+ gutter
51
+ }) => (0, _styledComponents.css)`
52
+ margin-bottom: 0;
53
+ margin-left: -${spacings[gutter]}px;
54
+
55
+ ${gutter === "none" && (0, _styledComponents.css)`
56
+ ${StyledInlineInput} + ${StyledInlineInput} ${_inputPresentation.default} {
57
+ border-left: none;
58
+ }
59
+ `}
60
+ `}
61
+ `;
62
+ exports.StyledContentContainer = StyledContentContainer;
63
+ const StyledInlineInputs = _styledComponents.default.div`
64
+ display: flex;
65
+ align-items: center;
45
66
 
46
67
  ${_label.StyledLabelContainer} {
68
+ width: auto;
47
69
  margin-bottom: 0;
48
70
  padding-right: 16px;
49
- width: ${({
71
+ flex: 0 0 ${({
50
72
  labelWidth
51
73
  }) => labelWidth ? `${labelWidth}%` : "auto"};
52
74
  }
@@ -58,30 +80,6 @@ const StyledInlineInputs = _styledComponents.default.div`
58
80
  [data-component="carbon-select"] input {
59
81
  width: 30px;
60
82
  }
61
-
62
- ${_row.default} {
63
- flex-grow: 1;
64
- }
65
-
66
- ${({
67
- gutter
68
- }) => (0, _styledComponents.css)`
69
- ${_row.default} {
70
- margin-bottom: 0;
71
- margin-left: -${spacings[gutter]}px;
72
-
73
- > ${_column.default} {
74
- margin-bottom: 0;
75
- padding-left: ${spacings[gutter]}px;
76
- }
77
- }
78
-
79
- ${gutter === "none" && (0, _styledComponents.css)`
80
- ${_column.default} + ${_column.default} ${_inputPresentation.default} {
81
- border-left: none;
82
- }
83
- `}
84
- `}
85
83
  `;
86
84
  StyledInlineInputs.defaultProps = {
87
85
  theme: _base.default
@@ -17,7 +17,7 @@ const StyledPage = _styledComponents.default.article`
17
17
  `;
18
18
  exports.StyledPage = StyledPage;
19
19
  const StyledPageContent = _styledComponents.default.div`
20
- box-sizing: content-box;
20
+ box-sizing: border-box;
21
21
  padding: 30px 40px;
22
22
  width: 100%;
23
23
  height: 100%;
@@ -11,6 +11,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  var _reactDom = _interopRequireDefault(require("react-dom"));
13
13
 
14
+ var _styledComponents = require("styled-components");
15
+
14
16
  var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
15
17
 
16
18
  var _browser = _interopRequireDefault(require("../../__internal__/utils/helpers/browser"));
@@ -31,6 +33,7 @@ const Portal = ({
31
33
  }) => {
32
34
  const [portalNode, setPortalNode] = (0, _react.useState)(null);
33
35
  const uniqueId = (0, _react.useMemo)(() => (0, _guid.default)(), []);
36
+ const theme = (0, _react.useContext)(_styledComponents.ThemeContext);
34
37
  (0, _react.useEffect)(() => {
35
38
  if (onReposition) {
36
39
  onReposition();
@@ -65,7 +68,7 @@ const Portal = ({
65
68
  setPortalNode(node);
66
69
  } else if (!node) {
67
70
  node = document.createElement("div");
68
- node.classList.add(portalClassName, _carbonScopedTokensProvider.tokensClassName);
71
+ node.classList.add(portalClassName, (0, _carbonScopedTokensProvider.tokensClassName)((theme === null || theme === void 0 ? void 0 : theme.name) || ""));
69
72
  node.setAttribute("data-portal-exit", uniqueId);
70
73
 
71
74
  if (id !== undefined) {
@@ -19,25 +19,34 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
 
22
- 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); }
23
-
24
22
  /**
25
23
  *
26
24
  * Converts theme properties to css variables form and set them locally for
27
25
  * given scope
28
26
  *
29
27
  */
30
- const tokensClassName = `sageDesignTokens-${(0, _guid.default)()}`;
28
+ const activeThemes = {};
29
+ const carbonInstanceId = (0, _guid.default)();
30
+
31
+ const kebabCase = input => input && input.toString().toLowerCase().match(/\w*/gm).filter(Boolean).join("-");
32
+
33
+ const tokensClassName = theme => `sage-design-tokens-${kebabCase(theme)}-${carbonInstanceId}`;
34
+
31
35
  exports.tokensClassName = tokensClassName;
32
36
  const GlobalTokens = (0, _styledComponents.createGlobalStyle)`
33
- .${tokensClassName} {
34
- ${({
37
+ ${({
35
38
  theme
36
- }) => (0, _generateCssVariables.default)(theme.compatibility)}
37
- }
38
- `;
39
+ }) => {
40
+ const className = tokensClassName(theme.name);
41
+ activeThemes[className] = activeThemes[className] || (0, _generateCssVariables.default)(theme.compatibility);
42
+ return Object.entries(activeThemes).reduce((acc, [name, definitions]) => `${acc} .${name} { ${definitions} }`, "");
43
+ }}`;
39
44
  exports.GlobalTokens = GlobalTokens;
40
- const TokensProviderWrapper = _styledComponents.default.div`
45
+ const TokensProviderWrapper = _styledComponents.default.div.attrs(({
46
+ theme
47
+ }) => ({
48
+ className: tokensClassName(theme.name)
49
+ }))`
41
50
  margin: 0;
42
51
  padding: 0;
43
52
  width: auto;
@@ -45,14 +54,8 @@ const TokensProviderWrapper = _styledComponents.default.div`
45
54
  `;
46
55
 
47
56
  const CarbonScopedTokensProvider = ({
48
- children,
49
- theme,
50
- ...props
51
- }) => /*#__PURE__*/_react.default.createElement(TokensProviderWrapper, _extends({}, props, {
52
- className: tokensClassName
53
- }), /*#__PURE__*/_react.default.createElement(GlobalTokens, {
54
- theme: theme
55
- }), children);
57
+ children
58
+ }) => /*#__PURE__*/_react.default.createElement(TokensProviderWrapper, null, /*#__PURE__*/_react.default.createElement(GlobalTokens, null), children);
56
59
 
57
60
  var _default = CarbonScopedTokensProvider;
58
61
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "102.4.5",
3
+ "version": "102.6.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {