Zum Inhalt springen

Playground.

Schalten Sie jede Funktion von SuperScheduler Pro ein, sehen Sie, wo sie auf dem Board wirkt, und nehmen Sie den exakten Code mit.

59 Optionen, 12 Designs, Boards mit bis zu 150.000 Ereignissen. Drücken Sie /, um eine davon zu finden.

Live-Board

MarkeAna P.DesignJonas K.MotionMei L.DesignRafa D.ProduktionProduktNoor H.EntwicklungLuca B.EntwicklungIris V.DesignTom S.ProduktionStudioEva M.MotionKofi A.MotionLia R.DesignMax W.EntwicklungNimbus-KampagneSocial-ClipsAtlas-RelaunchIcon-SetAtlas-RelaunchDesign-ReviewHarbor-AppAPI-DokuHarbor-AppPressemappeNimbus-KampagneStore-AssetsAtlas-RelaunchOnboarding-FlowHarbor-AppUsability-TestNimbus-KampagneMarkenhandbuchHarbor-AppSocial-ClipsAtlas-RelaunchIcon-SetNimbus-KampagneDesign-ReviewAtlas-RelaunchAPI-DokuNimbus-KampagnePressemappeAtlas-RelaunchStore-AssetsHarbor-AppOnboarding-FlowNimbus-KampagnePreisseiteHarbor-AppSocial-ClipsAtlas-RelaunchIcon-SetNimbus-KampagneDesign-ReviewHarbor-AppAPI-Doku75%83%83%83%75%75%58%50%67%67%67%50%33%25%8%TeamauslastungOktober 2026So., 11.Mo., 12.Di., 13.Mi., 14.Do., 15.Fr., 16.Sa., 17.So., 18.Mo., 19.Di., 20.Mi., 21.Do., 22.Fr., 23.Sa., 24.So., 25.

Ziehen, Größe ändern, auswählen, Rechtsklick oder Zoom: Jeder Callback landet unter Ereignisse.

Ausgabe

import { useEffect, useMemo, useRef, useState } from 'react'
import { SuperScheduler, useSchedulerControl } from 'super-scheduler'
import type {
  SchedulerBeforeCellRenderArgs,
  SchedulerBeforeEventRenderArgs,
  SchedulerBeforeTimeHeaderRenderArgs,
  SchedulerEventHoverOptions,
  SchedulerRowFilterArgs,
  SchedulerTimeRangeSelectedArgs,
} from 'super-scheduler'
import { SuperSchedulerComponent } from 'super-scheduler/react-render'
import { createHistory } from 'super-scheduler/history'
import { SchedulerMinimap } from 'super-scheduler/minimap'
import { createLodBadge, createZoomSlider } from 'super-scheduler/zoom-ui'
import 'super-scheduler/styles.css'
import './my-planning.css'

/** Your event fields that the card template reads. */
interface Card {
  tone: number
  status: 'confirmed' | 'tentative' | 'live' | 'done' | 'risk'
  sub: string
  milestone?: boolean
}

const escape = SuperScheduler.Util.escapeHtml
const start = SuperScheduler.Date.today().firstDayOfWeek(1).addDays(-7)
const timeHeaders: SuperScheduler.TimeHeaderData[] = [
  { groupBy: 'Month', format: 'MMMM yyyy' },
  { groupBy: 'Day', format: 'ddd d' },
]

// Pinch, Ctrl/⌘ + wheel and the slider move through these levels continuously.
const zoomLevels: SuperScheduler.ZoomLevel[] = [
  {
    id: 'hours',
    properties: {
      scale: 'Hour',
      cellWidth: 46,
      timeHeaders: [
        { groupBy: 'Day', format: 'dddd d MMMM' },
        { groupBy: 'Hour', format: 'HH' },
      ],
    },
  },
  {
    id: 'days',
    properties: {
      scale: 'Day',
      cellWidth: 68,
      timeHeaders: [
        { groupBy: 'Month', format: 'MMMM yyyy' },
        { groupBy: 'Day', format: 'ddd d' },
      ],
    },
  },
  {
    id: 'weeks',
    properties: {
      scale: 'Week',
      cellWidth: 120,
      timeHeaders: [
        { groupBy: 'Month', format: 'MMMM yyyy' },
        { groupBy: 'Cell', format: 'd MMM' },
      ],
    },
  },
  {
    id: 'months',
    properties: {
      scale: 'Month',
      cellWidth: 150,
      timeHeaders: [
        { groupBy: 'Year', format: 'yyyy' },
        { groupBy: 'Month', format: 'MMMM' },
      ],
    },
  },
]

// One history per board, created once (not on every render).
const history = createHistory()

