alinea
Version:
Headless git-based CMS
46 lines (45 loc) • 1.68 kB
TypeScript
import type { EntryFields } from 'alinea/core/EntryFields';
import type { Filter } from 'alinea/core/Filter';
import type { Graph, Projection } from 'alinea/core/Graph';
import type { Label } from 'alinea/core/Label';
import type { Picker } from 'alinea/core/Picker';
import { Type } from 'alinea/core/Type';
import { EntryReference } from './EntryReference.js';
export interface EditorInfo {
graph: Graph;
entry: {
id: string;
type: string;
workspace: string;
root: string;
parentId: string | null;
locale: string | null;
};
}
export interface EditorLocation {
parentId?: string;
workspace: string;
root: string;
}
type DynamicOption<T> = T | ((info: EditorInfo) => T | Promise<T>);
export interface EntryPickerConditions {
/** Choose from a flat list of direct children of the currently edited entry */
pickChildren?: boolean;
/** Set the initial location in which the entry picker is opened */
location?: DynamicOption<EditorLocation>;
/** Filter entries by a condition, this results in a flat list of options */
condition?: DynamicOption<Filter<EntryFields>>;
/** @internal Enable entry picker navigation */
enableNavigation?: boolean;
}
export interface EntryPickerOptions<Definition = {}> extends EntryPickerConditions {
selection: Projection;
defaultView?: 'row' | 'thumb';
showMedia?: boolean;
max?: number;
label?: string;
title?: Label;
fields?: Definition | Type<Definition>;
}
export declare function entryPicker<Ref extends EntryReference, Fields>(options: EntryPickerOptions<Fields>): Picker<Ref, EntryPickerOptions<Fields>>;
export {};