getEditorItems
Builds the default editor field array from a CardShape (or EditorShape). The fields match the sections visible on the card.
Usage
import { getEditorItems } from "@svar-ui/svelte-kanban";
getEditorItems(shape?: EditorShape | CardShape): EditorItem[];
The returned array always starts with label (text input, required). Other fields follow, depending 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
Without arguments, the function uses the default shape from getCardShape(), which enables priority, progress, description, deadline, and tags.
Example
Mirror the card shape in the editor:
<script>
import {
Kanban,
Editor,
getEditorItems,
getCardShape,
} from "@svar-ui/svelte-kanban";
const card = {
...getCardShape(),
users: {
data: [
{ id: 1, label: "Alex" },
{ id: 2, label: "Sam" },
],
},
};
let api;
</script>
<Kanban {cards} {columns} {card} bind:this={api} />
<Editor {api} items={getEditorItems(card)} />
Pluck a single default field and customize it:
import { getEditorItems } from "@svar-ui/svelte-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