@leafygreen-ui/portal
Advanced tools
Comparing version 2.0.1 to 2.1.0
# @leafygreen-ui/portal | ||
## 2.1.0 | ||
### Minor Changes | ||
- 1c797b3: Portal allows setting a className prop for the containing element | ||
### Patch Changes | ||
- Updated dependencies [1c797b3] | ||
- @leafygreen-ui/lib@4.5.0 | ||
## 2.0.1 | ||
@@ -4,0 +15,0 @@ |
import Portal from './Portal'; | ||
export default Portal; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"),require("prop-types"),require("react-dom"));else if("function"==typeof define&&define.amd)define(["react","prop-types","react-dom"],t);else{var n="object"==typeof exports?t(require("react"),require("prop-types"),require("react-dom")):t(e.react,e["prop-types"],e["react-dom"]);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(global,(function(e,t,n){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=((r=n(1))&&r.__esModule?r:{default:r}).default;t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=n(2),u=(r=n(3))&&r.__esModule?r:{default:r},i=n(4);function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=function(e){function t(){var e,n,r,o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var u=arguments.length,i=new Array(u),c=0;c<u;c++)i[c]=arguments[c];return r=this,n=!(o=(e=f(t)).call.apply(e,[this].concat(i)))||"object"!==a(o)&&"function"!=typeof o?l(r):o,d(l(n),"state",{defaultContainer:null}),n}var n,r,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t)}(t,e),n=t,o=[{key:"createPortalContainer",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",t=document.createElement(e);return document.body.appendChild(t),{el:t,remove:function(){return document.body.removeChild(t)}}}}],(r=[{key:"componentDidMount",value:function(){this.props.container||this.setState({defaultContainer:t.createPortalContainer()})}},{key:"shouldComponentUpdate",value:function(e){return this.props.container===e.container||(console.error("Changing the Portal container is not supported behavior and may cause unintended side effects. Instead, create a new Portal instance"),!1)}},{key:"componentWillUnmount",value:function(){var e=this.state.defaultContainer;e&&e.remove()}},{key:"render",value:function(){var e=this.state.defaultContainer,t=this.props,n=t.container,r=void 0===n?e&&e.el:n,o=t.children;return r&&(0,i.createPortal)(o,r)}}])&&c(n.prototype,r),o&&c(n,o),t}(o.Component);t.default=s,d(s,"displayName","Portal"),d(s,"propTypes",{children:u.default.node,container:u.default.oneOfType([u.default.node,u.default.object])})},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t){e.exports=n}])})); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"),require("prop-types"),require("react-dom"));else if("function"==typeof define&&define.amd)define(["react","prop-types","react-dom"],t);else{var r="object"==typeof exports?t(require("react"),require("prop-types"),require("react-dom")):t(e.react,e["prop-types"],e["react-dom"]);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(global,(function(e,t,r){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=((n=r(1))&&n.__esModule?n:{default:n}).default;t.default=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,o=r(2),a=(n=r(3))&&n.__esModule?n:{default:n},u=r(4);function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,a=void 0;try{for(var u,i=e[Symbol.iterator]();!(n=(u=i.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw a}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function l(e){var t,r,n,a=i((0,o.useState)(null!==(t=e.container)&&void 0!==t?t:(r=e.className,n=document.createElement("div"),r&&(n.className=r),document.body.appendChild(n),n)),1)[0],c=(0,o.useRef)(e);return(0,o.useEffect)((function(){var t,r=c.current;(c.current=e,r.container===e.container)?r.className!==e.className&&(a.className=null!==(t=e.className)&&void 0!==t?t:""):console.error("Changing the Portal container is not supported behavior and may cause unintended side effects. Instead, create a new Portal instance.")})),(0,o.useEffect)((function(){return function(){e.container||a.remove()}}),[]),(0,u.createPortal)(e.children,a)}l.displayName="Portal",l.propTypes={children:a.default.node,className:a.default.string,container:a.default.oneOfType([a.default.node,a.default.object])};var f=l;t.default=f},function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t){e.exports=r}])})); | ||
//# sourceMappingURL=index.node.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"),require("prop-types"),require("react-dom"));else if("function"==typeof define&&define.amd)define(["react","prop-types","react-dom"],t);else{var n="object"==typeof exports?t(require("react"),require("prop-types"),require("react-dom")):t(e.react,e["prop-types"],e["react-dom"]);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(e,t,n){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=((r=n(1))&&r.__esModule?r:{default:r}).default;t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=n(2),u=(r=n(3))&&r.__esModule?r:{default:r},i=n(4);function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=function(e){function t(){var e,n,r,o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var u=arguments.length,i=new Array(u),c=0;c<u;c++)i[c]=arguments[c];return r=this,n=!(o=(e=f(t)).call.apply(e,[this].concat(i)))||"object"!==a(o)&&"function"!=typeof o?l(r):o,d(l(n),"state",{defaultContainer:null}),n}var n,r,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t)}(t,e),n=t,o=[{key:"createPortalContainer",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",t=document.createElement(e);return document.body.appendChild(t),{el:t,remove:function(){return document.body.removeChild(t)}}}}],(r=[{key:"componentDidMount",value:function(){this.props.container||this.setState({defaultContainer:t.createPortalContainer()})}},{key:"shouldComponentUpdate",value:function(e){return this.props.container===e.container||(console.error("Changing the Portal container is not supported behavior and may cause unintended side effects. Instead, create a new Portal instance"),!1)}},{key:"componentWillUnmount",value:function(){var e=this.state.defaultContainer;e&&e.remove()}},{key:"render",value:function(){var e=this.state.defaultContainer,t=this.props,n=t.container,r=void 0===n?e&&e.el:n,o=t.children;return r&&(0,i.createPortal)(o,r)}}])&&c(n.prototype,r),o&&c(n,o),t}(o.Component);t.default=s,d(s,"displayName","Portal"),d(s,"propTypes",{children:u.default.node,container:u.default.oneOfType([u.default.node,u.default.object])})},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t){e.exports=n}])})); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"),require("prop-types"),require("react-dom"));else if("function"==typeof define&&define.amd)define(["react","prop-types","react-dom"],t);else{var r="object"==typeof exports?t(require("react"),require("prop-types"),require("react-dom")):t(e.react,e["prop-types"],e["react-dom"]);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(window,(function(e,t,r){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=((n=r(1))&&n.__esModule?n:{default:n}).default;t.default=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,o=r(2),u=(n=r(3))&&n.__esModule?n:{default:n},a=r(4);function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,u=void 0;try{for(var a,i=e[Symbol.iterator]();!(n=(a=i.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw u}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function f(e){var t,r,n,u=i((0,o.useState)(null!==(t=e.container)&&void 0!==t?t:(r=e.className,n=document.createElement("div"),r&&(n.className=r),document.body.appendChild(n),n)),1)[0],c=(0,o.useRef)(e);return(0,o.useEffect)((function(){var t,r=c.current;(c.current=e,r.container===e.container)?r.className!==e.className&&(u.className=null!==(t=e.className)&&void 0!==t?t:""):console.error("Changing the Portal container is not supported behavior and may cause unintended side effects. Instead, create a new Portal instance.")})),(0,o.useEffect)((function(){return function(){e.container||u.remove()}}),[]),(0,a.createPortal)(e.children,u)}f.displayName="Portal",f.propTypes={children:u.default.node,className:u.default.string,container:u.default.oneOfType([u.default.node,u.default.object])};var l=f;t.default=l},function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t){e.exports=r}])})); | ||
//# sourceMappingURL=index.web.js.map |
@@ -1,27 +0,21 @@ | ||
import { Component } from 'react'; | ||
/// <reference types="react" /> | ||
import type { OneOf } from '@leafygreen-ui/lib'; | ||
import PropTypes from 'prop-types'; | ||
interface PortalContainer { | ||
el: Element; | ||
remove: () => Element; | ||
} | ||
interface PortalProps { | ||
declare type PortalProps = { | ||
children?: React.ReactNode; | ||
container?: HTMLElement; | ||
} | ||
interface PortalState { | ||
defaultContainer: PortalContainer | null; | ||
} | ||
export default class Portal extends Component<PortalProps, PortalState> { | ||
static createPortalContainer(nodeType?: keyof HTMLElementTagNameMap): PortalContainer; | ||
static displayName: string; | ||
static propTypes: { | ||
} & OneOf<{ | ||
container: HTMLElement; | ||
}, { | ||
className?: string; | ||
}>; | ||
declare function Portal(props: PortalProps): import("react").ReactPortal; | ||
declare namespace Portal { | ||
var displayName: string; | ||
var propTypes: { | ||
children: PropTypes.Requireable<PropTypes.ReactNodeLike>; | ||
className: PropTypes.Requireable<string>; | ||
container: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>; | ||
}; | ||
state: PortalState; | ||
componentDidMount(): void; | ||
shouldComponentUpdate(nextProps: PortalProps): boolean; | ||
componentWillUnmount(): void; | ||
render(): import("react").ReactPortal | null; | ||
} | ||
export {}; | ||
export default Portal; | ||
//# sourceMappingURL=Portal.d.ts.map |
{ | ||
"name": "@leafygreen-ui/portal", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "LeafyGreen UI Kit Portal", | ||
@@ -19,5 +19,5 @@ "browser": "./dist/index.web.js", | ||
"dependencies": { | ||
"@leafygreen-ui/lib": "^4.4.1" | ||
"@leafygreen-ui/lib": "^4.5.0" | ||
}, | ||
"gitHead": "dd71a2d404218ccec2e657df9c0263dc1c15b9e0" | ||
} |
@@ -5,2 +5,3 @@ { | ||
"declarationDir": "dist", | ||
"outDir": "dist", | ||
"rootDir": "src" | ||
@@ -7,0 +8,0 @@ }, |
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
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
328094
21
340
+ Added@jridgewell/gen-mapping@0.3.7(transitive)
+ Added@jridgewell/sourcemap-codec@1.4.16-beta.0(transitive)
+ Addedjsesc@3.0.2(transitive)
- Removed@jridgewell/gen-mapping@0.3.8(transitive)
- Removed@jridgewell/set-array@1.2.1(transitive)
- Removedjsesc@3.1.0(transitive)
Updated@leafygreen-ui/lib@^4.5.0