mirror of
https://gitee.com/xuliangzhan_admin/vxe-table.git
synced 2026-01-21 05:27:57 +08:00
167 lines
5.6 KiB
JavaScript
167 lines
5.6 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = void 0;
|
|
|
|
var _xeUtils = _interopRequireDefault(require("xe-utils/methods/xe-utils"));
|
|
|
|
var _conf = _interopRequireDefault(require("../../conf"));
|
|
|
|
var _tools = require("../../tools");
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
var _default = {
|
|
name: 'VxeButton',
|
|
props: {
|
|
type: String,
|
|
size: String,
|
|
name: [String, Number],
|
|
status: String,
|
|
icon: String,
|
|
disabled: Boolean,
|
|
loading: Boolean
|
|
},
|
|
computed: {
|
|
vSize: function vSize() {
|
|
return this.size || this.$parent.size || this.$parent.vSize;
|
|
},
|
|
isText: function isText() {
|
|
return this.type === 'text';
|
|
},
|
|
isFormBtn: function isFormBtn() {
|
|
return this.type === 'submit' || this.type === 'reset';
|
|
},
|
|
btnType: function btnType() {
|
|
return this.isText ? this.type : 'button';
|
|
},
|
|
btnStatus: function btnStatus() {
|
|
return this.status || (this.type === 'primary' ? this.type : null);
|
|
}
|
|
},
|
|
created: function created() {
|
|
if (this.type === 'primary') {
|
|
_tools.UtilTools.warn('vxe.error.delProp', ['type=primary', 'status=primary']);
|
|
}
|
|
},
|
|
render: function render(h) {
|
|
var _ref2,
|
|
_this = this,
|
|
_ref3;
|
|
|
|
var $scopedSlots = this.$scopedSlots,
|
|
$listeners = this.$listeners,
|
|
type = this.type,
|
|
isText = this.isText,
|
|
isFormBtn = this.isFormBtn,
|
|
btnStatus = this.btnStatus,
|
|
btnType = this.btnType,
|
|
vSize = this.vSize,
|
|
name = this.name,
|
|
disabled = this.disabled,
|
|
loading = this.loading;
|
|
return $scopedSlots.dropdowns ? h('div', {
|
|
class: ['vxe-button--dropdown', _defineProperty({}, "size--".concat(vSize), vSize)]
|
|
}, [h('button', {
|
|
class: ['vxe-button', "type--".concat(btnType), (_ref2 = {}, _defineProperty(_ref2, "size--".concat(vSize), vSize), _defineProperty(_ref2, "theme--".concat(btnStatus), btnStatus && !isText), _defineProperty(_ref2, 'is--disabled', disabled || loading), _defineProperty(_ref2, 'is--loading', loading), _ref2)],
|
|
attrs: {
|
|
name: name,
|
|
type: isFormBtn ? type : null,
|
|
disabled: disabled || loading
|
|
},
|
|
on: Object.assign({
|
|
mouseenter: this.mouseenterEvent,
|
|
mouseleave: this.mouseleaveEvent
|
|
}, _xeUtils.default.objectMap($listeners, function (cb, type) {
|
|
return function (evnt) {
|
|
return _this.$emit(type, evnt);
|
|
};
|
|
}))
|
|
}, this.renderContent(h).concat([h('i', {
|
|
class: "vxe-button--dropdown-arrow ".concat(_conf.default.icon.dropdownBottom)
|
|
})])), h('div', {
|
|
class: 'vxe-button--dropdown-wrapper',
|
|
on: {
|
|
click: this.clickDropdownEvent,
|
|
mouseenter: this.mouseenterEvent,
|
|
mouseleave: this.mouseleaveEvent
|
|
}
|
|
}, $scopedSlots.dropdowns.call(this))]) : h('button', {
|
|
class: ['vxe-button', "type--".concat(btnType), (_ref3 = {}, _defineProperty(_ref3, "size--".concat(vSize), vSize), _defineProperty(_ref3, "theme--".concat(btnStatus), btnStatus && !isText), _defineProperty(_ref3, 'is--disabled', disabled || loading), _defineProperty(_ref3, 'is--loading', loading), _ref3)],
|
|
attrs: {
|
|
name: name,
|
|
type: isFormBtn ? type : null,
|
|
disabled: disabled || loading
|
|
},
|
|
on: _xeUtils.default.objectMap($listeners, function (cb, type) {
|
|
return function (evnt) {
|
|
return _this.$emit(type, evnt);
|
|
};
|
|
})
|
|
}, this.renderContent(h));
|
|
},
|
|
methods: {
|
|
renderContent: function renderContent(h) {
|
|
var $scopedSlots = this.$scopedSlots,
|
|
icon = this.icon,
|
|
loading = this.loading;
|
|
var contents = [];
|
|
|
|
if (loading) {
|
|
contents.push(h('i', {
|
|
class: ['vxe-button--loading-icon', _conf.default.icon.btnLoading]
|
|
}));
|
|
} else if (icon) {
|
|
contents.push(h('i', {
|
|
class: ['vxe-button--icon', icon]
|
|
}));
|
|
}
|
|
|
|
if ($scopedSlots.default) {
|
|
contents.push($scopedSlots.default.call(this));
|
|
}
|
|
|
|
return contents;
|
|
},
|
|
clickDropdownEvent: function clickDropdownEvent(evnt) {
|
|
var dropdownElem = evnt.currentTarget;
|
|
var wrapperElem = dropdownElem.parentNode;
|
|
|
|
var _DomTools$getEventTar = _tools.DomTools.getEventTargetNode(evnt, dropdownElem, 'vxe-button'),
|
|
flag = _DomTools$getEventTar.flag,
|
|
targetElem = _DomTools$getEventTar.targetElem;
|
|
|
|
if (flag) {
|
|
wrapperElem.dataset.active = 'N';
|
|
|
|
_tools.DomTools.removeClass(wrapperElem, 'is--active');
|
|
|
|
_tools.UtilTools.emitEvent(this, 'dropdown-click', [{
|
|
name: targetElem.getAttribute('name')
|
|
}, evnt]);
|
|
}
|
|
},
|
|
mouseenterEvent: function mouseenterEvent(evnt) {
|
|
var dropdownElem = evnt.currentTarget;
|
|
var wrapperElem = dropdownElem.parentNode;
|
|
wrapperElem.dataset.active = 'Y';
|
|
|
|
_tools.DomTools.addClass(wrapperElem, 'is--active');
|
|
},
|
|
mouseleaveEvent: function mouseleaveEvent(evnt) {
|
|
var dropdownElem = evnt.currentTarget;
|
|
var wrapperElem = dropdownElem.parentNode;
|
|
wrapperElem.dataset.active = 'N';
|
|
setTimeout(function () {
|
|
if (wrapperElem.dataset.active !== 'Y') {
|
|
_tools.DomTools.removeClass(wrapperElem, 'is--active');
|
|
}
|
|
}, 300);
|
|
}
|
|
}
|
|
};
|
|
exports.default = _default; |