@semcore/portal
Advanced tools
Comparing version 2.6.0 to 2.6.1
@@ -5,2 +5,8 @@ # Changelog | ||
## [2.6.1] - 2023-04-14 | ||
### Changed | ||
- Version patch update due to children dependencies update (`@semcore/utils` [3.50.0 ~> 3.50.2]). | ||
## [2.6.0] - 2023-03-27 | ||
@@ -7,0 +13,0 @@ |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -15,5 +14,3 @@ value: true | ||
}); | ||
var _Portal = _interopRequireWildcard(require("./Portal")); | ||
Object.keys(_Portal).forEach(function (key) { | ||
@@ -20,0 +17,0 @@ if (key === "default" || key === "__esModule") return; |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -11,15 +9,8 @@ value: true | ||
exports["default"] = exports.PortalProvider = void 0; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _reactDom = require("react-dom"); | ||
var _core = _interopRequireWildcard(require("@semcore/core")); | ||
var _canUseDOM = _interopRequireDefault(require("@semcore/utils/lib/canUseDOM")); | ||
var _ref = require("@semcore/utils/lib/ref"); | ||
var PortalContext = _core.register.get('portal-context', | ||
@@ -29,14 +20,11 @@ /*#__PURE__*/ | ||
_react["default"].createContext((0, _canUseDOM["default"])() ? document.body : null)); | ||
function Portal(props) { | ||
var Children = props.Children, | ||
disablePortal = props.disablePortal, | ||
ignorePortalsStacking = props.ignorePortalsStacking; | ||
disablePortal = props.disablePortal, | ||
ignorePortalsStacking = props.ignorePortalsStacking; | ||
var container = (0, _react.useContext)(PortalContext); | ||
var _useState = (0, _react.useState)(ignorePortalsStacking ? document.body : (0, _ref.getNodeByRef)(container)), | ||
_useState2 = (0, _slicedToArray2["default"])(_useState, 2), | ||
mountNode = _useState2[0], | ||
setMountNode = _useState2[1]; | ||
_useState2 = (0, _slicedToArray2["default"])(_useState, 2), | ||
mountNode = _useState2[0], | ||
setMountNode = _useState2[1]; | ||
(0, _react.useEffect)(function () { | ||
@@ -47,17 +35,12 @@ if (!disablePortal) { | ||
}, [container, disablePortal]); | ||
if (disablePortal) { | ||
return /*#__PURE__*/_react["default"].createElement(Children, null); | ||
} | ||
return mountNode ? /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/_react["default"].createElement(Children, null), mountNode) : null; | ||
} | ||
Portal.displayName = 'Portal'; | ||
var PortalProvider = PortalContext.Provider; | ||
exports.PortalProvider = PortalProvider; | ||
var _default = (0, _core["default"])(Portal); | ||
exports["default"] = _default; | ||
//# sourceMappingURL=Portal.js.map |
@@ -11,14 +11,11 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; | ||
React.createContext(canUseDOM() ? document.body : null)); | ||
function Portal(props) { | ||
var Children = props.Children, | ||
disablePortal = props.disablePortal, | ||
ignorePortalsStacking = props.ignorePortalsStacking; | ||
disablePortal = props.disablePortal, | ||
ignorePortalsStacking = props.ignorePortalsStacking; | ||
var container = useContext(PortalContext); | ||
var _useState = useState(ignorePortalsStacking ? document.body : getNodeByRef(container)), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
mountNode = _useState2[0], | ||
setMountNode = _useState2[1]; | ||
_useState2 = _slicedToArray(_useState, 2), | ||
mountNode = _useState2[0], | ||
setMountNode = _useState2[1]; | ||
useEffect(function () { | ||
@@ -29,10 +26,7 @@ if (!disablePortal) { | ||
}, [container, disablePortal]); | ||
if (disablePortal) { | ||
return /*#__PURE__*/React.createElement(Children, null); | ||
} | ||
return mountNode ? /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(Children, null), mountNode) : null; | ||
} | ||
Portal.displayName = 'Portal'; | ||
@@ -39,0 +33,0 @@ var PortalProvider = PortalContext.Provider; |
{ | ||
"name": "@semcore/portal", | ||
"description": "Semrush Portal Component", | ||
"version": "2.6.0", | ||
"version": "2.6.1", | ||
"main": "lib/cjs/index.js", | ||
@@ -6,0 +6,0 @@ "module": "lib/es6/index.js", |
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
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
20081