const hover: SchedulerEventHoverOptions = {
  delay: 300,
  pin: 'click',
  render: ({ e, row, pinned, close }) => (
    <section className="hover-card">
      <strong>{e.text()}</strong>
      <p>{row.name} · {e.start().toString('ddd d MMM')} – {e.end().toString('ddd d MMM')}</p>
      {pinned ? <button onClick={close}>Close</button> : null}
    </section>
  ),
}

interface PlanningProps {
  resources: SuperScheduler.ResourceData[]
  events: SuperScheduler.EventData<Card>[]
}

export function Planning({ resources, events }: PlanningProps) {
  const { controlRef, control } = useSchedulerControl()
  const [query, setQuery] = useState('')
  // rows.filter runs onRowFilter for each row; an empty value shows every row.
  useEffect(() => {
    control?.rows.filter(query.trim().toLowerCase() || null)
  }, [control, query])
  const toolbar = useRef<HTMLDivElement>(null)
  useEffect(() => {
    const host = toolbar.current
    if (control === null || host === null) return
    const slider = createZoomSlider(control, host, { detents: 'zoomLevels', label: 'Cell width' })
    const badge = createLodBadge(control, host)
    return () => {
      slider.dispose()
      badge.dispose()
    }
  }, [control])
  const menu = useMemo(() => eventMenu(control), [control])
  return (
    <div className="planning" style={{ height: 640 }}>
      <div className="planning__toolbar" ref={toolbar}>
        <input
          type="search"
          aria-label="Search rows"
          value={query}
          onChange={(event) => setQuery(event.target.value)}
        />
      </div>
      <SuperSchedulerComponent
        cssClass="my-planning"
        locale="de-de"
        density="comfortable"
        startDate={start}
        days={21}
        scale="Day"
        cellWidth={68}
        timeHeaders={timeHeaders}
        nowLine={{ label: true, cssClass: 'now' }}
        zoom="days"
        zoomGesture={{ min: 3, max: 900 }}
        treeEnabled
        rowHeaderColumns={[
        { title: 'Person', width: 150, display: 'name' },
        { title: 'Rolle', width: 104, display: 'detail' },
      ]}
        rowHeaderColumnsResizable
        rowHeaderResizable
        rowHeaderWidthMax={480}
        rowMarginTop={3}
        rowMarginBottom={3}
        eventHeight={42}
        useEventBoxes="Never"
        durationBarVisible={false}
        eventHtmlRightMargin={6}
        conflictHighlight
        timeRangeSelectedHandling="Enabled"
        keyboardEnabled
        keyboardTarget="component"
        keyboardMode="Full"
        keyboardOptions={{ zoomKeys: true }}
        showToolTip={false}
        eventHoverHandling="Disabled"
        height="100%"
        zoomLevels={zoomLevels}
        controlRef={controlRef}
        resources={resources}
        events={events}
        history={history}
        onBeforeEventRender={renderEvent}
        onBeforeTimeHeaderRender={renderTimeHeader}
        onBeforeCellRender={renderCell}
        onEventsChange={() => control?.update()}
        onRowFilter={filterRow}
        onTimeRangeSelected={createEvent}
        contextMenu={menu}
        eventHover={hover}
      />
      <div className="planning__overview">
        <span className="planning__overview-label">Overview</span>
        <SchedulerMinimap className="planning__minimap" control={control} height={28} />
      </div>
    </div>
  )
}

/** Writes each card: your fields, escaped, into the markup my-planning.css styles. */
function renderEvent({ data }: SchedulerBeforeEventRenderArgs) {
  const card = data as typeof data & Card
  if (card.milestone) {
    // A marker at its start, in the first lane, that pushes no other card away.
    data.type = 'Milestone'
    data.line = 0
    data.nonBlocking = true
    data.cssClass = `ev ev--milestone ev--t${card.tone}`
    data.html = ''
    data.htmlRight = `<span class="ev-side">${escape(data.text)}</span>`
    return
  }
  data.cssClass = `ev ev--twoLine ev--t${card.tone} ev--${card.status} ev--areas`
  data.html = `<span class="ev__title">${escape(data.text)}</span><span class="ev__meta super-scheduler-lod-full" data-super-scheduler-part="event-meta">${escape(card.sub)}</span>`
  data.areas = cardAreas(data, card)
}

