Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
110 lines
3.6 KiB
TypeScript
110 lines
3.6 KiB
TypeScript
"use client";
|
|
|
|
import * as React from "react";
|
|
import type { CalendarEntry } from "@/lib/calendar";
|
|
import { cn } from "@/lib/utils";
|
|
import {
|
|
ENTRY_DRAG_TYPE,
|
|
type CalendarDay,
|
|
type CalendarView,
|
|
} from "@/components/calendar/calendar-month";
|
|
import { CalendarEntryPill } from "@/components/calendar/CalendarEntryPill";
|
|
|
|
const MS_PER_DAY = 86_400_000;
|
|
|
|
export interface CalendarDayCellProps {
|
|
day: CalendarDay;
|
|
view: CalendarView;
|
|
entries: readonly CalendarEntry[];
|
|
onSelect: (entry: CalendarEntry) => void;
|
|
/** Id of the entry currently being moved by drag-drop (spinner, no drop target feedback). */
|
|
movingId?: string | null;
|
|
/** Drop a dragged entry (by id) onto this day; a no-op prop leaves the cell non-interactive for drops. */
|
|
onDropOnDay?: (id: string, day: Date) => void;
|
|
}
|
|
|
|
/**
|
|
* One day cell in the grid: the day number (today highlighted, out-of-month days
|
|
* dimmed in the month view) plus the day's colour-coded entry pills. In the week
|
|
* view cells are taller so every entry is shown; in the month view a tall day is
|
|
* capped with a "+N more" hint to keep the grid compact.
|
|
*/
|
|
export function CalendarDayCell({
|
|
day,
|
|
view,
|
|
entries,
|
|
onSelect,
|
|
movingId = null,
|
|
onDropOnDay,
|
|
}: Readonly<CalendarDayCellProps>) {
|
|
const [over, setOver] = React.useState(false);
|
|
const isWeek = view === "week";
|
|
const cap = isWeek ? entries.length : 3;
|
|
const shown = entries.slice(0, cap);
|
|
const overflow = entries.length - shown.length;
|
|
// A drop that would land a publish in the past is refused server-side anyway
|
|
// (rescheduleEntry rejects a non-future time), so block it at the UI layer too.
|
|
const past = day.date.getTime() + MS_PER_DAY <= Date.now();
|
|
const canDrop = Boolean(onDropOnDay) && !past;
|
|
|
|
return (
|
|
<div
|
|
onDragOver={(e) => {
|
|
if (!canDrop || !e.dataTransfer.types.includes(ENTRY_DRAG_TYPE)) return;
|
|
e.preventDefault();
|
|
e.dataTransfer.dropEffect = "move";
|
|
if (!over) setOver(true);
|
|
}}
|
|
onDragLeave={() => setOver(false)}
|
|
onDrop={(e) => {
|
|
setOver(false);
|
|
if (!canDrop) return;
|
|
const id = e.dataTransfer.getData(ENTRY_DRAG_TYPE);
|
|
if (!id) return;
|
|
e.preventDefault();
|
|
onDropOnDay?.(id, day.date);
|
|
}}
|
|
className={cn(
|
|
"flex flex-col gap-1 border-b border-r border-border p-1.5 transition-colors",
|
|
isWeek ? "min-h-[14rem]" : "min-h-[6.5rem]",
|
|
!day.inCurrentMonth && "bg-muted/30 text-muted-foreground",
|
|
past && "bg-muted/20",
|
|
over && "bg-primary/10 ring-2 ring-inset ring-primary/50",
|
|
)}
|
|
>
|
|
<div className="flex items-center justify-between px-0.5">
|
|
<span
|
|
className={cn(
|
|
"inline-flex size-6 items-center justify-center rounded-full text-xs font-medium",
|
|
day.isToday && "bg-primary text-primary-foreground",
|
|
!day.isToday && !day.inCurrentMonth && "text-muted-foreground",
|
|
)}
|
|
>
|
|
{day.date.getDate()}
|
|
</span>
|
|
{entries.length > 0 && (
|
|
<span className="text-[10px] tabular-nums text-muted-foreground">
|
|
{entries.length}
|
|
</span>
|
|
)}
|
|
</div>
|
|
|
|
<div className="flex flex-col gap-1">
|
|
{shown.map((entry) => (
|
|
<CalendarEntryPill
|
|
key={entry.id}
|
|
entry={entry}
|
|
onSelect={onSelect}
|
|
moving={movingId === entry.id}
|
|
/>
|
|
))}
|
|
{overflow > 0 && (
|
|
<span className="px-1.5 text-[10px] font-medium text-muted-foreground">
|
|
+{overflow} more
|
|
</span>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|