Skip to content
kitn AI/UI

Tasks

kai-tasks

Present a list of tasks the user can check off, then confirm in one go — the card stays quiet while the user picks, and only the final confirm fires with the selected ids in a single atomic event.

  • Shadow DOM
  • Select-all with indeterminate state
  • Min / max gating
  • Read-only resolved view

Feed the card via the data property (an object, so set it in JavaScript). Listen for the bubbling kai-card CustomEvent:

const el = document.querySelector('kai-tasks');
el.data = {
selectAll: true,
confirmLabel: 'Run selected',
tasks: [
{ id: 'lint', label: 'Run linter', checked: true },
{ id: 'test', label: 'Run unit tests', checked: true },
{ id: 'build', label: 'Build production bundle' },
],
};
el.addEventListener('kai-card', (e) => {
if (e.detail.kind === 'submit') {
console.log('selected ids:', e.detail.data.selected);
}
});

The element emits three verbs on kai-card:

verbwhenpayload
readyon mount{ kind: 'ready', cardId }
submituser clicks confirm{ kind: 'submit', cardId, data: { selected: string[] } }
errordata is malformed{ kind: 'error', cardId, message }
  • Gating — confirm is enabled when checked count is >= (min ?? (allowEmpty ? 0 : 1)) and <= (max ?? ∞). When max is reached, unchecked rows disable automatically.
  • Resolved state — after receiving submit, set el.resolution = { kind: 'submit', data: { selected: [...] } } to render the read-only summary.

selectAll: true with rows pre-checked; the select-all header goes indeterminate when only some rows are checked.

allowEmpty: false keeps confirm disabled until the user checks something.

min and max cap how many rows the user can pick; over-selection is blocked automatically.

Each task row accepts an optional description — a secondary line for impact notes, caveats, or reversibility hints.

After confirm, set el.resolution to render the chromed summary — checkboxes and confirm button are removed.

An empty tasks array (or malformed definition) triggers the inline error view and emits an error CardEvent.

PropertyTypeDefaultNotes
data The tasks definition (the CardEnvelope.data). Set as a JS PROPERTY: `el.data = { tasks:[…], selectAll, confirmLabel, … }`. Import `TasksCardData` from `@kitn.ai/ui` for the full shape.
cardId Stable card id correlating every emitted CardEvent. Attribute: `card-id`.
heading Heading rendered in the card chrome (= CardEnvelope.title). Attribute: `heading`.
resolution Set when the user resolved this card; renders the read-only view. Property: `el.resolution = { kind:'submit', data:{ selected:[…] } }`.

This element wraps these SolidJS components — reach for them directly when you need finer control than the props expose.

TasksCard