@lazycatcloud/lzc-toolkit 0.0.19 → 0.0.21

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,84 @@
1
- import { unref as m, getCurrentScope as ie, onScopeDispose as ce, getCurrentInstance as ue, onMounted as U, nextTick as de, ref as _, watch as R, shallowRef as fe, onUnmounted as ve, computed as w, inject as y, provide as b, defineComponent as B, openBlock as I, createBlock as pe, Transition as he, withCtx as ge, createElementBlock as x, createElementVNode as C, withModifiers as me, normalizeClass as be, renderSlot as W, createCommentVNode as ye, render as _e, h as E, normalizeStyle as T, toRef as we, normalizeProps as K, guardReactiveProps as L, Fragment as Oe, renderList as Se } from "vue";
2
- var j;
1
+ import { unref as _, getCurrentScope as de, onScopeDispose as ve, getCurrentInstance as pe, onMounted as D, nextTick as he, ref as S, watch as $, shallowRef as ge, computed as g, onUnmounted as me, inject as O, provide as y, defineComponent as T, openBlock as I, createBlock as be, Transition as ye, withCtx as _e, createElementBlock as x, createElementVNode as C, withModifiers as we, normalizeClass as Oe, renderSlot as M, createCommentVNode as Se, render as Ie, h as E, normalizeStyle as U, toRef as xe, mergeProps as Ce, normalizeProps as k, guardReactiveProps as K, Fragment as Pe, renderList as Ee } from "vue";
2
+ var z;
3
3
  const P = typeof window < "u";
