@lazycatcloud/lzc-toolkit 0.0.13 → 0.0.15

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,68 +1,68 @@
1
- import { unref as b, getCurrentScope as Z, onScopeDispose as ee, getCurrentInstance as te, onMounted as j, nextTick as ne, ref as y, watch as B, shallowRef as oe, onUnmounted as le, computed as _, provide as m, defineComponent as F, openBlock as S, createBlock as re, Transition as se, withCtx as ae, createElementBlock as I, createElementVNode as x, withModifiers as ie, normalizeClass as ue, renderSlot as U, createCommentVNode as ce, render as de, h as P, toRef as fe, normalizeStyle as z, normalizeProps as H, guardReactiveProps as K, Fragment as ve, renderList as pe } from "vue";
1
+ import { unref as y, getCurrentScope as ie, onScopeDispose as ce, getCurrentInstance as ue, onMounted as F, nextTick as de, ref as O, watch as B, shallowRef as fe, onUnmounted as ve, computed as S, inject as b, provide as m, defineComponent as U, openBlock as I, createBlock as pe, Transition as ge, withCtx as he, createElementBlock as P, createElementVNode as E, withModifiers as me, normalizeClass as be, renderSlot as D, createCommentVNode as ye, render as Oe, h as x, toRef as we, normalizeStyle as H, normalizeProps as K, guardReactiveProps as j, Fragment as _e, renderList as Se } from "vue";
2
2
  var N;
3
3
  const C = typeof window < "u";
