MCPcopy
hub / github.com/palantir/blueprint / DateRangeInput

Class DateRangeInput

packages/datetime/src/dateRangeInput.tsx:214–1012  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212
213@polyfill
214export 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 }

Callers

nothing calls this directly

Calls 12

formatDateMethod · 0.95
parseDateMethod · 0.95
isNextDateRangeValidMethod · 0.95
getDefaultMaxDateFunction · 0.90
getDefaultMinDateFunction · 0.90
isRefObjectFunction · 0.90
getFormattedDateStringFunction · 0.90
areSameTimeFunction · 0.90
isDateValidFunction · 0.90
isDayInRangeFunction · 0.90
preventDefaultMethod · 0.80
getOtherBoundaryMethod · 0.80

Tested by

no test coverage detected