@ea-controls/mat-table-extensions
Version:
Angular directives that allows to extend Angular [mat-table](https://material.angular.io/components/table/overview) features
161 lines (154 loc) • 10.1 kB
JavaScript
import * as i0 from '@angular/core';
import { inject, input, effect, Directive, booleanAttribute, NgModule } from '@angular/core';
import { MatHeaderCellDef, MatTable, MatColumnDef, MatFooterCellDef, MatTableModule } from '@angular/material/table';
import { CdkHeaderRowDef, CdkFooterRowDef } from '@angular/cdk/table';
class MatExtraHeaderCellDefDirective extends MatHeaderCellDef {
_table = inject(MatTable);
_column = inject(MatColumnDef);
_newColumn;
_prefix = input('', { alias: 'matExtraHeaderCellDef' });
constructor() {
super();
this._newColumn = new MatColumnDef();
effect(() => {
if (this._table) {
this._newColumn.name = `h_${this._column.name}_${this._prefix()}`;
this._newColumn.sticky = this._column.sticky;
this._newColumn.stickyEnd = this._column.stickyEnd;
this._newColumn.cssClassFriendlyName = this._column.cssClassFriendlyName;
this._newColumn.headerCell = this;
this._table.addColumnDef(this._newColumn);
}
});
}
ngOnDestroy() {
this._table.removeColumnDef(this._newColumn);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: MatExtraHeaderCellDefDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.7", type: MatExtraHeaderCellDefDirective, isStandalone: true, selector: "[matExtraHeaderCellDef]", inputs: { _prefix: { classPropertyName: "_prefix", publicName: "matExtraHeaderCellDef", isSignal: true, isRequired: false, transformFunction: null } }, providers: [{ provide: MatHeaderCellDef, useExisting: MatExtraHeaderCellDefDirective }], usesInheritance: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: MatExtraHeaderCellDefDirective, decorators: [{
type: Directive,
args: [{
selector: '[matExtraHeaderCellDef]',
providers: [{ provide: MatHeaderCellDef, useExisting: MatExtraHeaderCellDefDirective }]
}]
}], ctorParameters: () => [] });
class MatExtraFooterCellDefDirective extends MatFooterCellDef {
_table = inject(MatTable);
_column = inject(MatColumnDef);
_newColumn;
_prefix = input('', { alias: 'matExtraFooterCellDef' });
constructor() {
super();
this._newColumn = new MatColumnDef();
effect(() => {
if (this._table) {
this._newColumn.name = `f_${this._column.name}_${this._prefix()}`;
this._newColumn.sticky = this._column.sticky;
this._newColumn.stickyEnd = this._column.stickyEnd;
this._newColumn.cssClassFriendlyName = this._column.cssClassFriendlyName;
this._newColumn.footerCell = this;
this._table.addColumnDef(this._newColumn);
}
});
}
ngOnDestroy() {
this._table.removeColumnDef(this._newColumn);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: MatExtraFooterCellDefDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.7", type: MatExtraFooterCellDefDirective, isStandalone: true, selector: "[matExtraFooterCellDef]", inputs: { _prefix: { classPropertyName: "_prefix", publicName: "matExtraFooterCellDef", isSignal: true, isRequired: false, transformFunction: null } }, providers: [{ provide: MatFooterCellDef, useExisting: MatExtraFooterCellDefDirective }], usesInheritance: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: MatExtraFooterCellDefDirective, decorators: [{
type: Directive,
args: [{
selector: '[matExtraFooterCellDef]',
providers: [{ provide: MatFooterCellDef, useExisting: MatExtraFooterCellDefDirective }]
}]
}], ctorParameters: () => [] });
class MatExtraHeaderRowDefDirective extends CdkHeaderRowDef {
_prefix = input.required({ alias: 'matExtraHeaderRowDefName' });
constructor() {
super();
effect(() => this.columns = [...this.columns].map(c => `h_${c}_${this._prefix()}`));
}
ngOnDestroy() {
this.columns = [];
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: MatExtraHeaderRowDefDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.7", type: MatExtraHeaderRowDefDirective, isStandalone: true, selector: "[matExtraHeaderRowDef]", inputs: { columns: { classPropertyName: "columns", publicName: "matExtraHeaderRowDef", isSignal: false, isRequired: false, transformFunction: null }, sticky: { classPropertyName: "sticky", publicName: "matExtraHeaderRowDefSticky", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, _prefix: { classPropertyName: "_prefix", publicName: "matExtraHeaderRowDefName", isSignal: true, isRequired: true, transformFunction: null } }, providers: [{ provide: CdkHeaderRowDef, useExisting: MatExtraHeaderRowDefDirective }], usesInheritance: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: MatExtraHeaderRowDefDirective, decorators: [{
type: Directive,
args: [{
selector: '[matExtraHeaderRowDef]',
providers: [{ provide: CdkHeaderRowDef, useExisting: MatExtraHeaderRowDefDirective }],
inputs: [
{ name: 'columns', alias: 'matExtraHeaderRowDef' },
{ name: 'sticky', alias: 'matExtraHeaderRowDefSticky', transform: booleanAttribute },
],
}]
}], ctorParameters: () => [] });
class MatExtraFooterRowDefDirective extends CdkFooterRowDef {
_prefix = input.required({ alias: 'matExtraFooterRowDefName' });
constructor() {
super();
effect(() => this.columns = [...this.columns].map(c => `f_${c}_${this._prefix()}`));
}
ngOnDestroy() {
this.columns = [];
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: MatExtraFooterRowDefDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.7", type: MatExtraFooterRowDefDirective, isStandalone: true, selector: "[matExtraFooterRowDef]", inputs: { columns: { classPropertyName: "columns", publicName: "matExtraFooterRowDef", isSignal: false, isRequired: false, transformFunction: null }, sticky: { classPropertyName: "sticky", publicName: "matExtraFooterRowDefSticky", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, _prefix: { classPropertyName: "_prefix", publicName: "matExtraFooterRowDefName", isSignal: true, isRequired: true, transformFunction: null } }, providers: [{ provide: CdkFooterRowDef, useExisting: MatExtraFooterRowDefDirective }], usesInheritance: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: MatExtraFooterRowDefDirective, decorators: [{
type: Directive,
args: [{
selector: '[matExtraFooterRowDef]',
providers: [{ provide: CdkFooterRowDef, useExisting: MatExtraFooterRowDefDirective }],
inputs: [
{ name: 'columns', alias: 'matExtraFooterRowDef' },
{ name: 'sticky', alias: 'matExtraFooterRowDefSticky', transform: booleanAttribute },
],
}]
}], ctorParameters: () => [] });
class MatExtraTableModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: MatExtraTableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.7", ngImport: i0, type: MatExtraTableModule, imports: [MatExtraHeaderCellDefDirective,
MatExtraFooterCellDefDirective,
MatExtraHeaderRowDefDirective,
MatExtraFooterRowDefDirective,
MatTableModule], exports: [MatExtraHeaderCellDefDirective,
MatExtraFooterCellDefDirective,
MatExtraHeaderRowDefDirective,
MatExtraFooterRowDefDirective,
MatTableModule] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: MatExtraTableModule, imports: [MatTableModule, MatTableModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: MatExtraTableModule, decorators: [{
type: NgModule,
args: [{
imports: [
MatExtraHeaderCellDefDirective,
MatExtraFooterCellDefDirective,
MatExtraHeaderRowDefDirective,
MatExtraFooterRowDefDirective,
MatTableModule
],
exports: [
MatExtraHeaderCellDefDirective,
MatExtraFooterCellDefDirective,
MatExtraHeaderRowDefDirective,
MatExtraFooterRowDefDirective,
MatTableModule
],
}]
}] });
/*
* Public API Surface of mat-table-extensions
*/
/**
* Generated bundle index. Do not edit.
*/
export { MatExtraFooterCellDefDirective, MatExtraFooterRowDefDirective, MatExtraHeaderCellDefDirective, MatExtraHeaderRowDefDirective, MatExtraTableModule };
//# sourceMappingURL=ea-controls-mat-table-extensions.mjs.map