@neatui/vue 2.15.11 → 2.16.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
CHANGED
|
@@ -10,54 +10,38 @@
|
|
|
10
10
|
class="fekit-layer"
|
|
11
11
|
>
|
|
12
12
|
<div :ui-flex="`col ${flex}`" :style="wrapStyle" class="fekit-layer-wrap" @animationend="anim" @click="_sys_hide">
|
|
13
|
-
<slot></slot>
|
|
13
|
+
<slot :param="_tasks[id]?.params"></slot>
|
|
14
14
|
</div>
|
|
15
15
|
</div>
|
|
16
16
|
</Teleport>
|
|
17
17
|
</template>
|
|
18
18
|
<script lang="ts" setup>
|
|
19
|
-
import { onBeforeUnmount,
|
|
19
|
+
import { onBeforeUnmount, reactive, watch } from 'vue';
|
|
20
20
|
import { isFunction } from '@fekit/utils';
|
|
21
|
+
import { _tasks, getActiveLayer } from './index';
|
|
21
22
|
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
// 类型定义
|
|
24
|
+
interface Props {
|
|
25
|
+
zIndex?: string | number;
|
|
26
|
+
area?: string;
|
|
27
|
+
id: string;
|
|
28
|
+
am?: 'aa' | 'ab' | 'ac' | 'ad' | 'ae' | 'af' | 'ag' | 'ah' | 'ai' | 'aj' | 'ak' | 'al' | 'am' | 'an' | 'ao' | 'ap' | 'aq' | 'ar' | 'as' | 'at' | (string & {});
|
|
29
|
+
flex?: string;
|
|
30
|
+
dark?: string | number;
|
|
31
|
+
darkClickClose?: boolean;
|
|
32
|
+
wrapStyle?: string;
|
|
25
33
|
}
|
|
26
|
-
const _tasks: any = (window as any)._FEKIT_LAYER_TASKS;
|
|
27
34
|
|
|
28
35
|
// 弹窗入参
|
|
29
|
-
const props
|
|
30
|
-
zIndex:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
id: {
|
|
39
|
-
type: String,
|
|
40
|
-
},
|
|
41
|
-
am: {
|
|
42
|
-
type: String as PropType<'aa' | 'ab' | 'ac' | 'ad' | 'ae' | 'af' | 'ag' | 'ah' | 'ai' | 'aj' | 'ak' | 'al' | 'am' | 'an' | 'ao' | 'ap' | 'aq' | 'ar' | 'as' | 'at'>,
|
|
43
|
-
default: 'as',
|
|
44
|
-
},
|
|
45
|
-
flex: {
|
|
46
|
-
type: String as PropType<'lt' | 'ct' | 'rt' | 'lm' | 'cm' | 'rm' | 'lb' | 'cb' | 'rb'>,
|
|
47
|
-
default: 'cm',
|
|
48
|
-
},
|
|
49
|
-
dark: {
|
|
50
|
-
type: [String, Number],
|
|
51
|
-
default: '',
|
|
52
|
-
},
|
|
53
|
-
darkClickClose: {
|
|
54
|
-
type: Boolean,
|
|
55
|
-
default: true,
|
|
56
|
-
},
|
|
57
|
-
wrapStyle: {
|
|
58
|
-
type: String,
|
|
59
|
-
default: '',
|
|
60
|
-
},
|
|
36
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
37
|
+
zIndex: '',
|
|
38
|
+
area: '#fekit',
|
|
39
|
+
id: '',
|
|
40
|
+
am: 'as',
|
|
41
|
+
flex: 'cm',
|
|
42
|
+
dark: '',
|
|
43
|
+
darkClickClose: true,
|
|
44
|
+
wrapStyle: '',
|
|
61
45
|
});
|
|
62
46
|
|
|
63
47
|
const _area: any = document.querySelector(props.area);
|
|
@@ -73,14 +57,18 @@
|
|
|
73
57
|
view: 0,
|
|
74
58
|
params: {},
|
|
75
59
|
top: 0,
|
|
60
|
+
sw: 0,
|
|
76
61
|
});
|
|
77
62
|
|
|
78
63
|
function disableScroll() {
|
|
79
64
|
state.top = document.documentElement.scrollTop;
|
|
65
|
+
const sw = window.innerWidth - document.documentElement.clientWidth;
|
|
66
|
+
state.sw = sw;
|
|
80
67
|
document.body.style.overflow = 'hidden';
|
|
81
68
|
document.body.style.position = 'fixed';
|
|
82
69
|
document.body.style.top = `-${state.top}px`;
|
|
83
70
|
document.body.style.width = '100%';
|
|
71
|
+
document.body.style.paddingRight = `${sw}px`;
|
|
84
72
|
}
|
|
85
73
|
|
|
86
74
|
function enableScroll() {
|
|
@@ -88,17 +76,30 @@
|
|
|
88
76
|
document.body.style.removeProperty('position');
|
|
89
77
|
document.body.style.removeProperty('top');
|
|
90
78
|
document.body.style.removeProperty('width');
|
|
91
|
-
|
|
79
|
+
document.body.style.removeProperty('padding-right');
|
|
80
|
+
if (state.top) {
|
|
81
|
+
window.scrollTo(0, state.top);
|
|
82
|
+
}
|
|
92
83
|
}
|
|
93
84
|
|
|
94
85
|
watch(
|
|
95
86
|
() => state.view,
|
|
96
87
|
(view: any) => {
|
|
88
|
+
if (_tasks[props.id]) {
|
|
89
|
+
_tasks[props.id].view = view;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const active = getActiveLayer() || [];
|
|
93
|
+
|
|
97
94
|
if (view === 2) {
|
|
98
|
-
|
|
95
|
+
if (active.length === 1) {
|
|
96
|
+
disableScroll();
|
|
97
|
+
}
|
|
99
98
|
}
|
|
100
99
|
if (view === 0) {
|
|
101
|
-
|
|
100
|
+
if (!active.length) {
|
|
101
|
+
enableScroll();
|
|
102
|
+
}
|
|
102
103
|
}
|
|
103
104
|
},
|
|
104
105
|
{ deep: true, immediate: true },
|
|
@@ -152,7 +153,14 @@
|
|
|
152
153
|
// 关闭弹层(没有动画过程)
|
|
153
154
|
const none = (_params: any = {}, then = () => {}) => {
|
|
154
155
|
state.view = 0;
|
|
155
|
-
on.
|
|
156
|
+
on.none.push(then);
|
|
157
|
+
// 立即执行回调,因为没有动画
|
|
158
|
+
on.none.forEach((fun: any) => {
|
|
159
|
+
if (isFunction(fun)) {
|
|
160
|
+
fun();
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
on.none.length = 0;
|
|
156
164
|
};
|
|
157
165
|
|
|
158
166
|
// 点暗层关闭
|
|
@@ -171,6 +179,7 @@
|
|
|
171
179
|
fun();
|
|
172
180
|
}
|
|
173
181
|
});
|
|
182
|
+
on.hide.length = 0; // 清空回调数组
|
|
174
183
|
}
|
|
175
184
|
if (state.view === 2) {
|
|
176
185
|
state.view = 3;
|
|
@@ -179,6 +188,7 @@
|
|
|
179
188
|
fun();
|
|
180
189
|
}
|
|
181
190
|
});
|
|
191
|
+
on.show.length = 0; // 清空回调数组
|
|
182
192
|
}
|
|
183
193
|
};
|
|
184
194
|
|
|
@@ -195,11 +205,14 @@
|
|
|
195
205
|
|
|
196
206
|
// 卸载弹层
|
|
197
207
|
onBeforeUnmount(() => {
|
|
208
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
198
209
|
delete _tasks[id];
|
|
199
210
|
});
|
|
200
211
|
</script>
|
|
201
212
|
|
|
202
213
|
<style lang="scss">
|
|
214
|
+
@use '@neatui/css' as neatui;
|
|
215
|
+
|
|
203
216
|
// 弹层
|
|
204
217
|
.fekit-layer {
|
|
205
218
|
position: fixed;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import Layer from './Layer.vue';
|
|
2
|
+
|
|
3
|
+
export const _tasks: any = {};
|
|
4
|
+
export const _state: any = {};
|
|
5
|
+
export const getActiveLayer = () => {
|
|
6
|
+
return Object.values(_tasks).filter((task: any) => task.view > 0);
|
|
7
|
+
};
|
|
2
8
|
const LayerById = (id: any) => {
|
|
3
|
-
return
|
|
9
|
+
return _tasks[id];
|
|
4
10
|
};
|
|
11
|
+
|
|
5
12
|
export { Layer, LayerById };
|