@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.
Files changed (127) hide show
  1. package/CHANGELOG.md +2111 -0
  2. package/LICENSE +13 -0
  3. package/README.md +13 -0
  4. package/__perf__/default.tsx +42 -0
  5. package/__perf__/interactions.tsx +136 -0
  6. package/__perf__/scroll.tsx +98 -0
  7. package/codemods/12.0.0-lite-mode.ts +51 -0
  8. package/codemods/__tests__/12.0.0-lite-mode.test.ts +493 -0
  9. package/codemods/__tests__/handle-prop-spread.tsx +276 -0
  10. package/codemods/__tests__/inline-WidthNames-declaration.test.ts +260 -0
  11. package/codemods/__tests__/map-actions-prop.tsx +436 -0
  12. package/codemods/__tests__/map-body-from-props.test.ts +645 -0
  13. package/codemods/__tests__/map-container-from-props.test.ts +323 -0
  14. package/codemods/__tests__/map-footer-from-props.test.ts +544 -0
  15. package/codemods/__tests__/map-header-from-props.test.ts +559 -0
  16. package/codemods/__tests__/map-heading-prop.tsx +438 -0
  17. package/codemods/__tests__/remove-appearance-prop.test.ts +79 -0
  18. package/codemods/__tests__/remove-component-override-props.test.ts +153 -0
  19. package/codemods/__tests__/remove-is-chromeless.tsx +182 -0
  20. package/codemods/__tests__/rename-appearance-type.test.ts +52 -0
  21. package/codemods/__tests__/rename-inner-component-prop-types.test.ts +82 -0
  22. package/codemods/__tests__/rename-scrollBehavior-to-shouldScrollInViewport.test.ts +237 -0
  23. package/codemods/internal/constants.tsx +41 -0
  24. package/codemods/internal/utils.tsx +223 -0
  25. package/codemods/migrations/handle-prop-spread.tsx +51 -0
  26. package/codemods/migrations/inline-WidthNames-declaration.ts +92 -0
  27. package/codemods/migrations/map-actions-prop.tsx +430 -0
  28. package/codemods/migrations/map-body-from-props.ts +147 -0
  29. package/codemods/migrations/map-container-from-props.ts +72 -0
  30. package/codemods/migrations/map-footer-from-props.ts +107 -0
  31. package/codemods/migrations/map-header-from-props.ts +101 -0
  32. package/codemods/migrations/map-heading-prop.tsx +193 -0
  33. package/codemods/migrations/remove-appearance-prop.ts +27 -0
  34. package/codemods/migrations/remove-component-override-props.ts +84 -0
  35. package/codemods/migrations/remove-is-chromeless.tsx +42 -0
  36. package/codemods/migrations/rename-appearance-type.ts +9 -0
  37. package/codemods/migrations/rename-inner-component-prop-types.ts +28 -0
  38. package/codemods/migrations/rename-scrollBehavior-to-shouldScrollInViewport.ts +82 -0
  39. package/dist/cjs/hooks.js +22 -0
  40. package/dist/cjs/index.js +63 -0
  41. package/dist/cjs/internal/components/modal-dialog.js +155 -0
  42. package/dist/cjs/internal/components/positioner.js +89 -0
  43. package/dist/cjs/internal/components/scroll-container.js +138 -0
  44. package/dist/cjs/internal/constants.js +48 -0
  45. package/dist/cjs/internal/context.js +13 -0
  46. package/dist/cjs/internal/hooks/use-modal-stack.js +110 -0
  47. package/dist/cjs/internal/hooks/use-on-motion-finish.js +24 -0
  48. package/dist/cjs/internal/hooks/use-prevent-programmatic-scroll.js +55 -0
  49. package/dist/cjs/internal/hooks/use-scroll.js +20 -0
  50. package/dist/cjs/internal/utils.js +35 -0
  51. package/dist/cjs/modal-body.js +66 -0
  52. package/dist/cjs/modal-footer.js +40 -0
  53. package/dist/cjs/modal-header.js +43 -0
  54. package/dist/cjs/modal-title.js +108 -0
  55. package/dist/cjs/modal-transition.js +21 -0
  56. package/dist/cjs/modal-wrapper.js +126 -0
  57. package/dist/cjs/types.js +5 -0
  58. package/dist/cjs/version.json +5 -0
  59. package/dist/es2019/hooks.js +11 -0
  60. package/dist/es2019/index.js +7 -0
  61. package/dist/es2019/internal/components/modal-dialog.js +120 -0
  62. package/dist/es2019/internal/components/positioner.js +78 -0
  63. package/dist/es2019/internal/components/scroll-container.js +97 -0
  64. package/dist/es2019/internal/constants.js +27 -0
  65. package/dist/es2019/internal/context.js +3 -0
  66. package/dist/es2019/internal/hooks/use-modal-stack.js +85 -0
  67. package/dist/es2019/internal/hooks/use-on-motion-finish.js +17 -0
  68. package/dist/es2019/internal/hooks/use-prevent-programmatic-scroll.js +39 -0
  69. package/dist/es2019/internal/hooks/use-scroll.js +11 -0
  70. package/dist/es2019/internal/utils.js +22 -0
  71. package/dist/es2019/modal-body.js +50 -0
  72. package/dist/es2019/modal-footer.js +30 -0
  73. package/dist/es2019/modal-header.js +30 -0
  74. package/dist/es2019/modal-title.js +94 -0
  75. package/dist/es2019/modal-transition.js +10 -0
  76. package/dist/es2019/modal-wrapper.js +88 -0
  77. package/dist/es2019/types.js +1 -0
  78. package/dist/es2019/version.json +5 -0
  79. package/dist/esm/hooks.js +11 -0
  80. package/dist/esm/index.js +7 -0
  81. package/dist/esm/internal/components/modal-dialog.js +131 -0
  82. package/dist/esm/internal/components/positioner.js +76 -0
  83. package/dist/esm/internal/components/scroll-container.js +114 -0
  84. package/dist/esm/internal/constants.js +27 -0
  85. package/dist/esm/internal/context.js +3 -0
  86. package/dist/esm/internal/hooks/use-modal-stack.js +96 -0
  87. package/dist/esm/internal/hooks/use-on-motion-finish.js +16 -0
  88. package/dist/esm/internal/hooks/use-prevent-programmatic-scroll.js +44 -0
  89. package/dist/esm/internal/hooks/use-scroll.js +11 -0
  90. package/dist/esm/internal/utils.js +22 -0
  91. package/dist/esm/modal-body.js +49 -0
  92. package/dist/esm/modal-footer.js +29 -0
  93. package/dist/esm/modal-header.js +29 -0
  94. package/dist/esm/modal-title.js +93 -0
  95. package/dist/esm/modal-transition.js +10 -0
  96. package/dist/esm/modal-wrapper.js +96 -0
  97. package/dist/esm/types.js +1 -0
  98. package/dist/esm/version.json +5 -0
  99. package/dist/types/hooks.d.ts +1 -0
  100. package/dist/types/index.d.ts +8 -0
  101. package/dist/types/internal/components/modal-dialog.d.ts +3 -0
  102. package/dist/types/internal/components/positioner.d.ts +10 -0
  103. package/dist/types/internal/components/scroll-container.d.ts +20 -0
  104. package/dist/types/internal/constants.d.ts +25 -0
  105. package/dist/types/internal/context.d.ts +20 -0
  106. package/dist/types/internal/hooks/use-modal-stack.d.ts +13 -0
  107. package/dist/types/internal/hooks/use-on-motion-finish.d.ts +4 -0
  108. package/dist/types/internal/hooks/use-prevent-programmatic-scroll.d.ts +7 -0
  109. package/dist/types/internal/hooks/use-scroll.d.ts +1 -0
  110. package/dist/types/internal/utils.d.ts +3 -0
  111. package/dist/types/modal-body.d.ts +16 -0
  112. package/dist/types/modal-footer.d.ts +16 -0
  113. package/dist/types/modal-header.d.ts +16 -0
  114. package/dist/types/modal-title.d.ts +26 -0
  115. package/dist/types/modal-transition.d.ts +3 -0
  116. package/dist/types/modal-wrapper.d.ts +5 -0
  117. package/dist/types/types.d.ts +90 -0
  118. package/extract-react-types/modal-attributes.tsx +5 -0
  119. package/hooks/package.json +7 -0
  120. package/modal-body/package.json +7 -0
  121. package/modal-dialog/package.json +7 -0
  122. package/modal-footer/package.json +7 -0
  123. package/modal-header/package.json +7 -0
  124. package/modal-title/package.json +7 -0
  125. package/modal-transition/package.json +7 -0
  126. package/package.json +113 -0
  127. package/types/package.json +7 -0
