UNPKG

tav-ui

Version:
103 lines (100 loc) 4.12 kB
import { defineComponent, ref, computed, unref, h, resolveComponent, openBlock, createElementBlock, renderSlot, Fragment, createBlock, normalizeProps, mergeProps, withCtx, createVNode } from 'vue'; import { ExclamationCircleOutlined } from '@ant-design/icons-vue'; import { Tooltip, Modal } from 'ant-design-vue'; import { useAttrs } from '../../../hooks/core/useAttrs2.mjs'; import { TaButton } from '../../button/index2.mjs'; import { TaIcon } from '../../icon/index2.mjs'; import { isString } from '../../../utils/is2.mjs'; import '../../../locales/index2.mjs'; import { buttonModalProps } from './types2.mjs'; import _export_sfc from '../../../../_virtual/plugin-vue_export-helper.mjs'; import { tavI18n } from '../../../locales/transfer2.mjs'; const _sfc_main = defineComponent({ name: "TaButtonModal", components: { Button: TaButton, Tooltip }, inheritAttrs: false, props: buttonModalProps, setup(props) { const actionEl = ref(null); const attrs = useAttrs(); const getBindValues = computed(() => { return Object.assign({ okText: tavI18n("Tav.common.okText"), cancelText: tavI18n("Tav.common.cancelText") }, { ...props, ...unref(attrs) }); }); function getTooltip(data) { return { getPopupContainer: () => unref(actionEl) || document.body, placement: "bottom", ...isString(data) ? { title: data } : data }; } const handleButtonClick = () => { const _getBindValues = unref(getBindValues); if (_getBindValues.onClick) { _getBindValues.onClick(); } else { const confirmProps = { class: "modal-button-confirm", icon: h(ExclamationCircleOutlined), ..._getBindValues.popConfirm }; if (_getBindValues.icon) confirmProps.icon = h(TaIcon, { icon: unref(getBindValues).icon }); if (_getBindValues.popConfirm && _getBindValues.popConfirm.confirm) confirmProps.onOk = _getBindValues.popConfirm.confirm; if (_getBindValues.popConfirm && _getBindValues.popConfirm.cancel) confirmProps.onCancel = _getBindValues.popConfirm.cancel; Modal.confirm(confirmProps); } }; return { getBindValues, handleButtonClick, getTooltip }; } }); function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_Button = resolveComponent("Button"); const _component_Tooltip = resolveComponent("Tooltip"); return openBlock(), createElementBlock("div", null, [ _ctx.isInDropDown ? (openBlock(), createElementBlock("div", { key: 0, class: "ta-button-modal dropdown-modal-button", onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleButtonClick && _ctx.handleButtonClick(...args)) }, [ renderSlot(_ctx.$slots, "default") ])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [ _ctx.getBindValues.tooltip ? (openBlock(), createBlock(_component_Tooltip, normalizeProps(mergeProps({ key: 0 }, _ctx.getTooltip(_ctx.getBindValues.tooltip))), { default: withCtx(() => [ createVNode(_component_Button, mergeProps({ ..._ctx.getBindValues, onClick: null }, { class: "ta-button-modal", onClick: _ctx.handleButtonClick }), { default: withCtx(() => [ renderSlot(_ctx.$slots, "default") ]), _: 3 }, 16, ["onClick"]) ]), _: 3 }, 16)) : (openBlock(), createBlock(_component_Button, mergeProps({ key: 1 }, { ..._ctx.getBindValues, onClick: null }, { class: "ta-button-modal", onClick: _ctx.handleButtonClick }), { default: withCtx(() => [ renderSlot(_ctx.$slots, "default") ]), _: 3 }, 16, ["onClick"])) ], 2112)) ]); } var ButtonModal = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/tav-ui/tav-ui/packages/components/button-modal/src/button-modal.vue"]]); export { ButtonModal as default }; //# sourceMappingURL=button-modal2.mjs.map