@atlaskit/tabs 17.2.0 → 17.2.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 +14 -36
- package/dist/cjs/components/tab-list.compiled.css +8 -2
- package/dist/cjs/components/tab-list.js +1 -2
- package/dist/cjs/components/tabs.js +1 -1
- package/dist/es2019/components/tab-list.compiled.css +8 -2
- package/dist/es2019/components/tab-list.js +1 -1
- package/dist/es2019/components/tabs.js +1 -1
- package/dist/esm/components/tab-list.compiled.css +8 -2
- package/dist/esm/components/tab-list.js +1 -2
- package/dist/esm/components/tabs.js +1 -1
- package/dist/types/components/tab-panel.d.ts +2 -2
- package/dist/types-ts4.5/components/tab-panel.d.ts +2 -2
- package/package.json +2 -3
- package/codemods/13.0.0-lite-mode.tsx +0 -31
- package/codemods/__tests__/13.0.0-lite-mode.tsx +0 -569
- package/codemods/__tests__/add-id-prop.tsx +0 -77
- package/codemods/__tests__/map-tabs-prop.tsx +0 -299
- package/codemods/__tests__/on-select-to-on-change.tsx +0 -541
- package/codemods/__tests__/remove-components-prop.tsx +0 -151
- package/codemods/__tests__/remove-is-selected-test-prop.tsx +0 -147
- package/codemods/__tests__/remove-tab-item-tab-content.tsx +0 -86
- package/codemods/__tests__/remove-types.tsx +0 -162
- package/codemods/__tests__/rename-is-content-persisted-to-should-unmount-tab-panel-on-change.tsx +0 -311
- package/codemods/migrations/add-id-prop.tsx +0 -51
- package/codemods/migrations/map-tabs-prop.tsx +0 -171
- package/codemods/migrations/on-select-to-on-change.tsx +0 -91
- package/codemods/migrations/remove-components-prop.tsx +0 -20
- package/codemods/migrations/remove-is-selected-test-prop.tsx +0 -17
- package/codemods/migrations/remove-tab-item-tab-content.tsx +0 -26
- package/codemods/migrations/remove-types.tsx +0 -45
- package/codemods/migrations/rename-is-content-persisted-to-should-unmount-tab-panel-on-change.tsx +0 -62
- package/codemods/utils.tsx +0 -39
|
@@ -1,541 +0,0 @@
|
|
|
1
|
-
import { createTransformer } from '@atlaskit/codemod-utils';
|
|
2
|
-
|
|
3
|
-
import { migrateOnSelectType } from '../migrations/on-select-to-on-change';
|
|
4
|
-
|
|
5
|
-
const transformer = createTransformer([migrateOnSelectType]);
|
|
6
|
-
|
|
7
|
-
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
8
|
-
|
|
9
|
-
describe('change onSelect to onChange', () => {
|
|
10
|
-
defineInlineTest(
|
|
11
|
-
{ default: transformer, parser: 'tsx' },
|
|
12
|
-
{},
|
|
13
|
-
`
|
|
14
|
-
import React, { useState } from 'react';
|
|
15
|
-
import Tabs from '@atlaskit/tabs';
|
|
16
|
-
import { TabData } from '@atlaskit/tabs/types';
|
|
17
|
-
|
|
18
|
-
const tabs: Array<TabData> = [
|
|
19
|
-
{ label: 'Tab 1', content: One, testId: 'one' },
|
|
20
|
-
{ label: 'Tab 2', content: Two },
|
|
21
|
-
{ label: 'Tab 3', content: Three },
|
|
22
|
-
{ label: 'Tab 4', content: Four },
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
export default function defaultTabs() {
|
|
26
|
-
const [selected, setSelected] = useState(0);
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<Tabs
|
|
30
|
-
onSelect={(selected, selectedIndex, analyticsEvent) => setSelected(selectedIndex)}
|
|
31
|
-
selected={selected}
|
|
32
|
-
tabs={tabs}
|
|
33
|
-
/>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
`,
|
|
37
|
-
`
|
|
38
|
-
/* TODO: (from codemod)
|
|
39
|
-
This file uses onSelect and this prop has been changed names to onChange.
|
|
40
|
-
|
|
41
|
-
The type of onChange has also changed from
|
|
42
|
-
(selected: TabData, selectedIndex: number, analyticsEvent: UIAnalyticsEvent) => void;
|
|
43
|
-
to
|
|
44
|
-
(index: number, analyticsEvent: UIAnalyticsEvent) => void;
|
|
45
|
-
|
|
46
|
-
The logic around selecting tabs has changed internally and there is no longer the concept of TabData.
|
|
47
|
-
Tabs is now composable and the tabs prop has been removed.
|
|
48
|
-
|
|
49
|
-
The codemod has changed your usage of onSelect to be one of onChange. We are using the tabs
|
|
50
|
-
array and the selected index to pass the "selected tab" to your old onSelect function. This is
|
|
51
|
-
functional but you may like to update your usage of tabs to fit with the new API.
|
|
52
|
-
|
|
53
|
-
If you are using the selected prop you will need to ensure that you are passing in the index
|
|
54
|
-
of the selected tab as it also doesn't accept TabData anymore. */
|
|
55
|
-
import React, { useState } from 'react';
|
|
56
|
-
import Tabs from '@atlaskit/tabs';
|
|
57
|
-
import { TabData } from '@atlaskit/tabs/types';
|
|
58
|
-
|
|
59
|
-
const tabs: Array<TabData> = [
|
|
60
|
-
{ label: 'Tab 1', content: One, testId: 'one' },
|
|
61
|
-
{ label: 'Tab 2', content: Two },
|
|
62
|
-
{ label: 'Tab 3', content: Three },
|
|
63
|
-
{ label: 'Tab 4', content: Four },
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
export default function defaultTabs() {
|
|
67
|
-
const [selected, setSelected] = useState(0);
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<Tabs
|
|
71
|
-
onChange={(index, analyticsEvent) => {
|
|
72
|
-
const selectedTab = tabs[index];
|
|
73
|
-
((selected, selectedIndex, analyticsEvent) => setSelected(selectedIndex))(selectedTab, index, analyticsEvent);
|
|
74
|
-
}}
|
|
75
|
-
selected={selected}
|
|
76
|
-
tabs={tabs}
|
|
77
|
-
/>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
`,
|
|
81
|
-
'should change inline usage of onSelect to IIFE onChange and find the relevant tab data',
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
defineInlineTest(
|
|
85
|
-
{ default: transformer, parser: 'tsx' },
|
|
86
|
-
{},
|
|
87
|
-
`
|
|
88
|
-
import React, { useState } from 'react';
|
|
89
|
-
import Tabs from '@atlaskit/tabs';
|
|
90
|
-
|
|
91
|
-
export default function defaultTabs() {
|
|
92
|
-
const [selected, setSelected] = useState(0);
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<Tabs
|
|
96
|
-
onSelect={(selected, selectedIndex, analyticsEvent) => setSelected(selectedIndex)}
|
|
97
|
-
selected={selected}
|
|
98
|
-
tabs={[
|
|
99
|
-
{ label: 'Tab 1', content: One, testId: 'one' },
|
|
100
|
-
{ label: 'Tab 2', content: Two },
|
|
101
|
-
{ label: 'Tab 3', content: Three },
|
|
102
|
-
{ label: 'Tab 4', content: Four },
|
|
103
|
-
]}
|
|
104
|
-
/>
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
`,
|
|
108
|
-
`
|
|
109
|
-
/* TODO: (from codemod)
|
|
110
|
-
This file uses onSelect and this prop has been changed names to onChange.
|
|
111
|
-
|
|
112
|
-
The type of onChange has also changed from
|
|
113
|
-
(selected: TabData, selectedIndex: number, analyticsEvent: UIAnalyticsEvent) => void;
|
|
114
|
-
to
|
|
115
|
-
(index: number, analyticsEvent: UIAnalyticsEvent) => void;
|
|
116
|
-
|
|
117
|
-
The logic around selecting tabs has changed internally and there is no longer the concept of TabData.
|
|
118
|
-
Tabs is now composable and the tabs prop has been removed.
|
|
119
|
-
|
|
120
|
-
The codemod has changed your usage of onSelect to be one of onChange. We are using the tabs
|
|
121
|
-
array and the selected index to pass the "selected tab" to your old onSelect function. This is
|
|
122
|
-
functional but you may like to update your usage of tabs to fit with the new API.
|
|
123
|
-
|
|
124
|
-
If you are using the selected prop you will need to ensure that you are passing in the index
|
|
125
|
-
of the selected tab as it also doesn't accept TabData anymore. */
|
|
126
|
-
import React, { useState } from 'react';
|
|
127
|
-
import Tabs from '@atlaskit/tabs';
|
|
128
|
-
|
|
129
|
-
export default function defaultTabs() {
|
|
130
|
-
const [selected, setSelected] = useState(0);
|
|
131
|
-
|
|
132
|
-
return (
|
|
133
|
-
<Tabs
|
|
134
|
-
onChange={(index, analyticsEvent) => {
|
|
135
|
-
const selectedTab = [
|
|
136
|
-
{ label: 'Tab 1', content: One, testId: 'one' },
|
|
137
|
-
{ label: 'Tab 2', content: Two },
|
|
138
|
-
{ label: 'Tab 3', content: Three },
|
|
139
|
-
{ label: 'Tab 4', content: Four },
|
|
140
|
-
][index];
|
|
141
|
-
|
|
142
|
-
((selected, selectedIndex, analyticsEvent) => setSelected(selectedIndex))(selectedTab, index, analyticsEvent);
|
|
143
|
-
}}
|
|
144
|
-
selected={selected}
|
|
145
|
-
tabs={[
|
|
146
|
-
{ label: 'Tab 1', content: One, testId: 'one' },
|
|
147
|
-
{ label: 'Tab 2', content: Two },
|
|
148
|
-
{ label: 'Tab 3', content: Three },
|
|
149
|
-
{ label: 'Tab 4', content: Four },
|
|
150
|
-
]}
|
|
151
|
-
/>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
`,
|
|
155
|
-
'should change inline usage of onSelect to IIFE onChange and find the relevant tab data if tabs is defined inline',
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
defineInlineTest(
|
|
159
|
-
{ default: transformer, parser: 'tsx' },
|
|
160
|
-
{},
|
|
161
|
-
`
|
|
162
|
-
import React, { useState } from 'react';
|
|
163
|
-
|
|
164
|
-
import Tabs from '@atlaskit/tabs';
|
|
165
|
-
import { TabData } from '@atlaskit/tabs/types';
|
|
166
|
-
|
|
167
|
-
const tabs: Array<TabData> = [
|
|
168
|
-
{ label: 'Tab 1', content: One, testId: 'one' },
|
|
169
|
-
{ label: 'Tab 2', content: Two },
|
|
170
|
-
{ label: 'Tab 3', content: Three },
|
|
171
|
-
{ label: 'Tab 4', content: Four },
|
|
172
|
-
];
|
|
173
|
-
|
|
174
|
-
export default function defaultTabs() {
|
|
175
|
-
const [selected, setSelected] = useState(0);
|
|
176
|
-
|
|
177
|
-
const onSelect = (selected, selectedIndex) => setSelected(selectedIndex);
|
|
178
|
-
|
|
179
|
-
return (
|
|
180
|
-
<Tabs
|
|
181
|
-
onSelect={onSelect}
|
|
182
|
-
selected={selected}
|
|
183
|
-
tabs={tabs}
|
|
184
|
-
/>
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
`,
|
|
188
|
-
`
|
|
189
|
-
/* TODO: (from codemod)
|
|
190
|
-
This file uses onSelect and this prop has been changed names to onChange.
|
|
191
|
-
|
|
192
|
-
The type of onChange has also changed from
|
|
193
|
-
(selected: TabData, selectedIndex: number, analyticsEvent: UIAnalyticsEvent) => void;
|
|
194
|
-
to
|
|
195
|
-
(index: number, analyticsEvent: UIAnalyticsEvent) => void;
|
|
196
|
-
|
|
197
|
-
The logic around selecting tabs has changed internally and there is no longer the concept of TabData.
|
|
198
|
-
Tabs is now composable and the tabs prop has been removed.
|
|
199
|
-
|
|
200
|
-
The codemod has changed your usage of onSelect to be one of onChange. We are using the tabs
|
|
201
|
-
array and the selected index to pass the "selected tab" to your old onSelect function. This is
|
|
202
|
-
functional but you may like to update your usage of tabs to fit with the new API.
|
|
203
|
-
|
|
204
|
-
If you are using the selected prop you will need to ensure that you are passing in the index
|
|
205
|
-
of the selected tab as it also doesn't accept TabData anymore. */
|
|
206
|
-
import React, { useState } from 'react';
|
|
207
|
-
|
|
208
|
-
import Tabs from '@atlaskit/tabs';
|
|
209
|
-
import { TabData } from '@atlaskit/tabs/types';
|
|
210
|
-
|
|
211
|
-
const tabs: Array<TabData> = [
|
|
212
|
-
{ label: 'Tab 1', content: One, testId: 'one' },
|
|
213
|
-
{ label: 'Tab 2', content: Two },
|
|
214
|
-
{ label: 'Tab 3', content: Three },
|
|
215
|
-
{ label: 'Tab 4', content: Four },
|
|
216
|
-
];
|
|
217
|
-
|
|
218
|
-
export default function defaultTabs() {
|
|
219
|
-
const [selected, setSelected] = useState(0);
|
|
220
|
-
|
|
221
|
-
const onSelect = (selected, selectedIndex) => setSelected(selectedIndex);
|
|
222
|
-
|
|
223
|
-
return (
|
|
224
|
-
<Tabs
|
|
225
|
-
onChange={(index, analyticsEvent) => {
|
|
226
|
-
const selectedTab = tabs[index];
|
|
227
|
-
onSelect(selectedTab, index, analyticsEvent);
|
|
228
|
-
}}
|
|
229
|
-
selected={selected}
|
|
230
|
-
tabs={tabs}
|
|
231
|
-
/>
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
`,
|
|
235
|
-
'should change usage of onSelect to onChange with the relevant tab data',
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
defineInlineTest(
|
|
239
|
-
{ default: transformer, parser: 'tsx' },
|
|
240
|
-
{},
|
|
241
|
-
`
|
|
242
|
-
import React, { useState } from 'react';
|
|
243
|
-
|
|
244
|
-
import Tabs from '@atlaskit/tabs';
|
|
245
|
-
|
|
246
|
-
export default function defaultTabs() {
|
|
247
|
-
const [selected, setSelected] = useState(0);
|
|
248
|
-
|
|
249
|
-
const onSelect = (selected, selectedIndex) => setSelected(selectedIndex);
|
|
250
|
-
|
|
251
|
-
return (
|
|
252
|
-
<Tabs
|
|
253
|
-
onSelect={onSelect}
|
|
254
|
-
selected={selected}
|
|
255
|
-
tabs={[
|
|
256
|
-
{ label: 'Tab 1', content: One, testId: 'one' },
|
|
257
|
-
{ label: 'Tab 2', content: Two },
|
|
258
|
-
{ label: 'Tab 3', content: Three },
|
|
259
|
-
{ label: 'Tab 4', content: Four },
|
|
260
|
-
]}
|
|
261
|
-
/>
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
`,
|
|
265
|
-
`
|
|
266
|
-
/* TODO: (from codemod)
|
|
267
|
-
This file uses onSelect and this prop has been changed names to onChange.
|
|
268
|
-
|
|
269
|
-
The type of onChange has also changed from
|
|
270
|
-
(selected: TabData, selectedIndex: number, analyticsEvent: UIAnalyticsEvent) => void;
|
|
271
|
-
to
|
|
272
|
-
(index: number, analyticsEvent: UIAnalyticsEvent) => void;
|
|
273
|
-
|
|
274
|
-
The logic around selecting tabs has changed internally and there is no longer the concept of TabData.
|
|
275
|
-
Tabs is now composable and the tabs prop has been removed.
|
|
276
|
-
|
|
277
|
-
The codemod has changed your usage of onSelect to be one of onChange. We are using the tabs
|
|
278
|
-
array and the selected index to pass the "selected tab" to your old onSelect function. This is
|
|
279
|
-
functional but you may like to update your usage of tabs to fit with the new API.
|
|
280
|
-
|
|
281
|
-
If you are using the selected prop you will need to ensure that you are passing in the index
|
|
282
|
-
of the selected tab as it also doesn't accept TabData anymore. */
|
|
283
|
-
import React, { useState } from 'react';
|
|
284
|
-
|
|
285
|
-
import Tabs from '@atlaskit/tabs';
|
|
286
|
-
|
|
287
|
-
export default function defaultTabs() {
|
|
288
|
-
const [selected, setSelected] = useState(0);
|
|
289
|
-
|
|
290
|
-
const onSelect = (selected, selectedIndex) => setSelected(selectedIndex);
|
|
291
|
-
|
|
292
|
-
return (
|
|
293
|
-
<Tabs
|
|
294
|
-
onChange={(index, analyticsEvent) => {
|
|
295
|
-
const selectedTab = [
|
|
296
|
-
{ label: 'Tab 1', content: One, testId: 'one' },
|
|
297
|
-
{ label: 'Tab 2', content: Two },
|
|
298
|
-
{ label: 'Tab 3', content: Three },
|
|
299
|
-
{ label: 'Tab 4', content: Four },
|
|
300
|
-
][index];
|
|
301
|
-
|
|
302
|
-
onSelect(selectedTab, index, analyticsEvent);
|
|
303
|
-
}}
|
|
304
|
-
selected={selected}
|
|
305
|
-
tabs={[
|
|
306
|
-
{ label: 'Tab 1', content: One, testId: 'one' },
|
|
307
|
-
{ label: 'Tab 2', content: Two },
|
|
308
|
-
{ label: 'Tab 3', content: Three },
|
|
309
|
-
{ label: 'Tab 4', content: Four },
|
|
310
|
-
]}
|
|
311
|
-
/>
|
|
312
|
-
);
|
|
313
|
-
}
|
|
314
|
-
`,
|
|
315
|
-
'should change usage of onSelect to onChange with the relevant tab data if tabs is defined inline',
|
|
316
|
-
);
|
|
317
|
-
defineInlineTest(
|
|
318
|
-
{ default: transformer, parser: 'tsx' },
|
|
319
|
-
{},
|
|
320
|
-
`
|
|
321
|
-
import React, { useState } from 'react';
|
|
322
|
-
|
|
323
|
-
import Tabs from '@atlaskit/tabs';
|
|
324
|
-
|
|
325
|
-
const getTabs = () => (
|
|
326
|
-
[
|
|
327
|
-
{ label: 'Tab 1', content: One, testId: 'one' },
|
|
328
|
-
{ label: 'Tab 2', content: Two },
|
|
329
|
-
{ label: 'Tab 3', content: Three },
|
|
330
|
-
{ label: 'Tab 4', content: Four },
|
|
331
|
-
]
|
|
332
|
-
);
|
|
333
|
-
|
|
334
|
-
export default function defaultTabs() {
|
|
335
|
-
const [selected, setSelected] = useState(0);
|
|
336
|
-
|
|
337
|
-
const onSelect = (selected, selectedIndex) => setSelected(selectedIndex);
|
|
338
|
-
|
|
339
|
-
return (
|
|
340
|
-
<Tabs
|
|
341
|
-
onSelect={onSelect}
|
|
342
|
-
selected={selected}
|
|
343
|
-
tabs={getTabs()}
|
|
344
|
-
/>
|
|
345
|
-
);
|
|
346
|
-
}
|
|
347
|
-
`,
|
|
348
|
-
`
|
|
349
|
-
/* TODO: (from codemod)
|
|
350
|
-
This file uses onSelect and this prop has been changed names to onChange.
|
|
351
|
-
|
|
352
|
-
The type of onChange has also changed from
|
|
353
|
-
(selected: TabData, selectedIndex: number, analyticsEvent: UIAnalyticsEvent) => void;
|
|
354
|
-
to
|
|
355
|
-
(index: number, analyticsEvent: UIAnalyticsEvent) => void;
|
|
356
|
-
|
|
357
|
-
The logic around selecting tabs has changed internally and there is no longer the concept of TabData.
|
|
358
|
-
Tabs is now composable and the tabs prop has been removed.
|
|
359
|
-
|
|
360
|
-
The codemod has changed your usage of onSelect to be one of onChange. We are using the tabs
|
|
361
|
-
array and the selected index to pass the "selected tab" to your old onSelect function. This is
|
|
362
|
-
functional but you may like to update your usage of tabs to fit with the new API.
|
|
363
|
-
|
|
364
|
-
If you are using the selected prop you will need to ensure that you are passing in the index
|
|
365
|
-
of the selected tab as it also doesn't accept TabData anymore. */
|
|
366
|
-
import React, { useState } from 'react';
|
|
367
|
-
|
|
368
|
-
import Tabs from '@atlaskit/tabs';
|
|
369
|
-
|
|
370
|
-
const getTabs = () => (
|
|
371
|
-
[
|
|
372
|
-
{ label: 'Tab 1', content: One, testId: 'one' },
|
|
373
|
-
{ label: 'Tab 2', content: Two },
|
|
374
|
-
{ label: 'Tab 3', content: Three },
|
|
375
|
-
{ label: 'Tab 4', content: Four },
|
|
376
|
-
]
|
|
377
|
-
);
|
|
378
|
-
|
|
379
|
-
export default function defaultTabs() {
|
|
380
|
-
const [selected, setSelected] = useState(0);
|
|
381
|
-
|
|
382
|
-
const onSelect = (selected, selectedIndex) => setSelected(selectedIndex);
|
|
383
|
-
|
|
384
|
-
return (
|
|
385
|
-
<Tabs
|
|
386
|
-
onChange={(index, analyticsEvent) => {
|
|
387
|
-
const selectedTab = getTabs()[index];
|
|
388
|
-
onSelect(selectedTab, index, analyticsEvent);
|
|
389
|
-
}}
|
|
390
|
-
selected={selected}
|
|
391
|
-
tabs={getTabs()}
|
|
392
|
-
/>
|
|
393
|
-
);
|
|
394
|
-
}
|
|
395
|
-
`,
|
|
396
|
-
'should change usage of onSelect to onChange with the relevant tab data if tabs is a function',
|
|
397
|
-
);
|
|
398
|
-
defineInlineTest(
|
|
399
|
-
{ default: transformer, parser: 'tsx' },
|
|
400
|
-
{},
|
|
401
|
-
`
|
|
402
|
-
import React, { useState } from 'react';
|
|
403
|
-
|
|
404
|
-
import Tabs from '@atlaskit/tabs';
|
|
405
|
-
|
|
406
|
-
export default function defaultTabs(props) {
|
|
407
|
-
const [selected, setSelected] = useState(0);
|
|
408
|
-
|
|
409
|
-
const onSelect = (selected, selectedIndex) => setSelected(selectedIndex);
|
|
410
|
-
|
|
411
|
-
return (
|
|
412
|
-
<Tabs
|
|
413
|
-
onSelect={onSelect}
|
|
414
|
-
selected={selected}
|
|
415
|
-
{...props}
|
|
416
|
-
/>
|
|
417
|
-
);
|
|
418
|
-
}
|
|
419
|
-
`,
|
|
420
|
-
`
|
|
421
|
-
/* TODO: (from codemod)
|
|
422
|
-
This file uses onSelect and this prop has been changed names to onChange.
|
|
423
|
-
|
|
424
|
-
The type of onChange has also changed from
|
|
425
|
-
(selected: TabData, selectedIndex: number, analyticsEvent: UIAnalyticsEvent) => void;
|
|
426
|
-
to
|
|
427
|
-
(index: number, analyticsEvent: UIAnalyticsEvent) => void;
|
|
428
|
-
|
|
429
|
-
The logic around selecting tabs has changed internally and there is no longer the concept of TabData.
|
|
430
|
-
Tabs is now composable and the tabs prop has been removed.
|
|
431
|
-
|
|
432
|
-
The codemod has changed your usage of onSelect to be one of onChange. We are using the tabs
|
|
433
|
-
array and the selected index to pass the "selected tab" to your old onSelect function. This is
|
|
434
|
-
functional but you may like to update your usage of tabs to fit with the new API.
|
|
435
|
-
|
|
436
|
-
If you are using the selected prop you will need to ensure that you are passing in the index
|
|
437
|
-
of the selected tab as it also doesn't accept TabData anymore. */
|
|
438
|
-
import React, { useState } from 'react';
|
|
439
|
-
|
|
440
|
-
import Tabs from '@atlaskit/tabs';
|
|
441
|
-
|
|
442
|
-
export default function defaultTabs(props) {
|
|
443
|
-
const [selected, setSelected] = useState(0);
|
|
444
|
-
|
|
445
|
-
const onSelect = (selected, selectedIndex) => setSelected(selectedIndex);
|
|
446
|
-
|
|
447
|
-
return (
|
|
448
|
-
<Tabs
|
|
449
|
-
onChange={(index, analyticsEvent) => {
|
|
450
|
-
const selectedTab = props.tabs[index];
|
|
451
|
-
onSelect(selectedTab, index, analyticsEvent);
|
|
452
|
-
}}
|
|
453
|
-
selected={selected}
|
|
454
|
-
{...props}
|
|
455
|
-
/>
|
|
456
|
-
);
|
|
457
|
-
}
|
|
458
|
-
`,
|
|
459
|
-
'should change usage of onSelect to onChange if the tabs prop is spread',
|
|
460
|
-
);
|
|
461
|
-
|
|
462
|
-
defineInlineTest(
|
|
463
|
-
{ default: transformer, parser: 'tsx' },
|
|
464
|
-
{},
|
|
465
|
-
`
|
|
466
|
-
import React, { useState } from 'react';
|
|
467
|
-
|
|
468
|
-
import Tabs from '@atlaskit/tabs';
|
|
469
|
-
|
|
470
|
-
export default function defaultTabs() {
|
|
471
|
-
const [selected, setSelected] = useState(0);
|
|
472
|
-
|
|
473
|
-
const onSelect = (selected, selectedIndex) => setSelected(selectedIndex);
|
|
474
|
-
|
|
475
|
-
return (
|
|
476
|
-
<Tabs
|
|
477
|
-
selected={selected}
|
|
478
|
-
tabs={[
|
|
479
|
-
{ label: 'Tab 1', content: One, testId: 'one' },
|
|
480
|
-
{ label: 'Tab 2', content: <CustomElement onChange={() => {console.log('big change')}} /> },
|
|
481
|
-
{ label: 'Tab 3', content: Three },
|
|
482
|
-
{ label: 'Tab 4', content: Four },
|
|
483
|
-
]}
|
|
484
|
-
onSelect={onSelect}
|
|
485
|
-
/>
|
|
486
|
-
);
|
|
487
|
-
}
|
|
488
|
-
`,
|
|
489
|
-
`
|
|
490
|
-
/* TODO: (from codemod)
|
|
491
|
-
This file uses onSelect and this prop has been changed names to onChange.
|
|
492
|
-
|
|
493
|
-
The type of onChange has also changed from
|
|
494
|
-
(selected: TabData, selectedIndex: number, analyticsEvent: UIAnalyticsEvent) => void;
|
|
495
|
-
to
|
|
496
|
-
(index: number, analyticsEvent: UIAnalyticsEvent) => void;
|
|
497
|
-
|
|
498
|
-
The logic around selecting tabs has changed internally and there is no longer the concept of TabData.
|
|
499
|
-
Tabs is now composable and the tabs prop has been removed.
|
|
500
|
-
|
|
501
|
-
The codemod has changed your usage of onSelect to be one of onChange. We are using the tabs
|
|
502
|
-
array and the selected index to pass the "selected tab" to your old onSelect function. This is
|
|
503
|
-
functional but you may like to update your usage of tabs to fit with the new API.
|
|
504
|
-
|
|
505
|
-
If you are using the selected prop you will need to ensure that you are passing in the index
|
|
506
|
-
of the selected tab as it also doesn't accept TabData anymore. */
|
|
507
|
-
import React, { useState } from 'react';
|
|
508
|
-
|
|
509
|
-
import Tabs from '@atlaskit/tabs';
|
|
510
|
-
|
|
511
|
-
export default function defaultTabs() {
|
|
512
|
-
const [selected, setSelected] = useState(0);
|
|
513
|
-
|
|
514
|
-
const onSelect = (selected, selectedIndex) => setSelected(selectedIndex);
|
|
515
|
-
|
|
516
|
-
return (
|
|
517
|
-
<Tabs
|
|
518
|
-
selected={selected}
|
|
519
|
-
tabs={[
|
|
520
|
-
{ label: 'Tab 1', content: One, testId: 'one' },
|
|
521
|
-
{ label: 'Tab 2', content: <CustomElement onChange={() => {console.log('big change')}} /> },
|
|
522
|
-
{ label: 'Tab 3', content: Three },
|
|
523
|
-
{ label: 'Tab 4', content: Four },
|
|
524
|
-
]}
|
|
525
|
-
onChange={(index, analyticsEvent) => {
|
|
526
|
-
const selectedTab = [
|
|
527
|
-
{ label: 'Tab 1', content: One, testId: 'one' },
|
|
528
|
-
{ label: 'Tab 2', content: <CustomElement onChange={() => {console.log('big change')}} /> },
|
|
529
|
-
{ label: 'Tab 3', content: Three },
|
|
530
|
-
{ label: 'Tab 4', content: Four },
|
|
531
|
-
][index];
|
|
532
|
-
|
|
533
|
-
onSelect(selectedTab, index, analyticsEvent);
|
|
534
|
-
}}
|
|
535
|
-
/>
|
|
536
|
-
);
|
|
537
|
-
}
|
|
538
|
-
`,
|
|
539
|
-
'should change usage of onSelect to onChange with the relevant tab data if onChange is defined in tabs children',
|
|
540
|
-
);
|
|
541
|
-
});
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { createTransformer } from '@atlaskit/codemod-utils';
|
|
2
|
-
|
|
3
|
-
import { removeComponentsProp } from '../migrations/remove-components-prop';
|
|
4
|
-
|
|
5
|
-
const transformer = createTransformer([removeComponentsProp]);
|
|
6
|
-
|
|
7
|
-
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
8
|
-
|
|
9
|
-
describe('remove components prop', () => {
|
|
10
|
-
defineInlineTest(
|
|
11
|
-
{ default: transformer, parser: 'tsx' },
|
|
12
|
-
{},
|
|
13
|
-
`
|
|
14
|
-
import React from 'react';
|
|
15
|
-
|
|
16
|
-
import Tabs, { Tab, TabList, TabPanel } from '@atlaskit/tabs';
|
|
17
|
-
import { customComponents } from './custom';
|
|
18
|
-
|
|
19
|
-
export default function defaultTabs() {
|
|
20
|
-
return (
|
|
21
|
-
<Tabs
|
|
22
|
-
onChange={index => console.log('Selected Tab', index + 1)}
|
|
23
|
-
id="default"
|
|
24
|
-
testId="default"
|
|
25
|
-
components={customComponents}
|
|
26
|
-
>
|
|
27
|
-
<TabList>
|
|
28
|
-
<Tab>Tab 1</Tab>
|
|
29
|
-
<Tab>Tab 2</Tab>
|
|
30
|
-
<Tab>Tab 3</Tab>
|
|
31
|
-
<Tab>Tab 4</Tab>
|
|
32
|
-
</TabList>
|
|
33
|
-
<TabPanel>One</TabPanel>
|
|
34
|
-
<TabPanel>Two</TabPanel>
|
|
35
|
-
<TabPanel>Three</TabPanel>
|
|
36
|
-
<TabPanel>Four</TabPanel>
|
|
37
|
-
</Tabs>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
`,
|
|
41
|
-
`
|
|
42
|
-
/* TODO: (from codemod)
|
|
43
|
-
We could not automatically convert this code to the new API.
|
|
44
|
-
|
|
45
|
-
This file uses \`Tabs\`’s \`component\` prop. This has been removed as part of moving to
|
|
46
|
-
a compositional API.
|
|
47
|
-
|
|
48
|
-
To create a custom tab (replacement for \`Item\` component) refer to the docs at
|
|
49
|
-
https://atlassian.design/components/tabs/examples#customizing-tab
|
|
50
|
-
|
|
51
|
-
To create a custom tab panel (replacement for \`Content\` component) refer to the docs at
|
|
52
|
-
https://atlassian.design/components/tabs/examples#customizing-tab-panel */
|
|
53
|
-
import React from 'react';
|
|
54
|
-
|
|
55
|
-
import Tabs, { Tab, TabList, TabPanel } from '@atlaskit/tabs';
|
|
56
|
-
import { customComponents } from './custom';
|
|
57
|
-
|
|
58
|
-
export default function defaultTabs() {
|
|
59
|
-
return (
|
|
60
|
-
<Tabs
|
|
61
|
-
onChange={index => console.log('Selected Tab', index + 1)}
|
|
62
|
-
id="default"
|
|
63
|
-
testId="default">
|
|
64
|
-
<TabList>
|
|
65
|
-
<Tab>Tab 1</Tab>
|
|
66
|
-
<Tab>Tab 2</Tab>
|
|
67
|
-
<Tab>Tab 3</Tab>
|
|
68
|
-
<Tab>Tab 4</Tab>
|
|
69
|
-
</TabList>
|
|
70
|
-
<TabPanel>One</TabPanel>
|
|
71
|
-
<TabPanel>Two</TabPanel>
|
|
72
|
-
<TabPanel>Three</TabPanel>
|
|
73
|
-
<TabPanel>Four</TabPanel>
|
|
74
|
-
</Tabs>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
`,
|
|
78
|
-
'should remove component prop if using variable',
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
defineInlineTest(
|
|
82
|
-
{ default: transformer, parser: 'tsx' },
|
|
83
|
-
{},
|
|
84
|
-
`
|
|
85
|
-
import React from 'react';
|
|
86
|
-
|
|
87
|
-
import Tabs, { Tab, TabList, TabPanel } from '@atlaskit/tabs';
|
|
88
|
-
import { TooltipItem, CustomContent } from './custom';
|
|
89
|
-
|
|
90
|
-
export default function defaultTabs() {
|
|
91
|
-
return (
|
|
92
|
-
<Tabs
|
|
93
|
-
onChange={index => console.log('Selected Tab', index + 1)}
|
|
94
|
-
id="default"
|
|
95
|
-
testId="default"
|
|
96
|
-
components={{ Item: TooltipItem, Content: CustomContent}}
|
|
97
|
-
>
|
|
98
|
-
<TabList>
|
|
99
|
-
<Tab>Tab 1</Tab>
|
|
100
|
-
<Tab>Tab 2</Tab>
|
|
101
|
-
<Tab>Tab 3</Tab>
|
|
102
|
-
<Tab>Tab 4</Tab>
|
|
103
|
-
</TabList>
|
|
104
|
-
<TabPanel>One</TabPanel>
|
|
105
|
-
<TabPanel>Two</TabPanel>
|
|
106
|
-
<TabPanel>Three</TabPanel>
|
|
107
|
-
<TabPanel>Four</TabPanel>
|
|
108
|
-
</Tabs>
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
`,
|
|
112
|
-
`
|
|
113
|
-
/* TODO: (from codemod)
|
|
114
|
-
We could not automatically convert this code to the new API.
|
|
115
|
-
|
|
116
|
-
This file uses \`Tabs\`’s \`component\` prop. This has been removed as part of moving to
|
|
117
|
-
a compositional API.
|
|
118
|
-
|
|
119
|
-
To create a custom tab (replacement for \`Item\` component) refer to the docs at
|
|
120
|
-
https://atlassian.design/components/tabs/examples#customizing-tab
|
|
121
|
-
|
|
122
|
-
To create a custom tab panel (replacement for \`Content\` component) refer to the docs at
|
|
123
|
-
https://atlassian.design/components/tabs/examples#customizing-tab-panel */
|
|
124
|
-
import React from 'react';
|
|
125
|
-
|
|
126
|
-
import Tabs, { Tab, TabList, TabPanel } from '@atlaskit/tabs';
|
|
127
|
-
import { TooltipItem, CustomContent } from './custom';
|
|
128
|
-
|
|
129
|
-
export default function defaultTabs() {
|
|
130
|
-
return (
|
|
131
|
-
<Tabs
|
|
132
|
-
onChange={index => console.log('Selected Tab', index + 1)}
|
|
133
|
-
id="default"
|
|
134
|
-
testId="default">
|
|
135
|
-
<TabList>
|
|
136
|
-
<Tab>Tab 1</Tab>
|
|
137
|
-
<Tab>Tab 2</Tab>
|
|
138
|
-
<Tab>Tab 3</Tab>
|
|
139
|
-
<Tab>Tab 4</Tab>
|
|
140
|
-
</TabList>
|
|
141
|
-
<TabPanel>One</TabPanel>
|
|
142
|
-
<TabPanel>Two</TabPanel>
|
|
143
|
-
<TabPanel>Three</TabPanel>
|
|
144
|
-
<TabPanel>Four</TabPanel>
|
|
145
|
-
</Tabs>
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
`,
|
|
149
|
-
'should remove component prop if using an object',
|
|
150
|
-
);
|
|
151
|
-
});
|