@lazycatcloud/lzc-toolkit 0.0.1 → 0.0.2

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