Citas de clínica de fisioterapia
Un paciente no puede venir a las 10:00. Encuentra el siguiente hueco que respete pausas y limpiezas.
- Salud
- Forma
- Escala por minutos
- Filas de resumen
- Minimapa
- Búsqueda en vivo
- Áreas activas
- Reglas de movimiento
- Tiempo bloqueado
- Columnas de fila
- Temas
- Demo con datos sintéticos
Misión
0 de 3 pasos hechosJueves, 9:40: Owen Hart (F-2318, rehabilitación de rodilla a las 10:00 con Alba R.) llama para pedir una hora más tarde.
Arrastra F-2318 a la fila de Marc D. a las 12:00, mientras se limpia su sala. — Pendiente
Los huecos rayados están bloqueados. La tarjeta de arrastre muestra el motivo y la cita no se suelta ahí.
Suéltala a las 12:30 en la fila de Marc D., justo después de la limpieza. — Pendiente
Vale cualquier hueco libre de un profesional que haga rehabilitación de rodilla. La fila del osteópata la rechaza.
Cambia a huecos de 15 minutos y alarga una cita un cuarto de hora. — Pendiente
Elige «15 min» en la barra y arrastra el borde derecho de una tarjeta. Con el teclado, Alt+Mayús+flechas cambia su duración.
Unos 30 segundos. Los pasos se marcan a medida que los completas.
Teclado: enfoca la rejilla y usa las flechas, Intro y Alt+flechas para mover.
Vista previa del primer fotogramaEn vivo: el motor Pro real, funcionando en tu navegadorUnos 30 segundos. Los pasos se marcan a medida que los completas. Teclado: enfoca la rejilla y usa las flechas, Intro y Alt+flechas para mover.
La situación.
Forma es una clínica ficticia con tres fisioterapeutas, un osteópata y una terapeuta de masaje deportivo. Las citas duran de 15 a 60 minutos, cada profesional trabaja en una sala y el día se interrumpe con pausas, una sesión clínica y la limpieza de las salas entre tratamientos.
Cuando un paciente llama para cambiar una cita, recepción tiene segundos para encontrar hueco mientras se llena la sala de espera. Una cuadrícula en papel o un calendario genérico dejan citar encima de una pausa o dar una sesión de osteopatía a un fisioterapeuta. La agenda tiene que rechazar esos huecos y decir por qué, también en voz alta para quien usa lector de pantalla. Pacientes, personal y citas son inventados.
Qué vas a hacer
Intentarás colocar una cita en un hueco de limpieza, oirás por qué se rechaza, la llevarás al primer hueco libre después de la limpieza y ajustarás su duración en pasos de 15 minutos.
Dónde termina la librería y empieza tu aplicación.
SuperScheduler aporta
- Escalas por minutos como zoomLevels (celdas de 30 y 15 minutos) con ajuste a la rejilla y la noche oculta (showNonBusiness: false).
- Una fila resumen fija (frozen: ‘top’, cellsDisabled) que rellena onBeforeCellRender, y cabeceras de profesional con medidores de carga en vivo mediante rowHeaderColumns.
- Tarjetas ricas desde onBeforeEventRender con áreas: el avatar del paciente como chip de estado clicable (action: ‘None’, onClick) y la preparación de la sala anclada en el tiempo (start, end).
- Búsqueda de pacientes con events.filter y onEventFilter, el viewport de super-scheduler/hooks (useSchedulerState) para el selector de día, y el ahora de la clínica como separator.
- Celdas deshabilitadas y vetos por fotograma (allowed, message) al arrastrar o redimensionar, la tarjeta de arrastre, la tarjeta al pasar el ratón, el teclado y eventos controlados (onEventsChange).
- El minimapa (super-scheduler/minimap) con un rango fijo sobre los dos días de consulta, alimentado con la serie propia de la aplicación; su selector también funciona como deslizador desde el teclado.
El código de este ejemplo decide
- Qué disciplinas pueden hacer cada tratamiento, y las pausas, la sesión clínica y la limpieza de salas.
- Los estados de la visita y su orden, las salas en uso, la carga de cada profesional y las cifras de recepción.
- Una frase por cada motivo de rechazo, anunciada en una región en vivo cortés cuando no se puede soltar la cita.
- El panel de detalle, la misión y todos los textos de esta página.
- La parte reservada de cada hora que dibuja el minimapa, la hora punta y los umbrales de «ocupado» y «completo» que comparte con los medidores de carga.
El código de esta demo.
Son los archivos que ejecuta esta página, no una copia simplificada. Compilan contra los exports públicos de SuperScheduler Pro.
La integración: tamaños de hueco, la fila fija, tarjetas con áreas, celdas deshabilitadas a partir de los bloqueos, el filtro de eventos y los callbacks donde las reglas rechazan un hueco.
/**
* 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}
/>
)
}El archivo contiene los ficheros de este ejemplo y un README. No incluye SuperScheduler Pro ni ninguna clave de descarga.