@atlaskit/modal-dialog 12.20.2 → 12.20.4

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 (40) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/internal/components/positioner.js +2 -1
  3. package/dist/cjs/modal-wrapper.js +1 -1
  4. package/dist/es2019/internal/components/positioner.js +3 -2
  5. package/dist/es2019/modal-wrapper.js +1 -1
  6. package/dist/esm/internal/components/positioner.js +3 -2
  7. package/dist/esm/modal-wrapper.js +1 -1
  8. package/package.json +4 -4
  9. package/codemods/12.0.0-lite-mode.tsx +0 -48
  10. package/codemods/__tests__/12.0.0-lite-mode.test.tsx +0 -493
  11. package/codemods/__tests__/handle-prop-spread.tsx +0 -276
  12. package/codemods/__tests__/inline-width-names-declaration.test.tsx +0 -260
  13. package/codemods/__tests__/map-actions-prop.tsx +0 -436
  14. package/codemods/__tests__/map-body-from-props.test.tsx +0 -645
  15. package/codemods/__tests__/map-container-from-props.test.tsx +0 -323
  16. package/codemods/__tests__/map-footer-from-props.test.tsx +0 -544
  17. package/codemods/__tests__/map-header-from-props.test.tsx +0 -559
  18. package/codemods/__tests__/map-heading-prop.tsx +0 -438
  19. package/codemods/__tests__/remove-appearance-prop.test.tsx +0 -79
  20. package/codemods/__tests__/remove-component-override-props.test.tsx +0 -153
  21. package/codemods/__tests__/remove-is-chromeless.tsx +0 -182
  22. package/codemods/__tests__/rename-appearance-type.test.tsx +0 -52
  23. package/codemods/__tests__/rename-inner-component-prop-types.test.tsx +0 -82
  24. package/codemods/__tests__/rename-scroll-behavior-to-should-scroll-in-viewport.test.tsx +0 -235
  25. package/codemods/internal/constants.tsx +0 -41
  26. package/codemods/internal/utils.tsx +0 -186
  27. package/codemods/migrations/handle-prop-spread.tsx +0 -48
  28. package/codemods/migrations/inline-width-names-declaration.tsx +0 -81
  29. package/codemods/migrations/map-actions-prop.tsx +0 -391
  30. package/codemods/migrations/map-body-from-props.tsx +0 -122
  31. package/codemods/migrations/map-container-from-props.tsx +0 -51
  32. package/codemods/migrations/map-footer-from-props.tsx +0 -89
  33. package/codemods/migrations/map-header-from-props.tsx +0 -82
  34. package/codemods/migrations/map-heading-prop.tsx +0 -167
  35. package/codemods/migrations/remove-appearance-prop.tsx +0 -26
  36. package/codemods/migrations/remove-component-override-props.tsx +0 -72
  37. package/codemods/migrations/remove-is-chromeless.tsx +0 -36
  38. package/codemods/migrations/rename-appearance-type.tsx +0 -9
  39. package/codemods/migrations/rename-inner-component-prop-types.tsx +0 -25
  40. package/codemods/migrations/rename-scroll-behavior-to-should-scroll-in-viewport.tsx +0 -66
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/modal-dialog
2
2
 
