hooks
Makes any element of the calendar the application’s: its classes, its content in place of ours, and code run when it comes and goes.
| Type | CalendarHooks |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/calendar.ts |
What it does
Section titled “What it does”Each member names an element, and takes up to four things (the holders —
dayLane, slotLane, morePopover, view, resourceLane,
resourceGroupLane — take class, didMount and willUnmount only):
class: a string, a list, or a function of the element’s context (null: none), read again at each drawing;content(ctx, el): a string or a node in place of ours (nullkeeps ours);didMount({ el, ctx }): once the element is in the page — it may return its own clean-up;willUnmount({ el, ctx }): before it leaves.
Every context holds view (the view’s type) and what the element is about —
a day’s date, an event’s instance, a label’s time. The frameworks draw
the content with their own templates (listed per element below); hooks
then adds classes and mounts. update({ hooks }) redraws in place — and
closes an open “+N” panel — when a member differs; elements whose mounts did
not change are not mounted again, and the same functions again change
nothing.
Its members
Section titled “Its members”allDayLabel
Section titled “allDayLabel”| Type | ElementHooks<AllDayLabelCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
The all-day row’s label (hooks.allDayLabel; Angular dzAllDayLabel, React renderAllDayLabel, Vue #all-day-label).
dayCell
Section titled “dayCell”| Type | ElementHooks<DayCellCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
A day’s cell in a month or a day grid: its date, today, outside (a day of another month), its resource — a count, a mark (Angular dzDayCell, React renderDayCell, Vue #day-cell).
dayHeader
Section titled “dayHeader”| Type | ElementHooks<DayHeaderCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
A day’s head: a week’s or a day’s date, a month’s weekday — a mark, a count, a button (Angular dzDayHeader, React renderDayHeader, Vue #day-header).
dayLane
Section titled “dayLane”| Type | ElementHooks<DayLaneCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
A time grid’s column for a day: classes (a closed day) and mounts; its content stays the calendar’s.
| Type | EventHooks |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
An event, in every view: classes from its data, its content in place of ours (Angular dzEventContent, React renderEventContent, Vue #event-content), mounts — content runs again only when the event changed.
listDayHeader
Section titled “listDayHeader”| Type | ElementHooks<ListDayHeaderCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
A list’s day heading (Angular dzListDayHeader, React renderListDayHeader, Vue #list-day-header).
monthHeader
Section titled “monthHeader”| Type | ElementHooks<MonthHeaderCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
A month’s title in a multi-month view (Angular dzMonthHeader, React renderMonthHeader, Vue #month-header).
moreLink
Section titled “moreLink”| Type | ElementHooks<MoreLinkCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
“+N”: its count and the day or the time it stands for (Angular dzMoreLink, React renderMoreLink, Vue #more-link).
morePopover
Section titled “morePopover”| Type | ElementHooks<MorePopoverCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
The panel “+N” opens: classes and mounts; its content is the day’s events.
noEvents
Section titled “noEvents”| Type | ElementHooks<NoEventsCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
The list’s “nothing to show” (Angular dzNoEvents, React renderNoEvents, Vue #no-events).
nowIndicator
Section titled “nowIndicator”| Type | ElementHooks<NowIndicatorCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
The line at the current time (Angular dzNowIndicator, React renderNowIndicator, Vue #now-indicator).
resource
Section titled “resource”| Type | ResourceHooks |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
A resource’s head — a column’s, a timeline row’s: its content in place of the title (Angular dzResource, React renderResource, Vue #resource).
resourceAreaHeader
Section titled “resourceAreaHeader”| Type | ElementHooks<ResourceAreaHeaderCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
A timeline’s resource column head (Angular dzResourceAreaHeader, React renderResourceAreaHeader, Vue #resource-area-header).
resourceGroupHeader
Section titled “resourceGroupHeader”| Type | ElementHooks<ResourceGroupCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
A group’s head in resource views and its row in a timeline (Angular dzResourceGroupHeader, React renderResourceGroupHeader, Vue #resource-group-header).
resourceGroupLane
Section titled “resourceGroupLane”| Type | ElementHooks<ResourceGroupCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
A group’s row across a timeline’s time: classes and mounts.
resourceLane
Section titled “resourceLane”| Type | ElementHooks<ResourceLaneCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
A resource’s row across a timeline’s time: classes and mounts.
slotLabel
Section titled “slotLabel”| Type | ElementHooks<SlotLabelCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
A time label in a time grid’s gutter: its time and its text (Angular dzSlotLabel, React renderSlotLabel, Vue #slot-label).
slotLane
Section titled “slotLane”| Type | ElementHooks<SlotLaneCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
A slot’s row across a time grid — drawn as elements only when this hook is given: classes (a lunch break shaded) and mounts.
| Type | ElementHooks<ViewHookCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
The view’s root: classes per view and mounts (a view’s own banner).
weekNumber
Section titled “weekNumber”| Type | ElementHooks<WeekNumberCtx> |
|---|---|
| Default | not set |
Live update (update()) | Yes |
| Declared in | packages/dom/src/host.ts |
A week’s number (Angular dzWeekNumber, React renderWeekNumber, Vue #week-number).
Example
Section titled “Example”import { createCalendar } from '@dzcalendar/dom';
createCalendar(element, { timeZone: 'Europe/Paris', hooks: { // Events of the urgent kind carry a class of yours. event: { class: ({ instance }) => (instance.event.props['urgent'] ? 'is-urgent' : null) }, // Wednesdays closed: shaded in every week. dayLane: { class: ({ date }) => (date.dayOfWeek === 3 ? 'is-closed' : null) }, dayHeader: { didMount: ({ el, ctx }) => el.setAttribute('title', ctx.date.toString()) }, },});import { Component } from '@angular/core';import { DZ_CALENDAR } from '@dzcalendar/angular';import type { CalendarHooks } from '@dzcalendar/dom';
@Component({ selector: 'app-agenda', imports: [DZ_CALENDAR], template: ` <dz-calendar timeZone="Europe/Paris" [hooks]="hooks"> <ng-template dzEventContent let-event><b>{{ event.title }}</b></ng-template> </dz-calendar>`,})export class Agenda { readonly hooks: CalendarHooks = { dayLane: { class: ({ date }) => (date.dayOfWeek === 3 ? 'is-closed' : null) } };}import { DzCalendar } from '@dzcalendar/react';import type { CalendarHooks } from '@dzcalendar/dom';
const HOOKS: CalendarHooks = { dayLane: { class: ({ date }) => (date.dayOfWeek === 3 ? 'is-closed' : null) } };
export function Agenda() { return <DzCalendar timeZone="Europe/Paris" hooks={HOOKS} renderEventContent={(event) => <b>{event.title}</b>} />;}<script setup lang="ts">import { DzCalendar } from '@dzcalendar/vue';import type { CalendarHooks } from '@dzcalendar/dom';
const hooks: CalendarHooks = { dayLane: { class: ({ date }) => (date.dayOfWeek === 3 ? 'is-closed' : null) } };</script>
<template> <DzCalendar time-zone="Europe/Paris" :hooks="hooks"> <template #event-content="{ event }"><b>{{ event.title }}</b></template> </DzCalendar></template>In the frameworks hooks is an input or prop in all three (Angular [hooks], React hooks, Vue :hooks), merged with the templates.
See also
Section titled “See also”formats— only how dates are written.headerItems— places of your own in the header.- Theming.