| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- import { c$ as b, B as p, _ as i, cU as y, e as O } from "./index2.js";
- import { shallowRef as s, onBeforeUnmount as m, defineComponent as P, onMounted as R, createVNode as x } from "vue";
- const A = () => {
- const n = s(!1);
- return m(() => {
- n.value = !0;
- }), n;
- }, D = {
- type: {
- type: String
- },
- actionFn: Function,
- close: Function,
- autofocus: Boolean,
- prefixCls: String,
- buttonProps: O(),
- emitEvent: Boolean,
- quitOnNullishReturnValue: Boolean
- };
- function d(n) {
- return !!(n && n.then);
- }
- const T = P({
- compatConfig: {
- MODE: 3
- },
- name: "ActionButton",
- props: D,
- setup(n, g) {
- let {
- slots: B
- } = g;
- const l = s(!1), c = s(), u = s(!1);
- let f;
- const v = A();
- R(() => {
- n.autofocus && (f = setTimeout(() => {
- var e, t;
- return (t = (e = b(c.value)) === null || e === void 0 ? void 0 : e.focus) === null || t === void 0 ? void 0 : t.call(e);
- }));
- }), m(() => {
- clearTimeout(f);
- });
- const a = function() {
- for (var e, t = arguments.length, o = new Array(t), r = 0; r < t; r++)
- o[r] = arguments[r];
- (e = n.close) === null || e === void 0 || e.call(n, ...o);
- }, h = (e) => {
- d(e) && (u.value = !0, e.then(function() {
- v.value || (u.value = !1), a(...arguments), l.value = !1;
- }, (t) => (v.value || (u.value = !1), l.value = !1, Promise.reject(t))));
- }, C = (e) => {
- const {
- actionFn: t
- } = n;
- if (l.value)
- return;
- if (l.value = !0, !t) {
- a();
- return;
- }
- let o;
- if (n.emitEvent) {
- if (o = t(e), n.quitOnNullishReturnValue && !d(o)) {
- l.value = !1, a(e);
- return;
- }
- } else if (t.length)
- o = t(n.close), l.value = !1;
- else if (o = t(), !o) {
- a();
- return;
- }
- h(o);
- };
- return () => {
- const {
- type: e,
- prefixCls: t,
- buttonProps: o
- } = n;
- return x(p, i(i(i({}, y(e)), {}, {
- onClick: C,
- loading: u.value,
- prefixCls: t
- }, o), {}, {
- ref: c
- }), B);
- };
- }
- });
- export {
- T as A
- };
|