Use the source below in your application. Try the interactive component in Playground or Examples.
import '@blukavantui/community/theme.css'
import {createKanban} from '@blukavantui/pro/kanban';
import '@blukavantui/pro/kanban.css';
export function mount(host: HTMLElement) {
const approval=document.createElement('div');approval.setAttribute('role','region');approval.setAttribute('aria-label','Review transition');host.append(approval);
const board = createKanban(
host,
{
Resources:[{Key:"maya",Name:"Maya Chen",Position:"Design lead",Color:"Purple"}],
ShowFilters:true,SwimlaneField:'Team',
TransitionRules:[{FromColumnKey:'todo',ToColumnKey:'done',RequiresApproval:true,RequiredFields:'ResourceKey'}],
Columns: [
{ Key: "todo", Label: "To do", Color: "Primary" },
{ Key: "done", Label: "Done", Color: "Success" },
],
Cards: [
{ Key: "task-1", ColumnKey: "todo", Title: "Build the first page",BorderColor:"Purple",Team:"Product",ResourceKey:"maya",CardType:"Design",EstimatePoints:5,EstimateHours:8,ProjectTag:"Launch" },
],
AllowEditing: true,
EnableBulkSave: true,
AllowReorder: true,
},
{
TransitionRequested:(requestId,card,_from,to)=>{
approval.replaceChildren(document.createTextNode(`Move ${card.Title} to ${to}? `));
for(const [label,approved] of [['Approve',true],['Reject',false]] as const){const button=document.createElement('button');button.type='button';button.textContent=label;button.onclick=()=>{approval.replaceChildren();board.update({TransitionResultRequestId:requestId,TransitionResultApproved:approved,TransitionResultMessage:approved?'Approved.':'Move rejected.'});};approval.append(button);}
// Replace this demo decision with your authorized server approval workflow.
},
SaveRequested: (requestId, cards) => {
// Runnable local example. Replace this with an awaited request to your own backend.
try {
localStorage.setItem("bluui-starter-cards", JSON.stringify(cards));
board.update({
SaveResultRequestId: requestId,
SaveResultSuccess: true,
SaveResultCards: cards,
SaveResultMessage: "Saved in this browser.",
});
} catch {
board.update({
SaveResultRequestId: requestId,
SaveResultSuccess: false,
SaveResultMessage: "Saving failed. Your draft remains available.",
});
}
},
},
);
return {destroy(){board.destroy();approval.remove();}};
}
const instance = mount(document.getElementById('example')!)
// When this page or framework component is removed:
// instance.destroy()