@atlaskit/tabs 13.3.1 → 13.3.3

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,17 @@
1
1
  # @atlaskit/tabs
2
2
 
3
+ ## 13.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9827dcb82b8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9827dcb82b8) - No-op change to introduce spacing tokens to design system components.
8
+
9
+ ## 13.3.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`0d42cd1c926`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0d42cd1c926) - Internal changes to the way styles are applied. There should be no noticeable changes to consumers.
14
+
3
15
  ## 13.3.1
4
16
 
5
17
  ### Patch Changes
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @repo/internal/react/use-primitives */
1
2
  import React from 'react';
2
3
 
3
4
  import Tabs, { Tab, TabList, TabPanel } from '../src';
@@ -1,19 +1,17 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
- exports.default = exports.TabList = void 0;
9
-
10
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
6
+ exports.default = void 0;
11
7
 
12
8
  var _react = require("react");
13
9
 
14
10
  var _react2 = require("@emotion/react");
15
11
 
16
- var _components = _interopRequireDefault(require("@atlaskit/theme/components"));
12
+ var _dsExplorations = require("@atlaskit/ds-explorations");
13
+
14
+ var _components = require("@atlaskit/theme/components");
17
15
 
18
16
  var _hooks = require("../hooks");
19
17
 
@@ -24,9 +22,21 @@ var _styles = require("../internal/styles");
24
22
  var _utils = require("../internal/utils");
25
23
 
26
24
  /** @jsx jsx */
