Socket
Socket
Sign inDemoInstall

@semcore/portal

Package Overview
Dependencies
Maintainers
2
Versions
208
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@semcore/portal - npm Package Compare versions

Comparing version 3.18.0 to 3.20.0-prerelease.0

12

CHANGELOG.md

@@ -5,2 +5,14 @@ # Changelog

## [3.20.0] - 2024-03-26
### Added
- Api to get know if the portal is mounted (`onMount` prop).
## [3.19.0] - 2024-03-25
### Fixed
- Portal hydration errors in nextjs and astro.
## [3.18.0] - 2024-03-15

@@ -7,0 +19,0 @@

13

lib/cjs/Portal.js

@@ -19,10 +19,6 @@ "use strict";

disablePortal = props.disablePortal,
ignorePortalsStacking = props.ignorePortalsStacking;
ignorePortalsStacking = props.ignorePortalsStacking,
onMount = props.onMount;
var container = _react["default"].useContext(PortalContext);
var initialMountNode = _react["default"].useMemo(function () {
if (!ignorePortalsStacking) return (0, _ref.getNodeByRef)(container);
if ((0, _canUseDOM["default"])()) return document.body;
return null;
}, [ignorePortalsStacking, container]);
var _React$useState = _react["default"].useState(initialMountNode),
var _React$useState = _react["default"].useState(null),
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),

@@ -33,2 +29,3 @@ mountNode = _React$useState2[0],

if (disablePortal) return;
onMount === null || onMount === void 0 ? void 0 : onMount(true);
if (ignorePortalsStacking) {

@@ -39,3 +36,3 @@ setMountNode((0, _canUseDOM["default"])() ? document.body : null);

setMountNode((0, _ref.getNodeByRef)(container));
}, [container, disablePortal]);
}, [container, disablePortal, onMount]);
if (disablePortal) {

@@ -42,0 +39,0 @@ return /*#__PURE__*/_react["default"].createElement(Children, null);

@@ -14,10 +14,6 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";

disablePortal = props.disablePortal,
ignorePortalsStacking = props.ignorePortalsStacking;
ignorePortalsStacking = props.ignorePortalsStacking,
onMount = props.onMount;
var container = React.useContext(PortalContext);
var initialMountNode = React.useMemo(function () {
if (!ignorePortalsStacking) return getNodeByRef(container);
if (canUseDOM()) return document.body;
return null;
}, [ignorePortalsStacking, container]);
var _React$useState = React.useState(initialMountNode),
var _React$useState = React.useState(null),
_React$useState2 = _slicedToArray(_React$useState, 2),

@@ -28,2 +24,3 @@ mountNode = _React$useState2[0],

if (disablePortal) return;
onMount === null || onMount === void 0 ? void 0 : onMount(true);
if (ignorePortalsStacking) {

@@ -34,3 +31,3 @@ setMountNode(canUseDOM() ? document.body : null);

setMountNode(getNodeByRef(container));
}, [container, disablePortal]);
}, [container, disablePortal, onMount]);
if (disablePortal) {

@@ -37,0 +34,0 @@ return /*#__PURE__*/React.createElement(Children, null);

@@ -12,2 +12,4 @@ import React from 'react';

ignorePortalsStacking?: boolean;
/** Called when portal mount state changes */
onMount?: (mounted: boolean) => void;
};

@@ -14,0 +16,0 @@ declare const PortalProvider: React.Provider<NodeByRef>;

{
"name": "@semcore/portal",
"description": "Semrush Portal Component",
"version": "3.18.0",
"version": "3.20.0-prerelease.0",
"main": "lib/cjs/index.js",

@@ -12,6 +12,6 @@ "module": "lib/es6/index.js",

"dependencies": {
"@semcore/utils": "4.21.0"
"@semcore/utils": "4.21.1-prerelease.0"
},
"peerDependencies": {
"@semcore/core": "^2.17.5",
"@semcore/core": "^2.18.1-prerelease.0",
"react": "16.8 - 18",

@@ -18,0 +18,0 @@ "react-dom": "16.8 - 18"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc