Open hannahker opened 2 years ago
I really like this idea. It's probably worth implementing a value
param as an alias of date
to keep this backwards compatible. Otherwise I frequently use that pattern with PMCs and it would be great to see value
standardized across all formlikes.
I like it too. Yes, it would need to be done in a backward-compatible way for sure. And some logic around ensuring date
and value
stay in sync.
This could be extended to DatePickerRange
as well, where value
would be a length-2 list like it is for RangeSlider
@hannahker I vote you make a PR with this, great opportunity for Services to get familiar with core Dash libraries!
Alright stay tuned! 😄
Hi @hannahker, you can try this out: https://dash-mantine-components.herokuapp.com/components/datepicker The docs are a work in progress but please reach out if you need any help.
PS: I'm the author of this library. Repo
Hi @snehilvj - yes this is what I had in mind. Thanks for drawing this to my attention. These are also all really great looking components! Excited to try them out :)
As an alternative to Input("start-date", "date") as a workaround, you can add "value" to a custom class like this.
from dash import dcc
class DatePickerRangeCustom(dcc.DatePickerRange):
def __init__(self, **kwargs):
super(DatePickerRangeCustom, self).__init__(**kwargs)
self.value = [kwargs['start_date'], kwargs['end_date']]
self._prop_names.append('value')
self.available_properties.append('value')
Is your feature request related to a problem? Please describe. Pattern-matching callbacks are really helpful when collecting a large number of inputs in a callback, using the
value
component property. For example, using the following as callback inputs works really well:But, this is complicated when a date from
dcc.DatePickerSingle
is a parameter, because the name of the property holding its 'value' is actually calleddate
. It's workable to just pass something likeInput("start-date", "date")
as a separate callback input, but makes for messy code and to some extent defeats the elegance of pattern-matching.Describe the solution you'd like The component property from
dcc.DatePickerSingle
is calledvalue
instead ofdate
.Describe alternatives you've considered The workaround mentioned above is the alternative I've implemented. You could also have a
dcc.Input
where the user types in a date, but then you'd lose the nice calendar UI element.