@lazycatcloud/lzc-toolkit 0.0.6 → 0.0.7

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
@@ -40,30 +40,30 @@ var z = Object.getOwnPropertySymbols, _e = Object.prototype.hasOwnProperty, Oe =
40
40
  return n;
41
41
  };
42
42
  function Pe(e, t, n = {}) {
43
- const l = n, { window: r = ye } = l, s = Se(l, ["window"]);
43
+ const l = n, { window: i = ye } = l, r = Se(l, ["window"]);
44
44
  let o;
45
- const i = we(() => r && "ResizeObserver" in r), a = () => {
45
+ const s = we(() => i && "ResizeObserver" in i), a = () => {
46
46
  o && (o.disconnect(), o = void 0);
47
47
  }, c = T(() => M(e), (_) => {
48
- a(), i.value && r && _ && (o = new ResizeObserver(t), o.observe(_, s));
48
+ a(), s.value && i && _ && (o = new ResizeObserver(t), o.observe(_, r));
49
49
  }, { immediate: !0, flush: "post" }), w = () => {
50
50
  a(), c();
51
51
  };
52
52
  return me(w), {
53
- isSupported: i,
53
+ isSupported: s,
54
54
  stop: w
55
55
  };
56
56
  }
57
57
  function Ie(e, t = { width: 0, height: 0 }, n = {}) {
58
- const { box: l = "content-box" } = n, r = b(t.width), s = b(t.height);
58
+ const { box: l = "content-box" } = n, i = b(t.width), r = b(t.height);
59
59
  return Pe(e, ([o]) => {
60
- const i = l === "border-box" ? o.borderBoxSize : l === "content-box" ? o.contentBoxSize : o.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 = o.contentRect.width, s.value = o.contentRect.height);
60
+ const s = l === "border-box" ? o.borderBoxSize : l === "content-box" ? o.contentBoxSize : o.devicePixelContentBoxSize;
61
+ s ? (i.value = s.reduce((a, { inlineSize: c }) => a + c, 0), r.value = s.reduce((a, { blockSize: c }) => a + c, 0)) : (i.value = o.contentRect.width, r.value = o.contentRect.height);
62
62
  }, n), T(() => M(e), (o) => {
63
- r.value = o ? t.width : 0, s.value = o ? t.height : 0;
63
+ i.value = o ? t.width : 0, r.value = o ? t.height : 0;
64
64
  }), {
65
- width: r,
66
- height: s
65
+ width: i,
66
+ height: r
67
67
  };
68
68
  }
69
69
  var Q;
@@ -108,8 +108,8 @@ Te({
108
108
  linear: ge
109
109
  }, Be);
