Timeline · Use cases
Subtask checklist inside events
Each job carries its checklist; ticking a step updates the job in your state. The checkboxes stop the drag so they stay checkboxes.
Live demo
Tick off a step · Drag a job by its title
Fullscreenimport { ProScheduler } from "@andreisaac/pro-scheduler"
import { priorityColors, technicians, workOrders, type WorkOrder } from "./data/operations"
import { useEvents } from "./kit"
export function SubtaskChecklistDemo() {
const { events, setEvents, handlers } = useEvents(workOrders)
const toggle = (id: string, index: number) =>
setEvents((list) =>
list.map((order) => {
if (order.id !== id) return order
const checklist = order.checklist.map((item, i) => (i === index ? { ...item, done: !item.done } : item))
const progress = Math.round((checklist.filter((i) => i.done).length / checklist.length) * 100)
return { ...order, checklist, progress }
})
)
return (
<ProScheduler
data={events}
resources={technicians}
view={{ timeline: { type: "week", resolutionHorizontal: "day" } }}
styleConfig={{ laneHeight: 128, minRowHeight: 140, unitWidthPx: 150, fitToWidth: false }}
showDefaultEditor={false}
renderTimelineEvent={({ original }) => {
const order = original as WorkOrder
return (
<div
className="flex h-full flex-col gap-1 overflow-hidden rounded-md border-l-4 bg-card p-1.5 text-[11px] shadow-xs ring-1 ring-border"
style={{ borderLeftColor: priorityColors[order.priority] }}
>
<strong className="truncate text-foreground">{order.title}</strong>
{order.checklist.map((item, i) => (
<label
key={item.label}
className="flex items-center gap-1.5 text-muted-foreground"
// Keep the checkbox a checkbox: don't start a drag or a click on the bar.
onPointerDown={(e) => e.stopPropagation()}
onClick={(e) => e.stopPropagation()}
>
<input type="checkbox" checked={item.done} onChange={() => toggle(order.id, i)} />
<span className={item.done ? "line-through" : undefined}>{item.label}</span>
</label>
))}
</div>
)
}}
height={620}
{...handlers}
/>
)
}// data/operations.ts — sample data, relative to the current week or month.
import type { SchedulerEvent, SchedulerResource } from "@andreisaac/pro-scheduler"
import { weekStart } from "./studio"
export type Priority = "Low" | "Normal" | "Urgent"
export type WorkOrder = SchedulerEvent & {
id: string
start: Date
end: Date
resource: string
customer: string
address: string
priority: Priority
/** 0–100 */
progress: number
checklist: { label: string; done: boolean }[]
}
export const priorityColors: Record<Priority, string> = {
Low: "#64748b",
Normal: "#2563eb",
Urgent: "#dc2626",
}
export const technicians: SchedulerResource[] = [
{ id: "t1", name: "Ana Pereira", skill: "HVAC", color: "#2563eb" },
{ id: "t2", name: "Ben Carter", skill: "Electrical", color: "#059669" },
{ id: "t3", name: "Chen Wei", skill: "Plumbing", color: "#d97706" },
{ id: "t4", name: "Dara Walsh", skill: "HVAC", color: "#7c3aed" },
{ id: "t5", name: "Eli Novak", skill: "Electrical", color: "#db2777" },
{ id: "t6", name: "Fatima Zahra", skill: "Plumbing", color: "#0891b2" },
]
const jobs: [string, string, string, Priority][] = [
["Boiler service", "Hillside School", "12 Oak Rd", "Normal"],
["Rewire kitchen", "Café Luna", "4 Market St", "Urgent"],
["Leak under sink", "M. Duarte", "88 River Ln", "Urgent"],
["AC filter swap", "Northline TV", "1 Studio Way", "Low"],
["Panel upgrade", "Greenhouse Co", "9 Farm Rd", "Normal"],
["Water heater", "K. Osei", "31 Elm St", "Normal"],
["Thermostat install", "Aurora Bank", "200 Main St", "Low"],
["Lighting fault", "City Library", "5 Civic Sq", "Urgent"],
["Drain survey", "Harbor Coffee", "17 Quay St", "Normal"],
["Heat pump check", "Lumen Labs", "3 Science Pk", "Low"],
["EV charger", "R. Silva", "64 Pine Ave", "Normal"],
["Burst pipe", "Riverside Flats", "2 Bank St", "Urgent"],
]
const steps = ["Arrive and assess", "Isolate supply", "Repair", "Test", "Customer sign-off"]
/** Two or three orders per technician across the working week. */
export function workOrders(base = weekStart()): WorkOrder[] {
return jobs.map(([title, customer, address, priority], i) => {
const tech = technicians[i % technicians.length]
const day = i % 5
const from = 8 + ((i * 3) % 7)
const hours = 2 + (i % 4)
const start = new Date(base.getFullYear(), base.getMonth(), base.getDate() + day, from)
const progress = [100, 60, 20, 0][i % 4]
const done = Math.round((progress / 100) * steps.length)
return {
id: `wo-${i + 1}`,
title,
customer,
address,
priority,
progress,
checklist: steps.map((label, s) => ({ label, done: s < done })),
start,
end: new Date(start.getTime() + hours * 3_600_000),
resource: String(tech.id),
color: priorityColors[priority],
}
})
}About this demo
Each job carries its checklist; ticking a step updates the job in your state. The checkboxes stop the drag so they stay checkboxes.
Things to try
- Tick off a step
- Drag a job by its title
The props behind it are explained in Custom rendering.