@petkit/ngx-table-descartes
Version:
Angular descartes table component
2 lines • 3.1 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("lodash-es"),require("rxjs"),require("@angular/common")):"function"==typeof define&&define.amd?define("@petkit/ngx-table-descartes",["exports","@angular/core","lodash-es","rxjs","@angular/common"],e):e((t.petkit=t.petkit||{},t.petkit["ngx-table-descartes"]={}),t.ng.core,null,t.rxjs,t.ng.common)}(this,function(t,e,c,n,r){"use strict";function s(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,a=n.call(t),l=[];try{for(;(void 0===e||0<e--)&&!(r=a.next()).done;)l.push(r.value)}catch(i){o={error:i}}finally{try{r&&!r.done&&(n=a["return"])&&n.call(a)}finally{if(o)throw o.error}}return l}var o=function(){function t(){this.data=n.of([]),this.order=n.of(null),this.table=[]}return t.prototype.ngOnInit=function(){var i=this;n.combineLatest([this.data,this.order]).subscribe(function(t){var e=s(t,2),n=e[0],r=e[1];if(c.isArray(n)){var o=r||n[0]&&c.keys(n[0])||null;if(i._order=o,c.isArray(o)){var a=c.orderBy(n,o);i.orderData=a;var l=i.getAoA(a,o);i.aoaData=l,i.table=i.format(l)}}})},t.prototype.getAoA=function(t,n){return t.map(function(e){return n.map(function(t){return e[t]}).filter(function(t){return t!==undefined})})},t.prototype.format=function(t){var i=this;if(!c.isArray(t)||0===t.length)return[];if(!c.isArray(t[0])||0===t[0].length)return[];var e=c.groupBy(t,function(t){return t[0]});return c.values(e).map(function(t){var e,o=[],a=[];t.forEach(function(t){var e=s(t),n=e[0],r=e.slice(1);a.push(n),o.push(r)});var n={content:a[0],rowspan:a.length,key:i._order?i._order[i._order.length-o[0].length-1]:null},r=i.format(o);r.length?(r[0].unshift(n),e=r):e=function l(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t}([[n]],s(a).slice(1).map(function(){return[]}));return e}).reduce(function(t,e){return t.concat(e)},[])},t.decorators=[{type:e.Component,args:[{selector:"ngx-table-descartes",template:'<table class="ngx-table-descartes__table">\n <ng-content></ng-content>\n <tbody>\n <tr *ngFor="let row of table; index as i;">\n <td class="ngx-table-descartes__td" *ngFor="let cell of row" [attr.rowspan]="cell.rowspan">\n <ng-container *ngIf="tpl">\n <ng-container *ngTemplateOutlet="tpl; context: {cell: cell, row: aoaData[i], obj: orderData[i]};"></ng-container>\n </ng-container>\n <ng-container *ngIf="!tpl">{{cell.content}}</ng-container>\n </td>\n </tr>\n </tbody>\n</table>\n\n\n',styles:[".ngx-table-descartes__table{border-collapse:collapse;width:100%;text-align:center;vertical-align:middle}.ngx-table-descartes__td{border:1px solid #bfbfbf}"]}]}],t.ctorParameters=function(){return[]},t.propDecorators={data:[{type:e.Input}],order:[{type:e.Input}],tpl:[{type:e.Input}]},t}(),a=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[r.CommonModule],declarations:[o],exports:[o]}]}],t}();t.TableDescartesModule=a,t.ɵa=o,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=petkit-ngx-table-descartes.umd.min.js.map