@veracity/vui
Version:
Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.
19 lines (18 loc) • 854 B
JavaScript
//#region src/calendar/hooks/useDefaultViewMonth.ts
/**
* Calculates the default view date, either using selected date, current date or boundaries
* Used when initializing, after that viewDate will be set
* Memoized so will only recalculate when boundaries or selectedDate changes
*/
const useDefaultViewMonth = ({ boundaries, selectedDate, isStartDate }) => {
if (selectedDate) return selectedDate;
const currentDate = /* @__PURE__ */ new Date();
if (!boundaries) return currentDate;
if (boundaries.endDate && currentDate > boundaries.endDate && !isStartDate) return boundaries.endDate;
if (boundaries.startDate && currentDate > boundaries.startDate && isStartDate) return boundaries.startDate;
return currentDate;
};
//#endregion
export { useDefaultViewMonth };
globalThis.__vuiVersion__ = "5.3.1"
//# sourceMappingURL=useDefaultViewMonth.js.map