text-column.d.ts 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. */
  8. import { InjectionToken, OnDestroy, OnInit } from '@angular/core';
  9. import { CdkCellDef, CdkColumnDef, CdkHeaderCellDef } from './cell';
  10. import { CdkTable } from './table';
  11. /** Configurable options for `CdkTextColumn`. */
  12. export interface TextColumnOptions<T> {
  13. /**
  14. * Default function that provides the header text based on the column name if a header
  15. * text is not provided.
  16. */
  17. defaultHeaderTextTransform?: (name: string) => string;
  18. /** Default data accessor to use if one is not provided. */
  19. defaultDataAccessor?: (data: T, name: string) => string;
  20. }
  21. /** Injection token that can be used to specify the text column options. */
  22. export declare const TEXT_COLUMN_OPTIONS: InjectionToken<TextColumnOptions<any>>;
  23. /**
  24. * Column that simply shows text content for the header and row cells. Assumes that the table
  25. * is using the native table implementation (`<table>`).
  26. *
  27. * By default, the name of this column will be the header text and data property accessor.
  28. * The header text can be overridden with the `headerText` input. Cell values can be overridden with
  29. * the `dataAccessor` input. Change the text justification to the start or end using the `justify`
  30. * input.
  31. */
  32. export declare class CdkTextColumn<T> implements OnDestroy, OnInit {
  33. private _table;
  34. private _options;
  35. /** Column name that should be used to reference this column. */
  36. name: string;
  37. _name: string;
  38. /**
  39. * Text label that should be used for the column header. If this property is not
  40. * set, the header text will default to the column name with its first letter capitalized.
  41. */
  42. headerText: string;
  43. /**
  44. * Accessor function to retrieve the data rendered for each cell. If this
  45. * property is not set, the data cells will render the value found in the data's property matching
  46. * the column's name. For example, if the column is named `id`, then the rendered value will be
  47. * value defined by the data's `id` property.
  48. */
  49. dataAccessor: (data: T, name: string) => string;
  50. /** Alignment of the cell values. */
  51. justify: 'start' | 'end';
  52. /** @docs-private */
  53. columnDef: CdkColumnDef;
  54. /**
  55. * The column cell is provided to the column during `ngOnInit` with a static query.
  56. * Normally, this will be retrieved by the column using `ContentChild`, but that assumes the
  57. * column definition was provided in the same view as the table, which is not the case with this
  58. * component.
  59. * @docs-private
  60. */
  61. cell: CdkCellDef;
  62. /**
  63. * The column headerCell is provided to the column during `ngOnInit` with a static query.
  64. * Normally, this will be retrieved by the column using `ContentChild`, but that assumes the
  65. * column definition was provided in the same view as the table, which is not the case with this
  66. * component.
  67. * @docs-private
  68. */
  69. headerCell: CdkHeaderCellDef;
  70. constructor(_table: CdkTable<T>, _options: TextColumnOptions<T>);
  71. ngOnInit(): void;
  72. ngOnDestroy(): void;
  73. /**
  74. * Creates a default header text. Use the options' header text transformation function if one
  75. * has been provided. Otherwise simply capitalize the column name.
  76. */
  77. _createDefaultHeaderText(): string;
  78. /** Synchronizes the column definition name with the text column name. */
  79. private _syncColumnDefName;
  80. }