Aller au contenu

Rendez-vous d’un cabinet de kinésithérapie

Un patient ne peut pas venir à 10 h. Trouvez le prochain créneau qui respecte pauses et nettoyages.

  • Santé
  • Forma
  • Échelle à la minute
  • Lignes de synthèse
  • Minimap
  • Recherche instantanée
  • Zones actives
  • Règles de déplacement
  • Créneaux bloqués
  • Colonnes de ligne
  • Thèmes
  • Démo avec données fictives

Mission

0 étapes faites sur 3

Jeudi, 9 h 40 : Owen Hart (F-2318, rééducation du genou à 10 h avec Alba R.) appelle pour demander un horaire plus tardif.

  1. Faites glisser F-2318 sur la ligne de Marc D. à 12 h, pendant le nettoyage de sa salle. — À faire

    Les créneaux rayés sont bloqués. La carte de déplacement affiche le motif et le dépôt est refusé.

  2. Déposez-le à 12 h 30 sur la ligne de Marc D., juste après le nettoyage. — À faire

    Tout créneau libre convient si le praticien fait de la rééducation du genou. La ligne de l’ostéopathe le refuse.

  3. Passez aux créneaux de 15 minutes et allongez un rendez-vous d’un quart d’heure. — À faire

    Choisissez « 15 min » dans la barre, puis tirez le bord droit d’une carte. Au clavier, Alt+Maj+flèches modifie sa durée.

Environ 30 secondes. Les étapes se cochent au fur et à mesure.

Clavier : placez le focus sur la grille, puis flèches, Entrée et Alt+flèches pour déplacer.

Forma
KinésithérapieAlba R.32%Marc D.31%Nora S.36%Thérapie manuelleTeo V.33%Iris M.38%Lucía FerrerBilan initialOwen HartRééducation du genouMia LaurentMobilité de l’épauleJonas WeberSoin lombaireAitana RuizRééducation du genouTomás IbarraSoin lombaireClaire DuboisRééducation du genouLeo BrandtMobilité de l’épauleSara ContiBilan initialHugo MartínSoin lombaireNoah BeckerExercices thérapeutiquesInés NavarroExercices thérapeutiquesYuki TanakaExercices thérapeutiquesMarta VidalExercices thérapeutiquesRafael CostaOstéopathieAnna KowalskiOstéopathieDiego HerreraBilan initialChloé MartinSoin lombaireEmma LarsenMassage sportifLucas MoreauMassage sportifNadia HaddadMassage sportif243344333100003Salles occupéessur 5jeudi 15 octobre08:0008:3009:0009:3010:0010:3011:0011:3012:0012:3013:0013:3014:0014:3015:00

Aperçu de la première imageEn direct : le vrai moteur Pro, dans votre navigateurEnviron 30 secondes. Les étapes se cochent au fur et à mesure. Clavier : placez le focus sur la grille, puis flèches, Entrée et Alt+flèches pour déplacer.

La situation.

Forma est un cabinet fictif qui réunit trois kinésithérapeutes, un ostéopathe et une praticienne de massage sportif. Les rendez-vous durent de 15 à 60 minutes, chaque praticien travaille dans une salle, et la journée est coupée par des pauses, une réunion de synthèse et le nettoyage des salles entre deux séances.

Quand un patient appelle pour déplacer un rendez-vous, l’accueil n’a que quelques secondes pour trouver un créneau pendant que la salle d’attente se remplit. Une grille papier ou un agenda générique laisse réserver sur une pause ou confier une séance d’ostéopathie à un kinésithérapeute. Le planning doit refuser ces créneaux et dire pourquoi, y compris à voix haute pour les lecteurs d’écran. Patients, équipe et rendez-vous sont inventés.

Ce que vous allez faire

Vous tenterez de placer un rendez-vous sur un créneau de nettoyage, entendrez pourquoi il est refusé, le déplacerez sur le premier créneau libre après le nettoyage et ajusterez sa durée par pas de 15 minutes.

