@@ -36,6 +36,9 @@ function getLabel(mode: ModeType, configuredLabel?: string) {
3636 if ( mode === 'excludeInRange' ) {
3737 return 'Select excluded dates'
3838 }
39+ if ( mode === 'multi' ) {
40+ return 'Select dates'
41+ }
3942 return '...?'
4043}
4144
@@ -61,6 +64,9 @@ export default function DatePickerModalHeader(props: HeaderContentProps) {
6164 { mode === 'excludeInRange' ? (
6265 < HeaderContentExcludeInRange { ...props } color = { color } />
6366 ) : null }
67+ { mode === 'multi' ? (
68+ < HeaderContentMulti { ...props } color = { color } />
69+ ) : null }
6470 </ View >
6571 </ View >
6672 < View style = { styles . fill } />
@@ -98,6 +104,37 @@ export function HeaderContentSingle({
98104 )
99105}
100106
107+ export function HeaderContentMulti ( {
108+ state,
109+ emptyLabel = ' ' ,
110+ color,
111+ locale,
112+ } : HeaderContentProps & { color : string } ) {
113+ const dateCount = state . dates ?. length || 0
114+ const lighterColor = Color ( color ) . fade ( 0.5 ) . rgb ( ) . toString ( )
115+ const dateColor = dateCount ? color : lighterColor
116+
117+ const formatter = React . useMemo ( ( ) => {
118+ return new Intl . DateTimeFormat ( locale , {
119+ month : 'short' ,
120+ day : 'numeric' ,
121+ } )
122+ } , [ locale ] )
123+
124+ let label = emptyLabel
125+ if ( dateCount ) {
126+ if ( dateCount <= 2 ) {
127+ label = state . dates . map ( ( date ) => formatter . format ( date ) ) . join ( ', ' )
128+ } else {
129+ label = formatter . format ( state . dates [ 0 ] ) + ` (+ ${ dateCount - 1 } more)`
130+ }
131+ }
132+
133+ return (
134+ < Text style = { [ styles . singleHeaderText , { color : dateColor } ] } > { label } </ Text >
135+ )
136+ }
137+
101138export function HeaderContentExcludeInRange ( {
102139 state,
103140 emptyLabel = ' ' ,
0 commit comments