@atlaskit/modal-dialog 12.0.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 +2111 -0
- package/LICENSE +13 -0
- package/README.md +13 -0
- package/__perf__/default.tsx +42 -0
- package/__perf__/interactions.tsx +136 -0
- package/__perf__/scroll.tsx +98 -0
- package/codemods/12.0.0-lite-mode.ts +51 -0
- package/codemods/__tests__/12.0.0-lite-mode.test.ts +493 -0
- package/codemods/__tests__/handle-prop-spread.tsx +276 -0
- package/codemods/__tests__/inline-WidthNames-declaration.test.ts +260 -0
- package/codemods/__tests__/map-actions-prop.tsx +436 -0
- package/codemods/__tests__/map-body-from-props.test.ts +645 -0
- package/codemods/__tests__/map-container-from-props.test.ts +323 -0
- package/codemods/__tests__/map-footer-from-props.test.ts +544 -0
- package/codemods/__tests__/map-header-from-props.test.ts +559 -0
- package/codemods/__tests__/map-heading-prop.tsx +438 -0
- package/codemods/__tests__/remove-appearance-prop.test.ts +79 -0
- package/codemods/__tests__/remove-component-override-props.test.ts +153 -0
- package/codemods/__tests__/remove-is-chromeless.tsx +182 -0
- package/codemods/__tests__/rename-appearance-type.test.ts +52 -0
- package/codemods/__tests__/rename-inner-component-prop-types.test.ts +82 -0
- package/codemods/__tests__/rename-scrollBehavior-to-shouldScrollInViewport.test.ts +237 -0
- package/codemods/internal/constants.tsx +41 -0
- package/codemods/internal/utils.tsx +223 -0
- package/codemods/migrations/handle-prop-spread.tsx +51 -0
- package/codemods/migrations/inline-WidthNames-declaration.ts +92 -0
- package/codemods/migrations/map-actions-prop.tsx +430 -0
- package/codemods/migrations/map-body-from-props.ts +147 -0
- package/codemods/migrations/map-container-from-props.ts +72 -0
- package/codemods/migrations/map-footer-from-props.ts +107 -0
- package/codemods/migrations/map-header-from-props.ts +101 -0
- package/codemods/migrations/map-heading-prop.tsx +193 -0
- package/codemods/migrations/remove-appearance-prop.ts +27 -0
- package/codemods/migrations/remove-component-override-props.ts +84 -0
- package/codemods/migrations/remove-is-chromeless.tsx +42 -0
- package/codemods/migrations/rename-appearance-type.ts +9 -0
- package/codemods/migrations/rename-inner-component-prop-types.ts +28 -0
- package/codemods/migrations/rename-scrollBehavior-to-shouldScrollInViewport.ts +82 -0
- package/dist/cjs/hooks.js +22 -0
- package/dist/cjs/index.js +63 -0
- package/dist/cjs/internal/components/modal-dialog.js +155 -0
- package/dist/cjs/internal/components/positioner.js +89 -0
- package/dist/cjs/internal/components/scroll-container.js +138 -0
- package/dist/cjs/internal/constants.js +48 -0
- package/dist/cjs/internal/context.js +13 -0
- package/dist/cjs/internal/hooks/use-modal-stack.js +110 -0
- package/dist/cjs/internal/hooks/use-on-motion-finish.js +24 -0
- package/dist/cjs/internal/hooks/use-prevent-programmatic-scroll.js +55 -0
- package/dist/cjs/internal/hooks/use-scroll.js +20 -0
- package/dist/cjs/internal/utils.js +35 -0
- package/dist/cjs/modal-body.js +66 -0
- package/dist/cjs/modal-footer.js +40 -0
- package/dist/cjs/modal-header.js +43 -0
- package/dist/cjs/modal-title.js +108 -0
- package/dist/cjs/modal-transition.js +21 -0
- package/dist/cjs/modal-wrapper.js +126 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/hooks.js +11 -0
- package/dist/es2019/index.js +7 -0
- package/dist/es2019/internal/components/modal-dialog.js +120 -0
- package/dist/es2019/internal/components/positioner.js +78 -0
- package/dist/es2019/internal/components/scroll-container.js +97 -0
- package/dist/es2019/internal/constants.js +27 -0
- package/dist/es2019/internal/context.js +3 -0
- package/dist/es2019/internal/hooks/use-modal-stack.js +85 -0
- package/dist/es2019/internal/hooks/use-on-motion-finish.js +17 -0
- package/dist/es2019/internal/hooks/use-prevent-programmatic-scroll.js +39 -0
- package/dist/es2019/internal/hooks/use-scroll.js +11 -0
- package/dist/es2019/internal/utils.js +22 -0
- package/dist/es2019/modal-body.js +50 -0
- package/dist/es2019/modal-footer.js +30 -0
- package/dist/es2019/modal-header.js +30 -0
- package/dist/es2019/modal-title.js +94 -0
- package/dist/es2019/modal-transition.js +10 -0
- package/dist/es2019/modal-wrapper.js +88 -0
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/hooks.js +11 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/internal/components/modal-dialog.js +131 -0
- package/dist/esm/internal/components/positioner.js +76 -0
- package/dist/esm/internal/components/scroll-container.js +114 -0
- package/dist/esm/internal/constants.js +27 -0
- package/dist/esm/internal/context.js +3 -0
- package/dist/esm/internal/hooks/use-modal-stack.js +96 -0
- package/dist/esm/internal/hooks/use-on-motion-finish.js +16 -0
- package/dist/esm/internal/hooks/use-prevent-programmatic-scroll.js +44 -0
- package/dist/esm/internal/hooks/use-scroll.js +11 -0
- package/dist/esm/internal/utils.js +22 -0
- package/dist/esm/modal-body.js +49 -0
- package/dist/esm/modal-footer.js +29 -0
- package/dist/esm/modal-header.js +29 -0
- package/dist/esm/modal-title.js +93 -0
- package/dist/esm/modal-transition.js +10 -0
- package/dist/esm/modal-wrapper.js +96 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/hooks.d.ts +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/internal/components/modal-dialog.d.ts +3 -0
- package/dist/types/internal/components/positioner.d.ts +10 -0
- package/dist/types/internal/components/scroll-container.d.ts +20 -0
- package/dist/types/internal/constants.d.ts +25 -0
- package/dist/types/internal/context.d.ts +20 -0
- package/dist/types/internal/hooks/use-modal-stack.d.ts +13 -0
- package/dist/types/internal/hooks/use-on-motion-finish.d.ts +4 -0
- package/dist/types/internal/hooks/use-prevent-programmatic-scroll.d.ts +7 -0
- package/dist/types/internal/hooks/use-scroll.d.ts +1 -0
- package/dist/types/internal/utils.d.ts +3 -0
- package/dist/types/modal-body.d.ts +16 -0
- package/dist/types/modal-footer.d.ts +16 -0
- package/dist/types/modal-header.d.ts +16 -0
- package/dist/types/modal-title.d.ts +26 -0
- package/dist/types/modal-transition.d.ts +3 -0
- package/dist/types/modal-wrapper.d.ts +5 -0
- package/dist/types/types.d.ts +90 -0
- package/extract-react-types/modal-attributes.tsx +5 -0
- package/hooks/package.json +7 -0
- package/modal-body/package.json +7 -0
- package/modal-dialog/package.json +7 -0
- package/modal-footer/package.json +7 -0
- package/modal-header/package.json +7 -0
- package/modal-title/package.json +7 -0
- package/modal-transition/package.json +7 -0
- package/package.json +113 -0
- package/types/package.json +7 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { createTransformer } from '@atlaskit/codemod-utils';
|
|
2
|
+
|
|
3
|
+
import { removeComponentOverrideProps } from '../migrations/remove-component-override-props';
|
|
4
|
+
|
|
5
|
+
const transformer = createTransformer([removeComponentOverrideProps]);
|
|
6
|
+
|
|
7
|
+
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
8
|
+
|
|
9
|
+
describe('remove component override props', () => {
|
|
10
|
+
['tsx', 'babylon'].forEach((parser) => {
|
|
11
|
+
describe(`parser: ${parser}`, () => {
|
|
12
|
+
defineInlineTest(
|
|
13
|
+
{ default: transformer, parser },
|
|
14
|
+
{},
|
|
15
|
+
`
|
|
16
|
+
import React from 'react';
|
|
17
|
+
|
|
18
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
19
|
+
|
|
20
|
+
export default function modalDialog() {
|
|
21
|
+
return (
|
|
22
|
+
<ModalDialog
|
|
23
|
+
onClose={handleClose}
|
|
24
|
+
components={{}}
|
|
25
|
+
>
|
|
26
|
+
{content}
|
|
27
|
+
</ModalDialog>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
`,
|
|
31
|
+
`/* TODO: (from codemod)\u0020
|
|
32
|
+
We have converted this file as best we could but you might still need
|
|
33
|
+
to manually complete migrating this usage of ModalDialog.
|
|
34
|
+
|
|
35
|
+
This file uses one or more of the following ModalDialog props: 'components', 'header',
|
|
36
|
+
'footer', 'body'. These props have been removed as part of moving to
|
|
37
|
+
a compositional API.
|
|
38
|
+
|
|
39
|
+
The render props that used to be exposed by the custom component APIs are
|
|
40
|
+
now accessible using the 'useModal' hook instead: 'testId', 'titleId', and 'onClose'.
|
|
41
|
+
|
|
42
|
+
We are also no longer exposing 'appearance' as render prop, so this needs to be
|
|
43
|
+
manually passed to your custom components.
|
|
44
|
+
|
|
45
|
+
If you are using the 'container' value of 'components' to wrap ModalDialog in something
|
|
46
|
+
other than a 'form', you'll need to add the style 'all: inherit;' for scrolling to function.
|
|
47
|
+
|
|
48
|
+
For a complete guide on customization using the new compositional API, refer to the docs at
|
|
49
|
+
https://atlassian.design/components/modal-dialog/examples. */
|
|
50
|
+
import React from 'react';
|
|
51
|
+
|
|
52
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
53
|
+
|
|
54
|
+
export default function modalDialog() {
|
|
55
|
+
return (
|
|
56
|
+
<ModalDialog onClose={handleClose}>
|
|
57
|
+
{content}
|
|
58
|
+
</ModalDialog>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
`,
|
|
62
|
+
'should remove components prop and add explanation in comment',
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
defineInlineTest(
|
|
66
|
+
{ default: transformer, parser },
|
|
67
|
+
{},
|
|
68
|
+
`
|
|
69
|
+
import React from 'react';
|
|
70
|
+
|
|
71
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
72
|
+
|
|
73
|
+
export default function modalDialog() {
|
|
74
|
+
return (
|
|
75
|
+
<ModalDialog
|
|
76
|
+
onClose={handleClose}
|
|
77
|
+
header={header}
|
|
78
|
+
footer={footer}
|
|
79
|
+
body={body}
|
|
80
|
+
>
|
|
81
|
+
{content}
|
|
82
|
+
</ModalDialog>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
`,
|
|
86
|
+
`/* TODO: (from codemod)\u0020
|
|
87
|
+
We have converted this file as best we could but you might still need
|
|
88
|
+
to manually complete migrating this usage of ModalDialog.
|
|
89
|
+
|
|
90
|
+
This file uses one or more of the following ModalDialog props: 'components', 'header',
|
|
91
|
+
'footer', 'body'. These props have been removed as part of moving to
|
|
92
|
+
a compositional API.
|
|
93
|
+
|
|
94
|
+
The render props that used to be exposed by the custom component APIs are
|
|
95
|
+
now accessible using the 'useModal' hook instead: 'testId', 'titleId', and 'onClose'.
|
|
96
|
+
|
|
97
|
+
We are also no longer exposing 'appearance' as render prop, so this needs to be
|
|
98
|
+
manually passed to your custom components.
|
|
99
|
+
|
|
100
|
+
If you are using the 'container' value of 'components' to wrap ModalDialog in something
|
|
101
|
+
other than a 'form', you'll need to add the style 'all: inherit;' for scrolling to function.
|
|
102
|
+
|
|
103
|
+
For a complete guide on customization using the new compositional API, refer to the docs at
|
|
104
|
+
https://atlassian.design/components/modal-dialog/examples. */
|
|
105
|
+
import React from 'react';
|
|
106
|
+
|
|
107
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
108
|
+
|
|
109
|
+
export default function modalDialog() {
|
|
110
|
+
return (
|
|
111
|
+
<ModalDialog onClose={handleClose}>
|
|
112
|
+
{content}
|
|
113
|
+
</ModalDialog>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
`,
|
|
117
|
+
'should remove header/footer/body props and add explanation in comment',
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
defineInlineTest(
|
|
121
|
+
{ default: transformer, parser },
|
|
122
|
+
{},
|
|
123
|
+
`
|
|
124
|
+
import React from 'react';
|
|
125
|
+
|
|
126
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
127
|
+
|
|
128
|
+
export default function modalDialog() {
|
|
129
|
+
return (
|
|
130
|
+
<ModalDialog onClose={handleClose}>
|
|
131
|
+
{content}
|
|
132
|
+
</ModalDialog>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
`,
|
|
136
|
+
`
|
|
137
|
+
import React from 'react';
|
|
138
|
+
|
|
139
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
140
|
+
|
|
141
|
+
export default function modalDialog() {
|
|
142
|
+
return (
|
|
143
|
+
<ModalDialog onClose={handleClose}>
|
|
144
|
+
{content}
|
|
145
|
+
</ModalDialog>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
`,
|
|
149
|
+
'should not add comment if there are no component props to be removed',
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { createTransformer } from '@atlaskit/codemod-utils';
|
|
2
|
+
|
|
3
|
+
import { removeIsChromeless } from '../migrations/remove-is-chromeless';
|
|
4
|
+
|
|
5
|
+
const transformer = createTransformer([removeIsChromeless]);
|
|
6
|
+
|
|
7
|
+
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
8
|
+
|
|
9
|
+
describe('Modal isChromeless prop removal codemods', () => {
|
|
10
|
+
['tsx', 'babylon'].forEach((parser) => {
|
|
11
|
+
describe(`parser: ${parser}`, () => {
|
|
12
|
+
defineInlineTest(
|
|
13
|
+
{ default: transformer, parser },
|
|
14
|
+
{},
|
|
15
|
+
`
|
|
16
|
+
import React from 'react';
|
|
17
|
+
import Modal from '@atlaskit/modal-dialog';
|
|
18
|
+
|
|
19
|
+
const App = () => {
|
|
20
|
+
return (
|
|
21
|
+
<Modal
|
|
22
|
+
testId="modal"
|
|
23
|
+
isChromeless={false}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
`,
|
|
28
|
+
`
|
|
29
|
+
import React from 'react';
|
|
30
|
+
import Modal from '@atlaskit/modal-dialog';
|
|
31
|
+
|
|
32
|
+
const App = () => {
|
|
33
|
+
return <Modal testId="modal" />;
|
|
34
|
+
}
|
|
35
|
+
`,
|
|
36
|
+
`should remove the "isChromeless" prop without adding comment when its value is false`,
|
|
37
|
+
);
|
|
38
|
+
defineInlineTest(
|
|
39
|
+
{ default: transformer, parser },
|
|
40
|
+
{},
|
|
41
|
+
`
|
|
42
|
+
import React from 'react';
|
|
43
|
+
import Modal from '@atlaskit/modal-dialog';
|
|
44
|
+
|
|
45
|
+
const App = () => {
|
|
46
|
+
return (
|
|
47
|
+
<Modal
|
|
48
|
+
testId="modal"
|
|
49
|
+
isBlanketHidden
|
|
50
|
+
autoFocus={false}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
`,
|
|
55
|
+
`
|
|
56
|
+
import React from 'react';
|
|
57
|
+
import Modal from '@atlaskit/modal-dialog';
|
|
58
|
+
|
|
59
|
+
const App = () => {
|
|
60
|
+
return (
|
|
61
|
+
<Modal
|
|
62
|
+
testId="modal"
|
|
63
|
+
isBlanketHidden
|
|
64
|
+
autoFocus={false}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
`,
|
|
69
|
+
`should leave other props as it is when "isChromeless" prop is not present`,
|
|
70
|
+
);
|
|
71
|
+
defineInlineTest(
|
|
72
|
+
{ default: transformer, parser },
|
|
73
|
+
{},
|
|
74
|
+
`
|
|
75
|
+
import React from 'react';
|
|
76
|
+
import Modal from '@atlaskit/modal-dialog';
|
|
77
|
+
|
|
78
|
+
const App = () => {
|
|
79
|
+
return (
|
|
80
|
+
<Modal
|
|
81
|
+
testId="modal"
|
|
82
|
+
isChromeless={true}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
`,
|
|
87
|
+
`
|
|
88
|
+
import React from 'react';
|
|
89
|
+
import Modal from '@atlaskit/modal-dialog';
|
|
90
|
+
|
|
91
|
+
const App = () => {
|
|
92
|
+
return (
|
|
93
|
+
/* TODO: (from codemod)\u0020
|
|
94
|
+
ModalDialog has a new compositional API and the 'isChromeless' prop is no longer supported.
|
|
95
|
+
To have the functionality of the 'isChromeless' prop, you can choose to not use any of the default exports (ModalBody, ModalHeader and ModalFooter).
|
|
96
|
+
The only other change is that ModalDialog's children should have a border radius of 3px to match the box shadow.
|
|
97
|
+
For more information, check the documentation at https://atlassian.design/components/modal-dialog/examples */
|
|
98
|
+
(<Modal testId="modal" />)
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
`,
|
|
102
|
+
`should remove the "isChromeless" prop and add comment when its value is true`,
|
|
103
|
+
);
|
|
104
|
+
defineInlineTest(
|
|
105
|
+
{ default: transformer, parser },
|
|
106
|
+
{},
|
|
107
|
+
`
|
|
108
|
+
import React from 'react';
|
|
109
|
+
import Modal from '@atlaskit/modal-dialog';
|
|
110
|
+
|
|
111
|
+
const App = () => {
|
|
112
|
+
return (
|
|
113
|
+
<Modal
|
|
114
|
+
testId="modal"
|
|
115
|
+
onCloseComplete={() => console.log('closed')}
|
|
116
|
+
isChromeless
|
|
117
|
+
isBlanketHidden
|
|
118
|
+
autoFocus={false}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
`,
|
|
123
|
+
`
|
|
124
|
+
import React from 'react';
|
|
125
|
+
import Modal from '@atlaskit/modal-dialog';
|
|
126
|
+
|
|
127
|
+
const App = () => {
|
|
128
|
+
return (
|
|
129
|
+
/* TODO: (from codemod)\u0020
|
|
130
|
+
ModalDialog has a new compositional API and the 'isChromeless' prop is no longer supported.
|
|
131
|
+
To have the functionality of the 'isChromeless' prop, you can choose to not use any of the default exports (ModalBody, ModalHeader and ModalFooter).
|
|
132
|
+
The only other change is that ModalDialog's children should have a border radius of 3px to match the box shadow.
|
|
133
|
+
For more information, check the documentation at https://atlassian.design/components/modal-dialog/examples */
|
|
134
|
+
(<Modal
|
|
135
|
+
testId="modal"
|
|
136
|
+
onCloseComplete={() => console.log('closed')}
|
|
137
|
+
isBlanketHidden
|
|
138
|
+
autoFocus={false} />)
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
`,
|
|
142
|
+
`should remove the "isChromeless" prop and add comment when its value is implicitly true`,
|
|
143
|
+
);
|
|
144
|
+
defineInlineTest(
|
|
145
|
+
{ default: transformer, parser },
|
|
146
|
+
{},
|
|
147
|
+
`
|
|
148
|
+
import React from 'react';
|
|
149
|
+
import Modal from '@atlaskit/modal-dialog';
|
|
150
|
+
|
|
151
|
+
const App = () => {
|
|
152
|
+
const val=false;
|
|
153
|
+
return (
|
|
154
|
+
<Modal
|
|
155
|
+
isChromeless={val}
|
|
156
|
+
>
|
|
157
|
+
hello world
|
|
158
|
+
</Modal>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
`,
|
|
162
|
+
`
|
|
163
|
+
import React from 'react';
|
|
164
|
+
import Modal from '@atlaskit/modal-dialog';
|
|
165
|
+
|
|
166
|
+
const App = () => {
|
|
167
|
+
const val=false;
|
|
168
|
+
return (
|
|
169
|
+
/* TODO: (from codemod)\u0020
|
|
170
|
+
ModalDialog has a new compositional API and the 'isChromeless' prop is no longer supported.
|
|
171
|
+
To have the functionality of the 'isChromeless' prop, you can choose to not use any of the default exports (ModalBody, ModalHeader and ModalFooter).
|
|
172
|
+
The only other change is that ModalDialog's children should have a border radius of 3px to match the box shadow.
|
|
173
|
+
For more information, check the documentation at https://atlassian.design/components/modal-dialog/examples */
|
|
174
|
+
(<Modal>hello world</Modal>)
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
`,
|
|
178
|
+
`should remove the "isChromeless" prop and add comment when its value is a variable`,
|
|
179
|
+
);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createTransformer } from '@atlaskit/codemod-utils';
|
|
2
|
+
|
|
3
|
+
import { renameAppearanceType } from '../migrations/rename-appearance-type';
|
|
4
|
+
|
|
5
|
+
const transformer = createTransformer([renameAppearanceType]);
|
|
6
|
+
|
|
7
|
+
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
8
|
+
|
|
9
|
+
// Only testing for tsx here because it's modifying types
|
|
10
|
+
describe('rename appearance prop type', () => {
|
|
11
|
+
defineInlineTest(
|
|
12
|
+
{ default: transformer, parser: 'tsx' },
|
|
13
|
+
{},
|
|
14
|
+
`
|
|
15
|
+
import React from 'react';
|
|
16
|
+
import { AppearanceType } from '@atlaskit/modal-dialog';
|
|
17
|
+
`,
|
|
18
|
+
`
|
|
19
|
+
import React from 'react';
|
|
20
|
+
import { Appearance as AppearanceType } from '@atlaskit/modal-dialog';
|
|
21
|
+
`,
|
|
22
|
+
'should create alias for AppearanceType as Appearance',
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
defineInlineTest(
|
|
26
|
+
{ default: transformer, parser: 'tsx' },
|
|
27
|
+
{},
|
|
28
|
+
`
|
|
29
|
+
import React from 'react';
|
|
30
|
+
import ModalDialog, { AppearanceType } from '@atlaskit/modal-dialog';
|
|
31
|
+
`,
|
|
32
|
+
`
|
|
33
|
+
import React from 'react';
|
|
34
|
+
import ModalDialog, { Appearance as AppearanceType } from '@atlaskit/modal-dialog';
|
|
35
|
+
`,
|
|
36
|
+
'should create aliases when imported with a default import',
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
defineInlineTest(
|
|
40
|
+
{ default: transformer, parser: 'tsx' },
|
|
41
|
+
{},
|
|
42
|
+
`
|
|
43
|
+
import React from 'react';
|
|
44
|
+
import ModalDialog, { AppearanceType as ModalDialogAppearance } from '@atlaskit/modal-dialog';
|
|
45
|
+
`,
|
|
46
|
+
`
|
|
47
|
+
import React from 'react';
|
|
48
|
+
import ModalDialog, { Appearance as ModalDialogAppearance } from '@atlaskit/modal-dialog';
|
|
49
|
+
`,
|
|
50
|
+
'should preserve old alias names',
|
|
51
|
+
);
|
|
52
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createTransformer } from '@atlaskit/codemod-utils';
|
|
2
|
+
|
|
3
|
+
import { renameInnerComponentPropTypes } from '../migrations/rename-inner-component-prop-types';
|
|
4
|
+
|
|
5
|
+
const transformer = createTransformer([renameInnerComponentPropTypes]);
|
|
6
|
+
|
|
7
|
+
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
8
|
+
|
|
9
|
+
// Only testing for tsx here because it's modifying types
|
|
10
|
+
describe('rename inner component prop types', () => {
|
|
11
|
+
defineInlineTest(
|
|
12
|
+
{ default: transformer, parser: 'tsx' },
|
|
13
|
+
{},
|
|
14
|
+
`
|
|
15
|
+
import React from 'react';
|
|
16
|
+
import {
|
|
17
|
+
HeaderComponentProps,
|
|
18
|
+
BodyComponentProps,
|
|
19
|
+
FooterComponentProps,
|
|
20
|
+
TitleComponentProps,
|
|
21
|
+
} from '@atlaskit/modal-dialog';
|
|
22
|
+
`,
|
|
23
|
+
`
|
|
24
|
+
import React from 'react';
|
|
25
|
+
import {
|
|
26
|
+
ModalHeaderProps as HeaderComponentProps,
|
|
27
|
+
ModalBodyProps as BodyComponentProps,
|
|
28
|
+
ModalFooterProps as FooterComponentProps,
|
|
29
|
+
ModalTitleProps as TitleComponentProps,
|
|
30
|
+
} from '@atlaskit/modal-dialog';
|
|
31
|
+
`,
|
|
32
|
+
'should create aliases for (Header/Body/Footer/Title)ComponentProps as Modal(Header/Body/Footer/Title)Props',
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
defineInlineTest(
|
|
36
|
+
{ default: transformer, parser: 'tsx' },
|
|
37
|
+
{},
|
|
38
|
+
`
|
|
39
|
+
import React from 'react';
|
|
40
|
+
import ModalDialog, {
|
|
41
|
+
HeaderComponentProps,
|
|
42
|
+
BodyComponentProps,
|
|
43
|
+
FooterComponentProps,
|
|
44
|
+
TitleComponentProps,
|
|
45
|
+
} from '@atlaskit/modal-dialog';
|
|
46
|
+
`,
|
|
47
|
+
`
|
|
48
|
+
import React from 'react';
|
|
49
|
+
import ModalDialog, {
|
|
50
|
+
ModalHeaderProps as HeaderComponentProps,
|
|
51
|
+
ModalBodyProps as BodyComponentProps,
|
|
52
|
+
ModalFooterProps as FooterComponentProps,
|
|
53
|
+
ModalTitleProps as TitleComponentProps,
|
|
54
|
+
} from '@atlaskit/modal-dialog';
|
|
55
|
+
`,
|
|
56
|
+
'should create aliases when imported with a default import',
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
defineInlineTest(
|
|
60
|
+
{ default: transformer, parser: 'tsx' },
|
|
61
|
+
{},
|
|
62
|
+
`
|
|
63
|
+
import React from 'react';
|
|
64
|
+
import ModalDialog, {
|
|
65
|
+
HeaderComponentProps as CustomHeaderProps,
|
|
66
|
+
BodyComponentProps as CustomBodyProps,
|
|
67
|
+
FooterComponentProps as CustomFooterProps,
|
|
68
|
+
TitleComponentProps as CustomTitleProps,
|
|
69
|
+
} from '@atlaskit/modal-dialog';
|
|
70
|
+
`,
|
|
71
|
+
`
|
|
72
|
+
import React from 'react';
|
|
73
|
+
import ModalDialog, {
|
|
74
|
+
ModalHeaderProps as CustomHeaderProps,
|
|
75
|
+
ModalBodyProps as CustomBodyProps,
|
|
76
|
+
ModalFooterProps as CustomFooterProps,
|
|
77
|
+
ModalTitleProps as CustomTitleProps,
|
|
78
|
+
} from '@atlaskit/modal-dialog';
|
|
79
|
+
`,
|
|
80
|
+
'should preserve old alias names',
|
|
81
|
+
);
|
|
82
|
+
});
|