angular / angular/components

feat(MatDateRangePicker): add ability to use a custom component inside a dialog/popup

オープン
#20,613 コメント 9 件 リアクション 9 件 担当者 0 名 GitHub で見る
area: material/datepicker feature P2
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
91

説明

#### Feature Description

At the moment, the component that is used by the [`MatDatepickerBase._openAsDialog`](https://github.com/angular/components/blob/dfdf5cf7574a201b98b7e35ce770984527c790ee/src/material/datepicker/datepicker-base.ts#L500) and [`MatDatepickerBase._openAsPopup`](https://github.com/angular/components/blob/dfdf5cf7574a201b98b7e35ce770984527c790ee/src/material/datepicker/datepicker-base.ts#L542) methods is hardcoded. And you can't extend those because they are private.

If, instead, `MatDatepickerContent` was injected, we would have the ability to provide a component with extended functionality, e.g. with predefined date ranges. So, in the `MatDatepickerBase` we should have something like that:
```ts
constructor(
// ...
@Inject(MAT_DATEPICKER_CONTENT) private datepickerContent: MatDatepickerContentBase,
) {
// ...
}

// ...

private _openAsDialog(): void {
// ...
this._dialogRef = this._dialog.open>(this.datepickerContent, /* ... */);
// ...
}
```

We can then import `MatDatepickerContentBase`, extend it and provide our own component to be used in a dialog or popup.

#### Use Case

Add predefined ranges, use two calendars instead of one, add buttons etc.
For example, check the [ngx-daterangepicker-material](https://www.npmjs.com/package/ngx-daterangepicker-material) package:
![image](https://user-images.githubusercontent.com/21097952/93769328-4f237480-fc23-11ea-9160-8cf8081bfdbd.png)

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず src/material/datepicker/datepicker-base.ts の _openAsDialog と _openAsPopup を読み、次に MatDatepickerContent と MatDatepickerContentBase を追跡します。注入可能なコンテンツ拡張ポイントを定義し、カスタムコンポーネントでハードコードされたダイアログまたはポップアップのコンテンツを置き換えながら、datepicker の動作を維持できることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。