@atlaskit/portal 4.2.11 → 4.2.13

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 (37) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +4 -2
  3. package/dist/cjs/index.js +0 -3
  4. package/dist/cjs/internal/components/internal-portal.js +4 -7
  5. package/dist/cjs/internal/hooks/use-is-subsequent-render.js +3 -9
  6. package/dist/cjs/internal/hooks/use-portal-event.js +0 -6
  7. package/dist/cjs/internal/utils/portal-custom-event.js +3 -5
  8. package/dist/cjs/internal/utils/portal-dom-utils.js +6 -17
  9. package/dist/cjs/portal.js +2 -8
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/internal/components/internal-portal.js +3 -2
  12. package/dist/es2019/internal/hooks/use-is-subsequent-render.js +0 -2
  13. package/dist/es2019/internal/hooks/use-portal-event.js +0 -2
  14. package/dist/es2019/internal/utils/portal-custom-event.js +3 -5
  15. package/dist/es2019/internal/utils/portal-dom-utils.js +7 -11
  16. package/dist/es2019/version.json +1 -1
  17. package/dist/esm/internal/components/internal-portal.js +4 -3
  18. package/dist/esm/internal/hooks/use-is-subsequent-render.js +3 -6
  19. package/dist/esm/internal/hooks/use-portal-event.js +0 -2
  20. package/dist/esm/internal/utils/portal-custom-event.js +3 -5
  21. package/dist/esm/internal/utils/portal-dom-utils.js +7 -11
  22. package/dist/esm/portal.js +2 -2
  23. package/dist/esm/version.json +1 -1
  24. package/package.json +22 -20
  25. package/report.api.md +33 -21
  26. package/dist/types-ts4.0/constants.d.ts +0 -2
  27. package/dist/types-ts4.0/entry-points/types.d.ts +0 -1
  28. package/dist/types-ts4.0/index.d.ts +0 -3
  29. package/dist/types-ts4.0/internal/components/internal-portal.d.ts +0 -7
  30. package/dist/types-ts4.0/internal/constants.d.ts +0 -3
  31. package/dist/types-ts4.0/internal/hooks/use-is-subsequent-render.d.ts +0 -2
  32. package/dist/types-ts4.0/internal/hooks/use-portal-event.d.ts +0 -2
  33. package/dist/types-ts4.0/internal/types.d.ts +0 -24
  34. package/dist/types-ts4.0/internal/utils/portal-custom-event.d.ts +0 -6
  35. package/dist/types-ts4.0/internal/utils/portal-dom-utils.d.ts +0 -17
  36. package/dist/types-ts4.0/portal.d.ts +0 -3
  37. package/dist/types-ts4.0/types.d.ts +0 -13
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/portal
2
2
 
3
+ ## 4.2.13
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4ba10567310`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4ba10567310) - Internal changes.
8
+
9
+ ## 4.2.12
10
+
11
+ ### Patch Changes
12
+
13
+ - [`9827dcb82b8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9827dcb82b8) - No-op change to introduce spacing tokens to design system components.
14
+
3
15
  ## 4.2.11
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -1,11 +1,13 @@
1
1
  # Portal
2
2
 
3
- An Atlaskit wrapper for rendering components in React Portals.
3
+ A wrapper for rendering components in React portals.
4
4
 
5
5
  ## Installation
6
6
 
7
+ ```sh
7
8
  yarn add @atlaskit/portal
9
+ ```
8
10
 
9
11
  ## Usage
10
12
 
11
- Detailed docs and example usage can be found [here](https://atlaskit.atlassian.com/packages/core/portal).
13
+ [View documentation](https://atlassian.design/components/portal/).
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -23,7 +22,5 @@ Object.defineProperty(exports, "default", {
23
22
  return _portal.default;
24
23
  }
25
24
  });
26
-
27
25
  var _portal = _interopRequireDefault(require("./portal"));
28
-
29
26
  var _constants = require("./constants");
@@ -4,23 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = InternalPortal;
7
-
8
7
  var _react = require("react");
9
-
10
8
  var _reactDom = require("react-dom");
11
-
12
9
  var _portalDomUtils = require("../utils/portal-dom-utils");
13
-
14
10
  function InternalPortal(props) {
15
11
  var zIndex = props.zIndex,
16
- children = props.children;
12
+ children = props.children;
17
13
  var container = (0, _react.useMemo)(function () {
18
14
  return (0, _portalDomUtils.createContainer)(zIndex);
19
- }, [zIndex]); // This is in the render method instead of useEffect so that
15
+ }, [zIndex]);
16
+
17
+ // This is in the render method instead of useEffect so that
20
18
  // the portal will be added to the DOM before the children render.
