cr vc-time-picker

This commit is contained in:
tangjinzhou 2019-06-27 22:00:08 +08:00
parent 82b4715e95
commit 8f29e5e594
4 changed files with 31 additions and 18 deletions

View File

@ -44,8 +44,8 @@ const Combobox = {
},
methods: {
onItemChange(type, itemValue) {
const { defaultOpenValue, use12Hours, isAM } = this;
const value = (this.value || defaultOpenValue).clone();
const { defaultOpenValue, use12Hours, value: propValue, isAM } = this;
const value = (propValue || defaultOpenValue).clone();
if (type === 'hour') {
if (use12Hours) {
@ -106,17 +106,24 @@ const Combobox = {
selectedIndex={hourOptionsAdj.indexOf(hourAdj)}
type="hour"
onSelect={this.onItemChange}
onMouseenter={this.onEnterSelectPanel.bind(this, 'hour')}
onMouseenter={() => this.onEnterSelectPanel('hour')}
/>
);
},
getMinuteSelect(minute) {
const { prefixCls, minuteOptions, disabledMinutes, defaultOpenValue, showMinute } = this;
const {
prefixCls,
minuteOptions,
disabledMinutes,
defaultOpenValue,
showMinute,
value: propValue,
} = this;
if (!showMinute) {
return null;
}
const value = this.value || defaultOpenValue;
const value = propValue || defaultOpenValue;
const disabledOptions = disabledMinutes(value.hour());
return (
@ -126,17 +133,24 @@ const Combobox = {
selectedIndex={minuteOptions.indexOf(minute)}
type="minute"
onSelect={this.onItemChange}
onMouseenter={this.onEnterSelectPanel.bind(this, 'minute')}
onMouseenter={() => this.onEnterSelectPanel('minute')}
/>
);
},
getSecondSelect(second) {
const { prefixCls, secondOptions, disabledSeconds, showSecond, defaultOpenValue } = this;
const {
prefixCls,
secondOptions,
disabledSeconds,
showSecond,
defaultOpenValue,
value: propValue,
} = this;
if (!showSecond) {
return null;
}
const value = this.value || defaultOpenValue;
const value = propValue || defaultOpenValue;
const disabledOptions = disabledSeconds(value.hour(), value.minute());
return (
@ -146,7 +160,7 @@ const Combobox = {
selectedIndex={secondOptions.indexOf(second)}
type="second"
onSelect={this.onItemChange}
onMouseenter={this.onEnterSelectPanel.bind(this, 'second')}
onMouseenter={() => this.onEnterSelectPanel('second')}
/>
);
},
@ -170,15 +184,15 @@ const Combobox = {
selectedIndex={selected}
type="ampm"
onSelect={this.onItemChange}
onMouseenter={this.onEnterSelectPanel.bind(this, 'ampm')}
onMouseenter={() => this.onEnterSelectPanel('ampm')}
/>
);
},
},
render() {
const { prefixCls, defaultOpenValue } = this;
const value = this.value || defaultOpenValue;
const { prefixCls, defaultOpenValue, value: propValue } = this;
const value = propValue || defaultOpenValue;
return (
<div class={`${prefixCls}-combobox`}>
{this.getHourSelect(value.hour())}

View File

@ -199,7 +199,6 @@ const Panel = {
disabledMinutes={disabledMinutes}
disabledSeconds={disabledSeconds}
onChange={this.onChange}
onClear={clear}
allowEmpty={allowEmpty}
focusOnOpen={focusOnOpen}
onKeydown={keydown}

View File

@ -67,7 +67,7 @@ const Select = {
[`${prefixCls}-select-option-disabled`]: item.disabled,
});
const onClick = item.disabled
? undefined
? noop
: () => {
this.onSelect(item.value);
};
@ -106,14 +106,14 @@ const Select = {
},
render() {
if (this.options.length === 0) {
const { prefixCls, options, active } = this;
if (options.length === 0) {
return null;
}
const { prefixCls } = this;
const cls = {
[`${prefixCls}-select`]: 1,
[`${prefixCls}-select-active`]: this.active,
[`${prefixCls}-select-active`]: active,
};
return (

View File

@ -24,7 +24,7 @@ const MultipleSelector = {
searchValue: PropTypes.string,
labelInValue: PropTypes.bool,
maxTagCount: PropTypes.number,
maxTagPlaceholder: PropTypes.oneOfType([PropTypes.any, PropTypes.func]),
maxTagPlaceholder: PropTypes.any,
// onChoiceAnimationLeave: PropTypes.func,
},