UNPKG

tdesign-vue

Version:
169 lines (165 loc) 6.65 kB
/** * tdesign v1.14.1 * (c) 2025 tdesign * @license MIT */ import { h as helper } from '../_chunks/dep-6a4dc7bb.js'; import _typeof from '@babel/runtime/helpers/typeof'; import _defineProperty from '@babel/runtime/helpers/defineProperty'; import Vue from 'vue'; import { isString, isObject } from 'lodash-es'; import { renderTNodeJSX } from '../utils/render-tnode.js'; import { Button } from '../button/index.js'; import '@babel/runtime/helpers/readOnlyError'; import '@vue/composition-api'; import '../button/button.js'; import '../loading/index.js'; import '../loading/directive.js'; import '../loading/plugin.js'; import '../loading/loading.js'; import '../loading/icon/gradient.js'; import '../_common/js/loading/circle-adapter.js'; import '../_common/js/utils/setStyle.js'; import '../_common/js/utils/helper.js'; import '@babel/runtime/helpers/toConsumableArray'; import '@babel/runtime/helpers/objectWithoutProperties'; import '@babel/runtime/helpers/slicedToArray'; import '../config-provider/config-receiver.js'; import '../config-provider/context.js'; import '../_common/js/global-config/default-config.js'; import '../_common/js/global-config/locale/zh_CN.js'; import '../_chunks/dep-ba613a02.js'; import '../_chunks/dep-fdb1b253.js'; import 'dayjs'; import '../_common/js/global-config/t.js'; import '../utils/mixins.js'; import '../utils/dom.js'; import 'raf'; import '../utils/easing.js'; import '../utils/transfer-dom.js'; import '../loading/props.js'; import '../config.js'; import '../utils/withInstall.js'; import '../button/props.js'; import '../utils/ripple.js'; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var ActionMixin = Vue.extend({ methods: { getConfirmBtn: function getConfirmBtn(options) { var h = this.$createElement; var confirmBtn = options.confirmBtn, className = options.className, confirmLoading = options.confirmLoading; if (confirmBtn === null) return null; if (confirmBtn && this.$scopedSlots.confirmBtn) { console.warn("Both $props.confirmBtn and $scopedSlots.confirmBtn exist, $props.confirmBtn is preferred."); } var defaultButtonProps = this.getDefaultConfirmBtnProps(options); if (!confirmBtn && !this.$scopedSlots.confirmBtn) { return h(Button, helper([{ "class": className }, { "props": _objectSpread({ loading: confirmLoading }, defaultButtonProps) }])); } if (confirmBtn && ["string", "object"].includes(_typeof(confirmBtn))) { return this.getButtonByProps(confirmBtn, { defaultButtonProps: defaultButtonProps, className: className, confirmLoading: confirmLoading }); } return renderTNodeJSX(this, "confirmBtn"); }, getCancelBtn: function getCancelBtn(options) { var h = this.$createElement; var cancelBtn = options.cancelBtn, className = options.className; if (cancelBtn === null) return null; if (cancelBtn && this.$scopedSlots.cancelBtn) { console.warn("Both $props.cancelBtn and $scopedSlots.cancelBtn exist, $props.cancelBtn is preferred."); } var defaultButtonProps = this.getDefaultCancelBtnProps(options); if (!cancelBtn && !this.$scopedSlots.cancelBtn) { return h(Button, helper([{ "class": className }, { "props": _objectSpread({}, defaultButtonProps) }])); } if (cancelBtn && ["string", "object"].includes(_typeof(cancelBtn))) { return this.getButtonByProps(cancelBtn, { defaultButtonProps: defaultButtonProps, className: className }); } return renderTNodeJSX(this, "cancelBtn"); }, getButtonByProps: function getButtonByProps(button, params) { var h = this.$createElement; var defaultButtonProps = params.defaultButtonProps, className = params.className, confirmLoading = params.confirmLoading; var newOptions = defaultButtonProps; if (isString(button)) { newOptions.content = button; } else if (isObject(button)) { newOptions = _objectSpread(_objectSpread({}, newOptions), button); } if (confirmLoading !== void 0) { newOptions.loading = confirmLoading; } return h(Button, helper([{ "class": className }, { "props": newOptions }])); }, confirmBtnAction: function confirmBtnAction(e) {}, cancelBtnAction: function cancelBtnAction(e) {}, getDefaultConfirmBtnProps: function getDefaultConfirmBtnProps(options) { var _this = this; var globalConfirm = options.globalConfirm, theme = options.theme, globalConfirmBtnTheme = options.globalConfirmBtnTheme; var defaultTheme = (globalConfirmBtnTheme === null || globalConfirmBtnTheme === void 0 ? void 0 : globalConfirmBtnTheme[theme]) || "primary"; var props = { theme: defaultTheme, content: "\u786E\u5B9A", size: options.size, onClick: function onClick(e) { _this.confirmBtnAction(e); } }; if (isString(globalConfirm)) { props.content = globalConfirm; } else if (isObject(globalConfirm)) { props = _objectSpread(_objectSpread({}, props), globalConfirm); } return props; }, getDefaultCancelBtnProps: function getDefaultCancelBtnProps(options) { var _this2 = this; var globalCancel = options.globalCancel; var props = { theme: "default", content: "\u53D6\u6D88", size: options.size, onClick: function onClick(e) { _this2.cancelBtnAction(e); } }; if (isString(globalCancel)) { props.content = globalCancel; } else if (isObject(globalCancel)) { props = _objectSpread(_objectSpread({}, props), globalCancel); } return props; } } }); export { ActionMixin as default }; //# sourceMappingURL=actions.js.map