![]() 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 { useMemo } from 'react';
import clsx from 'clsx';
import type {
ClassName,
TileClassNameFunc,
TileContentFunc,
TileDisabledFunc,
View,
} from './shared/types.js';
type TileProps = {
/**
* The beginning of a period that shall be displayed.
*
* @example new Date(2017, 0, 1)
*/
activeStartDate: Date;
children: React.ReactNode;
classes?: string[];
date: Date;
formatAbbr?: (locale: string | undefined, date: Date) => string;
/**
* Locale that should be used by the calendar. Can be any [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag).
*
* **Note**: When using SSR, setting this prop may help resolving hydration errors caused by locale mismatch between server and client.
*
* @example 'hu-HU'
*/
locale?: string;
/**
* Maximum date that the user can select. Periods partially overlapped by maxDate will also be selectable, although react-calendar will ensure that no later date is selected.
*
* @example new Date()
*/
maxDate?: Date;
maxDateTransform: (date: Date) => Date;
/**
* Minimum date that the user can select. Periods partially overlapped by minDate will also be selectable, although react-calendar will ensure that no earlier date is selected.
*
* @example new Date()
*/
minDate?: Date;
minDateTransform: (date: Date) => Date;
onClick?: (date: Date, event: React.MouseEvent<HTMLButtonElement>) => void;
onMouseOver?: (date: Date) => void;
style?: React.CSSProperties;
/**
* Class name(s) that will be applied to a given calendar item (day on month view, month on year view and so on).
*
* @example 'class1 class2'
* @example ['class1', 'class2 class3']
* @example ({ activeStartDate, date, view }) => view === 'month' && date.getDay() === 3 ? 'wednesday' : null
*/
tileClassName?: TileClassNameFunc | ClassName;
/**
* Allows to render custom content within a given calendar item (day on month view, month on year view and so on).
*
* @example 'Sample'
* @example ({ activeStartDate, date, view }) => view === 'month' && date.getDay() === 0 ? <p>It's Sunday!</p> : null
*/
tileContent?: TileContentFunc | React.ReactNode;
/**
* Pass a function to determine if a certain day should be displayed as disabled.
*
* @example ({ activeStartDate, date, view }) => date.getDay() === 0
*/
tileDisabled?: TileDisabledFunc;
/**
* Determines which calendar view shall be opened. Does not disable navigation. Can be `"month"`, `"year"`, `"decade"` or `"century"`.
*
* @example 'year'
*/
view: View;
};
export default function Tile(props: TileProps): React.ReactElement {
const {
activeStartDate,
children,
classes,
date,
formatAbbr,
locale,
maxDate,
maxDateTransform,
minDate,
minDateTransform,
onClick,
onMouseOver,
style,
tileClassName: tileClassNameProps,
tileContent: tileContentProps,
tileDisabled,
view,
} = props;
const tileClassName = useMemo(() => {
const args = { activeStartDate, date, view };
return typeof tileClassNameProps === 'function' ? tileClassNameProps(args) : tileClassNameProps;
}, [activeStartDate, date, tileClassNameProps, view]);
const tileContent = useMemo(() => {
const args = { activeStartDate, date, view };
return typeof tileContentProps === 'function' ? tileContentProps(args) : tileContentProps;
}, [activeStartDate, date, tileContentProps, view]);
return (
<button
className={clsx(classes, tileClassName)}
disabled={
(minDate && minDateTransform(minDate) > date) ||
(maxDate && maxDateTransform(maxDate) < date) ||
tileDisabled?.({ activeStartDate, date, view })
}
onClick={onClick ? (event) => onClick(date, event) : undefined}
onFocus={onMouseOver ? () => onMouseOver(date) : undefined}
onMouseOver={onMouseOver ? () => onMouseOver(date) : undefined}
style={style}
type="button"
>
{formatAbbr ? <abbr aria-label={formatAbbr(locale, date)}>{children}</abbr> : children}
{tileContent}
</button>
);
}