Skip to content

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.

TypeCalendarHooks
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/calendar.ts

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 (null keeps 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.

TypeElementHooks<AllDayLabelCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/host.ts

The all-day row’s label (hooks.allDayLabel; Angular dzAllDayLabel, React renderAllDayLabel, Vue #all-day-label).

TypeElementHooks<DayCellCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/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).

TypeElementHooks<DayHeaderCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/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).

TypeElementHooks<DayLaneCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/host.ts

A time grid’s column for a day: classes (a closed day) and mounts; its content stays the calendar’s.

TypeEventHooks
Defaultnot set
Live update (update())Yes
Declared inpackages/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.

TypeElementHooks<ListDayHeaderCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/host.ts

A list’s day heading (Angular dzListDayHeader, React renderListDayHeader, Vue #list-day-header).

TypeElementHooks<MonthHeaderCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/host.ts

A month’s title in a multi-month view (Angular dzMonthHeader, React renderMonthHeader, Vue #month-header).

TypeElementHooks<MoreLinkCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/host.ts

“+N”: its count and the day or the time it stands for (Angular dzMoreLink, React renderMoreLink, Vue #more-link).

TypeElementHooks<MorePopoverCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/host.ts

The panel “+N” opens: classes and mounts; its content is the day’s events.

TypeElementHooks<NoEventsCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/host.ts

The list’s “nothing to show” (Angular dzNoEvents, React renderNoEvents, Vue #no-events).

TypeElementHooks<NowIndicatorCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/host.ts

The line at the current time (Angular dzNowIndicator, React renderNowIndicator, Vue #now-indicator).

TypeResourceHooks
Defaultnot set
Live update (update())Yes
Declared inpackages/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).

TypeElementHooks<ResourceAreaHeaderCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/host.ts

A timeline’s resource column head (Angular dzResourceAreaHeader, React renderResourceAreaHeader, Vue #resource-area-header).

TypeElementHooks<ResourceGroupCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/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).

TypeElementHooks<ResourceGroupCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/host.ts

A group’s row across a timeline’s time: classes and mounts.

TypeElementHooks<ResourceLaneCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/host.ts

A resource’s row across a timeline’s time: classes and mounts.

TypeElementHooks<SlotLabelCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/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).

TypeElementHooks<SlotLaneCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/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.

TypeElementHooks<ViewHookCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/host.ts

The view’s root: classes per view and mounts (a view’s own banner).

TypeElementHooks<WeekNumberCtx>
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/host.ts

A week’s number (Angular dzWeekNumber, React renderWeekNumber, Vue #week-number).

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()) },
},
});

In the frameworks hooks is an input or prop in all three (Angular [hooks], React hooks, Vue :hooks), merged with the templates.