Skip to content

Commit 9155be0

Browse files
✨ [feature] update some depend packages(#15)
1 parent 1feaa24 commit 9155be0

14 files changed

+6672
-4797
lines changed

examples/basic/index.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import React from 'react';
33
import ReactDOM from 'react-dom';
44
import { convertDate } from '../../lib/time.js';
55
import DatePicker from '../../lib/index';
6-
// import DatePicker from '../../dist/react-mobile-datepicker.js';
7-
8-
window.Perf = require('react-addons-perf');
96

107
(function main() {
118
class App extends React.Component {
@@ -61,9 +58,8 @@ window.Perf = require('react-addons-perf');
6158
</a>
6259
</div>
6360
<DatePicker
64-
dateFormat={['hh', 'mm', 'ss']}
65-
showFormat="hh:mm:ss"
6661
value={this.state.time}
62+
min={new Date(2017, 2, 2)}
6763
theme={this.state.theme}
6864
isOpen={this.state.isOpen}
6965
onSelect={this.handleSelect}

lib/DatePicker.js

+19-15
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,33 @@
22
* @module DatePicker Component
33
*/
44

5-
import React, { Component, PropTypes } from 'react';
5+
import React, { Component } from 'react';
66
import DatePickerItem from './DatePickerItem.js';
77
import PureRender from './pureRender.js';
88
import { convertDate, nextDate } from './time.js';
99

10+
type Props = {
11+
theme: string,
12+
value: Object,
13+
min: Object,
14+
max: Object,
15+
dateFormat: Array<*>,
16+
showFormat: string,
17+
confirmText: string,
18+
cancelText: string,
19+
onSelect: Function,
20+
onCancel: Function,
21+
}
22+
23+
type State = {
24+
value: Date,
25+
}
26+
1027
/**
1128
* Class DatePicker Component Class
1229
* @extends Component
1330
*/
14-
class DatePicker extends Component {
31+
class DatePicker extends Component<void, Props, State> {
1532
constructor(props) {
1633
super(props);
1734
this.state = {
@@ -99,17 +116,4 @@ class DatePicker extends Component {
99116
}
100117
}
101118

102-
DatePicker.propTypes = {
103-
theme: PropTypes.string,
104-
value: PropTypes.object,
105-
min: PropTypes.object,
106-
max: PropTypes.object,
107-
dateFormat: PropTypes.array,
108-
showFormat: PropTypes.string,
109-
confirmText: PropTypes.string,
110-
cancelText: PropTypes.string,
111-
onSelect: PropTypes.func,
112-
onCancel: PropTypes.func,
113-
};
114-
115119
export default DatePicker;

lib/DatePickerItem.js

+14-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* @module Date组件
44
*/
5-
import React, { Component, PropTypes } from 'react';
5+
import React, { Component } from 'react';
66
import * as TimeUtil from './time.js';
77
import { shallowEqual } from './pureRender.js';
88
import { addPrefixCss, formatCss } from './prefix.js';
@@ -40,12 +40,24 @@ const getTimeType = format => {
4040
throw new Error('时间格式必须包含 Y, M, D, h, m 或 s字母');
4141
}
4242

43+
type Props = {
44+
value: Object,
45+
min: Object,
46+
max: Object,
47+
format: string,
48+
onSelect: Function,
49+
}
50+
51+
type State = {
52+
translateY: number,
53+
marginTop: number,
54+
}
4355

4456
/**
4557
* Class Date组件类
4658
* @extends Component
4759
*/
48-
class DatePickerItem extends Component {
60+
class DatePickerItem extends Component<void, Props, State> {
4961
constructor(props) {
5062
super(props);
5163
this.animating = false; // 判断是否在transition过渡动画之中
@@ -329,12 +341,4 @@ class DatePickerItem extends Component {
329341
}
330342
}
331343

332-
DatePickerItem.propTypes = {
333-
value: PropTypes.object,
334-
min: PropTypes.object,
335-
max: PropTypes.object,
336-
format: PropTypes.string,
337-
onSelect: PropTypes.func,
338-
};
339-
340344
export default DatePickerItem;

lib/Modal.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
import React, { Component, PropTypes } from 'react';
1+
import React, { Component } from 'react';
22
import ReactDOM from 'react-dom';
33
const renderSubtreeIntoContainer = ReactDOM.unstable_renderSubtreeIntoContainer;
44

5+
type Props = {
6+
children: React.Element<*>,
7+
isOpen: boolean,
8+
}
59

6-
class Modal extends Component {
7-
static propTypes = {
8-
children: PropTypes.node,
9-
isOpen: PropTypes.bool,
10-
}
10+
type DefaultProps = {
11+
isOpen: boolean,
12+
}
13+
14+
class Modal extends Component<DefaultProps, Props, void> {
1115

1216
static defaultProps = {
1317
isOpen: false,

lib/index.js

+9-17
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import './index.css';
2-
import React, { PropTypes } from 'react';
2+
import React from 'react';
33
import DatePicker from './DatePicker.js';
44
import Modal from './Modal.js';
55

6+
type EnhanceDatePickerProps<T> = T & {
7+
isOpen: boolean,
8+
}
69

7-
function EnhanceDatePicker({ isOpen, ...props }) {
10+
function EnhanceDatePicker<T: *>({ isOpen, ...props }: EnhanceDatePickerProps<T>) {
811
function onModalClose(event) {
912
if (event.target === event.currentTarget) {
1013
props.onCancel();
@@ -21,8 +24,11 @@ function EnhanceDatePicker({ isOpen, ...props }) {
2124
);
2225
}
2326

27+
type ModalDatePickerProps<T> = T & {
28+
isPopup: boolean,
29+
}
2430

25-
function ModalDatePicker({ isPopup, ...props }) {
31+
function ModalDatePicker<T: *>({ isPopup, ...props }: ModalDatePickerProps<T>) {
2632
if (!isPopup) {
2733
return <DatePicker {...props} />;
2834
}
@@ -34,20 +40,6 @@ function ModalDatePicker({ isPopup, ...props }) {
3440
);
3541
}
3642

37-
ModalDatePicker.propTypes = {
38-
isPopup: PropTypes.bool,
39-
isOpen: PropTypes.bool,
40-
theme: PropTypes.string,
41-
value: PropTypes.object,
42-
min: PropTypes.object,
43-
max: PropTypes.object,
44-
dateFormat: PropTypes.array,
45-
confirmText: PropTypes.string,
46-
cancelText: PropTypes.string,
47-
onSelect: PropTypes.func,
48-
onCancel: PropTypes.func,
49-
};
50-
5143
ModalDatePicker.defaultProps = {
5244
isPopup: true,
5345
isOpen: false,

0 commit comments

Comments
 (0)