@@ -258,11 +258,17 @@ function CalendarDateControl< Item >( {
258258 hideLabelFromVision,
259259 validity,
260260} : DataFormControlProps < Item > ) {
261- const { id, label, setValue, getValue, isValid } = field ;
261+ const { id, type, label, setValue, getValue, isValid, displayFormat } =
262+ field ;
262263 const [ selectedPresetId , setSelectedPresetId ] = useState < string | null > (
263264 null
264265 ) ;
265266
267+ let weekStartsOn ;
268+ if ( type === 'date' ) {
269+ weekStartsOn = weekStartsOnToNumber ( displayFormat . weekStartsOn ) ;
270+ }
271+
266272 const fieldValue = getValue ( { item : data } ) ;
267273 const value = typeof fieldValue === 'string' ? fieldValue : undefined ;
268274 const [ calendarMonth , setCalendarMonth ] = useState < Date > ( ( ) => {
@@ -396,9 +402,7 @@ function CalendarDateControl< Item >( {
396402 month = { calendarMonth }
397403 onMonthChange = { setCalendarMonth }
398404 timeZone = { timezoneString || undefined }
399- weekStartsOn = { weekStartsOnToNumber (
400- field . displayFormat . weekStartsOn
401- ) }
405+ weekStartsOn = { weekStartsOn }
402406 />
403407 </ VStack >
404408 </ BaseControl >
@@ -413,7 +417,7 @@ function CalendarDateRangeControl< Item >( {
413417 hideLabelFromVision,
414418 validity,
415419} : DataFormControlProps < Item > ) {
416- const { id, label, getValue, setValue } = field ;
420+ const { id, type , label, getValue, setValue, displayFormat } = field ;
417421 let value : DateRange ;
418422 const fieldValue = getValue ( { item : data } ) ;
419423 if (
@@ -424,6 +428,11 @@ function CalendarDateRangeControl< Item >( {
424428 value = fieldValue as DateRange ;
425429 }
426430
431+ let weekStartsOn ;
432+ if ( type === 'date' ) {
433+ weekStartsOn = weekStartsOnToNumber ( displayFormat . weekStartsOn ) ;
434+ }
435+
427436 const onChangeCallback = useCallback (
428437 ( newValue : DateRange ) => {
429438 onChange (
@@ -611,9 +620,7 @@ function CalendarDateRangeControl< Item >( {
611620 month = { calendarMonth }
612621 onMonthChange = { setCalendarMonth }
613622 timeZone = { timezone . string || undefined }
614- weekStartsOn = { weekStartsOnToNumber (
615- field . displayFormat . weekStartsOn
616- ) }
623+ weekStartsOn = { weekStartsOn }
617624 />
618625 </ VStack >
619626 </ BaseControl >
0 commit comments