zx-infinite-scroll 1.0.4 → 1.0.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/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import { defineComponent as N, openBlock as f, createElementBlock as m, normalizeClass as P, createElementVNode as z, toDisplayString as $, computed as re, normalizeStyle as U, renderSlot as j, createTextVNode as ge, createCommentVNode as V, ref as d, watch as Y, onMounted as ce, nextTick as I, onBeforeUnmount as pe, withDirectives as xe, vShow as ye, createVNode as Te, createBlock as Z, withCtx as we } from "vue";
2
- const Ee = { class: "loading-content" }, Re = { class: "loading-text" }, Ce = /* @__PURE__ */ N({
1
+ import { defineComponent as Y, openBlock as f, createElementBlock as p, normalizeClass as X, createElementVNode as $, toDisplayString as V, computed as se, normalizeStyle as P, renderSlot as K, createTextVNode as ge, createCommentVNode as D, ref as d, watch as j, onMounted as fe, nextTick as I, onBeforeUnmount as xe, withDirectives as ye, vShow as Te, createVNode as be, createBlock as U, withCtx as we } from "vue";
2
+ const Ee = { class: "loading-content" }, Re = { class: "loading-text" }, Ce = /* @__PURE__ */ Y({
3
3
  name: "RequestLoading",
4
4
  __name: "request-loading",
5
5
  props: {
@@ -7,24 +7,24 @@ const Ee = { class: "loading-content" }, Re = { class: "loading-text" }, Ce = /*
7
7
  fullscreen: { type: Boolean, default: !1 }
8
8
  },
9
9
  setup(t) {
10
- return (g, p) => (f(), m("div", {
11
- class: P(["loading-container", { fullscreen: t.fullscreen }])
10
+ return (m, g) => (f(), p("div", {
11
+ class: X(["loading-container", { fullscreen: t.fullscreen }])
12
12
  }, [
13
- z("div", Ee, [
14
- p[0] || (p[0] = z("span", { class: "loading-spinner" }, null, -1)),
15
- z("span", Re, $(t.text), 1)
13
+ $("div", Ee, [
14
+ g[0] || (g[0] = $("span", { class: "loading-spinner" }, null, -1)),
15
+ $("span", Re, V(t.text), 1)
16
16
  ])
17
17
  ], 2));
18
18
  }
19
- }), G = (t, g) => {
20
- const p = t.__vccOpts || t;
21
- for (const [n, x] of g)
22
- p[n] = x;
23
- return p;
24
- }, K = /* @__PURE__ */ G(Ce, [["__scopeId", "data-v-d89150ba"]]), Le = ["src"], ke = {
19
+ }), G = (t, m) => {
20
+ const g = t.__vccOpts || t;
21
+ for (const [l, x] of m)
22
+ g[l] = x;
23
+ return g;
24
+ }, Z = /* @__PURE__ */ G(Ce, [["__scopeId", "data-v-d89150ba"]]), ke = ["src"], Le = {
25
25
  key: 0,
26
26
  class: "empty-text"
27
- }, He = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='80' viewBox='0 0 96 80' fill='none'%3E%3Cpath d='M8 16C8 12.6863 10.6863 10 14 10H38L44 16H82C85.3137 16 88 18.6863 88 22V66C88 69.3137 85.3137 72 82 72H14C10.6863 72 8 69.3137 8 66V16Z' fill='%23E8E8E8'/%3E%3Cpath d='M8 20C8 18.3431 9.34315 17 11 17H85C86.6569 17 88 18.3431 88 20V66C88 69.3137 85.3137 72 82 72H14C10.6863 72 8 69.3137 8 66V20Z' fill='%23F5F5F5'/%3E%3Cpath d='M38 42C38 40.8954 38.8954 40 40 40H56C57.1046 40 58 40.8954 58 42V44C58 45.1046 57.1046 46 56 46H40C38.8954 46 38 45.1046 38 44V42Z' fill='%23D9D9D9'/%3E%3C/svg%3E", Se = /* @__PURE__ */ N({
27
+ }, He = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='80' viewBox='0 0 96 80' fill='none'%3E%3Cpath d='M8 16C8 12.6863 10.6863 10 14 10H38L44 16H82C85.3137 16 88 18.6863 88 22V66C88 69.3137 85.3137 72 82 72H14C10.6863 72 8 69.3137 8 66V16Z' fill='%23E8E8E8'/%3E%3Cpath d='M8 20C8 18.3431 9.34315 17 11 17H85C86.6569 17 88 18.3431 88 20V66C88 69.3137 85.3137 72 82 72H14C10.6863 72 8 69.3137 8 66V20Z' fill='%23F5F5F5'/%3E%3Cpath d='M38 42C38 40.8954 38.8954 40 40 40H56C57.1046 40 58 40.8954 58 42V44C58 45.1046 57.1046 46 56 46H40C38.8954 46 38 45.1046 38 44V42Z' fill='%23D9D9D9'/%3E%3C/svg%3E", Se = /* @__PURE__ */ Y({
28
28
  name: "EmptyComponent",
29
29
  __name: "empty-component",
30
30
  props: {
@@ -34,38 +34,38 @@ const Ee = { class: "loading-content" }, Re = { class: "loading-text" }, Ce = /*
34
34
  emptyImage: { default: "" }
35
35
  },
36
36
  setup(t) {
37
- const g = t, p = re(() => ({
38
- paddingTop: typeof g.paddingTop == "number" ? `${g.paddingTop}px` : g.paddingTop
39
- })), n = re(() => g.emptyImage || He);
40
- return (x, a) => (f(), m("div", {
37
+ const m = t, g = se(() => ({
38
+ paddingTop: typeof m.paddingTop == "number" ? `${m.paddingTop}px` : m.paddingTop
39
+ })), l = se(() => m.emptyImage || He);
40
+ return (x, a) => (f(), p("div", {
41
41
  class: "empty-wrap",
42
- style: U(p.value)
42
+ style: P(g.value)
43
43
  }, [
44
- z("img", {
44
+ $("img", {
45
45
  class: "empty-image",
46
- src: n.value,
46
+ src: l.value,
47
47
  alt: ""
48
- }, null, 8, Le),
49
- t.showText ? (f(), m("p", ke, [
50
- j(x.$slots, "default", {}, () => [
51
- ge($(t.text), 1)
48
+ }, null, 8, ke),
49
+ t.showText ? (f(), p("p", Le, [
50
+ K(x.$slots, "default", {}, () => [
51
+ ge(V(t.text), 1)
52
52
  ], !0)
53
- ])) : V("", !0)
53
+ ])) : D("", !0)
54
54
  ], 4));
55
55
  }
56
- }), fe = /* @__PURE__ */ G(Se, [["__scopeId", "data-v-3c452901"]]), Be = { class: "pull-refresh-content" }, be = { key: 0 }, Me = {
56
+ }), de = /* @__PURE__ */ G(Se, [["__scopeId", "data-v-3c452901"]]), ze = { class: "pull-refresh-content" }, Be = { key: 0 }, Me = {
57
57
  key: 1,
58
58
  class: "pull-text"
59
59
  }, De = {
60
60
  key: 2,
61
61
  class: "pull-text"
62
- }, Ve = {
62
+ }, Ie = {
63
63
  key: 0,
64
64
  class: "content-loading-mask"
65
- }, Ie = {
65
+ }, Ve = {
66
66
  key: 1,
67
67
  class: "finished-text"
68
- }, ue = 8, $e = /* @__PURE__ */ N({
68
+ }, ue = 8, $e = /* @__PURE__ */ Y({
69
69
  name: "InfiniteScroll",
70
70
  __name: "infinite-scroll",
71
71
  props: {
@@ -86,189 +86,189 @@ const Ee = { class: "loading-content" }, Re = { class: "loading-text" }, Ce = /*
86
86
  contentLoading: { type: Boolean, default: !1 }
87
87
  },
88
88
  emits: ["refresh", "load", "retry"],
89
- setup(t, { expose: g, emit: p }) {
90
- const n = t, x = p, a = d(null), o = d(null), C = d(null), i = d("idle"), h = d(0), y = d(!1);
91
- let E = 0, L = 0, T = 0, w = "none", v = !1, S = !1, B = !1, k = null, r = null, l = null, u = null, c = -1;
92
- function M(e, s) {
93
- !n.pullRefresh || v || (E = e, L = s, T = 0, w = "none", i.value = "idle");
89
+ setup(t, { expose: m, emit: g }) {
90
+ const l = t, x = g, a = d(null), i = d(null), R = d(null), o = d("idle"), h = d(0), y = d(!1);
91
+ let w = 0, C = 0, T = 0, b = "none", v = !1, H = !1, S = !1, k = null, s = null, n = null, u = null, c = -1;
92
+ function B(e, r) {
93
+ !l.pullRefresh || v || (w = e, C = r, T = 0, b = "none", o.value = "idle");
94
94
  }
95
- function J(e, s, R) {
96
- if (!n.pullRefresh || v || L === 0) return !1;
97
- const D = e - E, H = s - L;
98
- if (w === "none") {
99
- const b = Math.abs(D), X = Math.abs(H);
100
- if (b > ue || X > ue)
101
- w = X > b * 1.5 ? "vertical" : "horizontal";
95
+ function J(e, r, E) {
96
+ if (!l.pullRefresh || v || C === 0) return !1;
97
+ const M = e - w, L = r - C;
98
+ if (b === "none") {
99
+ const z = Math.abs(M), O = Math.abs(L);
100
+ if (z > ue || O > ue)
101
+ b = O > z * 1.5 ? "vertical" : "horizontal";
102
102
  else
103
103
  return !1;
104
104
  }
105
- if (w === "horizontal") return !1;
106
- const q = ve() <= 1;
107
- if (!q && H < 0) {
108
- const b = a.value;
109
- return !!(b && b.scrollHeight - b.scrollTop - b.clientHeight <= 1 && R);
105
+ if (b === "horizontal") return !1;
106
+ const q = pe() <= 1;
107
+ if (!q && L < 0) {
108
+ const z = a.value;
109
+ return !!(z && z.scrollHeight - z.scrollTop - z.clientHeight <= 1 && E);
110
110
  }
111
- return q ? (T = Math.max(0, Math.min(H, 150)), y.value = !0, r === null && (r = requestAnimationFrame(() => {
112
- r = null, h.value = T * 0.5, T === 0 ? i.value = "idle" : i.value = T > n.pullThreshold ? "loosing" : "pulling";
113
- })), H > 0) : !1;
111
+ return q ? (T = Math.max(0, Math.min(L, 150)), y.value = !0, s === null && (s = requestAnimationFrame(() => {
112
+ s = null, h.value = T * 0.5, T === 0 ? o.value = "idle" : o.value = T > l.pullThreshold ? "loosing" : "pulling";
113
+ })), L > 0) : !1;
114
114
  }
115
115
  function Q() {
116
- !n.pullRefresh || v || (r !== null && (cancelAnimationFrame(r), r = null), y.value = !1, T > n.pullThreshold ? (v = !0, i.value = "refreshing", h.value = 50, x("refresh")) : (h.value = 0, i.value = "idle"), oe());
116
+ !l.pullRefresh || v || (s !== null && (cancelAnimationFrame(s), s = null), y.value = !1, T > l.pullThreshold ? (v = !0, o.value = "refreshing", h.value = 50, x("refresh")) : (h.value = 0, o.value = "idle"), ie());
117
117
  }
118
- function he() {
119
- !n.pullRefresh || v || (r !== null && (cancelAnimationFrame(r), r = null), y.value = !1, h.value = 0, i.value = "idle", oe());
118
+ function ve() {
119
+ !l.pullRefresh || v || (s !== null && (cancelAnimationFrame(s), s = null), y.value = !1, h.value = 0, o.value = "idle", ie());
120
120
  }
121
121
  function W(e) {
122
- M(e.touches[0].clientX, e.touches[0].clientY);
122
+ B(e.touches[0].clientX, e.touches[0].clientY);
123
123
  }
124
124
  function _(e) {
125
- const s = e.touches[0];
126
- J(s.clientX, s.clientY, e.cancelable) && e.cancelable && e.preventDefault();
125
+ const r = e.touches[0];
126
+ J(r.clientX, r.clientY, e.cancelable) && e.cancelable && e.preventDefault();
127
127
  }
128
128
  function ee() {
129
129
  Q();
130
130
  }
131
131
  function te() {
132
- he();
133
- }
134
- function le(e) {
135
- !n.pullRefresh || v || e.button !== 0 || (B = !0, M(e.clientX, e.clientY));
132
+ ve();
136
133
  }
137
134
  function ne(e) {
138
- B && J(e.clientX, e.clientY, !0) && e.preventDefault();
135
+ !l.pullRefresh || v || e.button !== 0 || (S = !0, B(e.clientX, e.clientY));
136
+ }
137
+ function le(e) {
138
+ S && J(e.clientX, e.clientY, !0) && e.preventDefault();
139
139
  }
140
140
  function ae() {
141
- B && (B = !1, Q());
141
+ S && (S = !1, Q());
142
142
  }
143
- function oe() {
144
- E = 0, L = 0, T = 0, w = "none";
143
+ function ie() {
144
+ w = 0, C = 0, T = 0, b = "none";
145
145
  }
146
- function O() {
147
- n.loading || n.finished || n.error || S || k || (k = window.setTimeout(() => {
146
+ function A() {
147
+ l.loading || l.finished || l.error || H || k || (k = window.setTimeout(() => {
148
148
  var q;
149
149
  k = null;
150
150
  const e = a.value;
151
151
  if (!e) return;
152
- const { scrollTop: s, clientHeight: R, scrollHeight: D } = e, H = ((q = o.value) == null ? void 0 : q.clientHeight) || 0;
153
- if (H <= R) {
154
- if (c === H) return;
155
- c = H, ie(!0);
152
+ const { scrollTop: r, clientHeight: E, scrollHeight: M } = e, L = ((q = i.value) == null ? void 0 : q.clientHeight) || 0;
153
+ if (L <= E) {
154
+ if (c === L) return;
155
+ c = L, oe(!0);
156
156
  return;
157
157
  }
158
- D - s - R <= n.loadThreshold && ie(!1);
158
+ M - r - E <= l.loadThreshold && oe(!1);
159
159
  }, 100));
160
160
  }
161
- function ie(e = !1) {
162
- S = !0, x("load"), I(() => {
163
- var R;
164
- const s = a.value;
165
- s && (e ? s.scrollTop = s.scrollHeight : (R = C.value) == null || R.scrollIntoView({ block: "end", behavior: "smooth" }));
161
+ function oe(e = !1) {
162
+ H = !0, x("load"), I(() => {
163
+ var E;
164
+ const r = a.value;
165
+ r && (e ? r.scrollTop = r.scrollHeight : (E = R.value) == null || E.scrollIntoView({ block: "end", behavior: "smooth" }));
166
166
  });
167
167
  }
168
- function ve() {
168
+ function pe() {
169
169
  var e;
170
170
  return ((e = a.value) == null ? void 0 : e.scrollTop) ?? 0;
171
171
  }
172
- function A() {
173
- v = !1, h.value = 0, l !== null && clearTimeout(l), l = window.setTimeout(() => {
174
- i.value = "idle", l = null;
172
+ function N() {
173
+ v = !1, h.value = 0, n !== null && clearTimeout(n), n = window.setTimeout(() => {
174
+ o.value = "idle", n = null;
175
175
  }, 250), c = -1, I(() => {
176
176
  F();
177
177
  });
178
178
  }
179
- function se() {
180
- S = !1, I(() => {
181
- var s;
182
- const e = ((s = o.value) == null ? void 0 : s.clientHeight) || 0;
179
+ function re() {
180
+ H = !1, I(() => {
181
+ var r;
182
+ const e = ((r = i.value) == null ? void 0 : r.clientHeight) || 0;
183
183
  c !== -1 && e === c || (c = -1, F());
184
184
  });
185
185
  }
186
186
  function F() {
187
- n.finished || n.loading || n.error || I(() => {
188
- var R, D;
189
- const e = ((R = o.value) == null ? void 0 : R.clientHeight) || 0, s = ((D = a.value) == null ? void 0 : D.clientHeight) || 0;
190
- e <= s && !S && O();
187
+ l.finished || l.loading || l.error || I(() => {
188
+ var E, M;
189
+ const e = ((E = i.value) == null ? void 0 : E.clientHeight) || 0, r = ((M = a.value) == null ? void 0 : M.clientHeight) || 0;
190
+ e <= r && !H && A();
191
191
  });
192
192
  }
193
193
  function me() {
194
194
  x("retry");
195
195
  }
196
- return Y(
197
- () => n.loading,
196
+ return j(
197
+ () => l.loading,
198
198
  (e) => {
199
- e || (S = !1);
199
+ e || (H = !1);
200
200
  }
201
- ), Y(
202
- () => n.finished,
201
+ ), j(
202
+ () => l.finished,
203
203
  (e) => {
204
204
  e && (c = -1);
205
205
  }
206
- ), ce(() => {
206
+ ), fe(() => {
207
207
  const e = a.value;
208
- e && (n.pullRefresh && (e.addEventListener("touchstart", W, { passive: !0 }), e.addEventListener("touchmove", _, { passive: !1 }), e.addEventListener("touchend", ee, { passive: !0 }), e.addEventListener("touchcancel", te, { passive: !0 }), e.addEventListener("mousedown", le), window.addEventListener("mousemove", ne), window.addEventListener("mouseup", ae)), e.addEventListener("scroll", O, { passive: !0 }), typeof ResizeObserver < "u" && (u = new ResizeObserver(() => {
208
+ e && (l.pullRefresh && (e.addEventListener("touchstart", W, { passive: !0 }), e.addEventListener("touchmove", _, { passive: !1 }), e.addEventListener("touchend", ee, { passive: !0 }), e.addEventListener("touchcancel", te, { passive: !0 }), e.addEventListener("mousedown", ne), window.addEventListener("mousemove", le), window.addEventListener("mouseup", ae)), e.addEventListener("scroll", A, { passive: !0 }), typeof ResizeObserver < "u" && (u = new ResizeObserver(() => {
209
209
  F();
210
- }), u.observe(e), o.value && u.observe(o.value)), I(() => {
210
+ }), u.observe(e), i.value && u.observe(i.value)), I(() => {
211
211
  F();
212
212
  }));
213
- }), pe(() => {
213
+ }), xe(() => {
214
214
  const e = a.value;
215
- e && (e.removeEventListener("touchstart", W), e.removeEventListener("touchmove", _), e.removeEventListener("touchend", ee), e.removeEventListener("touchcancel", te), e.removeEventListener("mousedown", le), e.removeEventListener("scroll", O)), window.removeEventListener("mousemove", ne), window.removeEventListener("mouseup", ae), u && (u.disconnect(), u = null), r !== null && (cancelAnimationFrame(r), r = null), k !== null && (clearTimeout(k), k = null), l !== null && (clearTimeout(l), l = null);
216
- }), g({
217
- refresh: A,
218
- finishRefresh: A,
219
- finishPullDown: A,
220
- finishLoad: se,
221
- finishPullUp: se,
215
+ e && (e.removeEventListener("touchstart", W), e.removeEventListener("touchmove", _), e.removeEventListener("touchend", ee), e.removeEventListener("touchcancel", te), e.removeEventListener("mousedown", ne), e.removeEventListener("scroll", A)), window.removeEventListener("mousemove", le), window.removeEventListener("mouseup", ae), u && (u.disconnect(), u = null), s !== null && (cancelAnimationFrame(s), s = null), k !== null && (clearTimeout(k), k = null), n !== null && (clearTimeout(n), n = null);
216
+ }), m({
217
+ refresh: N,
218
+ finishRefresh: N,
219
+ finishPullDown: N,
220
+ finishLoad: re,
221
+ finishPullUp: re,
222
222
  checkContentHeight: F
223
- }), (e, s) => (f(), m("div", {
223
+ }), (e, r) => (f(), p("div", {
224
224
  ref_key: "containerRef",
225
225
  ref: a,
226
226
  class: "infinite-scroll"
227
227
  }, [
228
- t.pullRefresh ? (f(), m("div", {
228
+ t.pullRefresh ? (f(), p("div", {
229
229
  key: 0,
230
- class: P(["pull-refresh-indicator", { "no-transition": y.value }]),
231
- style: U({ transform: `translateY(${h.value}px)` })
230
+ class: X(["pull-refresh-indicator", { "no-transition": y.value }]),
231
+ style: P({ transform: `translateY(${h.value}px)` })
232
232
  }, [
233
- xe(z("div", Be, [
234
- i.value === "refreshing" ? (f(), m("span", be)) : i.value === "loosing" ? (f(), m("span", Me, $(t.loosingText), 1)) : (f(), m("span", De, $(t.pullingText), 1))
233
+ ye($("div", ze, [
234
+ o.value === "refreshing" ? (f(), p("span", Be)) : o.value === "loosing" ? (f(), p("span", Me, V(t.loosingText), 1)) : (f(), p("span", De, V(t.pullingText), 1))
235
235
  ], 512), [
236
- [ye, i.value !== "idle"]
236
+ [Te, o.value !== "idle"]
237
237
  ])
238
- ], 6)) : V("", !0),
239
- z("div", {
238
+ ], 6)) : D("", !0),
239
+ $("div", {
240
240
  ref_key: "contentRef",
241
- ref: o,
242
- class: P(["infinite-scroll-content", { "no-transition": y.value }]),
243
- style: U(t.pullRefresh ? { transform: `translateY(${h.value}px)` } : {})
241
+ ref: i,
242
+ class: X(["infinite-scroll-content", { "no-transition": y.value }]),
243
+ style: P(t.pullRefresh ? { transform: `translateY(${h.value}px)` } : {})
244
244
  }, [
245
- t.contentLoading ? (f(), m("div", Ve, [
246
- Te(K, { text: t.refreshingText }, null, 8, ["text"])
247
- ])) : V("", !0),
248
- t.isEmpty && !t.loading ? (f(), Z(fe, {
245
+ t.contentLoading ? (f(), p("div", Ie, [
246
+ be(Z, { text: t.refreshingText }, null, 8, ["text"])
247
+ ])) : D("", !0),
248
+ t.isEmpty && !t.loading ? (f(), U(de, {
249
249
  key: 1,
250
250
  text: t.emptyText
251
- }, null, 8, ["text"])) : V("", !0),
252
- j(e.$slots, "default", {}, void 0, !0),
253
- t.isEmpty ? V("", !0) : (f(), m("div", {
251
+ }, null, 8, ["text"])) : D("", !0),
252
+ K(e.$slots, "default", {}, void 0, !0),
253
+ t.isEmpty ? D("", !0) : (f(), p("div", {
254
254
  key: 2,
255
255
  ref_key: "indicatorRef",
256
- ref: C,
256
+ ref: R,
257
257
  class: "load-more-indicator"
258
258
  }, [
259
- t.loading && i.value !== "refreshing" ? (f(), Z(K, {
259
+ t.loading && o.value !== "refreshing" ? (f(), U(Z, {
260
260
  key: 0,
261
261
  text: t.loadingText
262
- }, null, 8, ["text"])) : t.finished ? (f(), m("span", Ie, $(t.finishedText), 1)) : t.error ? (f(), m("span", {
262
+ }, null, 8, ["text"])) : t.finished ? (f(), p("span", Ve, V(t.finishedText), 1)) : t.error ? (f(), p("span", {
263
263
  key: 2,
264
264
  class: "error-text",
265
265
  onClick: me
266
- }, $(t.errorText), 1)) : V("", !0)
266
+ }, V(t.errorText), 1)) : D("", !0)
267
267
  ], 512))
268
268
  ], 6)
269
269
  ], 512));
270
270
  }
271
- }), de = /* @__PURE__ */ G($e, [["__scopeId", "data-v-bf5ca1d9"]]), ze = /* @__PURE__ */ N({
271
+ }), he = /* @__PURE__ */ G($e, [["__scopeId", "data-v-bf5ca1d9"]]), Fe = /* @__PURE__ */ Y({
272
272
  name: "InfiniteScrollV2",
273
273
  __name: "infinite-scroll-v2",
274
274
  props: {
@@ -289,96 +289,96 @@ const Ee = { class: "loading-content" }, Re = { class: "loading-text" }, Ce = /*
289
289
  errorText: { default: "加载失败,点击重试" }
290
290
  },
291
291
  emits: ["success", "error", "update:list"],
292
- setup(t, { expose: g, emit: p }) {
293
- const n = t, x = p, a = d(null), o = d([]), C = d(!1), i = d(!1), h = d(!1), y = d(!1), E = d(0), L = d(1), T = d(!1);
294
- let w = 0;
295
- async function v(l = !1) {
296
- l && (L.value = 1, i.value = !1, h.value = !1), C.value = !0, y.value = !1, w += 1;
297
- const u = w;
292
+ setup(t, { expose: m, emit: g }) {
293
+ const l = t, x = g, a = d(null), i = d([]), R = d(!1), o = d(!1), h = d(!1), y = d(!1), w = d(0), C = d(1), T = d(!1);
294
+ let b = 0;
295
+ async function v(n = !1) {
296
+ n && (C.value = 1, o.value = !1, h.value = !1), R.value = !0, y.value = !1, b += 1;
297
+ const u = b;
298
298
  try {
299
- const c = await n.fetchFn({
300
- page: L.value,
301
- pageSize: n.pageSize,
302
- ...n.params
299
+ const c = await l.fetchFn({
300
+ page: C.value,
301
+ pageSize: l.pageSize,
302
+ ...l.params
303
303
  });
304
- if (u !== w) return;
305
- const M = (c == null ? void 0 : c.records) || [];
306
- l ? (o.value = M, E.value = 0) : o.value = [...o.value, ...M], E.value = Number((c == null ? void 0 : c.total) || 0), i.value = o.value.length >= E.value, h.value = o.value.length === 0, x("success", { records: M, total: E.value, reset: l }), x("update:list", o.value);
304
+ if (u !== b) return;
305
+ const B = (c == null ? void 0 : c.records) || [];
306
+ n ? (i.value = B, w.value = 0) : i.value = [...i.value, ...B], w.value = Number((c == null ? void 0 : c.total) || 0), o.value = i.value.length >= w.value, h.value = i.value.length === 0, x("success", { records: B, total: w.value, reset: n }), x("update:list", i.value);
307
307
  } catch (c) {
308
- if (u !== w) return;
308
+ if (u !== b) return;
309
309
  y.value = !0, x("error", c);
310
310
  } finally {
311
- u === w && (C.value = !1);
311
+ u === b && (R.value = !1);
312
312
  }
313
313
  }
314
- async function S() {
315
- var l;
316
- T.value = !0, (l = a.value) == null || l.finishRefresh(), await new Promise((u) => {
314
+ async function H() {
315
+ var n;
316
+ T.value = !0, (n = a.value) == null || n.finishRefresh(), await new Promise((u) => {
317
317
  setTimeout(() => u(), 250);
318
318
  }), await v(!0), T.value = !1;
319
319
  }
320
- async function B() {
321
- var l, u;
322
- if (i.value) {
323
- (l = a.value) == null || l.finishLoad();
320
+ async function S() {
321
+ var n, u;
322
+ if (o.value) {
323
+ (n = a.value) == null || n.finishLoad();
324
324
  return;
325
325
  }
326
- o.value.length > 0 && (L.value += 1), await v(!1), (u = a.value) == null || u.finishLoad();
326
+ i.value.length > 0 && (C.value += 1), await v(!1), (u = a.value) == null || u.finishLoad();
327
327
  }
328
328
  function k() {
329
- y.value = !1, o.value.length === 0 ? v(!0) : B();
329
+ y.value = !1, i.value.length === 0 ? v(!0) : S();
330
330
  }
331
- async function r() {
331
+ async function s() {
332
332
  await v(!0);
333
333
  }
334
- return Y(
335
- () => n.params,
334
+ return j(
335
+ () => l.params,
336
336
  () => {
337
- n.autoReload && r();
337
+ l.autoReload && s();
338
338
  },
339
339
  { deep: !0 }
340
- ), Y(
341
- o,
340
+ ), j(
341
+ i,
342
342
  async () => {
343
- var l;
344
- await I(), (l = a.value) == null || l.checkContentHeight();
343
+ var n;
344
+ await I(), (n = a.value) == null || n.checkContentHeight();
345
345
  },
346
346
  { deep: !0 }
347
- ), ce(() => {
348
- n.immediate && v(!0);
349
- }), g({
347
+ ), fe(() => {
348
+ l.immediate && v(!0);
349
+ }), m({
350
350
  /** 重新加载第一页 */
351
- reload: r,
351
+ reload: s,
352
352
  /** 兼容别名 */
353
- refresh: r,
353
+ refresh: s,
354
354
  /** 当前列表数据 */
355
- list: o,
355
+ list: i,
356
356
  /** 加载中状态 */
357
- loading: C,
357
+ loading: R,
358
358
  /** 是否已加载完 */
359
- finished: i,
359
+ finished: o,
360
360
  /** 是否空数据 */
361
361
  isEmpty: h,
362
362
  /** 总条数 */
363
- total: E,
363
+ total: w,
364
364
  /** 透传 v1 方法 */
365
365
  finishLoad: () => {
366
- var l;
367
- return (l = a.value) == null ? void 0 : l.finishLoad();
366
+ var n;
367
+ return (n = a.value) == null ? void 0 : n.finishLoad();
368
368
  },
369
369
  finishRefresh: () => {
370
- var l;
371
- return (l = a.value) == null ? void 0 : l.finishRefresh();
370
+ var n;
371
+ return (n = a.value) == null ? void 0 : n.finishRefresh();
372
372
  },
373
373
  checkContentHeight: () => {
374
- var l;
375
- return (l = a.value) == null ? void 0 : l.checkContentHeight();
374
+ var n;
375
+ return (n = a.value) == null ? void 0 : n.checkContentHeight();
376
376
  }
377
- }), (l, u) => (f(), Z(de, {
377
+ }), (n, u) => (f(), U(he, {
378
378
  ref_key: "scrollRef",
379
379
  ref: a,
380
- loading: C.value,
381
- finished: i.value,
380
+ loading: R.value,
381
+ finished: o.value,
382
382
  "is-empty": h.value,
383
383
  error: y.value,
384
384
  "pull-refresh": t.pullRefresh,
@@ -392,37 +392,45 @@ const Ee = { class: "loading-content" }, Re = { class: "loading-text" }, Ce = /*
392
392
  "finished-text": t.finishedText,
393
393
  "error-text": t.errorText,
394
394
  "content-loading": T.value,
395
- onLoad: B,
396
- onRefresh: S,
395
+ onLoad: S,
396
+ onRefresh: H,
397
397
  onRetry: k
398
398
  }, {
399
399
  default: we(() => [
400
- j(l.$slots, "default", {
401
- list: o.value,
402
- loading: C.value,
403
- finished: i.value,
400
+ K(n.$slots, "default", {
401
+ list: i.value,
402
+ loading: R.value,
403
+ finished: o.value,
404
404
  isEmpty: h.value,
405
405
  error: y.value,
406
- total: E.value,
407
- reload: r
406
+ total: w.value,
407
+ reload: s
408
408
  })
409
409
  ]),
410
410
  _: 3
411
411
  }, 8, ["loading", "finished", "is-empty", "error", "pull-refresh", "pull-threshold", "load-threshold", "empty-text", "pulling-text", "loosing-text", "refreshing-text", "loading-text", "finished-text", "error-text", "content-loading"]));
412
412
  }
413
413
  });
414
- function Fe(t) {
415
- t.component("InfiniteScroll", de), t.component("InfiniteScrollV2", ze), t.component("RequestLoading", K), t.component("EmptyComponent", fe);
414
+ let ce = !1;
415
+ const qe = ".loading-content[data-v-d89150ba]{display:flex;align-items:center;justify-content:center;gap:8px;padding:6px 12px;border-radius:16px;color:var(--zx-primary-color, #1e5efd);font-size:14px}.loading-spinner[data-v-d89150ba]{width:18px;height:18px;border-radius:50%;border:2.5px solid var(--zx-primary-color, #1e5efd);border-top-color:transparent;animation:spin-d89150ba .8s linear infinite}@keyframes spin-d89150ba{to{transform:rotate(360deg)}}.loading-container.fullscreen[data-v-d89150ba]{position:fixed;top:0;left:0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;background-color:#ffffff80}.empty-wrap[data-v-3c452901]{display:flex;flex-direction:column;align-items:center}.empty-image[data-v-3c452901]{width:96px;height:80px}.empty-text[data-v-3c452901]{margin:12px 0 0;color:#8c8f97;font-size:12px;line-height:22px}.infinite-scroll[data-v-bf5ca1d9]{height:100%;position:relative;min-height:100%;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;touch-action:pan-y;-webkit-overflow-scrolling:touch}.pull-refresh-indicator[data-v-bf5ca1d9]{position:absolute;top:-50px;left:0;right:0;height:50px;transition:transform .25s}.pull-refresh-indicator.no-transition[data-v-bf5ca1d9]{transition:none}.pull-refresh-content[data-v-bf5ca1d9]{display:flex;align-items:center;justify-content:center;height:100%;font-size:14px;color:#969799}.pull-text[data-v-bf5ca1d9]{color:var(--zx-primary-color, #1989fa);font-size:14px}.infinite-scroll-content[data-v-bf5ca1d9]{position:relative;transition:transform .25s;min-height:100%}.infinite-scroll-content.no-transition[data-v-bf5ca1d9]{transition:none}.content-loading-mask[data-v-bf5ca1d9]{position:absolute;top:0;left:0;right:0;bottom:0;background-color:#fffc;display:flex;align-items:center;justify-content:center;z-index:10;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.load-more-indicator[data-v-bf5ca1d9]{display:flex;align-items:center;justify-content:center;min-height:50px;padding:16px 0;font-size:14px;color:#8c8f97}.finished-text[data-v-bf5ca1d9]{color:#8c8f97;font-size:14px}.error-text[data-v-bf5ca1d9]{color:#ee0a24;font-size:14px;cursor:pointer}.error-text[data-v-bf5ca1d9]:active{opacity:.7}";
416
+ function je() {
417
+ if (ce || typeof document > "u") return;
418
+ const t = document.createElement("style");
419
+ t.setAttribute("data-source", "zx-infinite-scroll"), t.textContent = qe, document.head.appendChild(t), ce = !0;
420
+ }
421
+ je();
422
+ function Ye(t) {
423
+ t.component("InfiniteScroll", he), t.component("InfiniteScrollV2", Fe), t.component("RequestLoading", Z), t.component("EmptyComponent", de);
416
424
  }
417
- const Ne = {
418
- install: Fe
425
+ const Oe = {
426
+ install: Ye
419
427
  };
420
428
  export {
421
- fe as EmptyComponent,
422
- de as InfiniteScroll,
423
- ze as InfiniteScrollV2,
424
- K as RequestLoading,
425
- Ne as default,
426
- Fe as install
429
+ de as EmptyComponent,
430
+ he as InfiniteScroll,
431
+ Fe as InfiniteScrollV2,
432
+ Z as RequestLoading,
433
+ Oe as default,
434
+ Ye as install
427
435
  };
428
436
  //# sourceMappingURL=index.es.js.map