@lazycatcloud/lzc-toolkit 0.0.21 → 0.0.23

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 _, 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
- const P = typeof window < "u";
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);
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 K, 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 Ke, normalizeProps as Z, guardReactiveProps as ee, Fragment as je, renderList as ze } 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 Ae(e) {
8
+ function fe(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 Ne(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 (d) => {
33
+ const u = L(e), h = Date.now() - n;
34
+ if (a(), u <= 0)
35
+ return n = Date.now(), d();
36
+ h > u && (t || !r) ? (n = Date.now(), d()) : l && (o = setTimeout(() => {
37
+ n = Date.now(), r = !0, a(), d();
38
+ }, u)), !t && !o && (o = setTimeout(() => r = !0, u)), r = !1;
39
+ };
40
+ }
41
+ function Qe(e) {
9
42
  return e;
10
43
  }
11
- function $e(e) {
12
- return de() ? (ve(e), !0) : !1;
44
+ function ke(e) {
45
+ return He() ? (Ie(e), !0) : !1;
46
+ }
47
+ function We(e, l = 200, t = {}) {
48
+ return fe(Me(l, t), e);
49
+ }
50
+ function Ue(e, l = 200, t = !1, n = !0) {
51
+ return fe(Ne(l, t, n), e);
13
52
  }
14
- function Te(e, n = !0) {
15
- pe() ? D(e) : n ? e() : he(e);
53
+ function qe(e, l = !0) {
54
+ Te() ? G(e) : l ? e() : ae(e);
16
55
  }
17
- function W(e) {
18
- var n;
19
- const t = Re(e);
20
- return (n = t?.$el) != null ? n : t;
56
+ function de(e) {
57
+ var l;
58
+ const t = L(e);
59
+ return (l = t?.$el) != null ? l : t;
21
60
  }
22
- const Fe = P ? window : void 0;
23
- P && window.document;
24
- P && window.navigator;
25
- P && window.location;
26
- function Le(e, n = !1) {
27
- const t = S(), o = () => t.value = Boolean(e());
28
- return o(), Te(o, n), t;
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;
29
68
  }
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) => {
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) => {
34
73
  var t = {};
35
- for (var o in e)
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]);
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]);
40
79
  return t;
41
80
  };
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();
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), d = () => {
85
+ a && (a.disconnect(), a = void 0);
86
+ }, u = V(() => de(e), (p) => {
87
+ d(), c.value && o && p && (a = new ResizeObserver(l), a.observe(p, r));
88
+ }, { immediate: !0, flush: "post" }), h = () => {
89
+ d(), u();
51
90
  };
52
- return $e(p), {
53
- isSupported: f,
54
- stop: p
91
+ return ke(h), {
92
+ isSupported: c,
93
+ stop: h
55
94
  };
56
95
  }
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;
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((d, { inlineSize: u }) => d + u, 0), r.value = c.reduce((d, { blockSize: u }) => d + u, 0)) : (o.value = a.contentRect.width, r.value = a.contentRect.height);
101
+ }, t), V(() => de(e), (a) => {
102
+ o.value = a ? l.width : 0, r.value = a ? l.height : 0;
64
103
  }), {
65
- width: a,
66
- height: s
104
+ width: o,
105
+ height: r
67
106
  };
68
107
  }