27
- var TabListWithMode = function TabListWithMode(props) {
28
- var children = props.children,
29
- mode = props.mode;
25
+
26
+ /**
27
+ * __TabList__
28
+ *
29
+ * A TabList groups `Tab` components together.
30
+ *
31
+ * - [Examples](https://atlassian.design/components/tabs/examples)
32
+ * - [Code](https://atlassian.design/components/tabs/code)
33
+ * - [Usage](https://atlassian.design/components/tabs/usage)
34
+ */
35
+ var TabList = function TabList(props) {
36
+ var children = props.children;
37
+
38
+ var _useGlobalTheme = (0, _components.useGlobalTheme)(),
39
+ mode = _useGlobalTheme.mode;
30
40
 
31
41
  var _useTabList = (0, _hooks.useTabList)(),
32
42
  tabsId = _useTabList.tabsId,
@@ -38,7 +48,7 @@ var TabListWithMode = function TabListWithMode(props) {
38
48
  var childrenArray = _react.Children.toArray(children).filter(Boolean);
39
49
 
40
50
  var length = childrenArray.length;
41
- var styles = (0, _react.useMemo)(function () {
51
+ var tabListStyles = (0, _react.useMemo)(function () {
42
52
  return (0, _styles.getTabListStyles)(mode);
43
53
  }, [mode]);
44
54
  var selectTabByIndex = (0, _react.useCallback)(function (index) {
@@ -105,11 +115,19 @@ var TabListWithMode = function TabListWithMode(props) {
105
115
  key: index
106
116
  }, tab);
107
117
  }, [length, onKeyDown, onChange, tabsId]);
108
- return (// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
109
- (0, _react2.jsx)("div", {
118
+ return (// Only styles that affect the TabList itself have been applied via primitives.
119
+ // The other styles applied through the CSS prop are there for styling children
120
+ // through inheritance. This is important for custom cases that use the useTab(),
121
+ // which applies accessibility atributes that we use as a styling hook.
122
+ (0, _react2.jsx)(_dsExplorations.UNSAFE_Box, {
123
+ as: "div",
110
124
  role: "tablist",
111
- css: styles,
112
- ref: ref
125
+ display: "flex",
126
+ position: "relative",
127
+ padding: "sp-0",
128
+ ref: ref // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
129
+ ,
130
+ css: tabListStyles
113
131
  }, childrenArray.map(function (child, index) {
114
132
  return getTabWithContext({
115
133
  tab: child,
@@ -119,26 +137,6 @@ var TabListWithMode = function TabListWithMode(props) {
119
137
  }))
120
138
  );
121
139
  };
122
- /**
123
- * __TabList__
124
- *
125
- * A TabList groups `Tab` components together.
126
- *
127
- * - [Examples](https://atlassian.design/components/tabs/examples)
128
- * - [Code](https://atlassian.design/components/tabs/code)
129
- * - [Usage](https://atlassian.design/components/tabs/usage)
130
- */
131
-
132
-
133
- var TabList = function TabList(props) {
134
- return (0, _react2.jsx)(_components.default.Consumer, null, function (_ref2) {
135
- var mode = _ref2.mode;
136
- return (0, _react2.jsx)(TabListWithMode, (0, _extends2.default)({}, props, {
137
- mode: mode
138
- }));
139
- });
140
- };
141
140
 
142
- exports.TabList = TabList;
143
141
  var _default = TabList;
144
142
  exports.default = _default;
@@ -9,7 +9,11 @@ exports.default = void 0;
9
9
 
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
 
12
- var _react = require("@emotion/react");
12
+ var _react = require("react");
13
+
14
+ var _react2 = require("@emotion/react");
15
+
16
+ var _dsExplorations = require("@atlaskit/ds-explorations");
13
17
 
14
18
  var _hooks = require("../hooks");
15
19
 
@@ -29,9 +33,10 @@ var TabPanel = function TabPanel(_ref) {
29
33
  var children = _ref.children,
30
34
  testId = _ref.testId;
31
35
  var tabPanelAttributes = (0, _hooks.useTabPanel)();
32
- return (0, _react.jsx)("div", (0, _extends2.default)({
33
- "data-testid": testId
34
- }, tabPanelAttributes), children);
36
+ return (0, _react2.jsx)(_dsExplorations.UNSAFE_Box, (0, _extends2.default)({
37
+ testId: testId,
38
+ as: "div"
39
+ }, tabPanelAttributes), (0, _react2.jsx)(_react.Fragment, null, children));
35
40
  };
36
41
 
37
42
  var _default = TabPanel;
@@ -11,6 +11,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
11
11
 
12
12
  var _react = require("@emotion/react");
13
13
 
14
+ var _dsExplorations = require("@atlaskit/ds-explorations");
15
+
14
16
  var _hooks = require("../hooks");
15
17
 
16
18
  /** @jsx jsx */
@@ -28,7 +30,13 @@ function Tab(_ref) {
28
30
  var children = _ref.children,
29
31
  testId = _ref.testId;
30
32
  var tabAttributes = (0, _hooks.useTab)();
31
- return (0, _react.jsx)("div", (0, _extends2.default)({
32
- "data-testid": testId
33
- }, tabAttributes), children);
33
+ return (0, _react.jsx)(_dsExplorations.UNSAFE_Box, (0, _extends2.default)({
34
+ as: "div",
35
+ testId: testId
36
+ }, tabAttributes), (0, _react.jsx)(_dsExplorations.UNSAFE_Text, {
37
+ shouldTruncate: true,
38
+ UNSAFE_style: {
39
+ color: 'inherit'
40
+ }
41
+ }, children));
34
42
  }
@@ -5,9 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = exports.Tabs = void 0;
9
-
10
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
+ exports.default = void 0;
11
9
 
12
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
11
 
@@ -21,7 +19,9 @@ var _react2 = require("@emotion/react");
21
19
 
22
20
  var _usePlatformLeafEventHandler = require("@atlaskit/analytics-next/usePlatformLeafEventHandler");
23
21
 
24
- var _components = _interopRequireDefault(require("@atlaskit/theme/components"));
22
+ var _dsExplorations = require("@atlaskit/ds-explorations");
23
+
24
+ var _components = require("@atlaskit/theme/components");
25
25
 
26
26
  var _context = require("../internal/context");
27
27
 
@@ -36,7 +36,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
36
36
  var analyticsAttributes = {
37
37
  componentName: 'tabs',
38
38
  packageName: "@atlaskit/tabs",
39
- packageVersion: "13.3.1"
39
+ packageVersion: "13.3.3"
40
40
  };
41
41
 
42
42
  var getTabPanelWithContext = function getTabPanelWithContext(_ref) {
@@ -58,8 +58,18 @@ var getTabPanelWithContext = function getTabPanelWithContext(_ref) {
58
58
  }, tabPanel)
59
59
  );
60
60
  };
61
+ /**
62
+ * __Tabs__
63
+ *
64
+ * Tabs acts as a container for all Tab components.
65
+ *
66
+ * - [Examples](https://atlassian.design/components/tabs/examples)
67
+ * - [Code](https://atlassian.design/components/tabs/code)
68
+ * - [Usage](https://atlassian.design/components/tabs/usage)
69
+ */
61
70
 
62
- var TabsWithMode = function TabsWithMode(props) {
71
+
72
+ var Tabs = function Tabs(props) {
63
73
  var _props$shouldUnmountT = props.shouldUnmountTabPanelOnChange,
64
74
  shouldUnmountTabPanelOnChange = _props$shouldUnmountT === void 0 ? false : _props$shouldUnmountT,
65
75
  SelectedType = props.selected,
@@ -68,8 +78,10 @@ var TabsWithMode = function TabsWithMode(props) {
68
78
  id = props.id,
69
79
  analyticsContext = props.analyticsContext,
70
80
  children = props.children,
71
- testId = props.testId,
72
- mode = props.mode;
81
+ testId = props.testId;
82
+
83
+ var _useGlobalTheme = (0, _components.useGlobalTheme)(),
84
+ mode = _useGlobalTheme.mode;
73
85
 
74
86
  var _useState = (0, _react.useState)(SelectedType || defaultSelected || 0),
75
87
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -124,9 +136,22 @@ var TabsWithMode = function TabsWithMode(props) {
124
136
  var tabsStyles = (0, _react.useMemo)(function () {
125
137
  return (0, _styles.getTabsStyles)(mode);
126
138
  }, [mode]);
127
- return (// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
128
- (0, _react2.jsx)("div", {
129
- "data-testid": testId,
139
+ return (// Only styles that affect the Tabs container itself have been applied via primitives.
140
+ // The other styles applied through the CSS prop are there for styling children
141
+ // through inheritance. This is important for custom cases that use the useTabPanel(),
142
+ // which applies accessibility atributes that we use as a styling hook.
143
+ (0, _react2.jsx)(_dsExplorations.UNSAFE_Box, {
144
+ as: "div",
145
+ testId: testId,
146
+ display: "flex",
147
+ flexDirection: "column",
148
+ UNSAFE_style: {
149
+ maxWidth: '100%',
150
+ minHeight: '0%',
151
+ flexBasis: '100%',
152
+ flexGrow: 1
153
+ } // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
154
+ ,
130
155
  css: tabsStyles
131
156
  }, (0, _react2.jsx)(_context.TabListContext.Provider, {
132
157
  value: {
@@ -134,29 +159,9 @@ var TabsWithMode = function TabsWithMode(props) {
134
159
  onChange: onChangeAnalytics,
135
160
  tabsId: id
136
161
  }
137
- }, tabList), tabPanelsWithContext)
162
+ }, tabList), (0, _react2.jsx)(_react.Fragment, null, tabPanelsWithContext))
138
163
  );
139
164
  };
140
- /**
141
- * __Tabs__
142
- *
143
- * Tabs acts as a container for all Tab components.
144
- *
145
- * - [Examples](https://atlassian.design/components/tabs/examples)
146
- * - [Code](https://atlassian.design/components/tabs/code)
147
- * - [Usage](https://atlassian.design/components/tabs/usage)
148
- */
149
-
150
-
151
- var Tabs = function Tabs(props) {
152
- return (0, _react2.jsx)(_components.default.Consumer, null, function (_ref2) {
153
- var mode = _ref2.mode;
154
- return (0, _react2.jsx)(TabsWithMode, (0, _extends2.default)({}, props, {
155
- mode: mode
156
- }));
157
- });
158
- };
159
165
 
160
- exports.Tabs = Tabs;
161
166
  var _default = Tabs;
162
167
  exports.default = _default;
@@ -55,12 +55,6 @@ var getTabPanelStyles = function getTabPanelStyles(mode) {
55
55
  var getTabsStyles = function getTabsStyles(mode) {
56
56
  return (// eslint-disable-next-line @repo/internal/styles/no-exported-styles
57
57
  (0, _react.css)({
58
- display: 'flex',
59
- maxWidth: '100%',
60
- minHeight: '0%',
61
- flexBasis: '100%',
62
- flexDirection: 'column',
63
- flexGrow: 1,
64
58
  '& [role="tabpanel"]': getTabPanelStyles(mode),
65
59
  // The hidden attribute doesn't work on flex elements
66
60
  // Change display to be none
@@ -87,10 +81,6 @@ var tabLineStyles = {
87
81
  var getTabListStyles = function getTabListStyles(mode) {
88
82
  return (// eslint-disable-next-line @repo/internal/styles/no-exported-styles
89
83
  (0, _react.css)({
90
- display: 'flex',
91
- margin: 0,
92
- padding: 0,
93
- position: 'relative',
94
84
  '& [role="tab"]': getTabStyles(mode),
95
85
  fontWeight: 500,
96
86
  '&::before': _objectSpread(_objectSpread({}, tabLineStyles), {}, {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tabs",
3
- "version": "13.3.1",
3
+ "version": "13.3.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,19 +1,29 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
-
3
1
  /** @jsx jsx */
4
2
  import { Children, createRef, useCallback, useMemo } from 'react';
5
3
  import { jsx } from '@emotion/react';
6
- import GlobalTheme from '@atlaskit/theme/components';
4
+ import { UNSAFE_Box as Box } from '@atlaskit/ds-explorations';
5
+ import { useGlobalTheme } from '@atlaskit/theme/components';
7
6
  import { useTabList } from '../hooks';
8
7
  import { TabContext } from '../internal/context';
9
8
  import { getTabListStyles } from '../internal/styles';
10
9
  import { onMouseDownBlur } from '../internal/utils';
11
10
 
12
- const TabListWithMode = props => {
11
+ /**
12
+ * __TabList__
13
+ *
14
+ * A TabList groups `Tab` components together.
15
+ *
16
+ * - [Examples](https://atlassian.design/components/tabs/examples)
17
+ * - [Code](https://atlassian.design/components/tabs/code)
18
+ * - [Usage](https://atlassian.design/components/tabs/usage)
19
+ */
20
+ const TabList = props => {
13
21
  const {
14
- children,
15
- mode
22
+ children
16
23
  } = props;
24
+ const {
25
+ mode
26
+ } = useGlobalTheme();
17
27
  const {
18
28
  tabsId,
19
29
  selected,
@@ -23,7 +33,7 @@ const TabListWithMode = props => {
23
33
 
24
34
  const childrenArray = Children.toArray(children).filter(Boolean);
25
35
  const length = childrenArray.length;
26
- const styles = useMemo(() => getTabListStyles(mode), [mode]);
36
+ const tabListStyles = useMemo(() => getTabListStyles(mode), [mode]);
27
37
  const selectTabByIndex = useCallback(index => {
28
38
  var _ref$current;
29
39
 
@@ -84,11 +94,19 @@ const TabListWithMode = props => {
84
94
  },
85
95
  key: index
86
96
  }, tab), [length, onKeyDown, onChange, tabsId]);
87
- return (// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
88
- jsx("div", {
97
+ return (// Only styles that affect the TabList itself have been applied via primitives.
98
+ // The other styles applied through the CSS prop are there for styling children
99
+ // through inheritance. This is important for custom cases that use the useTab(),
100
+ // which applies accessibility atributes that we use as a styling hook.
101
+ jsx(Box, {
102
+ as: "div",
89
103
  role: "tablist",
90
- css: styles,
91
- ref: ref
104
+ display: "flex",
105
+ position: "relative",
106
+ padding: "sp-0",
107
+ ref: ref // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
108
+ ,
109
+ css: tabListStyles
92
110
  }, childrenArray.map((child, index) => getTabWithContext({
93
111
  tab: child,
94
112
  index,
@@ -96,20 +114,5 @@ const TabListWithMode = props => {
96
114
  })))
97
115
  );
98
116
  };
99
- /**
100
- * __TabList__
101
- *
102
- * A TabList groups `Tab` components together.
103
- *
104
- * - [Examples](https://atlassian.design/components/tabs/examples)
105
- * - [Code](https://atlassian.design/components/tabs/code)
106
- * - [Usage](https://atlassian.design/components/tabs/usage)
107
- */
108
-
109
117
 
110
- export const TabList = props => jsx(GlobalTheme.Consumer, null, ({
111
- mode
112
- }) => jsx(TabListWithMode, _extends({}, props, {
113
- mode: mode
114
- })));
115
118
  export default TabList;
@@ -1,7 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
 
3
3
  /** @jsx jsx */
4
+ import { Fragment } from 'react';
4
5
  import { jsx } from '@emotion/react';
6
+ import { UNSAFE_Box as Box } from '@atlaskit/ds-explorations';
5
7
  import { useTabPanel } from '../hooks';
6
8
 
7
9
  // Note this is not being memoized as children is an unstable reference
@@ -20,9 +22,10 @@ const TabPanel = ({
20
22
  testId
21
23
  }) => {
22
24
  const tabPanelAttributes = useTabPanel();
23
- return jsx("div", _extends({
24
- "data-testid": testId
25
- }, tabPanelAttributes), children);
25
+ return jsx(Box, _extends({
26
+ testId: testId,
27
+ as: "div"
28
+ }, tabPanelAttributes), jsx(Fragment, null, children));
26
29
  };
27
30
 
28
31
  export default TabPanel;
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
 
3
3
  /** @jsx jsx */
4
4
  import { jsx } from '@emotion/react';
5
+ import { UNSAFE_Box as Box, UNSAFE_Text as Text } from '@atlaskit/ds-explorations';
5
6
  import { useTab } from '../hooks';
6
7
 
7
8
  /**
@@ -18,7 +19,13 @@ export default function Tab({
18
19
  testId
19
20
  }) {
20
21
  const tabAttributes = useTab();
21
- return jsx("div", _extends({
22
- "data-testid": testId
23
- }, tabAttributes), children);
22
+ return jsx(Box, _extends({
23
+ as: "div",
24
+ testId: testId
25
+ }, tabAttributes), jsx(Text, {
26
+ shouldTruncate: true,
27
+ UNSAFE_style: {
28
+ color: 'inherit'
29
+ }
30
+ }, children));
24
31
  }
@@ -1,17 +1,16 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
-
3
1
  /** @jsx jsx */
4
- import { Children, useCallback, useMemo, useRef, useState } from 'react';
2
+ import { Children, Fragment, useCallback, useMemo, useRef, useState } from 'react';
5
3
  import { jsx } from '@emotion/react';
6
4
  import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
7
- import GlobalTheme from '@atlaskit/theme/components';
5
+ import { UNSAFE_Box as Box } from '@atlaskit/ds-explorations';
6
+ import { useGlobalTheme } from '@atlaskit/theme/components';
8
7
  import { TabListContext, TabPanelContext } from '../internal/context';
9
8
  import { getTabsStyles } from '../internal/styles';
10
9
  import { onMouseDownBlur } from '../internal/utils';
11
10
  const analyticsAttributes = {
12
11
  componentName: 'tabs',
13
12
  packageName: "@atlaskit/tabs",
14
- packageVersion: "13.3.1"
13
+ packageVersion: "13.3.3"
15
14
  };
16
15
 
17
16
  const getTabPanelWithContext = ({
@@ -31,8 +30,18 @@ tabPanel && jsx(TabPanelContext.Provider, {
31
30
  },
32
31
  key: index
33
32
  }, tabPanel);
33
+ /**
34
+ * __Tabs__
35
+ *
36
+ * Tabs acts as a container for all Tab components.
37
+ *
38
+ * - [Examples](https://atlassian.design/components/tabs/examples)
39
+ * - [Code](https://atlassian.design/components/tabs/code)
40
+ * - [Usage](https://atlassian.design/components/tabs/usage)
41
+ */
42
+
34
43
 
35
- const TabsWithMode = props => {
44
+ const Tabs = props => {
36
45
  const {
37
46
  shouldUnmountTabPanelOnChange = false,
38
47
  selected: SelectedType,
@@ -41,9 +50,11 @@ const TabsWithMode = props => {
41
50
  id,
42
51
  analyticsContext,
43
52
  children,
44
- testId,
45
- mode
53
+ testId
46
54
  } = props;
55
+ const {
56
+ mode
57
+ } = useGlobalTheme();
47
58
  const [selectedState, setSelected] = useState(SelectedType || defaultSelected || 0);
48
59
  const selected = SelectedType === undefined ? selectedState : SelectedType;
49
60
  const childrenArray = Children.toArray(children) // Don't include any conditional children
@@ -83,9 +94,22 @@ const TabsWithMode = props => {
83
94
  tabsId: id
84
95
  }));
85
96
  const tabsStyles = useMemo(() => getTabsStyles(mode), [mode]);
86
- return (// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
87
- jsx("div", {
88
- "data-testid": testId,
97
+ return (// Only styles that affect the Tabs container itself have been applied via primitives.
98
+ // The other styles applied through the CSS prop are there for styling children
99
+ // through inheritance. This is important for custom cases that use the useTabPanel(),
100
+ // which applies accessibility atributes that we use as a styling hook.
101
+ jsx(Box, {
102
+ as: "div",
103
+ testId: testId,
104
+ display: "flex",
105
+ flexDirection: "column",
106
+ UNSAFE_style: {
107
+ maxWidth: '100%',
108
+ minHeight: '0%',
109
+ flexBasis: '100%',
110
+ flexGrow: 1
111
+ } // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
112
+ ,
89
113
  css: tabsStyles
90
114
  }, jsx(TabListContext.Provider, {
91
115
  value: {
@@ -93,23 +117,8 @@ const TabsWithMode = props => {
93
117
  onChange: onChangeAnalytics,
94
118
  tabsId: id
95
119
  }
96
- }, tabList), tabPanelsWithContext)
120
+ }, tabList), jsx(Fragment, null, tabPanelsWithContext))
97
121
  );
98
122
  };
99
- /**
100
- * __Tabs__
101
- *
102
- * Tabs acts as a container for all Tab components.
103
- *
104
- * - [Examples](https://atlassian.design/components/tabs/examples)
105
- * - [Code](https://atlassian.design/components/tabs/code)
106
- * - [Usage](https://atlassian.design/components/tabs/usage)
107
- */
108
-
109
123
 
110
- export const Tabs = props => jsx(GlobalTheme.Consumer, null, ({
111
- mode
112
- }) => jsx(TabsWithMode, _extends({}, props, {
113
- mode: mode
114
- })));
115
124
  export default Tabs;
@@ -35,12 +35,6 @@ const getTabPanelStyles = mode => ({
35
35
 
36
36
  export const getTabsStyles = mode => // eslint-disable-next-line @repo/internal/styles/no-exported-styles
37
37
  css({
38
- display: 'flex',
39
- maxWidth: '100%',
40
- minHeight: '0%',
41
- flexBasis: '100%',
42
- flexDirection: 'column',
43
- flexGrow: 1,
44
38
  '& [role="tabpanel"]': getTabPanelStyles(mode),
45
39
  // The hidden attribute doesn't work on flex elements
46
40
  // Change display to be none
@@ -61,10 +55,6 @@ const tabLineStyles = {
61
55
  };
62
56
  export const getTabListStyles = mode => // eslint-disable-next-line @repo/internal/styles/no-exported-styles
63
57
  css({
64
- display: 'flex',
65
- margin: 0,
66
- padding: 0,
67
- position: 'relative',
68
58
  '& [role="tab"]': getTabStyles(mode),
69
59
  fontWeight: 500,
70
60
  '&::before': { ...tabLineStyles,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tabs",
3
- "version": "13.3.1",
3
+ "version": "13.3.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,17 +1,27 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
-
3
1
  /** @jsx jsx */
4
2
  import { Children, createRef, useCallback, useMemo } from 'react';
5
3
  import { jsx } from '@emotion/react';
6
- import GlobalTheme from '@atlaskit/theme/components';
4
+ import { UNSAFE_Box as Box } from '@atlaskit/ds-explorations';
5
+ import { useGlobalTheme } from '@atlaskit/theme/components';
7
6
  import { useTabList } from '../hooks';
8
7
  import { TabContext } from '../internal/context';
9
8
  import { getTabListStyles } from '../internal/styles';
10
9
  import { onMouseDownBlur } from '../internal/utils';
11
10
 
12
- var TabListWithMode = function TabListWithMode(props) {
13
- var children = props.children,
14
- mode = props.mode;
11
+ /**
12
+ * __TabList__
13
+ *
14
+ * A TabList groups `Tab` components together.
15
+ *
16
+ * - [Examples](https://atlassian.design/components/tabs/examples)
17
+ * - [Code](https://atlassian.design/components/tabs/code)
18
+ * - [Usage](https://atlassian.design/components/tabs/usage)
19
+ */
20
+ var TabList = function TabList(props) {
21
+ var children = props.children;
22
+
23
+ var _useGlobalTheme = useGlobalTheme(),
24
+ mode = _useGlobalTheme.mode;
15
25
 
16
26
  var _useTabList = useTabList(),
17
27
  tabsId = _useTabList.tabsId,
@@ -22,7 +32,7 @@ var TabListWithMode = function TabListWithMode(props) {
22
32
 
23
33
  var childrenArray = Children.toArray(children).filter(Boolean);
24
34
  var length = childrenArray.length;
25
- var styles = useMemo(function () {
35
+ var tabListStyles = useMemo(function () {
26
36
  return getTabListStyles(mode);
27
37
  }, [mode]);
28
38
  var selectTabByIndex = useCallback(function (index) {
@@ -89,11 +99,19 @@ var TabListWithMode = function TabListWithMode(props) {
89
99
  key: index
90
100
  }, tab);
91
101
  }, [length, onKeyDown, onChange, tabsId]);
92
- return (// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
93
- jsx("div", {
102
+ return (// Only styles that affect the TabList itself have been applied via primitives.
103
+ // The other styles applied through the CSS prop are there for styling children
104
+ // through inheritance. This is important for custom cases that use the useTab(),
105
+ // which applies accessibility atributes that we use as a styling hook.
106
+ jsx(Box, {
107
+ as: "div",
94
108
  role: "tablist",
95
- css: styles,
96
- ref: ref
109
+ display: "flex",
110
+ position: "relative",
111
+ padding: "sp-0",
112
+ ref: ref // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
113
+ ,
114
+ css: tabListStyles
97
115
  }, childrenArray.map(function (child, index) {
98
116
  return getTabWithContext({
99
117
  tab: child,
@@ -103,23 +121,5 @@ var TabListWithMode = function TabListWithMode(props) {
103
121
  }))
104
122
  );
105
123
  };
106
- /**
107
- * __TabList__
108
- *
109
- * A TabList groups `Tab` components together.
110
- *
111
- * - [Examples](https://atlassian.design/components/tabs/examples)
112
- * - [Code](https://atlassian.design/components/tabs/code)
113
- * - [Usage](https://atlassian.design/components/tabs/usage)
114
- */
115
124
 
116
-
117
- export var TabList = function TabList(props) {
118
- return jsx(GlobalTheme.Consumer, null, function (_ref2) {
119
- var mode = _ref2.mode;
120
- return jsx(TabListWithMode, _extends({}, props, {
121
- mode: mode
122
- }));
123
- });
124
- };
125
125
  export default TabList;
@@ -1,7 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
 
3
3
  /** @jsx jsx */
4
+ import { Fragment } from 'react';
4
5
  import { jsx } from '@emotion/react';
6
+ import { UNSAFE_Box as Box } from '@atlaskit/ds-explorations';
5
7
  import { useTabPanel } from '../hooks';
6
8
 
7
9
  // Note this is not being memoized as children is an unstable reference
@@ -19,9 +21,10 @@ var TabPanel = function TabPanel(_ref) {
19
21
  var children = _ref.children,
20
22
  testId = _ref.testId;
21
23
  var tabPanelAttributes = useTabPanel();
22
- return jsx("div", _extends({
23
- "data-testid": testId
24
- }, tabPanelAttributes), children);
24
+ return jsx(Box, _extends({
25
+ testId: testId,
26
+ as: "div"
27
+ }, tabPanelAttributes), jsx(Fragment, null, children));
25
28
  };
26
29
 
27
30
  export default TabPanel;
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
 
3
3
  /** @jsx jsx */
4
4
  import { jsx } from '@emotion/react';
5
+ import { UNSAFE_Box as Box, UNSAFE_Text as Text } from '@atlaskit/ds-explorations';
5
6
  import { useTab } from '../hooks';
6
7
 
7
8
  /**
@@ -17,7 +18,13 @@ export default function Tab(_ref) {
17
18
  var children = _ref.children,
18
19
  testId = _ref.testId;
19
20
  var tabAttributes = useTab();
20
- return jsx("div", _extends({
21
- "data-testid": testId
22
- }, tabAttributes), children);
21
+ return jsx(Box, _extends({
22
+ as: "div",
23
+ testId: testId
24
+ }, tabAttributes), jsx(Text, {
25
+ shouldTruncate: true,
26
+ UNSAFE_style: {
27
+ color: 'inherit'
28
+ }
29
+ }, children));
23
30
  }
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  import _toArray from "@babel/runtime/helpers/toArray";
4
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
@@ -8,17 +7,18 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
8
7
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
8
 
10
9
  /** @jsx jsx */
11
- import { Children, useCallback, useMemo, useRef, useState } from 'react';
10
+ import { Children, Fragment, useCallback, useMemo, useRef, useState } from 'react';
12
11
  import { jsx } from '@emotion/react';
13
12
  import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
14
- import GlobalTheme from '@atlaskit/theme/components';
13
+ import { UNSAFE_Box as Box } from '@atlaskit/ds-explorations';
14
+ import { useGlobalTheme } from '@atlaskit/theme/components';
15
15
  import { TabListContext, TabPanelContext } from '../internal/context';
16
16
  import { getTabsStyles } from '../internal/styles';
17
17
  import { onMouseDownBlur } from '../internal/utils';
18
18
  var analyticsAttributes = {
19
19
  componentName: 'tabs',
20
20
  packageName: "@atlaskit/tabs",
21
- packageVersion: "13.3.1"
21
+ packageVersion: "13.3.3"
22
22
  };
23
23
 
24
24
  var getTabPanelWithContext = function getTabPanelWithContext(_ref) {
@@ -40,8 +40,18 @@ var getTabPanelWithContext = function getTabPanelWithContext(_ref) {
40
40
  }, tabPanel)
41
41
  );
42
42
  };
43
+ /**
44
+ * __Tabs__
45
+ *
46
+ * Tabs acts as a container for all Tab components.
47
+ *
48
+ * - [Examples](https://atlassian.design/components/tabs/examples)
49
+ * - [Code](https://atlassian.design/components/tabs/code)
50
+ * - [Usage](https://atlassian.design/components/tabs/usage)
51
+ */
43
52
 
44
- var TabsWithMode = function TabsWithMode(props) {
53
+
54
+ var Tabs = function Tabs(props) {
45
55
  var _props$shouldUnmountT = props.shouldUnmountTabPanelOnChange,
46
56
  shouldUnmountTabPanelOnChange = _props$shouldUnmountT === void 0 ? false : _props$shouldUnmountT,
47
57
  SelectedType = props.selected,
@@ -50,8 +60,10 @@ var TabsWithMode = function TabsWithMode(props) {
50
60
  id = props.id,
51
61
  analyticsContext = props.analyticsContext,
52
62
  children = props.children,
53
- testId = props.testId,
54
- mode = props.mode;
63
+ testId = props.testId;
64
+
65
+ var _useGlobalTheme = useGlobalTheme(),
66
+ mode = _useGlobalTheme.mode;
55
67
 
56
68
  var _useState = useState(SelectedType || defaultSelected || 0),
57
69
  _useState2 = _slicedToArray(_useState, 2),
@@ -104,9 +116,22 @@ var TabsWithMode = function TabsWithMode(props) {
104
116
  var tabsStyles = useMemo(function () {
105
117
  return getTabsStyles(mode);
106
118
  }, [mode]);
107
- return (// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
108
- jsx("div", {
109
- "data-testid": testId,
119
+ return (// Only styles that affect the Tabs container itself have been applied via primitives.
120
+ // The other styles applied through the CSS prop are there for styling children
121
+ // through inheritance. This is important for custom cases that use the useTabPanel(),
122
+ // which applies accessibility atributes that we use as a styling hook.
123
+ jsx(Box, {
124
+ as: "div",
125
+ testId: testId,
126
+ display: "flex",
127
+ flexDirection: "column",
128
+ UNSAFE_style: {
129
+ maxWidth: '100%',
130
+ minHeight: '0%',
131
+ flexBasis: '100%',
132
+ flexGrow: 1
133
+ } // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
134
+ ,
110
135
  css: tabsStyles
111
136
  }, jsx(TabListContext.Provider, {
112
137
  value: {
@@ -114,26 +139,8 @@ var TabsWithMode = function TabsWithMode(props) {
114
139
  onChange: onChangeAnalytics,
115
140
  tabsId: id
116
141
  }
117
- }, tabList), tabPanelsWithContext)
142
+ }, tabList), jsx(Fragment, null, tabPanelsWithContext))
118
143
  );
119
144
  };
120
- /**
121
- * __Tabs__
122
- *
123
- * Tabs acts as a container for all Tab components.
124
- *
125
- * - [Examples](https://atlassian.design/components/tabs/examples)
126
- * - [Code](https://atlassian.design/components/tabs/code)
127
- * - [Usage](https://atlassian.design/components/tabs/usage)
128
- */
129
-
130
145
 
131
- export var Tabs = function Tabs(props) {
132
- return jsx(GlobalTheme.Consumer, null, function (_ref2) {
133
- var mode = _ref2.mode;
134
- return jsx(TabsWithMode, _extends({}, props, {
135
- mode: mode
136
- }));
137
- });
138
- };
139
146
  export default Tabs;
@@ -43,12 +43,6 @@ var getTabPanelStyles = function getTabPanelStyles(mode) {
43
43
  export var getTabsStyles = function getTabsStyles(mode) {
44
44
  return (// eslint-disable-next-line @repo/internal/styles/no-exported-styles
45
45
  css({
46
- display: 'flex',
47
- maxWidth: '100%',
48
- minHeight: '0%',
49
- flexBasis: '100%',
50
- flexDirection: 'column',
51
- flexGrow: 1,
52
46
  '& [role="tabpanel"]': getTabPanelStyles(mode),
53
47
  // The hidden attribute doesn't work on flex elements
54
48
  // Change display to be none
@@ -72,10 +66,6 @@ var tabLineStyles = {
72
66
  export var getTabListStyles = function getTabListStyles(mode) {
73
67
  return (// eslint-disable-next-line @repo/internal/styles/no-exported-styles
74
68
  css({
75
- display: 'flex',
76
- margin: 0,
77
- padding: 0,
78
- position: 'relative',
79
69
  '& [role="tab"]': getTabStyles(mode),
80
70
  fontWeight: 500,
81
71
  '&::before': _objectSpread(_objectSpread({}, tabLineStyles), {}, {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tabs",
3
- "version": "13.3.1",
3
+ "version": "13.3.3",
4
4
  "sideEffects": false
5
5
  }
@@ -9,5 +9,5 @@ import { TabListProps } from '../types';
9
9
  * - [Code](https://atlassian.design/components/tabs/code)
10
10
  * - [Usage](https://atlassian.design/components/tabs/usage)
11
11
  */
12
- export declare const TabList: (props: TabListProps) => jsx.JSX.Element;
12
+ declare const TabList: (props: TabListProps) => jsx.JSX.Element;
13
13
  export default TabList;
@@ -1,4 +1,3 @@
1
- /** @jsx jsx */
2
1
  import { jsx } from '@emotion/react';
3
2
  import { TabPanelProps } from '../types';
4
3
  /**
@@ -9,5 +9,5 @@ import { TabsProps } from '../types';
9
9
  * - [Code](https://atlassian.design/components/tabs/code)
10
10
  * - [Usage](https://atlassian.design/components/tabs/usage)
11
11
  */
12
- export declare const Tabs: (props: TabsProps) => jsx.JSX.Element;
12
+ declare const Tabs: (props: TabsProps) => jsx.JSX.Element;
13
13
  export default Tabs;
@@ -9,5 +9,5 @@ import { TabListProps } from '../types';
9
9
  * - [Code](https://atlassian.design/components/tabs/code)
10
10
  * - [Usage](https://atlassian.design/components/tabs/usage)
11
11
  */
12
- export declare const TabList: (props: TabListProps) => jsx.JSX.Element;
12
+ declare const TabList: (props: TabListProps) => jsx.JSX.Element;
13
13
  export default TabList;
@@ -1,4 +1,3 @@
1
- /** @jsx jsx */
2
1
  import { jsx } from '@emotion/react';
3
2
  import { TabPanelProps } from '../types';
4
3
  /**
@@ -9,5 +9,5 @@ import { TabsProps } from '../types';
9
9
  * - [Code](https://atlassian.design/components/tabs/code)
10
10
  * - [Usage](https://atlassian.design/components/tabs/usage)
11
11
  */
12
- export declare const Tabs: (props: TabsProps) => jsx.JSX.Element;
12
+ declare const Tabs: (props: TabsProps) => jsx.JSX.Element;
13
13
  export default Tabs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tabs",
3
- "version": "13.3.1",
3
+ "version": "13.3.3",
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/"
@@ -15,13 +15,15 @@
15
15
  "typesVersions": {
16
16
  ">=4.0 <4.5": {
17
17
  "*": [
18
- "dist/types-ts4.0/*"
18
+ "dist/types-ts4.0/*",
19
+ "dist/types-ts4.0/index.d.ts"
19
20
  ]
20
21
  }
21
22
  },
22
23
  "sideEffects": false,
23
24
  "atlaskit:src": "src/index.tsx",
24
25
  "atlassian": {
26
+ "disableProductCI": true,
25
27
  "team": "Design System Team",
26
28
  "releaseModel": "scheduled",
27
29
  "website": {
@@ -32,6 +34,7 @@
32
34
  "dependencies": {
33
35
  "@atlaskit/analytics-next": "^8.2.0",
34
36
  "@atlaskit/codemod-utils": "^4.1.0",
37
+ "@atlaskit/ds-explorations": "^0.1.0",
35
38
  "@atlaskit/theme": "^12.2.0",
36
39
  "@atlaskit/tokens": "^0.10.0",
37
40
  "@babel/runtime": "^7.0.0",
@@ -44,10 +47,10 @@
44
47
  "@atlaskit/button": "^16.3.0",
45
48
  "@atlaskit/docs": "*",
46
49
  "@atlaskit/ds-lib": "^2.1.0",
47
- "@atlaskit/section-message": "^6.2.0",
50
+ "@atlaskit/section-message": "^6.3.0",
48
51
  "@atlaskit/spinner": "^15.1.0",
49
52
  "@atlaskit/ssr": "*",
50
- "@atlaskit/tooltip": "^17.5.0",
53
+ "@atlaskit/tooltip": "^17.6.0",
51
54
  "@atlaskit/visual-regression": "*",
52
55
  "@atlaskit/webdriver-runner": "*",
53
56
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
@@ -67,8 +70,12 @@
67
70
  "@repo/internal": {
68
71
  "dom-events": "use-bind-event-listener",
69
72
  "design-system": "v1",
70
- "ui-components": "lite-mode",
73
+ "ui-components": [
74
+ "primitives",
75
+ "lite-mode"
76
+ ],
71
77
  "analytics": "analytics-next",
78
+ "design-tokens": "spacing",
72
79
  "theming": "tokens",
73
80
  "styling": [
74
81
  "static",
package/report.api.md CHANGED
@@ -1,10 +1,11 @@
1
- ## API Report File for "@atlaskit/tabs"
1
+ ## API Report File for "@atlaskit/tabs".
2
2
 
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
3
+ > Do not edit this file. This report is auto-generated by [API Extractor](https://api-extractor.com/).
4
4
 
5
- ```ts
6
- /// <reference types="react" />
5
+ [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
7
6
 
7
+ ```ts
8
+ import { jsx } from '@emotion/react';
8
9
  import { KeyboardEvent as KeyboardEvent_2 } from 'react';
9
10
  import { MouseEvent as MouseEvent_2 } from 'react';
10
11
  import { ReactNode } from 'react';
@@ -18,7 +19,16 @@ declare type OnChangeCallback = (
18
19
 
19
20
  declare type SelectedType = number;
20
21
 
21
- export declare function Tab({ children, testId }: TabProps): JSX.Element;
22
+ /**
23
+ * __Tab__
24
+ *
25
+ * Tab represents an indivudal Tab displayed in a TabList.
26
+ *
27
+ * - [Examples](https://atlassian.design/components/tabs/examples)
28
+ * - [Code](https://atlassian.design/components/tabs/code)
29
+ * - [Usage](https://atlassian.design/components/tabs/usage)
30
+ */
31
+ export declare function Tab({ children, testId }: TabProps): jsx.JSX.Element;
22
32
 
23
33
  export declare type TabAttributesType = {
24
34
  /**
@@ -79,19 +89,36 @@ export declare type TabAttributesType = {
79
89
  * The TabData type remains so the variable used in tabs can have a type.
80
90
  */
81
91
  export declare interface TabData {
82
- /** String to be put inside a tab */
92
+ /**
93
+ * String to be put inside a tab
94
+ */
83
95
  label?: string;
84
- /** String to be put inside a tab panel */
96
+ /**
97
+ * String to be put inside a tab panel
98
+ */
85
99
  content?: ReactNode;
86
- /** A `testId` prop is provided for specified elements, which is a unique
100
+ /**
101
+ * A `testId` prop is provided for specified elements, which is a unique
87
102
  * string that appears as a data attribute `data-testid` in the rendered code,
88
- * serving as a hook for automated tests. This `testId` is put on the tab. */
103
+ * serving as a hook for automated tests. This `testId` is put on the tab.
104
+ */
89
105
  testId?: string;
90
- /** Used by consumers to convey extra information about the tab. */
106
+ /**
107
+ * Used by consumers to convey extra information about the tab.
108
+ */
91
109
  [key: string]: any;
92
110
  }
93
111
 
94
- export declare const TabList: (props: TabListProps) => JSX.Element;
112
+ /**
113
+ * __TabList__
114
+ *
115
+ * A TabList groups `Tab` components together.
116
+ *
117
+ * - [Examples](https://atlassian.design/components/tabs/examples)
118
+ * - [Code](https://atlassian.design/components/tabs/code)
119
+ * - [Usage](https://atlassian.design/components/tabs/usage)
120
+ */
121
+ export declare const TabList: (props: TabListProps) => jsx.JSX.Element;
95
122
 
96
123
  export declare type TabListAttributesType = {
97
124
  /**
@@ -117,10 +144,19 @@ export declare interface TabListProps {
117
144
  children: ReactNode;
118
145
  }
119
146
 
147
+ /**
148
+ * __TabPanel__
149
+ *
150
+ * A TabPanel houses the contents of a Tab.
151
+ *
152
+ * - [Examples](https://atlassian.design/components/tabs/examples)
153
+ * - [Code](https://atlassian.design/components/tabs/code)
154
+ * - [Usage](https://atlassian.design/components/tabs/usage)
155
+ */
120
156
  export declare const TabPanel: ({
121
157
  children,
122
158
  testId,
123
- }: TabPanelProps) => JSX.Element;
159
+ }: TabPanelProps) => jsx.JSX.Element;
124
160
 
125
161
  export declare type TabPanelAttributesType = {
126
162
  /**
@@ -174,7 +210,16 @@ export declare interface TabProps {
174
210
  testId?: string;
175
211
  }
176
212
 
177
- declare const Tabs: (props: TabsProps) => JSX.Element;
213
+ /**
214
+ * __Tabs__
215
+ *
216
+ * Tabs acts as a container for all Tab components.
217
+ *
218
+ * - [Examples](https://atlassian.design/components/tabs/examples)
219
+ * - [Code](https://atlassian.design/components/tabs/code)
220
+ * - [Usage](https://atlassian.design/components/tabs/usage)
221
+ */
222
+ declare const Tabs: (props: TabsProps) => jsx.JSX.Element;
178
223
  export default Tabs;
179
224
 
180
225
  export declare interface TabsProps extends WithAnalyticsEventsProps {