MCPcopy Index your code
hub / github.com/react-dates/react-dates / constructor

Method constructor

src/components/DayPicker.jsx:201–262  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

199
200class DayPicker extends React.PureComponent {
201 constructor(props) {
202 super(props);
203
204 const currentMonth = props.hidden ? moment() : props.initialVisibleMonth();
205
206 let focusedDate = currentMonth.clone().startOf('month');
207 if (props.getFirstFocusableDay) {
208 focusedDate = props.getFirstFocusableDay(currentMonth);
209 }
210
211 const { horizontalMonthPadding } = props;
212
213 const translationValue = props.isRTL && this.isHorizontal()
214 ? -getCalendarMonthWidth(props.daySize, horizontalMonthPadding)
215 : 0;
216
217 this.hasSetInitialVisibleMonth = !props.hidden;
218 this.state = {
219 currentMonthScrollTop: null,
220 currentMonth,
221 monthTransition: null,
222 translationValue,
223 scrollableMonthMultiple: 1,
224 calendarMonthWidth: getCalendarMonthWidth(props.daySize, horizontalMonthPadding),
225 focusedDate: (!props.hidden || props.isFocused) ? focusedDate : null,
226 nextFocusedDate: null,
227 showKeyboardShortcuts: props.showKeyboardShortcuts,
228 onKeyboardShortcutsPanelClose() {},
229 isTouchDevice: isTouchDevice(),
230 withMouseInteractions: true,
231 calendarInfoWidth: 0,
232 monthTitleHeight: null,
233 hasSetHeight: false,
234 };
235
236 this.setCalendarMonthWeeks(currentMonth);
237
238 this.calendarMonthGridHeight = 0;
239 this.setCalendarInfoWidthTimeout = null;
240 this.setCalendarMonthGridHeightTimeout = null;
241
242 this.onKeyDown = this.onKeyDown.bind(this);
243 this.throttledKeyDown = throttle(this.onFinalKeyDown, 200, { trailing: false });
244 this.onPrevMonthClick = this.onPrevMonthClick.bind(this);
245 this.onPrevMonthTransition = this.onPrevMonthTransition.bind(this);
246 this.onNextMonthClick = this.onNextMonthClick.bind(this);
247 this.onNextMonthTransition = this.onNextMonthTransition.bind(this);
248 this.onMonthChange = this.onMonthChange.bind(this);
249 this.onYearChange = this.onYearChange.bind(this);
250
251 this.getNextScrollableMonths = this.getNextScrollableMonths.bind(this);
252 this.getPrevScrollableMonths = this.getPrevScrollableMonths.bind(this);
253 this.updateStateAfterMonthTransition = this.updateStateAfterMonthTransition.bind(this);
254
255 this.openKeyboardShortcutsPanel = this.openKeyboardShortcutsPanel.bind(this);
256 this.closeKeyboardShortcutsPanel = this.closeKeyboardShortcutsPanel.bind(this);
257
258 this.setCalendarInfoRef = this.setCalendarInfoRef.bind(this);

Callers

nothing calls this directly

Calls 4

isHorizontalMethod · 0.95
setCalendarMonthWeeksMethod · 0.95
getCalendarMonthWidthFunction · 0.85
getFirstFocusableDayMethod · 0.45

Tested by

no test coverage detected