@atlaskit/tabs 13.4.0 → 13.4.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/tabs
2
2
 
3
+ ## 13.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
8
+
9
+ ## 13.4.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade Typescript from `4.5.5` to `4.9.5`
14
+
3
15
  ## 13.4.0
4
16
 
5
17
  ### Minor Changes
@@ -21,7 +21,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
21
21
  var analyticsAttributes = {
22
22
  componentName: 'tabs',
23
23
  packageName: "@atlaskit/tabs",
24
- packageVersion: "13.4.0"
24
+ packageVersion: "13.4.2"
25
25
  };
26
26
  var getTabPanelWithContext = function getTabPanelWithContext(_ref) {
27
27
  var tabPanel = _ref.tabPanel,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tabs",
3
- "version": "13.4.0",
3
+ "version": "13.4.2",
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.4.0"
13
+ packageVersion: "13.4.2"
14
14
  };
15
15
  const getTabPanelWithContext = ({
16
16
  tabPanel,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tabs",
3
- "version": "13.4.0",
3
+ "version": "13.4.2",
4
4
  "sideEffects": false
5
5
  }
@@ -15,7 +15,7 @@ import { onMouseDownBlur } from '../internal/utils';
15
15
  var analyticsAttributes = {
16
16
  componentName: 'tabs',
17
17
  packageName: "@atlaskit/tabs",
18
- packageVersion: "13.4.0"
18
+ packageVersion: "13.4.2"
19
19
  };
20
20
  var getTabPanelWithContext = function getTabPanelWithContext(_ref) {
21
21
  var tabPanel = _ref.tabPanel,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tabs",
3
- "version": "13.4.0",
3
+ "version": "13.4.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import { ThemeModes } from '@atlaskit/theme/types';
2
- export declare type TabColors = {
2
+ export type TabColors = {
3
3
  labelColor: string;
4
4
  activeLabelColor: string;
5
5
  hoverLabelColor: string;
@@ -7,7 +7,7 @@ export declare type TabColors = {
7
7
  focusBorderColor: string;
8
8
  };
9
9
  export declare const getTabColors: (mode: ThemeModes) => TabColors;
10
- export declare type TabLineColors = {
10
+ export type TabLineColors = {
11
11
  lineColor: string;
12
12
  hoveredColor: string;
13
13
  activeColor: string;
@@ -56,8 +56,8 @@ export interface TabData {
56
56
  */
57
57
  [key: string]: any;
58
58
  }
59
- export declare type SelectedType = number;
60
- export declare type OnChangeCallback = (index: SelectedType, analyticsEvent: UIAnalyticsEvent) => void;
59
+ export type SelectedType = number;
60
+ export type OnChangeCallback = (index: SelectedType, analyticsEvent: UIAnalyticsEvent) => void;
61
61
  export interface TabsProps extends WithAnalyticsEventsProps {
62
62
  /**
63
63
  * The index of the tab that will be selected by default when the component mounts.
@@ -108,7 +108,7 @@ export interface TabListProps {
108
108
  */
109
109
  children: ReactNode;
110
110
  }
111
- export declare type TabAttributesType = {
111
+ export type TabAttributesType = {
112
112
  /**
113
113
  * Changes the selected tab.
114
114
  */
@@ -152,7 +152,7 @@ export declare type TabAttributesType = {
152
152
  */
153
153
  tabIndex: number;
154
154
  };
155
- export declare type TabListAttributesType = {
155
+ export type TabListAttributesType = {
156
156
  /**
157
157
  * The index of the selected tab.
158
158
  */
@@ -167,7 +167,7 @@ export declare type TabListAttributesType = {
167
167
  */
168
168
  onChange: (index: SelectedType) => void;
169
169
  };
170
- export declare type TabPanelAttributesType = {
170
+ export type TabPanelAttributesType = {
171
171
  /**
172
172
  * Role is "tabpanel".
173
173
  */
@@ -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,3 @@
1
+ export declare const useTab: () => import("./types").TabAttributesType;
2
+ export declare const useTabList: () => import("./types").TabListAttributesType;
3
+ export declare const useTabPanel: () => import("./types").TabPanelAttributesType;
@@ -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 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 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,2 @@
1
+ import type { MouseEvent } from 'react';
2
+ export declare const onMouseDownBlur: (e: MouseEvent<HTMLElement>) => void;
@@ -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 type SelectedType = number;
60
+ export 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 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 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 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
+ };
@@ -6,9 +6,9 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/hooks.d.ts",
8
8
  "typesVersions": {
9
- ">=4.0 <4.5": {
9
+ ">=4.5 <4.9": {
10
10
  "*": [
11
- "../dist/types-ts4.0/hooks.d.ts"
11
+ "../dist/types-ts4.5/hooks.d.ts"
12
12
  ]
13
13
  }
14
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tabs",
3
- "version": "13.4.0",
3
+ "version": "13.4.2",
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,6 +12,14 @@
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.5 <4.9": {
17
+ "*": [
18
+ "dist/types-ts4.5/*",
19
+ "dist/types-ts4.5/index.d.ts"
20
+ ]
21
+ }
22
+ },
15
23
  "sideEffects": false,
16
24
  "atlaskit:src": "src/index.tsx",
17
25
  "atlassian": {
@@ -27,7 +35,7 @@
27
35
  "@atlaskit/codemod-utils": "^4.2.0",
28
36
  "@atlaskit/ds-explorations": "^2.1.0",
29
37
  "@atlaskit/theme": "^12.5.0",
30
- "@atlaskit/tokens": "^1.3.0",
38
+ "@atlaskit/tokens": "^1.4.0",
31
39
  "@babel/runtime": "^7.0.0",
32
40
  "@emotion/react": "^11.7.1"
33
41
  },
@@ -46,12 +54,11 @@
46
54
  "@atlaskit/webdriver-runner": "*",
47
55
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
48
56
  "@testing-library/react": "^12.1.5",
49
- "enzyme": "^3.10.0",
50
57
  "jscodeshift": "^0.13.0",
51
58
  "react-dom": "^16.8.0",
52
59
  "react-lorem-component": "^0.13.0",
53
60
  "storybook-addon-performance": "^0.16.0",
54
- "typescript": "4.5.5",
61
+ "typescript": "~4.9.5",
55
62
  "wait-for-expect": "^1.2.0"
56
63
  },
57
64
  "techstack": {
@@ -6,9 +6,9 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/types.d.ts",
8
8
  "typesVersions": {
9
- ">=4.0 <4.5": {
9
+ ">=4.5 <4.9": {
10
10
  "*": [
11
- "../dist/types-ts4.0/types.d.ts"
11
+ "../dist/types-ts4.5/types.d.ts"
12
12
  ]
13
13
  }
14
14
  }