Où s’arrête la bibliothèque et où commence votre application.

SuperScheduler fournit

  • Des échelles à la minute en zoomLevels (cellules de 30 et 15 minutes) avec aimantation et nuit masquée (showNonBusiness : false).
  • Une ligne de synthèse figée (frozen : ‘top’, cellsDisabled) remplie par onBeforeCellRender, et des en-têtes de praticien avec jauges de charge en direct via rowHeaderColumns.
  • Des cartes riches depuis onBeforeEventRender avec des zones : l’avatar du patient comme puce de statut cliquable (action : ‘None’, onClick) et la remise en état de la salle ancrée dans le temps (start, end).
  • La recherche de patients avec events.filter et onEventFilter, le viewport de super-scheduler/hooks (useSchedulerState) pour le choix du jour, et le maintenant du cabinet en separator.
  • Cellules désactivées et refus à chaque image (allowed, message) pendant le glisser ou le redimensionnement, la carte de glisser, la carte au survol, le clavier et des événements contrôlés (onEventsChange).
  • La minicarte (super-scheduler/minimap) sur une plage fixe couvrant les deux jours de consultation, alimentée par la série propre de l’application ; sa fenêtre se pilote aussi au clavier, comme un curseur.

Le code de cet exemple décide

  • Quelles disciplines assurent chaque soin, ainsi que les pauses, la réunion et le nettoyage des salles.
  • Les statuts de visite et leur ordre, les salles occupées, la charge de chaque praticien et les chiffres de l’accueil.
  • Une phrase par motif de refus, annoncée dans une région live polie quand un dépôt est refusé.
  • Le panneau de détail, la mission et tous les textes de cette page.
  • La part réservée de chaque heure que dessine la minicarte, l’heure de pointe et les seuils « chargé » et « complet » partagés avec les jauges de charge.

Le code de cette démo.

Ce sont les fichiers exécutés par cette page, pas une copie simplifiée. Ils compilent avec les exports publics de SuperScheduler Pro.

tsx.zip

L’intégration : tailles de créneau, la ligne figée, les cartes à zones, les cellules désactivées issues des blocages, le filtre d’événements et les callbacks où les règles refusent un créneau.

/**
 * Forma appointment board: practitioners over two clinic days in 30- or 15-minute slots, a frozen
 * "rooms in use" row on top and the clinic's now.
 *
 * Library: minute-scale zoom levels, a frozen summary row (frozen: 'top', cellsDisabled) filled by
 * onBeforeCellRender, row header columns with a live load meter, rich cards from
 * onBeforeEventRender with areas (a clickable status chip, a time-anchored room reset), disabled
 * cells, a separator for "now", the event filter (events.filter + onEventFilter) behind the
 * patient search, drag/resize with per-frame vetoes, the drag card, the event hover card
 * (super-scheduler/react-render), conflict highlighting, a context menu and keyboard moves.
 * Application: who may deliver which treatment, the clinic's fixed blocks, the status cycle and
 * the sentence that explains every refusal. Those rules live in ./rules.
 */
