Planificación de escenarios de un festival
Una prueba de sonido invade el margen de una actuación. Amplía a cinco minutos, recórtala y mira qué salas y equipos dependen del artista.
- Eventos en directo
- Aurora Live
- Filas de resumen
- Minimapa
- Dependencias
- Escala por minutos
- Cruceta
- Zoom continuo
- Áreas activas
- Columnas de fila
- Temas
- Demo con datos sintéticos
Misión
0 de 3 pasos hechosSábado, 18:25: Saltwater Choir sale a la Carpa, pero su prueba de sonido termina solo diez minutos antes.
Haz clic en la actuación de Saltwater Choir en la Carpa. — Pendiente
El panel lateral muestra la prueba, el margen y las salas; las filas relacionadas se resaltan en el tablero.
Cambia a la escala de 5 minutos. — Pendiente
Con celdas de 15 minutos la prueba solo podría acabar a las 18:00, y quedaría por debajo de los 20 minutos que necesita.
Arrastra el final de la prueba de sonido hasta las 18:05. — Pendiente
El vínculo rojo vuelve a ser neutro cuando quedan 20 minutos. La prueba no puede empezar antes: Northern Hum toca hasta las 17:45.
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.
Aurora Live es un festival ficticio de un día con tres escenarios, dos camerinos, una sala de prensa y cuatro equipos técnicos. El orden de actuaciones se publica semanas antes; lo que producción sigue planificando el mismo día son las pruebas de sonido, encajadas entre actuaciones y con un margen antes de que el grupo salga al escenario.
En una hoja de cálculo cinco minutos desaparecen: una prueba que acaba diez minutos antes de una actuación parece correcta con resolución horaria. El tablero tiene que ampliar hasta el minuto, mantener cada prueba unida a su actuación, rechazar los movimientos sin sentido (una prueba en otro escenario, una actuación ya publicada) y mostrar qué salas y equipos implica cada artista.
Qué vas a hacer
Abrirás la hoja de un artista en el panel lateral, ampliarás a celdas de cinco minutos y recortarás una prueba de sonido hasta que su vínculo con la actuación deje de estar en rojo.
Dónde termina la librería y empieza tu aplicación.
SuperScheduler aporta
- Línea de tiempo intradía con la noche oculta (horario laborable, sábado incluido) y zoomLevels de horas a celdas de 15 y 5 minutos, animados con control.zoom.animateTo.
- Filas agrupadas con tres rowHeaderColumns (nombre, aforo, siguiente bloque) y emptyHeight por recurso para las etiquetas de grupo.
- Una fila resumen frozen: 'top' pintada con onBeforeCellRender: un carril por escenario, encendido, rayado o tramado en cada celda.
- Distintivos de onBeforeTimeHeaderRender como áreas de cabecera (puertas, cierre, la hora del espectáculo), separators para esas tres horas y crosshairType: 'Full'.
- Tarjetas escritas en onBeforeEventRender (entrada, rayas, tramado), áreas al pasar el ratón (visibility: 'Hover', action: 'None', onClick) que desplazan una prueba y vínculos fin-inicio curvos.
- Arrastre y redimensionado ajustados a la celda activa, sin solapes, rechazos en la dragCard, conflictHighlight, deshacer y rehacer con createHistory, keyboardMode: 'Full', la API rows.selection, tarjetas eventHover (super-scheduler/react-render) y un menú contextual con el aspecto del producto.
- Bajo el tablero, el minimapa de super-scheduler/minimap alimentado con el uso de escenarios por cuarto de hora durante el horario de apertura (una serie Float32Array sobre un rango fijo), un tono por cuarto de hora y etiquetas traducidas; los turnos de los equipos llevan áreas situadas por hora (start y end) para las actuaciones que cubren.
El código de este ejemplo decide
- Qué bloques se mueven (solo las pruebas de sonido), en qué escenario y cuánto pueden acortarse.
- El margen de 20 minutos entre una prueba y su actuación, cuándo su vínculo se vuelve rojo y qué vínculos se dibujan (márgenes cortos y el artista seleccionado, o todos).
- Qué hace cada escenario en cada celda (actuación, prueba, cambio o apagado), la hora del espectáculo y la franja que dice qué suena ahora y qué viene después.
- Qué salas y equipos dependen de cada artista, la hoja propia del artista en el panel lateral y la leyenda que resalta un escenario.
- Lo que dicen las tarjetas, la regla de cinco minutos del veredicto de arrastre, las acciones del menú y al pasar el ratón (mantener el margen, desplazar una prueba cinco minutos) y todos los textos de esta página.
- El uso de escenarios por cuarto de hora (actuaciones y pruebas frente al tiempo de los tres escenarios), los cuartos en que un margen se queda corto, el cuarto más lleno y las actuaciones que cubre cada turno.
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: niveles de zoom, horas nocturnas ocultas, rowHeaderColumns, la fila resumen fija, los distintivos de cabecera y los separators, la cruz completa, el resaltado de filas con rows.selection, la tarjeta al pasar el ratón, el veredicto de arrastre, el menú contextual, las áreas de desplazamiento, las áreas situadas por hora en los turnos y los callbacks donde las reglas rechazan un movimiento o un cambio de duración.
/**
* Aurora Live run sheet: stages, rooms and crews over one festival day, down to five minutes.
*
* Library: timeline with hidden night, zoom levels from hours to 5-minute cells, tree rows with
* three row-header columns (rowHeaderColumns), a frozen summary row ("Stages live", frozen: 'top')
* painted by onBeforeCellRender, time-header badges through onBeforeTimeHeaderRender areas,
* separators for doors, curfew and the show clock, the full crosshair, row selection (related
* rows), dependency links, drag/resize with overlap prevention and conflict highlighting, hover
* areas on line checks, time-placed areas on crew calls (the sets they work), undo history, keyboard, the event hover card and the drag card
* (super-scheduler/react-render), a context menu, and the skin (./tokens.css, ./festival.css).
* Application: which blocks can move, the line-check buffer before each set, the shortest check,
* which rows relate to an act, what each stage is doing per cell and what the cards say. Those
* rules live in ./rules and run inside the callbacks below.
*/
import {
useCallback,
useEffect,
useMemo,
useState,
useSyncExternalStore,
type RefObject,
} from 'react'
import { SuperScheduler } from 'super-scheduler'
import type {
SchedulerBeforeTimeHeaderRenderArgs,
SchedulerEventsChangeArgs,
} from 'super-scheduler'
import type { SchedulerHistory } from 'super-scheduler/history'
import { SuperSchedulerComponent, type SchedulerRenderProps } from 'super-scheduler/react-render'
import { format } from '~/i18n/format'
import { HOUR, MINUTE, parseCivil } from '../../scheduler/civil'
import { toneClass } from '../../scheduler/tones'
import { headerLabel, usesTwelveHours } from '../../scheduler/header-format'
import { createHeaderHook } from '../../scheduler/live-headers'
import { createEventMenu, type MenuEntry } from '../kit/context-menu'
import { formatClock } from '../kit/format'
import { useEventHover, type HoverCardModel } from '../kit/hover-card'
import { KEYS } from '../kit/keys'
import { useDropRefusal } from '../kit/use-drop-refusal'
import { createDragCard } from '../kit/verdict'
import { skinClass, skinMenuTheme } from '../registry'
import type { DemoCommon } from '../types'
import {
CELL_WIDTH,
GEOMETRY,
LIVE_ROW,
STAGE_TONES,
actName,
civilOf,
isRowId,
readSlotFields,
slotLabel,
toResources,
type SlotEvent,
} from './adapter'
import { CLOSE_BUFFER } from './card-text'
import {
cardClasses,
createCardHtml,
createLiveCell,
headerMarkers,
markerAreas,
minuteLabel,
rowHeaderHtml,
} from './board-html'
import {
CURFEW,
DOORS,
FESTIVAL_DAY,
INITIAL_VIEW_START,
OPEN_HOURS,
SHOW_CLOCK,
type ActId,
type RowId,
type Slot,
} from './model'
import {
BUFFER_NEEDED,
actSlots,
bufferFix,
changeoverSets,
checkTooShort,
crewStages,
isStage,
moveProblem,
nudgeCheck,
setsDuring,
type MoveProblem,
type NudgeResult,
} from './rules'
import { bufferAt, bufferRuler, slotCard } from './slot-card'
import type { AuroraText, ZoomId } from './text'
import './tokens.css'
import './festival.css'
/** What the board asks the demo to do (context menu, keyboard). */
export type SlotAction = 'details' | 'keep-buffer' | 'earlier' | 'later' | 'go-check' | 'go-set'
/** Five-minute steps: the finest cell of the board. */
export const NUDGE_MINUTES = 5
const FIVE_MINUTES = 5 * MINUTE
export interface AuroraSchedulerProps {
readonly events: SlotEvent[]
readonly slots: readonly Slot[]
/** Acts whose line check ends too close to their set. */
readonly shortBuffers: readonly ActId[]
/** Rows that relate to the act in the side panel (highlighted). */
readonly relatedRows: readonly RowId[]
readonly text: AuroraText
readonly common: DemoCommon
/** BCP 47 tag for labels, and the scheduler locale id. */
readonly tag: string
readonly schedulerLocale: string
/** Level on mount. Later changes go through control.zoom so the view animates from where it is. */
readonly initialZoom: ZoomId
/** Every check-to-set link, or only those of the selected act and of short buffers. */
readonly showAllLinks: boolean
readonly selectedAct: ActId | null
/** The slot shown in the side sheet: it gets the selection ring. */
readonly selected: string | null
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, message: string) => void
readonly onAction: (action: SlotAction, id: string) => void
readonly onToggleLinks: () => void
readonly onZoomLevel: (level: ZoomId) => void
}
const ZOOM_LEVELS: SuperScheduler.ZoomLevel[] = [
{
id: 'hours',
properties: {
scale: 'Hour',
cellWidth: CELL_WIDTH.hours,
timeHeaders: [{ groupBy: 'Day' }, { groupBy: 'Hour' }],
},
},
{
id: 'quarter',
properties: {
scale: 'CellDuration',
cellDuration: 15,
cellWidth: CELL_WIDTH.quarter,
timeHeaders: [{ groupBy: 'Day' }, { groupBy: 'Cell' }],
},
},
{
id: 'five',
properties: {
scale: 'CellDuration',
cellDuration: 5,
cellWidth: CELL_WIDTH.five,
timeHeaders: [{ groupBy: 'Hour' }, { groupBy: 'Cell' }],
},
},
]
const ZOOM_IDS: readonly ZoomId[] = ['hours', 'quarter', 'five']
/**
* Time headers: the shared Intl labels, except at five minutes where the hour sits above and the
* minutes (":05") below, so 26 px cells stay readable. The upper row carries the run sheet's
* badges (doors, the show clock, curfew) as areas placed inside the cell that holds them.
*/
function festivalHeaders(
tag: string,
text: AuroraText,
): (args: SchedulerBeforeTimeHeaderRenderArgs) => void {
const shared = createHeaderHook(tag)
const markers = headerMarkers(text, tag)
return (args) => {
const start = args.header.start.getTime()
const end = args.header.end.getTime()
// The cell's own span tells the level (control.cellDuration lags during an animated zoom and
// keeps its last value on the hour level).
const span = end - start
if (args.header.level !== 0 && span === FIVE_MINUTES) args.header.html = minuteLabel(start)
else if (args.header.level === 0 && span === HOUR)
args.header.html = SuperScheduler.Util.escapeHtml(headerLabel(start, 'hour', tag, 'group'))
else shared(args)
if (args.header.level === 0) args.header.areas = markerAreas(markers, start, end)
}
}
/** The label of a five-minute nudge in the menu: the new time, or why it cannot happen. */
export function nudgeLabel(
direction: 'earlier' | 'later',
result: NudgeResult,
text: AuroraText,
tag: string,
): string {
if (result.ok) return format(text.actions[direction], { time: formatClock(result.start, tag) })
const reason =
result.reason === 'closed'
? text.actions.closed
: format(text.actions.blockedBy, {
name:
result.other.act === undefined
? slotLabel(result.other, text)
: actName(result.other.act),
})
return format(direction === 'earlier' ? text.actions.earlierBlocked : text.actions.laterBlocked, {
reason,
})
}
export function AuroraScheduler(props: AuroraSchedulerProps) {
const {
events,
slots,
shortBuffers,
relatedRows,
selectedAct,
selected,
text,
common,
tag,
schedulerLocale,
initialZoom,
showAllLinks,
history,
controlRef,
} = props
const {
onEventsChange,
onSelect,
onMoved,
onResized,
onRefused,
onAction,
onToggleLinks,
onZoomLevel,
} = props
const resources = useMemo(() => toResources(text), [text])
// Phones keep the name column only; capacity and the next block are in the cards and the panel.
const compact = useNarrowScreen()
const rowHeaderColumns = useMemo<SuperScheduler.RowHeaderColumnData[]>(
() => [
{ title: text.columns.name, width: compact ? 150 : GEOMETRY.rowHeader.name },
{
title: text.columns.capacity,
width: GEOMETRY.rowHeader.capacity,
toolTip: text.columns.capacityTip,
hidden: compact,
},
{
title: text.columns.next,
width: GEOMETRY.rowHeader.next,
toolTip: text.columns.nextTip,
hidden: compact,
},
],
[text, compact],
)
// Header labels follow the active level. An animated zoom renders the new level's headers before
// control.cellDuration reports it, so the hook is rebuilt (headers repainted) once a zoom lands.
const [headerHook, setHeaderHook] = useState(() => festivalHeaders(tag, text))
// Doors and curfew are fixed lines of the day; the show clock is the run sheet's "now".
const separators = useMemo<SuperScheduler.SeparatorData[]>(
() => [
{
location: DOORS,
cssClass: 'al-sep al-sep--doors',
layer: 'BelowEvents',
width: 1,
toolTip: text.markers.doors,
},
{
location: CURFEW,
cssClass: 'al-sep al-sep--curfew',
layer: 'BelowEvents',
width: 1,
toolTip: text.markers.curfew,
},
{
location: SHOW_CLOCK,
cssClass: 'al-sep al-sep--clock',
layer: 'AboveEvents',
width: 2,
toolTip: text.markers.onAir,
},
],
[text],
)
// What the grid paints, rebuilt when the plan changes and cached inside.
const paint = useMemo(() => {
const context = { slots, text, tag }
return {
card: createCardHtml(context),
row: rowHeaderHtml(context),
live: createLiveCell(slots, text),
}
}, [slots, text, tag])
// A refused drop (wrong stage, published set, short check, overlap) is said on release.
const refusal = useDropRefusal(onRefused)
// Each act's line check leads to its set: a finish-to-start link, red when the buffer is short.
// Morning checks would cross a whole stage row, so by default only the selected act and the
// short buffers show theirs.
const links = useMemo<SuperScheduler.LinkData[]>(() => {
const short = new Set(shortBuffers)
return slots.flatMap((check) => {
const set =
check.kind === 'check'
? slots.find((slot) => slot.kind === 'set' && slot.act === check.act)
: undefined
if (set === undefined || check.act === undefined) return []
if (!showAllLinks && !short.has(check.act) && check.act !== selectedAct) return []
return [
{
id: `${check.act}-buffer`,
from: check.id,
to: set.id,
type: 'FinishToStart' as const,
...(short.has(check.act) ? { cssClass: 'ss-link--late' } : {}),
},
]
})
}, [slots, shortBuffers, showAllLinks, selectedAct])
// Hover card: buffer, rooms and crews of the act, or what a crew block sits between.
const card = useCallback(
(event: SuperScheduler.Event): HoverCardModel | null => {
const slot = slots.find((candidate) => candidate.id === String(event.id()))
return slot === undefined ? null : slotCard(slot, slots, text, common, tag)
},
[slots, text, common, tag],
)
const { eventHover, closeHover, suppressHover } = useEventHover(card)
// Drag verdict: clock times (one festival day), the stage rules, and for line checks the
// buffer they would leave, drawn as five-minute pips so it reads at the finest zoom.
const dragCard = useMemo<SuperScheduler.DragCardOptions>(() => {
const pattern = usesTwelveHours(tag) ? 'h:mm tt' : 'HH:mm'
const sets = new Map(
slots.flatMap((slot) =>
slot.kind === 'set' && slot.act !== undefined ? [[slot.act, slot]] : [],
),
)
const checkOf = (id: SuperScheduler.EventId | null) =>
slots.find((slot) => slot.id === String(id) && slot.kind === 'check')
const base = createDragCard({
tag,
common,
rowName: (id) => (isRowId(id) ? text.rows[id] : null),
warn: (info) => {
const check = checkOf(info.eventId)
const set = check?.act === undefined ? undefined : sets.get(check.act)
if (check?.act === undefined || set === undefined) return null
const minutes = bufferAt(set.start, info.end.getTime())
return minutes >= BUFFER_NEEDED
? null
: format(text.card.early, {
minutes,
act: actName(check.act),
needed: BUFFER_NEEDED,
})
},
})
return {
...base,
markerFormat: pattern,
html: (info) => {
const html = base.html?.(info) ?? null
const check = checkOf(info.eventId)
const set = check?.act === undefined ? undefined : sets.get(check.act)
if (html === null || check === undefined || set === undefined) return html
if (String(info.resource) !== check.row || info.forbidden || info.overlapping) return html
// A check hours before its set needs no ruler; near the set it shows the buffer left.
const minutes = bufferAt(set.start, info.end.getTime())
if (minutes > CLOSE_BUFFER) return html
// The ruler goes inside the verdict, after its pills and before the reason line.
const ruler = bufferRuler(minutes, text)
const reason = html.indexOf('<div class="ss-vd__reason">')
return reason === -1
? `${html.slice(0, -'</div>'.length)}${ruler}</div>`
: `${html.slice(0, reason)}${ruler}${html.slice(reason)}`
},
}
}, [slots, text, common, tag])
// Context menu: rebuilt when the plan changes, so its labels name the real consequence.
const contextMenu = useMemo(
() =>
createEventMenu({
theme: skinMenuTheme('festival-stages'),
title: (event) => format(common.kit.menuTitle, { name: event.text() }),
onOpenChange: (open) => suppressHover(open),
entries: (event) => {
const id = String(event.id())
const slot = slots.find((candidate) => candidate.id === id)
if (slot === undefined) return []
const entries: MenuEntry[] = [
{
label: common.kit.openDetails,
icon: 'details',
keys: KEYS.details,
run: () => onAction('details', id),
},
]
const act = slot.act
if (act !== undefined && (slot.kind === 'set' || slot.kind === 'check')) {
const fix = bufferFix(act, slots)
if (fix !== null)
entries.push({
label: format(text.actions.keepBuffer, {
needed: BUFFER_NEEDED,
time: formatClock(fix.end, tag),
}),
icon: 'slot',
primary: true,
run: () => onAction('keep-buffer', id),
})
}
if (slot.kind === 'check') {
const earlier = nudgeCheck(slot, slots, -NUDGE_MINUTES)
const later = nudgeCheck(slot, slots, NUDGE_MINUTES)
entries.push(
'separator',
{
label: nudgeLabel('earlier', earlier, text, tag),
icon: 'after',
disabled: !earlier.ok,
run: () => onAction('earlier', id),
},
{
label: nudgeLabel('later', later, text, tag),
icon: 'after',
disabled: !later.ok,
run: () => onAction('later', id),
},
)
} else if (slot.kind === 'set' && act !== undefined) {
const check = actSlots(act, slots).check
if (check !== undefined)
entries.push('separator', {
label: `${text.actions.goToCheck} · ${formatClock(check.start, tag)}`,
icon: 'focus',
run: () => onAction('go-check', id),
})
} else {
// Rooms and crews follow the running order: the menu leads to the set that decides.
const next =
slot.kind === 'changeover'
? changeoverSets(slot, slots).after
: act === undefined
? undefined
: actSlots(act, slots).set
if (next?.act !== undefined)
entries.push('separator', {
label: `${format(text.actions.goToAct, { act: actName(next.act) })} · ${formatClock(next.start, tag)}`,
icon: 'focus',
run: () => onAction('go-set', id),
})
}
entries.push('separator', {
label: showAllLinks ? text.actions.hideLinks : text.actions.showLinks,
icon: 'link',
run: onToggleLinks,
})
return entries
},
}),
[slots, showAllLinks, common, text, tag, onAction, onToggleLinks, suppressHover],
)
const config = useMemo<SchedulerRenderProps>(() => {
const short = new Set<string>(shortBuffers)
const related = new Set<string>(relatedRows)
const problemText = (problem: MoveProblem) =>
problem === 'published'
? text.rules.published
: problem === 'follows'
? text.rules.follows
: text.rules.wrongStage
const overlapText = (conflicts: readonly SuperScheduler.Event[]) => {
const first = conflicts[0]
return first === undefined ? null : format(common.kit.overlaps, { name: first.text() })
}
const byId = new Map(slots.map((slot) => [slot.id, slot]))
// Hover buttons of a line check: five minutes earlier or later, named by their result.
const nudgeAreas = (slot: Slot): SuperScheduler.AreaData[] =>
(['earlier', 'later'] as const).map((direction, index) => {
const result = nudgeCheck(
slot,
slots,
direction === 'earlier' ? -NUDGE_MINUTES : NUDGE_MINUTES,
)
const label = nudgeLabel(direction, result, text, tag)
return {
right: index === 0 ? 30 : 4,
top: 4,
width: 24,
height: 18,
visibility: 'Hover',
action: 'None',
cssClass: `al-nudge${result.ok ? '' : ' al-nudge--off'}`,
html: `<span aria-hidden="true">${direction === 'earlier' ? '−5' : '+5'}</span>`,
toolTip: label,
onClick: () => {
if (result.ok) onAction(direction, slot.id)
else onRefused(slot.id, label)
},
}
})
// A crew call shows when its stages are lit: one segment per set it works, placed by time (the
// library positions areas from `start` and `end`) in that stage's light.
const shiftAreas = (slot: Slot): SuperScheduler.AreaData[] =>
setsDuring(slot, slots).flatMap((set) =>
set.act === undefined || !isStage(set.row)
? []
: [
{
// The set, clipped to the call.
start: parseCivil(set.start) > parseCivil(slot.start) ? set.start : slot.start,
end: parseCivil(set.end) < parseCivil(slot.end) ? set.end : slot.end,
// One lane per stage the crew works, stacked along the foot.
bottom: 1 + 2 * Math.max(0, crewStages(slot.row).indexOf(set.row)),
height: 2,
nonFloating: true,
cssClass: `al-call ${toneClass(STAGE_TONES[set.row])}`,
toolTip: `${actName(set.act)} · ${formatClock(set.start, tag)}`,
},
],
)
return {
locale: schedulerLocale,
startDate: FESTIVAL_DAY,
days: 1,
zoomLevels: ZOOM_LEVELS,
zoom: initialZoom,
zoomPosition: 'left',
// The site opens at noon: the morning stays hidden. A Saturday is a working day here.
businessBeginsHour: OPEN_HOURS.begin,
businessEndsHour: OPEN_HOURS.end,
businessWeekends: true,
showNonBusiness: false,
useEventBoxes: 'Never',
height: '100%',
cssClass: `al-board ${skinClass('festival-stages')}`,
treeEnabled: true,
treePreventParentUsage: true,
rowHeaderColumns,
rowHeaderWidthAutoFit: false,
eventHeight: GEOMETRY.eventHeight,
rowMarginTop: GEOMETRY.rowMargin,
rowMarginBottom: GEOMETRY.rowMargin,
crosshairType: 'Full',
separators,
allowEventOverlap: false,
conflictHighlight: true,
linkLayer: 'Below',
timeRangeSelectedHandling: 'Disabled',
durationBarVisible: false,
showToolTip: false,
keyboardEnabled: true,
keyboardTarget: 'component',
keyboardMode: 'Full',
history,
controlRef,
onEventsChange,
onBeforeTimeHeaderRender: headerHook,
onBeforeRowHeaderRender: (args) => {
const id = String(args.row.id)
const html = paint.row(id)
if (html === null) return
const [name, capacity, next] = args.row.columns
if (name !== undefined) name.html = html.name
if (capacity !== undefined) capacity.html = html.capacity
if (next !== undefined) next.html = html.next
args.row.cssClass =
id === LIVE_ROW
? 'al-row--live'
: args.row.data.children !== undefined
? 'al-row--group'
: ''
},
// The frozen row sums up the stages per cell; the selected act's rows are tinted (their
// headers come from rows.selection).
onBeforeCellRender: (args) => {
const cell = args.cell
if (cell.resource === LIVE_ROW) {
const live = paint.live(cell.start.getTime(), cell.end.getTime())
cell.properties.html = live.html
cell.properties.cssClass = `al-live-cell al-live-cell--${live.count}`
return
}
if (related.has(String(cell.resource))) cell.properties.cssClass = 'al-related'
},
onBeforeEventRender: (args) => {
const fields = readSlotFields(args.data)
const id = String(args.data.id)
const known = byId.get(id)
if (fields === null || known === undefined) return
// The control may hold newer times than React (a drop lands before onEventsChange).
const slot: Slot = {
...known,
start: civilOf(args.data.start),
end: civilOf(args.data.end),
}
args.data.html = paint.card(slot)
let classes = cardClasses(slot)
if (fields.kind === 'set' && fields.act !== undefined && short.has(fields.act))
classes += ' ss-ev--late'
if (id === selected) classes += ' al-ev--selected'
args.data.cssClass = classes
if (fields.kind === 'check') args.data.areas = nudgeAreas(slot)
else if (fields.kind === 'shift') args.data.areas = shiftAreas(slot)
},
// Only line checks move, and only on their act's stage; overlap is refused by the library.
onEventMoving: (args) => {
const id = String(args.e.id())
const fields = readSlotFields(args.e.data)
const problem = fields === null ? null : moveProblem(fields, String(args.resource))
if (problem !== null) {
const message = problemText(problem)
args.allowed = false
args.message = message
refusal.track(id, message)
return
}
refusal.track(id, overlapText(args.conflicts))
},
// Final check before the commit (also covers keyboard moves).
onEventMove: (args) => {
const fields = readSlotFields(args.e.data)
const problem = fields === null ? null : moveProblem(fields, String(args.newResource))
if (problem !== null) {
args.preventDefault()
refusal.clear()
onRefused(String(args.e.id()), problemText(problem))
}
},
onEventResizing: (args) => {
const id = String(args.e.id())
if (checkTooShort(args.start.value, args.end.value)) {
args.allowed = false
args.message = text.rules.tooShort
refusal.track(id, text.rules.tooShort)
return
}
refusal.track(id, overlapText(args.conflicts))
},
onEventResize: (args) => {
if (checkTooShort(args.newStart.value, args.newEnd.value)) {
args.preventDefault()
refusal.clear()
onRefused(String(args.e.id()), text.rules.tooShort)
}
},
onEventMoved: (args) => {
refusal.clear()
onMoved(String(args.e.id()))
},
onEventResized: (args) => {
refusal.clear()
onResized(String(args.e.id()))
},
// A click (or Enter) docks the slot into the side sheet; the hover card steps aside.
onEventClick: (args) => {
closeHover()
onSelect(String(args.e.id()))
},
onZoom: (args) => {
if (args.phase !== 'end') return
setHeaderHook(() => festivalHeaders(tag, text))
const level = ZOOM_IDS[args.level]
if (level !== undefined) onZoomLevel(level)
},
}
}, [
history,
controlRef,
slots,
shortBuffers,
relatedRows,
selected,
rowHeaderColumns,
separators,
paint,
common,
refusal,
closeHover,
onAction,
onEventsChange,
onMoved,
onRefused,
onResized,
onSelect,
onZoomLevel,
schedulerLocale,
headerHook,
tag,
text,
initialZoom,
])
// Highlighted rows are the control's row selection, driven by the act in the side panel.
useEffect(() => {
const control = controlRef.current
if (control === null || control.disposed()) return
control.rows.selection.clear()
for (const id of relatedRows) {
const row = control.rows.find(id)
if (row !== null) control.rows.selection.add(row)
}
}, [controlRef, relatedRows])
// Imperative and once: a scroll prop would be re-applied on every update.
useEffect(() => {
controlRef.current?.scrollTo(INITIAL_VIEW_START, false, 'left')
}, [controlRef])
return (
<SuperSchedulerComponent
{...config}
resources={resources}
events={events}
links={links}
eventHover={eventHover}
dragCard={dragCard}
contextMenu={contextMenu}
/>
)
}
const NARROW = '(max-width: 639px)'
/** True on phone-sized screens (the stage is then too narrow for three header columns). */
function useNarrowScreen(): boolean {
return useSyncExternalStore(
(notify) => {
const query = window.matchMedia(NARROW)
query.addEventListener('change', notify)
return () => query.removeEventListener('change', notify)
},
() => window.matchMedia(NARROW).matches,
() => false,
)
}El archivo contiene los ficheros de este ejemplo y un README. No incluye SuperScheduler Pro ni ninguna clave de descarga.