@dazhicheng/ui 1.6.19 → 1.6.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/tt-form/index.d.ts +2 -2
- package/dist/components/tt-form/src/formApi.d.ts +11 -2
- package/dist/components/tt-form/src/group-form/LazyFormField.vue.js +162 -114
- package/dist/components/tt-form/src/group-form/groupFormApi.js +0 -6
- package/dist/components/tt-form/src/group-form/lazyContext.d.ts +18 -0
- package/dist/components/tt-form/src/group-form/lazyContext.js +64 -36
- package/dist/components/tt-form/src/group-form/types.d.ts +39 -6
- package/dist/components/tt-form/src/group-form/useGroupForm.d.ts +7 -5
- package/dist/components/tt-form/src/types.d.ts +58 -26
- package/dist/components/tt-form/src/useForm.d.ts +1 -1
- package/dist/components/tt-form/src/useForm.js +5 -5
- package/dist/components/tt-modal/index.d.ts +1 -0
- package/dist/components/tt-modal/index.js +8 -3
- package/dist/components/tt-modal/src/RenderModal.vue.js +224 -210
- package/dist/components/tt-modal/src/hooks/useModalRender.js +66 -67
- package/dist/components/tt-modal/src/index.js +9 -7
- package/dist/components/tt-modal/src/utils/modal-api.d.ts +9 -3
- package/dist/components/tt-modal/src/utils/modal-api.js +42 -36
- package/dist/components/tt-modal/src/utils/modal-close-transition.d.ts +13 -0
- package/dist/components/tt-modal/src/utils/modal-close-transition.js +13 -0
- package/dist/components/tt-modal/src/utils/modal-host-app.d.ts +5 -0
- package/dist/components/tt-modal/src/utils/modal-host-app.js +12 -0
- package/dist/components/tt-modal/src/utils/modal-scope.d.ts +21 -0
- package/dist/components/tt-modal/src/utils/modal-scope.js +20 -0
- package/dist/components/tt-modal/src/utils/modal-service.d.ts +23 -0
- package/dist/components/tt-modal/src/utils/modal-service.js +51 -0
- package/dist/components/tt-modal/src/utils/modal-stack.d.ts +14 -13
- package/dist/components/tt-modal/src/utils/modal-stack.js +20 -9
- package/dist/components/tt-modal/src/utils/modal-z-index.d.ts +15 -0
- package/dist/components/tt-modal/src/utils/modal-z-index.js +24 -0
- package/dist/components/tt-modal/src/utils/resolve-modal-target.d.ts +14 -0
- package/dist/components/tt-modal/src/utils/resolve-modal-target.js +83 -47
- package/dist/components/tt-modal-form/props.d.ts +9 -4
- package/dist/components/tt-modal-form/useModalForm.d.ts +1 -1
- package/dist/components/tt-table/index.d.ts +15 -0
- package/dist/components/tt-table/src/Table.vue.d.ts +9 -0
- package/dist/components/tt-table/src/Table.vue.js +240 -242
- package/dist/components/tt-table/src/TableForm.vue.d.ts +7 -5
- package/dist/components/tt-table/src/TableForm.vue.js +199 -180
- package/dist/components/tt-table/src/hooks/usePagination.d.ts +1 -1
- package/dist/components/tt-table/src/hooks/usePagination.js +38 -24
- package/dist/components/tt-table/src/hooks/useTableRender.d.ts +4 -4
- package/dist/components/tt-table/src/props.d.ts +6 -0
- package/dist/components/tt-table/src/props.js +5 -0
- package/dist/components/tt-table/src/types/table.d.ts +8 -0
- package/dist/components/tt-table/src/types/tableForm.d.ts +29 -14
- package/dist/components/tt-table/src/utils/table-form-api.d.ts +11 -11
- package/dist/index.js +132 -127
- package/package.json +1 -1
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
import { useStore as
|
|
2
|
-
import { reactive as
|
|
3
|
-
import { RouterView as
|
|
4
|
-
import
|
|
1
|
+
import { useStore as h } from "@tanstack/vue-store";
|
|
2
|
+
import { reactive as x, ref as _, defineComponent as M, provide as w, nextTick as T, h as i, inject as E, onMounted as S, render as y } from "vue";
|
|
3
|
+
import { RouterView as g } from "vue-router";
|
|
4
|
+
import v from "../RenderModal.vue.js";
|
|
5
5
|
/* empty css */
|
|
6
|
-
import { ModalApi as
|
|
6
|
+
import { ModalApi as O } from "../utils/modal-api.js";
|
|
7
|
+
import { onModalCloseTransitionEnd as k } from "../utils/modal-close-transition.js";
|
|
7
8
|
import { resolveModalTarget as P } from "../utils/resolve-modal-target.js";
|
|
8
|
-
const R = Symbol("Tt_MODAL_INJECT"),
|
|
9
|
-
function
|
|
10
|
-
var
|
|
11
|
-
const { connectedComponent:
|
|
12
|
-
if (
|
|
13
|
-
const e =
|
|
9
|
+
const R = Symbol("Tt_MODAL_INJECT"), L = {};
|
|
10
|
+
function K(n = {}, c = R) {
|
|
11
|
+
var m;
|
|
12
|
+
const { connectedComponent: r } = n;
|
|
13
|
+
if (r) {
|
|
14
|
+
const e = x({}), d = _(!0);
|
|
14
15
|
return [M(
|
|
15
|
-
(
|
|
16
|
-
extendApi(
|
|
17
|
-
Object.setPrototypeOf(e,
|
|
16
|
+
(u, { attrs: C, slots: A }) => (w(c, {
|
|
17
|
+
extendApi(b) {
|
|
18
|
+
Object.setPrototypeOf(e, b);
|
|
18
19
|
},
|
|
19
20
|
options: n,
|
|
20
21
|
async reCreateModal() {
|
|
21
|
-
|
|
22
|
+
d.value = !1, await T(), d.value = !0;
|
|
22
23
|
}
|
|
23
|
-
}),
|
|
24
|
-
...
|
|
25
|
-
...
|
|
26
|
-
...
|
|
24
|
+
}), V(e, {
|
|
25
|
+
...u,
|
|
26
|
+
...C,
|
|
27
|
+
...A
|
|
27
28
|
}), () => i(
|
|
28
|
-
|
|
29
|
+
d.value ? r : "div",
|
|
29
30
|
{
|
|
30
|
-
...
|
|
31
|
-
...
|
|
31
|
+
...u,
|
|
32
|
+
...C
|
|
32
33
|
},
|
|
33
|
-
|
|
34
|
+
A
|
|
34
35
|
)),
|
|
35
36
|
{
|
|
36
37
|
name: "TtModal",
|
|
@@ -38,95 +39,93 @@ function F(n = {}, c = R) {
|
|
|
38
39
|
}
|
|
39
40
|
), e];
|
|
40
41
|
}
|
|
41
|
-
const o =
|
|
42
|
-
...
|
|
42
|
+
const o = E(c, {}), t = {
|
|
43
|
+
...L,
|
|
43
44
|
...o.options,
|
|
44
45
|
...n
|
|
45
46
|
};
|
|
46
47
|
t.onVisibleChange = (e) => {
|
|
47
|
-
var
|
|
48
|
-
(
|
|
48
|
+
var d, a, u;
|
|
49
|
+
(d = n.onVisibleChange) == null || d.call(n, e), (u = (a = o.options) == null ? void 0 : a.onVisibleChange) == null || u.call(a, e);
|
|
49
50
|
};
|
|
50
51
|
const s = t.onClosed;
|
|
51
52
|
t.onClosed = () => {
|
|
52
53
|
var e;
|
|
53
54
|
s == null || s(), t.destroyOnClose && ((e = o.reCreateDrawer) == null || e.call(o));
|
|
54
55
|
};
|
|
55
|
-
const f = new
|
|
56
|
-
l.useStore = (e) =>
|
|
56
|
+
const f = new O(t), l = f;
|
|
57
|
+
l.useStore = (e) => h(f.store, e);
|
|
57
58
|
const p = M(
|
|
58
|
-
(e, { attrs:
|
|
59
|
-
|
|
59
|
+
(e, { attrs: d, slots: a }) => () => i(
|
|
60
|
+
v,
|
|
60
61
|
{
|
|
61
62
|
...e,
|
|
62
|
-
...
|
|
63
|
+
...d,
|
|
63
64
|
modalApi: l
|
|
64
65
|
},
|
|
65
|
-
|
|
66
|
+
a
|
|
66
67
|
),
|
|
67
68
|
{
|
|
68
69
|
name: "TtModal",
|
|
69
70
|
inheritAttrs: !1
|
|
70
71
|
}
|
|
71
72
|
);
|
|
72
|
-
return (
|
|
73
|
+
return (m = o.extendApi) == null || m.call(o, l), [p, l];
|
|
73
74
|
}
|
|
74
|
-
function
|
|
75
|
-
const o = new
|
|
76
|
-
t.useStore = (e) =>
|
|
75
|
+
function q(n, c, r) {
|
|
76
|
+
const o = new O(r), t = o;
|
|
77
|
+
t.useStore = (e) => h(o.store, e);
|
|
77
78
|
const s = document.createElement("div");
|
|
78
|
-
(
|
|
79
|
+
(r.appendToBody ? document.body : P() ?? document.body).appendChild(s);
|
|
79
80
|
const l = M(
|
|
80
|
-
(e, { slots:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
a
|
|
97
|
-
)),
|
|
81
|
+
(e, { slots: d }) => {
|
|
82
|
+
S(() => {
|
|
83
|
+
r && t.setModalProps(r), t.openModal();
|
|
84
|
+
});
|
|
85
|
+
const a = k(t, () => {
|
|
86
|
+
a(), y(null, s), s.remove();
|
|
87
|
+
});
|
|
88
|
+
return () => i(
|
|
89
|
+
v,
|
|
90
|
+
{
|
|
91
|
+
...e,
|
|
92
|
+
modalApi: t
|
|
93
|
+
},
|
|
94
|
+
d
|
|
95
|
+
);
|
|
96
|
+
},
|
|
98
97
|
{
|
|
99
98
|
name: "TtModal",
|
|
100
99
|
inheritAttrs: !1
|
|
101
100
|
}
|
|
102
|
-
), p = i(c, {}),
|
|
103
|
-
|
|
101
|
+
), p = i(c, {}), m = i(
|
|
102
|
+
g,
|
|
104
103
|
{},
|
|
105
104
|
() => i(
|
|
106
105
|
l,
|
|
107
106
|
{
|
|
108
|
-
...
|
|
107
|
+
...r
|
|
109
108
|
},
|
|
110
109
|
{
|
|
111
110
|
default: () => p
|
|
112
111
|
}
|
|
113
112
|
)
|
|
114
113
|
);
|
|
115
|
-
return
|
|
114
|
+
return m.appContext = n._context, y(m, s), t;
|
|
116
115
|
}
|
|
117
|
-
async function
|
|
116
|
+
async function V(n, c) {
|
|
118
117
|
var t;
|
|
119
118
|
if (!c || Object.keys(c).length === 0)
|
|
120
119
|
return;
|
|
121
|
-
await
|
|
122
|
-
const
|
|
123
|
-
if (!
|
|
120
|
+
await T();
|
|
121
|
+
const r = (t = n == null ? void 0 : n.store) == null ? void 0 : t.state;
|
|
122
|
+
if (!r)
|
|
124
123
|
return;
|
|
125
|
-
const o = new Set(Object.keys(
|
|
124
|
+
const o = new Set(Object.keys(r));
|
|
126
125
|
for (const s of Object.keys(c))
|
|
127
126
|
o.has(s) && ["class"].includes(s);
|
|
128
127
|
}
|
|
129
128
|
export {
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
q as showTtModal,
|
|
130
|
+
K as useModalRender
|
|
132
131
|
};
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { inject as
|
|
1
|
+
import { inject as e } from "vue";
|
|
2
2
|
import { showTtModal as M } from "./hooks/useModalRender.js";
|
|
3
|
+
import { setModalHostApp as d } from "./utils/modal-host-app.js";
|
|
3
4
|
const t = Symbol("SHOW_MODAL");
|
|
4
|
-
function
|
|
5
|
-
|
|
5
|
+
function f(o) {
|
|
6
|
+
d(o);
|
|
7
|
+
const r = (n, s) => M(o, n, s);
|
|
6
8
|
o.provide(t, r);
|
|
7
9
|
}
|
|
8
|
-
function
|
|
9
|
-
const o =
|
|
10
|
+
function m() {
|
|
11
|
+
const o = e(t);
|
|
10
12
|
if (!o)
|
|
11
13
|
throw new Error("[TtModal]: useShowModal() 需要先调用 setupModal(app) 进行注册");
|
|
12
14
|
return o;
|
|
13
15
|
}
|
|
14
16
|
export {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
f as setupModal,
|
|
18
|
+
m as useShowModal
|
|
17
19
|
};
|
|
@@ -14,6 +14,8 @@ export declare class ModalApi {
|
|
|
14
14
|
private api;
|
|
15
15
|
/** 弹窗的当前状态,使用Partial<ModalRenderState>类型 */
|
|
16
16
|
state: ModalRenderState;
|
|
17
|
+
/** 可见状态的响应式镜像:store.state 是普通对象,computed 直接读它取不到变化 */
|
|
18
|
+
private visibleRef;
|
|
17
19
|
/** 弹窗的实例方法,用于处理弹窗的各种操作 */
|
|
18
20
|
private methods?;
|
|
19
21
|
/** 构造函数,初始化弹窗的API接口和状态 */
|
|
@@ -55,8 +57,7 @@ export declare class ModalApi {
|
|
|
55
57
|
openModal<T>(visible?: boolean, data?: T): void;
|
|
56
58
|
/**
|
|
57
59
|
* 设置弹窗的属性
|
|
58
|
-
* @param props -
|
|
59
|
-
* @returns 当前实例
|
|
60
|
+
* @param props - 属性对象,传 visible 即按传入值开关弹窗
|
|
60
61
|
*/
|
|
61
62
|
setModalProps(props: Partial<ModalRenderState>): Promise<void>;
|
|
62
63
|
/**
|
|
@@ -81,11 +82,16 @@ export declare class ModalApi {
|
|
|
81
82
|
* 关闭弹窗
|
|
82
83
|
*/
|
|
83
84
|
closeModal(): void;
|
|
85
|
+
/**
|
|
86
|
+
* 关闭页面上所有已打开的弹窗,不限打开方式。
|
|
87
|
+
* 走 ESC / 取消按钮同一条路径,各弹窗的 closeFunc 拦截仍生效。
|
|
88
|
+
*/
|
|
89
|
+
closeAll(): void;
|
|
84
90
|
/**
|
|
85
91
|
* 获取弹窗的可见状态
|
|
86
92
|
* @returns 弹窗的可见状态
|
|
87
93
|
*/
|
|
88
|
-
getVisible: import('vue').ComputedRef<boolean
|
|
94
|
+
getVisible: import('vue').ComputedRef<boolean>;
|
|
89
95
|
/**
|
|
90
96
|
* 重置弹窗高度
|
|
91
97
|
*/
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var s = (o, t, e) =>
|
|
1
|
+
var b = Object.defineProperty;
|
|
2
|
+
var S = (o, t, e) => t in o ? b(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var s = (o, t, e) => S(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import "axios";
|
|
5
5
|
import "element-plus";
|
|
6
|
-
import { isElement as
|
|
7
|
-
import { computed as
|
|
6
|
+
import { isElement as C, isFunction as n } from "../../../../packages/utils/src/is.js";
|
|
7
|
+
import { shallowRef as w, computed as k } from "vue";
|
|
8
8
|
import "dayjs";
|
|
9
9
|
import "numeral";
|
|
10
|
-
import { bindMethods as
|
|
10
|
+
import { bindMethods as y } from "../../../../packages/utils/src/tool.js";
|
|
11
11
|
import { mergeWithArrayOverride as m } from "../../../../packages/utils/src/merge.js";
|
|
12
12
|
import "../../../../node_modules/.pnpm/decimal.js@10.6.0/node_modules/decimal.js/decimal.js";
|
|
13
13
|
import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js";
|
|
@@ -15,10 +15,11 @@ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/en
|
|
|
15
15
|
import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
|
|
16
16
|
import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
|
|
17
17
|
import "lodash-es";
|
|
18
|
-
import { Store as
|
|
19
|
-
import { useDebounceFn as
|
|
20
|
-
import { GlobalConfig as
|
|
21
|
-
|
|
18
|
+
import { Store as M } from "@tanstack/vue-store";
|
|
19
|
+
import { useDebounceFn as D } from "@vueuse/core";
|
|
20
|
+
import { GlobalConfig as R } from "../../../../hooks/useSetup.js";
|
|
21
|
+
import { closeAllModals as B } from "./modal-stack.js";
|
|
22
|
+
class K {
|
|
22
23
|
/** 构造函数,初始化弹窗的API接口和状态 */
|
|
23
24
|
constructor(t = {}) {
|
|
24
25
|
/** 共享数据对象,用于在组件间传递数据 */
|
|
@@ -31,17 +32,17 @@ class _ {
|
|
|
31
32
|
s(this, "api");
|
|
32
33
|
/** 弹窗的当前状态,使用Partial<ModalRenderState>类型 */
|
|
33
34
|
s(this, "state");
|
|
35
|
+
/** 可见状态的响应式镜像:store.state 是普通对象,computed 直接读它取不到变化 */
|
|
36
|
+
s(this, "visibleRef", w(!1));
|
|
34
37
|
/** 弹窗的实例方法,用于处理弹窗的各种操作 */
|
|
35
38
|
s(this, "methods");
|
|
36
39
|
/**
|
|
37
40
|
* 确认操作
|
|
38
41
|
*/
|
|
39
|
-
s(this, "onOk",
|
|
42
|
+
s(this, "onOk", D(async () => {
|
|
40
43
|
var t, e;
|
|
41
44
|
try {
|
|
42
|
-
this.changeOkLoading(!0),
|
|
43
|
-
} catch (i) {
|
|
44
|
-
throw new Error(i);
|
|
45
|
+
this.changeOkLoading(!0), await ((e = (t = this.api).onOk) == null ? void 0 : e.call(t));
|
|
45
46
|
} finally {
|
|
46
47
|
this.changeOkLoading(!1);
|
|
47
48
|
}
|
|
@@ -50,16 +51,16 @@ class _ {
|
|
|
50
51
|
* 获取弹窗的可见状态
|
|
51
52
|
* @returns 弹窗的可见状态
|
|
52
53
|
*/
|
|
53
|
-
s(this, "getVisible",
|
|
54
|
+
s(this, "getVisible", k(() => this.visibleRef.value));
|
|
54
55
|
const {
|
|
55
56
|
connectedComponent: e,
|
|
56
57
|
onVisibleChange: i,
|
|
57
58
|
onClose: a,
|
|
58
|
-
onClosed:
|
|
59
|
+
onClosed: l,
|
|
59
60
|
onOk: p,
|
|
60
|
-
onReceiveSharedData:
|
|
61
|
-
...
|
|
62
|
-
} = t,
|
|
61
|
+
onReceiveSharedData: f,
|
|
62
|
+
...u
|
|
63
|
+
} = t, v = {
|
|
63
64
|
visible: !1,
|
|
64
65
|
title: "",
|
|
65
66
|
cancelText: "取消",
|
|
@@ -87,17 +88,17 @@ class _ {
|
|
|
87
88
|
cancelButtonProps: {},
|
|
88
89
|
isBottom: !1,
|
|
89
90
|
resizeChange: void 0,
|
|
90
|
-
modal:
|
|
91
|
+
modal: R.showMask,
|
|
91
92
|
/** 点击遮罩是否关闭,默认 false */
|
|
92
93
|
closeOnClickModal: !1
|
|
93
94
|
};
|
|
94
|
-
this.store = new
|
|
95
|
+
this.store = new M(m(u, v), {
|
|
95
96
|
onUpdate: () => {
|
|
96
97
|
var h, c, d;
|
|
97
|
-
const
|
|
98
|
-
this.state =
|
|
98
|
+
const r = this.store.state, g = (h = this.state) == null ? void 0 : h.visible;
|
|
99
|
+
this.state = r, r.visible !== g && (this.visibleRef.value = !!r.visible, (d = (c = this.api).onVisibleChange) == null || d.call(c, !!r.visible));
|
|
99
100
|
}
|
|
100
|
-
}), this.state = this.store.state, this.api = { onVisibleChange: i, onClose: a, onClosed:
|
|
101
|
+
}), this.state = this.store.state, this.visibleRef.value = !!this.state.visible, this.api = { onVisibleChange: i, onClose: a, onClosed: l, onOk: p, onReceiveSharedData: f }, y(this);
|
|
101
102
|
}
|
|
102
103
|
/**
|
|
103
104
|
* 挂载弹窗实例和API接口
|
|
@@ -111,13 +112,13 @@ class _ {
|
|
|
111
112
|
* 关闭弹窗
|
|
112
113
|
*/
|
|
113
114
|
async close() {
|
|
114
|
-
var a,
|
|
115
|
+
var a, l;
|
|
115
116
|
const t = document.querySelector('.viewer-container[aria-modal="true"]');
|
|
116
|
-
if (
|
|
117
|
+
if (C(t))
|
|
117
118
|
return;
|
|
118
119
|
const { closeFunc: e } = this.state;
|
|
119
120
|
let i = !0;
|
|
120
|
-
e && n(e) && (i = await e()), this.setState({ visible: !i }), (
|
|
121
|
+
e && n(e) && (i = await e()), this.setState({ visible: !i }), (l = (a = this.api).onClosed) == null || l.call(a);
|
|
121
122
|
}
|
|
122
123
|
/**
|
|
123
124
|
* 取消操作
|
|
@@ -152,16 +153,14 @@ class _ {
|
|
|
152
153
|
}
|
|
153
154
|
/**
|
|
154
155
|
* 设置弹窗的属性
|
|
155
|
-
* @param props -
|
|
156
|
-
* @returns 当前实例
|
|
156
|
+
* @param props - 属性对象,传 visible 即按传入值开关弹窗
|
|
157
157
|
*/
|
|
158
158
|
async setModalProps(t) {
|
|
159
|
-
if (this.setState(t), Reflect.has(t, "visible"))
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
this.setState({ visible: !t.visible });
|
|
159
|
+
if (this.setState(t), !Reflect.has(t, "visible") || t.visible) return;
|
|
160
|
+
const { closeFunc: e } = this.state;
|
|
161
|
+
if (!e || !n(e)) return;
|
|
162
|
+
const i = await e();
|
|
163
|
+
this.setState({ visible: !i });
|
|
165
164
|
}
|
|
166
165
|
/**
|
|
167
166
|
* 设置弹窗的加载状态
|
|
@@ -194,6 +193,13 @@ class _ {
|
|
|
194
193
|
closeModal() {
|
|
195
194
|
this.setState({ visible: !1 });
|
|
196
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* 关闭页面上所有已打开的弹窗,不限打开方式。
|
|
198
|
+
* 走 ESC / 取消按钮同一条路径,各弹窗的 closeFunc 拦截仍生效。
|
|
199
|
+
*/
|
|
200
|
+
closeAll() {
|
|
201
|
+
B();
|
|
202
|
+
}
|
|
197
203
|
/**
|
|
198
204
|
* 重置弹窗高度
|
|
199
205
|
*/
|
|
@@ -210,5 +216,5 @@ class _ {
|
|
|
210
216
|
}
|
|
211
217
|
}
|
|
212
218
|
export {
|
|
213
|
-
|
|
219
|
+
K as ModalApi
|
|
214
220
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ModalApi } from './modal-api';
|
|
2
|
+
/**
|
|
3
|
+
* 订阅弹窗关闭动画结束
|
|
4
|
+
* @param api 弹窗 api 实例
|
|
5
|
+
* @param listener 动画结束后的回调
|
|
6
|
+
* @returns 取消订阅
|
|
7
|
+
*/
|
|
8
|
+
export declare function onModalCloseTransitionEnd(api: ModalApi, listener: () => void): () => void;
|
|
9
|
+
/**
|
|
10
|
+
* 通知弹窗关闭动画已结束,由 RenderModal 在 ElDialog 的 closed 事件里调用
|
|
11
|
+
* @param api 弹窗 api 实例
|
|
12
|
+
*/
|
|
13
|
+
export declare function emitModalCloseTransitionEnd(api: ModalApi): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const o = /* @__PURE__ */ new WeakMap();
|
|
2
|
+
function s(t, e) {
|
|
3
|
+
const n = o.get(t) ?? /* @__PURE__ */ new Set();
|
|
4
|
+
return o.set(t, n), n.add(e), () => n.delete(e);
|
|
5
|
+
}
|
|
6
|
+
function a(t) {
|
|
7
|
+
var e;
|
|
8
|
+
(e = o.get(t)) == null || e.forEach((n) => n());
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
a as emitModalCloseTransitionEnd,
|
|
12
|
+
s as onModalCloseTransitionEnd
|
|
13
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 微前端隔离工具。组件库被抽成共享依赖时多个子应用共用模块级状态,
|
|
3
|
+
* 因此模块级注册表都要按子应用分桶。
|
|
4
|
+
*/
|
|
5
|
+
/** 当前作用域标识:子应用用 micro-app name,宿主页面用 host */
|
|
6
|
+
export declare function getModalScopeKey(): string;
|
|
7
|
+
/**
|
|
8
|
+
* 取真实 document。沙箱里的 document 代理会把查询范围收窄到子应用内,
|
|
9
|
+
* 从真实节点回溯才能看到其它子应用的弹窗;shadowDOM 模式下退回传入值。
|
|
10
|
+
* @param doc 起点 document
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveScanDocument(doc: Document): Document;
|
|
13
|
+
/** 当前可用的 document,SSR 下返回 undefined */
|
|
14
|
+
export declare function getClientDocument(): Document | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* 两个节点是否属于同一个子应用(宿主页面节点视作同一作用域)。
|
|
17
|
+
* 跨子应用复用挂载容器会让弹窗随对方卸载一起消失。
|
|
18
|
+
* @param a 节点 a
|
|
19
|
+
* @param b 节点 b
|
|
20
|
+
*/
|
|
21
|
+
export declare function isSameMicroAppScope(a: HTMLElement, b: HTMLElement): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function c() {
|
|
2
|
+
return typeof window > "u" ? "host" : window.__MICRO_APP_NAME__ || "host";
|
|
3
|
+
}
|
|
4
|
+
function u(t) {
|
|
5
|
+
var n;
|
|
6
|
+
const o = t.body ?? t.documentElement, e = (n = o == null ? void 0 : o.getRootNode) == null ? void 0 : n.call(o);
|
|
7
|
+
return e instanceof Document ? e : t;
|
|
8
|
+
}
|
|
9
|
+
function i() {
|
|
10
|
+
return typeof document > "u" ? void 0 : document;
|
|
11
|
+
}
|
|
12
|
+
function r(t, o) {
|
|
13
|
+
return t.closest("micro-app-body") === o.closest("micro-app-body");
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
i as getClientDocument,
|
|
17
|
+
c as getModalScopeKey,
|
|
18
|
+
r as isSameMicroAppScope,
|
|
19
|
+
u as resolveScanDocument
|
|
20
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ModalApiOptions, TtModalExtendedModalApi } from '../typing';
|
|
2
|
+
/** 命令式打开弹窗的配置,与 useModalRender 入参一致:内容组件放 connectedComponent */
|
|
3
|
+
export type OpenTtModalOptions = ModalApiOptions;
|
|
4
|
+
/**
|
|
5
|
+
* 命令式打开弹窗
|
|
6
|
+
* useShowModal 内部是 inject 只能在 setup 用;这里从 setupModal 记录的实例取 appContext。
|
|
7
|
+
* @param options 弹窗配置,内容组件放 connectedComponent
|
|
8
|
+
* @returns 弹窗 api
|
|
9
|
+
*/
|
|
10
|
+
export declare function openTtModal(options?: OpenTtModalOptions): TtModalExtendedModalApi;
|
|
11
|
+
/**
|
|
12
|
+
* 关闭命令式打开的弹窗
|
|
13
|
+
* @param target 指定要关闭的弹窗 api,缺省关闭最上层那个
|
|
14
|
+
*/
|
|
15
|
+
export declare function closeTtModal(target?: TtModalExtendedModalApi): void;
|
|
16
|
+
/** 关闭当前作用域下所有已打开的弹窗,不限于 ttModal.open 开的 */
|
|
17
|
+
export declare function closeAllTtModal(): void;
|
|
18
|
+
/** 命令式弹窗入口,用法见文档 */
|
|
19
|
+
export declare const ttModal: {
|
|
20
|
+
open: typeof openTtModal;
|
|
21
|
+
close: typeof closeTtModal;
|
|
22
|
+
closeAll: typeof closeAllTtModal;
|
|
23
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { defineComponent as r } from "vue";
|
|
2
|
+
import { showTtModal as d } from "../hooks/useModalRender.js";
|
|
3
|
+
import { getModalHostApp as i } from "./modal-host-app.js";
|
|
4
|
+
import { getModalScopeKey as f } from "./modal-scope.js";
|
|
5
|
+
import { closeAllModals as M } from "./modal-stack.js";
|
|
6
|
+
const m = r({
|
|
7
|
+
name: "TtModalEmptyContent",
|
|
8
|
+
setup: () => () => null
|
|
9
|
+
}), c = /* @__PURE__ */ new Map();
|
|
10
|
+
function l() {
|
|
11
|
+
const n = f(), o = c.get(n);
|
|
12
|
+
if (o) return o;
|
|
13
|
+
const t = [];
|
|
14
|
+
return c.set(n, t), t;
|
|
15
|
+
}
|
|
16
|
+
function s(n) {
|
|
17
|
+
c.forEach((o) => {
|
|
18
|
+
const t = o.indexOf(n);
|
|
19
|
+
t !== -1 && o.splice(t, 1);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function u(n = {}) {
|
|
23
|
+
const o = i();
|
|
24
|
+
if (!o)
|
|
25
|
+
throw new Error("[TtModal]: 命令式打开弹窗需要先 app.use(TtUI) 或调用 setupModal(app) 完成注册");
|
|
26
|
+
const { connectedComponent: t, onClosed: e, ...a } = n, p = d(o, t ?? m, {
|
|
27
|
+
...a,
|
|
28
|
+
onClosed() {
|
|
29
|
+
s(p), e == null || e();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return l().push(p), p;
|
|
33
|
+
}
|
|
34
|
+
function T(n) {
|
|
35
|
+
const o = l(), t = n ?? o[o.length - 1];
|
|
36
|
+
t && (s(t), t.close());
|
|
37
|
+
}
|
|
38
|
+
function g() {
|
|
39
|
+
l().splice(0), M();
|
|
40
|
+
}
|
|
41
|
+
const x = {
|
|
42
|
+
open: u,
|
|
43
|
+
close: T,
|
|
44
|
+
closeAll: g
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
g as closeAllTtModal,
|
|
48
|
+
T as closeTtModal,
|
|
49
|
+
u as openTtModal,
|
|
50
|
+
x as ttModal
|
|
51
|
+
};
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 弹窗 ESC 栈管理器
|
|
3
|
-
*
|
|
4
|
-
* 解决 element-plus ElDialog 两个问题:
|
|
5
|
-
* 1. 多个弹窗同时打开时,按 ESC 会一次性关闭所有弹窗。
|
|
6
|
-
* 期望:按一次 ESC 只关闭最顶层(最后打开)的弹窗,逐个关闭。
|
|
7
|
-
* 2. 弹窗内表单元素(input / select 等)聚焦时按 ESC 也会关闭弹窗。
|
|
8
|
-
* vue2 的 element-ui 不存在该问题。
|
|
9
|
-
* 期望:焦点位于表单交互元素上时,ESC 交给该元素处理(如关闭下拉),不关闭弹窗。
|
|
10
|
-
*
|
|
11
|
-
* 实现方式:在 ElDialog 上禁用原生 close-on-press-escape,由本管理器统一处理。
|
|
12
|
-
*/
|
|
13
1
|
export interface ModalStackItem {
|
|
14
2
|
/** 弹窗实例 uid */
|
|
15
3
|
uid: number;
|
|
16
4
|
/** 关闭弹窗的回调 */
|
|
17
5
|
close: () => void;
|
|
6
|
+
/** 所属子应用,微前端下共享组件库时用于隔离批量关闭 */
|
|
7
|
+
scope?: string;
|
|
18
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* 当前作用域下逻辑上还打开着的弹窗 uid。
|
|
11
|
+
* 关闭时立即出栈,所以不含正在播离场动画的弹窗——那些不该再被当成已打开。
|
|
12
|
+
*/
|
|
13
|
+
export declare function getOpenModalUids(): number[];
|
|
19
14
|
/**
|
|
20
15
|
* 弹窗打开时入栈,并确保全局监听已绑定。
|
|
21
16
|
*/
|
|
22
|
-
export declare function pushModal(item: ModalStackItem): void;
|
|
17
|
+
export declare function pushModal(item: Omit<ModalStackItem, "scope">): void;
|
|
18
|
+
/**
|
|
19
|
+
* 关闭当前作用域下所有已打开的弹窗,从最上层往下逐个关。
|
|
20
|
+
* 栈里不区分打开方式,声明式、useShowModal、ttModal.open 开的都会关;
|
|
21
|
+
* 走 ESC / 取消按钮同一条路径,closeFunc 拦截仍生效。
|
|
22
|
+
*/
|
|
23
|
+
export declare function closeAllModals(): void;
|
|
23
24
|
/**
|
|
24
25
|
* 弹窗关闭时出栈,栈为空时解绑全局监听。
|
|
25
26
|
*/
|