110
110
  function Ae(e, t) {
111
- const n = b(), l = Ie(n), r = b([]), s = b(0), o = le(e), i = b({ start: 0, end: 10 }), { itemHeight: a, overscan: c = 5 } = t, w = (u) => {
112
- const { start: h = 0 } = i.value;
111
+ const n = b(), l = Ie(n), i = b([]), r = b(0), o = le(e), s = b({ start: 0, end: 10 }), { itemHeight: a, overscan: c = 5 } = t, w = (u) => {
112
+ const { start: h = 0 } = s.value;
113
113
  let v = 0, p = 0;
114
114
  for (let g = h; g < o.value.length; g++)
115
115
  if (v += a(g), v >= u) {
@@ -133,12 +133,12 @@ function Ae(e, t) {
133
133
  const u = n.value;
134
134
  if (u) {
135
135
  const h = _(u.scrollTop), v = w(u.clientHeight), p = h - c, g = h + v + c;
136
- i.value = {
136
+ s.value = {
137
137
  start: p < 0 ? 0 : p,
138
138
  end: g > o.value.length ? o.value.length : g
139
- }, r.value = o.value.slice(i.value.start, i.value.end).map((R, Z) => ({
139
+ }, i.value = o.value.slice(s.value.start, s.value.end).map((R, Z) => ({
140
140
  data: R,
141
- index: Z + i.value.start
141
+ index: Z + s.value.start
142
142
  }));
143
143
  }
144
144
  };
@@ -154,7 +154,7 @@ function Ae(e, t) {
154
154
  );
155
155
  const A = O(() => typeof a == "number" ? o.value.length * a : o.value.reduce((u, h, v) => u + a(v), 0)), W = (u) => typeof a == "number" ? u * a : o.value.slice(0, u).reduce((v, p, g) => v + a(g), 0), q = (u) => {
156
156
  n.value && (n.value.scrollTop = u, B());
157
- }, G = O(() => W(i.value.start)), Y = O(() => ({
157
+ }, G = O(() => W(s.value.start)), Y = O(() => ({
158
158
  style: {
159
159
  width: "100%",
160
160
  height: `${A.value}px`
@@ -166,15 +166,15 @@ function Ae(e, t) {
166
166
  }
167
167
  })), X = { overflowY: "auto" };
168
168
  return {
169
- list: r,
169
+ list: i,
170
170
  totalHeight: A,
171
171
  clientHeight: l.height,
172
172
  scrollTo: q,
173
- scrollTop: s,
173
+ scrollTop: r,
174
174
  containerProps: {
175
175
  ref: n,
176
176
  onScroll: (u) => {
177
- u.target && (s.value = u.target.scrollTop), f();
177
+ u.target && (r.value = u.target.scrollTop), f();
178
178
  },
179
179
  style: X
180
180
  },
@@ -184,8 +184,8 @@ function Ae(e, t) {
184
184
  }
185
185
  const Re = Symbol(), Ne = Symbol(), $e = Symbol(), He = Symbol(), Ke = Symbol(), Ve = Symbol(), ze = Symbol(), Qe = Symbol();
186
186
  function Ue(e, t) {
187
- const n = b({}), l = O(() => e.value.filter((d) => n.value[d[t]])), r = O(() => l.value.length != 0 && Object.keys(n.value).length == e.value.length);
188
- function s() {
187
+ const n = b({}), l = O(() => e.value.filter((d) => n.value[d[t]])), i = O(() => l.value.length != 0 && Object.keys(n.value).length == e.value.length);
188
+ function r() {
189
189
  e.value.forEach((d) => {
190
190
  n.value[d[t]] = !0;
191
191
  });
@@ -193,7 +193,7 @@ function Ue(e, t) {
193
193
  function o() {
194
194
  n.value = {};
195
195
  }
196
- function i(d) {
196
+ function s(d) {
197
197
  d.forEach((f) => {
198
198
  n.value[f[t]] || (n.value[f[t]] = !0);
199
199
  });
@@ -212,18 +212,18 @@ function Ue(e, t) {
212
212
  });
213
213
  }
214
214
  function _() {
215
- r.value ? o() : s();
215
+ i.value ? o() : r();
216
216
  }
217
- return m(Re, _), m(Ne, w), m($e, c), m(He, l), m(Ke, i), m(Ve, a), m(ze, r), m(Qe, o), {
217
+ return m(Re, _), m(Ne, w), m($e, c), m(He, l), m(Ke, s), m(Ve, a), m(ze, i), m(Qe, o), {
218
218
  selected: l,
219
- select: i,
220
- selectAll: s,
219
+ select: s,
220
+ selectAll: r,
221
221
  unselect: a,
222
222
  unselectAll: o,
223
223
  toggle: w,
224
224
  toggleAll: _,
225
225
  isSelected: c,
226
- isAllSelected: r
226
+ isAllSelected: i
227
227
  };
228
228
  }
229
229
  const ke = Symbol(), Le = /* @__PURE__ */ D({
@@ -237,7 +237,7 @@ const ke = Symbol(), Le = /* @__PURE__ */ D({
237
237
  const n = e, l = () => {
238
238
  n.closeOnClickOverlay && t("update:show", !1);
239
239
  };
240
- return m(ke, () => t("update:show", !1)), (r, s) => (S(), re(se, { name: "modal" }, {
240
+ return m(ke, () => t("update:show", !1)), (i, r) => (S(), re(se, { name: "modal" }, {
241
241
  default: ae(() => [
242
242
  e.visiable ? (S(), I("div", {
243
243
  key: 0,
@@ -245,11 +245,11 @@ const ke = Symbol(), Le = /* @__PURE__ */ D({
245
245
  class: "modal absolute inset-0 bottom-0 z-50 flex bg-stone-900 bg-opacity-50"
246
246
  }, [
247
247
  x("div", {
248
- onClick: s[0] || (s[0] = ie(() => {
248
+ onClick: r[0] || (r[0] = ie(() => {
249
249
  }, ["stop"])),
250
250
  class: "dialog m-auto flex flex-col"
251
251
  }, [
252
- U(r.$slots, "default")
252
+ U(i.$slots, "default")
253
253
  ])
254
254
  ])) : ue("", !0)
255
255
  ]),
@@ -260,48 +260,47 @@ const ke = Symbol(), Le = /* @__PURE__ */ D({
260
260
  function Me() {
261
261
  let e = null;
262
262
  const t = b({});
263
- function n(r, s, o = !0) {
264
- return t.value[r] ? (t.value[r].visiable = o, !0) : (t.value[r] = {
265
- visiable: o,
266
- componentProps: s
263
+ function n(r, o, s = !0) {
264
+ return t.value[r] ? (t.value[r].visiable = s, !0) : (t.value[r] = {
265
+ visiable: s,
266
+ componentProps: o
267
267
  }, !1);
268
268
  }
269
269
  function l(r) {
270
- const s = r.component.name;
271
- if (!n(s, r.componentProps || {})) {
272
- const o = {
270
+ t.value[r].visiable = !1, t.value = {}, e && e.childNodes.length > 0 && e.childNodes.forEach((o) => {
271
+ e?.removeChild(o);
272
+ });
273
+ }
274
+ function i(r) {
275
+ const o = r.component.name;
276
+ if (!n(o, r.componentProps || {})) {
277
+ const s = {
273
278
  setup() {
274
279
  return () => N(
275
280
  Le,
276
281
  {
277
- visiable: t.value[s].visiable,
278
- "onUpdate:show": (i) => {
279
- t.value[s].visiable = i;
282
+ visiable: t.value[o].visiable,
283
+ "onUpdate:show": (a) => {
284
+ l(o);
280
285
  }
281
286
  },
282
287
  {
283
288
  default: () => N(
284
289
  r.component,
285
- t.value[s].componentProps
290
+ t.value[o].componentProps
286
291
  )
287
292
  }
288
293
  );
289
294
  }
290
295
  };
291
- e || (e = document.createElement("div"), e.setAttribute("id", "dialog"), document.body.appendChild(e)), ce(de(o), e);
296
+ e || (e = document.createElement("div"), e.setAttribute("id", "dialog"), document.body.appendChild(e)), ce(de(s), e);
292
297
  }
293
- return {
294
- close: () => {
295
- t.value[s].visiable = !1, t.value = {}, e?.childNodes && e.childNodes.forEach((o) => {
296
- e?.removeChild(o);
297
- });
298
- }
299
- };
298
+ return { close: l };
300
299
  }
301
300
  return F(() => {
302
301
  e && document.body.removeChild(e);
303
302
  }), {
304
- create: l
303
+ create: i
305
304
  };
306
305
  }
307
306
  const je = /* @__PURE__ */ D({
@@ -311,21 +310,21 @@ const je = /* @__PURE__ */ D({
311
310
  itemHeight: null
312
311
  },
313
312
  setup(e) {
314
- const t = e, { list: n, containerProps: l, wrapperProps: r, innerProps: s } = Ae(
313
+ const t = e, { list: n, containerProps: l, wrapperProps: i, innerProps: r } = Ae(
315
314
  fe(t, "data"),
316
315
  {
317
316
  itemHeight: (o) => t.itemHeight(0),
318
317
  overscan: 10
319
318
  }
320
319
  );
321
- return (o, i) => (S(), I("div", {
320
+ return (o, s) => (S(), I("div", {
322
321
  ref: y(l).ref,
323
- onScrollPassive: i[0] || (i[0] = (...a) => y(l).onScroll && y(l).onScroll(...a)),
322
+ onScrollPassive: s[0] || (s[0] = (...a) => y(l).onScroll && y(l).onScroll(...a)),
324
323
  class: "hiddenScorllBar-firefox hiddenScorllBar h-full overflow-hidden",
325
324
  style: $(y(l).style)
326
325
  }, [
327
- x("div", H(K(y(r))), [
328
- x("div", H(K(y(s))), [
326
+ x("div", H(K(y(i))), [
327
+ x("div", H(K(y(r))), [
329
328
  (S(!0), I(ve, null, pe(y(n), ({ index: a, data: c }) => (S(), I("div", {
330
329
  key: a,
331
330
  style: $({
@@ -345,8 +344,8 @@ const je = /* @__PURE__ */ D({
345
344
  });
346
345
  const Fe = (e, t) => {
347
346
  const n = e.__vccOpts || e;
348
- for (const [l, r] of t)
349
- n[l] = r;
347
+ for (const [l, i] of t)
348
+ n[l] = i;
350
349
  return n;
351
350
  }, We = /* @__PURE__ */ Fe(je, [["__scopeId", "data-v-b9b7f6cb"]]);
352
351
  export {
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
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 w=typeof window<"u";w&&((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=w?window:void 0;w&&window.document,w&&window.navigator,w&&window.location;function q(t,n=!1){const o=e.ref(),r=()=>o.value=Boolean(t());return r(),U(r,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 E=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable,J=(t,n)=>{var o={};for(var r in t)G.call(t,r)&&n.indexOf(r)<0&&(o[r]=t[r]);if(t!=null&&E)for(var r of E(t))n.indexOf(r)<0&&Y.call(t,r)&&(o[r]=t[r]);return o};function X(t,n,o={}){const r=o,{window:a=W}=r,s=J(r,["window"]);let l;const c=q(()=>a&&"ResizeObserver"in a),i=()=>{l&&(l.disconnect(),l=void 0)},f=e.watch(()=>C(t),_=>{i(),c.value&&a&&_&&(l=new ResizeObserver(n),l.observe(_,s))},{immediate:!0,flush:"post"}),v=()=>{i(),f()};return F(v),{isSupported:c,stop:v}}function Z(t,n={width:0,height:0},o={}){const{box:r="content-box"}=o,a=e.ref(n.width),s=e.ref(n.height);return X(t,([l])=>{const c=r==="border-box"?l.borderBoxSize:r==="content-box"?l.contentBoxSize:l.devicePixelContentBoxSize;c?(a.value=c.reduce((i,{inlineSize:f})=>i+f,0),s.value=c.reduce((i,{blockSize:f})=>i+f,0)):(a.value=l.contentRect.width,s.value=l.contentRect.height)},o),e.watch(()=>C(t),l=>{a.value=l?n.width:0,s.value=l?n.height:0}),{width:a,height:s}}var I;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})(I||(I={}));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(),r=Z(o),a=e.ref([]),s=e.ref(0),l=e.shallowRef(t),c=e.ref({start:0,end:10}),{itemHeight:i,overscan:f=5}=n,v=d=>{const{start:y=0}=c.value;let m=0,g=0;for(let b=y;b<l.value.length;b++)if(m+=i(b),m>=d){g=b;break}return g-y},_=d=>{let y=0,m=0;for(let g=0;g<l.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=_(d.scrollTop),m=v(d.clientHeight),g=y-f,b=y+m+f;c.value={start:g<0?0:g,end:b>l.value.length?l.value.length:b},a.value=l.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([r.width,r.height,l],()=>{h()},{deep:!0});const j=e.computed(()=>typeof i=="number"?l.value.length*i:l.value.reduce((d,y,m)=>d+i(m),0)),ce=d=>typeof i=="number"?d*i:l.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:r.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(),x=Symbol(),V=Symbol(),N=Symbol(),R=Symbol(),z=Symbol(),$=Symbol();function le(t,n){const o=e.ref({}),r=e.computed(()=>t.value.filter(p=>o.value[p[n]])),a=e.computed(()=>r.value.length!=0&&Object.keys(o.value).length==t.value.length);function s(){t.value.forEach(p=>{o.value[p[n]]=!0})}function l(){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 v(p){p.forEach(h=>{f(h)?delete o.value[h[n]]:o.value[h[n]]=!0})}function _(){a.value?l():s()}return e.provide(A,_),e.provide(k,v),e.provide(x,f),e.provide(V,r),e.provide(N,c),e.provide(R,i),e.provide(z,a),e.provide($,l),{selected:r,select:c,selectAll:s,unselect:i,unselectAll:l,toggle:v,toggleAll:_,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,r=()=>{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:r,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,l=!0){return n.value[a]?(n.value[a].visiable=l,!0):(n.value[a]={visiable:l,componentProps:s},!1)}function r(a){const s=a.component.name;if(!o(s,a.componentProps||{})){const l={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(l),t)}return{close:()=>{n.value[s].visiable=!1,n.value={},t?.childNodes&&t.childNodes.forEach(l=>{t?.removeChild(l)})}}}return e.onUnmounted(()=>{t&&document.body.removeChild(t)}),{create:r}}const se=e.defineComponent({__name:"VirtualList",props:{data:null,itemHeight:null},setup(t){const n=t,{list:o,containerProps:r,wrapperProps:a,innerProps:s}=K(e.toRef(n,"data"),{itemHeight:l=>n.itemHeight(0),overscan:10});return(l,c)=>(e.openBlock(),e.createElementBlock("div",{ref:e.unref(r).ref,onScrollPassive:c[0]||(c[0]=(...i)=>e.unref(r).onScroll&&e.unref(r).onScroll(...i)),class:"hiddenScorllBar-firefox hiddenScorllBar h-full overflow-hidden",style:e.normalizeStyle(e.unref(r).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`,display:"flex"})},[e.renderSlot(l.$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[r,a]of n)o[r]=a;return o})(se,[["__scopeId","data-v-b9b7f6cb"]]);u.DialogController=ae,u.VirtualList=ie,u.allSelectedKey=V,u.closeDialogKey=H,u.isAllSelectedKey=z,u.isSelectedKey=x,u.selectKey=N,u.toggleAllKey=A,u.toggleKey=k,u.unselectAllKey=$,u.unselectKey=R,u.useSelectable=le,u.useVirtualList=K,Object.defineProperties(u,{__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 w=typeof window<"u";w&&((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=w?window:void 0;w&&window.document,w&&window.navigator,w&&window.location;function q(t,n=!1){const o=e.ref(),r=()=>o.value=Boolean(t());return r(),U(r,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 E=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable,J=(t,n)=>{var o={};for(var r in t)G.call(t,r)&&n.indexOf(r)<0&&(o[r]=t[r]);if(t!=null&&E)for(var r of E(t))n.indexOf(r)<0&&Y.call(t,r)&&(o[r]=t[r]);return o};function X(t,n,o={}){const r=o,{window:c=W}=r,a=J(r,["window"]);let l;const s=q(()=>c&&"ResizeObserver"in c),i=()=>{l&&(l.disconnect(),l=void 0)},f=e.watch(()=>C(t),_=>{i(),s.value&&c&&_&&(l=new ResizeObserver(n),l.observe(_,a))},{immediate:!0,flush:"post"}),v=()=>{i(),f()};return F(v),{isSupported:s,stop:v}}function Z(t,n={width:0,height:0},o={}){const{box:r="content-box"}=o,c=e.ref(n.width),a=e.ref(n.height);return X(t,([l])=>{const s=r==="border-box"?l.borderBoxSize:r==="content-box"?l.contentBoxSize:l.devicePixelContentBoxSize;s?(c.value=s.reduce((i,{inlineSize:f})=>i+f,0),a.value=s.reduce((i,{blockSize:f})=>i+f,0)):(c.value=l.contentRect.width,a.value=l.contentRect.height)},o),e.watch(()=>C(t),l=>{c.value=l?n.width:0,a.value=l?n.height:0}),{width:c,height:a}}var I;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})(I||(I={}));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(),r=Z(o),c=e.ref([]),a=e.ref(0),l=e.shallowRef(t),s=e.ref({start:0,end:10}),{itemHeight:i,overscan:f=5}=n,v=d=>{const{start:y=0}=s.value;let g=0,m=0;for(let b=y;b<l.value.length;b++)if(g+=i(b),g>=d){m=b;break}return m-y},_=d=>{let y=0,g=0;for(let m=0;m<l.value.length;m++)if(y+=i(m),y>=d){g=m;break}return g};let p;const h=()=>{cancelAnimationFrame(p),p=requestAnimationFrame(L)},L=()=>{const d=o.value;if(d){const y=_(d.scrollTop),g=v(d.clientHeight),m=y-f,b=y+g+f;s.value={start:m<0?0:m,end:b>l.value.length?l.value.length:b},c.value=l.value.slice(s.value.start,s.value.end).map((Q,ge)=>({data:Q,index:ge+s.value.start}))}};e.onMounted(()=>{}),e.onUnmounted(()=>{cancelAnimationFrame(p)}),e.watch([r.width,r.height,l],()=>{h()},{deep:!0});const j=e.computed(()=>typeof i=="number"?l.value.length*i:l.value.reduce((d,y,g)=>d+i(g),0)),ce=d=>typeof i=="number"?d*i:l.value.slice(0,d).reduce((g,m,b)=>g+i(b),0),ue=d=>{o.value&&(o.value.scrollTop=d,L())},de=e.computed(()=>ce(s.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:c,totalHeight:j,clientHeight:r.height,scrollTo:ue,scrollTop:a,containerProps:{ref:o,onScroll:d=>{d.target&&(a.value=d.target.scrollTop),h()},style:he},wrapperProps:fe,innerProps:pe}}const A=Symbol(),k=Symbol(),x=Symbol(),V=Symbol(),N=Symbol(),R=Symbol(),z=Symbol(),$=Symbol();function le(t,n){const o=e.ref({}),r=e.computed(()=>t.value.filter(p=>o.value[p[n]])),c=e.computed(()=>r.value.length!=0&&Object.keys(o.value).length==t.value.length);function a(){t.value.forEach(p=>{o.value[p[n]]=!0})}function l(){o.value={}}function s(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 v(p){p.forEach(h=>{f(h)?delete o.value[h[n]]:o.value[h[n]]=!0})}function _(){c.value?l():a()}return e.provide(A,_),e.provide(k,v),e.provide(x,f),e.provide(V,r),e.provide(N,s),e.provide(R,i),e.provide(z,c),e.provide($,l),{selected:r,select:s,selectAll:a,unselect:i,unselectAll:l,toggle:v,toggleAll:_,isSelected:f,isAllSelected:c}}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,r=()=>{o.closeOnClickOverlay&&n("update:show",!1)};return e.provide(H,()=>n("update:show",!1)),(c,a)=>(e.openBlock(),e.createBlock(e.Transition,{name:"modal"},{default:e.withCtx(()=>[t.visiable?(e.openBlock(),e.createElementBlock("div",{key:0,onClick:r,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:"dialog m-auto flex flex-col"},[e.renderSlot(c.$slots,"default")])])):e.createCommentVNode("",!0)]),_:3}))}});function ae(){let t=null;const n=e.ref({});function o(a,l,s=!0){return n.value[a]?(n.value[a].visiable=s,!0):(n.value[a]={visiable:s,componentProps:l},!1)}function r(a){n.value[a].visiable=!1,n.value={},t&&t.childNodes.length>0&&t.childNodes.forEach(l=>{t?.removeChild(l)})}function c(a){const l=a.component.name;if(!o(l,a.componentProps||{})){const s={setup(){return()=>e.h(re,{visiable:n.value[l].visiable,"onUpdate:show":i=>{r(l)}},{default:()=>e.h(a.component,n.value[l].componentProps)})}};t||(t=document.createElement("div"),t.setAttribute("id","dialog"),document.body.appendChild(t)),e.render(e.createVNode(s),t)}return{close:r}}return e.onUnmounted(()=>{t&&document.body.removeChild(t)}),{create:c}}const se=e.defineComponent({__name:"VirtualList",props:{data:null,itemHeight:null},setup(t){const n=t,{list:o,containerProps:r,wrapperProps:c,innerProps:a}=K(e.toRef(n,"data"),{itemHeight:l=>n.itemHeight(0),overscan:10});return(l,s)=>(e.openBlock(),e.createElementBlock("div",{ref:e.unref(r).ref,onScrollPassive:s[0]||(s[0]=(...i)=>e.unref(r).onScroll&&e.unref(r).onScroll(...i)),class:"hiddenScorllBar-firefox hiddenScorllBar h-full overflow-hidden",style:e.normalizeStyle(e.unref(r).style)},[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(c))),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(a))),[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(o),({index:i,data:f})=>(e.openBlock(),e.createElementBlock("div",{key:i,style:e.normalizeStyle({height:`${t.itemHeight(f)}px`,display:"flex"})},[e.renderSlot(l.$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[r,c]of n)o[r]=c;return o})(se,[["__scopeId","data-v-b9b7f6cb"]]);u.DialogController=ae,u.VirtualList=ie,u.allSelectedKey=V,u.closeDialogKey=H,u.isAllSelectedKey=z,u.isSelectedKey=x,u.selectKey=N,u.toggleAllKey=A,u.toggleKey=k,u.unselectAllKey=$,u.unselectKey=R,u.useSelectable=le,u.useVirtualList=K,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -13,6 +13,6 @@ export declare type DialogOptionsMap = {
13
13
  };
14
14
  export declare function DialogController(): {
15
15
  create: (options: DialogControllerOptions) => {
16
- close: () => void;
16
+ close: (id: string) => void;
17
17
  };
18
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazycatcloud/lzc-toolkit",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "lazycat ui toolkits",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
@@ -10,14 +10,14 @@
10
10
  "directories": {
11
11
  "test": "test"
12
12
  },
13
+ "access": "public",
13
14
  "types": "./dist/types/index.d.ts",
14
15
  "scripts": {
15
16
  "dev": "vite",
16
17
  "build": "vite build && vue-tsc --emitDeclarationOnly && mv dist/src dist/types",
17
18
  "test": "echo \"Error: no test specified\" && exit 1",
18
19
  "typecheck": "vue-tsc --noEmit",
19
- "prepublishOnly": "npm run build",
20
- "publish": "npm publish --access public"
20
+ "prepublishOnly": "npm run build"
21
21
  },
22
22
  "author": "",
23
23
  "license": "ISC",