carbon-react 101.0.4 → 101.3.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.
@@ -11,6 +11,9 @@ export interface TooltipProviderProps {
11
11
  children: React.ReactNode;
12
12
  /** Aria label for rendered help component */
13
13
  helpAriaLabel?: string;
14
+ focusable?: boolean;
15
+ tooltipVisible?: boolean;
16
+ disabled?: boolean;
14
17
  }
15
18
 
16
19
  declare const ToolbarContext: React.Context<ToolbarContextProps>;
@@ -18,11 +18,17 @@ exports.TooltipContext = TooltipContext;
18
18
  const TooltipProvider = ({
19
19
  children,
20
20
  tooltipPosition,
21
- helpAriaLabel
21
+ helpAriaLabel,
22
+ focusable = true,
23
+ tooltipVisible,
24
+ disabled = false
22
25
  }) => /*#__PURE__*/_react.default.createElement(TooltipContext.Provider, {
23
26
  value: {
24
27
  tooltipPosition,
25
- helpAriaLabel
28
+ helpAriaLabel,
29
+ focusable,
30
+ tooltipVisible,
31
+ disabled
26
32
  }
27
33
  }, children);
28
34
 
@@ -30,5 +36,8 @@ exports.TooltipProvider = TooltipProvider;
30
36
  TooltipProvider.propTypes = {
31
37
  children: _propTypes.default.node.isRequired,
32
38
  tooltipPosition: _propTypes.default.oneOf(["top", "bottom", "left", "right"]),
33
- helpAriaLabel: _propTypes.default.string
39
+ helpAriaLabel: _propTypes.default.string,
40
+ focusable: _propTypes.default.bool,
41
+ tooltipVisible: _propTypes.default.bool,
42
+ disabled: _propTypes.default.bool
34
43
  };
