y-design-ssr 0.2.6 → 0.2.8

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.
Files changed (129) hide show
  1. package/README.md +1 -1
  2. package/libs/button/index.css +1 -579
  3. package/libs/button/index.d.ts +0 -1
  4. package/libs/button/index.mjs +65 -111
  5. package/libs/button/index.umd.js +2 -203
  6. package/libs/cell/index.css +1 -1077
  7. package/libs/cell/index.d.ts +0 -1
  8. package/libs/cell/index.mjs +104 -168
  9. package/libs/cell/index.umd.js +2 -301
  10. package/libs/checkbox/index.css +1 -1053
  11. package/libs/checkbox/index.d.ts +0 -1
  12. package/libs/checkbox/index.mjs +127 -243
  13. package/libs/checkbox/index.umd.js +2 -370
  14. package/libs/checkboxGroup/index.css +1 -422
  15. package/libs/checkboxGroup/index.d.ts +0 -1
  16. package/libs/checkboxGroup/index.mjs +87 -174
  17. package/libs/checkboxGroup/index.umd.js +2 -266
  18. package/libs/col/index.css +1 -615
  19. package/libs/col/index.d.ts +0 -1
  20. package/libs/col/index.mjs +81 -247
  21. package/libs/col/index.umd.js +2 -306
  22. package/libs/countdown/index.css +1 -417
  23. package/libs/countdown/index.d.ts +0 -1
  24. package/libs/countdown/index.mjs +71 -180
  25. package/libs/countdown/index.umd.js +2 -232
  26. package/libs/dialog/index.css +1 -1405
  27. package/libs/dialog/index.d.ts +0 -1
  28. package/libs/dialog/index.mjs +476 -647
  29. package/libs/dialog/index.umd.js +2 -1129
  30. package/libs/empty/index.css +1 -457
  31. package/libs/empty/index.d.ts +0 -1
  32. package/libs/empty/index.mjs +44 -92
  33. package/libs/empty/index.umd.js +2 -140
  34. package/libs/form/index.css +1 -477
  35. package/libs/form/index.d.ts +0 -1
  36. package/libs/form/index.mjs +126 -227
  37. package/libs/form/index.umd.js +2 -320
  38. package/libs/formItem/index.css +1 -477
  39. package/libs/formItem/index.d.ts +0 -1
  40. package/libs/formItem/index.mjs +126 -277
  41. package/libs/formItem/index.umd.js +2 -373
  42. package/libs/icon/index.css +1 -982
  43. package/libs/icon/index.d.ts +0 -1
  44. package/libs/icon/index.mjs +58 -108
  45. package/libs/icon/index.umd.js +2 -187
  46. package/libs/index.css +1 -2902
  47. package/libs/index.mjs +2348 -3789
  48. package/libs/index.umd.js +2 -5509
  49. package/libs/input/index.css +1 -483
  50. package/libs/input/index.d.ts +0 -1
  51. package/libs/input/index.mjs +92 -184
  52. package/libs/input/index.umd.js +2 -275
  53. package/libs/layout/index.css +1 -684
  54. package/libs/layout/index.mjs +130 -230
  55. package/libs/layout/index.umd.js +2 -318
  56. package/libs/list/index.css +1 -440
  57. package/libs/list/index.d.ts +0 -1
  58. package/libs/list/index.mjs +207 -389
  59. package/libs/list/index.umd.js +2 -572
  60. package/libs/loading/index.css +1 -548
  61. package/libs/loading/index.d.ts +0 -1
  62. package/libs/loading/index.mjs +118 -197
  63. package/libs/loading/index.umd.js +2 -322
  64. package/libs/locale/index.mjs +28 -0
  65. package/libs/locale/index.umd.js +1 -0
  66. package/libs/locale/package.json +6 -0
  67. package/libs/mask/index.css +1 -426
  68. package/libs/mask/index.d.ts +0 -1
  69. package/libs/mask/index.mjs +70 -132
  70. package/libs/mask/index.umd.js +2 -202
  71. package/libs/popup/index.css +1 -465
  72. package/libs/popup/index.d.ts +0 -1
  73. package/libs/popup/index.mjs +134 -211
  74. package/libs/popup/index.umd.js +2 -359
  75. package/libs/progress/index.css +1 -488
  76. package/libs/progress/index.d.ts +0 -1
  77. package/libs/progress/index.mjs +128 -201
  78. package/libs/progress/index.umd.js +2 -323
  79. package/libs/pullrefresh/index.css +1 -441
  80. package/libs/pullrefresh/index.d.ts +0 -1
  81. package/libs/pullrefresh/index.mjs +111 -242
  82. package/libs/pullrefresh/index.umd.js +2 -303
  83. package/libs/row/index.css +1 -485
  84. package/libs/row/index.d.ts +0 -1
  85. package/libs/row/index.mjs +89 -182
  86. package/libs/row/index.umd.js +2 -238
  87. package/libs/slider/index.css +1 -558
  88. package/libs/slider/index.d.ts +0 -1
  89. package/libs/slider/index.mjs +160 -357
  90. package/libs/slider/index.umd.js +2 -454
  91. package/libs/stepper/index.css +1 -489
  92. package/libs/stepper/index.d.ts +0 -1
  93. package/libs/stepper/index.mjs +101 -182
  94. package/libs/stepper/index.umd.js +2 -270
  95. package/libs/style/index.css +1 -0
  96. package/libs/style/index.mjs +1 -0
  97. package/libs/style/index.umd.js +2 -0
  98. package/libs/style/package.json +6 -0
  99. package/libs/swipe/index.css +1 -506
  100. package/libs/swipe/index.d.ts +0 -1
  101. package/libs/swipe/index.mjs +259 -543
  102. package/libs/swipe/index.umd.js +2 -704
  103. package/libs/swipeItem/index.css +1 -424
  104. package/libs/swipeItem/index.d.ts +0 -1
  105. package/libs/swipeItem/index.mjs +52 -112
  106. package/libs/swipeItem/index.umd.js +2 -155
  107. package/libs/switch/index.css +1 -472
  108. package/libs/switch/index.d.ts +0 -1
  109. package/libs/switch/index.mjs +62 -122
  110. package/libs/switch/index.umd.js +2 -201
  111. package/libs/tab/index.d.ts +0 -1
  112. package/libs/tab/index.mjs +68 -132
  113. package/libs/tab/index.umd.js +1 -191
  114. package/libs/tabs/index.css +1 -514
  115. package/libs/tabs/index.d.ts +0 -1
  116. package/libs/tabs/index.mjs +410 -752
  117. package/libs/tabs/index.umd.js +2 -1021
  118. package/libs/toast/index.css +1 -1050
  119. package/libs/toast/index.d.ts +0 -1
  120. package/libs/toast/index.mjs +114 -184
  121. package/libs/toast/index.umd.js +2 -307
  122. package/libs/tooltip/index.css +1 -514
  123. package/libs/tooltip/index.d.ts +0 -1
  124. package/libs/tooltip/index.mjs +155 -294
  125. package/libs/tooltip/index.umd.js +2 -417
  126. package/libs/utils/index.mjs +76 -0
  127. package/libs/utils/index.umd.js +1 -0
  128. package/libs/utils/package.json +6 -0
  129. package/package.json +2 -5
