diff --git a/src/addons/Portal/Portal.js b/src/addons/Portal/Portal.js index b97a0c24b3..794db7c5ca 100644 --- a/src/addons/Portal/Portal.js +++ b/src/addons/Portal/Portal.js @@ -4,19 +4,14 @@ import ReactDOM from 'react-dom' import { AutoControlledComponent as Component, - keyboardKey, isBrowser, + keyboardKey, makeDebugger, META, } from '../../lib' const debug = makeDebugger('portal') -const _meta = { - name: 'Portal', - type: META.TYPES.ADDON, -} - /** * A component that allows you to render children outside their parent. * @see Modal @@ -29,14 +24,6 @@ class Portal extends Component { /** Additional classes. */ className: PropTypes.string, - /** - * Controls whether or not the portal should close on a click on the portal background. - * NOTE: This differs from closeOnDocumentClick: - * - DocumentClick - any click not within the portal - * - RootNodeClick - a click not within the portal but within the portal's wrapper - */ - closeOnRootNodeClick: PropTypes.bool, - /** Controls whether or not the portal should close when the document is clicked. */ closeOnDocumentClick: PropTypes.bool, @@ -50,6 +37,14 @@ class Portal extends Component { */ closeOnPortalMouseLeave: PropTypes.bool, + /** + * Controls whether or not the portal should close on a click on the portal background. + * NOTE: This differs from closeOnDocumentClick: + * - DocumentClick - any click not within the portal + * - RootNodeClick - a click not within the portal but within the portal's wrapper + */ + closeOnRootNodeClick: PropTypes.bool, + /** Controls whether or not the portal should close on blur of the trigger. */ closeOnTriggerBlur: PropTypes.bool, @@ -132,7 +127,10 @@ class Portal extends Component { 'open', ] - static _meta = _meta + static _meta = { + name: 'Portal', + type: META.TYPES.ADDON, + } state = {} diff --git a/src/addons/Portal/index.d.ts b/src/addons/Portal/index.d.ts index f318519ff9..148fb1bf05 100644 --- a/src/addons/Portal/index.d.ts +++ b/src/addons/Portal/index.d.ts @@ -1,6 +1,11 @@ import * as React from 'react'; export interface PortalProps { + [key: string]: any; + + /** Primary content. */ + children?: React.ReactNode; + /** Additional classes. */ className?: string; @@ -52,7 +57,7 @@ export interface PortalProps { * @param {SyntheticEvent} event - React's original SyntheticEvent. * @param {object} data - All props. */ - onClose?: React.MouseEventHandler; + onClose?: (event: React.MouseEvent, data: PortalProps) => void; /** * Called when the portal is mounted on the DOM @@ -60,7 +65,7 @@ export interface PortalProps { * @param {null} * @param {object} data - All props. */ - onMount?: (nothing: null, props: PortalProps) => void; + onMount?: (nothing: null, data: PortalProps) => void; /** * Called when an open event happens @@ -68,7 +73,7 @@ export interface PortalProps { * @param {SyntheticEvent} event - React's original SyntheticEvent. * @param {object} data - All props. */ - onOpen?: React.MouseEventHandler; + onOpen?: (event: React.MouseEvent, data: PortalProps) => void; /** * Called when the portal is unmounted from the DOM @@ -76,7 +81,7 @@ export interface PortalProps { * @param {null} * @param {object} data - All props. */ - onUnmount?: (nothing: null, props: PortalProps) => void; + onUnmount?: (nothing: null, data: PortalProps) => void; /** Controls whether or not the portal is displayed. */ open?: boolean;