@soei/flyweight 0.3.5 → 0.3.6

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 o=require("@soei/util"),i=require("vue");let V=/(\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=o.runer("match",e,V)){let r=s.length,h,n=0,l,a=[];for(;r--;)n=s.shift(),n in N?(h&&a.push(h),n==="%"&&(a.length=2),l=n):+n&&a.push(+n),a.length==2&&(a.push(t),h=N[l].apply(null,a),a.length=0);+h||(h=+a.pop()),e=h>>0}return e},L={},f=(e,t)=>(e+"").replace(/\w+\((.*)\)/g,"$1").replace(L[t]||(L[t]=new RegExp("(?=\\s+|^)(\\d+)(?:\\.\\d{1,})?(?!(?:\\.)*\\d|%|\\w)","g")),"$1px");const E=(e,t)=>{const s=e.__vccOpts||e;for(const[r,h]of t)s[r]=h;return s};let A=e=>e==null||e==null,W=(...e)=>{console.info("::::FLYWEIGHT",...e)};const M={name:"Flyweight",props:{flys:{type:Array,default:()=>[]},width:{type:Number,default:0},height:{type:Number,default:100},w:{type:[Number,String]},h:{type:[Number,String]},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||""},style(){var e=this.w,t=this.h,s=this.Size,r={};return o.merge(r,{"--width":f(this.realW),"--height":f(this.realH),"--flyweight-content":f(s)},t&&{"--flyweight-h":f(t)},e&&r,{"--flyweight-w":f(e)},"mix"),r}},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){W(e)}this.scrollx=o.runer("hasAttribute",this.flyweight,"scroll-x"),this.BoxRule="clientHeight=>height,clientWidth=>width",this.direction=this.scrollx?"scrollLeft":"scrollTop"},methods:{exec:f,trigger(e,t){o.isArray(e)||(e=e&&t?[[e,t]]:[]),e.length&&this.lazyrun(()=>{o.each(e,(s,r)=>{this.$emit(r[0],A(r[1])?!0:r[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,(r,h,n,l)=>{if(h[n]==l)return r},t.picker,t.id);A(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,r=this.expand;(this.flyweight[this.direction]/r>>0)+this.row-s-1>0||(this.flyweight[this.direction]=s*r,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),r={offset:s,top:s,width:this.realW,height:this.realH,index:s/this.expand>>0};o.merge(r,this.space),e.from||t.push(["onscroll",r]);let h=!1;o.each(this.flyweights,(n,l,a,d,g,u,p,y,c)=>{if(a=n/g>>0,y=a+d*(+(a<u%d)+(u/d>>0)),c=y*g+n%g,c>=this.count){h||(t.push(["onend"]),h=!0);return}l.index=y,l.i=c,l.data=this.flys[c];let m=[y*this.expand+l.x,l.space];p&&m.reverse(),l.top=m[0],l.left=m[1]},null,this.row,this.column,r.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,r=this.flyweight,h=o.picker(r,this.BoxRule);this.$nextTick(()=>{let n=/true/.test(this.auto),[l,a]=this.offset,d=h.width,g=h.height,u=(C(this.width,d)||d)+l,p=C(this.height,g)+a,y=[d/u>>0||1,g/p>>0||1];s&&y.reverse();let[c,m]=y,S=this.padding,b,k=0,w,T;s?(w=u,u-=l,T=x=>x*(p-a)+(x+1)*a):(n?(u=(d-l*(c+2*S-1))/c,b=!S*l,k=S*l):(b=0,k=(d%u+l*c)/(c+1)>>0,u-=l),T=x=>x*(u+b)+(x+1)*k,w=p),this.row=m+2,this.column=c,this.realH=p-a,this.realW=u,this.expand=w,this.Size=Math.ceil(e/c)*w;let z=Math.min(e,c*this.row),_=z-1,$;for(;z-- >0;)$=_-z,this.$set(t,$,{x:l,y:a,width:u,height:p-a,space:T($%c),data:{}});t.length=_+1;let v=[];g/w>_/c&&v.push(["onend"]),this.flyweight&&(this.flyweight[this.direction]=0),this.$nextTick(()=>{this.setindex(this.selectIndex||0),this.scroll()}),v.push(["update:space",{row:(_/c>>0)+1,column:c,showrow:this.row,showcolumn:this.column}]),this.trigger(v)})}}},j={class:"flyweight-all"};function P(e,t,s,r,h,n){return i.openBlock(),i.createElementBlock("div",{ref:"flyweight",class:i.normalizeClass(["flyweight",{"flyweight-active":h.actice}]),style:i.normalizeStyle(n.style),onScroll:t[0]||(t[0]=(...l)=>n.scroll&&n.scroll(...l))},[i.createElementVNode("div",j,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(h.flyweights,(l,a)=>(i.openBlock(),i.createElementBlock("div",{key:a,style:i.normalizeStyle({top:l.top+"px",left:l.left+"px"})},[i.renderSlot(e.$slots,"default",i.mergeProps({ref_for:!0},l),void 0,!0)],4))),128))]),h.flyweights.length?i.renderSlot(e.$slots,"end",{key:0},void 0,!0):i.createCommentVNode("",!0)],38)}const F=E(M,[["render",P],["__scopeId","data-v-ae52e0f1"]]);function B(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}},q=["BackGround","BordeR","Height","Width","Top","Right","Bottom","Left"],O={};o.each(q,(e,t,s)=>{e=B(t),O["--"+B(t,!0)]=e,s[e]=function(){this.trigger++}},H);const D={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:f,isEmpty:o.isEmpty,isSimplyType:o.isSimplyType,tr(){let e={};return this.margin(this.offset),o.each(O,(t,s)=>{this.css(e,t,s)}),e},tolower:B,css(e,t,s){let r=this[s]||this.default[s];!r||this.default[s]==r||(e[t]=f(r))},change(e){o.isSimplyType(e)||(this.closecss=o.picker(e,"color=>--s-card-close-color,size=>--s-close-width,bold=>--s-close-height,*"))},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)}},G={class:"card-title"},U=["title"],X={class:"card-content"};function Y(e,t,s,r,h,n){return i.openBlock(),i.createElementBlock("div",{class:"card",key:h.trigger,style:i.normalizeStyle(n.isEmpty(n.style)?n.tr():n.style)},[i.renderSlot(e.$slots,"default",{},()=>[i.renderSlot(e.$slots,"title",{},()=>{var l;return[i.createElementVNode("div",G,[i.createTextVNode(i.toDisplayString(s.show||s.title)+" ",1),i.createElementVNode("div",{class:i.normalizeClass(["card-close",{hide:n.isSimplyType(s.close)?!s.close:!1}]),style:i.normalizeStyle(h.closecss),onClick:t[0]||(t[0]=a=>e.$emit("close")),title:(l=s.close)==null?void 0:l.tips},null,14,U)])]},!0),i.renderSlot(e.$slots,"content",{},()=>[i.createElementVNode("div",X,[i.renderSlot(e.$slots,"inner",{},void 0,!0)])],!0)],!0)],4)}const R=E(D,[["render",Y],["__scopeId","data-v-c1ad1d74"]]),J={name:"Stream",computed:{column(){let{columns:e,T:t}=this,s=e||t;return o.isEmpty(s)?[]:o.isArray(s)?s:[s]}},props:{bridge:{type:String,default:"slot"},type:{type:String,default:"div"},data:{type:Array,default:()=>[]},columns:{type:Array,default:()=>null},T:{type:Array,default:()=>null}},methods:{trigger(e){let t=e[this.bridge]||e.type;return(this.$scopedSlots||this.$slots)[t]?t:"default"}}};function K(e,t,s,r,h,n){return i.openBlock(),i.createBlock(i.resolveDynamicComponent(s.type),i.mergeProps(e.$attrs,{data:s.data}),{default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(n.column,l=>i.renderSlot(e.$slots,n.trigger(l),i.mergeProps({key:l.type,ref_for:!0},l))),128))]),_:3},16,["data"])}const I=E(J,[["render",K]]),Q=[F,R,I],Z={install(e){Q.forEach(t=>{e.component("S"+t.name,t),e.component(t.name+"S",t)})}};exports.Card=R;exports.Flyweight=F;exports.Stream=I;exports.default=Z;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("@soei/util"),i=require("vue");let V=/(\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=o.runer("match",e,V)){let r=s.length,h,n=0,l,a=[];for(;r--;)n=s.shift(),n in N?(h&&a.push(h),n==="%"&&(a.length=2),l=n):+n&&a.push(+n),a.length==2&&(a.push(t),h=N[l].apply(null,a),a.length=0);+h||(h=+a.pop()),e=h>>0}return e},L={},f=(e,t)=>(e+"").replace(/\w+\((.*)\)/g,"$1").replace(L[t]||(L[t]=new RegExp("(?=\\s+|^)(\\d+)(?:\\.\\d{1,})?(?!(?:\\.)*\\d|%|\\w)","g")),"$1px");const E=(e,t)=>{const s=e.__vccOpts||e;for(const[r,h]of t)s[r]=h;return s};let A=e=>e==null||e==null,W=(...e)=>{console.info("::::FLYWEIGHT",...e)};const M={name:"Flyweight",props:{flys:{type:Array,default:()=>[]},width:{type:Number,default:0},height:{type:Number,default:100},w:{type:[Number,String]},h:{type:[Number,String]},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||""},style(){var e=this.w,t=this.h,s=this.Size,r={};return o.merge(r,{"--width":f(this.realW),"--height":f(this.realH),"--flyweight-content":f(s)},t&&{"--flyweight-h":f(t)},e&&r,{"--flyweight-w":f(e)},"mix"),r}},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){W(e)}this.scrollx=o.runer("hasAttribute",this.flyweight,"scroll-x"),this.BoxRule="clientHeight=>height,clientWidth=>width",this.direction=this.scrollx?"scrollLeft":"scrollTop"},methods:{exec:f,trigger(e,t){o.isArray(e)||(e=e&&t?[[e,t]]:[]),e.length&&this.lazyrun(()=>{o.each(e,(s,r)=>{this.$emit(r[0],A(r[1])?!0:r[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,(r,h,n,l)=>{if(h[n]==l)return r},t.picker,t.id);A(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,r=this.expand;(this.flyweight[this.direction]/r>>0)+this.row-s-1>0||(this.flyweight[this.direction]=s*r,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),r={offset:s,top:s,width:this.realW,height:this.realH,index:s/this.expand>>0};o.merge(r,this.space),e.from||t.push(["onscroll",r]);let h=!1;o.each(this.flyweights,(n,l,a,d,g,u,p,y,c)=>{if(a=n/g>>0,y=a+d*(+(a<u%d)+(u/d>>0)),c=y*g+n%g,c>=this.count){h||(t.push(["onend"]),h=!0);return}l.index=y,l.i=c,l.data=this.flys[c];let m=[y*this.expand+l.x,l.space];p&&m.reverse(),l.top=m[0],l.left=m[1]},null,this.row,this.column,r.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,r=this.flyweight,h=o.picker(r,this.BoxRule);this.$nextTick(()=>{let n=/true/.test(this.auto),[l,a]=this.offset,d=h.width,g=h.height,u=(C(this.width,d)||d)+l,p=C(this.height,g)+a,y=[d/u>>0||1,g/p>>0||1];s&&y.reverse();let[c,m]=y,S=this.padding,b,k=0,w,z;s?(w=u,u-=l,z=x=>x*(p-a)+(x+1)*a):(n?(u=(d-l*(c+2*S-1))/c,b=!S*l,k=S*l):(b=0,k=(d%u+l*c)/(c+1)>>0,u-=l),z=x=>x*(u+b)+(x+1)*k,w=p),this.row=m+2,this.column=c,this.realH=p-a,this.realW=u,this.expand=w,this.Size=Math.ceil(e/c)*w;let T=Math.min(e,c*this.row),_=T-1,$;for(;T-- >0;)$=_-T,this.$set(t,$,{x:l,y:a,width:u,height:p-a,space:z($%c),data:{}});t.length=_+1;let v=[];g/w>_/c&&v.push(["onend"]),this.flyweight&&(this.flyweight[this.direction]=0),this.$nextTick(()=>{this.setindex(this.selectIndex||0),this.scroll()}),v.push(["update:space",{row:(_/c>>0)+1,column:c,showrow:this.row,showcolumn:this.column}]),this.trigger(v)})}}},P={class:"flyweight-all"};function j(e,t,s,r,h,n){return i.openBlock(),i.createElementBlock("div",{ref:"flyweight",class:i.normalizeClass(["flyweight",{"flyweight-active":h.actice}]),style:i.normalizeStyle(n.style),onScroll:t[0]||(t[0]=(...l)=>n.scroll&&n.scroll(...l))},[i.createElementVNode("div",P,[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(h.flyweights,(l,a)=>(i.openBlock(),i.createElementBlock("div",{key:a,style:i.normalizeStyle({top:l.top+"px",left:l.left+"px"})},[i.renderSlot(e.$slots,"default",i.mergeProps({ref_for:!0},l),void 0,!0)],4))),128))]),h.flyweights.length?i.renderSlot(e.$slots,"end",{key:0},void 0,!0):i.createCommentVNode("",!0)],38)}const R=E(M,[["render",j],["__scopeId","data-v-ae52e0f1"]]);function B(e,t){return t&&(e=e.replace(/[a-z]/g,"")),e.toLowerCase()}let F={close:{handler(e){this.change(e)},deep:!0},offset:{handler(e){this.margin(e)},deep:!0}},q=["BackGround","BordeR","Height","Width","Top","Right","Bottom","Left"],H={};o.each(q,(e,t,s)=>{e=B(t),H["--"+B(t,!0)]=e,s[e]=function(){this.trigger++}},F);const D={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:F,methods:{exec:f,isEmpty:o.isEmpty,isSimplyType:o.isSimplyType,tr(){let e={};return this.margin(this.offset),o.each(H,(t,s)=>{this.css(e,t,s)}),e},tolower:B,css(e,t,s){let r=this[s]||this.default[s];!r||this.default[s]==r||(e[t]=f(r))},change(e){o.isSimplyType(e)||(this.closecss=o.picker(e,"color=>--s-card-close-color,size=>--s-close-width,bold=>--s-close-height,*"))},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)}},G={class:"card-title"},U=["title"],X={class:"card-content"};function Y(e,t,s,r,h,n){return i.openBlock(),i.createElementBlock("div",{class:"card",key:h.trigger,style:i.normalizeStyle(n.isEmpty(n.style)?n.tr():n.style)},[i.renderSlot(e.$slots,"default",{},()=>[i.renderSlot(e.$slots,"title",{},()=>{var l;return[i.createElementVNode("div",G,[i.createTextVNode(i.toDisplayString(s.show||s.title)+" ",1),i.createElementVNode("div",{class:i.normalizeClass(["card-close",{hide:n.isSimplyType(s.close)?!s.close:!1}]),style:i.normalizeStyle(h.closecss),onClick:t[0]||(t[0]=a=>e.$emit("close")),title:(l=s.close)==null?void 0:l.tips},null,14,U)])]},!0),i.renderSlot(e.$slots,"content",{},()=>[i.createElementVNode("div",X,[i.renderSlot(e.$slots,"inner",{},void 0,!0)])],!0)],!0)],4)}const O=E(D,[["render",Y],["__scopeId","data-v-c1ad1d74"]]),J={name:"Stream",computed:{column(){let{columns:e,T:t}=this,s=e||t;return o.isEmpty(s)?[]:o.isArray(s)?s:[s]}},props:{bridge:{type:String,default:"slot"},type:{type:String,default:"div"},data:{type:Array,default:()=>[]},columns:{type:Array,default:()=>null},T:{type:Array,default:()=>null}},methods:{trigger(e){let t=e[this.bridge]||e.type;return(this.$scopedSlots||this.$slots)[t]?t:"default"}}};function K(e,t,s,r,h,n){return i.openBlock(),i.createBlock(i.resolveDynamicComponent(s.type),i.normalizeProps(i.guardReactiveProps(e.$attrs)),{default:i.withCtx(()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(n.column,l=>i.renderSlot(e.$slots,n.trigger(l),i.mergeProps({key:l.type,ref_for:!0},l))),128))]),_:3},16)}const I=E(J,[["render",K]]),Q=[R,O,I],Z={install(e){Q.forEach(t=>{e.component("S"+t.name,t),e.component(t.name+"S",t)})}};exports.Card=O;exports.Flyweight=R;exports.Stream=I;exports.default=Z;
package/Flyweight.js CHANGED
@@ -1,37 +1,37 @@
1
- import { runer as y, merge as H, isArray as D, each as b, picker as R, isEmpty as G, isSimplyType as I, isString as J } from "@soei/util";
2
- import { openBlock as m, createElementBlock as S, normalizeClass as P, normalizeStyle as k, createElementVNode as T, Fragment as U, renderList as X, renderSlot as p, mergeProps as E, createCommentVNode as K, createTextVNode as Q, toDisplayString as Z, createBlock as tt, resolveDynamicComponent as et, withCtx as st } from "vue";
3
- let it = /(\d+|[+\-\*/]|%)/g, W = {
1
+ import { runer as y, merge as A, isArray as P, each as b, picker as H, isEmpty as V, isSimplyType as F, isString as J } from "@soei/util";
2
+ import { openBlock as m, createElementBlock as S, normalizeClass as D, normalizeStyle as k, createElementVNode as T, Fragment as G, renderList as U, renderSlot as p, mergeProps as X, createCommentVNode as K, createTextVNode as Q, toDisplayString as Z, createBlock as tt, resolveDynamicComponent as et, normalizeProps as st, guardReactiveProps as it, withCtx as lt } from "vue";
3
+ let rt = /(\d+|[+\-\*/]|%)/g, I = {
4
4
  "+": (t, e) => t + e,
5
5
  "-": (t, e) => t - e,
6
6
  "*": (t, e) => t * e,
7
7
  "/": (t, e) => t / e,
8
8
  "%": (t, e, s) => parseFloat(t) / 100 * s
9
- }, j = (t, e) => {
9
+ }, W = (t, e) => {
10
10
  let s;
11
- if (s = y("match", t, it)) {
11
+ if (s = y("match", t, rt)) {
12
12
  let l = s.length, h, r = 0, i, n = [];
13
13
  for (; l--; )
14
- r = s.shift(), r in W ? (h && n.push(h), r === "%" && (n.length = 2), i = r) : +r && n.push(+r), n.length == 2 && (n.push(e), h = W[i].apply(null, n), n.length = 0);
14
+ r = s.shift(), r in I ? (h && n.push(h), r === "%" && (n.length = 2), i = r) : +r && n.push(+r), n.length == 2 && (n.push(e), h = I[i].apply(null, n), n.length = 0);
15
15
  +h || (h = +n.pop()), t = h >> 0;
16
16
  }
17
17
  return t;
18
- }, M = {}, u = (t, e) => (t + "").replace(
18
+ }, j = {}, u = (t, e) => (t + "").replace(
19
19
  /\w+\((.*)\)/g,
20
20
  "$1"
21
21
  ).replace(
22
- M[e] || (M[e] = new RegExp("(?=\\s+|^)(\\d+)(?:\\.\\d{1,})?(?!(?:\\.)*\\d|%|\\w)", "g")),
22
+ j[e] || (j[e] = new RegExp("(?=\\s+|^)(\\d+)(?:\\.\\d{1,})?(?!(?:\\.)*\\d|%|\\w)", "g")),
23
23
  "$1px"
24
24
  );
25
- const F = (t, e) => {
25
+ const O = (t, e) => {
26
26
  const s = t.__vccOpts || t;
27
27
  for (const [l, h] of e)
28
28
  s[l] = h;
29
29
  return s;
30
30
  };
31
- let V = (t) => t == null || t == null, lt = (...t) => {
31
+ let M = (t) => t == null || t == null, ht = (...t) => {
32
32
  console.info("::::FLYWEIGHT", ...t);
33
33
  };
34
- const rt = {
34
+ const nt = {
35
35
  name: "Flyweight",
36
36
  props: {
37
37
  flys: {
@@ -95,7 +95,7 @@ const rt = {
95
95
  },
96
96
  style() {
97
97
  var t = this.w, e = this.h, s = this.Size, l = {};
98
- return H(l, {
98
+ return A(l, {
99
99
  "--width": u(this.realW),
100
100
  "--height": u(this.realH),
101
101
  "--flyweight-content": u(s)
@@ -154,7 +154,7 @@ const rt = {
154
154
  this.rebuild(), this.$emit("resize");
155
155
  }).observe(this.flyweight);
156
156
  } catch (t) {
157
- lt(t);
157
+ ht(t);
158
158
  }
159
159
  this.scrollx = y("hasAttribute", this.flyweight, "scroll-x"), this.BoxRule = /* this.scrollx ? 'clientHeight=>width,clientWidth=>height' : */
160
160
  "clientHeight=>height,clientWidth=>width", this.direction = this.scrollx ? "scrollLeft" : "scrollTop";
@@ -162,9 +162,9 @@ const rt = {
162
162
  methods: {
163
163
  exec: u,
164
164
  trigger(t, e) {
165
- D(t) || (t = t && e ? [[t, e]] : []), t.length && this.lazyrun(() => {
165
+ P(t) || (t = t && e ? [[t, e]] : []), t.length && this.lazyrun(() => {
166
166
  b(t, (s, l) => {
167
- this.$emit(l[0], V(l[1]) ? !0 : l[1]);
167
+ this.$emit(l[0], M(l[1]) ? !0 : l[1]);
168
168
  });
169
169
  });
170
170
  },
@@ -179,7 +179,7 @@ const rt = {
179
179
  if (h[r] == i)
180
180
  return l;
181
181
  }, e.picker, e.id);
182
- V(s) || this.setindex(s);
182
+ M(s) || this.setindex(s);
183
183
  }], this, t);
184
184
  },
185
185
  setindex(t) {
@@ -205,7 +205,7 @@ const rt = {
205
205
  /* 显示区域第一行的索引 */
206
206
  index: s / this.expand >> 0
207
207
  };
208
- H(l, this.space), t.from || e.push(["onscroll", l]);
208
+ A(l, this.space), t.from || e.push(["onscroll", l]);
209
209
  let h = !1;
210
210
  b(
211
211
  this.flyweights,
@@ -240,9 +240,9 @@ const rt = {
240
240
  if (!t)
241
241
  return e.length = t;
242
242
  this.count = t;
243
- let s = this.scrollx, l = this.flyweight, h = R(l, this.BoxRule);
243
+ let s = this.scrollx, l = this.flyweight, h = H(l, this.BoxRule);
244
244
  this.$nextTick(() => {
245
- let r = /true/.test(this.auto), [i, n] = this.offset, c = h.width, d = h.height, a = (j(this.width, c) || c) + i, f = j(this.height, d) + n, g = [c / a >> 0 || 1, d / f >> 0 || 1];
245
+ let r = /true/.test(this.auto), [i, n] = this.offset, c = h.width, d = h.height, a = (W(this.width, c) || c) + i, f = W(this.height, d) + n, g = [c / a >> 0 || 1, d / f >> 0 || 1];
246
246
  s && g.reverse();
247
247
  let [o, w] = g, z = this.padding, v, N = 0, x, B;
248
248
  s ? (x = a, a -= i, B = (_) => (
@@ -260,44 +260,44 @@ const rt = {
260
260
  data: {}
261
261
  });
262
262
  e.length = $ + 1;
263
- let A = [];
264
- d / x > $ / o && A.push(["onend"]), this.flyweight && (this.flyweight[this.direction] = 0), this.$nextTick(() => {
263
+ let R = [];
264
+ d / x > $ / o && R.push(["onend"]), this.flyweight && (this.flyweight[this.direction] = 0), this.$nextTick(() => {
265
265
  this.setindex(this.selectIndex || 0), this.scroll();
266
- }), A.push(["update:space", {
266
+ }), R.push(["update:space", {
267
267
  row: ($ / o >> 0) + 1,
268
268
  column: o,
269
269
  showrow: this.row,
270
270
  showcolumn: this.column
271
- }]), this.trigger(A);
271
+ }]), this.trigger(R);
272
272
  });
273
273
  }
274
274
  }
275
- }, ht = { class: "flyweight-all" };
276
- function nt(t, e, s, l, h, r) {
275
+ }, ot = { class: "flyweight-all" };
276
+ function at(t, e, s, l, h, r) {
277
277
  return m(), S("div", {
278
278
  ref: "flyweight",
279
- class: P(["flyweight", {
279
+ class: D(["flyweight", {
280
280
  "flyweight-active": h.actice
281
281
  }]),
282
282
  style: k(r.style),
283
283
  onScroll: e[0] || (e[0] = (...i) => r.scroll && r.scroll(...i))
284
284
  }, [
285
- T("div", ht, [
286
- (m(!0), S(U, null, X(h.flyweights, (i, n) => (m(), S("div", {
285
+ T("div", ot, [
286
+ (m(!0), S(G, null, U(h.flyweights, (i, n) => (m(), S("div", {
287
287
  key: n,
288
288
  style: k({
289
289
  top: i.top + "px",
290
290
  left: i.left + "px"
291
291
  })
292
292
  }, [
293
- p(t.$slots, "default", E({ ref_for: !0 }, i), void 0, !0)
293
+ p(t.$slots, "default", X({ ref_for: !0 }, i), void 0, !0)
294
294
  ], 4))), 128))
295
295
  ]),
296
296
  h.flyweights.length ? p(t.$slots, "end", { key: 0 }, void 0, !0) : K("", !0)
297
297
  ], 38);
298
298
  }
299
- const ot = /* @__PURE__ */ F(rt, [["render", nt], ["__scopeId", "data-v-ae52e0f1"]]);
300
- function O(t, e) {
299
+ const ct = /* @__PURE__ */ O(nt, [["render", at], ["__scopeId", "data-v-ae52e0f1"]]);
300
+ function E(t, e) {
301
301
  return e && (t = t.replace(/[a-z]/g, "")), t.toLowerCase();
302
302
  }
303
303
  let Y = {
@@ -313,7 +313,7 @@ let Y = {
313
313
  },
314
314
  deep: !0
315
315
  }
316
- }, at = [
316
+ }, ut = [
317
317
  "BackGround",
318
318
  "BordeR",
319
319
  "Height",
@@ -324,15 +324,15 @@ let Y = {
324
324
  "Left"
325
325
  ], q = {};
326
326
  b(
327
- at,
327
+ ut,
328
328
  (t, e, s) => {
329
- t = O(e), q["--" + O(e, !0)] = t, s[t] = function() {
329
+ t = E(e), q["--" + E(e, !0)] = t, s[t] = function() {
330
330
  this.trigger++;
331
331
  };
332
332
  },
333
333
  Y
334
334
  );
335
- const ct = {
335
+ const dt = {
336
336
  name: "Card",
337
337
  // inheritAttrs: false,
338
338
  props: {
@@ -394,29 +394,29 @@ const ct = {
394
394
  watch: Y,
395
395
  methods: {
396
396
  exec: u,
397
- isEmpty: G,
398
- isSimplyType: I,
397
+ isEmpty: V,
398
+ isSimplyType: F,
399
399
  tr() {
400
400
  let t = {};
401
401
  return this.margin(this.offset), b(q, (e, s) => {
402
402
  this.css(t, e, s);
403
403
  }), t;
404
404
  },
405
- tolower: O,
405
+ tolower: E,
406
406
  css(t, e, s) {
407
407
  let l = this[s] || this.default[s];
408
408
  !l || this.default[s] == l || (t[e] = u(l));
409
409
  },
410
410
  change(t) {
411
- I(t) || (this.closecss = R(
411
+ F(t) || (this.closecss = H(
412
412
  t,
413
413
  "color=>--s-card-close-color,size=>--s-close-width,bold=>--s-close-height,*"
414
414
  ));
415
415
  },
416
416
  margin(t) {
417
- H(
417
+ A(
418
418
  this,
419
- R(
419
+ H(
420
420
  J(t) ? t.split(/\s*(?:,|\s+)\s*/) : t,
421
421
  "0=>top,1|0=>right,2|0=>bottom,3|1|0=>left",
422
422
  !0
@@ -428,8 +428,8 @@ const ct = {
428
428
  mounted() {
429
429
  this.change(this.close);
430
430
  }
431
- }, ut = { class: "card-title" }, dt = ["title"], ft = { class: "card-content" };
432
- function gt(t, e, s, l, h, r) {
431
+ }, ft = { class: "card-title" }, gt = ["title"], pt = { class: "card-content" };
432
+ function yt(t, e, s, l, h, r) {
433
433
  return m(), S("div", {
434
434
  class: "card",
435
435
  key: h.trigger,
@@ -439,31 +439,31 @@ function gt(t, e, s, l, h, r) {
439
439
  p(t.$slots, "title", {}, () => {
440
440
  var i;
441
441
  return [
442
- T("div", ut, [
442
+ T("div", ft, [
443
443
  Q(Z(s.show || s.title) + " ", 1),
444
444
  T("div", {
445
- class: P(["card-close", { hide: r.isSimplyType(s.close) ? !s.close : !1 }]),
445
+ class: D(["card-close", { hide: r.isSimplyType(s.close) ? !s.close : !1 }]),
446
446
  style: k(h.closecss),
447
447
  onClick: e[0] || (e[0] = (n) => t.$emit("close")),
448
448
  title: (i = s.close) == null ? void 0 : i.tips
449
- }, null, 14, dt)
449
+ }, null, 14, gt)
450
450
  ])
451
451
  ];
452
452
  }, !0),
453
453
  p(t.$slots, "content", {}, () => [
454
- T("div", ft, [
454
+ T("div", pt, [
455
455
  p(t.$slots, "inner", {}, void 0, !0)
456
456
  ])
457
457
  ], !0)
458
458
  ], !0)
459
459
  ], 4);
460
460
  }
461
- const pt = /* @__PURE__ */ F(ct, [["render", gt], ["__scopeId", "data-v-c1ad1d74"]]), yt = {
461
+ const mt = /* @__PURE__ */ O(dt, [["render", yt], ["__scopeId", "data-v-c1ad1d74"]]), wt = {
462
462
  name: "Stream",
463
463
  computed: {
464
464
  column() {
465
465
  let { columns: t, T: e } = this, s = t || e;
466
- return G(s) ? [] : D(s) ? s : [s];
466
+ return V(s) ? [] : P(s) ? s : [s];
467
467
  }
468
468
  },
469
469
  props: {
@@ -496,27 +496,27 @@ const pt = /* @__PURE__ */ F(ct, [["render", gt], ["__scopeId", "data-v-c1ad1d74
496
496
  }
497
497
  }
498
498
  };
499
- function mt(t, e, s, l, h, r) {
500
- return m(), tt(et(s.type), E(t.$attrs, { data: s.data }), {
501
- default: st(() => [
502
- (m(!0), S(U, null, X(r.column, (i) => p(t.$slots, r.trigger(i), E({
499
+ function xt(t, e, s, l, h, r) {
500
+ return m(), tt(et(s.type), st(it(t.$attrs)), {
501
+ default: lt(() => [
502
+ (m(!0), S(G, null, U(r.column, (i) => p(t.$slots, r.trigger(i), X({
503
503
  key: i.type,
504
504
  ref_for: !0
505
505
  }, i))), 128))
506
506
  ]),
507
507
  _: 3
508
- }, 16, ["data"]);
508
+ }, 16);
509
509
  }
510
- const wt = /* @__PURE__ */ F(yt, [["render", mt]]), xt = [ot, pt, wt], St = {
510
+ const _t = /* @__PURE__ */ O(wt, [["render", xt]]), bt = [ct, mt, _t], Tt = {
511
511
  install(t) {
512
- xt.forEach((e) => {
512
+ bt.forEach((e) => {
513
513
  t.component("S" + e.name, e), t.component(e.name + "S", e);
514
514
  });
515
515
  }
516
516
  };
517
517
  export {
518
- pt as Card,
519
- ot as Flyweight,
520
- wt as Stream,
521
- St as default
518
+ mt as Card,
519
+ ct as Flyweight,
520
+ _t as Stream,
521
+ Tt as default
522
522
  };
package/README.md CHANGED
@@ -6,6 +6,23 @@
6
6
 
7
7
  [![安装](https://img.shields.io/badge/-@soei-ae8aff?style=flat-square)![NPM Downloads by package author](https://img.shields.io/npm-stat/dw/soeiz?style=flat-square)](https://npmjs.com/package/@soei/flyweight)
8
8
 
9
+ ```html
10
+ <!-- 版本 0.3.6 新增属性 bridge, T==columns -->
11
+ <!-- bridge="property" 绑定属性: columns对应属性 -->
12
+ <Stream
13
+ type="组件名|div|Card|s-flyweight|..."
14
+ bridge="key"
15
+ :columns="[{key:1, name:'x'}]|{key:1, name:'x'}"
16
+ [...组件的属性]
17
+ >
18
+ <!-- 插槽 #1中的1 为插槽名称 对应columns中的key对应的值决定, 由bridge指定 -->
19
+ <template #1="{ name }"> {{name}} </template>
20
+ <template #2> 2 </template>
21
+
22
+ <template #default> 默认输出[可以不写] </template>
23
+ </Stream>
24
+ ```
25
+
9
26
  ```html
10
27
  <!-- 版本 0.3.3 新增 属性 w, h, 默认 100% -->
11
28
  <s-flyweight
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.5",
5
+ "version": "0.3.6",
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 h=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},N=(e,t)=>{let i;if(i=h.runer("match",e,W)){let s=i.length,l,u=0,r,o=[];for(;s--;)u=i.shift(),u in R?(l&&o.push(l),u==="%"&&(o.length=2),r=u):+u&&o.push(+u),o.length==2&&(o.push(t),l=R[r].apply(null,o),o.length=0);+l||(l=+o.pop()),e=l>>0}return e},F={},y=(e,t)=>(e+"").replace(/\w+\((.*)\)/g,"$1").replace(F[t]||(F[t]=new RegExp("(?=\\s+|^)(\\d+)(?:\\.\\d{1,})?(?!(?:\\.)*\\d|%|\\w)","g")),"$1px");function k(e,t,i,s,l,u,r,o){var n=typeof e=="function"?e.options:e;t&&(n.render=t,n.staticRenderFns=i,n._compiled=!0),s&&(n.functional=!0),u&&(n._scopeId="data-v-"+u);var f;if(r?(f=function(c){c=c||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!c&&typeof __VUE_SSR_CONTEXT__<"u"&&(c=__VUE_SSR_CONTEXT__),l&&l.call(this,c),c&&c._registeredComponents&&c._registeredComponents.add(r)},n._ssrRegister=f):l&&(f=o?function(){l.call(this,(n.functional?this.parent:this).$root.$options.shadowRoot)}:l),f)if(n.functional){n._injectStyles=f;var d=n.render;n.render=function(a,g){return f.call(g),d(a,g)}}else{var p=n.beforeCreate;n.beforeCreate=p?[].concat(p,f):[f]}return{exports:e,options:n}}let A=e=>e==null||e==null,M=(...e)=>{console.info("::::FLYWEIGHT",...e)};const I={name:"Flyweight",props:{flys:{type:Array,default:()=>[]},width:{type:Number,default:0},height:{type:Number,default:100},w:{type:[Number,String]},h:{type:[Number,String]},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||""},style(){var e=this.w,t=this.h,i=this.Size,s={};return h.merge(s,{"--width":y(this.realW),"--height":y(this.realH),"--flyweight-content":y(i)},t&&{"--flyweight-h":y(t)},e&&s,{"--flyweight-w":y(e)},"mix"),s}},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){M(e)}this.scrollx=h.runer("hasAttribute",this.flyweight,"scroll-x"),this.BoxRule="clientHeight=>height,clientWidth=>width",this.direction=this.scrollx?"scrollLeft":"scrollTop"},methods:{exec:y,trigger(e,t){h.isArray(e)||(e=e&&t?[[e,t]]:[]),e.length&&this.lazyrun(()=>{h.each(e,(i,s)=>{this.$emit(s[0],A(s[1])?!0:s[1])})})},cheackflys(e){if(!this.flys.length)return e&&this.task.push(e),!0},setview(e){h.runer([this.cheackflys,t=>{t=t||{};let i=t.index||h.each(this.flys,(s,l,u,r)=>{if(l[u]==r)return s},t.picker,t.id);A(i)||this.setindex(i)}],this,e)},setindex(e){h.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(()=>{h.runer(e)},t||this.lazy)},run(e){let t=[],i=h.runer(this.direction,e.target),s={offset:i,top:i,width:this.realW,height:this.realH,index:i/this.expand>>0};h.merge(s,this.space),e.from||t.push(["onscroll",s]);let l=!1;h.each(this.flyweights,(u,r,o,n,f,d,p,c,a)=>{if(o=u/f>>0,c=o+n*(+(o<d%n)+(d/n>>0)),a=c*f+u%f,a>=this.count){l||(t.push(["onend"]),l=!0);return}r.index=c,r.i=a,r.data=this.flys[a];let g=[c*this.expand+r.x,r.space];p&&g.reverse(),r.top=g[0],r.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,l=h.picker(s,this.BoxRule);this.$nextTick(()=>{let u=/true/.test(this.auto),[r,o]=this.offset,n=l.width,f=l.height,d=(N(this.width,n)||n)+r,p=N(this.height,f)+o,c=[n/d>>0||1,f/p>>0||1];i&&c.reverse();let[a,g]=c,x=this.padding,v,b=0,_,$;i?(_=d,d-=r,$=m=>m*(p-o)+(m+1)*o):(u?(d=(n-r*(a+2*x-1))/a,v=!x*r,b=x*r):(v=0,b=(n%d+r*a)/(a+1)>>0,d-=r),$=m=>m*(d+v)+(m+1)*b,_=p),this.row=g+2,this.column=a,this.realH=p-o,this.realW=d,this.expand=_,this.Size=Math.ceil(e/a)*_;let S=Math.min(e,a*this.row),w=S-1,T;for(;S-- >0;)T=w-S,this.$set(t,T,{x:r,y:o,width:d,height:p-o,space:$(T%a),data:{}});t.length=w+1;let C=[];f/_>w/a&&C.push(["onend"]),this.flyweight&&(this.flyweight[this.direction]=0),this.$nextTick(()=>{this.setindex(this.selectIndex||0),this.scroll()}),C.push(["update:space",{row:(w/a>>0)+1,column:a,showrow:this.row,showcolumn:this.column}]),this.trigger(C)})}}};var U=function(){var t=this,i=t._self._c;return i("div",{ref:"flyweight",staticClass:"flyweight",class:{"flyweight-active":t.actice},style:t.style,on:{scroll:t.scroll}},[i("div",{staticClass:"flyweight-all"},t._l(t.flyweights,function(s,l){return i("div",{key:l,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)},X=[],j=k(I,U,X,!1,null,"3416ac53",null,null);const O=j.exports;function z(e,t){return t&&(e=e.replace(/[a-z]/g,"")),e.toLowerCase()}let E={close:{handler(e){this.change(e)},deep:!0},offset:{handler(e){this.margin(e)},deep:!0}},G=["BackGround","BordeR","Height","Width","Top","Right","Bottom","Left"],H={};h.each(G,(e,t,i)=>{e=z(t),H["--"+z(t,!0)]=e,i[e]=function(){this.trigger++}},E);const V={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:E,methods:{exec:y,isEmpty:h.isEmpty,isSimplyType:h.isSimplyType,tr(){let e={};return this.margin(this.offset),h.each(H,(t,i)=>{this.css(e,t,i)}),e},tolower:z,css(e,t,i){let s=this[i]||this.default[i];!s||this.default[i]==s||(e[t]=y(s))},change(e){h.isSimplyType(e)||(this.closecss=h.picker(e,"color=>--s-card-close-color,size=>--s-close-width,bold=>--s-close-height,*"))},margin(e){h.merge(this,h.picker(h.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 q=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(){var s;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,attrs:{title:(s=t.close)==null?void 0:s.tips},on:{click:function(l){return t.$emit("close")}}})])]}),t._t("content",function(){return[i("div",{staticClass:"card-content"},[t._t("inner")],2)]})]})],2)},P=[],Y=k(V,q,P,!1,null,"16139b86",null,null);const L=Y.exports,D={name:"Stream",computed:{column(){let{columns:e,T:t}=this,i=e||t;return h.isEmpty(i)?[]:h.isArray(i)?i:[i]}},props:{bridge:{type:String,default:"slot"},type:{type:String,default:"div"},data:{type:Array,default:()=>[]},columns:{type:Array,default:()=>null},T:{type:Array,default:()=>null}},methods:{trigger(e){let t=e[this.bridge]||e.type;return(this.$scopedSlots||this.$slots)[t]?t:"default"}}};var J=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.column,function(s){return[t._t(t.trigger(s),null,null,s)]})],2)},K=[],Q=k(D,J,K,!1,null,null,null,null);const B=Q.exports,Z=[O,L,B],tt={install(e){Z.forEach(t=>{e.component("S"+t.name,t),e.component(t.name+"S",t)})}};exports.Card=L;exports.Flyweight=O;exports.Stream=B;exports.default=tt;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=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},N=(e,t)=>{let i;if(i=h.runer("match",e,W)){let s=i.length,l,u=0,r,o=[];for(;s--;)u=i.shift(),u in R?(l&&o.push(l),u==="%"&&(o.length=2),r=u):+u&&o.push(+u),o.length==2&&(o.push(t),l=R[r].apply(null,o),o.length=0);+l||(l=+o.pop()),e=l>>0}return e},F={},y=(e,t)=>(e+"").replace(/\w+\((.*)\)/g,"$1").replace(F[t]||(F[t]=new RegExp("(?=\\s+|^)(\\d+)(?:\\.\\d{1,})?(?!(?:\\.)*\\d|%|\\w)","g")),"$1px");function k(e,t,i,s,l,u,r,o){var n=typeof e=="function"?e.options:e;t&&(n.render=t,n.staticRenderFns=i,n._compiled=!0),s&&(n.functional=!0),u&&(n._scopeId="data-v-"+u);var f;if(r?(f=function(c){c=c||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!c&&typeof __VUE_SSR_CONTEXT__<"u"&&(c=__VUE_SSR_CONTEXT__),l&&l.call(this,c),c&&c._registeredComponents&&c._registeredComponents.add(r)},n._ssrRegister=f):l&&(f=o?function(){l.call(this,(n.functional?this.parent:this).$root.$options.shadowRoot)}:l),f)if(n.functional){n._injectStyles=f;var d=n.render;n.render=function(a,g){return f.call(g),d(a,g)}}else{var p=n.beforeCreate;n.beforeCreate=p?[].concat(p,f):[f]}return{exports:e,options:n}}let A=e=>e==null||e==null,M=(...e)=>{console.info("::::FLYWEIGHT",...e)};const I={name:"Flyweight",props:{flys:{type:Array,default:()=>[]},width:{type:Number,default:0},height:{type:Number,default:100},w:{type:[Number,String]},h:{type:[Number,String]},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||""},style(){var e=this.w,t=this.h,i=this.Size,s={};return h.merge(s,{"--width":y(this.realW),"--height":y(this.realH),"--flyweight-content":y(i)},t&&{"--flyweight-h":y(t)},e&&s,{"--flyweight-w":y(e)},"mix"),s}},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){M(e)}this.scrollx=h.runer("hasAttribute",this.flyweight,"scroll-x"),this.BoxRule="clientHeight=>height,clientWidth=>width",this.direction=this.scrollx?"scrollLeft":"scrollTop"},methods:{exec:y,trigger(e,t){h.isArray(e)||(e=e&&t?[[e,t]]:[]),e.length&&this.lazyrun(()=>{h.each(e,(i,s)=>{this.$emit(s[0],A(s[1])?!0:s[1])})})},cheackflys(e){if(!this.flys.length)return e&&this.task.push(e),!0},setview(e){h.runer([this.cheackflys,t=>{t=t||{};let i=t.index||h.each(this.flys,(s,l,u,r)=>{if(l[u]==r)return s},t.picker,t.id);A(i)||this.setindex(i)}],this,e)},setindex(e){h.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(()=>{h.runer(e)},t||this.lazy)},run(e){let t=[],i=h.runer(this.direction,e.target),s={offset:i,top:i,width:this.realW,height:this.realH,index:i/this.expand>>0};h.merge(s,this.space),e.from||t.push(["onscroll",s]);let l=!1;h.each(this.flyweights,(u,r,o,n,f,d,p,c,a)=>{if(o=u/f>>0,c=o+n*(+(o<d%n)+(d/n>>0)),a=c*f+u%f,a>=this.count){l||(t.push(["onend"]),l=!0);return}r.index=c,r.i=a,r.data=this.flys[a];let g=[c*this.expand+r.x,r.space];p&&g.reverse(),r.top=g[0],r.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,l=h.picker(s,this.BoxRule);this.$nextTick(()=>{let u=/true/.test(this.auto),[r,o]=this.offset,n=l.width,f=l.height,d=(N(this.width,n)||n)+r,p=N(this.height,f)+o,c=[n/d>>0||1,f/p>>0||1];i&&c.reverse();let[a,g]=c,x=this.padding,v,b=0,_,$;i?(_=d,d-=r,$=m=>m*(p-o)+(m+1)*o):(u?(d=(n-r*(a+2*x-1))/a,v=!x*r,b=x*r):(v=0,b=(n%d+r*a)/(a+1)>>0,d-=r),$=m=>m*(d+v)+(m+1)*b,_=p),this.row=g+2,this.column=a,this.realH=p-o,this.realW=d,this.expand=_,this.Size=Math.ceil(e/a)*_;let S=Math.min(e,a*this.row),w=S-1,T;for(;S-- >0;)T=w-S,this.$set(t,T,{x:r,y:o,width:d,height:p-o,space:$(T%a),data:{}});t.length=w+1;let C=[];f/_>w/a&&C.push(["onend"]),this.flyweight&&(this.flyweight[this.direction]=0),this.$nextTick(()=>{this.setindex(this.selectIndex||0),this.scroll()}),C.push(["update:space",{row:(w/a>>0)+1,column:a,showrow:this.row,showcolumn:this.column}]),this.trigger(C)})}}};var U=function(){var t=this,i=t._self._c;return i("div",{ref:"flyweight",staticClass:"flyweight",class:{"flyweight-active":t.actice},style:t.style,on:{scroll:t.scroll}},[i("div",{staticClass:"flyweight-all"},t._l(t.flyweights,function(s,l){return i("div",{key:l,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)},X=[],j=k(I,U,X,!1,null,"3416ac53",null,null);const O=j.exports;function z(e,t){return t&&(e=e.replace(/[a-z]/g,"")),e.toLowerCase()}let E={close:{handler(e){this.change(e)},deep:!0},offset:{handler(e){this.margin(e)},deep:!0}},G=["BackGround","BordeR","Height","Width","Top","Right","Bottom","Left"],H={};h.each(G,(e,t,i)=>{e=z(t),H["--"+z(t,!0)]=e,i[e]=function(){this.trigger++}},E);const V={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:E,methods:{exec:y,isEmpty:h.isEmpty,isSimplyType:h.isSimplyType,tr(){let e={};return this.margin(this.offset),h.each(H,(t,i)=>{this.css(e,t,i)}),e},tolower:z,css(e,t,i){let s=this[i]||this.default[i];!s||this.default[i]==s||(e[t]=y(s))},change(e){h.isSimplyType(e)||(this.closecss=h.picker(e,"color=>--s-card-close-color,size=>--s-close-width,bold=>--s-close-height,*"))},margin(e){h.merge(this,h.picker(h.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 q=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(){var s;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,attrs:{title:(s=t.close)==null?void 0:s.tips},on:{click:function(l){return t.$emit("close")}}})])]}),t._t("content",function(){return[i("div",{staticClass:"card-content"},[t._t("inner")],2)]})]})],2)},P=[],Y=k(V,q,P,!1,null,"16139b86",null,null);const L=Y.exports,D={name:"Stream",computed:{column(){let{columns:e,T:t}=this,i=e||t;return h.isEmpty(i)?[]:h.isArray(i)?i:[i]}},props:{bridge:{type:String,default:"slot"},type:{type:String,default:"div"},data:{type:Array,default:()=>[]},columns:{type:Array,default:()=>null},T:{type:Array,default:()=>null}},methods:{trigger(e){let t=e[this.bridge]||e.type;return(this.$scopedSlots||this.$slots)[t]?t:"default"}}};var J=function(){var t=this,i=t._self._c;return i(t.type,t._b({tag:"component"},"component",t.$attrs,!1),[t._l(t.column,function(s){return t._t(t.trigger(s),null,null,s)})],2)},K=[],Q=k(D,J,K,!1,null,null,null,null);const B=Q.exports,Z=[O,L,B],tt={install(e){Z.forEach(t=>{e.component("S"+t.name,t),e.component(t.name+"S",t)})}};exports.Card=L;exports.Flyweight=O;exports.Stream=B;exports.default=tt;
package/vue2/index.js CHANGED
@@ -510,8 +510,8 @@ const tt = Z.exports, et = {
510
510
  };
511
511
  var st = function() {
512
512
  var t = this, s = t._self._c;
513
- return s(t.type, t._b({ tag: "component", attrs: { data: t.data } }, "component", t.$attrs, !1), [t._l(t.column, function(i) {
514
- return [t._t(t.trigger(i), null, null, i)];
513
+ return s(t.type, t._b({ tag: "component" }, "component", t.$attrs, !1), [t._l(t.column, function(i) {
514
+ return t._t(t.trigger(i), null, null, i);
515
515
  })], 2);
516
516
  }, it = [], lt = /* @__PURE__ */ F(
517
517
  et,