1 | # rc-dialog
|
2 | ---
|
3 |
|
4 | react dialog component
|
5 |
|
6 | [![NPM version][npm-image]][npm-url]
|
7 | [![build status][travis-image]][travis-url]
|
8 | [![Test coverage][coveralls-image]][coveralls-url]
|
9 | [![Dependencies][david-image]][david-url]
|
10 | [![DevDependencies][david-dev-image]][david-dev-url]
|
11 | [![npm download][download-image]][download-url]
|
12 | [![bundle size][bundlephobia-image]][bundlephobia-url]
|
13 |
|
14 | [npm-image]: http://img.shields.io/npm/v/rc-dialog.svg?style=flat-square
|
15 | [npm-url]: http://npmjs.org/package/rc-dialog
|
16 | [travis-image]: https://img.shields.io/travis/react-component/dialog/master?style=flat-square
|
17 | [travis-url]: https://travis-ci.org/react-component/dialog
|
18 | [circleci-image]: https://img.shields.io/circleci/react-component/dialog/master?style=flat-square
|
19 | [circleci-url]: https://circleci.com/gh/react-component/dialog
|
20 | [coveralls-image]: https://img.shields.io/coveralls/react-component/dialog.svg?style=flat-square
|
21 | [coveralls-url]: https://coveralls.io/r/react-component/dialog?branch=master
|
22 | [david-url]: https://david-dm.org/react-component/dialog
|
23 | [david-image]: https://david-dm.org/react-component/dialog/status.svg?style=flat-square
|
24 | [david-dev-url]: https://david-dm.org/react-component/dialog?type=dev
|
25 | [david-dev-image]: https://david-dm.org/react-component/dialog/dev-status.svg?style=flat-square
|
26 | [download-image]: https://img.shields.io/npm/dm/rc-dialog.svg?style=flat-square
|
27 | [download-url]: https://npmjs.org/package/rc-dialog
|
28 | [bundlephobia-url]: https://bundlephobia.com/result?p=rc-dialog
|
29 | [bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-dialog
|
30 |
|
31 | ## Screenshot
|
32 |
|
33 | <img src="http://gtms04.alicdn.com/tps/i4/TB1dp5lHXXXXXbmXpXXyVug.FXX-664-480.png" />
|
34 |
|
35 | ## Install
|
36 |
|
37 | [![rc-dialog](https://nodei.co/npm/rc-dialog.png)](https://npmjs.org/package/rc-dialog)
|
38 |
|
39 | ## Usage
|
40 |
|
41 | ```js
|
42 | var Dialog = require('rc-dialog');
|
43 |
|
44 | ReactDOM.render(
|
45 | <Dialog title={title} onClose={callback1} visible>
|
46 | <p>first dialog</p>
|
47 | </Dialog>
|
48 | ), document.getElementById('t1'));
|
49 |
|
50 | // use dialog
|
51 | ```
|
52 |
|
53 | ## API
|
54 |
|
55 | ### rc-dialog
|
56 |
|
57 |
|
58 | <table class="table table-bordered table-striped">
|
59 | <thead>
|
60 | <tr>
|
61 | <th style="width: 100px;">name</th>
|
62 | <th style="width: 50px;">type</th>
|
63 | <th>default</th>
|
64 | <th>description</th>
|
65 | </tr>
|
66 | </thead>
|
67 | <tbody>
|
68 | <tr>
|
69 | <td>prefixCls</td>
|
70 | <td>String</td>
|
71 | <td>rc-dialog</td>
|
72 | <td>The dialog dom node's prefixCls</td>
|
73 | </tr>
|
74 | <tr>
|
75 | <td>className</td>
|
76 | <td>String</td>
|
77 | <td></td>
|
78 | <td>additional className for dialog</td>
|
79 | </tr>
|
80 | <tr>
|
81 | <td>wrapClassName</td>
|
82 | <td>String</td>
|
83 | <td></td>
|
84 | <td>additional className for dialog wrap</td>
|
85 | </tr>
|
86 | <tr>
|
87 | <td>style</td>
|
88 | <td>Object</td>
|
89 | <td>{}</td>
|
90 | <td>Root style for dialog element.Such as width, height</td>
|
91 | </tr>
|
92 | <tr>
|
93 | <td>zIndex</td>
|
94 | <td>Number</td>
|
95 | <td></td>
|
96 | <td></td>
|
97 | </tr>
|
98 | <tr>
|
99 | <td>bodyStyle</td>
|
100 | <td>Object</td>
|
101 | <td>{}</td>
|
102 | <td>body style for dialog body element.Such as height</td>
|
103 | </tr>
|
104 | <tr>
|
105 | <td>maskStyle</td>
|
106 | <td>Object</td>
|
107 | <td>{}</td>
|
108 | <td>style for mask element.</td>
|
109 | </tr>
|
110 | <tr>
|
111 | <td>visible</td>
|
112 | <td>Boolean</td>
|
113 | <td>false</td>
|
114 | <td>current dialog's visible status</td>
|
115 | </tr>
|
116 | <tr>
|
117 | <td>animation</td>
|
118 | <td>String</td>
|
119 | <td></td>
|
120 | <td>part of dialog animation css class name</td>
|
121 | </tr>
|
122 | <tr>
|
123 | <td>maskAnimation</td>
|
124 | <td>String</td>
|
125 | <td></td>
|
126 | <td>part of dialog's mask animation css class name</td>
|
127 | </tr>
|
128 | <tr>
|
129 | <td>transitionName</td>
|
130 | <td>String</td>
|
131 | <td></td>
|
132 | <td>dialog animation css class name</td>
|
133 | </tr>
|
134 | <tr>
|
135 | <td>maskTransitionName</td>
|
136 | <td>String</td>
|
137 | <td></td>
|
138 | <td>mask animation css class name</td>
|
139 | </tr>
|
140 | <tr>
|
141 | <td>title</td>
|
142 | <td>String|React.Element</td>
|
143 | <td></td>
|
144 | <td>Title of the dialog</td>
|
145 | </tr>
|
146 | <tr>
|
147 | <td>footer</td>
|
148 | <td>React.Element</td>
|
149 | <td></td>
|
150 | <td>footer of the dialog</td>
|
151 | </tr>
|
152 | <tr>
|
153 | <td>closable</td>
|
154 | <td>Boolean</td>
|
155 | <td>true</td>
|
156 | <td>whether show close button</td>
|
157 | </tr>
|
158 | <tr>
|
159 | <td>mask</td>
|
160 | <td>Boolean</td>
|
161 | <td>true</td>
|
162 | <td>whether show mask</td>
|
163 | </tr>
|
164 | <tr>
|
165 | <td>maskClosable</td>
|
166 | <td>Boolean</td>
|
167 | <td>true</td>
|
168 | <td>whether click mask to close</td>
|
169 | </tr>
|
170 | <tr>
|
171 | <td>keyboard</td>
|
172 | <td>Boolean</td>
|
173 | <td>true</td>
|
174 | <td>whether support press esc to close</td>
|
175 | </tr>
|
176 | <tr>
|
177 | <td>mousePosition</td>
|
178 | <td>{x:number,y:number}</td>
|
179 | <td></td>
|
180 | <td>set pageX and pageY of current mouse(it will cause transform origin to be set).</td>
|
181 | </tr>
|
182 | <tr>
|
183 | <td>onClose</td>
|
184 | <td>function()</td>
|
185 | <td></td>
|
186 | <td>called when click close button or mask</td>
|
187 | </tr>
|
188 | <tr>
|
189 | <td>afterClose</td>
|
190 | <td>function()</td>
|
191 | <td></td>
|
192 | <td>called when close animation end</td>
|
193 | </tr>
|
194 | <tr>
|
195 | <td>getContainer</td>
|
196 | <td>function(): HTMLElement</td>
|
197 | <td></td>
|
198 | <td>to determine where Dialog will be mounted</td>
|
199 | </tr>
|
200 | <tr>
|
201 | <td>destroyOnClose</td>
|
202 | <td>Boolean</td>
|
203 | <td>false</td>
|
204 | <td>to unmount child compenents on onClose</td>
|
205 | </tr>
|
206 | <tr>
|
207 | <td>closeIcon</td>
|
208 | <td>ReactNode</td>
|
209 | <td></td>
|
210 | <td>specific the close icon.</td>
|
211 | </tr>
|
212 | <tr>
|
213 | <td>forceRender</td>
|
214 | <td>Boolean</td>
|
215 | <td>false</td>
|
216 | <td>Create dialog dom node before dialog first show </td>
|
217 | </tr>
|
218 | <tr>
|
219 | <td>focusTriggerAfterClose</td>
|
220 | <td>Boolean</td>
|
221 | <td>true</td>
|
222 | <td>focus trigger element when dialog closed</td>
|
223 | </tr>
|
224 | </tbody>
|
225 | </table>
|
226 |
|
227 | ## Development
|
228 |
|
229 | ```
|
230 | npm install
|
231 | npm start
|
232 | ```
|
233 |
|
234 | ## Example
|
235 |
|
236 | http://localhost:8007/examples/
|
237 |
|
238 | online example: http://react-component.github.io/dialog/
|
239 |
|
240 | ## Test Case
|
241 |
|
242 | ```
|
243 | npm test
|
244 | npm run chrome-test
|
245 | ```
|
246 |
|
247 | ## Coverage
|
248 |
|
249 | ```
|
250 | npm run coverage
|
251 | ```
|
252 |
|
253 | open coverage/ dir
|
254 |
|
255 |
|
256 | ## License
|
257 |
|
258 | rc-dialog is released under the MIT license.
|