@truenewx/tnxvue3 3.4.7 → 3.5.0
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/package.json +2 -2
- package/src/components/ScrollView.vue +1 -1
- package/src/tdesign/mobile/dialog/Dialog.vue +56 -22
- package/src/tdesign/mobile/popup/Popup.vue +20 -1
- package/src/tdesign/mobile/popup/popupZIndex.js +52 -0
- package/src/tdesign/mobile/tnxtdm.css +20 -2
- package/src/tdesign/mobile/tnxtdm.ts +2 -0
- package/src/tnxvue-router.ts +2 -17
- package/src/tnxvue.ts +2 -1
- package/src/vue.d.ts +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truenewx/tnxvue3",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "互联网技术解决方案:Vue3扩展支持",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"vue-router": "~5.1.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@truenewx/tnxcore": "3.
|
|
34
|
+
"@truenewx/tnxcore": "3.5.0",
|
|
35
35
|
"bootstrap": "5.3.8",
|
|
36
36
|
"cash-dom": "8.1.5",
|
|
37
37
|
"mitt": "3.0.1"
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<t-dialog
|
|
3
|
-
class="tnxtdm-dialog"
|
|
3
|
+
:class="['tnxtdm-dialog', dialogDomClass]"
|
|
4
4
|
v-model:visible="visible"
|
|
5
5
|
:title="title"
|
|
6
6
|
:width="width"
|
|
7
|
+
:style="{height: height}"
|
|
7
8
|
:close-on-overlay-click="options['close-on-overlay-click']"
|
|
8
9
|
:close-btn="!buttons?.length"
|
|
9
10
|
:destroy-on-close="true"
|
|
@@ -26,6 +27,7 @@
|
|
|
26
27
|
|
|
27
28
|
<script>
|
|
28
29
|
import DialogContent from './DialogContent.vue';
|
|
30
|
+
import {updatePopupDomZIndex} from '../popup/popupZIndex';
|
|
29
31
|
|
|
30
32
|
export default {
|
|
31
33
|
name: 'TnxtdmDialog',
|
|
@@ -44,14 +46,13 @@ export default {
|
|
|
44
46
|
contentProps: Object,
|
|
45
47
|
buttons: Array,
|
|
46
48
|
theme: String,
|
|
47
|
-
width:
|
|
48
|
-
|
|
49
|
-
default: '100%',
|
|
50
|
-
},
|
|
49
|
+
width: [Number, String],
|
|
50
|
+
height: String,
|
|
51
51
|
},
|
|
52
52
|
emits: ['update:modelValue', 'shown', 'closed'],
|
|
53
53
|
data() {
|
|
54
54
|
return {
|
|
55
|
+
dialogDomClass: `tnxtdm-dialog-${this.id}`,
|
|
55
56
|
visible: this.modelValue,
|
|
56
57
|
options: {
|
|
57
58
|
modal: true,
|
|
@@ -69,10 +70,16 @@ export default {
|
|
|
69
70
|
},
|
|
70
71
|
visible(val) {
|
|
71
72
|
this.$emit('update:modelValue', val);
|
|
73
|
+
if (val) {
|
|
74
|
+
this.updateZIndex();
|
|
75
|
+
}
|
|
72
76
|
}
|
|
73
77
|
},
|
|
74
78
|
mounted() {
|
|
75
79
|
this.$nextTick(() => {
|
|
80
|
+
if (this.visible) {
|
|
81
|
+
this.updateZIndex();
|
|
82
|
+
}
|
|
76
83
|
if (this.$refs.content && !this.$refs.content.close) {
|
|
77
84
|
this.$refs.content.close = () => {
|
|
78
85
|
this.close();
|
|
@@ -87,6 +94,15 @@ export default {
|
|
|
87
94
|
});
|
|
88
95
|
},
|
|
89
96
|
methods: {
|
|
97
|
+
updateZIndex() {
|
|
98
|
+
this.$nextTick(() => {
|
|
99
|
+
window.requestAnimationFrame(() => {
|
|
100
|
+
const dialogElement = document.body.querySelector(`.${this.dialogDomClass}`);
|
|
101
|
+
const popupElement = dialogElement ? dialogElement.closest('.t-popup') : null;
|
|
102
|
+
updatePopupDomZIndex(popupElement);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
},
|
|
90
106
|
btnClick(index) {
|
|
91
107
|
const button = this.buttons[index];
|
|
92
108
|
if (button) {
|
|
@@ -152,28 +168,46 @@ export default {
|
|
|
152
168
|
|
|
153
169
|
<style>
|
|
154
170
|
.tnxtdm-dialog {
|
|
171
|
+
--td-dialog-width: calc(var(--max-page-width) - 48px);
|
|
172
|
+
max-height: calc(100vh - 48px);
|
|
173
|
+
}
|
|
155
174
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
175
|
+
.tnxtdm-dialog .t-dialog {
|
|
176
|
+
height: 100%;
|
|
177
|
+
display: flex;
|
|
178
|
+
flex-direction: column;
|
|
179
|
+
}
|
|
160
180
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
181
|
+
.tnxtdm-dialog .t-dialog .t-dialog__content {
|
|
182
|
+
flex: 1;
|
|
183
|
+
min-height: 0;
|
|
184
|
+
max-height: 100%;
|
|
185
|
+
}
|
|
164
186
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
187
|
+
.tnxtdm-dialog .t-dialog .t-dialog__content .t-dialog__body {
|
|
188
|
+
flex: 1;
|
|
189
|
+
min-height: 0;
|
|
190
|
+
}
|
|
168
191
|
|
|
169
|
-
|
|
170
|
-
|
|
192
|
+
.tnxtdm-dialog .t-dialog .t-dialog__content .t-dialog__body .t-dialog__body-text {
|
|
193
|
+
height: 100%;
|
|
194
|
+
max-height: 100%;
|
|
195
|
+
}
|
|
171
196
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
197
|
+
.tnxtdm-dialog.t-dialog__wrapper.t-popup--center {
|
|
198
|
+
max-width: var(--max-page-width);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.tnxtdm-dialog .t-dialog__close-btn {
|
|
202
|
+
right: 12px;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.tnxtdm-dialog .t-dialog__footer {
|
|
206
|
+
padding: 12px 24px;
|
|
207
|
+
}
|
|
177
208
|
|
|
209
|
+
.tnxtdm-dialog .t-dialog__footer .tnxtdm-dialog-footer {
|
|
210
|
+
padding: 12px 0;
|
|
211
|
+
width: 100%;
|
|
178
212
|
}
|
|
179
213
|
</style>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<slot name="trigger" :show="open" :visible="visible"></slot>
|
|
3
3
|
<t-popup
|
|
4
|
-
class="tnxtdm-popup"
|
|
4
|
+
:class="['tnxtdm-popup', popupDomClass]"
|
|
5
5
|
v-model="visible"
|
|
6
6
|
:placement="placement"
|
|
7
7
|
:destroy-on-close="true"
|
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
</template>
|
|
30
30
|
|
|
31
31
|
<script>
|
|
32
|
+
import {updatePopupDomZIndex} from './popupZIndex';
|
|
33
|
+
|
|
32
34
|
export default {
|
|
33
35
|
name: 'TnxtdmPopup',
|
|
34
36
|
props: {
|
|
@@ -41,6 +43,7 @@ export default {
|
|
|
41
43
|
},
|
|
42
44
|
data() {
|
|
43
45
|
return {
|
|
46
|
+
popupDomClass: `tnxtdm-popup-${window.tnx.util.string.uuid32()}`,
|
|
44
47
|
visible: false,
|
|
45
48
|
}
|
|
46
49
|
},
|
|
@@ -50,6 +53,9 @@ export default {
|
|
|
50
53
|
},
|
|
51
54
|
visible(val) {
|
|
52
55
|
this.$emit('update:modelValue', val);
|
|
56
|
+
if (val) {
|
|
57
|
+
this.updateZIndex();
|
|
58
|
+
}
|
|
53
59
|
},
|
|
54
60
|
},
|
|
55
61
|
emits: ['update:modelValue', 'close'],
|
|
@@ -57,6 +63,14 @@ export default {
|
|
|
57
63
|
this.visible = this.modelValue;
|
|
58
64
|
},
|
|
59
65
|
methods: {
|
|
66
|
+
updateZIndex() {
|
|
67
|
+
this.$nextTick(() => {
|
|
68
|
+
window.requestAnimationFrame(() => {
|
|
69
|
+
const popupElement = document.body.querySelector(`.${this.popupDomClass}`);
|
|
70
|
+
updatePopupDomZIndex(popupElement);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
},
|
|
60
74
|
open() {
|
|
61
75
|
this.visible = true;
|
|
62
76
|
},
|
|
@@ -71,9 +85,14 @@ export default {
|
|
|
71
85
|
<style>
|
|
72
86
|
.tnxtdm-popup {
|
|
73
87
|
border-radius: 12px 12px 0 0;
|
|
88
|
+
width: 100%;
|
|
89
|
+
max-width: var(--max-page-width);
|
|
74
90
|
max-height: 80vh;
|
|
75
91
|
display: flex;
|
|
76
92
|
flex-direction: column;
|
|
93
|
+
left: 0;
|
|
94
|
+
right: 0;
|
|
95
|
+
margin: 0 auto;
|
|
77
96
|
}
|
|
78
97
|
|
|
79
98
|
.tnxtdm-popup .tnxtdm-popup-header {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
function getElementZIndex(element) {
|
|
2
|
+
if (!element) {
|
|
3
|
+
return 0;
|
|
4
|
+
}
|
|
5
|
+
const zIndex = parseInt(window.getComputedStyle(element).zIndex, 10);
|
|
6
|
+
if (isNaN(zIndex)) {
|
|
7
|
+
return 0;
|
|
8
|
+
}
|
|
9
|
+
return zIndex;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getTopBodyChildZIndex(excludeElements = []) {
|
|
13
|
+
const excludeSet = new Set(excludeElements.filter(Boolean));
|
|
14
|
+
let maxZIndex = 0;
|
|
15
|
+
|
|
16
|
+
Array.from(document.body.children).forEach((element) => {
|
|
17
|
+
if (excludeSet.has(element)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const zIndex = getElementZIndex(element);
|
|
21
|
+
if (zIndex > maxZIndex) {
|
|
22
|
+
maxZIndex = zIndex;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return maxZIndex;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function findOverlayElement(contentElement) {
|
|
30
|
+
let element = contentElement ? contentElement.previousElementSibling : null;
|
|
31
|
+
while (element) {
|
|
32
|
+
if (element.classList && element.classList.contains('t-overlay')) {
|
|
33
|
+
return element;
|
|
34
|
+
}
|
|
35
|
+
element = element.previousElementSibling;
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function updatePopupDomZIndex(contentElement) {
|
|
41
|
+
if (!contentElement || !document.body.contains(contentElement)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const overlayElement = findOverlayElement(contentElement);
|
|
46
|
+
const maxZIndex = getTopBodyChildZIndex([contentElement, overlayElement]);
|
|
47
|
+
|
|
48
|
+
if (overlayElement) {
|
|
49
|
+
overlayElement.style.zIndex = String(maxZIndex + 1);
|
|
50
|
+
}
|
|
51
|
+
contentElement.style.zIndex = String(maxZIndex + 2);
|
|
52
|
+
}
|
|
@@ -68,8 +68,18 @@
|
|
|
68
68
|
font-size: 14px;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
.t-
|
|
72
|
-
|
|
71
|
+
.t-dialog__content {
|
|
72
|
+
padding: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.t-dialog__header {
|
|
76
|
+
padding: 1rem 0 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.t-dialog__body {
|
|
80
|
+
margin-top: 1rem;
|
|
81
|
+
padding-left: 20px;
|
|
82
|
+
padding-right: 20px;
|
|
73
83
|
overflow-y: auto;
|
|
74
84
|
}
|
|
75
85
|
|
|
@@ -77,6 +87,10 @@
|
|
|
77
87
|
margin-top: 1rem;
|
|
78
88
|
}
|
|
79
89
|
|
|
90
|
+
.t-drawer__sidebar {
|
|
91
|
+
overflow-y: auto;
|
|
92
|
+
}
|
|
93
|
+
|
|
80
94
|
.t-drawer__sidebar-item-icon {
|
|
81
95
|
display: flex;
|
|
82
96
|
align-items: center;
|
|
@@ -87,6 +101,10 @@
|
|
|
87
101
|
padding-right: 0;
|
|
88
102
|
}
|
|
89
103
|
|
|
104
|
+
.t-popup {
|
|
105
|
+
z-index: 1001;
|
|
106
|
+
}
|
|
107
|
+
|
|
90
108
|
.t-popover__wrapper {
|
|
91
109
|
display: flex;
|
|
92
110
|
align-items: center;
|
|
@@ -109,6 +109,8 @@ export default class TnxTdm extends TnxTd {
|
|
|
109
109
|
contentProps: contentProps,
|
|
110
110
|
buttons: buttons,
|
|
111
111
|
theme: options.theme,
|
|
112
|
+
width: options.width,
|
|
113
|
+
height: options.height,
|
|
112
114
|
});
|
|
113
115
|
const dialog = dialogVm.mount(containerSelector) as ModalComponentInstance;
|
|
114
116
|
dialog.options = Object.assign(dialog.options || {}, options);
|
package/src/tnxvue-router.ts
CHANGED
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
RouteLocationNormalized,
|
|
12
12
|
RouteLocationNormalizedLoaded,
|
|
13
13
|
RouteLocationNormalizedLoadedGeneric,
|
|
14
|
-
NavigationGuardNext,
|
|
15
14
|
} from 'vue-router';
|
|
16
15
|
import * as NetUtil from '../../tnxcore/src/util/net.ts';
|
|
17
16
|
|
|
@@ -160,8 +159,7 @@ export default function (items: RouteItem[], useHashHistory = true, fnImportPage
|
|
|
160
159
|
router.$beforeLeaveHandlers[path] = handler;
|
|
161
160
|
};
|
|
162
161
|
|
|
163
|
-
router.beforeEach((to: RouteLocationNormalized, from: RouteLocationNormalizedLoaded
|
|
164
|
-
let allow = true;
|
|
162
|
+
router.beforeEach((to: RouteLocationNormalized, from: RouteLocationNormalizedLoaded) => {
|
|
165
163
|
let beforeLeaveHandler = router.$beforeLeaveHandlers[from.path];
|
|
166
164
|
if (!beforeLeaveHandler) {
|
|
167
165
|
let toItem = findItemByPath(null, items, to.path);
|
|
@@ -177,20 +175,7 @@ export default function (items: RouteItem[], useHashHistory = true, fnImportPage
|
|
|
177
175
|
}
|
|
178
176
|
}
|
|
179
177
|
if (beforeLeaveHandler) {
|
|
180
|
-
|
|
181
|
-
if (result instanceof Promise) {
|
|
182
|
-
result.then((allowed: boolean): void => {
|
|
183
|
-
if (allowed) {
|
|
184
|
-
next();
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
return;
|
|
188
|
-
} else if (result === false) {
|
|
189
|
-
allow = false;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
if (allow) {
|
|
193
|
-
next();
|
|
178
|
+
return beforeLeaveHandler(to);
|
|
194
179
|
}
|
|
195
180
|
});
|
|
196
181
|
|
package/src/tnxvue.ts
CHANGED
|
@@ -28,7 +28,8 @@ export type DialogOptions = {
|
|
|
28
28
|
click?: boolean | ((yes: boolean, close: () => void) => boolean | undefined) | ((close: () => void) => boolean | undefined);
|
|
29
29
|
buttonText?: string | string[];
|
|
30
30
|
buttons?: ButtonOptions[];
|
|
31
|
-
width?:
|
|
31
|
+
width?: string | number;
|
|
32
|
+
height?: string;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export type OpenType = 'alert' | 'confirm' | 'close' | 'none';
|