Planification des scènes d’un festival
Une balance mord sur la marge d’un concert. Zoomez à cinq minutes, raccourcissez-la et voyez les salles et équipes dont dépend l’artiste.
- Spectacle vivant
- Aurora Live
- Lignes de synthèse
- Minimap
- Dépendances
- Échelle à la minute
- Réticule
- Zoom continu
- Zones actives
- Colonnes de ligne
- Thèmes
- Démo avec données fictives
Mission
0 étapes faites sur 3Samedi, 18:25 : Saltwater Choir monte sur la scène du Chapiteau, mais sa balance finit seulement dix minutes avant.
Cliquez sur le concert de Saltwater Choir au Chapiteau. — À faire
Le panneau latéral montre la balance, la marge et les salles ; les lignes liées s’allument dans le planning.
Passez à l’échelle de 5 minutes. — À faire
Avec des cellules de 15 minutes, la balance ne pourrait finir qu’à 18:00 et durerait moins que les 20 minutes nécessaires.
Ramenez la fin de la balance à 18:05. — À faire
Le lien rouge redevient neutre dès qu’il reste 20 minutes. La balance ne peut pas commencer plus tôt : Northern Hum joue jusqu’à 17:45.
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.
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.
Aurora Live est un festival fictif d’une journée avec trois scènes, deux loges, une salle de presse et quatre équipes techniques. Le programme est publié des semaines à l’avance ; ce que la production planifie encore le jour même, ce sont les balances, glissées entre les concerts, chacune avec une marge avant l’entrée en scène.
Dans un tableur, cinq minutes disparaissent : une balance qui finit dix minutes avant un concert semble correcte à l’échelle de l’heure. Le planning doit zoomer jusqu’à la minute, garder chaque balance reliée à son concert, refuser les déplacements absurdes (une balance sur une autre scène, un concert déjà publié) et montrer les salles et équipes qu’implique chaque artiste.
Ce que vous allez faire
Vous ouvrirez la fiche d’un artiste dans le panneau latéral, zoomerez sur des cellules de cinq minutes et raccourcirez une balance jusqu’à ce que son lien avec le concert redevienne neutre.
Où s’arrête la bibliothèque et où commence votre application.
SuperScheduler fournit
- Axe intrajournalier sans la nuit (heures ouvrées, samedi compris) et zoomLevels des heures aux cellules de 15 et 5 minutes, animés par control.zoom.animateTo.
- Lignes groupées avec trois rowHeaderColumns (nom, jauge, bloc suivant) et un emptyHeight par ressource pour les libellés de groupe.
- Une ligne de synthèse frozen: 'top' peinte par onBeforeCellRender : une piste par scène, allumée, rayée ou hachurée à chaque cellule.
- Des badges onBeforeTimeHeaderRender en zones d’en-tête (portes, couvre-feu, heure du spectacle), des separators pour ces trois heures et crosshairType: 'Full'.
- Cartes écrites dans onBeforeEventRender (billet, rayures, hachures), zones au survol (visibility: 'Hover', action: 'None', onClick) qui décalent une balance, et liens fin-début courbes.
- Glisser et redimensionner calés sur la cellule active, sans chevauchement, refus sur la dragCard, conflictHighlight, annuler/rétablir avec createHistory, keyboardMode: 'Full', l’API rows.selection, cartes eventHover (super-scheduler/react-render) et un menu contextuel aux couleurs du produit.
- Sous le tableau, la minicarte de super-scheduler/minimap alimentée par le temps de scène par quart d’heure sur les heures d’ouverture (une série Float32Array sur une plage fixe), un ton par quart d’heure et des libellés traduits ; les services des équipes portent des zones placées dans le temps (start et end) pour les concerts qu’ils couvrent.
Le code de cet exemple décide
- Quels blocs bougent (seulement les balances), sur quelle scène, et jusqu’où une balance peut être raccourcie.
- La marge de 20 minutes entre une balance et son concert, le moment où son lien passe au rouge, et les liens dessinés (marges trop courtes et artiste sélectionné, ou tous).
- Ce que fait chaque scène dans chaque cellule (concert, balance, changement ou éteinte), l’heure du spectacle et le bandeau qui dit ce qui joue et ce qui suit.
- Les salles et équipes liées à un artiste, sa propre conduite dans le panneau latéral et la légende qui met une scène en avant.
- Ce que disent les cartes, la règle de cinq minutes du verdict, les actions du menu et du survol (garder la marge, décaler une balance de cinq minutes) et tous les textes de cette page.
- Le temps de scène par quart d’heure (concerts et balances rapportés au temps des trois scènes), les quarts d’heure où une marge est trop courte, le quart d’heure le plus chargé et les concerts que couvre chaque service.
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.
L’intégration : niveaux de zoom, heures de nuit masquées, rowHeaderColumns, la ligne de synthèse figée, les badges d’en-tête et les separators, la croix complète, la mise en évidence des lignes via rows.selection, la carte au survol, le verdict de glisser-déposer, le menu contextuel, les zones de décalage, les zones placées dans le temps sur les services des équipes et les callbacks où les règles refusent un déplacement ou un redimensionnement.
/**
* 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,
)
}L’archive contient les fichiers de cet exemple et un README. Elle n’inclut ni SuperScheduler Pro ni aucune clé de téléchargement.