@lazycatcloud/lzc-toolkit 0.0.43 → 0.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -319,7 +319,7 @@ const pt = Symbol(), ht = /* @__PURE__ */ N({
319
319
  e.visiable ? (T(), P("div", {
320
320
  key: 0,
321
321
  onClick: n,
322
- class: "modal absolute inset-0 bottom-0 flex bg-stone-900 bg-opacity-50 z-[999]"
322
+ class: "modal absolute left-0 right-0 top-0 bottom-0 flex bg-stone-900 bg-opacity-50 z-[999]"
323
323
  }, [
324
324
  R("div", {
325
325
  onClick: a[0] || (a[0] = De(() => {
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(h,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(h=typeof globalThis<"u"?globalThis:h||self,e(h.ui={},h.Vue))})(this,function(h,e){"use strict";var le;const B=typeof window<"u";B&&((le=window?.navigator)==null?void 0:le.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function j(t){return typeof t=="function"?t():e.unref(t)}function me(t,l){function n(...o){t(()=>l.apply(this,o),{fn:l,thisArg:this,args:o})}return n}function ge(t,l={}){let n,o;return s=>{const r=j(t),f=j(l.maxWait);if(n&&clearTimeout(n),r<=0||f!==void 0&&f<=0)return o&&(clearTimeout(o),o=null),s();f&&!o&&(o=setTimeout(()=>{n&&clearTimeout(n),o=null,s()},f)),n=setTimeout(()=>{o&&clearTimeout(o),o=null,s()},r)}}function ve(t){return t}function ye(t){return e.getCurrentScope()?(e.onScopeDispose(t),!0):!1}function ne(t,l=200,n={}){return me(ge(l,n),t)}function be(t,l=!0){e.getCurrentInstance()?e.onMounted(t):l?t():e.nextTick(t)}function oe(t){var l;const n=j(t);return(l=n?.$el)!=null?l:n}const _e=B?window:void 0;B&&window.document,B&&window.navigator,B&&window.location;function we(t,l=!1){const n=e.ref(),o=()=>n.value=Boolean(t());return o(),be(o,l),n}const K=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},V="__vueuse_ssr_handlers__";K[V]=K[V]||{},K[V];var re=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,Oe=(t,l)=>{var n={};for(var o in t)Se.call(t,o)&&l.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&re)for(var o of re(t))l.indexOf(o)<0&&Ee.call(t,o)&&(n[o]=t[o]);return n};function Te(t,l,n={}){const o=n,{window:i=_e}=o,s=Oe(o,["window"]);let r;const f=we(()=>i&&"ResizeObserver"in i),v=()=>{r&&(r.disconnect(),r=void 0)},m=e.watch(()=>oe(t),g=>{v(),f.value&&i&&g&&(r=new ResizeObserver(l),r.observe(g,s))},{immediate:!0,flush:"post"}),p=()=>{v(),m()};return ye(p),{isSupported:f,stop:p}}function Be(t,l={width:0,height:0},n={}){const{box:o="content-box"}=n,i=e.ref(l.width),s=e.ref(l.height);return Te(t,([r])=>{const f=o==="border-box"?r.borderBoxSize:o==="content-box"?r.contentBoxSize:r.devicePixelContentBoxSize;f?(i.value=f.reduce((v,{inlineSize:m})=>v+m,0),s.value=f.reduce((v,{blockSize:m})=>v+m,0)):(i.value=r.contentRect.width,s.value=r.contentRect.height)},n),e.watch(()=>oe(t),r=>{i.value=r?l.width:0,s.value=r?l.height:0}),{width:i,height:s}}var ie;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})(ie||(ie={}));var He=Object.defineProperty,ae=Object.getOwnPropertySymbols,Ie=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,se=(t,l,n)=>l in t?He(t,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[l]=n,Re=(t,l)=>{for(var n in l||(l={}))Ie.call(l,n)&&se(t,n,l[n]);if(ae)for(var n of ae(l))Ce.call(l,n)&&se(t,n,l[n]);return t};Re({linear:ve},{easeInSine:[.12,0,.39,0],easeOutSine:[.61,1,.88,1],easeInOutSine:[.37,0,.63,1],easeInQuad:[.11,0,.5,0],easeOutQuad:[.5,1,.89,1],easeInOutQuad:[.45,0,.55,1],easeInCubic:[.32,0,.67,0],easeOutCubic:[.33,1,.68,1],easeInOutCubic:[.65,0,.35,1],easeInQuart:[.5,0,.75,0],easeOutQuart:[.25,1,.5,1],easeInOutQuart:[.76,0,.24,1],easeInQuint:[.64,0,.78,0],easeOutQuint:[.22,1,.36,1],easeInOutQuint:[.83,0,.17,1],easeInExpo:[.7,0,.84,0],easeOutExpo:[.16,1,.3,1],easeInOutExpo:[.87,0,.13,1],easeInCirc:[.55,0,1,.45],easeOutCirc:[0,.55,.45,1],easeInOutCirc:[.85,0,.15,1],easeInBack:[.36,0,.66,-.56],easeOutBack:[.34,1.56,.64,1],easeInOutBack:[.68,-.6,.32,1.6]});function ce(t,l){const{scrollEndHook:n,itemHeight:o,overscan:i=5}=l,s=e.ref(null),r=Be(s),f=e.ref(!0),v=ne(G,100);let m;const p=e.shallowRef(t),g=e.ref(0),c=e.ref({start:0,end:10});let u=0;const E=e.ref([]),y=e.computed(()=>{let{sum:a,height:d}={sum:0,height:0};return p.value.map((S,w)=>(typeof o=="number"?d=o:d=o(w),a+=d,{height:d,sum:a}))}),Y=e.computed(()=>A(c.value.start)),O=e.computed(()=>typeof o=="number"?y.value.length*o:y.value[y.value.length-1]?.sum||0),I=e.computed(()=>{let a=E.value.length-i,d=Math.max(a-u,0);return E.value.slice(d,a)});e.onMounted(()=>{}),e.onUnmounted(()=>cancelAnimationFrame(m)),e.watch([r.width,r.height,p],([a,d])=>{(a||d)&&R()},{deep:!0}),e.watch(g,()=>{C(),v()});function C(){f.value=!1}function G(){f.value=!0,n?.()}function R(){cancelAnimationFrame(m),m=requestAnimationFrame(x)}function x(){if(s.value){g.value=s.value.scrollTop,u=H();let a=P(g.value),d=a+u+i;a=a-i,a=a<0?0:a,d=d>p.value.length?p.value.length:d,c.value={start:a,end:d},E.value=p.value.slice(a,d).map((S,w)=>({data:S,index:w+a}))}}function P(a){let d=0,S=y.value.length-1,w=-1;for(;d<=S;){const b=Math.floor((d+S)/2);y.value[b].sum>=a?(w=b,S=b-1):d=b+1}return Math.max(0,w)}function H(){let a=0,d=0,S=J();for(let w=S;w<y.value.length&&(a++,d+=y.value[w].height,!(d>=r.height.value));w++);return a}function A(a){if(typeof o=="number")return a*o;let d=y.value[a];return d?d.sum-d.height:0}function $(a){return y.value[a]||{sum:0,height:0}}function J(){let a=c.value.start;return a>=i&&(a+=i),a}function X(a){if(s.value){const d=$(a);s.value.scrollTop=d.sum-d.height,x()}}const Z=e.computed(()=>({style:{width:"100%",height:`${O.value}px`,pointerEvents:f.value?void 0:"none"}})),k=e.computed(()=>({style:{transform:`translate3d(0, ${Y.value}px, 0)`,"will-change":"transform"}})),ee={overflowY:"auto"};return{list:E,visiableList:I,getItemHeightData:$,getoffsetTopIndex:P,totalHeight:O,clientHeight:r.height,scrollTo:X,scrollTop:g,isScrollEnd:f,containerProps:{ref:s,onScroll:()=>{R()},style:ee},wrapperProps:Z,innerProps:k}}const F=Symbol(),D=Symbol(),M=Symbol(),N=Symbol(),z=Symbol(),Q=Symbol(),U=Symbol(),W=Symbol(),q=Symbol();function xe(){const{voidFn:t,boolFn:l,boolRef:n,arrayRef:o}={voidFn:u=>{},boolFn:u=>!1,boolRef:e.computed(()=>!1),arrayRef:e.computed(()=>[])},i=e.inject(N,o),s=e.inject(M,l),r=e.inject(W,n),f=e.inject(D,t),v=e.inject(F,t),m=e.inject(z,t),p=e.inject(Q,t),g=e.inject(U,t),c=e.inject(q,t);return{selected:i,isSelected:s,isAllSelected:r,toggle:f,toggleAll:v,select:m,selectAll:p,unselect:g,unselectAll:c}}function Pe(t,l){const n=e.ref({}),o=e.computed(()=>t.value.filter(c=>n.value[c[l]])),i=e.computed(()=>o.value.length!=0&&Object.keys(n.value).length==t.value.length);function s(){t.value.forEach(c=>{n.value[c[l]]=!0})}function r(){n.value={}}function f(c){c.forEach(u=>{n.value[u[l]]||(n.value[u[l]]=!0)})}function v(c){c.forEach(u=>{n.value[u[l]]&&delete n.value[u[l]]})}function m(c){return!!n.value[c[l]]}function p(c){c.forEach(u=>{m(u)?delete n.value[u[l]]:n.value[u[l]]=!0})}function g(){i.value?r():s()}return e.provide(F,g),e.provide(D,p),e.provide(M,m),e.provide(N,o),e.provide(z,f),e.provide(Q,s),e.provide(U,v),e.provide(W,i),e.provide(q,r),{selected:o,select:f,selectAll:s,unselect:v,unselectAll:r,toggle:p,toggleAll:g,isSelected:m,isAllSelected:i}}const ue=Symbol(),Ae=e.defineComponent({__name:"Dialog",props:{visiable:{type:Boolean,default:!1},closeOnClickOverlay:{type:Boolean,default:!0},dialogClass:{default:""}},emits:["update:visiable"],setup(t,{emit:l}){const n=t,o=()=>{n.closeOnClickOverlay&&l("update:visiable",!1)};return e.provide(ue,()=>l("update:visiable",!1)),(i,s)=>(e.openBlock(),e.createBlock(e.Transition,{name:"modal"},{default:e.withCtx(()=>[t.visiable?(e.openBlock(),e.createElementBlock("div",{key:0,onClick:o,class:"modal absolute inset-0 bottom-0 flex bg-stone-900 bg-opacity-50 z-[999]"},[e.createElementVNode("div",{onClick:s[0]||(s[0]=e.withModifiers(()=>{},["stop"])),class:e.normalizeClass(["dialog m-auto flex flex-col",t.dialogClass])},[e.renderSlot(i.$slots,"default")],2)])):e.createCommentVNode("",!0)]),_:3}))}});function $e(t){function l(n,o){const i=document.createElement("div"),s={setup(){return()=>e.h(Ae,{visiable:!0,"onUpdate:visiable":()=>{i?.remove()},...t},{default:()=>e.h(n,o)})}};return document.body.appendChild(i),e.render(e.h(s),i),{close:()=>i?.remove()}}return{create:l}}const ke=["xlink:href","fill","color"],Le=e.defineComponent({__name:"SvgIcon",props:{name:null,prefix:{default:"icon"},color:{default:"#FFF"},width:null,height:null},setup(t){const l=t,n=e.computed(()=>`#${l.prefix}-${l.name}`),o=e.computed(()=>({width:`${l.width??l.height}px`,height:`${l.height??l.width}px`,aspectRatio:l.width&&l.height?void 0:"1/1"}));return(i,s)=>(e.openBlock(),e.createElementBlock("svg",{"aria-hidden":"",style:e.normalizeStyle(e.unref(o))},[e.createElementVNode("use",{"xlink:href":e.unref(n),fill:t.color,color:t.color},null,8,ke)],4))}});function je(t){const{containerEl:l,sliderEl:n,autoHeight:o,performance:i={},maxHeightRatio:s=.9}=t,r=e.ref(!0),f=ne(A,100);let v,m="";const p=e.ref(0),g=e.ref(0),c=e.ref(0),u=e.ref({top:0,scrollTop:0,scrollHeight:0,clientHeight:0}),E=e.ref({clientHeight:0}),y=e.computed(()=>!!g.value),Y=e.computed(()=>u.value.scrollHeight>u.value.clientHeight),O=e.computed(()=>u.value.clientHeight-E.value.clientHeight),I=e.computed(()=>u.value.scrollHeight-u.value.clientHeight),C=e.computed(()=>Math.max(u.value.clientHeight/u.value.scrollHeight,.05)),G=e.computed(()=>C.value>s?0:C.value*u.value.clientHeight),R=e.computed(()=>({willChange:"transform",transform:`translate3d(0,${c.value}px,0)`,height:o?`${G.value}px`:void 0}));function x(b){H(),g.value=b.clientY-n.value.getBoundingClientRect().top||1,m=getComputedStyle(l.value).scrollBehavior,m==="smooth"&&(l.value.style.scrollBehavior="unset")}function P(){l.value.style.scrollBehavior=m,g.value=0,f()}function H(){r.value=!1}function A(){y.value||(r.value=!0)}function $(b){if(!y.value)return;let _=b.clientY-u.value.top-g.value;_<0?c.value=0:_>=O.value?c.value=O.value:c.value=_,l.value.scrollTo({top:c.value/O.value*I.value})}function J(){y.value||X()}function X(){cancelAnimationFrame(v),v=requestAnimationFrame(Z)}function Z(){l.value&&(p.value=i.scrollTop?.value??l.value.scrollTop,c.value=p.value/I.value*O.value)}function k(b){let _="addEventListener";b==="add"?_="addEventListener":_="removeEventListener",n.value?.[_]("pointerdown",x,{passive:!0}),window[_]("pointermove",$,{passive:!0}),window[_]("pointerup",P,{passive:!0})}const ee=new MutationObserver(b=>{b.map(L=>L.oldValue).join().includes("height")&&a()});function a(){u.value.top=l.value?.getBoundingClientRect().top??0,u.value.scrollHeight=l.value?.scrollHeight??0,u.value.clientHeight=l.value?.clientHeight??0}function d(){H(),setTimeout(()=>{E.value.clientHeight=n.value?.clientHeight??0,A()},150)}function S(b,_,L="dynamic-styles"){let T=document.getElementById(L);T||(T=document.createElement("style"),T.id=L,document.head.appendChild(T));const fe=T.sheet.cssRules,pe=fe.length,Qe=`${b} { ${_} }`;for(let te=0;te<pe;te++){const he=fe[te];if(he.selectorText===b&&he.style.cssText===_)return}T.sheet.insertRule(Qe,pe)}function w(){l.value&&n.value?(S(".hide-scrollbar","scrollbar-width: none; -ms-overflow-style: none;"),S(".hide-scrollbar::-webkit-scrollbar","display: none"),l.value.addEventListener("scroll",J,{passive:!0}),k("add"),ee.observe(l.value,{subtree:!0,attributeOldValue:!0,attributeFilter:["style"]}),setTimeout(()=>{a()},100),d()):console.error("useScrollBar:","\u521D\u59CB\u5316\u5931\u8D25!",{containerEl:l,sliderEl:n})}return e.watch(p,()=>{H(),f()}),{isScrollEnd:r,isDragSlider:y,offsetTop:c,scrollTop:p,scrollable:Y,sliderPos:R,init:w,modifySliderEventListener:k}}const Ke=(t=>(e.pushScopeId("data-v-edec7292"),t=t(),e.popScopeId(),t))(()=>e.createElementVNode("div",{class:"default-slider"},null,-1)),Ve=e.defineComponent({__name:"ScrollBar",props:{containerEl:null,autoHide:{type:Boolean},autoHeight:{type:Boolean},performance:null},setup(t,{expose:l}){const n=t,o=!!e.useSlots().default,i=e.ref(null),s=e.computed(()=>n.containerEl),r=je({containerEl:s,sliderEl:i,autoHeight:o?n.autoHeight:!0,performance:n.performance}),{scrollable:f,isScrollEnd:v,sliderPos:m}=r,p=e.ref(!1),g=n.autoHide?e.computed(()=>p.value||!v.value):e.computed(()=>f.value);e.onMounted(()=>{e.nextTick(()=>{r.init()})}),e.onUnmounted(()=>{r.modifySliderEventListener("remove")});function c(){p.value=!0}function u(){p.value=!1}return l({uScrollBarReturn:r}),(E,y)=>(e.openBlock(),e.createBlock(e.Transition,null,{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{ref_key:"sliderRef",ref:i,class:"slider-wrapper",onMouseenter:c,onMouseleave:u,style:e.normalizeStyle(e.unref(m))},[e.renderSlot(E.$slots,"default",{},()=>[Ke],!0)],36),[[e.vShow,e.unref(g)]])]),_:3}))}}),qe="",de=(t,l)=>{const n=t.__vccOpts||t;for(const[o,i]of l)n[o]=i;return n},Fe=de(Ve,[["__scopeId","data-v-edec7292"]]),De={class:"virtualListWrapper"},Me={inheritAttrs:!1},Ne=e.defineComponent({...Me,__name:"VirtualList",props:{data:null,itemHeight:null,overscan:{default:10}},emits:["scrollEnd"],setup(t,{expose:l,emit:n}){const o=t,i=ce(e.toRef(o,"data"),{itemHeight:p=>o.itemHeight(o.data[p]),overscan:o.overscan,scrollEndHook:()=>{n("scrollEnd")}}),{list:s,containerProps:r,wrapperProps:f,innerProps:v,getItemHeightData:m}=i;return l({vListReturn:i}),(p,g)=>(e.openBlock(),e.createElementBlock("div",De,[e.createElementVNode("div",e.mergeProps({onScrollPassive:g[0]||(g[0]=(...c)=>e.unref(r).onScroll&&e.unref(r).onScroll(...c)),ref:e.unref(r).ref,class:"virtualList"},p.$attrs),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(f))),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(v))),[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),({index:c,data:u})=>(e.openBlock(),e.createElementBlock("div",{key:c,style:e.normalizeStyle({height:`${e.unref(m)(c).height}px`,display:"flex"})},[e.renderSlot(p.$slots,"default",{data:u,index:c},void 0,!0)],4))),128))],16)],16)],16)]))}}),Ye="",ze=de(Ne,[["__scopeId","data-v-4ba97cce"]]);h.ScrollBar=Fe,h.SvgIcon=Le,h.VirtualList=ze,h.allSelectedKey=N,h.closeDialogKey=ue,h.dialogController=$e,h.isAllSelectedKey=W,h.isSelectedKey=M,h.selectAllKey=Q,h.selectKey=z,h.toggleAllKey=F,h.toggleKey=D,h.unselectAllKey=q,h.unselectKey=U,h.useSelectable=Pe,h.useSelectableInjectors=xe,h.useVirtualList=ce,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(h,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(h=typeof globalThis<"u"?globalThis:h||self,e(h.ui={},h.Vue))})(this,function(h,e){"use strict";var le;const B=typeof window<"u";B&&((le=window?.navigator)==null?void 0:le.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function j(t){return typeof t=="function"?t():e.unref(t)}function me(t,l){function n(...o){t(()=>l.apply(this,o),{fn:l,thisArg:this,args:o})}return n}function ge(t,l={}){let n,o;return s=>{const r=j(t),f=j(l.maxWait);if(n&&clearTimeout(n),r<=0||f!==void 0&&f<=0)return o&&(clearTimeout(o),o=null),s();f&&!o&&(o=setTimeout(()=>{n&&clearTimeout(n),o=null,s()},f)),n=setTimeout(()=>{o&&clearTimeout(o),o=null,s()},r)}}function ve(t){return t}function ye(t){return e.getCurrentScope()?(e.onScopeDispose(t),!0):!1}function ne(t,l=200,n={}){return me(ge(l,n),t)}function be(t,l=!0){e.getCurrentInstance()?e.onMounted(t):l?t():e.nextTick(t)}function oe(t){var l;const n=j(t);return(l=n?.$el)!=null?l:n}const _e=B?window:void 0;B&&window.document,B&&window.navigator,B&&window.location;function we(t,l=!1){const n=e.ref(),o=()=>n.value=Boolean(t());return o(),be(o,l),n}const K=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},V="__vueuse_ssr_handlers__";K[V]=K[V]||{},K[V];var re=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,Oe=(t,l)=>{var n={};for(var o in t)Se.call(t,o)&&l.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&re)for(var o of re(t))l.indexOf(o)<0&&Ee.call(t,o)&&(n[o]=t[o]);return n};function Te(t,l,n={}){const o=n,{window:i=_e}=o,s=Oe(o,["window"]);let r;const f=we(()=>i&&"ResizeObserver"in i),v=()=>{r&&(r.disconnect(),r=void 0)},m=e.watch(()=>oe(t),g=>{v(),f.value&&i&&g&&(r=new ResizeObserver(l),r.observe(g,s))},{immediate:!0,flush:"post"}),p=()=>{v(),m()};return ye(p),{isSupported:f,stop:p}}function Be(t,l={width:0,height:0},n={}){const{box:o="content-box"}=n,i=e.ref(l.width),s=e.ref(l.height);return Te(t,([r])=>{const f=o==="border-box"?r.borderBoxSize:o==="content-box"?r.contentBoxSize:r.devicePixelContentBoxSize;f?(i.value=f.reduce((v,{inlineSize:m})=>v+m,0),s.value=f.reduce((v,{blockSize:m})=>v+m,0)):(i.value=r.contentRect.width,s.value=r.contentRect.height)},n),e.watch(()=>oe(t),r=>{i.value=r?l.width:0,s.value=r?l.height:0}),{width:i,height:s}}var ie;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})(ie||(ie={}));var He=Object.defineProperty,ae=Object.getOwnPropertySymbols,Ie=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,se=(t,l,n)=>l in t?He(t,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[l]=n,Re=(t,l)=>{for(var n in l||(l={}))Ie.call(l,n)&&se(t,n,l[n]);if(ae)for(var n of ae(l))Ce.call(l,n)&&se(t,n,l[n]);return t};Re({linear:ve},{easeInSine:[.12,0,.39,0],easeOutSine:[.61,1,.88,1],easeInOutSine:[.37,0,.63,1],easeInQuad:[.11,0,.5,0],easeOutQuad:[.5,1,.89,1],easeInOutQuad:[.45,0,.55,1],easeInCubic:[.32,0,.67,0],easeOutCubic:[.33,1,.68,1],easeInOutCubic:[.65,0,.35,1],easeInQuart:[.5,0,.75,0],easeOutQuart:[.25,1,.5,1],easeInOutQuart:[.76,0,.24,1],easeInQuint:[.64,0,.78,0],easeOutQuint:[.22,1,.36,1],easeInOutQuint:[.83,0,.17,1],easeInExpo:[.7,0,.84,0],easeOutExpo:[.16,1,.3,1],easeInOutExpo:[.87,0,.13,1],easeInCirc:[.55,0,1,.45],easeOutCirc:[0,.55,.45,1],easeInOutCirc:[.85,0,.15,1],easeInBack:[.36,0,.66,-.56],easeOutBack:[.34,1.56,.64,1],easeInOutBack:[.68,-.6,.32,1.6]});function ce(t,l){const{scrollEndHook:n,itemHeight:o,overscan:i=5}=l,s=e.ref(null),r=Be(s),f=e.ref(!0),v=ne(G,100);let m;const p=e.shallowRef(t),g=e.ref(0),c=e.ref({start:0,end:10});let u=0;const E=e.ref([]),y=e.computed(()=>{let{sum:a,height:d}={sum:0,height:0};return p.value.map((S,w)=>(typeof o=="number"?d=o:d=o(w),a+=d,{height:d,sum:a}))}),Y=e.computed(()=>A(c.value.start)),O=e.computed(()=>typeof o=="number"?y.value.length*o:y.value[y.value.length-1]?.sum||0),I=e.computed(()=>{let a=E.value.length-i,d=Math.max(a-u,0);return E.value.slice(d,a)});e.onMounted(()=>{}),e.onUnmounted(()=>cancelAnimationFrame(m)),e.watch([r.width,r.height,p],([a,d])=>{(a||d)&&R()},{deep:!0}),e.watch(g,()=>{C(),v()});function C(){f.value=!1}function G(){f.value=!0,n?.()}function R(){cancelAnimationFrame(m),m=requestAnimationFrame(x)}function x(){if(s.value){g.value=s.value.scrollTop,u=H();let a=P(g.value),d=a+u+i;a=a-i,a=a<0?0:a,d=d>p.value.length?p.value.length:d,c.value={start:a,end:d},E.value=p.value.slice(a,d).map((S,w)=>({data:S,index:w+a}))}}function P(a){let d=0,S=y.value.length-1,w=-1;for(;d<=S;){const b=Math.floor((d+S)/2);y.value[b].sum>=a?(w=b,S=b-1):d=b+1}return Math.max(0,w)}function H(){let a=0,d=0,S=J();for(let w=S;w<y.value.length&&(a++,d+=y.value[w].height,!(d>=r.height.value));w++);return a}function A(a){if(typeof o=="number")return a*o;let d=y.value[a];return d?d.sum-d.height:0}function $(a){return y.value[a]||{sum:0,height:0}}function J(){let a=c.value.start;return a>=i&&(a+=i),a}function X(a){if(s.value){const d=$(a);s.value.scrollTop=d.sum-d.height,x()}}const Z=e.computed(()=>({style:{width:"100%",height:`${O.value}px`,pointerEvents:f.value?void 0:"none"}})),k=e.computed(()=>({style:{transform:`translate3d(0, ${Y.value}px, 0)`,"will-change":"transform"}})),ee={overflowY:"auto"};return{list:E,visiableList:I,getItemHeightData:$,getoffsetTopIndex:P,totalHeight:O,clientHeight:r.height,scrollTo:X,scrollTop:g,isScrollEnd:f,containerProps:{ref:s,onScroll:()=>{R()},style:ee},wrapperProps:Z,innerProps:k}}const F=Symbol(),D=Symbol(),M=Symbol(),N=Symbol(),z=Symbol(),Q=Symbol(),U=Symbol(),W=Symbol(),q=Symbol();function xe(){const{voidFn:t,boolFn:l,boolRef:n,arrayRef:o}={voidFn:u=>{},boolFn:u=>!1,boolRef:e.computed(()=>!1),arrayRef:e.computed(()=>[])},i=e.inject(N,o),s=e.inject(M,l),r=e.inject(W,n),f=e.inject(D,t),v=e.inject(F,t),m=e.inject(z,t),p=e.inject(Q,t),g=e.inject(U,t),c=e.inject(q,t);return{selected:i,isSelected:s,isAllSelected:r,toggle:f,toggleAll:v,select:m,selectAll:p,unselect:g,unselectAll:c}}function Pe(t,l){const n=e.ref({}),o=e.computed(()=>t.value.filter(c=>n.value[c[l]])),i=e.computed(()=>o.value.length!=0&&Object.keys(n.value).length==t.value.length);function s(){t.value.forEach(c=>{n.value[c[l]]=!0})}function r(){n.value={}}function f(c){c.forEach(u=>{n.value[u[l]]||(n.value[u[l]]=!0)})}function v(c){c.forEach(u=>{n.value[u[l]]&&delete n.value[u[l]]})}function m(c){return!!n.value[c[l]]}function p(c){c.forEach(u=>{m(u)?delete n.value[u[l]]:n.value[u[l]]=!0})}function g(){i.value?r():s()}return e.provide(F,g),e.provide(D,p),e.provide(M,m),e.provide(N,o),e.provide(z,f),e.provide(Q,s),e.provide(U,v),e.provide(W,i),e.provide(q,r),{selected:o,select:f,selectAll:s,unselect:v,unselectAll:r,toggle:p,toggleAll:g,isSelected:m,isAllSelected:i}}const ue=Symbol(),Ae=e.defineComponent({__name:"Dialog",props:{visiable:{type:Boolean,default:!1},closeOnClickOverlay:{type:Boolean,default:!0},dialogClass:{default:""}},emits:["update:visiable"],setup(t,{emit:l}){const n=t,o=()=>{n.closeOnClickOverlay&&l("update:visiable",!1)};return e.provide(ue,()=>l("update:visiable",!1)),(i,s)=>(e.openBlock(),e.createBlock(e.Transition,{name:"modal"},{default:e.withCtx(()=>[t.visiable?(e.openBlock(),e.createElementBlock("div",{key:0,onClick:o,class:"modal absolute left-0 right-0 top-0 bottom-0 flex bg-stone-900 bg-opacity-50 z-[999]"},[e.createElementVNode("div",{onClick:s[0]||(s[0]=e.withModifiers(()=>{},["stop"])),class:e.normalizeClass(["dialog m-auto flex flex-col",t.dialogClass])},[e.renderSlot(i.$slots,"default")],2)])):e.createCommentVNode("",!0)]),_:3}))}});function $e(t){function l(n,o){const i=document.createElement("div"),s={setup(){return()=>e.h(Ae,{visiable:!0,"onUpdate:visiable":()=>{i?.remove()},...t},{default:()=>e.h(n,o)})}};return document.body.appendChild(i),e.render(e.h(s),i),{close:()=>i?.remove()}}return{create:l}}const ke=["xlink:href","fill","color"],Le=e.defineComponent({__name:"SvgIcon",props:{name:null,prefix:{default:"icon"},color:{default:"#FFF"},width:null,height:null},setup(t){const l=t,n=e.computed(()=>`#${l.prefix}-${l.name}`),o=e.computed(()=>({width:`${l.width??l.height}px`,height:`${l.height??l.width}px`,aspectRatio:l.width&&l.height?void 0:"1/1"}));return(i,s)=>(e.openBlock(),e.createElementBlock("svg",{"aria-hidden":"",style:e.normalizeStyle(e.unref(o))},[e.createElementVNode("use",{"xlink:href":e.unref(n),fill:t.color,color:t.color},null,8,ke)],4))}});function je(t){const{containerEl:l,sliderEl:n,autoHeight:o,performance:i={},maxHeightRatio:s=.9}=t,r=e.ref(!0),f=ne(A,100);let v,m="";const p=e.ref(0),g=e.ref(0),c=e.ref(0),u=e.ref({top:0,scrollTop:0,scrollHeight:0,clientHeight:0}),E=e.ref({clientHeight:0}),y=e.computed(()=>!!g.value),Y=e.computed(()=>u.value.scrollHeight>u.value.clientHeight),O=e.computed(()=>u.value.clientHeight-E.value.clientHeight),I=e.computed(()=>u.value.scrollHeight-u.value.clientHeight),C=e.computed(()=>Math.max(u.value.clientHeight/u.value.scrollHeight,.05)),G=e.computed(()=>C.value>s?0:C.value*u.value.clientHeight),R=e.computed(()=>({willChange:"transform",transform:`translate3d(0,${c.value}px,0)`,height:o?`${G.value}px`:void 0}));function x(b){H(),g.value=b.clientY-n.value.getBoundingClientRect().top||1,m=getComputedStyle(l.value).scrollBehavior,m==="smooth"&&(l.value.style.scrollBehavior="unset")}function P(){l.value.style.scrollBehavior=m,g.value=0,f()}function H(){r.value=!1}function A(){y.value||(r.value=!0)}function $(b){if(!y.value)return;let _=b.clientY-u.value.top-g.value;_<0?c.value=0:_>=O.value?c.value=O.value:c.value=_,l.value.scrollTo({top:c.value/O.value*I.value})}function J(){y.value||X()}function X(){cancelAnimationFrame(v),v=requestAnimationFrame(Z)}function Z(){l.value&&(p.value=i.scrollTop?.value??l.value.scrollTop,c.value=p.value/I.value*O.value)}function k(b){let _="addEventListener";b==="add"?_="addEventListener":_="removeEventListener",n.value?.[_]("pointerdown",x,{passive:!0}),window[_]("pointermove",$,{passive:!0}),window[_]("pointerup",P,{passive:!0})}const ee=new MutationObserver(b=>{b.map(L=>L.oldValue).join().includes("height")&&a()});function a(){u.value.top=l.value?.getBoundingClientRect().top??0,u.value.scrollHeight=l.value?.scrollHeight??0,u.value.clientHeight=l.value?.clientHeight??0}function d(){H(),setTimeout(()=>{E.value.clientHeight=n.value?.clientHeight??0,A()},150)}function S(b,_,L="dynamic-styles"){let T=document.getElementById(L);T||(T=document.createElement("style"),T.id=L,document.head.appendChild(T));const fe=T.sheet.cssRules,pe=fe.length,Qe=`${b} { ${_} }`;for(let te=0;te<pe;te++){const he=fe[te];if(he.selectorText===b&&he.style.cssText===_)return}T.sheet.insertRule(Qe,pe)}function w(){l.value&&n.value?(S(".hide-scrollbar","scrollbar-width: none; -ms-overflow-style: none;"),S(".hide-scrollbar::-webkit-scrollbar","display: none"),l.value.addEventListener("scroll",J,{passive:!0}),k("add"),ee.observe(l.value,{subtree:!0,attributeOldValue:!0,attributeFilter:["style"]}),setTimeout(()=>{a()},100),d()):console.error("useScrollBar:","\u521D\u59CB\u5316\u5931\u8D25!",{containerEl:l,sliderEl:n})}return e.watch(p,()=>{H(),f()}),{isScrollEnd:r,isDragSlider:y,offsetTop:c,scrollTop:p,scrollable:Y,sliderPos:R,init:w,modifySliderEventListener:k}}const Ke=(t=>(e.pushScopeId("data-v-edec7292"),t=t(),e.popScopeId(),t))(()=>e.createElementVNode("div",{class:"default-slider"},null,-1)),Ve=e.defineComponent({__name:"ScrollBar",props:{containerEl:null,autoHide:{type:Boolean},autoHeight:{type:Boolean},performance:null},setup(t,{expose:l}){const n=t,o=!!e.useSlots().default,i=e.ref(null),s=e.computed(()=>n.containerEl),r=je({containerEl:s,sliderEl:i,autoHeight:o?n.autoHeight:!0,performance:n.performance}),{scrollable:f,isScrollEnd:v,sliderPos:m}=r,p=e.ref(!1),g=n.autoHide?e.computed(()=>p.value||!v.value):e.computed(()=>f.value);e.onMounted(()=>{e.nextTick(()=>{r.init()})}),e.onUnmounted(()=>{r.modifySliderEventListener("remove")});function c(){p.value=!0}function u(){p.value=!1}return l({uScrollBarReturn:r}),(E,y)=>(e.openBlock(),e.createBlock(e.Transition,null,{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{ref_key:"sliderRef",ref:i,class:"slider-wrapper",onMouseenter:c,onMouseleave:u,style:e.normalizeStyle(e.unref(m))},[e.renderSlot(E.$slots,"default",{},()=>[Ke],!0)],36),[[e.vShow,e.unref(g)]])]),_:3}))}}),qe="",de=(t,l)=>{const n=t.__vccOpts||t;for(const[o,i]of l)n[o]=i;return n},Fe=de(Ve,[["__scopeId","data-v-edec7292"]]),De={class:"virtualListWrapper"},Me={inheritAttrs:!1},Ne=e.defineComponent({...Me,__name:"VirtualList",props:{data:null,itemHeight:null,overscan:{default:10}},emits:["scrollEnd"],setup(t,{expose:l,emit:n}){const o=t,i=ce(e.toRef(o,"data"),{itemHeight:p=>o.itemHeight(o.data[p]),overscan:o.overscan,scrollEndHook:()=>{n("scrollEnd")}}),{list:s,containerProps:r,wrapperProps:f,innerProps:v,getItemHeightData:m}=i;return l({vListReturn:i}),(p,g)=>(e.openBlock(),e.createElementBlock("div",De,[e.createElementVNode("div",e.mergeProps({onScrollPassive:g[0]||(g[0]=(...c)=>e.unref(r).onScroll&&e.unref(r).onScroll(...c)),ref:e.unref(r).ref,class:"virtualList"},p.$attrs),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(f))),[e.createElementVNode("div",e.normalizeProps(e.guardReactiveProps(e.unref(v))),[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),({index:c,data:u})=>(e.openBlock(),e.createElementBlock("div",{key:c,style:e.normalizeStyle({height:`${e.unref(m)(c).height}px`,display:"flex"})},[e.renderSlot(p.$slots,"default",{data:u,index:c},void 0,!0)],4))),128))],16)],16)],16)]))}}),Ye="",ze=de(Ne,[["__scopeId","data-v-4ba97cce"]]);h.ScrollBar=Fe,h.SvgIcon=Le,h.VirtualList=ze,h.allSelectedKey=N,h.closeDialogKey=ue,h.dialogController=$e,h.isAllSelectedKey=W,h.isSelectedKey=M,h.selectAllKey=Q,h.selectKey=z,h.toggleAllKey=F,h.toggleKey=D,h.unselectAllKey=q,h.unselectKey=U,h.useSelectable=Pe,h.useSelectableInjectors=xe,h.useVirtualList=ce,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazycatcloud/lzc-toolkit",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "description": "lazycat ui toolkits",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",