duetds / date-picker

Duet Date Picker is an open source version of Duet Design System’s accessible date picker. Try live example at https://duetds.github.io/date-picker/
https://www.duetds.com
MIT License
1.73k stars 68 forks source link

Expose default localization hash #101

Open romaricpascal opened 2 years ago

romaricpascal commented 2 years ago

Is your feature request related to a problem? Please describe. I needed to provided the date picker with a custom localisation hash that only had a few keys different from the default one. Having to provide all the localisation keys required me to hunt for these default values in the repository.

Describe the solution you'd like It'd be great if the Hash with the default keys was made accessible somehow (both when using a bundler or not). I did manage to sort myself with the following import, but that'd only work when getting the package from NPM and using a bundler:

import DUET_DEFAULT_LOCALIZATION from '@duetds/date-picker/dist/collection/components/duet-date-picker/date-localization';

Describe alternatives you've considered I did try to access the localization property on the element after creation:

const picker = document.createElement('duet-date-picker');
picker.localization // undefined :(

// Some code that adds the picker to the page

requestAnimationFrame(() => { // For lack of a better way to check that the picker is hydrated
  console.log(picker.localization); // same
});