Loading component…
Loading component…
An agent deciding by a DMN decision table – the request on top, rules below checked row by row until the matching rule lights up with its outputs
To reuse this local React demo, copy all files from the Code tab into the same folder, then import DecisionTable from ./decision-table.
import { DecisionTable, type DecisionInput, type DecisionOutput, type DecisionRule } from "@/components/ui/decision-table";
const inputs: DecisionInput[] = [
{ id: "amount", label: "Amount", type: "number", format: (v) => `$${v}` },
{ id: "tier", label: "Tier", type: "string" },
{ id: "days", label: "Days", type: "number" },
];
const outputs: DecisionOutput[] = [{ id: "decision", label: "Decision" }];
const rules: DecisionRule[] = [
{ id: "r1", when: { amount: "> 500" }, then: { decision: { text: "Review", tone: "warn" } } },
{ id: "r2", when: { tier: '"Gold", "Platinum"', days: "<= 60" }, then: { decision: { text: "Approve", tone: "ok" } } },
{ id: "r3", when: {}, then: { decision: { text: "Reject", tone: "bad" } }, note: "Anything else" },
];
export function Refunds({ request }) {
return <DecisionTable name="Refund approval" hitPolicy="F" inputs={inputs} outputs={outputs} rules={rules} request={request} />;
}| Name | Type | Default | Description |
|---|---|---|---|
| name | string | The decision's name, in the head | |
| inputs | DecisionInput[] | The input columns – { id, label, type?, format?, width? }. format turns a request's value into its chip text; width is the column's weight against the others (default 1) | |
| outputs | DecisionOutput[] | The output columns, right of a quiet divider (where DMN draws its double rule) – { id, label, width? } | |
| rules | DecisionRule[] | One row per rule – { id, when, then, note? }. when maps input ids to DMN conditions (a missing one is "-", anything); then maps output ids to text or { text, tone?, logo? } – tone ok, warn, bad or info makes a badge | |
| hitPolicy | "U" \| "F" \| "P" \| "A" \| "C" | Unique, First, Priority, Any or Collect – shown in the corner. F stops at the first rule that matches; the others check every rule and show each match. Default F | |
| request | DecisionRequest | The request being decided – { id, name, photo?, source?, detail?, values }. A new id starts the check | |
| agent | { id, name } | The agent that decides – its pixel mark twinkles while it checks | |
| version | string | A small tag beside the name – "v3" | |
| history | DecisionRequest[] | Earlier requests as faces in the foot – with onPick, a click checks one again | |
| onPick | (requestId: string) => void | Called when a face in the foot is clicked | |
| onDecide | (ruleIds: string[]) => void | Called once a check is finished, with the rules that matched | |
| pace | number | Milliseconds per rule while checking – default 420 | |
| className | string | Extra class on the root – set the color variables on it, e.g. --ui-dmn-blue |
Below 800px the notes column steps aside – each rule's card still shows its note
Narrow: the request's chips wrap under the person, and the table scrolls sideways inside its frame
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"