@lazycatcloud/lzc-toolkit 0.0.44 → 0.0.45

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,7 +1,7 @@
1
- import { unref as S, getCurrentScope as $e, onScopeDispose as Ae, getCurrentInstance as Fe, onMounted as le, nextTick as ge, ref as m, watch as $, shallowRef as Le, computed as h, onUnmounted as me, inject as H, provide as E, defineComponent as N, openBlock as T, createBlock as _e, Transition as ye, withCtx as be, createElementBlock as P, createElementVNode as R, withModifiers as De, normalizeClass as Me, renderSlot as ne, createCommentVNode as Ve, render as ke, h as X, normalizeStyle as oe, useSlots as Ke, withDirectives as je, vShow as ze, pushScopeId as Ne, popScopeId as Qe, toRef as We, mergeProps as Ue, normalizeProps as ue, guardReactiveProps as ce, Fragment as qe, renderList as Ye } from "vue";
2
- var de;
1
+ import { unref as S, getCurrentScope as $e, onScopeDispose as Ae, getCurrentInstance as Fe, onMounted as le, nextTick as he, ref as m, watch as $, shallowRef as Le, computed as h, onUnmounted as ge, inject as H, provide as x, defineComponent as N, openBlock as T, createBlock as me, Transition as be, withCtx as ye, createElementBlock as P, createElementVNode as R, withModifiers as De, normalizeClass as Me, renderSlot as ne, createCommentVNode as Ve, render as ke, h as X, normalizeStyle as oe, useSlots as ze, withDirectives as Ke, vShow as je, pushScopeId as Ne, popScopeId as Qe, toRef as We, mergeProps as Ue, normalizeProps as ie, guardReactiveProps as ue, Fragment as qe, renderList as Ye } from "vue";
2
+ var ce;
3
3
  const A = typeof window < "u";
