feat(DatePicker): select range of dates
Hello, it's possible to set date range in date picker (have the ability to choose startDate and endDate and get all dates between startDate and endDate).
@lihanyu23 Ok, I got it. I will commit tomorrow to my repo to show. I'm going to use one input and add 1-3 additional variables to MatDatepicker and it's childs. I started to create another component, but then I understand that 90% of code is the same with MatDatePicker, and I decided to update MatDatepicker.
About selecting and showing days through MatCalendar - no any problem.
The difficulty in displaying value in <input>. Examples, how I think to show them (depends on DateAdapter)
01/31/2017 — 02/18/2017 (or 01/31 — 02/18/2017)
Later to do these displaying
nov 2017 (for 11/01/2017 — 11/31/2017)
jul 2017 — dec 2017 (for 07/01/2017 — 12/12/2017)
And of course string parser will separate string (by — or -) to convert it to two dates (begin and end). Also I don't forget about sauch date formats as 01-01-2001
@SaturnTeam Here is my ideas/mockup based on the styles of the latest datepicker.

Pattern with "filling" like this should work better (especially for ranges greater than 1 month), because:
- starting and ending points are always rounded and easy to notice
- all days between are just filled with background color so they looks less noisy as if it was with circles.
For styling I used
background-color: #e6f3ff;
and for corner points I used this trick
border-radius: 100% 0 0 100%;
@Den-dp I wanted to do the same too. I got some problem, but now I can't understand what it was. I'll try tomorrow. I didn't find your color in material pallete https://material.io/guidelines/style/color.html#color-color-palette I will look something similar
@SaturnTeam good catch! Any color from 50-200 should fit perfectly
@SaturnTeam try to use 50 or 100 from the palette. Also I like @Den-dp's idea.
The color should depend on the current theme. Not everyone will use blue. From the material design page: https://material.io/guidelines/style/color.html#color-color-system
A primary color is the color displayed most frequently across your app’s screens and components. It can also be used to accent elements, if you don’t have a secondary color. To create contrast between elements, you can use lighter or darker tones of your primary color.
I don't know if the Angular material implementation defines something like primary_color and primary_color_light for the themes, but we are looking for a color to specify the "from" and "to" dates and a lighter version of this color to show the selected dates.
@Den-dp I like your design. I agree with you that it looks less noisy => better
@Den-dp @RaulRG @lihanyu23 As you can see, it is not very great idea.
without border-radius
with border-radius

@lihanyu23 I commited to my repo https://github.com/SaturnTeam/material2 . Serving is the same as usual material dev. Range mode enabled on http://localhost:4200/datepicker "Result"
@SaturnTeam haha, but why? :stuck_out_tongue_winking_eye: Good work! :sparkles: The first one looks great for me!
Also here I tried to use a lighter 50 color and it looks even better

Personally, I do like the mockup without border-radius on each day, because the shape helps the eye to distinguish important information (where are the starting and ending points of the range) and f.e. expectations about whether or not the last day in calendar (NOV 30) is the end of the range is more clear.
Also for reference flights.google uses filled background in their calendar too

Ohh, just look how cute these neighborhood dates.
Code is ready (see my repo). Writing tests and documentation in progress. Also I applied last changes with multi year view.
(keyboard not working temporally)
@juliemr @mmalerba Proposal https://docs.google.com/document/d/14S3BvSm9o8_7VKwJU0ek59V7Cm4Yjt6OOoMj_lpfYZ0/edit?usp=sharing
I created from my code standalone package. Installation: yarn add saturn-datepicker or npm install saturn-datepicker. Disscussion and info https://github.com/SaturnTeam/saturn-datepicker
Anyone knows about a11y with range selection?
Our requirements (searching for documents within certain date ranges) dictate that the start and/or end dates may be empty if the user chooses. That way the date range can be used to mean "after a specific date" when only the start date is chosen, "before a specific date" when only the end date is chosen, "between two dates" when both are chosen, or "any date" when neither date is chosen.
This is something that most third-party implementations can't do, but that would be especially useful particularly for search interfaces! It would be greatly appreciated if this use case would be taken into account. :)
@mischkl Do you have any ideas how to do it through UI?
@mischkl These are exactly our requirements as well. The typical scenario for a range date picker is to use it for filtering data. Of course, there is another use case like "dates for your hotel booking" were you need fixed limits, but for filtering it is quite usual to have an "open" limit.
Do you have any ideas how to do it through UI?
@SaturnTeam My guess is to have two modes : "start date" and "end date". And a "validate" button.
When opening the date range picker :
- the mode is set to "start date"
- when you select a date the mode switch to "end date"
- OR you can manually switch to "end date" without entering any start date via two buttons (
select start dateandselect end dateat the top, like the exemple below)
Here is an exemple from third party Ionic 3 Date Picker :

The exemple is just for the switch button. It misses the validate button. We should also have an option to validate via a backdrop dismiss.
Here is a mockup I made of what such a date picker control could look like. It would not only support empty start/end dates but also keyboard-only data entry, which I believe is another important goal that the current date picker already fulfills.

Once the user clicks on a start date, the focus automatically switches to the end date, as in most 3rd party implementations. In case the user wants to leave the "From" date blank, they would simply click or tab to the "To" field manually. The cursor and field highlighting should be enough so they know what they are entering at any given time.
Additionally the color-coding of the input fields helps to form a mental map between what is entered above and what is selected on the calendar below - however it remains to be seen whether this is able to mesh seamlessly with the Material Design guidelines.
In keeping with other material controls there is no extra "validate" button; rather the validation would occur on tab / loss of focus. As a general rule it should not be possible to click on an end date that occurs before a start date.
Additionally there is the problem of how to show the start date and end date on the same day. For this case the color could be a blend of the start/end colors, or perhaps an overlapping venn-diagram-esque set of circles.
Whether the start and/or end date is allowed to be left blank can of course be made configurable, in order to support classic "hotel booking" use cases as well as search filtering use cases.
@mmalerba for discussion above ^