UNPKG

quarkd

Version:

Mobile UI Components built on Web Components.

2 lines (1 loc) 3.76 kB
import{_ as t,a as e}from"../typeof.js";import{_ as r,a as o,b as n,c as i,P as a,H as c,d as l,N as s,B as d}from"../index2.js";import{_ as u}from"../defineProperty.js";import"../loading/index.js";import{c as h}from"../public.js";import{g as f}from"../index3.js";import{Local as p}from"../locale/index.js";var v=function(t){var e;return function(){for(var r=arguments.length,o=new Array(r),n=0;n<r;n++)o[n]=arguments[n];e&&clearTimeout(e),e=setTimeout((function(){t.apply(void 0,o)}))}};function m(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=r(t);if(e){var a=r(this).constructor;n=Reflect.construct(i,arguments,a)}else n=i.apply(this,arguments);return o(this,n)}}var x=function(r){n(l,c);var o=m(l);function l(){var e;t(this,l);for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return e=o.call.apply(o,[this].concat(n)),u(i(e),"error",!1),u(i(e),"offset",300),u(i(e),"finished",!1),u(i(e),"errortext",""),u(i(e),"textcolor","#879099"),u(i(e),"loadingtext",p.current.loading),u(i(e),"finishedtext",""),u(i(e),"loading",!1),u(i(e),"immediatecheck",!0),u(i(e),"placeholderRef",a()),u(i(e),"check",v((function(t){var r=t.auto,o=void 0!==r&&r;if(!e.loading&&h(e.finished)&&h(e.error)&&(!f(i(e))||o)&&e.placeholderRef&&e.placeholderRef.current){var n=i(e).offset;e.placeholderRef.current.getBoundingClientRect().bottom-window.screen.height<=n&&e.$emit("load")}}))),u(i(e),"clickErrorText",(function(){e.$emit("reload"),e.check({auto:!0})})),u(i(e),"renderLoading",(function(){return c.h("slot",{name:"loading",part:"loading"},c.h("div",{class:"quark-list-text",part:"list-text"},c.h("quark-loading",{type:"circular",color:e.textcolor,size:"15",part:"loading"},e.loadingtext)))})),u(i(e),"renderFinishedText",(function(){return e.finishedtext?c.h("div",{class:"quark-list-text",part:"finished-text",style:"color: ".concat(e.textcolor)},e.finishedtext):c.h("slot",{name:"finished"})})),u(i(e),"renderErrorText",(function(){return e.errortext?c.h("div",{class:"quark-list-text",style:"color: ".concat(e.textcolor),onClick:e.clickErrorText},e.errortext):c.h("slot",{name:"error",onClick:e.clickErrorText})})),e}return e(l,[{key:"componentDidMount",value:function(){var t=this;this.immediatecheck&&setTimeout((function(){return t.check({auto:!0})}),50),window.addEventListener("scroll",this.check,!0)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("scroll",this.check,!0)}},{key:"shouldComponentUpdate",value:function(t,e,r){return"loading"===t&&!h(e)&&h(r)&&this.check({auto:!0}),!0}},{key:"render",value:function(){return c.h("div",{class:"quark-list",part:"root"},c.h("slot",{name:"content"}),this.loading&&!this.finished&&this.renderLoading(),this.finished&&this.renderFinishedText(),this.error&&this.renderErrorText(),c.h("div",{ref:this.placeholderRef,part:"placeholder"}))}}]),l}();l([s({type:Boolean})],x.prototype,"error",void 0),l([s({type:Number})],x.prototype,"offset",void 0),l([s({type:Boolean})],x.prototype,"finished",void 0),l([s()],x.prototype,"errortext",void 0),l([s()],x.prototype,"textcolor",void 0),l([s()],x.prototype,"loadingtext",void 0),l([s()],x.prototype,"finishedtext",void 0),l([s({type:Boolean})],x.prototype,"loading",void 0),l([s({type:Boolean})],x.prototype,"immediatecheck",void 0);var y=x=l([d({tag:"quark-list",style:":host {\n width: 100%;\n}\n\n:host .quark-list .quark-list-text {\n height: 13.33333vw;\n line-height: 13.33333vw;\n font-size: 3.73333vw;\n color: #879099;\n text-align: center;\n}\n"})],x);export{y as default};