/** Active areas: a setup band anchored to time, a hover action and a status dot. */
function cardAreas(data: SchedulerBeforeEventRenderArgs['data'], card: Card): SuperScheduler.AreaData[] {
  const length = data.end.getTime() - data.start.getTime()
  const areas: SuperScheduler.AreaData[] = []
  // A setup strip anchored to time along the card's foot: the first part of long work.
  if (length >= 3 * 86_400_000)
    areas.push({ start: data.start, end: data.start.addMilliseconds(Math.min(length * 0.15, 43_200_000)), bottom: 0, height: 3, cssClass: 'ev-band' })
  areas.push({
    right: 4, top: 11, width: 20, height: 20,
    html: '⋯', cssClass: 'ev-action', visibility: 'Hover',
    action: 'ContextMenu',
  })
  if (card.status === 'risk' || card.status === 'live')
    areas.push({ right: 6, top: 5, width: 7, height: 7, cssClass: `ev-status ev-status--${card.status}` })
  return areas
}

/** Each time header label as a word and a figure (Mo 12, October 2026), set apart in my-planning.css. */
function renderTimeHeader({ header }: SchedulerBeforeTimeHeaderRenderArgs) {
  const figure = (value: string) => `<span class="th-num">${escape(value)}</span>`
  const word = (value: string) => `<span class="th-word">${escape(value)}</span>`
  const wordFirst = /^(.*\p{L}.*?)\s+(\d+)$/u.exec(header.text)
  const figureFirst = /^(\d+)\.?\s+(.*\p{L}.*)$/u.exec(header.text)
  header.html = wordFirst
    ? `${word(wordFirst[1] ?? '')} ${figure(wordFirst[2] ?? '')}`
    : figureFirst
      ? `${figure(figureFirst[1] ?? '')} ${word(figureFirst[2] ?? '')}`
      : /^\d+$/.test(header.text)
        ? figure(header.text)
        : word(header.text)
}

/** The frozen summary row (resource `{ id: 'summary', frozen: 'top', cellsDisabled: true }`). */
function renderCell({ cell, control }: SchedulerBeforeCellRenderArgs) {
  if (cell.resource !== 'summary') return
  const share = occupancy(control, cell.start, cell.end)
  const pct = Math.round(share * 100)
  cell.properties.text = `${pct}%`
  cell.properties.cssClass = share >= 0.9 ? 'occ occ--full' : share >= 0.7 ? 'occ occ--high' : 'occ'
  cell.properties.areas = [{ left: 0, bottom: 0, height: 3, width: `${pct}%`, cssClass: share >= 0.9 ? 'occ-meter occ-meter--full' : 'occ-meter' }]
}

/** Booked time over bookable time in [start, end): computed from your data, not by the library. */
function occupancy(control: SuperScheduler.Scheduler, start: SuperScheduler.Date, end: SuperScheduler.Date) {
  const rows = control.rows.all().filter((row) => row.children().length === 0 && row.id !== 'summary').length
  let booked = 0
  for (const e of control.events.forRange(start, end))
    booked += Math.min(e.end().getTime(), end.getTime()) - Math.max(e.start().getTime(), start.getTime())
  return rows === 0 ? 0 : booked / (rows * (end.getTime() - start.getTime()))
}

function filterRow(args: SchedulerRowFilterArgs) {
  args.visible = args.row.name.toLowerCase().includes(String(args.filterParam))
}

/** Selecting empty cells creates an event there. */
function createEvent(args: SchedulerTimeRangeSelectedArgs) {
  const event: SuperScheduler.EventData<Partial<Card>> = {
    id: crypto.randomUUID(),
    start: args.start,
    end: args.end,
    resource: args.resource,
    text: 'New event',
    tone: 0,
    status: 'tentative',
  }
  args.control.events.add(event)
  args.control.clearSelection()
}

/** Right click, long press, or the Menu key / Shift+F10 on a focused card. */
function eventMenu(control: SuperScheduler.Scheduler | null) {
  const on = (run: (e: SuperScheduler.Event) => void) => ({ source }: SuperScheduler.MenuItemClickArgs) => {
    if (source instanceof SuperScheduler.Event) run(source)
  }
  const done = (e: SuperScheduler.Event): SuperScheduler.EventData<Partial<Card>> => ({ ...e.data, status: 'done' })
  return new SuperScheduler.Menu({
    theme: 'my-planning-menu',
    items: [
      { text: 'Duplicate', onClick: on((e) => control?.events.add({ ...e.data, id: crypto.randomUUID() })) },
      { text: 'Mark as done', onClick: on((e) => control?.events.update(done(e))) },
      { text: 'Move to next week', onClick: on((e) => control?.events.update({ ...e.data, start: e.start().addDays(7), end: e.end().addDays(7) })) },
      { text: '-' },
      { text: 'Remove', onClick: on((e) => control?.events.remove(e)) },
    ],
  })
}

Erzeugt aus demselben Einstellungsobjekt, das das Board konfiguriert. resources und events sind Ihre eigenen Daten.