@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,276 @@
|
|
|
1
|
+
import { createTransformer } from '@atlaskit/codemod-utils';
|
|
2
|
+
|
|
3
|
+
import { handlePropSpread } from '../migrations/handle-prop-spread';
|
|
4
|
+
|
|
5
|
+
const transformer = createTransformer([handlePropSpread]);
|
|
6
|
+
|
|
7
|
+
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
8
|
+
|
|
9
|
+
describe('Modal props spread handling codemod', () => {
|
|
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
|
+
const props = {}
|
|
19
|
+
const App = () => {
|
|
20
|
+
return <Modal {...props} />;
|
|
21
|
+
}
|
|
22
|
+
`,
|
|
23
|
+
`
|
|
24
|
+
/* TODO: (from codemod)\u0020
|
|
25
|
+
This file is spreading props on the ModalDialog component, so we could not
|
|
26
|
+
automatically convert this usage to the new API.
|
|
27
|
+
|
|
28
|
+
The following props have been deprecated as part of moving to a compositional API:
|
|
29
|
+
|
|
30
|
+
- 'heading' prop has been replaced by ModalHeader and ModalTitle components.
|
|
31
|
+
- 'actions' prop has been replaced by ModalFooter component, with Button components from @atlaskit/button.
|
|
32
|
+
- 'scrollBehavior' prop has been replaced by 'shouldScrollInViewport', where "outside" from the previous prop maps to true in the new prop.
|
|
33
|
+
- 'isHeadingMultiline' prop has been replaced by 'isMultiline' prop on the ModalTitle component.
|
|
34
|
+
- 'appearance' prop has been moved to the ModalTitle component. To achieve the feature parity, pass the 'appearance' prop directly to ModalTitle and Button components inside ModalFooter.
|
|
35
|
+
|
|
36
|
+
Refer to the docs for the new API at https://atlassian.design/components/modal-dialog/examples
|
|
37
|
+
to complete the migration and use the new composable components. */
|
|
38
|
+
import React from 'react';
|
|
39
|
+
import Modal from '@atlaskit/modal-dialog';
|
|
40
|
+
const props = {}
|
|
41
|
+
const App = () => {
|
|
42
|
+
return <Modal {...props} />;
|
|
43
|
+
}
|
|
44
|
+
`,
|
|
45
|
+
`should add a comment when props are being spread`,
|
|
46
|
+
);
|
|
47
|
+
defineInlineTest(
|
|
48
|
+
{ default: transformer, parser },
|
|
49
|
+
{},
|
|
50
|
+
`
|
|
51
|
+
import React from 'react';
|
|
52
|
+
const AKModalDialog = lazy(() => import('@atlaskit/modal-dialog'));
|
|
53
|
+
const props = {}
|
|
54
|
+
const App = () => {
|
|
55
|
+
return <AKModalDialog {...props} />;
|
|
56
|
+
}
|
|
57
|
+
`,
|
|
58
|
+
`
|
|
59
|
+
/* TODO: (from codemod)\u0020
|
|
60
|
+
This file is spreading props on the ModalDialog component, so we could not
|
|
61
|
+
automatically convert this usage to the new API.
|
|
62
|
+
|
|
63
|
+
The following props have been deprecated as part of moving to a compositional API:
|
|
64
|
+
|
|
65
|
+
- 'heading' prop has been replaced by ModalHeader and ModalTitle components.
|
|
66
|
+
- 'actions' prop has been replaced by ModalFooter component, with Button components from @atlaskit/button.
|
|
67
|
+
- 'scrollBehavior' prop has been replaced by 'shouldScrollInViewport', where "outside" from the previous prop maps to true in the new prop.
|
|
68
|
+
- 'isHeadingMultiline' prop has been replaced by 'isMultiline' prop on the ModalTitle component.
|
|
69
|
+
- 'appearance' prop has been moved to the ModalTitle component. To achieve the feature parity, pass the 'appearance' prop directly to ModalTitle and Button components inside ModalFooter.
|
|
70
|
+
|
|
71
|
+
Refer to the docs for the new API at https://atlassian.design/components/modal-dialog/examples
|
|
72
|
+
to complete the migration and use the new composable components. */
|
|
73
|
+
import React from 'react';
|
|
74
|
+
const AKModalDialog = lazy(() => import('@atlaskit/modal-dialog'));
|
|
75
|
+
const props = {}
|
|
76
|
+
const App = () => {
|
|
77
|
+
return <AKModalDialog {...props} />;
|
|
78
|
+
}
|
|
79
|
+
`,
|
|
80
|
+
`should add a comment when props are being spread on a dynamically imported modal`,
|
|
81
|
+
);
|
|
82
|
+
defineInlineTest(
|
|
83
|
+
{ default: transformer, parser },
|
|
84
|
+
{},
|
|
85
|
+
`
|
|
86
|
+
import React from 'react';
|
|
87
|
+
import Modal from '@atlaskit/modal-dialog';
|
|
88
|
+
const props = {}
|
|
89
|
+
const App = () => {
|
|
90
|
+
return (
|
|
91
|
+
<>
|
|
92
|
+
<Modal heading={"some heading"} testId="modal" isBlanketHidden />
|
|
93
|
+
<Modal {...props} />
|
|
94
|
+
<Modal heading={"some heading"} testId="modal" isBlanketHidden />
|
|
95
|
+
</>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
`,
|
|
99
|
+
`
|
|
100
|
+
/* TODO: (from codemod)\u0020
|
|
101
|
+
This file is spreading props on the ModalDialog component, so we could not
|
|
102
|
+
automatically convert this usage to the new API.
|
|
103
|
+
|
|
104
|
+
The following props have been deprecated as part of moving to a compositional API:
|
|
105
|
+
|
|
106
|
+
- 'heading' prop has been replaced by ModalHeader and ModalTitle components.
|
|
107
|
+
- 'actions' prop has been replaced by ModalFooter component, with Button components from @atlaskit/button.
|
|
108
|
+
- 'scrollBehavior' prop has been replaced by 'shouldScrollInViewport', where "outside" from the previous prop maps to true in the new prop.
|
|
109
|
+
- 'isHeadingMultiline' prop has been replaced by 'isMultiline' prop on the ModalTitle component.
|
|
110
|
+
- 'appearance' prop has been moved to the ModalTitle component. To achieve the feature parity, pass the 'appearance' prop directly to ModalTitle and Button components inside ModalFooter.
|
|
111
|
+
|
|
112
|
+
Refer to the docs for the new API at https://atlassian.design/components/modal-dialog/examples
|
|
113
|
+
to complete the migration and use the new composable components. */
|
|
114
|
+
import React from 'react';
|
|
115
|
+
import Modal from '@atlaskit/modal-dialog';
|
|
116
|
+
const props = {}
|
|
117
|
+
const App = () => {
|
|
118
|
+
return (
|
|
119
|
+
<>
|
|
120
|
+
<Modal heading={"some heading"} testId="modal" isBlanketHidden />
|
|
121
|
+
<Modal {...props} />
|
|
122
|
+
<Modal heading={"some heading"} testId="modal" isBlanketHidden />
|
|
123
|
+
</>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
`,
|
|
127
|
+
`should add a comment when props are being spread on atleast one modal`,
|
|
128
|
+
);
|
|
129
|
+
defineInlineTest(
|
|
130
|
+
{ default: transformer, parser },
|
|
131
|
+
{},
|
|
132
|
+
`
|
|
133
|
+
import React from 'react';
|
|
134
|
+
const AKModalDialog = lazy(() => import('@atlaskit/modal-dialog'));
|
|
135
|
+
const props = {}
|
|
136
|
+
const App = () => {
|
|
137
|
+
return (
|
|
138
|
+
<>
|
|
139
|
+
<AKModalDialog heading={"some heading"} testId="modal" isBlanketHidden />
|
|
140
|
+
<AKModalDialog {...props} />
|
|
141
|
+
<AKModalDialog heading={"some heading"} testId="modal" isBlanketHidden />
|
|
142
|
+
</>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
`,
|
|
146
|
+
`
|
|
147
|
+
/* TODO: (from codemod)\u0020
|
|
148
|
+
This file is spreading props on the ModalDialog component, so we could not
|
|
149
|
+
automatically convert this usage to the new API.
|
|
150
|
+
|
|
151
|
+
The following props have been deprecated as part of moving to a compositional API:
|
|
152
|
+
|
|
153
|
+
- 'heading' prop has been replaced by ModalHeader and ModalTitle components.
|
|
154
|
+
- 'actions' prop has been replaced by ModalFooter component, with Button components from @atlaskit/button.
|
|
155
|
+
- 'scrollBehavior' prop has been replaced by 'shouldScrollInViewport', where "outside" from the previous prop maps to true in the new prop.
|
|
156
|
+
- 'isHeadingMultiline' prop has been replaced by 'isMultiline' prop on the ModalTitle component.
|
|
157
|
+
- 'appearance' prop has been moved to the ModalTitle component. To achieve the feature parity, pass the 'appearance' prop directly to ModalTitle and Button components inside ModalFooter.
|
|
158
|
+
|
|
159
|
+
Refer to the docs for the new API at https://atlassian.design/components/modal-dialog/examples
|
|
160
|
+
to complete the migration and use the new composable components. */
|
|
161
|
+
import React from 'react';
|
|
162
|
+
const AKModalDialog = lazy(() => import('@atlaskit/modal-dialog'));
|
|
163
|
+
const props = {}
|
|
164
|
+
const App = () => {
|
|
165
|
+
return (
|
|
166
|
+
<>
|
|
167
|
+
<AKModalDialog heading={"some heading"} testId="modal" isBlanketHidden />
|
|
168
|
+
<AKModalDialog {...props} />
|
|
169
|
+
<AKModalDialog heading={"some heading"} testId="modal" isBlanketHidden />
|
|
170
|
+
</>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
`,
|
|
174
|
+
`should add a comment when props are being spread on atleast one modal when modals are dynamically imported`,
|
|
175
|
+
);
|
|
176
|
+
defineInlineTest(
|
|
177
|
+
{ default: transformer, parser },
|
|
178
|
+
{},
|
|
179
|
+
`
|
|
180
|
+
import React from 'react';
|
|
181
|
+
import Modal from '@atlaskit/modal-dialog';
|
|
182
|
+
const props = {}
|
|
183
|
+
const App = () => {
|
|
184
|
+
return (
|
|
185
|
+
<>
|
|
186
|
+
<Modal heading={"some heading"} testId="modal" isBlanketHidden />
|
|
187
|
+
<Modal heading="some other heading" testId="another-modal" isBlanketHidden={false} autoFocus />
|
|
188
|
+
</>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
`,
|
|
192
|
+
`
|
|
193
|
+
import React from 'react';
|
|
194
|
+
import Modal from '@atlaskit/modal-dialog';
|
|
195
|
+
const props = {}
|
|
196
|
+
const App = () => {
|
|
197
|
+
return (
|
|
198
|
+
<>
|
|
199
|
+
<Modal heading={"some heading"} testId="modal" isBlanketHidden />
|
|
200
|
+
<Modal heading="some other heading" testId="another-modal" isBlanketHidden={false} autoFocus />
|
|
201
|
+
</>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
`,
|
|
205
|
+
`should not add a comment when props are not being spread in any of modal`,
|
|
206
|
+
);
|
|
207
|
+
defineInlineTest(
|
|
208
|
+
{ default: transformer, parser },
|
|
209
|
+
{},
|
|
210
|
+
`
|
|
211
|
+
import React from 'react';
|
|
212
|
+
const AKModalDialog = lazy(() => import('@atlaskit/modal-dialog'));
|
|
213
|
+
const props = {}
|
|
214
|
+
const App = () => {
|
|
215
|
+
return (
|
|
216
|
+
<>
|
|
217
|
+
<AKModalDialog heading={"some heading"} testId="modal" isBlanketHidden />
|
|
218
|
+
<AKModalDialog heading="some other heading" testId="another-modal" isBlanketHidden={false} autoFocus />
|
|
219
|
+
</>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
`,
|
|
223
|
+
`
|
|
224
|
+
import React from 'react';
|
|
225
|
+
const AKModalDialog = lazy(() => import('@atlaskit/modal-dialog'));
|
|
226
|
+
const props = {}
|
|
227
|
+
const App = () => {
|
|
228
|
+
return (
|
|
229
|
+
<>
|
|
230
|
+
<AKModalDialog heading={"some heading"} testId="modal" isBlanketHidden />
|
|
231
|
+
<AKModalDialog heading="some other heading" testId="another-modal" isBlanketHidden={false} autoFocus />
|
|
232
|
+
</>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
`,
|
|
236
|
+
`should not add a comment when props are not being spread in any of modal when modals are dynamically imported`,
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
defineInlineTest(
|
|
240
|
+
{ default: transformer, parser },
|
|
241
|
+
{},
|
|
242
|
+
`
|
|
243
|
+
import React from 'react';
|
|
244
|
+
|
|
245
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
246
|
+
|
|
247
|
+
import ElementBrowser from './element-browser';
|
|
248
|
+
|
|
249
|
+
const App = (props) => {
|
|
250
|
+
return (
|
|
251
|
+
<ModalDialog heading="Modal dialog" testId="modal" isBlanketHidden>
|
|
252
|
+
<ElementBrowser {...props} />
|
|
253
|
+
</ModalDialog>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
`,
|
|
257
|
+
`
|
|
258
|
+
import React from 'react';
|
|
259
|
+
|
|
260
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
261
|
+
|
|
262
|
+
import ElementBrowser from './element-browser';
|
|
263
|
+
|
|
264
|
+
const App = (props) => {
|
|
265
|
+
return (
|
|
266
|
+
<ModalDialog heading="Modal dialog" testId="modal" isBlanketHidden>
|
|
267
|
+
<ElementBrowser {...props} />
|
|
268
|
+
</ModalDialog>
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
`,
|
|
272
|
+
`should not add a comment if prop spread is NOT on ModalDialog`,
|
|
273
|
+
);
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
});
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { createTransformer } from '@atlaskit/codemod-utils';
|
|
2
|
+
|
|
3
|
+
import { inlineWidthNamesDeclaration } from '../migrations/inline-WidthNames-declaration';
|
|
4
|
+
|
|
5
|
+
const transformer = createTransformer([inlineWidthNamesDeclaration]);
|
|
6
|
+
|
|
7
|
+
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
8
|
+
|
|
9
|
+
// Only testing for tsx here because it's modifying types
|
|
10
|
+
describe('inline WidthNames declaration', () => {
|
|
11
|
+
defineInlineTest(
|
|
12
|
+
{ default: transformer, parser: 'tsx' },
|
|
13
|
+
{},
|
|
14
|
+
`
|
|
15
|
+
import React from 'react';
|
|
16
|
+
|
|
17
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
18
|
+
import { WidthNames } from '@atlaskit/modal-dialog/shared-variables';
|
|
19
|
+
|
|
20
|
+
type CustomModalDialogProps = {
|
|
21
|
+
isOpen: boolean;
|
|
22
|
+
size?: WidthNames;
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
onDismiss: () => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default function customModalDialog(props: CustomModalDialogProps) {
|
|
28
|
+
const { isOpen, size, children, onDismiss } = props;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
isOpen && (
|
|
32
|
+
<ModalDialog width={size} onClose={onDismiss}>
|
|
33
|
+
{children}
|
|
34
|
+
</ModalDialog>
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
`,
|
|
39
|
+
`
|
|
40
|
+
import React from 'react';
|
|
41
|
+
|
|
42
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
43
|
+
|
|
44
|
+
type CustomModalDialogProps = {
|
|
45
|
+
isOpen: boolean;
|
|
46
|
+
size?: "small" | "medium" | "large" | "x-large";
|
|
47
|
+
children: React.ReactNode;
|
|
48
|
+
onDismiss: () => void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default function customModalDialog(props: CustomModalDialogProps) {
|
|
52
|
+
const { isOpen, size, children, onDismiss } = props;
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
isOpen && (
|
|
56
|
+
<ModalDialog width={size} onClose={onDismiss}>
|
|
57
|
+
{children}
|
|
58
|
+
</ModalDialog>
|
|
59
|
+
)
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
`,
|
|
63
|
+
'should inline values of WidthNames in a type declaration and remove shared-variables import',
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
defineInlineTest(
|
|
67
|
+
{ default: transformer, parser: 'tsx' },
|
|
68
|
+
{},
|
|
69
|
+
`
|
|
70
|
+
import React from 'react';
|
|
71
|
+
|
|
72
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
73
|
+
import { WidthNames as ModalDialogWidths } from '@atlaskit/modal-dialog/shared-variables';
|
|
74
|
+
|
|
75
|
+
type CustomModalDialogProps = {
|
|
76
|
+
isOpen: boolean;
|
|
77
|
+
size?: ModalDialogWidths;
|
|
78
|
+
children: React.ReactNode;
|
|
79
|
+
onDismiss: () => void;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default function customModalDialog(props: CustomModalDialogProps) {
|
|
83
|
+
const { isOpen, size, children, onDismiss } = props;
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
isOpen && (
|
|
87
|
+
<ModalDialog width={size} onClose={onDismiss}>
|
|
88
|
+
{children}
|
|
89
|
+
</ModalDialog>
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
`,
|
|
94
|
+
`
|
|
95
|
+
import React from 'react';
|
|
96
|
+
|
|
97
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
98
|
+
|
|
99
|
+
type CustomModalDialogProps = {
|
|
100
|
+
isOpen: boolean;
|
|
101
|
+
size?: "small" | "medium" | "large" | "x-large";
|
|
102
|
+
children: React.ReactNode;
|
|
103
|
+
onDismiss: () => void;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export default function customModalDialog(props: CustomModalDialogProps) {
|
|
107
|
+
const { isOpen, size, children, onDismiss } = props;
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
isOpen && (
|
|
111
|
+
<ModalDialog width={size} onClose={onDismiss}>
|
|
112
|
+
{children}
|
|
113
|
+
</ModalDialog>
|
|
114
|
+
)
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
`,
|
|
118
|
+
'should inline values of WidthNames imported with an alias and remove shared-variables import',
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
defineInlineTest(
|
|
122
|
+
{ default: transformer, parser: 'tsx' },
|
|
123
|
+
{},
|
|
124
|
+
`
|
|
125
|
+
import React from 'react';
|
|
126
|
+
|
|
127
|
+
import ModalDialog, { ModalDialogProps } from '@atlaskit/modal-dialog';
|
|
128
|
+
import { WidthNames } from '@atlaskit/modal-dialog/shared-variables';
|
|
129
|
+
|
|
130
|
+
interface CustomModalDialogProps extends ModalDialogProps {
|
|
131
|
+
isOpen: boolean;
|
|
132
|
+
size: WidthNames;
|
|
133
|
+
children: React.ReactNode;
|
|
134
|
+
onDismiss: () => void;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export default function customModalDialog(props: CustomModalDialogProps) {
|
|
138
|
+
const { isOpen, size, children, onDismiss } = props;
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
isOpen && (
|
|
142
|
+
<ModalDialog width={size} onClose={onDismiss}>
|
|
143
|
+
{children}
|
|
144
|
+
</ModalDialog>
|
|
145
|
+
)
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
`,
|
|
149
|
+
`
|
|
150
|
+
import React from 'react';
|
|
151
|
+
|
|
152
|
+
import ModalDialog, { ModalDialogProps } from '@atlaskit/modal-dialog';
|
|
153
|
+
|
|
154
|
+
interface CustomModalDialogProps extends ModalDialogProps {
|
|
155
|
+
isOpen: boolean;
|
|
156
|
+
size: "small" | "medium" | "large" | "x-large";
|
|
157
|
+
children: React.ReactNode;
|
|
158
|
+
onDismiss: () => void;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export default function customModalDialog(props: CustomModalDialogProps) {
|
|
162
|
+
const { isOpen, size, children, onDismiss } = props;
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
isOpen && (
|
|
166
|
+
<ModalDialog width={size} onClose={onDismiss}>
|
|
167
|
+
{children}
|
|
168
|
+
</ModalDialog>
|
|
169
|
+
)
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
`,
|
|
173
|
+
'should inline values of WidthNames in an interface declaration and remove shared-variables import',
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
defineInlineTest(
|
|
177
|
+
{ default: transformer, parser: 'tsx' },
|
|
178
|
+
{},
|
|
179
|
+
`
|
|
180
|
+
import React from 'react';
|
|
181
|
+
|
|
182
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
183
|
+
import { WidthNames } from '@atlaskit/modal-dialog/shared-variables';
|
|
184
|
+
|
|
185
|
+
import { getStyles } from './styles';
|
|
186
|
+
|
|
187
|
+
type CustomBodyProps = {
|
|
188
|
+
size: WidthNames;
|
|
189
|
+
children: React.ReactNode;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
interface CustomModalDialogProps {
|
|
193
|
+
isOpen: boolean;
|
|
194
|
+
size: WidthNames;
|
|
195
|
+
children: React.ReactNode;
|
|
196
|
+
onDismiss: () => void;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function CustomBody(props: CustomBodyProps) {
|
|
200
|
+
return (
|
|
201
|
+
<div style={getStyles(props.size)}>{props.children}</div>
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export default function customModalDialog(props: CustomModalDialogProps) {
|
|
206
|
+
const { isOpen, size, children, onDismiss } = props;
|
|
207
|
+
|
|
208
|
+
return (
|
|
209
|
+
isOpen && (
|
|
210
|
+
<ModalDialog width={size} onClose={onDismiss}>
|
|
211
|
+
<CustomBody size={size}>
|
|
212
|
+
{children}
|
|
213
|
+
</CustomBody>
|
|
214
|
+
</ModalDialog>
|
|
215
|
+
)
|
|
216
|
+
)
|
|
217
|
+
}
|
|
218
|
+
`,
|
|
219
|
+
`
|
|
220
|
+
import React from 'react';
|
|
221
|
+
|
|
222
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
223
|
+
|
|
224
|
+
import { getStyles } from './styles';
|
|
225
|
+
|
|
226
|
+
type CustomBodyProps = {
|
|
227
|
+
size: "small" | "medium" | "large" | "x-large";
|
|
228
|
+
children: React.ReactNode;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
interface CustomModalDialogProps {
|
|
232
|
+
isOpen: boolean;
|
|
233
|
+
size: "small" | "medium" | "large" | "x-large";
|
|
234
|
+
children: React.ReactNode;
|
|
235
|
+
onDismiss: () => void;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function CustomBody(props: CustomBodyProps) {
|
|
239
|
+
return (
|
|
240
|
+
<div style={getStyles(props.size)}>{props.children}</div>
|
|
241
|
+
)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export default function customModalDialog(props: CustomModalDialogProps) {
|
|
245
|
+
const { isOpen, size, children, onDismiss } = props;
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
isOpen && (
|
|
249
|
+
<ModalDialog width={size} onClose={onDismiss}>
|
|
250
|
+
<CustomBody size={size}>
|
|
251
|
+
{children}
|
|
252
|
+
</CustomBody>
|
|
253
|
+
</ModalDialog>
|
|
254
|
+
)
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
`,
|
|
258
|
+
'should inline values of WidthNames in both type and interface declarations and remove shared-variables import',
|
|
259
|
+
);
|
|
260
|
+
});
|