Browse Source

refactor(TimePicker): rewrite TimePicker

pull/2177/head^2
bang88 9 years ago
parent
commit
466e90da3f
  1. 2
      components/index.tsx
  2. 36
      components/time-picker/index.tsx

2
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';

36
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<TimePickerProps, any> {
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}
/>
/>
);
}
}

Loading…
Cancel
Save