对日期选择器
和时间选择器
的组合。
/**
* Author: ひまわり(dtysky<dtysky@outlook.com>)
* Github: https://github.com/dtysky
* Created: 2017/2/6
*/
import React, {Component} from 'react';
import {DateTimePicker} from 'hana-ui';
import ExampleBlock from 'demo/ExampleBlock';
/**
* @en
* Base
*
* All properties' usage are as same as the DatePicker and TimePicker, please check their definitions.
*
* @cn
* 基础
*
* 将时间选择器和日期选择器结合的组件,请从属性定义和`日期选择器的文档`以及`时间选择器的文档`中寻找使用方法。
*/
export default class ExampleBase extends Component {
state = {
dateString: ''
};
render() {
const {
dateString
} = this.state;
return (
<div>
<ExampleBlock>
<DateTimePicker />
</ExampleBlock>
<ExampleBlock
en={
<p>Using string as value.</p>
}
cn={
<p>使用字符串作为值。</p>
}
>
<DateTimePicker
value={dateString}
onChange={(value, text) => {
this.setState({dateString: text});
}}
/>
</ExampleBlock>
</div>
);
}
}
将时间选择器和日期选择器结合的组件,请从属性定义和日期选择器的文档
以及时间选择器的文档
中寻找使用方法。
使用字符串作为值。
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
value | dateOrStringOrNull | 日期值,如果未提供,此组件将会运行在自动模式。 | |
onChange | function | nop | 日期被选中时将会被调用的回调函数。 (date: Date, text: string) => void |
onCancel | function | nop | 选择框被关闭时将会被调用的回调函数。 () => void |
lang | enum: 'en' 'cn' 'jp' |
'en' | 期望使用的语言。 |
dateViewProps | object | {} | 此属性将会作为props 被传递给DatePicker的Text 组件。 |
timeViewProps | object | {} | 此属性将会作为props 被传递给TimePicker的Text 组件。 |
dateShow | bool | 直接控制DatePicker的选择框是否显示。 | |
timeShow | bool | 直接控制TimePicker的选择框是否显示。 | |
autoOk | bool | false | 是否在选择日期后,直接关闭选择框。 |
withClear | bool | false | 是否要添加清空功能。 |
dateFormat | function | date => dateToString(date) | 一个用于格式化日期到字符串的自定义方法,将会影响到所有和该组件输出text 相关的属性。(date: Date) => string |
timeFormat | function | date => timeToString(date) | 一个用于格式化时间到字符串的自定义方法,将会影响到所有和该组件输出text 相关的属性。(time: Date) => string |
className | string | 根元素的class。 | |
dateClassName | string | DatePicker的class。 | |
timeClassName | string | TimePicker的class。 | |
dateDialogClassName | string | DatePicker的选择框的class。 | |
timeDialogClassName | string | TimePicker的选择框的class。 | |
style | object | {} | 根元素的样式。 |
dateStyle | object | {} | DatePicker的样式。 |
timeStyle | object | {} | TimePicker的样式。 |
dateDialogStyle | object | {} | DatePicker的选择框的样式。 |
timeDialogStyle | object | {} | TimePicker的选择框的样式。 |
weekdayNames | arrayWith7Strings | 用户自定义的周一~周日的名称。 | |
weekdayShortNames | arrayWith7Strings | 用户自定义的周一~周日的短名称。 | |
monthNames | arrayWith12Strings | 用户自定义的每个月的名称。 | |
actionNames | shape | 用户自定义的选择框操作按钮的名称。 | |
yearStart | number | 1917 | 可选范围的起始年份。 |
yearEnd | number | 2200 | 可选范围的结束年份。 |
未在文档中说明的属性将会被自动加到根元素或form元素上。