mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 20:19:44 +08:00
update timepicker
This commit is contained in:
parent
55c2d2d244
commit
041691097a
@ -1,5 +1,4 @@
|
||||
基本
|
||||
====
|
||||
# 基本
|
||||
|
||||
- order: 0
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
禁用
|
||||
====
|
||||
# 禁用
|
||||
|
||||
- order: 4
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
无默认值
|
||||
====
|
||||
# 无默认值
|
||||
|
||||
- order: 5
|
||||
|
||||
|
19
components/timepicker/demo/size.md
Normal file
19
components/timepicker/demo/size.md
Normal file
@ -0,0 +1,19 @@
|
||||
# 三种大小
|
||||
|
||||
- order: 6
|
||||
|
||||
三种大小的输入框,大的用在表单中,中的为默认。
|
||||
|
||||
---
|
||||
|
||||
````jsx
|
||||
import { Timepicker } from 'antd';
|
||||
|
||||
ReactDOM.render(
|
||||
<div>
|
||||
<Timepicker defaultValue="12:08:23" size="large" />
|
||||
<Timepicker defaultValue="12:08:23" />
|
||||
<Timepicker defaultValue="12:08:23" size="small" />
|
||||
</div>
|
||||
, document.getElementById('components-timepicker-demo-size'));
|
||||
````
|
@ -1,5 +1,4 @@
|
||||
特定选项
|
||||
====
|
||||
# 特定选项
|
||||
|
||||
- order: 3
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
不展示秒
|
||||
====
|
||||
# 不展示秒
|
||||
|
||||
- order: 2
|
||||
|
||||
|
@ -14,31 +14,67 @@ const AntTimepicker = React.createClass({
|
||||
onChange() {}, // onChange 可用于 Validator
|
||||
locale: {},
|
||||
align: {
|
||||
offset: [0, -8],
|
||||
offset: [0, -1],
|
||||
},
|
||||
open: false,
|
||||
disabled: false,
|
||||
hourOptions: undefined,
|
||||
minuteOptions: undefined,
|
||||
secondOptions: undefined,
|
||||
size: '',
|
||||
placement: 'bottomLeft',
|
||||
transitionName: 'slide-up',
|
||||
};
|
||||
},
|
||||
|
||||
render() {
|
||||
const { defaultValue, format, placeholder, align, disabled, hourOptions, minuteOptions, secondOptions } = this.props;
|
||||
const prefixCls = 'ant-timepicker';
|
||||
const formatter = new DateTimeFormat(format);
|
||||
/**
|
||||
* 获得输入框的 className
|
||||
*/
|
||||
getSizeClass() {
|
||||
let sizeClass = '';
|
||||
if (this.props.size === 'large') {
|
||||
sizeClass = ' ant-input-lg';
|
||||
} else if (this.props.size === 'small') {
|
||||
sizeClass = ' ant-input-sm';
|
||||
}
|
||||
return sizeClass;
|
||||
},
|
||||
|
||||
let showValue = undefined;
|
||||
/**
|
||||
* 获得输入框的默认值
|
||||
*/
|
||||
getDefaultValue(formatter) {
|
||||
const defaultValue = this.props.defaultValue;
|
||||
if (defaultValue) {
|
||||
showValue = formatter.parse(defaultValue, {
|
||||
return formatter.parse(defaultValue, {
|
||||
locale: defaultValue.locale,
|
||||
obeyCount: true,
|
||||
});
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
|
||||
render() {
|
||||
const { format, placeholder, align, disabled, hourOptions, minuteOptions, secondOptions, placement, transitionName } = this.props;
|
||||
const prefixCls = 'ant-timepicker';
|
||||
const formatter = new DateTimeFormat(format);
|
||||
|
||||
return (
|
||||
<TimePicker prefixCls={prefixCls} locale={TimePickerLocale} formatter={formatter} hourOptions={hourOptions} minuteOptions={minuteOptions} secondOptions={secondOptions} disabled={disabled} align={align} placeholder={placeholder} value={showValue} />
|
||||
<TimePicker
|
||||
prefixCls={prefixCls}
|
||||
locale={TimePickerLocale}
|
||||
formatter={formatter}
|
||||
hourOptions={hourOptions}
|
||||
minuteOptions={minuteOptions}
|
||||
secondOptions={secondOptions}
|
||||
disabled={disabled}
|
||||
align={align}
|
||||
placeholder={placeholder}
|
||||
inputClassName={`ant-input ${this.getSizeClass()}`}
|
||||
defaultValue={this.getDefaultValue(formatter)}
|
||||
placement={placement}
|
||||
transitionName={transitionName}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
Timepicker
|
||||
==========
|
||||
# Timepicker
|
||||
|
||||
- category: Components
|
||||
- chinese: 时间选择框
|
||||
@ -30,5 +29,8 @@ API
|
||||
| hourOptions | 特定可选择的小时 | array | 0 到 24 组成的数组 |
|
||||
| minuteOptions | 特定可选择的分钟 | array | 0 到 60 组成的数组 |
|
||||
| secondOptions | 特定可选择的秒 | array | 0 到 60 组成的数组 |
|
||||
| inputClassName | 输入框的样式 | string | |
|
||||
| placement | 显示位置 | string | bottomLeft |
|
||||
| transitionName | 显示动画 | string | slide-up |
|
||||
|
||||
<style> .code-box-demo .ant-timepicker-picker { margin: 0 12px 12px 0; }</style>
|
||||
|
@ -57,7 +57,7 @@
|
||||
"rc-switch": "~1.3.1",
|
||||
"rc-table": "~3.6.1",
|
||||
"rc-tabs": "~5.5.0",
|
||||
"rc-time-picker": "~0.5.2",
|
||||
"rc-time-picker": "~0.5.4",
|
||||
"rc-tooltip": "~3.2.0",
|
||||
"rc-tree": "~0.19.0",
|
||||
"rc-trigger": "~1.0.6",
|
||||
|
@ -1,4 +1,4 @@
|
||||
.@{calendar-prefix-cls}-picker-container {
|
||||
.@{calendar-prefix-cls}-picker-container {
|
||||
position: absolute;
|
||||
z-index: 1070;
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
@timepicker-prefix-cls: ant-timepicker;
|
||||
|
||||
.@{timepicker-prefix-cls} {
|
||||
display: inline;
|
||||
box-sizing: border-box;
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
@ -9,6 +8,6 @@
|
||||
}
|
||||
|
||||
@import "timepicker/Picker";
|
||||
@import "timepicker/TimePanel";
|
||||
@import "timepicker/Panel";
|
||||
@import "timepicker/Header";
|
||||
@import "timepicker/Select";
|
||||
|
@ -1,3 +1,32 @@
|
||||
.@{timepicker-prefix-cls}-picker-container {
|
||||
z-index: 1070;
|
||||
position: absolute;
|
||||
|
||||
&.slide-up-enter.slide-up-enter-active&-placement-topLeft,
|
||||
&.slide-up-enter.slide-up-enter-active&-placement-topRight,
|
||||
&.slide-up-appear.slide-up-appear-active&-placement-topLeft,
|
||||
&.slide-up-appear.slide-up-appear-active&-placement-topRight {
|
||||
animation-name: antSlideDownIn;
|
||||
}
|
||||
|
||||
&.slide-up-enter.slide-up-enter-active&-placement-bottomLeft,
|
||||
&.slide-up-enter.slide-up-enter-active&-placement-bottomRight,
|
||||
&.slide-up-appear.slide-up-appear-active&-placement-bottomLeft,
|
||||
&.slide-up-appear.slide-up-appear-active&-placement-bottomRight {
|
||||
animation-name: antSlideUpIn;
|
||||
}
|
||||
|
||||
&.slide-up-leave.slide-up-leave-active&-placement-topLeft,
|
||||
&.slide-up-leave.slide-up-leave-active&-placement-topRight {
|
||||
animation-name: antSlideDownOut;
|
||||
}
|
||||
|
||||
&.slide-up-leave.slide-up-leave-active&-placement-bottomLeft,
|
||||
&.slide-up-leave.slide-up-leave-active&-placement-bottomRight {
|
||||
animation-name: antSlideUpOut;
|
||||
}
|
||||
}
|
||||
|
||||
.@{timepicker-prefix-cls}-picker {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
@ -6,7 +35,6 @@
|
||||
transition: opacity 0.3s ease;
|
||||
|
||||
> input {
|
||||
.ant-input;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
@ -26,7 +54,7 @@
|
||||
top: 50%;
|
||||
margin-top: -6px;
|
||||
&:after {
|
||||
content: "\e642";
|
||||
content: "\e643";
|
||||
font-family: "anticon";
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
&:hover {
|
||||
background: tint(@primary-color, 90%);
|
||||
transition: background 0.3s ease;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user