Skip to content

Commit a886aaa

Browse files
layershifterharel
authored andcommitted
style(Portal): update typings and propTypes usage (Semantic-Org#1300)
1 parent 618fbb5 commit a886aaa

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

src/addons/Portal/Portal.js

+13-15
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,14 @@ import ReactDOM from 'react-dom'
44

55
import {
66
AutoControlledComponent as Component,
7-
keyboardKey,
87
isBrowser,
8+
keyboardKey,
99
makeDebugger,
1010
META,
1111
} from '../../lib'
1212

1313
const debug = makeDebugger('portal')
1414

15-
const _meta = {
16-
name: 'Portal',
17-
type: META.TYPES.ADDON,
18-
}
19-
2015
/**
2116
* A component that allows you to render children outside their parent.
2217
* @see Modal
@@ -29,14 +24,6 @@ class Portal extends Component {
2924
/** Additional classes. */
3025
className: PropTypes.string,
3126

32-
/**
33-
* Controls whether or not the portal should close on a click on the portal background.
34-
* NOTE: This differs from closeOnDocumentClick:
35-
* - DocumentClick - any click not within the portal
36-
* - RootNodeClick - a click not within the portal but within the portal's wrapper
37-
*/
38-
closeOnRootNodeClick: PropTypes.bool,
39-
4027
/** Controls whether or not the portal should close when the document is clicked. */
4128
closeOnDocumentClick: PropTypes.bool,
4229

@@ -50,6 +37,14 @@ class Portal extends Component {
5037
*/
5138
closeOnPortalMouseLeave: PropTypes.bool,
5239

40+
/**
41+
* Controls whether or not the portal should close on a click on the portal background.
42+
* NOTE: This differs from closeOnDocumentClick:
43+
* - DocumentClick - any click not within the portal
44+
* - RootNodeClick - a click not within the portal but within the portal's wrapper
45+
*/
46+
closeOnRootNodeClick: PropTypes.bool,
47+
5348
/** Controls whether or not the portal should close on blur of the trigger. */
5449
closeOnTriggerBlur: PropTypes.bool,
5550

@@ -132,7 +127,10 @@ class Portal extends Component {
132127
'open',
133128
]
134129

135-
static _meta = _meta
130+
static _meta = {
131+
name: 'Portal',
132+
type: META.TYPES.ADDON,
133+
}
136134

137135
state = {}
138136

src/addons/Portal/index.d.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import * as React from 'react';
22

33
export interface PortalProps {
4+
[key: string]: any;
5+
6+
/** Primary content. */
7+
children?: React.ReactNode;
8+
49
/** Additional classes. */
510
className?: string;
611

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

5762
/**
5863
* Called when the portal is mounted on the DOM
5964
*
6065
* @param {null}
6166
* @param {object} data - All props.
6267
*/
63-
onMount?: (nothing: null, props: PortalProps) => void;
68+
onMount?: (nothing: null, data: PortalProps) => void;
6469

6570
/**
6671
* Called when an open event happens
6772
*
6873
* @param {SyntheticEvent} event - React's original SyntheticEvent.
6974
* @param {object} data - All props.
7075
*/
71-
onOpen?: React.MouseEventHandler<HTMLDivElement>;
76+
onOpen?: (event: React.MouseEvent<HTMLElement>, data: PortalProps) => void;
7277

7378
/**
7479
* Called when the portal is unmounted from the DOM
7580
*
7681
* @param {null}
7782
* @param {object} data - All props.
7883
*/
79-
onUnmount?: (nothing: null, props: PortalProps) => void;
84+
onUnmount?: (nothing: null, data: PortalProps) => void;
8085

8186
/** Controls whether or not the portal is displayed. */
8287
open?: boolean;

0 commit comments

Comments
 (0)