UNPKG

@prismicio/types-internal

Version:
37 lines (36 loc) 1.76 kB
import type { RepeatableContent, SharedSliceItemContent, SliceItemContent, WidgetContent } from "../content"; import type { CompositeSlice, Group, NestableWidget, NestedGroup, StaticSlices, UID, VariationFields } from "../customtypes"; export declare type TraverseSliceContentFn = <S extends SliceItemContent | SharedSliceItemContent, D extends VariationFields | CompositeSlice | Group | NestableWidget>({ path, key, apiId, model, content, }: { path: ContentPath; key: string; apiId: string; model?: D | undefined; content: S; }) => S | SharedSliceItemContent | undefined; export declare type TraverseWidgetContentFn = <C extends WidgetContent | RepeatableContent, D extends NestableWidget | StaticSlices | Group | UID>({ path, key, apiId, model, content, }: { path: ContentPath; key: string; apiId: string; model?: D | undefined; content: C; }) => C | undefined; export declare type ContentPathEntry = { type: "CustomType" | "Widget" | "SharedSlice" | "Slice" | "LegacySlice" | "GroupItem" | "primary" | "items" | "RepeatableItem"; key: string; }; export declare type ContentPath = ReadonlyArray<ContentPathEntry>; export declare const ContentPath: { serialize(path: ContentPath): string; current(path: ContentPath): ContentPathEntry | undefined; append(path: string, strElement: string): string; make(entries: Array<{ key?: ContentPathEntry["key"] | undefined; type: ContentPathEntry["type"]; }>): ContentPath; }; export declare type SliceModel = VariationFields | NestableWidget | CompositeSlice | Group; export declare type OnFieldFn<T extends UID | NestableWidget | Group | NestedGroup> = (args: { path: ReadonlyArray<string>; key: string; field: T; }) => T;