table.mjs 113 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256
  1. import * as i1 from '@angular/cdk/bidi';
  2. import { coerceBooleanProperty } from '@angular/cdk/coercion';
  3. import { _VIEW_REPEATER_STRATEGY, _RecycleViewRepeaterStrategy, isDataSource, _DisposeViewRepeaterStrategy } from '@angular/cdk/collections';
  4. export { DataSource } from '@angular/cdk/collections';
  5. import * as i2 from '@angular/cdk/platform';
  6. import * as i3 from '@angular/cdk/scrolling';
  7. import { ScrollingModule } from '@angular/cdk/scrolling';
  8. import { DOCUMENT } from '@angular/common';
  9. import * as i0 from '@angular/core';
  10. import { InjectionToken, Directive, Inject, Optional, Input, ContentChild, Injectable, Component, ChangeDetectionStrategy, ViewEncapsulation, EmbeddedViewRef, EventEmitter, NgZone, Attribute, SkipSelf, Output, ViewChild, ContentChildren, NgModule } from '@angular/core';
  11. import { Subject, from, BehaviorSubject, isObservable, of } from 'rxjs';
  12. import { takeUntil, take } from 'rxjs/operators';
  13. /**
  14. * Mixin to provide a directive with a function that checks if the sticky input has been
  15. * changed since the last time the function was called. Essentially adds a dirty-check to the
  16. * sticky value.
  17. * @docs-private
  18. */
  19. function mixinHasStickyInput(base) {
  20. return class extends base {
  21. /** Whether sticky positioning should be applied. */
  22. get sticky() {
  23. return this._sticky;
  24. }
  25. set sticky(v) {
  26. const prevValue = this._sticky;
  27. this._sticky = coerceBooleanProperty(v);
  28. this._hasStickyChanged = prevValue !== this._sticky;
  29. }
  30. /** Whether the sticky value has changed since this was last called. */
  31. hasStickyChanged() {
  32. const hasStickyChanged = this._hasStickyChanged;
  33. this._hasStickyChanged = false;
  34. return hasStickyChanged;
  35. }
  36. /** Resets the dirty check for cases where the sticky state has been used without checking. */
  37. resetStickyChanged() {
  38. this._hasStickyChanged = false;
  39. }
  40. constructor(...args) {
  41. super(...args);
  42. this._sticky = false;
  43. /** Whether the sticky input has changed since it was last checked. */
  44. this._hasStickyChanged = false;
  45. }
  46. };
  47. }
  48. /**
  49. * Used to provide a table to some of the sub-components without causing a circular dependency.
  50. * @docs-private
  51. */
  52. const CDK_TABLE = new InjectionToken('CDK_TABLE');
  53. /** Injection token that can be used to specify the text column options. */
  54. const TEXT_COLUMN_OPTIONS = new InjectionToken('text-column-options');
  55. /**
  56. * Cell definition for a CDK table.
  57. * Captures the template of a column's data row cell as well as cell-specific properties.
  58. */
  59. class CdkCellDef {
  60. constructor(/** @docs-private */ template) {
  61. this.template = template;
  62. }
  63. 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 }); }
  64. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkCellDef, selector: "[cdkCellDef]", ngImport: i0 }); }
  65. }
  66. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkCellDef, decorators: [{
  67. type: Directive,
  68. args: [{ selector: '[cdkCellDef]' }]
  69. }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
  70. /**
  71. * Header cell definition for a CDK table.
  72. * Captures the template of a column's header cell and as well as cell-specific properties.
  73. */
  74. class CdkHeaderCellDef {
  75. constructor(/** @docs-private */ template) {
  76. this.template = template;
  77. }
  78. 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 }); }
  79. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkHeaderCellDef, selector: "[cdkHeaderCellDef]", ngImport: i0 }); }
  80. }
  81. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkHeaderCellDef, decorators: [{
  82. type: Directive,
  83. args: [{ selector: '[cdkHeaderCellDef]' }]
  84. }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
  85. /**
  86. * Footer cell definition for a CDK table.
  87. * Captures the template of a column's footer cell and as well as cell-specific properties.
  88. */
  89. class CdkFooterCellDef {
  90. constructor(/** @docs-private */ template) {
  91. this.template = template;
  92. }
  93. 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 }); }
  94. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkFooterCellDef, selector: "[cdkFooterCellDef]", ngImport: i0 }); }
  95. }
  96. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFooterCellDef, decorators: [{
  97. type: Directive,
  98. args: [{ selector: '[cdkFooterCellDef]' }]
  99. }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
  100. // Boilerplate for applying mixins to CdkColumnDef.
  101. /** @docs-private */
  102. class CdkColumnDefBase {
  103. }
  104. const _CdkColumnDefBase = mixinHasStickyInput(CdkColumnDefBase);
  105. /**
  106. * Column definition for the CDK table.
  107. * Defines a set of cells available for a table column.
  108. */
  109. class CdkColumnDef extends _CdkColumnDefBase {
  110. /** Unique name for this column. */
  111. get name() {
  112. return this._name;
  113. }
  114. set name(name) {
  115. this._setNameInput(name);
  116. }
  117. /**
  118. * Whether this column should be sticky positioned on the end of the row. Should make sure
  119. * that it mimics the `CanStick` mixin such that `_hasStickyChanged` is set to true if the value
  120. * has been changed.
  121. */
  122. get stickyEnd() {
  123. return this._stickyEnd;
  124. }
  125. set stickyEnd(v) {
  126. const prevValue = this._stickyEnd;
  127. this._stickyEnd = coerceBooleanProperty(v);
  128. this._hasStickyChanged = prevValue !== this._stickyEnd;
  129. }
  130. constructor(_table) {
  131. super();
  132. this._table = _table;
  133. this._stickyEnd = false;
  134. }
  135. /**
  136. * Overridable method that sets the css classes that will be added to every cell in this
  137. * column.
  138. * In the future, columnCssClassName will change from type string[] to string and this
  139. * will set a single string value.
  140. * @docs-private
  141. */
  142. _updateColumnCssClassName() {
  143. this._columnCssClassName = [`cdk-column-${this.cssClassFriendlyName}`];
  144. }
  145. /**
  146. * This has been extracted to a util because of TS 4 and VE.
  147. * View Engine doesn't support property rename inheritance.
  148. * TS 4.0 doesn't allow properties to override accessors or vice-versa.
  149. * @docs-private
  150. */
  151. _setNameInput(value) {
  152. // If the directive is set without a name (updated programmatically), then this setter will
  153. // trigger with an empty string and should not overwrite the programmatically set value.
  154. if (value) {
  155. this._name = value;
  156. this.cssClassFriendlyName = value.replace(/[^a-z0-9_-]/gi, '-');
  157. this._updateColumnCssClassName();
  158. }
  159. }
  160. 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 }); }
  161. 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 }); }
  162. }
  163. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkColumnDef, decorators: [{
  164. type: Directive,
  165. args: [{
  166. selector: '[cdkColumnDef]',
  167. inputs: ['sticky'],
  168. providers: [{ provide: 'MAT_SORT_HEADER_COLUMN_DEF', useExisting: CdkColumnDef }],
  169. }]
  170. }], ctorParameters: function () { return [{ type: undefined, decorators: [{
  171. type: Inject,
  172. args: [CDK_TABLE]
  173. }, {
  174. type: Optional
  175. }] }]; }, propDecorators: { name: [{
  176. type: Input,
  177. args: ['cdkColumnDef']
  178. }], stickyEnd: [{
  179. type: Input,
  180. args: ['stickyEnd']
  181. }], cell: [{
  182. type: ContentChild,
  183. args: [CdkCellDef]
  184. }], headerCell: [{
  185. type: ContentChild,
  186. args: [CdkHeaderCellDef]
  187. }], footerCell: [{
  188. type: ContentChild,
  189. args: [CdkFooterCellDef]
  190. }] } });
  191. /** Base class for the cells. Adds a CSS classname that identifies the column it renders in. */
  192. class BaseCdkCell {
  193. constructor(columnDef, elementRef) {
  194. elementRef.nativeElement.classList.add(...columnDef._columnCssClassName);
  195. }
  196. }
  197. /** Header cell template container that adds the right classes and role. */
  198. class CdkHeaderCell extends BaseCdkCell {
  199. constructor(columnDef, elementRef) {
  200. super(columnDef, elementRef);
  201. }
  202. 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 }); }
  203. 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 }); }
  204. }
  205. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkHeaderCell, decorators: [{
  206. type: Directive,
  207. args: [{
  208. selector: 'cdk-header-cell, th[cdk-header-cell]',
  209. host: {
  210. 'class': 'cdk-header-cell',
  211. 'role': 'columnheader',
  212. },
  213. }]
  214. }], ctorParameters: function () { return [{ type: CdkColumnDef }, { type: i0.ElementRef }]; } });
  215. /** Footer cell template container that adds the right classes and role. */
  216. class CdkFooterCell extends BaseCdkCell {
  217. constructor(columnDef, elementRef) {
  218. super(columnDef, elementRef);
  219. if (columnDef._table?._elementRef.nativeElement.nodeType === 1) {
  220. const tableRole = columnDef._table._elementRef.nativeElement.getAttribute('role');
  221. const role = tableRole === 'grid' || tableRole === 'treegrid' ? 'gridcell' : 'cell';
  222. elementRef.nativeElement.setAttribute('role', role);
  223. }
  224. }
  225. 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 }); }
  226. 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 }); }
  227. }
  228. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFooterCell, decorators: [{
  229. type: Directive,
  230. args: [{
  231. selector: 'cdk-footer-cell, td[cdk-footer-cell]',
  232. host: {
  233. 'class': 'cdk-footer-cell',
  234. },
  235. }]
  236. }], ctorParameters: function () { return [{ type: CdkColumnDef }, { type: i0.ElementRef }]; } });
  237. /** Cell template container that adds the right classes and role. */
  238. class CdkCell extends BaseCdkCell {
  239. constructor(columnDef, elementRef) {
  240. super(columnDef, elementRef);
  241. if (columnDef._table?._elementRef.nativeElement.nodeType === 1) {
  242. const tableRole = columnDef._table._elementRef.nativeElement.getAttribute('role');
  243. const role = tableRole === 'grid' || tableRole === 'treegrid' ? 'gridcell' : 'cell';
  244. elementRef.nativeElement.setAttribute('role', role);
  245. }
  246. }
  247. 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 }); }
  248. 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 }); }
  249. }
  250. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkCell, decorators: [{
  251. type: Directive,
  252. args: [{
  253. selector: 'cdk-cell, td[cdk-cell]',
  254. host: {
  255. 'class': 'cdk-cell',
  256. },
  257. }]
  258. }], ctorParameters: function () { return [{ type: CdkColumnDef }, { type: i0.ElementRef }]; } });
  259. /**
  260. * @docs-private
  261. */
  262. class _Schedule {
  263. constructor() {
  264. this.tasks = [];
  265. this.endTasks = [];
  266. }
  267. }
  268. /** Injection token used to provide a coalesced style scheduler. */
  269. const _COALESCED_STYLE_SCHEDULER = new InjectionToken('_COALESCED_STYLE_SCHEDULER');
  270. /**
  271. * Allows grouping up CSSDom mutations after the current execution context.
  272. * This can significantly improve performance when separate consecutive functions are
  273. * reading from the CSSDom and then mutating it.
  274. *
  275. * @docs-private
  276. */
  277. class _CoalescedStyleScheduler {
  278. constructor(_ngZone) {
  279. this._ngZone = _ngZone;
  280. this._currentSchedule = null;
  281. this._destroyed = new Subject();
  282. }
  283. /**
  284. * Schedules the specified task to run at the end of the current VM turn.
  285. */
  286. schedule(task) {
  287. this._createScheduleIfNeeded();
  288. this._currentSchedule.tasks.push(task);
  289. }
  290. /**
  291. * Schedules the specified task to run after other scheduled tasks at the end of the current
  292. * VM turn.
  293. */
  294. scheduleEnd(task) {
  295. this._createScheduleIfNeeded();
  296. this._currentSchedule.endTasks.push(task);
  297. }
  298. /** Prevent any further tasks from running. */
  299. ngOnDestroy() {
  300. this._destroyed.next();
  301. this._destroyed.complete();
  302. }
  303. _createScheduleIfNeeded() {
  304. if (this._currentSchedule) {
  305. return;
  306. }
  307. this._currentSchedule = new _Schedule();
  308. this._getScheduleObservable()
  309. .pipe(takeUntil(this._destroyed))
  310. .subscribe(() => {
  311. while (this._currentSchedule.tasks.length || this._currentSchedule.endTasks.length) {
  312. const schedule = this._currentSchedule;
  313. // Capture new tasks scheduled by the current set of tasks.
  314. this._currentSchedule = new _Schedule();
  315. for (const task of schedule.tasks) {
  316. task();
  317. }
  318. for (const task of schedule.endTasks) {
  319. task();
  320. }
  321. }
  322. this._currentSchedule = null;
  323. });
  324. }
  325. _getScheduleObservable() {
  326. // Use onStable when in the context of an ongoing change detection cycle so that we
  327. // do not accidentally trigger additional cycles.
  328. return this._ngZone.isStable
  329. ? from(Promise.resolve(undefined))
  330. : this._ngZone.onStable.pipe(take(1));
  331. }
  332. 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 }); }
  333. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: _CoalescedStyleScheduler }); }
  334. }
  335. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: _CoalescedStyleScheduler, decorators: [{
  336. type: Injectable
  337. }], ctorParameters: function () { return [{ type: i0.NgZone }]; } });
  338. /**
  339. * The row template that can be used by the mat-table. Should not be used outside of the
  340. * material library.
  341. */
  342. const CDK_ROW_TEMPLATE = `<ng-container cdkCellOutlet></ng-container>`;
  343. /**
  344. * Base class for the CdkHeaderRowDef and CdkRowDef that handles checking their columns inputs
  345. * for changes and notifying the table.
  346. */
  347. class BaseRowDef {
  348. constructor(
  349. /** @docs-private */ template, _differs) {
  350. this.template = template;
  351. this._differs = _differs;
  352. }
  353. ngOnChanges(changes) {
  354. // Create a new columns differ if one does not yet exist. Initialize it based on initial value
  355. // of the columns property or an empty array if none is provided.
  356. if (!this._columnsDiffer) {
  357. const columns = (changes['columns'] && changes['columns'].currentValue) || [];
  358. this._columnsDiffer = this._differs.find(columns).create();
  359. this._columnsDiffer.diff(columns);
  360. }
  361. }
  362. /**
  363. * Returns the difference between the current columns and the columns from the last diff, or null
  364. * if there is no difference.
  365. */
  366. getColumnsDiff() {
  367. return this._columnsDiffer.diff(this.columns);
  368. }
  369. /** Gets this row def's relevant cell template from the provided column def. */
  370. extractCellTemplate(column) {
  371. if (this instanceof CdkHeaderRowDef) {
  372. return column.headerCell.template;
  373. }
  374. if (this instanceof CdkFooterRowDef) {
  375. return column.footerCell.template;
  376. }
  377. else {
  378. return column.cell.template;
  379. }
  380. }
  381. 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 }); }
  382. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: BaseRowDef, usesOnChanges: true, ngImport: i0 }); }
  383. }
  384. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: BaseRowDef, decorators: [{
  385. type: Directive
  386. }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.IterableDiffers }]; } });
  387. // Boilerplate for applying mixins to CdkHeaderRowDef.
  388. /** @docs-private */
  389. class CdkHeaderRowDefBase extends BaseRowDef {
  390. }
  391. const _CdkHeaderRowDefBase = mixinHasStickyInput(CdkHeaderRowDefBase);
  392. /**
  393. * Header row definition for the CDK table.
  394. * Captures the header row's template and other header properties such as the columns to display.
  395. */
  396. class CdkHeaderRowDef extends _CdkHeaderRowDefBase {
  397. constructor(template, _differs, _table) {
  398. super(template, _differs);
  399. this._table = _table;
  400. }
  401. // Prerender fails to recognize that ngOnChanges in a part of this class through inheritance.
  402. // Explicitly define it so that the method is called as part of the Angular lifecycle.
  403. ngOnChanges(changes) {
  404. super.ngOnChanges(changes);
  405. }
  406. 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 }); }
  407. 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 }); }
  408. }
  409. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkHeaderRowDef, decorators: [{
  410. type: Directive,
  411. args: [{
  412. selector: '[cdkHeaderRowDef]',
  413. inputs: ['columns: cdkHeaderRowDef', 'sticky: cdkHeaderRowDefSticky'],
  414. }]
  415. }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.IterableDiffers }, { type: undefined, decorators: [{
  416. type: Inject,
  417. args: [CDK_TABLE]
  418. }, {
  419. type: Optional
  420. }] }]; } });
  421. // Boilerplate for applying mixins to CdkFooterRowDef.
  422. /** @docs-private */
  423. class CdkFooterRowDefBase extends BaseRowDef {
  424. }
  425. const _CdkFooterRowDefBase = mixinHasStickyInput(CdkFooterRowDefBase);
  426. /**
  427. * Footer row definition for the CDK table.
  428. * Captures the footer row's template and other footer properties such as the columns to display.
  429. */
  430. class CdkFooterRowDef extends _CdkFooterRowDefBase {
  431. constructor(template, _differs, _table) {
  432. super(template, _differs);
  433. this._table = _table;
  434. }
  435. // Prerender fails to recognize that ngOnChanges in a part of this class through inheritance.
  436. // Explicitly define it so that the method is called as part of the Angular lifecycle.
  437. ngOnChanges(changes) {
  438. super.ngOnChanges(changes);
  439. }
  440. 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 }); }
  441. 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 }); }
  442. }
  443. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFooterRowDef, decorators: [{
  444. type: Directive,
  445. args: [{
  446. selector: '[cdkFooterRowDef]',
  447. inputs: ['columns: cdkFooterRowDef', 'sticky: cdkFooterRowDefSticky'],
  448. }]
  449. }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.IterableDiffers }, { type: undefined, decorators: [{
  450. type: Inject,
  451. args: [CDK_TABLE]
  452. }, {
  453. type: Optional
  454. }] }]; } });
  455. /**
  456. * Data row definition for the CDK table.
  457. * Captures the header row's template and other row properties such as the columns to display and
  458. * a when predicate that describes when this row should be used.
  459. */
  460. class CdkRowDef extends BaseRowDef {
  461. // TODO(andrewseguin): Add an input for providing a switch function to determine
  462. // if this template should be used.
  463. constructor(template, _differs, _table) {
  464. super(template, _differs);
  465. this._table = _table;
  466. }
  467. 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 }); }
  468. 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 }); }
  469. }
  470. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkRowDef, decorators: [{
  471. type: Directive,
  472. args: [{
  473. selector: '[cdkRowDef]',
  474. inputs: ['columns: cdkRowDefColumns', 'when: cdkRowDefWhen'],
  475. }]
  476. }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.IterableDiffers }, { type: undefined, decorators: [{
  477. type: Inject,
  478. args: [CDK_TABLE]
  479. }, {
  480. type: Optional
  481. }] }]; } });
  482. /**
  483. * Outlet for rendering cells inside of a row or header row.
  484. * @docs-private
  485. */
  486. class CdkCellOutlet {
  487. /**
  488. * Static property containing the latest constructed instance of this class.
  489. * Used by the CDK table when each CdkHeaderRow and CdkRow component is created using
  490. * createEmbeddedView. After one of these components are created, this property will provide
  491. * a handle to provide that component's cells and context. After init, the CdkCellOutlet will
  492. * construct the cells with the provided context.
  493. */
  494. static { this.mostRecentCellOutlet = null; }
  495. constructor(_viewContainer) {
  496. this._viewContainer = _viewContainer;
  497. CdkCellOutlet.mostRecentCellOutlet = this;
  498. }
  499. ngOnDestroy() {
  500. // If this was the last outlet being rendered in the view, remove the reference
  501. // from the static property after it has been destroyed to avoid leaking memory.
  502. if (CdkCellOutlet.mostRecentCellOutlet === this) {
  503. CdkCellOutlet.mostRecentCellOutlet = null;
  504. }
  505. }
  506. 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 }); }
  507. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkCellOutlet, selector: "[cdkCellOutlet]", ngImport: i0 }); }
  508. }
  509. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkCellOutlet, decorators: [{
  510. type: Directive,
  511. args: [{ selector: '[cdkCellOutlet]' }]
  512. }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }]; } });
  513. /** Header template container that contains the cell outlet. Adds the right class and role. */
  514. class CdkHeaderRow {
  515. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkHeaderRow, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  516. 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 }); }
  517. }
  518. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkHeaderRow, decorators: [{
  519. type: Component,
  520. args: [{
  521. selector: 'cdk-header-row, tr[cdk-header-row]',
  522. template: CDK_ROW_TEMPLATE,
  523. host: {
  524. 'class': 'cdk-header-row',
  525. 'role': 'row',
  526. },
  527. // See note on CdkTable for explanation on why this uses the default change detection strategy.
  528. // tslint:disable-next-line:validate-decorators
  529. changeDetection: ChangeDetectionStrategy.Default,
  530. encapsulation: ViewEncapsulation.None,
  531. }]
  532. }] });
  533. /** Footer template container that contains the cell outlet. Adds the right class and role. */
  534. class CdkFooterRow {
  535. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFooterRow, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  536. 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 }); }
  537. }
  538. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFooterRow, decorators: [{
  539. type: Component,
  540. args: [{
  541. selector: 'cdk-footer-row, tr[cdk-footer-row]',
  542. template: CDK_ROW_TEMPLATE,
  543. host: {
  544. 'class': 'cdk-footer-row',
  545. 'role': 'row',
  546. },
  547. // See note on CdkTable for explanation on why this uses the default change detection strategy.
  548. // tslint:disable-next-line:validate-decorators
  549. changeDetection: ChangeDetectionStrategy.Default,
  550. encapsulation: ViewEncapsulation.None,
  551. }]
  552. }] });
  553. /** Data row template container that contains the cell outlet. Adds the right class and role. */
  554. class CdkRow {
  555. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkRow, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
  556. 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 }); }
  557. }
  558. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkRow, decorators: [{
  559. type: Component,
  560. args: [{
  561. selector: 'cdk-row, tr[cdk-row]',
  562. template: CDK_ROW_TEMPLATE,
  563. host: {
  564. 'class': 'cdk-row',
  565. 'role': 'row',
  566. },
  567. // See note on CdkTable for explanation on why this uses the default change detection strategy.
  568. // tslint:disable-next-line:validate-decorators
  569. changeDetection: ChangeDetectionStrategy.Default,
  570. encapsulation: ViewEncapsulation.None,
  571. }]
  572. }] });
  573. /** Row that can be used to display a message when no data is shown in the table. */
  574. class CdkNoDataRow {
  575. constructor(templateRef) {
  576. this.templateRef = templateRef;
  577. this._contentClassName = 'cdk-no-data-row';
  578. }
  579. 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 }); }
  580. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkNoDataRow, selector: "ng-template[cdkNoDataRow]", ngImport: i0 }); }
  581. }
  582. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkNoDataRow, decorators: [{
  583. type: Directive,
  584. args: [{
  585. selector: 'ng-template[cdkNoDataRow]',
  586. }]
  587. }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
  588. /**
  589. * List of all possible directions that can be used for sticky positioning.
  590. * @docs-private
  591. */
  592. const STICKY_DIRECTIONS = ['top', 'bottom', 'left', 'right'];
  593. /**
  594. * Applies and removes sticky positioning styles to the `CdkTable` rows and columns cells.
  595. * @docs-private
  596. */
  597. class StickyStyler {
  598. /**
  599. * @param _isNativeHtmlTable Whether the sticky logic should be based on a table
  600. * that uses the native `<table>` element.
  601. * @param _stickCellCss The CSS class that will be applied to every row/cell that has
  602. * sticky positioning applied.
  603. * @param direction The directionality context of the table (ltr/rtl); affects column positioning
  604. * by reversing left/right positions.
  605. * @param _isBrowser Whether the table is currently being rendered on the server or the client.
  606. * @param _needsPositionStickyOnElement Whether we need to specify position: sticky on cells
  607. * using inline styles. If false, it is assumed that position: sticky is included in
  608. * the component stylesheet for _stickCellCss.
  609. * @param _positionListener A listener that is notified of changes to sticky rows/columns
  610. * and their dimensions.
  611. */
  612. constructor(_isNativeHtmlTable, _stickCellCss, direction, _coalescedStyleScheduler, _isBrowser = true, _needsPositionStickyOnElement = true, _positionListener) {
  613. this._isNativeHtmlTable = _isNativeHtmlTable;
  614. this._stickCellCss = _stickCellCss;
  615. this.direction = direction;
  616. this._coalescedStyleScheduler = _coalescedStyleScheduler;
  617. this._isBrowser = _isBrowser;
  618. this._needsPositionStickyOnElement = _needsPositionStickyOnElement;
  619. this._positionListener = _positionListener;
  620. this._cachedCellWidths = [];
  621. this._borderCellCss = {
  622. 'top': `${_stickCellCss}-border-elem-top`,
  623. 'bottom': `${_stickCellCss}-border-elem-bottom`,
  624. 'left': `${_stickCellCss}-border-elem-left`,
  625. 'right': `${_stickCellCss}-border-elem-right`,
  626. };
  627. }
  628. /**
  629. * Clears the sticky positioning styles from the row and its cells by resetting the `position`
  630. * style, setting the zIndex to 0, and unsetting each provided sticky direction.
  631. * @param rows The list of rows that should be cleared from sticking in the provided directions
  632. * @param stickyDirections The directions that should no longer be set as sticky on the rows.
  633. */
  634. clearStickyPositioning(rows, stickyDirections) {
  635. const elementsToClear = [];
  636. for (const row of rows) {
  637. // If the row isn't an element (e.g. if it's an `ng-container`),
  638. // it won't have inline styles or `children` so we skip it.
  639. if (row.nodeType !== row.ELEMENT_NODE) {
  640. continue;
  641. }
  642. elementsToClear.push(row);
  643. for (let i = 0; i < row.children.length; i++) {
  644. elementsToClear.push(row.children[i]);
  645. }
  646. }
  647. // Coalesce with sticky row/column updates (and potentially other changes like column resize).
  648. this._coalescedStyleScheduler.schedule(() => {
  649. for (const element of elementsToClear) {
  650. this._removeStickyStyle(element, stickyDirections);
  651. }
  652. });
  653. }
  654. /**
  655. * Applies sticky left and right positions to the cells of each row according to the sticky
  656. * states of the rendered column definitions.
  657. * @param rows The rows that should have its set of cells stuck according to the sticky states.
  658. * @param stickyStartStates A list of boolean states where each state represents whether the cell
  659. * in this index position should be stuck to the start of the row.
  660. * @param stickyEndStates A list of boolean states where each state represents whether the cell
  661. * in this index position should be stuck to the end of the row.
  662. * @param recalculateCellWidths Whether the sticky styler should recalculate the width of each
  663. * column cell. If `false` cached widths will be used instead.
  664. */
  665. updateStickyColumns(rows, stickyStartStates, stickyEndStates, recalculateCellWidths = true) {
  666. if (!rows.length ||
  667. !this._isBrowser ||
  668. !(stickyStartStates.some(state => state) || stickyEndStates.some(state => state))) {
  669. if (this._positionListener) {
  670. this._positionListener.stickyColumnsUpdated({ sizes: [] });
  671. this._positionListener.stickyEndColumnsUpdated({ sizes: [] });
  672. }
  673. return;
  674. }
  675. const firstRow = rows[0];
  676. const numCells = firstRow.children.length;
  677. const cellWidths = this._getCellWidths(firstRow, recalculateCellWidths);
  678. const startPositions = this._getStickyStartColumnPositions(cellWidths, stickyStartStates);
  679. const endPositions = this._getStickyEndColumnPositions(cellWidths, stickyEndStates);
  680. const lastStickyStart = stickyStartStates.lastIndexOf(true);
  681. const firstStickyEnd = stickyEndStates.indexOf(true);
  682. // Coalesce with sticky row updates (and potentially other changes like column resize).
  683. this._coalescedStyleScheduler.schedule(() => {
  684. const isRtl = this.direction === 'rtl';
  685. const start = isRtl ? 'right' : 'left';
  686. const end = isRtl ? 'left' : 'right';
  687. for (const row of rows) {
  688. for (let i = 0; i < numCells; i++) {
  689. const cell = row.children[i];
  690. if (stickyStartStates[i]) {
  691. this._addStickyStyle(cell, start, startPositions[i], i === lastStickyStart);
  692. }
  693. if (stickyEndStates[i]) {
  694. this._addStickyStyle(cell, end, endPositions[i], i === firstStickyEnd);
  695. }
  696. }
  697. }
  698. if (this._positionListener) {
  699. this._positionListener.stickyColumnsUpdated({
  700. sizes: lastStickyStart === -1
  701. ? []
  702. : cellWidths
  703. .slice(0, lastStickyStart + 1)
  704. .map((width, index) => (stickyStartStates[index] ? width : null)),
  705. });
  706. this._positionListener.stickyEndColumnsUpdated({
  707. sizes: firstStickyEnd === -1
  708. ? []
  709. : cellWidths
  710. .slice(firstStickyEnd)
  711. .map((width, index) => (stickyEndStates[index + firstStickyEnd] ? width : null))
  712. .reverse(),
  713. });
  714. }
  715. });
  716. }
  717. /**
  718. * Applies sticky positioning to the row's cells if using the native table layout, and to the
  719. * row itself otherwise.
  720. * @param rowsToStick The list of rows that should be stuck according to their corresponding
  721. * sticky state and to the provided top or bottom position.
  722. * @param stickyStates A list of boolean states where each state represents whether the row
  723. * should be stuck in the particular top or bottom position.
  724. * @param position The position direction in which the row should be stuck if that row should be
  725. * sticky.
  726. *
  727. */
  728. stickRows(rowsToStick, stickyStates, position) {
  729. // Since we can't measure the rows on the server, we can't stick the rows properly.
  730. if (!this._isBrowser) {
  731. return;
  732. }
  733. // If positioning the rows to the bottom, reverse their order when evaluating the sticky
  734. // position such that the last row stuck will be "bottom: 0px" and so on. Note that the
  735. // sticky states need to be reversed as well.
  736. const rows = position === 'bottom' ? rowsToStick.slice().reverse() : rowsToStick;
  737. const states = position === 'bottom' ? stickyStates.slice().reverse() : stickyStates;
  738. // Measure row heights all at once before adding sticky styles to reduce layout thrashing.
  739. const stickyOffsets = [];
  740. const stickyCellHeights = [];
  741. const elementsToStick = [];
  742. for (let rowIndex = 0, stickyOffset = 0; rowIndex < rows.length; rowIndex++) {
  743. if (!states[rowIndex]) {
  744. continue;
  745. }
  746. stickyOffsets[rowIndex] = stickyOffset;
  747. const row = rows[rowIndex];
  748. elementsToStick[rowIndex] = this._isNativeHtmlTable
  749. ? Array.from(row.children)
  750. : [row];
  751. const height = row.getBoundingClientRect().height;
  752. stickyOffset += height;
  753. stickyCellHeights[rowIndex] = height;
  754. }
  755. const borderedRowIndex = states.lastIndexOf(true);
  756. // Coalesce with other sticky row updates (top/bottom), sticky columns updates
  757. // (and potentially other changes like column resize).
  758. this._coalescedStyleScheduler.schedule(() => {
  759. for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
  760. if (!states[rowIndex]) {
  761. continue;
  762. }
  763. const offset = stickyOffsets[rowIndex];
  764. const isBorderedRowIndex = rowIndex === borderedRowIndex;
  765. for (const element of elementsToStick[rowIndex]) {
  766. this._addStickyStyle(element, position, offset, isBorderedRowIndex);
  767. }
  768. }
  769. if (position === 'top') {
  770. this._positionListener?.stickyHeaderRowsUpdated({
  771. sizes: stickyCellHeights,
  772. offsets: stickyOffsets,
  773. elements: elementsToStick,
  774. });
  775. }
  776. else {
  777. this._positionListener?.stickyFooterRowsUpdated({
  778. sizes: stickyCellHeights,
  779. offsets: stickyOffsets,
  780. elements: elementsToStick,
  781. });
  782. }
  783. });
  784. }
  785. /**
  786. * When using the native table in Safari, sticky footer cells do not stick. The only way to stick
  787. * footer rows is to apply sticky styling to the tfoot container. This should only be done if
  788. * all footer rows are sticky. If not all footer rows are sticky, remove sticky positioning from
  789. * the tfoot element.
  790. */
  791. updateStickyFooterContainer(tableElement, stickyStates) {
  792. if (!this._isNativeHtmlTable) {
  793. return;
  794. }
  795. const tfoot = tableElement.querySelector('tfoot');
  796. // Coalesce with other sticky updates (and potentially other changes like column resize).
  797. this._coalescedStyleScheduler.schedule(() => {
  798. if (stickyStates.some(state => !state)) {
  799. this._removeStickyStyle(tfoot, ['bottom']);
  800. }
  801. else {
  802. this._addStickyStyle(tfoot, 'bottom', 0, false);
  803. }
  804. });
  805. }
  806. /**
  807. * Removes the sticky style on the element by removing the sticky cell CSS class, re-evaluating
  808. * the zIndex, removing each of the provided sticky directions, and removing the
  809. * sticky position if there are no more directions.
  810. */
  811. _removeStickyStyle(element, stickyDirections) {
  812. for (const dir of stickyDirections) {
  813. element.style[dir] = '';
  814. element.classList.remove(this._borderCellCss[dir]);
  815. }
  816. // If the element no longer has any more sticky directions, remove sticky positioning and
  817. // the sticky CSS class.
  818. // Short-circuit checking element.style[dir] for stickyDirections as they
  819. // were already removed above.
  820. const hasDirection = STICKY_DIRECTIONS.some(dir => stickyDirections.indexOf(dir) === -1 && element.style[dir]);
  821. if (hasDirection) {
  822. element.style.zIndex = this._getCalculatedZIndex(element);
  823. }
  824. else {
  825. // When not hasDirection, _getCalculatedZIndex will always return ''.
  826. element.style.zIndex = '';
  827. if (this._needsPositionStickyOnElement) {
  828. element.style.position = '';
  829. }
  830. element.classList.remove(this._stickCellCss);
  831. }
  832. }
  833. /**
  834. * Adds the sticky styling to the element by adding the sticky style class, changing position
  835. * to be sticky (and -webkit-sticky), setting the appropriate zIndex, and adding a sticky
  836. * direction and value.
  837. */
  838. _addStickyStyle(element, dir, dirValue, isBorderElement) {
  839. element.classList.add(this._stickCellCss);
  840. if (isBorderElement) {
  841. element.classList.add(this._borderCellCss[dir]);
  842. }
  843. element.style[dir] = `${dirValue}px`;
  844. element.style.zIndex = this._getCalculatedZIndex(element);
  845. if (this._needsPositionStickyOnElement) {
  846. element.style.cssText += 'position: -webkit-sticky; position: sticky; ';
  847. }
  848. }
  849. /**
  850. * Calculate what the z-index should be for the element, depending on what directions (top,
  851. * bottom, left, right) have been set. It should be true that elements with a top direction
  852. * should have the highest index since these are elements like a table header. If any of those
  853. * elements are also sticky in another direction, then they should appear above other elements
  854. * that are only sticky top (e.g. a sticky column on a sticky header). Bottom-sticky elements
  855. * (e.g. footer rows) should then be next in the ordering such that they are below the header
  856. * but above any non-sticky elements. Finally, left/right sticky elements (e.g. sticky columns)
  857. * should minimally increment so that they are above non-sticky elements but below top and bottom
  858. * elements.
  859. */
  860. _getCalculatedZIndex(element) {
  861. const zIndexIncrements = {
  862. top: 100,
  863. bottom: 10,
  864. left: 1,
  865. right: 1,
  866. };
  867. let zIndex = 0;
  868. // Use `Iterable` instead of `Array` because TypeScript, as of 3.6.3,
  869. // loses the array generic type in the `for of`. But we *also* have to use `Array` because
  870. // typescript won't iterate over an `Iterable` unless you compile with `--downlevelIteration`
  871. for (const dir of STICKY_DIRECTIONS) {
  872. if (element.style[dir]) {
  873. zIndex += zIndexIncrements[dir];
  874. }
  875. }
  876. return zIndex ? `${zIndex}` : '';
  877. }
  878. /** Gets the widths for each cell in the provided row. */
  879. _getCellWidths(row, recalculateCellWidths = true) {
  880. if (!recalculateCellWidths && this._cachedCellWidths.length) {
  881. return this._cachedCellWidths;
  882. }
  883. const cellWidths = [];
  884. const firstRowCells = row.children;
  885. for (let i = 0; i < firstRowCells.length; i++) {
  886. let cell = firstRowCells[i];
  887. cellWidths.push(cell.getBoundingClientRect().width);
  888. }
  889. this._cachedCellWidths = cellWidths;
  890. return cellWidths;
  891. }
  892. /**
  893. * Determines the left and right positions of each sticky column cell, which will be the
  894. * accumulation of all sticky column cell widths to the left and right, respectively.
  895. * Non-sticky cells do not need to have a value set since their positions will not be applied.
  896. */
  897. _getStickyStartColumnPositions(widths, stickyStates) {
  898. const positions = [];
  899. let nextPosition = 0;
  900. for (let i = 0; i < widths.length; i++) {
  901. if (stickyStates[i]) {
  902. positions[i] = nextPosition;
  903. nextPosition += widths[i];
  904. }
  905. }
  906. return positions;
  907. }
  908. /**
  909. * Determines the left and right positions of each sticky column cell, which will be the
  910. * accumulation of all sticky column cell widths to the left and right, respectively.
  911. * Non-sticky cells do not need to have a value set since their positions will not be applied.
  912. */
  913. _getStickyEndColumnPositions(widths, stickyStates) {
  914. const positions = [];
  915. let nextPosition = 0;
  916. for (let i = widths.length; i > 0; i--) {
  917. if (stickyStates[i]) {
  918. positions[i] = nextPosition;
  919. nextPosition += widths[i];
  920. }
  921. }
  922. return positions;
  923. }
  924. }
  925. /**
  926. * Returns an error to be thrown when attempting to find an nonexistent column.
  927. * @param id Id whose lookup failed.
  928. * @docs-private
  929. */
  930. function getTableUnknownColumnError(id) {
  931. return Error(`Could not find column with id "${id}".`);
  932. }
  933. /**
  934. * Returns an error to be thrown when two column definitions have the same name.
  935. * @docs-private
  936. */
  937. function getTableDuplicateColumnNameError(name) {
  938. return Error(`Duplicate column definition name provided: "${name}".`);
  939. }
  940. /**
  941. * Returns an error to be thrown when there are multiple rows that are missing a when function.
  942. * @docs-private
  943. */
  944. function getTableMultipleDefaultRowDefsError() {
  945. return Error(`There can only be one default row without a when predicate function.`);
  946. }
  947. /**
  948. * Returns an error to be thrown when there are no matching row defs for a particular set of data.
  949. * @docs-private
  950. */
  951. function getTableMissingMatchingRowDefError(data) {
  952. return Error(`Could not find a matching row definition for the` +
  953. `provided row data: ${JSON.stringify(data)}`);
  954. }
  955. /**
  956. * Returns an error to be thrown when there is no row definitions present in the content.
  957. * @docs-private
  958. */
  959. function getTableMissingRowDefsError() {
  960. return Error('Missing definitions for header, footer, and row; ' +
  961. 'cannot determine which columns should be rendered.');
  962. }
  963. /**
  964. * Returns an error to be thrown when the data source does not match the compatible types.
  965. * @docs-private
  966. */
  967. function getTableUnknownDataSourceError() {
  968. return Error(`Provided data source did not match an array, Observable, or DataSource`);
  969. }
  970. /**
  971. * Returns an error to be thrown when the text column cannot find a parent table to inject.
  972. * @docs-private
  973. */
  974. function getTableTextColumnMissingParentTableError() {
  975. return Error(`Text column could not find a parent table for registration.`);
  976. }
  977. /**
  978. * Returns an error to be thrown when a table text column doesn't have a name.
  979. * @docs-private
  980. */
  981. function getTableTextColumnMissingNameError() {
  982. return Error(`Table text column must have a name.`);
  983. }
  984. /** The injection token used to specify the StickyPositioningListener. */
  985. const STICKY_POSITIONING_LISTENER = new InjectionToken('CDK_SPL');
  986. /**
  987. * Enables the recycle view repeater strategy, which reduces rendering latency. Not compatible with
  988. * tables that animate rows.
  989. */
  990. class CdkRecycleRows {
  991. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkRecycleRows, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
  992. 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 }); }
  993. }
  994. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkRecycleRows, decorators: [{
  995. type: Directive,
  996. args: [{
  997. selector: 'cdk-table[recycleRows], table[cdk-table][recycleRows]',
  998. providers: [{ provide: _VIEW_REPEATER_STRATEGY, useClass: _RecycleViewRepeaterStrategy }],
  999. }]
  1000. }] });
  1001. /**
  1002. * Provides a handle for the table to grab the view container's ng-container to insert data rows.
  1003. * @docs-private
  1004. */
  1005. class DataRowOutlet {
  1006. constructor(viewContainer, elementRef) {
  1007. this.viewContainer = viewContainer;
  1008. this.elementRef = elementRef;
  1009. }
  1010. 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 }); }
  1011. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: DataRowOutlet, selector: "[rowOutlet]", ngImport: i0 }); }
  1012. }
  1013. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: DataRowOutlet, decorators: [{
  1014. type: Directive,
  1015. args: [{ selector: '[rowOutlet]' }]
  1016. }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ElementRef }]; } });
  1017. /**
  1018. * Provides a handle for the table to grab the view container's ng-container to insert the header.
  1019. * @docs-private
  1020. */
  1021. class HeaderRowOutlet {
  1022. constructor(viewContainer, elementRef) {
  1023. this.viewContainer = viewContainer;
  1024. this.elementRef = elementRef;
  1025. }
  1026. 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 }); }
  1027. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: HeaderRowOutlet, selector: "[headerRowOutlet]", ngImport: i0 }); }
  1028. }
  1029. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HeaderRowOutlet, decorators: [{
  1030. type: Directive,
  1031. args: [{ selector: '[headerRowOutlet]' }]
  1032. }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ElementRef }]; } });
  1033. /**
  1034. * Provides a handle for the table to grab the view container's ng-container to insert the footer.
  1035. * @docs-private
  1036. */
  1037. class FooterRowOutlet {
  1038. constructor(viewContainer, elementRef) {
  1039. this.viewContainer = viewContainer;
  1040. this.elementRef = elementRef;
  1041. }
  1042. 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 }); }
  1043. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: FooterRowOutlet, selector: "[footerRowOutlet]", ngImport: i0 }); }
  1044. }
  1045. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: FooterRowOutlet, decorators: [{
  1046. type: Directive,
  1047. args: [{ selector: '[footerRowOutlet]' }]
  1048. }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ElementRef }]; } });
  1049. /**
  1050. * Provides a handle for the table to grab the view
  1051. * container's ng-container to insert the no data row.
  1052. * @docs-private
  1053. */
  1054. class NoDataRowOutlet {
  1055. constructor(viewContainer, elementRef) {
  1056. this.viewContainer = viewContainer;
  1057. this.elementRef = elementRef;
  1058. }
  1059. 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 }); }
  1060. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: NoDataRowOutlet, selector: "[noDataRowOutlet]", ngImport: i0 }); }
  1061. }
  1062. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: NoDataRowOutlet, decorators: [{
  1063. type: Directive,
  1064. args: [{ selector: '[noDataRowOutlet]' }]
  1065. }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ElementRef }]; } });
  1066. /**
  1067. * The table template that can be used by the mat-table. Should not be used outside of the
  1068. * material library.
  1069. * @docs-private
  1070. */
  1071. const CDK_TABLE_TEMPLATE =
  1072. // Note that according to MDN, the `caption` element has to be projected as the **first**
  1073. // element in the table. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/caption
  1074. `
  1075. <ng-content select="caption"></ng-content>
  1076. <ng-content select="colgroup, col"></ng-content>
  1077. <ng-container headerRowOutlet></ng-container>
  1078. <ng-container rowOutlet></ng-container>
  1079. <ng-container noDataRowOutlet></ng-container>
  1080. <ng-container footerRowOutlet></ng-container>
  1081. `;
  1082. /**
  1083. * Class used to conveniently type the embedded view ref for rows with a context.
  1084. * @docs-private
  1085. */
  1086. class RowViewRef extends EmbeddedViewRef {
  1087. }
  1088. /**
  1089. * A data table that can render a header row, data rows, and a footer row.
  1090. * Uses the dataSource input to determine the data to be rendered. The data can be provided either
  1091. * as a data array, an Observable stream that emits the data array to render, or a DataSource with a
  1092. * connect function that will return an Observable stream that emits the data array to render.
  1093. */
  1094. class CdkTable {
  1095. /**
  1096. * Tracking function that will be used to check the differences in data changes. Used similarly
  1097. * to `ngFor` `trackBy` function. Optimize row operations by identifying a row based on its data
  1098. * relative to the function to know if a row should be added/removed/moved.
  1099. * Accepts a function that takes two parameters, `index` and `item`.
  1100. */
  1101. get trackBy() {
  1102. return this._trackByFn;
  1103. }
  1104. set trackBy(fn) {
  1105. if ((typeof ngDevMode === 'undefined' || ngDevMode) && fn != null && typeof fn !== 'function') {
  1106. console.warn(`trackBy must be a function, but received ${JSON.stringify(fn)}.`);
  1107. }
  1108. this._trackByFn = fn;
  1109. }
  1110. /**
  1111. * The table's source of data, which can be provided in three ways (in order of complexity):
  1112. * - Simple data array (each object represents one table row)
  1113. * - Stream that emits a data array each time the array changes
  1114. * - `DataSource` object that implements the connect/disconnect interface.
  1115. *
  1116. * If a data array is provided, the table must be notified when the array's objects are
  1117. * added, removed, or moved. This can be done by calling the `renderRows()` function which will
  1118. * render the diff since the last table render. If the data array reference is changed, the table
  1119. * will automatically trigger an update to the rows.
  1120. *
  1121. * When providing an Observable stream, the table will trigger an update automatically when the
  1122. * stream emits a new array of data.
  1123. *
  1124. * Finally, when providing a `DataSource` object, the table will use the Observable stream
  1125. * provided by the connect function and trigger updates when that stream emits new data array
  1126. * values. During the table's ngOnDestroy or when the data source is removed from the table, the
  1127. * table will call the DataSource's `disconnect` function (may be useful for cleaning up any
  1128. * subscriptions registered during the connect process).
  1129. */
  1130. get dataSource() {
  1131. return this._dataSource;
  1132. }
  1133. set dataSource(dataSource) {
  1134. if (this._dataSource !== dataSource) {
  1135. this._switchDataSource(dataSource);
  1136. }
  1137. }
  1138. /**
  1139. * Whether to allow multiple rows per data object by evaluating which rows evaluate their 'when'
  1140. * predicate to true. If `multiTemplateDataRows` is false, which is the default value, then each
  1141. * dataobject will render the first row that evaluates its when predicate to true, in the order
  1142. * defined in the table, or otherwise the default row which does not have a when predicate.
  1143. */
  1144. get multiTemplateDataRows() {
  1145. return this._multiTemplateDataRows;
  1146. }
  1147. set multiTemplateDataRows(v) {
  1148. this._multiTemplateDataRows = coerceBooleanProperty(v);
  1149. // In Ivy if this value is set via a static attribute (e.g. <table multiTemplateDataRows>),
  1150. // this setter will be invoked before the row outlet has been defined hence the null check.
  1151. if (this._rowOutlet && this._rowOutlet.viewContainer.length) {
  1152. this._forceRenderDataRows();
  1153. this.updateStickyColumnStyles();
  1154. }
  1155. }
  1156. /**
  1157. * Whether to use a fixed table layout. Enabling this option will enforce consistent column widths
  1158. * and optimize rendering sticky styles for native tables. No-op for flex tables.
  1159. */
  1160. get fixedLayout() {
  1161. return this._fixedLayout;
  1162. }
  1163. set fixedLayout(v) {
  1164. this._fixedLayout = coerceBooleanProperty(v);
  1165. // Toggling `fixedLayout` may change column widths. Sticky column styles should be recalculated.
  1166. this._forceRecalculateCellWidths = true;
  1167. this._stickyColumnStylesNeedReset = true;
  1168. }
  1169. constructor(_differs, _changeDetectorRef, _elementRef, role, _dir, _document, _platform, _viewRepeater, _coalescedStyleScheduler, _viewportRuler,
  1170. /**
  1171. * @deprecated `_stickyPositioningListener` parameter to become required.
  1172. * @breaking-change 13.0.0
  1173. */
  1174. _stickyPositioningListener,
  1175. /**
  1176. * @deprecated `_ngZone` parameter to become required.
  1177. * @breaking-change 14.0.0
  1178. */
  1179. _ngZone) {
  1180. this._differs = _differs;
  1181. this._changeDetectorRef = _changeDetectorRef;
  1182. this._elementRef = _elementRef;
  1183. this._dir = _dir;
  1184. this._platform = _platform;
  1185. this._viewRepeater = _viewRepeater;
  1186. this._coalescedStyleScheduler = _coalescedStyleScheduler;
  1187. this._viewportRuler = _viewportRuler;
  1188. this._stickyPositioningListener = _stickyPositioningListener;
  1189. this._ngZone = _ngZone;
  1190. /** Subject that emits when the component has been destroyed. */
  1191. this._onDestroy = new Subject();
  1192. /**
  1193. * Map of all the user's defined columns (header, data, and footer cell template) identified by
  1194. * name. Collection populated by the column definitions gathered by `ContentChildren` as well as
  1195. * any custom column definitions added to `_customColumnDefs`.
  1196. */
  1197. this._columnDefsByName = new Map();
  1198. /**
  1199. * Column definitions that were defined outside of the direct content children of the table.
  1200. * These will be defined when, e.g., creating a wrapper around the cdkTable that has
  1201. * column definitions as *its* content child.
  1202. */
  1203. this._customColumnDefs = new Set();
  1204. /**
  1205. * Data row definitions that were defined outside of the direct content children of the table.
  1206. * These will be defined when, e.g., creating a wrapper around the cdkTable that has
  1207. * built-in data rows as *its* content child.
  1208. */
  1209. this._customRowDefs = new Set();
  1210. /**
  1211. * Header row definitions that were defined outside of the direct content children of the table.
  1212. * These will be defined when, e.g., creating a wrapper around the cdkTable that has
  1213. * built-in header rows as *its* content child.
  1214. */
  1215. this._customHeaderRowDefs = new Set();
  1216. /**
  1217. * Footer row definitions that were defined outside of the direct content children of the table.
  1218. * These will be defined when, e.g., creating a wrapper around the cdkTable that has a
  1219. * built-in footer row as *its* content child.
  1220. */
  1221. this._customFooterRowDefs = new Set();
  1222. /**
  1223. * Whether the header row definition has been changed. Triggers an update to the header row after
  1224. * content is checked. Initialized as true so that the table renders the initial set of rows.
  1225. */
  1226. this._headerRowDefChanged = true;
  1227. /**
  1228. * Whether the footer row definition has been changed. Triggers an update to the footer row after
  1229. * content is checked. Initialized as true so that the table renders the initial set of rows.
  1230. */
  1231. this._footerRowDefChanged = true;
  1232. /**
  1233. * Whether the sticky column styles need to be updated. Set to `true` when the visible columns
  1234. * change.
  1235. */
  1236. this._stickyColumnStylesNeedReset = true;
  1237. /**
  1238. * Whether the sticky styler should recalculate cell widths when applying sticky styles. If
  1239. * `false`, cached values will be used instead. This is only applicable to tables with
  1240. * {@link fixedLayout} enabled. For other tables, cell widths will always be recalculated.
  1241. */
  1242. this._forceRecalculateCellWidths = true;
  1243. /**
  1244. * Cache of the latest rendered `RenderRow` objects as a map for easy retrieval when constructing
  1245. * a new list of `RenderRow` objects for rendering rows. Since the new list is constructed with
  1246. * the cached `RenderRow` objects when possible, the row identity is preserved when the data
  1247. * and row template matches, which allows the `IterableDiffer` to check rows by reference
  1248. * and understand which rows are added/moved/removed.
  1249. *
  1250. * Implemented as a map of maps where the first key is the `data: T` object and the second is the
  1251. * `CdkRowDef<T>` object. With the two keys, the cache points to a `RenderRow<T>` object that
  1252. * contains an array of created pairs. The array is necessary to handle cases where the data
  1253. * array contains multiple duplicate data objects and each instantiated `RenderRow` must be
  1254. * stored.
  1255. */
  1256. this._cachedRenderRowsMap = new Map();
  1257. /**
  1258. * CSS class added to any row or cell that has sticky positioning applied. May be overridden by
  1259. * table subclasses.
  1260. */
  1261. this.stickyCssClass = 'cdk-table-sticky';
  1262. /**
  1263. * Whether to manually add position: sticky to all sticky cell elements. Not needed if
  1264. * the position is set in a selector associated with the value of stickyCssClass. May be
  1265. * overridden by table subclasses
  1266. */
  1267. this.needsPositionStickyOnElement = true;
  1268. /** Whether the no data row is currently showing anything. */
  1269. this._isShowingNoDataRow = false;
  1270. this._multiTemplateDataRows = false;
  1271. this._fixedLayout = false;
  1272. /**
  1273. * Emits when the table completes rendering a set of data rows based on the latest data from the
  1274. * data source, even if the set of rows is empty.
  1275. */
  1276. this.contentChanged = new EventEmitter();
  1277. // TODO(andrewseguin): Remove max value as the end index
  1278. // and instead calculate the view on init and scroll.
  1279. /**
  1280. * Stream containing the latest information on what rows are being displayed on screen.
  1281. * Can be used by the data source to as a heuristic of what data should be provided.
  1282. *
  1283. * @docs-private
  1284. */
  1285. this.viewChange = new BehaviorSubject({
  1286. start: 0,
  1287. end: Number.MAX_VALUE,
  1288. });
  1289. if (!role) {
  1290. this._elementRef.nativeElement.setAttribute('role', 'table');
  1291. }
  1292. this._document = _document;
  1293. this._isNativeHtmlTable = this._elementRef.nativeElement.nodeName === 'TABLE';
  1294. }
  1295. ngOnInit() {
  1296. this._setupStickyStyler();
  1297. if (this._isNativeHtmlTable) {
  1298. this._applyNativeTableSections();
  1299. }
  1300. // Set up the trackBy function so that it uses the `RenderRow` as its identity by default. If
  1301. // the user has provided a custom trackBy, return the result of that function as evaluated
  1302. // with the values of the `RenderRow`'s data and index.
  1303. this._dataDiffer = this._differs.find([]).create((_i, dataRow) => {
  1304. return this.trackBy ? this.trackBy(dataRow.dataIndex, dataRow.data) : dataRow;
  1305. });
  1306. this._viewportRuler
  1307. .change()
  1308. .pipe(takeUntil(this._onDestroy))
  1309. .subscribe(() => {
  1310. this._forceRecalculateCellWidths = true;
  1311. });
  1312. }
  1313. ngAfterContentChecked() {
  1314. // Cache the row and column definitions gathered by ContentChildren and programmatic injection.
  1315. this._cacheRowDefs();
  1316. this._cacheColumnDefs();
  1317. // Make sure that the user has at least added header, footer, or data row def.
  1318. if (!this._headerRowDefs.length &&
  1319. !this._footerRowDefs.length &&
  1320. !this._rowDefs.length &&
  1321. (typeof ngDevMode === 'undefined' || ngDevMode)) {
  1322. throw getTableMissingRowDefsError();
  1323. }
  1324. // Render updates if the list of columns have been changed for the header, row, or footer defs.
  1325. const columnsChanged = this._renderUpdatedColumns();
  1326. const rowDefsChanged = columnsChanged || this._headerRowDefChanged || this._footerRowDefChanged;
  1327. // Ensure sticky column styles are reset if set to `true` elsewhere.
  1328. this._stickyColumnStylesNeedReset = this._stickyColumnStylesNeedReset || rowDefsChanged;
  1329. this._forceRecalculateCellWidths = rowDefsChanged;
  1330. // If the header row definition has been changed, trigger a render to the header row.
  1331. if (this._headerRowDefChanged) {
  1332. this._forceRenderHeaderRows();
  1333. this._headerRowDefChanged = false;
  1334. }
  1335. // If the footer row definition has been changed, trigger a render to the footer row.
  1336. if (this._footerRowDefChanged) {
  1337. this._forceRenderFooterRows();
  1338. this._footerRowDefChanged = false;
  1339. }
  1340. // If there is a data source and row definitions, connect to the data source unless a
  1341. // connection has already been made.
  1342. if (this.dataSource && this._rowDefs.length > 0 && !this._renderChangeSubscription) {
  1343. this._observeRenderChanges();
  1344. }
  1345. else if (this._stickyColumnStylesNeedReset) {
  1346. // In the above case, _observeRenderChanges will result in updateStickyColumnStyles being
  1347. // called when it row data arrives. Otherwise, we need to call it proactively.
  1348. this.updateStickyColumnStyles();
  1349. }
  1350. this._checkStickyStates();
  1351. }
  1352. ngOnDestroy() {
  1353. [
  1354. this._rowOutlet.viewContainer,
  1355. this._headerRowOutlet.viewContainer,
  1356. this._footerRowOutlet.viewContainer,
  1357. this._cachedRenderRowsMap,
  1358. this._customColumnDefs,
  1359. this._customRowDefs,
  1360. this._customHeaderRowDefs,
  1361. this._customFooterRowDefs,
  1362. this._columnDefsByName,
  1363. ].forEach(def => {
  1364. def.clear();
  1365. });
  1366. this._headerRowDefs = [];
  1367. this._footerRowDefs = [];
  1368. this._defaultRowDef = null;
  1369. this._onDestroy.next();
  1370. this._onDestroy.complete();
  1371. if (isDataSource(this.dataSource)) {
  1372. this.dataSource.disconnect(this);
  1373. }
  1374. }
  1375. /**
  1376. * Renders rows based on the table's latest set of data, which was either provided directly as an
  1377. * input or retrieved through an Observable stream (directly or from a DataSource).
  1378. * Checks for differences in the data since the last diff to perform only the necessary
  1379. * changes (add/remove/move rows).
  1380. *
  1381. * If the table's data source is a DataSource or Observable, this will be invoked automatically
  1382. * each time the provided Observable stream emits a new data array. Otherwise if your data is
  1383. * an array, this function will need to be called to render any changes.
  1384. */
  1385. renderRows() {
  1386. this._renderRows = this._getAllRenderRows();
  1387. const changes = this._dataDiffer.diff(this._renderRows);
  1388. if (!changes) {
  1389. this._updateNoDataRow();
  1390. this.contentChanged.next();
  1391. return;
  1392. }
  1393. const viewContainer = this._rowOutlet.viewContainer;
  1394. this._viewRepeater.applyChanges(changes, viewContainer, (record, _adjustedPreviousIndex, currentIndex) => this._getEmbeddedViewArgs(record.item, currentIndex), record => record.item.data, (change) => {
  1395. if (change.operation === 1 /* _ViewRepeaterOperation.INSERTED */ && change.context) {
  1396. this._renderCellTemplateForItem(change.record.item.rowDef, change.context);
  1397. }
  1398. });
  1399. // Update the meta context of a row's context data (index, count, first, last, ...)
  1400. this._updateRowIndexContext();
  1401. // Update rows that did not get added/removed/moved but may have had their identity changed,
  1402. // e.g. if trackBy matched data on some property but the actual data reference changed.
  1403. changes.forEachIdentityChange((record) => {
  1404. const rowView = viewContainer.get(record.currentIndex);
  1405. rowView.context.$implicit = record.item.data;
  1406. });
  1407. this._updateNoDataRow();
  1408. // Allow the new row data to render before measuring it.
  1409. // @breaking-change 14.0.0 Remove undefined check once _ngZone is required.
  1410. if (this._ngZone && NgZone.isInAngularZone()) {
  1411. this._ngZone.onStable.pipe(take(1), takeUntil(this._onDestroy)).subscribe(() => {
  1412. this.updateStickyColumnStyles();
  1413. });
  1414. }
  1415. else {
  1416. this.updateStickyColumnStyles();
  1417. }
  1418. this.contentChanged.next();
  1419. }
  1420. /** Adds a column definition that was not included as part of the content children. */
  1421. addColumnDef(columnDef) {
  1422. this._customColumnDefs.add(columnDef);
  1423. }
  1424. /** Removes a column definition that was not included as part of the content children. */
  1425. removeColumnDef(columnDef) {
  1426. this._customColumnDefs.delete(columnDef);
  1427. }
  1428. /** Adds a row definition that was not included as part of the content children. */
  1429. addRowDef(rowDef) {
  1430. this._customRowDefs.add(rowDef);
  1431. }
  1432. /** Removes a row definition that was not included as part of the content children. */
  1433. removeRowDef(rowDef) {
  1434. this._customRowDefs.delete(rowDef);
  1435. }
  1436. /** Adds a header row definition that was not included as part of the content children. */
  1437. addHeaderRowDef(headerRowDef) {
  1438. this._customHeaderRowDefs.add(headerRowDef);
  1439. this._headerRowDefChanged = true;
  1440. }
  1441. /** Removes a header row definition that was not included as part of the content children. */
  1442. removeHeaderRowDef(headerRowDef) {
  1443. this._customHeaderRowDefs.delete(headerRowDef);
  1444. this._headerRowDefChanged = true;
  1445. }
  1446. /** Adds a footer row definition that was not included as part of the content children. */
  1447. addFooterRowDef(footerRowDef) {
  1448. this._customFooterRowDefs.add(footerRowDef);
  1449. this._footerRowDefChanged = true;
  1450. }
  1451. /** Removes a footer row definition that was not included as part of the content children. */
  1452. removeFooterRowDef(footerRowDef) {
  1453. this._customFooterRowDefs.delete(footerRowDef);
  1454. this._footerRowDefChanged = true;
  1455. }
  1456. /** Sets a no data row definition that was not included as a part of the content children. */
  1457. setNoDataRow(noDataRow) {
  1458. this._customNoDataRow = noDataRow;
  1459. }
  1460. /**
  1461. * Updates the header sticky styles. First resets all applied styles with respect to the cells
  1462. * sticking to the top. Then, evaluating which cells need to be stuck to the top. This is
  1463. * automatically called when the header row changes its displayed set of columns, or if its
  1464. * sticky input changes. May be called manually for cases where the cell content changes outside
  1465. * of these events.
  1466. */
  1467. updateStickyHeaderRowStyles() {
  1468. const headerRows = this._getRenderedRows(this._headerRowOutlet);
  1469. const tableElement = this._elementRef.nativeElement;
  1470. // Hide the thead element if there are no header rows. This is necessary to satisfy
  1471. // overzealous a11y checkers that fail because the `rowgroup` element does not contain
  1472. // required child `row`.
  1473. const thead = tableElement.querySelector('thead');
  1474. if (thead) {
  1475. thead.style.display = headerRows.length ? '' : 'none';
  1476. }
  1477. const stickyStates = this._headerRowDefs.map(def => def.sticky);
  1478. this._stickyStyler.clearStickyPositioning(headerRows, ['top']);
  1479. this._stickyStyler.stickRows(headerRows, stickyStates, 'top');
  1480. // Reset the dirty state of the sticky input change since it has been used.
  1481. this._headerRowDefs.forEach(def => def.resetStickyChanged());
  1482. }
  1483. /**
  1484. * Updates the footer sticky styles. First resets all applied styles with respect to the cells
  1485. * sticking to the bottom. Then, evaluating which cells need to be stuck to the bottom. This is
  1486. * automatically called when the footer row changes its displayed set of columns, or if its
  1487. * sticky input changes. May be called manually for cases where the cell content changes outside
  1488. * of these events.
  1489. */
  1490. updateStickyFooterRowStyles() {
  1491. const footerRows = this._getRenderedRows(this._footerRowOutlet);
  1492. const tableElement = this._elementRef.nativeElement;
  1493. // Hide the tfoot element if there are no footer rows. This is necessary to satisfy
  1494. // overzealous a11y checkers that fail because the `rowgroup` element does not contain
  1495. // required child `row`.
  1496. const tfoot = tableElement.querySelector('tfoot');
  1497. if (tfoot) {
  1498. tfoot.style.display = footerRows.length ? '' : 'none';
  1499. }
  1500. const stickyStates = this._footerRowDefs.map(def => def.sticky);
  1501. this._stickyStyler.clearStickyPositioning(footerRows, ['bottom']);
  1502. this._stickyStyler.stickRows(footerRows, stickyStates, 'bottom');
  1503. this._stickyStyler.updateStickyFooterContainer(this._elementRef.nativeElement, stickyStates);
  1504. // Reset the dirty state of the sticky input change since it has been used.
  1505. this._footerRowDefs.forEach(def => def.resetStickyChanged());
  1506. }
  1507. /**
  1508. * Updates the column sticky styles. First resets all applied styles with respect to the cells
  1509. * sticking to the left and right. Then sticky styles are added for the left and right according
  1510. * to the column definitions for each cell in each row. This is automatically called when
  1511. * the data source provides a new set of data or when a column definition changes its sticky
  1512. * input. May be called manually for cases where the cell content changes outside of these events.
  1513. */
  1514. updateStickyColumnStyles() {
  1515. const headerRows = this._getRenderedRows(this._headerRowOutlet);
  1516. const dataRows = this._getRenderedRows(this._rowOutlet);
  1517. const footerRows = this._getRenderedRows(this._footerRowOutlet);
  1518. // For tables not using a fixed layout, the column widths may change when new rows are rendered.
  1519. // In a table using a fixed layout, row content won't affect column width, so sticky styles
  1520. // don't need to be cleared unless either the sticky column config changes or one of the row
  1521. // defs change.
  1522. if ((this._isNativeHtmlTable && !this._fixedLayout) || this._stickyColumnStylesNeedReset) {
  1523. // Clear the left and right positioning from all columns in the table across all rows since
  1524. // sticky columns span across all table sections (header, data, footer)
  1525. this._stickyStyler.clearStickyPositioning([...headerRows, ...dataRows, ...footerRows], ['left', 'right']);
  1526. this._stickyColumnStylesNeedReset = false;
  1527. }
  1528. // Update the sticky styles for each header row depending on the def's sticky state
  1529. headerRows.forEach((headerRow, i) => {
  1530. this._addStickyColumnStyles([headerRow], this._headerRowDefs[i]);
  1531. });
  1532. // Update the sticky styles for each data row depending on its def's sticky state
  1533. this._rowDefs.forEach(rowDef => {
  1534. // Collect all the rows rendered with this row definition.
  1535. const rows = [];
  1536. for (let i = 0; i < dataRows.length; i++) {
  1537. if (this._renderRows[i].rowDef === rowDef) {
  1538. rows.push(dataRows[i]);
  1539. }
  1540. }
  1541. this._addStickyColumnStyles(rows, rowDef);
  1542. });
  1543. // Update the sticky styles for each footer row depending on the def's sticky state
  1544. footerRows.forEach((footerRow, i) => {
  1545. this._addStickyColumnStyles([footerRow], this._footerRowDefs[i]);
  1546. });
  1547. // Reset the dirty state of the sticky input change since it has been used.
  1548. Array.from(this._columnDefsByName.values()).forEach(def => def.resetStickyChanged());
  1549. }
  1550. /**
  1551. * Get the list of RenderRow objects to render according to the current list of data and defined
  1552. * row definitions. If the previous list already contained a particular pair, it should be reused
  1553. * so that the differ equates their references.
  1554. */
  1555. _getAllRenderRows() {
  1556. const renderRows = [];
  1557. // Store the cache and create a new one. Any re-used RenderRow objects will be moved into the
  1558. // new cache while unused ones can be picked up by garbage collection.
  1559. const prevCachedRenderRows = this._cachedRenderRowsMap;
  1560. this._cachedRenderRowsMap = new Map();
  1561. // For each data object, get the list of rows that should be rendered, represented by the
  1562. // respective `RenderRow` object which is the pair of `data` and `CdkRowDef`.
  1563. for (let i = 0; i < this._data.length; i++) {
  1564. let data = this._data[i];
  1565. const renderRowsForData = this._getRenderRowsForData(data, i, prevCachedRenderRows.get(data));
  1566. if (!this._cachedRenderRowsMap.has(data)) {
  1567. this._cachedRenderRowsMap.set(data, new WeakMap());
  1568. }
  1569. for (let j = 0; j < renderRowsForData.length; j++) {
  1570. let renderRow = renderRowsForData[j];
  1571. const cache = this._cachedRenderRowsMap.get(renderRow.data);
  1572. if (cache.has(renderRow.rowDef)) {
  1573. cache.get(renderRow.rowDef).push(renderRow);
  1574. }
  1575. else {
  1576. cache.set(renderRow.rowDef, [renderRow]);
  1577. }
  1578. renderRows.push(renderRow);
  1579. }
  1580. }
  1581. return renderRows;
  1582. }
  1583. /**
  1584. * Gets a list of `RenderRow<T>` for the provided data object and any `CdkRowDef` objects that
  1585. * should be rendered for this data. Reuses the cached RenderRow objects if they match the same
  1586. * `(T, CdkRowDef)` pair.
  1587. */
  1588. _getRenderRowsForData(data, dataIndex, cache) {
  1589. const rowDefs = this._getRowDefs(data, dataIndex);
  1590. return rowDefs.map(rowDef => {
  1591. const cachedRenderRows = cache && cache.has(rowDef) ? cache.get(rowDef) : [];
  1592. if (cachedRenderRows.length) {
  1593. const dataRow = cachedRenderRows.shift();
  1594. dataRow.dataIndex = dataIndex;
  1595. return dataRow;
  1596. }
  1597. else {
  1598. return { data, rowDef, dataIndex };
  1599. }
  1600. });
  1601. }
  1602. /** Update the map containing the content's column definitions. */
  1603. _cacheColumnDefs() {
  1604. this._columnDefsByName.clear();
  1605. const columnDefs = mergeArrayAndSet(this._getOwnDefs(this._contentColumnDefs), this._customColumnDefs);
  1606. columnDefs.forEach(columnDef => {
  1607. if (this._columnDefsByName.has(columnDef.name) &&
  1608. (typeof ngDevMode === 'undefined' || ngDevMode)) {
  1609. throw getTableDuplicateColumnNameError(columnDef.name);
  1610. }
  1611. this._columnDefsByName.set(columnDef.name, columnDef);
  1612. });
  1613. }
  1614. /** Update the list of all available row definitions that can be used. */
  1615. _cacheRowDefs() {
  1616. this._headerRowDefs = mergeArrayAndSet(this._getOwnDefs(this._contentHeaderRowDefs), this._customHeaderRowDefs);
  1617. this._footerRowDefs = mergeArrayAndSet(this._getOwnDefs(this._contentFooterRowDefs), this._customFooterRowDefs);
  1618. this._rowDefs = mergeArrayAndSet(this._getOwnDefs(this._contentRowDefs), this._customRowDefs);
  1619. // After all row definitions are determined, find the row definition to be considered default.
  1620. const defaultRowDefs = this._rowDefs.filter(def => !def.when);
  1621. if (!this.multiTemplateDataRows &&
  1622. defaultRowDefs.length > 1 &&
  1623. (typeof ngDevMode === 'undefined' || ngDevMode)) {
  1624. throw getTableMultipleDefaultRowDefsError();
  1625. }
  1626. this._defaultRowDef = defaultRowDefs[0];
  1627. }
  1628. /**
  1629. * Check if the header, data, or footer rows have changed what columns they want to display or
  1630. * whether the sticky states have changed for the header or footer. If there is a diff, then
  1631. * re-render that section.
  1632. */
  1633. _renderUpdatedColumns() {
  1634. const columnsDiffReducer = (acc, def) => acc || !!def.getColumnsDiff();
  1635. // Force re-render data rows if the list of column definitions have changed.
  1636. const dataColumnsChanged = this._rowDefs.reduce(columnsDiffReducer, false);
  1637. if (dataColumnsChanged) {
  1638. this._forceRenderDataRows();
  1639. }
  1640. // Force re-render header/footer rows if the list of column definitions have changed.
  1641. const headerColumnsChanged = this._headerRowDefs.reduce(columnsDiffReducer, false);
  1642. if (headerColumnsChanged) {
  1643. this._forceRenderHeaderRows();
  1644. }
  1645. const footerColumnsChanged = this._footerRowDefs.reduce(columnsDiffReducer, false);
  1646. if (footerColumnsChanged) {
  1647. this._forceRenderFooterRows();
  1648. }
  1649. return dataColumnsChanged || headerColumnsChanged || footerColumnsChanged;
  1650. }
  1651. /**
  1652. * Switch to the provided data source by resetting the data and unsubscribing from the current
  1653. * render change subscription if one exists. If the data source is null, interpret this by
  1654. * clearing the row outlet. Otherwise start listening for new data.
  1655. */
  1656. _switchDataSource(dataSource) {
  1657. this._data = [];
  1658. if (isDataSource(this.dataSource)) {
  1659. this.dataSource.disconnect(this);
  1660. }
  1661. // Stop listening for data from the previous data source.
  1662. if (this._renderChangeSubscription) {
  1663. this._renderChangeSubscription.unsubscribe();
  1664. this._renderChangeSubscription = null;
  1665. }
  1666. if (!dataSource) {
  1667. if (this._dataDiffer) {
  1668. this._dataDiffer.diff([]);
  1669. }
  1670. this._rowOutlet.viewContainer.clear();
  1671. }
  1672. this._dataSource = dataSource;
  1673. }
  1674. /** Set up a subscription for the data provided by the data source. */
  1675. _observeRenderChanges() {
  1676. // If no data source has been set, there is nothing to observe for changes.
  1677. if (!this.dataSource) {
  1678. return;
  1679. }
  1680. let dataStream;
  1681. if (isDataSource(this.dataSource)) {
  1682. dataStream = this.dataSource.connect(this);
  1683. }
  1684. else if (isObservable(this.dataSource)) {
  1685. dataStream = this.dataSource;
  1686. }
  1687. else if (Array.isArray(this.dataSource)) {
  1688. dataStream = of(this.dataSource);
  1689. }
  1690. if (dataStream === undefined && (typeof ngDevMode === 'undefined' || ngDevMode)) {
  1691. throw getTableUnknownDataSourceError();
  1692. }
  1693. this._renderChangeSubscription = dataStream
  1694. .pipe(takeUntil(this._onDestroy))
  1695. .subscribe(data => {
  1696. this._data = data || [];
  1697. this.renderRows();
  1698. });
  1699. }
  1700. /**
  1701. * Clears any existing content in the header row outlet and creates a new embedded view
  1702. * in the outlet using the header row definition.
  1703. */
  1704. _forceRenderHeaderRows() {
  1705. // Clear the header row outlet if any content exists.
  1706. if (this._headerRowOutlet.viewContainer.length > 0) {
  1707. this._headerRowOutlet.viewContainer.clear();
  1708. }
  1709. this._headerRowDefs.forEach((def, i) => this._renderRow(this._headerRowOutlet, def, i));
  1710. this.updateStickyHeaderRowStyles();
  1711. }
  1712. /**
  1713. * Clears any existing content in the footer row outlet and creates a new embedded view
  1714. * in the outlet using the footer row definition.
  1715. */
  1716. _forceRenderFooterRows() {
  1717. // Clear the footer row outlet if any content exists.
  1718. if (this._footerRowOutlet.viewContainer.length > 0) {
  1719. this._footerRowOutlet.viewContainer.clear();
  1720. }
  1721. this._footerRowDefs.forEach((def, i) => this._renderRow(this._footerRowOutlet, def, i));
  1722. this.updateStickyFooterRowStyles();
  1723. }
  1724. /** Adds the sticky column styles for the rows according to the columns' stick states. */
  1725. _addStickyColumnStyles(rows, rowDef) {
  1726. const columnDefs = Array.from(rowDef.columns || []).map(columnName => {
  1727. const columnDef = this._columnDefsByName.get(columnName);
  1728. if (!columnDef && (typeof ngDevMode === 'undefined' || ngDevMode)) {
  1729. throw getTableUnknownColumnError(columnName);
  1730. }
  1731. return columnDef;
  1732. });
  1733. const stickyStartStates = columnDefs.map(columnDef => columnDef.sticky);
  1734. const stickyEndStates = columnDefs.map(columnDef => columnDef.stickyEnd);
  1735. this._stickyStyler.updateStickyColumns(rows, stickyStartStates, stickyEndStates, !this._fixedLayout || this._forceRecalculateCellWidths);
  1736. }
  1737. /** Gets the list of rows that have been rendered in the row outlet. */
  1738. _getRenderedRows(rowOutlet) {
  1739. const renderedRows = [];
  1740. for (let i = 0; i < rowOutlet.viewContainer.length; i++) {
  1741. const viewRef = rowOutlet.viewContainer.get(i);
  1742. renderedRows.push(viewRef.rootNodes[0]);
  1743. }
  1744. return renderedRows;
  1745. }
  1746. /**
  1747. * Get the matching row definitions that should be used for this row data. If there is only
  1748. * one row definition, it is returned. Otherwise, find the row definitions that has a when
  1749. * predicate that returns true with the data. If none return true, return the default row
  1750. * definition.
  1751. */
  1752. _getRowDefs(data, dataIndex) {
  1753. if (this._rowDefs.length == 1) {
  1754. return [this._rowDefs[0]];
  1755. }
  1756. let rowDefs = [];
  1757. if (this.multiTemplateDataRows) {
  1758. rowDefs = this._rowDefs.filter(def => !def.when || def.when(dataIndex, data));
  1759. }
  1760. else {
  1761. let rowDef = this._rowDefs.find(def => def.when && def.when(dataIndex, data)) || this._defaultRowDef;
  1762. if (rowDef) {
  1763. rowDefs.push(rowDef);
  1764. }
  1765. }
  1766. if (!rowDefs.length && (typeof ngDevMode === 'undefined' || ngDevMode)) {
  1767. throw getTableMissingMatchingRowDefError(data);
  1768. }
  1769. return rowDefs;
  1770. }
  1771. _getEmbeddedViewArgs(renderRow, index) {
  1772. const rowDef = renderRow.rowDef;
  1773. const context = { $implicit: renderRow.data };
  1774. return {
  1775. templateRef: rowDef.template,
  1776. context,
  1777. index,
  1778. };
  1779. }
  1780. /**
  1781. * Creates a new row template in the outlet and fills it with the set of cell templates.
  1782. * Optionally takes a context to provide to the row and cells, as well as an optional index
  1783. * of where to place the new row template in the outlet.
  1784. */
  1785. _renderRow(outlet, rowDef, index, context = {}) {
  1786. // TODO(andrewseguin): enforce that one outlet was instantiated from createEmbeddedView
  1787. const view = outlet.viewContainer.createEmbeddedView(rowDef.template, context, index);
  1788. this._renderCellTemplateForItem(rowDef, context);
  1789. return view;
  1790. }
  1791. _renderCellTemplateForItem(rowDef, context) {
  1792. for (let cellTemplate of this._getCellTemplates(rowDef)) {
  1793. if (CdkCellOutlet.mostRecentCellOutlet) {
  1794. CdkCellOutlet.mostRecentCellOutlet._viewContainer.createEmbeddedView(cellTemplate, context);
  1795. }
  1796. }
  1797. this._changeDetectorRef.markForCheck();
  1798. }
  1799. /**
  1800. * Updates the index-related context for each row to reflect any changes in the index of the rows,
  1801. * e.g. first/last/even/odd.
  1802. */
  1803. _updateRowIndexContext() {
  1804. const viewContainer = this._rowOutlet.viewContainer;
  1805. for (let renderIndex = 0, count = viewContainer.length; renderIndex < count; renderIndex++) {
  1806. const viewRef = viewContainer.get(renderIndex);
  1807. const context = viewRef.context;
  1808. context.count = count;
  1809. context.first = renderIndex === 0;
  1810. context.last = renderIndex === count - 1;
  1811. context.even = renderIndex % 2 === 0;
  1812. context.odd = !context.even;
  1813. if (this.multiTemplateDataRows) {
  1814. context.dataIndex = this._renderRows[renderIndex].dataIndex;
  1815. context.renderIndex = renderIndex;
  1816. }
  1817. else {
  1818. context.index = this._renderRows[renderIndex].dataIndex;
  1819. }
  1820. }
  1821. }
  1822. /** Gets the column definitions for the provided row def. */
  1823. _getCellTemplates(rowDef) {
  1824. if (!rowDef || !rowDef.columns) {
  1825. return [];
  1826. }
  1827. return Array.from(rowDef.columns, columnId => {
  1828. const column = this._columnDefsByName.get(columnId);
  1829. if (!column && (typeof ngDevMode === 'undefined' || ngDevMode)) {
  1830. throw getTableUnknownColumnError(columnId);
  1831. }
  1832. return rowDef.extractCellTemplate(column);
  1833. });
  1834. }
  1835. /** Adds native table sections (e.g. tbody) and moves the row outlets into them. */
  1836. _applyNativeTableSections() {
  1837. const documentFragment = this._document.createDocumentFragment();
  1838. const sections = [
  1839. { tag: 'thead', outlets: [this._headerRowOutlet] },
  1840. { tag: 'tbody', outlets: [this._rowOutlet, this._noDataRowOutlet] },
  1841. { tag: 'tfoot', outlets: [this._footerRowOutlet] },
  1842. ];
  1843. for (const section of sections) {
  1844. const element = this._document.createElement(section.tag);
  1845. element.setAttribute('role', 'rowgroup');
  1846. for (const outlet of section.outlets) {
  1847. element.appendChild(outlet.elementRef.nativeElement);
  1848. }
  1849. documentFragment.appendChild(element);
  1850. }
  1851. // Use a DocumentFragment so we don't hit the DOM on each iteration.
  1852. this._elementRef.nativeElement.appendChild(documentFragment);
  1853. }
  1854. /**
  1855. * Forces a re-render of the data rows. Should be called in cases where there has been an input
  1856. * change that affects the evaluation of which rows should be rendered, e.g. toggling
  1857. * `multiTemplateDataRows` or adding/removing row definitions.
  1858. */
  1859. _forceRenderDataRows() {
  1860. this._dataDiffer.diff([]);
  1861. this._rowOutlet.viewContainer.clear();
  1862. this.renderRows();
  1863. }
  1864. /**
  1865. * Checks if there has been a change in sticky states since last check and applies the correct
  1866. * sticky styles. Since checking resets the "dirty" state, this should only be performed once
  1867. * during a change detection and after the inputs are settled (after content check).
  1868. */
  1869. _checkStickyStates() {
  1870. const stickyCheckReducer = (acc, d) => {
  1871. return acc || d.hasStickyChanged();
  1872. };
  1873. // Note that the check needs to occur for every definition since it notifies the definition
  1874. // that it can reset its dirty state. Using another operator like `some` may short-circuit
  1875. // remaining definitions and leave them in an unchecked state.
  1876. if (this._headerRowDefs.reduce(stickyCheckReducer, false)) {
  1877. this.updateStickyHeaderRowStyles();
  1878. }
  1879. if (this._footerRowDefs.reduce(stickyCheckReducer, false)) {
  1880. this.updateStickyFooterRowStyles();
  1881. }
  1882. if (Array.from(this._columnDefsByName.values()).reduce(stickyCheckReducer, false)) {
  1883. this._stickyColumnStylesNeedReset = true;
  1884. this.updateStickyColumnStyles();
  1885. }
  1886. }
  1887. /**
  1888. * Creates the sticky styler that will be used for sticky rows and columns. Listens
  1889. * for directionality changes and provides the latest direction to the styler. Re-applies column
  1890. * stickiness when directionality changes.
  1891. */
  1892. _setupStickyStyler() {
  1893. const direction = this._dir ? this._dir.value : 'ltr';
  1894. this._stickyStyler = new StickyStyler(this._isNativeHtmlTable, this.stickyCssClass, direction, this._coalescedStyleScheduler, this._platform.isBrowser, this.needsPositionStickyOnElement, this._stickyPositioningListener);
  1895. (this._dir ? this._dir.change : of())
  1896. .pipe(takeUntil(this._onDestroy))
  1897. .subscribe(value => {
  1898. this._stickyStyler.direction = value;
  1899. this.updateStickyColumnStyles();
  1900. });
  1901. }
  1902. /** Filters definitions that belong to this table from a QueryList. */
  1903. _getOwnDefs(items) {
  1904. return items.filter(item => !item._table || item._table === this);
  1905. }
  1906. /** Creates or removes the no data row, depending on whether any data is being shown. */
  1907. _updateNoDataRow() {
  1908. const noDataRow = this._customNoDataRow || this._noDataRow;
  1909. if (!noDataRow) {
  1910. return;
  1911. }
  1912. const shouldShow = this._rowOutlet.viewContainer.length === 0;
  1913. if (shouldShow === this._isShowingNoDataRow) {
  1914. return;
  1915. }
  1916. const container = this._noDataRowOutlet.viewContainer;
  1917. if (shouldShow) {
  1918. const view = container.createEmbeddedView(noDataRow.templateRef);
  1919. const rootNode = view.rootNodes[0];
  1920. // Only add the attributes if we have a single root node since it's hard
  1921. // to figure out which one to add it to when there are multiple.
  1922. if (view.rootNodes.length === 1 && rootNode?.nodeType === this._document.ELEMENT_NODE) {
  1923. rootNode.setAttribute('role', 'row');
  1924. rootNode.classList.add(noDataRow._contentClassName);
  1925. }
  1926. }
  1927. else {
  1928. container.clear();
  1929. }
  1930. this._isShowingNoDataRow = shouldShow;
  1931. }
  1932. 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 }); }
  1933. 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: [
  1934. { provide: CDK_TABLE, useExisting: CdkTable },
  1935. { provide: _VIEW_REPEATER_STRATEGY, useClass: _DisposeViewRepeaterStrategy },
  1936. { provide: _COALESCED_STYLE_SCHEDULER, useClass: _CoalescedStyleScheduler },
  1937. // Prevent nested tables from seeing this table's StickyPositioningListener.
  1938. { provide: STICKY_POSITIONING_LISTENER, useValue: null },
  1939. ], 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 }); }
  1940. }
  1941. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkTable, decorators: [{
  1942. type: Component,
  1943. args: [{ selector: 'cdk-table, table[cdk-table]', exportAs: 'cdkTable', template: CDK_TABLE_TEMPLATE, host: {
  1944. 'class': 'cdk-table',
  1945. '[class.cdk-table-fixed-layout]': 'fixedLayout',
  1946. 'ngSkipHydration': '',
  1947. }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.Default, providers: [
  1948. { provide: CDK_TABLE, useExisting: CdkTable },
  1949. { provide: _VIEW_REPEATER_STRATEGY, useClass: _DisposeViewRepeaterStrategy },
  1950. { provide: _COALESCED_STYLE_SCHEDULER, useClass: _CoalescedStyleScheduler },
  1951. // Prevent nested tables from seeing this table's StickyPositioningListener.
  1952. { provide: STICKY_POSITIONING_LISTENER, useValue: null },
  1953. ], styles: [".cdk-table-fixed-layout{table-layout:fixed}"] }]
  1954. }], ctorParameters: function () { return [{ type: i0.IterableDiffers }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: undefined, decorators: [{
  1955. type: Attribute,
  1956. args: ['role']
  1957. }] }, { type: i1.Directionality, decorators: [{
  1958. type: Optional
  1959. }] }, { type: undefined, decorators: [{
  1960. type: Inject,
  1961. args: [DOCUMENT]
  1962. }] }, { type: i2.Platform }, { type: undefined, decorators: [{
  1963. type: Inject,
  1964. args: [_VIEW_REPEATER_STRATEGY]
  1965. }] }, { type: _CoalescedStyleScheduler, decorators: [{
  1966. type: Inject,
  1967. args: [_COALESCED_STYLE_SCHEDULER]
  1968. }] }, { type: i3.ViewportRuler }, { type: undefined, decorators: [{
  1969. type: Optional
  1970. }, {
  1971. type: SkipSelf
  1972. }, {
  1973. type: Inject,
  1974. args: [STICKY_POSITIONING_LISTENER]
  1975. }] }, { type: i0.NgZone, decorators: [{
  1976. type: Optional
  1977. }] }]; }, propDecorators: { trackBy: [{
  1978. type: Input
  1979. }], dataSource: [{
  1980. type: Input
  1981. }], multiTemplateDataRows: [{
  1982. type: Input
  1983. }], fixedLayout: [{
  1984. type: Input
  1985. }], contentChanged: [{
  1986. type: Output
  1987. }], _rowOutlet: [{
  1988. type: ViewChild,
  1989. args: [DataRowOutlet, { static: true }]
  1990. }], _headerRowOutlet: [{
  1991. type: ViewChild,
  1992. args: [HeaderRowOutlet, { static: true }]
  1993. }], _footerRowOutlet: [{
  1994. type: ViewChild,
  1995. args: [FooterRowOutlet, { static: true }]
  1996. }], _noDataRowOutlet: [{
  1997. type: ViewChild,
  1998. args: [NoDataRowOutlet, { static: true }]
  1999. }], _contentColumnDefs: [{
  2000. type: ContentChildren,
  2001. args: [CdkColumnDef, { descendants: true }]
  2002. }], _contentRowDefs: [{
  2003. type: ContentChildren,
  2004. args: [CdkRowDef, { descendants: true }]
  2005. }], _contentHeaderRowDefs: [{
  2006. type: ContentChildren,
  2007. args: [CdkHeaderRowDef, {
  2008. descendants: true,
  2009. }]
  2010. }], _contentFooterRowDefs: [{
  2011. type: ContentChildren,
  2012. args: [CdkFooterRowDef, {
  2013. descendants: true,
  2014. }]
  2015. }], _noDataRow: [{
  2016. type: ContentChild,
  2017. args: [CdkNoDataRow]
  2018. }] } });
  2019. /** Utility function that gets a merged list of the entries in an array and values of a Set. */
  2020. function mergeArrayAndSet(array, set) {
  2021. return array.concat(Array.from(set));
  2022. }
  2023. /**
  2024. * Column that simply shows text content for the header and row cells. Assumes that the table
  2025. * is using the native table implementation (`<table>`).
  2026. *
  2027. * By default, the name of this column will be the header text and data property accessor.
  2028. * The header text can be overridden with the `headerText` input. Cell values can be overridden with
  2029. * the `dataAccessor` input. Change the text justification to the start or end using the `justify`
  2030. * input.
  2031. */
  2032. class CdkTextColumn {
  2033. /** Column name that should be used to reference this column. */
  2034. get name() {
  2035. return this._name;
  2036. }
  2037. set name(name) {
  2038. this._name = name;
  2039. // With Ivy, inputs can be initialized before static query results are
  2040. // available. In that case, we defer the synchronization until "ngOnInit" fires.
  2041. this._syncColumnDefName();
  2042. }
  2043. constructor(
  2044. // `CdkTextColumn` is always requiring a table, but we just assert it manually
  2045. // for better error reporting.
  2046. // tslint:disable-next-line: lightweight-tokens
  2047. _table, _options) {
  2048. this._table = _table;
  2049. this._options = _options;
  2050. /** Alignment of the cell values. */
  2051. this.justify = 'start';
  2052. this._options = _options || {};
  2053. }
  2054. ngOnInit() {
  2055. this._syncColumnDefName();
  2056. if (this.headerText === undefined) {
  2057. this.headerText = this._createDefaultHeaderText();
  2058. }
  2059. if (!this.dataAccessor) {
  2060. this.dataAccessor =
  2061. this._options.defaultDataAccessor || ((data, name) => data[name]);
  2062. }
  2063. if (this._table) {
  2064. // Provide the cell and headerCell directly to the table with the static `ViewChild` query,
  2065. // since the columnDef will not pick up its content by the time the table finishes checking
  2066. // its content and initializing the rows.
  2067. this.columnDef.cell = this.cell;
  2068. this.columnDef.headerCell = this.headerCell;
  2069. this._table.addColumnDef(this.columnDef);
  2070. }
  2071. else if (typeof ngDevMode === 'undefined' || ngDevMode) {
  2072. throw getTableTextColumnMissingParentTableError();
  2073. }
  2074. }
  2075. ngOnDestroy() {
  2076. if (this._table) {
  2077. this._table.removeColumnDef(this.columnDef);
  2078. }
  2079. }
  2080. /**
  2081. * Creates a default header text. Use the options' header text transformation function if one
  2082. * has been provided. Otherwise simply capitalize the column name.
  2083. */
  2084. _createDefaultHeaderText() {
  2085. const name = this.name;
  2086. if (!name && (typeof ngDevMode === 'undefined' || ngDevMode)) {
  2087. throw getTableTextColumnMissingNameError();
  2088. }
  2089. if (this._options && this._options.defaultHeaderTextTransform) {
  2090. return this._options.defaultHeaderTextTransform(name);
  2091. }
  2092. return name[0].toUpperCase() + name.slice(1);
  2093. }
  2094. /** Synchronizes the column definition name with the text column name. */
  2095. _syncColumnDefName() {
  2096. if (this.columnDef) {
  2097. this.columnDef.name = this.name;
  2098. }
  2099. }
  2100. 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 }); }
  2101. 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: `
  2102. <ng-container cdkColumnDef>
  2103. <th cdk-header-cell *cdkHeaderCellDef [style.text-align]="justify">
  2104. {{headerText}}
  2105. </th>
  2106. <td cdk-cell *cdkCellDef="let data" [style.text-align]="justify">
  2107. {{dataAccessor(data, name)}}
  2108. </td>
  2109. </ng-container>
  2110. `, 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 }); }
  2111. }
  2112. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkTextColumn, decorators: [{
  2113. type: Component,
  2114. args: [{
  2115. selector: 'cdk-text-column',
  2116. template: `
  2117. <ng-container cdkColumnDef>
  2118. <th cdk-header-cell *cdkHeaderCellDef [style.text-align]="justify">
  2119. {{headerText}}
  2120. </th>
  2121. <td cdk-cell *cdkCellDef="let data" [style.text-align]="justify">
  2122. {{dataAccessor(data, name)}}
  2123. </td>
  2124. </ng-container>
  2125. `,
  2126. encapsulation: ViewEncapsulation.None,
  2127. // Change detection is intentionally not set to OnPush. This component's template will be provided
  2128. // to the table to be inserted into its view. This is problematic when change detection runs since
  2129. // the bindings in this template will be evaluated _after_ the table's view is evaluated, which
  2130. // mean's the template in the table's view will not have the updated value (and in fact will cause
  2131. // an ExpressionChangedAfterItHasBeenCheckedError).
  2132. // tslint:disable-next-line:validate-decorators
  2133. changeDetection: ChangeDetectionStrategy.Default,
  2134. }]
  2135. }], ctorParameters: function () { return [{ type: CdkTable, decorators: [{
  2136. type: Optional
  2137. }] }, { type: undefined, decorators: [{
  2138. type: Optional
  2139. }, {
  2140. type: Inject,
  2141. args: [TEXT_COLUMN_OPTIONS]
  2142. }] }]; }, propDecorators: { name: [{
  2143. type: Input
  2144. }], headerText: [{
  2145. type: Input
  2146. }], dataAccessor: [{
  2147. type: Input
  2148. }], justify: [{
  2149. type: Input
  2150. }], columnDef: [{
  2151. type: ViewChild,
  2152. args: [CdkColumnDef, { static: true }]
  2153. }], cell: [{
  2154. type: ViewChild,
  2155. args: [CdkCellDef, { static: true }]
  2156. }], headerCell: [{
  2157. type: ViewChild,
  2158. args: [CdkHeaderCellDef, { static: true }]
  2159. }] } });
  2160. const EXPORTED_DECLARATIONS = [
  2161. CdkTable,
  2162. CdkRowDef,
  2163. CdkCellDef,
  2164. CdkCellOutlet,
  2165. CdkHeaderCellDef,
  2166. CdkFooterCellDef,
  2167. CdkColumnDef,
  2168. CdkCell,
  2169. CdkRow,
  2170. CdkHeaderCell,
  2171. CdkFooterCell,
  2172. CdkHeaderRow,
  2173. CdkHeaderRowDef,
  2174. CdkFooterRow,
  2175. CdkFooterRowDef,
  2176. DataRowOutlet,
  2177. HeaderRowOutlet,
  2178. FooterRowOutlet,
  2179. CdkTextColumn,
  2180. CdkNoDataRow,
  2181. CdkRecycleRows,
  2182. NoDataRowOutlet,
  2183. ];
  2184. class CdkTableModule {
  2185. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkTableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
  2186. static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0", ngImport: i0, type: CdkTableModule, declarations: [CdkTable,
  2187. CdkRowDef,
  2188. CdkCellDef,
  2189. CdkCellOutlet,
  2190. CdkHeaderCellDef,
  2191. CdkFooterCellDef,
  2192. CdkColumnDef,
  2193. CdkCell,
  2194. CdkRow,
  2195. CdkHeaderCell,
  2196. CdkFooterCell,
  2197. CdkHeaderRow,
  2198. CdkHeaderRowDef,
  2199. CdkFooterRow,
  2200. CdkFooterRowDef,
  2201. DataRowOutlet,
  2202. HeaderRowOutlet,
  2203. FooterRowOutlet,
  2204. CdkTextColumn,
  2205. CdkNoDataRow,
  2206. CdkRecycleRows,
  2207. NoDataRowOutlet], imports: [ScrollingModule], exports: [CdkTable,
  2208. CdkRowDef,
  2209. CdkCellDef,
  2210. CdkCellOutlet,
  2211. CdkHeaderCellDef,
  2212. CdkFooterCellDef,
  2213. CdkColumnDef,
  2214. CdkCell,
  2215. CdkRow,
  2216. CdkHeaderCell,
  2217. CdkFooterCell,
  2218. CdkHeaderRow,
  2219. CdkHeaderRowDef,
  2220. CdkFooterRow,
  2221. CdkFooterRowDef,
  2222. DataRowOutlet,
  2223. HeaderRowOutlet,
  2224. FooterRowOutlet,
  2225. CdkTextColumn,
  2226. CdkNoDataRow,
  2227. CdkRecycleRows,
  2228. NoDataRowOutlet] }); }
  2229. static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkTableModule, imports: [ScrollingModule] }); }
  2230. }
  2231. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkTableModule, decorators: [{
  2232. type: NgModule,
  2233. args: [{
  2234. exports: EXPORTED_DECLARATIONS,
  2235. declarations: EXPORTED_DECLARATIONS,
  2236. imports: [ScrollingModule],
  2237. }]
  2238. }] });
  2239. /**
  2240. * Generated bundle index. Do not edit.
  2241. */
  2242. 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 };
  2243. //# sourceMappingURL=table.mjs.map