|
@@ -59,6 +59,10 @@
|
|
tabindex: {
|
|
tabindex: {
|
|
type: Number,
|
|
type: Number,
|
|
default: 0
|
|
default: 0
|
|
|
|
+ },
|
|
|
|
+ disabled: {
|
|
|
|
+ type: Boolean,
|
|
|
|
+ default: false
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
@@ -111,14 +115,14 @@
|
|
};
|
|
};
|
|
},
|
|
},
|
|
show() {
|
|
show() {
|
|
- if (this.triggerElm.disabled) return;
|
|
|
|
|
|
+ if (this.disabled) return;
|
|
clearTimeout(this.timeout);
|
|
clearTimeout(this.timeout);
|
|
this.timeout = setTimeout(() => {
|
|
this.timeout = setTimeout(() => {
|
|
this.visible = true;
|
|
this.visible = true;
|
|
}, this.trigger === 'click' ? 0 : this.showTimeout);
|
|
}, this.trigger === 'click' ? 0 : this.showTimeout);
|
|
},
|
|
},
|
|
hide() {
|
|
hide() {
|
|
- if (this.triggerElm.disabled) return;
|
|
|
|
|
|
+ if (this.disabled) return;
|
|
this.removeTabindex();
|
|
this.removeTabindex();
|
|
if (this.tabindex >= 0) {
|
|
if (this.tabindex >= 0) {
|
|
this.resetTabindex(this.triggerElm);
|
|
this.resetTabindex(this.triggerElm);
|
|
@@ -129,7 +133,7 @@
|
|
}, this.trigger === 'click' ? 0 : this.hideTimeout);
|
|
}, this.trigger === 'click' ? 0 : this.hideTimeout);
|
|
},
|
|
},
|
|
handleClick() {
|
|
handleClick() {
|
|
- if (this.triggerElm.disabled) return;
|
|
|
|
|
|
+ if (this.disabled) return;
|
|
if (this.visible) {
|
|
if (this.visible) {
|
|
this.hide();
|
|
this.hide();
|
|
} else {
|
|
} else {
|
|
@@ -250,28 +254,38 @@
|
|
},
|
|
},
|
|
|
|
|
|
render(h) {
|
|
render(h) {
|
|
- let { hide, splitButton, type, dropdownSize } = this;
|
|
|
|
|
|
+ let { hide, splitButton, type, dropdownSize, disabled } = this;
|
|
|
|
|
|
const handleMainButtonClick = (event) => {
|
|
const handleMainButtonClick = (event) => {
|
|
this.$emit('click', event);
|
|
this.$emit('click', event);
|
|
hide();
|
|
hide();
|
|
};
|
|
};
|
|
|
|
|
|
- let triggerElm = !splitButton
|
|
|
|
- ? this.$slots.default
|
|
|
|
- : (<el-button-group>
|
|
|
|
- <el-button type={type} size={dropdownSize} nativeOn-click={handleMainButtonClick}>
|
|
|
|
|
|
+ let triggerElm = null;
|
|
|
|
+ if (splitButton) {
|
|
|
|
+ triggerElm = <el-button-group>
|
|
|
|
+ <el-button type={type} size={dropdownSize} nativeOn-click={handleMainButtonClick} disabled={disabled}>
|
|
{this.$slots.default}
|
|
{this.$slots.default}
|
|
</el-button>
|
|
</el-button>
|
|
- <el-button ref="trigger" type={type} size={dropdownSize} class="el-dropdown__caret-button">
|
|
|
|
|
|
+ <el-button ref="trigger" type={type} size={dropdownSize} class="el-dropdown__caret-button" disabled={disabled}>
|
|
<i class="el-dropdown__icon el-icon-arrow-down"></i>
|
|
<i class="el-dropdown__icon el-icon-arrow-down"></i>
|
|
</el-button>
|
|
</el-button>
|
|
- </el-button-group>);
|
|
|
|
|
|
+ </el-button-group>;
|
|
|
|
+ } else {
|
|
|
|
+ triggerElm = this.$slots.default;
|
|
|
|
+ const vnodeData = triggerElm[0].data || {};
|
|
|
|
+ let { attrs = {} } = vnodeData;
|
|
|
|
+ if (disabled && !attrs.disabled) {
|
|
|
|
+ attrs.disabled = true;
|
|
|
|
+ vnodeData.attrs = attrs;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ const menuElm = disabled ? null : this.$slots.dropdown;
|
|
|
|
|
|
return (
|
|
return (
|
|
- <div class="el-dropdown" v-clickoutside={hide}>
|
|
|
|
|
|
+ <div class="el-dropdown" v-clickoutside={hide} aria-disabled={disabled}>
|
|
{triggerElm}
|
|
{triggerElm}
|
|
- {this.$slots.dropdown}
|
|
|
|
|
|
+ {menuElm}
|
|
</div>
|
|
</div>
|
|
);
|
|
);
|
|
}
|
|
}
|