feat(MatDateRangePicker): add ability to use a custom component inside a dialog/popup
- Langage dominant
- TypeScript
- Étoiles
- 25k
- Forks
- 6.8k
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 91
Description
#### 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:

Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par lire src/material/datepicker/datepicker-base.ts au niveau de _openAsDialog et _openAsPopup, puis suivez MatDatepickerContent et MatDatepickerContentBase. Définissez le point d’extension de contenu injectable et vérifiez qu’un composant personnalisé peut remplacer le contenu codé en dur de la boîte de dialogue ou du popup tout en conservant le comportement du datepicker.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- angular, typescript
- Domaine
- frontend
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100