Skip to content

Commit 93ab25e

Browse files
committed
文档更新
1 parent f88db65 commit 93ab25e

File tree

2 files changed

+83
-44
lines changed

2 files changed

+83
-44
lines changed

README.md

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,44 +29,65 @@ render(){
2929

3030
```
3131

32-
### propTypes
32+
### Interfaces
3333

3434
```ts
3535
type statusTypes = 'unmounted' | 'exited' | 'entering' | 'entered' | 'exiting' ;
3636

37-
interface PopupProps {
38-
children?: React.ReactNode | (status: statusTypes) => React.ReactNode;
39-
prefixCls?: string;
40-
style?: React.CSSProperties;
41-
className?: string;
42-
rootClassName?: string;
43-
rootStyle?: React.CSSProperties;
44-
rootProps?: React.HTMLAttributes<any>;
45-
46-
fixed?: boolean;
47-
visible: boolean;
48-
lazy?: boolean;
37+
interface PopupProps extends React.HTMLAttributes<any> {
38+
/** 样式前缀 */
39+
prefixCls?: string;
40+
/** popup元素样式 */
41+
style?: React.CSSProperties;
42+
/** popupCSS样式名 */
43+
className?: string;
44+
/** popup根节点CSS样式名 */
45+
rootClassName?: string;
46+
/** popup根节点样式 */
47+
rootStyle?: React.CSSProperties;
48+
/** popup元素属性 */
49+
rootProps?: React.HTMLAttributes<any>;
50+
/** 否显示popup(受控) */
51+
visible?: boolean;
52+
/** 使用fixed定位popup */
53+
fixed?: boolean;
54+
/** 初始不显示的情况下不渲染组件 */
55+
lazy?: boolean;
56+
/** 当destroyOnClose=false时,组件刷新时强制更新 */
4957
forceRender?: boolean;
50-
51-
//http://reactcommunity.org/react-transition-group/css-transition
52-
transition?: CSSTransitionProps;
53-
destroyOnClose?: boolean;
54-
55-
disableMask?: boolean;
56-
mask?: boolean;
57-
maskStyle?: React.CSSProperties;
58-
maskProps?: {};
59-
maskClassName?: string;
60-
//http://reactcommunity.org/react-transition-group/css-transition
61-
maskTransition?: CSSTransitionProps;
62-
63-
component?: React.ElementType;
64-
maskComponent?: React.ElementType;
65-
rootComponent?: React.ElementType;
66-
67-
wrapContent?: (node: React.ReactNode) => React.ReactNode;
68-
69-
[prop: string]: any;
58+
/** CSSTransition参数,参考:react-transition-group */
59+
transition?: Partial<CSSTransitionProps>;
60+
/** 隐藏销毁弹组件 */
61+
destroyOnClose?: boolean;
62+
/** popup显示用于获取元素显示位置信息,大部分情况下建议直接用style */
63+
getPosition?: (
64+
dom: HTMLElement
65+
) => {
66+
top?: number | string;
67+
left?: number | string;
68+
right?: number | string;
69+
bottom?: number | string;
70+
};
71+
/** 禁用mask */
72+
disableMask?: boolean;
73+
/** 是否开启遮罩层 */
74+
mask?: boolean;
75+
/** 遮罩层样式 */
76+
maskStyle?: React.CSSProperties;
77+
/** 遮罩层组件属性 */
78+
maskProps?: React.HTMLAttributes<any>;
79+
/** 遮罩层样式名称 */
80+
maskClassName?: string;
81+
/** CSSTransition参数,参考:react-transition-group */
82+
maskTransition?: Partial<CSSTransitionProps>;
83+
/** 内部使用 */
84+
component?: React.ElementType;
85+
/** 内部使用 */
86+
maskComponent?: React.ElementType;
87+
/** 内部使用 */
88+
rootComponent?: React.ElementType;
89+
/** 内部使用 */
90+
wrapContent?: (node: React.ReactNode) => React.ReactNode;
7091
}
7192
```
7293

src/index.tsx

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,31 @@ import CSSTransition, { CSSTransitionProps } from "react-transition-group/CSSTra
88
export const version = "%VERSION%";
99

1010
export interface PopupProps extends React.HTMLAttributes<any> {
11+
/** 样式前缀 */
1112
prefixCls?: string;
13+
/** popup元素样式 */
1214
style?: React.CSSProperties;
15+
/** popupCSS样式名 */
1316
className?: string;
17+
/** popup根节点CSS样式名 */
1418
rootClassName?: string;
19+
/** popup根节点样式 */
1520
rootStyle?: React.CSSProperties;
21+
/** popup元素属性 */
1622
rootProps?: React.HTMLAttributes<any>;
17-
23+
/** 否显示popup(受控) */
1824
visible?: boolean;
25+
/** 使用fixed定位popup */
1926
fixed?: boolean;
27+
/** 初始不显示的情况下不渲染组件 */
2028
lazy?: boolean;
29+
/** 当destroyOnClose=false时,组件刷新时强制更新 */
2130
forceRender?: boolean;
22-
31+
/** CSSTransition参数,参考:react-transition-group */
2332
transition?: Partial<CSSTransitionProps>;
33+
/** 隐藏销毁弹组件 */
2434
destroyOnClose?: boolean;
35+
/** popup显示用于获取元素显示位置信息,大部分情况下建议直接用style */
2536
getPosition?: (
2637
dom: HTMLElement
2738
) => {
@@ -30,18 +41,25 @@ export interface PopupProps extends React.HTMLAttributes<any> {
3041
right?: number | string;
3142
bottom?: number | string;
3243
};
33-
44+
/** 禁用mask */
3445
disableMask?: boolean;
46+
/** 是否开启遮罩层 */
3547
mask?: boolean;
48+
/** 遮罩层样式 */
3649
maskStyle?: React.CSSProperties;
50+
/** 遮罩层组件属性 */
3751
maskProps?: React.HTMLAttributes<any>;
52+
/** 遮罩层样式名称 */
3853
maskClassName?: string;
54+
/** CSSTransition参数,参考:react-transition-group */
3955
maskTransition?: Partial<CSSTransitionProps>;
40-
56+
/** 内部使用 */
4157
component?: React.ElementType;
58+
/** 内部使用 */
4259
maskComponent?: React.ElementType;
60+
/** 内部使用 */
4361
rootComponent?: React.ElementType;
44-
62+
/** 内部使用 */
4563
wrapContent?: (node: React.ReactNode) => React.ReactNode;
4664
}
4765

@@ -147,13 +165,13 @@ export class Popup extends React.Component<PopupProps, {}> {
147165
}
148166
}
149167

150-
onEnter(
168+
protected onEnter(
151169
{ onEnter }: CSSTransitionProps,
152170
isMask: boolean,
153171
node: HTMLElement,
154172
appearing: boolean
155173
) {
156-
const { destroyOnClose, getPosition } = this.props;
174+
const { getPosition } = this.props;
157175
const rootElement = findDOMNode(this.rootInstance) as HTMLElement;
158176
const popupElement = findDOMNode(this.popupInstance) as HTMLElement;
159177
const maskElement = findDOMNode(this.maskInstance) as HTMLElement;
@@ -210,7 +228,7 @@ export class Popup extends React.Component<PopupProps, {}> {
210228
}
211229
}
212230

213-
onEntered({ onEntered }, isMask: boolean, node: HTMLElement, appearing: boolean) {
231+
protected onEntered({ onEntered }, isMask: boolean, node: HTMLElement, appearing: boolean) {
214232
if (isMask) {
215233
this.inMaskTransition = false;
216234
} else {
@@ -222,7 +240,7 @@ export class Popup extends React.Component<PopupProps, {}> {
222240
}
223241
}
224242

225-
onExit({ onExit }: CSSTransitionProps, isMask: boolean, node: HTMLElement) {
243+
protected onExit({ onExit }: CSSTransitionProps, isMask: boolean, node: HTMLElement) {
226244
if (isMask) {
227245
this.inMaskTransition = true;
228246
} else {
@@ -234,7 +252,7 @@ export class Popup extends React.Component<PopupProps, {}> {
234252
}
235253
}
236254

237-
onExited({ onExited }: CSSTransitionProps, isMask: boolean, node: HTMLElement) {
255+
protected onExited({ onExited }: CSSTransitionProps, isMask: boolean, node: HTMLElement) {
238256
const { destroyOnClose, visible } = this.props;
239257
const rootElement = findDOMNode(this.rootInstance) as HTMLElement;
240258
const popupElement = findDOMNode(this.popupInstance) as HTMLElement;
@@ -269,7 +287,7 @@ export class Popup extends React.Component<PopupProps, {}> {
269287
}
270288
}
271289

272-
renderPopupMask() {
290+
protected renderPopupMask() {
273291
const {
274292
prefixCls,
275293
visible,

0 commit comments

Comments
 (0)