y-design-ssr 0.2.6 → 0.2.7
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/README.md +1 -1
- package/libs/button/index.css +1 -579
- package/libs/button/index.mjs +66 -111
- package/libs/button/index.umd.js +2 -203
- package/libs/cell/index.css +1 -1077
- package/libs/cell/index.mjs +105 -168
- package/libs/cell/index.umd.js +2 -301
- package/libs/checkbox/index.css +1 -1053
- package/libs/checkbox/index.mjs +128 -243
- package/libs/checkbox/index.umd.js +2 -370
- package/libs/checkboxGroup/index.css +1 -422
- package/libs/checkboxGroup/index.mjs +88 -174
- package/libs/checkboxGroup/index.umd.js +2 -266
- package/libs/col/index.css +1 -615
- package/libs/col/index.mjs +82 -247
- package/libs/col/index.umd.js +2 -306
- package/libs/countdown/index.css +1 -417
- package/libs/countdown/index.mjs +72 -180
- package/libs/countdown/index.umd.js +2 -232
- package/libs/dialog/index.css +1 -1405
- package/libs/dialog/index.mjs +477 -647
- package/libs/dialog/index.umd.js +2 -1129
- package/libs/empty/index.css +1 -457
- package/libs/empty/index.mjs +45 -92
- package/libs/empty/index.umd.js +2 -140
- package/libs/form/index.css +1 -477
- package/libs/form/index.mjs +127 -227
- package/libs/form/index.umd.js +2 -320
- package/libs/formItem/index.css +1 -477
- package/libs/formItem/index.mjs +127 -277
- package/libs/formItem/index.umd.js +2 -373
- package/libs/icon/index.css +1 -982
- package/libs/icon/index.mjs +59 -108
- package/libs/icon/index.umd.js +2 -187
- package/libs/index.css +1 -2902
- package/libs/index.mjs +2348 -3789
- package/libs/index.umd.js +2 -5509
- package/libs/input/index.css +1 -483
- package/libs/input/index.mjs +93 -184
- package/libs/input/index.umd.js +2 -275
- package/libs/layout/index.css +1 -684
- package/libs/layout/index.mjs +130 -230
- package/libs/layout/index.umd.js +2 -318
- package/libs/list/index.css +1 -440
- package/libs/list/index.mjs +208 -389
- package/libs/list/index.umd.js +2 -572
- package/libs/loading/index.css +1 -548
- package/libs/loading/index.mjs +119 -197
- package/libs/loading/index.umd.js +2 -322
- package/libs/locale/index.mjs +28 -0
- package/libs/locale/index.umd.js +1 -0
- package/libs/locale/package.json +6 -0
- package/libs/mask/index.css +1 -426
- package/libs/mask/index.mjs +71 -132
- package/libs/mask/index.umd.js +2 -202
- package/libs/popup/index.css +1 -465
- package/libs/popup/index.mjs +135 -211
- package/libs/popup/index.umd.js +2 -359
- package/libs/progress/index.css +1 -488
- package/libs/progress/index.mjs +129 -201
- package/libs/progress/index.umd.js +2 -323
- package/libs/pullrefresh/index.css +1 -441
- package/libs/pullrefresh/index.mjs +112 -242
- package/libs/pullrefresh/index.umd.js +2 -303
- package/libs/row/index.css +1 -485
- package/libs/row/index.mjs +90 -182
- package/libs/row/index.umd.js +2 -238
- package/libs/slider/index.css +1 -558
- package/libs/slider/index.mjs +161 -357
- package/libs/slider/index.umd.js +2 -454
- package/libs/stepper/index.css +1 -489
- package/libs/stepper/index.mjs +102 -182
- package/libs/stepper/index.umd.js +2 -270
- package/libs/style/index.css +1 -0
- package/libs/style/index.mjs +1 -0
- package/libs/style/index.umd.js +2 -0
- package/libs/style/package.json +6 -0
- package/libs/swipe/index.css +1 -506
- package/libs/swipe/index.mjs +260 -543
- package/libs/swipe/index.umd.js +2 -704
- package/libs/swipeItem/index.css +1 -424
- package/libs/swipeItem/index.mjs +53 -112
- package/libs/swipeItem/index.umd.js +2 -155
- package/libs/switch/index.css +1 -472
- package/libs/switch/index.mjs +63 -122
- package/libs/switch/index.umd.js +2 -201
- package/libs/tab/index.mjs +69 -132
- package/libs/tab/index.umd.js +1 -191
- package/libs/tabs/index.css +1 -514
- package/libs/tabs/index.mjs +411 -752
- package/libs/tabs/index.umd.js +2 -1021
- package/libs/toast/index.css +1 -1050
- package/libs/toast/index.mjs +115 -184
- package/libs/toast/index.umd.js +2 -307
- package/libs/tooltip/index.css +1 -514
- package/libs/tooltip/index.mjs +156 -294
- package/libs/tooltip/index.umd.js +2 -417
- package/libs/utils/index.mjs +76 -0
- package/libs/utils/index.umd.js +1 -0
- package/libs/utils/package.json +6 -0
- package/package.json +1 -4
package/libs/list/index.mjs
CHANGED
|
@@ -1,46 +1,11 @@
|
|
|
1
|
-
import { ref, reactive, defineComponent, createVNode, computed, onMounted, onUpdated, nextTick, onUnmounted, createTextVNode } from "vue";
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (!mods) {
|
|
10
|
-
return "";
|
|
11
|
-
}
|
|
12
|
-
if (typeof mods === "string") {
|
|
13
|
-
return ` ${el}--${mods}`;
|
|
14
|
-
}
|
|
15
|
-
if (Array.isArray(mods)) {
|
|
16
|
-
return mods.reduce((acc, cur) => acc + getMods(el, cur), "");
|
|
17
|
-
}
|
|
18
|
-
return Object.keys(mods).reduce(
|
|
19
|
-
(acc, cur) => acc + (mods[cur] ? getMods(el, cur) : ""),
|
|
20
|
-
""
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
const createBEM = (block) => {
|
|
24
|
-
return (el, mods) => {
|
|
25
|
-
let _el = el;
|
|
26
|
-
let _mods = mods;
|
|
27
|
-
if (_el && typeof _el !== "string") {
|
|
28
|
-
_mods = _el;
|
|
29
|
-
_el = "";
|
|
30
|
-
}
|
|
31
|
-
_el = _el ? `${block}__${_el}` : block;
|
|
32
|
-
return `${_el}${getMods(_el, _mods)}`;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
const createGlobalBem = () => {
|
|
36
|
-
return (el, mods) => {
|
|
37
|
-
if (!mods) {
|
|
38
|
-
return `y-${el}`;
|
|
39
|
-
}
|
|
40
|
-
return `${getMods(`y-${el}`, mods)}`;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
const defaultLang = {
|
|
1
|
+
import { ref as d, reactive as K, defineComponent as P, createVNode as i, computed as S, onMounted as Q, onUpdated as X, nextTick as Z, onUnmounted as ee, createTextVNode as te } from "vue";
|
|
2
|
+
const ne = (e) => (n) => Object.prototype.toString.call(n) === `[object ${e}]`, ae = ne("Number"), L = (e, n) => n ? typeof n == "string" ? ` ${e}--${n}` : Array.isArray(n) ? n.reduce((c, r) => c + L(e, r), "") : Object.keys(n).reduce(
|
|
3
|
+
(c, r) => c + (n[r] ? L(e, r) : ""),
|
|
4
|
+
""
|
|
5
|
+
) : "", le = (e) => (n, c) => {
|
|
6
|
+
let r = n, f = c;
|
|
7
|
+
return r && typeof r != "string" && (f = r, r = ""), r = r ? `${e}__${r}` : e, `${r}${L(r, f)}`;
|
|
8
|
+
}, re = () => (e, n) => n ? `${L(`y-${e}`, n)}` : `y-${e}`, ie = {
|
|
44
9
|
"pull-refresh": {
|
|
45
10
|
pulling: "下拉刷新...",
|
|
46
11
|
loosing: "释放刷新...",
|
|
@@ -52,22 +17,15 @@ const defaultLang = {
|
|
|
52
17
|
validateMessage: "请输入正确内容"
|
|
53
18
|
}
|
|
54
19
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"zh-CN":
|
|
20
|
+
d("zh-CN");
|
|
21
|
+
K({
|
|
22
|
+
"zh-CN": ie
|
|
58
23
|
});
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
return [
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (isNaN(Number(val)) && typeof val === "string") {
|
|
65
|
-
return val;
|
|
66
|
-
}
|
|
67
|
-
return `${val}px`;
|
|
68
|
-
};
|
|
69
|
-
const parseFlexDirection = (location) => {
|
|
70
|
-
switch (location) {
|
|
24
|
+
const G = (e) => {
|
|
25
|
+
const n = `y-${e}`;
|
|
26
|
+
return [n, le(n), re()];
|
|
27
|
+
}, H = (e) => isNaN(Number(e)) && typeof e == "string" ? e : `${e}px`, oe = (e) => {
|
|
28
|
+
switch (e) {
|
|
71
29
|
case "top":
|
|
72
30
|
return "column-reverse";
|
|
73
31
|
case "bottom":
|
|
@@ -79,9 +37,7 @@ const parseFlexDirection = (location) => {
|
|
|
79
37
|
default:
|
|
80
38
|
return "column";
|
|
81
39
|
}
|
|
82
|
-
}
|
|
83
|
-
const [name, bem$1] = createNamespace("loading");
|
|
84
|
-
const _props = {
|
|
40
|
+
}, [ue, R] = G("loading"), ce = {
|
|
85
41
|
// Loading icon 的颜色
|
|
86
42
|
color: {
|
|
87
43
|
type: String,
|
|
@@ -140,80 +96,76 @@ const _props = {
|
|
|
140
96
|
type: String,
|
|
141
97
|
default: "relative"
|
|
142
98
|
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
slots
|
|
99
|
+
}, se = /* @__PURE__ */ P({
|
|
100
|
+
name: ue,
|
|
101
|
+
props: ce,
|
|
102
|
+
setup(e, {
|
|
103
|
+
slots: n
|
|
149
104
|
}) {
|
|
150
105
|
return () => {
|
|
151
|
-
var
|
|
106
|
+
var w, B;
|
|
152
107
|
const {
|
|
153
|
-
position,
|
|
154
|
-
textLocation,
|
|
155
|
-
bgColor,
|
|
156
|
-
bgBorderRadius,
|
|
157
|
-
size,
|
|
158
|
-
padding,
|
|
159
|
-
color,
|
|
160
|
-
thick,
|
|
161
|
-
direction,
|
|
162
|
-
text,
|
|
163
|
-
textColor,
|
|
164
|
-
textSize
|
|
165
|
-
} =
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
[position]: position !== "relative"
|
|
108
|
+
position: c,
|
|
109
|
+
textLocation: r,
|
|
110
|
+
bgColor: f,
|
|
111
|
+
bgBorderRadius: m,
|
|
112
|
+
size: o,
|
|
113
|
+
padding: x,
|
|
114
|
+
color: v,
|
|
115
|
+
thick: C,
|
|
116
|
+
direction: I,
|
|
117
|
+
text: s,
|
|
118
|
+
textColor: p,
|
|
119
|
+
textSize: l
|
|
120
|
+
} = e, k = ((w = n.default) == null ? void 0 : w.call(n)) || s;
|
|
121
|
+
return i("div", {
|
|
122
|
+
class: R({
|
|
123
|
+
[c]: c !== "relative"
|
|
170
124
|
})
|
|
171
|
-
}, [
|
|
172
|
-
|
|
173
|
-
[
|
|
125
|
+
}, [i("div", {
|
|
126
|
+
class: R("bg", {
|
|
127
|
+
[c]: c !== "relative"
|
|
174
128
|
}),
|
|
175
|
-
|
|
176
|
-
flexDirection:
|
|
177
|
-
backgroundColor:
|
|
178
|
-
borderRadius:
|
|
179
|
-
padding:
|
|
129
|
+
style: {
|
|
130
|
+
flexDirection: oe(r),
|
|
131
|
+
backgroundColor: f,
|
|
132
|
+
borderRadius: H(m),
|
|
133
|
+
padding: H(x)
|
|
180
134
|
}
|
|
181
|
-
}, [
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
width:
|
|
185
|
-
height:
|
|
135
|
+
}, [i("span", {
|
|
136
|
+
class: R("icon-wrapper"),
|
|
137
|
+
style: {
|
|
138
|
+
width: H(o),
|
|
139
|
+
height: H(o)
|
|
186
140
|
}
|
|
187
|
-
}, [((
|
|
188
|
-
|
|
189
|
-
[
|
|
141
|
+
}, [((B = n.icon) == null ? void 0 : B.call(n)) || i("svg", {
|
|
142
|
+
class: R("icon", {
|
|
143
|
+
[I]: I
|
|
190
144
|
}),
|
|
191
|
-
|
|
192
|
-
}, [
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
stroke:
|
|
196
|
-
strokeWidth:
|
|
145
|
+
viewBox: "25 25 50 50"
|
|
146
|
+
}, [i("circle", {
|
|
147
|
+
class: R("icon-circle"),
|
|
148
|
+
style: {
|
|
149
|
+
stroke: v,
|
|
150
|
+
strokeWidth: H(C)
|
|
197
151
|
},
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}, null)])]),
|
|
203
|
-
|
|
204
|
-
[
|
|
152
|
+
cx: "50",
|
|
153
|
+
cy: "50",
|
|
154
|
+
r: "20",
|
|
155
|
+
fill: "none"
|
|
156
|
+
}, null)])]), k && i("span", {
|
|
157
|
+
class: R("text", {
|
|
158
|
+
[r]: r
|
|
205
159
|
}),
|
|
206
|
-
|
|
207
|
-
color:
|
|
208
|
-
fontSize:
|
|
160
|
+
style: {
|
|
161
|
+
color: p,
|
|
162
|
+
fontSize: H(l)
|
|
209
163
|
}
|
|
210
|
-
}, [
|
|
164
|
+
}, [k])])]);
|
|
211
165
|
};
|
|
212
166
|
}
|
|
213
|
-
})
|
|
214
|
-
|
|
215
|
-
const List = /* @__PURE__ */ defineComponent({
|
|
216
|
-
name: cname,
|
|
167
|
+
}), [de, h] = G("list"), V = /* @__PURE__ */ P({
|
|
168
|
+
name: de,
|
|
217
169
|
props: {
|
|
218
170
|
// 加载中 文案
|
|
219
171
|
loadingText: {
|
|
@@ -248,7 +200,7 @@ const List = /* @__PURE__ */ defineComponent({
|
|
|
248
200
|
// 是否在初始化时立即执行滚动位置检查
|
|
249
201
|
immediateCheck: {
|
|
250
202
|
type: Boolean,
|
|
251
|
-
default:
|
|
203
|
+
default: !0
|
|
252
204
|
},
|
|
253
205
|
// 滚动条与底部距离小于多少时触发加载
|
|
254
206
|
loadOffset: {
|
|
@@ -258,7 +210,7 @@ const List = /* @__PURE__ */ defineComponent({
|
|
|
258
210
|
// 是否使用虚拟列表
|
|
259
211
|
virtual: {
|
|
260
212
|
type: Boolean,
|
|
261
|
-
default:
|
|
213
|
+
default: !1
|
|
262
214
|
},
|
|
263
215
|
// 缓冲区比例
|
|
264
216
|
bufferScale: {
|
|
@@ -273,294 +225,161 @@ const List = /* @__PURE__ */ defineComponent({
|
|
|
273
225
|
// 是否是不定高度子项
|
|
274
226
|
dynamicItemHeight: {
|
|
275
227
|
type: Boolean,
|
|
276
|
-
default:
|
|
228
|
+
default: !1
|
|
277
229
|
}
|
|
278
230
|
},
|
|
279
231
|
emits: ["load"],
|
|
280
|
-
setup(
|
|
281
|
-
slots,
|
|
282
|
-
emit,
|
|
283
|
-
expose
|
|
232
|
+
setup(e, {
|
|
233
|
+
slots: n,
|
|
234
|
+
emit: c,
|
|
235
|
+
expose: r
|
|
284
236
|
}) {
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const contentRef = ref();
|
|
290
|
-
const scrollBarRef = ref();
|
|
291
|
-
const itemsRef = ref([]);
|
|
292
|
-
const startIndexRef = ref(0);
|
|
293
|
-
const endIndexRef = ref(0);
|
|
294
|
-
const positionsRef = ref([]);
|
|
295
|
-
const listContainerRef = computed(() => {
|
|
296
|
-
return isNumber(props.height) ? `${props.height}px` : props.height;
|
|
297
|
-
});
|
|
298
|
-
const listHeightRef = computed(() => {
|
|
299
|
-
const listHeight = positionsRef.value.length ? positionsRef.value[positionsRef.value.length - 1].bottom : 0;
|
|
300
|
-
return listHeight;
|
|
301
|
-
});
|
|
302
|
-
const realRenderListRef = computed(() => {
|
|
303
|
-
if (props.virtual) {
|
|
304
|
-
const start = startIndexRef.value - aboveCountRef.value;
|
|
305
|
-
const end = endIndexRef.value + belowCountRef.value;
|
|
306
|
-
return _dataSourceRef.value.slice(start, end);
|
|
307
|
-
}
|
|
308
|
-
return _dataSourceRef.value;
|
|
309
|
-
});
|
|
310
|
-
const aboveCountRef = computed(() => {
|
|
311
|
-
const above = Math.min(startIndexRef.value, props.bufferScale * visibleCountRef.value);
|
|
312
|
-
return above;
|
|
313
|
-
});
|
|
314
|
-
const belowCountRef = computed(() => {
|
|
315
|
-
const below = Math.min(props.dataSource.length - endIndexRef.value, props.bufferScale * visibleCountRef.value);
|
|
316
|
-
return below;
|
|
317
|
-
});
|
|
318
|
-
const visibleCountRef = computed(() => {
|
|
319
|
-
const count = Math.ceil(visibleHeightRef.value / parseInt(String(props.itemHeight)));
|
|
320
|
-
return count;
|
|
321
|
-
});
|
|
322
|
-
const _dataSourceRef = computed(() => {
|
|
323
|
-
return props.dataSource.map((item, index) => {
|
|
324
|
-
item[props.keyName] = index;
|
|
325
|
-
return item;
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
const getScrollTop = () => {
|
|
329
|
-
if (pageModeRef.value) {
|
|
330
|
-
return document.documentElement.scrollTop || document.body.scrollTop;
|
|
331
|
-
}
|
|
332
|
-
return listRef.value.scrollTop;
|
|
333
|
-
};
|
|
334
|
-
const getScrollHeight = () => {
|
|
335
|
-
if (pageModeRef.value) {
|
|
336
|
-
return document.documentElement.scrollHeight;
|
|
237
|
+
const f = d(0), m = d(!1), o = d("normal"), x = d(), v = d(), C = d(), I = d([]), s = d(0), p = d(0), l = d([]), k = S(() => ae(e.height) ? `${e.height}px` : e.height), w = S(() => l.value.length ? l.value[l.value.length - 1].bottom : 0), B = S(() => {
|
|
238
|
+
if (e.virtual) {
|
|
239
|
+
const t = s.value - M.value, a = p.value + A.value;
|
|
240
|
+
return _.value.slice(t, a);
|
|
337
241
|
}
|
|
338
|
-
return
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
break;
|
|
360
|
-
default:
|
|
361
|
-
stateRef.value = "normal";
|
|
362
|
-
if (props.virtual) {
|
|
363
|
-
updatePositions();
|
|
364
|
-
if (props.dataSource.length < visibleCountRef.value + belowCountRef.value) {
|
|
365
|
-
loadData();
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
});
|
|
370
|
-
};
|
|
371
|
-
const checkIsScrollToBottom = () => {
|
|
372
|
-
if (stateRef.value !== "normal")
|
|
373
|
-
return;
|
|
374
|
-
if (getScrollHeight() - getScrollTop() - visibleHeightRef.value <= props.loadOffset) {
|
|
375
|
-
loadData();
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
const initPositions = () => {
|
|
379
|
-
positionsRef.value = _dataSourceRef.value.map((_, index) => {
|
|
380
|
-
const height = parseInt(String(props.itemHeight));
|
|
242
|
+
return _.value;
|
|
243
|
+
}), M = S(() => Math.min(s.value, e.bufferScale * $.value)), A = S(() => Math.min(e.dataSource.length - p.value, e.bufferScale * $.value)), $ = S(() => Math.ceil(f.value / parseInt(String(e.itemHeight)))), _ = S(() => e.dataSource.map((t, a) => (t[e.keyName] = a, t))), j = () => m.value ? document.documentElement.scrollTop || document.body.scrollTop : x.value.scrollTop, W = () => m.value ? document.documentElement.scrollHeight : x.value.scrollHeight, E = () => {
|
|
244
|
+
o.value !== "loading" && (o.value = "loading", c("load", (t) => {
|
|
245
|
+
if (o.value === "loading")
|
|
246
|
+
switch (t) {
|
|
247
|
+
case "error":
|
|
248
|
+
o.value = "error";
|
|
249
|
+
break;
|
|
250
|
+
case "finished":
|
|
251
|
+
o.value = "finished", e.virtual && D(), e.virtual && e.dynamicItemHeight && U();
|
|
252
|
+
break;
|
|
253
|
+
default:
|
|
254
|
+
o.value = "normal", e.virtual && (U(), e.dataSource.length < $.value + A.value && E());
|
|
255
|
+
}
|
|
256
|
+
}));
|
|
257
|
+
}, z = () => {
|
|
258
|
+
o.value === "normal" && W() - j() - f.value <= e.loadOffset && E();
|
|
259
|
+
}, D = () => {
|
|
260
|
+
l.value = _.value.map((t, a) => {
|
|
261
|
+
const u = parseInt(String(e.itemHeight));
|
|
381
262
|
return {
|
|
382
|
-
index,
|
|
383
|
-
height,
|
|
384
|
-
top:
|
|
385
|
-
bottom: (
|
|
263
|
+
index: a,
|
|
264
|
+
height: u,
|
|
265
|
+
top: a * u,
|
|
266
|
+
bottom: (a + 1) * u
|
|
386
267
|
};
|
|
387
268
|
});
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
let tempIndex = -1;
|
|
400
|
-
while (start <= end) {
|
|
401
|
-
const midIndex = Math.floor((start + end) / 2);
|
|
402
|
-
const midValue = list[midIndex].bottom;
|
|
403
|
-
if (midValue === value) {
|
|
404
|
-
return midIndex + 1;
|
|
405
|
-
} else if (midValue < value) {
|
|
406
|
-
start = midIndex + 1;
|
|
407
|
-
} else if (midValue > value) {
|
|
408
|
-
if (tempIndex === -1 || tempIndex > midIndex) {
|
|
409
|
-
tempIndex = midIndex;
|
|
410
|
-
}
|
|
411
|
-
end = midIndex - 1;
|
|
412
|
-
}
|
|
269
|
+
}, U = () => {
|
|
270
|
+
D();
|
|
271
|
+
for (let t = 1; t < l.value.length; t++)
|
|
272
|
+
l.value[t].top = l.value[t - 1].bottom, l.value[t].bottom = l.value[t].top + l.value[t].height;
|
|
273
|
+
}, Y = (t, a) => {
|
|
274
|
+
let u = 0, N = t.length - 1, g = -1;
|
|
275
|
+
for (; u <= N; ) {
|
|
276
|
+
const y = Math.floor((u + N) / 2), b = t[y].bottom;
|
|
277
|
+
if (b === a)
|
|
278
|
+
return y + 1;
|
|
279
|
+
b < a ? u = y + 1 : b > a && ((g === -1 || g > y) && (g = y), N = y - 1);
|
|
413
280
|
}
|
|
414
|
-
return
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
const handleScroll = () => {
|
|
420
|
-
checkIsScrollToBottom();
|
|
421
|
-
if (props.virtual) {
|
|
422
|
-
const scrollTop = getScrollTop();
|
|
423
|
-
updateVisibleData(scrollTop);
|
|
281
|
+
return g;
|
|
282
|
+
}, q = (t) => Y(l.value, t), O = () => {
|
|
283
|
+
if (z(), e.virtual) {
|
|
284
|
+
const t = j();
|
|
285
|
+
F(t);
|
|
424
286
|
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
if (!contentRef.value)
|
|
287
|
+
}, F = (t) => {
|
|
288
|
+
if (!v.value)
|
|
428
289
|
return;
|
|
429
|
-
const
|
|
430
|
-
if (
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
contentRef.value.style.transform = `translate3d(0, ${startOffset}px, 0)`;
|
|
290
|
+
const a = t || 0;
|
|
291
|
+
if (e.dynamicItemHeight) {
|
|
292
|
+
s.value = q(a), p.value = s.value + $.value;
|
|
293
|
+
const u = l.value[s.value - M.value].top ? l.value[s.value - M.value].top : 0;
|
|
294
|
+
v.value.style.transform = `translate3d(0, ${u}px, 0)`;
|
|
435
295
|
} else {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
contentRef.value.style.transform = `translate3d(0, ${startOffset}px, 0)`;
|
|
296
|
+
s.value = Math.floor(a / parseInt(String(e.itemHeight))), p.value = s.value + $.value;
|
|
297
|
+
const u = s.value * parseInt(String(e.itemHeight)) - M.value * parseInt(String(e.itemHeight));
|
|
298
|
+
v.value.style.transform = `translate3d(0, ${u}px, 0)`;
|
|
440
299
|
}
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
if (!contentRef.value || !scrollBarRef.value)
|
|
444
|
-
return;
|
|
445
|
-
const nodes = contentRef.value.children;
|
|
446
|
-
if (!(nodes && nodes.length > 0))
|
|
300
|
+
}, J = () => {
|
|
301
|
+
if (!v.value || !C.value)
|
|
447
302
|
return;
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
const {
|
|
452
|
-
height
|
|
453
|
-
} =
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
positionsRef.value[index].bottom -= dValue;
|
|
459
|
-
positionsRef.value[index].height = height;
|
|
460
|
-
for (let k = index + 1; k < positionsRef.value.length; k++) {
|
|
461
|
-
positionsRef.value[k].top = positionsRef.value[k - 1].bottom;
|
|
462
|
-
positionsRef.value[k].bottom -= dValue;
|
|
463
|
-
}
|
|
303
|
+
const t = v.value.children;
|
|
304
|
+
t && t.length > 0 && [...t].forEach((a) => {
|
|
305
|
+
if (a instanceof HTMLDivElement) {
|
|
306
|
+
const u = a.getBoundingClientRect(), {
|
|
307
|
+
height: N
|
|
308
|
+
} = u, g = Number(a.dataset.index), b = l.value[g].height - N;
|
|
309
|
+
if (b) {
|
|
310
|
+
l.value[g].bottom -= b, l.value[g].height = N;
|
|
311
|
+
for (let T = g + 1; T < l.value.length; T++)
|
|
312
|
+
l.value[T].top = l.value[T - 1].bottom, l.value[T].bottom -= b;
|
|
464
313
|
}
|
|
465
314
|
}
|
|
466
315
|
});
|
|
467
316
|
};
|
|
468
|
-
|
|
469
|
-
...
|
|
470
|
-
checkIsScrollToBottom,
|
|
471
|
-
loadData
|
|
472
|
-
})
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
pageModeRef.value = true;
|
|
479
|
-
visibleHeightRef.value = document.documentElement.clientHeight;
|
|
480
|
-
document.addEventListener("scroll", handleScroll);
|
|
481
|
-
}
|
|
482
|
-
if (props.virtual) {
|
|
483
|
-
initPositions();
|
|
484
|
-
updateVisibleData();
|
|
485
|
-
}
|
|
486
|
-
if (props.immediateCheck) {
|
|
487
|
-
checkIsScrollToBottom();
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
onUpdated(async () => {
|
|
491
|
-
var _a, _b;
|
|
492
|
-
if (props.virtual && props.dynamicItemHeight) {
|
|
493
|
-
await nextTick();
|
|
494
|
-
if (!((_b = (_a = contentRef.value) == null ? void 0 : _a.children) == null ? void 0 : _b.length)) {
|
|
317
|
+
return r({
|
|
318
|
+
...e,
|
|
319
|
+
checkIsScrollToBottom: z,
|
|
320
|
+
loadData: E
|
|
321
|
+
}), Q(() => {
|
|
322
|
+
e.height !== "auto" ? (m.value = !1, f.value = x.value.clientHeight) : e.height === "auto" && (m.value = !0, f.value = document.documentElement.clientHeight, document.addEventListener("scroll", O)), e.virtual && (D(), F()), e.immediateCheck && z();
|
|
323
|
+
}), X(async () => {
|
|
324
|
+
var t, a;
|
|
325
|
+
if (e.virtual && e.dynamicItemHeight) {
|
|
326
|
+
if (await Z(), !((a = (t = v.value) == null ? void 0 : t.children) != null && a.length))
|
|
495
327
|
return;
|
|
496
|
-
|
|
497
|
-
updateItemSize();
|
|
328
|
+
J();
|
|
498
329
|
}
|
|
499
|
-
})
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
330
|
+
}), ee(() => {
|
|
331
|
+
m.value && document.removeEventListener("scroll", O);
|
|
332
|
+
}), () => i("div", {
|
|
333
|
+
ref: x,
|
|
334
|
+
class: `${h()} ${e.virtual ? h({
|
|
335
|
+
virtual: !0
|
|
336
|
+
}) : ""}`,
|
|
337
|
+
style: {
|
|
338
|
+
height: k.value
|
|
339
|
+
},
|
|
340
|
+
onScroll: O
|
|
341
|
+
}, [e.virtual && i("div", {
|
|
342
|
+
ref: C,
|
|
343
|
+
class: h("phantom"),
|
|
344
|
+
style: {
|
|
345
|
+
height: `${w.value}px`
|
|
503
346
|
}
|
|
504
|
-
})
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
"
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
})]), stateRef.value === "loading" && createVNode("div", {
|
|
534
|
-
"class": bem({
|
|
535
|
-
loading: true
|
|
536
|
-
})
|
|
537
|
-
}, [slots.loading ? slots.loading() : createVNode(YLoading, {
|
|
538
|
-
"text-location": "right"
|
|
539
|
-
}, {
|
|
540
|
-
default: () => [createTextVNode("加载中...")]
|
|
541
|
-
})]), stateRef.value === "finished" && createVNode("div", {
|
|
542
|
-
"class": bem({
|
|
543
|
-
finished: true
|
|
544
|
-
})
|
|
545
|
-
}, [props.finishedText]), stateRef.value === "error" && createVNode("div", {
|
|
546
|
-
"class": bem("error"),
|
|
547
|
-
"role": "presentation",
|
|
548
|
-
"onClick": loadData
|
|
549
|
-
}, [props.errorText])]);
|
|
550
|
-
};
|
|
347
|
+
}, null), i("div", {
|
|
348
|
+
ref: v,
|
|
349
|
+
class: h("content")
|
|
350
|
+
}, [B.value.map((t) => {
|
|
351
|
+
var a;
|
|
352
|
+
return i("div", {
|
|
353
|
+
ref: I,
|
|
354
|
+
class: h("item"),
|
|
355
|
+
"data-index": t._index
|
|
356
|
+
}, [(a = n.default) == null ? void 0 : a.call(n, {
|
|
357
|
+
item: t
|
|
358
|
+
})]);
|
|
359
|
+
})]), o.value === "loading" && i("div", {
|
|
360
|
+
class: h({
|
|
361
|
+
loading: !0
|
|
362
|
+
})
|
|
363
|
+
}, [n.loading ? n.loading() : i(se, {
|
|
364
|
+
"text-location": "right"
|
|
365
|
+
}, {
|
|
366
|
+
default: () => [te("加载中...")]
|
|
367
|
+
})]), o.value === "finished" && i("div", {
|
|
368
|
+
class: h({
|
|
369
|
+
finished: !0
|
|
370
|
+
})
|
|
371
|
+
}, [e.finishedText]), o.value === "error" && i("div", {
|
|
372
|
+
class: h("error"),
|
|
373
|
+
role: "presentation",
|
|
374
|
+
onClick: E
|
|
375
|
+
}, [e.errorText])]);
|
|
551
376
|
}
|
|
552
377
|
});
|
|
553
|
-
|
|
554
|
-
const
|
|
555
|
-
|
|
556
|
-
const animation = "";
|
|
557
|
-
const theme = "";
|
|
558
|
-
const style = "";
|
|
559
|
-
List.install = (Vue) => {
|
|
560
|
-
const { name: name2 } = List;
|
|
561
|
-
Vue.component(name2, List);
|
|
378
|
+
V.install = (e) => {
|
|
379
|
+
const { name: n } = V;
|
|
380
|
+
e.component(n, V);
|
|
562
381
|
};
|
|
563
382
|
export {
|
|
564
|
-
List,
|
|
565
|
-
|
|
383
|
+
V as List,
|
|
384
|
+
V as default
|
|
566
385
|
};
|