@atlaskit/tabs 13.3.0 → 13.3.2
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 +12 -0
- package/__perf__/default.tsx +1 -0
- package/dist/cjs/components/tab-list.js +32 -34
- package/dist/cjs/components/tab-panel.js +9 -4
- package/dist/cjs/components/tab.js +11 -3
- package/dist/cjs/components/tabs.js +37 -32
- package/dist/cjs/internal/styles.js +0 -10
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/tab-list.js +29 -26
- package/dist/es2019/components/tab-panel.js +6 -3
- package/dist/es2019/components/tab.js +10 -3
- package/dist/es2019/components/tabs.js +36 -27
- package/dist/es2019/internal/styles.js +0 -10
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/tab-list.js +29 -29
- package/dist/esm/components/tab-panel.js +6 -3
- package/dist/esm/components/tab.js +10 -3
- package/dist/esm/components/tabs.js +36 -29
- package/dist/esm/internal/styles.js +0 -10
- package/dist/esm/version.json +1 -1
- package/dist/types/components/tab-list.d.ts +1 -1
- package/dist/types/components/tab-panel.d.ts +0 -1
- package/dist/types/components/tabs.d.ts +1 -1
- package/dist/types-ts4.0/components/tab-list.d.ts +13 -0
- package/dist/types-ts4.0/components/tab-panel.d.ts +13 -0
- package/dist/types-ts4.0/components/tab.d.ts +13 -0
- package/dist/types-ts4.0/components/tabs.d.ts +13 -0
- package/dist/types-ts4.0/hooks.d.ts +3 -0
- package/dist/types-ts4.0/index.d.ts +6 -0
- package/dist/types-ts4.0/internal/colors.d.ts +17 -0
- package/dist/types-ts4.0/internal/context.d.ts +5 -0
- package/dist/types-ts4.0/internal/styles.d.ts +5 -0
- package/dist/types-ts4.0/internal/utils.d.ts +2 -0
- package/dist/types-ts4.0/performance/examples.d.ts +24 -0
- package/dist/types-ts4.0/types.d.ts +196 -0
- package/hooks/package.json +8 -1
- package/package.json +17 -6
- package/report.api.md +58 -13
- package/types/package.json +8 -1
|
@@ -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
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
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 (//
|
|
93
|
-
|
|
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
|
-
|
|
96
|
-
|
|
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(
|
|
23
|
-
|
|
24
|
-
|
|
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(
|
|
21
|
-
"
|
|
22
|
-
|
|
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
|
|
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.
|
|
21
|
+
packageVersion: "13.3.2"
|
|
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
|
-
|
|
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
|
-
|
|
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 (//
|
|
108
|
-
|
|
109
|
-
|
|
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), {}, {
|
package/dist/esm/version.json
CHANGED
|
@@ -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
|
-
|
|
12
|
+
declare const TabList: (props: TabListProps) => jsx.JSX.Element;
|
|
13
13
|
export default TabList;
|
|
@@ -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
|
-
|
|
12
|
+
declare const Tabs: (props: TabsProps) => jsx.JSX.Element;
|
|
13
13
|
export default Tabs;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import { TabListProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* __TabList__
|
|
5
|
+
*
|
|
6
|
+
* A TabList groups `Tab` components together.
|
|
7
|
+
*
|
|
8
|
+
* - [Examples](https://atlassian.design/components/tabs/examples)
|
|
9
|
+
* - [Code](https://atlassian.design/components/tabs/code)
|
|
10
|
+
* - [Usage](https://atlassian.design/components/tabs/usage)
|
|
11
|
+
*/
|
|
12
|
+
declare const TabList: (props: TabListProps) => jsx.JSX.Element;
|
|
13
|
+
export default TabList;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import { TabPanelProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* __TabPanel__
|
|
5
|
+
*
|
|
6
|
+
* A TabPanel houses the contents of a Tab.
|
|
7
|
+
*
|
|
8
|
+
* - [Examples](https://atlassian.design/components/tabs/examples)
|
|
9
|
+
* - [Code](https://atlassian.design/components/tabs/code)
|
|
10
|
+
* - [Usage](https://atlassian.design/components/tabs/usage)
|
|
11
|
+
*/
|
|
12
|
+
declare const TabPanel: ({ children, testId }: TabPanelProps) => jsx.JSX.Element;
|
|
13
|
+
export default TabPanel;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import { TabProps } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* __Tab__
|
|
6
|
+
*
|
|
7
|
+
* Tab represents an indivudal Tab displayed in a TabList.
|
|
8
|
+
*
|
|
9
|
+
* - [Examples](https://atlassian.design/components/tabs/examples)
|
|
10
|
+
* - [Code](https://atlassian.design/components/tabs/code)
|
|
11
|
+
* - [Usage](https://atlassian.design/components/tabs/usage)
|
|
12
|
+
*/
|
|
13
|
+
export default function Tab({ children, testId }: TabProps): jsx.JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import { TabsProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* __Tabs__
|
|
5
|
+
*
|
|
6
|
+
* Tabs acts as a container for all Tab components.
|
|
7
|
+
*
|
|
8
|
+
* - [Examples](https://atlassian.design/components/tabs/examples)
|
|
9
|
+
* - [Code](https://atlassian.design/components/tabs/code)
|
|
10
|
+
* - [Usage](https://atlassian.design/components/tabs/usage)
|
|
11
|
+
*/
|
|
12
|
+
declare const Tabs: (props: TabsProps) => jsx.JSX.Element;
|
|
13
|
+
export default Tabs;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default } from './components/tabs';
|
|
2
|
+
export { default as TabPanel } from './components/tab-panel';
|
|
3
|
+
export { default as Tab } from './components/tab';
|
|
4
|
+
export { default as TabList } from './components/tab-list';
|
|
5
|
+
export type { TabProps, TabPanelProps, TabsProps, TabListProps, TabAttributesType, TabListAttributesType, TabPanelAttributesType, TabData, } from './types';
|
|
6
|
+
export { useTab, useTabPanel } from './hooks';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ThemeModes } from '@atlaskit/theme/types';
|
|
2
|
+
export declare type TabColors = {
|
|
3
|
+
labelColor: string;
|
|
4
|
+
activeLabelColor: string;
|
|
5
|
+
hoverLabelColor: string;
|
|
6
|
+
selectedColor: string;
|
|
7
|
+
focusBorderColor: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const getTabColors: (mode: ThemeModes) => TabColors;
|
|
10
|
+
export declare type TabLineColors = {
|
|
11
|
+
lineColor: string;
|
|
12
|
+
hoveredColor: string;
|
|
13
|
+
activeColor: string;
|
|
14
|
+
selectedColor: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const getTabLineColor: (mode: ThemeModes) => TabLineColors;
|
|
17
|
+
export declare const getTabPanelFocusColor: (mode: ThemeModes) => string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TabAttributesType, TabListAttributesType, TabPanelAttributesType } from '../types';
|
|
3
|
+
export declare const TabContext: import("react").Context<TabAttributesType | null>;
|
|
4
|
+
export declare const TabListContext: import("react").Context<TabListAttributesType | null>;
|
|
5
|
+
export declare const TabPanelContext: import("react").Context<TabPanelAttributesType | null>;
|
|
@@ -0,0 +1,5 @@
|
|
|
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;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { PublicInteractionTask } from 'storybook-addon-performance';
|
|
3
|
+
export declare const performance: {
|
|
4
|
+
(): JSX.Element;
|
|
5
|
+
story: {
|
|
6
|
+
name: string;
|
|
7
|
+
parameters: {
|
|
8
|
+
performance: {
|
|
9
|
+
interactions: PublicInteractionTask[];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare const heavyPerformance: {
|
|
15
|
+
(): JSX.Element;
|
|
16
|
+
story: {
|
|
17
|
+
name: string;
|
|
18
|
+
parameters: {
|
|
19
|
+
performance: {
|
|
20
|
+
interactions: PublicInteractionTask[];
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
2
|
+
import UIAnalyticsEvent from '@atlaskit/analytics-next/UIAnalyticsEvent';
|
|
3
|
+
import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
4
|
+
export interface TabProps {
|
|
5
|
+
/**
|
|
6
|
+
* The children to be rendered within a `Tab`.
|
|
7
|
+
*/
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* A `testId` prop is is a unique string that appears as a data attribute `data-testid`
|
|
11
|
+
* on the `Tab` element, serving as a hook for automated tests.
|
|
12
|
+
*/
|
|
13
|
+
testId?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface TabPanelProps {
|
|
16
|
+
/**
|
|
17
|
+
* The children to be rendered within a `TabPanel`.
|
|
18
|
+
*/
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* A `testId` prop is is a unique string that appears as a data attribute `data-testid`
|
|
22
|
+
* on the `TabPanel` element, serving as a hook for automated tests.
|
|
23
|
+
*/
|
|
24
|
+
testId?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated
|
|
28
|
+
* Previously this was the type for the tabs prop that was used like
|
|
29
|
+
* <Tabs tabs={tabs} />
|
|
30
|
+
* The codemod changes this to be
|
|
31
|
+
* <Tabs>
|
|
32
|
+
* <TabList>
|
|
33
|
+
* {tabs.map(tab => <Tab testId={tab.testId}>{tab.label}</Tab>)}
|
|
34
|
+
* </TabList>
|
|
35
|
+
* {tabs.map(tab => <TabPanel>{tab.content}</TabPanel>)}
|
|
36
|
+
* </Tabs>
|
|
37
|
+
* The TabData type remains so the variable used in tabs can have a type.
|
|
38
|
+
*/
|
|
39
|
+
export interface TabData {
|
|
40
|
+
/**
|
|
41
|
+
* String to be put inside a tab
|
|
42
|
+
*/
|
|
43
|
+
label?: string;
|
|
44
|
+
/**
|
|
45
|
+
* String to be put inside a tab panel
|
|
46
|
+
*/
|
|
47
|
+
content?: ReactNode;
|
|
48
|
+
/**
|
|
49
|
+
* A `testId` prop is provided for specified elements, which is a unique
|
|
50
|
+
* string that appears as a data attribute `data-testid` in the rendered code,
|
|
51
|
+
* serving as a hook for automated tests. This `testId` is put on the tab.
|
|
52
|
+
*/
|
|
53
|
+
testId?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Used by consumers to convey extra information about the tab.
|
|
56
|
+
*/
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
}
|
|
59
|
+
export declare type SelectedType = number;
|
|
60
|
+
export declare type OnChangeCallback = (index: SelectedType, analyticsEvent: UIAnalyticsEvent) => void;
|
|
61
|
+
export interface TabsProps extends WithAnalyticsEventsProps {
|
|
62
|
+
/**
|
|
63
|
+
* The index of the tab that will be selected by default when the component mounts.
|
|
64
|
+
* If not set the first tab will be displayed by default.
|
|
65
|
+
*/
|
|
66
|
+
defaultSelected?: SelectedType;
|
|
67
|
+
/**
|
|
68
|
+
* A callback function which will be fired when a changed. It will be passed
|
|
69
|
+
* the index of the selected tab and a `UIAnalyticsEvent`.
|
|
70
|
+
*/
|
|
71
|
+
onChange?: OnChangeCallback;
|
|
72
|
+
/**
|
|
73
|
+
* The selected tab's index. If this prop is set the component behaves as a
|
|
74
|
+
* controlled component. It will be up to you to listen to `onChange`.
|
|
75
|
+
*/
|
|
76
|
+
selected?: SelectedType;
|
|
77
|
+
/**
|
|
78
|
+
* Tabs by default leaves `TabPanel`'s mounted on the page after they have been selected.
|
|
79
|
+
* If you would like to unmount a `TabPanel` when it is not selected, set this prop to
|
|
80
|
+
* be true.
|
|
81
|
+
*/
|
|
82
|
+
shouldUnmountTabPanelOnChange?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Additional information to be included in the `context` of analytics events that come from `Tabs`.
|
|
85
|
+
*/
|
|
86
|
+
analyticsContext?: Record<string, any>;
|
|
87
|
+
/**
|
|
88
|
+
* A `testId` prop is a unique string that appears as a data attribute `data-testid`
|
|
89
|
+
* on the `Tabs` element, serving as a hook for automated tests.
|
|
90
|
+
*/
|
|
91
|
+
testId?: string;
|
|
92
|
+
/**
|
|
93
|
+
* The children of Tabs. The first child should be a `TabList` filled with `Tab`'s.
|
|
94
|
+
* Subsequent children should be `TabPanel`'s. There should be a `Tab` for each `TabPanel`.
|
|
95
|
+
* If you want to customize `Tab` or `TabPanel`, refer to the examples in the documentation.
|
|
96
|
+
*/
|
|
97
|
+
children: ReactNode;
|
|
98
|
+
/**
|
|
99
|
+
* A unique ID that will be used to generate IDs for tabs and tab panels.
|
|
100
|
+
* This is required for accessibility purposes.
|
|
101
|
+
*/
|
|
102
|
+
id: string;
|
|
103
|
+
}
|
|
104
|
+
export interface TabListProps {
|
|
105
|
+
/**
|
|
106
|
+
* A collection of `Tab`'s. There should be a `Tab` for each `TabPanel`.
|
|
107
|
+
* If you want to customize `Tab` there is documentation in the tab section.
|
|
108
|
+
*/
|
|
109
|
+
children: ReactNode;
|
|
110
|
+
}
|
|
111
|
+
export declare type TabAttributesType = {
|
|
112
|
+
/**
|
|
113
|
+
* Changes the selected tab.
|
|
114
|
+
*/
|
|
115
|
+
onClick: () => void;
|
|
116
|
+
/**
|
|
117
|
+
* ID of the tab.
|
|
118
|
+
*/
|
|
119
|
+
id: string;
|
|
120
|
+
/**
|
|
121
|
+
* The id of the tab panel that this tab links.
|
|
122
|
+
*/
|
|
123
|
+
'aria-controls': string;
|
|
124
|
+
/**
|
|
125
|
+
* The position of this tab within the tab list.
|
|
126
|
+
*/
|
|
127
|
+
'aria-posinset': number;
|
|
128
|
+
/**
|
|
129
|
+
* Whether this tab is selected.
|
|
130
|
+
*/
|
|
131
|
+
'aria-selected': boolean;
|
|
132
|
+
/**
|
|
133
|
+
* The number of tabs in this tab list.
|
|
134
|
+
*/
|
|
135
|
+
'aria-setsize': number;
|
|
136
|
+
/**
|
|
137
|
+
* Prevents a focus ring being shown when clicked.
|
|
138
|
+
*/
|
|
139
|
+
onMouseDown: (e: MouseEvent<HTMLElement>) => void;
|
|
140
|
+
/**
|
|
141
|
+
* Allows navigation of tabs with automatic activation.
|
|
142
|
+
* Read here for more details: https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-1/tabs.html
|
|
143
|
+
*/
|
|
144
|
+
onKeyDown: (e: KeyboardEvent<HTMLElement>) => void;
|
|
145
|
+
/**
|
|
146
|
+
* Role is "tab".
|
|
147
|
+
*/
|
|
148
|
+
role: 'tab';
|
|
149
|
+
/**
|
|
150
|
+
* If the tab is selected the tab index is 0 and is focusable.
|
|
151
|
+
* Otherwise it is -1 and is not focusable.
|
|
152
|
+
*/
|
|
153
|
+
tabIndex: number;
|
|
154
|
+
};
|
|
155
|
+
export declare type TabListAttributesType = {
|
|
156
|
+
/**
|
|
157
|
+
* The index of the selected tab.
|
|
158
|
+
*/
|
|
159
|
+
selected: SelectedType;
|
|
160
|
+
/**
|
|
161
|
+
* A unique ID that will be used to generate IDs for tabs and tab panels.
|
|
162
|
+
* This is required for accessibility reasons.
|
|
163
|
+
*/
|
|
164
|
+
tabsId: string;
|
|
165
|
+
/**
|
|
166
|
+
* A callback function which will be fired when a tab is changed.
|
|
167
|
+
*/
|
|
168
|
+
onChange: (index: SelectedType) => void;
|
|
169
|
+
};
|
|
170
|
+
export declare type TabPanelAttributesType = {
|
|
171
|
+
/**
|
|
172
|
+
* Role is "tabpanel".
|
|
173
|
+
*/
|
|
174
|
+
role: 'tabpanel';
|
|
175
|
+
/**
|
|
176
|
+
* ID of the the tab panel.
|
|
177
|
+
*/
|
|
178
|
+
id: string;
|
|
179
|
+
/**
|
|
180
|
+
* Hidden is true if it is not the selected tab.
|
|
181
|
+
*/
|
|
182
|
+
hidden?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* The id of the tab that links to this tab panel.
|
|
185
|
+
*/
|
|
186
|
+
'aria-labelledby': string;
|
|
187
|
+
/**
|
|
188
|
+
* Prevents a focus ring being shown when clicked.
|
|
189
|
+
*/
|
|
190
|
+
onMouseDown: (e: MouseEvent<HTMLElement>) => void;
|
|
191
|
+
/**
|
|
192
|
+
* If the tab panel is selected the tab index is 0 and is focusable.
|
|
193
|
+
* Otherwise it is -1 and is not focusable.
|
|
194
|
+
*/
|
|
195
|
+
tabIndex: number;
|
|
196
|
+
};
|
package/hooks/package.json
CHANGED
|
@@ -4,5 +4,12 @@
|
|
|
4
4
|
"module": "../dist/esm/hooks.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/hooks.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/hooks.d.ts"
|
|
7
|
+
"types": "../dist/types/hooks.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.0 <4.5": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.0/hooks.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
8
15
|
}
|