@atlaskit/tabs 13.3.9 → 13.3.11
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 +13 -0
- package/dist/cjs/components/tab-list.js +20 -37
- package/dist/cjs/components/tab-panel.js +2 -10
- package/dist/cjs/components/tab.js +1 -7
- package/dist/cjs/components/tabs.js +32 -53
- package/dist/cjs/hooks.js +0 -14
- package/dist/cjs/index.js +0 -6
- package/dist/cjs/internal/colors.js +0 -8
- package/dist/cjs/internal/context.js +1 -2
- package/dist/cjs/internal/styles.js +6 -21
- package/dist/cjs/internal/utils.js +0 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/tab-list.js +14 -18
- package/dist/es2019/components/tab-panel.js +0 -4
- package/dist/es2019/components/tab.js +0 -2
- package/dist/es2019/components/tabs.js +16 -16
- package/dist/es2019/hooks.js +0 -6
- package/dist/es2019/internal/styles.js +14 -13
- package/dist/es2019/internal/utils.js +0 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/tab-list.js +20 -28
- package/dist/esm/components/tab-panel.js +1 -5
- package/dist/esm/components/tab.js +1 -3
- package/dist/esm/components/tabs.js +32 -39
- package/dist/esm/hooks.js +0 -6
- package/dist/esm/internal/styles.js +6 -12
- package/dist/esm/internal/utils.js +0 -1
- package/dist/esm/version.json +1 -1
- package/package.json +3 -3
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _toArray from "@babel/runtime/helpers/toArray";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
-
|
|
5
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
|
|
7
5
|
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; }
|
|
8
|
-
|
|
9
6
|
/** @jsx jsx */
|
|
10
7
|
import { Children, Fragment, useCallback, useMemo, useRef, useState } from 'react';
|
|
11
8
|
import { jsx } from '@emotion/react';
|
|
@@ -18,15 +15,15 @@ import { onMouseDownBlur } from '../internal/utils';
|
|
|
18
15
|
var analyticsAttributes = {
|
|
19
16
|
componentName: 'tabs',
|
|
20
17
|
packageName: "@atlaskit/tabs",
|
|
21
|
-
packageVersion: "13.3.
|
|
18
|
+
packageVersion: "13.3.11"
|
|
22
19
|
};
|
|
23
|
-
|
|
24
20
|
var getTabPanelWithContext = function getTabPanelWithContext(_ref) {
|
|
25
21
|
var tabPanel = _ref.tabPanel,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return (
|
|
22
|
+
index = _ref.index,
|
|
23
|
+
isSelected = _ref.isSelected,
|
|
24
|
+
tabsId = _ref.tabsId;
|
|
25
|
+
return (
|
|
26
|
+
// Ensure tabPanel exists in case it has been removed
|
|
30
27
|
tabPanel && jsx(TabPanelContext.Provider, {
|
|
31
28
|
value: {
|
|
32
29
|
role: 'tabpanel',
|
|
@@ -40,6 +37,7 @@ var getTabPanelWithContext = function getTabPanelWithContext(_ref) {
|
|
|
40
37
|
}, tabPanel)
|
|
41
38
|
);
|
|
42
39
|
};
|
|
40
|
+
|
|
43
41
|
/**
|
|
44
42
|
* __Tabs__
|
|
45
43
|
*
|
|
@@ -49,49 +47,42 @@ var getTabPanelWithContext = function getTabPanelWithContext(_ref) {
|
|
|
49
47
|
* - [Code](https://atlassian.design/components/tabs/code)
|
|
50
48
|
* - [Usage](https://atlassian.design/components/tabs/usage)
|
|
51
49
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
50
|
var Tabs = function Tabs(props) {
|
|
55
51
|
var _props$shouldUnmountT = props.shouldUnmountTabPanelOnChange,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
shouldUnmountTabPanelOnChange = _props$shouldUnmountT === void 0 ? false : _props$shouldUnmountT,
|
|
53
|
+
SelectedType = props.selected,
|
|
54
|
+
defaultSelected = props.defaultSelected,
|
|
55
|
+
onChangeProp = props.onChange,
|
|
56
|
+
id = props.id,
|
|
57
|
+
analyticsContext = props.analyticsContext,
|
|
58
|
+
children = props.children,
|
|
59
|
+
testId = props.testId;
|
|
65
60
|
var _useGlobalTheme = useGlobalTheme(),
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
mode = _useGlobalTheme.mode;
|
|
68
62
|
var _useState = useState(SelectedType || defaultSelected || 0),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
64
|
+
selectedState = _useState2[0],
|
|
65
|
+
setSelected = _useState2[1];
|
|
73
66
|
var selected = SelectedType === undefined ? selectedState : SelectedType;
|
|
74
|
-
var childrenArray = Children.toArray(children)
|
|
67
|
+
var childrenArray = Children.toArray(children)
|
|
68
|
+
// Don't include any conditional children
|
|
75
69
|
.filter(function (child) {
|
|
76
70
|
return Boolean(child);
|
|
77
|
-
});
|
|
78
|
-
|
|
71
|
+
});
|
|
72
|
+
// First child should be a tabList followed by tab panels
|
|
79
73
|
var _childrenArray = _toArray(childrenArray),
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
tabList = _childrenArray[0],
|
|
75
|
+
tabPanels = _childrenArray.slice(1);
|
|
83
76
|
|
|
77
|
+
// Keep track of visited and add to a set
|
|
84
78
|
var visited = useRef(new Set([selected]));
|
|
85
|
-
|
|
86
79
|
if (!visited.current.has(selected)) {
|
|
87
80
|
visited.current.add(selected);
|
|
88
81
|
}
|
|
89
|
-
|
|
90
82
|
var onChange = useCallback(function (index, analyticsEvent) {
|
|
91
83
|
if (onChangeProp) {
|
|
92
84
|
onChangeProp(index, analyticsEvent);
|
|
93
85
|
}
|
|
94
|
-
|
|
95
86
|
setSelected(index);
|
|
96
87
|
}, [onChangeProp]);
|
|
97
88
|
var onChangeAnalytics = usePlatformLeafEventHandler(_objectSpread({
|
|
@@ -104,7 +95,8 @@ var Tabs = function Tabs(props) {
|
|
|
104
95
|
index: selected,
|
|
105
96
|
isSelected: true,
|
|
106
97
|
tabsId: id
|
|
107
|
-
}) :
|
|
98
|
+
}) :
|
|
99
|
+
// If a panel has already been visited, don't unmount it
|
|
108
100
|
Array.from(visited.current).map(function (tabIndex) {
|
|
109
101
|
return getTabPanelWithContext({
|
|
110
102
|
tabPanel: tabPanels[tabIndex],
|
|
@@ -116,7 +108,8 @@ var Tabs = function Tabs(props) {
|
|
|
116
108
|
var tabsStyles = useMemo(function () {
|
|
117
109
|
return getTabsStyles(mode);
|
|
118
110
|
}, [mode]);
|
|
119
|
-
return (
|
|
111
|
+
return (
|
|
112
|
+
// Only styles that affect the Tabs container itself have been applied via primitives.
|
|
120
113
|
// The other styles applied through the CSS prop are there for styling children
|
|
121
114
|
// through inheritance. This is important for custom cases that use the useTabPanel(),
|
|
122
115
|
// which applies accessibility atributes that we use as a styling hook.
|
|
@@ -130,7 +123,8 @@ var Tabs = function Tabs(props) {
|
|
|
130
123
|
minHeight: '0%',
|
|
131
124
|
flexBasis: '100%',
|
|
132
125
|
flexGrow: 1
|
|
133
|
-
}
|
|
126
|
+
}
|
|
127
|
+
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
134
128
|
,
|
|
135
129
|
css: tabsStyles
|
|
136
130
|
}, jsx(TabListContext.Provider, {
|
|
@@ -142,5 +136,4 @@ var Tabs = function Tabs(props) {
|
|
|
142
136
|
}, tabList), jsx(Fragment, null, tabPanelsWithContext))
|
|
143
137
|
);
|
|
144
138
|
};
|
|
145
|
-
|
|
146
139
|
export default Tabs;
|
package/dist/esm/hooks.js
CHANGED
|
@@ -2,28 +2,22 @@ import { useContext } from 'react';
|
|
|
2
2
|
import { TabContext, TabListContext, TabPanelContext } from './internal/context';
|
|
3
3
|
export var useTab = function useTab() {
|
|
4
4
|
var tabData = useContext(TabContext);
|
|
5
|
-
|
|
6
5
|
if (tabData == null || typeof tabData === 'undefined') {
|
|
7
6
|
throw Error('@atlaskit/tabs: A Tab must have a TabList parent.');
|
|
8
7
|
}
|
|
9
|
-
|
|
10
8
|
return tabData;
|
|
11
9
|
};
|
|
12
10
|
export var useTabList = function useTabList() {
|
|
13
11
|
var tabListData = useContext(TabListContext);
|
|
14
|
-
|
|
15
12
|
if (tabListData === null || typeof tabListData === 'undefined') {
|
|
16
13
|
throw Error('@atlaskit/tabs: A TabList must have a Tabs parent.');
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
return tabListData;
|
|
20
16
|
};
|
|
21
17
|
export var useTabPanel = function useTabPanel() {
|
|
22
18
|
var tabPanelData = useContext(TabPanelContext);
|
|
23
|
-
|
|
24
19
|
if (tabPanelData === null || typeof tabPanelData === 'undefined') {
|
|
25
20
|
throw Error('@atlaskit/tabs: A TabPanel must have a Tabs parent.');
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
return tabPanelData;
|
|
29
23
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
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; }
|
|
6
|
-
|
|
7
4
|
import { css } from '@emotion/react';
|
|
8
5
|
import { borderRadius as getBorderRadius, gridSize as getGridSize } from '@atlaskit/theme/constants';
|
|
9
6
|
import { getTabColors, getTabLineColor, getTabPanelFocusColor } from './colors';
|
|
@@ -14,8 +11,9 @@ var tabTopBottomPadding = "".concat(gridSize / 2, "px");
|
|
|
14
11
|
var underlineHeight = '2px';
|
|
15
12
|
var highContrastFocusStyles = {
|
|
16
13
|
outline: '1px solid'
|
|
17
|
-
};
|
|
14
|
+
};
|
|
18
15
|
|
|
16
|
+
// Required so the focus ring is visible in high contrast mode
|
|
19
17
|
var highContrastFocusRing = {
|
|
20
18
|
'@media screen and (forced-colors: active), screen and (-ms-high-contrast: active)': {
|
|
21
19
|
'&:focus-visible': highContrastFocusStyles,
|
|
@@ -24,7 +22,6 @@ var highContrastFocusRing = {
|
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
};
|
|
27
|
-
|
|
28
25
|
var tabFocusStyles = function tabFocusStyles(mode) {
|
|
29
26
|
return {
|
|
30
27
|
boxShadow: "0 0 0 2px ".concat(getTabPanelFocusColor(mode), " inset"),
|
|
@@ -32,11 +29,9 @@ var tabFocusStyles = function tabFocusStyles(mode) {
|
|
|
32
29
|
outline: 'none'
|
|
33
30
|
};
|
|
34
31
|
};
|
|
35
|
-
|
|
36
32
|
var getTabPanelStyles = function getTabPanelStyles(mode) {
|
|
37
33
|
return _objectSpread({
|
|
38
34
|
flexGrow: 1,
|
|
39
|
-
|
|
40
35
|
/*
|
|
41
36
|
NOTE min-height set to 0% because of Firefox bug
|
|
42
37
|
FF http://stackoverflow.com/questions/28636832/firefox-overflow-y-not-working-with-nested-flexbox
|
|
@@ -50,9 +45,9 @@ var getTabPanelStyles = function getTabPanelStyles(mode) {
|
|
|
50
45
|
}
|
|
51
46
|
}, highContrastFocusRing);
|
|
52
47
|
};
|
|
53
|
-
|
|
54
48
|
export var getTabsStyles = function getTabsStyles(mode) {
|
|
55
|
-
return (
|
|
49
|
+
return (
|
|
50
|
+
// eslint-disable-next-line @repo/internal/styles/no-exported-styles
|
|
56
51
|
css({
|
|
57
52
|
'& [role="tabpanel"]': getTabPanelStyles(mode),
|
|
58
53
|
// The hidden attribute doesn't work on flex elements
|
|
@@ -75,7 +70,8 @@ var tabLineStyles = {
|
|
|
75
70
|
right: tabLeftRightPadding
|
|
76
71
|
};
|
|
77
72
|
export var getTabListStyles = function getTabListStyles(mode) {
|
|
78
|
-
return (
|
|
73
|
+
return (
|
|
74
|
+
// eslint-disable-next-line @repo/internal/styles/no-exported-styles
|
|
79
75
|
css({
|
|
80
76
|
'& [role="tab"]': getTabStyles(mode),
|
|
81
77
|
fontWeight: "var(--ds-font-weight-medium, 500)",
|
|
@@ -87,7 +83,6 @@ export var getTabListStyles = function getTabListStyles(mode) {
|
|
|
87
83
|
})
|
|
88
84
|
);
|
|
89
85
|
};
|
|
90
|
-
|
|
91
86
|
var tabPanelFocusStyles = function tabPanelFocusStyles(mode) {
|
|
92
87
|
var colors = getTabColors(mode);
|
|
93
88
|
return {
|
|
@@ -100,7 +95,6 @@ var tabPanelFocusStyles = function tabPanelFocusStyles(mode) {
|
|
|
100
95
|
}
|
|
101
96
|
};
|
|
102
97
|
};
|
|
103
|
-
|
|
104
98
|
export var getTabStyles = function getTabStyles(mode) {
|
|
105
99
|
var colors = getTabColors(mode);
|
|
106
100
|
return _objectSpread(_objectSpread({
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/tabs",
|
|
3
|
-
"version": "13.3.
|
|
3
|
+
"version": "13.3.11",
|
|
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/"
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@atlaskit/analytics-next": "^8.2.0",
|
|
28
28
|
"@atlaskit/codemod-utils": "^4.1.0",
|
|
29
|
-
"@atlaskit/ds-explorations": "^
|
|
29
|
+
"@atlaskit/ds-explorations": "^2.0.0",
|
|
30
30
|
"@atlaskit/theme": "^12.2.0",
|
|
31
|
-
"@atlaskit/tokens": "^0.
|
|
31
|
+
"@atlaskit/tokens": "^1.0.0",
|
|
32
32
|
"@babel/runtime": "^7.0.0",
|
|
33
33
|
"@emotion/react": "^11.7.1"
|
|
34
34
|
},
|