As far as I am able to see, the Polaris TextField component only has "date" and "datetime-local" as types that can be used to represent dates.
The "date" type displays the format MM/dd/yyy, and the "datetime-local" displays "mm/dd/yyyy --:-- --".
The problem with "date" for me, is that it does not show the pattern for my locale i.e. "dd/MM/yyyy", and the problem with "datetime-local" is that it displays a time, which I do not need. So I guess I need a "date-local".
Is there any plans an making this "date-local" type, or is there a way where I can set my custom formatting of the selected date on the component?
Solved! Go to the solution
Those are HTML5 inout types. Nothing Polaris can really do to extend them. I'd also refer you to this SO answer. Basically there's wire format as defined by the standard, and then there's the presentational side of things left to browsers. You cannot change / extend the wire format, but you certainly can change how the component is displaying dates.
In the case of Polaris, it's not really the component at fault either. As mentioned in the SO answer, some browsers are still shady about how they render local dates. For example, I live in the Czech Republic, use a US English configured OS with locale set to Czechia and Chrome displays the date inputs perfectly.
So, use Polaris Input and use type=date and the rest is up to the users locale and browser. If that doesn't sound good enough, then you can implement your own component for date rendering that doesn't rely on the standard HTML5 types or extends them.
Hope this helped a bit!
Thank you for your answer.
Ah ok - I haven't dived into how React exactly works, but I though React/Polaris might have hooked into the types of the input field somehow.
I can't quite figure out why my Chrome browser does not show the locale I would like it to though.
C.f. https://developers.google.com/web/updates/2012/08/Quick-FAQs-on-input-type-date-in-Google-Chrome?hl=... it should use the date format in the region settings where I have "dd-MM-yyyy", but that's an issue to report in some other system now that I know it is not Polaris related ;o)
And if that leads nowhere, I can create my own component as you mention.