import { useCallback, useEffect, useMemo, type RefObject } from 'react'
import type { SchedulerEventsChangeArgs, SuperScheduler } from 'super-scheduler'
import type { SchedulerHistory } from 'super-scheduler/history'
import { SuperSchedulerComponent, type SchedulerRenderProps } from 'super-scheduler/react-render'
import { format, plural } from '~/i18n/format'
import { DAY, HOUR, MINUTE, civil, parseCivil } from '../../scheduler/civil'
import { headerLabel } from '../../scheduler/header-format'
import { unitOfSpan } from '../../scheduler/live-headers'
import { createEventMenu } from '../kit/context-menu'
import { formatClock, formatDay, formatSpan, formatWhen } from '../kit/format'
import { defaultHints } from '../kit/hover-card'
import { KEYS } from '../kit/keys'
import { useDropRefusal } from '../kit/use-drop-refusal'
import { createDragCard } from '../kit/verdict'
import type { DemoCommon } from '../types'
import {
  CARD_HEIGHT,
  CARD_INSET,
  HEADER_ROW,
  PRACTITIONER_COLUMNS,
  SLOT_WIDTH,
  civilOf,
  isAppointmentEvent,
  practitionerOf,
  readAppointmentFields,
  toResources,
  type AppointmentEvent,
} from './adapter'
import {
  blockHtml,
  cardHtml,
  createHtmlCache,
  dayHtml,
  loadHtml,
  nowTagHtml,
  practitionerHtml,
  roomsCellHtml,
  slotHtml,
  statusChipHtml,
  summaryHeadHtml,
  teamHtml,
} from './cards'
import {
  BLOCKS,
  CLINIC_DAYS,
  NOW,
  OPENING_HOURS,
  PRACTITIONERS,
  PRACTITIONER_NAMES,
  RESET_MINUTES,
  TODAY,
  type Appointment,
} from './model'
import {
  TREATMENT_DISCIPLINES,
  blockAt,
  initials,
  matchesSearch,
  nextFreeSlot,
  nextStatus,
  roomsInUse,
  shortName,
  slotRefusal,
  utilisation,
  type Refusal,
} from './rules'
import { ZOOM_IDS, type FormaText, type ZoomId } from './text'
import { useVisitHover, type VisitCardModel } from './visit-card'
import './tokens.css'
import './forma.css'

/** What the board asks the demo to do (context menu, status chip). */
export type AppointmentAction = 'details' | 'cycle-status' | 'next-slot'

export interface FormaSchedulerProps {
  readonly events: AppointmentEvent[]
  /** The same appointments in model form: cards, figures and the menu read them. */
  readonly appointments: readonly Appointment[]
  readonly text: FormaText
  readonly common: DemoCommon
  /** BCP 47 tag for labels, and the scheduler locale id. */
  readonly tag: string
  readonly schedulerLocale: string
  /** Slot size on mount. Later changes go through control.zoom so the view animates. */
  readonly initialZoom: ZoomId
  /** The appointment shown in the detail sheet: it gets the selection ring. */
  readonly selected: string | null
  /** The patient search ('' shows everyone): applied with events.filter. */
  readonly query: string
  /** Narrow stage: a slimmer practitioner column. */
  readonly narrow: boolean
  /** The product skin: a class for the scheduler root (hover cards copy it) and the menu theme. */
  readonly skin: { readonly cssClass: string; readonly menuTheme: string }
  readonly history: SchedulerHistory
  readonly controlRef: RefObject<SuperScheduler.Scheduler | null>
  readonly onEventsChange: (args: SchedulerEventsChangeArgs) => void
  readonly onSelect: (id: string) => void
  readonly onMoved: (id: string) => void
  readonly onResized: (id: string) => void
  readonly onRefused: (id: string, refusal: Refusal) => void
  readonly onAction: (action: AppointmentAction, id: string) => void
  readonly onZoomLevel: (level: ZoomId) => void
}

/** Where an appointment could go next, by the clinic's rules (menu and sheet share it). */
export function nextSlotOf(
  appointment: Appointment,
  appointments: readonly Appointment[],
): { start: string; end: string } | null {
  const practitioner = practitionerOf(appointment.practitioner)
  if (practitioner === null) return null
  return nextFreeSlot(
    appointment,
    practitioner,
    BLOCKS,
    appointments,
    { first: CLINIC_DAYS.start, count: CLINIC_DAYS.count },
    OPENING_HOURS,
  )
}

/** Slot sizes: snapping follows the cell, so 15-minute cells move appointments by quarters. */
const SLOT_LEVELS: Readonly<Record<ZoomId, SuperScheduler.ZoomLevelProperties>> = {
  fifteen: { scale: 'CellDuration', cellDuration: 15, cellWidth: SLOT_WIDTH.fifteen },
  thirty: { scale: 'CellDuration', cellDuration: 30, cellWidth: SLOT_WIDTH.thirty },
}

