11import React from 'react' ;
22import DatePicker from 'material-ui/DatePicker' ;
33import Toggle from 'material-ui/Toggle' ;
4+ import areIntlLocalesSupported from 'intl-locales-supported' ;
45
5- const DateTimeFormat = global . Intl . DateTimeFormat ;
6+ let DateTimeFormat ;
7+
8+ if ( areIntlLocalesSupported ( [ 'en-US' ] ) ) {
9+ DateTimeFormat = global . Intl . DateTimeFormat ;
10+ } else {
11+ const IntlPolyfill = require ( 'intl' ) ;
12+ DateTimeFormat = IntlPolyfill . DateTimeFormat ;
13+ require ( 'intl/locale-data/jsonp/en-US' ) ;
14+ }
615
716const optionsStyle = {
817 maxWidth : 255 ,
@@ -29,13 +38,13 @@ export default class DatePickerExampleToggle extends React.Component {
2938 } ;
3039 }
3140
32- handleChangeMinDate = ( x , date ) => {
41+ handleChangeMinDate = ( event , date ) => {
3342 this . setState ( {
3443 minDate : date ,
3544 } ) ;
3645 } ;
3746
38- handleChangeMaxDate = ( x , date ) => {
47+ handleChangeMaxDate = ( event , date ) => {
3948 this . setState ( {
4049 maxDate : date ,
4150 } ) ;
@@ -75,6 +84,7 @@ export default class DatePickerExampleToggle extends React.Component {
7584 autoOk = { this . state . autoOk }
7685 floatingLabelText = "Min Date"
7786 defaultDate = { this . state . minDate }
87+ disableYearSelection = { this . state . disableYearSelection }
7888 />
7989 < DatePicker
8090 formatDate = { new DateTimeFormat ( 'en-US' , {
@@ -87,19 +97,20 @@ export default class DatePickerExampleToggle extends React.Component {
8797 autoOk = { this . state . autoOk }
8898 floatingLabelText = "Max Date"
8999 defaultDate = { this . state . maxDate }
100+ disableYearSelection = { this . state . disableYearSelection }
90101 />
91102 < Toggle
92103 name = "autoOk"
93104 value = "autoOk"
94105 label = "Auto Accept"
95- defaultToggled = { this . state . autoOk }
106+ toggled = { this . state . autoOk }
96107 onToggle = { this . handleToggle }
97108 />
98109 < Toggle
99110 name = "disableYearSelection"
100111 value = "disableYearSelection"
101112 label = "Disable Year Selection"
102- defaultToggled = { this . state . disableYearSelection }
113+ toggled = { this . state . disableYearSelection }
103114 onToggle = { this . handleToggle }
104115 />
105116 </ div >
0 commit comments