@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,323 @@
|
|
|
1
|
+
import { createTransformer } from '@atlaskit/codemod-utils';
|
|
2
|
+
|
|
3
|
+
import { mapContainerFromProps } from '../migrations/map-container-from-props';
|
|
4
|
+
|
|
5
|
+
const transformer = createTransformer([mapContainerFromProps]);
|
|
6
|
+
|
|
7
|
+
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
8
|
+
|
|
9
|
+
describe('map container from 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
|
+
const Container = (props) => (<form>{props.children}</form>);
|
|
21
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
22
|
+
|
|
23
|
+
export default function modalDialog() {
|
|
24
|
+
return (
|
|
25
|
+
<ModalDialog
|
|
26
|
+
onClose={handleClose}
|
|
27
|
+
components={{
|
|
28
|
+
Container,
|
|
29
|
+
Header
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
{content}
|
|
33
|
+
</ModalDialog>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
`,
|
|
37
|
+
`
|
|
38
|
+
import React from 'react';
|
|
39
|
+
|
|
40
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
41
|
+
|
|
42
|
+
const Container = (props) => (<form>{props.children}</form>);
|
|
43
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
44
|
+
|
|
45
|
+
export default function modalDialog() {
|
|
46
|
+
return (
|
|
47
|
+
<ModalDialog
|
|
48
|
+
onClose={handleClose}
|
|
49
|
+
components={{
|
|
50
|
+
Header
|
|
51
|
+
}}>
|
|
52
|
+
{Container({
|
|
53
|
+
children: <>
|
|
54
|
+
{content}
|
|
55
|
+
</>
|
|
56
|
+
})}
|
|
57
|
+
</ModalDialog>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
`,
|
|
61
|
+
'should invoke Container declared as shorthand with children passed as argument',
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
defineInlineTest(
|
|
65
|
+
{ default: transformer, parser },
|
|
66
|
+
{},
|
|
67
|
+
`
|
|
68
|
+
import React from 'react';
|
|
69
|
+
|
|
70
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
71
|
+
|
|
72
|
+
const ContainerComponent = (props) => (<form>{props.children}</form>);
|
|
73
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
74
|
+
|
|
75
|
+
export default function modalDialog() {
|
|
76
|
+
return (
|
|
77
|
+
<ModalDialog
|
|
78
|
+
onClose={handleClose}
|
|
79
|
+
components={{
|
|
80
|
+
Container: ContainerComponent,
|
|
81
|
+
Header
|
|
82
|
+
}}
|
|
83
|
+
>
|
|
84
|
+
{content}
|
|
85
|
+
</ModalDialog>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
`,
|
|
89
|
+
`
|
|
90
|
+
import React from 'react';
|
|
91
|
+
|
|
92
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
93
|
+
|
|
94
|
+
const ContainerComponent = (props) => (<form>{props.children}</form>);
|
|
95
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
96
|
+
|
|
97
|
+
export default function modalDialog() {
|
|
98
|
+
return (
|
|
99
|
+
<ModalDialog
|
|
100
|
+
onClose={handleClose}
|
|
101
|
+
components={{
|
|
102
|
+
Header
|
|
103
|
+
}}>
|
|
104
|
+
{ContainerComponent({
|
|
105
|
+
children: <>
|
|
106
|
+
{content}
|
|
107
|
+
</>
|
|
108
|
+
})}
|
|
109
|
+
</ModalDialog>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
`,
|
|
113
|
+
'should invoke Container declared as assigned variable with children passed as argument',
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
defineInlineTest(
|
|
117
|
+
{ default: transformer, parser },
|
|
118
|
+
{},
|
|
119
|
+
`
|
|
120
|
+
import React from 'react';
|
|
121
|
+
|
|
122
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
123
|
+
|
|
124
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
125
|
+
|
|
126
|
+
export default function modalDialog() {
|
|
127
|
+
return (
|
|
128
|
+
<ModalDialog
|
|
129
|
+
onClose={handleClose}
|
|
130
|
+
components={{
|
|
131
|
+
Container: 'form',
|
|
132
|
+
Header
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
{content}
|
|
136
|
+
</ModalDialog>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
`,
|
|
140
|
+
`
|
|
141
|
+
import React from 'react';
|
|
142
|
+
|
|
143
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
144
|
+
|
|
145
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
146
|
+
|
|
147
|
+
export default function modalDialog() {
|
|
148
|
+
return (
|
|
149
|
+
<ModalDialog
|
|
150
|
+
onClose={handleClose}
|
|
151
|
+
components={{
|
|
152
|
+
Header
|
|
153
|
+
}}>
|
|
154
|
+
<form>
|
|
155
|
+
{content}
|
|
156
|
+
</form>
|
|
157
|
+
</ModalDialog>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
`,
|
|
161
|
+
'should wrap Container declared as string around children',
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
defineInlineTest(
|
|
165
|
+
{ default: transformer, parser },
|
|
166
|
+
{},
|
|
167
|
+
`
|
|
168
|
+
import React from 'react';
|
|
169
|
+
|
|
170
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
171
|
+
import Form from '@atlaskit/form';
|
|
172
|
+
|
|
173
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
174
|
+
|
|
175
|
+
export default function modalDialog() {
|
|
176
|
+
return (
|
|
177
|
+
<ModalDialog
|
|
178
|
+
onClose={handleClose}
|
|
179
|
+
components={{
|
|
180
|
+
Header,
|
|
181
|
+
Container: (props) => (
|
|
182
|
+
<Form onSubmit={onSubmit}>
|
|
183
|
+
{({ formProps }) => <form {...formProps}>{props.children}</form>}
|
|
184
|
+
</Form>
|
|
185
|
+
)
|
|
186
|
+
}}
|
|
187
|
+
>
|
|
188
|
+
<div>First content</div>
|
|
189
|
+
<div>Second content</div>
|
|
190
|
+
</ModalDialog>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
`,
|
|
194
|
+
`
|
|
195
|
+
import React from 'react';
|
|
196
|
+
|
|
197
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
198
|
+
import Form from '@atlaskit/form';
|
|
199
|
+
|
|
200
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
201
|
+
|
|
202
|
+
export default function modalDialog() {
|
|
203
|
+
return (
|
|
204
|
+
<ModalDialog
|
|
205
|
+
onClose={handleClose}
|
|
206
|
+
components={{
|
|
207
|
+
Header
|
|
208
|
+
}}>
|
|
209
|
+
{(props => <Form onSubmit={onSubmit}>
|
|
210
|
+
{({ formProps }) => <form {...formProps}>{props.children}</form>}
|
|
211
|
+
</Form>)({
|
|
212
|
+
children: <>
|
|
213
|
+
<div>First content</div>
|
|
214
|
+
<div>Second content</div>
|
|
215
|
+
</>
|
|
216
|
+
})}
|
|
217
|
+
</ModalDialog>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
`,
|
|
221
|
+
'should invoke Container declared as a function expression with children passed as argument',
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
defineInlineTest(
|
|
225
|
+
{ default: transformer, parser },
|
|
226
|
+
{},
|
|
227
|
+
`
|
|
228
|
+
import React from 'react';
|
|
229
|
+
|
|
230
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
231
|
+
|
|
232
|
+
const components = {
|
|
233
|
+
Container: (props) => (<form>{props.children}</form>),
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export default function modalDialog() {
|
|
237
|
+
return (
|
|
238
|
+
<ModalDialog onClose={handleClose} components={components}>
|
|
239
|
+
{content}
|
|
240
|
+
</ModalDialog>
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
`,
|
|
244
|
+
`
|
|
245
|
+
import React from 'react';
|
|
246
|
+
|
|
247
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
248
|
+
|
|
249
|
+
const components = {
|
|
250
|
+
Container: (props) => (<form>{props.children}</form>),
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export default function modalDialog() {
|
|
254
|
+
return (
|
|
255
|
+
<ModalDialog onClose={handleClose} components={components}>
|
|
256
|
+
{content}
|
|
257
|
+
</ModalDialog>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
`,
|
|
261
|
+
'should do nothing if components definition is not an inline object expression',
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
defineInlineTest(
|
|
265
|
+
{ default: transformer, parser },
|
|
266
|
+
{},
|
|
267
|
+
`
|
|
268
|
+
import React from 'react';
|
|
269
|
+
|
|
270
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
271
|
+
|
|
272
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
273
|
+
|
|
274
|
+
class CustomModalDialog extends React.Component {
|
|
275
|
+
container = (props) => (<form>{props.children}</form>);
|
|
276
|
+
|
|
277
|
+
render() {
|
|
278
|
+
return (
|
|
279
|
+
<ModalDialog
|
|
280
|
+
onClose={handleClose}
|
|
281
|
+
components={{
|
|
282
|
+
Container: this.container,
|
|
283
|
+
Header
|
|
284
|
+
}}
|
|
285
|
+
>
|
|
286
|
+
{content}
|
|
287
|
+
</ModalDialog>
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
`,
|
|
292
|
+
`
|
|
293
|
+
import React from 'react';
|
|
294
|
+
|
|
295
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
296
|
+
|
|
297
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
298
|
+
|
|
299
|
+
class CustomModalDialog extends React.Component {
|
|
300
|
+
container = (props) => (<form>{props.children}</form>);
|
|
301
|
+
|
|
302
|
+
render() {
|
|
303
|
+
return (
|
|
304
|
+
<ModalDialog
|
|
305
|
+
onClose={handleClose}
|
|
306
|
+
components={{
|
|
307
|
+
Header
|
|
308
|
+
}}>
|
|
309
|
+
{this.container({
|
|
310
|
+
children: <>
|
|
311
|
+
{content}
|
|
312
|
+
</>
|
|
313
|
+
})}
|
|
314
|
+
</ModalDialog>
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
`,
|
|
319
|
+
'should invoke Container of a modal dialog declared as class component',
|
|
320
|
+
);
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
});
|
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
import { createTransformer } from '@atlaskit/codemod-utils';
|
|
2
|
+
|
|
3
|
+
import { mapFooterFromProps } from '../migrations/map-footer-from-props';
|
|
4
|
+
|
|
5
|
+
const transformer = createTransformer([mapFooterFromProps]);
|
|
6
|
+
|
|
7
|
+
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
8
|
+
|
|
9
|
+
describe('map footer from 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
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
21
|
+
const Footer = (props) => (<div>{props.children}</div>);
|
|
22
|
+
|
|
23
|
+
export default function modalDialog() {
|
|
24
|
+
return (
|
|
25
|
+
<ModalDialog
|
|
26
|
+
onClose={handleClose}
|
|
27
|
+
components={{
|
|
28
|
+
Header,
|
|
29
|
+
Footer
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
{content}
|
|
33
|
+
</ModalDialog>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
`,
|
|
37
|
+
`
|
|
38
|
+
import React from 'react';
|
|
39
|
+
|
|
40
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
41
|
+
|
|
42
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
43
|
+
const Footer = (props) => (<div>{props.children}</div>);
|
|
44
|
+
|
|
45
|
+
export default function modalDialog() {
|
|
46
|
+
return (
|
|
47
|
+
<ModalDialog
|
|
48
|
+
onClose={handleClose}
|
|
49
|
+
components={{
|
|
50
|
+
Header
|
|
51
|
+
}}>
|
|
52
|
+
{content}
|
|
53
|
+
{Footer()}
|
|
54
|
+
</ModalDialog>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
`,
|
|
58
|
+
'should invoke Footer declared as shorthand',
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
defineInlineTest(
|
|
62
|
+
{ default: transformer, parser },
|
|
63
|
+
{},
|
|
64
|
+
`
|
|
65
|
+
import React from 'react';
|
|
66
|
+
|
|
67
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
68
|
+
|
|
69
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
70
|
+
const CustomFooter = (props) => (<div>{props.children}</div>);
|
|
71
|
+
|
|
72
|
+
export default function modalDialog() {
|
|
73
|
+
return (
|
|
74
|
+
<ModalDialog
|
|
75
|
+
onClose={handleClose}
|
|
76
|
+
components={{
|
|
77
|
+
Header,
|
|
78
|
+
Footer: CustomFooter,
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
{content}
|
|
82
|
+
</ModalDialog>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
`,
|
|
86
|
+
`
|
|
87
|
+
import React from 'react';
|
|
88
|
+
|
|
89
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
90
|
+
|
|
91
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
92
|
+
const CustomFooter = (props) => (<div>{props.children}</div>);
|
|
93
|
+
|
|
94
|
+
export default function modalDialog() {
|
|
95
|
+
return (
|
|
96
|
+
<ModalDialog
|
|
97
|
+
onClose={handleClose}
|
|
98
|
+
components={{
|
|
99
|
+
Header
|
|
100
|
+
}}>
|
|
101
|
+
{content}
|
|
102
|
+
{CustomFooter()}
|
|
103
|
+
</ModalDialog>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
`,
|
|
107
|
+
'should invoke Footer declared as assigned variable',
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
defineInlineTest(
|
|
111
|
+
{ default: transformer, parser },
|
|
112
|
+
{},
|
|
113
|
+
`
|
|
114
|
+
import React from 'react';
|
|
115
|
+
|
|
116
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
117
|
+
|
|
118
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
119
|
+
|
|
120
|
+
export default function modalDialog() {
|
|
121
|
+
return (
|
|
122
|
+
<ModalDialog
|
|
123
|
+
onClose={handleClose}
|
|
124
|
+
components={{
|
|
125
|
+
Header,
|
|
126
|
+
Footer: ({ testId, onClose }) => (
|
|
127
|
+
<div data-testid={testId}>
|
|
128
|
+
<button onClose={onClose}>Custom footer</button>
|
|
129
|
+
</div>
|
|
130
|
+
),
|
|
131
|
+
}}
|
|
132
|
+
>
|
|
133
|
+
{content}
|
|
134
|
+
</ModalDialog>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
`,
|
|
138
|
+
`
|
|
139
|
+
import React from 'react';
|
|
140
|
+
|
|
141
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
142
|
+
|
|
143
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
144
|
+
|
|
145
|
+
export default function modalDialog() {
|
|
146
|
+
return (
|
|
147
|
+
<ModalDialog
|
|
148
|
+
onClose={handleClose}
|
|
149
|
+
components={{
|
|
150
|
+
Header
|
|
151
|
+
}}>
|
|
152
|
+
{content}
|
|
153
|
+
{(({ testId, onClose }) => <div data-testid={testId}>
|
|
154
|
+
<button onClose={onClose}>Custom footer</button>
|
|
155
|
+
</div>)()}
|
|
156
|
+
</ModalDialog>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
`,
|
|
160
|
+
'should invoke Footer declared as arrow function',
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
defineInlineTest(
|
|
164
|
+
{ default: transformer, parser },
|
|
165
|
+
{},
|
|
166
|
+
`
|
|
167
|
+
import React from 'react';
|
|
168
|
+
|
|
169
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
170
|
+
|
|
171
|
+
const components = {
|
|
172
|
+
Footer: (props) => (<div>{props.children}</div>),
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export default function modalDialog() {
|
|
176
|
+
return (
|
|
177
|
+
<ModalDialog onClose={handleClose} components={components}>
|
|
178
|
+
{content}
|
|
179
|
+
</ModalDialog>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
`,
|
|
183
|
+
`
|
|
184
|
+
import React from 'react';
|
|
185
|
+
|
|
186
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
187
|
+
|
|
188
|
+
const components = {
|
|
189
|
+
Footer: (props) => (<div>{props.children}</div>),
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export default function modalDialog() {
|
|
193
|
+
return (
|
|
194
|
+
<ModalDialog onClose={handleClose} components={components}>
|
|
195
|
+
{content}
|
|
196
|
+
</ModalDialog>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
`,
|
|
200
|
+
'should do nothing if components definition is not an inline object expression',
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
defineInlineTest(
|
|
204
|
+
{ default: transformer, parser },
|
|
205
|
+
{},
|
|
206
|
+
`
|
|
207
|
+
import React from 'react';
|
|
208
|
+
|
|
209
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
210
|
+
|
|
211
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
212
|
+
|
|
213
|
+
class CustomModalDialog extends React.Component {
|
|
214
|
+
footer = (props) => (<div>{props.children}</div>);
|
|
215
|
+
|
|
216
|
+
render() {
|
|
217
|
+
return (
|
|
218
|
+
<ModalDialog
|
|
219
|
+
onClose={handleClose}
|
|
220
|
+
components={{
|
|
221
|
+
Header,
|
|
222
|
+
Footer: this.footer,
|
|
223
|
+
}}
|
|
224
|
+
>
|
|
225
|
+
{content}
|
|
226
|
+
</ModalDialog>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
`,
|
|
231
|
+
`
|
|
232
|
+
import React from 'react';
|
|
233
|
+
|
|
234
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
235
|
+
|
|
236
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
237
|
+
|
|
238
|
+
class CustomModalDialog extends React.Component {
|
|
239
|
+
footer = (props) => (<div>{props.children}</div>);
|
|
240
|
+
|
|
241
|
+
render() {
|
|
242
|
+
return (
|
|
243
|
+
<ModalDialog
|
|
244
|
+
onClose={handleClose}
|
|
245
|
+
components={{
|
|
246
|
+
Header
|
|
247
|
+
}}>
|
|
248
|
+
{content}
|
|
249
|
+
{this.footer()}
|
|
250
|
+
</ModalDialog>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
`,
|
|
255
|
+
'should invoke Footer of a modal dialog declared as class component',
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
defineInlineTest(
|
|
259
|
+
{ default: transformer, parser },
|
|
260
|
+
{},
|
|
261
|
+
`
|
|
262
|
+
import React from 'react';
|
|
263
|
+
|
|
264
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
265
|
+
|
|
266
|
+
class CustomModalDialog extends React.Component {
|
|
267
|
+
footer = (props) => (<div>{props.children}</div>);
|
|
268
|
+
|
|
269
|
+
render() {
|
|
270
|
+
return (
|
|
271
|
+
<ModalDialog onClose={handleClose} footer={this.footer}>
|
|
272
|
+
{content}
|
|
273
|
+
</ModalDialog>
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
`,
|
|
278
|
+
`
|
|
279
|
+
import React from 'react';
|
|
280
|
+
|
|
281
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
282
|
+
|
|
283
|
+
class CustomModalDialog extends React.Component {
|
|
284
|
+
footer = (props) => (<div>{props.children}</div>);
|
|
285
|
+
|
|
286
|
+
render() {
|
|
287
|
+
return (
|
|
288
|
+
<ModalDialog onClose={handleClose} footer={this.footer}>
|
|
289
|
+
{content}
|
|
290
|
+
{this.footer()}
|
|
291
|
+
</ModalDialog>
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
`,
|
|
296
|
+
'should invoke Footer passed to the footer prop',
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
defineInlineTest(
|
|
300
|
+
{ default: transformer, parser },
|
|
301
|
+
{},
|
|
302
|
+
`
|
|
303
|
+
import React from 'react';
|
|
304
|
+
|
|
305
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
306
|
+
|
|
307
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
308
|
+
|
|
309
|
+
class CustomModalDialog extends React.Component {
|
|
310
|
+
footer = (props) => (<div>{props.children}</div>);
|
|
311
|
+
|
|
312
|
+
render() {
|
|
313
|
+
return (
|
|
314
|
+
<ModalDialog
|
|
315
|
+
onClose={handleClose}
|
|
316
|
+
components={{
|
|
317
|
+
Header,
|
|
318
|
+
Footer: this.footer
|
|
319
|
+
}}
|
|
320
|
+
footer={({ testId, onClose }) => (
|
|
321
|
+
<div data-testid={testId}>
|
|
322
|
+
<button onClose={onClose}>Custom footer</button>
|
|
323
|
+
</div>
|
|
324
|
+
)}
|
|
325
|
+
>
|
|
326
|
+
{content}
|
|
327
|
+
</ModalDialog>
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
`,
|
|
332
|
+
`
|
|
333
|
+
import React from 'react';
|
|
334
|
+
|
|
335
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
336
|
+
|
|
337
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
338
|
+
|
|
339
|
+
class CustomModalDialog extends React.Component {
|
|
340
|
+
footer = (props) => (<div>{props.children}</div>);
|
|
341
|
+
|
|
342
|
+
render() {
|
|
343
|
+
return (
|
|
344
|
+
<ModalDialog
|
|
345
|
+
onClose={handleClose}
|
|
346
|
+
components={{
|
|
347
|
+
Header
|
|
348
|
+
}}
|
|
349
|
+
footer={({ testId, onClose }) => (
|
|
350
|
+
<div data-testid={testId}>
|
|
351
|
+
<button onClose={onClose}>Custom footer</button>
|
|
352
|
+
</div>
|
|
353
|
+
)}>
|
|
354
|
+
{content}
|
|
355
|
+
{this.footer()}
|
|
356
|
+
</ModalDialog>
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
`,
|
|
361
|
+
'should take Footer passed from components prop if both declarations exist',
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
defineInlineTest(
|
|
365
|
+
{ default: transformer, parser },
|
|
366
|
+
{},
|
|
367
|
+
`
|
|
368
|
+
import React from 'react';
|
|
369
|
+
|
|
370
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
371
|
+
|
|
372
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
373
|
+
|
|
374
|
+
class CustomModalDialog extends React.Component {
|
|
375
|
+
footer = (props) => (<div>{props.children}</div>);
|
|
376
|
+
|
|
377
|
+
render() {
|
|
378
|
+
return (
|
|
379
|
+
<ModalDialog
|
|
380
|
+
onClose={handleClose}
|
|
381
|
+
appearance="warning"
|
|
382
|
+
components={{
|
|
383
|
+
Header,
|
|
384
|
+
Footer: this.footer
|
|
385
|
+
}}
|
|
386
|
+
>
|
|
387
|
+
{content}
|
|
388
|
+
</ModalDialog>
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
`,
|
|
393
|
+
`
|
|
394
|
+
import React from 'react';
|
|
395
|
+
|
|
396
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
397
|
+
|
|
398
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
399
|
+
|
|
400
|
+
class CustomModalDialog extends React.Component {
|
|
401
|
+
footer = (props) => (<div>{props.children}</div>);
|
|
402
|
+
|
|
403
|
+
render() {
|
|
404
|
+
return (
|
|
405
|
+
<ModalDialog
|
|
406
|
+
onClose={handleClose}
|
|
407
|
+
appearance="warning"
|
|
408
|
+
components={{
|
|
409
|
+
Header
|
|
410
|
+
}}>
|
|
411
|
+
{content}
|
|
412
|
+
{this.footer({
|
|
413
|
+
appearance: "warning"
|
|
414
|
+
})}
|
|
415
|
+
</ModalDialog>
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
`,
|
|
420
|
+
'should pass appearance set as string literal from parent ModalDialog to custom footer as argument',
|
|
421
|
+
);
|
|
422
|
+
|
|
423
|
+
defineInlineTest(
|
|
424
|
+
{ default: transformer, parser },
|
|
425
|
+
{},
|
|
426
|
+
`
|
|
427
|
+
import React from 'react';
|
|
428
|
+
|
|
429
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
430
|
+
|
|
431
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
432
|
+
|
|
433
|
+
class CustomModalDialog extends React.Component {
|
|
434
|
+
footer = (props) => (<div>{props.children}</div>);
|
|
435
|
+
|
|
436
|
+
render() {
|
|
437
|
+
return (
|
|
438
|
+
<ModalDialog
|
|
439
|
+
onClose={handleClose}
|
|
440
|
+
appearance={modalDialogAppearance}
|
|
441
|
+
components={{
|
|
442
|
+
Header,
|
|
443
|
+
Footer: this.footer
|
|
444
|
+
}}
|
|
445
|
+
>
|
|
446
|
+
{content}
|
|
447
|
+
</ModalDialog>
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
`,
|
|
452
|
+
`
|
|
453
|
+
import React from 'react';
|
|
454
|
+
|
|
455
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
456
|
+
|
|
457
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
458
|
+
|
|
459
|
+
class CustomModalDialog extends React.Component {
|
|
460
|
+
footer = (props) => (<div>{props.children}</div>);
|
|
461
|
+
|
|
462
|
+
render() {
|
|
463
|
+
return (
|
|
464
|
+
<ModalDialog
|
|
465
|
+
onClose={handleClose}
|
|
466
|
+
appearance={modalDialogAppearance}
|
|
467
|
+
components={{
|
|
468
|
+
Header
|
|
469
|
+
}}>
|
|
470
|
+
{content}
|
|
471
|
+
{this.footer({
|
|
472
|
+
appearance: modalDialogAppearance
|
|
473
|
+
})}
|
|
474
|
+
</ModalDialog>
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
`,
|
|
479
|
+
'should pass appearance set as expression from parent ModalDialog to custom footer as argument',
|
|
480
|
+
);
|
|
481
|
+
|
|
482
|
+
defineInlineTest(
|
|
483
|
+
{ default: transformer, parser },
|
|
484
|
+
{},
|
|
485
|
+
`
|
|
486
|
+
import React from 'react';
|
|
487
|
+
|
|
488
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
489
|
+
import SectionMessage from '@atlaskit/section-message';
|
|
490
|
+
|
|
491
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
492
|
+
const FooterComponent = (props) => (<div>{props.children}</div>);
|
|
493
|
+
|
|
494
|
+
export default function modalDialog() {
|
|
495
|
+
return (
|
|
496
|
+
<ModalDialog
|
|
497
|
+
onClose={handleClose}
|
|
498
|
+
appearance="warning"
|
|
499
|
+
components={{
|
|
500
|
+
Header,
|
|
501
|
+
Footer: FooterComponent,
|
|
502
|
+
}}
|
|
503
|
+
>
|
|
504
|
+
<SectionMessage appearance="information">
|
|
505
|
+
{sectionMessage}
|
|
506
|
+
</SectionMessage>
|
|
507
|
+
{content}
|
|
508
|
+
</ModalDialog>
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
`,
|
|
512
|
+
`
|
|
513
|
+
import React from 'react';
|
|
514
|
+
|
|
515
|
+
import ModalDialog from '@atlaskit/modal-dialog';
|
|
516
|
+
import SectionMessage from '@atlaskit/section-message';
|
|
517
|
+
|
|
518
|
+
const Header = (props) => (<div><h1>{props.children}</h1></div>);
|
|
519
|
+
const FooterComponent = (props) => (<div>{props.children}</div>);
|
|
520
|
+
|
|
521
|
+
export default function modalDialog() {
|
|
522
|
+
return (
|
|
523
|
+
<ModalDialog
|
|
524
|
+
onClose={handleClose}
|
|
525
|
+
appearance="warning"
|
|
526
|
+
components={{
|
|
527
|
+
Header
|
|
528
|
+
}}>
|
|
529
|
+
<SectionMessage appearance="information">
|
|
530
|
+
{sectionMessage}
|
|
531
|
+
</SectionMessage>
|
|
532
|
+
{content}
|
|
533
|
+
{FooterComponent({
|
|
534
|
+
appearance: "warning"
|
|
535
|
+
})}
|
|
536
|
+
</ModalDialog>
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
`,
|
|
540
|
+
'should pass appearance attribute ONLY from parent ModalDialog',
|
|
541
|
+
);
|
|
542
|
+
});
|
|
543
|
+
});
|
|
544
|
+
});
|