Add the option to select DateField type
vcardins opened this issue · comments
Currently, there is only the option to select a date and time on the DateField component.
https://github.com/vazco/uniforms/blob/master/packages/uniforms-material/src/DateField.tsx#L61
Maybe the type
prop could be variable even if its default value is "datetime-local"
Hi @vcardins , thanks for the issue report.
I agree with you and I think it would make sense to be able to handle the date
type. Other types probably cannot be supported as they would break the functionality of the field if they were used.
Just to make sure - is date
indeed the type that you would like to pass or do you have a different use case?
@wadamek65 Thanks for the quick reply. Initially, the date is the only use case that I need at the moment, but whichever types are possible would make it more flexible.
Thank you!
The only problem with incorporating more type
variants is that we'd have to cover them in the value
as well (here), as different types require different formats. We may implement it at some point, but I'd still recommend a custom date picker for better UX and browser compatibility.
I see. Could it then cover just datetime-local and date types? I believe that in the majority of the use cases only date is needed. Thanks!!
Hey, @radekmie it was not clear, should we expect that the type date
will be added?
We've discussed it internally and we're willing to add support for type="date"
as well, but there's no high priority for that. If you'd like to give it a shot, feel free to do so!
Things to do:
- Handle
value
formatting differently, based ontype
.- I think that something like
type === 'date' ? type : 'datetime-local'
would be fine;type
alone is a uniforms prop (e.g.,Date
) so we cannot use it directly.
- I think that something like
- Add tests.
- Check if
onChange
works (it's probably fine as it is now). - Check if
value
formatting works.
- Check if
Thanks, @radekmie. I'll work on that!