mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-11 11:32:52 +08:00
* deps: upgrade dependencies, close: #3161 * css: update style for DatePicker[showTime]
This commit is contained in:
parent
a7ba9004e1
commit
d8e9fff5ba
@ -45,10 +45,7 @@ export default class RangePicker extends React.Component<any, any> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const props = this.props;
|
const props = this.props;
|
||||||
const locale = props.locale;
|
const { disabledDate, showTime, prefixCls, popupStyle, style, onOk, locale } = props;
|
||||||
|
|
||||||
const { disabledDate, showTime, getCalendarContainer, prefixCls,
|
|
||||||
transitionName, disabled, popupStyle, align, style, onOk } = this.props;
|
|
||||||
const state = this.state;
|
const state = this.state;
|
||||||
|
|
||||||
const calendarClassName = classNames({
|
const calendarClassName = classNames({
|
||||||
@ -63,9 +60,7 @@ export default class RangePicker extends React.Component<any, any> {
|
|||||||
onOk: this.handleChange,
|
onOk: this.handleChange,
|
||||||
};
|
};
|
||||||
if (props.timePicker) {
|
if (props.timePicker) {
|
||||||
pickerChangeHandler.onChange = (value) => {
|
pickerChangeHandler.onChange = value => this.handleChange(value);
|
||||||
this.handleChange(value);
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
calendarHandler = {};
|
calendarHandler = {};
|
||||||
}
|
}
|
||||||
@ -98,26 +93,21 @@ export default class RangePicker extends React.Component<any, any> {
|
|||||||
|
|
||||||
return (<span className={props.pickerClass} style={style}>
|
return (<span className={props.pickerClass} style={style}>
|
||||||
<RcDatePicker
|
<RcDatePicker
|
||||||
|
{...props}
|
||||||
{...pickerChangeHandler}
|
{...pickerChangeHandler}
|
||||||
transitionName={transitionName}
|
|
||||||
disabled={disabled}
|
|
||||||
calendar={calendar}
|
calendar={calendar}
|
||||||
value={state.value}
|
value={state.value}
|
||||||
prefixCls={`${prefixCls}-picker-container`}
|
prefixCls={`${prefixCls}-picker-container`}
|
||||||
style={popupStyle}
|
style={popupStyle}
|
||||||
align={align}
|
|
||||||
getCalendarContainer={getCalendarContainer}
|
|
||||||
onOpen={props.toggleOpen}
|
|
||||||
onClose={props.toggleOpen}
|
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
({ value }) => {
|
({ value }) => {
|
||||||
const start = value[0];
|
const start = value[0];
|
||||||
const end = value[1];
|
const end = value[1];
|
||||||
return (
|
return (
|
||||||
<span className={props.pickerInputClass} disabled={disabled}>
|
<span className={props.pickerInputClass} disabled={props.disabled}>
|
||||||
<input
|
<input
|
||||||
disabled={disabled}
|
disabled={props.disabled}
|
||||||
readOnly
|
readOnly
|
||||||
value={(start && start.format(props.format)) || ''}
|
value={(start && start.format(props.format)) || ''}
|
||||||
placeholder={startPlaceholder}
|
placeholder={startPlaceholder}
|
||||||
@ -125,7 +115,7 @@ export default class RangePicker extends React.Component<any, any> {
|
|||||||
/>
|
/>
|
||||||
<span className={`${prefixCls}-range-picker-separator`}> ~ </span>
|
<span className={`${prefixCls}-range-picker-separator`}> ~ </span>
|
||||||
<input
|
<input
|
||||||
disabled={disabled}
|
disabled={props.disabled}
|
||||||
readOnly
|
readOnly
|
||||||
value={(end && end.format(props.format)) || ''}
|
value={(end && end.format(props.format)) || ''}
|
||||||
placeholder={endPlaceholder}
|
placeholder={endPlaceholder}
|
||||||
|
@ -72,11 +72,7 @@ export default function createPicker(TheCalendar) {
|
|||||||
let calendarHandler: Object = {
|
let calendarHandler: Object = {
|
||||||
onOk: this.handleChange,
|
onOk: this.handleChange,
|
||||||
// fix https://github.com/ant-design/ant-design/issues/1902
|
// fix https://github.com/ant-design/ant-design/issues/1902
|
||||||
onSelect: (value, cause) => {
|
onSelect: value => this.handleChange(value),
|
||||||
if (cause && cause.source === 'todayButton') {
|
|
||||||
this.handleChange(value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
if (props.showTime) {
|
if (props.showTime) {
|
||||||
pickerChangeHandler = {};
|
pickerChangeHandler = {};
|
||||||
@ -113,18 +109,12 @@ export default function createPicker(TheCalendar) {
|
|||||||
return (
|
return (
|
||||||
<span className={props.pickerClass} style={assign({}, pickerStyle, props.style)}>
|
<span className={props.pickerClass} style={assign({}, pickerStyle, props.style)}>
|
||||||
<RcDatePicker
|
<RcDatePicker
|
||||||
|
{...props}
|
||||||
{...pickerChangeHandler}
|
{...pickerChangeHandler}
|
||||||
transitionName={props.transitionName}
|
|
||||||
disabled={props.disabled}
|
|
||||||
calendar={calendar}
|
calendar={calendar}
|
||||||
value={this.state.value}
|
value={this.state.value}
|
||||||
prefixCls={`${prefixCls}-picker-container`}
|
prefixCls={`${prefixCls}-picker-container`}
|
||||||
style={props.popupStyle}
|
style={props.popupStyle}
|
||||||
align={props.align}
|
|
||||||
getCalendarContainer={props.getCalendarContainer}
|
|
||||||
open={props.open}
|
|
||||||
onOpen={props.toggleOpen}
|
|
||||||
onClose={props.toggleOpen}
|
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
({ value }) => {
|
({ value }) => {
|
||||||
|
@ -48,12 +48,12 @@ const DateRange = React.createClass({
|
|||||||
onEndChange(value) {
|
onEndChange(value) {
|
||||||
this.onChange('endValue', value);
|
this.onChange('endValue', value);
|
||||||
},
|
},
|
||||||
handleStartToggle({ open }) {
|
handleStartOpenChange(open) {
|
||||||
if (!open) {
|
if (!open) {
|
||||||
this.setState({ endOpen: true });
|
this.setState({ endOpen: true });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleEndToggle({ open }) {
|
handleEndOpenChange(open) {
|
||||||
this.setState({ endOpen: open });
|
this.setState({ endOpen: open });
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
@ -66,7 +66,7 @@ const DateRange = React.createClass({
|
|||||||
value={this.state.startValue}
|
value={this.state.startValue}
|
||||||
placeholder="开始日期"
|
placeholder="开始日期"
|
||||||
onChange={this.onStartChange}
|
onChange={this.onStartChange}
|
||||||
toggleOpen={this.handleStartToggle}
|
onOpenChange={this.handleStartOpenChange}
|
||||||
/>
|
/>
|
||||||
<DatePicker
|
<DatePicker
|
||||||
disabledDate={this.disabledEndDate}
|
disabledDate={this.disabledEndDate}
|
||||||
@ -76,7 +76,7 @@ const DateRange = React.createClass({
|
|||||||
placeholder="结束日期"
|
placeholder="结束日期"
|
||||||
onChange={this.onEndChange}
|
onChange={this.onEndChange}
|
||||||
open={this.state.endOpen}
|
open={this.state.endOpen}
|
||||||
toggleOpen={this.handleEndToggle}
|
onOpenChange={this.handleEndOpenChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -41,7 +41,7 @@ moment.tz.setDefault('Asia/Shanghai')
|
|||||||
| locale | localization configuration | Object | [default](https://github.com/ant-design/ant-design/issues/424) |
|
| locale | localization configuration | Object | [default](https://github.com/ant-design/ant-design/issues/424) |
|
||||||
| onOk | a callback function, can be executed when OK-button is clicked | function(Date value) | - |
|
| onOk | a callback function, can be executed when OK-button is clicked | function(Date value) | - |
|
||||||
| open | open state of picker | bool | - |
|
| open | open state of picker | bool | - |
|
||||||
| toggleOpen | a callback function, can be executed whether the popup calendar is popped up or closed | function(open) | - |
|
| onOpenChange | a callback function, can be executed whether the popup calendar is popped up or closed | function(status) | - |
|
||||||
| getCalendarContainer | to set the container of the floating layer, while the default is to create a `div` element in `body` | function(trigger) | - |
|
| getCalendarContainer | to set the container of the floating layer, while the default is to create a `div` element in `body` | function(trigger) | - |
|
||||||
| showTime | to provide an additional time selection | Object/Boolean | [TimePicker Options](http://ant.design/components/time-picker/#api) |
|
| showTime | to provide an additional time selection | Object/Boolean | [TimePicker Options](http://ant.design/components/time-picker/#api) |
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ moment.tz.setDefault('Asia/Shanghai')
|
|||||||
| size | 输入框大小,`large` 高度为 32px,`small` 为 22px,默认是 28px | string | 无 |
|
| size | 输入框大小,`large` 高度为 32px,`small` 为 22px,默认是 28px | string | 无 |
|
||||||
| locale | 国际化配置 | object | [默认配置](https://github.com/ant-design/ant-design/issues/424) |
|
| locale | 国际化配置 | object | [默认配置](https://github.com/ant-design/ant-design/issues/424) |
|
||||||
| open | 控制弹层是否展开 | bool | - |
|
| open | 控制弹层是否展开 | bool | - |
|
||||||
| toggleOpen | 弹出日历和关闭日历的回调 | function(open) | 无 |
|
| onOpenChange | 弹出日历和关闭日历的回调 | function(status) | 无 |
|
||||||
| getCalendarContainer | 定义浮层的容器,默认为 body 上新建 div | function(trigger) | 无 |
|
| getCalendarContainer | 定义浮层的容器,默认为 body 上新建 div | function(trigger) | 无 |
|
||||||
| showTime | 增加时间选择功能 | Object or Boolean | [TimePicker Options](http://ant.design/components/time-picker/#api) |
|
| showTime | 增加时间选择功能 | Object or Boolean | [TimePicker Options](http://ant.design/components/time-picker/#api) |
|
||||||
|
|
||||||
|
@ -24,6 +24,21 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&-1-column,
|
||||||
|
&-1-column &-select {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
&-2-columns &-select {
|
||||||
|
width: 115px;
|
||||||
|
}
|
||||||
|
&-1-column &-select,
|
||||||
|
&-2-columns &-select {
|
||||||
|
li {
|
||||||
|
padding: 0;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&-input {
|
&-input {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
@ -4,6 +4,7 @@ import TimePickerPanel from 'rc-time-picker/lib/Panel';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import defaultLocale from './locale/zh_CN';
|
import defaultLocale from './locale/zh_CN';
|
||||||
import assign from 'object-assign';
|
import assign from 'object-assign';
|
||||||
|
import warning from 'warning';
|
||||||
|
|
||||||
export default function wrapPicker(Picker, defaultFormat?) {
|
export default function wrapPicker(Picker, defaultFormat?) {
|
||||||
const PickerWrapper = React.createClass({
|
const PickerWrapper = React.createClass({
|
||||||
@ -16,7 +17,7 @@ export default function wrapPicker(Picker, defaultFormat?) {
|
|||||||
},
|
},
|
||||||
onOk() {
|
onOk() {
|
||||||
},
|
},
|
||||||
toggleOpen() {
|
onOpenChange() {
|
||||||
},
|
},
|
||||||
locale: {},
|
locale: {},
|
||||||
align: {
|
align: {
|
||||||
@ -44,8 +45,18 @@ export default function wrapPicker(Picker, defaultFormat?) {
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleOpen ({open}) {
|
handleOpenChange(open) {
|
||||||
this.props.toggleOpen({open});
|
const { onOpenChange, toggleOpen } = this.props;
|
||||||
|
onOpenChange(open);
|
||||||
|
|
||||||
|
if (toggleOpen) {
|
||||||
|
warning(
|
||||||
|
false,
|
||||||
|
'`toggleOpen` is deprecated and will be removed in the future, ' +
|
||||||
|
'please use `onOpenChange` instead'
|
||||||
|
);
|
||||||
|
toggleOpen({open});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -63,17 +74,22 @@ export default function wrapPicker(Picker, defaultFormat?) {
|
|||||||
|
|
||||||
const locale = this.getLocale();
|
const locale = this.getLocale();
|
||||||
|
|
||||||
const timeFormat = props.showTime && props.showTime.format;
|
const timeFormat = (props.showTime && props.showTime.format) || 'HH:mm:ss';
|
||||||
const rcTimePickerProps = {
|
const rcTimePickerProps = {
|
||||||
format: timeFormat || 'HH:mm:ss',
|
format: timeFormat,
|
||||||
showSecond: timeFormat && timeFormat.indexOf('ss') >= 0,
|
showSecond: timeFormat.indexOf('ss') >= 0,
|
||||||
showHour: timeFormat && timeFormat.indexOf('HH') >= 0,
|
showHour: timeFormat.indexOf('HH') >= 0,
|
||||||
};
|
};
|
||||||
|
const timePickerCls = classNames({
|
||||||
|
[`${prefixCls}-time-picker-1-column`]: !(rcTimePickerProps.showSecond || rcTimePickerProps.showHour),
|
||||||
|
[`${prefixCls}-time-picker-2-columns`]: rcTimePickerProps.showSecond !== rcTimePickerProps.showHour,
|
||||||
|
});
|
||||||
const timePicker = props.showTime ? (
|
const timePicker = props.showTime ? (
|
||||||
<TimePickerPanel
|
<TimePickerPanel
|
||||||
{...rcTimePickerProps}
|
{...rcTimePickerProps}
|
||||||
{...props.showTime}
|
{...props.showTime}
|
||||||
prefixCls={`${prefixCls}-time-picker`}
|
prefixCls={`${prefixCls}-time-picker`}
|
||||||
|
className={timePickerCls}
|
||||||
placeholder={locale.timePickerLocale.placeholder}
|
placeholder={locale.timePickerLocale.placeholder}
|
||||||
transitionName="slide-up"
|
transitionName="slide-up"
|
||||||
/>
|
/>
|
||||||
@ -86,7 +102,7 @@ export default function wrapPicker(Picker, defaultFormat?) {
|
|||||||
pickerInputClass={pickerInputClass}
|
pickerInputClass={pickerInputClass}
|
||||||
locale={locale}
|
locale={locale}
|
||||||
timePicker={timePicker}
|
timePicker={timePicker}
|
||||||
toggleOpen={this.toggleOpen}
|
onOpenChange={this.handleOpenChange}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -42,11 +42,11 @@
|
|||||||
"object-assign": "~4.1.0",
|
"object-assign": "~4.1.0",
|
||||||
"omit.js": "^0.1.0",
|
"omit.js": "^0.1.0",
|
||||||
"rc-animate": "~2.3.0",
|
"rc-animate": "~2.3.0",
|
||||||
"rc-calendar": "~7.1.0",
|
"rc-calendar": "~7.2.0",
|
||||||
"rc-cascader": "~0.10.1",
|
"rc-cascader": "~0.10.1",
|
||||||
"rc-checkbox": "~1.4.0",
|
"rc-checkbox": "~1.4.0",
|
||||||
"rc-collapse": "~1.6.4",
|
"rc-collapse": "~1.6.4",
|
||||||
"rc-dialog": "~6.3.0",
|
"rc-dialog": "~6.4.0",
|
||||||
"rc-dropdown": "~1.4.8",
|
"rc-dropdown": "~1.4.8",
|
||||||
"rc-editor-mention": "~0.2.2",
|
"rc-editor-mention": "~0.2.2",
|
||||||
"rc-form": "~1.0.0",
|
"rc-form": "~1.0.0",
|
||||||
@ -69,7 +69,7 @@
|
|||||||
"rc-tree": "~1.3.6",
|
"rc-tree": "~1.3.6",
|
||||||
"rc-tree-select": "~1.8.0",
|
"rc-tree-select": "~1.8.0",
|
||||||
"rc-upload": "~2.1.0",
|
"rc-upload": "~2.1.0",
|
||||||
"rc-util": "^3.3.0",
|
"rc-util": "^4.0.0",
|
||||||
"react-addons-pure-render-mixin": "^15.0.0",
|
"react-addons-pure-render-mixin": "^15.0.0",
|
||||||
"react-slick": "~0.14.2",
|
"react-slick": "~0.14.2",
|
||||||
"shallowequal": "^0.2.2",
|
"shallowequal": "^0.2.2",
|
||||||
|
Loading…
Reference in New Issue
Block a user