Skip to content

TaskBoard ​

TaskBoard is a kanban board: cards in status columns, optionally split into horizontal swimlanes, with card counts, WIP limits and minimums, collapsible columns and lanes, and a filter. Use it next to a GanttChart for the same tasks, or on its own for work in progress.

It is an opt-in, controlled component. A pointer, touch or keyboard move becomes a card-move proposal that validateCardMove can reject and applyBoardCardMove applies; the board never reorders its cards itself.

Minimal example ​

vue
<script setup lang="ts">
import { ref } from 'vue'
import { TaskBoard, applyBoardCardMove, type TaskBoardCard, type TaskBoardCardMove, type TaskBoardColumn } from '@eightkk/vue-weave'
import '@eightkk/vue-weave/style.css'

const columns: TaskBoardColumn[] = [
  { id: 'todo', label: 'To do' },
  { id: 'doing', label: 'Doing', wipLimit: 2 },
  { id: 'done', label: 'Done' },
]
const cards = ref<TaskBoardCard[]>([
  { id: 'spec', columnId: 'doing', label: 'Write the spec' },
  { id: 'api', columnId: 'todo', label: 'Billing API' },
])

function move(change: TaskBoardCardMove) {
  cards.value = applyBoardCardMove(cards.value, change, { columns })
}
</script>

<template>
  <TaskBoard :columns="columns" :cards="cards" @card-move="move" />
</template>

Examples: Task board and the example index. Types: TaskBoardCard, TaskBoardColumn, TaskBoardCardMove, TaskBoardExposed.

TaskBoard ​

An opt-in third controlled component: a kanban board that shows cards in status columns, optionally split into horizontal swimlanes. It never changes its data. A drag or keyboard move becomes a card-move proposal, and the parent applies it, for example with applyBoardCardMove. It is designed to sit next to a GanttChart on the same tasks: give the bars and the cards the same IDs and share one selected ID (see the "Task board" demo).

