@neatui/nuxt 1.2.6 → 1.3.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
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@neatui/nuxt",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.3.0",
|
4
4
|
"description": "NeatUI component library for Nuxt 3",
|
5
5
|
"main": "./src/index.ts",
|
6
6
|
"license": "MIT",
|
@@ -37,7 +37,7 @@
|
|
37
37
|
"@fekit/scrollto": "^3.0.3",
|
38
38
|
"@fekit/toast": "^2.7.2",
|
39
39
|
"@fekit/utils": "^4.3.1",
|
40
|
-
"@neatui/css": "^3.
|
40
|
+
"@neatui/css": "^3.15.0",
|
41
41
|
"@rollup/plugin-commonjs": "^26.0.1",
|
42
42
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
43
43
|
"@vue/compiler-sfc": "^3.4.30",
|
@@ -7,9 +7,10 @@
|
|
7
7
|
:data-key="id"
|
8
8
|
:style="`${`${dark}` ? 'background-color: rgba(0, 0, 0, ' + dark + ');' : ''}${zIndex ? 'z-index:' + zIndex + ';' : ''}`"
|
9
9
|
:view="state.view"
|
10
|
-
class="fekit-layer"
|
10
|
+
class="fekit-layer"
|
11
|
+
>
|
11
12
|
<div :ui-flex="`col ${flex}`" :style="wrapStyle" class="fekit-layer-wrap" @animationend="anim" @click="_sys_hide">
|
12
|
-
<slot :param="_tasks[id]
|
13
|
+
<slot :param="_tasks[id]?.params"></slot>
|
13
14
|
</div>
|
14
15
|
</div>
|
15
16
|
</Teleport>
|
@@ -17,15 +18,15 @@
|
|
17
18
|
<script lang="ts" setup>
|
18
19
|
import { onBeforeUnmount, reactive, watch } from 'vue';
|
19
20
|
import { isFunction } from '@fekit/utils';
|
20
|
-
import { _tasks } from './index';
|
21
|
+
import { _tasks, getActiveLayer } from './index';
|
21
22
|
|
22
23
|
// 类型定义
|
23
24
|
interface Props {
|
24
25
|
zIndex?: string | number;
|
25
26
|
area?: string;
|
26
27
|
id: string;
|
27
|
-
am?: 'aa' | 'ab' | 'ac' | 'ad' | 'ae' | 'af' | 'ag' | 'ah' | 'ai' | 'aj' | 'ak' | 'al' | 'am' | 'an' | 'ao' | 'ap' | 'aq' | 'ar' | 'as' | 'at';
|
28
|
-
flex?:
|
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;
|
29
30
|
dark?: string | number;
|
30
31
|
darkClickClose?: boolean;
|
31
32
|
wrapStyle?: string;
|
@@ -43,12 +44,14 @@
|
|
43
44
|
wrapStyle: '',
|
44
45
|
});
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
if (import.meta.client) {
|
48
|
+
const _area: any = document.querySelector(props.area);
|
49
|
+
if (!_area) {
|
50
|
+
const el = document.createElement('div');
|
51
|
+
el.id = (props.area || '#fekit').substring(1);
|
52
|
+
el.style.position = 'absolute';
|
53
|
+
document.body.appendChild(el);
|
54
|
+
}
|
52
55
|
}
|
53
56
|
|
54
57
|
// 状态管理
|
@@ -56,11 +59,13 @@
|
|
56
59
|
view: 0,
|
57
60
|
params: {},
|
58
61
|
top: 0,
|
62
|
+
sw: 0,
|
59
63
|
});
|
60
64
|
|
61
65
|
function disableScroll() {
|
62
66
|
state.top = document.documentElement.scrollTop;
|
63
67
|
const sw = window.innerWidth - document.documentElement.clientWidth;
|
68
|
+
state.sw = sw;
|
64
69
|
document.body.style.overflow = 'hidden';
|
65
70
|
document.body.style.position = 'fixed';
|
66
71
|
document.body.style.top = `-${state.top}px`;
|
@@ -74,17 +79,29 @@
|
|
74
79
|
document.body.style.removeProperty('top');
|
75
80
|
document.body.style.removeProperty('width');
|
76
81
|
document.body.style.removeProperty('padding-right');
|
77
|
-
|
82
|
+
if (state.top) {
|
83
|
+
window.scrollTo(0, state.top);
|
84
|
+
}
|
78
85
|
}
|
79
86
|
|
80
87
|
watch(
|
81
88
|
() => state.view,
|
82
89
|
(view: any) => {
|
90
|
+
if (_tasks[props.id]) {
|
91
|
+
_tasks[props.id].view = view;
|
92
|
+
}
|
93
|
+
|
94
|
+
const active = getActiveLayer() || [];
|
95
|
+
|
83
96
|
if (view === 2) {
|
84
|
-
|
97
|
+
if (active.length === 1) {
|
98
|
+
disableScroll();
|
99
|
+
}
|
85
100
|
}
|
86
101
|
if (view === 0) {
|
87
|
-
|
102
|
+
if (!active.length) {
|
103
|
+
enableScroll();
|
104
|
+
}
|
88
105
|
}
|
89
106
|
},
|
90
107
|
{ deep: true, immediate: true },
|
@@ -138,7 +155,14 @@
|
|
138
155
|
// 关闭弹层(没有动画过程)
|
139
156
|
const none = (_params: any = {}, then = () => {}) => {
|
140
157
|
state.view = 0;
|
141
|
-
on.
|
158
|
+
on.none.push(then);
|
159
|
+
// 立即执行回调,因为没有动画
|
160
|
+
on.none.forEach((fun: any) => {
|
161
|
+
if (isFunction(fun)) {
|
162
|
+
fun();
|
163
|
+
}
|
164
|
+
});
|
165
|
+
on.none.length = 0;
|
142
166
|
};
|
143
167
|
|
144
168
|
// 点暗层关闭
|
@@ -157,6 +181,7 @@
|
|
157
181
|
fun();
|
158
182
|
}
|
159
183
|
});
|
184
|
+
on.hide.length = 0; // 清空回调数组
|
160
185
|
}
|
161
186
|
if (state.view === 2) {
|
162
187
|
state.view = 3;
|
@@ -165,16 +190,19 @@
|
|
165
190
|
fun();
|
166
191
|
}
|
167
192
|
});
|
193
|
+
on.show.length = 0; // 清空回调数组
|
168
194
|
}
|
169
195
|
};
|
170
196
|
|
171
197
|
// 注册弹层
|
172
198
|
const { id = '' }: any = { ...props };
|
173
199
|
if (_tasks[id]) {
|
200
|
+
console.error('Layer 有重复 id', id);
|
174
201
|
}
|
175
202
|
if (id) {
|
176
203
|
_tasks[id] = { init, show, hide, open, none };
|
177
204
|
} else {
|
205
|
+
console.error('Layer 必须填写全局统一的 id');
|
178
206
|
}
|
179
207
|
|
180
208
|
// 卸载弹层
|
@@ -219,10 +247,10 @@
|
|
219
247
|
width: 2em;
|
220
248
|
height: 2em;
|
221
249
|
|
222
|
-
color: var(--co-
|
250
|
+
color: var(--co-read);
|
223
251
|
bottom: auto;
|
224
|
-
top:
|
225
|
-
right:
|
252
|
+
top: 0.5em;
|
253
|
+
right: 0.5em;
|
226
254
|
left: auto;
|
227
255
|
box-shadow: none;
|
228
256
|
|
@@ -232,7 +260,8 @@
|
|
232
260
|
transform: scale(0.9);
|
233
261
|
transition: all 0.2s;
|
234
262
|
border-radius: 50%;
|
235
|
-
background:
|
263
|
+
background:
|
264
|
+
linear-gradient(45deg, transparent 44%, currentColor 45%, currentColor 55%, transparent 56%) no-repeat center / 50% 50%,
|
236
265
|
linear-gradient(-45deg, transparent 44%, currentColor 45%, currentColor 55%, transparent 56%) no-repeat center / 50% 50%;
|
237
266
|
|
238
267
|
&:active {
|
@@ -249,18 +278,4 @@
|
|
249
278
|
}
|
250
279
|
}
|
251
280
|
}
|
252
|
-
|
253
|
-
@include neatui.mob {
|
254
|
-
.fekit-layer-close {
|
255
|
-
top: 1.5em;
|
256
|
-
right: 1.5em;
|
257
|
-
|
258
|
-
color: var(--co-fore);
|
259
|
-
top: auto;
|
260
|
-
right: auto;
|
261
|
-
left: 50%;
|
262
|
-
bottom: -2.5rem;
|
263
|
-
box-shadow: 0 0 0 2px currentColor;
|
264
|
-
}
|
265
|
-
}
|
266
281
|
</style>
|
@@ -1,5 +1,12 @@
|
|
1
|
+
import Layer from './Layer.vue';
|
2
|
+
|
1
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
9
|
return _tasks[id];
|
4
10
|
};
|
5
|
-
|
11
|
+
|
12
|
+
export { Layer, LayerById };
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import Layer from './LayerView/
|
2
|
-
import LayerById from './LayerView/index';
|
1
|
+
import { Layer, LayerById } from './LayerView/index';
|
3
2
|
import Icon from './Icon.vue';
|
4
3
|
import IFollowView from './IFollowView.vue';
|
5
4
|
import IPickerView from './IPickerView.vue';
|