foundation.d.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * @license
  3. * Copyright 2019 Google Inc.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. * THE SOFTWARE.
  22. */
  23. import { MDCFoundation } from '@material/base/foundation';
  24. import { MDCDataTableAdapter } from './adapter';
  25. import { RowClickEventData, SortActionEventData } from './types';
  26. /**
  27. * The Foundation of data table component containing pure business logic, any
  28. * logic requiring DOM manipulation are delegated to adapter methods.
  29. */
  30. export declare class MDCDataTableFoundation extends MDCFoundation<MDCDataTableAdapter> {
  31. static get defaultAdapter(): MDCDataTableAdapter;
  32. constructor(adapter?: Partial<MDCDataTableAdapter>);
  33. /**
  34. * Re-initializes header row checkbox and row checkboxes when selectable rows
  35. * are added or removed from table. Use this if registering checkbox is
  36. * synchronous.
  37. */
  38. layout(): void;
  39. /**
  40. * Re-initializes header row checkbox and row checkboxes when selectable rows
  41. * are added or removed from table. Use this if registering checkbox is
  42. * asynchronous.
  43. */
  44. layoutAsync(): Promise<void>;
  45. /**
  46. * @return Returns array of row elements.
  47. */
  48. getRows(): HTMLElement[];
  49. /**
  50. * @return Array of header cell elements.
  51. */
  52. getHeaderCells(): Element[];
  53. /**
  54. * Sets selected row ids. Overwrites previously selected rows.
  55. * @param rowIds Array of row ids that needs to be selected.
  56. */
  57. setSelectedRowIds(rowIds: string[]): void;
  58. /**
  59. * @return Returns array of all row ids.
  60. */
  61. getRowIds(): Array<string | null>;
  62. /**
  63. * @return Returns array of selected row ids.
  64. */
  65. getSelectedRowIds(): Array<string | null>;
  66. /**
  67. * Handles header row checkbox change event.
  68. */
  69. handleHeaderRowCheckboxChange(): void;
  70. /**
  71. * Handles change event originated from row checkboxes.
  72. */
  73. handleRowCheckboxChange(event: Event): void;
  74. /**
  75. * Handles sort action on sortable header cell.
  76. */
  77. handleSortAction(eventData: SortActionEventData): void;
  78. /**
  79. * Handles data table row click event.
  80. */
  81. handleRowClick({ rowId, row, altKey, ctrlKey, metaKey, shiftKey }: RowClickEventData): void;
  82. /**
  83. * Shows progress indicator blocking only the table body content when in
  84. * loading state.
  85. */
  86. showProgress(): void;
  87. /**
  88. * Hides progress indicator when data table is finished loading.
  89. */
  90. hideProgress(): void;
  91. /**
  92. * Updates header row checkbox state based on number of rows selected.
  93. */
  94. private setHeaderRowCheckboxState;
  95. /**
  96. * Sets the attributes of row element based on selection state.
  97. */
  98. private selectRowAtIndex;
  99. }