PropType / defaultMeaning
columnsreadonly TaskBoardColumn[] / requiredStatus columns in display order: unique ID, label, optional detail, optional wipLimit and optional wipMin (non-negative integers, wipMin at most wipLimit)
cardsreadonly C[] (C extends TaskBoardCard) / requiredID, columnId, laneId (required on a board with lanes), label, optional detail, tone, draggable (false keeps the card in place) and data (TaskBoardCard<D>). The array order is the order inside every cell. C is inferred
lanesreadonly TaskBoardLane[] / undefinedHorizontal swimlanes in display order: unique ID, label and optional detail. Without lanes (or with an empty array) the board has one row of cells and card laneIds are ignored
filter(card: C) => boolean / undefinedShows only the cards it accepts. Applied before grouping, so counts, keyboard navigation and drops see the shown cards. A column header shows "shown of all" (for example "3 of 7", using labels.of) while the filter hides cards of that column. WIP limits and minimums still count every card. Pass a new function when the criteria change. A move in progress is cancelled (data-change) only when the cards the filter shows change, but every new function regroups the board, so keep its identity (for example in a computed) instead of writing an arrow function inline. A value that is not a function is reported through validation-error (a TypeError)
collapsibleboolean / falseRenders a toggle button (aria-expanded) in every column header and lane header, named labels.collapse or labels.expand plus the label ("Collapse To do", "Expand To do")
collapsedColumnIdsreadonly string[] / undefinedControlled collapsed columns; supports v-model:collapsed-column-ids. Honoured with or without collapsible. Compared by value (order and duplicates do not matter), so an equal array written inline changes nothing
collapsedLaneIdsreadonly string[] / undefinedControlled collapsed lanes; supports v-model:collapsed-lane-ids. Column and lane IDs live in separate props, so they never clash. Compared by value like collapsedColumnIds
selectedIdstring / undefinedControlled selected card, drawn with vw-is-selected and aria-pressed="true"; supports v-model:selected-id
readonlyboolean / falseDisables moves; cards can still be selected and activated
validateCardMoveTaskBoardCardMoveValidator / undefinedSynchronous check of a proposal: true or undefined accepts, false (default message labels.moveRejected, "This card move was rejected.") or a reason string rejects; a blank string rejects with the default message
labelsPartial<TaskBoardLabels> / Englishregion ("Task board"), empty, emptyCell, card, cards, wipLimit, overLimit, wipMin, underMinimum, collapse, expand, moveHint, moveRejected, pickedUp, moved, moveCancelled, position, of and lane
dirChartDirection / ltrrtl places the first column on the right and swaps Left and Right; with auto the board follows the inherited direction
heightnumber or CSS string / undefinedHeight of the scroll viewport; by default the board is as tall as its content
autoScrollboolean / trueScrolls the viewport while a pointer drag is held within 36 px of one of its edges
EventPayloadMeaning
card-moveTaskBoardCardMoveProposal: id, before and after positions (columnId, laneId on a board with lanes, index) and source (pointer or keyboard). after.index counts the cards of the target cell without the moved card, and before.index and after.index always count every card of the cell, including those a filter hides, so applyBoardCardMove(cards, change) on the full array places the card where the board showed it: right before the shown card at the drop place, or right after the last shown card, or last in a cell with no shown card. Apply it with applyBoardCardMove(cards, change). A drop on the card's own position proposes nothing and reports card-move-cancel with reason no-target
card-move-rejected(change, reason)validateCardMove rejected the proposal; the reason is announced in the live region
card-move-cancelTaskBoardMoveCancelA pick-up or drag ended without a proposal: id, before, source and reason: escape (Escape), api (the exposed cancelMove()), pointer-cancel (pointer cancellation or lost capture), no-target (released outside every cell, or dropped on the card's own place), blur (the picked-up card lost focus) or data-change (cards, columns, lanes or readonly changed, the collapsed column or lane IDs changed by value, or the cards that filter shows changed)
card-activateidA card was activated by click or Enter, or by Space on a card that cannot move
background-clickTaskBoardBackgroundClick{ columnId?, laneId? }. Fires when a primary-button press on empty board space is released before it moves past the drag threshold (a click, not a drag or a scroll). Empty space is a cell outside its cards (also the "No cards" text and the strip of a collapsed column), with the cell's columnId and, on a board with lanes, laneId, or the board background between and around the cells, with neither. It does not fire for cards, column and lane headers, toggles or other controls, or the scrollbar. The component keeps no selection of its own, so an application usually clears its controlled selection here
update:selectedIdidThe same activation, for v-model:selected-id; not emitted when the card is already selected
update:collapsedColumnIdsstring[]A column toggle proposes the new list of collapsed column IDs; the board never changes it itself
update:collapsedLaneIdsstring[]A lane toggle proposes the new list of collapsed lane IDs
validation-errorErrorInvalid columns, lanes or cards (the errors of groupBoardCards). The board renders its empty state and the error is rethrown, as in GanttChart

Slots are card({ card, selected, moving, column, lane }) (inside the card button, so keep it non-interactive), column-header({ column, status, collapsed, toggle, toggleLabel }) with the TaskBoardColumnStatus of the column (the slot replaces the whole header, the built-in collapse toggle included, so it receives the column's collapsed state, toggle(), which proposes the toggled collapsedColumnIds through update:collapsedColumnIds like the built-in toggle, and toggleLabel, that toggle's accessible name such as "Collapse To do", to draw its own toggle button), and empty({ column, lane }) for a cell without cards (without column for a board without columns). Methods are focusCard(id), cancelMove(), which reports card-move-cancel with reason api (1.2.0 reported escape), and exportSvg(options?) and exportPng(options?) (see Export to SVG and PNG). The public component type is TaskBoardComponent, and TaskBoardExposed<C> types a template ref.

Markup and accessibility. The scroll viewport is a focusable region named labels.region. Each cell is a list named after its column, or "column · lane" on a board with lanes (for example "Doing · Web team"), and described by the column's count, WIP limit and over-limit state ("4 cards, WIP limit 3, Over WIP limit"). A card is a button named by its label, with aria-pressed for the selection, and described by its detail and, when it is movable, by labels.moveHint. A column toggle is described by the same column description as the cells, and a lane toggle by the lane's count ("4 cards"), so a collapsed column or lane still reports them. Column headers show the count as "count / limit"; a column over its limit gets vw-is-over-limit and the visible labels.overLimit warning, and one at its limit vw-is-at-limit. A column under its wipMin gets vw-is-under-minimum, the visible labels.underMinimum warning and the same words in the cell description ("1 card, WIP minimum 2, Under WIP minimum"). A WIP limit or minimum never blocks a move by itself: reject such moves in validateCardMove if they must not happen.

Collapsing. A collapsed column (vw-is-collapsed) is a narrow strip with its toggle, rotated label and count; its cards are not rendered. A collapsed lane shows only its header, with its count. Cards in collapsed areas are not focusable, arrow-key focus and the pick-up target skip them, and a collapsed column or lane is not a drop target: a drag over it has no target, and the keyboard moves past it. Changing the collapsed IDs (by value) cancels a move in progress (data-change). The strip width is --vw-board-collapsed-width.

Pointer. A press on a movable card and a move of 4 px start a drag with the mouse, a pen or touch (movable cards have touch-action: none). The card follows the pointer (vw-is-dragging), and a drop indicator (vw-board-drop, with vw-is-over-limit when the drop would take another column over its limit) shows the place between the cards of the cell under the pointer (vw-is-target). Release proposes the move; Escape, pointer cancellation and data changes cancel it. A click without a drag selects and activates the card. cards, columns and lanes are watched by reference: pass new arrays instead of mutating them, and keep columns and lanes out of inline template literals, which are new arrays on every render of the parent and would cancel a move in progress. The collapsed IDs are compared by value and filter by the cards it shows, so inline values there do not cancel a move, though an inline filter still regroups the board on every render.

Keyboard. Space picks a movable card up (vw-is-picked) and announces its place ("Picked up Billing API. To do, lane API team, position 1 of 1."). Up and Down move the drop indicator through the cell and on into the previous or next lane, Left and Right to the neighbouring column in the visual direction, Home and End to the first and last place of the cell; each step is announced ("Doing, lane API team, position 1 of 3, Over WIP limit."). Space or Enter drops, Escape or moving the focus away cancels. The card keeps the focus, also after the parent applies the move and the card is drawn in its new cell; a move that the parent has not applied by the time the focus leaves the card moves no focus later. Without a pick-up, Enter activates the card and the arrow keys move the focus to the neighbouring card.

ts
import { applyBoardCardMove, type TaskBoardCardMove } from '@eightkk/vue-weave'

function validateCardMove(change: TaskBoardCardMove) {
  const task = cards.value.find(card => card.id === change.id)
  return change.after.columnId !== 'done' || (task?.data?.progress ?? 0) >= 1 || 'Finish the work first.'
}
function moveCard(change: TaskBoardCardMove) {
  cards.value = applyBoardCardMove(cards.value, change, { columns, lanes })
}
// <TaskBoard v-model:selected-id="selectedId" :columns="columns" :lanes="lanes" :cards="cards"
//   :validate-card-move="validateCardMove" @card-move="moveCard" />
// <GanttChart :rows="rows" :bars="bars" :range="range" :selected-ids="new Set(selectedId ? [selectedId] : [])"
//   @select="id => selectedId = id" />

Task board helpers ​

These functions are part of @eightkk/vue-weave/core and do not need Vue.

FunctionResult
groupBoardCards(cards, columns, lanes?, { filter }?)TaskBoardGroups: rows (one per lane in lane order, or one without laneId when there are no lanes), each with one TaskBoardCell per column holding its cards in cards order (with filter, only the accepted ones, plus indices, their indexes among all cards of the cell, and total); columns, one TaskBoardColumnStatus per column with count (shown cards over all lanes), total (all cards), wipLimit, wipMin, atLimit (total >= wipLimit), overLimit (total > wipLimit) and underMinimum (total < wipMin); and positions, every card's TaskBoardPosition by ID, counting hidden cards. Throws Invalid column ID, Duplicate card ID and the like for IDs (kinds column, lane and card), Unknown column in card <id>: <value> and Unknown lane in card <id>: <value> (also for a missing laneId on a board with lanes), a RangeError for a WIP limit or minimum that is not a non-negative integer, or a minimum above the limit, and a TypeError for a filter that is not a function (The board filter must be a function: <type>)
boardCardPosition(cards, id, { lanes }?)The TaskBoardPosition of one card; with lanes: true the index counts only the cards of the same lane. Throws Unknown card in board: <id>
applyBoardCardMove(cards, move, { columns, lanes }?)A new array in which the card has the target column (and lane when after.laneId is set) and sits before the card that had after.index in the target cell, or after the cell's last card. Other cards are kept as they are; the moved card is a shallow copy. A move whose positions have no laneId treats each column as one cell and keeps the card's laneId. With columns or lanes, the target must name one (Unknown column in card move <id>: <value>, Unknown lane in card move <id>: <value>). Throws an Error for an unknown card, a move that names a lane in only one position, and a stale move whose before is not the card's current position (Stale card move for <id>: …), and a RangeError for an index that is not an integer from 0 to the size of the target cell

Released under the MIT License.