@dazhicheng/ui 1.6.4 → 1.6.6

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.
@@ -1,8 +1,8 @@
1
- import { defineComponent as d, ref as i, computed as g, watch as x, unref as r, onMounted as w, nextTick as v, withDirectives as S, createElementBlock as _, openBlock as k, normalizeClass as y, normalizeStyle as B, renderSlot as C } from "vue";
1
+ import { defineComponent as _, ref as c, computed as b, watch as p, unref as r, nextTick as m, onMounted as B, onBeforeUnmount as C, withDirectives as L, createElementBlock as O, openBlock as k, normalizeClass as A, normalizeStyle as D, renderSlot as E } from "vue";
2
2
  import "../../../../node_modules/.pnpm/vue-types@5.1.3_vue@3.5.21_typescript@5.9.3_/node_modules/vue-types/shim/index.modern.js";
3
- import { useDesign as H } from "../../../../packages/hooks/src/useDesign.js";
3
+ import { useDesign as T } from "../../../../packages/hooks/src/useDesign.js";
4
4
  import "axios";
5
- import { vLoading as T } from "element-plus";
5
+ import { vLoading as z } from "element-plus";
6
6
  import "dayjs";
7
7
  import "numeral";
8
8
  import "xe-utils";
@@ -16,48 +16,79 @@ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pa
16
16
  import "lodash-es";
17
17
  import { useIsScroll as $ } from "../../../../packages/hooks/src/useIsScroll.js";
18
18
  import "vue-router";
