source: trip-planner-front/node_modules/@angular/cdk/esm2015/table/text-column.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 17.2 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { ChangeDetectionStrategy, Component, Inject, Input, Optional, ViewChild, ViewEncapsulation, } from '@angular/core';
9import { CdkCellDef, CdkColumnDef, CdkHeaderCellDef } from './cell';
10import { CdkTable } from './table';
11import { getTableTextColumnMissingParentTableError, getTableTextColumnMissingNameError, } from './table-errors';
12import { TEXT_COLUMN_OPTIONS } from './tokens';
13/**
14 * Column that simply shows text content for the header and row cells. Assumes that the table
15 * is using the native table implementation (`<table>`).
16 *
17 * By default, the name of this column will be the header text and data property accessor.
18 * The header text can be overridden with the `headerText` input. Cell values can be overridden with
19 * the `dataAccessor` input. Change the text justification to the start or end using the `justify`
20 * input.
21 */
22export class CdkTextColumn {
23 constructor(
24 // `CdkTextColumn` is always requiring a table, but we just assert it manually
25 // for better error reporting.
26 // tslint:disable-next-line: lightweight-tokens
27 _table, _options) {
28 this._table = _table;
29 this._options = _options;
30 /** Alignment of the cell values. */
31 this.justify = 'start';
32 this._options = _options || {};
33 }
34 /** Column name that should be used to reference this column. */
35 get name() {
36 return this._name;
37 }
38 set name(name) {
39 this._name = name;
40 // With Ivy, inputs can be initialized before static query results are
41 // available. In that case, we defer the synchronization until "ngOnInit" fires.
42 this._syncColumnDefName();
43 }
44 ngOnInit() {
45 this._syncColumnDefName();
46 if (this.headerText === undefined) {
47 this.headerText = this._createDefaultHeaderText();
48 }
49 if (!this.dataAccessor) {
50 this.dataAccessor =
51 this._options.defaultDataAccessor || ((data, name) => data[name]);
52 }
53 if (this._table) {
54 // Provide the cell and headerCell directly to the table with the static `ViewChild` query,
55 // since the columnDef will not pick up its content by the time the table finishes checking
56 // its content and initializing the rows.
57 this.columnDef.cell = this.cell;
58 this.columnDef.headerCell = this.headerCell;
59 this._table.addColumnDef(this.columnDef);
60 }
61 else if (typeof ngDevMode === 'undefined' || ngDevMode) {
62 throw getTableTextColumnMissingParentTableError();
63 }
64 }
65 ngOnDestroy() {
66 if (this._table) {
67 this._table.removeColumnDef(this.columnDef);
68 }
69 }
70 /**
71 * Creates a default header text. Use the options' header text transformation function if one
72 * has been provided. Otherwise simply capitalize the column name.
73 */
74 _createDefaultHeaderText() {
75 const name = this.name;
76 if (!name && (typeof ngDevMode === 'undefined' || ngDevMode)) {
77 throw getTableTextColumnMissingNameError();
78 }
79 if (this._options && this._options.defaultHeaderTextTransform) {
80 return this._options.defaultHeaderTextTransform(name);
81 }
82 return name[0].toUpperCase() + name.slice(1);
83 }
84 /** Synchronizes the column definition name with the text column name. */
85 _syncColumnDefName() {
86 if (this.columnDef) {
87 this.columnDef.name = this.name;
88 }
89 }
90}
91CdkTextColumn.decorators = [
92 { type: Component, args: [{
93 selector: 'cdk-text-column',
94 template: `
95 <ng-container cdkColumnDef>
96 <th cdk-header-cell *cdkHeaderCellDef [style.text-align]="justify">
97 {{headerText}}
98 </th>
99 <td cdk-cell *cdkCellDef="let data" [style.text-align]="justify">
100 {{dataAccessor(data, name)}}
101 </td>
102 </ng-container>
103 `,
104 encapsulation: ViewEncapsulation.None,
105 // Change detection is intentionally not set to OnPush. This component's template will be provided
106 // to the table to be inserted into its view. This is problematic when change detection runs since
107 // the bindings in this template will be evaluated _after_ the table's view is evaluated, which
108 // mean's the template in the table's view will not have the updated value (and in fact will cause
109 // an ExpressionChangedAfterItHasBeenCheckedError).
110 // tslint:disable-next-line:validate-decorators
111 changeDetection: ChangeDetectionStrategy.Default
112 },] }
113];
114CdkTextColumn.ctorParameters = () => [
115 { type: CdkTable, decorators: [{ type: Optional }] },
116 { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [TEXT_COLUMN_OPTIONS,] }] }
117];
118CdkTextColumn.propDecorators = {
119 name: [{ type: Input }],
120 headerText: [{ type: Input }],
121 dataAccessor: [{ type: Input }],
122 justify: [{ type: Input }],
123 columnDef: [{ type: ViewChild, args: [CdkColumnDef, { static: true },] }],
124 cell: [{ type: ViewChild, args: [CdkCellDef, { static: true },] }],
125 headerCell: [{ type: ViewChild, args: [CdkHeaderCellDef, { static: true },] }]
126};
127//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGV4dC1jb2x1bW4uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL3RhYmxlL3RleHQtY29sdW1uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFDTCx1QkFBdUIsRUFDdkIsU0FBUyxFQUNULE1BQU0sRUFDTixLQUFLLEVBR0wsUUFBUSxFQUNSLFNBQVMsRUFDVCxpQkFBaUIsR0FDbEIsTUFBTSxlQUFlLENBQUM7QUFDdkIsT0FBTyxFQUFDLFVBQVUsRUFBRSxZQUFZLEVBQUUsZ0JBQWdCLEVBQUMsTUFBTSxRQUFRLENBQUM7QUFDbEUsT0FBTyxFQUFDLFFBQVEsRUFBQyxNQUFNLFNBQVMsQ0FBQztBQUNqQyxPQUFPLEVBQ0wseUNBQXlDLEVBQ3pDLGtDQUFrQyxHQUNuQyxNQUFNLGdCQUFnQixDQUFDO0FBQ3hCLE9BQU8sRUFBQyxtQkFBbUIsRUFBb0IsTUFBTSxVQUFVLENBQUM7QUFHaEU7Ozs7Ozs7O0dBUUc7QUFzQkgsTUFBTSxPQUFPLGFBQWE7SUFxRHhCO0lBQ0ksOEVBQThFO0lBQzlFLDhCQUE4QjtJQUM5QiwrQ0FBK0M7SUFDM0IsTUFBbUIsRUFDVSxRQUE4QjtRQUQzRCxXQUFNLEdBQU4sTUFBTSxDQUFhO1FBQ1UsYUFBUSxHQUFSLFFBQV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