forked from inno-v/react-date-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.jsx
184 lines (155 loc) · 4.62 KB
/
index.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
'use strict'
// require('./index.css')
// require('./theme/hackerone.css')
//
require('./style/index.scss')
import DateFormatInput from './src/DateFormatInput'
import MonthView from './src/MonthView'
import DatePicker from './src/DatePicker'
import TimePicker from './src/TimePicker'
import TimeInput from './src/TimeInput'
import NavigationView from './src/NavigationView'
import TransitionView from './src/TransitionView'
import NavBar from './src/NavBar'
import MultiMonthView from './src/MultiMonthView'
import DateField from './src/DateField'
import Clock from './src/Clock'
import { Flex, Item } from 'react-flex'
var moment = require('moment');
var React = require('react')
var render = require('react-dom').render
var range = ['2016-05-01', '2016-05-09']
var date = moment().add(-10, 'days')
var LOCALE = 'en'
var TODAY = {
en: 'Today',
fr: 'Aujourd\'hui',
de: 'Heute',
es: 'Hoy',
ro: 'Azi'
}
var GO2SELECTED = {
en: 'Go to selected',
es: 'Vaya a Favoritos',
de: 'Zum ausgewählten',
fr: 'Aller a la liste',
ro: 'Mergi la selectie'
}
function emptyFn(){}
let R = range
var App = React.createClass({
displayName: 'App',
onLocaleChange: function(event) {
LOCALE = event.target.value
this.setState({})
},
getInitialState(){
return {
date: '2016-10-03',
text: 'atext',
time: '03:45:21 pm'
}
},
onTimeChange(time){
// console.log('time', time)
this.setState({ time })
},
onChange(date){
this.setState({
date
})
},
onTextChange(text){
this.setState({
text
})
},
render: function(){
range = this.props.range || range
date = this.props.date || date
return <div style={{margin: 10}}>
{/*<DateField pattern={false} dateFormat="YYYY MM DD" />
<TransitionView transitionDuration="0.1s">
<MonthView dateFormat="DD/MM/YYYY" defaultDate="20/04/2016" onChange={() => {}}/>
</TransitionView>
<br />
*/}
{/*<TimeInput format="hh:mm:ss A" xonChange={this.onTimeChange} defaultValue={this.state.time}/>*/}
<DateFormatInput defaultValue={new Date()} autoFocus dateFormat="YYYY:MM:DD--hh:mm:ss!!"/>
<br />
<TimePicker timeFormat="HH:mm:ss" defaultTime style={{minHeight: 200, minWidth: 200}}/>
<br />
<DateField
pattern
dateFormat="YYYY-MM-DD hh:mm a"
defaultValue="2016-04-02 04:11 am"
xonChange={this.onChange}
>
<DatePicker />
</DateField>
<br />
<input defaultValue="dadas"/>
navview
{/*<MonthView
className="xxx"
minDate="2016-10-10"
maxDate="2016-11-11"
locale={LOCALE}
xrange={R}
xdefaultRange={[]}
onRenderDay={(props) => {
props.onClick = () => {
console.log(props.dateMoment.format('YYYY-MM-DD'), props.disabled)
}
return props
}}
isDisabledDay={(props) => {
return props.dateMoment.format('YYYY-MM-DD') == '2016-10-20'
}}
/>*/}
transition view
<MonthView
style={{maxWidth: 400}}
locale={LOCALE}
onRenderDay={(props) => {
props.onClick = () => {
console.log(props.dateMoment.format('YYYY-MM-DD'), props.disabled)
}
return props
}}
xisDisabledDay={(props) => {
return props.dateMoment.format('YYYY-MM-DD') == '2016-10-20'
}}
defaultRange={[]}
>
</MonthView>
<MultiMonthView
style={{maxWidth: 1200}}
maxDate="2016-08-20"
defaultRange={[]}
size={4}
/>
<p>Select locale: <select value={LOCALE} onChange={this.onLocaleChange}>
<option value="en">English (US)</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="es">Spanish</option>
<option value="ro">Romanian</option>
</select>
</p>
</div>
},
onRangeChange: function(range, r){
if (r.length){
if (r[1].timestamp - r[0].timestamp < 1000 * 60 *60*24 * 3)
return range[0]
}
// console.log(range)
R = range
this.setState({})
//range = rangeValue
//date = rangeValue
//this.setState({})
}
})
render(<App />, document.getElementById('content'))