@atlaskit/portal
Advanced tools
Comparing version 3.0.13 to 3.1.0
# @atlaskit/portal | ||
## 3.1.0 | ||
### Minor Changes | ||
- [minor][bf8796cffa](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/bf8796cffa): | ||
Add mount and unmount events to @atlaskit/portal | ||
## 3.0.13 | ||
@@ -4,0 +12,0 @@ |
@@ -8,2 +8,4 @@ "use strict"; | ||
var exenv_1 = require("exenv"); | ||
var theme_1 = require("@atlaskit/theme"); | ||
var constants_1 = require("../constants"); | ||
var createContainer = function (zIndex) { | ||
@@ -30,2 +32,20 @@ var container = document.createElement('div'); | ||
}; | ||
var zIndexToName = Object.keys(theme_1.layers).reduce(function (acc, name) { | ||
var value = theme_1.layers[name](); | ||
acc[value] = name; | ||
return acc; | ||
}, {}); | ||
var getLayerName = function (zIndex) { | ||
return Object.prototype.hasOwnProperty.call(zIndexToName, zIndex) | ||
? zIndexToName[zIndex] | ||
: null; | ||
}; | ||
var fireMountUnmountEvent = function (eventName, zIndex) { | ||
var event = new Event(eventName); | ||
event.detail = { | ||
layer: getLayerName(Number(zIndex)), | ||
zIndex: zIndex, | ||
}; | ||
window.dispatchEvent(event); | ||
}; | ||
// This is a generic component does two things: | ||
@@ -75,5 +95,7 @@ // 1. Portals it's children using React.createPortal | ||
}); | ||
fireMountUnmountEvent(constants_1.PORTAL_MOUNT_EVENT, Number(zIndex)); | ||
}; | ||
Portal.prototype.componentWillUnmount = function () { | ||
var container = this.state.container; | ||
var zIndex = this.props.zIndex; | ||
if (container) { | ||
@@ -87,2 +109,3 @@ portalParent().removeChild(container); | ||
} | ||
fireMountUnmountEvent(constants_1.PORTAL_UNMOUNT_EVENT, Number(zIndex)); | ||
}; | ||
@@ -89,0 +112,0 @@ Portal.prototype.render = function () { |
@@ -1,1 +0,2 @@ | ||
export { default } from './components/Portal'; | ||
export { default, PortalEvent } from './components/Portal'; | ||
export * from './constants'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var Portal_1 = require("./components/Portal"); | ||
exports.default = Portal_1.default; | ||
tslib_1.__exportStar(require("./constants"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@atlaskit/portal", | ||
"version": "3.0.13", | ||
"version": "3.1.0", | ||
"sideEffects": false | ||
} |
@@ -6,2 +6,4 @@ import { __extends } from "tslib"; | ||
import { canUseDOM } from 'exenv'; | ||
import { layers } from '@atlaskit/theme'; | ||
import { PORTAL_MOUNT_EVENT, PORTAL_UNMOUNT_EVENT } from '../constants'; | ||
var createContainer = function (zIndex) { | ||
@@ -28,2 +30,20 @@ var container = document.createElement('div'); | ||
}; | ||
var zIndexToName = Object.keys(layers).reduce(function (acc, name) { | ||
var value = layers[name](); | ||
acc[value] = name; | ||
return acc; | ||
}, {}); | ||
var getLayerName = function (zIndex) { | ||
return Object.prototype.hasOwnProperty.call(zIndexToName, zIndex) | ||
? zIndexToName[zIndex] | ||
: null; | ||
}; | ||
var fireMountUnmountEvent = function (eventName, zIndex) { | ||
var event = new Event(eventName); | ||
event.detail = { | ||
layer: getLayerName(Number(zIndex)), | ||
zIndex: zIndex, | ||
}; | ||
window.dispatchEvent(event); | ||
}; | ||
// This is a generic component does two things: | ||
@@ -73,5 +93,7 @@ // 1. Portals it's children using React.createPortal | ||
}); | ||
fireMountUnmountEvent(PORTAL_MOUNT_EVENT, Number(zIndex)); | ||
}; | ||
Portal.prototype.componentWillUnmount = function () { | ||
var container = this.state.container; | ||
var zIndex = this.props.zIndex; | ||
if (container) { | ||
@@ -85,2 +107,3 @@ portalParent().removeChild(container); | ||
} | ||
fireMountUnmountEvent(PORTAL_UNMOUNT_EVENT, Number(zIndex)); | ||
}; | ||
@@ -87,0 +110,0 @@ Portal.prototype.render = function () { |
@@ -1,1 +0,2 @@ | ||
export { default } from './components/Portal'; | ||
export { default, PortalEvent } from './components/Portal'; | ||
export * from './constants'; |
export { default } from './components/Portal'; | ||
export * from './constants'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@atlaskit/portal", | ||
"version": "3.0.13", | ||
"version": "3.1.0", | ||
"sideEffects": false | ||
} |
{ | ||
"name": "@atlaskit/portal", | ||
"version": "3.0.13", | ||
"version": "3.1.0", | ||
"description": "Atlaskit wrapper for rendering components in React portals", | ||
@@ -24,2 +24,3 @@ "repository": "https://bitbucket.org/atlassian/atlaskit-mk-2", | ||
"dependencies": { | ||
"@atlaskit/theme": "^9.2.2", | ||
"@babel/runtime": "^7.0.0", | ||
@@ -26,0 +27,0 @@ "exenv": "^1.2.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35261
26
340
7
1
+ Added@atlaskit/theme@^9.2.2
+ Added@atlaskit/theme@9.5.6(transitive)
+ Addedasap@2.0.6(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedcamelize@1.0.1(transitive)
+ Addedcore-js@1.2.7(transitive)
+ Addedcss-color-keywords@1.0.0(transitive)
+ Addedcss-to-react-native@2.3.2(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedfbjs@0.8.18(transitive)
+ Addedhas-flag@1.0.0(transitive)
+ Addedhoist-non-react-statics@2.5.5(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisomorphic-fetch@2.2.1(transitive)
+ Addednode-fetch@1.7.3(transitive)
+ Addedpostcss-value-parser@3.3.1(transitive)
+ Addedpromise@7.3.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedstyled-components@3.4.10(transitive)
+ Addedstylis@3.5.4(transitive)
+ Addedstylis-rule-sheet@0.0.10(transitive)
+ Addedsupports-color@3.2.3(transitive)
+ Addedua-parser-js@0.7.40(transitive)
+ Addedwhatwg-fetch@3.6.20(transitive)