// Same order as ZOOM_IDS, so onZoom's level index maps back to an id.
const ZOOM_LEVELS: SuperScheduler.ZoomLevel[] = ZOOM_IDS.map((id) => ({
  id,
  properties: SLOT_LEVELS[id],
}))

const NOW_TICKS = parseCivil(NOW)
/** The avatar (and status chip) on a card, in px. */
const AVATAR = 28
const TODAY_TICKS = parseCivil(TODAY)
const ROOMS_TOTAL = PRACTITIONERS.length

/** Every appointment the control holds right now, in the shape the rules read. */
function appointmentsIn(
  control: SuperScheduler.Scheduler,
): Pick<Appointment, 'id' | 'practitioner' | 'start' | 'end'>[] {
  return control.events.list.flatMap((event) => {
    const practitioner = event.resource === undefined ? null : practitionerOf(event.resource)
    if (practitioner === null || !isAppointmentEvent(event)) return []
    return [
      {
        id: String(event.id),
        practitioner: practitioner.id,
        start: civilOf(event.start),
        end: civilOf(event.end),
      },
    ]
  })
}

/** Checks one proposed slot of an appointment against the clinic's rules. */
function refusalFor(
  control: SuperScheduler.Scheduler | null,
  data: object,
  id: string,
  resource: SuperScheduler.ResourceId,
  start: SuperScheduler.Date,
  end: SuperScheduler.Date,
): Refusal | null {
  const fields = readAppointmentFields(data)
  const practitioner = practitionerOf(resource)
  if (control === null || fields === null || practitioner === null) return null
  return slotRefusal(
    { id, treatment: fields.treatment, start: civil(start.ticks), end: civil(end.ticks) },
    practitioner,
    BLOCKS,
    appointmentsIn(control),
  )
}

