Skip to content

Commit 915c1eb

Browse files
[Dialog] Use open instead of isOpen
1 parent 49feb2e commit 915c1eb

File tree

6 files changed

+135
-80
lines changed

6 files changed

+135
-80
lines changed

.babelrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"stage": 1,
3+
"plugins": [
4+
"dev-expression"
5+
]
6+
}

docs/src/app/components/pages/components/dialog.jsx

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ export default class DialogPage extends React.Component {
1111
super();
1212
this.state = {
1313
modal: false,
14-
showDialogStandardActions: false,
15-
showDialogCustomActions: false,
16-
showDialogScrollable: false,
14+
openDialogStandardActions: false,
15+
openDialogCustomActions: false,
16+
openDialogScrollable: false,
1717
};
1818
this._handleCustomDialogCancel = this._handleCustomDialogCancel.bind(this);
1919
this._handleCustomDialogSubmit = this._handleCustomDialogSubmit.bind(this);
@@ -76,19 +76,19 @@ export default class DialogPage extends React.Component {
7676
desc: 'Force the user to use one of the actions in the dialog. Clicking outside the dialog will not dismiss the dialog.',
7777
},
7878
{
79-
name: 'openImmediately',
79+
name: 'Deprecated: openImmediately',
8080
type: 'bool',
8181
header: 'default: false',
8282
desc: 'Deprecated: Set to true to have the dialog automatically open on mount.',
8383
},
8484
{
85-
name: 'defaultIsOpen',
85+
name: 'defaultOpen',
8686
type: 'bool',
8787
header: 'default: false',
8888
desc: 'Set to true to have the dialog automatically open on mount.',
8989
},
9090
{
91-
name: 'isOpen',
91+
name: 'open',
9292
type: 'bool',
9393
header: 'default: null',
9494
desc: 'Controls whether the Dialog is opened or not.',
@@ -117,6 +117,16 @@ export default class DialogPage extends React.Component {
117117
{
118118
name: 'Methods',
119119
infoArray: [
120+
{
121+
name: 'Deprecated: dismiss',
122+
header: 'Dialog.dismiss()',
123+
desc: 'Hides the dialog.',
124+
},
125+
{
126+
name: 'Deprecated: show',
127+
header: 'Dialog.show()',
128+
desc: 'Shows the dialog.',
129+
},
120130
{
121131
name: 'isOpen',
122132
header: 'Dialog.isOpen()',
@@ -127,6 +137,16 @@ export default class DialogPage extends React.Component {
127137
{
128138
name: 'Events',
129139
infoArray: [
140+
{
141+
name: 'Deprecated: onDismiss',
142+
header: 'function()',
143+
desc: 'Fired when the dialog is dismissed.',
144+
},
145+
{
146+
name: 'Deprecated: onShow',
147+
header: 'function()',
148+
desc: 'Fired when the dialog is shown.',
149+
},
130150
{
131151
name: 'onRequestClose',
132152
header: 'function(buttonClicked)',
@@ -182,7 +202,7 @@ export default class DialogPage extends React.Component {
182202
title="Dialog With Standard Actions"
183203
actions={standardActions}
184204
actionFocus="submit"
185-
isOpen={this.state.showDialogStandardActions}
205+
open={this.state.openDialogStandardActions}
186206
onRequestClose={this._handleRequestClose}>
187207
The actions in this window are created from the json that's passed in.
188208
</Dialog>
@@ -191,7 +211,7 @@ export default class DialogPage extends React.Component {
191211
ref="customDialog"
192212
title="Dialog With Custom Actions"
193213
actions={customActions}
194-
isOpen={this.state.showDialogCustomActions}
214+
open={this.state.openDialogCustomActions}
195215
onRequestClose={this._handleRequestClose}>
196216
The actions in this window were passed in as an array of react objects.
197217
</Dialog>
@@ -207,7 +227,7 @@ export default class DialogPage extends React.Component {
207227
actions={scrollableCustomActions}
208228
autoDetectWindowHeight={true}
209229
autoScrollBodyContent={true}
210-
isOpen={this.state.showDialogScrollable}
230+
open={this.state.openDialogScrollable}
211231
onRequestClose={this._handleRequestClose}>
212232
<div style={{height: '1000px'}}>
213233
Really long content
@@ -225,13 +245,13 @@ export default class DialogPage extends React.Component {
225245

226246
_handleCustomDialogCancel() {
227247
this.setState({
228-
showDialogCustomActions: true,
248+
openDialogCustomActions: true,
229249
});
230250
}
231251

232252
_handleCustomDialogSubmit() {
233253
this.setState({
234-
showDialogCustomActions: true,
254+
openDialogCustomActions: true,
235255
});
236256
}
237257

@@ -241,40 +261,40 @@ export default class DialogPage extends React.Component {
241261

242262
_handleScrollableDialogCancel() {
243263
this.setState({
244-
showDialogScrollable: false,
264+
openDialogScrollable: false,
245265
});
246266
}
247267

248268
_handleScrollableDialogSubmit() {
249269
this.setState({
250-
showDialogScrollable: false,
270+
openDialogScrollable: false,
251271
});
252272
}
253273

254274
_handleCustomDialogTouchTap() {
255275
this.setState({
256-
showDialogScrollable: true,
276+
openDialogScrollable: true,
257277
});
258278
}
259279

260280
_handleStandardDialogTouchTap() {
261281
this.setState({
262-
showDialogStandardActions: true,
282+
openDialogStandardActions: true,
263283
});
264284
}
265285

266286
_handleScrollableDialogTouchTap() {
267287
this.setState({
268-
showDialogScrollable: true,
288+
openDialogScrollable: true,
269289
});
270290
}
271291

272292
_handleRequestClose(buttonClicked) {
273293
if (!buttonClicked && this.state.modal) return;
274294
this.setState({
275-
showDialogStandardActions: false,
276-
showDialogCustomActions: false,
277-
showDialogScrollable: false,
295+
openDialogStandardActions: false,
296+
openDialogCustomActions: false,
297+
openDialogScrollable: false,
278298
});
279299
}
280300

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"test-base": "./node_modules/.bin/karma start",
1111
"prebuild": "rimraf lib",
1212
"lint": "gulp eslint",
13-
"build": "babel --stage 1 ./src --out-dir ./lib",
13+
"build": "babel ./src --out-dir ./lib",
1414
"prepublish": "npm run build"
1515
},
1616
"keywords": [
@@ -49,6 +49,7 @@
4949
"babel-core": "^5.8.21",
5050
"babel-eslint": "^4.1.3",
5151
"babel-loader": "^5.3.2",
52+
"babel-plugin-dev-expression": "^0.1.0",
5253
"babel-runtime": "^5.8.25",
5354
"babelify": "^6.1.3",
5455
"browserify-istanbul": "^0.2.1",

src/date-picker/date-picker-dialog.jsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ const DatePickerDialog = React.createClass({
8383

8484
getInitialState() {
8585
return {
86+
open: false,
8687
isCalendarActive: false,
8788
muiTheme: this.context.muiTheme ? this.context.muiTheme : ThemeManager.getMuiTheme(DefaultRawTheme),
8889
};
@@ -160,7 +161,9 @@ const DatePickerDialog = React.createClass({
160161
onDismiss={this._handleDialogDismiss}
161162
onShow={this._handleDialogShow}
162163
onClickAway={this._handleDialogClickAway}
163-
repositionOnUpdate={false}>
164+
repositionOnUpdate={false}
165+
open={this.state.open}
166+
onRequestClose={this.dismiss}>
164167
<Calendar
165168
DateTimeFormat={DateTimeFormat}
166169
locale={locale}
@@ -178,11 +181,15 @@ const DatePickerDialog = React.createClass({
178181
},
179182

180183
show() {
181-
this.refs.dialog.show();
184+
this.setState({
185+
open: true,
186+
});
182187
},
183188

184189
dismiss() {
185-
this.refs.dialog.dismiss();
190+
this.setState({
191+
open: false,
192+
});
186193
},
187194

188195
_onDayTouchTap() {

0 commit comments

Comments
 (0)