UNPKG

ipsos-components

Version:

Material Design components for Angular

48 lines (41 loc) 1.62 kB
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import {Injectable, SkipSelf, Optional} from '@angular/core'; import {Subject} from 'rxjs/Subject'; import {SortDirection} from './sort-direction'; /** * To modify the labels and text displayed, create a new instance of MatSortHeaderIntl and * include it in a custom provider. */ @Injectable() export class MatSortHeaderIntl { /** * Stream that emits whenever the labels here are changed. Use this to notify * components if the labels have changed after initialization. */ changes: Subject<void> = new Subject<void>(); /** ARIA label for the sorting button. */ sortButtonLabel = (id: string) => { return `Change sorting for ${id}`; } /** A label to describe the current sort (visible only to screenreaders). */ sortDescriptionLabel = (id: string, direction: SortDirection) => { return `Sorted by ${id} ${direction == 'asc' ? 'ascending' : 'descending'}`; } } /** @docs-private */ export function MAT_SORT_HEADER_INTL_PROVIDER_FACTORY(parentIntl: MatSortHeaderIntl) { return parentIntl || new MatSortHeaderIntl(); } /** @docs-private */ export const MAT_SORT_HEADER_INTL_PROVIDER = { // If there is already an MatSortHeaderIntl available, use that. Otherwise, provide a new one. provide: MatSortHeaderIntl, deps: [[new Optional(), new SkipSelf(), MatSortHeaderIntl]], useFactory: MAT_SORT_HEADER_INTL_PROVIDER_FACTORY };