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

Support only having some params set in localization #109

Open umer936 opened 2 years ago

umer936 commented 2 years ago

Say I just want to change the placeholder.

Currently, I have to pass in all of the fields in localization according to https://github.com/duetds/date-picker/issues/29#issuecomment-700696092 . However, I have found that as long as I pass in dayNames, monthNames, and monthNamesShort, nothing breaks.

Describe the solution you'd like If I just want to change the placeholder, there's no reason I need to have my own copies of the fields in the localization object. It should default to the default if a value is not given.

rdebeasi commented 2 years ago

That feature would be super helpful! As a workaround, the default localization options can be imported from here:

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

The defaults can be used like this:

myDatePickerElement.localization = {
  ...dateLocalization,
  locale: 'en-US'
};

This module doesn't include type declarations, so you'll need to declare the module in a d.ts file if you're using TypeScript:

declare module '@duetds/date-picker/dist/collection/components/duet-date-picker/date-localization';
rdebeasi commented 2 years ago

See also #101