UNPKG

react-native-full-calendars

Version:

React Native Full Calendar (RNFC) is an intuitive and powerful calendar component library designed for React Native.

38 lines (37 loc) 1.21 kB
"use strict"; import { addMonths, format, lastDayOfMonth } from 'date-fns'; import React, { useContext, useMemo } from 'react'; import { StyleSheet, Text, View } from 'react-native'; import { CalendarContext } from '../../store'; import { jsx as _jsx } from "react/jsx-runtime"; export const Header = /*#__PURE__*/React.memo(({ index }) => { const { initialDate, renderHeader, theme } = useContext(CalendarContext); const firstDayOfMonth = useMemo(() => addMonths(initialDate, index), [initialDate, index]); firstDayOfMonth.setDate(1); const lastDayOfMo = useMemo(() => lastDayOfMonth(firstDayOfMonth), [firstDayOfMonth]); const headerText = format(firstDayOfMonth, theme.headerDateFormat); return /*#__PURE__*/_jsx(View, { children: renderHeader ? renderHeader({ startDate: firstDayOfMonth, endDate: lastDayOfMo }) : /*#__PURE__*/_jsx(View, { style: [styleSheet.headerStyle, theme.headerStyle], children: /*#__PURE__*/_jsx(Text, { style: [theme.headerTextStyle], children: headerText }) }) }); }); const styleSheet = StyleSheet.create({ headerStyle: { alignItems: 'center' } }); //# sourceMappingURL=Header.js.map