From 466e90da3f5c84b00f3fc003c52d3c903d3949b2 Mon Sep 17 00:00:00 2001 From: bang88 Date: Mon, 27 Jun 2016 00:05:32 +0700 Subject: [PATCH] refactor(TimePicker): rewrite TimePicker --- components/index.tsx | 2 ++ components/time-picker/index.tsx | 36 ++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/components/index.tsx b/components/index.tsx index 0b813ffeca..da07c6919e 100644 --- a/components/index.tsx +++ b/components/index.tsx @@ -4,3 +4,5 @@ export { default as Tabs } from './Tabs'; export { default as Tag } from './Tag'; +export { default as TimePicker } from './time-picker'; + diff --git a/components/time-picker/index.tsx b/components/time-picker/index.tsx index cc9163f478..45ec32fd0e 100644 --- a/components/time-picker/index.tsx +++ b/components/time-picker/index.tsx @@ -1,11 +1,39 @@ -import React from 'react'; +import * as React from 'react'; import DateTimeFormat from 'gregorian-calendar-format'; import RcTimePicker from 'rc-time-picker/lib/TimePicker'; import defaultLocale from './locale/zh_CN'; import classNames from 'classnames'; import GregorianCalendar from 'gregorian-calendar'; import assign from 'object-assign'; -export default class TimePicker extends React.Component { + +// TimePicker +export interface TimePickerProps { + /** 默认时间*/ + value?: string | Date, + /** 初始默认时间*/ + defaultValue?: string | Date, + /** 展示的时间格式 : "HH:mm:ss"、"HH:mm"、"mm:ss" */ + format?: string, + /** 时间发生变化的回调*/ + onChange?: (Date: Date) => void, + /** 禁用全部操作*/ + disabled?: boolean, + /** 没有值的时候显示的内容*/ + placeholder?: string, + /** 国际化配置*/ + locale?: Object, + /** 隐藏禁止选择的选项*/ + hideDisabledOptions?: boolean, + /** 禁止选择部分小时选项*/ + disabledHours?: Function, + /** 禁止选择部分分钟选项*/ + disabledMinutes?: Function, + /** 禁止选择部分秒选项*/ + disabledSeconds?: Function, + + style?: React.CSSProperties +} +export default class TimePicker extends React.Component { static defaultProps = { format: 'HH:mm:ss', prefixCls: 'ant-time-picker', @@ -109,9 +137,9 @@ export default class TimePicker extends React.Component { {...props} className={className} locale={locale} - formatter={this.getFormatter()} + formatter={this.getFormatter() } onChange={this.handleChange} - /> + /> ); } }