Emit static fallback tokens for forced-colors mode
Map semantic border and focus-ring variables to system color keywords when Windows High Contrast is active.
Interactive four-lane sprint board with pointer drag-and-drop, keyboard and menu column movement, search and priority/assignee filters, quick-add task dialog, task detail drawer, and toast feedback.
Nov 25 – Dec 8
Map semantic border and focus-ring variables to system color keywords when Windows High Contrast is active.
Bundle the layer-ordering plugin and dev source-map bridge into a single export so starter apps need one line.
Keep Select and Menu surfaces inside the visual viewport when opened near container scroll edges on Safari and Chrome.
Ensure disabled controls remain discoverable via arrow keys while Home and End jump cleanly across grouped separators.
Derive inner control corners from parent panel radii minus padding so nested surfaces keep uniform optical spacing.
Enforce minimum APCA Lc 60 foreground contrast across all 22 semantic color palettes under user contrast slider shifts.
Eliminate runtime style-map cloning on re-render and keep unused variant axes strippable during production bundling.
1npx stylexblocks add kanban-board123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838import * as stylex from "@stylexjs/stylex";import { useCallback, useEffect, useMemo, useRef, useState, type KeyboardEvent as ReactKeyboardEvent, type PointerEvent as ReactPointerEvent, type ReactNode,} from "react";import { Avatar } from "#components/ui/ui-sdk/avatar.tsx";import { Badge } from "#components/ui/ui-sdk/badge.tsx";import { Button } from "#components/ui/ui-sdk/button.tsx";import { Card } from "#components/ui/ui-sdk/card.tsx";import { Square } from "#components/ui/ui-sdk/center.tsx";import { Checkbox } from "#components/ui/ui-sdk/checkbox.tsx";import { Dialog } from "#components/ui/ui-sdk/dialog.tsx";import { Drawer } from "#components/ui/ui-sdk/drawer.tsx";import { EmptyState } from "#components/ui/ui-sdk/empty-state.tsx";import { Field } from "#components/ui/ui-sdk/field.tsx";import { Grid } from "#components/ui/ui-sdk/grid.tsx";import { Heading } from "#components/ui/ui-sdk/heading.tsx";import { Icon } from "#components/ui/ui-sdk/icon.tsx";import { IconButton } from "#components/ui/ui-sdk/icon-button.tsx";import { Input } from "#components/ui/ui-sdk/input.tsx";import { Menu } from "#components/ui/ui-sdk/menu.tsx";import { Select } from "#components/ui/ui-sdk/select.tsx";import { Separator } from "#components/ui/ui-sdk/separator.tsx";import { HStack, Stack, VStack } from "#components/ui/ui-sdk/stack.tsx";import { Status } from "#components/ui/ui-sdk/status.tsx";import { Text } from "#components/ui/ui-sdk/text.tsx";import { Textarea } from "#components/ui/ui-sdk/textarea.tsx";import { Toast, Toaster } from "#components/ui/ui-sdk/toast.tsx";import { Tooltip } from "#components/ui/ui-sdk/tooltip.tsx";import type { colorPalette } from "@stylexblocks/ui/color-palette.stylex.ts";import { semanticColors } from "@stylexblocks/ui/semantic-tokens/colors.stylex.ts";import { semanticRadii } from "@stylexblocks/ui/semantic-tokens/radii.stylex.ts";import { semanticShadows } from "@stylexblocks/ui/semantic-tokens/shadows.stylex.ts";import { accentPalette, amberPalette, bluePalette, emeraldPalette, grayPalette, greenPalette, indigoPalette, redPalette, tealPalette, violetPalette,} from "@stylexblocks/ui/themes/palettes.ts";import { durations } from "@stylexblocks/ui/tokens/durations.stylex.ts";import { fonts } from "@stylexblocks/ui/tokens/fonts.stylex.ts";import { lineHeights } from "@stylexblocks/ui/tokens/line-heights.stylex.ts";import { radii } from "@stylexblocks/ui/tokens/radii.stylex.ts";import { sizes } from "@stylexblocks/ui/tokens/sizes.stylex.ts";import { spacing } from "@stylexblocks/ui/tokens/spacing.stylex.ts";import { zIndices } from "@stylexblocks/ui/tokens/z-indices.stylex.ts";import type { StyleOverrideProps } from "#lib/recipe-props.ts";
// ============= TYPES =============
export type KanbanColumnId = "backlog" | "in-progress" | "review" | "shipped";export type KanbanPriority = "high" | "medium" | "low";export type KanbanSortOrder = "manual" | "priority" | "due" | "key";
export interface KanbanAssignee { id: string; name: string; role: string; initials: string; palette: stylex.Theme<typeof colorPalette>;}
export interface KanbanChecklistItem { id: string; label: string; done: boolean;}
export interface KanbanTask { id: string; key: string; sprintId: string; column: KanbanColumnId; priority: KanbanPriority; title: string; description: string; assigneeId: string; labels: string[]; dueDate: string; dueSortKey: number; updatedAt: string; checklist: KanbanChecklistItem[];}
export interface KanbanSprint { id: string; label: string; window: string;}
export interface KanbanBoardProps extends StyleOverrideProps { /** Primary board heading shown in the header bar. */ title?: string; /** Optional subtitle displayed beside or beneath the board title. */ subtitle?: string; /** Initial tasks populating the board. */ initialItems?: KanbanTask[]; /** Available sprints selectable from the top bar. */ sprints?: KanbanSprint[]; /** Team members available for assignment and filtering. */ assignees?: KanbanAssignee[]; /** Active user ID used by the "Assign to me" quick action. */ currentUserId?: string; /** Called whenever the task list changes (move, reorder, create, edit, delete). */ onItemsChange?: (items: KanbanTask[]) => void;}
interface ColumnMeta { id: KanbanColumnId; title: string; palette: stylex.Theme<typeof colorPalette>; tooltip: string; emptyTitle: string; emptyDescription: string;}
interface DropTarget { column: KanbanColumnId; index: number;}
interface DragState { id: string; width: number; height: number; offsetX: number; offsetY: number; pointerX: number; pointerY: number; target: DropTarget | null;}
// ============= CONSTANTS & DEMO DATA =============
const COLUMNS: readonly ColumnMeta[] = [ { id: "backlog", title: "Backlog", palette: grayPalette, tooltip: "Scoped engine tasks ready to be pulled into the active release.", emptyTitle: "Backlog is clear", emptyDescription: "New release work and scoped tickets appear here.", }, { id: "in-progress", title: "In Progress", palette: accentPalette, tooltip: "Active engineering and design-token work underway right now.", emptyTitle: "Nothing in progress", emptyDescription: "Drag a card here or add a task to start active work.", }, { id: "review", title: "Review", palette: amberPalette, tooltip: "Pull requests awaiting accessibility, visual, or API sign-off.", emptyTitle: "Review queue is empty", emptyDescription: "Items ready for peer or a11y review land in this lane.", }, { id: "shipped", title: "Shipped", palette: greenPalette, tooltip: "Merged, tested, and verified for Release 2.4.", emptyTitle: "Nothing shipped yet", emptyDescription: "Completed tasks verified in canary appear here.", },];
const PRIORITY_META: Record< KanbanPriority, { label: string; rank: number; palette: stylex.Theme<typeof colorPalette> }> = { high: { label: "High", rank: 0, palette: redPalette }, medium: { label: "Medium", rank: 1, palette: amberPalette }, low: { label: "Low", rank: 2, palette: tealPalette },};
const SORT_OPTIONS: ReadonlyArray<{ value: KanbanSortOrder; label: string }> = [ { value: "manual", label: "Manual order" }, { value: "priority", label: "Priority (High first)" }, { value: "due", label: "Due date (Soonest)" }, { value: "key", label: "Issue key (DS-201)" },];
const PRIORITY_FILTER_ITEMS = [ { value: "all", label: "All priorities" }, { value: "high", label: "High priority" }, { value: "medium", label: "Medium priority" }, { value: "low", label: "Low priority" },] as const;
const COLUMN_SELECT_ITEMS = COLUMNS.map((c) => ({ value: c.id, label: c.title,})) as ReadonlyArray<{ value: KanbanColumnId; label: string }>;
const PRIORITY_SELECT_ITEMS = [ { value: "high", label: "High" }, { value: "medium", label: "Medium" }, { value: "low", label: "Low" },] as const;
const DEFAULT_SPRINTS: KanbanSprint[] = [ { id: "r24-s14", label: "Sprint 14 · Active", window: "Nov 25 – Dec 8" }, { id: "r24-s13", label: "Sprint 13 · Previous", window: "Nov 11 – Nov 24" }, { id: "r23-s12", label: "Sprint 12 · Archive", window: "Oct 28 – Nov 10" },];
const DEFAULT_ASSIGNEES: KanbanAssignee[] = [ { id: "nina", name: "Nina Okafor", role: "Staff Systems Engineer", initials: "NO", palette: indigoPalette, }, { id: "tomas", name: "Tomas Lindholm", role: "Accessibility Lead", initials: "TL", palette: tealPalette, }, { id: "priya", name: "Priya Subramanian", role: "Runtime Compiler Eng", initials: "PS", palette: violetPalette, }, { id: "diego", name: "Diego Morales", role: "Interaction Designer", initials: "DM", palette: bluePalette, }, { id: "hana", name: "Hana Takahashi", role: "Design Token Architect", initials: "HT", palette: emeraldPalette, },];
const DEFAULT_ITEMS: KanbanTask[] = [ { id: "task-ds-206", key: "DS-206", sprintId: "r24-s14", column: "backlog", priority: "medium", title: "Emit static fallback tokens for forced-colors mode", description: "Map semantic border and focus-ring variables to system color keywords when Windows High Contrast is active.", assigneeId: "hana", labels: ["Tokens", "A11y"], dueDate: "Dec 9", dueSortKey: 20261209, updatedAt: "3h ago", checklist: [ { id: "c-206-1", label: "Audit focus-ring contrast in forced-colors media query", done: true }, { id: "c-206-2", label: "Add snapshot tests for Button, Input, and Select", done: false }, { id: "c-206-3", label: "Document token overrides in theming guide", done: false }, ], }, { id: "task-ds-208", key: "DS-208", sprintId: "r24-s14", column: "backlog", priority: "low", title: "Publish zero-config Vite preset for atomic CSS layers", description: "Bundle the layer-ordering plugin and dev source-map bridge into a single export so starter apps need one line.", assigneeId: "priya", labels: ["Build", "DX"], dueDate: "Dec 11", dueSortKey: 20261211, updatedAt: "1d ago", checklist: [ { id: "c-208-1", label: "Validate HMR reload speed on 200+ style sheets", done: false }, { id: "c-208-2", label: "Verify SSR stylesheet extraction order", done: false }, ], }, { id: "task-ds-201", key: "DS-201", sprintId: "r24-s14", column: "in-progress", priority: "high", title: "Anchor-positioned popover collision flips in top layer", description: "Keep Select and Menu surfaces inside the visual viewport when opened near container scroll edges on Safari and Chrome.", assigneeId: "nina", labels: ["Overlays", "Engine"], dueDate: "Dec 3", dueSortKey: 20261203, updatedAt: "14m ago", checklist: [ { id: "c-201-1", label: "Measure available block height against visualViewport", done: true }, { id: "c-201-2", label: "Handle RTL inline-start flip transitions cleanly", done: true }, { id: "c-201-3", label: "Add Playwright edge-collision regression suite", done: false }, ], }, { id: "task-ds-204", key: "DS-204", sprintId: "r24-s14", column: "in-progress", priority: "medium", title: "Roving tabindex polish for composite toolbar groups", description: "Ensure disabled controls remain discoverable via arrow keys while Home and End jump cleanly across grouped separators.", assigneeId: "tomas", labels: ["A11y", "Keyboard"], dueDate: "Dec 5", dueSortKey: 20261205, updatedAt: "42m ago", checklist: [ { id: "c-204-1", label: "Verify VoiceOver and NVDA group announcements", done: true }, { id: "c-204-2", label: "Sync roving index when items mount dynamically", done: false }, ], }, { id: "task-ds-203", key: "DS-203", sprintId: "r24-s14", column: "review", priority: "high", title: "Concentric radius tokens for nested cards and drawers", description: "Derive inner control corners from parent panel radii minus padding so nested surfaces keep uniform optical spacing.", assigneeId: "diego", labels: ["Tokens", "Layout"], dueDate: "Dec 4", dueSortKey: 20261204, updatedAt: "1h ago", checklist: [ { id: "c-203-1", label: "Validate radius clamping at compact scale factor 0.85", done: true }, { id: "c-203-2", label: "Review visual diffs across Dialog, Drawer, and Card", done: true }, { id: "c-203-3", label: "Final design sign-off from platform reviewers", done: false }, ], }, { id: "task-ds-198", key: "DS-198", sprintId: "r24-s14", column: "shipped", priority: "high", title: "OKLCH palette contrast guardrails for dark theme surfaces", description: "Enforce minimum APCA Lc 60 foreground contrast across all 22 semantic color palettes under user contrast slider shifts.", assigneeId: "hana", labels: ["Color", "Tokens"], dueDate: "Dec 1", dueSortKey: 20261201, updatedAt: "Yesterday", checklist: [ { id: "c-198-1", label: "Run automated contrast matrix across 22 palettes", done: true }, { id: "c-198-2", label: "Ship updated semantic color vars in @stylexblocks/ui", done: true }, ], }, { id: "task-ds-199", key: "DS-199", sprintId: "r24-s14", column: "shipped", priority: "low", title: "Tree-shakeable slot recipe context helper", description: "Eliminate runtime style-map cloning on re-render and keep unused variant axes strippable during production bundling.", assigneeId: "priya", labels: ["Performance", "Engine"], dueDate: "Nov 29", dueSortKey: 20261129, updatedAt: "2d ago", checklist: [ { id: "c-199-1", label: "Benchmark 1,000-row table cell render latency", done: true }, { id: "c-199-2", label: "Confirm 14% gzip reduction on UI SDK entry chunk", done: true }, ], }, // Sprint 13 items so switching sprints shows realistic historical data { id: "task-ds-191", key: "DS-191", sprintId: "r24-s13", column: "review", priority: "medium", title: "Swipe-to-dismiss spring damping on mobile drawers", description: "Tune velocity threshold and backdrop opacity interpolation when dismissing side sheets on touch viewports.", assigneeId: "diego", labels: ["Motion", "Overlays"], dueDate: "Nov 24", dueSortKey: 20261124, updatedAt: "6d ago", checklist: [ { id: "c-191-1", label: "Respect prefers-reduced-motion spring fallback", done: true }, { id: "c-191-2", label: "Test rubber-banding on iOS Safari 18", done: false }, ], }, { id: "task-ds-187", key: "DS-187", sprintId: "r24-s13", column: "shipped", priority: "high", title: "Zero-layout-shift Toast region stacking queue", description: "Stabilize vertical toast heights with GPU translate animations and pause auto-dismiss timers while hovered or focused.", assigneeId: "nina", labels: ["Feedback", "Engine"], dueDate: "Nov 21", dueSortKey: 20261121, updatedAt: "1w ago", checklist: [ { id: "c-187-1", label: "Verify polite live-region announcements", done: true }, { id: "c-187-2", label: "Add keyboard Escape dismissal for active region", done: true }, ], }, { id: "task-ds-189", key: "DS-189", sprintId: "r24-s13", column: "shipped", priority: "low", title: "Numeric tabular alignment for stat cards and badges", description: "Apply font-variant-numeric tabular-nums across count badges, KPI deltas, and progress indicators to prevent jitter.", assigneeId: "tomas", labels: ["Typography"], dueDate: "Nov 22", dueSortKey: 20261122, updatedAt: "1w ago", checklist: [ { id: "c-189-1", label: "Audit Badge, Stat, and Pagination counters", done: true }, ], }, // Sprint 12 archive item { id: "task-ds-176", key: "DS-176", sprintId: "r23-s12", column: "shipped", priority: "medium", title: "Baseline typography scale tokens for UI SDK v2.3", description: "Standardize heading and body line-height pairings with optical tracking tokens across all 11 heading steps.", assigneeId: "hana", labels: ["Typography", "Tokens"], dueDate: "Nov 8", dueSortKey: 20261108, updatedAt: "3w ago", checklist: [ { id: "c-176-1", label: "Verify baseline grid alignment across all sizes", done: true }, ], },];
const DRAG_THRESHOLD = 5;const LONG_PRESS_MS = 280;const LONG_PRESS_SLOP = 8;const SIDE_BY_SIDE = "@media (min-width: 768px)";
function parseKeyNumber(key: string): number { const match = /\d+/.exec(key); return match ? Number.parseInt(match[0], 10) : 0;}
function getColumnTitle(columnId: KanbanColumnId): string { return COLUMNS.find((col) => col.id === columnId)?.title ?? columnId;}
function getFirstName(fullName: string): string { return fullName.split(" ")[0] ?? fullName;}
// ============= INLINE SVG ICONS =============
function PlusIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" aria-hidden="true" > <path d="M10 4.5v11" /> <path d="M4.5 10h11" /> </Icon> );}
function SearchIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <circle cx="9" cy="9" r="5.5" /> <path d="m13.2 13.2 3.3 3.3" /> </Icon> );}
function CloseIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" aria-hidden="true" > <path d="m5.5 5.5 9 9" /> <path d="m14.5 5.5-9 9" /> </Icon> );}
function SortIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M7 4.5v11" /> <path d="m4.5 7 2.5-2.5L9.5 7" /> <path d="M13 15.5v-11" /> <path d="m10.5 13 2.5 2.5 2.5-2.5" /> </Icon> );}
function MoreHorizontalIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" > <circle cx="5" cy="10" r="1.4" /> <circle cx="10" cy="10" r="1.4" /> <circle cx="15" cy="10" r="1.4" /> </Icon> );}
function InfoCircleIcon() { return ( <Icon size="xs" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <circle cx="8" cy="8" r="6" /> <path d="M8 7.2v3.6" /> <path d="M8 5.1h.01" /> </Icon> );}
function ChecklistSmallIcon() { return ( <Icon size="xs" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <rect x="2.5" y="2.5" width="11" height="11" rx="2" /> <path d="m5.5 8 1.8 1.8 3.2-3.6" /> </Icon> );}
function CalendarSmallIcon() { return ( <Icon size="xs" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <rect x="2.2" y="3.2" width="11.6" height="10.6" rx="2" /> <path d="M5.2 1.8v2.6" /> <path d="M10.8 1.8v2.6" /> <path d="M2.2 6.5h11.6" /> </Icon> );}
function ColumnEmptyIcon({ columnId }: { columnId: KanbanColumnId }) { if (columnId === "backlog") { return ( <Icon size="lg" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M4 13V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v7" /> <path d="M4 13h4.5l1.5 2.5h4l1.5-2.5H20v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-5Z" /> </Icon> ); } if (columnId === "in-progress") { return ( <Icon size="lg" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M20 12a8 8 0 0 1-13.66 5.66" /> <path d="M4 12a8 8 0 0 1 13.66-5.66" /> <path d="M17.5 3.5v3.5H14" /> <path d="M6.5 20.5V17H10" /> </Icon> ); } if (columnId === "review") { return ( <Icon size="lg" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <rect x="4" y="4" width="16" height="16" rx="2.5" /> <path d="m8.5 12 2.2 2.2 4.8-5" /> </Icon> ); } return ( <Icon size="lg" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <circle cx="12" cy="12" r="8.5" /> <path d="m8.5 12.2 2.3 2.3 4.8-5.1" /> </Icon> );}
// ============= STYLES =============
const styles = stylex.create({ root: { backgroundColor: semanticColors.bg, color: semanticColors.fg, fontFamily: fonts.body, height: "100%", minHeight: "100%", overflowX: "hidden", overflowY: "hidden", width: "100%", }, header: { backgroundColor: semanticColors.bgPanel, borderBottomColor: semanticColors.border, borderBottomStyle: "solid", borderBottomWidth: "1px", flexShrink: 0, paddingBlock: spacing._3_5, paddingInline: spacing._4, }, titleHeading: { marginBlock: 0, }, sprintSelect: { width: "12.5rem", }, headerDivider: { height: sizes._5, }, filterControls: { flexBasis: "auto", flexGrow: 1, flexShrink: 1, }, searchWrap: { flexBasis: "14rem", flexGrow: 1, flexShrink: 1, maxWidth: "22rem", minWidth: "12rem", position: "relative", }, searchIconSlot: { alignItems: "center", color: semanticColors.fgMuted, display: "inline-flex", insetBlockStart: "50%", insetInlineStart: spacing._2_5, pointerEvents: "none", position: "absolute", transform: "translateY(-50%)", zIndex: zIndices.layer1, }, searchInput: { paddingInlineEnd: spacing._8, paddingInlineStart: spacing._8, }, searchClearBtn: { insetBlockStart: "50%", insetInlineEnd: spacing._1, position: "absolute", transform: "translateY(-50%)", }, filterSelect: { width: "9.5rem", }, assigneeSelect: { width: "10.5rem", }, keyboardHint: { display: { default: "none", "@media (min-width: 1024px)": "inline" }, }, boardMain: { flexBasis: 0, flexGrow: 1, flexShrink: 1, minHeight: 0, overflowX: "hidden", overflowY: "hidden", }, boardColumns: { flexBasis: 0, flexDirection: { default: "column", [SIDE_BY_SIDE]: "row" }, flexGrow: 1, flexShrink: 1, gap: spacing._3_5, height: "100%", minHeight: 0, overflowX: { default: "hidden", [SIDE_BY_SIDE]: "auto" }, overflowY: { default: "auto", [SIDE_BY_SIDE]: "hidden" }, paddingBlock: spacing._4, paddingInline: spacing._4, }, columnShell: { backgroundColor: semanticColors.bgMuted, borderColor: semanticColors.borderSubtle, borderStyle: "solid", borderWidth: "1px", flexBasis: { default: "auto", [SIDE_BY_SIDE]: "19rem" }, flexGrow: { default: 0, [SIDE_BY_SIDE]: 1 }, flexShrink: 0, height: { default: "auto", [SIDE_BY_SIDE]: "100%" }, maxWidth: { default: "100%", [SIDE_BY_SIDE]: "24rem" }, minHeight: 0, minWidth: { default: "100%", [SIDE_BY_SIDE]: "17.5rem" }, overflowX: "hidden", overflowY: "hidden", transitionDuration: durations.fast, transitionProperty: "border-color, background-color", }, columnShellDropTarget: { borderColor: semanticColors.accentBorder, backgroundColor: semanticColors.bgInset, }, columnHeader: { flexShrink: 0, paddingBlock: spacing._2_5, paddingInline: spacing._3, }, columnHeading: { marginBlock: 0, }, infoTrigger: { alignItems: "center", appearance: "none", backgroundColor: "transparent", borderRadius: radii.full, borderStyle: "none", borderWidth: 0, color: { default: semanticColors.fgSubtle, ":hover": semanticColors.fg, }, cursor: "pointer", display: "inline-flex", height: sizes._5, justifyContent: "center", paddingBlock: 0, paddingInline: 0, width: sizes._5, }, columnCount: { paddingInline: spacing._1, }, columnBody: { flexBasis: 0, flexGrow: 1, flexShrink: 1, minHeight: "6rem", overflowX: "hidden", overflowY: { default: "visible", [SIDE_BY_SIDE]: "auto" }, paddingBlock: spacing._2_5, paddingInline: spacing._2_5, }, columnEmpty: { paddingBlock: spacing._8, paddingInline: spacing._3, }, columnEmptyIndicator: { color: semanticColors.fgSubtle, }, card: { borderStyle: "solid", boxShadow: { default: semanticShadows.xs, ":hover": semanticShadows.md, }, cursor: "grab", outlineColor: { default: null, ":focus-visible": semanticColors.accentFocusRing, }, outlineOffset: { default: null, ":focus-visible": "2px", }, outlineStyle: { default: null, ":focus-visible": "solid", }, outlineWidth: { default: null, ":focus-visible": "2px", }, touchAction: "manipulation", transitionDuration: durations.fast, transitionProperty: "box-shadow, border-color", userSelect: "none", }, cardCarried: { display: "none", }, keyBadge: { fontFamily: fonts.mono, }, cardTitle: { marginBlock: 0, }, cardDescription: { WebkitBoxOrient: "vertical", WebkitLineClamp: 2, display: "-webkit-box", lineHeight: lineHeights.sm, overflowX: "hidden", overflowY: "hidden", }, cardFooter: { borderTopColor: semanticColors.borderMuted, borderTopStyle: "solid", borderTopWidth: "1px", paddingTop: spacing._2, }, cardMetaRight: { color: semanticColors.fgSubtle, flexShrink: 0, }, inlineFlex: { display: "inline-flex", }, floatingWrap: { insetBlockStart: 0, insetInlineStart: 0, pointerEvents: "none", position: "fixed", zIndex: zIndices.overlay, }, floatingCard: { borderStyle: "solid", boxShadow: semanticShadows.xl, cursor: "grabbing", }, floatingAt: (x: number, y: number, width: number) => ({ transform: `translate3d(${x}px, ${y}px, 0)`, width: `${width}px`, }), ghostSlot: (height: number) => ({ backgroundColor: semanticColors.bgSubtle, borderColor: semanticColors.accentBorder, borderRadius: semanticRadii.panel, borderStyle: "dashed", borderWidth: "1px", flexShrink: 0, height: `${height}px`, }), // Dialog & Drawer form layout formTwoCol: { gridTemplateColumns: { default: "1fr", "@media (min-width: 520px)": "1fr 1fr" }, }, dialogHeaderStack: { flexDirection: "column", gap: spacing._1, paddingInlineEnd: spacing._10, }, dialogTitleReset: { marginBlock: 0, }, drawerHeaderStack: { alignItems: "flex-start", flexDirection: "column", gap: spacing._2, paddingInlineEnd: spacing._10, }, drawerChecklistItem: { alignItems: "center", backgroundColor: semanticColors.bgMuted, borderRadius: semanticRadii.control, display: "flex", paddingBlock: spacing._2, paddingInline: spacing._2_5, }, checklistLabelDone: { color: semanticColors.fgSubtle, textDecoration: "line-through", }, drawerFooterSplit: { justifyContent: "space-between", width: "100%", }, fullWidth: { width: "100%", },});
// ============= CARD BODY =============
interface BoardCardBodyProps { item: KanbanTask; assignee: KanbanAssignee | undefined; isCurrentUserAssignee: boolean; onOpen: (item: KanbanTask) => void; onAssignToMe: (id: string) => void; onMove: (id: string, to: KanbanColumnId) => void; onDelete: (id: string) => void; interactive?: boolean;}
function BoardCardBody({ item, assignee, isCurrentUserAssignee, onOpen, onAssignToMe, onMove, onDelete, interactive = true,}: BoardCardBodyProps) { const priority = PRIORITY_META[item.priority]; const currentColIdx = COLUMNS.findIndex((c) => c.id === item.column); const completedCount = item.checklist.filter((c) => c.done).length;
return ( <VStack gap="2"> <HStack gap="2" align="start" justify="between"> <HStack gap="1.5" wrap="wrap"> <Badge variant="surface" size="sm" style={styles.keyBadge}> {item.key} </Badge> <Badge variant="subtle" size="sm" palette={priority.palette}> {priority.label} </Badge> </HStack>
{interactive ? ( <Menu.Root size="sm"> <Menu.Trigger render={ <IconButton variant="ghost" size="xs" aria-label={`Actions for ${item.key}`} onClick={(e) => e.stopPropagation()} /> } > <MoreHorizontalIcon /> </Menu.Trigger> <Menu.Content align="end"> <Menu.Item value="open" onSelect={() => onOpen(item)}> <Menu.ItemText>Open details</Menu.ItemText> <Menu.ItemCommand>↵</Menu.ItemCommand> </Menu.Item> <Menu.Item value="assign-me" disabled={isCurrentUserAssignee} onSelect={() => onAssignToMe(item.id)} > <Menu.ItemText> {isCurrentUserAssignee ? "Assigned to you" : "Assign to me"} </Menu.ItemText> </Menu.Item> <Menu.Separator /> <Menu.Group> <Menu.GroupLabel>Move to lane</Menu.GroupLabel> {COLUMNS.filter((c) => c.id !== item.column).map((col) => { const targetIdx = COLUMNS.findIndex((c) => c.id === col.id); const shortcut = targetIdx === currentColIdx - 1 ? "←" : targetIdx === currentColIdx + 1 ? "→" : null; return ( <Menu.Item key={col.id} value={`move-${col.id}`} onSelect={() => onMove(item.id, col.id)} > <Menu.ItemText>{col.title}</Menu.ItemText> {shortcut ? <Menu.ItemCommand>{shortcut}</Menu.ItemCommand> : null} </Menu.Item> ); })} </Menu.Group> <Menu.Separator /> <Menu.Item value="delete" destructive onSelect={() => onDelete(item.id)}> <Menu.ItemText>Delete task</Menu.ItemText> </Menu.Item> </Menu.Content> </Menu.Root> ) : ( <Square render={<span />} size="xs" aria-hidden="true"> <MoreHorizontalIcon /> </Square> )} </HStack>
<VStack gap="1"> <Heading render={<h3 />} size="sm" style={styles.cardTitle}> {item.title} </Heading> {item.description ? ( <Text size="xs" tone="muted" style={styles.cardDescription}> {item.description} </Text> ) : null} </VStack>
{item.labels.length > 0 ? ( <HStack gap="1" wrap="wrap"> {item.labels.slice(0, 3).map((label) => ( <Badge key={label} variant="outline" size="xs"> {label} </Badge> ))} </HStack> ) : null}
<HStack gap="2" justify="between" style={styles.cardFooter}> <HStack gap="1.5"> {assignee ? ( <> <Avatar.Root size="xs" variant="subtle" palette={assignee.palette}> <Avatar.Fallback>{assignee.initials}</Avatar.Fallback> </Avatar.Root> <Text render={<span />} size="xs" tone="muted" truncate="true"> {getFirstName(assignee.name)} </Text> </> ) : ( <Text render={<span />} size="xs" tone="muted" truncate="true"> Unassigned </Text> )} </HStack>
<HStack gap="2" style={styles.cardMetaRight}> {item.checklist.length > 0 ? ( <HStack render={<span />} gap="1" style={styles.inlineFlex} title={`${completedCount} of ${item.checklist.length} checklist items complete`} > <ChecklistSmallIcon /> <Text render={<span />} size="xs" tone="subtle" tabular="true"> {completedCount}/{item.checklist.length} </Text> </HStack> ) : null} <HStack render={<span />} gap="1" style={styles.inlineFlex}> <CalendarSmallIcon /> <Text render={<span />} size="xs" tone="subtle" tabular="true"> {item.dueDate} </Text> </HStack> </HStack> </HStack> </VStack> );}
// ============= BOARD CARD =============
interface BoardCardProps { item: KanbanTask; assignee: KanbanAssignee | undefined; isCurrentUserAssignee: boolean; cardRef: (el: HTMLDivElement | null) => void; onPointerDown: (e: ReactPointerEvent<HTMLDivElement>, id: string) => void; onCardClick: (item: KanbanTask) => void; onCardKeyDown: (e: ReactKeyboardEvent<HTMLDivElement>, item: KanbanTask) => void; onAssignToMe: (id: string) => void; onMove: (id: string, to: KanbanColumnId) => void; onDelete: (id: string) => void; isCarried?: boolean;}
function BoardCard({ item, assignee, isCurrentUserAssignee, cardRef, onPointerDown, onCardClick, onCardKeyDown, onAssignToMe, onMove, onDelete, isCarried = false,}: BoardCardProps) { const priorityLabel = PRIORITY_META[item.priority].label; const colTitle = getColumnTitle(item.column);
return ( <Card.Root ref={cardRef} variant="outline" size="sm" role="article" tabIndex={isCarried ? -1 : 0} aria-label={`${item.key}: ${item.title}. ${colTitle}, ${priorityLabel} priority. Press Enter to open details, or Left and Right arrow keys to move columns.`} style={[styles.card, isCarried && styles.cardCarried]} onPointerDown={(e) => onPointerDown(e, item.id)} onClick={() => onCardClick(item)} onKeyDown={(e) => onCardKeyDown(e, item)} > <Card.Body> <BoardCardBody item={item} assignee={assignee} isCurrentUserAssignee={isCurrentUserAssignee} onOpen={onCardClick} onAssignToMe={onAssignToMe} onMove={onMove} onDelete={onDelete} /> </Card.Body> </Card.Root> );}
// ============= BOARD COLUMN =============
interface BoardColumnProps { meta: ColumnMeta; count: number; isDropTarget: boolean; isEmpty: boolean; isFiltered: boolean; contentRef: (el: HTMLDivElement | null) => void; onQuickAdd: (columnId: KanbanColumnId) => void; children: ReactNode;}
function BoardColumn({ meta, count, isDropTarget, isEmpty, isFiltered, contentRef, onQuickAdd, children,}: BoardColumnProps) { return ( <VStack render={<section />} gap="0" aria-label={`${meta.title} column, ${count} ${count === 1 ? "task" : "tasks"}`} style={[styles.columnShell, isDropTarget && styles.columnShellDropTarget]} > <HStack gap="2" justify="between" style={styles.columnHeader}> <HStack gap="2"> <Status.Root size="md" palette={meta.palette}> <Status.Indicator aria-hidden="true" /> </Status.Root> <Heading render={<h2 />} size="sm" style={styles.columnHeading}> {meta.title} </Heading> <Tooltip.Root variant="inverted" delay={180} closeDelay={80}> <Tooltip.Trigger render={ <button type="button" aria-label={`About ${meta.title}`} {...stylex.props(styles.infoTrigger)} /> } > <InfoCircleIcon /> </Tooltip.Trigger> <Tooltip.Content sideOffset={6}> <Tooltip.Arrow /> {meta.tooltip} </Tooltip.Content> </Tooltip.Root> </HStack>
<HStack gap="1"> <Text render={<span />} size="xs" weight="medium" tone="muted" tabular="true" style={styles.columnCount} > {count} </Text> <IconButton variant="ghost" size="xs" aria-label={`Add task to ${meta.title}`} onClick={() => onQuickAdd(meta.id)} > <PlusIcon /> </IconButton> </HStack> </HStack>
<Separator orientation="horizontal" size="sm" decorative />
<VStack ref={contentRef} gap="2.5" style={styles.columnBody}> {isEmpty ? ( <EmptyState.Root size="sm" align="center" style={styles.columnEmpty}> <EmptyState.Content> <EmptyState.Indicator style={styles.columnEmptyIndicator}> <ColumnEmptyIcon columnId={meta.id} /> </EmptyState.Indicator> <EmptyState.Title> {isFiltered ? `No matches in ${meta.title}` : meta.emptyTitle} </EmptyState.Title> <EmptyState.Description> {isFiltered ? "Adjust search or filters to see hidden tasks." : meta.emptyDescription} </EmptyState.Description> </EmptyState.Content> </EmptyState.Root> ) : null} {children} </VStack> </VStack> );}
// ============= MAIN COMPONENT =============
/** * KanbanBoard — interactive sprint board with pointer drag-and-drop (including * touch long-press), keyboard and menu column movement, search/filter/sort * controls, quick-add task dialog, task detail drawer, and toast feedback. */export function KanbanBoard({ title = "Release 2.4 · Component Engine", subtitle, initialItems = DEFAULT_ITEMS, sprints = DEFAULT_SPRINTS, assignees = DEFAULT_ASSIGNEES, currentUserId = "nina", onItemsChange, palette, style,}: KanbanBoardProps) { const queue = useMemo(() => Toast.createToaster(), []);
const [items, setItems] = useState<KanbanTask[]>(initialItems); const [activeSprintId, setActiveSprintId] = useState<string>(sprints[0]?.id ?? "r24-s14"); const [search, setSearch] = useState(""); const [priorityFilter, setPriorityFilter] = useState<"all" | KanbanPriority>("all"); const [assigneeFilter, setAssigneeFilter] = useState<string>("all"); const [sortOrder, setSortOrder] = useState<KanbanSortOrder>("manual"); const [drag, setDrag] = useState<DragState | null>(null);
// Quick-add dialog state const [addOpen, setAddOpen] = useState(false); const [draftTitle, setDraftTitle] = useState(""); const [draftDescription, setDraftDescription] = useState(""); const [draftColumn, setDraftColumn] = useState<KanbanColumnId>("backlog"); const [draftPriority, setDraftPriority] = useState<KanbanPriority>("medium"); const [draftAssigneeId, setDraftAssigneeId] = useState<string>( currentUserId || assignees[0]?.id || "", ); const [draftDueDate, setDraftDueDate] = useState("Dec 12"); const [draftLabels, setDraftLabels] = useState("Engine"); const [draftError, setDraftError] = useState("");
// Task detail drawer state const [selectedTaskId, setSelectedTaskId] = useState<string | null>(null); const [editTitle, setEditTitle] = useState(""); const [editDescription, setEditDescription] = useState(""); const [editDueDate, setEditDueDate] = useState("");
const assigneeById = useMemo( () => new Map(assignees.map((member) => [member.id, member])), [assignees], );
const activeSprint = useMemo( () => sprints.find((s) => s.id === activeSprintId) ?? sprints[0], [sprints, activeSprintId], );
const selectedTask = useMemo( () => (selectedTaskId ? items.find((it) => it.id === selectedTaskId) ?? null : null), [items, selectedTaskId], );
const updateItems = useCallback( (updater: (prev: KanbanTask[]) => KanbanTask[]) => { setItems((prev) => { const next = updater(prev); onItemsChange?.(next); return next; }); }, [onItemsChange], );
// Filter & sort items for the active sprint const sprintItems = useMemo( () => items.filter((item) => item.sprintId === activeSprintId), [items, activeSprintId], );
const hasActiveFilter = search.trim().length > 0 || priorityFilter !== "all" || assigneeFilter !== "all";
const visibleItems = useMemo(() => { const query = search.trim().toLowerCase(); const filtered = sprintItems.filter((item) => { if (priorityFilter !== "all" && item.priority !== priorityFilter) { return false; } if (assigneeFilter !== "all" && item.assigneeId !== assigneeFilter) { return false; } if (!query) { return true; } const member = assigneeById.get(item.assigneeId); const haystack = [ item.key, item.title, item.description, ...item.labels, member?.name ?? "", ] .join(" ") .toLowerCase(); return haystack.includes(query); });
if (sortOrder === "manual") { return filtered; }
const sorted = [...filtered]; if (sortOrder === "priority") { sorted.sort((a, b) => PRIORITY_META[a.priority].rank - PRIORITY_META[b.priority].rank); } else if (sortOrder === "due") { sorted.sort((a, b) => a.dueSortKey - b.dueSortKey); } else if (sortOrder === "key") { sorted.sort((a, b) => parseKeyNumber(a.key) - parseKeyNumber(b.key)); } return sorted; }, [sprintItems, search, priorityFilter, assigneeFilter, sortOrder, assigneeById]);
const itemsByColumn = useMemo(() => { const map: Record<KanbanColumnId, KanbanTask[]> = { backlog: [], "in-progress": [], review: [], shipped: [], }; for (const item of visibleItems) { map[item.column].push(item); } return map; }, [visibleItems]);
const shippedCount = useMemo( () => sprintItems.filter((it) => it.column === "shipped").length, [sprintItems], );
// Keep a live ref to itemsByColumn so pointermove hit-testing never sees stale closures const itemsByColumnRef = useRef(itemsByColumn); itemsByColumnRef.current = itemsByColumn;
// Element registries for pointer drag hit-testing const columnEls = useRef(new Map<KanbanColumnId, HTMLElement>()); const cardEls = useRef(new Map<string, HTMLElement>()); const columnRefCbs = useRef( new Map<KanbanColumnId, (el: HTMLDivElement | null) => void>(), ); const cardRefCbs = useRef( new Map<string, (el: HTMLDivElement | null) => void>(), ); const teardownRef = useRef<(() => void) | null>(null); const carryingRef = useRef(false); const suppressNextClickRef = useRef(false);
const holdScroll = useRef((ev: TouchEvent) => { if (carryingRef.current) { ev.preventDefault(); } }).current;
const getColumnRef = useCallback((id: KanbanColumnId) => { let cb = columnRefCbs.current.get(id); if (!cb) { cb = (el) => { if (el) { columnEls.current.set(id, el); } else { columnEls.current.delete(id); } }; columnRefCbs.current.set(id, cb); } return cb; }, []);
const getCardRef = useCallback( (id: string) => { let cb = cardRefCbs.current.get(id); if (!cb) { cb = (el) => { const previous = cardEls.current.get(id); previous?.removeEventListener("touchmove", holdScroll); if (el) { cardEls.current.set(id, el); el.addEventListener("touchmove", holdScroll, { passive: false }); } else { cardEls.current.delete(id); } }; cardRefCbs.current.set(id, cb); } return cb; }, [holdScroll], );
// ============= MUTATIONS =============
const moveItemToColumn = useCallback( (id: string, to: KanbanColumnId, refocus = false) => { let movedTask: KanbanTask | undefined; updateItems((prev) => prev.map((item) => { if (item.id !== id) return item; movedTask = item; return item.column === to ? item : { ...item, column: to, updatedAt: "Just now" }; }), ); if (movedTask && movedTask.column !== to) { queue.info(`Moved ${movedTask.key} to ${getColumnTitle(to)}`, { description: movedTask.title, }); } if (refocus) { requestAnimationFrame(() => { cardEls.current.get(id)?.focus(); }); } }, [updateItems, queue], );
const reorderWithinColumn = useCallback( (id: string, direction: -1 | 1) => { let moved = false; updateItems((prev) => { const target = prev.find((it) => it.id === id); if (!target) return prev; const colItems = itemsByColumnRef.current[target.column]; const idx = colItems.findIndex((it) => it.id === id); const swapWith = colItems[idx + direction]; if (!swapWith) return prev;
const next = [...prev]; const aIdx = next.findIndex((it) => it.id === id); const bIdx = next.findIndex((it) => it.id === swapWith.id); if (aIdx === -1 || bIdx === -1) return prev;
const [removed] = next.splice(aIdx, 1); const insertAt = next.findIndex((it) => it.id === swapWith.id); next.splice(direction === -1 ? insertAt : insertAt + 1, 0, removed); moved = true; return next; }); if (moved) { if (sortOrder !== "manual") { setSortOrder("manual"); } requestAnimationFrame(() => { cardEls.current.get(id)?.focus(); }); } }, [updateItems, sortOrder], );
const assignToMe = useCallback( (id: string) => { const me = assigneeById.get(currentUserId); if (!me) return; let targetKey = ""; updateItems((prev) => prev.map((item) => { if (item.id !== id) return item; targetKey = item.key; return { ...item, assigneeId: me.id, updatedAt: "Just now" }; }), ); if (targetKey) { queue.success(`Assigned ${targetKey} to ${me.name}`); } }, [assigneeById, currentUserId, updateItems, queue], );
const deleteTask = useCallback( (id: string) => { let deleted: KanbanTask | undefined; updateItems((prev) => { deleted = prev.find((it) => it.id === id); return prev.filter((it) => it.id !== id); }); if (selectedTaskId === id) { setSelectedTaskId(null); } if (deleted) { queue.info(`Removed ${deleted.key}`, { description: deleted.title }); } }, [selectedTaskId, updateItems, queue], );
const openTaskDrawer = useCallback((task: KanbanTask) => { setSelectedTaskId(task.id); setEditTitle(task.title); setEditDescription(task.description); setEditDueDate(task.dueDate); }, []);
const handleCardClick = useCallback( (task: KanbanTask) => { if (suppressNextClickRef.current) { suppressNextClickRef.current = false; return; } openTaskDrawer(task); }, [openTaskDrawer], );
const handleCardKeyDown = useCallback( (e: ReactKeyboardEvent<HTMLDivElement>, item: KanbanTask) => { if (e.target !== e.currentTarget) return;
if (e.key === "Enter" || e.key === " ") { e.preventDefault(); openTaskDrawer(item); return; }
const colIdx = COLUMNS.findIndex((c) => c.id === item.column); if (e.key === "ArrowRight" || e.key === "]") { const nextCol = COLUMNS[colIdx + 1]; if (nextCol) { e.preventDefault(); moveItemToColumn(item.id, nextCol.id, true); } return; }
if (e.key === "ArrowLeft" || e.key === "[") { const prevCol = COLUMNS[colIdx - 1]; if (prevCol) { e.preventDefault(); moveItemToColumn(item.id, prevCol.id, true); } return; }
if (e.altKey && e.key === "ArrowUp") { e.preventDefault(); reorderWithinColumn(item.id, -1); return; }
if (e.altKey && e.key === "ArrowDown") { e.preventDefault(); reorderWithinColumn(item.id, 1); } }, [openTaskDrawer, moveItemToColumn, reorderWithinColumn], );
// ============= POINTER DRAG & DROP =============
const computeTarget = useCallback( (px: number, py: number, draggedId: string): DropTarget | null => { for (const [colId, el] of Array.from(columnEls.current.entries())) { const r = el.getBoundingClientRect(); if (px < r.left || px > r.right || py < r.top || py > r.bottom) { continue; }
const ids = itemsByColumnRef.current[colId] .filter((it) => it.id !== draggedId) .map((it) => it.id);
let index = ids.length; for (let i = 0; i < ids.length; i++) { const cardEl = cardEls.current.get(ids[i]); if (!cardEl) continue; const cr = cardEl.getBoundingClientRect(); if (py < cr.top + cr.height / 2) { index = i; break; } } return { column: colId, index }; } return null; }, [], );
const commitDrag = useCallback( (id: string, target: DropTarget) => { let movedTask: KanbanTask | undefined; let columnChanged = false;
updateItems((prev) => { const moved = prev.find((it) => it.id === id); if (!moved) return prev; movedTask = moved; columnChanged = moved.column !== target.column;
const rest = prev.filter((it) => it.id !== id); const updated: KanbanTask = { ...moved, column: target.column, updatedAt: columnChanged ? "Just now" : moved.updatedAt, }; const visibleColIds = itemsByColumnRef.current[target.column] .filter((it) => it.id !== id) .map((it) => it.id); const anchorId = visibleColIds[target.index];
if (!anchorId) { return [...rest, updated]; } const at = rest.findIndex((it) => it.id === anchorId); if (at === -1) { return [...rest, updated]; } return [...rest.slice(0, at), updated, ...rest.slice(at)]; });
if (!columnChanged && sortOrder !== "manual") { setSortOrder("manual"); }
if (movedTask && columnChanged) { queue.info(`Moved ${movedTask.key} to ${getColumnTitle(target.column)}`, { description: movedTask.title, }); } }, [updateItems, sortOrder, queue], );
const onCardPointerDown = useCallback( (e: ReactPointerEvent<HTMLDivElement>, id: string) => { if (e.button !== 0) return;
const targetEl = e.target as HTMLElement | null; if (targetEl?.closest('button, a, input, [role="menuitem"], [role="menu"]')) { return; }
const el = cardEls.current.get(id); if (!el) return;
const rect = el.getBoundingClientRect(); const startX = e.clientX; const startY = e.clientY; const offsetX = startX - rect.left; const offsetY = startY - rect.top; const { width, height } = rect;
let started = false; let target: DropTarget | null = null; const byLongPress = e.pointerType === "touch"; let longPressTimer: number | null = null;
const clearLongPress = () => { if (longPressTimer !== null) { window.clearTimeout(longPressTimer); longPressTimer = null; } };
const follow = (x: number, y: number) => { if (!started) { started = true; suppressNextClickRef.current = true; } carryingRef.current = e.pointerType !== "mouse"; target = computeTarget(x, y, id); setDrag({ id, width, height, offsetX, offsetY, pointerX: x, pointerY: y, target, }); };
if (byLongPress) { longPressTimer = window.setTimeout(() => { longPressTimer = null; follow(startX, startY); }, LONG_PRESS_MS); }
const onMove = (ev: PointerEvent) => { if (!started && byLongPress) { if ( Math.hypot(ev.clientX - startX, ev.clientY - startY) > LONG_PRESS_SLOP ) { teardownRef.current?.(); } return; } if ( !started && Math.abs(ev.clientX - startX) + Math.abs(ev.clientY - startY) < DRAG_THRESHOLD ) { return; } follow(ev.clientX, ev.clientY); };
const onCancel = () => { teardownRef.current?.(); setDrag(null); };
const onUp = () => { teardownRef.current?.(); if (started && target) { commitDrag(id, target); } setDrag(null); if (started) { window.setTimeout(() => { suppressNextClickRef.current = false; }, 0); } };
const teardown = () => { clearLongPress(); window.removeEventListener("pointermove", onMove); window.removeEventListener("pointerup", onUp); window.removeEventListener("pointercancel", onCancel); carryingRef.current = false; teardownRef.current = null; };
teardownRef.current = teardown; window.addEventListener("pointermove", onMove); window.addEventListener("pointerup", onUp); window.addEventListener("pointercancel", onCancel); }, [computeTarget, commitDrag], );
const isDragging = drag !== null; const draggedItem = drag ? items.find((it) => it.id === drag.id) : undefined;
useEffect(() => { if (!isDragging) return; const previous = document.body.style.userSelect; document.body.style.userSelect = "none"; return () => { document.body.style.userSelect = previous; }; }, [isDragging]);
useEffect(() => () => teardownRef.current?.(), []);
// ============= QUICK ADD DIALOG =============
const openQuickAdd = useCallback( (columnId: KanbanColumnId = "backlog") => { setDraftColumn(columnId); setDraftTitle(""); setDraftDescription(""); setDraftPriority("medium"); setDraftAssigneeId(currentUserId || assignees[0]?.id || ""); setDraftDueDate("Dec 12"); setDraftLabels("Engine"); setDraftError(""); setAddOpen(true); }, [currentUserId, assignees], );
const handleCreateTask = useCallback( (e: React.FormEvent<HTMLFormElement>) => { e.preventDefault(); const trimmedTitle = draftTitle.trim(); if (!trimmedTitle) { setDraftError("Enter a short task title before adding to the board."); return; }
const maxKey = items.reduce( (max, item) => Math.max(max, parseKeyNumber(item.key)), 200, ); const nextKey = `DS-${maxKey + 1}`; const parsedLabels = draftLabels .split(",") .map((l) => l.trim()) .filter(Boolean) .slice(0, 3);
const created: KanbanTask = { id: `task-${nextKey.toLowerCase()}-${Date.now()}`, key: nextKey, sprintId: activeSprintId, column: draftColumn, priority: draftPriority, title: trimmedTitle, description: draftDescription.trim(), assigneeId: draftAssigneeId, labels: parsedLabels, dueDate: draftDueDate.trim() || "Dec 12", dueSortKey: 20261212, updatedAt: "Just now", checklist: [], };
updateItems((prev) => [created, ...prev]); setAddOpen(false); queue.success(`Created ${nextKey}`, { description: `Added to ${getColumnTitle(draftColumn)} in ${activeSprint?.label ?? "sprint"}.`, }); }, [ draftTitle, draftDescription, draftColumn, draftPriority, draftAssigneeId, draftDueDate, draftLabels, items, activeSprintId, activeSprint, updateItems, queue, ], );
// ============= DETAIL DRAWER HANDLERS =============
const handleSaveTaskEdits = useCallback(() => { if (!selectedTask) return; const trimmed = editTitle.trim(); if (!trimmed) { queue.error("Task title cannot be empty"); return; } updateItems((prev) => prev.map((item) => item.id === selectedTask.id ? { ...item, title: trimmed, description: editDescription.trim(), dueDate: editDueDate.trim() || item.dueDate, updatedAt: "Just now", } : item, ), ); queue.success(`Updated ${selectedTask.key}`, { description: "Changes saved to sprint board.", }); setSelectedTaskId(null); }, [selectedTask, editTitle, editDescription, editDueDate, updateItems, queue]);
const handleToggleChecklistItem = useCallback( (taskId: string, checklistItemId: string, checked: boolean) => { updateItems((prev) => prev.map((item) => { if (item.id !== taskId) return item; return { ...item, updatedAt: "Just now", checklist: item.checklist.map((entry) => entry.id === checklistItemId ? { ...entry, done: checked } : entry, ), }; }), ); }, [updateItems], );
const handleDrawerPriorityChange = useCallback( (priority: KanbanPriority) => { if (!selectedTask || selectedTask.priority === priority) return; updateItems((prev) => prev.map((item) => item.id === selectedTask.id ? { ...item, priority, updatedAt: "Just now" } : item, ), ); queue.info(`Set ${selectedTask.key} priority to ${PRIORITY_META[priority].label}`); }, [selectedTask, updateItems, queue], );
const handleDrawerAssigneeChange = useCallback( (nextAssigneeId: string) => { if (!selectedTask || selectedTask.assigneeId === nextAssigneeId) return; const member = assigneeById.get(nextAssigneeId); updateItems((prev) => prev.map((item) => item.id === selectedTask.id ? { ...item, assigneeId: nextAssigneeId, updatedAt: "Just now" } : item, ), ); if (member) { queue.info(`Reassigned ${selectedTask.key} to ${member.name}`); } }, [selectedTask, assigneeById, updateItems, queue], );
// ============= SELECT DATA =============
const sprintSelectItems = useMemo( () => sprints.map((s) => ({ value: s.id, label: s.label })), [sprints], );
const assigneeFilterItems = useMemo( () => [ { value: "all", label: "All assignees" }, ...assignees.map((member) => ({ value: member.id, label: member.name })), ], [assignees], );
const assigneeSelectItems = useMemo( () => assignees.map((member) => ({ value: member.id, label: member.name })), [assignees], );
const activeSortLabel = SORT_OPTIONS.find((opt) => opt.value === sortOrder)?.label ?? "Manual order";
// ============= COLUMN RENDERING =============
const isColumnEmpty = (colId: KanbanColumnId): boolean => !itemsByColumn[colId].some((it) => it.id !== drag?.id) && drag?.target?.column !== colId;
const renderColumnCards = (colId: KanbanColumnId): ReactNode => { const colItems = itemsByColumn[colId]; const visible = drag ? colItems.filter((it) => it.id !== drag.id) : colItems; const carried = drag ? colItems.find((it) => it.id === drag.id) : undefined; const ghostTarget = drag && drag.target && drag.target.column === colId ? drag : null;
if (visible.length === 0 && !ghostTarget && !carried) { return null; }
const nodes: ReactNode[] = visible.map((it) => ( <BoardCard key={it.id} item={it} assignee={assigneeById.get(it.assigneeId)} isCurrentUserAssignee={it.assigneeId === currentUserId} cardRef={getCardRef(it.id)} onPointerDown={onCardPointerDown} onCardClick={handleCardClick} onCardKeyDown={handleCardKeyDown} onAssignToMe={assignToMe} onMove={moveItemToColumn} onDelete={deleteTask} /> ));
if (ghostTarget && ghostTarget.target) { const index = Math.min(ghostTarget.target.index, nodes.length); nodes.splice( index, 0, <div key="drag-ghost" aria-hidden="true" {...stylex.props(styles.ghostSlot(ghostTarget.height))} />, ); }
if (carried) { nodes.push( <BoardCard key={carried.id} item={carried} assignee={assigneeById.get(carried.assigneeId)} isCurrentUserAssignee={carried.assigneeId === currentUserId} cardRef={getCardRef(carried.id)} onPointerDown={onCardPointerDown} onCardClick={handleCardClick} onCardKeyDown={handleCardKeyDown} onAssignToMe={assignToMe} onMove={moveItemToColumn} onDelete={deleteTask} isCarried />, ); }
return nodes; };
const resetFilters = () => { setSearch(""); setPriorityFilter("all"); setAssigneeFilter("all"); };
return ( <VStack gap="0" palette={palette} style={[styles.root, style]}> {/* Top Board Header & Filter Controls */} <VStack render={<header />} gap="3" style={styles.header}> <HStack gap="3" justify="between" wrap="wrap"> <HStack gap="2.5" wrap="wrap"> <Heading render={<h1 />} size="lg" style={styles.titleHeading}> {title} </Heading> <Badge variant="subtle" size="sm"> {visibleItems.length} {hasActiveFilter ? ` / ${sprintItems.length}` : ""} tasks </Badge> <Badge variant="outline" size="sm" palette={greenPalette}> {shippedCount}/{sprintItems.length} shipped </Badge> {subtitle || activeSprint?.window ? ( <Text size="xs" tone="muted"> {subtitle ?? activeSprint?.window} </Text> ) : null} </HStack>
<HStack gap="2" wrap="wrap"> <Select.Root items={sprintSelectItems} value={activeSprintId} onValueChange={(next) => { if (next) setActiveSprintId(next); }} size="sm" variant="outline" style={styles.sprintSelect} > <Select.Control> <Select.Trigger aria-label="Select sprint"> <Select.Value /> </Select.Trigger> <Select.IndicatorGroup> <Select.Icon /> </Select.IndicatorGroup> </Select.Control> <Select.Content> {sprints.map((s) => ( <Select.Item key={s.id} value={s.id}> <Select.ItemText>{s.label}</Select.ItemText> <Select.ItemIndicator /> </Select.Item> ))} </Select.Content> </Select.Root>
<Separator orientation="vertical" size="sm" decorative style={styles.headerDivider} />
<Button variant="solid" size="sm" palette={accentPalette} onClick={() => openQuickAdd("backlog")} > <PlusIcon /> <span>Add task</span> </Button> </HStack> </HStack>
<HStack gap="2" justify="between" wrap="wrap"> <HStack gap="2" wrap="wrap" style={styles.filterControls}> <div {...stylex.props(styles.searchWrap)}> <span {...stylex.props(styles.searchIconSlot)}> <SearchIcon /> </span> <Input size="sm" variant="outline" aria-label="Search sprint tasks" placeholder="Search key, title, label, or owner…" value={search} onValueChange={setSearch} style={styles.searchInput} /> {search ? ( <IconButton variant="ghost" size="2xs" aria-label="Clear search" style={styles.searchClearBtn} onClick={() => setSearch("")} > <CloseIcon /> </IconButton> ) : null} </div>
<Select.Root items={PRIORITY_FILTER_ITEMS} value={priorityFilter} onValueChange={(val) => setPriorityFilter((val as "all" | KanbanPriority) || "all") } size="sm" variant="outline" style={styles.filterSelect} > <Select.Control> <Select.Trigger aria-label="Filter by priority"> <Select.Value /> </Select.Trigger> <Select.IndicatorGroup> <Select.Icon /> </Select.IndicatorGroup> </Select.Control> <Select.Content> {PRIORITY_FILTER_ITEMS.map((opt) => ( <Select.Item key={opt.value} value={opt.value}> <Select.ItemText>{opt.label}</Select.ItemText> <Select.ItemIndicator /> </Select.Item> ))} </Select.Content> </Select.Root>
<Select.Root items={assigneeFilterItems} value={assigneeFilter} onValueChange={(val) => setAssigneeFilter(val || "all")} size="sm" variant="outline" style={styles.assigneeSelect} > <Select.Control> <Select.Trigger aria-label="Filter by assignee"> <Select.Value /> </Select.Trigger> <Select.IndicatorGroup> <Select.Icon /> </Select.IndicatorGroup> </Select.Control> <Select.Content> {assigneeFilterItems.map((opt) => ( <Select.Item key={opt.value} value={opt.value}> <Select.ItemText>{opt.label}</Select.ItemText> <Select.ItemIndicator /> </Select.Item> ))} </Select.Content> </Select.Root>
<Menu.Root size="sm"> <Menu.Trigger render={<Button variant="surface" size="sm" />}> <SortIcon /> <span>{activeSortLabel}</span> </Menu.Trigger> <Menu.Content align="start"> <Menu.Group> <Menu.GroupLabel>Sort cards within lanes</Menu.GroupLabel> <Menu.RadioGroup value={sortOrder} onValueChange={(val) => setSortOrder(val as KanbanSortOrder)} > {SORT_OPTIONS.map((opt) => ( <Menu.RadioItem key={opt.value} value={opt.value}> <Menu.ItemText>{opt.label}</Menu.ItemText> <Menu.ItemIndicator /> </Menu.RadioItem> ))} </Menu.RadioGroup> </Menu.Group> </Menu.Content> </Menu.Root>
{hasActiveFilter ? ( <Button variant="ghost" size="sm" onClick={resetFilters}> Reset filters </Button> ) : null} </HStack>
<HStack gap="2"> <Text render={<span />} size="xs" tone="subtle" style={styles.keyboardHint}> Drag cards or focus a card and press ← / → to move lanes </Text> </HStack> </HStack> </VStack>
{/* Main Board Columns */} <VStack render={<main />} gap="0" style={styles.boardMain}> <Stack align="stretch" style={styles.boardColumns}> {COLUMNS.map((meta) => ( <BoardColumn key={meta.id} meta={meta} count={itemsByColumn[meta.id].length} isDropTarget={drag?.target?.column === meta.id} isEmpty={isColumnEmpty(meta.id)} isFiltered={hasActiveFilter} contentRef={getColumnRef(meta.id)} onQuickAdd={openQuickAdd} > {renderColumnCards(meta.id)} </BoardColumn> ))} </Stack> </VStack>
{/* Floating Drag Preview */} {drag && draggedItem ? ( <div aria-hidden="true" {...stylex.props( styles.floatingWrap, styles.floatingAt( drag.pointerX - drag.offsetX, drag.pointerY - drag.offsetY, drag.width, ), )} > <Card.Root variant="elevated" size="sm" style={styles.floatingCard}> <Card.Body> <BoardCardBody item={draggedItem} assignee={assigneeById.get(draggedItem.assigneeId)} isCurrentUserAssignee={draggedItem.assigneeId === currentUserId} onOpen={() => {}} onAssignToMe={() => {}} onMove={() => {}} onDelete={() => {}} interactive={false} /> </Card.Body> </Card.Root> </div> ) : null}
{/* Quick-Add Task Dialog */} <Dialog.Root open={addOpen} onOpenChange={setAddOpen} size="md" placement="center" > <Dialog.Backdrop /> <Dialog.Content> <Dialog.Close render={ <IconButton variant="ghost" size="xs" aria-label="Close new task dialog" /> } > <CloseIcon /> </Dialog.Close>
<form onSubmit={handleCreateTask} noValidate> <Dialog.Header style={styles.dialogHeaderStack}> <Dialog.Title style={styles.dialogTitleReset}> Create sprint task </Dialog.Title> <Dialog.Description> Add a scoped work item directly to {activeSprint?.label ?? "this sprint"}. </Dialog.Description> </Dialog.Header>
<Dialog.Body> <VStack gap="3"> <Field.Root required invalid={Boolean(draftError)}> <Field.Label> Title <Field.RequiredIndicator /> </Field.Label> <Input autoFocus required placeholder="e.g. Audit combobox keyboard navigation in RTL" value={draftTitle} onValueChange={(val) => { setDraftTitle(val); if (draftError) setDraftError(""); }} /> {draftError ? <Field.Error>{draftError}</Field.Error> : null} </Field.Root>
<Field.Root> <Field.Label>Description</Field.Label> <Textarea rows={3} placeholder="Outline acceptance criteria, edge cases, or related RFCs…" value={draftDescription} onValueChange={setDraftDescription} /> </Field.Root>
<Grid gap="3" style={styles.formTwoCol}> <Field.Root> <Field.Label>Column</Field.Label> <Select.Root items={COLUMN_SELECT_ITEMS} value={draftColumn} onValueChange={(val) => { if (val) setDraftColumn(val as KanbanColumnId); }} size="md" variant="outline" style={styles.fullWidth} > <Select.Control> <Select.Trigger> <Select.Value /> </Select.Trigger> <Select.IndicatorGroup> <Select.Icon /> </Select.IndicatorGroup> </Select.Control> <Select.Content> {COLUMN_SELECT_ITEMS.map((col) => ( <Select.Item key={col.value} value={col.value}> <Select.ItemText>{col.label}</Select.ItemText> <Select.ItemIndicator /> </Select.Item> ))} </Select.Content> </Select.Root> </Field.Root>
<Field.Root> <Field.Label>Priority</Field.Label> <Select.Root items={PRIORITY_SELECT_ITEMS} value={draftPriority} onValueChange={(val) => { if (val) setDraftPriority(val as KanbanPriority); }} size="md" variant="outline" style={styles.fullWidth} > <Select.Control> <Select.Trigger> <Select.Value /> </Select.Trigger> <Select.IndicatorGroup> <Select.Icon /> </Select.IndicatorGroup> </Select.Control> <Select.Content> {PRIORITY_SELECT_ITEMS.map((p) => ( <Select.Item key={p.value} value={p.value}> <Select.ItemText>{p.label}</Select.ItemText> <Select.ItemIndicator /> </Select.Item> ))} </Select.Content> </Select.Root> </Field.Root> </Grid>
<Grid gap="3" style={styles.formTwoCol}> <Field.Root> <Field.Label>Assignee</Field.Label> <Select.Root items={assigneeSelectItems} value={draftAssigneeId} onValueChange={(val) => { if (val) setDraftAssigneeId(val); }} size="md" variant="outline" style={styles.fullWidth} > <Select.Control> <Select.Trigger> <Select.Value /> </Select.Trigger> <Select.IndicatorGroup> <Select.Icon /> </Select.IndicatorGroup> </Select.Control> <Select.Content> {assigneeSelectItems.map((member) => ( <Select.Item key={member.value} value={member.value}> <Select.ItemText>{member.label}</Select.ItemText> <Select.ItemIndicator /> </Select.Item> ))} </Select.Content> </Select.Root> </Field.Root>
<Field.Root> <Field.Label>Due date</Field.Label> <Input placeholder="Dec 12" value={draftDueDate} onValueChange={setDraftDueDate} /> </Field.Root> </Grid>
<Field.Root> <Field.Label>Labels</Field.Label> <Input placeholder="Tokens, A11y, Engine" value={draftLabels} onValueChange={setDraftLabels} /> </Field.Root> </VStack> </Dialog.Body>
<Dialog.Footer> <Button type="button" variant="ghost" size="sm" onClick={() => setAddOpen(false)} > Cancel </Button> <Button type="submit" variant="solid" size="sm" palette={accentPalette}> Create task </Button> </Dialog.Footer> </form> </Dialog.Content> </Dialog.Root>
{/* Task Detail Drawer */} <Drawer.Root open={selectedTask !== null} onOpenChange={(open) => { if (!open) setSelectedTaskId(null); }} placement="end" size="sm" > <Drawer.Backdrop /> <Drawer.Content> {selectedTask ? ( <> <Drawer.Header style={styles.drawerHeaderStack}> <HStack gap="1.5" wrap="wrap"> <Badge variant="surface" size="sm" style={styles.keyBadge}> {selectedTask.key} </Badge> <Badge variant="subtle" size="sm" palette={PRIORITY_META[selectedTask.priority].palette} > {PRIORITY_META[selectedTask.priority].label} priority </Badge> {selectedTask.labels.map((label) => ( <Badge key={label} variant="outline" size="xs"> {label} </Badge> ))} </HStack> <Drawer.Title>{selectedTask.title}</Drawer.Title> <Drawer.Description> Updated {selectedTask.updatedAt} · Due {selectedTask.dueDate} </Drawer.Description> <Drawer.Close render={ <IconButton variant="ghost" size="xs" aria-label="Close task details" /> } > <CloseIcon /> </Drawer.Close> </Drawer.Header>
<Separator orientation="horizontal" size="sm" decorative />
<Drawer.Body> <VStack gap="3"> <Grid columns="2" gap="3"> <Field.Root> <Field.Label>Status lane</Field.Label> <Select.Root items={COLUMN_SELECT_ITEMS} value={selectedTask.column} onValueChange={(val) => { if (val) { moveItemToColumn(selectedTask.id, val as KanbanColumnId); } }} size="sm" variant="outline" style={styles.fullWidth} > <Select.Control> <Select.Trigger> <Select.Value /> </Select.Trigger> <Select.IndicatorGroup> <Select.Icon /> </Select.IndicatorGroup> </Select.Control> <Select.Content> {COLUMN_SELECT_ITEMS.map((col) => ( <Select.Item key={col.value} value={col.value}> <Select.ItemText>{col.label}</Select.ItemText> <Select.ItemIndicator /> </Select.Item> ))} </Select.Content> </Select.Root> </Field.Root>
<Field.Root> <Field.Label>Priority</Field.Label> <Select.Root items={PRIORITY_SELECT_ITEMS} value={selectedTask.priority} onValueChange={(val) => { if (val) handleDrawerPriorityChange(val as KanbanPriority); }} size="sm" variant="outline" style={styles.fullWidth} > <Select.Control> <Select.Trigger> <Select.Value /> </Select.Trigger> <Select.IndicatorGroup> <Select.Icon /> </Select.IndicatorGroup> </Select.Control> <Select.Content> {PRIORITY_SELECT_ITEMS.map((p) => ( <Select.Item key={p.value} value={p.value}> <Select.ItemText>{p.label}</Select.ItemText> <Select.ItemIndicator /> </Select.Item> ))} </Select.Content> </Select.Root> </Field.Root>
<Field.Root> <Field.Label>Assignee</Field.Label> <Select.Root items={assigneeSelectItems} value={selectedTask.assigneeId} onValueChange={(val) => { if (val) handleDrawerAssigneeChange(val); }} size="sm" variant="outline" style={styles.fullWidth} > <Select.Control> <Select.Trigger> <Select.Value /> </Select.Trigger> <Select.IndicatorGroup> <Select.Icon /> </Select.IndicatorGroup> </Select.Control> <Select.Content> {assigneeSelectItems.map((member) => ( <Select.Item key={member.value} value={member.value}> <Select.ItemText>{member.label}</Select.ItemText> <Select.ItemIndicator /> </Select.Item> ))} </Select.Content> </Select.Root> </Field.Root>
<Field.Root> <Field.Label>Due date</Field.Label> <Input size="sm" value={editDueDate} onValueChange={setEditDueDate} /> </Field.Root> </Grid>
<Separator orientation="horizontal" size="sm" decorative />
<Field.Root> <Field.Label>Title</Field.Label> <Input size="sm" value={editTitle} onValueChange={setEditTitle} /> </Field.Root>
<Field.Root> <Field.Label>Description</Field.Label> <Textarea rows={4} size="sm" value={editDescription} onValueChange={setEditDescription} /> </Field.Root>
{selectedTask.checklist.length > 0 ? ( <> <Separator orientation="horizontal" size="sm" decorative /> <VStack gap="3"> <HStack gap="2" justify="between"> <Text size="xs" weight="medium" tone="muted"> Acceptance checklist </Text> <Badge variant="subtle" size="xs"> {selectedTask.checklist.filter((c) => c.done).length}/ {selectedTask.checklist.length} </Badge> </HStack> <VStack gap="2"> {selectedTask.checklist.map((entry) => ( <div key={entry.id} {...stylex.props(styles.drawerChecklistItem)} > <Checkbox.Root size="sm" palette={accentPalette}> <Checkbox.Control checked={entry.done} onCheckedChange={(next) => handleToggleChecklistItem( selectedTask.id, entry.id, next === true, ) } /> <Checkbox.Label style={entry.done ? styles.checklistLabelDone : undefined} > {entry.label} </Checkbox.Label> </Checkbox.Root> </div> ))} </VStack> </VStack> </> ) : null}
<Text size="xs" tone="subtle"> Tip: Use ← / → on any focused card to move between lanes. </Text> </VStack> </Drawer.Body>
<Separator orientation="horizontal" size="sm" decorative />
<Drawer.Footer style={styles.drawerFooterSplit}> <Button variant="ghost" size="sm" palette={redPalette} onClick={() => deleteTask(selectedTask.id)} > Delete </Button> <HStack gap="2"> <Button variant="ghost" size="sm" onClick={() => setSelectedTaskId(null)} > Close </Button> <Button variant="solid" size="sm" palette={accentPalette} onClick={handleSaveTaskEdits} > Save changes </Button> </HStack> </Drawer.Footer> </> ) : null} </Drawer.Content> </Drawer.Root>
<Toaster toaster={queue} /> </VStack> );}
Inspired by the Kanban Board template from Astryx (MIT License · Copyright (c) 2026 Meta Platforms, Inc.).