![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.quebec/private_html/node_modules/react-calendar/src/ |
import clsx from 'clsx';
import Days from './MonthView/Days.js';
import Weekdays from './MonthView/Weekdays.js';
import WeekNumbers from './MonthView/WeekNumbers.js';
import { CALENDAR_TYPES, CALENDAR_TYPE_LOCALES } from './shared/const.js';
import type { CalendarType } from './shared/types.js';
function getCalendarTypeFromLocale(locale: string | undefined): CalendarType {
if (locale) {
for (const [calendarType, locales] of Object.entries(CALENDAR_TYPE_LOCALES)) {
if (locales.includes(locale)) {
return calendarType as CalendarType;
}
}
}
return CALENDAR_TYPES.ISO_8601;
}
type MonthViewProps = {
/**
* Type of calendar that should be used. Can be `'gregory`, `'hebrew'`, `'islamic'`, `'iso8601'`. Setting to `"gregory"` or `"hebrew"` will change the first day of the week to Sunday. Setting to `"islamic"` will change the first day of the week to Saturday. Setting to `"islamic"` or `"hebrew"` will make weekends appear on Friday to Saturday.
*
* @example 'iso8601'
*/
calendarType?: CalendarType;
/**
* Whether week numbers shall be shown at the left of MonthView or not.
*
* @default false
* @example true
*/
showWeekNumbers?: boolean;
} & Omit<
React.ComponentProps<typeof Weekdays> &
React.ComponentProps<typeof WeekNumbers> &
React.ComponentProps<typeof Days>,
'calendarType'
>;
/**
* Displays a given month.
*/
export default function MonthView(props: MonthViewProps): React.ReactElement {
const { activeStartDate, locale, onMouseLeave, showFixedNumberOfWeeks } = props;
const {
calendarType = getCalendarTypeFromLocale(locale),
formatShortWeekday,
formatWeekday,
onClickWeekNumber,
showWeekNumbers,
...childProps
} = props;
function renderWeekdays() {
return (
<Weekdays
calendarType={calendarType}
formatShortWeekday={formatShortWeekday}
formatWeekday={formatWeekday}
locale={locale}
onMouseLeave={onMouseLeave}
/>
);
}
function renderWeekNumbers() {
if (!showWeekNumbers) {
return null;
}
return (
<WeekNumbers
activeStartDate={activeStartDate}
calendarType={calendarType}
onClickWeekNumber={onClickWeekNumber}
onMouseLeave={onMouseLeave}
showFixedNumberOfWeeks={showFixedNumberOfWeeks}
/>
);
}
function renderDays() {
return <Days calendarType={calendarType} {...childProps} />;
}
const className = 'react-calendar__month-view';
return (
<div className={clsx(className, showWeekNumbers ? `${className}--weekNumbers` : '')}>
<div
style={{
display: 'flex',
alignItems: 'flex-end',
}}
>
{renderWeekNumbers()}
<div
style={{
flexGrow: 1,
width: '100%',
}}
>
{renderWeekdays()}
{renderDays()}
</div>
</div>
</div>
);
}