{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "recurring-jobs-calendar",
  "title": "Recurring Jobs Calendar",
  "description": "A month of scheduled bot runs at a glance: a dot for every run, red where one failed, and pick any day to see what ran or will run.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/recurring-jobs-calendar/recurring-jobs-calendar.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface RecurringJob {\n  id: string;\n  name: string;\n  /** Short time, e.g. \"02:00\". */\n  time: string;\n  /** Plain wording, e.g. \"Every weekday\". */\n  schedule: string;\n  /** Days of the week it runs, with 0 as Monday. */\n  weekdays?: number[];\n  /** Dates of the month it runs. */\n  dates?: number[];\n  /** Past dates where it failed. */\n  failedOn?: number[];\n}\n\nexport interface RecurringJobsCalendarProps extends Omit<\n  React.ComponentPropsWithoutRef<\"section\">,\n  \"title\"\n> {\n  theme?: \"dark\" | \"light\";\n  title?: string;\n  year?: number;\n  /** From 0 to 11. */\n  month?: number;\n  /** Today's date in that month. */\n  today?: number;\n  jobs?: RecurringJob[];\n  onSelectDay?: (date: number) => void;\n}\n\nconst FONT =\n  '\"Inter Variable\", Inter, \"SF Pro Display\", -apple-system, BlinkMacSystemFont, sans-serif';\nconst ACCENT = \"#5E6AD2\";\nconst RED = \"#EB5757\";\nconst GREEN = \"#27A644\";\nconst RING = \"outline-none focus-visible:ring-2 focus-visible:ring-[#5E6AD2]\";\nconst COLORS = [\"#5E6AD2\", \"#4EA7FC\", \"#8A8F98\"];\nconst WEEKDAYS = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\", \"Sun\"];\nconst MONTHS = [\n  \"January\",\n  \"February\",\n  \"March\",\n  \"April\",\n  \"May\",\n  \"June\",\n  \"July\",\n  \"August\",\n  \"September\",\n  \"October\",\n  \"November\",\n  \"December\",\n];\n\nconst PALETTES = {\n  dark: {\n    card: \"#08090A\",\n    border: \"rgba(255,255,255,0.08)\",\n    text: \"#F7F8F8\",\n    soft: \"#D0D6E0\",\n    sub: \"#8A8F98\",\n    faint: \"#62666D\",\n    chip: \"rgba(255,255,255,0.05)\",\n    cell: \"rgba(255,255,255,0.03)\",\n    picked: \"rgba(94,106,210,0.16)\",\n  },\n  light: {\n    card: \"#FFFFFF\",\n    border: \"rgba(8,9,10,0.08)\",\n    text: \"#08090A\",\n    soft: \"#3C3F44\",\n    sub: \"#62666D\",\n    faint: \"#8A8F98\",\n    chip: \"rgba(8,9,10,0.04)\",\n    cell: \"rgba(8,9,10,0.025)\",\n    picked: \"rgba(94,106,210,0.12)\",\n  },\n};\n\nconst DEFAULT_JOBS: RecurringJob[] = [\n  {\n    id: \"sync\",\n    name: \"Warehouse sync\",\n    time: \"02:00\",\n    schedule: \"Every weekday\",\n    weekdays: [0, 1, 2, 3, 4],\n    failedOn: [9],\n  },\n  {\n    id: \"digest\",\n    name: \"Weekly digest\",\n    time: \"08:00\",\n    schedule: \"Every Monday\",\n    weekdays: [0],\n  },\n  {\n    id: \"invoices\",\n    name: \"Monthly invoices\",\n    time: \"06:30\",\n    schedule: \"On the 1st and 15th\",\n    dates: [1, 15],\n  },\n];\n\n/** Drawn as SVG, because a tiny border-radius circle turns lumpy on 1x screens. */\nfunction Dot({ size, color }: { size: number; color: string }) {\n  const r = size / 2;\n  return (\n    <svg\n      aria-hidden=\"true\"\n      width={size}\n      height={size}\n      viewBox={`0 0 ${size} ${size}`}\n      className=\"block shrink-0\"\n    >\n      <circle cx={r} cy={r} r={r} style={{ fill: color }} />\n    </svg>\n  );\n}\n\nexport function RecurringJobsCalendar({\n  theme = \"dark\",\n  title = \"Scheduled runs\",\n  year = 2026,\n  month = 2,\n  today = 12,\n  jobs = DEFAULT_JOBS,\n  onSelectDay,\n  className,\n  style,\n  ...rest\n}: RecurringJobsCalendarProps) {\n  const c = PALETTES[theme];\n  const [selected, setSelected] = React.useState(today);\n  const [hidden, setHidden] = React.useState<string[]>([]);\n\n  // UTC, so the grid is the same on the server and in every time zone.\n  const days = new Date(Date.UTC(year, month + 1, 0)).getUTCDate();\n  const offset = (new Date(Date.UTC(year, month, 1)).getUTCDay() + 6) % 7;\n  const weekdayOf = (date: number) => (date - 1 + offset) % 7;\n  const dates = Array.from({ length: days }, (_, i) => i + 1);\n\n  const runsOn = (date: number) =>\n    jobs.filter(\n      (j) =>\n        !hidden.includes(j.id) &&\n        (j.weekdays?.includes(weekdayOf(date)) || j.dates?.includes(date)),\n    );\n  const total = dates.reduce((sum, d) => sum + runsOn(d).length, 0);\n  const failed = dates.reduce(\n    (sum, d) => sum + runsOn(d).filter((j) => j.failedOn?.includes(d)).length,\n    0,\n  );\n  const colorOf = (job: RecurringJob) =>\n    COLORS[jobs.indexOf(job) % COLORS.length];\n\n  const stateOf = (job: RecurringJob, date: number) =>\n    job.failedOn?.includes(date)\n      ? { label: \"Failed\", color: RED }\n      : date < today\n        ? { label: \"Done\", color: GREEN }\n        : date === today\n          ? { label: \"Today\", color: ACCENT }\n          : { label: \"Scheduled\", color: c.faint };\n\n  const select = (date: number) => {\n    setSelected(date);\n    onSelectDay?.(date);\n  };\n\n  return (\n    <section\n      aria-label={title}\n      className={`@container w-full rounded-2xl border ${className ?? \"\"}`}\n      style={{\n        background: c.card,\n        borderColor: c.border,\n        color: c.text,\n        fontFamily: FONT,\n        ...style,\n      }}\n      {...rest}\n    >\n      <div className=\"p-5 pb-3 @2xl:p-6 @2xl:pb-3\">\n        <div className=\"flex items-start justify-between gap-4\">\n          <header className=\"min-w-0\">\n            <h3 className=\"m-0 text-[20px] leading-[26px] font-[590] tracking-[-0.012em]\">\n              {title}\n            </h3>\n            <p\n              className=\"m-0 mt-1 text-[13px] leading-[20px] tracking-[-0.011em]\"\n              style={{ color: c.sub }}\n            >\n              {MONTHS[month]} {year}\n            </p>\n          </header>\n          <div className=\"shrink-0 text-right\">\n            <p\n              aria-live=\"polite\"\n              className=\"m-0 text-[32px] leading-[32px] font-[510] tracking-[-0.022em] tabular-nums\"\n            >\n              {total}\n            </p>\n            <p\n              className=\"m-0 mt-1.5 text-[13px] leading-[20px] tabular-nums\"\n              style={{ color: c.sub }}\n            >\n              Runs, {failed} failed\n            </p>\n          </div>\n        </div>\n        <div className=\"mt-3 flex flex-wrap gap-1.5\">\n          {jobs.map((job) => {\n            const off = hidden.includes(job.id);\n            return (\n              <button\n                key={job.id}\n                type=\"button\"\n                data-job={job.id}\n                aria-pressed={!off}\n                onClick={() =>\n                  setHidden((h) =>\n                    off ? h.filter((x) => x !== job.id) : [...h, job.id],\n                  )\n                }\n                className={`flex h-7 cursor-pointer items-center gap-2 rounded-full border-0 px-3 text-[13px] leading-[20px] font-[510] tracking-[-0.011em] motion-safe:transition-opacity motion-safe:duration-150 ${RING}`}\n                style={{\n                  background: c.chip,\n                  color: c.text,\n                  opacity: off ? 0.45 : 1,\n                }}\n              >\n                <Dot size={8} color={colorOf(job)} />\n                {job.name}\n              </button>\n            );\n          })}\n        </div>\n      </div>\n\n      <div className=\"grid gap-x-6 @2xl:grid-cols-[minmax(0,1.5fr)_minmax(0,1fr)]\">\n        <div className=\"min-w-0 px-4 pb-4 @2xl:pr-0 @2xl:pl-5\">\n          <div\n            className=\"grid gap-1\"\n            style={{ gridTemplateColumns: \"repeat(7, minmax(0, 1fr))\" }}\n          >\n            {WEEKDAYS.map((d) => (\n              <span\n                key={d}\n                className=\"py-1 text-center text-[11.5px] leading-[16px] tracking-[-0.005em]\"\n                style={{ color: c.faint }}\n              >\n                {d}\n              </span>\n            ))}\n            {Array.from({ length: offset }, (_, i) => (\n              <span key={`pad-${i}`} aria-hidden=\"true\" />\n            ))}\n            {dates.map((date) => {\n              const runs = runsOn(date);\n              const on = date === selected;\n              const bad = runs.some((j) => j.failedOn?.includes(date));\n              return (\n                <button\n                  key={date}\n                  type=\"button\"\n                  data-day={date}\n                  aria-pressed={on}\n                  aria-label={`${MONTHS[month]} ${date}, ${runs.length} runs`}\n                  onClick={() => select(date)}\n                  className={`flex cursor-pointer flex-col items-center justify-center gap-1 rounded-lg border p-0 motion-safe:transition-colors motion-safe:duration-150 ${RING}`}\n                  style={{\n                    height: 46,\n                    background: on ? c.picked : c.cell,\n                    borderColor: on\n                      ? ACCENT\n                      : date === today\n                        ? c.faint\n                        : \"transparent\",\n                  }}\n                >\n                  <span\n                    className=\"text-[12.5px] leading-[16px] font-[510] tabular-nums\"\n                    style={{ color: date < today ? c.sub : c.text }}\n                  >\n                    {date}\n                  </span>\n                  <span className=\"flex gap-[3px]\" style={{ height: 5 }}>\n                    {runs.map((job) => (\n                      <Dot\n                        key={job.id}\n                        size={5}\n                        color={\n                          bad && job.failedOn?.includes(date)\n                            ? RED\n                            : colorOf(job)\n                        }\n                      />\n                    ))}\n                  </span>\n                </button>\n              );\n            })}\n          </div>\n        </div>\n\n        {/* Every day shares one cell, so picking a date never changes the card's height. */}\n        <div\n          className=\"grid border-t p-5 @2xl:border-t-0 @2xl:border-l @2xl:pt-1\"\n          style={{\n            borderColor: c.border,\n            gridTemplateColumns: \"minmax(0, 1fr)\",\n          }}\n        >\n          {dates.map((date) => {\n            const on = date === selected;\n            const runs = runsOn(date);\n            return (\n              <div\n                key={date}\n                aria-hidden={!on}\n                className={`min-w-0 [grid-area:1/1] ${on ? \"visible\" : \"invisible\"}`}\n              >\n                <p className=\"m-0 text-[15px] leading-[22px] font-[590] tracking-[-0.012em]\">\n                  {MONTHS[month]} {date}\n                </p>\n                <p\n                  className=\"m-0 text-[12.5px] leading-[18px] tracking-[-0.008em] tabular-nums\"\n                  style={{ color: c.faint }}\n                >\n                  {runs.length\n                    ? `${runs.length} ${runs.length === 1 ? \"run\" : \"runs\"}`\n                    : \"Nothing scheduled\"}\n                </p>\n                <ul\n                  className=\"m-0 mt-3 list-none p-0\"\n                  style={{ minHeight: jobs.length * 54 }}\n                >\n                  {runs.map((job) => {\n                    const state = stateOf(job, date);\n                    return (\n                      <li\n                        key={job.id}\n                        className=\"flex items-center gap-2.5 border-t py-2\"\n                        style={{ borderColor: c.border, height: 54 }}\n                      >\n                        <Dot size={8} color={colorOf(job)} />\n                        <span className=\"min-w-0 flex-1\">\n                          <span className=\"block truncate text-[13px] leading-[20px] font-[510] tracking-[-0.011em]\">\n                            {job.name}\n                          </span>\n                          <span\n                            className=\"block truncate text-[12px] leading-[16px] tracking-[-0.005em]\"\n                            style={{ color: c.faint }}\n                          >\n                            {job.time}, {job.schedule.toLowerCase()}\n                          </span>\n                        </span>\n                        <span\n                          className=\"shrink-0 text-[12.5px] leading-[18px] tracking-[-0.008em]\"\n                          style={{ color: state.color }}\n                        >\n                          {state.label}\n                        </span>\n                      </li>\n                    );\n                  })}\n                </ul>\n              </div>\n            );\n          })}\n        </div>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}