@atlaskit/tabs 13.3.4 → 13.3.6

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.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 13.3.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [`0637c50e226`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0637c50e226) - Updated Tabs compnent to prefer to use focus-visible over focus css selectors.
14
+
3
15
  ## 13.3.4
4
16
 
5
17
  ### Patch Changes
@@ -7,26 +7,24 @@ import {
7
7
  getJSXAttributesByName,
8
8
  } from '@atlaskit/codemod-utils';
9
9
 
10
- export const createRemoveFuncWithDefaultSpecifierFor = (
11
- component: string,
12
- prop: string,
13
- comment?: string,
14
- ) => (j: core.JSCodeshift, source: Collection<Node>) => {
15
- const specifier = getDefaultSpecifier(j, source, component);
10
+ export const createRemoveFuncWithDefaultSpecifierFor =
11
+ (component: string, prop: string, comment?: string) =>
12
+ (j: core.JSCodeshift, source: Collection<Node>) => {
13
+ const specifier = getDefaultSpecifier(j, source, component);
16
14
 
17
- if (!specifier) {
18
- return;
19
- }
15
+ if (!specifier) {
16
+ return;
17
+ }
20
18
 
21
- source.findJSXElements(specifier).forEach((element) => {
22
- getJSXAttributesByName(j, element, prop).forEach((attribute: any) => {
23
- if (comment) {
24
- addCommentToStartOfFile({ j, base: source, message: comment });
25
- }
26
- j(attribute).remove();
19
+ source.findJSXElements(specifier).forEach((element) => {
20
+ getJSXAttributesByName(j, element, prop).forEach((attribute: any) => {
21
+ if (comment) {
22
+ addCommentToStartOfFile({ j, base: source, message: comment });
23
+ }
24
+ j(attribute).remove();
25
+ });
27
26
  });
28
- });
29
- };
27
+ };
30
28
 
31
29
  export function doesIdentifierExist({
32
30
  j,
@@ -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.4"
39
+ packageVersion: "13.3.6"
40
40
  };
41
41
 
42
42
  var getTabPanelWithContext = function getTabPanelWithContext(_ref) {
@@ -23,16 +23,28 @@ var borderRadius = (0, _constants.borderRadius)();
23
23
  var gridSize = (0, _constants.gridSize)();
24
24
  var tabLeftRightPadding = "".concat(gridSize, "px");
25
25
  var tabTopBottomPadding = "".concat(gridSize / 2, "px");
26
- var underlineHeight = '2px'; // Required so the focus ring is visible in high contrast mode
26
+ var underlineHeight = '2px';
27
+ var highContrastFocusStyles = {
28
+ outline: '1px solid'
29
+ }; // Required so the focus ring is visible in high contrast mode
27
30
 
28
31
  var highContrastFocusRing = {
29
32
  '@media screen and (forced-colors: active), screen and (-ms-high-contrast: active)': {
30
- '&:focus': {
31
- outline: '1px solid'
33
+ '&:focus-visible': highContrastFocusStyles,
34
+ '@supports not selector(*:focus-visible)': {
35
+ '&:focus': highContrastFocusStyles
32
36
  }
33
37
  }
34
38
  };
35
39
 
40
+ var tabFocusStyles = function tabFocusStyles(mode) {
41
+ return {
42
+ boxShadow: "0 0 0 2px ".concat((0, _colors.getTabPanelFocusColor)(mode), " inset"),
43
+ borderRadius: borderRadius,
44
+ outline: 'none'
45
+ };
46
+ };
47
+
36
48
  var getTabPanelStyles = function getTabPanelStyles(mode) {
37
49
  return _objectSpread({
38
50
  flexGrow: 1,
@@ -44,10 +56,9 @@ var getTabPanelStyles = function getTabPanelStyles(mode) {
44
56
  minHeight: '0%',
45
57
  display: 'flex',
46
58
  padding: "0 ".concat(tabLeftRightPadding),
47
- '&:focus': {
48
- boxShadow: "0 0 0 2px ".concat((0, _colors.getTabPanelFocusColor)(mode), " inset"),
49
- borderRadius: borderRadius,
50
- outline: 'none'
59
+ '&:focus-visible': tabFocusStyles(mode),
60
+ '@supports not selector(*:focus-visible)': {
61
+ '&:focus': tabFocusStyles(mode)
51
62
  }
52
63
  }, highContrastFocusRing);
53
64
  };
@@ -94,6 +105,19 @@ var getTabListStyles = function getTabListStyles(mode) {
94
105
 
95
106
  exports.getTabListStyles = getTabListStyles;
96
107
 
108
+ var tabPanelFocusStyles = function tabPanelFocusStyles(mode) {
109
+ var colors = (0, _colors.getTabColors)(mode);
110
+ return {
111
+ boxShadow: "0 0 0 2px ".concat(colors.focusBorderColor, " inset"),
112
+ borderRadius: borderRadius,
113
+ outline: 'none',
114
+ // Hide TabLine on focus
115
+ '&::after': {
116
+ opacity: 0
117
+ }
118
+ };
119
+ };
120
+
97
121
  var getTabStyles = function getTabStyles(mode) {
98
122
  var colors = (0, _colors.getTabColors)(mode);
99
123
  return _objectSpread(_objectSpread({
@@ -122,14 +146,9 @@ var getTabStyles = function getTabStyles(mode) {
122
146
  height: 0
123
147
  })
124
148
  },
125
- '&:focus': {
126
- boxShadow: "0 0 0 2px ".concat(colors.focusBorderColor, " inset"),
127
- borderRadius: borderRadius,
128
- outline: 'none',
129
- // Hide TabLine on focus
130
- '&::after': {
131
- opacity: 0
132
- }
149
+ '&:focus-visible': tabPanelFocusStyles(mode),
150
+ '@supports not selector(*:focus-visible)': {
151
+ '&:focus': tabPanelFocusStyles(mode)
133
152
  }
134
153
  }, highContrastFocusRing), {}, {
135
154
  '&[aria-selected="true"]': {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tabs",
3
- "version": "13.3.4",
3
+ "version": "13.3.6",
4
4
  "sideEffects": false
5
5
  }
@@ -10,7 +10,7 @@ import { onMouseDownBlur } from '../internal/utils';
10
10
  const analyticsAttributes = {
11
11
  componentName: 'tabs',
12
12
  packageName: "@atlaskit/tabs",
13
- packageVersion: "13.3.4"
13
+ packageVersion: "13.3.6"
14
14
  };
15
15
 
16
16
  const getTabPanelWithContext = ({
@@ -5,16 +5,26 @@ const borderRadius = getBorderRadius();
5
5
  const gridSize = getGridSize();
6
6
  const tabLeftRightPadding = `${gridSize}px`;
7
7
  const tabTopBottomPadding = `${gridSize / 2}px`;
8
- const underlineHeight = '2px'; // Required so the focus ring is visible in high contrast mode
8
+ const underlineHeight = '2px';
9
+ const highContrastFocusStyles = {
10
+ outline: '1px solid'
11
+ }; // Required so the focus ring is visible in high contrast mode
9
12
 
10
13
  const highContrastFocusRing = {
11
14
  '@media screen and (forced-colors: active), screen and (-ms-high-contrast: active)': {
12
- '&:focus': {
13
- outline: '1px solid'
15
+ '&:focus-visible': highContrastFocusStyles,
16
+ '@supports not selector(*:focus-visible)': {
17
+ '&:focus': highContrastFocusStyles
14
18
  }
15
19
  }
16
20
  };
17
21
 
22
+ const tabFocusStyles = mode => ({
23
+ boxShadow: `0 0 0 2px ${getTabPanelFocusColor(mode)} inset`,
24
+ borderRadius: borderRadius,
25
+ outline: 'none'
26
+ });
27
+
18
28
  const getTabPanelStyles = mode => ({
19
29
  flexGrow: 1,
20
30
 
@@ -25,10 +35,9 @@ const getTabPanelStyles = mode => ({
25
35
  minHeight: '0%',
26
36
  display: 'flex',
27
37
  padding: `0 ${tabLeftRightPadding}`,
28
- '&:focus': {
29
- boxShadow: `0 0 0 2px ${getTabPanelFocusColor(mode)} inset`,
30
- borderRadius: borderRadius,
31
- outline: 'none'
38
+ '&:focus-visible': tabFocusStyles(mode),
39
+ '@supports not selector(*:focus-visible)': {
40
+ '&:focus': tabFocusStyles(mode)
32
41
  },
33
42
  ...highContrastFocusRing
34
43
  });
@@ -63,6 +72,20 @@ css({
63
72
  backgroundColor: getTabLineColor(mode).lineColor
64
73
  }
65
74
  });
75
+
76
+ const tabPanelFocusStyles = mode => {
77
+ const colors = getTabColors(mode);
78
+ return {
79
+ boxShadow: `0 0 0 2px ${colors.focusBorderColor} inset`,
80
+ borderRadius: borderRadius,
81
+ outline: 'none',
82
+ // Hide TabLine on focus
83
+ '&::after': {
84
+ opacity: 0
85
+ }
86
+ };
87
+ };
88
+
66
89
  export const getTabStyles = mode => {
67
90
  const colors = getTabColors(mode);
68
91
  return {
@@ -91,14 +114,9 @@ export const getTabStyles = mode => {
91
114
  height: 0
92
115
  }
93
116
  },
94
- '&:focus': {
95
- boxShadow: `0 0 0 2px ${colors.focusBorderColor} inset`,
96
- borderRadius: borderRadius,
97
- outline: 'none',
98
- // Hide TabLine on focus
99
- '&::after': {
100
- opacity: 0
101
- }
117
+ '&:focus-visible': tabPanelFocusStyles(mode),
118
+ '@supports not selector(*:focus-visible)': {
119
+ '&:focus': tabPanelFocusStyles(mode)
102
120
  },
103
121
  ...highContrastFocusRing,
104
122
  '&[aria-selected="true"]': {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tabs",
3
- "version": "13.3.4",
3
+ "version": "13.3.6",
4
4
  "sideEffects": false
5
5
  }
@@ -18,7 +18,7 @@ import { onMouseDownBlur } from '../internal/utils';
18
18
  var analyticsAttributes = {
19
19
  componentName: 'tabs',
20
20
  packageName: "@atlaskit/tabs",
21
- packageVersion: "13.3.4"
21
+ packageVersion: "13.3.6"
22
22
  };
23
23
 
24
24
  var getTabPanelWithContext = function getTabPanelWithContext(_ref) {
@@ -11,16 +11,28 @@ var borderRadius = getBorderRadius();
11
11
  var gridSize = getGridSize();
12
12
  var tabLeftRightPadding = "".concat(gridSize, "px");
13
13
  var tabTopBottomPadding = "".concat(gridSize / 2, "px");
14
- var underlineHeight = '2px'; // Required so the focus ring is visible in high contrast mode
14
+ var underlineHeight = '2px';
15
+ var highContrastFocusStyles = {
16
+ outline: '1px solid'
17
+ }; // Required so the focus ring is visible in high contrast mode
15
18
 
16
19
  var highContrastFocusRing = {
17
20
  '@media screen and (forced-colors: active), screen and (-ms-high-contrast: active)': {
18
- '&:focus': {
19
- outline: '1px solid'
21
+ '&:focus-visible': highContrastFocusStyles,
22
+ '@supports not selector(*:focus-visible)': {
23
+ '&:focus': highContrastFocusStyles
20
24
  }
21
25
  }
22
26
  };
23
27
 
28
+ var tabFocusStyles = function tabFocusStyles(mode) {
29
+ return {
30
+ boxShadow: "0 0 0 2px ".concat(getTabPanelFocusColor(mode), " inset"),
31
+ borderRadius: borderRadius,
32
+ outline: 'none'
33
+ };
34
+ };
35
+
24
36
  var getTabPanelStyles = function getTabPanelStyles(mode) {
25
37
  return _objectSpread({
26
38
  flexGrow: 1,
@@ -32,10 +44,9 @@ var getTabPanelStyles = function getTabPanelStyles(mode) {
32
44
  minHeight: '0%',
33
45
  display: 'flex',
34
46
  padding: "0 ".concat(tabLeftRightPadding),
35
- '&:focus': {
36
- boxShadow: "0 0 0 2px ".concat(getTabPanelFocusColor(mode), " inset"),
37
- borderRadius: borderRadius,
38
- outline: 'none'
47
+ '&:focus-visible': tabFocusStyles(mode),
48
+ '@supports not selector(*:focus-visible)': {
49
+ '&:focus': tabFocusStyles(mode)
39
50
  }
40
51
  }, highContrastFocusRing);
41
52
  };
@@ -76,6 +87,20 @@ export var getTabListStyles = function getTabListStyles(mode) {
76
87
  })
77
88
  );
78
89
  };
90
+
91
+ var tabPanelFocusStyles = function tabPanelFocusStyles(mode) {
92
+ var colors = getTabColors(mode);
93
+ return {
94
+ boxShadow: "0 0 0 2px ".concat(colors.focusBorderColor, " inset"),
95
+ borderRadius: borderRadius,
96
+ outline: 'none',
97
+ // Hide TabLine on focus
98
+ '&::after': {
99
+ opacity: 0
100
+ }
101
+ };
102
+ };
103
+
79
104
  export var getTabStyles = function getTabStyles(mode) {
80
105
  var colors = getTabColors(mode);
81
106
  return _objectSpread(_objectSpread({
@@ -104,14 +129,9 @@ export var getTabStyles = function getTabStyles(mode) {
104
129
  height: 0
105
130
  })
106
131
  },
107
- '&:focus': {
108
- boxShadow: "0 0 0 2px ".concat(colors.focusBorderColor, " inset"),
109
- borderRadius: borderRadius,
110
- outline: 'none',
111
- // Hide TabLine on focus
112
- '&::after': {
113
- opacity: 0
114
- }
132
+ '&:focus-visible': tabPanelFocusStyles(mode),
133
+ '@supports not selector(*:focus-visible)': {
134
+ '&:focus': tabPanelFocusStyles(mode)
115
135
  }
116
136
  }, highContrastFocusRing), {}, {
117
137
  '&[aria-selected="true"]': {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tabs",
3
- "version": "13.3.4",
3
+ "version": "13.3.6",
4
4
  "sideEffects": false
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tabs",
3
- "version": "13.3.4",
3
+ "version": "13.3.6",
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/"
@@ -12,14 +12,6 @@
12
12
  "module": "dist/esm/index.js",
13
13
  "module:es2019": "dist/es2019/index.js",
14
14
  "types": "dist/types/index.d.ts",
15
- "typesVersions": {
16
- ">=4.0 <4.5": {
17
- "*": [
18
- "dist/types-ts4.0/*",
19
- "dist/types-ts4.0/index.d.ts"
20
- ]
21
- }
22
- },
23
15
  "sideEffects": false,
24
16
  "atlaskit:src": "src/index.tsx",
25
17
  "atlassian": {
@@ -34,9 +26,9 @@
34
26
  "dependencies": {
35
27
  "@atlaskit/analytics-next": "^8.2.0",
36
28
  "@atlaskit/codemod-utils": "^4.1.0",
37
- "@atlaskit/ds-explorations": "^1.0.0",
29
+ "@atlaskit/ds-explorations": "^1.2.0",
38
30
  "@atlaskit/theme": "^12.2.0",
39
- "@atlaskit/tokens": "^0.10.0",
31
+ "@atlaskit/tokens": "^0.11.0",
40
32
  "@babel/runtime": "^7.0.0",
41
33
  "@emotion/react": "^11.7.1"
42
34
  },
@@ -1,13 +0,0 @@
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;
@@ -1,13 +0,0 @@
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;
@@ -1,13 +0,0 @@
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;
@@ -1,13 +0,0 @@
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;
@@ -1,3 +0,0 @@
1
- export declare const useTab: () => import("./types").TabAttributesType;
2
- export declare const useTabList: () => import("./types").TabListAttributesType;
3
- export declare const useTabPanel: () => import("./types").TabPanelAttributesType;
@@ -1,6 +0,0 @@
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';
@@ -1,17 +0,0 @@
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;
@@ -1,5 +0,0 @@
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>;
@@ -1,5 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- import type { MouseEvent } from 'react';
2
- export declare const onMouseDownBlur: (e: MouseEvent<HTMLElement>) => void;
@@ -1,24 +0,0 @@
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
- };
@@ -1,196 +0,0 @@
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
- };