diff --git a/libs/core/src/lib/list/list-item/list-item.component.ts b/libs/core/src/lib/list/list-item/list-item.component.ts index fb42d1a0d5f..e8576ec7e25 100644 --- a/libs/core/src/lib/list/list-item/list-item.component.ts +++ b/libs/core/src/lib/list/list-item/list-item.component.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/member-ordering */ import { AfterContentInit, + Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, @@ -132,6 +133,10 @@ export class ListItemComponent @HostBinding('class.fd-list__item--link') link = false; + /** Aria-role attribute. */ + @Input() + ariaRole: Nullable; + /** @hidden */ @ContentChild(FD_RADIO_BUTTON_COMPONENT) set radio(value: RadioButtonComponent) { @@ -187,6 +192,11 @@ export class ListItemComponent /** @hidden */ @HostBinding('attr.role') + private get roleAttr(): string { + return this.ariaRole || this._role; + } + + /** @hidden */ private _role = 'listitem'; // default for li elements /** @hidden */ @@ -201,6 +211,7 @@ export class ListItemComponent constructor( public readonly elementRef: ElementRef, private readonly _changeDetectorRef: ChangeDetectorRef, + @Attribute('role') private readonly _defaultRole: string | null, @Optional() @Inject(FD_LIST_UNREAD_INDICATOR) private readonly _unreadIndicator?: ListUnreadIndicator ) { super(elementRef); diff --git a/libs/docs/platform/list/examples/platform-list-with-group-header-example.component.html b/libs/docs/platform/list/examples/platform-list-with-group-header-example.component.html index 90b7450a8f1..ae39157ab4f 100644 --- a/libs/docs/platform/list/examples/platform-list-with-group-header-example.component.html +++ b/libs/docs/platform/list/examples/platform-list-with-group-header-example.component.html @@ -1,6 +1,6 @@
Cozy
- - + + diff --git a/libs/docs/platform/list/examples/platform-list-with-infinite-scroll-example.component.ts b/libs/docs/platform/list/examples/platform-list-with-infinite-scroll-example.component.ts index 03727cd1419..7386f7d8136 100644 --- a/libs/docs/platform/list/examples/platform-list-with-infinite-scroll-example.component.ts +++ b/libs/docs/platform/list/examples/platform-list-with-infinite-scroll-example.component.ts @@ -1,7 +1,7 @@ -import { Component, ChangeDetectionStrategy } from '@angular/core'; -import { Observable, of } from 'rxjs'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { BehaviorSubject, Observable, of } from 'rxjs'; -import { ListDataSource, DataProvider } from '@fundamental-ngx/platform/shared'; +import { DataProvider, ListDataSource } from '@fundamental-ngx/platform/shared'; export interface User { firstName: string; @@ -114,9 +114,13 @@ const list_elements: User[] = [ ]; export class ListDataProvider extends DataProvider { + private readonly _totalItems = new BehaviorSubject(0); constructor() { super(); } + getTotalItems(): Observable { + return this._totalItems.asObservable(); + } fetch(params: Map): Observable { let data = list_elements; const name = params.get('name'); @@ -125,6 +129,8 @@ export class ListDataProvider extends DataProvider { data = data.filter((user) => user.firstName.toLowerCase().indexOf(keyword) > -1); } + this._totalItems.next(data.length); + return of(data); } } diff --git a/libs/docs/platform/list/examples/platform-list-with-more-button-example.component.ts b/libs/docs/platform/list/examples/platform-list-with-more-button-example.component.ts index df8e40108ba..ee30d4fca23 100644 --- a/libs/docs/platform/list/examples/platform-list-with-more-button-example.component.ts +++ b/libs/docs/platform/list/examples/platform-list-with-more-button-example.component.ts @@ -1,7 +1,7 @@ -import { Component, ChangeDetectionStrategy } from '@angular/core'; -import { Observable, of } from 'rxjs'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { BehaviorSubject, Observable, of } from 'rxjs'; -import { ListDataSource, DataProvider } from '@fundamental-ngx/platform/shared'; +import { DataProvider, ListDataSource } from '@fundamental-ngx/platform/shared'; export interface User { firstName: string; @@ -114,9 +114,13 @@ const list_elements: User[] = [ ]; export class ListDataProvider extends DataProvider { + private readonly _totalItems = new BehaviorSubject(0); constructor() { super(); } + getTotalItems(): Observable { + return this._totalItems.asObservable(); + } fetch(params: Map): Observable { let data = list_elements; const name = params.get('name'); @@ -125,6 +129,9 @@ export class ListDataProvider extends DataProvider { data = data.filter((user) => user.firstName.toLowerCase().indexOf(keyword) > -1); } + // Update total items count when new request completed. + this._totalItems.next(data.length); + return of(data); } } diff --git a/libs/docs/platform/list/examples/platform-list-with-selection-example.component.html b/libs/docs/platform/list/examples/platform-list-with-selection-example.component.html index 8cba62d70cd..1229693bf43 100644 --- a/libs/docs/platform/list/examples/platform-list-with-selection-example.component.html +++ b/libs/docs/platform/list/examples/platform-list-with-selection-example.component.html @@ -9,6 +9,7 @@ (selectedItemChange)="_showItemInfo($event)" [selection]="true" [ariaMultiselectable]="true" + role="listbox" > diff --git a/libs/docs/platform/list/examples/platform-list-with-single-selection-example.component.html b/libs/docs/platform/list/examples/platform-list-with-single-selection-example.component.html index 360c6b93485..55346234698 100644 --- a/libs/docs/platform/list/examples/platform-list-with-single-selection-example.component.html +++ b/libs/docs/platform/list/examples/platform-list-with-single-selection-example.component.html @@ -9,6 +9,7 @@ (selectedItemChange)="_showItemInfo($event)" [selection]="true" [ariaMultiselectable]="false" + role="listbox" >