@@ -102,6 +102,17 @@ import { getScrollbarWidth } from "../common/utils";
102102 *
103103 * See `TableHeaderItem` class for more information.
104104 *
105+ * ## No data template
106+ *
107+ * When table has no data to show, it can show a message you provide it instead.
108+ *
109+ * ```html
110+ * <ibm-table [model]="model">No data.</ibm-table>
111+ * ```
112+ *
113+ * ... will show `No data.` message, but you can get creative and provide any template you want
114+ * to replace table's default `tbody`.
115+ *
105116 * ## Use pagination as table footer
106117 *
107118 * ```html
@@ -195,9 +206,9 @@ import { getScrollbarWidth } from "../common/utils";
195206 <svg
196207 class="bx--table-sort-v2__icon"
197208 width="10" height="5" viewBox="0 0 10 5"
198- aria-label="Sort rows by this header in descending order "
199- alt="Sort rows by this header in descending order ">
200- <title>Sort rows by this header in descending order </title>
209+ [attr. aria-label]="(column.sorted && column.ascending ? sortDescendingLabel : sortAscendingLabel) "
210+ [attr. alt]="(column.sorted && column.ascending ? sortDescendingLabel : sortAscendingLabel) ">
211+ <title>{{(column.sorted && column.ascending ? sortDescendingLabel : sortAscendingLabel)}} </title>
201212 <path d="M0 0l5 4.998L10 0z" fill-rule="evenodd" />
202213 </svg>
203214 </button>
@@ -269,6 +280,7 @@ import { getScrollbarWidth } from "../common/utils";
269280 </tr>
270281 </thead>
271282 <tbody
283+ *ngIf="!noData; else noDataTemplate"
272284 [ngStyle]="{'overflow-y': 'scroll'}"
273285 (scroll)="onScroll($event)">
274286 <ng-container *ngFor="let row of model.data; let i = index">
@@ -292,6 +304,7 @@ import { getScrollbarWidth } from "../common/utils";
292304 <button
293305 *ngIf="model.isRowExpandable(i)"
294306 (click)="model.expandRow(i, !model.rowsExpanded[i])"
307+ [attr.aria-label]="expandButtonAriaLabel"
295308 class="bx--table-expand-v2__button">
296309 <svg class="bx--table-expand-v2__svg" width="7" height="12" viewBox="0 0 7 12">
297310 <path fill-rule="nonzero" d="M5.569 5.994L0 .726.687 0l6.336 5.994-6.335 6.002L0 11.27z" />
@@ -331,6 +344,7 @@ import { getScrollbarWidth } from "../common/utils";
331344 </tr>
332345 </ng-container>
333346 </tbody>
347+ <ng-template #noDataTemplate><ng-content></ng-content></ng-template>
334348 <tfoot>
335349 <tr *ngIf="this.model.isLoading">
336350 <td class="table_loading-indicator">
@@ -440,6 +454,10 @@ export class Table {
440454 */
441455 @Input ( ) columnsDraggable = false ;
442456
457+ @Input ( ) expandButtonAriaLabel = "Expand row" ;
458+ @Input ( ) sortDescendingLabel = "Sort rows by this header in descending order" ;
459+ @Input ( ) sortAscendingLabel = "Sort rows by this header in ascending order" ;
460+
443461 /**
444462 * Controls if all checkboxes are viewed as selected.
445463 *
@@ -511,6 +529,12 @@ export class Table {
511529 */
512530 @Output ( ) scrollLoad = new EventEmitter < TableModel > ( ) ;
513531
532+ get noData ( ) {
533+ return ! this . model . data ||
534+ this . model . data . length === 0 ||
535+ this . model . data . length === 1 && this . model . data [ 0 ] . length === 0 ;
536+ }
537+
514538 private _model : TableModel ;
515539
516540 private columnResizeWidth : number ;
0 commit comments