@soei/flyweight 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Flyweight.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@soei/util"),s=require("vue");let H=/(\d+|[+\-\*/]|%)/g,b={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t,l)=>parseFloat(e)/100*l},v=(e,t)=>{let l;if(l=c.runer("match",e,H)){let h=l.length,i,r=0,o,n=[];for(;h--;)r=l.shift(),r in b?(i&&n.push(i),r==="%"&&(n.length=2),o=r):+r&&n.push(+r),n.length==2&&(n.push(t),console.log(n,o,"W"),i=b[o].apply(null,n),n.length=0);+i||(i=+n.pop()),e=i>>0}return e},B=e=>e.replace(/\w+\((.*)\)/g,"$1").replace(/(?=\D)0(?!\w)/,"0px");const z=(e,t)=>{const l=e.__vccOpts||e;for(const[h,i]of t)l[h]=i;return l};let T=e=>e==null||e==null,C=(...e)=>{console.info("::::FLYWEIGHT",...e)};const O={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}},computed:{flyweight(){return this.$refs.flyweight}},data(){return{flyweights:[],actice:!1,Height:null,column:1,row:1,fwheight:10,count:0,task:[],realW:0,realH:0}},watch:{flys(e){this.count=e.length,this.re();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,l)=>{e[t]=l}),this.setindex(this.index);try{new ResizeObserver(()=>{this.re(),this.$emit("resize")}).observe(this.flyweight)}catch(e){C(e)}},methods:{trigger(e,t){this.lazyrun(()=>{c.isArray(e)||(e=[[e,t]]),c.each(e,(l,h)=>{this.$emit(h[0],T(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 l=t.index||c.each(this.flys,(h,i,r,o)=>{if(i[r]==o)return h},t.picker,t.id);T(l)||this.setindex(l)}],this,e)},setindex(e){c.runer([this.cheackflys,({index:t})=>{this.$nextTick(()=>{let l=t/this.column>>0,h=this.fwheight;(this.flyweight.scrollTop/h>>0)+this.row-l-1>0||(this.flyweight.scrollTop=l*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=[],l=c.picker(e.target,"scrollTop=>top");c.merge(l,{height:this.realH,width:this.realW,index:l.top/this.fwheight>>0},this.space,"mix"),e.from||t.push(["onscroll",l]);let h=!1;c.each(this.flyweights,(i,r,o,n,d,u,a,f)=>{if(o=i/d>>0,a=o+n*(+(o<u%n)+(u/n>>0)),f=a*d+i%d,f>=this.count){h||(t.push(["onend"]),h=!0);return}r.index=a,r.top=a*this.fwheight,r.data=this.flys[f]},null,this.row,this.column,l.index),this.trigger(t),t=null},scroll(e){this.run(e||{target:this.flyweight,from:"space"})},re(){let e=this.count||this.flys.length,t=this.flyweights;if(!e)return t.length=e;this.count=e;let l=this.flyweight,h=c.picker(l,"clientHeight=>height,clientWidth=>width");this.$nextTick(()=>{let i=/true/.test(this.auto),[r,o]=this.offset,n=h.width,d=h.height,u=(v(this.width,n)||n)+r,a=v(this.height,d)+o;this.realH=a-o;let f=n/u>>0||1,p=d/a>>0;this.row=p+2,this.column=f,this.fwheight=a;let m,x=0;i?(u=(n/f>>0)-r/f*(f-1),m=r):(m=0,x=r/(f+1)*f+n%u/(f+1)>>0,u-=r),this.realW=u,this.Height=Math.ceil(e/f)*a;let w=Math.min(e,f*this.row),y=w-1,g,_,k;for(;w-- >0;)g=y-w,k=this.flys[g],l=t[g],p=g/f>>0,_=g%f,this.$set(t,g,{data:k,top:p*a,left:_*(u+m)+(_+1)*x,index:p});t.length=y+1;let S=[];d/a>y/f&&S.push(["onend"]),this.scroll(),S.push(["update:space",{row:(y/f>>0)+1,column:f,showrow:this.row,showcolumn:this.column}]),this.trigger(S)})}}};function F(e,t,l,h,i,r){return s.openBlock(),s.createElementBlock("div",{ref:"flyweight",class:s.normalizeClass(["flyweight",{"flyweight-active":i.actice}]),style:s.normalizeStyle({"--width":i.realW+"px","--height":i.realH+"px"}),onScroll:t[0]||(t[0]=(...o)=>r.scroll&&r.scroll(...o))},[s.createElementVNode("div",{class:"flyweight-all",style:s.normalizeStyle({"--flyweight-height":i.Height+"px"})},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(i.flyweights,(o,n)=>(s.openBlock(),s.createElementBlock("div",{key:n,style:s.normalizeStyle({top:o.top+"px",left:o.left+"px"})},[s.renderSlot(e.$slots,"default",{data:o.data,index:o.index},void 0,!0)],4))),128))],4),i.flyweights.length?s.renderSlot(e.$slots,"end",{key:0},void 0,!0):s.createCommentVNode("",!0)],38)}const N=z(O,[["render",F],["__scopeId","data-v-292d1069"]]);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:{},$$attrs:{},top:"0",right:"0",bottom:"0",left:"0"}},watch:{close:{handler(e){this.change(e)},deep:!0},offset:{handler(e){this.offser(e)},deep:!0}},methods:{exec:B,isEmpty:c.isEmpty,isSimplyType:c.isSimplyType,change(e){c.isSimplyType(e)||(this.closecss=c.picker(e,"color=>--s-card-close-color,*"))},offser(e){e=c.isString(e)?e.split(/\s*(?:,|\s+)\s*/):e;let t=c.picker(e,"0=>top,1|0=>right,2|0=>bottom,3|1|0=>left",!0);c.each(t,(l,h,i)=>{i[l]=h+"px"},t),c.merge(this,t,!0)}},mounted(){this.change(this.close),this.offser(this.offset)}},W={class:"card-title"},$={class:"card-content"};function j(e,t,l,h,i,r){return s.openBlock(),s.createElementBlock("div",{class:"card",style:s.normalizeStyle({"--card-background-color":l.background,"--card-bw":l.border,"--card-height":r.exec(l.height),"--card-width":r.exec(l.width),"--top":i.top,"--right":i.right,"--bottom":i.bottom,"--left":i.left})},[s.renderSlot(e.$slots,"default",{},()=>[s.renderSlot(e.$slots,"title",{},()=>[s.createElementVNode("div",W,[s.createTextVNode(s.toDisplayString(l.show||l.title)+" ",1),s.createElementVNode("div",{class:s.normalizeClass(["card-close",{hide:r.isSimplyType(l.close)?!l.close:!1}]),style:s.normalizeStyle(i.closecss),onClick:t[0]||(t[0]=o=>e.$emit("close"))},null,6)])],!0),s.renderSlot(e.$slots,"content",{},()=>[s.createElementVNode("div",$,[s.renderSlot(e.$slots,"inner",{},void 0,!0)])],!0)],!0)],4)}const E=z(V,[["render",j],["__scopeId","data-v-84f183dc"]]),I=[N,E],L={install(e){I.forEach(t=>{e.component("S"+t.name,t),e.component(t.name+"S",t)})}};exports.Card=E;exports.Flyweight=N;exports.default=L;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("@soei/util"),l=require("vue");let H=/(\d+|[+\-\*/]|%)/g,T={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t,s)=>parseFloat(e)/100*s},v=(e,t)=>{let s;if(s=n.runer("match",e,H)){let h=s.length,r,i=0,c,o=[];for(;h--;)i=s.shift(),i in T?(r&&o.push(r),i==="%"&&(o.length=2),c=i):+i&&o.push(+i),o.length==2&&(o.push(t),console.log(o,c,"W"),r=T[c].apply(null,o),o.length=0);+r||(r=+o.pop()),e=r>>0}return e},z=e=>e.replace(/\w+\((.*)\)/g,"$1").replace(/(?=\D)0(?!\w)/,"0px");const B=(e,t)=>{const s=e.__vccOpts||e;for(const[h,r]of t)s[h]=r;return s};let $=e=>e==null||e==null,C=(...e)=>{console.info("::::FLYWEIGHT",...e)};const O={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,Height:null,column:1,row:1,fwheight:10,count:0,task:[],realW:0,realH:0}},watch:{flys(e){this.count=e.length,this.re();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.re(),this.$emit("resize")}).observe(this.flyweight)}catch(e){C(e)}},methods:{trigger(e,t){this.lazyrun(()=>{n.isArray(e)||(e=[[e,t]]),n.each(e,(s,h)=>{this.$emit(h[0],$(h[1])?!0:h[1])})})},cheackflys(e){if(!this.flys.length)return e&&this.task.push(e),!0},setview(e){n.runer([this.cheackflys,t=>{t=t||{};let s=t.index||n.each(this.flys,(h,r,i,c)=>{if(r[i]==c)return h},t.picker,t.id);$(s)||this.setindex(s)}],this,e)},setindex(e){n.runer([this.cheackflys,({index:t})=>{this.$nextTick(()=>{let s=t/this.column>>0,h=this.fwheight;(this.flyweight.scrollTop/h>>0)+this.row-s-1>0||(this.flyweight.scrollTop=s*h,this.scroll())})}],this,{index:e})},lazyrun(e,t){clearTimeout(this.time),this.time=setTimeout(()=>{n.runer(e)},t||this.lazy)},run(e){let t=[],s=n.picker(e.target,"scrollTop=>top");n.merge(s,{height:this.realH,width:this.realW,index:s.top/this.fwheight>>0},this.space,"mix"),e.from||t.push(["onscroll",s]);let h=!1;n.each(this.flyweights,(r,i,c,o,d,u,f,a)=>{if(c=r/d>>0,f=c+o*(+(c<u%o)+(u/o>>0)),a=f*d+r%d,a>=this.count){h||(t.push(["onend"]),h=!0);return}i.index=f,i.i=a,i.top=f*this.fwheight,i.data=this.flys[a],i.width=this.realW,i.height=this.realH},null,this.row,this.column,s.index),this.trigger(t),t=null},scroll(e){this.run(e||{target:this.flyweight,from:"space"})},re(){let e=this.count||this.flys.length,t=this.flyweights;if(!e)return t.length=e;this.count=e;let s=this.flyweight,h=n.picker(s,"clientHeight=>height,clientWidth=>width");this.$nextTick(()=>{let r=/true/.test(this.auto),[i,c]=this.offset,o=h.width,d=h.height,u=(v(this.width,o)||o)+i,f=v(this.height,d)+c;this.realH=f-c;let a=o/u>>0||1,g=d/f>>0,m=this.padding;this.row=g+2,this.column=a,this.fwheight=f;let w,_=0;r?(u=(o-i*(a+2*m-1))/a,w=!m*i,_=m*i):(w=0,_=(o%u+i*a)/(a+1)>>0,u-=i),this.realW=u,this.Height=Math.ceil(e/a)*f;let S=Math.min(e,a*this.row),y=S-1,p,k,b;for(;S-- >0;)p=y-S,b=this.flys[p],s=t[p],g=p/a>>0,k=p%a,this.$set(t,p,{data:b,top:g*f,left:k*(u+w)+(k+1)*_,index:g});t.length=y+1;let x=[];d/f>y/a&&x.push(["onend"]),this.scroll(),x.push(["update:space",{row:(y/a>>0)+1,column:a,showrow:this.row,showcolumn:this.column}]),this.trigger(x)})}}};function W(e,t,s,h,r,i){return l.openBlock(),l.createElementBlock("div",{ref:"flyweight",class:l.normalizeClass(["flyweight",{"flyweight-active":r.actice}]),style:l.normalizeStyle({"--width":r.realW+"px","--height":r.realH+"px"}),onScroll:t[0]||(t[0]=(...c)=>i.scroll&&i.scroll(...c))},[l.createElementVNode("div",{class:"flyweight-all",style:l.normalizeStyle({"--flyweight-height":r.Height+"px"})},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(r.flyweights,(c,o)=>(l.openBlock(),l.createElementBlock("div",{key:o,style:l.normalizeStyle({top:c.top+"px",left:c.left+"px"})},[l.renderSlot(e.$slots,"default",l.mergeProps({ref_for:!0},c),void 0,!0)],4))),128))],4),r.flyweights.length?l.renderSlot(e.$slots,"end",{key:0},void 0,!0):l.createCommentVNode("",!0)],38)}const N=B(O,[["render",W],["__scopeId","data-v-4f09502c"]]);const F={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:{},$$attrs:{},top:"0",right:"0",bottom:"0",left:"0",style:{}}},computed:{style(){let e={};return n.each(["BackGround","Border","Height","Width","Top","Right","BottoM","Left"],(t,s)=>{e["--"+s.replace(/[a-z]/g,"")]=z(this[s.toLowerCase()])}),e}},watch:{close:{handler(e){this.change(e)},deep:!0},offset:{handler(e){this.offser(e)},deep:!0}},methods:{exec:z,isEmpty:n.isEmpty,isSimplyType:n.isSimplyType,change(e){n.isSimplyType(e)||(this.closecss=n.picker(e,"color=>--s-card-close-color,*"))},offser(e){e=n.isString(e)?e.split(/\s*(?:,|\s+)\s*/):e;let t=n.picker(e,"0=>top,1|0=>right,2|0=>bottom,3|1|0=>left",!0);n.each(t,(s,h,r)=>{r[s]=h+"px"},t),n.merge(this,t,!0)}},mounted(){this.change(this.close),this.offser(this.offset)}},L={class:"card-title"},V={class:"card-content"};function M(e,t,s,h,r,i){return l.openBlock(),l.createElementBlock("div",{class:"card",style:l.normalizeStyle(i.style)},[l.renderSlot(e.$slots,"default",{},()=>[l.renderSlot(e.$slots,"title",{},()=>[l.createElementVNode("div",L,[l.createTextVNode(l.toDisplayString(s.show||s.title)+" ",1),l.createElementVNode("div",{class:l.normalizeClass(["card-close",{hide:i.isSimplyType(s.close)?!s.close:!1}]),style:l.normalizeStyle(r.closecss),onClick:t[0]||(t[0]=c=>e.$emit("close"))},null,6)])],!0),l.renderSlot(e.$slots,"content",{},()=>[l.createElementVNode("div",V,[l.renderSlot(e.$slots,"inner",{},void 0,!0)])],!0)],!0)],4)}const E=B(F,[["render",M],["__scopeId","data-v-ca61ca3d"]]),j=[N,E],I={install(e){j.forEach(t=>{e.component("S"+t.name,t),e.component(t.name+"S",t)})}};exports.Card=E;exports.Flyweight=N;exports.default=I;
package/Flyweight.js CHANGED
@@ -1,31 +1,31 @@
1
- import { runer as w, isArray as L, each as m, picker as k, merge as $, isEmpty as j, isSimplyType as O, isString as A } from "@soei/util";
2
- import { openBlock as _, createElementBlock as x, normalizeClass as E, normalizeStyle as g, createElementVNode as b, Fragment as B, renderList as V, renderSlot as d, createCommentVNode as D, createTextVNode as M, toDisplayString as R } from "vue";
3
- let G = /(\d+|[+\-\*/]|%)/g, C = {
4
- "+": (t, e) => t + e,
5
- "-": (t, e) => t - e,
6
- "*": (t, e) => t * e,
7
- "/": (t, e) => t / e,
8
- "%": (t, e, s) => parseFloat(t) / 100 * s
9
- }, F = (t, e) => {
1
+ import { runer as m, isArray as j, each as g, picker as b, merge as L, isEmpty as A, isSimplyType as W, isString as M } from "@soei/util";
2
+ import { openBlock as _, createElementBlock as x, normalizeClass as E, normalizeStyle as p, createElementVNode as k, Fragment as R, renderList as V, renderSlot as d, mergeProps as D, createCommentVNode as G, createTextVNode as P, toDisplayString as U } from "vue";
3
+ let Y = /(\d+|[+\-\*/]|%)/g, B = {
4
+ "+": (e, t) => e + t,
5
+ "-": (e, t) => e - t,
6
+ "*": (e, t) => e * t,
7
+ "/": (e, t) => e / t,
8
+ "%": (e, t, s) => parseFloat(e) / 100 * s
9
+ }, C = (e, t) => {
10
10
  let s;
11
- if (s = w("match", t, G)) {
12
- let h = s.length, i, l = 0, n, r = [];
13
- for (; h--; )
14
- l = s.shift(), l in C ? (i && r.push(i), l === "%" && (r.length = 2), n = l) : +l && r.push(+l), r.length == 2 && (r.push(e), console.log(r, n, "W"), i = C[n].apply(null, r), r.length = 0);
15
- +i || (i = +r.pop()), t = i >> 0;
11
+ if (s = m("match", e, Y)) {
12
+ let r = s.length, l, i = 0, o, h = [];
13
+ for (; r--; )
14
+ i = s.shift(), i in B ? (l && h.push(l), i === "%" && (h.length = 2), o = i) : +i && h.push(+i), h.length == 2 && (h.push(t), console.log(h, o, "W"), l = B[o].apply(null, h), h.length = 0);
15
+ +l || (l = +h.pop()), e = l >> 0;
16
16
  }
17
- return t;
18
- }, U = (t) => t.replace(/\w+\((.*)\)/g, "$1").replace(/(?=\D)0(?!\w)/, "0px");
19
- const I = (t, e) => {
20
- const s = t.__vccOpts || t;
21
- for (const [h, i] of e)
22
- s[h] = i;
17
+ return e;
18
+ }, O = (e) => e.replace(/\w+\((.*)\)/g, "$1").replace(/(?=\D)0(?!\w)/, "0px");
19
+ const I = (e, t) => {
20
+ const s = e.__vccOpts || e;
21
+ for (const [r, l] of t)
22
+ s[r] = l;
23
23
  return s;
24
24
  };
25
- let W = (t) => t == null || t == null, Y = (...t) => {
26
- console.info("::::FLYWEIGHT", ...t);
25
+ let F = (e) => e == null || e == null, q = (...e) => {
26
+ console.info("::::FLYWEIGHT", ...e);
27
27
  };
28
- const q = {
28
+ const J = {
29
29
  name: "Flyweight",
30
30
  props: {
31
31
  flys: {
@@ -71,6 +71,10 @@ const q = {
71
71
  space: {
72
72
  type: Object,
73
73
  default: () => null
74
+ },
75
+ padding: {
76
+ type: Boolean,
77
+ default: !1
74
78
  }
75
79
  },
76
80
  computed: {
@@ -93,176 +97,173 @@ const q = {
93
97
  };
94
98
  },
95
99
  watch: {
96
- flys(t) {
97
- this.count = t.length, this.re();
98
- let e = this.task.shift();
99
- e && this.$nextTick(() => {
100
- this.setview(e);
100
+ flys(e) {
101
+ this.count = e.length, this.re();
102
+ let t = this.task.shift();
103
+ t && this.$nextTick(() => {
104
+ this.setview(t);
101
105
  });
102
106
  },
103
107
  view: {
104
- handler(t) {
105
- this.setview(t);
108
+ handler(e) {
109
+ this.setview(e);
106
110
  },
107
111
  immediate: !0,
108
112
  deep: !0
109
113
  },
110
- index(t) {
111
- this.setindex(t);
114
+ index(e) {
115
+ this.setindex(e);
112
116
  },
113
- top(t) {
114
- this.flyweight.scrollTop = t;
117
+ top(e) {
118
+ this.flyweight.scrollTop = e;
115
119
  },
116
- left(t) {
117
- this.flyweight.scrollLeft = t;
120
+ left(e) {
121
+ this.flyweight.scrollLeft = e;
118
122
  }
119
123
  },
120
124
  mounted() {
121
- this.flyweights = [], this.$set || (this.$set = (t, e, s) => {
122
- t[e] = s;
125
+ this.flyweights = [], this.$set || (this.$set = (e, t, s) => {
126
+ e[t] = s;
123
127
  }), this.setindex(this.index);
124
128
  try {
125
129
  new ResizeObserver(() => {
126
130
  this.re(), this.$emit("resize");
127
131
  }).observe(this.flyweight);
128
- } catch (t) {
129
- Y(t);
132
+ } catch (e) {
133
+ q(e);
130
134
  }
131
135
  },
132
136
  methods: {
133
- trigger(t, e) {
137
+ trigger(e, t) {
134
138
  this.lazyrun(() => {
135
- L(t) || (t = [[t, e]]), m(t, (s, h) => {
136
- this.$emit(h[0], W(h[1]) ? !0 : h[1]);
139
+ j(e) || (e = [[e, t]]), g(e, (s, r) => {
140
+ this.$emit(r[0], F(r[1]) ? !0 : r[1]);
137
141
  });
138
142
  });
139
143
  },
140
- cheackflys(t) {
144
+ cheackflys(e) {
141
145
  if (!this.flys.length)
142
- return t && this.task.push(t), !0;
146
+ return e && this.task.push(e), !0;
143
147
  },
144
- setview(t) {
145
- w([this.cheackflys, (e) => {
146
- e = e || {};
147
- let s = e.index || m(this.flys, (h, i, l, n) => {
148
- if (i[l] == n)
149
- return h;
150
- }, e.picker, e.id);
151
- W(s) || this.setindex(s);
152
- }], this, t);
148
+ setview(e) {
149
+ m([this.cheackflys, (t) => {
150
+ t = t || {};
151
+ let s = t.index || g(this.flys, (r, l, i, o) => {
152
+ if (l[i] == o)
153
+ return r;
154
+ }, t.picker, t.id);
155
+ F(s) || this.setindex(s);
156
+ }], this, e);
153
157
  },
154
- setindex(t) {
155
- w([this.cheackflys, ({ index: e }) => {
158
+ setindex(e) {
159
+ m([this.cheackflys, ({ index: t }) => {
156
160
  this.$nextTick(() => {
157
- let s = e / this.column >> 0, h = this.fwheight;
158
- (this.flyweight.scrollTop / h >> 0) + this.row - s - 1 > 0 || (this.flyweight.scrollTop = s * h, this.scroll());
161
+ let s = t / this.column >> 0, r = this.fwheight;
162
+ (this.flyweight.scrollTop / r >> 0) + this.row - s - 1 > 0 || (this.flyweight.scrollTop = s * r, this.scroll());
159
163
  });
160
- }], this, { index: t });
164
+ }], this, { index: e });
161
165
  },
162
- lazyrun(t, e) {
166
+ lazyrun(e, t) {
163
167
  clearTimeout(this.time), this.time = setTimeout(() => {
164
- w(t);
165
- }, e || this.lazy);
168
+ m(e);
169
+ }, t || this.lazy);
166
170
  },
167
- run(t) {
168
- let e = [], s = k(t.target, "scrollTop=>top");
169
- $(s, {
171
+ run(e) {
172
+ let t = [], s = b(e.target, "scrollTop=>top");
173
+ L(s, {
170
174
  height: this.realH,
171
175
  width: this.realW,
172
176
  /* 显示区域第一行的索引 */
173
177
  index: s.top / this.fwheight >> 0
174
178
  // ...this
175
- }, this.space, "mix"), t.from || e.push(["onscroll", s]);
176
- let h = !1;
177
- m(
179
+ }, this.space, "mix"), e.from || t.push(["onscroll", s]);
180
+ let r = !1;
181
+ g(
178
182
  this.flyweights,
179
- (i, l, n, r, u, f, c, o) => {
180
- if (n = i / u >> 0, c = n + r * /* 偏移量, 如果超出顶部 + 1轮,排列到列队后, 否则保持在当前*/
181
- (+(n < f % r) + (f / r >> 0)), o = c * u + i % u, o >= this.count) {
182
- h || (e.push(["onend"]), h = !0);
183
+ (l, i, o, h, a, c, f, n) => {
184
+ if (o = l / a >> 0, f = o + h * /* 偏移量, 如果超出顶部 + 1轮,排列到列队后, 否则保持在当前*/
185
+ (+(o < c % h) + (c / h >> 0)), n = f * a + l % a, n >= this.count) {
186
+ r || (t.push(["onend"]), r = !0);
183
187
  return;
184
188
  }
185
- l.index = c, l.top = c * this.fwheight, l.data = this.flys[o];
189
+ i.index = f, i.i = n, i.top = f * this.fwheight, i.data = this.flys[n], i.width = this.realW, i.height = this.realH;
186
190
  },
187
191
  null,
188
192
  this.row,
189
193
  this.column,
190
194
  /* 显示区域第一行的索引 */
191
195
  s.index
192
- ), this.trigger(e), e = null;
196
+ ), this.trigger(t), t = null;
193
197
  },
194
- scroll(t) {
195
- this.run(t || { target: this.flyweight, from: "space" });
198
+ scroll(e) {
199
+ this.run(e || { target: this.flyweight, from: "space" });
196
200
  },
197
201
  re() {
198
- let t = this.count || this.flys.length, e = this.flyweights;
199
- if (!t)
200
- return e.length = t;
201
- this.count = t;
202
- let s = this.flyweight, h = k(s, "clientHeight=>height,clientWidth=>width");
202
+ let e = this.count || this.flys.length, t = this.flyweights;
203
+ if (!e)
204
+ return t.length = e;
205
+ this.count = e;
206
+ let s = this.flyweight, r = b(s, "clientHeight=>height,clientWidth=>width");
203
207
  this.$nextTick(() => {
204
- let i = /true/.test(this.auto), [l, n] = this.offset, r = h.width, u = h.height, f = (F(this.width, r) || r) + l, c = F(this.height, u) + n;
205
- this.realH = c - n;
206
- let o = r / f >> 0 || 1, p = u / c >> 0;
207
- this.row = p + 2, this.column = o, this.fwheight = c;
208
- let v, H = 0;
209
- i ? (f = (r / o >> 0) - l / o * (o - 1), v = l) : (v = 0, H = l / (o + 1) * o + r % f / (o + 1) >> 0, f -= l), this.realW = f, this.Height = Math.ceil(t / o) * c;
210
- let S = Math.min(t, o * this.row), y = S - 1, a, T, N;
211
- for (; S-- > 0; )
212
- a = y - S, N = this.flys[a], s = e[a], p = a / o >> 0, T = a % o, this.$set(e, a, {
208
+ let l = /true/.test(this.auto), [i, o] = this.offset, h = r.width, a = r.height, c = (C(this.width, h) || h) + i, f = C(this.height, a) + o;
209
+ this.realH = f - o;
210
+ let n = h / c >> 0 || 1, y = a / f >> 0, S = this.padding;
211
+ this.row = y + 2, this.column = n, this.fwheight = f;
212
+ let T, $ = 0;
213
+ l ? (c = (h - i * (n + 2 * S - 1)) / n, T = !S * i, $ = S * i) : (T = 0, $ = (h % c + i * n) / (n + 1) >> 0, c -= i), this.realW = c, this.Height = Math.ceil(e / n) * f;
214
+ let v = Math.min(e, n * this.row), w = v - 1, u, z, N;
215
+ for (; v-- > 0; )
216
+ u = w - v, N = this.flys[u], s = t[u], y = u / n >> 0, z = u % n, this.$set(t, u, {
213
217
  data: N,
214
- top: p * c,
215
- left: T * (f + v) + (T + 1) * H,
216
- index: p
218
+ top: y * f,
219
+ left: z * (c + T) + (z + 1) * $,
220
+ index: y
217
221
  });
218
- e.length = y + 1;
219
- let z = [];
220
- u / c > y / o && z.push(["onend"]), this.scroll(), z.push(["update:space", {
221
- row: (y / o >> 0) + 1,
222
- column: o,
222
+ t.length = w + 1;
223
+ let H = [];
224
+ a / f > w / n && H.push(["onend"]), this.scroll(), H.push(["update:space", {
225
+ row: (w / n >> 0) + 1,
226
+ column: n,
223
227
  showrow: this.row,
224
228
  showcolumn: this.column
225
- }]), this.trigger(z);
229
+ }]), this.trigger(H);
226
230
  });
227
231
  }
228
232
  }
229
233
  };
230
- function J(t, e, s, h, i, l) {
234
+ function K(e, t, s, r, l, i) {
231
235
  return _(), x("div", {
232
236
  ref: "flyweight",
233
237
  class: E(["flyweight", {
234
- "flyweight-active": i.actice
238
+ "flyweight-active": l.actice
235
239
  }]),
236
- style: g({
237
- "--width": i.realW + "px",
238
- "--height": i.realH + "px"
240
+ style: p({
241
+ "--width": l.realW + "px",
242
+ "--height": l.realH + "px"
239
243
  }),
240
- onScroll: e[0] || (e[0] = (...n) => l.scroll && l.scroll(...n))
244
+ onScroll: t[0] || (t[0] = (...o) => i.scroll && i.scroll(...o))
241
245
  }, [
242
- b("div", {
246
+ k("div", {
243
247
  class: "flyweight-all",
244
- style: g({
245
- "--flyweight-height": i.Height + "px"
248
+ style: p({
249
+ "--flyweight-height": l.Height + "px"
246
250
  })
247
251
  }, [
248
- (_(!0), x(B, null, V(i.flyweights, (n, r) => (_(), x("div", {
249
- key: r,
250
- style: g({
251
- top: n.top + "px",
252
- left: n.left + "px"
252
+ (_(!0), x(R, null, V(l.flyweights, (o, h) => (_(), x("div", {
253
+ key: h,
254
+ style: p({
255
+ top: o.top + "px",
256
+ left: o.left + "px"
253
257
  })
254
258
  }, [
255
- d(t.$slots, "default", {
256
- data: n.data,
257
- index: n.index
258
- }, void 0, !0)
259
+ d(e.$slots, "default", D({ ref_for: !0 }, o), void 0, !0)
259
260
  ], 4))), 128))
260
261
  ], 4),
261
- i.flyweights.length ? d(t.$slots, "end", { key: 0 }, void 0, !0) : D("", !0)
262
+ l.flyweights.length ? d(e.$slots, "end", { key: 0 }, void 0, !0) : G("", !0)
262
263
  ], 38);
263
264
  }
264
- const K = /* @__PURE__ */ I(q, [["render", J], ["__scopeId", "data-v-292d1069"]]);
265
- const P = {
265
+ const Q = /* @__PURE__ */ I(J, [["render", K], ["__scopeId", "data-v-4f09502c"]]);
266
+ const X = {
266
267
  name: "Card",
267
268
  // inheritAttrs: false,
268
269
  props: {
@@ -306,84 +307,84 @@ const P = {
306
307
  top: "0",
307
308
  right: "0",
308
309
  bottom: "0",
309
- left: "0"
310
+ left: "0",
311
+ style: {}
310
312
  };
311
313
  },
314
+ computed: {
315
+ style() {
316
+ let e = {};
317
+ return g(["BackGround", "Border", "Height", "Width", "Top", "Right", "BottoM", "Left"], (t, s) => {
318
+ e["--" + s.replace(/[a-z]/g, "")] = O(this[s.toLowerCase()]);
319
+ }), e;
320
+ }
321
+ },
312
322
  watch: {
313
323
  close: {
314
- handler(t) {
315
- this.change(t);
324
+ handler(e) {
325
+ this.change(e);
316
326
  },
317
327
  deep: !0
318
328
  },
319
329
  offset: {
320
- handler(t) {
321
- this.offser(t);
330
+ handler(e) {
331
+ this.offser(e);
322
332
  },
323
333
  deep: !0
324
334
  }
325
335
  },
326
336
  methods: {
327
- exec: U,
328
- isEmpty: j,
329
- isSimplyType: O,
330
- change(t) {
331
- O(t) || (this.closecss = k(t, "color=>--s-card-close-color,*"));
337
+ exec: O,
338
+ isEmpty: A,
339
+ isSimplyType: W,
340
+ change(e) {
341
+ W(e) || (this.closecss = b(e, "color=>--s-card-close-color,*"));
332
342
  },
333
- offser(t) {
334
- t = A(t) ? t.split(/\s*(?:,|\s+)\s*/) : t;
335
- let e = k(t, "0=>top,1|0=>right,2|0=>bottom,3|1|0=>left", !0);
336
- m(e, (s, h, i) => {
337
- i[s] = h + "px";
338
- }, e), $(this, e, !0);
343
+ offser(e) {
344
+ e = M(e) ? e.split(/\s*(?:,|\s+)\s*/) : e;
345
+ let t = b(e, "0=>top,1|0=>right,2|0=>bottom,3|1|0=>left", !0);
346
+ g(t, (s, r, l) => {
347
+ l[s] = r + "px";
348
+ }, t), L(this, t, !0);
339
349
  }
340
350
  },
341
351
  mounted() {
342
352
  this.change(this.close), this.offser(this.offset);
343
353
  }
344
- }, Q = { class: "card-title" }, X = { class: "card-content" };
345
- function Z(t, e, s, h, i, l) {
354
+ }, Z = { class: "card-title" }, ee = { class: "card-content" };
355
+ function te(e, t, s, r, l, i) {
346
356
  return _(), x("div", {
347
357
  class: "card",
348
- style: g({
349
- "--card-background-color": s.background,
350
- "--card-bw": s.border,
351
- "--card-height": l.exec(s.height),
352
- "--card-width": l.exec(s.width),
353
- "--top": i.top,
354
- "--right": i.right,
355
- "--bottom": i.bottom,
356
- "--left": i.left
357
- })
358
+ style: p(i.style)
358
359
  }, [
359
- d(t.$slots, "default", {}, () => [
360
- d(t.$slots, "title", {}, () => [
361
- b("div", Q, [
362
- M(R(s.show || s.title) + " ", 1),
363
- b("div", {
364
- class: E(["card-close", { hide: l.isSimplyType(s.close) ? !s.close : !1 }]),
365
- style: g(i.closecss),
366
- onClick: e[0] || (e[0] = (n) => t.$emit("close"))
360
+ d(e.$slots, "default", {}, () => [
361
+ d(e.$slots, "title", {}, () => [
362
+ k("div", Z, [
363
+ P(U(s.show || s.title) + " ", 1),
364
+ k("div", {
365
+ class: E(["card-close", { hide: i.isSimplyType(s.close) ? !s.close : !1 }]),
366
+ style: p(l.closecss),
367
+ onClick: t[0] || (t[0] = (o) => e.$emit("close"))
367
368
  }, null, 6)
368
369
  ])
369
370
  ], !0),
370
- d(t.$slots, "content", {}, () => [
371
- b("div", X, [
372
- d(t.$slots, "inner", {}, void 0, !0)
371
+ d(e.$slots, "content", {}, () => [
372
+ k("div", ee, [
373
+ d(e.$slots, "inner", {}, void 0, !0)
373
374
  ])
374
375
  ], !0)
375
376
  ], !0)
376
377
  ], 4);
377
378
  }
378
- const tt = /* @__PURE__ */ I(P, [["render", Z], ["__scopeId", "data-v-84f183dc"]]), et = [K, tt], lt = {
379
- install(t) {
380
- et.forEach((e) => {
381
- t.component("S" + e.name, e), t.component(e.name + "S", e);
379
+ const se = /* @__PURE__ */ I(X, [["render", te], ["__scopeId", "data-v-ca61ca3d"]]), ie = [Q, se], he = {
380
+ install(e) {
381
+ ie.forEach((t) => {
382
+ e.component("S" + t.name, t), e.component(t.name + "S", t);
382
383
  });
383
384
  }
384
385
  };
385
386
  export {
386
- tt as Card,
387
- K as Flyweight,
388
- lt as default
387
+ se as Card,
388
+ Q as Flyweight,
389
+ he as default
389
390
  };
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组件",
5
- "version": "0.2.1",
5
+ "version": "0.2.2",
6
6
  "type": "module",
7
7
  "main": "Flyweight.cjs",
8
8
  "module": "Flyweight.js",
package/style.css CHANGED
@@ -1 +1 @@
1
- .flyweight[data-v-292d1069]{height:100%;width:100%;overflow:auto;position:relative}.flyweight .flyweight-all[data-v-292d1069]{height:var(--flyweight-height)}.flyweight .flyweight-all[data-v-292d1069]>*{width:calc(var(--width));height:var(--height);position:absolute}.card[data-v-84f183dc]{position:relative;background-color:var(--card-bgc, var(--card-background-color, #fff));padding:10px;border-radius:10px;box-sizing:border-box;border-style:solid;border-color:var(--card-border-color, #555);justify-content:flex-start;margin:var(--top, 0) var(--right, 0) var(--bottom, 0) var(--left, 0);height:calc(var(--card-height, 100%) - var(--top, 0) - var(--bottom, 0));width:var(--card-width, 100%);overflow:auto}.card[simply][data-v-84f183dc],.card [simply][data-v-84f183dc]{background-color:inherit;border:0!important}.card[flex][data-v-84f183dc],.card [flex][data-v-84f183dc]{display:flex}.card[column][data-v-84f183dc],.card [column][data-v-84f183dc]{flex-direction:column}.card[row][data-v-84f183dc],.card [row][data-v-84f183dc]{flex-direction:row}.card[center][data-v-84f183dc],.card [center][data-v-84f183dc]{justify-content:center}.card[vcenter][data-v-84f183dc],.card [vcenter][data-v-84f183dc]{align-items:center}.card .card-title[data-v-84f183dc]{max-height:40px}.card .card-close[data-v-84f183dc]{position:absolute;width:20px;height:20px;right:10px;top:10px;border-radius:10px;z-index:1;--s-transform: 45deg;--s-hover-transform: 35deg;--s-close-width: 11px;--s-close-height: 2px;cursor:pointer;background-color:var(--s-card-close-background-color, transparent);transition:all .3s ease}.card .card-close.hide[data-v-84f183dc]{display:none}.card .card-close[data-v-84f183dc]:before,.card .card-close[data-v-84f183dc]:after{content:"";width:var(--s-close-width, 11px);height:var(--s-close-height, 2px);background-color:var(--s-card-close-color, #555);transform-origin:center;position:inherit;border-radius:10px;top:calc(50% - var(--s-close-height, 2px) / 2);left:calc(50% - var(--s-close-width, 11px) / 2)}.card .card-close[data-v-84f183dc]:before{transform:rotate(var(--s-transform, 45deg))}.card .card-close[data-v-84f183dc]:after{transform:rotate(calc(0deg - var(--s-transform, 45deg)))}.card .card-close[data-v-84f183dc]:hover:before{transform:rotate(var(--s-hover-transform, 45deg))}.card .card-close[data-v-84f183dc]:hover:after{transform:rotate(calc(0deg - var(--s-hover-transform, 45deg)))}.card .card-content[data-v-84f183dc]{overflow:auto}
1
+ .flyweight[data-v-4f09502c]{height:100%;width:100%;overflow:auto;position:relative}.flyweight .flyweight-all[data-v-4f09502c]{height:var(--flyweight-height)}.flyweight .flyweight-all[data-v-4f09502c]>*{width:calc(var(--width));height:var(--height);position:absolute}.card[data-v-ca61ca3d]{position:relative;background-color:var(--BG, var(--card-background-color, #fff));padding:10px;border-radius:10px;box-sizing:border-box;border-style:solid;border-color:var(--card-border-color, #555);justify-content:flex-start;margin:var(--T, 0) var(--R, 0) var(--BM, 0) var(--L, 0);height:calc(var(--H, 100%) - var(--T, 0) - var(--BM, 0));width:calc(var(--W, 100%) - var(--L, 0) - var(--R, 0));overflow:auto}.card[simply][data-v-ca61ca3d],.card [simply][data-v-ca61ca3d]{background-color:inherit;border:0!important}.card[flex][data-v-ca61ca3d],.card [flex][data-v-ca61ca3d]{display:flex}.card[column][data-v-ca61ca3d],.card [column][data-v-ca61ca3d]{flex-direction:column}.card[row][data-v-ca61ca3d],.card [row][data-v-ca61ca3d]{flex-direction:row}.card[center][data-v-ca61ca3d],.card [center][data-v-ca61ca3d]{justify-content:center}.card[vcenter][data-v-ca61ca3d],.card [vcenter][data-v-ca61ca3d]{align-items:center}.card .card-title[data-v-ca61ca3d]{max-height:40px}.card .card-close[data-v-ca61ca3d]{position:absolute;width:20px;height:20px;right:10px;top:10px;border-radius:10px;z-index:1;--s-transform: 45deg;--s-hover-transform: 35deg;--s-close-width: 11px;--s-close-height: 2px;cursor:pointer;background-color:var(--s-card-close-background-color, transparent);transition:all .3s ease}.card .card-close.hide[data-v-ca61ca3d]{display:none}.card .card-close[data-v-ca61ca3d]:before,.card .card-close[data-v-ca61ca3d]:after{content:"";width:var(--s-close-width, 11px);height:var(--s-close-height, 2px);background-color:var(--s-card-close-color, #555);transform-origin:center;position:inherit;border-radius:10px;top:calc(50% - var(--s-close-height, 2px) / 2);left:calc(50% - var(--s-close-width, 11px) / 2)}.card .card-close[data-v-ca61ca3d]:before{transform:rotate(var(--s-transform, 45deg))}.card .card-close[data-v-ca61ca3d]:after{transform:rotate(calc(0deg - var(--s-transform, 45deg)))}.card .card-close[data-v-ca61ca3d]:hover:before{transform:rotate(var(--s-hover-transform, 45deg))}.card .card-close[data-v-ca61ca3d]:hover:after{transform:rotate(calc(0deg - var(--s-hover-transform, 45deg)))}.card .card-content[data-v-ca61ca3d]{overflow:auto}