@soei/flyweight 0.3.0 → 0.3.1

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/Flyweight.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@soei/util"),l=require("vue");let I=/(\d+|[+\-\*/]|%)/g,N={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t,s)=>parseFloat(e)/100*s},C=(e,t)=>{let s;if(s=c.runer("match",e,I)){let h=s.length,r,n=0,i,o=[];for(;h--;)n=s.shift(),n in N?(r&&o.push(r),n==="%"&&(o.length=2),i=n):+n&&o.push(+n),o.length==2&&(o.push(t),r=N[i].apply(null,o),o.length=0);+r||(r=+o.pop()),e=r>>0}return e},B=e=>(e+"").replace(/\w+\((.*)\)/g,"$1").replace(/(?=\s+|^)(\d+(\.\d+)*)(?!(?:\.)*\d|%|\w)/g,"$1px");const E=(e,t)=>{const s=e.__vccOpts||e;for(const[h,r]of t)s[h]=r;return s};let L=e=>e==null||e==null,V=(...e)=>{console.info("::::FLYWEIGHT",...e)};const W={name:"Flyweight",props:{flys:{type:Array,default:()=>[]},width:{type:Number,default:0},height:{type:Number,default:100},offset:{type:Array,default:()=>[0,0]},lazy:{type:Number,default:100},view:{type:Object,default:()=>({id:0})},index:{type:Number,default:0},top:{type:Number,default:!1},left:{type:Number,default:!1},auto:{type:[Boolean,String],default:!1},space:{type:Object,default:()=>null},padding:{type:Boolean,default:!1}},computed:{flyweight(){return this.$refs.flyweight||""}},data(){return{flyweights:[],actice:!1,Size:null,column:1,row:1,expand:10,count:0,task:[],realW:0,realH:0}},watch:{flys(e){this.count=e.length,this.rebuild();let t=this.task.shift();t&&this.$nextTick(()=>{this.setview(t)})},view:{handler(e){this.setview(e)},immediate:!0,deep:!0},index(e){this.setindex(e)},top(e){this.flyweight.scrollTop=e},left(e){this.flyweight.scrollLeft=e}},mounted(){this.flyweights=[],this.$set||(this.$set=(e,t,s)=>{e[t]=s}),this.setindex(this.index);try{new ResizeObserver(()=>{this.rebuild(),this.$emit("resize")}).observe(this.flyweight)}catch(e){V(e)}this.scrollx=c.runer("hasAttribute",this.flyweight,"scroll-x"),this.BoxRule="clientHeight=>height,clientWidth=>width",this.direction=this.scrollx?"scrollLeft":"scrollTop"},methods:{exec:B,trigger(e,t){this.lazyrun(()=>{c.isArray(e)||(e=[[e,t]]),c.each(e,(s,h)=>{this.$emit(h[0],L(h[1])?!0:h[1])})})},cheackflys(e){if(!this.flys.length)return e&&this.task.push(e),!0},setview(e){c.runer([this.cheackflys,t=>{t=t||{};let s=t.index||c.each(this.flys,(h,r,n,i)=>{if(r[n]==i)return h},t.picker,t.id);L(s)||this.setindex(s)}],this,e)},setindex(e){c.runer([this.cheackflys,({index:t})=>{this.selectIndex=t,this.$nextTick(()=>{let s=t/this.column>>0,h=this.expand;(this.flyweight[this.direction]/h>>0)+this.row-s-1>0||(this.flyweight[this.direction]=s*h,this.scroll())})}],this,{index:e})},lazyrun(e,t){clearTimeout(this.time),this.time=setTimeout(()=>{c.runer(e)},t||this.lazy)},run(e){let t=[],s=c.runer(this.direction,e.target),h={offset:s,top:s,width:this.realW,height:this.realH,index:s/this.expand>>0};c.merge(h,this.space),e.from||t.push(["onscroll",h]);let r=!1;c.each(this.flyweights,(n,i,o,d,f,u,p,g,a)=>{if(o=n/f>>0,g=o+d*(+(o<u%d)+(u/d>>0)),a=g*f+n%f,a>=this.count){r||(t.push(["onend"]),r=!0);return}i.index=g,i.i=a,i.data=this.flys[a];let y=[g*this.expand+i.x,i.space];p&&y.reverse(),i.top=y[0],i.left=y[1]},null,this.row,this.column,h.index,this.scrollx),this.trigger(t),t=null},scroll(e){this.run(e||{target:this.flyweight,from:"space"})},rebuild(){let e=this.count||this.flys.length,t=this.flyweights;if(!e)return t.length=e;this.count=e;let s=this.scrollx,h=this.flyweight,r=c.picker(h,this.BoxRule);this.$nextTick(()=>{let n=/true/.test(this.auto),[i,o]=this.offset,d=r.width,f=r.height,u=(C(this.width,d)||d)+i,p=C(this.height,f)+o,g=[d/u>>0||1,f/p>>0||1];s&&g.reverse();let[a,y]=g,_=this.padding,S,k=0,m,b;s?(m=u,u-=i,b=w=>w*(p-o)+(w+1)*o):(n?(u=(d-i*(a+2*_-1))/a,S=!_*i,k=_*i):(S=0,k=(d%u+i*a)/(a+1)>>0,u-=i),b=w=>w*(u+S)+(w+1)*k,m=p),this.row=y+2,this.column=a,this.realH=p-o,this.realW=u,this.expand=m,this.Size=Math.ceil(e/a)*m;let T=Math.min(e,a*this.row),x=T-1,z;for(;T-- >0;)z=x-T,this.$set(t,z,{x:i,y:o,width:u,height:p-o,space:b(z%a),data:{}});t.length=x+1;let v=[];f/m>x/a&&v.push(["onend"]),this.flyweight&&(this.flyweight[this.direction]=0),this.$nextTick(()=>{this.setindex(this.selectIndex||0),this.scroll()}),v.push(["update:space",{row:(x/a>>0)+1,column:a,showrow:this.row,showcolumn:this.column}]),this.trigger(v)})}}},j={class:"flyweight-all"};function M(e,t,s,h,r,n){return l.openBlock(),l.createElementBlock("div",{ref:"flyweight",class:l.normalizeClass(["flyweight",{"flyweight-active":r.actice}]),style:l.normalizeStyle({"--width":n.exec(r.realW),"--height":n.exec(r.realH),"--flyweight-content":n.exec(r.Size)}),onScroll:t[0]||(t[0]=(...i)=>n.scroll&&n.scroll(...i))},[l.createElementVNode("div",j,[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(r.flyweights,(i,o)=>(l.openBlock(),l.createElementBlock("div",{key:o,style:l.normalizeStyle({top:i.top+"px",left:i.left+"px"})},[l.renderSlot(e.$slots,"default",l.mergeProps({ref_for:!0},i),void 0,!0)],4))),128))]),r.flyweights.length?l.renderSlot(e.$slots,"end",{key:0},void 0,!0):l.createCommentVNode("",!0)],38)}const F=E(W,[["render",M],["__scopeId","data-v-8f29f044"]]);function $(e,t){return t&&(e=e.replace(/[a-z]/g,"")),e.toLowerCase()}let H={close:{handler(e){this.change(e)},deep:!0},offset:{handler(e){this.margin(e)},deep:!0}},P=["BackGround","BordeR","Height","Width","Top","Right","Bottom","Left"],O={};c.each(P,(e,t,s)=>{e=$(t),O["--"+$(t,!0)]=e,s[e]=function(){this.trigger++}},H);const q={name:"Card",props:{offset:{type:[String,Array],default:()=>[0,0,0,0]},background:{type:String,default:""},border:{type:String,default:"1px"},height:{type:String,default:"100%"},width:{type:String,default:"100%"},show:{type:String,default:""},close:{type:Object,default:null},title:{type:String,default:""}},data(){return{closecss:{},trigger:0,default:{top:"0px",right:"0px",bottom:"0px",left:"0px",height:"100%",width:"100%",background:"",border:"1px"}}},computed:{style(){return this.tr()}},watch:H,methods:{exec:B,isEmpty:c.isEmpty,isSimplyType:c.isSimplyType,tr(){let e={};return this.margin(this.offset),c.each(O,(t,s)=>{this.css(e,t,s)}),e},tolower:$,css(e,t,s){let h=this[s]||this.default[s];!h||this.default[s]==h||(e[t]=B(h))},change(e){c.isSimplyType(e)||(this.closecss=c.picker(e,"color=>--s-card-close-color,*"))},margin(e){c.merge(this,c.picker(c.isString(e)?e.split(/\s*(?:,|\s+)\s*/):e,"0=>top,1|0=>right,2|0=>bottom,3|1|0=>left",!0),!0)}},mounted(){this.change(this.close)}},D={class:"card-title"},G={class:"card-content"};function U(e,t,s,h,r,n){return l.openBlock(),l.createElementBlock("div",{class:"card",key:r.trigger,style:l.normalizeStyle(n.isEmpty(n.style)?n.tr():n.style)},[l.renderSlot(e.$slots,"default",{},()=>[l.renderSlot(e.$slots,"title",{},()=>[l.createElementVNode("div",D,[l.createTextVNode(l.toDisplayString(s.show||s.title)+" ",1),l.createElementVNode("div",{class:l.normalizeClass(["card-close",{hide:n.isSimplyType(s.close)?!s.close:!1}]),style:l.normalizeStyle(r.closecss),onClick:t[0]||(t[0]=i=>e.$emit("close"))},null,6)])],!0),l.renderSlot(e.$slots,"content",{},()=>[l.createElementVNode("div",G,[l.renderSlot(e.$slots,"inner",{},void 0,!0)])],!0)],!0)],4)}const A=E(q,[["render",U],["__scopeId","data-v-fcd6014d"]]),X={name:"Stream",props:{type:{type:String,default:"div"},data:{type:Array,default:()=>[]},T:{type:Array,default:()=>[]}}};function Y(e,t,s,h,r,n){return l.openBlock(),l.createBlock(l.resolveDynamicComponent(s.type),l.mergeProps(e.$attrs,{data:s.data}),{default:l.withCtx(()=>[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(s.T,i=>l.renderSlot(e.$slots,i.slot||i.type||"default",l.mergeProps({key:i.type,ref_for:!0},i))),128))]),_:3},16,["data"])}const R=E(X,[["render",Y]]),J=[F,A,R],K={install(e){J.forEach(t=>{e.component("S"+t.name,t),e.component(t.name+"S",t)})}};exports.Card=A;exports.Flyweight=F;exports.Stream=R;exports.default=K;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@soei/util"),l=require("vue");let I=/(\d+|[+\-\*/]|%)/g,N={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t,s)=>parseFloat(e)/100*s},C=(e,t)=>{let s;if(s=c.runer("match",e,I)){let h=s.length,i,n=0,r,o=[];for(;h--;)n=s.shift(),n in N?(i&&o.push(i),n==="%"&&(o.length=2),r=n):+n&&o.push(+n),o.length==2&&(o.push(t),i=N[r].apply(null,o),o.length=0);+i||(i=+o.pop()),e=i>>0}return e},B=e=>(e+"").replace(/\w+\((.*)\)/g,"$1").replace(/(?=\s+|^)(\d+(\.\d+)*)(?!(?:\.)*\d|%|\w)/g,"$1px");const E=(e,t)=>{const s=e.__vccOpts||e;for(const[h,i]of t)s[h]=i;return s};let L=e=>e==null||e==null,V=(...e)=>{console.info("::::FLYWEIGHT",...e)};const W={name:"Flyweight",props:{flys:{type:Array,default:()=>[]},width:{type:Number,default:0},height:{type:Number,default:100},offset:{type:Array,default:()=>[0,0]},lazy:{type:Number,default:100},view:{type:Object,default:()=>({id:0})},index:{type:Number,default:0},top:{type:Number,default:!1},left:{type:Number,default:!1},auto:{type:[Boolean,String],default:!1},space:{type:Object,default:()=>null},padding:{type:Boolean,default:!1}},computed:{flyweight(){return this.$refs.flyweight||""}},data(){return{flyweights:[],actice:!1,Size:null,column:1,row:1,expand:10,count:0,task:[],realW:0,realH:0}},watch:{flys(e){this.count=e.length,this.rebuild();let t=this.task.shift();t&&this.$nextTick(()=>{this.setview(t)})},view:{handler(e){this.setview(e)},immediate:!0,deep:!0},index(e){this.setindex(e)},top(e){this.flyweight.scrollTop=e},left(e){this.flyweight.scrollLeft=e}},mounted(){this.flyweights=[],this.$set||(this.$set=(e,t,s)=>{e[t]=s}),this.setindex(this.index);try{new ResizeObserver(()=>{this.rebuild(),this.$emit("resize")}).observe(this.flyweight)}catch(e){V(e)}this.scrollx=c.runer("hasAttribute",this.flyweight,"scroll-x"),this.BoxRule="clientHeight=>height,clientWidth=>width",this.direction=this.scrollx?"scrollLeft":"scrollTop"},methods:{exec:B,trigger(e,t){this.lazyrun(()=>{c.isArray(e)||(e=[[e,t]]),c.each(e,(s,h)=>{this.$emit(h[0],L(h[1])?!0:h[1])})})},cheackflys(e){if(!this.flys.length)return e&&this.task.push(e),!0},setview(e){c.runer([this.cheackflys,t=>{t=t||{};let s=t.index||c.each(this.flys,(h,i,n,r)=>{if(i[n]==r)return h},t.picker,t.id);L(s)||this.setindex(s)}],this,e)},setindex(e){c.runer([this.cheackflys,({index:t})=>{this.selectIndex=t,this.$nextTick(()=>{let s=t/this.column>>0,h=this.expand;(this.flyweight[this.direction]/h>>0)+this.row-s-1>0||(this.flyweight[this.direction]=s*h,this.scroll())})}],this,{index:e})},lazyrun(e,t){clearTimeout(this.time),this.time=setTimeout(()=>{c.runer(e)},t||this.lazy)},run(e){let t=[],s=c.runer(this.direction,e.target),h={offset:s,top:s,width:this.realW,height:this.realH,index:s/this.expand>>0};c.merge(h,this.space),e.from||t.push(["onscroll",h]);let i=!1;c.each(this.flyweights,(n,r,o,d,f,u,g,p,a)=>{if(o=n/f>>0,p=o+d*(+(o<u%d)+(u/d>>0)),a=p*f+n%f,a>=this.count){i||(t.push(["onend"]),i=!0);return}r.index=p,r.i=a,r.data=this.flys[a];let y=[p*this.expand+r.x,r.space];g&&y.reverse(),r.top=y[0],r.left=y[1]},null,this.row,this.column,h.index,this.scrollx),this.trigger(t),t=null},scroll(e){this.run(e||{target:this.flyweight,from:"space"})},rebuild(){let e=this.count||this.flys.length,t=this.flyweights;if(!e)return t.length=e;this.count=e;let s=this.scrollx,h=this.flyweight,i=c.picker(h,this.BoxRule);this.$nextTick(()=>{let n=/true/.test(this.auto),[r,o]=this.offset,d=i.width,f=i.height,u=(C(this.width,d)||d)+r,g=C(this.height,f)+o,p=[d/u>>0||1,f/g>>0||1];s&&p.reverse();let[a,y]=p,_=this.padding,S,k=0,m,b;s?(m=u,u-=r,b=w=>w*(g-o)+(w+1)*o):(n?(u=(d-r*(a+2*_-1))/a,S=!_*r,k=_*r):(S=0,k=(d%u+r*a)/(a+1)>>0,u-=r),b=w=>w*(u+S)+(w+1)*k,m=g),this.row=y+2,this.column=a,this.realH=g-o,this.realW=u,this.expand=m,this.Size=Math.ceil(e/a)*m;let T=Math.min(e,a*this.row),x=T-1,z;for(;T-- >0;)z=x-T,this.$set(t,z,{x:r,y:o,width:u,height:g-o,space:b(z%a),data:{}});t.length=x+1;let v=[];f/m>x/a&&v.push(["onend"]),this.flyweight&&(this.flyweight[this.direction]=0),this.$nextTick(()=>{this.setindex(this.selectIndex||0),this.scroll()}),v.push(["update:space",{row:(x/a>>0)+1,column:a,showrow:this.row,showcolumn:this.column}]),this.trigger(v)})}}},j={class:"flyweight-all"};function M(e,t,s,h,i,n){return l.openBlock(),l.createElementBlock("div",{ref:"flyweight",class:l.normalizeClass(["flyweight",{"flyweight-active":i.actice}]),style:l.normalizeStyle({"--width":n.exec(i.realW),"--height":n.exec(i.realH),"--flyweight-content":n.exec(i.Size)}),onScroll:t[0]||(t[0]=(...r)=>n.scroll&&n.scroll(...r))},[l.createElementVNode("div",j,[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(i.flyweights,(r,o)=>(l.openBlock(),l.createElementBlock("div",{key:o,style:l.normalizeStyle({top:r.top+"px",left:r.left+"px"})},[l.renderSlot(e.$slots,"default",l.mergeProps({ref_for:!0},r),void 0,!0)],4))),128))]),i.flyweights.length?l.renderSlot(e.$slots,"end",{key:0},void 0,!0):l.createCommentVNode("",!0)],38)}const F=E(W,[["render",M],["__scopeId","data-v-8f29f044"]]);function $(e,t){return t&&(e=e.replace(/[a-z]/g,"")),e.toLowerCase()}let H={close:{handler(e){this.change(e)},deep:!0},offset:{handler(e){this.margin(e)},deep:!0}},P=["BackGround","BordeR","Height","Width","Top","Right","Bottom","Left"],O={};c.each(P,(e,t,s)=>{e=$(t),O["--"+$(t,!0)]=e,s[e]=function(){this.trigger++}},H);const q={name:"Card",props:{offset:{type:[String,Array],default:()=>[0,0,0,0]},background:{type:String,default:""},border:{type:String,default:"1px"},height:{type:String,default:"100%"},width:{type:String,default:"100%"},show:{type:String,default:""},close:{type:Object,default:null},title:{type:String,default:""}},data(){return{closecss:{},trigger:0,default:{top:"0px",right:"0px",bottom:"0px",left:"0px",height:"100%",width:"100%",background:"",border:"1px"}}},computed:{style(){return this.tr()}},watch:H,methods:{exec:B,isEmpty:c.isEmpty,isSimplyType:c.isSimplyType,tr(){let e={};return this.margin(this.offset),c.each(O,(t,s)=>{this.css(e,t,s)}),e},tolower:$,css(e,t,s){let h=this[s]||this.default[s];!h||this.default[s]==h||(e[t]=B(h))},change(e){c.isSimplyType(e)||(this.closecss=c.picker(e,"color=>--s-card-close-color,*"))},margin(e){c.merge(this,c.picker(c.isString(e)?e.split(/\s*(?:,|\s+)\s*/):e,"0=>top,1|0=>right,2|0=>bottom,3|1|0=>left",!0),!0)}},mounted(){this.change(this.close)}},D={class:"card-title"},G={class:"card-content"};function U(e,t,s,h,i,n){return l.openBlock(),l.createElementBlock("div",{class:"card",key:i.trigger,style:l.normalizeStyle(n.isEmpty(n.style)?n.tr():n.style)},[l.renderSlot(e.$slots,"default",{},()=>[l.renderSlot(e.$slots,"title",{},()=>[l.createElementVNode("div",D,[l.createTextVNode(l.toDisplayString(s.show||s.title)+" ",1),l.createElementVNode("div",{class:l.normalizeClass(["card-close",{hide:n.isSimplyType(s.close)?!s.close:!1}]),style:l.normalizeStyle(i.closecss),onClick:t[0]||(t[0]=r=>e.$emit("close"))},null,6)])],!0),l.renderSlot(e.$slots,"content",{},()=>[l.createElementVNode("div",G,[l.renderSlot(e.$slots,"inner",{},void 0,!0)])],!0)],!0)],4)}const A=E(q,[["render",U],["__scopeId","data-v-fcd6014d"]]),X={name:"Stream",props:{type:{type:String,default:"div"},data:{type:Array,default:()=>[]},T:{type:Array,default:()=>[]}},methods:{trigger(e){let t=e.slot||e.type;return(this.$scopedSlots||this.$slots)[t]?t:"default"}}};function Y(e,t,s,h,i,n){return l.openBlock(),l.createBlock(l.resolveDynamicComponent(s.type),l.mergeProps(e.$attrs,{data:s.data}),{default:l.withCtx(()=>[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(s.T,r=>l.renderSlot(e.$slots,n.trigger(r),l.mergeProps({key:r.type,ref_for:!0},r))),128))]),_:3},16,["data"])}const R=E(X,[["render",Y]]),J=[F,A,R],K={install(e){J.forEach(t=>{e.component("S"+t.name,t),e.component(t.name+"S",t)})}};exports.Card=A;exports.Flyweight=F;exports.Stream=R;exports.default=K;
package/Flyweight.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { runer as p, isArray as X, each as _, merge as V, picker as H, isEmpty as Y, isSimplyType as F, isString as q } from "@soei/util";
2
- import { openBlock as y, createElementBlock as b, normalizeClass as D, normalizeStyle as T, createElementVNode as k, Fragment as G, renderList as M, renderSlot as g, mergeProps as A, createCommentVNode as J, createTextVNode as K, toDisplayString as Q, createBlock as Z, resolveDynamicComponent as tt, withCtx as et } from "vue";
2
+ import { openBlock as y, createElementBlock as S, normalizeClass as D, normalizeStyle as T, createElementVNode as k, Fragment as G, renderList as M, renderSlot as g, mergeProps as A, createCommentVNode as J, createTextVNode as K, toDisplayString as Q, createBlock as Z, resolveDynamicComponent as tt, withCtx as et } from "vue";
3
3
  let st = /(\d+|[+\-\*/]|%)/g, I = {
4
4
  "+": (t, e) => t + e,
5
5
  "-": (t, e) => t - e,
@@ -220,14 +220,14 @@ const lt = {
220
220
  this.$nextTick(() => {
221
221
  let r = /true/.test(this.auto), [i, n] = this.offset, c = l.width, u = l.height, a = (W(this.width, c) || c) + i, d = W(this.height, u) + n, f = [c / a >> 0 || 1, u / d >> 0 || 1];
222
222
  s && f.reverse();
223
- let [o, m] = f, v = this.padding, z, $ = 0, w, B;
223
+ let [o, m] = f, $ = this.padding, v, z = 0, w, B;
224
224
  s ? (w = a, a -= i, B = (x) => (
225
225
  /* 计算top偏移量 */
226
226
  x * (d - n) + (x + 1) * n
227
- )) : (r ? (a = (c - i * (o + 2 * v - 1)) / o, z = !v * i, $ = v * i) : (z = 0, $ = (c % a + i * o) / (o + 1) >> 0, a -= i), B = (x) => x * (a + z) + (x + 1) * $, w = d), this.row = m + 2, this.column = o, this.realH = d - n, this.realW = a, this.expand = w, this.Size = Math.ceil(t / o) * w;
228
- let N = Math.min(t, o * this.row), S = N - 1, C;
227
+ )) : (r ? (a = (c - i * (o + 2 * $ - 1)) / o, v = !$ * i, z = $ * i) : (v = 0, z = (c % a + i * o) / (o + 1) >> 0, a -= i), B = (x) => x * (a + v) + (x + 1) * z, w = d), this.row = m + 2, this.column = o, this.realH = d - n, this.realW = a, this.expand = w, this.Size = Math.ceil(t / o) * w;
228
+ let N = Math.min(t, o * this.row), b = N - 1, C;
229
229
  for (; N-- > 0; )
230
- C = S - N, this.$set(e, C, {
230
+ C = b - N, this.$set(e, C, {
231
231
  x: i,
232
232
  y: n,
233
233
  width: a,
@@ -235,12 +235,12 @@ const lt = {
235
235
  space: B(C % o),
236
236
  data: {}
237
237
  });
238
- e.length = S + 1;
238
+ e.length = b + 1;
239
239
  let L = [];
240
- u / w > S / o && L.push(["onend"]), this.flyweight && (this.flyweight[this.direction] = 0), this.$nextTick(() => {
240
+ u / w > b / o && L.push(["onend"]), this.flyweight && (this.flyweight[this.direction] = 0), this.$nextTick(() => {
241
241
  this.setindex(this.selectIndex || 0), this.scroll();
242
242
  }), L.push(["update:space", {
243
- row: (S / o >> 0) + 1,
243
+ row: (b / o >> 0) + 1,
244
244
  column: o,
245
245
  showrow: this.row,
246
246
  showcolumn: this.column
@@ -250,7 +250,7 @@ const lt = {
250
250
  }
251
251
  }, rt = { class: "flyweight-all" };
252
252
  function ht(t, e, s, h, l, r) {
253
- return y(), b("div", {
253
+ return y(), S("div", {
254
254
  ref: "flyweight",
255
255
  class: D(["flyweight", {
256
256
  "flyweight-active": l.actice
@@ -263,7 +263,7 @@ function ht(t, e, s, h, l, r) {
263
263
  onScroll: e[0] || (e[0] = (...i) => r.scroll && r.scroll(...i))
264
264
  }, [
265
265
  k("div", rt, [
266
- (y(!0), b(G, null, M(l.flyweights, (i, n) => (y(), b("div", {
266
+ (y(!0), S(G, null, M(l.flyweights, (i, n) => (y(), S("div", {
267
267
  key: n,
268
268
  style: T({
269
269
  top: i.top + "px",
@@ -390,7 +390,7 @@ const at = {
390
390
  }
391
391
  }, ct = { class: "card-title" }, ut = { class: "card-content" };
392
392
  function dt(t, e, s, h, l, r) {
393
- return y(), b("div", {
393
+ return y(), S("div", {
394
394
  class: "card",
395
395
  key: l.trigger,
396
396
  style: T(r.isEmpty(r.style) ? r.tr() : r.style)
@@ -429,12 +429,18 @@ const ft = /* @__PURE__ */ E(at, [["render", dt], ["__scopeId", "data-v-fcd6014d
429
429
  type: Array,
430
430
  default: () => []
431
431
  }
432
+ },
433
+ methods: {
434
+ trigger(t) {
435
+ let e = t.slot || t.type;
436
+ return (this.$scopedSlots || this.$slots)[e] ? e : "default";
437
+ }
432
438
  }
433
439
  };
434
440
  function pt(t, e, s, h, l, r) {
435
441
  return y(), Z(tt(s.type), A(t.$attrs, { data: s.data }), {
436
442
  default: et(() => [
437
- (y(!0), b(G, null, M(s.T, (i) => g(t.$slots, i.slot || i.type || "default", A({
443
+ (y(!0), S(G, null, M(s.T, (i) => g(t.$slots, r.trigger(i), A({
438
444
  key: i.type,
439
445
  ref_for: !0
440
446
  }, i))), 128))
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@soei/flyweight",
3
3
  "private": false,
4
4
  "description": "Vue组件, 列表de享元模式~减少DOM节点 flyweight, Card, Stream组件",
5
- "version": "0.3.0",
5
+ "version": "0.3.1",
6
6
  "type": "module",
7
7
  "main": "Flyweight.cjs",
8
8
  "module": "Flyweight.js",
package/vue2/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("@soei/util");let W=/(\d+|[+\-\*/]|%)/g,R={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t,i)=>parseFloat(e)/100*i},F=(e,t)=>{let i;if(i=a.runer("match",e,W)){let s=i.length,n,c=0,l,h=[];for(;s--;)c=i.shift(),c in R?(n&&h.push(n),c==="%"&&(h.length=2),l=c):+c&&h.push(+c),h.length==2&&(h.push(t),n=R[l].apply(null,h),h.length=0);+n||(n=+h.pop()),e=n>>0}return e},C=e=>(e+"").replace(/\w+\((.*)\)/g,"$1").replace(/(?=\s+|^)(\d+(\.\d+)*)(?!(?:\.)*\d|%|\w)/g,"$1px");function z(e,t,i,s,n,c,l,h){var r=typeof e=="function"?e.options:e;t&&(r.render=t,r.staticRenderFns=i,r._compiled=!0),s&&(r.functional=!0),c&&(r._scopeId="data-v-"+c);var f;if(l?(f=function(u){u=u||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!u&&typeof __VUE_SSR_CONTEXT__<"u"&&(u=__VUE_SSR_CONTEXT__),n&&n.call(this,u),u&&u._registeredComponents&&u._registeredComponents.add(l)},r._ssrRegister=f):n&&(f=h?function(){n.call(this,(r.functional?this.parent:this).$root.$options.shadowRoot)}:n),f)if(r.functional){r._injectStyles=f;var d=r.render;r.render=function(o,g){return f.call(g),d(o,g)}}else{var p=r.beforeCreate;r.beforeCreate=p?[].concat(p,f):[f]}return{exports:e,options:r}}let N=e=>e==null||e==null,E=(...e)=>{console.info("::::FLYWEIGHT",...e)};const I={name:"Flyweight",props:{flys:{type:Array,default:()=>[]},width:{type:Number,default:0},height:{type:Number,default:100},offset:{type:Array,default:()=>[0,0]},lazy:{type:Number,default:100},view:{type:Object,default:()=>({id:0})},index:{type:Number,default:0},top:{type:Number,default:!1},left:{type:Number,default:!1},auto:{type:[Boolean,String],default:!1},space:{type:Object,default:()=>null},padding:{type:Boolean,default:!1}},computed:{flyweight(){return this.$refs.flyweight||""}},data(){return{flyweights:[],actice:!1,Size:null,column:1,row:1,expand:10,count:0,task:[],realW:0,realH:0}},watch:{flys(e){this.count=e.length,this.rebuild();let t=this.task.shift();t&&this.$nextTick(()=>{this.setview(t)})},view:{handler(e){this.setview(e)},immediate:!0,deep:!0},index(e){this.setindex(e)},top(e){this.flyweight.scrollTop=e},left(e){this.flyweight.scrollLeft=e}},mounted(){this.flyweights=[],this.$set||(this.$set=(e,t,i)=>{e[t]=i}),this.setindex(this.index);try{new ResizeObserver(()=>{this.rebuild(),this.$emit("resize")}).observe(this.flyweight)}catch(e){E(e)}this.scrollx=a.runer("hasAttribute",this.flyweight,"scroll-x"),this.BoxRule="clientHeight=>height,clientWidth=>width",this.direction=this.scrollx?"scrollLeft":"scrollTop"},methods:{exec:C,trigger(e,t){this.lazyrun(()=>{a.isArray(e)||(e=[[e,t]]),a.each(e,(i,s)=>{this.$emit(s[0],N(s[1])?!0:s[1])})})},cheackflys(e){if(!this.flys.length)return e&&this.task.push(e),!0},setview(e){a.runer([this.cheackflys,t=>{t=t||{};let i=t.index||a.each(this.flys,(s,n,c,l)=>{if(n[c]==l)return s},t.picker,t.id);N(i)||this.setindex(i)}],this,e)},setindex(e){a.runer([this.cheackflys,({index:t})=>{this.selectIndex=t,this.$nextTick(()=>{let i=t/this.column>>0,s=this.expand;(this.flyweight[this.direction]/s>>0)+this.row-i-1>0||(this.flyweight[this.direction]=i*s,this.scroll())})}],this,{index:e})},lazyrun(e,t){clearTimeout(this.time),this.time=setTimeout(()=>{a.runer(e)},t||this.lazy)},run(e){let t=[],i=a.runer(this.direction,e.target),s={offset:i,top:i,width:this.realW,height:this.realH,index:i/this.expand>>0};a.merge(s,this.space),e.from||t.push(["onscroll",s]);let n=!1;a.each(this.flyweights,(c,l,h,r,f,d,p,u,o)=>{if(h=c/f>>0,u=h+r*(+(h<d%r)+(d/r>>0)),o=u*f+c%f,o>=this.count){n||(t.push(["onend"]),n=!0);return}l.index=u,l.i=o,l.data=this.flys[o];let g=[u*this.expand+l.x,l.space];p&&g.reverse(),l.top=g[0],l.left=g[1]},null,this.row,this.column,s.index,this.scrollx),this.trigger(t),t=null},scroll(e){this.run(e||{target:this.flyweight,from:"space"})},rebuild(){let e=this.count||this.flys.length,t=this.flyweights;if(!e)return t.length=e;this.count=e;let i=this.scrollx,s=this.flyweight,n=a.picker(s,this.BoxRule);this.$nextTick(()=>{let c=/true/.test(this.auto),[l,h]=this.offset,r=n.width,f=n.height,d=(F(this.width,r)||r)+l,p=F(this.height,f)+h,u=[r/d>>0||1,f/p>>0||1];i&&u.reverse();let[o,g]=u,w=this.padding,x,v=0,y,$;i?(y=d,d-=l,$=_=>_*(p-h)+(_+1)*h):(c?(d=(r-l*(o+2*w-1))/o,x=!w*l,v=w*l):(x=0,v=(r%d+l*o)/(o+1)>>0,d-=l),$=_=>_*(d+x)+(_+1)*v,y=p),this.row=g+2,this.column=o,this.realH=p-h,this.realW=d,this.expand=y,this.Size=Math.ceil(e/o)*y;let b=Math.min(e,o*this.row),m=b-1,S;for(;b-- >0;)S=m-b,this.$set(t,S,{x:l,y:h,width:d,height:p-h,space:$(S%o),data:{}});t.length=m+1;let T=[];f/y>m/o&&T.push(["onend"]),this.flyweight&&(this.flyweight[this.direction]=0),this.$nextTick(()=>{this.setindex(this.selectIndex||0),this.scroll()}),T.push(["update:space",{row:(m/o>>0)+1,column:o,showrow:this.row,showcolumn:this.column}]),this.trigger(T)})}}};var M=function(){var t=this,i=t._self._c;return i("div",{ref:"flyweight",staticClass:"flyweight",class:{"flyweight-active":t.actice},style:{"--width":t.exec(t.realW),"--height":t.exec(t.realH),"--flyweight-content":t.exec(t.Size)},on:{scroll:t.scroll}},[i("div",{staticClass:"flyweight-all"},t._l(t.flyweights,function(s,n){return i("div",{key:n,style:{top:s.top+"px",left:s.left+"px"}},[t._t("default",null,null,s)],2)}),0),t.flyweights.length?t._t("end"):t._e()],2)},U=[],X=z(I,M,U,!1,null,"05373fe1",null,null);const O=X.exports;function k(e,t){return t&&(e=e.replace(/[a-z]/g,"")),e.toLowerCase()}let H={close:{handler(e){this.change(e)},deep:!0},offset:{handler(e){this.margin(e)},deep:!0}},j=["BackGround","BordeR","Height","Width","Top","Right","Bottom","Left"],L={};a.each(j,(e,t,i)=>{e=k(t),L["--"+k(t,!0)]=e,i[e]=function(){this.trigger++}},H);const G={name:"Card",props:{offset:{type:[String,Array],default:()=>[0,0,0,0]},background:{type:String,default:""},border:{type:String,default:"1px"},height:{type:String,default:"100%"},width:{type:String,default:"100%"},show:{type:String,default:""},close:{type:Object,default:null},title:{type:String,default:""}},data(){return{closecss:{},trigger:0,default:{top:"0px",right:"0px",bottom:"0px",left:"0px",height:"100%",width:"100%",background:"",border:"1px"}}},computed:{style(){return this.tr()}},watch:H,methods:{exec:C,isEmpty:a.isEmpty,isSimplyType:a.isSimplyType,tr(){let e={};return this.margin(this.offset),a.each(L,(t,i)=>{this.css(e,t,i)}),e},tolower:k,css(e,t,i){let s=this[i]||this.default[i];!s||this.default[i]==s||(e[t]=C(s))},change(e){a.isSimplyType(e)||(this.closecss=a.picker(e,"color=>--s-card-close-color,*"))},margin(e){a.merge(this,a.picker(a.isString(e)?e.split(/\s*(?:,|\s+)\s*/):e,"0=>top,1|0=>right,2|0=>bottom,3|1|0=>left",!0),!0)}},mounted(){this.change(this.close)}};var V=function(){var t=this,i=t._self._c;return i("div",{key:t.trigger,staticClass:"card",style:t.isEmpty(t.style)?t.tr():t.style},[t._t("default",function(){return[t._t("title",function(){return[i("div",{staticClass:"card-title"},[t._v(" "+t._s(t.show||t.title)+" "),i("div",{staticClass:"card-close",class:{hide:t.isSimplyType(t.close)?!t.close:!1},style:t.closecss,on:{click:function(s){return t.$emit("close")}}})])]}),t._t("content",function(){return[i("div",{staticClass:"card-content"},[t._t("inner")],2)]})]})],2)},q=[],P=z(G,V,q,!1,null,"19340aef",null,null);const A=P.exports,Y={name:"Stream",props:{type:{type:String,default:"div"},data:{type:Array,default:()=>[]},T:{type:Array,default:()=>[]}}};var D=function(){var t=this,i=t._self._c;return i(t.type,t._b({tag:"component",attrs:{data:t.data}},"component",t.$attrs,!1),[t._l(t.T,function(s){return[t._t(s.slot||s.type||"default",null,null,s)]})],2)},J=[],K=z(Y,D,J,!1,null,null,null,null);const B=K.exports,Q=[O,A,B],Z={install(e){Q.forEach(t=>{e.component("S"+t.name,t),e.component(t.name+"S",t)})}};exports.Card=A;exports.Flyweight=O;exports.Stream=B;exports.default=Z;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("@soei/util");let W=/(\d+|[+\-\*/]|%)/g,R={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t,s)=>parseFloat(e)/100*s},F=(e,t)=>{let s;if(s=o.runer("match",e,W)){let i=s.length,n,c=0,r,h=[];for(;i--;)c=s.shift(),c in R?(n&&h.push(n),c==="%"&&(h.length=2),r=c):+c&&h.push(+c),h.length==2&&(h.push(t),n=R[r].apply(null,h),h.length=0);+n||(n=+h.pop()),e=n>>0}return e},C=e=>(e+"").replace(/\w+\((.*)\)/g,"$1").replace(/(?=\s+|^)(\d+(\.\d+)*)(?!(?:\.)*\d|%|\w)/g,"$1px");function z(e,t,s,i,n,c,r,h){var l=typeof e=="function"?e.options:e;t&&(l.render=t,l.staticRenderFns=s,l._compiled=!0),i&&(l.functional=!0),c&&(l._scopeId="data-v-"+c);var f;if(r?(f=function(u){u=u||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!u&&typeof __VUE_SSR_CONTEXT__<"u"&&(u=__VUE_SSR_CONTEXT__),n&&n.call(this,u),u&&u._registeredComponents&&u._registeredComponents.add(r)},l._ssrRegister=f):n&&(f=h?function(){n.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:n),f)if(l.functional){l._injectStyles=f;var d=l.render;l.render=function(a,g){return f.call(g),d(a,g)}}else{var p=l.beforeCreate;l.beforeCreate=p?[].concat(p,f):[f]}return{exports:e,options:l}}let N=e=>e==null||e==null,E=(...e)=>{console.info("::::FLYWEIGHT",...e)};const I={name:"Flyweight",props:{flys:{type:Array,default:()=>[]},width:{type:Number,default:0},height:{type:Number,default:100},offset:{type:Array,default:()=>[0,0]},lazy:{type:Number,default:100},view:{type:Object,default:()=>({id:0})},index:{type:Number,default:0},top:{type:Number,default:!1},left:{type:Number,default:!1},auto:{type:[Boolean,String],default:!1},space:{type:Object,default:()=>null},padding:{type:Boolean,default:!1}},computed:{flyweight(){return this.$refs.flyweight||""}},data(){return{flyweights:[],actice:!1,Size:null,column:1,row:1,expand:10,count:0,task:[],realW:0,realH:0}},watch:{flys(e){this.count=e.length,this.rebuild();let t=this.task.shift();t&&this.$nextTick(()=>{this.setview(t)})},view:{handler(e){this.setview(e)},immediate:!0,deep:!0},index(e){this.setindex(e)},top(e){this.flyweight.scrollTop=e},left(e){this.flyweight.scrollLeft=e}},mounted(){this.flyweights=[],this.$set||(this.$set=(e,t,s)=>{e[t]=s}),this.setindex(this.index);try{new ResizeObserver(()=>{this.rebuild(),this.$emit("resize")}).observe(this.flyweight)}catch(e){E(e)}this.scrollx=o.runer("hasAttribute",this.flyweight,"scroll-x"),this.BoxRule="clientHeight=>height,clientWidth=>width",this.direction=this.scrollx?"scrollLeft":"scrollTop"},methods:{exec:C,trigger(e,t){this.lazyrun(()=>{o.isArray(e)||(e=[[e,t]]),o.each(e,(s,i)=>{this.$emit(i[0],N(i[1])?!0:i[1])})})},cheackflys(e){if(!this.flys.length)return e&&this.task.push(e),!0},setview(e){o.runer([this.cheackflys,t=>{t=t||{};let s=t.index||o.each(this.flys,(i,n,c,r)=>{if(n[c]==r)return i},t.picker,t.id);N(s)||this.setindex(s)}],this,e)},setindex(e){o.runer([this.cheackflys,({index:t})=>{this.selectIndex=t,this.$nextTick(()=>{let s=t/this.column>>0,i=this.expand;(this.flyweight[this.direction]/i>>0)+this.row-s-1>0||(this.flyweight[this.direction]=s*i,this.scroll())})}],this,{index:e})},lazyrun(e,t){clearTimeout(this.time),this.time=setTimeout(()=>{o.runer(e)},t||this.lazy)},run(e){let t=[],s=o.runer(this.direction,e.target),i={offset:s,top:s,width:this.realW,height:this.realH,index:s/this.expand>>0};o.merge(i,this.space),e.from||t.push(["onscroll",i]);let n=!1;o.each(this.flyweights,(c,r,h,l,f,d,p,u,a)=>{if(h=c/f>>0,u=h+l*(+(h<d%l)+(d/l>>0)),a=u*f+c%f,a>=this.count){n||(t.push(["onend"]),n=!0);return}r.index=u,r.i=a,r.data=this.flys[a];let g=[u*this.expand+r.x,r.space];p&&g.reverse(),r.top=g[0],r.left=g[1]},null,this.row,this.column,i.index,this.scrollx),this.trigger(t),t=null},scroll(e){this.run(e||{target:this.flyweight,from:"space"})},rebuild(){let e=this.count||this.flys.length,t=this.flyweights;if(!e)return t.length=e;this.count=e;let s=this.scrollx,i=this.flyweight,n=o.picker(i,this.BoxRule);this.$nextTick(()=>{let c=/true/.test(this.auto),[r,h]=this.offset,l=n.width,f=n.height,d=(F(this.width,l)||l)+r,p=F(this.height,f)+h,u=[l/d>>0||1,f/p>>0||1];s&&u.reverse();let[a,g]=u,w=this.padding,x,v=0,y,$;s?(y=d,d-=r,$=_=>_*(p-h)+(_+1)*h):(c?(d=(l-r*(a+2*w-1))/a,x=!w*r,v=w*r):(x=0,v=(l%d+r*a)/(a+1)>>0,d-=r),$=_=>_*(d+x)+(_+1)*v,y=p),this.row=g+2,this.column=a,this.realH=p-h,this.realW=d,this.expand=y,this.Size=Math.ceil(e/a)*y;let b=Math.min(e,a*this.row),m=b-1,S;for(;b-- >0;)S=m-b,this.$set(t,S,{x:r,y:h,width:d,height:p-h,space:$(S%a),data:{}});t.length=m+1;let T=[];f/y>m/a&&T.push(["onend"]),this.flyweight&&(this.flyweight[this.direction]=0),this.$nextTick(()=>{this.setindex(this.selectIndex||0),this.scroll()}),T.push(["update:space",{row:(m/a>>0)+1,column:a,showrow:this.row,showcolumn:this.column}]),this.trigger(T)})}}};var M=function(){var t=this,s=t._self._c;return s("div",{ref:"flyweight",staticClass:"flyweight",class:{"flyweight-active":t.actice},style:{"--width":t.exec(t.realW),"--height":t.exec(t.realH),"--flyweight-content":t.exec(t.Size)},on:{scroll:t.scroll}},[s("div",{staticClass:"flyweight-all"},t._l(t.flyweights,function(i,n){return s("div",{key:n,style:{top:i.top+"px",left:i.left+"px"}},[t._t("default",null,null,i)],2)}),0),t.flyweights.length?t._t("end"):t._e()],2)},U=[],X=z(I,M,U,!1,null,"05373fe1",null,null);const O=X.exports;function k(e,t){return t&&(e=e.replace(/[a-z]/g,"")),e.toLowerCase()}let H={close:{handler(e){this.change(e)},deep:!0},offset:{handler(e){this.margin(e)},deep:!0}},j=["BackGround","BordeR","Height","Width","Top","Right","Bottom","Left"],L={};o.each(j,(e,t,s)=>{e=k(t),L["--"+k(t,!0)]=e,s[e]=function(){this.trigger++}},H);const G={name:"Card",props:{offset:{type:[String,Array],default:()=>[0,0,0,0]},background:{type:String,default:""},border:{type:String,default:"1px"},height:{type:String,default:"100%"},width:{type:String,default:"100%"},show:{type:String,default:""},close:{type:Object,default:null},title:{type:String,default:""}},data(){return{closecss:{},trigger:0,default:{top:"0px",right:"0px",bottom:"0px",left:"0px",height:"100%",width:"100%",background:"",border:"1px"}}},computed:{style(){return this.tr()}},watch:H,methods:{exec:C,isEmpty:o.isEmpty,isSimplyType:o.isSimplyType,tr(){let e={};return this.margin(this.offset),o.each(L,(t,s)=>{this.css(e,t,s)}),e},tolower:k,css(e,t,s){let i=this[s]||this.default[s];!i||this.default[s]==i||(e[t]=C(i))},change(e){o.isSimplyType(e)||(this.closecss=o.picker(e,"color=>--s-card-close-color,*"))},margin(e){o.merge(this,o.picker(o.isString(e)?e.split(/\s*(?:,|\s+)\s*/):e,"0=>top,1|0=>right,2|0=>bottom,3|1|0=>left",!0),!0)}},mounted(){this.change(this.close)}};var V=function(){var t=this,s=t._self._c;return s("div",{key:t.trigger,staticClass:"card",style:t.isEmpty(t.style)?t.tr():t.style},[t._t("default",function(){return[t._t("title",function(){return[s("div",{staticClass:"card-title"},[t._v(" "+t._s(t.show||t.title)+" "),s("div",{staticClass:"card-close",class:{hide:t.isSimplyType(t.close)?!t.close:!1},style:t.closecss,on:{click:function(i){return t.$emit("close")}}})])]}),t._t("content",function(){return[s("div",{staticClass:"card-content"},[t._t("inner")],2)]})]})],2)},q=[],P=z(G,V,q,!1,null,"19340aef",null,null);const A=P.exports,Y={name:"Stream",props:{type:{type:String,default:"div"},data:{type:Array,default:()=>[]},T:{type:Array,default:()=>[]}},methods:{trigger(e){let t=e.slot||e.type;return(this.$scopedSlots||this.$slots)[t]?t:"default"}}};var D=function(){var t=this,s=t._self._c;return s(t.type,t._b({tag:"component",attrs:{data:t.data}},"component",t.$attrs,!1),[t._l(t.T,function(i){return[t._t(t.trigger(i),null,null,i)]})],2)},J=[],K=z(Y,D,J,!1,null,null,null,null);const B=K.exports,Q=[O,A,B],Z={install(e){Q.forEach(t=>{e.component("S"+t.name,t),e.component(t.name+"S",t)})}};exports.Card=A;exports.Flyweight=O;exports.Stream=B;exports.default=Z;
package/vue2/index.js CHANGED
@@ -247,14 +247,14 @@ const M = {
247
247
  /* 计算top偏移量 */
248
248
  _ * (d - h) + (_ + 1) * h
249
249
  )) : (a ? (u = (r - l * (o + 2 * x - 1)) / o, v = !x * l, $ = x * l) : (v = 0, $ = (r % u + l * o) / (o + 1) >> 0, u -= l), b = (_) => _ * (u + v) + (_ + 1) * $, y = d), this.row = p + 2, this.column = o, this.realH = d - h, this.realW = u, this.expand = y, this.Size = Math.ceil(e / o) * y;
250
- let T = Math.min(e, o * this.row), w = T - 1, S;
251
- for (; T-- > 0; )
252
- S = w - T, this.$set(t, S, {
250
+ let S = Math.min(e, o * this.row), w = S - 1, T;
251
+ for (; S-- > 0; )
252
+ T = w - S, this.$set(t, T, {
253
253
  x: l,
254
254
  y: h,
255
255
  width: u,
256
256
  height: d - h,
257
- space: b(S % o),
257
+ space: b(T % o),
258
258
  data: {}
259
259
  });
260
260
  t.length = w + 1;
@@ -444,12 +444,18 @@ const Z = Q.exports, tt = {
444
444
  type: Array,
445
445
  default: () => []
446
446
  }
447
+ },
448
+ methods: {
449
+ trigger(e) {
450
+ let t = e.slot || e.type;
451
+ return (this.$scopedSlots || this.$slots)[t] ? t : "default";
452
+ }
447
453
  }
448
454
  };
449
455
  var et = function() {
450
456
  var t = this, s = t._self._c;
451
457
  return s(t.type, t._b({ tag: "component", attrs: { data: t.data } }, "component", t.$attrs, !1), [t._l(t.T, function(i) {
452
- return [t._t(i.slot || i.type || "default", null, null, i)];
458
+ return [t._t(t.trigger(i), null, null, i)];
453
459
  })], 2);
454
460
  }, st = [], it = /* @__PURE__ */ F(
455
461
  tt,