| 212 | |
| 213 | @polyfill |
| 214 | export class DateRangeInput extends AbstractPureComponent2<IDateRangeInputProps, IDateRangeInputState> { |
| 215 | public static defaultProps: Partial<IDateRangeInputProps> = { |
| 216 | allowSingleDayRange: false, |
| 217 | closeOnSelection: true, |
| 218 | contiguousCalendarMonths: true, |
| 219 | dayPickerProps: {}, |
| 220 | disabled: false, |
| 221 | endInputProps: {}, |
| 222 | invalidDateMessage: "Invalid date", |
| 223 | maxDate: getDefaultMaxDate(), |
| 224 | minDate: getDefaultMinDate(), |
| 225 | outOfRangeMessage: "Out of range", |
| 226 | overlappingDatesMessage: "Overlapping dates", |
| 227 | popoverProps: {}, |
| 228 | selectAllOnFocus: false, |
| 229 | shortcuts: true, |
| 230 | singleMonthOnly: false, |
| 231 | startInputProps: {}, |
| 232 | }; |
| 233 | |
| 234 | public static displayName = `${DISPLAYNAME_PREFIX}.DateRangeInput`; |
| 235 | |
| 236 | private startInputRef: HTMLInputElement | IRefObject<HTMLInputElement> | null; |
| 237 | private endInputRef: HTMLInputElement | IRefObject<HTMLInputElement> | null; |
| 238 | private refHandlers = { |
| 239 | endInputRef: isRefObject<HTMLInputElement>(this.props.endInputProps.inputRef) |
| 240 | ? (this.endInputRef = this.props.endInputProps.inputRef) |
| 241 | : (ref: HTMLInputElement | null) => { |
| 242 | this.endInputRef = ref; |
| 243 | (this.props.endInputProps.inputRef as IRefCallback<HTMLInputElement>)?.(ref); |
| 244 | }, |
| 245 | startInputRef: isRefObject<HTMLInputElement>(this.props.startInputProps.inputRef) |
| 246 | ? (this.startInputRef = this.props.startInputProps.inputRef) |
| 247 | : (ref: HTMLInputElement | null) => { |
| 248 | this.startInputRef = ref; |
| 249 | (this.props.startInputProps.inputRef as IRefCallback<HTMLInputElement>)?.(ref); |
| 250 | }, |
| 251 | }; |
| 252 | |
| 253 | public constructor(props: IDateRangeInputProps, context?: any) { |
| 254 | super(props, context); |
| 255 | this.reset(props); |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * Public method intended for unit testing only. Do not use in feature work! |
| 260 | */ |
| 261 | public reset(props: IDateRangeInputProps = this.props) { |
| 262 | const [selectedStart, selectedEnd] = this.getInitialRange(); |
| 263 | this.state = { |
| 264 | formattedMaxDateString: this.getFormattedMinMaxDateString(props, "maxDate"), |
| 265 | formattedMinDateString: this.getFormattedMinMaxDateString(props, "minDate"), |
| 266 | isOpen: false, |
| 267 | selectedEnd, |
| 268 | selectedShortcutIndex: -1, |
| 269 | selectedStart, |
| 270 | }; |
| 271 | } |
nothing calls this directly
no test coverage detected