packages/travix-ui-kit/components/calendar/calendar.js
function processProps(props) {
  const { initialDates, maxDate, minDate, selectionType, multiplemode } = props;
  const maxLimit = maxDate ? normalizeDate(getUTCDate(maxDate), 23, 59, 59, 999) : null;

  let renderDate = (initialDates && initialDates.length && initialDates[0]) ? getUTCDate(initialDates[0]) : new Date();
  normalizeDate(renderDate);

  let minLimit = minDate ? normalizeDate(getUTCDate(minDate)) : null;
  let selectedDates = [null, null];

  if (initialDates) {
    selectedDates = selectedDates.map((item, idx) => {
      if (!initialDates[idx]) {
        return null;
      }

      return normalizeDate(getUTCDate(initialDates[idx]));
    });
  }

  /**
   * If a minDate or a maxDate is set, let's check if any selectedDates are outside of the boundaries.
   * If so, resets the selectedDates.
   */
  if (minLimit || maxLimit) {
    const isAnyDateOutOfLimit = selectedDates.some(item => (
      item && (
        (minLimit && (minLimit.getTime() > item.getTime())) ||
        (maxLimit && (maxLimit.getTime() < item.getTime()))
      )
    ));

    if (isAnyDateOutOfLimit) {
      selectedDates = [null, null];
      console.warn(`A calendar instance contains a selectedDate outside of the minDate and maxDate boundaries`); // eslint-disable-line
    }
  }

  /** If initialDates is defined and we have a start date, we want to set it as the minLimit */
  if (selectedDates[0] && (selectionType === CALENDAR_SELECTION_TYPE_RANGE && !multiplemode)) {
    minLimit = selectedDates[0];
  }

  /** If the renderDate is not between any of the minLimit and/or maxDate, we need to redefine it. */
  if (minLimit && (renderDate.getTime() < minLimit.getTime())) {
    renderDate = minLimit;
  } else if (maxLimit && (renderDate.getTime() > maxLimit.getTime())) {
    renderDate = maxLimit;
  }

  return {
    maxLimit,
    minLimit,
    renderDate,
    selectedDates,
  };
}
function processProps(props) {
  const { initialDates, maxDate, minDate, selectionType, multiplemode } = props;
  const maxLimit = maxDate ? normalizeDate(getUTCDate(maxDate), 23, 59, 59, 999) : null;

  let renderDate = (initialDates && initialDates.length && initialDates[0]) ? getUTCDate(initialDates[0]) : new Date();
  normalizeDate(renderDate);

  let minLimit = minDate ? normalizeDate(getUTCDate(minDate)) : null;
  let selectedDates = [null, null];

  if (initialDates) {
    selectedDates = selectedDates.map((item, idx) => {
      if (!initialDates[idx]) {
        return null;
      }

      return normalizeDate(getUTCDate(initialDates[idx]));
    });
  }

  /**
   * If a minDate or a maxDate is set, let's check if any selectedDates are outside of the boundaries.
   * If so, resets the selectedDates.
   */
  if (minLimit || maxLimit) {
    const isAnyDateOutOfLimit = selectedDates.some(item => (
      item && (
        (minLimit && (minLimit.getTime() > item.getTime())) ||
        (maxLimit && (maxLimit.getTime() < item.getTime()))
      )
    ));

    if (isAnyDateOutOfLimit) {
      selectedDates = [null, null];
      console.warn(`A calendar instance contains a selectedDate outside of the minDate and maxDate boundaries`); // eslint-disable-line
    }
  }

  /** If initialDates is defined and we have a start date, we want to set it as the minLimit */
  if (selectedDates[0] && (selectionType === CALENDAR_SELECTION_TYPE_RANGE && !multiplemode)) {
    minLimit = selectedDates[0];
  }

  /** If the renderDate is not between any of the minLimit and/or maxDate, we need to redefine it. */
  if (minLimit && (renderDate.getTime() < minLimit.getTime())) {
    renderDate = minLimit;
  } else if (maxLimit && (renderDate.getTime() > maxLimit.getTime())) {
    renderDate = maxLimit;
  }

  return {
    maxLimit,
    minLimit,
    renderDate,
    selectedDates,
  };
}
function processProps ( props ) { const { initialDates , maxDate , minDate , selectionType , multiplemode } = props ; const maxLimit = maxDate ? normalizeDate ( getUTCDate ( maxDate ) , 23 , 59 , 59 , 999 ) : null ; let renderDate = ( initialDates && initialDates . length && initialDates [ 0 ] ) ? getUTCDate ( initialDates [ 0 ] ) : new Date ( ) ; normalizeDate ( renderDate ) ; let minLimit = minDate ? normalizeDate ( getUTCDate ( minDate ) ) : null ; let selectedDates = [ null , null ] ; if ( initialDates ) { selectedDates = selectedDates . map ( ( item , idx ) => { if ( ! initialDates [ idx ] ) { return null ; } return normalizeDate ( getUTCDate ( initialDates [ idx ] ) ) ; } ) ; } /**
   * If a minDate or a maxDate is set, let's check if any selectedDates are outside of the boundaries.
   * If so, resets the selectedDates.
   */ if ( minLimit || maxLimit ) { const isAnyDateOutOfLimit = selectedDates . some ( item => ( item && ( ( minLimit && ( minLimit . getTime ( ) > item . getTime ( ) ) ) || ( maxLimit && ( maxLimit . getTime ( ) < item . getTime ( ) ) ) ) ) ) ; if ( isAnyDateOutOfLimit ) { selectedDates = [ null , null ] ; console . warn ( ` ` ) ; // eslint-disable-line } } /** If initialDates is defined and we have a start date, we want to set it as the minLimit */ if ( selectedDates [ 0 ] && ( selectionType === CALENDAR_SELECTION_TYPE_RANGE && ! multiplemode ) ) { minLimit = selectedDates [ 0 ] ; } /** If the renderDate is not between any of the minLimit and/or maxDate, we need to redefine it. */ if ( minLimit && ( renderDate . getTime ( ) < minLimit . getTime ( ) ) ) { renderDate = minLimit ; } else if ( maxLimit && ( renderDate . getTime ( ) > maxLimit . getTime ( ) ) ) { renderDate = maxLimit ; } return { maxLimit , minLimit , renderDate , selectedDates , } ; }
Processes the given props and the existing state and returns
a new state.

@function processProps
@param {Object} props Props to base the new state on.
@param {Object} state (Existing) state to be based on for the existing values.
@return {Object} New state to be set/used.
@static
Processes the given props and the existing state and returns a new state .