taiga-family / maskito

Collection of libraries to create an input mask which ensures that user types value according to predefined format.
https://maskito.dev
Apache License 2.0
1.44k stars 35 forks source link

🚀 - `MaskitoDateMode` supports `dd/mm` & `mm/dd` formats #1827

Open avtarnanrey opened 2 weeks ago

avtarnanrey commented 2 weeks ago

Which package(s) are relevant/related to the feature request?

@maskito/kit

Description

maskitoDateOptionsGenerator function do not allow dd/mm and mm/dd date formats.

Because function createMinMaxDatePostprocessor has default min date set to new Date('0001-01-01') If user don't input year then clamp function set the date to min date and return 12/31.

To allow this, we can remove the DEFAULT_MIN_DATE from min parameter in function createMinMaxDatePostprocessor.

and then return a date if min is undefined const clampedDate = min ? clamp(date, min, max) : date; https://github.com/taiga-family/maskito/blob/c81cda5d3c2e6f5f87aedfa984f7f235edca8c2b/projects/kit/src/lib/processors/min-max-date-postprocessor.ts#L52

nsbarsukov commented 2 weeks ago

https://github.com/taiga-family/maskito/blob/31a371a11494803a57263a5a6a829ecfc97d4b96/projects/kit/src/lib/types/date-mode.ts#L1-L8