carbon-react 94.7.0 → 95.0.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.
@@ -58,7 +58,7 @@ const CheckableInput = ({
58
58
  const {
59
59
  current: id
60
60
  } = (0, _react.useRef)(inputId || (0, _guid.default)());
61
- const labelId = `${id}-label`;
61
+ const labelId = label ? `${id}-label` : undefined;
62
62
  const helpId = [error, warning, info, labelHelp].filter(validation => typeof validation === "string").length ? `${id}-help` : undefined;
63
63
  const fieldHelpId = fieldHelp ? `${id}-field-help` : undefined;
64
64
  const isRadio = type === "radio";
@@ -32,6 +32,7 @@ const HiddenCheckableInput = ({
32
32
  inputRef,
33
33
  onChange,
34
34
  autoFocus,
35
+ ariaLabelledBy,
35
36
  ...props
36
37
  }) => {
37
38
  const {
@@ -76,7 +77,7 @@ const HiddenCheckableInput = ({
76
77
  autoFocus: autoFocus,
77
78
  "aria-checked": checked,
78
79
  checked: checked,
79
- "aria-labelledby": labelId,
80
+ "aria-labelledby": ariaLabelledBy || labelId,
80
81
  "aria-describedby": ariaDescribedBy,
81
82
  name: name,
82
83
  role: type,
@@ -135,7 +136,10 @@ HiddenCheckableInput.propTypes = {
135
136
  /** A callback to retrieve the input reference */
136
137
  inputRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
137
138
  current: _propTypes.default.instanceOf(Element)
138
- })])
139
+ })]),
140
+
141
+ /** The id of the element that labels the input */
142
+ ariaLabelledBy: _propTypes.default.string
139
143
  };
140
144
 
141
145
  var _default = /*#__PURE__*/_react.default.memo(HiddenCheckableInput);
@@ -37,6 +37,8 @@ export interface HiddenCheckableInputProps
37
37
  fieldHelpId?: string;
38
38
  /** Element id for aria-labelledby */
39
39
  labelId?: string;
40
+ /** The id of the element that labels the input */
41
+ ariaLabelledBy?: string;
40
42
  }
41
43
 