@@ -39,6 +39,7 @@ const FlatTable = ({
39
39
  hasMaxHeight = false,
40
40
  ariaDescribedby,
41
41
  minHeight,
42
+ overflowX,
42
43
  ...rest
43
44
  }) => {
44
45
  const addDefaultHeight = !height && (hasStickyHead || hasStickyFooter);
@@ -57,16 +58,18 @@ const FlatTable = ({
57
58
  }) => /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTableWrapper, _extends({
58
59
  isInSidebar: isInSidebar,
59
60
  hasStickyHead: hasStickyHead,
60
- colorTheme: colorTheme
61
- }, rest, {
61
+ colorTheme: colorTheme,
62
62
  minHeight: minHeight,
63
63
  overflowY: !isInSidebar && (hasStickyHead || hasStickyFooter) ? "auto" : undefined,
64
64
  height: addDefaultHeight && !hasMaxHeight ? "99%" : height,
65
65
  maxHeight: hasMaxHeight ? "100%" : undefined,
66
66
  display: "flex",
67
67
  flexDirection: "column",
68
- justifyContent: hasStickyFooter || height ? "space-between" : undefined
69
- }), /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTable, _extends({
68
+ justifyContent: hasStickyFooter || height ? "space-between" : undefined,
69
+ tabIndex: "0",
70
+ role: "region",
71
+ overflowX: overflowX
72
+ }, rest), /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTable, _extends({
70
73
  "data-component": "flat-table"
71
74
  }, tableStylingProps), caption ? /*#__PURE__*/_react.default.createElement("caption", null, caption) : null, /*#__PURE__*/_react.default.createElement(FlatTableThemeContext.Provider, {
72
75
  value: {
@@ -114,7 +117,10 @@ FlatTable.propTypes = { ...marginPropTypes,
114
117
  size: _propTypes.default.oneOf(["compact", "small", "medium", "large", "extraLarge"]),
115
118
 
116
119
  /** Applies max-height of 100% to FlatTable if true */
117
- hasMaxHeight: _propTypes.default.bool
120
+ hasMaxHeight: _propTypes.default.bool,
121
+
122
+ /** Set the overflow X of the table wrapper. Any valid CSS string */
123
+ overflowX: _propTypes.default.string
118
124
  };
119
125
  FlatTable.defaultProps = {
120
126
  colorTheme: "dark",
@@ -107,6 +107,18 @@ const StyledFlatTableWrapper = (0, _styledComponents.default)(_box.default)`
107
107
  }) => (0, _styledComponents.css)`
108
108
  box-sizing: border-box;
109
109
 
110
+ :focus {
111
+ outline: 2px solid ${theme.colors.focus};
112
+
113
+ :not(:focus-visible) {
114
+ outline: none;
115
+ }
116
+
117
+ :focus-visible {
118
+ outline: 2px solid ${theme.colors.focus};
119
+ }
120
+ }
121
+
110
122
  ${isInSidebar ? "min-width: fit-content" : `box-shadow: inset 0px 0px 0px 1px ${theme.table.secondary}`};
111
123
  `}
112
124
 
@@ -57,6 +57,12 @@ const Icon = /*#__PURE__*/_react.default.forwardRef(({
57
57
  ...rest
58
58
  }, ref) => {
59
59
  const isInteractive = !!tooltipMessage && !disabled;
60
+ const {
61
+ tooltipPosition: tooltipPositionFromContext,
62
+ focusable: focusableFromContext,
63
+ tooltipVisible: tooltipVisibleFromContext,
64
+ disabled: disabledFromContext
65
+ } = (0, _react.useContext)(_tooltipProvider.TooltipContext);
60
66
  /** Return Icon type with overrides */
61
67
 
62
68
  const iconType = () => {
@@ -83,13 +89,14 @@ const Icon = /*#__PURE__*/_react.default.forwardRef(({
83
89
  }
84
90
  };
85
91
 
86
- const hasTooltip = !disabled && tooltipMessage && focusable;
92
+ const isFocusable = focusableFromContext !== undefined ? focusableFromContext : focusable;
93
+ const hasTooltip = !disabled && !disabledFromContext && tooltipMessage && isFocusable;
87
94
  const styleProps = {
88
95
  bg,
89
96
  bgSize,
90
97
  bgShape,
91
98
  color,
92
- disabled,
99
+ disabled: disabledFromContext || disabled,
93
100
  fontSize,
94
101
  isInteractive,
95
102
  type: iconType(),
@@ -108,12 +115,9 @@ const Icon = /*#__PURE__*/_react.default.forwardRef(({
108
115
  role: hasTooltip && role === undefined ? "tooltip" : role
109
116
  }));
110
117
 
111
- const {
112
- tooltipPosition: tooltipPositionFromContext
113
- } = (0, _react.useContext)(_tooltipProvider.TooltipContext);
114
-
115
118
  if (tooltipMessage) {
116
- const visible = disabled ? false : tooltipVisible;
119
+ const showTooltip = tooltipVisibleFromContext !== undefined ? tooltipVisibleFromContext : tooltipVisible;
120
+ const visible = disabled ? false : showTooltip;
117
121
  return /*#__PURE__*/_react.default.createElement(_tooltip.default, {
118
122
  message: tooltipMessage,
119
123
  position: tooltipPositionFromContext || tooltipPosition,
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
@@ -19,8 +19,14 @@ var _icon = _interopRequireDefault(require("../icon"));
19
19
 
20
20
  var _utils = require("../../style/utils");
21
21
 
22
+ var _tooltipProvider = require("../../__internal__/tooltip-provider");
23
+
22
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
25
 
26
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
27
+
28
+ 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; }
29
+
24
30
  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); }
25
31
 
26
32
  const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
@@ -29,9 +35,16 @@ const IconButton = /*#__PURE__*/_react.default.forwardRef(({
29
35
  "aria-label": ariaLabel,
30
36
  onAction,
31
37
  children,
38
+ disabled,
32
39
  ...rest
33
40
  }, ref) => {
34
41
  const marginProps = (0, _utils.filterStyledSystemMarginProps)(rest);
42
+ const hasIconWithTooltip = !!_react.default.Children.toArray(children).find(child => {
43
+ var _child$props;
44
+
45
+ return child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.tooltipMessage;
46
+ });
47
+ const [tooltipVisible, setTooltipVisible] = (0, _react.useState)(undefined);
35
48
 
36
49
  const onKeyDown = e => {
37
50
  if (_events.default.isEnterKey(e) || _events.default.isSpaceKey(e)) {
@@ -46,12 +59,27 @@ const IconButton = /*#__PURE__*/_react.default.forwardRef(({
46
59
  onAction(e);
47
60
  };
48
61
 
62
+ const handleTooltipVisibility = (ev, callbackName) => {
63
+ setTooltipVisible(["onFocus", "onMouseEnter"].includes(callbackName));
64
+ if (rest[callbackName]) rest[callbackName](ev);
65
+ };
66
+
49
67
  return /*#__PURE__*/_react.default.createElement(_iconButton.default, _extends({}, rest, {
50
68
  "aria-label": ariaLabel,
51
69
  onKeyDown: onKeyDown,
52
70
  onClick: handleOnAction,
53
- ref: ref
54
- }, marginProps), children);
71
+ ref: ref,
72
+ disabled: disabled
73
+ }, !disabled && hasIconWithTooltip && {
74
+ onFocus: ev => handleTooltipVisibility(ev, "onFocus"),
75
+ onBlur: ev => handleTooltipVisibility(ev, "onBlur"),
76
+ onMouseEnter: ev => handleTooltipVisibility(ev, "onMouseEnter"),
77
+ onMouseLeave: ev => handleTooltipVisibility(ev, "onMouseLeave")
78
+ }, marginProps), /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
79
+ disabled: disabled,
80
+ tooltipVisible: tooltipVisible,
81
+ focusable: false
82
+ }, children));
55
83
  });
56
84
 
57
85
  IconButton.propTypes = { ...marginPropTypes,
@@ -65,7 +93,10 @@ IconButton.propTypes = { ...marginPropTypes,
65
93
  onAction: _propTypes.default.func.isRequired,
66
94
 
67
95
  /** Prop to specify the aria-label of the icon-button component */
68
- "aria-label": _propTypes.default.string
96
+ "aria-label": _propTypes.default.string,
97
+
98
+ /** Set the button to disabled */
99
+ disabled: _propTypes.default.bool
69
100
  };
70
101
  var _default = IconButton;
71
102
  exports.default = _default;
@@ -7,6 +7,8 @@ export interface IconButtonProps extends MarginProps {
7
7
  children: React.ReactElement<IconProps>;
8
8
  /** Callback */
9
9
  onAction: React.MouseEventHandler<HTMLButtonElement>;
10
+ /** Set the button to disabled */
11
+ disabled?: boolean;
10
12
  }
11
13
 
12
14
  declare function IconButton(
@@ -344,7 +344,7 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
344
344
  } = optionData;
345
345
 
346
346
  if (selectionType === "navigationKey") {
347
- setHighlightedValue("");
347
+ setHighlightedValue(newValue);
348
348
  return;
349
349
  }
350
350
 
@@ -353,26 +353,23 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
353
353
  }
354
354
 
355
355
  setTextValue("");
356
+ const isAlreadySelected = selectedValue.findIndex(val => (0, _isExpectedValue.default)(val, newValue)) !== -1;
357
+
358
+ if (!isAlreadySelected && isControlled.current && onChange) {
359
+ onChange(createCustomEvent([...selectedValue, newValue]));
360
+ }
361
+
356
362
  setSelectedValue(previousValue => {
357
363
  textboxRef.focus();
358
364
  isMouseDownReported.current = false;
359
- const isAlreadySelected = previousValue.findIndex(val => (0, _isExpectedValue.default)(val, newValue)) !== -1;
360
365
 
361
366
  if (isAlreadySelected) {
362
367
  return previousValue;
363
368
  }
364
369
 
365
- const valueList = [...previousValue, newValue];
366
-
367
- if (isControlled.current && onChange) {
368
- onChange(createCustomEvent(valueList));
369
- return previousValue;
370
- }
371
-
372
- return valueList;
370
+ return [...previousValue, newValue];
373
371
  });
374
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
375
- [createCustomEvent, onChange, textboxRef]);
372
+ }, [createCustomEvent, onChange, textboxRef, selectedValue]);
376
373
 
377
374
  function onSelectListClose() {
378
375
  setOpenState(false);
@@ -0,0 +1 @@
1
+ export { default } from "./tab-title";
@@ -52,6 +52,7 @@ const TabTitle = /*#__PURE__*/_react.default.forwardRef(({
52
52
  isInSidebar,
53
53
  href,
54
54
  onKeyDown,
55
+ align,
55
56
  ...tabTitleProps
56
57
  }, ref) => {
57
58
  const keys = (0, _react.useRef)([]);
@@ -74,6 +75,8 @@ const TabTitle = /*#__PURE__*/_react.default.forwardRef(({
74
75
  };
75
76
 
76
77
  const handleClick = ev => {
78
+ var _ref$current;
79
+
77
80
  ev.preventDefault();
78
81
  const customEvent = { ...ev,
79
82
  target: { ...ev.target,
@@ -86,8 +89,10 @@ const TabTitle = /*#__PURE__*/_react.default.forwardRef(({
86
89
  if (href) {
87
90
  onClick(customEvent);
88
91
  return window.open(href, "_blank");
89
- }
92
+ } // safari does not focus buttons by default
90
93
 
94
+
95
+ (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
91
96
  return onClick(customEvent);
92
97
  };
93
98
 
@@ -131,18 +136,17 @@ const TabTitle = /*#__PURE__*/_react.default.forwardRef(({
131
136
  error: error,
132
137
  warning: warning,
133
138
  info: info,
134
- size: size,
135
139
  noRightBorder: noRightBorder,
136
140
  alternateStyling: alternateStyling || isInSidebar,
137
141
  borders: borders,
138
142
  isInSidebar: isInSidebar
139
- }, tabTitleProps, (0, _tags.default)("tab-header", tabTitleProps), {
140
- onKeyDown: handleKeyDown
141
- }), /*#__PURE__*/_react.default.createElement(_tabTitle.StyledTitleContent, _extends({}, isHref && {
143
+ }, tabTitleProps, isHref && {
142
144
  href,
143
145
  target: "_blank",
144
146
  as: "a"
145
- }, {
147
+ }, (0, _tags.default)("tab-header", tabTitleProps), {
148
+ onKeyDown: handleKeyDown
149
+ }), /*#__PURE__*/_react.default.createElement(_tabTitle.StyledTitleContent, {
146
150
  error: error,
147
151
  warning: warning,
148
152
  info: info,
@@ -155,23 +159,29 @@ const TabTitle = /*#__PURE__*/_react.default.forwardRef(({
155
159
  hasSiblings: !!siblings,
156
160
  isTabSelected: isTabSelected,
157
161
  hasCustomLayout: !!customLayout,
158
- alternateStyling: hasAlternateStyling
159
- }), renderContent(), isHref && /*#__PURE__*/_react.default.createElement(_icon.default, {
162
+ alternateStyling: hasAlternateStyling,
163
+ align: align,
164
+ hasHref: !!href
165
+ }, renderContent(), isHref && /*#__PURE__*/_react.default.createElement(_icon.default, {
160
166
  type: "link"
161
- }), /*#__PURE__*/_react.default.createElement(_tabTitle.StyledLayoutWrapper, {
167
+ }), hasFailedValidation && /*#__PURE__*/_react.default.createElement(_tabTitle.StyledLayoutWrapper, {
168
+ position: position,
162
169
  hasCustomSibling: !!customLayout
163
170
  }, error && /*#__PURE__*/_react.default.createElement(_validationIcon.default, {
164
171
  onClick: handleClick,
165
172
  tooltipPosition: "top",
166
- error: errorMessage
173
+ error: errorMessage,
174
+ tabIndex: null
167
175
  }), !error && warning && /*#__PURE__*/_react.default.createElement(_validationIcon.default, {
168
176
  onClick: handleClick,
169
177
  tooltipPosition: "top",
170
- warning: warningMessage
178
+ warning: warningMessage,
179
+ tabIndex: null
171
180
  }), !warning && !error && info && /*#__PURE__*/_react.default.createElement(_validationIcon.default, {
172
181
  onClick: handleClick,
173
182
  tooltipPosition: "top",
174
- info: infoMessage
183
+ info: infoMessage,
184
+ tabIndex: null
175
185
  }))), !(hasFailedValidation || hasAlternateStyling) && isTabSelected && /*#__PURE__*/_react.default.createElement(_tabTitle.StyledSelectedIndicator, {
176
186
  "data-element": "tab-selected-indicator",
177
187
  position: position,
@@ -204,7 +214,8 @@ TabTitle.propTypes = {
204
214
  noRightBorder: _propTypes.default.bool,
205
215
  customLayout: _propTypes.default.node,
206
216
  isInSidebar: _propTypes.default.bool,
207
- href: _propTypes.default.string
217
+ href: _propTypes.default.string,
218
+ align: _propTypes.default.oneOf(["left", "right"])
208
219
  };
209
220
  var _default = TabTitle;
210
221
  exports.default = _default;
@@ -0,0 +1,39 @@
1
+ import * as React from "react";
2
+
3
+ export interface TabTitleProps {
4
+ title: string;
5
+ id?: string;
6
+ dataTabId?: string;
7
+ className?: string;
8
+ children?: React.ReactNode;
9
+ isTabSelected?: boolean;
10
+ position?: "top" | "left";
11
+ errorMessage?: string;
12
+ warningMessage?: string;
13
+ infoMessage?: string;
14
+ errors?: boolean;
15
+ warning?: boolean;
16
+ info?: boolean;
17
+ borders?: boolean;
18
+ noLeftBorder?: boolean;
19
+ noRightBorder?: boolean;
20
+ alternateStyling?: boolean;
21
+ isInSidebar?: boolean;
22
+ siblings?: React.ReactNode[];
23
+ titlePosition?: "before" | "after";
24
+ href?: string;
25
+ tabIndex?: string;
26
+ size?: "default" | "large";
27
+ align?: "left" | "right";
28
+ customLayout?: React.ReactNode;
29
+ onClick?: (
30
+ ev: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>
31
+ ) => void;
32
+ onKeyDown?: (
33
+ ev: React.KeyboardEvent<HTMLButtonElement | HTMLAnchorElement>
34
+ ) => void;
35
+ }
36
+
37
+ declare function TabTitle(props: TabTitleProps): JSX.Element;
38
+
39
+ export default TabTitle;
@@ -21,8 +21,9 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
21
21
 
22
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; }
23
23
 
24
- const StyledTitleContent = _styledComponents.default.div`
24
+ const StyledTitleContent = _styledComponents.default.span`
25
25
  outline: none;
26
+ display: inline-block;
26
27
 
27
28
  ${({
28
29
  theme,
@@ -32,17 +33,22 @@ const StyledTitleContent = _styledComponents.default.div`
32
33
  noLeftBorder,
33
34
  noRightBorder,
34
35
  isTabSelected,
35
- hasSiblings,
36
- href,
36
+ hasHref,
37
37
  error,
38
- warning,
39
- info,
40
- alternateStyling
38
+ alternateStyling,
39
+ align
41
40
  }) => (0, _styledComponents.css)`
42
41
  line-height: 20px;
43
42
  margin: 0;
43
+ text-align: ${align};
44
+
45
+ ${position === "left" && (0, _styledComponents.css)`
46
+ display: flex;
47
+ width: 100%;
48
+ justify-content: ${align === "right" ? "flex-end" : "flex-start"};
49
+ `}
44
50
 
45
- ${href && (0, _styledComponents.css)`
51
+ ${hasHref && (0, _styledComponents.css)`
46
52
  color: ${theme.text.color};
47
53
  display: block;
48
54
  text-decoration: none;
@@ -81,10 +87,8 @@ const StyledTitleContent = _styledComponents.default.div`
81
87
 
82
88
  ${size === "large" && position === "top" && (0, _styledComponents.css)`
83
89
  padding: 10px 24px;
90
+ ${borders && `padding-bottom: 9px;`}
84
91
  font-size: 16px;
85
- ${isTabSelected && !hasSiblings && !(error || warning || info) && (0, _styledComponents.css)`
86
- padding-bottom: 6px;
87
- `}
88
92
  `}
89
93
 
90
94
  ${size === "large" && position === "left" && (0, _styledComponents.css)`
@@ -95,11 +99,12 @@ const StyledTitleContent = _styledComponents.default.div`
95
99
 
96
100
  ${size === "default" && (0, _styledComponents.css)`
97
101
  padding: 10px 16px;
98
- ${isTabSelected && !(error || warning || info) && position === "top" && (0, _styledComponents.css)`
99
- padding-bottom: 8px;
100
- `}
101
102
 
102
- ${position === "left" && !isTabSelected && !alternateStyling && error && `margin-right: -2px;`}
103
+ ${borders && `padding-bottom: 9px;`}
104
+
105
+ ${position === "left" && !isTabSelected && !alternateStyling && error && `
106
+ margin-right: -2px;
107
+ `}
103
108
  `}
104
109
  `}
105
110
 
@@ -131,7 +136,7 @@ const StyledTitleContent = _styledComponents.default.div`
131
136
  padding-right: ${size === "large" ? "26px;" : "18px;"};
132
137
  `}
133
138
 
134
- &:hover {
139
+ &:hover {
135
140
  outline: 1px solid;
136
141
  outline-offset: -1px;
137
142
 
@@ -174,10 +179,10 @@ const StyledTitleContent = _styledComponents.default.div`
174
179
 
175
180
  ${position === "left" && (0, _styledComponents.css)`
176
181
  border-right-color: transparent;
177
- padding-right: ${size === "large" ? "26px;" : "18px;"};
182
+ padding-right: ${size === "large" ? "26px" : "18px"};
178
183
  `}
179
184
 
180
- &:hover {
185
+ &:hover {
181
186
  outline: 2px solid ${theme.colors.error};
182
187
  outline-offset: -2px;
183
188
  ${position === "top" && (0, _styledComponents.css)`
@@ -190,7 +195,7 @@ const StyledTitleContent = _styledComponents.default.div`
190
195
 
191
196
  ${position === "left" && (0, _styledComponents.css)`
192
197
  border-right-color: transparent;
193
- padding-right: ${size === "large" ? "26px;" : "18px;"};
198
+ padding-right: ${size === "large" ? "26px" : "18px"};
194
199
  `}
195
200
  }
196
201
  `}
@@ -206,23 +211,11 @@ const StyledTitleContent = _styledComponents.default.div`
206
211
  position
207
212
  }) => hasSiblings && !hasCustomLayout && position === "top" && (0, _styledComponents.css)`
208
213
  height: 20px;
214
+ padding-top: 10px;
215
+ padding-bottom: 10px;
209
216
 
210
- ${size === "default" && (0, _styledComponents.css)`
211
- padding-top: 10px;
212
- padding-bottom: 10px;
213
-
214
- ${!(error || warning || info) && isTabSelected && (0, _styledComponents.css)`
215
- padding-bottom: 8px;
216
- `}
217
- `}
218
-
219
- ${size === "large" && (0, _styledComponents.css)`
220
- padding-top: 10px;
221
- padding-bottom: 10px;
222
-
223
- ${!(error || warning || info) && isTabSelected && (0, _styledComponents.css)`
224
- padding-bottom: 6px;
225
- `}
217
+ ${size === "large" && !(error || warning || info) && isTabSelected && (0, _styledComponents.css)`
218
+ padding-bottom: 6px;
226
219
  `}
227
220
  `}
228
221
 
@@ -238,13 +231,13 @@ const StyledTitleContent = _styledComponents.default.div`
238
231
  display: flex;
239
232
 
240
233
  ${position === "left" && (0, _styledComponents.css)`
241
- padding: ${size === "large" ? "2px;" : "0px;"}
242
- ${isTabSelected && (0, _styledComponents.css)`
243
- padding-right: 0px;
244
- `}
245
- ${(error || warning || info) && (0, _styledComponents.css)`
246
- padding-right: ${size === "large" ? "26px" : "18px"};
247
- `};
234
+ padding: ${size === "large" ? "2px" : "0px"};
235
+ ${isTabSelected && (0, _styledComponents.css)`
236
+ padding-right: 0px;
237
+ `}
238
+ ${(error || warning || info) && (0, _styledComponents.css)`
239
+ padding-right: ${size === "large" ? "26px" : "18px"};
240
+ `}
248
241
  `}
249
242
 
250
243
  ${position === "top" && (0, _styledComponents.css)`
@@ -253,49 +246,63 @@ const StyledTitleContent = _styledComponents.default.div`
253
246
  padding-bottom: 0px;
254
247
  `}
255
248
  ${(error || warning || info) && (0, _styledComponents.css)`
256
- padding-bottom: ${size === "large" ? "4px;" : "2px;"}
257
- padding-right: ${size === "large" ? "18px;" : "14px;"}
258
-
259
- &:hover {
260
249
  padding-bottom: ${size === "large" ? "4px;" : "2px;"}
261
- }
262
- `};
250
+ padding-right: ${size === "large" ? "18px;" : "14px;"}
251
+
252
+ &:hover {
253
+ padding-bottom: ${size === "large" ? "4px;" : "2px;"}
254
+ }
255
+ `};
263
256
  `}
264
257
  `}
265
258
  `;
266
259
  exports.StyledTitleContent = StyledTitleContent;
267
- const StyledTabTitle = _styledComponents.default.li`
260
+ const StyledTabTitle = _styledComponents.default.button`
268
261
  background-color: transparent;
269
262
  display: inline-block;
270
263
  font-weight: bold;
271
- height: 100%;
272
264
  position: relative;
265
+ border: none;
266
+ cursor: pointer;
267
+ font-size: 14px;
268
+ padding: 0px;
269
+ text-decoration: none;
270
+ outline-offset: 0px;
271
+ margin: 0;
272
+
273
+ a:visited {
274
+ color: inherit;
275
+ }
273
276
 
274
277
  ${({
275
278
  position,
276
279
  borders,
277
280
  noRightBorder,
278
281
  noLeftBorder
279
- }) => `
280
- ${position === "top" && (0, _styledComponents.css)`
281
- ${borders && !(noRightBorder || noLeftBorder) && (0, _styledComponents.css)`
282
- &:not(:first-of-type) {
283
- margin-left: -1px;
284
- }
285
- `}
286
- `}
287
- ${position === "left" && (0, _styledComponents.css)`
288
- ${borders && (0, _styledComponents.css)`
289
- &:not(:first-of-type) {
290
- margin-top: -1px;
291
- }
292
- `}
293
- `}
294
- `}
282
+ }) => (0, _styledComponents.css)`
283
+ ${position === "top" && (0, _styledComponents.css)`
284
+ height: 40px;
295
285
 
296
- &:first-child {
297
- margin-left: 0;
298
- }
286
+ ${borders && !(noRightBorder || noLeftBorder) && (0, _styledComponents.css)`
287
+ &:nth-of-type(n + 1) {
288
+ margin-left: -1px;
289
+ }
290
+ &:first-child {
291
+ margin-left: 0;
292
+ }
293
+ `}
294
+ `}
295
+ ${position === "left" && (0, _styledComponents.css)`
296
+ ${borders && (0, _styledComponents.css)`
297
+ &:nth-of-type(n + 1) {
298
+ margin-top: -1px;
299
+ }
300
+ &:first-child {
301
+ margin-top: 0;
302
+ }
303
+ `}
304
+ `}
305
+ `}
299
306
 
300
307
  ${({
301
308
  isTabSelected,
@@ -319,27 +326,12 @@ const StyledTabTitle = _styledComponents.default.li`
319
326
  error,
320
327
  warning,
321
328
  info,
322
- size,
323
- isInSidebar,
324
- position
329
+ isInSidebar
325
330
  }) => isTabSelected && (0, _styledComponents.css)`
326
331
  ${!isInSidebar && "z-index: 1;"}
327
332
  color: ${theme.text.color};
328
333
  background-color: ${theme.colors.white};
329
334
 
330
- ${alternateStyling && (0, _styledComponents.css)`
331
- border-bottom: 2px solid ${theme.tab.background};
332
- `}
333
-
334
- ${!alternateStyling && (0, _styledComponents.css)`
335
- padding-bottom: 2px;
336
- `}
337
-
338
- ${size === "large" && (0, _styledComponents.css)`
339
- ${position === "top" && `
340
- padding-bottom: ${alternateStyling ? "3px" : "4px"};
341
- `}
342
- `}
343
335
  ${(error || warning || info) && (0, _styledComponents.css)`
344
336
  padding-bottom: 0px;
345
337
  `}
@@ -364,7 +356,6 @@ const StyledTabTitle = _styledComponents.default.li`
364
356
 
365
357
  ${({
366
358
  position,
367
- size,
368
359
  borders,
369
360
  theme,
370
361
  alternateStyling,
@@ -387,7 +378,7 @@ const StyledTabTitle = _styledComponents.default.li`
387
378
  }
388
379
  `}
389
380
 
390
- display: block;
381
+ display: flex;
391
382
  height: auto;
392
383
  margin-left: 0px;
393
384
 
@@ -422,12 +413,6 @@ const StyledTabTitle = _styledComponents.default.li`
422
413
 
423
414
  background-color: ${theme.colors.white};
424
415
 
425
- ${size === "large" && (0, _styledComponents.css)`
426
- & ${StyledTitleContent} {
427
- padding-right: 22px;
428
- }
429
- `}
430
-
431
416
  &:hover {
432
417
  ${alternateStyling && ` border-right-color: ${theme.tab.background};`}
433
418
  background-color: ${theme.colors.white};
@@ -473,7 +458,8 @@ const StyledLayoutWrapper = _styledComponents.default.div`
473
458
  ${({
474
459
  hasCustomLayout,
475
460
  titlePosition,
476
- hasCustomSibling
461
+ hasCustomSibling,
462
+ position
477
463
  }) => !hasCustomLayout && (0, _styledComponents.css)`
478
464
  display: inline-flex;
479
465
 
@@ -500,7 +486,7 @@ const StyledLayoutWrapper = _styledComponents.default.div`
500
486
  ${_icon.default} {
501
487
  height: 16px;
502
488
  left: -2px;
503
- top: 3px;
489
+ top: ${position === "left" ? "1px" : "3px"};
504
490
  }
505
491
  }
506
492
  `}
@@ -0,0 +1 @@
1
+ export { default } from "./tab-header";
@@ -0,0 +1,16 @@
1
+ import * as React from "react";
2
+
3
+ export interface TabHeaderProps {
4
+ role?: string;
5
+ position?: "top" | "left";
6
+ extendedLine?: boolean;
7
+ noRightBorder?: boolean;
8
+ alternateStyling?: boolean;
9
+ isInSidebar?: boolean;
10
+ children: React.ReactNode;
11
+ align?: "left" | "right";
12
+ }
13
+
14
+ declare function TabHeader(props: TabHeaderProps): JSX.Element;
15
+
16
+ export default TabHeader;
@@ -50,7 +50,7 @@ const StyledTabsHeaderWrapper = _styledComponents.default.div`
50
50
  `}
51
51
  `;
52
52
  exports.StyledTabsHeaderWrapper = StyledTabsHeaderWrapper;
53
- const StyledTabsHeaderList = _styledComponents.default.ul`
53
+ const StyledTabsHeaderList = _styledComponents.default.div`
54
54
  display: flex;
55
55
  box-shadow: inset 0px ${computeLineWidth} 0px 0px
56
56
  ${({
@@ -249,6 +249,7 @@ const Tabs = ({
249
249
  noRightBorder: ["no right side", "no sides"].includes(borders),
250
250
  customLayout: customLayout,
251
251
  isInSidebar: isInSidebar,
252
+ align: align,
252
253
  onFocus: () => {
253
254
  if (!hasTabStop(tabId)) {
254
255
  setTabStopId(tabId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "101.0.4",
3
+ "version": "101.3.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {