@atlaskit/tabs 13.4.9 → 14.0.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/tabs
2
2
 
3
+ ## 14.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#41866](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41866) [`ed8b6957789`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ed8b6957789) - Removes any usage of deprecated legacy theming APIs. These have been superseeded by design tokens.
8
+
3
9
  ## 13.4.9
4
10
 
5
11
  ### Patch Changes
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = require("react");
8
8
  var _react2 = require("@emotion/react");
9
- var _components = require("@atlaskit/theme/components");
10
9
  var _hooks = require("../hooks");
11
10
  var _context = require("../internal/context");
12
11
  var _styles = require("../internal/styles");
@@ -19,6 +18,9 @@ var baseStyles = (0, _react2.css)({
19
18
  position: 'relative'
20
19
  });
21
20
 
21
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
22
+ var tabListStyles = (0, _styles.getTabListStyles)();
23
+
22
24
  /**
23
25
  * __TabList__
24
26
  *
@@ -30,8 +32,6 @@ var baseStyles = (0, _react2.css)({
30
32
  */
31
33
  var TabList = function TabList(_ref) {
32
34
  var children = _ref.children;
33
- var _useGlobalTheme = (0, _components.useGlobalTheme)(),
34
- mode = _useGlobalTheme.mode;
35
35
  var _useTabList = (0, _hooks.useTabList)(),
36
36
  tabsId = _useTabList.tabsId,
37
37
  selected = _useTabList.selected,
@@ -41,9 +41,6 @@ var TabList = function TabList(_ref) {
41
41
  // Don't include any conditional children
42
42
  var childrenArray = _react.Children.toArray(children).filter(Boolean);
43
43
  var length = childrenArray.length;
44
- var tabListStyles = (0, _react.useMemo)(function () {
45
- return (0, _styles.getTabListStyles)(mode);
46
- }, [mode]);
47
44
  var selectTabByIndex = (0, _react.useCallback)(function (index) {
48
45
  var _ref$current;
49
46
  var newSelectedNode = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector("[id='".concat(tabsId, "-").concat(index, "']"));
@@ -11,7 +11,6 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
11
11
  var _react = require("react");
12
12
  var _react2 = require("@emotion/react");
13
13
  var _usePlatformLeafEventHandler = require("@atlaskit/analytics-next/usePlatformLeafEventHandler");
14
- var _components = require("@atlaskit/theme/components");
15
14
  var _context = require("../internal/context");
16
15
  var _styles = require("../internal/styles");
17
16
  var _utils = require("../internal/utils");
@@ -25,10 +24,13 @@ var baseStyles = (0, _react2.css)({
25
24
  flexDirection: 'column',
26
25
  flexGrow: 1
27
26
  });
27
+
28
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
29
+ var tabsStyles = (0, _styles.getTabsStyles)();
28
30
  var analyticsAttributes = {
29
31
  componentName: 'tabs',
30
32
  packageName: "@atlaskit/tabs",
31
- packageVersion: "13.4.9"
33
+ packageVersion: "14.0.0"
32
34
  };
33
35
  var getTabPanelWithContext = function getTabPanelWithContext(_ref) {
34
36
  var tabPanel = _ref.tabPanel,
@@ -70,8 +72,6 @@ var Tabs = function Tabs(props) {
70
72
  analyticsContext = props.analyticsContext,
71
73
  children = props.children,
72
74
  testId = props.testId;
73
- var _useGlobalTheme = (0, _components.useGlobalTheme)(),
74
- mode = _useGlobalTheme.mode;
75
75
  var _useState = (0, _react.useState)(SelectedType || defaultSelected || 0),
76
76
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
77
77
  selectedState = _useState2[0],
@@ -118,9 +118,6 @@ var Tabs = function Tabs(props) {
118
118
  tabsId: id
119
119
  });
120
120
  });
121
- var tabsStyles = (0, _react.useMemo)(function () {
122
- return (0, _styles.getTabsStyles)(mode);
123
- }, [mode]);
124
121
  return (
125
122
  // Only styles that affect the Tabs container itself have been applied via primitives.
126
123
  // The other styles applied through the CSS prop are there for styling children
@@ -3,48 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getTabPanelFocusColor = exports.getTabLineColor = exports.getTabColors = void 0;
6
+ exports.tabPanelFocusColor = exports.tabLineColors = exports.tabColors = void 0;
7
7
  var _colors = require("@atlaskit/theme/colors");
8
- var tabColorMap = {
9
- light: {
10
- labelColor: "var(--ds-text-subtle, ".concat(_colors.N500, ")"),
11
- activeLabelColor: "var(--ds-text, ".concat(_colors.B500, ")"),
12
- hoverLabelColor: "var(--ds-text-subtle, ".concat(_colors.B400, ")"),
13
- selectedColor: "var(--ds-text-selected, ".concat(_colors.B400, ")"),
14
- focusBorderColor: "var(--ds-border-focused, ".concat(_colors.B100, ")")
15
- },
16
- dark: {
17
- labelColor: "var(--ds-text-subtle, ".concat(_colors.DN400, ")"),
18
- activeLabelColor: "var(--ds-text, ".concat(_colors.B200, ")"),
19
- hoverLabelColor: "var(--ds-text-subtle, ".concat(_colors.B75, ")"),
20
- selectedColor: "var(--ds-text-selected, ".concat(_colors.B75, ")"),
21
- focusBorderColor: "var(--ds-border-focused, ".concat(_colors.B75, ")")
22
- }
8
+ var tabColors = exports.tabColors = {
9
+ labelColor: "var(--ds-text-subtle, ".concat(_colors.N500, ")"),
10
+ activeLabelColor: "var(--ds-text, ".concat(_colors.B500, ")"),
11
+ hoverLabelColor: "var(--ds-text-subtle, ".concat(_colors.B400, ")"),
12
+ selectedColor: "var(--ds-text-selected, ".concat(_colors.B400, ")"),
13
+ focusBorderColor: "var(--ds-border-focused, ".concat(_colors.B100, ")")
23
14
  };
24
- var getTabColors = exports.getTabColors = function getTabColors(mode) {
25
- return tabColorMap[mode];
15
+ var tabLineColors = exports.tabLineColors = {
16
+ lineColor: "var(--ds-border, ".concat(_colors.N30, ")"),
17
+ hoveredColor: "var(--ds-border, transparent)",
18
+ activeColor: "var(--ds-border, transparent)",
19
+ selectedColor: "var(--ds-border-selected, ".concat(_colors.B400, ")")
26
20
  };
27
- var tabLineColorMap = {
28
- light: {
29
- lineColor: "var(--ds-border, ".concat(_colors.N30, ")"),
30
- hoveredColor: "var(--ds-border, transparent)",
31
- activeColor: "var(--ds-border, transparent)",
32
- selectedColor: "var(--ds-border-selected, ".concat(_colors.B400, ")")
33
- },
34
- dark: {
35
- lineColor: "var(--ds-border, ".concat(_colors.DN0, ")"),
36
- hoveredColor: "var(--ds-border, transparent)",
37
- activeColor: "var(--ds-border, transparent)",
38
- selectedColor: "var(--ds-border-selected, ".concat(_colors.B75, ")")
39
- }
40
- };
41
- var getTabLineColor = exports.getTabLineColor = function getTabLineColor(mode) {
42
- return tabLineColorMap[mode];
43
- };
44
- var tabPanelFocusColorMap = {
45
- light: "var(--ds-border-focused, ".concat(_colors.B100, ")"),
46
- dark: "var(--ds-border-focused, ".concat(_colors.B75, ")")
47
- };
48
- var getTabPanelFocusColor = exports.getTabPanelFocusColor = function getTabPanelFocusColor(mode) {
49
- return tabPanelFocusColorMap[mode];
50
- };
21
+ var tabPanelFocusColor = exports.tabPanelFocusColor = "var(--ds-border-focused, ".concat(_colors.B100, ")");
@@ -27,14 +27,14 @@ var highContrastFocusRing = {
27
27
  }
28
28
  }
29
29
  };
30
- var tabFocusStyles = function tabFocusStyles(mode) {
30
+ var tabFocusStyles = function tabFocusStyles() {
31
31
  return {
32
- boxShadow: "0 0 0 2px ".concat((0, _colors.getTabPanelFocusColor)(mode), " inset"),
32
+ boxShadow: "0 0 0 2px ".concat(_colors.tabPanelFocusColor, " inset"),
33
33
  borderRadius: "var(--ds-border-radius, 3px)",
34
34
  outline: 'none'
35
35
  };
36
36
  };
37
- var getTabPanelStyles = function getTabPanelStyles(mode) {
37
+ var getTabPanelStyles = function getTabPanelStyles() {
38
38
  return _objectSpread({
39
39
  flexGrow: 1,
40
40
  /*
@@ -44,17 +44,17 @@ var getTabPanelStyles = function getTabPanelStyles(mode) {
44
44
  minHeight: '0%',
45
45
  display: 'flex',
46
46
  padding: "0 ".concat(tabLeftRightPadding),
47
- '&:focus-visible': tabFocusStyles(mode),
47
+ '&:focus-visible': tabFocusStyles(),
48
48
  '@supports not selector(*:focus-visible)': {
49
- '&:focus': tabFocusStyles(mode)
49
+ '&:focus': tabFocusStyles()
50
50
  }
51
51
  }, highContrastFocusRing);
52
52
  };
53
- var getTabsStyles = exports.getTabsStyles = function getTabsStyles(mode) {
53
+ var getTabsStyles = exports.getTabsStyles = function getTabsStyles() {
54
54
  return (
55
55
  // eslint-disable-next-line @repo/internal/styles/no-exported-styles
56
56
  (0, _react.css)({
57
- '& [role="tabpanel"]': getTabPanelStyles(mode),
57
+ '& [role="tabpanel"]': getTabPanelStyles(),
58
58
  // The hidden attribute doesn't work on flex elements
59
59
  // Change display to be none
60
60
  // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
@@ -74,22 +74,22 @@ var tabLineStyles = {
74
74
  left: tabLeftRightPadding,
75
75
  right: tabLeftRightPadding
76
76
  };
77
- var getTabListStyles = exports.getTabListStyles = function getTabListStyles(mode) {
77
+ var getTabListStyles = exports.getTabListStyles = function getTabListStyles() {
78
78
  return (
79
79
  // eslint-disable-next-line @repo/internal/styles/no-exported-styles
80
80
  (0, _react.css)({
81
- '& [role="tab"]': getTabStyles(mode),
81
+ '& [role="tab"]': getTabStyles(),
82
82
  fontWeight: "var(--ds-font-weight-medium, 500)",
83
83
  '&::before': _objectSpread(_objectSpread({}, tabLineStyles), {}, {
84
84
  height: underlineHeight,
85
85
  // This line is not a border so the selected line is visible in high contrast mode
86
- backgroundColor: (0, _colors.getTabLineColor)(mode).lineColor
86
+ backgroundColor: _colors.tabLineColors.lineColor
87
87
  })
88
88
  })
89
89
  );
90
90
  };
91
- var tabPanelFocusStyles = function tabPanelFocusStyles(mode) {
92
- var colors = (0, _colors.getTabColors)(mode);
91
+ var tabPanelFocusStyles = function tabPanelFocusStyles() {
92
+ var colors = _colors.tabColors;
93
93
  return {
94
94
  boxShadow: "0 0 0 2px ".concat(colors.focusBorderColor, " inset"),
95
95
  borderRadius: "var(--ds-border-radius, 3px)",
@@ -100,8 +100,8 @@ var tabPanelFocusStyles = function tabPanelFocusStyles(mode) {
100
100
  }
101
101
  };
102
102
  };
103
- var getTabStyles = exports.getTabStyles = function getTabStyles(mode) {
104
- var colors = (0, _colors.getTabColors)(mode);
103
+ var getTabStyles = exports.getTabStyles = function getTabStyles() {
104
+ var colors = _colors.tabColors;
105
105
  return _objectSpread(_objectSpread({
106
106
  color: colors.labelColor,
107
107
  cursor: 'pointer',
@@ -116,7 +116,7 @@ var getTabStyles = exports.getTabStyles = function getTabStyles(mode) {
116
116
  // TODO: interaction states will be reviewed in DSP-1438
117
117
  color: colors.hoverLabelColor,
118
118
  '&::after': _objectSpread(_objectSpread({}, tabLineStyles), {}, {
119
- borderBottom: "".concat(underlineHeight, " solid ").concat((0, _colors.getTabLineColor)(mode).hoveredColor),
119
+ borderBottom: "".concat(underlineHeight, " solid ").concat(_colors.tabLineColors.hoveredColor),
120
120
  height: 0
121
121
  })
122
122
  },
@@ -124,20 +124,20 @@ var getTabStyles = exports.getTabStyles = function getTabStyles(mode) {
124
124
  // TODO: interaction states will be reviewed in DSP-1438
125
125
  color: colors.activeLabelColor,
126
126
  '&::after': _objectSpread(_objectSpread({}, tabLineStyles), {}, {
127
- borderBottom: "".concat(underlineHeight, " solid ").concat((0, _colors.getTabLineColor)(mode).activeColor),
127
+ borderBottom: "".concat(underlineHeight, " solid ").concat(_colors.tabLineColors.activeColor),
128
128
  height: 0
129
129
  })
130
130
  },
131
- '&:focus-visible': tabPanelFocusStyles(mode),
131
+ '&:focus-visible': tabPanelFocusStyles(),
132
132
  '@supports not selector(*:focus-visible)': {
133
- '&:focus': tabPanelFocusStyles(mode)
133
+ '&:focus': tabPanelFocusStyles()
134
134
  }
135
135
  }, highContrastFocusRing), {}, {
136
136
  '&[aria-selected="true"]': {
137
137
  color: colors.selectedColor,
138
138
  '&::after': _objectSpread(_objectSpread({}, tabLineStyles), {}, {
139
139
  // This line is a border so it is visible in high contrast mode
140
- borderBottom: "".concat(underlineHeight, " solid ").concat((0, _colors.getTabLineColor)(mode).selectedColor),
140
+ borderBottom: "".concat(underlineHeight, " solid ").concat(_colors.tabLineColors.selectedColor),
141
141
  height: 0
142
142
  })
143
143
  }
@@ -1,7 +1,6 @@
1
1
  /** @jsx jsx */
2
- import { Children, createRef, useCallback, useMemo } from 'react';
2
+ import { Children, createRef, useCallback } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
- import { useGlobalTheme } from '@atlaskit/theme/components';
5
4
  import { useTabList } from '../hooks';
6
5
  import { TabContext } from '../internal/context';
7
6
  import { getTabListStyles } from '../internal/styles';
@@ -12,6 +11,9 @@ const baseStyles = css({
12
11
  position: 'relative'
13
12
  });
14
13
 
14
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
15
+ const tabListStyles = getTabListStyles();
16
+
15
17
  /**
16
18
  * __TabList__
17
19
  *
@@ -24,9 +26,6 @@ const baseStyles = css({
24
26
  const TabList = ({
25
27
  children
26
28
  }) => {
27
- const {
28
- mode
29
- } = useGlobalTheme();
30
29
  const {
31
30
  tabsId,
32
31
  selected,
@@ -37,7 +36,6 @@ const TabList = ({
37
36
  // Don't include any conditional children
38
37
  const childrenArray = Children.toArray(children).filter(Boolean);
39
38
  const length = childrenArray.length;
40
- const tabListStyles = useMemo(() => getTabListStyles(mode), [mode]);
41
39
  const selectTabByIndex = useCallback(index => {
42
40
  var _ref$current;
43
41
  const newSelectedNode = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector(`[id='${tabsId}-${index}']`);
@@ -1,8 +1,7 @@
1
1
  /** @jsx jsx */
2
- import { Children, Fragment, useCallback, useMemo, useRef, useState } from 'react';
2
+ import { Children, Fragment, useCallback, useRef, useState } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
4
  import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
5
- import { useGlobalTheme } from '@atlaskit/theme/components';
6
5
  import { TabListContext, TabPanelContext } from '../internal/context';
7
6
  import { getTabsStyles } from '../internal/styles';
8
7
  import { onMouseDownBlur } from '../internal/utils';
@@ -14,10 +13,13 @@ const baseStyles = css({
14
13
  flexDirection: 'column',
15
14
  flexGrow: 1
16
15
  });
16
+
17
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
18
+ const tabsStyles = getTabsStyles();
17
19
  const analyticsAttributes = {
18
20
  componentName: 'tabs',
19
21
  packageName: "@atlaskit/tabs",
20
- packageVersion: "13.4.9"
22
+ packageVersion: "14.0.0"
21
23
  };
22
24
  const getTabPanelWithContext = ({
23
25
  tabPanel,
@@ -58,9 +60,6 @@ const Tabs = props => {
58
60
  children,
59
61
  testId
60
62
  } = props;
61
- const {
62
- mode
63
- } = useGlobalTheme();
64
63
  const [selectedState, setSelected] = useState(SelectedType || defaultSelected || 0);
65
64
  const selected = SelectedType === undefined ? selectedState : SelectedType;
66
65
  const childrenArray = Children.toArray(children)
@@ -99,7 +98,6 @@ const Tabs = props => {
99
98
  isSelected: tabIndex === selected,
100
99
  tabsId: id
101
100
  }));
102
- const tabsStyles = useMemo(() => getTabsStyles(mode), [mode]);
103
101
  return (
104
102
  // Only styles that affect the Tabs container itself have been applied via primitives.
105
103
  // The other styles applied through the CSS prop are there for styling children
@@ -1,40 +1,15 @@
1
- import { B100, B200, B400, B500, B75, DN0, DN400, N30, N500 } from '@atlaskit/theme/colors';
2
- const tabColorMap = {
3
- light: {
4
- labelColor: `var(--ds-text-subtle, ${N500})`,
5
- activeLabelColor: `var(--ds-text, ${B500})`,
6
- hoverLabelColor: `var(--ds-text-subtle, ${B400})`,
7
- selectedColor: `var(--ds-text-selected, ${B400})`,
8
- focusBorderColor: `var(--ds-border-focused, ${B100})`
9
- },
10
- dark: {
11
- labelColor: `var(--ds-text-subtle, ${DN400})`,
12
- activeLabelColor: `var(--ds-text, ${B200})`,
13
- hoverLabelColor: `var(--ds-text-subtle, ${B75})`,
14
- selectedColor: `var(--ds-text-selected, ${B75})`,
15
- focusBorderColor: `var(--ds-border-focused, ${B75})`
16
- }
17
- };
18
- export const getTabColors = mode => {
19
- return tabColorMap[mode];
20
- };
21
- const tabLineColorMap = {
22
- light: {
23
- lineColor: `var(--ds-border, ${N30})`,
24
- hoveredColor: "var(--ds-border, transparent)",
25
- activeColor: "var(--ds-border, transparent)",
26
- selectedColor: `var(--ds-border-selected, ${B400})`
27
- },
28
- dark: {
29
- lineColor: `var(--ds-border, ${DN0})`,
30
- hoveredColor: "var(--ds-border, transparent)",
31
- activeColor: "var(--ds-border, transparent)",
32
- selectedColor: `var(--ds-border-selected, ${B75})`
33
- }
34
- };
35
- export const getTabLineColor = mode => tabLineColorMap[mode];
36
- const tabPanelFocusColorMap = {
37
- light: `var(--ds-border-focused, ${B100})`,
38
- dark: `var(--ds-border-focused, ${B75})`
39
- };
40
- export const getTabPanelFocusColor = mode => tabPanelFocusColorMap[mode];
1
+ import { B100, B400, B500, N30, N500 } from '@atlaskit/theme/colors';
2
+ export const tabColors = {
3
+ labelColor: `var(--ds-text-subtle, ${N500})`,
4
+ activeLabelColor: `var(--ds-text, ${B500})`,
5
+ hoverLabelColor: `var(--ds-text-subtle, ${B400})`,
6
+ selectedColor: `var(--ds-text-selected, ${B400})`,
7
+ focusBorderColor: `var(--ds-border-focused, ${B100})`
8
+ };
9
+ export const tabLineColors = {
10
+ lineColor: `var(--ds-border, ${N30})`,
11
+ hoveredColor: "var(--ds-border, transparent)",
12
+ activeColor: "var(--ds-border, transparent)",
13
+ selectedColor: `var(--ds-border-selected, ${B400})`
14
+ };
15
+ export const tabPanelFocusColor = `var(--ds-border-focused, ${B100})`;
@@ -1,5 +1,5 @@
1
1
  import { css } from '@emotion/react';
2
- import { getTabColors, getTabLineColor, getTabPanelFocusColor } from './colors';
2
+ import { tabColors, tabLineColors, tabPanelFocusColor } from './colors';
3
3
  const tabLeftRightPadding = "var(--ds-space-100, 8px)";
4
4
  const tabTopBottomPadding = "var(--ds-space-050, 4px)";
5
5
  // TODO this should probably be `border.width.indicator`
@@ -17,12 +17,12 @@ const highContrastFocusRing = {
17
17
  }
18
18
  }
19
19
  };
20
- const tabFocusStyles = mode => ({
21
- boxShadow: `0 0 0 2px ${getTabPanelFocusColor(mode)} inset`,
20
+ const tabFocusStyles = () => ({
21
+ boxShadow: `0 0 0 2px ${tabPanelFocusColor} inset`,
22
22
  borderRadius: "var(--ds-border-radius, 3px)",
23
23
  outline: 'none'
24
24
  });
25
- const getTabPanelStyles = mode => ({
25
+ const getTabPanelStyles = () => ({
26
26
  flexGrow: 1,
27
27
  /*
28
28
  NOTE min-height set to 0% because of Firefox bug
@@ -31,16 +31,16 @@ const getTabPanelStyles = mode => ({
31
31
  minHeight: '0%',
32
32
  display: 'flex',
33
33
  padding: `0 ${tabLeftRightPadding}`,
34
- '&:focus-visible': tabFocusStyles(mode),
34
+ '&:focus-visible': tabFocusStyles(),
35
35
  '@supports not selector(*:focus-visible)': {
36
- '&:focus': tabFocusStyles(mode)
36
+ '&:focus': tabFocusStyles()
37
37
  },
38
38
  ...highContrastFocusRing
39
39
  });
40
- export const getTabsStyles = mode =>
40
+ export const getTabsStyles = () =>
41
41
  // eslint-disable-next-line @repo/internal/styles/no-exported-styles
42
42
  css({
43
- '& [role="tabpanel"]': getTabPanelStyles(mode),
43
+ '& [role="tabpanel"]': getTabPanelStyles(),
44
44
  // The hidden attribute doesn't work on flex elements
45
45
  // Change display to be none
46
46
  // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
@@ -58,20 +58,20 @@ const tabLineStyles = {
58
58
  left: tabLeftRightPadding,
59
59
  right: tabLeftRightPadding
60
60
  };
61
- export const getTabListStyles = mode =>
61
+ export const getTabListStyles = () =>
62
62
  // eslint-disable-next-line @repo/internal/styles/no-exported-styles
63
63
  css({
64
- '& [role="tab"]': getTabStyles(mode),
64
+ '& [role="tab"]': getTabStyles(),
65
65
  fontWeight: "var(--ds-font-weight-medium, 500)",
66
66
  '&::before': {
67
67
  ...tabLineStyles,
68
68
  height: underlineHeight,
69
69
  // This line is not a border so the selected line is visible in high contrast mode
70
- backgroundColor: getTabLineColor(mode).lineColor
70
+ backgroundColor: tabLineColors.lineColor
71
71
  }
72
72
  });
73
- const tabPanelFocusStyles = mode => {
74
- const colors = getTabColors(mode);
73
+ const tabPanelFocusStyles = () => {
74
+ const colors = tabColors;
75
75
  return {
76
76
  boxShadow: `0 0 0 2px ${colors.focusBorderColor} inset`,
77
77
  borderRadius: "var(--ds-border-radius, 3px)",
@@ -82,8 +82,8 @@ const tabPanelFocusStyles = mode => {
82
82
  }
83
83
  };
84
84
  };
85
- export const getTabStyles = mode => {
86
- const colors = getTabColors(mode);
85
+ export const getTabStyles = () => {
86
+ const colors = tabColors;
87
87
  return {
88
88
  color: colors.labelColor,
89
89
  cursor: 'pointer',
@@ -99,7 +99,7 @@ export const getTabStyles = mode => {
99
99
  color: colors.hoverLabelColor,
100
100
  '&::after': {
101
101
  ...tabLineStyles,
102
- borderBottom: `${underlineHeight} solid ${getTabLineColor(mode).hoveredColor}`,
102
+ borderBottom: `${underlineHeight} solid ${tabLineColors.hoveredColor}`,
103
103
  height: 0
104
104
  }
105
105
  },
@@ -108,13 +108,13 @@ export const getTabStyles = mode => {
108
108
  color: colors.activeLabelColor,
109
109
  '&::after': {
110
110
  ...tabLineStyles,
111
- borderBottom: `${underlineHeight} solid ${getTabLineColor(mode).activeColor}`,
111
+ borderBottom: `${underlineHeight} solid ${tabLineColors.activeColor}`,
112
112
  height: 0
113
113
  }
114
114
  },
115
- '&:focus-visible': tabPanelFocusStyles(mode),
115
+ '&:focus-visible': tabPanelFocusStyles(),
116
116
  '@supports not selector(*:focus-visible)': {
117
- '&:focus': tabPanelFocusStyles(mode)
117
+ '&:focus': tabPanelFocusStyles()
118
118
  },
119
119
  ...highContrastFocusRing,
120
120
  '&[aria-selected="true"]': {
@@ -122,7 +122,7 @@ export const getTabStyles = mode => {
122
122
  '&::after': {
123
123
  ...tabLineStyles,
124
124
  // This line is a border so it is visible in high contrast mode
125
- borderBottom: `${underlineHeight} solid ${getTabLineColor(mode).selectedColor}`,
125
+ borderBottom: `${underlineHeight} solid ${tabLineColors.selectedColor}`,
126
126
  height: 0
127
127
  }
128
128
  }
@@ -1,7 +1,6 @@
1
1
  /** @jsx jsx */
2
- import { Children, createRef, useCallback, useMemo } from 'react';
2
+ import { Children, createRef, useCallback } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
- import { useGlobalTheme } from '@atlaskit/theme/components';
5
4
  import { useTabList } from '../hooks';
6
5
  import { TabContext } from '../internal/context';
7
6
  import { getTabListStyles } from '../internal/styles';
@@ -12,6 +11,9 @@ var baseStyles = css({
12
11
  position: 'relative'
13
12
  });
14
13
 
14
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
15
+ var tabListStyles = getTabListStyles();
16
+
15
17
  /**
16
18
  * __TabList__
17
19
  *
@@ -23,8 +25,6 @@ var baseStyles = css({
23
25
  */
24
26
  var TabList = function TabList(_ref) {
25
27
  var children = _ref.children;
26
- var _useGlobalTheme = useGlobalTheme(),
27
- mode = _useGlobalTheme.mode;
28
28
  var _useTabList = useTabList(),
29
29
  tabsId = _useTabList.tabsId,
30
30
  selected = _useTabList.selected,
@@ -34,9 +34,6 @@ var TabList = function TabList(_ref) {
34
34
  // Don't include any conditional children
35
35
  var childrenArray = Children.toArray(children).filter(Boolean);
36
36
  var length = childrenArray.length;
37
- var tabListStyles = useMemo(function () {
38
- return getTabListStyles(mode);
39
- }, [mode]);
40
37
  var selectTabByIndex = useCallback(function (index) {
41
38
  var _ref$current;
42
39
  var newSelectedNode = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector("[id='".concat(tabsId, "-").concat(index, "']"));
@@ -4,10 +4,9 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
6
  /** @jsx jsx */
7
- import { Children, Fragment, useCallback, useMemo, useRef, useState } from 'react';
7
+ import { Children, Fragment, useCallback, useRef, useState } from 'react';
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
10
- import { useGlobalTheme } from '@atlaskit/theme/components';
11
10
  import { TabListContext, TabPanelContext } from '../internal/context';
12
11
  import { getTabsStyles } from '../internal/styles';
13
12
  import { onMouseDownBlur } from '../internal/utils';
@@ -19,10 +18,13 @@ var baseStyles = css({
19
18
  flexDirection: 'column',
20
19
  flexGrow: 1
21
20
  });
21
+
22
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
23
+ var tabsStyles = getTabsStyles();
22
24
  var analyticsAttributes = {
23
25
  componentName: 'tabs',
24
26
  packageName: "@atlaskit/tabs",
25
- packageVersion: "13.4.9"
27
+ packageVersion: "14.0.0"
26
28
  };
27
29
  var getTabPanelWithContext = function getTabPanelWithContext(_ref) {
28
30
  var tabPanel = _ref.tabPanel,
@@ -64,8 +66,6 @@ var Tabs = function Tabs(props) {
64
66
  analyticsContext = props.analyticsContext,
65
67
  children = props.children,
66
68
  testId = props.testId;
67
- var _useGlobalTheme = useGlobalTheme(),
68
- mode = _useGlobalTheme.mode;
69
69
  var _useState = useState(SelectedType || defaultSelected || 0),
70
70
  _useState2 = _slicedToArray(_useState, 2),
71
71
  selectedState = _useState2[0],
@@ -112,9 +112,6 @@ var Tabs = function Tabs(props) {
112
112
  tabsId: id
113
113
  });
114
114
  });
115
- var tabsStyles = useMemo(function () {
116
- return getTabsStyles(mode);
117
- }, [mode]);
118
115
  return (
119
116
  // Only styles that affect the Tabs container itself have been applied via primitives.
120
117
  // The other styles applied through the CSS prop are there for styling children
@@ -1,44 +1,15 @@
1
- import { B100, B200, B400, B500, B75, DN0, DN400, N30, N500 } from '@atlaskit/theme/colors';
2
- var tabColorMap = {
3
- light: {
4
- labelColor: "var(--ds-text-subtle, ".concat(N500, ")"),
5
- activeLabelColor: "var(--ds-text, ".concat(B500, ")"),
6
- hoverLabelColor: "var(--ds-text-subtle, ".concat(B400, ")"),
7
- selectedColor: "var(--ds-text-selected, ".concat(B400, ")"),
8
- focusBorderColor: "var(--ds-border-focused, ".concat(B100, ")")
9
- },
10
- dark: {
11
- labelColor: "var(--ds-text-subtle, ".concat(DN400, ")"),
12
- activeLabelColor: "var(--ds-text, ".concat(B200, ")"),
13
- hoverLabelColor: "var(--ds-text-subtle, ".concat(B75, ")"),
14
- selectedColor: "var(--ds-text-selected, ".concat(B75, ")"),
15
- focusBorderColor: "var(--ds-border-focused, ".concat(B75, ")")
16
- }
17
- };
18
- export var getTabColors = function getTabColors(mode) {
19
- return tabColorMap[mode];
20
- };
21
- var tabLineColorMap = {
22
- light: {
23
- lineColor: "var(--ds-border, ".concat(N30, ")"),
24
- hoveredColor: "var(--ds-border, transparent)",
25
- activeColor: "var(--ds-border, transparent)",
26
- selectedColor: "var(--ds-border-selected, ".concat(B400, ")")
27
- },
28
- dark: {
29
- lineColor: "var(--ds-border, ".concat(DN0, ")"),
30
- hoveredColor: "var(--ds-border, transparent)",
31
- activeColor: "var(--ds-border, transparent)",
32
- selectedColor: "var(--ds-border-selected, ".concat(B75, ")")
33
- }
34
- };
35
- export var getTabLineColor = function getTabLineColor(mode) {
36
- return tabLineColorMap[mode];
37
- };
38
- var tabPanelFocusColorMap = {
39
- light: "var(--ds-border-focused, ".concat(B100, ")"),
40
- dark: "var(--ds-border-focused, ".concat(B75, ")")
41
- };
42
- export var getTabPanelFocusColor = function getTabPanelFocusColor(mode) {
43
- return tabPanelFocusColorMap[mode];
44
- };
1
+ import { B100, B400, B500, N30, N500 } from '@atlaskit/theme/colors';
2
+ export var tabColors = {
3
+ labelColor: "var(--ds-text-subtle, ".concat(N500, ")"),
4
+ activeLabelColor: "var(--ds-text, ".concat(B500, ")"),
5
+ hoverLabelColor: "var(--ds-text-subtle, ".concat(B400, ")"),
6
+ selectedColor: "var(--ds-text-selected, ".concat(B400, ")"),
7
+ focusBorderColor: "var(--ds-border-focused, ".concat(B100, ")")
8
+ };
9
+ export var tabLineColors = {
10
+ lineColor: "var(--ds-border, ".concat(N30, ")"),
11
+ hoveredColor: "var(--ds-border, transparent)",
12
+ activeColor: "var(--ds-border, transparent)",
13
+ selectedColor: "var(--ds-border-selected, ".concat(B400, ")")
14
+ };
15
+ export var tabPanelFocusColor = "var(--ds-border-focused, ".concat(B100, ")");
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  import { css } from '@emotion/react';
5
- import { getTabColors, getTabLineColor, getTabPanelFocusColor } from './colors';
5
+ import { tabColors, tabLineColors, tabPanelFocusColor } from './colors';
6
6
  var tabLeftRightPadding = "var(--ds-space-100, 8px)";
7
7
  var tabTopBottomPadding = "var(--ds-space-050, 4px)";
8
8
  // TODO this should probably be `border.width.indicator`
@@ -20,14 +20,14 @@ var highContrastFocusRing = {
20
20
  }
21
21
  }
22
22
  };
23
- var tabFocusStyles = function tabFocusStyles(mode) {
23
+ var tabFocusStyles = function tabFocusStyles() {
24
24
  return {
25
- boxShadow: "0 0 0 2px ".concat(getTabPanelFocusColor(mode), " inset"),
25
+ boxShadow: "0 0 0 2px ".concat(tabPanelFocusColor, " inset"),
26
26
  borderRadius: "var(--ds-border-radius, 3px)",
27
27
  outline: 'none'
28
28
  };
29
29
  };
30
- var getTabPanelStyles = function getTabPanelStyles(mode) {
30
+ var getTabPanelStyles = function getTabPanelStyles() {
31
31
  return _objectSpread({
32
32
  flexGrow: 1,
33
33
  /*
@@ -37,17 +37,17 @@ var getTabPanelStyles = function getTabPanelStyles(mode) {
37
37
  minHeight: '0%',
38
38
  display: 'flex',
39
39
  padding: "0 ".concat(tabLeftRightPadding),
40
- '&:focus-visible': tabFocusStyles(mode),
40
+ '&:focus-visible': tabFocusStyles(),
41
41
  '@supports not selector(*:focus-visible)': {
42
- '&:focus': tabFocusStyles(mode)
42
+ '&:focus': tabFocusStyles()
43
43
  }
44
44
  }, highContrastFocusRing);
45
45
  };
46
- export var getTabsStyles = function getTabsStyles(mode) {
46
+ export var getTabsStyles = function getTabsStyles() {
47
47
  return (
48
48
  // eslint-disable-next-line @repo/internal/styles/no-exported-styles
49
49
  css({
50
- '& [role="tabpanel"]': getTabPanelStyles(mode),
50
+ '& [role="tabpanel"]': getTabPanelStyles(),
51
51
  // The hidden attribute doesn't work on flex elements
52
52
  // Change display to be none
53
53
  // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
@@ -67,22 +67,22 @@ var tabLineStyles = {
67
67
  left: tabLeftRightPadding,
68
68
  right: tabLeftRightPadding
69
69
  };
70
- export var getTabListStyles = function getTabListStyles(mode) {
70
+ export var getTabListStyles = function getTabListStyles() {
71
71
  return (
72
72
  // eslint-disable-next-line @repo/internal/styles/no-exported-styles
73
73
  css({
74
- '& [role="tab"]': getTabStyles(mode),
74
+ '& [role="tab"]': getTabStyles(),
75
75
  fontWeight: "var(--ds-font-weight-medium, 500)",
76
76
  '&::before': _objectSpread(_objectSpread({}, tabLineStyles), {}, {
77
77
  height: underlineHeight,
78
78
  // This line is not a border so the selected line is visible in high contrast mode
79
- backgroundColor: getTabLineColor(mode).lineColor
79
+ backgroundColor: tabLineColors.lineColor
80
80
  })
81
81
  })
82
82
  );
83
83
  };
84
- var tabPanelFocusStyles = function tabPanelFocusStyles(mode) {
85
- var colors = getTabColors(mode);
84
+ var tabPanelFocusStyles = function tabPanelFocusStyles() {
85
+ var colors = tabColors;
86
86
  return {
87
87
  boxShadow: "0 0 0 2px ".concat(colors.focusBorderColor, " inset"),
88
88
  borderRadius: "var(--ds-border-radius, 3px)",
@@ -93,8 +93,8 @@ var tabPanelFocusStyles = function tabPanelFocusStyles(mode) {
93
93
  }
94
94
  };
95
95
  };
96
- export var getTabStyles = function getTabStyles(mode) {
97
- var colors = getTabColors(mode);
96
+ export var getTabStyles = function getTabStyles() {
97
+ var colors = tabColors;
98
98
  return _objectSpread(_objectSpread({
99
99
  color: colors.labelColor,
100
100
  cursor: 'pointer',
@@ -109,7 +109,7 @@ export var getTabStyles = function getTabStyles(mode) {
109
109
  // TODO: interaction states will be reviewed in DSP-1438
110
110
  color: colors.hoverLabelColor,
111
111
  '&::after': _objectSpread(_objectSpread({}, tabLineStyles), {}, {
112
- borderBottom: "".concat(underlineHeight, " solid ").concat(getTabLineColor(mode).hoveredColor),
112
+ borderBottom: "".concat(underlineHeight, " solid ").concat(tabLineColors.hoveredColor),
113
113
  height: 0
114
114
  })
115
115
  },
@@ -117,20 +117,20 @@ export var getTabStyles = function getTabStyles(mode) {
117
117
  // TODO: interaction states will be reviewed in DSP-1438
118
118
  color: colors.activeLabelColor,
119
119
  '&::after': _objectSpread(_objectSpread({}, tabLineStyles), {}, {
120
- borderBottom: "".concat(underlineHeight, " solid ").concat(getTabLineColor(mode).activeColor),
120
+ borderBottom: "".concat(underlineHeight, " solid ").concat(tabLineColors.activeColor),
121
121
  height: 0
122
122
  })
123
123
  },
124
- '&:focus-visible': tabPanelFocusStyles(mode),
124
+ '&:focus-visible': tabPanelFocusStyles(),
125
125
  '@supports not selector(*:focus-visible)': {
126
- '&:focus': tabPanelFocusStyles(mode)
126
+ '&:focus': tabPanelFocusStyles()
127
127
  }
128
128
  }, highContrastFocusRing), {}, {
129
129
  '&[aria-selected="true"]': {
130
130
  color: colors.selectedColor,
131
131
  '&::after': _objectSpread(_objectSpread({}, tabLineStyles), {}, {
132
132
  // This line is a border so it is visible in high contrast mode
133
- borderBottom: "".concat(underlineHeight, " solid ").concat(getTabLineColor(mode).selectedColor),
133
+ borderBottom: "".concat(underlineHeight, " solid ").concat(tabLineColors.selectedColor),
134
134
  height: 0
135
135
  })
136
136
  }
@@ -1,17 +1,14 @@
1
- import { ThemeModes } from '@atlaskit/theme/types';
2
- export type TabColors = {
3
- labelColor: string;
4
- activeLabelColor: string;
5
- hoverLabelColor: string;
6
- selectedColor: string;
7
- focusBorderColor: string;
1
+ export declare const tabColors: {
2
+ labelColor: "var(--ds-text-subtle)";
3
+ activeLabelColor: "var(--ds-text)";
4
+ hoverLabelColor: "var(--ds-text-subtle)";
5
+ selectedColor: "var(--ds-text-selected)";
6
+ focusBorderColor: "var(--ds-border-focused)";
8
7
  };
9
- export declare const getTabColors: (mode: ThemeModes) => TabColors;
10
- export type TabLineColors = {
11
- lineColor: string;
12
- hoveredColor: string;
13
- activeColor: string;
14
- selectedColor: string;
8
+ export declare const tabLineColors: {
9
+ lineColor: "var(--ds-border)";
10
+ hoveredColor: "var(--ds-border)";
11
+ activeColor: "var(--ds-border)";
12
+ selectedColor: "var(--ds-border-selected)";
15
13
  };
16
- export declare const getTabLineColor: (mode: ThemeModes) => TabLineColors;
17
- export declare const getTabPanelFocusColor: (mode: ThemeModes) => string;
14
+ export declare const tabPanelFocusColor: "var(--ds-border-focused)";
@@ -1,5 +1,4 @@
1
1
  import { CSSObject, SerializedStyles } from '@emotion/react';
2
- import { ThemeModes } from '@atlaskit/theme/types';
3
- export declare const getTabsStyles: (mode: ThemeModes) => SerializedStyles;
4
- export declare const getTabListStyles: (mode: ThemeModes) => SerializedStyles;
5
- export declare const getTabStyles: (mode: ThemeModes) => CSSObject;
2
+ export declare const getTabsStyles: () => SerializedStyles;
3
+ export declare const getTabListStyles: () => SerializedStyles;
4
+ export declare const getTabStyles: () => CSSObject;
@@ -1,17 +1,14 @@
1
- import { ThemeModes } from '@atlaskit/theme/types';
2
- export type TabColors = {
3
- labelColor: string;
4
- activeLabelColor: string;
5
- hoverLabelColor: string;
6
- selectedColor: string;
7
- focusBorderColor: string;
1
+ export declare const tabColors: {
2
+ labelColor: "var(--ds-text-subtle)";
3
+ activeLabelColor: "var(--ds-text)";
4
+ hoverLabelColor: "var(--ds-text-subtle)";
5
+ selectedColor: "var(--ds-text-selected)";
6
+ focusBorderColor: "var(--ds-border-focused)";
8
7
  };
9
- export declare const getTabColors: (mode: ThemeModes) => TabColors;
10
- export type TabLineColors = {
11
- lineColor: string;
12
- hoveredColor: string;
13
- activeColor: string;
14
- selectedColor: string;
8
+ export declare const tabLineColors: {
9
+ lineColor: "var(--ds-border)";
10
+ hoveredColor: "var(--ds-border)";
11
+ activeColor: "var(--ds-border)";
12
+ selectedColor: "var(--ds-border-selected)";
15
13
  };
16
- export declare const getTabLineColor: (mode: ThemeModes) => TabLineColors;
17
- export declare const getTabPanelFocusColor: (mode: ThemeModes) => string;
14
+ export declare const tabPanelFocusColor: "var(--ds-border-focused)";
@@ -1,5 +1,4 @@
1
1
  import { CSSObject, SerializedStyles } from '@emotion/react';
2
- import { ThemeModes } from '@atlaskit/theme/types';
3
- export declare const getTabsStyles: (mode: ThemeModes) => SerializedStyles;
4
- export declare const getTabListStyles: (mode: ThemeModes) => SerializedStyles;
5
- export declare const getTabStyles: (mode: ThemeModes) => CSSObject;
2
+ export declare const getTabsStyles: () => SerializedStyles;
3
+ export declare const getTabListStyles: () => SerializedStyles;
4
+ export declare const getTabStyles: () => CSSObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tabs",
3
- "version": "13.4.9",
3
+ "version": "14.0.0",
4
4
  "description": "Tabs are used to organize content by grouping similar information on the same page.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -37,9 +37,9 @@
37
37
  "@atlaskit/analytics-next": "^9.1.0",
38
38
  "@atlaskit/codemod-utils": "^4.2.0",
39
39
  "@atlaskit/ds-explorations": "^3.0.0",
40
- "@atlaskit/primitives": "^1.6.0",
40
+ "@atlaskit/primitives": "^1.10.0",
41
41
  "@atlaskit/theme": "^12.6.0",
42
- "@atlaskit/tokens": "^1.26.0",
42
+ "@atlaskit/tokens": "^1.28.0",
43
43
  "@babel/runtime": "^7.0.0",
44
44
  "@emotion/react": "^11.7.1"
45
45
  },