react-native-easy-calendar
Version:
Customizable, easy-to-use, performant calendar components for React Native
36 lines (32 loc) • 1.22 kB
JavaScript
import React from 'react';
import dayjs from 'dayjs';
import { Text, TouchableOpacity } from 'react-native';
import { ThemeContext } from '../Contexts';
const Month = ({
date,
onPress,
isSelected,
isDisabled,
locale
}) => {
const theme = React.useContext(ThemeContext);
const _onPress = React.useCallback(() => onPress(date), [date, onPress]);
return /*#__PURE__*/React.createElement(TouchableOpacity, {
testID: 'month-container',
accessibilityRole: 'button',
accessibilityLabel: dayjs(date).locale(locale).format('MMM'),
accessibilityState: {
disabled: isDisabled,
selected: isSelected
},
accessibilityHint: 'Press to select this month and return to calendar month view',
disabled: isDisabled,
onPress: _onPress,
style: [theme.normalMonthContainer, isSelected && theme.selectedMonthContainer, isDisabled && theme.disabledMonthContainer]
}, /*#__PURE__*/React.createElement(Text, {
testID: 'month-text',
style: [theme.normalMonthText, isSelected && theme.selectedMonthText, isDisabled && theme.disabledMonthText]
}, dayjs(date).locale(locale).format('MMM')));
};
export default /*#__PURE__*/React.memo(Month);
//# sourceMappingURL=Month.js.map