From a2b6071343215cb6fdc8948e39f687606fdeb014 Mon Sep 17 00:00:00 2001 From: hamza jazyri Date: Tue, 7 Mar 2023 02:36:00 +0100 Subject: [PATCH] docs(material/datepicker): Update close calendar label Previously, the close calendar label was not updating correctly when switching languages. This commit fixes that issue. Fixes #26652. --- .../datepicker-locale/datepicker-locale-example.ts | 11 ++++------- src/material/datepicker/datepicker-intl.ts | 14 +------------- src/material/datepicker/datepicker-module.ts | 4 ++-- tools/public_api_guard/material/datepicker.md | 11 ----------- 4 files changed, 7 insertions(+), 33 deletions(-) diff --git a/src/components-examples/material/datepicker/datepicker-locale/datepicker-locale-example.ts b/src/components-examples/material/datepicker/datepicker-locale/datepicker-locale-example.ts index 38408539c069..deadab0f44a2 100644 --- a/src/components-examples/material/datepicker/datepicker-locale/datepicker-locale-example.ts +++ b/src/components-examples/material/datepicker/datepicker-locale/datepicker-locale-example.ts @@ -9,11 +9,6 @@ import 'moment/locale/ja'; import 'moment/locale/fr'; import {MatDatepickerIntl} from '@angular/material/datepicker'; -@Injectable() -export class DatepickerIntl extends MatDatepickerIntl { - override closeCalendarLabel = 'カレンダーを閉じる'; -} - /** @title Datepicker with different locale */ @Component({ selector: 'datepicker-locale-example', @@ -32,7 +27,6 @@ export class DatepickerIntl extends MatDatepickerIntl { useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS], }, - {provide: MatDatepickerIntl, useClass: DatepickerIntl}, {provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS}, ], }) @@ -41,7 +35,10 @@ export class DatepickerLocaleExample { private _adapter: DateAdapter, private _intl: MatDatepickerIntl, @Inject(MAT_DATE_LOCALE) private _locale: string, - ) {} + ) { + this._intl.closeCalendarLabel = 'カレンダーを閉じる'; + this._intl.changes.next(); + } french() { this._locale = 'fr'; diff --git a/src/material/datepicker/datepicker-intl.ts b/src/material/datepicker/datepicker-intl.ts index a9500b843280..1144192ba7bd 100644 --- a/src/material/datepicker/datepicker-intl.ts +++ b/src/material/datepicker/datepicker-intl.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Injectable, Optional, SkipSelf} from '@angular/core'; +import {Injectable} from '@angular/core'; import {Subject} from 'rxjs'; /** Datepicker data that requires internationalization. */ @@ -75,15 +75,3 @@ export class MatDatepickerIntl { return `${start} to ${end}`; } } - -/** @docs-private */ -export function MAT_DATEPICKER_INTL_PROVIDER_FACTORY(parentIntl: MatDatepickerIntl) { - return parentIntl || new MatDatepickerIntl(); -} - -/** @docs-private */ -export const MAT_DATEPICKER_INTL_PROVIDER = { - provide: MatDatepickerIntl, - deps: [[new Optional(), new SkipSelf(), MatDatepickerIntl]], - useFactory: MAT_DATEPICKER_INTL_PROVIDER_FACTORY, -}; diff --git a/src/material/datepicker/datepicker-module.ts b/src/material/datepicker/datepicker-module.ts index a4ec99dc31a7..4732992723eb 100644 --- a/src/material/datepicker/datepicker-module.ts +++ b/src/material/datepicker/datepicker-module.ts @@ -22,7 +22,7 @@ import { MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER, } from './datepicker-base'; import {MatDatepickerInput} from './datepicker-input'; -import {MAT_DATEPICKER_INTL_PROVIDER} from './datepicker-intl'; +import {MatDatepickerIntl} from './datepicker-intl'; import {MatDatepickerToggle, MatDatepickerToggleIcon} from './datepicker-toggle'; import {MatMonthView} from './month-view'; import {MatMultiYearView} from './multi-year-view'; @@ -82,6 +82,6 @@ import {MatDatepickerActions, MatDatepickerApply, MatDatepickerCancel} from './d MatDatepickerCancel, MatDatepickerApply, ], - providers: [MAT_DATEPICKER_INTL_PROVIDER, MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER], + providers: [MatDatepickerIntl, MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER], }) export class MatDatepickerModule {} diff --git a/tools/public_api_guard/material/datepicker.md b/tools/public_api_guard/material/datepicker.md index d7680d8e99f9..12cb821f0668 100644 --- a/tools/public_api_guard/material/datepicker.md +++ b/tools/public_api_guard/material/datepicker.md @@ -48,7 +48,6 @@ import { Observable } from 'rxjs'; import { OnChanges } from '@angular/core'; import { OnDestroy } from '@angular/core'; import { OnInit } from '@angular/core'; -import { Optional } from '@angular/core'; import { Overlay } from '@angular/cdk/overlay'; import { Portal } from '@angular/cdk/portal'; import { ScrollStrategy } from '@angular/cdk/overlay'; @@ -108,16 +107,6 @@ export type ExtractDateTypeFromSelection = T extends DateRange ? D : // @public export const MAT_DATE_RANGE_SELECTION_STRATEGY: InjectionToken>; -// @public -export const MAT_DATEPICKER_INTL_PROVIDER: { - provide: typeof MatDatepickerIntl; - deps: Optional[][]; - useFactory: typeof MAT_DATEPICKER_INTL_PROVIDER_FACTORY; -}; - -// @public -export function MAT_DATEPICKER_INTL_PROVIDER_FACTORY(parentIntl: MatDatepickerIntl): MatDatepickerIntl; - // @public export const MAT_DATEPICKER_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>;