69
- var N;
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
- })(N || (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
- if (Q)
77
- for (var t of Q(n))
78
- Qe.call(n, t) && V(e, t, n[t]);
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 De = {
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,181 +143,181 @@ const De = {
104
143
  easeOutBack: [0.34, 1.56, 0.64, 1],
105
144
  easeInOutBack: [0.68, -0.6, 0.32, 1.6]
106
145
  };
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);
146
+ rt({
147
+ linear: Qe
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), d = m(0), u = m({ start: 0, end: 10 });
153
+ let h = 0;
154
+ const p = m([]), s = g(() => {
155
+ let { sum: i, height: f } = { sum: 0, height: 0 };
156
+ return c.value.map((w, b) => (typeof t == "number" ? f = t : f = t(b), i += f, { height: f, 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, f = Math.max(i - h, 0);
159
+ return p.value.slice(f, i);
121
160
  });
122
- D(() => {
123
- }), me(() => cancelAnimationFrame(r)), $(
124
- [s.width, s.height, f],
125
- ([l, u]) => {
126
- (l || u) && L();
161
+ G(() => {
162
+ }), ie(() => cancelAnimationFrame(a)), V(
163
+ [r.width, r.height, c],
164
+ ([i, f]) => {
165
+ (i || f) && F();
127
166
  },
128
167
  { deep: !0 }
129
168
  );
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) => ({
169
+ function F() {
170
+ cancelAnimationFrame(a), a = requestAnimationFrame(I);
171
+ }
172
+ function I() {
173
+ if (o.value) {
174
+ d.value = o.value.scrollTop, h = j();
175
+ let i = A(d.value), f = i + h + n;
176
+ i = i - n, i = i < 0 ? 0 : i, f = f > c.value.length ? c.value.length : f, u.value = { start: i, end: f }, p.value = c.value.slice(i, f).map((w, b) => ({
138
177
  data: w,
139
- index: b + l
178
+ index: b + i
140
179
  }));
141
180
  }
142
181
  }
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);
182
+ function A(i) {
183
+ let f = Math.floor(s.value.length / 16), w = -1, b = -1;
184
+ for (let _ = 0; _ < 16; _++) {
185
+ if (s.value.at(f * _).sum >= i) {
186
+ w = Math.max(0, _ - 1);
148
187
  break;
149
188
  }
150
- m === 15 && (w = m);
189
+ _ === 15 && (w = _);
151
190
  }
152
- w *= u;
153
- for (let m = w; m < i.value.length; m++)
154
- if (i.value[m].sum >= l) {
155
- b = m;
191
+ w *= f;
192
+ for (let _ = w; _ < s.value.length; _++)
193
+ if (s.value[_].sum >= i) {
194
+ b = _;
156
195
  break;
157
196
  }
158
197
  return Math.max(0, b);
159
198
  }
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++)
199
+ function j() {
200
+ let i = 0, f = 0, w = z();
201
+ for (let b = w; b < s.value.length && (i++, f += s.value[b].height, !(f >= r.height.value)); b++)
163
202
  ;
164
- return l;
203
+ return i;
165
204
  }
166
- function se(l) {
205
+ function D(i) {
167
206
  if (typeof t == "number")
168
- return l * t;
169
- let u = i.value[l];
170
- return u.sum - u.height;
207
+ return i * t;
208
+ let f = s.value[i];
209
+ return f.sum - f.height;
171
210
  }
172
- function H(l) {
173
- return i.value.at(l) || { sum: 0, height: 0 };
211
+ function $(i) {
212
+ return s.value.at(i) || { sum: 0, height: 0 };
174
213
  }
175
- function re() {
176
- let l = c.value.start;
177
- return l >= o && (l += o), l;
214
+ function z() {
215
+ let i = u.value.start;
216
+ return i >= n && (i += n), i;
178
217
  }
179
- function ie(l) {
180
- if (a.value) {
181
- const u = H(l);
182
- a.value.scrollTop = u.sum - u.height, B();
218
+ function M(i) {
219
+ if (o.value) {
220
+ const f = $(i);
221
+ o.value.scrollTop = f.sum - f.height, I();
183
222
  }
184
223
  }
185
- const ue = g(() => ({
224
+ const N = g(() => ({
186
225
  style: {
187
226
  width: "100%",
188
- height: `${F.value}px`
227
+ height: `${H.value}px`
189
228
  }
190
- })), ce = g(() => ({
229
+ })), Q = g(() => ({
191
230
  style: {
192
- transform: `translate3d(0, ${h.value}px, 0)`,
231
+ transform: `translate3d(0, ${v.value}px, 0)`,
193
232
  "will-change": "transform"
194
233
  }
195
- })), fe = {
234
+ })), k = {
196
235
  overflowY: "auto"
197
236
  };
198
237
  return {
199
- list: d,
200
- visiableList: oe,
201
- getItemHeightData: H,
202
- totalHeight: F,
203
- clientHeight: s.height,
204
- scrollTo: ie,
205
- scrollTop: v,
238
+ list: p,
239
+ visiableList: B,
240
+ getItemHeightData: $,
241
+ totalHeight: H,
242
+ clientHeight: r.height,
243
+ scrollTo: M,
244
+ scrollTop: d,
206
245
  containerProps: {
207
- ref: a,
246
+ ref: o,
208
247
  onScroll: () => {
209
- L();
248
+ F();
210
249
  },
211
- style: fe
250
+ style: k
212
251
  },
213
- wrapperProps: ue,
214
- innerProps: ce
252
+ wrapperProps: N,
253
+ innerProps: Q
215
254
  };
216
255
  }
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) => {
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) => {
221
260
  },
222
- boolFn: (h) => !1,
261
+ boolFn: (v) => !1,
223
262
  boolRef: g(() => !1),
224
263
  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);
264
+ }, o = x(ge, n), r = x(he, l), a = x(ye, t), c = x(pe, e), d = x(ve, e), u = x(me, e), h = x(be, e), p = x(_e, e), s = x(we, e);
226
265
  return {
227
- selected: a,
228
- isSelected: s,
229
- isAllSelected: r,
230
- toggle: f,
231
- toggleAll: v,
232
- select: c,
233
- selectAll: p,
234
- unselect: d,
235
- unselectAll: i
266
+ selected: o,
267
+ isSelected: r,
268
+ isAllSelected: a,
269
+ toggle: c,
270
+ toggleAll: d,
271
+ select: u,
272
+ selectAll: h,
273
+ unselect: p,
274
+ unselectAll: s
236
275
  };
237
276
  }
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;
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;
243
282
  });
244
283
  }
245
- function r() {
284
+ function a() {
246
285
  t.value = {};
247
286
  }
248
- function f(i) {
249
- i.forEach((h) => {
250
- t.value[h[n]] || (t.value[h[n]] = !0);
287
+ function c(s) {
288
+ s.forEach((v) => {
289
+ t.value[v[l]] || (t.value[v[l]] = !0);
251
290
  });
252
291
  }
253
- function v(i) {
254
- i.forEach((h) => {
255
- t.value[h[n]] && delete t.value[h[n]];
292
+ function d(s) {
293
+ s.forEach((v) => {
294
+ t.value[v[l]] && delete t.value[v[l]];
256
295
  });
257
296
  }
258
- function c(i) {
259
- return !!t.value[i[n]];
297
+ function u(s) {
298
+ return !!t.value[s[l]];
260
299
  }
261
- function p(i) {
262
- i.forEach((h) => {
263
- c(h) ? delete t.value[h[n]] : t.value[h[n]] = !0;
300
+ function h(s) {
301
+ s.forEach((v) => {
302
+ u(v) ? delete t.value[v[l]] : t.value[v[l]] = !0;
264
303
  });
265
304
  }
266
- function d() {
267
- a.value ? r() : s();
305
+ function p() {
306
+ o.value ? a() : r();
268
307
  }
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), {
270
- selected: o,
271
- select: f,
272
- selectAll: s,
273
- unselect: v,
274
- unselectAll: r,
275
- toggle: p,
276
- toggleAll: d,
277
- isSelected: c,
278
- isAllSelected: a
308
+ return O(ve, p), O(pe, h), O(he, u), O(ge, n), O(me, c), O(be, r), O(_e, d), O(ye, o), O(we, a), {
309
+ selected: n,
310
+ select: c,
311
+ selectAll: r,
312
+ unselect: d,
313
+ unselectAll: a,
314
+ toggle: h,
315
+ toggleAll: p,
316
+ isSelected: u,
317
+ isAllSelected: o
279
318
  };
280
319
  }
281
- const Ue = Symbol(), We = /* @__PURE__ */ T({
320
+ const st = Symbol(), ut = /* @__PURE__ */ K({
282
321
  __name: "Dialog",
283
322
  props: {
284
323
  visiable: { type: Boolean, default: !1 },
@@ -286,58 +325,58 @@ const Ue = Symbol(), We = /* @__PURE__ */ T({
286
325
  dialogClass: { default: "" }
287
326
  },
288
327
  emits: ["update:visiable"],
289
- setup(e, { emit: n }) {
290
- const t = e, o = () => {
291
- t.closeOnClickOverlay && n("update:visiable", !1);
328
+ setup(e, { emit: l }) {
329
+ const t = e, n = () => {
330
+ t.closeOnClickOverlay && l("update:visiable", !1);
292
331
  };
293
- return y(Ue, () => n("update:visiable", !1)), (a, s) => (I(), be(ye, { name: "modal" }, {
294
- default: _e(() => [
295
- 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", {
296
335
  key: 0,
297
- onClick: o,
336
+ onClick: n,
298
337
  class: "modal absolute inset-0 bottom-0 z-50 flex bg-stone-900 bg-opacity-50"
299
338
  }, [
300
339
  C("div", {
301
- onClick: s[0] || (s[0] = we(() => {
340
+ onClick: r[0] || (r[0] = Ce(() => {
302
341
  }, ["stop"])),
303
- class: Oe(["dialog m-auto flex flex-col", e.dialogClass])
342
+ class: Be(["dialog m-auto flex flex-col", e.dialogClass])
304
343
  }, [
305
- M(a.$slots, "default")
344
+ J(o.$slots, "default")
306
345
  ], 2)
307
- ])) : Se("", !0)
346
+ ])) : Pe("", !0)
308
347
  ]),
309
348
  _: 3
310
349
  }));
311
350
  }
312
351
  });
313
- function nt(e) {
314
- function n(t, o) {
315
- const a = document.createElement("div"), s = {
352
+ function wt(e) {
353
+ function l(t, n) {
354
+ const o = document.createElement("div"), r = {
316
355
  setup() {
317
- return () => E(
318
- We,
356
+ return () => U(
357
+ ut,
319
358
  {
320
359
  visiable: !0,
321
360
  "onUpdate:visiable": () => {
322
- a?.remove();
361
+ o?.remove();
323
362
  },
324
363
  ...e
325
364
  },
326
365
  {
327
- default: () => E(t, o)
366
+ default: () => U(t, n)
328
367
  }
329
368
  );
330
369
  }
331
370
  };
332
- return document.body.appendChild(a), Ie(E(s), a), {
333
- close: () => a?.remove()
371
+ return document.body.appendChild(o), Re(U(r), o), {
372
+ close: () => o?.remove()
334
373
  };
335
374
  }
336
375
  return {
337
- create: n
376
+ create: l
338
377
  };
339
378
  }
340
- const qe = ["xlink:href", "fill", "color"], ot = /* @__PURE__ */ T({
379
+ const ct = ["xlink:href", "fill", "color"], St = /* @__PURE__ */ K({
341
380
  __name: "SvgIcon",
342
381
  props: {
343
382
  name: null,
@@ -347,57 +386,184 @@ const qe = ["xlink:href", "fill", "color"], ot = /* @__PURE__ */ T({
347
386
  height: null
348
387
  },
349
388
  setup(e) {
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"
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"
354
393
  }));
355
- return (a, s) => (I(), x("svg", {
394
+ return (o, r) => (E(), P("svg", {
356
395
  "aria-hidden": "",
357
- style: U(_(o))
396
+ style: X(y(n))
358
397
  }, [
359
398
  C("use", {
360
- "xlink:href": _(t),
399
+ "xlink:href": y(t),
361
400
  fill: e.color,
362
401
  color: e.color
363
- }, null, 8, qe)
402
+ }, null, 8, ct)
364
403
  ], 4));
365
404
  }
366
- }), Ge = { class: "virtualListWrapper" }, Ye = {
405
+ });
406
+ function ft(e) {
407
+ const { containerEl: l, sliderEl: t, autoHeight: n, performance: o = {} } = e, r = m(!0), a = We(Q, 1e3), c = Ue(W, 1e3, !0, !0);
408
+ let d, 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), j = g(() => Math.max(
417
+ v.value.clientHeight / v.value.scrollHeight,
418
+ 0.05
419
+ )), D = g(() => j.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 z(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 N() {
431
+ r.value = !1;
432
+ }
433
+ function Q() {
434
+ B.value || (r.value = !0);
435
+ }
436
+ function k(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 || f();
446
+ }
447
+ function f() {
448
+ cancelAnimationFrame(d), d = 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", z, {
456
+ passive: !0
457
+ }), window[S]("pointermove", k, { 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
+ N(), a();
478
+ }), {
479
+ isScrollEnd: r,
480
+ isDragSlider: B,
481
+ scrollable: F,
482
+ sliderPos: $,
483
+ init: Oe,
484
+ modifySliderEventListener: b
485
+ };
486
+ }
487
+ const dt = (e) => ($e("data-v-9645dfb5"), e = e(), Le(), e), vt = /* @__PURE__ */ dt(() => /* @__PURE__ */ C("div", { class: "default-slider" }, null, -1)), pt = /* @__PURE__ */ K({
488
+ __name: "ScrollBar",
489
+ props: {
490
+ containerEl: null,
491
+ autoHide: { type: Boolean },
492
+ autoHeight: { type: Boolean },
493
+ performance: null
494
+ },
495
+ setup(e, { expose: l }) {
496
+ const t = e, n = !!Fe().default, o = m(null), r = g(() => t.containerEl), a = ft({
497
+ containerEl: r,
498
+ sliderEl: o,
499
+ autoHeight: n ? t.autoHeight : !0,
500
+ performance: t.performance
501
+ }), { scrollable: c, isScrollEnd: d, sliderPos: u } = a, h = t.autoHide ? g(() => !d.value) : g(() => c.value);
502
+ return G(() => {
503
+ ae(() => {
504
+ a.init();
505
+ });
506
+ }), ie(() => {
507
+ a.modifySliderEventListener("remove");
508
+ }), l({ uScrollBarReturn: a }), (p, s) => (E(), se(ue, null, {
509
+ default: ce(() => [
510
+ Ae(C("div", {
511
+ ref_key: "sliderRef",
512
+ ref: o,
513
+ class: "slider-wrapper",
514
+ style: X(y(u))
515
+ }, [
516
+ J(p.$slots, "default", {}, () => [
517
+ vt
518
+ ], !0)
519
+ ], 4), [
520
+ [De, y(h)]
521
+ ])
522
+ ]),
523
+ _: 3
524
+ }));
525
+ }
526
+ });
527
+ const Se = (e, l) => {
528
+ const t = e.__vccOpts || e;
529
+ for (const [n, o] of l)
530
+ t[n] = o;
531
+ return t;
532
+ }, Ot = /* @__PURE__ */ Se(pt, [["__scopeId", "data-v-9645dfb5"]]), ht = { class: "virtualListWrapper" }, gt = {
367
533
  inheritAttrs: !1
368
- }, Je = /* @__PURE__ */ T({
369
- ...Ye,
534
+ }, mt = /* @__PURE__ */ K({
535
+ ...gt,
370
536
  __name: "VirtualList",
371
537
  props: {
372
538
  data: null,
373
539
  itemHeight: null,
374
540
  overscan: { default: 10 }
375
541
  },
376
- setup(e, { expose: n }) {
377
- const t = e, o = Me(xe(t, "data"), {
378
- itemHeight: (c) => t.itemHeight(t.data[c]),
542
+ setup(e, { expose: l }) {
543
+ const t = e, n = it(Ve(t, "data"), {
544
+ itemHeight: (u) => t.itemHeight(t.data[u]),
379
545
  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,
546
+ }), { list: o, containerProps: r, wrapperProps: a, innerProps: c, getItemHeightData: d } = n;
547
+ return l({
548
+ vListReturn: n
549
+ }), (u, h) => (E(), P("div", ht, [
550
+ C("div", Ke({
551
+ onScrollPassive: h[0] || (h[0] = (...p) => y(r).onScroll && y(r).onScroll(...p)),
552
+ ref: y(r).ref,
387
553
  class: "virtualList"
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`,
554
+ }, u.$attrs), [
555
+ C("div", Z(ee(y(a))), [
556
+ C("div", Z(ee(y(c))), [
557
+ (E(!0), P(je, null, ze(y(o), ({ index: p, data: s }) => (E(), P("div", {
558
+ key: p,
559
+ style: X({
560
+ height: `${y(d)(p).height}px`,
395
561
  display: "flex"
396
562
  })
397
563
  }, [
398
- M(c.$slots, "default", {
399
- data: i,
400
- index: d
564
+ J(u.$slots, "default", {
565
+ data: s,
566
+ index: p
401
567
  }, void 0, !0)
402
568
  ], 4))), 128))
403
569
  ], 16)
@@ -406,27 +572,23 @@ const qe = ["xlink:href", "fill", "color"], ot = /* @__PURE__ */ T({
406
572
  ]));
407
573
  }
408
574
  });
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"]]);
575
+ const xt = /* @__PURE__ */ Se(mt, [["__scopeId", "data-v-134ad8ab"]]);
415
576
  export {
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
577
+ Ot as ScrollBar,
578
+ St as SvgIcon,
579
+ xt as VirtualList,
580
+ ge as allSelectedKey,
581
+ st as closeDialogKey,
582
+ wt as dialogController,
583
+ ye as isAllSelectedKey,
584
+ he as isSelectedKey,
585
+ be as selectAllKey,
586
+ me as selectKey,
587
+ ve as toggleAllKey,
588
+ pe as toggleKey,
589
+ we as unselectAllKey,
590
+ _e as unselectKey,
591
+ yt as useSelectable,
592
+ _t as useSelectableInjectors,
593
+ it as useVirtualList
432
594
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
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"}})});
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,n){function l(...o){t(()=>n.apply(this,o),{fn:n,thisArg:this,args:o})}return l}function ie(t,n={}){let l,o;return i=>{const a=B(t),d=B(n.maxWait);if(l&&clearTimeout(l),a<=0||d!==void 0&&d<=0)return o&&(clearTimeout(o),o=null),i();d&&!o&&(o=setTimeout(()=>{l&&clearTimeout(l),o=null,i()},d)),l=setTimeout(()=>{o&&clearTimeout(o),o=null,i()},a)}}function ae(t,n=!0,l=!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&&(l||!i)?(o=Date.now(),p()):n&&(r=setTimeout(()=>{o=Date.now(),i=!0,a(),p()},u)),!l&&!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,n=200,l={}){return J(ie(n,l),t)}function de(t,n=200,l=!1,o=!0){return J(ae(n,l,o),t)}function fe(t,n=!0){e.getCurrentInstance()?e.onMounted(t):n?t():e.nextTick(t)}function X(t){var n;const l=B(t);return(n=l?.$el)!=null?n:l}const pe=I?window:void 0;I&&window.document,I&&window.navigator,I&&window.location;function he(t,n=!1){const l=e.ref(),o=()=>l.value=Boolean(t());return o(),fe(o,n),l}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,n)=>{var l={};for(var o in t)me.call(t,o)&&n.indexOf(o)<0&&(l[o]=t[o]);if(t!=null&&Z)for(var o of Z(t))n.indexOf(o)<0&&ge.call(t,o)&&(l[o]=t[o]);return l};function be(t,n,l={}){const o=l,{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(n),a.observe(m,i))},{immediate:!0,flush:"post"}),v=()=>{p(),u()};return ce(v),{isSupported:d,stop:v}}function ye(t,n={width:0,height:0},l={}){const{box:o="content-box"}=l,r=e.ref(n.width),i=e.ref(n.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)},l),e.watch(()=>X(t),a=>{r.value=a?n.width:0,i.value=a?n.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,le=(t,n,l)=>n in t?_e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[n]=l,Oe=(t,n)=>{for(var l in n||(n={}))we.call(n,l)&&le(t,l,n[l]);if(te)for(var l of te(n))Se.call(n,l)&&le(t,l,n[l]);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 ne(t,n){const{itemHeight:l,overscan:o=5}=n,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 l=="number"?f=l:f=l(b),s+=f,{height:f,sum:s}))}),h=e.computed(()=>P(u.value.start)),S=e.computed(()=>typeof l=="number"?c.value.length*l: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=M();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 M(){let s=0,f=0,_=z();for(let b=_;b<c.value.length&&(s++,f+=c.value[b].height,!(f>=i.height.value));b++);return s}function P(s){if(typeof l=="number")return s*l;let f=c.value[s];return f.sum-f.height}function x(s){return c.value.at(s)||{sum:0,height:0}}function z(){let s=u.value.start;return s>=o&&(s+=o),s}function Q(s){if(r.value){const f=x(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:x,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(),V=Symbol(),$=Symbol(),k=Symbol(),N=Symbol();function Ee(){const{voidFn:t,boolFn:n,boolRef:l,arrayRef:o}={voidFn:h=>{},boolFn:h=>!1,boolRef:e.computed(()=>!1),arrayRef:e.computed(()=>[])},r=e.inject(j,o),i=e.inject(L,n),a=e.inject(k,l),d=e.inject(F,t),p=e.inject(D,t),u=e.inject(K,t),v=e.inject(V,t),m=e.inject($,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,n){const l=e.ref({}),o=e.computed(()=>t.value.filter(c=>l.value[c[n]])),r=e.computed(()=>o.value.length!=0&&Object.keys(l.value).length==t.value.length);function i(){t.value.forEach(c=>{l.value[c[n]]=!0})}function a(){l.value={}}function d(c){c.forEach(h=>{l.value[h[n]]||(l.value[h[n]]=!0)})}function p(c){c.forEach(h=>{l.value[h[n]]&&delete l.value[h[n]]})}function u(c){return!!l.value[c[n]]}function v(c){c.forEach(h=>{u(h)?delete l.value[h[n]]:l.value[h[n]]=!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(V,i),e.provide($,p),e.provide(k,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:n}){const l=t,o=()=>{l.closeOnClickOverlay&&n("update:visiable",!1)};return e.provide(oe,()=>n("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 n(l,o){const r=document.createElement("div"),i={setup(){return()=>e.h(Ie,{visiable:!0,"onUpdate:visiable":()=>{r?.remove()},...t},{default:()=>e.h(l,o)})}};return document.body.appendChild(r),e.render(e.h(i),r),{close:()=>r?.remove()}}return{create:n}}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 n=t,l=e.computed(()=>`#${n.prefix}-${n.name}`),o=e.computed(()=>({width:n.width,height:n.height,aspectRatio:n.width&&n.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(l),fill:t.color,color:t.color},null,8,He)],4))}});function Pe(t){const{containerEl:n,sliderEl:l,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),M=e.computed(()=>Math.max(h.value.clientHeight/h.value.scrollHeight,.05)),P=e.computed(()=>M.value*h.value.clientHeight),x=e.computed(()=>({willChange:"transform",transform:`translate3d(0,${c.value}px,0)`,height:o?`${P.value}px`:void 0}));function z(E){m.value=E.clientY-l.value.getBoundingClientRect().top||1,u=getComputedStyle(n.value).scrollBehavior,u==="smooth"&&(n.value.style.scrollBehavior="unset")}function Q(){n.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,n.value.scrollTo({top:c.value/O.value*C.value})}function s(){T.value||f()}function f(){cancelAnimationFrame(p),p=requestAnimationFrame(_)}function _(){n.value&&(v.value=r.scrollTop?.value??n.value.scrollTop,c.value=v.value/C.value*O.value)}function b(E){let w="addEventListener";E==="add"?w="addEventListener":w="removeEventListener",l.value?.[w]("pointerdown",z,{passive:!0}),window[w]("pointermove",q,{passive:!0}),window[w]("pointerup",Q,{passive:!0})}const y=new MutationObserver(E=>{E.map(Ve=>Ve.oldValue).join().includes("height")?Y():S.value.clientHeight===0&&d()});function Y(){h.value.top=n.value?.getBoundingClientRect().top??0,h.value.scrollHeight=n.value?.scrollHeight??0,h.value.clientHeight=n.value?.clientHeight??0,o?S.value.clientHeight=P.value:S.value.clientHeight=l.value?.clientHeight??0}function Ke(){n.value&&l.value?(n.value.addEventListener("scroll",s,{passive:!0}),b("add"),y.observe(n.value,{subtree:!0,attributeOldValue:!0,attributeFilter:["style"]}),setTimeout(()=>{Y()},100)):console.error("useScrollBar:","\u521D\u59CB\u5316\u5931\u8D25!",{containerEl:n,sliderEl:l})}return e.watch(v,()=>{U(),a()}),{isScrollEnd:i,isDragSlider:T,scrollable:H,sliderPos:x,init:Ke,modifySliderEventListener:b}}const xe=(t=>(e.pushScopeId("data-v-9645dfb5"),t=t(),e.popScopeId(),t))(()=>e.createElementVNode("div",{class:"default-slider"},null,-1)),Re=e.defineComponent({__name:"ScrollBar",props:{containerEl:null,autoHide:{type:Boolean},autoHeight:{type:Boolean},performance:null},setup(t,{expose:n}){const l=t,o=!!e.useSlots().default,r=e.ref(null),i=e.computed(()=>l.containerEl),a=Pe({containerEl:i,sliderEl:r,autoHeight:o?l.autoHeight:!0,performance:l.performance}),{scrollable:d,isScrollEnd:p,sliderPos:u}=a,v=l.autoHide?e.computed(()=>!p.value):e.computed(()=>d.value);return e.onMounted(()=>{e.nextTick(()=>{a.init()})}),e.onUnmounted(()=>{a.modifySliderEventListener("remove")}),n({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:"slider-wrapper",style:e.normalizeStyle(e.unref(u))},[e.renderSlot(m.$slots,"default",{},()=>[xe],!0)],4),[[e.vShow,e.unref(v)]])]),_:3}))}}),Ne="",re=(t,n)=>{const l=t.__vccOpts||t;for(const[o,r]of n)l[o]=r;return l},Ae=re(Re,[["__scopeId","data-v-9645dfb5"]]),De={class:"virtualListWrapper"},Fe={inheritAttrs:!1},Le=e.defineComponent({...Fe,__name:"VirtualList",props:{data:null,itemHeight:null,overscan:{default:10}},setup(t,{expose:n}){const l=t,o=ne(e.toRef(l,"data"),{itemHeight:u=>l.itemHeight(l.data[u]),overscan:l.overscan}),{list:r,containerProps:i,wrapperProps:a,innerProps:d,getItemHeightData:p}=o;return n({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)]))}}),Me="",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=k,g.isSelectedKey=L,g.selectAllKey=V,g.selectKey=K,g.toggleAllKey=D,g.toggleKey=F,g.unselectAllKey=N,g.unselectKey=$,g.useSelectable=Te,g.useSelectableInjectors=Ee,g.useVirtualList=ne,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/dist/style.css CHANGED
@@ -1 +1 @@
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}
1
+ .v-enter-active[data-v-9645dfb5]{opacity:0}.v-leave-active[data-v-9645dfb5]{transition:all .15s ease-out}.v-leave-to[data-v-9645dfb5]{opacity:0}.slider-wrapper[data-v-9645dfb5]{z-index:100;position:absolute;right:0;touch-action:none}.default-slider[data-v-9645dfb5]{width:6px;height:100%;background-color:#0003;border-radius:3px;margin-right:3px}.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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazycatcloud/lzc-toolkit",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "lazycat ui toolkits",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",