Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(datepicker): Improve extensibility for datepicker use custom calendar implementation #25709

Open
martin-the-geek opened this issue Sep 26, 2022 · 0 comments
Labels
area: material/datepicker feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@martin-the-geek
Copy link

Feature Description

The content of the datepicker overlay is hard-coded in:

const portal = new ComponentPortal<MatDatepickerContent<S, D>>(
MatDatepickerContent,
this._viewContainerRef,
);

It would be beneficial to allow custom content implementations (either derived from MatDatepickerContent or matching an interface) to be used, maybe as a factory method that could be added as a provider.

Use Case

We have an application where weeks are grouped into biweekly periods and the users find it useful when selecting dates which biweekly period a week is in and whether the week is the first or second week.

We are able to subtype the MatCalendarBody with a custom template that include another column (with a rowspan) to identify the biweekly period.

We are able to subtype the MatMonthView to use our custom body and to ensure the cells are built with days in the months before or after to make sure that each biweekly period is complete (it would be nice if _createWeekCells, _getCellCompareValue and _shouldEnableDate were not private so that they could be overridden/accessed).

We are able to subtype MatCalendar to use our custom month view.

We are able to subtype MatDatepickerContent to use our custom calendar.

Unfortunately this is where it ends. We cannot use a custom content component with the datepicker without copying a large amount of code.

At a minimum we would like to be able to specify a custom content for the datepicker (and dateRangePicker) through something like a provider.

Or even nicer would be an option to dynamically identify the calendar views (possibly with a provider) to avoid all the extra subtyping.

This extensibility could also help other achieve similar requests like #20530.

@martin-the-geek martin-the-geek added feature This issue represents a new feature or feature request rather than a bug or bug fix needs triage This issue needs to be triaged by the team labels Sep 26, 2022
@andrewseguin andrewseguin added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: material/datepicker and removed needs triage This issue needs to be triaged by the team labels May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/datepicker feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

2 participants