ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
95 lines • 14.2 kB
JavaScript
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
import { Injectable } from '@angular/core';
import { BehaviorSubject, combineLatest, merge, ReplaySubject } from 'rxjs';
import { map } from 'rxjs/operators';
export class NzTableStyleService {
constructor() {
this.theadTemplate$ = new ReplaySubject(1);
this.hasFixLeft$ = new ReplaySubject(1);
this.hasFixRight$ = new ReplaySubject(1);
this.hostWidth$ = new ReplaySubject(1);
this.columnCount$ = new ReplaySubject(1);
this.showEmpty$ = new ReplaySubject(1);
this.noResult$ = new ReplaySubject(1);
this.listOfThWidthConfigPx$ = new BehaviorSubject([]);
this.tableWidthConfigPx$ = new BehaviorSubject([]);
this.manualWidthConfigPx$ = combineLatest([this.tableWidthConfigPx$, this.listOfThWidthConfigPx$]).pipe(map(([widthConfig, listOfWidth]) => (widthConfig.length ? widthConfig : listOfWidth)));
this.listOfAutoWidthPx$ = new ReplaySubject(1);
this.listOfListOfThWidthPx$ = merge(
/** init with manual width **/
this.manualWidthConfigPx$, combineLatest([this.listOfAutoWidthPx$, this.manualWidthConfigPx$]).pipe(map(([autoWidth, manualWidth]) => {
/** use autoWidth until column length match **/
if (autoWidth.length === manualWidth.length) {
return autoWidth.map((width, index) => {
if (width === '0px') {
return manualWidth[index] || null;
}
else {
return manualWidth[index] || width;
}
});
}
else {
return manualWidth;
}
})));
this.listOfMeasureColumn$ = new ReplaySubject(1);
this.listOfListOfThWidth$ = this.listOfAutoWidthPx$.pipe(map(list => list.map(width => parseInt(width, 10))));
this.enableAutoMeasure$ = new ReplaySubject(1);
}
setTheadTemplate(template) {
this.theadTemplate$.next(template);
}
setHasFixLeft(hasFixLeft) {
this.hasFixLeft$.next(hasFixLeft);
}
setHasFixRight(hasFixRight) {
this.hasFixRight$.next(hasFixRight);
}
setTableWidthConfig(widthConfig) {
this.tableWidthConfigPx$.next(widthConfig);
}
setListOfTh(listOfTh) {
let columnCount = 0;
listOfTh.forEach(th => {
columnCount += (th.colspan && +th.colspan) || (th.colSpan && +th.colSpan) || 1;
});
const listOfThPx = listOfTh.map(item => item.nzWidth);
this.columnCount$.next(columnCount);
this.listOfThWidthConfigPx$.next(listOfThPx);
}
setListOfMeasureColumn(listOfTh) {
const listOfKeys = [];
listOfTh.forEach(th => {
const length = (th.colspan && +th.colspan) || (th.colSpan && +th.colSpan) || 1;
for (let i = 0; i < length; i++) {
listOfKeys.push(`measure_key_${i}`);
}
});
this.listOfMeasureColumn$.next(listOfKeys);
}
setListOfAutoWidth(listOfAutoWidth) {
this.listOfAutoWidthPx$.next(listOfAutoWidth.map(width => `${width}px`));
}
setShowEmpty(showEmpty) {
this.showEmpty$.next(showEmpty);
}
setNoResult(noResult) {
this.noResult$.next(noResult);
}
setScroll(scrollX, scrollY) {
const enableAutoMeasure = !!(scrollX || scrollY);
if (!enableAutoMeasure) {
this.setListOfAutoWidth([]);
}
this.enableAutoMeasure$.next(enableAutoMeasure);
}
}
NzTableStyleService.decorators = [
{ type: Injectable }
];
NzTableStyleService.ctorParameters = () => [];
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFibGUtc3R5bGUuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIvaG9tZS92c3RzL3dvcmsvMS9zL2NvbXBvbmVudHMvdGFibGUvIiwic291cmNlcyI6WyJzcmMvdGFibGUtc3R5bGUuc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7O0dBR0c7QUFFSCxPQUFPLEVBQUUsVUFBVSxFQUFlLE1BQU0sZUFBZSxDQUFDO0FBRXhELE9BQU8sRUFBRSxlQUFlLEVBQUUsYUFBYSxFQUFFLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSxNQUFNLENBQUM7QUFDNUUsT0FBTyxFQUFFLEdBQUcsRUFBRSxNQUF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