4
4
  C && ((N = window?.navigator) == null ? void 0 : N.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
5
- function he(e) {
6
- return typeof e == "function" ? e() : b(e);
5
+ function Ie(e) {
6
+ return typeof e == "function" ? e() : y(e);
7
7
  }
8
- function ge(e) {
8
+ function Ce(e) {
9
9
  return e;
10
10
  }
11
- function me(e) {
12
- return Z() ? (ee(e), !0) : !1;
11
+ function Pe(e) {
12
+ return ie() ? (ce(e), !0) : !1;
13
13
  }
14
- function be(e, n = !0) {
15
- te() ? j(e) : n ? e() : ne(e);
14
+ function xe(e, n = !0) {
15
+ ue() ? F(e) : n ? e() : de(e);
16
16
  }
17
- function D(e) {
17
+ function W(e) {
18
18
  var n;
19
- const t = he(e);
19
+ const t = Ie(e);
20
20
  return (n = t?.$el) != null ? n : t;
21
21
  }
22
- const ye = C ? window : void 0;
22
+ const Ee = C ? window : void 0;
23
23
  C && window.document;
24
24
  C && window.navigator;
25
25
  C && window.location;
26
- function Oe(e, n = !1) {
27
- const t = y(), o = () => t.value = Boolean(e());
28
- return o(), be(o, n), t;
26
+ function Te(e, n = !1) {
27
+ const t = O(), o = () => t.value = Boolean(e());
28
+ return o(), xe(o, n), t;
29
29
  }
30
- const E = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, T = "__vueuse_ssr_handlers__";
31
- E[T] = E[T] || {};
32
- E[T];
33
- var Q = Object.getOwnPropertySymbols, we = Object.prototype.hasOwnProperty, _e = Object.prototype.propertyIsEnumerable, Se = (e, n) => {
30
+ const T = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, A = "__vueuse_ssr_handlers__";
31
+ T[A] = T[A] || {};
32
+ T[A];
33
+ var Q = Object.getOwnPropertySymbols, Ae = Object.prototype.hasOwnProperty, Be = Object.prototype.propertyIsEnumerable, Re = (e, n) => {
34
34
  var t = {};
35
35
  for (var o in e)
36
- we.call(e, o) && n.indexOf(o) < 0 && (t[o] = e[o]);
36
+ Ae.call(e, o) && n.indexOf(o) < 0 && (t[o] = e[o]);
37
37
  if (e != null && Q)
38
38
  for (var o of Q(e))
39
- n.indexOf(o) < 0 && _e.call(e, o) && (t[o] = e[o]);
39
+ n.indexOf(o) < 0 && Be.call(e, o) && (t[o] = e[o]);
40
40
  return t;
41
41
  };
42
- function Ce(e, n, t = {}) {
43
- const o = t, { window: r = ye } = o, a = Se(o, ["window"]);
42
+ function $e(e, n, t = {}) {
43
+ const o = t, { window: s = Ee } = o, a = Re(o, ["window"]);
44
44
  let l;
45
- const i = Oe(() => r && "ResizeObserver" in r), s = () => {
45
+ const i = Te(() => s && "ResizeObserver" in s), r = () => {
46
46
  l && (l.disconnect(), l = void 0);
47
- }, c = B(() => D(e), (w) => {
48
- s(), i.value && r && w && (l = new ResizeObserver(n), l.observe(w, a));
49
- }, { immediate: !0, flush: "post" }), O = () => {
50
- s(), c();
47
+ }, u = B(() => W(e), (_) => {
48
+ r(), i.value && s && _ && (l = new ResizeObserver(n), l.observe(_, a));
49
+ }, { immediate: !0, flush: "post" }), w = () => {
50
+ r(), u();
51
51
  };
52
- return me(O), {
52
+ return Pe(w), {
53
53
  isSupported: i,
54
- stop: O
54
+ stop: w
55
55
  };
56
56
  }
57
- function Ie(e, n = { width: 0, height: 0 }, t = {}) {
58
- const { box: o = "content-box" } = t, r = y(n.width), a = y(n.height);
59
- return Ce(e, ([l]) => {
57
+ function ze(e, n = { width: 0, height: 0 }, t = {}) {
58
+ const { box: o = "content-box" } = t, s = O(n.width), a = O(n.height);
59
+ return $e(e, ([l]) => {
60
60
  const i = o === "border-box" ? l.borderBoxSize : o === "content-box" ? l.contentBoxSize : l.devicePixelContentBoxSize;
61
- i ? (r.value = i.reduce((s, { inlineSize: c }) => s + c, 0), a.value = i.reduce((s, { blockSize: c }) => s + c, 0)) : (r.value = l.contentRect.width, a.value = l.contentRect.height);
62
- }, t), B(() => D(e), (l) => {
63
- r.value = l ? n.width : 0, a.value = l ? n.height : 0;
61
+ i ? (s.value = i.reduce((r, { inlineSize: u }) => r + u, 0), a.value = i.reduce((r, { blockSize: u }) => r + u, 0)) : (s.value = l.contentRect.width, a.value = l.contentRect.height);
62
+ }, t), B(() => W(e), (l) => {
63
+ s.value = l ? n.width : 0, a.value = l ? n.height : 0;
64
64
  }), {
65
- width: r,
65
+ width: s,
66
66
  height: a
67
67
  };
68
68
  }
@@ -70,15 +70,15 @@ var k;
70
70
  (function(e) {
71
71
  e.UP = "UP", e.RIGHT = "RIGHT", e.DOWN = "DOWN", e.LEFT = "LEFT", e.NONE = "NONE";
72
72
  })(k || (k = {}));
73
- var Pe = Object.defineProperty, L = Object.getOwnPropertySymbols, xe = Object.prototype.hasOwnProperty, Ee = Object.prototype.propertyIsEnumerable, V = (e, n, t) => n in e ? Pe(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t, Te = (e, n) => {
73
+ var He = Object.defineProperty, L = Object.getOwnPropertySymbols, Ke = Object.prototype.hasOwnProperty, je = Object.prototype.propertyIsEnumerable, V = (e, n, t) => n in e ? He(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t, Ne = (e, n) => {
74
74
  for (var t in n || (n = {}))
75
- xe.call(n, t) && V(e, t, n[t]);
75
+ Ke.call(n, t) && V(e, t, n[t]);
76
76
  if (L)
77
77
  for (var t of L(n))
78
- Ee.call(n, t) && V(e, t, n[t]);
78
+ je.call(n, t) && V(e, t, n[t]);
79
79
  return e;
80
80
  };
81
- const Be = {
81
+ const Qe = {
82
82
  easeInSine: [0.12, 0, 0.39, 0],
83
83
  easeOutSine: [0.61, 1, 0.88, 1],
84
84
  easeInOutSine: [0.37, 0, 0.63, 1],
@@ -104,23 +104,23 @@ const Be = {
104
104
  easeOutBack: [0.34, 1.56, 0.64, 1],
105
105
  easeInOutBack: [0.68, -0.6, 0.32, 1.6]
106
106
  };
107
- Te({
108
- linear: ge
109
- }, Be);
110
- function Re(e, n) {
111
- const t = y(), o = Ie(t), r = y([]), a = y(0), l = oe(e), i = y({ start: 0, end: 10 }), { itemHeight: s, overscan: c = 5 } = n, O = (u) => {
112
- const { start: h = 0 } = i.value;
107
+ Ne({
108
+ linear: Ce
109
+ }, Qe);
110
+ function ke(e, n) {
111
+ const t = O(), o = ze(t), s = O([]), a = O(0), l = fe(e), i = O({ start: 0, end: 10 }), { itemHeight: r, overscan: u = 5 } = n, w = (c) => {
112
+ const { start: g = 0 } = i.value;
113
113
  let v = 0, p = 0;
114
- for (let g = h; g < l.value.length; g++)
115
- if (v += s(g), v >= u) {
116
- p = g;
114
+ for (let h = g; h < l.value.length; h++)
115
+ if (v += r(h), v >= c) {
116
+ p = h;
117
117
  break;
118
118
  }
119
- return p - h;
120
- }, w = (u) => {
121
- let h = 0, v = 0;
119
+ return p - g;
120
+ }, _ = (c) => {
121
+ let g = 0, v = 0;
122
122
  for (let p = 0; p < l.value.length; p++)
123
- if (h += s(p), h >= u) {
123
+ if (g += r(p), g >= c) {
124
124
  v = p;
125
125
  break;
126
126
  }
@@ -130,20 +130,20 @@ function Re(e, n) {
130
130
  const f = () => {
131
131
  cancelAnimationFrame(d), d = requestAnimationFrame(R);
132
132
  }, R = () => {
133
- const u = t.value;
134
- if (u) {
135
- const h = w(u.scrollTop), v = O(u.clientHeight), p = h - c, g = h + v + c;
133
+ const c = t.value;
134
+ if (c) {
135
+ const g = _(c.scrollTop), v = w(c.clientHeight), p = g - u, h = g + v + u;
136
136
  i.value = {
137
137
  start: p < 0 ? 0 : p,
138
- end: g > l.value.length ? l.value.length : g
139
- }, r.value = l.value.slice(i.value.start, i.value.end).map(($, X) => ({
140
- data: $,
141
- index: X + i.value.start
138
+ end: h > l.value.length ? l.value.length : h
139
+ }, s.value = l.value.slice(i.value.start, i.value.end).map((z, ae) => ({
140
+ data: z,
141
+ index: ae + i.value.start
142
142
  }));
143
143
  }
144
144
  };
145
- j(() => {
146
- }), le(() => {
145
+ F(() => {
146
+ }), ve(() => {
147
147
  cancelAnimationFrame(d);
148
148
  }), B(
149
149
  [o.width, o.height, l],
@@ -152,39 +152,52 @@ function Re(e, n) {
152
152
  },
153
153
  { deep: !0 }
154
154
  );
155
- const A = _(() => typeof s == "number" ? l.value.length * s : l.value.reduce((u, h, v) => u + s(v), 0)), W = (u) => typeof s == "number" ? u * s : l.value.slice(0, u).reduce((v, p, g) => v + s(g), 0), M = (u) => {
156
- t.value && (t.value.scrollTop = u, R());
157
- }, q = _(() => W(i.value.start)), G = _(() => ({
155
+ const $ = S(() => typeof r == "number" ? l.value.length * r : l.value.reduce((c, g, v) => c + r(v), 0)), te = (c) => typeof r == "number" ? c * r : l.value.slice(0, c).reduce((v, p, h) => v + r(h), 0), ne = (c) => {
156
+ t.value && (t.value.scrollTop = c, R());
157
+ }, oe = S(() => te(i.value.start)), le = S(() => ({
158
158
  style: {
159
159
  width: "100%",
160
- height: `${A.value}px`
160
+ height: `${$.value}px`
161
161
  }
162
- })), Y = _(() => ({
162
+ })), se = S(() => ({
163
163
  style: {
164
- transform: `translate3d(0, ${q.value}px, 0)`,
164
+ transform: `translate3d(0, ${oe.value}px, 0)`,
165
165
  "will-change": "transform"
166
166
  }
167
- })), J = { overflowY: "auto" };
167
+ })), re = { overflowY: "auto" };
168
168
  return {
169
- list: r,
170
- totalHeight: A,
169
+ list: s,
170
+ totalHeight: $,
171
171
  clientHeight: o.height,
172
- scrollTo: M,
172
+ scrollTo: ne,
173
173
  scrollTop: a,
174
174
  containerProps: {
175
175
  ref: t,
176
- onScroll: (u) => {
177
- u.target && (a.value = u.target.scrollTop), f();
176
+ onScroll: (c) => {
177
+ c.target && (a.value = c.target.scrollTop), f();
178
178
  },
179
- style: J
179
+ style: re
180
180
  },
181
- wrapperProps: G,
182
- innerProps: Y
181
+ wrapperProps: le,
182
+ innerProps: se
183
183
  };
184
184
  }
185
- const Ae = Symbol(), $e = Symbol(), ze = Symbol(), He = Symbol(), Ke = Symbol(), Ne = Symbol(), Qe = Symbol(), ke = Symbol();
186
- function De(e, n) {
187
- const t = y({}), o = _(() => e.value.filter((d) => t.value[d[n]])), r = _(() => o.value.length != 0 && Object.keys(t.value).length == e.value.length);
185
+ const M = Symbol(), q = Symbol(), G = Symbol(), Y = Symbol(), J = Symbol(), X = Symbol(), Z = Symbol(), ee = Symbol();
186
+ function We() {
187
+ const e = b(M), n = b(q), t = b(G), o = b(Y), s = b(J), a = b(X), l = b(Z), i = b(ee);
188
+ return {
189
+ toggleAll: e,
190
+ toggle: n,
191
+ isSelected: t,
192
+ selected: o,
193
+ select: s,
194
+ unselect: a,
195
+ isAllSelected: l,
196
+ unselectAll: i
197
+ };
198
+ }
199
+ function Me(e, n) {
200
+ const t = O({}), o = S(() => e.value.filter((d) => t.value[d[n]])), s = S(() => o.value.length != 0 && Object.keys(t.value).length == e.value.length);
188
201
  function a() {
189
202
  e.value.forEach((d) => {
190
203
  t.value[d[n]] = !0;
@@ -198,35 +211,35 @@ function De(e, n) {
198
211
  t.value[f[n]] || (t.value[f[n]] = !0);
199
212
  });
200
213
  }
201
- function s(d) {
214
+ function r(d) {
202
215
  d.forEach((f) => {
203
216
  t.value[f[n]] && delete t.value[f[n]];
204
217
  });
205
218
  }
206
- function c(d) {
219
+ function u(d) {
207
220
  return !!t.value[d[n]];
208
221
  }
209
- function O(d) {
222
+ function w(d) {
210
223
  d.forEach((f) => {
211
- c(f) ? delete t.value[f[n]] : t.value[f[n]] = !0;
224
+ u(f) ? delete t.value[f[n]] : t.value[f[n]] = !0;
212
225
  });
213
226
  }
214
- function w() {
215
- r.value ? l() : a();
227
+ function _() {
228
+ s.value ? l() : a();
216
229
  }
217
- return m(Ae, w), m($e, O), m(ze, c), m(He, o), m(Ke, i), m(Ne, s), m(Qe, r), m(ke, l), {
230
+ return m(M, _), m(q, w), m(G, u), m(Y, o), m(J, i), m(X, r), m(Z, s), m(ee, l), {
218
231
  selected: o,
219
232
  select: i,
220
233
  selectAll: a,
221
- unselect: s,
234
+ unselect: r,
222
235
  unselectAll: l,
223
- toggle: O,
224
- toggleAll: w,
225
- isSelected: c,
226
- isAllSelected: r
236
+ toggle: w,
237
+ toggleAll: _,
238
+ isSelected: u,
239
+ isAllSelected: s
227
240
  };
228
241
  }
229
- const Le = Symbol(), Ve = /* @__PURE__ */ F({
242
+ const Le = Symbol(), Ve = /* @__PURE__ */ U({
230
243
  __name: "Dialog",
231
244
  props: {
232
245
  visiable: { type: Boolean, default: !1 },
@@ -238,85 +251,85 @@ const Le = Symbol(), Ve = /* @__PURE__ */ F({
238
251
  const t = e, o = () => {
239
252
  t.closeOnClickOverlay && n("update:visiable", !1);
240
253
  };
241
- return m(Le, () => n("update:visiable", !1)), (r, a) => (S(), re(se, { name: "modal" }, {
242
- default: ae(() => [
243
- e.visiable ? (S(), I("div", {
254
+ return m(Le, () => n("update:visiable", !1)), (s, a) => (I(), pe(ge, { name: "modal" }, {
255
+ default: he(() => [
256
+ e.visiable ? (I(), P("div", {
244
257
  key: 0,
245
258
  onClick: o,
246
259
  class: "modal absolute inset-0 bottom-0 z-50 flex bg-stone-900 bg-opacity-50"
247
260
  }, [
248
- x("div", {
249
- onClick: a[0] || (a[0] = ie(() => {
261
+ E("div", {
262
+ onClick: a[0] || (a[0] = me(() => {
250
263
  }, ["stop"])),
251
- class: ue(["dialog m-auto flex flex-col", e.dialogClass])
264
+ class: be(["dialog m-auto flex flex-col", e.dialogClass])
252
265
  }, [
253
- U(r.$slots, "default")
266
+ D(s.$slots, "default")
254
267
  ], 2)
255
- ])) : ce("", !0)
268
+ ])) : ye("", !0)
256
269
  ]),
257
270
  _: 3
258
271
  }));
259
272
  }
260
273
  });
261
- function We(e) {
274
+ function qe(e) {
262
275
  function n(t, o) {
263
- const r = document.createElement("div"), a = {
276
+ const s = document.createElement("div"), a = {
264
277
  setup() {
265
- return () => P(
278
+ return () => x(
266
279
  Ve,
267
280
  {
268
281
  visiable: !0,
269
282
  "onUpdate:visiable": () => {
270
- r?.remove();
283
+ s?.remove();
271
284
  },
272
285
  ...e
273
286
  },
274
287
  {
275
- default: () => P(t, o)
288
+ default: () => x(t, o)
276
289
  }
277
290
  );
278
291
  }
279
292
  };
280
- return document.body.appendChild(r), de(P(a), r), {
281
- close: () => r?.remove()
293
+ return document.body.appendChild(s), Oe(x(a), s), {
294
+ close: () => s?.remove()
282
295
  };
283
296
  }
284
297
  return {
285
298
  create: n
286
299
  };
287
300
  }
288
- const je = /* @__PURE__ */ F({
301
+ const Fe = /* @__PURE__ */ U({
289
302
  __name: "VirtualList",
290
303
  props: {
291
304
  data: null,
292
305
  itemHeight: null
293
306
  },
294
307
  setup(e) {
295
- const n = e, { list: t, containerProps: o, wrapperProps: r, innerProps: a } = Re(
296
- fe(n, "data"),
308
+ const n = e, { list: t, containerProps: o, wrapperProps: s, innerProps: a } = ke(
309
+ we(n, "data"),
297
310
  {
298
311
  itemHeight: (l) => n.itemHeight(0),
299
312
  overscan: 10
300
313
  }
301
314
  );
302
- return (l, i) => (S(), I("div", {
303
- ref: b(o).ref,
304
- onScrollPassive: i[0] || (i[0] = (...s) => b(o).onScroll && b(o).onScroll(...s)),
315
+ return (l, i) => (I(), P("div", {
316
+ ref: y(o).ref,
317
+ onScrollPassive: i[0] || (i[0] = (...r) => y(o).onScroll && y(o).onScroll(...r)),
305
318
  class: "hiddenScorllBar-firefox hiddenScorllBar h-full overflow-hidden",
306
- style: z(b(o).style)
319
+ style: H(y(o).style)
307
320
  }, [
308
- x("div", H(K(b(r))), [
309
- x("div", H(K(b(a))), [
310
- (S(!0), I(ve, null, pe(b(t), ({ index: s, data: c }) => (S(), I("div", {
311
- key: s,
312
- style: z({
313
- height: `${e.itemHeight(c)}px`,
321
+ E("div", K(j(y(s))), [
322
+ E("div", K(j(y(a))), [
323
+ (I(!0), P(_e, null, Se(y(t), ({ index: r, data: u }) => (I(), P("div", {
324
+ key: r,
325
+ style: H({
326
+ height: `${e.itemHeight(u)}px`,
314
327
  display: "flex"
315
328
  })
316
329
  }, [
317
- U(l.$slots, "default", {
318
- data: c,
319
- index: s
330
+ D(l.$slots, "default", {
331
+ data: u,
332
+ index: r
320
333
  }, void 0, !0)
321
334
  ], 4))), 128))
322
335
  ], 16)
@@ -324,24 +337,25 @@ const je = /* @__PURE__ */ F({
324
337
  ], 36));
325
338
  }
326
339
  });
327
- const Fe = (e, n) => {
340
+ const Ue = (e, n) => {
328
341
  const t = e.__vccOpts || e;
329
- for (const [o, r] of n)
330
- t[o] = r;
342
+ for (const [o, s] of n)
343
+ t[o] = s;
331
344
  return t;
332
- }, Me = /* @__PURE__ */ Fe(je, [["__scopeId", "data-v-b9b7f6cb"]]);
345
+ }, Ge = /* @__PURE__ */ Ue(Fe, [["__scopeId", "data-v-b9b7f6cb"]]);
333
346
  export {
334
- Me as VirtualList,
335
- He as allSelectedKey,
347
+ Ge as VirtualList,
348
+ Y as allSelectedKey,
336
349
  Le as closeDialogKey,
337
- We as dialogController,
338
- Qe as isAllSelectedKey,
339
- ze as isSelectedKey,
340
- Ke as selectKey,
341
- Ae as toggleAllKey,
342
- $e as toggleKey,
343
- ke as unselectAllKey,
344
- Ne as unselectKey,
345
- De as useSelectable,
346
- Re as useVirtualList
350
+ qe as dialogController,
351
+ Z as isAllSelectedKey,
352
+ G as isSelectedKey,
353
+ J as selectKey,
354
+ M as toggleAllKey,
355
+ q as toggleKey,
356
+ ee as unselectAllKey,
357
+ X as unselectKey,
358
+ Me as useSelectable,
359
+ We as useSelectableInjectors,
360
+ ke as useVirtualList
347
361
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(i,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(i=typeof globalThis<"u"?globalThis:i||self,e(i.ui={},i.Vue))})(this,function(i,e){"use strict";var P;const w=typeof window<"u";w&&((P=window?.navigator)==null?void 0:P.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function F(t){return typeof t=="function"?t():e.unref(t)}function M(t){return t}function D(t){return e.getCurrentScope()?(e.onScopeDispose(t),!0):!1}function U(t,o=!0){e.getCurrentInstance()?e.onMounted(t):o?t():e.nextTick(t)}function C(t){var o;const n=F(t);return(o=n?.$el)!=null?o:n}const W=w?window:void 0;w&&window.document,w&&window.navigator,w&&window.location;function q(t,o=!1){const n=e.ref(),l=()=>n.value=Boolean(t());return l(),U(l,o),n}const O=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},S="__vueuse_ssr_handlers__";O[S]=O[S]||{},O[S];var I=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable,J=(t,o)=>{var n={};for(var l in t)G.call(t,l)&&o.indexOf(l)<0&&(n[l]=t[l]);if(t!=null&&I)for(var l of I(t))o.indexOf(l)<0&&Y.call(t,l)&&(n[l]=t[l]);return n};function X(t,o,n={}){const l=n,{window:a=W}=l,c=J(l,["window"]);let r;const u=q(()=>a&&"ResizeObserver"in a),s=()=>{r&&(r.disconnect(),r=void 0)},f=e.watch(()=>C(t),v=>{s(),u.value&&a&&v&&(r=new ResizeObserver(o),r.observe(v,c))},{immediate:!0,flush:"post"}),_=()=>{s(),f()};return D(_),{isSupported:u,stop:_}}function Z(t,o={width:0,height:0},n={}){const{box:l="content-box"}=n,a=e.ref(o.width),c=e.ref(o.height);return X(t,([r])=>{const u=l==="border-box"?r.borderBoxSize:l==="content-box"?r.contentBoxSize:r.devicePixelContentBoxSize;u?(a.value=u.reduce((s,{inlineSize:f})=>s+f,0),c.value=u.reduce((s,{blockSize:f})=>s+f,0)):(a.value=r.contentRect.width,c.value=r.contentRect.height)},n),e.watch(()=>C(t),r=>{a.value=r?o.width:0,c.value=r?o.height:0}),{width:a,height:c}}var E;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})(E||(E={}));var ee=Object.defineProperty,B=Object.getOwnPropertySymbols,te=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable,T=(t,o,n)=>o in t?ee(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n,oe=(t,o)=>{for(var n in o||(o={}))te.call(o,n)&&T(t,n,o[n]);if(B)for(var n of B(o))ne.call(o,n)&&T(t,n,o[n]);return t};oe({linear:M},{easeInSine:[.12,0,.39,0],easeOutSine:[.61,1,.88,1],easeInOutSine:[.37,0,.63,1],easeInQuad:[.11,0,.5,0],easeOutQuad:[.5,1,.89,1],easeInOutQuad:[.45,0,.55,1],easeInCubic:[.32,0,.67,0],easeOutCubic:[.33,1,.68,1],easeInOutCubic:[.65,0,.35,1],easeInQuart:[.5,0,.75,0],easeOutQuart:[.25,1,.5,1],easeInOutQuart:[.76,0,.24,1],easeInQuint:[.64,0,.78,0],easeOutQuint:[.22,1,.36,1],easeInOutQuint:[.83,0,.17,1],easeInExpo:[.7,0,.84,0],easeOutExpo:[.16,1,.3,1],easeInOutExpo:[.87,0,.13,1],easeInCirc:[.55,0,1,.45],easeOutCirc:[0,.55,.45,1],easeInOutCirc:[.85,0,.15,1],easeInBack:[.36,0,.66,-.56],easeOutBack:[.34,1.56,.64,1],easeInOutBack:[.68,-.6,.32,1.6]});function K(t,o){const n=e.ref(),l=Z(n),a=e.ref([]),c=e.ref(0),r=e.shallowRef(t),u=e.ref({start:0,end:10}),{itemHeight:s,overscan:f=5}=o,_=d=>{const{start:y=0}=u.value;let g=0,m=0;for(let b=y;b<r.value.length;b++)if(g+=s(b),g>=d){m=b;break}return m-y},v=d=>{let y=0,g=0;for(let m=0;m<r.value.length;m++)if(y+=s(m),y>=d){g=m;break}return g};let p;const h=()=>{cancelAnimationFrame(p),p=requestAnimationFrame(L)},L=()=>{const d=n.value;if(d){const y=v(d.scrollTop),g=_(d.clientHeight),m=y-f,b=y+g+f;u.value={start:m<0?0:m,end:b>r.value.length?r.value.length:b},a.value=r.value.slice(u.value.start,u.value.end).map((Q,ge)=>({data:Q,index:ge+u.value.start}))}};e.onMounted(()=>{}),e.onUnmounted(()=>{cancelAnimationFrame(p)}),e.watch([l.width,l.height,r],()=>{h()},{deep:!0});const j=e.computed(()=>typeof s=="number"?r.value.length*s:r.value.reduce((d,y,g)=>d+s(g),0)),ce=d=>typeof s=="number"?d*s:r.value.slice(0,d).reduce((g,m,b)=>g+s(b),0),ue=d=>{n.value&&(n.value.scrollTop=d,L())},de=e.computed(()=>ce(u.value.start)),fe=e.computed(()=>({style:{width:"100%",height:`${j.value}px`}})),pe=e.computed(()=>({style:{transform:`translate3d(0, ${de.value}px, 0)`,"will-change":"transform"}})),he={overflowY:"auto"};return{list:a,totalHeight:j,clientHeight:l.height,scrollTo:ue,scrollTop:c,containerProps:{ref:n,onScroll:d=>{d.target&&(c.value=d.target.scrollTop),h()},style:he},wrapperProps:fe,innerProps:pe}}const k=Symbol(),x=Symbol(),A=Symbol(),R=Symbol(),V=Symbol(),z=Symbol(),N=Symbol(),$=Symbol();function le(t,o){const n=e.ref({}),l=e.computed(()=>t.value.filter(p=>n.value[p[o]])),a=e.computed(()=>l.value.length!=0&&Object.keys(n.value).length==t.value.length);function c(){t.value.forEach(p=>{n.value[p[o]]=!0})}function r(){n.value={}}function u(p){p.forEach(h=>{n.value[h[o]]||(n.value[h[o]]=!0)})}function s(p){p.forEach(h=>{n.value[h[o]]&&delete n.value[h[o]]})}function f(p){return!!n.value[p[o]]}function _(p){p.forEach(h=>{f(h)?delete n.value[h[o]]:n.value[h[o]]=!0})}function v(){a.value?r():c()}return e.provide(k,v),e.provide(x,_),e.provide(A,f),e.provide(R,l),e.provide(V,u),e.provide(z,s),e.provide(N,a),e.provide($,r),{selected:l,select:u,selectAll:c,unselect:s,unselectAll:r,toggle:_,toggleAll:v,isSelected:f,isAllSelected:a}}const H=Symbol(),re=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(H,()=>o("update:visiable",!1)),(a,c)=>(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:c[0]||(c[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 ae(t){function o(n,l){const a=document.createElement("div"),c={setup(){return()=>e.h(re,{visiable:!0,"onUpdate:visiable":()=>{a?.remove()},...t},{default:()=>e.h(n,l)})}};return document.body.appendChild(a),e.render(e.h(c),a),{close:()=>a?.remove()}}return{create:o}}const se=e.defineComponent({__name:"VirtualList",props:{data:null,itemHeight:null},setup(t){const o=t,{list:n,containerProps:l,wrapperProps:a,innerProps:c}=K(e.toRef(o,"data"),{itemHeight:r=>o.itemHeight(0),overscan:10});return(r,u)=>(e.openBlock(),e.createElementBlock("div",{ref:e.unref(l).ref,onScrollPassive:u[0]||(u[0]=(...s)=>e.unref(l).onScroll&&e.unref(l).onScroll(...s)),class:"hiddenScorllBar-firefox hiddenScorllBar h-full overflow-hidden",style:e.normalizeStyle(e.unref(l).style)},[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(a))),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(c))),[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n),({index:s,data:f})=>(e.openBlock(),e.createElementBlock("div",{key:s,style:e.normalizeStyle({height:`${t.itemHeight(f)}px`,display:"flex"})},[e.renderSlot(r.$slots,"default",{data:f,index:s},void 0,!0)],4))),128))],16)],16)],36))}}),ye="",ie=((t,o)=>{const n=t.__vccOpts||t;for(const[l,a]of o)n[l]=a;return n})(se,[["__scopeId","data-v-b9b7f6cb"]]);i.VirtualList=ie,i.allSelectedKey=R,i.closeDialogKey=H,i.dialogController=ae,i.isAllSelectedKey=N,i.isSelectedKey=A,i.selectKey=V,i.toggleAllKey=k,i.toggleKey=x,i.unselectAllKey=$,i.unselectKey=z,i.useSelectable=le,i.useVirtualList=K,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(u,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(u=typeof globalThis<"u"?globalThis:u||self,e(u.ui={},u.Vue))})(this,function(u,e){"use strict";var A;const O=typeof window<"u";O&&((A=window?.navigator)==null?void 0:A.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function F(t){return typeof t=="function"?t():e.unref(t)}function M(t){return t}function D(t){return e.getCurrentScope()?(e.onScopeDispose(t),!0):!1}function U(t,o=!0){e.getCurrentInstance()?e.onMounted(t):o?t():e.nextTick(t)}function k(t){var o;const n=F(t);return(o=n?.$el)!=null?o:n}const W=O?window:void 0;O&&window.document,O&&window.navigator,O&&window.location;function q(t,o=!1){const n=e.ref(),l=()=>n.value=Boolean(t());return l(),U(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 x=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable,J=(t,o)=>{var n={};for(var l in t)G.call(t,l)&&o.indexOf(l)<0&&(n[l]=t[l]);if(t!=null&&x)for(var l of x(t))o.indexOf(l)<0&&Y.call(t,l)&&(n[l]=t[l]);return n};function X(t,o,n={}){const l=n,{window:s=W}=l,a=J(l,["window"]);let r;const c=q(()=>s&&"ResizeObserver"in s),i=()=>{r&&(r.disconnect(),r=void 0)},f=e.watch(()=>k(t),w=>{i(),c.value&&s&&w&&(r=new ResizeObserver(o),r.observe(w,a))},{immediate:!0,flush:"post"}),_=()=>{i(),f()};return D(_),{isSupported:c,stop:_}}function Z(t,o={width:0,height:0},n={}){const{box:l="content-box"}=n,s=e.ref(o.width),a=e.ref(o.height);return X(t,([r])=>{const c=l==="border-box"?r.borderBoxSize:l==="content-box"?r.contentBoxSize:r.devicePixelContentBoxSize;c?(s.value=c.reduce((i,{inlineSize:f})=>i+f,0),a.value=c.reduce((i,{blockSize:f})=>i+f,0)):(s.value=r.contentRect.width,a.value=r.contentRect.height)},n),e.watch(()=>k(t),r=>{s.value=r?o.width:0,a.value=r?o.height:0}),{width:s,height:a}}var R;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})(R||(R={}));var ee=Object.defineProperty,V=Object.getOwnPropertySymbols,te=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable,z=(t,o,n)=>o in t?ee(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n,oe=(t,o)=>{for(var n in o||(o={}))te.call(o,n)&&z(t,n,o[n]);if(V)for(var n of V(o))ne.call(o,n)&&z(t,n,o[n]);return t};oe({linear:M},{easeInSine:[.12,0,.39,0],easeOutSine:[.61,1,.88,1],easeInOutSine:[.37,0,.63,1],easeInQuad:[.11,0,.5,0],easeOutQuad:[.5,1,.89,1],easeInOutQuad:[.45,0,.55,1],easeInCubic:[.32,0,.67,0],easeOutCubic:[.33,1,.68,1],easeInOutCubic:[.65,0,.35,1],easeInQuart:[.5,0,.75,0],easeOutQuart:[.25,1,.5,1],easeInOutQuart:[.76,0,.24,1],easeInQuint:[.64,0,.78,0],easeOutQuint:[.22,1,.36,1],easeInOutQuint:[.83,0,.17,1],easeInExpo:[.7,0,.84,0],easeOutExpo:[.16,1,.3,1],easeInOutExpo:[.87,0,.13,1],easeInCirc:[.55,0,1,.45],easeOutCirc:[0,.55,.45,1],easeInOutCirc:[.85,0,.15,1],easeInBack:[.36,0,.66,-.56],easeOutBack:[.34,1.56,.64,1],easeInOutBack:[.68,-.6,.32,1.6]});function N(t,o){const n=e.ref(),l=Z(n),s=e.ref([]),a=e.ref(0),r=e.shallowRef(t),c=e.ref({start:0,end:10}),{itemHeight:i,overscan:f=5}=o,_=d=>{const{start:b=0}=c.value;let h=0,m=0;for(let y=b;y<r.value.length;y++)if(h+=i(y),h>=d){m=y;break}return m-b},w=d=>{let b=0,h=0;for(let m=0;m<r.value.length;m++)if(b+=i(m),b>=d){h=m;break}return h};let p;const g=()=>{cancelAnimationFrame(p),p=requestAnimationFrame(H)},H=()=>{const d=n.value;if(d){const b=w(d.scrollTop),h=_(d.clientHeight),m=b-f,y=b+h+f;c.value={start:m<0?0:m,end:y>r.value.length?r.value.length:y},s.value=r.value.slice(c.value.start,c.value.end).map((Q,me)=>({data:Q,index:me+c.value.start}))}};e.onMounted(()=>{}),e.onUnmounted(()=>{cancelAnimationFrame(p)}),e.watch([l.width,l.height,r],()=>{g()},{deep:!0});const L=e.computed(()=>typeof i=="number"?r.value.length*i:r.value.reduce((d,b,h)=>d+i(h),0)),ue=d=>typeof i=="number"?d*i:r.value.slice(0,d).reduce((h,m,y)=>h+i(y),0),de=d=>{n.value&&(n.value.scrollTop=d,H())},fe=e.computed(()=>ue(c.value.start)),pe=e.computed(()=>({style:{width:"100%",height:`${L.value}px`}})),ge=e.computed(()=>({style:{transform:`translate3d(0, ${fe.value}px, 0)`,"will-change":"transform"}})),he={overflowY:"auto"};return{list:s,totalHeight:L,clientHeight:l.height,scrollTo:de,scrollTop:a,containerProps:{ref:n,onScroll:d=>{d.target&&(a.value=d.target.scrollTop),g()},style:he},wrapperProps:pe,innerProps:ge}}const P=Symbol(),C=Symbol(),I=Symbol(),E=Symbol(),B=Symbol(),T=Symbol(),j=Symbol(),K=Symbol();function le(){const t=e.inject(P),o=e.inject(C),n=e.inject(I),l=e.inject(E),s=e.inject(B),a=e.inject(T),r=e.inject(j),c=e.inject(K);return{toggleAll:t,toggle:o,isSelected:n,selected:l,select:s,unselect:a,isAllSelected:r,unselectAll:c}}function re(t,o){const n=e.ref({}),l=e.computed(()=>t.value.filter(p=>n.value[p[o]])),s=e.computed(()=>l.value.length!=0&&Object.keys(n.value).length==t.value.length);function a(){t.value.forEach(p=>{n.value[p[o]]=!0})}function r(){n.value={}}function c(p){p.forEach(g=>{n.value[g[o]]||(n.value[g[o]]=!0)})}function i(p){p.forEach(g=>{n.value[g[o]]&&delete n.value[g[o]]})}function f(p){return!!n.value[p[o]]}function _(p){p.forEach(g=>{f(g)?delete n.value[g[o]]:n.value[g[o]]=!0})}function w(){s.value?r():a()}return e.provide(P,w),e.provide(C,_),e.provide(I,f),e.provide(E,l),e.provide(B,c),e.provide(T,i),e.provide(j,s),e.provide(K,r),{selected:l,select:c,selectAll:a,unselect:i,unselectAll:r,toggle:_,toggleAll:w,isSelected:f,isAllSelected:s}}const $=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($,()=>o("update:visiable",!1)),(s,a)=>(e.openBlock(),e.createBlock(e.Transition,{name:"modal"},{default:e.withCtx(()=>[t.visiable?(e.openBlock(),e.createElementBlock("div",{key:0,onClick:l,class:"modal absolute inset-0 bottom-0 z-50 flex bg-stone-900 bg-opacity-50"},[e.createElementVNode("div",{onClick:a[0]||(a[0]=e.withModifiers(()=>{},["stop"])),class:e.normalizeClass(["dialog m-auto flex flex-col",t.dialogClass])},[e.renderSlot(s.$slots,"default")],2)])):e.createCommentVNode("",!0)]),_:3}))}});function ie(t){function o(n,l){const s=document.createElement("div"),a={setup(){return()=>e.h(se,{visiable:!0,"onUpdate:visiable":()=>{s?.remove()},...t},{default:()=>e.h(n,l)})}};return document.body.appendChild(s),e.render(e.h(a),s),{close:()=>s?.remove()}}return{create:o}}const ae=e.defineComponent({__name:"VirtualList",props:{data:null,itemHeight:null},setup(t){const o=t,{list:n,containerProps:l,wrapperProps:s,innerProps:a}=N(e.toRef(o,"data"),{itemHeight:r=>o.itemHeight(0),overscan:10});return(r,c)=>(e.openBlock(),e.createElementBlock("div",{ref:e.unref(l).ref,onScrollPassive:c[0]||(c[0]=(...i)=>e.unref(l).onScroll&&e.unref(l).onScroll(...i)),class:"hiddenScorllBar-firefox hiddenScorllBar h-full overflow-hidden",style:e.normalizeStyle(e.unref(l).style)},[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(s))),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(a))),[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n),({index:i,data:f})=>(e.openBlock(),e.createElementBlock("div",{key:i,style:e.normalizeStyle({height:`${t.itemHeight(f)}px`,display:"flex"})},[e.renderSlot(r.$slots,"default",{data:f,index:i},void 0,!0)],4))),128))],16)],16)],36))}}),ye="",ce=((t,o)=>{const n=t.__vccOpts||t;for(const[l,s]of o)n[l]=s;return n})(ae,[["__scopeId","data-v-b9b7f6cb"]]);u.VirtualList=ce,u.allSelectedKey=E,u.closeDialogKey=$,u.dialogController=ie,u.isAllSelectedKey=j,u.isSelectedKey=I,u.selectKey=B,u.toggleAllKey=P,u.toggleKey=C,u.unselectAllKey=K,u.unselectKey=T,u.useSelectable=re,u.useSelectableInjectors=le,u.useVirtualList=N,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,9 +1,17 @@
1
- import { type ComponentOptions, type VNodeProps } from "vue";
1
+ import { type VNodeProps } from "vue";
2
2
  import { type DialogProps } from "./Dialog.vue";
3
3
  export * from "./keys";
4
+ interface Constructor<P = any> {
5
+ __isFragment?: never;
6
+ __isTeleport?: never;
7
+ __isSuspense?: never;
8
+ new (...args: any[]): {
9
+ $props: P;
10
+ };
11
+ }
4
12
  declare type DialogControllerOptions = Omit<DialogProps, "visiable">;
5
13
  export declare function dialogController(dialogProps?: DialogControllerOptions): {
6
- create: <P>(component: ComponentOptions<P, any, any, any, any, any, any, any>, componentProps?: (VNodeProps & P) | undefined) => {
14
+ create: <P>(component: Constructor<P>, componentProps?: (VNodeProps & P) | undefined) => {
7
15
  close: () => void;
8
16
  };
9
17
  };
@@ -1,5 +1,15 @@
1
1
  import { type ComputedRef, type Ref } from "vue";
2
2
  export * from "./keys";
3
+ export declare function useSelectableInjectors(): {
4
+ toggleAll: (() => void) | undefined;
5
+ toggle: ((a: any[]) => void) | undefined;
6
+ isSelected: ((a: any) => boolean) | undefined;
7
+ selected: ComputedRef<any[]> | undefined;
8
+ select: ((a: any) => void) | undefined;
9
+ unselect: ((a: any) => void) | undefined;
10
+ isAllSelected: ComputedRef<boolean> | undefined;
11
+ unselectAll: (() => void) | undefined;
12
+ };
3
13
  export declare function useSelectable<T extends Record<K, string | number>, K extends keyof T>(data: Ref<Array<T>>, key: K): {
4
14
  selected: ComputedRef<T[]>;
5
15
  select: (items: Array<T>) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazycatcloud/lzc-toolkit",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "lazycat ui toolkits",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",