|
1 | 1 | import dayjs from "dayjs"; |
2 | 2 | import type { DateCompViewProps } from "./dateComp"; |
3 | | -import { disabledDate, getStyle, StyledPickerPanel } from "comps/comps/dateComp/dateCompUtil"; |
| 3 | +import { disabledDate, getStyle, StyledPickerPanel, parseInputFormats } from "comps/comps/dateComp/dateCompUtil"; |
4 | 4 | import { useUIView } from "../../utils/useUIView"; |
5 | 5 | import { checkIsMobile } from "util/commonUtils"; |
6 | 6 | import React, { useContext } from "react"; |
@@ -68,20 +68,15 @@ export interface DateRangeUIViewProps extends DateCompViewProps { |
68 | 68 |
|
69 | 69 | export const DateRangeUIView = (props: DateRangeUIViewProps) => { |
70 | 70 | const editorState = useContext(EditorContext); |
| 71 | + const placeholders: [string, string] = Array.isArray(props.placeholder) |
| 72 | + ? props.placeholder |
| 73 | + : [props.placeholder || 'Start Date', props.placeholder || 'End Date']; |
71 | 74 |
|
72 | | - // Extract or compute the placeholder values |
73 | | - let placeholders: [string, string]; |
74 | | - if (Array.isArray(props.placeholder)) { |
75 | | - placeholders = props.placeholder; |
76 | | - } else { |
77 | | - // Use the same placeholder for both start and end if it's a single string |
78 | | - placeholders = [props.placeholder || 'Start Date', props.placeholder || 'End Date']; |
79 | | - } |
80 | 75 | return useUIView( |
81 | 76 | <DateRangeMobileUIView {...props} />, |
82 | 77 | <RangePickerStyled |
83 | 78 | {...omit(props, "onChange" , "format", "inputFormat", "pickerMode", "$childrenInputFieldStyle")} |
84 | | - format={props.inputFormat} |
| 79 | + format={parseInputFormats(props.inputFormat)} |
85 | 80 | ref={props.viewRef as any} |
86 | 81 | picker={props.pickerMode as any} |
87 | 82 | value={[props.start, props.end]} |
|
0 commit comments