getEditorItems
Builds the default editor field array from a CardShape (or EditorShape). The result matches the sections visible on the card, so the editor form stays in sync with what users see on the board.
Usage
import { getEditorItems } from "@svar-ui/react-kanban";
getEditorItems(shape?: EditorShape | CardShape): EditorItem[];
The returned array always starts with label (text input, required). The remaining fields are appended based on the shape:
description- textareapriority- richselect; options come fromshape.priority.dataor fall back togetPriorityOptions()progress- slider, 0 to 1, step 0.1deadline- datepicker, clearabletags- multicombo; included only whenshape.tags.datais providedusers- multicombo; included only whenshape.users.datais provided
When called without arguments, the default shape is used (getCardShape()), which enables priority, progress, description, deadline, and tags.
Example
Mirror the card shape in the editor:
import { useState } from "react";
import { Kanban, Editor, getEditorItems, getCardShape } from "@svar-ui/react-kanban";
const card = {
...getCardShape(),
users: { data: [{ id: 1, label: "Alex" }, { id: 2, label: "Sam" }] },
menu: true,
};
function App() {
const [api, setApi] = useState(null);
return (
<>
<Kanban cards={cards} columns={columns} card={card} init={setApi} />
{api && <Editor api={api} items={getEditorItems(card)} />}
</>
);
}
Pluck a single default field and customize it:
import { getEditorItems } from "@svar-ui/react-kanban";
const priorityItem = getEditorItems().find(it => it.key === "priority");
const items = [
{ comp: "text", key: "label", label: "Title", required: true },
{ ...priorityItem, column: "right", required: true },
];
Related
- Editing guide - default and custom editor items
- Editor - the component that renders these items
- getCardShape - default shape used when no argument is passed
- getPriorityOptions - default priority data for the richselect