1
1
import type {
2
- AriaLabels ,
3
- IFormat ,
4
- Transition ,
5
- TextInputOptions ,
6
- DateFilter ,
7
2
ActionRowData ,
8
- MultiCalendarsProp ,
9
- MultiCalendarsOptions ,
10
- OptionEnabled ,
11
- TextInputProp ,
12
- InlineProp ,
13
- InlineOptions ,
3
+ AriaLabels ,
14
4
Config ,
15
- HighlightProp ,
5
+ DateFilter ,
16
6
Highlight ,
17
7
HighlightFn ,
18
- WeekNumbersProp ,
19
- WeekNumbersOpts ,
20
- RangeProp ,
21
- RangeConfig ,
22
- TimeZoneProp ,
23
- TimeZoneConfig ,
8
+ HighlightProp ,
9
+ IFormat ,
24
10
IMarker ,
25
- PropDates ,
26
- MultiDatesProp ,
27
- MultiDatesDefault ,
11
+ InlineOptions ,
12
+ InlineProp ,
28
13
MapPropDatesOpts ,
14
+ MultiCalendarsOptions ,
15
+ MultiCalendarsProp ,
16
+ MultiDatesDefault ,
17
+ MultiDatesProp ,
18
+ OptionEnabled ,
19
+ PropDates ,
20
+ RangeConfig ,
21
+ RangeProp ,
22
+ TextInputOptions ,
23
+ TextInputProp ,
24
+ TimeZoneConfig ,
25
+ TimeZoneProp ,
26
+ Transition ,
29
27
UIOpts ,
30
28
UIParsed ,
29
+ WeekNumbersOpts ,
30
+ WeekNumbersProp ,
31
31
} from '@/interfaces' ;
32
32
import { getDate } from '@/utils/date-utils' ;
33
33
import { dateToTimezoneSafe , sanitizeDateToLocal } from '@/utils/timezone' ;
34
- import { getMapKey , shouldMap } from '@/utils/util' ;
34
+ import { getMapKey , getMapKeyType , shouldMap } from '@/utils/util' ;
35
+ import { MAP_KEY_FORMAT } from '@/constants' ;
35
36
36
37
export const mergeDefaultTransitions = ( conf : Partial < Transition > ) : Transition => ( {
37
38
menuAppearTop : 'dp-menu-appear-top' ,
@@ -254,12 +255,13 @@ export const getDefaultTimeZone = (timeZone: TimeZoneProp) => {
254
255
const datesArrToMap = (
255
256
datesArr : ( Date | string | number ) [ ] ,
256
257
timezone : TimeZoneConfig | undefined ,
258
+ format : MAP_KEY_FORMAT ,
257
259
reset ?: boolean ,
258
260
) : Map < string , Date | null > => {
259
261
return new Map (
260
262
datesArr . map ( ( date ) => {
261
263
const d = dateToTimezoneSafe ( date , timezone , reset ) ;
262
- return [ getMapKey ( d ) , d ] ;
264
+ return [ getMapKey ( d , format ) , d ] ;
263
265
} ) ,
264
266
) ;
265
267
} ;
@@ -269,7 +271,7 @@ const mapMarkers = (markers: IMarker[], timezone: TimeZoneConfig | undefined) =>
269
271
return new Map (
270
272
markers . map ( ( marker ) => {
271
273
const date = dateToTimezoneSafe ( marker . date , timezone ) ;
272
- return [ getMapKey ( date ) , marker ] ;
274
+ return [ getMapKey ( date , MAP_KEY_FORMAT . DATE ) , marker ] ;
273
275
} ) ,
274
276
) ;
275
277
}
@@ -281,18 +283,19 @@ const mapMarkers = (markers: IMarker[], timezone: TimeZoneConfig | undefined) =>
281
283
* All validation that is done from these props will now be in sync with provided timezone config
282
284
*/
283
285
export const mapPropDates = ( opts : MapPropDatesOpts ) : PropDates => {
286
+ const format = getMapKeyType ( opts . isMonthPicker , opts . isYearPicker ) ;
284
287
return {
285
288
minDate : sanitizeDateToLocal ( opts . minDate , opts . timezone , opts . isSpecific ) ,
286
289
maxDate : sanitizeDateToLocal ( opts . maxDate , opts . timezone , opts . isSpecific ) ,
287
290
disabledDates : shouldMap ( opts . disabledDates )
288
- ? datesArrToMap ( opts . disabledDates , opts . timezone , opts . isSpecific )
291
+ ? datesArrToMap ( opts . disabledDates , opts . timezone , format , opts . isSpecific )
289
292
: opts . disabledDates ,
290
293
allowedDates : shouldMap ( opts . allowedDates )
291
- ? datesArrToMap ( opts . allowedDates , opts . timezone , opts . isSpecific )
294
+ ? datesArrToMap ( opts . allowedDates , opts . timezone , format , opts . isSpecific )
292
295
: null ,
293
296
highlight :
294
297
typeof opts . highlight === 'object' && shouldMap ( opts . highlight ?. dates )
295
- ? datesArrToMap ( opts . highlight . dates , opts . timezone )
298
+ ? datesArrToMap ( opts . highlight . dates , opts . timezone , format )
296
299
: ( opts . highlight as HighlightFn ) ,
297
300
markers : mapMarkers ( opts . markers , opts . timezone ) ,
298
301
} ;
0 commit comments