Fragiola

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 weekNumbers setting: "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-column in Vue, the weekNumberColumn input 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, a Calendar.WeekNumber warns once.
  • It lives inside a Calendar.Week; keep its room with --calendar-row-inset on 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>
Locale and week numbersThe same month in several locales: their first day of the week, their weekday names and their ISO or local week numbers.Open the live example

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.

proptypedescription
childrenReactNode | (state) => ReactNodewhat it shows, or a function of its state

State

WeekNumberState:

fieldtypedescription
weekNumbernumberthe row's week number, under the weekNumbers setting