@freshworks/crayons
Version:
Crayons Web Components library
1 lines • 4.98 kB
JavaScript
var __awaiter=this&&this.__awaiter||function(t,e,n,o){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,r){function a(t){try{u(o.next(t))}catch(e){r(e)}}function s(t){try{u(o["throw"](t))}catch(e){r(e)}}function u(t){t.done?n(t.value):i(t.value).then(a,s)}u((o=o.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},o,i,r,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(t){return function(e){return u([t,e])}}function u(a){if(o)throw new TypeError("Generator is already executing.");while(n)try{if(o=1,i&&(r=a[0]&2?i["return"]:a[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;if(i=0,r)a=[a[0]&2,r.value];switch(a[0]){case 0:case 1:r=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;i=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(r=n.trys,r=r.length>0&&r[r.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!r||a[1]>r[0]&&a[1]<r[3])){n.label=a[1];break}if(a[0]===6&&n.label<r[1]){n.label=r[1];r=a;break}if(r&&n.label<r[2]){n.label=r[2];n.ops.push(a);break}if(r[2])n.ops.pop();n.trys.pop();continue}a=e.call(t,n)}catch(s){a=[6,s];i=0}finally{o=r=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./p-6d102d56.system.js","./p-a5f2e72b.system.js"],(function(t){"use strict";var e,n,o,i,r,a;return{setters:[function(t){e=t.r;n=t.c;o=t.h;i=t.e},function(t){r=t.T;a=t.i}],execute:function(){var s=':host{font-family:var(--fw-font-family, -apple-system, blinkmacsystemfont, "Segoe UI", roboto, oxygen, ubuntu, cantarell, "Open Sans", "Helvetica Neue", sans-serif);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-box-sizing:border-box;box-sizing:border-box}:host{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.current-record{color:#6f7c87;margin-left:10px;margin-right:14px;line-height:20px;font-size:14px}.current-record .record{font-weight:700}';var u=undefined&&undefined.__decorate||function(t,e,n,o){var i=arguments.length,r=i<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,n):o,a;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(t,e,n,o);else for(var s=t.length-1;s>=0;s--)if(a=t[s])r=(i<3?a(r):i>3?a(e,n,r):a(e,n))||r;return i>3&&r&&Object.defineProperty(e,n,r),r};var c=t("fw_pagination",function(){function t(t){e(this,t);this.fwChange=n(this,"fwChange",7);this.page=1;this.perPage=10;this.buttonGroupLabel="";this.previousButtonLabel="";this.nextButtonLabel="";this.isLoading=false}t.prototype.previousPage=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.goToPrevious();return[2]}))}))};t.prototype.nextPage=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.goToNext();return[2]}))}))};t.prototype.getLastPage=function(){return Math.ceil(this.total/this.perPage)};t.prototype.getStartRecord=function(){return Math.max((this.page-1)*this.perPage+1,1)};t.prototype.getEndRecord=function(){return Math.min(this.start+this.perPage-1,this.total)};t.prototype.handlePage=function(t){if(t>this.getLastPage())return;this.start=this.getStartRecord();this.end=this.getEndRecord()};t.prototype.handleTotal=function(){this.end=this.getEndRecord()};t.prototype.componentWillLoad=function(){this.page=Math.min(this.page,this.getLastPage());this.start=this.getStartRecord();this.end=this.getEndRecord()};t.prototype.goToPrevious=function(){this.page=Math.max(1,this.page-1);this.fwChange.emit({page:this.page})};t.prototype.goToNext=function(){this.page=Math.min(this.getLastPage(),this.page+1);this.fwChange.emit({page:this.page})};t.prototype.render=function(){var t=this;return o(i,null,o("div",{class:"current-record",innerHTML:r.t("pagination.content",{start:this.start,end:this.end,total:this.total})}),o("fw-button-group",{label:this.buttonGroupLabel},o("fw-button",{disabled:this.start===1||this.isLoading,color:"secondary",size:"icon","aria-label":this.previousButtonLabel,onFwClick:function(){return t.goToPrevious()}},o("fw-icon",{name:"chevron-left"})),o("fw-button",{disabled:this.end===this.total||this.isLoading,color:"secondary",size:"icon","aria-label":this.nextButtonLabel,onFwClick:function(){return t.goToNext()}},o("fw-icon",{name:"chevron-right"}))))};Object.defineProperty(t,"watchers",{get:function(){return{page:["handlePage"],total:["handleTotal"]}},enumerable:false,configurable:true});return t}());u([a({keyName:"pagination.buttonGroupLabel"})],c.prototype,"buttonGroupLabel",void 0);u([a({keyName:"pagination.previousButtonLabel"})],c.prototype,"previousButtonLabel",void 0);u([a({keyName:"pagination.nextButtonLabel"})],c.prototype,"nextButtonLabel",void 0);c.style=s}}}));