@@ -1,46 +1,11 @@
1
- import { ref, reactive, defineComponent, createVNode, computed, onMounted, onUpdated, nextTick, onUnmounted, createTextVNode } from "vue";
2
- const tagTester = (name2) => {
3
- return (obj) => {
4
- return Object.prototype.toString.call(obj) === `[object ${name2}]`;
5
- };
6
- };
7
- const isNumber = tagTester("Number");
8
- const getMods = (el, mods) => {
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
- ref("zh-CN");
56
- reactive({
57
- "zh-CN": defaultLang
20
+ d("zh-CN");
21
+ K({
22
+ "zh-CN": ie
58
23
  });
59
- const createNamespace = (name2) => {
60
- const prefixedName = `y-${name2}`;
61
- return [prefixedName, createBEM(prefixedName), createGlobalBem()];
62
- };
63
- const parseUnit = (val) => {
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
- const YLoading = /* @__PURE__ */ defineComponent({
145
- name,
146
- props: _props,
147
- setup(props, {
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 _a, _b;
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
- } = props;
166
- const showText = ((_a = slots.default) == null ? void 0 : _a.call(slots)) || text;
167
- return createVNode("div", {
168
- "class": bem$1({
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
- }, [createVNode("div", {
172
- "class": bem$1("bg", {
173
- [position]: position !== "relative"
125
+ }, [i("div", {
126
+ class: R("bg", {
127
+ [c]: c !== "relative"
174
128
  }),
175
- "style": {
176
- flexDirection: parseFlexDirection(textLocation),
177
- backgroundColor: bgColor,
178
- borderRadius: parseUnit(bgBorderRadius),
179
- padding: parseUnit(padding)
129
+ style: {
130
+ flexDirection: oe(r),
131
+ backgroundColor: f,
132
+ borderRadius: H(m),
133
+ padding: H(x)
180
134
  }
181
- }, [createVNode("span", {
182
- "class": bem$1("icon-wrapper"),
183
- "style": {
184
- width: parseUnit(size),
185
- height: parseUnit(size)
135
+ }, [i("span", {
136
+ class: R("icon-wrapper"),
137
+ style: {
138
+ width: H(o),
139
+ height: H(o)
186
140
  }
187
- }, [((_b = slots.icon) == null ? void 0 : _b.call(slots)) || createVNode("svg", {
188
- "class": bem$1("icon", {
189
- [direction]: direction
141
+ }, [((B = n.icon) == null ? void 0 : B.call(n)) || i("svg", {
142
+ class: R("icon", {
143
+ [I]: I
190
144
  }),
191
- "viewBox": "25 25 50 50"
192
- }, [createVNode("circle", {
193
- "class": bem$1("icon-circle"),
194
- "style": {
195
- stroke: color,
196
- strokeWidth: parseUnit(thick)
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
- "cx": "50",
199
- "cy": "50",
200
- "r": "20",
201
- "fill": "none"
202
- }, null)])]), showText && createVNode("span", {
203
- "class": bem$1("text", {
204
- [textLocation]: textLocation
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
- "style": {
207
- color: textColor,
208
- fontSize: parseUnit(textSize)
160
+ style: {
161
+ color: p,
162
+ fontSize: H(l)
209
163
  }
210
- }, [showText])])]);
164
+ }, [k])])]);
211
165
  };
212
166
  }
213
- });
214
- const [cname, bem] = createNamespace("list");
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: true
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: false
213
+ default: !1
262
214
  },
263
215
  // 缓冲区比例
264
216
  bufferScale: {
@@ -273,294 +225,160 @@ const List = /* @__PURE__ */ defineComponent({
273
225
  // 是否是不定高度子项
274
226
  dynamicItemHeight: {
275
227
  type: Boolean,
276
- default: false
228
+ default: !1
277
229
  }
278
230
  },
279
231
  emits: ["load"],
280
- setup(props, {
281
- slots,
282
- emit,
283
- expose
232
+ setup(e, {
233
+ slots: n,
234
+ emit: c,
235
+ expose: r
284
236
  }) {
285
- const visibleHeightRef = ref(0);
286
- const pageModeRef = ref(false);
287
- const stateRef = ref("normal");
288
- const listRef = ref();
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 listRef.value.scrollHeight;
339
- };
340
- const loadData = () => {
341
- if (stateRef.value === "loading")
342
- return;
343
- stateRef.value = "loading";
344
- emit("load", (state) => {
345
- if (stateRef.value !== "loading")
346
- return;
347
- switch (state) {
348
- case "error":
349
- stateRef.value = "error";
350
- break;
351
- case "finished":
352
- stateRef.value = "finished";
353
- if (props.virtual) {
354
- initPositions();
355
- }
356
- if (props.virtual && props.dynamicItemHeight) {
357
- updatePositions();
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: index * height,
385
- bottom: (index + 1) * height
263
+ index: a,
264
+ height: u,
265
+ top: a * u,
266
+ bottom: (a + 1) * u
386
267
  };
387
268
  });
388
- };
389
- const updatePositions = () => {
390
- initPositions();
391
- for (let i = 1; i < positionsRef.value.length; i++) {
392
- positionsRef.value[i].top = positionsRef.value[i - 1].bottom;
393
- positionsRef.value[i].bottom = positionsRef.value[i].top + positionsRef.value[i].height;
394
- }
395
- };
396
- const binarySearch = (list, value) => {
397
- let start = 0;
398
- let end = list.length - 1;
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 tempIndex;
415
- };
416
- const getStartIndex = (scrollTop) => {
417
- return binarySearch(positionsRef.value, scrollTop);
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
- const updateVisibleData = (scrollTopParam) => {
427
- if (!contentRef.value)
287
+ }, F = (t) => {
288
+ if (!v.value)
428
289
  return;
429
- const scrollTop = scrollTopParam || 0;
430
- if (props.dynamicItemHeight) {
431
- startIndexRef.value = getStartIndex(scrollTop);
432
- endIndexRef.value = startIndexRef.value + visibleCountRef.value;
433
- const startOffset = positionsRef.value[startIndexRef.value - aboveCountRef.value].top ? positionsRef.value[startIndexRef.value - aboveCountRef.value].top : 0;
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
- startIndexRef.value = Math.floor(scrollTop / parseInt(String(props.itemHeight)));
437
- endIndexRef.value = startIndexRef.value + visibleCountRef.value;
438
- const startOffset = startIndexRef.value * parseInt(String(props.itemHeight)) - aboveCountRef.value * parseInt(String(props.itemHeight));
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
- const updateItemSize = () => {
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
- [...nodes].forEach((node) => {
449
- if (node instanceof HTMLDivElement) {
450
- const rect = node.getBoundingClientRect();
451
- const {
452
- height
453
- } = rect;
454
- const index = Number(node.dataset.index);
455
- const oldHeight = positionsRef.value[index].height;
456
- const dValue = oldHeight - height;
457
- if (dValue) {
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
- expose({
469
- ...props,
470
- checkIsScrollToBottom,
471
- loadData
472
- });
473
- onMounted(() => {
474
- if (props.height !== "auto") {
475
- pageModeRef.value = false;
476
- visibleHeightRef.value = listRef.value.clientHeight;
477
- } else if (props.height === "auto") {
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
- onUnmounted(() => {
501
- if (pageModeRef.value) {
502
- document.removeEventListener("scroll", handleScroll);
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
- return () => {
506
- return createVNode("div", {
507
- "ref": listRef,
508
- "class": `${bem()} ${props.virtual ? bem({
509
- virtual: true
510
- }) : ""}`,
511
- "style": {
512
- height: listContainerRef.value
513
- },
514
- "onScroll": handleScroll
515
- }, [props.virtual && createVNode("div", {
516
- "ref": scrollBarRef,
517
- "class": bem("phantom"),
518
- "style": {
519
- height: `${listHeightRef.value}px`
520
- }
521
- }, null), createVNode("div", {
522
- "ref": contentRef,
523
- "class": bem("content")
524
- }, [realRenderListRef.value.map((item) => {
525
- var _a;
526
- return createVNode("div", {
527
- "ref": itemsRef,
528
- "class": bem("item"),
529
- "data-index": item._index
530
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
531
- item
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
- const reset = "";
554
- const libs = "";
555
- const font = "";
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
- List as default
383
+ V as default
566
384
  };