UNPKG

@freshworks/crayons

Version:
1 lines 3.38 kB
var __awaiter=this&&this.__awaiter||function(r,t,e,o){function n(r){return r instanceof e?r:new e((function(t){t(r)}))}return new(e||(e=Promise))((function(e,i){function s(r){try{c(o.next(r))}catch(t){i(t)}}function a(r){try{c(o["throw"](r))}catch(t){i(t)}}function c(r){r.done?e(r.value):n(r.value).then(s,a)}c((o=o.apply(r,t||[])).next())}))};var __generator=this&&this.__generator||function(r,t){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,i,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(r){return function(t){return c([r,t])}}function c(s){if(o)throw new TypeError("Generator is already executing.");while(e)try{if(o=1,n&&(i=s[0]&2?n["return"]:s[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;if(n=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:e.label++;return{value:s[1],done:false};case 5:e.label++;n=s[1];s=[0];continue;case 7:s=e.ops.pop();e.trys.pop();continue;default:if(!(i=e.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){e.label=s[1];break}if(s[0]===6&&e.label<i[1]){e.label=i[1];i=s;break}if(i&&e.label<i[2]){e.label=i[2];e.ops.push(s);break}if(i[2])e.ops.pop();e.trys.pop();continue}s=t.call(r,e)}catch(a){s=[6,a];n=0}finally{o=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{r as registerInstance,h,e as Host}from"./index-25bc21e4.js";import{c as createProgressLoaderContainer,g as getPropOptions}from"./progress-loader-util-1fff4614.js";import"./_commonjsHelpers-9943807e.js";var ProgressLoader=function(){function r(r){registerInstance(this,r);this.parent="body";this.minimum=.08;this.easing="ease";this.speed=200;this.trickle=true;this.trickleSpeed=200;this.template='<div class="bar" role="progressbar" aria-valuemin="0" aria-valuemax="1"></div>';this.show=false}r.prototype.start=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){try{this.show=true;this.progressObj.start()}catch(t){console.error("Error in start method",t)}return[2]}))}))};r.prototype.done=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){try{this.show=false;this.progressObj.done()}catch(t){console.error("Error in done method",t)}return[2]}))}))};r.prototype.inc=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){try{this.progressObj.inc()}catch(t){console.error("Error in inc method",t)}return[2]}))}))};r.prototype.set=function(r){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){try{this.progressObj.set(r)}catch(e){console.error("Error in set method",e)}return[2]}))}))};r.prototype.showChanged=function(r){if(r){this.progressObj.start()}else{this.progressObj.done()}};r.prototype.disconnectedCallback=function(){this.progressObj.done()};r.prototype.componentWillLoad=function(){this.progressObj=createProgressLoaderContainer(getPropOptions(this));if(this.show)this.progressObj.start()};r.prototype.render=function(){return h(Host,null,h("slot",null))};Object.defineProperty(r,"watchers",{get:function(){return{show:["showChanged"]}},enumerable:false,configurable:true});return r}();export{ProgressLoader as fw_progress_loader};