@atlaskit/portal 4.3.6 → 4.4.1

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 (31) hide show
  1. package/CHANGELOG.md +43 -31
  2. package/dist/cjs/constants.js +2 -4
  3. package/dist/cjs/entry-points/types.js +1 -5
  4. package/dist/cjs/internal/constants.js +3 -6
  5. package/dist/cjs/internal/hooks/use-is-subsequent-render.js +9 -4
  6. package/dist/cjs/internal/hooks/use-isomorphic-layout-effect.js +11 -0
  7. package/dist/cjs/internal/hooks/use-portal-event.js +1 -2
  8. package/dist/cjs/internal/utils/portal-dom-utils.js +4 -7
  9. package/dist/cjs/portal.js +7 -5
  10. package/dist/es2019/entry-points/types.js +0 -1
  11. package/dist/es2019/internal/hooks/use-is-subsequent-render.js +4 -2
  12. package/dist/es2019/internal/hooks/use-isomorphic-layout-effect.js +6 -0
  13. package/dist/es2019/portal.js +6 -6
  14. package/dist/esm/entry-points/types.js +0 -1
  15. package/dist/esm/internal/hooks/use-is-subsequent-render.js +8 -2
  16. package/dist/esm/internal/hooks/use-isomorphic-layout-effect.js +6 -0
  17. package/dist/esm/portal.js +7 -5
  18. package/dist/types/internal/hooks/use-is-subsequent-render.d.ts +2 -1
  19. package/dist/types/internal/hooks/use-isomorphic-layout-effect.d.ts +5 -0
  20. package/dist/types/internal/types.d.ts +1 -0
  21. package/dist/types/portal.d.ts +1 -1
  22. package/dist/types/types.d.ts +6 -1
  23. package/dist/types-ts4.5/internal/hooks/use-is-subsequent-render.d.ts +2 -1
  24. package/dist/types-ts4.5/internal/hooks/use-isomorphic-layout-effect.d.ts +5 -0
  25. package/dist/types-ts4.5/internal/types.d.ts +1 -0
  26. package/dist/types-ts4.5/portal.d.ts +1 -1
  27. package/dist/types-ts4.5/types.d.ts +6 -1
  28. package/package.json +7 -5
  29. package/report.api.md +9 -1
  30. package/types/package.json +1 -1
  31. package/tmp/api-report-tmp.d.ts +0 -46
package/CHANGELOG.md CHANGED
@@ -1,47 +1,59 @@
1
1
  # @atlaskit/portal
2
2
 
3
+ ## 4.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#83116](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83116) [`8d4e99057fe0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8d4e99057fe0) - Upgrade Typescript from `4.9.5` to `5.4.2`
8
+
9
+ ## 4.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#41817](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41817) [`76888385b72`](https://bitbucket.org/atlassian/atlassian-frontend/commits/76888385b72) - Add MountStrategy prop to specify mount strategy
14
+
3
15
  ## 4.3.6
4
16
 
5
17
  ### Patch Changes
6
18
 
