react-native-ethiopian-calendar-date-picker
Version:
A react native calendar component which is mainly intended for applications which require Ethiopian calendar.
52 lines • 1.95 kB
JavaScript
import React, { useState } from 'react';
import { EthiopianCalender } from './components/EthiopianCalendar';
import { GregorianCalendar } from './components/GregorianCalender';
import { toEthiopic } from '../utils/Calendar/Convertor';
export const Calendar = /*#__PURE__*/React.memo(props => {
const {
mode = 'EC',
locale = 'AMH',
onDatePress,
onModeChange,
onLanguageChange,
hideHeaderButtons,
theme,
initialDate,
minDate,
maxDate
} = props;
const [selectedDate, setSelectedDate] = useState();
if (mode === 'EC') return /*#__PURE__*/React.createElement(EthiopianCalender, {
date: initialDate && {
year: initialDate.getFullYear(),
month: initialDate.getMonth() + 1,
day: initialDate.getDate()
},
locale: locale,
onDatePress: onDatePress,
theme: theme,
onModeChange: onModeChange,
onLanguageChange: onLanguageChange,
hideHeaderButtons: hideHeaderButtons,
selectedDate: selectedDate,
setSelectedDate: setSelectedDate,
minDate: toEthiopic(minDate === null || minDate === void 0 ? void 0 : minDate.year, minDate === null || minDate === void 0 ? void 0 : minDate.month, minDate === null || minDate === void 0 ? void 0 : minDate.day),
maxDate: toEthiopic(maxDate === null || maxDate === void 0 ? void 0 : maxDate.year, maxDate === null || maxDate === void 0 ? void 0 : maxDate.month, maxDate === null || maxDate === void 0 ? void 0 : maxDate.day)
});
return /*#__PURE__*/React.createElement(GregorianCalendar, {
date: initialDate && {
year: initialDate.getFullYear(),
month: initialDate.getMonth() + 1,
day: initialDate.getDate()
},
minDate: minDate,
maxDate: maxDate,
onDatePress: onDatePress,
theme: theme,
onModeChange: onModeChange,
hideHeaderButtons: hideHeaderButtons,
selectedDate: selectedDate,
setSelectedDate: setSelectedDate
});
});
//# sourceMappingURL=index.js.map