Saltar al contenido

Playground.

Activa cualquier función de SuperScheduler Pro, mira dónde actúa en el tablero y llévate el código exacto.

59 opciones, 12 estilos, tableros de hasta 150.000 eventos. Pulsa / para encontrar cualquiera.

Tablero en vivo

MarcaAna P.DiseñoJonas K.MotionMei L.DiseñoRafa D.ProducciónProductoNoor H.IngenieríaLuca B.IngenieríaIris V.DiseñoTom S.ProducciónEstudioEva M.MotionKofi A.MotionLia R.DiseñoMax W.IngenieríaCampaña NimbusCortes para redesRelanzamiento AtlasJuego de iconosRelanzamiento AtlasRevisión de diseñoApp HarborDocumentación de la APIApp HarborKit de prensaCampaña NimbusMaterial para tiendasRelanzamiento AtlasFlujo de onboardingApp HarborTest de usabilidadCampaña NimbusManual de marcaApp HarborCortes para redesRelanzamiento AtlasJuego de iconosCampaña NimbusRevisión de diseñoRelanzamiento AtlasDocumentación de la APICampaña NimbusKit de prensaRelanzamiento AtlasMaterial para tiendasApp HarborFlujo de onboardingCampaña NimbusPágina de preciosApp HarborCortes para redesRelanzamiento AtlasJuego de iconosCampaña NimbusRevisión de diseñoApp HarborDocumentación de la API75%83%83%83%75%75%58%50%67%67%67%50%33%25%8%Carga del equipooctubre de 2026dom 11lun 12mar 13mié 14jue 15vie 16sáb 17dom 18lun 19mar 20mié 21jue 22vie 23sáb 24dom 25

Arrastra, redimensiona, selecciona, haz clic derecho o haz zoom: cada callback llega a Eventos.

Salida

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="es-es"
        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: 'Persona', width: 150, display: 'name' },
        { title: 'Rol', 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)) },
    ],
  })
}

Generado a partir del mismo objeto de ajustes que configura el tablero. resources y events son tus propios datos.