21
19
  // For any further changes, ensure that the container does not have a
22
20
  // parent besides the portal parent.
23
-
24
21
  (0, _portalDomUtils.appendPortalContainerIfNotAppended)(container);
25
22
  (0, _react.useEffect)(function () {
26
23
  return function () {
@@ -1,27 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
9
  var _react = require("react");
13
-
14
10
  var useIsSubsequentRender = function useIsSubsequentRender() {
15
11
  var _useState = (0, _react.useState)(false),
16
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
17
- isSubsequentRender = _useState2[0],
18
- setIsSubsequentRender = _useState2[1];
19
-
12
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
13
+ isSubsequentRender = _useState2[0],
14
+ setIsSubsequentRender = _useState2[1];
20
15
  (0, _react.useEffect)(function () {
21
16
  setIsSubsequentRender(true);
22
17
  }, []);
23
18
  return isSubsequentRender;
24
19
  };
25
-
26
20
  var _default = useIsSubsequentRender;
27
21
  exports.default = _default;
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _react = require("react");
11
-
12
9
  var _constants = require("../../constants");
13
-
14
10
  var _portalCustomEvent = _interopRequireDefault(require("../utils/portal-custom-event"));
15
-
16
11
  var useFirePortalEvent = function useFirePortalEvent(zIndex) {
17
12
  var zIndexNumber = Number(zIndex);
18
13
  (0, _react.useEffect)(function () {
@@ -22,6 +17,5 @@ var useFirePortalEvent = function useFirePortalEvent(zIndex) {
22
17
  };
23
18
  }, [zIndexNumber]);
24
19
  };
25
-
26
20
  var _default = useFirePortalEvent;
27
21
  exports.default = _default;
@@ -15,23 +15,22 @@ var zIndexToName = {
15
15
  700: 'spotlight',
16
16
  800: 'tooltip'
17
17
  };
18
+
18
19
  /**
19
20
  * return layer name in Atlassian design system corresponding to given z-index
20
21
  * @param {number} zIndex - z-index value for which layer name is needed
21
22
  * @returns {LayerName | null} - The layer name for given z-index. If layer name is not found then null is returned
22
23
  */
23
-
24
24
  var getLayerName = function getLayerName(zIndex) {
25
25
  return zIndexToName.hasOwnProperty(zIndex) ? zIndexToName[zIndex] : null;
26
26
  };
27
+
27
28
  /**
28
29
  * Creates a PortalEvent object with given eventName, given zIndex and corresponding layer
29
30
  * @param {string} eventName - either of Mount or Unmount event name
30
31
  * @param {number} zIndex - z-index value which will be included in the event to be dispatched
31
32
  * @returns {PortalEvent} - The newly created PortalEvent object
32
33
  */
33
-
34
-
35
34
  var getEvent = function getEvent(eventName, zIndex) {
36
35
  var detail = {
37
36
  layer: getLayerName(Number(zIndex)),
@@ -41,13 +40,12 @@ var getEvent = function getEvent(eventName, zIndex) {
41
40
  detail: detail
42
41
  });
43
42
  };
43
+
44
44
  /**
45
45
  * Dispatches a custom event on window with given eventName, given zIndex and corresponding layer
46
46
  * @param {string} eventName - either of Mount or Unmount event name
47
47
  * @param {number} zIndex - z-index value which will be included in the event to be dispatched
48
48
  */
49
-
50
-
51
49
  function firePortalEvent(eventName, zIndex) {
52
50
  var event = getEvent(eventName, zIndex);
53
51
  window.dispatchEvent(event);
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.removePortalContainer = exports.createContainer = exports.appendPortalContainerIfNotAppended = void 0;
7
-
8
7
  var _constants = require("../constants");
9
-
10
8
  /**
11
9
  * Creates a new portal container element with provided z-index and class name 'atlaskit-portal',
12
10
  * it is not be attached to any DOM node at this stage.
@@ -19,59 +17,50 @@ var createContainer = function createContainer(zIndex) {
19
17
  container.style.zIndex = "".concat(zIndex);
20
18
  return container;
21
19
  };
20
+
22
21
  /**
23
22
  * Returns document body element
24
23
  * @return {number} - The document body element
25
24
  */
26
-
27
-
28
25
  exports.createContainer = createContainer;
29
-
30
26
  var getBody = function getBody() {
31
27
  return document.body;
32
28
  };
29
+
33
30
  /**
34
31
  * Returns portal parent container. If no container exists already then it creates a new container with class name 'atlaskit-portal-container'
35
32
  * @return {Element} - The portal parent container div element
36
33
  */
37
-
38
-
39
34
  var getPortalParent = function getPortalParent() {
40
35
  var parentElement = document.querySelector(_constants.portalParentSelector);
41
-
42
36
  if (!parentElement) {
43
37
  var parent = document.createElement('div');
44
- parent.className = _constants.portalParentClassName; // we are setting display to flex because we want each portal to create a new stacking context
38
+ parent.className = _constants.portalParentClassName;
39
+ // we are setting display to flex because we want each portal to create a new stacking context
45
40
  // See https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
46
-
47
41
  parent.style.display = 'flex';
48
42
  getBody().appendChild(parent);
49
43
  return parent;
50
44
  }
51
-
52
45
  return parentElement;
53
46
  };
47
+
54
48
  /**
55
49
  * Removes portal container from portal parent container
56
50
  * @param {HTMLDivElement | undefined} container - portal container to be removed from portal parent container
57
51
  */
58
-
59
-
60
52
  var removePortalContainer = function removePortalContainer(container) {
61
53
  getPortalParent().removeChild(container);
62
54
  };
55
+
63
56
  /**
64
57
  * Appends portal container to portal parent container if it hasn't already been done
65
58
  * @param {HTMLDivElement | undefined} container - portal container to be added to portal parent container
66
59
  */
67
-
68
-
69
60
  exports.removePortalContainer = removePortalContainer;
70
-
71
61
  var appendPortalContainerIfNotAppended = function appendPortalContainerIfNotAppended(container) {
72
62
  if (!container.parentElement) {
73
63
  getPortalParent().appendChild(container);
74
64
  }
75
65
  };
76
-
77
66
  exports.appendPortalContainerIfNotAppended = appendPortalContainerIfNotAppended;
@@ -1,24 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = Portal;
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  var _internalPortal = _interopRequireDefault(require("./internal/components/internal-portal"));
13
-
14
10
  var _useIsSubsequentRender = _interopRequireDefault(require("./internal/hooks/use-is-subsequent-render"));
15
-
16
11
  var _usePortalEvent = _interopRequireDefault(require("./internal/hooks/use-portal-event"));
17
-
18
12
  function Portal(props) {
19
13
  var _props$zIndex = props.zIndex,
20
- zIndex = _props$zIndex === void 0 ? 0 : _props$zIndex,
21
- children = props.children;
14
+ zIndex = _props$zIndex === void 0 ? 0 : _props$zIndex,
15
+ children = props.children;
22
16
  var isSubsequentRender = (0, _useIsSubsequentRender.default)();
23
17
  (0, _usePortalEvent.default)(zIndex);
24
18
  return isSubsequentRender ? /*#__PURE__*/_react.default.createElement(_internalPortal.default, {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/portal",
3
- "version": "4.2.11",
3
+ "version": "4.2.13",
4
4
  "sideEffects": false
5
5
  }
@@ -6,11 +6,12 @@ export default function InternalPortal(props) {
6
6
  zIndex,
7
7
  children
8
8
  } = props;
9
- const container = useMemo(() => createContainer(zIndex), [zIndex]); // This is in the render method instead of useEffect so that
9
+ const container = useMemo(() => createContainer(zIndex), [zIndex]);
10
+
11
+ // This is in the render method instead of useEffect so that
10
12
  // the portal will be added to the DOM before the children render.
11
13
  // For any further changes, ensure that the container does not have a
12
14
  // parent besides the portal parent.
13
-
14
15
  appendPortalContainerIfNotAppended(container);
15
16
  useEffect(() => {
16
17
  return () => {
@@ -1,5 +1,4 @@
1
1
  import { useEffect, useState } from 'react';
2
-
3
2
  const useIsSubsequentRender = () => {
4
3
  const [isSubsequentRender, setIsSubsequentRender] = useState(false);
5
4
  useEffect(() => {
@@ -7,5 +6,4 @@ const useIsSubsequentRender = () => {
7
6
  }, []);
8
7
  return isSubsequentRender;
9
8
  };
10
-
11
9
  export default useIsSubsequentRender;
@@ -1,7 +1,6 @@
1
1
  import { useEffect } from 'react';
2
2
  import { PORTAL_MOUNT_EVENT, PORTAL_UNMOUNT_EVENT } from '../../constants';
3
3
  import firePortalEvent from '../utils/portal-custom-event';
4
-
5
4
  const useFirePortalEvent = zIndex => {
6
5
  const zIndexNumber = Number(zIndex);
7
6
  useEffect(() => {
@@ -11,5 +10,4 @@ const useFirePortalEvent = zIndex => {
11
10
  };
12
11
  }, [zIndexNumber]);
13
12
  };
14
-
15
13
  export default useFirePortalEvent;
@@ -9,23 +9,22 @@ const zIndexToName = {
9
9
  700: 'spotlight',
10
10
  800: 'tooltip'
11
11
  };
12
+
12
13
  /**
13
14
  * return layer name in Atlassian design system corresponding to given z-index
14
15
  * @param {number} zIndex - z-index value for which layer name is needed
15
16
  * @returns {LayerName | null} - The layer name for given z-index. If layer name is not found then null is returned
16
17
  */
17
-
18
18
  const getLayerName = zIndex => {
19
19
  return zIndexToName.hasOwnProperty(zIndex) ? zIndexToName[zIndex] : null;
20
20
  };
21
+
21
22
  /**
22
23
  * Creates a PortalEvent object with given eventName, given zIndex and corresponding layer
23
24
  * @param {string} eventName - either of Mount or Unmount event name
24
25
  * @param {number} zIndex - z-index value which will be included in the event to be dispatched
25
26
  * @returns {PortalEvent} - The newly created PortalEvent object
26
27
  */
27
-
28
-
29
28
  const getEvent = (eventName, zIndex) => {
30
29
  const detail = {
31
30
  layer: getLayerName(Number(zIndex)),
@@ -35,13 +34,12 @@ const getEvent = (eventName, zIndex) => {
35
34
  detail
36
35
  });
37
36
  };
37
+
38
38
  /**
39
39
  * Dispatches a custom event on window with given eventName, given zIndex and corresponding layer
40
40
  * @param {string} eventName - either of Mount or Unmount event name
41
41
  * @param {number} zIndex - z-index value which will be included in the event to be dispatched
42
42
  */
43
-
44
-
45
43
  export default function firePortalEvent(eventName, zIndex) {
46
44
  const event = getEvent(eventName, zIndex);
47
45
  window.dispatchEvent(event);
@@ -1,60 +1,56 @@
1
1
  import { portalClassName, portalParentClassName, portalParentSelector } from '../constants';
2
+
2
3
  /**
3
4
  * Creates a new portal container element with provided z-index and class name 'atlaskit-portal',
4
5
  * it is not be attached to any DOM node at this stage.
5
6
  * @param {number | string} zIndex - the z-index value of the newly created portal container element
6
7
  * @return {number} - The newly created container element
7
8
  */
8
-
9
9
  export const createContainer = zIndex => {
10
10
  const container = document.createElement('div');
11
11
  container.className = portalClassName;
12
12
  container.style.zIndex = `${zIndex}`;
13
13
  return container;
14
14
  };
15
+
15
16
  /**
16
17
  * Returns document body element
17
18
  * @return {number} - The document body element
18
19
  */
19
-
20
20
  const getBody = () => {
21
21
  return document.body;
22
22
  };
23
+
23
24
  /**
24
25
  * Returns portal parent container. If no container exists already then it creates a new container with class name 'atlaskit-portal-container'
25
26
  * @return {Element} - The portal parent container div element
26
27
  */
27
-
28
-
29
28
  const getPortalParent = () => {
30
29
  const parentElement = document.querySelector(portalParentSelector);
31
-
32
30
  if (!parentElement) {
33
31
  const parent = document.createElement('div');
34
- parent.className = portalParentClassName; // we are setting display to flex because we want each portal to create a new stacking context
32
+ parent.className = portalParentClassName;
33
+ // we are setting display to flex because we want each portal to create a new stacking context
35
34
  // See https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
36
-
37
35
  parent.style.display = 'flex';
38
36
  getBody().appendChild(parent);
39
37
  return parent;
40
38
  }
41
-
42
39
  return parentElement;
43
40
  };
41
+
44
42
  /**
45
43
  * Removes portal container from portal parent container
46
44
  * @param {HTMLDivElement | undefined} container - portal container to be removed from portal parent container
47
45
  */
48
-
49
-
50
46
  export const removePortalContainer = container => {
51
47
  getPortalParent().removeChild(container);
52
48
  };
49
+
53
50
  /**
54
51
  * Appends portal container to portal parent container if it hasn't already been done
55
52
  * @param {HTMLDivElement | undefined} container - portal container to be added to portal parent container
56
53
  */
57
-
58
54
  export const appendPortalContainerIfNotAppended = container => {
59
55
  if (!container.parentElement) {
60
56
  getPortalParent().appendChild(container);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/portal",
3
- "version": "4.2.11",
3
+ "version": "4.2.13",
4
4
  "sideEffects": false
5
5
  }
@@ -3,14 +3,15 @@ import { createPortal } from 'react-dom';
3
3
  import { appendPortalContainerIfNotAppended, createContainer, removePortalContainer } from '../utils/portal-dom-utils';
4
4
  export default function InternalPortal(props) {
5
5
  var zIndex = props.zIndex,
6
- children = props.children;
6
+ children = props.children;
7
7
  var container = useMemo(function () {
8
8
  return createContainer(zIndex);
9
- }, [zIndex]); // This is in the render method instead of useEffect so that
9
+ }, [zIndex]);
10
+
11
+ // This is in the render method instead of useEffect so that
10
12
  // the portal will be added to the DOM before the children render.
11
13
  // For any further changes, ensure that the container does not have a
12
14
  // parent besides the portal parent.
13
-
14
15
  appendPortalContainerIfNotAppended(container);
15
16
  useEffect(function () {
16
17
  return function () {
@@ -1,16 +1,13 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { useEffect, useState } from 'react';
3
-
4
3
  var useIsSubsequentRender = function useIsSubsequentRender() {
5
4
  var _useState = useState(false),
6
- _useState2 = _slicedToArray(_useState, 2),
7
- isSubsequentRender = _useState2[0],
8
- setIsSubsequentRender = _useState2[1];
9
-
5
+ _useState2 = _slicedToArray(_useState, 2),
6
+ isSubsequentRender = _useState2[0],
7
+ setIsSubsequentRender = _useState2[1];
10
8
  useEffect(function () {
11
9
  setIsSubsequentRender(true);
12
10
  }, []);
13
11
  return isSubsequentRender;
14
12
  };
15
-
16
13
  export default useIsSubsequentRender;
@@ -1,7 +1,6 @@
1
1
  import { useEffect } from 'react';
2
2
  import { PORTAL_MOUNT_EVENT, PORTAL_UNMOUNT_EVENT } from '../../constants';
3
3
  import firePortalEvent from '../utils/portal-custom-event';
4
-
5
4
  var useFirePortalEvent = function useFirePortalEvent(zIndex) {
6
5
  var zIndexNumber = Number(zIndex);
7
6
  useEffect(function () {
@@ -11,5 +10,4 @@ var useFirePortalEvent = function useFirePortalEvent(zIndex) {
11
10
  };
12
11
  }, [zIndexNumber]);
13
12
  };
14
-
15
13
  export default useFirePortalEvent;
@@ -9,23 +9,22 @@ var zIndexToName = {
9
9
  700: 'spotlight',
10
10
  800: 'tooltip'
11
11
  };
12
+
12
13
  /**
13
14
  * return layer name in Atlassian design system corresponding to given z-index
14
15
  * @param {number} zIndex - z-index value for which layer name is needed
15
16
  * @returns {LayerName | null} - The layer name for given z-index. If layer name is not found then null is returned
16
17
  */
17
-
18
18
  var getLayerName = function getLayerName(zIndex) {
19
19
  return zIndexToName.hasOwnProperty(zIndex) ? zIndexToName[zIndex] : null;
20
20
  };
21
+
21
22
  /**
22
23
  * Creates a PortalEvent object with given eventName, given zIndex and corresponding layer
23
24
  * @param {string} eventName - either of Mount or Unmount event name
24
25
  * @param {number} zIndex - z-index value which will be included in the event to be dispatched
25
26
  * @returns {PortalEvent} - The newly created PortalEvent object
26
27
  */
27
-
28
-
29
28
  var getEvent = function getEvent(eventName, zIndex) {
30
29
  var detail = {
31
30
  layer: getLayerName(Number(zIndex)),
@@ -35,13 +34,12 @@ var getEvent = function getEvent(eventName, zIndex) {
35
34
  detail: detail
36
35
  });
37
36
  };
37
+
38
38
  /**
39
39
  * Dispatches a custom event on window with given eventName, given zIndex and corresponding layer
40
40
  * @param {string} eventName - either of Mount or Unmount event name
41
41
  * @param {number} zIndex - z-index value which will be included in the event to be dispatched
42
42
  */
43
-
44
-
45
43
  export default function firePortalEvent(eventName, zIndex) {
46
44
  var event = getEvent(eventName, zIndex);
47
45
  window.dispatchEvent(event);
@@ -1,60 +1,56 @@
1
1
  import { portalClassName, portalParentClassName, portalParentSelector } from '../constants';
2
+
2
3
  /**
3
4
  * Creates a new portal container element with provided z-index and class name 'atlaskit-portal',
4
5
  * it is not be attached to any DOM node at this stage.
5
6
  * @param {number | string} zIndex - the z-index value of the newly created portal container element
6
7
  * @return {number} - The newly created container element
7
8
  */
8
-
9
9
  export var createContainer = function createContainer(zIndex) {
10
10
  var container = document.createElement('div');
11
11
  container.className = portalClassName;
12
12
  container.style.zIndex = "".concat(zIndex);
13
13
  return container;
14
14
  };
15
+
15
16
  /**
16
17
  * Returns document body element
17
18
  * @return {number} - The document body element
18
19
  */
19
-
20
20
  var getBody = function getBody() {
21
21
  return document.body;
22
22
  };
23
+
23
24
  /**
24
25
  * Returns portal parent container. If no container exists already then it creates a new container with class name 'atlaskit-portal-container'
25
26
  * @return {Element} - The portal parent container div element
26
27
  */
27
-
28
-
29
28
  var getPortalParent = function getPortalParent() {
30
29
  var parentElement = document.querySelector(portalParentSelector);
31
-
32
30
  if (!parentElement) {
33
31
  var parent = document.createElement('div');
34
- parent.className = portalParentClassName; // we are setting display to flex because we want each portal to create a new stacking context
32
+ parent.className = portalParentClassName;
33
+ // we are setting display to flex because we want each portal to create a new stacking context
35
34
  // See https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
36
-
37
35
  parent.style.display = 'flex';
38
36
  getBody().appendChild(parent);
39
37
  return parent;
40
38
  }
41
-
42
39
  return parentElement;
43
40
  };
41
+
44
42
  /**
45
43
  * Removes portal container from portal parent container
46
44
  * @param {HTMLDivElement | undefined} container - portal container to be removed from portal parent container
47
45
  */
48
-
49
-
50
46
  export var removePortalContainer = function removePortalContainer(container) {
51
47
  getPortalParent().removeChild(container);
52
48
  };
49
+
53
50
  /**
54
51
  * Appends portal container to portal parent container if it hasn't already been done
55
52
  * @param {HTMLDivElement | undefined} container - portal container to be added to portal parent container
56
53
  */
57
-
58
54
  export var appendPortalContainerIfNotAppended = function appendPortalContainerIfNotAppended(container) {
59
55
  if (!container.parentElement) {
60
56
  getPortalParent().appendChild(container);
@@ -4,8 +4,8 @@ import useIsSubsequentRender from './internal/hooks/use-is-subsequent-render';
4
4
  import useFirePortalEvent from './internal/hooks/use-portal-event';
5
5
  export default function Portal(props) {
6
6
  var _props$zIndex = props.zIndex,
7
- zIndex = _props$zIndex === void 0 ? 0 : _props$zIndex,
8
- children = props.children;
7
+ zIndex = _props$zIndex === void 0 ? 0 : _props$zIndex,
8
+ children = props.children;
9
9
  var isSubsequentRender = useIsSubsequentRender();
10
10
  useFirePortalEvent(zIndex);
11
11
  return isSubsequentRender ? /*#__PURE__*/React.createElement(InternalPortal, {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/portal",
3
- "version": "4.2.11",
3
+ "version": "4.2.13",
4
4
  "sideEffects": false
5
5
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atlaskit/portal",
3
- "version": "4.2.11",
4
- "description": "Atlaskit wrapper for rendering components in React portals",
3
+ "version": "4.2.13",
4
+ "description": "A wrapper for rendering components in React portals.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
7
7
  },
@@ -12,13 +12,6 @@
12
12
  "module": "dist/esm/index.js",
13
13
  "module:es2019": "dist/es2019/index.js",
14
14
  "types": "dist/types/index.d.ts",
15
- "typesVersions": {
16
- ">=4.0 <4.5": {
17
- "*": [
18
- "dist/types-ts4.0/*"
19
- ]
20
- }
21
- },
22
15
  "sideEffects": false,
23
16
  "atlaskit:src": "src/index.tsx",
24
17
  "atlassian": {
@@ -26,7 +19,7 @@
26
19
  "releaseModel": "scheduled",
27
20
  "website": {
28
21
  "name": "Portal",
29
- "category": "Components"
22
+ "category": "Libraries"
30
23
  }
31
24
  },
32
25
  "af:exports": {
@@ -34,7 +27,7 @@
34
27
  ".": "./src/index.tsx"
35
28
  },
36
29
  "dependencies": {
37
- "@atlaskit/theme": "^12.2.0",
30
+ "@atlaskit/theme": "^12.4.0",
38
31
  "@babel/runtime": "^7.0.0"
39
32
  },
40
33
  "peerDependencies": {
@@ -42,18 +35,24 @@
42
35
  "react-dom": "^16.8.0"
43
36
  },
44
37
  "devDependencies": {
45
- "@atlaskit/button": "^16.3.0",
38
+ "@atlaskit/banner": "^12.0.9",
39
+ "@atlaskit/button": "^16.6.0",
40
+ "@atlaskit/code": "^14.5.0",
46
41
  "@atlaskit/docs": "*",
47
- "@atlaskit/flag": "^14.7.0",
48
- "@atlaskit/icon": "^21.10.0",
49
- "@atlaskit/inline-dialog": "^13.4.0",
50
- "@atlaskit/modal-dialog": "^12.3.0",
51
- "@atlaskit/onboarding": "^10.5.0",
42
+ "@atlaskit/flag": "^15.1.0",
43
+ "@atlaskit/icon": "^21.11.0",
44
+ "@atlaskit/image": "^1.0.3",
45
+ "@atlaskit/inline-dialog": "^13.5.0",
46
+ "@atlaskit/modal-dialog": "^12.4.0",
47
+ "@atlaskit/onboarding": "^10.7.0",
48
+ "@atlaskit/section-message": "^6.3.9",
52
49
  "@atlaskit/ssr": "*",
53
- "@atlaskit/tooltip": "^17.5.0",
50
+ "@atlaskit/tokens": "^1.2.0",
51
+ "@atlaskit/tooltip": "^17.7.0",
54
52
  "@atlaskit/visual-regression": "*",
55
53
  "@atlaskit/webdriver-runner": "*",
56
54
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
55
+ "@emotion/react": "^11.7.1",
57
56
  "@testing-library/react": "^12.1.5",
58
57
  "bind-event-listener": "^2.1.1",
59
58
  "enzyme": "^3.10.0",
@@ -75,7 +74,10 @@
75
74
  "design-system": "v1",
76
75
  "ui-components": "lite-mode",
77
76
  "analytics": "analytics-next",
78
- "theming": "tokens",
77
+ "design-tokens": [
78
+ "color",
79
+ "spacing"
80
+ ],
79
81
  "deprecation": "no-deprecated-imports",
80
82
  "styling": [
81
83
  "static",
@@ -83,6 +85,6 @@
83
85
  ]
84
86
  }
85
87
  },
86
- "homepage": "https://atlaskit.atlassian.com/packages/design-system/portal",
88
+ "homepage": "https://atlassian.design/components/portal/",
87
89
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
88
90
  }
package/report.api.md CHANGED
@@ -1,6 +1,17 @@
1
+ <!-- API Report Version: 2.3 -->
2
+
1
3
  ## API Report File for "@atlaskit/portal"
2
4
 
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
5
+ > Do not edit this file. This report is auto-generated using [API Extractor](https://api-extractor.com/).
6
+ > [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
7
+
8
+ ### Table of contents
9
+
10
+ - [Main Entry Types](#main-entry-types)
11
+
12
+ ### Main Entry Types
13
+
14
+ <!--SECTION START: Main Entry Types-->
4
15
 
5
16
  ```ts
6
17
  /// <reference types="react" />
@@ -8,38 +19,39 @@
8
19
  import type { Layers } from '@atlaskit/theme/types';
9
20
  import { default as React_2 } from 'react';
10
21
 
11
- /**
12
- * Named layers of all z-index used in the Atlassian Design System.
13
- */
14
- declare type LayerName = keyof Layers;
22
+ // @public
23
+ type LayerName = keyof Layers;
15
24
 
16
- declare function Portal(props: PortalProps): JSX.Element | null;
25
+ // @public (undocumented)
26
+ function Portal(props: PortalProps): JSX.Element | null;
17
27
  export default Portal;
18
28
 
19
- export declare const PORTAL_MOUNT_EVENT = 'akPortalMount';
29
+ // @public (undocumented)
30
+ export const PORTAL_MOUNT_EVENT = 'akPortalMount';
20
31
 
21
- export declare const PORTAL_UNMOUNT_EVENT = 'akPortalUnmount';
32
+ // @public (undocumented)
33
+ export const PORTAL_UNMOUNT_EVENT = 'akPortalUnmount';
22
34
 
23
- /**
24
- * Custom event object that will be fired when Atlassian Portal component is mounted and unmounted
25
- */
26
- export declare type PortalEvent = CustomEvent<PortalEventDetail>;
35
+ // @public
36
+ export type PortalEvent = CustomEvent<PortalEventDetail>;
27
37
 
28
- /**
29
- * Interface for event to be fired on Atlassian Portal component mount and unmount
30
- */
31
- declare interface PortalEventDetail {
38
+ // @public
39
+ interface PortalEventDetail {
40
+ // (undocumented)
32
41
  layer: LayerName | null;
42
+ // (undocumented)
33
43
  zIndex: number;
34
44
  }
35
45
 
36
- /**
37
- * Interface for props to be passed in Atlassian Portal component
38
- */
39
- export declare interface PortalProps {
46
+ // @public
47
+ export interface PortalProps {
48
+ // (undocumented)
40
49
  children: React_2.ReactNode;
50
+ // (undocumented)
41
51
  zIndex?: number | string;
42
52
  }
43
53
 
44
- export {};
54
+ // (No @packageDocumentation comment for this package)
45
55
  ```
56
+
57
+ <!--SECTION END: Main Entry Types-->
@@ -1,2 +0,0 @@
1
- export declare const PORTAL_MOUNT_EVENT = "akPortalMount";
2
- export declare const PORTAL_UNMOUNT_EVENT = "akPortalUnmount";
@@ -1 +0,0 @@
1
- export type { PortalEvent, PortalProps } from '../types';
@@ -1,3 +0,0 @@
1
- export { default } from './portal';
2
- export type { PortalEvent, PortalProps } from './types';
3
- export { PORTAL_MOUNT_EVENT, PORTAL_UNMOUNT_EVENT } from './constants';
@@ -1,7 +0,0 @@
1
- import { ReactPortal } from 'react';
2
- interface InternalPortalProps {
3
- children: React.ReactNode;
4
- zIndex: number | string;
5
- }
6
- export default function InternalPortal(props: InternalPortalProps): ReactPortal;
7
- export {};
@@ -1,3 +0,0 @@
1
- export declare const portalParentClassName = "atlaskit-portal-container";
2
- export declare const portalParentSelector = "body > .atlaskit-portal-container";
3
- export declare const portalClassName = "atlaskit-portal";
@@ -1,2 +0,0 @@
1
- declare const useIsSubsequentRender: () => boolean;
2
- export default useIsSubsequentRender;
@@ -1,2 +0,0 @@
1
- declare const useFirePortalEvent: (zIndex: number | string) => void;
2
- export default useFirePortalEvent;
@@ -1,24 +0,0 @@
1
- import type { Layers } from '@atlaskit/theme/types';
2
- /**
3
- * Named layers of all z-index used in the Atlassian Design System.
4
- */
5
- export declare type LayerName = keyof Layers;
6
- /**
7
- * Creates a new type by reversing the key and values of the passed type
8
- * @param {T} T - the generic type to be reversed. Each members of it should be a Record in key-value form
9
- * @returns - The reversed type
10
- */
11
- declare type ReverseMap<T extends Record<keyof T, T[keyof T]>> = {
12
- [P in T[keyof T]]: {
13
- [K in keyof T]: T[K] extends P ? K : never;
14
- }[keyof T];
15
- };
16
- export declare type ReversedLayers = ReverseMap<Layers>;
17
- /**
18
- * Interface for event to be fired on Atlassian Portal component mount and unmount
19
- */
20
- export interface PortalEventDetail {
21
- layer: LayerName | null;
22
- zIndex: number;
23
- }
24
- export {};
@@ -1,6 +0,0 @@
1
- /**
2
- * Dispatches a custom event on window with given eventName, given zIndex and corresponding layer
3
- * @param {string} eventName - either of Mount or Unmount event name
4
- * @param {number} zIndex - z-index value which will be included in the event to be dispatched
5
- */
6
- export default function firePortalEvent(eventName: string, zIndex: number): void;
@@ -1,17 +0,0 @@
1
- /**
2
- * Creates a new portal container element with provided z-index and class name 'atlaskit-portal',
3
- * it is not be attached to any DOM node at this stage.
4
- * @param {number | string} zIndex - the z-index value of the newly created portal container element
5
- * @return {number} - The newly created container element
6
- */
7
- export declare const createContainer: (zIndex: number | string) => HTMLDivElement;
8
- /**
9
- * Removes portal container from portal parent container
10
- * @param {HTMLDivElement | undefined} container - portal container to be removed from portal parent container
11
- */
12
- export declare const removePortalContainer: (container: HTMLDivElement) => void;
13
- /**
14
- * Appends portal container to portal parent container if it hasn't already been done
15
- * @param {HTMLDivElement | undefined} container - portal container to be added to portal parent container
16
- */
17
- export declare const appendPortalContainerIfNotAppended: (container: HTMLDivElement) => void;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { PortalProps } from './types';
3
- export default function Portal(props: PortalProps): JSX.Element | null;
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { PortalEventDetail } from './internal/types';
3
- /**
4
- * Interface for props to be passed in Atlassian Portal component
5
- */
6
- export interface PortalProps {
7
- children: React.ReactNode;
8
- zIndex?: number | string;
9
- }
10
- /**
11
- * Custom event object that will be fired when Atlassian Portal component is mounted and unmounted
12
- */
13
- export declare type PortalEvent = CustomEvent<PortalEventDetail>;