tav-ui
Version:
82 lines (77 loc) • 3.45 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var antDesignVue = require('ant-design-vue');
var useAttrs = require('../../../hooks/core/useAttrs2.js');
var index = require('../../icon/index2.js');
require('../../permission/index2.js');
var useGlobalConfig = require('../../../hooks/global/useGlobalConfig2.js');
require('../../../utils/index2.js');
var types = require('./types2.js');
var pluginVue_exportHelper = require('../../../../_virtual/plugin-vue_export-helper.js');
var is = require('../../../utils/is2.js');
var utils = require('../../permission/src/utils2.js');
const _sfc_main = vue.defineComponent({
name: "TaButton",
components: { Button: antDesignVue.Button, Icon: index.TaIcon },
inheritAttrs: false,
props: types.buttonProps,
setup(props) {
const attrs = useAttrs.useAttrs({ excludeDefaultKeys: false });
const getButtonClass = vue.computed(() => {
const { color, disabled } = props;
return [
{
[`ant-btn-${color}`]: !!color,
"is-disabled": disabled
}
];
});
const getBindValue = vue.computed(() => ({ ...vue.unref(attrs), ...props }));
const IfShow = vue.computed(() => (code) => {
const permissions = useGlobalConfig.useGlobalConfig("permissions");
const PermissionFlag = is.isUnDef(code) ? true : vue.unref(permissions)[code]?.ifShow;
const PermisionCodeFlag = is.isUnDef(props.permissionCode) ? true : props.permissionCode === 1;
return PermissionFlag && PermisionCodeFlag && props.ifShow;
});
const computedUsePermission = vue.computed(() => {
if (props.usePermission) {
return utils.usePermissionMatchedByParent({
...props.usePermission
}).value;
}
return true;
});
return { getButtonClass, getBindValue, IfShow, computedUsePermission };
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_Icon = vue.resolveComponent("Icon");
const _component_Button = vue.resolveComponent("Button", true);
return vue.withDirectives((vue.openBlock(), vue.createBlock(_component_Button, vue.mergeProps(_ctx.getBindValue, {
class: [_ctx.getButtonClass, "ta-basic-button"],
onClick: _ctx.onClick
}), {
default: vue.withCtx((data) => [
!_ctx.loading && _ctx.preIcon ? (vue.openBlock(), vue.createBlock(_component_Icon, {
key: 0,
icon: _ctx.preIcon,
size: _ctx.iconSize,
color: _ctx.preIconColor
}, null, 8, ["icon", "size", "color"])) : vue.createCommentVNode("v-if", true),
!_ctx.loading ? vue.renderSlot(_ctx.$slots, "default", vue.normalizeProps(vue.mergeProps({ key: 1 }, data || {}))) : vue.createCommentVNode("v-if", true),
!_ctx.loading && _ctx.postIcon ? (vue.openBlock(), vue.createBlock(_component_Icon, {
key: 2,
icon: _ctx.postIcon,
size: _ctx.iconSize,
color: _ctx.postIconColor
}, null, 8, ["icon", "size", "color"])) : vue.createCommentVNode("v-if", true)
]),
_: 3
}, 16, ["class", "onClick"])), [
[vue.vShow, _ctx.computedUsePermission && _ctx.IfShow(_ctx.permission)]
]);
}
var Button = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/tav-ui/tav-ui/packages/components/button/src/button.vue"]]);
exports["default"] = Button;
//# sourceMappingURL=button2.js.map