4
- A && ((de = window?.navigator) == null ? void 0 : de.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
4
+ A && ((ce = window?.navigator) == null ? void 0 : ce.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
5
5
  function Z(e) {
6
6
  return typeof e == "function" ? e() : S(e);
7
7
  }
@@ -30,13 +30,13 @@ function Xe(e) {
30
30
  function Ze(e) {
31
31
  return $e() ? (Ae(e), !0) : !1;
32
32
  }
33
- function we(e, t = 200, l = {}) {
33
+ function _e(e, t = 200, l = {}) {
34
34
  return Ge(Je(t, l), e);
35
35
  }
36
36
  function et(e, t = !0) {
37
- Fe() ? le(e) : t ? e() : ge(e);
37
+ Fe() ? le(e) : t ? e() : he(e);
38
38
  }
39
- function Se(e) {
39
+ function we(e) {
40
40
  var t;
41
41
  const l = Z(e);
42
42
  return (t = l?.$el) != null ? t : l;
@@ -52,12 +52,12 @@ function lt(e, t = !1) {
52
52
  const ee = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, te = "__vueuse_ssr_handlers__";
53
53
  ee[te] = ee[te] || {};
54
54
  ee[te];
55
- var ve = Object.getOwnPropertySymbols, nt = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, rt = (e, t) => {
55
+ var de = Object.getOwnPropertySymbols, nt = Object.prototype.hasOwnProperty, ot = Object.prototype.propertyIsEnumerable, rt = (e, t) => {
56
56
  var l = {};
57
57
  for (var n in e)
58
58
  nt.call(e, n) && t.indexOf(n) < 0 && (l[n] = e[n]);
59
- if (e != null && ve)
60
- for (var n of ve(e))
59
+ if (e != null && de)
60
+ for (var n of de(e))
61
61
  t.indexOf(n) < 0 && ot.call(e, n) && (l[n] = e[n]);
62
62
  return l;
63
63
  };
@@ -66,7 +66,7 @@ function st(e, t, l = {}) {
66
66
  let o;
67
67
  const d = lt(() => r && "ResizeObserver" in r), g = () => {
68
68
  o && (o.disconnect(), o = void 0);
69
- }, f = $(() => Se(e), (p) => {
69
+ }, f = $(() => we(e), (p) => {
70
70
  g(), d.value && r && p && (o = new ResizeObserver(t), o.observe(p, a));
71
71
  }, { immediate: !0, flush: "post" }), v = () => {
72
72
  g(), f();
@@ -81,23 +81,23 @@ function at(e, t = { width: 0, height: 0 }, l = {}) {
81
81
  return st(e, ([o]) => {
82
82
  const d = n === "border-box" ? o.borderBoxSize : n === "content-box" ? o.contentBoxSize : o.devicePixelContentBoxSize;
83
83
  d ? (r.value = d.reduce((g, { inlineSize: f }) => g + f, 0), a.value = d.reduce((g, { blockSize: f }) => g + f, 0)) : (r.value = o.contentRect.width, a.value = o.contentRect.height);
84
- }, l), $(() => Se(e), (o) => {
84
+ }, l), $(() => we(e), (o) => {
85
85
  r.value = o ? t.width : 0, a.value = o ? t.height : 0;
86
86
  }), {
87
87
  width: r,
88
88
  height: a
89
89
  };
90
90
  }
91
- var fe;
91
+ var ve;
92
92
  (function(e) {
93
93
  e.UP = "UP", e.RIGHT = "RIGHT", e.DOWN = "DOWN", e.LEFT = "LEFT", e.NONE = "NONE";
94
- })(fe || (fe = {}));
95
- var it = Object.defineProperty, pe = Object.getOwnPropertySymbols, ut = Object.prototype.hasOwnProperty, ct = Object.prototype.propertyIsEnumerable, he = (e, t, l) => t in e ? it(e, t, { enumerable: !0, configurable: !0, writable: !0, value: l }) : e[t] = l, dt = (e, t) => {
94
+ })(ve || (ve = {}));
95
+ var it = Object.defineProperty, fe = Object.getOwnPropertySymbols, ut = Object.prototype.hasOwnProperty, ct = Object.prototype.propertyIsEnumerable, pe = (e, t, l) => t in e ? it(e, t, { enumerable: !0, configurable: !0, writable: !0, value: l }) : e[t] = l, dt = (e, t) => {
96
96
  for (var l in t || (t = {}))
97
- ut.call(t, l) && he(e, l, t[l]);
98
- if (pe)
99
- for (var l of pe(t))
100
- ct.call(t, l) && he(e, l, t[l]);
97
+ ut.call(t, l) && pe(e, l, t[l]);
98
+ if (fe)
99
+ for (var l of fe(t))
100
+ ct.call(t, l) && pe(e, l, t[l]);
101
101
  return e;
102
102
  };
103
103
  const vt = {
@@ -130,19 +130,19 @@ dt({
130
130
  linear: Xe
131
131
  }, vt);
132
132
  function ft(e, t) {
133
- const { scrollEndHook: l, itemHeight: n, overscan: r = 5 } = t, a = m(null), o = at(a), d = m(!0), g = we(W, 100);
133
+ const { scrollEndHook: l, itemHeight: n, overscan: r = 5 } = t, a = m(null), o = at(a), d = m(!0), g = _e(W, 100);
134
134
  let f;
135
135
  const v = Le(e), p = m(0), i = m({ start: 0, end: 10 });
136
136
  let u = 0;
137
- const x = m([]), _ = h(() => {
137
+ const E = m([]), b = h(() => {
138
138
  let { sum: s, height: c } = { sum: 0, height: 0 };
139
139
  return v.value.map((O, w) => (typeof n == "number" ? c = n : c = n(w), s += c, { height: c, sum: s }));
140
- }), Q = h(() => k(i.value.start)), I = h(() => typeof n == "number" ? _.value.length * n : _.value[_.value.length - 1]?.sum || 0), F = h(() => {
141
- let s = x.value.length - r, c = Math.max(s - u, 0);
142
- return x.value.slice(c, s);
140
+ }), Q = h(() => k(i.value.start)), I = h(() => typeof n == "number" ? b.value.length * n : b.value[b.value.length - 1]?.sum || 0), F = h(() => {
141
+ let s = E.value.length - r, c = Math.max(s - u, 0);
142
+ return E.value.slice(c, s);
143
143
  });
144
144
  le(() => {
145
- }), me(() => cancelAnimationFrame(f)), $(
145
+ }), ge(() => cancelAnimationFrame(f)), $(
146
146
  [o.width, o.height, v],
147
147
  ([s, c]) => {
148
148
  (s || c) && D();
@@ -164,34 +164,34 @@ function ft(e, t) {
164
164
  if (a.value) {
165
165
  p.value = a.value.scrollTop, u = B();
166
166
  let s = V(p.value), c = s + u + r;
167
- s = s - r, s = s < 0 ? 0 : s, c = c > v.value.length ? v.value.length : c, i.value = { start: s, end: c }, x.value = v.value.slice(s, c).map((O, w) => ({
167
+ s = s - r, s = s < 0 ? 0 : s, c = c > v.value.length ? v.value.length : c, i.value = { start: s, end: c }, E.value = v.value.slice(s, c).map((O, w) => ({
168
168
  data: O,
169
169
  index: w + s
170
170
  }));
171
171
  }
172
172
  }
173
173
  function V(s) {
174
- let c = 0, O = _.value.length - 1, w = -1;
174
+ let c = 0, O = b.value.length - 1, w = -1;
175
175
  for (; c <= O; ) {
176
176
  const y = Math.floor((c + O) / 2);
177
- _.value[y].sum >= s ? (w = y, O = y - 1) : c = y + 1;
177
+ b.value[y].sum >= s ? (w = y, O = y - 1) : c = y + 1;
178
178
  }
179
179
  return Math.max(0, w);
180
180
  }
181
181
  function B() {
182
182
  let s = 0, c = 0, O = U();
183
- for (let w = O; w < _.value.length && (s++, c += _.value[w].height, !(c >= o.height.value)); w++)
183
+ for (let w = O; w < b.value.length && (s++, c += b.value[w].height, !(c >= o.height.value)); w++)
184
184
  ;
185
185
  return s;
186
186
  }
187
187
  function k(s) {
188
188
  if (typeof n == "number")
189
189
  return s * n;
190
- let c = _.value[s];
190
+ let c = b.value[s];
191
191
  return c ? c.sum - c.height : 0;
192
192
  }
193
- function K(s) {
194
- return _.value[s] || { sum: 0, height: 0 };
193
+ function z(s) {
194
+ return b.value[s] || { sum: 0, height: 0 };
195
195
  }
196
196
  function U() {
197
197
  let s = i.value.start;
@@ -199,7 +199,7 @@ function ft(e, t) {
199
199
  }
200
200
  function q(s) {
201
201
  if (a.value) {
202
- const c = K(s);
202
+ const c = z(s);
203
203
  a.value.scrollTop = c.sum - c.height, M();
204
204
  }
205
205
  }
@@ -209,7 +209,7 @@ function ft(e, t) {
209
209
  height: `${I.value}px`,
210
210
  pointerEvents: d.value ? void 0 : "none"
211
211
  }
212
- })), j = h(() => ({
212
+ })), K = h(() => ({
213
213
  style: {
214
214
  transform: `translate3d(0, ${Q.value}px, 0)`,
215
215
  "will-change": "transform"
@@ -218,9 +218,9 @@ function ft(e, t) {
218
218
  overflowY: "auto"
219
219
  };
220
220
  return {
221
- list: x,
221
+ list: E,
222
222
  visiableList: F,
223
- getItemHeightData: K,
223
+ getItemHeightData: z,
224
224
  getoffsetTopIndex: V,
225
225
  totalHeight: I,
226
226
  clientHeight: o.height,
@@ -235,18 +235,18 @@ function ft(e, t) {
235
235
  style: G
236
236
  },
237
237
  wrapperProps: Y,
238
- innerProps: j
238
+ innerProps: K
239
239
  };
240
240
  }
241
- const Oe = Symbol(), Ee = Symbol(), xe = Symbol(), He = Symbol(), Ie = Symbol(), Te = Symbol(), Re = Symbol(), Ce = Symbol(), Be = Symbol();
242
- function Ht() {
241
+ const Se = Symbol(), Oe = Symbol(), xe = Symbol(), Ee = Symbol(), He = Symbol(), Ie = Symbol(), Te = Symbol(), Re = Symbol(), Ce = Symbol();
242
+ function Et() {
243
243
  const { voidFn: e, boolFn: t, boolRef: l, arrayRef: n } = {
244
244
  voidFn: (u) => {
245
245
  },
246
246
  boolFn: (u) => !1,
247
247
  boolRef: h(() => !1),
248
248
  arrayRef: h(() => [])
249
- }, r = H(He, n), a = H(xe, t), o = H(Ce, l), d = H(Ee, e), g = H(Oe, e), f = H(Ie, e), v = H(Te, e), p = H(Re, e), i = H(Be, e);
249
+ }, r = H(Ee, n), a = H(xe, t), o = H(Re, l), d = H(Oe, e), g = H(Se, e), f = H(He, e), v = H(Ie, e), p = H(Te, e), i = H(Ce, e);
250
250
  return {
251
251
  selected: r,
252
252
  isSelected: a,
@@ -259,7 +259,7 @@ function Ht() {
259
259
  unselectAll: i
260
260
  };
261
261
  }
262
- function It(e, t) {
262
+ function Ht(e, t) {
263
263
  const l = m({}), n = h(() => e.value.filter((i) => l.value[i[t]])), r = h(() => n.value.length != 0 && Object.keys(l.value).length == e.value.length);
264
264
  function a() {
265
265
  e.value.forEach((i) => {
@@ -290,7 +290,7 @@ function It(e, t) {
290
290
  function p() {
291
291
  r.value ? o() : a();
292
292
  }
293
- return E(Oe, p), E(Ee, v), E(xe, f), E(He, n), E(Ie, d), E(Te, a), E(Re, g), E(Ce, r), E(Be, o), {
293
+ return x(Se, p), x(Oe, v), x(xe, f), x(Ee, n), x(He, d), x(Ie, a), x(Te, g), x(Re, r), x(Ce, o), {
294
294
  selected: n,
295
295
  select: d,
296
296
  selectAll: a,
@@ -314,19 +314,19 @@ const pt = Symbol(), ht = /* @__PURE__ */ N({
314
314
  const l = e, n = () => {
315
315
  l.closeOnClickOverlay && t("update:visiable", !1);
316
316
  };
317
- return E(pt, () => t("update:visiable", !1)), (r, a) => (T(), _e(ye, { name: "modal" }, {
318
- default: be(() => [
317
+ return x(pt, () => t("update:visiable", !1)), (r, a) => (T(), me(be, { name: "modal" }, {
318
+ default: ye(() => [
319
319
  e.visiable ? (T(), P("div", {
320
320
  key: 0,
321
321
  onClick: n,
322
- class: "modal"
322
+ class: "modal absolute left-0 right-0 top-0 bottom-0 flex bg-stone-900 bg-opacity-50 z-[999]"
323
323
  }, [
324
324
  R("div", {
325
325
  onClick: a[0] || (a[0] = De(() => {
326
326
  }, ["stop"])),
327
- class: Me(["dialog", e.dialogClass])
327
+ class: Me(["dialog m-auto flex flex-col", e.dialogClass])
328
328
  }, [
329
- ne(r.$slots, "default", {}, void 0, !0)
329
+ ne(r.$slots, "default")
330
330
  ], 2)
331
331
  ])) : Ve("", !0)
332
332
  ]),
@@ -334,18 +334,12 @@ const pt = Symbol(), ht = /* @__PURE__ */ N({
334
334
  }));
335
335
  }
336
336
  });
337
- const re = (e, t) => {
338
- const l = e.__vccOpts || e;
339
- for (const [n, r] of t)
340
- l[n] = r;
341
- return l;
342
- }, gt = /* @__PURE__ */ re(ht, [["__scopeId", "data-v-c9f7a6a8"]]);
343
- function Tt(e) {
337
+ function It(e) {
344
338
  function t(l, n) {
345
339
  const r = document.createElement("div"), a = {
346
340
  setup() {
347
341
  return () => X(
348
- gt,
342
+ ht,
349
343
  {
350
344
  visiable: !0,
351
345
  "onUpdate:visiable": () => {
@@ -367,7 +361,7 @@ function Tt(e) {
367
361
  create: t
368
362
  };
369
363
  }
370
- const mt = ["xlink:href", "fill", "color"], Rt = /* @__PURE__ */ N({
364
+ const gt = ["xlink:href", "fill", "color"], Tt = /* @__PURE__ */ N({
371
365
  __name: "SvgIcon",
372
366
  props: {
373
367
  name: null,
@@ -390,27 +384,27 @@ const mt = ["xlink:href", "fill", "color"], Rt = /* @__PURE__ */ N({
390
384
  "xlink:href": S(l),
391
385
  fill: e.color,
392
386
  color: e.color
393
- }, null, 8, mt)
387
+ }, null, 8, gt)
394
388
  ], 4));
395
389
  }
396
390
  });
397
- function _t(e) {
391
+ function mt(e) {
398
392
  const {
399
393
  containerEl: t,
400
394
  sliderEl: l,
401
395
  autoHeight: n,
402
396
  performance: r = {},
403
397
  maxHeightRatio: a = 0.9
404
- } = e, o = m(!0), d = we(k, 100);
398
+ } = e, o = m(!0), d = _e(k, 100);
405
399
  let g, f = "";
406
400
  const v = m(0), p = m(0), i = m(0), u = m({
407
401
  top: 0,
408
402
  scrollTop: 0,
409
403
  scrollHeight: 0,
410
404
  clientHeight: 0
411
- }), x = m({
405
+ }), E = m({
412
406
  clientHeight: 0
413
- }), _ = h(() => !!p.value), Q = h(() => u.value.scrollHeight > u.value.clientHeight), I = h(() => u.value.clientHeight - x.value.clientHeight), F = h(() => u.value.scrollHeight - u.value.clientHeight), L = h(() => Math.max(
407
+ }), b = h(() => !!p.value), Q = h(() => u.value.scrollHeight > u.value.clientHeight), I = h(() => u.value.clientHeight - E.value.clientHeight), F = h(() => u.value.scrollHeight - u.value.clientHeight), L = h(() => Math.max(
414
408
  u.value.clientHeight / u.value.scrollHeight,
415
409
  0.05
416
410
  )), W = h(() => L.value > a ? 0 : L.value * u.value.clientHeight), D = h(() => ({
@@ -428,18 +422,18 @@ function _t(e) {
428
422
  o.value = !1;
429
423
  }
430
424
  function k() {
431
- _.value || (o.value = !0);
425
+ b.value || (o.value = !0);
432
426
  }
433
- function K(y) {
434
- if (!_.value)
427
+ function z(y) {
428
+ if (!b.value)
435
429
  return;
436
- let b = y.clientY - u.value.top - p.value;
437
- b < 0 ? i.value = 0 : b >= I.value ? i.value = I.value : i.value = b, t.value.scrollTo({
430
+ let _ = y.clientY - u.value.top - p.value;
431
+ _ < 0 ? i.value = 0 : _ >= I.value ? i.value = I.value : i.value = _, t.value.scrollTo({
438
432
  top: i.value / I.value * F.value
439
433
  });
440
434
  }
441
435
  function U() {
442
- _.value || q();
436
+ b.value || q();
443
437
  }
444
438
  function q() {
445
439
  cancelAnimationFrame(g), g = requestAnimationFrame(Y);
@@ -447,33 +441,33 @@ function _t(e) {
447
441
  function Y() {
448
442
  t.value && (v.value = r.scrollTop?.value ?? t.value.scrollTop, i.value = v.value / F.value * I.value);
449
443
  }
450
- function j(y) {
451
- let b = "addEventListener";
452
- y === "add" ? b = "addEventListener" : b = "removeEventListener", l.value?.[b]("pointerdown", M, {
444
+ function K(y) {
445
+ let _ = "addEventListener";
446
+ y === "add" ? _ = "addEventListener" : _ = "removeEventListener", l.value?.[_]("pointerdown", M, {
453
447
  passive: !0
454
- }), window[b]("pointermove", K, { passive: !0 }), window[b]("pointerup", V, { passive: !0 });
448
+ }), window[_]("pointermove", z, { passive: !0 }), window[_]("pointerup", V, { passive: !0 });
455
449
  }
456
450
  const G = new MutationObserver((y) => {
457
- y.map((z) => z.oldValue).join().includes("height") && s();
451
+ y.map((j) => j.oldValue).join().includes("height") && s();
458
452
  });
459
453
  function s() {
460
454
  u.value.top = t.value?.getBoundingClientRect().top ?? 0, u.value.scrollHeight = t.value?.scrollHeight ?? 0, u.value.clientHeight = t.value?.clientHeight ?? 0;
461
455
  }
462
456
  function c() {
463
457
  B(), setTimeout(() => {
464
- x.value.clientHeight = l.value?.clientHeight ?? 0, k();
458
+ E.value.clientHeight = l.value?.clientHeight ?? 0, k();
465
459
  }, 150);
466
460
  }
467
- function O(y, b, z = "dynamic-styles") {
468
- let C = document.getElementById(z);
469
- C || (C = document.createElement("style"), C.id = z, document.head.appendChild(C));
470
- const se = C.sheet.cssRules, ae = se.length, Pe = `${y} { ${b} }`;
471
- for (let J = 0; J < ae; J++) {
472
- const ie = se[J];
473
- if (ie.selectorText === y && ie.style.cssText === b)
461
+ function O(y, _, j = "dynamic-styles") {
462
+ let C = document.getElementById(j);
463
+ C || (C = document.createElement("style"), C.id = j, document.head.appendChild(C));
464
+ const re = C.sheet.cssRules, se = re.length, Pe = `${y} { ${_} }`;
465
+ for (let J = 0; J < se; J++) {
466
+ const ae = re[J];
467
+ if (ae.selectorText === y && ae.style.cssText === _)
474
468
  return;
475
469
  }
476
- C.sheet.insertRule(Pe, ae);
470
+ C.sheet.insertRule(Pe, se);
477
471
  }
478
472
  function w() {
479
473
  t.value && l.value ? (O(
@@ -481,7 +475,7 @@ function _t(e) {
481
475
  "scrollbar-width: none; -ms-overflow-style: none;"
482
476
  ), O(".hide-scrollbar::-webkit-scrollbar", "display: none"), t.value.addEventListener("scroll", U, {
483
477
  passive: !0
484
- }), j("add"), G.observe(t.value, {
478
+ }), K("add"), G.observe(t.value, {
485
479
  subtree: !0,
486
480
  attributeOldValue: !0,
487
481
  attributeFilter: ["style"]
@@ -493,16 +487,16 @@ function _t(e) {
493
487
  B(), d();
494
488
  }), {
495
489
  isScrollEnd: o,
496
- isDragSlider: _,
490
+ isDragSlider: b,
497
491
  offsetTop: i,
498
492
  scrollTop: v,
499
493
  scrollable: Q,
500
494
  sliderPos: D,
501
495
  init: w,
502
- modifySliderEventListener: j
496
+ modifySliderEventListener: K
503
497
  };
504
498
  }
505
- const yt = (e) => (Ne("data-v-edec7292"), e = e(), Qe(), e), bt = /* @__PURE__ */ yt(() => /* @__PURE__ */ R("div", { class: "default-slider" }, null, -1)), wt = /* @__PURE__ */ N({
499
+ const bt = (e) => (Ne("data-v-edec7292"), e = e(), Qe(), e), yt = /* @__PURE__ */ bt(() => /* @__PURE__ */ R("div", { class: "default-slider" }, null, -1)), _t = /* @__PURE__ */ N({
506
500
  __name: "ScrollBar",
507
501
  props: {
508
502
  containerEl: null,
@@ -511,17 +505,17 @@ const yt = (e) => (Ne("data-v-edec7292"), e = e(), Qe(), e), bt = /* @__PURE__ *
511
505
  performance: null
512
506
  },
513
507
  setup(e, { expose: t }) {
514
- const l = e, n = !!Ke().default, r = m(null), a = h(() => l.containerEl), o = _t({
508
+ const l = e, n = !!ze().default, r = m(null), a = h(() => l.containerEl), o = mt({
515
509
  containerEl: a,
516
510
  sliderEl: r,
517
511
  autoHeight: n ? l.autoHeight : !0,
518
512
  performance: l.performance
519
513
  }), { scrollable: d, isScrollEnd: g, sliderPos: f } = o, v = m(!1), p = l.autoHide ? h(() => v.value || !g.value) : h(() => d.value);
520
514
  le(() => {
521
- ge(() => {
515
+ he(() => {
522
516
  o.init();
523
517
  });
524
- }), me(() => {
518
+ }), ge(() => {
525
519
  o.modifySliderEventListener("remove");
526
520
  });
527
521
  function i() {
@@ -530,9 +524,9 @@ const yt = (e) => (Ne("data-v-edec7292"), e = e(), Qe(), e), bt = /* @__PURE__ *
530
524
  function u() {
531
525
  v.value = !1;
532
526
  }
533
- return t({ uScrollBarReturn: o }), (x, _) => (T(), _e(ye, null, {
534
- default: be(() => [
535
- je(R("div", {
527
+ return t({ uScrollBarReturn: o }), (E, b) => (T(), me(be, null, {
528
+ default: ye(() => [
529
+ Ke(R("div", {
536
530
  ref_key: "sliderRef",
537
531
  ref: r,
538
532
  class: "slider-wrapper",
@@ -540,21 +534,26 @@ const yt = (e) => (Ne("data-v-edec7292"), e = e(), Qe(), e), bt = /* @__PURE__ *
540
534
  onMouseleave: u,
541
535
  style: oe(S(f))
542
536
  }, [
543
- ne(x.$slots, "default", {}, () => [
544
- bt
537
+ ne(E.$slots, "default", {}, () => [
538
+ yt
545
539
  ], !0)
546
540
  ], 36), [
547
- [ze, S(p)]
541
+ [je, S(p)]
548
542
  ])
549
543
  ]),
550
544
  _: 3
551
545
  }));
552
546
  }
553
547
  });
554
- const Ct = /* @__PURE__ */ re(wt, [["__scopeId", "data-v-edec7292"]]), St = { class: "virtualListWrapper" }, Ot = {
548
+ const Be = (e, t) => {
549
+ const l = e.__vccOpts || e;
550
+ for (const [n, r] of t)
551
+ l[n] = r;
552
+ return l;
553
+ }, Rt = /* @__PURE__ */ Be(_t, [["__scopeId", "data-v-edec7292"]]), wt = { class: "virtualListWrapper" }, St = {
555
554
  inheritAttrs: !1
556
- }, Et = /* @__PURE__ */ N({
557
- ...Ot,
555
+ }, Ot = /* @__PURE__ */ N({
556
+ ...St,
558
557
  __name: "VirtualList",
559
558
  props: {
560
559
  data: null,
@@ -572,14 +571,14 @@ const Ct = /* @__PURE__ */ re(wt, [["__scopeId", "data-v-edec7292"]]), St = { cl
572
571
  }), { list: a, containerProps: o, wrapperProps: d, innerProps: g, getItemHeightData: f } = r;
573
572
  return t({
574
573
  vListReturn: r
575
- }), (v, p) => (T(), P("div", St, [
574
+ }), (v, p) => (T(), P("div", wt, [
576
575
  R("div", Ue({
577
576
  onScrollPassive: p[0] || (p[0] = (...i) => S(o).onScroll && S(o).onScroll(...i)),
578
577
  ref: S(o).ref,
579
578
  class: "virtualList"
580
579
  }, v.$attrs), [
581
- R("div", ue(ce(S(d))), [
582
- R("div", ue(ce(S(g))), [
580
+ R("div", ie(ue(S(d))), [
581
+ R("div", ie(ue(S(g))), [
583
582
  (T(!0), P(qe, null, Ye(S(a), ({ index: i, data: u }) => (T(), P("div", {
584
583
  key: i,
585
584
  style: oe({
@@ -598,23 +597,23 @@ const Ct = /* @__PURE__ */ re(wt, [["__scopeId", "data-v-edec7292"]]), St = { cl
598
597
  ]));
599
598
  }
600
599
  });
601
- const Bt = /* @__PURE__ */ re(Et, [["__scopeId", "data-v-4ba97cce"]]);
600
+ const Ct = /* @__PURE__ */ Be(Ot, [["__scopeId", "data-v-4ba97cce"]]);
602
601
  export {
603
- Ct as ScrollBar,
604
- Rt as SvgIcon,
605
- Bt as VirtualList,
606
- He as allSelectedKey,
602
+ Rt as ScrollBar,
603
+ Tt as SvgIcon,
604
+ Ct as VirtualList,
605
+ Ee as allSelectedKey,
607
606
  pt as closeDialogKey,
608
- Tt as dialogController,
609
- Ce as isAllSelectedKey,
607
+ It as dialogController,
608
+ Re as isAllSelectedKey,
610
609
  xe as isSelectedKey,
611
- Te as selectAllKey,
612
- Ie as selectKey,
613
- Oe as toggleAllKey,
614
- Ee as toggleKey,
615
- Be as unselectAllKey,
616
- Re as unselectKey,
617
- It as useSelectable,
618
- Ht as useSelectableInjectors,
610
+ Ie as selectAllKey,
611
+ He as selectKey,
612
+ Se as toggleAllKey,
613
+ Oe as toggleKey,
614
+ Ce as unselectAllKey,
615
+ Te as unselectKey,
616
+ Ht as useSelectable,
617
+ Et as useSelectableInjectors,
619
618
  ft as useVirtualList
620
619
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(h,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(h=typeof globalThis<"u"?globalThis:h||self,e(h.ui={},h.Vue))})(this,function(h,e){"use strict";var ne;const B=typeof window<"u";B&&((ne=window?.navigator)==null?void 0:ne.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function j(t){return typeof t=="function"?t():e.unref(t)}function me(t,l){function n(...o){t(()=>l.apply(this,o),{fn:l,thisArg:this,args:o})}return n}function ge(t,l={}){let n,o;return s=>{const r=j(t),f=j(l.maxWait);if(n&&clearTimeout(n),r<=0||f!==void 0&&f<=0)return o&&(clearTimeout(o),o=null),s();f&&!o&&(o=setTimeout(()=>{n&&clearTimeout(n),o=null,s()},f)),n=setTimeout(()=>{o&&clearTimeout(o),o=null,s()},r)}}function ve(t){return t}function ye(t){return e.getCurrentScope()?(e.onScopeDispose(t),!0):!1}function oe(t,l=200,n={}){return me(ge(l,n),t)}function _e(t,l=!0){e.getCurrentInstance()?e.onMounted(t):l?t():e.nextTick(t)}function re(t){var l;const n=j(t);return(l=n?.$el)!=null?l:n}const be=B?window:void 0;B&&window.document,B&&window.navigator,B&&window.location;function we(t,l=!1){const n=e.ref(),o=()=>n.value=Boolean(t());return o(),_e(o,l),n}const K=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},V="__vueuse_ssr_handlers__";K[V]=K[V]||{},K[V];var ie=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,Oe=(t,l)=>{var n={};for(var o in t)Se.call(t,o)&&l.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&ie)for(var o of ie(t))l.indexOf(o)<0&&Ee.call(t,o)&&(n[o]=t[o]);return n};function Te(t,l,n={}){const o=n,{window:i=be}=o,s=Oe(o,["window"]);let r;const f=we(()=>i&&"ResizeObserver"in i),v=()=>{r&&(r.disconnect(),r=void 0)},m=e.watch(()=>re(t),g=>{v(),f.value&&i&&g&&(r=new ResizeObserver(l),r.observe(g,s))},{immediate:!0,flush:"post"}),p=()=>{v(),m()};return ye(p),{isSupported:f,stop:p}}function Be(t,l={width:0,height:0},n={}){const{box:o="content-box"}=n,i=e.ref(l.width),s=e.ref(l.height);return Te(t,([r])=>{const f=o==="border-box"?r.borderBoxSize:o==="content-box"?r.contentBoxSize:r.devicePixelContentBoxSize;f?(i.value=f.reduce((v,{inlineSize:m})=>v+m,0),s.value=f.reduce((v,{blockSize:m})=>v+m,0)):(i.value=r.contentRect.width,s.value=r.contentRect.height)},n),e.watch(()=>re(t),r=>{i.value=r?l.width:0,s.value=r?l.height:0}),{width:i,height:s}}var ae;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})(ae||(ae={}));var He=Object.defineProperty,se=Object.getOwnPropertySymbols,Ie=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,ce=(t,l,n)=>l in t?He(t,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[l]=n,Re=(t,l)=>{for(var n in l||(l={}))Ie.call(l,n)&&ce(t,n,l[n]);if(se)for(var n of se(l))Ce.call(l,n)&&ce(t,n,l[n]);return t};Re({linear:ve},{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 ue(t,l){const{scrollEndHook:n,itemHeight:o,overscan:i=5}=l,s=e.ref(null),r=Be(s),f=e.ref(!0),v=oe(J,100);let m;const p=e.shallowRef(t),g=e.ref(0),c=e.ref({start:0,end:10});let u=0;const E=e.ref([]),y=e.computed(()=>{let{sum:a,height:d}={sum:0,height:0};return p.value.map((S,w)=>(typeof o=="number"?d=o:d=o(w),a+=d,{height:d,sum:a}))}),G=e.computed(()=>A(c.value.start)),O=e.computed(()=>typeof o=="number"?y.value.length*o:y.value[y.value.length-1]?.sum||0),I=e.computed(()=>{let a=E.value.length-i,d=Math.max(a-u,0);return E.value.slice(d,a)});e.onMounted(()=>{}),e.onUnmounted(()=>cancelAnimationFrame(m)),e.watch([r.width,r.height,p],([a,d])=>{(a||d)&&R()},{deep:!0}),e.watch(g,()=>{C(),v()});function C(){f.value=!1}function J(){f.value=!0,n?.()}function R(){cancelAnimationFrame(m),m=requestAnimationFrame(P)}function P(){if(s.value){g.value=s.value.scrollTop,u=H();let a=x(g.value),d=a+u+i;a=a-i,a=a<0?0:a,d=d>p.value.length?p.value.length:d,c.value={start:a,end:d},E.value=p.value.slice(a,d).map((S,w)=>({data:S,index:w+a}))}}function x(a){let d=0,S=y.value.length-1,w=-1;for(;d<=S;){const _=Math.floor((d+S)/2);y.value[_].sum>=a?(w=_,S=_-1):d=_+1}return Math.max(0,w)}function H(){let a=0,d=0,S=X();for(let w=S;w<y.value.length&&(a++,d+=y.value[w].height,!(d>=r.height.value));w++);return a}function A(a){if(typeof o=="number")return a*o;let d=y.value[a];return d?d.sum-d.height:0}function $(a){return y.value[a]||{sum:0,height:0}}function X(){let a=c.value.start;return a>=i&&(a+=i),a}function Z(a){if(s.value){const d=$(a);s.value.scrollTop=d.sum-d.height,P()}}const ee=e.computed(()=>({style:{width:"100%",height:`${O.value}px`,pointerEvents:f.value?void 0:"none"}})),k=e.computed(()=>({style:{transform:`translate3d(0, ${G.value}px, 0)`,"will-change":"transform"}})),te={overflowY:"auto"};return{list:E,visiableList:I,getItemHeightData:$,getoffsetTopIndex:x,totalHeight:O,clientHeight:r.height,scrollTo:Z,scrollTop:g,isScrollEnd:f,containerProps:{ref:s,onScroll:()=>{R()},style:te},wrapperProps:ee,innerProps:k}}const D=Symbol(),F=Symbol(),M=Symbol(),N=Symbol(),z=Symbol(),Q=Symbol(),U=Symbol(),W=Symbol(),q=Symbol();function Pe(){const{voidFn:t,boolFn:l,boolRef:n,arrayRef:o}={voidFn:u=>{},boolFn:u=>!1,boolRef:e.computed(()=>!1),arrayRef:e.computed(()=>[])},i=e.inject(N,o),s=e.inject(M,l),r=e.inject(W,n),f=e.inject(F,t),v=e.inject(D,t),m=e.inject(z,t),p=e.inject(Q,t),g=e.inject(U,t),c=e.inject(q,t);return{selected:i,isSelected:s,isAllSelected:r,toggle:f,toggleAll:v,select:m,selectAll:p,unselect:g,unselectAll:c}}function xe(t,l){const n=e.ref({}),o=e.computed(()=>t.value.filter(c=>n.value[c[l]])),i=e.computed(()=>o.value.length!=0&&Object.keys(n.value).length==t.value.length);function s(){t.value.forEach(c=>{n.value[c[l]]=!0})}function r(){n.value={}}function f(c){c.forEach(u=>{n.value[u[l]]||(n.value[u[l]]=!0)})}function v(c){c.forEach(u=>{n.value[u[l]]&&delete n.value[u[l]]})}function m(c){return!!n.value[c[l]]}function p(c){c.forEach(u=>{m(u)?delete n.value[u[l]]:n.value[u[l]]=!0})}function g(){i.value?r():s()}return e.provide(D,g),e.provide(F,p),e.provide(M,m),e.provide(N,o),e.provide(z,f),e.provide(Q,s),e.provide(U,v),e.provide(W,i),e.provide(q,r),{selected:o,select:f,selectAll:s,unselect:v,unselectAll:r,toggle:p,toggleAll:g,isSelected:m,isAllSelected:i}}const de=Symbol(),Ae=e.defineComponent({__name:"Dialog",props:{visiable:{type:Boolean,default:!1},closeOnClickOverlay:{type:Boolean,default:!0},dialogClass:{default:""}},emits:["update:visiable"],setup(t,{emit:l}){const n=t,o=()=>{n.closeOnClickOverlay&&l("update:visiable",!1)};return e.provide(de,()=>l("update:visiable",!1)),(i,s)=>(e.openBlock(),e.createBlock(e.Transition,{name:"modal"},{default:e.withCtx(()=>[t.visiable?(e.openBlock(),e.createElementBlock("div",{key:0,onClick:o,class:"modal"},[e.createElementVNode("div",{onClick:s[0]||(s[0]=e.withModifiers(()=>{},["stop"])),class:e.normalizeClass(["dialog",t.dialogClass])},[e.renderSlot(i.$slots,"default",{},void 0,!0)],2)])):e.createCommentVNode("",!0)]),_:3}))}}),qe="",Y=(t,l)=>{const n=t.__vccOpts||t;for(const[o,i]of l)n[o]=i;return n},$e=Y(Ae,[["__scopeId","data-v-c9f7a6a8"]]);function ke(t){function l(n,o){const i=document.createElement("div"),s={setup(){return()=>e.h($e,{visiable:!0,"onUpdate:visiable":()=>{i?.remove()},...t},{default:()=>e.h(n,o)})}};return document.body.appendChild(i),e.render(e.h(s),i),{close:()=>i?.remove()}}return{create:l}}const Le=["xlink:href","fill","color"],je=e.defineComponent({__name:"SvgIcon",props:{name:null,prefix:{default:"icon"},color:{default:"#FFF"},width:null,height:null},setup(t){const l=t,n=e.computed(()=>`#${l.prefix}-${l.name}`),o=e.computed(()=>({width:`${l.width??l.height}px`,height:`${l.height??l.width}px`,aspectRatio:l.width&&l.height?void 0:"1/1"}));return(i,s)=>(e.openBlock(),e.createElementBlock("svg",{"aria-hidden":"",style:e.normalizeStyle(e.unref(o))},[e.createElementVNode("use",{"xlink:href":e.unref(n),fill:t.color,color:t.color},null,8,Le)],4))}});function Ke(t){const{containerEl:l,sliderEl:n,autoHeight:o,performance:i={},maxHeightRatio:s=.9}=t,r=e.ref(!0),f=oe(A,100);let v,m="";const p=e.ref(0),g=e.ref(0),c=e.ref(0),u=e.ref({top:0,scrollTop:0,scrollHeight:0,clientHeight:0}),E=e.ref({clientHeight:0}),y=e.computed(()=>!!g.value),G=e.computed(()=>u.value.scrollHeight>u.value.clientHeight),O=e.computed(()=>u.value.clientHeight-E.value.clientHeight),I=e.computed(()=>u.value.scrollHeight-u.value.clientHeight),C=e.computed(()=>Math.max(u.value.clientHeight/u.value.scrollHeight,.05)),J=e.computed(()=>C.value>s?0:C.value*u.value.clientHeight),R=e.computed(()=>({willChange:"transform",transform:`translate3d(0,${c.value}px,0)`,height:o?`${J.value}px`:void 0}));function P(_){H(),g.value=_.clientY-n.value.getBoundingClientRect().top||1,m=getComputedStyle(l.value).scrollBehavior,m==="smooth"&&(l.value.style.scrollBehavior="unset")}function x(){l.value.style.scrollBehavior=m,g.value=0,f()}function H(){r.value=!1}function A(){y.value||(r.value=!0)}function $(_){if(!y.value)return;let b=_.clientY-u.value.top-g.value;b<0?c.value=0:b>=O.value?c.value=O.value:c.value=b,l.value.scrollTo({top:c.value/O.value*I.value})}function X(){y.value||Z()}function Z(){cancelAnimationFrame(v),v=requestAnimationFrame(ee)}function ee(){l.value&&(p.value=i.scrollTop?.value??l.value.scrollTop,c.value=p.value/I.value*O.value)}function k(_){let b="addEventListener";_==="add"?b="addEventListener":b="removeEventListener",n.value?.[b]("pointerdown",P,{passive:!0}),window[b]("pointermove",$,{passive:!0}),window[b]("pointerup",x,{passive:!0})}const te=new MutationObserver(_=>{_.map(L=>L.oldValue).join().includes("height")&&a()});function a(){u.value.top=l.value?.getBoundingClientRect().top??0,u.value.scrollHeight=l.value?.scrollHeight??0,u.value.clientHeight=l.value?.clientHeight??0}function d(){H(),setTimeout(()=>{E.value.clientHeight=n.value?.clientHeight??0,A()},150)}function S(_,b,L="dynamic-styles"){let T=document.getElementById(L);T||(T=document.createElement("style"),T.id=L,document.head.appendChild(T));const fe=T.sheet.cssRules,pe=fe.length,Ue=`${_} { ${b} }`;for(let le=0;le<pe;le++){const he=fe[le];if(he.selectorText===_&&he.style.cssText===b)return}T.sheet.insertRule(Ue,pe)}function w(){l.value&&n.value?(S(".hide-scrollbar","scrollbar-width: none; -ms-overflow-style: none;"),S(".hide-scrollbar::-webkit-scrollbar","display: none"),l.value.addEventListener("scroll",X,{passive:!0}),k("add"),te.observe(l.value,{subtree:!0,attributeOldValue:!0,attributeFilter:["style"]}),setTimeout(()=>{a()},100),d()):console.error("useScrollBar:","\u521D\u59CB\u5316\u5931\u8D25!",{containerEl:l,sliderEl:n})}return e.watch(p,()=>{H(),f()}),{isScrollEnd:r,isDragSlider:y,offsetTop:c,scrollTop:p,scrollable:G,sliderPos:R,init:w,modifySliderEventListener:k}}const Ve=(t=>(e.pushScopeId("data-v-edec7292"),t=t(),e.popScopeId(),t))(()=>e.createElementVNode("div",{class:"default-slider"},null,-1)),De=e.defineComponent({__name:"ScrollBar",props:{containerEl:null,autoHide:{type:Boolean},autoHeight:{type:Boolean},performance:null},setup(t,{expose:l}){const n=t,o=!!e.useSlots().default,i=e.ref(null),s=e.computed(()=>n.containerEl),r=Ke({containerEl:s,sliderEl:i,autoHeight:o?n.autoHeight:!0,performance:n.performance}),{scrollable:f,isScrollEnd:v,sliderPos:m}=r,p=e.ref(!1),g=n.autoHide?e.computed(()=>p.value||!v.value):e.computed(()=>f.value);e.onMounted(()=>{e.nextTick(()=>{r.init()})}),e.onUnmounted(()=>{r.modifySliderEventListener("remove")});function c(){p.value=!0}function u(){p.value=!1}return l({uScrollBarReturn:r}),(E,y)=>(e.openBlock(),e.createBlock(e.Transition,null,{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{ref_key:"sliderRef",ref:i,class:"slider-wrapper",onMouseenter:c,onMouseleave:u,style:e.normalizeStyle(e.unref(m))},[e.renderSlot(E.$slots,"default",{},()=>[Ve],!0)],36),[[e.vShow,e.unref(g)]])]),_:3}))}}),Ge="",Fe=Y(De,[["__scopeId","data-v-edec7292"]]),Me={class:"virtualListWrapper"},Ne={inheritAttrs:!1},ze=e.defineComponent({...Ne,__name:"VirtualList",props:{data:null,itemHeight:null,overscan:{default:10}},emits:["scrollEnd"],setup(t,{expose:l,emit:n}){const o=t,i=ue(e.toRef(o,"data"),{itemHeight:p=>o.itemHeight(o.data[p]),overscan:o.overscan,scrollEndHook:()=>{n("scrollEnd")}}),{list:s,containerProps:r,wrapperProps:f,innerProps:v,getItemHeightData:m}=i;return l({vListReturn:i}),(p,g)=>(e.openBlock(),e.createElementBlock("div",Me,[e.createElementVNode("div",e.mergeProps({onScrollPassive:g[0]||(g[0]=(...c)=>e.unref(r).onScroll&&e.unref(r).onScroll(...c)),ref:e.unref(r).ref,class:"virtualList"},p.$attrs),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(f))),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(v))),[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),({index:c,data:u})=>(e.openBlock(),e.createElementBlock("div",{key:c,style:e.normalizeStyle({height:`${e.unref(m)(c).height}px`,display:"flex"})},[e.renderSlot(p.$slots,"default",{data:u,index:c},void 0,!0)],4))),128))],16)],16)],16)]))}}),Je="",Qe=Y(ze,[["__scopeId","data-v-4ba97cce"]]);h.ScrollBar=Fe,h.SvgIcon=je,h.VirtualList=Qe,h.allSelectedKey=N,h.closeDialogKey=de,h.dialogController=ke,h.isAllSelectedKey=W,h.isSelectedKey=M,h.selectAllKey=Q,h.selectKey=z,h.toggleAllKey=D,h.toggleKey=F,h.unselectAllKey=q,h.unselectKey=U,h.useSelectable=xe,h.useSelectableInjectors=Pe,h.useVirtualList=ue,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(h,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(h=typeof globalThis<"u"?globalThis:h||self,e(h.ui={},h.Vue))})(this,function(h,e){"use strict";var le;const B=typeof window<"u";B&&((le=window?.navigator)==null?void 0:le.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function j(t){return typeof t=="function"?t():e.unref(t)}function me(t,l){function n(...o){t(()=>l.apply(this,o),{fn:l,thisArg:this,args:o})}return n}function ge(t,l={}){let n,o;return s=>{const r=j(t),f=j(l.maxWait);if(n&&clearTimeout(n),r<=0||f!==void 0&&f<=0)return o&&(clearTimeout(o),o=null),s();f&&!o&&(o=setTimeout(()=>{n&&clearTimeout(n),o=null,s()},f)),n=setTimeout(()=>{o&&clearTimeout(o),o=null,s()},r)}}function ve(t){return t}function ye(t){return e.getCurrentScope()?(e.onScopeDispose(t),!0):!1}function ne(t,l=200,n={}){return me(ge(l,n),t)}function be(t,l=!0){e.getCurrentInstance()?e.onMounted(t):l?t():e.nextTick(t)}function oe(t){var l;const n=j(t);return(l=n?.$el)!=null?l:n}const _e=B?window:void 0;B&&window.document,B&&window.navigator,B&&window.location;function we(t,l=!1){const n=e.ref(),o=()=>n.value=Boolean(t());return o(),be(o,l),n}const K=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},V="__vueuse_ssr_handlers__";K[V]=K[V]||{},K[V];var re=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,Oe=(t,l)=>{var n={};for(var o in t)Se.call(t,o)&&l.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&re)for(var o of re(t))l.indexOf(o)<0&&Ee.call(t,o)&&(n[o]=t[o]);return n};function Te(t,l,n={}){const o=n,{window:i=_e}=o,s=Oe(o,["window"]);let r;const f=we(()=>i&&"ResizeObserver"in i),v=()=>{r&&(r.disconnect(),r=void 0)},m=e.watch(()=>oe(t),g=>{v(),f.value&&i&&g&&(r=new ResizeObserver(l),r.observe(g,s))},{immediate:!0,flush:"post"}),p=()=>{v(),m()};return ye(p),{isSupported:f,stop:p}}function Be(t,l={width:0,height:0},n={}){const{box:o="content-box"}=n,i=e.ref(l.width),s=e.ref(l.height);return Te(t,([r])=>{const f=o==="border-box"?r.borderBoxSize:o==="content-box"?r.contentBoxSize:r.devicePixelContentBoxSize;f?(i.value=f.reduce((v,{inlineSize:m})=>v+m,0),s.value=f.reduce((v,{blockSize:m})=>v+m,0)):(i.value=r.contentRect.width,s.value=r.contentRect.height)},n),e.watch(()=>oe(t),r=>{i.value=r?l.width:0,s.value=r?l.height:0}),{width:i,height:s}}var ie;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})(ie||(ie={}));var He=Object.defineProperty,ae=Object.getOwnPropertySymbols,Ie=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,se=(t,l,n)=>l in t?He(t,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[l]=n,Re=(t,l)=>{for(var n in l||(l={}))Ie.call(l,n)&&se(t,n,l[n]);if(ae)for(var n of ae(l))Ce.call(l,n)&&se(t,n,l[n]);return t};Re({linear:ve},{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 ce(t,l){const{scrollEndHook:n,itemHeight:o,overscan:i=5}=l,s=e.ref(null),r=Be(s),f=e.ref(!0),v=ne(G,100);let m;const p=e.shallowRef(t),g=e.ref(0),c=e.ref({start:0,end:10});let u=0;const E=e.ref([]),y=e.computed(()=>{let{sum:a,height:d}={sum:0,height:0};return p.value.map((S,w)=>(typeof o=="number"?d=o:d=o(w),a+=d,{height:d,sum:a}))}),Y=e.computed(()=>A(c.value.start)),O=e.computed(()=>typeof o=="number"?y.value.length*o:y.value[y.value.length-1]?.sum||0),I=e.computed(()=>{let a=E.value.length-i,d=Math.max(a-u,0);return E.value.slice(d,a)});e.onMounted(()=>{}),e.onUnmounted(()=>cancelAnimationFrame(m)),e.watch([r.width,r.height,p],([a,d])=>{(a||d)&&R()},{deep:!0}),e.watch(g,()=>{C(),v()});function C(){f.value=!1}function G(){f.value=!0,n?.()}function R(){cancelAnimationFrame(m),m=requestAnimationFrame(x)}function x(){if(s.value){g.value=s.value.scrollTop,u=H();let a=P(g.value),d=a+u+i;a=a-i,a=a<0?0:a,d=d>p.value.length?p.value.length:d,c.value={start:a,end:d},E.value=p.value.slice(a,d).map((S,w)=>({data:S,index:w+a}))}}function P(a){let d=0,S=y.value.length-1,w=-1;for(;d<=S;){const b=Math.floor((d+S)/2);y.value[b].sum>=a?(w=b,S=b-1):d=b+1}return Math.max(0,w)}function H(){let a=0,d=0,S=J();for(let w=S;w<y.value.length&&(a++,d+=y.value[w].height,!(d>=r.height.value));w++);return a}function A(a){if(typeof o=="number")return a*o;let d=y.value[a];return d?d.sum-d.height:0}function $(a){return y.value[a]||{sum:0,height:0}}function J(){let a=c.value.start;return a>=i&&(a+=i),a}function X(a){if(s.value){const d=$(a);s.value.scrollTop=d.sum-d.height,x()}}const Z=e.computed(()=>({style:{width:"100%",height:`${O.value}px`,pointerEvents:f.value?void 0:"none"}})),k=e.computed(()=>({style:{transform:`translate3d(0, ${Y.value}px, 0)`,"will-change":"transform"}})),ee={overflowY:"auto"};return{list:E,visiableList:I,getItemHeightData:$,getoffsetTopIndex:P,totalHeight:O,clientHeight:r.height,scrollTo:X,scrollTop:g,isScrollEnd:f,containerProps:{ref:s,onScroll:()=>{R()},style:ee},wrapperProps:Z,innerProps:k}}const F=Symbol(),D=Symbol(),M=Symbol(),N=Symbol(),z=Symbol(),Q=Symbol(),U=Symbol(),W=Symbol(),q=Symbol();function xe(){const{voidFn:t,boolFn:l,boolRef:n,arrayRef:o}={voidFn:u=>{},boolFn:u=>!1,boolRef:e.computed(()=>!1),arrayRef:e.computed(()=>[])},i=e.inject(N,o),s=e.inject(M,l),r=e.inject(W,n),f=e.inject(D,t),v=e.inject(F,t),m=e.inject(z,t),p=e.inject(Q,t),g=e.inject(U,t),c=e.inject(q,t);return{selected:i,isSelected:s,isAllSelected:r,toggle:f,toggleAll:v,select:m,selectAll:p,unselect:g,unselectAll:c}}function Pe(t,l){const n=e.ref({}),o=e.computed(()=>t.value.filter(c=>n.value[c[l]])),i=e.computed(()=>o.value.length!=0&&Object.keys(n.value).length==t.value.length);function s(){t.value.forEach(c=>{n.value[c[l]]=!0})}function r(){n.value={}}function f(c){c.forEach(u=>{n.value[u[l]]||(n.value[u[l]]=!0)})}function v(c){c.forEach(u=>{n.value[u[l]]&&delete n.value[u[l]]})}function m(c){return!!n.value[c[l]]}function p(c){c.forEach(u=>{m(u)?delete n.value[u[l]]:n.value[u[l]]=!0})}function g(){i.value?r():s()}return e.provide(F,g),e.provide(D,p),e.provide(M,m),e.provide(N,o),e.provide(z,f),e.provide(Q,s),e.provide(U,v),e.provide(W,i),e.provide(q,r),{selected:o,select:f,selectAll:s,unselect:v,unselectAll:r,toggle:p,toggleAll:g,isSelected:m,isAllSelected:i}}const ue=Symbol(),Ae=e.defineComponent({__name:"Dialog",props:{visiable:{type:Boolean,default:!1},closeOnClickOverlay:{type:Boolean,default:!0},dialogClass:{default:""}},emits:["update:visiable"],setup(t,{emit:l}){const n=t,o=()=>{n.closeOnClickOverlay&&l("update:visiable",!1)};return e.provide(ue,()=>l("update:visiable",!1)),(i,s)=>(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 left-0 right-0 top-0 bottom-0 flex bg-stone-900 bg-opacity-50 z-[999]"},[e.createElementVNode("div",{onClick:s[0]||(s[0]=e.withModifiers(()=>{},["stop"])),class:e.normalizeClass(["dialog m-auto flex flex-col",t.dialogClass])},[e.renderSlot(i.$slots,"default")],2)])):e.createCommentVNode("",!0)]),_:3}))}});function $e(t){function l(n,o){const i=document.createElement("div"),s={setup(){return()=>e.h(Ae,{visiable:!0,"onUpdate:visiable":()=>{i?.remove()},...t},{default:()=>e.h(n,o)})}};return document.body.appendChild(i),e.render(e.h(s),i),{close:()=>i?.remove()}}return{create:l}}const ke=["xlink:href","fill","color"],Le=e.defineComponent({__name:"SvgIcon",props:{name:null,prefix:{default:"icon"},color:{default:"#FFF"},width:null,height:null},setup(t){const l=t,n=e.computed(()=>`#${l.prefix}-${l.name}`),o=e.computed(()=>({width:`${l.width??l.height}px`,height:`${l.height??l.width}px`,aspectRatio:l.width&&l.height?void 0:"1/1"}));return(i,s)=>(e.openBlock(),e.createElementBlock("svg",{"aria-hidden":"",style:e.normalizeStyle(e.unref(o))},[e.createElementVNode("use",{"xlink:href":e.unref(n),fill:t.color,color:t.color},null,8,ke)],4))}});function je(t){const{containerEl:l,sliderEl:n,autoHeight:o,performance:i={},maxHeightRatio:s=.9}=t,r=e.ref(!0),f=ne(A,100);let v,m="";const p=e.ref(0),g=e.ref(0),c=e.ref(0),u=e.ref({top:0,scrollTop:0,scrollHeight:0,clientHeight:0}),E=e.ref({clientHeight:0}),y=e.computed(()=>!!g.value),Y=e.computed(()=>u.value.scrollHeight>u.value.clientHeight),O=e.computed(()=>u.value.clientHeight-E.value.clientHeight),I=e.computed(()=>u.value.scrollHeight-u.value.clientHeight),C=e.computed(()=>Math.max(u.value.clientHeight/u.value.scrollHeight,.05)),G=e.computed(()=>C.value>s?0:C.value*u.value.clientHeight),R=e.computed(()=>({willChange:"transform",transform:`translate3d(0,${c.value}px,0)`,height:o?`${G.value}px`:void 0}));function x(b){H(),g.value=b.clientY-n.value.getBoundingClientRect().top||1,m=getComputedStyle(l.value).scrollBehavior,m==="smooth"&&(l.value.style.scrollBehavior="unset")}function P(){l.value.style.scrollBehavior=m,g.value=0,f()}function H(){r.value=!1}function A(){y.value||(r.value=!0)}function $(b){if(!y.value)return;let _=b.clientY-u.value.top-g.value;_<0?c.value=0:_>=O.value?c.value=O.value:c.value=_,l.value.scrollTo({top:c.value/O.value*I.value})}function J(){y.value||X()}function X(){cancelAnimationFrame(v),v=requestAnimationFrame(Z)}function Z(){l.value&&(p.value=i.scrollTop?.value??l.value.scrollTop,c.value=p.value/I.value*O.value)}function k(b){let _="addEventListener";b==="add"?_="addEventListener":_="removeEventListener",n.value?.[_]("pointerdown",x,{passive:!0}),window[_]("pointermove",$,{passive:!0}),window[_]("pointerup",P,{passive:!0})}const ee=new MutationObserver(b=>{b.map(L=>L.oldValue).join().includes("height")&&a()});function a(){u.value.top=l.value?.getBoundingClientRect().top??0,u.value.scrollHeight=l.value?.scrollHeight??0,u.value.clientHeight=l.value?.clientHeight??0}function d(){H(),setTimeout(()=>{E.value.clientHeight=n.value?.clientHeight??0,A()},150)}function S(b,_,L="dynamic-styles"){let T=document.getElementById(L);T||(T=document.createElement("style"),T.id=L,document.head.appendChild(T));const fe=T.sheet.cssRules,pe=fe.length,Qe=`${b} { ${_} }`;for(let te=0;te<pe;te++){const he=fe[te];if(he.selectorText===b&&he.style.cssText===_)return}T.sheet.insertRule(Qe,pe)}function w(){l.value&&n.value?(S(".hide-scrollbar","scrollbar-width: none; -ms-overflow-style: none;"),S(".hide-scrollbar::-webkit-scrollbar","display: none"),l.value.addEventListener("scroll",J,{passive:!0}),k("add"),ee.observe(l.value,{subtree:!0,attributeOldValue:!0,attributeFilter:["style"]}),setTimeout(()=>{a()},100),d()):console.error("useScrollBar:","\u521D\u59CB\u5316\u5931\u8D25!",{containerEl:l,sliderEl:n})}return e.watch(p,()=>{H(),f()}),{isScrollEnd:r,isDragSlider:y,offsetTop:c,scrollTop:p,scrollable:Y,sliderPos:R,init:w,modifySliderEventListener:k}}const Ke=(t=>(e.pushScopeId("data-v-edec7292"),t=t(),e.popScopeId(),t))(()=>e.createElementVNode("div",{class:"default-slider"},null,-1)),Ve=e.defineComponent({__name:"ScrollBar",props:{containerEl:null,autoHide:{type:Boolean},autoHeight:{type:Boolean},performance:null},setup(t,{expose:l}){const n=t,o=!!e.useSlots().default,i=e.ref(null),s=e.computed(()=>n.containerEl),r=je({containerEl:s,sliderEl:i,autoHeight:o?n.autoHeight:!0,performance:n.performance}),{scrollable:f,isScrollEnd:v,sliderPos:m}=r,p=e.ref(!1),g=n.autoHide?e.computed(()=>p.value||!v.value):e.computed(()=>f.value);e.onMounted(()=>{e.nextTick(()=>{r.init()})}),e.onUnmounted(()=>{r.modifySliderEventListener("remove")});function c(){p.value=!0}function u(){p.value=!1}return l({uScrollBarReturn:r}),(E,y)=>(e.openBlock(),e.createBlock(e.Transition,null,{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{ref_key:"sliderRef",ref:i,class:"slider-wrapper",onMouseenter:c,onMouseleave:u,style:e.normalizeStyle(e.unref(m))},[e.renderSlot(E.$slots,"default",{},()=>[Ke],!0)],36),[[e.vShow,e.unref(g)]])]),_:3}))}}),qe="",de=(t,l)=>{const n=t.__vccOpts||t;for(const[o,i]of l)n[o]=i;return n},Fe=de(Ve,[["__scopeId","data-v-edec7292"]]),De={class:"virtualListWrapper"},Me={inheritAttrs:!1},Ne=e.defineComponent({...Me,__name:"VirtualList",props:{data:null,itemHeight:null,overscan:{default:10}},emits:["scrollEnd"],setup(t,{expose:l,emit:n}){const o=t,i=ce(e.toRef(o,"data"),{itemHeight:p=>o.itemHeight(o.data[p]),overscan:o.overscan,scrollEndHook:()=>{n("scrollEnd")}}),{list:s,containerProps:r,wrapperProps:f,innerProps:v,getItemHeightData:m}=i;return l({vListReturn:i}),(p,g)=>(e.openBlock(),e.createElementBlock("div",De,[e.createElementVNode("div",e.mergeProps({onScrollPassive:g[0]||(g[0]=(...c)=>e.unref(r).onScroll&&e.unref(r).onScroll(...c)),ref:e.unref(r).ref,class:"virtualList"},p.$attrs),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(f))),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(v))),[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),({index:c,data:u})=>(e.openBlock(),e.createElementBlock("div",{key:c,style:e.normalizeStyle({height:`${e.unref(m)(c).height}px`,display:"flex"})},[e.renderSlot(p.$slots,"default",{data:u,index:c},void 0,!0)],4))),128))],16)],16)],16)]))}}),Ye="",ze=de(Ne,[["__scopeId","data-v-4ba97cce"]]);h.ScrollBar=Fe,h.SvgIcon=Le,h.VirtualList=ze,h.allSelectedKey=N,h.closeDialogKey=ue,h.dialogController=$e,h.isAllSelectedKey=W,h.isSelectedKey=M,h.selectAllKey=Q,h.selectKey=z,h.toggleAllKey=F,h.toggleKey=D,h.unselectAllKey=q,h.unselectKey=U,h.useSelectable=Pe,h.useSelectableInjectors=xe,h.useVirtualList=ce,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .modal[data-v-c9f7a6a8]{position:absolute;display:flex;inset:0;background-color:#1c1917;z-index:999}.dialog[data-v-c9f7a6a8]{margin:auto;display:flex;flex-direction:column}.v-leave-active[data-v-edec7292]{transition:all .15s ease-out;transition-delay:.9s}.v-leave-to[data-v-edec7292]{opacity:0}.slider-wrapper[data-v-edec7292]{z-index:100;position:absolute;right:0;touch-action:none}.default-slider[data-v-edec7292]{width:6px;height:100%;background-color:#0003;border-radius:3px;margin-right:3px}.virtualList[data-v-4ba97cce]{width:100%;height:100%;position:absolute;overflow-y:auto;scroll-behavior:smooth;user-select:none}.virtualListWrapper[data-v-4ba97cce]{width:100%;height:100%;position:relative}
1
+ .v-leave-active[data-v-edec7292]{transition:all .15s ease-out;transition-delay:.9s}.v-leave-to[data-v-edec7292]{opacity:0}.slider-wrapper[data-v-edec7292]{z-index:100;position:absolute;right:0;touch-action:none}.default-slider[data-v-edec7292]{width:6px;height:100%;background-color:#0003;border-radius:3px;margin-right:3px}.virtualList[data-v-4ba97cce]{width:100%;height:100%;position:absolute;overflow-y:auto;scroll-behavior:smooth;user-select:none}.virtualListWrapper[data-v-4ba97cce]{width:100%;height:100%;position:relative}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazycatcloud/lzc-toolkit",
3
- "version": "0.0.44",
3
+ "version": "0.0.45",
4
4
  "description": "lazycat ui toolkits",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",