42
44
  declare function HiddenCheckableInput(
@@ -7,6 +7,8 @@ exports.default = exports.ButtonWithForwardRef = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
+ var _styledComponents = require("styled-components");
11
+
10
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
13
 
12
14
  var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
@@ -17,6 +19,8 @@ var _button = _interopRequireWildcard(require("./button.style"));
17
19
 
18
20
  var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags/tags"));
19
21
 
22
+ var _base = _interopRequireDefault(require("../../style/themes/base"));
23
+
20
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
25
 
22
26
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -35,21 +39,23 @@ function renderChildren({
35
39
  disabled,
36
40
  buttonType,
37
41
  iconTooltipMessage,
38
- iconTooltipPosition
42
+ iconTooltipPosition,
43
+ theme
39
44
  /* eslint-enable */
40
45
 
41
46
  }) {
42
47
  const iconColorMap = {
43
- primary: "on-dark-background",
44
- secondary: "business-color",
45
- tertiary: "business-color",
46
- darkBackground: "business-color"
48
+ primary: theme.colors.white,
49
+ secondary: theme.colors.primary,
50
+ tertiary: theme.colors.primary,
51
+ darkBackground: theme.colors.primary
47
52
  };
48
53
  const iconProps = {
49
54
  type: iconType,
50
55
  disabled,
51
- bgTheme: "none",
52
- iconColor: iconColorMap[buttonType]
56
+ bgSize: "extra-small",
57
+ color: iconColorMap[buttonType],
58
+ bg: "transparent"
53
59
  };
54
60
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, iconType && iconPosition === "before" && children && /*#__PURE__*/_react.default.createElement(_icon.default, iconProps), /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement("span", {
55
61
  "data-element": "main-text"
@@ -129,6 +135,8 @@ const renderStyledButton = buttonProps => {
129
135
  };
130
136
 
131
137
  const Button = props => {
138
+ const theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _base.default;
139
+
132
140
  const {
133
141
  size,
134
142
  subtext
@@ -142,7 +150,8 @@ const Button = props => {
142
150
  } = props;
143
151
  const propsWithoutAs = { ...rest,
144
152
  buttonType: buttonType || as,
145
- ref: forwardRef || linkRef
153
+ ref: forwardRef || linkRef,
154
+ theme
146
155
  };
147
156
 
148
157
  if (subtext.length > 0 && size !== "large") {
@@ -19,10 +19,9 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
19
19
 
20
20
  const ButtonToggleIcon = props => /*#__PURE__*/_react.default.createElement(_buttonToggle.StyledButtonToggleIcon, props, /*#__PURE__*/_react.default.createElement(_icon.default, _extends({
21
21
  type: props.buttonIcon,
22
- fontSize: props.buttonIconSize
23
- }, props, {
24
- bgTheme: "none"
25
- })));
22
+ fontSize: props.buttonIconSize,
23
+ bgSize: "extra-small"
24
+ }, props)));
26
25
 
27
26
  ButtonToggleIcon.propTypes = {
28
27
  /**
@@ -144,6 +144,8 @@ const StyledButtonToggleIcon = _styledComponents.default.div`
144
144
  ${_icon.default} {
145
145
  margin-right: 0;
146
146
  margin-bottom: 8px;
147
+ height: ${`${iconFontSizes.largeIcon}px`};
148
+ width: ${`${iconFontSizes.largeIcon}px`};
147
149
  }
148
150
 
149
151
  ${_icon.default}::before {
@@ -27,7 +27,8 @@ const FlatTableCheckbox = ({
27
27
  onClick,
28
28
  leftPosition,
29
29
  cellIndex,
30
- reportCellWidth
30
+ reportCellWidth,
31
+ ariaLabelledBy
31
32
  }) => {
32
33
  const ref = (0, _react.useRef)(null);
33
34
  (0, _react.useLayoutEffect)(() => {
@@ -47,7 +48,8 @@ const FlatTableCheckbox = ({
47
48
  checked: checked,
48
49
  onChange: onChange,
49
50
  name: "flat-table-checkbox",
50
- mb: 0
51
+ mb: 0,
52
+ ariaLabelledBy: ariaLabelledBy
51
53
  }));
52
54
  };
53
55
 
@@ -67,6 +69,9 @@ FlatTableCheckbox.propTypes = {
67
69
  /** Whether to render the checkbox or not, defaults to true */
68
70
  selectable: _propTypes.default.bool,
69
71
 
72
+ /** The id of the element that labels the input */
73
+ ariaLabelledBy: _propTypes.default.string,
74
+
70
75
  /**
71
76
  * @private
72
77
  * @ignore
@@ -11,6 +11,8 @@ export interface FlatTableCheckboxProps {
11
11
  selectable?: boolean;
12
12
  /** Callback function to be called when click event received */
13
13
  onClick?: (ev: React.MouseEvent<HTMLElement>) => void;
14
+ /** The id of the element that labels the input */
15
+ ariaLabelledBy?: string;
14
16
  }
15
17
 
16
18
  declare function FlatTableCheckbox(props: FlatTableCheckboxProps): JSX.Element;
@@ -85,6 +85,7 @@ const StyledHeadingBackButton = (0, _styledComponents.default)(_link.default)`
85
85
 
86
86
  ${_icon2.default} {
87
87
  margin-right: 0;
88
+ display: inline-flex;
88
89
  }
89
90
  }
90
91
  `;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.ICONS = exports.ICON_COLORS = exports.ICON_BACKGROUNDS = exports.ICON_SIZES = exports.ICON_SHAPES = exports.ICON_TOOLTIP_POSITIONS = void 0;
6
+ exports.default = exports.ICONS = exports.ICON_SIZES = exports.ICON_SHAPES = exports.ICON_TOOLTIP_POSITIONS = void 0;
7
7
  const dlsConfig = {
8
8
  backgroundSize: {
9
9
  "extra-small": "16px",
@@ -30,10 +30,6 @@ const ICON_SHAPES = ["circle", "rounded-rect", "square"];
30
30
  exports.ICON_SHAPES = ICON_SHAPES;
31
31
  const ICON_SIZES = ["extra-small", "small", "medium", "large", "extra-large"];
32
32
  exports.ICON_SIZES = ICON_SIZES;
33
- const ICON_BACKGROUNDS = ["info", "error", "success", "warning", "business", "none"];
34
- exports.ICON_BACKGROUNDS = ICON_BACKGROUNDS;
35
- const ICON_COLORS = ["default", "on-light-background", "on-dark-background", "business-color"];
36
- exports.ICON_COLORS = ICON_COLORS;
37
33
  const ICONS = ["add", "alert", "analysis", "arrow_down", "arrow_left", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_right", "arrow_right_small", "arrow_up", "attach", "bank", "basket", "basket_with_squares", "bin", "blocked", "blocked_square", "block_arrow_right", "bold", "boxed_shapes", "bulk_destroy", "bullet_list", "bullet_list_dotted", "bullet_list_numbers", "business", "calendar", "calendar_today", "call", "camera", "card_view", "caret_down", "caret_left", "caret_right", "caret_up", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "cart", "chat", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chevron_down", "chevron_left", "chevron_right", "chevron_up", "chevron_down_thick", "chevron_left_thick", "chevron_right_thick", "chevron_up_thick", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "copy", "credit_card", "credit_card_slash", "cross", "cross_circle", "csv", "delete", "delivery", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "drag", "drag_vertical", "draft", "dropdown", "duplicate", "edit", "edited", "email", "email_switch", "ellipsis_horizontal", "ellipsis_vertical", "envelope_dollar", "envelope_euro", "error", "error_square", "euro", "expand", "factory", "favourite", "favourite_lined", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter", "filter_new", "fit_height", "fit_width", "flag", "folder", "gift", "graph", "grid", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "ledger", "ledger_arrow_left", "ledger_arrow_right", "link", "list_view", "locked", "location", "logout", "lookup", "marker", "message", "messages", "minus", "minus_large", "mobile", "money_bag", "pause", "pause_circle", "pdf", "people", "people_switch", "person", "person_info", "person_tick", "phone", "play", "play_circle", "plus", "plus_large", "pound", "print", "progress", "progressed", "question", "refresh", "refresh_clock", "remove", "sage_coin", "save", "scan", "search", "services", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split", "split_container", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "three_boxes", "tick", "tick_circle", "undo", "unlocked", "upload", "uploaded", "video", "view", "warning", "admin", "arrow", "contacts", "create", "disconnect", "entry", "go", "lightbulb_off", "lightbulb_on", "none", "old_warning", "piggy_bank", "question_hollow", "question_mark", "settings_old", "talk", "true_tick"];
38
34
  exports.ICONS = ICONS;
39
35
  var _default = dlsConfig;
@@ -19,8 +19,6 @@ var _tooltip = _interopRequireDefault(require("../tooltip"));
19
19
 
20
20
  var _utils = require("../../style/utils");
21
21
 
22
- var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
23
-
24
22
  var _iconConfig = require("./icon-config");
25
23
 
26
24
  var _tooltipProvider = require("../../__internal__/tooltip-provider");
@@ -33,19 +31,16 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
33
31
 
34
32
  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); }
35
33
 
36
- let deprecatedWarnTriggered = false;
37
34
  const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
38
35
 
39
36
  const Icon = /*#__PURE__*/_react.default.forwardRef(({
40
37
  bg,
41
38
  bgShape,
42
39
  bgSize,
43
- bgTheme,
44
40
  className,
45
41
  color,
46
42
  disabled,
47
43
  fontSize,
48
- iconColor,
49
44
  type,
50
45
  tooltipMessage,
51
46
  tooltipPosition,
@@ -58,12 +53,6 @@ const Icon = /*#__PURE__*/_react.default.forwardRef(({
58
53
  inputSize,
59
54
  ...rest
60
55
  }, ref) => {
61
- if (!deprecatedWarnTriggered && (iconColor || bgTheme)) {
62
- deprecatedWarnTriggered = true;
63
-
64
- _logger.default.deprecate("`iconColor` and `bgTheme` props are deprecated and will soon be removed");
65
- }
66
-
67
56
  const isInteractive = !!tooltipMessage && !disabled;
68
57
  /** Return Icon type with overrides */
69
58
 
@@ -93,14 +82,12 @@ const Icon = /*#__PURE__*/_react.default.forwardRef(({
93
82
 
94
83
  const styleProps = {
95
84
  bg,
96
- bgTheme,
97
85
  bgSize,
98
86
  bgShape,
99
87
  color,
100
88
  disabled,
101
89
  fontSize,
102
90
  isInteractive,
103
- iconColor,
104
91
  tabIndex,
105
92
  type: iconType(),
106
93
  ...(0, _utils.filterStyledSystemMarginProps)(rest)
@@ -157,19 +144,13 @@ Icon.propTypes = { ...marginPropTypes,
157
144
  /** Background shape */
158
145
  bgShape: _propTypes.default.oneOf(["circle", "rounded-rect", "square"]),
159
146
 
160
- /** Background color theme */
161
- bgTheme: _propTypes.default.oneOf(["info", "error", "success", "warning", "business", "none"]),
162
-
163
147
  /** Icon font size */
164
148
  fontSize: _propTypes.default.oneOf(["small", "medium", "large", "extra-large"]),
165
149
 
166
- /** Icon color */
167
- iconColor: _propTypes.default.oneOf(["default", "on-light-background", "on-dark-background", "business-color"]),
168
-
169
- /** Override iconColor, provide any color from palette or any valid css color value. */
150
+ /** Icon colour, provide any color from palette or any valid css color value. */
170
151
  color: _propTypes.default.string,
171
152
 
172
- /** Override bgTheme, provide any color from palette or any valid css color value. */
153
+ /** Background colour, provide any color from palette or any valid css color value. */
173
154
  bg: _propTypes.default.string,
174
155
 
175
156
  /** Sets the icon in the disabled state */
@@ -15,13 +15,7 @@ export type FontSize =
15
15
  | "large"
16
16
  | "extra-large";
17
17
  export type BackgroundShape = "circle" | "rounded-rect" | "square";
18
- export type BackgroundTheme =
19
- | "info"
20
- | "error"
21
- | "success"
22
- | "warning"
23
- | "business"
24
- | "none";
18
+
25
19
  export type IconType =
26
20
  | "add"
27
21
  | "alert"
@@ -209,11 +203,6 @@ export type IconType =
209
203
  | "video"
210
204
  | "view"
211
205
  | "warning";
212
- export type IconColor =
213
- | "default"
214
- | "on-light-background"
215
- | "on-dark-background"
216
- | "business-color";
217
206
 
218
207
  export interface IconProps extends MarginProps {
219
208
  /** Icon type */
@@ -222,15 +211,11 @@ export interface IconProps extends MarginProps {
222
211
  bgSize?: BgSize;
223
212
  /** Background shape */
224
213
  bgShape?: BackgroundShape;
225
- /** Background color theme */
226
- bgTheme?: BackgroundTheme;
227
214
  /** Icon font size */
228
215
  fontSize?: FontSize;
229
- /** Icon color */
230
- iconColor?: IconColor;
231
- /** Override iconColor, provide any color from palette or any valid css color value. */
216
+ /** Icon colour, provide any color from palette or any valid css color value. */
232
217
  color?: string;
233
- /** Override bgTheme, provide any color from palette or any valid css color value. */
218
+ /** Background colour, provide any color from palette or any valid css color value. */
234
219
  bg?: string;
235
220
  /** Sets the icon in the disabled state */
236
221
  disabled?: boolean;
@@ -17,8 +17,6 @@ var _iconUnicodes = _interopRequireDefault(require("./icon-unicodes"));
17
17
 
18
18
  var _base = _interopRequireDefault(require("../../style/themes/base"));
19
19
 
20
- var _palette = _interopRequireDefault(require("../../style/palette"));
21
-
22
20
  var _iconConfig = _interopRequireWildcard(require("./icon-config"));
23
21
 
24
22
  var _browserTypeCheck = _interopRequireWildcard(require("../../__internal__/utils/helpers/browser-type-check"));
@@ -31,60 +29,6 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
31
29
 
32
30
  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; }
33
31
 
34
- const getBackgroundColor = (theme, bgTheme, disabled, isHover) => {
35
- if (bgTheme !== "none") {
36
- if (disabled) return theme.icon.disabled;
37
- }
38
-
39
- const palette = (0, _palette.default)({
40
- statusColor: theme.colors[bgTheme],
41
- businessColor: theme.colors.primary
42
- });
43
- const statuses = ["info", "error", "success", "warning"];
44
-
45
- if (statuses.includes(bgTheme)) {
46
- return isHover ? palette.statusColorShade(20) : theme.colors[bgTheme];
47
- }
48
-
49
- if (bgTheme === "business") {
50
- return isHover ? palette.businessColorShade(20) : theme.colors.primary;
51
- }
52
-
53
- return "transparent";
54
- };
55
-
56
- const getIconColor = (bgTheme, theme, iconColor, disabled, isHover) => {
57
- if (disabled) return theme.icon.disabled;
58
-
59
- if (bgTheme !== "none") {
60
- const whiteIconBackgrounds = ["error", "info", "business"];
61
- const darkIconBackgrounds = ["success", "warning"];
62
- if (whiteIconBackgrounds.includes(bgTheme)) return theme.colors.white;
63
-
64
- if (darkIconBackgrounds.includes(bgTheme)) {
65
- return isHover ? theme.icon.defaultHover : theme.icon.default;
66
- }
67
- }
68
-
69
- const palette = (0, _palette.default)({
70
- businessColor: theme.colors.primary
71
- });
72
-
73
- switch (iconColor) {
74
- case "on-dark-background":
75
- return theme.colors.white;
76
-
77
- case "on-light-background":
78
- return isHover ? theme.icon.onLightBackgroundHover : theme.icon.onLightBackground;
79
-
80
- case "business-color":
81
- return isHover ? palette.businessColorShade(20) : theme.colors.primary;
82
-
83
- default:
84
- return isHover ? theme.icon.defaultHover : theme.icon.default;
85
- }
86
- };
87
-
88
32
  function adjustIconBgSize(fontSize, bgSize) {
89
33
  var _replacements$fontSiz;
90
34
 
@@ -113,12 +57,10 @@ function adjustIconBgSize(fontSize, bgSize) {
113
57
 
114
58
  const StyledIcon = _styledComponents.default.span`
115
59
  ${({
116
- bgTheme,
117
60
  theme,
118
61
  color,
119
62
  bg,
120
63
  isInteractive,
121
- iconColor,
122
64
  bgSize,
123
65
  bgShape,
124
66
  type,
@@ -131,7 +73,10 @@ const StyledIcon = _styledComponents.default.span`
131
73
  let bgHoverColor;
132
74
 
133
75
  try {
134
- if (color) {
76
+ if (disabled) {
77
+ finalColor = theme.icon.disabled;
78
+ finalHoverColor = theme.icon.disabled;
79
+ } else if (color) {
135
80
  const {
136
81
  color: renderedColor
137
82
  } = (0, _color.default)({
@@ -141,8 +86,8 @@ const StyledIcon = _styledComponents.default.span`
141
86
  finalColor = renderedColor;
142
87
  finalHoverColor = (0, _polished.shade)(0.2, renderedColor);
143
88
  } else {
144
- finalColor = getIconColor(bgTheme, theme, iconColor, disabled, false);
145
- finalHoverColor = getIconColor(bgTheme, theme, iconColor, disabled, true);
89
+ finalColor = theme.icon.default;
90
+ finalHoverColor = theme.icon.defaultHover;
146
91
  }
147
92
 
148
93
  if (bg) {
@@ -154,9 +99,12 @@ const StyledIcon = _styledComponents.default.span`
154
99
  });
155
100
  bgColor = backgroundColor;
156
101
  bgHoverColor = (0, _polished.shade)(0.2, backgroundColor);
102
+ } else if (disabled) {
103
+ bgColor = theme.icon.disabled;
104
+ bgHoverColor = theme.icon.disabled;
157
105
  } else {
158
- bgColor = getBackgroundColor(theme, bgTheme, disabled, false);
159
- bgHoverColor = getBackgroundColor(theme, bgTheme, disabled, true);
106
+ bgColor = "transparent";
107
+ bgHoverColor = "transparent";
160
108
  }
161
109
  } catch (e) {
162
110
  // eslint-disable-next-line no-console
@@ -164,11 +112,16 @@ const StyledIcon = _styledComponents.default.span`
164
112
  }
165
113
 
166
114
  return (0, _styledComponents.css)`
167
- display: inline-block;
168
115
  position: relative;
169
116
  color: ${finalColor};
170
117
  background-color: ${bgColor};
171
118
  vertical-align: middle;
119
+ align-items: center;
120
+ display: inline-flex;
121
+ justify-content: center;
122
+ height: ${adjustIconBgSize(fontSize, bgSize)};
123
+ width: ${adjustIconBgSize(fontSize, bgSize)};
124
+ border-radius: ${_iconConfig.default.backgroundShape[bgShape]};
172
125
 
173
126
  ${isInteractive && (0, _styledComponents.css)`
174
127
  &:hover {
@@ -177,15 +130,6 @@ const StyledIcon = _styledComponents.default.span`
177
130
  }
178
131
  `}
179
132
 
180
- ${bgTheme !== "none" && (0, _styledComponents.css)`
181
- align-items: center;
182
- display: inline-flex;
183
- justify-content: center;
184
- height: ${adjustIconBgSize(fontSize, bgSize)};
185
- width: ${adjustIconBgSize(fontSize, bgSize)};
186
- border-radius: ${_iconConfig.default.backgroundShape[bgShape]};
187
- `}
188
-
189
133
  &::before {
190
134
  -webkit-font-smoothing: antialiased;
191
135
  -moz-osx-font-smoothing: grayscale;
@@ -220,9 +164,7 @@ StyledIcon.propTypes = {
220
164
  disabled: _propTypes.default.bool,
221
165
  bgSize: _propTypes.default.oneOf(["extra-small", "small", "medium", "large", "extra-large"]),
222
166
  bgShape: _propTypes.default.oneOf(_iconConfig.ICON_SHAPES),
223
- bgTheme: _propTypes.default.oneOf([..._iconConfig.ICON_COLORS, ..._iconConfig.ICON_BACKGROUNDS, ""]),
224
- fontSize: _propTypes.default.oneOf(["small", "medium", "large", "extra-large"]),
225
- iconColor: _propTypes.default.oneOf(_iconConfig.ICON_COLORS)
167
+ fontSize: _propTypes.default.oneOf(["small", "medium", "large", "extra-large"])
226
168
  };
227
169
  StyledIcon.defaultProps = {
228
170
  theme: _base.default
@@ -7,6 +7,8 @@ exports.default = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
+ var _styledComponents = require("styled-components");
11
+
10
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
13
 
12
14
  var _icon = _interopRequireDefault(require("../icon"));
@@ -17,6 +19,8 @@ var _link = require("./link.style");
17
19
 
18
20
  var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags/tags"));
19
21
 
22
+ var _themes = require("../../style/themes");
23
+
20
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
25
 
22
26
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -44,6 +48,8 @@ const Link = /*#__PURE__*/_react.default.forwardRef(({
44
48
  target,
45
49
  ...rest
46
50
  }, ref) => {
51
+ const theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _themes.baseTheme;
52
+
47
53
  const tabIndex = tabbable && !disabled ? "0" : "-1";
48
54
 
49
55
  const handleOnKeyDown = ev => {
@@ -66,8 +72,8 @@ const Link = /*#__PURE__*/_react.default.forwardRef(({
66
72
  const hasProperAlignment = icon && iconAlign === currentAlignment;
67
73
  return hasProperAlignment ? /*#__PURE__*/_react.default.createElement(_icon.default, {
68
74
  type: icon,
69
- bgTheme: "none",
70
- iconColor: "business-color",
75
+ bgSize: "extra-small",
76
+ color: theme.colors.primary,
71
77
  disabled: disabled,
72
78
  ariaLabel: ariaLabel,
73
79
  tooltipMessage: tooltipMessage,
@@ -54,6 +54,7 @@ const StyledLink = _styledComponents.default.span`
54
54
  color: ${isSkipLink ? theme.text.color : theme.colors.primary};
55
55
  display: inline-block;
56
56
  ${_icon.default} {
57
+ display: inline-block;
57
58
  position: relative;
58
59
  vertical-align: middle;
59
60
  ${iconAlign === "left" && (0, _styledComponents.css)`
@@ -23,8 +23,7 @@ const TypeIcon = ({
23
23
  variant: variant,
24
24
  transparent: transparent
25
25
  }, /*#__PURE__*/_react.default.createElement(_icon.default, {
26
- type: variant,
27
- bgTheme: "none"
26
+ type: variant
28
27
  }));
29
28
  };
30
29
 
@@ -32,9 +32,7 @@ const renderCloseIcon = onDelete => /*#__PURE__*/_react.default.createElement(_i
32
32
  "data-element": "close",
33
33
  "aria-label": "close"
34
34
  }, /*#__PURE__*/_react.default.createElement(_icon.default, {
35
- type: "cross",
36
- bgSize: "small",
37
- bgTheme: "none"
35
+ type: "cross"
38
36
  }));
39
37
 
40
38
  const Pill = ({
@@ -173,6 +173,8 @@ const PillStyle = _styledComponents.default.span`
173
173
  ${_icon.default} {
174
174
  font-size: 12px;
175
175
  padding: 0 4px;
176
+ height: unset;
177
+ width: unset;
176
178
 
177
179
  &:hover,
178
180
  &:focus {
@@ -7,6 +7,8 @@ exports.default = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
+ var _styledComponents = require("styled-components");
11
+
10
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
13
 
12
14
  var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
@@ -29,6 +31,8 @@ var _popover = _interopRequireDefault(require("../../__internal__/popover"));
29
31
 
30
32
  var _utils = require("../../style/utils");
31
33
 
34
+ var _themes = require("../../style/themes");
35
+
32
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
37
 
34
38
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -54,6 +58,8 @@ const SplitButton = ({
54
58
  text,
55
59
  ...rest
56
60
  }) => {
61
+ const theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _themes.baseTheme;
62
+
57
63
  const isToggleButtonFocused = (0, _react.useRef)(false);
58
64
  const buttonLabelId = (0, _react.useRef)((0, _guid.default)());
59
65
  const additionalButtons = (0, _react.useRef)([]);
@@ -161,8 +167,8 @@ const SplitButton = ({
161
167
 
162
168
  function getIconColor() {
163
169
  const colorsMap = {
164
- primary: "on-dark-background",
165
- secondary: "business-color"
170
+ primary: theme.colors.white,
171
+ secondary: theme.colors.primary
166
172
  };
167
173
  return colorsMap[buttonType || as];
168
174
  }
@@ -180,8 +186,9 @@ const SplitButton = ({
180
186
  key: "toggle-button"
181
187
  }, toggleButtonProps()), /*#__PURE__*/_react.default.createElement(_icon.default, {
182
188
  type: "dropdown",
183
- bgTheme: "none",
184
- iconColor: getIconColor(),
189
+ bgSize: "extra-small",
190
+ color: getIconColor(),
191
+ bg: "transparent",
185
192
  disabled: disabled
186
193
  }))];
187
194
  }
@@ -344,10 +344,6 @@ const StyledTabTitle = _styledComponents.default.li`
344
344
  padding-bottom: 0px;
345
345
  `}
346
346
 
347
- &:focus {
348
- outline: ${isInSidebar ? "none;" : `2px solid ${theme.colors.focus};`}
349
- }
350
-
351
347
  &:hover {
352
348
  background-color: ${theme.colors.white};
353
349
  border-bottom-color: ${alternateStyling ? `${theme.tab.background};` : `${theme.colors.primary};`}
@@ -355,6 +351,16 @@ const StyledTabTitle = _styledComponents.default.li`
355
351
  cursor: default;
356
352
  }
357
353
  `}
354
+
355
+ ${({
356
+ theme,
357
+ isInSidebar
358
+ }) => `
359
+ &:focus {
360
+ outline: ${isInSidebar ? "none;" : `2px solid ${theme.colors.focus};`}
361
+ z-index: 1;
362
+ }
363
+ `}
358
364
 
359
365
  ${({
360
366
  position,
@@ -59,9 +59,22 @@ const Tabs = ({
59
59
  headerWidth,
60
60
  ...rest
61
61
  }) => {
62
- const tabRefs = (0, _react.useRef)([]);
62
+ /** The children nodes converted into an Array */
63
+ const filteredChildren = (0, _react.useMemo)(() => _react.Children.toArray(children).filter(child => child), [children]);
64
+ /** Array of the tabIds for the child nodes */
65
+
66
+ const tabIds = () => {
67
+ return filteredChildren.map(child => child.props.tabId);
68
+ };
69
+ /** Array of refs to the TabTitle nodes */
70
+
71
+
72
+ const tabRefs = (0, _react.useMemo)(() => Array.from({
73
+ length: filteredChildren.length
74
+ }).map(() => /*#__PURE__*/(0, _react.createRef)()), [filteredChildren.length]);
63
75
  const previousSelectedTabId = (0, _react.useRef)(selectedTabId);
64
76
  const [selectedTabIdState, setSelectedTabIdState] = (0, _react.useState)();
77
+ const [tabStopId, setTabStopId] = (0, _react.useState)();
65
78
  const {
66
79
  isInSidebar
67
80
  } = (0, _react.useContext)(_drawer.DrawerSidebarContext);
@@ -69,7 +82,13 @@ const Tabs = ({
69
82
  const [tabsWarnings, setTabsWarnings] = (0, _react.useState)({});
70
83
  const [tabsInfos, setTabsInfos] = (0, _react.useState)({});
71
84
  (0, _react.useLayoutEffect)(() => {
72
- const selectedTab = selectedTabId || _react.default.Children.toArray(children)[0].props.tabId;
85
+ const selectedTab = selectedTabId || _react.Children.toArray(children)[0].props.tabId;
86
+
87
+ if (!tabIds().includes(selectedTabId)) {
88
+ setTabStopId(_react.default.Children.toArray(children)[0].props.tabId);
89
+ } else {
90
+ setTabStopId(selectedTab);
91
+ }
73
92
 
74
93
  setSelectedTabIdState(selectedTab); // eslint-disable-next-line react-hooks/exhaustive-deps
75
94
  }, []);
@@ -94,15 +113,25 @@ const Tabs = ({
94
113
  });
95
114
  }
96
115
  }, [tabsInfos]);
116
+ /** Returns true/false for if the given tab id is selected. */
117
+
118
+ const isTabSelected = (0, _react.useCallback)(tabId => tabId === selectedTabIdState, [selectedTabIdState]);
119
+ const hasTabStop = (0, _react.useCallback)(tabId => tabId === tabStopId, [tabStopId]);
97
120
  /** Updates the currently visible tab */
98
121
 
99
122
  const updateVisibleTab = (0, _react.useCallback)(tabid => {
100
- setSelectedTabIdState(tabid);
123
+ if (!isTabSelected(tabid)) {
124
+ setSelectedTabIdState(tabid);
125
+ }
126
+
127
+ if (!hasTabStop(tabid)) {
128
+ setTabStopId(tabid);
129
+ }
101
130
 
102
131
  if (onTabChange) {
103
132
  onTabChange(tabid);
104
133
  }
105
- }, [onTabChange]);
134
+ }, [onTabChange, isTabSelected, hasTabStop]);
106
135
  /** Determines if the tab titles are in a vertical format. */
107
136
 
108
137
  const isVertical = currentPosition => currentPosition === "left";
@@ -122,17 +151,7 @@ const Tabs = ({
122
151
  /** Focuses the tab for the reference specified */
123
152
 
124
153
 
125
- const focusTab = ref => ref.focus();
126
- /** The children nodes converted into an Array */
127
-
128
-
129
- const filteredChildren = _react.default.useMemo(() => _react.default.Children.toArray(children).filter(child => child), [children]);
130
- /** Array of the tabIds for the child nodes */
131
-
132
-
133
- const tabIds = () => {
134
- return filteredChildren.map(child => child.props.tabId);
135
- };
154
+ const focusTab = ref => ref.current.focus();
136
155
  /** Will trigger the tab at the given index. */
137
156
 
138
157
 
@@ -148,7 +167,7 @@ const Tabs = ({
148
167
  }
149
168
 
150
169
  const nextTabId = ids[newIndex];
151
- const nextRef = tabRefs.current[newIndex];
170
+ const nextRef = tabRefs[newIndex];
152
171
  updateVisibleTab(nextTabId);
153
172
  focusTab(nextRef);
154
173
  };
@@ -174,16 +193,6 @@ const Tabs = ({
174
193
  }
175
194
  };
176
195
  };
177
- /** Returns true/false for if the given tab id is selected. */
178
-
179
-
180
- const isTabSelected = tabId => tabId === selectedTabIdState;
181
-
182
- const addRef = ref => {
183
- if (ref && !tabRefs.current.includes(ref)) {
184
- tabRefs.current.push(ref);
185
- }
186
- };
187
196
  /** Build the headers for the tab component */
188
197
 
189
198
 
@@ -220,8 +229,8 @@ const Tabs = ({
220
229
  key: tabId,
221
230
  onClick: handleTabClick,
222
231
  onKeyDown: handleKeyDown(index),
223
- ref: node => addRef(node),
224
- tabIndex: isTabSelected(tabId) ? "0" : "-1",
232
+ ref: tabRefs[index],
233
+ tabIndex: isTabSelected(tabId) || hasTabStop(tabId) ? "0" : "-1",
225
234
  title: title,
226
235
  href: href,
227
236
  isTabSelected: isTabSelected(tabId),
@@ -239,7 +248,16 @@ const Tabs = ({
239
248
  noLeftBorder: ["no left side", "no sides"].includes(borders),
240
249
  noRightBorder: ["no right side", "no sides"].includes(borders),
241
250
  customLayout: customLayout,
242
- isInSidebar: isInSidebar
251
+ isInSidebar: isInSidebar,
252
+ onFocus: () => {
253
+ if (!hasTabStop(tabId)) {
254
+ setTabStopId(tabId);
255
+ }
256
+
257
+ if (!isTabSelected(tabId)) {
258
+ updateVisibleTab(tabId);
259
+ }
260
+ }
243
261
  });
244
262
 
245
263
  return tabTitle;
@@ -264,7 +282,7 @@ const Tabs = ({
264
282
  tab = child;
265
283
  }
266
284
  });
267
- return tab ? /*#__PURE__*/_react.default.cloneElement(tab, {
285
+ return tab ? /*#__PURE__*/(0, _react.cloneElement)(tab, {
268
286
  isTabSelected: isTabSelected(tab.props.tabId)
269
287
  }) : null;
270
288
  };
@@ -279,7 +297,7 @@ const Tabs = ({
279
297
  }
280
298
 
281
299
  const tabs = filteredChildren.map(child => {
282
- return /*#__PURE__*/_react.default.cloneElement(child, { ...child.props,
300
+ return /*#__PURE__*/(0, _react.cloneElement)(child, { ...child.props,
283
301
  role: "tabpanel",
284
302
  position,
285
303
  isTabSelected: isTabSelected(child.props.tabId),
@@ -23,6 +23,10 @@ var _default = theme => ({ ...theme,
23
23
  metaName: "Base Theme",
24
24
  metaPublic: "true",
25
25
  colorsLogo: "#00D639",
26
+ colorsYin030: "rgba(0,0,0,0.3)",
27
+ colorsYin055: "rgba(0,0,0,0.55)",
28
+ colorsYin065: "rgba(0,0,0,0.65)",
29
+ colorsYin090: "rgba(0,0,0,0.9)",
26
30
  colorsComponentsNavigation500: "#008146",
27
31
  colorsComponentsNavigation600: "#006738",
28
32
  colorsComponentsNavigation700: "#004D2A",
@@ -126,31 +130,31 @@ var _default = theme => ({ ...theme,
126
130
  sizing050: "4px",
127
131
  sizing075: "6px",
128
132
  sizingLogowidth: "40px",
129
- spacing000: theme.space[0],
133
+ spacing000: `${theme.space[0]}px`,
130
134
  // 0px
131
135
  spacing025: "2px",
132
136
  spacing050: "4px",
133
137
  spacing075: "6px",
134
- spacing100: theme.space[1],
138
+ spacing100: `${theme.space[1]}px`,
135
139
  // 8px
136
140
  spacing125: "10px",
137
141
  spacing150: "12px",
138
- spacing200: theme.space[2],
142
+ spacing200: `${theme.space[2]}px`,
139
143
  // 16px
140
144
  spacing250: "20px",
141
- spacing300: theme.space[3],
145
+ spacing300: `${theme.space[3]}px`,
142
146
  // 24px
143
- spacing400: theme.space[4],
147
+ spacing400: `${theme.space[4]}px`,
144
148
  // 32px
145
- spacing500: theme.space[5],
149
+ spacing500: `${theme.space[5]}px`,
146
150
  // 40px
147
- spacing600: theme.space[6],
151
+ spacing600: `${theme.space[6]}px`,
148
152
  // 48px
149
- spacing700: theme.space[7],
153
+ spacing700: `${theme.space[7]}px`,
150
154
  // 56px
151
- spacing800: theme.space[8],
155
+ spacing800: `${theme.space[8]}px`,
152
156
  // 64px
153
- spacing900: theme.space[9],
157
+ spacing900: `${theme.space[9]}px`,
154
158
  // 72px
155
159
  borderWidth100: "1px",
156
160
  borderWidth200: "2px",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "94.7.0",
3
+ "version": "95.0.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {
@@ -133,7 +133,7 @@
133
133
  },
134
134
  "dependencies": {
135
135
  "@popperjs/core": "^2.9.0",
136
- "@sage/design-tokens": "^1.65.0",
136
+ "@sage/design-tokens": "^1.73.0",
137
137
  "@styled-system/prop-types": "^5.1.5",
138
138
  "@tippyjs/react": "^4.2.5",
139
139
  "classnames": "~2.2.6",