carbon-react 121.0.0 → 121.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.
@@ -70,6 +70,7 @@ Crumb.propTypes = {
70
70
  "data-component": PropTypes.string,
71
71
  "data-element": PropTypes.string,
72
72
  "data-role": PropTypes.string,
73
+ "hasFocus": PropTypes.bool,
73
74
  "href": PropTypes.string,
74
75
  "isCurrent": PropTypes.bool,
75
76
  "onClick": PropTypes.func,
@@ -1,5 +1,5 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : 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
- import React, { useContext, useMemo } from "react";
2
+ import React, { useContext, useMemo, useState } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import Icon from "../icon";
5
5
  import MenuContext from "../menu/menu.context";
@@ -29,6 +29,7 @@ const Link = /*#__PURE__*/React.forwardRef(({
29
29
  removeAriaLabelOnIcon,
30
30
  ...rest
31
31
  }, ref) => {
32
+ const [hasFocus, setHasFocus] = useState(false);
32
33
  const l = useLocale();
33
34
  const {
34
35
  inMenu
@@ -75,7 +76,9 @@ const Link = /*#__PURE__*/React.forwardRef(({
75
76
  href,
76
77
  rel,
77
78
  "aria-label": ariaLabel,
78
- ...ariaProps
79
+ ...ariaProps,
80
+ onFocus: () => setHasFocus(true),
81
+ onBlur: () => setHasFocus(false)
79
82
  };
80
83
  const buttonProps = {
81
84
  type: "button"
@@ -87,8 +90,7 @@ const Link = /*#__PURE__*/React.forwardRef(({
87
90
  }
88
91
  return /*#__PURE__*/React.createElement(type, type === "button" ? {
89
92
  ...componentProps,
90
- ...buttonProps,
91
- placeholderTabIndex
93
+ ...buttonProps
92
94
  } : {
93
95
  ...componentProps,
94
96
  ...(placeholderTabIndex && href === undefined && !onClick && {
@@ -107,6 +109,8 @@ const Link = /*#__PURE__*/React.forwardRef(({
107
109
  isMenuItem: inMenu
108
110
  }, tagComponent("link", rest), isSkipLink && {
109
111
  "data-element": "skip-link"
112
+ }, {
113
+ hasFocus: hasFocus
110
114
  }), createLinkBasedOnType());
111
115
  });
112
116
  Link.propTypes = {
@@ -162,6 +166,7 @@ Link.propTypes = {
162
166
  "children": PropTypes.node,
163
167
  "className": PropTypes.string,
164
168
  "disabled": PropTypes.bool,
169
+ "hasFocus": PropTypes.bool,
165
170
  "href": PropTypes.string,
166
171
  "icon": PropTypes.oneOf(["accessibility_web", "add", "admin", "alert_on", "alert", "analysis", "app_facebook", "app_instagram", "app_tiktok", "app_twitter", "app_youtube", "apps", "arrow_bottom_right_circle", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_top_left_circle", "arrow_up", "arrow", "arrows_left_right", "attach", "bank_with_card", "bank", "basket_with_squares", "basket", "bed", "bill_paid", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "box_arrow_left", "box_arrow_right", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_pay_date", "calendar_today", "calendar", "call", "camera", "car_lock", "car_money", "car_repair", "card_view", "card_wallet", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "cash", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "check_all", "check_none", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect_off", "connect", "construction", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "dashboard", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "drill", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "form_refresh", "gift", "go", "graduation_hat", "graph", "grid", "hand_cash_coins", "hand_cash_note", "heart_pulse", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "intranet", "italic", "job_seeked", "key", "laptop", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "like", "link_cloud", "link_on", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "microphone", "minus_large", "minus", "mobile", "money_bag", "none", "old_warning", "palm_tree", "pause_circle", "pause", "pdf", "people_switch", "people", "percentage_boxed", "person_info", "person_tick", "person", "petrol_pump", "phone", "piggy_bank", "plane", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "protect", "question_hollow", "question_mark", "question", "recruiting", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "send", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "support_online", "sync", "tag", "talk", "target_man", "target", "theatre_masks", "three_boxes", "tick_circle", "tick_thick", "tick", "true_tick", "u_turn_left", "u_turn_right", "undo", "unlocked", "upload", "uploaded", "video", "view", "volunteering", "warning", "website", "welfare"]),
167
172
  "iconAlign": PropTypes.oneOf(["left", "right"]),
@@ -10,6 +10,7 @@ export interface StyledLinkProps {
10
10
  isDarkBackground?: boolean;
11
11
  /** Allows link styling to be updated for light or dark backgrounds */
12
12
  variant?: Variants;
13
+ hasFocus?: boolean;
13
14
  }
14
15
  interface PrivateStyledLinkProps {
15
16
  hasContent: boolean;
@@ -42,7 +42,8 @@ const StyledLink = styled.span`
42
42
  disabled,
43
43
  variant,
44
44
  isDarkBackground,
45
- isMenuItem
45
+ isMenuItem,
46
+ hasFocus
46
47
  }) => {
47
48
  const colorMapKey = isDarkBackground ? "dark" : "light";
48
49
  const {
@@ -117,21 +118,6 @@ const StyledLink = styled.span`
117
118
  }
118
119
  `}
119
120
  }
120
-
121
- ${!disabled && !theme.focusRedesignOptOut && css`
122
- a,
123
- button {
124
- outline: none;
125
- text-decoration: none;
126
- border-bottom-left-radius: var(--borderRadius000);
127
- border-bottom-right-radius: var(--borderRadius000);
128
- }
129
- &:focus-within {
130
- box-shadow: 0 4px 0 0 var(--colorsUtilityYin090);
131
- border-bottom-left-radius: var(--borderRadius025);
132
- border-bottom-right-radius: var(--borderRadius025);
133
- }
134
- `}
135
121
  `}
136
122
 
137
123
  a,
@@ -173,6 +159,19 @@ const StyledLink = styled.span`
173
159
  `}
174
160
  }
175
161
 
162
+ ${!isSkipLink && !disabled && !theme.focusRedesignOptOut && hasFocus && css`
163
+ a,
164
+ button {
165
+ outline: none;
166
+ text-decoration: none;
167
+ border-bottom-left-radius: var(--borderRadius000);
168
+ border-bottom-right-radius: var(--borderRadius000);
169
+ }
170
+ box-shadow: 0 4px 0 0 var(--colorsUtilityYin090);
171
+ border-bottom-left-radius: var(--borderRadius025);
172
+ border-bottom-right-radius: var(--borderRadius025);
173
+ `}
174
+
176
175
  button {
177
176
  background-color: transparent;
178
177
  border: none;
@@ -7,14 +7,6 @@ import menuConfigVariants from "../menu.config";
7
7
  import Link from "../../link";
8
8
  import addFocusStyling from "../../../style/utils/add-focus-styling";
9
9
  import { baseTheme } from "../../../style/themes";
10
- const overrideLinkFocusStyling = fullScreenView => `
11
- &:focus-within {
12
- box-shadow: none;
13
- a {
14
- background-color: ${fullScreenView ? "var(--colorsComponentsMenuAutumnStandard600)" : "transparent"};
15
- }
16
- }
17
- `;
18
10
  const oldFocusStyling = `
19
11
  box-shadow: inset 0 0 0 var(--borderWidth300) var(--colorsSemanticFocus500);
20
12
  `;
@@ -45,19 +37,13 @@ const StyledMenuItemWrapper = styled.a.attrs({
45
37
  font-weight: 700;
46
38
  height: 40px;
47
39
  position: relative;
48
-
49
- && {
50
- :focus-within > a, > button {
51
- background-color: transparent;
52
- }
53
- }
40
+ box-shadow: none;
54
41
 
55
42
  a,
56
43
  button {
57
44
  cursor: pointer;
58
45
  }
59
46
 
60
- ${overrideLinkFocusStyling(inFullscreenView)}
61
47
  a:focus,
62
48
  button:focus {
63
49
  ${({
@@ -77,6 +77,7 @@ Crumb.propTypes = {
77
77
  "data-component": _propTypes.default.string,
78
78
  "data-element": _propTypes.default.string,
79
79
  "data-role": _propTypes.default.string,
80
+ "hasFocus": _propTypes.default.bool,
80
81
  "href": _propTypes.default.string,
81
82
  "isCurrent": _propTypes.default.bool,
82
83
  "onClick": _propTypes.default.func,
@@ -38,6 +38,7 @@ const Link = /*#__PURE__*/_react.default.forwardRef(({
38
38
  removeAriaLabelOnIcon,
39
39
  ...rest
40
40
  }, ref) => {
41
+ const [hasFocus, setHasFocus] = (0, _react.useState)(false);
41
42
  const l = (0, _useLocale.default)();
42
43
  const {
43
44
  inMenu
@@ -84,7 +85,9 @@ const Link = /*#__PURE__*/_react.default.forwardRef(({
84
85
  href,
85
86
  rel,
86
87
  "aria-label": ariaLabel,
87
- ...ariaProps
88
+ ...ariaProps,
89
+ onFocus: () => setHasFocus(true),
90
+ onBlur: () => setHasFocus(false)
88
91
  };
89
92
  const buttonProps = {
90
93
  type: "button"
@@ -96,8 +99,7 @@ const Link = /*#__PURE__*/_react.default.forwardRef(({
96
99
  }
97
100
  return /*#__PURE__*/_react.default.createElement(type, type === "button" ? {
98
101
  ...componentProps,
99
- ...buttonProps,
100
- placeholderTabIndex
102
+ ...buttonProps
101
103
  } : {
102
104
  ...componentProps,
103
105
  ...(placeholderTabIndex && href === undefined && !onClick && {
@@ -116,6 +118,8 @@ const Link = /*#__PURE__*/_react.default.forwardRef(({
116
118
  isMenuItem: inMenu
117
119
  }, (0, _tags.default)("link", rest), isSkipLink && {
118
120
  "data-element": "skip-link"
121
+ }, {
122
+ hasFocus: hasFocus
119
123
  }), createLinkBasedOnType());
120
124
  });
121
125
  exports.Link = Link;
@@ -172,6 +176,7 @@ Link.propTypes = {
172
176
  "children": _propTypes.default.node,
173
177
  "className": _propTypes.default.string,
174
178
  "disabled": _propTypes.default.bool,
179
+ "hasFocus": _propTypes.default.bool,
175
180
  "href": _propTypes.default.string,
176
181
  "icon": _propTypes.default.oneOf(["accessibility_web", "add", "admin", "alert_on", "alert", "analysis", "app_facebook", "app_instagram", "app_tiktok", "app_twitter", "app_youtube", "apps", "arrow_bottom_right_circle", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_top_left_circle", "arrow_up", "arrow", "arrows_left_right", "attach", "bank_with_card", "bank", "basket_with_squares", "basket", "bed", "bill_paid", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "box_arrow_left", "box_arrow_right", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_pay_date", "calendar_today", "calendar", "call", "camera", "car_lock", "car_money", "car_repair", "card_view", "card_wallet", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "cash", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "check_all", "check_none", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect_off", "connect", "construction", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "dashboard", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "drill", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "form_refresh", "gift", "go", "graduation_hat", "graph", "grid", "hand_cash_coins", "hand_cash_note", "heart_pulse", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "intranet", "italic", "job_seeked", "key", "laptop", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "like", "link_cloud", "link_on", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "microphone", "minus_large", "minus", "mobile", "money_bag", "none", "old_warning", "palm_tree", "pause_circle", "pause", "pdf", "people_switch", "people", "percentage_boxed", "person_info", "person_tick", "person", "petrol_pump", "phone", "piggy_bank", "plane", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "protect", "question_hollow", "question_mark", "question", "recruiting", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "send", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "support_online", "sync", "tag", "talk", "target_man", "target", "theatre_masks", "three_boxes", "tick_circle", "tick_thick", "tick", "true_tick", "u_turn_left", "u_turn_right", "undo", "unlocked", "upload", "uploaded", "video", "view", "volunteering", "warning", "website", "welfare"]),
177
182
  "iconAlign": _propTypes.default.oneOf(["left", "right"]),
@@ -10,6 +10,7 @@ export interface StyledLinkProps {
10
10
  isDarkBackground?: boolean;
11
11
  /** Allows link styling to be updated for light or dark backgrounds */
12
12
  variant?: Variants;
13
+ hasFocus?: boolean;
13
14
  }
14
15
  interface PrivateStyledLinkProps {
15
16
  hasContent: boolean;
@@ -51,7 +51,8 @@ const StyledLink = _styledComponents.default.span`
51
51
  disabled,
52
52
  variant,
53
53
  isDarkBackground,
54
- isMenuItem
54
+ isMenuItem,
55
+ hasFocus
55
56
  }) => {
56
57
  const colorMapKey = isDarkBackground ? "dark" : "light";
57
58
  const {
@@ -126,21 +127,6 @@ const StyledLink = _styledComponents.default.span`
126
127
  }
127
128
  `}
128
129
  }
129
-
130
- ${!disabled && !theme.focusRedesignOptOut && (0, _styledComponents.css)`
131
- a,
132
- button {
133
- outline: none;
134
- text-decoration: none;
135
- border-bottom-left-radius: var(--borderRadius000);
136
- border-bottom-right-radius: var(--borderRadius000);
137
- }
138
- &:focus-within {
139
- box-shadow: 0 4px 0 0 var(--colorsUtilityYin090);
140
- border-bottom-left-radius: var(--borderRadius025);
141
- border-bottom-right-radius: var(--borderRadius025);
142
- }
143
- `}
144
130
  `}
145
131
 
146
132
  a,
@@ -182,6 +168,19 @@ const StyledLink = _styledComponents.default.span`
182
168
  `}
183
169
  }
184
170
 
171
+ ${!isSkipLink && !disabled && !theme.focusRedesignOptOut && hasFocus && (0, _styledComponents.css)`
172
+ a,
173
+ button {
174
+ outline: none;
175
+ text-decoration: none;
176
+ border-bottom-left-radius: var(--borderRadius000);
177
+ border-bottom-right-radius: var(--borderRadius000);
178
+ }
179
+ box-shadow: 0 4px 0 0 var(--colorsUtilityYin090);
180
+ border-bottom-left-radius: var(--borderRadius025);
181
+ border-bottom-right-radius: var(--borderRadius025);
182
+ `}
183
+
185
184
  button {
186
185
  background-color: transparent;
187
186
  border: none;
@@ -16,14 +16,6 @@ var _themes = require("../../../style/themes");
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
19
- const overrideLinkFocusStyling = fullScreenView => `
20
- &:focus-within {
21
- box-shadow: none;
22
- a {
23
- background-color: ${fullScreenView ? "var(--colorsComponentsMenuAutumnStandard600)" : "transparent"};
24
- }
25
- }
26
- `;
27
19
  const oldFocusStyling = `
28
20
  box-shadow: inset 0 0 0 var(--borderWidth300) var(--colorsSemanticFocus500);
29
21
  `;
@@ -54,19 +46,13 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
54
46
  font-weight: 700;
55
47
  height: 40px;
56
48
  position: relative;
57
-
58
- && {
59
- :focus-within > a, > button {
60
- background-color: transparent;
61
- }
62
- }
49
+ box-shadow: none;
63
50
 
64
51
  a,
65
52
  button {
66
53
  cursor: pointer;
67
54
  }
68
55
 
69
- ${overrideLinkFocusStyling(inFullscreenView)}
70
56
  a:focus,
71
57
  button:focus {
72
58
  ${({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "121.0.0",
3
+ "version": "121.0.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",