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