UNPKG

@e280/quay

Version:

File-browser and outliner UI for the web

34 lines (33 loc) 1.56 kB
import { Codex } from "../codex.js"; import { Id, Kind, Schema } from "./types.js"; /** * Codex Item * - Quay's concept of a nestable thing. * - ergonomic handle which consolidates taxonomy, clade, and hierarchy functionality. */ export declare class CodexItem<Sc extends Schema = any, K extends Kind<Sc> = Kind<Sc>> { private codex; id: Id; signal: import("@benev/slate").Signal<this>; constructor(codex: Codex<Sc>, id: Id); get kind(): K; isKind<K2 extends Kind<Sc>>(kind: K2): this is CodexItem<Sc, K2>; /** get information about the type of entity */ get taxon(): Sc["taxon"]; /** get information about this specific entity */ get specimen(): Sc["specimens"][K]; /** get this item's parent item, or undefined if it's not attached */ get parent(): CodexItem<Sc> | undefined; /** get an array of this item's children */ get children(): CodexItem<Sc>[]; /** add items as children */ attach(...items: CodexItem<Sc>[]): this; /** detach this item from the hierarchy completely */ detach(): void; /** create a new item that will be a child */ create<K extends keyof Sc["specimens"]>(kind: K, specimen: Sc["specimens"][K]): CodexItem<Sc, keyof Sc["specimens"]>; /** create a new item that will be a child */ destroy(): void; /** iterate over this item and all its descendants */ crawl(predicate?: (item: CodexItem<Sc>, path: CodexItem<Sc>[]) => boolean): Generator<[CodexItem<Sc, keyof Sc["specimens"]>, CodexItem<Sc, keyof Sc["specimens"]>[]], void, unknown>; }