@lazycatcloud/lzc-toolkit 0.0.20 → 0.0.22

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,84 +1,123 @@
1
- import { unref as m, getCurrentScope as ie, onScopeDispose as ce, getCurrentInstance as ue, onMounted as V, nextTick as de, ref as _, watch as $, shallowRef as fe, onUnmounted as ve, computed as w, inject as y, provide as b, defineComponent as R, openBlock as I, createBlock as pe, Transition as he, withCtx as ge, createElementBlock as x, createElementVNode as P, withModifiers as me, normalizeClass as be, renderSlot as U, createCommentVNode as ye, render as _e, h as E, normalizeStyle as W, toRef as we, mergeProps as Oe, normalizeProps as H, guardReactiveProps as K, Fragment as Se, renderList as Ie } from "vue";
2
- var L;
3
- const C = typeof window < "u";
4
- C && ((L = window?.navigator) == null ? void 0 : L.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
5
- function xe(e) {
6
- return typeof e == "function" ? e() : m(e);
1
+ import { unref as y, getCurrentScope as He, onScopeDispose as Ie, getCurrentInstance as Te, onMounted as G, nextTick as ae, ref as m, watch as V, shallowRef as Ee, computed as g, onUnmounted as ie, inject as x, provide as O, defineComponent as z, openBlock as E, createBlock as se, Transition as ue, withCtx as ce, createElementBlock as P, createElementVNode as C, withModifiers as Ce, normalizeClass as Be, renderSlot as J, createCommentVNode as Pe, render as Re, h as U, normalizeStyle as X, useSlots as Fe, withDirectives as Ae, vShow as De, pushScopeId as $e, popScopeId as Le, toRef as Ve, mergeProps as ze, normalizeProps as Z, guardReactiveProps as ee, Fragment as Ke, renderList as je } from "vue";
2
+ var te;
3
+ const R = typeof window < "u";
4
+ R && ((te = window?.navigator) == null ? void 0 : te.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
5
+ function L(e) {
6
+ return typeof e == "function" ? e() : y(e);
7
7
  }
8
- function Pe(e) {
8
+ function de(e, l) {
9
+ function t(...n) {
10
+ e(() => l.apply(this, n), { fn: l, thisArg: this, args: n });
11
+ }
12
+ return t;
13
+ }
14
+ function Me(e, l = {}) {
15
+ let t, n;
16
+ return (r) => {
17
+ const a = L(e), c = L(l.maxWait);
18
+ if (t && clearTimeout(t), a <= 0 || c !== void 0 && c <= 0)
19
+ return n && (clearTimeout(n), n = null), r();
20
+ c && !n && (n = setTimeout(() => {
21
+ t && clearTimeout(t), n = null, r();
22
+ }, c)), t = setTimeout(() => {
23
+ n && clearTimeout(n), n = null, r();
24
+ }, a);
25
+ };
26
+ }
27
+ function ke(e, l = !0, t = !0) {
28
+ let n = 0, o, r = !0;
29
+ const a = () => {
30
+ o && (clearTimeout(o), o = void 0);
31
+ };
32
+ return (f) => {
33
+ const u = L(e), h = Date.now() - n;
34
+ if (a(), u <= 0)
35
+ return n = Date.now(), f();
36
+ h > u && (t || !r) ? (n = Date.now(), f()) : l && (o = setTimeout(() => {
37
+ n = Date.now(), r = !0, a(), f();
38
+ }, u)), !t && !o && (o = setTimeout(() => r = !0, u)), r = !1;
39
+ };
40
+ }
41
+ function Ne(e) {
9
42
  return e;
10
43
  }
11
- function Ce(e) {
12
- return ie() ? (ce(e), !0) : !1;
44
+ function Qe(e) {
45
+ return He() ? (Ie(e), !0) : !1;
46
+ }
47
+ function We(e, l = 200, t = {}) {
48
+ return de(Me(l, t), e);
13
49
  }
14
- function Ee(e, t = !0) {
15
- ue() ? V(e) : t ? e() : de(e);
50
+ function Ue(e, l = 200, t = !1, n = !0) {
51
+ return de(ke(l, t, n), e);
16
52
  }
17
- function D(e) {
18
- var t;
19
- const n = xe(e);
20
- return (t = n?.$el) != null ? t : n;
53
+ function qe(e, l = !0) {
54
+ Te() ? G(e) : l ? e() : ae(e);
21
55
  }
22
- const Ae = C ? window : void 0;
23
- C && window.document;
24
- C && window.navigator;
25
- C && window.location;
26
- function Te(e, t = !1) {
27
- const n = _(), o = () => n.value = Boolean(e());
28
- return o(), Ee(o, t), n;
56
+ function fe(e) {
57
+ var l;
58
+ const t = L(e);
59
+ return (l = t?.$el) != null ? l : t;
29
60
  }
30
- const A = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, T = "__vueuse_ssr_handlers__";
31
- A[T] = A[T] || {};
32
- A[T];
33
- var j = Object.getOwnPropertySymbols, $e = Object.prototype.hasOwnProperty, Re = Object.prototype.propertyIsEnumerable, Be = (e, t) => {
34
- var n = {};
35
- for (var o in e)
36
- $e.call(e, o) && t.indexOf(o) < 0 && (n[o] = e[o]);
37
- if (e != null && j)
38
- for (var o of j(e))
39
- t.indexOf(o) < 0 && Re.call(e, o) && (n[o] = e[o]);
40
- return n;
61
+ const Ye = R ? window : void 0;
62
+ R && window.document;
63
+ R && window.navigator;
64
+ R && window.location;
65
+ function Ge(e, l = !1) {
66
+ const t = m(), n = () => t.value = Boolean(e());
67
+ return n(), qe(n, l), t;
68
+ }
69
+ const q = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Y = "__vueuse_ssr_handlers__";
70
+ q[Y] = q[Y] || {};
71
+ q[Y];
72
+ var le = Object.getOwnPropertySymbols, Je = Object.prototype.hasOwnProperty, Xe = Object.prototype.propertyIsEnumerable, Ze = (e, l) => {
73
+ var t = {};
74
+ for (var n in e)
75
+ Je.call(e, n) && l.indexOf(n) < 0 && (t[n] = e[n]);
76
+ if (e != null && le)
77
+ for (var n of le(e))
78
+ l.indexOf(n) < 0 && Xe.call(e, n) && (t[n] = e[n]);
79
+ return t;
41
80
  };
42
- function ke(e, t, n = {}) {
43
- const o = n, { window: s = Ae } = o, a = Be(o, ["window"]);
44
- let l;
45
- const i = Te(() => s && "ResizeObserver" in s), r = () => {
46
- l && (l.disconnect(), l = void 0);
47
- }, u = $(() => D(e), (S) => {
48
- r(), i.value && s && S && (l = new ResizeObserver(t), l.observe(S, a));
49
- }, { immediate: !0, flush: "post" }), O = () => {
50
- r(), u();
81
+ function et(e, l, t = {}) {
82
+ const n = t, { window: o = Ye } = n, r = Ze(n, ["window"]);
83
+ let a;
84
+ const c = Ge(() => o && "ResizeObserver" in o), f = () => {
85
+ a && (a.disconnect(), a = void 0);
86
+ }, u = V(() => fe(e), (p) => {
87
+ f(), c.value && o && p && (a = new ResizeObserver(l), a.observe(p, r));
88
+ }, { immediate: !0, flush: "post" }), h = () => {
89
+ f(), u();
51
90
  };
52
- return Ce(O), {
53
- isSupported: i,
54
- stop: O
91
+ return Qe(h), {
92
+ isSupported: c,
93
+ stop: h
55
94
  };
56
95
  }
57
- function ze(e, t = { width: 0, height: 0 }, n = {}) {
58
- const { box: o = "content-box" } = n, s = _(t.width), a = _(t.height);
59
- return ke(e, ([l]) => {
60
- const i = o === "border-box" ? l.borderBoxSize : o === "content-box" ? l.contentBoxSize : l.devicePixelContentBoxSize;
61
- i ? (s.value = i.reduce((r, { inlineSize: u }) => r + u, 0), a.value = i.reduce((r, { blockSize: u }) => r + u, 0)) : (s.value = l.contentRect.width, a.value = l.contentRect.height);
62
- }, n), $(() => D(e), (l) => {
63
- s.value = l ? t.width : 0, a.value = l ? t.height : 0;
96
+ function tt(e, l = { width: 0, height: 0 }, t = {}) {
97
+ const { box: n = "content-box" } = t, o = m(l.width), r = m(l.height);
98
+ return et(e, ([a]) => {
99
+ const c = n === "border-box" ? a.borderBoxSize : n === "content-box" ? a.contentBoxSize : a.devicePixelContentBoxSize;
100
+ c ? (o.value = c.reduce((f, { inlineSize: u }) => f + u, 0), r.value = c.reduce((f, { blockSize: u }) => f + u, 0)) : (o.value = a.contentRect.width, r.value = a.contentRect.height);
101
+ }, t), V(() => fe(e), (a) => {
102
+ o.value = a ? l.width : 0, r.value = a ? l.height : 0;
64
103
  }), {
65
- width: s,
66
- height: a
104
+ width: o,
105
+ height: r
67
106
  };
68
107
  }
69
- var F;
108
+ var ne;
70
109
  (function(e) {
71
110
  e.UP = "UP", e.RIGHT = "RIGHT", e.DOWN = "DOWN", e.LEFT = "LEFT", e.NONE = "NONE";
72
- })(F || (F = {}));
73
- var He = Object.defineProperty, N = Object.getOwnPropertySymbols, Ke = Object.prototype.hasOwnProperty, Le = Object.prototype.propertyIsEnumerable, Q = (e, t, n) => t in e ? He(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, je = (e, t) => {
74
- for (var n in t || (t = {}))
75
- Ke.call(t, n) && Q(e, n, t[n]);
76
- if (N)
77
- for (var n of N(t))
78
- Le.call(t, n) && Q(e, n, t[n]);
111
+ })(ne || (ne = {}));
112
+ var lt = Object.defineProperty, oe = Object.getOwnPropertySymbols, nt = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, re = (e, l, t) => l in e ? lt(e, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[l] = t, rt = (e, l) => {
113
+ for (var t in l || (l = {}))
114
+ nt.call(l, t) && re(e, t, l[t]);
115
+ if (oe)
116
+ for (var t of oe(l))
117
+ ot.call(l, t) && re(e, t, l[t]);
79
118
  return e;
80
119
  };
81
- const Fe = {
120
+ const at = {
82
121
  easeInSine: [0.12, 0, 0.39, 0],
83
122
  easeOutSine: [0.61, 1, 0.88, 1],
84
123
  easeInOutSine: [0.37, 0, 0.63, 1],
@@ -104,142 +143,181 @@ const Fe = {
104
143
  easeOutBack: [0.34, 1.56, 0.64, 1],
105
144
  easeInOutBack: [0.68, -0.6, 0.32, 1.6]
106
145
  };
107
- je({
108
- linear: Pe
109
- }, Fe);
110
- function Ne(e, t) {
111
- const n = _(), o = ze(n), s = _([]), a = _(0), l = fe(e), i = _({ start: 0, end: 10 }), { itemHeight: r, overscan: u = 5 } = t, O = (c) => {
112
- const { start: h = 0 } = i.value;
113
- let v = 0, p = 0;
114
- for (let g = h; g < l.value.length; g++)
115
- if (v += r(g), v >= c) {
116
- p = g;
146
+ rt({
147
+ linear: Ne
148
+ }, at);
149
+ function it(e, l) {
150
+ const { itemHeight: t, overscan: n = 5 } = l, o = m(), r = tt(o);
151
+ let a;
152
+ const c = Ee(e), f = m(0), u = m({ start: 0, end: 10 });
153
+ let h = 0;
154
+ const p = m([]), s = g(() => {
155
+ let { sum: i, height: d } = { sum: 0, height: 0 };
156
+ return c.value.map((w, b) => (typeof t == "number" ? d = t : d = t(b), i += d, { height: d, sum: i }));
157
+ }), v = g(() => D(u.value.start)), H = g(() => typeof t == "number" ? s.value.length * t : s.value.at(-1)?.sum || 0), B = g(() => {
158
+ let i = p.value.length - n, d = Math.max(i - h, 0);
159
+ return p.value.slice(d, i);
160
+ });
161
+ G(() => {
162
+ }), ie(() => cancelAnimationFrame(a)), V(
163
+ [r.width, r.height, c],
164
+ ([i, d]) => {
165
+ (i || d) && F();
166
+ },
167
+ { deep: !0 }
168
+ );
169
+ function F() {
170
+ cancelAnimationFrame(a), a = requestAnimationFrame(I);
171
+ }
172
+ function I() {
173
+ if (o.value) {
174
+ f.value = o.value.scrollTop, h = K();
175
+ let i = A(f.value), d = i + h + n;
176
+ i = i - n, i = i < 0 ? 0 : i, d = d > c.value.length ? c.value.length : d, u.value = { start: i, end: d }, p.value = c.value.slice(i, d).map((w, b) => ({
177
+ data: w,
178
+ index: b + i
179
+ }));
180
+ }
181
+ }
182
+ function A(i) {
183
+ let d = Math.floor(s.value.length / 16), w = -1, b = -1;
184
+ for (let _ = 0; _ < 16; _++) {
185
+ if (s.value.at(d * _).sum >= i) {
186
+ w = Math.max(0, _ - 1);
117
187
  break;
118
188
  }
119
- return p - h;
120
- }, S = (c) => {
121
- let h = 0, v = 0;
122
- for (let p = 0; p < l.value.length; p++)
123
- if (h += r(p), h >= c) {
124
- v = p;
189
+ _ === 15 && (w = _);
190
+ }
191
+ w *= d;
192
+ for (let _ = w; _ < s.value.length; _++)
193
+ if (s.value[_].sum >= i) {
194
+ b = _;
125
195
  break;
126
196
  }
127
- return v;
128
- };
129
- let d;
130
- const f = () => {
131
- cancelAnimationFrame(d), d = requestAnimationFrame(B);
132
- }, B = () => {
133
- const c = n.value;
134
- if (c) {
135
- const h = S(c.scrollTop), v = O(c.clientHeight), p = h - u, g = h + v + u;
136
- i.value = {
137
- start: p < 0 ? 0 : p,
138
- end: g > l.value.length ? l.value.length : g
139
- }, s.value = l.value.slice(i.value.start, i.value.end).map((z, ae) => ({
140
- data: z,
141
- index: ae + i.value.start
142
- }));
197
+ return Math.max(0, b);
198
+ }
199
+ function K() {
200
+ let i = 0, d = 0, w = j();
201
+ for (let b = w; b < s.value.length && (d += s.value[b].height, !(d >= r.height.value)); b++, i++)
202
+ ;
203
+ return i;
204
+ }
205
+ function D(i) {
206
+ if (typeof t == "number")
207
+ return i * t;
208
+ let d = s.value[i];
209
+ return d.sum - d.height;
210
+ }
211
+ function $(i) {
212
+ return s.value.at(i) || { sum: 0, height: 0 };
213
+ }
214
+ function j() {
215
+ let i = u.value.start;
216
+ return i >= n && (i += n), i;
217
+ }
218
+ function M(i) {
219
+ if (o.value) {
220
+ const d = $(i);
221
+ o.value.scrollTop = d.sum - d.height, I();
143
222
  }
144
- };
145
- V(() => {
146
- }), ve(() => {
147
- cancelAnimationFrame(d);
148
- }), $(
149
- [o.width, o.height, l],
150
- () => {
151
- f();
152
- },
153
- { deep: !0 }
154
- );
155
- const k = w(() => typeof r == "number" ? l.value.length * r : l.value.reduce((c, h, v) => c + r(v), 0)), te = (c) => typeof r == "number" ? c * r : l.value.slice(0, c).reduce((v, p, g) => v + r(g), 0), ne = (c) => {
156
- n.value && (n.value.scrollTop = c, B());
157
- }, oe = w(() => te(i.value.start)), le = w(() => ({
223
+ }
224
+ const k = g(() => ({
158
225
  style: {
159
226
  width: "100%",
160
- height: `${k.value}px`
227
+ height: `${H.value}px`
161
228
  }
162
- })), se = w(() => ({
229
+ })), N = g(() => ({
163
230
  style: {
164
- transform: `translate3d(0, ${oe.value}px, 0)`,
231
+ transform: `translate3d(0, ${v.value}px, 0)`,
165
232
  "will-change": "transform"
166
233
  }
167
- })), re = { overflowY: "auto" };
234
+ })), Q = {
235
+ overflowY: "auto"
236
+ };
168
237
  return {
169
- list: s,
170
- totalHeight: k,
171
- clientHeight: o.height,
172
- scrollTo: ne,
173
- scrollTop: a,
238
+ list: p,
239
+ visiableList: B,
240
+ getItemHeightData: $,
241
+ totalHeight: H,
242
+ clientHeight: r.height,
243
+ scrollTo: M,
244
+ scrollTop: f,
174
245
  containerProps: {
175
- ref: n,
176
- onScroll: (c) => {
177
- c.target && (a.value = c.target.scrollTop), f();
246
+ ref: o,
247
+ onScroll: () => {
248
+ F();
178
249
  },
179
- style: re
250
+ style: Q
180
251
  },
181
- wrapperProps: le,
182
- innerProps: se
252
+ wrapperProps: k,
253
+ innerProps: N
183
254
  };
184
255
  }
185
- const M = Symbol(), q = Symbol(), G = Symbol(), Y = Symbol(), J = Symbol(), X = Symbol(), Z = Symbol(), ee = Symbol();
186
- function Ye() {
187
- const e = y(M), t = y(q), n = y(G), o = y(Y), s = y(J), a = y(X), l = y(Z), i = y(ee);
256
+ const ve = Symbol(), pe = Symbol(), he = Symbol(), ge = Symbol(), me = Symbol(), be = Symbol(), _e = Symbol(), ye = Symbol(), we = Symbol();
257
+ function _t() {
258
+ const { voidFn: e, boolFn: l, boolRef: t, arrayRef: n } = {
259
+ voidFn: (v) => {
260
+ },
261
+ boolFn: (v) => !1,
262
+ boolRef: g(() => !1),
263
+ arrayRef: g(() => [])
264
+ }, o = x(ge, n), r = x(he, l), a = x(ye, t), c = x(pe, e), f = x(ve, e), u = x(me, e), h = x(be, e), p = x(_e, e), s = x(we, e);
188
265
  return {
189
- toggleAll: e,
190
- toggle: t,
191
- isSelected: n,
192
266
  selected: o,
193
- select: s,
194
- unselect: a,
195
- isAllSelected: l,
196
- unselectAll: i
267
+ isSelected: r,
268
+ isAllSelected: a,
269
+ toggle: c,
270
+ toggleAll: f,
271
+ select: u,
272
+ selectAll: h,
273
+ unselect: p,
274
+ unselectAll: s
197
275
  };
198
276
  }
199
- function Je(e, t) {
200
- const n = _({}), o = w(() => e.value.filter((d) => n.value[d[t]])), s = w(() => o.value.length != 0 && Object.keys(n.value).length == e.value.length);
201
- function a() {
202
- e.value.forEach((d) => {
203
- n.value[d[t]] = !0;
277
+ function yt(e, l) {
278
+ const t = m({}), n = g(() => e.value.filter((s) => t.value[s[l]])), o = g(() => n.value.length != 0 && Object.keys(t.value).length == e.value.length);
279
+ function r() {
280
+ e.value.forEach((s) => {
281
+ t.value[s[l]] = !0;
204
282
  });
205
283
  }
206
- function l() {
207
- n.value = {};
284
+ function a() {
285
+ t.value = {};
208
286
  }
209
- function i(d) {
210
- d.forEach((f) => {
211
- n.value[f[t]] || (n.value[f[t]] = !0);
287
+ function c(s) {
288
+ s.forEach((v) => {
289
+ t.value[v[l]] || (t.value[v[l]] = !0);
212
290
  });
213
291
  }
214
- function r(d) {
215
- d.forEach((f) => {
216
- n.value[f[t]] && delete n.value[f[t]];
292
+ function f(s) {
293
+ s.forEach((v) => {
294
+ t.value[v[l]] && delete t.value[v[l]];
217
295
  });
218
296
  }
219
- function u(d) {
220
- return !!n.value[d[t]];
297
+ function u(s) {
298
+ return !!t.value[s[l]];
221
299
  }
222
- function O(d) {
223
- d.forEach((f) => {
224
- u(f) ? delete n.value[f[t]] : n.value[f[t]] = !0;
300
+ function h(s) {
301
+ s.forEach((v) => {
302
+ u(v) ? delete t.value[v[l]] : t.value[v[l]] = !0;
225
303
  });
226
304
  }
227
- function S() {
228
- s.value ? l() : a();
305
+ function p() {
306
+ o.value ? a() : r();
229
307
  }
230
- return b(M, S), b(q, O), b(G, u), b(Y, o), b(J, i), b(X, r), b(Z, s), b(ee, l), {
231
- selected: o,
232
- select: i,
233
- selectAll: a,
234
- unselect: r,
235
- unselectAll: l,
236
- toggle: O,
237
- toggleAll: S,
308
+ return O(ve, p), O(pe, h), O(he, u), O(ge, n), O(me, c), O(be, r), O(_e, f), O(ye, o), O(we, a), {
309
+ selected: n,
310
+ select: c,
311
+ selectAll: r,
312
+ unselect: f,
313
+ unselectAll: a,
314
+ toggle: h,
315
+ toggleAll: p,
238
316
  isSelected: u,
239
- isAllSelected: s
317
+ isAllSelected: o
240
318
  };
241
319
  }
242
- const Qe = Symbol(), Ve = /* @__PURE__ */ R({
320
+ const st = Symbol(), ut = /* @__PURE__ */ z({
243
321
  __name: "Dialog",
244
322
  props: {
245
323
  visiable: { type: Boolean, default: !1 },
@@ -247,118 +325,251 @@ const Qe = Symbol(), Ve = /* @__PURE__ */ R({
247
325
  dialogClass: { default: "" }
248
326
  },
249
327
  emits: ["update:visiable"],
250
- setup(e, { emit: t }) {
251
- const n = e, o = () => {
252
- n.closeOnClickOverlay && t("update:visiable", !1);
328
+ setup(e, { emit: l }) {
329
+ const t = e, n = () => {
330
+ t.closeOnClickOverlay && l("update:visiable", !1);
253
331
  };
254
- return b(Qe, () => t("update:visiable", !1)), (s, a) => (I(), pe(he, { name: "modal" }, {
255
- default: ge(() => [
256
- e.visiable ? (I(), x("div", {
332
+ return O(st, () => l("update:visiable", !1)), (o, r) => (E(), se(ue, { name: "modal" }, {
333
+ default: ce(() => [
334
+ e.visiable ? (E(), P("div", {
257
335
  key: 0,
258
- onClick: o,
336
+ onClick: n,
259
337
  class: "modal absolute inset-0 bottom-0 z-50 flex bg-stone-900 bg-opacity-50"
260
338
  }, [
261
- P("div", {
262
- onClick: a[0] || (a[0] = me(() => {
339
+ C("div", {
340
+ onClick: r[0] || (r[0] = Ce(() => {
263
341
  }, ["stop"])),
264
- class: be(["dialog m-auto flex flex-col", e.dialogClass])
342
+ class: Be(["dialog m-auto flex flex-col", e.dialogClass])
265
343
  }, [
266
- U(s.$slots, "default")
344
+ J(o.$slots, "default")
267
345
  ], 2)
268
- ])) : ye("", !0)
346
+ ])) : Pe("", !0)
269
347
  ]),
270
348
  _: 3
271
349
  }));
272
350
  }
273
351
  });
274
- function Xe(e) {
275
- function t(n, o) {
276
- const s = document.createElement("div"), a = {
352
+ function wt(e) {
353
+ function l(t, n) {
354
+ const o = document.createElement("div"), r = {
277
355
  setup() {
278
- return () => E(
279
- Ve,
356
+ return () => U(
357
+ ut,
280
358
  {
281
359
  visiable: !0,
282
360
  "onUpdate:visiable": () => {
283
- s?.remove();
361
+ o?.remove();
284
362
  },
285
363
  ...e
286
364
  },
287
365
  {
288
- default: () => E(n, o)
366
+ default: () => U(t, n)
289
367
  }
290
368
  );
291
369
  }
292
370
  };
293
- return document.body.appendChild(s), _e(E(a), s), {
294
- close: () => s?.remove()
371
+ return document.body.appendChild(o), Re(U(r), o), {
372
+ close: () => o?.remove()
295
373
  };
296
374
  }
297
375
  return {
298
- create: t
376
+ create: l
299
377
  };
300
378
  }
301
- const Ue = ["xlink:href", "fill", "color"], Ze = /* @__PURE__ */ R({
379
+ const ct = ["xlink:href", "fill", "color"], St = /* @__PURE__ */ z({
302
380
  __name: "SvgIcon",
303
381
  props: {
304
- prefix: { default: "icon" },
305
382
  name: null,
383
+ prefix: { default: "icon" },
306
384
  color: { default: "#FFF" },
307
- width: { default: 16 },
308
- height: { default: 16 }
385
+ width: null,
386
+ height: null
309
387
  },
310
388
  setup(e) {
311
- const t = e, n = w(() => `#${t.prefix}-${t.name}`), o = w(() => ({
312
- width: t.width,
313
- height: t.height
389
+ const l = e, t = g(() => `#${l.prefix}-${l.name}`), n = g(() => ({
390
+ width: l.width,
391
+ height: l.height,
392
+ aspectRatio: l.width && l.height ? void 0 : "1/1"
314
393
  }));
315
- return (s, a) => (I(), x("svg", {
394
+ return (o, r) => (E(), P("svg", {
316
395
  "aria-hidden": "",
317
- style: W(m(o))
396
+ style: X(y(n))
318
397
  }, [
319
- P("use", {
320
- "xlink:href": m(n),
398
+ C("use", {
399
+ "xlink:href": y(t),
321
400
  fill: e.color,
322
401
  color: e.color
323
- }, null, 8, Ue)
402
+ }, null, 8, ct)
324
403
  ], 4));
325
404
  }
326
- }), We = { class: "virtualListWrapper" }, De = {
405
+ });
406
+ function dt(e) {
407
+ const { containerEl: l, sliderEl: t, autoHeight: n, performance: o = {} } = e, r = m(!0), a = We(N, 1e3), c = Ue(W, 1e3, !0, !0);
408
+ let f, u = "";
409
+ const h = m(0), p = m(0), s = m(0), v = m({
410
+ top: 0,
411
+ scrollTop: 0,
412
+ scrollHeight: 0,
413
+ clientHeight: 0
414
+ }), H = m({
415
+ clientHeight: 0
416
+ }), B = g(() => !!p.value), F = g(() => v.value.scrollHeight > v.value.clientHeight), I = g(() => v.value.clientHeight - H.value.clientHeight), A = g(() => v.value.scrollHeight - v.value.clientHeight), K = g(() => Math.max(
417
+ v.value.clientHeight / v.value.scrollHeight,
418
+ 0.05
419
+ )), D = g(() => K.value * v.value.clientHeight), $ = g(() => ({
420
+ willChange: "transform",
421
+ transform: `translate3d(0,${s.value}px,0)`,
422
+ height: n ? `${D.value}px` : void 0
423
+ }));
424
+ function j(T) {
425
+ p.value = T.clientY - t.value.getBoundingClientRect().top || 1, u = getComputedStyle(l.value).scrollBehavior, u === "smooth" && (l.value.style.scrollBehavior = "unset");
426
+ }
427
+ function M() {
428
+ l.value.style.scrollBehavior = u, p.value = 0, a();
429
+ }
430
+ function k() {
431
+ r.value = !1;
432
+ }
433
+ function N() {
434
+ B.value || (r.value = !0);
435
+ }
436
+ function Q(T) {
437
+ if (!B.value)
438
+ return;
439
+ let S = T.clientY - v.value.top - p.value;
440
+ S < 0 ? s.value = 0 : S >= I.value ? s.value = I.value : s.value = S, l.value.scrollTo({
441
+ top: s.value / I.value * A.value
442
+ });
443
+ }
444
+ function i() {
445
+ B.value || d();
446
+ }
447
+ function d() {
448
+ cancelAnimationFrame(f), f = requestAnimationFrame(w);
449
+ }
450
+ function w() {
451
+ l.value && (h.value = o.scrollTop?.value ?? l.value.scrollTop, s.value = h.value / A.value * I.value);
452
+ }
453
+ function b(T) {
454
+ let S = "addEventListener";
455
+ T === "add" ? S = "addEventListener" : S = "removeEventListener", t.value?.[S]("pointerdown", j, {
456
+ passive: !0
457
+ }), window[S]("pointermove", Q, { passive: !0 }), window[S]("pointerup", M, { passive: !0 });
458
+ }
459
+ const _ = new MutationObserver((T) => {
460
+ T.map((xe) => xe.oldValue).join().includes("height") ? W() : H.value.clientHeight === 0 && c();
461
+ });
462
+ function W() {
463
+ v.value.top = l.value?.getBoundingClientRect().top ?? 0, v.value.scrollHeight = l.value?.scrollHeight ?? 0, v.value.clientHeight = l.value?.clientHeight ?? 0, n ? H.value.clientHeight = D.value : H.value.clientHeight = t.value?.clientHeight ?? 0;
464
+ }
465
+ function Oe() {
466
+ l.value && t.value ? (l.value.addEventListener("scroll", i, {
467
+ passive: !0
468
+ }), b("add"), _.observe(l.value, {
469
+ subtree: !0,
470
+ attributeOldValue: !0,
471
+ attributeFilter: ["style"]
472
+ }), setTimeout(() => {
473
+ W();
474
+ }, 100)) : console.error("useScrollBar:", "\u521D\u59CB\u5316\u5931\u8D25!", { containerEl: l, sliderEl: t });
475
+ }
476
+ return V(h, () => {
477
+ k(), a();
478
+ }), {
479
+ isScrollEnd: r,
480
+ isDragSlider: B,
481
+ scrollable: F,
482
+ sliderPos: $,
483
+ init: Oe,
484
+ modifySliderEventListener: b
485
+ };
486
+ }
487
+ const ft = (e) => ($e("data-v-d564e88d"), e = e(), Le(), e), vt = /* @__PURE__ */ ft(() => /* @__PURE__ */ C("div", {
488
+ w: "6px",
489
+ h: "full",
490
+ bg: "black/20",
491
+ rounded: "3px",
492
+ mr: "3px"
493
+ }, null, -1)), pt = /* @__PURE__ */ z({
494
+ __name: "ScrollBar",
495
+ props: {
496
+ containerEl: null,
497
+ autoHide: { type: Boolean },
498
+ autoHeight: { type: Boolean },
499
+ performance: null
500
+ },
501
+ setup(e, { expose: l }) {
502
+ const t = e, n = !!Fe().default, o = m(null), r = g(() => t.containerEl), a = dt({
503
+ containerEl: r,
504
+ sliderEl: o,
505
+ autoHeight: n ? t.autoHeight : !0,
506
+ performance: t.performance
507
+ }), { scrollable: c, isScrollEnd: f, sliderPos: u } = a, h = t.autoHide ? g(() => !f.value) : g(() => c.value);
508
+ return G(() => {
509
+ ae(() => {
510
+ a.init();
511
+ });
512
+ }), ie(() => {
513
+ a.modifySliderEventListener("remove");
514
+ }), l({ uScrollBarReturn: a }), (p, s) => (E(), se(ue, null, {
515
+ default: ce(() => [
516
+ Ae(C("div", {
517
+ ref_key: "sliderRef",
518
+ ref: o,
519
+ class: "z-100 absolute right-0",
520
+ style: X([{ "touch-action": "none" }, y(u)])
521
+ }, [
522
+ J(p.$slots, "default", {}, () => [
523
+ vt
524
+ ], !0)
525
+ ], 4), [
526
+ [De, y(h)]
527
+ ])
528
+ ]),
529
+ _: 3
530
+ }));
531
+ }
532
+ });
533
+ const Se = (e, l) => {
534
+ const t = e.__vccOpts || e;
535
+ for (const [n, o] of l)
536
+ t[n] = o;
537
+ return t;
538
+ }, Ot = /* @__PURE__ */ Se(pt, [["__scopeId", "data-v-d564e88d"]]), ht = { class: "virtualListWrapper" }, gt = {
327
539
  inheritAttrs: !1
328
- }, Me = /* @__PURE__ */ R({
329
- ...De,
540
+ }, mt = /* @__PURE__ */ z({
541
+ ...gt,
330
542
  __name: "VirtualList",
331
543
  props: {
332
544
  data: null,
333
- itemHeight: null
545
+ itemHeight: null,
546
+ overscan: { default: 10 }
334
547
  },
335
- setup(e) {
336
- const t = e, { list: n, containerProps: o, wrapperProps: s, innerProps: a } = Ne(
337
- we(t, "data"),
338
- {
339
- itemHeight: (l) => t.itemHeight(0),
340
- overscan: 10
341
- }
342
- );
343
- return (l, i) => (I(), x("div", We, [
344
- P("div", Oe({
345
- onScrollPassive: i[0] || (i[0] = (...r) => m(o).onScroll && m(o).onScroll(...r)),
346
- ref: m(o).ref,
347
- style: m(o).style,
548
+ setup(e, { expose: l }) {
549
+ const t = e, n = it(Ve(t, "data"), {
550
+ itemHeight: (u) => t.itemHeight(t.data[u]),
551
+ overscan: t.overscan
552
+ }), { list: o, containerProps: r, wrapperProps: a, innerProps: c, getItemHeightData: f } = n;
553
+ return l({
554
+ vListReturn: n
555
+ }), (u, h) => (E(), P("div", ht, [
556
+ C("div", ze({
557
+ onScrollPassive: h[0] || (h[0] = (...p) => y(r).onScroll && y(r).onScroll(...p)),
558
+ ref: y(r).ref,
348
559
  class: "virtualList"
349
- }, l.$attrs), [
350
- P("div", H(K(m(s))), [
351
- P("div", H(K(m(a))), [
352
- (I(!0), x(Se, null, Ie(m(n), ({ index: r, data: u }) => (I(), x("div", {
353
- key: r,
354
- style: W({
355
- height: `${e.itemHeight(u)}px`,
560
+ }, u.$attrs), [
561
+ C("div", Z(ee(y(a))), [
562
+ C("div", Z(ee(y(c))), [
563
+ (E(!0), P(Ke, null, je(y(o), ({ index: p, data: s }) => (E(), P("div", {
564
+ key: p,
565
+ style: X({
566
+ height: `${y(f)(p).height}px`,
356
567
  display: "flex"
357
568
  })
358
569
  }, [
359
- U(l.$slots, "default", {
360
- data: u,
361
- index: r
570
+ J(u.$slots, "default", {
571
+ data: s,
572
+ index: p
362
573
  }, void 0, !0)
363
574
  ], 4))), 128))
364
575
  ], 16)
@@ -367,26 +578,23 @@ const Ue = ["xlink:href", "fill", "color"], Ze = /* @__PURE__ */ R({
367
578
  ]));
368
579
  }
369
580
  });
370
- const qe = (e, t) => {
371
- const n = e.__vccOpts || e;
372
- for (const [o, s] of t)
373
- n[o] = s;
374
- return n;
375
- }, et = /* @__PURE__ */ qe(Me, [["__scopeId", "data-v-06e648eb"]]);
581
+ const xt = /* @__PURE__ */ Se(mt, [["__scopeId", "data-v-134ad8ab"]]);
376
582
  export {
377
- Ze as SvgIcon,
378
- et as VirtualList,
379
- Y as allSelectedKey,
380
- Qe as closeDialogKey,
381
- Xe as dialogController,
382
- Z as isAllSelectedKey,
383
- G as isSelectedKey,
384
- J as selectKey,
385
- M as toggleAllKey,
386
- q as toggleKey,
387
- ee as unselectAllKey,
388
- X as unselectKey,
389
- Je as useSelectable,
390
- Ye as useSelectableInjectors,
391
- Ne as useVirtualList
583
+ Ot as ScrollBar,
584
+ St as SvgIcon,
585
+ xt as VirtualList,
586
+ ge as allSelectedKey,
587
+ st as closeDialogKey,
588
+ wt as dialogController,
589
+ ye as isAllSelectedKey,
590
+ he as isSelectedKey,
591
+ be as selectAllKey,
592
+ me as selectKey,
593
+ ve as toggleAllKey,
594
+ pe as toggleKey,
595
+ we as unselectAllKey,
596
+ _e as unselectKey,
597
+ yt as useSelectable,
598
+ _t as useSelectableInjectors,
599
+ it as useVirtualList
392
600
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(c,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(c=typeof globalThis<"u"?globalThis:c||self,e(c.ui={},c.Vue))})(this,function(c,e){"use strict";var A;const O=typeof window<"u";O&&((A=window?.navigator)==null?void 0:A.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function Q(t){return typeof t=="function"?t():e.unref(t)}function M(t){return t}function D(t){return e.getCurrentScope()?(e.onScopeDispose(t),!0):!1}function U(t,n=!0){e.getCurrentInstance()?e.onMounted(t):n?t():e.nextTick(t)}function K(t){var n;const o=Q(t);return(n=o?.$el)!=null?n:o}const W=O?window:void 0;O&&window.document,O&&window.navigator,O&&window.location;function q(t,n=!1){const o=e.ref(),l=()=>o.value=Boolean(t());return l(),U(l,n),o}const S=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},v="__vueuse_ssr_handlers__";S[v]=S[v]||{},S[v];var x=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable,J=(t,n)=>{var o={};for(var l in t)G.call(t,l)&&n.indexOf(l)<0&&(o[l]=t[l]);if(t!=null&&x)for(var l of x(t))n.indexOf(l)<0&&Y.call(t,l)&&(o[l]=t[l]);return o};function X(t,n,o={}){const l=o,{window:s=W}=l,a=J(l,["window"]);let r;const d=q(()=>s&&"ResizeObserver"in s),i=()=>{r&&(r.disconnect(),r=void 0)},f=e.watch(()=>K(t),w=>{i(),d.value&&s&&w&&(r=new ResizeObserver(n),r.observe(w,a))},{immediate:!0,flush:"post"}),_=()=>{i(),f()};return D(_),{isSupported:d,stop:_}}function Z(t,n={width:0,height:0},o={}){const{box:l="content-box"}=o,s=e.ref(n.width),a=e.ref(n.height);return X(t,([r])=>{const d=l==="border-box"?r.borderBoxSize:l==="content-box"?r.contentBoxSize:r.devicePixelContentBoxSize;d?(s.value=d.reduce((i,{inlineSize:f})=>i+f,0),a.value=d.reduce((i,{blockSize:f})=>i+f,0)):(s.value=r.contentRect.width,a.value=r.contentRect.height)},o),e.watch(()=>K(t),r=>{s.value=r?n.width:0,a.value=r?n.height:0}),{width:s,height:a}}var $;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})($||($={}));var ee=Object.defineProperty,V=Object.getOwnPropertySymbols,te=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable,R=(t,n,o)=>n in t?ee(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,oe=(t,n)=>{for(var o in n||(n={}))te.call(n,o)&&R(t,o,n[o]);if(V)for(var o of V(n))ne.call(n,o)&&R(t,o,n[o]);return t};oe({linear:M},{easeInSine:[.12,0,.39,0],easeOutSine:[.61,1,.88,1],easeInOutSine:[.37,0,.63,1],easeInQuad:[.11,0,.5,0],easeOutQuad:[.5,1,.89,1],easeInOutQuad:[.45,0,.55,1],easeInCubic:[.32,0,.67,0],easeOutCubic:[.33,1,.68,1],easeInOutCubic:[.65,0,.35,1],easeInQuart:[.5,0,.75,0],easeOutQuart:[.25,1,.5,1],easeInOutQuart:[.76,0,.24,1],easeInQuint:[.64,0,.78,0],easeOutQuint:[.22,1,.36,1],easeInOutQuint:[.83,0,.17,1],easeInExpo:[.7,0,.84,0],easeOutExpo:[.16,1,.3,1],easeInOutExpo:[.87,0,.13,1],easeInCirc:[.55,0,1,.45],easeOutCirc:[0,.55,.45,1],easeInOutCirc:[.85,0,.15,1],easeInBack:[.36,0,.66,-.56],easeOutBack:[.34,1.56,.64,1],easeInOutBack:[.68,-.6,.32,1.6]});function N(t,n){const o=e.ref(),l=Z(o),s=e.ref([]),a=e.ref(0),r=e.shallowRef(t),d=e.ref({start:0,end:10}),{itemHeight:i,overscan:f=5}=n,_=u=>{const{start:y=0}=d.value;let g=0,m=0;for(let b=y;b<r.value.length;b++)if(g+=i(b),g>=u){m=b;break}return m-y},w=u=>{let y=0,g=0;for(let m=0;m<r.value.length;m++)if(y+=i(m),y>=u){g=m;break}return g};let p;const h=()=>{cancelAnimationFrame(p),p=requestAnimationFrame(L)},L=()=>{const u=o.value;if(u){const y=w(u.scrollTop),g=_(u.clientHeight),m=y-f,b=y+g+f;d.value={start:m<0?0:m,end:b>r.value.length?r.value.length:b},s.value=r.value.slice(d.value.start,d.value.end).map((F,we)=>({data:F,index:we+d.value.start}))}};e.onMounted(()=>{}),e.onUnmounted(()=>{cancelAnimationFrame(p)}),e.watch([l.width,l.height,r],()=>{h()},{deep:!0});const H=e.computed(()=>typeof i=="number"?r.value.length*i:r.value.reduce((u,y,g)=>u+i(g),0)),he=u=>typeof i=="number"?u*i:r.value.slice(0,u).reduce((g,m,b)=>g+i(b),0),ge=u=>{o.value&&(o.value.scrollTop=u,L())},me=e.computed(()=>he(d.value.start)),ye=e.computed(()=>({style:{width:"100%",height:`${H.value}px`}})),be=e.computed(()=>({style:{transform:`translate3d(0, ${me.value}px, 0)`,"will-change":"transform"}})),_e={overflowY:"auto"};return{list:s,totalHeight:H,clientHeight:l.height,scrollTo:ge,scrollTop:a,containerProps:{ref:o,onScroll:u=>{u.target&&(a.value=u.target.scrollTop),h()},style:_e},wrapperProps:ye,innerProps:be}}const I=Symbol(),P=Symbol(),C=Symbol(),E=Symbol(),B=Symbol(),T=Symbol(),j=Symbol(),k=Symbol();function le(){const t=e.inject(I),n=e.inject(P),o=e.inject(C),l=e.inject(E),s=e.inject(B),a=e.inject(T),r=e.inject(j),d=e.inject(k);return{toggleAll:t,toggle:n,isSelected:o,selected:l,select:s,unselect:a,isAllSelected:r,unselectAll:d}}function re(t,n){const o=e.ref({}),l=e.computed(()=>t.value.filter(p=>o.value[p[n]])),s=e.computed(()=>l.value.length!=0&&Object.keys(o.value).length==t.value.length);function a(){t.value.forEach(p=>{o.value[p[n]]=!0})}function r(){o.value={}}function d(p){p.forEach(h=>{o.value[h[n]]||(o.value[h[n]]=!0)})}function i(p){p.forEach(h=>{o.value[h[n]]&&delete o.value[h[n]]})}function f(p){return!!o.value[p[n]]}function _(p){p.forEach(h=>{f(h)?delete o.value[h[n]]:o.value[h[n]]=!0})}function w(){s.value?r():a()}return e.provide(I,w),e.provide(P,_),e.provide(C,f),e.provide(E,l),e.provide(B,d),e.provide(T,i),e.provide(j,s),e.provide(k,r),{selected:l,select:d,selectAll:a,unselect:i,unselectAll:r,toggle:_,toggleAll:w,isSelected:f,isAllSelected:s}}const z=Symbol(),se=e.defineComponent({__name:"Dialog",props:{visiable:{type:Boolean,default:!1},closeOnClickOverlay:{type:Boolean,default:!0},dialogClass:{default:""}},emits:["update:visiable"],setup(t,{emit:n}){const o=t,l=()=>{o.closeOnClickOverlay&&n("update:visiable",!1)};return e.provide(z,()=>n("update:visiable",!1)),(s,a)=>(e.openBlock(),e.createBlock(e.Transition,{name:"modal"},{default:e.withCtx(()=>[t.visiable?(e.openBlock(),e.createElementBlock("div",{key:0,onClick:l,class:"modal absolute inset-0 bottom-0 z-50 flex bg-stone-900 bg-opacity-50"},[e.createElementVNode("div",{onClick:a[0]||(a[0]=e.withModifiers(()=>{},["stop"])),class:e.normalizeClass(["dialog m-auto flex flex-col",t.dialogClass])},[e.renderSlot(s.$slots,"default")],2)])):e.createCommentVNode("",!0)]),_:3}))}});function ie(t){function n(o,l){const s=document.createElement("div"),a={setup(){return()=>e.h(se,{visiable:!0,"onUpdate:visiable":()=>{s?.remove()},...t},{default:()=>e.h(o,l)})}};return document.body.appendChild(s),e.render(e.h(a),s),{close:()=>s?.remove()}}return{create:n}}const ae=["xlink:href","fill","color"],ce=e.defineComponent({__name:"SvgIcon",props:{prefix:{default:"icon"},name:null,color:{default:"#FFF"},width:{default:16},height:{default:16}},setup(t){const n=t,o=e.computed(()=>`#${n.prefix}-${n.name}`),l=e.computed(()=>({width:n.width,height:n.height}));return(s,a)=>(e.openBlock(),e.createElementBlock("svg",{"aria-hidden":"",style:e.normalizeStyle(e.unref(l))},[e.createElementVNode("use",{"xlink:href":e.unref(o),fill:t.color,color:t.color},null,8,ae)],4))}}),de={class:"virtualListWrapper"},ue={inheritAttrs:!1},fe=e.defineComponent({...ue,__name:"VirtualList",props:{data:null,itemHeight:null},setup(t){const n=t,{list:o,containerProps:l,wrapperProps:s,innerProps:a}=N(e.toRef(n,"data"),{itemHeight:r=>n.itemHeight(0),overscan:10});return(r,d)=>(e.openBlock(),e.createElementBlock("div",de,[e.createElementVNode("div",e.mergeProps({onScrollPassive:d[0]||(d[0]=(...i)=>e.unref(l).onScroll&&e.unref(l).onScroll(...i)),ref:e.unref(l).ref,style:e.unref(l).style,class:"virtualList"},r.$attrs),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(s))),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(a))),[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(o),({index:i,data:f})=>(e.openBlock(),e.createElementBlock("div",{key:i,style:e.normalizeStyle({height:`${t.itemHeight(f)}px`,display:"flex"})},[e.renderSlot(r.$slots,"default",{data:f,index:i},void 0,!0)],4))),128))],16)],16)],16)]))}}),Se="",pe=((t,n)=>{const o=t.__vccOpts||t;for(const[l,s]of n)o[l]=s;return o})(fe,[["__scopeId","data-v-06e648eb"]]);c.SvgIcon=ce,c.VirtualList=pe,c.allSelectedKey=E,c.closeDialogKey=z,c.dialogController=ie,c.isAllSelectedKey=j,c.isSelectedKey=C,c.selectKey=B,c.toggleAllKey=I,c.toggleKey=P,c.unselectAllKey=k,c.unselectKey=T,c.useSelectable=re,c.useSelectableInjectors=le,c.useVirtualList=N,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(g,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(g=typeof globalThis<"u"?globalThis:g||self,e(g.ui={},g.Vue))})(this,function(g,e){"use strict";var G;const I=typeof window<"u";I&&((G=window?.navigator)==null?void 0:G.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function B(t){return typeof t=="function"?t():e.unref(t)}function J(t,l){function n(...o){t(()=>l.apply(this,o),{fn:l,thisArg:this,args:o})}return n}function ie(t,l={}){let n,o;return i=>{const a=B(t),d=B(l.maxWait);if(n&&clearTimeout(n),a<=0||d!==void 0&&d<=0)return o&&(clearTimeout(o),o=null),i();d&&!o&&(o=setTimeout(()=>{n&&clearTimeout(n),o=null,i()},d)),n=setTimeout(()=>{o&&clearTimeout(o),o=null,i()},a)}}function ae(t,l=!0,n=!0){let o=0,r,i=!0;const a=()=>{r&&(clearTimeout(r),r=void 0)};return p=>{const u=B(t),v=Date.now()-o;if(a(),u<=0)return o=Date.now(),p();v>u&&(n||!i)?(o=Date.now(),p()):l&&(r=setTimeout(()=>{o=Date.now(),i=!0,a(),p()},u)),!n&&!r&&(r=setTimeout(()=>i=!0,u)),i=!1}}function se(t){return t}function ce(t){return e.getCurrentScope()?(e.onScopeDispose(t),!0):!1}function ue(t,l=200,n={}){return J(ie(l,n),t)}function de(t,l=200,n=!1,o=!0){return J(ae(l,n,o),t)}function fe(t,l=!0){e.getCurrentInstance()?e.onMounted(t):l?t():e.nextTick(t)}function X(t){var l;const n=B(t);return(l=n?.$el)!=null?l:n}const pe=I?window:void 0;I&&window.document,I&&window.navigator,I&&window.location;function he(t,l=!1){const n=e.ref(),o=()=>n.value=Boolean(t());return o(),fe(o,l),n}const R=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},A="__vueuse_ssr_handlers__";R[A]=R[A]||{},R[A];var Z=Object.getOwnPropertySymbols,me=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable,ve=(t,l)=>{var n={};for(var o in t)me.call(t,o)&&l.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&Z)for(var o of Z(t))l.indexOf(o)<0&&ge.call(t,o)&&(n[o]=t[o]);return n};function be(t,l,n={}){const o=n,{window:r=pe}=o,i=ve(o,["window"]);let a;const d=he(()=>r&&"ResizeObserver"in r),p=()=>{a&&(a.disconnect(),a=void 0)},u=e.watch(()=>X(t),m=>{p(),d.value&&r&&m&&(a=new ResizeObserver(l),a.observe(m,i))},{immediate:!0,flush:"post"}),v=()=>{p(),u()};return ce(v),{isSupported:d,stop:v}}function ye(t,l={width:0,height:0},n={}){const{box:o="content-box"}=n,r=e.ref(l.width),i=e.ref(l.height);return be(t,([a])=>{const d=o==="border-box"?a.borderBoxSize:o==="content-box"?a.contentBoxSize:a.devicePixelContentBoxSize;d?(r.value=d.reduce((p,{inlineSize:u})=>p+u,0),i.value=d.reduce((p,{blockSize:u})=>p+u,0)):(r.value=a.contentRect.width,i.value=a.contentRect.height)},n),e.watch(()=>X(t),a=>{r.value=a?l.width:0,i.value=a?l.height:0}),{width:r,height:i}}var ee;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})(ee||(ee={}));var _e=Object.defineProperty,te=Object.getOwnPropertySymbols,we=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable,ne=(t,l,n)=>l in t?_e(t,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[l]=n,Oe=(t,l)=>{for(var n in l||(l={}))we.call(l,n)&&ne(t,n,l[n]);if(te)for(var n of te(l))Se.call(l,n)&&ne(t,n,l[n]);return t};Oe({linear:se},{easeInSine:[.12,0,.39,0],easeOutSine:[.61,1,.88,1],easeInOutSine:[.37,0,.63,1],easeInQuad:[.11,0,.5,0],easeOutQuad:[.5,1,.89,1],easeInOutQuad:[.45,0,.55,1],easeInCubic:[.32,0,.67,0],easeOutCubic:[.33,1,.68,1],easeInOutCubic:[.65,0,.35,1],easeInQuart:[.5,0,.75,0],easeOutQuart:[.25,1,.5,1],easeInOutQuart:[.76,0,.24,1],easeInQuint:[.64,0,.78,0],easeOutQuint:[.22,1,.36,1],easeInOutQuint:[.83,0,.17,1],easeInExpo:[.7,0,.84,0],easeOutExpo:[.16,1,.3,1],easeInOutExpo:[.87,0,.13,1],easeInCirc:[.55,0,1,.45],easeOutCirc:[0,.55,.45,1],easeInOutCirc:[.85,0,.15,1],easeInBack:[.36,0,.66,-.56],easeOutBack:[.34,1.56,.64,1],easeInOutBack:[.68,-.6,.32,1.6]});function le(t,l){const{itemHeight:n,overscan:o=5}=l,r=e.ref(),i=ye(r);let a;const d=e.shallowRef(t),p=e.ref(0),u=e.ref({start:0,end:10});let v=0;const m=e.ref([]),c=e.computed(()=>{let{sum:s,height:f}={sum:0,height:0};return d.value.map((_,b)=>(typeof n=="number"?f=n:f=n(b),s+=f,{height:f,sum:s}))}),h=e.computed(()=>x(u.value.start)),S=e.computed(()=>typeof n=="number"?c.value.length*n:c.value.at(-1)?.sum||0),T=e.computed(()=>{let s=m.value.length-o,f=Math.max(s-v,0);return m.value.slice(f,s)});e.onMounted(()=>{}),e.onUnmounted(()=>cancelAnimationFrame(a)),e.watch([i.width,i.height,d],([s,f])=>{(s||f)&&H()},{deep:!0});function H(){cancelAnimationFrame(a),a=requestAnimationFrame(O)}function O(){if(r.value){p.value=r.value.scrollTop,v=z();let s=C(p.value),f=s+v+o;s=s-o,s=s<0?0:s,f=f>d.value.length?d.value.length:f,u.value={start:s,end:f},m.value=d.value.slice(s,f).map((_,b)=>({data:_,index:b+s}))}}function C(s){let f=Math.floor(c.value.length/16),_=-1,b=-1;for(let y=0;y<16;y++){if(c.value.at(f*y).sum>=s){_=Math.max(0,y-1);break}y===15&&(_=y)}_*=f;for(let y=_;y<c.value.length;y++)if(c.value[y].sum>=s){b=y;break}return Math.max(0,b)}function z(){let s=0,f=0,_=M();for(let b=_;b<c.value.length&&(f+=c.value[b].height,!(f>=i.height.value));b++,s++);return s}function x(s){if(typeof n=="number")return s*n;let f=c.value[s];return f.sum-f.height}function P(s){return c.value.at(s)||{sum:0,height:0}}function M(){let s=u.value.start;return s>=o&&(s+=o),s}function Q(s){if(r.value){const f=P(s);r.value.scrollTop=f.sum-f.height,O()}}const U=e.computed(()=>({style:{width:"100%",height:`${S.value}px`}})),W=e.computed(()=>({style:{transform:`translate3d(0, ${h.value}px, 0)`,"will-change":"transform"}})),q={overflowY:"auto"};return{list:m,visiableList:T,getItemHeightData:P,totalHeight:S,clientHeight:i.height,scrollTo:Q,scrollTop:p,containerProps:{ref:r,onScroll:()=>{H()},style:q},wrapperProps:U,innerProps:W}}const D=Symbol(),F=Symbol(),L=Symbol(),j=Symbol(),k=Symbol(),K=Symbol(),V=Symbol(),$=Symbol(),N=Symbol();function Ee(){const{voidFn:t,boolFn:l,boolRef:n,arrayRef:o}={voidFn:h=>{},boolFn:h=>!1,boolRef:e.computed(()=>!1),arrayRef:e.computed(()=>[])},r=e.inject(j,o),i=e.inject(L,l),a=e.inject($,n),d=e.inject(F,t),p=e.inject(D,t),u=e.inject(k,t),v=e.inject(K,t),m=e.inject(V,t),c=e.inject(N,t);return{selected:r,isSelected:i,isAllSelected:a,toggle:d,toggleAll:p,select:u,selectAll:v,unselect:m,unselectAll:c}}function Te(t,l){const n=e.ref({}),o=e.computed(()=>t.value.filter(c=>n.value[c[l]])),r=e.computed(()=>o.value.length!=0&&Object.keys(n.value).length==t.value.length);function i(){t.value.forEach(c=>{n.value[c[l]]=!0})}function a(){n.value={}}function d(c){c.forEach(h=>{n.value[h[l]]||(n.value[h[l]]=!0)})}function p(c){c.forEach(h=>{n.value[h[l]]&&delete n.value[h[l]]})}function u(c){return!!n.value[c[l]]}function v(c){c.forEach(h=>{u(h)?delete n.value[h[l]]:n.value[h[l]]=!0})}function m(){r.value?a():i()}return e.provide(D,m),e.provide(F,v),e.provide(L,u),e.provide(j,o),e.provide(k,d),e.provide(K,i),e.provide(V,p),e.provide($,r),e.provide(N,a),{selected:o,select:d,selectAll:i,unselect:p,unselectAll:a,toggle:v,toggleAll:m,isSelected:u,isAllSelected:r}}const oe=Symbol(),Ie=e.defineComponent({__name:"Dialog",props:{visiable:{type:Boolean,default:!1},closeOnClickOverlay:{type:Boolean,default:!0},dialogClass:{default:""}},emits:["update:visiable"],setup(t,{emit:l}){const n=t,o=()=>{n.closeOnClickOverlay&&l("update:visiable",!1)};return e.provide(oe,()=>l("update:visiable",!1)),(r,i)=>(e.openBlock(),e.createBlock(e.Transition,{name:"modal"},{default:e.withCtx(()=>[t.visiable?(e.openBlock(),e.createElementBlock("div",{key:0,onClick:o,class:"modal absolute inset-0 bottom-0 z-50 flex bg-stone-900 bg-opacity-50"},[e.createElementVNode("div",{onClick:i[0]||(i[0]=e.withModifiers(()=>{},["stop"])),class:e.normalizeClass(["dialog m-auto flex flex-col",t.dialogClass])},[e.renderSlot(r.$slots,"default")],2)])):e.createCommentVNode("",!0)]),_:3}))}});function Be(t){function l(n,o){const r=document.createElement("div"),i={setup(){return()=>e.h(Ie,{visiable:!0,"onUpdate:visiable":()=>{r?.remove()},...t},{default:()=>e.h(n,o)})}};return document.body.appendChild(r),e.render(e.h(i),r),{close:()=>r?.remove()}}return{create:l}}const He=["xlink:href","fill","color"],Ce=e.defineComponent({__name:"SvgIcon",props:{name:null,prefix:{default:"icon"},color:{default:"#FFF"},width:null,height:null},setup(t){const l=t,n=e.computed(()=>`#${l.prefix}-${l.name}`),o=e.computed(()=>({width:l.width,height:l.height,aspectRatio:l.width&&l.height?void 0:"1/1"}));return(r,i)=>(e.openBlock(),e.createElementBlock("svg",{"aria-hidden":"",style:e.normalizeStyle(e.unref(o))},[e.createElementVNode("use",{"xlink:href":e.unref(n),fill:t.color,color:t.color},null,8,He)],4))}});function xe(t){const{containerEl:l,sliderEl:n,autoHeight:o,performance:r={}}=t,i=e.ref(!0),a=ue(W,1e3),d=de(Y,1e3,!0,!0);let p,u="";const v=e.ref(0),m=e.ref(0),c=e.ref(0),h=e.ref({top:0,scrollTop:0,scrollHeight:0,clientHeight:0}),S=e.ref({clientHeight:0}),T=e.computed(()=>!!m.value),H=e.computed(()=>h.value.scrollHeight>h.value.clientHeight),O=e.computed(()=>h.value.clientHeight-S.value.clientHeight),C=e.computed(()=>h.value.scrollHeight-h.value.clientHeight),z=e.computed(()=>Math.max(h.value.clientHeight/h.value.scrollHeight,.05)),x=e.computed(()=>z.value*h.value.clientHeight),P=e.computed(()=>({willChange:"transform",transform:`translate3d(0,${c.value}px,0)`,height:o?`${x.value}px`:void 0}));function M(E){m.value=E.clientY-n.value.getBoundingClientRect().top||1,u=getComputedStyle(l.value).scrollBehavior,u==="smooth"&&(l.value.style.scrollBehavior="unset")}function Q(){l.value.style.scrollBehavior=u,m.value=0,a()}function U(){i.value=!1}function W(){T.value||(i.value=!0)}function q(E){if(!T.value)return;let w=E.clientY-h.value.top-m.value;w<0?c.value=0:w>=O.value?c.value=O.value:c.value=w,l.value.scrollTo({top:c.value/O.value*C.value})}function s(){T.value||f()}function f(){cancelAnimationFrame(p),p=requestAnimationFrame(_)}function _(){l.value&&(v.value=r.scrollTop?.value??l.value.scrollTop,c.value=v.value/C.value*O.value)}function b(E){let w="addEventListener";E==="add"?w="addEventListener":w="removeEventListener",n.value?.[w]("pointerdown",M,{passive:!0}),window[w]("pointermove",q,{passive:!0}),window[w]("pointerup",Q,{passive:!0})}const y=new MutationObserver(E=>{E.map(Ke=>Ke.oldValue).join().includes("height")?Y():S.value.clientHeight===0&&d()});function Y(){h.value.top=l.value?.getBoundingClientRect().top??0,h.value.scrollHeight=l.value?.scrollHeight??0,h.value.clientHeight=l.value?.clientHeight??0,o?S.value.clientHeight=x.value:S.value.clientHeight=n.value?.clientHeight??0}function ke(){l.value&&n.value?(l.value.addEventListener("scroll",s,{passive:!0}),b("add"),y.observe(l.value,{subtree:!0,attributeOldValue:!0,attributeFilter:["style"]}),setTimeout(()=>{Y()},100)):console.error("useScrollBar:","\u521D\u59CB\u5316\u5931\u8D25!",{containerEl:l,sliderEl:n})}return e.watch(v,()=>{U(),a()}),{isScrollEnd:i,isDragSlider:T,scrollable:H,sliderPos:P,init:ke,modifySliderEventListener:b}}const Pe=(t=>(e.pushScopeId("data-v-d564e88d"),t=t(),e.popScopeId(),t))(()=>e.createElementVNode("div",{w:"6px",h:"full",bg:"black/20",rounded:"3px",mr:"3px"},null,-1)),Re=e.defineComponent({__name:"ScrollBar",props:{containerEl:null,autoHide:{type:Boolean},autoHeight:{type:Boolean},performance:null},setup(t,{expose:l}){const n=t,o=!!e.useSlots().default,r=e.ref(null),i=e.computed(()=>n.containerEl),a=xe({containerEl:i,sliderEl:r,autoHeight:o?n.autoHeight:!0,performance:n.performance}),{scrollable:d,isScrollEnd:p,sliderPos:u}=a,v=n.autoHide?e.computed(()=>!p.value):e.computed(()=>d.value);return e.onMounted(()=>{e.nextTick(()=>{a.init()})}),e.onUnmounted(()=>{a.modifySliderEventListener("remove")}),l({uScrollBarReturn:a}),(m,c)=>(e.openBlock(),e.createBlock(e.Transition,null,{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{ref_key:"sliderRef",ref:r,class:"z-100 absolute right-0",style:e.normalizeStyle([{"touch-action":"none"},e.unref(u)])},[e.renderSlot(m.$slots,"default",{},()=>[Pe],!0)],4),[[e.vShow,e.unref(v)]])]),_:3}))}}),Ne="",re=(t,l)=>{const n=t.__vccOpts||t;for(const[o,r]of l)n[o]=r;return n},Ae=re(Re,[["__scopeId","data-v-d564e88d"]]),De={class:"virtualListWrapper"},Fe={inheritAttrs:!1},Le=e.defineComponent({...Fe,__name:"VirtualList",props:{data:null,itemHeight:null,overscan:{default:10}},setup(t,{expose:l}){const n=t,o=le(e.toRef(n,"data"),{itemHeight:u=>n.itemHeight(n.data[u]),overscan:n.overscan}),{list:r,containerProps:i,wrapperProps:a,innerProps:d,getItemHeightData:p}=o;return l({vListReturn:o}),(u,v)=>(e.openBlock(),e.createElementBlock("div",De,[e.createElementVNode("div",e.mergeProps({onScrollPassive:v[0]||(v[0]=(...m)=>e.unref(i).onScroll&&e.unref(i).onScroll(...m)),ref:e.unref(i).ref,class:"virtualList"},u.$attrs),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(a))),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(d))),[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),({index:m,data:c})=>(e.openBlock(),e.createElementBlock("div",{key:m,style:e.normalizeStyle({height:`${e.unref(p)(m).height}px`,display:"flex"})},[e.renderSlot(u.$slots,"default",{data:c,index:m},void 0,!0)],4))),128))],16)],16)],16)]))}}),ze="",je=re(Le,[["__scopeId","data-v-134ad8ab"]]);g.ScrollBar=Ae,g.SvgIcon=Ce,g.VirtualList=je,g.allSelectedKey=j,g.closeDialogKey=oe,g.dialogController=Be,g.isAllSelectedKey=$,g.isSelectedKey=L,g.selectAllKey=K,g.selectKey=k,g.toggleAllKey=D,g.toggleKey=F,g.unselectAllKey=N,g.unselectKey=V,g.useSelectable=Te,g.useSelectableInjectors=Ee,g.useVirtualList=le,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .virtualListWrapper[data-v-06e648eb]{width:100%;height:100%;position:relative}.virtualList[data-v-06e648eb] ::-webkit-scrollbar{display:none}.virtualList[data-v-06e648eb]{width:100%;height:100%;position:absolute;top:0}
1
+ .v-enter-active[data-v-d564e88d]{opacity:0}.v-leave-active[data-v-d564e88d]{transition:all .15s ease-out}.v-leave-to[data-v-d564e88d]{opacity:0}.virtualListWrapper[data-v-134ad8ab]{width:100%;height:100%;position:relative}.virtualList[data-v-134ad8ab] ::-webkit-scrollbar{display:none}.virtualList[data-v-134ad8ab]{width:100%;height:100%;position:absolute;overflow-y:auto;scroll-behavior:smooth;user-select:none}.virtualList[data-v-134ad8ab]::-webkit-scrollbar{display:none}
@@ -2,4 +2,5 @@ export * from "./useVirtualList";
2
2
  export * from "./useSelectable";
3
3
  export * from "./dialog";
4
4
  export { default as SvgIcon } from "./svgIcon/SvgIcon.vue";
5
+ export { default as ScrollBar } from "./scroll-bar";
5
6
  export { default as VirtualList } from "./useVirtualList/VirtualList.vue";
@@ -0,0 +1,98 @@
1
+ import { nextTick, type Ref } from "vue";
2
+ export interface Props {
3
+ containerEl: null | HTMLElement;
4
+ autoHide?: boolean;
5
+ autoHeight?: boolean;
6
+ performance?: {
7
+ scrollTop?: Ref<number>;
8
+ };
9
+ }
10
+ declare const _default: {
11
+ new (...args: any[]): {
12
+ $: import("vue").ComponentInternalInstance;
13
+ $data: {};
14
+ $props: Partial<{}> & Omit<Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {}>>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>;
15
+ $attrs: {
16
+ [x: string]: unknown;
17
+ };
18
+ $refs: {
19
+ [x: string]: unknown;
20
+ };
21
+ $slots: Readonly<{
22
+ [name: string]: import("vue").Slot | undefined;
23
+ }>;
24
+ $root: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
25
+ $parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
26
+ $emit: (event: string, ...args: any[]) => void;
27
+ $el: any;
28
+ $options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {}>>>, {
29
+ uScrollBarReturn: {
30
+ isScrollEnd: Ref<boolean>;
31
+ isDragSlider: import("vue").ComputedRef<boolean>;
32
+ scrollable: import("vue").ComputedRef<boolean>;
33
+ sliderPos: import("vue").ComputedRef<import("vue").CSSProperties>;
34
+ init: () => void;
35
+ modifySliderEventListener: (action: "add" | "remove") => void;
36
+ };
37
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {}> & {
38
+ beforeCreate?: ((() => void) | (() => void)[]) | undefined;
39
+ created?: ((() => void) | (() => void)[]) | undefined;
40
+ beforeMount?: ((() => void) | (() => void)[]) | undefined;
41
+ mounted?: ((() => void) | (() => void)[]) | undefined;
42
+ beforeUpdate?: ((() => void) | (() => void)[]) | undefined;
43
+ updated?: ((() => void) | (() => void)[]) | undefined;
44
+ activated?: ((() => void) | (() => void)[]) | undefined;
45
+ deactivated?: ((() => void) | (() => void)[]) | undefined;
46
+ beforeDestroy?: ((() => void) | (() => void)[]) | undefined;
47
+ beforeUnmount?: ((() => void) | (() => void)[]) | undefined;
48
+ destroyed?: ((() => void) | (() => void)[]) | undefined;
49
+ unmounted?: ((() => void) | (() => void)[]) | undefined;
50
+ renderTracked?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
51
+ renderTriggered?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
52
+ errorCaptured?: (((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void)[]) | undefined;
53
+ };
54
+ $forceUpdate: () => void;
55
+ $nextTick: typeof nextTick;
56
+ $watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
57
+ } & Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {}>>> & import("vue").ShallowUnwrapRef<{
58
+ uScrollBarReturn: {
59
+ isScrollEnd: Ref<boolean>;
60
+ isDragSlider: import("vue").ComputedRef<boolean>;
61
+ scrollable: import("vue").ComputedRef<boolean>;
62
+ sliderPos: import("vue").ComputedRef<import("vue").CSSProperties>;
63
+ init: () => void;
64
+ modifySliderEventListener: (action: "add" | "remove") => void;
65
+ };
66
+ }> & {} & import("vue").ComponentCustomProperties;
67
+ __isFragment?: undefined;
68
+ __isTeleport?: undefined;
69
+ __isSuspense?: undefined;
70
+ } & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {}>>>, {
71
+ uScrollBarReturn: {
72
+ isScrollEnd: Ref<boolean>;
73
+ isDragSlider: import("vue").ComputedRef<boolean>;
74
+ scrollable: import("vue").ComputedRef<boolean>;
75
+ sliderPos: import("vue").ComputedRef<import("vue").CSSProperties>;
76
+ init: () => void;
77
+ modifySliderEventListener: (action: "add" | "remove") => void;
78
+ };
79
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
80
+ $slots: {
81
+ default: (_: {}) => any;
82
+ };
83
+ });
84
+ export default _default;
85
+ declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
86
+ declare type __VLS_TypePropsToRuntimeProps<T> = {
87
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
88
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
89
+ } : {
90
+ type: import('vue').PropType<T[K]>;
91
+ required: true;
92
+ };
93
+ };
94
+ declare type __VLS_WithDefaults<P, D> = {
95
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? P[K] & {
96
+ default: D[K];
97
+ } : P[K];
98
+ };
@@ -0,0 +1,2 @@
1
+ import ScrollBar from "./ScrollBar.vue";
2
+ export default ScrollBar;
@@ -0,0 +1,10 @@
1
+ import { type CSSProperties } from "vue";
2
+ import type { ScrollBarOptions } from "./type";
3
+ export declare function useScrollBar(options: ScrollBarOptions): {
4
+ isScrollEnd: import("vue").Ref<boolean>;
5
+ isDragSlider: import("vue").ComputedRef<boolean>;
6
+ scrollable: import("vue").ComputedRef<boolean>;
7
+ sliderPos: import("vue").ComputedRef<CSSProperties>;
8
+ init: () => void;
9
+ modifySliderEventListener: (action: "add" | "remove") => void;
10
+ };
@@ -0,0 +1,9 @@
1
+ import type { Ref } from "vue";
2
+ export declare type ScrollBarOptions = {
3
+ containerEl: Ref<HTMLElement | null>;
4
+ sliderEl: Ref<HTMLElement | null>;
5
+ autoHeight?: boolean;
6
+ performance?: {
7
+ scrollTop?: Ref<number>;
8
+ };
9
+ };
@@ -1,30 +1,24 @@
1
1
  declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
2
- prefix: string;
3
2
  name: string;
3
+ prefix?: string | undefined;
4
4
  color?: string | undefined;
5
5
  width?: number | undefined;
6
6
  height?: number | undefined;
7
7
  }>, {
8
8
  prefix: string;
9
9
  color: string;
10
- width: number;
11
- height: number;
12
10
  }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
13
- prefix: string;
14
11
  name: string;
12
+ prefix?: string | undefined;
15
13
  color?: string | undefined;
16
14
  width?: number | undefined;
17
15
  height?: number | undefined;
18
16
  }>, {
19
17
  prefix: string;
20
18
  color: string;
21
- width: number;
22
- height: number;
23
19
  }>>>, {
24
20
  prefix: string;
25
21
  color: string;
26
- width: number;
27
- height: number;
28
22
  }>;
29
23
  export default _default;
30
24
  declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
@@ -1,14 +1,15 @@
1
1
  import { type ComputedRef, type Ref } from "vue";
2
2
  export * from "./keys";
3
3
  export declare function useSelectableInjectors(): {
4
- toggleAll: (() => void) | undefined;
5
- toggle: ((a: any[]) => void) | undefined;
6
- isSelected: ((a: any) => boolean) | undefined;
7
- selected: ComputedRef<any[]> | undefined;
8
- select: ((a: any) => void) | undefined;
9
- unselect: ((a: any) => void) | undefined;
10
- isAllSelected: ComputedRef<boolean> | undefined;
11
- unselectAll: (() => void) | undefined;
4
+ selected: ComputedRef<any[]>;
5
+ isSelected: (_?: any) => boolean;
6
+ isAllSelected: ComputedRef<boolean>;
7
+ toggle: (a: any[]) => void;
8
+ toggleAll: (_?: any) => void;
9
+ select: (_?: any) => void;
10
+ selectAll: (_?: any) => void;
11
+ unselect: (_?: any) => void;
12
+ unselectAll: (_?: any) => void;
12
13
  };
13
14
  export declare function useSelectable<T extends Record<K, string | number>, K extends keyof T>(data: Ref<Array<T>>, key: K): {
14
15
  selected: ComputedRef<T[]>;
@@ -4,6 +4,7 @@ export declare const toggleKey: InjectionKey<(a: Array<any>) => void>;
4
4
  export declare const isSelectedKey: InjectionKey<(a: any) => boolean>;
5
5
  export declare const allSelectedKey: InjectionKey<ComputedRef<any[]>>;
6
6
  export declare const selectKey: InjectionKey<(a: any) => void>;
7
+ export declare const selectAllKey: InjectionKey<() => void>;
7
8
  export declare const unselectKey: InjectionKey<(a: any) => void>;
8
9
  export declare const isAllSelectedKey: InjectionKey<ComputedRef<boolean>>;
9
10
  export declare const unselectAllKey: InjectionKey<() => void>;
@@ -2,10 +2,15 @@ declare const _default: {
2
2
  new (...args: any[]): {
3
3
  $: import("vue").ComponentInternalInstance;
4
4
  $data: {};
5
- $props: Partial<{}> & Omit<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
6
- data: any;
7
- itemHeight: (a: number) => number;
8
- }>>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>;
5
+ $props: Partial<{
6
+ overscan: number;
7
+ }> & Omit<Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
8
+ data: any[];
9
+ itemHeight: (d: any) => number;
10
+ overscan?: number | undefined;
11
+ }>, {
12
+ overscan: number;
13
+ }>>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "overscan">;
9
14
  $attrs: {
10
15
  [x: string]: unknown;
11
16
  };
@@ -19,10 +24,17 @@ declare const _default: {
19
24
  $parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
20
25
  $emit: (event: string, ...args: any[]) => void;
21
26
  $el: any;
22
- $options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
23
- data: any;
24
- itemHeight: (a: number) => number;
25
- }>>>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {}> & {
27
+ $options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
28
+ data: any[];
29
+ itemHeight: (d: any) => number;
30
+ overscan?: number | undefined;
31
+ }>, {
32
+ overscan: number;
33
+ }>>>, {
34
+ vListReturn: import("./index").UseVirtualListReturn<any>;
35
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
36
+ overscan: number;
37
+ }> & {
26
38
  beforeCreate?: ((() => void) | (() => void)[]) | undefined;
27
39
  created?: ((() => void) | (() => void)[]) | undefined;
28
40
  beforeMount?: ((() => void) | (() => void)[]) | undefined;
@@ -42,17 +54,29 @@ declare const _default: {
42
54
  $forceUpdate: () => void;
43
55
  $nextTick: typeof import("vue").nextTick;
44
56
  $watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
45
- } & Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
46
- data: any;
47
- itemHeight: (a: number) => number;
48
- }>>> & import("vue").ShallowUnwrapRef<{}> & {} & import("vue").ComponentCustomProperties;
57
+ } & Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
58
+ data: any[];
59
+ itemHeight: (d: any) => number;
60
+ overscan?: number | undefined;
61
+ }>, {
62
+ overscan: number;
63
+ }>>> & import("vue").ShallowUnwrapRef<{
64
+ vListReturn: import("./index").UseVirtualListReturn<any>;
65
+ }> & {} & import("vue").ComponentCustomProperties;
49
66
  __isFragment?: undefined;
50
67
  __isTeleport?: undefined;
51
68
  __isSuspense?: undefined;
52
- } & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
53
- data: any;
54
- itemHeight: (a: number) => number;
55
- }>>>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
69
+ } & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
70
+ data: any[];
71
+ itemHeight: (d: any) => number;
72
+ overscan?: number | undefined;
73
+ }>, {
74
+ overscan: number;
75
+ }>>>, {
76
+ vListReturn: import("./index").UseVirtualListReturn<any>;
77
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
78
+ overscan: number;
79
+ }> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
56
80
  $slots: {
57
81
  default: (_: {
58
82
  data: any;
@@ -70,3 +94,8 @@ declare type __VLS_TypePropsToRuntimeProps<T> = {
70
94
  required: true;
71
95
  };
72
96
  };
97
+ declare type __VLS_WithDefaults<P, D> = {
98
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? P[K] & {
99
+ default: D[K];
100
+ } : P[K];
101
+ };
@@ -19,6 +19,11 @@ export interface UseVirtualListItem<T> {
19
19
  }
20
20
  export interface UseVirtualListReturn<T> {
21
21
  list: Ref<UseVirtualListItem<T>[]>;
22
+ visiableList: ComputedRef<UseVirtualListItem<T>[]>;
23
+ getItemHeightData: (index: number) => {
24
+ sum: number;
25
+ height: number;
26
+ };
22
27
  scrollTo: (index: number) => void;
23
28
  totalHeight: Ref<number>;
24
29
  clientHeight: Ref<number>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazycatcloud/lzc-toolkit",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "lazycat ui toolkits",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",