@atlaskit/tabs 16.1.2 → 16.2.0
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 +14 -1
- package/__perf__/default.tsx +16 -16
- package/codemods/13.0.0-lite-mode.tsx +14 -18
- package/codemods/__tests__/13.0.0-lite-mode.tsx +44 -44
- package/codemods/__tests__/add-id-prop.tsx +13 -13
- package/codemods/__tests__/map-tabs-prop.tsx +42 -42
- package/codemods/__tests__/on-select-to-on-change.tsx +49 -49
- package/codemods/__tests__/remove-components-prop.tsx +14 -14
- package/codemods/__tests__/remove-is-selected-test-prop.tsx +14 -14
- package/codemods/__tests__/remove-tab-item-tab-content.tsx +7 -7
- package/codemods/__tests__/remove-types.tsx +14 -14
- package/codemods/__tests__/rename-is-content-persisted-to-should-unmount-tab-panel-on-change.tsx +36 -38
- package/codemods/migrations/add-id-prop.tsx +37 -45
- package/codemods/migrations/map-tabs-prop.tsx +143 -164
- package/codemods/migrations/on-select-to-on-change.tsx +66 -76
- package/codemods/migrations/remove-components-prop.tsx +3 -3
- package/codemods/migrations/remove-is-selected-test-prop.tsx +3 -3
- package/codemods/migrations/remove-tab-item-tab-content.tsx +19 -22
- package/codemods/migrations/remove-types.tsx +32 -32
- package/codemods/migrations/rename-is-content-persisted-to-should-unmount-tab-panel-on-change.tsx +46 -59
- package/codemods/utils.tsx +25 -28
- package/dist/cjs/components/tab-list.js +5 -0
- package/dist/cjs/components/tab-panel.js +5 -0
- package/dist/cjs/components/tab.js +4 -0
- package/dist/cjs/components/tabs.js +4 -2
- package/dist/cjs/internal/styles.js +8 -5
- package/dist/es2019/components/tab-list.js +5 -0
- package/dist/es2019/components/tab-panel.js +5 -0
- package/dist/es2019/components/tab.js +4 -0
- package/dist/es2019/components/tabs.js +6 -1
- package/dist/es2019/internal/styles.js +9 -4
- package/dist/esm/components/tab-list.js +5 -0
- package/dist/esm/components/tab-panel.js +5 -0
- package/dist/esm/components/tab.js +4 -0
- package/dist/esm/components/tabs.js +6 -1
- package/dist/esm/internal/styles.js +8 -4
- package/dist/types/components/tab.d.ts +3 -0
- package/dist/types-ts4.5/components/tab.d.ts +3 -0
- package/extract-react-types/tab-attributes.tsx +1 -1
- package/extract-react-types/tab-panel-attributes.tsx +1 -1
- package/package.json +93 -93
- package/report.api.md +40 -42
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
type ASTPath,
|
|
3
|
+
type default as core,
|
|
4
|
+
type ImportDeclaration,
|
|
5
|
+
type JSXElement,
|
|
6
6
|
} from 'jscodeshift';
|
|
7
7
|
import { type Collection } from 'jscodeshift/src/Collection';
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
addCommentToStartOfFile,
|
|
11
|
+
getDefaultSpecifier,
|
|
12
|
+
getJSXAttributesByName,
|
|
13
13
|
} from '@atlaskit/codemod-utils';
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
createRemoveFuncWithDefaultSpecifierFor,
|
|
17
|
-
doesIdentifierExist,
|
|
18
|
-
} from '../utils';
|
|
15
|
+
import { createRemoveFuncWithDefaultSpecifierFor, doesIdentifierExist } from '../utils';
|
|
19
16
|
|
|
20
17
|
const spreadComment = `
|
|
21
18
|
This file is spreading props on the Tabs component.
|
|
@@ -31,162 +28,144 @@ https://atlassian.design/components/tabs/examples
|
|
|
31
28
|
`;
|
|
32
29
|
|
|
33
30
|
const getImportSpecifiers = (j: core.JSCodeshift, defined: Array<string>) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return j.importSpecifier(j.identifier(specifier));
|
|
42
|
-
}
|
|
43
|
-
});
|
|
31
|
+
return ['Tab', 'TabList', 'TabPanel'].map((specifier) => {
|
|
32
|
+
if (!defined.includes(specifier)) {
|
|
33
|
+
return j.importSpecifier(j.identifier(specifier), j.identifier(`Atlaskit${specifier}`));
|
|
34
|
+
} else {
|
|
35
|
+
return j.importSpecifier(j.identifier(specifier));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
44
38
|
};
|
|
45
39
|
|
|
46
40
|
const packageName = '@atlaskit/tabs';
|
|
47
41
|
export const mapTabsProp = (j: core.JSCodeshift, source: Collection<Node>) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
path.node.source.value === packageName,
|
|
176
|
-
)
|
|
177
|
-
.forEach((path: ASTPath<ImportDeclaration>) => {
|
|
178
|
-
j(path).replaceWith(
|
|
179
|
-
j.importDeclaration(
|
|
180
|
-
// @ts-ignore
|
|
181
|
-
[...path.value.specifiers, ...specifiers],
|
|
182
|
-
|
|
183
|
-
j.literal(packageName),
|
|
184
|
-
),
|
|
185
|
-
);
|
|
186
|
-
});
|
|
42
|
+
const specifier = getDefaultSpecifier(j, source, packageName);
|
|
43
|
+
|
|
44
|
+
if (!specifier) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const tabTagName = doesIdentifierExist({ j, base: source, name: 'Tab' }) ? 'AtlaskitTab' : 'Tab';
|
|
49
|
+
const tabListTagName = doesIdentifierExist({
|
|
50
|
+
j,
|
|
51
|
+
base: source,
|
|
52
|
+
name: 'TabList',
|
|
53
|
+
})
|
|
54
|
+
? 'AtlaskitTabList'
|
|
55
|
+
: 'TabList';
|
|
56
|
+
const tabPanelTagName = doesIdentifierExist({
|
|
57
|
+
j,
|
|
58
|
+
base: source,
|
|
59
|
+
name: 'TabPanel',
|
|
60
|
+
})
|
|
61
|
+
? 'AtlaskitTabPanel'
|
|
62
|
+
: 'TabPanel';
|
|
63
|
+
|
|
64
|
+
source.findJSXElements(specifier).forEach((element: ASTPath<JSXElement>) => {
|
|
65
|
+
let tabs;
|
|
66
|
+
|
|
67
|
+
getJSXAttributesByName(j, element, 'tabs').forEach((attribute: any) => {
|
|
68
|
+
tabs = attribute.value.value.expression;
|
|
69
|
+
});
|
|
70
|
+
if (!tabs) {
|
|
71
|
+
j(element)
|
|
72
|
+
.find(j.JSXOpeningElement)
|
|
73
|
+
.find(j.JSXSpreadAttribute)
|
|
74
|
+
.forEach((spreadAttribute) => {
|
|
75
|
+
// If using spread then leave a comment indicating further research being needed
|
|
76
|
+
addCommentToStartOfFile({ j, base: source, message: spreadComment });
|
|
77
|
+
const spreadArgument = spreadAttribute.value.argument;
|
|
78
|
+
tabs = j.memberExpression(spreadArgument, j.identifier('tabs'));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!tabs) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const newLine = j.jsxText('\n');
|
|
87
|
+
|
|
88
|
+
const tabList = j.jsxElement(
|
|
89
|
+
j.jsxOpeningElement(j.jsxIdentifier(tabListTagName)),
|
|
90
|
+
j.jsxClosingElement(j.jsxIdentifier(tabListTagName)),
|
|
91
|
+
[
|
|
92
|
+
j.jsxText('\n'),
|
|
93
|
+
j.jsxExpressionContainer(
|
|
94
|
+
j.callExpression(j.memberExpression(tabs, j.identifier('map')), [
|
|
95
|
+
j.arrowFunctionExpression(
|
|
96
|
+
[j.identifier('tab'), j.identifier('index')],
|
|
97
|
+
j.jsxElement(
|
|
98
|
+
j.jsxOpeningElement(j.jsxIdentifier(tabTagName), [
|
|
99
|
+
j.jsxAttribute(
|
|
100
|
+
j.jsxIdentifier('testId'),
|
|
101
|
+
j.jsxExpressionContainer(j.identifier('tab.testId')),
|
|
102
|
+
),
|
|
103
|
+
j.jsxAttribute(
|
|
104
|
+
j.jsxIdentifier('key'),
|
|
105
|
+
j.jsxExpressionContainer(j.identifier('index')),
|
|
106
|
+
),
|
|
107
|
+
]),
|
|
108
|
+
j.jsxClosingElement(j.jsxIdentifier(tabTagName)),
|
|
109
|
+
[j.jsxExpressionContainer(j.identifier('tab.label'))],
|
|
110
|
+
),
|
|
111
|
+
),
|
|
112
|
+
]),
|
|
113
|
+
),
|
|
114
|
+
j.jsxText('\n'),
|
|
115
|
+
],
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const tabPanels = j.jsxExpressionContainer(
|
|
119
|
+
j.callExpression(j.memberExpression(tabs, j.identifier('map')), [
|
|
120
|
+
j.arrowFunctionExpression(
|
|
121
|
+
[j.identifier('tab'), j.identifier('index')],
|
|
122
|
+
j.jsxElement(
|
|
123
|
+
j.jsxOpeningElement(j.jsxIdentifier(tabPanelTagName), [
|
|
124
|
+
j.jsxAttribute(
|
|
125
|
+
j.jsxIdentifier('key'),
|
|
126
|
+
j.jsxExpressionContainer(j.identifier('index')),
|
|
127
|
+
),
|
|
128
|
+
]),
|
|
129
|
+
j.jsxClosingElement(j.jsxIdentifier(tabPanelTagName)),
|
|
130
|
+
[j.jsxExpressionContainer(j.identifier('tab.content'))],
|
|
131
|
+
),
|
|
132
|
+
),
|
|
133
|
+
]),
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const tabsChildren = [newLine, tabList, newLine, tabPanels, newLine];
|
|
137
|
+
|
|
138
|
+
j(element)
|
|
139
|
+
.find(j.JSXOpeningElement)
|
|
140
|
+
.forEach((openingElement) => {
|
|
141
|
+
// @ts-ignore
|
|
142
|
+
if (openingElement.value.name.name === specifier) {
|
|
143
|
+
j(openingElement).replaceWith(
|
|
144
|
+
j.jsxElement(
|
|
145
|
+
j.jsxOpeningElement(j.jsxIdentifier(specifier), openingElement.value.attributes),
|
|
146
|
+
j.jsxClosingElement(j.jsxIdentifier(specifier)),
|
|
147
|
+
tabsChildren,
|
|
148
|
+
),
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const specifiers = getImportSpecifiers(j, [tabTagName, tabListTagName, tabPanelTagName]);
|
|
155
|
+
|
|
156
|
+
source
|
|
157
|
+
.find(j.ImportDeclaration)
|
|
158
|
+
.filter((path: ASTPath<ImportDeclaration>) => path.node.source.value === packageName)
|
|
159
|
+
.forEach((path: ASTPath<ImportDeclaration>) => {
|
|
160
|
+
j(path).replaceWith(
|
|
161
|
+
j.importDeclaration(
|
|
162
|
+
// @ts-ignore
|
|
163
|
+
[...path.value.specifiers, ...specifiers],
|
|
164
|
+
|
|
165
|
+
j.literal(packageName),
|
|
166
|
+
),
|
|
167
|
+
);
|
|
168
|
+
});
|
|
187
169
|
};
|
|
188
170
|
|
|
189
|
-
export const removeTabsProp = createRemoveFuncWithDefaultSpecifierFor(
|
|
190
|
-
'@atlaskit/tabs',
|
|
191
|
-
'tabs',
|
|
192
|
-
);
|
|
171
|
+
export const removeTabsProp = createRemoveFuncWithDefaultSpecifierFor('@atlaskit/tabs', 'tabs');
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ASTPath,
|
|
3
|
-
type default as core,
|
|
4
|
-
type JSXElement,
|
|
5
|
-
} from 'jscodeshift';
|
|
1
|
+
import { type ASTPath, type default as core, type JSXElement } from 'jscodeshift';
|
|
6
2
|
import { type Collection } from 'jscodeshift/src/Collection';
|
|
7
3
|
|
|
8
4
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
addCommentToStartOfFile,
|
|
6
|
+
getDefaultSpecifier,
|
|
7
|
+
getJSXAttributesByName,
|
|
12
8
|
} from '@atlaskit/codemod-utils';
|
|
13
9
|
|
|
14
10
|
const comment = `
|
|
@@ -30,72 +26,66 @@ If you are using the selected prop you will need to ensure that you are passing
|
|
|
30
26
|
of the selected tab as it also doesn't accept TabData anymore.
|
|
31
27
|
`;
|
|
32
28
|
|
|
33
|
-
export const migrateOnSelectType = (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
j.jsxIdentifier('onChange'),
|
|
96
|
-
j.jsxExpressionContainer(newVersionOfFn),
|
|
97
|
-
),
|
|
98
|
-
);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
29
|
+
export const migrateOnSelectType = (j: core.JSCodeshift, source: Collection<Node>) => {
|
|
30
|
+
const specifier = getDefaultSpecifier(j, source, '@atlaskit/tabs');
|
|
31
|
+
|
|
32
|
+
if (!specifier) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
source.findJSXElements(specifier).forEach((element: ASTPath<JSXElement>) => {
|
|
37
|
+
let tabs: any;
|
|
38
|
+
getJSXAttributesByName(j, element, 'tabs').forEach((attribute: any) => {
|
|
39
|
+
tabs = attribute.value.value.expression;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (!tabs) {
|
|
43
|
+
j(element)
|
|
44
|
+
.find(j.JSXOpeningElement)
|
|
45
|
+
.find(j.JSXSpreadAttribute)
|
|
46
|
+
.forEach((spreadAttribute) => {
|
|
47
|
+
const spreadArgument = spreadAttribute.value.argument;
|
|
48
|
+
tabs = j.memberExpression(spreadArgument, j.identifier('tabs'));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!tabs) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getJSXAttributesByName(j, element, 'onSelect').forEach((attribute: any) => {
|
|
57
|
+
addCommentToStartOfFile({ j, base: source, message: comment });
|
|
58
|
+
const onChangeValue = attribute.node.value.expression;
|
|
59
|
+
|
|
60
|
+
let selectedTab = j.variableDeclaration('const', [
|
|
61
|
+
j.variableDeclarator(
|
|
62
|
+
j.identifier('selectedTab'),
|
|
63
|
+
j.memberExpression(tabs, j.identifier('index'), true),
|
|
64
|
+
),
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
// Wrap arrow functions to create an IIFE
|
|
68
|
+
let onChangeCall = onChangeValue.name
|
|
69
|
+
? onChangeValue
|
|
70
|
+
: j.parenthesizedExpression(onChangeValue);
|
|
71
|
+
|
|
72
|
+
const newVersionOfFn = j.arrowFunctionExpression(
|
|
73
|
+
[j.identifier('index'), j.identifier('analyticsEvent')],
|
|
74
|
+
j.blockStatement([
|
|
75
|
+
selectedTab,
|
|
76
|
+
j.expressionStatement(
|
|
77
|
+
j.callExpression(onChangeCall, [
|
|
78
|
+
j.identifier('selectedTab'),
|
|
79
|
+
j.identifier('index'),
|
|
80
|
+
j.identifier('analyticsEvent'),
|
|
81
|
+
]),
|
|
82
|
+
),
|
|
83
|
+
]),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
j(attribute).replaceWith(
|
|
87
|
+
j.jsxAttribute(j.jsxIdentifier('onChange'), j.jsxExpressionContainer(newVersionOfFn)),
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
101
91
|
};
|
|
@@ -14,7 +14,7 @@ https://atlassian.design/components/tabs/examples#customizing-tab-panel
|
|
|
14
14
|
`;
|
|
15
15
|
|
|
16
16
|
export const removeComponentsProp = createRemoveFuncWithDefaultSpecifierFor(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
'@atlaskit/tabs',
|
|
18
|
+
'components',
|
|
19
|
+
comment,
|
|
20
20
|
);
|
|
@@ -11,7 +11,7 @@ This is documented at https:atlassian.design/components/tabs/examples#controlled
|
|
|
11
11
|
`;
|
|
12
12
|
|
|
13
13
|
export const removeIsSelectedTestProp = createRemoveFuncWithDefaultSpecifierFor(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
'@atlaskit/tabs',
|
|
15
|
+
'isSelectedTest',
|
|
16
|
+
comment,
|
|
17
17
|
);
|
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
type ASTPath,
|
|
3
|
+
type default as core,
|
|
4
|
+
type ImportDeclaration,
|
|
5
|
+
type ImportSpecifier,
|
|
6
6
|
} from 'jscodeshift';
|
|
7
7
|
import { type Collection } from 'jscodeshift/src/Collection';
|
|
8
8
|
|
|
9
9
|
const component = '@atlaskit/tabs';
|
|
10
10
|
|
|
11
|
-
export const removeTabItemTabContent = (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
j(importSpecifier).remove();
|
|
27
|
-
});
|
|
28
|
-
});
|
|
11
|
+
export const removeTabItemTabContent = (j: core.JSCodeshift, source: Collection<Node>) => {
|
|
12
|
+
source
|
|
13
|
+
.find(j.ImportDeclaration)
|
|
14
|
+
.filter(
|
|
15
|
+
(importDeclaration: ASTPath<ImportDeclaration>) =>
|
|
16
|
+
importDeclaration.node.source.value === component,
|
|
17
|
+
)
|
|
18
|
+
// Tabs only exported TabItem and TabContent from base so remove them
|
|
19
|
+
.forEach((importDeclaration) => {
|
|
20
|
+
j(importDeclaration)
|
|
21
|
+
.find(j.ImportSpecifier)
|
|
22
|
+
.forEach((importSpecifier: ASTPath<ImportSpecifier>) => {
|
|
23
|
+
j(importSpecifier).remove();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
29
26
|
};
|
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
type ASTPath,
|
|
3
|
+
type default as core,
|
|
4
|
+
type ImportDeclaration,
|
|
5
|
+
type ImportSpecifier,
|
|
6
6
|
} from 'jscodeshift';
|
|
7
7
|
import { type Collection } from 'jscodeshift/src/Collection';
|
|
8
8
|
|
|
9
9
|
const component = '@atlaskit/tabs/types';
|
|
10
10
|
const existingTypes = [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
'TabProps',
|
|
12
|
+
'TabPanelProps',
|
|
13
|
+
'TabsProps',
|
|
14
|
+
'TabListProps',
|
|
15
|
+
'TabAttributesType',
|
|
16
|
+
'TabListAttributesType',
|
|
17
|
+
'TabPanelAttributesType',
|
|
18
|
+
'TabData',
|
|
19
19
|
];
|
|
20
20
|
|
|
21
21
|
export const removeTypes = (j: core.JSCodeshift, source: Collection<Node>) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
source
|
|
23
|
+
.find(j.ImportDeclaration)
|
|
24
|
+
.filter(
|
|
25
|
+
(importDeclaration: ASTPath<ImportDeclaration>) =>
|
|
26
|
+
importDeclaration.node.source.value === component,
|
|
27
|
+
)
|
|
28
|
+
.forEach((importDeclaration) => {
|
|
29
|
+
const specifiers = j(importDeclaration)
|
|
30
|
+
.find(j.ImportSpecifier)
|
|
31
|
+
.filter((importSpecifier: ASTPath<ImportSpecifier>) => {
|
|
32
|
+
if (!existingTypes.includes(importSpecifier.node.imported.name)) {
|
|
33
|
+
j(importSpecifier).remove();
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
return true;
|
|
39
|
+
});
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
if (!specifiers.length) {
|
|
42
|
+
j(importDeclaration).remove();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
45
|
};
|