7
- - [`f78ae454863`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f78ae454863) - Update tooltip z-index to 9999
19
+ - [#39442](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/39442) [`f78ae454863`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f78ae454863) - Update tooltip z-index to 9999
8
20
  - Updated dependencies
9
21
 
10
22
  ## 4.3.5
11
23
 
12
24
  ### Patch Changes
13
25
 
14
- - [`9af31f3c1ae`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9af31f3c1ae) - Delete version.json
26
+ - [#38731](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/38731) [`9af31f3c1ae`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9af31f3c1ae) - Delete version.json
15
27
 
16
28
  ## 4.3.4
17
29
 
18
30
  ### Patch Changes
19
31
 
20
- - [`33f10b7eb36`](https://bitbucket.org/atlassian/atlassian-frontend/commits/33f10b7eb36) - Removing unused dependencies and dev dependencies
32
+ - [#34445](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/34445) [`33f10b7eb36`](https://bitbucket.org/atlassian/atlassian-frontend/commits/33f10b7eb36) - Removing unused dependencies and dev dependencies
21
33
 
22
34
  ## 4.3.3
23
35
 
24
36
  ### Patch Changes
25
37
 
26
- - [`77766ad157d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/77766ad157d) - Enrol packages to push-model consumption in Jira.
38
+ - [#34124](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/34124) [`77766ad157d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/77766ad157d) - Enrol packages to push-model consumption in Jira.
27
39
 
28
40
  ## 4.3.2
29
41
 
30
42
  ### Patch Changes
31
43
 
32
- - [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
44
+ - [#33793](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33793) [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
33
45
 
34
46
  ## 4.3.1
35
47
 
36
48
  ### Patch Changes
37
49
 
38
- - [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade Typescript from `4.5.5` to `4.9.5`
50
+ - [#33649](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33649) [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade Typescript from `4.5.5` to `4.9.5`
39
51
 
40
52
  ## 4.3.0
41
53
 
42
54
  ### Minor Changes
43
55
 
44
- - [`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip minor dependency bump
56
+ - [#33258](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33258) [`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip minor dependency bump
45
57
 
46
58
  ### Patch Changes
47
59
 
@@ -51,106 +63,106 @@
51
63
 
52
64
  ### Patch Changes
53
65
 
54
- - [`4ba10567310`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4ba10567310) - Internal changes.
66
+ - [#32211](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/32211) [`4ba10567310`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4ba10567310) - Internal changes.
55
67
 
56
68
  ## 4.2.12
57
69
 
58
70
  ### Patch Changes
59
71
 
60
- - [`9827dcb82b8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9827dcb82b8) - No-op change to introduce spacing tokens to design system components.
72
+ - [#26303](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/26303) [`9827dcb82b8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9827dcb82b8) - No-op change to introduce spacing tokens to design system components.
61
73
 
62
74
  ## 4.2.11
63
75
 
64
76
  ### Patch Changes
65
77
 
66
- - [`8cc2f888c83`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8cc2f888c83) - Upgrade Typescript from `4.3.5` to `4.5.5`
78
+ - [#24874](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24874) [`8cc2f888c83`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8cc2f888c83) - Upgrade Typescript from `4.3.5` to `4.5.5`
67
79
 
68
80
  ## 4.2.10
69
81
 
70
82
  ### Patch Changes
71
83
 
72
- - [`8d4228767b0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8d4228767b0) - Upgrade Typescript from `4.2.4` to `4.3.5`.
84
+ - [#24492](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24492) [`8d4228767b0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8d4228767b0) - Upgrade Typescript from `4.2.4` to `4.3.5`.
73
85
 
74
86
  ## 4.2.9
75
87
 
76
88
  ### Patch Changes
77
89
 
78
- - [`d5f0b466415`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d5f0b466415) - Internal code change turning on new linting rules.
90
+ - [#23381](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/23381) [`d5f0b466415`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d5f0b466415) - Internal code change turning on new linting rules.
79
91
 
80
92
  ## 4.2.8
81
93
 
82
94
  ### Patch Changes
83
95
 
84
- - [`8a5bdb3c844`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8a5bdb3c844) - Upgrading internal dependency (bind-event-listener) for improved internal types
96
+ - [#22614](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/22614) [`8a5bdb3c844`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8a5bdb3c844) - Upgrading internal dependency (bind-event-listener) for improved internal types
85
97
 
86
98
  ## 4.2.7
87
99
 
88
100
  ### Patch Changes
89
101
 
90
- - [`cb2392f6d33`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cb2392f6d33) - Upgrade to TypeScript 4.2.4
102
+ - [#20650](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/20650) [`cb2392f6d33`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cb2392f6d33) - Upgrade to TypeScript 4.2.4
91
103
 
92
104
  ## 4.2.6
93
105
 
94
106
  ### Patch Changes
95
107
 
96
- - [`b3e5a62a9e3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b3e5a62a9e3) - Adds `static` techstack to package, enforcing stricter style linting. In this case the package already satisfied this requirement so there have been no changes to styles.
108
+ - [#20033](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/20033) [`b3e5a62a9e3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b3e5a62a9e3) - Adds `static` techstack to package, enforcing stricter style linting. In this case the package already satisfied this requirement so there have been no changes to styles.
97
109
 
98
110
  ## 4.2.5
99
111
 
100
112
  ### Patch Changes
101
113
 
102
- - [`cf853e39278`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cf853e39278) - Retains the portal wrapper in the DOM after the last portal is unmounted. This drastically reduces the style recalculations and improves performance for portalled elements.
114
+ - [#14319](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/14319) [`cf853e39278`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cf853e39278) - Retains the portal wrapper in the DOM after the last portal is unmounted. This drastically reduces the style recalculations and improves performance for portalled elements.
103
115
  - Updated dependencies
104
116
 
105
117
  ## 4.2.4
106
118
 
107
119
  ### Patch Changes
108
120
 
109
- - [`cd34d8ca8ea`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cd34d8ca8ea) - Internal wiring up to the tokens techstack, no code changes.
121
+ - [#13302](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/13302) [`cd34d8ca8ea`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cd34d8ca8ea) - Internal wiring up to the tokens techstack, no code changes.
110
122
 
111
123
  ## 4.2.3
112
124
 
113
125
  ### Patch Changes
114
126
 
115
- - [`ea086afdc2d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ea086afdc2d) - Fix bug where Portal was attached to the body after the children were rendered. Now Portal is attached before it's children are rendered.
127
+ - [#12837](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/12837) [`ea086afdc2d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ea086afdc2d) - Fix bug where Portal was attached to the body after the children were rendered. Now Portal is attached before it's children are rendered.
116
128
  - Updated dependencies
117
129
 
118
130
  ## 4.2.2
119
131
 
120
132
  ### Patch Changes
121
133
 
122
- - [`378d1cef00f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/378d1cef00f) - Bump `@atlaskit/theme` to version `^11.3.0`.
134
+ - [#12880](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/12880) [`378d1cef00f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/378d1cef00f) - Bump `@atlaskit/theme` to version `^11.3.0`.
123
135
 
124
136
  ## 4.2.1
125
137
 
126
138
  ### Patch Changes
127
139
 
128
- - [`d6f7ff383cf`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d6f7ff383cf) - Updates to development dependency `storybook-addon-performance`
140
+ - [#12167](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/12167) [`d6f7ff383cf`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d6f7ff383cf) - Updates to development dependency `storybook-addon-performance`
129
141
 
130
142
  ## 4.2.0
131
143
 
132
144
  ### Minor Changes
133
145
 
134
- - [`f6b951a51f2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f6b951a51f2) - Removes usage of styled-components in favour of standardising on emotion
146
+ - [#12170](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/12170) [`f6b951a51f2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f6b951a51f2) - Removes usage of styled-components in favour of standardising on emotion
135
147
 
136
148
  ## 4.1.2
137
149
 
138
150
  ### Patch Changes
139
151
 
140
- - [`28f40bac160`](https://bitbucket.org/atlassian/atlassian-frontend/commits/28f40bac160) - Updates targets for modal dialog in VR tests.
152
+ - [#10569](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/10569) [`28f40bac160`](https://bitbucket.org/atlassian/atlassian-frontend/commits/28f40bac160) - Updates targets for modal dialog in VR tests.
141
153
 
142
154
  ## 4.1.1
143
155
 
144
156
  ### Patch Changes
145
157
 
146
- - [`8b360a4ac06`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8b360a4ac06) - NO-ISSUE Update modal dialog selector for VR & integration tests
158
+ - [#10230](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/10230) [`8b360a4ac06`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8b360a4ac06) - NO-ISSUE Update modal dialog selector for VR & integration tests
147
159
  - Updated dependencies
148
160
 
149
161
  ## 4.1.0
150
162
 
151
163
  ### Minor Changes
152
164
 
153
- - [`d4f0c36ac36`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d4f0c36ac36) - Converted class based portal component to functional component and dropped unused ie11 specific code
165
+ - [#9083](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/9083) [`d4f0c36ac36`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d4f0c36ac36) - Converted class based portal component to functional component and dropped unused ie11 specific code
154
166
 
155
167
  ### Patch Changes
156
168
 
@@ -161,13 +173,13 @@
161
173
 
162
174
  ### Patch Changes
163
175
 
164
- - [`d3265f19be`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d3265f19be) - Transpile packages using babel rather than tsc
176
+ - [#5857](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/5857) [`d3265f19be`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d3265f19be) - Transpile packages using babel rather than tsc
165
177
 
166
178
  ## 4.0.4
167
179
 
168
180
  ### Patch Changes
169
181
 
170
- - [`5f58283e1f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5f58283e1f) - Export types using Typescript's new "export type" syntax to satisfy Typescript's --isolatedModules compiler option.
182
+ - [#5497](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/5497) [`5f58283e1f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5f58283e1f) - Export types using Typescript's new "export type" syntax to satisfy Typescript's --isolatedModules compiler option.
171
183
  This requires version 3.8 of Typescript, read more about how we handle Typescript versions here: https://atlaskit.atlassian.com/get-started
172
184
  Also add `typescript` to `devDependencies` to denote version that the package was built with.
173
185
 
@@ -181,7 +193,7 @@
181
193
 
182
194
  ### Patch Changes
183
195
 
184
- - [`6c525a8229`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6c525a8229) - Upgraded to TypeScript 3.9.6 and tslib to 2.0.0
196
+ - [#3885](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/3885) [`6c525a8229`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6c525a8229) - Upgraded to TypeScript 3.9.6 and tslib to 2.0.0
185
197
 
186
198
  Since tslib is a dependency for all our packages we recommend that products also follow this tslib upgrade
187
199
  to prevent duplicates of tslib being bundled.
@@ -190,14 +202,14 @@
190
202
 
191
203
  ### Patch Changes
192
204
 
193
- - [`3414523d6f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3414523d6f) - Rearange buttons order to align with design guidelines
205
+ - [#3428](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/3428) [`3414523d6f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3414523d6f) - Rearange buttons order to align with design guidelines
194
206
  - [`db053b24d8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/db053b24d8) - Update all the theme imports to be tree-shakable
195
207
 
196
208
  ## 4.0.0
197
209
 
198
210
  ### Major Changes
199
211
 
200
- - [`87f4720f27`](https://bitbucket.org/atlassian/atlassian-frontend/commits/87f4720f27) - Officially dropping IE11 support, from this version onwards there are no warranties of the package working in IE11.
212
+ - [#3335](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/3335) [`87f4720f27`](https://bitbucket.org/atlassian/atlassian-frontend/commits/87f4720f27) - Officially dropping IE11 support, from this version onwards there are no warranties of the package working in IE11.
201
213
  For more information see: https://community.developer.atlassian.com/t/atlaskit-to-drop-support-for-internet-explorer-11-from-1st-july-2020/39534
202
214
 
203
215
  ### Patch Changes
@@ -208,13 +220,13 @@
208
220
 
209
221
  ### Patch Changes
210
222
 
211
- - [`54a9514fcf`](https://bitbucket.org/atlassian/atlassian-frontend/commits/54a9514fcf) - Build and supporting files will no longer be published to npm
223
+ - [#2866](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/2866) [`54a9514fcf`](https://bitbucket.org/atlassian/atlassian-frontend/commits/54a9514fcf) - Build and supporting files will no longer be published to npm
212
224
 
213
225
  ## 3.1.8
214
226
 
215
227
  ### Patch Changes
216
228
 
217
- - [`4069606178`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4069606178) - Change imports to comply with Atlassian conventions- Updated dependencies
229
+ - [#1868](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/1868) [`4069606178`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4069606178) - Change imports to comply with Atlassian conventions- Updated dependencies
218
230
 
219
231
  ## 3.1.7
220
232
 
@@ -4,7 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.PORTAL_UNMOUNT_EVENT = exports.PORTAL_MOUNT_EVENT = void 0;
7
- var PORTAL_MOUNT_EVENT = 'akPortalMount';
8
- exports.PORTAL_MOUNT_EVENT = PORTAL_MOUNT_EVENT;
9
- var PORTAL_UNMOUNT_EVENT = 'akPortalUnmount';
10
- exports.PORTAL_UNMOUNT_EVENT = PORTAL_UNMOUNT_EVENT;
7
+ var PORTAL_MOUNT_EVENT = exports.PORTAL_MOUNT_EVENT = 'akPortalMount';
8
+ var PORTAL_UNMOUNT_EVENT = exports.PORTAL_UNMOUNT_EVENT = 'akPortalUnmount';
@@ -1,5 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ "use strict";
@@ -4,9 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.portalParentSelector = exports.portalParentClassName = exports.portalClassName = void 0;
7
- var portalParentClassName = 'atlaskit-portal-container';
8
- exports.portalParentClassName = portalParentClassName;
9
- var portalParentSelector = 'body > .atlaskit-portal-container';
10
- exports.portalParentSelector = portalParentSelector;
11
- var portalClassName = 'atlaskit-portal';
12
- exports.portalClassName = portalClassName;
7
+ var portalParentClassName = exports.portalParentClassName = 'atlaskit-portal-container';
8
+ var portalParentSelector = exports.portalParentSelector = 'body > .atlaskit-portal-container';
9
+ var portalClassName = exports.portalClassName = 'atlaskit-portal';
@@ -7,15 +7,20 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _react = require("react");
10
- var useIsSubsequentRender = function useIsSubsequentRender() {
10
+ var _useIsomorphicLayoutEffect = require("./use-isomorphic-layout-effect");
11
+ var useIsSubsequentRender = function useIsSubsequentRender(mountStrategy) {
11
12
  var _useState = (0, _react.useState)(false),
12
13
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
13
14
  isSubsequentRender = _useState2[0],
14
15
  setIsSubsequentRender = _useState2[1];
15
- (0, _react.useEffect)(function () {
16
+ var _useState3 = (0, _react.useState)(function () {
17
+ return mountStrategy === 'layoutEffect' ? _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect : _react.useEffect;
18
+ }),
19
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 1),
20
+ useMountEffect = _useState4[0];
21
+ useMountEffect(function () {
16
22
  setIsSubsequentRender(true);
17
23
  }, []);
18
24
  return isSubsequentRender;
19
25
  };
20
- var _default = useIsSubsequentRender;
21
- exports.default = _default;
26
+ var _default = exports.default = useIsSubsequentRender;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useIsomorphicLayoutEffect = void 0;
7
+ var _react = require("react");
8
+ /**
9
+ * Needed to supress the SSR warning when running use layout effect on the server.
10
+ */
11
+ var useIsomorphicLayoutEffect = exports.useIsomorphicLayoutEffect = typeof window !== 'undefined' ? _react.useLayoutEffect : _react.useEffect;
@@ -17,5 +17,4 @@ var useFirePortalEvent = function useFirePortalEvent(zIndex) {
17
17
  };
18
18
  }, [zIndexNumber]);
19
19
  };
20
- var _default = useFirePortalEvent;
21
- exports.default = _default;
20
+ var _default = exports.default = useFirePortalEvent;
@@ -11,7 +11,7 @@ var _constants = require("../constants");
11
11
  * @param {number | string} zIndex - the z-index value of the newly created portal container element
12
12
  * @return {number} - The newly created container element
13
13
  */
14
- var createContainer = function createContainer(zIndex) {
14
+ var createContainer = exports.createContainer = function createContainer(zIndex) {
15
15
  var container = document.createElement('div');
16
16
  container.className = _constants.portalClassName;
17
17
  container.style.zIndex = "".concat(zIndex);
@@ -22,7 +22,6 @@ var createContainer = function createContainer(zIndex) {
22
22
  * Returns document body element
23
23
  * @return {number} - The document body element
24
24
  */
25
- exports.createContainer = createContainer;
26
25
  var getBody = function getBody() {
27
26
  return document.body;
28
27
  };
@@ -49,7 +48,7 @@ var getPortalParent = function getPortalParent() {
49
48
  * Removes portal container from portal parent container
50
49
  * @param {HTMLDivElement | undefined} container - portal container to be removed from portal parent container
51
50
  */
52
- var removePortalContainer = function removePortalContainer(container) {
51
+ var removePortalContainer = exports.removePortalContainer = function removePortalContainer(container) {
53
52
  getPortalParent().removeChild(container);
54
53
  };
55
54
 
@@ -57,10 +56,8 @@ var removePortalContainer = function removePortalContainer(container) {
57
56
  * Appends portal container to portal parent container if it hasn't already been done
58
57
  * @param {HTMLDivElement | undefined} container - portal container to be added to portal parent container
59
58
  */
60
- exports.removePortalContainer = removePortalContainer;
61
- var appendPortalContainerIfNotAppended = function appendPortalContainerIfNotAppended(container) {
59
+ var appendPortalContainerIfNotAppended = exports.appendPortalContainerIfNotAppended = function appendPortalContainerIfNotAppended(container) {
62
60
  if (!container.parentElement) {
63
61
  getPortalParent().appendChild(container);
64
62
  }
65
- };
66
- exports.appendPortalContainerIfNotAppended = appendPortalContainerIfNotAppended;
63
+ };
@@ -9,11 +9,13 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _internalPortal = _interopRequireDefault(require("./internal/components/internal-portal"));
10
10
  var _useIsSubsequentRender = _interopRequireDefault(require("./internal/hooks/use-is-subsequent-render"));
11
11
  var _usePortalEvent = _interopRequireDefault(require("./internal/hooks/use-portal-event"));
12
- function Portal(props) {
13
- var _props$zIndex = props.zIndex,
14
- zIndex = _props$zIndex === void 0 ? 0 : _props$zIndex,
15
- children = props.children;
16
- var isSubsequentRender = (0, _useIsSubsequentRender.default)();
12
+ function Portal(_ref) {
13
+ var _ref$zIndex = _ref.zIndex,
14
+ zIndex = _ref$zIndex === void 0 ? 0 : _ref$zIndex,
15
+ children = _ref.children,
16
+ _ref$mountStrategy = _ref.mountStrategy,
17
+ mountStrategy = _ref$mountStrategy === void 0 ? 'effect' : _ref$mountStrategy;
18
+ var isSubsequentRender = (0, _useIsSubsequentRender.default)(mountStrategy);
17
19
  (0, _usePortalEvent.default)(zIndex);
18
20
  return isSubsequentRender ? /*#__PURE__*/_react.default.createElement(_internalPortal.default, {
19
21
  zIndex: zIndex
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +1,9 @@
1
1
  import { useEffect, useState } from 'react';
2
- const useIsSubsequentRender = () => {
2
+ import { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect';
3
+ const useIsSubsequentRender = mountStrategy => {
3
4
  const [isSubsequentRender, setIsSubsequentRender] = useState(false);
4
- useEffect(() => {
5
+ const [useMountEffect] = useState(() => mountStrategy === 'layoutEffect' ? useIsomorphicLayoutEffect : useEffect);
6
+ useMountEffect(() => {
5
7
  setIsSubsequentRender(true);
6
8
  }, []);
7
9
  return isSubsequentRender;
@@ -0,0 +1,6 @@
1
+ import { useEffect, useLayoutEffect } from 'react';
2
+
3
+ /**
4
+ * Needed to supress the SSR warning when running use layout effect on the server.
5
+ */
6
+ export const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
@@ -2,12 +2,12 @@ import React from 'react';
2
2
  import InternalPortal from './internal/components/internal-portal';
3
3
  import useIsSubsequentRender from './internal/hooks/use-is-subsequent-render';
4
4
  import useFirePortalEvent from './internal/hooks/use-portal-event';
5
- export default function Portal(props) {
6
- const {
7
- zIndex = 0,
8
- children
9
- } = props;
10
- const isSubsequentRender = useIsSubsequentRender();
5
+ export default function Portal({
6
+ zIndex = 0,
7
+ children,
8
+ mountStrategy = 'effect'
9
+ }) {
10
+ const isSubsequentRender = useIsSubsequentRender(mountStrategy);
11
11
  useFirePortalEvent(zIndex);
12
12
  return isSubsequentRender ? /*#__PURE__*/React.createElement(InternalPortal, {
13
13
  zIndex: zIndex
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +1,17 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { useEffect, useState } from 'react';
3
- var useIsSubsequentRender = function useIsSubsequentRender() {
3
+ import { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect';
4
+ var useIsSubsequentRender = function useIsSubsequentRender(mountStrategy) {
4
5
  var _useState = useState(false),
5
6
  _useState2 = _slicedToArray(_useState, 2),
6
7
  isSubsequentRender = _useState2[0],
7
8
  setIsSubsequentRender = _useState2[1];
8
- useEffect(function () {
9
+ var _useState3 = useState(function () {
10
+ return mountStrategy === 'layoutEffect' ? useIsomorphicLayoutEffect : useEffect;
11
+ }),
12
+ _useState4 = _slicedToArray(_useState3, 1),
13
+ useMountEffect = _useState4[0];
14
+ useMountEffect(function () {
9
15
  setIsSubsequentRender(true);
10
16
  }, []);
11
17
  return isSubsequentRender;
@@ -0,0 +1,6 @@
1
+ import { useEffect, useLayoutEffect } from 'react';
2
+
3
+ /**
4
+ * Needed to supress the SSR warning when running use layout effect on the server.
5
+ */
6
+ export var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
@@ -2,11 +2,13 @@ import React from 'react';
2
2
  import InternalPortal from './internal/components/internal-portal';
3
3
  import useIsSubsequentRender from './internal/hooks/use-is-subsequent-render';
4
4
  import useFirePortalEvent from './internal/hooks/use-portal-event';
5
- export default function Portal(props) {
6
- var _props$zIndex = props.zIndex,
7
- zIndex = _props$zIndex === void 0 ? 0 : _props$zIndex,
8
- children = props.children;
9
- var isSubsequentRender = useIsSubsequentRender();
5
+ export default function Portal(_ref) {
6
+ var _ref$zIndex = _ref.zIndex,
7
+ zIndex = _ref$zIndex === void 0 ? 0 : _ref$zIndex,
8
+ children = _ref.children,
9
+ _ref$mountStrategy = _ref.mountStrategy,
10
+ mountStrategy = _ref$mountStrategy === void 0 ? 'effect' : _ref$mountStrategy;
11
+ var isSubsequentRender = useIsSubsequentRender(mountStrategy);
10
12
  useFirePortalEvent(zIndex);
11
13
  return isSubsequentRender ? /*#__PURE__*/React.createElement(InternalPortal, {
12
14
  zIndex: zIndex
@@ -1,2 +1,3 @@
1
- declare const useIsSubsequentRender: () => boolean;
1
+ import { MountStrategy } from '../types';
2
+ declare const useIsSubsequentRender: (mountStrategy?: MountStrategy) => boolean;
2
3
  export default useIsSubsequentRender;
@@ -0,0 +1,5 @@
1
+ import { useEffect } from 'react';
2
+ /**
3
+ * Needed to supress the SSR warning when running use layout effect on the server.
4
+ */
5
+ export declare const useIsomorphicLayoutEffect: typeof useEffect;
@@ -21,4 +21,5 @@ export interface PortalEventDetail {
21
21
  layer: LayerName | null;
22
22
  zIndex: number;
23
23
  }
24
+ export type MountStrategy = 'effect' | 'layoutEffect';
24
25
  export {};
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { PortalProps } from './types';
3
- export default function Portal(props: PortalProps): JSX.Element | null;
3
+ export default function Portal({ zIndex, children, mountStrategy, }: PortalProps): JSX.Element | null;
@@ -1,11 +1,16 @@
1
1
  import React from 'react';
2
- import { PortalEventDetail } from './internal/types';
2
+ import { MountStrategy, PortalEventDetail } from './internal/types';
3
3
  /**
4
4
  * Interface for props to be passed in Atlassian Portal component
5
5
  */
6
6
  export interface PortalProps {
7
7
  children: React.ReactNode;
8
8
  zIndex?: number | string;
9
+ /**
10
+ * Specify the mount strategy: useEffect or useLayoutEffect.
11
+ * Note: UseLayoutEffect can lead to performance issues and is discouraged.
12
+ */
13
+ mountStrategy?: MountStrategy;
9
14
  }
10
15
  /**
11
16
  * Custom event object that will be fired when Atlassian Portal component is mounted and unmounted
@@ -1,2 +1,3 @@
1
- declare const useIsSubsequentRender: () => boolean;
1
+ import { MountStrategy } from '../types';
2
+ declare const useIsSubsequentRender: (mountStrategy?: MountStrategy) => boolean;
2
3
  export default useIsSubsequentRender;
@@ -0,0 +1,5 @@
1
+ import { useEffect } from 'react';
2
+ /**
3
+ * Needed to supress the SSR warning when running use layout effect on the server.
4
+ */
5
+ export declare const useIsomorphicLayoutEffect: typeof useEffect;
@@ -21,4 +21,5 @@ export interface PortalEventDetail {
21
21
  layer: LayerName | null;
22
22
  zIndex: number;
23
23
  }
24
+ export type MountStrategy = 'effect' | 'layoutEffect';
24
25
  export {};
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { PortalProps } from './types';
3
- export default function Portal(props: PortalProps): JSX.Element | null;
3
+ export default function Portal({ zIndex, children, mountStrategy, }: PortalProps): JSX.Element | null;
@@ -1,11 +1,16 @@
1
1
  import React from 'react';
2
- import { PortalEventDetail } from './internal/types';
2
+ import { MountStrategy, PortalEventDetail } from './internal/types';
3
3
  /**
4
4
  * Interface for props to be passed in Atlassian Portal component
5
5
  */
6
6
  export interface PortalProps {
7
7
  children: React.ReactNode;
8
8
  zIndex?: number | string;
9
+ /**
10
+ * Specify the mount strategy: useEffect or useLayoutEffect.
11
+ * Note: UseLayoutEffect can lead to performance issues and is discouraged.
12
+ */
13
+ mountStrategy?: MountStrategy;
9
14
  }
10
15
  /**
11
16
  * Custom event object that will be fired when Atlassian Portal component is mounted and unmounted
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/portal",
3
- "version": "4.3.6",
3
+ "version": "4.4.1",
4
4
  "description": "A wrapper for rendering components in React portals.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -47,17 +47,19 @@
47
47
  },
48
48
  "devDependencies": {
49
49
  "@af/accessibility-testing": "*",
50
+ "@af/integration-testing": "*",
51
+ "@atlaskit/ds-lib": "^2.2.0",
50
52
  "@atlaskit/ssr": "*",
51
- "@atlaskit/tokens": "^1.18.0",
53
+ "@atlaskit/tokens": "^1.42.0",
52
54
  "@atlaskit/visual-regression": "*",
53
- "@atlaskit/webdriver-runner": "*",
54
55
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
55
56
  "@emotion/react": "^11.7.1",
56
57
  "@testing-library/react": "^12.1.5",
58
+ "@testing-library/react-hooks": "^8.0.1",
57
59
  "bind-event-listener": "^2.1.1",
58
60
  "raf-stub": "^2.0.1",
59
61
  "storybook-addon-performance": "^0.16.0",
60
- "typescript": "~4.9.5"
62
+ "typescript": "~5.4.2"
61
63
  },
62
64
  "keywords": [
63
65
  "atlaskit",
@@ -86,4 +88,4 @@
86
88
  },
87
89
  "homepage": "https://atlassian.design/components/portal/",
88
90
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
89
- }
91
+ }
package/report.api.md CHANGED
@@ -24,7 +24,14 @@ import { default as React_2 } from 'react';
24
24
  type LayerName = keyof Layers;
25
25
 
26
26
  // @public (undocumented)
27
- function Portal(props: PortalProps): JSX.Element | null;
27
+ type MountStrategy = 'effect' | 'layoutEffect';
28
+
29
+ // @public (undocumented)
30
+ function Portal({
31
+ zIndex,
32
+ children,
33
+ mountStrategy,
34
+ }: PortalProps): JSX.Element | null;
28
35
  export default Portal;
29
36
 
30
37
  // @public (undocumented)
@@ -48,6 +55,7 @@ interface PortalEventDetail {
48
55
  export interface PortalProps {
49
56
  // (undocumented)
50
57
  children: React_2.ReactNode;
58
+ mountStrategy?: MountStrategy;
51
59
  // (undocumented)
52
60
  zIndex?: number | string;
53
61
  }
@@ -6,7 +6,7 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/entry-points/types.d.ts",
8
8
  "typesVersions": {
9
- ">=4.5 <4.9": {
9
+ ">=4.5 <5.4": {
10
10
  "*": [
11
11
  "../dist/types-ts4.5/entry-points/types.d.ts"
12
12
  ]
@@ -1,46 +0,0 @@
1
- ## API Report File for "@atlaskit/portal"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- /// <reference types="react" />
8
-
9
- import type { Layers } from '@atlaskit/theme/types';
10
- import { default as React_2 } from 'react';
11
-
12
- // @public
13
- type LayerName = keyof Layers;
14
-
15
- // @public (undocumented)
16
- function Portal(props: PortalProps): JSX.Element | null;
17
- export default Portal;
18
-
19
- // @public (undocumented)
20
- export const PORTAL_MOUNT_EVENT = "akPortalMount";
21
-
22
- // @public (undocumented)
23
- export const PORTAL_UNMOUNT_EVENT = "akPortalUnmount";
24
-
25
- // @public
26
- export type PortalEvent = CustomEvent<PortalEventDetail>;
27
-
28
- // @public
29
- interface PortalEventDetail {
30
- // (undocumented)
31
- layer: LayerName | null;
32
- // (undocumented)
33
- zIndex: number;
34
- }
35
-
36
- // @public
37
- export interface PortalProps {
38
- // (undocumented)
39
- children: React_2.ReactNode;
40
- // (undocumented)
41
- zIndex?: number | string;
42
- }
43
-
44
- // (No @packageDocumentation comment for this package)
45
-
46
- ```