Kozea / formol

An opinionated react form framework.
MIT License
189 stars 17 forks source link

Asynchronously require calendar locales #49

Open corysimmons opened 5 years ago

corysimmons commented 5 years ago
These dependencies were not found:

* date-fns in ./node_modules/formol/src/async/CalendarField.jsx, ./node_modules/formol/src/async/CalendarFieldLocales.js
* date-fns/locale/fr in ./node_modules/formol/src/async/CalendarFieldLocales.js

To install them, you can run: npm install --save date-fns date-fns/locale/fr
paradoxxxzero commented 5 years ago

date-fns is a peer dependency, en locale is not needed as it's the default. I might need to make the other locales a conditional require though.

corysimmons commented 5 years ago

Yeah I think adding a global setting, or a locale prop to <Formol> and/or <CalendarField> would be a nice user experience.

paradoxxxzero commented 5 years ago

Do you mean this https://github.com/Kozea/formol/blob/master/src/Formol.jsx#L77 ?

corysimmons commented 5 years ago

https://github.com/Kozea/formol/blob/cf3aad216cfe4fcb4c3aa0351e8caf79706bca20/src/async/CalendarFieldLocales.js#L2

paradoxxxzero commented 5 years ago

What I meant is there is a global prop called i18n on Formol and a local on CalendarField. I agree that even if you don't need the fr one, it will be imported anyway which is bad but not that bad.

corysimmons commented 5 years ago

Ah okay. So date-fns comes with en built-in? So when I try to use that component, it requests fr, and that pkg isn't installed.

Yeah, I think remove fr and just do whatever the date-fns default is, or possibly make it a peer dep as well?

I don't really know what the best action is. I just know that when I go to use that calendar component it asks me to install fr 🤷‍♀️

paradoxxxzero commented 5 years ago

Yep I'll work on it