@@ -0,0 +1,16 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ export interface ModalHeaderProps {
4
+ /**
5
+ * Children of modal dialog header.
6
+ */
7
+ children?: React.ReactNode;
8
+ /**
9
+ * A `testId` prop is provided for specified elements,
10
+ * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
11
+ * serving as a hook for automated tests.
12
+ */
13
+ testId?: string;
14
+ }
15
+ declare const ModalHeader: (props: ModalHeaderProps) => JSX.Element;
16
+ export default ModalHeader;
@@ -0,0 +1,26 @@
1
+ /** @jsx jsx */
2
+ import { ReactNode } from 'react';
3
+ import { Appearance } from './types';
4
+ export interface ModalTitleProps {
5
+ /**
6
+ * Appearance of the modal that changes the color of the primary action and adds an icon to the title.
7
+ */
8
+ appearance?: Appearance;
9
+ /**
10
+ * Children of modal dialog header.
11
+ */
12
+ children?: ReactNode;
13
+ /**
14
+ * When `true` will allow the title to span multiple lines.
15
+ * Defaults to `true`.
16
+ */
17
+ isMultiline?: boolean;
18
+ /**
19
+ * A `testId` prop is provided for specified elements,
20
+ * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
21
+ * serving as a hook for automated tests.
22
+ */
23
+ testId?: string;
24
+ }
25
+ declare const ModalTitle: (props: ModalTitleProps) => JSX.Element;
26
+ export default ModalTitle;
@@ -0,0 +1,3 @@
1
+ import { ExitingPersistenceProps } from '@atlaskit/motion/exiting-persistence';
2
+ declare const ModalTransition: (props: Pick<ExitingPersistenceProps, 'children'>) => JSX.Element;
3
+ export default ModalTransition;
@@ -0,0 +1,5 @@
1
+ /** @jsx jsx */
2
+ import type { ModalDialogProps } from './types';
3
+ export type { ModalDialogProps };
4
+ declare const ModalWrapper: (props: ModalDialogProps) => JSX.Element;
5
+ export default ModalWrapper;
@@ -0,0 +1,90 @@
1
+ import React, { RefObject } from 'react';
2
+ import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
3
+ import type { WidthNames } from './internal/constants';
4
+ export declare type KeyboardOrMouseEvent = React.MouseEvent<any> | React.KeyboardEvent<any> | KeyboardEvent;
5
+ export declare type Appearance = 'danger' | 'warning';
6
+ export declare type OnCloseHandler = (e: KeyboardOrMouseEvent, analyticEvent: UIAnalyticsEvent) => void;
7
+ export declare type OnCloseCompleteHandler = (element: HTMLElement) => void;
8
+ export declare type OnOpenCompleteHandler = (node: HTMLElement, isAppearing: boolean) => void;
9
+ export declare type OnStackChangeHandler = (stackIndex: number) => void;
10
+ export type { ModalHeaderProps } from './modal-header';
11
+ export type { ModalTitleProps } from './modal-title';
12
+ export type { ModalBodyProps } from './modal-body';
13
+ export type { ModalFooterProps } from './modal-footer';
14
+ export type { ModalAttributes } from './internal/context';
15
+ export interface ModalDialogProps {
16
+ /**
17
+ * Focus is moved to the first interactive element inside the modal dialog when `true`.
18
+ * Pass an element `ref` to focus on a specific element.
19
+ */
20
+ autoFocus?: boolean | RefObject<HTMLElement | null | undefined>;
21
+ /**
22
+ * Contents of the modal dialog.
23
+ */
24
+ children?: React.ReactNode;
25
+ /**
26
+ * Height of the modal dialog.
27
+ * When unset the modal dialog will grow to fill the viewport and then start overflowing its contents.
28
+ */
29
+ height?: number | string;
30
+ /**
31
+ * Width of the modal dialog.
32
+ * The recommended way to specify modal width is using named size options.
33
+ */
34
+ width?: number | string | WidthNames;
35
+ /**
36
+ * Callback function called when the modal dialog is requesting to be closed.
37
+ */
38
+ onClose?: OnCloseHandler;
39
+ /**
40
+ * Callback function called when the modal dialog has finished closing.
41
+ */
42
+ onCloseComplete?: OnCloseCompleteHandler;
43
+ /**
44
+ * Callback function called when the modal dialog has finished opening.
45
+ */
46
+ onOpenComplete?: OnOpenCompleteHandler;
47
+ /**
48
+ * Callback function called when the modal changes position in the stack.
49
+ */
50
+ onStackChange?: OnStackChangeHandler;
51
+ /**
52
+ * Will set the scroll boundary to the viewport.
53
+ * If set to false, the scroll boundary is set to the modal dialog body.
54
+ */
55
+ shouldScrollInViewport?: boolean;
56
+ /**
57
+ * Calls `onClose` when clicking the blanket behind the modal dialog.
58
+ */
59
+ shouldCloseOnOverlayClick?: boolean;
60
+ /**
61
+ * Calls `onClose` when pressing escape.
62
+ */
63
+ shouldCloseOnEscapePress?: boolean;
64
+ /**
65
+ * Will remove the blanket tinted background color.
66
+ */
67
+ isBlanketHidden?: boolean;
68
+ /**
69
+ * Number representing where in the stack of modals this modal sits.
70
+ * This offsets the modal dialogs vertical position.
71
+ */
72
+ stackIndex?: number;
73
+ /**
74
+ * A `testId` prop is provided for specified elements,
75
+ * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
76
+ * serving as a hook for automated tests.
77
+
78
+ * If not overridden using `testId` prop in the respective components,
79
+ * this will set `data-testid` on these elements when defined:
80
+
81
+ * - Modal dialog - `{testId}`
82
+ * - Modal header - `{testId}--header`
83
+ * - Modal title - `{testId}--title`
84
+ * - Modal body - `{testId}--body`
85
+ * - Modal footer - `{testId}--footer`
86
+ * - Scrollable element - `{testId}--scrollable`
87
+ * - Blanket - `{testId}--blanket`
88
+ */
89
+ testId?: string;
90
+ }
@@ -0,0 +1,5 @@
1
+ import { ModalAttributes } from '../src/internal/context';
2
+
3
+ export default function ModalAttributesFunction(props: ModalAttributes) {
4
+ return null;
5
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@atlaskit/modal-dialog/hooks",
3
+ "main": "../dist/cjs/hooks.js",
4
+ "module": "../dist/esm/hooks.js",
5
+ "module:es2019": "../dist/es2019/hooks.js",
6
+ "types": "../dist/types/hooks.d.ts"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@atlaskit/modal-dialog/modal-body",
3
+ "main": "../dist/cjs/modal-body.js",
4
+ "module": "../dist/esm/modal-body.js",
5
+ "module:es2019": "../dist/es2019/modal-body.js",
6
+ "types": "../dist/types/modal-body.d.ts"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@atlaskit/modal-dialog/modal-dialog",
3
+ "main": "../dist/cjs/modal-wrapper.js",
4
+ "module": "../dist/esm/modal-wrapper.js",
5
+ "module:es2019": "../dist/es2019/modal-wrapper.js",
6
+ "types": "../dist/types/modal-wrapper.d.ts"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@atlaskit/modal-dialog/modal-footer",
3
+ "main": "../dist/cjs/modal-footer.js",
4
+ "module": "../dist/esm/modal-footer.js",
5
+ "module:es2019": "../dist/es2019/modal-footer.js",
6
+ "types": "../dist/types/modal-footer.d.ts"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@atlaskit/modal-dialog/modal-header",
3
+ "main": "../dist/cjs/modal-header.js",
4
+ "module": "../dist/esm/modal-header.js",
5
+ "module:es2019": "../dist/es2019/modal-header.js",
6
+ "types": "../dist/types/modal-header.d.ts"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@atlaskit/modal-dialog/modal-title",
3
+ "main": "../dist/cjs/modal-title.js",
4
+ "module": "../dist/esm/modal-title.js",
5
+ "module:es2019": "../dist/es2019/modal-title.js",
6
+ "types": "../dist/types/modal-title.d.ts"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@atlaskit/modal-dialog/modal-transition",
3
+ "main": "../dist/cjs/modal-transition.js",
4
+ "module": "../dist/esm/modal-transition.js",
5
+ "module:es2019": "../dist/es2019/modal-transition.js",
6
+ "types": "../dist/types/modal-transition.d.ts"
7
+ }
package/package.json ADDED
@@ -0,0 +1,113 @@
1
+ {
2
+ "name": "@atlaskit/modal-dialog",
3
+ "version": "12.0.2",
4
+ "description": "A modal dialog displays content that requires user interaction, in a layer above the page.",
5
+ "publishConfig": {
6
+ "registry": "https://registry.npmjs.org/"
7
+ },
8
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend",
9
+ "author": "Atlassian Pty Ltd",
10
+ "license": "Apache-2.0",
11
+ "main": "dist/cjs/index.js",
12
+ "module": "dist/esm/index.js",
13
+ "module:es2019": "dist/es2019/index.js",
14
+ "types": "dist/types/index.d.ts",
15
+ "sideEffects": false,
16
+ "af:exports": {
17
+ ".": "./src/index.ts",
18
+ "./types": "./src/types.ts",
19
+ "./hooks": "./src/hooks.ts",
20
+ "./modal-dialog": "./src/modal-wrapper.tsx",
21
+ "./modal-header": "./src/modal-header.tsx",
22
+ "./modal-title": "./src/modal-title.tsx",
23
+ "./modal-body": "./src/modal-body.tsx",
24
+ "./modal-footer": "./src/modal-footer.tsx",
25
+ "./modal-transition": "./src/modal-transition.tsx"
26
+ },
27
+ "atlaskit:src": "src/index.ts",
28
+ "atlassian": {
29
+ "team": "Design System Team",
30
+ "inPublicMirror": true,
31
+ "releaseModel": "scheduled",
32
+ "website": {
33
+ "name": "Modal dialog"
34
+ }
35
+ },
36
+ "scripts": {
37
+ "watch": "tsc --watch --noEmit --project './tsconfig.json'"
38
+ },
39
+ "dependencies": {
40
+ "@atlaskit/analytics-next": "^8.2.0",
41
+ "@atlaskit/blanket": "^12.2.0",
42
+ "@atlaskit/codemod-utils": "^3.4.0",
43
+ "@atlaskit/ds-lib": "^1.3.0",
44
+ "@atlaskit/focus-ring": "0.2.2",
45
+ "@atlaskit/icon": "^21.9.0",
46
+ "@atlaskit/motion": "^1.0.0",
47
+ "@atlaskit/portal": "^4.1.0",
48
+ "@atlaskit/theme": "^12.0.0",
49
+ "@babel/runtime": "^7.0.0",
50
+ "@emotion/core": "^10.0.9",
51
+ "raf-schd": "^2.1.0",
52
+ "react-focus-lock": "^1.19.1",
53
+ "react-scrolllock": "^5.0.1",
54
+ "react-uid": "^2.2.0"
55
+ },
56
+ "peerDependencies": {
57
+ "react": "^16.8.0"
58
+ },
59
+ "devDependencies": {
60
+ "@atlaskit/avatar": "*",
61
+ "@atlaskit/avatar-group": "*",
62
+ "@atlaskit/breadcrumbs": "*",
63
+ "@atlaskit/build-utils": "*",
64
+ "@atlaskit/button": "*",
65
+ "@atlaskit/checkbox": "*",
66
+ "@atlaskit/datetime-picker": "*",
67
+ "@atlaskit/docs": "*",
68
+ "@atlaskit/dropdown-menu": "*",
69
+ "@atlaskit/flag": "*",
70
+ "@atlaskit/form": "*",
71
+ "@atlaskit/inline-dialog": "*",
72
+ "@atlaskit/popup": "*",
73
+ "@atlaskit/radio": "*",
74
+ "@atlaskit/section-message": "*",
75
+ "@atlaskit/select": "*",
76
+ "@atlaskit/ssr": "*",
77
+ "@atlaskit/textfield": "*",
78
+ "@atlaskit/tooltip": "*",
79
+ "@atlaskit/visual-regression": "*",
80
+ "@atlaskit/webdriver-runner": "*",
81
+ "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
82
+ "@testing-library/dom": "^7.7.3",
83
+ "@testing-library/react": "^8.0.1",
84
+ "@testing-library/react-hooks": "^1.0.4",
85
+ "@types/react-beautiful-dnd": "^11.0.1",
86
+ "jscodeshift": "^0.13.0",
87
+ "react-beautiful-dnd": "^12.1.1",
88
+ "react-dom": "^16.8.0",
89
+ "react-lorem-component": "^0.13.0",
90
+ "storybook-addon-performance": "^0.16.0",
91
+ "typescript": "3.9.6",
92
+ "wait-for-expect": "^1.2.0"
93
+ },
94
+ "keywords": [
95
+ "atlaskit",
96
+ "react",
97
+ "ui"
98
+ ],
99
+ "techstack": {
100
+ "@atlassian/frontend": {
101
+ "import-structure": "atlassian-conventions"
102
+ },
103
+ "@repo/internal": {
104
+ "ui-components": "lite-mode",
105
+ "analytics": "analytics-next",
106
+ "theming": "new-theming-api",
107
+ "deprecation": "no-deprecated-imports",
108
+ "styling": "emotion"
109
+ }
110
+ },
111
+ "homepage": "https://atlassian.design/components/modal-dialog/",
112
+ "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
113
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@atlaskit/modal-dialog/types",
3
+ "main": "../dist/cjs/types.js",
4
+ "module": "../dist/esm/types.js",
5
+ "module:es2019": "../dist/es2019/types.js",
6
+ "types": "../dist/types/types.d.ts"
7
+ }