| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256 |
- import * as i1 from '@angular/cdk/bidi';
- import { coerceBooleanProperty } from '@angular/cdk/coercion';
- import { _VIEW_REPEATER_STRATEGY, _RecycleViewRepeaterStrategy, isDataSource, _DisposeViewRepeaterStrategy } from '@angular/cdk/collections';
- export { DataSource } from '@angular/cdk/collections';
- import * as i2 from '@angular/cdk/platform';
- import * as i3 from '@angular/cdk/scrolling';
- import { ScrollingModule } from '@angular/cdk/scrolling';
- import { DOCUMENT } from '@angular/common';
- import * as i0 from '@angular/core';
- import { InjectionToken, Directive, Inject, Optional, Input, ContentChild, Injectable, Component, ChangeDetectionStrategy, ViewEncapsulation, EmbeddedViewRef, EventEmitter, NgZone, Attribute, SkipSelf, Output, ViewChild, ContentChildren, NgModule } from '@angular/core';
- import { Subject, from, BehaviorSubject, isObservable, of } from 'rxjs';
- import { takeUntil, take } from 'rxjs/operators';
- /**
- * Mixin to provide a directive with a function that checks if the sticky input has been
- * changed since the last time the function was called. Essentially adds a dirty-check to the
- * sticky value.
- * @docs-private
- */
- function mixinHasStickyInput(base) {
- return class extends base {
- /** Whether sticky positioning should be applied. */
- get sticky() {
- return this._sticky;
- }
- set sticky(v) {
- const prevValue = this._sticky;
- this._sticky = coerceBooleanProperty(v);
- this._hasStickyChanged = prevValue !== this._sticky;
- }
- /** Whether the sticky value has changed since this was last called. */
- hasStickyChanged() {
- const hasStickyChanged = this._hasStickyChanged;
- this._hasStickyChanged = false;
- return hasStickyChanged;
- }
- /** Resets the dirty check for cases where the sticky state has been used without checking. */
- resetStickyChanged() {
- this._hasStickyChanged = false;
- }
- constructor(...args) {
- super(...args);
- this._sticky = false;
- /** Whether the sticky input has changed since it was last checked. */
- this._hasStickyChanged = false;
- }
- };
- }
- /**
- * Used to provide a table to some of the sub-components without causing a circular dependency.
- * @docs-private
- */
- const CDK_TABLE = new InjectionToken('CDK_TABLE');
- /** Injection token that can be used to specify the text column options. */
- const TEXT_COLUMN_OPTIONS = new InjectionToken('text-column-options');
- /**
- * Cell definition for a CDK table.
- * Captures the template of a column's data row cell as well as cell-specific properties.
- */
- class CdkCellDef {
- constructor(/** @docs-private */ template) {
- this.template = template;
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkCellDef, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkCellDef, selector: "[cdkCellDef]", ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkCellDef, decorators: [{
- type: Directive,
- args: [{ selector: '[cdkCellDef]' }]
- }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
- /**
- * Header cell definition for a CDK table.
- * Captures the template of a column's header cell and as well as cell-specific properties.
- */
- class CdkHeaderCellDef {
- constructor(/** @docs-private */ template) {
- this.template = template;
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkHeaderCellDef, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkHeaderCellDef, selector: "[cdkHeaderCellDef]", ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkHeaderCellDef, decorators: [{
- type: Directive,
- args: [{ selector: '[cdkHeaderCellDef]' }]
- }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
- /**
- * Footer cell definition for a CDK table.
- * Captures the template of a column's footer cell and as well as cell-specific properties.
- */
- class CdkFooterCellDef {
- constructor(/** @docs-private */ template) {
- this.template = template;
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFooterCellDef, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkFooterCellDef, selector: "[cdkFooterCellDef]", ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFooterCellDef, decorators: [{
- type: Directive,
- args: [{ selector: '[cdkFooterCellDef]' }]
- }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
- // Boilerplate for applying mixins to CdkColumnDef.
- /** @docs-private */
- class CdkColumnDefBase {
- }
- const _CdkColumnDefBase = mixinHasStickyInput(CdkColumnDefBase);
- /**
- * Column definition for the CDK table.
- * Defines a set of cells available for a table column.
- */
- class CdkColumnDef extends _CdkColumnDefBase {
- /** Unique name for this column. */
- get name() {
- return this._name;
- }
- set name(name) {
- this._setNameInput(name);
- }
- /**
- * Whether this column should be sticky positioned on the end of the row. Should make sure
- * that it mimics the `CanStick` mixin such that `_hasStickyChanged` is set to true if the value
- * has been changed.
- */
- get stickyEnd() {
- return this._stickyEnd;
- }
- set stickyEnd(v) {
- const prevValue = this._stickyEnd;
- this._stickyEnd = coerceBooleanProperty(v);
- this._hasStickyChanged = prevValue !== this._stickyEnd;
- }
- constructor(_table) {
- super();
- this._table = _table;
- this._stickyEnd = false;
- }
- /**
- * Overridable method that sets the css classes that will be added to every cell in this
- * column.
- * In the future, columnCssClassName will change from type string[] to string and this
- * will set a single string value.
- * @docs-private
- */
- _updateColumnCssClassName() {
- this._columnCssClassName = [`cdk-column-${this.cssClassFriendlyName}`];
- }
- /**
- * This has been extracted to a util because of TS 4 and VE.
- * View Engine doesn't support property rename inheritance.
- * TS 4.0 doesn't allow properties to override accessors or vice-versa.
- * @docs-private
- */
- _setNameInput(value) {
- // If the directive is set without a name (updated programmatically), then this setter will
- // trigger with an empty string and should not overwrite the programmatically set value.
- if (value) {
- this._name = value;
- this.cssClassFriendlyName = value.replace(/[^a-z0-9_-]/gi, '-');
- this._updateColumnCssClassName();
- }
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkColumnDef, deps: [{ token: CDK_TABLE, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkColumnDef, selector: "[cdkColumnDef]", inputs: { sticky: "sticky", name: ["cdkColumnDef", "name"], stickyEnd: "stickyEnd" }, providers: [{ provide: 'MAT_SORT_HEADER_COLUMN_DEF', useExisting: CdkColumnDef }], queries: [{ propertyName: "cell", first: true, predicate: CdkCellDef, descendants: true }, { propertyName: "headerCell", first: true, predicate: CdkHeaderCellDef, descendants: true }, { propertyName: "footerCell", first: true, predicate: CdkFooterCellDef, descendants: true }], usesInheritance: true, ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkColumnDef, decorators: [{
- type: Directive,
- args: [{
- selector: '[cdkColumnDef]',
- inputs: ['sticky'],
- providers: [{ provide: 'MAT_SORT_HEADER_COLUMN_DEF', useExisting: CdkColumnDef }],
- }]
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
- type: Inject,
- args: [CDK_TABLE]
- }, {
- type: Optional
- }] }]; }, propDecorators: { name: [{
- type: Input,
- args: ['cdkColumnDef']
- }], stickyEnd: [{
- type: Input,
- args: ['stickyEnd']
- }], cell: [{
- type: ContentChild,
- args: [CdkCellDef]
- }], headerCell: [{
- type: ContentChild,
- args: [CdkHeaderCellDef]
- }], footerCell: [{
- type: ContentChild,
- args: [CdkFooterCellDef]
- }] } });
- /** Base class for the cells. Adds a CSS classname that identifies the column it renders in. */
- class BaseCdkCell {
- constructor(columnDef, elementRef) {
- elementRef.nativeElement.classList.add(...columnDef._columnCssClassName);
- }
- }
- /** Header cell template container that adds the right classes and role. */
- class CdkHeaderCell extends BaseCdkCell {
- constructor(columnDef, elementRef) {
- super(columnDef, elementRef);
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkHeaderCell, deps: [{ token: CdkColumnDef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkHeaderCell, selector: "cdk-header-cell, th[cdk-header-cell]", host: { attributes: { "role": "columnheader" }, classAttribute: "cdk-header-cell" }, usesInheritance: true, ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkHeaderCell, decorators: [{
- type: Directive,
- args: [{
- selector: 'cdk-header-cell, th[cdk-header-cell]',
- host: {
- 'class': 'cdk-header-cell',
- 'role': 'columnheader',
- },
- }]
- }], ctorParameters: function () { return [{ type: CdkColumnDef }, { type: i0.ElementRef }]; } });
- /** Footer cell template container that adds the right classes and role. */
- class CdkFooterCell extends BaseCdkCell {
- constructor(columnDef, elementRef) {
- super(columnDef, elementRef);
- if (columnDef._table?._elementRef.nativeElement.nodeType === 1) {
- const tableRole = columnDef._table._elementRef.nativeElement.getAttribute('role');
- const role = tableRole === 'grid' || tableRole === 'treegrid' ? 'gridcell' : 'cell';
- elementRef.nativeElement.setAttribute('role', role);
- }
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFooterCell, deps: [{ token: CdkColumnDef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkFooterCell, selector: "cdk-footer-cell, td[cdk-footer-cell]", host: { classAttribute: "cdk-footer-cell" }, usesInheritance: true, ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFooterCell, decorators: [{
- type: Directive,
- args: [{
- selector: 'cdk-footer-cell, td[cdk-footer-cell]',
- host: {
- 'class': 'cdk-footer-cell',
- },
- }]
- }], ctorParameters: function () { return [{ type: CdkColumnDef }, { type: i0.ElementRef }]; } });
- /** Cell template container that adds the right classes and role. */
- class CdkCell extends BaseCdkCell {
- constructor(columnDef, elementRef) {
- super(columnDef, elementRef);
- if (columnDef._table?._elementRef.nativeElement.nodeType === 1) {
- const tableRole = columnDef._table._elementRef.nativeElement.getAttribute('role');
- const role = tableRole === 'grid' || tableRole === 'treegrid' ? 'gridcell' : 'cell';
- elementRef.nativeElement.setAttribute('role', role);
- }
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkCell, deps: [{ token: CdkColumnDef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkCell, selector: "cdk-cell, td[cdk-cell]", host: { classAttribute: "cdk-cell" }, usesInheritance: true, ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkCell, decorators: [{
- type: Directive,
- args: [{
- selector: 'cdk-cell, td[cdk-cell]',
- host: {
- 'class': 'cdk-cell',
- },
- }]
- }], ctorParameters: function () { return [{ type: CdkColumnDef }, { type: i0.ElementRef }]; } });
- /**
- * @docs-private
- */
- class _Schedule {
- constructor() {
- this.tasks = [];
- this.endTasks = [];
- }
- }
- /** Injection token used to provide a coalesced style scheduler. */
- const _COALESCED_STYLE_SCHEDULER = new InjectionToken('_COALESCED_STYLE_SCHEDULER');
- /**
- * Allows grouping up CSSDom mutations after the current execution context.
- * This can significantly improve performance when separate consecutive functions are
- * reading from the CSSDom and then mutating it.
- *
- * @docs-private
- */
- class _CoalescedStyleScheduler {
- constructor(_ngZone) {
- this._ngZone = _ngZone;
- this._currentSchedule = null;
- this._destroyed = new Subject();
- }
- /**
- * Schedules the specified task to run at the end of the current VM turn.
- */
- schedule(task) {
- this._createScheduleIfNeeded();
- this._currentSchedule.tasks.push(task);
- }
- /**
- * Schedules the specified task to run after other scheduled tasks at the end of the current
- * VM turn.
- */
- scheduleEnd(task) {
- this._createScheduleIfNeeded();
- this._currentSchedule.endTasks.push(task);
- }
- /** Prevent any further tasks from running. */
- ngOnDestroy() {
- this._destroyed.next();
- this._destroyed.complete();
- }
- _createScheduleIfNeeded() {
- if (this._currentSchedule) {
- return;
- }
- this._currentSchedule = new _Schedule();
- this._getScheduleObservable()
- .pipe(takeUntil(this._destroyed))
- .subscribe(() => {
- while (this._currentSchedule.tasks.length || this._currentSchedule.endTasks.length) {
- const schedule = this._currentSchedule;
- // Capture new tasks scheduled by the current set of tasks.
- this._currentSchedule = new _Schedule();
- for (const task of schedule.tasks) {
- task();
- }
- for (const task of schedule.endTasks) {
- task();
- }
- }
- this._currentSchedule = null;
- });
- }
- _getScheduleObservable() {
- // Use onStable when in the context of an ongoing change detection cycle so that we
- // do not accidentally trigger additional cycles.
- return this._ngZone.isStable
- ? from(Promise.resolve(undefined))
- : this._ngZone.onStable.pipe(take(1));
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: _CoalescedStyleScheduler, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable }); }
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: _CoalescedStyleScheduler }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: _CoalescedStyleScheduler, decorators: [{
- type: Injectable
- }], ctorParameters: function () { return [{ type: i0.NgZone }]; } });
- /**
- * The row template that can be used by the mat-table. Should not be used outside of the
- * material library.
- */
- const CDK_ROW_TEMPLATE = `<ng-container cdkCellOutlet></ng-container>`;
- /**
- * Base class for the CdkHeaderRowDef and CdkRowDef that handles checking their columns inputs
- * for changes and notifying the table.
- */
- class BaseRowDef {
- constructor(
- /** @docs-private */ template, _differs) {
- this.template = template;
- this._differs = _differs;
- }
- ngOnChanges(changes) {
- // Create a new columns differ if one does not yet exist. Initialize it based on initial value
- // of the columns property or an empty array if none is provided.
- if (!this._columnsDiffer) {
- const columns = (changes['columns'] && changes['columns'].currentValue) || [];
- this._columnsDiffer = this._differs.find(columns).create();
- this._columnsDiffer.diff(columns);
- }
- }
- /**
- * Returns the difference between the current columns and the columns from the last diff, or null
- * if there is no difference.
- */
- getColumnsDiff() {
- return this._columnsDiffer.diff(this.columns);
- }
- /** Gets this row def's relevant cell template from the provided column def. */
- extractCellTemplate(column) {
- if (this instanceof CdkHeaderRowDef) {
- return column.headerCell.template;
- }
- if (this instanceof CdkFooterRowDef) {
- return column.footerCell.template;
- }
- else {
- return column.cell.template;
- }
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: BaseRowDef, deps: [{ token: i0.TemplateRef }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: BaseRowDef, usesOnChanges: true, ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: BaseRowDef, decorators: [{
- type: Directive
- }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.IterableDiffers }]; } });
- // Boilerplate for applying mixins to CdkHeaderRowDef.
- /** @docs-private */
- class CdkHeaderRowDefBase extends BaseRowDef {
- }
- const _CdkHeaderRowDefBase = mixinHasStickyInput(CdkHeaderRowDefBase);
- /**
- * Header row definition for the CDK table.
- * Captures the header row's template and other header properties such as the columns to display.
- */
- class CdkHeaderRowDef extends _CdkHeaderRowDefBase {
- constructor(template, _differs, _table) {
- super(template, _differs);
- this._table = _table;
- }
- // Prerender fails to recognize that ngOnChanges in a part of this class through inheritance.
- // Explicitly define it so that the method is called as part of the Angular lifecycle.
- ngOnChanges(changes) {
- super.ngOnChanges(changes);
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkHeaderRowDef, deps: [{ token: i0.TemplateRef }, { token: i0.IterableDiffers }, { token: CDK_TABLE, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkHeaderRowDef, selector: "[cdkHeaderRowDef]", inputs: { columns: ["cdkHeaderRowDef", "columns"], sticky: ["cdkHeaderRowDefSticky", "sticky"] }, usesInheritance: true, usesOnChanges: true, ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkHeaderRowDef, decorators: [{
- type: Directive,
- args: [{
- selector: '[cdkHeaderRowDef]',
- inputs: ['columns: cdkHeaderRowDef', 'sticky: cdkHeaderRowDefSticky'],
- }]
- }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.IterableDiffers }, { type: undefined, decorators: [{
- type: Inject,
- args: [CDK_TABLE]
- }, {
- type: Optional
- }] }]; } });
- // Boilerplate for applying mixins to CdkFooterRowDef.
- /** @docs-private */
- class CdkFooterRowDefBase extends BaseRowDef {
- }
- const _CdkFooterRowDefBase = mixinHasStickyInput(CdkFooterRowDefBase);
- /**
- * Footer row definition for the CDK table.
- * Captures the footer row's template and other footer properties such as the columns to display.
- */
- class CdkFooterRowDef extends _CdkFooterRowDefBase {
- constructor(template, _differs, _table) {
- super(template, _differs);
- this._table = _table;
- }
- // Prerender fails to recognize that ngOnChanges in a part of this class through inheritance.
- // Explicitly define it so that the method is called as part of the Angular lifecycle.
- ngOnChanges(changes) {
- super.ngOnChanges(changes);
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFooterRowDef, deps: [{ token: i0.TemplateRef }, { token: i0.IterableDiffers }, { token: CDK_TABLE, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkFooterRowDef, selector: "[cdkFooterRowDef]", inputs: { columns: ["cdkFooterRowDef", "columns"], sticky: ["cdkFooterRowDefSticky", "sticky"] }, usesInheritance: true, usesOnChanges: true, ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFooterRowDef, decorators: [{
- type: Directive,
- args: [{
- selector: '[cdkFooterRowDef]',
- inputs: ['columns: cdkFooterRowDef', 'sticky: cdkFooterRowDefSticky'],
- }]
- }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.IterableDiffers }, { type: undefined, decorators: [{
- type: Inject,
- args: [CDK_TABLE]
- }, {
- type: Optional
- }] }]; } });
- /**
- * Data row definition for the CDK table.
- * Captures the header row's template and other row properties such as the columns to display and
- * a when predicate that describes when this row should be used.
- */
- class CdkRowDef extends BaseRowDef {
- // TODO(andrewseguin): Add an input for providing a switch function to determine
- // if this template should be used.
- constructor(template, _differs, _table) {
- super(template, _differs);
- this._table = _table;
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkRowDef, deps: [{ token: i0.TemplateRef }, { token: i0.IterableDiffers }, { token: CDK_TABLE, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkRowDef, selector: "[cdkRowDef]", inputs: { columns: ["cdkRowDefColumns", "columns"], when: ["cdkRowDefWhen", "when"] }, usesInheritance: true, ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkRowDef, decorators: [{
- type: Directive,
- args: [{
- selector: '[cdkRowDef]',
- inputs: ['columns: cdkRowDefColumns', 'when: cdkRowDefWhen'],
- }]
- }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.IterableDiffers }, { type: undefined, decorators: [{
- type: Inject,
- args: [CDK_TABLE]
- }, {
- type: Optional
- }] }]; } });
- /**
- * Outlet for rendering cells inside of a row or header row.
- * @docs-private
- */
- class CdkCellOutlet {
- /**
- * Static property containing the latest constructed instance of this class.
- * Used by the CDK table when each CdkHeaderRow and CdkRow component is created using
- * createEmbeddedView. After one of these components are created, this property will provide
- * a handle to provide that component's cells and context. After init, the CdkCellOutlet will
- * construct the cells with the provided context.
- */
- static { this.mostRecentCellOutlet = null; }
- constructor(_viewContainer) {
- this._viewContainer = _viewContainer;
- CdkCellOutlet.mostRecentCellOutlet = this;
- }
- ngOnDestroy() {
- // If this was the last outlet being rendered in the view, remove the reference
- // from the static property after it has been destroyed to avoid leaking memory.
- if (CdkCellOutlet.mostRecentCellOutlet === this) {
- CdkCellOutlet.mostRecentCellOutlet = null;
- }
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkCellOutlet, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkCellOutlet, selector: "[cdkCellOutlet]", ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkCellOutlet, decorators: [{
- type: Directive,
- args: [{ selector: '[cdkCellOutlet]' }]
- }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }]; } });
- /** Header template container that contains the cell outlet. Adds the right class and role. */
- class CdkHeaderRow {
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkHeaderRow, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: CdkHeaderRow, selector: "cdk-header-row, tr[cdk-header-row]", host: { attributes: { "role": "row" }, classAttribute: "cdk-header-row" }, ngImport: i0, template: "<ng-container cdkCellOutlet></ng-container>", isInline: true, dependencies: [{ kind: "directive", type: CdkCellOutlet, selector: "[cdkCellOutlet]" }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkHeaderRow, decorators: [{
- type: Component,
- args: [{
- selector: 'cdk-header-row, tr[cdk-header-row]',
- template: CDK_ROW_TEMPLATE,
- host: {
- 'class': 'cdk-header-row',
- 'role': 'row',
- },
- // See note on CdkTable for explanation on why this uses the default change detection strategy.
- // tslint:disable-next-line:validate-decorators
- changeDetection: ChangeDetectionStrategy.Default,
- encapsulation: ViewEncapsulation.None,
- }]
- }] });
- /** Footer template container that contains the cell outlet. Adds the right class and role. */
- class CdkFooterRow {
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFooterRow, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: CdkFooterRow, selector: "cdk-footer-row, tr[cdk-footer-row]", host: { attributes: { "role": "row" }, classAttribute: "cdk-footer-row" }, ngImport: i0, template: "<ng-container cdkCellOutlet></ng-container>", isInline: true, dependencies: [{ kind: "directive", type: CdkCellOutlet, selector: "[cdkCellOutlet]" }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFooterRow, decorators: [{
- type: Component,
- args: [{
- selector: 'cdk-footer-row, tr[cdk-footer-row]',
- template: CDK_ROW_TEMPLATE,
- host: {
- 'class': 'cdk-footer-row',
- 'role': 'row',
- },
- // See note on CdkTable for explanation on why this uses the default change detection strategy.
- // tslint:disable-next-line:validate-decorators
- changeDetection: ChangeDetectionStrategy.Default,
- encapsulation: ViewEncapsulation.None,
- }]
- }] });
- /** Data row template container that contains the cell outlet. Adds the right class and role. */
- class CdkRow {
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkRow, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: CdkRow, selector: "cdk-row, tr[cdk-row]", host: { attributes: { "role": "row" }, classAttribute: "cdk-row" }, ngImport: i0, template: "<ng-container cdkCellOutlet></ng-container>", isInline: true, dependencies: [{ kind: "directive", type: CdkCellOutlet, selector: "[cdkCellOutlet]" }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkRow, decorators: [{
- type: Component,
- args: [{
- selector: 'cdk-row, tr[cdk-row]',
- template: CDK_ROW_TEMPLATE,
- host: {
- 'class': 'cdk-row',
- 'role': 'row',
- },
- // See note on CdkTable for explanation on why this uses the default change detection strategy.
- // tslint:disable-next-line:validate-decorators
- changeDetection: ChangeDetectionStrategy.Default,
- encapsulation: ViewEncapsulation.None,
- }]
- }] });
- /** Row that can be used to display a message when no data is shown in the table. */
- class CdkNoDataRow {
- constructor(templateRef) {
- this.templateRef = templateRef;
- this._contentClassName = 'cdk-no-data-row';
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkNoDataRow, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkNoDataRow, selector: "ng-template[cdkNoDataRow]", ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkNoDataRow, decorators: [{
- type: Directive,
- args: [{
- selector: 'ng-template[cdkNoDataRow]',
- }]
- }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
- /**
- * List of all possible directions that can be used for sticky positioning.
- * @docs-private
- */
- const STICKY_DIRECTIONS = ['top', 'bottom', 'left', 'right'];
- /**
- * Applies and removes sticky positioning styles to the `CdkTable` rows and columns cells.
- * @docs-private
- */
- class StickyStyler {
- /**
- * @param _isNativeHtmlTable Whether the sticky logic should be based on a table
- * that uses the native `<table>` element.
- * @param _stickCellCss The CSS class that will be applied to every row/cell that has
- * sticky positioning applied.
- * @param direction The directionality context of the table (ltr/rtl); affects column positioning
- * by reversing left/right positions.
- * @param _isBrowser Whether the table is currently being rendered on the server or the client.
- * @param _needsPositionStickyOnElement Whether we need to specify position: sticky on cells
- * using inline styles. If false, it is assumed that position: sticky is included in
- * the component stylesheet for _stickCellCss.
- * @param _positionListener A listener that is notified of changes to sticky rows/columns
- * and their dimensions.
- */
- constructor(_isNativeHtmlTable, _stickCellCss, direction, _coalescedStyleScheduler, _isBrowser = true, _needsPositionStickyOnElement = true, _positionListener) {
- this._isNativeHtmlTable = _isNativeHtmlTable;
- this._stickCellCss = _stickCellCss;
- this.direction = direction;
- this._coalescedStyleScheduler = _coalescedStyleScheduler;
- this._isBrowser = _isBrowser;
- this._needsPositionStickyOnElement = _needsPositionStickyOnElement;
- this._positionListener = _positionListener;
- this._cachedCellWidths = [];
- this._borderCellCss = {
- 'top': `${_stickCellCss}-border-elem-top`,
- 'bottom': `${_stickCellCss}-border-elem-bottom`,
- 'left': `${_stickCellCss}-border-elem-left`,
- 'right': `${_stickCellCss}-border-elem-right`,
- };
- }
- /**
- * Clears the sticky positioning styles from the row and its cells by resetting the `position`
- * style, setting the zIndex to 0, and unsetting each provided sticky direction.
- * @param rows The list of rows that should be cleared from sticking in the provided directions
- * @param stickyDirections The directions that should no longer be set as sticky on the rows.
- */
- clearStickyPositioning(rows, stickyDirections) {
- const elementsToClear = [];
- for (const row of rows) {
- // If the row isn't an element (e.g. if it's an `ng-container`),
- // it won't have inline styles or `children` so we skip it.
- if (row.nodeType !== row.ELEMENT_NODE) {
- continue;
- }
- elementsToClear.push(row);
- for (let i = 0; i < row.children.length; i++) {
- elementsToClear.push(row.children[i]);
- }
- }
- // Coalesce with sticky row/column updates (and potentially other changes like column resize).
- this._coalescedStyleScheduler.schedule(() => {
- for (const element of elementsToClear) {
- this._removeStickyStyle(element, stickyDirections);
- }
- });
- }
- /**
- * Applies sticky left and right positions to the cells of each row according to the sticky
- * states of the rendered column definitions.
- * @param rows The rows that should have its set of cells stuck according to the sticky states.
- * @param stickyStartStates A list of boolean states where each state represents whether the cell
- * in this index position should be stuck to the start of the row.
- * @param stickyEndStates A list of boolean states where each state represents whether the cell
- * in this index position should be stuck to the end of the row.
- * @param recalculateCellWidths Whether the sticky styler should recalculate the width of each
- * column cell. If `false` cached widths will be used instead.
- */
- updateStickyColumns(rows, stickyStartStates, stickyEndStates, recalculateCellWidths = true) {
- if (!rows.length ||
- !this._isBrowser ||
- !(stickyStartStates.some(state => state) || stickyEndStates.some(state => state))) {
- if (this._positionListener) {
- this._positionListener.stickyColumnsUpdated({ sizes: [] });
- this._positionListener.stickyEndColumnsUpdated({ sizes: [] });
- }
- return;
- }
- const firstRow = rows[0];
- const numCells = firstRow.children.length;
- const cellWidths = this._getCellWidths(firstRow, recalculateCellWidths);
- const startPositions = this._getStickyStartColumnPositions(cellWidths, stickyStartStates);
- const endPositions = this._getStickyEndColumnPositions(cellWidths, stickyEndStates);
- const lastStickyStart = stickyStartStates.lastIndexOf(true);
- const firstStickyEnd = stickyEndStates.indexOf(true);
- // Coalesce with sticky row updates (and potentially other changes like column resize).
- this._coalescedStyleScheduler.schedule(() => {
- const isRtl = this.direction === 'rtl';
- const start = isRtl ? 'right' : 'left';
- const end = isRtl ? 'left' : 'right';
- for (const row of rows) {
- for (let i = 0; i < numCells; i++) {
- const cell = row.children[i];
- if (stickyStartStates[i]) {
- this._addStickyStyle(cell, start, startPositions[i], i === lastStickyStart);
- }
- if (stickyEndStates[i]) {
- this._addStickyStyle(cell, end, endPositions[i], i === firstStickyEnd);
- }
- }
- }
- if (this._positionListener) {
- this._positionListener.stickyColumnsUpdated({
- sizes: lastStickyStart === -1
- ? []
- : cellWidths
- .slice(0, lastStickyStart + 1)
- .map((width, index) => (stickyStartStates[index] ? width : null)),
- });
- this._positionListener.stickyEndColumnsUpdated({
- sizes: firstStickyEnd === -1
- ? []
- : cellWidths
- .slice(firstStickyEnd)
- .map((width, index) => (stickyEndStates[index + firstStickyEnd] ? width : null))
- .reverse(),
- });
- }
- });
- }
- /**
- * Applies sticky positioning to the row's cells if using the native table layout, and to the
- * row itself otherwise.
- * @param rowsToStick The list of rows that should be stuck according to their corresponding
- * sticky state and to the provided top or bottom position.
- * @param stickyStates A list of boolean states where each state represents whether the row
- * should be stuck in the particular top or bottom position.
- * @param position The position direction in which the row should be stuck if that row should be
- * sticky.
- *
- */
- stickRows(rowsToStick, stickyStates, position) {
- // Since we can't measure the rows on the server, we can't stick the rows properly.
- if (!this._isBrowser) {
- return;
- }
- // If positioning the rows to the bottom, reverse their order when evaluating the sticky
- // position such that the last row stuck will be "bottom: 0px" and so on. Note that the
- // sticky states need to be reversed as well.
- const rows = position === 'bottom' ? rowsToStick.slice().reverse() : rowsToStick;
- const states = position === 'bottom' ? stickyStates.slice().reverse() : stickyStates;
- // Measure row heights all at once before adding sticky styles to reduce layout thrashing.
- const stickyOffsets = [];
- const stickyCellHeights = [];
- const elementsToStick = [];
- for (let rowIndex = 0, stickyOffset = 0; rowIndex < rows.length; rowIndex++) {
- if (!states[rowIndex]) {
- continue;
- }
- stickyOffsets[rowIndex] = stickyOffset;
- const row = rows[rowIndex];
- elementsToStick[rowIndex] = this._isNativeHtmlTable
- ? Array.from(row.children)
- : [row];
- const height = row.getBoundingClientRect().height;
- stickyOffset += height;
- stickyCellHeights[rowIndex] = height;
- }
- const borderedRowIndex = states.lastIndexOf(true);
- // Coalesce with other sticky row updates (top/bottom), sticky columns updates
- // (and potentially other changes like column resize).
- this._coalescedStyleScheduler.schedule(() => {
- for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
- if (!states[rowIndex]) {
- continue;
- }
- const offset = stickyOffsets[rowIndex];
- const isBorderedRowIndex = rowIndex === borderedRowIndex;
- for (const element of elementsToStick[rowIndex]) {
- this._addStickyStyle(element, position, offset, isBorderedRowIndex);
- }
- }
- if (position === 'top') {
- this._positionListener?.stickyHeaderRowsUpdated({
- sizes: stickyCellHeights,
- offsets: stickyOffsets,
- elements: elementsToStick,
- });
- }
- else {
- this._positionListener?.stickyFooterRowsUpdated({
- sizes: stickyCellHeights,
- offsets: stickyOffsets,
- elements: elementsToStick,
- });
- }
- });
- }
- /**
- * When using the native table in Safari, sticky footer cells do not stick. The only way to stick
- * footer rows is to apply sticky styling to the tfoot container. This should only be done if
- * all footer rows are sticky. If not all footer rows are sticky, remove sticky positioning from
- * the tfoot element.
- */
- updateStickyFooterContainer(tableElement, stickyStates) {
- if (!this._isNativeHtmlTable) {
- return;
- }
- const tfoot = tableElement.querySelector('tfoot');
- // Coalesce with other sticky updates (and potentially other changes like column resize).
- this._coalescedStyleScheduler.schedule(() => {
- if (stickyStates.some(state => !state)) {
- this._removeStickyStyle(tfoot, ['bottom']);
- }
- else {
- this._addStickyStyle(tfoot, 'bottom', 0, false);
- }
- });
- }
- /**
- * Removes the sticky style on the element by removing the sticky cell CSS class, re-evaluating
- * the zIndex, removing each of the provided sticky directions, and removing the
- * sticky position if there are no more directions.
- */
- _removeStickyStyle(element, stickyDirections) {
- for (const dir of stickyDirections) {
- element.style[dir] = '';
- element.classList.remove(this._borderCellCss[dir]);
- }
- // If the element no longer has any more sticky directions, remove sticky positioning and
- // the sticky CSS class.
- // Short-circuit checking element.style[dir] for stickyDirections as they
- // were already removed above.
- const hasDirection = STICKY_DIRECTIONS.some(dir => stickyDirections.indexOf(dir) === -1 && element.style[dir]);
- if (hasDirection) {
- element.style.zIndex = this._getCalculatedZIndex(element);
- }
- else {
- // When not hasDirection, _getCalculatedZIndex will always return ''.
- element.style.zIndex = '';
- if (this._needsPositionStickyOnElement) {
- element.style.position = '';
- }
- element.classList.remove(this._stickCellCss);
- }
- }
- /**
- * Adds the sticky styling to the element by adding the sticky style class, changing position
- * to be sticky (and -webkit-sticky), setting the appropriate zIndex, and adding a sticky
- * direction and value.
- */
- _addStickyStyle(element, dir, dirValue, isBorderElement) {
- element.classList.add(this._stickCellCss);
- if (isBorderElement) {
- element.classList.add(this._borderCellCss[dir]);
- }
- element.style[dir] = `${dirValue}px`;
- element.style.zIndex = this._getCalculatedZIndex(element);
- if (this._needsPositionStickyOnElement) {
- element.style.cssText += 'position: -webkit-sticky; position: sticky; ';
- }
- }
- /**
- * Calculate what the z-index should be for the element, depending on what directions (top,
- * bottom, left, right) have been set. It should be true that elements with a top direction
- * should have the highest index since these are elements like a table header. If any of those
- * elements are also sticky in another direction, then they should appear above other elements
- * that are only sticky top (e.g. a sticky column on a sticky header). Bottom-sticky elements
- * (e.g. footer rows) should then be next in the ordering such that they are below the header
- * but above any non-sticky elements. Finally, left/right sticky elements (e.g. sticky columns)
- * should minimally increment so that they are above non-sticky elements but below top and bottom
- * elements.
- */
- _getCalculatedZIndex(element) {
- const zIndexIncrements = {
- top: 100,
- bottom: 10,
- left: 1,
- right: 1,
- };
- let zIndex = 0;
- // Use `Iterable` instead of `Array` because TypeScript, as of 3.6.3,
- // loses the array generic type in the `for of`. But we *also* have to use `Array` because
- // typescript won't iterate over an `Iterable` unless you compile with `--downlevelIteration`
- for (const dir of STICKY_DIRECTIONS) {
- if (element.style[dir]) {
- zIndex += zIndexIncrements[dir];
- }
- }
- return zIndex ? `${zIndex}` : '';
- }
- /** Gets the widths for each cell in the provided row. */
- _getCellWidths(row, recalculateCellWidths = true) {
- if (!recalculateCellWidths && this._cachedCellWidths.length) {
- return this._cachedCellWidths;
- }
- const cellWidths = [];
- const firstRowCells = row.children;
- for (let i = 0; i < firstRowCells.length; i++) {
- let cell = firstRowCells[i];
- cellWidths.push(cell.getBoundingClientRect().width);
- }
- this._cachedCellWidths = cellWidths;
- return cellWidths;
- }
- /**
- * Determines the left and right positions of each sticky column cell, which will be the
- * accumulation of all sticky column cell widths to the left and right, respectively.
- * Non-sticky cells do not need to have a value set since their positions will not be applied.
- */
- _getStickyStartColumnPositions(widths, stickyStates) {
- const positions = [];
- let nextPosition = 0;
- for (let i = 0; i < widths.length; i++) {
- if (stickyStates[i]) {
- positions[i] = nextPosition;
- nextPosition += widths[i];
- }
- }
- return positions;
- }
- /**
- * Determines the left and right positions of each sticky column cell, which will be the
- * accumulation of all sticky column cell widths to the left and right, respectively.
- * Non-sticky cells do not need to have a value set since their positions will not be applied.
- */
- _getStickyEndColumnPositions(widths, stickyStates) {
- const positions = [];
- let nextPosition = 0;
- for (let i = widths.length; i > 0; i--) {
- if (stickyStates[i]) {
- positions[i] = nextPosition;
- nextPosition += widths[i];
- }
- }
- return positions;
- }
- }
- /**
- * Returns an error to be thrown when attempting to find an nonexistent column.
- * @param id Id whose lookup failed.
- * @docs-private
- */
- function getTableUnknownColumnError(id) {
- return Error(`Could not find column with id "${id}".`);
- }
- /**
- * Returns an error to be thrown when two column definitions have the same name.
- * @docs-private
- */
- function getTableDuplicateColumnNameError(name) {
- return Error(`Duplicate column definition name provided: "${name}".`);
- }
- /**
- * Returns an error to be thrown when there are multiple rows that are missing a when function.
- * @docs-private
- */
- function getTableMultipleDefaultRowDefsError() {
- return Error(`There can only be one default row without a when predicate function.`);
- }
- /**
- * Returns an error to be thrown when there are no matching row defs for a particular set of data.
- * @docs-private
- */
- function getTableMissingMatchingRowDefError(data) {
- return Error(`Could not find a matching row definition for the` +
- `provided row data: ${JSON.stringify(data)}`);
- }
- /**
- * Returns an error to be thrown when there is no row definitions present in the content.
- * @docs-private
- */
- function getTableMissingRowDefsError() {
- return Error('Missing definitions for header, footer, and row; ' +
- 'cannot determine which columns should be rendered.');
- }
- /**
- * Returns an error to be thrown when the data source does not match the compatible types.
- * @docs-private
- */
- function getTableUnknownDataSourceError() {
- return Error(`Provided data source did not match an array, Observable, or DataSource`);
- }
- /**
- * Returns an error to be thrown when the text column cannot find a parent table to inject.
- * @docs-private
- */
- function getTableTextColumnMissingParentTableError() {
- return Error(`Text column could not find a parent table for registration.`);
- }
- /**
- * Returns an error to be thrown when a table text column doesn't have a name.
- * @docs-private
- */
- function getTableTextColumnMissingNameError() {
- return Error(`Table text column must have a name.`);
- }
- /** The injection token used to specify the StickyPositioningListener. */
- const STICKY_POSITIONING_LISTENER = new InjectionToken('CDK_SPL');
- /**
- * Enables the recycle view repeater strategy, which reduces rendering latency. Not compatible with
- * tables that animate rows.
- */
- class CdkRecycleRows {
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkRecycleRows, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkRecycleRows, selector: "cdk-table[recycleRows], table[cdk-table][recycleRows]", providers: [{ provide: _VIEW_REPEATER_STRATEGY, useClass: _RecycleViewRepeaterStrategy }], ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkRecycleRows, decorators: [{
- type: Directive,
- args: [{
- selector: 'cdk-table[recycleRows], table[cdk-table][recycleRows]',
- providers: [{ provide: _VIEW_REPEATER_STRATEGY, useClass: _RecycleViewRepeaterStrategy }],
- }]
- }] });
- /**
- * Provides a handle for the table to grab the view container's ng-container to insert data rows.
- * @docs-private
- */
- class DataRowOutlet {
- constructor(viewContainer, elementRef) {
- this.viewContainer = viewContainer;
- this.elementRef = elementRef;
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: DataRowOutlet, deps: [{ token: i0.ViewContainerRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: DataRowOutlet, selector: "[rowOutlet]", ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: DataRowOutlet, decorators: [{
- type: Directive,
- args: [{ selector: '[rowOutlet]' }]
- }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ElementRef }]; } });
- /**
- * Provides a handle for the table to grab the view container's ng-container to insert the header.
- * @docs-private
- */
- class HeaderRowOutlet {
- constructor(viewContainer, elementRef) {
- this.viewContainer = viewContainer;
- this.elementRef = elementRef;
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HeaderRowOutlet, deps: [{ token: i0.ViewContainerRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: HeaderRowOutlet, selector: "[headerRowOutlet]", ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HeaderRowOutlet, decorators: [{
- type: Directive,
- args: [{ selector: '[headerRowOutlet]' }]
- }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ElementRef }]; } });
- /**
- * Provides a handle for the table to grab the view container's ng-container to insert the footer.
- * @docs-private
- */
- class FooterRowOutlet {
- constructor(viewContainer, elementRef) {
- this.viewContainer = viewContainer;
- this.elementRef = elementRef;
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: FooterRowOutlet, deps: [{ token: i0.ViewContainerRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: FooterRowOutlet, selector: "[footerRowOutlet]", ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: FooterRowOutlet, decorators: [{
- type: Directive,
- args: [{ selector: '[footerRowOutlet]' }]
- }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ElementRef }]; } });
- /**
- * Provides a handle for the table to grab the view
- * container's ng-container to insert the no data row.
- * @docs-private
- */
- class NoDataRowOutlet {
- constructor(viewContainer, elementRef) {
- this.viewContainer = viewContainer;
- this.elementRef = elementRef;
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: NoDataRowOutlet, deps: [{ token: i0.ViewContainerRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: NoDataRowOutlet, selector: "[noDataRowOutlet]", ngImport: i0 }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: NoDataRowOutlet, decorators: [{
- type: Directive,
- args: [{ selector: '[noDataRowOutlet]' }]
- }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ElementRef }]; } });
- /**
- * The table template that can be used by the mat-table. Should not be used outside of the
- * material library.
- * @docs-private
- */
- const CDK_TABLE_TEMPLATE =
- // Note that according to MDN, the `caption` element has to be projected as the **first**
- // element in the table. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/caption
- `
- <ng-content select="caption"></ng-content>
- <ng-content select="colgroup, col"></ng-content>
- <ng-container headerRowOutlet></ng-container>
- <ng-container rowOutlet></ng-container>
- <ng-container noDataRowOutlet></ng-container>
- <ng-container footerRowOutlet></ng-container>
- `;
- /**
- * Class used to conveniently type the embedded view ref for rows with a context.
- * @docs-private
- */
- class RowViewRef extends EmbeddedViewRef {
- }
- /**
- * A data table that can render a header row, data rows, and a footer row.
- * Uses the dataSource input to determine the data to be rendered. The data can be provided either
- * as a data array, an Observable stream that emits the data array to render, or a DataSource with a
- * connect function that will return an Observable stream that emits the data array to render.
- */
- class CdkTable {
- /**
- * Tracking function that will be used to check the differences in data changes. Used similarly
- * to `ngFor` `trackBy` function. Optimize row operations by identifying a row based on its data
- * relative to the function to know if a row should be added/removed/moved.
- * Accepts a function that takes two parameters, `index` and `item`.
- */
- get trackBy() {
- return this._trackByFn;
- }
- set trackBy(fn) {
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && fn != null && typeof fn !== 'function') {
- console.warn(`trackBy must be a function, but received ${JSON.stringify(fn)}.`);
- }
- this._trackByFn = fn;
- }
- /**
- * The table's source of data, which can be provided in three ways (in order of complexity):
- * - Simple data array (each object represents one table row)
- * - Stream that emits a data array each time the array changes
- * - `DataSource` object that implements the connect/disconnect interface.
- *
- * If a data array is provided, the table must be notified when the array's objects are
- * added, removed, or moved. This can be done by calling the `renderRows()` function which will
- * render the diff since the last table render. If the data array reference is changed, the table
- * will automatically trigger an update to the rows.
- *
- * When providing an Observable stream, the table will trigger an update automatically when the
- * stream emits a new array of data.
- *
- * Finally, when providing a `DataSource` object, the table will use the Observable stream
- * provided by the connect function and trigger updates when that stream emits new data array
- * values. During the table's ngOnDestroy or when the data source is removed from the table, the
- * table will call the DataSource's `disconnect` function (may be useful for cleaning up any
- * subscriptions registered during the connect process).
- */
- get dataSource() {
- return this._dataSource;
- }
- set dataSource(dataSource) {
- if (this._dataSource !== dataSource) {
- this._switchDataSource(dataSource);
- }
- }
- /**
- * Whether to allow multiple rows per data object by evaluating which rows evaluate their 'when'
- * predicate to true. If `multiTemplateDataRows` is false, which is the default value, then each
- * dataobject will render the first row that evaluates its when predicate to true, in the order
- * defined in the table, or otherwise the default row which does not have a when predicate.
- */
- get multiTemplateDataRows() {
- return this._multiTemplateDataRows;
- }
- set multiTemplateDataRows(v) {
- this._multiTemplateDataRows = coerceBooleanProperty(v);
- // In Ivy if this value is set via a static attribute (e.g. <table multiTemplateDataRows>),
- // this setter will be invoked before the row outlet has been defined hence the null check.
- if (this._rowOutlet && this._rowOutlet.viewContainer.length) {
- this._forceRenderDataRows();
- this.updateStickyColumnStyles();
- }
- }
- /**
- * Whether to use a fixed table layout. Enabling this option will enforce consistent column widths
- * and optimize rendering sticky styles for native tables. No-op for flex tables.
- */
- get fixedLayout() {
- return this._fixedLayout;
- }
- set fixedLayout(v) {
- this._fixedLayout = coerceBooleanProperty(v);
- // Toggling `fixedLayout` may change column widths. Sticky column styles should be recalculated.
- this._forceRecalculateCellWidths = true;
- this._stickyColumnStylesNeedReset = true;
- }
- constructor(_differs, _changeDetectorRef, _elementRef, role, _dir, _document, _platform, _viewRepeater, _coalescedStyleScheduler, _viewportRuler,
- /**
- * @deprecated `_stickyPositioningListener` parameter to become required.
- * @breaking-change 13.0.0
- */
- _stickyPositioningListener,
- /**
- * @deprecated `_ngZone` parameter to become required.
- * @breaking-change 14.0.0
- */
- _ngZone) {
- this._differs = _differs;
- this._changeDetectorRef = _changeDetectorRef;
- this._elementRef = _elementRef;
- this._dir = _dir;
- this._platform = _platform;
- this._viewRepeater = _viewRepeater;
- this._coalescedStyleScheduler = _coalescedStyleScheduler;
- this._viewportRuler = _viewportRuler;
- this._stickyPositioningListener = _stickyPositioningListener;
- this._ngZone = _ngZone;
- /** Subject that emits when the component has been destroyed. */
- this._onDestroy = new Subject();
- /**
- * Map of all the user's defined columns (header, data, and footer cell template) identified by
- * name. Collection populated by the column definitions gathered by `ContentChildren` as well as
- * any custom column definitions added to `_customColumnDefs`.
- */
- this._columnDefsByName = new Map();
- /**
- * Column definitions that were defined outside of the direct content children of the table.
- * These will be defined when, e.g., creating a wrapper around the cdkTable that has
- * column definitions as *its* content child.
- */
- this._customColumnDefs = new Set();
- /**
- * Data row definitions that were defined outside of the direct content children of the table.
- * These will be defined when, e.g., creating a wrapper around the cdkTable that has
- * built-in data rows as *its* content child.
- */
- this._customRowDefs = new Set();
- /**
- * Header row definitions that were defined outside of the direct content children of the table.
- * These will be defined when, e.g., creating a wrapper around the cdkTable that has
- * built-in header rows as *its* content child.
- */
- this._customHeaderRowDefs = new Set();
- /**
- * Footer row definitions that were defined outside of the direct content children of the table.
- * These will be defined when, e.g., creating a wrapper around the cdkTable that has a
- * built-in footer row as *its* content child.
- */
- this._customFooterRowDefs = new Set();
- /**
- * Whether the header row definition has been changed. Triggers an update to the header row after
- * content is checked. Initialized as true so that the table renders the initial set of rows.
- */
- this._headerRowDefChanged = true;
- /**
- * Whether the footer row definition has been changed. Triggers an update to the footer row after
- * content is checked. Initialized as true so that the table renders the initial set of rows.
- */
- this._footerRowDefChanged = true;
- /**
- * Whether the sticky column styles need to be updated. Set to `true` when the visible columns
- * change.
- */
- this._stickyColumnStylesNeedReset = true;
- /**
- * Whether the sticky styler should recalculate cell widths when applying sticky styles. If
- * `false`, cached values will be used instead. This is only applicable to tables with
- * {@link fixedLayout} enabled. For other tables, cell widths will always be recalculated.
- */
- this._forceRecalculateCellWidths = true;
- /**
- * Cache of the latest rendered `RenderRow` objects as a map for easy retrieval when constructing
- * a new list of `RenderRow` objects for rendering rows. Since the new list is constructed with
- * the cached `RenderRow` objects when possible, the row identity is preserved when the data
- * and row template matches, which allows the `IterableDiffer` to check rows by reference
- * and understand which rows are added/moved/removed.
- *
- * Implemented as a map of maps where the first key is the `data: T` object and the second is the
- * `CdkRowDef<T>` object. With the two keys, the cache points to a `RenderRow<T>` object that
- * contains an array of created pairs. The array is necessary to handle cases where the data
- * array contains multiple duplicate data objects and each instantiated `RenderRow` must be
- * stored.
- */
- this._cachedRenderRowsMap = new Map();
- /**
- * CSS class added to any row or cell that has sticky positioning applied. May be overridden by
- * table subclasses.
- */
- this.stickyCssClass = 'cdk-table-sticky';
- /**
- * Whether to manually add position: sticky to all sticky cell elements. Not needed if
- * the position is set in a selector associated with the value of stickyCssClass. May be
- * overridden by table subclasses
- */
- this.needsPositionStickyOnElement = true;
- /** Whether the no data row is currently showing anything. */
- this._isShowingNoDataRow = false;
- this._multiTemplateDataRows = false;
- this._fixedLayout = false;
- /**
- * Emits when the table completes rendering a set of data rows based on the latest data from the
- * data source, even if the set of rows is empty.
- */
- this.contentChanged = new EventEmitter();
- // TODO(andrewseguin): Remove max value as the end index
- // and instead calculate the view on init and scroll.
- /**
- * Stream containing the latest information on what rows are being displayed on screen.
- * Can be used by the data source to as a heuristic of what data should be provided.
- *
- * @docs-private
- */
- this.viewChange = new BehaviorSubject({
- start: 0,
- end: Number.MAX_VALUE,
- });
- if (!role) {
- this._elementRef.nativeElement.setAttribute('role', 'table');
- }
- this._document = _document;
- this._isNativeHtmlTable = this._elementRef.nativeElement.nodeName === 'TABLE';
- }
- ngOnInit() {
- this._setupStickyStyler();
- if (this._isNativeHtmlTable) {
- this._applyNativeTableSections();
- }
- // Set up the trackBy function so that it uses the `RenderRow` as its identity by default. If
- // the user has provided a custom trackBy, return the result of that function as evaluated
- // with the values of the `RenderRow`'s data and index.
- this._dataDiffer = this._differs.find([]).create((_i, dataRow) => {
- return this.trackBy ? this.trackBy(dataRow.dataIndex, dataRow.data) : dataRow;
- });
- this._viewportRuler
- .change()
- .pipe(takeUntil(this._onDestroy))
- .subscribe(() => {
- this._forceRecalculateCellWidths = true;
- });
- }
- ngAfterContentChecked() {
- // Cache the row and column definitions gathered by ContentChildren and programmatic injection.
- this._cacheRowDefs();
- this._cacheColumnDefs();
- // Make sure that the user has at least added header, footer, or data row def.
- if (!this._headerRowDefs.length &&
- !this._footerRowDefs.length &&
- !this._rowDefs.length &&
- (typeof ngDevMode === 'undefined' || ngDevMode)) {
- throw getTableMissingRowDefsError();
- }
- // Render updates if the list of columns have been changed for the header, row, or footer defs.
- const columnsChanged = this._renderUpdatedColumns();
- const rowDefsChanged = columnsChanged || this._headerRowDefChanged || this._footerRowDefChanged;
- // Ensure sticky column styles are reset if set to `true` elsewhere.
- this._stickyColumnStylesNeedReset = this._stickyColumnStylesNeedReset || rowDefsChanged;
- this._forceRecalculateCellWidths = rowDefsChanged;
- // If the header row definition has been changed, trigger a render to the header row.
- if (this._headerRowDefChanged) {
- this._forceRenderHeaderRows();
- this._headerRowDefChanged = false;
- }
- // If the footer row definition has been changed, trigger a render to the footer row.
- if (this._footerRowDefChanged) {
- this._forceRenderFooterRows();
- this._footerRowDefChanged = false;
- }
- // If there is a data source and row definitions, connect to the data source unless a
- // connection has already been made.
- if (this.dataSource && this._rowDefs.length > 0 && !this._renderChangeSubscription) {
- this._observeRenderChanges();
- }
- else if (this._stickyColumnStylesNeedReset) {
- // In the above case, _observeRenderChanges will result in updateStickyColumnStyles being
- // called when it row data arrives. Otherwise, we need to call it proactively.
- this.updateStickyColumnStyles();
- }
- this._checkStickyStates();
- }
- ngOnDestroy() {
- [
- this._rowOutlet.viewContainer,
- this._headerRowOutlet.viewContainer,
- this._footerRowOutlet.viewContainer,
- this._cachedRenderRowsMap,
- this._customColumnDefs,
- this._customRowDefs,
- this._customHeaderRowDefs,
- this._customFooterRowDefs,
- this._columnDefsByName,
- ].forEach(def => {
- def.clear();
- });
- this._headerRowDefs = [];
- this._footerRowDefs = [];
- this._defaultRowDef = null;
- this._onDestroy.next();
- this._onDestroy.complete();
- if (isDataSource(this.dataSource)) {
- this.dataSource.disconnect(this);
- }
- }
- /**
- * Renders rows based on the table's latest set of data, which was either provided directly as an
- * input or retrieved through an Observable stream (directly or from a DataSource).
- * Checks for differences in the data since the last diff to perform only the necessary
- * changes (add/remove/move rows).
- *
- * If the table's data source is a DataSource or Observable, this will be invoked automatically
- * each time the provided Observable stream emits a new data array. Otherwise if your data is
- * an array, this function will need to be called to render any changes.
- */
- renderRows() {
- this._renderRows = this._getAllRenderRows();
- const changes = this._dataDiffer.diff(this._renderRows);
- if (!changes) {
- this._updateNoDataRow();
- this.contentChanged.next();
- return;
- }
- const viewContainer = this._rowOutlet.viewContainer;
- this._viewRepeater.applyChanges(changes, viewContainer, (record, _adjustedPreviousIndex, currentIndex) => this._getEmbeddedViewArgs(record.item, currentIndex), record => record.item.data, (change) => {
- if (change.operation === 1 /* _ViewRepeaterOperation.INSERTED */ && change.context) {
- this._renderCellTemplateForItem(change.record.item.rowDef, change.context);
- }
- });
- // Update the meta context of a row's context data (index, count, first, last, ...)
- this._updateRowIndexContext();
- // Update rows that did not get added/removed/moved but may have had their identity changed,
- // e.g. if trackBy matched data on some property but the actual data reference changed.
- changes.forEachIdentityChange((record) => {
- const rowView = viewContainer.get(record.currentIndex);
- rowView.context.$implicit = record.item.data;
- });
- this._updateNoDataRow();
- // Allow the new row data to render before measuring it.
- // @breaking-change 14.0.0 Remove undefined check once _ngZone is required.
- if (this._ngZone && NgZone.isInAngularZone()) {
- this._ngZone.onStable.pipe(take(1), takeUntil(this._onDestroy)).subscribe(() => {
- this.updateStickyColumnStyles();
- });
- }
- else {
- this.updateStickyColumnStyles();
- }
- this.contentChanged.next();
- }
- /** Adds a column definition that was not included as part of the content children. */
- addColumnDef(columnDef) {
- this._customColumnDefs.add(columnDef);
- }
- /** Removes a column definition that was not included as part of the content children. */
- removeColumnDef(columnDef) {
- this._customColumnDefs.delete(columnDef);
- }
- /** Adds a row definition that was not included as part of the content children. */
- addRowDef(rowDef) {
- this._customRowDefs.add(rowDef);
- }
- /** Removes a row definition that was not included as part of the content children. */
- removeRowDef(rowDef) {
- this._customRowDefs.delete(rowDef);
- }
- /** Adds a header row definition that was not included as part of the content children. */
- addHeaderRowDef(headerRowDef) {
- this._customHeaderRowDefs.add(headerRowDef);
- this._headerRowDefChanged = true;
- }
- /** Removes a header row definition that was not included as part of the content children. */
- removeHeaderRowDef(headerRowDef) {
- this._customHeaderRowDefs.delete(headerRowDef);
- this._headerRowDefChanged = true;
- }
- /** Adds a footer row definition that was not included as part of the content children. */
- addFooterRowDef(footerRowDef) {
- this._customFooterRowDefs.add(footerRowDef);
- this._footerRowDefChanged = true;
- }
- /** Removes a footer row definition that was not included as part of the content children. */
- removeFooterRowDef(footerRowDef) {
- this._customFooterRowDefs.delete(footerRowDef);
- this._footerRowDefChanged = true;
- }
- /** Sets a no data row definition that was not included as a part of the content children. */
- setNoDataRow(noDataRow) {
- this._customNoDataRow = noDataRow;
- }
- /**
- * Updates the header sticky styles. First resets all applied styles with respect to the cells
- * sticking to the top. Then, evaluating which cells need to be stuck to the top. This is
- * automatically called when the header row changes its displayed set of columns, or if its
- * sticky input changes. May be called manually for cases where the cell content changes outside
- * of these events.
- */
- updateStickyHeaderRowStyles() {
- const headerRows = this._getRenderedRows(this._headerRowOutlet);
- const tableElement = this._elementRef.nativeElement;
- // Hide the thead element if there are no header rows. This is necessary to satisfy
- // overzealous a11y checkers that fail because the `rowgroup` element does not contain
- // required child `row`.
- const thead = tableElement.querySelector('thead');
- if (thead) {
- thead.style.display = headerRows.length ? '' : 'none';
- }
- const stickyStates = this._headerRowDefs.map(def => def.sticky);
- this._stickyStyler.clearStickyPositioning(headerRows, ['top']);
- this._stickyStyler.stickRows(headerRows, stickyStates, 'top');
- // Reset the dirty state of the sticky input change since it has been used.
- this._headerRowDefs.forEach(def => def.resetStickyChanged());
- }
- /**
- * Updates the footer sticky styles. First resets all applied styles with respect to the cells
- * sticking to the bottom. Then, evaluating which cells need to be stuck to the bottom. This is
- * automatically called when the footer row changes its displayed set of columns, or if its
- * sticky input changes. May be called manually for cases where the cell content changes outside
- * of these events.
- */
- updateStickyFooterRowStyles() {
- const footerRows = this._getRenderedRows(this._footerRowOutlet);
- const tableElement = this._elementRef.nativeElement;
- // Hide the tfoot element if there are no footer rows. This is necessary to satisfy
- // overzealous a11y checkers that fail because the `rowgroup` element does not contain
- // required child `row`.
- const tfoot = tableElement.querySelector('tfoot');
- if (tfoot) {
- tfoot.style.display = footerRows.length ? '' : 'none';
- }
- const stickyStates = this._footerRowDefs.map(def => def.sticky);
- this._stickyStyler.clearStickyPositioning(footerRows, ['bottom']);
- this._stickyStyler.stickRows(footerRows, stickyStates, 'bottom');
- this._stickyStyler.updateStickyFooterContainer(this._elementRef.nativeElement, stickyStates);
- // Reset the dirty state of the sticky input change since it has been used.
- this._footerRowDefs.forEach(def => def.resetStickyChanged());
- }
- /**
- * Updates the column sticky styles. First resets all applied styles with respect to the cells
- * sticking to the left and right. Then sticky styles are added for the left and right according
- * to the column definitions for each cell in each row. This is automatically called when
- * the data source provides a new set of data or when a column definition changes its sticky
- * input. May be called manually for cases where the cell content changes outside of these events.
- */
- updateStickyColumnStyles() {
- const headerRows = this._getRenderedRows(this._headerRowOutlet);
- const dataRows = this._getRenderedRows(this._rowOutlet);
- const footerRows = this._getRenderedRows(this._footerRowOutlet);
- // For tables not using a fixed layout, the column widths may change when new rows are rendered.
- // In a table using a fixed layout, row content won't affect column width, so sticky styles
- // don't need to be cleared unless either the sticky column config changes or one of the row
- // defs change.
- if ((this._isNativeHtmlTable && !this._fixedLayout) || this._stickyColumnStylesNeedReset) {
- // Clear the left and right positioning from all columns in the table across all rows since
- // sticky columns span across all table sections (header, data, footer)
- this._stickyStyler.clearStickyPositioning([...headerRows, ...dataRows, ...footerRows], ['left', 'right']);
- this._stickyColumnStylesNeedReset = false;
- }
- // Update the sticky styles for each header row depending on the def's sticky state
- headerRows.forEach((headerRow, i) => {
- this._addStickyColumnStyles([headerRow], this._headerRowDefs[i]);
- });
- // Update the sticky styles for each data row depending on its def's sticky state
- this._rowDefs.forEach(rowDef => {
- // Collect all the rows rendered with this row definition.
- const rows = [];
- for (let i = 0; i < dataRows.length; i++) {
- if (this._renderRows[i].rowDef === rowDef) {
- rows.push(dataRows[i]);
- }
- }
- this._addStickyColumnStyles(rows, rowDef);
- });
- // Update the sticky styles for each footer row depending on the def's sticky state
- footerRows.forEach((footerRow, i) => {
- this._addStickyColumnStyles([footerRow], this._footerRowDefs[i]);
- });
- // Reset the dirty state of the sticky input change since it has been used.
- Array.from(this._columnDefsByName.values()).forEach(def => def.resetStickyChanged());
- }
- /**
- * Get the list of RenderRow objects to render according to the current list of data and defined
- * row definitions. If the previous list already contained a particular pair, it should be reused
- * so that the differ equates their references.
- */
- _getAllRenderRows() {
- const renderRows = [];
- // Store the cache and create a new one. Any re-used RenderRow objects will be moved into the
- // new cache while unused ones can be picked up by garbage collection.
- const prevCachedRenderRows = this._cachedRenderRowsMap;
- this._cachedRenderRowsMap = new Map();
- // For each data object, get the list of rows that should be rendered, represented by the
- // respective `RenderRow` object which is the pair of `data` and `CdkRowDef`.
- for (let i = 0; i < this._data.length; i++) {
- let data = this._data[i];
- const renderRowsForData = this._getRenderRowsForData(data, i, prevCachedRenderRows.get(data));
- if (!this._cachedRenderRowsMap.has(data)) {
- this._cachedRenderRowsMap.set(data, new WeakMap());
- }
- for (let j = 0; j < renderRowsForData.length; j++) {
- let renderRow = renderRowsForData[j];
- const cache = this._cachedRenderRowsMap.get(renderRow.data);
- if (cache.has(renderRow.rowDef)) {
- cache.get(renderRow.rowDef).push(renderRow);
- }
- else {
- cache.set(renderRow.rowDef, [renderRow]);
- }
- renderRows.push(renderRow);
- }
- }
- return renderRows;
- }
- /**
- * Gets a list of `RenderRow<T>` for the provided data object and any `CdkRowDef` objects that
- * should be rendered for this data. Reuses the cached RenderRow objects if they match the same
- * `(T, CdkRowDef)` pair.
- */
- _getRenderRowsForData(data, dataIndex, cache) {
- const rowDefs = this._getRowDefs(data, dataIndex);
- return rowDefs.map(rowDef => {
- const cachedRenderRows = cache && cache.has(rowDef) ? cache.get(rowDef) : [];
- if (cachedRenderRows.length) {
- const dataRow = cachedRenderRows.shift();
- dataRow.dataIndex = dataIndex;
- return dataRow;
- }
- else {
- return { data, rowDef, dataIndex };
- }
- });
- }
- /** Update the map containing the content's column definitions. */
- _cacheColumnDefs() {
- this._columnDefsByName.clear();
- const columnDefs = mergeArrayAndSet(this._getOwnDefs(this._contentColumnDefs), this._customColumnDefs);
- columnDefs.forEach(columnDef => {
- if (this._columnDefsByName.has(columnDef.name) &&
- (typeof ngDevMode === 'undefined' || ngDevMode)) {
- throw getTableDuplicateColumnNameError(columnDef.name);
- }
- this._columnDefsByName.set(columnDef.name, columnDef);
- });
- }
- /** Update the list of all available row definitions that can be used. */
- _cacheRowDefs() {
- this._headerRowDefs = mergeArrayAndSet(this._getOwnDefs(this._contentHeaderRowDefs), this._customHeaderRowDefs);
- this._footerRowDefs = mergeArrayAndSet(this._getOwnDefs(this._contentFooterRowDefs), this._customFooterRowDefs);
- this._rowDefs = mergeArrayAndSet(this._getOwnDefs(this._contentRowDefs), this._customRowDefs);
- // After all row definitions are determined, find the row definition to be considered default.
- const defaultRowDefs = this._rowDefs.filter(def => !def.when);
- if (!this.multiTemplateDataRows &&
- defaultRowDefs.length > 1 &&
- (typeof ngDevMode === 'undefined' || ngDevMode)) {
- throw getTableMultipleDefaultRowDefsError();
- }
- this._defaultRowDef = defaultRowDefs[0];
- }
- /**
- * Check if the header, data, or footer rows have changed what columns they want to display or
- * whether the sticky states have changed for the header or footer. If there is a diff, then
- * re-render that section.
- */
- _renderUpdatedColumns() {
- const columnsDiffReducer = (acc, def) => acc || !!def.getColumnsDiff();
- // Force re-render data rows if the list of column definitions have changed.
- const dataColumnsChanged = this._rowDefs.reduce(columnsDiffReducer, false);
- if (dataColumnsChanged) {
- this._forceRenderDataRows();
- }
- // Force re-render header/footer rows if the list of column definitions have changed.
- const headerColumnsChanged = this._headerRowDefs.reduce(columnsDiffReducer, false);
- if (headerColumnsChanged) {
- this._forceRenderHeaderRows();
- }
- const footerColumnsChanged = this._footerRowDefs.reduce(columnsDiffReducer, false);
- if (footerColumnsChanged) {
- this._forceRenderFooterRows();
- }
- return dataColumnsChanged || headerColumnsChanged || footerColumnsChanged;
- }
- /**
- * Switch to the provided data source by resetting the data and unsubscribing from the current
- * render change subscription if one exists. If the data source is null, interpret this by
- * clearing the row outlet. Otherwise start listening for new data.
- */
- _switchDataSource(dataSource) {
- this._data = [];
- if (isDataSource(this.dataSource)) {
- this.dataSource.disconnect(this);
- }
- // Stop listening for data from the previous data source.
- if (this._renderChangeSubscription) {
- this._renderChangeSubscription.unsubscribe();
- this._renderChangeSubscription = null;
- }
- if (!dataSource) {
- if (this._dataDiffer) {
- this._dataDiffer.diff([]);
- }
- this._rowOutlet.viewContainer.clear();
- }
- this._dataSource = dataSource;
- }
- /** Set up a subscription for the data provided by the data source. */
- _observeRenderChanges() {
- // If no data source has been set, there is nothing to observe for changes.
- if (!this.dataSource) {
- return;
- }
- let dataStream;
- if (isDataSource(this.dataSource)) {
- dataStream = this.dataSource.connect(this);
- }
- else if (isObservable(this.dataSource)) {
- dataStream = this.dataSource;
- }
- else if (Array.isArray(this.dataSource)) {
- dataStream = of(this.dataSource);
- }
- if (dataStream === undefined && (typeof ngDevMode === 'undefined' || ngDevMode)) {
- throw getTableUnknownDataSourceError();
- }
- this._renderChangeSubscription = dataStream
- .pipe(takeUntil(this._onDestroy))
- .subscribe(data => {
- this._data = data || [];
- this.renderRows();
- });
- }
- /**
- * Clears any existing content in the header row outlet and creates a new embedded view
- * in the outlet using the header row definition.
- */
- _forceRenderHeaderRows() {
- // Clear the header row outlet if any content exists.
- if (this._headerRowOutlet.viewContainer.length > 0) {
- this._headerRowOutlet.viewContainer.clear();
- }
- this._headerRowDefs.forEach((def, i) => this._renderRow(this._headerRowOutlet, def, i));
- this.updateStickyHeaderRowStyles();
- }
- /**
- * Clears any existing content in the footer row outlet and creates a new embedded view
- * in the outlet using the footer row definition.
- */
- _forceRenderFooterRows() {
- // Clear the footer row outlet if any content exists.
- if (this._footerRowOutlet.viewContainer.length > 0) {
- this._footerRowOutlet.viewContainer.clear();
- }
- this._footerRowDefs.forEach((def, i) => this._renderRow(this._footerRowOutlet, def, i));
- this.updateStickyFooterRowStyles();
- }
- /** Adds the sticky column styles for the rows according to the columns' stick states. */
- _addStickyColumnStyles(rows, rowDef) {
- const columnDefs = Array.from(rowDef.columns || []).map(columnName => {
- const columnDef = this._columnDefsByName.get(columnName);
- if (!columnDef && (typeof ngDevMode === 'undefined' || ngDevMode)) {
- throw getTableUnknownColumnError(columnName);
- }
- return columnDef;
- });
- const stickyStartStates = columnDefs.map(columnDef => columnDef.sticky);
- const stickyEndStates = columnDefs.map(columnDef => columnDef.stickyEnd);
- this._stickyStyler.updateStickyColumns(rows, stickyStartStates, stickyEndStates, !this._fixedLayout || this._forceRecalculateCellWidths);
- }
- /** Gets the list of rows that have been rendered in the row outlet. */
- _getRenderedRows(rowOutlet) {
- const renderedRows = [];
- for (let i = 0; i < rowOutlet.viewContainer.length; i++) {
- const viewRef = rowOutlet.viewContainer.get(i);
- renderedRows.push(viewRef.rootNodes[0]);
- }
- return renderedRows;
- }
- /**
- * Get the matching row definitions that should be used for this row data. If there is only
- * one row definition, it is returned. Otherwise, find the row definitions that has a when
- * predicate that returns true with the data. If none return true, return the default row
- * definition.
- */
- _getRowDefs(data, dataIndex) {
- if (this._rowDefs.length == 1) {
- return [this._rowDefs[0]];
- }
- let rowDefs = [];
- if (this.multiTemplateDataRows) {
- rowDefs = this._rowDefs.filter(def => !def.when || def.when(dataIndex, data));
- }
- else {
- let rowDef = this._rowDefs.find(def => def.when && def.when(dataIndex, data)) || this._defaultRowDef;
- if (rowDef) {
- rowDefs.push(rowDef);
- }
- }
- if (!rowDefs.length && (typeof ngDevMode === 'undefined' || ngDevMode)) {
- throw getTableMissingMatchingRowDefError(data);
- }
- return rowDefs;
- }
- _getEmbeddedViewArgs(renderRow, index) {
- const rowDef = renderRow.rowDef;
- const context = { $implicit: renderRow.data };
- return {
- templateRef: rowDef.template,
- context,
- index,
- };
- }
- /**
- * Creates a new row template in the outlet and fills it with the set of cell templates.
- * Optionally takes a context to provide to the row and cells, as well as an optional index
- * of where to place the new row template in the outlet.
- */
- _renderRow(outlet, rowDef, index, context = {}) {
- // TODO(andrewseguin): enforce that one outlet was instantiated from createEmbeddedView
- const view = outlet.viewContainer.createEmbeddedView(rowDef.template, context, index);
- this._renderCellTemplateForItem(rowDef, context);
- return view;
- }
- _renderCellTemplateForItem(rowDef, context) {
- for (let cellTemplate of this._getCellTemplates(rowDef)) {
- if (CdkCellOutlet.mostRecentCellOutlet) {
- CdkCellOutlet.mostRecentCellOutlet._viewContainer.createEmbeddedView(cellTemplate, context);
- }
- }
- this._changeDetectorRef.markForCheck();
- }
- /**
- * Updates the index-related context for each row to reflect any changes in the index of the rows,
- * e.g. first/last/even/odd.
- */
- _updateRowIndexContext() {
- const viewContainer = this._rowOutlet.viewContainer;
- for (let renderIndex = 0, count = viewContainer.length; renderIndex < count; renderIndex++) {
- const viewRef = viewContainer.get(renderIndex);
- const context = viewRef.context;
- context.count = count;
- context.first = renderIndex === 0;
- context.last = renderIndex === count - 1;
- context.even = renderIndex % 2 === 0;
- context.odd = !context.even;
- if (this.multiTemplateDataRows) {
- context.dataIndex = this._renderRows[renderIndex].dataIndex;
- context.renderIndex = renderIndex;
- }
- else {
- context.index = this._renderRows[renderIndex].dataIndex;
- }
- }
- }
- /** Gets the column definitions for the provided row def. */
- _getCellTemplates(rowDef) {
- if (!rowDef || !rowDef.columns) {
- return [];
- }
- return Array.from(rowDef.columns, columnId => {
- const column = this._columnDefsByName.get(columnId);
- if (!column && (typeof ngDevMode === 'undefined' || ngDevMode)) {
- throw getTableUnknownColumnError(columnId);
- }
- return rowDef.extractCellTemplate(column);
- });
- }
- /** Adds native table sections (e.g. tbody) and moves the row outlets into them. */
- _applyNativeTableSections() {
- const documentFragment = this._document.createDocumentFragment();
- const sections = [
- { tag: 'thead', outlets: [this._headerRowOutlet] },
- { tag: 'tbody', outlets: [this._rowOutlet, this._noDataRowOutlet] },
- { tag: 'tfoot', outlets: [this._footerRowOutlet] },
- ];
- for (const section of sections) {
- const element = this._document.createElement(section.tag);
- element.setAttribute('role', 'rowgroup');
- for (const outlet of section.outlets) {
- element.appendChild(outlet.elementRef.nativeElement);
- }
- documentFragment.appendChild(element);
- }
- // Use a DocumentFragment so we don't hit the DOM on each iteration.
- this._elementRef.nativeElement.appendChild(documentFragment);
- }
- /**
- * Forces a re-render of the data rows. Should be called in cases where there has been an input
- * change that affects the evaluation of which rows should be rendered, e.g. toggling
- * `multiTemplateDataRows` or adding/removing row definitions.
- */
- _forceRenderDataRows() {
- this._dataDiffer.diff([]);
- this._rowOutlet.viewContainer.clear();
- this.renderRows();
- }
- /**
- * Checks if there has been a change in sticky states since last check and applies the correct
- * sticky styles. Since checking resets the "dirty" state, this should only be performed once
- * during a change detection and after the inputs are settled (after content check).
- */
- _checkStickyStates() {
- const stickyCheckReducer = (acc, d) => {
- return acc || d.hasStickyChanged();
- };
- // Note that the check needs to occur for every definition since it notifies the definition
- // that it can reset its dirty state. Using another operator like `some` may short-circuit
- // remaining definitions and leave them in an unchecked state.
- if (this._headerRowDefs.reduce(stickyCheckReducer, false)) {
- this.updateStickyHeaderRowStyles();
- }
- if (this._footerRowDefs.reduce(stickyCheckReducer, false)) {
- this.updateStickyFooterRowStyles();
- }
- if (Array.from(this._columnDefsByName.values()).reduce(stickyCheckReducer, false)) {
- this._stickyColumnStylesNeedReset = true;
- this.updateStickyColumnStyles();
- }
- }
- /**
- * Creates the sticky styler that will be used for sticky rows and columns. Listens
- * for directionality changes and provides the latest direction to the styler. Re-applies column
- * stickiness when directionality changes.
- */
- _setupStickyStyler() {
- const direction = this._dir ? this._dir.value : 'ltr';
- this._stickyStyler = new StickyStyler(this._isNativeHtmlTable, this.stickyCssClass, direction, this._coalescedStyleScheduler, this._platform.isBrowser, this.needsPositionStickyOnElement, this._stickyPositioningListener);
- (this._dir ? this._dir.change : of())
- .pipe(takeUntil(this._onDestroy))
- .subscribe(value => {
- this._stickyStyler.direction = value;
- this.updateStickyColumnStyles();
- });
- }
- /** Filters definitions that belong to this table from a QueryList. */
- _getOwnDefs(items) {
- return items.filter(item => !item._table || item._table === this);
- }
- /** Creates or removes the no data row, depending on whether any data is being shown. */
- _updateNoDataRow() {
- const noDataRow = this._customNoDataRow || this._noDataRow;
- if (!noDataRow) {
- return;
- }
- const shouldShow = this._rowOutlet.viewContainer.length === 0;
- if (shouldShow === this._isShowingNoDataRow) {
- return;
- }
- const container = this._noDataRowOutlet.viewContainer;
- if (shouldShow) {
- const view = container.createEmbeddedView(noDataRow.templateRef);
- const rootNode = view.rootNodes[0];
- // Only add the attributes if we have a single root node since it's hard
- // to figure out which one to add it to when there are multiple.
- if (view.rootNodes.length === 1 && rootNode?.nodeType === this._document.ELEMENT_NODE) {
- rootNode.setAttribute('role', 'row');
- rootNode.classList.add(noDataRow._contentClassName);
- }
- }
- else {
- container.clear();
- }
- this._isShowingNoDataRow = shouldShow;
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkTable, deps: [{ token: i0.IterableDiffers }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: 'role', attribute: true }, { token: i1.Directionality, optional: true }, { token: DOCUMENT }, { token: i2.Platform }, { token: _VIEW_REPEATER_STRATEGY }, { token: _COALESCED_STYLE_SCHEDULER }, { token: i3.ViewportRuler }, { token: STICKY_POSITIONING_LISTENER, optional: true, skipSelf: true }, { token: i0.NgZone, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: CdkTable, selector: "cdk-table, table[cdk-table]", inputs: { trackBy: "trackBy", dataSource: "dataSource", multiTemplateDataRows: "multiTemplateDataRows", fixedLayout: "fixedLayout" }, outputs: { contentChanged: "contentChanged" }, host: { attributes: { "ngSkipHydration": "" }, properties: { "class.cdk-table-fixed-layout": "fixedLayout" }, classAttribute: "cdk-table" }, providers: [
- { provide: CDK_TABLE, useExisting: CdkTable },
- { provide: _VIEW_REPEATER_STRATEGY, useClass: _DisposeViewRepeaterStrategy },
- { provide: _COALESCED_STYLE_SCHEDULER, useClass: _CoalescedStyleScheduler },
- // Prevent nested tables from seeing this table's StickyPositioningListener.
- { provide: STICKY_POSITIONING_LISTENER, useValue: null },
- ], queries: [{ propertyName: "_noDataRow", first: true, predicate: CdkNoDataRow, descendants: true }, { propertyName: "_contentColumnDefs", predicate: CdkColumnDef, descendants: true }, { propertyName: "_contentRowDefs", predicate: CdkRowDef, descendants: true }, { propertyName: "_contentHeaderRowDefs", predicate: CdkHeaderRowDef, descendants: true }, { propertyName: "_contentFooterRowDefs", predicate: CdkFooterRowDef, descendants: true }], viewQueries: [{ propertyName: "_rowOutlet", first: true, predicate: DataRowOutlet, descendants: true, static: true }, { propertyName: "_headerRowOutlet", first: true, predicate: HeaderRowOutlet, descendants: true, static: true }, { propertyName: "_footerRowOutlet", first: true, predicate: FooterRowOutlet, descendants: true, static: true }, { propertyName: "_noDataRowOutlet", first: true, predicate: NoDataRowOutlet, descendants: true, static: true }], exportAs: ["cdkTable"], ngImport: i0, template: "\n <ng-content select=\"caption\"></ng-content>\n <ng-content select=\"colgroup, col\"></ng-content>\n <ng-container headerRowOutlet></ng-container>\n <ng-container rowOutlet></ng-container>\n <ng-container noDataRowOutlet></ng-container>\n <ng-container footerRowOutlet></ng-container>\n", isInline: true, styles: [".cdk-table-fixed-layout{table-layout:fixed}"], dependencies: [{ kind: "directive", type: DataRowOutlet, selector: "[rowOutlet]" }, { kind: "directive", type: HeaderRowOutlet, selector: "[headerRowOutlet]" }, { kind: "directive", type: FooterRowOutlet, selector: "[footerRowOutlet]" }, { kind: "directive", type: NoDataRowOutlet, selector: "[noDataRowOutlet]" }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkTable, decorators: [{
- type: Component,
- args: [{ selector: 'cdk-table, table[cdk-table]', exportAs: 'cdkTable', template: CDK_TABLE_TEMPLATE, host: {
- 'class': 'cdk-table',
- '[class.cdk-table-fixed-layout]': 'fixedLayout',
- 'ngSkipHydration': '',
- }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.Default, providers: [
- { provide: CDK_TABLE, useExisting: CdkTable },
- { provide: _VIEW_REPEATER_STRATEGY, useClass: _DisposeViewRepeaterStrategy },
- { provide: _COALESCED_STYLE_SCHEDULER, useClass: _CoalescedStyleScheduler },
- // Prevent nested tables from seeing this table's StickyPositioningListener.
- { provide: STICKY_POSITIONING_LISTENER, useValue: null },
- ], styles: [".cdk-table-fixed-layout{table-layout:fixed}"] }]
- }], ctorParameters: function () { return [{ type: i0.IterableDiffers }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: undefined, decorators: [{
- type: Attribute,
- args: ['role']
- }] }, { type: i1.Directionality, decorators: [{
- type: Optional
- }] }, { type: undefined, decorators: [{
- type: Inject,
- args: [DOCUMENT]
- }] }, { type: i2.Platform }, { type: undefined, decorators: [{
- type: Inject,
- args: [_VIEW_REPEATER_STRATEGY]
- }] }, { type: _CoalescedStyleScheduler, decorators: [{
- type: Inject,
- args: [_COALESCED_STYLE_SCHEDULER]
- }] }, { type: i3.ViewportRuler }, { type: undefined, decorators: [{
- type: Optional
- }, {
- type: SkipSelf
- }, {
- type: Inject,
- args: [STICKY_POSITIONING_LISTENER]
- }] }, { type: i0.NgZone, decorators: [{
- type: Optional
- }] }]; }, propDecorators: { trackBy: [{
- type: Input
- }], dataSource: [{
- type: Input
- }], multiTemplateDataRows: [{
- type: Input
- }], fixedLayout: [{
- type: Input
- }], contentChanged: [{
- type: Output
- }], _rowOutlet: [{
- type: ViewChild,
- args: [DataRowOutlet, { static: true }]
- }], _headerRowOutlet: [{
- type: ViewChild,
- args: [HeaderRowOutlet, { static: true }]
- }], _footerRowOutlet: [{
- type: ViewChild,
- args: [FooterRowOutlet, { static: true }]
- }], _noDataRowOutlet: [{
- type: ViewChild,
- args: [NoDataRowOutlet, { static: true }]
- }], _contentColumnDefs: [{
- type: ContentChildren,
- args: [CdkColumnDef, { descendants: true }]
- }], _contentRowDefs: [{
- type: ContentChildren,
- args: [CdkRowDef, { descendants: true }]
- }], _contentHeaderRowDefs: [{
- type: ContentChildren,
- args: [CdkHeaderRowDef, {
- descendants: true,
- }]
- }], _contentFooterRowDefs: [{
- type: ContentChildren,
- args: [CdkFooterRowDef, {
- descendants: true,
- }]
- }], _noDataRow: [{
- type: ContentChild,
- args: [CdkNoDataRow]
- }] } });
- /** Utility function that gets a merged list of the entries in an array and values of a Set. */
- function mergeArrayAndSet(array, set) {
- return array.concat(Array.from(set));
- }
- /**
- * Column that simply shows text content for the header and row cells. Assumes that the table
- * is using the native table implementation (`<table>`).
- *
- * By default, the name of this column will be the header text and data property accessor.
- * The header text can be overridden with the `headerText` input. Cell values can be overridden with
- * the `dataAccessor` input. Change the text justification to the start or end using the `justify`
- * input.
- */
- class CdkTextColumn {
- /** Column name that should be used to reference this column. */
- get name() {
- return this._name;
- }
- set name(name) {
- this._name = name;
- // With Ivy, inputs can be initialized before static query results are
- // available. In that case, we defer the synchronization until "ngOnInit" fires.
- this._syncColumnDefName();
- }
- constructor(
- // `CdkTextColumn` is always requiring a table, but we just assert it manually
- // for better error reporting.
- // tslint:disable-next-line: lightweight-tokens
- _table, _options) {
- this._table = _table;
- this._options = _options;
- /** Alignment of the cell values. */
- this.justify = 'start';
- this._options = _options || {};
- }
- ngOnInit() {
- this._syncColumnDefName();
- if (this.headerText === undefined) {
- this.headerText = this._createDefaultHeaderText();
- }
- if (!this.dataAccessor) {
- this.dataAccessor =
- this._options.defaultDataAccessor || ((data, name) => data[name]);
- }
- if (this._table) {
- // Provide the cell and headerCell directly to the table with the static `ViewChild` query,
- // since the columnDef will not pick up its content by the time the table finishes checking
- // its content and initializing the rows.
- this.columnDef.cell = this.cell;
- this.columnDef.headerCell = this.headerCell;
- this._table.addColumnDef(this.columnDef);
- }
- else if (typeof ngDevMode === 'undefined' || ngDevMode) {
- throw getTableTextColumnMissingParentTableError();
- }
- }
- ngOnDestroy() {
- if (this._table) {
- this._table.removeColumnDef(this.columnDef);
- }
- }
- /**
- * Creates a default header text. Use the options' header text transformation function if one
- * has been provided. Otherwise simply capitalize the column name.
- */
- _createDefaultHeaderText() {
- const name = this.name;
- if (!name && (typeof ngDevMode === 'undefined' || ngDevMode)) {
- throw getTableTextColumnMissingNameError();
- }
- if (this._options && this._options.defaultHeaderTextTransform) {
- return this._options.defaultHeaderTextTransform(name);
- }
- return name[0].toUpperCase() + name.slice(1);
- }
- /** Synchronizes the column definition name with the text column name. */
- _syncColumnDefName() {
- if (this.columnDef) {
- this.columnDef.name = this.name;
- }
- }
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkTextColumn, deps: [{ token: CdkTable, optional: true }, { token: TEXT_COLUMN_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: CdkTextColumn, selector: "cdk-text-column", inputs: { name: "name", headerText: "headerText", dataAccessor: "dataAccessor", justify: "justify" }, viewQueries: [{ propertyName: "columnDef", first: true, predicate: CdkColumnDef, descendants: true, static: true }, { propertyName: "cell", first: true, predicate: CdkCellDef, descendants: true, static: true }, { propertyName: "headerCell", first: true, predicate: CdkHeaderCellDef, descendants: true, static: true }], ngImport: i0, template: `
- <ng-container cdkColumnDef>
- <th cdk-header-cell *cdkHeaderCellDef [style.text-align]="justify">
- {{headerText}}
- </th>
- <td cdk-cell *cdkCellDef="let data" [style.text-align]="justify">
- {{dataAccessor(data, name)}}
- </td>
- </ng-container>
- `, isInline: true, dependencies: [{ kind: "directive", type: CdkCellDef, selector: "[cdkCellDef]" }, { kind: "directive", type: CdkHeaderCellDef, selector: "[cdkHeaderCellDef]" }, { kind: "directive", type: CdkColumnDef, selector: "[cdkColumnDef]", inputs: ["sticky", "cdkColumnDef", "stickyEnd"] }, { kind: "directive", type: CdkCell, selector: "cdk-cell, td[cdk-cell]" }, { kind: "directive", type: CdkHeaderCell, selector: "cdk-header-cell, th[cdk-header-cell]" }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkTextColumn, decorators: [{
- type: Component,
- args: [{
- selector: 'cdk-text-column',
- template: `
- <ng-container cdkColumnDef>
- <th cdk-header-cell *cdkHeaderCellDef [style.text-align]="justify">
- {{headerText}}
- </th>
- <td cdk-cell *cdkCellDef="let data" [style.text-align]="justify">
- {{dataAccessor(data, name)}}
- </td>
- </ng-container>
- `,
- encapsulation: ViewEncapsulation.None,
- // Change detection is intentionally not set to OnPush. This component's template will be provided
- // to the table to be inserted into its view. This is problematic when change detection runs since
- // the bindings in this template will be evaluated _after_ the table's view is evaluated, which
- // mean's the template in the table's view will not have the updated value (and in fact will cause
- // an ExpressionChangedAfterItHasBeenCheckedError).
- // tslint:disable-next-line:validate-decorators
- changeDetection: ChangeDetectionStrategy.Default,
- }]
- }], ctorParameters: function () { return [{ type: CdkTable, decorators: [{
- type: Optional
- }] }, { type: undefined, decorators: [{
- type: Optional
- }, {
- type: Inject,
- args: [TEXT_COLUMN_OPTIONS]
- }] }]; }, propDecorators: { name: [{
- type: Input
- }], headerText: [{
- type: Input
- }], dataAccessor: [{
- type: Input
- }], justify: [{
- type: Input
- }], columnDef: [{
- type: ViewChild,
- args: [CdkColumnDef, { static: true }]
- }], cell: [{
- type: ViewChild,
- args: [CdkCellDef, { static: true }]
- }], headerCell: [{
- type: ViewChild,
- args: [CdkHeaderCellDef, { static: true }]
- }] } });
- const EXPORTED_DECLARATIONS = [
- CdkTable,
- CdkRowDef,
- CdkCellDef,
- CdkCellOutlet,
- CdkHeaderCellDef,
- CdkFooterCellDef,
- CdkColumnDef,
- CdkCell,
- CdkRow,
- CdkHeaderCell,
- CdkFooterCell,
- CdkHeaderRow,
- CdkHeaderRowDef,
- CdkFooterRow,
- CdkFooterRowDef,
- DataRowOutlet,
- HeaderRowOutlet,
- FooterRowOutlet,
- CdkTextColumn,
- CdkNoDataRow,
- CdkRecycleRows,
- NoDataRowOutlet,
- ];
- class CdkTableModule {
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkTableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0", ngImport: i0, type: CdkTableModule, declarations: [CdkTable,
- CdkRowDef,
- CdkCellDef,
- CdkCellOutlet,
- CdkHeaderCellDef,
- CdkFooterCellDef,
- CdkColumnDef,
- CdkCell,
- CdkRow,
- CdkHeaderCell,
- CdkFooterCell,
- CdkHeaderRow,
- CdkHeaderRowDef,
- CdkFooterRow,
- CdkFooterRowDef,
- DataRowOutlet,
- HeaderRowOutlet,
- FooterRowOutlet,
- CdkTextColumn,
- CdkNoDataRow,
- CdkRecycleRows,
- NoDataRowOutlet], imports: [ScrollingModule], exports: [CdkTable,
- CdkRowDef,
- CdkCellDef,
- CdkCellOutlet,
- CdkHeaderCellDef,
- CdkFooterCellDef,
- CdkColumnDef,
- CdkCell,
- CdkRow,
- CdkHeaderCell,
- CdkFooterCell,
- CdkHeaderRow,
- CdkHeaderRowDef,
- CdkFooterRow,
- CdkFooterRowDef,
- DataRowOutlet,
- HeaderRowOutlet,
- FooterRowOutlet,
- CdkTextColumn,
- CdkNoDataRow,
- CdkRecycleRows,
- NoDataRowOutlet] }); }
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkTableModule, imports: [ScrollingModule] }); }
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkTableModule, decorators: [{
- type: NgModule,
- args: [{
- exports: EXPORTED_DECLARATIONS,
- declarations: EXPORTED_DECLARATIONS,
- imports: [ScrollingModule],
- }]
- }] });
- /**
- * Generated bundle index. Do not edit.
- */
- export { BaseCdkCell, BaseRowDef, CDK_ROW_TEMPLATE, CDK_TABLE, CDK_TABLE_TEMPLATE, CdkCell, CdkCellDef, CdkCellOutlet, CdkColumnDef, CdkFooterCell, CdkFooterCellDef, CdkFooterRow, CdkFooterRowDef, CdkHeaderCell, CdkHeaderCellDef, CdkHeaderRow, CdkHeaderRowDef, CdkNoDataRow, CdkRecycleRows, CdkRow, CdkRowDef, CdkTable, CdkTableModule, CdkTextColumn, DataRowOutlet, FooterRowOutlet, HeaderRowOutlet, NoDataRowOutlet, STICKY_DIRECTIONS, STICKY_POSITIONING_LISTENER, StickyStyler, TEXT_COLUMN_OPTIONS, _COALESCED_STYLE_SCHEDULER, _CoalescedStyleScheduler, _Schedule, mixinHasStickyInput };
- //# sourceMappingURL=table.mjs.map
|