4
- P && ((j = window?.navigator) == null ? void 0 : j.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
5
- function Ie(e) {
6
- return typeof e == "function" ? e() : m(e);
4
+ P && ((z = window?.navigator) == null ? void 0 : z.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
5
+ function Re(e) {
6
+ return typeof e == "function" ? e() : _(e);
7
7
  }
8
- function xe(e) {
8
+ function Ae(e) {
9
9
  return e;
10
10
  }
11
- function Ce(e) {
12
- return ie() ? (ce(e), !0) : !1;
11
+ function $e(e) {
12
+ return de() ? (ve(e), !0) : !1;
13
13
  }
14
- function Pe(e, t = !0) {
15
- ue() ? U(e) : t ? e() : de(e);
14
+ function Te(e, n = !0) {
15
+ pe() ? D(e) : n ? e() : he(e);
16
16
  }
17
- function D(e) {
18
- var t;
19
- const n = Ie(e);
20
- return (t = n?.$el) != null ? t : n;
17
+ function W(e) {
18
+ var n;
19
+ const t = Re(e);
20
+ return (n = t?.$el) != null ? n : t;
21
21
  }
22
- const Ee = P ? window : void 0;
22
+ const Fe = P ? window : void 0;
23
23
  P && window.document;
24
24
  P && window.navigator;
25
25
  P && window.location;
26
- function Te(e, t = !1) {
27
- const n = _(), o = () => n.value = Boolean(e());
28
- return o(), Pe(o, t), n;
26
+ function Le(e, n = !1) {
27
+ const t = S(), o = () => t.value = Boolean(e());
28
+ return o(), Te(o, n), t;
29
29
  }
30
- const A = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, $ = "__vueuse_ssr_handlers__";
31
- A[$] = A[$] || {};
32
- A[$];
33
- var F = Object.getOwnPropertySymbols, Ae = Object.prototype.hasOwnProperty, $e = Object.prototype.propertyIsEnumerable, Re = (e, t) => {
34
- var n = {};
30
+ const R = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, A = "__vueuse_ssr_handlers__";
31
+ R[A] = R[A] || {};
32
+ R[A];
33
+ var j = Object.getOwnPropertySymbols, Be = Object.prototype.hasOwnProperty, He = Object.prototype.propertyIsEnumerable, ke = (e, n) => {
34
+ var t = {};
35
35
  for (var o in e)
36
- Ae.call(e, o) && t.indexOf(o) < 0 && (n[o] = e[o]);
37
- if (e != null && F)
38
- for (var o of F(e))
39
- t.indexOf(o) < 0 && $e.call(e, o) && (n[o] = e[o]);
40
- return n;
36
+ Be.call(e, o) && n.indexOf(o) < 0 && (t[o] = e[o]);
37
+ if (e != null && j)
38
+ for (var o of j(e))
39
+ n.indexOf(o) < 0 && He.call(e, o) && (t[o] = e[o]);
40
+ return t;
41
41
  };
42
- function Be(e, t, n = {}) {
43
- const o = n, { window: s = Ee } = o, a = Re(o, ["window"]);
44
- let l;
45
- const i = Te(() => s && "ResizeObserver" in s), r = () => {
46
- l && (l.disconnect(), l = void 0);
47
- }, u = R(() => 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();
42
+ function Ke(e, n, t = {}) {
43
+ const o = t, { window: a = Fe } = o, s = ke(o, ["window"]);
44
+ let r;
45
+ const f = Le(() => a && "ResizeObserver" in a), v = () => {
46
+ r && (r.disconnect(), r = void 0);
47
+ }, c = $(() => W(e), (d) => {
48
+ v(), f.value && a && d && (r = new ResizeObserver(n), r.observe(d, s));
49
+ }, { immediate: !0, flush: "post" }), p = () => {
50
+ v(), c();
51
51
  };
52
- return Ce(O), {
53
- isSupported: i,
54
- stop: O
52
+ return $e(p), {
53
+ isSupported: f,
54
+ stop: p
55
55
  };
56
56
  }
57
- function ke(e, t = { width: 0, height: 0 }, n = {}) {
58
- const { box: o = "content-box" } = n, s = _(t.width), a = _(t.height);
59
- return Be(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), R(() => D(e), (l) => {
63
- s.value = l ? t.width : 0, a.value = l ? t.height : 0;
57
+ function ze(e, n = { width: 0, height: 0 }, t = {}) {
58
+ const { box: o = "content-box" } = t, a = S(n.width), s = S(n.height);
59
+ return Ke(e, ([r]) => {
60
+ const f = o === "border-box" ? r.borderBoxSize : o === "content-box" ? r.contentBoxSize : r.devicePixelContentBoxSize;
61
+ f ? (a.value = f.reduce((v, { inlineSize: c }) => v + c, 0), s.value = f.reduce((v, { blockSize: c }) => v + c, 0)) : (a.value = r.contentRect.width, s.value = r.contentRect.height);
62
+ }, t), $(() => W(e), (r) => {
63
+ a.value = r ? n.width : 0, s.value = r ? n.height : 0;
64
64
  }), {
65
- width: s,
66
- height: a
65
+ width: a,
66
+ height: s
67
67
  };
68
68
  }
69
69
  var N;
70
70
  (function(e) {
71
71
  e.UP = "UP", e.RIGHT = "RIGHT", e.DOWN = "DOWN", e.LEFT = "LEFT", e.NONE = "NONE";
72
72
  })(N || (N = {}));
73
- var ze = Object.defineProperty, Q = Object.getOwnPropertySymbols, He = Object.prototype.hasOwnProperty, Ke = Object.prototype.propertyIsEnumerable, V = (e, t, n) => t in e ? ze(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, Le = (e, t) => {
74
- for (var n in t || (t = {}))
75
- He.call(t, n) && V(e, n, t[n]);
73
+ var je = Object.defineProperty, Q = Object.getOwnPropertySymbols, Ne = Object.prototype.hasOwnProperty, Qe = Object.prototype.propertyIsEnumerable, V = (e, n, t) => n in e ? je(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t, Ve = (e, n) => {
74
+ for (var t in n || (n = {}))
75
+ Ne.call(n, t) && V(e, t, n[t]);
76
76
  if (Q)
77
- for (var n of Q(t))
78
- Ke.call(t, n) && V(e, n, t[n]);
77
+ for (var t of Q(n))
78
+ Qe.call(n, t) && V(e, t, n[t]);
79
79
  return e;
80
80
  };
81
- const je = {
81
+ const De = {
82
82
  easeInSine: [0.12, 0, 0.39, 0],
83
83
  easeOutSine: [0.61, 1, 0.88, 1],
84
84
  easeInOutSine: [0.37, 0, 0.63, 1],
@@ -104,142 +104,181 @@ const je = {
104
104
  easeOutBack: [0.34, 1.56, 0.64, 1],
105
105
  easeInOutBack: [0.68, -0.6, 0.32, 1.6]
106
106
  };
107
- Le({
108
- linear: xe
109
- }, je);
110
- function Fe(e, t) {
111
- const n = _(), o = ke(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;
107
+ Ve({
108
+ linear: Ae
109
+ }, De);
110
+ function Me(e, n) {
111
+ const { itemHeight: t, overscan: o = 5 } = n, a = S(), s = ze(a);
112
+ let r;
113
+ const f = ge(e), v = S(0), c = S({ start: 0, end: 10 });
114
+ let p = 0;
115
+ const d = S([]), i = g(() => {
116
+ let { sum: l, height: u } = { sum: 0, height: 0 };
117
+ return f.value.map((w, b) => (typeof t == "number" ? u = t : u = t(b), l += u, { height: u, sum: l }));
118
+ }), h = g(() => se(c.value.start)), F = g(() => typeof t == "number" ? i.value.length * t : i.value.at(-1)?.sum || 0), oe = g(() => {
119
+ let l = d.value.length - o, u = Math.max(l - p, 0);
120
+ return d.value.slice(u, l);
121
+ });
122
+ D(() => {
123
+ }), me(() => cancelAnimationFrame(r)), $(
124
+ [s.width, s.height, f],
125
+ ([l, u]) => {
126
+ (l || u) && L();
127
+ },
128
+ { deep: !0 }
129
+ );
130
+ function L() {
131
+ cancelAnimationFrame(r), r = requestAnimationFrame(B);
132
+ }
133
+ function B() {
134
+ if (a.value) {
135
+ v.value = a.value.scrollTop, p = ae();
136
+ let l = le(v.value), u = l + p + o;
137
+ l = l - o, l = l < 0 ? 0 : l, u = u > f.value.length ? f.value.length : u, c.value = { start: l, end: u }, d.value = f.value.slice(l, u).map((w, b) => ({
138
+ data: w,
139
+ index: b + l
140
+ }));
141
+ }
142
+ }
143
+ function le(l) {
144
+ let u = Math.floor(i.value.length / 16), w = -1, b = -1;
145
+ for (let m = 0; m < 16; m++) {
146
+ if (i.value.at(u * m).sum >= l) {
147
+ w = Math.max(0, m - 1);
117
148
  break;
118
149
  }
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;
150
+ m === 15 && (w = m);
151
+ }
152
+ w *= u;
153
+ for (let m = w; m < i.value.length; m++)
154
+ if (i.value[m].sum >= l) {
155
+ b = m;
125
156
  break;
126
157
  }
127
- return v;
128
- };
129
- let d;
130
- const f = () => {
131
- cancelAnimationFrame(d), d = requestAnimationFrame(k);
132
- }, k = () => {
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((H, ae) => ({
140
- data: H,
141
- index: ae + i.value.start
142
- }));
158
+ return Math.max(0, b);
159
+ }
160
+ function ae() {
161
+ let l = 0, u = 0, w = re();
162
+ for (let b = w; b < i.value.length && (u += i.value[b].height, !(u >= s.height.value)); b++, l++)
163
+ ;
164
+ return l;
165
+ }
166
+ function se(l) {
167
+ if (typeof t == "number")
168
+ return l * t;
169
+ let u = i.value[l];
170
+ return u.sum - u.height;
171
+ }
172
+ function H(l) {
173
+ return i.value.at(l) || { sum: 0, height: 0 };
174
+ }
175
+ function re() {
176
+ let l = c.value.start;
177
+ return l >= o && (l += o), l;
178
+ }
179
+ function ie(l) {
180
+ if (a.value) {
181
+ const u = H(l);
182
+ a.value.scrollTop = u.sum - u.height, B();
143
183
  }
144
- };
145
- U(() => {
146
- }), ve(() => {
147
- cancelAnimationFrame(d);
148
- }), R(
149
- [o.width, o.height, l],
150
- () => {
151
- f();
152
- },
153
- { deep: !0 }
154
- );
155
- const z = 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, k());
157
- }, oe = w(() => te(i.value.start)), le = w(() => ({
184
+ }
185
+ const ue = g(() => ({
158
186
  style: {
159
187
  width: "100%",
160
- height: `${z.value}px`
188
+ height: `${F.value}px`
161
189
  }
162
- })), se = w(() => ({
190
+ })), ce = g(() => ({
163
191
  style: {
164
- transform: `translate3d(0, ${oe.value}px, 0)`,
192
+ transform: `translate3d(0, ${h.value}px, 0)`,
165
193
  "will-change": "transform"
166
194
  }
167
- })), re = { overflowY: "auto" };
195
+ })), fe = {
196
+ overflowY: "auto"
197
+ };
168
198
  return {
169
- list: s,
170
- totalHeight: z,
171
- clientHeight: o.height,
172
- scrollTo: ne,
173
- scrollTop: a,
199
+ list: d,
200
+ visiableList: oe,
201
+ getItemHeightData: H,
202
+ totalHeight: F,
203
+ clientHeight: s.height,
204
+ scrollTo: ie,
205
+ scrollTop: v,
174
206
  containerProps: {
175
- ref: n,
176
- onScroll: (c) => {
177
- c.target && (a.value = c.target.scrollTop), f();
207
+ ref: a,
208
+ onScroll: () => {
209
+ L();
178
210
  },
179
- style: re
211
+ style: fe
180
212
  },
181
- wrapperProps: le,
182
- innerProps: se
213
+ wrapperProps: ue,
214
+ innerProps: ce
183
215
  };
184
216
  }
185
- const M = Symbol(), q = Symbol(), G = Symbol(), Y = Symbol(), J = Symbol(), X = Symbol(), Z = Symbol(), ee = Symbol();
186
- function qe() {
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);
217
+ const q = Symbol(), G = Symbol(), Y = Symbol(), J = Symbol(), X = Symbol(), Z = Symbol(), ee = Symbol(), te = Symbol(), ne = Symbol();
218
+ function et() {
219
+ const { voidFn: e, boolFn: n, boolRef: t, arrayRef: o } = {
220
+ voidFn: (h) => {
221
+ },
222
+ boolFn: (h) => !1,
223
+ boolRef: g(() => !1),
224
+ arrayRef: g(() => [])
225
+ }, a = O(J, o), s = O(Y, n), r = O(te, t), f = O(G, e), v = O(q, e), c = O(X, e), p = O(Z, e), d = O(ee, e), i = O(ne, e);
188
226
  return {
189
- toggleAll: e,
190
- toggle: t,
191
- isSelected: n,
192
- selected: o,
193
- select: s,
194
- unselect: a,
195
- isAllSelected: l,
227
+ selected: a,
228
+ isSelected: s,
229
+ isAllSelected: r,
230
+ toggle: f,
231
+ toggleAll: v,
232
+ select: c,
233
+ selectAll: p,
234
+ unselect: d,
196
235
  unselectAll: i
197
236
  };
198
237
  }
199
- function Ge(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;
238
+ function tt(e, n) {
239
+ const t = S({}), o = g(() => e.value.filter((i) => t.value[i[n]])), a = g(() => o.value.length != 0 && Object.keys(t.value).length == e.value.length);
240
+ function s() {
241
+ e.value.forEach((i) => {
242
+ t.value[i[n]] = !0;
204
243
  });
205
244
  }
206
- function l() {
207
- n.value = {};
245
+ function r() {
246
+ t.value = {};
208
247
  }
209
- function i(d) {
210
- d.forEach((f) => {
211
- n.value[f[t]] || (n.value[f[t]] = !0);
248
+ function f(i) {
249
+ i.forEach((h) => {
250
+ t.value[h[n]] || (t.value[h[n]] = !0);
212
251
  });
213
252
  }
214
- function r(d) {
215
- d.forEach((f) => {
216
- n.value[f[t]] && delete n.value[f[t]];
253
+ function v(i) {
254
+ i.forEach((h) => {
255
+ t.value[h[n]] && delete t.value[h[n]];
217
256
  });
218
257
  }
219
- function u(d) {
220
- return !!n.value[d[t]];
258
+ function c(i) {
259
+ return !!t.value[i[n]];
221
260
  }
222
- function O(d) {
223
- d.forEach((f) => {
224
- u(f) ? delete n.value[f[t]] : n.value[f[t]] = !0;
261
+ function p(i) {
262
+ i.forEach((h) => {
263
+ c(h) ? delete t.value[h[n]] : t.value[h[n]] = !0;
225
264
  });
226
265
  }
227
- function S() {
228
- s.value ? l() : a();
266
+ function d() {
267
+ a.value ? r() : s();
229
268
  }
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), {
269
+ return y(q, d), y(G, p), y(Y, c), y(J, o), y(X, f), y(Z, s), y(ee, v), y(te, a), y(ne, r), {
231
270
  selected: o,
232
- select: i,
233
- selectAll: a,
234
- unselect: r,
235
- unselectAll: l,
236
- toggle: O,
237
- toggleAll: S,
238
- isSelected: u,
239
- isAllSelected: s
271
+ select: f,
272
+ selectAll: s,
273
+ unselect: v,
274
+ unselectAll: r,
275
+ toggle: p,
276
+ toggleAll: d,
277
+ isSelected: c,
278
+ isAllSelected: a
240
279
  };
241
280
  }
242
- const Ne = Symbol(), Qe = /* @__PURE__ */ B({
281
+ const Ue = Symbol(), We = /* @__PURE__ */ T({
243
282
  __name: "Dialog",
244
283
  props: {
245
284
  visiable: { type: Boolean, default: !1 },
@@ -247,143 +286,147 @@ const Ne = Symbol(), Qe = /* @__PURE__ */ B({
247
286
  dialogClass: { default: "" }
248
287
  },
249
288
  emits: ["update:visiable"],
250
- setup(e, { emit: t }) {
251
- const n = e, o = () => {
252
- n.closeOnClickOverlay && t("update:visiable", !1);
289
+ setup(e, { emit: n }) {
290
+ const t = e, o = () => {
291
+ t.closeOnClickOverlay && n("update:visiable", !1);
253
292
  };
254
- return b(Ne, () => t("update:visiable", !1)), (s, a) => (I(), pe(he, { name: "modal" }, {
255
- default: ge(() => [
293
+ return y(Ue, () => n("update:visiable", !1)), (a, s) => (I(), be(ye, { name: "modal" }, {
294
+ default: _e(() => [
256
295
  e.visiable ? (I(), x("div", {
257
296
  key: 0,
258
297
  onClick: o,
259
298
  class: "modal absolute inset-0 bottom-0 z-50 flex bg-stone-900 bg-opacity-50"
260
299
  }, [
261
300
  C("div", {
262
- onClick: a[0] || (a[0] = me(() => {
301
+ onClick: s[0] || (s[0] = we(() => {
263
302
  }, ["stop"])),
264
- class: be(["dialog m-auto flex flex-col", e.dialogClass])
303
+ class: Oe(["dialog m-auto flex flex-col", e.dialogClass])
265
304
  }, [
266
- W(s.$slots, "default")
305
+ M(a.$slots, "default")
267
306
  ], 2)
268
- ])) : ye("", !0)
307
+ ])) : Se("", !0)
269
308
  ]),
270
309
  _: 3
271
310
  }));
272
311
  }
273
312
  });
274
- function Ye(e) {
275
- function t(n, o) {
276
- const s = document.createElement("div"), a = {
313
+ function nt(e) {
314
+ function n(t, o) {
315
+ const a = document.createElement("div"), s = {
277
316
  setup() {
278
317
  return () => E(
279
- Qe,
318
+ We,
280
319
  {
281
320
  visiable: !0,
282
321
  "onUpdate:visiable": () => {
283
- s?.remove();
322
+ a?.remove();
284
323
  },
285
324
  ...e
286
325
  },
287
326
  {
288
- default: () => E(n, o)
327
+ default: () => E(t, o)
289
328
  }
290
329
  );
291
330
  }
292
331
  };
293
- return document.body.appendChild(s), _e(E(a), s), {
294
- close: () => s?.remove()
332
+ return document.body.appendChild(a), Ie(E(s), a), {
333
+ close: () => a?.remove()
295
334
  };
296
335
  }
297
336
  return {
298
- create: t
337
+ create: n
299
338
  };
300
339
  }
301
- const Ve = ["xlink:href", "fill", "color"], Je = /* @__PURE__ */ B({
340
+ const qe = ["xlink:href", "fill", "color"], ot = /* @__PURE__ */ T({
302
341
  __name: "SvgIcon",
303
342
  props: {
304
- prefix: { default: "icon" },
305
343
  name: null,
344
+ prefix: { default: "icon" },
306
345
  color: { default: "#FFF" },
307
- width: { default: 16 },
308
- height: { default: 16 }
346
+ width: null,
347
+ height: null
309
348
  },
310
349
  setup(e) {
311
- const t = e, n = w(() => `#${t.prefix}-${t.name}`), o = w(() => ({
312
- width: t.width,
313
- height: t.height
350
+ const n = e, t = g(() => `#${n.prefix}-${n.name}`), o = g(() => ({
351
+ width: n.width,
352
+ height: n.height,
353
+ aspectRatio: n.width && n.height ? void 0 : "1/1"
314
354
  }));
315
- return (s, a) => (I(), x("svg", {
355
+ return (a, s) => (I(), x("svg", {
316
356
  "aria-hidden": "",
317
- style: T(m(o))
357
+ style: U(_(o))
318
358
  }, [
319
359
  C("use", {
320
- "xlink:href": m(n),
360
+ "xlink:href": _(t),
321
361
  fill: e.color,
322
362
  color: e.color
323
- }, null, 8, Ve)
363
+ }, null, 8, qe)
324
364
  ], 4));
325
365
  }
326
- }), Ue = { class: "virtualListWrapper" }, We = /* @__PURE__ */ B({
366
+ }), Ge = { class: "virtualListWrapper" }, Ye = {
367
+ inheritAttrs: !1
368
+ }, Je = /* @__PURE__ */ T({
369
+ ...Ye,
327
370
  __name: "VirtualList",
328
371
  props: {
329
372
  data: null,
330
- itemHeight: null
373
+ itemHeight: null,
374
+ overscan: { default: 10 }
331
375
  },
332
- setup(e) {
333
- const t = e, { list: n, containerProps: o, wrapperProps: s, innerProps: a } = Fe(
334
- we(t, "data"),
335
- {
336
- itemHeight: (l) => t.itemHeight(0),
337
- overscan: 10
338
- }
339
- );
340
- return (l, i) => (I(), x("div", Ue, [
341
- C("div", {
342
- onScrollPassive: i[0] || (i[0] = (...r) => m(o).onScroll && m(o).onScroll(...r)),
343
- ref: m(o).ref,
344
- style: T(m(o).style),
376
+ setup(e, { expose: n }) {
377
+ const t = e, o = Me(xe(t, "data"), {
378
+ itemHeight: (c) => t.itemHeight(t.data[c]),
379
+ overscan: t.overscan
380
+ }), { list: a, containerProps: s, wrapperProps: r, innerProps: f, getItemHeightData: v } = o;
381
+ return n({
382
+ vListReturn: o
383
+ }), (c, p) => (I(), x("div", Ge, [
384
+ C("div", Ce({
385
+ onScrollPassive: p[0] || (p[0] = (...d) => _(s).onScroll && _(s).onScroll(...d)),
386
+ ref: _(s).ref,
345
387
  class: "virtualList"
346
- }, [
347
- C("div", K(L(m(s))), [
348
- C("div", K(L(m(a))), [
349
- (I(!0), x(Oe, null, Se(m(n), ({ index: r, data: u }) => (I(), x("div", {
350
- key: r,
351
- style: T({
352
- height: `${e.itemHeight(u)}px`,
388
+ }, c.$attrs), [
389
+ C("div", k(K(_(r))), [
390
+ C("div", k(K(_(f))), [
391
+ (I(!0), x(Pe, null, Ee(_(a), ({ index: d, data: i }) => (I(), x("div", {
392
+ key: d,
393
+ style: U({
394
+ height: `${_(v)(d).height}px`,
353
395
  display: "flex"
354
396
  })
355
397
  }, [
356
- W(l.$slots, "default", {
357
- data: u,
358
- index: r
398
+ M(c.$slots, "default", {
399
+ data: i,
400
+ index: d
359
401
  }, void 0, !0)
360
402
  ], 4))), 128))
361
403
  ], 16)
362
404
  ], 16)
363
- ], 36)
405
+ ], 16)
364
406
  ]));
365
407
  }
366
408
  });
367
- const De = (e, t) => {
368
- const n = e.__vccOpts || e;
369
- for (const [o, s] of t)
370
- n[o] = s;
371
- return n;
372
- }, Xe = /* @__PURE__ */ De(We, [["__scopeId", "data-v-e5ab2b81"]]);
409
+ const Xe = (e, n) => {
410
+ const t = e.__vccOpts || e;
411
+ for (const [o, a] of n)
412
+ t[o] = a;
413
+ return t;
414
+ }, lt = /* @__PURE__ */ Xe(Je, [["__scopeId", "data-v-134ad8ab"]]);
373
415
  export {
374
- Je as SvgIcon,
375
- Xe as VirtualList,
376
- Y as allSelectedKey,
377
- Ne as closeDialogKey,
378
- Ye as dialogController,
379
- Z as isAllSelectedKey,
380
- G as isSelectedKey,
381
- J as selectKey,
382
- M as toggleAllKey,
383
- q as toggleKey,
384
- ee as unselectAllKey,
385
- X as unselectKey,
386
- Ge as useSelectable,
387
- qe as useSelectableInjectors,
388
- Fe as useVirtualList
416
+ ot as SvgIcon,
417
+ lt as VirtualList,
418
+ J as allSelectedKey,
419
+ Ue as closeDialogKey,
420
+ nt as dialogController,
421
+ te as isAllSelectedKey,
422
+ Y as isSelectedKey,
423
+ Z as selectAllKey,
424
+ X as selectKey,
425
+ q as toggleAllKey,
426
+ G as toggleKey,
427
+ ne as unselectAllKey,
428
+ ee as unselectKey,
429
+ tt as useSelectable,
430
+ et as useSelectableInjectors,
431
+ Me as useVirtualList
389
432
  };
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 K;const O=typeof window<"u";O&&((K=window?.navigator)==null?void 0:K.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 A(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(()=>A(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(()=>A(t),r=>{s.value=r?n.width:0,a.value=r?n.height:0}),{width:s,height:a}}var V;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})(V||(V={}));var ee=Object.defineProperty,$=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($)for(var o of $(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 z(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,_e)=>({data:F,index:_e+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)),pe=u=>typeof i=="number"?u*i:r.value.slice(0,u).reduce((g,m,b)=>g+i(b),0),he=u=>{o.value&&(o.value.scrollTop=u,L())},ge=e.computed(()=>pe(d.value.start)),me=e.computed(()=>({style:{width:"100%",height:`${H.value}px`}})),ye=e.computed(()=>({style:{transform:`translate3d(0, ${ge.value}px, 0)`,"will-change":"transform"}})),be={overflowY:"auto"};return{list:s,totalHeight:H,clientHeight:l.height,scrollTo:he,scrollTop:a,containerProps:{ref:o,onScroll:u=>{u.target&&(a.value=u.target.scrollTop),h()},style:be},wrapperProps:me,innerProps:ye}}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 N=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(N,()=>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=e.defineComponent({__name:"VirtualList",props:{data:null,itemHeight:null},setup(t){const n=t,{list:o,containerProps:l,wrapperProps:s,innerProps:a}=z(e.toRef(n,"data"),{itemHeight:r=>n.itemHeight(0),overscan:10});return(r,d)=>(e.openBlock(),e.createElementBlock("div",de,[e.createElementVNode("div",{onScrollPassive:d[0]||(d[0]=(...i)=>e.unref(l).onScroll&&e.unref(l).onScroll(...i)),ref:e.unref(l).ref,style:e.normalizeStyle(e.unref(l).style),class:"virtualList"},[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)],36)]))}}),Oe="",fe=((t,n)=>{const o=t.__vccOpts||t;for(const[l,s]of n)o[l]=s;return o})(ue,[["__scopeId","data-v-e5ab2b81"]]);c.SvgIcon=ce,c.VirtualList=fe,c.allSelectedKey=E,c.closeDialogKey=N,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=z,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d.ui={},d.Vue))})(this,function(d,e){"use strict";var k;const O=typeof window<"u";O&&((k=window?.navigator)==null?void 0:k.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function D(t){return typeof t=="function"?t():e.unref(t)}function U(t){return t}function W(t){return e.getCurrentScope()?(e.onScopeDispose(t),!0):!1}function q(t,o=!0){e.getCurrentInstance()?e.onMounted(t):o?t():e.nextTick(t)}function R(t){var o;const n=D(t);return(o=n?.$el)!=null?o:n}const G=O?window:void 0;O&&window.document,O&&window.navigator,O&&window.location;function Y(t,o=!1){const n=e.ref(),l=()=>n.value=Boolean(t());return l(),q(l,o),n}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 T=Object.getOwnPropertySymbols,J=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,Z=(t,o)=>{var n={};for(var l in t)J.call(t,l)&&o.indexOf(l)<0&&(n[l]=t[l]);if(t!=null&&T)for(var l of T(t))o.indexOf(l)<0&&X.call(t,l)&&(n[l]=t[l]);return n};function ee(t,o,n={}){const l=n,{window:a=G}=l,i=Z(l,["window"]);let s;const p=Y(()=>a&&"ResizeObserver"in a),h=()=>{s&&(s.disconnect(),s=void 0)},f=e.watch(()=>R(t),m=>{h(),p.value&&a&&m&&(s=new ResizeObserver(o),s.observe(m,i))},{immediate:!0,flush:"post"}),g=()=>{h(),f()};return W(g),{isSupported:p,stop:g}}function te(t,o={width:0,height:0},n={}){const{box:l="content-box"}=n,a=e.ref(o.width),i=e.ref(o.height);return ee(t,([s])=>{const p=l==="border-box"?s.borderBoxSize:l==="content-box"?s.contentBoxSize:s.devicePixelContentBoxSize;p?(a.value=p.reduce((h,{inlineSize:f})=>h+f,0),i.value=p.reduce((h,{blockSize:f})=>h+f,0)):(a.value=s.contentRect.width,i.value=s.contentRect.height)},n),e.watch(()=>R(t),s=>{a.value=s?o.width:0,i.value=s?o.height:0}),{width:a,height:i}}var V;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})(V||(V={}));var ne=Object.defineProperty,$=Object.getOwnPropertySymbols,oe=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,L=(t,o,n)=>o in t?ne(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n,re=(t,o)=>{for(var n in o||(o={}))oe.call(o,n)&&L(t,n,o[n]);if($)for(var n of $(o))le.call(o,n)&&L(t,n,o[n]);return t};re({linear:U},{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 F(t,o){const{itemHeight:n,overscan:l=5}=o,a=e.ref(),i=te(a);let s;const p=e.shallowRef(t),h=e.ref(0),f=e.ref({start:0,end:10});let g=0;const m=e.ref([]),c=e.computed(()=>{let{sum:r,height:u}={sum:0,height:0};return p.value.map((w,_)=>(typeof n=="number"?u=n:u=n(_),r+=u,{height:u,sum:r}))}),b=e.computed(()=>_e(f.value.start)),z=e.computed(()=>typeof n=="number"?c.value.length*n:c.value.at(-1)?.sum||0),ge=e.computed(()=>{let r=m.value.length-l,u=Math.max(r-g,0);return m.value.slice(u,r)});e.onMounted(()=>{}),e.onUnmounted(()=>cancelAnimationFrame(s)),e.watch([i.width,i.height,p],([r,u])=>{(r||u)&&H()},{deep:!0});function H(){cancelAnimationFrame(s),s=requestAnimationFrame(M)}function M(){if(a.value){h.value=a.value.scrollTop,g=ye();let r=be(h.value),u=r+g+l;r=r-l,r=r<0?0:r,u=u>p.value.length?p.value.length:u,f.value={start:r,end:u},m.value=p.value.slice(r,u).map((w,_)=>({data:w,index:_+r}))}}function be(r){let u=Math.floor(c.value.length/16),w=-1,_=-1;for(let y=0;y<16;y++){if(c.value.at(u*y).sum>=r){w=Math.max(0,y-1);break}y===15&&(w=y)}w*=u;for(let y=w;y<c.value.length;y++)if(c.value[y].sum>=r){_=y;break}return Math.max(0,_)}function ye(){let r=0,u=0,w=we();for(let _=w;_<c.value.length&&(u+=c.value[_].height,!(u>=i.height.value));_++,r++);return r}function _e(r){if(typeof n=="number")return r*n;let u=c.value[r];return u.sum-u.height}function Q(r){return c.value.at(r)||{sum:0,height:0}}function we(){let r=f.value.start;return r>=l&&(r+=l),r}function Oe(r){if(a.value){const u=Q(r);a.value.scrollTop=u.sum-u.height,M()}}const Se=e.computed(()=>({style:{width:"100%",height:`${z.value}px`}})),ve=e.computed(()=>({style:{transform:`translate3d(0, ${b.value}px, 0)`,"will-change":"transform"}})),Ie={overflowY:"auto"};return{list:m,visiableList:ge,getItemHeightData:Q,totalHeight:z,clientHeight:i.height,scrollTo:Oe,scrollTop:h,containerProps:{ref:a,onScroll:()=>{H()},style:Ie},wrapperProps:Se,innerProps:ve}}const I=Symbol(),P=Symbol(),C=Symbol(),E=Symbol(),A=Symbol(),x=Symbol(),B=Symbol(),K=Symbol(),j=Symbol();function ae(){const{voidFn:t,boolFn:o,boolRef:n,arrayRef:l}={voidFn:b=>{},boolFn:b=>!1,boolRef:e.computed(()=>!1),arrayRef:e.computed(()=>[])},a=e.inject(E,l),i=e.inject(C,o),s=e.inject(K,n),p=e.inject(P,t),h=e.inject(I,t),f=e.inject(A,t),g=e.inject(x,t),m=e.inject(B,t),c=e.inject(j,t);return{selected:a,isSelected:i,isAllSelected:s,toggle:p,toggleAll:h,select:f,selectAll:g,unselect:m,unselectAll:c}}function ie(t,o){const n=e.ref({}),l=e.computed(()=>t.value.filter(c=>n.value[c[o]])),a=e.computed(()=>l.value.length!=0&&Object.keys(n.value).length==t.value.length);function i(){t.value.forEach(c=>{n.value[c[o]]=!0})}function s(){n.value={}}function p(c){c.forEach(b=>{n.value[b[o]]||(n.value[b[o]]=!0)})}function h(c){c.forEach(b=>{n.value[b[o]]&&delete n.value[b[o]]})}function f(c){return!!n.value[c[o]]}function g(c){c.forEach(b=>{f(b)?delete n.value[b[o]]:n.value[b[o]]=!0})}function m(){a.value?s():i()}return e.provide(I,m),e.provide(P,g),e.provide(C,f),e.provide(E,l),e.provide(A,p),e.provide(x,i),e.provide(B,h),e.provide(K,a),e.provide(j,s),{selected:l,select:p,selectAll:i,unselect:h,unselectAll:s,toggle:g,toggleAll:m,isSelected:f,isAllSelected:a}}const N=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:o}){const n=t,l=()=>{n.closeOnClickOverlay&&o("update:visiable",!1)};return e.provide(N,()=>o("update:visiable",!1)),(a,i)=>(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:i[0]||(i[0]=e.withModifiers(()=>{},["stop"])),class:e.normalizeClass(["dialog m-auto flex flex-col",t.dialogClass])},[e.renderSlot(a.$slots,"default")],2)])):e.createCommentVNode("",!0)]),_:3}))}});function ce(t){function o(n,l){const a=document.createElement("div"),i={setup(){return()=>e.h(se,{visiable:!0,"onUpdate:visiable":()=>{a?.remove()},...t},{default:()=>e.h(n,l)})}};return document.body.appendChild(a),e.render(e.h(i),a),{close:()=>a?.remove()}}return{create:o}}const ue=["xlink:href","fill","color"],de=e.defineComponent({__name:"SvgIcon",props:{name:null,prefix:{default:"icon"},color:{default:"#FFF"},width:null,height:null},setup(t){const o=t,n=e.computed(()=>`#${o.prefix}-${o.name}`),l=e.computed(()=>({width:o.width,height:o.height,aspectRatio:o.width&&o.height?void 0:"1/1"}));return(a,i)=>(e.openBlock(),e.createElementBlock("svg",{"aria-hidden":"",style:e.normalizeStyle(e.unref(l))},[e.createElementVNode("use",{"xlink:href":e.unref(n),fill:t.color,color:t.color},null,8,ue)],4))}}),fe={class:"virtualListWrapper"},pe={inheritAttrs:!1},me=e.defineComponent({...pe,__name:"VirtualList",props:{data:null,itemHeight:null,overscan:{default:10}},setup(t,{expose:o}){const n=t,l=F(e.toRef(n,"data"),{itemHeight:f=>n.itemHeight(n.data[f]),overscan:n.overscan}),{list:a,containerProps:i,wrapperProps:s,innerProps:p,getItemHeightData:h}=l;return o({vListReturn:l}),(f,g)=>(e.openBlock(),e.createElementBlock("div",fe,[e.createElementVNode("div",e.mergeProps({onScrollPassive:g[0]||(g[0]=(...m)=>e.unref(i).onScroll&&e.unref(i).onScroll(...m)),ref:e.unref(i).ref,class:"virtualList"},f.$attrs),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(s))),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(p))),[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(a),({index:m,data:c})=>(e.openBlock(),e.createElementBlock("div",{key:m,style:e.normalizeStyle({height:`${e.unref(h)(m).height}px`,display:"flex"})},[e.renderSlot(f.$slots,"default",{data:c,index:m},void 0,!0)],4))),128))],16)],16)],16)]))}}),Ce="",he=((t,o)=>{const n=t.__vccOpts||t;for(const[l,a]of o)n[l]=a;return n})(me,[["__scopeId","data-v-134ad8ab"]]);d.SvgIcon=de,d.VirtualList=he,d.allSelectedKey=E,d.closeDialogKey=N,d.dialogController=ce,d.isAllSelectedKey=K,d.isSelectedKey=C,d.selectAllKey=x,d.selectKey=A,d.toggleAllKey=I,d.toggleKey=P,d.unselectAllKey=j,d.unselectKey=B,d.useSelectable=ie,d.useSelectableInjectors=ae,d.useVirtualList=F,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .virtualListWrapper[data-v-e5ab2b81]{width:100%;height:100%;position:relative}.virtualList[data-v-e5ab2b81] ::-webkit-scrollbar{display:none}.virtualList[data-v-e5ab2b81]{width:100%;height:100%;position:absolute;top:0;-ms-overflow-style:none;scrollbar-width:none}
1
+ .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}
@@ -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.19",
3
+ "version": "0.0.21",
4
4
  "description": "lazycat ui toolkits",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",