API: primitives (@fragiola/calendar-react)
Calendar.Weeks
The month's rows. It calls your function once per week of the day grid and renders no element of its own.
Calendar.Weeks walks the month's rows. It renders nothing of its own: it calls your children
function once per week (a DayGridWeek of the core's layout), and you render a Calendar.Week
for it. The row's markup, height and look are yours.
Behaviour
- The weeks come from the core's layout (
model.get("day-grid"), or the engine's withdayMaxEvents: "auto"), keyed byweek.id, the row's first day. - A week keeps its object while nothing in it changes, so moving an event changes only the rows it leaves and enters.
- It calls the function again for a week whose object changed, and for every week when the
function itself is a new one (React's contract). An inline function is always current but
re-renders every row on each render of the component that writes it; a stable function
(declared outside the component, or
useCallbackwith what it reads) re-renders only the rows whose layout changed. See performance.
Usage
import { Calendar, type DayGridWeek } from "@fragiola/calendar-react";
// reads only its argument: declared outside the component, it is stable
function weekRow(week: DayGridWeek) {
return (
<Calendar.Week week={week} className="week">
{(day) => <Calendar.Day day={day} className="day" />}
</Calendar.Week>
);
}
<Calendar.DayGrid aria-label="Month">
<Calendar.Weeks>{weekRow}</Calendar.Weeks>
</Calendar.DayGrid>;Props
In Vue: the same props (in kebab-case in a template), and slots in place of children; see
Vue primitives.
In Angular: a directive on your element, the props as its inputs, templates in place of
children; see Angular primitives.
WeeksProps (it renders no element, so it takes no other prop):
| prop | type | description |
|---|---|---|
children | (week: DayGridWeek) => ReactNode | called per row of the month; render a Calendar.Week |