From 8f29e5e594066f201522c99c90a4aa4eed919014 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Thu, 27 Jun 2019 22:00:08 +0800 Subject: [PATCH] cr vc-time-picker --- components/vc-time-picker/Combobox.jsx | 38 +++++++++++++------ components/vc-time-picker/Panel.jsx | 1 - components/vc-time-picker/Select.jsx | 8 ++-- .../src/Selector/MultipleSelector/index.jsx | 2 +- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/components/vc-time-picker/Combobox.jsx b/components/vc-time-picker/Combobox.jsx index 35a622d72..ae2c6e864 100644 --- a/components/vc-time-picker/Combobox.jsx +++ b/components/vc-time-picker/Combobox.jsx @@ -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())} diff --git a/components/vc-time-picker/Panel.jsx b/components/vc-time-picker/Panel.jsx index 58d2b811e..87d50ce88 100644 --- a/components/vc-time-picker/Panel.jsx +++ b/components/vc-time-picker/Panel.jsx @@ -199,7 +199,6 @@ const Panel = { disabledMinutes={disabledMinutes} disabledSeconds={disabledSeconds} onChange={this.onChange} - onClear={clear} allowEmpty={allowEmpty} focusOnOpen={focusOnOpen} onKeydown={keydown} diff --git a/components/vc-time-picker/Select.jsx b/components/vc-time-picker/Select.jsx index 5daff2dbb..e9eb43b27 100644 --- a/components/vc-time-picker/Select.jsx +++ b/components/vc-time-picker/Select.jsx @@ -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 ( diff --git a/components/vc-tree-select/src/Selector/MultipleSelector/index.jsx b/components/vc-tree-select/src/Selector/MultipleSelector/index.jsx index 1a8ce163c..0b5c52a13 100644 --- a/components/vc-tree-select/src/Selector/MultipleSelector/index.jsx +++ b/components/vc-tree-select/src/Selector/MultipleSelector/index.jsx @@ -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, },