API: primitives (@fragiola/calendar-react)
Calendar.WeekNumber
The row header of a month's week. It gives you the row's week number under the weekNumbers setting; what it shows is yours.
Calendar.WeekNumber is the row header of a Calendar.Week (role="rowheader"). It renders a
div with what you give it, and hands you the row's week number.
Behaviour
- The number follows the
weekNumberssetting:"iso"(ISO 8601 weeks) or"locale"(the locale's first day and minimal days); a row's number is its middle day's. - It is not in the roving focus.
- Give the root
weekNumberColumn(week-number-columnin Vue, theweekNumberColumninput in Angular) wherever the rows render one: the grid then counts its column (aria-colcount), the week number is column 1 (aria-colindex) and the days and their headers from 2, so the header row and the rows agree. Without it, aCalendar.WeekNumberwarns once. - It lives inside a
Calendar.Week; keep its room with--calendar-row-inseton the row so the selection and the drag preview start after it.
It renders data-calendar-part="week-number".
Usage
<Calendar.Week week={week}>
<Calendar.WeekNumber className="week-number">
{({ weekNumber }) => <span aria-label={`Week ${weekNumber}`}>{weekNumber}</span>}
</Calendar.WeekNumber>
<Calendar.Days>{(day) => <Calendar.Day day={day} />}</Calendar.Days>
</Calendar.Week>Props
WeekNumberProps; it also takes the common props and every div
attribute.
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.
| prop | type | description |
|---|---|---|
children | ReactNode | (state) => ReactNode | what it shows, or a function of its state |
State
WeekNumberState:
| field | type | description |
|---|---|---|
weekNumber | number | the row's week number, under the weekNumbers setting |