UNPKG

alinea

Version:
52 lines (51 loc) 1.95 kB
import type { ComponentType } from 'react'; import { type HasRoot } from './Internal.js'; import type { Label } from './Label.js'; import type { OrderBy } from './OrderBy.js'; import type { Page } from './Page.js'; import type { Preview } from './Preview.js'; import { Schema } from './Schema.js'; import { Type } from './Type.js'; import type { View } from './View.js'; export interface RootI18n { locales: ReadonlyArray<string>; } export interface RootMeta { /** Accepts entries of these types as children */ contains?: Array<string | Type>; /** Order children entries in the sidebar content tree */ orderChildrenBy?: OrderBy | Array<OrderBy>; icon?: ComponentType; i18n?: RootI18n; /** Point to a React component used to view this root in the dashboard */ view?: View<{ root: RootData; }>; isMediaRoot?: boolean; preview?: Preview; } export interface ChildrenDefinition { [key: string]: Page; } export interface RootData extends RootMeta { label: string; } export type Root<Children extends ChildrenDefinition = ChildrenDefinition> = Children & HasRoot; export declare namespace Root { function label(root: Root): Label; function contains(root: Root): Array<string | Type>; function data(root: Root): RootData; function preview(root: Root): Preview | undefined; function defaultLocale(root: Root): string | undefined; function isRoot(value: any): value is Root; function isMediaRoot(root: Root): boolean; function validate(root: Root, workspaceLabel: string, schema: Schema): void; function referencedViews(root: Root): Array<string>; } export interface RootOptions<Children> extends RootMeta { children?: Children; } export interface RootInternal extends RootOptions<ChildrenDefinition> { label: string; } export declare function root<Entries extends ChildrenDefinition>(label: string, config?: RootOptions<Entries>): Root<Entries>;