Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(Portal): update typings and propTypes usage #1300

Merged
merged 1 commit into from
Feb 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions src/addons/Portal/Portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,

Expand All @@ -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,

Expand Down Expand Up @@ -132,7 +127,10 @@ class Portal extends Component {
'open',
]

static _meta = _meta
static _meta = {
name: 'Portal',
type: META.TYPES.ADDON,
}

state = {}

Expand Down
13 changes: 9 additions & 4 deletions src/addons/Portal/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as React from 'react';

export interface PortalProps {
[key: string]: any;

/** Primary content. */
children?: React.ReactNode;

/** Additional classes. */
className?: string;

Expand Down Expand Up @@ -52,31 +57,31 @@ export interface PortalProps {
* @param {SyntheticEvent} event - React's original SyntheticEvent.
* @param {object} data - All props.
*/
onClose?: React.MouseEventHandler<HTMLDivElement>;
onClose?: (event: React.MouseEvent<HTMLElement>, data: PortalProps) => void;

/**
* Called when the portal is mounted on the DOM
*
* @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
*
* @param {SyntheticEvent} event - React's original SyntheticEvent.
* @param {object} data - All props.
*/
onOpen?: React.MouseEventHandler<HTMLDivElement>;
onOpen?: (event: React.MouseEvent<HTMLElement>, data: PortalProps) => void;

/**
* Called when the portal is unmounted from the DOM
*
* @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;
Expand Down