mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
3.91k stars 1.19k forks source link

LuxonAdapter - MUI: The token yyyy should have a 'maxDigitNumber' property on it's adapter #8951

Closed rodrigofariow closed 1 year ago

rodrigofariow commented 1 year ago

Duplicates

Latest version

Steps to reproduce 🕹

https://codesandbox.io/s/sad-alex-2tv99s When we set a defaultOutputCalendar='iso8601' on luxon Settings and then use a picker we get:

The token yyyy should have a 'maxDigitNumber' property on it's adapter

Context on why we use this: It is somewhat important for our web app to guarantee the calendar system is iso8601, if a user wants to. Most users in countries that "use" other calendar systems prefer to use the standard one so we offer that option, regardless of the timezone and locale.

Other available formats appear to work so I'm assuming luxon handles this one differently, weirdly enough. Hopefully this is something we can handle on mui side and it is on scope 🙏

Here are the docs related to this: https://github.com/moment/luxon/blob/master/docs/calendars.md

Current behavior 😯

Can't use any date pickers when Settings.defaultOutputCalendar = 'iso8601'

Expected behavior 🤔

Should work with any defaultOutputCalendar that we could possibly set on luxon.

Context 🔦

No response

Your environment 🌎

System: OS: macOS 13.3.1 Binaries: Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node Yarn: 1.22.19 - ~/.yarn/bin/yarn npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm Browsers: Chrome: 113.0.5672.92 Edge: Not Found Firefox: 110.0.1 Safari: 16.4 npmPackages: @emotion/react: 11.10.4 => 11.10.4 @emotion/styled: 11.10.4 => 11.10.4 @mui/icons-material: 5.11.11 => 5.11.11 @mui/lab: 5.0.0-alpha.122 => 5.0.0-alpha.122 @mui/material: 5.11.12 => 5.11.12 @mui/system: 5.11.12 => 5.11.12 @mui/types: 7.2.3 => 7.2.3 @mui/x-data-grid: 6.3.0 => 6.3.0 @mui/x-data-grid-generator: 6.3.0 => 6.3.0 @mui/x-data-grid-premium: 6.3.0 => 6.3.0 @mui/x-data-grid-pro: 6.3.0 => 6.3.0 @mui/x-date-pickers: 6.3.1 => 6.3.1 @mui/x-date-pickers-pro: 6.3.1 => 6.3.1 @types/react: 18.0.34 => 18.0.34 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 styled-components: 5.3.5 => 5.3.5 typescript: 5.0.2 => 5.0.2

Order ID or Support key 💳 (optional)

54728

alexfauquette commented 1 year ago

@flaviendelangle Is their a reason preventing us from doing the following?

const formatTokenMap: FieldFormatTokenMap = {
  // Year
  y: { sectionType: 'year', contentType: 'digit', maxLength: 4 },
- yy: 'year',
+ yy: { sectionType: 'year', contentType: 'digit', maxLength: 4 },
- yyyy: 'year',
+ yyyy: { sectionType: 'year', contentType: 'digit', maxLength: 4 },
flaviendelangle commented 1 year ago

For yy it's maxLength: 2 no? But other than that, no I think it's fine.