export function FormaScheduler(props: FormaSchedulerProps) {
  const {
    events,
    appointments,
    text,
    common,
    tag,
    schedulerLocale,
    initialZoom,
    selected,
    query,
    narrow,
    skin,
    history,
    controlRef,
  } = props
  const { onEventsChange, onSelect, onMoved, onResized, onRefused, onAction, onZoomLevel } = props

  const resources = useMemo(() => toResources(text), [text])
  const byId = useMemo(
    () => new Map(appointments.map((appointment) => [appointment.id, appointment])),
    [appointments],
  )

  // The drag card shows a refusal while the shadow sits on a forbidden slot; the hook announces
  // the last reason when the pointer is released without a drop, so it is heard, not only seen.
  const refusal = useDropRefusal(onRefused)

  // Visit card: the patient, the care, when and where, how it was booked, and who may deliver it.
  const card = useCallback(
    (event: SuperScheduler.Event): VisitCardModel | null => {
      const appointment = byId.get(String(event.id()))
      const practitioner =
        appointment === undefined ? null : practitionerOf(appointment.practitioner)
      // The appointment open in the sheet needs no card.
      if (appointment === undefined || practitioner === null || appointment.id === selected)
        return null
      const start = parseCivil(appointment.start)
      const end = parseCivil(appointment.end)
      const day = start - (start % DAY)
      const who = new Intl.ListFormat(tag, { type: 'conjunction' }).format(
        TREATMENT_DISCIPLINES[appointment.treatment].map(
          (discipline) => text.disciplines[discipline],
        ),
      )
      const reset = RESET_MINUTES[appointment.treatment]
      return {
        id: appointment.id,
        initials: initials(appointment.patient),
        patient: appointment.patient,
        code: appointment.id,
        treatment: appointment.treatment,
        treatmentLabel: text.treatments[appointment.treatment],
        status: appointment.status,
        statusLabel: text.statuses[appointment.status],
        time: {
          start,
          end,
          day: formatDay(start, tag),
          startLabel: formatClock(start, tag),
          endLabel: formatClock(end, tag),
          span: formatSpan(end - start, tag),
          window: { start: day + OPENING_HOURS.begin * HOUR, end: day + OPENING_HOURS.end * HOUR },
        },
        facts: [
          {
            label: text.fields.practitioner,
            value: `${PRACTITIONER_NAMES[practitioner.id]} · ${text.rooms[practitioner.room]}`,
          },
          { label: text.fields.channel, value: text.channels[appointment.channel] },
          ...(reset === 0
            ? []
            : [{ label: text.card.resetLabel, value: plural(text.minutes, reset, tag) }]),
        ],
        rule: format(text.card.deliveredBy, { who }),
        hints: defaultHints(common),
      }
    },
    [byId, selected, text, common, tag],
  )
  const { eventHover, closeHover, suppressHover } = useVisitHover(card)

  // Drag verdict: practitioner, the new slot, minutes, and the clinic's reason when it refuses.
  const dragCard = useMemo(
    () =>
      createDragCard({
        tag,
        common,
        rowName: (id) => {
          const practitioner = practitionerOf(id)
          return practitioner === null
            ? null
            : `${PRACTITIONER_NAMES[practitioner.id]} · ${text.rooms[practitioner.room]}`
        },
      }),
    [tag, common, text],
  )

  // Context menu: rebuilt when the day changes, so its labels name the real slot and status.
  const contextMenu = useMemo(
    () =>
      createEventMenu({
        theme: skin.menuTheme,
        title: (event) => format(common.kit.menuTitle, { name: String(event.id()) }),
        onOpenChange: (open) => suppressHover(open),
        entries: (event) => {
          const id = String(event.id())
          const appointment = byId.get(id)
          if (appointment === undefined) return []
          const slot = nextSlotOf(appointment, appointments)
          const next = nextStatus(appointment.status)
          return [
            {
              label: common.kit.openDetails,
              icon: 'details',
              keys: KEYS.details,
              run: () => onAction('details', id),
            },
            {
              label: format(text.actions.markAs, { status: text.statuses[next] }),
              icon: next === 'done' ? 'confirm' : 'pending',
              primary: true,
              run: () => onAction('cycle-status', id),
            },
            'separator',
            {
              label:
                slot === null
                  ? text.actions.noSlot
                  : format(text.actions.nextSlot, { time: formatWhen(slot.start, tag) }),
              icon: 'slot',
              disabled: slot === null,
              run: () => onAction('next-slot', id),
            },
          ]
        },
      }),
    [byId, appointments, skin, common, text, tag, onAction, suppressHover],
  )

  // Narrow stages keep the practitioner column only: the load meter steps aside.
  const columns = useMemo<SuperScheduler.RowHeaderColumnData[]>(
    () =>
      narrow
        ? [
            {
              name: text.columns.practitioner,
              width: PRACTITIONER_COLUMNS.narrowPractitioner,
              nonresizable: true,
            },
          ]
        : [
            {
              name: text.columns.practitioner,
              width: PRACTITIONER_COLUMNS.practitioner,
              nonresizable: true,
            },
            { name: text.columns.load, width: PRACTITIONER_COLUMNS.load, nonresizable: true },
          ],
    [narrow, text],
  )

  const config = useMemo<SchedulerRenderProps>(() => {
    const cards = createHtmlCache()
    const cells = createHtmlCache(1200)
    const rows = createHtmlCache(200)
    const headers = createHtmlCache(400)
    // Today's load per practitioner, for the meters in their headers.
    const loads = new Map(
      PRACTITIONERS.map((practitioner) => [
        practitioner.id,
        utilisation(appointments, BLOCKS, practitioner.id, TODAY, OPENING_HOURS),
      ]),
    )

    return {
      locale: schedulerLocale,
      cssClass: skin.cssClass,
      startDate: CLINIC_DAYS.start,
      days: CLINIC_DAYS.count,
      timeHeaders: [{ groupBy: 'Day' }, { groupBy: 'Cell' }],
      headerHeight: HEADER_ROW,
      zoomLevels: ZOOM_LEVELS,
      zoom: initialZoom,
      zoomPosition: 'left',
      // The clinic is closed at night: only opening hours are drawn.
      businessBeginsHour: OPENING_HOURS.begin,
      businessEndsHour: OPENING_HOURS.end,
      showNonBusiness: false,
      useEventBoxes: 'Never',
      height: '100%',
      treeEnabled: true,
      treePreventParentUsage: true,
      treeIndent: 0,
      rowHeaderColumns: columns,
      rowHeaderColumnsMergeParents: true,
      rowHeaderWidth: narrow
        ? PRACTITIONER_COLUMNS.narrowPractitioner
        : PRACTITIONER_COLUMNS.practitioner + PRACTITIONER_COLUMNS.load,
      rowHeaderWidthAutoFit: false,
      eventHeight: CARD_HEIGHT,
      rowMarginTop: CARD_INSET,
      rowMarginBottom: CARD_INSET,
      eventBorderRadius: 12,
      durationBarVisible: false,
      // The clinic's now: a calm line through the day, its time in the slot header.
      separators: [{ location: NOW, layer: 'AboveEvents', width: 2, cssClass: 'fm-nowline' }],
      allowEventOverlap: false,
      conflictHighlight: true,
      showToolTip: false,
      keyboardEnabled: true,
      keyboardTarget: 'component',
      keyboardMode: 'Full',
      history,
      controlRef,
      onEventsChange,

      // The search: an appointment shows when its patient or code matches.
      onEventFilter: (args) => {
        const param = args.filterParam
        const fields = readAppointmentFields(args.e.data)
        if (typeof param !== 'string' || fields === null) return
        args.visible = matchesSearch({ id: String(args.e.id()), patient: fields.patient }, param)
      },

      onBeforeTimeHeaderRender: (args) => {
        const header = args.header
        const start = header.start.ticks
        const span = header.end.ticks - start
        if (header.level === 0) {
          const today = start - (start % DAY) === TODAY_TICKS
          header.html = headers(`d:${start}:${span}`, () =>
            span <= DAY
              ? dayHtml(headerLabel(start, 'day', tag, 'group'), today ? text.day.today : null)
              : slotHtml(headerLabel(start, unitOfSpan(span, 'group'), tag, 'group'), true),
          )
          return
        }
        const minutes = new Date(start).getUTCMinutes()
        header.html = headers(`c:${start}:${span}`, () =>
          slotHtml(
            headerLabel(start, unitOfSpan(span, 'cell'), tag, 'cell', args.control.cellWidth),
            minutes === 0,
          ),
        )
        header.cssClass = minutes === 0 ? 'fm-slot-cell fm-slot-cell--hour' : 'fm-slot-cell'
        if (NOW_TICKS >= start && NOW_TICKS < start + span) {
          header.cssClass += ' fm-slot-cell--now'
          header.areas = [
            {
              left: `${((NOW_TICKS - start) / span) * 100}%`,
              top: 0,
              bottom: 0,
              width: 64,
              cssClass: 'fm-now-area',
              html: headers(`now:${tag}`, () => nowTagHtml(formatClock(NOW_TICKS, tag))),
            },
          ]
        }
      },

      onBeforeRowHeaderRender: (args) => {
        const row = args.row
        const [first, second] = row.columns
        if (row.id === 'rooms') {
          row.cssClass = 'fm-rh fm-rh--summary'
          const html = rows(`s:${text.summary.label}`, () =>
            summaryHeadHtml(text.summary.label, format(text.summary.meta, { total: ROOMS_TOTAL })),
          )
          row.html = html
          if (first !== undefined) first.html = html
          return
        }
        const practitioner = practitionerOf(row.id)
        if (practitioner === null) {
          row.cssClass = 'fm-rh fm-rh--team'
          const count = PRACTITIONERS.filter((candidate) => candidate.team === row.id).length
          const html = rows(`t:${String(row.id)}:${row.name}`, () => teamHtml(row.name, count))
          row.html = html
          if (first !== undefined) first.html = html
          return
        }
        row.cssClass = 'fm-rh fm-rh--person'
        const name = PRACTITIONER_NAMES[practitioner.id]
        if (first !== undefined)
          first.html = rows(`p:${practitioner.id}:${text.roles[practitioner.discipline]}`, () =>
            practitionerHtml(initials(name), name, text.roles[practitioner.discipline]),
          )
        if (second !== undefined) {
          const percent = loads.get(practitioner.id) ?? 0
          const label = format(text.load, { percent })
          second.html = rows(`l:${practitioner.id}:${percent}:${label}`, () =>
            loadHtml(percent, label),
          )
        }
      },

      // The frozen row counts rooms in use per slot; breaks, meetings and cleaning become disabled
      // cells (the library refuses drops on them); the past is quieter.
      onBeforeCellRender: (args) => {
        const cell = args.cell
        const start = cell.start.ticks
        const end = cell.end.ticks
        if (cell.resource === 'rooms') {
          const used = roomsInUse(appointments, civil(start), civil(end))
          const label = format(text.summary.cell, { count: used, total: ROOMS_TOTAL })
          cell.properties.html = cells(`r:${used}:${label}`, () =>
            roomsCellHtml(used, ROOMS_TOTAL, label),
          )
          cell.properties.cssClass =
            start <= NOW_TICKS && NOW_TICKS < end ? 'fm-sum fm-sum--now' : 'fm-sum'
          return
        }
        const practitioner = practitionerOf(cell.resource)
        if (practitioner === null) {
          cell.properties.cssClass = 'fm-team-cell'
          return
        }
        const past = end <= NOW_TICKS ? 'fm-past' : ''
        const cellStart = civil(start)
        const block = blockAt(BLOCKS, practitioner.id, cellStart, civil(end))
        if (block === null) {
          cell.properties.cssClass = past
          return
        }
        cell.properties.disabled = true
        cell.properties.cssClass = `fm-block fm-block--${block.kind}${cellStart === block.start ? ' fm-block--first' : ''} ${past}`
        if (cellStart === block.start)
          cell.properties.html = cells(`b:${block.kind}:${text.blocks[block.kind]}`, () =>
            blockHtml(text.blocks[block.kind]),
          )
      },

      onBeforeEventRender: (args) => {
        const data = args.data
        const fields = readAppointmentFields(data)
        if (fields === null) return
        const id = String(data.id)
        const practitioner = data.resource === undefined ? null : practitionerOf(data.resource)
        const room = practitioner === null ? '' : text.rooms[practitioner.room]
        const classes = ['fm-ev', `fm-ev--${fields.status}`]
        if (id === selected) classes.push('fm-ev--selected')
        data.cssClass = classes.join(' ')
        data.html = cards(
          `${id}:${fields.patient}:${fields.treatment}:${room}:${text.treatments[fields.treatment]}`,
          () =>
            cardHtml({
              patient: fields.patient,
              short: shortName(fields.patient),
              treatment: fields.treatment,
              treatmentLabel: text.treatments[fields.treatment],
              room,
            }),
        )
        data.ariaLabel = `${id}, ${fields.patient}, ${text.treatments[fields.treatment]}, ${text.statuses[fields.status]}`
        const next = nextStatus(fields.status)
        const who = initials(fields.patient)
        const areas: SuperScheduler.AreaData[] = [
          // The patient's avatar is the status chip: one click moves the visit on (booked →
          // arrived → in treatment → done).
          {
            left: 8,
            top: (CARD_HEIGHT - AVATAR) / 2,
            width: AVATAR,
            height: AVATAR,
            action: 'None',
            cssClass: `fm-who fm-who--${fields.status}`,
            html: cards(`who:${who}:${fields.status}`, () => statusChipHtml(who, fields.status)),
            toolTip: format(text.card.statusHint, {
              status: text.statuses[fields.status],
              next: text.statuses[next],
            }),
            onClick: () => {
              closeHover()
              onAction('cycle-status', id)
            },
          },
        ]
        // The room reset at the end of the slot, anchored in time.
        const reset = RESET_MINUTES[fields.treatment]
        if (reset > 0) {
          const end = data.end.ticks
          areas.push({
            start: civil(end - reset * MINUTE),
            end: civil(end),
            top: 0,
            bottom: 0,
            cssClass: 'fm-reset',
            action: 'Default',
            toolTip: format(text.card.reset, { minutes: reset }),
          })
        }
        data.areas = areas
      },

      onEventMoving: (args) => {
        const id = String(args.e.id())
        const reason = refusalFor(
          controlRef.current,
          args.e.data,
          id,
          args.resource,
          args.start,
          args.end,
        )
        refusal.track(id, reason)
        if (reason !== null) {
          args.allowed = false
          args.message = text.rules[reason]
        }
      },

      // Final check before the commit; keyboard moves (Alt+arrows) arrive here without a drag.
      onEventMove: (args) => {
        const id = String(args.e.id())
        const reason = refusalFor(
          args.control,
          args.e.data,
          id,
          args.newResource,
          args.newStart,
          args.newEnd,
        )
        if (reason !== null) {
          args.preventDefault()
          refusal.clear()
          onRefused(id, reason)
        }
      },

      onEventResizing: (args) => {
        const id = String(args.e.id())
        const resource = args.e.resource()
        const reason =
          resource === undefined
            ? null
            : refusalFor(controlRef.current, args.e.data, id, resource, args.start, args.end)
        refusal.track(id, reason)
        if (reason !== null) {
          args.allowed = false
          args.message = text.rules[reason]
        }
      },

      onEventResize: (args) => {
        const id = String(args.e.id())
        const resource = args.e.resource()
        const reason =
          resource === undefined
            ? null
            : refusalFor(args.control, args.e.data, id, resource, args.newStart, args.newEnd)
        if (reason !== null) {
          args.preventDefault()
          refusal.clear()
          onRefused(id, reason)
        }
      },

      onEventMoved: (args) => {
        refusal.clear()
        onMoved(String(args.e.id()))
      },
      onEventResized: (args) => {
        refusal.clear()
        onResized(String(args.e.id()))
      },
      // A click (or Enter) docks the appointment into the detail sheet; the hover card steps aside.
      onEventClick: (args) => {
        closeHover()
        onSelect(String(args.e.id()))
      },

      onZoom: (args) => {
        if (args.phase !== 'end') return
        const level = ZOOM_IDS[args.level]
        if (level !== undefined) onZoomLevel(level)
      },
    }
  }, [
    appointments,
    columns,
    controlRef,
    history,
    initialZoom,
    narrow,
    selected,
    skin,
    closeHover,
    onAction,
    onEventsChange,
    onMoved,
    onRefused,
    onResized,
    onSelect,
    onZoomLevel,
    refusal,
    schedulerLocale,
    tag,
    text,
  ])

  // The search goes through the library's event filter; the predicate is onEventFilter above.
  useEffect(() => {
    controlRef.current?.events.filter(query.trim() === '' ? null : query)
  }, [controlRef, query, config])

  return (
    <SuperSchedulerComponent
      {...config}
      resources={resources}
      events={events}
      eventHover={eventHover}
      dragCard={dragCard}
      contextMenu={contextMenu}
    />
  )
}

L’archive contient les fichiers de cet exemple et un README. Elle n’inclut ni SuperScheduler Pro ni aucune clé de téléchargement.