19
- import { basicProps as b } from "../props.js";
20
- const V = /* @__PURE__ */ d({
19
+ import { basicProps as I } from "../props.js";
20
+ import { MODAL_OVERLAY_CONTAINED_CLASS as N } from "../utils/resolve-modal-target.js";
21
+ const se = /* @__PURE__ */ _({
21
22
  name: "TtWrapper",
22
23
  __name: "ModalWrapper",
23
- props: b,
24
+ props: {
25
+ ...I,
26
+ /** 区域遮罩:高度相对挂载容器,不再按整屏 vh */
27
+ contained: { type: Boolean, default: !1 }
28
+ },
24
29
  emits: ["is-scroll"],
25
- setup(p, { expose: m, emit: s }) {
26
- const t = p, n = s, l = i(window.innerHeight * 0.7), { prefixCls: a } = H("modal-wrapper"), o = i(), c = g(() => ({
27
- // minHeight: `${props.minHeight}px`,
28
- maxHeight: t.isBottom ? "calc(100vh - 60px - 44px - 33px)" : `${t.height || l.value}px`,
29
- height: t.height > 0 ? `${t.height}px !important` : "auto"
30
- // overflow: 'auto',
31
- // padding: '12px 16px',
32
- }));
33
- function f() {
30
+ setup(h, { expose: f, emit: d }) {
31
+ const t = h, u = d, s = c(Math.floor(window.innerHeight * 0.7)), { prefixCls: g } = T("modal-wrapper"), o = c();
32
+ let n;
33
+ function l() {
34
+ var i;
35
+ const e = r(o);
36
+ return ((i = e == null ? void 0 : e.closest) == null ? void 0 : i.call(e, ".el-overlay")) || null;
37
+ }
38
+ function a() {
39
+ const e = l(), i = t.contained || !!(e != null && e.classList.contains(N)), y = e && e.clientHeight > 0 ? e.clientHeight : window.innerHeight, M = i ? 40 : Math.floor(window.innerHeight * 0.15), R = i ? 24 : 0, S = Math.max(160, y - M - R - 116);
40
+ s.value = S;
41
+ }
42
+ const v = b(() => {
43
+ if (t.contained && !(t.height > 0))
44
+ return {
45
+ maxHeight: "none",
46
+ height: "auto"
47
+ };
48
+ const e = t.height > 0 ? Math.min(t.height, s.value) : s.value;
49
+ return {
50
+ maxHeight: t.isBottom ? t.contained ? "calc(100% - 137px)" : "calc(100vh - 60px - 44px - 33px)" : `${e}px`,
51
+ height: t.height > 0 ? `${t.height}px !important` : "auto"
52
+ };
53
+ });
54
+ function x() {
34
55
  r(o) && r(o).scrollTo(0, 1e6);
35
56
  }
36
- const { hasScrollbar: h, update: u } = $();
37
- return x(
38
- () => r(h),
57
+ const { hasScrollbar: w, update: H } = $();
58
+ return p(
59
+ () => r(w),
39
60
  (e) => {
40
- n("is-scroll", e);
61
+ u("is-scroll", e);
62
+ }
63
+ ), p(
64
+ () => t.contained,
65
+ () => {
66
+ m(() => a());
41
67
  }
42
- ), w(() => {
43
- v(() => {
44
- u(o);
68
+ ), B(() => {
69
+ m(() => {
70
+ H(o), a();
71
+ const e = l();
72
+ e && typeof ResizeObserver < "u" && (n = new ResizeObserver(() => a()), n.observe(e));
45
73
  });
46
- }), m({
47
- onScrollBottom: f,
74
+ }), C(() => {
75
+ n == null || n.disconnect(), n = void 0;
76
+ }), f({
77
+ onScrollBottom: x,
78
+ setModalHeight: a,
48
79
  elm: o
49
- }), (e, z) => S((k(), _("div", {
80
+ }), (e, i) => L((k(), O("div", {
50
81
  ref_key: "wrapperRef",
51
82
  ref: o,
52
- style: B(c.value),
53
- class: y([r(a)])
83
+ style: D(v.value),
84
+ class: A([r(g)])
54
85
  }, [
55
- C(e.$slots, "default")
86
+ E(e.$slots, "default")
56
87
  ], 6)), [
57
- [r(T), e.loading]
88
+ [r(z), e.loading]
58
89
  ]);
59
90
  }
60
91
  });
61
92
  export {
62
- V as default
93
+ se as default
63
94
  };
@@ -1,30 +1,31 @@
1
1
  import { useStore as y } from "@tanstack/vue-store";
2
- import { reactive as x, ref as T, defineComponent as p, provide as _, nextTick as v, h as u, inject as S, onMounted as g, watch as k, render as h } from "vue";
3
- import { RouterView as E } from "vue-router";
4
- import O from "../RenderModal.vue.js";
2
+ import { reactive as w, ref as x, defineComponent as M, provide as _, nextTick as v, h as i, inject as g, onMounted as E, watch as S, render as h } from "vue";
3
+ import { RouterView as k } from "vue-router";
4
+ import T from "../RenderModal.vue.js";
5
5
  /* empty css */
6
6
  import { ModalApi as b } from "../utils/modal-api.js";
7
- const P = Symbol("Tt_MODAL_INJECT"), R = {};
8
- function D(r = {}, a = P) {
9
- var l;
10
- const { connectedComponent: d } = r;
7
+ import { resolveModalTarget as P } from "../utils/resolve-modal-target.js";
8
+ const R = Symbol("Tt_MODAL_INJECT"), V = {};
9
+ function F(n = {}, c = R) {
10
+ var u;
11
+ const { connectedComponent: d } = n;
11
12
  if (d) {
12
- const t = x({}), o = T(!0);
13
- return [p(
14
- (m, { attrs: A, slots: C }) => (_(a, {
15
- extendApi(w) {
16
- Object.setPrototypeOf(t, w);
13
+ const e = w({}), a = x(!0);
14
+ return [M(
15
+ (m, { attrs: A, slots: C }) => (_(c, {
16
+ extendApi(O) {
17
+ Object.setPrototypeOf(e, O);
17
18
  },
18
- options: r,
19
+ options: n,
19
20
  async reCreateModal() {
20
- o.value = !1, await v(), o.value = !0;
21
+ a.value = !1, await v(), a.value = !0;
21
22
  }
22
- }), V(t, {
23
+ }), L(e, {
23
24
  ...m,
24
25
  ...A,
25
26
  ...C
26
- }), () => u(
27
- o.value ? d : "div",
27
+ }), () => i(
28
+ a.value ? d : "div",
28
29
  {
29
30
  ...m,
30
31
  ...A
@@ -35,97 +36,97 @@ function D(r = {}, a = P) {
35
36
  name: "TtModal",
36
37
  inheritAttrs: !1
37
38
  }
38
- ), t];
39
+ ), e];
39
40
  }
40
- const n = S(a, {}), e = {
41
- ...R,
42
- ...n.options,
43
- ...r
41
+ const o = g(c, {}), t = {
42
+ ...V,
43
+ ...o.options,
44
+ ...n
44
45
  };
45
- e.onVisibleChange = (t) => {
46
- var o, c, m;
47
- (o = r.onVisibleChange) == null || o.call(r, t), (m = (c = n.options) == null ? void 0 : c.onVisibleChange) == null || m.call(c, t);
46
+ t.onVisibleChange = (e) => {
47
+ var a, r, m;
48
+ (a = n.onVisibleChange) == null || a.call(n, e), (m = (r = o.options) == null ? void 0 : r.onVisibleChange) == null || m.call(r, e);
48
49
  };
49
- const s = e.onClosed;
50
- e.onClosed = () => {
51
- var t;
52
- s == null || s(), e.destroyOnClose && ((t = n.reCreateDrawer) == null || t.call(n));
50
+ const s = t.onClosed;
51
+ t.onClosed = () => {
52
+ var e;
53
+ s == null || s(), t.destroyOnClose && ((e = o.reCreateDrawer) == null || e.call(o));
53
54
  };
54
- const f = new b(e), i = f;
55
- i.useStore = (t) => y(f.store, t);
56
- const M = p(
57
- (t, { attrs: o, slots: c }) => () => u(
58
- O,
55
+ const f = new b(t), l = f;
56
+ l.useStore = (e) => y(f.store, e);
57
+ const p = M(
58
+ (e, { attrs: a, slots: r }) => () => i(
59
+ T,
59
60
  {
60
- ...t,
61
- ...o,
62
- modalApi: i
61
+ ...e,
62
+ ...a,
63
+ modalApi: l
63
64
  },
64
- c
65
+ r
65
66
  ),
66
67
  {
67
68
  name: "TtModal",
68
69
  inheritAttrs: !1
69
70
  }
70
71
  );
71
- return (l = n.extendApi) == null || l.call(n, i), [M, i];
72
+ return (u = o.extendApi) == null || u.call(o, l), [p, l];
72
73
  }
73
- function F(r, a, d) {
74
- const n = new b(d), e = n;
75
- e.useStore = (l) => y(n.store, l);
74
+ function K(n, c, d) {
75
+ const o = new b(d), t = o;
76
+ t.useStore = (e) => y(o.store, e);
76
77
  const s = document.createElement("div");
77
- document.body.appendChild(s);
78
- const f = p(
79
- (l, { slots: t }) => (g(() => {
80
- d && e.setModalProps(d), e.openModal();
81
- }), k(
78
+ (d.appendToBody ? document.body : P() ?? document.body).appendChild(s);
79
+ const l = M(
80
+ (e, { slots: a }) => (E(() => {
81
+ d && t.setModalProps(d), t.openModal();
82
+ }), S(
82
83
  () => {
83
- var o;
84
- return (o = e.getVisible) == null ? void 0 : o.value;
84
+ var r;
85
+ return (r = t.getVisible) == null ? void 0 : r.value;
85
86
  },
86
- (o) => {
87
- o || (h(null, s), s.remove());
87
+ (r) => {
88
+ r || (h(null, s), s.remove());
88
89
  }
89
- ), () => u(
90
- O,
90
+ ), () => i(
91
+ T,
91
92
  {
92
- ...l,
93
- modalApi: e
93
+ ...e,
94
+ modalApi: t
94
95
  },
95
- t
96
+ a
96
97
  )),
97
98
  {
98
99
  name: "TtModal",
99
100
  inheritAttrs: !1
100
101
  }
101
- ), i = u(a, {}), M = u(
102
- E,
102
+ ), p = i(c, {}), u = i(
103
+ k,
103
104
  {},
104
- () => u(
105
- f,
105
+ () => i(
106
+ l,
106
107
  {
107
108
  ...d
108
109
  },
109
110
  {
110
- default: () => i
111
+ default: () => p
111
112
  }
112
113
  )
113
114
  );
114
- return M.appContext = r._context, h(M, s), e;
115
+ return u.appContext = n._context, h(u, s), t;
115
116
  }
116
- async function V(r, a) {
117
- var e;
118
- if (!a || Object.keys(a).length === 0)
117
+ async function L(n, c) {
118
+ var t;
119
+ if (!c || Object.keys(c).length === 0)
119
120
  return;
120
121
  await v();
121
- const d = (e = r == null ? void 0 : r.store) == null ? void 0 : e.state;
122
+ const d = (t = n == null ? void 0 : n.store) == null ? void 0 : t.state;
122
123
  if (!d)
123
124
  return;
124
- const n = new Set(Object.keys(d));
125
- for (const s of Object.keys(a))
126
- n.has(s) && ["class"].includes(s);
125
+ const o = new Set(Object.keys(d));
126
+ for (const s of Object.keys(c))
127
+ o.has(s) && ["class"].includes(s);
127
128
  }
128
129
  export {
129
- F as showTtModal,
130
- D as useModalRender
130
+ K as showTtModal,
131
+ F as useModalRender
131
132
  };
@@ -152,6 +152,11 @@ export type ModalRenderState = {
152
152
  * @default false
153
153
  */
154
154
  isBottom?: boolean;
155
+ /**
156
+ * 点击遮罩是否关闭弹窗
157
+ * @default false
158
+ */
159
+ closeOnClickModal?: boolean;
155
160
  } & Partial<DialogProps>;
156
161
  export type ModalApiOptions = ModalRenderState & Partial<DialogProps> & {
157
162
  /**
@@ -4,10 +4,10 @@ var s = (o, t, e) => b(o, typeof t != "symbol" ? t + "" : t, e);
4
4
  import "axios";
5
5
  import "element-plus";
6
6
  import { isElement as S, isFunction as n } from "../../../../packages/utils/src/is.js";
7
- import { computed as w } from "vue";
7
+ import { computed as C } from "vue";
8
8
  import "dayjs";
9
9
  import "numeral";
10
- import { bindMethods as C } from "../../../../packages/utils/src/tool.js";
10
+ import { bindMethods as w } 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";
@@ -50,7 +50,7 @@ class _ {
50
50
  * 获取弹窗的可见状态
51
51
  * @returns 弹窗的可见状态
52
52
  */
53
- s(this, "getVisible", w(() => this.state.visible));
53
+ s(this, "getVisible", C(() => this.state.visible));
54
54
  const {
55
55
  connectedComponent: e,
56
56
  onVisibleChange: i,
@@ -87,7 +87,9 @@ class _ {
87
87
  cancelButtonProps: {},
88
88
  isBottom: !1,
89
89
  resizeChange: void 0,
90
- modal: D.showMask
90
+ modal: D.showMask,
91
+ /** 点击遮罩是否关闭,默认 false */
92
+ closeOnClickModal: !1
91
93
  };
92
94
  this.store = new k(m(f, g), {
93
95
  onUpdate: () => {
@@ -95,7 +97,7 @@ class _ {
95
97
  const l = this.store.state;
96
98
  this.state = l, l.visible !== ((h = this.state) == null ? void 0 : h.visible) && ((d = (c = this.api).onVisibleChange) == null || d.call(c, !!l.visible));
97
99
  }
98
- }), this.state = this.store.state, this.api = { onVisibleChange: i, onClose: a, onClosed: r, onOk: p, onReceiveSharedData: u }, C(this);
100
+ }), this.state = this.store.state, this.api = { onVisibleChange: i, onClose: a, onClosed: r, onOk: p, onReceiveSharedData: u }, w(this);
99
101
  }
100
102
  /**
101
103
  * 挂载弹窗实例和API接口
@@ -0,0 +1,19 @@
1
+ export declare const MODAL_OVERLAY_CONTAINED_CLASS = "tt-modal-overlay--contained";
2
+ /** 注入全局样式,避免仅依赖 Vue SFC / scopecss 导致 absolute 未生效 */
3
+ export declare function ensureContainedOverlayStyle(doc?: Document): void;
4
+ /** 用内联样式强制区域遮罩,压过 EP 的 position:fixed(含内部 overlay-dialog) */
5
+ export declare function applyContainedOverlayInline(uid: string | number, doc?: Document): void;
6
+ /** KeepAlive / 切页:隐藏已 Teleport 出去的遮罩,避免挡其它页。找到并隐藏则 true */
7
+ export declare function suspendOverlayByUid(uid: string | number, doc?: Document): boolean;
8
+ /**
9
+ * 打开后立刻切页时,遮罩可能晚一帧才挂上。监听 DOM,出现后立刻隐藏。
10
+ * 返回取消函数。
11
+ */
12
+ export declare function watchOverlayThenSuspend(uid: string | number, doc?: Document, timeoutMs?: number): () => void;
13
+ /** KeepAlive / 切回:恢复未关闭的弹窗遮罩 */
14
+ export declare function resumeOverlayByUid(uid: string | number, doc?: Document): void;
15
+ /**
16
+ * 解析弹窗 Teleport 目标。无可用节点时返回 null,由调用方回退 body。
17
+ * 子应用只要处在 micro 环境,尽量返回内容区节点(含 micro-app-body),以便加 contained class。
18
+ */
19
+ export declare function resolveModalTarget(): HTMLElement | null;
@@ -0,0 +1,153 @@
1
+ const a = "tt-modal-overlay--contained", u = "tt-modal-overlay-contained-style-v2";
2
+ function y(t = document) {
3
+ var r;
4
+ if (typeof t > "u") return;
5
+ const o = `
6
+ .el-overlay.${a},
7
+ .el-overlay.${a} .el-overlay-dialog {
8
+ position: absolute !important;
9
+ inset: 0 !important;
10
+ height: 100% !important;
11
+ }
12
+ .el-overlay.${a} .el-overlay-dialog {
13
+ overflow: auto !important;
14
+ }
15
+ .el-overlay.${a} .tt-ui-modal.el-dialog {
16
+ --tt-modal-contained-top: 40px;
17
+ --tt-modal-contained-bottom: 24px;
18
+ margin-top: var(--tt-modal-contained-top) !important;
19
+ margin-bottom: var(--tt-modal-contained-bottom) !important;
20
+ max-height: calc(100% - var(--tt-modal-contained-top) - var(--tt-modal-contained-bottom)) !important;
21
+ display: flex !important;
22
+ flex-direction: column !important;
23
+ overflow: hidden !important;
24
+ }
25
+ .el-overlay.${a} .tt-ui-modal.el-dialog .el-dialog__header,
26
+ .el-overlay.${a} .tt-ui-modal.el-dialog .el-dialog__footer {
27
+ flex-shrink: 0;
28
+ }
29
+ .el-overlay.${a} .tt-ui-modal.el-dialog .el-dialog__body {
30
+ display: flex !important;
31
+ flex: 1 1 auto !important;
32
+ flex-direction: column !important;
33
+ min-height: 0 !important;
34
+ overflow: hidden !important;
35
+ }
36
+ .el-overlay.${a} .tt-ui-modal.el-dialog .tt-modal-wrapper {
37
+ flex: 1 1 auto !important;
38
+ min-height: 0 !important;
39
+ max-height: none !important;
40
+ overflow: auto !important;
41
+ }
42
+ `.trim();
43
+ let e = t.getElementById(u);
44
+ if (e) {
45
+ e.textContent = o;
46
+ return;
47
+ }
48
+ (r = t.getElementById("tt-modal-overlay-contained-style")) == null || r.remove(), e = t.createElement("style"), e.id = u, e.textContent = o;
49
+ const n = t.head || t.documentElement;
50
+ n == null || n.appendChild(e);
51
+ }
52
+ function p(t) {
53
+ t.style.setProperty("position", "absolute", "important"), t.style.setProperty("top", "0", "important"), t.style.setProperty("right", "0", "important"), t.style.setProperty("bottom", "0", "important"), t.style.setProperty("left", "0", "important"), t.style.setProperty("height", "100%", "important");
54
+ }
55
+ function f(t, o = document) {
56
+ const e = o.querySelector(`.el-overlay.tt-id-${t}`);
57
+ if (!e) return;
58
+ const n = !!e.closest("micro-app-body");
59
+ if (!e.classList.contains(a) && !n) return;
60
+ p(e);
61
+ const r = e.querySelector(".el-overlay-dialog");
62
+ r && p(r);
63
+ }
64
+ function m(t, o = document) {
65
+ const e = o.querySelector(`.el-overlay.tt-id-${t}`);
66
+ return e ? (e.dataset.ttModalSuspended = "1", e.style.setProperty("display", "none", "important"), !0) : !1;
67
+ }
68
+ function b(t, o = document, e = 3e3) {
69
+ if (m(t, o)) return () => {
70
+ };
71
+ const n = o.body || o.documentElement;
72
+ if (!n) return () => {
73
+ };
74
+ let r = !1;
75
+ const i = () => {
76
+ r || (r = !0, s.disconnect(), clearTimeout(d));
77
+ }, s = new MutationObserver(() => {
78
+ m(t, o) && i();
79
+ });
80
+ s.observe(n, { childList: !0, subtree: !0 });
81
+ const d = window.setTimeout(i, e);
82
+ return i;
83
+ }
84
+ function C(t, o = document) {
85
+ const e = o.querySelector(`.el-overlay.tt-id-${t}`);
86
+ !e || e.dataset.ttModalSuspended !== "1" || (delete e.dataset.ttModalSuspended, e.style.removeProperty("display"), f(t, o));
87
+ }
88
+ function v(t) {
89
+ return t.isConnected ? t.getClientRects().length > 0 : !1;
90
+ }
91
+ function g(t) {
92
+ return t.isConnected ? (t.clientHeight || t.getBoundingClientRect().height) >= 48 : !1;
93
+ }
94
+ function c(t) {
95
+ return !!t.closest("micro-app-body");
96
+ }
97
+ function l(t, o = !0) {
98
+ return !t || !t.isConnected || o && !g(t) || o && !v(t) ? null : t;
99
+ }
100
+ function h(t) {
101
+ getComputedStyle(t).position === "static" && (t.style.position = "relative");
102
+ }
103
+ function _() {
104
+ const t = window.__MICRO_APP_NAME__;
105
+ if (t) {
106
+ const i = typeof CSS < "u" && CSS.escape ? CSS.escape(t) : t, s = document.querySelector(
107
+ `micro-app[name="${i}"] micro-app-body #app`
108
+ ), d = l(s, !1);
109
+ if (d) return d;
110
+ }
111
+ const o = document.querySelector("#app");
112
+ if (o) {
113
+ const i = l(o, !1);
114
+ return i || o;
115
+ }
116
+ const e = document.querySelector("micro-app-body #app");
117
+ if (e) {
118
+ const i = l(e, !1);
119
+ if (i) return i;
120
+ }
121
+ const n = document.body;
122
+ return n && (n.tagName === "MICRO-APP-BODY" || c(n)) ? n : document.querySelector("micro-app-body");
123
+ }
124
+ function S() {
125
+ const t = document.querySelector("#app-content");
126
+ if (t && !c(t)) {
127
+ const e = l(t, !0);
128
+ if (e) return e;
129
+ }
130
+ const o = document.querySelectorAll("#app");
131
+ for (const e of Array.from(o)) {
132
+ const n = e;
133
+ if (c(n)) continue;
134
+ const r = l(n, !0);
135
+ if (r) return r;
136
+ }
137
+ return null;
138
+ }
139
+ function A() {
140
+ if (typeof document > "u") return null;
141
+ y();
142
+ const t = window.__MICRO_APP_ENVIRONMENT__ ? _() : S();
143
+ return t && h(t), t;
144
+ }
145
+ export {
146
+ a as MODAL_OVERLAY_CONTAINED_CLASS,
147
+ f as applyContainedOverlayInline,
148
+ y as ensureContainedOverlayStyle,
149
+ A as resolveModalTarget,
150
+ C as resumeOverlayByUid,
151
+ m as suspendOverlayByUid,
152
+ b as watchOverlayThenSuspend
153
+ };