3
+ ## 12.20.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#113859](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/113859)
8
+ [`c14cf08cfe2e9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c14cf08cfe2e9) -
9
+ Remove old codemods.
10
+
11
+ ## 12.20.3
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 12.20.2
4
18
 
5
19
  ### Patch Changes
@@ -58,7 +58,8 @@ var bodyScrollStyles = (0, _react.css)((0, _defineProperty2.default)({}, _primit
58
58
  pointerEvents: 'none'
59
59
  }));
60
60
  var stackTransitionStyles = (0, _react.css)({
61
- transitionDuration: "".concat(_durations.mediumDurationMs, "ms"),
61
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
62
+ transitionDuration: "".concat(_durations.durations.medium, "ms"),
62
63
  transitionProperty: 'transform',
63
64
  transitionTimingFunction: _curves.easeInOut,
64
65
  /**
@@ -108,7 +108,7 @@ var ModalWrapper = function ModalWrapper(props) {
108
108
  action: 'closed',
109
109
  componentName: 'modalDialog',
110
110
  packageName: "@atlaskit/modal-dialog",
111
- packageVersion: "12.20.2"
111
+ packageVersion: "12.20.4"
112
112
  });
113
113
  var onBlanketClicked = (0, _react.useCallback)(function (e) {
114
114
  if (shouldCloseOnOverlayClick) {
@@ -7,7 +7,7 @@
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { easeInOut } from '@atlaskit/motion/curves';
10
- import { mediumDurationMs } from '@atlaskit/motion/durations';
10
+ import { durations } from '@atlaskit/motion/durations';
11
11
  import { media } from '@atlaskit/primitives';
12
12
  import { layers } from '@atlaskit/theme/constants';
13
13
  import { gutter, verticalOffset } from '../constants';
@@ -53,7 +53,8 @@ const bodyScrollStyles = css({
53
53
  }
54
54
  });
55
55
  const stackTransitionStyles = css({
56
- transitionDuration: `${mediumDurationMs}ms`,
56
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
57
+ transitionDuration: `${durations.medium}ms`,
57
58
  transitionProperty: 'transform',
58
59
  transitionTimingFunction: easeInOut,
59
60
  /**
@@ -93,7 +93,7 @@ const ModalWrapper = props => {
93
93
  action: 'closed',
94
94
  componentName: 'modalDialog',
95
95
  packageName: "@atlaskit/modal-dialog",
96
- packageVersion: "12.20.2"
96
+ packageVersion: "12.20.4"
97
97
  });
98
98
  const onBlanketClicked = useCallback(e => {
99
99
  if (shouldCloseOnOverlayClick) {
@@ -8,7 +8,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
9
  import { css, jsx } from '@emotion/react';
10
10
  import { easeInOut } from '@atlaskit/motion/curves';
11
- import { mediumDurationMs } from '@atlaskit/motion/durations';
11
+ import { durations } from '@atlaskit/motion/durations';
12
12
  import { media } from '@atlaskit/primitives';
13
13
  import { layers } from '@atlaskit/theme/constants';
14
14
  import { gutter, verticalOffset } from '../constants';
@@ -51,7 +51,8 @@ var bodyScrollStyles = css(_defineProperty({}, media.above.xs, {
51
51
  pointerEvents: 'none'
52
52
  }));
53
53
  var stackTransitionStyles = css({
54
- transitionDuration: "".concat(mediumDurationMs, "ms"),
54
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
55
+ transitionDuration: "".concat(durations.medium, "ms"),
55
56
  transitionProperty: 'transform',
56
57
  transitionTimingFunction: easeInOut,
57
58
  /**
@@ -98,7 +98,7 @@ var ModalWrapper = function ModalWrapper(props) {
98
98
  action: 'closed',
99
99
  componentName: 'modalDialog',
100
100
  packageName: "@atlaskit/modal-dialog",
101
- packageVersion: "12.20.2"
101
+ packageVersion: "12.20.4"
102
102
  });
103
103
  var onBlanketClicked = useCallback(function (e) {
104
104
  if (shouldCloseOnOverlayClick) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/modal-dialog",
3
- "version": "12.20.2",
3
+ "version": "12.20.4",
4
4
  "description": "A modal dialog displays content that requires user interaction, in a layer above the page.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -33,13 +33,13 @@
33
33
  "@atlaskit/codemod-utils": "^4.2.0",
34
34
  "@atlaskit/ds-lib": "^3.5.0",
35
35
  "@atlaskit/focus-ring": "^2.1.0",
36
- "@atlaskit/icon": "^23.7.0",
36
+ "@atlaskit/icon": "^23.9.0",
37
37
  "@atlaskit/layering": "^1.1.0",
38
- "@atlaskit/motion": "^1.10.0",
38
+ "@atlaskit/motion": "^2.0.0",
39
39
  "@atlaskit/platform-feature-flags": "^1.0.0",
40
40
  "@atlaskit/portal": "^4.11.0",
41
41
  "@atlaskit/pragmatic-drag-and-drop": "^1.5.0",
42
- "@atlaskit/primitives": "^13.4.0",
42
+ "@atlaskit/primitives": "^13.5.0",
43
43
  "@atlaskit/theme": "^15.0.0",
44
44
  "@atlaskit/tokens": "^3.3.0",
45
45
  "@babel/runtime": "^7.0.0",
@@ -1,48 +0,0 @@
1
- import { type JSCodeshift } from 'jscodeshift';
2
- import { type Collection } from 'jscodeshift/src/Collection';
3
-
4
- import { createTransformer, hasImportDeclaration } from '@atlaskit/codemod-utils';
5
-
6
- import { handlePropSpread } from './migrations/handle-prop-spread';
7
- import { inlineWidthNamesDeclaration } from './migrations/inline-width-names-declaration';
8
- import { mapActionsProp } from './migrations/map-actions-prop';
9
- import { mapBodyFromProps } from './migrations/map-body-from-props';
10
- import { mapContainerFromProps } from './migrations/map-container-from-props';
11
- import { mapFooterFromProps } from './migrations/map-footer-from-props';
12
- import { mapHeaderFromProps } from './migrations/map-header-from-props';
13
- import { mapHeadingPropToModalTitle } from './migrations/map-heading-prop';
14
- import { removeAppearanceProp } from './migrations/remove-appearance-prop';
15
- import { removeComponentOverrideProps } from './migrations/remove-component-override-props';
16
- import { removeIsChromeless } from './migrations/remove-is-chromeless';
17
- import { renameAppearanceType } from './migrations/rename-appearance-type';
18
- import { renameInnerComponentPropTypes } from './migrations/rename-inner-component-prop-types';
19
- import { renameScrollBehaviorToShouldScrollInViewport } from './migrations/rename-scroll-behavior-to-should-scroll-in-viewport';
20
-
21
- /**
22
- * The order of these migrations matters!
23
- * Mapping the container usage, along with removal of key props
24
- * such as the 'components' and 'appearance' should come last
25
- * after the other migrations.
26
- */
27
- const transformer = createTransformer(
28
- [
29
- mapBodyFromProps,
30
- mapHeaderFromProps,
31
- mapFooterFromProps,
32
- renameScrollBehaviorToShouldScrollInViewport,
33
- renameAppearanceType,
34
- renameInnerComponentPropTypes,
35
- inlineWidthNamesDeclaration,
36
- mapHeadingPropToModalTitle,
37
- mapActionsProp,
38
- mapContainerFromProps,
39
- removeComponentOverrideProps,
40
- removeAppearanceProp,
41
- removeIsChromeless,
42
- handlePropSpread,
43
- ],
44
- (j: JSCodeshift, source: Collection<Node>) =>
45
- hasImportDeclaration(j, source, '@atlaskit/modal-dialog'),
46
- );
47
-
48
- export default transformer;
@@ -1,493 +0,0 @@
1
- import transformer from '../12.0.0-lite-mode';
2
-
3
- const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
4
-
5
- describe('12.0.0-lite-mode', () => {
6
- ['tsx', 'babylon'].forEach((parser) => {
7
- describe(`parser: ${parser}`, () => {
8
- defineInlineTest(
9
- { default: transformer, parser },
10
- {},
11
- `
12
- import React, { useState } from 'react';
13
-
14
- import ModalDialog from '@atlaskit/modal-dialog';
15
-
16
- const Container = (props) => (<form>{props.children}</form>);
17
- const Header = (props) => (<div><h1>{props.children}</h1></div>);
18
- const Footer = (props) => (<div>{props.children}</div>);
19
-
20
- export default function modalDialog() {
21
- const [appearance, setAppearance] = useState(null);
22
-
23
- return (
24
- <ModalDialog
25
- appearance={appearance}
26
- scrollBehavior="outside"
27
- onClose={noop}
28
- components={{ Container }}
29
- header={Header}
30
- footer={Footer}>
31
- <p>Content #1</p>
32
- <p>Content #2</p>
33
- </ModalDialog>
34
- );
35
- }
36
- `,
37
- `
38
- /* TODO: (from codemod)\u0020
39
- We have converted this file as best we could but you might still need
40
- to manually complete migrating this usage of ModalDialog.
41
-
42
- This file uses one or more of the following ModalDialog props: 'components', 'header',
43
- 'footer', 'body'. These props have been removed as part of moving to
44
- a compositional API.
45
-
46
- The render props that used to be exposed by the custom component APIs are
47
- now accessible using the 'useModal' hook instead: 'testId', 'titleId', and 'onClose'.
48
-
49
- We are also no longer exposing 'appearance' as render prop, so this needs to be
50
- manually passed to your custom components.
51
-
52
- If you are using the 'container' value of 'components' to wrap ModalDialog in something
53
- other than a 'form', you'll need to add the style 'all: inherit;' for scrolling to function.
54
-
55
- For a complete guide on customization using the new compositional API, refer to the docs at
56
- https://atlassian.design/components/modal-dialog/examples. */
57
- import React, { useState } from 'react';
58
-
59
- import ModalDialog, { ModalBody } from "@atlaskit/modal-dialog";
60
-
61
- const Container = (props) => (<form>{props.children}</form>);
62
- const Header = (props) => (<div><h1>{props.children}</h1></div>);
63
- const Footer = (props) => (<div>{props.children}</div>);
64
-
65
- export default function modalDialog() {
66
- const [appearance, setAppearance] = useState(null);
67
-
68
- return (
69
- <ModalDialog shouldScrollInViewport onClose={noop}>
70
- {Container({
71
- children: <>
72
- {Header({
73
- appearance: appearance
74
- })}
75
- <ModalBody>
76
- <p>Content #1</p>
77
- <p>Content #2</p>
78
- </ModalBody>
79
- {Footer({
80
- appearance: appearance
81
- })}
82
- </>
83
- })}
84
- </ModalDialog>
85
- );
86
- }
87
- `,
88
- 'should change custom usages in the appropriate order',
89
- );
90
-
91
- defineInlineTest(
92
- { default: transformer, parser },
93
- {},
94
- `
95
- import React, { useState } from 'react';
96
-
97
- import ModalDialog, {
98
- AppearanceType,
99
- HeaderComponentProps,
100
- FooterComponentProps,
101
- BodyComponentProps
102
- } from '@atlaskit/modal-dialog';
103
-
104
- const Container = (props) => (<form>{props.children}</form>);
105
- const Header = (props: HeaderComponentProps) => (<div><h1>{props.children}</h1></div>);
106
- const Footer = (props: FooterComponentProps) => (<div>{props.children}</div>);
107
-
108
- export default function modalDialog() {
109
- const [appearance, setAppearance] = useState<AppearanceType | null>(null);
110
-
111
- return (
112
- <ModalDialog
113
- appearance={appearance}
114
- scrollBehavior="outside"
115
- onClose={noop}
116
- components={{ Container }}
117
- header={Header}
118
- footer={Footer} />
119
- );
120
- }
121
- `,
122
- `
123
- /* TODO: (from codemod)\u0020
124
- We have converted this file as best we could but you might still need
125
- to manually complete migrating this usage of ModalDialog.
126
-
127
- This file uses one or more of the following ModalDialog props: 'components', 'header',
128
- 'footer', 'body'. These props have been removed as part of moving to
129
- a compositional API.
130
-
131
- The render props that used to be exposed by the custom component APIs are
132
- now accessible using the 'useModal' hook instead: 'testId', 'titleId', and 'onClose'.
133
-
134
- We are also no longer exposing 'appearance' as render prop, so this needs to be
135
- manually passed to your custom components.
136
-
137
- If you are using the 'container' value of 'components' to wrap ModalDialog in something
138
- other than a 'form', you'll need to add the style 'all: inherit;' for scrolling to function.
139
-
140
- For a complete guide on customization using the new compositional API, refer to the docs at
141
- https://atlassian.design/components/modal-dialog/examples. */
142
- import React, { useState } from 'react';
143
-
144
- import ModalDialog, {
145
- Appearance as AppearanceType,
146
- ModalHeaderProps as HeaderComponentProps,
147
- ModalFooterProps as FooterComponentProps,
148
- ModalBodyProps as BodyComponentProps
149
- } from '@atlaskit/modal-dialog';
150
-
151
- const Container = (props) => (<form>{props.children}</form>);
152
- const Header = (props: HeaderComponentProps) => (<div><h1>{props.children}</h1></div>);
153
- const Footer = (props: FooterComponentProps) => (<div>{props.children}</div>);
154
-
155
- export default function modalDialog() {
156
- const [appearance, setAppearance] = useState<AppearanceType | null>(null);
157
-
158
- return (
159
- <ModalDialog shouldScrollInViewport onClose={noop}>
160
- {Container({
161
- children: <>
162
- {Header({
163
- appearance: appearance
164
- })}{Footer({
165
- appearance: appearance
166
- })}
167
- </>
168
- })}
169
- </ModalDialog>
170
- );
171
- }
172
- `,
173
- 'should change custom usages for a self-closing modal without body',
174
- );
175
-
176
- defineInlineTest(
177
- { default: transformer, parser },
178
- {},
179
- `
180
- import React, { useState } from 'react';
181
-
182
- import ModalDialog, { ModalTransition } from '@atlaskit/modal-dialog';
183
-
184
- export default function modalDialog(props) {
185
- const [isOpen, toggleOpen] = useState<boolean>(false);
186
- const { appearance, multiline, onClose } = props;
187
-
188
- const actions = [
189
- { text: 'Close', onClick: close, testId: 'primary' },
190
- {
191
- text: 'Secondary Action',
192
- onClick: noop,
193
- testId: 'secondary',
194
- },
195
- ];
196
-
197
- return (
198
- <ModalTransition>
199
- {isOpen &&
200
- <ModalDialog
201
- appearance={appearance}
202
- actions={actions}
203
- onClose={onClose}
204
- heading="Modal dialog"
205
- isHeadingMultiline={multiline}
206
- isChromeless={false}
207
- scrollBehavior="outside"
208
- {...props}
209
- >
210
- <div>Content #1</div>
211
- <div>Content #2</div>
212
- </ModalDialog>
213
- }
214
- </ModalTransition>
215
- );
216
- }
217
- `,
218
- `
219
- /* TODO: (from codemod)\u0020
220
- This file is spreading props on the ModalDialog component, so we could not
221
- automatically convert this usage to the new API.
222
-
223
- The following props have been deprecated as part of moving to a compositional API:
224
-
225
- - 'heading' prop has been replaced by ModalHeader and ModalTitle components.
226
- - 'actions' prop has been replaced by ModalFooter component, with Button components from @atlaskit/button.
227
- - 'scrollBehavior' prop has been replaced by 'shouldScrollInViewport', where "outside" from the previous prop maps to true in the new prop.
228
- - 'isHeadingMultiline' prop has been replaced by 'isMultiline' prop on the ModalTitle component.
229
- - '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.
230
-
231
- Refer to the docs for the new API at https://atlassian.design/components/modal-dialog/examples
232
- to complete the migration and use the new composable components. */
233
- import React, { useState } from 'react';
234
-
235
- import Button from "@atlaskit/button/standard-button";
236
- import ModalDialog, { ModalTransition, ModalBody, ModalTitle, ModalHeader, ModalFooter } from "@atlaskit/modal-dialog";
237
-
238
- export default function modalDialog(props) {
239
- const [isOpen, toggleOpen] = useState<boolean>(false);
240
- const { appearance, multiline, onClose } = props;
241
-
242
- const actions = [
243
- { text: 'Close', onClick: close, testId: 'primary' },
244
- {
245
- text: 'Secondary Action',
246
- onClick: noop,
247
- testId: 'secondary',
248
- },
249
- ];
250
-
251
- return (
252
- <ModalTransition>
253
- {isOpen &&
254
- <ModalDialog onClose={onClose} shouldScrollInViewport {...props}>
255
- <ModalHeader>
256
- <ModalTitle appearance={appearance} isMultiline={multiline}>
257
- Modal dialog
258
- </ModalTitle>
259
- </ModalHeader>
260
-
261
- <ModalBody>
262
- <div>Content #1</div>
263
- <div>Content #2</div>
264
- </ModalBody>
265
- <ModalFooter>
266
- {actions.map((props, index) => <Button
267
- {...props}
268
- autoFocus={index === 0}
269
- appearance={index === 0 ? appearance || "primary" : "subtle"}>{props.text}</Button>).reverse()}
270
- </ModalFooter>
271
- </ModalDialog>
272
- }
273
- </ModalTransition>
274
- );
275
- }
276
- `,
277
- 'should change default usages for modal dialog',
278
- );
279
-
280
- defineInlineTest(
281
- { default: transformer, parser },
282
- {},
283
- `
284
- import React, { useState } from 'react';
285
-
286
- import ModalDialog, { ModalTransition, ModalBody } from '@atlaskit/modal-dialog';
287
-
288
- import { getModalDialogActions } from './utils';
289
-
290
- const Container = (props) => (<form>{props.children}</form>);
291
- const CustomBody = (props) => (<div><ModalBody>{props.children}</ModalBody></div>);
292
-
293
- export default function modalDialog(props) {
294
- const [isOpen, toggleOpen] = useState<boolean>(false);
295
- const { appearance, onClose } = props;
296
-
297
- return (
298
- <ModalTransition>
299
- {isOpen &&
300
- <ModalDialog
301
- components={{ Container, Body: CustomBody }}
302
- actions={getModalDialogActions(onClose)}
303
- onClose={onClose}
304
- heading="Modal dialog"
305
- isChromeless={true}
306
- scrollBehavior="outside"
307
- >
308
- <div>Content #1</div>
309
- <div>Content #2</div>
310
- </ModalDialog>
311
- }
312
- </ModalTransition>
313
- );
314
- }
315
- `,
316
- `
317
- /* TODO: (from codemod)\u0020
318
- We have converted this file as best we could but you might still need
319
- to manually complete migrating this usage of ModalDialog.
320
-
321
- This file uses one or more of the following ModalDialog props: 'components', 'header',
322
- 'footer', 'body'. These props have been removed as part of moving to
323
- a compositional API.
324
-
325
- The render props that used to be exposed by the custom component APIs are
326
- now accessible using the 'useModal' hook instead: 'testId', 'titleId', and 'onClose'.
327
-
328
- We are also no longer exposing 'appearance' as render prop, so this needs to be
329
- manually passed to your custom components.
330
-
331
- If you are using the 'container' value of 'components' to wrap ModalDialog in something
332
- other than a 'form', you'll need to add the style 'all: inherit;' for scrolling to function.
333
-
334
- For a complete guide on customization using the new compositional API, refer to the docs at
335
- https://atlassian.design/components/modal-dialog/examples. */
336
- import React, { useState } from 'react';
337
-
338
- import Button from "@atlaskit/button/standard-button";
339
- import ModalDialog, { ModalTransition, ModalBody, ModalTitle, ModalHeader, ModalFooter } from "@atlaskit/modal-dialog";
340
-
341
- import { getModalDialogActions } from './utils';
342
-
343
- const Container = (props) => (<form>{props.children}</form>);
344
- const CustomBody = (props) => (<div><ModalBody>{props.children}</ModalBody></div>);
345
-
346
- export default function modalDialog(props) {
347
- const [isOpen, toggleOpen] = useState<boolean>(false);
348
- const { appearance, onClose } = props;
349
-
350
- return (
351
- <ModalTransition>
352
- {isOpen &&
353
- /* TODO: (from codemod)\u0020
354
- ModalDialog has a new compositional API and the 'isChromeless' prop is no longer supported.
355
- To have the functionality of the 'isChromeless' prop, you can choose to not use any of the default exports (ModalBody, ModalHeader and ModalFooter).
356
- The only other change is that ModalDialog's children should have a border radius of 3px to match the box shadow.
357
- For more information, check the documentation at https://atlassian.design/components/modal-dialog/examples */
358
- <ModalDialog onClose={onClose} shouldScrollInViewport>
359
- {Container({
360
- children: <>
361
- <ModalHeader>
362
- <ModalTitle>
363
- Modal dialog
364
- </ModalTitle>
365
- </ModalHeader>
366
-
367
- {CustomBody({
368
- children: <>
369
- <div>Content #1</div>
370
- <div>Content #2</div>
371
- </>
372
- })}
373
- <ModalFooter>
374
- {getModalDialogActions(onClose).map((props, index) => <Button
375
- {...props}
376
- appearance={index === 0 ? props.appearance || "primary" : props.appearance || "subtle"}>{props.text}</Button>)}
377
- </ModalFooter>
378
- </>
379
- })}
380
- </ModalDialog>
381
- }
382
- </ModalTransition>
383
- );
384
- }
385
- `,
386
- 'should change mixed usages (custom + default) for modal dialog',
387
- );
388
- });
389
- });
390
-
391
- // Only support ts for this case
392
- defineInlineTest(
393
- { default: transformer, parser: 'tsx' },
394
- {},
395
- `
396
- import React, { useState } from 'react';
397
-
398
- import ModalDialog, {
399
- AppearanceType,
400
- HeaderComponentProps,
401
- FooterComponentProps,
402
- } from '@atlaskit/modal-dialog';
403
-
404
- import { WidthNames } from '@atlaskit/modal-dialog/shared-variables';
405
-
406
- interface CustomHeaderProps extends HeaderComponentProps {
407
- size?: WidthNames;
408
- }
409
-
410
- const Container = (props) => (<form>{props.children}</form>);
411
- const Header = (props: CustomHeaderProps) => (<div><h1>{props.children}</h1></div>);
412
- const Footer = (props: FooterComponentProps) => (<div>{props.children}</div>);
413
-
414
- export default function modalDialog() {
415
- const [appearance, setAppearance] = useState<AppearanceType | null>(null);
416
-
417
- return (
418
- <ModalDialog
419
- appearance={appearance}
420
- scrollBehavior="outside"
421
- onClose={noop}
422
- components={{ Container }}
423
- header={Header}
424
- footer={Footer}>
425
- <p>Content #1</p>
426
- <p>Content #2</p>
427
- </ModalDialog>
428
- );
429
- }
430
- `,
431
- `
432
- /* TODO: (from codemod)\u0020
433
- We have converted this file as best we could but you might still need
434
- to manually complete migrating this usage of ModalDialog.
435
-
436
- This file uses one or more of the following ModalDialog props: 'components', 'header',
437
- 'footer', 'body'. These props have been removed as part of moving to
438
- a compositional API.
439
-
440
- The render props that used to be exposed by the custom component APIs are
441
- now accessible using the 'useModal' hook instead: 'testId', 'titleId', and 'onClose'.
442
-
443
- We are also no longer exposing 'appearance' as render prop, so this needs to be
444
- manually passed to your custom components.
445
-
446
- If you are using the 'container' value of 'components' to wrap ModalDialog in something
447
- other than a 'form', you'll need to add the style 'all: inherit;' for scrolling to function.
448
-
449
- For a complete guide on customization using the new compositional API, refer to the docs at
450
- https://atlassian.design/components/modal-dialog/examples. */
451
- import React, { useState } from 'react';
452
-
453
- import ModalDialog, {
454
- Appearance as AppearanceType,
455
- ModalHeaderProps as HeaderComponentProps,
456
- ModalFooterProps as FooterComponentProps,
457
- ModalBody,
458
- } from "@atlaskit/modal-dialog";
459
-
460
- interface CustomHeaderProps extends HeaderComponentProps {
461
- size?: "small" | "medium" | "large" | "x-large";
462
- }
463
-
464
- const Container = (props) => (<form>{props.children}</form>);
465
- const Header = (props: CustomHeaderProps) => (<div><h1>{props.children}</h1></div>);
466
- const Footer = (props: FooterComponentProps) => (<div>{props.children}</div>);
467
-
468
- export default function modalDialog() {
469
- const [appearance, setAppearance] = useState<AppearanceType | null>(null);
470
-
471
- return (
472
- <ModalDialog shouldScrollInViewport onClose={noop}>
473
- {Container({
474
- children: <>
475
- {Header({
476
- appearance: appearance
477
- })}
478
- <ModalBody>
479
- <p>Content #1</p>
480
- <p>Content #2</p>
481
- </ModalBody>
482
- {Footer({
483
- appearance: appearance
484
- })}
485
- </>
486
- })}
487
- </ModalDialog>
488
- );
489
- }
490
- `,
491
- 'should change custom usages and types in the appropriate order',
492
- );
493
- });